@glyphteck/veyl 0.57.0 → 0.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +137 -187
- package/dist/index.js +89 -122
- package/docs/agents.md +18 -16
- package/docs/api.md +21 -25
- package/docs/cli.md +13 -12
- package/docs/validation.md +1 -1
- package/examples/bot-fleet/readme.md +1 -1
- package/examples/bot-fleet/runtime.js +0 -1
- package/package.json +1 -1
- package/readme.md +13 -14
package/dist/index.js
CHANGED
|
@@ -46,26 +46,6 @@ var __export = (target, all) => {
|
|
|
46
46
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
47
47
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
48
48
|
|
|
49
|
-
// ../../core/agreement.js
|
|
50
|
-
function hasCurrentAgreement(user) {
|
|
51
|
-
const agreement = user?.agreement;
|
|
52
|
-
return agreement?.termsVersion === CURRENT_AGREEMENT.termsVersion && agreement?.communityRulesVersion === CURRENT_AGREEMENT.communityRulesVersion && !!agreement?.acceptedAt;
|
|
53
|
-
}
|
|
54
|
-
function requireCurrentTermsVersion(value) {
|
|
55
|
-
const version = typeof value === "string" ? value.trim() : "";
|
|
56
|
-
if (version !== TERMS_VERSION) {
|
|
57
|
-
throw new Error(`Current Terms version ${TERMS_VERSION} must be accepted.`);
|
|
58
|
-
}
|
|
59
|
-
return version;
|
|
60
|
-
}
|
|
61
|
-
var TERMS_VERSION = "2026-07-15", COMMUNITY_RULES_VERSION = "2026-05-11.1", CURRENT_AGREEMENT;
|
|
62
|
-
var init_agreement = __esm(() => {
|
|
63
|
-
CURRENT_AGREEMENT = Object.freeze({
|
|
64
|
-
termsVersion: TERMS_VERSION,
|
|
65
|
-
communityRulesVersion: COMMUNITY_RULES_VERSION
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
49
|
// ../../node_modules/.bun/@noble+hashes@2.2.0/node_modules/@noble/hashes/utils.js
|
|
70
50
|
function isBytes(a) {
|
|
71
51
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
@@ -8777,6 +8757,19 @@ var init_avatar = __esm(() => {
|
|
|
8777
8757
|
AVATAR_VERSION_RE = /^[0-9a-f]{64}$/;
|
|
8778
8758
|
});
|
|
8779
8759
|
|
|
8760
|
+
// ../../core/agreement.js
|
|
8761
|
+
function hasCurrentAgreement(user) {
|
|
8762
|
+
const agreement = user?.agreement;
|
|
8763
|
+
return agreement?.termsVersion === CURRENT_AGREEMENT.termsVersion && agreement?.communityRulesVersion === CURRENT_AGREEMENT.communityRulesVersion && !!agreement?.acceptedAt;
|
|
8764
|
+
}
|
|
8765
|
+
var TERMS_VERSION = "2026-07-15", COMMUNITY_RULES_VERSION = "2026-05-11.1", CURRENT_AGREEMENT;
|
|
8766
|
+
var init_agreement = __esm(() => {
|
|
8767
|
+
CURRENT_AGREEMENT = Object.freeze({
|
|
8768
|
+
termsVersion: TERMS_VERSION,
|
|
8769
|
+
communityRulesVersion: COMMUNITY_RULES_VERSION
|
|
8770
|
+
});
|
|
8771
|
+
});
|
|
8772
|
+
|
|
8780
8773
|
// ../../core/utils/time.js
|
|
8781
8774
|
function timestampMs(value, fallback = null, options = {}) {
|
|
8782
8775
|
let ms = null;
|
|
@@ -32453,9 +32446,9 @@ function stopped(signal) {
|
|
|
32453
32446
|
}
|
|
32454
32447
|
async function listenAccount(client, options = {}) {
|
|
32455
32448
|
const messageSource = nextListenerSource();
|
|
32456
|
-
const compact2 = options.compact
|
|
32457
|
-
const incomingOnly = options.incomingOnly
|
|
32458
|
-
const transientChats = options.
|
|
32449
|
+
const compact2 = options.compact !== false;
|
|
32450
|
+
const incomingOnly = options.incomingOnly !== false;
|
|
32451
|
+
const transientChats = options.persistentChats !== true;
|
|
32459
32452
|
const chatCount = cleanCount(options.chatCount || options.chats, DEFAULT_CHAT_COUNT, 500);
|
|
32460
32453
|
const messageCount = cleanCount(options.messageCount || options.messages, DEFAULT_MESSAGE_COUNT);
|
|
32461
32454
|
const replayMessageLimit = cleanCount(options.replayMessageLimit, DEFAULT_REPLAY_MESSAGE_LIMIT, DEFAULT_REPLAY_MESSAGE_LIMIT);
|
|
@@ -32614,7 +32607,7 @@ async function listenAccount(client, options = {}) {
|
|
|
32614
32607
|
}
|
|
32615
32608
|
page.release?.();
|
|
32616
32609
|
if (count >= replayMessageLimit) {
|
|
32617
|
-
throw new Error(`
|
|
32610
|
+
throw new Error(`listener replay checkpoint not found: ${chat.id}`);
|
|
32618
32611
|
}
|
|
32619
32612
|
count = Math.min(replayMessageLimit, count * 2);
|
|
32620
32613
|
}
|
|
@@ -41131,7 +41124,7 @@ var package_default;
|
|
|
41131
41124
|
var init_package = __esm(() => {
|
|
41132
41125
|
package_default = {
|
|
41133
41126
|
name: "veyl",
|
|
41134
|
-
version: "0.
|
|
41127
|
+
version: "0.58.0",
|
|
41135
41128
|
private: true,
|
|
41136
41129
|
license: "UNLICENSED",
|
|
41137
41130
|
workspaces: {
|
|
@@ -41248,15 +41241,13 @@ function cleanOptionalUsername(value) {
|
|
|
41248
41241
|
}
|
|
41249
41242
|
function agreementSummary(user) {
|
|
41250
41243
|
const agreement = user?.agreement || null;
|
|
41251
|
-
const acceptedAt = timestampMs(agreement?.acceptedAt);
|
|
41252
41244
|
return {
|
|
41253
|
-
|
|
41254
|
-
|
|
41255
|
-
|
|
41256
|
-
|
|
41257
|
-
|
|
41258
|
-
|
|
41259
|
-
currentAccepted: hasCurrentAgreement(user)
|
|
41245
|
+
links: {
|
|
41246
|
+
terms: links.terms,
|
|
41247
|
+
communityRules: links.communityRules
|
|
41248
|
+
},
|
|
41249
|
+
accepted: hasCurrentAgreement(user),
|
|
41250
|
+
acceptedAt: timestampMs(agreement?.acceptedAt)
|
|
41260
41251
|
};
|
|
41261
41252
|
}
|
|
41262
41253
|
function cleanTargetValue(value) {
|
|
@@ -41530,10 +41521,10 @@ class AccountRuntime {
|
|
|
41530
41521
|
uid: profile.uid,
|
|
41531
41522
|
username: profile.username,
|
|
41532
41523
|
profile: profile.profile,
|
|
41533
|
-
credentialId: profile.credentialId,
|
|
41534
41524
|
network: this.session?.network || profile.network || this.network,
|
|
41525
|
+
hasAccountKey: !!(profile.privateKeyPem || this.options.accountKey || this.options.credential?.privateKeyPem),
|
|
41535
41526
|
hasVault: profile.hasVault === true,
|
|
41536
|
-
|
|
41527
|
+
hasVaultKey: !!(profile.vaultSecret || this.options.vaultKey),
|
|
41537
41528
|
walletPK: profile.walletPK || null,
|
|
41538
41529
|
chatPK: profile.chatPK || null,
|
|
41539
41530
|
notificationPK: profile.notificationPK || null,
|
|
@@ -41559,7 +41550,6 @@ class AccountRuntime {
|
|
|
41559
41550
|
const username = cleanUsername3(options.username);
|
|
41560
41551
|
const profileName = this.store.profile || username;
|
|
41561
41552
|
const network = String(options.network || this.network).toUpperCase();
|
|
41562
|
-
const termsVersion = requireCurrentTermsVersion(options.termsVersion);
|
|
41563
41553
|
const machine = options.credential || this.options.credential || this.ports.createCredential();
|
|
41564
41554
|
const namespaceKeyPath = options.namespaceKeyPath || this.options.namespaceKeyPath;
|
|
41565
41555
|
const namespaceClaim = options.namespaceClaim || (namespaceKeyPath ? await this.ports.signNamespaceClaim({
|
|
@@ -41571,7 +41561,7 @@ class AccountRuntime {
|
|
|
41571
41561
|
const start = await this.callAccountEndpoint("/account/create/start", {
|
|
41572
41562
|
username,
|
|
41573
41563
|
publicKeyPem: machine.publicKeyPem,
|
|
41574
|
-
termsVersion,
|
|
41564
|
+
termsVersion: TERMS_VERSION,
|
|
41575
41565
|
...namespaceClaim ? { namespaceClaim } : {}
|
|
41576
41566
|
});
|
|
41577
41567
|
const finish = await this.callAccountEndpoint("/account/create/finish", {
|
|
@@ -41580,33 +41570,30 @@ class AccountRuntime {
|
|
|
41580
41570
|
});
|
|
41581
41571
|
await this.ports.signIn(this.auth, finish.token);
|
|
41582
41572
|
this.autoLogin = true;
|
|
41583
|
-
|
|
41573
|
+
await this.saveProfile({
|
|
41584
41574
|
profile: profileName,
|
|
41585
41575
|
username,
|
|
41586
41576
|
uid: finish.uid,
|
|
41587
41577
|
network,
|
|
41588
41578
|
credentialId: finish.credentialId || machine.credentialId,
|
|
41589
41579
|
publicKeyPem: machine.publicKeyPem,
|
|
41590
|
-
privateKeyPem: options.
|
|
41580
|
+
privateKeyPem: options.saveKey === false ? null : machine.privateKeyPem,
|
|
41591
41581
|
auth: "machine",
|
|
41592
41582
|
bot: finish.bot === BOT_PROFILE_MARKER ? BOT_PROFILE_MARKER : null,
|
|
41593
41583
|
createdAt: Date.now(),
|
|
41594
41584
|
hasVault: false
|
|
41595
41585
|
});
|
|
41596
|
-
return
|
|
41597
|
-
...this.accountSummary(profile),
|
|
41598
|
-
publicKeyPem: machine.publicKeyPem,
|
|
41599
|
-
privateKeyPem: machine.privateKeyPem
|
|
41600
|
-
};
|
|
41586
|
+
return machine.privateKeyPem;
|
|
41601
41587
|
}
|
|
41602
41588
|
async loginAccount(options = {}) {
|
|
41603
41589
|
const username = cleanOptionalUsername(options.username);
|
|
41604
41590
|
const profile = await this.loadProfile(this.store.profile || username);
|
|
41605
|
-
const
|
|
41606
|
-
const
|
|
41607
|
-
const
|
|
41591
|
+
const key = String(options.key || this.options.accountKey || this.ports.env?.VEYL_ACCOUNT_KEY || "").trim();
|
|
41592
|
+
const credential = options.credential || this.options.credential || (key ? this.ports.readCredential(key) : null);
|
|
41593
|
+
const credentialId = credential?.credentialId || profile.credentialId;
|
|
41594
|
+
const privateKeyPem = credential?.privateKeyPem || profile.privateKeyPem;
|
|
41608
41595
|
if (!credentialId || !privateKeyPem) {
|
|
41609
|
-
throw new Error("
|
|
41596
|
+
throw new Error("account key required");
|
|
41610
41597
|
}
|
|
41611
41598
|
const namespaceKeyPath = options.namespaceKeyPath || this.options.namespaceKeyPath;
|
|
41612
41599
|
const namespaceClaim = options.namespaceClaim || (namespaceKeyPath ? await this.ports.signNamespaceClaim({
|
|
@@ -41630,6 +41617,8 @@ class AccountRuntime {
|
|
|
41630
41617
|
uid: finish.uid || profile.uid,
|
|
41631
41618
|
username: finish.username || profile.username,
|
|
41632
41619
|
credentialId,
|
|
41620
|
+
publicKeyPem: credential?.publicKeyPem || profile.publicKeyPem,
|
|
41621
|
+
privateKeyPem: options.saveKey === false ? profile.privateKeyPem || null : privateKeyPem,
|
|
41633
41622
|
bot: finish.bot === BOT_PROFILE_MARKER ? BOT_PROFILE_MARKER : null,
|
|
41634
41623
|
lastLoginAt: Date.now()
|
|
41635
41624
|
});
|
|
@@ -41653,38 +41642,32 @@ class AccountRuntime {
|
|
|
41653
41642
|
const username = cleanUsername3(options.username);
|
|
41654
41643
|
const profileName = this.store.profile || username;
|
|
41655
41644
|
const network = String(options.network || this.network).toUpperCase();
|
|
41656
|
-
const termsVersion = requireCurrentTermsVersion(options.termsVersion);
|
|
41657
41645
|
const flow = await this.ports.runPasskeyFlow({
|
|
41658
41646
|
mode: "create",
|
|
41659
41647
|
label: options.label || username,
|
|
41660
41648
|
webUrl: options.webUrl,
|
|
41661
41649
|
timeoutMs: options.timeoutMs,
|
|
41662
41650
|
onUrl: options.onPasskeyUrl,
|
|
41663
|
-
termsVersion
|
|
41651
|
+
termsVersion: TERMS_VERSION
|
|
41664
41652
|
});
|
|
41665
41653
|
const user = await this.ports.signIn(this.auth, flow.token);
|
|
41666
41654
|
this.autoLogin = true;
|
|
41667
41655
|
await this.accountOwner.profile.setUsername(username);
|
|
41668
41656
|
const machine = options.credential || this.ports.createCredential();
|
|
41669
41657
|
const credential = machine ? await this.addMachineCredential(machine) : null;
|
|
41670
|
-
|
|
41658
|
+
await this.saveProfile({
|
|
41671
41659
|
profile: profileName,
|
|
41672
41660
|
username,
|
|
41673
41661
|
uid: user.uid,
|
|
41674
41662
|
network,
|
|
41675
41663
|
credentialId: credential?.credentialId || machine?.credentialId || null,
|
|
41676
41664
|
publicKeyPem: machine?.publicKeyPem || null,
|
|
41677
|
-
privateKeyPem: options.
|
|
41665
|
+
privateKeyPem: options.saveKey === false ? null : machine?.privateKeyPem || null,
|
|
41678
41666
|
auth: "passkey",
|
|
41679
41667
|
createdAt: Date.now(),
|
|
41680
41668
|
hasVault: false
|
|
41681
41669
|
});
|
|
41682
|
-
return
|
|
41683
|
-
...this.accountSummary(profile),
|
|
41684
|
-
passkey: true,
|
|
41685
|
-
publicKeyPem: machine?.publicKeyPem || null,
|
|
41686
|
-
privateKeyPem: machine?.privateKeyPem || null
|
|
41687
|
-
};
|
|
41670
|
+
return machine.privateKeyPem;
|
|
41688
41671
|
}
|
|
41689
41672
|
async loginPasskeyAccount(options = {}) {
|
|
41690
41673
|
const requested = cleanOptionalUsername(options.username);
|
|
@@ -41700,7 +41683,7 @@ class AccountRuntime {
|
|
|
41700
41683
|
this.autoLogin = true;
|
|
41701
41684
|
const username = await this.readUsername(user.uid, stored?.username || requested);
|
|
41702
41685
|
const hasSavedCredential = !!(stored?.credentialId && stored?.privateKeyPem);
|
|
41703
|
-
const machine = hasSavedCredential ? null : options.credential || this.ports.createCredential();
|
|
41686
|
+
const machine = hasSavedCredential ? null : options.credential || (options.saveKey === false ? null : this.ports.createCredential());
|
|
41704
41687
|
const credential = machine ? await this.addMachineCredential(machine) : null;
|
|
41705
41688
|
const profile = await this.saveProfile({
|
|
41706
41689
|
...stored || {},
|
|
@@ -41710,17 +41693,12 @@ class AccountRuntime {
|
|
|
41710
41693
|
network: String(stored?.network || options.network || this.network).toUpperCase(),
|
|
41711
41694
|
credentialId: credential?.credentialId || stored?.credentialId || machine?.credentialId || null,
|
|
41712
41695
|
publicKeyPem: machine?.publicKeyPem || stored?.publicKeyPem || null,
|
|
41713
|
-
privateKeyPem: options.
|
|
41696
|
+
privateKeyPem: options.saveKey === false ? stored?.privateKeyPem || null : machine?.privateKeyPem || stored?.privateKeyPem || null,
|
|
41714
41697
|
auth: "passkey",
|
|
41715
41698
|
bot: null,
|
|
41716
41699
|
lastLoginAt: Date.now()
|
|
41717
41700
|
});
|
|
41718
|
-
return
|
|
41719
|
-
...this.accountSummary(profile),
|
|
41720
|
-
passkey: true,
|
|
41721
|
-
publicKeyPem: machine?.publicKeyPem || null,
|
|
41722
|
-
privateKeyPem: machine?.privateKeyPem || null
|
|
41723
|
-
};
|
|
41701
|
+
return this.accountSummary(profile);
|
|
41724
41702
|
}
|
|
41725
41703
|
async me() {
|
|
41726
41704
|
const profile = await this.store.load();
|
|
@@ -41756,7 +41734,7 @@ class AccountRuntime {
|
|
|
41756
41734
|
throw new Error("account login required");
|
|
41757
41735
|
}
|
|
41758
41736
|
if (profile.auth === "passkey" && (!profile.credentialId || !profile.privateKeyPem)) {
|
|
41759
|
-
await this.loginPasskeyAccount({ username: profile.profile,
|
|
41737
|
+
await this.loginPasskeyAccount({ username: profile.profile, saveKey: false });
|
|
41760
41738
|
return this.profileData;
|
|
41761
41739
|
}
|
|
41762
41740
|
await this.loginAccount({
|
|
@@ -41783,7 +41761,6 @@ class AccountRuntime {
|
|
|
41783
41761
|
return agreementSummary(await this.readyAccountUser(options));
|
|
41784
41762
|
}
|
|
41785
41763
|
async acceptAccountTerms(options = {}) {
|
|
41786
|
-
requireCurrentTermsVersion(options.termsVersion);
|
|
41787
41764
|
const user = await this.readyAccountUser(options);
|
|
41788
41765
|
if (!hasCurrentAgreement(user)) {
|
|
41789
41766
|
await user.acceptAgreement();
|
|
@@ -41871,9 +41848,9 @@ class AccountRuntime {
|
|
|
41871
41848
|
if (await this.cloud.user.vault.exists(profile.uid)) {
|
|
41872
41849
|
throw new Error("vault already exists");
|
|
41873
41850
|
}
|
|
41874
|
-
const vaultSecret = String(options.
|
|
41851
|
+
const vaultSecret = String(options.key || this.options.vaultKey || this.ports.env?.VEYL_VAULT_KEY || this.ports.randomSecret()).trim();
|
|
41875
41852
|
if (!vaultSecret) {
|
|
41876
|
-
throw new Error("vault
|
|
41853
|
+
throw new Error("vault key required");
|
|
41877
41854
|
}
|
|
41878
41855
|
const encrypted = options.masterSeed ? await this.ports.vaultCrypto.encryptMasterSeed(options.masterSeed, vaultSecret, { registry: options.registry }) : await this.ports.vaultCrypto.encryptSeed(vaultSecret, { registry: options.registry });
|
|
41879
41856
|
const vault = packSeedData(encrypted);
|
|
@@ -41882,7 +41859,7 @@ class AccountRuntime {
|
|
|
41882
41859
|
const next = await this.saveProfile({
|
|
41883
41860
|
...profile,
|
|
41884
41861
|
hasVault: true,
|
|
41885
|
-
vaultSecret: options.
|
|
41862
|
+
vaultSecret: options.saveKey === false ? null : vaultSecret,
|
|
41886
41863
|
network: session.network,
|
|
41887
41864
|
walletPK: session.walletPK,
|
|
41888
41865
|
chatPK: session.chatPK,
|
|
@@ -41891,16 +41868,13 @@ class AccountRuntime {
|
|
|
41891
41868
|
});
|
|
41892
41869
|
this.session.account = this.accountSummary(next);
|
|
41893
41870
|
this.trackWalletIdentity(session);
|
|
41894
|
-
return
|
|
41895
|
-
...this.accountSummary(next),
|
|
41896
|
-
vaultSecret
|
|
41897
|
-
};
|
|
41871
|
+
return vaultSecret;
|
|
41898
41872
|
}
|
|
41899
41873
|
async exportWallet(options = {}) {
|
|
41900
41874
|
const profile = await this.ensureAuth();
|
|
41901
|
-
const vaultSecret = String(options.
|
|
41875
|
+
const vaultSecret = String(options.key || this.options.vaultKey || this.ports.env?.VEYL_VAULT_KEY || profile.vaultSecret || "").trim();
|
|
41902
41876
|
if (!vaultSecret) {
|
|
41903
|
-
throw new Error("vault
|
|
41877
|
+
throw new Error("vault key required");
|
|
41904
41878
|
}
|
|
41905
41879
|
const vault = await this.cloud.user.vault.read(profile.uid);
|
|
41906
41880
|
if (!vault) {
|
|
@@ -41916,9 +41890,9 @@ class AccountRuntime {
|
|
|
41916
41890
|
if (this.session) {
|
|
41917
41891
|
return this.accountSummary(profile);
|
|
41918
41892
|
}
|
|
41919
|
-
const vaultSecret = String(options.
|
|
41893
|
+
const vaultSecret = String(options.key || this.options.vaultKey || this.ports.env?.VEYL_VAULT_KEY || profile.vaultSecret || "").trim();
|
|
41920
41894
|
if (!vaultSecret) {
|
|
41921
|
-
throw new Error("vault
|
|
41895
|
+
throw new Error("vault key required");
|
|
41922
41896
|
}
|
|
41923
41897
|
const vault = await this.cloud.user.vault.read(profile.uid);
|
|
41924
41898
|
if (!vault) {
|
|
@@ -41928,7 +41902,7 @@ class AccountRuntime {
|
|
|
41928
41902
|
const next = await this.saveProfile({
|
|
41929
41903
|
...profile,
|
|
41930
41904
|
hasVault: true,
|
|
41931
|
-
vaultSecret: options.
|
|
41905
|
+
vaultSecret: options.saveKey === false ? profile.vaultSecret || null : profile.vaultSecret || vaultSecret,
|
|
41932
41906
|
network: session.network,
|
|
41933
41907
|
walletPK: session.walletPK || profile.walletPK || null,
|
|
41934
41908
|
chatPK: session.chatPK,
|
|
@@ -42163,7 +42137,7 @@ class AccountRuntime {
|
|
|
42163
42137
|
}
|
|
42164
42138
|
}
|
|
42165
42139
|
}
|
|
42166
|
-
var API_VERSION =
|
|
42140
|
+
var API_VERSION = 4, REQUIRED_FUNCTION_PORTS;
|
|
42167
42141
|
var init_client = __esm(() => {
|
|
42168
42142
|
init_values();
|
|
42169
42143
|
init_pack();
|
|
@@ -42174,6 +42148,7 @@ var init_client = __esm(() => {
|
|
|
42174
42148
|
init_username();
|
|
42175
42149
|
init_time();
|
|
42176
42150
|
init_vault();
|
|
42151
|
+
init_links();
|
|
42177
42152
|
init_account();
|
|
42178
42153
|
init_auth();
|
|
42179
42154
|
init_listen();
|
|
@@ -42184,6 +42159,7 @@ var init_client = __esm(() => {
|
|
|
42184
42159
|
"openLocalCache",
|
|
42185
42160
|
"runPasskeyFlow",
|
|
42186
42161
|
"createCredential",
|
|
42162
|
+
"readCredential",
|
|
42187
42163
|
"signChallenge",
|
|
42188
42164
|
"signNamespaceClaim",
|
|
42189
42165
|
"signIn",
|
|
@@ -177108,6 +177084,16 @@ function credentialIdForPublicKey(publicKeyPem) {
|
|
|
177108
177084
|
}
|
|
177109
177085
|
return createHash3("sha256").update(key).digest("base64url");
|
|
177110
177086
|
}
|
|
177087
|
+
function machineCredential(privateKey, publicKey) {
|
|
177088
|
+
const publicKeyPem = publicKey.export({ type: "spki", format: "pem" });
|
|
177089
|
+
const privateKeyPem = privateKey.export({ type: "pkcs8", format: "pem" });
|
|
177090
|
+
return {
|
|
177091
|
+
type: "ed25519",
|
|
177092
|
+
credentialId: credentialIdForPublicKey(publicKeyPem),
|
|
177093
|
+
publicKeyPem,
|
|
177094
|
+
privateKeyPem
|
|
177095
|
+
};
|
|
177096
|
+
}
|
|
177111
177097
|
function createMachineCredential(options2 = {}) {
|
|
177112
177098
|
let privateKey;
|
|
177113
177099
|
let publicKey;
|
|
@@ -177132,15 +177118,11 @@ function createMachineCredential(options2 = {}) {
|
|
|
177132
177118
|
} else {
|
|
177133
177119
|
({ privateKey, publicKey } = generateKeyPairSync("ed25519"));
|
|
177134
177120
|
}
|
|
177135
|
-
|
|
177136
|
-
|
|
177137
|
-
|
|
177138
|
-
|
|
177139
|
-
|
|
177140
|
-
credentialId,
|
|
177141
|
-
publicKeyPem,
|
|
177142
|
-
privateKeyPem
|
|
177143
|
-
};
|
|
177121
|
+
return machineCredential(privateKey, publicKey);
|
|
177122
|
+
}
|
|
177123
|
+
function readMachineCredential(key) {
|
|
177124
|
+
const privateKey = createPrivateKey(String(key ?? ""));
|
|
177125
|
+
return machineCredential(privateKey, createPublicKey(privateKey));
|
|
177144
177126
|
}
|
|
177145
177127
|
function signMachineChallenge(privateKeyPem, challenge2) {
|
|
177146
177128
|
const key = createPrivateKey(String(privateKeyPem ?? ""));
|
|
@@ -177650,6 +177632,7 @@ function createNodePorts(options2 = {}) {
|
|
|
177650
177632
|
})),
|
|
177651
177633
|
runPasskeyFlow: options2.runPasskeyFlow || runPasskeyBrowserFlow,
|
|
177652
177634
|
createCredential: options2.createCredential || createMachineCredential,
|
|
177635
|
+
readCredential: options2.readCredential || readMachineCredential,
|
|
177653
177636
|
signChallenge: options2.signChallenge || signMachineChallenge,
|
|
177654
177637
|
signNamespaceClaim: options2.signNamespaceClaim || signNamespaceClaim,
|
|
177655
177638
|
signIn: options2.signIn || signInRuntime,
|
|
@@ -177957,7 +177940,6 @@ class Fleet {
|
|
|
177957
177940
|
}) || (() => {});
|
|
177958
177941
|
const accountEventOptions = typeof this.eventOptions === "function" ? await this.eventOptions(profile) : this.eventOptions;
|
|
177959
177942
|
record.listenTask = record.client.listen({
|
|
177960
|
-
...DEFAULT_EVENT_OPTIONS,
|
|
177961
177943
|
...accountEventOptions || {},
|
|
177962
177944
|
signal: controller.signal,
|
|
177963
177945
|
onEvent: (event2) => {
|
|
@@ -178251,13 +178233,9 @@ class Fleet {
|
|
|
178251
178233
|
function createFleet(options2 = {}) {
|
|
178252
178234
|
return new Fleet(options2);
|
|
178253
178235
|
}
|
|
178254
|
-
var DEFAULT_BOOT_CONCURRENCY = 4, DEFAULT_EVENT_BACKLOG = 1000, DEFAULT_START_TIMEOUT_MS = 30000
|
|
178236
|
+
var DEFAULT_BOOT_CONCURRENCY = 4, DEFAULT_EVENT_BACKLOG = 1000, DEFAULT_START_TIMEOUT_MS = 30000;
|
|
178255
178237
|
var init_fleet = __esm(() => {
|
|
178256
178238
|
init_node();
|
|
178257
|
-
DEFAULT_EVENT_OPTIONS = Object.freeze({
|
|
178258
|
-
agent: true,
|
|
178259
|
-
replay: false
|
|
178260
|
-
});
|
|
178261
178239
|
});
|
|
178262
178240
|
|
|
178263
178241
|
// src/fleet-journal.js
|
|
@@ -179130,7 +179108,7 @@ class FleetOwner {
|
|
|
179130
179108
|
homeDir: this.homeDir,
|
|
179131
179109
|
activate: false,
|
|
179132
179110
|
credential: material.credential,
|
|
179133
|
-
|
|
179111
|
+
vaultKey: material.vaultSecret,
|
|
179134
179112
|
namespaceKeyPath: this.options.namespaceKeyPath,
|
|
179135
179113
|
getVaultMasterSeed: () => {
|
|
179136
179114
|
const derived = deriveFleetAccount(this.seed, accountIndex);
|
|
@@ -179264,7 +179242,6 @@ class FleetOwner {
|
|
|
179264
179242
|
throw new Error("stop the fleet owner before provisioning an account");
|
|
179265
179243
|
}
|
|
179266
179244
|
return this.withStoppedOwnerLock(async () => {
|
|
179267
|
-
requireCurrentTermsVersion(input.termsVersion);
|
|
179268
179245
|
const record = accountRecord(input, this.manifest.nextAccountIndex);
|
|
179269
179246
|
if (this.slot(record.profile)) {
|
|
179270
179247
|
throw new Error(`fleet profile exists: ${record.profile}`);
|
|
@@ -179273,30 +179250,23 @@ class FleetOwner {
|
|
|
179273
179250
|
throw new Error(`fleet username exists: ${record.username}`);
|
|
179274
179251
|
}
|
|
179275
179252
|
await this.saveProfiles([...this.manifest.profiles, record], record.accountIndex + 1);
|
|
179276
|
-
return this.finishProvision(record, {
|
|
179277
|
-
create: true,
|
|
179278
|
-
termsVersion: input.termsVersion
|
|
179279
|
-
});
|
|
179253
|
+
return this.finishProvision(record, { create: true });
|
|
179280
179254
|
});
|
|
179281
179255
|
});
|
|
179282
179256
|
}
|
|
179283
|
-
resume(profile
|
|
179257
|
+
resume(profile) {
|
|
179284
179258
|
return this.mutate(async () => {
|
|
179285
179259
|
if (this.fleet) {
|
|
179286
179260
|
throw new Error("stop the fleet owner before resuming provisioning");
|
|
179287
179261
|
}
|
|
179288
179262
|
return this.withStoppedOwnerLock(async () => {
|
|
179289
|
-
requireCurrentTermsVersion(options2.termsVersion);
|
|
179290
179263
|
const record = this.slot(profile);
|
|
179291
179264
|
if (!record)
|
|
179292
179265
|
throw new Error("fleet profile not found");
|
|
179293
179266
|
if (record.state !== "provisioning") {
|
|
179294
179267
|
throw new Error("fleet profile is already provisioned");
|
|
179295
179268
|
}
|
|
179296
|
-
return this.finishProvision(record, {
|
|
179297
|
-
create: false,
|
|
179298
|
-
termsVersion: options2.termsVersion
|
|
179299
|
-
});
|
|
179269
|
+
return this.finishProvision(record, { create: false });
|
|
179300
179270
|
});
|
|
179301
179271
|
});
|
|
179302
179272
|
}
|
|
@@ -179328,7 +179298,7 @@ class FleetOwner {
|
|
|
179328
179298
|
homeDir: this.homeDir,
|
|
179329
179299
|
activate: false,
|
|
179330
179300
|
credential: material.credential,
|
|
179331
|
-
|
|
179301
|
+
vaultKey: material.vaultSecret,
|
|
179332
179302
|
namespaceKeyPath: this.options.namespaceKeyPath,
|
|
179333
179303
|
namespaceKeyOptional: true
|
|
179334
179304
|
}, record);
|
|
@@ -179336,13 +179306,13 @@ class FleetOwner {
|
|
|
179336
179306
|
let account = await client2.account.me();
|
|
179337
179307
|
if (!account?.uid) {
|
|
179338
179308
|
if (options2.create) {
|
|
179339
|
-
|
|
179309
|
+
await client2.account.create({
|
|
179340
179310
|
username: record.username,
|
|
179341
179311
|
network: record.network,
|
|
179342
|
-
termsVersion: options2.termsVersion,
|
|
179343
179312
|
credential: material.credential,
|
|
179344
|
-
|
|
179313
|
+
saveKey: false
|
|
179345
179314
|
});
|
|
179315
|
+
account = await client2.account.me();
|
|
179346
179316
|
} else {
|
|
179347
179317
|
try {
|
|
179348
179318
|
account = await client2.account.login({
|
|
@@ -179351,13 +179321,13 @@ class FleetOwner {
|
|
|
179351
179321
|
} catch (error) {
|
|
179352
179322
|
if (error?.code !== "not-found")
|
|
179353
179323
|
throw error;
|
|
179354
|
-
|
|
179324
|
+
await client2.account.create({
|
|
179355
179325
|
username: record.username,
|
|
179356
179326
|
network: record.network,
|
|
179357
|
-
termsVersion: options2.termsVersion,
|
|
179358
179327
|
credential: material.credential,
|
|
179359
|
-
|
|
179328
|
+
saveKey: false
|
|
179360
179329
|
});
|
|
179330
|
+
account = await client2.account.me();
|
|
179361
179331
|
}
|
|
179362
179332
|
}
|
|
179363
179333
|
} else {
|
|
@@ -179366,12 +179336,13 @@ class FleetOwner {
|
|
|
179366
179336
|
});
|
|
179367
179337
|
}
|
|
179368
179338
|
if (account.hasVault !== true) {
|
|
179369
|
-
|
|
179370
|
-
|
|
179339
|
+
await client2.vault.create({
|
|
179340
|
+
key: material.vaultSecret,
|
|
179371
179341
|
masterSeed: material.masterSeed,
|
|
179372
179342
|
registry: material.registry,
|
|
179373
|
-
|
|
179343
|
+
saveKey: false
|
|
179374
179344
|
});
|
|
179345
|
+
account = await client2.account.me();
|
|
179375
179346
|
} else {
|
|
179376
179347
|
await client2.ensureUnlocked();
|
|
179377
179348
|
account = await client2.account.me();
|
|
@@ -179416,7 +179387,6 @@ async function openFleetOwner(options2 = {}) {
|
|
|
179416
179387
|
});
|
|
179417
179388
|
}
|
|
179418
179389
|
var init_fleet_owner = __esm(() => {
|
|
179419
|
-
init_agreement();
|
|
179420
179390
|
init_username();
|
|
179421
179391
|
init_node();
|
|
179422
179392
|
init_fleet_manifest();
|
|
@@ -179673,7 +179643,6 @@ __export(exports_src, {
|
|
|
179673
179643
|
cleanProfileName: () => cleanProfileName,
|
|
179674
179644
|
callFleetControl: () => callFleetControl,
|
|
179675
179645
|
VERSION: () => VERSION,
|
|
179676
|
-
TERMS_VERSION: () => TERMS_VERSION,
|
|
179677
179646
|
SdkError: () => SdkError,
|
|
179678
179647
|
ProfileStore: () => ProfileStore,
|
|
179679
179648
|
OPERATION_OUTCOME_UNKNOWN_CODE: () => OPERATION_OUTCOME_UNKNOWN_CODE,
|
|
@@ -179690,7 +179659,6 @@ __export(exports_src, {
|
|
|
179690
179659
|
API_VERSION: () => API_VERSION
|
|
179691
179660
|
});
|
|
179692
179661
|
var init_src = __esm(() => {
|
|
179693
|
-
init_agreement();
|
|
179694
179662
|
init_account();
|
|
179695
179663
|
init_auth();
|
|
179696
179664
|
init_client();
|
|
@@ -179737,7 +179705,6 @@ export {
|
|
|
179737
179705
|
cleanProfileName,
|
|
179738
179706
|
callFleetControl,
|
|
179739
179707
|
VERSION,
|
|
179740
|
-
TERMS_VERSION,
|
|
179741
179708
|
SdkError,
|
|
179742
179709
|
ProfileStore,
|
|
179743
179710
|
OPERATION_OUTCOME_UNKNOWN_CODE,
|
package/docs/agents.md
CHANGED
|
@@ -6,19 +6,21 @@ The SDK is not a privileged backend. It authenticates, decrypts the vault, signs
|
|
|
6
6
|
|
|
7
7
|
## Setup
|
|
8
8
|
|
|
9
|
+
Creating an account accepts Veyl's [Terms](https://veyl.glyphteck.com/legal#terms) and [Community Rules](https://veyl.glyphteck.com/community-rules).
|
|
10
|
+
|
|
9
11
|
```js
|
|
10
|
-
import { open
|
|
12
|
+
import { open } from '@glyphteck/veyl';
|
|
11
13
|
|
|
12
|
-
const veyl = await open({
|
|
13
|
-
await veyl.account.create({
|
|
14
|
+
const veyl = await open({ network: 'REGTEST' });
|
|
15
|
+
const accountKey = await veyl.account.create({
|
|
14
16
|
username: 'runner',
|
|
15
|
-
termsVersion: TERMS_VERSION,
|
|
16
|
-
saveCredential: true,
|
|
17
17
|
});
|
|
18
|
-
await veyl.vault.create(
|
|
18
|
+
const vaultKey = await veyl.vault.create();
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
The
|
|
21
|
+
The first call returns the account key used to authenticate this machine. The second returns the vault key that unlocks the vault and every feature derived from it. The SDK saves both in the local profile by default; treat both returned values as secrets.
|
|
22
|
+
|
|
23
|
+
Use `REGTEST` for disposable automation.
|
|
22
24
|
|
|
23
25
|
For existing accounts:
|
|
24
26
|
|
|
@@ -35,7 +37,6 @@ Keep that client alive. Repeated cold CLI invocations re-run authentication, vau
|
|
|
35
37
|
const controller = new AbortController();
|
|
36
38
|
|
|
37
39
|
await veyl.listen({
|
|
38
|
-
agent: true,
|
|
39
40
|
replay: false,
|
|
40
41
|
signal: controller.signal,
|
|
41
42
|
async onEvent(event) {
|
|
@@ -51,7 +52,7 @@ await veyl.listen({
|
|
|
51
52
|
});
|
|
52
53
|
```
|
|
53
54
|
|
|
54
|
-
This is a live subscription to shared chat-list and transfer state, not a polling loop.
|
|
55
|
+
This is a live subscription to shared chat-list and transfer state, not a polling loop. By default it emits compact peer-authored events and opens a changed chat only long enough to process it, so hundreds of peers do not become hundreds of retained message listeners. Set `compact: false` or `incomingOnly: false` when complete payloads or self-authored messages are required. A long-lived fleet can opt into `persistentChats: true` with `persistentChatIdleMs` to keep active conversations mounted, mark peer messages read before policy effects, and release only idle conversations; the account-level chat-list subscription reopens them when new activity arrives. Each listener has independent replay/filter state. Slow callbacks should hand work to an application queue if they must preserve event throughput.
|
|
55
56
|
|
|
56
57
|
Compact message events include reusable `replyTo` and `reactTo` targets. Transaction events carry the same simplified transfer shape returned by wallet history.
|
|
57
58
|
|
|
@@ -70,7 +71,7 @@ unsubscribe();
|
|
|
70
71
|
|
|
71
72
|
The mounted route preserves its coherent transcript and retention lifecycle until leave. Account-wide `listen` remains the wakeup surface; entered chat is the focused conversation surface.
|
|
72
73
|
|
|
73
|
-
For multiple agent identities, run one local `openFleetOwner`. It derives every account's machine credential, vault
|
|
74
|
+
For multiple agent identities, run one local `openFleetOwner`. It derives every account's machine credential, vault key, and Veyl master seed from one versioned root and account index. It opens one normal public client per secret-free manifest profile, tags each event with its account, and runs host policies above those clients. It grants no admin access and bypasses no product owner.
|
|
74
75
|
|
|
75
76
|
```js
|
|
76
77
|
import { openFleetOwner } from '@glyphteck/veyl';
|
|
@@ -82,7 +83,7 @@ fleet.use(agentPolicy);
|
|
|
82
83
|
await fleet.start();
|
|
83
84
|
```
|
|
84
85
|
|
|
85
|
-
Back up the fleet root once. The manifest and local profiles contain public account metadata, not derived
|
|
86
|
+
Back up the fleet root once. The manifest and local profiles contain public account metadata, not derived account or vault keys. Account indexes are never reused.
|
|
86
87
|
|
|
87
88
|
## Error policy
|
|
88
89
|
|
|
@@ -109,7 +110,7 @@ Then issue commands from other processes through the owner-only local socket:
|
|
|
109
110
|
veyl --profile runner --session default wallet balance
|
|
110
111
|
veyl --profile runner --session default chat send @alice "hello"
|
|
111
112
|
veyl --profile runner --session default chat enter @alice
|
|
112
|
-
veyl --profile runner --session default session events
|
|
113
|
+
veyl --profile runner --session default session events
|
|
113
114
|
veyl --profile runner --session default session stop
|
|
114
115
|
```
|
|
115
116
|
|
|
@@ -119,7 +120,7 @@ An entered chat remains mounted in the foreground session if its output shell di
|
|
|
119
120
|
|
|
120
121
|
## Safety rules
|
|
121
122
|
|
|
122
|
-
- Treat `vault export`,
|
|
123
|
+
- Treat `vault export`, account keys, vault keys, passkey link URLs, invoices, and signed withdrawal material as sensitive.
|
|
123
124
|
- Never log a passkey link URL; it is a one-time account-access credential.
|
|
124
125
|
- Never call account deletion or withdrawal confirmation without explicit authority.
|
|
125
126
|
- Prefer `withdrawal.prepare` for review and `withdrawal.confirm` only after the amount, address, speed, and fees are accepted. Preserve the returned quote id and fee amount as one pair for confirmation; preparation may restructure Spark leaves even though it does not spend or broadcast.
|
|
@@ -133,15 +134,16 @@ An entered chat remains mounted in the foreground session if its output shell di
|
|
|
133
134
|
VEYL_HOME=/secure/veyl-home
|
|
134
135
|
VEYL_PROFILE=runner
|
|
135
136
|
VEYL_NETWORK=REGTEST
|
|
136
|
-
|
|
137
|
+
VEYL_ACCOUNT_KEY=...
|
|
138
|
+
VEYL_VAULT_KEY=...
|
|
137
139
|
VEYL_WEB_URL=https://veyl.glyphteck.com
|
|
138
140
|
```
|
|
139
141
|
|
|
140
142
|
Use an application secret manager and disable package persistence when appropriate:
|
|
141
143
|
|
|
142
144
|
```js
|
|
143
|
-
await veyl.account.create({
|
|
144
|
-
await veyl.vault.create({
|
|
145
|
+
await veyl.account.create({ saveKey: false, ... });
|
|
146
|
+
await veyl.vault.create({ saveKey: false, key });
|
|
145
147
|
```
|
|
146
148
|
|
|
147
149
|
## Surface boundaries
|