khala-cli 0.4.17 → 0.4.19
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/{chunk-AXJRW3YA.mjs → chunk-2CM6MFLQ.mjs} +8 -7
- package/dist/chunk-5T2T2BGP.mjs +25 -0
- package/dist/{chunk-4FHEEYBQ.mjs → chunk-6CUBZHAI.mjs} +53 -11
- package/dist/{chunk-BOVWVPZ4.mjs → chunk-7BR55Y3K.mjs} +2 -2
- package/dist/{chunk-AIMS2KTW.mjs → chunk-7JLJ2IVR.mjs} +19 -81
- package/dist/{chunk-JNJIEPTE.mjs → chunk-A76X5SLZ.mjs} +9 -7
- package/dist/{chunk-OMTRW7ZJ.mjs → chunk-BUFSSWDE.mjs} +1 -1
- package/dist/{chunk-S2DVXLX5.mjs → chunk-CR2MQIB4.mjs} +30 -15
- package/dist/{chunk-BL6XGS7X.mjs → chunk-DP24LQAW.mjs} +44 -22
- package/dist/{chunk-MBGNVMCW.mjs → chunk-ERWPSB27.mjs} +1 -1
- package/dist/{chunk-DRQSMMA3.mjs → chunk-I3UIC3DD.mjs} +2 -2
- package/dist/chunk-IH5ALDEX.mjs +17 -0
- package/dist/{chunk-SRJIIZYI.mjs → chunk-JALXEI56.mjs} +3 -3
- package/dist/{chunk-5TVMOFQN.mjs → chunk-K7YTGI7R.mjs} +6 -6
- package/dist/chunk-LOVF37KO.mjs +72 -0
- package/dist/{chunk-QLXFYQJT.mjs → chunk-LUQ2K5K2.mjs} +11 -13
- package/dist/chunk-LZXXWDKB.mjs +18 -0
- package/dist/{chunk-WGVVAKZL.mjs → chunk-ME3G775Q.mjs} +140 -5
- package/dist/{chunk-H3B7UAJM.mjs → chunk-NDII2VEP.mjs} +1 -1
- package/dist/{chunk-3J6GKPIV.mjs → chunk-NYMXWKOF.mjs} +2 -2
- package/dist/{chunk-F33TZMSA.mjs → chunk-OFLK3DF2.mjs} +1 -1
- package/dist/{chunk-HA3NHQ2V.mjs → chunk-OPBCYCDJ.mjs} +24 -26
- package/dist/{chunk-2XSE7NIJ.mjs → chunk-POSW5KU5.mjs} +30 -28
- package/dist/{chunk-TZJA43Q5.mjs → chunk-PQ6Y7QRL.mjs} +7 -7
- package/dist/{chunk-FUFXUHYJ.mjs → chunk-PXNKY5ZM.mjs} +8 -10
- package/dist/{chunk-M4J4H3IJ.mjs → chunk-Q2ENNHOG.mjs} +3 -3
- package/dist/{chunk-XM6NMJGJ.mjs → chunk-RYBGLMUZ.mjs} +2 -2
- package/dist/{chunk-MEN4C4E4.mjs → chunk-TJUM3DPB.mjs} +1 -1
- package/dist/{chunk-2AP7E7SS.mjs → chunk-TZLAEDD2.mjs} +12 -5
- package/dist/{chunk-JSWOO4QR.mjs → chunk-UI5OJ2TY.mjs} +3 -3
- package/dist/{chunk-JHBYHSZZ.mjs → chunk-V5SWPOLN.mjs} +178 -97
- package/dist/{chunk-WLXW2EJZ.mjs → chunk-WOHXD3RS.mjs} +436 -132
- package/dist/{chunk-KPGNHSRB.mjs → chunk-YN334EWZ.mjs} +2 -2
- package/dist/khala.mjs +11 -11
- package/dist/web/assets/local-NETsM4LU.css +1 -0
- package/dist/web/assets/local-SRORuW7r.js +13 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/chunk-HKDKE7LO.mjs +0 -138
- package/dist/chunk-HNTESR25.mjs +0 -323
- package/dist/chunk-MQ2SOR5R.mjs +0 -27
- package/dist/chunk-QTK3UCD5.mjs +0 -20
- package/dist/chunk-ZW4COOHQ.mjs +0 -19
- package/dist/web/assets/local-DfWzk9Rp.js +0 -13
- package/dist/web/assets/local-rpKMAzbU.css +0 -1
|
@@ -1,42 +1,41 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
retryUnexpired
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-BUFSSWDE.mjs";
|
|
5
5
|
import {
|
|
6
6
|
IMAGE_MAX_BYTES,
|
|
7
7
|
RESTORE_HISTORY_MAX_PAGES
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-6CUBZHAI.mjs";
|
|
9
|
+
import "./chunk-TJUM3DPB.mjs";
|
|
10
10
|
import {
|
|
11
|
+
CHANNEL_EVENT_TYPE,
|
|
11
12
|
LISTENING_MODE_COMMAND_TYPE,
|
|
12
13
|
LISTENING_MODE_MEMBER_KEY,
|
|
13
|
-
memberListeningMode
|
|
14
|
-
} from "./chunk-HKDKE7LO.mjs";
|
|
15
|
-
import {
|
|
16
|
-
CHANNEL_EVENT_TYPE,
|
|
17
14
|
encodeChannelEvent,
|
|
15
|
+
memberListeningMode,
|
|
18
16
|
memberRenameContent
|
|
19
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-ME3G775Q.mjs";
|
|
20
18
|
import {
|
|
21
19
|
StateError
|
|
22
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-YN334EWZ.mjs";
|
|
23
21
|
import {
|
|
24
22
|
init_define_KHALA_BUNDLE
|
|
25
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-NDII2VEP.mjs";
|
|
26
24
|
|
|
27
25
|
// src/matrix/session.ts
|
|
28
26
|
init_define_KHALA_BUNDLE();
|
|
29
27
|
|
|
30
28
|
// ../contracts/src/m1/archive.ts
|
|
31
29
|
init_define_KHALA_BUNDLE();
|
|
32
|
-
var
|
|
33
|
-
function
|
|
34
|
-
|
|
30
|
+
var ARCHIVE_NOTICE_TYPE = "com.khala.archive.v1";
|
|
31
|
+
function decodeArchiveNotice(content) {
|
|
32
|
+
const c = content;
|
|
33
|
+
return typeof c === "object" && c !== null && c.v === 1 && typeof c.room_id === "string" && typeof c.archived === "boolean" ? { v: 1, room_id: c.room_id, archived: c.archived } : void 0;
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
// src/matrix/session.ts
|
|
38
37
|
import { randomUUID } from "node:crypto";
|
|
39
|
-
import { createClient, ClientEvent, RoomEvent,
|
|
38
|
+
import { createClient, ClientEvent, RoomEvent, MatrixEventEvent, SyncState, SetPresence, Direction, Method, EventType } from "matrix-js-sdk";
|
|
40
39
|
function message(event) {
|
|
41
40
|
const type = event.getType();
|
|
42
41
|
const eventId = event.getId();
|
|
@@ -60,24 +59,27 @@ async function createAgentMatrixSession(creds, opts) {
|
|
|
60
59
|
const started = Date.now();
|
|
61
60
|
const rejoinTxnId = `khala.rejoin.${randomUUID()}`;
|
|
62
61
|
const log = (line) => opts?.log?.(line);
|
|
63
|
-
const persistent = opts?.cryptoStore ? await (await import("./chunk-
|
|
62
|
+
const persistent = opts?.cryptoStore ? await (await import("./chunk-UI5OJ2TY.mjs")).openCryptoStore(opts.cryptoStore.dir, opts.cryptoStore.root, creds) : void 0;
|
|
64
63
|
const client = createClient({ ...persistent ? { store: persistent.sync } : {}, baseUrl: creds.homeserver, userId: creds.userId, accessToken: creds.accessToken, deviceId: creds.deviceId });
|
|
65
64
|
const handlers = /* @__PURE__ */ new Set();
|
|
66
65
|
const ended = /* @__PURE__ */ new Set();
|
|
67
66
|
const modeHandlers = /* @__PURE__ */ new Set();
|
|
68
67
|
const inviters = /* @__PURE__ */ new Map();
|
|
69
68
|
const archiveHandlers = /* @__PURE__ */ new Set();
|
|
69
|
+
const archiveNotices = /* @__PURE__ */ new Map();
|
|
70
70
|
const ownerArchived = (roomId) => {
|
|
71
|
-
const
|
|
72
|
-
return
|
|
71
|
+
const notice = archiveNotices.get(roomId);
|
|
72
|
+
return notice && notice.sender === inviters.get(roomId) ? notice.archived : void 0;
|
|
73
73
|
};
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
if (stopped || !
|
|
77
|
-
|
|
74
|
+
const archiveNotice = ({ message: m }) => {
|
|
75
|
+
const notice = m.type === ARCHIVE_NOTICE_TYPE ? decodeArchiveNotice(m.content) : void 0;
|
|
76
|
+
if (stopped || !notice) return;
|
|
77
|
+
archiveNotices.set(notice.room_id, { sender: m.sender, archived: notice.archived });
|
|
78
|
+
const archived = ownerArchived(notice.room_id);
|
|
79
|
+
if (archived === void 0) return;
|
|
78
80
|
for (const handler of archiveHandlers) {
|
|
79
81
|
try {
|
|
80
|
-
handler(
|
|
82
|
+
handler(notice.room_id, archived);
|
|
81
83
|
} catch {
|
|
82
84
|
log("archive_handler_error");
|
|
83
85
|
}
|
|
@@ -109,8 +111,8 @@ async function createAgentMatrixSession(creds, opts) {
|
|
|
109
111
|
let presenceTimer;
|
|
110
112
|
let away;
|
|
111
113
|
const publishPresence = () => {
|
|
112
|
-
void client.setSyncPresence(away ? SetPresence.
|
|
113
|
-
void client.setPresence(away ? { presence: "
|
|
114
|
+
void client.setSyncPresence(away ? SetPresence.Unavailable : void 0);
|
|
115
|
+
void client.setPresence(away ? { presence: "unavailable", status_msg: away } : { presence: "online", status_msg: "" }).catch(() => log("presence_failed"));
|
|
114
116
|
};
|
|
115
117
|
let recovering = persistent?.restored ?? false;
|
|
116
118
|
const deliver = (event) => {
|
|
@@ -273,7 +275,7 @@ async function createAgentMatrixSession(creds, opts) {
|
|
|
273
275
|
client.removeListener(RoomEvent.Timeline, timeline);
|
|
274
276
|
client.removeListener(MatrixEventEvent.Decrypted, decrypted);
|
|
275
277
|
client.removeListener(ClientEvent.Sync, syncLog);
|
|
276
|
-
client.removeListener(
|
|
278
|
+
client.removeListener(ClientEvent.ReceivedToDeviceMessage, archiveNotice);
|
|
277
279
|
client.removeListener(RoomEvent.MyMembership, membershipEnded);
|
|
278
280
|
for (const cancel of [...cancellations]) cancel();
|
|
279
281
|
liveEvents.clear();
|
|
@@ -316,7 +318,7 @@ async function createAgentMatrixSession(creds, opts) {
|
|
|
316
318
|
await client.initRustCrypto(persistent ? { useIndexedDB: true, cryptoDatabasePrefix: persistent.prefix } : { useIndexedDB: false });
|
|
317
319
|
} catch (error) {
|
|
318
320
|
if (!persistent?.restored || error instanceof StateError && error.code === "unsafe_state_dir") throw error;
|
|
319
|
-
throw new (await import("./chunk-
|
|
321
|
+
throw new (await import("./chunk-UI5OJ2TY.mjs")).CryptoStoreCorruptError();
|
|
320
322
|
}
|
|
321
323
|
const crypto = client.getCrypto();
|
|
322
324
|
if (!crypto) throw new Error("crypto_unavailable");
|
|
@@ -335,7 +337,7 @@ async function createAgentMatrixSession(creds, opts) {
|
|
|
335
337
|
client.on(RoomEvent.Timeline, timeline);
|
|
336
338
|
client.on(MatrixEventEvent.Decrypted, decrypted);
|
|
337
339
|
client.on(ClientEvent.Sync, syncLog);
|
|
338
|
-
client.on(
|
|
340
|
+
client.on(ClientEvent.ReceivedToDeviceMessage, archiveNotice);
|
|
339
341
|
const prepared = wait((check) => {
|
|
340
342
|
client.on(ClientEvent.Sync, check);
|
|
341
343
|
return () => {
|
|
@@ -630,8 +632,8 @@ async function createAgentMatrixSession(creds, opts) {
|
|
|
630
632
|
const user = client.getUser(member.userId);
|
|
631
633
|
const event = user?.events.presence;
|
|
632
634
|
if (!user || !event) return { name: member.name, presence: "unknown" };
|
|
633
|
-
if (user.presence !== "offline") return { name: member.name, presence: "online" };
|
|
634
635
|
const reason = event.getContent().status_msg;
|
|
636
|
+
if (user.presence !== "offline" && !(user.presence === "unavailable" && reason)) return { name: member.name, presence: "online" };
|
|
635
637
|
return {
|
|
636
638
|
name: member.name,
|
|
637
639
|
presence: "away",
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
WATCH_USAGE,
|
|
4
|
+
claudeWatchCommand,
|
|
4
5
|
monitorArmed,
|
|
5
6
|
monitorOwner,
|
|
6
7
|
run,
|
|
7
8
|
watchSession
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-F33TZMSA.mjs";
|
|
14
|
-
import "./chunk-H3B7UAJM.mjs";
|
|
9
|
+
} from "./chunk-WOHXD3RS.mjs";
|
|
10
|
+
import "./chunk-ME3G775Q.mjs";
|
|
11
|
+
import "./chunk-YN334EWZ.mjs";
|
|
12
|
+
import "./chunk-OFLK3DF2.mjs";
|
|
13
|
+
import "./chunk-NDII2VEP.mjs";
|
|
15
14
|
export {
|
|
16
15
|
WATCH_USAGE,
|
|
16
|
+
claudeWatchCommand,
|
|
17
17
|
run as default,
|
|
18
18
|
monitorArmed,
|
|
19
19
|
monitorOwner,
|
|
@@ -14,21 +14,19 @@ import {
|
|
|
14
14
|
decodeLocalSendResult,
|
|
15
15
|
ensureHelper,
|
|
16
16
|
localRoomPath
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import {
|
|
22
|
-
LISTENING_MODE_COMMAND_TYPE
|
|
23
|
-
} from "./chunk-HKDKE7LO.mjs";
|
|
17
|
+
} from "./chunk-TZLAEDD2.mjs";
|
|
18
|
+
import "./chunk-TJUM3DPB.mjs";
|
|
19
|
+
import "./chunk-7BR55Y3K.mjs";
|
|
20
|
+
import "./chunk-ERWPSB27.mjs";
|
|
24
21
|
import {
|
|
25
22
|
CHANNEL_EVENT_TYPE,
|
|
23
|
+
LISTENING_MODE_COMMAND_TYPE,
|
|
26
24
|
memberRenameContent
|
|
27
|
-
} from "./chunk-
|
|
28
|
-
import "./chunk-
|
|
25
|
+
} from "./chunk-ME3G775Q.mjs";
|
|
26
|
+
import "./chunk-YN334EWZ.mjs";
|
|
29
27
|
import {
|
|
30
28
|
init_define_KHALA_BUNDLE
|
|
31
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-NDII2VEP.mjs";
|
|
32
30
|
|
|
33
31
|
// src/local/session.ts
|
|
34
32
|
init_define_KHALA_BUNDLE();
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
checkName,
|
|
5
5
|
isDefaultAgentName,
|
|
6
6
|
restartHelper
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-TZLAEDD2.mjs";
|
|
8
8
|
import {
|
|
9
9
|
StateError,
|
|
10
10
|
harnessInfo,
|
|
@@ -13,10 +13,10 @@ import {
|
|
|
13
13
|
stateRoot,
|
|
14
14
|
validateAgentName,
|
|
15
15
|
writeJsonAtomic
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-YN334EWZ.mjs";
|
|
17
17
|
import {
|
|
18
18
|
init_define_KHALA_BUNDLE
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-NDII2VEP.mjs";
|
|
20
20
|
|
|
21
21
|
// src/local/identity.ts
|
|
22
22
|
init_define_KHALA_BUNDLE();
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
readJson,
|
|
5
5
|
readProcess,
|
|
6
6
|
writeJsonAtomic
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-YN334EWZ.mjs";
|
|
8
8
|
import {
|
|
9
9
|
init_define_KHALA_BUNDLE
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-NDII2VEP.mjs";
|
|
11
11
|
|
|
12
12
|
// src/wake/terminal/capture.ts
|
|
13
13
|
init_define_KHALA_BUNDLE();
|
|
@@ -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-NDII2VEP.mjs";
|
|
5
5
|
|
|
6
6
|
// src/events/member-rename.ts
|
|
7
7
|
init_define_KHALA_BUNDLE();
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
KHALA_AGENT_VERSION
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-7BR55Y3K.mjs";
|
|
5
5
|
import {
|
|
6
6
|
bundle
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ERWPSB27.mjs";
|
|
8
8
|
import {
|
|
9
9
|
LISTENING_MODES
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-ME3G775Q.mjs";
|
|
11
11
|
import {
|
|
12
12
|
HARNESS_REGISTRY,
|
|
13
13
|
M1_LABEL_MAX_BYTES,
|
|
@@ -35,10 +35,10 @@ import {
|
|
|
35
35
|
utcTimestamp,
|
|
36
36
|
utf8Length,
|
|
37
37
|
version
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-YN334EWZ.mjs";
|
|
39
39
|
import {
|
|
40
40
|
init_define_KHALA_BUNDLE
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-NDII2VEP.mjs";
|
|
42
42
|
|
|
43
43
|
// src/client.ts
|
|
44
44
|
init_define_KHALA_BUNDLE();
|
|
@@ -132,6 +132,10 @@ function isDefaultAgentName(name, username, harness) {
|
|
|
132
132
|
const escaped = escapePattern(`${username}-${harnessInfo(harness).modelName}`);
|
|
133
133
|
return new RegExp(`^${escaped}(?:-\\d+)?$`, "iu").test(name);
|
|
134
134
|
}
|
|
135
|
+
function agentNameFromTitle(title) {
|
|
136
|
+
const name = title.normalize("NFKD").replace(/[^A-Za-z0-9-]/gu, "").replace(/-+/gu, "-").replace(/^-+/u, "").slice(0, AGENT_NAME_MAX).replace(/-+$/u, "");
|
|
137
|
+
return checkName(name, "agent").ok ? name : null;
|
|
138
|
+
}
|
|
135
139
|
|
|
136
140
|
// ../contracts/src/m1/local.ts
|
|
137
141
|
var LOCAL_OWNER_USER_ID = "@khala_owner:local";
|
|
@@ -691,10 +695,13 @@ export {
|
|
|
691
695
|
isHumanColorId,
|
|
692
696
|
defaultHumanColor,
|
|
693
697
|
normalizeInitials,
|
|
698
|
+
USERNAME_MAX,
|
|
699
|
+
AGENT_NAME_MAX,
|
|
694
700
|
checkName,
|
|
695
701
|
checkNewUsername,
|
|
696
702
|
defaultAgentName,
|
|
697
703
|
isDefaultAgentName,
|
|
704
|
+
agentNameFromTitle,
|
|
698
705
|
LOCAL_OWNER_USER_ID,
|
|
699
706
|
LOCAL_LINK_TTL_MS,
|
|
700
707
|
LOCAL_LONG_POLL_MAX_S,
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
retryUnexpired
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-BUFSSWDE.mjs";
|
|
5
5
|
import {
|
|
6
6
|
StateError,
|
|
7
7
|
ensureStateDir,
|
|
8
8
|
writeJsonAtomic
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-YN334EWZ.mjs";
|
|
10
10
|
import {
|
|
11
11
|
__commonJS,
|
|
12
12
|
__export,
|
|
13
13
|
__toESM,
|
|
14
14
|
init_define_KHALA_BUNDLE
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-NDII2VEP.mjs";
|
|
16
16
|
|
|
17
17
|
// ../../node_modules/.pnpm/immediate@3.3.0/node_modules/immediate/lib/nextTick.js
|
|
18
18
|
var require_nextTick = __commonJS({
|