tersign 0.4.5 → 0.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -3,13 +3,21 @@ const sub = process.argv[2];
3
3
  if (sub === undefined || sub === 'mcp') {
4
4
  if (sub === 'mcp')
5
5
  process.argv.splice(2, 1);
6
- // Bare `npx tersign` with no config is almost always a curious human, not an MCP client —
7
- // greet them with the wiring instructions instead of a stack trace.
8
- if (!process.env.TERSIGN_SELLER_KEY) {
9
- console.error('tersign: this command starts the MCP server, which needs TERSIGN_SELLER_KEY set.\n\n' +
10
- 'Wire it into your MCP client config:\n' +
11
- ' { "mcpServers": { "tersign": { "command": "npx", "args": ["tersign"],\n' +
12
- ' "env": { "TERSIGN_SELLER_KEY": "0x<your-seller-key>" } } } }\n\n' +
6
+ // Bare `npx tersign` at a prompt is almost always a curious human, not an MCP client — greet
7
+ // them rather than sitting mute on a stdio transport they are not speaking. The discriminator
8
+ // is the TTY, NOT the presence of a key: an MCP client, a directory's sandbox and a CI probe
9
+ // all arrive with stdin piped, and until 2026-08-29 every one of them hit a hard exit here.
10
+ // That made `npx tersign` fail on first run for anyone who had not already exported a key,
11
+ // left the server impossible to introspect or demonstrate anywhere, and contradicted
12
+ // record_disclosure's own published promise that the first call self-provisions. The key is
13
+ // no longer required — envDeps resolves through the shared keystore — so the greeting is now
14
+ // a courtesy for humans instead of a gate on everyone.
15
+ if (process.stdin.isTTY && !process.env.TERSIGN_SELLER_KEY) {
16
+ console.error('tersign: this starts the MCP server, which speaks JSON-RPC over stdin — nothing to see\n' +
17
+ 'at a prompt. Wire it into your MCP client config:\n\n' +
18
+ ' { "mcpServers": { "tersign": { "command": "npx", "args": ["tersign"] } } }\n\n' +
19
+ 'No key needed: the first call self-provisions a signer-keyed account (OS keychain,\n' +
20
+ 'else ~/.tersign/signer.key). Set TERSIGN_SELLER_KEY to use your own.\n\n' +
13
21
  "Just exploring? Try: tersign help · tersign verify <receipt.json | 0xdigest> [--ledger url]");
14
22
  process.exit(1);
15
23
  }
@@ -8,6 +8,6 @@ export declare function envDeps(env?: Record<string, string | undefined>): McpDe
8
8
  * every client; mcp.test.ts pins it against package.json so a release bump can't drift it. */
9
9
  export declare const MCP_SERVER_IDENTITY: {
10
10
  readonly name: "tersign";
11
- readonly version: "0.4.5";
11
+ readonly version: "0.4.7";
12
12
  };
13
13
  export declare function buildServer(deps: McpDeps): McpServer;
@@ -3,14 +3,18 @@ import { z } from 'zod';
3
3
  import { privateKeyToAccount } from 'viem/accounts';
4
4
  import { Assure } from '../assure.js';
5
5
  import { LedgerClient } from '../ledgerClient.js';
6
+ import { resolveSignerKey } from '../keystore.js';
6
7
  import { adjudicateDisputeTool, getDisputeTool, issueReceiptTool, openDisputeTool, recordDisclosureTool, recordRefundTool, submitEvidenceTool, verifyReceiptTool, verifyRecordTool, } from './tools.js';
7
8
  /** MCP packaging: exposes assure as tools any MCP-speaking agent can call, so an agent
8
9
  * (or its framework) can issue, verify, and chain receipts without importing the SDK.
9
10
  * Config via env — see envDeps(). */
10
11
  export function envDeps(env = process.env) {
11
- const key = env.TERSIGN_SELLER_KEY;
12
- if (!key)
13
- throw new Error('TERSIGN_SELLER_KEY (0x-prefixed private key) is required');
12
+ // Same key resolution as the CLI surfaces: TERSIGN_SELLER_KEY, else the OS keychain, else a
13
+ // 0600 keyfile, else generate one and persist it. record_disclosure's own description promises
14
+ // that first call self-provisions a signer-keyed account; before this the MCP entry point threw
15
+ // instead, so `npx tersign` died on first run for anyone who had not already exported a key —
16
+ // and no directory or sandbox could introspect the server at all.
17
+ const key = env.TERSIGN_SELLER_KEY ?? resolveSignerKey({ create: true }).key;
14
18
  const account = privateKeyToAccount(key);
15
19
  const assure = new Assure({
16
20
  signer: account,
@@ -45,7 +49,7 @@ function json(value) {
45
49
  }
46
50
  /** MUST match package.json name/version — the MCP handshake self-reports this identity to
47
51
  * every client; mcp.test.ts pins it against package.json so a release bump can't drift it. */
48
- export const MCP_SERVER_IDENTITY = { name: 'tersign', version: '0.4.5' };
52
+ export const MCP_SERVER_IDENTITY = { name: 'tersign', version: '0.4.7' };
49
53
  export function buildServer(deps) {
50
54
  const server = new McpServer(MCP_SERVER_IDENTITY);
51
55
  server.registerTool('issue_receipt', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tersign",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
4
  "description": "Tersign \u2014 the evidence layer for the agent economy. Counter-signed receipts, agent action records, idempotency enforcement, refunds, disputes, and jury-ready evidence envelopes for x402/agent-commerce sellers.",
5
5
  "license": "MIT",
6
6
  "type": "module",