@provenonce/mcp 1.0.5 → 1.0.6

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.
@@ -90,15 +90,21 @@ var PROVENONCE_TOOLS = [
90
90
  },
91
91
  {
92
92
  name: "provenonce_beats_proof",
93
- description: "Compute a local Beats work-proof \u2014 cryptographic evidence of computational effort by this agent. Returns a hash chain proof that can be shared as evidence of work. No network call required.",
93
+ description: "Compute a Beats work-proof \u2014 cryptographic evidence of computational effort by this agent. Computes sequential hash chains at the current network difficulty, submits to the Beats service for a signed receipt. The receipt can be used for spawn authorization and other operations.",
94
94
  inputSchema: {
95
95
  type: "object",
96
96
  properties: {
97
97
  count: {
98
98
  type: "integer",
99
- description: "Number of beats to compute (min 10, max 1000)",
99
+ description: "Number of beats to compute (min 10, max 10000)",
100
100
  minimum: 10,
101
- maximum: 1e3
101
+ maximum: 1e4
102
+ },
103
+ difficulty: {
104
+ type: "integer",
105
+ description: "Hash iterations per beat (default 1000, min 100, max 5000). Usually auto-detected from network.",
106
+ minimum: 100,
107
+ maximum: 5e3
102
108
  }
103
109
  },
104
110
  required: ["count"]
@@ -153,4 +159,4 @@ var PROVENONCE_TOOLS = [
153
159
  export {
154
160
  PROVENONCE_TOOLS
155
161
  };
156
- //# sourceMappingURL=chunk-COVXPAEW.js.map
162
+ //# sourceMappingURL=chunk-ONDCXFYW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/tools.ts"],"sourcesContent":["/** Provenonce Skill — 9 MCP tool definitions (JSON Schema) */\r\nexport const PROVENONCE_TOOLS = [\r\n {\r\n name: 'provenonce_register',\r\n description:\r\n 'Register this agent with Provenonce to get a cryptographic identity (hash + API key). ' +\r\n 'Safe to call multiple times — returns existing identity if already registered. ' +\r\n 'No wallet required. Free.',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {\r\n name: {\r\n type: 'string',\r\n description: 'Human-readable name for this agent (optional, max 64 chars)',\r\n maxLength: 64,\r\n },\r\n skill_ref: {\r\n type: 'string',\r\n description:\r\n '16-character hex ref token of the skill that deployed you — for rev-share attribution (optional)',\r\n pattern: '^[0-9a-f]{16}$',\r\n },\r\n },\r\n },\r\n },\r\n\r\n {\r\n name: 'provenonce_status',\r\n description:\r\n 'Get this agent\\'s current Provenonce status: identity, SIGIL, beats balance, and next steps. ' +\r\n 'Requires prior provenonce_register call.',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {},\r\n },\r\n },\r\n\r\n {\r\n name: 'provenonce_purchase_sigil',\r\n description:\r\n 'Purchase a Provenonce SIGIL to unlock full provenance: heartbeat access, signed passport, ' +\r\n 'and a permanent identity record. Requires a Solana payment transaction. ' +\r\n 'SIGIL format: name*principal*tier (e.g. my-agent*acme*ind).',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {\r\n name: {\r\n type: 'string',\r\n description: 'SIGIL name segment — identifies this specific agent (e.g. \"my-agent\")',\r\n },\r\n principal: {\r\n type: 'string',\r\n description: 'Principal segment — identifies the operator or organisation (e.g. \"acme\")',\r\n },\r\n identity_class: {\r\n type: 'string',\r\n enum: ['narrow_task', 'autonomous', 'orchestrator'],\r\n description:\r\n 'Agent identity class (pricing axis): narrow_task=single-purpose, autonomous=independent decision-maker, orchestrator=coordinates other agents',\r\n },\r\n tier: {\r\n type: 'string',\r\n enum: ['sov', 'org', 'ind', 'eph', 'sbx'],\r\n description:\r\n 'Trust governance tier: sov=sovereign/root, org=organisation, ind=individual, eph=ephemeral, sbx=sandbox',\r\n },\r\n payment_tx: {\r\n type: 'string',\r\n description: 'Solana transaction signature for the SIGIL fee payment',\r\n },\r\n },\r\n required: ['name', 'principal', 'identity_class', 'tier', 'payment_tx'],\r\n },\r\n },\r\n\r\n {\r\n name: 'provenonce_heartbeat',\r\n description:\r\n 'Submit a heartbeat to prove this agent is alive. Requires a SIGIL (call provenonce_purchase_sigil first). ' +\r\n 'Requires a Solana payment transaction for the heartbeat fee.',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {\r\n payment_tx: {\r\n type: 'string',\r\n description: 'Solana transaction signature for the heartbeat fee payment',\r\n },\r\n },\r\n required: ['payment_tx'],\r\n },\r\n },\r\n\r\n {\r\n name: 'provenonce_get_passport',\r\n description:\r\n 'Get this agent\\'s cryptographically signed Passport — a verifiable identity document ' +\r\n 'any third party can verify offline using the Provenonce authority public key. ' +\r\n 'Requires an active SIGIL and at least one heartbeat.',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {\r\n payment_tx: {\r\n type: 'string',\r\n description: 'Solana transaction signature for the passport reissue fee (if applicable)',\r\n },\r\n },\r\n },\r\n },\r\n\r\n {\r\n name: 'provenonce_beats_proof',\r\n description:\r\n 'Compute a Beats work-proof — cryptographic evidence of computational effort by this agent. ' +\r\n 'Computes sequential hash chains at the current network difficulty, submits to the Beats service ' +\r\n 'for a signed receipt. The receipt can be used for spawn authorization and other operations.',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {\r\n count: {\r\n type: 'integer',\r\n description: 'Number of beats to compute (min 10, max 10000)',\r\n minimum: 10,\r\n maximum: 10000,\r\n },\r\n difficulty: {\r\n type: 'integer',\r\n description: 'Hash iterations per beat (default 1000, min 100, max 5000). Usually auto-detected from network.',\r\n minimum: 100,\r\n maximum: 5000,\r\n },\r\n },\r\n required: ['count'],\r\n },\r\n },\r\n\r\n {\r\n name: 'provenonce_verify_agent',\r\n description:\r\n 'Verify another agent\\'s Provenonce identity. Returns their SIGIL, identity class, and registration status. ' +\r\n 'Public — no authentication required.',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {\r\n hash: {\r\n type: 'string',\r\n description: 'The agent hash to verify (0x + 64 hex chars)',\r\n pattern: '^0x[0-9a-fA-F]{64}$',\r\n },\r\n },\r\n required: ['hash'],\r\n },\r\n },\r\n\r\n {\r\n name: 'provenonce_spawn',\r\n description:\r\n 'Spawn a child agent under this agent\\'s identity. The child inherits lineage from the parent. ' +\r\n 'Returns the child\\'s hash and API key. Requires sufficient beats balance or a work-proof receipt.',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {\r\n child_name: {\r\n type: 'string',\r\n description: 'Name for the child agent (max 64 chars)',\r\n maxLength: 64,\r\n },\r\n },\r\n required: ['child_name'],\r\n },\r\n },\r\n\r\n {\r\n name: 'provenonce_get_lineage',\r\n description:\r\n 'Get the full lineage chain for an agent — all events in its provenance history ' +\r\n '(registration, SIGIL issuance, heartbeats, spawns). Public — no authentication required.',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {\r\n hash: {\r\n type: 'string',\r\n description:\r\n 'The agent hash to get lineage for (0x + 64 hex chars). Defaults to this agent if omitted.',\r\n pattern: '^0x[0-9a-fA-F]{64}$',\r\n },\r\n },\r\n },\r\n },\r\n] as const;\r\n\r\nexport type ToolName = (typeof PROVENONCE_TOOLS)[number]['name'];\r\n"],"mappings":";;;AACO,IAAM,mBAAmB;AAAA,EAC9B;AAAA,IACE,MAAM;AAAA,IACN,aACE;AAAA,IAGF,aAAa;AAAA,MACX,MAAM;AAAA,MACN,YAAY;AAAA,QACV,MAAM;AAAA,UACJ,MAAM;AAAA,UACN,aAAa;AAAA,UACb,WAAW;AAAA,QACb;AAAA,QACA,WAAW;AAAA,UACT,MAAM;AAAA,UACN,aACE;AAAA,UACF,SAAS;AAAA,QACX;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA;AAAA,IACE,MAAM;AAAA,IACN,aACE;AAAA,IAEF,aAAa;AAAA,MACX,MAAM;AAAA,MACN,YAAY,CAAC;AAAA,IACf;AAAA,EACF;AAAA,EAEA;AAAA,IACE,MAAM;AAAA,IACN,aACE;AAAA,IAGF,aAAa;AAAA,MACX,MAAM;AAAA,MACN,YAAY;AAAA,QACV,MAAM;AAAA,UACJ,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,QACA,WAAW;AAAA,UACT,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,QACA,gBAAgB;AAAA,UACd,MAAM;AAAA,UACN,MAAM,CAAC,eA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SAAS;AAAA,QACX;AAAA,MACF;AAAA,MACA,UAAU,CAAC,MAAM;AAAA,IACnB;AAAA,EACF;AAAA,EAEA;AAAA,IACE,MAAM;AAAA,IACN,aACE;AAAA,IAEF,aAAa;AAAA,MACX,MAAM;AAAA,MACN,YAAY;AAAA,QACV,YAAY;AAAA,UACV,MAAM;AAAA,UACN,aAAa;AAAA,UACb,WAAW;AAAA,QACb;AAAA,MACF;AAAA,MACA,UAAU,CAAC,YAAY;AAAA,IACzB;AAAA,EACF;AAAA,EAEA;AAAA,IACE,MAAM;AAAA,IACN,aACE;AAAA,IAEF,aAAa;AAAA,MACX,MAAM;AAAA,MACN,YAAY;AAAA,QACV,MAAM;AAAA,UACJ,MAAM;AAAA,UACN,aACE;AAAA,UACF,SAAS;AAAA,QACX;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // @provenonce/mcp — Provenonce Skill for AI agents
2
2
  import {
3
3
  PROVENONCE_TOOLS
4
- } from "./chunk-COVXPAEW.js";
4
+ } from "./chunk-ONDCXFYW.js";
5
5
 
6
6
  // src/index.ts
7
7
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
@@ -12,7 +12,7 @@ import {
12
12
  } from "@modelcontextprotocol/sdk/types.js";
13
13
 
14
14
  // src/handlers.ts
15
- import { createHash } from "crypto";
15
+ import { createHash, randomBytes } from "crypto";
16
16
 
17
17
  // src/credentials.ts
18
18
  import { readFileSync, writeFileSync, mkdirSync, chmodSync, existsSync } from "fs";
@@ -61,6 +61,7 @@ function saveCredentials(creds) {
61
61
 
62
62
  // src/client.ts
63
63
  var REGISTRY_URL = process.env.PROVENONCE_REGISTRY_URL || "https://provenonce.io";
64
+ var BEATS_URL = process.env.PROVENONCE_BEATS_URL || "https://beats.provenonce.dev";
64
65
  async function apiFetch(path, opts = {}) {
65
66
  const headers = { "Content-Type": "application/json" };
66
67
  if (opts.apiKey) headers["Authorization"] = `Bearer ${opts.apiKey}`;
@@ -80,6 +81,26 @@ async function apiFetch(path, opts = {}) {
80
81
  return { data: null, error: err2.message };
81
82
  }
82
83
  }
84
+ async function fetchAnchor() {
85
+ return apiFetch("/api/v1/beat/anchor");
86
+ }
87
+ async function submitWorkProof(proof) {
88
+ try {
89
+ const res = await fetch(`${BEATS_URL}/api/v1/beat/work-proof`, {
90
+ method: "POST",
91
+ headers: { "Content-Type": "application/json" },
92
+ body: JSON.stringify({ work_proof: proof })
93
+ });
94
+ const json = await res.json();
95
+ if (!res.ok) {
96
+ const msg = json.error ?? `HTTP ${res.status}`;
97
+ return { data: null, error: msg };
98
+ }
99
+ return { data: json, error: null };
100
+ } catch (err2) {
101
+ return { data: null, error: err2.message };
102
+ }
103
+ }
83
104
  async function registerAgent(opts) {
84
105
  const tokenRes = await apiFetch("/api/v1/register/token", {
85
106
  method: "POST",
@@ -153,10 +174,14 @@ async function getLineage(hash) {
153
174
  return apiFetch(`/api/v1/agent/lineage/${encodeURIComponent(hash)}`);
154
175
  }
155
176
  async function spawnChild(apiKey, opts) {
177
+ const step1Body = { child_name: opts.childName };
178
+ if (opts.beatsReceipt) {
179
+ step1Body.beats_receipt = opts.beatsReceipt;
180
+ }
156
181
  const step1 = await apiFetch("/api/v1/agent/spawn", {
157
182
  method: "POST",
158
183
  apiKey,
159
- body: { child_name: opts.childName }
184
+ body: step1Body
160
185
  });
161
186
  if (step1.error || !step1.data?.spawn_authorization) {
162
187
  return { data: null, error: step1.error ?? "Spawn step 1 failed: no authorization returned" };
@@ -289,24 +314,98 @@ async function handleGetPassport(args) {
289
314
  _verify: "Verify at: GET https://provenonce.io/.well-known/provenonce-authority.json for the authority public key."
290
315
  });
291
316
  }
292
- async function handleBeatsProof(args) {
293
- const count = Math.max(10, Math.min(1e3, args.count));
294
- const creds = loadCredentials();
295
- const seed = creds?.agent_hash ?? `provenonce:beats:${Date.now()}`;
317
+ function computeBeatHash(prevHash, beatIndex, difficulty, anchorHash) {
318
+ const seed = anchorHash ? `${prevHash}:${beatIndex}::${anchorHash}` : `${prevHash}:${beatIndex}:`;
319
+ let current = createHash("sha256").update(seed, "utf8").digest("hex");
320
+ for (let i = 0; i < difficulty; i++) {
321
+ current = createHash("sha256").update(current, "utf8").digest("hex");
322
+ }
323
+ return current;
324
+ }
325
+ async function computeWorkProof(count, difficulty) {
326
+ const anchorRes = await fetchAnchor();
327
+ const anchor = anchorRes.data?.anchor;
328
+ const anchorHash = anchor?.hash;
329
+ const anchorIndex = anchor?.beat_index ?? 0;
330
+ const genesisInput = `provenonce:beats:${randomBytes(16).toString("hex")}`;
331
+ const genesisHash = createHash("sha256").update(genesisInput, "utf8").digest("hex");
332
+ const spotCheckIndices = selectSpotCheckIndices(count);
333
+ const spotChecks = [];
296
334
  const start = Date.now();
297
- let hash = createHash("sha256").update(seed).digest("hex");
298
- const fromHash = `0x${hash}`;
299
- for (let i = 1; i < count; i++) {
300
- hash = createHash("sha256").update(hash).digest("hex");
335
+ let prevHash = genesisHash;
336
+ for (let i = 1; i <= count; i++) {
337
+ const hash = computeBeatHash(prevHash, i, difficulty, anchorHash);
338
+ if (spotCheckIndices.has(i)) {
339
+ spotChecks.push({ index: i, hash, prev: prevHash });
340
+ }
341
+ prevHash = hash;
301
342
  }
302
- const toHash = `0x${hash}`;
303
343
  const duration = Date.now() - start;
304
- return ok({
344
+ const fromHash = genesisHash;
345
+ const toHash = prevHash;
346
+ const localProof = {
347
+ from_hash: fromHash,
348
+ to_hash: toHash,
349
+ beats_computed: count,
350
+ duration_ms: duration
351
+ };
352
+ const submitRes = await submitWorkProof({
305
353
  from_hash: fromHash,
306
354
  to_hash: toHash,
307
355
  beats_computed: count,
308
- duration_ms: duration,
309
- message: `Computed ${count} beats in ${duration}ms. This is cryptographic proof of computational work.`
356
+ difficulty,
357
+ anchor_index: anchorIndex,
358
+ anchor_hash: anchorHash,
359
+ spot_checks: spotChecks
360
+ });
361
+ if (submitRes.error) {
362
+ return { receipt: null, localProof, error: `Beats submission failed: ${submitRes.error}` };
363
+ }
364
+ if (!submitRes.data?.valid) {
365
+ return { receipt: null, localProof, error: `Beats rejected proof: ${submitRes.data?.reason ?? "unknown"}` };
366
+ }
367
+ return { receipt: submitRes.data.receipt ?? null, localProof };
368
+ }
369
+ function selectSpotCheckIndices(count) {
370
+ const minChecks = 3;
371
+ const density = 1e3;
372
+ const maxChecks = 25;
373
+ const needed = Math.max(
374
+ Math.min(count, minChecks),
375
+ Math.min(Math.ceil(count / density), maxChecks)
376
+ );
377
+ const indices = /* @__PURE__ */ new Set();
378
+ indices.add(1);
379
+ indices.add(count);
380
+ if (needed > 2 && count > 2) {
381
+ const interiorNeeded = needed - 2;
382
+ for (let j = 1; j <= interiorNeeded; j++) {
383
+ const idx = Math.round(1 + j * (count - 1) / (interiorNeeded + 1));
384
+ if (idx > 1 && idx < count) {
385
+ indices.add(idx);
386
+ }
387
+ }
388
+ }
389
+ return indices;
390
+ }
391
+ async function handleBeatsProof(args) {
392
+ const count = Math.max(10, Math.min(1e4, args.count));
393
+ const difficulty = Math.max(100, Math.min(5e3, args.difficulty ?? 1e3));
394
+ const { receipt, localProof, error } = await computeWorkProof(count, difficulty);
395
+ if (receipt) {
396
+ return ok({
397
+ ...localProof,
398
+ difficulty,
399
+ receipt,
400
+ message: `Computed ${count} beats at difficulty ${difficulty} in ${localProof.duration_ms}ms. Signed receipt obtained from Beats service.`
401
+ });
402
+ }
403
+ return ok({
404
+ ...localProof,
405
+ difficulty,
406
+ receipt: null,
407
+ _warning: error ?? "Could not obtain signed receipt from Beats service.",
408
+ message: `Computed ${count} beats locally in ${localProof.duration_ms}ms but receipt not available. ${error ?? ""}`
310
409
  });
311
410
  }
312
411
  async function handleVerifyAgent(args) {
@@ -316,9 +415,18 @@ async function handleVerifyAgent(args) {
316
415
  }
317
416
  async function handleSpawn(args) {
318
417
  const creds = requireCredentials();
418
+ const SPAWN_BEATS = 1050;
419
+ const SPAWN_DIFFICULTY = 1e3;
420
+ const { receipt, error: proofError } = await computeWorkProof(SPAWN_BEATS, SPAWN_DIFFICULTY);
421
+ if (!receipt) {
422
+ return err(
423
+ `Failed to obtain Beats work-proof receipt for spawn. ${proofError ?? "Unknown error"}. You can try calling provenonce_beats_proof with count=1050 manually, then retry spawn.`
424
+ );
425
+ }
319
426
  const { data, error } = await spawnChild(creds.api_key, {
320
427
  childName: args.child_name,
321
- parentHash: creds.agent_hash
428
+ parentHash: creds.agent_hash,
429
+ beatsReceipt: receipt
322
430
  });
323
431
  if (error || !data) return err(error ?? "Spawn failed");
324
432
  return ok({
@@ -374,7 +482,10 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
374
482
  case "provenonce_get_passport":
375
483
  return handleGetPassport({ payment_tx: a.payment_tx });
376
484
  case "provenonce_beats_proof":
377
- return handleBeatsProof({ count: a.count });
485
+ return handleBeatsProof({
486
+ count: a.count,
487
+ difficulty: a.difficulty
488
+ });
378
489
  case "provenonce_verify_agent":
379
490
  return handleVerifyAgent({ hash: a.hash });
380
491
  case "provenonce_spawn":
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/handlers.ts","../src/credentials.ts","../src/client.ts"],"sourcesContent":["import { Server } from '@modelcontextprotocol/sdk/server/index.js';\r\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\r\nimport {\r\n CallToolRequestSchema,\r\n ListToolsRequestSchema,\r\n} from '@modelcontextprotocol/sdk/types.js';\r\n\r\nimport { PROVENONCE_TOOLS } from './tools.js';\r\nimport {\r\n handleRegister,\r\n handleStatus,\r\n handlePurchaseSigil,\r\n handleHeartbeat,\r\n handleGetPassport,\r\n handleBeatsProof,\r\n handleVerifyAgent,\r\n handleSpawn,\r\n handleGetLineage,\r\n} from './handlers.js';\r\n\r\nconst server = new Server(\r\n { name: 'provenonce', version: '1.0.0' },\r\n { capabilities: { tools: {} } },\r\n);\r\n\r\n// List available tools\r\nserver.setRequestHandler(ListToolsRequestSchema, async () => ({\r\n tools: PROVENONCE_TOOLS.map((t) => ({\r\n name: t.name,\r\n description: t.description,\r\n inputSchema: t.inputSchema,\r\n })),\r\n}));\r\n\r\n// Handle tool calls\r\nserver.setRequestHandler(CallToolRequestSchema, async (request) => {\r\n const { name, arguments: args = {} } = request.params;\r\n const a = args as Record<string, unknown>;\r\n\r\n switch (name) {\r\n case 'provenonce_register':\r\n return handleRegister({\r\n name: a.name as string | undefined,\r\n skill_ref: a.skill_ref as string | undefined,\r\n });\r\n\r\n case 'provenonce_status':\r\n return handleStatus();\r\n\r\n case 'provenonce_purchase_sigil':\r\n return handlePurchaseSigil({\r\n name: a.name as string,\r\n principal: a.principal as string,\r\n identity_class: a.identity_class as string,\r\n tier: a.tier as string,\r\n payment_tx: a.payment_tx as string,\r\n });\r\n\r\n case 'provenonce_heartbeat':\r\n return handleHeartbeat({ payment_tx: a.payment_tx as string });\r\n\r\n case 'provenonce_get_passport':\r\n return handleGetPassport({ payment_tx: a.payment_tx as string | undefined });\r\n\r\n case 'provenonce_beats_proof':\r\n return handleBeatsProof({ count: a.count as number });\r\n\r\n case 'provenonce_verify_agent':\r\n return handleVerifyAgent({ hash: a.hash as string });\r\n\r\n case 'provenonce_spawn':\r\n return handleSpawn({ child_name: a.child_name as string });\r\n\r\n case 'provenonce_get_lineage':\r\n return handleGetLineage({ hash: a.hash as string | undefined });\r\n\r\n default:\r\n return {\r\n content: [{ type: 'text', text: `Unknown tool: ${name}` }],\r\n isError: true,\r\n };\r\n }\r\n});\r\n\r\n// Start stdio transport\r\nasync function main() {\r\n const transport = new StdioServerTransport();\r\n await server.connect(transport);\r\n}\r\n\r\nmain().catch((err) => {\r\n process.stderr.write(`Fatal: ${(err as Error).message}\\n`);\r\n process.exit(1);\r\n});\r\n","import { createHash } from 'crypto';\r\nimport { loadCredentials, saveCredentials } from './credentials.js';\r\nimport * as api from './client.js';\r\n\r\nfunction requireCredentials() {\r\n const creds = loadCredentials();\r\n if (!creds) {\r\n throw new Error(\r\n 'Not registered. Call provenonce_register first.',\r\n );\r\n }\r\n return creds;\r\n}\r\n\r\nfunction ok(data: unknown): { content: [{ type: 'text'; text: string }] } {\r\n return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };\r\n}\r\n\r\nfunction err(message: string): { content: [{ type: 'text'; text: string }]; isError: true } {\r\n return { content: [{ type: 'text', text: `Error: ${message}` }], isError: true };\r\n}\r\n\r\n// ── provenonce_register ───────────────────────────────────────────────────────\r\n\r\nexport async function handleRegister(args: { name?: string; skill_ref?: string }) {\r\n // Return existing identity if already registered\r\n const existing = loadCredentials();\r\n if (existing) {\r\n const { data, error } = await api.getStatus(existing.api_key);\r\n if (data) {\r\n return ok({\r\n registered: false,\r\n message: 'Already registered — returning existing identity.',\r\n hash: existing.agent_hash,\r\n sigil: data.sigil,\r\n identity_class: data.identity_class,\r\n _hint: data._hint,\r\n });\r\n }\r\n if (error) {\r\n // Credentials stale or invalid — fall through to re-register\r\n }\r\n }\r\n\r\n const { data, error } = await api.registerAgent({\r\n name: args.name,\r\n skillRef: args.skill_ref,\r\n });\r\n\r\n if (error || !data) return err(error ?? 'Registration failed');\r\n\r\n saveCredentials({ api_key: data.api_key, agent_hash: data.hash });\r\n\r\n return ok({\r\n registered: true,\r\n hash: data.hash,\r\n api_key: data.api_key,\r\n depth: data.depth,\r\n message: 'Agent registered. Credentials saved. Call provenonce_status to see your full state.',\r\n _warning: 'Save your api_key securely. It will not be shown again after this session.',\r\n });\r\n}\r\n\r\n// ── provenonce_status ─────────────────────────────────────────────────────────\r\n\r\nexport async function handleStatus() {\r\n const creds = requireCredentials();\r\n const { data, error } = await api.getStatus(creds.api_key);\r\n if (error || !data) return err(error ?? 'Failed to get status');\r\n return ok(data);\r\n}\r\n\r\n// ── provenonce_purchase_sigil ─────────────────────────────────────────────────\r\n\r\nexport async function handlePurchaseSigil(args: {\r\n name: string;\r\n principal: string;\r\n identity_class: string;\r\n tier: string;\r\n payment_tx: string;\r\n}) {\r\n const creds = requireCredentials();\r\n const skillRef = process.env.PROVENONCE_SKILL_REF;\r\n\r\n const { data, error } = await api.purchaseSigil(creds.api_key, {\r\n name: args.name,\r\n principal: args.principal,\r\n identity_class: args.identity_class,\r\n tier: args.tier,\r\n payment_tx: args.payment_tx,\r\n skillRef,\r\n });\r\n\r\n if (error || !data) return err(error ?? 'SIGIL purchase failed');\r\n\r\n return ok({\r\n ...data,\r\n heartbeat_unlocked: true,\r\n message: `SIGIL issued: ${data.sigil}. You can now call provenonce_heartbeat and provenonce_get_passport.`,\r\n });\r\n}\r\n\r\n// ── provenonce_heartbeat ──────────────────────────────────────────────────────\r\n\r\nexport async function handleHeartbeat(args: { payment_tx: string }) {\r\n const creds = requireCredentials();\r\n const { data, error } = await api.heartbeat(creds.api_key, args.payment_tx);\r\n if (error || !data) return err(error ?? 'Heartbeat failed');\r\n\r\n if (!data.ok && data.sigil_required) {\r\n return err('SIGIL required. Call provenonce_purchase_sigil first.');\r\n }\r\n\r\n return ok({\r\n ok: data.ok,\r\n message: data.ok ? 'Heartbeat recorded. Agent liveness confirmed.' : 'Heartbeat failed.',\r\n });\r\n}\r\n\r\n// ── provenonce_get_passport ───────────────────────────────────────────────────\r\n\r\nexport async function handleGetPassport(args: { payment_tx?: string }) {\r\n const creds = requireCredentials();\r\n const { data, error } = await api.getPassport(creds.api_key, args.payment_tx);\r\n if (error || !data) return err(error ?? 'Passport retrieval failed');\r\n\r\n return ok({\r\n passport: data.lineage_proof,\r\n message:\r\n 'Passport issued. Share this signed document with any third party to prove your identity offline.',\r\n _verify:\r\n 'Verify at: GET https://provenonce.io/.well-known/provenonce-authority.json for the authority public key.',\r\n });\r\n}\r\n\r\n// ── provenonce_beats_proof ────────────────────────────────────────────────────\r\n\r\nexport async function handleBeatsProof(args: { count: number }) {\r\n const count = Math.max(10, Math.min(1000, args.count));\r\n const creds = loadCredentials();\r\n const seed = creds?.agent_hash ?? `provenonce:beats:${Date.now()}`;\r\n\r\n const start = Date.now();\r\n let hash = createHash('sha256').update(seed).digest('hex');\r\n const fromHash = `0x${hash}`;\r\n\r\n for (let i = 1; i < count; i++) {\r\n hash = createHash('sha256').update(hash).digest('hex');\r\n }\r\n\r\n const toHash = `0x${hash}`;\r\n const duration = Date.now() - start;\r\n\r\n return ok({\r\n from_hash: fromHash,\r\n to_hash: toHash,\r\n beats_computed: count,\r\n duration_ms: duration,\r\n message: `Computed ${count} beats in ${duration}ms. This is cryptographic proof of computational work.`,\r\n });\r\n}\r\n\r\n// ── provenonce_verify_agent ───────────────────────────────────────────────────\r\n\r\nexport async function handleVerifyAgent(args: { hash: string }) {\r\n const { data, error } = await api.verifyAgent(args.hash);\r\n if (error || !data) return err(error ?? 'Verification failed');\r\n return ok(data);\r\n}\r\n\r\n// ── provenonce_spawn ──────────────────────────────────────────────────────────\r\n\r\nexport async function handleSpawn(args: { child_name: string }) {\r\n const creds = requireCredentials();\r\n\r\n const { data, error } = await api.spawnChild(creds.api_key, {\r\n childName: args.child_name,\r\n parentHash: creds.agent_hash,\r\n });\r\n\r\n if (error || !data) return err(error ?? 'Spawn failed');\r\n\r\n return ok({\r\n ...data,\r\n message: `Child agent spawned: ${data.child_hash}. Save the child_api_key — it will not be shown again.`,\r\n _warning: 'The child agent has its own identity. Configure it with PROVENONCE_API_KEY + PROVENONCE_AGENT_HASH.',\r\n });\r\n}\r\n\r\n// ── provenonce_get_lineage ────────────────────────────────────────────────────\r\n\r\nexport async function handleGetLineage(args: { hash?: string }) {\r\n const creds = loadCredentials();\r\n const targetHash = args.hash ?? creds?.agent_hash;\r\n\r\n if (!targetHash) {\r\n return err('No hash provided and agent is not registered. Call provenonce_register first or provide a hash.');\r\n }\r\n\r\n const { data, error } = await api.getLineage(targetHash);\r\n if (error || !data) return err(error ?? 'Lineage retrieval failed');\r\n return ok(data);\r\n}\r\n","import { readFileSync, writeFileSync, mkdirSync, chmodSync, existsSync } from 'fs';\r\nimport { join } from 'path';\r\nimport { homedir } from 'os';\r\nimport type { StoredCredentials } from './types.js';\r\n\r\nfunction getConfigDir(): string {\r\n return join(homedir(), '.provenonce');\r\n}\r\n\r\nfunction getConfigPath(): string {\r\n return join(getConfigDir(), 'config.json');\r\n}\r\n\r\n/** Load credentials — env vars take priority over config file */\r\nexport function loadCredentials(): StoredCredentials | null {\r\n const apiKey = process.env.PROVENONCE_API_KEY;\r\n const agentHash = process.env.PROVENONCE_AGENT_HASH;\r\n\r\n if (apiKey && agentHash) {\r\n return { api_key: apiKey, agent_hash: agentHash };\r\n }\r\n\r\n const configPath = getConfigPath();\r\n if (!existsSync(configPath)) return null;\r\n\r\n try {\r\n const raw = readFileSync(configPath, 'utf-8');\r\n const parsed = JSON.parse(raw) as Partial<StoredCredentials>;\r\n if (parsed.api_key && parsed.agent_hash) {\r\n return { api_key: parsed.api_key, agent_hash: parsed.agent_hash };\r\n }\r\n } catch {\r\n // Corrupt config — treat as missing\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/** Persist credentials to ~/.provenonce/config.json (chmod 600) */\r\nexport function saveCredentials(creds: StoredCredentials): void {\r\n const dir = getConfigDir();\r\n if (!existsSync(dir)) {\r\n mkdirSync(dir, { recursive: true });\r\n }\r\n\r\n const configPath = getConfigPath();\r\n const data: StoredCredentials = {\r\n api_key: creds.api_key,\r\n agent_hash: creds.agent_hash,\r\n };\r\n\r\n writeFileSync(configPath, JSON.stringify(data, null, 2), 'utf-8');\r\n\r\n // chmod 600 — owner read/write only (Unix only; no-op on Windows)\r\n try {\r\n chmodSync(configPath, 0o600);\r\n } catch {\r\n // Windows — chmod not supported; recommend env var instead\r\n }\r\n}\r\n\r\n/** Clear stored credentials */\r\nexport function clearCredentials(): void {\r\n const configPath = getConfigPath();\r\n if (existsSync(configPath)) {\r\n writeFileSync(configPath, '{}', 'utf-8');\r\n }\r\n}\r\n","import type {\r\n RegisterResult,\r\n AgentStatus,\r\n HeartbeatResult,\r\n PassportResult,\r\n SigilResult,\r\n VerifyAgentResult,\r\n LineageResult,\r\n SpawnResult,\r\n} from './types.js';\r\n\r\nconst REGISTRY_URL = process.env.PROVENONCE_REGISTRY_URL || 'https://provenonce.io';\r\n\r\nasync function apiFetch<T>(\r\n path: string,\r\n opts: { method?: string; body?: unknown; apiKey?: string; isPublic?: boolean } = {},\r\n): Promise<{ data: T | null; error: string | null }> {\r\n const headers: Record<string, string> = { 'Content-Type': 'application/json' };\r\n if (opts.apiKey) headers['Authorization'] = `Bearer ${opts.apiKey}`;\r\n\r\n try {\r\n const res = await fetch(`${REGISTRY_URL}${path}`, {\r\n method: opts.method ?? 'GET',\r\n headers,\r\n body: opts.body ? JSON.stringify(opts.body) : undefined,\r\n });\r\n\r\n const json = await res.json() as Record<string, unknown>;\r\n\r\n if (!res.ok) {\r\n const msg = (json.error as string) ?? `HTTP ${res.status}`;\r\n return { data: null, error: msg };\r\n }\r\n\r\n return { data: json as T, error: null };\r\n } catch (err) {\r\n return { data: null, error: (err as Error).message };\r\n }\r\n}\r\n\r\n/** Register a new agent (no-wallet path) */\r\nexport async function registerAgent(opts: {\r\n name?: string;\r\n skillRef?: string;\r\n}): Promise<{ data: RegisterResult | null; error: string | null }> {\r\n // Step 1: Obtain a self-service registration token (RFC-010, 5-min TTL)\r\n const tokenRes = await apiFetch<{ token: string }>('/api/v1/register/token', {\r\n method: 'POST',\r\n body: {},\r\n });\r\n if (tokenRes.error || !tokenRes.data?.token) {\r\n return { data: null, error: tokenRes.error ?? 'Failed to obtain registration token' };\r\n }\r\n\r\n // Step 2: Register with the token\r\n const headers: Record<string, string> = {\r\n 'Content-Type': 'application/json',\r\n 'x-registration-token': tokenRes.data.token,\r\n };\r\n try {\r\n const res = await fetch(`${REGISTRY_URL}/api/v1/register`, {\r\n method: 'POST',\r\n headers,\r\n body: JSON.stringify({\r\n name: opts.name,\r\n wallet: 'none',\r\n ...(opts.skillRef ? { ref: opts.skillRef } : {}),\r\n }),\r\n });\r\n const json = await res.json() as Record<string, unknown>;\r\n if (!res.ok) {\r\n return { data: null, error: (json.error as string) ?? `HTTP ${res.status}` };\r\n }\r\n return { data: json as RegisterResult, error: null };\r\n } catch (err) {\r\n return { data: null, error: (err as Error).message };\r\n }\r\n}\r\n\r\n/** Get full agent status */\r\nexport async function getStatus(apiKey: string): Promise<{ data: AgentStatus | null; error: string | null }> {\r\n return apiFetch<AgentStatus>('/api/v1/skill/bootstrap', {\r\n method: 'POST',\r\n apiKey,\r\n body: {},\r\n });\r\n}\r\n\r\n/** Submit heartbeat */\r\nexport async function heartbeat(apiKey: string, paymentTx?: string): Promise<{ data: HeartbeatResult | null; error: string | null }> {\r\n return apiFetch<HeartbeatResult>('/api/v1/agent/heartbeat', {\r\n method: 'POST',\r\n apiKey,\r\n body: { payment_tx: paymentTx },\r\n });\r\n}\r\n\r\n/** Reissue passport / lineage proof */\r\nexport async function getPassport(apiKey: string, paymentTx?: string): Promise<{ data: { lineage_proof: PassportResult } | null; error: string | null }> {\r\n return apiFetch<{ lineage_proof: PassportResult }>('/api/v1/agent/reissue-proof', {\r\n method: 'POST',\r\n apiKey,\r\n body: paymentTx ? { payment_tx: paymentTx } : {},\r\n });\r\n}\r\n\r\n/** Purchase a SIGIL */\r\nexport async function purchaseSigil(apiKey: string, opts: {\r\n name: string;\r\n principal: string;\r\n identity_class: string;\r\n tier: string;\r\n payment_tx: string;\r\n skillRef?: string;\r\n}): Promise<{ data: SigilResult | null; error: string | null }> {\r\n return apiFetch<SigilResult>('/api/v1/sigil', {\r\n method: 'POST',\r\n apiKey,\r\n body: {\r\n name: opts.name,\r\n principal: opts.principal,\r\n identity_class: opts.identity_class,\r\n tier: opts.tier,\r\n payment_tx: opts.payment_tx,\r\n ...(opts.skillRef ? { ref: opts.skillRef } : {}),\r\n },\r\n });\r\n}\r\n\r\n/** Verify another agent's identity (public) */\r\nexport async function verifyAgent(hash: string): Promise<{ data: VerifyAgentResult | null; error: string | null }> {\r\n return apiFetch<VerifyAgentResult>(`/api/v1/verify/${encodeURIComponent(hash)}`);\r\n}\r\n\r\n/** Get agent lineage chain (public) */\r\nexport async function getLineage(hash: string): Promise<{ data: LineageResult | null; error: string | null }> {\r\n return apiFetch<LineageResult>(`/api/v1/agent/lineage/${encodeURIComponent(hash)}`);\r\n}\r\n\r\n/** Spawn a child agent — handles full 3-step flow internally */\r\nexport async function spawnChild(apiKey: string, opts: {\r\n childName: string;\r\n parentHash: string;\r\n}): Promise<{ data: SpawnResult | null; error: string | null }> {\r\n // Step 1: Get spawn authorization\r\n const step1 = await apiFetch<{\r\n spawn_authorization: string;\r\n child_name?: string;\r\n }>('/api/v1/agent/spawn', {\r\n method: 'POST',\r\n apiKey,\r\n body: { child_name: opts.childName },\r\n });\r\n\r\n if (step1.error || !step1.data?.spawn_authorization) {\r\n return { data: null, error: step1.error ?? 'Spawn step 1 failed: no authorization returned' };\r\n }\r\n\r\n const spawnAuth = step1.data.spawn_authorization;\r\n\r\n // Step 2: Register the child with the spawn_authorization\r\n const reg = await apiFetch<RegisterResult>('/api/v1/register', {\r\n method: 'POST',\r\n apiKey,\r\n body: {\r\n name: opts.childName,\r\n wallet: 'none',\r\n spawn_authorization: spawnAuth,\r\n },\r\n });\r\n\r\n if (reg.error || !reg.data?.hash) {\r\n return { data: null, error: reg.error ?? 'Spawn step 2 (child registration) failed' };\r\n }\r\n\r\n const childHash = reg.data.hash;\r\n const childApiKey = reg.data.api_key;\r\n\r\n // Step 3: Finalize the spawn\r\n const step3 = await apiFetch<{ ok: boolean }>('/api/v1/agent/spawn', {\r\n method: 'POST',\r\n apiKey,\r\n body: { child_hash: childHash },\r\n });\r\n\r\n if (step3.error) {\r\n return { data: null, error: step3.error };\r\n }\r\n\r\n return {\r\n data: {\r\n child_hash: childHash,\r\n child_api_key: childApiKey,\r\n child_depth: reg.data.depth,\r\n parent_hash: opts.parentHash,\r\n },\r\n error: null,\r\n };\r\n}\r\n"],"mappings":";;;;;;AAAA,SAAS,cAAc;AACvB,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,OACK;;;ACLP,SAAS,kBAAkB;;;ACA3B,SAAS,cA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IAAI,GAAG,CAAC;AAAA,QACzD,SAAS;AAAA,MACX;AAAA,EACJ;AACF,CAAC;AAGD,eAAe,OAAO;AACpB,QAAM,YAAY,IAAI,qBAAqB;AAC3C,QAAM,OAAO,QAAQ,SAAS;AAChC;AAEA,KAAK,EAAE,MAAM,CAACC,SAAQ;AACpB,UAAQ,OAAO,MAAM,UAAWA,KAAc,OAAO;AAAA,CAAI;AACzD,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["err","data","error","err"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/handlers.ts","../src/credentials.ts","../src/client.ts"],"sourcesContent":["import { Server } from '@modelcontextprotocol/sdk/server/index.js';\r\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\r\nimport {\r\n CallToolRequestSchema,\r\n ListToolsRequestSchema,\r\n} from '@modelcontextprotocol/sdk/types.js';\r\n\r\nimport { PROVENONCE_TOOLS } from './tools.js';\r\nimport {\r\n handleRegister,\r\n handleStatus,\r\n handlePurchaseSigil,\r\n handleHeartbeat,\r\n handleGetPassport,\r\n handleBeatsProof,\r\n handleVerifyAgent,\r\n handleSpawn,\r\n handleGetLineage,\r\n} from './handlers.js';\r\n\r\nconst server = new Server(\r\n { name: 'provenonce', version: '1.0.0' },\r\n { capabilities: { tools: {} } },\r\n);\r\n\r\n// List available tools\r\nserver.setRequestHandler(ListToolsRequestSchema, async () => ({\r\n tools: PROVENONCE_TOOLS.map((t) => ({\r\n name: t.name,\r\n description: t.description,\r\n inputSchema: t.inputSchema,\r\n })),\r\n}));\r\n\r\n// Handle tool calls\r\nserver.setRequestHandler(CallToolRequestSchema, async (request) => {\r\n const { name, arguments: args = {} } = request.params;\r\n const a = args as Record<string, unknown>;\r\n\r\n switch (name) {\r\n case 'provenonce_register':\r\n return handleRegister({\r\n name: a.name as string | undefined,\r\n skill_ref: a.skill_ref as string | undefined,\r\n });\r\n\r\n case 'provenonce_status':\r\n return handleStatus();\r\n\r\n case 'provenonce_purchase_sigil':\r\n return handlePurchaseSigil({\r\n name: a.name as string,\r\n principal: a.principal as string,\r\n identity_class: a.identity_class as string,\r\n tier: a.tier as string,\r\n payment_tx: a.payment_tx as string,\r\n });\r\n\r\n case 'provenonce_heartbeat':\r\n return handleHeartbeat({ payment_tx: a.payment_tx as string });\r\n\r\n case 'provenonce_get_passport':\r\n return handleGetPassport({ payment_tx: a.payment_tx as string | undefined });\r\n\r\n case 'provenonce_beats_proof':\r\n return handleBeatsProof({\r\n count: a.count as number,\r\n difficulty: a.difficulty as number | undefined,\r\n });\r\n\r\n case 'provenonce_verify_agent':\r\n return handleVerifyAgent({ hash: a.hash as string });\r\n\r\n case 'provenonce_spawn':\r\n return handleSpawn({ child_name: a.child_name as string });\r\n\r\n case 'provenonce_get_lineage':\r\n return handleGetLineage({ hash: a.hash as string | undefined });\r\n\r\n default:\r\n return {\r\n content: [{ type: 'text', text: `Unknown tool: ${name}` }],\r\n isError: true,\r\n };\r\n }\r\n});\r\n\r\n// Start stdio transport\r\nasync function main() {\r\n const transport = new StdioServerTransport();\r\n await server.connect(transport);\r\n}\r\n\r\nmain().catch((err) => {\r\n process.stderr.write(`Fatal: ${(err as Error).message}\\n`);\r\n process.exit(1);\r\n});\r\n","import { createHash, randomBytes } from 'crypto';\r\nimport { loadCredentials, saveCredentials } from './credentials.js';\r\nimport * as api from './client.js';\r\nimport type { WorkProofReceipt } from './types.js';\r\n\r\nfunction requireCredentials() {\r\n const creds = loadCredentials();\r\n if (!creds) {\r\n throw new Error(\r\n 'Not registered. Call provenonce_register first.',\r\n );\r\n }\r\n return creds;\r\n}\r\n\r\nfunction ok(data: unknown): { content: [{ type: 'text'; text: string }] } {\r\n return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };\r\n}\r\n\r\nfunction err(message: string): { content: [{ type: 'text'; text: string }]; isError: true } {\r\n return { content: [{ type: 'text', text: `Error: ${message}` }], isError: true };\r\n}\r\n\r\n// ── provenonce_register ───────────────────────────────────────────────────────\r\n\r\nexport async function handleRegister(args: { name?: string; skill_ref?: string }) {\r\n // Return existing identity if already registered\r\n const existing = loadCredentials();\r\n if (existing) {\r\n const { data, error } = await api.getStatus(existing.api_key);\r\n if (data) {\r\n return ok({\r\n registered: false,\r\n message: 'Already registered — returning existing identity.',\r\n hash: existing.agent_hash,\r\n sigil: data.sigil,\r\n identity_class: data.identity_class,\r\n _hint: data._hint,\r\n });\r\n }\r\n if (error) {\r\n // Credentials stale or invalid — fall through to re-register\r\n }\r\n }\r\n\r\n const { data, error } = await api.registerAgent({\r\n name: args.name,\r\n skillRef: args.skill_ref,\r\n });\r\n\r\n if (error || !data) return err(error ?? 'Registration failed');\r\n\r\n saveCredentials({ api_key: data.api_key, agent_hash: data.hash });\r\n\r\n return ok({\r\n registered: true,\r\n hash: data.hash,\r\n api_key: data.api_key,\r\n depth: data.depth,\r\n message: 'Agent registered. Credentials saved. Call provenonce_status to see your full state.',\r\n _warning: 'Save your api_key securely. It will not be shown again after this session.',\r\n });\r\n}\r\n\r\n// ── provenonce_status ─────────────────────────────────────────────────────────\r\n\r\nexport async function handleStatus() {\r\n const creds = requireCredentials();\r\n const { data, error } = await api.getStatus(creds.api_key);\r\n if (error || !data) return err(error ?? 'Failed to get status');\r\n return ok(data);\r\n}\r\n\r\n// ── provenonce_purchase_sigil ─────────────────────────────────────────────────\r\n\r\nexport async function handlePurchaseSigil(args: {\r\n name: string;\r\n principal: string;\r\n identity_class: string;\r\n tier: string;\r\n payment_tx: string;\r\n}) {\r\n const creds = requireCredentials();\r\n const skillRef = process.env.PROVENONCE_SKILL_REF;\r\n\r\n const { data, error } = await api.purchaseSigil(creds.api_key, {\r\n name: args.name,\r\n principal: args.principal,\r\n identity_class: args.identity_class,\r\n tier: args.tier,\r\n payment_tx: args.payment_tx,\r\n skillRef,\r\n });\r\n\r\n if (error || !data) return err(error ?? 'SIGIL purchase failed');\r\n\r\n return ok({\r\n ...data,\r\n heartbeat_unlocked: true,\r\n message: `SIGIL issued: ${data.sigil}. You can now call provenonce_heartbeat and provenonce_get_passport.`,\r\n });\r\n}\r\n\r\n// ── provenonce_heartbeat ──────────────────────────────────────────────────────\r\n\r\nexport async function handleHeartbeat(args: { payment_tx: string }) {\r\n const creds = requireCredentials();\r\n const { data, error } = await api.heartbeat(creds.api_key, args.payment_tx);\r\n if (error || !data) return err(error ?? 'Heartbeat failed');\r\n\r\n if (!data.ok && data.sigil_required) {\r\n return err('SIGIL required. Call provenonce_purchase_sigil first.');\r\n }\r\n\r\n return ok({\r\n ok: data.ok,\r\n message: data.ok ? 'Heartbeat recorded. Agent liveness confirmed.' : 'Heartbeat failed.',\r\n });\r\n}\r\n\r\n// ── provenonce_get_passport ───────────────────────────────────────────────────\r\n\r\nexport async function handleGetPassport(args: { payment_tx?: string }) {\r\n const creds = requireCredentials();\r\n const { data, error } = await api.getPassport(creds.api_key, args.payment_tx);\r\n if (error || !data) return err(error ?? 'Passport retrieval failed');\r\n\r\n return ok({\r\n passport: data.lineage_proof,\r\n message:\r\n 'Passport issued. Share this signed document with any third party to prove your identity offline.',\r\n _verify:\r\n 'Verify at: GET https://provenonce.io/.well-known/provenonce-authority.json for the authority public key.',\r\n });\r\n}\r\n\r\n// ── provenonce_beats_proof ────────────────────────────────────────────────────\r\n\r\n/**\r\n * Compute a single beat using the canonical Provenonce formula from lib/beat.ts.\r\n * seed = `${prevHash}:${beatIndex}::${anchorHash}` (empty nonce)\r\n * hash = sha256(seed), then sha256(hash) `difficulty` times.\r\n */\r\nfunction computeBeatHash(prevHash: string, beatIndex: number, difficulty: number, anchorHash?: string): string {\r\n const seed = anchorHash\r\n ? `${prevHash}:${beatIndex}::${anchorHash}`\r\n : `${prevHash}:${beatIndex}:`;\r\n\r\n let current = createHash('sha256').update(seed, 'utf8').digest('hex');\r\n for (let i = 0; i < difficulty; i++) {\r\n current = createHash('sha256').update(current, 'utf8').digest('hex');\r\n }\r\n return current;\r\n}\r\n\r\n/**\r\n * Compute a full beats work-proof and submit to the Beats service for a signed receipt.\r\n */\r\nexport async function computeWorkProof(\r\n count: number,\r\n difficulty: number,\r\n): Promise<{ receipt: WorkProofReceipt | null; localProof: { from_hash: string; to_hash: string; beats_computed: number; duration_ms: number }; error?: string }> {\r\n // 1. Fetch current anchor\r\n const anchorRes = await api.fetchAnchor();\r\n const anchor = anchorRes.data?.anchor;\r\n const anchorHash = anchor?.hash;\r\n const anchorIndex = anchor?.beat_index ?? 0;\r\n\r\n // 2. Generate genesis hash\r\n const genesisInput = `provenonce:beats:${randomBytes(16).toString('hex')}`;\r\n const genesisHash = createHash('sha256').update(genesisInput, 'utf8').digest('hex');\r\n\r\n // 3. Compute beats with proper formula + collect spot checks\r\n const spotCheckIndices = selectSpotCheckIndices(count);\r\n const spotChecks: { index: number; hash: string; prev: string }[] = [];\r\n\r\n const start = Date.now();\r\n let prevHash = genesisHash;\r\n\r\n for (let i = 1; i <= count; i++) {\r\n const hash = computeBeatHash(prevHash, i, difficulty, anchorHash);\r\n\r\n if (spotCheckIndices.has(i)) {\r\n spotChecks.push({ index: i, hash, prev: prevHash });\r\n }\r\n\r\n prevHash = hash;\r\n }\r\n\r\n const duration = Date.now() - start;\r\n const fromHash = genesisHash;\r\n const toHash = prevHash;\r\n\r\n const localProof = {\r\n from_hash: fromHash,\r\n to_hash: toHash,\r\n beats_computed: count,\r\n duration_ms: duration,\r\n };\r\n\r\n // 4. Submit to Beats service for a signed receipt\r\n const submitRes = await api.submitWorkProof({\r\n from_hash: fromHash,\r\n to_hash: toHash,\r\n beats_computed: count,\r\n difficulty,\r\n anchor_index: anchorIndex,\r\n anchor_hash: anchorHash,\r\n spot_checks: spotChecks,\r\n });\r\n\r\n if (submitRes.error) {\r\n return { receipt: null, localProof, error: `Beats submission failed: ${submitRes.error}` };\r\n }\r\n\r\n if (!submitRes.data?.valid) {\r\n return { receipt: null, localProof, error: `Beats rejected proof: ${submitRes.data?.reason ?? 'unknown'}` };\r\n }\r\n\r\n return { receipt: submitRes.data.receipt ?? null, localProof };\r\n}\r\n\r\n/**\r\n * Select spot check indices for a given beat count.\r\n * Rules: first beat + last beat + evenly-spaced interior.\r\n * Density: 1 per 1000 beats, min 3.\r\n */\r\nfunction selectSpotCheckIndices(count: number): Set<number> {\r\n const minChecks = 3;\r\n const density = 1000;\r\n const maxChecks = 25;\r\n const needed = Math.max(\r\n Math.min(count, minChecks),\r\n Math.min(Math.ceil(count / density), maxChecks),\r\n );\r\n\r\n const indices = new Set<number>();\r\n indices.add(1); // first beat (genesis binding)\r\n indices.add(count); // last beat (terminal binding)\r\n\r\n // Fill interior evenly\r\n if (needed > 2 && count > 2) {\r\n const interiorNeeded = needed - 2;\r\n for (let j = 1; j <= interiorNeeded; j++) {\r\n const idx = Math.round(1 + (j * (count - 1)) / (interiorNeeded + 1));\r\n if (idx > 1 && idx < count) {\r\n indices.add(idx);\r\n }\r\n }\r\n }\r\n\r\n return indices;\r\n}\r\n\r\nexport async function handleBeatsProof(args: { count: number; difficulty?: number }) {\r\n const count = Math.max(10, Math.min(10000, args.count));\r\n const difficulty = Math.max(100, Math.min(5000, args.difficulty ?? 1000));\r\n\r\n const { receipt, localProof, error } = await computeWorkProof(count, difficulty);\r\n\r\n if (receipt) {\r\n return ok({\r\n ...localProof,\r\n difficulty,\r\n receipt,\r\n message: `Computed ${count} beats at difficulty ${difficulty} in ${localProof.duration_ms}ms. Signed receipt obtained from Beats service.`,\r\n });\r\n }\r\n\r\n return ok({\r\n ...localProof,\r\n difficulty,\r\n receipt: null,\r\n _warning: error ?? 'Could not obtain signed receipt from Beats service.',\r\n message: `Computed ${count} beats locally in ${localProof.duration_ms}ms but receipt not available. ${error ?? ''}`,\r\n });\r\n}\r\n\r\n// ── provenonce_verify_agent ───────────────────────────────────────────────────\r\n\r\nexport async function handleVerifyAgent(args: { hash: string }) {\r\n const { data, error } = await api.verifyAgent(args.hash);\r\n if (error || !data) return err(error ?? 'Verification failed');\r\n return ok(data);\r\n}\r\n\r\n// ── provenonce_spawn ──────────────────────────────────────────────────────────\r\n\r\nexport async function handleSpawn(args: { child_name: string }) {\r\n const creds = requireCredentials();\r\n\r\n // Auto-compute a work-proof receipt for spawn authorization.\r\n // Spawn cost at depth 0 / 0 siblings = 1000 beats. We compute 1050 for margin.\r\n // The spawn endpoint will reject without a receipt when BEATS_REQUIRED=true.\r\n const SPAWN_BEATS = 1050;\r\n const SPAWN_DIFFICULTY = 1000;\r\n\r\n const { receipt, error: proofError } = await computeWorkProof(SPAWN_BEATS, SPAWN_DIFFICULTY);\r\n\r\n if (!receipt) {\r\n return err(\r\n `Failed to obtain Beats work-proof receipt for spawn. ${proofError ?? 'Unknown error'}. ` +\r\n 'You can try calling provenonce_beats_proof with count=1050 manually, then retry spawn.',\r\n );\r\n }\r\n\r\n const { data, error } = await api.spawnChild(creds.api_key, {\r\n childName: args.child_name,\r\n parentHash: creds.agent_hash,\r\n beatsReceipt: receipt,\r\n });\r\n\r\n if (error || !data) return err(error ?? 'Spawn failed');\r\n\r\n return ok({\r\n ...data,\r\n message: `Child agent spawned: ${data.child_hash}. Save the child_api_key — it will not be shown again.`,\r\n _warning: 'The child agent has its own identity. Configure it with PROVENONCE_API_KEY + PROVENONCE_AGENT_HASH.',\r\n });\r\n}\r\n\r\n// ── provenonce_get_lineage ────────────────────────────────────────────────────\r\n\r\nexport async function handleGetLineage(args: { hash?: string }) {\r\n const creds = loadCredentials();\r\n const targetHash = args.hash ?? creds?.agent_hash;\r\n\r\n if (!targetHash) {\r\n return err('No hash provided and agent is not registered. Call provenonce_register first or provide a hash.');\r\n }\r\n\r\n const { data, error } = await api.getLineage(targetHash);\r\n if (error || !data) return err(error ?? 'Lineage retrieval failed');\r\n return ok(data);\r\n}\r\n","import { readFileSync, writeFileSync, mkdirSync, chmodSync, existsSync } from 'fs';\r\nimport { join } from 'path';\r\nimport { homedir } from 'os';\r\nimport type { StoredCredentials } from './types.js';\r\n\r\nfunction getConfigDir(): string {\r\n return join(homedir(), '.provenonce');\r\n}\r\n\r\nfunction getConfigPath(): string {\r\n return join(getConfigDir(), 'config.json');\r\n}\r\n\r\n/** Load credentials — env vars take priority over config file */\r\nexport function loadCredentials(): StoredCredentials | null {\r\n const apiKey = process.env.PROVENONCE_API_KEY;\r\n const agentHash = process.env.PROVENONCE_AGENT_HASH;\r\n\r\n if (apiKey && agentHash) {\r\n return { api_key: apiKey, agent_hash: agentHash };\r\n }\r\n\r\n const configPath = getConfigPath();\r\n if (!existsSync(configPath)) return null;\r\n\r\n try {\r\n const raw = readFileSync(configPath, 'utf-8');\r\n const parsed = JSON.parse(raw) as Partial<StoredCredentials>;\r\n if (parsed.api_key && parsed.agent_hash) {\r\n return { api_key: parsed.api_key, agent_hash: parsed.agent_hash };\r\n }\r\n } catch {\r\n // Corrupt config — treat as missing\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/** Persist credentials to ~/.provenonce/config.json (chmod 600) */\r\nexport function saveCredentials(creds: StoredCredentials): void {\r\n const dir = getConfigDir();\r\n if (!existsSync(dir)) {\r\n mkdirSync(dir, { recursive: true });\r\n }\r\n\r\n const configPath = getConfigPath();\r\n const data: StoredCredentials = {\r\n api_key: creds.api_key,\r\n agent_hash: creds.agent_hash,\r\n };\r\n\r\n writeFileSync(configPath, JSON.stringify(data, null, 2), 'utf-8');\r\n\r\n // chmod 600 — owner read/write only (Unix only; no-op on Windows)\r\n try {\r\n chmodSync(configPath, 0o600);\r\n } catch {\r\n // Windows — chmod not supported; recommend env var instead\r\n }\r\n}\r\n\r\n/** Clear stored credentials */\r\nexport function clearCredentials(): void {\r\n const configPath = getConfigPath();\r\n if (existsSync(configPath)) {\r\n writeFileSync(configPath, '{}', 'utf-8');\r\n }\r\n}\r\n","import type {\r\n RegisterResult,\r\n AgentStatus,\r\n HeartbeatResult,\r\n PassportResult,\r\n SigilResult,\r\n VerifyAgentResult,\r\n LineageResult,\r\n SpawnResult,\r\n AnchorResponse,\r\n WorkProofReceipt,\r\n} from './types.js';\r\n\r\nconst REGISTRY_URL = process.env.PROVENONCE_REGISTRY_URL || 'https://provenonce.io';\r\nconst BEATS_URL = process.env.PROVENONCE_BEATS_URL || 'https://beats.provenonce.dev';\r\n\r\nasync function apiFetch<T>(\r\n path: string,\r\n opts: { method?: string; body?: unknown; apiKey?: string; isPublic?: boolean } = {},\r\n): Promise<{ data: T | null; error: string | null }> {\r\n const headers: Record<string, string> = { 'Content-Type': 'application/json' };\r\n if (opts.apiKey) headers['Authorization'] = `Bearer ${opts.apiKey}`;\r\n\r\n try {\r\n const res = await fetch(`${REGISTRY_URL}${path}`, {\r\n method: opts.method ?? 'GET',\r\n headers,\r\n body: opts.body ? JSON.stringify(opts.body) : undefined,\r\n });\r\n\r\n const json = await res.json() as Record<string, unknown>;\r\n\r\n if (!res.ok) {\r\n const msg = (json.error as string) ?? `HTTP ${res.status}`;\r\n return { data: null, error: msg };\r\n }\r\n\r\n return { data: json as T, error: null };\r\n } catch (err) {\r\n return { data: null, error: (err as Error).message };\r\n }\r\n}\r\n\r\n/** Fetch the latest global anchor from the Registry */\r\nexport async function fetchAnchor(): Promise<{ data: AnchorResponse | null; error: string | null }> {\r\n return apiFetch<AnchorResponse>('/api/v1/beat/anchor');\r\n}\r\n\r\n/** Submit a work-proof to the Beats service for a signed receipt */\r\nexport async function submitWorkProof(proof: {\r\n from_hash: string;\r\n to_hash: string;\r\n beats_computed: number;\r\n difficulty: number;\r\n anchor_index: number;\r\n anchor_hash?: string;\r\n spot_checks: { index: number; hash: string; prev: string }[];\r\n}): Promise<{ data: { valid: boolean; receipt?: WorkProofReceipt; reason?: string } | null; error: string | null }> {\r\n try {\r\n const res = await fetch(`${BEATS_URL}/api/v1/beat/work-proof`, {\r\n method: 'POST',\r\n headers: { 'Content-Type': 'application/json' },\r\n body: JSON.stringify({ work_proof: proof }),\r\n });\r\n\r\n const json = await res.json() as Record<string, unknown>;\r\n if (!res.ok) {\r\n const msg = (json.error as string) ?? `HTTP ${res.status}`;\r\n return { data: null, error: msg };\r\n }\r\n\r\n return { data: json as { valid: boolean; receipt?: WorkProofReceipt; reason?: string }, error: null };\r\n } catch (err) {\r\n return { data: null, error: (err as Error).message };\r\n }\r\n}\r\n\r\n/** Register a new agent (no-wallet path) */\r\nexport async function registerAgent(opts: {\r\n name?: string;\r\n skillRef?: string;\r\n}): Promise<{ data: RegisterResult | null; error: string | null }> {\r\n // Step 1: Obtain a self-service registration token (RFC-010, 5-min TTL)\r\n const tokenRes = await apiFetch<{ token: string }>('/api/v1/register/token', {\r\n method: 'POST',\r\n body: {},\r\n });\r\n if (tokenRes.error || !tokenRes.data?.token) {\r\n return { data: null, error: tokenRes.error ?? 'Failed to obtain registration token' };\r\n }\r\n\r\n // Step 2: Register with the token\r\n const headers: Record<string, string> = {\r\n 'Content-Type': 'application/json',\r\n 'x-registration-token': tokenRes.data.token,\r\n };\r\n try {\r\n const res = await fetch(`${REGISTRY_URL}/api/v1/register`, {\r\n method: 'POST',\r\n headers,\r\n body: JSON.stringify({\r\n name: opts.name,\r\n wallet: 'none',\r\n ...(opts.skillRef ? { ref: opts.skillRef } : {}),\r\n }),\r\n });\r\n const json = await res.json() as Record<string, unknown>;\r\n if (!res.ok) {\r\n return { data: null, error: (json.error as string) ?? `HTTP ${res.status}` };\r\n }\r\n return { data: json as RegisterResult, error: null };\r\n } catch (err) {\r\n return { data: null, error: (err as Error).message };\r\n }\r\n}\r\n\r\n/** Get full agent status */\r\nexport async function getStatus(apiKey: string): Promise<{ data: AgentStatus | null; error: string | null }> {\r\n return apiFetch<AgentStatus>('/api/v1/skill/bootstrap', {\r\n method: 'POST',\r\n apiKey,\r\n body: {},\r\n });\r\n}\r\n\r\n/** Submit heartbeat */\r\nexport async function heartbeat(apiKey: string, paymentTx?: string): Promise<{ data: HeartbeatResult | null; error: string | null }> {\r\n return apiFetch<HeartbeatResult>('/api/v1/agent/heartbeat', {\r\n method: 'POST',\r\n apiKey,\r\n body: { payment_tx: paymentTx },\r\n });\r\n}\r\n\r\n/** Reissue passport / lineage proof */\r\nexport async function getPassport(apiKey: string, paymentTx?: string): Promise<{ data: { lineage_proof: PassportResult } | null; error: string | null }> {\r\n return apiFetch<{ lineage_proof: PassportResult }>('/api/v1/agent/reissue-proof', {\r\n method: 'POST',\r\n apiKey,\r\n body: paymentTx ? { payment_tx: paymentTx } : {},\r\n });\r\n}\r\n\r\n/** Purchase a SIGIL */\r\nexport async function purchaseSigil(apiKey: string, opts: {\r\n name: string;\r\n principal: string;\r\n identity_class: string;\r\n tier: string;\r\n payment_tx: string;\r\n skillRef?: string;\r\n}): Promise<{ data: SigilResult | null; error: string | null }> {\r\n return apiFetch<SigilResult>('/api/v1/sigil', {\r\n method: 'POST',\r\n apiKey,\r\n body: {\r\n name: opts.name,\r\n principal: opts.principal,\r\n identity_class: opts.identity_class,\r\n tier: opts.tier,\r\n payment_tx: opts.payment_tx,\r\n ...(opts.skillRef ? { ref: opts.skillRef } : {}),\r\n },\r\n });\r\n}\r\n\r\n/** Verify another agent's identity (public) */\r\nexport async function verifyAgent(hash: string): Promise<{ data: VerifyAgentResult | null; error: string | null }> {\r\n return apiFetch<VerifyAgentResult>(`/api/v1/verify/${encodeURIComponent(hash)}`);\r\n}\r\n\r\n/** Get agent lineage chain (public) */\r\nexport async function getLineage(hash: string): Promise<{ data: LineageResult | null; error: string | null }> {\r\n return apiFetch<LineageResult>(`/api/v1/agent/lineage/${encodeURIComponent(hash)}`);\r\n}\r\n\r\n/** Spawn a child agent — handles full 3-step flow internally */\r\nexport async function spawnChild(apiKey: string, opts: {\r\n childName: string;\r\n parentHash: string;\r\n beatsReceipt?: WorkProofReceipt;\r\n}): Promise<{ data: SpawnResult | null; error: string | null }> {\r\n // Step 1: Get spawn authorization (include receipt if available)\r\n const step1Body: Record<string, unknown> = { child_name: opts.childName };\r\n if (opts.beatsReceipt) {\r\n step1Body.beats_receipt = opts.beatsReceipt;\r\n }\r\n\r\n const step1 = await apiFetch<{\r\n spawn_authorization: string;\r\n child_name?: string;\r\n }>('/api/v1/agent/spawn', {\r\n method: 'POST',\r\n apiKey,\r\n body: step1Body,\r\n });\r\n\r\n if (step1.error || !step1.data?.spawn_authorization) {\r\n return { data: null, error: step1.error ?? 'Spawn step 1 failed: no authorization returned' };\r\n }\r\n\r\n const spawnAuth = step1.data.spawn_authorization;\r\n\r\n // Step 2: Register the child with the spawn_authorization\r\n const reg = await apiFetch<RegisterResult>('/api/v1/register', {\r\n method: 'POST',\r\n apiKey,\r\n body: {\r\n name: opts.childName,\r\n wallet: 'none',\r\n spawn_authorization: spawnAuth,\r\n },\r\n });\r\n\r\n if (reg.error || !reg.data?.hash) {\r\n return { data: null, error: reg.error ?? 'Spawn step 2 (child registration) failed' };\r\n }\r\n\r\n const childHash = reg.data.hash;\r\n const childApiKey = reg.data.api_key;\r\n\r\n // Step 3: Finalize the spawn\r\n const step3 = await apiFetch<{ ok: boolean }>('/api/v1/agent/spawn', {\r\n method: 'POST',\r\n apiKey,\r\n body: { child_hash: childHash },\r\n });\r\n\r\n if (step3.error) {\r\n return { data: null, error: step3.error };\r\n }\r\n\r\n return {\r\n data: {\r\n child_hash: childHash,\r\n child_api_key: childApiKey,\r\n child_depth: reg.data.depth,\r\n parent_hash: opts.parentHash,\r\n },\r\n error: null,\r\n };\r\n}\r\n"],"mappings":";;;;;;AAAA,SAAS,cAAc;AACvB,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,OACK;;;ACLP,SAAS,YAAY,mBAAmB;;;ACAxC,SAAS,cAAc,eAAe,WAAW,WAAW,kBAAkB;AAC9E,SAAS,YAAY;AACrB,SAAS,eAAe;AAGxB,SAAS,eAAuB;AAC9B,SAAO,KAAK,QAAQ,GAAG,aAAa;AACtC;AAEA,SAAS,gBAAwB;AAC/B,SAAO,KAAK,aAAa,GAAG,aAAa;AAC3C;AAGO,SAAS,kBAA4C;AAC1D,QAAM,SAAS,QAAQ,IAAI;AAC3B,QAAM,YAAY,QAAQ,IAAI;AAE9B,MAAI,UAAU,WAAW;AACvB,WAAO,EAAE,SAAS,QAAQ,YAAY,UAAU;AAAA,EACl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C;AAAA,IAEH,KAAK;AACH,aAAO,kBAAkB,EAAE,MAAM,EAAE,KAAe,CAAC;AAAA,IAErD,KAAK;AACH,aAAO,YAAY,EAAE,YAAY,EAAE,WAAqB,CAAC;AAAA,IAE3D,KAAK;AACH,aAAO,iBAAiB,EAAE,MAAM,EAAE,KAA2B,CAAC;AAAA,IAEhE;AACE,aAAO;AAAA,QACL,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,iBAAiB,IAAI,GAAG,CAAC;AAAA,QACzD,SAAS;AAAA,MACX;AAAA,EACJ;AACF,CAAC;AAGD,eAAe,OAAO;AACpB,QAAM,YAAY,IAAI,qBAAqB;AAC3C,QAAM,OAAO,QAAQ,SAAS;AAChC;AAEA,KAAK,EAAE,MAAM,CAACC,SAAQ;AACpB,UAAQ,OAAO,MAAM,UAAWA,KAAc,OAAO;AAAA,CAAI;AACzD,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["err","data","error","err"]}
package/dist/tools.d.ts CHANGED
@@ -88,9 +88,15 @@ declare const PROVENONCE_TOOLS: readonly [{
88
88
  readonly properties: {
89
89
  readonly count: {
90
90
  readonly type: "integer";
91
- readonly description: "Number of beats to compute (min 10, max 1000)";
91
+ readonly description: "Number of beats to compute (min 10, max 10000)";
92
92
  readonly minimum: 10;
93
- readonly maximum: 1000;
93
+ readonly maximum: 10000;
94
+ };
95
+ readonly difficulty: {
96
+ readonly type: "integer";
97
+ readonly description: "Hash iterations per beat (default 1000, min 100, max 5000). Usually auto-detected from network.";
98
+ readonly minimum: 100;
99
+ readonly maximum: 5000;
94
100
  };
95
101
  };
96
102
  readonly required: readonly ["count"];
package/dist/tools.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // @provenonce/mcp — Provenonce Skill for AI agents
2
2
  import {
3
3
  PROVENONCE_TOOLS
4
- } from "./chunk-COVXPAEW.js";
4
+ } from "./chunk-ONDCXFYW.js";
5
5
  export {
6
6
  PROVENONCE_TOOLS
7
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@provenonce/mcp",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Provenonce Skill — MCP server giving any AI agent cryptographic identity, SIGIL, heartbeat, passport, and beats proofs.",
5
5
  "keywords": ["provenonce", "mcp", "ai-agent", "identity", "provenance", "sigil"],
6
6
  "homepage": "https://provenonce.io",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/tools.ts"],"sourcesContent":["/** Provenonce Skill — 9 MCP tool definitions (JSON Schema) */\r\nexport const PROVENONCE_TOOLS = [\r\n {\r\n name: 'provenonce_register',\r\n description:\r\n 'Register this agent with Provenonce to get a cryptographic identity (hash + API key). ' +\r\n 'Safe to call multiple times — returns existing identity if already registered. ' +\r\n 'No wallet required. Free.',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {\r\n name: {\r\n type: 'string',\r\n description: 'Human-readable name for this agent (optional, max 64 chars)',\r\n maxLength: 64,\r\n },\r\n skill_ref: {\r\n type: 'string',\r\n description:\r\n '16-character hex ref token of the skill that deployed you — for rev-share attribution (optional)',\r\n pattern: '^[0-9a-f]{16}$',\r\n },\r\n },\r\n },\r\n },\r\n\r\n {\r\n name: 'provenonce_status',\r\n description:\r\n 'Get this agent\\'s current Provenonce status: identity, SIGIL, beats balance, and next steps. ' +\r\n 'Requires prior provenonce_register call.',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {},\r\n },\r\n },\r\n\r\n {\r\n name: 'provenonce_purchase_sigil',\r\n description:\r\n 'Purchase a Provenonce SIGIL to unlock full provenance: heartbeat access, signed passport, ' +\r\n 'and a permanent identity record. Requires a Solana payment transaction. ' +\r\n 'SIGIL format: name*principal*tier (e.g. my-agent*acme*ind).',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {\r\n name: {\r\n type: 'string',\r\n description: 'SIGIL name segment — identifies this specific agent (e.g. \"my-agent\")',\r\n },\r\n principal: {\r\n type: 'string',\r\n description: 'Principal segment — identifies the operator or organisation (e.g. \"acme\")',\r\n },\r\n identity_class: {\r\n type: 'string',\r\n enum: ['narrow_task', 'autonomous', 'orchestrator'],\r\n description:\r\n 'Agent identity class (pricing axis): narrow_task=single-purpose, autonomous=independent decision-maker, orchestrator=coordinates other agents',\r\n },\r\n tier: {\r\n type: 'string',\r\n enum: ['sov', 'org', 'ind', 'eph', 'sbx'],\r\n description:\r\n 'Trust governance tier: sov=sovereign/root, org=organisation, ind=individual, eph=ephemeral, sbx=sandbox',\r\n },\r\n payment_tx: {\r\n type: 'string',\r\n description: 'Solana transaction signature for the SIGIL fee payment',\r\n },\r\n },\r\n required: ['name', 'principal', 'identity_class', 'tier', 'payment_tx'],\r\n },\r\n },\r\n\r\n {\r\n name: 'provenonce_heartbeat',\r\n description:\r\n 'Submit a heartbeat to prove this agent is alive. Requires a SIGIL (call provenonce_purchase_sigil first). ' +\r\n 'Requires a Solana payment transaction for the heartbeat fee.',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {\r\n payment_tx: {\r\n type: 'string',\r\n description: 'Solana transaction signature for the heartbeat fee payment',\r\n },\r\n },\r\n required: ['payment_tx'],\r\n },\r\n },\r\n\r\n {\r\n name: 'provenonce_get_passport',\r\n description:\r\n 'Get this agent\\'s cryptographically signed Passport — a verifiable identity document ' +\r\n 'any third party can verify offline using the Provenonce authority public key. ' +\r\n 'Requires an active SIGIL and at least one heartbeat.',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {\r\n payment_tx: {\r\n type: 'string',\r\n description: 'Solana transaction signature for the passport reissue fee (if applicable)',\r\n },\r\n },\r\n },\r\n },\r\n\r\n {\r\n name: 'provenonce_beats_proof',\r\n description:\r\n 'Compute a local Beats work-proof — cryptographic evidence of computational effort by this agent. ' +\r\n 'Returns a hash chain proof that can be shared as evidence of work. No network call required.',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {\r\n count: {\r\n type: 'integer',\r\n description: 'Number of beats to compute (min 10, max 1000)',\r\n minimum: 10,\r\n maximum: 1000,\r\n },\r\n },\r\n required: ['count'],\r\n },\r\n },\r\n\r\n {\r\n name: 'provenonce_verify_agent',\r\n description:\r\n 'Verify another agent\\'s Provenonce identity. Returns their SIGIL, identity class, and registration status. ' +\r\n 'Public — no authentication required.',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {\r\n hash: {\r\n type: 'string',\r\n description: 'The agent hash to verify (0x + 64 hex chars)',\r\n pattern: '^0x[0-9a-fA-F]{64}$',\r\n },\r\n },\r\n required: ['hash'],\r\n },\r\n },\r\n\r\n {\r\n name: 'provenonce_spawn',\r\n description:\r\n 'Spawn a child agent under this agent\\'s identity. The child inherits lineage from the parent. ' +\r\n 'Returns the child\\'s hash and API key. Requires sufficient beats balance or a work-proof receipt.',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {\r\n child_name: {\r\n type: 'string',\r\n description: 'Name for the child agent (max 64 chars)',\r\n maxLength: 64,\r\n },\r\n },\r\n required: ['child_name'],\r\n },\r\n },\r\n\r\n {\r\n name: 'provenonce_get_lineage',\r\n description:\r\n 'Get the full lineage chain for an agent — all events in its provenance history ' +\r\n '(registration, SIGIL issuance, heartbeats, spawns). Public — no authentication required.',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {\r\n hash: {\r\n type: 'string',\r\n description:\r\n 'The agent hash to get lineage for (0x + 64 hex chars). Defaults to this agent if omitted.',\r\n pattern: '^0x[0-9a-fA-F]{64}$',\r\n },\r\n },\r\n },\r\n },\r\n] as const;\r\n\r\nexport type ToolName = (typeof PROVENONCE_TOOLS)[number]['name'];\r\n"],"mappings":";;;AACO,IAAM,mBAAmB;AAAA,EAC9B;AAAA,IACE,MAAM;AAAA,IACN,aACE;AAAA,IAGF,aAAa;AAAA,MACX,MAAM;AAAA,MACN,YAAY;AAAA,QACV,MAAM;AAAA,UACJ,MAAM;AAAA,UACN,aAAa;AAAA,UACb,WAAW;AAAA,QACb;AAAA,QACA,WAAW;AAAA,UACT,MAAM;AAAA,UACN,aACE;AAAA,UACF,SAAS;AAAA,QACX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