khala-cli 0.4.9 → 0.4.10

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 (45) hide show
  1. package/dist/THIRD_PARTY_NOTICES.txt +28 -0
  2. package/dist/{chunk-NIX5F4LT.mjs → chunk-2AMWQ7RB.mjs} +330 -66
  3. package/dist/{chunk-PAJ4JJPV.mjs → chunk-3E5DH3Y6.mjs} +43 -6
  4. package/dist/{chunk-NGSYOVQ4.mjs → chunk-4BP7V3OP.mjs} +2 -2
  5. package/dist/{chunk-TEFOQXBK.mjs → chunk-4BZQ4GVW.mjs} +3 -3
  6. package/dist/{chunk-ITFD3JZS.mjs → chunk-5JSGA6OB.mjs} +424 -78
  7. package/dist/{chunk-QKWEZXR3.mjs → chunk-6AQVW5W7.mjs} +12 -4
  8. package/dist/{chunk-UK5GJO4Y.mjs → chunk-6J2PUM7L.mjs} +6 -5
  9. package/dist/{chunk-P3YIN7G7.mjs → chunk-6SUV3EW6.mjs} +11 -10
  10. package/dist/{chunk-GSZADJMW.mjs → chunk-ARIDZOTI.mjs} +309 -81
  11. package/dist/chunk-C2WEDMAF.mjs +15 -0
  12. package/dist/{chunk-DJM23SIU.mjs → chunk-CHC4VZF5.mjs} +7 -8
  13. package/dist/{chunk-BLCRVRIK.mjs → chunk-CKLCR5G4.mjs} +456 -87
  14. package/dist/{chunk-7R3EIDGR.mjs → chunk-EVT2DWNZ.mjs} +1 -1
  15. package/dist/{chunk-KMLXOPBQ.mjs → chunk-FJVVSKZ3.mjs} +4 -2
  16. package/dist/{chunk-3KDOTR54.mjs → chunk-G3NMB4PY.mjs} +1 -1
  17. package/dist/{chunk-SSO5RFOX.mjs → chunk-HHEZVPRR.mjs} +1 -1
  18. package/dist/{chunk-BV45NK7K.mjs → chunk-JKOJQTFT.mjs} +100 -6
  19. package/dist/{chunk-T7IL7V7Q.mjs → chunk-NDMFD5IM.mjs} +13 -10
  20. package/dist/{chunk-TANCKTDK.mjs → chunk-OEV5DFLW.mjs} +70 -5
  21. package/dist/{chunk-BEO7WIIM.mjs → chunk-OIZ4R5H7.mjs} +28 -8
  22. package/dist/{chunk-FZEH2IXZ.mjs → chunk-PJKI7SRI.mjs} +176 -26
  23. package/dist/{chunk-NPSQNCOY.mjs → chunk-PN25BUQ4.mjs} +13 -4
  24. package/dist/{chunk-3R6HFSLL.mjs → chunk-QDPJ4VT2.mjs} +92 -38
  25. package/dist/{chunk-FO5GXCST.mjs → chunk-SRZTHCXP.mjs} +5 -5
  26. package/dist/{chunk-LBT47HLZ.mjs → chunk-TSK3HJEG.mjs} +10 -9
  27. package/dist/{chunk-6BO3JSUP.mjs → chunk-UX34IVN5.mjs} +2 -2
  28. package/dist/{chunk-V4F3SYKW.mjs → chunk-VAC3JTAV.mjs} +25 -17
  29. package/dist/{chunk-PDZ5Z5ZE.mjs → chunk-VDZK4LW3.mjs} +24 -9
  30. package/dist/chunk-W6HM6F2U.mjs +901 -0
  31. package/dist/{chunk-WDOHRV3D.mjs → chunk-WPNMWNCL.mjs} +14 -14
  32. package/dist/chunk-WUDXHF2Q.mjs +14 -0
  33. package/dist/{chunk-XBQDIKB5.mjs → chunk-WZJ6DQJV.mjs} +9 -8
  34. package/dist/{chunk-ANSR4IAW.mjs → chunk-XR625T3I.mjs} +2 -2
  35. package/dist/{chunk-K7V7X6WU.mjs → chunk-ZSKLNZWZ.mjs} +21 -4
  36. package/dist/iterm2_send.py +56 -0
  37. package/dist/khala.mjs +11 -11
  38. package/dist/web/assets/local-CSPuGnH2.css +1 -0
  39. package/dist/web/assets/local-Dtyxaacx.js +9 -0
  40. package/dist/web/index.html +2 -2
  41. package/package.json +1 -1
  42. package/dist/chunk-47XNLAJG.mjs +0 -38
  43. package/dist/chunk-XUCWSYVS.mjs +0 -148
  44. package/dist/web/assets/local-CFzRHZpB.js +0 -9
  45. package/dist/web/assets/local-ciypUFoK.css +0 -1
@@ -0,0 +1,901 @@
1
+ import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
2
+ import {
3
+ adapterFor
4
+ } from "./chunk-5JSGA6OB.mjs";
5
+ import {
6
+ installedLauncher,
7
+ launcherShellQuote,
8
+ readWakeSettings
9
+ } from "./chunk-2AMWQ7RB.mjs";
10
+ import {
11
+ HARNESS_REGISTRY,
12
+ filesForDir,
13
+ readStateFile,
14
+ stateRoot
15
+ } from "./chunk-PN25BUQ4.mjs";
16
+ import {
17
+ readWakeState
18
+ } from "./chunk-ZSKLNZWZ.mjs";
19
+ import {
20
+ init_define_KHALA_BUNDLE
21
+ } from "./chunk-EVT2DWNZ.mjs";
22
+
23
+ // src/wake/status.ts
24
+ init_define_KHALA_BUNDLE();
25
+ import path3 from "node:path";
26
+
27
+ // src/wake/installation.ts
28
+ init_define_KHALA_BUNDLE();
29
+ import { readFile } from "node:fs/promises";
30
+ import os from "node:os";
31
+ import path from "node:path";
32
+
33
+ // ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/index.js
34
+ init_define_KHALA_BUNDLE();
35
+
36
+ // ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/parse.js
37
+ init_define_KHALA_BUNDLE();
38
+
39
+ // ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/struct.js
40
+ init_define_KHALA_BUNDLE();
41
+
42
+ // ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/primitive.js
43
+ init_define_KHALA_BUNDLE();
44
+
45
+ // ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/date.js
46
+ init_define_KHALA_BUNDLE();
47
+ var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
48
+ var TomlDate = class _TomlDate extends Date {
49
+ #hasDate = false;
50
+ #hasTime = false;
51
+ #offset = null;
52
+ constructor(date) {
53
+ let hasDate = true;
54
+ let hasTime = true;
55
+ let offset = "Z";
56
+ if (typeof date === "string") {
57
+ let match = date.match(DATE_TIME_RE);
58
+ if (match) {
59
+ if (!match[1]) {
60
+ hasDate = false;
61
+ date = `0000-01-01T${date}`;
62
+ }
63
+ hasTime = !!match[2];
64
+ hasTime && date[10] === " " && (date = date.replace(" ", "T"));
65
+ if (match[2] && +match[2] > 23) {
66
+ date = "";
67
+ } else {
68
+ offset = match[3] || null;
69
+ date = date.toUpperCase();
70
+ if (!offset && hasTime)
71
+ date += "Z";
72
+ }
73
+ } else {
74
+ date = "";
75
+ }
76
+ }
77
+ super(date);
78
+ if (!isNaN(this.getTime())) {
79
+ this.#hasDate = hasDate;
80
+ this.#hasTime = hasTime;
81
+ this.#offset = offset;
82
+ }
83
+ }
84
+ isDateTime() {
85
+ return this.#hasDate && this.#hasTime;
86
+ }
87
+ isLocal() {
88
+ return !this.#hasDate || !this.#hasTime || !this.#offset;
89
+ }
90
+ isDate() {
91
+ return this.#hasDate && !this.#hasTime;
92
+ }
93
+ isTime() {
94
+ return this.#hasTime && !this.#hasDate;
95
+ }
96
+ isValid() {
97
+ return this.#hasDate || this.#hasTime;
98
+ }
99
+ toISOString() {
100
+ let iso = super.toISOString();
101
+ if (this.isDate())
102
+ return iso.slice(0, 10);
103
+ if (this.isTime())
104
+ return iso.slice(11, 23);
105
+ if (this.#offset === null)
106
+ return iso.slice(0, -1);
107
+ if (this.#offset === "Z")
108
+ return iso;
109
+ let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
110
+ offset = this.#offset[0] === "-" ? offset : -offset;
111
+ let offsetDate = new Date(this.getTime() - offset * 6e4);
112
+ return offsetDate.toISOString().slice(0, -1) + this.#offset;
113
+ }
114
+ static wrapAsOffsetDateTime(jsDate, offset = "Z") {
115
+ let date = new _TomlDate(jsDate);
116
+ date.#offset = offset;
117
+ return date;
118
+ }
119
+ static wrapAsLocalDateTime(jsDate) {
120
+ let date = new _TomlDate(jsDate);
121
+ date.#offset = null;
122
+ return date;
123
+ }
124
+ static wrapAsLocalDate(jsDate) {
125
+ let date = new _TomlDate(jsDate);
126
+ date.#hasTime = false;
127
+ date.#offset = null;
128
+ return date;
129
+ }
130
+ static wrapAsLocalTime(jsDate) {
131
+ let date = new _TomlDate(jsDate);
132
+ date.#hasDate = false;
133
+ date.#offset = null;
134
+ return date;
135
+ }
136
+ };
137
+
138
+ // ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/error.js
139
+ init_define_KHALA_BUNDLE();
140
+ function getLineColFromPtr(string, ptr) {
141
+ let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
142
+ return [lines.length, lines.pop().length + 1];
143
+ }
144
+ function makeCodeBlock(string, line, column) {
145
+ let lines = string.split(/\r\n|\n|\r/g);
146
+ let codeblock = "";
147
+ let numberLen = (Math.log10(line + 1) | 0) + 1;
148
+ for (let i = line - 1; i <= line + 1; i++) {
149
+ let l = lines[i - 1];
150
+ if (!l)
151
+ continue;
152
+ codeblock += i.toString().padEnd(numberLen, " ");
153
+ codeblock += ": ";
154
+ codeblock += l;
155
+ codeblock += "\n";
156
+ if (i === line) {
157
+ codeblock += " ".repeat(numberLen + column + 2);
158
+ codeblock += "^\n";
159
+ }
160
+ }
161
+ return codeblock;
162
+ }
163
+ var TomlError = class extends Error {
164
+ line;
165
+ column;
166
+ codeblock;
167
+ constructor(message, options) {
168
+ const [line, column] = getLineColFromPtr(options.toml, options.ptr);
169
+ const codeblock = makeCodeBlock(options.toml, line, column);
170
+ super(`Invalid TOML document: ${message}
171
+
172
+ ${codeblock}`, options);
173
+ this.line = line;
174
+ this.column = column;
175
+ this.codeblock = codeblock;
176
+ }
177
+ };
178
+
179
+ // ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/util.js
180
+ init_define_KHALA_BUNDLE();
181
+ function indexOfNewline(str, start = 0) {
182
+ let idx = str.indexOf("\n", start);
183
+ if (str.charCodeAt(idx - 1) === 13)
184
+ idx--;
185
+ return idx;
186
+ }
187
+ function skipComment(ctx) {
188
+ for (; ctx.p < ctx.s.length; ctx.p++) {
189
+ let c = ctx.s.charCodeAt(ctx.p);
190
+ if (c === 10)
191
+ break;
192
+ if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) {
193
+ ctx.p++;
194
+ break;
195
+ }
196
+ if (c < 32 && c !== 9 || c === 127) {
197
+ throw new TomlError("control characters are not allowed in comments", {
198
+ toml: ctx.s,
199
+ ptr: ctx.p
200
+ });
201
+ }
202
+ }
203
+ }
204
+ function skipVoid(ctx, banNewLines, banComments) {
205
+ let c;
206
+ while (1) {
207
+ while ((c = ctx.s.charCodeAt(ctx.p)) === 32 || c === 9 || !banNewLines && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10))
208
+ ctx.p++;
209
+ if (banComments || c !== 35)
210
+ break;
211
+ skipComment(ctx);
212
+ }
213
+ }
214
+ function skipUntil(ctx, sep, end) {
215
+ let ptr = ctx.p;
216
+ if (!end) {
217
+ ptr = indexOfNewline(ctx.s, ptr);
218
+ ctx.p = ptr < 0 ? ctx.s.length : ptr;
219
+ return;
220
+ }
221
+ for (; ctx.p < ctx.s.length; ctx.p++) {
222
+ let c = ctx.s.charCodeAt(ctx.p);
223
+ if (c === 35) {
224
+ skipComment(ctx);
225
+ } else if (c === end || c === sep) {
226
+ return;
227
+ }
228
+ }
229
+ throw new TomlError("cannot find end of structure", {
230
+ toml: ctx.s,
231
+ ptr
232
+ });
233
+ }
234
+
235
+ // ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/primitive.js
236
+ var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
237
+ var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
238
+ var LEADING_ZERO = /^[+-]?0[0-9_]/;
239
+ function parseString(ctx) {
240
+ let start = ctx.p;
241
+ let c = ctx.s.charCodeAt(ctx.p++);
242
+ let first = c;
243
+ let isLiteral = c === 39;
244
+ let isMultiline = c === ctx.s.charCodeAt(ctx.p) && c === ctx.s.charCodeAt(ctx.p + 1);
245
+ if (isMultiline) {
246
+ if ((c = ctx.s.charCodeAt(ctx.p += 2)) === 10)
247
+ ctx.p++;
248
+ else if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)
249
+ ctx.p += 2;
250
+ }
251
+ let parsed = "";
252
+ let sliceStart = ctx.p;
253
+ let state = 0;
254
+ for (; ctx.p < ctx.s.length; ctx.p++) {
255
+ c = ctx.s.charCodeAt(ctx.p);
256
+ if (isMultiline && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)) {
257
+ state = state && 3;
258
+ } else if (c < 32 && c !== 9 || c === 127) {
259
+ throw new TomlError("control characters are not allowed in strings", {
260
+ toml: ctx.s,
261
+ ptr: ctx.p
262
+ });
263
+ } else if ((!state || state === 3) && c === first && (!isMultiline || ctx.s.charCodeAt(ctx.p + 1) === first && ctx.s.charCodeAt(ctx.p + 2) === first)) {
264
+ if (isMultiline) {
265
+ if (ctx.s.charCodeAt(ctx.p + 3) === first)
266
+ ctx.p++;
267
+ if (ctx.s.charCodeAt(ctx.p + 3) === first)
268
+ ctx.p++;
269
+ }
270
+ if (!state)
271
+ parsed += ctx.s.slice(sliceStart, ctx.p);
272
+ ctx.p += isMultiline ? 3 : 1;
273
+ return parsed;
274
+ } else if (!state) {
275
+ if (!isLiteral && c === 92) {
276
+ parsed += ctx.s.slice(sliceStart, sliceStart = ctx.p);
277
+ state = 1;
278
+ }
279
+ } else if (state === 1) {
280
+ if (c === 120 || c === 117 || c === 85) {
281
+ let value = 0;
282
+ let len = c === 120 ? 2 : c === 117 ? 4 : 8;
283
+ for (let j = 0; j < len; j++, ctx.p++) {
284
+ let hex = ctx.s.charCodeAt(ctx.p + 1);
285
+ let digit = (
286
+ /* 0-9 */
287
+ hex >= 48 && hex <= 57 ? hex - 48 : (
288
+ /* A-F */
289
+ hex >= 65 && hex <= 70 ? hex - 65 + 10 : (
290
+ /* a-f */
291
+ hex >= 97 && hex <= 102 ? hex - 97 + 10 : -1
292
+ )
293
+ )
294
+ );
295
+ if (digit < 0)
296
+ throw new TomlError("invalid non-hex character in unicode escape", { toml: ctx.s, ptr: ctx.p + 1 });
297
+ value = value << 4 | digit;
298
+ }
299
+ if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) {
300
+ throw new TomlError("invalid unicode escape", { toml: ctx.s, ptr: ctx.p });
301
+ }
302
+ parsed += String.fromCodePoint(value);
303
+ sliceStart = ctx.p + 1;
304
+ state = 0;
305
+ } else if (c === 32 || c === 9) {
306
+ state = 2;
307
+ } else {
308
+ if (c === 98)
309
+ parsed += "\b";
310
+ else if (c === 116)
311
+ parsed += " ";
312
+ else if (c === 110)
313
+ parsed += "\n";
314
+ else if (c === 102)
315
+ parsed += "\f";
316
+ else if (c === 114)
317
+ parsed += "\r";
318
+ else if (c === 101)
319
+ parsed += "\x1B";
320
+ else if (c === 34)
321
+ parsed += '"';
322
+ else if (c === 92)
323
+ parsed += "\\";
324
+ else
325
+ throw new TomlError("unrecognized escape sequence", { toml: ctx.s, ptr: ctx.p });
326
+ sliceStart = ctx.p + 1;
327
+ state = 0;
328
+ }
329
+ } else if (c !== 32 && c !== 9) {
330
+ if (state === 2) {
331
+ throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
332
+ toml: ctx.s,
333
+ ptr: sliceStart
334
+ });
335
+ }
336
+ state = !isLiteral && c === 92 ? 1 : 0;
337
+ sliceStart = ctx.p;
338
+ }
339
+ }
340
+ throw new TomlError("unfinished string", { toml: ctx.s, ptr: start });
341
+ }
342
+ function sliceAndTrimEndOf(ctx, start, end) {
343
+ let value = ctx.s.slice(start, end);
344
+ let commentIdx = value.indexOf("#");
345
+ if (commentIdx > 0) {
346
+ skipComment({ s: value, p: commentIdx, d: 0 });
347
+ value = value.slice(0, commentIdx);
348
+ }
349
+ return value.trimEnd();
350
+ }
351
+ function parseValue(ctx, integersAsBigInt, end) {
352
+ let ptr = ctx.p;
353
+ let err = { toml: ctx.s, ptr };
354
+ skipUntil(ctx, 44, end);
355
+ let value = sliceAndTrimEndOf(ctx, ptr, ctx.p);
356
+ if (!value)
357
+ throw new TomlError("incomplete declaration: value expected", err);
358
+ if (value === "-inf")
359
+ return -Infinity;
360
+ if (value === "inf" || value === "+inf")
361
+ return Infinity;
362
+ if (value === "nan" || value === "+nan" || value === "-nan")
363
+ return NaN;
364
+ if (value === "-0")
365
+ return integersAsBigInt ? 0n : 0;
366
+ let isInt = INT_REGEX.test(value);
367
+ if (isInt || FLOAT_REGEX.test(value)) {
368
+ if (LEADING_ZERO.test(value)) {
369
+ throw new TomlError("leading zeroes are not allowed", err);
370
+ }
371
+ value = value.replace(/_/g, "");
372
+ let numeric = +value;
373
+ if (isNaN(numeric)) {
374
+ throw new TomlError("invalid number", err);
375
+ }
376
+ if (isInt) {
377
+ if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
378
+ throw new TomlError("integer value cannot be represented losslessly", err);
379
+ }
380
+ if (isInt || integersAsBigInt === true)
381
+ numeric = BigInt(value);
382
+ }
383
+ return numeric;
384
+ }
385
+ const date = new TomlDate(value);
386
+ if (!date.isValid())
387
+ throw new TomlError("invalid value", err);
388
+ return date;
389
+ }
390
+
391
+ // ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/extract.js
392
+ init_define_KHALA_BUNDLE();
393
+ function extractValue(ctx, end, integersAsBigInt) {
394
+ let ptr = ctx.p;
395
+ let c = ctx.s.charCodeAt(ptr);
396
+ if (c === 91 || c === 123) {
397
+ if (!ctx.d--) {
398
+ throw new TomlError("document contains excessively nested structures. aborting.", {
399
+ toml: ctx.s,
400
+ ptr
401
+ });
402
+ }
403
+ let value = c === 91 ? parseArray(ctx, integersAsBigInt) : parseInlineTable(ctx, integersAsBigInt);
404
+ ctx.d++;
405
+ return value;
406
+ }
407
+ if (c === 34 || c === 39) {
408
+ return parseString(ctx);
409
+ }
410
+ if (c === 116) {
411
+ if (ctx.s.charCodeAt(++ctx.p) !== 114 || ctx.s.charCodeAt(++ctx.p) !== 117 || ctx.s.charCodeAt(++ctx.p) !== 101)
412
+ throw new TomlError("invalid value", { toml: ctx.s, ptr });
413
+ ctx.p++;
414
+ return true;
415
+ }
416
+ if (c === 102) {
417
+ if (ctx.s.charCodeAt(++ctx.p) !== 97 || ctx.s.charCodeAt(++ctx.p) !== 108 || ctx.s.charCodeAt(++ctx.p) !== 115 || ctx.s.charCodeAt(++ctx.p) !== 101)
418
+ throw new TomlError("invalid value", { toml: ctx.s, ptr });
419
+ ctx.p++;
420
+ return false;
421
+ }
422
+ return parseValue(ctx, integersAsBigInt, end);
423
+ }
424
+
425
+ // ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/struct.js
426
+ var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
427
+ function parseKey(ctx, end = "=") {
428
+ let start = ctx.p;
429
+ let dot = start - 1;
430
+ let parsed = [];
431
+ let endPtr = ctx.s.indexOf(end, start);
432
+ if (endPtr < 0) {
433
+ throw new TomlError("incomplete key-value: cannot find end of key", {
434
+ toml: ctx.s,
435
+ ptr: start
436
+ });
437
+ }
438
+ do {
439
+ let c = ctx.s.charCodeAt(ctx.p = ++dot);
440
+ if (c !== 32 && c !== 9) {
441
+ if (c === 34 || c === 39) {
442
+ if (c === ctx.s.charCodeAt(ctx.p + 1) && c === ctx.s.charCodeAt(ctx.p + 2)) {
443
+ throw new TomlError("multiline strings are not allowed in keys", {
444
+ toml: ctx.s,
445
+ ptr: ctx.p
446
+ });
447
+ }
448
+ let part = parseString(ctx);
449
+ dot = ctx.s.indexOf(".", ctx.p);
450
+ let strEnd = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
451
+ let newLine = indexOfNewline(strEnd);
452
+ if (newLine > -1) {
453
+ throw new TomlError("newlines are not allowed in keys", {
454
+ toml: ctx.s,
455
+ ptr: newLine
456
+ });
457
+ }
458
+ if (strEnd.trimStart()) {
459
+ throw new TomlError("found extra tokens after the string part", {
460
+ toml: ctx.s,
461
+ ptr: ctx.p
462
+ });
463
+ }
464
+ if (endPtr < ctx.p) {
465
+ endPtr = ctx.s.indexOf(end, ctx.p);
466
+ if (endPtr < 0) {
467
+ throw new TomlError("incomplete key-value: cannot find end of key", {
468
+ toml: ctx.s,
469
+ ptr: start
470
+ });
471
+ }
472
+ }
473
+ parsed.push(part);
474
+ } else {
475
+ dot = ctx.s.indexOf(".", ctx.p);
476
+ let part = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
477
+ if (!KEY_PART_RE.test(part)) {
478
+ throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
479
+ toml: ctx.s,
480
+ ptr: ctx.p
481
+ });
482
+ }
483
+ parsed.push(part.trimEnd());
484
+ }
485
+ }
486
+ } while (dot + 1 && dot < endPtr);
487
+ ctx.p = endPtr + 1;
488
+ skipVoid(ctx, true, true);
489
+ return parsed;
490
+ }
491
+ function parseInlineTable(ctx, integersAsBigInt) {
492
+ let res = {};
493
+ let seen = /* @__PURE__ */ new Set();
494
+ let c;
495
+ ctx.p++;
496
+ while (ctx.p < ctx.s.length) {
497
+ skipVoid(ctx);
498
+ if ((c = ctx.s.charCodeAt(ctx.p)) === 125) {
499
+ ctx.p++;
500
+ return res;
501
+ }
502
+ let k;
503
+ let t = res;
504
+ let hasOwn = false;
505
+ let p = ctx.p;
506
+ let key = parseKey(ctx);
507
+ for (let i = 0; i < key.length; i++) {
508
+ if (i)
509
+ t = hasOwn ? t[k] : t[k] = {};
510
+ k = key[i];
511
+ if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
512
+ throw new TomlError("trying to redefine an already defined value", {
513
+ toml: ctx.s,
514
+ ptr: p
515
+ });
516
+ }
517
+ if (!hasOwn && k === "__proto__") {
518
+ Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
519
+ }
520
+ }
521
+ if (hasOwn) {
522
+ throw new TomlError("trying to redefine an already defined value", {
523
+ toml: ctx.s,
524
+ ptr: ctx.p
525
+ });
526
+ }
527
+ let value = extractValue(ctx, 125, integersAsBigInt);
528
+ seen.add(t[k] = value);
529
+ skipVoid(ctx);
530
+ if ((c = ctx.s.charCodeAt(ctx.p++)) === 125) {
531
+ return res;
532
+ }
533
+ if (c !== 44) {
534
+ throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
535
+ }
536
+ }
537
+ throw new TomlError("unfinished table encountered", {
538
+ toml: ctx.s,
539
+ ptr: ctx.p
540
+ });
541
+ }
542
+ function parseArray(ctx, integersAsBigInt) {
543
+ let res = [];
544
+ let c;
545
+ ctx.p++;
546
+ while (ctx.p < ctx.s.length) {
547
+ skipVoid(ctx);
548
+ if ((c = ctx.s.charCodeAt(ctx.p)) === 93) {
549
+ ctx.p++;
550
+ return res;
551
+ }
552
+ res.push(extractValue(ctx, 93, integersAsBigInt));
553
+ skipVoid(ctx);
554
+ if ((c = ctx.s.charCodeAt(ctx.p++)) === 93) {
555
+ return res;
556
+ }
557
+ if (c !== 44) {
558
+ throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
559
+ }
560
+ }
561
+ throw new TomlError("unfinished array encountered", {
562
+ toml: ctx.s,
563
+ ptr: ctx.p
564
+ });
565
+ }
566
+
567
+ // ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/parse.js
568
+ function peekTable(key, table, meta, type) {
569
+ let t = table;
570
+ let m = meta;
571
+ let k;
572
+ let hasOwn = false;
573
+ let state;
574
+ for (let i = 0; i < key.length; i++) {
575
+ if (i) {
576
+ t = hasOwn ? t[k] : t[k] = {};
577
+ m = (state = m[k]).c;
578
+ if (type === 0 && (state.t === 1 || state.t === 2)) {
579
+ return null;
580
+ }
581
+ if (state.t === 2) {
582
+ let l = t.length - 1;
583
+ t = t[l];
584
+ m = m[l].c;
585
+ }
586
+ }
587
+ k = key[i];
588
+ if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === 0 && m[k]?.d) {
589
+ return null;
590
+ }
591
+ if (!hasOwn) {
592
+ if (k === "__proto__") {
593
+ Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
594
+ Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
595
+ }
596
+ m[k] = {
597
+ t: i < key.length - 1 && type === 2 ? 3 : type,
598
+ d: false,
599
+ i: 0,
600
+ c: {}
601
+ };
602
+ }
603
+ }
604
+ state = m[k];
605
+ if (state.t !== type && !(type === 1 && state.t === 3)) {
606
+ return null;
607
+ }
608
+ if (type === 2) {
609
+ if (!state.d) {
610
+ state.d = true;
611
+ t[k] = [];
612
+ }
613
+ t[k].push(t = {});
614
+ state.c[state.i++] = state = { t: 1, d: false, i: 0, c: {} };
615
+ }
616
+ if (state.d) {
617
+ return null;
618
+ }
619
+ state.d = true;
620
+ if (type === 1) {
621
+ t = hasOwn ? t[k] : t[k] = {};
622
+ } else if (type === 0 && hasOwn) {
623
+ return null;
624
+ }
625
+ return [k, t, state.c];
626
+ }
627
+ function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
628
+ let ctx = { s: toml, p: 0, d: maxDepth };
629
+ let res = {};
630
+ let meta = {};
631
+ let tmp;
632
+ let tbl = res;
633
+ let m = meta;
634
+ skipVoid(ctx);
635
+ while (ctx.p < toml.length) {
636
+ if (toml.charCodeAt(ctx.p) === 91) {
637
+ let isTableArray = toml.charCodeAt(++ctx.p) === 91;
638
+ tmp = ctx.p += +isTableArray;
639
+ let k = parseKey(ctx, "]");
640
+ if (isTableArray) {
641
+ if (toml.charCodeAt(ctx.p - 1) !== 93) {
642
+ throw new TomlError("expected end of table declaration", {
643
+ toml,
644
+ ptr: ctx.p - 1
645
+ });
646
+ }
647
+ ctx.p++;
648
+ }
649
+ let p = peekTable(
650
+ k,
651
+ res,
652
+ meta,
653
+ isTableArray ? 2 : 1
654
+ /* Type.EXPLICIT */
655
+ );
656
+ if (!p) {
657
+ throw new TomlError("trying to redefine an already defined table or value", {
658
+ toml,
659
+ ptr: tmp
660
+ });
661
+ }
662
+ m = p[2];
663
+ tbl = p[1];
664
+ } else {
665
+ tmp = ctx.p;
666
+ let k = parseKey(ctx);
667
+ let p = peekTable(
668
+ k,
669
+ tbl,
670
+ m,
671
+ 0
672
+ /* Type.DOTTED */
673
+ );
674
+ if (!p) {
675
+ throw new TomlError("trying to redefine an already defined table or value", {
676
+ toml,
677
+ ptr: tmp
678
+ });
679
+ }
680
+ p[1][p[0]] = extractValue(ctx, void 0, integersAsBigInt);
681
+ }
682
+ skipVoid(ctx, true);
683
+ if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 10 && tmp !== 13) {
684
+ throw new TomlError("each key-value declaration must be followed by an end-of-line", {
685
+ toml,
686
+ ptr: ctx.p
687
+ });
688
+ }
689
+ skipVoid(ctx);
690
+ }
691
+ return res;
692
+ }
693
+
694
+ // ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/stringify.js
695
+ init_define_KHALA_BUNDLE();
696
+
697
+ // src/wake/installation.ts
698
+ var object = (value) => !!value && typeof value === "object" && !Array.isArray(value);
699
+ async function text(file) {
700
+ try {
701
+ return await readFile(file, "utf8");
702
+ } catch {
703
+ return void 0;
704
+ }
705
+ }
706
+ async function nativeWakeInstallation(harness, env) {
707
+ const home = env.HOME ?? os.homedir();
708
+ if (harness === "codex") {
709
+ const dir = env.CODEX_HOME && path.isAbsolute(env.CODEX_HOME) ? env.CODEX_HOME : path.join(home, ".codex");
710
+ try {
711
+ const config = parse(await text(path.join(dir, "config.toml")) ?? "");
712
+ const servers = config.mcp_servers;
713
+ const entry = object(servers) ? servers.khala : void 0;
714
+ if (object(entry) && entry.enabled !== false && typeof entry.command === "string" && Array.isArray(entry.args) && entry.args.includes("mcp") && entry.args.indexOf("--harness") >= 0 && entry.args[entry.args.indexOf("--harness") + 1] === "codex") return;
715
+ } catch {
716
+ }
717
+ try {
718
+ const config = JSON.parse(await text(path.join(dir, "hooks.json")) ?? "{}");
719
+ if (object(config) && object(config.hooks) && Object.values(config.hooks).some((groups) => Array.isArray(groups) && groups.some((group) => object(group) && Array.isArray(group.hooks) && group.hooks.some((hook) => object(hook) && typeof hook.command === "string" && /\bkhala(?:[.]cmd)?["']?\s+hook\s+deliver\s+--harness\s+codex\b/u.test(hook.command))))) return;
720
+ } catch {
721
+ }
722
+ } else if (harness === "opencode") {
723
+ const dir = path.join(env.XDG_CONFIG_HOME && path.isAbsolute(env.XDG_CONFIG_HOME) ? env.XDG_CONFIG_HOME : path.join(home, ".config"), "opencode");
724
+ const marker = (await text(path.join(dir, "opencode.json.khala-plugin")))?.trim();
725
+ for (const file of ["opencode.jsonc", "opencode.json"]) {
726
+ try {
727
+ const config = JSON.parse((await text(path.join(dir, file)) ?? "{}").replace(/^\uFEFF/u, ""));
728
+ if (!object(config)) continue;
729
+ if (Array.isArray(config.plugin) && config.plugin.some((spec) => typeof spec === "string" && (spec === "khala-opencode" || spec.startsWith("khala-opencode@") || spec === marker || /^file:.*[/\\]khala-opencode-[^/\\]+\.tgz$/u.test(spec)))) return;
730
+ if (object(config.mcp) && object(config.mcp.khala) && config.mcp.khala.enabled !== false)
731
+ return "OpenCode has only the Khala MCP entry; native wake requires the Khala plugin.";
732
+ } catch {
733
+ }
734
+ }
735
+ } else return;
736
+ return `Khala is not installed for ${harness}; run khala install ${harness}.`;
737
+ }
738
+
739
+ // src/wake/antigravity-registration.ts
740
+ init_define_KHALA_BUNDLE();
741
+ import os2 from "node:os";
742
+ import path2 from "node:path";
743
+ function antigravityRegisterCommand(env = process.env, bin) {
744
+ const platform = process.platform;
745
+ const home = platform === "win32" ? env.USERPROFILE || os2.homedir() : env.HOME || os2.homedir();
746
+ return launcherShellQuote(platform, bin ?? installedLauncher(platform, platform === "win32" ? path2.win32 : path2.posix, home, env).bin) + " wake register --harness antigravity";
747
+ }
748
+ function antigravityRegisterHint(env = process.env, bin) {
749
+ return `Run ${antigravityRegisterCommand(env, bin)} through your own shell tool after khala_join and at every session start; repeat if the local server restarts. Never print or send the credential environment variables.`;
750
+ }
751
+
752
+ // src/wake/status.ts
753
+ var CODEX_DAEMON_WAKE_NOTE = "Codex threads can keep answering mentions while the app-server daemon runs, even after the TUI exits. Stop with khala_leave, khala wake off --harness codex, or codex app-server daemon stop.";
754
+ var WAKE_STATES = {
755
+ held: { reason: "Held by your Qwen setting.", remedy: "/peers accept, or change agents.crossSessionInbound in Qwen settings." },
756
+ active: { reason: "Idle wake is on.", remedy: "" },
757
+ needs_consent: { reason: "Idle wake needs consent.", remedy: "khala wake on --driver <d>" },
758
+ unavailable: { reason: "No remote-control API is available.", remedy: "", reasons: {
759
+ wake_status_unavailable: "Wake status is unavailable.",
760
+ antigravity_credentials_missing: "Antigravity native wake credentials are missing.",
761
+ antigravity_credentials_rejected: "Antigravity native wake credentials were rejected.",
762
+ qwen_session_missing: "Run wake status inside a Qwen session; its messaging socket is not inherited here.",
763
+ qwen_socket_missing: "Qwen session registry or private controller credential is unavailable.",
764
+ qwen_watcher_missing: "The Qwen background shell watcher is not armed; call khala_status inside Qwen for its installed run_shell_command command.",
765
+ qwen_refused: "Qwen cross-session messaging is refused or off.",
766
+ queue_missing: "Codex queue is missing.",
767
+ codex_binary_missing: "Codex queue is missing.",
768
+ codex_queue_unavailable: "Codex queue is unavailable.",
769
+ nonce_timeout: "The wake verification deadline passed.",
770
+ windows: "Windows has no supported remote-control API.",
771
+ driver_missing: "No wake driver is installed for this transport.",
772
+ monitor_missing: "The Muse monitor is not armed; start monitor on khala watch with persistent: true, wake_delay_ms: 0, show_lines: true.",
773
+ watcher_missing: "The Claude watcher is not armed.",
774
+ terminal_aborted: "The terminal wake check was cancelled.",
775
+ terminal_unavailable_on_platform: "This platform has no supported terminal remote-control API.",
776
+ terminal_empty_prompt_unavailable: "This harness has no verified empty-prompt pattern.",
777
+ terminal_consent_required: "Terminal wake needs consent; run khala wake on --driver terminal.",
778
+ terminal_capture_pending_prompt: "Terminal capture is pending; send the first Codex prompt.",
779
+ "no remote-control API": "No terminal remote-control API is available.",
780
+ terminal_not_idle: "The agent must be idle for at least 30 seconds before a terminal wake.",
781
+ terminal_agent_exited: "The captured agent process has exited or changed.",
782
+ terminal_pane_unsafe: "The terminal pane is unavailable or its input mode is unsafe.",
783
+ terminal_pane_not_owned: "The agent does not own the terminal pane foreground process group.",
784
+ terminal_prompt_not_empty: "The terminal prompt contains a draft or its cursor has moved.",
785
+ terminal_probe_failed: "The terminal remote-control check failed.",
786
+ wezterm_pane_missing: "The captured WezTerm pane is no longer available.",
787
+ wezterm_tty_unavailable: "WezTerm did not report the pane terminal device; ownership cannot be verified.",
788
+ wezterm_cursor_unavailable: "WezTerm did not report the cursor position; an empty prompt cannot be verified."
789
+ } },
790
+ disabled: { reason: "Idle wake is off.", remedy: "khala wake on --driver <d>" },
791
+ disabled_after_failures: { reason: "Idle wake was disabled after two unverified wakes.", remedy: "khala wake on --driver <d>" },
792
+ lapsed: { reason: "The Claude watcher passed its deadline; any prompt re-arms it.", remedy: "Send any prompt to re-arm the watcher." },
793
+ none_by_design: { reason: "The generic tier has no idle wake by design.", remedy: "" }
794
+ };
795
+ function wakeStatusText(driver, state, unavailableReason) {
796
+ const text2 = WAKE_STATES[state];
797
+ return { driver, state, reason: state === "unavailable" && unavailableReason ? WAKE_STATES.unavailable.reasons[unavailableReason] : text2.reason, ...text2.remedy ? { remedy: text2.remedy.replace("<d>", driver) } : {} };
798
+ }
799
+ function wakeDrivers(harness) {
800
+ const adapter = adapterFor(harness);
801
+ const drivers = (adapter?.wakeLadder ?? []).map((driver) => ({ ...driver, runtime: driver }));
802
+ for (const driver of adapter?.wakeConsentDrivers ?? []) if (!drivers.some((item) => item.id === driver.id)) drivers.push(driver);
803
+ if (harness === "claude" && !drivers.some((driver) => driver.id === "watcher")) drivers.unshift({ id: "watcher", rung: 2, optIn: false });
804
+ return drivers.sort((a, b) => a.rung - b.rung);
805
+ }
806
+ function watcherAlive(pid) {
807
+ if (typeof pid !== "number" || !Number.isSafeInteger(pid) || pid <= 0) return false;
808
+ try {
809
+ process.kill(pid, 0);
810
+ return true;
811
+ } catch (error) {
812
+ return error.code === "EPERM";
813
+ }
814
+ }
815
+ async function wakeStatus(harness, options = {}) {
816
+ const env = options.env ?? process.env;
817
+ const settings = await readWakeSettings(stateRoot(env));
818
+ const states = options.files ? await readWakeState(options.files.dir) : {};
819
+ const drivers = wakeDrivers(harness);
820
+ if (!drivers.length) return [{ harness, rung: 0, ...wakeStatusText("none", harness === "generic" ? "none_by_design" : "unavailable", harness === "generic" ? void 0 : "driver_missing") }];
821
+ const rows = [];
822
+ for (const driver of drivers) {
823
+ const key = `${harness}/${driver.id}`;
824
+ let state;
825
+ let unavailableReason;
826
+ if (!Object.hasOwn(settings.off, key) && !states[driver.id]?.disabled && (harness === "codex" && driver.id === "queue" || harness === "opencode" && driver.id === "opencode-native")) {
827
+ const reason = await nativeWakeInstallation(harness, env);
828
+ if (reason) {
829
+ rows.push({ harness, rung: driver.rung, driver: driver.id, state: "unavailable", reason, remedy: `khala install ${harness}` });
830
+ continue;
831
+ }
832
+ }
833
+ if (Object.hasOwn(settings.off, key)) state = "disabled";
834
+ else if (states[driver.id]?.disabled) state = "disabled_after_failures";
835
+ else if (driver.optIn && !Object.hasOwn(settings.consent, key)) state = "needs_consent";
836
+ else if (driver.id === "watcher") {
837
+ const watcher = options.files ? await readStateFile(options.files.dir, "watcher.json") : null;
838
+ state = watcher?.state === "expired" ? "lapsed" : watcher?.state === "armed" && watcherAlive(watcher.pid) ? "active" : "unavailable";
839
+ if (state === "unavailable") unavailableReason = "watcher_missing";
840
+ } else if (driver.runtime) {
841
+ const files = options.files ?? filesForDir(path3.join(stateRoot(env), harness, "status"));
842
+ const ctx = { files, harness, sessionId: options.sessionId ?? "status", env, signal: new AbortController().signal, now: Date.now() };
843
+ const available = await driver.runtime.available(ctx);
844
+ state = available ? "active" : "unavailable";
845
+ if (!available) {
846
+ const reason = await driver.runtime.unavailableReason?.(ctx);
847
+ if (reason === "qwen_held") state = "held";
848
+ if (reason && Object.hasOwn(WAKE_STATES.unavailable.reasons, reason)) unavailableReason = reason;
849
+ }
850
+ } else {
851
+ state = "unavailable";
852
+ unavailableReason = process.platform === "win32" && driver.id === "terminal" ? "windows" : "driver_missing";
853
+ }
854
+ const status = wakeStatusText(driver.id, state, unavailableReason);
855
+ if (harness === "antigravity" && driver.id === "antigravity-native") {
856
+ if (!options.sessionId && state === "unavailable") {
857
+ status.reason = "Antigravity native wake credentials are scoped to a conversation.";
858
+ status.note = "Credential availability is session-scoped; run this command inside the Antigravity agent shell.";
859
+ } else if (unavailableReason === "antigravity_credentials_missing" || unavailableReason === "antigravity_credentials_rejected") status.remedy = antigravityRegisterCommand(env) + " through the agent shell";
860
+ }
861
+ rows.push({
862
+ harness,
863
+ rung: driver.rung,
864
+ ...status,
865
+ ...harness === "antigravity" && driver.id === "antigravity-native" ? { note: (status.note ? status.note + " " : "") + "Native wake and Sync continuation use billed model turns." } : {},
866
+ ...harness === "codex" && driver.id === "queue" ? { note: CODEX_DAEMON_WAKE_NOTE } : {}
867
+ });
868
+ }
869
+ return rows;
870
+ }
871
+ function selectedWakeStatus(rows) {
872
+ const row = rows.find((item) => item.state === "active") ?? rows[0];
873
+ const { driver, state, reason, remedy, note } = row;
874
+ return { driver, state, reason, ...remedy ? { remedy } : {}, ...note ? { note } : {} };
875
+ }
876
+ var WAKE_HARNESSES = HARNESS_REGISTRY.map((row) => row.id);
877
+ async function wakeDisableNotice(dir) {
878
+ const { takeWakeDisableNotices } = await import("./chunk-FJVVSKZ3.mjs");
879
+ let drivers;
880
+ try {
881
+ const states = await readWakeState(dir);
882
+ if (!Object.values(states).some((state) => state.disabled && !state.noticeShown)) return void 0;
883
+ drivers = await takeWakeDisableNotices(dir);
884
+ } catch {
885
+ return void 0;
886
+ }
887
+ return drivers.length ? drivers.map((driver) => {
888
+ const status = wakeStatusText(driver, "disabled_after_failures");
889
+ return `Idle wake (${driver}): ${status.reason} Run \`${status.remedy}\` to re-enable it.`;
890
+ }).join("\n") : void 0;
891
+ }
892
+
893
+ export {
894
+ antigravityRegisterHint,
895
+ wakeStatusText,
896
+ wakeDrivers,
897
+ wakeStatus,
898
+ selectedWakeStatus,
899
+ WAKE_HARNESSES,
900
+ wakeDisableNotice
901
+ };