@vinihcrosa/lumem-os 0.1.0 → 0.2.0
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/README.md +19 -5
- package/bin/lumem.mjs +379 -166
- package/dist/server/main.mjs +1638 -483
- package/dist/web/assets/{codemirror-setup-Csmyc9rQ.js → codemirror-setup-qkhLO-HV.js} +1 -1
- package/dist/web/assets/index-BkIky5Mw.css +32 -0
- package/dist/web/assets/index-CKedNrvw.js +101 -0
- package/dist/web/index.html +2 -2
- package/drizzle/0012_modo_do_lumem.sql +55 -0
- package/drizzle/meta/0012_snapshot.json +1681 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +1 -1
- package/dist/web/assets/index-BlWx0v0O.js +0 -101
- package/dist/web/assets/index-jS7lSqBc.css +0 -32
package/bin/lumem.mjs
CHANGED
|
@@ -371,104 +371,104 @@ ZodError.create = (issues) => {
|
|
|
371
371
|
|
|
372
372
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.js
|
|
373
373
|
var errorMap = (issue, _ctx) => {
|
|
374
|
-
let
|
|
374
|
+
let message2;
|
|
375
375
|
switch (issue.code) {
|
|
376
376
|
case ZodIssueCode.invalid_type:
|
|
377
377
|
if (issue.received === ZodParsedType.undefined) {
|
|
378
|
-
|
|
378
|
+
message2 = "Required";
|
|
379
379
|
} else {
|
|
380
|
-
|
|
380
|
+
message2 = `Expected ${issue.expected}, received ${issue.received}`;
|
|
381
381
|
}
|
|
382
382
|
break;
|
|
383
383
|
case ZodIssueCode.invalid_literal:
|
|
384
|
-
|
|
384
|
+
message2 = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
|
|
385
385
|
break;
|
|
386
386
|
case ZodIssueCode.unrecognized_keys:
|
|
387
|
-
|
|
387
|
+
message2 = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
|
|
388
388
|
break;
|
|
389
389
|
case ZodIssueCode.invalid_union:
|
|
390
|
-
|
|
390
|
+
message2 = `Invalid input`;
|
|
391
391
|
break;
|
|
392
392
|
case ZodIssueCode.invalid_union_discriminator:
|
|
393
|
-
|
|
393
|
+
message2 = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
|
|
394
394
|
break;
|
|
395
395
|
case ZodIssueCode.invalid_enum_value:
|
|
396
|
-
|
|
396
|
+
message2 = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
|
|
397
397
|
break;
|
|
398
398
|
case ZodIssueCode.invalid_arguments:
|
|
399
|
-
|
|
399
|
+
message2 = `Invalid function arguments`;
|
|
400
400
|
break;
|
|
401
401
|
case ZodIssueCode.invalid_return_type:
|
|
402
|
-
|
|
402
|
+
message2 = `Invalid function return type`;
|
|
403
403
|
break;
|
|
404
404
|
case ZodIssueCode.invalid_date:
|
|
405
|
-
|
|
405
|
+
message2 = `Invalid date`;
|
|
406
406
|
break;
|
|
407
407
|
case ZodIssueCode.invalid_string:
|
|
408
408
|
if (typeof issue.validation === "object") {
|
|
409
409
|
if ("includes" in issue.validation) {
|
|
410
|
-
|
|
410
|
+
message2 = `Invalid input: must include "${issue.validation.includes}"`;
|
|
411
411
|
if (typeof issue.validation.position === "number") {
|
|
412
|
-
|
|
412
|
+
message2 = `${message2} at one or more positions greater than or equal to ${issue.validation.position}`;
|
|
413
413
|
}
|
|
414
414
|
} else if ("startsWith" in issue.validation) {
|
|
415
|
-
|
|
415
|
+
message2 = `Invalid input: must start with "${issue.validation.startsWith}"`;
|
|
416
416
|
} else if ("endsWith" in issue.validation) {
|
|
417
|
-
|
|
417
|
+
message2 = `Invalid input: must end with "${issue.validation.endsWith}"`;
|
|
418
418
|
} else {
|
|
419
419
|
util.assertNever(issue.validation);
|
|
420
420
|
}
|
|
421
421
|
} else if (issue.validation !== "regex") {
|
|
422
|
-
|
|
422
|
+
message2 = `Invalid ${issue.validation}`;
|
|
423
423
|
} else {
|
|
424
|
-
|
|
424
|
+
message2 = "Invalid";
|
|
425
425
|
}
|
|
426
426
|
break;
|
|
427
427
|
case ZodIssueCode.too_small:
|
|
428
428
|
if (issue.type === "array")
|
|
429
|
-
|
|
429
|
+
message2 = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
|
|
430
430
|
else if (issue.type === "string")
|
|
431
|
-
|
|
431
|
+
message2 = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
|
|
432
432
|
else if (issue.type === "number")
|
|
433
|
-
|
|
433
|
+
message2 = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
434
434
|
else if (issue.type === "bigint")
|
|
435
|
-
|
|
435
|
+
message2 = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
436
436
|
else if (issue.type === "date")
|
|
437
|
-
|
|
437
|
+
message2 = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
|
|
438
438
|
else
|
|
439
|
-
|
|
439
|
+
message2 = "Invalid input";
|
|
440
440
|
break;
|
|
441
441
|
case ZodIssueCode.too_big:
|
|
442
442
|
if (issue.type === "array")
|
|
443
|
-
|
|
443
|
+
message2 = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
|
|
444
444
|
else if (issue.type === "string")
|
|
445
|
-
|
|
445
|
+
message2 = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
|
|
446
446
|
else if (issue.type === "number")
|
|
447
|
-
|
|
447
|
+
message2 = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
448
448
|
else if (issue.type === "bigint")
|
|
449
|
-
|
|
449
|
+
message2 = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
450
450
|
else if (issue.type === "date")
|
|
451
|
-
|
|
451
|
+
message2 = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
|
|
452
452
|
else
|
|
453
|
-
|
|
453
|
+
message2 = "Invalid input";
|
|
454
454
|
break;
|
|
455
455
|
case ZodIssueCode.custom:
|
|
456
|
-
|
|
456
|
+
message2 = `Invalid input`;
|
|
457
457
|
break;
|
|
458
458
|
case ZodIssueCode.invalid_intersection_types:
|
|
459
|
-
|
|
459
|
+
message2 = `Intersection results could not be merged`;
|
|
460
460
|
break;
|
|
461
461
|
case ZodIssueCode.not_multiple_of:
|
|
462
|
-
|
|
462
|
+
message2 = `Number must be a multiple of ${issue.multipleOf}`;
|
|
463
463
|
break;
|
|
464
464
|
case ZodIssueCode.not_finite:
|
|
465
|
-
|
|
465
|
+
message2 = "Number must be finite";
|
|
466
466
|
break;
|
|
467
467
|
default:
|
|
468
|
-
|
|
468
|
+
message2 = _ctx.defaultError;
|
|
469
469
|
util.assertNever(issue);
|
|
470
470
|
}
|
|
471
|
-
return { message };
|
|
471
|
+
return { message: message2 };
|
|
472
472
|
};
|
|
473
473
|
var en_default = errorMap;
|
|
474
474
|
|
|
@@ -594,8 +594,8 @@ var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
|
594
594
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
|
|
595
595
|
var errorUtil;
|
|
596
596
|
(function(errorUtil2) {
|
|
597
|
-
errorUtil2.errToObj = (
|
|
598
|
-
errorUtil2.toString = (
|
|
597
|
+
errorUtil2.errToObj = (message2) => typeof message2 === "string" ? { message: message2 } : message2 || {};
|
|
598
|
+
errorUtil2.toString = (message2) => typeof message2 === "string" ? message2 : message2?.message;
|
|
599
599
|
})(errorUtil || (errorUtil = {}));
|
|
600
600
|
|
|
601
601
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
|
|
@@ -647,16 +647,16 @@ function processCreateParams(params) {
|
|
|
647
647
|
if (errorMap2)
|
|
648
648
|
return { errorMap: errorMap2, description };
|
|
649
649
|
const customMap = (iss, ctx) => {
|
|
650
|
-
const { message } = params;
|
|
650
|
+
const { message: message2 } = params;
|
|
651
651
|
if (iss.code === "invalid_enum_value") {
|
|
652
|
-
return { message:
|
|
652
|
+
return { message: message2 ?? ctx.defaultError };
|
|
653
653
|
}
|
|
654
654
|
if (typeof ctx.data === "undefined") {
|
|
655
|
-
return { message:
|
|
655
|
+
return { message: message2 ?? required_error ?? ctx.defaultError };
|
|
656
656
|
}
|
|
657
657
|
if (iss.code !== "invalid_type")
|
|
658
658
|
return { message: ctx.defaultError };
|
|
659
|
-
return { message:
|
|
659
|
+
return { message: message2 ?? invalid_type_error ?? ctx.defaultError };
|
|
660
660
|
};
|
|
661
661
|
return { errorMap: customMap, description };
|
|
662
662
|
}
|
|
@@ -782,14 +782,14 @@ var ZodType = class {
|
|
|
782
782
|
const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
|
|
783
783
|
return handleResult(ctx, result);
|
|
784
784
|
}
|
|
785
|
-
refine(check,
|
|
785
|
+
refine(check, message2) {
|
|
786
786
|
const getIssueProperties = (val) => {
|
|
787
|
-
if (typeof
|
|
788
|
-
return { message };
|
|
789
|
-
} else if (typeof
|
|
790
|
-
return
|
|
787
|
+
if (typeof message2 === "string" || typeof message2 === "undefined") {
|
|
788
|
+
return { message: message2 };
|
|
789
|
+
} else if (typeof message2 === "function") {
|
|
790
|
+
return message2(val);
|
|
791
791
|
} else {
|
|
792
|
-
return
|
|
792
|
+
return message2;
|
|
793
793
|
}
|
|
794
794
|
};
|
|
795
795
|
return this._refinement((val, ctx) => {
|
|
@@ -1325,11 +1325,11 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1325
1325
|
}
|
|
1326
1326
|
return { status: status.value, value: input.data };
|
|
1327
1327
|
}
|
|
1328
|
-
_regex(regex, validation,
|
|
1328
|
+
_regex(regex, validation, message2) {
|
|
1329
1329
|
return this.refinement((data) => regex.test(data), {
|
|
1330
1330
|
validation,
|
|
1331
1331
|
code: ZodIssueCode.invalid_string,
|
|
1332
|
-
...errorUtil.errToObj(
|
|
1332
|
+
...errorUtil.errToObj(message2)
|
|
1333
1333
|
});
|
|
1334
1334
|
}
|
|
1335
1335
|
_addCheck(check) {
|
|
@@ -1338,37 +1338,37 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1338
1338
|
checks: [...this._def.checks, check]
|
|
1339
1339
|
});
|
|
1340
1340
|
}
|
|
1341
|
-
email(
|
|
1342
|
-
return this._addCheck({ kind: "email", ...errorUtil.errToObj(
|
|
1341
|
+
email(message2) {
|
|
1342
|
+
return this._addCheck({ kind: "email", ...errorUtil.errToObj(message2) });
|
|
1343
1343
|
}
|
|
1344
|
-
url(
|
|
1345
|
-
return this._addCheck({ kind: "url", ...errorUtil.errToObj(
|
|
1344
|
+
url(message2) {
|
|
1345
|
+
return this._addCheck({ kind: "url", ...errorUtil.errToObj(message2) });
|
|
1346
1346
|
}
|
|
1347
|
-
emoji(
|
|
1348
|
-
return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(
|
|
1347
|
+
emoji(message2) {
|
|
1348
|
+
return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message2) });
|
|
1349
1349
|
}
|
|
1350
|
-
uuid(
|
|
1351
|
-
return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(
|
|
1350
|
+
uuid(message2) {
|
|
1351
|
+
return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message2) });
|
|
1352
1352
|
}
|
|
1353
|
-
nanoid(
|
|
1354
|
-
return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(
|
|
1353
|
+
nanoid(message2) {
|
|
1354
|
+
return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message2) });
|
|
1355
1355
|
}
|
|
1356
|
-
cuid(
|
|
1357
|
-
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(
|
|
1356
|
+
cuid(message2) {
|
|
1357
|
+
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message2) });
|
|
1358
1358
|
}
|
|
1359
|
-
cuid2(
|
|
1360
|
-
return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(
|
|
1359
|
+
cuid2(message2) {
|
|
1360
|
+
return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message2) });
|
|
1361
1361
|
}
|
|
1362
|
-
ulid(
|
|
1363
|
-
return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(
|
|
1362
|
+
ulid(message2) {
|
|
1363
|
+
return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message2) });
|
|
1364
1364
|
}
|
|
1365
|
-
base64(
|
|
1366
|
-
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(
|
|
1365
|
+
base64(message2) {
|
|
1366
|
+
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message2) });
|
|
1367
1367
|
}
|
|
1368
|
-
base64url(
|
|
1368
|
+
base64url(message2) {
|
|
1369
1369
|
return this._addCheck({
|
|
1370
1370
|
kind: "base64url",
|
|
1371
|
-
...errorUtil.errToObj(
|
|
1371
|
+
...errorUtil.errToObj(message2)
|
|
1372
1372
|
});
|
|
1373
1373
|
}
|
|
1374
1374
|
jwt(options) {
|
|
@@ -1398,8 +1398,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1398
1398
|
...errorUtil.errToObj(options?.message)
|
|
1399
1399
|
});
|
|
1400
1400
|
}
|
|
1401
|
-
date(
|
|
1402
|
-
return this._addCheck({ kind: "date", message });
|
|
1401
|
+
date(message2) {
|
|
1402
|
+
return this._addCheck({ kind: "date", message: message2 });
|
|
1403
1403
|
}
|
|
1404
1404
|
time(options) {
|
|
1405
1405
|
if (typeof options === "string") {
|
|
@@ -1415,14 +1415,14 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1415
1415
|
...errorUtil.errToObj(options?.message)
|
|
1416
1416
|
});
|
|
1417
1417
|
}
|
|
1418
|
-
duration(
|
|
1419
|
-
return this._addCheck({ kind: "duration", ...errorUtil.errToObj(
|
|
1418
|
+
duration(message2) {
|
|
1419
|
+
return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message2) });
|
|
1420
1420
|
}
|
|
1421
|
-
regex(regex,
|
|
1421
|
+
regex(regex, message2) {
|
|
1422
1422
|
return this._addCheck({
|
|
1423
1423
|
kind: "regex",
|
|
1424
1424
|
regex,
|
|
1425
|
-
...errorUtil.errToObj(
|
|
1425
|
+
...errorUtil.errToObj(message2)
|
|
1426
1426
|
});
|
|
1427
1427
|
}
|
|
1428
1428
|
includes(value, options) {
|
|
@@ -1433,46 +1433,46 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1433
1433
|
...errorUtil.errToObj(options?.message)
|
|
1434
1434
|
});
|
|
1435
1435
|
}
|
|
1436
|
-
startsWith(value,
|
|
1436
|
+
startsWith(value, message2) {
|
|
1437
1437
|
return this._addCheck({
|
|
1438
1438
|
kind: "startsWith",
|
|
1439
1439
|
value,
|
|
1440
|
-
...errorUtil.errToObj(
|
|
1440
|
+
...errorUtil.errToObj(message2)
|
|
1441
1441
|
});
|
|
1442
1442
|
}
|
|
1443
|
-
endsWith(value,
|
|
1443
|
+
endsWith(value, message2) {
|
|
1444
1444
|
return this._addCheck({
|
|
1445
1445
|
kind: "endsWith",
|
|
1446
1446
|
value,
|
|
1447
|
-
...errorUtil.errToObj(
|
|
1447
|
+
...errorUtil.errToObj(message2)
|
|
1448
1448
|
});
|
|
1449
1449
|
}
|
|
1450
|
-
min(minLength,
|
|
1450
|
+
min(minLength, message2) {
|
|
1451
1451
|
return this._addCheck({
|
|
1452
1452
|
kind: "min",
|
|
1453
1453
|
value: minLength,
|
|
1454
|
-
...errorUtil.errToObj(
|
|
1454
|
+
...errorUtil.errToObj(message2)
|
|
1455
1455
|
});
|
|
1456
1456
|
}
|
|
1457
|
-
max(maxLength,
|
|
1457
|
+
max(maxLength, message2) {
|
|
1458
1458
|
return this._addCheck({
|
|
1459
1459
|
kind: "max",
|
|
1460
1460
|
value: maxLength,
|
|
1461
|
-
...errorUtil.errToObj(
|
|
1461
|
+
...errorUtil.errToObj(message2)
|
|
1462
1462
|
});
|
|
1463
1463
|
}
|
|
1464
|
-
length(len,
|
|
1464
|
+
length(len, message2) {
|
|
1465
1465
|
return this._addCheck({
|
|
1466
1466
|
kind: "length",
|
|
1467
1467
|
value: len,
|
|
1468
|
-
...errorUtil.errToObj(
|
|
1468
|
+
...errorUtil.errToObj(message2)
|
|
1469
1469
|
});
|
|
1470
1470
|
}
|
|
1471
1471
|
/**
|
|
1472
1472
|
* Equivalent to `.min(1)`
|
|
1473
1473
|
*/
|
|
1474
|
-
nonempty(
|
|
1475
|
-
return this.min(1, errorUtil.errToObj(
|
|
1474
|
+
nonempty(message2) {
|
|
1475
|
+
return this.min(1, errorUtil.errToObj(message2));
|
|
1476
1476
|
}
|
|
1477
1477
|
trim() {
|
|
1478
1478
|
return new _ZodString({
|
|
@@ -1665,19 +1665,19 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1665
1665
|
}
|
|
1666
1666
|
return { status: status.value, value: input.data };
|
|
1667
1667
|
}
|
|
1668
|
-
gte(value,
|
|
1669
|
-
return this.setLimit("min", value, true, errorUtil.toString(
|
|
1668
|
+
gte(value, message2) {
|
|
1669
|
+
return this.setLimit("min", value, true, errorUtil.toString(message2));
|
|
1670
1670
|
}
|
|
1671
|
-
gt(value,
|
|
1672
|
-
return this.setLimit("min", value, false, errorUtil.toString(
|
|
1671
|
+
gt(value, message2) {
|
|
1672
|
+
return this.setLimit("min", value, false, errorUtil.toString(message2));
|
|
1673
1673
|
}
|
|
1674
|
-
lte(value,
|
|
1675
|
-
return this.setLimit("max", value, true, errorUtil.toString(
|
|
1674
|
+
lte(value, message2) {
|
|
1675
|
+
return this.setLimit("max", value, true, errorUtil.toString(message2));
|
|
1676
1676
|
}
|
|
1677
|
-
lt(value,
|
|
1678
|
-
return this.setLimit("max", value, false, errorUtil.toString(
|
|
1677
|
+
lt(value, message2) {
|
|
1678
|
+
return this.setLimit("max", value, false, errorUtil.toString(message2));
|
|
1679
1679
|
}
|
|
1680
|
-
setLimit(kind, value, inclusive,
|
|
1680
|
+
setLimit(kind, value, inclusive, message2) {
|
|
1681
1681
|
return new _ZodNumber({
|
|
1682
1682
|
...this._def,
|
|
1683
1683
|
checks: [
|
|
@@ -1686,7 +1686,7 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1686
1686
|
kind,
|
|
1687
1687
|
value,
|
|
1688
1688
|
inclusive,
|
|
1689
|
-
message: errorUtil.toString(
|
|
1689
|
+
message: errorUtil.toString(message2)
|
|
1690
1690
|
}
|
|
1691
1691
|
]
|
|
1692
1692
|
});
|
|
@@ -1697,68 +1697,68 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1697
1697
|
checks: [...this._def.checks, check]
|
|
1698
1698
|
});
|
|
1699
1699
|
}
|
|
1700
|
-
int(
|
|
1700
|
+
int(message2) {
|
|
1701
1701
|
return this._addCheck({
|
|
1702
1702
|
kind: "int",
|
|
1703
|
-
message: errorUtil.toString(
|
|
1703
|
+
message: errorUtil.toString(message2)
|
|
1704
1704
|
});
|
|
1705
1705
|
}
|
|
1706
|
-
positive(
|
|
1706
|
+
positive(message2) {
|
|
1707
1707
|
return this._addCheck({
|
|
1708
1708
|
kind: "min",
|
|
1709
1709
|
value: 0,
|
|
1710
1710
|
inclusive: false,
|
|
1711
|
-
message: errorUtil.toString(
|
|
1711
|
+
message: errorUtil.toString(message2)
|
|
1712
1712
|
});
|
|
1713
1713
|
}
|
|
1714
|
-
negative(
|
|
1714
|
+
negative(message2) {
|
|
1715
1715
|
return this._addCheck({
|
|
1716
1716
|
kind: "max",
|
|
1717
1717
|
value: 0,
|
|
1718
1718
|
inclusive: false,
|
|
1719
|
-
message: errorUtil.toString(
|
|
1719
|
+
message: errorUtil.toString(message2)
|
|
1720
1720
|
});
|
|
1721
1721
|
}
|
|
1722
|
-
nonpositive(
|
|
1722
|
+
nonpositive(message2) {
|
|
1723
1723
|
return this._addCheck({
|
|
1724
1724
|
kind: "max",
|
|
1725
1725
|
value: 0,
|
|
1726
1726
|
inclusive: true,
|
|
1727
|
-
message: errorUtil.toString(
|
|
1727
|
+
message: errorUtil.toString(message2)
|
|
1728
1728
|
});
|
|
1729
1729
|
}
|
|
1730
|
-
nonnegative(
|
|
1730
|
+
nonnegative(message2) {
|
|
1731
1731
|
return this._addCheck({
|
|
1732
1732
|
kind: "min",
|
|
1733
1733
|
value: 0,
|
|
1734
1734
|
inclusive: true,
|
|
1735
|
-
message: errorUtil.toString(
|
|
1735
|
+
message: errorUtil.toString(message2)
|
|
1736
1736
|
});
|
|
1737
1737
|
}
|
|
1738
|
-
multipleOf(value,
|
|
1738
|
+
multipleOf(value, message2) {
|
|
1739
1739
|
return this._addCheck({
|
|
1740
1740
|
kind: "multipleOf",
|
|
1741
1741
|
value,
|
|
1742
|
-
message: errorUtil.toString(
|
|
1742
|
+
message: errorUtil.toString(message2)
|
|
1743
1743
|
});
|
|
1744
1744
|
}
|
|
1745
|
-
finite(
|
|
1745
|
+
finite(message2) {
|
|
1746
1746
|
return this._addCheck({
|
|
1747
1747
|
kind: "finite",
|
|
1748
|
-
message: errorUtil.toString(
|
|
1748
|
+
message: errorUtil.toString(message2)
|
|
1749
1749
|
});
|
|
1750
1750
|
}
|
|
1751
|
-
safe(
|
|
1751
|
+
safe(message2) {
|
|
1752
1752
|
return this._addCheck({
|
|
1753
1753
|
kind: "min",
|
|
1754
1754
|
inclusive: true,
|
|
1755
1755
|
value: Number.MIN_SAFE_INTEGER,
|
|
1756
|
-
message: errorUtil.toString(
|
|
1756
|
+
message: errorUtil.toString(message2)
|
|
1757
1757
|
})._addCheck({
|
|
1758
1758
|
kind: "max",
|
|
1759
1759
|
inclusive: true,
|
|
1760
1760
|
value: Number.MAX_SAFE_INTEGER,
|
|
1761
|
-
message: errorUtil.toString(
|
|
1761
|
+
message: errorUtil.toString(message2)
|
|
1762
1762
|
});
|
|
1763
1763
|
}
|
|
1764
1764
|
get minValue() {
|
|
@@ -1881,19 +1881,19 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1881
1881
|
});
|
|
1882
1882
|
return INVALID;
|
|
1883
1883
|
}
|
|
1884
|
-
gte(value,
|
|
1885
|
-
return this.setLimit("min", value, true, errorUtil.toString(
|
|
1884
|
+
gte(value, message2) {
|
|
1885
|
+
return this.setLimit("min", value, true, errorUtil.toString(message2));
|
|
1886
1886
|
}
|
|
1887
|
-
gt(value,
|
|
1888
|
-
return this.setLimit("min", value, false, errorUtil.toString(
|
|
1887
|
+
gt(value, message2) {
|
|
1888
|
+
return this.setLimit("min", value, false, errorUtil.toString(message2));
|
|
1889
1889
|
}
|
|
1890
|
-
lte(value,
|
|
1891
|
-
return this.setLimit("max", value, true, errorUtil.toString(
|
|
1890
|
+
lte(value, message2) {
|
|
1891
|
+
return this.setLimit("max", value, true, errorUtil.toString(message2));
|
|
1892
1892
|
}
|
|
1893
|
-
lt(value,
|
|
1894
|
-
return this.setLimit("max", value, false, errorUtil.toString(
|
|
1893
|
+
lt(value, message2) {
|
|
1894
|
+
return this.setLimit("max", value, false, errorUtil.toString(message2));
|
|
1895
1895
|
}
|
|
1896
|
-
setLimit(kind, value, inclusive,
|
|
1896
|
+
setLimit(kind, value, inclusive, message2) {
|
|
1897
1897
|
return new _ZodBigInt({
|
|
1898
1898
|
...this._def,
|
|
1899
1899
|
checks: [
|
|
@@ -1902,7 +1902,7 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1902
1902
|
kind,
|
|
1903
1903
|
value,
|
|
1904
1904
|
inclusive,
|
|
1905
|
-
message: errorUtil.toString(
|
|
1905
|
+
message: errorUtil.toString(message2)
|
|
1906
1906
|
}
|
|
1907
1907
|
]
|
|
1908
1908
|
});
|
|
@@ -1913,43 +1913,43 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1913
1913
|
checks: [...this._def.checks, check]
|
|
1914
1914
|
});
|
|
1915
1915
|
}
|
|
1916
|
-
positive(
|
|
1916
|
+
positive(message2) {
|
|
1917
1917
|
return this._addCheck({
|
|
1918
1918
|
kind: "min",
|
|
1919
1919
|
value: BigInt(0),
|
|
1920
1920
|
inclusive: false,
|
|
1921
|
-
message: errorUtil.toString(
|
|
1921
|
+
message: errorUtil.toString(message2)
|
|
1922
1922
|
});
|
|
1923
1923
|
}
|
|
1924
|
-
negative(
|
|
1924
|
+
negative(message2) {
|
|
1925
1925
|
return this._addCheck({
|
|
1926
1926
|
kind: "max",
|
|
1927
1927
|
value: BigInt(0),
|
|
1928
1928
|
inclusive: false,
|
|
1929
|
-
message: errorUtil.toString(
|
|
1929
|
+
message: errorUtil.toString(message2)
|
|
1930
1930
|
});
|
|
1931
1931
|
}
|
|
1932
|
-
nonpositive(
|
|
1932
|
+
nonpositive(message2) {
|
|
1933
1933
|
return this._addCheck({
|
|
1934
1934
|
kind: "max",
|
|
1935
1935
|
value: BigInt(0),
|
|
1936
1936
|
inclusive: true,
|
|
1937
|
-
message: errorUtil.toString(
|
|
1937
|
+
message: errorUtil.toString(message2)
|
|
1938
1938
|
});
|
|
1939
1939
|
}
|
|
1940
|
-
nonnegative(
|
|
1940
|
+
nonnegative(message2) {
|
|
1941
1941
|
return this._addCheck({
|
|
1942
1942
|
kind: "min",
|
|
1943
1943
|
value: BigInt(0),
|
|
1944
1944
|
inclusive: true,
|
|
1945
|
-
message: errorUtil.toString(
|
|
1945
|
+
message: errorUtil.toString(message2)
|
|
1946
1946
|
});
|
|
1947
1947
|
}
|
|
1948
|
-
multipleOf(value,
|
|
1948
|
+
multipleOf(value, message2) {
|
|
1949
1949
|
return this._addCheck({
|
|
1950
1950
|
kind: "multipleOf",
|
|
1951
1951
|
value,
|
|
1952
|
-
message: errorUtil.toString(
|
|
1952
|
+
message: errorUtil.toString(message2)
|
|
1953
1953
|
});
|
|
1954
1954
|
}
|
|
1955
1955
|
get minValue() {
|
|
@@ -2072,18 +2072,18 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
2072
2072
|
checks: [...this._def.checks, check]
|
|
2073
2073
|
});
|
|
2074
2074
|
}
|
|
2075
|
-
min(minDate,
|
|
2075
|
+
min(minDate, message2) {
|
|
2076
2076
|
return this._addCheck({
|
|
2077
2077
|
kind: "min",
|
|
2078
2078
|
value: minDate.getTime(),
|
|
2079
|
-
message: errorUtil.toString(
|
|
2079
|
+
message: errorUtil.toString(message2)
|
|
2080
2080
|
});
|
|
2081
2081
|
}
|
|
2082
|
-
max(maxDate,
|
|
2082
|
+
max(maxDate, message2) {
|
|
2083
2083
|
return this._addCheck({
|
|
2084
2084
|
kind: "max",
|
|
2085
2085
|
value: maxDate.getTime(),
|
|
2086
|
-
message: errorUtil.toString(
|
|
2086
|
+
message: errorUtil.toString(message2)
|
|
2087
2087
|
});
|
|
2088
2088
|
}
|
|
2089
2089
|
get minDate() {
|
|
@@ -2315,26 +2315,26 @@ var ZodArray = class _ZodArray extends ZodType {
|
|
|
2315
2315
|
get element() {
|
|
2316
2316
|
return this._def.type;
|
|
2317
2317
|
}
|
|
2318
|
-
min(minLength,
|
|
2318
|
+
min(minLength, message2) {
|
|
2319
2319
|
return new _ZodArray({
|
|
2320
2320
|
...this._def,
|
|
2321
|
-
minLength: { value: minLength, message: errorUtil.toString(
|
|
2321
|
+
minLength: { value: minLength, message: errorUtil.toString(message2) }
|
|
2322
2322
|
});
|
|
2323
2323
|
}
|
|
2324
|
-
max(maxLength,
|
|
2324
|
+
max(maxLength, message2) {
|
|
2325
2325
|
return new _ZodArray({
|
|
2326
2326
|
...this._def,
|
|
2327
|
-
maxLength: { value: maxLength, message: errorUtil.toString(
|
|
2327
|
+
maxLength: { value: maxLength, message: errorUtil.toString(message2) }
|
|
2328
2328
|
});
|
|
2329
2329
|
}
|
|
2330
|
-
length(len,
|
|
2330
|
+
length(len, message2) {
|
|
2331
2331
|
return new _ZodArray({
|
|
2332
2332
|
...this._def,
|
|
2333
|
-
exactLength: { value: len, message: errorUtil.toString(
|
|
2333
|
+
exactLength: { value: len, message: errorUtil.toString(message2) }
|
|
2334
2334
|
});
|
|
2335
2335
|
}
|
|
2336
|
-
nonempty(
|
|
2337
|
-
return this.min(1,
|
|
2336
|
+
nonempty(message2) {
|
|
2337
|
+
return this.min(1, message2);
|
|
2338
2338
|
}
|
|
2339
2339
|
};
|
|
2340
2340
|
ZodArray.create = (schema, params) => {
|
|
@@ -2477,17 +2477,17 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2477
2477
|
get shape() {
|
|
2478
2478
|
return this._def.shape();
|
|
2479
2479
|
}
|
|
2480
|
-
strict(
|
|
2480
|
+
strict(message2) {
|
|
2481
2481
|
errorUtil.errToObj;
|
|
2482
2482
|
return new _ZodObject({
|
|
2483
2483
|
...this._def,
|
|
2484
2484
|
unknownKeys: "strict",
|
|
2485
|
-
...
|
|
2485
|
+
...message2 !== void 0 ? {
|
|
2486
2486
|
errorMap: (issue, ctx) => {
|
|
2487
2487
|
const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
|
|
2488
2488
|
if (issue.code === "unrecognized_keys")
|
|
2489
2489
|
return {
|
|
2490
|
-
message: errorUtil.errToObj(
|
|
2490
|
+
message: errorUtil.errToObj(message2).message ?? defaultError
|
|
2491
2491
|
};
|
|
2492
2492
|
return {
|
|
2493
2493
|
message: defaultError
|
|
@@ -3243,23 +3243,23 @@ var ZodSet = class _ZodSet extends ZodType {
|
|
|
3243
3243
|
return finalizeSet(elements);
|
|
3244
3244
|
}
|
|
3245
3245
|
}
|
|
3246
|
-
min(minSize,
|
|
3246
|
+
min(minSize, message2) {
|
|
3247
3247
|
return new _ZodSet({
|
|
3248
3248
|
...this._def,
|
|
3249
|
-
minSize: { value: minSize, message: errorUtil.toString(
|
|
3249
|
+
minSize: { value: minSize, message: errorUtil.toString(message2) }
|
|
3250
3250
|
});
|
|
3251
3251
|
}
|
|
3252
|
-
max(maxSize,
|
|
3252
|
+
max(maxSize, message2) {
|
|
3253
3253
|
return new _ZodSet({
|
|
3254
3254
|
...this._def,
|
|
3255
|
-
maxSize: { value: maxSize, message: errorUtil.toString(
|
|
3255
|
+
maxSize: { value: maxSize, message: errorUtil.toString(message2) }
|
|
3256
3256
|
});
|
|
3257
3257
|
}
|
|
3258
|
-
size(size,
|
|
3259
|
-
return this.min(size,
|
|
3258
|
+
size(size, message2) {
|
|
3259
|
+
return this.min(size, message2).max(size, message2);
|
|
3260
3260
|
}
|
|
3261
|
-
nonempty(
|
|
3262
|
-
return this.min(1,
|
|
3261
|
+
nonempty(message2) {
|
|
3262
|
+
return this.min(1, message2);
|
|
3263
3263
|
}
|
|
3264
3264
|
};
|
|
3265
3265
|
ZodSet.create = (valueType, params) => {
|
|
@@ -4083,6 +4083,9 @@ var acpPermissionOptionKindSchema = external_exports.enum([
|
|
|
4083
4083
|
"reject_once",
|
|
4084
4084
|
"reject_always"
|
|
4085
4085
|
]);
|
|
4086
|
+
var lumemModeSchema = external_exports.enum(["ask", "auto", "free"]);
|
|
4087
|
+
var lumemModeDefaultSchema = external_exports.enum(["ask", "auto"]);
|
|
4088
|
+
var acpModeOwnerSchema = external_exports.enum(["agent", "lumem"]);
|
|
4086
4089
|
var acpPermissionOptionSchema = external_exports.object({
|
|
4087
4090
|
optionId: external_exports.string(),
|
|
4088
4091
|
/** The agent's own label, shown verbatim (A13). */
|
|
@@ -4186,13 +4189,40 @@ var acpEventSchema = external_exports.discriminatedUnion("type", [
|
|
|
4186
4189
|
title: external_exports.string(),
|
|
4187
4190
|
command: external_exports.string().nullish(),
|
|
4188
4191
|
cwd: external_exports.string(),
|
|
4189
|
-
options: external_exports.array(acpPermissionOptionSchema).min(1)
|
|
4192
|
+
options: external_exports.array(acpPermissionOptionSchema).min(1),
|
|
4193
|
+
/**
|
|
4194
|
+
* Why the Lumem policy did not answer this one (`session-mode`, T7).
|
|
4195
|
+
*
|
|
4196
|
+
* Null under `ask`, and under an agent that owns its own modes: there is
|
|
4197
|
+
* nothing to explain when asking *is* the rule. Set when a policy that would
|
|
4198
|
+
* normally answer did not — `auto` facing a write, or an agent that offered
|
|
4199
|
+
* no way to allow (Q6) — because "why am I being asked in auto mode?" is
|
|
4200
|
+
* otherwise a question the screen cannot answer.
|
|
4201
|
+
*/
|
|
4202
|
+
policyReason: external_exports.string().nullable().default(null)
|
|
4190
4203
|
}),
|
|
4191
4204
|
external_exports.object({
|
|
4192
4205
|
type: external_exports.literal("permission_resolved"),
|
|
4193
4206
|
requestId: external_exports.string(),
|
|
4194
4207
|
/** `"cancelled"` is the agent giving up on the ask, not the user denying. */
|
|
4195
|
-
outcome: external_exports.union([external_exports.literal("cancelled"), external_exports.object({ optionId: external_exports.string() })])
|
|
4208
|
+
outcome: external_exports.union([external_exports.literal("cancelled"), external_exports.object({ optionId: external_exports.string() })]),
|
|
4209
|
+
/**
|
|
4210
|
+
* Who signed it (F1.6).
|
|
4211
|
+
*
|
|
4212
|
+
* `default` and not `optional`, for two reasons that point the same way: a
|
|
4213
|
+
* transcript recorded before this feature has no field and must still open,
|
|
4214
|
+
* and `"user"` is the truthful answer for every one of them — nothing but a
|
|
4215
|
+
* person could answer a permission request back then.
|
|
4216
|
+
*/
|
|
4217
|
+
by: external_exports.enum(["user", "lumem"]).default("user"),
|
|
4218
|
+
/**
|
|
4219
|
+
* Why the policy answered, in the words the card shows.
|
|
4220
|
+
*
|
|
4221
|
+
* Only ever set when `by` is `"lumem"`: a person clicking a button is its
|
|
4222
|
+
* own reason, and inventing prose for it would be the daemon narrating the
|
|
4223
|
+
* user's intent.
|
|
4224
|
+
*/
|
|
4225
|
+
reason: external_exports.string().nullable().default(null)
|
|
4196
4226
|
}),
|
|
4197
4227
|
/**
|
|
4198
4228
|
* The plan, whole (F2.5).
|
|
@@ -4237,7 +4267,24 @@ var acpEventSchema = external_exports.discriminatedUnion("type", [
|
|
|
4237
4267
|
* sending this. So the client replaces rather than merging, and there is exactly
|
|
4238
4268
|
* one place that has to get the merge right.
|
|
4239
4269
|
*/
|
|
4240
|
-
options: external_exports.array(acpConfigOptionSchema)
|
|
4270
|
+
options: external_exports.array(acpConfigOptionSchema),
|
|
4271
|
+
/**
|
|
4272
|
+
* Which of the two authorities is in charge right now (A1).
|
|
4273
|
+
*
|
|
4274
|
+
* Defaults to `"agent"` so a transcript recorded before `session-mode` reads
|
|
4275
|
+
* as what it was: a conversation where only the agent could offer a mode.
|
|
4276
|
+
*/
|
|
4277
|
+
modeOwner: acpModeOwnerSchema.default("agent"),
|
|
4278
|
+
/**
|
|
4279
|
+
* The policy value, whoever owns the selector.
|
|
4280
|
+
*
|
|
4281
|
+
* Sent even while the agent owns the mode, and that is on purpose: the value
|
|
4282
|
+
* is *kept*, not erased, so an agent that stops reporting modes hands the
|
|
4283
|
+
* conversation back to the policy it already had (T12).
|
|
4284
|
+
*/
|
|
4285
|
+
lumemMode: lumemModeSchema.default("ask"),
|
|
4286
|
+
/** What a new session in this workspace would start at — the menu's footer (Q5). */
|
|
4287
|
+
lumemModeDefault: lumemModeDefaultSchema.default("ask")
|
|
4241
4288
|
}),
|
|
4242
4289
|
/** What `/` offers (F2.8). An empty list means the agent offers none. */
|
|
4243
4290
|
external_exports.object({ type: external_exports.literal("commands"), commands: external_exports.array(acpCommandSchema) }),
|
|
@@ -4335,7 +4382,17 @@ var acpClientMessageSchema = external_exports.discriminatedUnion("type", [
|
|
|
4335
4382
|
type: external_exports.literal("set_config"),
|
|
4336
4383
|
optionId: external_exports.string().min(1),
|
|
4337
4384
|
value: external_exports.string().min(1)
|
|
4338
|
-
})
|
|
4385
|
+
}),
|
|
4386
|
+
/**
|
|
4387
|
+
* Switch the policy Lumem applies when the agent offers no modes (F1.1).
|
|
4388
|
+
*
|
|
4389
|
+
* A message of its own rather than a `set_config` with `optionId: "mode"`,
|
|
4390
|
+
* because it is not the same act: `set_config` forwards a value to the agent
|
|
4391
|
+
* and this one never leaves the daemon. Sharing the message would put two
|
|
4392
|
+
* destinations behind one name, and the first bug would be a policy change
|
|
4393
|
+
* quietly forwarded to an agent that does not have the option.
|
|
4394
|
+
*/
|
|
4395
|
+
external_exports.object({ type: external_exports.literal("set_lumem_mode"), mode: lumemModeSchema })
|
|
4339
4396
|
]);
|
|
4340
4397
|
var acpServerMessageSchema = external_exports.discriminatedUnion("type", [
|
|
4341
4398
|
/**
|
|
@@ -4358,6 +4415,23 @@ var acpServerMessageSchema = external_exports.discriminatedUnion("type", [
|
|
|
4358
4415
|
* broken for as long as nothing changed.
|
|
4359
4416
|
*/
|
|
4360
4417
|
configOptions: external_exports.array(acpConfigOptionSchema).default([]),
|
|
4418
|
+
/**
|
|
4419
|
+
* The mode state, on attach, for the same reason `configOptions` is here: a
|
|
4420
|
+
* composer whose mode pill appeared only once something changed would look
|
|
4421
|
+
* broken for as long as nothing did.
|
|
4422
|
+
*/
|
|
4423
|
+
modeOwner: acpModeOwnerSchema.default("agent"),
|
|
4424
|
+
lumemMode: lumemModeSchema.default("ask"),
|
|
4425
|
+
lumemModeDefault: lumemModeDefaultSchema.default("ask"),
|
|
4426
|
+
/**
|
|
4427
|
+
* The checkout this conversation runs in.
|
|
4428
|
+
*
|
|
4429
|
+
* Here because the `free` gate has to name what it is opening, and it names
|
|
4430
|
+
* it as a **path on disk** rather than as "the worktree": the path is what
|
|
4431
|
+
* says the size of the damage (Q4). A gate that could not say it would be
|
|
4432
|
+
* asking for a decision without stating its scope.
|
|
4433
|
+
*/
|
|
4434
|
+
cwd: external_exports.string().default(""),
|
|
4361
4435
|
transcript: external_exports.array(acpTranscriptEntrySchema)
|
|
4362
4436
|
}),
|
|
4363
4437
|
external_exports.object({
|
|
@@ -4381,7 +4455,7 @@ var acpServerMessageSchema = external_exports.discriminatedUnion("type", [
|
|
|
4381
4455
|
]);
|
|
4382
4456
|
|
|
4383
4457
|
// ../shared/src/constants.ts
|
|
4384
|
-
var LUMEM_VERSION = "0.
|
|
4458
|
+
var LUMEM_VERSION = "0.2.0";
|
|
4385
4459
|
var ACP_ADAPTER_PACKAGE = "@agentclientprotocol/claude-agent-acp";
|
|
4386
4460
|
var ACP_ADAPTER_INSTALL = `npm i -g ${ACP_ADAPTER_PACKAGE}`;
|
|
4387
4461
|
|
|
@@ -4431,7 +4505,7 @@ var ptyServerMessageSchema = external_exports.discriminatedUnion("type", [
|
|
|
4431
4505
|
]);
|
|
4432
4506
|
|
|
4433
4507
|
// src/run.ts
|
|
4434
|
-
import { fileURLToPath } from "node:url";
|
|
4508
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
4435
4509
|
|
|
4436
4510
|
// src/args.ts
|
|
4437
4511
|
import { parseArgs } from "node:util";
|
|
@@ -4439,6 +4513,7 @@ var HELP = `lumem \u2014 harness local de agentes de c\xF3digo
|
|
|
4439
4513
|
|
|
4440
4514
|
Uso:
|
|
4441
4515
|
lumem [start] [op\xE7\xF5es] sobe o daemon e serve a interface
|
|
4516
|
+
lumem upgrade [--check] atualiza o daemon para a \xFAltima vers\xE3o do npm
|
|
4442
4517
|
lumem version imprime a vers\xE3o
|
|
4443
4518
|
lumem help imprime esta ajuda
|
|
4444
4519
|
|
|
@@ -4447,6 +4522,7 @@ Op\xE7\xF5es:
|
|
|
4447
4522
|
--host <endere\xE7o> interface de escuta (padr\xE3o: 127.0.0.1)
|
|
4448
4523
|
--state-dir <caminho> onde o Lumem guarda tudo (padr\xE3o: ~/.lumem)
|
|
4449
4524
|
--open abre o navegador quando subir
|
|
4525
|
+
--check em \`upgrade\`, s\xF3 diz se tem vers\xE3o nova
|
|
4450
4526
|
-v, --version o mesmo que \`lumem version\`
|
|
4451
4527
|
-h, --help o mesmo que \`lumem help\`
|
|
4452
4528
|
|
|
@@ -4469,6 +4545,7 @@ function parseCommand(argv) {
|
|
|
4469
4545
|
host: { type: "string" },
|
|
4470
4546
|
"state-dir": { type: "string" },
|
|
4471
4547
|
open: { type: "boolean", default: false },
|
|
4548
|
+
check: { type: "boolean", default: false },
|
|
4472
4549
|
version: { type: "boolean", short: "v", default: false },
|
|
4473
4550
|
help: { type: "boolean", short: "h", default: false }
|
|
4474
4551
|
}
|
|
@@ -4485,6 +4562,7 @@ function parseCommand(argv) {
|
|
|
4485
4562
|
}
|
|
4486
4563
|
if (verb === "help") return { kind: "help" };
|
|
4487
4564
|
if (verb === "version") return { kind: "version" };
|
|
4565
|
+
if (verb === "upgrade") return { kind: "upgrade", check: values.check === true };
|
|
4488
4566
|
if (verb !== "start") return { kind: "invalid", message: `comando desconhecido: ${verb}` };
|
|
4489
4567
|
const port = values.port === void 0 ? null : toPort(values.port);
|
|
4490
4568
|
if (values.port !== void 0 && port === null) {
|
|
@@ -4541,6 +4619,129 @@ async function probePort({
|
|
|
4541
4619
|
}
|
|
4542
4620
|
}
|
|
4543
4621
|
|
|
4622
|
+
// src/upgrade.ts
|
|
4623
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
4624
|
+
import { fileURLToPath } from "node:url";
|
|
4625
|
+
var PACKAGE_NAME = "@vinihcrosa/lumem-os";
|
|
4626
|
+
var REGISTRY_URL = `https://registry.npmjs.org/${encodeURIComponent(PACKAGE_NAME)}/latest`;
|
|
4627
|
+
function detectPackageManager(installPath) {
|
|
4628
|
+
const path = installPath.replace(/\\/g, "/");
|
|
4629
|
+
if (/\/\.?pnpm[/-]/.test(path)) return "pnpm";
|
|
4630
|
+
if (path.includes("/.bun/")) return "bun";
|
|
4631
|
+
if (/\/\.?yarn\//.test(path)) return "yarn";
|
|
4632
|
+
return "npm";
|
|
4633
|
+
}
|
|
4634
|
+
function installCommand(manager, spec) {
|
|
4635
|
+
switch (manager) {
|
|
4636
|
+
case "pnpm":
|
|
4637
|
+
return { command: "pnpm", args: ["add", "--global", spec] };
|
|
4638
|
+
case "yarn":
|
|
4639
|
+
return { command: "yarn", args: ["global", "add", spec] };
|
|
4640
|
+
case "bun":
|
|
4641
|
+
return { command: "bun", args: ["add", "--global", spec] };
|
|
4642
|
+
case "npm":
|
|
4643
|
+
return { command: "npm", args: ["install", "--global", spec] };
|
|
4644
|
+
}
|
|
4645
|
+
}
|
|
4646
|
+
function compareVersions(a, b) {
|
|
4647
|
+
const split = (version) => {
|
|
4648
|
+
const [core = "", pre = ""] = version.trim().replace(/^v/, "").split("-", 2);
|
|
4649
|
+
return { parts: core.split(".").map((n) => Number.parseInt(n, 10) || 0), pre };
|
|
4650
|
+
};
|
|
4651
|
+
const left = split(a);
|
|
4652
|
+
const right = split(b);
|
|
4653
|
+
for (let i = 0; i < 3; i += 1) {
|
|
4654
|
+
const l = left.parts[i] ?? 0;
|
|
4655
|
+
const r = right.parts[i] ?? 0;
|
|
4656
|
+
if (l !== r) return l < r ? -1 : 1;
|
|
4657
|
+
}
|
|
4658
|
+
if (left.pre === right.pre) return 0;
|
|
4659
|
+
if (left.pre === "") return 1;
|
|
4660
|
+
if (right.pre === "") return -1;
|
|
4661
|
+
return left.pre < right.pre ? -1 : 1;
|
|
4662
|
+
}
|
|
4663
|
+
async function fetchLatestVersion({
|
|
4664
|
+
request = fetch,
|
|
4665
|
+
timeoutMs = 1e4
|
|
4666
|
+
} = {}) {
|
|
4667
|
+
const response = await request(REGISTRY_URL, {
|
|
4668
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
4669
|
+
headers: { accept: "application/json" }
|
|
4670
|
+
});
|
|
4671
|
+
if (!response.ok) throw new Error(`o registry respondeu ${String(response.status)}`);
|
|
4672
|
+
const body = await response.json();
|
|
4673
|
+
if (typeof body.version !== "string" || body.version === "") {
|
|
4674
|
+
throw new Error("o registry respondeu sem vers\xE3o");
|
|
4675
|
+
}
|
|
4676
|
+
return body.version;
|
|
4677
|
+
}
|
|
4678
|
+
async function upgrade(deps) {
|
|
4679
|
+
const {
|
|
4680
|
+
out,
|
|
4681
|
+
err,
|
|
4682
|
+
current,
|
|
4683
|
+
check,
|
|
4684
|
+
origin,
|
|
4685
|
+
fetchLatest = () => fetchLatestVersion(),
|
|
4686
|
+
install = runInstall,
|
|
4687
|
+
manager = detectPackageManager(fileURLToPath(import.meta.url)),
|
|
4688
|
+
probe = probePort
|
|
4689
|
+
} = deps;
|
|
4690
|
+
let latest;
|
|
4691
|
+
try {
|
|
4692
|
+
latest = await fetchLatest();
|
|
4693
|
+
} catch (error) {
|
|
4694
|
+
err(`n\xE3o consegui perguntar ao npm qual \xE9 a \xFAltima vers\xE3o: ${message(error)}`);
|
|
4695
|
+
return 1;
|
|
4696
|
+
}
|
|
4697
|
+
const order = compareVersions(current, latest);
|
|
4698
|
+
if (order === 0) {
|
|
4699
|
+
out(`j\xE1 est\xE1 na \xFAltima vers\xE3o (v${current}).`);
|
|
4700
|
+
return 0;
|
|
4701
|
+
}
|
|
4702
|
+
if (order === 1) {
|
|
4703
|
+
out(`a vers\xE3o instalada (v${current}) \xE9 mais nova que a do npm (v${latest}); nada a fazer.`);
|
|
4704
|
+
return 0;
|
|
4705
|
+
}
|
|
4706
|
+
if (check) {
|
|
4707
|
+
out(`tem vers\xE3o nova: v${current} \u2192 v${latest}`);
|
|
4708
|
+
out("rode `lumem upgrade` para instalar.");
|
|
4709
|
+
return 0;
|
|
4710
|
+
}
|
|
4711
|
+
const command = installCommand(manager, `${PACKAGE_NAME}@${latest}`);
|
|
4712
|
+
out(`atualizando o Lumem: v${current} \u2192 v${latest}`);
|
|
4713
|
+
out(`$ ${command.command} ${command.args.join(" ")}`);
|
|
4714
|
+
let code2;
|
|
4715
|
+
try {
|
|
4716
|
+
code2 = await install(command);
|
|
4717
|
+
} catch (error) {
|
|
4718
|
+
err(`n\xE3o consegui rodar o ${command.command}: ${message(error)}`);
|
|
4719
|
+
return 1;
|
|
4720
|
+
}
|
|
4721
|
+
if (code2 !== 0) {
|
|
4722
|
+
err(`o ${command.command} saiu com ${String(code2)}; o Lumem continua na v${current}.`);
|
|
4723
|
+
return code2;
|
|
4724
|
+
}
|
|
4725
|
+
out(`pronto: v${latest} instalado.`);
|
|
4726
|
+
const occupant = await probe({ origin });
|
|
4727
|
+
if (occupant.kind === "lumem") {
|
|
4728
|
+
out(`o daemon em ${origin} ainda est\xE1 na v${occupant.version}: pare e suba de novo para valer.`);
|
|
4729
|
+
}
|
|
4730
|
+
return 0;
|
|
4731
|
+
}
|
|
4732
|
+
function message(error) {
|
|
4733
|
+
return error instanceof Error ? error.message : String(error);
|
|
4734
|
+
}
|
|
4735
|
+
async function runInstall({ command, args }) {
|
|
4736
|
+
return await new Promise((resolve, reject) => {
|
|
4737
|
+
const child = spawn2(command, args, { stdio: "inherit" });
|
|
4738
|
+
child.on("error", reject);
|
|
4739
|
+
child.on("close", (code2) => {
|
|
4740
|
+
resolve(code2 ?? 1);
|
|
4741
|
+
});
|
|
4742
|
+
});
|
|
4743
|
+
}
|
|
4744
|
+
|
|
4544
4745
|
// src/run.ts
|
|
4545
4746
|
var DEFAULT_PORT = 4317;
|
|
4546
4747
|
var DEFAULT_HOST = "127.0.0.1";
|
|
@@ -4552,10 +4753,11 @@ async function run(argv, deps) {
|
|
|
4552
4753
|
env,
|
|
4553
4754
|
version,
|
|
4554
4755
|
startDaemon = async () => {
|
|
4555
|
-
await import(
|
|
4756
|
+
await import(fileURLToPath2(new URL(DAEMON_ENTRY, import.meta.url)));
|
|
4556
4757
|
},
|
|
4557
4758
|
probe = probePort,
|
|
4558
|
-
open = openInBrowser
|
|
4759
|
+
open = openInBrowser,
|
|
4760
|
+
upgrade: upgrade2 = upgrade
|
|
4559
4761
|
} = deps;
|
|
4560
4762
|
const command = parseCommand(argv);
|
|
4561
4763
|
if (command.kind === "help") {
|
|
@@ -4571,9 +4773,20 @@ async function run(argv, deps) {
|
|
|
4571
4773
|
err("`lumem help` lista o que existe.");
|
|
4572
4774
|
return 2;
|
|
4573
4775
|
}
|
|
4776
|
+
const originOf = (port2, host2) => `http://${host2 === "0.0.0.0" ? "127.0.0.1" : host2}:${String(port2)}`;
|
|
4777
|
+
if (command.kind === "upgrade") {
|
|
4778
|
+
return await upgrade2({
|
|
4779
|
+
out,
|
|
4780
|
+
err,
|
|
4781
|
+
current: version,
|
|
4782
|
+
check: command.check,
|
|
4783
|
+
origin: originOf(Number(env["LUMEM_PORT"] ?? DEFAULT_PORT), env["LUMEM_HOST"] ?? DEFAULT_HOST),
|
|
4784
|
+
probe
|
|
4785
|
+
});
|
|
4786
|
+
}
|
|
4574
4787
|
const port = command.port ?? Number(env["LUMEM_PORT"] ?? DEFAULT_PORT);
|
|
4575
4788
|
const host = command.host ?? env["LUMEM_HOST"] ?? DEFAULT_HOST;
|
|
4576
|
-
const origin =
|
|
4789
|
+
const origin = originOf(port, host);
|
|
4577
4790
|
const occupant = await probe({ origin });
|
|
4578
4791
|
if (occupant.kind === "lumem") {
|
|
4579
4792
|
out(`j\xE1 tem um Lumem em ${origin} (v${occupant.version})`);
|