@zerox1/core 0.4.2

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.
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Protocol codec — identical wire format used by all mesh variants.
3
+ *
4
+ * Negotiation payload wire format:
5
+ * [16 bytes: LE signed 128-bit integer (amount_micro)] [N bytes: UTF-8 JSON body]
6
+ *
7
+ * Collaboration payloads (enterprise) use plain JSON — no binary prefix.
8
+ */
9
+ import type { ProposePayload, CounterPayload, AcceptPayload, DeliverPayload } from './types.js';
10
+ export declare function encodeProposePayload(message: string, amountMicro?: bigint, maxRounds?: number): Uint8Array;
11
+ export declare function decodeProposePayload(payloadB64: string): ProposePayload | null;
12
+ export declare function encodeCounterPayload(amountMicro: bigint, round: number, maxRounds: number, message?: string): Uint8Array;
13
+ export declare function decodeCounterPayload(payloadB64: string): CounterPayload | null;
14
+ export declare function encodeAcceptPayload(amountMicro: bigint, message?: string): Uint8Array;
15
+ export declare function decodeAcceptPayload(payloadB64: string): AcceptPayload | null;
16
+ export declare function encodeFeedbackPayload(score: number, outcome: 'positive' | 'neutral' | 'negative', message?: string): Uint8Array;
17
+ /**
18
+ * Decode a DELIVER payload from an inbound envelope's payload_b64.
19
+ *
20
+ * ```ts
21
+ * agent.on('DELIVER', (env) => {
22
+ * const d = decodeDeliverPayload(env.payload_b64)
23
+ * if (!d) return
24
+ * console.log(`Delivered: ${d.summary}, fee: $${d.fee_usdc ?? 0}`)
25
+ * // Note: fee_usdc is in the payload — NOT on env.fee_usdc (that field doesn't exist)
26
+ * })
27
+ * ```
28
+ */
29
+ export declare function decodeDeliverPayload(payloadB64: string): DeliverPayload | null;
30
+ export declare function encodeJsonPayload(obj: unknown): Uint8Array;
31
+ export declare function decodeJsonPayload<T = unknown>(payloadB64: string): T | null;
32
+ export declare function newConversationId(): string;
33
+ export declare function bytesToBase64(bytes: Uint8Array): string;
34
+ export declare function base64ToBytes(b64: string): Uint8Array;
35
+ export declare function hexToBase64(hex: string): string;
36
+ export declare function base64ToHex(b64: string): string;
37
+ //# sourceMappingURL=codec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../src/codec.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAuB/F,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,WAAW,GAAE,MAAW,EACxB,SAAS,GAAE,MAAU,GACpB,UAAU,CAMZ;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAQ9E;AAED,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,MAAM,GACf,UAAU,CAQZ;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAQ9E;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CAQrF;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAQ5E;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,UAAU,GAAG,SAAS,GAAG,UAAU,EAC5C,OAAO,CAAC,EAAE,MAAM,GACf,UAAU,CAIZ;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAG9E;AAID,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,UAAU,CAE1D;AAED,wBAAgB,iBAAiB,CAAC,CAAC,GAAG,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CAG3E;AAID,wBAAgB,iBAAiB,IAAI,MAAM,CAG1C;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAEvD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAErD;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C"}
package/dist/codec.js ADDED
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ /**
3
+ * Protocol codec — identical wire format used by all mesh variants.
4
+ *
5
+ * Negotiation payload wire format:
6
+ * [16 bytes: LE signed 128-bit integer (amount_micro)] [N bytes: UTF-8 JSON body]
7
+ *
8
+ * Collaboration payloads (enterprise) use plain JSON — no binary prefix.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.encodeProposePayload = encodeProposePayload;
12
+ exports.decodeProposePayload = decodeProposePayload;
13
+ exports.encodeCounterPayload = encodeCounterPayload;
14
+ exports.decodeCounterPayload = decodeCounterPayload;
15
+ exports.encodeAcceptPayload = encodeAcceptPayload;
16
+ exports.decodeAcceptPayload = decodeAcceptPayload;
17
+ exports.encodeFeedbackPayload = encodeFeedbackPayload;
18
+ exports.decodeDeliverPayload = decodeDeliverPayload;
19
+ exports.encodeJsonPayload = encodeJsonPayload;
20
+ exports.decodeJsonPayload = decodeJsonPayload;
21
+ exports.newConversationId = newConversationId;
22
+ exports.bytesToBase64 = bytesToBase64;
23
+ exports.base64ToBytes = base64ToBytes;
24
+ exports.hexToBase64 = hexToBase64;
25
+ exports.base64ToHex = base64ToHex;
26
+ // ── Internal binary helpers ────────────────────────────────────────────────
27
+ function writeLEi128(buf, offset, value) {
28
+ let v = value < 0n ? (1n << 128n) + value : value;
29
+ for (let i = 0; i < 16; i++) {
30
+ buf[offset + i] = Number(v & 0xffn);
31
+ v >>= 8n;
32
+ }
33
+ }
34
+ function readLEi128(buf, offset) {
35
+ let value = 0n;
36
+ for (let i = 15; i >= 0; i--) {
37
+ value = (value << 8n) | BigInt(buf[offset + i]);
38
+ }
39
+ if (value >= (1n << 127n))
40
+ value -= 1n << 128n;
41
+ return value;
42
+ }
43
+ // ── Negotiation codec ──────────────────────────────────────────────────────
44
+ function encodeProposePayload(message, amountMicro = 0n, maxRounds = 2) {
45
+ const jsonBytes = Buffer.from(JSON.stringify({ max_rounds: maxRounds, message }), 'utf8');
46
+ const buf = new Uint8Array(16 + jsonBytes.length);
47
+ writeLEi128(buf, 0, amountMicro);
48
+ buf.set(jsonBytes, 16);
49
+ return buf;
50
+ }
51
+ function decodeProposePayload(payloadB64) {
52
+ try {
53
+ const bytes = Buffer.from(payloadB64, 'base64');
54
+ if (bytes.length < 16)
55
+ return null;
56
+ const amount_micro = readLEi128(bytes, 0);
57
+ const json = JSON.parse(bytes.slice(16).toString('utf8'));
58
+ return { message: json.message ?? '', amount_micro, max_rounds: json.max_rounds ?? 2 };
59
+ }
60
+ catch {
61
+ return null;
62
+ }
63
+ }
64
+ function encodeCounterPayload(amountMicro, round, maxRounds, message) {
65
+ const body = { round, max_rounds: maxRounds };
66
+ if (message)
67
+ body.message = message;
68
+ const jsonBytes = Buffer.from(JSON.stringify(body), 'utf8');
69
+ const buf = new Uint8Array(16 + jsonBytes.length);
70
+ writeLEi128(buf, 0, amountMicro);
71
+ buf.set(jsonBytes, 16);
72
+ return buf;
73
+ }
74
+ function decodeCounterPayload(payloadB64) {
75
+ try {
76
+ const bytes = Buffer.from(payloadB64, 'base64');
77
+ if (bytes.length < 16)
78
+ return null;
79
+ const amount_micro = readLEi128(bytes, 0);
80
+ const json = JSON.parse(bytes.slice(16).toString('utf8'));
81
+ return { amount_micro, round: json.round ?? 1, max_rounds: json.max_rounds ?? 2, message: json.message };
82
+ }
83
+ catch {
84
+ return null;
85
+ }
86
+ }
87
+ function encodeAcceptPayload(amountMicro, message) {
88
+ const body = {};
89
+ if (message)
90
+ body.message = message;
91
+ const jsonBytes = Buffer.from(JSON.stringify(body), 'utf8');
92
+ const buf = new Uint8Array(16 + jsonBytes.length);
93
+ writeLEi128(buf, 0, amountMicro);
94
+ buf.set(jsonBytes, 16);
95
+ return buf;
96
+ }
97
+ function decodeAcceptPayload(payloadB64) {
98
+ try {
99
+ const bytes = Buffer.from(payloadB64, 'base64');
100
+ if (bytes.length < 16)
101
+ return null;
102
+ const amount_micro = readLEi128(bytes, 0);
103
+ const json = JSON.parse(bytes.slice(16).toString('utf8'));
104
+ return { amount_micro, message: json.message };
105
+ }
106
+ catch {
107
+ return null;
108
+ }
109
+ }
110
+ function encodeFeedbackPayload(score, outcome, message) {
111
+ const body = { score, outcome };
112
+ if (message)
113
+ body.message = message;
114
+ return Buffer.from(JSON.stringify(body), 'utf8');
115
+ }
116
+ /**
117
+ * Decode a DELIVER payload from an inbound envelope's payload_b64.
118
+ *
119
+ * ```ts
120
+ * agent.on('DELIVER', (env) => {
121
+ * const d = decodeDeliverPayload(env.payload_b64)
122
+ * if (!d) return
123
+ * console.log(`Delivered: ${d.summary}, fee: $${d.fee_usdc ?? 0}`)
124
+ * // Note: fee_usdc is in the payload — NOT on env.fee_usdc (that field doesn't exist)
125
+ * })
126
+ * ```
127
+ */
128
+ function decodeDeliverPayload(payloadB64) {
129
+ try {
130
+ return JSON.parse(Buffer.from(payloadB64, 'base64').toString('utf8'));
131
+ }
132
+ catch {
133
+ return null;
134
+ }
135
+ }
136
+ // ── JSON payload helpers ───────────────────────────────────────────────────
137
+ function encodeJsonPayload(obj) {
138
+ return Buffer.from(JSON.stringify(obj), 'utf8');
139
+ }
140
+ function decodeJsonPayload(payloadB64) {
141
+ try {
142
+ return JSON.parse(Buffer.from(payloadB64, 'base64').toString('utf8'));
143
+ }
144
+ catch {
145
+ return null;
146
+ }
147
+ }
148
+ // ── Utilities ──────────────────────────────────────────────────────────────
149
+ function newConversationId() {
150
+ const { randomBytes } = require('crypto');
151
+ return randomBytes(16).toString('hex');
152
+ }
153
+ function bytesToBase64(bytes) {
154
+ return Buffer.from(bytes).toString('base64');
155
+ }
156
+ function base64ToBytes(b64) {
157
+ return Buffer.from(b64, 'base64');
158
+ }
159
+ function hexToBase64(hex) {
160
+ return Buffer.from(hex, 'hex').toString('base64');
161
+ }
162
+ function base64ToHex(b64) {
163
+ return Buffer.from(b64, 'base64').toString('hex');
164
+ }
165
+ //# sourceMappingURL=codec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codec.js","sourceRoot":"","sources":["../src/codec.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AAyBH,oDAUC;AAED,oDAQC;AAED,oDAaC;AAED,oDAQC;AAED,kDAQC;AAED,kDAQC;AAED,sDAQC;AAcD,oDAGC;AAID,8CAEC;AAED,8CAGC;AAID,8CAGC;AAED,sCAEC;AAED,sCAEC;AAED,kCAEC;AAED,kCAEC;AAnJD,8EAA8E;AAE9E,SAAS,WAAW,CAAC,GAAe,EAAE,MAAc,EAAE,KAAa;IACjE,IAAI,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAA;IACjD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,CAAA;QACnC,CAAC,KAAK,EAAE,CAAA;IACV,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,GAAe,EAAE,MAAc;IACjD,IAAI,KAAK,GAAG,EAAE,CAAA;IACd,KAAK,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7B,KAAK,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,G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,CAAC;AAED,SAAgB,WAAW,CAAC,GAAW;IACrC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AACnD,CAAC;AAED,SAAgB,WAAW,CAAC,GAAW;IACrC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AACnD,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Ed25519 keypair generation and signing — wraps @noble/ed25519.
3
+ *
4
+ * Agent identity on the 0x01 mesh is a 32-byte Ed25519 public key,
5
+ * represented as a 64-char lowercase hex string (agent_id).
6
+ */
7
+ export interface Keypair {
8
+ /** 32-byte raw private key scalar */
9
+ privateKey: Uint8Array;
10
+ /** 32-byte Ed25519 public key (= agent_id bytes) */
11
+ publicKey: Uint8Array;
12
+ }
13
+ /** Generate a new random Ed25519 keypair. */
14
+ export declare function generateKeypair(): Promise<Keypair>;
15
+ /**
16
+ * Derive a keypair deterministically from a 32-byte seed.
17
+ * Useful for reproducible identities from a stored secret.
18
+ */
19
+ export declare function keypairFromSeed(seed: Uint8Array): Promise<Keypair>;
20
+ /** Sign a message with a private key. Returns a 64-byte signature. */
21
+ export declare function sign(message: Uint8Array, privateKey: Uint8Array): Promise<Uint8Array>;
22
+ /** Verify a signature against a message and public key. */
23
+ export declare function verify(signature: Uint8Array, message: Uint8Array, publicKey: Uint8Array): Promise<boolean>;
24
+ /** Convert a 32-byte public key to a 64-char lowercase hex agent_id. */
25
+ export declare function publicKeyToAgentId(publicKey: Uint8Array): string;
26
+ /** Parse a 64-char hex agent_id back to 32-byte public key bytes. */
27
+ export declare function agentIdToPublicKey(agentId: string): Uint8Array;
28
+ //# sourceMappingURL=crypto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,WAAW,OAAO;IACtB,qCAAqC;IACrC,UAAU,EAAE,UAAU,CAAA;IACtB,oDAAoD;IACpD,SAAS,EAAE,UAAU,CAAA;CACtB;AAED,6CAA6C;AAC7C,wBAAsB,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,CAIxD;AAED;;;GAGG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAIxE;AAED,sEAAsE;AACtE,wBAAsB,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAE3F;AAED,2DAA2D;AAC3D,wBAAsB,MAAM,CAC1B,SAAS,EAAE,UAAU,EACrB,OAAO,EAAE,UAAU,EACnB,SAAS,EAAE,UAAU,GACpB,OAAO,CAAC,OAAO,CAAC,CAMlB;AAED,wEAAwE;AACxE,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,UAAU,GAAG,MAAM,CAEhE;AAED,qEAAqE;AACrE,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,CAG9D"}
package/dist/crypto.js ADDED
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ /**
3
+ * Ed25519 keypair generation and signing — wraps @noble/ed25519.
4
+ *
5
+ * Agent identity on the 0x01 mesh is a 32-byte Ed25519 public key,
6
+ * represented as a 64-char lowercase hex string (agent_id).
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.generateKeypair = generateKeypair;
43
+ exports.keypairFromSeed = keypairFromSeed;
44
+ exports.sign = sign;
45
+ exports.verify = verify;
46
+ exports.publicKeyToAgentId = publicKeyToAgentId;
47
+ exports.agentIdToPublicKey = agentIdToPublicKey;
48
+ const ed = __importStar(require("@noble/ed25519"));
49
+ /** Generate a new random Ed25519 keypair. */
50
+ async function generateKeypair() {
51
+ const privateKey = ed.utils.randomPrivateKey();
52
+ const publicKey = await ed.getPublicKeyAsync(privateKey);
53
+ return { privateKey, publicKey };
54
+ }
55
+ /**
56
+ * Derive a keypair deterministically from a 32-byte seed.
57
+ * Useful for reproducible identities from a stored secret.
58
+ */
59
+ async function keypairFromSeed(seed) {
60
+ if (seed.length !== 32)
61
+ throw new Error('Seed must be 32 bytes');
62
+ const publicKey = await ed.getPublicKeyAsync(seed);
63
+ return { privateKey: seed, publicKey };
64
+ }
65
+ /** Sign a message with a private key. Returns a 64-byte signature. */
66
+ async function sign(message, privateKey) {
67
+ return ed.signAsync(message, privateKey);
68
+ }
69
+ /** Verify a signature against a message and public key. */
70
+ async function verify(signature, message, publicKey) {
71
+ try {
72
+ return await ed.verifyAsync(signature, message, publicKey);
73
+ }
74
+ catch {
75
+ return false;
76
+ }
77
+ }
78
+ /** Convert a 32-byte public key to a 64-char lowercase hex agent_id. */
79
+ function publicKeyToAgentId(publicKey) {
80
+ return Buffer.from(publicKey).toString('hex');
81
+ }
82
+ /** Parse a 64-char hex agent_id back to 32-byte public key bytes. */
83
+ function agentIdToPublicKey(agentId) {
84
+ if (agentId.length !== 64)
85
+ throw new Error('agent_id must be 64 hex chars');
86
+ return Buffer.from(agentId, 'hex');
87
+ }
88
+ //# sourceMappingURL=crypto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.js","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYH,0CAIC;AAMD,0CAIC;AAGD,oBAEC;AAGD,wBAUC;AAGD,gDAEC;AAGD,gDAGC;AArDD,mDAAoC;AASpC,6CAA6C;AACtC,KAAK,UAAU,eAAe;IACnC,MAAM,UAAU,GAAG,EAAE,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAA;IAC9C,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAA;IACxD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,CAAA;AAClC,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,eAAe,CAAC,IAAgB;IACpD,IAAI,IAAI,CAAC,MAAM,KAAK,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAA;IAChE,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAClD,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;AACxC,CAAC;AAED,sEAAsE;AAC/D,KAAK,UAAU,IAAI,CAAC,OAAmB,EAAE,UAAsB;IACpE,OAAO,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;AAC1C,CAAC;AAED,2DAA2D;AACpD,KAAK,UAAU,MAAM,CAC1B,SAAqB,EACrB,OAAmB,EACnB,SAAqB;IAErB,IAAI,CAAC;QACH,OAAO,MAAM,EAAE,CAAC,WAAW,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;IAC5D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC;AAED,wEAAwE;AACxE,SAAgB,kBAAkB,CAAC,SAAqB;IACtD,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AAC/C,CAAC;AAED,qEAAqE;AACrE,SAAgB,kBAAkB,CAAC,OAAe;IAChD,IAAI,OAAO,CAAC,MAAM,KAAK,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;IAC3E,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;AACpC,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @zerox1/core — 0x01 protocol primitives
3
+ *
4
+ * Platform-agnostic, zero I/O. Works in Node.js, browsers, React Native,
5
+ * WASM runtimes, and anything that can run JavaScript.
6
+ *
7
+ * Contains:
8
+ * - All shared message types and payload interfaces
9
+ * - Negotiation payload encode/decode (PROPOSE / COUNTER / ACCEPT)
10
+ * - JSON payload helpers for collaboration messages
11
+ * - Ed25519 keypair generation and signing
12
+ * - Wire format utilities (base64, hex conversions)
13
+ *
14
+ * Platform-specific packages (@zerox1/client, @zerox1/enterprise-client,
15
+ * @zerox1/react-native) depend on this package and extend its types for
16
+ * their respective mesh variant.
17
+ */
18
+ export type { NegotiationMsgType, InboundEnvelope, FeedbackPayload, NotarizeBidPayload, ProposePayload, CounterPayload, AcceptPayload, DeliverPayload, NodeIdentity, PeerSnapshot, ReputationSnapshot, SendResult, NegotiateResult, SkillMeta, ApiEvent, AgentRecord, AgentProfile, ActivityEvent, NetworkStats, HostingNode, AgentsParams, ActivityParams, } from './types.js';
19
+ export { encodeProposePayload, decodeProposePayload, encodeCounterPayload, decodeCounterPayload, encodeAcceptPayload, decodeAcceptPayload, encodeFeedbackPayload, decodeDeliverPayload, encodeJsonPayload, decodeJsonPayload, newConversationId, bytesToBase64, base64ToBytes, hexToBase64, base64ToHex, } from './codec.js';
20
+ export type { Keypair } from './crypto.js';
21
+ export { generateKeypair, keypairFromSeed, sign, verify, publicKeyToAgentId, agentIdToPublicKey, } from './crypto.js';
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,EACV,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,aAAa,EACb,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,cAAc,GACf,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,WAAW,EACX,WAAW,GACZ,MAAM,YAAY,CAAA;AAEnB,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EACL,eAAe,EACf,eAAe,EACf,IAAI,EACJ,MAAM,EACN,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,aAAa,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ /**
3
+ * @zerox1/core — 0x01 protocol primitives
4
+ *
5
+ * Platform-agnostic, zero I/O. Works in Node.js, browsers, React Native,
6
+ * WASM runtimes, and anything that can run JavaScript.
7
+ *
8
+ * Contains:
9
+ * - All shared message types and payload interfaces
10
+ * - Negotiation payload encode/decode (PROPOSE / COUNTER / ACCEPT)
11
+ * - JSON payload helpers for collaboration messages
12
+ * - Ed25519 keypair generation and signing
13
+ * - Wire format utilities (base64, hex conversions)
14
+ *
15
+ * Platform-specific packages (@zerox1/client, @zerox1/enterprise-client,
16
+ * @zerox1/react-native) depend on this package and extend its types for
17
+ * their respective mesh variant.
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.agentIdToPublicKey = exports.publicKeyToAgentId = exports.verify = exports.sign = exports.keypairFromSeed = exports.generateKeypair = exports.base64ToHex = exports.hexToBase64 = exports.base64ToBytes = exports.bytesToBase64 = exports.newConversationId = exports.decodeJsonPayload = exports.encodeJsonPayload = exports.decodeDeliverPayload = exports.encodeFeedbackPayload = exports.decodeAcceptPayload = exports.encodeAcceptPayload = exports.decodeCounterPayload = exports.encodeCounterPayload = exports.decodeProposePayload = exports.encodeProposePayload = void 0;
21
+ var codec_js_1 = require("./codec.js");
22
+ Object.defineProperty(exports, "encodeProposePayload", { enumerable: true, get: function () { return codec_js_1.encodeProposePayload; } });
23
+ Object.defineProperty(exports, "decodeProposePayload", { enumerable: true, get: function () { return codec_js_1.decodeProposePayload; } });
24
+ Object.defineProperty(exports, "encodeCounterPayload", { enumerable: true, get: function () { return codec_js_1.encodeCounterPayload; } });
25
+ Object.defineProperty(exports, "decodeCounterPayload", { enumerable: true, get: function () { return codec_js_1.decodeCounterPayload; } });
26
+ Object.defineProperty(exports, "encodeAcceptPayload", { enumerable: true, get: function () { return codec_js_1.encodeAcceptPayload; } });
27
+ Object.defineProperty(exports, "decodeAcceptPayload", { enumerable: true, get: function () { return codec_js_1.decodeAcceptPayload; } });
28
+ Object.defineProperty(exports, "encodeFeedbackPayload", { enumerable: true, get: function () { return codec_js_1.encodeFeedbackPayload; } });
29
+ Object.defineProperty(exports, "decodeDeliverPayload", { enumerable: true, get: function () { return codec_js_1.decodeDeliverPayload; } });
30
+ Object.defineProperty(exports, "encodeJsonPayload", { enumerable: true, get: function () { return codec_js_1.encodeJsonPayload; } });
31
+ Object.defineProperty(exports, "decodeJsonPayload", { enumerable: true, get: function () { return codec_js_1.decodeJsonPayload; } });
32
+ Object.defineProperty(exports, "newConversationId", { enumerable: true, get: function () { return codec_js_1.newConversationId; } });
33
+ Object.defineProperty(exports, "bytesToBase64", { enumerable: true, get: function () { return codec_js_1.bytesToBase64; } });
34
+ Object.defineProperty(exports, "base64ToBytes", { enumerable: true, get: function () { return codec_js_1.base64ToBytes; } });
35
+ Object.defineProperty(exports, "hexToBase64", { enumerable: true, get: function () { return codec_js_1.hexToBase64; } });
36
+ Object.defineProperty(exports, "base64ToHex", { enumerable: true, get: function () { return codec_js_1.base64ToHex; } });
37
+ var crypto_js_1 = require("./crypto.js");
38
+ Object.defineProperty(exports, "generateKeypair", { enumerable: true, get: function () { return crypto_js_1.generateKeypair; } });
39
+ Object.defineProperty(exports, "keypairFromSeed", { enumerable: true, get: function () { return crypto_js_1.keypairFromSeed; } });
40
+ Object.defineProperty(exports, "sign", { enumerable: true, get: function () { return crypto_js_1.sign; } });
41
+ Object.defineProperty(exports, "verify", { enumerable: true, get: function () { return crypto_js_1.verify; } });
42
+ Object.defineProperty(exports, "publicKeyToAgentId", { enumerable: true, get: function () { return crypto_js_1.publicKeyToAgentId; } });
43
+ Object.defineProperty(exports, "agentIdToPublicKey", { enumerable: true, get: function () { return crypto_js_1.agentIdToPublicKey; } });
44
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AA2BH,uCAgBmB;AAfjB,gHAAA,oBAAoB,OAAA;AACpB,gHAAA,oBAAoB,OAAA;AACpB,gHAAA,oBAAoB,OAAA;AACpB,gHAAA,oBAAoB,OAAA;AACpB,+GAAA,mBAAmB,OAAA;AACnB,+GAAA,mBAAmB,OAAA;AACnB,iHAAA,qBAAqB,OAAA;AACrB,gHAAA,oBAAoB,OAAA;AACpB,6GAAA,iBAAiB,OAAA;AACjB,6GAAA,iBAAiB,OAAA;AACjB,6GAAA,iBAAiB,OAAA;AACjB,yGAAA,aAAa,OAAA;AACb,yGAAA,aAAa,OAAA;AACb,uGAAA,WAAW,OAAA;AACX,uGAAA,WAAW,OAAA;AAIb,yCAOoB;AANlB,4GAAA,eAAe,OAAA;AACf,4GAAA,eAAe,OAAA;AACf,iGAAA,IAAI,OAAA;AACJ,mGAAA,MAAM,OAAA;AACN,+GAAA,kBAAkB,OAAA;AAClB,+GAAA,kBAAkB,OAAA"}
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Core negotiation message types shared across all mesh variants.
3
+ * Platform packages extend this into their own `MsgType` union.
4
+ *
5
+ * Public mesh adds: VERDICT, ADVERTISE, DISCOVER, BEACON, NOTARIZE_BID, NOTARIZE_ASSIGN
6
+ * Enterprise adds: DEAL_CANCEL + collaboration types (ASSIGN, REPORT, etc.)
7
+ */
8
+ export type NegotiationMsgType = 'PROPOSE' | 'COUNTER' | 'ACCEPT' | 'REJECT' | 'DELIVER' | 'DISPUTE' | 'FEEDBACK';
9
+ export interface FeedbackPayload {
10
+ score: number;
11
+ outcome: 'positive' | 'neutral' | 'negative';
12
+ message?: string;
13
+ }
14
+ export interface NotarizeBidPayload {
15
+ task_id: string;
16
+ amount_micro: number;
17
+ deadline_secs: number;
18
+ }
19
+ /**
20
+ * Generic inbound envelope. T is the msg_type union for this mesh variant.
21
+ * Use the concrete InboundEnvelope exported by @zerox1/client or
22
+ * @zerox1/enterprise-client rather than this generic form directly.
23
+ *
24
+ * The node pre-decodes `feedback` for FEEDBACK messages so handlers don't
25
+ * need to call decodeJsonPayload — the fields are already available.
26
+ */
27
+ export interface InboundEnvelope<T extends string = string> {
28
+ msg_type: T;
29
+ sender: string;
30
+ recipient: string;
31
+ conversation_id: string;
32
+ nonce: number;
33
+ payload_b64: string;
34
+ /** Pre-decoded by the node — only present on FEEDBACK messages. */
35
+ feedback?: FeedbackPayload;
36
+ }
37
+ export interface ProposePayload {
38
+ message: string;
39
+ amount_micro: bigint;
40
+ max_rounds: number;
41
+ }
42
+ export interface CounterPayload {
43
+ message?: string;
44
+ amount_micro: bigint;
45
+ round: number;
46
+ max_rounds: number;
47
+ }
48
+ export interface AcceptPayload {
49
+ message?: string;
50
+ amount_micro: bigint;
51
+ }
52
+ /**
53
+ * DELIVER payload — sent by an agent to submit completed work.
54
+ * The `fee_usdc` field is the amount the agent charges for this delivery.
55
+ * This is application-level JSON encoded in payload_b64 — use
56
+ * `decodeDeliverPayload()` to parse it from an inbound DELIVER envelope.
57
+ *
58
+ * Note: `fee_usdc` is in the payload, NOT on the envelope itself.
59
+ */
60
+ export interface DeliverPayload {
61
+ /** Human-readable summary of the work delivered. */
62
+ summary?: string;
63
+ /** USDC amount charged for this delivery (e.g. 1.5 = $1.50). */
64
+ fee_usdc?: number;
65
+ /** Result data — structure is agent/app defined. */
66
+ result?: unknown;
67
+ }
68
+ export interface NodeIdentity {
69
+ agent_id: string;
70
+ name: string;
71
+ }
72
+ export interface PeerSnapshot {
73
+ agent_id: string;
74
+ peer_id?: string;
75
+ last_active_epoch?: number;
76
+ }
77
+ export interface ReputationSnapshot {
78
+ agent_id: string;
79
+ reliability: number;
80
+ cooperation: number;
81
+ total_tasks: number;
82
+ total_disputes: number;
83
+ last_active_epoch?: number;
84
+ }
85
+ export interface SendResult {
86
+ nonce: number;
87
+ payload_hash: string;
88
+ }
89
+ export interface NegotiateResult {
90
+ conversation_id: string;
91
+ nonce: number;
92
+ payload_hash: string;
93
+ }
94
+ export interface SkillMeta {
95
+ name: string;
96
+ version: string;
97
+ url: string;
98
+ }
99
+ export interface ApiEvent {
100
+ event_type: string;
101
+ agent_id?: string;
102
+ data?: unknown;
103
+ }
104
+ export interface AgentRecord {
105
+ agent_id: string;
106
+ name?: string;
107
+ capabilities?: string[];
108
+ reputation?: number;
109
+ stake?: number;
110
+ }
111
+ export interface AgentProfile extends AgentRecord {
112
+ total_tasks?: number;
113
+ total_disputes?: number;
114
+ last_active?: number;
115
+ }
116
+ export interface ActivityEvent {
117
+ id: number;
118
+ event_type: string;
119
+ agent_id: string;
120
+ counterpart_id?: string;
121
+ score?: number;
122
+ conversation_id?: string;
123
+ created_at: number;
124
+ }
125
+ export interface NetworkStats {
126
+ agent_count: number;
127
+ interaction_count: number;
128
+ started_at: number;
129
+ }
130
+ export interface HostingNode {
131
+ node_id: string;
132
+ name?: string;
133
+ fee_bps?: number;
134
+ api_url: string;
135
+ hosted_count: number;
136
+ first_seen?: number;
137
+ last_seen: number;
138
+ }
139
+ export interface AgentsParams {
140
+ limit?: number;
141
+ }
142
+ export interface ActivityParams {
143
+ limit?: number;
144
+ before?: number;
145
+ }
146
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAC1B,SAAS,GACT,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,SAAS,GACT,UAAU,CAAA;AAMd,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,UAAU,GAAG,SAAS,GAAG,UAAU,CAAA;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,MAAM,GAAG,MAA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AED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB"}
package/dist/types.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Core negotiation message types — shared across all mesh variants
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,+EAA+E;AAC/E,mEAAmE;AACnE,+EAA+E"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@zerox1/core",
3
+ "version": "0.4.2",
4
+ "description": "0x01 core protocol — types, codec, and Ed25519 crypto. Zero I/O, runs everywhere.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/0x01-a2a/node.git",
9
+ "directory": "packages/core"
10
+ },
11
+ "homepage": "https://0x01.world",
12
+ "keywords": [
13
+ "zerox1",
14
+ "0x01",
15
+ "agent",
16
+ "mesh",
17
+ "p2p",
18
+ "sdk"
19
+ ],
20
+ "main": "./dist/index.js",
21
+ "types": "./dist/index.d.ts",
22
+ "exports": {
23
+ ".": {
24
+ "require": "./dist/index.js",
25
+ "default": "./dist/index.js",
26
+ "types": "./dist/index.d.ts"
27
+ }
28
+ },
29
+ "files": [
30
+ "dist"
31
+ ],
32
+ "scripts": {
33
+ "build": "tsc",
34
+ "dev": "tsc --watch"
35
+ },
36
+ "dependencies": {
37
+ "@noble/ed25519": "^2.1.0"
38
+ },
39
+ "devDependencies": {
40
+ "@types/node": "^20.0.0",
41
+ "typescript": "^5.7.0"
42
+ }
43
+ }