khala-cli 0.4.5 → 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-TZKEQIHP.mjs → chunk-25AX7UMF.mjs} +305 -97
- package/dist/{chunk-AUJEUKVM.mjs → chunk-3OFKVYOX.mjs} +1 -1
- package/dist/{chunk-7G2G4E4U.mjs → chunk-4LSCOWWN.mjs} +18 -17
- package/dist/chunk-5RGEO5HN.mjs +142 -0
- package/dist/{chunk-V7M27QLT.mjs → chunk-6YEYXZZB.mjs} +8 -7
- package/dist/{chunk-EXHCVFVH.mjs → chunk-7V2YQIRI.mjs} +11 -5
- package/dist/{chunk-PXKGKVGW.mjs → chunk-APIWKRKG.mjs} +1 -1
- package/dist/{chunk-H46OG22B.mjs → chunk-C5SMOUTO.mjs} +34 -5
- package/dist/{chunk-Y4WVILEJ.mjs → chunk-IG2NU5J6.mjs} +4 -4
- package/dist/chunk-JEI32DEA.mjs +634 -0
- package/dist/{chunk-MBLP7LQJ.mjs → chunk-K6EJSZYO.mjs} +95 -98
- package/dist/{chunk-V4Y26O4R.mjs → chunk-L7L6UNXN.mjs} +85 -36
- package/dist/{chunk-P5CP32X2.mjs → chunk-LNG3ZZBK.mjs} +1 -1
- package/dist/{chunk-IR3VN2ID.mjs → chunk-OAFYPBCP.mjs} +1 -19
- package/dist/{chunk-Y2DRTRBJ.mjs → chunk-ODTSGEID.mjs} +24 -8
- package/dist/{chunk-T7YRVE43.mjs → chunk-OP2HZ7EM.mjs} +8 -30
- package/dist/{chunk-RSDOTTZQ.mjs → chunk-S3FX7VCY.mjs} +30 -12
- package/dist/{chunk-OLZ62X7S.mjs → chunk-SU6362YU.mjs} +1 -1
- package/dist/{chunk-EW22K3JO.mjs → chunk-TOBQUAPD.mjs} +210 -311
- package/dist/{chunk-SN3STAO2.mjs → chunk-U3MKSPRO.mjs} +40 -3
- package/dist/{chunk-6LC66VHK.mjs → chunk-W5HS2PQO.mjs} +12 -13
- package/dist/{chunk-KCJFSVDN.mjs → chunk-WNOIHCCC.mjs} +9 -7
- package/dist/{chunk-SQXDATEC.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-HB3UGIZG.mjs +0 -144
- package/dist/chunk-VUE2DDYY.mjs +0 -34
- package/dist/web/assets/local-C1vz22ps.js +0 -9
- package/dist/web/assets/local-DdjwMERJ.css +0 -1
|
@@ -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-HB3UGIZG.mjs";
|
|
5
2
|
import {
|
|
6
3
|
KhalaClientError,
|
|
7
4
|
LOCAL_LONG_POLL_MAX_S,
|
|
@@ -15,20 +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-
|
|
24
|
+
} from "./chunk-LNG3ZZBK.mjs";
|
|
25
|
+
import "./chunk-WNOIHCCC.mjs";
|
|
27
26
|
import {
|
|
28
27
|
LISTENING_MODE_COMMAND_TYPE
|
|
29
|
-
} from "./chunk-
|
|
30
|
-
import "./chunk-
|
|
31
|
-
import "./chunk-
|
|
28
|
+
} from "./chunk-3OFKVYOX.mjs";
|
|
29
|
+
import "./chunk-U3MKSPRO.mjs";
|
|
30
|
+
import "./chunk-APIWKRKG.mjs";
|
|
32
31
|
|
|
33
32
|
// src/local/session.ts
|
|
34
33
|
import { randomUUID } from "node:crypto";
|
|
@@ -227,7 +226,7 @@ async function createLocalSession(creds, opts = {}) {
|
|
|
227
226
|
try {
|
|
228
227
|
const page = decoded(await request(
|
|
229
228
|
"GET",
|
|
230
|
-
`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`,
|
|
231
230
|
void 0,
|
|
232
231
|
controller.signal,
|
|
233
232
|
(LOCAL_LONG_POLL_MAX_S + 10) * 1e3
|
|
@@ -323,7 +322,7 @@ async function createLocalSession(creds, opts = {}) {
|
|
|
323
322
|
const result = decoded(await withHelper(() => request("POST", "join", {})), decodeLocalJoined);
|
|
324
323
|
after = result.seq;
|
|
325
324
|
await me();
|
|
326
|
-
const members = decoded(await withHelper(() => request("GET", "members")), decodeLocalMembersResponse);
|
|
325
|
+
const members = decoded(await withHelper(() => request("GET", "members?wire=2")), decodeLocalMembersResponse);
|
|
327
326
|
check(roomId);
|
|
328
327
|
for (const member of members.members) {
|
|
329
328
|
names.set(member.userId, member.displayName);
|
|
@@ -341,7 +340,7 @@ async function createLocalSession(creds, opts = {}) {
|
|
|
341
340
|
},
|
|
342
341
|
async history(roomId, limit, before) {
|
|
343
342
|
check(roomId);
|
|
344
|
-
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);
|
|
345
344
|
const result = page.events.filter((e) => e.roomId === creds.roomId).map(message);
|
|
346
345
|
return { messages: result, ...page.nextBefore !== void 0 ? { nextBefore: page.nextBefore } : {} };
|
|
347
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];
|
|
@@ -150,7 +150,7 @@ function readStatus(files) {
|
|
|
150
150
|
return readJson(files.status);
|
|
151
151
|
}
|
|
152
152
|
async function writeStateFile(dir, name, value) {
|
|
153
|
-
if (!["join.json", "session.json", "cursor.json", "status.json", "mode.json", "rejoin.json", "channel.json"].includes(name)) throw new StateError("storage_failed");
|
|
153
|
+
if (!["join.json", "session.json", "cursor.json", "status.json", "mode.json", "rejoin.json", "channel.json", "resume.json"].includes(name)) throw new StateError("storage_failed");
|
|
154
154
|
await writeJsonAtomic(path.join(dir, name), value);
|
|
155
155
|
}
|
|
156
156
|
function readStateFile(dir, name) {
|
|
@@ -165,6 +165,7 @@ async function removeStateFile(dir, name) {
|
|
|
165
165
|
if (error.code !== "ENOENT") throw new StateError("storage_failed");
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
+
var TERMINAL_SESSION_DETAILS = ["left", "removed", "revoked", "unauthorized", "channel_deleted"];
|
|
168
169
|
|
|
169
170
|
export {
|
|
170
171
|
SESSION_ID_PATTERN,
|
|
@@ -185,5 +186,6 @@ export {
|
|
|
185
186
|
readStatus,
|
|
186
187
|
writeStateFile,
|
|
187
188
|
readStateFile,
|
|
188
|
-
removeStateFile
|
|
189
|
+
removeStateFile,
|
|
190
|
+
TERMINAL_SESSION_DETAILS
|
|
189
191
|
};
|
|
@@ -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
|
});
|