thenomad 0.4.1 → 0.5.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/dist/nomad.js +463 -68
- package/package.json +1 -1
- package/web/404.html +1 -1
- package/web/__next.__PAGE__.txt +33 -31
- package/web/__next._full.txt +37 -35
- package/web/__next._tree.txt +2 -2
- package/web/_next/static/chunks/0zu_3pbq18_tq.js +1 -0
- package/web/_next/static/chunks/{24nxqz5lj7mh0.js → 1119s7y-irwgs.js} +1 -1
- package/web/_next/static/chunks/2cr1t7zd3-idq.js +7 -0
- package/web/_next/static/chunks/{1ygp921kjfxbp.css → 2o1e9ex_u8yqf.css} +1 -1
- package/web/_next/static/chunks/2qcrytgk9-6pf.js +1 -0
- package/web/_not-found/__next._full.txt +3 -3
- package/web/_not-found/__next._not-found.__PAGE__.txt +2 -2
- package/web/_not-found/__next._tree.txt +2 -2
- package/web/_not-found.html +1 -1
- package/web/_not-found.txt +3 -3
- package/web/app/__next._full.txt +3 -3
- package/web/app/__next._tree.txt +2 -2
- package/web/app/__next.app.__PAGE__.txt +1 -1
- package/web/app/__next.app.txt +2 -2
- package/web/app/agents/__next._full.txt +3 -3
- package/web/app/agents/__next._tree.txt +2 -2
- package/web/app/agents/__next.app.agents.__PAGE__.txt +1 -1
- package/web/app/agents/__next.app.txt +2 -2
- package/web/app/agents/view/__next._full.txt +3 -3
- package/web/app/agents/view/__next._tree.txt +2 -2
- package/web/app/agents/view/__next.app.agents.view.__PAGE__.txt +1 -1
- package/web/app/agents/view/__next.app.txt +2 -2
- package/web/app/agents/view.html +1 -1
- package/web/app/agents/view.txt +3 -3
- package/web/app/agents.html +1 -1
- package/web/app/agents.txt +3 -3
- package/web/app/backups/__next._full.txt +3 -3
- package/web/app/backups/__next._tree.txt +2 -2
- package/web/app/backups/__next.app.backups.__PAGE__.txt +1 -1
- package/web/app/backups/__next.app.txt +2 -2
- package/web/app/backups.html +1 -1
- package/web/app/backups.txt +3 -3
- package/web/app/compatibility/__next._full.txt +5 -5
- package/web/app/compatibility/__next._tree.txt +2 -2
- package/web/app/compatibility/__next.app.compatibility.__PAGE__.txt +3 -3
- package/web/app/compatibility/__next.app.txt +2 -2
- package/web/app/compatibility.html +1 -1
- package/web/app/compatibility.txt +5 -5
- package/web/app/export/__next._full.txt +5 -5
- package/web/app/export/__next._tree.txt +2 -2
- package/web/app/export/__next.app.export.__PAGE__.txt +3 -3
- package/web/app/export/__next.app.txt +2 -2
- package/web/app/export.html +1 -1
- package/web/app/export.txt +5 -5
- package/web/app/history/__next._full.txt +5 -5
- package/web/app/history/__next._tree.txt +2 -2
- package/web/app/history/__next.app.history.__PAGE__.txt +3 -3
- package/web/app/history/__next.app.txt +2 -2
- package/web/app/history.html +1 -1
- package/web/app/history.txt +5 -5
- package/web/app/import/__next._full.txt +3 -3
- package/web/app/import/__next._tree.txt +2 -2
- package/web/app/import/__next.app.import.__PAGE__.txt +1 -1
- package/web/app/import/__next.app.txt +2 -2
- package/web/app/import.html +1 -1
- package/web/app/import.txt +3 -3
- package/web/app/migrate/__next._full.txt +5 -5
- package/web/app/migrate/__next._tree.txt +2 -2
- package/web/app/migrate/__next.app.migrate.__PAGE__.txt +3 -3
- package/web/app/migrate/__next.app.txt +2 -2
- package/web/app/migrate.html +1 -1
- package/web/app/migrate.txt +5 -5
- package/web/app/settings/__next._full.txt +5 -5
- package/web/app/settings/__next._tree.txt +2 -2
- package/web/app/settings/__next.app.settings.__PAGE__.txt +3 -3
- package/web/app/settings/__next.app.txt +2 -2
- package/web/app/settings.html +1 -1
- package/web/app/settings.txt +5 -5
- package/web/app/versions/__next._full.txt +3 -3
- package/web/app/versions/__next._tree.txt +2 -2
- package/web/app/versions/__next.app.txt +2 -2
- package/web/app/versions/__next.app.versions.__PAGE__.txt +1 -1
- package/web/app/versions.html +1 -1
- package/web/app/versions.txt +3 -3
- package/web/app.html +1 -1
- package/web/app.txt +3 -3
- package/web/docs/__next._full.txt +3 -3
- package/web/docs/__next._tree.txt +2 -2
- package/web/docs/__next.docs.__PAGE__.txt +2 -2
- package/web/docs/adapters/__next._full.txt +3 -3
- package/web/docs/adapters/__next._tree.txt +2 -2
- package/web/docs/adapters/__next.docs.adapters.__PAGE__.txt +2 -2
- package/web/docs/adapters.html +1 -1
- package/web/docs/adapters.txt +3 -3
- package/web/docs/format/__next._full.txt +3 -3
- package/web/docs/format/__next._tree.txt +2 -2
- package/web/docs/format/__next.docs.format.__PAGE__.txt +2 -2
- package/web/docs/format.html +2 -2
- package/web/docs/format.txt +3 -3
- package/web/docs/security/__next._full.txt +3 -3
- package/web/docs/security/__next._tree.txt +2 -2
- package/web/docs/security/__next.docs.security.__PAGE__.txt +2 -2
- package/web/docs/security.html +1 -1
- package/web/docs/security.txt +3 -3
- package/web/docs/token/__next._full.txt +3 -3
- package/web/docs/token/__next._tree.txt +2 -2
- package/web/docs/token/__next.docs.token.__PAGE__.txt +2 -2
- package/web/docs/token.html +1 -1
- package/web/docs/token.txt +3 -3
- package/web/docs.html +2 -2
- package/web/docs.txt +3 -3
- package/web/index.html +2 -2
- package/web/index.txt +37 -35
- package/web/inspect/__next._full.txt +6 -6
- package/web/inspect/__next._tree.txt +2 -2
- package/web/inspect/__next.inspect.__PAGE__.txt +5 -5
- package/web/inspect.html +1 -1
- package/web/inspect.txt +6 -6
- package/web/privacy/__next._full.txt +3 -3
- package/web/privacy/__next._tree.txt +2 -2
- package/web/privacy/__next.privacy.__PAGE__.txt +2 -2
- package/web/privacy.html +1 -1
- package/web/privacy.txt +3 -3
- package/web/terms/__next._full.txt +3 -3
- package/web/terms/__next._tree.txt +2 -2
- package/web/terms/__next.terms.__PAGE__.txt +2 -2
- package/web/terms.html +1 -1
- package/web/terms.txt +3 -3
- package/web/vote/__next._full.txt +3 -3
- package/web/vote/__next._tree.txt +2 -2
- package/web/vote/__next.vote.__PAGE__.txt +2 -2
- package/web/vote.html +1 -1
- package/web/vote.txt +3 -3
- package/web/_next/static/chunks/10-jap4z156cb.js +0 -1
- package/web/_next/static/chunks/2bgjjtv5djk5k.js +0 -1
- package/web/_next/static/chunks/2ka3apprzgwd-.js +0 -7
- /package/web/_next/static/{wjHK22E9HmfsJn0z_eAFq → rNLVbnwje7eCRAa4cBuY9}/_buildManifest.js +0 -0
- /package/web/_next/static/{wjHK22E9HmfsJn0z_eAFq → rNLVbnwje7eCRAa4cBuY9}/_clientMiddlewareManifest.js +0 -0
- /package/web/_next/static/{wjHK22E9HmfsJn0z_eAFq → rNLVbnwje7eCRAa4cBuY9}/_ssgManifest.js +0 -0
package/dist/nomad.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __esm = (fn, res) => function __init() {
|
|
5
|
-
|
|
4
|
+
var __esm = (fn, res, err) => function __init() {
|
|
5
|
+
if (err) throw err[0];
|
|
6
|
+
try {
|
|
7
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
8
|
+
} catch (e) {
|
|
9
|
+
throw err = [e], e;
|
|
10
|
+
}
|
|
6
11
|
};
|
|
7
12
|
var __export = (target, all) => {
|
|
8
13
|
for (var name in all)
|
|
@@ -923,7 +928,7 @@ var init_src2 = __esm({
|
|
|
923
928
|
init_markdown();
|
|
924
929
|
init_document();
|
|
925
930
|
init_merge();
|
|
926
|
-
NOMAD_VERSION = "0.
|
|
931
|
+
NOMAD_VERSION = "0.5.0";
|
|
927
932
|
NomadError = class extends Error {
|
|
928
933
|
constructor(message, code, hint) {
|
|
929
934
|
super(message);
|
|
@@ -1459,7 +1464,8 @@ function isSecretEnvEntry(key2, value) {
|
|
|
1459
1464
|
function isWalletEnvEntry(key2, value) {
|
|
1460
1465
|
const v = value.trim();
|
|
1461
1466
|
if (EVM_KEY_VALUE.test(v) || isMnemonic(v) || redactWalletText(v).count > 0) return true;
|
|
1462
|
-
|
|
1467
|
+
const walletName = WALLET_ENV_NAME.test(key2) || KEY_ENV_NAME.test(key2) && !SERVICE_KEY_NAME.test(key2);
|
|
1468
|
+
return walletName && (BARE_HEX_KEY.test(v) || BASE58_KEY.test(v) || BYTE_ARRAY_KEY.test(v));
|
|
1463
1469
|
}
|
|
1464
1470
|
function visitText(doc, fn) {
|
|
1465
1471
|
if (doc.identity.persona) fn("identity/persona.md", doc.identity.persona);
|
|
@@ -1578,13 +1584,15 @@ function sanitizeDocument(doc, options = {}) {
|
|
|
1578
1584
|
};
|
|
1579
1585
|
return { doc: out2, report };
|
|
1580
1586
|
}
|
|
1581
|
-
var EVM_KEY_VALUE, WALLET_ENV_NAME, BARE_HEX_KEY, BASE58_KEY, BYTE_ARRAY_KEY;
|
|
1587
|
+
var EVM_KEY_VALUE, WALLET_ENV_NAME, KEY_ENV_NAME, SERVICE_KEY_NAME, BARE_HEX_KEY, BASE58_KEY, BYTE_ARRAY_KEY;
|
|
1582
1588
|
var init_document2 = __esm({
|
|
1583
1589
|
"../../packages/security/src/document.ts"() {
|
|
1584
1590
|
"use strict";
|
|
1585
1591
|
init_secrets();
|
|
1586
1592
|
EVM_KEY_VALUE = /\b0x[0-9a-fA-F]{64}\b/;
|
|
1587
1593
|
WALLET_ENV_NAME = /(PRIVATE|WALLET|SIGNER|MNEMONIC|SEED|OWNER|PAYER|SESSION)/i;
|
|
1594
|
+
KEY_ENV_NAME = /(^|_)KEY$/i;
|
|
1595
|
+
SERVICE_KEY_NAME = /(API|ACCESS|AUTH|TOKEN|CLIENT|LICEN[CS]E|PUBLIC|PUB)/i;
|
|
1588
1596
|
BARE_HEX_KEY = /^(?:0x)?[0-9a-fA-F]{64}$/;
|
|
1589
1597
|
BASE58_KEY = /^[1-9A-HJ-NP-Za-km-z]{86,90}$/;
|
|
1590
1598
|
BYTE_ARRAY_KEY = /^\[\s*\d{1,3}(?:\s*,\s*\d{1,3}){63}\s*\]$/;
|
|
@@ -3431,10 +3439,22 @@ function applyKnownServerProfile(tool, platformName = "the destination") {
|
|
|
3431
3439
|
function knownServerId(tool) {
|
|
3432
3440
|
return PROFILES.find((p) => p.matches(tool))?.id ?? null;
|
|
3433
3441
|
}
|
|
3434
|
-
var isPriorsHost, PRIORS, isOakCommand, OAK, HEDGEHOOD_HOSTS, isHedgehoodHost, isHedgehoodCommand, HEDGEHOOD_KEY_VARS, HEDGEHOOD, isBrainChainCommand, literal, amount, BRAINCHAIN, PROFILES;
|
|
3442
|
+
var NPM_SPEC, escapeRe2, isPackageArg, isPackageInScript, isPriorsPackage, isPriorsScript, isPriorsHost, PRIORS, isOakCommand, OAK, HEDGEHOOD_HOSTS, isHedgehoodHost, isHedgehoodCommand, HEDGEHOOD_KEY_VARS, HEDGEHOOD, BRAINCHAIN_PKG, isBrainChainCommand, literal, amount, BRAINCHAIN, PROFILES;
|
|
3435
3443
|
var init_known_servers = __esm({
|
|
3436
3444
|
"../../packages/adapters/src/known-servers.ts"() {
|
|
3437
3445
|
"use strict";
|
|
3446
|
+
NPM_SPEC = "(@[0-9A-Za-z.^~*+-]{1,64})?";
|
|
3447
|
+
escapeRe2 = (s) => s.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
|
|
3448
|
+
isPackageArg = (name) => {
|
|
3449
|
+
const re = new RegExp(`^${escapeRe2(name)}${NPM_SPEC}$`);
|
|
3450
|
+
return (a) => re.test(a);
|
|
3451
|
+
};
|
|
3452
|
+
isPackageInScript = (name) => {
|
|
3453
|
+
const re = new RegExp(`(^|\\s)${escapeRe2(name)}${NPM_SPEC}(\\s|$)`);
|
|
3454
|
+
return (a) => re.test(a);
|
|
3455
|
+
};
|
|
3456
|
+
isPriorsPackage = isPackageArg("@priors/mcp");
|
|
3457
|
+
isPriorsScript = isPackageInScript("@priors/mcp");
|
|
3438
3458
|
isPriorsHost = (url) => {
|
|
3439
3459
|
if (!url) return false;
|
|
3440
3460
|
try {
|
|
@@ -3447,7 +3467,7 @@ var init_known_servers = __esm({
|
|
|
3447
3467
|
id: "priors",
|
|
3448
3468
|
vendor: "Priors",
|
|
3449
3469
|
label: "Priors (a credit service for agents on Robinhood Chain)",
|
|
3450
|
-
matches: (t) => !!t.mcp && (t.mcp.command === "priors-mcp" || t.mcp.args.some(
|
|
3470
|
+
matches: (t) => !!t.mcp && (t.mcp.command === "priors-mcp" || t.mcp.args.some(isPriorsPackage) || /(^|[\\/])(ba|z)?sh(\.exe)?$/.test(t.mcp.command ?? "") && t.mcp.args.some(isPriorsScript) || isPriorsHost(t.mcp.url)),
|
|
3451
3471
|
keyVars: ["PRIORS_KEY_FILE", "PRIORS_KEY"],
|
|
3452
3472
|
emptyOkEnv: ["PRIORS_AGENT_ID"],
|
|
3453
3473
|
limitVars: [
|
|
@@ -3498,7 +3518,7 @@ var init_known_servers = __esm({
|
|
|
3498
3518
|
id: "oak",
|
|
3499
3519
|
vendor: "Oak",
|
|
3500
3520
|
label: "Oak Agent Kit (a local wallet and tools for Robinhood Chain projects)",
|
|
3501
|
-
matches: (t) => !!t.mcp && t.mcp.transport === "stdio" && (isOakCommand(t.mcp.command) && t.mcp.args[0] === "mcp" || t.mcp.args.some((
|
|
3521
|
+
matches: (t) => !!t.mcp && t.mcp.transport === "stdio" && (isOakCommand(t.mcp.command) && t.mcp.args[0] === "mcp" || t.mcp.args.some(isPackageArg("@oakagentkit/addon"))),
|
|
3502
3522
|
keyVars: [],
|
|
3503
3523
|
emptyOkEnv: [],
|
|
3504
3524
|
limitVars: ["OAK_AUTO_DAILY_CAP_USD"],
|
|
@@ -3548,7 +3568,7 @@ var init_known_servers = __esm({
|
|
|
3548
3568
|
id: "hedgehood",
|
|
3549
3569
|
vendor: "Hedgehood",
|
|
3550
3570
|
label: "Hedgehood (an options market for AI agents on Robinhood Chain)",
|
|
3551
|
-
matches: (t) => !!t.mcp && (isHedgehoodCommand(t.mcp.command) || t.mcp.args.some((
|
|
3571
|
+
matches: (t) => !!t.mcp && (isHedgehoodCommand(t.mcp.command) || t.mcp.args.some(isPackageArg("@hedgehood-io/mcp")) || isHedgehoodHost(t.mcp.url)),
|
|
3552
3572
|
// Both the file and the raw form of a key may be set (the file wins), so keys are handled in apply().
|
|
3553
3573
|
keyVars: [],
|
|
3554
3574
|
emptyOkEnv: [],
|
|
@@ -3611,6 +3631,7 @@ var init_known_servers = __esm({
|
|
|
3611
3631
|
}
|
|
3612
3632
|
}
|
|
3613
3633
|
};
|
|
3634
|
+
BRAINCHAIN_PKG = /^brainchain-mcp(@(latest|next|\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?))?$/;
|
|
3614
3635
|
isBrainChainCommand = (command) => !!command && /(^|[\\/])brainchain-mcp(\.cmd|\.exe)?$/i.test(command);
|
|
3615
3636
|
literal = (t, k) => {
|
|
3616
3637
|
const v = t.mcp?.env[k];
|
|
@@ -3627,7 +3648,7 @@ var init_known_servers = __esm({
|
|
|
3627
3648
|
id: "brainchain",
|
|
3628
3649
|
vendor: "BrainChain",
|
|
3629
3650
|
label: "BrainChain (verified AI work, paid on Robinhood Chain or Base)",
|
|
3630
|
-
matches: (t) => !!t.mcp && t.mcp.transport === "stdio" && (isBrainChainCommand(t.mcp.command) || t.mcp.args.some((a) =>
|
|
3651
|
+
matches: (t) => !!t.mcp && t.mcp.transport === "stdio" && (isBrainChainCommand(t.mcp.command) || t.mcp.args.some((a) => BRAINCHAIN_PKG.test(a))),
|
|
3631
3652
|
keyVars: ["BRAINCHAIN_PAYER_KEY_FILE", "BRAINCHAIN_PAYER_KEY"],
|
|
3632
3653
|
emptyOkEnv: [],
|
|
3633
3654
|
limitVars: ["BRAINCHAIN_MAX_PRICE_UNITS", "BRAINCHAIN_BUDGET_UNITS", "BRAINCHAIN_DAILY_UNITS", "BRAINCHAIN_MAX_BOND_UNITS", "BRAINCHAIN_STATE_DIR"],
|
|
@@ -3679,7 +3700,7 @@ var init_known_servers = __esm({
|
|
|
3679
3700
|
if (optionalKeys.length) {
|
|
3680
3701
|
out2.manualSteps.push(`"${t.name}" can only pay with its wallet key: make sure ${optionalKeys.join(" or ")} is set for it on ${platform}. Without it the server starts and reads, but cannot post or bond tasks.`);
|
|
3681
3702
|
}
|
|
3682
|
-
const pkg = mcp.args.find((a) =>
|
|
3703
|
+
const pkg = mcp.args.find((a) => BRAINCHAIN_PKG.test(a)) ?? "brainchain-mcp";
|
|
3683
3704
|
const prefix = `${testnet ? "BRAINCHAIN_NETWORK=testnet " : ""}${base ? "BRAINCHAIN_PAY_ON=base " : ""}BRAINCHAIN_PAYER_KEY_FILE=<key file>`;
|
|
3684
3705
|
if (!base) out2.manualSteps.push(`Paying in USDG needs a one-time approval per wallet. If this wallet has not paid BrainChain in USDG before, run in your own terminal: ${prefix} npx -y ${pkg} approve`);
|
|
3685
3706
|
out2.manualSteps.push(`Check the wallet before the agent pays: ${prefix} npx -y ${pkg} wallet (it prints the wallet and what it still needs, never the key).`);
|
|
@@ -3817,6 +3838,9 @@ function skillToFiles(skill, baseRel, extraFrontmatter = {}) {
|
|
|
3817
3838
|
}
|
|
3818
3839
|
return files;
|
|
3819
3840
|
}
|
|
3841
|
+
function isPlainCliWord(s, allow = "name") {
|
|
3842
|
+
return allow === "name" ? /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/.test(s) : /^[A-Za-z0-9][A-Za-z0-9._@\/:+-]{0,255}$/.test(s);
|
|
3843
|
+
}
|
|
3820
3844
|
function safeName2(s) {
|
|
3821
3845
|
return s.replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^[-.]+|[-.]+$/g, "") || "item";
|
|
3822
3846
|
}
|
|
@@ -4075,6 +4099,20 @@ function mcpServersFromTools(tools, opts) {
|
|
|
4075
4099
|
if (trust === "untrusted") {
|
|
4076
4100
|
out2.unsupported.push({ category: "permissions", item: `${t.name}: Hermes asked before every call that is not read-only (trust: untrusted)`, reason: "Destination approvals are not copied.", alternative: `Set ${opts.platformName} to ask before using "${t.name}" tools, before using real funds.` });
|
|
4077
4101
|
}
|
|
4102
|
+
const oc = t.extensions?.["x-openclaw"];
|
|
4103
|
+
if (oc && opts.platformName !== "OpenClaw") {
|
|
4104
|
+
const filter = oc.toolFilter;
|
|
4105
|
+
const list = (v) => Array.isArray(v) ? v.map(String).join(", ") : "";
|
|
4106
|
+
if (filter && (list(filter.include) || list(filter.exclude))) {
|
|
4107
|
+
out2.unsupported.push({
|
|
4108
|
+
category: "permissions",
|
|
4109
|
+
item: `${t.name}: OpenClaw limited the tools the agent could use from this server (${[list(filter.include) && `only ${list(filter.include)}`, list(filter.exclude) && `not ${list(filter.exclude)}`].filter(Boolean).join("; ")})`,
|
|
4110
|
+
reason: `Nomad does not write a per-server tool filter on ${opts.platformName}, so every tool of this server is available there.`,
|
|
4111
|
+
alternative: `Block the tools you do not want in ${opts.platformName}'s permissions or approvals.`
|
|
4112
|
+
});
|
|
4113
|
+
}
|
|
4114
|
+
if (oc.auth === "oauth") out2.manualSteps.push(`Sign in to the "${t.name}" MCP server in ${opts.platformName}: it signs in with OAuth on OpenClaw, and sign-ins are not copied.`);
|
|
4115
|
+
}
|
|
4078
4116
|
const mcp = t.mcp;
|
|
4079
4117
|
const s = {};
|
|
4080
4118
|
if (mcp.transport === "stdio") {
|
|
@@ -4804,7 +4842,9 @@ async function planMain(doc, ctx, L) {
|
|
|
4804
4842
|
const info = doc.integrations.find((i) => i.kind === "claude-code-plugin" && i.name === id)?.config;
|
|
4805
4843
|
const marketName = id.split("@")[1];
|
|
4806
4844
|
const market = typeof info?.marketplaceRepo === "string" ? info.marketplaceRepo : (marketName && KNOWN_MARKETPLACE_REPOS[marketName]) ?? marketName ?? "<marketplace>";
|
|
4807
|
-
manualSteps.push(
|
|
4845
|
+
manualSteps.push(
|
|
4846
|
+
isPlainCliWord(id, "path") && isPlainCliWord(market, "path") ? `Install the plugin ${id} in Claude Code: /plugin marketplace add ${market}, then /plugin install ${id}. Nomad does not copy plugin servers or skills.` : `Install the plugin ${JSON.stringify(id)} in Claude Code from its marketplace. Nomad prints no command for it, because its name has characters a terminal could misread, and does not copy plugin servers or skills.`
|
|
4847
|
+
);
|
|
4808
4848
|
}
|
|
4809
4849
|
if (wants(ctx, "skills")) {
|
|
4810
4850
|
for (const s of doc.skills.filter((x) => !pluginOf(x, P))) {
|
|
@@ -5317,6 +5357,15 @@ var init_codex = __esm({
|
|
|
5317
5357
|
// ../../packages/adapters/src/openclaw.ts
|
|
5318
5358
|
import { basename as basename5, join as join6, relative as relative2 } from "path";
|
|
5319
5359
|
import JSON5 from "json5";
|
|
5360
|
+
function openclawSettingsOf(cfg) {
|
|
5361
|
+
const out2 = {};
|
|
5362
|
+
for (const k of OPENCLAW_SERVER_SETTINGS) if (cfg[k] !== void 0) out2[k] = cfg[k];
|
|
5363
|
+
if (cfg.oauth !== void 0) out2.hadOauthOverrides = true;
|
|
5364
|
+
return Object.keys(out2).length && !hasVar(JSON.stringify(out2)) ? out2 : null;
|
|
5365
|
+
}
|
|
5366
|
+
function launchUsesVar(t) {
|
|
5367
|
+
return !!t.mcp && (hasVar(t.mcp.command) || hasVar(t.mcp.url) || t.mcp.args.some(hasVar));
|
|
5368
|
+
}
|
|
5320
5369
|
function openclawServersForRead(raw) {
|
|
5321
5370
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return {};
|
|
5322
5371
|
const out2 = {};
|
|
@@ -5563,7 +5612,12 @@ async function readAgent(root, agentId, notes, prefer) {
|
|
|
5563
5612
|
});
|
|
5564
5613
|
}
|
|
5565
5614
|
doc.skills.push(...await readSkillsTree(join6(ws, "skills"), P3, notes, 1));
|
|
5566
|
-
|
|
5615
|
+
const rawServers = cfg?.mcp?.servers && typeof cfg.mcp.servers === "object" ? cfg.mcp.servers : {};
|
|
5616
|
+
for (const t of toolsFromMcpServers(openclawServersForRead(rawServers), P3, "openclaw.json")) {
|
|
5617
|
+
const settings2 = rawServers[t.name] && typeof rawServers[t.name] === "object" ? openclawSettingsOf(rawServers[t.name]) : null;
|
|
5618
|
+
if (settings2) t.extensions = { ...t.extensions, "x-openclaw": settings2 };
|
|
5619
|
+
doc.tools.push(t);
|
|
5620
|
+
}
|
|
5567
5621
|
const m = modelOf(cfg, agentId);
|
|
5568
5622
|
if (m.primary) doc.models.preferred = m.primary;
|
|
5569
5623
|
doc.models.fallbacks = m.fallbacks;
|
|
@@ -5725,13 +5779,40 @@ ${m.content.trim()}
|
|
|
5725
5779
|
const mcpTools = doc.tools.filter((t) => t.kind === "mcp" && t.mcp && !pluginOf(t, P3));
|
|
5726
5780
|
if (mcpTools.length) {
|
|
5727
5781
|
const r = mcpServersFromTools(mcpTools, { platformName: "OpenClaw", envRefStyle: "none" });
|
|
5782
|
+
const setStep = (name, field, k, why) => {
|
|
5783
|
+
const label = field === "env" ? `${k}` : `the ${k} header`;
|
|
5784
|
+
manualSteps.push(
|
|
5785
|
+
isPlainCliWord(name) && isPlainCliWord(k) ? `Set ${label} for the "${name}" MCP server in OpenClaw${why}: openclaw config set mcp.servers.${name}.${field}.${k} <value>` : `Set ${label} for the MCP server ${JSON.stringify(name)} in OpenClaw${why}, under mcp.servers in openclaw.json. Nomad prints no command for it, because its name has characters a terminal could misread.`
|
|
5786
|
+
);
|
|
5787
|
+
};
|
|
5728
5788
|
for (const [name, server] of Object.entries(r.servers)) {
|
|
5729
5789
|
const tool = mcpTools.find((t) => t.name === name);
|
|
5790
|
+
if (hasVar(server.command) || hasVar(server.url) || Array.isArray(server.args) && server.args.some(hasVar)) {
|
|
5791
|
+
delete r.servers[name];
|
|
5792
|
+
unsupported.push({ category: "tools", item: name, reason: "Its command line or address uses a ${...} variable, which an older OpenClaw refuses to load when the variable is unset.", alternative: "Add it yourself with openclaw mcp set, with the variable's value filled in." });
|
|
5793
|
+
continue;
|
|
5794
|
+
}
|
|
5730
5795
|
if (tool?.mcp?.transport === "http") server.transport = "streamable-http";
|
|
5731
5796
|
else if (tool?.mcp?.transport === "sse") server.transport = "sse";
|
|
5797
|
+
const oc = tool?.extensions?.["x-openclaw"];
|
|
5798
|
+
if (oc) {
|
|
5799
|
+
for (const k of OPENCLAW_SERVER_SETTINGS) if (oc[k] !== void 0) server[k] = oc[k];
|
|
5800
|
+
if (oc.auth === "oauth") manualSteps.push(isPlainCliWord(name) ? `Sign in to the "${name}" MCP server again: openclaw mcp login ${name} (sign-ins are not copied).` : `Sign in to the MCP server ${JSON.stringify(name)} again in OpenClaw (sign-ins are not copied).`);
|
|
5801
|
+
if (oc.hadOauthOverrides) manualSteps.push(`The "${name}" MCP server had OAuth overrides in openclaw.json (scope, redirect or client metadata). Nomad does not copy them; add them again if you need them.`);
|
|
5802
|
+
}
|
|
5732
5803
|
const refs = r.refs[name];
|
|
5733
|
-
for (const k of refs?.env ?? [])
|
|
5734
|
-
for (const [h] of refs?.headers ?? [])
|
|
5804
|
+
for (const k of refs?.env ?? []) setStep(name, "env", k, refs.optional.includes(k) ? " (optional on the source: only if you use it)" : "");
|
|
5805
|
+
for (const [h] of refs?.headers ?? []) setStep(name, "headers", h, "");
|
|
5806
|
+
for (const field of ["env", "headers"]) {
|
|
5807
|
+
const rec = server[field];
|
|
5808
|
+
if (!rec) continue;
|
|
5809
|
+
for (const [k, v] of Object.entries(rec)) {
|
|
5810
|
+
if (!hasVar(v)) continue;
|
|
5811
|
+
delete rec[k];
|
|
5812
|
+
setStep(name, field, k, ` (on the source it was ${JSON.stringify(v)}, which uses a variable)`);
|
|
5813
|
+
}
|
|
5814
|
+
if (!Object.keys(rec).length) delete server[field];
|
|
5815
|
+
}
|
|
5735
5816
|
}
|
|
5736
5817
|
if (Object.keys(r.servers).length) {
|
|
5737
5818
|
cfgPatch.mcp = { servers: r.servers };
|
|
@@ -5752,7 +5833,7 @@ ${m.content.trim()}
|
|
|
5752
5833
|
if (newEntry) notes.push({ level: "info", message: `A new agent "${agentId}" with its own workspace will be created. Restart the gateway to load it.` });
|
|
5753
5834
|
return { nativeId: agentId, files, notes, manualSteps, conversions, unsupported };
|
|
5754
5835
|
}
|
|
5755
|
-
var P3, OC_TOOLS, CAP_TOOLS, openclawAdapter;
|
|
5836
|
+
var P3, hasVar, OPENCLAW_SERVER_SETTINGS, OC_TOOLS, CAP_TOOLS, openclawAdapter;
|
|
5756
5837
|
var init_openclaw = __esm({
|
|
5757
5838
|
"../../packages/adapters/src/openclaw.ts"() {
|
|
5758
5839
|
"use strict";
|
|
@@ -5761,6 +5842,8 @@ var init_openclaw = __esm({
|
|
|
5761
5842
|
init_catalog();
|
|
5762
5843
|
init_util();
|
|
5763
5844
|
P3 = "openclaw";
|
|
5845
|
+
hasVar = (v) => typeof v === "string" && /\$\{[^}]*\}/.test(v.replace(/\$\$\{/g, ""));
|
|
5846
|
+
OPENCLAW_SERVER_SETTINGS = ["toolFilter", "codex", "auth", "requestTimeoutMs", "connectionTimeoutMs", "supportsParallelToolCalls"];
|
|
5764
5847
|
OC_TOOLS = {
|
|
5765
5848
|
exec: "shell",
|
|
5766
5849
|
process: "shell",
|
|
@@ -5840,7 +5923,7 @@ var init_openclaw = __esm({
|
|
|
5840
5923
|
const missing = doc.skills.filter((s) => !pluginOf(s, this.info.id) && !names.has(s.name));
|
|
5841
5924
|
checks.push({ name: "Skills written", ok: !missing.length, detail: missing.length ? `Missing: ${missing.map((s) => s.name).join(", ")}` : void 0 });
|
|
5842
5925
|
}
|
|
5843
|
-
const servers = doc.tools.filter((t) => t.kind === "mcp" && t.mcp && t.enabled !== false && !pluginOf(t, this.info.id));
|
|
5926
|
+
const servers = doc.tools.filter((t) => t.kind === "mcp" && t.mcp && t.enabled !== false && !pluginOf(t, this.info.id) && !launchUsesVar(t));
|
|
5844
5927
|
if (wants(ctx, "tools") && servers.length) {
|
|
5845
5928
|
const names = new Set(got.tools.map((t) => t.name));
|
|
5846
5929
|
const missing = servers.filter((t) => !names.has(t.name));
|
|
@@ -6144,7 +6227,9 @@ ${m.content.trim()}
|
|
|
6144
6227
|
}
|
|
6145
6228
|
const fromPlugins = new Set([...doc.tools, ...doc.skills].map((x) => pluginOf(x, P4)).filter((x) => !!x));
|
|
6146
6229
|
for (const name of fromPlugins) {
|
|
6147
|
-
manualSteps.push(
|
|
6230
|
+
manualSteps.push(
|
|
6231
|
+
isPlainCliWord(name, "path") ? `Install and enable the Hermes plugin ${name}: "hermes plugins install ${name}", then "hermes plugins enable ${name}" (portable plugins install disabled). Nomad does not copy plugin servers or skills into config.yaml or skills/.` : `Install and enable the Hermes plugin ${JSON.stringify(name)} from where you got it. Nomad prints no command for it, because its name has characters a terminal could misread, and does not copy plugin servers or skills.`
|
|
6232
|
+
);
|
|
6148
6233
|
}
|
|
6149
6234
|
if (wants(ctx, "skills")) {
|
|
6150
6235
|
for (const s of doc.skills.filter((x) => !pluginOf(x, P4))) {
|
|
@@ -7416,6 +7501,7 @@ __export(src_exports2, {
|
|
|
7416
7501
|
infoById: () => infoById,
|
|
7417
7502
|
instructionsText: () => instructionsText,
|
|
7418
7503
|
integrationStep: () => integrationStep,
|
|
7504
|
+
isPlainCliWord: () => isPlainCliWord,
|
|
7419
7505
|
join: () => join10,
|
|
7420
7506
|
knownElizaosPlugin: () => knownElizaosPlugin,
|
|
7421
7507
|
knownServerId: () => knownServerId,
|
|
@@ -8503,6 +8589,15 @@ var init_engine = __esm({
|
|
|
8503
8589
|
if (commands.length && changing.length) approvalsRequired.push("run-commands");
|
|
8504
8590
|
const notes = [...loaded.notes, ...planned.notes];
|
|
8505
8591
|
if (components2.includes("skills")) notes.push(...knownSkillNotes(doc.skills, adapter.info.id, adapter.info.displayName));
|
|
8592
|
+
if (req.source.kind === "package" && (loaded.signer?.state === "unsigned" || loaded.signer?.state === "unknown")) {
|
|
8593
|
+
notes.push({ level: "warning", message: `${loaded.signer.state === "unsigned" ? "This package is not signed" : "This package is signed by a key you have not trusted"}, so Nomad cannot tell who made it. Move it only if you trust where it came from, and read the preview before you approve.` });
|
|
8594
|
+
}
|
|
8595
|
+
if (req.source.kind !== "location") {
|
|
8596
|
+
const plugins = [...new Set([...doc.tools, ...doc.skills].map((x) => x.source?.pluginHost === adapter.info.id && typeof x.source?.plugin === "string" ? x.source.plugin : null).filter((x) => !!x))];
|
|
8597
|
+
if (plugins.length) {
|
|
8598
|
+
notes.push({ level: "warning", message: `The plugin install steps below come from ${req.source.kind === "package" ? "a package" : "the Nomad library"}: whoever made it chose the plugin and marketplace names (${plugins.join(", ")}). Check that they are the ones you expect before you install anything.` });
|
|
8599
|
+
}
|
|
8600
|
+
}
|
|
8506
8601
|
if (!(await adapter.detect(root)).detected && adapter.info.support !== "GUIDED") {
|
|
8507
8602
|
notes.push({ level: "info", message: `${adapter.info.displayName} was not detected at ${displayPath(root)}. Nomad will create the files there.` });
|
|
8508
8603
|
}
|
|
@@ -8523,7 +8618,7 @@ var init_engine = __esm({
|
|
|
8523
8618
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8524
8619
|
kind: req.kind ?? "migrate",
|
|
8525
8620
|
agent: { id: doc.id, name: doc.name, version: loaded.version },
|
|
8526
|
-
source: { label: loaded.label, adapter: loaded.sourceAdapter?.info.id ?? null, root: req.source.kind === "location" ? resolveRoot(req.source.root) : void 0, nativeId: req.source.kind === "location" ? req.source.nativeId : void 0 },
|
|
8621
|
+
source: { label: loaded.label, adapter: loaded.sourceAdapter?.info.id ?? null, root: req.source.kind === "location" ? resolveRoot(req.source.root) : void 0, nativeId: req.source.kind === "location" ? req.source.nativeId : void 0, ...loaded.signer ? { signer: loaded.signer.state } : {} },
|
|
8527
8622
|
destination: { adapter: adapter.info.id, displayName: adapter.info.displayName, root, nativeId: planned.nativeId, support: adapter.info.support, guided: adapter.info.support === "GUIDED" },
|
|
8528
8623
|
mode,
|
|
8529
8624
|
components: components2,
|
|
@@ -9036,8 +9131,8 @@ __export(src_exports4, {
|
|
|
9036
9131
|
});
|
|
9037
9132
|
import { McpServer as McpServer2 } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
9038
9133
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
9039
|
-
import { readFileSync as
|
|
9040
|
-
import { join as
|
|
9134
|
+
import { readFileSync as readFileSync5 } from "fs";
|
|
9135
|
+
import { join as join19, resolve as resolve6 } from "path";
|
|
9041
9136
|
import { z as z4 } from "zod";
|
|
9042
9137
|
function text2(data) {
|
|
9043
9138
|
return { content: [{ type: "text", text: typeof data === "string" ? data : JSON.stringify(data, null, 2) }] };
|
|
@@ -9070,9 +9165,9 @@ function summarizePlan(p) {
|
|
|
9070
9165
|
};
|
|
9071
9166
|
}
|
|
9072
9167
|
function createMcpServer(options = {}) {
|
|
9073
|
-
const nomad = new Nomad({ home: options.home ?
|
|
9168
|
+
const nomad = new Nomad({ home: options.home ? resolve6(options.home) : nomadHome() });
|
|
9074
9169
|
const server = new McpServer2({ name: "nomad", version: NOMAD_VERSION });
|
|
9075
|
-
const exportsDir =
|
|
9170
|
+
const exportsDir = join19(nomad.store.home, "exports");
|
|
9076
9171
|
server.registerTool(
|
|
9077
9172
|
"list_agents",
|
|
9078
9173
|
{ title: "List agents", description: "Agents in the local Nomad library with their known locations.", inputSchema: {} },
|
|
@@ -9142,9 +9237,9 @@ function createMcpServer(options = {}) {
|
|
|
9142
9237
|
{ title: "Validate a package", description: "Check a .nomad, .agentpack or .jetpack package for structure, integrity and security problems.", inputSchema: { path: z4.string().describe("Path to a package file") } },
|
|
9143
9238
|
async ({ path }) => {
|
|
9144
9239
|
try {
|
|
9145
|
-
const p =
|
|
9240
|
+
const p = resolve6(expandHome(path));
|
|
9146
9241
|
if (!/\.(nomad|agentpack|jetpack)$/.test(p)) throw new NomadError("Only .nomad, .agentpack or .jetpack files can be validated.", "usage");
|
|
9147
|
-
const r = nomad.validatePackage(new Uint8Array(
|
|
9242
|
+
const r = nomad.validatePackage(new Uint8Array(readFileSync5(p)));
|
|
9148
9243
|
return text2({ ok: r.ok, name: r.doc?.name, issues: r.issues, warnings: r.warnings, secretsFound: r.scan?.findings.length ?? 0 });
|
|
9149
9244
|
} catch (e) {
|
|
9150
9245
|
return fail(e);
|
|
@@ -9267,10 +9362,10 @@ init_src6();
|
|
|
9267
9362
|
import { Command, Option } from "commander";
|
|
9268
9363
|
import { createInterface } from "readline/promises";
|
|
9269
9364
|
import { spawn as spawn2 } from "child_process";
|
|
9270
|
-
import { existsSync as
|
|
9271
|
-
import { dirname as
|
|
9365
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync4, writeFileSync as writeFileSync4 } from "fs";
|
|
9366
|
+
import { dirname as dirname7, join as join20, resolve as resolve7 } from "path";
|
|
9272
9367
|
import { fileURLToPath } from "url";
|
|
9273
|
-
import { randomBytes as
|
|
9368
|
+
import { randomBytes as randomBytes4 } from "crypto";
|
|
9274
9369
|
|
|
9275
9370
|
// src/format.ts
|
|
9276
9371
|
var NPM_NAME = "thenomad";
|
|
@@ -9402,6 +9497,7 @@ function summaryText(p) {
|
|
|
9402
9497
|
if (p.conversions.length) lines.push(`Adapted: ${p.conversions.map((c2) => `${c2.item} ${dim("\u2192 " + c2.to)}`).join("; ")}.`);
|
|
9403
9498
|
if (p.unsupported.length) lines.push(yellow(`Can't move: ${p.unsupported.map((u) => u.item).join(", ")}`) + dim(" (kept in the report with setup steps)"));
|
|
9404
9499
|
if (p.disabledRoutines.length) lines.push(`Routines arrive paused: ${p.disabledRoutines.join(", ")}.`);
|
|
9500
|
+
if (p.source.signer === "unsigned" || p.source.signer === "unknown") lines.push(yellow(p.source.signer === "unsigned" ? "Not signed: Nomad cannot tell who made this package. Move it only if you trust where it came from." : "Signed by a key you have not trusted: Nomad cannot tell who made this package."));
|
|
9405
9501
|
for (const c2 of p.commands ?? []) lines.push(yellow(`Starts by itself on ${p.destination.displayName}: "${c2.tool}" runs ${c2.command}`) + (c2.env.length ? dim(` (with ${c2.env.join(", ")} set)`) : ""));
|
|
9406
9502
|
if (p.secrets.findings || p.secrets.strippedEnv.length) {
|
|
9407
9503
|
const parts = [p.secrets.findings ? `${p.secrets.findings} found in text and removed` : "", p.secrets.strippedEnv.length ? `you will reconnect ${p.secrets.strippedEnv.map((s) => s.split(":")[1]).join(", ")}` : ""].filter(Boolean);
|
|
@@ -9432,14 +9528,14 @@ function shellQuote(s) {
|
|
|
9432
9528
|
return `'${s.replace(/'/g, `'\\''`)}'`;
|
|
9433
9529
|
}
|
|
9434
9530
|
function run(cmd, args, input) {
|
|
9435
|
-
return new Promise((
|
|
9531
|
+
return new Promise((resolve8, reject) => {
|
|
9436
9532
|
const p = spawn(cmd, args, { stdio: ["pipe", "pipe", "pipe"] });
|
|
9437
9533
|
let stdout = "";
|
|
9438
9534
|
let stderr = "";
|
|
9439
9535
|
p.stdout.on("data", (d) => stdout += d);
|
|
9440
9536
|
p.stderr.on("data", (d) => stderr += d);
|
|
9441
9537
|
p.on("error", (e) => reject(new NomadError(`${cmd} is not available: ${e.message}`, "ssh-missing", "Install OpenSSH to use remote migration.")));
|
|
9442
|
-
p.on("close", (code) =>
|
|
9538
|
+
p.on("close", (code) => resolve8({ code: code ?? 1, stdout, stderr }));
|
|
9443
9539
|
if (input) p.stdin.end(input);
|
|
9444
9540
|
else p.stdin.end();
|
|
9445
9541
|
});
|
|
@@ -9478,8 +9574,8 @@ async function remoteMigrate(o, packagePath, args) {
|
|
|
9478
9574
|
|
|
9479
9575
|
// src/ui.ts
|
|
9480
9576
|
import { createServer } from "http";
|
|
9481
|
-
import { existsSync as
|
|
9482
|
-
import { extname, join as
|
|
9577
|
+
import { existsSync as existsSync6, readFileSync as readFileSync4, statSync as statSync3 } from "fs";
|
|
9578
|
+
import { extname, join as join18, normalize, resolve as resolve5, sep as sep4 } from "path";
|
|
9483
9579
|
|
|
9484
9580
|
// ../../packages/local/src/index.ts
|
|
9485
9581
|
import { timingSafeEqual } from "crypto";
|
|
@@ -9697,6 +9793,203 @@ async function handleLocalApi(req, ctx, path) {
|
|
|
9697
9793
|
}
|
|
9698
9794
|
}
|
|
9699
9795
|
|
|
9796
|
+
// src/install.ts
|
|
9797
|
+
init_src2();
|
|
9798
|
+
import { spawnSync } from "child_process";
|
|
9799
|
+
import { createHash, randomBytes as randomBytes3 } from "crypto";
|
|
9800
|
+
import { chmodSync as chmodSync2, cpSync, existsSync as existsSync5, mkdirSync as mkdirSync3, readdirSync, readFileSync as readFileSync3, renameSync, rmSync, statSync as statSync2, writeFileSync as writeFileSync3 } from "fs";
|
|
9801
|
+
import { basename as basename11, dirname as dirname6, join as join17, resolve as resolve4 } from "path";
|
|
9802
|
+
var REPO = "kadiri-seer/nomad";
|
|
9803
|
+
var VERSION_RE = /^\d+\.\d+\.\d+$/;
|
|
9804
|
+
function currentInstall(execPath = process.execPath) {
|
|
9805
|
+
const appDir = dirname6(execPath);
|
|
9806
|
+
if (basename11(dirname6(appDir)) !== "app" || !VERSION_RE.test(basename11(appDir))) return null;
|
|
9807
|
+
const root = dirname6(dirname6(appDir));
|
|
9808
|
+
try {
|
|
9809
|
+
const info = JSON.parse(readFileSync3(join17(root, "install.json"), "utf8"));
|
|
9810
|
+
if (info.by !== "nomad-installer" || typeof info.target !== "string" || !/^(windows|macos|linux)-(x64|arm64)$/.test(info.target)) return null;
|
|
9811
|
+
return { root, target: info.target, version: basename11(appDir) };
|
|
9812
|
+
} catch {
|
|
9813
|
+
return null;
|
|
9814
|
+
}
|
|
9815
|
+
}
|
|
9816
|
+
function newer(a, b) {
|
|
9817
|
+
const pa = a.split(".").map(Number);
|
|
9818
|
+
const pb = b.split(".").map(Number);
|
|
9819
|
+
for (let i = 0; i < 3; i++) if (pa[i] !== pb[i]) return pa[i] > pb[i];
|
|
9820
|
+
return false;
|
|
9821
|
+
}
|
|
9822
|
+
function assetName(target) {
|
|
9823
|
+
return `nomad-${target}.${target.startsWith("windows") ? "zip" : "tar.gz"}`;
|
|
9824
|
+
}
|
|
9825
|
+
function checksumFor(sums, name) {
|
|
9826
|
+
for (const line of sums.split(/\r?\n/)) {
|
|
9827
|
+
const m = /^([0-9a-fA-F]{64})\s+\*?(\S+)\s*$/.exec(line);
|
|
9828
|
+
if (m && m[2] === name) return m[1].toLowerCase();
|
|
9829
|
+
}
|
|
9830
|
+
return null;
|
|
9831
|
+
}
|
|
9832
|
+
async function get(url) {
|
|
9833
|
+
const host = new URL(url).host;
|
|
9834
|
+
let r;
|
|
9835
|
+
try {
|
|
9836
|
+
r = await fetch(url, { headers: { "User-Agent": `nomad/${NOMAD_VERSION}`, Accept: host === "api.github.com" ? "application/vnd.github+json" : "*/*" }, redirect: "follow", ...host === "api.github.com" ? { signal: AbortSignal.timeout(3e4) } : {} });
|
|
9837
|
+
} catch {
|
|
9838
|
+
throw new Error(`Could not reach ${host}. Check your connection and try again.`);
|
|
9839
|
+
}
|
|
9840
|
+
if (r.status === 404 && host === "api.github.com") throw new Error("No Nomad release was found on GitHub. Try again later.");
|
|
9841
|
+
if (!r.ok) throw new Error(`Could not reach ${host} (HTTP ${r.status}). Try again later.`);
|
|
9842
|
+
return r;
|
|
9843
|
+
}
|
|
9844
|
+
async function latestVersion() {
|
|
9845
|
+
const data = await (await get(`https://api.github.com/repos/${REPO}/releases/latest`)).json();
|
|
9846
|
+
const tag = typeof data.tag_name === "string" ? data.tag_name : "";
|
|
9847
|
+
if (!/^v\d+\.\d+\.\d+$/.test(tag)) throw new Error("GitHub returned an unexpected release name. Try again later.");
|
|
9848
|
+
return tag.slice(1);
|
|
9849
|
+
}
|
|
9850
|
+
function switchedVersion(install) {
|
|
9851
|
+
try {
|
|
9852
|
+
const v = readFileSync3(join17(install.root, "current"), "utf8").trim();
|
|
9853
|
+
if (VERSION_RE.test(v) && newer(v, install.version)) return v;
|
|
9854
|
+
} catch {
|
|
9855
|
+
}
|
|
9856
|
+
return install.version;
|
|
9857
|
+
}
|
|
9858
|
+
async function checkForUpdate(install = currentInstall()) {
|
|
9859
|
+
if (!install) return { installed: false, current: NOMAD_VERSION };
|
|
9860
|
+
const current2 = switchedVersion(install);
|
|
9861
|
+
const latest = await latestVersion();
|
|
9862
|
+
return { installed: true, current: current2, latest, available: newer(latest, current2) };
|
|
9863
|
+
}
|
|
9864
|
+
function systemTar() {
|
|
9865
|
+
if (process.platform === "win32") return join17(process.env.SystemRoot ?? "C:\\Windows", "System32", "tar.exe");
|
|
9866
|
+
for (const p of ["/usr/bin/tar", "/bin/tar"]) if (existsSync5(p)) return p;
|
|
9867
|
+
return "tar";
|
|
9868
|
+
}
|
|
9869
|
+
function renameWithRetry(from, to) {
|
|
9870
|
+
for (let i = 0; ; i++) {
|
|
9871
|
+
try {
|
|
9872
|
+
return renameSync(from, to);
|
|
9873
|
+
} catch (e) {
|
|
9874
|
+
const code = e.code;
|
|
9875
|
+
if (i >= 40 || code !== "EPERM" && code !== "EBUSY" && code !== "EACCES") throw e;
|
|
9876
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 500);
|
|
9877
|
+
}
|
|
9878
|
+
}
|
|
9879
|
+
}
|
|
9880
|
+
function removeQuietly(p) {
|
|
9881
|
+
try {
|
|
9882
|
+
rmSync(p, { recursive: true, force: true, maxRetries: 3, retryDelay: 200 });
|
|
9883
|
+
} catch {
|
|
9884
|
+
}
|
|
9885
|
+
}
|
|
9886
|
+
var powershell = () => join17(process.env.SystemRoot ?? "C:\\Windows", "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
|
|
9887
|
+
function startPowerShell(script, env) {
|
|
9888
|
+
const ps = powershell();
|
|
9889
|
+
const launch = "Start-Process -FilePath $env:NOMAD_PS -ArgumentList '-NoProfile','-NonInteractive','-ExecutionPolicy','Bypass','-EncodedCommand',$env:NOMAD_PS_SCRIPT -WindowStyle Hidden";
|
|
9890
|
+
const r = spawnSync(ps, ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", launch], {
|
|
9891
|
+
env: { ...process.env, ...env, NOMAD_PS: ps, NOMAD_PS_SCRIPT: Buffer.from(script, "utf16le").toString("base64") },
|
|
9892
|
+
stdio: "ignore",
|
|
9893
|
+
windowsHide: true,
|
|
9894
|
+
timeout: 6e4
|
|
9895
|
+
});
|
|
9896
|
+
return r.status === 0;
|
|
9897
|
+
}
|
|
9898
|
+
function removeAfterExit(dir) {
|
|
9899
|
+
if (process.platform !== "win32") return;
|
|
9900
|
+
startPowerShell(`Wait-Process -Id ${process.pid} -ErrorAction SilentlyContinue; Start-Sleep -Seconds 2; Remove-Item -LiteralPath $env:NOMAD_OLD_DIR -Recurse -Force -ErrorAction SilentlyContinue`, { NOMAD_OLD_DIR: dir });
|
|
9901
|
+
}
|
|
9902
|
+
function takeLock(root) {
|
|
9903
|
+
const lock = join17(root, "update.lock");
|
|
9904
|
+
try {
|
|
9905
|
+
if (Date.now() - statSync2(lock).mtimeMs > 15 * 60 * 1e3) rmSync(lock, { recursive: true, force: true });
|
|
9906
|
+
} catch {
|
|
9907
|
+
}
|
|
9908
|
+
try {
|
|
9909
|
+
mkdirSync3(lock);
|
|
9910
|
+
} catch {
|
|
9911
|
+
throw new Error("Another Nomad update is running. Try again in a few minutes.");
|
|
9912
|
+
}
|
|
9913
|
+
return () => removeQuietly(lock);
|
|
9914
|
+
}
|
|
9915
|
+
async function applyUpdate(install, version, log = () => void 0) {
|
|
9916
|
+
if (!VERSION_RE.test(version)) throw new Error(`Not a version: ${version}`);
|
|
9917
|
+
if (switchedVersion(install) === version && existsSync5(join17(install.root, "app", version))) return version;
|
|
9918
|
+
const asset = assetName(install.target);
|
|
9919
|
+
const base = `https://github.com/${REPO}/releases/download/v${version}`;
|
|
9920
|
+
const unlock = takeLock(install.root);
|
|
9921
|
+
const work = join17(install.root, `tmp-${randomBytes3(6).toString("hex")}`);
|
|
9922
|
+
mkdirSync3(work, { recursive: true });
|
|
9923
|
+
try {
|
|
9924
|
+
log(`Downloading Nomad ${version}...`);
|
|
9925
|
+
const sums = await (await get(`${base}/SHA256SUMS`)).text();
|
|
9926
|
+
const expected = checksumFor(sums, asset);
|
|
9927
|
+
if (!expected) throw new Error(`The release has no fingerprint for ${asset}. Nothing was changed.`);
|
|
9928
|
+
const bytes2 = Buffer.from(await (await get(`${base}/${asset}`)).arrayBuffer());
|
|
9929
|
+
const actual = createHash("sha256").update(bytes2).digest("hex");
|
|
9930
|
+
if (actual !== expected) throw new Error("The download does not match its published fingerprint. Nothing was changed.");
|
|
9931
|
+
log("Fingerprint checked.");
|
|
9932
|
+
const archive = join17(work, asset);
|
|
9933
|
+
writeFileSync3(archive, bytes2);
|
|
9934
|
+
const staged = join17(work, "app");
|
|
9935
|
+
mkdirSync3(staged);
|
|
9936
|
+
const x = spawnSync(systemTar(), [install.target.startsWith("windows") ? "-xf" : "-xzf", archive, "-C", staged], { stdio: "pipe" });
|
|
9937
|
+
if (x.status !== 0) throw new Error(`Could not unpack the download: ${String(x.stderr ?? x.error ?? "").trim()}`);
|
|
9938
|
+
const node = join17(staged, process.platform === "win32" ? "node.exe" : "node");
|
|
9939
|
+
const check = spawnSync(node, [join17(staged, "node_modules", "thenomad", "dist", "nomad.js"), "--version"], { encoding: "utf8", timeout: 6e4 });
|
|
9940
|
+
if (check.status !== 0 || check.stdout.trim() !== version) throw new Error(`The new version did not start correctly. Nothing was changed.${check.stderr ? `
|
|
9941
|
+
${check.stderr.trim()}` : ""}`);
|
|
9942
|
+
const target = join17(install.root, "app", version);
|
|
9943
|
+
if (resolve4(target) === resolve4(dirname6(process.execPath))) throw new Error(`Nomad ${version} is the version running now.`);
|
|
9944
|
+
removeQuietly(target);
|
|
9945
|
+
renameWithRetry(staged, target);
|
|
9946
|
+
const launcher = join17(target, "launcher");
|
|
9947
|
+
if (existsSync5(launcher)) {
|
|
9948
|
+
for (const f of readdirSync(launcher)) {
|
|
9949
|
+
cpSync(join17(launcher, f), join17(install.root, "bin", f), { force: true });
|
|
9950
|
+
if (process.platform !== "win32" && !f.endsWith(".png") && !f.endsWith(".icns")) chmodSync2(join17(install.root, "bin", f), 493);
|
|
9951
|
+
}
|
|
9952
|
+
}
|
|
9953
|
+
const next = join17(install.root, `current.${randomBytes3(4).toString("hex")}`);
|
|
9954
|
+
writeFileSync3(next, version);
|
|
9955
|
+
renameSync(next, join17(install.root, "current"));
|
|
9956
|
+
const infoPath = join17(install.root, "install.json");
|
|
9957
|
+
const info = JSON.parse(readFileSync3(infoPath, "utf8"));
|
|
9958
|
+
writeFileSync3(infoPath, JSON.stringify({ ...info, version, updated: (/* @__PURE__ */ new Date()).toISOString() }, null, 2) + "\n");
|
|
9959
|
+
if (process.platform === "win32") {
|
|
9960
|
+
const reg = join17(process.env.SystemRoot ?? "C:\\Windows", "System32", "reg.exe");
|
|
9961
|
+
spawnSync(reg, ["add", "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\thenomad.website", "/v", "DisplayVersion", "/t", "REG_SZ", "/d", version, "/f"], { stdio: "ignore" });
|
|
9962
|
+
}
|
|
9963
|
+
const running = resolve4(dirname6(process.execPath));
|
|
9964
|
+
for (const v of readdirSync(join17(install.root, "app"))) {
|
|
9965
|
+
const dir = resolve4(install.root, "app", v);
|
|
9966
|
+
if (v === version) continue;
|
|
9967
|
+
if (dir === running) removeAfterExit(dir);
|
|
9968
|
+
else removeQuietly(dir);
|
|
9969
|
+
}
|
|
9970
|
+
return version;
|
|
9971
|
+
} finally {
|
|
9972
|
+
removeQuietly(work);
|
|
9973
|
+
unlock();
|
|
9974
|
+
}
|
|
9975
|
+
}
|
|
9976
|
+
function runUninstaller(install, opts) {
|
|
9977
|
+
if (process.platform === "win32") {
|
|
9978
|
+
const script2 = join17(install.root, "bin", "uninstall.ps1");
|
|
9979
|
+
if (!existsSync5(script2)) return false;
|
|
9980
|
+
return startPowerShell(`& $env:NOMAD_UNINSTALL -Yes -WaitPid ${process.pid} -DataDir $env:NOMAD_DATA_DIR${opts.removeData ? " -RemoveData" : ""}`, {
|
|
9981
|
+
NOMAD_UNINSTALL: script2,
|
|
9982
|
+
NOMAD_DATA_DIR: opts.dataDir
|
|
9983
|
+
});
|
|
9984
|
+
}
|
|
9985
|
+
const script = join17(install.root, "bin", "uninstall.sh");
|
|
9986
|
+
if (!existsSync5(script)) return false;
|
|
9987
|
+
const args = [script, "--yes", "--data-dir", opts.dataDir];
|
|
9988
|
+
if (opts.removeData) args.push("--remove-data");
|
|
9989
|
+
const r = spawnSync("/bin/sh", args, { stdio: "inherit" });
|
|
9990
|
+
return r.status === 0;
|
|
9991
|
+
}
|
|
9992
|
+
|
|
9700
9993
|
// src/ui.ts
|
|
9701
9994
|
var TYPES = {
|
|
9702
9995
|
".html": "text/html; charset=utf-8",
|
|
@@ -9718,8 +10011,8 @@ var SECURITY_HEADERS = {
|
|
|
9718
10011
|
"Permissions-Policy": "camera=(), microphone=(), geolocation=()"
|
|
9719
10012
|
};
|
|
9720
10013
|
function findSite(here) {
|
|
9721
|
-
const candidates = [
|
|
9722
|
-
return candidates.find((d) =>
|
|
10014
|
+
const candidates = [resolve5(here, "../web"), resolve5(here, "../../web/.next-export"), resolve5(process.cwd(), "apps/web/.next-export")];
|
|
10015
|
+
return candidates.find((d) => existsSync6(join18(d, "app.html"))) ?? null;
|
|
9723
10016
|
}
|
|
9724
10017
|
function fileFor(site, pathname) {
|
|
9725
10018
|
let rel;
|
|
@@ -9729,11 +10022,11 @@ function fileFor(site, pathname) {
|
|
|
9729
10022
|
return null;
|
|
9730
10023
|
}
|
|
9731
10024
|
if (rel.includes("\0")) return null;
|
|
9732
|
-
const base = normalize(
|
|
10025
|
+
const base = normalize(join18(site, rel));
|
|
9733
10026
|
if (base !== site && !base.startsWith(site + sep4)) return null;
|
|
9734
|
-
for (const p of [base, `${base}.html`,
|
|
10027
|
+
for (const p of [base, `${base}.html`, join18(base, "index.html")]) {
|
|
9735
10028
|
try {
|
|
9736
|
-
if (
|
|
10029
|
+
if (statSync3(p).isFile()) return p;
|
|
9737
10030
|
} catch {
|
|
9738
10031
|
}
|
|
9739
10032
|
}
|
|
@@ -9768,6 +10061,24 @@ async function send(res, r) {
|
|
|
9768
10061
|
res.writeHead(r.status, headers);
|
|
9769
10062
|
res.end(r.body ? Buffer.from(await r.arrayBuffer()) : void 0);
|
|
9770
10063
|
}
|
|
10064
|
+
async function appUpdate(req, ctx) {
|
|
10065
|
+
const json2 = (body2, status = 200) => new Response(JSON.stringify(body2), { status, headers: { "Content-Type": "application/json", "Cache-Control": "no-store" } });
|
|
10066
|
+
const ok = checkRequest(req, ctx);
|
|
10067
|
+
if (!ok.ok) return json2({ error: ok.error }, ok.status);
|
|
10068
|
+
const install = currentInstall();
|
|
10069
|
+
if (!install) return json2({ installed: false });
|
|
10070
|
+
try {
|
|
10071
|
+
if (req.method === "GET") return json2(new URL(req.url).searchParams.get("check") === "1" ? await checkForUpdate(install) : { installed: true, current: install.version });
|
|
10072
|
+
if (req.method === "POST") {
|
|
10073
|
+
const c2 = await checkForUpdate(install);
|
|
10074
|
+
if (!c2.available || !c2.latest) return json2({ ...c2, updated: false });
|
|
10075
|
+
return json2({ ...c2, updated: true, current: await applyUpdate(install, c2.latest) });
|
|
10076
|
+
}
|
|
10077
|
+
return json2({ error: "Method not allowed." }, 405);
|
|
10078
|
+
} catch (e) {
|
|
10079
|
+
return json2({ error: e.message }, 502);
|
|
10080
|
+
}
|
|
10081
|
+
}
|
|
9771
10082
|
function startUi(opts) {
|
|
9772
10083
|
const { nomad, site, port, token } = opts;
|
|
9773
10084
|
const ctx = { nomad, token, port };
|
|
@@ -9780,6 +10091,7 @@ function startUi(opts) {
|
|
|
9780
10091
|
return;
|
|
9781
10092
|
}
|
|
9782
10093
|
if (url.pathname === "/app/session") return send(res, sessionResponse(await toRequest(req, url), ctx));
|
|
10094
|
+
if (opts.appUpdates && url.pathname === "/api/app/update") return send(res, await appUpdate(await toRequest(req, url), ctx));
|
|
9783
10095
|
if (url.pathname.startsWith("/api/local/")) {
|
|
9784
10096
|
const path2 = url.pathname.slice("/api/local/".length).split("/").filter(Boolean).map(decodeURIComponent);
|
|
9785
10097
|
return send(res, await handleLocalApi(await toRequest(req, url), ctx, path2));
|
|
@@ -9789,11 +10101,11 @@ function startUi(opts) {
|
|
|
9789
10101
|
return;
|
|
9790
10102
|
}
|
|
9791
10103
|
const file = fileFor(site, url.pathname === "/" ? "/index.html" : url.pathname);
|
|
9792
|
-
const path = file ??
|
|
10104
|
+
const path = file ?? join18(site, "404.html");
|
|
9793
10105
|
const type = TYPES[extname(path)] ?? "application/octet-stream";
|
|
9794
10106
|
const immutable = url.pathname.startsWith("/_next/static/");
|
|
9795
10107
|
res.writeHead(file ? 200 : 404, { ...SECURITY_HEADERS, "Content-Type": type, "Cache-Control": immutable ? "public, max-age=31536000, immutable" : "no-cache" });
|
|
9796
|
-
res.end(req.method === "HEAD" ? void 0 :
|
|
10108
|
+
res.end(req.method === "HEAD" ? void 0 : readFileSync4(path));
|
|
9797
10109
|
} catch (e) {
|
|
9798
10110
|
if (!res.headersSent) res.writeHead(500, { "Content-Type": "text/plain" });
|
|
9799
10111
|
res.end(e.message);
|
|
@@ -9828,8 +10140,8 @@ function out() {
|
|
|
9828
10140
|
}
|
|
9829
10141
|
function engine() {
|
|
9830
10142
|
const home2 = program.opts().home;
|
|
9831
|
-
if (home2) process.env.NOMAD_HOME =
|
|
9832
|
-
return new Nomad({ home: home2 ?
|
|
10143
|
+
if (home2) process.env.NOMAD_HOME = resolve7(home2);
|
|
10144
|
+
return new Nomad({ home: home2 ? resolve7(home2) : nomadHome() });
|
|
9833
10145
|
}
|
|
9834
10146
|
function components(list) {
|
|
9835
10147
|
if (!list) return void 0;
|
|
@@ -9958,8 +10270,8 @@ program.command("inspect <source>").description("show what an agent contains (re
|
|
|
9958
10270
|
);
|
|
9959
10271
|
program.command("validate <package>").description("check a package (.nomad, .agentpack or .jetpack) without importing it").action(
|
|
9960
10272
|
(pkg) => run2(async (nomad) => {
|
|
9961
|
-
const { readFileSync:
|
|
9962
|
-
const r = nomad.validatePackage(new Uint8Array(
|
|
10273
|
+
const { readFileSync: readFileSync6 } = await import("fs");
|
|
10274
|
+
const r = nomad.validatePackage(new Uint8Array(readFileSync6(resolve7(pkg))));
|
|
9963
10275
|
const { describeSigner: describeSigner2 } = await Promise.resolve().then(() => (init_src8(), src_exports3));
|
|
9964
10276
|
print(out(), () => r.ok ? [green("Valid package") + ` ${r.doc.name} (${r.doc.id})`, `Format ${r.format}. ${describeSigner2(r.signer)}`, `${r.fileCount} files, ${r.totalBytes} bytes`, ...r.warnings.map((w) => yellow("! ") + w), ...r.scan?.findings.length ? [yellow(`${r.scan.findings.length} secret(s) found in the package`)] : []] : [red("Invalid package"), ...r.issues.map((i) => ` ${i.path}: ${i.message}`)], { ok: r.ok, format: r.format, signer: r.signer, issues: r.issues, warnings: r.warnings, info: r.info, findings: r.scan?.findings ?? [] });
|
|
9965
10277
|
return r.ok ? EXIT.ok : EXIT.invalid;
|
|
@@ -9969,7 +10281,7 @@ program.command("export <source>").description("export an agent to a portable .n
|
|
|
9969
10281
|
(source, o) => run2(async (nomad) => {
|
|
9970
10282
|
const spec = await parseSource(nomad, source, { sourceDir: o.sourceDir, agent: o.agent });
|
|
9971
10283
|
if (o.includeSecrets && !out().json) process.stderr.write(yellow("Warning: secret values will be stored in the package. Share it only with people who may see them.\n"));
|
|
9972
|
-
const r = await nomad.exportAgent(spec, { outPath:
|
|
10284
|
+
const r = await nomad.exportAgent(spec, { outPath: resolve7(o.out), includeSecrets: o.includeSecrets, includeFiles: o.includeFiles, includeSensitiveFiles: o.includeSensitiveFiles, components: components(o.components), format: o.format === "jetpack" ? "interchange" : "nomad", sign: o.sign });
|
|
9973
10285
|
print(out(), () => [green("Exported") + ` ${r.path}`, ...r.receipt.signedBy ? [`Signed with your key ${r.receipt.signedBy}`] : [], ...r.receipt.notIncluded.length ? [yellow(`Not representable in this format: ${r.receipt.notIncluded.join(", ")}`)] : [], `${r.files.size} files, ${r.bytes.length} bytes`, ...r.sanitize.redactedText || r.sanitize.strippedEnvValues.length ? [yellow(`${r.sanitize.redactedText} secret(s) redacted, ${r.sanitize.strippedEnvValues.length} credential(s) replaced by references`)] : [], ...r.sanitize.removedFiles.length ? [yellow(`Left out credential files: ${r.sanitize.removedFiles.join(", ")}`)] : [], ...r.sanitize.walletKeysKept ? [yellow(`Left out ${r.sanitize.walletKeysKept} wallet key(s) or recovery phrase(s): Nomad never stores them as values, even with --include-secrets.`)] : []], r.receipt);
|
|
9974
10286
|
})
|
|
9975
10287
|
);
|
|
@@ -9977,7 +10289,7 @@ approvalOptions(
|
|
|
9977
10289
|
program.command("import <package>").description("import a package into the library, and optionally into a platform").option("--to <platform>", "also write the agent to this platform").option("--dest-dir <dir>", "destination directory").addOption(new Option("--mode <mode>", "conflict handling").choices(["merge", "copy", "replace"]).default("merge")).option("--name <name>", "name for copy mode").option("--components <list>", "only these components")
|
|
9978
10290
|
).action(
|
|
9979
10291
|
(pkg, o) => run2(async (nomad) => {
|
|
9980
|
-
const path =
|
|
10292
|
+
const path = resolve7(pkg);
|
|
9981
10293
|
const r = await nomad.importPackage({ path });
|
|
9982
10294
|
if (!r.ok) {
|
|
9983
10295
|
print(out(), () => [red("The package was rejected"), ...r.issues.map((i) => ` ${i.path}: ${i.message}`)], r);
|
|
@@ -10009,7 +10321,7 @@ approvalOptions(
|
|
|
10009
10321
|
})
|
|
10010
10322
|
);
|
|
10011
10323
|
function parseDestination(spec) {
|
|
10012
|
-
if (/\.(nomad|jetpack)$/i.test(spec)) return { kind: "file", path:
|
|
10324
|
+
if (/\.(nomad|jetpack)$/i.test(spec)) return { kind: "file", path: resolve7(spec.replace(/^~(?=$|\/)/, process.env.HOME ?? "~")) };
|
|
10013
10325
|
const m = /^([a-z0-9-]+)(?::(.*?))?(?:#(.+))?$/.exec(spec);
|
|
10014
10326
|
const adapter = m ? findAdapter(m[1]) : void 0;
|
|
10015
10327
|
if (!adapter || !m) throw new NomadError(`"${spec}" is not a platform or a package file.`, "usage", `Use a platform (${listAdapters().map((a) => a.info.id).slice(0, 5).join(", ")}, ...), a platform with a folder such as claude-code:~/project, or a file ending in .nomad.`);
|
|
@@ -10046,8 +10358,8 @@ program.command("keys").description("show your signing key, and the keys you tru
|
|
|
10046
10358
|
);
|
|
10047
10359
|
program.command("trust <package>").description("trust the key that signed a package").requiredOption("--name <who>", "a name for this key, such as a person or team").action(
|
|
10048
10360
|
(pkg, o) => run2(async (nomad) => {
|
|
10049
|
-
const { readFileSync:
|
|
10050
|
-
const k = nomad.trustPackageSigner(new Uint8Array(
|
|
10361
|
+
const { readFileSync: readFileSync6 } = await import("fs");
|
|
10362
|
+
const k = nomad.trustPackageSigner(new Uint8Array(readFileSync6(resolve7(pkg))), o.name);
|
|
10051
10363
|
print(out(), () => [green("Trusted") + ` ${k.fingerprint} ${k.name}`, dim("Check this fingerprint with them through another channel.")], k);
|
|
10052
10364
|
})
|
|
10053
10365
|
);
|
|
@@ -10155,7 +10467,7 @@ remote.command("push <source>").description("export locally, copy over SSH, and
|
|
|
10155
10467
|
(source, o) => run2(async (nomad) => {
|
|
10156
10468
|
const spec = await parseSource(nomad, source);
|
|
10157
10469
|
const tmp = await makeTempDir("nomad-remote-");
|
|
10158
|
-
const exp = await nomad.exportAgent(spec, { outPath:
|
|
10470
|
+
const exp = await nomad.exportAgent(spec, { outPath: join20(tmp, "agent.nomad") });
|
|
10159
10471
|
const r = await remoteMigrate({ host: o.host, port: o.port ? Number(o.port) : void 0, identity: o.identity, remoteCommand: o.remoteCommand }, exp.path, { to: o.to, dest: o.destDir, mode: o.mode, apply: !!o.apply });
|
|
10160
10472
|
print(out(), () => typeof r.result === "string" ? r.result : r.result.receipt ? receiptText(r.result.receipt) : planText(r.result.plan, out().verbose), r.result);
|
|
10161
10473
|
return r.code;
|
|
@@ -10164,10 +10476,10 @@ remote.command("push <source>").description("export locally, copy over SSH, and
|
|
|
10164
10476
|
program.command("schema").description("write the Universal Agent Format JSON Schemas").option("-o, --out <dir>", "output directory", ".").action(
|
|
10165
10477
|
(o) => run2(async () => {
|
|
10166
10478
|
const s = jsonSchemas();
|
|
10167
|
-
const dir =
|
|
10168
|
-
|
|
10169
|
-
|
|
10170
|
-
|
|
10479
|
+
const dir = resolve7(o.out);
|
|
10480
|
+
mkdirSync4(dir, { recursive: true });
|
|
10481
|
+
writeFileSync4(join20(dir, "agent-document.schema.json"), JSON.stringify(s.agentDocument, null, 2));
|
|
10482
|
+
writeFileSync4(join20(dir, "package-manifest.schema.json"), JSON.stringify(s.packageManifest, null, 2));
|
|
10171
10483
|
print(out(), () => `Wrote schemas to ${dir}`, { dir });
|
|
10172
10484
|
})
|
|
10173
10485
|
);
|
|
@@ -10189,27 +10501,99 @@ program.command("mcp").description("run the Nomad MCP server on stdio").option("
|
|
|
10189
10501
|
const { startMcpServer: startMcpServer2 } = await Promise.resolve().then(() => (init_src9(), src_exports4));
|
|
10190
10502
|
await startMcpServer2({ home: program.opts().home, allowWrites: !!o.allowWrites, allowReplace: !!o.allowReplace && !!o.allowWrites });
|
|
10191
10503
|
});
|
|
10192
|
-
program.command("
|
|
10193
|
-
const
|
|
10194
|
-
|
|
10195
|
-
|
|
10196
|
-
|
|
10504
|
+
program.command("update").description("update Nomad to the newest version (when installed from thenomad.website)").option("--check", "only check whether a newer version exists").option("-y, --yes", "update without asking").action(async (o) => {
|
|
10505
|
+
const install = currentInstall();
|
|
10506
|
+
if (!install) {
|
|
10507
|
+
const npx = process.env.npm_command === "exec";
|
|
10508
|
+
process.stderr.write(
|
|
10509
|
+
npx ? `npx runs the newest version each time, or add @latest: ${bold("npx thenomad@latest")}
|
|
10510
|
+
` : `This copy of Nomad was not installed with the installer from thenomad.website.
|
|
10511
|
+
If you installed it with npm, update with: ${bold("npm install -g thenomad@latest")}
|
|
10512
|
+
`
|
|
10513
|
+
);
|
|
10514
|
+
return;
|
|
10515
|
+
}
|
|
10516
|
+
try {
|
|
10517
|
+
const c2 = await checkForUpdate(install);
|
|
10518
|
+
if (!c2.available) {
|
|
10519
|
+
process.stderr.write(`${green("Nomad is up to date")} (${install.version}).
|
|
10520
|
+
`);
|
|
10521
|
+
return;
|
|
10522
|
+
}
|
|
10523
|
+
process.stderr.write(`Nomad ${bold(c2.latest)} is available. You have ${install.version}.
|
|
10524
|
+
`);
|
|
10525
|
+
if (o.check) return;
|
|
10526
|
+
if (!o.yes && !await confirm("Update now?", true)) {
|
|
10527
|
+
process.exitCode = EXIT.approval;
|
|
10528
|
+
return;
|
|
10529
|
+
}
|
|
10530
|
+
const v = await applyUpdate(install, c2.latest, (l) => process.stderr.write(dim(l) + "\n"));
|
|
10531
|
+
process.stderr.write(`${green("Updated")} to Nomad ${v}. If the dashboard is open, close it and open Nomad again.
|
|
10532
|
+
`);
|
|
10533
|
+
} catch (e) {
|
|
10534
|
+
process.stderr.write(red("Error: ") + e.message + "\n");
|
|
10535
|
+
process.exitCode = EXIT.error;
|
|
10536
|
+
}
|
|
10537
|
+
});
|
|
10538
|
+
program.command("uninstall").description("remove Nomad from this computer (your agents are not touched)").option("-y, --yes", "do not ask; keeps your library, backups and history").option("--remove-data", "also delete the library, backups and history").action(async (o) => {
|
|
10539
|
+
const install = currentInstall();
|
|
10540
|
+
const dataDir = program.opts().home ? resolve7(program.opts().home) : nomadHome();
|
|
10541
|
+
if (!install) {
|
|
10542
|
+
process.stderr.write(
|
|
10543
|
+
`This copy of Nomad was not installed with the installer from thenomad.website.
|
|
10544
|
+
If you installed it with npm, remove it with: ${bold("npm uninstall -g thenomad")}
|
|
10545
|
+
Your library, backups and history stay in ${displayPath(dataDir)} until you delete that folder.
|
|
10546
|
+
`
|
|
10547
|
+
);
|
|
10548
|
+
return;
|
|
10549
|
+
}
|
|
10550
|
+
let removeData = !!o.removeData;
|
|
10551
|
+
if (!o.yes) {
|
|
10552
|
+
if (!process.stdin.isTTY) {
|
|
10553
|
+
process.stderr.write(`Run ${bold("nomad uninstall --yes")} to remove Nomad without questions.
|
|
10554
|
+
`);
|
|
10555
|
+
process.exitCode = EXIT.approval;
|
|
10556
|
+
return;
|
|
10557
|
+
}
|
|
10558
|
+
process.stderr.write(`This removes Nomad ${install.version} from ${displayPath(install.root)}, with its shortcut and the nomad command.
|
|
10559
|
+
Your agents are not touched.
|
|
10560
|
+
`);
|
|
10561
|
+
if (!await confirm("Remove Nomad?")) {
|
|
10562
|
+
process.exitCode = EXIT.approval;
|
|
10563
|
+
return;
|
|
10564
|
+
}
|
|
10565
|
+
if (!removeData && existsSync7(join20(dataDir, "nomad.db"))) removeData = await confirm(`Also delete the library, backups and history in ${displayPath(dataDir)}? Backups cannot be restored after this.`);
|
|
10566
|
+
}
|
|
10567
|
+
if (!runUninstaller(install, { removeData, dataDir })) {
|
|
10568
|
+
process.stderr.write(red("Error: ") + `The uninstaller is missing from ${displayPath(join20(install.root, "bin"))}. Delete ${displayPath(install.root)} to remove Nomad.
|
|
10569
|
+
`);
|
|
10570
|
+
process.exitCode = EXIT.error;
|
|
10571
|
+
return;
|
|
10572
|
+
}
|
|
10573
|
+
if (process.platform === "win32") process.stderr.write(`${green("Removing Nomad.")} It will be gone in a few seconds.${removeData ? "" : ` Your library, backups and history stay in ${displayPath(dataDir)}.`}
|
|
10574
|
+
`);
|
|
10575
|
+
});
|
|
10576
|
+
program.command("ui").description("open the dashboard in your browser (only this computer can reach it)").option("-p, --port <port>", "port", "4317").option("--no-open", "do not open a browser").option("--dev", "developers: run the Next.js app from the repository with live reload").addOption(new Option("--app").hideHelp()).action(async (o) => {
|
|
10577
|
+
const here = dirname7(fileURLToPath(import.meta.url));
|
|
10578
|
+
const token = randomBytes4(24).toString("base64url");
|
|
10579
|
+
let port = Number(o.port);
|
|
10580
|
+
let url = `http://127.0.0.1:${port}/app/session?token=${token}`;
|
|
10197
10581
|
const openBrowser = () => {
|
|
10198
10582
|
if (!o.open) return;
|
|
10199
10583
|
const [cmd, args] = process.platform === "darwin" ? ["open", [url]] : process.platform === "win32" ? ["cmd", ["/c", "start", "", url]] : ["xdg-open", [url]];
|
|
10200
10584
|
spawn2(cmd, args, { stdio: "ignore", detached: true }).on("error", () => void 0).unref();
|
|
10201
10585
|
};
|
|
10202
10586
|
if (o.dev) {
|
|
10203
|
-
const webDir = [
|
|
10587
|
+
const webDir = [resolve7(here, "../../web"), resolve7(process.cwd(), "apps/web")].find((d) => existsSync7(join20(d, "package.json")));
|
|
10204
10588
|
if (!webDir) {
|
|
10205
10589
|
process.stderr.write(red("--dev needs the repository checkout.\n"));
|
|
10206
10590
|
process.exitCode = 1;
|
|
10207
10591
|
return;
|
|
10208
10592
|
}
|
|
10209
|
-
const env = { ...process.env, NOMAD_LOCAL: "1", NOMAD_LOCAL_TOKEN: token, NOMAD_HOME: program.opts().home ?
|
|
10593
|
+
const env = { ...process.env, NOMAD_LOCAL: "1", NOMAD_LOCAL_TOKEN: token, NOMAD_HOME: program.opts().home ? resolve7(program.opts().home) : nomadHome(), PORT: String(port) };
|
|
10210
10594
|
process.stderr.write(`${bold("Nomad")} dev server at ${url}
|
|
10211
10595
|
`);
|
|
10212
|
-
const child = spawn2(process.execPath, [
|
|
10596
|
+
const child = spawn2(process.execPath, [join20(webDir, "node_modules", "next", "dist", "bin", "next"), "dev", "-H", "127.0.0.1", "-p", String(port)], { cwd: webDir, env, stdio: ["ignore", "inherit", "inherit"] });
|
|
10213
10597
|
setTimeout(openBrowser, 2500);
|
|
10214
10598
|
child.on("exit", (code) => process.exitCode = code ?? 0);
|
|
10215
10599
|
return;
|
|
@@ -10222,7 +10606,16 @@ program.command("ui").description("open the dashboard in your browser (only this
|
|
|
10222
10606
|
}
|
|
10223
10607
|
const nomad = engine();
|
|
10224
10608
|
try {
|
|
10225
|
-
|
|
10609
|
+
for (let tries = 0; ; tries++) {
|
|
10610
|
+
try {
|
|
10611
|
+
await startUi({ nomad, site, port, token, appUpdates: !!currentInstall() });
|
|
10612
|
+
break;
|
|
10613
|
+
} catch (e) {
|
|
10614
|
+
if (!o.app || tries >= 20 || e.code !== "EADDRINUSE") throw e;
|
|
10615
|
+
port += 1;
|
|
10616
|
+
url = `http://127.0.0.1:${port}/app/session?token=${token}`;
|
|
10617
|
+
}
|
|
10618
|
+
}
|
|
10226
10619
|
} catch (e) {
|
|
10227
10620
|
nomad.close();
|
|
10228
10621
|
const busy = e.code === "EADDRINUSE";
|
|
@@ -10231,9 +10624,11 @@ program.command("ui").description("open the dashboard in your browser (only this
|
|
|
10231
10624
|
process.exitCode = 1;
|
|
10232
10625
|
return;
|
|
10233
10626
|
}
|
|
10234
|
-
process.stderr.write(
|
|
10235
|
-
|
|
10236
|
-
|
|
10627
|
+
process.stderr.write(
|
|
10628
|
+
`${bold("Nomad")} is open at ${url}
|
|
10629
|
+
${dim(o.app ? "Only this computer can reach it. Keep this window open while you use Nomad, and close it to stop." : "Only this computer can reach it. Press Ctrl+C to stop.")}
|
|
10630
|
+
`
|
|
10631
|
+
);
|
|
10237
10632
|
openBrowser();
|
|
10238
10633
|
const stop = () => {
|
|
10239
10634
|
nomad.close();
|
|
@@ -10272,8 +10667,8 @@ async function guided(nomad) {
|
|
|
10272
10667
|
if (items.length === 1) process.stderr.write(dim("No agents were found at the usual places. You can open a package file.") + "\n");
|
|
10273
10668
|
const pick = await choose(rl, "Which agent?", items);
|
|
10274
10669
|
if (pick === "file") {
|
|
10275
|
-
const path =
|
|
10276
|
-
if (!
|
|
10670
|
+
const path = resolve7((await rl.question("Path to the file: ")).trim().replace(/^~(?=$|\/)/, process.env.HOME ?? "~"));
|
|
10671
|
+
if (!existsSync7(path)) throw new NomadError(`There is no file at ${path}.`, "not-found");
|
|
10277
10672
|
source = { kind: "package", path };
|
|
10278
10673
|
from = null;
|
|
10279
10674
|
} else {
|
|
@@ -10295,7 +10690,7 @@ async function guided(nomad) {
|
|
|
10295
10690
|
const name = (await nomad.loadSource(source).catch(() => null))?.doc.name ?? "agent";
|
|
10296
10691
|
const def = `./${name.replace(/[^A-Za-z0-9._-]+/g, "-")}.nomad`;
|
|
10297
10692
|
const a = (await rl.question(`Save to ${dim(`[${def}]`)}: `)).trim();
|
|
10298
|
-
dest = { kind: "file", path:
|
|
10693
|
+
dest = { kind: "file", path: resolve7(a || def) };
|
|
10299
10694
|
} else {
|
|
10300
10695
|
const info = getAdapter(where).info;
|
|
10301
10696
|
const def = info.defaultLocations[0] ?? displayPath(process.cwd());
|