khala-cli 0.4.9 → 0.4.11
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/dist/THIRD_PARTY_NOTICES.txt +28 -0
- package/dist/{chunk-DJM23SIU.mjs → chunk-3KHLSF4A.mjs} +7 -8
- package/dist/{chunk-PDZ5Z5ZE.mjs → chunk-4CENUF7M.mjs} +24 -9
- package/dist/{chunk-QKWEZXR3.mjs → chunk-4PUNVPC3.mjs} +12 -4
- package/dist/{chunk-WDOHRV3D.mjs → chunk-7FFHZ7EI.mjs} +14 -14
- package/dist/chunk-AQX2OYEF.mjs +19 -0
- package/dist/{chunk-ITFD3JZS.mjs → chunk-BVG7PJNZ.mjs} +424 -78
- package/dist/{chunk-NGSYOVQ4.mjs → chunk-CXVANPY5.mjs} +2 -2
- package/dist/chunk-CYINL2V3.mjs +20 -0
- package/dist/{chunk-KMLXOPBQ.mjs → chunk-E5QRD6W3.mjs} +4 -2
- package/dist/{chunk-FO5GXCST.mjs → chunk-FGHPOKXG.mjs} +5 -5
- package/dist/{chunk-FZEH2IXZ.mjs → chunk-GVZD4TLW.mjs} +180 -26
- package/dist/{chunk-V4F3SYKW.mjs → chunk-H2L5GQ5W.mjs} +25 -17
- package/dist/chunk-HZH74L5T.mjs +901 -0
- package/dist/{chunk-NPSQNCOY.mjs → chunk-JNSB3E6C.mjs} +13 -4
- package/dist/{chunk-7R3EIDGR.mjs → chunk-LDW4HOQW.mjs} +1 -1
- package/dist/chunk-LNKI3CZO.mjs +15 -0
- package/dist/{chunk-TEFOQXBK.mjs → chunk-MAIMFERG.mjs} +3 -3
- package/dist/chunk-MYIZQCRW.mjs +27 -0
- package/dist/{chunk-TANCKTDK.mjs → chunk-N6UYX3SY.mjs} +72 -5
- package/dist/{chunk-6BO3JSUP.mjs → chunk-NE4S7N3R.mjs} +2 -2
- package/dist/{chunk-BLCRVRIK.mjs → chunk-NJ5ICCVZ.mjs} +456 -87
- package/dist/{chunk-3R6HFSLL.mjs → chunk-NN5RHU6C.mjs} +92 -38
- package/dist/{chunk-NIX5F4LT.mjs → chunk-NOKTVPSY.mjs} +330 -66
- package/dist/{chunk-3KDOTR54.mjs → chunk-NUQSDSVT.mjs} +1 -1
- package/dist/{chunk-BEO7WIIM.mjs → chunk-OSVXLZKJ.mjs} +28 -8
- package/dist/{chunk-SSO5RFOX.mjs → chunk-R5NDTJRA.mjs} +1 -1
- package/dist/{chunk-K7V7X6WU.mjs → chunk-TVQ4MSEI.mjs} +21 -4
- package/dist/{chunk-BV45NK7K.mjs → chunk-VWWI4S5A.mjs} +100 -6
- package/dist/{chunk-UK5GJO4Y.mjs → chunk-WA5LB5GN.mjs} +6 -5
- package/dist/chunk-X3BAMHAR.mjs +14 -0
- package/dist/{chunk-PAJ4JJPV.mjs → chunk-YDEZFVF7.mjs} +43 -6
- package/dist/{chunk-GSZADJMW.mjs → chunk-YFX5NDSL.mjs} +338 -81
- package/dist/{chunk-ANSR4IAW.mjs → chunk-YIKJI26V.mjs} +2 -2
- package/dist/{chunk-T7IL7V7Q.mjs → chunk-YNUCRFM2.mjs} +13 -10
- package/dist/iterm2_send.py +56 -0
- package/dist/khala.mjs +11 -11
- package/dist/web/assets/local-DPcMk9Xz.css +1 -0
- package/dist/web/assets/local-SDOFp8OA.js +9 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/chunk-47XNLAJG.mjs +0 -38
- package/dist/chunk-LBT47HLZ.mjs +0 -19
- package/dist/chunk-P3YIN7G7.mjs +0 -26
- package/dist/chunk-XBQDIKB5.mjs +0 -18
- package/dist/chunk-XUCWSYVS.mjs +0 -148
- package/dist/web/assets/local-CFzRHZpB.js +0 -9
- package/dist/web/assets/local-ciypUFoK.css +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
init_define_KHALA_BUNDLE
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-LDW4HOQW.mjs";
|
|
5
5
|
|
|
6
6
|
// ../contracts/src/m1/harness.ts
|
|
7
7
|
init_define_KHALA_BUNDLE();
|
|
@@ -18,8 +18,8 @@ var HARNESS_REGISTRY = [
|
|
|
18
18
|
{ id: "copilot", displayName: "Copilot CLI", modelName: "Copilot", logoKey: "copilot", steer: true, sync: true, idleWake: "opt-in", registered: true },
|
|
19
19
|
{ id: "vscode", displayName: "Copilot (VS Code)", modelName: "VSCode", logoKey: "copilot", steer: true, sync: true, idleWake: "opt-in", registered: true },
|
|
20
20
|
{ id: "gemini", displayName: "Gemini CLI", modelName: "Gemini", logoKey: "gemini", steer: true, sync: true, idleWake: "opt-in", registered: true },
|
|
21
|
-
//
|
|
22
|
-
{ id: "antigravity", displayName: "Antigravity CLI", modelName: "Antigravity", logoKey: null, steer:
|
|
21
|
+
// Spike-backed capabilities; transport availability is reported per session.
|
|
22
|
+
{ id: "antigravity", displayName: "Antigravity CLI", modelName: "Antigravity", logoKey: null, steer: true, sync: true, idleWake: "opt-in", registered: true },
|
|
23
23
|
{ id: "qwen", displayName: "Qwen Code", modelName: "Qwen", logoKey: "qwen", steer: true, sync: true, idleWake: "default", registered: true },
|
|
24
24
|
{ id: "muse", displayName: "Muse Code", modelName: "Muse", logoKey: null, steer: true, sync: true, idleWake: "default", registered: true },
|
|
25
25
|
{ id: "generic", displayName: "MCP agent", modelName: "Agent", logoKey: null, steer: false, sync: false, idleWake: "none", registered: true }
|
|
@@ -328,6 +328,14 @@ function cachedProcessReader(read = readProcess) {
|
|
|
328
328
|
return result;
|
|
329
329
|
};
|
|
330
330
|
}
|
|
331
|
+
async function readProcessArguments(pid) {
|
|
332
|
+
if (!validPid(pid) || process.platform !== "linux") return null;
|
|
333
|
+
try {
|
|
334
|
+
return (await readFile(`/proc/${pid}/cmdline`, "utf8")).split("\0").slice(0, -1);
|
|
335
|
+
} catch {
|
|
336
|
+
return null;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
331
339
|
|
|
332
340
|
// src/state.ts
|
|
333
341
|
var SESSION_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;
|
|
@@ -512,7 +520,7 @@ async function readWatcherStatus(files, read = readProcess, now = () => /* @__PU
|
|
|
512
520
|
return writer && writer.startTime !== owner?.startTime ? { ...status, state: "disconnected", detail: "process_exited" } : status;
|
|
513
521
|
}
|
|
514
522
|
async function writeStateFile(dir, name, value) {
|
|
515
|
-
if (!["join.json", "session.json", "cursor.json", "status.json", "mode.json", "rejoin.json", "channel.json", "resume.json"].includes(name)) throw new StateError("storage_failed");
|
|
523
|
+
if (!["join.json", "session.json", "cursor.json", "status.json", "mode.json", "rejoin.json", "channel.json", "resume.json", "fold.json"].includes(name)) throw new StateError("storage_failed");
|
|
516
524
|
await writeJsonAtomic(path.join(dir, name), name === "status.json" ? await ownStatus(value) : value);
|
|
517
525
|
}
|
|
518
526
|
function readStateFile(dir, name) {
|
|
@@ -565,6 +573,7 @@ export {
|
|
|
565
573
|
ancestors,
|
|
566
574
|
nearestNonShellAncestor,
|
|
567
575
|
cachedProcessReader,
|
|
576
|
+
readProcessArguments,
|
|
568
577
|
SESSION_ID_PATTERN,
|
|
569
578
|
StateError,
|
|
570
579
|
stateRoot,
|
|
@@ -45,7 +45,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
45
45
|
var define_KHALA_BUNDLE_default;
|
|
46
46
|
var init_define_KHALA_BUNDLE = __esm({
|
|
47
47
|
"<define:__KHALA_BUNDLE__>"() {
|
|
48
|
-
define_KHALA_BUNDLE_default = { name: "khala-cli", version: "0.4.
|
|
48
|
+
define_KHALA_BUNDLE_default = { name: "khala-cli", version: "0.4.11" };
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
init_define_KHALA_BUNDLE
|
|
4
|
+
} from "./chunk-LDW4HOQW.mjs";
|
|
5
|
+
|
|
6
|
+
// src/matrix/decryption-retry.ts
|
|
7
|
+
init_define_KHALA_BUNDLE();
|
|
8
|
+
var DECRYPTION_RETRY_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
9
|
+
function retryUnexpired(entry, now = Date.now()) {
|
|
10
|
+
return entry.firstSeen <= now && now - entry.firstSeen <= DECRYPTION_RETRY_MAX_AGE_MS;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
retryUnexpired
|
|
15
|
+
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
listChannels
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-N6UYX3SY.mjs";
|
|
5
5
|
import {
|
|
6
6
|
TERMINAL_SESSION_DETAILS,
|
|
7
7
|
cachedProcessReader,
|
|
8
8
|
readStateFile,
|
|
9
9
|
readStatus,
|
|
10
10
|
validAgentRejoinSecret
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-JNSB3E6C.mjs";
|
|
12
12
|
import {
|
|
13
13
|
init_define_KHALA_BUNDLE
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-LDW4HOQW.mjs";
|
|
15
15
|
|
|
16
16
|
// src/session-start-wake.ts
|
|
17
17
|
init_define_KHALA_BUNDLE();
|
|
@@ -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-OSVXLZKJ.mjs";
|
|
10
|
+
import "./chunk-HZH74L5T.mjs";
|
|
11
|
+
import "./chunk-BVG7PJNZ.mjs";
|
|
12
|
+
import "./chunk-4PUNVPC3.mjs";
|
|
13
|
+
import "./chunk-NOKTVPSY.mjs";
|
|
14
|
+
import "./chunk-CXVANPY5.mjs";
|
|
15
|
+
import "./chunk-N6UYX3SY.mjs";
|
|
16
|
+
import "./chunk-VWWI4S5A.mjs";
|
|
17
|
+
import "./chunk-JNSB3E6C.mjs";
|
|
18
|
+
import "./chunk-TVQ4MSEI.mjs";
|
|
19
|
+
import "./chunk-LDW4HOQW.mjs";
|
|
20
|
+
export {
|
|
21
|
+
WAKE_USAGE,
|
|
22
|
+
consentLine,
|
|
23
|
+
cli_default as default,
|
|
24
|
+
runWake,
|
|
25
|
+
sessionIds,
|
|
26
|
+
setWake
|
|
27
|
+
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
decodeChannelEvent,
|
|
4
|
+
formatChannelEventLine
|
|
5
|
+
} from "./chunk-VWWI4S5A.mjs";
|
|
2
6
|
import {
|
|
3
7
|
StateError,
|
|
4
8
|
channelFiles,
|
|
@@ -10,10 +14,52 @@ import {
|
|
|
10
14
|
stateKey,
|
|
11
15
|
writeJsonAtomic,
|
|
12
16
|
writeStateFile
|
|
13
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-JNSB3E6C.mjs";
|
|
14
18
|
import {
|
|
15
19
|
init_define_KHALA_BUNDLE
|
|
16
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-LDW4HOQW.mjs";
|
|
21
|
+
|
|
22
|
+
// src/events/receive.ts
|
|
23
|
+
init_define_KHALA_BUNDLE();
|
|
24
|
+
function toEventInboxEntry(base, rawContent, you) {
|
|
25
|
+
const decoded = decodeChannelEvent(rawContent);
|
|
26
|
+
if (!decoded.ok) return null;
|
|
27
|
+
const content = decoded.value;
|
|
28
|
+
const to = content.kind === "handoff" ? String(content.data?.to ?? "").replace(/^@/u, "").toLowerCase() : "";
|
|
29
|
+
return {
|
|
30
|
+
entry: {
|
|
31
|
+
...base,
|
|
32
|
+
kind: "event",
|
|
33
|
+
body: formatChannelEventLine(content) + (content.url ? " " + content.url : ""),
|
|
34
|
+
eventKind: content.kind,
|
|
35
|
+
...content.data ? { data: content.data } : {},
|
|
36
|
+
...to && to === you?.toLowerCase() ? { mention: true } : {}
|
|
37
|
+
},
|
|
38
|
+
...content.key !== void 0 ? { key: content.key } : {}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function createEventKeyFilter() {
|
|
42
|
+
const seen = /* @__PURE__ */ new Set();
|
|
43
|
+
return (key) => {
|
|
44
|
+
if (key === void 0) return true;
|
|
45
|
+
if (seen.has(key)) return false;
|
|
46
|
+
seen.add(key);
|
|
47
|
+
return true;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function isWakeEntry(entry) {
|
|
51
|
+
return entry.kind === "message" || entry.mention === true;
|
|
52
|
+
}
|
|
53
|
+
var agentGroupMention = /(?<![\p{L}\p{N}_@])@(?:channel|agents)(?![\p{L}\p{N}_])/iu;
|
|
54
|
+
function mentions(entry, name) {
|
|
55
|
+
if (entry.kind === "message" && agentGroupMention.test(entry.body)) return true;
|
|
56
|
+
if (!name) return false;
|
|
57
|
+
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
58
|
+
return new RegExp(`(?<![\\p{L}\\p{N}_])@?${escaped}(?![\\p{L}\\p{N}_])`, "iu").test(entry.body);
|
|
59
|
+
}
|
|
60
|
+
function wakesAgent(entry, mode, you) {
|
|
61
|
+
return isWakeEntry(entry) && (mode !== "sync" || entry.senderKind !== "agent" || entry.mention === true || mentions(entry, you));
|
|
62
|
+
}
|
|
17
63
|
|
|
18
64
|
// src/inbox.ts
|
|
19
65
|
init_define_KHALA_BUNDLE();
|
|
@@ -63,16 +109,18 @@ async function unread(files) {
|
|
|
63
109
|
}
|
|
64
110
|
async function unreadCounts(files) {
|
|
65
111
|
const { entries } = await unread(files);
|
|
66
|
-
return { total: entries.length, messages: entries.filter((entry) => entry
|
|
112
|
+
return { total: entries.length, messages: entries.filter((entry) => isWakeEntry(entry)).length };
|
|
67
113
|
}
|
|
68
|
-
async function advanceCursor(files, expected, delivered) {
|
|
114
|
+
async function advanceCursor(files, expected, delivered, shown = false) {
|
|
69
115
|
const current = await readCursor(files);
|
|
70
116
|
if (current.deliveredCount !== expected.deliveredCount || current.lastDeliveredEventId !== expected.lastDeliveredEventId) return "conflict";
|
|
71
117
|
if (!delivered.length) return expected;
|
|
72
118
|
const entries = await readEntries(files);
|
|
73
119
|
const slice = entries.slice(expected.deliveredCount, expected.deliveredCount + delivered.length);
|
|
74
120
|
if (slice.length !== delivered.length || slice.some((entry, index) => entry.eventId !== delivered[index]?.eventId)) return "conflict";
|
|
75
|
-
const
|
|
121
|
+
const last = delivered[delivered.length - 1].eventId;
|
|
122
|
+
const shownEventId = shown ? last : current.shownEventId;
|
|
123
|
+
const next = { lastDeliveredEventId: last, deliveredCount: expected.deliveredCount + delivered.length, ...shownEventId ? { shownEventId } : {} };
|
|
76
124
|
await writeJsonAtomic(files.cursor, next);
|
|
77
125
|
return next;
|
|
78
126
|
}
|
|
@@ -208,11 +256,22 @@ function resolveChannel(list, ref) {
|
|
|
208
256
|
|
|
209
257
|
// src/activity.ts
|
|
210
258
|
init_define_KHALA_BUNDLE();
|
|
259
|
+
import * as fs3 from "node:fs/promises";
|
|
211
260
|
import path2 from "node:path";
|
|
212
261
|
async function readActivity(files) {
|
|
213
262
|
const activity = await readJson(path2.join(files.dir, "activity.json"));
|
|
214
263
|
return activity && ["idle", "busy"].includes(activity.state) && typeof activity.updatedAt === "string" && Number.isFinite(Date.parse(activity.updatedAt)) ? activity : { state: "busy", updatedAt: (/* @__PURE__ */ new Date(0)).toISOString() };
|
|
215
264
|
}
|
|
265
|
+
var USAGE_LIMIT = "usage-limit.json";
|
|
266
|
+
async function markUsageLimit(files, now = () => /* @__PURE__ */ new Date()) {
|
|
267
|
+
await writeJsonAtomic(path2.join(files.dir, USAGE_LIMIT), { at: now().toISOString() });
|
|
268
|
+
}
|
|
269
|
+
async function clearUsageLimit(files) {
|
|
270
|
+
await fs3.rm(path2.join(files.dir, USAGE_LIMIT), { force: true });
|
|
271
|
+
}
|
|
272
|
+
async function usageLimited(dir) {
|
|
273
|
+
return await readJson(path2.join(dir, USAGE_LIMIT)) !== null;
|
|
274
|
+
}
|
|
216
275
|
async function writeActivity(files, state, now = () => /* @__PURE__ */ new Date()) {
|
|
217
276
|
const activity = { state, updatedAt: now().toISOString() };
|
|
218
277
|
await writeJsonAtomic(path2.join(files.dir, "activity.json"), activity);
|
|
@@ -220,6 +279,11 @@ async function writeActivity(files, state, now = () => /* @__PURE__ */ new Date(
|
|
|
220
279
|
}
|
|
221
280
|
|
|
222
281
|
export {
|
|
282
|
+
toEventInboxEntry,
|
|
283
|
+
createEventKeyFilter,
|
|
284
|
+
isWakeEntry,
|
|
285
|
+
mentions,
|
|
286
|
+
wakesAgent,
|
|
223
287
|
readEntries,
|
|
224
288
|
readCursor,
|
|
225
289
|
unread,
|
|
@@ -231,5 +295,8 @@ export {
|
|
|
231
295
|
migrateLegacy,
|
|
232
296
|
resolveChannel,
|
|
233
297
|
readActivity,
|
|
298
|
+
markUsageLimit,
|
|
299
|
+
clearUsageLimit,
|
|
300
|
+
usageLimited,
|
|
234
301
|
writeActivity
|
|
235
302
|
};
|
|
@@ -2,10 +2,10 @@ import { createRequire as __khalaCreateRequire } from 'node:module'; const requi
|
|
|
2
2
|
import {
|
|
3
3
|
adapterFor,
|
|
4
4
|
resolveSources
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-BVG7PJNZ.mjs";
|
|
6
6
|
import {
|
|
7
7
|
init_define_KHALA_BUNDLE
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-LDW4HOQW.mjs";
|
|
9
9
|
|
|
10
10
|
// src/mcp/session-id.ts
|
|
11
11
|
init_define_KHALA_BUNDLE();
|