@hivefloor/cli 0.1.5 → 0.1.8
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/LICENSE +6 -20
- package/README.md +29 -8
- package/dist/chunk-2ERPDCOT.js +38 -0
- package/dist/chunk-4G362W6G.js +19 -0
- package/dist/chunk-5OJUJCE3.js +817 -0
- package/dist/{chunk-U6RRUAC2.js → chunk-5XXYQQG6.js} +53 -8
- package/dist/chunk-AGIYVFDQ.js +10984 -0
- package/dist/{chunk-RYGL6XU4.js → chunk-BLLPDPTL.js} +4 -2
- package/dist/{chunk-3N5JYP5O.js → chunk-FPJNGKT5.js} +5 -3
- package/dist/chunk-HW3KRNCO.js +201 -0
- package/dist/{chunk-4DRHR7LR.js → chunk-HWBUESB4.js} +1158 -196
- package/dist/{chunk-C627OKTW.js → chunk-K2IRTZH5.js} +7 -6
- package/dist/chunk-KQMPCV57.js +122 -0
- package/dist/{chunk-J36OIJBM.js → chunk-L6EFW2SJ.js} +14 -10
- package/dist/{chunk-IJRHCDIG.js → chunk-LX5A25O6.js} +4 -2
- package/dist/{chunk-MZGGJ6ZS.js → chunk-MYJCU5JL.js} +4 -2
- package/dist/{chunk-H6NYMF2D.js → chunk-NMUH5NXN.js} +6 -4
- package/dist/{chunk-VX7SCIF2.js → chunk-NRJONTFT.js} +3 -1
- package/dist/chunk-QBBKGORP.js +327 -0
- package/dist/{chunk-SOXRITAW.js → chunk-QGULSOQ2.js} +3 -0
- package/dist/{chunk-6MDJB3BV.js → chunk-QLMLB7RB.js} +17 -9
- package/dist/{chunk-TKMIV7BG.js → chunk-QPAFN47B.js} +3 -1
- package/dist/chunk-SBOEAOHD.js +48 -0
- package/dist/{chunk-IWIDKNWC.js → chunk-TIR4CV3P.js} +21 -17
- package/dist/{chunk-6XVIEX75.js → chunk-X2KH6AR4.js} +25 -303
- package/dist/chunk-XAXKZ572.js +106 -0
- package/dist/{chunk-TPMFQUAW.js → chunk-XPGL7VYE.js} +12 -0
- package/dist/{cli-JCBZICR3.js → cli-BFOJWJNG.js} +56 -20
- package/dist/connect-ZJ4JXBAJ.js +27 -0
- package/dist/control-6GHTZQJV.js +25 -0
- package/dist/{disconnect-WQMDCUXT.js → disconnect-3T25NTKX.js} +24 -17
- package/dist/{hook-AYJNRGIY.js → hook-TPSHBCWU.js} +277 -17
- package/dist/index.js +9 -6
- package/dist/{link-ORT4LID6.js → link-EAS5F5PC.js} +14 -11
- package/dist/{machine-connect-N52CKQEW.js → machine-connect-KEI4BRWF.js} +23 -17
- package/dist/mcp-LVIYR3EN.js +1882 -0
- package/dist/orch-KVRL2YA2.js +137 -0
- package/dist/{run-ZAZ45MKQ.js → run-JL2OZWK3.js} +1920 -28
- package/dist/{status-GOCFNO7K.js → status-QXOOJGGN.js} +14 -11
- package/dist/{token-EMM4AJAU.js → token-BFWWQIDA.js} +10 -7
- package/dist/{voice-F5MIS3IZ.js → voice-QXHFXRWG.js} +5 -3
- package/dist/{where-XFXRTP7E.js → where-CMUORQIO.js} +11 -8
- package/package.json +5 -6
- package/dist/chunk-JCLWCMEM.js +0 -8
- package/dist/chunk-K3NQKI34.js +0 -10
- package/dist/chunk-X6B6R32A.js +0 -303
- package/dist/connect-2HLVPEOL.js +0 -23
- package/dist/mcp-2SF6Y73M.js +0 -118
|
@@ -1,48 +1,73 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __hfCreateRequire } from 'node:module';
|
|
3
|
+
const require = __hfCreateRequire(import.meta.url);
|
|
2
4
|
import {
|
|
3
|
-
HARD_EXIT_MS
|
|
4
|
-
|
|
5
|
+
HARD_EXIT_MS,
|
|
6
|
+
PERMISSION_HARD_STOP_MS,
|
|
7
|
+
PERMISSION_WAIT_MS
|
|
8
|
+
} from "./chunk-4G362W6G.js";
|
|
5
9
|
import {
|
|
6
10
|
detectRepo
|
|
7
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-BLLPDPTL.js";
|
|
8
12
|
import {
|
|
9
13
|
envTokenForHost
|
|
10
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-NMUH5NXN.js";
|
|
11
15
|
import {
|
|
12
16
|
defaultHost,
|
|
13
17
|
loadToken
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-QLMLB7RB.js";
|
|
19
|
+
import "./chunk-QPAFN47B.js";
|
|
16
20
|
import {
|
|
21
|
+
agentPidOf,
|
|
17
22
|
appendToSpool,
|
|
23
|
+
clientIdleSec,
|
|
18
24
|
contextEventName,
|
|
19
25
|
contextOutput,
|
|
26
|
+
findPane,
|
|
20
27
|
nudgesOf,
|
|
28
|
+
readSessions,
|
|
29
|
+
realProc,
|
|
21
30
|
releaseSpool,
|
|
31
|
+
senderName,
|
|
22
32
|
stashNudges,
|
|
33
|
+
takeDecision,
|
|
34
|
+
takeInbox,
|
|
23
35
|
takeSpool,
|
|
24
|
-
takeStashed
|
|
25
|
-
|
|
36
|
+
takeStashed,
|
|
37
|
+
updateSession,
|
|
38
|
+
validCwd,
|
|
39
|
+
validTranscript
|
|
40
|
+
} from "./chunk-5OJUJCE3.js";
|
|
41
|
+
import "./chunk-SBOEAOHD.js";
|
|
42
|
+
import {
|
|
43
|
+
controlOn,
|
|
44
|
+
readControl
|
|
45
|
+
} from "./chunk-KQMPCV57.js";
|
|
26
46
|
import {
|
|
27
47
|
readMachine,
|
|
28
48
|
serviceAlive
|
|
29
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-LX5A25O6.js";
|
|
50
|
+
import {
|
|
51
|
+
runFile
|
|
52
|
+
} from "./chunk-XAXKZ572.js";
|
|
30
53
|
import {
|
|
31
54
|
configDir,
|
|
32
55
|
machineSpoolFile
|
|
33
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-XPGL7VYE.js";
|
|
34
57
|
import {
|
|
35
58
|
DEFAULT_HOST,
|
|
36
59
|
assertTokenTransport,
|
|
37
60
|
hostFromEnv
|
|
38
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-QGULSOQ2.js";
|
|
39
62
|
import {
|
|
63
|
+
CONTROL_REPLY_MAX,
|
|
40
64
|
HOOK_BATCH_MAX,
|
|
41
65
|
PROFILE_KEY_RE,
|
|
42
66
|
SESSION_ACCOUNT_RE,
|
|
67
|
+
machinePromptResponse,
|
|
43
68
|
redact
|
|
44
|
-
} from "./chunk-
|
|
45
|
-
import "./chunk-
|
|
69
|
+
} from "./chunk-HWBUESB4.js";
|
|
70
|
+
import "./chunk-2ERPDCOT.js";
|
|
46
71
|
|
|
47
72
|
// src/hook.ts
|
|
48
73
|
import fs from "fs";
|
|
@@ -61,7 +86,13 @@ var NAMES = {
|
|
|
61
86
|
pretooluse: "tool_agent_pre",
|
|
62
87
|
posttooluse: "tool_agent_post"
|
|
63
88
|
};
|
|
64
|
-
var WAITING_TYPES = /* @__PURE__ */ new Set(["permission_prompt"
|
|
89
|
+
var WAITING_TYPES = /* @__PURE__ */ new Set(["permission_prompt"]);
|
|
90
|
+
function endsWithQuestion(text) {
|
|
91
|
+
const t = str(text);
|
|
92
|
+
if (!t) return false;
|
|
93
|
+
const last = t.split(/\r?\n/).map((l) => l.trim()).filter((l) => l !== "" && !/^```/.test(l)).pop() ?? "";
|
|
94
|
+
return /\?[\s*_)"'`]*$/.test(last);
|
|
95
|
+
}
|
|
65
96
|
var LINE_MAX = 140;
|
|
66
97
|
var str = (v) => typeof v === "string" && v.trim() !== "" ? v : void 0;
|
|
67
98
|
var rec = (v) => typeof v === "object" && v !== null && !Array.isArray(v) ? v : {};
|
|
@@ -118,6 +149,7 @@ function mapHookEvent(tool, native, input) {
|
|
|
118
149
|
case "stop": {
|
|
119
150
|
const s = statusLine(input.last_assistant_message) ?? statusLine(input.prompt_response);
|
|
120
151
|
if (s) out.status_line = s;
|
|
152
|
+
if (endsWithQuestion(input.last_assistant_message ?? input.prompt_response)) out.asks = true;
|
|
121
153
|
break;
|
|
122
154
|
}
|
|
123
155
|
default:
|
|
@@ -132,6 +164,170 @@ function cwdOf(input) {
|
|
|
132
164
|
|
|
133
165
|
// src/hook.ts
|
|
134
166
|
import path from "path";
|
|
167
|
+
|
|
168
|
+
// src/service/control/hookside.ts
|
|
169
|
+
import { randomBytes } from "crypto";
|
|
170
|
+
var EVENTS = {
|
|
171
|
+
sessionstart: "SessionStart",
|
|
172
|
+
sessionend: "SessionEnd",
|
|
173
|
+
userpromptsubmit: "UserPromptSubmit",
|
|
174
|
+
pretooluse: "PreToolUse",
|
|
175
|
+
posttooluse: "PostToolUse",
|
|
176
|
+
stop: "Stop",
|
|
177
|
+
notification: "Notification",
|
|
178
|
+
permissionrequest: "PermissionRequest"
|
|
179
|
+
};
|
|
180
|
+
var INBOX_EVENTS = /* @__PURE__ */ new Set(["SessionStart", "UserPromptSubmit", "PreToolUse", "PostToolUse"]);
|
|
181
|
+
var REPLY_WINDOW_MS = 30 * 6e4;
|
|
182
|
+
var POLL_MS = 250;
|
|
183
|
+
var TERMINAL_ACTIVE_SEC = 60;
|
|
184
|
+
var str2 = (v) => typeof v === "string" && v !== "" ? v : void 0;
|
|
185
|
+
var frameMessage = (from, text) => `Message from ${from} through HiveFloor: ${JSON.stringify(text)}`;
|
|
186
|
+
async function controlHookStep(tool, native, input, deps) {
|
|
187
|
+
const out = { texts: [] };
|
|
188
|
+
try {
|
|
189
|
+
const ctl = (deps.readControl ?? readControl)();
|
|
190
|
+
const on = controlOn(ctl);
|
|
191
|
+
const sid = str2(input.session_id);
|
|
192
|
+
const ev = EVENTS[native.toLowerCase()];
|
|
193
|
+
if (!sid || !ev || ev === "PermissionRequest" || tool !== "claude" && tool !== "codex") return out;
|
|
194
|
+
const now = deps.now();
|
|
195
|
+
if (ev === "SessionEnd") {
|
|
196
|
+
updateSession(sid, now, () => void 0);
|
|
197
|
+
return out;
|
|
198
|
+
}
|
|
199
|
+
const before = readSessions(now)[sid];
|
|
200
|
+
const proc = deps.proc ?? realProc(deps.run ?? runFile);
|
|
201
|
+
const agent = !before?.pid || before.ended || ev === "SessionStart" ? await agentPidOf(proc, deps.pid, deps.ppid) : void 0;
|
|
202
|
+
const cwdRaw = cwdOf(input);
|
|
203
|
+
const cwd = validCwd(cwdRaw) ? cwdRaw : void 0;
|
|
204
|
+
const transcript = tool === "claude" && validTranscript(input.transcript_path) ? input.transcript_path : void 0;
|
|
205
|
+
const idleNote = ev === "Notification" && input.notification_type !== "permission_prompt";
|
|
206
|
+
let closed;
|
|
207
|
+
updateSession(sid, now, (e) => {
|
|
208
|
+
const next = { ...e ?? { tool, event: idleNote ? "Stop" : ev, at: deps.startedAt }, tool };
|
|
209
|
+
if (next.ended && !agent) {
|
|
210
|
+
delete next.pid;
|
|
211
|
+
delete next.start;
|
|
212
|
+
}
|
|
213
|
+
delete next.ended;
|
|
214
|
+
if (cwd) next.cwd = cwd;
|
|
215
|
+
if (transcript) next.transcript = transcript;
|
|
216
|
+
if (agent) {
|
|
217
|
+
next.pid = agent.pid;
|
|
218
|
+
next.start = agent.start;
|
|
219
|
+
}
|
|
220
|
+
if (!idleNote && deps.startedAt >= next.at) {
|
|
221
|
+
next.event = ev;
|
|
222
|
+
next.at = deps.startedAt;
|
|
223
|
+
}
|
|
224
|
+
if (on && next.prompt_id && ev !== "Notification") {
|
|
225
|
+
closed = next.prompt_id;
|
|
226
|
+
delete next.prompt_id;
|
|
227
|
+
delete next.prompt_at;
|
|
228
|
+
}
|
|
229
|
+
return next;
|
|
230
|
+
});
|
|
231
|
+
if (!on) return out;
|
|
232
|
+
if (closed) await deps.post(`/api/v1/machine/prompts/${encodeURIComponent(closed)}/close`, {}, 1500);
|
|
233
|
+
if (tool !== "claude") return out;
|
|
234
|
+
if (INBOX_EVENTS.has(ev)) out.texts = takeInbox(sid, now).map((m) => frameMessage(senderName(m.from), m.text));
|
|
235
|
+
if (ev === "Stop") {
|
|
236
|
+
const text = str2(input.last_assistant_message);
|
|
237
|
+
const after = readSessions(now)[sid]?.msg_at;
|
|
238
|
+
const allowed = ctl.config.replies === "always" || ctl.config.replies === "after_message" && after !== void 0 && now - after <= REPLY_WINDOW_MS;
|
|
239
|
+
if (text && allowed) out.reply = redact(text).text.slice(0, CONTROL_REPLY_MAX);
|
|
240
|
+
}
|
|
241
|
+
} catch {
|
|
242
|
+
}
|
|
243
|
+
return out;
|
|
244
|
+
}
|
|
245
|
+
var allow = JSON.stringify({ hookSpecificOutput: { hookEventName: "PermissionRequest", decision: { behavior: "allow" } } });
|
|
246
|
+
var deny = (message) => JSON.stringify({ hookSpecificOutput: { hookEventName: "PermissionRequest", decision: { behavior: "deny", ...message ? { message } : {} } } });
|
|
247
|
+
function promptSummary(toolName, toolInput) {
|
|
248
|
+
let text = "";
|
|
249
|
+
try {
|
|
250
|
+
text = typeof toolInput === "string" ? toolInput : JSON.stringify(toolInput) ?? "";
|
|
251
|
+
} catch {
|
|
252
|
+
text = "";
|
|
253
|
+
}
|
|
254
|
+
return `${toolName}: ${redact(text).text.slice(0, 300)}`.slice(0, 600);
|
|
255
|
+
}
|
|
256
|
+
async function permissionHook(input, deps) {
|
|
257
|
+
let timer;
|
|
258
|
+
const hard = new Promise((resolve) => {
|
|
259
|
+
timer = setTimeout(() => resolve(void 0), PERMISSION_HARD_STOP_MS);
|
|
260
|
+
timer.unref?.();
|
|
261
|
+
});
|
|
262
|
+
try {
|
|
263
|
+
return await Promise.race([permissionInner(input, deps), hard]);
|
|
264
|
+
} catch {
|
|
265
|
+
return void 0;
|
|
266
|
+
} finally {
|
|
267
|
+
if (timer) clearTimeout(timer);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
async function permissionInner(input, deps) {
|
|
271
|
+
const ctl = (deps.readControl ?? readControl)();
|
|
272
|
+
const v = ctl.state === "ok" && ctl.config.enabled ? ctl.config.verbs : void 0;
|
|
273
|
+
if (!v || !v.approve && !v.deny) return void 0;
|
|
274
|
+
const sid = str2(input.session_id);
|
|
275
|
+
const toolName = str2(input.tool_name);
|
|
276
|
+
if (!sid || !toolName) return void 0;
|
|
277
|
+
const start = deps.now();
|
|
278
|
+
const run = deps.run ?? runFile;
|
|
279
|
+
const proc = deps.proc ?? realProc(run);
|
|
280
|
+
const sleep = deps.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
281
|
+
const promptId = randomBytes(16).toString("hex");
|
|
282
|
+
const agent = await agentPidOf(proc, deps.pid, deps.ppid);
|
|
283
|
+
updateSession(sid, start, (e) => ({
|
|
284
|
+
...e ?? { tool: "claude", event: "PermissionRequest", at: deps.startedAt },
|
|
285
|
+
tool: "claude",
|
|
286
|
+
...agent ? { pid: agent.pid, start: agent.start } : {},
|
|
287
|
+
event: "PermissionRequest",
|
|
288
|
+
at: Math.max(e?.at ?? 0, deps.startedAt),
|
|
289
|
+
prompt_id: promptId,
|
|
290
|
+
prompt_at: start
|
|
291
|
+
}));
|
|
292
|
+
const forget = () => updateSession(sid, deps.now(), (e) => {
|
|
293
|
+
if (!e || e.prompt_id !== promptId) return e;
|
|
294
|
+
const { prompt_id: _p, prompt_at: _a, ...rest } = e;
|
|
295
|
+
return rest;
|
|
296
|
+
});
|
|
297
|
+
const res = await deps.post("/api/v1/machine/prompts", { session_id: sid, prompt_id: promptId, tool_name: toolName, summary: promptSummary(toolName, input.tool_input) }, 3e3);
|
|
298
|
+
const hold = res && res.status >= 200 && res.status < 300 ? machinePromptResponse.safeParse(res.json) : void 0;
|
|
299
|
+
if (!hold?.success || !hold.data.hold) {
|
|
300
|
+
forget();
|
|
301
|
+
return void 0;
|
|
302
|
+
}
|
|
303
|
+
const pid = agent?.pid ?? readSessions(start)[sid]?.pid;
|
|
304
|
+
const pane = pid !== void 0 ? await findPane(run, proc, pid) : void 0;
|
|
305
|
+
const idle = pane ? await clientIdleSec(run, pane, deps.now()) : void 0;
|
|
306
|
+
if (idle !== void 0 && idle < TERMINAL_ACTIVE_SEC) {
|
|
307
|
+
await deps.post(`/api/v1/machine/prompts/${promptId}/close`, {}, 1500);
|
|
308
|
+
forget();
|
|
309
|
+
return void 0;
|
|
310
|
+
}
|
|
311
|
+
while (deps.now() - start < PERMISSION_WAIT_MS) {
|
|
312
|
+
const d = takeDecision(promptId);
|
|
313
|
+
if (d) {
|
|
314
|
+
forget();
|
|
315
|
+
return d.behavior === "allow" ? allow : deny(d.message);
|
|
316
|
+
}
|
|
317
|
+
await sleep(POLL_MS);
|
|
318
|
+
}
|
|
319
|
+
const last = takeDecision(promptId);
|
|
320
|
+
if (last) {
|
|
321
|
+
forget();
|
|
322
|
+
return last.behavior === "allow" ? allow : deny(last.message);
|
|
323
|
+
}
|
|
324
|
+
await deps.post(`/api/v1/machine/prompts/${promptId}/close`, {}, 1500);
|
|
325
|
+
forget();
|
|
326
|
+
return void 0;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// src/hook.ts
|
|
330
|
+
var CONTROL_STEP_MS = 1500;
|
|
135
331
|
var POST_TIMEOUT_MS = 2e3;
|
|
136
332
|
var EXIT_MARGIN_MS = 400;
|
|
137
333
|
var MIN_POST_MS = 250;
|
|
@@ -189,6 +385,52 @@ async function post(deps, host, token, events, timeoutMs, route = "/api/v1/hooks
|
|
|
189
385
|
return "retry";
|
|
190
386
|
}
|
|
191
387
|
}
|
|
388
|
+
function controlPost(deps, host, token) {
|
|
389
|
+
return async (route, body, timeoutMs) => {
|
|
390
|
+
try {
|
|
391
|
+
assertTokenTransport(host);
|
|
392
|
+
const res = await deps.fetch(`${host}${route}`, {
|
|
393
|
+
method: "POST",
|
|
394
|
+
headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
|
|
395
|
+
body: JSON.stringify(body),
|
|
396
|
+
redirect: "error",
|
|
397
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
398
|
+
});
|
|
399
|
+
const text = await res.text().catch(() => "");
|
|
400
|
+
let json;
|
|
401
|
+
try {
|
|
402
|
+
json = text ? JSON.parse(text) : void 0;
|
|
403
|
+
} catch {
|
|
404
|
+
json = void 0;
|
|
405
|
+
}
|
|
406
|
+
return { status: res.status, json };
|
|
407
|
+
} catch {
|
|
408
|
+
return void 0;
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
function controlDeps(deps, host, token, startedAt) {
|
|
413
|
+
return { now: deps.now, startedAt, pid: deps.pid ?? process.pid, ppid: deps.ppid ?? process.ppid, post: controlPost(deps, host, token), ...deps.control };
|
|
414
|
+
}
|
|
415
|
+
async function writeOut(deps, text) {
|
|
416
|
+
if (deps.write) {
|
|
417
|
+
deps.write(text);
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
await new Promise((resolve) => {
|
|
421
|
+
const t = setTimeout(resolve, 500);
|
|
422
|
+
try {
|
|
423
|
+
process.stdout.write(`${text}
|
|
424
|
+
`, () => {
|
|
425
|
+
clearTimeout(t);
|
|
426
|
+
resolve();
|
|
427
|
+
});
|
|
428
|
+
} catch {
|
|
429
|
+
clearTimeout(t);
|
|
430
|
+
resolve();
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
}
|
|
192
434
|
async function runHook(args, deps) {
|
|
193
435
|
try {
|
|
194
436
|
await runHookInner(args, deps, deps.now());
|
|
@@ -226,16 +468,34 @@ async function runHookInner(args, deps, startedAt) {
|
|
|
226
468
|
return;
|
|
227
469
|
}
|
|
228
470
|
if (grokId && !input.session_id && !input.conversation_id) input = { ...input, session_id: grokId };
|
|
471
|
+
const controlled = machine !== void 0 && profile !== void 0 && !grokId && (toolArg === "claude" || toolArg === "codex");
|
|
472
|
+
let ctl = { texts: [] };
|
|
473
|
+
if (controlled) {
|
|
474
|
+
const cd = controlDeps(deps, host, token, startedAt);
|
|
475
|
+
if (toolArg === "claude" && native.toLowerCase() === "permissionrequest") {
|
|
476
|
+
const out = await permissionHook(input, cd);
|
|
477
|
+
if (out) await writeOut(deps, out);
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
ctl = await Promise.race([controlHookStep(toolArg, native, input, cd), new Promise((r) => setTimeout(() => r({ texts: [] }), CONTROL_STEP_MS).unref())]);
|
|
481
|
+
}
|
|
229
482
|
const mapped = mapHookEvent(toolArg === "grok" ? "claude" : toolArg, native, input);
|
|
230
|
-
if (!mapped)
|
|
483
|
+
if (!mapped) {
|
|
484
|
+
const name = contextEventName(toolArg, native);
|
|
485
|
+
if (name && ctl.texts.length > 0) await writeOut(deps, contextOutput(name, ctl.texts));
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
231
488
|
const nowMs = deps.now();
|
|
232
489
|
const event = { ...mapped, tool, client_at: new Date(nowMs).toISOString() };
|
|
233
490
|
const contextName = grokId ? null : contextEventName(toolArg, native);
|
|
234
491
|
if (contextName) event.deliver = true;
|
|
235
|
-
|
|
492
|
+
if (ctl.reply && mapped.event === "stop") event.reply = ctl.reply;
|
|
493
|
+
const nudges = ctl.texts.map((text) => ({ session_id: event.session_id, text }));
|
|
236
494
|
const show = () => printNudges(deps, contextName, event.session_id, nudges, nowMs);
|
|
237
495
|
if (grokId && isDuplicate(`${tool}|${event.session_id}|${event.event}|${event.subagent_id ?? ""}`, nowMs)) return;
|
|
238
|
-
const
|
|
496
|
+
const reportedCwd = cwdOf(input);
|
|
497
|
+
if (validCwd(reportedCwd)) event.cwd = reportedCwd;
|
|
498
|
+
const repo = await detectRepo(reportedCwd ?? deps.cwd);
|
|
239
499
|
if (repo) event.repo = { remote: repo.remote, ...repo.branch ? { branch: repo.branch } : {}, ...repo.path ? { path: repo.path } : {} };
|
|
240
500
|
if (machine && profile !== void 0) {
|
|
241
501
|
const account = deps.env.FLEET_PROFILE?.trim();
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __hfCreateRequire } from 'node:module';
|
|
3
|
+
const require = __hfCreateRequire(import.meta.url);
|
|
2
4
|
import {
|
|
3
|
-
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
5
|
+
hardExitFor
|
|
6
|
+
} from "./chunk-4G362W6G.js";
|
|
7
|
+
import "./chunk-2ERPDCOT.js";
|
|
6
8
|
|
|
7
9
|
// src/index.ts
|
|
8
10
|
var argv = process.argv.slice(2);
|
|
9
11
|
if (argv[0] === "hook") {
|
|
10
12
|
process.on("uncaughtException", () => process.exit(0));
|
|
11
13
|
process.on("unhandledRejection", () => process.exit(0));
|
|
12
|
-
setTimeout(() => process.exit(0),
|
|
14
|
+
setTimeout(() => process.exit(0), hardExitFor(argv[2])).unref();
|
|
13
15
|
try {
|
|
14
|
-
const { runHookCli } = await import("./hook-
|
|
16
|
+
const { runHookCli } = await import("./hook-TPSHBCWU.js");
|
|
15
17
|
await runHookCli(argv.slice(1));
|
|
16
18
|
} catch {
|
|
17
19
|
}
|
|
18
20
|
process.exit(0);
|
|
19
21
|
} else {
|
|
20
|
-
const { run } = await import("./cli-
|
|
22
|
+
const { run } = await import("./cli-BFOJWJNG.js");
|
|
21
23
|
process.exitCode = await run(argv);
|
|
24
|
+
if (argv[0] === "service") process.exit(process.exitCode);
|
|
22
25
|
}
|
|
@@ -1,37 +1,40 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __hfCreateRequire } from 'node:module';
|
|
3
|
+
const require = __hfCreateRequire(import.meta.url);
|
|
2
4
|
import {
|
|
3
5
|
deviceLogin
|
|
4
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-FPJNGKT5.js";
|
|
5
7
|
import {
|
|
6
8
|
detectRepo
|
|
7
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-BLLPDPTL.js";
|
|
8
10
|
import {
|
|
9
11
|
resolveSession
|
|
10
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-NMUH5NXN.js";
|
|
11
13
|
import {
|
|
12
14
|
saveToken
|
|
13
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-QLMLB7RB.js";
|
|
14
16
|
import {
|
|
15
17
|
checkUnknownFlags,
|
|
16
18
|
flagStr
|
|
17
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-QPAFN47B.js";
|
|
18
20
|
import {
|
|
19
21
|
VERSION
|
|
20
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-K2IRTZH5.js";
|
|
21
23
|
import {
|
|
22
24
|
apiRequest,
|
|
23
25
|
errorOf
|
|
24
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-NRJONTFT.js";
|
|
27
|
+
import "./chunk-XAXKZ572.js";
|
|
25
28
|
import {
|
|
26
29
|
isTool
|
|
27
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-XPGL7VYE.js";
|
|
28
31
|
import {
|
|
29
32
|
machineName
|
|
30
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-QGULSOQ2.js";
|
|
31
34
|
import {
|
|
32
35
|
cliNpxCommand
|
|
33
|
-
} from "./chunk-
|
|
34
|
-
import "./chunk-
|
|
36
|
+
} from "./chunk-HWBUESB4.js";
|
|
37
|
+
import "./chunk-2ERPDCOT.js";
|
|
35
38
|
|
|
36
39
|
// src/link.ts
|
|
37
40
|
var LINK_FLAGS = /* @__PURE__ */ new Set(["project", "new", "path", "tool", "host", "no-open", "help", "h"]);
|
|
@@ -1,54 +1,60 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __hfCreateRequire } from 'node:module';
|
|
3
|
+
const require = __hfCreateRequire(import.meta.url);
|
|
2
4
|
import {
|
|
3
5
|
resolveHost
|
|
4
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-TIR4CV3P.js";
|
|
5
7
|
import {
|
|
6
8
|
deviceLogin
|
|
7
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-FPJNGKT5.js";
|
|
8
10
|
import {
|
|
9
11
|
installCliCopy,
|
|
10
12
|
installMachineHooks
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-5XXYQQG6.js";
|
|
14
|
+
import "./chunk-4G362W6G.js";
|
|
15
|
+
import "./chunk-QBBKGORP.js";
|
|
16
|
+
import "./chunk-X2KH6AR4.js";
|
|
17
|
+
import "./chunk-BLLPDPTL.js";
|
|
14
18
|
import {
|
|
15
19
|
installService,
|
|
16
20
|
windowsUser
|
|
17
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-QLMLB7RB.js";
|
|
18
22
|
import {
|
|
19
23
|
flagStr
|
|
20
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-QPAFN47B.js";
|
|
21
25
|
import {
|
|
22
26
|
claudeDirsOfScan,
|
|
23
27
|
cliVersionOs,
|
|
24
28
|
scanProcesses
|
|
25
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-MYJCU5JL.js";
|
|
26
30
|
import {
|
|
27
31
|
VERSION
|
|
28
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-K2IRTZH5.js";
|
|
33
|
+
import "./chunk-KQMPCV57.js";
|
|
29
34
|
import {
|
|
30
35
|
codexConfigDir
|
|
31
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-L6EFW2SJ.js";
|
|
32
37
|
import {
|
|
33
38
|
readMachine,
|
|
34
39
|
secureWindowsMachine,
|
|
35
40
|
writeMachine
|
|
36
|
-
} from "./chunk-
|
|
37
|
-
import "./chunk-
|
|
41
|
+
} from "./chunk-LX5A25O6.js";
|
|
42
|
+
import "./chunk-NRJONTFT.js";
|
|
43
|
+
import "./chunk-XAXKZ572.js";
|
|
38
44
|
import {
|
|
39
45
|
cliEntry,
|
|
40
46
|
findBin
|
|
41
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-XPGL7VYE.js";
|
|
42
48
|
import {
|
|
43
49
|
machineName,
|
|
44
50
|
normalizeHost,
|
|
45
51
|
runCmd
|
|
46
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-QGULSOQ2.js";
|
|
47
53
|
import {
|
|
48
54
|
cliNpxCommand,
|
|
49
55
|
machineTokenSuccessSchema
|
|
50
|
-
} from "./chunk-
|
|
51
|
-
import "./chunk-
|
|
56
|
+
} from "./chunk-HWBUESB4.js";
|
|
57
|
+
import "./chunk-2ERPDCOT.js";
|
|
52
58
|
|
|
53
59
|
// src/machine-connect.ts
|
|
54
60
|
import fs from "fs";
|
|
@@ -106,7 +112,7 @@ async function connectMachine(ctx, p) {
|
|
|
106
112
|
state.installed.claude_dirs = hooks.claude_dirs;
|
|
107
113
|
if (hooks.codex_dir) {
|
|
108
114
|
state.installed.codex_dir = hooks.codex_dir;
|
|
109
|
-
warnings.push("Codex asks you to trust new hooks: run codex, open /hooks and approve the
|
|
115
|
+
warnings.push("Codex asks you to trust new hooks: run codex, open /hooks and approve the HiveFloor hooks once.");
|
|
110
116
|
}
|
|
111
117
|
writeMachine(state);
|
|
112
118
|
if (p.flags["no-service"]) {
|