@newtype-ai/nit 0.2.6 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -132,7 +132,7 @@ your-project/
132
132
  ## Programmatic API
133
133
 
134
134
  ```typescript
135
- import { init, commit, checkout, branch, push, status, sign, loginPayload } from '@newtype-ai/nit';
135
+ import { init, commit, checkout, branch, push, status, sign, loginPayload, loadRawKeyPair } from '@newtype-ai/nit';
136
136
 
137
137
  await init();
138
138
 
@@ -143,6 +143,10 @@ const payload = await loginPayload('faam.io');
143
143
  // Customize card, then commit & push
144
144
  await commit('FAAM config');
145
145
  await push({ all: true });
146
+
147
+ // Access raw Ed25519 keypair (64 bytes: [seed || pubkey])
148
+ const keypair = await loadRawKeyPair('/path/to/.nit');
149
+ // → Uint8Array(64) — compatible with Solana and other Ed25519 libraries
146
150
  ```
147
151
 
148
152
  ## Design Principles
@@ -232,6 +232,24 @@ async function loadPrivateKey(nitDir) {
232
232
  format: "jwk"
233
233
  });
234
234
  }
235
+ async function loadRawKeyPair(nitDir) {
236
+ const pubBase64 = await loadPublicKey(nitDir);
237
+ const keyPath = join3(nitDir, "identity", "agent.key");
238
+ let privBase64;
239
+ try {
240
+ privBase64 = (await fs3.readFile(keyPath, "utf-8")).trim();
241
+ } catch {
242
+ throw new Error(
243
+ "Private key not found at .nit/identity/agent.key. Regenerate with `nit init`."
244
+ );
245
+ }
246
+ const seed = Buffer.from(privBase64, "base64");
247
+ const pubkey = Buffer.from(pubBase64, "base64");
248
+ const keypair = new Uint8Array(64);
249
+ keypair.set(seed, 0);
250
+ keypair.set(pubkey, 32);
251
+ return keypair;
252
+ }
235
253
  function formatPublicKeyField(pubBase64) {
236
254
  return `ed25519:${pubBase64}`;
237
255
  }
@@ -1137,6 +1155,7 @@ async function remoteSetUrl(name, url, options) {
1137
1155
  }
1138
1156
 
1139
1157
  export {
1158
+ loadRawKeyPair,
1140
1159
  formatPublicKeyField,
1141
1160
  parsePublicKeyField,
1142
1161
  signChallenge,
package/dist/cli.js CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  remoteSetUrl,
16
16
  sign,
17
17
  status
18
- } from "./chunk-3RRHLPAC.js";
18
+ } from "./chunk-CJUMX46F.js";
19
19
 
20
20
  // src/cli.ts
21
21
  var bold = (s) => `\x1B[1m${s}\x1B[0m`;
package/dist/index.d.ts CHANGED
@@ -135,6 +135,12 @@ declare function diffCards(oldCard: AgentCard, newCard: AgentCard): DiffResult;
135
135
  */
136
136
  declare function formatDiff(diff: DiffResult): string;
137
137
 
138
+ /**
139
+ * Load the Ed25519 keypair as raw bytes (64-byte Uint8Array).
140
+ * Format: [32-byte seed || 32-byte public key]
141
+ * Compatible with Solana keypair format and other Ed25519 libraries.
142
+ */
143
+ declare function loadRawKeyPair(nitDir: string): Promise<Uint8Array>;
138
144
  /**
139
145
  * Format a raw base64 public key as the value for the agent card's
140
146
  * `publicKey` field: "ed25519:<base64>".
@@ -305,4 +311,4 @@ declare function remoteSetUrl(name: string, url: string, options?: {
305
311
  projectDir?: string;
306
312
  }): Promise<void>;
307
313
 
308
- 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, branch, checkout, commit, deriveAgentId, diff, diffCards, fetchBranchCard, findNitDir, formatDiff, formatPublicKeyField, init, loadAgentId, log, loginPayload, parsePublicKeyField, push, remote, remoteAdd, remoteSetUrl, sign, signChallenge, signMessage, status };
314
+ 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, branch, checkout, commit, deriveAgentId, diff, diffCards, fetchBranchCard, findNitDir, formatDiff, formatPublicKeyField, init, loadAgentId, loadRawKeyPair, log, loginPayload, parsePublicKeyField, push, remote, remoteAdd, remoteSetUrl, sign, signChallenge, signMessage, status };
package/dist/index.js CHANGED
@@ -13,6 +13,7 @@ import {
13
13
  formatPublicKeyField,
14
14
  init,
15
15
  loadAgentId,
16
+ loadRawKeyPair,
16
17
  log,
17
18
  loginPayload,
18
19
  parsePublicKeyField,
@@ -24,7 +25,7 @@ import {
24
25
  signChallenge,
25
26
  signMessage,
26
27
  status
27
- } from "./chunk-3RRHLPAC.js";
28
+ } from "./chunk-CJUMX46F.js";
28
29
  export {
29
30
  NIT_NAMESPACE,
30
31
  branch,
@@ -39,6 +40,7 @@ export {
39
40
  formatPublicKeyField,
40
41
  init,
41
42
  loadAgentId,
43
+ loadRawKeyPair,
42
44
  log,
43
45
  loginPayload,
44
46
  parsePublicKeyField,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newtype-ai/nit",
3
- "version": "0.2.6",
3
+ "version": "0.3.0",
4
4
  "description": "Version control for agent cards",
5
5
  "type": "module",
6
6
  "bin": {