@newtype-ai/nit 0.4.8 → 0.4.9

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 CHANGED
@@ -2,6 +2,7 @@
2
2
  // nit — version control for agent cards
3
3
  import {
4
4
  branch,
5
+ broadcast,
5
6
  checkout,
6
7
  commit,
7
8
  diff,
@@ -13,9 +14,12 @@ import {
13
14
  remote,
14
15
  remoteAdd,
15
16
  remoteSetUrl,
17
+ rpcInfo,
18
+ rpcSetUrl,
16
19
  sign,
20
+ signTx,
17
21
  status
18
- } from "./chunk-7LNGTHKO.js";
22
+ } from "./chunk-Q5GX7ZXR.js";
19
23
 
20
24
  // src/update-check.ts
21
25
  import { execSync } from "child_process";
@@ -28,7 +32,7 @@ var FETCH_TIMEOUT_MS = 3e3;
28
32
  var REGISTRY_URL = "https://registry.npmjs.org/@newtype-ai/nit/latest";
29
33
  function getCurrentVersion() {
30
34
  try {
31
- return "0.4.8";
35
+ return "0.4.9";
32
36
  } catch {
33
37
  return "0.0.0";
34
38
  }
@@ -149,6 +153,15 @@ async function main() {
149
153
  case "remote":
150
154
  await cmdRemote(args);
151
155
  break;
156
+ case "sign-tx":
157
+ await cmdSignTx(args);
158
+ break;
159
+ case "broadcast":
160
+ await cmdBroadcast(args);
161
+ break;
162
+ case "rpc":
163
+ await cmdRpc(args);
164
+ break;
152
165
  case "help":
153
166
  case "--help":
154
167
  case "-h":
@@ -359,6 +372,73 @@ async function cmdSign(args) {
359
372
  const signature = await sign(message);
360
373
  console.log(signature);
361
374
  }
375
+ async function cmdSignTx(args) {
376
+ const chainIndex = args.indexOf("--chain");
377
+ if (chainIndex === -1 || !args[chainIndex + 1]) {
378
+ console.error("Usage: nit sign-tx --chain <evm|solana> <hex-data>");
379
+ process.exit(1);
380
+ }
381
+ const chain = args[chainIndex + 1];
382
+ if (chain !== "evm" && chain !== "solana") {
383
+ console.error(`Unknown chain: ${chain}. Use 'evm' or 'solana'.`);
384
+ process.exit(1);
385
+ }
386
+ const data = args.filter((_, i) => i !== chainIndex && i !== chainIndex + 1)[0];
387
+ if (!data) {
388
+ console.error("Usage: nit sign-tx --chain <evm|solana> <hex-data>");
389
+ process.exit(1);
390
+ }
391
+ const result = await signTx(chain, data);
392
+ console.log(JSON.stringify(result, null, 2));
393
+ }
394
+ async function cmdBroadcast(args) {
395
+ const chainIndex = args.indexOf("--chain");
396
+ if (chainIndex === -1 || !args[chainIndex + 1]) {
397
+ console.error("Usage: nit broadcast --chain <evm|solana> <signed-tx>");
398
+ process.exit(1);
399
+ }
400
+ const chain = args[chainIndex + 1];
401
+ if (chain !== "evm" && chain !== "solana") {
402
+ console.error(`Unknown chain: ${chain}. Use 'evm' or 'solana'.`);
403
+ process.exit(1);
404
+ }
405
+ const signedTx = args.filter((_, i) => i !== chainIndex && i !== chainIndex + 1)[0];
406
+ if (!signedTx) {
407
+ console.error("Usage: nit broadcast --chain <evm|solana> <signed-tx>");
408
+ process.exit(1);
409
+ }
410
+ const result = await broadcast(chain, signedTx);
411
+ console.log(`${green("+")} ${result.txHash}`);
412
+ console.log(dim(` \u2192 ${result.rpcUrl}`));
413
+ }
414
+ async function cmdRpc(args) {
415
+ if (args[0] === "set-url") {
416
+ const chain = args[1];
417
+ const url = args[2];
418
+ if (!chain || !url) {
419
+ console.error("Usage: nit rpc set-url <chain> <url>");
420
+ process.exit(1);
421
+ }
422
+ await rpcSetUrl(chain, url);
423
+ console.log(`Set RPC URL for '${chain}' to ${url}`);
424
+ return;
425
+ }
426
+ if (args[0]) {
427
+ console.error(`nit rpc: unknown subcommand '${args[0]}'`);
428
+ console.error("Usage: nit rpc [set-url <chain> <url>]");
429
+ process.exit(1);
430
+ }
431
+ const info = await rpcInfo();
432
+ const chains = Object.keys(info);
433
+ if (chains.length === 0) {
434
+ console.log(dim("No RPC endpoints configured."));
435
+ console.log(dim("Run: nit rpc set-url <chain> <url>"));
436
+ return;
437
+ }
438
+ for (const [chain, config] of Object.entries(info)) {
439
+ console.log(` ${bold(chain)}: ${config.url}`);
440
+ }
441
+ }
362
442
  function printUsage() {
363
443
  console.log(`
364
444
  ${bold("nit")} \u2014 version control for agent cards
@@ -379,6 +459,10 @@ ${bold("Commands:")}
379
459
  remote Show remote info
380
460
  remote add <n> <u> Add a new remote
381
461
  remote set-url <n> <u> Change remote URL
462
+ sign-tx --chain <c> <data> Sign tx data (evm: hash, solana: message)
463
+ broadcast --chain <c> <tx> Send signed tx to RPC endpoint
464
+ rpc Show configured RPC endpoints
465
+ rpc set-url <c> <url> Set RPC endpoint for a chain
382
466
 
383
467
  ${bold("Examples:")}
384
468
  nit init
package/dist/index.d.ts CHANGED
@@ -32,12 +32,19 @@ interface NitRemoteConfig {
32
32
  /** Legacy field — push auth is now via Ed25519 keypair */
33
33
  credential?: string;
34
34
  }
35
+ /** RPC endpoint configuration for a specific chain. */
36
+ interface NitRpcConfig {
37
+ /** JSON-RPC endpoint URL */
38
+ url: string;
39
+ }
35
40
  /** Full .nit/config file contents. */
36
41
  interface NitConfig {
37
42
  /** Keyed by remote name (e.g. "origin") */
38
43
  remotes: Record<string, NitRemoteConfig>;
39
44
  /** Discovered skills directory path */
40
45
  skillsDir?: string;
46
+ /** RPC endpoints keyed by chain name (e.g. "evm", "solana") */
47
+ rpc?: Record<string, NitRpcConfig>;
41
48
  }
42
49
  /** A2A-compatible agent card. */
43
50
  interface AgentCard {
@@ -124,6 +131,26 @@ interface StatusResult {
124
131
  behind: number;
125
132
  }>;
126
133
  }
134
+ /** Result of signing transaction data. */
135
+ interface SignTxResult {
136
+ /** Chain that was signed for */
137
+ chain: 'evm' | 'solana';
138
+ /** The signature (EVM: "0x{r}{s}{v}" 130 hex chars, Solana: base64 64-byte Ed25519) */
139
+ signature: string;
140
+ /** EVM only: recovery parameter (0 or 1) for agent to compute chain-specific v */
141
+ recovery?: number;
142
+ /** The signer address */
143
+ address: string;
144
+ }
145
+ /** Result of broadcasting a signed transaction. */
146
+ interface BroadcastResult {
147
+ /** Chain that was broadcast to */
148
+ chain: 'evm' | 'solana';
149
+ /** Transaction hash (EVM) or signature (Solana) */
150
+ txHash: string;
151
+ /** RPC endpoint used */
152
+ rpcUrl: string;
153
+ }
127
154
  /** Result of generating a login payload for app authentication. */
128
155
  interface LoginPayload {
129
156
  agent_id: string;
@@ -225,6 +252,28 @@ declare function getWalletAddresses(nitDir: string): Promise<WalletAddresses>;
225
252
  * For EVM transaction signing.
226
253
  */
227
254
  declare function loadSecp256k1RawKeyPair(nitDir: string): Promise<Uint8Array>;
255
+ /**
256
+ * Sign a 32-byte hash with the agent's derived secp256k1 private key.
257
+ * Returns ECDSA signature with recovery parameter.
258
+ *
259
+ * The caller (agent) provides a pre-hashed message (e.g. keccak256 of
260
+ * an RLP-encoded EVM transaction). nit signs it and returns (r, s, recovery).
261
+ * The agent computes chain-specific v = chainId * 2 + 35 + recovery (EIP-155).
262
+ */
263
+ declare function signEvmHash(nitDir: string, hash: Uint8Array): Promise<{
264
+ r: string;
265
+ s: string;
266
+ v: number;
267
+ recovery: number;
268
+ signature: string;
269
+ }>;
270
+ /**
271
+ * Sign raw bytes with the agent's Ed25519 private key.
272
+ * Returns 64-byte signature as Uint8Array.
273
+ *
274
+ * For Solana transactions: the caller provides the serialized message bytes.
275
+ */
276
+ declare function signSolanaBytes(nitDir: string, message: Uint8Array): Promise<Uint8Array>;
228
277
 
229
278
  /**
230
279
  * Walk up from startDir looking for a .nit/ directory.
@@ -343,5 +392,33 @@ declare function remoteAdd(name: string, url: string, options?: {
343
392
  declare function remoteSetUrl(name: string, url: string, options?: {
344
393
  projectDir?: string;
345
394
  }): Promise<void>;
395
+ /**
396
+ * Sign transaction data with the agent's identity-derived key.
397
+ *
398
+ * EVM: pass a 32-byte keccak256 hash (hex). Returns ECDSA signature.
399
+ * Solana: pass serialized message bytes (hex). Returns Ed25519 signature.
400
+ */
401
+ declare function signTx(chain: 'evm' | 'solana', data: string, options?: {
402
+ projectDir?: string;
403
+ }): Promise<SignTxResult>;
404
+ /**
405
+ * Broadcast a signed transaction to the configured RPC endpoint.
406
+ */
407
+ declare function broadcast(chain: 'evm' | 'solana', signedTx: string, options?: {
408
+ projectDir?: string;
409
+ rpcUrl?: string;
410
+ }): Promise<BroadcastResult>;
411
+ /**
412
+ * Set the RPC endpoint URL for a chain.
413
+ */
414
+ declare function rpcSetUrl(chain: string, url: string, options?: {
415
+ projectDir?: string;
416
+ }): Promise<void>;
417
+ /**
418
+ * Get all configured RPC endpoints.
419
+ */
420
+ declare function rpcInfo(options?: {
421
+ projectDir?: string;
422
+ }): Promise<Record<string, NitRpcConfig>>;
346
423
 
347
- export { type AgentCard, type AgentCardSkill, type DiffResult, type FieldDiff, type InitResult, type LoginPayload, NIT_NAMESPACE, type NitBranch, type NitCommit, type NitConfig, type NitHead, type NitRemoteConfig, type PushResult, type RemoteInfo, type SkillMetadata, type StatusResult, type WalletAddresses$1 as WalletAddresses, base58Encode, branch, checkout, commit, deriveAgentId, diff, diffCards, fetchBranchCard, findNitDir, formatDiff, formatPublicKeyField, getEvmAddress, getSolanaAddress, getWalletAddresses, init, loadAgentId, loadRawKeyPair, loadSecp256k1RawKeyPair, log, loginPayload, parsePublicKeyField, push, remote, remoteAdd, remoteSetUrl, sign, signChallenge, signMessage, status };
424
+ export { type AgentCard, type AgentCardSkill, type BroadcastResult, type DiffResult, type FieldDiff, type InitResult, type LoginPayload, NIT_NAMESPACE, type NitBranch, type NitCommit, type NitConfig, type NitHead, type NitRemoteConfig, type NitRpcConfig, type PushResult, type RemoteInfo, type SignTxResult, type SkillMetadata, type StatusResult, type WalletAddresses$1 as WalletAddresses, base58Encode, branch, broadcast, checkout, commit, deriveAgentId, diff, diffCards, fetchBranchCard, findNitDir, formatDiff, formatPublicKeyField, getEvmAddress, getSolanaAddress, getWalletAddresses, init, loadAgentId, loadRawKeyPair, loadSecp256k1RawKeyPair, log, loginPayload, parsePublicKeyField, push, remote, remoteAdd, remoteSetUrl, rpcInfo, rpcSetUrl, sign, signChallenge, signEvmHash, signMessage, signSolanaBytes, signTx, status };
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ import {
3
3
  NIT_NAMESPACE,
4
4
  base58Encode,
5
5
  branch,
6
+ broadcast,
6
7
  checkout,
7
8
  commit,
8
9
  deriveAgentId,
@@ -26,15 +27,21 @@ import {
26
27
  remote,
27
28
  remoteAdd,
28
29
  remoteSetUrl,
30
+ rpcInfo,
31
+ rpcSetUrl,
29
32
  sign,
30
33
  signChallenge,
34
+ signEvmHash,
31
35
  signMessage,
36
+ signSolanaBytes,
37
+ signTx,
32
38
  status
33
- } from "./chunk-7LNGTHKO.js";
39
+ } from "./chunk-Q5GX7ZXR.js";
34
40
  export {
35
41
  NIT_NAMESPACE,
36
42
  base58Encode,
37
43
  branch,
44
+ broadcast,
38
45
  checkout,
39
46
  commit,
40
47
  deriveAgentId,
@@ -58,8 +65,13 @@ export {
58
65
  remote,
59
66
  remoteAdd,
60
67
  remoteSetUrl,
68
+ rpcInfo,
69
+ rpcSetUrl,
61
70
  sign,
62
71
  signChallenge,
72
+ signEvmHash,
63
73
  signMessage,
74
+ signSolanaBytes,
75
+ signTx,
64
76
  status
65
77
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newtype-ai/nit",
3
- "version": "0.4.8",
3
+ "version": "0.4.9",
4
4
  "description": "Version control for agent cards",
5
5
  "type": "module",
6
6
  "bin": {
@@ -42,6 +42,7 @@
42
42
  },
43
43
  "homepage": "https://github.com/newtype-ai/nit",
44
44
  "devDependencies": {
45
+ "@noble/curves": "^2.0.0",
45
46
  "@noble/hashes": "^2.0.1",
46
47
  "@types/node": "^25.3.0",
47
48
  "tsup": "^8.0.0",
@@ -1,8 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
  console.log(`
3
+ _ _ _____
4
+ | \\ |"| ___ |_ " _|
5
+ <| \\| |> |_"_| | |
6
+ U| |\\ |u | | /| |\\
7
+ |_| \\_| U/| |\\u u |_|U
8
+ || \\\\,-.-,_|___|_,-._// \\\\_
9
+ (_") (_/ \\_)-' '-(_/(__) (__)
10
+
3
11
  nit — version control for agent cards
4
12
 
5
13
  Get started: nit init
6
14
  Commands: nit --help
7
- Full playbook: https://github.com/newtype-ai/nit/blob/main/SKILL.md
8
15
  `);