@provenonce/mcp 1.0.3 β†’ 1.0.5

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
@@ -1,153 +1,126 @@
1
- # MCP Registry
2
-
3
- The MCP registry provides MCP clients with a list of MCP servers, like an app store for MCP servers.
4
-
5
- [**πŸ“€ Publish my MCP server**](docs/modelcontextprotocol-io/quickstart.mdx) | [**⚑️ Live API docs**](https://registry.modelcontextprotocol.io/docs) | [**πŸ‘€ Ecosystem vision**](docs/design/ecosystem-vision.md) | πŸ“– **[Full documentation](./docs)**
6
-
7
- ## Development Status
8
-
9
- **2025-10-24 update**: The Registry API has entered an **API freeze (v0.1)** πŸŽ‰. For the next month or more, the API will remain stable with no breaking changes, allowing integrators to confidently implement support. This freeze applies to v0.1 while development continues on v0. We'll use this period to validate the API in real-world integrations and gather feedback to shape v1 for general availability. Thank you to everyone for your contributions and patienceβ€”your involvement has been key to getting us here!
10
-
11
- **2025-09-08 update**: The registry has launched in preview πŸŽ‰ ([announcement blog post](https://blog.modelcontextprotocol.io/posts/2025-09-08-mcp-registry-preview/)). While the system is now more stable, this is still a preview release and breaking changes or data resets may occur. A general availability (GA) release will follow later. We'd love your feedback in [GitHub discussions](https://github.com/modelcontextprotocol/registry/discussions/new?category=ideas) or in the [#registry-dev Discord](https://discord.com/channels/1358869848138059966/1369487942862504016) ([joining details here](https://modelcontextprotocol.io/community/communication)).
12
-
13
- Current key maintainers:
14
- - **Adam Jones** (Anthropic) [@domdomegg](https://github.com/domdomegg)
15
- - **Tadas Antanavicius** (PulseMCP) [@tadasant](https://github.com/tadasant)
16
- - **Toby Padilla** (GitHub) [@toby](https://github.com/toby)
17
- - **Radoslav (Rado) Dimitrov** (Stacklok) [@rdimitrov](https://github.com/rdimitrov)
18
-
19
- ## Contributing
20
-
21
- We use multiple channels for collaboration - see [modelcontextprotocol.io/community/communication](https://modelcontextprotocol.io/community/communication).
22
-
23
- Often (but not always) ideas flow through this pipeline:
24
-
25
- - **[Discord](https://modelcontextprotocol.io/community/communication)** - Real-time community discussions
26
- - **[Discussions](https://github.com/modelcontextprotocol/registry/discussions)** - Propose and discuss product/technical requirements
27
- - **[Issues](https://github.com/modelcontextprotocol/registry/issues)** - Track well-scoped technical work
28
- - **[Pull Requests](https://github.com/modelcontextprotocol/registry/pulls)** - Contribute work towards issues
29
-
30
- ### Quick start:
31
-
32
- #### Pre-requisites
33
-
34
- - **Docker**
35
- - **Go 1.24.x**
36
- - **ko** - Container image builder for Go ([installation instructions](https://ko.build/install/))
37
- - **golangci-lint v2.4.0**
38
-
39
- #### Running the server
40
-
41
- ```bash
42
- # Start full development environment
43
- make dev-compose
44
- ```
45
-
46
- This starts the registry at [`localhost:8080`](http://localhost:8080) with PostgreSQL. The database uses ephemeral storage and is reset each time you restart the containers, ensuring a clean state for development and testing.
47
-
48
- **Note:** The registry uses [ko](https://ko.build) to build container images. The `make dev-compose` command automatically builds the registry image with ko and loads it into your local Docker daemon before starting the services.
49
-
50
- By default, the registry seeds from the production API with a filtered subset of servers (to keep startup fast). This ensures your local environment mirrors production behavior and all seed data passes validation. For offline development you can seed from a file without validation with `MCP_REGISTRY_SEED_FROM=data/seed.json MCP_REGISTRY_ENABLE_REGISTRY_VALIDATION=false make dev-compose`.
51
-
52
- The setup can be configured with environment variables in [docker-compose.yml](./docker-compose.yml) - see [.env.example](./.env.example) for a reference.
53
-
54
- <details>
55
- <summary>Alternative: Running a pre-built Docker image</summary>
56
-
57
- Pre-built Docker images are automatically published to GitHub Container Registry:
58
-
59
- ```bash
60
- # Run latest stable release
61
- docker run -p 8080:8080 ghcr.io/modelcontextprotocol/registry:latest
62
-
63
- # Run latest from main branch (continuous deployment)
64
- docker run -p 8080:8080 ghcr.io/modelcontextprotocol/registry:main
65
-
66
- # Run specific release version
67
- docker run -p 8080:8080 ghcr.io/modelcontextprotocol/registry:v1.0.0
68
-
69
- # Run development build from main branch
70
- docker run -p 8080:8080 ghcr.io/modelcontextprotocol/registry:main-20250906-abc123d
71
- ```
72
-
73
- **Available tags:**
74
- - **Releases**: `latest`, `v1.0.0`, `v1.1.0`, etc.
75
- - **Continuous**: `main` (latest main branch build)
76
- - **Development**: `main-<date>-<sha>` (specific commit builds)
77
-
78
- </details>
79
-
80
- #### Publishing a server
81
-
82
- To publish a server, we've built a simple CLI. You can use it with:
83
-
84
- ```bash
85
- # Build the latest CLI
86
- make publisher
87
-
88
- # Use it!
89
- ./bin/mcp-publisher --help
90
- ```
91
-
92
- See [the publisher guide](./docs/modelcontextprotocol-io/quickstart.mdx) for more details.
93
-
94
- #### Other commands
95
-
96
- ```bash
97
- # Run lint, unit tests and integration tests
98
- make check
99
- ```
100
-
101
- There are also a few more helpful commands for development. Run `make help` to learn more, or look in [Makefile](./Makefile).
102
-
103
- <!--
104
- For Claude and other AI tools: Always prefer make targets over custom commands where possible.
105
- -->
106
-
107
- ## Architecture
108
-
109
- ### Project Structure
110
-
111
- ```
112
- β”œβ”€β”€ cmd/ # Application entry points
113
- β”‚ └── publisher/ # Server publishing tool
114
- β”œβ”€β”€ data/ # Seed data
115
- β”œβ”€β”€ deploy/ # Deployment configuration (Pulumi)
116
- β”œβ”€β”€ docs/ # Documentation
117
- β”œβ”€β”€ internal/ # Private application code
118
- β”‚ β”œβ”€β”€ api/ # HTTP handlers and routing
119
- β”‚ β”œβ”€β”€ auth/ # Authentication (GitHub OAuth, JWT, namespace blocking)
120
- β”‚ β”œβ”€β”€ config/ # Configuration management
121
- β”‚ β”œβ”€β”€ database/ # Data persistence (PostgreSQL)
122
- β”‚ β”œβ”€β”€ service/ # Business logic
123
- β”‚ β”œβ”€β”€ telemetry/ # Metrics and monitoring
124
- β”‚ └── validators/ # Input validation
125
- β”œβ”€β”€ pkg/ # Public packages
126
- β”‚ β”œβ”€β”€ api/ # API types and structures
127
- β”‚ β”‚ └── v0/ # Version 0 API types
128
- β”‚ └── model/ # Data models for server.json
129
- β”œβ”€β”€ scripts/ # Development and testing scripts
130
- β”œβ”€β”€ tests/ # Integration tests
131
- └── tools/ # CLI tools and utilities
132
- └── validate-*.sh # Schema validation tools
133
- ```
134
-
135
- ### Authentication
136
-
137
- Publishing supports multiple authentication methods:
138
- - **GitHub OAuth** - For publishing by logging into GitHub
139
- - **GitHub OIDC** - For publishing from GitHub Actions
140
- - **DNS verification** - For proving ownership of a domain and its subdomains
141
- - **HTTP verification** - For proving ownership of a domain
142
-
143
- The registry validates namespace ownership when publishing. E.g. to publish...:
144
- - `io.github.domdomegg/my-cool-mcp` you must login to GitHub as `domdomegg`, or be in a GitHub Action on domdomegg's repos
145
- - `me.adamjones/my-cool-mcp` you must prove ownership of `adamjones.me` via DNS or HTTP challenge
146
-
147
- ## Community Projects
148
-
149
- Check out [community projects](docs/community-projects.md) to explore notable registry-related work created by the community.
150
-
151
- ## More documentation
152
-
153
- See the [documentation](./docs) for more details if your question has not been answered here!
1
+ # @provenonce/mcp
2
+
3
+ **Provenonce Skill** β€” Give any AI agent cryptographic identity in under 60 seconds.
4
+
5
+ Add this skill to your agent and it gets:
6
+ - A permanent cryptographic hash (identity)
7
+ - A SIGIL (verified identity class + tier)
8
+ - A signed Passport (verifiable offline by any third party)
9
+ - Heartbeat (continuous liveness proof)
10
+ - Beats proofs (evidence of computational work)
11
+ - Lineage (full ancestry chain)
12
+
13
+ ## Quick Start
14
+
15
+ ### Claude Desktop / Claude Code
16
+
17
+ Add to `~/.claude/claude_desktop_config.json`:
18
+
19
+ ```json
20
+ {
21
+ "mcpServers": {
22
+ "provenonce": {
23
+ "command": "npx",
24
+ "args": ["-y", "@provenonce/mcp"]
25
+ }
26
+ }
27
+ }
28
+ ```
29
+
30
+ That's it. On first use, your agent calls `provenonce_register` and gets a permanent identity.
31
+
32
+ ### With pre-existing credentials
33
+
34
+ ```json
35
+ {
36
+ "mcpServers": {
37
+ "provenonce": {
38
+ "command": "npx",
39
+ "args": ["-y", "@provenonce/mcp"],
40
+ "env": {
41
+ "PROVENONCE_API_KEY": "pvn_...",
42
+ "PROVENONCE_AGENT_HASH": "0x..."
43
+ }
44
+ }
45
+ }
46
+ }
47
+ ```
48
+
49
+ ### As a skill developer (earn rev share)
50
+
51
+ If you're a developer embedding this skill in your framework, include your partner ref token:
52
+
53
+ ```json
54
+ {
55
+ "env": {
56
+ "PROVENONCE_SKILL_REF": "your16hextoken"
57
+ }
58
+ }
59
+ ```
60
+
61
+ You earn 30% of every SIGIL purchased by agents you deploy. Register at `POST /api/v1/skill/register`.
62
+
63
+ ## The 9 Tools
64
+
65
+ | Tool | What it does | Auth needed |
66
+ |------|-------------|-------------|
67
+ | `provenonce_register` | Auto-register agent, get hash + API key | None |
68
+ | `provenonce_status` | Full current state (SIGIL, balance, hints) | Yes |
69
+ | `provenonce_purchase_sigil` | Buy SIGIL, unlock heartbeat + passport | Yes + SOL tx |
70
+ | `provenonce_heartbeat` | Submit liveness proof | Yes + SOL tx |
71
+ | `provenonce_get_passport` | Get signed identity document | Yes |
72
+ | `provenonce_beats_proof` | Compute local work proof | None |
73
+ | `provenonce_verify_agent` | Check another agent's identity | None |
74
+ | `provenonce_spawn` | Spawn a child agent | Yes |
75
+ | `provenonce_get_lineage` | Get full ancestry chain | None |
76
+
77
+ ## Agent Flow
78
+
79
+ ```
80
+ Day 1: provenonce_register β†’ hash minted, credentials saved
81
+ provenonce_beats_proof β†’ works immediately, no SIGIL needed
82
+ provenonce_status β†’ { sigil: null, _hint: "Call provenonce_purchase_sigil..." }
83
+
84
+ Day 7: provenonce_purchase_sigil β†’ pay SOL, SIGIL issued
85
+ provenonce_heartbeat β†’ now unlocked
86
+ provenonce_get_passport β†’ signed identity doc, share with anyone
87
+ provenonce_verify_agent β†’ verify a counterparty before trusting them
88
+ ```
89
+
90
+ ## Environment Variables
91
+
92
+ | Variable | Description | Default |
93
+ |----------|-------------|---------|
94
+ | `PROVENONCE_API_KEY` | Agent API key (pvn_...) | Read from ~/.provenonce/config.json |
95
+ | `PROVENONCE_AGENT_HASH` | Agent hash (0x...) | Read from ~/.provenonce/config.json |
96
+ | `PROVENONCE_SKILL_REF` | Your partner ref token (for rev share) | None |
97
+ | `PROVENONCE_REGISTRY_URL` | Registry URL override | https://provenonce.io |
98
+
99
+ ## Framework-Agnostic Usage
100
+
101
+ ```typescript
102
+ import { PROVENONCE_TOOLS } from '@provenonce/mcp/tools';
103
+
104
+ // OpenAI
105
+ const tools = PROVENONCE_TOOLS.map(t => ({ type: 'function', function: t }));
106
+
107
+ // LangChain / custom β€” use PROVENONCE_TOOLS for schema, implement handlers yourself
108
+ ```
109
+
110
+ ## Credential Storage
111
+
112
+ Credentials are stored in `~/.provenonce/config.json` with `chmod 600` permissions (Unix).
113
+
114
+ On Windows, use environment variables (`PROVENONCE_API_KEY` + `PROVENONCE_AGENT_HASH`) β€” file permissions are not enforced.
115
+
116
+ ## What's Coming
117
+
118
+ - `provenonce_kyc` β€” KYC / identity class upgrade
119
+ - Auto-heartbeat timer (opt-in)
120
+ - Python SDK (`provenonce-mcp`)
121
+
122
+ ## Links
123
+
124
+ - Registry: [provenonce.io](https://provenonce.io)
125
+ - Docs: [provenonce.dev](https://provenonce.dev)
126
+ - API: [provenonce.io/openapi.yaml](https://provenonce.io/openapi.yaml)
package/dist/index.js CHANGED
@@ -81,14 +81,35 @@ async function apiFetch(path, opts = {}) {
81
81
  }
82
82
  }
83
83
  async function registerAgent(opts) {
84
- return apiFetch("/api/v1/register", {
84
+ const tokenRes = await apiFetch("/api/v1/register/token", {
85
85
  method: "POST",
86
- body: {
87
- name: opts.name,
88
- wallet: "none",
89
- ...opts.skillRef ? { ref: opts.skillRef } : {}
90
- }
86
+ body: {}
91
87
  });
88
+ if (tokenRes.error || !tokenRes.data?.token) {
89
+ return { data: null, error: tokenRes.error ?? "Failed to obtain registration token" };
90
+ }
91
+ const headers = {
92
+ "Content-Type": "application/json",
93
+ "x-registration-token": tokenRes.data.token
94
+ };
95
+ try {
96
+ const res = await fetch(`${REGISTRY_URL}/api/v1/register`, {
97
+ method: "POST",
98
+ headers,
99
+ body: JSON.stringify({
100
+ name: opts.name,
101
+ wallet: "none",
102
+ ...opts.skillRef ? { ref: opts.skillRef } : {}
103
+ })
104
+ });
105
+ const json = await res.json();
106
+ if (!res.ok) {
107
+ return { data: null, error: json.error ?? `HTTP ${res.status}` };
108
+ }
109
+ return { data: json, error: null };
110
+ } catch (err2) {
111
+ return { data: null, error: err2.message };
112
+ }
92
113
  }
93
114
  async function getStatus(apiKey) {
94
115
  return apiFetch("/api/v1/skill/bootstrap", {
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 return apiFetch<RegisterResult>('/api/v1/register', {\r\n method: 'POST',\r\n body: {\r\n name: opts.name,\r\n wallet: 'none',\r\n ...(opts.skillRef ? { ref: opts.skillRef } : {}),\r\n },\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,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,EAClD;AAEA,QAAM,aAAa,cAAc;AACjC,MAAI,CAAC,WAAW,UAAU,EAAG,QAAO;AAEpC,MAAI;AACF,UAAM,MAAM,aAAa,YAAY,OAAO;AAC5C,UAAM,SAAS,KAAK,MAAM,GAAG;AAC7B,QAAI,OAAO,WAAW,OAAO,YAAY;AACvC,aAAO,EAAE,SAAS,OAAO,SAAS,YAAY,OAAO,WAAW;AAAA,IAClE;AAAA,EACF,QAAQ;AAAA,EAER;AAEA,SAAO;AACT;AAGO,SAAS,gBAAgB,OAAgC;AAC9D,QAAM,MAAM,aAAa;AACzB,MAAI,CAAC,WAAW,GAAG,GAAG;AACpB,cAAU,KAAK,EAAE,WAAW,KAAK,CA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Q,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({ 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,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,EAClD;AAEA,QAAM,aAAa,cAAc;AACjC,MAAI,CAAC,WAAW,UAAU,EAAG,QAAO;AAEpC,MAAI;AACF,UAAM,MAAM,aAAa,YAAY,OAAO;AAC5C,UAAM,SAAS,KAAK,MAAM,GAAG;AAC7B,QAAI,OAAO,WAAW,OAAO,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AACH,aAAO,aAAa;AAAA,IAEtB,KAAK;AACH,aAAO,oBAAoB;AAAA,QACzB,MAAM,EAAE;AAAA,QACR,WAAW,EAAE;AAAA,QACb,gBAAgB,EAAE;AAAA,QAClB,MAAM,EAAE;AAAA,QACR,YAAY,EAAE;AAAA,MAChB,CAAC;AAAA,IAEH,KAAK;AACH,aAAO,gBAAgB,EAAE,YAAY,EAAE,WAAqB,CAAC;AAAA,IAE/D,KAAK;AACH,aAAO,kBAAkB,EAAE,YAAY,EAAE,WAAiC,CAAC;AAAA,IAE7E,KAAK;AACH,aAAO,iBAAiB,EAAE,OAAO,EAAE,MAAgB,CAAC;AAAA,IAEtD,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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@provenonce/mcp",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
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",