khala-cli 0.4.2 → 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.
Files changed (33) hide show
  1. package/dist/{chunk-K4MDSFHU.mjs → chunk-6OADQWV7.mjs} +14 -10
  2. package/dist/{chunk-MHZWR4A3.mjs → chunk-7CVU5OZ7.mjs} +1 -1
  3. package/dist/{chunk-7MQAMABY.mjs → chunk-AK74S7EN.mjs} +4 -4
  4. package/dist/chunk-AUJEUKVM.mjs +121 -0
  5. package/dist/chunk-DC3OX6F4.mjs +52 -0
  6. package/dist/chunk-ENPBK5W2.mjs +187 -0
  7. package/dist/chunk-FA6Z65DW.mjs +19 -0
  8. package/dist/{chunk-JRZZVTQ4.mjs → chunk-FUU775QM.mjs} +81 -10
  9. package/dist/chunk-GE3RXO2X.mjs +26 -0
  10. package/dist/{chunk-YP45XTOH.mjs → chunk-LHAMBQK7.mjs} +5 -5
  11. package/dist/{chunk-T6RZE5IQ.mjs → chunk-LN3G2LJV.mjs} +10 -7
  12. package/dist/{chunk-NUS6M27N.mjs → chunk-LQ6KNUNN.mjs} +64 -51
  13. package/dist/{chunk-CDHHFC6C.mjs → chunk-MU4FUENP.mjs} +3 -2
  14. package/dist/{chunk-2OO725IZ.mjs → chunk-MZS7XFMC.mjs} +3 -3
  15. package/dist/{chunk-U5ZMOPUK.mjs → chunk-N5VYKQMR.mjs} +5 -46
  16. package/dist/{chunk-BZ53MZEE.mjs → chunk-OS2JLDL7.mjs} +4 -2
  17. package/dist/chunk-P5CP32X2.mjs +170 -0
  18. package/dist/{chunk-46PTKRZC.mjs → chunk-PJ3E3IVH.mjs} +171 -113
  19. package/dist/chunk-SN3STAO2.mjs +190 -0
  20. package/dist/{chunk-B5BFL7OD.mjs → chunk-XEYKJMZL.mjs} +1 -1
  21. package/dist/{chunk-A3LJU4JA.mjs → chunk-ZKDDKUUA.mjs} +1 -1
  22. package/dist/{chunk-RW3DXWNC.mjs → chunk-ZRFXZK72.mjs} +1 -1
  23. package/dist/khala.mjs +12 -10
  24. package/dist/web/assets/apple-touch-icon-Du9V6qit.png +0 -0
  25. package/dist/web/assets/favicon-16x16-D5waNSZD.png +0 -0
  26. package/dist/web/assets/favicon-32x32-B9Ubw1Dx.png +0 -0
  27. package/dist/web/assets/favicon-zCD0pKtT.ico +0 -0
  28. package/dist/web/assets/local-Bk8hMIT-.js +9 -0
  29. package/dist/web/assets/{local-DHYvcQG0.css → local-vdvavyq0.css} +1 -1
  30. package/dist/web/index.html +7 -2
  31. package/package.json +1 -1
  32. package/dist/chunk-N6LMHR7P.mjs +0 -455
  33. package/dist/web/assets/local-CVA9799w.js +0 -9
@@ -1,455 +0,0 @@
1
- import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
2
-
3
- // ../contracts/src/delivery/decode.ts
4
- var MAX_IDENTIFIER_BYTES = 512;
5
- var DecodeFailure = class extends Error {
6
- code;
7
- field;
8
- constructor(field, code) {
9
- super(`${field || "<root>"}: ${code}`);
10
- this.name = "DecodeFailure";
11
- this.code = code;
12
- this.field = field;
13
- }
14
- };
15
- function fail(field, code) {
16
- throw new DecodeFailure(field, 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, code: error.code, field: error.field };
23
- return { ok: false, code: "invalid_field", field: "" };
24
- }
25
- }
26
- function utf8Length(value) {
27
- let bytes = 0;
28
- for (const character of value) {
29
- const codePoint = character.codePointAt(0) ?? 0;
30
- if (codePoint < 128) bytes += 1;
31
- else if (codePoint < 2048) bytes += 2;
32
- else if (codePoint < 65536) bytes += 3;
33
- else bytes += 4;
34
- }
35
- return bytes;
36
- }
37
- function isWellFormed(value) {
38
- for (let index = 0; index < value.length; index += 1) {
39
- const unit = value.charCodeAt(index);
40
- if (unit >= 55296 && unit <= 56319) {
41
- const next = value.charCodeAt(index + 1);
42
- if (!(next >= 56320 && next <= 57343)) return false;
43
- index += 1;
44
- } else if (unit >= 56320 && unit <= 57343) {
45
- return false;
46
- }
47
- }
48
- return true;
49
- }
50
- var CONTROL = /[\u0000-\u001f\u007f-\u009f]/;
51
- function identifier(input, field) {
52
- if (typeof input !== "string") fail(field, "invalid_field");
53
- if (!isWellFormed(input) || input.length === 0 || CONTROL.test(input)) fail(field, "invalid_field");
54
- if (utf8Length(input) > MAX_IDENTIFIER_BYTES) fail(field, "limit_exceeded");
55
- return input;
56
- }
57
- function literal(input, field, allowed) {
58
- if (!allowed.includes(input)) fail(field, "invalid_field");
59
- return input;
60
- }
61
-
62
- // ../contracts/src/delivery/ids.ts
63
- function readId(input, field) {
64
- return identifier(input, field);
65
- }
66
- var idDecoder = () => (input) => decodeWith(() => readId(input, ""));
67
- var decodeOwnerId = idDecoder();
68
- var decodeParticipantId = idDecoder();
69
- var decodeDeviceId = idDecoder();
70
- var decodeBindingId = idDecoder();
71
- var decodeRoomId = idDecoder();
72
- var decodeEventId = idDecoder();
73
- var decodeCommandId = idDecoder();
74
- var decodeReleaseId = idDecoder();
75
- var decodeReceiptId = idDecoder();
76
- var decodeAuthorizationId = idDecoder();
77
- var decodeOperationId = idDecoder();
78
- var decodeCausalRootId = idDecoder();
79
-
80
- // ../contracts/src/delivery/listening-mode.ts
81
- var LISTENING_MODES = ["steer", "sync", "async"];
82
- function decodeListeningMode(input) {
83
- return decodeWith(() => literal(input, "", LISTENING_MODES));
84
- }
85
-
86
- // ../contracts/src/messaging/decode.ts
87
- var MAX_IDENTIFIER_BYTES2 = 512;
88
- var DecodeFailure2 = class extends Error {
89
- path;
90
- code;
91
- constructor(path, code) {
92
- super(`${path || "<root>"}: ${code}`);
93
- this.name = "DecodeFailure";
94
- this.path = path;
95
- this.code = code;
96
- }
97
- };
98
- function fail2(path, code) {
99
- throw new DecodeFailure2(path, code);
100
- }
101
- function decodeWith2(read) {
102
- try {
103
- return { ok: true, value: read() };
104
- } catch (error) {
105
- if (error instanceof DecodeFailure2) return { ok: false, error: { path: error.path, code: error.code } };
106
- throw error;
107
- }
108
- }
109
- var join = (path, key) => typeof key === "number" ? `${path}[${key}]` : path ? `${path}.${key}` : key;
110
- function object2(input, path, keys) {
111
- if (typeof input !== "object" || input === null || Array.isArray(input)) fail2(path, "not_object");
112
- const prototype = Object.getPrototypeOf(input);
113
- if (prototype !== Object.prototype && prototype !== null) fail2(path, "not_object");
114
- const record2 = input;
115
- for (const key of Object.keys(record2)) if (!keys.includes(key)) fail2(join(path, key), "unknown_field");
116
- for (const key of keys) if (!Object.hasOwn(record2, key)) fail2(join(path, key), "missing_field");
117
- return { path, field: (key) => record2[key], at: (key) => join(path, key) };
118
- }
119
- function array(input, path) {
120
- if (!Array.isArray(input)) fail2(path, "wrong_type");
121
- return input;
122
- }
123
- function elementPath(path, index) {
124
- return join(path, index);
125
- }
126
- function utf8Length2(value) {
127
- let bytes = 0;
128
- for (const char of value) {
129
- const code = char.codePointAt(0) ?? 0;
130
- bytes += code < 128 ? 1 : code < 2048 ? 2 : code < 65536 ? 3 : 4;
131
- }
132
- return bytes;
133
- }
134
- function isWellFormed2(value) {
135
- for (let index = 0; index < value.length; index += 1) {
136
- const unit = value.charCodeAt(index);
137
- if (unit >= 55296 && unit <= 56319) {
138
- const next = value.charCodeAt(index + 1);
139
- if (!(next >= 56320 && next <= 57343)) return false;
140
- index += 1;
141
- } else if (unit >= 56320 && unit <= 57343) return false;
142
- }
143
- return true;
144
- }
145
- var CONTROL2 = /[\u0000-\u001f\u007f-\u009f]/;
146
- var INVISIBLE = /[\u061c\u200b\u200e\u200f\u202a-\u202e\u2060\u2066-\u2069\ufeff]/;
147
- function text(input, path, maxBytes) {
148
- if (typeof input !== "string") fail2(path, "wrong_type");
149
- if (!Number.isSafeInteger(maxBytes) || maxBytes < 0) fail2(path, "invalid_limits");
150
- if (!isWellFormed2(input)) fail2(path, "malformed_unicode");
151
- if (utf8Length2(input) > maxBytes) fail2(path, "too_long");
152
- if (input.includes("\0")) fail2(path, "control_character");
153
- return input;
154
- }
155
- function label(input, path, maxBytes) {
156
- const value = text(input, path, maxBytes);
157
- if (CONTROL2.test(value)) fail2(path, "control_character");
158
- return value;
159
- }
160
- function displayText(input, path, maxBytes) {
161
- const value = label(input, path, maxBytes);
162
- if (INVISIBLE.test(value)) fail2(path, "control_character");
163
- return value;
164
- }
165
- function identifier2(input, path) {
166
- const value = label(input, path, MAX_IDENTIFIER_BYTES2);
167
- if (value.length === 0) fail2(path, "empty");
168
- return value;
169
- }
170
- function nullable2(input, read) {
171
- return input === null ? null : read(input);
172
- }
173
- function literal2(input, path, allowed) {
174
- if (!allowed.includes(input)) fail2(path, typeof input === typeof allowed[0] ? "invalid_value" : "wrong_type");
175
- return input;
176
- }
177
- function version2(input, path) {
178
- if (input !== 1) fail2(path, "unsupported_version");
179
- return 1;
180
- }
181
- function safeInteger2(input, path) {
182
- if (typeof input !== "number") fail2(path, "wrong_type");
183
- if (!Number.isSafeInteger(input)) fail2(path, "unsafe_integer");
184
- if (input < 0) fail2(path, "invalid_value");
185
- return input;
186
- }
187
- var UTC_TIMESTAMP = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d{1,9})?Z$/;
188
- function utcTimestamp2(input, path) {
189
- if (typeof input !== "string") fail2(path, "wrong_type");
190
- const match = UTC_TIMESTAMP.exec(input);
191
- if (!match) fail2(path, "invalid_value");
192
- const [year, month, day, hour, minute, second] = match.slice(1).map(Number);
193
- const date = /* @__PURE__ */ new Date(0);
194
- date.setUTCFullYear(year, month - 1, day);
195
- date.setUTCHours(hour, minute, second, 0);
196
- if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day || date.getUTCHours() !== hour || date.getUTCMinutes() !== minute || date.getUTCSeconds() !== second) fail2(path, "invalid_value");
197
- return input;
198
- }
199
-
200
- // ../contracts/src/messaging/agent-names.ts
201
- var MAX_AGENT_NAME_BYTES = 80;
202
- var unsafe = /[\u0000-\u001f\u007f-\u009f\u061c\u200b-\u200f\u2028-\u202e\u2060-\u2069\ufeff]/u;
203
- var reserved = /\b(?:admin(?:istrator)?|system|khala|moderator|owner|human|security|support|official)\b/iu;
204
- function validateAgentName(input) {
205
- if (typeof input !== "string") return { ok: false, error: "blank" };
206
- const name = input.trim().normalize("NFC");
207
- if (!name) return { ok: false, error: "blank" };
208
- if (unsafe.test(name)) return { ok: false, error: "invalid_characters" };
209
- if (new TextEncoder().encode(name).byteLength > MAX_AGENT_NAME_BYTES) return { ok: false, error: "too_long" };
210
- if (reserved.test(name.normalize("NFKC"))) return { ok: false, error: "reserved" };
211
- return { ok: true, name };
212
- }
213
-
214
- // ../contracts/src/m1/agent-join.ts
215
- var HARNESSES = ["claude", "codex", "cursor"];
216
- var M1_LABEL_MAX_BYTES = 512;
217
- var agentConfirmPagePath = (id) => `/agent/confirm?joinId=${encodeURIComponent(id)}`;
218
- function readHarness(input, path) {
219
- return literal2(input, path, HARNESSES);
220
- }
221
- function readHttpUrl(input, path) {
222
- if (typeof input !== "string") fail2(path, "wrong_type");
223
- let url;
224
- try {
225
- url = new URL(input);
226
- } catch {
227
- fail2(path, "invalid_value");
228
- }
229
- if (url.username || url.password || url.hash || !(url.protocol === "https:" || url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname))) fail2(path, "invalid_value");
230
- return input;
231
- }
232
- function readMatrixUserId(input, path) {
233
- const value = identifier2(input, path);
234
- if (!/^@[^\s:]+:\S+$/u.test(value)) fail2(path, "invalid_value");
235
- return value;
236
- }
237
- function readRoomId(input, path) {
238
- const value = identifier2(input, path);
239
- if (!/^!\S+$/u.test(value)) fail2(path, "invalid_value");
240
- return value;
241
- }
242
- var validAgentSessionId = (value) => typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$/u.test(value);
243
- var validAgentRejoinSecret = (value) => typeof value === "string" && /^[A-Za-z0-9_-]{43}$/u.test(value);
244
-
245
- // ../contracts/src/m1/listening-mode.ts
246
- var LISTENING_MODE_COMMAND_TYPE = "com.khala.listening_mode.v1";
247
- var LISTENING_MODE_MEMBER_KEY = "com.khala.listening_mode";
248
- var DEFAULT_LISTENING_MODE = "sync";
249
- function decodeListeningModeCommand(input) {
250
- return decodeWith2(() => {
251
- const r = object2(input, "", ["v", "agent", "mode"]);
252
- return {
253
- v: version2(r.field("v"), r.at("v")),
254
- agent: readMatrixUserId(r.field("agent"), r.at("agent")),
255
- mode: literal2(r.field("mode"), r.at("mode"), LISTENING_MODES)
256
- };
257
- });
258
- }
259
- function memberListeningMode(content) {
260
- const value = typeof content === "object" && content !== null ? content[LISTENING_MODE_MEMBER_KEY] : void 0;
261
- const decoded = decodeListeningMode(value);
262
- return decoded.ok ? decoded.value : DEFAULT_LISTENING_MODE;
263
- }
264
-
265
- // ../contracts/src/m1/channel-event.ts
266
- var CHANNEL_EVENT_TYPE = "com.khala.event.v1";
267
- var CHANNEL_EVENT_STATUSES = ["info", "pending", "success", "failure", "attention"];
268
- var MAX_CHANNEL_EVENT_BYTES = 4096;
269
- function record(input, path) {
270
- if (typeof input !== "object" || input === null || Array.isArray(input)) fail2(path, "not_object");
271
- const prototype = Object.getPrototypeOf(input);
272
- if (prototype !== Object.prototype && prototype !== null) fail2(path, "not_object");
273
- const value = input;
274
- return {
275
- has: (key) => Object.hasOwn(value, key) && value[key] !== void 0,
276
- field: (key) => Object.hasOwn(value, key) ? value[key] : fail2(path ? `${path}.${key}` : key, "missing_field"),
277
- at: (key) => path ? `${path}.${key}` : key
278
- };
279
- }
280
- function nonempty(value, path) {
281
- if (!value.length) fail2(path, "empty");
282
- return value;
283
- }
284
- function display(input, path, maxBytes, maxPoints) {
285
- const value = nonempty(displayText(input, path, maxBytes), path);
286
- if ([...value].length > maxPoints) fail2(path, "too_long");
287
- return value;
288
- }
289
- function matching(value, path, pattern) {
290
- if (!pattern.test(value)) fail2(path, "invalid_value");
291
- return value;
292
- }
293
- function safely(read) {
294
- try {
295
- return read();
296
- } catch {
297
- return { ok: false, error: { path: "", code: "invalid_value" } };
298
- }
299
- }
300
- function decodeChannelEvent(raw) {
301
- return safely(() => decodeWith2(() => {
302
- let serialized;
303
- try {
304
- serialized = JSON.stringify(raw);
305
- } catch {
306
- fail2("", "invalid_value");
307
- }
308
- if (serialized !== void 0 && utf8Length2(serialized) > MAX_CHANNEL_EVENT_BYTES) fail2("", "too_long");
309
- const r = record(raw, "");
310
- const v = version2(r.field("v"), "v");
311
- const kind = matching(nonempty(label(r.field("kind"), "kind", 128), "kind"), "kind", /^[a-z0-9_-]+(\.[a-z0-9_-]+)*$/);
312
- const summary = display(r.field("summary"), "summary", 800, 200);
313
- if (!summary.trim()) fail2("summary", "empty");
314
- const body = label(r.field("body"), "body", 1024);
315
- return {
316
- v,
317
- kind,
318
- summary,
319
- body,
320
- ...r.has("status") ? { status: literal2(r.field("status"), "status", CHANNEL_EVENT_STATUSES) } : {},
321
- ...r.has("subject") ? { subject: readSubject(r.field("subject")) } : {},
322
- ...r.has("actor") ? { actor: display(r.field("actor"), "actor", 256, 64) } : {},
323
- ...r.has("url") ? { url: readUrl(r.field("url")) } : {},
324
- ...r.has("occurred_at") ? { occurred_at: utcTimestamp2(r.field("occurred_at"), "occurred_at") } : {},
325
- ...r.has("source") ? { source: readSource(r.field("source")) } : {},
326
- ...r.has("key") ? { key: nonempty(label(r.field("key"), "key", 200), "key") } : {}
327
- };
328
- }));
329
- }
330
- function readSubject(input) {
331
- const r = record(input, "subject");
332
- let pr;
333
- if (r.has("pr")) {
334
- pr = safeInteger2(r.field("pr"), r.at("pr"));
335
- if (pr === 0) fail2(r.at("pr"), "invalid_value");
336
- }
337
- let branch;
338
- if (r.has("branch")) {
339
- branch = nonempty(label(r.field("branch"), r.at("branch"), 255), r.at("branch"));
340
- if (branch.startsWith("refs/")) fail2(r.at("branch"), "invalid_value");
341
- }
342
- return {
343
- ...r.has("ticket") ? { ticket: display(r.field("ticket"), r.at("ticket"), 256, 64) } : {},
344
- ...pr !== void 0 ? { pr } : {},
345
- ...branch !== void 0 ? { branch } : {},
346
- ...r.has("repo") ? { repo: matching(label(r.field("repo"), r.at("repo"), 140), r.at("repo"), /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/) } : {},
347
- ...r.has("sha") ? { sha: matching(label(r.field("sha"), r.at("sha"), 64), r.at("sha"), /^[0-9a-f]{7,64}$/) } : {}
348
- };
349
- }
350
- function readSource(input) {
351
- const r = record(input, "source");
352
- return {
353
- system: nonempty(label(r.field("system"), r.at("system"), 32), r.at("system")),
354
- ...r.has("topic") ? { topic: label(r.field("topic"), r.at("topic"), 256) } : {},
355
- ...r.has("event_id") ? { event_id: label(r.field("event_id"), r.at("event_id"), 64) } : {}
356
- };
357
- }
358
- function readUrl(input) {
359
- if (typeof input !== "string") fail2("url", "wrong_type");
360
- if (utf8Length2(input) > 2048) fail2("url", "too_long");
361
- try {
362
- if (new URL(input).protocol !== "https:") fail2("url", "invalid_value");
363
- } catch {
364
- fail2("url", "invalid_value");
365
- }
366
- return input;
367
- }
368
- function formatChannelEventLine(content) {
369
- const { summary, subject } = content;
370
- const head = subject?.ticket ? `${subject.ticket} ${summary}` : summary;
371
- const tail = subject?.branch ?? (subject?.pr !== void 0 ? `PR #${subject.pr}` : void 0);
372
- return tail ? `${head} \xB7 ${tail}` : head;
373
- }
374
- function encodeChannelEvent(input) {
375
- return safely(() => {
376
- const checked = decodeWith2(() => {
377
- record(input, "");
378
- return { ...input, v: 1, body: "" };
379
- });
380
- if (!checked.ok) return checked;
381
- const decoded = decodeChannelEvent(checked.value);
382
- if (!decoded.ok) return decoded;
383
- return decodeChannelEvent({ ...decoded.value, body: formatChannelEventLine(decoded.value) });
384
- });
385
- }
386
- function memberRenameContent(content, previous) {
387
- const oldName = previous?.["displayname"];
388
- const newName = content["displayname"];
389
- if (previous?.["membership"] !== "join" || content["membership"] !== "join" || typeof oldName !== "string" || !oldName.trim() || typeof newName !== "string" || !newName.trim() || oldName === newName) return null;
390
- const encoded = encodeChannelEvent({ kind: "member", summary: `${oldName} is now ${newName}`, status: "info", source: { system: "khala" } });
391
- return encoded.ok ? encoded.value : null;
392
- }
393
- function statusFor(content) {
394
- if (content.status !== void 0) return content.status;
395
- switch (content.kind) {
396
- case "ci.passed":
397
- case "pr.merged":
398
- case "agent.unblocked":
399
- return "success";
400
- case "ci.failed":
401
- return "failure";
402
- case "pr.ready_for_review":
403
- case "pr.parked_ready":
404
- return "pending";
405
- case "agent.paused":
406
- case "agent.blocked":
407
- case "agent.pause.request":
408
- return "attention";
409
- default:
410
- return content.kind.startsWith("agent.attention.") && !content.kind.endsWith(".resolved") ? "attention" : "info";
411
- }
412
- }
413
-
414
- export {
415
- fail2 as fail,
416
- decodeWith2 as decodeWith,
417
- object2 as object,
418
- array,
419
- elementPath,
420
- utf8Length2 as utf8Length,
421
- isWellFormed2 as isWellFormed,
422
- text,
423
- label,
424
- displayText,
425
- identifier2 as identifier,
426
- nullable2 as nullable,
427
- literal2 as literal,
428
- version2 as version,
429
- safeInteger2 as safeInteger,
430
- utcTimestamp2 as utcTimestamp,
431
- reserved,
432
- validateAgentName,
433
- HARNESSES,
434
- M1_LABEL_MAX_BYTES,
435
- agentConfirmPagePath,
436
- readHarness,
437
- readHttpUrl,
438
- readMatrixUserId,
439
- readRoomId,
440
- validAgentSessionId,
441
- validAgentRejoinSecret,
442
- LISTENING_MODES,
443
- decodeListeningMode,
444
- LISTENING_MODE_COMMAND_TYPE,
445
- LISTENING_MODE_MEMBER_KEY,
446
- DEFAULT_LISTENING_MODE,
447
- decodeListeningModeCommand,
448
- memberListeningMode,
449
- CHANNEL_EVENT_TYPE,
450
- decodeChannelEvent,
451
- formatChannelEventLine,
452
- encodeChannelEvent,
453
- memberRenameContent,
454
- statusFor
455
- };