thenomad 0.1.0 → 0.3.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 +1 -1
- package/dist/nomad.js +1309 -273
- package/package.json +2 -2
- package/web/404.html +1 -1
- package/web/__next.__PAGE__.txt +43 -51
- package/web/__next._full.txt +42 -39
- package/web/__next._tree.txt +2 -2
- package/web/_next/static/chunks/1d7qnsfqdlz_u.js +1 -0
- package/web/_next/static/chunks/1p0rmc54l0_3e.js +5 -0
- package/web/_next/static/chunks/1ygp921kjfxbp.css +4 -0
- package/web/_next/static/chunks/1zb0q77s0yui0.js +1 -0
- package/web/_next/static/chunks/{2itrx72tv-gct.js → 240m_9t_ozl62.js} +16 -16
- package/web/_next/static/chunks/2c1swz3f540lq.js +1 -0
- package/web/_next/static/chunks/2gqqo11auvml1.js +1 -0
- package/web/_next/static/chunks/2m8g429r9sjgz.js +7 -0
- package/web/_next/static/chunks/2nr_qzaf1ds_m.js +1 -0
- package/web/_next/static/chunks/2x2dvcjppyahs.js +1 -0
- package/web/_not-found/__next._full.txt +27 -22
- package/web/_not-found/__next._not-found.__PAGE__.txt +30 -34
- package/web/_not-found/__next._tree.txt +2 -2
- package/web/_not-found.html +1 -1
- package/web/_not-found.txt +27 -22
- package/web/app/__next._full.txt +38 -30
- package/web/app/__next._tree.txt +4 -4
- package/web/app/__next.app.__PAGE__.txt +25 -48
- package/web/app/__next.app.txt +27 -0
- package/web/app/agents/__next._full.txt +40 -32
- package/web/app/agents/__next._tree.txt +4 -4
- package/web/app/agents/__next.app.agents.__PAGE__.txt +30 -52
- package/web/app/agents/__next.app.txt +27 -0
- package/web/app/agents/view/__next._full.txt +43 -36
- package/web/app/agents/view/__next._tree.txt +4 -4
- package/web/app/agents/view/__next.app.agents.view.__PAGE__.txt +33 -56
- package/web/app/agents/view/__next.app.txt +27 -0
- package/web/app/agents/view.html +1 -1
- package/web/app/agents/view.txt +43 -36
- package/web/app/agents.html +1 -1
- package/web/app/agents.txt +40 -32
- package/web/app/backups/__next._full.txt +39 -32
- package/web/app/backups/__next._tree.txt +4 -4
- package/web/app/backups/__next.app.backups.__PAGE__.txt +30 -52
- package/web/app/backups/__next.app.txt +27 -0
- package/web/app/backups.html +1 -1
- package/web/app/backups.txt +39 -32
- package/web/app/compatibility/__next._full.txt +40 -33
- package/web/app/compatibility/__next._tree.txt +4 -4
- package/web/app/compatibility/__next.app.compatibility.__PAGE__.txt +31 -53
- package/web/app/compatibility/__next.app.txt +27 -0
- package/web/app/compatibility.html +1 -1
- package/web/app/compatibility.txt +40 -33
- package/web/app/export/__next._full.txt +41 -33
- package/web/app/export/__next._tree.txt +4 -4
- package/web/app/export/__next.app.export.__PAGE__.txt +31 -53
- package/web/app/export/__next.app.txt +27 -0
- package/web/app/export.html +1 -1
- package/web/app/export.txt +41 -33
- package/web/app/history/__next._full.txt +40 -33
- package/web/app/history/__next._tree.txt +4 -4
- package/web/app/history/__next.app.history.__PAGE__.txt +31 -53
- package/web/app/history/__next.app.txt +27 -0
- package/web/app/history.html +1 -1
- package/web/app/history.txt +40 -33
- package/web/app/import/__next._full.txt +40 -32
- package/web/app/import/__next._tree.txt +4 -4
- package/web/app/import/__next.app.import.__PAGE__.txt +30 -52
- package/web/app/import/__next.app.txt +27 -0
- package/web/app/import.html +1 -1
- package/web/app/import.txt +40 -32
- package/web/app/migrate/__next._full.txt +40 -33
- package/web/app/migrate/__next._tree.txt +4 -4
- package/web/app/migrate/__next.app.migrate.__PAGE__.txt +31 -53
- package/web/app/migrate/__next.app.txt +27 -0
- package/web/app/migrate.html +1 -1
- package/web/app/migrate.txt +40 -33
- package/web/app/settings/__next._full.txt +39 -32
- package/web/app/settings/__next._tree.txt +4 -4
- package/web/app/settings/__next.app.settings.__PAGE__.txt +30 -52
- package/web/app/settings/__next.app.txt +27 -0
- package/web/app/settings.html +1 -1
- package/web/app/settings.txt +39 -32
- package/web/app/versions/__next._full.txt +39 -32
- package/web/app/versions/__next._tree.txt +4 -4
- package/web/app/versions/__next.app.txt +27 -0
- package/web/app/versions/__next.app.versions.__PAGE__.txt +30 -52
- package/web/app/versions.html +1 -1
- package/web/app/versions.txt +39 -32
- package/web/app.html +1 -1
- package/web/app.txt +38 -30
- package/web/docs/__next._full.txt +31 -31
- package/web/docs/__next._tree.txt +2 -2
- package/web/docs/__next.docs.__PAGE__.txt +38 -50
- package/web/docs/adapters/__next._full.txt +86 -81
- package/web/docs/adapters/__next._tree.txt +2 -2
- package/web/docs/adapters/__next.docs.adapters.__PAGE__.txt +91 -97
- package/web/docs/adapters.html +1 -1
- package/web/docs/adapters.txt +86 -81
- package/web/docs/format/__next._full.txt +40 -41
- package/web/docs/format/__next._tree.txt +2 -2
- package/web/docs/format/__next.docs.format.__PAGE__.txt +45 -57
- package/web/docs/format.html +2 -2
- package/web/docs/format.txt +40 -41
- package/web/docs/security/__next._full.txt +36 -37
- package/web/docs/security/__next._tree.txt +2 -2
- package/web/docs/security/__next.docs.security.__PAGE__.txt +41 -53
- package/web/docs/security.html +1 -1
- package/web/docs/security.txt +36 -37
- package/web/docs/token/__next._full.txt +52 -0
- package/web/docs/token/__next._tree.txt +6 -0
- package/web/docs/token/__next.docs.token.__PAGE__.txt +55 -0
- package/web/docs/token.html +1 -0
- package/web/docs/token.txt +52 -0
- package/web/docs.html +2 -2
- package/web/docs.txt +31 -31
- package/web/index.html +5 -5
- package/web/index.txt +42 -39
- package/web/inspect/__next._full.txt +29 -28
- package/web/inspect/__next._tree.txt +2 -2
- package/web/inspect/__next.inspect.__PAGE__.txt +32 -39
- package/web/inspect.html +1 -1
- package/web/inspect.txt +29 -28
- package/web/privacy/__next._full.txt +34 -30
- package/web/privacy/__next._tree.txt +2 -2
- package/web/privacy/__next.privacy.__PAGE__.txt +36 -41
- package/web/privacy.html +1 -1
- package/web/privacy.txt +34 -30
- package/web/terms/__next._full.txt +35 -33
- package/web/terms/__next._tree.txt +2 -2
- package/web/terms/__next.terms.__PAGE__.txt +37 -44
- package/web/terms.html +1 -1
- package/web/terms.txt +35 -33
- package/web/vote/__next._full.txt +34 -0
- package/web/vote/__next._tree.txt +5 -0
- package/web/vote/__next.vote.__PAGE__.txt +36 -0
- package/web/vote.html +1 -0
- package/web/vote.txt +34 -0
- package/web/_next/static/chunks/0fh-fhwc4fqmh.js +0 -1
- package/web/_next/static/chunks/0pa_vjzo6qbn_.js +0 -1
- package/web/_next/static/chunks/0r144bat18tjc.css +0 -4
- package/web/_next/static/chunks/0zz4b9f_7-jdc.js +0 -1
- package/web/_next/static/chunks/2-s_pll2nvnpu.js +0 -7
- package/web/_next/static/chunks/245h302r_8ful.js +0 -1
- package/web/_next/static/chunks/2bozyj4tl2bji.js +0 -1
- /package/web/_next/static/{iPPtzTmZOHZrEFsNQeVmA → ZvJnVlnOSb137CZRNRk3Z}/_buildManifest.js +0 -0
- /package/web/_next/static/{iPPtzTmZOHZrEFsNQeVmA → ZvJnVlnOSb137CZRNRk3Z}/_clientMiddlewareManifest.js +0 -0
- /package/web/_next/static/{iPPtzTmZOHZrEFsNQeVmA → ZvJnVlnOSb137CZRNRk3Z}/_ssgManifest.js +0 -0
package/dist/nomad.js
CHANGED
|
@@ -391,8 +391,8 @@ function ulid(now = Date.now()) {
|
|
|
391
391
|
rand[i] = 0;
|
|
392
392
|
}
|
|
393
393
|
} else {
|
|
394
|
-
const
|
|
395
|
-
rand = Array.from(
|
|
394
|
+
const bytes2 = randomBytes(16);
|
|
395
|
+
rand = Array.from(bytes2, (b) => b % 32);
|
|
396
396
|
}
|
|
397
397
|
lastTime = now;
|
|
398
398
|
lastRandom = rand;
|
|
@@ -497,9 +497,9 @@ function sortValue(v) {
|
|
|
497
497
|
}
|
|
498
498
|
return v;
|
|
499
499
|
}
|
|
500
|
-
function base64Encode(
|
|
500
|
+
function base64Encode(bytes2) {
|
|
501
501
|
let s = "";
|
|
502
|
-
for (let i = 0; i <
|
|
502
|
+
for (let i = 0; i < bytes2.length; i += 32768) s += String.fromCharCode(...bytes2.subarray(i, i + 32768));
|
|
503
503
|
return btoa(s);
|
|
504
504
|
}
|
|
505
505
|
function base64Decode(s) {
|
|
@@ -900,10 +900,10 @@ function mergeEntries(existing, incoming, delimiter) {
|
|
|
900
900
|
a.push(e);
|
|
901
901
|
added++;
|
|
902
902
|
}
|
|
903
|
-
const
|
|
903
|
+
const sep5 = delimiter.trim() === delimiter ? `
|
|
904
904
|
${delimiter}
|
|
905
905
|
` : delimiter;
|
|
906
|
-
return { value: a.join(
|
|
906
|
+
return { value: a.join(sep5) + (a.length ? "\n" : ""), added, duplicates };
|
|
907
907
|
}
|
|
908
908
|
var init_merge = __esm({
|
|
909
909
|
"../../packages/core/src/merge.ts"() {
|
|
@@ -923,7 +923,7 @@ var init_src2 = __esm({
|
|
|
923
923
|
init_markdown();
|
|
924
924
|
init_document();
|
|
925
925
|
init_merge();
|
|
926
|
-
NOMAD_VERSION = "0.
|
|
926
|
+
NOMAD_VERSION = "0.3.0";
|
|
927
927
|
NomadError = class extends Error {
|
|
928
928
|
constructor(message, code, hint) {
|
|
929
929
|
super(message);
|
|
@@ -937,8 +937,47 @@ var init_src2 = __esm({
|
|
|
937
937
|
}
|
|
938
938
|
});
|
|
939
939
|
|
|
940
|
+
// ../../packages/core/src/node/keymaterial.ts
|
|
941
|
+
import { realpathSync } from "fs";
|
|
942
|
+
function matches(p) {
|
|
943
|
+
const posix2 = p.replace(/\\/g, "/");
|
|
944
|
+
return KEY_MATERIAL_DIRS.some((re) => re.test(posix2)) || KEY_MATERIAL_FILES.some((re) => re.test(posix2));
|
|
945
|
+
}
|
|
946
|
+
function isKeyMaterialPath(abs) {
|
|
947
|
+
if (matches(abs)) return true;
|
|
948
|
+
try {
|
|
949
|
+
return matches(realpathSync(abs));
|
|
950
|
+
} catch {
|
|
951
|
+
return false;
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
function recordSkippedKeyMaterial(abs) {
|
|
955
|
+
skipped.add(abs);
|
|
956
|
+
}
|
|
957
|
+
function drainSkippedKeyMaterial() {
|
|
958
|
+
const out2 = [...skipped].sort();
|
|
959
|
+
skipped.clear();
|
|
960
|
+
return out2;
|
|
961
|
+
}
|
|
962
|
+
var KEY_MATERIAL_DIRS, KEY_MATERIAL_FILES, skipped;
|
|
963
|
+
var init_keymaterial = __esm({
|
|
964
|
+
"../../packages/core/src/node/keymaterial.ts"() {
|
|
965
|
+
"use strict";
|
|
966
|
+
KEY_MATERIAL_DIRS = [
|
|
967
|
+
/(^|\/)\.priors(\/|$)/,
|
|
968
|
+
/(^|\/)\.config\/priors(\/|$)/,
|
|
969
|
+
/(^|\/)\.local\/state\/priors-mcp(\/|$)/,
|
|
970
|
+
/(^|\/)\.agent001(\/|$)/,
|
|
971
|
+
// Oak Agent Kit: the encrypted wallet (wallet.enc), private notes (*.gloam.enc), the wallet journal and settings.
|
|
972
|
+
/(^|\/)\.oak(\/|$)/
|
|
973
|
+
];
|
|
974
|
+
KEY_MATERIAL_FILES = [/(^|\/)agent(-\d+)?\.key$/];
|
|
975
|
+
skipped = /* @__PURE__ */ new Set();
|
|
976
|
+
}
|
|
977
|
+
});
|
|
978
|
+
|
|
940
979
|
// ../../packages/core/src/node/fs.ts
|
|
941
|
-
import { constants, promises as fsp, lstatSync, existsSync, realpathSync } from "fs";
|
|
980
|
+
import { constants, promises as fsp, lstatSync, existsSync, realpathSync as realpathSync2 } from "fs";
|
|
942
981
|
import { homedir } from "os";
|
|
943
982
|
import { dirname, isAbsolute, join, relative, resolve, sep, posix } from "path";
|
|
944
983
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
@@ -956,7 +995,7 @@ function nomadHome() {
|
|
|
956
995
|
function resolveRoot(p) {
|
|
957
996
|
const abs = resolve(expandHome(p));
|
|
958
997
|
try {
|
|
959
|
-
return
|
|
998
|
+
return realpathSync2(abs);
|
|
960
999
|
} catch {
|
|
961
1000
|
return abs;
|
|
962
1001
|
}
|
|
@@ -975,8 +1014,12 @@ function safeJoin(root, rel) {
|
|
|
975
1014
|
const abs = resolve(root, ...rel.split("/"));
|
|
976
1015
|
const r = relative(root, abs);
|
|
977
1016
|
if (r.startsWith("..") || isAbsolute(r)) throw new UnsafePathError(`Path escapes its root: "${rel}"`);
|
|
1017
|
+
assertNotKeyMaterial(abs);
|
|
978
1018
|
return abs;
|
|
979
1019
|
}
|
|
1020
|
+
function assertNotKeyMaterial(abs) {
|
|
1021
|
+
if (isKeyMaterialPath(abs)) throw new UnsafePathError(`Refusing to touch ${abs}: it can hold wallet keys.`);
|
|
1022
|
+
}
|
|
980
1023
|
function assertNoSymlinks(root, abs) {
|
|
981
1024
|
const r = relative(root, abs);
|
|
982
1025
|
if (r.startsWith("..")) throw new UnsafePathError(`${abs} is outside ${root}`);
|
|
@@ -1017,6 +1060,10 @@ async function isFile(p) {
|
|
|
1017
1060
|
}
|
|
1018
1061
|
}
|
|
1019
1062
|
async function readTextIfExists(p, maxBytes = 10 * 1024 * 1024) {
|
|
1063
|
+
if (isKeyMaterialPath(p)) {
|
|
1064
|
+
if (await pathExists(p)) recordSkippedKeyMaterial(p);
|
|
1065
|
+
return null;
|
|
1066
|
+
}
|
|
1020
1067
|
try {
|
|
1021
1068
|
const st = await fsp.lstat(p);
|
|
1022
1069
|
if (st.isSymbolicLink()) {
|
|
@@ -1045,6 +1092,10 @@ async function walkFiles(root, options = {}) {
|
|
|
1045
1092
|
async function rec(dir, rel, depth) {
|
|
1046
1093
|
if (depth > maxDepth || out2.length >= maxFiles) return;
|
|
1047
1094
|
for (const e of await listDir(dir)) {
|
|
1095
|
+
if (isKeyMaterialPath(join(dir, e.name))) {
|
|
1096
|
+
recordSkippedKeyMaterial(join(dir, e.name));
|
|
1097
|
+
continue;
|
|
1098
|
+
}
|
|
1048
1099
|
if (e.symlink) continue;
|
|
1049
1100
|
const r = rel ? `${rel}/${e.name}` : e.name;
|
|
1050
1101
|
if (options.skip?.(r, e.dir)) continue;
|
|
@@ -1059,6 +1110,7 @@ async function walkFiles(root, options = {}) {
|
|
|
1059
1110
|
return out2;
|
|
1060
1111
|
}
|
|
1061
1112
|
async function atomicWrite(abs, data, mode) {
|
|
1113
|
+
assertNotKeyMaterial(abs);
|
|
1062
1114
|
await fsp.mkdir(dirname(abs), { recursive: true });
|
|
1063
1115
|
const tmp = join(dirname(abs), `.${posix.basename(abs.split(sep).join("/"))}.nomad-tmp-${randomBytes2(6).toString("hex")}`);
|
|
1064
1116
|
const fh = await fsp.open(tmp, constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY, mode ?? 420);
|
|
@@ -1092,7 +1144,7 @@ function displayPath(p) {
|
|
|
1092
1144
|
}
|
|
1093
1145
|
function realHome() {
|
|
1094
1146
|
try {
|
|
1095
|
-
return
|
|
1147
|
+
return realpathSync2(home());
|
|
1096
1148
|
} catch {
|
|
1097
1149
|
return home();
|
|
1098
1150
|
}
|
|
@@ -1101,6 +1153,7 @@ var UnsafePathError;
|
|
|
1101
1153
|
var init_fs = __esm({
|
|
1102
1154
|
"../../packages/core/src/node/fs.ts"() {
|
|
1103
1155
|
"use strict";
|
|
1156
|
+
init_keymaterial();
|
|
1104
1157
|
UnsafePathError = class extends Error {
|
|
1105
1158
|
constructor(message) {
|
|
1106
1159
|
super(message);
|
|
@@ -1115,10 +1168,63 @@ var init_node = __esm({
|
|
|
1115
1168
|
"../../packages/core/src/node/index.ts"() {
|
|
1116
1169
|
"use strict";
|
|
1117
1170
|
init_fs();
|
|
1171
|
+
init_keymaterial();
|
|
1172
|
+
}
|
|
1173
|
+
});
|
|
1174
|
+
|
|
1175
|
+
// ../../packages/security/src/bip39-words.ts
|
|
1176
|
+
var BIP39_ENGLISH;
|
|
1177
|
+
var init_bip39_words = __esm({
|
|
1178
|
+
"../../packages/security/src/bip39-words.ts"() {
|
|
1179
|
+
"use strict";
|
|
1180
|
+
BIP39_ENGLISH = new Set(
|
|
1181
|
+
"abandon ability able about above absent absorb abstract absurd abuse access accident account accuse achieve acid acoustic acquire across act action actor actress actual adapt add addict address adjust admit adult advance advice aerobic affair afford afraid again age agent agree ahead aim air airport aisle alarm album alcohol alert alien all alley allow almost alone alpha already also alter always amateur amazing among amount amused analyst anchor ancient anger angle angry animal ankle announce annual another answer antenna antique anxiety any apart apology appear apple approve april arch arctic area arena argue arm armed armor army around arrange arrest arrive arrow art artefact artist artwork ask aspect assault asset assist assume asthma athlete atom attack attend attitude attract auction audit august aunt author auto autumn average avocado avoid awake aware away awesome awful awkward axis baby bachelor bacon badge bag balance balcony ball bamboo banana banner bar barely bargain barrel base basic basket battle beach bean beauty because become beef before begin behave behind believe below belt bench benefit best betray better between beyond bicycle bid bike bind biology bird birth bitter black blade blame blanket blast bleak bless blind blood blossom blouse blue blur blush board boat body boil bomb bone bonus book boost border boring borrow boss bottom bounce box boy bracket brain brand brass brave bread breeze brick bridge brief bright bring brisk broccoli broken bronze broom brother brown brush bubble buddy budget buffalo build bulb bulk bullet bundle bunker burden burger burst bus business busy butter buyer buzz cabbage cabin cable cactus cage cake call calm camera camp can canal cancel candy cannon canoe canvas canyon capable capital captain car carbon card cargo carpet carry cart case cash casino castle casual cat catalog catch category cattle caught cause caution cave ceiling celery cement census century cereal certain chair chalk champion change chaos chapter charge chase chat cheap check cheese chef cherry chest chicken chief child chimney choice choose chronic chuckle chunk churn cigar cinnamon circle citizen city civil claim clap clarify claw clay clean clerk clever click client cliff climb clinic clip clock clog close cloth cloud clown club clump cluster clutch coach coast coconut code coffee coil coin collect color column combine come comfort comic common company concert conduct confirm congress connect consider control convince cook cool copper copy coral core corn correct cost cotton couch country couple course cousin cover coyote crack cradle craft cram crane crash crater crawl crazy cream credit creek crew cricket crime crisp critic crop cross crouch crowd crucial cruel cruise crumble crunch crush cry crystal cube culture cup cupboard curious current curtain curve cushion custom cute cycle dad damage damp dance danger daring dash daughter dawn day deal debate debris decade december decide decline decorate decrease deer defense define defy degree delay deliver demand demise denial dentist deny depart depend deposit depth deputy derive describe desert design desk despair destroy detail detect develop device devote diagram dial diamond diary dice diesel diet differ digital dignity dilemma dinner dinosaur direct dirt disagree discover disease dish dismiss disorder display distance divert divide divorce dizzy doctor document dog doll dolphin domain donate donkey donor door dose double dove draft dragon drama drastic draw dream dress drift drill drink drip drive drop drum dry duck dumb dune during dust dutch duty dwarf dynamic eager eagle early earn earth easily east easy echo ecology economy edge edit educate effort egg eight either elbow elder electric elegant element elephant elevator elite else embark embody embrace emerge emotion employ empower empty enable enact end endless endorse enemy energy enforce engage engine enhance enjoy enlist enough enrich enroll ensure enter entire entry envelope episode equal equip era erase erode erosion error erupt escape essay essence estate eternal ethics evidence evil evoke evolve exact example excess exchange excite exclude excuse execute exercise exhaust exhibit exile exist exit exotic expand expect expire explain expose express extend extra eye eyebrow fabric face faculty fade faint faith fall false fame family famous fan fancy fantasy farm fashion fat fatal father fatigue fault favorite feature february federal fee feed feel female fence festival fetch fever few fiber fiction field figure file film filter final find fine finger finish fire firm first fiscal fish fit fitness fix flag flame flash flat flavor flee flight flip float flock floor flower fluid flush fly foam focus fog foil fold follow food foot force forest forget fork fortune forum forward fossil foster found fox fragile frame frequent fresh friend fringe frog front frost frown frozen fruit fuel fun funny furnace fury future gadget gain galaxy gallery game gap garage garbage garden garlic garment gas gasp gate gather gauge gaze general genius genre gentle genuine gesture ghost giant gift giggle ginger giraffe girl give glad glance glare glass glide glimpse globe gloom glory glove glow glue goat goddess gold good goose gorilla gospel gossip govern gown grab grace grain grant grape grass gravity great green grid grief grit grocery group grow grunt guard guess guide guilt guitar gun gym habit hair half hammer hamster hand happy harbor hard harsh harvest hat have hawk hazard head health heart heavy hedgehog height hello helmet help hen hero hidden high hill hint hip hire history hobby hockey hold hole holiday hollow home honey hood hope horn horror horse hospital host hotel hour hover hub huge human humble humor hundred hungry hunt hurdle hurry hurt husband hybrid ice icon idea identify idle ignore ill illegal illness image imitate immense immune impact impose improve impulse inch include income increase index indicate indoor industry infant inflict inform inhale inherit initial inject injury inmate inner innocent input inquiry insane insect inside inspire install intact interest into invest invite involve iron island isolate issue item ivory jacket jaguar jar jazz jealous jeans jelly jewel job join joke journey joy judge juice jump jungle junior junk just kangaroo keen keep ketchup key kick kid kidney kind kingdom kiss kit kitchen kite kitten kiwi knee knife knock know lab label labor ladder lady lake lamp language laptop large later latin laugh laundry lava law lawn lawsuit layer lazy leader leaf learn leave lecture left leg legal legend leisure lemon lend length lens leopard lesson letter level liar liberty library license life lift light like limb limit link lion liquid list little live lizard load loan lobster local lock logic lonely long loop lottery loud lounge love loyal lucky luggage lumber lunar lunch luxury lyrics machine mad magic magnet maid mail main major make mammal man manage mandate mango mansion manual maple marble march margin marine market marriage mask mass master match material math matrix matter maximum maze meadow mean measure meat mechanic medal media melody melt member memory mention menu mercy merge merit merry mesh message metal method middle midnight milk million mimic mind minimum minor minute miracle mirror misery miss mistake mix mixed mixture mobile model modify mom moment monitor monkey monster month moon moral more morning mosquito mother motion motor mountain mouse move movie much muffin mule multiply muscle museum mushroom music must mutual myself mystery myth naive name napkin narrow nasty nation nature near neck need negative neglect neither nephew nerve nest net network neutral never news next nice night noble noise nominee noodle normal north nose notable note nothing notice novel now nuclear number nurse nut oak obey object oblige obscure observe obtain obvious occur ocean october odor off offer office often oil okay old olive olympic omit once one onion online only open opera opinion oppose option orange orbit orchard order ordinary organ orient original orphan ostrich other outdoor outer output outside oval oven over own owner oxygen oyster ozone pact paddle page pair palace palm panda panel panic panther paper parade parent park parrot party pass patch path patient patrol pattern pause pave payment peace peanut pear peasant pelican pen penalty pencil people pepper perfect permit person pet phone photo phrase physical piano picnic picture piece pig pigeon pill pilot pink pioneer pipe pistol pitch pizza place planet plastic plate play please pledge pluck plug plunge poem poet point polar pole police pond pony pool popular portion position possible post potato pottery poverty powder power practice praise predict prefer prepare present pretty prevent price pride primary print priority prison private prize problem process produce profit program project promote proof property prosper protect proud provide public pudding pull pulp pulse pumpkin punch pupil puppy purchase purity purpose purse push put puzzle pyramid quality quantum quarter question quick quit quiz quote rabbit raccoon race rack radar radio rail rain raise rally ramp ranch random range rapid rare rate rather raven raw razor ready real reason rebel rebuild recall receive recipe record recycle reduce reflect reform refuse region regret regular reject relax release relief rely remain remember remind remove render renew rent reopen repair repeat replace report require rescue resemble resist resource response result retire retreat return reunion reveal review reward rhythm rib ribbon rice rich ride ridge rifle right rigid ring riot ripple risk ritual rival river road roast robot robust rocket romance roof rookie room rose rotate rough round route royal rubber rude rug rule run runway rural sad saddle sadness safe sail salad salmon salon salt salute same sample sand satisfy satoshi sauce sausage save say scale scan scare scatter scene scheme school science scissors scorpion scout scrap screen script scrub sea search season seat second secret section security seed seek segment select sell seminar senior sense sentence series service session settle setup seven shadow shaft shallow share shed shell sheriff shield shift shine ship shiver shock shoe shoot shop short shoulder shove shrimp shrug shuffle shy sibling sick side siege sight sign silent silk silly silver similar simple since sing siren sister situate six size skate sketch ski skill skin skirt skull slab slam sleep slender slice slide slight slim slogan slot slow slush small smart smile smoke smooth snack snake snap sniff snow soap soccer social sock soda soft solar soldier solid solution solve someone song soon sorry sort soul sound soup source south space spare spatial spawn speak special speed spell spend sphere spice spider spike spin spirit split spoil sponsor spoon sport spot spray spread spring spy square squeeze squirrel stable stadium staff stage stairs stamp stand start state stay steak steel stem step stereo stick still sting stock stomach stone stool story stove strategy street strike strong struggle student stuff stumble style subject submit subway success such sudden suffer sugar suggest suit summer sun sunny sunset super supply supreme sure surface surge surprise surround survey suspect sustain swallow swamp swap swarm swear sweet swift swim swing switch sword symbol symptom syrup system table tackle tag tail talent talk tank tape target task taste tattoo taxi teach team tell ten tenant tennis tent term test text thank that theme then theory there they thing this thought three thrive throw thumb thunder ticket tide tiger tilt timber time tiny tip tired tissue title toast tobacco today toddler toe together toilet token tomato tomorrow tone tongue tonight tool tooth top topic topple torch tornado tortoise toss total tourist toward tower town toy track trade traffic tragic train transfer trap trash travel tray treat tree trend trial tribe trick trigger trim trip trophy trouble truck true truly trumpet trust truth try tube tuition tumble tuna tunnel turkey turn turtle twelve twenty twice twin twist two type typical ugly umbrella unable unaware uncle uncover under undo unfair unfold unhappy uniform unique unit universe unknown unlock until unusual unveil update upgrade uphold upon upper upset urban urge usage use used useful useless usual utility vacant vacuum vague valid valley valve van vanish vapor various vast vault vehicle velvet vendor venture venue verb verify version very vessel veteran viable vibrant vicious victory video view village vintage violin virtual virus visa visit visual vital vivid vocal voice void volcano volume vote voyage wage wagon wait walk wall walnut want warfare warm warrior wash wasp waste water wave way wealth weapon wear weasel weather web wedding weekend weird welcome west wet whale what wheat wheel when where whip whisper wide width wife wild will win window wine wing wink winner winter wire wisdom wise wish witness wolf woman wonder wood wool word work world worry worth wrap wreck wrestle wrist write wrong yard year yellow you young youth zebra zero zone zoo".split(" ")
|
|
1182
|
+
);
|
|
1118
1183
|
}
|
|
1119
1184
|
});
|
|
1120
1185
|
|
|
1121
1186
|
// ../../packages/security/src/secrets.ts
|
|
1187
|
+
function isMnemonic(value) {
|
|
1188
|
+
const words = value.trim().split(/\s+/);
|
|
1189
|
+
return [12, 15, 18, 21, 24].includes(words.length) && words.every((w) => BIP39_ENGLISH.has(w));
|
|
1190
|
+
}
|
|
1191
|
+
function isPublicRpcUrl(value) {
|
|
1192
|
+
try {
|
|
1193
|
+
const u = new URL(value.trim());
|
|
1194
|
+
return (u.protocol === "https:" || u.protocol === "wss:") && !u.username && !u.password && !u.search && (u.pathname === "/" || u.pathname === "") && PUBLIC_RPC_HOSTS.has(u.hostname);
|
|
1195
|
+
} catch {
|
|
1196
|
+
return false;
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
function isRpcEnvKey(key2) {
|
|
1200
|
+
return /(^|_)RPC(_URL)?$/i.test(key2);
|
|
1201
|
+
}
|
|
1202
|
+
function scanMcpLaunchFields(tool, fields) {
|
|
1203
|
+
const out2 = [];
|
|
1204
|
+
const check = (where, text3) => {
|
|
1205
|
+
out2.push(...scanText(text3, where));
|
|
1206
|
+
EVM_KEY.lastIndex = 0;
|
|
1207
|
+
let m;
|
|
1208
|
+
while (m = EVM_KEY.exec(text3)) {
|
|
1209
|
+
if (out2.some((f) => f.file === where && f.fingerprint === sha256(m[0]).slice(0, 12))) continue;
|
|
1210
|
+
out2.push({ ruleId: "evm-private-key", ruleName: "Wallet private key", file: where, line: 1, column: m.index + 1, fingerprint: sha256(m[0]).slice(0, 12), preview: `${m[0].length} characters` });
|
|
1211
|
+
}
|
|
1212
|
+
};
|
|
1213
|
+
(fields.args ?? []).forEach((a, i) => check(`tools/${tool}/args[${i}]`, a));
|
|
1214
|
+
for (const [k, v] of Object.entries(fields.env ?? {})) check(`tools/${tool}/env/${k}`, v);
|
|
1215
|
+
if (fields.url) check(`tools/${tool}/url`, fields.url);
|
|
1216
|
+
for (const [k, v] of Object.entries(fields.headers ?? {})) check(`tools/${tool}/headers/${k}`, v);
|
|
1217
|
+
return out2;
|
|
1218
|
+
}
|
|
1219
|
+
function redactLaunchField(text3) {
|
|
1220
|
+
const r = redactText(text3);
|
|
1221
|
+
let count = r.count;
|
|
1222
|
+
const out2 = r.text.replace(EVM_KEY, () => {
|
|
1223
|
+
count++;
|
|
1224
|
+
return "[REDACTED:evm-private-key]";
|
|
1225
|
+
});
|
|
1226
|
+
return { text: out2, count };
|
|
1227
|
+
}
|
|
1122
1228
|
function shannonEntropy(s) {
|
|
1123
1229
|
if (!s) return 0;
|
|
1124
1230
|
const freq = /* @__PURE__ */ new Map();
|
|
@@ -1152,6 +1258,7 @@ function rawMatches(text3) {
|
|
|
1152
1258
|
if (!value) continue;
|
|
1153
1259
|
if (PLACEHOLDER.test(value)) continue;
|
|
1154
1260
|
if (rule2.minEntropy && shannonEntropy(value) < rule2.minEntropy) continue;
|
|
1261
|
+
if (rule2.validate && !rule2.validate(value)) continue;
|
|
1155
1262
|
const start = m.index + (g === 0 ? 0 : m[0].indexOf(value));
|
|
1156
1263
|
const end = start + value.length;
|
|
1157
1264
|
if (found.some((f) => start < f.end && end > f.start)) continue;
|
|
@@ -1187,23 +1294,42 @@ function scanText(text3, file) {
|
|
|
1187
1294
|
});
|
|
1188
1295
|
}
|
|
1189
1296
|
function redactText(text3) {
|
|
1190
|
-
const
|
|
1191
|
-
if (!
|
|
1297
|
+
const matches2 = rawMatches(text3);
|
|
1298
|
+
if (!matches2.length) return { text: text3, count: 0 };
|
|
1192
1299
|
let out2 = "";
|
|
1193
1300
|
let last = 0;
|
|
1194
|
-
for (const m of
|
|
1301
|
+
for (const m of matches2) {
|
|
1195
1302
|
out2 += text3.slice(last, m.start) + `[REDACTED:${m.rule.id}]`;
|
|
1196
1303
|
last = m.end;
|
|
1197
1304
|
}
|
|
1198
1305
|
out2 += text3.slice(last);
|
|
1199
|
-
return { text: out2, count:
|
|
1306
|
+
return { text: out2, count: matches2.length };
|
|
1200
1307
|
}
|
|
1201
|
-
var SECRET_RULES, PLACEHOLDER, SENSITIVE_FILE_PATTERNS, SENSITIVE_ENV_KEY;
|
|
1308
|
+
var EVM_KEY, SECRET_RULES, PLACEHOLDER, SENSITIVE_FILE_PATTERNS, SENSITIVE_ENV_KEY, PUBLIC_RPC_HOSTS;
|
|
1202
1309
|
var init_secrets = __esm({
|
|
1203
1310
|
"../../packages/security/src/secrets.ts"() {
|
|
1204
1311
|
"use strict";
|
|
1205
1312
|
init_src2();
|
|
1313
|
+
init_bip39_words();
|
|
1314
|
+
EVM_KEY = /\b0x[0-9a-fA-F]{64}\b/g;
|
|
1206
1315
|
SECRET_RULES = [
|
|
1316
|
+
// A 0x-prefixed 32-byte hex value is a wallet key when the text around it says so.
|
|
1317
|
+
// Without that context it is usually a transaction or block hash, so it is left alone
|
|
1318
|
+
// here; launch arguments, URLs and headers of MCP servers are checked without context
|
|
1319
|
+
// (scanMcpLaunchFields).
|
|
1320
|
+
{
|
|
1321
|
+
id: "evm-private-key",
|
|
1322
|
+
name: "Wallet private key",
|
|
1323
|
+
pattern: /(?:private|secret|signer|wallet|\bkey\b|_key\b|-key\b)[^\n]{0,40}?\b(0x[0-9a-fA-F]{64})\b/gi,
|
|
1324
|
+
group: 1
|
|
1325
|
+
},
|
|
1326
|
+
{
|
|
1327
|
+
id: "bip39-mnemonic",
|
|
1328
|
+
name: "Wallet recovery phrase",
|
|
1329
|
+
pattern: /(?<![a-z] ?)\b([a-z]{3,8}(?:[ \t]+[a-z]{3,8}){11,23})\b(?! ?[a-z])/g,
|
|
1330
|
+
group: 1,
|
|
1331
|
+
validate: isMnemonic
|
|
1332
|
+
},
|
|
1207
1333
|
{ id: "private-key", name: "Private key block", pattern: /-----BEGIN (?:RSA |EC |OPENSSH |DSA |PGP |ENCRYPTED )?PRIVATE KEY(?: BLOCK)?-----[\s\S]*?(?:-----END[^-]*-----|$)/g },
|
|
1208
1334
|
{ id: "anthropic-key", name: "Anthropic API key", pattern: /\bsk-ant-[A-Za-z0-9_-]{20,}/g },
|
|
1209
1335
|
{ id: "openrouter-key", name: "OpenRouter API key", pattern: /\bsk-or-v1-[A-Za-z0-9]{32,}/g },
|
|
@@ -1222,7 +1348,7 @@ var init_secrets = __esm({
|
|
|
1222
1348
|
{
|
|
1223
1349
|
id: "generic-assignment",
|
|
1224
1350
|
name: "Credential assignment",
|
|
1225
|
-
pattern: /\b(?:password|passwd|pwd|secret|api[_-]?key|apikey|access[_-]?token|auth[_-]?token|client[_-]?secret|bearer)\b["']?\s*[:=]\s*["']?([^\s"'`,;]{8,})/gi,
|
|
1351
|
+
pattern: /\b(?:password|passwd|pwd|secret|api[_-]?key|apikey|access[_-]?token|auth[_-]?token|client[_-]?secret|bearer|private[_-]?key|mnemonic|seed[_ -]?phrase)\b["']?\s*[:=]\s*["']?([^\s"'`,;]{8,})/gi,
|
|
1226
1352
|
group: 1,
|
|
1227
1353
|
minEntropy: 3.2
|
|
1228
1354
|
}
|
|
@@ -1237,13 +1363,27 @@ var init_secrets = __esm({
|
|
|
1237
1363
|
/(^|\/)\.pypirc$/,
|
|
1238
1364
|
/(^|\/)(credentials|secrets?)(\.[a-z]+)?$/i,
|
|
1239
1365
|
/(^|\/)auth(-profiles)?\.json$/i,
|
|
1240
|
-
/(^|\/)\.git-credentials
|
|
1366
|
+
/(^|\/)\.git-credentials$/,
|
|
1367
|
+
// Wallet files kept by agent tools.
|
|
1368
|
+
/(^|\/)\.agent001\/wallet\.(json|enc)$/i,
|
|
1369
|
+
/(^|\/)\.config\/priors\/.+/i
|
|
1241
1370
|
];
|
|
1242
|
-
SENSITIVE_ENV_KEY = /(KEY|TOKEN|SECRET|PASSWORD|PASSWD|CREDENTIAL|AUTH|PRIVATE|COOKIE|SESSION|BEARER)/i;
|
|
1371
|
+
SENSITIVE_ENV_KEY = /(KEY|TOKEN|SECRET|PASSWORD|PASSWD|CREDENTIAL|AUTH|PRIVATE|COOKIE|SESSION|BEARER|MNEMONIC|SEED|WALLET|PASSPHRASE|KEYSTORE)/i;
|
|
1372
|
+
PUBLIC_RPC_HOSTS = /* @__PURE__ */ new Set([
|
|
1373
|
+
"rpc.mainnet.chain.robinhood.com",
|
|
1374
|
+
"rpc.testnet.chain.robinhood.com",
|
|
1375
|
+
"robinhood-rpc.publicnode.com",
|
|
1376
|
+
"rpc.ordofi.network",
|
|
1377
|
+
"mainnet.base.org"
|
|
1378
|
+
]);
|
|
1243
1379
|
}
|
|
1244
1380
|
});
|
|
1245
1381
|
|
|
1246
1382
|
// ../../packages/security/src/document.ts
|
|
1383
|
+
function isSecretEnvEntry(key2, value) {
|
|
1384
|
+
if (isSensitiveEnvKey(key2) || looksLikeSecretValue(value) || EVM_KEY_VALUE.test(value)) return true;
|
|
1385
|
+
return isRpcEnvKey(key2) && !isPublicRpcUrl(value);
|
|
1386
|
+
}
|
|
1247
1387
|
function visitText(doc, fn) {
|
|
1248
1388
|
if (doc.identity.persona) fn("identity/persona.md", doc.identity.persona);
|
|
1249
1389
|
if (doc.identity.description) fn("identity/description", doc.identity.description);
|
|
@@ -1257,10 +1397,6 @@ function visitText(doc, fn) {
|
|
|
1257
1397
|
for (const w of doc.workflows) {
|
|
1258
1398
|
for (const a of w.actions) if (a.kind === "prompt") fn(`workflows/${w.id}.prompt`, a.text);
|
|
1259
1399
|
}
|
|
1260
|
-
for (const t of doc.tools) {
|
|
1261
|
-
if (t.mcp?.args?.length) fn(`tools/${t.name}/args`, t.mcp.args.join(" "));
|
|
1262
|
-
if (t.mcp?.url) fn(`tools/${t.name}/url`, t.mcp.url);
|
|
1263
|
-
}
|
|
1264
1400
|
for (const it of doc.integrations) fn(`integrations/${it.name}.json`, JSON.stringify(it.config));
|
|
1265
1401
|
for (const f of doc.files) if (f.encoding === "utf8") fn(`files/${f.path}`, f.content);
|
|
1266
1402
|
}
|
|
@@ -1272,6 +1408,11 @@ function scanDocument(doc) {
|
|
|
1272
1408
|
for (const s of doc.skills)
|
|
1273
1409
|
for (const f of s.files)
|
|
1274
1410
|
if (isSensitiveFile(f.path)) sensitiveFiles.push({ file: `skills/${s.name}/${f.path}`, reason: "Credential or key file" });
|
|
1411
|
+
for (const t of doc.tools) {
|
|
1412
|
+
if (!t.mcp) continue;
|
|
1413
|
+
const literal = (rec) => Object.fromEntries(Object.entries(rec).flatMap(([k, v]) => "value" in v ? [[k, v.value]] : []));
|
|
1414
|
+
findings.push(...scanMcpLaunchFields(t.name, { args: t.mcp.args, url: t.mcp.url, headers: literal(t.mcp.headers) }).filter((f) => !f.file.includes("/headers/")));
|
|
1415
|
+
}
|
|
1275
1416
|
const inlineSecretValues = [];
|
|
1276
1417
|
for (const t of doc.tools) {
|
|
1277
1418
|
for (const [loc, rec] of [
|
|
@@ -1279,7 +1420,7 @@ function scanDocument(doc) {
|
|
|
1279
1420
|
["headers", t.mcp?.headers ?? {}]
|
|
1280
1421
|
]) {
|
|
1281
1422
|
for (const [k, v] of Object.entries(rec)) {
|
|
1282
|
-
if ("value" in v && (
|
|
1423
|
+
if ("value" in v && isSecretEnvEntry(k, v.value)) {
|
|
1283
1424
|
inlineSecretValues.push({ tool: t.name, key: k, location: loc });
|
|
1284
1425
|
}
|
|
1285
1426
|
}
|
|
@@ -1295,7 +1436,7 @@ function scanDocument(doc) {
|
|
|
1295
1436
|
function stripRecord(tool, rec, report) {
|
|
1296
1437
|
const out2 = {};
|
|
1297
1438
|
for (const [k, v] of Object.entries(rec)) {
|
|
1298
|
-
if ("value" in v && (
|
|
1439
|
+
if ("value" in v && isSecretEnvEntry(k, v.value)) {
|
|
1299
1440
|
out2[k] = { secretRef: k, redacted: true };
|
|
1300
1441
|
report.strippedEnvValues.push({ tool, key: k });
|
|
1301
1442
|
} else out2[k] = v;
|
|
@@ -1313,6 +1454,11 @@ function sanitizeDocument(doc, options = {}) {
|
|
|
1313
1454
|
report.redactedText += r.count;
|
|
1314
1455
|
return r.text;
|
|
1315
1456
|
};
|
|
1457
|
+
const launch = (s) => {
|
|
1458
|
+
const r = redactLaunchField(s);
|
|
1459
|
+
report.redactedText += r.count;
|
|
1460
|
+
return r.text;
|
|
1461
|
+
};
|
|
1316
1462
|
const keepFile = (path) => {
|
|
1317
1463
|
if (options.includeSensitiveFiles || !isSensitiveFile(path)) return true;
|
|
1318
1464
|
report.removedFiles.push(path);
|
|
@@ -1342,8 +1488,8 @@ function sanitizeDocument(doc, options = {}) {
|
|
|
1342
1488
|
...t,
|
|
1343
1489
|
mcp: {
|
|
1344
1490
|
...t.mcp,
|
|
1345
|
-
args: t.mcp.args.map(
|
|
1346
|
-
url: t.mcp.url === void 0 ? void 0 :
|
|
1491
|
+
args: t.mcp.args.map(launch),
|
|
1492
|
+
url: t.mcp.url === void 0 ? void 0 : launch(t.mcp.url),
|
|
1347
1493
|
env: stripRecord(t.name, t.mcp.env, report),
|
|
1348
1494
|
headers: stripRecord(t.name, t.mcp.headers, report)
|
|
1349
1495
|
}
|
|
@@ -1354,10 +1500,12 @@ function sanitizeDocument(doc, options = {}) {
|
|
|
1354
1500
|
};
|
|
1355
1501
|
return { doc: out2, report };
|
|
1356
1502
|
}
|
|
1503
|
+
var EVM_KEY_VALUE;
|
|
1357
1504
|
var init_document2 = __esm({
|
|
1358
1505
|
"../../packages/security/src/document.ts"() {
|
|
1359
1506
|
"use strict";
|
|
1360
1507
|
init_secrets();
|
|
1508
|
+
EVM_KEY_VALUE = /\b0x[0-9a-fA-F]{64}\b/;
|
|
1361
1509
|
}
|
|
1362
1510
|
});
|
|
1363
1511
|
|
|
@@ -1387,12 +1535,12 @@ function checkEntryName(name, limits) {
|
|
|
1387
1535
|
if (parts.some((p) => p === "" || p === ".")) throw new ArchiveError(`Entry has an empty path segment`, "unsafe-name", name);
|
|
1388
1536
|
if (parts.some((p) => p.length > 255)) throw new ArchiveError(`Entry has a path segment longer than 255 characters`, "unsafe-name", name);
|
|
1389
1537
|
}
|
|
1390
|
-
function listEntries(
|
|
1391
|
-
if (
|
|
1392
|
-
if (
|
|
1393
|
-
const view = new DataView(
|
|
1538
|
+
function listEntries(bytes2, limits = DEFAULT_LIMITS) {
|
|
1539
|
+
if (bytes2.length > limits.maxArchiveBytes) throw new ArchiveError(`Archive is larger than ${limits.maxArchiveBytes} bytes`, "archive-too-large");
|
|
1540
|
+
if (bytes2.length < 22) throw new ArchiveError("Not a ZIP archive", "not-zip");
|
|
1541
|
+
const view = new DataView(bytes2.buffer, bytes2.byteOffset, bytes2.byteLength);
|
|
1394
1542
|
let eocd = -1;
|
|
1395
|
-
for (let i =
|
|
1543
|
+
for (let i = bytes2.length - 22; i >= Math.max(0, bytes2.length - 22 - 65535); i--) {
|
|
1396
1544
|
if (view.getUint32(i, true) === 101010256) {
|
|
1397
1545
|
eocd = i;
|
|
1398
1546
|
break;
|
|
@@ -1404,13 +1552,13 @@ function listEntries(bytes, limits = DEFAULT_LIMITS) {
|
|
|
1404
1552
|
const cdOffset = view.getUint32(eocd + 16, true);
|
|
1405
1553
|
if (count === 65535 || cdOffset === 4294967295) throw new ArchiveError("ZIP64 archives are not supported", "zip64");
|
|
1406
1554
|
if (count > limits.maxEntries) throw new ArchiveError(`Archive has ${count} entries, more than the limit of ${limits.maxEntries}`, "too-many-entries");
|
|
1407
|
-
if (cdOffset + cdSize >
|
|
1555
|
+
if (cdOffset + cdSize > bytes2.length) throw new ArchiveError("Corrupt central directory", "corrupt");
|
|
1408
1556
|
const entries = [];
|
|
1409
1557
|
const seen = /* @__PURE__ */ new Set();
|
|
1410
1558
|
let total = 0;
|
|
1411
1559
|
let p = cdOffset;
|
|
1412
1560
|
for (let n = 0; n < count; n++) {
|
|
1413
|
-
if (p + 46 >
|
|
1561
|
+
if (p + 46 > bytes2.length || view.getUint32(p, true) !== 33639248) throw new ArchiveError("Corrupt central directory entry", "corrupt");
|
|
1414
1562
|
const madeBy = view.getUint16(p + 4, true);
|
|
1415
1563
|
const flags = view.getUint16(p + 8, true);
|
|
1416
1564
|
const method = view.getUint16(p + 10, true);
|
|
@@ -1421,7 +1569,7 @@ function listEntries(bytes, limits = DEFAULT_LIMITS) {
|
|
|
1421
1569
|
const commentLen = view.getUint16(p + 32, true);
|
|
1422
1570
|
const extAttr = view.getUint32(p + 38, true);
|
|
1423
1571
|
const localOffset = view.getUint32(p + 42, true);
|
|
1424
|
-
const name = new TextDecoder("utf-8", { fatal: false }).decode(
|
|
1572
|
+
const name = new TextDecoder("utf-8", { fatal: false }).decode(bytes2.subarray(p + 46, p + 46 + nameLen));
|
|
1425
1573
|
p += 46 + nameLen + extraLen + commentLen;
|
|
1426
1574
|
checkEntryName(name, limits);
|
|
1427
1575
|
if (flags & 1) throw new ArchiveError("Encrypted entries are not supported", "encrypted", name);
|
|
@@ -1471,20 +1619,20 @@ function inflateCapped(data, expected, name) {
|
|
|
1471
1619
|
if (written !== expected) throw new ArchiveError("Entry size does not match its declared size", "corrupt", name);
|
|
1472
1620
|
return out2;
|
|
1473
1621
|
}
|
|
1474
|
-
function extractEntries(
|
|
1475
|
-
const entries = listEntries(
|
|
1476
|
-
const view = new DataView(
|
|
1622
|
+
function extractEntries(bytes2, limits = DEFAULT_LIMITS) {
|
|
1623
|
+
const entries = listEntries(bytes2, limits);
|
|
1624
|
+
const view = new DataView(bytes2.buffer, bytes2.byteOffset, bytes2.byteLength);
|
|
1477
1625
|
const files = /* @__PURE__ */ new Map();
|
|
1478
1626
|
for (const e of entries) {
|
|
1479
1627
|
if (e.isDirectory) continue;
|
|
1480
1628
|
const lo = e.localOffset;
|
|
1481
|
-
if (lo + 30 >
|
|
1629
|
+
if (lo + 30 > bytes2.length || view.getUint32(lo, true) !== 67324752) throw new ArchiveError("Corrupt local header", "corrupt", e.name);
|
|
1482
1630
|
const nameLen = view.getUint16(lo + 26, true);
|
|
1483
1631
|
const extraLen = view.getUint16(lo + 28, true);
|
|
1484
1632
|
const start = lo + 30 + nameLen + extraLen;
|
|
1485
1633
|
const end = start + e.compressedSize;
|
|
1486
|
-
if (end >
|
|
1487
|
-
const raw =
|
|
1634
|
+
if (end > bytes2.length) throw new ArchiveError("Entry data is truncated", "corrupt", e.name);
|
|
1635
|
+
const raw = bytes2.subarray(start, end);
|
|
1488
1636
|
files.set(e.name, e.method === 0 ? raw.slice() : inflateCapped(raw, e.size, e.name));
|
|
1489
1637
|
}
|
|
1490
1638
|
return files;
|
|
@@ -2583,11 +2731,11 @@ function packAgent(doc, options = {}) {
|
|
|
2583
2731
|
}
|
|
2584
2732
|
return { bytes: createZip(files), manifest, files, scan, sanitize };
|
|
2585
2733
|
}
|
|
2586
|
-
function unpackAgent(
|
|
2734
|
+
function unpackAgent(bytes2, options = {}) {
|
|
2587
2735
|
const limits = { ...DEFAULT_LIMITS, ...options.limits };
|
|
2588
2736
|
let files;
|
|
2589
2737
|
try {
|
|
2590
|
-
files = extractEntries(
|
|
2738
|
+
files = extractEntries(bytes2, limits);
|
|
2591
2739
|
} catch (e) {
|
|
2592
2740
|
if (e instanceof ArchiveError) {
|
|
2593
2741
|
return { ok: false, doc: null, issues: [{ path: e.entry ?? "(archive)", message: `${e.message} [${e.code}]` }], warnings: [], scan: null, sanitize: null, executableFiles: [], fileCount: 0, totalBytes: 0 };
|
|
@@ -2739,7 +2887,7 @@ function analyzeCompatibility(doc, source, destination) {
|
|
|
2739
2887
|
const isAttention = items > 0 && (status === "unsupported" || status === "manual" && IMPORTANT.includes(category));
|
|
2740
2888
|
if (isAttention) {
|
|
2741
2889
|
attention.push(
|
|
2742
|
-
status === "unsupported" ? `${CATEGORY_LABELS[category]}: ${destination.displayName}
|
|
2890
|
+
status === "unsupported" ? `${CATEGORY_LABELS[category]}: ${destination.displayName} has no place for ${items === 1 ? "1 item" : `${items} items`}, so ${items === 1 ? "it is" : "they are"} not moved. Nomad keeps a copy and gives you steps to set ${items === 1 ? "it" : "them"} up another way.` : `${CATEGORY_LABELS[category]}: you finish setting up ${items === 1 ? "1 item" : `${items} items`} in ${destination.displayName} yourself. Nomad lists the steps.`
|
|
2743
2891
|
);
|
|
2744
2892
|
}
|
|
2745
2893
|
categories.push({
|
|
@@ -2823,7 +2971,7 @@ function fileInfo(id, displayName, description, defaultLocations, opts) {
|
|
|
2823
2971
|
id,
|
|
2824
2972
|
displayName,
|
|
2825
2973
|
category: "coding-agent",
|
|
2826
|
-
support: "
|
|
2974
|
+
support: "PARTIAL",
|
|
2827
2975
|
adapterVersion: "0.1.0",
|
|
2828
2976
|
supportedVersions: "Documented rules and configuration files as of late 2026",
|
|
2829
2977
|
description,
|
|
@@ -2844,7 +2992,7 @@ function fileInfo(id, displayName, description, defaultLocations, opts) {
|
|
|
2844
2992
|
knowledge: manual(),
|
|
2845
2993
|
project: convert()
|
|
2846
2994
|
}),
|
|
2847
|
-
limitations: ["
|
|
2995
|
+
limitations: ["Scheduled routines, model choice and permission enforcement stay in the application settings."]
|
|
2848
2996
|
};
|
|
2849
2997
|
}
|
|
2850
2998
|
function guidedInfo(id, displayName, category, description, notes) {
|
|
@@ -2855,7 +3003,7 @@ function guidedInfo(id, displayName, category, description, notes) {
|
|
|
2855
3003
|
category,
|
|
2856
3004
|
support: "GUIDED",
|
|
2857
3005
|
adapterVersion: "0.1.0",
|
|
2858
|
-
supportedVersions: category === "hosted" ? "
|
|
3006
|
+
supportedVersions: category === "hosted" ? "Published settings screens" : "Current public SDK",
|
|
2859
3007
|
description,
|
|
2860
3008
|
defaultLocations: [],
|
|
2861
3009
|
multiAgent: false,
|
|
@@ -2881,7 +3029,7 @@ function guidedInfo(id, displayName, category, description, notes) {
|
|
|
2881
3029
|
function infoById(id) {
|
|
2882
3030
|
return ALL_INFOS.find((a) => a.id === id);
|
|
2883
3031
|
}
|
|
2884
|
-
var full, convert, manual, none, rw, GENERIC_INFO, CLAUDE_CODE_INFO, CODEX_INFO, OPENCLAW_INFO, HERMES_INFO, CURSOR_INFO, WINDSURF_INFO, CLINE_INFO, ROO_INFO, CONTINUE_INFO, OPENCODE_INFO, GOOSE_INFO, AIDER_INFO, GEMINI_CLI_INFO, GUIDED_INFOS, ALL_INFOS;
|
|
3032
|
+
var full, convert, manual, none, rw, GENERIC_INFO, CLAUDE_CODE_INFO, CODEX_INFO, OPENCLAW_INFO, HERMES_INFO, CURSOR_INFO, WINDSURF_INFO, CLINE_INFO, ROO_INFO, CONTINUE_INFO, OPENCODE_INFO, GOOSE_INFO, AIDER_INFO, GEMINI_CLI_INFO, GUIDED_INFOS, ELIZAOS_INFO, ALL_INFOS;
|
|
2885
3033
|
var init_catalog = __esm({
|
|
2886
3034
|
"../../packages/adapters/src/catalog.ts"() {
|
|
2887
3035
|
"use strict";
|
|
@@ -2932,7 +3080,8 @@ var init_catalog = __esm({
|
|
|
2932
3080
|
}),
|
|
2933
3081
|
limitations: [
|
|
2934
3082
|
"User level MCP servers live in ~/.claude.json, which Claude Code also rewrites. Close Claude Code before migrating.",
|
|
2935
|
-
"Scheduled routines cannot be imported."
|
|
3083
|
+
"Scheduled routines cannot be imported.",
|
|
3084
|
+
"Reads installed plugins (servers and skills of enabled user-level plugins), never installs them."
|
|
2936
3085
|
]
|
|
2937
3086
|
};
|
|
2938
3087
|
CODEX_INFO = {
|
|
@@ -3017,7 +3166,10 @@ var init_catalog = __esm({
|
|
|
3017
3166
|
knowledge: manual(),
|
|
3018
3167
|
project: convert()
|
|
3019
3168
|
}),
|
|
3020
|
-
limitations: [
|
|
3169
|
+
limitations: [
|
|
3170
|
+
"Hermes memory has character limits (2,200 for MEMORY.md and 1,375 for USER.md by default). Larger imports are reported.",
|
|
3171
|
+
"Reads installed plugins (portable plugin servers and skills), never installs or enables them. ~/.hermes/.env is never read."
|
|
3172
|
+
]
|
|
3021
3173
|
};
|
|
3022
3174
|
CURSOR_INFO = fileInfo("cursor", "Cursor", "Project rules in .cursor/rules (MDC), legacy .cursorrules and AGENTS.md, plus .cursor/mcp.json.", [], {
|
|
3023
3175
|
mcp: true,
|
|
@@ -3078,12 +3230,44 @@ var init_catalog = __esm({
|
|
|
3078
3230
|
guidedInfo("n8n", "n8n", "framework", "System message for the AI Agent node and schedule trigger settings.", "Instructions become the system message."),
|
|
3079
3231
|
guidedInfo("letta", "Letta", "framework", "A Letta agent with persona and human memory blocks.", "Persona and user memory become memory blocks.")
|
|
3080
3232
|
];
|
|
3233
|
+
ELIZAOS_INFO = {
|
|
3234
|
+
id: "elizaos",
|
|
3235
|
+
displayName: "ElizaOS",
|
|
3236
|
+
category: "framework",
|
|
3237
|
+
support: "PARTIAL",
|
|
3238
|
+
adapterVersion: "0.1.0",
|
|
3239
|
+
supportedVersions: "ElizaOS 1.x JSON character files",
|
|
3240
|
+
description: "Character files (characters/*.json, *.character.json): bio, system prompt, style, knowledge, plugins and MCP servers under settings.mcp.",
|
|
3241
|
+
docsUrl: "https://docs.elizaos.ai/agents/character-interface",
|
|
3242
|
+
defaultLocations: [],
|
|
3243
|
+
multiAgent: true,
|
|
3244
|
+
configFormats: ["JSON"],
|
|
3245
|
+
capabilities: capabilityMatrix({
|
|
3246
|
+
identity: { read: "convert", write: "convert", notes: "bio becomes the persona; adjectives the tone." },
|
|
3247
|
+
instructions: { read: "convert", write: "convert", notes: "system and style; other instructions are folded into system with a heading." },
|
|
3248
|
+
memory: { read: "convert", write: "convert", notes: "Knowledge strings in the character. Runtime memory in ElizaOS's database is not read." },
|
|
3249
|
+
skills: { read: "unsupported", write: "unsupported" },
|
|
3250
|
+
tools: { read: "convert", write: "convert", notes: "MCP servers under settings.mcp.servers (needs @elizaos/plugin-mcp). References are not written." },
|
|
3251
|
+
integrations: { read: "manual", write: "manual", notes: "Plugins are listed; Nomad never installs them." },
|
|
3252
|
+
models: { read: "manual", write: "manual" },
|
|
3253
|
+
permissions: { read: "unsupported", write: "unsupported" },
|
|
3254
|
+
workflows: { read: "unsupported", write: "unsupported" },
|
|
3255
|
+
knowledge: { read: "convert", write: "manual", notes: "Knowledge file paths are listed, copied only with --include-files." },
|
|
3256
|
+
project: { read: "convert", write: "convert" }
|
|
3257
|
+
}),
|
|
3258
|
+
limitations: [
|
|
3259
|
+
"JSON characters only; TypeScript characters are reported, never run.",
|
|
3260
|
+
"Secrets (secrets and settings.secrets) are never read or written; only their names are listed.",
|
|
3261
|
+
"Runtime memory and conversations are not migrated."
|
|
3262
|
+
]
|
|
3263
|
+
};
|
|
3081
3264
|
ALL_INFOS = [
|
|
3082
3265
|
OPENCLAW_INFO,
|
|
3083
3266
|
CLAUDE_CODE_INFO,
|
|
3084
3267
|
CODEX_INFO,
|
|
3085
3268
|
HERMES_INFO,
|
|
3086
3269
|
GENERIC_INFO,
|
|
3270
|
+
ELIZAOS_INFO,
|
|
3087
3271
|
CURSOR_INFO,
|
|
3088
3272
|
WINDSURF_INFO,
|
|
3089
3273
|
CLINE_INFO,
|
|
@@ -3098,6 +3282,184 @@ var init_catalog = __esm({
|
|
|
3098
3282
|
}
|
|
3099
3283
|
});
|
|
3100
3284
|
|
|
3285
|
+
// ../../packages/adapters/src/known-servers.ts
|
|
3286
|
+
function applyKnownServerProfile(tool, platformName = "the destination") {
|
|
3287
|
+
const out2 = { tool, notes: [], manualSteps: [], unsupported: [] };
|
|
3288
|
+
const profile = tool.mcp ? PROFILES.find((p) => p.matches(tool)) : void 0;
|
|
3289
|
+
if (!profile || !tool.mcp) return out2;
|
|
3290
|
+
const env = { ...tool.mcp.env };
|
|
3291
|
+
const optional = new Set(tool.mcp.optionalEnv ?? []);
|
|
3292
|
+
const keys = profile.keyVars.filter((k) => env[k]);
|
|
3293
|
+
if (keys.length > 1) {
|
|
3294
|
+
for (const k of keys) delete env[k];
|
|
3295
|
+
out2.manualSteps.push(
|
|
3296
|
+
`"${tool.name}" listed both ${keys.join(" and ")}, which ${profile.id === "priors" ? "Priors" : "the server"} refuses together, so Nomad wrote neither. Set one: ${keys[0]} (recommended: a path to an owner-only key file, chmod 600, for a dedicated wallet) or ${keys[1]}.`
|
|
3297
|
+
);
|
|
3298
|
+
}
|
|
3299
|
+
for (const k of profile.keyVars) {
|
|
3300
|
+
if (keys.includes(k)) {
|
|
3301
|
+
out2.unsupported.push({ category: "tools", item: `${tool.name}: ${k}`, reason: "Wallet keys and key files are references only.", alternative: "Create the key file on the new machine (owner-only) and set the variable. Use a dedicated wallet." });
|
|
3302
|
+
}
|
|
3303
|
+
}
|
|
3304
|
+
for (const k of profile.limitVars) {
|
|
3305
|
+
const v = env[k];
|
|
3306
|
+
if (!v || "value" in v) continue;
|
|
3307
|
+
delete env[k];
|
|
3308
|
+
optional.delete(k);
|
|
3309
|
+
const looser = profile.looserDefaults[k];
|
|
3310
|
+
out2.unsupported.push({
|
|
3311
|
+
category: "permissions",
|
|
3312
|
+
item: `${tool.name}: ${k}`,
|
|
3313
|
+
reason: `Limit not carried: it was a reference on the source, so the destination uses ${profile.vendor} defaults${looser ? ` (${looser})` : ""}.`,
|
|
3314
|
+
alternative: `Set ${k} on the destination to keep the limit.`
|
|
3315
|
+
});
|
|
3316
|
+
}
|
|
3317
|
+
const mcp = { ...tool.mcp, env };
|
|
3318
|
+
const keptOptional = [...optional].filter((k) => env[k]);
|
|
3319
|
+
if (keptOptional.length) mcp.optionalEnv = keptOptional;
|
|
3320
|
+
else delete mcp.optionalEnv;
|
|
3321
|
+
if (profile.emptyOkEnv.length) mcp.emptyOkEnv = profile.emptyOkEnv;
|
|
3322
|
+
out2.tool = { ...tool, mcp };
|
|
3323
|
+
profile.apply?.(out2.tool, out2, platformName);
|
|
3324
|
+
return out2;
|
|
3325
|
+
}
|
|
3326
|
+
function knownServerId(tool) {
|
|
3327
|
+
return PROFILES.find((p) => p.matches(tool))?.id ?? null;
|
|
3328
|
+
}
|
|
3329
|
+
var isPriorsHost, PRIORS, isOakCommand, OAK, PROFILES;
|
|
3330
|
+
var init_known_servers = __esm({
|
|
3331
|
+
"../../packages/adapters/src/known-servers.ts"() {
|
|
3332
|
+
"use strict";
|
|
3333
|
+
isPriorsHost = (url) => {
|
|
3334
|
+
if (!url) return false;
|
|
3335
|
+
try {
|
|
3336
|
+
return new URL(url).hostname === "mcp.priors.trade";
|
|
3337
|
+
} catch {
|
|
3338
|
+
return false;
|
|
3339
|
+
}
|
|
3340
|
+
};
|
|
3341
|
+
PRIORS = {
|
|
3342
|
+
id: "priors",
|
|
3343
|
+
vendor: "Priors",
|
|
3344
|
+
label: "Priors (a credit service for agents on Robinhood Chain)",
|
|
3345
|
+
matches: (t) => !!t.mcp && (t.mcp.command === "priors-mcp" || t.mcp.args.some((a) => a.includes("@priors/mcp")) || isPriorsHost(t.mcp.url)),
|
|
3346
|
+
keyVars: ["PRIORS_KEY_FILE", "PRIORS_KEY"],
|
|
3347
|
+
emptyOkEnv: ["PRIORS_AGENT_ID"],
|
|
3348
|
+
limitVars: [
|
|
3349
|
+
"PRIORS_PAY_HOSTS",
|
|
3350
|
+
"PRIORS_OWNER_ENTITY_IDS",
|
|
3351
|
+
"PRIORS_MAX_PRICE_USD",
|
|
3352
|
+
"PRIORS_MAX_SPEND_USD",
|
|
3353
|
+
"PRIORS_MAX_BORROW_USD",
|
|
3354
|
+
"PRIORS_MAX_BORROW_TOTAL_USD",
|
|
3355
|
+
"PRIORS_MAX_SPEND_DAY_USD",
|
|
3356
|
+
"PRIORS_MAX_BORROW_DAY_USD",
|
|
3357
|
+
"PRIORS_AUTO_BORROW_USD",
|
|
3358
|
+
"PRIORS_STATE_DIR"
|
|
3359
|
+
],
|
|
3360
|
+
looserDefaults: {
|
|
3361
|
+
PRIORS_PAY_HOSTS: "defaults are looser: any public https host",
|
|
3362
|
+
PRIORS_MAX_SPEND_DAY_USD: "defaults are looser: no daily caps",
|
|
3363
|
+
PRIORS_MAX_BORROW_DAY_USD: "defaults are looser: no daily caps"
|
|
3364
|
+
},
|
|
3365
|
+
apply(t, out2, platform) {
|
|
3366
|
+
const mcp = t.mcp;
|
|
3367
|
+
if (mcp.transport !== "stdio") {
|
|
3368
|
+
out2.notes.push({ level: "info", category: "tools", message: `"${t.name}" is a remote server run by a third party (Priors). Nomad copies only its address.` });
|
|
3369
|
+
return;
|
|
3370
|
+
}
|
|
3371
|
+
out2.notes.push({
|
|
3372
|
+
level: "info",
|
|
3373
|
+
category: "integrations",
|
|
3374
|
+
message: "Priors on-chain items (the ERC-8004 identity, the credit line, open loans, Autopay enrolment, the declared agent wallet) stay with the wallet. Moving the agent does not move or repay them."
|
|
3375
|
+
});
|
|
3376
|
+
out2.notes.push({
|
|
3377
|
+
level: "info",
|
|
3378
|
+
category: "tools",
|
|
3379
|
+
message: `"${t.name}": daily spend and borrow counters start again on ${platform}. Give every client that uses this agent's key the same limits (Priors counts per state folder).`
|
|
3380
|
+
});
|
|
3381
|
+
if (mcp.command === "priors-mcp") {
|
|
3382
|
+
out2.manualSteps.push(`Install the Priors MCP server for "${t.name}": npm install -g @priors/mcp@<version you trust>. It needs Node.js 20.10 or later on the PATH ${platform} uses.`);
|
|
3383
|
+
}
|
|
3384
|
+
const keyFileArgs = mcp.args.filter((a) => /\.key$/i.test(a) || /(^|\/)\.config\/priors(\/|$)/.test(a));
|
|
3385
|
+
for (const a of keyFileArgs) {
|
|
3386
|
+
out2.manualSteps.push(`Create the key file ${a} on this machine (owner-only, chmod 600) for "${t.name}". Nomad did not copy it.`);
|
|
3387
|
+
out2.unsupported.push({ category: "tools", item: `${t.name}: key file referenced in launch arguments (${a})`, reason: "Key files are never read or copied.", alternative: "Create the key file on the new machine (owner-only) with a dedicated wallet." });
|
|
3388
|
+
}
|
|
3389
|
+
}
|
|
3390
|
+
};
|
|
3391
|
+
isOakCommand = (command) => !!command && /(^|[\\/])oak(\.cmd|\.exe)?$/i.test(command);
|
|
3392
|
+
OAK = {
|
|
3393
|
+
id: "oak",
|
|
3394
|
+
vendor: "Oak",
|
|
3395
|
+
label: "Oak Agent Kit (a local wallet and tools for Robinhood Chain projects)",
|
|
3396
|
+
matches: (t) => !!t.mcp && t.mcp.transport === "stdio" && (isOakCommand(t.mcp.command) && t.mcp.args[0] === "mcp" || t.mcp.args.some((a) => /^@oakagentkit\/addon(@|$)/.test(a))),
|
|
3397
|
+
keyVars: [],
|
|
3398
|
+
emptyOkEnv: [],
|
|
3399
|
+
limitVars: ["OAK_AUTO_DAILY_CAP_USD"],
|
|
3400
|
+
looserDefaults: { OAK_AUTO_DAILY_CAP_USD: "50 USD a day for automatic approvals" },
|
|
3401
|
+
apply(t, out2, platform) {
|
|
3402
|
+
const mcp = t.mcp;
|
|
3403
|
+
out2.notes.push({
|
|
3404
|
+
level: "info",
|
|
3405
|
+
category: "integrations",
|
|
3406
|
+
message: "Oak's wallet, its settings (including the approval mode and the daily budget) and its keychain entry stay on this computer, in ~/.oak and the system keychain. Nomad never reads ~/.oak."
|
|
3407
|
+
});
|
|
3408
|
+
out2.notes.push({
|
|
3409
|
+
level: "warning",
|
|
3410
|
+
category: "tools",
|
|
3411
|
+
message: `Oak: if ${platform} runs on another computer, Oak creates a new, empty wallet there the first time it starts. To keep the same wallet, restore it there yourself, in your own terminal and never through an agent, following Oak's backup guide (oak backup).`
|
|
3412
|
+
});
|
|
3413
|
+
out2.notes.push({
|
|
3414
|
+
level: "warning",
|
|
3415
|
+
category: "tools",
|
|
3416
|
+
message: `Oak: Oak asks for approval in the app before it signs. Oak's documentation says apps without MCP form elicitation cannot sign in its default ask mode, so check that ${platform} shows Oak's approval form before relying on it.`
|
|
3417
|
+
});
|
|
3418
|
+
if (isOakCommand(mcp.command)) {
|
|
3419
|
+
out2.manualSteps.push(`Install Oak for "${t.name}": npm install -g @oakagentkit/addon. It needs Node.js 22.12 or later, and the oak command must be on the PATH ${platform} uses.`);
|
|
3420
|
+
} else {
|
|
3421
|
+
out2.manualSteps.push(`"${t.name}" runs Oak through npx: ${platform} needs Node.js 22.12 or later on its PATH.`);
|
|
3422
|
+
}
|
|
3423
|
+
for (const k of ["OAK_NETWORK", "OAK_CHAIN_ID"]) {
|
|
3424
|
+
const v = mcp.env[k];
|
|
3425
|
+
if (v && !("value" in v)) {
|
|
3426
|
+
out2.notes.push({ level: "warning", category: "tools", message: `"${t.name}": ${k} is a reference. Set it on ${platform} too; without it Oak uses Robinhood Chain mainnet.` });
|
|
3427
|
+
}
|
|
3428
|
+
}
|
|
3429
|
+
}
|
|
3430
|
+
};
|
|
3431
|
+
PROFILES = [PRIORS, OAK];
|
|
3432
|
+
}
|
|
3433
|
+
});
|
|
3434
|
+
|
|
3435
|
+
// ../../packages/adapters/src/elizaos-known-plugins.ts
|
|
3436
|
+
function knownElizaosPlugin(name) {
|
|
3437
|
+
return KNOWN_ELIZAOS_PLUGINS.find((p) => p.name === name);
|
|
3438
|
+
}
|
|
3439
|
+
function elizaosPluginHint(name) {
|
|
3440
|
+
const k = knownElizaosPlugin(name);
|
|
3441
|
+
if (k?.equivalentMcp) {
|
|
3442
|
+
return `On this platform, use the local MCP server ${k.equivalentMcp.local} and/or the hosted server ${k.equivalentMcp.hosted}. Nomad does not add them for you (the key stays with you).`;
|
|
3443
|
+
}
|
|
3444
|
+
return "Reinstall or replace it on this platform. Nomad never installs plugins.";
|
|
3445
|
+
}
|
|
3446
|
+
var KNOWN_ELIZAOS_PLUGINS;
|
|
3447
|
+
var init_elizaos_known_plugins = __esm({
|
|
3448
|
+
"../../packages/adapters/src/elizaos-known-plugins.ts"() {
|
|
3449
|
+
"use strict";
|
|
3450
|
+
KNOWN_ELIZAOS_PLUGINS = [
|
|
3451
|
+
{
|
|
3452
|
+
name: "@priors/plugin-elizaos",
|
|
3453
|
+
settingNames: ["PRIORS_KEY_FILE", "PRIORS_KEY", "PRIORS_AGENT_ID", "PRIORS_OWNER_ENTITY_IDS", "PRIORS_PAY_HOSTS", "PRIORS_MAX_PRICE_USD", "PRIORS_MAX_SPEND_DAY_USD", "PRIORS_MAX_BORROW_DAY_USD", "PRIORS_STATE_DIR", "PRIORS_AUTO_BORROW_USD"],
|
|
3454
|
+
sensitive: ["PRIORS_KEY_FILE", "PRIORS_KEY"],
|
|
3455
|
+
safetyLimits: ["PRIORS_OWNER_ENTITY_IDS", "PRIORS_PAY_HOSTS", "PRIORS_MAX_PRICE_USD", "PRIORS_MAX_SPEND_DAY_USD", "PRIORS_MAX_BORROW_DAY_USD", "PRIORS_AUTO_BORROW_USD"],
|
|
3456
|
+
equivalentMcp: { local: "priors-wallet (@priors/mcp)", hosted: "https://mcp.priors.trade/mcp" },
|
|
3457
|
+
note: "Priors says the plugin runs @priors/mcp in process and reads the hosted read-only server."
|
|
3458
|
+
}
|
|
3459
|
+
];
|
|
3460
|
+
}
|
|
3461
|
+
});
|
|
3462
|
+
|
|
3101
3463
|
// ../../packages/adapters/src/util.ts
|
|
3102
3464
|
import { join as join2, basename } from "path";
|
|
3103
3465
|
import { promises as fsp2 } from "fs";
|
|
@@ -3367,87 +3729,146 @@ function parseAgentMarkdown(text3, platform, path) {
|
|
|
3367
3729
|
}
|
|
3368
3730
|
return result;
|
|
3369
3731
|
}
|
|
3370
|
-
function envRecord(raw) {
|
|
3371
|
-
const out2 = {};
|
|
3732
|
+
function envRecord(raw, refsOptional = false) {
|
|
3733
|
+
const out2 = { rec: {}, optional: [], defaults: [] };
|
|
3372
3734
|
if (raw && typeof raw === "object" && !Array.isArray(raw)) {
|
|
3373
3735
|
for (const [k, v] of Object.entries(raw)) {
|
|
3374
3736
|
if (typeof v === "string") {
|
|
3375
|
-
const ref =
|
|
3376
|
-
|
|
3377
|
-
|
|
3737
|
+
const ref = ENV_REF.exec(v);
|
|
3738
|
+
if (!ref) {
|
|
3739
|
+
out2.rec[k] = { value: v };
|
|
3740
|
+
continue;
|
|
3741
|
+
}
|
|
3742
|
+
out2.rec[k] = { secretRef: ref[2], redacted: true };
|
|
3743
|
+
if (ref[3] !== void 0 && ref[4]) out2.defaults.push([k, ref[4]]);
|
|
3744
|
+
else if (ref[3] !== void 0 || refsOptional) out2.optional.push(k);
|
|
3745
|
+
} else if (v !== null && v !== void 0) out2.rec[k] = { value: String(v) };
|
|
3378
3746
|
}
|
|
3379
3747
|
}
|
|
3380
3748
|
return out2;
|
|
3381
3749
|
}
|
|
3382
|
-
function toolsFromMcpServers(raw, platform, path) {
|
|
3750
|
+
function toolsFromMcpServers(raw, platform, path, opts = {}) {
|
|
3383
3751
|
if (!raw || typeof raw !== "object") return [];
|
|
3384
3752
|
const tools = [];
|
|
3385
3753
|
for (const [name, cfg] of Object.entries(raw)) {
|
|
3386
3754
|
if (!cfg || typeof cfg !== "object") continue;
|
|
3387
3755
|
const url = cfg.url ?? cfg.httpUrl ?? cfg.serverUrl;
|
|
3388
|
-
const transport = cfg.type === "sse" ? "sse" : url ? "http" : "stdio";
|
|
3756
|
+
const transport = cfg.type === "sse" || cfg.transport === "sse" ? "sse" : url ? "http" : "stdio";
|
|
3757
|
+
const env = envRecord(cfg.env, opts.refsOptional && transport === "stdio");
|
|
3758
|
+
const headers = envRecord(cfg.headers ?? cfg.http_headers);
|
|
3759
|
+
for (const [k, d] of env.defaults) opts.notes?.push({ level: "info", category: "tools", message: `"${name}": ${k} has a default (${d.length > 40 ? `${d.length} characters` : d}) that is not carried. Set ${k} on the destination if you rely on it.` });
|
|
3760
|
+
const mcp = {
|
|
3761
|
+
transport,
|
|
3762
|
+
command: typeof cfg.command === "string" ? cfg.command : void 0,
|
|
3763
|
+
args: Array.isArray(cfg.args) ? cfg.args.map(String) : [],
|
|
3764
|
+
url: typeof url === "string" ? url : void 0,
|
|
3765
|
+
env: env.rec,
|
|
3766
|
+
headers: headers.rec,
|
|
3767
|
+
cwd: typeof cfg.cwd === "string" ? cfg.cwd : void 0
|
|
3768
|
+
};
|
|
3769
|
+
if (env.optional.length) mcp.optionalEnv = env.optional;
|
|
3389
3770
|
tools.push({
|
|
3390
3771
|
name,
|
|
3391
3772
|
description: typeof cfg.description === "string" ? cfg.description : void 0,
|
|
3392
3773
|
kind: "mcp",
|
|
3393
|
-
mcp
|
|
3394
|
-
transport,
|
|
3395
|
-
command: typeof cfg.command === "string" ? cfg.command : void 0,
|
|
3396
|
-
args: Array.isArray(cfg.args) ? cfg.args.map(String) : [],
|
|
3397
|
-
url: typeof url === "string" ? url : void 0,
|
|
3398
|
-
env: envRecord(cfg.env),
|
|
3399
|
-
headers: envRecord(cfg.headers ?? cfg.http_headers),
|
|
3400
|
-
cwd: typeof cfg.cwd === "string" ? cfg.cwd : void 0
|
|
3401
|
-
},
|
|
3774
|
+
mcp,
|
|
3402
3775
|
permissions: [],
|
|
3403
3776
|
platforms: [],
|
|
3404
3777
|
enabled: cfg.disabled !== true && cfg.enabled !== false,
|
|
3405
|
-
source: { platform, path }
|
|
3778
|
+
source: { platform, path, ...opts.note ? { note: opts.note } : {}, ...opts.extra ?? {} }
|
|
3406
3779
|
});
|
|
3407
3780
|
}
|
|
3408
3781
|
return tools;
|
|
3409
3782
|
}
|
|
3783
|
+
function pluginOf(item, host) {
|
|
3784
|
+
const src = item.source;
|
|
3785
|
+
return src?.pluginHost === host && typeof src.plugin === "string" ? src.plugin : null;
|
|
3786
|
+
}
|
|
3787
|
+
function integrationStep(i, platformName, otherwise) {
|
|
3788
|
+
if (i.kind === "elizaos-plugin") {
|
|
3789
|
+
return `${i.name} was an ElizaOS plugin. ${elizaosPluginHint(i.name)}`;
|
|
3790
|
+
}
|
|
3791
|
+
if (i.kind === "claude-code-plugin" || i.kind === "hermes-plugin") {
|
|
3792
|
+
return `${i.name} was an installed ${i.kind === "hermes-plugin" ? "Hermes" : "Claude Code"} plugin (installed plugin read, not installed). Its servers and skills are written to ${platformName} as ordinary entries where ${platformName} has a place for them.`;
|
|
3793
|
+
}
|
|
3794
|
+
return otherwise;
|
|
3795
|
+
}
|
|
3410
3796
|
function mcpServersFromTools(tools, opts) {
|
|
3411
|
-
const
|
|
3412
|
-
const
|
|
3413
|
-
|
|
3414
|
-
|
|
3797
|
+
const style = opts.envRefStyle ?? (opts.envExpansion ? "dollar" : "none");
|
|
3798
|
+
const asRef = (name) => style === "env-prefix" ? `\${env:${name}}` : `\${${name}}`;
|
|
3799
|
+
const out2 = { servers: {}, manualSteps: [], unsupported: [], notes: [], refs: {} };
|
|
3800
|
+
const seenNotes = /* @__PURE__ */ new Set();
|
|
3801
|
+
for (const original of tools) {
|
|
3802
|
+
if (original.kind !== "mcp" || !original.mcp) continue;
|
|
3803
|
+
if (original.enabled === false) {
|
|
3804
|
+
out2.unsupported.push({ category: "tools", item: original.name, reason: "Disabled on the source, so it is not added.", alternative: "Add it yourself if you want it active here." });
|
|
3805
|
+
continue;
|
|
3806
|
+
}
|
|
3807
|
+
const profile = applyKnownServerProfile(original, opts.platformName);
|
|
3808
|
+
const t = profile.tool;
|
|
3809
|
+
out2.manualSteps.push(...profile.manualSteps);
|
|
3810
|
+
out2.unsupported.push(...profile.unsupported);
|
|
3811
|
+
for (const n of profile.notes) if (!seenNotes.has(n.message)) seenNotes.add(n.message), out2.notes.push(n);
|
|
3812
|
+
const trust = t.extensions?.["x-hermes"]?.trust;
|
|
3813
|
+
if (trust === "untrusted") {
|
|
3814
|
+
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.` });
|
|
3815
|
+
}
|
|
3816
|
+
const mcp = t.mcp;
|
|
3415
3817
|
const s = {};
|
|
3416
|
-
if (
|
|
3417
|
-
s.command =
|
|
3418
|
-
if (
|
|
3419
|
-
if (
|
|
3818
|
+
if (mcp.transport === "stdio") {
|
|
3819
|
+
s.command = mcp.command;
|
|
3820
|
+
if (mcp.args.length) s.args = mcp.args;
|
|
3821
|
+
if (mcp.cwd) s.cwd = mcp.cwd;
|
|
3420
3822
|
} else {
|
|
3421
|
-
s[opts.urlKey ?? "url"] =
|
|
3422
|
-
if (opts.typeField) s.type =
|
|
3823
|
+
s[opts.urlKey ?? "url"] = mcp.url;
|
|
3824
|
+
if (opts.typeField) s.type = mcp.transport;
|
|
3423
3825
|
}
|
|
3826
|
+
const optionalNames = new Set(mcp.optionalEnv ?? []);
|
|
3827
|
+
const refs = { env: [], headers: [], optional: [] };
|
|
3424
3828
|
const env = {};
|
|
3425
3829
|
const missing = [];
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
env[k] =
|
|
3430
|
-
|
|
3431
|
-
}
|
|
3830
|
+
const optionalMissing = [];
|
|
3831
|
+
for (const [k, v] of Object.entries(mcp.env)) {
|
|
3832
|
+
if ("value" in v) {
|
|
3833
|
+
env[k] = v.value;
|
|
3834
|
+
continue;
|
|
3835
|
+
}
|
|
3836
|
+
refs.env.push(k);
|
|
3837
|
+
if (optionalNames.has(k)) {
|
|
3838
|
+
refs.optional.push(k);
|
|
3839
|
+
const written = style === "none" ? null : opts.optionalRef?.(t, k) ?? null;
|
|
3840
|
+
if (written !== null) env[k] = written;
|
|
3841
|
+
else optionalMissing.push(k);
|
|
3842
|
+
continue;
|
|
3843
|
+
}
|
|
3844
|
+
if (style !== "none") env[k] = asRef(v.secretRef);
|
|
3845
|
+
missing.push(style === "none" ? k : v.secretRef);
|
|
3432
3846
|
}
|
|
3433
3847
|
if (Object.keys(env).length) s.env = env;
|
|
3434
3848
|
const headers = {};
|
|
3435
|
-
for (const [k, v] of Object.entries(
|
|
3849
|
+
for (const [k, v] of Object.entries(mcp.headers)) {
|
|
3436
3850
|
if ("value" in v) headers[k] = v.value;
|
|
3437
|
-
else
|
|
3438
|
-
headers[k
|
|
3439
|
-
|
|
3440
|
-
|
|
3851
|
+
else {
|
|
3852
|
+
refs.headers.push([k, v.secretRef]);
|
|
3853
|
+
if (style !== "none") {
|
|
3854
|
+
headers[k] = asRef(v.secretRef);
|
|
3855
|
+
missing.push(v.secretRef);
|
|
3856
|
+
} else missing.push(`${k} header`);
|
|
3857
|
+
}
|
|
3441
3858
|
}
|
|
3442
3859
|
if (Object.keys(headers).length) s.headers = headers;
|
|
3443
|
-
servers[t.name] = s;
|
|
3860
|
+
out2.servers[t.name] = s;
|
|
3861
|
+
out2.refs[t.name] = refs;
|
|
3444
3862
|
if (missing.length) {
|
|
3445
|
-
manualSteps.push(
|
|
3446
|
-
|
|
3863
|
+
out2.manualSteps.push(
|
|
3864
|
+
style !== "none" ? `Set ${missing.join(", ")} in your environment so the "${t.name}" MCP server can authenticate in ${opts.platformName}.` : `Add ${missing.join(", ")} for the "${t.name}" MCP server in ${opts.platformName}. Nomad does not write secret values.`
|
|
3447
3865
|
);
|
|
3448
3866
|
}
|
|
3867
|
+
if (optionalMissing.length) {
|
|
3868
|
+
out2.manualSteps.push(`If you use them, set ${optionalMissing.join(", ")} for the "${t.name}" MCP server in ${opts.platformName}. They were optional on the source and ${opts.platformName} may not accept an unset reference, so Nomad left them out.`);
|
|
3869
|
+
}
|
|
3449
3870
|
}
|
|
3450
|
-
return
|
|
3871
|
+
return out2;
|
|
3451
3872
|
}
|
|
3452
3873
|
function modelFamily(model) {
|
|
3453
3874
|
if (!model) return null;
|
|
@@ -3527,11 +3948,13 @@ function parseMixedMemory(text3, opts) {
|
|
|
3527
3948
|
if (outside) entries.push(...parseMemoryMarkdown(outside, opts).filter((e) => !/^#\s/.test(e.content)));
|
|
3528
3949
|
return entries;
|
|
3529
3950
|
}
|
|
3530
|
-
var TEXT_EXT2, MARKER_RE, KIND_TITLES2, SECTION_RE;
|
|
3951
|
+
var TEXT_EXT2, MARKER_RE, KIND_TITLES2, SECTION_RE, ENV_REF;
|
|
3531
3952
|
var init_util = __esm({
|
|
3532
3953
|
"../../packages/adapters/src/util.ts"() {
|
|
3533
3954
|
"use strict";
|
|
3534
3955
|
init_src2();
|
|
3956
|
+
init_known_servers();
|
|
3957
|
+
init_elizaos_known_plugins();
|
|
3535
3958
|
init_node();
|
|
3536
3959
|
init_src3();
|
|
3537
3960
|
init_src4();
|
|
@@ -3549,6 +3972,7 @@ var init_util = __esm({
|
|
|
3549
3972
|
document: "Documents"
|
|
3550
3973
|
};
|
|
3551
3974
|
SECTION_RE = /<!-- nomad:section ([^>]*?) -->/g;
|
|
3975
|
+
ENV_REF = /^\$\{(env:)?([A-Za-z_][A-Za-z0-9_]*)(:-([^}]*))?\}$/;
|
|
3552
3976
|
}
|
|
3553
3977
|
});
|
|
3554
3978
|
|
|
@@ -3744,7 +4168,8 @@ var init_generic = __esm({
|
|
|
3744
4168
|
});
|
|
3745
4169
|
|
|
3746
4170
|
// ../../packages/adapters/src/claude-code.ts
|
|
3747
|
-
import {
|
|
4171
|
+
import { realpathSync as realpathSync3 } from "fs";
|
|
4172
|
+
import { basename as basename3, dirname as dirname2, join as join4, resolve as resolve2, sep as sep2 } from "path";
|
|
3748
4173
|
async function layoutOf(root) {
|
|
3749
4174
|
const user = basename3(root) === ".claude" || !await pathExists(join4(root, ".claude")) && (await pathExists(join4(root, "settings.json")) || await isDirectory(join4(root, "agents")));
|
|
3750
4175
|
if (user) {
|
|
@@ -3865,6 +4290,86 @@ function subagentModel(doc) {
|
|
|
3865
4290
|
for (const a of ["opus", "sonnet", "haiku"]) if (lower.includes(a)) return a;
|
|
3866
4291
|
return void 0;
|
|
3867
4292
|
}
|
|
4293
|
+
async function readInstalledPlugins(root, settings2, notes) {
|
|
4294
|
+
const out2 = { tools: [], skills: [], integrations: [], sourceFiles: [] };
|
|
4295
|
+
const enabled = Object.entries(settings2?.enabledPlugins ?? {}).filter(([, v]) => v === true).map(([k]) => k);
|
|
4296
|
+
if (!enabled.length) return out2;
|
|
4297
|
+
const pluginsRoot = join4(root, "plugins");
|
|
4298
|
+
const roots = [pluginsRoot, process.env.CLAUDE_CODE_PLUGIN_CACHE_DIR].filter((x) => !!x).map((r) => {
|
|
4299
|
+
try {
|
|
4300
|
+
return realpathSync3(r);
|
|
4301
|
+
} catch {
|
|
4302
|
+
return r;
|
|
4303
|
+
}
|
|
4304
|
+
});
|
|
4305
|
+
const installedPath = join4(pluginsRoot, "installed_plugins.json");
|
|
4306
|
+
const installed = await readJson2(installedPath, notes);
|
|
4307
|
+
if (installed) out2.sourceFiles.push(installedPath);
|
|
4308
|
+
const map = installed?.plugins && typeof installed.plugins === "object" && !Array.isArray(installed.plugins) ? installed.plugins : installed ?? {};
|
|
4309
|
+
const marketplaces = await readJson2(join4(pluginsRoot, "known_marketplaces.json"), []) ?? {};
|
|
4310
|
+
for (const id of enabled) {
|
|
4311
|
+
const raw = map[id];
|
|
4312
|
+
const entry = Array.isArray(raw) ? raw.find((e) => e?.scope === "user") ?? raw[0] : raw;
|
|
4313
|
+
if (!entry || typeof entry.installPath !== "string") {
|
|
4314
|
+
notes.push({ level: "warning", category: "integrations", message: `Plugin ${id} is enabled but its install location was not found, so it was not read.` });
|
|
4315
|
+
continue;
|
|
4316
|
+
}
|
|
4317
|
+
let dir;
|
|
4318
|
+
try {
|
|
4319
|
+
dir = realpathSync3(entry.installPath);
|
|
4320
|
+
} catch {
|
|
4321
|
+
notes.push({ level: "warning", category: "integrations", message: `Plugin ${id} is enabled but its folder is missing.` });
|
|
4322
|
+
continue;
|
|
4323
|
+
}
|
|
4324
|
+
if (!roots.some((r) => dir === r || dir.startsWith(r + sep2))) {
|
|
4325
|
+
notes.push({ level: "warning", category: "integrations", message: `Plugin ${id} is installed outside the plugins folder, so it was not read.` });
|
|
4326
|
+
continue;
|
|
4327
|
+
}
|
|
4328
|
+
const [pluginName, marketplace] = id.split("@");
|
|
4329
|
+
const provenance = { note: `plugin ${id}`, extra: { plugin: id, pluginHost: P } };
|
|
4330
|
+
const manifestPath = join4(dir, ".claude-plugin", "plugin.json");
|
|
4331
|
+
const manifest = await readJson2(manifestPath, notes) ?? {};
|
|
4332
|
+
if (await pathExists(manifestPath)) out2.sourceFiles.push(manifestPath);
|
|
4333
|
+
const servers = {};
|
|
4334
|
+
if (manifest.mcpServers && typeof manifest.mcpServers === "object") Object.assign(servers, manifest.mcpServers);
|
|
4335
|
+
const mcpPath = join4(dir, typeof manifest.mcpServers === "string" ? manifest.mcpServers : ".mcp.json");
|
|
4336
|
+
const mcpFile = await readJson2(mcpPath, notes);
|
|
4337
|
+
if (mcpFile?.mcpServers) {
|
|
4338
|
+
out2.sourceFiles.push(mcpPath);
|
|
4339
|
+
Object.assign(servers, mcpFile.mcpServers);
|
|
4340
|
+
} else if (mcpFile && typeof mcpFile === "object") {
|
|
4341
|
+
const flat = Object.entries(mcpFile).filter(
|
|
4342
|
+
([, v]) => !!v && typeof v === "object" && !Array.isArray(v) && (typeof v.command === "string" || typeof v.url === "string")
|
|
4343
|
+
);
|
|
4344
|
+
if (flat.length) {
|
|
4345
|
+
out2.sourceFiles.push(mcpPath);
|
|
4346
|
+
Object.assign(servers, Object.fromEntries(flat));
|
|
4347
|
+
}
|
|
4348
|
+
}
|
|
4349
|
+
out2.tools.push(...toolsFromMcpServers(servers, P, `plugins/${id}`, { notes, ...provenance }));
|
|
4350
|
+
const skillDirs = Array.isArray(manifest.skills) ? manifest.skills : typeof manifest.skills === "string" ? [manifest.skills] : ["skills"];
|
|
4351
|
+
for (const rel of skillDirs) {
|
|
4352
|
+
if (typeof rel !== "string") continue;
|
|
4353
|
+
const abs = resolve2(dir, rel);
|
|
4354
|
+
if (abs !== dir && !abs.startsWith(dir + sep2)) continue;
|
|
4355
|
+
for (const sk of await readSkillsTree(abs, P, notes, 1)) {
|
|
4356
|
+
sk.source = { ...sk.source ?? { platform: P }, note: provenance.note, ...provenance.extra };
|
|
4357
|
+
out2.skills.push(sk);
|
|
4358
|
+
}
|
|
4359
|
+
}
|
|
4360
|
+
const repo = marketplaces?.[marketplace ?? ""]?.source?.repo;
|
|
4361
|
+
out2.integrations.push({
|
|
4362
|
+
name: id,
|
|
4363
|
+
kind: "claude-code-plugin",
|
|
4364
|
+
requiresAuth: false,
|
|
4365
|
+
config: { ...typeof entry.version === "string" ? { version: entry.version } : {}, ...marketplace ? { marketplace } : {}, ...typeof repo === "string" ? { marketplaceRepo: repo } : {}, plugin: pluginName },
|
|
4366
|
+
notes: "Installed Claude Code plugin",
|
|
4367
|
+
source: { platform: P, path: `plugins/${id}` }
|
|
4368
|
+
});
|
|
4369
|
+
notes.push({ level: "info", category: "integrations", message: `Read installed plugin ${id} (installed plugin read, not installed anywhere by Nomad).` });
|
|
4370
|
+
}
|
|
4371
|
+
return out2;
|
|
4372
|
+
}
|
|
3868
4373
|
async function readMain(root, notes, includeSecrets, agentId) {
|
|
3869
4374
|
const L = await layoutOf(root);
|
|
3870
4375
|
const sourceFiles = [];
|
|
@@ -3952,7 +4457,22 @@ async function readMain(root, notes, includeSecrets, agentId) {
|
|
|
3952
4457
|
const mcp = await readJson2(mcpFile, notes);
|
|
3953
4458
|
if (mcp?.mcpServers) {
|
|
3954
4459
|
sourceFiles.push(mcpFile);
|
|
3955
|
-
doc.tools.push(...toolsFromMcpServers(mcp.mcpServers, P, L.mcpPath));
|
|
4460
|
+
doc.tools.push(...toolsFromMcpServers(mcp.mcpServers, P, L.mcpPath, { notes }));
|
|
4461
|
+
}
|
|
4462
|
+
if (L.user) {
|
|
4463
|
+
const plugins = await readInstalledPlugins(root, settings2, notes);
|
|
4464
|
+
for (const t of plugins.tools) {
|
|
4465
|
+
const same2 = doc.tools.find((d) => d.mcp && t.mcp && d.mcp.transport === t.mcp.transport && !!d.mcp.url && d.mcp.url === t.mcp.url);
|
|
4466
|
+
if (same2) {
|
|
4467
|
+
notes.push({ level: "info", category: "tools", message: `"${t.name}" from plugin ${String(t.source?.plugin)} points at the same server as "${same2.name}", so it is read once.` });
|
|
4468
|
+
continue;
|
|
4469
|
+
}
|
|
4470
|
+
if (doc.tools.some((d) => d.name === t.name)) t.name = `${t.name}-plugin`;
|
|
4471
|
+
doc.tools.push(t);
|
|
4472
|
+
}
|
|
4473
|
+
doc.skills.push(...plugins.skills.filter((sk) => !doc.skills.some((d) => d.name === sk.name)));
|
|
4474
|
+
doc.integrations.push(...plugins.integrations);
|
|
4475
|
+
sourceFiles.push(...plugins.sourceFiles);
|
|
3956
4476
|
}
|
|
3957
4477
|
void includeSecrets;
|
|
3958
4478
|
return { doc, sourceFiles };
|
|
@@ -4016,8 +4536,15 @@ async function planMain(doc, ctx, L) {
|
|
|
4016
4536
|
description: "Agent name, persona and instructions in a Nomad managed section of CLAUDE.md"
|
|
4017
4537
|
});
|
|
4018
4538
|
if (doc.identity.persona) conversions.push({ category: "identity", item: "persona", from: "persona", to: "Persona section in CLAUDE.md" });
|
|
4539
|
+
const fromPlugins = new Set([...doc.tools, ...doc.skills].map((x) => pluginOf(x, P)).filter((x) => !!x));
|
|
4540
|
+
for (const id of fromPlugins) {
|
|
4541
|
+
const info = doc.integrations.find((i) => i.kind === "claude-code-plugin" && i.name === id)?.config;
|
|
4542
|
+
const marketName = id.split("@")[1];
|
|
4543
|
+
const market = typeof info?.marketplaceRepo === "string" ? info.marketplaceRepo : (marketName && KNOWN_MARKETPLACE_REPOS[marketName]) ?? marketName ?? "<marketplace>";
|
|
4544
|
+
manualSteps.push(`Install the plugin ${id} in Claude Code: /plugin marketplace add ${market}, then /plugin install ${id}. Nomad does not copy plugin servers or skills.`);
|
|
4545
|
+
}
|
|
4019
4546
|
if (wants(ctx, "skills")) {
|
|
4020
|
-
for (const s of doc.skills) {
|
|
4547
|
+
for (const s of doc.skills.filter((x) => !pluginOf(x, P))) {
|
|
4021
4548
|
if (s.frontmatter["x-claude-code-command"] === true || s.frontmatter["x-codex-prompt"] === true) {
|
|
4022
4549
|
const { "x-claude-code-command": _c, "x-codex-prompt": _p, ...fm } = s.frontmatter;
|
|
4023
4550
|
if (_p) conversions.push({ category: "skills", item: s.name, from: "Codex custom prompt", to: "Claude Code slash command" });
|
|
@@ -4050,9 +4577,16 @@ async function planMain(doc, ctx, L) {
|
|
|
4050
4577
|
files.push({ path: L.settings, content: JSON.stringify(settings2, null, 2) + "\n", strategy: "merge-json", component: "permissions", description: "Permissions and model in settings.json" });
|
|
4051
4578
|
}
|
|
4052
4579
|
if (wants(ctx, "tools")) {
|
|
4053
|
-
const mcpTools = doc.tools.filter((t) => t.kind === "mcp" && t.mcp);
|
|
4580
|
+
const mcpTools = doc.tools.filter((t) => t.kind === "mcp" && t.mcp && !pluginOf(t, P));
|
|
4054
4581
|
if (mcpTools.length) {
|
|
4055
|
-
const r = mcpServersFromTools(mcpTools, {
|
|
4582
|
+
const r = mcpServersFromTools(mcpTools, {
|
|
4583
|
+
platformName: "Claude Code",
|
|
4584
|
+
envRefStyle: "dollar",
|
|
4585
|
+
typeField: true,
|
|
4586
|
+
optionalRef: (t, name) => (t.mcp?.emptyOkEnv ?? []).includes(name) ? `\${${name}:-}` : null
|
|
4587
|
+
});
|
|
4588
|
+
unsupported.push(...r.unsupported);
|
|
4589
|
+
notes.push(...r.notes);
|
|
4056
4590
|
files.push({
|
|
4057
4591
|
path: L.mcpPath,
|
|
4058
4592
|
root: L.mcpRoot,
|
|
@@ -4070,7 +4604,7 @@ async function planMain(doc, ctx, L) {
|
|
|
4070
4604
|
for (const w of doc.workflows) unsupported.push({ category: "workflows", item: w.name, reason: "Claude Code has no local scheduler.", alternative: "Use a system scheduler or another platform for this routine." });
|
|
4071
4605
|
manualSteps.push(...workflowManualSteps(doc, "Claude Code"));
|
|
4072
4606
|
}
|
|
4073
|
-
if (wants(ctx, "integrations")) for (const i of doc.integrations) manualSteps.push(`Reconnect the ${i.name} integration in Claude Code.`);
|
|
4607
|
+
if (wants(ctx, "integrations")) for (const i of doc.integrations.filter((x) => !(x.kind === "claude-code-plugin" && fromPlugins.has(x.name)))) manualSteps.push(integrationStep(i, "Claude Code", `Reconnect the ${i.name} integration in Claude Code.`));
|
|
4074
4608
|
if (wants(ctx, "knowledge") && (doc.knowledge.length || doc.files.length)) manualSteps.push(`Copy ${doc.knowledge.length + doc.files.length} knowledge file(s) into your project and reference them from CLAUDE.md.`);
|
|
4075
4609
|
return { nativeId: "main", files, notes, manualSteps, conversions, unsupported };
|
|
4076
4610
|
}
|
|
@@ -4099,7 +4633,7 @@ function planSubagent(doc, ctx, L, stem) {
|
|
|
4099
4633
|
for (const r of restricted) unsupported.push({ category: "permissions", item: `${r.effect} ${r.capability} (${r.pattern})`, reason: "Subagents only support a tool allowlist.", alternative: "Add the rule to settings.json if it should apply to the whole project." });
|
|
4100
4634
|
return { nativeId: `subagent:${stem}`, files, notes: [], manualSteps, conversions: [], unsupported };
|
|
4101
4635
|
}
|
|
4102
|
-
var P, TOOL_CAP, SUBAGENT_TOOLS, claudeCodeAdapter;
|
|
4636
|
+
var P, KNOWN_MARKETPLACE_REPOS, TOOL_CAP, SUBAGENT_TOOLS, claudeCodeAdapter;
|
|
4103
4637
|
var init_claude_code = __esm({
|
|
4104
4638
|
"../../packages/adapters/src/claude-code.ts"() {
|
|
4105
4639
|
"use strict";
|
|
@@ -4108,6 +4642,9 @@ var init_claude_code = __esm({
|
|
|
4108
4642
|
init_catalog();
|
|
4109
4643
|
init_util();
|
|
4110
4644
|
P = "claude-code";
|
|
4645
|
+
KNOWN_MARKETPLACE_REPOS = {
|
|
4646
|
+
"oak-agent-kit": "OakAgentKit/oak"
|
|
4647
|
+
};
|
|
4111
4648
|
TOOL_CAP = {
|
|
4112
4649
|
Bash: "shell",
|
|
4113
4650
|
Read: "read",
|
|
@@ -4203,12 +4740,12 @@ var init_claude_code = __esm({
|
|
|
4203
4740
|
}
|
|
4204
4741
|
if (wants(ctx, "skills") && doc.skills.length && !nativeId.startsWith("subagent:")) {
|
|
4205
4742
|
const names = new Set(got.skills.map((s) => s.name));
|
|
4206
|
-
const missing = doc.skills.filter((s) => !names.has(s.name));
|
|
4743
|
+
const missing = doc.skills.filter((s) => !pluginOf(s, this.info.id) && !names.has(s.name));
|
|
4207
4744
|
checks.push({ name: "Skills written", ok: missing.length === 0, detail: missing.length ? `Missing: ${missing.map((s) => s.name).join(", ")}` : void 0 });
|
|
4208
4745
|
}
|
|
4209
4746
|
if (wants(ctx, "tools") && doc.tools.some((t) => t.kind === "mcp") && !nativeId.startsWith("subagent:")) {
|
|
4210
4747
|
const names = new Set(got.tools.map((t) => t.name));
|
|
4211
|
-
const missing = doc.tools.filter((t) => t.kind === "mcp" && !names.has(t.name));
|
|
4748
|
+
const missing = doc.tools.filter((t) => t.kind === "mcp" && t.enabled !== false && !pluginOf(t, this.info.id) && !names.has(t.name));
|
|
4212
4749
|
checks.push({ name: "MCP servers configured", ok: missing.length === 0, detail: missing.length ? `Missing: ${missing.map((t) => t.name).join(", ")}` : void 0 });
|
|
4213
4750
|
}
|
|
4214
4751
|
return checks;
|
|
@@ -4352,8 +4889,14 @@ var init_codex = __esm({
|
|
|
4352
4889
|
doc.permissions = policyFromCodexConfig(cfg);
|
|
4353
4890
|
if (cfg.mcp_servers) {
|
|
4354
4891
|
const servers = {};
|
|
4355
|
-
for (const [name, s] of Object.entries(cfg.mcp_servers))
|
|
4356
|
-
|
|
4892
|
+
for (const [name, s] of Object.entries(cfg.mcp_servers)) {
|
|
4893
|
+
const env = { ...s.env ?? {} };
|
|
4894
|
+
for (const v of Array.isArray(s.env_vars) ? s.env_vars : []) if (typeof v === "string" && !(v in env)) env[v] = `\${${v}}`;
|
|
4895
|
+
const headers = { ...s.http_headers ?? {} };
|
|
4896
|
+
for (const [h, v] of Object.entries(s.env_http_headers ?? {})) if (typeof v === "string") headers[h] = `\${${v}}`;
|
|
4897
|
+
servers[name] = { ...s, env, headers };
|
|
4898
|
+
}
|
|
4899
|
+
doc.tools.push(...toolsFromMcpServers(servers, P2, L.config, { notes }));
|
|
4357
4900
|
}
|
|
4358
4901
|
if (cfg.profiles) doc.extensions["x-codex"] = { profiles: cfg.profiles };
|
|
4359
4902
|
}
|
|
@@ -4432,14 +4975,25 @@ var init_codex = __esm({
|
|
|
4432
4975
|
if (wants(ctx, "tools")) {
|
|
4433
4976
|
const mcpTools = doc.tools.filter((t) => t.kind === "mcp" && t.mcp);
|
|
4434
4977
|
if (mcpTools.length) {
|
|
4435
|
-
const r = mcpServersFromTools(mcpTools, { platformName: "Codex",
|
|
4978
|
+
const r = mcpServersFromTools(mcpTools, { platformName: "Codex", envRefStyle: "none" });
|
|
4436
4979
|
const servers = {};
|
|
4437
4980
|
for (const [name, s] of Object.entries(r.servers)) {
|
|
4438
|
-
const
|
|
4439
|
-
|
|
4981
|
+
const refs = r.refs[name];
|
|
4982
|
+
if (s.url) {
|
|
4983
|
+
servers[name] = {
|
|
4984
|
+
url: s.url,
|
|
4985
|
+
...s.headers ? { http_headers: s.headers } : {},
|
|
4986
|
+
...refs?.headers.length ? { env_http_headers: Object.fromEntries(refs.headers) } : {}
|
|
4987
|
+
};
|
|
4988
|
+
continue;
|
|
4989
|
+
}
|
|
4990
|
+
const { headers: _h, ...rest } = s;
|
|
4991
|
+
servers[name] = { ...rest, ...refs?.env.length ? { env_vars: refs.env } : {} };
|
|
4440
4992
|
}
|
|
4441
4993
|
config.mcp_servers = servers;
|
|
4442
|
-
manualSteps.push(...r.manualSteps);
|
|
4994
|
+
manualSteps.push(...r.manualSteps.map((m) => m.replace(/^Add (.+) for the "(.+)" MCP server in Codex\. Nomad does not write secret values\.$/, 'Set $1 in your shell before starting Codex: the "$2" MCP server forwards them (env_vars). Nomad does not write secret values.')));
|
|
4995
|
+
unsupported.push(...r.unsupported);
|
|
4996
|
+
notes.push(...r.notes);
|
|
4443
4997
|
}
|
|
4444
4998
|
for (const t of doc.tools.filter((t2) => t2.kind !== "mcp")) unsupported.push({ category: "tools", item: t.name, reason: "Only MCP servers can be configured in Codex." });
|
|
4445
4999
|
}
|
|
@@ -4451,7 +5005,7 @@ var init_codex = __esm({
|
|
|
4451
5005
|
for (const w of doc.workflows) unsupported.push({ category: "workflows", item: w.name, reason: "Codex has no scheduler." });
|
|
4452
5006
|
manualSteps.push(...workflowManualSteps(doc, "Codex"));
|
|
4453
5007
|
}
|
|
4454
|
-
if (wants(ctx, "integrations")) for (const i of doc.integrations) manualSteps.push(`Reconnect the ${i.name} integration for Codex.`);
|
|
5008
|
+
if (wants(ctx, "integrations")) for (const i of doc.integrations) manualSteps.push(integrationStep(i, "Codex", `Reconnect the ${i.name} integration for Codex.`));
|
|
4455
5009
|
if (wants(ctx, "knowledge") && (doc.knowledge.length || doc.files.length)) manualSteps.push(`Copy ${doc.knowledge.length + doc.files.length} knowledge file(s) into the project and mention them in AGENTS.md.`);
|
|
4456
5010
|
return { nativeId: "main", files, notes, manualSteps, conversions, unsupported };
|
|
4457
5011
|
},
|
|
@@ -4482,12 +5036,12 @@ var init_codex = __esm({
|
|
|
4482
5036
|
}
|
|
4483
5037
|
if (wants(ctx, "skills") && doc.skills.length) {
|
|
4484
5038
|
const names = new Set(got.skills.map((s) => s.name));
|
|
4485
|
-
const missing = doc.skills.filter((s) => !names.has(s.name) && !names.has(safeName2(s.name)));
|
|
5039
|
+
const missing = doc.skills.filter((s) => !pluginOf(s, this.info.id) && !names.has(s.name) && !names.has(safeName2(s.name)));
|
|
4486
5040
|
checks.push({ name: "Skills written", ok: !missing.length, detail: missing.length ? `Missing: ${missing.map((s) => s.name).join(", ")}` : void 0 });
|
|
4487
5041
|
}
|
|
4488
5042
|
if (wants(ctx, "tools") && doc.tools.some((t) => t.kind === "mcp")) {
|
|
4489
5043
|
const names = new Set(got.tools.map((t) => t.name));
|
|
4490
|
-
const missing = doc.tools.filter((t) => t.kind === "mcp" && !names.has(t.name));
|
|
5044
|
+
const missing = doc.tools.filter((t) => t.kind === "mcp" && t.enabled !== false && !pluginOf(t, this.info.id) && !names.has(t.name));
|
|
4491
5045
|
checks.push({ name: "MCP servers configured", ok: !missing.length, detail: missing.length ? `Missing: ${missing.map((t) => t.name).join(", ")}` : void 0 });
|
|
4492
5046
|
}
|
|
4493
5047
|
return checks;
|
|
@@ -4887,7 +5441,7 @@ ${m.content.trim()}
|
|
|
4887
5441
|
if (t.mcp) manualSteps.push(`Add the "${t.name}" MCP server (${t.mcp.command ?? t.mcp.url ?? ""} ${t.mcp.args.join(" ")}) through your OpenClaw MCP plugin.`.replace(/\s+\)/, ")"));
|
|
4888
5442
|
}
|
|
4889
5443
|
}
|
|
4890
|
-
if (wants(ctx, "integrations")) for (const i of doc.integrations) manualSteps.push(`Reconnect ${i.name} in OpenClaw (credentials are never migrated).`);
|
|
5444
|
+
if (wants(ctx, "integrations")) for (const i of doc.integrations) manualSteps.push(integrationStep(i, "OpenClaw", `Reconnect ${i.name} in OpenClaw (credentials are never migrated).`));
|
|
4891
5445
|
if (wants(ctx, "knowledge") && (doc.knowledge.length || doc.files.length)) manualSteps.push(`Copy ${doc.knowledge.length + doc.files.length} knowledge file(s) into the workspace.`);
|
|
4892
5446
|
if (newEntry) notes.push({ level: "info", message: `A new agent "${agentId}" with its own workspace will be created. Restart the gateway to load it.` });
|
|
4893
5447
|
return { nativeId: agentId, files, notes, manualSteps, conversions, unsupported };
|
|
@@ -4977,7 +5531,7 @@ var init_openclaw = __esm({
|
|
|
4977
5531
|
}
|
|
4978
5532
|
if (wants(ctx, "skills") && doc.skills.length) {
|
|
4979
5533
|
const names = new Set(got.skills.map((s) => s.name));
|
|
4980
|
-
const missing = doc.skills.filter((s) => !names.has(s.name));
|
|
5534
|
+
const missing = doc.skills.filter((s) => !pluginOf(s, this.info.id) && !names.has(s.name));
|
|
4981
5535
|
checks.push({ name: "Skills written", ok: !missing.length, detail: missing.length ? `Missing: ${missing.map((s) => s.name).join(", ")}` : void 0 });
|
|
4982
5536
|
}
|
|
4983
5537
|
if (wants(ctx, "workflows") && doc.workflows.length) {
|
|
@@ -5055,6 +5609,70 @@ function memoryEntriesFrom(text3, kind, scope, path) {
|
|
|
5055
5609
|
source: { platform: P4, path }
|
|
5056
5610
|
}));
|
|
5057
5611
|
}
|
|
5612
|
+
async function readPlugins(h, cfg, notes) {
|
|
5613
|
+
const out2 = { tools: [], skills: [], integrations: [], sourceFiles: [] };
|
|
5614
|
+
const enabled = new Set(Array.isArray(cfg?.plugins?.enabled) ? cfg.plugins.enabled.map(String) : []);
|
|
5615
|
+
const disabled = new Set(Array.isArray(cfg?.plugins?.disabled) ? cfg.plugins.disabled.map(String) : []);
|
|
5616
|
+
const base = join7(h, "plugins");
|
|
5617
|
+
const dirs = [];
|
|
5618
|
+
for (const e of await listDir(base)) {
|
|
5619
|
+
if (!e.dir || e.name.startsWith(".")) continue;
|
|
5620
|
+
const abs = join7(base, e.name);
|
|
5621
|
+
if (await pathExists(join7(abs, "plugin.json")) || await pathExists(join7(abs, "plugin.yaml"))) dirs.push({ rel: e.name, abs });
|
|
5622
|
+
else for (const c2 of await listDir(abs)) if (c2.dir && !c2.name.startsWith(".") && (await pathExists(join7(abs, c2.name, "plugin.json")) || await pathExists(join7(abs, c2.name, "plugin.yaml")))) dirs.push({ rel: `${e.name}/${c2.name}`, abs: join7(abs, c2.name) });
|
|
5623
|
+
}
|
|
5624
|
+
for (const d of dirs) {
|
|
5625
|
+
const manifestText = await readTextIfExists(join7(d.abs, "plugin.json"));
|
|
5626
|
+
if (manifestText === null) {
|
|
5627
|
+
out2.integrations.push({ name: d.rel.split("/").pop(), kind: "hermes-plugin", requiresAuth: false, config: { native: true }, notes: "Native Hermes plugin (Python). Its code was not read or copied.", source: { platform: P4, path: `plugins/${d.rel}` } });
|
|
5628
|
+
notes.push({ level: "info", category: "integrations", message: `Hermes plugin ${d.rel} is a native plugin: code not read or copied.` });
|
|
5629
|
+
continue;
|
|
5630
|
+
}
|
|
5631
|
+
let manifest;
|
|
5632
|
+
try {
|
|
5633
|
+
manifest = JSON.parse(manifestText);
|
|
5634
|
+
} catch {
|
|
5635
|
+
notes.push({ level: "warning", category: "integrations", message: `plugins/${d.rel}/plugin.json could not be parsed and was skipped.` });
|
|
5636
|
+
continue;
|
|
5637
|
+
}
|
|
5638
|
+
out2.sourceFiles.push(join7(d.abs, "plugin.json"));
|
|
5639
|
+
const name = typeof manifest.name === "string" && manifest.name ? manifest.name : d.rel.split("/").pop();
|
|
5640
|
+
const on = enabled.has(name) && !disabled.has(name);
|
|
5641
|
+
const provenance = { note: `plugin ${name}`, extra: { plugin: name, pluginHost: P4 } };
|
|
5642
|
+
const trust = manifest.extensions?.["com.nousresearch.hermes"]?.servers ?? {};
|
|
5643
|
+
const mcpText = await readTextIfExists(join7(d.abs, "mcp.json"));
|
|
5644
|
+
const requiredEnv = [];
|
|
5645
|
+
if (mcpText !== null) {
|
|
5646
|
+
out2.sourceFiles.push(join7(d.abs, "mcp.json"));
|
|
5647
|
+
try {
|
|
5648
|
+
const servers = JSON.parse(mcpText).mcpServers ?? {};
|
|
5649
|
+
const tools = toolsFromMcpServers(servers, P4, `plugins/${d.rel}/mcp.json`, { notes, refsOptional: true, ...provenance });
|
|
5650
|
+
for (const t of tools) {
|
|
5651
|
+
if (!on) t.enabled = false;
|
|
5652
|
+
const tr = trust[t.name]?.trust;
|
|
5653
|
+
if (typeof tr === "string") t.extensions = { "x-hermes": { trust: tr } };
|
|
5654
|
+
for (const [k, v] of Object.entries(t.mcp.env)) if (!("value" in v)) requiredEnv.push(k);
|
|
5655
|
+
}
|
|
5656
|
+
out2.tools.push(...tools);
|
|
5657
|
+
} catch {
|
|
5658
|
+
notes.push({ level: "warning", category: "tools", message: `plugins/${d.rel}/mcp.json could not be parsed and was skipped.` });
|
|
5659
|
+
}
|
|
5660
|
+
}
|
|
5661
|
+
const skills = on ? await readSkillsTree(join7(d.abs, "skills"), P4, notes, 2) : [];
|
|
5662
|
+
for (const sk of skills) sk.source = { ...sk.source ?? { platform: P4 }, note: provenance.note, ...provenance.extra };
|
|
5663
|
+
out2.skills.push(...skills);
|
|
5664
|
+
out2.integrations.push({
|
|
5665
|
+
name,
|
|
5666
|
+
kind: "hermes-plugin",
|
|
5667
|
+
requiresAuth: requiredEnv.length > 0,
|
|
5668
|
+
config: { ...typeof manifest.version === "string" ? { version: manifest.version } : {}, enabled: on, ...requiredEnv.length ? { requiredEnv: [...new Set(requiredEnv)] } : {} },
|
|
5669
|
+
notes: on ? "Installed and enabled Hermes plugin" : "Installed Hermes plugin, not enabled",
|
|
5670
|
+
source: { platform: P4, path: `plugins/${d.rel}/plugin.json` }
|
|
5671
|
+
});
|
|
5672
|
+
notes.push({ level: "info", category: "integrations", message: `Read installed Hermes plugin ${name}${on ? "" : " (not enabled, so its servers stay off)"}. Nomad never installs or enables plugins.` });
|
|
5673
|
+
}
|
|
5674
|
+
return out2;
|
|
5675
|
+
}
|
|
5058
5676
|
async function readHome(root, nativeId, notes, agentId) {
|
|
5059
5677
|
const h = homeFor(root, nativeId);
|
|
5060
5678
|
const sourceFiles = [];
|
|
@@ -5104,13 +5722,21 @@ ${doc.identity.persona}` : outside;
|
|
|
5104
5722
|
const model = typeof cfg.model === "string" ? cfg.model : cfg.model?.default;
|
|
5105
5723
|
if (typeof model === "string") doc.models.preferred = model;
|
|
5106
5724
|
if (typeof cfg.model?.provider === "string") doc.models.provider = cfg.model.provider;
|
|
5107
|
-
if (cfg.mcp_servers) doc.tools.push(...toolsFromMcpServers(cfg.mcp_servers, P4, "config.yaml"));
|
|
5725
|
+
if (cfg.mcp_servers) doc.tools.push(...toolsFromMcpServers(cfg.mcp_servers, P4, "config.yaml", { notes, refsOptional: true }));
|
|
5108
5726
|
if (Array.isArray(cfg.command_allowlist)) {
|
|
5109
5727
|
doc.permissions = { mode: "ask", rules: cfg.command_allowlist.map((c2) => rule("shell", "allow", String(c2), "hermes:command_allowlist")), notes: ["Hermes command allowlist"] };
|
|
5110
5728
|
}
|
|
5111
5729
|
}
|
|
5112
5730
|
if (await pathExists(join7(h, ".env"))) notes.push({ level: "info", category: "integrations", message: "~/.hermes/.env holds secrets. It is never read or migrated." });
|
|
5113
5731
|
doc.skills.push(...await readSkillsTree(join7(h, "skills"), P4, notes, 3));
|
|
5732
|
+
const plugins = await readPlugins(h, cfg, notes);
|
|
5733
|
+
for (const t of plugins.tools) {
|
|
5734
|
+
if (doc.tools.some((d) => d.name === t.name)) t.name = `${t.name}-plugin`;
|
|
5735
|
+
doc.tools.push(t);
|
|
5736
|
+
}
|
|
5737
|
+
doc.skills.push(...plugins.skills.filter((s) => !doc.skills.some((d) => d.name === s.name)));
|
|
5738
|
+
doc.integrations.push(...plugins.integrations);
|
|
5739
|
+
sourceFiles.push(...plugins.sourceFiles);
|
|
5114
5740
|
const jobsText = await read("cron/jobs.json");
|
|
5115
5741
|
if (jobsText) {
|
|
5116
5742
|
try {
|
|
@@ -5179,15 +5805,15 @@ async function planHome(doc, ctx) {
|
|
|
5179
5805
|
const user = doc.memory.filter((m) => m.scope === "user" || m.kind === "profile");
|
|
5180
5806
|
const logs = doc.memory.filter((m) => m.kind === "daily-log" || m.kind === "document");
|
|
5181
5807
|
const rest = doc.memory.filter((m) => !user.includes(m) && !logs.includes(m));
|
|
5182
|
-
const
|
|
5808
|
+
const sep5 = `
|
|
5183
5809
|
${HERMES_DELIMITER}
|
|
5184
5810
|
`;
|
|
5185
5811
|
const check = async (rel, entries, limit, label) => {
|
|
5186
5812
|
if (!entries.length) return;
|
|
5187
5813
|
const existing = splitEntries(await readTextIfExists(join7(h, rel)) ?? "");
|
|
5188
5814
|
const all = [...existing, ...entries.map((e) => plainEntry(e.content)).filter((e) => !existing.includes(e))];
|
|
5189
|
-
const size = all.join(
|
|
5190
|
-
files.push({ path: `${prefix}${rel}`, content: entries.map((e) => plainEntry(e.content)).join(
|
|
5815
|
+
const size = all.join(sep5).length;
|
|
5816
|
+
files.push({ path: `${prefix}${rel}`, content: entries.map((e) => plainEntry(e.content)).join(sep5) + "\n", strategy: "append-entries", entryDelimiter: HERMES_DELIMITER, component: "memory", description: `${entries.length} ${label} entries` });
|
|
5191
5817
|
if (size > limit) {
|
|
5192
5818
|
notes.push({ level: "warning", category: "memory", message: `${rel} will hold ${size} characters, above the Hermes default limit of ${limit}. Hermes keeps loading it but refuses new memory until it is consolidated.` });
|
|
5193
5819
|
manualSteps.push(`Raise memory.${label === "user" ? "user_char_limit" : "memory_char_limit"} in config.yaml to at least ${size}, or ask Hermes to consolidate ${rel}.`);
|
|
@@ -5204,8 +5830,12 @@ ${m.content.trim()}
|
|
|
5204
5830
|
}
|
|
5205
5831
|
if (logs.length) conversions.push({ category: "memory", item: `${logs.length} logs`, from: "daily logs", to: "memories/archive (readable on request, not loaded into every prompt)" });
|
|
5206
5832
|
}
|
|
5833
|
+
const fromPlugins = new Set([...doc.tools, ...doc.skills].map((x) => pluginOf(x, P4)).filter((x) => !!x));
|
|
5834
|
+
for (const name of fromPlugins) {
|
|
5835
|
+
manualSteps.push(`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/.`);
|
|
5836
|
+
}
|
|
5207
5837
|
if (wants(ctx, "skills")) {
|
|
5208
|
-
for (const s of doc.skills) {
|
|
5838
|
+
for (const s of doc.skills.filter((x) => !pluginOf(x, P4))) {
|
|
5209
5839
|
const { "x-claude-code-command": c2, "x-codex-prompt": p, ...fm } = s.frontmatter;
|
|
5210
5840
|
files.push(...skillToFiles({ ...s, frontmatter: fm }, `${prefix}skills/nomad-imports`));
|
|
5211
5841
|
if (c2 || p) conversions.push({ category: "skills", item: s.name, from: c2 ? "Claude Code slash command" : "Codex custom prompt", to: "Hermes skill" });
|
|
@@ -5219,11 +5849,15 @@ ${m.content.trim()}
|
|
|
5219
5849
|
manualSteps.push(`Check that Hermes has a provider for ${model} ("hermes model").`);
|
|
5220
5850
|
}
|
|
5221
5851
|
if (wants(ctx, "tools")) {
|
|
5222
|
-
const mcpTools = doc.tools.filter((t) => t.kind === "mcp" && t.mcp);
|
|
5852
|
+
const mcpTools = doc.tools.filter((t) => t.kind === "mcp" && t.mcp && !pluginOf(t, P4));
|
|
5223
5853
|
if (mcpTools.length) {
|
|
5224
|
-
const r = mcpServersFromTools(mcpTools, { platformName: "Hermes
|
|
5854
|
+
const r = mcpServersFromTools(mcpTools, { platformName: "Hermes", envRefStyle: "dollar", optionalRef: (_t, name) => `\${${name}}` });
|
|
5225
5855
|
cfg.mcp_servers = r.servers;
|
|
5226
|
-
|
|
5856
|
+
const refNames = [...new Set(Object.values(r.refs).flatMap((x) => [...x.env.filter((k) => Object.values(r.servers).some((sv) => sv.env?.[k])), ...x.headers.map(([, v]) => v)]))];
|
|
5857
|
+
if (refNames.length) manualSteps.push(`Add ${refNames.join(", ")} to ~/.hermes/.env (Nomad never reads or writes that file).`);
|
|
5858
|
+
manualSteps.push(...r.manualSteps.filter((m) => !m.startsWith("Set ")));
|
|
5859
|
+
unsupported.push(...r.unsupported);
|
|
5860
|
+
notes.push(...r.notes);
|
|
5227
5861
|
}
|
|
5228
5862
|
}
|
|
5229
5863
|
if (wants(ctx, "permissions")) {
|
|
@@ -5273,7 +5907,7 @@ ${m.content.trim()}
|
|
|
5273
5907
|
manualSteps.push(`Review the imported routines and resume them with "hermes cron resume <id>". Results are delivered locally until you change the target.`);
|
|
5274
5908
|
}
|
|
5275
5909
|
}
|
|
5276
|
-
if (wants(ctx, "integrations")) for (const i of doc.integrations) manualSteps.push(`Reconnect ${i.name} in Hermes ("hermes gateway setup"). Credentials are never migrated.`);
|
|
5910
|
+
if (wants(ctx, "integrations")) for (const i of doc.integrations.filter((x) => !(x.kind === "hermes-plugin" && fromPlugins.has(x.name)))) manualSteps.push(integrationStep(i, "Hermes", `Reconnect ${i.name} in Hermes ("hermes gateway setup"). Credentials are never migrated.`));
|
|
5277
5911
|
if (wants(ctx, "knowledge") && (doc.knowledge.length || doc.files.length)) manualSteps.push(`Copy ${doc.knowledge.length + doc.files.length} knowledge file(s) somewhere Hermes can read them.`);
|
|
5278
5912
|
return { nativeId, files, notes, manualSteps, conversions, unsupported };
|
|
5279
5913
|
}
|
|
@@ -5344,7 +5978,7 @@ var init_hermes = __esm({
|
|
|
5344
5978
|
}
|
|
5345
5979
|
if (wants(ctx, "skills") && doc.skills.length) {
|
|
5346
5980
|
const names = new Set(got.skills.map((s) => s.name));
|
|
5347
|
-
const missing = doc.skills.filter((s) => !names.has(s.name));
|
|
5981
|
+
const missing = doc.skills.filter((s) => !pluginOf(s, this.info.id) && !names.has(s.name));
|
|
5348
5982
|
checks.push({ name: "Skills written", ok: !missing.length, detail: missing.length ? `Missing: ${missing.map((s) => s.name).join(", ")}` : void 0 });
|
|
5349
5983
|
}
|
|
5350
5984
|
if (wants(ctx, "workflows") && doc.workflows.length) {
|
|
@@ -5358,8 +5992,384 @@ var init_hermes = __esm({
|
|
|
5358
5992
|
}
|
|
5359
5993
|
});
|
|
5360
5994
|
|
|
5995
|
+
// ../../packages/adapters/src/elizaos.ts
|
|
5996
|
+
import { promises as fsp4 } from "fs";
|
|
5997
|
+
import { basename as basename6, dirname as dirname3, join as join8 } from "path";
|
|
5998
|
+
async function isFile2(p) {
|
|
5999
|
+
try {
|
|
6000
|
+
return (await fsp4.lstat(p)).isFile();
|
|
6001
|
+
} catch {
|
|
6002
|
+
return false;
|
|
6003
|
+
}
|
|
6004
|
+
}
|
|
6005
|
+
async function characterFiles(root) {
|
|
6006
|
+
if (/\.json$/i.test(root) && await isFile2(root)) return [{ id: basename6(root).replace(/(\.character)?\.json$/i, ""), path: root }];
|
|
6007
|
+
const out2 = [];
|
|
6008
|
+
for (const dir of [join8(root, "characters"), root]) {
|
|
6009
|
+
for (const e of await listDir(dir)) {
|
|
6010
|
+
if (!(e.file || e.symlink)) continue;
|
|
6011
|
+
const isChar = dir === root ? /\.character\.json$/i.test(e.name) : /\.json$/i.test(e.name);
|
|
6012
|
+
if (!isChar) continue;
|
|
6013
|
+
const id = e.name.replace(/(\.character)?\.json$/i, "");
|
|
6014
|
+
if (!out2.some((o) => o.id === id)) out2.push({ id, path: join8(dir, e.name) });
|
|
6015
|
+
}
|
|
6016
|
+
}
|
|
6017
|
+
return out2;
|
|
6018
|
+
}
|
|
6019
|
+
async function typescriptCharacters(root) {
|
|
6020
|
+
const found = [];
|
|
6021
|
+
for (const rel of ["character.ts", "src/character.ts", "src/characters"]) {
|
|
6022
|
+
if (!await pathExists(join8(root, rel))) continue;
|
|
6023
|
+
if (rel.endsWith(".ts")) found.push(rel);
|
|
6024
|
+
else for (const e of await listDir(join8(root, rel))) if (e.file && e.name.endsWith(".ts")) found.push(`${rel}/${e.name}`);
|
|
6025
|
+
}
|
|
6026
|
+
return found;
|
|
6027
|
+
}
|
|
6028
|
+
function isSecretEntry(key2, value) {
|
|
6029
|
+
if (isSensitiveEnvKey(key2)) return true;
|
|
6030
|
+
return typeof value === "string" && looksLikeSecretValue(value);
|
|
6031
|
+
}
|
|
6032
|
+
function stripSecrets(obj, names, prefix = "") {
|
|
6033
|
+
const out2 = {};
|
|
6034
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
6035
|
+
if (isSecretEntry(k, v)) {
|
|
6036
|
+
names.push(prefix + k);
|
|
6037
|
+
continue;
|
|
6038
|
+
}
|
|
6039
|
+
out2[k] = v;
|
|
6040
|
+
}
|
|
6041
|
+
return out2;
|
|
6042
|
+
}
|
|
6043
|
+
function parseCharacter(text3) {
|
|
6044
|
+
const parsed = JSON.parse(text3);
|
|
6045
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error("A character file must hold a JSON object.");
|
|
6046
|
+
const character = parsed;
|
|
6047
|
+
const secretNames = [];
|
|
6048
|
+
if (character.secrets && typeof character.secrets === "object") secretNames.push(...Object.keys(character.secrets));
|
|
6049
|
+
delete character.secrets;
|
|
6050
|
+
const settings2 = character.settings && typeof character.settings === "object" && !Array.isArray(character.settings) ? character.settings : void 0;
|
|
6051
|
+
if (settings2?.secrets && typeof settings2.secrets === "object") secretNames.push(...Object.keys(settings2.secrets));
|
|
6052
|
+
if (settings2) delete settings2.secrets;
|
|
6053
|
+
return { character, secretNames };
|
|
6054
|
+
}
|
|
6055
|
+
function characterToDocument(character, secretNames, path, notes) {
|
|
6056
|
+
const name = typeof character.name === "string" && character.name.trim() ? character.name.trim() : basename6(path).replace(/(\.character)?\.json$/i, "");
|
|
6057
|
+
const doc = createDocument({ name, platform: P5 });
|
|
6058
|
+
if (typeof character.nomadAgentId === "string" && /^[0-9A-HJKMNP-TV-Z]{26}$/.test(character.nomadAgentId)) doc.id = character.nomadAgentId;
|
|
6059
|
+
const settings2 = character.settings && typeof character.settings === "object" ? character.settings : {};
|
|
6060
|
+
if (typeof settings2.nomadAgentId === "string" && /^[0-9A-HJKMNP-TV-Z]{26}$/.test(settings2.nomadAgentId)) doc.id = settings2.nomadAgentId;
|
|
6061
|
+
const x = {};
|
|
6062
|
+
const src = (field) => ({ platform: P5, path: `${basename6(path)}#${field}` });
|
|
6063
|
+
if (typeof character.username === "string") x.username = character.username;
|
|
6064
|
+
if (typeof character.id === "string") x.characterId = character.id;
|
|
6065
|
+
if (Array.isArray(character.bio)) {
|
|
6066
|
+
doc.identity.persona = character.bio.map(String).join("\n");
|
|
6067
|
+
x.bioShape = "array";
|
|
6068
|
+
} else if (typeof character.bio === "string") {
|
|
6069
|
+
doc.identity.persona = character.bio;
|
|
6070
|
+
x.bioShape = "string";
|
|
6071
|
+
} else notes.push({ level: "info", category: "identity", message: "The character has no bio." });
|
|
6072
|
+
if (typeof character.system === "string" && character.system.trim()) doc.instructions.push({ id: "eliza-system", kind: "system", title: "System", content: character.system, source: src("system") });
|
|
6073
|
+
if (character.style && typeof character.style === "object") {
|
|
6074
|
+
x.style = character.style;
|
|
6075
|
+
const style = character.style;
|
|
6076
|
+
for (const k of STYLE_KEYS) {
|
|
6077
|
+
const items = Array.isArray(style[k]) ? style[k].map(String) : [];
|
|
6078
|
+
if (items.length) doc.instructions.push({ id: `eliza-style-${k}`, kind: "conventions", title: `Style (${k})`, content: items.map((i) => `- ${i}`).join("\n"), source: src(`style.${k}`) });
|
|
6079
|
+
}
|
|
6080
|
+
}
|
|
6081
|
+
if (Array.isArray(character.adjectives)) {
|
|
6082
|
+
x.adjectives = character.adjectives;
|
|
6083
|
+
const tone = character.adjectives.map(String).join(", ");
|
|
6084
|
+
doc.identity.tone = tone.length > 200 ? `${tone.slice(0, 197).replace(/,[^,]*$/, "")}...` : tone;
|
|
6085
|
+
}
|
|
6086
|
+
if (Array.isArray(character.topics)) x.topics = character.topics;
|
|
6087
|
+
for (const k of ["messageExamples", "postExamples"]) {
|
|
6088
|
+
if (character[k] === void 0) continue;
|
|
6089
|
+
if (bytes(x.messageExamples) + bytes(character[k]) > MAX_EXAMPLES_BYTES) {
|
|
6090
|
+
notes.push({ level: "warning", category: "identity", message: `${k} is larger than 256 KB and was left out.` });
|
|
6091
|
+
continue;
|
|
6092
|
+
}
|
|
6093
|
+
x[k] = character[k];
|
|
6094
|
+
}
|
|
6095
|
+
if (character.templates && typeof character.templates === "object") {
|
|
6096
|
+
x.templates = Object.fromEntries(Object.entries(character.templates).filter(([, v]) => typeof v === "string"));
|
|
6097
|
+
}
|
|
6098
|
+
if (Array.isArray(character.knowledge)) {
|
|
6099
|
+
let n = 0;
|
|
6100
|
+
for (const k of character.knowledge) {
|
|
6101
|
+
if (typeof k === "string") doc.memory.push({ id: `eliza-knowledge-${++n}`, kind: "fact", scope: "agent", content: k, tags: [], source: src("knowledge") });
|
|
6102
|
+
else if (k && typeof k === "object") {
|
|
6103
|
+
const ref = k;
|
|
6104
|
+
const p = typeof ref.path === "string" ? ref.path : typeof ref.directory === "string" ? ref.directory : null;
|
|
6105
|
+
if (p) doc.knowledge.push({ path: p, ...typeof ref.directory === "string" ? { directory: true } : {}, ...typeof ref.shared === "boolean" ? { shared: ref.shared } : {} });
|
|
6106
|
+
}
|
|
6107
|
+
}
|
|
6108
|
+
}
|
|
6109
|
+
if (Array.isArray(character.plugins)) {
|
|
6110
|
+
for (const raw of character.plugins) {
|
|
6111
|
+
if (typeof raw !== "string") continue;
|
|
6112
|
+
const known = knownElizaosPlugin(raw);
|
|
6113
|
+
const local = raw.startsWith(".") || raw.startsWith("/");
|
|
6114
|
+
const it = {
|
|
6115
|
+
name: raw,
|
|
6116
|
+
kind: "elizaos-plugin",
|
|
6117
|
+
requiresAuth: !!known?.sensitive.length,
|
|
6118
|
+
config: known ? { requiredSettingNames: known.settingNames } : {},
|
|
6119
|
+
notes: local ? "Local plugin: the path is on the source machine." : known ? `${known.note} ${elizaosPluginHint(raw)}` : void 0,
|
|
6120
|
+
source: src("plugins")
|
|
6121
|
+
};
|
|
6122
|
+
doc.integrations.push(it);
|
|
6123
|
+
}
|
|
6124
|
+
}
|
|
6125
|
+
const mcp = settings2.mcp && typeof settings2.mcp === "object" ? settings2.mcp : void 0;
|
|
6126
|
+
if (mcp?.servers && typeof mcp.servers === "object") doc.tools.push(...toolsFromMcpServers(mcp.servers, P5, `${basename6(path)}#settings.mcp.servers`, { notes }));
|
|
6127
|
+
const restNames = [];
|
|
6128
|
+
const { mcp: _mcp, nomadAgentId: _id, ...otherSettings } = settings2;
|
|
6129
|
+
const keptSettings = stripSecrets(otherSettings, restNames, "settings.");
|
|
6130
|
+
const mcpRest = mcp ? Object.fromEntries(Object.entries(mcp).filter(([k]) => k !== "servers")) : {};
|
|
6131
|
+
if (Object.keys(keptSettings).length || Object.keys(mcpRest).length) x.settings = { ...keptSettings, ...Object.keys(mcpRest).length ? { mcp: mcpRest } : {} };
|
|
6132
|
+
if (typeof character.modelProvider === "string") {
|
|
6133
|
+
const p = PROVIDERS[character.modelProvider.toLowerCase()];
|
|
6134
|
+
if (p) doc.models.provider = p;
|
|
6135
|
+
}
|
|
6136
|
+
const unknownNames = [];
|
|
6137
|
+
const unknown = stripSecrets(Object.fromEntries(Object.entries(character).filter(([k]) => !KNOWN_KEYS.has(k))), unknownNames);
|
|
6138
|
+
if (Object.keys(unknown).length && bytes(unknown) <= MAX_EXAMPLES_BYTES) x.unknown = unknown;
|
|
6139
|
+
const dropped = [...secretNames, ...restNames, ...unknownNames];
|
|
6140
|
+
if (dropped.length) {
|
|
6141
|
+
x.secretNames = dropped;
|
|
6142
|
+
notes.push({ level: "info", category: "integrations", message: `Secrets are never read or moved. Set these again on the destination: ${dropped.join(", ")}.` });
|
|
6143
|
+
}
|
|
6144
|
+
if (dropped.some((d) => d.endsWith(PRIORS_OWNER))) {
|
|
6145
|
+
notes.push({ level: "warning", category: "permissions", message: "This agent only moved money for named ElizaOS entities (PRIORS_OWNER_ENTITY_IDS). Other platforms use their own approval prompts; that rule does not transfer." });
|
|
6146
|
+
}
|
|
6147
|
+
const kept = ["topics", "messageExamples", "postExamples", "templates", "username", "characterId"].filter((k) => x[k] !== void 0);
|
|
6148
|
+
if (kept.length) notes.push({ level: "info", category: "identity", message: `Kept in the package for ElizaOS round trips, not applied on other platforms: ${kept.join(", ")}.` });
|
|
6149
|
+
if (doc.integrations.length) notes.push({ level: "info", category: "integrations", message: "ElizaOS plugins are listed by name; their code and installs do not move." });
|
|
6150
|
+
notes.push({ level: "info", category: "memory", message: "ElizaOS runtime memory and conversations live in its database and are not migrated." });
|
|
6151
|
+
doc.extensions[X] = x;
|
|
6152
|
+
doc.source.location = path;
|
|
6153
|
+
return doc;
|
|
6154
|
+
}
|
|
6155
|
+
async function locate(root, nativeId) {
|
|
6156
|
+
const files = await characterFiles(root);
|
|
6157
|
+
const hit = files.find((f) => f.id === nativeId);
|
|
6158
|
+
if (!hit) throw new NomadError(`No ElizaOS character "${nativeId}" in ${root}.`, "not-found");
|
|
6159
|
+
return hit.path;
|
|
6160
|
+
}
|
|
6161
|
+
function isObject(v) {
|
|
6162
|
+
return !!v && typeof v === "object" && !Array.isArray(v);
|
|
6163
|
+
}
|
|
6164
|
+
function documentToCharacter(doc, mcpServers) {
|
|
6165
|
+
const x = isObject(doc.extensions[X]) ? doc.extensions[X] : {};
|
|
6166
|
+
const restoredStyle = isObject(x.style) ? x.style : void 0;
|
|
6167
|
+
const sys = [];
|
|
6168
|
+
const styleFromDoc = {};
|
|
6169
|
+
for (const i of doc.instructions) {
|
|
6170
|
+
if (i.kind === "system") sys.unshift(i.content);
|
|
6171
|
+
else if (i.kind === "conventions" && /^Style \((all|chat|post)\)$/.test(i.title ?? "")) {
|
|
6172
|
+
const k = /\((\w+)\)/.exec(i.title)[1];
|
|
6173
|
+
styleFromDoc[k] = i.content.split("\n").map((l) => l.replace(/^[-*]\s+/, "")).filter(Boolean);
|
|
6174
|
+
} else sys.push(`## ${i.title ?? i.kind}
|
|
6175
|
+
|
|
6176
|
+
${i.content}`);
|
|
6177
|
+
}
|
|
6178
|
+
const persona = doc.identity.persona ?? "";
|
|
6179
|
+
const bio = x.bioShape === "array" ? persona.split("\n").filter((l) => l.length) : persona;
|
|
6180
|
+
const adjectives = Array.isArray(x.adjectives) ? x.adjectives : doc.identity.tone ? doc.identity.tone.split(/,\s*/).filter(Boolean) : void 0;
|
|
6181
|
+
const plugins = doc.integrations.filter((i) => i.kind === "elizaos-plugin").map((i) => i.name);
|
|
6182
|
+
const shared = (k) => typeof k.shared === "boolean" ? { shared: k.shared } : {};
|
|
6183
|
+
const knowledge = [...doc.memory.map((m) => m.content.replace(/^[-*]\s+/, "")), ...doc.knowledge.map((k) => k.directory === true ? { directory: k.path, ...shared(k) } : { path: k.path, ...shared(k) })];
|
|
6184
|
+
const settings2 = { ...isObject(x.settings) ? x.settings : {} };
|
|
6185
|
+
if (Object.keys(mcpServers).length) settings2.mcp = { ...isObject(settings2.mcp) ? settings2.mcp : {}, servers: mcpServers };
|
|
6186
|
+
settings2.nomadAgentId = doc.id;
|
|
6187
|
+
const out2 = {
|
|
6188
|
+
name: doc.identity.name ?? doc.name,
|
|
6189
|
+
...typeof x.username === "string" ? { username: x.username } : {},
|
|
6190
|
+
bio,
|
|
6191
|
+
...sys.length ? { system: sys.join("\n\n") } : {},
|
|
6192
|
+
...restoredStyle ? { style: restoredStyle } : Object.keys(styleFromDoc).length ? { style: styleFromDoc } : {},
|
|
6193
|
+
...adjectives?.length ? { adjectives } : {},
|
|
6194
|
+
...Array.isArray(x.topics) ? { topics: x.topics } : {},
|
|
6195
|
+
...x.messageExamples !== void 0 ? { messageExamples: x.messageExamples } : {},
|
|
6196
|
+
...x.postExamples !== void 0 ? { postExamples: x.postExamples } : {},
|
|
6197
|
+
...isObject(x.templates) ? { templates: x.templates } : {},
|
|
6198
|
+
...knowledge.length ? { knowledge } : {},
|
|
6199
|
+
...isObject(x.unknown) ? x.unknown : {},
|
|
6200
|
+
plugins,
|
|
6201
|
+
settings: settings2
|
|
6202
|
+
};
|
|
6203
|
+
return out2;
|
|
6204
|
+
}
|
|
6205
|
+
function hasSecretsKey(v) {
|
|
6206
|
+
if (Array.isArray(v)) return v.some(hasSecretsKey);
|
|
6207
|
+
if (!isObject(v)) return false;
|
|
6208
|
+
return Object.entries(v).some(([k, c2]) => k === "secrets" || hasSecretsKey(c2));
|
|
6209
|
+
}
|
|
6210
|
+
var P5, X, MAX_BYTES, MAX_EXAMPLES_BYTES, PRIORS_OWNER, KNOWN_KEYS, STYLE_KEYS, PROVIDERS, bytes, elizaosAdapter;
|
|
6211
|
+
var init_elizaos = __esm({
|
|
6212
|
+
"../../packages/adapters/src/elizaos.ts"() {
|
|
6213
|
+
"use strict";
|
|
6214
|
+
init_src2();
|
|
6215
|
+
init_node();
|
|
6216
|
+
init_src3();
|
|
6217
|
+
init_catalog();
|
|
6218
|
+
init_elizaos_known_plugins();
|
|
6219
|
+
init_known_servers();
|
|
6220
|
+
init_util();
|
|
6221
|
+
P5 = "elizaos";
|
|
6222
|
+
X = "x-elizaos";
|
|
6223
|
+
MAX_BYTES = 1024 * 1024;
|
|
6224
|
+
MAX_EXAMPLES_BYTES = 256 * 1024;
|
|
6225
|
+
PRIORS_OWNER = "PRIORS_OWNER_ENTITY_IDS";
|
|
6226
|
+
KNOWN_KEYS = /* @__PURE__ */ new Set(["name", "username", "id", "bio", "system", "style", "adjectives", "topics", "messageExamples", "postExamples", "templates", "knowledge", "plugins", "settings", "secrets", "modelProvider", "nomadAgentId"]);
|
|
6227
|
+
STYLE_KEYS = ["all", "chat", "post"];
|
|
6228
|
+
PROVIDERS = { anthropic: "anthropic", openai: "openai", openrouter: "openrouter", google: "google", groq: "groq", ollama: "ollama" };
|
|
6229
|
+
bytes = (v) => Buffer.byteLength(JSON.stringify(v ?? null));
|
|
6230
|
+
elizaosAdapter = {
|
|
6231
|
+
info: ELIZAOS_INFO,
|
|
6232
|
+
async detect(root) {
|
|
6233
|
+
const evidence = [];
|
|
6234
|
+
const files = await characterFiles(root);
|
|
6235
|
+
if (files.length) evidence.push(`${files.length} character file(s)`);
|
|
6236
|
+
const pkg = await readTextIfExists(join8(root, "package.json"));
|
|
6237
|
+
if (pkg && /"@elizaos\/(core|cli)"/.test(pkg)) evidence.push("package.json depends on @elizaos");
|
|
6238
|
+
const ts = await typescriptCharacters(root);
|
|
6239
|
+
if (ts.length) evidence.push(`TypeScript character: ${ts.join(", ")}`);
|
|
6240
|
+
const detected = files.length > 0 || evidence.some((e) => e.startsWith("package.json"));
|
|
6241
|
+
return { detected, confidence: files.length && evidence.length > 1 ? 0.9 : detected ? 0.6 : 0, evidence };
|
|
6242
|
+
},
|
|
6243
|
+
async discover(root) {
|
|
6244
|
+
const refs = [];
|
|
6245
|
+
for (const f of await characterFiles(root)) {
|
|
6246
|
+
let name = f.id;
|
|
6247
|
+
try {
|
|
6248
|
+
const st = await fsp4.lstat(f.path);
|
|
6249
|
+
if (!st.isSymbolicLink() && st.size <= MAX_BYTES) {
|
|
6250
|
+
const j = JSON.parse(await fsp4.readFile(f.path, "utf8"));
|
|
6251
|
+
if (typeof j?.name === "string") name = j.name;
|
|
6252
|
+
}
|
|
6253
|
+
} catch {
|
|
6254
|
+
}
|
|
6255
|
+
refs.push({ nativeId: f.id, name, location: f.path, kind: "main" });
|
|
6256
|
+
}
|
|
6257
|
+
return refs;
|
|
6258
|
+
},
|
|
6259
|
+
async read(root, nativeId) {
|
|
6260
|
+
const notes = [];
|
|
6261
|
+
const path = await locate(root, nativeId);
|
|
6262
|
+
const st = await fsp4.lstat(path);
|
|
6263
|
+
if (st.isSymbolicLink()) throw new NomadError(`${basename6(path)} is a symlink. Nomad does not follow it.`, "unsafe-path");
|
|
6264
|
+
if (st.size > MAX_BYTES) throw new NomadError(`${basename6(path)} is larger than 1 MB.`, "too-large");
|
|
6265
|
+
const text3 = await readTextIfExists(path);
|
|
6266
|
+
if (text3 === null) throw new NomadError(`${basename6(path)} could not be read.`, "not-found");
|
|
6267
|
+
let parsed;
|
|
6268
|
+
try {
|
|
6269
|
+
parsed = parseCharacter(text3);
|
|
6270
|
+
} catch (e) {
|
|
6271
|
+
const at2 = /position (\d+)/.exec(e.message)?.[1];
|
|
6272
|
+
throw new NomadError(`${basename6(path)} is not valid JSON${at2 ? ` (near character ${at2})` : ""}.`, "invalid-character");
|
|
6273
|
+
}
|
|
6274
|
+
const projectRoot = /\.json$/i.test(root) ? dirname3(root) : root;
|
|
6275
|
+
for (const ts of await typescriptCharacters(projectRoot)) notes.push({ level: "info", category: "identity", message: `TypeScript character found (${ts}), not imported. Nomad never runs your code.` });
|
|
6276
|
+
const doc = characterToDocument(parsed.character, parsed.secretNames, path, notes);
|
|
6277
|
+
doc.source.nativeId = nativeId;
|
|
6278
|
+
return { doc, sourceFiles: [path], notes };
|
|
6279
|
+
},
|
|
6280
|
+
async plan(doc, ctx) {
|
|
6281
|
+
const notes = [];
|
|
6282
|
+
const manualSteps = [];
|
|
6283
|
+
const conversions = [];
|
|
6284
|
+
const unsupported = [];
|
|
6285
|
+
const dir = "characters";
|
|
6286
|
+
let slug = ctx.targetNativeId ?? safeName2((ctx.mode === "copy" && ctx.targetName ? ctx.targetName : doc.name).toLowerCase());
|
|
6287
|
+
if (ctx.mode === "copy") {
|
|
6288
|
+
let i = 2;
|
|
6289
|
+
const base = slug;
|
|
6290
|
+
while (await pathExists(join8(ctx.root, dir, `${slug}.json`))) slug = `${base}-${i++}`;
|
|
6291
|
+
}
|
|
6292
|
+
const target = `${dir}/${slug}.json`;
|
|
6293
|
+
const existing = await readTextIfExists(join8(ctx.root, target));
|
|
6294
|
+
const tools = wants(ctx, "tools") ? doc.tools.filter((t) => t.kind === "mcp" && t.mcp) : [];
|
|
6295
|
+
const r = mcpServersFromTools(tools, { platformName: "ElizaOS", envRefStyle: "none" });
|
|
6296
|
+
const servers = {};
|
|
6297
|
+
for (const [name, s] of Object.entries(r.servers)) {
|
|
6298
|
+
servers[name] = s.url ? { type: "streamable-http", url: s.url } : { type: "stdio", command: s.command, ...s.args ? { args: s.args } : {}, ...s.env ? { env: s.env } : {} };
|
|
6299
|
+
}
|
|
6300
|
+
manualSteps.push(...r.manualSteps);
|
|
6301
|
+
unsupported.push(...r.unsupported);
|
|
6302
|
+
notes.push(...r.notes);
|
|
6303
|
+
for (const t of doc.tools.filter((t2) => t2.kind !== "mcp")) unsupported.push({ category: "tools", item: t.name, reason: "Only MCP servers can be written to an ElizaOS character." });
|
|
6304
|
+
if (Object.keys(servers).length) {
|
|
6305
|
+
manualSteps.push(`Add the ElizaOS MCP plugin "@elizaos/plugin-mcp" to the character's plugins and install it. Nomad does not add plugins.`);
|
|
6306
|
+
conversions.push({ category: "tools", item: `${Object.keys(servers).length} MCP server(s)`, from: "MCP servers", to: "settings.mcp.servers" });
|
|
6307
|
+
}
|
|
6308
|
+
const priors = tools.some((t) => knownServerId(t) === "priors") || doc.integrations.some((i) => i.name === "@priors/plugin-elizaos");
|
|
6309
|
+
if (priors) {
|
|
6310
|
+
manualSteps.push("Priors' documentation warns that ElizaOS keeps a character's settings in its database in plain text and returns them from its agents API. Put only a key file path in PRIORS_KEY_FILE, never the key itself.");
|
|
6311
|
+
}
|
|
6312
|
+
manualSteps.push("Set secrets in your own ElizaOS environment. Nomad never writes them into the character.");
|
|
6313
|
+
const docForWrite = {
|
|
6314
|
+
...doc,
|
|
6315
|
+
instructions: wants(ctx, "instructions") ? doc.instructions : [],
|
|
6316
|
+
memory: wants(ctx, "memory") ? doc.memory : [],
|
|
6317
|
+
knowledge: wants(ctx, "knowledge") ? doc.knowledge : [],
|
|
6318
|
+
integrations: wants(ctx, "integrations") ? doc.integrations : []
|
|
6319
|
+
};
|
|
6320
|
+
const character = documentToCharacter(docForWrite, servers);
|
|
6321
|
+
const folded = doc.instructions.filter((i) => i.kind !== "system" && !/^Style \((all|chat|post)\)$/.test(i.title ?? ""));
|
|
6322
|
+
if (folded.length && wants(ctx, "instructions")) conversions.push({ category: "instructions", item: `${folded.length} section(s)`, from: "instructions", to: "system (with headings)" });
|
|
6323
|
+
if (doc.memory.length && wants(ctx, "memory")) conversions.push({ category: "memory", item: `${doc.memory.length} entries`, from: "memory", to: "knowledge strings" });
|
|
6324
|
+
for (const k of doc.knowledge) manualSteps.push(`Copy the knowledge file ${k.path} into the ElizaOS project if it is not there.`);
|
|
6325
|
+
for (const i of doc.integrations.filter((x2) => x2.kind !== "elizaos-plugin")) manualSteps.push(`${i.name} was set up on the source. Find or install an ElizaOS plugin for it; Nomad never installs plugins.`);
|
|
6326
|
+
for (const p of doc.integrations.filter((x2) => x2.kind === "elizaos-plugin" && (x2.name.startsWith(".") || x2.name.startsWith("/")))) {
|
|
6327
|
+
notes.push({ level: "warning", category: "integrations", message: `Plugin ${p.name} is a local path on the source machine.` });
|
|
6328
|
+
}
|
|
6329
|
+
const x = isObject(doc.extensions[X]) ? doc.extensions[X] : {};
|
|
6330
|
+
if (Array.isArray(x.secretNames) && x.secretNames.length) manualSteps.push(`Set again in ElizaOS: ${x.secretNames.join(", ")}. ${x.secretNames.some((n) => n.endsWith(PRIORS_OWNER)) ? "Set PRIORS_OWNER_ENTITY_IDS to your own entity ids; never * unless you mean anyone." : ""}`.trim());
|
|
6331
|
+
if (wants(ctx, "skills")) for (const s of doc.skills) unsupported.push({ category: "skills", item: s.name, reason: "ElizaOS characters have no skills.", alternative: "Skill instructions are in the package and the report." });
|
|
6332
|
+
if (wants(ctx, "workflows")) for (const w of doc.workflows) unsupported.push({ category: "workflows", item: w.name, reason: "ElizaOS characters have no scheduler." });
|
|
6333
|
+
if (wants(ctx, "permissions") && doc.permissions.rules.length) unsupported.push({ category: "permissions", item: `${doc.permissions.rules.length} rule(s)`, reason: "ElizaOS characters have no permission rules." });
|
|
6334
|
+
if (wants(ctx, "models") && doc.models.preferred) manualSteps.push(`Choose ${doc.models.preferred} (or the closest model) through a model plugin in ElizaOS.`);
|
|
6335
|
+
const strategy = existing !== null && ctx.mode === "merge" ? "merge-json" : "replace";
|
|
6336
|
+
const files = [{ path: target, content: JSON.stringify(character, null, 2) + "\n", strategy, agentOwned: true, component: "identity", description: `ElizaOS character ${target}` }];
|
|
6337
|
+
return { nativeId: slug, files, notes, manualSteps, conversions, unsupported };
|
|
6338
|
+
},
|
|
6339
|
+
async verify(doc, root, nativeId, ctx) {
|
|
6340
|
+
const checks = [];
|
|
6341
|
+
const path = join8(root, "characters", `${nativeId}.json`);
|
|
6342
|
+
const text3 = await readTextIfExists(path);
|
|
6343
|
+
if (text3 === null) return [{ name: "Character file written", ok: false, detail: "File is missing" }];
|
|
6344
|
+
let raw;
|
|
6345
|
+
try {
|
|
6346
|
+
raw = JSON.parse(text3);
|
|
6347
|
+
} catch {
|
|
6348
|
+
return [{ name: "Character file parses", ok: false }];
|
|
6349
|
+
}
|
|
6350
|
+
checks.push({ name: "No secrets in the character", ok: !hasSecretsKey(raw) });
|
|
6351
|
+
const notes = [];
|
|
6352
|
+
const got = characterToDocument(parseCharacter(text3).character, [], path, notes);
|
|
6353
|
+
checks.push({ name: "Name kept", ok: got.name === (doc.identity.name ?? doc.name) });
|
|
6354
|
+
if (wants(ctx, "identity") && doc.identity.persona) checks.push({ name: "Bio kept", ok: (got.identity.persona ?? "").replace(/\n/g, "") === doc.identity.persona.replace(/\n/g, "") });
|
|
6355
|
+
const sys = doc.instructions.find((i) => i.kind === "system");
|
|
6356
|
+
if (sys && wants(ctx, "instructions")) checks.push({ name: "System prompt kept", ok: (got.instructions.find((i) => i.kind === "system")?.content ?? "").includes(sys.content) });
|
|
6357
|
+
const plugins = doc.integrations.filter((i) => i.kind === "elizaos-plugin").map((i) => i.name);
|
|
6358
|
+
if (wants(ctx, "integrations")) checks.push({ name: "Plugins kept in order", ok: JSON.stringify(got.integrations.map((i) => i.name)) === JSON.stringify(plugins) });
|
|
6359
|
+
if (wants(ctx, "tools")) {
|
|
6360
|
+
const expected = doc.tools.filter((t) => t.kind === "mcp" && t.enabled !== false).map((t) => t.name);
|
|
6361
|
+
const names = new Set(got.tools.map((t) => t.name));
|
|
6362
|
+
const missing = expected.filter((n) => !names.has(n));
|
|
6363
|
+
checks.push({ name: "MCP servers written", ok: !missing.length, detail: missing.length ? `Missing: ${missing.join(", ")}` : void 0 });
|
|
6364
|
+
}
|
|
6365
|
+
return checks;
|
|
6366
|
+
}
|
|
6367
|
+
};
|
|
6368
|
+
}
|
|
6369
|
+
});
|
|
6370
|
+
|
|
5361
6371
|
// ../../packages/adapters/src/file-based.ts
|
|
5362
|
-
import { basename as
|
|
6372
|
+
import { basename as basename7, join as join9 } from "path";
|
|
5363
6373
|
import { parse as parseYaml3, stringify as stringifyYaml3 } from "yaml";
|
|
5364
6374
|
async function readStructured(path, format, notes) {
|
|
5365
6375
|
const text3 = await readTextIfExists(path);
|
|
@@ -5400,26 +6410,27 @@ function toolsFromStyle(raw, style, platform, path) {
|
|
|
5400
6410
|
}
|
|
5401
6411
|
}
|
|
5402
6412
|
function patchForStyle(tools, spec, platformName) {
|
|
5403
|
-
const r = mcpServersFromTools(tools, { platformName,
|
|
6413
|
+
const r = mcpServersFromTools(tools, { platformName, envRefStyle: spec.envRefStyle ?? (spec.envExpansion ? "dollar" : "none"), urlKey: spec.urlKey });
|
|
6414
|
+
const extra = { unsupported: r.unsupported, notes: r.notes };
|
|
5404
6415
|
switch (spec.style) {
|
|
5405
6416
|
case "claude":
|
|
5406
|
-
return { patch: { mcpServers: r.servers }, steps: r.manualSteps };
|
|
6417
|
+
return { patch: { mcpServers: r.servers }, steps: r.manualSteps, ...extra };
|
|
5407
6418
|
case "opencode": {
|
|
5408
6419
|
const mcp = {};
|
|
5409
6420
|
for (const [name, s] of Object.entries(r.servers)) {
|
|
5410
6421
|
mcp[name] = s.command ? { type: "local", command: [s.command, ...s.args ?? []], ...s.env ? { environment: s.env } : {}, enabled: true } : { type: "remote", url: s.url, ...s.headers ? { headers: s.headers } : {}, enabled: true };
|
|
5411
6422
|
}
|
|
5412
|
-
return { patch: { mcp }, steps: r.manualSteps };
|
|
6423
|
+
return { patch: { mcp }, steps: r.manualSteps, ...extra };
|
|
5413
6424
|
}
|
|
5414
6425
|
case "goose": {
|
|
5415
6426
|
const extensions = {};
|
|
5416
6427
|
for (const [name, s] of Object.entries(r.servers)) {
|
|
5417
6428
|
extensions[name] = s.command ? { name, type: "stdio", cmd: s.command, args: s.args ?? [], ...s.env ? { envs: s.env } : {}, enabled: true, timeout: 300 } : { name, type: "streamable_http", uri: s.url, enabled: true, timeout: 300 };
|
|
5418
6429
|
}
|
|
5419
|
-
return { patch: { extensions }, steps: r.manualSteps };
|
|
6430
|
+
return { patch: { extensions }, steps: r.manualSteps, ...extra };
|
|
5420
6431
|
}
|
|
5421
6432
|
case "continue":
|
|
5422
|
-
return { patch: { mcpServers: Object.entries(r.servers).map(([name, s]) => ({ name, ...s })) }, steps: r.manualSteps };
|
|
6433
|
+
return { patch: { mcpServers: Object.entries(r.servers).map(([name, s]) => ({ name, ...s })) }, steps: r.manualSteps, ...extra };
|
|
5423
6434
|
}
|
|
5424
6435
|
}
|
|
5425
6436
|
function parseInstructionText(text3, kind, id, path, platform, doc, memorySection, prefer) {
|
|
@@ -5453,31 +6464,31 @@ function parseInstructionText(text3, kind, id, path, platform, doc, memorySectio
|
|
|
5453
6464
|
else if (outside) doc.instructions.unshift({ id, kind: "custom", title: path, content: outside, source: { platform, path } });
|
|
5454
6465
|
}
|
|
5455
6466
|
function defineFileAdapter(spec) {
|
|
5456
|
-
const
|
|
6467
|
+
const P6 = spec.info.id;
|
|
5457
6468
|
const name = spec.info.displayName;
|
|
5458
6469
|
async function targetPath(doc, root) {
|
|
5459
6470
|
const base = await spec.write.path(root);
|
|
5460
6471
|
if (spec.write.kind === "block") return base;
|
|
5461
|
-
if (base && await isFile(
|
|
6472
|
+
if (base && await isFile(join9(root, base))) return base;
|
|
5462
6473
|
return `${base}/nomad-${safeName2(slugify(doc.name))}${spec.write.ext ?? ".md"}`;
|
|
5463
6474
|
}
|
|
5464
6475
|
const adapter = {
|
|
5465
6476
|
info: spec.info,
|
|
5466
6477
|
async detect(root) {
|
|
5467
6478
|
const evidence = [];
|
|
5468
|
-
for (const f of spec.detect) if (await pathExists(
|
|
6479
|
+
for (const f of spec.detect) if (await pathExists(join9(root, f))) evidence.push(f);
|
|
5469
6480
|
return { detected: evidence.length > 0, confidence: evidence.length ? 0.6 : 0, evidence };
|
|
5470
6481
|
},
|
|
5471
6482
|
async discover(root) {
|
|
5472
6483
|
const d = await adapter.detect(root);
|
|
5473
6484
|
const refs = [];
|
|
5474
|
-
if (d.detected) refs.push({ nativeId: "main", name: `${name}: ${
|
|
6485
|
+
if (d.detected) refs.push({ nativeId: "main", name: `${name}: ${basename7(root)}`, description: d.evidence.join(", "), location: root, kind: "main" });
|
|
5475
6486
|
if (spec.agentsDir) {
|
|
5476
6487
|
const dir = await spec.agentsDir(root);
|
|
5477
|
-
for (const e of await listDir(
|
|
6488
|
+
for (const e of await listDir(join9(root, dir))) {
|
|
5478
6489
|
if (!e.file || !e.name.endsWith(".md")) continue;
|
|
5479
|
-
const fm = parseFrontmatter(await readTextIfExists(
|
|
5480
|
-
refs.push({ nativeId: `agent:${e.name.replace(/\.md$/, "")}`, name: e.name.replace(/\.md$/, ""), description: typeof fm.data.description === "string" ? fm.data.description : void 0, location:
|
|
6490
|
+
const fm = parseFrontmatter(await readTextIfExists(join9(root, dir, e.name)) ?? "");
|
|
6491
|
+
refs.push({ nativeId: `agent:${e.name.replace(/\.md$/, "")}`, name: e.name.replace(/\.md$/, ""), description: typeof fm.data.description === "string" ? fm.data.description : void 0, location: join9(root, dir, e.name), kind: "subagent" });
|
|
5481
6492
|
}
|
|
5482
6493
|
}
|
|
5483
6494
|
return refs;
|
|
@@ -5485,50 +6496,50 @@ function defineFileAdapter(spec) {
|
|
|
5485
6496
|
async read(root, nativeId, options = {}) {
|
|
5486
6497
|
const notes = [];
|
|
5487
6498
|
const sourceFiles = [];
|
|
5488
|
-
const doc = createDocument({ name: `${name}: ${
|
|
6499
|
+
const doc = createDocument({ name: `${name}: ${basename7(root)}`, platform: P6 });
|
|
5489
6500
|
doc.source.location = root;
|
|
5490
6501
|
doc.source.nativeId = nativeId;
|
|
5491
6502
|
if (nativeId.startsWith("agent:") && spec.agentsDir) {
|
|
5492
6503
|
const rel = `${await spec.agentsDir(root)}/${nativeId.slice(6)}.md`;
|
|
5493
|
-
const text3 = await readTextIfExists(
|
|
5494
|
-
sourceFiles.push(
|
|
6504
|
+
const text3 = await readTextIfExists(join9(root, rel)) ?? "";
|
|
6505
|
+
sourceFiles.push(join9(root, rel));
|
|
5495
6506
|
const fm = parseFrontmatter(text3);
|
|
5496
6507
|
doc.name = nativeId.slice(6);
|
|
5497
6508
|
doc.identity.name = doc.name;
|
|
5498
6509
|
if (typeof fm.data.description === "string") doc.description = fm.data.description;
|
|
5499
6510
|
if (typeof fm.data.model === "string") doc.models.preferred = fm.data.model;
|
|
5500
|
-
doc.extensions[`x-${
|
|
5501
|
-
parseInstructionText(fm.body, "system", "prompt", rel,
|
|
6511
|
+
doc.extensions[`x-${P6}`] = { frontmatter: fm.data };
|
|
6512
|
+
parseInstructionText(fm.body, "system", "prompt", rel, P6, doc);
|
|
5502
6513
|
return { doc, sourceFiles, notes };
|
|
5503
6514
|
}
|
|
5504
6515
|
for (const f of await spec.instructionFiles(root)) {
|
|
5505
|
-
const text3 = await readTextIfExists(
|
|
6516
|
+
const text3 = await readTextIfExists(join9(root, f.path));
|
|
5506
6517
|
if (text3 === null) continue;
|
|
5507
|
-
sourceFiles.push(
|
|
5508
|
-
parseInstructionText(text3, f.kind, f.path.replace(/[^A-Za-z0-9]+/g, "-").replace(/^-|-$/g, "").toLowerCase(), f.path,
|
|
6518
|
+
sourceFiles.push(join9(root, f.path));
|
|
6519
|
+
parseInstructionText(text3, f.kind, f.path.replace(/[^A-Za-z0-9]+/g, "-").replace(/^-|-$/g, "").toLowerCase(), f.path, P6, doc, spec.memorySection, options.agentId);
|
|
5509
6520
|
}
|
|
5510
6521
|
for (const dir of await spec.rulesDirs?.(root) ?? []) {
|
|
5511
|
-
if (!await isDirectory(
|
|
5512
|
-
for (const e of await listDir(
|
|
6522
|
+
if (!await isDirectory(join9(root, dir.path))) continue;
|
|
6523
|
+
for (const e of await listDir(join9(root, dir.path))) {
|
|
5513
6524
|
if (!e.file || !dir.exts.some((x) => e.name.endsWith(x))) continue;
|
|
5514
6525
|
const rel = `${dir.path}/${e.name}`;
|
|
5515
|
-
const text3 = await readTextIfExists(
|
|
5516
|
-
sourceFiles.push(
|
|
6526
|
+
const text3 = await readTextIfExists(join9(root, rel));
|
|
6527
|
+
sourceFiles.push(join9(root, rel));
|
|
5517
6528
|
const fm = parseFrontmatter(text3);
|
|
5518
|
-
parseInstructionText(text3, "custom", e.name.replace(/\.[^.]+$/, ""), rel,
|
|
6529
|
+
parseInstructionText(text3, "custom", e.name.replace(/\.[^.]+$/, ""), rel, P6, doc, void 0, options.agentId);
|
|
5519
6530
|
const last = doc.instructions[doc.instructions.length - 1];
|
|
5520
|
-
if (last && Object.keys(fm.data).length) last[`x-${
|
|
6531
|
+
if (last && Object.keys(fm.data).length) last[`x-${P6}`] = { frontmatter: fm.data };
|
|
5521
6532
|
}
|
|
5522
6533
|
}
|
|
5523
6534
|
if (spec.mcp) {
|
|
5524
6535
|
const p = await spec.mcp.path(root);
|
|
5525
|
-
const raw = await readStructured(
|
|
6536
|
+
const raw = await readStructured(join9(root, p), spec.mcp.format, notes);
|
|
5526
6537
|
if (raw) {
|
|
5527
|
-
sourceFiles.push(
|
|
5528
|
-
doc.tools.push(...toolsFromStyle(raw, spec.mcp.style,
|
|
6538
|
+
sourceFiles.push(join9(root, p));
|
|
6539
|
+
doc.tools.push(...toolsFromStyle(raw, spec.mcp.style, P6, p));
|
|
5529
6540
|
}
|
|
5530
6541
|
}
|
|
5531
|
-
if (spec.skillsDir) doc.skills.push(...await readSkillsTree(
|
|
6542
|
+
if (spec.skillsDir) doc.skills.push(...await readSkillsTree(join9(root, await spec.skillsDir(root)), P6, notes, 2));
|
|
5532
6543
|
return { doc, sourceFiles, notes };
|
|
5533
6544
|
},
|
|
5534
6545
|
async plan(doc, ctx) {
|
|
@@ -5542,7 +6553,7 @@ function defineFileAdapter(spec) {
|
|
|
5542
6553
|
if ((ctx.mode === "copy" || ctx.targetNativeId?.startsWith("agent:")) && spec.agentsDir) {
|
|
5543
6554
|
const stem = ctx.mode === "copy" ? safeName2(slugify(ctx.targetName ?? doc.name)) : ctx.targetNativeId.slice(6);
|
|
5544
6555
|
nativeId = `agent:${stem}`;
|
|
5545
|
-
const ext = doc.extensions[`x-${
|
|
6556
|
+
const ext = doc.extensions[`x-${P6}`]?.frontmatter ?? {};
|
|
5546
6557
|
files.push({ path: `${await spec.agentsDir(ctx.root)}/${stem}.md`, content: stringifyFrontmatter({ description: doc.description ?? doc.identity.description ?? doc.name, mode: "subagent", ...ext }, `<!-- nomad:agent=${doc.id} -->
|
|
5547
6558
|
` + body2), strategy: "replace", component: "instructions", description: `Agent definition ${stem}`, agentOwned: true });
|
|
5548
6559
|
} else if (ctx.mode === "copy" && spec.write.kind === "block") {
|
|
@@ -5550,7 +6561,7 @@ function defineFileAdapter(spec) {
|
|
|
5550
6561
|
return { nativeId, files: [], notes, manualSteps, conversions, unsupported };
|
|
5551
6562
|
} else {
|
|
5552
6563
|
const path = await targetPath(doc, ctx.root);
|
|
5553
|
-
if (spec.write.kind === "rule-file" && !await isFile(
|
|
6564
|
+
if (spec.write.kind === "rule-file" && !await isFile(join9(ctx.root, await spec.write.path(ctx.root)))) {
|
|
5554
6565
|
const fm = spec.write.frontmatter?.(doc) ?? {};
|
|
5555
6566
|
files.push({ path, content: stringifyFrontmatter(fm, `<!-- nomad:agent=${doc.id} -->
|
|
5556
6567
|
` + body2), strategy: "replace", component: "instructions", description: `Rules file for ${doc.name}`, agentOwned: true });
|
|
@@ -5576,7 +6587,9 @@ function defineFileAdapter(spec) {
|
|
|
5576
6587
|
const mcpTools = doc.tools.filter((t) => t.kind === "mcp" && t.mcp);
|
|
5577
6588
|
if (spec.mcp?.writable && mcpTools.length && !nativeId.startsWith("agent:")) {
|
|
5578
6589
|
const p = await spec.mcp.path(ctx.root);
|
|
5579
|
-
const { patch, steps } = patchForStyle(mcpTools, spec.mcp, name);
|
|
6590
|
+
const { patch, steps, unsupported: skipped2, notes: mcpNotes } = patchForStyle(mcpTools, spec.mcp, name);
|
|
6591
|
+
unsupported.push(...skipped2);
|
|
6592
|
+
notes.push(...mcpNotes);
|
|
5580
6593
|
files.push({ path: p, content: spec.mcp.format === "json" ? JSON.stringify(patch, null, 2) + "\n" : stringifyYaml3(patch), strategy: spec.mcp.format === "json" ? "merge-json" : "merge-yaml", arrayKeys: spec.mcp.style === "continue" ? { mcpServers: "name" } : void 0, component: "tools", description: `${mcpTools.length} MCP server(s) in ${p}` });
|
|
5581
6594
|
manualSteps.push(...steps);
|
|
5582
6595
|
} else {
|
|
@@ -5593,9 +6606,9 @@ function defineFileAdapter(spec) {
|
|
|
5593
6606
|
for (const w of doc.workflows) unsupported.push({ category: "workflows", item: w.name, reason: `${name} has no scheduler.` });
|
|
5594
6607
|
manualSteps.push(...workflowManualSteps(doc, name));
|
|
5595
6608
|
}
|
|
5596
|
-
if (wants(ctx, "integrations")) for (const i of doc.integrations) manualSteps.push(`Reconnect ${i.name} in ${name}.`);
|
|
6609
|
+
if (wants(ctx, "integrations")) for (const i of doc.integrations) manualSteps.push(integrationStep(i, name, `Reconnect ${i.name} in ${name}.`));
|
|
5597
6610
|
if (wants(ctx, "knowledge") && (doc.knowledge.length || doc.files.length)) manualSteps.push(`Copy ${doc.knowledge.length + doc.files.length} knowledge file(s) into the project.`);
|
|
5598
|
-
notes.push({ level: "info", message:
|
|
6611
|
+
notes.push({ level: "info", message: `Open the project in ${name} after migrating to confirm the rules load.` });
|
|
5599
6612
|
return { nativeId, files, notes, manualSteps, conversions, unsupported };
|
|
5600
6613
|
},
|
|
5601
6614
|
async verify(doc, root, nativeId, ctx) {
|
|
@@ -5613,7 +6626,7 @@ function defineFileAdapter(spec) {
|
|
|
5613
6626
|
}
|
|
5614
6627
|
if (spec.mcp?.writable && wants(ctx, "tools") && doc.tools.some((t) => t.kind === "mcp") && !nativeId.startsWith("agent:")) {
|
|
5615
6628
|
const names = new Set(got.tools.map((t) => t.name));
|
|
5616
|
-
const missing = doc.tools.filter((t) => t.kind === "mcp" && !names.has(t.name));
|
|
6629
|
+
const missing = doc.tools.filter((t) => t.kind === "mcp" && t.enabled !== false && !pluginOf(t, this.info.id) && !names.has(t.name));
|
|
5617
6630
|
checks.push({ name: "MCP servers configured", ok: !missing.length, detail: missing.length ? `Missing: ${missing.map((t) => t.name).join(", ")}` : void 0 });
|
|
5618
6631
|
}
|
|
5619
6632
|
return checks;
|
|
@@ -5630,7 +6643,7 @@ var init_file_based = __esm({
|
|
|
5630
6643
|
init_catalog();
|
|
5631
6644
|
init_util();
|
|
5632
6645
|
at = (p) => async () => p;
|
|
5633
|
-
isHomeDir = (root, name) =>
|
|
6646
|
+
isHomeDir = (root, name) => basename7(root) === name;
|
|
5634
6647
|
cursorAdapter = defineFileAdapter({
|
|
5635
6648
|
info: CURSOR_INFO,
|
|
5636
6649
|
detect: [".cursor", ".cursorrules"],
|
|
@@ -5640,7 +6653,7 @@ var init_file_based = __esm({
|
|
|
5640
6653
|
],
|
|
5641
6654
|
rulesDirs: async () => [{ path: ".cursor/rules", exts: [".mdc", ".md"] }],
|
|
5642
6655
|
write: { kind: "rule-file", path: at(".cursor/rules"), ext: ".mdc", frontmatter: (doc) => ({ description: doc.description ?? `${doc.name} agent instructions (Nomad)`, alwaysApply: true }) },
|
|
5643
|
-
mcp: { path: at(".cursor/mcp.json"), format: "json", style: "claude", writable: true, envExpansion: true }
|
|
6656
|
+
mcp: { path: at(".cursor/mcp.json"), format: "json", style: "claude", writable: true, envExpansion: true, envRefStyle: "env-prefix" }
|
|
5644
6657
|
});
|
|
5645
6658
|
windsurfAdapter = defineFileAdapter({
|
|
5646
6659
|
info: WINDSURF_INFO,
|
|
@@ -5652,7 +6665,7 @@ var init_file_based = __esm({
|
|
|
5652
6665
|
clineAdapter = defineFileAdapter({
|
|
5653
6666
|
info: CLINE_INFO,
|
|
5654
6667
|
detect: [".clinerules"],
|
|
5655
|
-
instructionFiles: async (root) => await isFile(
|
|
6668
|
+
instructionFiles: async (root) => await isFile(join9(root, ".clinerules")) ? [{ path: ".clinerules", kind: "custom" }] : [],
|
|
5656
6669
|
rulesDirs: async () => [{ path: ".clinerules", exts: [".md", ".txt"] }],
|
|
5657
6670
|
write: { kind: "rule-file", path: at(".clinerules"), ext: ".md" }
|
|
5658
6671
|
});
|
|
@@ -5976,7 +6989,7 @@ for item in ${JSON.stringify(memoryLines(doc).filter(Boolean))}:
|
|
|
5976
6989
|
});
|
|
5977
6990
|
|
|
5978
6991
|
// ../../packages/adapters/src/registry.ts
|
|
5979
|
-
import { join as
|
|
6992
|
+
import { join as join10 } from "path";
|
|
5980
6993
|
function registerAdapter(adapter) {
|
|
5981
6994
|
if (!/^[a-z0-9][a-z0-9-]*$/.test(adapter.info.id)) throw new Error(`Invalid adapter id "${adapter.info.id}"`);
|
|
5982
6995
|
registry.set(adapter.info.id, adapter);
|
|
@@ -6034,10 +7047,11 @@ var init_registry = __esm({
|
|
|
6034
7047
|
init_codex();
|
|
6035
7048
|
init_openclaw();
|
|
6036
7049
|
init_hermes();
|
|
7050
|
+
init_elizaos();
|
|
6037
7051
|
init_file_based();
|
|
6038
7052
|
init_guided();
|
|
6039
7053
|
registry = /* @__PURE__ */ new Map();
|
|
6040
|
-
for (const a of [openclawAdapter, claudeCodeAdapter, codexAdapter, hermesAdapter, genericAdapter, ...FILE_ADAPTERS, ...GUIDED_ADAPTERS]) registerAdapter(a);
|
|
7054
|
+
for (const a of [openclawAdapter, claudeCodeAdapter, codexAdapter, hermesAdapter, genericAdapter, elizaosAdapter, ...FILE_ADAPTERS, ...GUIDED_ADAPTERS]) registerAdapter(a);
|
|
6041
7055
|
}
|
|
6042
7056
|
});
|
|
6043
7057
|
|
|
@@ -6051,6 +7065,7 @@ __export(src_exports2, {
|
|
|
6051
7065
|
CODEX_INFO: () => CODEX_INFO,
|
|
6052
7066
|
CONTINUE_INFO: () => CONTINUE_INFO,
|
|
6053
7067
|
CURSOR_INFO: () => CURSOR_INFO,
|
|
7068
|
+
ELIZAOS_INFO: () => ELIZAOS_INFO,
|
|
6054
7069
|
FILE_ADAPTERS: () => FILE_ADAPTERS,
|
|
6055
7070
|
GEMINI_CLI_INFO: () => GEMINI_CLI_INFO,
|
|
6056
7071
|
GENERIC_INFO: () => GENERIC_INFO,
|
|
@@ -6059,13 +7074,16 @@ __export(src_exports2, {
|
|
|
6059
7074
|
GUIDED_INFOS: () => GUIDED_INFOS,
|
|
6060
7075
|
HERMES_DELIMITER: () => HERMES_DELIMITER,
|
|
6061
7076
|
HERMES_INFO: () => HERMES_INFO,
|
|
7077
|
+
KNOWN_ELIZAOS_PLUGINS: () => KNOWN_ELIZAOS_PLUGINS,
|
|
6062
7078
|
OPENCLAW_INFO: () => OPENCLAW_INFO,
|
|
6063
7079
|
OPENCODE_INFO: () => OPENCODE_INFO,
|
|
6064
7080
|
ROO_INFO: () => ROO_INFO,
|
|
6065
7081
|
WINDSURF_INFO: () => WINDSURF_INFO,
|
|
6066
7082
|
adapterInfos: () => adapterInfos,
|
|
7083
|
+
applyKnownServerProfile: () => applyKnownServerProfile,
|
|
6067
7084
|
bareModel: () => bareModel,
|
|
6068
7085
|
blanketEffect: () => blanketEffect,
|
|
7086
|
+
characterToDocument: () => characterToDocument,
|
|
6069
7087
|
claudeCodeAdapter: () => claudeCodeAdapter,
|
|
6070
7088
|
codexAdapter: () => codexAdapter,
|
|
6071
7089
|
codexSettingsFromPolicy: () => codexSettingsFromPolicy,
|
|
@@ -6074,23 +7092,32 @@ __export(src_exports2, {
|
|
|
6074
7092
|
demoteHeadings: () => demoteHeadings,
|
|
6075
7093
|
describeTrigger: () => describeTrigger,
|
|
6076
7094
|
detectAdapterFor: () => detectAdapterFor,
|
|
7095
|
+
documentToCharacter: () => documentToCharacter,
|
|
7096
|
+
elizaosAdapter: () => elizaosAdapter,
|
|
7097
|
+
elizaosPluginHint: () => elizaosPluginHint,
|
|
6077
7098
|
filesHash: () => filesHash,
|
|
6078
7099
|
findAdapter: () => findAdapter,
|
|
6079
7100
|
genericAdapter: () => genericAdapter,
|
|
6080
7101
|
getAdapter: () => getAdapter,
|
|
7102
|
+
hasSecretsKey: () => hasSecretsKey,
|
|
6081
7103
|
hermesAdapter: () => hermesAdapter,
|
|
6082
7104
|
infoById: () => infoById,
|
|
6083
7105
|
instructionsText: () => instructionsText,
|
|
6084
|
-
|
|
7106
|
+
integrationStep: () => integrationStep,
|
|
7107
|
+
join: () => join10,
|
|
7108
|
+
knownElizaosPlugin: () => knownElizaosPlugin,
|
|
7109
|
+
knownServerId: () => knownServerId,
|
|
6085
7110
|
listAdapters: () => listAdapters,
|
|
6086
7111
|
mcpServersFromTools: () => mcpServersFromTools,
|
|
6087
7112
|
modelFamily: () => modelFamily,
|
|
6088
7113
|
nomadBlockKey: () => nomadBlockKey,
|
|
6089
7114
|
openclawAdapter: () => openclawAdapter,
|
|
6090
7115
|
parseAgentMarkdown: () => parseAgentMarkdown,
|
|
7116
|
+
parseCharacter: () => parseCharacter,
|
|
6091
7117
|
parseMemoryMarkdown: () => parseMemoryMarkdown,
|
|
6092
7118
|
parseMixedMemory: () => parseMixedMemory,
|
|
6093
7119
|
plainEntry: () => plainEntry,
|
|
7120
|
+
pluginOf: () => pluginOf,
|
|
6094
7121
|
policyFromCodexConfig: () => policyFromCodexConfig,
|
|
6095
7122
|
policyFromSettings: () => policyFromSettings,
|
|
6096
7123
|
qualifiedModel: () => qualifiedModel,
|
|
@@ -6124,6 +7151,9 @@ var init_src6 = __esm({
|
|
|
6124
7151
|
init_hermes();
|
|
6125
7152
|
init_file_based();
|
|
6126
7153
|
init_guided();
|
|
7154
|
+
init_elizaos();
|
|
7155
|
+
init_elizaos_known_plugins();
|
|
7156
|
+
init_known_servers();
|
|
6127
7157
|
}
|
|
6128
7158
|
});
|
|
6129
7159
|
|
|
@@ -6253,7 +7283,7 @@ import Database from "better-sqlite3";
|
|
|
6253
7283
|
import { drizzle } from "drizzle-orm/better-sqlite3";
|
|
6254
7284
|
import { and, desc, eq } from "drizzle-orm";
|
|
6255
7285
|
import { mkdirSync, readFileSync, writeFileSync, existsSync as existsSync2, chmodSync } from "fs";
|
|
6256
|
-
import { join as
|
|
7286
|
+
import { join as join11 } from "path";
|
|
6257
7287
|
var SCHEMA_VERSION, NomadStore;
|
|
6258
7288
|
var init_src7 = __esm({
|
|
6259
7289
|
"../../packages/storage/src/index.ts"() {
|
|
@@ -6275,8 +7305,8 @@ var init_src7 = __esm({
|
|
|
6275
7305
|
db;
|
|
6276
7306
|
static open(home2 = nomadHome()) {
|
|
6277
7307
|
mkdirSync(home2, { recursive: true, mode: 448 });
|
|
6278
|
-
for (const d of ["objects", "backups", "exports"]) mkdirSync(
|
|
6279
|
-
const dbPath =
|
|
7308
|
+
for (const d of ["objects", "backups", "exports"]) mkdirSync(join11(home2, d), { recursive: true, mode: 448 });
|
|
7309
|
+
const dbPath = join11(home2, "nomad.db");
|
|
6280
7310
|
const sqlite = new Database(dbPath);
|
|
6281
7311
|
try {
|
|
6282
7312
|
chmodSync(dbPath, 384);
|
|
@@ -6297,13 +7327,13 @@ var init_src7 = __esm({
|
|
|
6297
7327
|
}
|
|
6298
7328
|
/* ----------------------------- objects ----------------------------- */
|
|
6299
7329
|
objectPath(hash) {
|
|
6300
|
-
return
|
|
7330
|
+
return join11(this.home, "objects", hash.slice(0, 2), `${hash}.json`);
|
|
6301
7331
|
}
|
|
6302
7332
|
putObject(doc) {
|
|
6303
7333
|
const hash = documentHash(doc);
|
|
6304
7334
|
const p = this.objectPath(hash);
|
|
6305
7335
|
if (!existsSync2(p)) {
|
|
6306
|
-
mkdirSync(
|
|
7336
|
+
mkdirSync(join11(this.home, "objects", hash.slice(0, 2)), { recursive: true, mode: 448 });
|
|
6307
7337
|
writeFileSync(p, JSON.stringify(doc), { mode: 384 });
|
|
6308
7338
|
}
|
|
6309
7339
|
return hash;
|
|
@@ -6443,17 +7473,17 @@ var init_src7 = __esm({
|
|
|
6443
7473
|
});
|
|
6444
7474
|
|
|
6445
7475
|
// ../../packages/migration/src/ops.ts
|
|
6446
|
-
import { promises as
|
|
6447
|
-
import { dirname as
|
|
7476
|
+
import { promises as fsp5 } from "fs";
|
|
7477
|
+
import { dirname as dirname4, join as join12, relative as relative3 } from "path";
|
|
6448
7478
|
import JSON52 from "json5";
|
|
6449
7479
|
import { parse as parseToml2, stringify as stringifyToml2 } from "smol-toml";
|
|
6450
7480
|
import { parseDocument as parseYamlDocument, isMap } from "yaml";
|
|
6451
7481
|
import { createTwoFilesPatch } from "diff";
|
|
6452
7482
|
async function readExisting(abs) {
|
|
6453
7483
|
try {
|
|
6454
|
-
const st = await
|
|
7484
|
+
const st = await fsp5.lstat(abs);
|
|
6455
7485
|
if (!st.isFile()) throw new UnsafePathError(`${abs} exists and is not a regular file`);
|
|
6456
|
-
return new Uint8Array(await
|
|
7486
|
+
return new Uint8Array(await fsp5.readFile(abs));
|
|
6457
7487
|
} catch (e) {
|
|
6458
7488
|
const code = e.code;
|
|
6459
7489
|
if (code === "ENOENT" || code === "ENOTDIR") return null;
|
|
@@ -6663,24 +7693,24 @@ async function applyOperations(ops) {
|
|
|
6663
7693
|
const current2 = await readExisting(op.abs);
|
|
6664
7694
|
const currentHash = current2 ? sha256(current2) : null;
|
|
6665
7695
|
if (currentHash !== op.beforeHash) throw new Error(`${op.display} changed after the preview was created. Preview the migration again.`);
|
|
6666
|
-
let d =
|
|
7696
|
+
let d = dirname4(op.abs);
|
|
6667
7697
|
const toCreate = [];
|
|
6668
7698
|
for (; ; ) {
|
|
6669
7699
|
try {
|
|
6670
|
-
await
|
|
7700
|
+
await fsp5.lstat(d);
|
|
6671
7701
|
break;
|
|
6672
7702
|
} catch {
|
|
6673
7703
|
toCreate.unshift(d);
|
|
6674
|
-
if (d ===
|
|
6675
|
-
d =
|
|
7704
|
+
if (d === dirname4(d)) break;
|
|
7705
|
+
d = dirname4(d);
|
|
6676
7706
|
}
|
|
6677
7707
|
}
|
|
6678
7708
|
for (const dir of toCreate) {
|
|
6679
|
-
await
|
|
7709
|
+
await fsp5.mkdir(dir);
|
|
6680
7710
|
createdDirs.push(dir);
|
|
6681
7711
|
}
|
|
6682
7712
|
let mode = op.mode;
|
|
6683
|
-
if (current2) mode = (await
|
|
7713
|
+
if (current2) mode = (await fsp5.stat(op.abs)).mode & 511;
|
|
6684
7714
|
await atomicWrite(op.abs, op.after, mode);
|
|
6685
7715
|
done.push(op);
|
|
6686
7716
|
}
|
|
@@ -6694,13 +7724,13 @@ async function rollback(done, createdDirs) {
|
|
|
6694
7724
|
for (const op of [...done].reverse()) {
|
|
6695
7725
|
try {
|
|
6696
7726
|
if (op.before) await atomicWrite(op.abs, op.before);
|
|
6697
|
-
else await
|
|
7727
|
+
else await fsp5.rm(op.abs, { force: true });
|
|
6698
7728
|
} catch {
|
|
6699
7729
|
}
|
|
6700
7730
|
}
|
|
6701
7731
|
for (const dir of [...createdDirs].reverse()) {
|
|
6702
7732
|
try {
|
|
6703
|
-
await
|
|
7733
|
+
await fsp5.rmdir(dir);
|
|
6704
7734
|
} catch {
|
|
6705
7735
|
}
|
|
6706
7736
|
}
|
|
@@ -6717,25 +7747,26 @@ var init_ops = __esm({
|
|
|
6717
7747
|
});
|
|
6718
7748
|
|
|
6719
7749
|
// ../../packages/migration/src/backup.ts
|
|
6720
|
-
import { promises as
|
|
6721
|
-
import { join as
|
|
7750
|
+
import { promises as fsp6 } from "fs";
|
|
7751
|
+
import { join as join13 } from "path";
|
|
6722
7752
|
import { createTwoFilesPatch as createTwoFilesPatch2 } from "diff";
|
|
6723
7753
|
async function createBackup(store, files, meta) {
|
|
6724
7754
|
const id = shortId("bk");
|
|
6725
|
-
const dir =
|
|
6726
|
-
await ensureDir(
|
|
7755
|
+
const dir = join13(store.home, "backups", id);
|
|
7756
|
+
await ensureDir(join13(dir, "files"));
|
|
6727
7757
|
const manifest = { id, kind: meta.kind, createdAt: (/* @__PURE__ */ new Date()).toISOString(), operationId: meta.operationId ?? null, agentId: meta.agentId ?? null, description: meta.description, files: [] };
|
|
6728
7758
|
let n = 0;
|
|
6729
7759
|
const seen = /* @__PURE__ */ new Set();
|
|
6730
7760
|
for (const f of files) {
|
|
6731
7761
|
if (seen.has(f.abs)) continue;
|
|
6732
7762
|
seen.add(f.abs);
|
|
7763
|
+
if (isKeyMaterialPath(f.abs)) continue;
|
|
6733
7764
|
try {
|
|
6734
|
-
const st = await
|
|
7765
|
+
const st = await fsp6.lstat(f.abs);
|
|
6735
7766
|
if (!st.isFile()) continue;
|
|
6736
|
-
const data = await
|
|
7767
|
+
const data = await fsp6.readFile(f.abs);
|
|
6737
7768
|
const stored = `files/${String(n++).padStart(5, "0")}`;
|
|
6738
|
-
await
|
|
7769
|
+
await fsp6.writeFile(join13(dir, stored), data, { mode: 384 });
|
|
6739
7770
|
manifest.files.push({ root: f.root, abs: f.abs, existed: true, sha256: sha256(new Uint8Array(data)), mode: st.mode & 511, stored });
|
|
6740
7771
|
} catch (e) {
|
|
6741
7772
|
const code = e.code;
|
|
@@ -6743,18 +7774,18 @@ async function createBackup(store, files, meta) {
|
|
|
6743
7774
|
manifest.files.push({ root: f.root, abs: f.abs, existed: false, sha256: null, mode: null, stored: null });
|
|
6744
7775
|
}
|
|
6745
7776
|
}
|
|
6746
|
-
await
|
|
7777
|
+
await fsp6.writeFile(join13(dir, "backup.json"), JSON.stringify(manifest, null, 2), { mode: 384 });
|
|
6747
7778
|
store.addBackup({ id, operationId: meta.operationId, agentId: meta.agentId, kind: meta.kind, path: dir, fileCount: manifest.files.length, description: meta.description });
|
|
6748
7779
|
return manifest;
|
|
6749
7780
|
}
|
|
6750
7781
|
async function loadBackup(store, id) {
|
|
6751
7782
|
const row = store.getBackup(id);
|
|
6752
7783
|
if (!row) throw new Error(`Backup ${id} not found`);
|
|
6753
|
-
return JSON.parse(await
|
|
7784
|
+
return JSON.parse(await fsp6.readFile(join13(row.path, "backup.json"), "utf8"));
|
|
6754
7785
|
}
|
|
6755
7786
|
async function current(abs) {
|
|
6756
7787
|
try {
|
|
6757
|
-
return new Uint8Array(await
|
|
7788
|
+
return new Uint8Array(await fsp6.readFile(abs));
|
|
6758
7789
|
} catch {
|
|
6759
7790
|
return null;
|
|
6760
7791
|
}
|
|
@@ -6769,7 +7800,7 @@ async function previewRestore(store, id) {
|
|
|
6769
7800
|
if (f.existed) {
|
|
6770
7801
|
if (nowHash === f.sha256) items.push({ path: displayPath(f.abs), abs: f.abs, action: "unchanged" });
|
|
6771
7802
|
else {
|
|
6772
|
-
const saved = new Uint8Array(await
|
|
7803
|
+
const saved = new Uint8Array(await fsp6.readFile(join13(row.path, f.stored)));
|
|
6773
7804
|
items.push({
|
|
6774
7805
|
path: displayPath(f.abs),
|
|
6775
7806
|
abs: f.abs,
|
|
@@ -6795,11 +7826,11 @@ async function restoreBackup(store, id) {
|
|
|
6795
7826
|
const item = preview.items.find((i) => i.abs === f.abs);
|
|
6796
7827
|
assertNoSymlinks(f.root, f.abs);
|
|
6797
7828
|
if (item.action === "restore") {
|
|
6798
|
-
const saved = new Uint8Array(await
|
|
7829
|
+
const saved = new Uint8Array(await fsp6.readFile(join13(row.path, f.stored)));
|
|
6799
7830
|
await atomicWrite(f.abs, saved, f.mode ?? void 0);
|
|
6800
7831
|
store.forgetWrite(f.abs);
|
|
6801
7832
|
} else if (item.action === "delete") {
|
|
6802
|
-
await
|
|
7833
|
+
await fsp6.rm(f.abs, { force: true });
|
|
6803
7834
|
store.forgetWrite(f.abs);
|
|
6804
7835
|
}
|
|
6805
7836
|
}
|
|
@@ -6922,13 +7953,13 @@ var init_compare = __esm({
|
|
|
6922
7953
|
// ../../packages/migration/src/keys.ts
|
|
6923
7954
|
import { createPrivateKey, createPublicKey, generateKeyPairSync, sign, verify } from "crypto";
|
|
6924
7955
|
import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
6925
|
-
import { join as
|
|
7956
|
+
import { join as join14 } from "path";
|
|
6926
7957
|
function fingerprintOf(rawKeyBase64) {
|
|
6927
7958
|
return sha256(new Uint8Array(Buffer.from(rawKeyBase64, "base64"))).slice(0, 16).match(/.{4}/g).join(" ");
|
|
6928
7959
|
}
|
|
6929
7960
|
function keyPaths(home2) {
|
|
6930
|
-
const dir =
|
|
6931
|
-
return { dir, priv:
|
|
7961
|
+
const dir = join14(home2, "keys");
|
|
7962
|
+
return { dir, priv: join14(dir, "signing.pem"), pub: join14(dir, "signing.pub") };
|
|
6932
7963
|
}
|
|
6933
7964
|
function signingIdentity(home2, create = true) {
|
|
6934
7965
|
const p = keyPaths(home2);
|
|
@@ -6990,8 +8021,8 @@ var init_keys = __esm({
|
|
|
6990
8021
|
});
|
|
6991
8022
|
|
|
6992
8023
|
// ../../packages/migration/src/engine.ts
|
|
6993
|
-
import { promises as
|
|
6994
|
-
import { basename as
|
|
8024
|
+
import { promises as fsp7, constants as constants2 } from "fs";
|
|
8025
|
+
import { basename as basename8, dirname as dirname5, join as join15 } from "path";
|
|
6995
8026
|
var PLAN_TTL_MS, Nomad;
|
|
6996
8027
|
var init_engine = __esm({
|
|
6997
8028
|
"../../packages/migration/src/engine.ts"() {
|
|
@@ -7049,7 +8080,12 @@ var init_engine = __esm({
|
|
|
7049
8080
|
const adapter = getAdapter(adapterId);
|
|
7050
8081
|
if (!adapter.read) throw new NomadError(`${adapter.info.displayName} cannot be read by Nomad.`, "not-readable", "Guided platforms only accept agents.");
|
|
7051
8082
|
const r = resolveRoot(root);
|
|
8083
|
+
drainSkippedKeyMaterial();
|
|
7052
8084
|
const result = await adapter.read(r, nativeId, { includeFiles: options.includeFiles, includeSecrets: options.includeSecrets });
|
|
8085
|
+
const skippedKeys = drainSkippedKeyMaterial();
|
|
8086
|
+
if (skippedKeys.length) {
|
|
8087
|
+
result.notes.push({ level: "info", category: "integrations", message: `Skipped ${skippedKeys.length} path(s) that can hold wallet keys: ${skippedKeys.map(displayPath).join(", ")} (not read, not copied)` });
|
|
8088
|
+
}
|
|
7053
8089
|
let doc = parseDocument(result.doc);
|
|
7054
8090
|
const mapped = this.store.findByLocation(adapterId, r, nativeId);
|
|
7055
8091
|
if (!this.store.getAgent(doc.id) && mapped) doc = { ...doc, id: mapped.agentId };
|
|
@@ -7086,12 +8122,12 @@ var init_engine = __esm({
|
|
|
7086
8122
|
return { doc: s.doc, notes: [], scan, sanitize: s.report, version: source.version ?? agent.currentVersion, sourceFiles: [], sourceAdapter: adapter, label: `${agent.name} v${source.version ?? agent.currentVersion} (library)` };
|
|
7087
8123
|
}
|
|
7088
8124
|
case "package": {
|
|
7089
|
-
const
|
|
7090
|
-
const u = unpackAgent(
|
|
8125
|
+
const bytes2 = source.bytes ?? new Uint8Array(await fsp7.readFile(source.path));
|
|
8126
|
+
const u = unpackAgent(bytes2, { includeSecrets: options.includeSecrets, verifySignature });
|
|
7091
8127
|
if (!u.ok || !u.doc) throw new NomadError("The package is not valid: " + u.issues.map((i) => `${i.path}: ${i.message}`).join("; "), "invalid-package");
|
|
7092
8128
|
const who = this.signerOf(u);
|
|
7093
8129
|
const notes = [{ level: who.state === "unknown" ? "warning" : "info", message: describeSigner(who) }, ...u.warnings.map((w) => ({ level: "warning", message: w }))];
|
|
7094
|
-
return { doc: u.doc, notes, scan: u.scan, sanitize: u.sanitize, sourceFiles: [], sourceAdapter: null, label: source.path ?
|
|
8130
|
+
return { doc: u.doc, notes, scan: u.scan, sanitize: u.sanitize, sourceFiles: [], sourceAdapter: null, label: source.path ? basename8(source.path) : "uploaded package", unpack: u, signer: who };
|
|
7095
8131
|
}
|
|
7096
8132
|
}
|
|
7097
8133
|
}
|
|
@@ -7204,34 +8240,34 @@ var init_engine = __esm({
|
|
|
7204
8240
|
const changed = ops.filter((o) => o.after && o.root === root);
|
|
7205
8241
|
if (!changed.length) return adapter.readPolicy(root, nativeId);
|
|
7206
8242
|
const tmp = await makeTempDir("nomad-overlay-");
|
|
7207
|
-
const overlay =
|
|
8243
|
+
const overlay = join15(tmp, basename8(root));
|
|
7208
8244
|
try {
|
|
7209
|
-
await
|
|
8245
|
+
await fsp7.mkdir(overlay, { recursive: true });
|
|
7210
8246
|
for (const o of ops) {
|
|
7211
8247
|
if (o.root !== root) continue;
|
|
7212
8248
|
const data = o.after ?? o.before;
|
|
7213
8249
|
if (!data) continue;
|
|
7214
8250
|
const p = safeJoin(overlay, o.rel);
|
|
7215
|
-
await
|
|
7216
|
-
await
|
|
8251
|
+
await fsp7.mkdir(dirname5(p), { recursive: true });
|
|
8252
|
+
await fsp7.writeFile(p, data);
|
|
7217
8253
|
}
|
|
7218
8254
|
for (const f of ["settings.json", ".claude/settings.json", "config.toml", ".codex/config.toml", "openclaw.json", "config.yaml"]) {
|
|
7219
|
-
const src =
|
|
7220
|
-
const dst =
|
|
8255
|
+
const src = join15(root, f);
|
|
8256
|
+
const dst = join15(overlay, f);
|
|
7221
8257
|
try {
|
|
7222
|
-
await
|
|
8258
|
+
await fsp7.access(dst);
|
|
7223
8259
|
} catch {
|
|
7224
8260
|
try {
|
|
7225
|
-
const data = await
|
|
7226
|
-
await
|
|
7227
|
-
await
|
|
8261
|
+
const data = await fsp7.readFile(src);
|
|
8262
|
+
await fsp7.mkdir(dirname5(dst), { recursive: true });
|
|
8263
|
+
await fsp7.writeFile(dst, data);
|
|
7228
8264
|
} catch {
|
|
7229
8265
|
}
|
|
7230
8266
|
}
|
|
7231
8267
|
}
|
|
7232
8268
|
return await adapter.readPolicy(overlay, nativeId);
|
|
7233
8269
|
} finally {
|
|
7234
|
-
await
|
|
8270
|
+
await fsp7.rm(tmp, { recursive: true, force: true });
|
|
7235
8271
|
}
|
|
7236
8272
|
}
|
|
7237
8273
|
getPlan(id) {
|
|
@@ -7295,7 +8331,7 @@ var init_engine = __esm({
|
|
|
7295
8331
|
const verification = [];
|
|
7296
8332
|
for (const o of changing) {
|
|
7297
8333
|
try {
|
|
7298
|
-
const data = new Uint8Array(await
|
|
8334
|
+
const data = new Uint8Array(await fsp7.readFile(o.abs));
|
|
7299
8335
|
if (sha256(data) !== o.afterHash) verification.push({ name: `${o.display} written`, ok: false, detail: "Content differs from what was planned" });
|
|
7300
8336
|
} catch {
|
|
7301
8337
|
verification.push({ name: `${o.display} written`, ok: false, detail: "File is missing" });
|
|
@@ -7333,18 +8369,18 @@ var init_engine = __esm({
|
|
|
7333
8369
|
}
|
|
7334
8370
|
}
|
|
7335
8371
|
async lock() {
|
|
7336
|
-
const path =
|
|
8372
|
+
const path = join15(this.store.home, "migration.lock");
|
|
7337
8373
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
7338
8374
|
try {
|
|
7339
|
-
const fh = await
|
|
8375
|
+
const fh = await fsp7.open(path, constants2.O_CREAT | constants2.O_EXCL | constants2.O_WRONLY, 384);
|
|
7340
8376
|
await fh.writeFile(String(process.pid));
|
|
7341
8377
|
await fh.close();
|
|
7342
8378
|
return async () => {
|
|
7343
|
-
await
|
|
8379
|
+
await fsp7.rm(path, { force: true });
|
|
7344
8380
|
};
|
|
7345
8381
|
} catch (e) {
|
|
7346
8382
|
if (e.code !== "EEXIST") throw e;
|
|
7347
|
-
const pid = Number(await
|
|
8383
|
+
const pid = Number(await fsp7.readFile(path, "utf8").catch(() => "0"));
|
|
7348
8384
|
let alive = false;
|
|
7349
8385
|
try {
|
|
7350
8386
|
if (pid) {
|
|
@@ -7355,7 +8391,7 @@ var init_engine = __esm({
|
|
|
7355
8391
|
alive = false;
|
|
7356
8392
|
}
|
|
7357
8393
|
if (alive) throw new NomadError("Another Nomad operation is running.", "locked", "Wait for it to finish and try again.");
|
|
7358
|
-
await
|
|
8394
|
+
await fsp7.rm(path, { force: true });
|
|
7359
8395
|
}
|
|
7360
8396
|
}
|
|
7361
8397
|
throw new NomadError("Could not acquire the operation lock.", "locked");
|
|
@@ -7375,7 +8411,7 @@ var init_engine = __esm({
|
|
|
7375
8411
|
const ext = interchange ? INTERCHANGE_EXTENSION : PACKAGE_EXTENSION;
|
|
7376
8412
|
let path = null;
|
|
7377
8413
|
if (options.outPath !== void 0) {
|
|
7378
|
-
path = /\.(nomad|agentpack|jetpack)$/.test(options.outPath) ? options.outPath :
|
|
8414
|
+
path = /\.(nomad|agentpack|jetpack)$/.test(options.outPath) ? options.outPath : join15(options.outPath, `${doc.name.replace(/[^A-Za-z0-9._-]+/g, "-")}${ext}`);
|
|
7379
8415
|
await atomicWrite(path, pack.bytes, 384);
|
|
7380
8416
|
}
|
|
7381
8417
|
const receipt = {
|
|
@@ -7401,8 +8437,8 @@ var init_engine = __esm({
|
|
|
7401
8437
|
return { ...pack, path, receipt };
|
|
7402
8438
|
}
|
|
7403
8439
|
/** Validate a package without importing it. */
|
|
7404
|
-
validatePackage(
|
|
7405
|
-
const u = unpackAgent(
|
|
8440
|
+
validatePackage(bytes2) {
|
|
8441
|
+
const u = unpackAgent(bytes2, { verifySignature });
|
|
7406
8442
|
return { ...u, signer: this.signerOf(u) };
|
|
7407
8443
|
}
|
|
7408
8444
|
/* ------------------------------------------------------------------ */
|
|
@@ -7416,8 +8452,8 @@ var init_engine = __esm({
|
|
|
7416
8452
|
return this.store.getSetting("trustedKeys", []);
|
|
7417
8453
|
}
|
|
7418
8454
|
/** Trust the key that signed a package, under a name you choose. */
|
|
7419
|
-
trustPackageSigner(
|
|
7420
|
-
const u = unpackAgent(
|
|
8455
|
+
trustPackageSigner(bytes2, name) {
|
|
8456
|
+
const u = unpackAgent(bytes2, { verifySignature });
|
|
7421
8457
|
const sig = u.info?.signature;
|
|
7422
8458
|
if (!sig) throw new NomadError("This package is not signed.", "unsigned");
|
|
7423
8459
|
if (sig.verified !== true) throw new NomadError("The signature does not match the package, so its key cannot be trusted.", "invalid-signature");
|
|
@@ -7434,13 +8470,13 @@ var init_engine = __esm({
|
|
|
7434
8470
|
}
|
|
7435
8471
|
/** Import a package into the local library. Use plan() with a package source to also write it to a platform. */
|
|
7436
8472
|
async importPackage(input) {
|
|
7437
|
-
const
|
|
7438
|
-
const u = unpackAgent(
|
|
8473
|
+
const bytes2 = input.bytes ?? new Uint8Array(await fsp7.readFile(input.path));
|
|
8474
|
+
const u = unpackAgent(bytes2, { verifySignature });
|
|
7439
8475
|
if (!u.ok || !u.doc) return { ok: false, issues: u.issues, warnings: u.warnings };
|
|
7440
8476
|
const who = this.signerOf(u);
|
|
7441
8477
|
const known = this.store.getAgent(u.doc.id);
|
|
7442
8478
|
const operationId = shortId("op");
|
|
7443
|
-
const doc = { ...u.doc, history: [...u.doc.history, { operationId, kind: "import", from: input.path ?
|
|
8479
|
+
const doc = { ...u.doc, history: [...u.doc.history, { operationId, kind: "import", from: input.path ? basename8(input.path) : "package", at: (/* @__PURE__ */ new Date()).toISOString() }] };
|
|
7444
8480
|
const saved = this.store.saveAgent(doc, { reason: "Imported package", operationId, platform: doc.source.platform });
|
|
7445
8481
|
const receipt = { operationId, kind: "import", status: "success", agent: { id: doc.id, name: doc.name }, recognized: !!known, version: saved.version, warnings: u.warnings, findings: u.scan?.findings.length ?? 0, redacted: u.sanitize?.redactedText ?? 0, executableFiles: u.executableFiles, at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
7446
8482
|
this.store.saveOperation({ id: operationId, kind: "import", agentId: doc.id, source: input.path ?? "package", destination: "library", status: "success", createdAt: receipt.at, receipt });
|
|
@@ -7516,7 +8552,7 @@ var init_engine = __esm({
|
|
|
7516
8552
|
if (!adapter?.read) continue;
|
|
7517
8553
|
try {
|
|
7518
8554
|
const r = await adapter.read(loc.root, loc.nativeId);
|
|
7519
|
-
for (const f of r.sourceFiles) files.push({ root:
|
|
8555
|
+
for (const f of r.sourceFiles) files.push({ root: dirname5(f), abs: f });
|
|
7520
8556
|
} catch {
|
|
7521
8557
|
}
|
|
7522
8558
|
}
|
|
@@ -7627,7 +8663,7 @@ __export(src_exports3, {
|
|
|
7627
8663
|
createBackup: () => createBackup,
|
|
7628
8664
|
describeSigner: () => describeSigner,
|
|
7629
8665
|
fingerprintOf: () => fingerprintOf,
|
|
7630
|
-
join: () =>
|
|
8666
|
+
join: () => join12,
|
|
7631
8667
|
loadBackup: () => loadBackup,
|
|
7632
8668
|
parseSource: () => parseSource,
|
|
7633
8669
|
previewRestore: () => previewRestore,
|
|
@@ -7663,7 +8699,7 @@ __export(src_exports4, {
|
|
|
7663
8699
|
import { McpServer as McpServer2 } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
7664
8700
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
7665
8701
|
import { readFileSync as readFileSync4 } from "fs";
|
|
7666
|
-
import { join as
|
|
8702
|
+
import { join as join18, resolve as resolve5 } from "path";
|
|
7667
8703
|
import { z as z4 } from "zod";
|
|
7668
8704
|
function text2(data) {
|
|
7669
8705
|
return { content: [{ type: "text", text: typeof data === "string" ? data : JSON.stringify(data, null, 2) }] };
|
|
@@ -7696,9 +8732,9 @@ function summarizePlan(p) {
|
|
|
7696
8732
|
};
|
|
7697
8733
|
}
|
|
7698
8734
|
function createMcpServer(options = {}) {
|
|
7699
|
-
const nomad = new Nomad({ home: options.home ?
|
|
8735
|
+
const nomad = new Nomad({ home: options.home ? resolve5(options.home) : nomadHome() });
|
|
7700
8736
|
const server = new McpServer2({ name: "nomad", version: NOMAD_VERSION });
|
|
7701
|
-
const exportsDir =
|
|
8737
|
+
const exportsDir = join18(nomad.store.home, "exports");
|
|
7702
8738
|
server.registerTool(
|
|
7703
8739
|
"list_agents",
|
|
7704
8740
|
{ title: "List agents", description: "Agents in the local Nomad library with their known locations.", inputSchema: {} },
|
|
@@ -7768,7 +8804,7 @@ function createMcpServer(options = {}) {
|
|
|
7768
8804
|
{ 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") } },
|
|
7769
8805
|
async ({ path }) => {
|
|
7770
8806
|
try {
|
|
7771
|
-
const p =
|
|
8807
|
+
const p = resolve5(expandHome(path));
|
|
7772
8808
|
if (!/\.(nomad|agentpack|jetpack)$/.test(p)) throw new NomadError("Only .nomad, .agentpack or .jetpack files can be validated.", "usage");
|
|
7773
8809
|
const r = nomad.validatePackage(new Uint8Array(readFileSync4(p)));
|
|
7774
8810
|
return text2({ ok: r.ok, name: r.doc?.name, issues: r.issues, warnings: r.warnings, secretsFound: r.scan?.findings.length ?? 0 });
|
|
@@ -7894,7 +8930,7 @@ import { Command, Option } from "commander";
|
|
|
7894
8930
|
import { createInterface } from "readline/promises";
|
|
7895
8931
|
import { spawn as spawn2 } from "child_process";
|
|
7896
8932
|
import { existsSync as existsSync6, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
7897
|
-
import { dirname as
|
|
8933
|
+
import { dirname as dirname6, join as join19, resolve as resolve6 } from "path";
|
|
7898
8934
|
import { fileURLToPath } from "url";
|
|
7899
8935
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
7900
8936
|
|
|
@@ -8050,20 +9086,20 @@ function approvalQuestion(p) {
|
|
|
8050
9086
|
// src/remote.ts
|
|
8051
9087
|
init_src2();
|
|
8052
9088
|
import { spawn } from "child_process";
|
|
8053
|
-
import { basename as
|
|
9089
|
+
import { basename as basename9 } from "path";
|
|
8054
9090
|
function shellQuote(s) {
|
|
8055
9091
|
if (/^[A-Za-z0-9_\/.:=@%+-]+$/.test(s)) return s;
|
|
8056
9092
|
return `'${s.replace(/'/g, `'\\''`)}'`;
|
|
8057
9093
|
}
|
|
8058
9094
|
function run(cmd, args, input) {
|
|
8059
|
-
return new Promise((
|
|
9095
|
+
return new Promise((resolve7, reject) => {
|
|
8060
9096
|
const p = spawn(cmd, args, { stdio: ["pipe", "pipe", "pipe"] });
|
|
8061
9097
|
let stdout = "";
|
|
8062
9098
|
let stderr = "";
|
|
8063
9099
|
p.stdout.on("data", (d) => stdout += d);
|
|
8064
9100
|
p.stderr.on("data", (d) => stderr += d);
|
|
8065
9101
|
p.on("error", (e) => reject(new NomadError(`${cmd} is not available: ${e.message}`, "ssh-missing", "Install OpenSSH to use remote migration.")));
|
|
8066
|
-
p.on("close", (code) =>
|
|
9102
|
+
p.on("close", (code) => resolve7({ code: code ?? 1, stdout, stderr }));
|
|
8067
9103
|
if (input) p.stdin.end(input);
|
|
8068
9104
|
else p.stdin.end();
|
|
8069
9105
|
});
|
|
@@ -8086,10 +9122,10 @@ async function remoteMigrate(o, packagePath, args) {
|
|
|
8086
9122
|
if (mk.code !== 0) explain2(mk.stderr, o.host);
|
|
8087
9123
|
const dir = mk.stdout.trim();
|
|
8088
9124
|
if (!/^\/[\w./-]+$/.test(dir)) throw new NomadError("Unexpected temporary directory from the remote host.", "ssh-failed");
|
|
8089
|
-
const scpArgs = ["-o", "StrictHostKeyChecking=yes", "-o", "BatchMode=yes", ...o.port ? ["-P", String(o.port)] : [], ...o.identity ? ["-i", o.identity] : [], packagePath, `${o.host}:${dir}/${
|
|
9125
|
+
const scpArgs = ["-o", "StrictHostKeyChecking=yes", "-o", "BatchMode=yes", ...o.port ? ["-P", String(o.port)] : [], ...o.identity ? ["-i", o.identity] : [], packagePath, `${o.host}:${dir}/${basename9(packagePath)}`];
|
|
8090
9126
|
const cp = await run("scp", scpArgs);
|
|
8091
9127
|
if (cp.code !== 0) explain2(cp.stderr, o.host);
|
|
8092
|
-
const remotePack = `${dir}/${
|
|
9128
|
+
const remotePack = `${dir}/${basename9(packagePath)}`;
|
|
8093
9129
|
const cmd = [o.remoteCommand, "migrate", "--from", shellQuote(remotePack), "--to", shellQuote(args.to), "--dest-dir", shellQuote(args.dest), "--mode", shellQuote(args.mode), ...args.apply ? ["--yes"] : ["--dry-run"], "--json"].join(" ");
|
|
8094
9130
|
const r = await run("ssh", [...sshBase(o), o.host, `${cmd}; status=$?; rm -rf ${shellQuote(dir)}; exit $status`]);
|
|
8095
9131
|
if (r.code !== 0 && !r.stdout.trim()) explain2(r.stderr, o.host);
|
|
@@ -8103,12 +9139,12 @@ async function remoteMigrate(o, packagePath, args) {
|
|
|
8103
9139
|
// src/ui.ts
|
|
8104
9140
|
import { createServer } from "http";
|
|
8105
9141
|
import { existsSync as existsSync5, readFileSync as readFileSync3, statSync as statSync2 } from "fs";
|
|
8106
|
-
import { extname, join as
|
|
9142
|
+
import { extname, join as join17, normalize, resolve as resolve4, sep as sep4 } from "path";
|
|
8107
9143
|
|
|
8108
9144
|
// ../../packages/local/src/index.ts
|
|
8109
9145
|
import { timingSafeEqual } from "crypto";
|
|
8110
9146
|
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
8111
|
-
import { basename as
|
|
9147
|
+
import { basename as basename10, join as join16, resolve as resolve3, sep as sep3 } from "path";
|
|
8112
9148
|
var SESSION_COOKIE = "nomad_session";
|
|
8113
9149
|
var HttpError = class extends Error {
|
|
8114
9150
|
constructor(status, message) {
|
|
@@ -8176,9 +9212,9 @@ function safeSource(nomadHome2, s) {
|
|
|
8176
9212
|
}
|
|
8177
9213
|
if (s.kind === "stored") return { kind: "stored", agentId: String(s.agentId), version: s.version ? Number(s.version) : void 0 };
|
|
8178
9214
|
if (s.kind === "package") {
|
|
8179
|
-
const uploads =
|
|
8180
|
-
const p =
|
|
8181
|
-
if (!p.startsWith(uploads +
|
|
9215
|
+
const uploads = join16(nomadHome2, "uploads");
|
|
9216
|
+
const p = resolve3(String(s.path));
|
|
9217
|
+
if (!p.startsWith(uploads + sep3) || !/\.(nomad|agentpack|jetpack)$/.test(p)) throw new HttpError(400, "Packages must be uploaded first.");
|
|
8182
9218
|
return { kind: "package", path: p };
|
|
8183
9219
|
}
|
|
8184
9220
|
throw new HttpError(400, "Unknown source kind.");
|
|
@@ -8258,15 +9294,15 @@ async function handle(req, ctx, path) {
|
|
|
8258
9294
|
}
|
|
8259
9295
|
case "POST export": {
|
|
8260
9296
|
const s = await body(req);
|
|
8261
|
-
const dir =
|
|
9297
|
+
const dir = join16(home2, "exports");
|
|
8262
9298
|
await mkdir(dir, { recursive: true, mode: 448 });
|
|
8263
9299
|
const r = await nomad.exportAgent(safeSource(home2, s.source), { outPath: dir, includeSecrets: !!s.includeSecrets, includeFiles: !!s.includeFiles, components: Array.isArray(s.components) && s.components.length ? s.components : void 0, format: s.format === "interchange" ? "interchange" : "nomad", sign: !!s.sign && s.format !== "interchange" });
|
|
8264
|
-
return json({ file:
|
|
9300
|
+
return json({ file: basename10(r.path), size: r.bytes.length, notIncluded: r.receipt.notIncluded, redacted: r.sanitize.redactedText, references: r.sanitize.strippedEnvValues.length, removedFiles: r.sanitize.removedFiles, signedBy: r.receipt.signedBy ?? null, receipt: r.receipt });
|
|
8265
9301
|
}
|
|
8266
9302
|
case "GET download": {
|
|
8267
9303
|
const name = q("file") ?? "";
|
|
8268
9304
|
if (!/^[\w.-]+\.(nomad|agentpack|jetpack)$/.test(name)) throw new HttpError(400, "Invalid file name.");
|
|
8269
|
-
const data = await readFile(
|
|
9305
|
+
const data = await readFile(join16(home2, "exports", name)).catch(() => {
|
|
8270
9306
|
throw new HttpError(404, "File not found.");
|
|
8271
9307
|
});
|
|
8272
9308
|
return new Response(new Uint8Array(data), { headers: { "Content-Type": "application/zip", "Content-Disposition": `attachment; filename="${name}"`, "Cache-Control": "no-store" } });
|
|
@@ -8277,9 +9313,9 @@ async function handle(req, ctx, path) {
|
|
|
8277
9313
|
if (data.length > 128 * 1024 * 1024) throw new HttpError(413, "The package is larger than 128 MB.");
|
|
8278
9314
|
const v = nomad.validatePackage(data);
|
|
8279
9315
|
if (!v.ok) return json({ ok: false, issues: v.issues });
|
|
8280
|
-
const dir =
|
|
9316
|
+
const dir = join16(home2, "uploads");
|
|
8281
9317
|
await mkdir(dir, { recursive: true, mode: 448 });
|
|
8282
|
-
const path2 =
|
|
9318
|
+
const path2 = join16(dir, `${Date.now()}-${v.doc.id}.nomad`);
|
|
8283
9319
|
await writeFile(path2, data, { mode: 384 });
|
|
8284
9320
|
return json({ ok: true, path: path2, name: v.doc.name, id: v.doc.id, warnings: v.warnings, secrets: v.scan?.findings.length ?? 0, files: v.fileCount, counts: { instructions: v.doc.instructions.length, memory: v.doc.memory.length, skills: v.doc.skills.length, tools: v.doc.tools.length, workflows: v.doc.workflows.length } });
|
|
8285
9321
|
}
|
|
@@ -8342,8 +9378,8 @@ var SECURITY_HEADERS = {
|
|
|
8342
9378
|
"Permissions-Policy": "camera=(), microphone=(), geolocation=()"
|
|
8343
9379
|
};
|
|
8344
9380
|
function findSite(here) {
|
|
8345
|
-
const candidates = [
|
|
8346
|
-
return candidates.find((d) => existsSync5(
|
|
9381
|
+
const candidates = [resolve4(here, "../web"), resolve4(here, "../../web/.next-export"), resolve4(process.cwd(), "apps/web/.next-export")];
|
|
9382
|
+
return candidates.find((d) => existsSync5(join17(d, "app.html"))) ?? null;
|
|
8347
9383
|
}
|
|
8348
9384
|
function fileFor(site, pathname) {
|
|
8349
9385
|
let rel;
|
|
@@ -8353,9 +9389,9 @@ function fileFor(site, pathname) {
|
|
|
8353
9389
|
return null;
|
|
8354
9390
|
}
|
|
8355
9391
|
if (rel.includes("\0")) return null;
|
|
8356
|
-
const base = normalize(
|
|
8357
|
-
if (base !== site && !base.startsWith(site +
|
|
8358
|
-
for (const p of [base, `${base}.html`,
|
|
9392
|
+
const base = normalize(join17(site, rel));
|
|
9393
|
+
if (base !== site && !base.startsWith(site + sep4)) return null;
|
|
9394
|
+
for (const p of [base, `${base}.html`, join17(base, "index.html")]) {
|
|
8359
9395
|
try {
|
|
8360
9396
|
if (statSync2(p).isFile()) return p;
|
|
8361
9397
|
} catch {
|
|
@@ -8413,7 +9449,7 @@ function startUi(opts) {
|
|
|
8413
9449
|
return;
|
|
8414
9450
|
}
|
|
8415
9451
|
const file = fileFor(site, url.pathname === "/" ? "/index.html" : url.pathname);
|
|
8416
|
-
const path = file ??
|
|
9452
|
+
const path = file ?? join17(site, "404.html");
|
|
8417
9453
|
const type = TYPES[extname(path)] ?? "application/octet-stream";
|
|
8418
9454
|
const immutable = url.pathname.startsWith("/_next/static/");
|
|
8419
9455
|
res.writeHead(file ? 200 : 404, { ...SECURITY_HEADERS, "Content-Type": type, "Cache-Control": immutable ? "public, max-age=31536000, immutable" : "no-cache" });
|
|
@@ -8452,8 +9488,8 @@ function out() {
|
|
|
8452
9488
|
}
|
|
8453
9489
|
function engine() {
|
|
8454
9490
|
const home2 = program.opts().home;
|
|
8455
|
-
if (home2) process.env.NOMAD_HOME =
|
|
8456
|
-
return new Nomad({ home: home2 ?
|
|
9491
|
+
if (home2) process.env.NOMAD_HOME = resolve6(home2);
|
|
9492
|
+
return new Nomad({ home: home2 ? resolve6(home2) : nomadHome() });
|
|
8457
9493
|
}
|
|
8458
9494
|
function components(list) {
|
|
8459
9495
|
if (!list) return void 0;
|
|
@@ -8582,7 +9618,7 @@ program.command("inspect <source>").description("show what an agent contains (re
|
|
|
8582
9618
|
program.command("validate <package>").description("check a package (.nomad, .agentpack or .jetpack) without importing it").action(
|
|
8583
9619
|
(pkg) => run2(async (nomad) => {
|
|
8584
9620
|
const { readFileSync: readFileSync5 } = await import("fs");
|
|
8585
|
-
const r = nomad.validatePackage(new Uint8Array(readFileSync5(
|
|
9621
|
+
const r = nomad.validatePackage(new Uint8Array(readFileSync5(resolve6(pkg))));
|
|
8586
9622
|
const { describeSigner: describeSigner2 } = await Promise.resolve().then(() => (init_src8(), src_exports3));
|
|
8587
9623
|
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 ?? [] });
|
|
8588
9624
|
return r.ok ? EXIT.ok : EXIT.invalid;
|
|
@@ -8592,7 +9628,7 @@ program.command("export <source>").description("export an agent to a portable .n
|
|
|
8592
9628
|
(source, o) => run2(async (nomad) => {
|
|
8593
9629
|
const spec = await parseSource(nomad, source, { sourceDir: o.sourceDir, agent: o.agent });
|
|
8594
9630
|
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"));
|
|
8595
|
-
const r = await nomad.exportAgent(spec, { outPath:
|
|
9631
|
+
const r = await nomad.exportAgent(spec, { outPath: resolve6(o.out), includeSecrets: o.includeSecrets, includeFiles: o.includeFiles, includeSensitiveFiles: o.includeSensitiveFiles, components: components(o.components), format: o.format === "jetpack" ? "interchange" : "nomad", sign: o.sign });
|
|
8596
9632
|
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.receipt);
|
|
8597
9633
|
})
|
|
8598
9634
|
);
|
|
@@ -8600,7 +9636,7 @@ approvalOptions(
|
|
|
8600
9636
|
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")
|
|
8601
9637
|
).action(
|
|
8602
9638
|
(pkg, o) => run2(async (nomad) => {
|
|
8603
|
-
const path =
|
|
9639
|
+
const path = resolve6(pkg);
|
|
8604
9640
|
const r = await nomad.importPackage({ path });
|
|
8605
9641
|
if (!r.ok) {
|
|
8606
9642
|
print(out(), () => [red("The package was rejected"), ...r.issues.map((i) => ` ${i.path}: ${i.message}`)], r);
|
|
@@ -8632,7 +9668,7 @@ approvalOptions(
|
|
|
8632
9668
|
})
|
|
8633
9669
|
);
|
|
8634
9670
|
function parseDestination(spec) {
|
|
8635
|
-
if (/\.(nomad|jetpack)$/i.test(spec)) return { kind: "file", path:
|
|
9671
|
+
if (/\.(nomad|jetpack)$/i.test(spec)) return { kind: "file", path: resolve6(spec.replace(/^~(?=$|\/)/, process.env.HOME ?? "~")) };
|
|
8636
9672
|
const m = /^([a-z0-9-]+)(?::(.*?))?(?:#(.+))?$/.exec(spec);
|
|
8637
9673
|
const adapter = m ? findAdapter(m[1]) : void 0;
|
|
8638
9674
|
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.`);
|
|
@@ -8670,7 +9706,7 @@ program.command("keys").description("show your signing key, and the keys you tru
|
|
|
8670
9706
|
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(
|
|
8671
9707
|
(pkg, o) => run2(async (nomad) => {
|
|
8672
9708
|
const { readFileSync: readFileSync5 } = await import("fs");
|
|
8673
|
-
const k = nomad.trustPackageSigner(new Uint8Array(readFileSync5(
|
|
9709
|
+
const k = nomad.trustPackageSigner(new Uint8Array(readFileSync5(resolve6(pkg))), o.name);
|
|
8674
9710
|
print(out(), () => [green("Trusted") + ` ${k.fingerprint} ${k.name}`, dim("Check this fingerprint with them through another channel.")], k);
|
|
8675
9711
|
})
|
|
8676
9712
|
);
|
|
@@ -8778,7 +9814,7 @@ remote.command("push <source>").description("export locally, copy over SSH, and
|
|
|
8778
9814
|
(source, o) => run2(async (nomad) => {
|
|
8779
9815
|
const spec = await parseSource(nomad, source);
|
|
8780
9816
|
const tmp = await makeTempDir("nomad-remote-");
|
|
8781
|
-
const exp = await nomad.exportAgent(spec, { outPath:
|
|
9817
|
+
const exp = await nomad.exportAgent(spec, { outPath: join19(tmp, "agent.nomad") });
|
|
8782
9818
|
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 });
|
|
8783
9819
|
print(out(), () => typeof r.result === "string" ? r.result : r.result.receipt ? receiptText(r.result.receipt) : planText(r.result.plan, out().verbose), r.result);
|
|
8784
9820
|
return r.code;
|
|
@@ -8787,10 +9823,10 @@ remote.command("push <source>").description("export locally, copy over SSH, and
|
|
|
8787
9823
|
program.command("schema").description("write the Universal Agent Format JSON Schemas").option("-o, --out <dir>", "output directory", ".").action(
|
|
8788
9824
|
(o) => run2(async () => {
|
|
8789
9825
|
const s = jsonSchemas();
|
|
8790
|
-
const dir =
|
|
9826
|
+
const dir = resolve6(o.out);
|
|
8791
9827
|
mkdirSync3(dir, { recursive: true });
|
|
8792
|
-
writeFileSync3(
|
|
8793
|
-
writeFileSync3(
|
|
9828
|
+
writeFileSync3(join19(dir, "agent-document.schema.json"), JSON.stringify(s.agentDocument, null, 2));
|
|
9829
|
+
writeFileSync3(join19(dir, "package-manifest.schema.json"), JSON.stringify(s.packageManifest, null, 2));
|
|
8794
9830
|
print(out(), () => `Wrote schemas to ${dir}`, { dir });
|
|
8795
9831
|
})
|
|
8796
9832
|
);
|
|
@@ -8813,7 +9849,7 @@ program.command("mcp").description("run the Nomad MCP server on stdio").option("
|
|
|
8813
9849
|
await startMcpServer2({ home: program.opts().home, allowWrites: !!o.allowWrites, allowReplace: !!o.allowReplace && !!o.allowWrites });
|
|
8814
9850
|
});
|
|
8815
9851
|
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").action(async (o) => {
|
|
8816
|
-
const here =
|
|
9852
|
+
const here = dirname6(fileURLToPath(import.meta.url));
|
|
8817
9853
|
const token = randomBytes3(24).toString("base64url");
|
|
8818
9854
|
const port = Number(o.port);
|
|
8819
9855
|
const url = `http://127.0.0.1:${port}/app/session?token=${token}`;
|
|
@@ -8823,16 +9859,16 @@ program.command("ui").description("open the dashboard in your browser (only this
|
|
|
8823
9859
|
spawn2(cmd, args, { stdio: "ignore", detached: true }).on("error", () => void 0).unref();
|
|
8824
9860
|
};
|
|
8825
9861
|
if (o.dev) {
|
|
8826
|
-
const webDir = [
|
|
9862
|
+
const webDir = [resolve6(here, "../../web"), resolve6(process.cwd(), "apps/web")].find((d) => existsSync6(join19(d, "package.json")));
|
|
8827
9863
|
if (!webDir) {
|
|
8828
9864
|
process.stderr.write(red("--dev needs the repository checkout.\n"));
|
|
8829
9865
|
process.exitCode = 1;
|
|
8830
9866
|
return;
|
|
8831
9867
|
}
|
|
8832
|
-
const env = { ...process.env, NOMAD_LOCAL: "1", NOMAD_LOCAL_TOKEN: token, NOMAD_HOME: program.opts().home ?
|
|
9868
|
+
const env = { ...process.env, NOMAD_LOCAL: "1", NOMAD_LOCAL_TOKEN: token, NOMAD_HOME: program.opts().home ? resolve6(program.opts().home) : nomadHome(), PORT: String(port) };
|
|
8833
9869
|
process.stderr.write(`${bold("Nomad")} dev server at ${url}
|
|
8834
9870
|
`);
|
|
8835
|
-
const child = spawn2(process.execPath, [
|
|
9871
|
+
const child = spawn2(process.execPath, [join19(webDir, "node_modules", "next", "dist", "bin", "next"), "dev", "-H", "127.0.0.1", "-p", String(port)], { cwd: webDir, env, stdio: ["ignore", "inherit", "inherit"] });
|
|
8836
9872
|
setTimeout(openBrowser, 2500);
|
|
8837
9873
|
child.on("exit", (code) => process.exitCode = code ?? 0);
|
|
8838
9874
|
return;
|
|
@@ -8895,7 +9931,7 @@ async function guided(nomad) {
|
|
|
8895
9931
|
if (items.length === 1) process.stderr.write(dim("No agents were found at the usual places. You can open a package file.") + "\n");
|
|
8896
9932
|
const pick = await choose(rl, "Which agent?", items);
|
|
8897
9933
|
if (pick === "file") {
|
|
8898
|
-
const path =
|
|
9934
|
+
const path = resolve6((await rl.question("Path to the file: ")).trim().replace(/^~(?=$|\/)/, process.env.HOME ?? "~"));
|
|
8899
9935
|
if (!existsSync6(path)) throw new NomadError(`There is no file at ${path}.`, "not-found");
|
|
8900
9936
|
source = { kind: "package", path };
|
|
8901
9937
|
from = null;
|
|
@@ -8918,7 +9954,7 @@ async function guided(nomad) {
|
|
|
8918
9954
|
const name = (await nomad.loadSource(source).catch(() => null))?.doc.name ?? "agent";
|
|
8919
9955
|
const def = `./${name.replace(/[^A-Za-z0-9._-]+/g, "-")}.nomad`;
|
|
8920
9956
|
const a = (await rl.question(`Save to ${dim(`[${def}]`)}: `)).trim();
|
|
8921
|
-
dest = { kind: "file", path:
|
|
9957
|
+
dest = { kind: "file", path: resolve6(a || def) };
|
|
8922
9958
|
} else {
|
|
8923
9959
|
const info = getAdapter(where).info;
|
|
8924
9960
|
const def = info.defaultLocations[0] ?? displayPath(process.cwd());
|