khala-cli 0.4.1 → 0.4.4
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-S72K3GSP.mjs → chunk-6OADQWV7.mjs} +31 -20
- package/dist/{chunk-YMDAY234.mjs → chunk-7CVU5OZ7.mjs} +1 -1
- package/dist/{chunk-PSN7P4AV.mjs → chunk-AK74S7EN.mjs} +4 -4
- package/dist/chunk-AUJEUKVM.mjs +121 -0
- package/dist/chunk-DC3OX6F4.mjs +52 -0
- package/dist/chunk-ENPBK5W2.mjs +187 -0
- package/dist/chunk-FA6Z65DW.mjs +19 -0
- package/dist/{chunk-KEGR6VEQ.mjs → chunk-FUU775QM.mjs} +81 -10
- package/dist/chunk-GE3RXO2X.mjs +26 -0
- package/dist/chunk-LHAMBQK7.mjs +144 -0
- package/dist/{chunk-EVLXC2WS.mjs → chunk-LN3G2LJV.mjs} +13 -10
- package/dist/{chunk-35KKPOKI.mjs → chunk-LQ6KNUNN.mjs} +87 -53
- package/dist/{chunk-CSIFRJFF.mjs → chunk-MU4FUENP.mjs} +3 -2
- package/dist/{chunk-L2HRDTA5.mjs → chunk-MZS7XFMC.mjs} +3 -3
- package/dist/{chunk-U5ZMOPUK.mjs → chunk-N5VYKQMR.mjs} +5 -46
- package/dist/{chunk-3SWCRLWX.mjs → chunk-OS2JLDL7.mjs} +172 -227
- package/dist/chunk-P5CP32X2.mjs +170 -0
- package/dist/{chunk-RX5HGJQT.mjs → chunk-PJ3E3IVH.mjs} +184 -126
- package/dist/chunk-SN3STAO2.mjs +190 -0
- package/dist/{chunk-B5BFL7OD.mjs → chunk-XEYKJMZL.mjs} +1 -1
- package/dist/{chunk-SR5BG7FL.mjs → chunk-ZKDDKUUA.mjs} +1 -1
- package/dist/{chunk-HAD5ZILW.mjs → chunk-ZRFXZK72.mjs} +1 -1
- package/dist/khala.mjs +12 -10
- package/dist/web/assets/apple-touch-icon-Du9V6qit.png +0 -0
- package/dist/web/assets/favicon-16x16-D5waNSZD.png +0 -0
- package/dist/web/assets/favicon-32x32-B9Ubw1Dx.png +0 -0
- package/dist/web/assets/favicon-zCD0pKtT.ico +0 -0
- package/dist/web/assets/local-Bk8hMIT-.js +9 -0
- package/dist/web/assets/{local-DHYvcQG0.css → local-vdvavyq0.css} +1 -1
- package/dist/web/index.html +7 -2
- package/package.json +1 -1
- package/dist/chunk-AVJKIJ34.mjs +0 -91
- package/dist/chunk-N6LMHR7P.mjs +0 -455
- package/dist/web/assets/local-DGdQ2afg.js +0 -9
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// ../contracts/src/messaging/decode.ts
|
|
4
|
+
var MAX_IDENTIFIER_BYTES = 512;
|
|
5
|
+
var DecodeFailure = class extends Error {
|
|
6
|
+
path;
|
|
7
|
+
code;
|
|
8
|
+
constructor(path, code) {
|
|
9
|
+
super(`${path || "<root>"}: ${code}`);
|
|
10
|
+
this.name = "DecodeFailure";
|
|
11
|
+
this.path = path;
|
|
12
|
+
this.code = code;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
function fail(path, code) {
|
|
16
|
+
throw new DecodeFailure(path, code);
|
|
17
|
+
}
|
|
18
|
+
function decodeWith(read) {
|
|
19
|
+
try {
|
|
20
|
+
return { ok: true, value: read() };
|
|
21
|
+
} catch (error) {
|
|
22
|
+
if (error instanceof DecodeFailure) return { ok: false, error: { path: error.path, code: error.code } };
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
var join = (path, key) => typeof key === "number" ? `${path}[${key}]` : path ? `${path}.${key}` : key;
|
|
27
|
+
function object(input, path, keys) {
|
|
28
|
+
if (typeof input !== "object" || input === null || Array.isArray(input)) fail(path, "not_object");
|
|
29
|
+
const prototype = Object.getPrototypeOf(input);
|
|
30
|
+
if (prototype !== Object.prototype && prototype !== null) fail(path, "not_object");
|
|
31
|
+
const record = input;
|
|
32
|
+
for (const key of Object.keys(record)) if (!keys.includes(key)) fail(join(path, key), "unknown_field");
|
|
33
|
+
for (const key of keys) if (!Object.hasOwn(record, key)) fail(join(path, key), "missing_field");
|
|
34
|
+
return { path, field: (key) => record[key], at: (key) => join(path, key) };
|
|
35
|
+
}
|
|
36
|
+
function array(input, path) {
|
|
37
|
+
if (!Array.isArray(input)) fail(path, "wrong_type");
|
|
38
|
+
return input;
|
|
39
|
+
}
|
|
40
|
+
function elementPath(path, index) {
|
|
41
|
+
return join(path, index);
|
|
42
|
+
}
|
|
43
|
+
function utf8Length(value) {
|
|
44
|
+
let bytes = 0;
|
|
45
|
+
for (const char of value) {
|
|
46
|
+
const code = char.codePointAt(0) ?? 0;
|
|
47
|
+
bytes += code < 128 ? 1 : code < 2048 ? 2 : code < 65536 ? 3 : 4;
|
|
48
|
+
}
|
|
49
|
+
return bytes;
|
|
50
|
+
}
|
|
51
|
+
function isWellFormed(value) {
|
|
52
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
53
|
+
const unit = value.charCodeAt(index);
|
|
54
|
+
if (unit >= 55296 && unit <= 56319) {
|
|
55
|
+
const next = value.charCodeAt(index + 1);
|
|
56
|
+
if (!(next >= 56320 && next <= 57343)) return false;
|
|
57
|
+
index += 1;
|
|
58
|
+
} else if (unit >= 56320 && unit <= 57343) return false;
|
|
59
|
+
}
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
var CONTROL = /[\u0000-\u001f\u007f-\u009f]/;
|
|
63
|
+
var INVISIBLE = /[\u061c\u200b\u200e\u200f\u202a-\u202e\u2060\u2066-\u2069\ufeff]/;
|
|
64
|
+
function text(input, path, maxBytes) {
|
|
65
|
+
if (typeof input !== "string") fail(path, "wrong_type");
|
|
66
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 0) fail(path, "invalid_limits");
|
|
67
|
+
if (!isWellFormed(input)) fail(path, "malformed_unicode");
|
|
68
|
+
if (utf8Length(input) > maxBytes) fail(path, "too_long");
|
|
69
|
+
if (input.includes("\0")) fail(path, "control_character");
|
|
70
|
+
return input;
|
|
71
|
+
}
|
|
72
|
+
function label(input, path, maxBytes) {
|
|
73
|
+
const value = text(input, path, maxBytes);
|
|
74
|
+
if (CONTROL.test(value)) fail(path, "control_character");
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
function displayText(input, path, maxBytes) {
|
|
78
|
+
const value = label(input, path, maxBytes);
|
|
79
|
+
if (INVISIBLE.test(value)) fail(path, "control_character");
|
|
80
|
+
return value;
|
|
81
|
+
}
|
|
82
|
+
function identifier(input, path) {
|
|
83
|
+
const value = label(input, path, MAX_IDENTIFIER_BYTES);
|
|
84
|
+
if (value.length === 0) fail(path, "empty");
|
|
85
|
+
return value;
|
|
86
|
+
}
|
|
87
|
+
function nullable(input, read) {
|
|
88
|
+
return input === null ? null : read(input);
|
|
89
|
+
}
|
|
90
|
+
function literal(input, path, allowed) {
|
|
91
|
+
if (!allowed.includes(input)) fail(path, typeof input === typeof allowed[0] ? "invalid_value" : "wrong_type");
|
|
92
|
+
return input;
|
|
93
|
+
}
|
|
94
|
+
function version(input, path) {
|
|
95
|
+
if (input !== 1) fail(path, "unsupported_version");
|
|
96
|
+
return 1;
|
|
97
|
+
}
|
|
98
|
+
function safeInteger(input, path) {
|
|
99
|
+
if (typeof input !== "number") fail(path, "wrong_type");
|
|
100
|
+
if (!Number.isSafeInteger(input)) fail(path, "unsafe_integer");
|
|
101
|
+
if (input < 0) fail(path, "invalid_value");
|
|
102
|
+
return input;
|
|
103
|
+
}
|
|
104
|
+
var UTC_TIMESTAMP = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d{1,9})?Z$/;
|
|
105
|
+
function utcTimestamp(input, path) {
|
|
106
|
+
if (typeof input !== "string") fail(path, "wrong_type");
|
|
107
|
+
const match = UTC_TIMESTAMP.exec(input);
|
|
108
|
+
if (!match) fail(path, "invalid_value");
|
|
109
|
+
const [year, month, day, hour, minute, second] = match.slice(1).map(Number);
|
|
110
|
+
const date = /* @__PURE__ */ new Date(0);
|
|
111
|
+
date.setUTCFullYear(year, month - 1, day);
|
|
112
|
+
date.setUTCHours(hour, minute, second, 0);
|
|
113
|
+
if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day || date.getUTCHours() !== hour || date.getUTCMinutes() !== minute || date.getUTCSeconds() !== second) fail(path, "invalid_value");
|
|
114
|
+
return input;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// ../contracts/src/messaging/agent-names.ts
|
|
118
|
+
var MAX_AGENT_NAME_BYTES = 80;
|
|
119
|
+
var unsafe = /[\u0000-\u001f\u007f-\u009f\u061c\u200b-\u200f\u2028-\u202e\u2060-\u2069\ufeff]/u;
|
|
120
|
+
var reserved = /\b(?:admin(?:istrator)?|system|khala|moderator|owner|human|security|support|official)\b/iu;
|
|
121
|
+
function validateAgentName(input) {
|
|
122
|
+
if (typeof input !== "string") return { ok: false, error: "blank" };
|
|
123
|
+
const name = input.trim().normalize("NFC");
|
|
124
|
+
if (!name) return { ok: false, error: "blank" };
|
|
125
|
+
if (unsafe.test(name)) return { ok: false, error: "invalid_characters" };
|
|
126
|
+
if (new TextEncoder().encode(name).byteLength > MAX_AGENT_NAME_BYTES) return { ok: false, error: "too_long" };
|
|
127
|
+
if (reserved.test(name.normalize("NFKC"))) return { ok: false, error: "reserved" };
|
|
128
|
+
return { ok: true, name };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// ../contracts/src/m1/agent-join.ts
|
|
132
|
+
var HARNESSES = ["claude", "codex", "cursor"];
|
|
133
|
+
var M1_LABEL_MAX_BYTES = 512;
|
|
134
|
+
var agentConfirmPagePath = (id) => `/agent/confirm?joinId=${encodeURIComponent(id)}`;
|
|
135
|
+
function readHarness(input, path) {
|
|
136
|
+
return literal(input, path, HARNESSES);
|
|
137
|
+
}
|
|
138
|
+
function readHttpUrl(input, path) {
|
|
139
|
+
if (typeof input !== "string") fail(path, "wrong_type");
|
|
140
|
+
let url;
|
|
141
|
+
try {
|
|
142
|
+
url = new URL(input);
|
|
143
|
+
} catch {
|
|
144
|
+
fail(path, "invalid_value");
|
|
145
|
+
}
|
|
146
|
+
if (url.username || url.password || url.hash || !(url.protocol === "https:" || url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname))) fail(path, "invalid_value");
|
|
147
|
+
return input;
|
|
148
|
+
}
|
|
149
|
+
function readMatrixUserId(input, path) {
|
|
150
|
+
const value = identifier(input, path);
|
|
151
|
+
if (!/^@[^\s:]+:\S+$/u.test(value)) fail(path, "invalid_value");
|
|
152
|
+
return value;
|
|
153
|
+
}
|
|
154
|
+
function readRoomId(input, path) {
|
|
155
|
+
const value = identifier(input, path);
|
|
156
|
+
if (!/^!\S+$/u.test(value)) fail(path, "invalid_value");
|
|
157
|
+
return value;
|
|
158
|
+
}
|
|
159
|
+
var validAgentSessionId = (value) => typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$/u.test(value);
|
|
160
|
+
var validAgentRejoinSecret = (value) => typeof value === "string" && /^[A-Za-z0-9_-]{43}$/u.test(value);
|
|
161
|
+
|
|
162
|
+
export {
|
|
163
|
+
fail,
|
|
164
|
+
decodeWith,
|
|
165
|
+
object,
|
|
166
|
+
array,
|
|
167
|
+
elementPath,
|
|
168
|
+
utf8Length,
|
|
169
|
+
isWellFormed,
|
|
170
|
+
text,
|
|
171
|
+
label,
|
|
172
|
+
displayText,
|
|
173
|
+
identifier,
|
|
174
|
+
nullable,
|
|
175
|
+
literal,
|
|
176
|
+
version,
|
|
177
|
+
safeInteger,
|
|
178
|
+
utcTimestamp,
|
|
179
|
+
reserved,
|
|
180
|
+
validateAgentName,
|
|
181
|
+
HARNESSES,
|
|
182
|
+
M1_LABEL_MAX_BYTES,
|
|
183
|
+
agentConfirmPagePath,
|
|
184
|
+
readHarness,
|
|
185
|
+
readHttpUrl,
|
|
186
|
+
readMatrixUserId,
|
|
187
|
+
readRoomId,
|
|
188
|
+
validAgentSessionId,
|
|
189
|
+
validAgentRejoinSecret
|
|
190
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
HARNESSES
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-SN3STAO2.mjs";
|
|
5
5
|
|
|
6
6
|
// src/state.ts
|
|
7
7
|
import { constants } from "node:fs";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
2
|
|
|
3
3
|
// <define:__KHALA_BUNDLE__>
|
|
4
|
-
var define_KHALA_BUNDLE_default = { name: "khala-cli", version: "0.4.
|
|
4
|
+
var define_KHALA_BUNDLE_default = { name: "khala-cli", version: "0.4.4" };
|
|
5
5
|
|
|
6
6
|
export {
|
|
7
7
|
define_KHALA_BUNDLE_default
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
define_KHALA_BUNDLE_default
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ZKDDKUUA.mjs";
|
|
5
5
|
|
|
6
6
|
// src/bundle.ts
|
|
7
7
|
var bundle = typeof define_KHALA_BUNDLE_default === "undefined" ? void 0 : define_KHALA_BUNDLE_default;
|
package/dist/khala.mjs
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
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-7CVU5OZ7.mjs";
|
|
6
|
+
import "./chunk-ZRFXZK72.mjs";
|
|
7
|
+
import "./chunk-ZKDDKUUA.mjs";
|
|
8
8
|
|
|
9
9
|
// src/cli.ts
|
|
10
10
|
var HOOK_NAME = /^[a-z][a-z0-9-]{0,31}$/;
|
|
11
11
|
var STDIN_CAP = 1024 * 1024;
|
|
12
|
-
var USAGE = "usage: khala mcp | khala hook <name> | khala local <command> | khala install codex | khala install cursor | khala --version";
|
|
12
|
+
var USAGE = "usage: khala mcp | khala watch [--harness claude|codex|cursor --session <id>] | khala hook <name> | khala local <command> | khala install codex | khala install cursor | khala --version";
|
|
13
13
|
async function readStdin() {
|
|
14
14
|
if (process.stdin.isTTY) return "";
|
|
15
15
|
const chunks = [];
|
|
@@ -31,7 +31,7 @@ async function runCli(argv, modules) {
|
|
|
31
31
|
console.log(KHALA_AGENT_VERSION);
|
|
32
32
|
return 0;
|
|
33
33
|
}
|
|
34
|
-
if (cmd === "mcp" || cmd === "install") {
|
|
34
|
+
if (cmd === "mcp" || cmd === "install" || cmd === "watch") {
|
|
35
35
|
const load = modules[cmd]();
|
|
36
36
|
if (!load) {
|
|
37
37
|
console.error(`khala: ${cmd} not available`);
|
|
@@ -78,12 +78,14 @@ async function runCli(argv, modules) {
|
|
|
78
78
|
|
|
79
79
|
// src/cli-bundle.ts
|
|
80
80
|
var hooks = {
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
"session-start": () => import("./chunk-GE3RXO2X.mjs"),
|
|
82
|
+
deliver: () => import("./chunk-6OADQWV7.mjs"),
|
|
83
|
+
"claude-wake": () => import("./chunk-MU4FUENP.mjs")
|
|
83
84
|
};
|
|
84
85
|
process.exitCode = await runCli(process.argv.slice(2), {
|
|
85
|
-
mcp: () => () => import("./chunk-
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
mcp: () => () => import("./chunk-LQ6KNUNN.mjs"),
|
|
87
|
+
watch: () => () => import("./chunk-FA6Z65DW.mjs"),
|
|
88
|
+
local: () => () => import("./chunk-PJ3E3IVH.mjs"),
|
|
89
|
+
install: () => () => import("./chunk-AK74S7EN.mjs"),
|
|
88
90
|
hook: (name) => Object.hasOwn(hooks, name) ? hooks[name] : void 0
|
|
89
91
|
});
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|