@glyphteck/veyl 0.67.0 → 0.69.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/account.js +5515 -2637
- package/dist/accountprofiles.js +124 -8
- package/dist/auth.js +3 -3
- package/dist/cli.js +13618 -5011
- package/dist/index.js +13609 -3945
- package/dist/kdf-worker-thread.js +174 -143
- package/docs/agents.md +11 -3
- package/docs/api.md +67 -9
- package/docs/cli.md +4 -4
- package/docs/validation.md +4 -4
- package/docs/vote-market.md +248 -0
- package/examples/bot-fleet/readme.md +1 -1
- package/examples/codex-agent/agent-instructions.js +19 -0
- package/examples/codex-agent/agent-state.js +357 -0
- package/examples/codex-agent/chat-whitelist.js +104 -0
- package/examples/codex-agent/codex-app-server.js +737 -0
- package/examples/codex-agent/codex-config.js +13 -0
- package/examples/codex-agent/codex-input.js +89 -0
- package/examples/codex-agent/connector.js +478 -0
- package/examples/codex-agent/index.js +140 -0
- package/examples/codex-agent/instance-lock.js +359 -0
- package/examples/codex-agent/readme.md +88 -0
- package/examples/codex-agent/veyl-channel.js +603 -0
- package/package.json +12 -1
- package/readme.md +1 -0
|
@@ -48,39 +48,7 @@ var __export = (target, all) => {
|
|
|
48
48
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
49
49
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
50
50
|
|
|
51
|
-
// ../../node_modules/.bun/@noble+hashes@2.
|
|
52
|
-
function fromBig(n, le = false) {
|
|
53
|
-
if (le)
|
|
54
|
-
return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
|
|
55
|
-
return { h: Number(n >> _32n & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
|
|
56
|
-
}
|
|
57
|
-
function split(lst, le = false) {
|
|
58
|
-
const len = lst.length;
|
|
59
|
-
let Ah = new Uint32Array(len);
|
|
60
|
-
let Al = new Uint32Array(len);
|
|
61
|
-
for (let i = 0;i < len; i++) {
|
|
62
|
-
const { h, l } = fromBig(lst[i], le);
|
|
63
|
-
[Ah[i], Al[i]] = [h, l];
|
|
64
|
-
}
|
|
65
|
-
return [Ah, Al];
|
|
66
|
-
}
|
|
67
|
-
function setU64FromNum(view, byteOffset, n, isLE) {
|
|
68
|
-
const h = fromNumH(n);
|
|
69
|
-
const l = fromNumL(n);
|
|
70
|
-
view.setUint32(byteOffset, isLE ? l : h, isLE);
|
|
71
|
-
view.setUint32(byteOffset + 4, isLE ? h : l, isLE);
|
|
72
|
-
}
|
|
73
|
-
function add(Ah, Al, Bh, Bl) {
|
|
74
|
-
const l = (Al >>> 0) + (Bl >>> 0);
|
|
75
|
-
return { h: Ah + Bh + (l / 2 ** 32 | 0) | 0, l: l | 0 };
|
|
76
|
-
}
|
|
77
|
-
var U32_MASK64, _32n, fromNumH = (n) => n / 2 ** 32 | 0, fromNumL = (n) => n >>> 0, shrSH = (h, _l, s) => h >>> s, shrSL = (h, l, s) => h << 32 - s | l >>> s, rotrSH = (h, l, s) => h >>> s | l << 32 - s, rotrSL = (h, l, s) => h << 32 - s | l >>> s, rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32, rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s, rotr32H = (_h, l) => l, rotr32L = (h, _l) => h, add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0), add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0, add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0), add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0, add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0), add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
|
|
78
|
-
var init__u64 = __esm(() => {
|
|
79
|
-
U32_MASK64 = /* @__PURE__ */ (() => BigInt(2 ** 32 - 1))();
|
|
80
|
-
_32n = /* @__PURE__ */ BigInt(32);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
// ../../node_modules/.bun/@noble+hashes@2.3.0/node_modules/@noble/hashes/utils.js
|
|
51
|
+
// ../../node_modules/.bun/@noble+hashes@2.4.0/node_modules/@noble/hashes/utils.js
|
|
84
52
|
function isBytes(a) {
|
|
85
53
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
86
54
|
}
|
|
@@ -198,7 +166,12 @@ function hexToBytes(hex) {
|
|
|
198
166
|
function utf8ToBytes(str) {
|
|
199
167
|
if (typeof str !== "string")
|
|
200
168
|
throw new TypeError("string expected");
|
|
201
|
-
|
|
169
|
+
const encoded = new TextEncoder().encode(str);
|
|
170
|
+
try {
|
|
171
|
+
return new Uint8Array(encoded);
|
|
172
|
+
} finally {
|
|
173
|
+
clean(encoded);
|
|
174
|
+
}
|
|
202
175
|
}
|
|
203
176
|
function kdfInputToBytes(data, errorTitle = "") {
|
|
204
177
|
if (typeof data === "string")
|
|
@@ -221,10 +194,10 @@ function concatBytes(...arrays) {
|
|
|
221
194
|
return res;
|
|
222
195
|
}
|
|
223
196
|
function checkOpts(defaults, opts, title = "opts") {
|
|
224
|
-
|
|
197
|
+
aopts(defaults, "defaults");
|
|
225
198
|
if (opts !== undefined)
|
|
226
|
-
|
|
227
|
-
const merged = Object.assign(defaults, opts);
|
|
199
|
+
aopts(opts, title);
|
|
200
|
+
const merged = Object.assign(Object.create(null), defaults, opts);
|
|
228
201
|
return merged;
|
|
229
202
|
}
|
|
230
203
|
function createHasher(hashCons, info = {}) {
|
|
@@ -252,6 +225,13 @@ function randomBytes(bytesLength = 32) {
|
|
|
252
225
|
var atitle = (title) => title ? `"${title}" ` : "", aobject = (value, label) => {
|
|
253
226
|
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
254
227
|
throw new TypeError((label === "object" ? "" : `"${label}" `) + "expected object, got type=" + typeof value);
|
|
228
|
+
}, aopts = (value, label) => {
|
|
229
|
+
aobject(value, label);
|
|
230
|
+
const proto = Object.getPrototypeOf(value);
|
|
231
|
+
if (proto !== Object.prototype && proto !== null)
|
|
232
|
+
throw new TypeError(`"${label}" expected plain object`);
|
|
233
|
+
if (Object.hasOwn(value, "__proto__"))
|
|
234
|
+
throw new TypeError(`"${label}.__proto__" is not allowed`);
|
|
255
235
|
}, isLE, swap8IfBE, swap32IfBE, hasHexBuiltin, hexes, oidNist = (suffix) => ({
|
|
256
236
|
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
|
|
257
237
|
});
|
|
@@ -263,7 +243,39 @@ var init_utils = __esm(() => {
|
|
|
263
243
|
hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
|
264
244
|
});
|
|
265
245
|
|
|
266
|
-
// ../../node_modules/.bun/@noble+hashes@2.
|
|
246
|
+
// ../../node_modules/.bun/@noble+hashes@2.4.0/node_modules/@noble/hashes/_u64.js
|
|
247
|
+
function fromBig(n, le = false) {
|
|
248
|
+
if (le)
|
|
249
|
+
return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
|
|
250
|
+
return { h: Number(n >> _32n & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
|
|
251
|
+
}
|
|
252
|
+
function split(lst, le = false) {
|
|
253
|
+
const len = lst.length;
|
|
254
|
+
let Ah = new Uint32Array(len);
|
|
255
|
+
let Al = new Uint32Array(len);
|
|
256
|
+
for (let i = 0;i < len; i++) {
|
|
257
|
+
const { h, l } = fromBig(lst[i], le);
|
|
258
|
+
[Ah[i], Al[i]] = [h, l];
|
|
259
|
+
}
|
|
260
|
+
return [Ah, Al];
|
|
261
|
+
}
|
|
262
|
+
function setU64FromNum(view, byteOffset, n, isLE2) {
|
|
263
|
+
const h = fromNumH(n);
|
|
264
|
+
const l = fromNumL(n);
|
|
265
|
+
view.setUint32(byteOffset, isLE2 ? l : h, isLE2);
|
|
266
|
+
view.setUint32(byteOffset + 4, isLE2 ? h : l, isLE2);
|
|
267
|
+
}
|
|
268
|
+
function add(Ah, Al, Bh, Bl) {
|
|
269
|
+
const l = (Al >>> 0) + (Bl >>> 0);
|
|
270
|
+
return { h: Ah + Bh + (l / 2 ** 32 | 0) | 0, l: l | 0 };
|
|
271
|
+
}
|
|
272
|
+
var U32_MASK64, _32n, fromNumH = (n) => n / 2 ** 32 | 0, fromNumL = (n) => n >>> 0, shrSH = (h, _l, s) => h >>> s, shrSL = (h, l, s) => h << 32 - s | l >>> s, rotrSH = (h, l, s) => h >>> s | l << 32 - s, rotrSL = (h, l, s) => h << 32 - s | l >>> s, rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32, rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s, rotr32H = (_h, l) => l, rotr32L = (h, _l) => h, add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0), add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0, add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0), add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0, add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0), add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
|
|
273
|
+
var init__u64 = __esm(() => {
|
|
274
|
+
U32_MASK64 = /* @__PURE__ */ (() => BigInt(2 ** 32 - 1))();
|
|
275
|
+
_32n = /* @__PURE__ */ BigInt(32);
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
// ../../node_modules/.bun/@noble+hashes@2.4.0/node_modules/@noble/hashes/_md.js
|
|
267
279
|
function Chi(a, b, c) {
|
|
268
280
|
return a & b ^ ~a & c;
|
|
269
281
|
}
|
|
@@ -402,10 +414,7 @@ var init__md = __esm(() => {
|
|
|
402
414
|
// src/runtime/kdf-worker-thread.js
|
|
403
415
|
import { parentPort } from "node:worker_threads";
|
|
404
416
|
|
|
405
|
-
// ../../node_modules/.bun/@noble+hashes@2.
|
|
406
|
-
init__u64();
|
|
407
|
-
|
|
408
|
-
// ../../node_modules/.bun/@noble+hashes@2.3.0/node_modules/@noble/hashes/_blake.js
|
|
417
|
+
// ../../node_modules/.bun/@noble+hashes@2.4.0/node_modules/@noble/hashes/_blake.js
|
|
409
418
|
var BSIGMA = /* @__PURE__ */ Uint8Array.from([
|
|
410
419
|
0,
|
|
411
420
|
1,
|
|
@@ -665,7 +674,7 @@ var BSIGMA = /* @__PURE__ */ Uint8Array.from([
|
|
|
665
674
|
9
|
|
666
675
|
]);
|
|
667
676
|
|
|
668
|
-
// ../../node_modules/.bun/@noble+hashes@2.
|
|
677
|
+
// ../../node_modules/.bun/@noble+hashes@2.4.0/node_modules/@noble/hashes/blake2.js
|
|
669
678
|
init__u64();
|
|
670
679
|
init_utils();
|
|
671
680
|
var B2B_IV = /* @__PURE__ */ Uint32Array.from([
|
|
@@ -1000,7 +1009,7 @@ class _BLAKE2b extends _BLAKE2 {
|
|
|
1000
1009
|
}
|
|
1001
1010
|
var blake2b = /* @__PURE__ */ createHasher((opts) => new _BLAKE2b(opts));
|
|
1002
1011
|
|
|
1003
|
-
// ../../node_modules/.bun/@noble+hashes@2.
|
|
1012
|
+
// ../../node_modules/.bun/@noble+hashes@2.4.0/node_modules/@noble/hashes/argon2.js
|
|
1004
1013
|
init_utils();
|
|
1005
1014
|
var AT = { Argon2d: 0, Argon2i: 1, Argon2id: 2 };
|
|
1006
1015
|
var ARGON2_SYNC_POINTS = 4;
|
|
@@ -1009,25 +1018,6 @@ var abytesOrZero = (buf, errorTitle = "") => {
|
|
|
1009
1018
|
return Uint8Array.of();
|
|
1010
1019
|
return kdfInputToBytes(buf, errorTitle);
|
|
1011
1020
|
};
|
|
1012
|
-
function mul(a, b) {
|
|
1013
|
-
const aL = a & 65535;
|
|
1014
|
-
const aH = a >>> 16;
|
|
1015
|
-
const bL = b & 65535;
|
|
1016
|
-
const bH = b >>> 16;
|
|
1017
|
-
const ll = Math.imul(aL, bL);
|
|
1018
|
-
const hl = Math.imul(aH, bL);
|
|
1019
|
-
const lh = Math.imul(aL, bH);
|
|
1020
|
-
const hh = Math.imul(aH, bH);
|
|
1021
|
-
const carry = (ll >>> 16) + (hl & 65535) + lh;
|
|
1022
|
-
const high = hh + (hl >>> 16) + (carry >>> 16) | 0;
|
|
1023
|
-
const low = carry << 16 | ll & 65535;
|
|
1024
|
-
return { h: high, l: low };
|
|
1025
|
-
}
|
|
1026
|
-
function mulHi(a, b) {
|
|
1027
|
-
const aL = a & 65535, aH = a >>> 16, bL = b & 65535, bH = b >>> 16;
|
|
1028
|
-
const carry = (Math.imul(aL, bL) >>> 16) + (Math.imul(aH, bL) & 65535) + Math.imul(aL, bH);
|
|
1029
|
-
return Math.imul(aH, bH) + (Math.imul(aH, bL) >>> 16) + (carry >>> 16) | 0;
|
|
1030
|
-
}
|
|
1031
1021
|
var A2_BUF = new Uint32Array(256);
|
|
1032
1022
|
function G(a, b, c, d) {
|
|
1033
1023
|
let Al = A2_BUF[2 * a], Ah = A2_BUF[2 * a + 1];
|
|
@@ -1036,41 +1026,41 @@ function G(a, b, c, d) {
|
|
|
1036
1026
|
let Dl = A2_BUF[2 * d], Dh = A2_BUF[2 * d + 1];
|
|
1037
1027
|
let ml = 0, mh = 0, rl = 0, xh = 0, xl = 0;
|
|
1038
1028
|
ml = Math.imul(Al, Bl);
|
|
1039
|
-
mh =
|
|
1029
|
+
mh = ((Al >>> 0) * (Bl >>> 0) - (ml >>> 0)) / 4294967296 + 0.5 | 0;
|
|
1040
1030
|
rl = (Al >>> 0) + (Bl >>> 0) + (ml << 1 >>> 0);
|
|
1041
1031
|
Ah = Ah + Bh + (mh << 1 | ml >>> 31) + (rl / 4294967296 | 0) | 0;
|
|
1042
1032
|
Al = rl | 0;
|
|
1043
1033
|
xh = Dh ^ Ah;
|
|
1044
1034
|
xl = Dl ^ Al;
|
|
1045
|
-
Dh =
|
|
1046
|
-
Dl =
|
|
1035
|
+
Dh = xl;
|
|
1036
|
+
Dl = xh;
|
|
1047
1037
|
ml = Math.imul(Cl, Dl);
|
|
1048
|
-
mh =
|
|
1038
|
+
mh = ((Cl >>> 0) * (Dl >>> 0) - (ml >>> 0)) / 4294967296 + 0.5 | 0;
|
|
1049
1039
|
rl = (Cl >>> 0) + (Dl >>> 0) + (ml << 1 >>> 0);
|
|
1050
1040
|
Ch = Ch + Dh + (mh << 1 | ml >>> 31) + (rl / 4294967296 | 0) | 0;
|
|
1051
1041
|
Cl = rl | 0;
|
|
1052
1042
|
xh = Bh ^ Ch;
|
|
1053
1043
|
xl = Bl ^ Cl;
|
|
1054
|
-
Bh =
|
|
1055
|
-
Bl =
|
|
1044
|
+
Bh = xh >>> 24 | xl << 8;
|
|
1045
|
+
Bl = xh << 8 | xl >>> 24;
|
|
1056
1046
|
ml = Math.imul(Al, Bl);
|
|
1057
|
-
mh =
|
|
1047
|
+
mh = ((Al >>> 0) * (Bl >>> 0) - (ml >>> 0)) / 4294967296 + 0.5 | 0;
|
|
1058
1048
|
rl = (Al >>> 0) + (Bl >>> 0) + (ml << 1 >>> 0);
|
|
1059
1049
|
Ah = Ah + Bh + (mh << 1 | ml >>> 31) + (rl / 4294967296 | 0) | 0;
|
|
1060
1050
|
Al = rl | 0;
|
|
1061
1051
|
xh = Dh ^ Ah;
|
|
1062
1052
|
xl = Dl ^ Al;
|
|
1063
|
-
Dh =
|
|
1064
|
-
Dl =
|
|
1053
|
+
Dh = xh >>> 16 | xl << 16;
|
|
1054
|
+
Dl = xh << 16 | xl >>> 16;
|
|
1065
1055
|
ml = Math.imul(Cl, Dl);
|
|
1066
|
-
mh =
|
|
1056
|
+
mh = ((Cl >>> 0) * (Dl >>> 0) - (ml >>> 0)) / 4294967296 + 0.5 | 0;
|
|
1067
1057
|
rl = (Cl >>> 0) + (Dl >>> 0) + (ml << 1 >>> 0);
|
|
1068
1058
|
Ch = Ch + Dh + (mh << 1 | ml >>> 31) + (rl / 4294967296 | 0) | 0;
|
|
1069
1059
|
Cl = rl | 0;
|
|
1070
1060
|
xh = Bh ^ Ch;
|
|
1071
1061
|
xl = Bl ^ Cl;
|
|
1072
|
-
Bh =
|
|
1073
|
-
Bl =
|
|
1062
|
+
Bh = xh << 1 | xl >>> 31;
|
|
1063
|
+
Bl = xh >>> 31 | xl << 1;
|
|
1074
1064
|
A2_BUF[2 * a] = Al, A2_BUF[2 * a + 1] = Ah;
|
|
1075
1065
|
A2_BUF[2 * b] = Bl, A2_BUF[2 * b + 1] = Bh;
|
|
1076
1066
|
A2_BUF[2 * c] = Cl, A2_BUF[2 * c + 1] = Ch;
|
|
@@ -1087,20 +1077,27 @@ function P(v00, v01, v02, v03, v04, v05, v06, v07, v08, v09, v10, v11, v12, v13,
|
|
|
1087
1077
|
G(v03, v04, v09, v14);
|
|
1088
1078
|
}
|
|
1089
1079
|
function block(x, xPos, yPos, outPos, needXor) {
|
|
1090
|
-
|
|
1091
|
-
|
|
1080
|
+
if (needXor) {
|
|
1081
|
+
for (let i = 0;i < 256; i++) {
|
|
1082
|
+
const r = x[xPos + i] ^ x[yPos + i];
|
|
1083
|
+
A2_BUF[i] = r;
|
|
1084
|
+
x[outPos + i] ^= r;
|
|
1085
|
+
}
|
|
1086
|
+
} else {
|
|
1087
|
+
for (let i = 0;i < 256; i++) {
|
|
1088
|
+
const r = x[xPos + i] ^ x[yPos + i];
|
|
1089
|
+
A2_BUF[i] = r;
|
|
1090
|
+
x[outPos + i] = r;
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1092
1093
|
for (let i = 0;i < 128; i += 16) {
|
|
1093
1094
|
P(i, i + 1, i + 2, i + 3, i + 4, i + 5, i + 6, i + 7, i + 8, i + 9, i + 10, i + 11, i + 12, i + 13, i + 14, i + 15);
|
|
1094
1095
|
}
|
|
1095
1096
|
for (let i = 0;i < 16; i += 2) {
|
|
1096
1097
|
P(i, i + 1, i + 16, i + 17, i + 32, i + 33, i + 48, i + 49, i + 64, i + 65, i + 80, i + 81, i + 96, i + 97, i + 112, i + 113);
|
|
1097
1098
|
}
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
x[outPos + i] ^= A2_BUF[i] ^ x[xPos + i] ^ x[yPos + i];
|
|
1101
|
-
else
|
|
1102
|
-
for (let i = 0;i < 256; i++)
|
|
1103
|
-
x[outPos + i] = A2_BUF[i] ^ x[xPos + i] ^ x[yPos + i];
|
|
1099
|
+
for (let i = 0;i < 256; i++)
|
|
1100
|
+
x[outPos + i] ^= A2_BUF[i];
|
|
1104
1101
|
clean(A2_BUF);
|
|
1105
1102
|
}
|
|
1106
1103
|
function Hp(A, dkLen) {
|
|
@@ -1139,19 +1136,28 @@ function indexAlpha(r, s, laneLen, segmentLen, index, randL, sameLane = false) {
|
|
|
1139
1136
|
else
|
|
1140
1137
|
area = laneLen - segmentLen + (index == 0 ? -1 : 0);
|
|
1141
1138
|
const startPos = r !== 0 && s !== ARGON2_SYNC_POINTS - 1 ? (s + 1) * segmentLen : 0;
|
|
1142
|
-
const
|
|
1139
|
+
const randLow = Math.imul(randL, randL);
|
|
1140
|
+
const randHigh = ((randL >>> 0) * (randL >>> 0) - (randLow >>> 0)) / 4294967296 + 0.5 | 0;
|
|
1141
|
+
const areaLow = Math.imul(area, randHigh);
|
|
1142
|
+
const areaHigh = ((area >>> 0) * (randHigh >>> 0) - (areaLow >>> 0)) / 4294967296 + 0.5 | 0;
|
|
1143
|
+
const rel = area - 1 - areaHigh;
|
|
1143
1144
|
return (startPos + rel) % laneLen;
|
|
1144
1145
|
}
|
|
1145
1146
|
var maxUint32 = Math.pow(2, 32);
|
|
1147
|
+
var ARGON2_DEFAULT_MEMORY = 1024 ** 2;
|
|
1148
|
+
var ARGON2_DEFAULT_MAXMEM = ARGON2_DEFAULT_MEMORY * 1024;
|
|
1146
1149
|
function isU32(num) {
|
|
1147
1150
|
return Number.isSafeInteger(num) && num >= 0 && num < maxUint32;
|
|
1148
1151
|
}
|
|
1149
|
-
function argon2Opts(opts) {
|
|
1152
|
+
function argon2Opts(opts = {}) {
|
|
1150
1153
|
opts = checkOpts({}, opts);
|
|
1151
1154
|
const merged = {
|
|
1155
|
+
t: 3,
|
|
1156
|
+
m: ARGON2_DEFAULT_MEMORY,
|
|
1157
|
+
p: 1,
|
|
1152
1158
|
version: 19,
|
|
1153
1159
|
dkLen: 32,
|
|
1154
|
-
maxmem:
|
|
1160
|
+
maxmem: ARGON2_DEFAULT_MAXMEM,
|
|
1155
1161
|
asyncTick: 10
|
|
1156
1162
|
};
|
|
1157
1163
|
for (let [k, v] of Object.entries(opts))
|
|
@@ -1175,63 +1181,89 @@ function argon2Opts(opts) {
|
|
|
1175
1181
|
throw new Error('"version" must be 0x10 or 0x13, got ' + version);
|
|
1176
1182
|
return merged;
|
|
1177
1183
|
}
|
|
1178
|
-
function
|
|
1179
|
-
|
|
1180
|
-
salt = kdfInputToBytes(salt, "salt");
|
|
1181
|
-
if (!isU32(password.length))
|
|
1182
|
-
throw new Error('"password" must be less of length 1..4Gb');
|
|
1183
|
-
if (!isU32(salt.length) || salt.length < 8)
|
|
1184
|
-
throw new Error('"salt" must be of length 8..4Gb');
|
|
1185
|
-
if (!Object.values(AT).includes(type))
|
|
1186
|
-
throw new Error('"type" was invalid');
|
|
1187
|
-
let { p, dkLen, m, t, version, key, personalization, maxmem, onProgress, asyncTick } = argon2Opts(opts);
|
|
1188
|
-
key = abytesOrZero(key, "key");
|
|
1189
|
-
personalization = abytesOrZero(personalization, "personalization");
|
|
1190
|
-
const h = blake2b.create();
|
|
1184
|
+
function argon2InitialHash(password, salt, type, opts) {
|
|
1185
|
+
const ownedInputs = [];
|
|
1191
1186
|
const BUF = new Uint32Array(1);
|
|
1192
1187
|
const BUF8 = u8(BUF);
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1188
|
+
let h;
|
|
1189
|
+
let H0;
|
|
1190
|
+
let succeeded = false;
|
|
1191
|
+
const rememberOwned = (input, bytes) => {
|
|
1192
|
+
if (typeof input === "string")
|
|
1193
|
+
ownedInputs.push(bytes);
|
|
1194
|
+
return bytes;
|
|
1195
|
+
};
|
|
1196
|
+
try {
|
|
1197
|
+
const passwordBytes = rememberOwned(password, kdfInputToBytes(password, "password"));
|
|
1198
|
+
const saltBytes = rememberOwned(salt, kdfInputToBytes(salt, "salt"));
|
|
1199
|
+
if (!isU32(passwordBytes.length))
|
|
1200
|
+
throw new Error('"password" must be less of length 1..4Gb');
|
|
1201
|
+
if (!isU32(saltBytes.length) || saltBytes.length < 8)
|
|
1202
|
+
throw new Error('"salt" must be of length 8..4Gb');
|
|
1203
|
+
if (!Object.values(AT).includes(type))
|
|
1204
|
+
throw new Error('"type" was invalid');
|
|
1205
|
+
let { p, dkLen, m, t, version, key, personalization, maxmem, onProgress, asyncTick } = argon2Opts(opts);
|
|
1206
|
+
const keyInput = key;
|
|
1207
|
+
key = rememberOwned(keyInput, abytesOrZero(keyInput, "key"));
|
|
1208
|
+
const personalizationInput = personalization;
|
|
1209
|
+
personalization = rememberOwned(personalizationInput, abytesOrZero(personalizationInput, "personalization"));
|
|
1210
|
+
h = blake2b.create();
|
|
1211
|
+
for (let item of [p, dkLen, m, t, version, type]) {
|
|
1212
|
+
BUF[0] = swap8IfBE(item);
|
|
1213
|
+
h.update(BUF8);
|
|
1214
|
+
}
|
|
1215
|
+
for (let i of [passwordBytes, saltBytes, key, personalization]) {
|
|
1216
|
+
BUF[0] = swap8IfBE(i.length);
|
|
1217
|
+
h.update(BUF8).update(i);
|
|
1218
|
+
}
|
|
1219
|
+
H0 = new Uint32Array(18);
|
|
1220
|
+
h.digestInto(u8(H0));
|
|
1221
|
+
succeeded = true;
|
|
1222
|
+
return { H0, p, dkLen, m, t, version, maxmem, onProgress, asyncTick };
|
|
1223
|
+
} finally {
|
|
1224
|
+
if (h)
|
|
1225
|
+
h.destroy();
|
|
1226
|
+
clean(BUF, ...ownedInputs);
|
|
1227
|
+
if (!succeeded && H0)
|
|
1228
|
+
clean(H0);
|
|
1221
1229
|
}
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1230
|
+
}
|
|
1231
|
+
function argon2Init(password, salt, type, opts) {
|
|
1232
|
+
const { H0, p, dkLen, m, t, version, maxmem, onProgress, asyncTick } = argon2InitialHash(password, salt, type, opts);
|
|
1233
|
+
try {
|
|
1234
|
+
const lanes = p;
|
|
1235
|
+
const mP = 4 * p * Math.floor(m / (ARGON2_SYNC_POINTS * p));
|
|
1236
|
+
const laneLen = Math.floor(mP / p);
|
|
1237
|
+
const segmentLen = Math.floor(laneLen / ARGON2_SYNC_POINTS);
|
|
1238
|
+
const memUsed = mP * 1024;
|
|
1239
|
+
if (!isU32(maxmem))
|
|
1240
|
+
throw new Error('"maxmem" expected <2**32, got ' + maxmem);
|
|
1241
|
+
if (memUsed > maxmem)
|
|
1242
|
+
throw new Error('"maxmem" limit was hit: memUsed(mP*1024)=' + memUsed + ", maxmem=" + maxmem);
|
|
1243
|
+
const B = new Uint32Array(memUsed / 4);
|
|
1244
|
+
for (let l = 0;l < p; l++) {
|
|
1245
|
+
const i = 256 * laneLen * l;
|
|
1246
|
+
H0[17] = swap8IfBE(l);
|
|
1247
|
+
H0[16] = swap8IfBE(0);
|
|
1248
|
+
B.set(swap32IfBE(u32(Hp(H0, 1024))), i);
|
|
1249
|
+
H0[16] = swap8IfBE(1);
|
|
1250
|
+
B.set(swap32IfBE(u32(Hp(H0, 1024))), i + 256);
|
|
1251
|
+
}
|
|
1252
|
+
let perBlock = () => {};
|
|
1253
|
+
if (onProgress) {
|
|
1254
|
+
const totalBlock = t * ARGON2_SYNC_POINTS * p * segmentLen - 2 * p;
|
|
1255
|
+
const callbackPer = Math.max(Math.floor(totalBlock / 1e4), 1);
|
|
1256
|
+
let blockCnt = 0;
|
|
1257
|
+
perBlock = () => {
|
|
1258
|
+
blockCnt++;
|
|
1259
|
+
if (onProgress && (!(blockCnt % callbackPer) || blockCnt === totalBlock))
|
|
1260
|
+
onProgress(blockCnt / totalBlock);
|
|
1261
|
+
};
|
|
1262
|
+
}
|
|
1263
|
+
return { type, mP, p, t, version, B, laneLen, lanes, segmentLen, dkLen, perBlock, asyncTick };
|
|
1264
|
+
} finally {
|
|
1265
|
+
clean(H0);
|
|
1232
1266
|
}
|
|
1233
|
-
clean(BUF, H0);
|
|
1234
|
-
return { type, mP, p, t, version, B, laneLen, lanes, segmentLen, dkLen, perBlock, asyncTick };
|
|
1235
1267
|
}
|
|
1236
1268
|
function argon2Output(B, p, laneLen, dkLen) {
|
|
1237
1269
|
const B_final = new Uint32Array(256);
|
|
@@ -1242,9 +1274,8 @@ function argon2Output(B, p, laneLen, dkLen) {
|
|
|
1242
1274
|
clean(B, B_final);
|
|
1243
1275
|
return res;
|
|
1244
1276
|
}
|
|
1245
|
-
function* argon2Blocks(ctx) {
|
|
1277
|
+
function* argon2Blocks(ctx, address) {
|
|
1246
1278
|
const { type, mP, p, t, version, B, laneLen, lanes, segmentLen, perBlock } = ctx;
|
|
1247
|
-
const address = new Uint32Array(3 * 256);
|
|
1248
1279
|
address[256 + 6] = mP;
|
|
1249
1280
|
address[256 + 8] = t;
|
|
1250
1281
|
address[256 + 10] = type;
|
|
@@ -1298,11 +1329,11 @@ function* argon2Blocks(ctx) {
|
|
|
1298
1329
|
}
|
|
1299
1330
|
function argon2(type, password, salt, opts) {
|
|
1300
1331
|
const ctx = argon2Init(password, salt, type, opts);
|
|
1301
|
-
const blocks = argon2Blocks(ctx);
|
|
1332
|
+
const blocks = argon2Blocks(ctx, new Uint32Array(3 * 256));
|
|
1302
1333
|
while (!blocks.next().done) {}
|
|
1303
1334
|
return argon2Output(ctx.B, ctx.p, ctx.laneLen, ctx.dkLen);
|
|
1304
1335
|
}
|
|
1305
|
-
var argon2id = (password, salt, opts) => argon2(AT.Argon2id, password, salt, opts);
|
|
1336
|
+
var argon2id = (password, salt, opts = {}) => argon2(AT.Argon2id, password, salt, opts);
|
|
1306
1337
|
|
|
1307
1338
|
// src/runtime/kdf-worker-thread.js
|
|
1308
1339
|
if (!parentPort)
|
package/docs/agents.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Use the JavaScript API for a long-running agent and the canonical CLI for one-off shell work. A local read-only MCP resource server can help an MCP-capable host discover the installed SDK documentation, but it cannot operate Veyl.
|
|
4
4
|
|
|
5
|
-
The SDK is not a privileged backend. It authenticates, decrypts the vault, signs wallet operations, encrypts/signs chat actions, and maintains encrypted local cache state exactly like web and iOS.
|
|
5
|
+
The SDK is not a privileged backend. It authenticates, decrypts the vault, signs wallet operations, encrypts/signs chat actions, and maintains encrypted local cache state exactly like web and iOS. A public profile is `sdk` while it is machine-only and becomes `app` if a passkey is linked. That describes its available client surface, not whether a person or agent operates it.
|
|
6
6
|
|
|
7
7
|
## Setup
|
|
8
8
|
|
|
@@ -31,6 +31,8 @@ await veyl.vault.unlock();
|
|
|
31
31
|
|
|
32
32
|
Keep that client alive. Repeated cold CLI invocations re-run authentication, vault decrypt, shared owner startup, and Spark wallet boot.
|
|
33
33
|
|
|
34
|
+
For a complete single-account Codex connector that reuses ChatGPT authentication, pins one owner, exposes the same unlocked client through the CLI, and projects live/writing state, see the [Codex agent example](../examples/codex-agent/readme.md). Its Veyl channel and connector are deliberately separate from the Codex app-server driver so another harness can replace only the harness seam.
|
|
35
|
+
|
|
34
36
|
## Event loop
|
|
35
37
|
|
|
36
38
|
```js
|
|
@@ -40,6 +42,10 @@ await veyl.listen({
|
|
|
40
42
|
replay: false,
|
|
41
43
|
signal: controller.signal,
|
|
42
44
|
async onEvent(event) {
|
|
45
|
+
if (event.type === 'message-request') {
|
|
46
|
+
await veyl.chat.resolveRequest(event.chat.id, 'accept');
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
43
49
|
if (event.type !== 'message') return;
|
|
44
50
|
if (event.message.type === 'txt') {
|
|
45
51
|
await veyl.chat.reactTo(event, '+1');
|
|
@@ -54,7 +60,9 @@ await veyl.listen({
|
|
|
54
60
|
|
|
55
61
|
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 and release only idle conversations; the account-level chat-list subscription reopens them when new activity arrives. Set `relayReads: true` with `read: true` when the listener itself represents viewing: it briefly joins the ordinary encrypted live room, advances from the already-decrypted message before emitting the event, and coalesces durable receipt writes without a second message lookup. Each listener has independent replay/filter state. Slow callbacks should hand work to an application queue if they must preserve event throughput.
|
|
56
62
|
|
|
57
|
-
|
|
63
|
+
`message-request` is an authenticated initial direct message, not writable chat authority. Choose `chat.resolveRequest(chatId, 'accept')` or `'reject'` according to the agent's policy. Accepting promotes the exact pending Welcome into the ordinary chat; rejecting consumes it without creating a chat.
|
|
64
|
+
|
|
65
|
+
Compact message events include stable `chatId`, verified sender identity, member summaries, and reusable `replyTo` and `reactTo` targets. Every text event also includes authenticated `message.mentions` entries with half-open utf-16 offsets. A member entry carries its stable epoch `chatPK`; an everyone entry carries `kind: 'everyone'`. Do not recover mention identity by parsing `message.text`: its authored label intentionally survives profile rename or deletion. Transaction events carry the same simplified transfer shape returned by wallet history.
|
|
58
66
|
|
|
59
67
|
When an agent is actively working inside one conversation, mount its shared route instead of repeatedly taking one-shot reads:
|
|
60
68
|
|
|
@@ -93,7 +101,7 @@ Agents should correct normal validation errors from their messages. They should
|
|
|
93
101
|
- preserve `operationId`;
|
|
94
102
|
- do not blindly repeat a Spark send, request payment, external invoice payment, or withdrawal;
|
|
95
103
|
- reconcile public wallet history or application state first;
|
|
96
|
-
- retry Lightning only when `retryable === true`, using the exact same `
|
|
104
|
+
- retry Lightning only when `retryable === true`, using `operationId` as the exact same `transferId`.
|
|
97
105
|
|
|
98
106
|
This is intentionally a small contract for the one class of error where automatic self-correction can lose money. Veyl does not maintain a large error taxonomy for ordinary mistakes.
|
|
99
107
|
|