khala-cli 0.4.8 → 0.4.10
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/README.md +4 -4
- package/dist/THIRD_PARTY_NOTICES.txt +809 -0
- package/dist/chunk-2AMWQ7RB.mjs +1127 -0
- package/dist/chunk-3E5DH3Y6.mjs +9864 -0
- package/dist/{chunk-IQJQ4RF5.mjs → chunk-4BP7V3OP.mjs} +12 -1
- package/dist/{chunk-FV32AQTC.mjs → chunk-4BZQ4GVW.mjs} +10 -6
- package/dist/chunk-5JSGA6OB.mjs +1483 -0
- package/dist/chunk-6AQVW5W7.mjs +60 -0
- package/dist/{chunk-W6R4UJUQ.mjs → chunk-6J2PUM7L.mjs} +16 -9
- package/dist/chunk-6SUV3EW6.mjs +27 -0
- package/dist/{chunk-RNDUFTBF.mjs → chunk-ARIDZOTI.mjs} +499 -115
- package/dist/chunk-C2WEDMAF.mjs +15 -0
- package/dist/{chunk-Z4JF2M5C.mjs → chunk-CHC4VZF5.mjs} +9 -9
- package/dist/chunk-CKLCR5G4.mjs +1369 -0
- package/dist/chunk-EVT2DWNZ.mjs +58 -0
- package/dist/chunk-FJVVSKZ3.mjs +22 -0
- package/dist/{chunk-APMWDF6B.mjs → chunk-G3NMB4PY.mjs} +4 -2
- package/dist/chunk-HHEZVPRR.mjs +7 -0
- package/dist/{chunk-54XFVSEC.mjs → chunk-JKOJQTFT.mjs} +103 -5
- package/dist/{chunk-ZJ4W7P33.mjs → chunk-NDMFD5IM.mjs} +15 -10
- package/dist/{chunk-VKQ3KUYO.mjs → chunk-OEV5DFLW.mjs} +77 -7
- package/dist/chunk-OIZ4R5H7.mjs +173 -0
- package/dist/{chunk-CJTCU755.mjs → chunk-PJKI7SRI.mjs} +256 -26
- package/dist/chunk-PN25BUQ4.mjs +599 -0
- package/dist/chunk-QDPJ4VT2.mjs +432 -0
- package/dist/{chunk-2DHIAFEV.mjs → chunk-SRZTHCXP.mjs} +24 -10
- package/dist/chunk-TSK3HJEG.mjs +20 -0
- package/dist/chunk-UX34IVN5.mjs +33 -0
- package/dist/{chunk-BKLW2SPG.mjs → chunk-VAC3JTAV.mjs} +34 -17
- package/dist/{chunk-VAI7IUI4.mjs → chunk-VDZK4LW3.mjs} +30 -12
- package/dist/chunk-W6HM6F2U.mjs +901 -0
- package/dist/{chunk-H3K4GA2P.mjs → chunk-WPNMWNCL.mjs} +33 -21
- package/dist/chunk-WUDXHF2Q.mjs +14 -0
- package/dist/chunk-WZJ6DQJV.mjs +19 -0
- package/dist/{chunk-5LIE5GUU.mjs → chunk-XR625T3I.mjs} +5 -1
- package/dist/chunk-ZSKLNZWZ.mjs +224 -0
- package/dist/iterm2_send.py +56 -0
- package/dist/khala.mjs +20 -13
- package/dist/web/assets/local-CSPuGnH2.css +1 -0
- package/dist/web/assets/local-Dtyxaacx.js +9 -0
- package/dist/web/index.html +2 -2
- package/package.json +5 -3
- package/dist/chunk-2VCAW4GH.mjs +0 -34
- package/dist/chunk-5BQTYU66.mjs +0 -886
- package/dist/chunk-5GLTKWJ5.mjs +0 -1
- package/dist/chunk-5PUQT3YS.mjs +0 -569
- package/dist/chunk-7HBRFY3Z.mjs +0 -8
- package/dist/chunk-CBPLCCRZ.mjs +0 -191
- package/dist/chunk-FH34B3I3.mjs +0 -235
- package/dist/chunk-NKX3SLS7.mjs +0 -227
- package/dist/chunk-VUSV2ADL.mjs +0 -267
- package/dist/web/assets/local-BQl2KrE1.js +0 -9
- package/dist/web/assets/local-OwDq47O4.css +0 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
nearestNonShellAncestor,
|
|
4
|
+
readJson,
|
|
5
|
+
readProcess,
|
|
6
|
+
writeJsonAtomic
|
|
7
|
+
} from "./chunk-PN25BUQ4.mjs";
|
|
8
|
+
import {
|
|
9
|
+
init_define_KHALA_BUNDLE
|
|
10
|
+
} from "./chunk-EVT2DWNZ.mjs";
|
|
11
|
+
|
|
12
|
+
// src/wake/terminal/capture.ts
|
|
13
|
+
init_define_KHALA_BUNDLE();
|
|
14
|
+
import path from "node:path";
|
|
15
|
+
import { unlink } from "node:fs/promises";
|
|
16
|
+
var sessionUuid = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i;
|
|
17
|
+
function validPane(value) {
|
|
18
|
+
if (!value || typeof value !== "object") return false;
|
|
19
|
+
const pane = value;
|
|
20
|
+
return typeof pane.paneId === "string" && (pane.kind === "tmux" ? /^%\d+$/.test(pane.paneId) : pane.kind === "iterm2" ? sessionUuid.test(pane.paneId) : ["wezterm", "kitty"].includes(pane.kind) && /^\d+$/.test(pane.paneId)) && Number.isSafeInteger(pane.agentPid) && pane.agentPid > 0 && typeof pane.capturedAt === "string" && Number.isFinite(Date.parse(pane.capturedAt)) && (pane.socket === void 0 || typeof pane.socket === "string" && !pane.socket.includes("\0") && (pane.kind === "kitty" || pane.kind === "tmux" && pane.socket.startsWith("/"))) && (pane.agentStartTime === void 0 || typeof pane.agentStartTime === "string" && pane.agentStartTime.length > 0);
|
|
21
|
+
}
|
|
22
|
+
async function readPane(files) {
|
|
23
|
+
const pane = await readJson(path.join(files.dir, "pane.json"));
|
|
24
|
+
return validPane(pane) ? pane : null;
|
|
25
|
+
}
|
|
26
|
+
async function capturePane(files, env, options = {}) {
|
|
27
|
+
const file = path.join(files.dir, "pane.json");
|
|
28
|
+
const clear = async () => {
|
|
29
|
+
await unlink(file).catch((error) => {
|
|
30
|
+
if (error.code !== "ENOENT") throw error;
|
|
31
|
+
});
|
|
32
|
+
return null;
|
|
33
|
+
};
|
|
34
|
+
if ((options.platform ?? process.platform) === "win32") return clear();
|
|
35
|
+
let target;
|
|
36
|
+
if (env.TMUX) {
|
|
37
|
+
const socket = env.TMUX.match(/^(.*),\d+,\d+$/)?.[1];
|
|
38
|
+
if (!socket?.startsWith("/") || socket.includes("\0") || !/^%\d+$/.test(env.TMUX_PANE ?? "")) return clear();
|
|
39
|
+
target = { kind: "tmux", paneId: env.TMUX_PANE, socket };
|
|
40
|
+
} else if (/^\d+$/.test(env.WEZTERM_PANE ?? "")) target = { kind: "wezterm", paneId: env.WEZTERM_PANE };
|
|
41
|
+
else if (env.KITTY_WINDOW_ID !== void 0) {
|
|
42
|
+
if (!/^\d+$/.test(env.KITTY_WINDOW_ID)) return clear();
|
|
43
|
+
target = { kind: "kitty", paneId: env.KITTY_WINDOW_ID, ...env.KITTY_LISTEN_ON === void 0 ? {} : { socket: env.KITTY_LISTEN_ON } };
|
|
44
|
+
} else if (env.ITERM_SESSION_ID !== void 0) {
|
|
45
|
+
const uuid = /^w\d+t\d+p\d+:(.+)$/.exec(env.ITERM_SESSION_ID)?.[1];
|
|
46
|
+
if (!uuid || !sessionUuid.test(uuid)) return clear();
|
|
47
|
+
target = { kind: "iterm2", paneId: uuid };
|
|
48
|
+
} else return clear();
|
|
49
|
+
const agent = await nearestNonShellAncestor(options.pid ?? process.pid, options.readProcess ?? readProcess);
|
|
50
|
+
if (!agent) return clear();
|
|
51
|
+
const pane = { ...target, agentPid: agent.pid, agentStartTime: agent.startTime, capturedAt: (options.now ?? (() => /* @__PURE__ */ new Date()))().toISOString() };
|
|
52
|
+
if (!validPane(pane)) return clear();
|
|
53
|
+
await writeJsonAtomic(file, pane);
|
|
54
|
+
return pane;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export {
|
|
58
|
+
readPane,
|
|
59
|
+
capturePane
|
|
60
|
+
};
|
|
@@ -1,28 +1,35 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
sessionStartWakeChannels
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-4BZQ4GVW.mjs";
|
|
5
|
+
import {
|
|
6
|
+
capturePane
|
|
7
|
+
} from "./chunk-6AQVW5W7.mjs";
|
|
5
8
|
import {
|
|
6
9
|
listChannels,
|
|
7
10
|
writeActivity
|
|
8
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-OEV5DFLW.mjs";
|
|
12
|
+
import "./chunk-JKOJQTFT.mjs";
|
|
9
13
|
import {
|
|
10
14
|
TERMINAL_SESSION_DETAILS,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import
|
|
15
|
-
|
|
15
|
+
openSessionDir,
|
|
16
|
+
readJson
|
|
17
|
+
} from "./chunk-PN25BUQ4.mjs";
|
|
18
|
+
import {
|
|
19
|
+
init_define_KHALA_BUNDLE
|
|
20
|
+
} from "./chunk-EVT2DWNZ.mjs";
|
|
16
21
|
|
|
17
22
|
// hooks/session-start.ts
|
|
23
|
+
init_define_KHALA_BUNDLE();
|
|
18
24
|
async function run(stdin, argv) {
|
|
19
25
|
if (argv.length) return 0;
|
|
20
26
|
try {
|
|
21
27
|
const input = JSON.parse(stdin);
|
|
22
28
|
if (input?.hook_event_name !== "SessionStart" || typeof input.session_id !== "string") return 0;
|
|
23
|
-
const files =
|
|
29
|
+
const files = await openSessionDir("claude", input.session_id);
|
|
30
|
+
await capturePane(files, process.env);
|
|
24
31
|
const channels = await listChannels(files);
|
|
25
|
-
const statuses = channels.length ? await Promise.all(channels.map(async (channel) => ({ status: await
|
|
32
|
+
const statuses = channels.length ? await Promise.all(channels.map(async (channel) => ({ status: await readJson(channel.files.status), channelName: channel.channelName ?? channel.roomId }))) : [{ status: await readJson(files.status), channelName: void 0 }];
|
|
26
33
|
if (process.env.CLAUDE_CODE_ENTRYPOINT === "cli" && ["startup", "resume"].includes(input.source) && (await sessionStartWakeChannels(files, process.env)).length) {
|
|
27
34
|
await writeActivity(files, "idle");
|
|
28
35
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
WAKE_USAGE,
|
|
4
|
+
cli_default,
|
|
5
|
+
consentLine,
|
|
6
|
+
runWake,
|
|
7
|
+
sessionIds,
|
|
8
|
+
setWake
|
|
9
|
+
} from "./chunk-OIZ4R5H7.mjs";
|
|
10
|
+
import "./chunk-W6HM6F2U.mjs";
|
|
11
|
+
import "./chunk-5JSGA6OB.mjs";
|
|
12
|
+
import "./chunk-6AQVW5W7.mjs";
|
|
13
|
+
import "./chunk-2AMWQ7RB.mjs";
|
|
14
|
+
import "./chunk-4BP7V3OP.mjs";
|
|
15
|
+
import "./chunk-OEV5DFLW.mjs";
|
|
16
|
+
import "./chunk-JKOJQTFT.mjs";
|
|
17
|
+
import "./chunk-PN25BUQ4.mjs";
|
|
18
|
+
import "./chunk-ZSKLNZWZ.mjs";
|
|
19
|
+
import "./chunk-EVT2DWNZ.mjs";
|
|
20
|
+
export {
|
|
21
|
+
WAKE_USAGE,
|
|
22
|
+
consentLine,
|
|
23
|
+
cli_default as default,
|
|
24
|
+
runWake,
|
|
25
|
+
sessionIds,
|
|
26
|
+
setWake
|
|
27
|
+
};
|