@aspectlylabs/mikka 0.0.0-stage → 0.0.3

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/login.js ADDED
@@ -0,0 +1,3889 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ try {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ } catch (e) {
11
+ throw mod = 0, e;
12
+ }
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key2 of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key2) && key2 !== except)
18
+ __defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+
31
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/constants.js
32
+ var require_constants = __commonJS({
33
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/constants.js"(exports, module) {
34
+ "use strict";
35
+ var SEMVER_SPEC_VERSION = "2.0.0";
36
+ var MAX_LENGTH = 256;
37
+ var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
38
+ 9007199254740991;
39
+ var MAX_SAFE_COMPONENT_LENGTH = 16;
40
+ var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
41
+ var RELEASE_TYPES = [
42
+ "major",
43
+ "premajor",
44
+ "minor",
45
+ "preminor",
46
+ "patch",
47
+ "prepatch",
48
+ "prerelease"
49
+ ];
50
+ module.exports = {
51
+ MAX_LENGTH,
52
+ MAX_SAFE_COMPONENT_LENGTH,
53
+ MAX_SAFE_BUILD_LENGTH,
54
+ MAX_SAFE_INTEGER,
55
+ RELEASE_TYPES,
56
+ SEMVER_SPEC_VERSION,
57
+ FLAG_INCLUDE_PRERELEASE: 1,
58
+ FLAG_LOOSE: 2
59
+ };
60
+ }
61
+ });
62
+
63
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/debug.js
64
+ var require_debug = __commonJS({
65
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/debug.js"(exports, module) {
66
+ "use strict";
67
+ var debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {
68
+ };
69
+ module.exports = debug;
70
+ }
71
+ });
72
+
73
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/re.js
74
+ var require_re = __commonJS({
75
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/re.js"(exports, module) {
76
+ "use strict";
77
+ var {
78
+ MAX_SAFE_COMPONENT_LENGTH,
79
+ MAX_SAFE_BUILD_LENGTH,
80
+ MAX_LENGTH
81
+ } = require_constants();
82
+ var debug = require_debug();
83
+ exports = module.exports = {};
84
+ var re = exports.re = [];
85
+ var safeRe = exports.safeRe = [];
86
+ var src = exports.src = [];
87
+ var safeSrc = exports.safeSrc = [];
88
+ var t = exports.t = {};
89
+ var R = 0;
90
+ var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
91
+ var safeRegexReplacements = [
92
+ ["\\s", 1],
93
+ ["\\d", MAX_LENGTH],
94
+ [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
95
+ ];
96
+ var makeSafeRegex = (value) => {
97
+ for (const [token, max] of safeRegexReplacements) {
98
+ value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
99
+ }
100
+ return value;
101
+ };
102
+ var createToken = (name, value, isGlobal) => {
103
+ const safe = makeSafeRegex(value);
104
+ const index = R++;
105
+ debug(name, index, value);
106
+ t[name] = index;
107
+ src[index] = value;
108
+ safeSrc[index] = safe;
109
+ re[index] = new RegExp(value, isGlobal ? "g" : void 0);
110
+ safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
111
+ };
112
+ createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
113
+ createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
114
+ createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
115
+ createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
116
+ createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
117
+ createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
118
+ createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
119
+ createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
120
+ createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
121
+ createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
122
+ createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
123
+ createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
124
+ createToken("FULL", `^${src[t.FULLPLAIN]}$`);
125
+ createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
126
+ createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
127
+ createToken("GTLT", "((?:<|>)?=?)");
128
+ createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
129
+ createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
130
+ createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
131
+ createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
132
+ createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
133
+ createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
134
+ createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
135
+ createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
136
+ createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
137
+ createToken("COERCERTL", src[t.COERCE], true);
138
+ createToken("COERCERTLFULL", src[t.COERCEFULL], true);
139
+ createToken("LONETILDE", "(?:~>?)");
140
+ createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
141
+ exports.tildeTrimReplace = "$1~";
142
+ createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
143
+ createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
144
+ createToken("LONECARET", "(?:\\^)");
145
+ createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
146
+ exports.caretTrimReplace = "$1^";
147
+ createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
148
+ createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
149
+ createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
150
+ createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
151
+ createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
152
+ exports.comparatorTrimReplace = "$1$2$3";
153
+ createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
154
+ createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
155
+ createToken("STAR", "(<|>)?=?\\s*\\*");
156
+ createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
157
+ createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
158
+ }
159
+ });
160
+
161
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/parse-options.js
162
+ var require_parse_options = __commonJS({
163
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/parse-options.js"(exports, module) {
164
+ "use strict";
165
+ var looseOption = Object.freeze({ loose: true });
166
+ var emptyOpts = Object.freeze({});
167
+ var parseOptions = (options) => {
168
+ if (!options) {
169
+ return emptyOpts;
170
+ }
171
+ if (typeof options !== "object") {
172
+ return looseOption;
173
+ }
174
+ return options;
175
+ };
176
+ module.exports = parseOptions;
177
+ }
178
+ });
179
+
180
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/identifiers.js
181
+ var require_identifiers = __commonJS({
182
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/identifiers.js"(exports, module) {
183
+ "use strict";
184
+ var numeric = /^[0-9]+$/;
185
+ var compareIdentifiers = (a, b) => {
186
+ if (typeof a === "number" && typeof b === "number") {
187
+ return a === b ? 0 : a < b ? -1 : 1;
188
+ }
189
+ const anum = numeric.test(a);
190
+ const bnum = numeric.test(b);
191
+ if (anum && bnum) {
192
+ a = +a;
193
+ b = +b;
194
+ }
195
+ return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
196
+ };
197
+ var rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
198
+ module.exports = {
199
+ compareIdentifiers,
200
+ rcompareIdentifiers
201
+ };
202
+ }
203
+ });
204
+
205
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/semver.js
206
+ var require_semver = __commonJS({
207
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/semver.js"(exports, module) {
208
+ "use strict";
209
+ var debug = require_debug();
210
+ var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
211
+ var { safeRe: re, t } = require_re();
212
+ var parseOptions = require_parse_options();
213
+ var { compareIdentifiers } = require_identifiers();
214
+ var isPrereleaseIdentifier = (prerelease, identifier) => {
215
+ const identifiers = identifier.split(".");
216
+ if (identifiers.length > prerelease.length) {
217
+ return false;
218
+ }
219
+ for (let i = 0; i < identifiers.length; i++) {
220
+ if (compareIdentifiers(prerelease[i], identifiers[i]) !== 0) {
221
+ return false;
222
+ }
223
+ }
224
+ return true;
225
+ };
226
+ var SemVer = class _SemVer {
227
+ constructor(version, options) {
228
+ options = parseOptions(options);
229
+ if (version instanceof _SemVer) {
230
+ if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
231
+ return version;
232
+ } else {
233
+ version = version.version;
234
+ }
235
+ } else if (typeof version !== "string") {
236
+ throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
237
+ }
238
+ if (version.length > MAX_LENGTH) {
239
+ throw new TypeError(
240
+ `version is longer than ${MAX_LENGTH} characters`
241
+ );
242
+ }
243
+ debug("SemVer", version, options);
244
+ this.options = options;
245
+ this.loose = !!options.loose;
246
+ this.includePrerelease = !!options.includePrerelease;
247
+ const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
248
+ if (!m) {
249
+ throw new TypeError(`Invalid Version: ${version}`);
250
+ }
251
+ this.raw = version;
252
+ this.major = +m[1];
253
+ this.minor = +m[2];
254
+ this.patch = +m[3];
255
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
256
+ throw new TypeError("Invalid major version");
257
+ }
258
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
259
+ throw new TypeError("Invalid minor version");
260
+ }
261
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
262
+ throw new TypeError("Invalid patch version");
263
+ }
264
+ if (!m[4]) {
265
+ this.prerelease = [];
266
+ } else {
267
+ this.prerelease = m[4].split(".").map((id3) => {
268
+ if (/^[0-9]+$/.test(id3)) {
269
+ const num = +id3;
270
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
271
+ return num;
272
+ }
273
+ }
274
+ return id3;
275
+ });
276
+ }
277
+ this.build = m[5] ? m[5].split(".") : [];
278
+ this.format();
279
+ }
280
+ format() {
281
+ this.version = `${this.major}.${this.minor}.${this.patch}`;
282
+ if (this.prerelease.length) {
283
+ this.version += `-${this.prerelease.join(".")}`;
284
+ }
285
+ return this.version;
286
+ }
287
+ toString() {
288
+ return this.version;
289
+ }
290
+ compare(other) {
291
+ debug("SemVer.compare", this.version, this.options, other);
292
+ if (!(other instanceof _SemVer)) {
293
+ if (typeof other === "string" && other === this.version) {
294
+ return 0;
295
+ }
296
+ other = new _SemVer(other, this.options);
297
+ }
298
+ if (other.version === this.version) {
299
+ return 0;
300
+ }
301
+ return this.compareMain(other) || this.comparePre(other);
302
+ }
303
+ compareMain(other) {
304
+ if (!(other instanceof _SemVer)) {
305
+ other = new _SemVer(other, this.options);
306
+ }
307
+ if (this.major < other.major) {
308
+ return -1;
309
+ }
310
+ if (this.major > other.major) {
311
+ return 1;
312
+ }
313
+ if (this.minor < other.minor) {
314
+ return -1;
315
+ }
316
+ if (this.minor > other.minor) {
317
+ return 1;
318
+ }
319
+ if (this.patch < other.patch) {
320
+ return -1;
321
+ }
322
+ if (this.patch > other.patch) {
323
+ return 1;
324
+ }
325
+ return 0;
326
+ }
327
+ comparePre(other) {
328
+ if (!(other instanceof _SemVer)) {
329
+ other = new _SemVer(other, this.options);
330
+ }
331
+ if (this.prerelease.length && !other.prerelease.length) {
332
+ return -1;
333
+ } else if (!this.prerelease.length && other.prerelease.length) {
334
+ return 1;
335
+ } else if (!this.prerelease.length && !other.prerelease.length) {
336
+ return 0;
337
+ }
338
+ let i = 0;
339
+ do {
340
+ const a = this.prerelease[i];
341
+ const b = other.prerelease[i];
342
+ debug("prerelease compare", i, a, b);
343
+ if (a === void 0 && b === void 0) {
344
+ return 0;
345
+ } else if (b === void 0) {
346
+ return 1;
347
+ } else if (a === void 0) {
348
+ return -1;
349
+ } else if (a === b) {
350
+ continue;
351
+ } else {
352
+ return compareIdentifiers(a, b);
353
+ }
354
+ } while (++i);
355
+ }
356
+ compareBuild(other) {
357
+ if (!(other instanceof _SemVer)) {
358
+ other = new _SemVer(other, this.options);
359
+ }
360
+ let i = 0;
361
+ do {
362
+ const a = this.build[i];
363
+ const b = other.build[i];
364
+ debug("build compare", i, a, b);
365
+ if (a === void 0 && b === void 0) {
366
+ return 0;
367
+ } else if (b === void 0) {
368
+ return 1;
369
+ } else if (a === void 0) {
370
+ return -1;
371
+ } else if (a === b) {
372
+ continue;
373
+ } else {
374
+ return compareIdentifiers(a, b);
375
+ }
376
+ } while (++i);
377
+ }
378
+ // preminor will bump the version up to the next minor release, and immediately
379
+ // down to pre-release. premajor and prepatch work the same way.
380
+ inc(release, identifier, identifierBase) {
381
+ if (release.startsWith("pre")) {
382
+ if (!identifier && identifierBase === false) {
383
+ throw new Error("invalid increment argument: identifier is empty");
384
+ }
385
+ if (identifier) {
386
+ const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
387
+ if (!match || match[1] !== identifier) {
388
+ throw new Error(`invalid identifier: ${identifier}`);
389
+ }
390
+ }
391
+ }
392
+ switch (release) {
393
+ case "premajor":
394
+ this.prerelease.length = 0;
395
+ this.patch = 0;
396
+ this.minor = 0;
397
+ this.major++;
398
+ this.inc("pre", identifier, identifierBase);
399
+ break;
400
+ case "preminor":
401
+ this.prerelease.length = 0;
402
+ this.patch = 0;
403
+ this.minor++;
404
+ this.inc("pre", identifier, identifierBase);
405
+ break;
406
+ case "prepatch":
407
+ this.prerelease.length = 0;
408
+ this.inc("patch", identifier, identifierBase);
409
+ this.inc("pre", identifier, identifierBase);
410
+ break;
411
+ // If the input is a non-prerelease version, this acts the same as
412
+ // prepatch.
413
+ case "prerelease":
414
+ if (this.prerelease.length === 0) {
415
+ this.inc("patch", identifier, identifierBase);
416
+ }
417
+ this.inc("pre", identifier, identifierBase);
418
+ break;
419
+ case "release":
420
+ if (this.prerelease.length === 0) {
421
+ throw new Error(`version ${this.raw} is not a prerelease`);
422
+ }
423
+ this.prerelease.length = 0;
424
+ break;
425
+ case "major":
426
+ if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
427
+ this.major++;
428
+ }
429
+ this.minor = 0;
430
+ this.patch = 0;
431
+ this.prerelease = [];
432
+ break;
433
+ case "minor":
434
+ if (this.patch !== 0 || this.prerelease.length === 0) {
435
+ this.minor++;
436
+ }
437
+ this.patch = 0;
438
+ this.prerelease = [];
439
+ break;
440
+ case "patch":
441
+ if (this.prerelease.length === 0) {
442
+ this.patch++;
443
+ }
444
+ this.prerelease = [];
445
+ break;
446
+ // This probably shouldn't be used publicly.
447
+ // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
448
+ case "pre": {
449
+ const base = Number(identifierBase) ? 1 : 0;
450
+ if (this.prerelease.length === 0) {
451
+ this.prerelease = [base];
452
+ } else {
453
+ let i = this.prerelease.length;
454
+ while (--i >= 0) {
455
+ if (typeof this.prerelease[i] === "number") {
456
+ this.prerelease[i]++;
457
+ i = -2;
458
+ }
459
+ }
460
+ if (i === -1) {
461
+ if (identifier === this.prerelease.join(".") && identifierBase === false) {
462
+ throw new Error("invalid increment argument: identifier already exists");
463
+ }
464
+ this.prerelease.push(base);
465
+ }
466
+ }
467
+ if (identifier) {
468
+ let prerelease = [identifier, base];
469
+ if (identifierBase === false) {
470
+ prerelease = [identifier];
471
+ }
472
+ if (isPrereleaseIdentifier(this.prerelease, identifier)) {
473
+ const prereleaseBase = this.prerelease[identifier.split(".").length];
474
+ if (isNaN(prereleaseBase)) {
475
+ this.prerelease = prerelease;
476
+ }
477
+ } else {
478
+ this.prerelease = prerelease;
479
+ }
480
+ }
481
+ break;
482
+ }
483
+ default:
484
+ throw new Error(`invalid increment argument: ${release}`);
485
+ }
486
+ this.raw = this.format();
487
+ if (this.build.length) {
488
+ this.raw += `+${this.build.join(".")}`;
489
+ }
490
+ return this;
491
+ }
492
+ };
493
+ module.exports = SemVer;
494
+ }
495
+ });
496
+
497
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/parse.js
498
+ var require_parse = __commonJS({
499
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/parse.js"(exports, module) {
500
+ "use strict";
501
+ var SemVer = require_semver();
502
+ var parse = (version, options, throwErrors = false) => {
503
+ if (version instanceof SemVer) {
504
+ return version;
505
+ }
506
+ try {
507
+ return new SemVer(version, options);
508
+ } catch (er) {
509
+ if (!throwErrors) {
510
+ return null;
511
+ }
512
+ throw er;
513
+ }
514
+ };
515
+ module.exports = parse;
516
+ }
517
+ });
518
+
519
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/valid.js
520
+ var require_valid = __commonJS({
521
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/valid.js"(exports, module) {
522
+ "use strict";
523
+ var parse = require_parse();
524
+ var valid2 = (version, options) => {
525
+ const v2 = parse(version, options);
526
+ return v2 ? v2.version : null;
527
+ };
528
+ module.exports = valid2;
529
+ }
530
+ });
531
+
532
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/clean.js
533
+ var require_clean = __commonJS({
534
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/clean.js"(exports, module) {
535
+ "use strict";
536
+ var parse = require_parse();
537
+ var clean = (version, options) => {
538
+ const s = parse(version.trim().replace(/^[=v]+/, ""), options);
539
+ return s ? s.version : null;
540
+ };
541
+ module.exports = clean;
542
+ }
543
+ });
544
+
545
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/inc.js
546
+ var require_inc = __commonJS({
547
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/inc.js"(exports, module) {
548
+ "use strict";
549
+ var SemVer = require_semver();
550
+ var inc = (version, release, options, identifier, identifierBase) => {
551
+ if (typeof options === "string") {
552
+ identifierBase = identifier;
553
+ identifier = options;
554
+ options = void 0;
555
+ }
556
+ try {
557
+ return new SemVer(
558
+ version instanceof SemVer ? version.version : version,
559
+ options
560
+ ).inc(release, identifier, identifierBase).version;
561
+ } catch (er) {
562
+ return null;
563
+ }
564
+ };
565
+ module.exports = inc;
566
+ }
567
+ });
568
+
569
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/diff.js
570
+ var require_diff = __commonJS({
571
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/diff.js"(exports, module) {
572
+ "use strict";
573
+ var parse = require_parse();
574
+ var diff = (version1, version2) => {
575
+ const v1 = parse(version1, null, true);
576
+ const v2 = parse(version2, null, true);
577
+ const comparison = v1.compare(v2);
578
+ if (comparison === 0) {
579
+ return null;
580
+ }
581
+ const v1Higher = comparison > 0;
582
+ const highVersion = v1Higher ? v1 : v2;
583
+ const lowVersion = v1Higher ? v2 : v1;
584
+ const highHasPre = !!highVersion.prerelease.length;
585
+ const lowHasPre = !!lowVersion.prerelease.length;
586
+ if (lowHasPre && !highHasPre) {
587
+ if (!lowVersion.patch && !lowVersion.minor) {
588
+ return "major";
589
+ }
590
+ if (lowVersion.compareMain(highVersion) === 0) {
591
+ if (lowVersion.minor && !lowVersion.patch) {
592
+ return "minor";
593
+ }
594
+ return "patch";
595
+ }
596
+ }
597
+ const prefix = highHasPre ? "pre" : "";
598
+ if (v1.major !== v2.major) {
599
+ return prefix + "major";
600
+ }
601
+ if (v1.minor !== v2.minor) {
602
+ return prefix + "minor";
603
+ }
604
+ if (v1.patch !== v2.patch) {
605
+ return prefix + "patch";
606
+ }
607
+ return "prerelease";
608
+ };
609
+ module.exports = diff;
610
+ }
611
+ });
612
+
613
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/major.js
614
+ var require_major = __commonJS({
615
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/major.js"(exports, module) {
616
+ "use strict";
617
+ var SemVer = require_semver();
618
+ var major = (a, loose) => new SemVer(a, loose).major;
619
+ module.exports = major;
620
+ }
621
+ });
622
+
623
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/minor.js
624
+ var require_minor = __commonJS({
625
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/minor.js"(exports, module) {
626
+ "use strict";
627
+ var SemVer = require_semver();
628
+ var minor = (a, loose) => new SemVer(a, loose).minor;
629
+ module.exports = minor;
630
+ }
631
+ });
632
+
633
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/patch.js
634
+ var require_patch = __commonJS({
635
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/patch.js"(exports, module) {
636
+ "use strict";
637
+ var SemVer = require_semver();
638
+ var patch = (a, loose) => new SemVer(a, loose).patch;
639
+ module.exports = patch;
640
+ }
641
+ });
642
+
643
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/prerelease.js
644
+ var require_prerelease = __commonJS({
645
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/prerelease.js"(exports, module) {
646
+ "use strict";
647
+ var parse = require_parse();
648
+ var prerelease = (version, options) => {
649
+ const parsed = parse(version, options);
650
+ return parsed && parsed.prerelease.length ? parsed.prerelease : null;
651
+ };
652
+ module.exports = prerelease;
653
+ }
654
+ });
655
+
656
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/compare.js
657
+ var require_compare = __commonJS({
658
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/compare.js"(exports, module) {
659
+ "use strict";
660
+ var SemVer = require_semver();
661
+ var compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
662
+ module.exports = compare;
663
+ }
664
+ });
665
+
666
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/rcompare.js
667
+ var require_rcompare = __commonJS({
668
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/rcompare.js"(exports, module) {
669
+ "use strict";
670
+ var compare = require_compare();
671
+ var rcompare = (a, b, loose) => compare(b, a, loose);
672
+ module.exports = rcompare;
673
+ }
674
+ });
675
+
676
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/compare-loose.js
677
+ var require_compare_loose = __commonJS({
678
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/compare-loose.js"(exports, module) {
679
+ "use strict";
680
+ var compare = require_compare();
681
+ var compareLoose = (a, b) => compare(a, b, true);
682
+ module.exports = compareLoose;
683
+ }
684
+ });
685
+
686
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/compare-build.js
687
+ var require_compare_build = __commonJS({
688
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/compare-build.js"(exports, module) {
689
+ "use strict";
690
+ var SemVer = require_semver();
691
+ var compareBuild = (a, b, loose) => {
692
+ const versionA = new SemVer(a, loose);
693
+ const versionB = new SemVer(b, loose);
694
+ return versionA.compare(versionB) || versionA.compareBuild(versionB);
695
+ };
696
+ module.exports = compareBuild;
697
+ }
698
+ });
699
+
700
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/sort.js
701
+ var require_sort = __commonJS({
702
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/sort.js"(exports, module) {
703
+ "use strict";
704
+ var compareBuild = require_compare_build();
705
+ var sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
706
+ module.exports = sort;
707
+ }
708
+ });
709
+
710
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/rsort.js
711
+ var require_rsort = __commonJS({
712
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/rsort.js"(exports, module) {
713
+ "use strict";
714
+ var compareBuild = require_compare_build();
715
+ var rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
716
+ module.exports = rsort;
717
+ }
718
+ });
719
+
720
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/gt.js
721
+ var require_gt = __commonJS({
722
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/gt.js"(exports, module) {
723
+ "use strict";
724
+ var compare = require_compare();
725
+ var gt = (a, b, loose) => compare(a, b, loose) > 0;
726
+ module.exports = gt;
727
+ }
728
+ });
729
+
730
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/lt.js
731
+ var require_lt = __commonJS({
732
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/lt.js"(exports, module) {
733
+ "use strict";
734
+ var compare = require_compare();
735
+ var lt = (a, b, loose) => compare(a, b, loose) < 0;
736
+ module.exports = lt;
737
+ }
738
+ });
739
+
740
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/eq.js
741
+ var require_eq = __commonJS({
742
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/eq.js"(exports, module) {
743
+ "use strict";
744
+ var compare = require_compare();
745
+ var eq = (a, b, loose) => compare(a, b, loose) === 0;
746
+ module.exports = eq;
747
+ }
748
+ });
749
+
750
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/neq.js
751
+ var require_neq = __commonJS({
752
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/neq.js"(exports, module) {
753
+ "use strict";
754
+ var compare = require_compare();
755
+ var neq = (a, b, loose) => compare(a, b, loose) !== 0;
756
+ module.exports = neq;
757
+ }
758
+ });
759
+
760
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/gte.js
761
+ var require_gte = __commonJS({
762
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/gte.js"(exports, module) {
763
+ "use strict";
764
+ var compare = require_compare();
765
+ var gte2 = (a, b, loose) => compare(a, b, loose) >= 0;
766
+ module.exports = gte2;
767
+ }
768
+ });
769
+
770
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/lte.js
771
+ var require_lte = __commonJS({
772
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/lte.js"(exports, module) {
773
+ "use strict";
774
+ var compare = require_compare();
775
+ var lte = (a, b, loose) => compare(a, b, loose) <= 0;
776
+ module.exports = lte;
777
+ }
778
+ });
779
+
780
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/cmp.js
781
+ var require_cmp = __commonJS({
782
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/cmp.js"(exports, module) {
783
+ "use strict";
784
+ var eq = require_eq();
785
+ var neq = require_neq();
786
+ var gt = require_gt();
787
+ var gte2 = require_gte();
788
+ var lt = require_lt();
789
+ var lte = require_lte();
790
+ var cmp = (a, op, b, loose) => {
791
+ switch (op) {
792
+ case "===":
793
+ if (typeof a === "object") {
794
+ a = a.version;
795
+ }
796
+ if (typeof b === "object") {
797
+ b = b.version;
798
+ }
799
+ return a === b;
800
+ case "!==":
801
+ if (typeof a === "object") {
802
+ a = a.version;
803
+ }
804
+ if (typeof b === "object") {
805
+ b = b.version;
806
+ }
807
+ return a !== b;
808
+ case "":
809
+ case "=":
810
+ case "==":
811
+ return eq(a, b, loose);
812
+ case "!=":
813
+ return neq(a, b, loose);
814
+ case ">":
815
+ return gt(a, b, loose);
816
+ case ">=":
817
+ return gte2(a, b, loose);
818
+ case "<":
819
+ return lt(a, b, loose);
820
+ case "<=":
821
+ return lte(a, b, loose);
822
+ default:
823
+ throw new TypeError(`Invalid operator: ${op}`);
824
+ }
825
+ };
826
+ module.exports = cmp;
827
+ }
828
+ });
829
+
830
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/coerce.js
831
+ var require_coerce = __commonJS({
832
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/coerce.js"(exports, module) {
833
+ "use strict";
834
+ var SemVer = require_semver();
835
+ var parse = require_parse();
836
+ var { safeRe: re, t } = require_re();
837
+ var coerce2 = (version, options) => {
838
+ if (version instanceof SemVer) {
839
+ return version;
840
+ }
841
+ if (typeof version === "number") {
842
+ version = String(version);
843
+ }
844
+ if (typeof version !== "string") {
845
+ return null;
846
+ }
847
+ options = options || {};
848
+ let match = null;
849
+ if (!options.rtl) {
850
+ match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
851
+ } else {
852
+ const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
853
+ let next;
854
+ while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {
855
+ if (!match || next.index + next[0].length !== match.index + match[0].length) {
856
+ match = next;
857
+ }
858
+ coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
859
+ }
860
+ coerceRtlRegex.lastIndex = -1;
861
+ }
862
+ if (match === null) {
863
+ return null;
864
+ }
865
+ const major = match[2];
866
+ const minor = match[3] || "0";
867
+ const patch = match[4] || "0";
868
+ const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : "";
869
+ const build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
870
+ return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options);
871
+ };
872
+ module.exports = coerce2;
873
+ }
874
+ });
875
+
876
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/truncate.js
877
+ var require_truncate = __commonJS({
878
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/truncate.js"(exports, module) {
879
+ "use strict";
880
+ var parse = require_parse();
881
+ var constants = require_constants();
882
+ var SemVer = require_semver();
883
+ var truncate = (version, truncation, options) => {
884
+ if (!constants.RELEASE_TYPES.includes(truncation)) {
885
+ return null;
886
+ }
887
+ const clonedVersion = cloneInputVersion(version, options);
888
+ return clonedVersion && doTruncation(clonedVersion, truncation);
889
+ };
890
+ var cloneInputVersion = (version, options) => {
891
+ const versionStringToParse = version instanceof SemVer ? version.version : version;
892
+ return parse(versionStringToParse, options);
893
+ };
894
+ var doTruncation = (version, truncation) => {
895
+ if (isPrerelease(truncation)) {
896
+ return version.version;
897
+ }
898
+ version.prerelease = [];
899
+ switch (truncation) {
900
+ case "major":
901
+ version.minor = 0;
902
+ version.patch = 0;
903
+ break;
904
+ case "minor":
905
+ version.patch = 0;
906
+ break;
907
+ }
908
+ return version.format();
909
+ };
910
+ var isPrerelease = (type) => {
911
+ return type.startsWith("pre");
912
+ };
913
+ module.exports = truncate;
914
+ }
915
+ });
916
+
917
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/lrucache.js
918
+ var require_lrucache = __commonJS({
919
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/lrucache.js"(exports, module) {
920
+ "use strict";
921
+ var LRUCache = class {
922
+ constructor() {
923
+ this.max = 1e3;
924
+ this.map = /* @__PURE__ */ new Map();
925
+ }
926
+ get(key2) {
927
+ const value = this.map.get(key2);
928
+ if (value === void 0) {
929
+ return void 0;
930
+ } else {
931
+ this.map.delete(key2);
932
+ this.map.set(key2, value);
933
+ return value;
934
+ }
935
+ }
936
+ delete(key2) {
937
+ return this.map.delete(key2);
938
+ }
939
+ set(key2, value) {
940
+ const deleted = this.delete(key2);
941
+ if (!deleted && value !== void 0) {
942
+ if (this.map.size >= this.max) {
943
+ const firstKey = this.map.keys().next().value;
944
+ this.delete(firstKey);
945
+ }
946
+ this.map.set(key2, value);
947
+ }
948
+ return this;
949
+ }
950
+ };
951
+ module.exports = LRUCache;
952
+ }
953
+ });
954
+
955
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/range.js
956
+ var require_range = __commonJS({
957
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/range.js"(exports, module) {
958
+ "use strict";
959
+ var SPACE_CHARACTERS = /\s+/g;
960
+ var Range = class _Range {
961
+ constructor(range, options) {
962
+ options = parseOptions(options);
963
+ if (range instanceof _Range) {
964
+ if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
965
+ return range;
966
+ } else {
967
+ return new _Range(range.raw, options);
968
+ }
969
+ }
970
+ if (range instanceof Comparator) {
971
+ this.raw = range.value;
972
+ this.set = [[range]];
973
+ this.formatted = void 0;
974
+ return this;
975
+ }
976
+ this.options = options;
977
+ this.loose = !!options.loose;
978
+ this.includePrerelease = !!options.includePrerelease;
979
+ this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
980
+ this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
981
+ if (!this.set.length) {
982
+ throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
983
+ }
984
+ if (this.set.length > 1) {
985
+ const first = this.set[0];
986
+ this.set = this.set.filter((c) => !isNullSet(c[0]));
987
+ if (this.set.length === 0) {
988
+ this.set = [first];
989
+ } else if (this.set.length > 1) {
990
+ for (const c of this.set) {
991
+ if (c.length === 1 && isAny(c[0])) {
992
+ this.set = [c];
993
+ break;
994
+ }
995
+ }
996
+ }
997
+ }
998
+ this.formatted = void 0;
999
+ }
1000
+ get range() {
1001
+ if (this.formatted === void 0) {
1002
+ this.formatted = "";
1003
+ for (let i = 0; i < this.set.length; i++) {
1004
+ if (i > 0) {
1005
+ this.formatted += "||";
1006
+ }
1007
+ const comps = this.set[i];
1008
+ for (let k = 0; k < comps.length; k++) {
1009
+ if (k > 0) {
1010
+ this.formatted += " ";
1011
+ }
1012
+ this.formatted += comps[k].toString().trim();
1013
+ }
1014
+ }
1015
+ }
1016
+ return this.formatted;
1017
+ }
1018
+ format() {
1019
+ return this.range;
1020
+ }
1021
+ toString() {
1022
+ return this.range;
1023
+ }
1024
+ parseRange(range) {
1025
+ range = range.replace(BUILDSTRIPRE, "");
1026
+ const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
1027
+ const memoKey = memoOpts + ":" + range;
1028
+ const cached = cache.get(memoKey);
1029
+ if (cached) {
1030
+ return cached;
1031
+ }
1032
+ const loose = this.options.loose;
1033
+ const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
1034
+ range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
1035
+ debug("hyphen replace", range);
1036
+ range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
1037
+ debug("comparator trim", range);
1038
+ range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
1039
+ debug("tilde trim", range);
1040
+ range = range.replace(re[t.CARETTRIM], caretTrimReplace);
1041
+ debug("caret trim", range);
1042
+ let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
1043
+ if (loose) {
1044
+ rangeList = rangeList.filter((comp) => {
1045
+ debug("loose invalid filter", comp, this.options);
1046
+ return !!comp.match(re[t.COMPARATORLOOSE]);
1047
+ });
1048
+ }
1049
+ debug("range list", rangeList);
1050
+ const rangeMap = /* @__PURE__ */ new Map();
1051
+ const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
1052
+ for (const comp of comparators) {
1053
+ if (isNullSet(comp)) {
1054
+ return [comp];
1055
+ }
1056
+ rangeMap.set(comp.value, comp);
1057
+ }
1058
+ if (rangeMap.size > 1 && rangeMap.has("")) {
1059
+ rangeMap.delete("");
1060
+ }
1061
+ const result = [...rangeMap.values()];
1062
+ cache.set(memoKey, result);
1063
+ return result;
1064
+ }
1065
+ intersects(range, options) {
1066
+ if (!(range instanceof _Range)) {
1067
+ throw new TypeError("a Range is required");
1068
+ }
1069
+ return this.set.some((thisComparators) => {
1070
+ return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
1071
+ return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
1072
+ return rangeComparators.every((rangeComparator) => {
1073
+ return thisComparator.intersects(rangeComparator, options);
1074
+ });
1075
+ });
1076
+ });
1077
+ });
1078
+ }
1079
+ // if ANY of the sets match ALL of its comparators, then pass
1080
+ test(version) {
1081
+ if (!version) {
1082
+ return false;
1083
+ }
1084
+ if (typeof version === "string") {
1085
+ try {
1086
+ version = new SemVer(version, this.options);
1087
+ } catch (er) {
1088
+ return false;
1089
+ }
1090
+ }
1091
+ for (let i = 0; i < this.set.length; i++) {
1092
+ if (testSet(this.set[i], version, this.options)) {
1093
+ return true;
1094
+ }
1095
+ }
1096
+ return false;
1097
+ }
1098
+ };
1099
+ module.exports = Range;
1100
+ var LRU = require_lrucache();
1101
+ var cache = new LRU();
1102
+ var parseOptions = require_parse_options();
1103
+ var Comparator = require_comparator();
1104
+ var debug = require_debug();
1105
+ var SemVer = require_semver();
1106
+ var {
1107
+ safeRe: re,
1108
+ src,
1109
+ t,
1110
+ comparatorTrimReplace,
1111
+ tildeTrimReplace,
1112
+ caretTrimReplace
1113
+ } = require_re();
1114
+ var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
1115
+ var BUILDSTRIPRE = new RegExp(src[t.BUILD], "g");
1116
+ var isNullSet = (c) => c.value === "<0.0.0-0";
1117
+ var isAny = (c) => c.value === "";
1118
+ var isSatisfiable = (comparators, options) => {
1119
+ let result = true;
1120
+ const remainingComparators = comparators.slice();
1121
+ let testComparator = remainingComparators.pop();
1122
+ while (result && remainingComparators.length) {
1123
+ result = remainingComparators.every((otherComparator) => {
1124
+ return testComparator.intersects(otherComparator, options);
1125
+ });
1126
+ testComparator = remainingComparators.pop();
1127
+ }
1128
+ return result;
1129
+ };
1130
+ var parseComparator = (comp, options) => {
1131
+ comp = comp.replace(re[t.BUILD], "");
1132
+ debug("comp", comp, options);
1133
+ comp = replaceCarets(comp, options);
1134
+ debug("caret", comp);
1135
+ comp = replaceTildes(comp, options);
1136
+ debug("tildes", comp);
1137
+ comp = replaceXRanges(comp, options);
1138
+ debug("xrange", comp);
1139
+ comp = replaceStars(comp, options);
1140
+ debug("stars", comp);
1141
+ return comp;
1142
+ };
1143
+ var isX = (id3) => !id3 || id3.toLowerCase() === "x" || id3 === "*";
1144
+ var invalidXRangeOrder = (M, m, p) => isX(M) && !isX(m) || isX(m) && p && !isX(p);
1145
+ var replaceTildes = (comp, options) => {
1146
+ return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
1147
+ };
1148
+ var replaceTilde = (comp, options) => {
1149
+ const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
1150
+ const z27 = options.includePrerelease ? "-0" : "";
1151
+ return comp.replace(r, (_, M, m, p, pr) => {
1152
+ debug("tilde", comp, _, M, m, p, pr);
1153
+ let ret;
1154
+ if (isX(M)) {
1155
+ ret = "";
1156
+ } else if (isX(m)) {
1157
+ ret = `>=${M}.0.0${z27} <${+M + 1}.0.0-0`;
1158
+ } else if (isX(p)) {
1159
+ ret = `>=${M}.${m}.0${z27} <${M}.${+m + 1}.0-0`;
1160
+ } else if (pr) {
1161
+ debug("replaceTilde pr", pr);
1162
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
1163
+ } else {
1164
+ ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
1165
+ }
1166
+ debug("tilde return", ret);
1167
+ return ret;
1168
+ });
1169
+ };
1170
+ var replaceCarets = (comp, options) => {
1171
+ return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
1172
+ };
1173
+ var replaceCaret = (comp, options) => {
1174
+ debug("caret", comp, options);
1175
+ const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
1176
+ const z27 = options.includePrerelease ? "-0" : "";
1177
+ return comp.replace(r, (_, M, m, p, pr) => {
1178
+ debug("caret", comp, _, M, m, p, pr);
1179
+ let ret;
1180
+ if (isX(M)) {
1181
+ ret = "";
1182
+ } else if (isX(m)) {
1183
+ ret = `>=${M}.0.0${z27} <${+M + 1}.0.0-0`;
1184
+ } else if (isX(p)) {
1185
+ if (M === "0") {
1186
+ ret = `>=${M}.${m}.0${z27} <${M}.${+m + 1}.0-0`;
1187
+ } else {
1188
+ ret = `>=${M}.${m}.0${z27} <${+M + 1}.0.0-0`;
1189
+ }
1190
+ } else if (pr) {
1191
+ debug("replaceCaret pr", pr);
1192
+ if (M === "0") {
1193
+ if (m === "0") {
1194
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
1195
+ } else {
1196
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
1197
+ }
1198
+ } else {
1199
+ ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
1200
+ }
1201
+ } else {
1202
+ debug("no pr");
1203
+ if (M === "0") {
1204
+ if (m === "0") {
1205
+ ret = `>=${M}.${m}.${p} <${M}.${m}.${+p + 1}-0`;
1206
+ } else {
1207
+ ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
1208
+ }
1209
+ } else {
1210
+ ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
1211
+ }
1212
+ }
1213
+ debug("caret return", ret);
1214
+ return ret;
1215
+ });
1216
+ };
1217
+ var replaceXRanges = (comp, options) => {
1218
+ debug("replaceXRanges", comp, options);
1219
+ return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
1220
+ };
1221
+ var replaceXRange = (comp, options) => {
1222
+ comp = comp.trim();
1223
+ const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
1224
+ return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
1225
+ debug("xRange", comp, ret, gtlt, M, m, p, pr);
1226
+ if (invalidXRangeOrder(M, m, p)) {
1227
+ return comp;
1228
+ }
1229
+ const xM = isX(M);
1230
+ const xm = xM || isX(m);
1231
+ const xp = xm || isX(p);
1232
+ const anyX = xp;
1233
+ if (gtlt === "=" && anyX) {
1234
+ gtlt = "";
1235
+ }
1236
+ pr = options.includePrerelease ? "-0" : "";
1237
+ if (xM) {
1238
+ if (gtlt === ">" || gtlt === "<") {
1239
+ ret = "<0.0.0-0";
1240
+ } else {
1241
+ ret = "*";
1242
+ }
1243
+ } else if (gtlt && anyX) {
1244
+ if (xm) {
1245
+ m = 0;
1246
+ }
1247
+ p = 0;
1248
+ if (gtlt === ">") {
1249
+ gtlt = ">=";
1250
+ if (xm) {
1251
+ M = +M + 1;
1252
+ m = 0;
1253
+ p = 0;
1254
+ } else {
1255
+ m = +m + 1;
1256
+ p = 0;
1257
+ }
1258
+ } else if (gtlt === "<=") {
1259
+ gtlt = "<";
1260
+ if (xm) {
1261
+ M = +M + 1;
1262
+ } else {
1263
+ m = +m + 1;
1264
+ }
1265
+ }
1266
+ if (gtlt === "<") {
1267
+ pr = "-0";
1268
+ }
1269
+ ret = `${gtlt + M}.${m}.${p}${pr}`;
1270
+ } else if (xm) {
1271
+ ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
1272
+ } else if (xp) {
1273
+ ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
1274
+ }
1275
+ debug("xRange return", ret);
1276
+ return ret;
1277
+ });
1278
+ };
1279
+ var replaceStars = (comp, options) => {
1280
+ debug("replaceStars", comp, options);
1281
+ return comp.trim().replace(re[t.STAR], "");
1282
+ };
1283
+ var replaceGTE0 = (comp, options) => {
1284
+ debug("replaceGTE0", comp, options);
1285
+ return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
1286
+ };
1287
+ var hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
1288
+ if (isX(fM)) {
1289
+ from = "";
1290
+ } else if (isX(fm)) {
1291
+ from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
1292
+ } else if (isX(fp)) {
1293
+ from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
1294
+ } else if (fpr) {
1295
+ from = `>=${from}`;
1296
+ } else {
1297
+ from = `>=${from}${incPr ? "-0" : ""}`;
1298
+ }
1299
+ if (isX(tM)) {
1300
+ to = "";
1301
+ } else if (isX(tm)) {
1302
+ to = `<${+tM + 1}.0.0-0`;
1303
+ } else if (isX(tp)) {
1304
+ to = `<${tM}.${+tm + 1}.0-0`;
1305
+ } else if (tpr) {
1306
+ to = `<=${tM}.${tm}.${tp}-${tpr}`;
1307
+ } else if (incPr) {
1308
+ to = `<${tM}.${tm}.${+tp + 1}-0`;
1309
+ } else {
1310
+ to = `<=${to}`;
1311
+ }
1312
+ return `${from} ${to}`.trim();
1313
+ };
1314
+ var testSet = (set, version, options) => {
1315
+ for (let i = 0; i < set.length; i++) {
1316
+ if (!set[i].test(version)) {
1317
+ return false;
1318
+ }
1319
+ }
1320
+ if (version.prerelease.length && !options.includePrerelease) {
1321
+ for (let i = 0; i < set.length; i++) {
1322
+ debug(set[i].semver);
1323
+ if (set[i].semver === Comparator.ANY) {
1324
+ continue;
1325
+ }
1326
+ if (set[i].semver.prerelease.length > 0) {
1327
+ const allowed = set[i].semver;
1328
+ if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
1329
+ return true;
1330
+ }
1331
+ }
1332
+ }
1333
+ return false;
1334
+ }
1335
+ return true;
1336
+ };
1337
+ }
1338
+ });
1339
+
1340
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/comparator.js
1341
+ var require_comparator = __commonJS({
1342
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/comparator.js"(exports, module) {
1343
+ "use strict";
1344
+ var ANY = /* @__PURE__ */ Symbol("SemVer ANY");
1345
+ var Comparator = class _Comparator {
1346
+ static get ANY() {
1347
+ return ANY;
1348
+ }
1349
+ constructor(comp, options) {
1350
+ options = parseOptions(options);
1351
+ if (comp instanceof _Comparator) {
1352
+ if (comp.loose === !!options.loose) {
1353
+ return comp;
1354
+ } else {
1355
+ comp = comp.value;
1356
+ }
1357
+ }
1358
+ comp = comp.trim().split(/\s+/).join(" ");
1359
+ debug("comparator", comp, options);
1360
+ this.options = options;
1361
+ this.loose = !!options.loose;
1362
+ this.parse(comp);
1363
+ if (this.semver === ANY) {
1364
+ this.value = "";
1365
+ } else {
1366
+ this.value = this.operator + this.semver.version;
1367
+ }
1368
+ debug("comp", this);
1369
+ }
1370
+ parse(comp) {
1371
+ const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
1372
+ const m = comp.match(r);
1373
+ if (!m) {
1374
+ throw new TypeError(`Invalid comparator: ${comp}`);
1375
+ }
1376
+ this.operator = m[1] !== void 0 ? m[1] : "";
1377
+ if (this.operator === "=") {
1378
+ this.operator = "";
1379
+ }
1380
+ if (!m[2]) {
1381
+ this.semver = ANY;
1382
+ } else {
1383
+ this.semver = new SemVer(m[2], this.options.loose);
1384
+ }
1385
+ }
1386
+ toString() {
1387
+ return this.value;
1388
+ }
1389
+ test(version) {
1390
+ debug("Comparator.test", version, this.options.loose);
1391
+ if (this.semver === ANY || version === ANY) {
1392
+ return true;
1393
+ }
1394
+ if (typeof version === "string") {
1395
+ try {
1396
+ version = new SemVer(version, this.options);
1397
+ } catch (er) {
1398
+ return false;
1399
+ }
1400
+ }
1401
+ return cmp(version, this.operator, this.semver, this.options);
1402
+ }
1403
+ intersects(comp, options) {
1404
+ if (!(comp instanceof _Comparator)) {
1405
+ throw new TypeError("a Comparator is required");
1406
+ }
1407
+ if (this.operator === "") {
1408
+ if (this.value === "") {
1409
+ return true;
1410
+ }
1411
+ return new Range(comp.value, options).test(this.value);
1412
+ } else if (comp.operator === "") {
1413
+ if (comp.value === "") {
1414
+ return true;
1415
+ }
1416
+ return new Range(this.value, options).test(comp.semver);
1417
+ }
1418
+ options = parseOptions(options);
1419
+ if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) {
1420
+ return false;
1421
+ }
1422
+ if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) {
1423
+ return false;
1424
+ }
1425
+ if (this.operator.startsWith(">") && comp.operator.startsWith(">")) {
1426
+ return true;
1427
+ }
1428
+ if (this.operator.startsWith("<") && comp.operator.startsWith("<")) {
1429
+ return true;
1430
+ }
1431
+ if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) {
1432
+ return true;
1433
+ }
1434
+ if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) {
1435
+ return true;
1436
+ }
1437
+ if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) {
1438
+ return true;
1439
+ }
1440
+ return false;
1441
+ }
1442
+ };
1443
+ module.exports = Comparator;
1444
+ var parseOptions = require_parse_options();
1445
+ var { safeRe: re, t } = require_re();
1446
+ var cmp = require_cmp();
1447
+ var debug = require_debug();
1448
+ var SemVer = require_semver();
1449
+ var Range = require_range();
1450
+ }
1451
+ });
1452
+
1453
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/satisfies.js
1454
+ var require_satisfies = __commonJS({
1455
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/satisfies.js"(exports, module) {
1456
+ "use strict";
1457
+ var Range = require_range();
1458
+ var satisfies = (version, range, options) => {
1459
+ try {
1460
+ range = new Range(range, options);
1461
+ } catch (er) {
1462
+ return false;
1463
+ }
1464
+ return range.test(version);
1465
+ };
1466
+ module.exports = satisfies;
1467
+ }
1468
+ });
1469
+
1470
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/to-comparators.js
1471
+ var require_to_comparators = __commonJS({
1472
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/to-comparators.js"(exports, module) {
1473
+ "use strict";
1474
+ var Range = require_range();
1475
+ var toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
1476
+ module.exports = toComparators;
1477
+ }
1478
+ });
1479
+
1480
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/max-satisfying.js
1481
+ var require_max_satisfying = __commonJS({
1482
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/max-satisfying.js"(exports, module) {
1483
+ "use strict";
1484
+ var SemVer = require_semver();
1485
+ var Range = require_range();
1486
+ var maxSatisfying = (versions, range, options) => {
1487
+ let max = null;
1488
+ let maxSV = null;
1489
+ let rangeObj = null;
1490
+ try {
1491
+ rangeObj = new Range(range, options);
1492
+ } catch (er) {
1493
+ return null;
1494
+ }
1495
+ versions.forEach((v2) => {
1496
+ if (rangeObj.test(v2)) {
1497
+ if (!max || maxSV.compare(v2) === -1) {
1498
+ max = v2;
1499
+ maxSV = new SemVer(max, options);
1500
+ }
1501
+ }
1502
+ });
1503
+ return max;
1504
+ };
1505
+ module.exports = maxSatisfying;
1506
+ }
1507
+ });
1508
+
1509
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/min-satisfying.js
1510
+ var require_min_satisfying = __commonJS({
1511
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/min-satisfying.js"(exports, module) {
1512
+ "use strict";
1513
+ var SemVer = require_semver();
1514
+ var Range = require_range();
1515
+ var minSatisfying = (versions, range, options) => {
1516
+ let min = null;
1517
+ let minSV = null;
1518
+ let rangeObj = null;
1519
+ try {
1520
+ rangeObj = new Range(range, options);
1521
+ } catch (er) {
1522
+ return null;
1523
+ }
1524
+ versions.forEach((v2) => {
1525
+ if (rangeObj.test(v2)) {
1526
+ if (!min || minSV.compare(v2) === 1) {
1527
+ min = v2;
1528
+ minSV = new SemVer(min, options);
1529
+ }
1530
+ }
1531
+ });
1532
+ return min;
1533
+ };
1534
+ module.exports = minSatisfying;
1535
+ }
1536
+ });
1537
+
1538
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/min-version.js
1539
+ var require_min_version = __commonJS({
1540
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/min-version.js"(exports, module) {
1541
+ "use strict";
1542
+ var SemVer = require_semver();
1543
+ var Range = require_range();
1544
+ var gt = require_gt();
1545
+ var minVersion = (range, loose) => {
1546
+ range = new Range(range, loose);
1547
+ let minver = new SemVer("0.0.0");
1548
+ if (range.test(minver)) {
1549
+ return minver;
1550
+ }
1551
+ minver = new SemVer("0.0.0-0");
1552
+ if (range.test(minver)) {
1553
+ return minver;
1554
+ }
1555
+ minver = null;
1556
+ for (let i = 0; i < range.set.length; ++i) {
1557
+ const comparators = range.set[i];
1558
+ let setMin = null;
1559
+ comparators.forEach((comparator) => {
1560
+ const compver = new SemVer(comparator.semver.version);
1561
+ switch (comparator.operator) {
1562
+ case ">":
1563
+ if (compver.prerelease.length === 0) {
1564
+ compver.patch++;
1565
+ } else {
1566
+ compver.prerelease.push(0);
1567
+ }
1568
+ compver.raw = compver.format();
1569
+ /* fallthrough */
1570
+ case "":
1571
+ case ">=":
1572
+ if (!setMin || gt(compver, setMin)) {
1573
+ setMin = compver;
1574
+ }
1575
+ break;
1576
+ case "<":
1577
+ case "<=":
1578
+ break;
1579
+ /* istanbul ignore next */
1580
+ default:
1581
+ throw new Error(`Unexpected operation: ${comparator.operator}`);
1582
+ }
1583
+ });
1584
+ if (setMin && (!minver || gt(minver, setMin))) {
1585
+ minver = setMin;
1586
+ }
1587
+ }
1588
+ if (minver && range.test(minver)) {
1589
+ return minver;
1590
+ }
1591
+ return null;
1592
+ };
1593
+ module.exports = minVersion;
1594
+ }
1595
+ });
1596
+
1597
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/valid.js
1598
+ var require_valid2 = __commonJS({
1599
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/valid.js"(exports, module) {
1600
+ "use strict";
1601
+ var Range = require_range();
1602
+ var validRange = (range, options) => {
1603
+ try {
1604
+ return new Range(range, options).range || "*";
1605
+ } catch (er) {
1606
+ return null;
1607
+ }
1608
+ };
1609
+ module.exports = validRange;
1610
+ }
1611
+ });
1612
+
1613
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/outside.js
1614
+ var require_outside = __commonJS({
1615
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/outside.js"(exports, module) {
1616
+ "use strict";
1617
+ var SemVer = require_semver();
1618
+ var Comparator = require_comparator();
1619
+ var { ANY } = Comparator;
1620
+ var Range = require_range();
1621
+ var satisfies = require_satisfies();
1622
+ var gt = require_gt();
1623
+ var lt = require_lt();
1624
+ var lte = require_lte();
1625
+ var gte2 = require_gte();
1626
+ var outside = (version, range, hilo, options) => {
1627
+ version = new SemVer(version, options);
1628
+ range = new Range(range, options);
1629
+ let gtfn, ltefn, ltfn, comp, ecomp;
1630
+ switch (hilo) {
1631
+ case ">":
1632
+ gtfn = gt;
1633
+ ltefn = lte;
1634
+ ltfn = lt;
1635
+ comp = ">";
1636
+ ecomp = ">=";
1637
+ break;
1638
+ case "<":
1639
+ gtfn = lt;
1640
+ ltefn = gte2;
1641
+ ltfn = gt;
1642
+ comp = "<";
1643
+ ecomp = "<=";
1644
+ break;
1645
+ default:
1646
+ throw new TypeError('Must provide a hilo val of "<" or ">"');
1647
+ }
1648
+ if (satisfies(version, range, options)) {
1649
+ return false;
1650
+ }
1651
+ for (let i = 0; i < range.set.length; ++i) {
1652
+ const comparators = range.set[i];
1653
+ let high = null;
1654
+ let low = null;
1655
+ comparators.forEach((comparator) => {
1656
+ if (comparator.semver === ANY) {
1657
+ comparator = new Comparator(">=0.0.0");
1658
+ }
1659
+ high = high || comparator;
1660
+ low = low || comparator;
1661
+ if (gtfn(comparator.semver, high.semver, options)) {
1662
+ high = comparator;
1663
+ } else if (ltfn(comparator.semver, low.semver, options)) {
1664
+ low = comparator;
1665
+ }
1666
+ });
1667
+ if (high.operator === comp || high.operator === ecomp) {
1668
+ return false;
1669
+ }
1670
+ if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
1671
+ return false;
1672
+ } else if (low.operator === ecomp && ltfn(version, low.semver)) {
1673
+ return false;
1674
+ }
1675
+ }
1676
+ return true;
1677
+ };
1678
+ module.exports = outside;
1679
+ }
1680
+ });
1681
+
1682
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/gtr.js
1683
+ var require_gtr = __commonJS({
1684
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/gtr.js"(exports, module) {
1685
+ "use strict";
1686
+ var outside = require_outside();
1687
+ var gtr = (version, range, options) => outside(version, range, ">", options);
1688
+ module.exports = gtr;
1689
+ }
1690
+ });
1691
+
1692
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/ltr.js
1693
+ var require_ltr = __commonJS({
1694
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/ltr.js"(exports, module) {
1695
+ "use strict";
1696
+ var outside = require_outside();
1697
+ var ltr = (version, range, options) => outside(version, range, "<", options);
1698
+ module.exports = ltr;
1699
+ }
1700
+ });
1701
+
1702
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/intersects.js
1703
+ var require_intersects = __commonJS({
1704
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/intersects.js"(exports, module) {
1705
+ "use strict";
1706
+ var Range = require_range();
1707
+ var intersects = (r1, r2, options) => {
1708
+ r1 = new Range(r1, options);
1709
+ r2 = new Range(r2, options);
1710
+ return r1.intersects(r2, options);
1711
+ };
1712
+ module.exports = intersects;
1713
+ }
1714
+ });
1715
+
1716
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/simplify.js
1717
+ var require_simplify = __commonJS({
1718
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/simplify.js"(exports, module) {
1719
+ "use strict";
1720
+ var satisfies = require_satisfies();
1721
+ var compare = require_compare();
1722
+ module.exports = (versions, range, options) => {
1723
+ const set = [];
1724
+ let first = null;
1725
+ let prev = null;
1726
+ const v2 = versions.sort((a, b) => compare(a, b, options));
1727
+ for (const version of v2) {
1728
+ const included = satisfies(version, range, options);
1729
+ if (included) {
1730
+ prev = version;
1731
+ if (!first) {
1732
+ first = version;
1733
+ }
1734
+ } else {
1735
+ if (prev) {
1736
+ set.push([first, prev]);
1737
+ }
1738
+ prev = null;
1739
+ first = null;
1740
+ }
1741
+ }
1742
+ if (first) {
1743
+ set.push([first, null]);
1744
+ }
1745
+ const ranges = [];
1746
+ for (const [min, max] of set) {
1747
+ if (min === max) {
1748
+ ranges.push(min);
1749
+ } else if (!max && min === v2[0]) {
1750
+ ranges.push("*");
1751
+ } else if (!max) {
1752
+ ranges.push(`>=${min}`);
1753
+ } else if (min === v2[0]) {
1754
+ ranges.push(`<=${max}`);
1755
+ } else {
1756
+ ranges.push(`${min} - ${max}`);
1757
+ }
1758
+ }
1759
+ const simplified = ranges.join(" || ");
1760
+ const original = typeof range.raw === "string" ? range.raw : String(range);
1761
+ return simplified.length < original.length ? simplified : range;
1762
+ };
1763
+ }
1764
+ });
1765
+
1766
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/subset.js
1767
+ var require_subset = __commonJS({
1768
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/subset.js"(exports, module) {
1769
+ "use strict";
1770
+ var Range = require_range();
1771
+ var Comparator = require_comparator();
1772
+ var { ANY } = Comparator;
1773
+ var satisfies = require_satisfies();
1774
+ var compare = require_compare();
1775
+ var subset = (sub, dom, options = {}) => {
1776
+ if (sub === dom) {
1777
+ return true;
1778
+ }
1779
+ sub = new Range(sub, options);
1780
+ dom = new Range(dom, options);
1781
+ let sawNonNull = false;
1782
+ OUTER: for (const simpleSub of sub.set) {
1783
+ for (const simpleDom of dom.set) {
1784
+ const isSub = simpleSubset(simpleSub, simpleDom, options);
1785
+ sawNonNull = sawNonNull || isSub !== null;
1786
+ if (isSub) {
1787
+ continue OUTER;
1788
+ }
1789
+ }
1790
+ if (sawNonNull) {
1791
+ return false;
1792
+ }
1793
+ }
1794
+ return true;
1795
+ };
1796
+ var minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")];
1797
+ var minimumVersion = [new Comparator(">=0.0.0")];
1798
+ var simpleSubset = (sub, dom, options) => {
1799
+ if (sub === dom) {
1800
+ return true;
1801
+ }
1802
+ if (sub.length === 1 && sub[0].semver === ANY) {
1803
+ if (dom.length === 1 && dom[0].semver === ANY) {
1804
+ return true;
1805
+ } else if (options.includePrerelease) {
1806
+ sub = minimumVersionWithPreRelease;
1807
+ } else {
1808
+ sub = minimumVersion;
1809
+ }
1810
+ }
1811
+ if (dom.length === 1 && dom[0].semver === ANY) {
1812
+ if (options.includePrerelease) {
1813
+ return true;
1814
+ } else {
1815
+ dom = minimumVersion;
1816
+ }
1817
+ }
1818
+ const eqSet = /* @__PURE__ */ new Set();
1819
+ let gt, lt;
1820
+ for (const c of sub) {
1821
+ if (c.operator === ">" || c.operator === ">=") {
1822
+ gt = higherGT(gt, c, options);
1823
+ } else if (c.operator === "<" || c.operator === "<=") {
1824
+ lt = lowerLT(lt, c, options);
1825
+ } else {
1826
+ eqSet.add(c.semver);
1827
+ }
1828
+ }
1829
+ if (eqSet.size > 1) {
1830
+ return null;
1831
+ }
1832
+ let gtltComp;
1833
+ if (gt && lt) {
1834
+ gtltComp = compare(gt.semver, lt.semver, options);
1835
+ if (gtltComp > 0) {
1836
+ return null;
1837
+ } else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) {
1838
+ return null;
1839
+ }
1840
+ }
1841
+ for (const eq of eqSet) {
1842
+ if (gt && !satisfies(eq, String(gt), options)) {
1843
+ return null;
1844
+ }
1845
+ if (lt && !satisfies(eq, String(lt), options)) {
1846
+ return null;
1847
+ }
1848
+ for (const c of dom) {
1849
+ if (!satisfies(eq, String(c), options)) {
1850
+ return false;
1851
+ }
1852
+ }
1853
+ return true;
1854
+ }
1855
+ let higher, lower;
1856
+ let hasDomLT, hasDomGT;
1857
+ let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
1858
+ let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false;
1859
+ if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) {
1860
+ needDomLTPre = false;
1861
+ }
1862
+ for (const c of dom) {
1863
+ hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
1864
+ hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
1865
+ if (gt) {
1866
+ if (needDomGTPre) {
1867
+ if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) {
1868
+ needDomGTPre = false;
1869
+ }
1870
+ }
1871
+ if (c.operator === ">" || c.operator === ">=") {
1872
+ higher = higherGT(gt, c, options);
1873
+ if (higher === c && higher !== gt) {
1874
+ return false;
1875
+ }
1876
+ } else if (gt.operator === ">=" && !c.test(gt.semver)) {
1877
+ return false;
1878
+ }
1879
+ }
1880
+ if (lt) {
1881
+ if (needDomLTPre) {
1882
+ if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) {
1883
+ needDomLTPre = false;
1884
+ }
1885
+ }
1886
+ if (c.operator === "<" || c.operator === "<=") {
1887
+ lower = lowerLT(lt, c, options);
1888
+ if (lower === c && lower !== lt) {
1889
+ return false;
1890
+ }
1891
+ } else if (lt.operator === "<=" && !c.test(lt.semver)) {
1892
+ return false;
1893
+ }
1894
+ }
1895
+ if (!c.operator && (lt || gt) && gtltComp !== 0) {
1896
+ return false;
1897
+ }
1898
+ }
1899
+ if (gt && hasDomLT && !lt && gtltComp !== 0) {
1900
+ return false;
1901
+ }
1902
+ if (lt && hasDomGT && !gt && gtltComp !== 0) {
1903
+ return false;
1904
+ }
1905
+ if (needDomGTPre || needDomLTPre) {
1906
+ return false;
1907
+ }
1908
+ return true;
1909
+ };
1910
+ var higherGT = (a, b, options) => {
1911
+ if (!a) {
1912
+ return b;
1913
+ }
1914
+ const comp = compare(a.semver, b.semver, options);
1915
+ return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
1916
+ };
1917
+ var lowerLT = (a, b, options) => {
1918
+ if (!a) {
1919
+ return b;
1920
+ }
1921
+ const comp = compare(a.semver, b.semver, options);
1922
+ return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
1923
+ };
1924
+ module.exports = subset;
1925
+ }
1926
+ });
1927
+
1928
+ // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/index.js
1929
+ var require_semver2 = __commonJS({
1930
+ "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/index.js"(exports, module) {
1931
+ "use strict";
1932
+ var internalRe = require_re();
1933
+ var constants = require_constants();
1934
+ var SemVer = require_semver();
1935
+ var identifiers = require_identifiers();
1936
+ var parse = require_parse();
1937
+ var valid2 = require_valid();
1938
+ var clean = require_clean();
1939
+ var inc = require_inc();
1940
+ var diff = require_diff();
1941
+ var major = require_major();
1942
+ var minor = require_minor();
1943
+ var patch = require_patch();
1944
+ var prerelease = require_prerelease();
1945
+ var compare = require_compare();
1946
+ var rcompare = require_rcompare();
1947
+ var compareLoose = require_compare_loose();
1948
+ var compareBuild = require_compare_build();
1949
+ var sort = require_sort();
1950
+ var rsort = require_rsort();
1951
+ var gt = require_gt();
1952
+ var lt = require_lt();
1953
+ var eq = require_eq();
1954
+ var neq = require_neq();
1955
+ var gte2 = require_gte();
1956
+ var lte = require_lte();
1957
+ var cmp = require_cmp();
1958
+ var coerce2 = require_coerce();
1959
+ var truncate = require_truncate();
1960
+ var Comparator = require_comparator();
1961
+ var Range = require_range();
1962
+ var satisfies = require_satisfies();
1963
+ var toComparators = require_to_comparators();
1964
+ var maxSatisfying = require_max_satisfying();
1965
+ var minSatisfying = require_min_satisfying();
1966
+ var minVersion = require_min_version();
1967
+ var validRange = require_valid2();
1968
+ var outside = require_outside();
1969
+ var gtr = require_gtr();
1970
+ var ltr = require_ltr();
1971
+ var intersects = require_intersects();
1972
+ var simplifyRange = require_simplify();
1973
+ var subset = require_subset();
1974
+ module.exports = {
1975
+ parse,
1976
+ valid: valid2,
1977
+ clean,
1978
+ inc,
1979
+ diff,
1980
+ major,
1981
+ minor,
1982
+ patch,
1983
+ prerelease,
1984
+ compare,
1985
+ rcompare,
1986
+ compareLoose,
1987
+ compareBuild,
1988
+ sort,
1989
+ rsort,
1990
+ gt,
1991
+ lt,
1992
+ eq,
1993
+ neq,
1994
+ gte: gte2,
1995
+ lte,
1996
+ cmp,
1997
+ coerce: coerce2,
1998
+ truncate,
1999
+ Comparator,
2000
+ Range,
2001
+ satisfies,
2002
+ toComparators,
2003
+ maxSatisfying,
2004
+ minSatisfying,
2005
+ minVersion,
2006
+ validRange,
2007
+ outside,
2008
+ gtr,
2009
+ ltr,
2010
+ intersects,
2011
+ simplifyRange,
2012
+ subset,
2013
+ SemVer,
2014
+ re: internalRe.re,
2015
+ src: internalRe.src,
2016
+ tokens: internalRe.t,
2017
+ SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
2018
+ RELEASE_TYPES: constants.RELEASE_TYPES,
2019
+ compareIdentifiers: identifiers.compareIdentifiers,
2020
+ rcompareIdentifiers: identifiers.rcompareIdentifiers
2021
+ };
2022
+ }
2023
+ });
2024
+
2025
+ // ../protocol/src/accounts.ts
2026
+ import { z } from "zod";
2027
+ var connectedAccount = z.object({
2028
+ /** The provider, e.g. "github". Unique per person, so it names the row. */
2029
+ providerId: z.string(),
2030
+ /**
2031
+ * The account's id at the provider. Better Auth stores the provider's own
2032
+ * user id here, which for GitHub is a number — the closest thing to a
2033
+ * display name the table holds.
2034
+ */
2035
+ accountId: z.string(),
2036
+ /** OAuth scopes granted, space separated. Null when the provider sent none. */
2037
+ scope: z.string().nullable(),
2038
+ /** When the account was linked, ISO 8601. */
2039
+ createdAt: z.string()
2040
+ });
2041
+ var connectedAccountsResponse = z.object({
2042
+ accounts: z.array(connectedAccount)
2043
+ });
2044
+
2045
+ // ../protocol/src/agent-policy.ts
2046
+ import { z as z2 } from "zod";
2047
+ var PERMISSION_DECISIONS = ["allow", "ask", "deny"];
2048
+ var CONFIGURABLE_PERMISSIONS = {
2049
+ install_dependency: ["allow", "ask", "deny"],
2050
+ // Everything outside the worktree is read-only in the sandbox (ADR 0009,
2051
+ // Stage 1 isolation), so writing there cannot be allowed wholesale.
2052
+ write_outside_repo: ["ask", "deny"],
2053
+ git_push: ["allow", "ask", "deny"],
2054
+ network: ["allow", "ask", "deny"],
2055
+ computer_use: ["allow", "ask", "deny"]
2056
+ };
2057
+ var CONFIGURABLE_ACTIONS = Object.keys(
2058
+ CONFIGURABLE_PERMISSIONS
2059
+ );
2060
+ var FIXED_PERMISSIONS = {
2061
+ read_in_worktree: "allow",
2062
+ write_in_worktree: "allow",
2063
+ run_project_script: "allow",
2064
+ // Allowed once the user approved the repo's recipe; asked before that.
2065
+ run_setup_recipe: "allow"
2066
+ };
2067
+ var PERMISSION_DEFAULTS = {
2068
+ ...FIXED_PERMISSIONS,
2069
+ install_dependency: "allow",
2070
+ write_outside_repo: "ask",
2071
+ git_push: "ask",
2072
+ network: "ask",
2073
+ computer_use: "ask"
2074
+ };
2075
+ var NETWORK_DOMAIN_RE = /^(\*\.)?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?(\.[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*(:[0-9]{1,5})?$/;
2076
+ var MAX_NETWORK_DOMAINS = 200;
2077
+ var MAX_GUIDANCE_LENGTH = 1e4;
2078
+ var MAX_MODEL_NAME_LENGTH = 120;
2079
+ var networkDomainSchema = z2.string().trim().toLowerCase().min(1).max(253).regex(NETWORK_DOMAIN_RE);
2080
+ function normalizeDomains(domains) {
2081
+ return [...new Set(domains.map((d) => d.trim().toLowerCase()))].filter(
2082
+ Boolean
2083
+ );
2084
+ }
2085
+ var networkAllowSchema = z2.array(networkDomainSchema).max(MAX_NETWORK_DOMAINS).transform(normalizeDomains);
2086
+ var storedPermissionsSchema = z2.strictObject({
2087
+ install_dependency: z2.enum(CONFIGURABLE_PERMISSIONS.install_dependency),
2088
+ write_outside_repo: z2.enum(CONFIGURABLE_PERMISSIONS.write_outside_repo),
2089
+ git_push: z2.enum(CONFIGURABLE_PERMISSIONS.git_push),
2090
+ network: z2.enum(CONFIGURABLE_PERMISSIONS.network),
2091
+ computer_use: z2.enum(CONFIGURABLE_PERMISSIONS.computer_use)
2092
+ }).partial();
2093
+ var guidanceSchema = z2.string().max(MAX_GUIDANCE_LENGTH);
2094
+ var runPolicySchema = z2.object({
2095
+ permissions: z2.object({
2096
+ install_dependency: z2.enum(PERMISSION_DECISIONS),
2097
+ write_outside_repo: z2.enum(PERMISSION_DECISIONS),
2098
+ git_push: z2.enum(PERMISSION_DECISIONS),
2099
+ network: z2.enum(PERMISSION_DECISIONS),
2100
+ // Older servers omit this field; the daemon treats that as ask, never allow.
2101
+ computer_use: z2.enum(PERMISSION_DECISIONS).optional()
2102
+ }),
2103
+ /** The workspace layer of the domain allow-list (ADR 0009). */
2104
+ networkAllow: z2.array(z2.string().min(1).max(253)).max(MAX_NETWORK_DOMAINS),
2105
+ /** Host-derived worker/workspace ceiling; even network=allow cannot widen it. */
2106
+ networkCeiling: z2.array(networkDomainSchema).max(MAX_NETWORK_DOMAINS).optional(),
2107
+ /**
2108
+ * The run only reads: the worktree is not writable and nothing is pushed
2109
+ * (ADR 0046). Absent from an older server means a normal, writable run.
2110
+ */
2111
+ readOnly: z2.boolean().optional()
2112
+ });
2113
+ var MODEL_HARNESSES = ["claude_code", "codex", "cursor"];
2114
+ var modelHarnessSchema = z2.enum(MODEL_HARNESSES);
2115
+ var modelNameSchema = z2.string().trim().min(1).max(MAX_MODEL_NAME_LENGTH);
2116
+ var modelByHarnessSchema = z2.strictObject({
2117
+ claude_code: modelNameSchema,
2118
+ codex: modelNameSchema,
2119
+ cursor: modelNameSchema
2120
+ }).partial();
2121
+ var APPROVAL_MODES = ["ask", "read_only"];
2122
+ var approvalModeSchema = z2.enum(APPROVAL_MODES);
2123
+
2124
+ // ../protocol/src/auth.ts
2125
+ import { z as z3 } from "zod";
2126
+ var AUTH_PROVIDERS = ["github", "google"];
2127
+ var authProvider = z3.enum(AUTH_PROVIDERS);
2128
+ var DESKTOP_SCHEMES = ["mikka", "mikka-dev"];
2129
+ var desktopScheme = z3.enum(DESKTOP_SCHEMES);
2130
+ var AUTH_BASE_PATH = "/api/auth";
2131
+ var DAEMON_CLIENT_ID = "mikka-daemon";
2132
+ var AUTH_ROUTES = {
2133
+ /** Better Auth jwt plugin: short-lived JWT for zero-cache and the relay. */
2134
+ token: `${AUTH_BASE_PATH}/token`,
2135
+ /** Dev-only bypass (a Better Auth endpoint, so it sets the session cookie). */
2136
+ devLogin: `${AUTH_BASE_PATH}/dev/login`,
2137
+ me: "/v1/me"
2138
+ };
2139
+ var activeSession = z3.object({
2140
+ id: z3.string(),
2141
+ /** ISO timestamps. */
2142
+ createdAt: z3.string(),
2143
+ expiresAt: z3.string(),
2144
+ ipAddress: z3.string().nullable(),
2145
+ userAgent: z3.string().nullable(),
2146
+ /** Derived from the caller's JWT (`sid`), not from the request's cookies. */
2147
+ current: z3.boolean()
2148
+ });
2149
+ var activeSessions = z3.object({ sessions: z3.array(activeSession) });
2150
+ var authorizedDevice = z3.object({
2151
+ id: z3.uuid(),
2152
+ name: z3.string(),
2153
+ hostname: z3.string().nullable(),
2154
+ platform: z3.string().nullable(),
2155
+ daemonVersion: z3.string().nullable(),
2156
+ lastSeenAt: z3.string().nullable(),
2157
+ /** The daemon session; null once the authorization is revoked. */
2158
+ sessionId: z3.string().nullable(),
2159
+ /** When the daemon signed in, and when that session expires. */
2160
+ authorizedAt: z3.string().nullable(),
2161
+ expiresAt: z3.string().nullable()
2162
+ });
2163
+ var authorizedDevices = z3.object({
2164
+ devices: z3.array(authorizedDevice)
2165
+ });
2166
+ var authorizedApplication = z3.object({
2167
+ id: z3.string(),
2168
+ name: z3.string(),
2169
+ uri: z3.string().nullable(),
2170
+ scopes: z3.array(z3.string()),
2171
+ createdAt: z3.string(),
2172
+ updatedAt: z3.string()
2173
+ });
2174
+ var authorizedApplications = z3.object({
2175
+ applications: z3.array(authorizedApplication)
2176
+ });
2177
+ var sessionUser = z3.object({
2178
+ id: z3.uuid(),
2179
+ email: z3.string(),
2180
+ name: z3.string(),
2181
+ image: z3.string().nullable()
2182
+ });
2183
+ var accessToken = z3.object({
2184
+ token: z3.string().min(1),
2185
+ /** Expiry, ms since epoch (from the JWT's `exp`). */
2186
+ expiresAt: z3.number().int()
2187
+ });
2188
+
2189
+ // ../protocol/src/bridge.ts
2190
+ import { z as z4 } from "zod";
2191
+ var LANGUAGES = ["zh-CN", "en"];
2192
+ var languagePreference = z4.enum(["system", ...LANGUAGES]);
2193
+ var themePreference = z4.enum(["system", "light", "dark"]);
2194
+ var appHref = z4.string().max(2048).regex(/^\/(?!\/)/);
2195
+ var DESKTOP_NOTIFICATION_KINDS = [
2196
+ "review",
2197
+ "awaiting",
2198
+ "failed"
2199
+ ];
2200
+ var desktopNotification = z4.object({
2201
+ /** The `notification` row id. */
2202
+ id: z4.string().min(1).max(200),
2203
+ kind: z4.enum(DESKTOP_NOTIFICATION_KINDS),
2204
+ /** `ORV-12 · 等你验收`; the issue number is always in it. */
2205
+ title: z4.string().min(1).max(300),
2206
+ /** The issue title. */
2207
+ body: z4.string().max(1e3),
2208
+ href: appHref
2209
+ });
2210
+ var desktopBadgeCount = z4.number().int().min(0).max(9999);
2211
+ var savedTab = z4.object({
2212
+ entries: z4.array(appHref).min(1).max(50),
2213
+ index: z4.number().int().min(0).max(49)
2214
+ });
2215
+ var savedTabs = z4.object({
2216
+ items: z4.array(savedTab).max(50),
2217
+ active: z4.number().int().min(0).max(49)
2218
+ });
2219
+ var firstDayOfWeekPreference = z4.enum(["monday", "sunday", "saturday"]);
2220
+ var commentSubmitKeyPreference = z4.enum(["mod+enter", "enter"]);
2221
+ var settingsSchema = z4.object({
2222
+ language: languagePreference,
2223
+ theme: themePreference,
2224
+ /** Sidebar expanded (true) or collapsed offcanvas (false); ⌘B and `[`. */
2225
+ sidebarOpen: z4.boolean(),
2226
+ /** Titlebar tabs; empty until the app has saved them once. */
2227
+ tabs: savedTabs,
2228
+ /** Send anonymous usage events (ADR 0033); off by choice in Settings. */
2229
+ telemetry: z4.boolean(),
2230
+ /** Which day a week starts on in date pickers. */
2231
+ firstDayOfWeek: firstDayOfWeekPreference,
2232
+ /** Which key press sends a comment. */
2233
+ commentSubmitKey: commentSubmitKeyPreference
2234
+ });
2235
+ var DEFAULT_SETTINGS = {
2236
+ language: "system",
2237
+ theme: "system",
2238
+ sidebarOpen: true,
2239
+ tabs: { items: [], active: 0 },
2240
+ telemetry: true,
2241
+ firstDayOfWeek: "monday",
2242
+ commentSubmitKey: "mod+enter"
2243
+ };
2244
+ var SETTINGS_KEYS = Object.keys(DEFAULT_SETTINGS);
2245
+ var authState = z4.discriminatedUnion("status", [
2246
+ z4.object({ status: z4.literal("signed_out") }),
2247
+ z4.object({ status: z4.literal("signing_in"), provider: authProvider }),
2248
+ z4.object({ status: z4.literal("signed_in"), user: sessionUser }),
2249
+ z4.object({
2250
+ status: z4.literal("update_required"),
2251
+ minVersion: z4.string()
2252
+ }),
2253
+ z4.object({ status: z4.literal("error"), code: z4.string() })
2254
+ ]);
2255
+ var localDevice = z4.object({
2256
+ /** Whether the daemon on this computer answers. */
2257
+ status: z4.enum(["online", "connecting", "offline"]),
2258
+ /** The device row this daemon registered, once it has. */
2259
+ deviceId: z4.string().nullable(),
2260
+ workspaceId: z4.string().nullable(),
2261
+ /** The daemon holds a device credential. */
2262
+ signedIn: z4.boolean(),
2263
+ /** The daemon's link to the server; null while the daemon is offline. */
2264
+ server: z4.enum(["online", "offline", "unregistered"]).nullable()
2265
+ });
2266
+ var deviceLinkRequest = z4.object({ workspaceId: z4.uuid() });
2267
+ var pickedRepo = z4.object({
2268
+ /** The repo's top level (a subfolder pick resolves to it). */
2269
+ path: z4.string().min(1).max(4e3),
2270
+ name: z4.string().max(500),
2271
+ /** `origin` (or the first remote), null when the repo has none. */
2272
+ remoteUrl: z4.string().max(2e3).nullable()
2273
+ });
2274
+ var pickRepoResult = z4.discriminatedUnion("status", [
2275
+ z4.object({ status: z4.literal("picked"), repo: pickedRepo }),
2276
+ z4.object({ status: z4.literal("cancelled") }),
2277
+ z4.object({ status: z4.literal("not_a_repo"), path: z4.string() })
2278
+ ]);
2279
+
2280
+ // ../protocol/src/cycles.ts
2281
+ import { z as z5 } from "zod";
2282
+ var WEEKDAYS = [
2283
+ "monday",
2284
+ "tuesday",
2285
+ "wednesday",
2286
+ "thursday",
2287
+ "friday",
2288
+ "saturday",
2289
+ "sunday"
2290
+ ];
2291
+ var CYCLE_DURATION_MIN_DAYS = 1;
2292
+ var CYCLE_DURATION_MAX_DAYS = 56;
2293
+ var CYCLE_UPCOMING_MAX = 8;
2294
+ var teamCycleSettingsSchema = z5.object({
2295
+ /** Off until a person turns it on: nothing is created and nothing rolls. */
2296
+ enabled: z5.boolean().default(false),
2297
+ /** Length of a cycle in days; the end date is `start + duration - 1`. */
2298
+ durationDays: z5.number().int().min(CYCLE_DURATION_MIN_DAYS).max(CYCLE_DURATION_MAX_DAYS).default(14),
2299
+ /** The weekday a team's first cycle starts on. */
2300
+ startWeekday: z5.enum(WEEKDAYS).default("monday"),
2301
+ /** Cycles kept ready ahead of the current one. 0 creates them just in time. */
2302
+ upcomingCount: z5.number().int().min(0).max(CYCLE_UPCOMING_MAX).default(1),
2303
+ /**
2304
+ * When a cycle ends, unfinished issues move to the next one. Off leaves them
2305
+ * in the finished cycle, which is what `cycle.complete` has always done.
2306
+ */
2307
+ autoRollover: z5.boolean().default(true),
2308
+ /**
2309
+ * The team's calendar. A cycle ends at the last moment of its end date
2310
+ * *here*, not in UTC, so a team in Auckland and one in Los Angeles roll over
2311
+ * at different instants.
2312
+ */
2313
+ timezone: z5.string().max(64).refine(isValidTimeZone, "Unknown timezone.").default("UTC")
2314
+ });
2315
+ function isValidTimeZone(value) {
2316
+ try {
2317
+ new Intl.DateTimeFormat("en-US", { timeZone: value });
2318
+ return true;
2319
+ } catch {
2320
+ return false;
2321
+ }
2322
+ }
2323
+
2324
+ // ../protocol/src/daemon.ts
2325
+ import { z as z10 } from "zod";
2326
+
2327
+ // ../protocol/src/harness.ts
2328
+ import { z as z6 } from "zod";
2329
+ var HARNESSES = ["claude_code", "codex", "cursor", "mock"];
2330
+ var harnessSchema = z6.enum(HARNESSES);
2331
+ var harnessInfoSchema = z6.object({
2332
+ harness: harnessSchema,
2333
+ installed: z6.boolean(),
2334
+ models: z6.array(z6.string().trim().min(1).max(128)).max(500).optional(),
2335
+ /** Deprecated (#312, 2026-10-27): could host the native Coordinator. The server keeps that runtime switched off. */
2336
+ coordinator: z6.boolean().optional(),
2337
+ /** Set only by a runner with an isolated, owner-bound subscription broker. */
2338
+ subscriptionBroker: z6.literal(true).optional(),
2339
+ /** Set only by an E2B worker with the guarded Bot computer broker. */
2340
+ computerBroker: z6.literal(true).optional(),
2341
+ /** Run-scoped CLI approvals and policy-version checks are supported. */
2342
+ toolApproval: z6.literal(true).optional(),
2343
+ /** Version string reported by the CLI, null when not installed. */
2344
+ version: z6.string().nullable()
2345
+ });
2346
+
2347
+ // ../protocol/src/quota.ts
2348
+ import { z as z7 } from "zod";
2349
+ var QUOTA_VENDORS = ["claude_code", "codex", "cursor"];
2350
+ var quotaVendorSchema = z7.enum(QUOTA_VENDORS);
2351
+ var QUOTA_SOURCES = ["local_credentials", "official"];
2352
+ var quotaSourceSchema = z7.enum(QUOTA_SOURCES);
2353
+ var QUOTA_WINDOW_KINDS = [
2354
+ "five_hour",
2355
+ "weekly",
2356
+ "monthly",
2357
+ "daily",
2358
+ "hourly",
2359
+ "other"
2360
+ ];
2361
+ var quotaWindowKindSchema = z7.enum(QUOTA_WINDOW_KINDS);
2362
+ var QUOTA_METERS = [
2363
+ "auto",
2364
+ "api",
2365
+ "on_demand",
2366
+ "team_pool",
2367
+ "team_on_demand"
2368
+ ];
2369
+ var quotaMeterSchema = z7.enum(QUOTA_METERS);
2370
+ var quotaWindowSchema = z7.object({
2371
+ kind: quotaWindowKindSchema,
2372
+ /** 0..1 share of the window already used. */
2373
+ used: z7.number().min(0).max(1),
2374
+ resetsAt: z7.string().nullable(),
2375
+ /** Model display name for a per-model window, e.g. "Opus". */
2376
+ model: z7.string().min(1).max(40).optional(),
2377
+ meter: quotaMeterSchema.optional()
2378
+ });
2379
+ var quotaSnapshotSchema = z7.object({
2380
+ vendor: quotaVendorSchema,
2381
+ source: quotaSourceSchema,
2382
+ status: z7.enum(["ok", "unknown"]),
2383
+ plan: z7.string().max(40).nullable(),
2384
+ windows: z7.array(quotaWindowSchema).max(12),
2385
+ /** When this vendor was last read (ISO-8601). */
2386
+ observedAt: z7.string()
2387
+ });
2388
+ var quotaSnapshotReportSchema = z7.object({
2389
+ /** When the whole read finished. Null before the first read. */
2390
+ observedAt: z7.string().nullable(),
2391
+ quotas: z7.array(quotaSnapshotSchema).max(6)
2392
+ });
2393
+
2394
+ // ../protocol/src/run.ts
2395
+ import { z as z9 } from "zod";
2396
+
2397
+ // ../protocol/src/plan.ts
2398
+ import { z as z8 } from "zod";
2399
+ var text = (max) => z8.string().trim().min(1).max(max);
2400
+ var key = z8.string().trim().min(1).max(64);
2401
+ var planSection = z8.object({
2402
+ heading: text(200),
2403
+ items: z8.array(text(2e3)).min(1).max(50)
2404
+ });
2405
+ var planSpec = z8.object({
2406
+ title: text(500),
2407
+ summary: z8.string().trim().max(4e3).default(""),
2408
+ sections: z8.array(planSection).min(1).max(30)
2409
+ });
2410
+ var planCriterion = z8.object({
2411
+ body: text(2e3),
2412
+ /** The command that checks it; absent means a person checks it. */
2413
+ checkCommand: z8.string().trim().max(2e3).optional()
2414
+ });
2415
+ var PLAN_PRIORITIES = [
2416
+ "none",
2417
+ "urgent",
2418
+ "high",
2419
+ "medium",
2420
+ "low"
2421
+ ];
2422
+ var planIssue = z8.object({
2423
+ key,
2424
+ title: text(500),
2425
+ goal: z8.string().trim().max(4e3).optional(),
2426
+ /** Grouping only; order lives in `blockedBy` (`issue.parent_id`). */
2427
+ parentKey: key.optional(),
2428
+ blockedBy: z8.array(key).max(50).default([]),
2429
+ criteria: z8.array(planCriterion).min(1).max(50),
2430
+ verifyCommand: z8.string().trim().max(2e3).optional(),
2431
+ predictedFiles: z8.array(z8.string().trim().max(1e3)).max(200).default([]),
2432
+ sizeEstimate: z8.object({ files: z8.number().int().min(0), lines: z8.number().int().min(0) }).optional(),
2433
+ priority: z8.enum(PLAN_PRIORITIES).default("none")
2434
+ });
2435
+ var planSplit = z8.object({
2436
+ summary: z8.string().trim().max(4e3).default(""),
2437
+ issues: z8.array(planIssue).min(1).max(100)
2438
+ });
2439
+ var planHandoff = z8.object({
2440
+ specId: z8.uuid(),
2441
+ spec: planSpec,
2442
+ split: planSplit
2443
+ });
2444
+
2445
+ // ../protocol/src/run.ts
2446
+ var RUN_QUESTION_KINDS = [
2447
+ "context",
2448
+ "decision",
2449
+ "permission",
2450
+ "external"
2451
+ ];
2452
+ var runQuestion = z9.object({
2453
+ questionId: z9.uuid(),
2454
+ kind: z9.enum(RUN_QUESTION_KINDS).default("decision"),
2455
+ question: z9.string().trim().min(1).max(4e3),
2456
+ context: z9.string().trim().max(4e3).optional(),
2457
+ options: z9.array(z9.string().trim().min(1).max(4e3)).max(20).default([])
2458
+ }).strict();
2459
+ var RUN_STOP_REASONS = [
2460
+ "submitted",
2461
+ "turn_ended",
2462
+ "asked_human",
2463
+ "blocked",
2464
+ "cancelled",
2465
+ "error",
2466
+ "timeout",
2467
+ "device_lost"
2468
+ ];
2469
+ var runStopReason = z9.enum(RUN_STOP_REASONS);
2470
+ var shortList = z9.array(z9.string().max(1e3)).max(5e3);
2471
+ var VERIFY_STATUSES = ["passed", "failed", "not_run"];
2472
+ var verifyStatus = z9.enum(VERIFY_STATUSES);
2473
+ var runPublish = z9.object({
2474
+ /** Where the commit went: the issue's branch, or the run's own. */
2475
+ branch: z9.string().max(500),
2476
+ /** Null when nothing was committed (no changes, or the commit failed). */
2477
+ commit: z9.string().max(100).nullable(),
2478
+ pushed: z9.boolean(),
2479
+ remote: z9.string().max(200).nullable(),
2480
+ /**
2481
+ * Why nothing was pushed when that was expected: the agent changed
2482
+ * nothing, or the repo has not approved pushes. Absent with
2483
+ * `pushed: false` means the commit or the push failed (see `note`).
2484
+ */
2485
+ skipped: z9.enum(["no_changes", "not_approved"]).optional(),
2486
+ note: z9.string().max(2e3).optional()
2487
+ });
2488
+ var runBenchmarkContext = z9.object({
2489
+ sourceCommit: z9.string().regex(/^[a-f0-9]{40}$/),
2490
+ benchmarkDigest: z9.string().regex(/^[a-f0-9]{64}$/),
2491
+ caseId: z9.string().min(1).max(200),
2492
+ fixtureDigest: z9.string().regex(/^[a-f0-9]{64}$/),
2493
+ policyDigest: z9.string().regex(/^[a-f0-9]{64}$/)
2494
+ }).strict();
2495
+ var runExecution = runBenchmarkContext.extend({
2496
+ harness: z9.enum(["codex", "claude_code", "cursor"]),
2497
+ requestedModel: z9.string().min(1).max(500).nullable(),
2498
+ observedModel: z9.string().min(1).max(500).nullable(),
2499
+ verifyCommand: z9.string().min(1).max(2e3)
2500
+ }).strict();
2501
+ var runRuntime = runExecution.pick({
2502
+ harness: true,
2503
+ requestedModel: true,
2504
+ observedModel: true,
2505
+ policyDigest: true,
2506
+ sourceCommit: true
2507
+ }).strict();
2508
+ var runSkillMount = z9.object({
2509
+ receiptId: z9.uuid(),
2510
+ versionId: z9.uuid(),
2511
+ sha256: z9.string().regex(/^[a-f0-9]{64}$/),
2512
+ sessionId: z9.string().min(1).max(500),
2513
+ mountedAt: z9.iso.datetime()
2514
+ }).strict();
2515
+ var runReport = z9.object({
2516
+ /** Worktree base journaled before the adapter started; never agent-supplied. */
2517
+ sourceCommit: z9.string().regex(/^[a-f0-9]{40}$/).optional(),
2518
+ skillMount: runSkillMount.optional(),
2519
+ execution: runExecution.optional(),
2520
+ runtime: runRuntime.optional(),
2521
+ /** What was done, in a few sentences. Empty when the run crashed early. */
2522
+ summary: z9.string().max(1e4),
2523
+ /** Paths relative to the worktree root (from `git status`). */
2524
+ filesChanged: shortList,
2525
+ /** The daemon's run of the issue's verify command after a submit. */
2526
+ verify: z9.object({
2527
+ status: verifyStatus,
2528
+ command: z9.string().max(2e3).optional(),
2529
+ /** Actual process outcome from the daemon, never the agent. */
2530
+ exitCode: z9.number().int().nullable().optional(),
2531
+ signal: z9.string().max(100).nullable().optional(),
2532
+ timedOut: z9.boolean().optional(),
2533
+ /** Tail of the command output. */
2534
+ output: z9.string().max(1e4).optional()
2535
+ }),
2536
+ openQuestions: z9.array(z9.string().max(2e3)).max(50),
2537
+ /** What should happen next, from the agent's point of view. */
2538
+ question: runQuestion.optional(),
2539
+ nextStep: z9.string().max(2e3).nullable(),
2540
+ /** For `blocked`: the external condition, e.g. `quota_exhausted`. */
2541
+ blockedOn: z9.string().max(500).optional(),
2542
+ /** Daemon-owned receipt for an exact, unchanged read-only candidate. */
2543
+ check: z9.object({
2544
+ sha: z9.string().regex(/^[a-f0-9]{40}$/),
2545
+ readOnly: z9.literal(true)
2546
+ }).optional(),
2547
+ /** Preview branch created or used by the producing run; descriptive metadata only. */
2548
+ previewDatabaseBranch: z9.string().trim().min(1).max(500).optional(),
2549
+ /** Acceptance criteria the agent checked, with evidence. */
2550
+ criteria: z9.array(
2551
+ z9.object({
2552
+ criterionId: z9.uuid().optional(),
2553
+ text: z9.string().max(2e3).optional(),
2554
+ passed: z9.boolean(),
2555
+ evidence: z9.string().max(1e4).optional(),
2556
+ /** Agent-reported criterion check; the daemon-owned verify remains authoritative. */
2557
+ command: z9.string().trim().min(1).max(2e3).optional(),
2558
+ exitCode: z9.number().int().nullable().optional()
2559
+ })
2560
+ ).max(200).optional(),
2561
+ /**
2562
+ * A `plan` run's hand-in: the spec it wrote and the split it proposes for
2563
+ * it (ADR ORV-205). Only the daemon sets this, and only for a `plan` run.
2564
+ */
2565
+ plan: planHandoff.optional(),
2566
+ interfacesProduced: shortList.optional(),
2567
+ knownIssues: shortList.optional(),
2568
+ notesForNext: z9.string().max(1e4).optional(),
2569
+ /** Set by the daemon after a verified submit; never by the agent. */
2570
+ publish: runPublish.optional(),
2571
+ followUps: z9.array(
2572
+ z9.object({
2573
+ title: z9.string().trim().min(1).max(500),
2574
+ goal: z9.string().max(2e3).optional(),
2575
+ reason: z9.string().max(2e3).optional()
2576
+ })
2577
+ ).max(50).optional()
2578
+ });
2579
+ var runCompletion = z9.object({
2580
+ stopReason: runStopReason,
2581
+ report: runReport
2582
+ });
2583
+ var runCompleteRequest = z9.object({ stopReason: runStopReason, report: runReport.optional() }).refine((body) => body.stopReason !== "submitted" || body.report, {
2584
+ message: "A submitted run needs a report.",
2585
+ path: ["report"]
2586
+ });
2587
+
2588
+ // ../protocol/src/daemon.ts
2589
+ var RUN_STATES = [
2590
+ "queued",
2591
+ "preparing",
2592
+ "running",
2593
+ "waiting_input",
2594
+ "finishing",
2595
+ "succeeded",
2596
+ /** Ended without success or failure: the turn ended, a question, a blocker. */
2597
+ "stopped",
2598
+ "failed",
2599
+ "cancelled"
2600
+ ];
2601
+ var runStateSchema = z10.enum(RUN_STATES);
2602
+ var stopReasonSchema = runStopReason;
2603
+ var DAEMON_RPC_ERRORS = {
2604
+ handshakeRequired: 4001,
2605
+ protocolMismatch: 4002,
2606
+ unauthorized: 4003,
2607
+ repoNotAllowed: 4010,
2608
+ runNotFound: 4011,
2609
+ runNotPinnedHere: 4012,
2610
+ harnessNotSupported: 4013,
2611
+ invalidId: 4014,
2612
+ serverUnreachable: 4020,
2613
+ draining: 4030
2614
+ };
2615
+ var helloParams = z10.object({
2616
+ protocolVersion: z10.number().int(),
2617
+ /** Contents of the daemon's `daemon.secret` file in the flavor data dir. */
2618
+ secret: z10.string(),
2619
+ client: z10.object({ name: z10.string(), version: z10.string() })
2620
+ });
2621
+ var helloResult = z10.object({
2622
+ protocolVersion: z10.number().int(),
2623
+ daemonVersion: z10.string(),
2624
+ pid: z10.number().int()
2625
+ });
2626
+ var runSummarySchema = z10.object({
2627
+ runId: z10.string(),
2628
+ issueId: z10.string(),
2629
+ harness: harnessSchema,
2630
+ state: runStateSchema,
2631
+ worktree: z10.string().nullable(),
2632
+ sessionId: z10.string().nullable(),
2633
+ /** Chunks emitted so far (the daemon-local producer sequence). */
2634
+ chunks: z10.number().int().nonnegative(),
2635
+ error: z10.string().nullable(),
2636
+ /** Set once the run reached a terminal state. */
2637
+ stopReason: stopReasonSchema.optional(),
2638
+ /** Lease from the server; the daemon stops the run if it cannot renew it. */
2639
+ leaseExpiresAt: z10.string().optional(),
2640
+ /** Last progress seen by the watchdog (ISO time), while the run is active. */
2641
+ lastProgressAt: z10.string().optional()
2642
+ });
2643
+ var daemonStatusSchema = z10.object({
2644
+ daemonVersion: z10.string(),
2645
+ protocolVersion: z10.number().int(),
2646
+ pid: z10.number().int(),
2647
+ dataDir: z10.string(),
2648
+ /** Null until the device is registered with the server. */
2649
+ deviceId: z10.string().nullable(),
2650
+ /** The workspace the device credential was handed over for, if named. */
2651
+ workspaceId: z10.string().nullable(),
2652
+ /** Holds a device credential (it may still be refused by the server). */
2653
+ signedIn: z10.boolean(),
2654
+ server: z10.enum(["online", "offline", "unregistered"]),
2655
+ harnesses: z10.array(harnessInfoSchema),
2656
+ runs: z10.array(runSummarySchema),
2657
+ /** Bytes used by run worktrees under the daemon's data dir. */
2658
+ worktreeDiskBytes: z10.number().int().nonnegative(),
2659
+ /** Items buffered on disk, waiting for the server. */
2660
+ pendingUploads: z10.number().int().nonnegative(),
2661
+ draining: z10.boolean(),
2662
+ /** Latest subscription snapshots. Empty when quota polling is off. */
2663
+ quotas: z10.array(quotaSnapshotSchema).max(6)
2664
+ });
2665
+ var empty = z10.object({}).optional();
2666
+ var ok = z10.object({ ok: z10.literal(true) });
2667
+ var daemonRpc = {
2668
+ "daemon.hello": { params: helloParams, result: helloResult },
2669
+ "daemon.status": { params: empty, result: daemonStatusSchema },
2670
+ /** Cached subscription snapshots. Does not start a vendor request. */
2671
+ "quota.snapshot": { params: empty, result: quotaSnapshotReportSchema },
2672
+ /** Stop accepting runs, journal active ones for resume, then exit. */
2673
+ "daemon.drain": { params: empty, result: ok },
2674
+ /** Hand the daemon a device credential obtained by the signed-in desktop. */
2675
+ "device.setCredential": {
2676
+ params: z10.object({
2677
+ credential: z10.string().min(1),
2678
+ /** Needed only for users in more than one workspace. */
2679
+ workspaceId: z10.uuid().optional()
2680
+ }),
2681
+ result: ok
2682
+ },
2683
+ /** Forget the device credential (the person signed out of the app). */
2684
+ "device.clearCredential": { params: empty, result: ok },
2685
+ /** Claim a queued run pinned to this device and start it. */
2686
+ "runs.start": {
2687
+ params: z10.object({ runId: z10.string() }),
2688
+ result: runSummarySchema
2689
+ },
2690
+ "runs.list": { params: empty, result: z10.array(runSummarySchema) },
2691
+ /** Interject a user message into a running session. */
2692
+ "runs.send": {
2693
+ params: z10.object({ runId: z10.string(), text: z10.string().min(1) }),
2694
+ result: ok
2695
+ },
2696
+ "runs.cancel": {
2697
+ params: z10.object({ runId: z10.string() }),
2698
+ result: runSummarySchema
2699
+ },
2700
+ /**
2701
+ * Dev only (`mikka daemon --dev --server memory`): queue and start a mock
2702
+ * run on an allow-listed repo without a server. Refused otherwise.
2703
+ */
2704
+ "dev.mockRun": {
2705
+ params: z10.object({
2706
+ repoId: z10.string(),
2707
+ fixture: z10.string().optional(),
2708
+ baseBranch: z10.string().optional(),
2709
+ /** Run after the mock submits; defaults to `git diff --check`. */
2710
+ verifyCommand: z10.string().optional()
2711
+ }),
2712
+ result: runSummarySchema
2713
+ }
2714
+ };
2715
+
2716
+ // ../protocol/src/device.ts
2717
+ import { z as z13 } from "zod";
2718
+
2719
+ // ../protocol/src/skill.ts
2720
+ import { z as z12 } from "zod";
2721
+
2722
+ // ../protocol/src/skill-artifact.ts
2723
+ import { z as z11 } from "zod";
2724
+ var skillArtifactRefSchema = z11.object({
2725
+ schemaVersion: z11.literal(1),
2726
+ registryId: z11.literal("mikka-builtin"),
2727
+ skillId: z11.uuid(),
2728
+ versionId: z11.uuid(),
2729
+ format: z11.literal("single-skill-md-v1"),
2730
+ sha256: z11.string().regex(/^[a-f0-9]{64}$/)
2731
+ }).strict();
2732
+ var skillAssignmentReceiptSchema = z11.object({
2733
+ id: z11.uuid(),
2734
+ runId: z11.uuid(),
2735
+ issueId: z11.uuid(),
2736
+ agentId: z11.uuid(),
2737
+ repoId: z11.uuid(),
2738
+ deviceId: z11.uuid(),
2739
+ leaseExpiresAt: z11.iso.datetime(),
2740
+ assignedAt: z11.iso.datetime(),
2741
+ artifact: skillArtifactRefSchema
2742
+ }).strict();
2743
+ var skillReceiptRevalidationSchema = z11.object({
2744
+ skillReceipt: skillAssignmentReceiptSchema,
2745
+ leaseExpiresAt: z11.iso.datetime()
2746
+ }).strict();
2747
+
2748
+ // ../protocol/src/skill.ts
2749
+ var MAX_SKILLS_PER_RUN = 20;
2750
+ var MAX_SKILL_NAME_LENGTH = 80;
2751
+ var MAX_SKILL_DESCRIPTION_LENGTH = 500;
2752
+ var MAX_SKILL_INSTRUCTIONS_LENGTH = 2e4;
2753
+ var MAX_SKILL_FILES = 20;
2754
+ var MAX_SKILL_FILE_PATH_LENGTH = 200;
2755
+ var MAX_SKILL_FILE_CONTENT_LENGTH = 1e5;
2756
+ var skillFilePathSchema = z12.string().min(1).max(MAX_SKILL_FILE_PATH_LENGTH).refine(
2757
+ (path) => !path.startsWith("/") && !path.includes("\\") && !path.split("/").some((segment) => segment === ".." || segment === ""),
2758
+ { message: "A skill file path must be relative and stay inside the skill." }
2759
+ );
2760
+ var skillFileSchema = z12.object({
2761
+ path: skillFilePathSchema,
2762
+ content: z12.string().max(MAX_SKILL_FILE_CONTENT_LENGTH)
2763
+ });
2764
+ var skillFilesSchema = z12.array(skillFileSchema).max(MAX_SKILL_FILES);
2765
+ var skillNameSchema = z12.string().trim().min(1).max(MAX_SKILL_NAME_LENGTH);
2766
+ var skillDescriptionSchema = z12.string().trim().max(MAX_SKILL_DESCRIPTION_LENGTH);
2767
+ var skillInstructionsSchema = z12.string().trim().min(1).max(MAX_SKILL_INSTRUCTIONS_LENGTH);
2768
+ var runSkillSchema = z12.object({
2769
+ id: z12.uuid(),
2770
+ name: skillNameSchema,
2771
+ description: z12.string().nullable(),
2772
+ instructions: skillInstructionsSchema,
2773
+ files: skillFilesSchema
2774
+ });
2775
+ var runSkillRefSchema = z12.object({
2776
+ id: z12.uuid(),
2777
+ name: skillNameSchema
2778
+ });
2779
+
2780
+ // ../protocol/src/device.ts
2781
+ var id = z13.string().min(1).max(64);
2782
+ var isoTime = z13.iso.datetime({ offset: true });
2783
+ var deviceComputerCapability = z13.object({ installed: z13.boolean(), version: z13.string().max(100).nullable() }).strict();
2784
+ var deviceRegistration = z13.object({
2785
+ deviceType: z13.enum(["laptop", "server"]).optional(),
2786
+ name: z13.string().trim().min(1).max(200),
2787
+ hostname: z13.string().max(255).nullable().optional(),
2788
+ platform: z13.string().max(50),
2789
+ arch: z13.string().max(50),
2790
+ daemonVersion: z13.string().max(50),
2791
+ protocolVersion: z13.number().int(),
2792
+ harnesses: z13.array(harnessInfoSchema).max(20),
2793
+ computerUse: deviceComputerCapability.optional(),
2794
+ /**
2795
+ * This machine's one device id, the same in every workspace (ADR ORV-284).
2796
+ * Registering with it in another workspace joins the same device there.
2797
+ * An id the server does not know yet becomes the new device's id; another
2798
+ * person's id registers a new device.
2799
+ */
2800
+ deviceId: id.optional(),
2801
+ /** Needed only when the user belongs to more than one workspace. */
2802
+ workspaceId: z13.uuid().optional()
2803
+ });
2804
+ var deviceRegistered = z13.object({
2805
+ deviceId: id,
2806
+ workspaceId: z13.uuid()
2807
+ });
2808
+ var heartbeatRunSchema = z13.object({
2809
+ runId: id,
2810
+ /** Last tool call, turn boundary or file change (not raw output). */
2811
+ lastProgressAt: isoTime
2812
+ });
2813
+ var deviceManagementCommand = z13.object({ id: z13.uuid(), kind: z13.enum(["redetect", "restart", "update", "uninstall"]) });
2814
+ var deviceHeartbeatSchema = z13.object({
2815
+ completedDeviceCommands: z13.array(z13.uuid()).max(100).optional(),
2816
+ failedDeviceCommands: z13.array(z13.object({ id: z13.uuid(), error: z13.string().max(500) })).max(100).optional(),
2817
+ harnesses: z13.array(harnessInfoSchema).max(20),
2818
+ computerUse: deviceComputerCapability.optional(),
2819
+ deviceType: z13.enum(["laptop", "server"]).optional(),
2820
+ runs: z13.array(heartbeatRunSchema).max(500),
2821
+ worktreeDiskBytes: z13.number().int().nonnegative(),
2822
+ /**
2823
+ * Subscription windows read on this device. Absent when the daemon is not
2824
+ * polling. Numbers only, never a vendor credential (ADR 0027).
2825
+ */
2826
+ quotas: z13.array(quotaSnapshotSchema).max(6).optional()
2827
+ });
2828
+ var heartbeatResultSchema = z13.object({
2829
+ deviceCommands: z13.array(deviceManagementCommand).max(1).optional(),
2830
+ /** Renewed lease expiry per run id; a run missing here is not renewed. */
2831
+ leases: z13.record(z13.string(), isoTime),
2832
+ /**
2833
+ * Runs the device reported that it no longer holds: they ended on the
2834
+ * server, or went to another attempt after the lease ran out. The daemon
2835
+ * stops them now instead of when their lease runs out.
2836
+ */
2837
+ revoked: z13.array(id).max(500).optional(),
2838
+ /** Short-lived cloud device token, returned only over its authenticated link. */
2839
+ cloudCredential: z13.string().regex(/^orv_[A-Za-z0-9_-]{43}$/).optional()
2840
+ });
2841
+ var RUN_CHECKPOINT_MAX_BYTES = 8 * 1024 * 1024;
2842
+ var runCheckpointSchema = z13.object({
2843
+ /** The commit the run's worktree started from. */
2844
+ baseCommit: z13.string().regex(/^[0-9a-f]{40,64}$/),
2845
+ /**
2846
+ * `git diff --binary` from `baseCommit` to the whole worktree (tracked
2847
+ * and untracked files, ignored ones left out, the agent's own commits
2848
+ * included), gzipped, base64.
2849
+ */
2850
+ patch: z13.string().max(Math.ceil(RUN_CHECKPOINT_MAX_BYTES * 4 / 3) + 4),
2851
+ /** Files the patch touches. */
2852
+ files: z13.number().int().nonnegative(),
2853
+ takenAt: isoTime
2854
+ });
2855
+ var setupRecipeSchema = z13.object({
2856
+ /** Paths relative to the main checkout copied into each new worktree. */
2857
+ copyFiles: z13.array(z13.string().max(1e3)).max(200),
2858
+ /** Shell command run in the worktree, e.g. `bun install`. */
2859
+ command: z13.string().max(2e3).optional(),
2860
+ /** Approved once per repo by the user; unapproved recipes never run. */
2861
+ approved: z13.boolean()
2862
+ });
2863
+ var deviceRepoSchema = z13.object({
2864
+ repoId: id,
2865
+ name: z13.string().max(500),
2866
+ /** Logical repository key; only trusted cloud runtimes use an absolute path. */
2867
+ path: z13.string().min(1).max(4e3),
2868
+ remoteUrl: z13.string().max(2e3).nullable().optional(),
2869
+ setup: setupRecipeSchema.optional(),
2870
+ /** Domains agents may reach in this repo, on top of the harness's own. */
2871
+ networkAllow: z13.array(z13.string().min(1).max(253)).max(200).optional(),
2872
+ /** Push run branches after a verified hand-in ("always for this repo"). */
2873
+ push: z13.object({
2874
+ approved: z13.boolean(),
2875
+ remote: z13.string().min(1).max(200).optional()
2876
+ }).optional()
2877
+ });
2878
+ var deviceReposResponse = z13.object({
2879
+ repos: z13.array(deviceRepoSchema)
2880
+ });
2881
+ var pendingRunsResponse = z13.object({ runIds: z13.array(id) });
2882
+ var RUN_KINDS = ["implement", "acceptance", "fix", "plan"];
2883
+ var runAssignmentSchema = z13.object({
2884
+ runId: id,
2885
+ issueId: id,
2886
+ deviceId: id,
2887
+ repoId: id,
2888
+ /** Clone URL for local runs; hosted computer assignments keep their isolated workspace. */
2889
+ remoteUrl: z13.string().min(1).max(4e3).optional(),
2890
+ /** Absent means origin/HEAD after fetch. */
2891
+ baseBranch: z13.string().min(1).max(500).optional(),
2892
+ expectedRepoRemote: z13.string().max(2e3).optional(),
2893
+ harness: harnessSchema,
2894
+ prompt: z13.string().max(1e5),
2895
+ /**
2896
+ * The model the harness's CLI is asked to run, from the per-harness
2897
+ * preference of the person this run works for (ADR 0060). Absent: the
2898
+ * CLI's own default. A daemon that does not know the field ignores it
2899
+ * (zod strips unknown keys), so this needs no version gate.
2900
+ */
2901
+ model: modelNameSchema.optional(),
2902
+ /** Owner-bound selection only; no subscription credential enters the assignment. */
2903
+ subscriptionBinding: z13.object({
2904
+ bindingId: z13.uuid(),
2905
+ ownerId: z13.string().min(1).max(128),
2906
+ workspaceId: z13.uuid(),
2907
+ consumerId: z13.uuid(),
2908
+ route: z13.enum(["codex_cli", "claude_code_cli"])
2909
+ }).strict().optional(),
2910
+ /** Local host authority comes only from the server's owner-bound Bot run. */
2911
+ localComputer: z13.object({
2912
+ botId: z13.uuid(),
2913
+ ownerId: z13.string().min(1).max(128),
2914
+ workspaceId: z13.uuid(),
2915
+ policyVersion: z13.number().int().nonnegative().max(2147483647),
2916
+ permission: z13.enum(["allow", "ask"])
2917
+ }).strict().optional(),
2918
+ /** Trusted server assignment; the model cannot choose a Bot or display. */
2919
+ computer: z13.object({
2920
+ botId: z13.uuid(),
2921
+ ownerId: z13.string().min(1).max(128),
2922
+ display: z13.string().regex(/^:[1-9][0-9]{0,2}$/),
2923
+ policyVersion: z13.number().int().nonnegative().max(2147483647)
2924
+ }).strict().optional(),
2925
+ /**
2926
+ * 4e3: the task's explicit user variables (workspace + matching repository secrets/env, NAME -> value).
2927
+ * Cloud workers only. Passed into the task container through its own channel, never into the worker's
2928
+ * env, and never written to the run journal.
2929
+ */
2930
+ taskEnv: z13.record(z13.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/), z13.string().max(65536)).optional(),
2931
+ /**
2932
+ * Names in `taskEnv` that are secrets (kind 'secret'; env vars are not listed). The daemon masks
2933
+ * their values (raw + standard base64) in run output before anything is uploaded; the server
2934
+ * masks again. Older daemons strip this field and rely on server-side masking only.
2935
+ */
2936
+ taskSecretNames: z13.array(z13.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/)).max(500).optional(),
2937
+ /** Mock harness only: fixture name under `packages/daemon/fixtures`. */
2938
+ fixture: z13.string().max(200).optional(),
2939
+ /**
2940
+ * The issue's branch (`mikka/<team>-<number>`, ADR 0024): every run of
2941
+ * the issue pushes its verified commit here, so one pull request follows
2942
+ * the issue across fix rounds. A run that starts a new worktree builds on
2943
+ * this branch from the remote when it exists. Without it the daemon
2944
+ * pushes the run's own branch.
2945
+ */
2946
+ pushBranch: z13.string().min(1).max(250).optional(),
2947
+ /** Run by the daemon in the worktree after the agent submits. */
2948
+ verifyCommand: z13.string().max(2e3).optional(),
2949
+ /** Run lease; renewed through the device heartbeat. */
2950
+ leaseExpiresAt: isoTime.optional(),
2951
+ /**
2952
+ * The Mikka MCP server for the agent inside this run: `report`, `ask` and
2953
+ * `blocked` reach the person's Coordinator. Send `token` as a bearer token;
2954
+ * it stops working when the run ends. Absent: the server could not issue
2955
+ * one, and the run goes ahead without it.
2956
+ */
2957
+ mcp: z13.object({ url: z13.url(), token: z13.string().min(1).max(200), mailbox: z13.literal(true).optional() }).optional(),
2958
+ /** Question continuation must not silently open a different session. */
2959
+ /**
2960
+ * What the orchestrator dispatched this run for (ADR 0023). `plan` writes a
2961
+ * spec and proposes a split instead of changing code (ADR ORV-205).
2962
+ */
2963
+ kind: z13.enum(RUN_KINDS).optional(),
2964
+ /**
2965
+ * The earlier run this one continues (continue, fix, answer, a person's
2966
+ * message): the daemon works on in that run's worktree, on this run's
2967
+ * branch, so nothing the earlier run left uncommitted is lost.
2968
+ */
2969
+ continuesRunId: id.optional(),
2970
+ /**
2971
+ * The latest checkpoint of the attempt this run takes over after its
2972
+ * machine went offline. Used only for a new worktree (another machine, or
2973
+ * the earlier worktree is gone): it starts at `baseCommit` (the base
2974
+ * branch when that commit is not here) with the patch applied.
2975
+ */
2976
+ resumeFrom: runCheckpointSchema.optional(),
2977
+ /**
2978
+ * The harness session to continue. A daemon that cannot resume starts a
2979
+ * new session with `prompt`, which always carries the full brief.
2980
+ */
2981
+ resumeSessionId: z13.string().max(500).optional(),
2982
+ requireSessionResume: z13.boolean().optional(),
2983
+ preserveQuestionWorktree: z13.boolean().optional(),
2984
+ questionId: z13.uuid().optional(),
2985
+ /**
2986
+ * What this run adds on top of the brief (a person's message, an answer,
2987
+ * a fix request). A resumed session gets only this as its next message;
2988
+ * a new session gets `prompt`, which already includes it.
2989
+ */
2990
+ followUp: z13.string().max(1e5).optional(),
2991
+ /**
2992
+ * The workspace's agent permissions and network allow-list (ADR 0028).
2993
+ * Absent from an older server: the daemon applies the ADR 0009 defaults.
2994
+ */
2995
+ policy: runPolicySchema.optional(),
2996
+ /** Trusted server revision for the exact run policy; older servers omit it. */
2997
+ policyRevision: z13.string().regex(/^[a-f0-9]{64}$/).optional(),
2998
+ /**
2999
+ * The skills mounted on this run's agent and still enabled, resolved at
3000
+ * claim time the way `policy` is. The daemon inlines them into the agent's
3001
+ * brief and writes them under the run's directory. Absent from an older
3002
+ * server: the run simply has none.
3003
+ */
3004
+ skills: z13.array(runSkillSchema).max(MAX_SKILLS_PER_RUN).optional(),
3005
+ /** Server-minted assignment provenance; does not grant any policy permission. */
3006
+ skillReceipt: skillAssignmentReceiptSchema.optional(),
3007
+ /** Frozen by the server benchmark ledger; never extracted from model output. */
3008
+ benchmark: runBenchmarkContext.optional()
3009
+ });
3010
+ var runPatchSchema = z13.object({
3011
+ state: z13.enum([
3012
+ "queued",
3013
+ "preparing",
3014
+ "running",
3015
+ "waiting_input",
3016
+ "finishing",
3017
+ "succeeded",
3018
+ "stopped",
3019
+ "failed",
3020
+ "cancelled"
3021
+ ]),
3022
+ sessionId: z13.string().max(500).nullable().optional(),
3023
+ worktree: z13.string().max(4e3).nullable().optional(),
3024
+ error: z13.string().max(1e4).nullable().optional(),
3025
+ /** Set on every terminal state. */
3026
+ stopReason: runStopReason.optional()
3027
+ });
3028
+ var runEventBatchSchema = z13.object({
3029
+ fromSeq: z13.number().int().min(1),
3030
+ chunks: z13.array(z13.looseObject({ type: z13.string() })).min(1).max(1e3)
3031
+ });
3032
+ var runEventsAccepted = z13.object({
3033
+ /** Producer seq of the last chunk the server holds for this run. */
3034
+ offset: z13.string()
3035
+ });
3036
+ var runCommandSchema = z13.discriminatedUnion("kind", [
3037
+ z13.object({
3038
+ kind: z13.literal("input"),
3039
+ runId: id,
3040
+ messageId: z13.uuid(),
3041
+ text: z13.string().min(1).max(1e5)
3042
+ }),
3043
+ z13.object({ kind: z13.literal("stop"), runId: id })
3044
+ ]);
3045
+ var runCommandsResponse = z13.object({
3046
+ commands: z13.array(runCommandSchema).max(500)
3047
+ });
3048
+ var runCommandsAck = z13.object({
3049
+ delivered: z13.array(z13.uuid()).max(500)
3050
+ });
3051
+ var FS_MAX_ENTRIES = 500;
3052
+ var fsBrowseRequest = z13.object({
3053
+ /** Absolute path on the device; omitted: the device's home folder. */
3054
+ path: z13.string().trim().min(1).max(4e3).optional(),
3055
+ showHidden: z13.boolean().optional()
3056
+ });
3057
+ var fsPendingRequest = fsBrowseRequest.extend({ id: z13.uuid() });
3058
+ var fsRequestsResponse = z13.object({
3059
+ requests: z13.array(fsPendingRequest).max(50)
3060
+ });
3061
+ var fsEntry = z13.object({
3062
+ name: z13.string().max(1e3),
3063
+ path: z13.string().max(4e3),
3064
+ /** The folder is the top level of a git repo (it has a `.git`). */
3065
+ isRepo: z13.boolean()
3066
+ });
3067
+ var fsListing = z13.object({
3068
+ ok: z13.literal(true),
3069
+ path: z13.string().max(4e3),
3070
+ /** Null at the filesystem root. */
3071
+ parent: z13.string().max(4e3).nullable(),
3072
+ home: z13.string().max(4e3),
3073
+ /** `darwin`, `linux`, `win32`: for path separators and wording. */
3074
+ platform: z13.string().max(50),
3075
+ entries: z13.array(fsEntry).max(FS_MAX_ENTRIES),
3076
+ /** More folders existed than `FS_MAX_ENTRIES`. */
3077
+ truncated: z13.boolean(),
3078
+ /**
3079
+ * The git repo `path` is in, if any: its top level and `origin` (or the
3080
+ * first remote). This is what `device.addRepo` should be given.
3081
+ */
3082
+ repo: z13.object({
3083
+ path: z13.string().max(4e3),
3084
+ remoteUrl: z13.string().max(2e3).nullable()
3085
+ }).nullable()
3086
+ });
3087
+ var FS_ERROR_CODES = [
3088
+ "not_found",
3089
+ "not_a_directory",
3090
+ "denied",
3091
+ "failed"
3092
+ ];
3093
+ var fsFailure = z13.object({
3094
+ ok: z13.literal(false),
3095
+ code: z13.enum(FS_ERROR_CODES),
3096
+ message: z13.string().max(1e3)
3097
+ });
3098
+ var fsResult = z13.discriminatedUnion("ok", [fsListing, fsFailure]);
3099
+
3100
+ // ../protocol/src/orchestrator.ts
3101
+ import { z as z14 } from "zod";
3102
+ var minutes = (n) => n * 6e4;
3103
+ var orchestratorSettingsSchema = z14.object({
3104
+ /** "Continue" prompts after a turn ended without a submit. */
3105
+ maxContinuations: z14.number().int().min(0).max(20).default(3),
3106
+ /** Resumes after the CLI crashed, before one fresh session. */
3107
+ maxCrashRetries: z14.number().int().min(0).max(20).default(3),
3108
+ /** Fix rounds after the daemon's verify failed. */
3109
+ maxFixAttempts: z14.number().int().min(0).max(20).default(3),
3110
+ /** "You seem stuck" prompts after a run stalled. */
3111
+ maxStallRecoveries: z14.number().int().min(0).max(20).default(2),
3112
+ /** No progress for this long while the lease is fresh = stalled. */
3113
+ stalledAfterMs: z14.number().int().min(minutes(1)).default(minutes(10)),
3114
+ /** A device offline this long is handed to a person (no auto switch). */
3115
+ deviceOfflineEscalateMs: z14.number().int().min(0).default(minutes(30)),
3116
+ /** An unanswered question frees its concurrency slot after this. */
3117
+ questionSlotReleaseMs: z14.number().int().min(0).default(minutes(24 * 60)),
3118
+ /** Automatic dispatches per issue per hour before a person looks. */
3119
+ maxDispatchesPerHour: z14.number().int().min(1).max(100).default(6),
3120
+ /** Wait before resuming a run that hit its quota (no reset time known). */
3121
+ quotaBackoffMs: z14.number().int().min(0).default(minutes(15)),
3122
+ /**
3123
+ * How often an issue waiting on its pull request or CI asks GitHub again
3124
+ * when no webhook arrived (ADR 0024).
3125
+ */
3126
+ ciRecheckMs: z14.number().int().min(3e4).default(minutes(2)),
3127
+ /** A pushed commit with no checks after this long has no CI: it passes. */
3128
+ ciNoChecksMs: z14.number().int().min(0).default(minutes(5)),
3129
+ /** CI still running after this long goes to a person. */
3130
+ ciTimeoutMs: z14.number().int().min(minutes(5)).default(minutes(120)),
3131
+ /** Remote URL of the repo this project's issues run in. */
3132
+ repoUrl: z14.string().max(2e3).optional()
3133
+ });
3134
+ var CRASH_BACKOFF_MS = [1e4, 6e4, minutes(5)];
3135
+ var UPSTREAM_RECHECK_MS = minutes(5);
3136
+ var PERSON_WAIT_DETAIL_CODES = [
3137
+ "review",
3138
+ // The planner wrote a spec; a person approves it, then its split (ADR ORV-205).
3139
+ "plan_review",
3140
+ "question",
3141
+ "verify_failed",
3142
+ "no_verify_command",
3143
+ "no_submit",
3144
+ "stalled",
3145
+ "crashed",
3146
+ "blocked",
3147
+ "auth_expired",
3148
+ "device_offline",
3149
+ "agent_no_device",
3150
+ "no_repo",
3151
+ "repo_ambiguous",
3152
+ "no_criteria",
3153
+ "dispatch_loop",
3154
+ "manual_advance",
3155
+ "push_failed",
3156
+ "pr_failed",
3157
+ "pr_closed",
3158
+ "ci_failed",
3159
+ "ci_timeout",
3160
+ "acceptance_failed"
3161
+ ];
3162
+ var EXTERNAL_WAIT_DETAIL_CODES = [
3163
+ "pr_opening",
3164
+ "ci_pending",
3165
+ "upstream",
3166
+ "device_offline_recent",
3167
+ "capacity",
3168
+ "file_overlap",
3169
+ "retry_backoff",
3170
+ "quota"
3171
+ ];
3172
+ var WAIT_DETAIL_CODES = [
3173
+ ...PERSON_WAIT_DETAIL_CODES,
3174
+ ...EXTERNAL_WAIT_DETAIL_CODES
3175
+ ];
3176
+ var waitDetailSchema = z14.object({
3177
+ code: z14.enum(WAIT_DETAIL_CODES),
3178
+ params: z14.record(
3179
+ z14.string(),
3180
+ z14.union([
3181
+ z14.string(),
3182
+ z14.number(),
3183
+ z14.array(z14.string()),
3184
+ // `repo_ambiguous`: the repos a person can pick from.
3185
+ z14.array(z14.record(z14.string(), z14.string()))
3186
+ ])
3187
+ ).optional()
3188
+ });
3189
+ var prChecksSchema = z14.object({
3190
+ state: z14.enum(["pending", "success", "failure", "none"]),
3191
+ /** Failed checks, for the fix round's brief and the issue page. */
3192
+ failing: z14.array(
3193
+ z14.object({
3194
+ name: z14.string().max(500),
3195
+ summary: z14.string().max(4e3).optional(),
3196
+ url: z14.string().max(2e3).optional()
3197
+ })
3198
+ ).max(50),
3199
+ total: z14.number().int().min(0)
3200
+ });
3201
+ var DEFAULT_BRANCH_TEMPLATE = "mikka/{team}-{number}";
3202
+ var BRANCH_FORBIDDEN = /[\s~^:?*[\\]|\.\.|@\{|\/\/|^\/|\/$/;
3203
+ var BRANCH_FORBIDDEN_HINT = "No spaces or ~ ^ : ? * [ \\ .. @{ //, and no leading or trailing /.";
3204
+ var hasControlCharacter = (value) => [...value].some((char) => {
3205
+ const code = char.charCodeAt(0);
3206
+ return code < 32 || code === 127;
3207
+ });
3208
+ var branchTemplateSchema = z14.string().trim().min(1).max(200).refine((value) => value.includes("{number}"), {
3209
+ message: "The template must contain {number}."
3210
+ }).refine(
3211
+ (value) => !BRANCH_FORBIDDEN.test(value) && !hasControlCharacter(value),
3212
+ { message: BRANCH_FORBIDDEN_HINT }
3213
+ );
3214
+ var prBodyTemplateSchema = z14.string().max(2e4).nullable().optional();
3215
+ var REVIEW_CHECK_HARNESSES = [
3216
+ "claude_code",
3217
+ "codex",
3218
+ "cursor"
3219
+ ];
3220
+ var reviewRuleSchema = z14.object({
3221
+ /** In Review needs an open pull request for the issue's branch (ADR 0024). */
3222
+ requirePullRequest: z14.boolean().default(true),
3223
+ /** ... and green CI on it. Ignored when no pull request is required. */
3224
+ requireCi: z14.boolean().default(true),
3225
+ /**
3226
+ * The harness that must run the read-only check (ADR 0046). Null: any
3227
+ * second agent on the device. A configured harness the device does not run
3228
+ * means no check runs, exactly as if the device had no second agent.
3229
+ */
3230
+ checkHarness: z14.enum(REVIEW_CHECK_HARNESSES).nullable().default(null),
3231
+ branchTemplate: branchTemplateSchema.default(DEFAULT_BRANCH_TEMPLATE),
3232
+ /** `{key}`, `{title}` and `{summary}`; null keeps Mikka's default text. */
3233
+ prBodyTemplate: prBodyTemplateSchema.default(null)
3234
+ });
3235
+ var DEFAULT_REVIEW_RULE = reviewRuleSchema.parse({});
3236
+
3237
+ // ../protocol/src/platform.ts
3238
+ var NO_CAPABILITIES = Object.freeze({
3239
+ "app.info": false,
3240
+ "notifications.system": false,
3241
+ "notifications.badge": false,
3242
+ "device.localIdentity": false,
3243
+ "device.pickRepo": false,
3244
+ "quota.snapshot": false,
3245
+ "preview.scheme": false,
3246
+ "settings.local": false
3247
+ });
3248
+ var WEB_PLATFORM = Object.freeze({
3249
+ runtime: "web",
3250
+ bridge: null,
3251
+ capabilities: NO_CAPABILITIES
3252
+ });
3253
+
3254
+ // ../protocol/src/preview.ts
3255
+ import { z as z15 } from "zod";
3256
+ var PREVIEW_MAX_LENGTH = 5 * 1024 * 1024;
3257
+ var previewHtml = z15.string().max(PREVIEW_MAX_LENGTH);
3258
+ var DIRECTIVES = [
3259
+ "default-src 'none'",
3260
+ "script-src 'unsafe-inline'",
3261
+ "style-src 'unsafe-inline'",
3262
+ "img-src data: blob:",
3263
+ "font-src data:",
3264
+ "media-src data: blob:",
3265
+ "base-uri 'none'",
3266
+ "form-action 'none'"
3267
+ ];
3268
+ var PREVIEW_CSP_HEADER = ["sandbox allow-scripts", ...DIRECTIVES].join(
3269
+ "; "
3270
+ );
3271
+ var META = `<meta http-equiv="Content-Security-Policy" content="${DIRECTIVES.join("; ")}">`;
3272
+
3273
+ // ../protocol/src/profile.ts
3274
+ import { z as z16 } from "zod";
3275
+ var usernameSchema = z16.string().trim().min(3, "At least 3 characters.").max(32, "At most 32 characters.").regex(
3276
+ /^[a-z0-9][a-z0-9_-]*$/,
3277
+ "Start with a letter or digit; lowercase letters, digits, - and _ only."
3278
+ );
3279
+ var displayNameSchema = z16.string().trim().min(1, "A name is required.").max(80, "At most 80 characters.");
3280
+ var avatarUrlSchema = z16.url().max(2048).refine((value) => /^https?:\/\//.test(value), "Use an http(s) URL.");
3281
+ var AVATAR_MAX_BYTES = 5 * 1024 * 1024;
3282
+ var AVATAR_CONTENT_TYPES = [
3283
+ "image/png",
3284
+ "image/jpeg",
3285
+ "image/webp",
3286
+ "image/gif"
3287
+ ];
3288
+ var avatarPresignRequest = z16.object({
3289
+ contentType: z16.enum(AVATAR_CONTENT_TYPES),
3290
+ /** Bytes, checked against AVATAR_MAX_BYTES. */
3291
+ size: z16.number().int().positive()
3292
+ });
3293
+ var avatarPresignResponse = z16.object({
3294
+ uploadUrl: z16.url(),
3295
+ /** What to store in `user.image` once the PUT has succeeded. */
3296
+ publicUrl: avatarUrlSchema,
3297
+ expiresIn: z16.number().int().positive()
3298
+ });
3299
+
3300
+ // ../protocol/src/relay.ts
3301
+ import {
3302
+ asSchema,
3303
+ safeValidateUIMessages,
3304
+ uiMessageChunkSchema
3305
+ } from "ai";
3306
+ import { z as z17 } from "zod";
3307
+ var RELAY_PROTOCOL_VERSION = 1;
3308
+ var MAX_INPUT_LENGTH = 2e4;
3309
+ var uuid = z17.uuid();
3310
+ var runEvent = z17.discriminatedUnion("kind", [
3311
+ /** One streaming chunk of the unfinished message `messageId`. */
3312
+ z17.object({
3313
+ kind: z17.literal("chunk"),
3314
+ messageId: uuid,
3315
+ chunk: z17.looseObject({ type: z17.string() })
3316
+ }),
3317
+ /** A finished message; persisted as a `message` row, then fanned out. */
3318
+ z17.object({
3319
+ kind: z17.literal("message.final"),
3320
+ /** Order of the message within the run. */
3321
+ seq: z17.number().int().min(0),
3322
+ message: z17.looseObject({
3323
+ id: uuid,
3324
+ role: z17.enum(["system", "user", "assistant"]),
3325
+ parts: z17.array(z17.looseObject({ type: z17.string() }))
3326
+ })
3327
+ }),
3328
+ z17.object({
3329
+ kind: z17.literal("run.status"),
3330
+ status: z17.enum([
3331
+ "queued",
3332
+ "preparing",
3333
+ "running",
3334
+ "waiting_input",
3335
+ "finishing",
3336
+ "succeeded",
3337
+ "failed",
3338
+ "cancelled"
3339
+ ])
3340
+ })
3341
+ ]);
3342
+ var chunkSchema = asSchema(uiMessageChunkSchema);
3343
+ var v = z17.literal(RELAY_PROTOCOL_VERSION);
3344
+ var presenceView = z17.discriminatedUnion("type", [
3345
+ z17.object({ type: z17.literal("issue"), id: uuid }),
3346
+ z17.object({ type: z17.literal("project"), id: uuid })
3347
+ ]);
3348
+ var relayClientMessage = z17.discriminatedUnion("type", [
3349
+ z17.object({
3350
+ v,
3351
+ type: z17.literal("subscribe"),
3352
+ runId: uuid,
3353
+ /** Resume after this seq; omitted = everything still buffered. */
3354
+ after: z17.number().int().min(0).optional()
3355
+ }),
3356
+ z17.object({ v, type: z17.literal("unsubscribe"), runId: uuid }),
3357
+ z17.object({ v, type: z17.literal("publish"), runId: uuid, event: runEvent }),
3358
+ /**
3359
+ * A person's message to the running agent (ADR 0018). Saved as a `user`
3360
+ * message row with this id (a re-send with the same id is applied once),
3361
+ * then handed to the run's daemon, which marks it delivered.
3362
+ */
3363
+ z17.object({
3364
+ v,
3365
+ type: z17.literal("send"),
3366
+ runId: uuid,
3367
+ messageId: uuid,
3368
+ text: z17.string().trim().min(1).max(MAX_INPUT_LENGTH)
3369
+ }),
3370
+ /** A person stops the run; the daemon cancels the agent's session. */
3371
+ z17.object({ v, type: z17.literal("stop"), runId: uuid }),
3372
+ /**
3373
+ * Says where this connection is looking, in one workspace (ADR 0049). Sent
3374
+ * once when a page opens and again every `PRESENCE_HEARTBEAT_MS`; `view`
3375
+ * null keeps the member online without naming a page. Never persisted.
3376
+ */
3377
+ z17.object({
3378
+ v,
3379
+ type: z17.literal("presence"),
3380
+ workspaceId: uuid,
3381
+ view: presenceView.nullable()
3382
+ }),
3383
+ /** Stops announcing in a workspace; the member leaves its viewer list. */
3384
+ z17.object({ v, type: z17.literal("presence.leave"), workspaceId: uuid })
3385
+ ]);
3386
+ var RELAY_ERROR_CODES = [
3387
+ "bad_message",
3388
+ "unauthorized",
3389
+ "forbidden",
3390
+ "update_required",
3391
+ "rate_limited",
3392
+ "persist_failed",
3393
+ /** `send` / `stop` to a run that is not active (queued or ended). */
3394
+ "run_not_active",
3395
+ /** `presence` for a workspace the caller is not a member of (ADR 0049). */
3396
+ "not_a_member"
3397
+ ];
3398
+ var relayErrorCode = z17.enum(RELAY_ERROR_CODES);
3399
+ var relayServerMessage = z17.discriminatedUnion("type", [
3400
+ z17.object({
3401
+ v,
3402
+ type: z17.literal("subscribed"),
3403
+ runId: uuid,
3404
+ latestSeq: z17.number().int().min(0)
3405
+ }),
3406
+ z17.object({
3407
+ v,
3408
+ type: z17.literal("event"),
3409
+ runId: uuid,
3410
+ seq: z17.number().int().min(1),
3411
+ event: runEvent
3412
+ }),
3413
+ /**
3414
+ * `send` / `stop` was saved and is on its way to the run's device.
3415
+ * `messageId` is set for `send`.
3416
+ */
3417
+ z17.object({
3418
+ v,
3419
+ type: z17.literal("accepted"),
3420
+ runId: uuid,
3421
+ request: z17.enum(["send", "stop"]),
3422
+ messageId: uuid.optional()
3423
+ }),
3424
+ /** Publisher acknowledgment with the seq the hub assigned. */
3425
+ z17.object({
3426
+ v,
3427
+ type: z17.literal("ack"),
3428
+ runId: uuid,
3429
+ seq: z17.number().int().min(1)
3430
+ }),
3431
+ /**
3432
+ * Everyone the server sees online in this workspace, and where each is
3433
+ * looking (ADR 0049). A snapshot after every change, so a client never has
3434
+ * to merge deltas; `lastSeenAt` is the server's clock.
3435
+ */
3436
+ z17.object({
3437
+ v,
3438
+ type: z17.literal("presence"),
3439
+ workspaceId: uuid,
3440
+ members: z17.array(
3441
+ z17.object({
3442
+ userId: uuid,
3443
+ view: presenceView.nullable(),
3444
+ lastSeenAt: z17.number().int()
3445
+ })
3446
+ )
3447
+ }),
3448
+ z17.object({
3449
+ v,
3450
+ type: z17.literal("error"),
3451
+ code: relayErrorCode,
3452
+ message: z17.string(),
3453
+ runId: uuid.optional(),
3454
+ minVersion: z17.string().optional()
3455
+ })
3456
+ ]);
3457
+
3458
+ // ../protocol/src/version.ts
3459
+ var import_semver = __toESM(require_semver2(), 1);
3460
+ import { z as z18 } from "zod";
3461
+ var CLIENT_VERSION_HEADER = "x-mikka-client-version";
3462
+ var CLIENT_KINDS = ["desktop", "mobile"];
3463
+ var clientKind = z18.enum(CLIENT_KINDS);
3464
+ var updateRequiredError = z18.object({
3465
+ error: z18.literal("update_required"),
3466
+ minVersion: z18.string(),
3467
+ message: z18.string()
3468
+ });
3469
+
3470
+ // ../protocol/src/coordinator.ts
3471
+ import { z as z19 } from "zod";
3472
+ var coordinatorRuntimeSchema = z19.discriminatedUnion("harness", [
3473
+ z19.object({ harness: z19.literal("ai_sdk") }).strict(),
3474
+ z19.object({ harness: z19.enum(["claude_code", "codex"]), deviceId: z19.uuid(), model: z19.string().trim().min(1).max(120).optional() }).strict()
3475
+ ]);
3476
+ var coordinatorToolSpecSchema = z19.object({
3477
+ name: z19.string().regex(/^[A-Za-z][A-Za-z0-9_]{0,63}$/),
3478
+ description: z19.string().max(2e4),
3479
+ inputSchema: z19.record(z19.string(), z19.unknown())
3480
+ });
3481
+ var nativeCoordinatorJobSchema = z19.object({
3482
+ id: z19.uuid(),
3483
+ harness: z19.enum(["claude_code", "codex"]),
3484
+ model: z19.string().optional(),
3485
+ instructions: z19.string().min(1).max(2e5),
3486
+ context: z19.string().min(1).max(5e5),
3487
+ tools: z19.array(coordinatorToolSpecSchema).max(100),
3488
+ expiresAt: z19.iso.datetime()
3489
+ });
3490
+ var nativeCoordinatorClaimSchema = z19.object({ job: nativeCoordinatorJobSchema.nullable() });
3491
+ var nativeCoordinatorCommandSchema = z19.discriminatedUnion("type", [
3492
+ z19.object({ type: z19.literal("tool"), callId: z19.string().min(1).max(200), name: z19.string().min(1).max(64), input: z19.record(z19.string(), z19.unknown()) }).strict(),
3493
+ z19.object({ type: z19.literal("complete"), text: z19.string().min(1).max(2e5).refine((value) => value.trim().length > 0) }).strict(),
3494
+ z19.object({ type: z19.literal("failed") }).strict()
3495
+ ]);
3496
+ var nativeCoordinatorToolResultSchema = z19.discriminatedUnion("status", [
3497
+ z19.object({ status: z19.literal("pending") }),
3498
+ z19.object({ status: z19.literal("done"), output: z19.unknown() })
3499
+ ]);
3500
+
3501
+ // ../protocol/src/computer.ts
3502
+ import { z as z20 } from "zod";
3503
+ var machineStateSchema = z20.enum(["sleeping", "waking", "running", "error"]);
3504
+ var controlStateSchema = z20.enum(["agent", "user", "idle"]);
3505
+ var computerToolSchema = z20.enum(["click", "type", "key", "scroll", "screenshot"]);
3506
+ var screenRectSchema = z20.object({ x: z20.number(), y: z20.number(), w: z20.number().nonnegative(), h: z20.number().nonnegative() });
3507
+ var computerActionSchema = z20.object({ tool: computerToolSchema, x: z20.number().optional(), y: z20.number().optional(), text: z20.string().optional(), rect: screenRectSchema.optional() });
3508
+ var lastActionSchema = computerActionSchema.omit({ text: true }).extend({ at: z20.iso.datetime() });
3509
+ var approvalViewSchema = z20.object({
3510
+ id: z20.string(),
3511
+ digest: z20.string(),
3512
+ runId: z20.string(),
3513
+ botId: z20.string(),
3514
+ action: computerActionSchema,
3515
+ summary: z20.string(),
3516
+ expiresAt: z20.iso.datetime()
3517
+ });
3518
+ var computerStateSchema = z20.object({
3519
+ machine: machineStateSchema,
3520
+ control: controlStateSchema,
3521
+ controlledBy: z20.object({ userId: z20.string() }).optional(),
3522
+ lastAction: lastActionSchema.optional(),
3523
+ pendingApproval: approvalViewSchema.optional()
3524
+ });
3525
+ var viewerModeSchema = z20.enum(["view", "control"]);
3526
+ var viewerRequestSchema = z20.object({ mode: viewerModeSchema }).strict();
3527
+ var viewerGrantSchema = z20.object({ url: z20.url({ protocol: /^wss$/ }), expiresAt: z20.iso.datetime() });
3528
+ var createBotSchema = z20.object({ name: z20.string().trim().min(1).max(120) }).strict();
3529
+ var botViewSchema = z20.object({ id: z20.uuid(), name: z20.string().min(1).max(120) });
3530
+ var approvalDecisionSchema = z20.object({ digest: z20.string(), decision: z20.enum(["approve", "deny"]), scope: z20.enum(["once", "run"]) }).strict();
3531
+ var computerTaskStateSchema = z20.enum(["working", "approval", "done", "failed"]);
3532
+ var computerTaskSchema = z20.object({ botId: z20.string(), runId: z20.string(), task: z20.string(), state: computerTaskStateSchema, approvalId: z20.string().optional() });
3533
+ var computerEventSchema = z20.discriminatedUnion("type", [
3534
+ z20.object({ type: z20.literal("computer.machine"), state: machineStateSchema }),
3535
+ z20.object({ type: z20.literal("computer.control"), botId: z20.string(), control: controlStateSchema, controlledBy: z20.object({ userId: z20.string() }).optional() }),
3536
+ z20.object({ type: z20.literal("computer.action"), botId: z20.string(), lastAction: lastActionSchema }),
3537
+ z20.object({ type: z20.literal("computer.approval"), botId: z20.string(), approval: approvalViewSchema.nullable() })
3538
+ ]);
3539
+ var reviewDigestSchema = z20.string().regex(/^[a-f0-9]{64}$/);
3540
+ var localComputerCall = z20.discriminatedUnion("name", [
3541
+ z20.object({ name: z20.literal("get_desktop_state"), arguments: z20.object({}).strict() }).strict(),
3542
+ z20.object({ name: z20.literal("click"), arguments: z20.object({ x: z20.number().int().min(0).max(1e5), y: z20.number().int().min(0).max(1e5) }).strict() }).strict(),
3543
+ z20.object({ name: z20.literal("type_text"), arguments: z20.object({ text: z20.string().min(1).max(8e3) }).strict() }).strict(),
3544
+ z20.object({ name: z20.literal("press_key"), arguments: z20.object({
3545
+ key: z20.string().regex(/^(?:[\x20-\x7e]|enter|return|tab|escape|space|backspace|delete|insert|home|end|pageup|pagedown|up|down|left|right|f(?:[1-9]|1[0-2]))$/),
3546
+ modifiers: z20.array(z20.enum(["ctrl", "shift", "alt", "super"])).max(4).refine((items) => new Set(items).size === items.length).optional()
3547
+ }).strict() }).strict(),
3548
+ z20.object({ name: z20.literal("scroll"), arguments: z20.object({ direction: z20.enum(["up", "down", "left", "right"]), amount: z20.number().int().min(1).max(50), x: z20.number().int().min(0).max(1e5), y: z20.number().int().min(0).max(1e5) }).strict() }).strict()
3549
+ ]);
3550
+ var localComputerRequest = z20.object({
3551
+ id: z20.uuid(),
3552
+ runId: z20.uuid(),
3553
+ target: reviewDigestSchema,
3554
+ display: z20.string().regex(/^:[1-9][0-9]{0,2}$/).optional(),
3555
+ call: localComputerCall,
3556
+ expiresAt: z20.number().int().positive(),
3557
+ digest: reviewDigestSchema
3558
+ }).strict();
3559
+ var localComputerDecision = z20.object({ id: z20.uuid(), digest: reviewDigestSchema, approve: z20.boolean() }).strict();
3560
+ var computerSyncBody = z20.object({ requests: z20.array(localComputerRequest).max(20) }).strict();
3561
+ var computerSyncResponse = z20.object({ decisions: z20.array(localComputerDecision).max(20) }).strict();
3562
+
3563
+ // ../protocol/src/subscription.ts
3564
+ import { z as z21 } from "zod";
3565
+ var id2 = z21.string().min(1).max(128);
3566
+ var subscriptionRouteSchema = z21.enum([
3567
+ "codex_cli",
3568
+ "claude_code_cli",
3569
+ "codex_cpa",
3570
+ "claude_cpa",
3571
+ "openai_siwc"
3572
+ ]);
3573
+ var subscriptionConnectionSchema = z21.object({
3574
+ id: id2,
3575
+ ownerId: id2,
3576
+ workspaceId: id2,
3577
+ provider: z21.enum(["openai", "anthropic"]),
3578
+ state: z21.enum([
3579
+ "pending",
3580
+ "connected",
3581
+ "reconnect_required",
3582
+ "disconnected"
3583
+ ]),
3584
+ // Increment on reconnect/disconnect. Old bindings cannot become valid again.
3585
+ revision: z21.number().int().positive(),
3586
+ quota: quotaSnapshotSchema
3587
+ }).strict();
3588
+ var subscriptionBindingSchema = z21.object({
3589
+ id: id2,
3590
+ ownerId: id2,
3591
+ workspaceId: id2,
3592
+ // An agent or assistant session selected explicitly by the owner.
3593
+ consumerId: id2,
3594
+ connectionId: id2,
3595
+ connectionRevision: z21.number().int().positive(),
3596
+ route: subscriptionRouteSchema
3597
+ }).strict();
3598
+ var nativeBrokerContextSchema = z21.object({
3599
+ route: z21.enum(["codex_cli", "claude_code_cli"]),
3600
+ modelId: z21.string().min(1).max(128),
3601
+ revision: z21.number().int().positive(),
3602
+ accountId: z21.string().min(1).max(512),
3603
+ plan: z21.string().max(40).optional(),
3604
+ expiresAt: z21.iso.datetime()
3605
+ }).strict();
3606
+
3607
+ // src/login.ts
3608
+ import { z as z26 } from "zod";
3609
+
3610
+ // src/errors.ts
3611
+ var DaemonError = class extends Error {
3612
+ constructor(code, message, data) {
3613
+ super(message);
3614
+ this.code = code;
3615
+ this.data = data;
3616
+ this.name = "DaemonError";
3617
+ }
3618
+ code;
3619
+ data;
3620
+ };
3621
+ var ServerUnreachableError = class extends DaemonError {
3622
+ constructor(cause) {
3623
+ super(DAEMON_RPC_ERRORS.serverUnreachable, "Server unreachable");
3624
+ this.cause = cause;
3625
+ }
3626
+ };
3627
+
3628
+ // package.json
3629
+ var package_default = {
3630
+ name: "@mikka/daemon",
3631
+ version: "0.0.3",
3632
+ description: "Local Mikka daemon: runs agents through the user's own CLIs",
3633
+ type: "module",
3634
+ private: true,
3635
+ license: "AGPL-3.0-only",
3636
+ bin: {
3637
+ mikka: "./dist/mikka.js"
3638
+ },
3639
+ exports: {
3640
+ ".": "./src/main.ts",
3641
+ "./cli": "./src/cli.ts",
3642
+ "./client": "./src/rpc/client.ts",
3643
+ "./env": "./src/env.ts",
3644
+ "./paths": "./src/paths.ts",
3645
+ "./http-link": "./src/server-link-http.ts",
3646
+ "./login": "./src/login.ts",
3647
+ "./log": "./src/log.ts",
3648
+ "./sandbox": "./src/agents/sandbox.ts",
3649
+ "./coordinator": "./src/coordinator/index.ts"
3650
+ },
3651
+ scripts: {
3652
+ daemon: "tsx bin/mikka.ts daemon",
3653
+ dev: "tsx watch bin/mikka.ts daemon --dev --server memory",
3654
+ typecheck: "tsgo --noEmit -p tsconfig.json",
3655
+ test: "vitest run && pnpm test:mailbox-cli && pnpm test:repository-identity",
3656
+ "test:mailbox-cli": "node --import tsx --test --test-timeout=60000 test/run-mailbox.node-test.ts",
3657
+ "codex:types": 'codex app-server generate-ts --out "${TMPDIR:-/tmp}/mikka-codex-types" && echo "Generated; compare v2/ with src/adapters/codex-protocol.ts"',
3658
+ "test:real": "MIKKA_REAL_AGENTS=${MIKKA_REAL_AGENTS:-claude_code,codex,cursor} vitest run test/real-agents.test.ts",
3659
+ "test:changed": "vitest run --changed origin/main --passWithNoTests",
3660
+ build: "node scripts/build.mjs",
3661
+ "test:package": "node --test test/package.test.mjs",
3662
+ "test:repository-identity": "node --experimental-strip-types --test test/repository-identity-pure.node-test.ts"
3663
+ },
3664
+ dependencies: {
3665
+ "@agentclientprotocol/sdk": "1.9.0",
3666
+ "@anthropic-ai/claude-agent-sdk": "^0.3.305",
3667
+ "@anthropic-ai/sandbox-runtime": "0.0.80",
3668
+ "@mikka/protocol": "workspace:*",
3669
+ ai: "7.0.142",
3670
+ execa: "10.1.1",
3671
+ pino: "10.4.0",
3672
+ "proper-lockfile": "4.1.2",
3673
+ "rotating-file-stream": "3.2.10",
3674
+ "simple-git": "4.0.2",
3675
+ "vscode-jsonrpc": "9.0.3",
3676
+ zod: "4.6.7"
3677
+ },
3678
+ devDependencies: {
3679
+ "@mikka/config": "workspace:*",
3680
+ "@types/node": "24.19.2",
3681
+ "@types/proper-lockfile": "4.1.4",
3682
+ tsx: "4.23.15",
3683
+ esbuild: "0.28.2",
3684
+ vitest: "5.0.5"
3685
+ },
3686
+ engines: {
3687
+ node: ">=24"
3688
+ },
3689
+ gitHead: "4d1f09bda63e1b86a6cf08c4c7f4dc159b2938a2"
3690
+ };
3691
+
3692
+ // src/paths.ts
3693
+ var DAEMON_VERSION = package_default.version;
3694
+
3695
+ // src/server-link-http.ts
3696
+ import { z as z25 } from "zod";
3697
+
3698
+ // ../protocol/src/capture.ts
3699
+ import { z as z22 } from "zod";
3700
+ var CAPTURE_CONTENT_TYPES = [
3701
+ "image/png",
3702
+ "image/jpeg",
3703
+ "image/webp",
3704
+ "video/mp4",
3705
+ "video/webm"
3706
+ ];
3707
+ var CAPTURE_KINDS = ["image", "video"];
3708
+ var CAPTURE_SOURCES = ["cloud_computer", "local"];
3709
+ var CAPTURE_MAX_BYTES = {
3710
+ image: 1e7,
3711
+ video: 1e8
3712
+ };
3713
+ var RECORDING_MAX_SECONDS = 300;
3714
+ var CAPTURE_TITLE_MAX = 200;
3715
+ var sha256 = z22.string().regex(/^[a-f0-9]{64}$/);
3716
+ var title = z22.string().trim().min(1).max(CAPTURE_TITLE_MAX);
3717
+ var captureUploadRequest = z22.object({
3718
+ /** Stable client id, persisted before the first network attempt. */
3719
+ captureId: z22.uuid().optional(),
3720
+ title,
3721
+ contentType: z22.enum(CAPTURE_CONTENT_TYPES),
3722
+ size: z22.number().int().min(1).max(CAPTURE_MAX_BYTES.video),
3723
+ sha256
3724
+ }).strict();
3725
+ var captureUploadTarget = z22.discriminatedUnion("target", [
3726
+ z22.object({ target: z22.literal("storage"), url: z22.url({ protocol: /^https$/ }), headers: z22.record(z22.string(), z22.string()) }),
3727
+ z22.object({ target: z22.literal("server") })
3728
+ ]);
3729
+ var captureUploadResponse = z22.object({
3730
+ captureId: z22.uuid(),
3731
+ upload: captureUploadTarget
3732
+ });
3733
+ var captureView = z22.object({
3734
+ id: z22.uuid(),
3735
+ kind: z22.enum(CAPTURE_KINDS),
3736
+ contentType: z22.enum(CAPTURE_CONTENT_TYPES),
3737
+ title: z22.string(),
3738
+ size: z22.number().int().nonnegative(),
3739
+ durationMs: z22.number().int().nonnegative().nullable(),
3740
+ source: z22.enum(CAPTURE_SOURCES),
3741
+ createdAt: z22.iso.datetime()
3742
+ });
3743
+ var captureCompleteResponse = z22.object({ capture: captureView });
3744
+ var screenCaptureRequest = z22.discriminatedUnion("action", [
3745
+ z22.object({ action: z22.literal("screenshot"), title }).strict(),
3746
+ z22.object({ action: z22.literal("start_recording"), title, maxSeconds: z22.number().int().min(5).max(RECORDING_MAX_SECONDS).optional() }).strict(),
3747
+ z22.object({ action: z22.literal("stop_recording") }).strict()
3748
+ ]);
3749
+ var screenCaptureResponse = z22.discriminatedUnion("action", [
3750
+ z22.object({ action: z22.literal("screenshot"), capture: captureView }),
3751
+ z22.object({ action: z22.literal("start_recording"), recordingId: z22.uuid(), stopsAt: z22.iso.datetime() }),
3752
+ z22.object({ action: z22.literal("stop_recording"), capture: captureView })
3753
+ ]);
3754
+
3755
+ // src/run-mailbox.ts
3756
+ import { z as z24 } from "zod";
3757
+
3758
+ // ../protocol/src/mailbox.ts
3759
+ import { z as z23 } from "zod";
3760
+ var mailboxSend = z23.object({ to: z23.uuid(), key: z23.uuid().describe("Stable idempotency key; reuse only to retry this exact envelope."), text: z23.string().trim().min(1).max(4e3), replyTo: z23.uuid().optional() }).strict();
3761
+ var mailboxAck = z23.object({ ids: z23.array(z23.uuid()).max(50) }).strict();
3762
+ var mailboxInputs = {
3763
+ mailbox_recipients: z23.object({}).strict(),
3764
+ mailbox_send: mailboxSend,
3765
+ mailbox_inbox: z23.object({}).strict(),
3766
+ mailbox_ack: mailboxAck,
3767
+ mailbox_sent: z23.object({}).strict()
3768
+ };
3769
+
3770
+ // src/run-mailbox.ts
3771
+ var requestSchema = z24.union([
3772
+ z24.object({ operation: z24.literal("list") }).strict(),
3773
+ z24.object({ operation: z24.literal("call"), name: z24.enum(Object.keys(mailboxInputs)), arguments: z24.unknown() }).strict()
3774
+ ]);
3775
+
3776
+ // src/server-link-http.ts
3777
+ var deviceSessionRejection = z25.object({ error: z25.enum(["Unauthorized", "authRequired"]) }).strict();
3778
+ function serverUrl(base, path) {
3779
+ return new URL(`${base.replace(/\/+$/, "")}${path}`);
3780
+ }
3781
+
3782
+ // src/login.ts
3783
+ var DEVICE_CODE_PATH = `${AUTH_BASE_PATH}/device/code`;
3784
+ var DEVICE_TOKEN_PATH = `${AUTH_BASE_PATH}/device/token`;
3785
+ var DEVICE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
3786
+ var deviceCodeResponse = z26.object({
3787
+ device_code: z26.string().min(1),
3788
+ user_code: z26.string().min(1),
3789
+ verification_uri: z26.string(),
3790
+ verification_uri_complete: z26.string().optional(),
3791
+ expires_in: z26.number().positive(),
3792
+ interval: z26.number().positive().default(5)
3793
+ });
3794
+ var tokenResponse = z26.object({ access_token: z26.string().regex(/^orv_[A-Za-z0-9_-]{43}$/) });
3795
+ var errorResponse = z26.object({ error: z26.string() });
3796
+ var LoginError = class extends DaemonError {
3797
+ constructor(reason, message) {
3798
+ super(4003, message);
3799
+ this.reason = reason;
3800
+ }
3801
+ reason;
3802
+ };
3803
+ async function post(options, path, body) {
3804
+ const fetchImpl = options.fetchImpl ?? fetch;
3805
+ let response;
3806
+ try {
3807
+ response = await fetchImpl(serverUrl(options.serverUrl, path), {
3808
+ method: "POST",
3809
+ headers: {
3810
+ "content-type": "application/json",
3811
+ [CLIENT_VERSION_HEADER]: DAEMON_VERSION
3812
+ },
3813
+ body: JSON.stringify(body),
3814
+ signal: options.signal
3815
+ });
3816
+ } catch (error) {
3817
+ throw new ServerUnreachableError(error);
3818
+ }
3819
+ return {
3820
+ status: response.status,
3821
+ json: await response.json().catch(() => null)
3822
+ };
3823
+ }
3824
+ async function deviceLogin(options) {
3825
+ const sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
3826
+ const started = await post(options, DEVICE_CODE_PATH, {
3827
+ client_id: DAEMON_CLIENT_ID
3828
+ });
3829
+ const code = deviceCodeResponse.safeParse(started.json);
3830
+ if (started.status !== 200 || !code.success)
3831
+ throw new LoginError(
3832
+ "failed",
3833
+ `The server did not start a device login (${started.status}).`
3834
+ );
3835
+ options.prompt(code.data);
3836
+ let intervalMs = code.data.interval * 1e3;
3837
+ const deadline = Date.now() + code.data.expires_in * 1e3;
3838
+ while (Date.now() < deadline) {
3839
+ await sleep(intervalMs);
3840
+ if (options.signal?.aborted)
3841
+ throw new LoginError("failed", "Login cancelled.");
3842
+ const polled = await post(options, DEVICE_TOKEN_PATH, {
3843
+ grant_type: DEVICE_GRANT_TYPE,
3844
+ device_code: code.data.device_code,
3845
+ client_id: DAEMON_CLIENT_ID
3846
+ });
3847
+ const token = tokenResponse.safeParse(polled.json);
3848
+ if (polled.status === 200 && token.success) return token.data.access_token;
3849
+ const error = errorResponse.safeParse(polled.json);
3850
+ switch (error.success ? error.data.error : "") {
3851
+ case "authorization_pending":
3852
+ continue;
3853
+ case "slow_down":
3854
+ intervalMs += 5e3;
3855
+ continue;
3856
+ case "access_denied":
3857
+ throw new LoginError("access_denied", "The login was denied.");
3858
+ case "expired_token":
3859
+ throw new LoginError("expired_token", "The code expired; try again.");
3860
+ default:
3861
+ throw new LoginError(
3862
+ "failed",
3863
+ `Device login failed (${polled.status}${error.success ? `, ${error.data.error}` : ""}).`
3864
+ );
3865
+ }
3866
+ }
3867
+ throw new LoginError("expired_token", "The code expired; try again.");
3868
+ }
3869
+ async function registrationLogin(options) {
3870
+ if (!/^orv_[A-Za-z0-9_-]{43}$/.test(options.token)) throw new LoginError("failed", "Invalid registration token.");
3871
+ const response = await (options.fetchImpl ?? fetch)(serverUrl(options.serverUrl, "/v1/devices/enroll"), {
3872
+ method: "POST",
3873
+ headers: { authorization: `Bearer ${options.token}` },
3874
+ redirect: "error",
3875
+ signal: AbortSignal.timeout(3e4)
3876
+ });
3877
+ const body = await response.json().catch(() => null);
3878
+ const parsed = tokenResponse.safeParse({ access_token: body?.credential });
3879
+ if (!response.ok || !parsed.success) throw new LoginError("failed", "Device registration token expired or already used.");
3880
+ return parsed.data.access_token;
3881
+ }
3882
+ export {
3883
+ DEVICE_CODE_PATH,
3884
+ DEVICE_GRANT_TYPE,
3885
+ DEVICE_TOKEN_PATH,
3886
+ LoginError,
3887
+ deviceLogin,
3888
+ registrationLogin
3889
+ };