khala-cli 0.4.6 → 0.4.7
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-2U4E7AM7.mjs → chunk-25AX7UMF.mjs} +294 -101
- package/dist/{chunk-AUJEUKVM.mjs → chunk-3OFKVYOX.mjs} +1 -1
- package/dist/{chunk-AWBKVTLV.mjs → chunk-4LSCOWWN.mjs} +13 -14
- package/dist/chunk-5RGEO5HN.mjs +142 -0
- package/dist/{chunk-B2MOLCJM.mjs → chunk-6YEYXZZB.mjs} +8 -9
- package/dist/{chunk-2XTYRBYX.mjs → chunk-7V2YQIRI.mjs} +4 -4
- package/dist/{chunk-55KBLEX5.mjs → chunk-APIWKRKG.mjs} +1 -1
- package/dist/{chunk-PY2ZNVNY.mjs → chunk-C5SMOUTO.mjs} +34 -5
- package/dist/{chunk-JG5J3SHW.mjs → chunk-IG2NU5J6.mjs} +4 -4
- package/dist/chunk-JEI32DEA.mjs +634 -0
- package/dist/{chunk-4X35OUAN.mjs → chunk-K6EJSZYO.mjs} +92 -95
- package/dist/{chunk-FH2CZX5T.mjs → chunk-L7L6UNXN.mjs} +83 -36
- package/dist/{chunk-P5CP32X2.mjs → chunk-LNG3ZZBK.mjs} +1 -1
- package/dist/{chunk-CWHGNVZV.mjs → chunk-OAFYPBCP.mjs} +1 -1
- package/dist/{chunk-OECJ45NM.mjs → chunk-ODTSGEID.mjs} +24 -8
- package/dist/{chunk-XUJIJ4KB.mjs → chunk-OP2HZ7EM.mjs} +1 -1
- package/dist/{chunk-6E3UCO22.mjs → chunk-S3FX7VCY.mjs} +8 -11
- package/dist/{chunk-PFDUXY3N.mjs → chunk-SU6362YU.mjs} +1 -1
- package/dist/{chunk-Z4EDYB6Y.mjs → chunk-TOBQUAPD.mjs} +59 -43
- package/dist/{chunk-SN3STAO2.mjs → chunk-U3MKSPRO.mjs} +40 -3
- package/dist/{chunk-SZIEG3RS.mjs → chunk-W5HS2PQO.mjs} +12 -14
- package/dist/{chunk-OW3DSTEZ.mjs → chunk-WNOIHCCC.mjs} +5 -5
- package/dist/{chunk-RRBIVI77.mjs → chunk-YIHRHD7W.mjs} +1 -1
- package/dist/khala.mjs +10 -10
- package/dist/web/assets/local-BQl2KrE1.js +9 -0
- package/dist/web/assets/local-OwDq47O4.css +1 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/chunk-DPW43YNC.mjs +0 -36
- package/dist/chunk-IULQYQJZ.mjs +0 -144
- package/dist/chunk-WHONG7UF.mjs +0 -267
- package/dist/chunk-ZHMGB3PP.mjs +0 -82
- package/dist/web/assets/local-K8EcTVxW.js +0 -9
- package/dist/web/assets/local-R2y0Gl4T.css +0 -1
|
@@ -5,21 +5,20 @@ import {
|
|
|
5
5
|
reportReady,
|
|
6
6
|
requestJoin,
|
|
7
7
|
saveHostedUsername
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import {
|
|
10
|
-
KHALA_AGENT_VERSION
|
|
11
|
-
} from "./chunk-RRBIVI77.mjs";
|
|
8
|
+
} from "./chunk-ODTSGEID.mjs";
|
|
12
9
|
import {
|
|
13
10
|
createEventKeyFilter,
|
|
14
11
|
isWakeEntry,
|
|
15
12
|
toEventInboxEntry
|
|
16
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-OAFYPBCP.mjs";
|
|
17
14
|
import {
|
|
18
15
|
KhalaClientError,
|
|
19
|
-
LOCAL_OWNER_USER_ID
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
LOCAL_OWNER_USER_ID
|
|
17
|
+
} from "./chunk-25AX7UMF.mjs";
|
|
18
|
+
import {
|
|
19
|
+
KHALA_AGENT_VERSION
|
|
20
|
+
} from "./chunk-YIHRHD7W.mjs";
|
|
21
|
+
import "./chunk-SU6362YU.mjs";
|
|
23
22
|
import "./chunk-5GLTKWJ5.mjs";
|
|
24
23
|
import {
|
|
25
24
|
CHANNEL_EVENT_TYPE,
|
|
@@ -27,19 +26,21 @@ import {
|
|
|
27
26
|
formatChannelEventLine,
|
|
28
27
|
memberRenameContent,
|
|
29
28
|
statusFor
|
|
30
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-LNG3ZZBK.mjs";
|
|
31
30
|
import {
|
|
32
31
|
monitorArmed,
|
|
33
32
|
resolveHarness,
|
|
34
|
-
|
|
35
|
-
} from "./chunk-
|
|
33
|
+
resolveSession
|
|
34
|
+
} from "./chunk-4LSCOWWN.mjs";
|
|
36
35
|
import {
|
|
37
|
-
|
|
38
|
-
} from "./chunk-
|
|
36
|
+
SESSION_UNKNOWN_HINT
|
|
37
|
+
} from "./chunk-5RGEO5HN.mjs";
|
|
39
38
|
import {
|
|
39
|
+
adapterFor,
|
|
40
40
|
applyListeningMode,
|
|
41
|
+
createWakeLadder,
|
|
41
42
|
readListeningMode
|
|
42
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-JEI32DEA.mjs";
|
|
43
44
|
import {
|
|
44
45
|
appendInbox,
|
|
45
46
|
channelKey,
|
|
@@ -47,8 +48,7 @@ import {
|
|
|
47
48
|
migrateLegacy,
|
|
48
49
|
resolveChannel,
|
|
49
50
|
unreadCount
|
|
50
|
-
} from "./chunk-
|
|
51
|
-
import "./chunk-DPW43YNC.mjs";
|
|
51
|
+
} from "./chunk-OP2HZ7EM.mjs";
|
|
52
52
|
import {
|
|
53
53
|
StateError,
|
|
54
54
|
TERMINAL_SESSION_DETAILS,
|
|
@@ -64,18 +64,19 @@ import {
|
|
|
64
64
|
sessionFiles,
|
|
65
65
|
writeJoinFile,
|
|
66
66
|
writeStateFile
|
|
67
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-WNOIHCCC.mjs";
|
|
68
68
|
import {
|
|
69
69
|
decodeListeningModeCommand
|
|
70
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-3OFKVYOX.mjs";
|
|
71
71
|
import {
|
|
72
72
|
displayText,
|
|
73
|
+
harnessInfo,
|
|
73
74
|
isWellFormed,
|
|
74
75
|
label,
|
|
75
76
|
utf8Length,
|
|
76
77
|
validAgentRejoinSecret
|
|
77
|
-
} from "./chunk-
|
|
78
|
-
import "./chunk-
|
|
78
|
+
} from "./chunk-U3MKSPRO.mjs";
|
|
79
|
+
import "./chunk-APIWKRKG.mjs";
|
|
79
80
|
|
|
80
81
|
// src/mcp/main.ts
|
|
81
82
|
import { Console } from "node:console";
|
|
@@ -504,6 +505,7 @@ function resolveEventInput(args) {
|
|
|
504
505
|
|
|
505
506
|
// src/mcp/tools.ts
|
|
506
507
|
var ERROR_CODES = [
|
|
508
|
+
"update_required",
|
|
507
509
|
"channel_required",
|
|
508
510
|
"channel_unknown",
|
|
509
511
|
"channel_ambiguous",
|
|
@@ -529,12 +531,14 @@ function createKhalaTools(input) {
|
|
|
529
531
|
async call(args, context) {
|
|
530
532
|
if (!hasOnly(args, Object.keys(properties)) || !validate(args)) return failure(context.id, -32602, "Invalid params");
|
|
531
533
|
try {
|
|
532
|
-
const client = input.clientFor(context.meta);
|
|
533
|
-
if (client === null) return success(context.id, toolError("session_unknown"));
|
|
534
|
+
const client = await input.clientFor(context.meta);
|
|
535
|
+
if (client === null) return success(context.id, toolError("session_unknown", { hint: SESSION_UNKNOWN_HINT }));
|
|
534
536
|
const structuredContent = await invoke(client, args);
|
|
535
537
|
return success(context.id, { content: [{ type: "text", text: render(structuredContent) }], structuredContent });
|
|
536
538
|
} catch (error) {
|
|
537
|
-
|
|
539
|
+
const code = errorCode(error);
|
|
540
|
+
const extra = error instanceof KhalaClientError ? { ...error.extra, ...code === "update_required" ? { message: error.message } : {} } : void 0;
|
|
541
|
+
return success(context.id, toolError(code, extra));
|
|
538
542
|
}
|
|
539
543
|
}
|
|
540
544
|
};
|
|
@@ -553,7 +557,7 @@ function createKhalaTools(input) {
|
|
|
553
557
|
} },
|
|
554
558
|
["link"],
|
|
555
559
|
(args) => typeof args.link === "string" && (!Object.hasOwn(args, "label") || typeof args.label === "string" && args.label.trim().length > 0 && [...args.label].length <= 40),
|
|
556
|
-
(client, args) => client.join(args.link, args.label ??
|
|
560
|
+
(client, args) => client.join(args.link, args.label ?? harnessInfo(input.harness).modelName),
|
|
557
561
|
(result) => {
|
|
558
562
|
const joined = result;
|
|
559
563
|
if (joined.state === "connected") return `Connected to ${joined.channelName}.`;
|
|
@@ -615,12 +619,14 @@ function createKhalaTools(input) {
|
|
|
615
619
|
return success(context.id, { content: [{ type: "text", text: "Skipped channel event." }], structuredContent: { skipped: true } });
|
|
616
620
|
}
|
|
617
621
|
try {
|
|
618
|
-
const client = input.clientFor(context.meta);
|
|
619
|
-
if (client === null) return success(context.id, toolError("session_unknown"));
|
|
622
|
+
const client = await input.clientFor(context.meta);
|
|
623
|
+
if (client === null) return success(context.id, toolError("session_unknown", { hint: SESSION_UNKNOWN_HINT }));
|
|
620
624
|
const sent = await (channel === void 0 ? client.sendChannelEvent(resolved.content) : client.sendChannelEvent(resolved.content, channel));
|
|
621
625
|
return success(context.id, { content: [{ type: "text", text: `Posted channel event: ${resolved.content.body}` }], structuredContent: sent });
|
|
622
626
|
} catch (error) {
|
|
623
|
-
|
|
627
|
+
const code = errorCode(error);
|
|
628
|
+
const extra = error instanceof KhalaClientError ? { ...error.extra, ...code === "update_required" ? { message: error.message } : {} } : void 0;
|
|
629
|
+
return success(context.id, toolError(code, extra));
|
|
624
630
|
}
|
|
625
631
|
}
|
|
626
632
|
}
|
|
@@ -637,7 +643,7 @@ import * as fs from "node:fs/promises";
|
|
|
637
643
|
import { createHash, randomBytes } from "node:crypto";
|
|
638
644
|
|
|
639
645
|
// src/transport.ts
|
|
640
|
-
var startChannelSession = async (creds, options) => creds.transport === "local" ? (await import("./chunk-
|
|
646
|
+
var startChannelSession = async (creds, options) => creds.transport === "local" ? (await import("./chunk-W5HS2PQO.mjs")).createLocalSession(creds) : (await import("./chunk-IG2NU5J6.mjs")).createAgentMatrixSession(creds, options);
|
|
641
647
|
|
|
642
648
|
// src/sender.ts
|
|
643
649
|
function localpart(userId) {
|
|
@@ -680,7 +686,7 @@ function createKhalaAgentClient(options) {
|
|
|
680
686
|
const api = options.joinApi ?? { requestJoin, pollJoin, reportReady };
|
|
681
687
|
let status = { state: "idle", updatedAt: now().toISOString() };
|
|
682
688
|
let initialization;
|
|
683
|
-
const rejoinable = adapterFor(options.harness)?.rejoinable(options.sessionId) ?? false;
|
|
689
|
+
const rejoinable = options.rejoinable ?? adapterFor(options.harness)?.sessionSources[0]?.rejoinable(options.sessionId) ?? false;
|
|
684
690
|
let rejoinSecret;
|
|
685
691
|
let savedSecret;
|
|
686
692
|
let resuming;
|
|
@@ -1072,7 +1078,7 @@ function createKhalaAgentClient(options) {
|
|
|
1072
1078
|
signal.addEventListener("abort", releaseAbort, { once: true });
|
|
1073
1079
|
if (signal.aborted) releaseAbort();
|
|
1074
1080
|
});
|
|
1075
|
-
const request = restore?.localCredentials ? Promise.resolve({ ...attempt.created, origin: new URL(link).origin, autoConfirmed: true }) : api.requestJoin({ link, harness: options.harness, label: label2, ...rejoinSecret === void 0 ? {} : { sessionId: options.sessionId, rejoinSecret } }, restore ? { fetch: (input, init) => (options.fetch ?? fetch)(input, { ...init, signal: init?.signal ? AbortSignal.any([signal, init.signal]) : signal }) } : fetchDeps);
|
|
1081
|
+
const request = restore?.localCredentials ? Promise.resolve({ ...attempt.created, origin: new URL(link).origin, autoConfirmed: true }) : api.requestJoin({ link, harness: options.harness, label: label2, ...rejoinSecret === void 0 ? {} : { sessionId: options.sessionId, rejoinSecret } }, { ...options.env ? { env: options.env } : {}, ...restore ? { fetch: (input, init) => (options.fetch ?? fetch)(input, { ...init, signal: init?.signal ? AbortSignal.any([signal, init.signal]) : signal }) } : fetchDeps });
|
|
1076
1082
|
const created = await Promise.race([request, aborted]).finally(() => {
|
|
1077
1083
|
if (releaseAbort) signal.removeEventListener("abort", releaseAbort);
|
|
1078
1084
|
});
|
|
@@ -1284,14 +1290,22 @@ function createKhalaAgentClient(options) {
|
|
|
1284
1290
|
|
|
1285
1291
|
// src/mcp/wiring.ts
|
|
1286
1292
|
function createRealClientFactory(env, deps = {}) {
|
|
1287
|
-
return ({ harness, sessionId }) => {
|
|
1293
|
+
return ({ harness, sessionId, rejoinable }) => {
|
|
1288
1294
|
const files = sessionFiles(harness, sessionId, env);
|
|
1289
1295
|
const adapter = adapterFor(harness);
|
|
1290
|
-
const
|
|
1291
|
-
const waker = createWaker
|
|
1296
|
+
const drivers = adapter?.wakeLadder;
|
|
1297
|
+
const waker = drivers?.length ? deps.createWaker ? deps.createWaker({ files, threadId: sessionId }) : createWakeLadder({
|
|
1298
|
+
files,
|
|
1299
|
+
harness,
|
|
1300
|
+
sessionId,
|
|
1301
|
+
drivers,
|
|
1302
|
+
env,
|
|
1303
|
+
warningPrefix: adapter?.wakeWarningName ?? "wake"
|
|
1304
|
+
}) : void 0;
|
|
1292
1305
|
const client = (deps.createClient ?? createKhalaAgentClient)({
|
|
1293
1306
|
harness,
|
|
1294
1307
|
sessionId,
|
|
1308
|
+
...rejoinable !== void 0 ? { rejoinable } : {},
|
|
1295
1309
|
env,
|
|
1296
1310
|
...waker ? { onInboxAppend: () => waker.notify() } : {}
|
|
1297
1311
|
});
|
|
@@ -1386,21 +1400,23 @@ async function runMcpCommand(argv, deps) {
|
|
|
1386
1400
|
return 2;
|
|
1387
1401
|
}
|
|
1388
1402
|
const clients = /* @__PURE__ */ new Map();
|
|
1389
|
-
const clientForSession = (
|
|
1390
|
-
|
|
1403
|
+
const clientForSession = (session) => {
|
|
1404
|
+
const { sessionId, rejoinable } = session;
|
|
1405
|
+
const key = `${rejoinable}:${sessionId}`;
|
|
1406
|
+
let client = clients.get(key);
|
|
1391
1407
|
if (client === void 0) {
|
|
1392
|
-
client = deps.createClient({ harness, sessionId });
|
|
1393
|
-
clients.set(
|
|
1408
|
+
client = deps.createClient({ harness, sessionId, rejoinable });
|
|
1409
|
+
clients.set(key, client);
|
|
1394
1410
|
}
|
|
1395
1411
|
return client;
|
|
1396
1412
|
};
|
|
1397
|
-
const startupSession =
|
|
1398
|
-
if (startupSession !== null
|
|
1413
|
+
const startupSession = adapterFor(harness)?.restoreAtStartup ? await resolveSession(harness, void 0, env) : null;
|
|
1414
|
+
if (startupSession !== null) clientForSession(startupSession);
|
|
1399
1415
|
const tools = createKhalaTools({
|
|
1400
1416
|
harness,
|
|
1401
|
-
clientFor(meta) {
|
|
1402
|
-
const
|
|
1403
|
-
return
|
|
1417
|
+
async clientFor(meta) {
|
|
1418
|
+
const session = await resolveSession(harness, meta, env);
|
|
1419
|
+
return session === null ? null : clientForSession(session);
|
|
1404
1420
|
}
|
|
1405
1421
|
});
|
|
1406
1422
|
try {
|
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
2
|
|
|
3
|
+
// ../contracts/src/m1/harness.ts
|
|
4
|
+
var HARNESS_ID = /^[a-z][a-z0-9-]{1,23}$/;
|
|
5
|
+
function isHarnessId(input) {
|
|
6
|
+
return typeof input === "string" && HARNESS_ID.exec(input)?.[0] === input;
|
|
7
|
+
}
|
|
8
|
+
var LEGACY_HARNESSES = ["claude", "codex", "cursor"];
|
|
9
|
+
var HARNESS_REGISTRY = [
|
|
10
|
+
{ id: "claude", displayName: "Claude Code", modelName: "Claude", logoKey: "claude", steer: true, sync: true, idleWake: "default", registered: true },
|
|
11
|
+
{ id: "codex", displayName: "Codex", modelName: "Codex", logoKey: "codex", steer: true, sync: true, idleWake: "default", registered: true },
|
|
12
|
+
{ id: "cursor", displayName: "Cursor", modelName: "Cursor", logoKey: "cursor", steer: true, sync: true, idleWake: "none", registered: true },
|
|
13
|
+
{ id: "opencode", displayName: "OpenCode", modelName: "OpenCode", logoKey: "opencode", steer: true, sync: true, idleWake: "default", registered: true },
|
|
14
|
+
{ id: "copilot", displayName: "Copilot CLI", modelName: "Copilot", logoKey: "copilot", steer: true, sync: true, idleWake: "opt-in", registered: true },
|
|
15
|
+
{ id: "vscode", displayName: "Copilot (VS Code)", modelName: "VSCode", logoKey: "copilot", steer: true, sync: true, idleWake: "opt-in", registered: true },
|
|
16
|
+
{ id: "gemini", displayName: "Gemini CLI", modelName: "Gemini", logoKey: "gemini", steer: true, sync: true, idleWake: "opt-in", registered: true },
|
|
17
|
+
// U29 and U33 establish these capabilities after their spikes.
|
|
18
|
+
{ id: "antigravity", displayName: "Antigravity CLI", modelName: "Antigravity", logoKey: null, steer: false, sync: false, idleWake: "none", registered: true },
|
|
19
|
+
{ id: "qwen", displayName: "Qwen Code", modelName: "Qwen", logoKey: "qwen", steer: true, sync: true, idleWake: "default", registered: true },
|
|
20
|
+
{ id: "muse", displayName: "Muse Code", modelName: "Muse", logoKey: null, steer: false, sync: false, idleWake: "none", registered: true },
|
|
21
|
+
{ id: "generic", displayName: "MCP agent", modelName: "Agent", logoKey: null, steer: false, sync: false, idleWake: "none", registered: true }
|
|
22
|
+
];
|
|
23
|
+
function harnessInfo(id) {
|
|
24
|
+
return HARNESS_REGISTRY.find((row) => row.id === id) ?? {
|
|
25
|
+
id,
|
|
26
|
+
displayName: id.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" "),
|
|
27
|
+
modelName: "Agent",
|
|
28
|
+
logoKey: null,
|
|
29
|
+
steer: false,
|
|
30
|
+
sync: false,
|
|
31
|
+
idleWake: "none",
|
|
32
|
+
registered: false
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
3
36
|
// ../contracts/src/messaging/decode.ts
|
|
4
37
|
var MAX_IDENTIFIER_BYTES = 512;
|
|
5
38
|
var DecodeFailure = class extends Error {
|
|
@@ -129,11 +162,12 @@ function validateAgentName(input) {
|
|
|
129
162
|
}
|
|
130
163
|
|
|
131
164
|
// ../contracts/src/m1/agent-join.ts
|
|
132
|
-
var HARNESSES = ["claude", "codex", "cursor"];
|
|
133
165
|
var M1_LABEL_MAX_BYTES = 512;
|
|
134
166
|
var agentConfirmPagePath = (id) => `/agent/confirm?joinId=${encodeURIComponent(id)}`;
|
|
135
167
|
function readHarness(input, path) {
|
|
136
|
-
|
|
168
|
+
if (typeof input !== "string") fail(path, "wrong_type");
|
|
169
|
+
if (!isHarnessId(input)) fail(path, "invalid_value");
|
|
170
|
+
return input;
|
|
137
171
|
}
|
|
138
172
|
function readHttpUrl(input, path) {
|
|
139
173
|
if (typeof input !== "string") fail(path, "wrong_type");
|
|
@@ -160,6 +194,10 @@ var validAgentSessionId = (value) => typeof value === "string" && /^[A-Za-z0-9][
|
|
|
160
194
|
var validAgentRejoinSecret = (value) => typeof value === "string" && /^[A-Za-z0-9_-]{43}$/u.test(value);
|
|
161
195
|
|
|
162
196
|
export {
|
|
197
|
+
isHarnessId,
|
|
198
|
+
LEGACY_HARNESSES,
|
|
199
|
+
HARNESS_REGISTRY,
|
|
200
|
+
harnessInfo,
|
|
163
201
|
fail,
|
|
164
202
|
decodeWith,
|
|
165
203
|
object,
|
|
@@ -178,7 +216,6 @@ export {
|
|
|
178
216
|
utcTimestamp,
|
|
179
217
|
reserved,
|
|
180
218
|
validateAgentName,
|
|
181
|
-
HARNESSES,
|
|
182
219
|
M1_LABEL_MAX_BYTES,
|
|
183
220
|
agentConfirmPagePath,
|
|
184
221
|
readHarness,
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
ensureHelper
|
|
4
|
-
} from "./chunk-IULQYQJZ.mjs";
|
|
5
2
|
import {
|
|
6
3
|
KhalaClientError,
|
|
7
4
|
LOCAL_LONG_POLL_MAX_S,
|
|
@@ -15,21 +12,22 @@ import {
|
|
|
15
12
|
decodeLocalMembersResponse,
|
|
16
13
|
decodeLocalNameContent,
|
|
17
14
|
decodeLocalSendResult,
|
|
15
|
+
ensureHelper,
|
|
18
16
|
localRoomPath
|
|
19
|
-
} from "./chunk-
|
|
20
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-25AX7UMF.mjs";
|
|
18
|
+
import "./chunk-YIHRHD7W.mjs";
|
|
19
|
+
import "./chunk-SU6362YU.mjs";
|
|
21
20
|
import "./chunk-5GLTKWJ5.mjs";
|
|
22
21
|
import {
|
|
23
22
|
CHANNEL_EVENT_TYPE,
|
|
24
23
|
memberRenameContent
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import "./chunk-
|
|
27
|
-
import "./chunk-OW3DSTEZ.mjs";
|
|
24
|
+
} from "./chunk-LNG3ZZBK.mjs";
|
|
25
|
+
import "./chunk-WNOIHCCC.mjs";
|
|
28
26
|
import {
|
|
29
27
|
LISTENING_MODE_COMMAND_TYPE
|
|
30
|
-
} from "./chunk-
|
|
31
|
-
import "./chunk-
|
|
32
|
-
import "./chunk-
|
|
28
|
+
} from "./chunk-3OFKVYOX.mjs";
|
|
29
|
+
import "./chunk-U3MKSPRO.mjs";
|
|
30
|
+
import "./chunk-APIWKRKG.mjs";
|
|
33
31
|
|
|
34
32
|
// src/local/session.ts
|
|
35
33
|
import { randomUUID } from "node:crypto";
|
|
@@ -228,7 +226,7 @@ async function createLocalSession(creds, opts = {}) {
|
|
|
228
226
|
try {
|
|
229
227
|
const page = decoded(await request(
|
|
230
228
|
"GET",
|
|
231
|
-
`events?after=${after}&wait=${LOCAL_LONG_POLL_MAX_S}&prev=1`,
|
|
229
|
+
`events?after=${after}&wait=${LOCAL_LONG_POLL_MAX_S}&prev=1&wire=2`,
|
|
232
230
|
void 0,
|
|
233
231
|
controller.signal,
|
|
234
232
|
(LOCAL_LONG_POLL_MAX_S + 10) * 1e3
|
|
@@ -324,7 +322,7 @@ async function createLocalSession(creds, opts = {}) {
|
|
|
324
322
|
const result = decoded(await withHelper(() => request("POST", "join", {})), decodeLocalJoined);
|
|
325
323
|
after = result.seq;
|
|
326
324
|
await me();
|
|
327
|
-
const members = decoded(await withHelper(() => request("GET", "members")), decodeLocalMembersResponse);
|
|
325
|
+
const members = decoded(await withHelper(() => request("GET", "members?wire=2")), decodeLocalMembersResponse);
|
|
328
326
|
check(roomId);
|
|
329
327
|
for (const member of members.members) {
|
|
330
328
|
names.set(member.userId, member.displayName);
|
|
@@ -342,7 +340,7 @@ async function createLocalSession(creds, opts = {}) {
|
|
|
342
340
|
},
|
|
343
341
|
async history(roomId, limit, before) {
|
|
344
342
|
check(roomId);
|
|
345
|
-
const page = decoded(await withHelper(() => request("GET", `messages?limit=${limit}${before !== void 0 ? `&before=${encodeURIComponent(before)}` : ""}`)), decodeLocalHistoryPage);
|
|
343
|
+
const page = decoded(await withHelper(() => request("GET", `messages?wire=2&limit=${limit}${before !== void 0 ? `&before=${encodeURIComponent(before)}` : ""}`)), decodeLocalHistoryPage);
|
|
346
344
|
const result = page.events.filter((e) => e.roomId === creds.roomId).map(message);
|
|
347
345
|
return { messages: result, ...page.nextBefore !== void 0 ? { nextBefore: page.nextBefore } : {} };
|
|
348
346
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
} from "./chunk-
|
|
3
|
+
isHarnessId
|
|
4
|
+
} from "./chunk-U3MKSPRO.mjs";
|
|
5
5
|
|
|
6
6
|
// src/state.ts
|
|
7
7
|
import { constants } from "node:fs";
|
|
@@ -71,7 +71,7 @@ async function removeJoinFile(files, link) {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
function sessionFiles(harness, sessionId, env) {
|
|
74
|
-
if (!
|
|
74
|
+
if (!isHarnessId(harness) || !SESSION_ID_PATTERN.test(sessionId)) throw new StateError("invalid_session_id");
|
|
75
75
|
return filesForDir(path.join(stateRoot(env), harness, sessionId));
|
|
76
76
|
}
|
|
77
77
|
function resolveStateDir(harness, sessionId, env) {
|
|
@@ -80,9 +80,9 @@ function resolveStateDir(harness, sessionId, env) {
|
|
|
80
80
|
async function ensureStateDir(dir) {
|
|
81
81
|
try {
|
|
82
82
|
let sessionDir = dir;
|
|
83
|
-
if (path.basename(path.dirname(dir)) === "channels" && /^[a-f0-9]{24}$/.test(path.basename(dir)) &&
|
|
83
|
+
if (path.basename(path.dirname(dir)) === "channels" && /^[a-f0-9]{24}$/.test(path.basename(dir)) && isHarnessId(path.basename(path.dirname(path.dirname(path.dirname(dir))))) && path.basename(path.dirname(path.dirname(path.dirname(path.dirname(dir))))) === "khala") {
|
|
84
84
|
sessionDir = path.dirname(path.dirname(dir));
|
|
85
|
-
} else if (["channels", "joins"].includes(path.basename(dir)) &&
|
|
85
|
+
} else if (["channels", "joins"].includes(path.basename(dir)) && isHarnessId(path.basename(path.dirname(path.dirname(dir)))) && path.basename(path.dirname(path.dirname(path.dirname(dir)))) === "khala") {
|
|
86
86
|
sessionDir = path.dirname(dir);
|
|
87
87
|
}
|
|
88
88
|
const directories = [path.dirname(path.dirname(sessionDir)), path.dirname(sessionDir), sessionDir];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
bundle
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-SU6362YU.mjs";
|
|
5
5
|
|
|
6
6
|
// src/version.ts
|
|
7
7
|
var KHALA_AGENT_VERSION = bundle?.version ?? "0.0.0";
|
package/dist/khala.mjs
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
KHALA_AGENT_VERSION
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-YIHRHD7W.mjs";
|
|
6
|
+
import "./chunk-SU6362YU.mjs";
|
|
7
|
+
import "./chunk-APIWKRKG.mjs";
|
|
8
8
|
|
|
9
9
|
// src/cli.ts
|
|
10
10
|
var HOOK_NAME = /^[a-z][a-z0-9-]{0,31}$/;
|
|
@@ -78,14 +78,14 @@ async function runCli(argv, modules) {
|
|
|
78
78
|
|
|
79
79
|
// src/cli-bundle.ts
|
|
80
80
|
var hooks = {
|
|
81
|
-
"session-start": () => import("./chunk-
|
|
82
|
-
deliver: () => import("./chunk-
|
|
83
|
-
"claude-wake": () => import("./chunk-
|
|
81
|
+
"session-start": () => import("./chunk-7V2YQIRI.mjs"),
|
|
82
|
+
deliver: () => import("./chunk-K6EJSZYO.mjs"),
|
|
83
|
+
"claude-wake": () => import("./chunk-C5SMOUTO.mjs")
|
|
84
84
|
};
|
|
85
85
|
process.exitCode = await runCli(process.argv.slice(2), {
|
|
86
|
-
mcp: () => () => import("./chunk-
|
|
87
|
-
watch: () => () => import("./chunk-
|
|
88
|
-
local: () => () => import("./chunk-
|
|
89
|
-
install: () => () => import("./chunk-
|
|
86
|
+
mcp: () => () => import("./chunk-TOBQUAPD.mjs"),
|
|
87
|
+
watch: () => () => import("./chunk-6YEYXZZB.mjs"),
|
|
88
|
+
local: () => () => import("./chunk-L7L6UNXN.mjs"),
|
|
89
|
+
install: () => () => import("./chunk-S3FX7VCY.mjs"),
|
|
90
90
|
hook: (name) => Object.hasOwn(hooks, name) ? hooks[name] : void 0
|
|
91
91
|
});
|