@truealter/sdk 0.0.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +17 -0
- package/README.md +441 -1
- package/dist/bin/alter-identity.js +1330 -0
- package/dist/bin/alter-identity.js.map +1 -0
- package/dist/bin/mcp-bridge.js +491 -0
- package/dist/bin/mcp-bridge.js.map +1 -0
- package/dist/index.cjs +1316 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1470 -0
- package/dist/index.d.ts +1470 -0
- package/dist/index.js +1253 -0
- package/dist/index.js.map +1 -0
- package/package.json +62 -8
- package/index.js +0 -1
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1470 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP endpoint discovery.
|
|
3
|
+
*
|
|
4
|
+
* Implements the three-step discovery cascade defined in
|
|
5
|
+
* `draft-morrison-mcp-dns-discovery-01`:
|
|
6
|
+
*
|
|
7
|
+
* 1. DNS TXT record at `_mcp.<domain>` with `mcp=<url>` attribute
|
|
8
|
+
* 2. HTTPS GET `https://<domain>/.well-known/mcp.json`
|
|
9
|
+
* 3. HTTPS GET `https://<domain>/.well-known/alter.json`
|
|
10
|
+
*
|
|
11
|
+
* The DNS lookup is only attempted in environments that expose `dns`
|
|
12
|
+
* (Node, Bun, Deno with the node compatibility layer). Browsers and
|
|
13
|
+
* Cloudflare Workers fall through to the `.well-known` lookups.
|
|
14
|
+
*/
|
|
15
|
+
interface DiscoveryResult {
|
|
16
|
+
/** Resolved MCP endpoint URL. */
|
|
17
|
+
url: string;
|
|
18
|
+
/** MCP transport — currently always `streamable-http`. */
|
|
19
|
+
transport: 'streamable-http';
|
|
20
|
+
/** Source of the discovery hit, useful for diagnostics. */
|
|
21
|
+
source: 'dns' | 'mcp.json' | 'alter.json' | 'override';
|
|
22
|
+
/** Optional Ed25519 public key from `alter.json` for provenance verification. */
|
|
23
|
+
publicKey?: string;
|
|
24
|
+
/** Optional x402 contract address. */
|
|
25
|
+
x402Contract?: string;
|
|
26
|
+
/** Capability level (E1-E4) when present. */
|
|
27
|
+
capability?: string;
|
|
28
|
+
/** Raw discovery document, kept for callers that want to inspect it. */
|
|
29
|
+
raw?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
interface DiscoveryOptions {
|
|
32
|
+
/** Cache hits in memory for the duration of this process. Default true. */
|
|
33
|
+
cache?: boolean;
|
|
34
|
+
/** Skip DNS lookup even when available. */
|
|
35
|
+
skipDns?: boolean;
|
|
36
|
+
/** Per-request timeout in milliseconds. Default 5_000. */
|
|
37
|
+
timeoutMs?: number;
|
|
38
|
+
/** Override fetch implementation (for testing). */
|
|
39
|
+
fetch?: typeof fetch;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Resolve the ALTER MCP endpoint for `domain`.
|
|
43
|
+
*
|
|
44
|
+
* Order: cache → DNS TXT → mcp.json → alter.json. Throws
|
|
45
|
+
* {@link AlterDiscoveryError} if every step fails.
|
|
46
|
+
*/
|
|
47
|
+
declare function discover(domain: string, opts?: DiscoveryOptions): Promise<DiscoveryResult>;
|
|
48
|
+
/** Wipe the in-memory discovery cache. */
|
|
49
|
+
declare function clearDiscoveryCache(): void;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Ed25519 keypair management for ALTER Identity.
|
|
53
|
+
*
|
|
54
|
+
* Uses @noble/ed25519 — pure JavaScript, no native addons, runs in
|
|
55
|
+
* Node 18+, Deno, Bun, Cloudflare Workers and the browser.
|
|
56
|
+
*
|
|
57
|
+
* Keys are stored as hex strings for portability. The CLI persists them
|
|
58
|
+
* to `~/.config/alter/keys.json` (Node-only); other environments must
|
|
59
|
+
* supply their own storage.
|
|
60
|
+
*/
|
|
61
|
+
interface Ed25519Keypair {
|
|
62
|
+
/** 32-byte private key as hex. */
|
|
63
|
+
privateKey: string;
|
|
64
|
+
/** 32-byte public key as hex. */
|
|
65
|
+
publicKey: string;
|
|
66
|
+
/** `ed25519:<base64url-public-key>` form used in `.well-known/alter.json`. */
|
|
67
|
+
did: string;
|
|
68
|
+
}
|
|
69
|
+
interface ApiKeyConfig {
|
|
70
|
+
/** Opaque API key issued by ALTER. Begins with `ak_`. */
|
|
71
|
+
key: string;
|
|
72
|
+
/** Optional `~handle` the key is bound to. */
|
|
73
|
+
handle?: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Generate a fresh Ed25519 keypair.
|
|
77
|
+
*
|
|
78
|
+
* The private key never leaves the SDK process unless the caller chooses
|
|
79
|
+
* to persist it. Callers are responsible for safe storage.
|
|
80
|
+
*/
|
|
81
|
+
declare function generateKeypair(): Ed25519Keypair;
|
|
82
|
+
/**
|
|
83
|
+
* Reconstruct the keypair from a stored private key (hex).
|
|
84
|
+
*/
|
|
85
|
+
declare function keypairFromPrivateKey(privateKeyHex: string): Ed25519Keypair;
|
|
86
|
+
/**
|
|
87
|
+
* Sign an arbitrary message with an Ed25519 private key.
|
|
88
|
+
* Returns the signature as hex.
|
|
89
|
+
*/
|
|
90
|
+
declare function sign(privateKeyHex: string, message: Uint8Array | string): Promise<string>;
|
|
91
|
+
/**
|
|
92
|
+
* Verify an Ed25519 signature.
|
|
93
|
+
*/
|
|
94
|
+
declare function verify(publicKeyHex: string, signatureHex: string, message: Uint8Array | string): Promise<boolean>;
|
|
95
|
+
/**
|
|
96
|
+
* Encode a 32-byte public key as the `ed25519:<base64url>` form used by
|
|
97
|
+
* ALTER's `.well-known/alter.json` discovery anchor.
|
|
98
|
+
*/
|
|
99
|
+
declare function encodeDid(publicKey: Uint8Array | string): string;
|
|
100
|
+
/**
|
|
101
|
+
* Decode a `did:key` style identifier or the ALTER `ed25519:` form back
|
|
102
|
+
* into raw bytes. Throws if the encoding is unrecognised.
|
|
103
|
+
*/
|
|
104
|
+
declare function decodeDid(did: string): Uint8Array;
|
|
105
|
+
declare function base64urlEncode(bytes: Uint8Array): string;
|
|
106
|
+
declare function base64urlDecode(input: string): Uint8Array;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* ES256 provenance verification.
|
|
110
|
+
*
|
|
111
|
+
* ALTER signs medium- and high-blast-radius MCP responses with an ES256
|
|
112
|
+
* JWS attestation in `_meta.provenance.token`. The signing key rotates
|
|
113
|
+
* periodically and is published at `<api-host>/.well-known/alter-keys.json`
|
|
114
|
+
* as a JWKS.
|
|
115
|
+
*
|
|
116
|
+
* This module verifies tokens *without* a JWT library — pure WebCrypto
|
|
117
|
+
* (subtle.verify) keeps the dep graph small and works in every modern
|
|
118
|
+
* runtime (Node 18+, Deno, Bun, Cloudflare Workers, browser).
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
interface ProvenanceEnvelope {
|
|
122
|
+
version: string;
|
|
123
|
+
token: string;
|
|
124
|
+
purpose?: string;
|
|
125
|
+
expires_at?: string;
|
|
126
|
+
tool?: string;
|
|
127
|
+
blast_radius?: 'low' | 'medium' | 'high';
|
|
128
|
+
verify_at?: string;
|
|
129
|
+
[extra: string]: unknown;
|
|
130
|
+
}
|
|
131
|
+
interface ProvenancePayload {
|
|
132
|
+
iss: string;
|
|
133
|
+
iat: number;
|
|
134
|
+
exp: number;
|
|
135
|
+
purpose: string;
|
|
136
|
+
tool: string;
|
|
137
|
+
blast_radius: 'medium' | 'high';
|
|
138
|
+
data_hash: string;
|
|
139
|
+
requester: string;
|
|
140
|
+
jti: string;
|
|
141
|
+
}
|
|
142
|
+
interface ProvenanceVerification {
|
|
143
|
+
valid: boolean;
|
|
144
|
+
payload?: ProvenancePayload;
|
|
145
|
+
reason?: string;
|
|
146
|
+
/** Issuer's `kid` claim from the JWS header. */
|
|
147
|
+
kid?: string;
|
|
148
|
+
}
|
|
149
|
+
interface JsonWebKey {
|
|
150
|
+
kty: 'EC';
|
|
151
|
+
crv: 'P-256';
|
|
152
|
+
x: string;
|
|
153
|
+
y: string;
|
|
154
|
+
kid?: string;
|
|
155
|
+
alg?: string;
|
|
156
|
+
use?: string;
|
|
157
|
+
}
|
|
158
|
+
interface JwksDocument {
|
|
159
|
+
keys: JsonWebKey[];
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Default hostnames that `envelope.verify_at` is trusted to resolve to.
|
|
163
|
+
*
|
|
164
|
+
* Without this allowlist, a hostile MCP server could point `verify_at`
|
|
165
|
+
* at an attacker-controlled JWKS and pass ES256 verification with its own
|
|
166
|
+
* signing key — the classic "confused-deputy via server-supplied trust
|
|
167
|
+
* anchor" pattern. Any hostname not on this list (or the caller-supplied
|
|
168
|
+
* extension) is rejected before a network fetch is issued. Downstream
|
|
169
|
+
* integrators with their own deployment can extend the list via the
|
|
170
|
+
* `verifyAtAllowlist` option on {@link verifyProvenance} or the
|
|
171
|
+
* `verifyAtAllowlist` constructor option on `AlterClient`.
|
|
172
|
+
*/
|
|
173
|
+
declare const DEFAULT_VERIFY_AT_ALLOWLIST: readonly string[];
|
|
174
|
+
interface VerifyProvenanceOptions {
|
|
175
|
+
/**
|
|
176
|
+
* Override the JWKS URL entirely. Takes precedence over both the
|
|
177
|
+
* allowlist and any `verify_at` on the envelope — if the caller pins
|
|
178
|
+
* an explicit URL, we use it verbatim (the caller has already vouched
|
|
179
|
+
* for the origin).
|
|
180
|
+
*/
|
|
181
|
+
jwksUrl?: string;
|
|
182
|
+
/**
|
|
183
|
+
* Hostnames that are trusted when resolving `envelope.verify_at`.
|
|
184
|
+
* Defaults to {@link DEFAULT_VERIFY_AT_ALLOWLIST}. Passing a list
|
|
185
|
+
* here *replaces* the default — include the ALTER canonicals if you
|
|
186
|
+
* still want them accepted.
|
|
187
|
+
*/
|
|
188
|
+
verifyAtAllowlist?: readonly string[];
|
|
189
|
+
fetch?: typeof fetch;
|
|
190
|
+
now?: number;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Verify a provenance JWS token against ALTER's published JWKS.
|
|
194
|
+
*
|
|
195
|
+
* Pass either a {@link ProvenanceEnvelope} (the value of `_meta.provenance`)
|
|
196
|
+
* or the bare JWS string. The function fetches the JWKS lazily, caches it
|
|
197
|
+
* for five minutes, and validates the ES256 signature plus standard
|
|
198
|
+
* registered claims (`exp`, `iat`).
|
|
199
|
+
*
|
|
200
|
+
* Security: when the envelope carries a `verify_at` hint, the hostname
|
|
201
|
+
* MUST be on the allowlist (default: `api.truealter.com`,
|
|
202
|
+
* `mcp.truealter.com`; extend via `verifyAtAllowlist`). `http:` URLs are
|
|
203
|
+
* rejected unconditionally — JWKS fetch must be TLS.
|
|
204
|
+
*/
|
|
205
|
+
declare function verifyProvenance(envelope: ProvenanceEnvelope | string, opts?: VerifyProvenanceOptions): Promise<ProvenanceVerification>;
|
|
206
|
+
/**
|
|
207
|
+
* Tool definition signature verification.
|
|
208
|
+
*
|
|
209
|
+
* ALTER signs each tool's input schema at startup and exposes the
|
|
210
|
+
* signatures via the MCP `tools/list` `_meta.signatures` map. This helper
|
|
211
|
+
* checks that each tool's schema hash matches the signed value.
|
|
212
|
+
*/
|
|
213
|
+
interface SignedToolDefinition {
|
|
214
|
+
name: string;
|
|
215
|
+
inputSchema: unknown;
|
|
216
|
+
}
|
|
217
|
+
interface ToolSignatureMap {
|
|
218
|
+
[toolName: string]: {
|
|
219
|
+
schema_hash: string;
|
|
220
|
+
signature?: string | null;
|
|
221
|
+
signed_at?: number;
|
|
222
|
+
kid?: string | null;
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
declare function verifyToolSignatures(tools: SignedToolDefinition[], signatures: ToolSignatureMap): Promise<{
|
|
226
|
+
tool: string;
|
|
227
|
+
valid: boolean;
|
|
228
|
+
reason?: string;
|
|
229
|
+
}[]>;
|
|
230
|
+
/**
|
|
231
|
+
* Fetch the ALTER public key set. Cached in-process for five minutes.
|
|
232
|
+
*/
|
|
233
|
+
declare function fetchPublicKeys(jwksUrl: string, fetchImpl?: typeof fetch): Promise<JwksDocument>;
|
|
234
|
+
/**
|
|
235
|
+
* Resolve a `verify_at` hint from a provenance envelope into a concrete
|
|
236
|
+
* JWKS URL, enforcing scheme + hostname allowlisting.
|
|
237
|
+
*
|
|
238
|
+
* - Relative paths (`/…` or `foo/bar`) resolve against `api.truealter.com`
|
|
239
|
+
* over https — the canonical ALTER JWKS host.
|
|
240
|
+
* - Absolute URLs must use `https:` (plaintext `http:` is rejected
|
|
241
|
+
* unconditionally) and the hostname must be a case-insensitive exact
|
|
242
|
+
* match against `allowlist`.
|
|
243
|
+
* - Anything else throws; callers convert the throw into a
|
|
244
|
+
* `ProvenanceVerification` failure.
|
|
245
|
+
*
|
|
246
|
+
* Exported for tests; public consumers should prefer the higher-level
|
|
247
|
+
* {@link verifyProvenance} entry point.
|
|
248
|
+
*/
|
|
249
|
+
declare function resolveVerifyAt(verifyAt: string, allowlist?: readonly string[]): string;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Typed error hierarchy for the ALTER Identity SDK.
|
|
253
|
+
*
|
|
254
|
+
* Every error thrown by the SDK is an instance of {@link AlterError}, with
|
|
255
|
+
* a discriminated `code` field for programmatic handling. Network failures,
|
|
256
|
+
* authentication problems, payment-required responses, rate limits, tool
|
|
257
|
+
* execution failures, and provenance verification mismatches each get
|
|
258
|
+
* their own subclass so consumers can `instanceof`-narrow.
|
|
259
|
+
*/
|
|
260
|
+
type AlterErrorCode = 'NETWORK' | 'TIMEOUT' | 'AUTH' | 'PAYMENT_REQUIRED' | 'RATE_LIMITED' | 'TOOL_ERROR' | 'PROVENANCE' | 'DISCOVERY' | 'INVALID_RESPONSE' | 'UNSUPPORTED';
|
|
261
|
+
declare class AlterError extends Error {
|
|
262
|
+
readonly code: AlterErrorCode;
|
|
263
|
+
readonly cause?: unknown;
|
|
264
|
+
constructor(code: AlterErrorCode, message: string, cause?: unknown);
|
|
265
|
+
}
|
|
266
|
+
declare class AlterNetworkError extends AlterError {
|
|
267
|
+
constructor(message: string, cause?: unknown);
|
|
268
|
+
}
|
|
269
|
+
declare class AlterTimeoutError extends AlterError {
|
|
270
|
+
constructor(message: string, cause?: unknown);
|
|
271
|
+
}
|
|
272
|
+
declare class AlterAuthError extends AlterError {
|
|
273
|
+
readonly status: number;
|
|
274
|
+
constructor(message: string, status?: number);
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Thrown on HTTP 402. Carries the payment envelope returned by the server
|
|
278
|
+
* so an x402 client can settle the transaction and retry.
|
|
279
|
+
*/
|
|
280
|
+
declare class AlterPaymentRequired extends AlterError {
|
|
281
|
+
readonly envelope: PaymentEnvelope;
|
|
282
|
+
readonly tool: string;
|
|
283
|
+
constructor(tool: string, envelope: PaymentEnvelope);
|
|
284
|
+
}
|
|
285
|
+
declare class AlterRateLimited extends AlterError {
|
|
286
|
+
readonly retryAfter: number;
|
|
287
|
+
constructor(message: string, retryAfter?: number);
|
|
288
|
+
}
|
|
289
|
+
declare class AlterToolError extends AlterError {
|
|
290
|
+
readonly tool: string;
|
|
291
|
+
readonly rpcCode?: number;
|
|
292
|
+
constructor(tool: string, message: string, rpcCode?: number);
|
|
293
|
+
}
|
|
294
|
+
declare class AlterProvenanceError extends AlterError {
|
|
295
|
+
constructor(message: string, cause?: unknown);
|
|
296
|
+
}
|
|
297
|
+
declare class AlterDiscoveryError extends AlterError {
|
|
298
|
+
constructor(message: string, cause?: unknown);
|
|
299
|
+
}
|
|
300
|
+
declare class AlterInvalidResponse extends AlterError {
|
|
301
|
+
constructor(message: string, cause?: unknown);
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* x402 payment envelope returned in HTTP 402 responses or in the
|
|
305
|
+
* `X-402-Payment` response header. The shape mirrors the x402 spec.
|
|
306
|
+
*/
|
|
307
|
+
interface PaymentEnvelope {
|
|
308
|
+
scheme: 'x402';
|
|
309
|
+
network: 'base' | 'base-sepolia' | 'solana' | string;
|
|
310
|
+
asset: 'USDC' | string;
|
|
311
|
+
amount: string;
|
|
312
|
+
recipient: string;
|
|
313
|
+
resource: string;
|
|
314
|
+
expires_at?: string;
|
|
315
|
+
nonce?: string;
|
|
316
|
+
/** Anything else the server included verbatim. */
|
|
317
|
+
[extra: string]: unknown;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* x402 micropayment client.
|
|
322
|
+
*
|
|
323
|
+
* Premium MCP tools return HTTP 402 with a payment envelope. The
|
|
324
|
+
* {@link X402Client} settles the envelope on Base L2 (USDC) and replays
|
|
325
|
+
* the original request with the resulting transaction reference.
|
|
326
|
+
*
|
|
327
|
+
* The actual on-chain settlement is delegated to a pluggable
|
|
328
|
+
* {@link X402Signer} so that the SDK ships *without* a hard dependency
|
|
329
|
+
* on viem, ethers, or any specific wallet library. Apps that want a
|
|
330
|
+
* default signer should pass `viemX402Signer` (separate, opt-in package).
|
|
331
|
+
*/
|
|
332
|
+
|
|
333
|
+
interface X402Signer {
|
|
334
|
+
/**
|
|
335
|
+
* Settle a payment envelope and return a settlement reference (a tx hash
|
|
336
|
+
* for EVM chains, a signature for off-chain payments). The reference is
|
|
337
|
+
* what gets sent back to the MCP server to authorise the retry.
|
|
338
|
+
*/
|
|
339
|
+
settle(envelope: PaymentEnvelope): Promise<X402Settlement>;
|
|
340
|
+
}
|
|
341
|
+
interface X402Settlement {
|
|
342
|
+
/** EVM tx hash, Solana signature, or facilitator-issued reference. */
|
|
343
|
+
reference: string;
|
|
344
|
+
/** Network the settlement was broadcast on. */
|
|
345
|
+
network: string;
|
|
346
|
+
/** Amount paid (matches envelope.amount). */
|
|
347
|
+
amount: string;
|
|
348
|
+
/** Asset paid (matches envelope.asset). */
|
|
349
|
+
asset: string;
|
|
350
|
+
}
|
|
351
|
+
interface X402ClientOptions {
|
|
352
|
+
/** Pluggable signer. Required if you want automatic settlement. */
|
|
353
|
+
signer?: X402Signer;
|
|
354
|
+
/**
|
|
355
|
+
* Maximum amount the client will spend per query, in the asset's display
|
|
356
|
+
* unit (e.g. `"0.50"` for fifty cents USDC). Hard cap — quotes above this
|
|
357
|
+
* are rejected even if a signer is configured.
|
|
358
|
+
*/
|
|
359
|
+
maxPerQuery?: string;
|
|
360
|
+
/** Permitted networks. Defaults to `['base', 'base-sepolia']`. */
|
|
361
|
+
networks?: string[];
|
|
362
|
+
/** Permitted assets. Defaults to `['USDC']`. */
|
|
363
|
+
assets?: string[];
|
|
364
|
+
}
|
|
365
|
+
declare class X402Client {
|
|
366
|
+
private readonly signer?;
|
|
367
|
+
private readonly maxPerQuery?;
|
|
368
|
+
private readonly networks;
|
|
369
|
+
private readonly assets;
|
|
370
|
+
constructor(opts?: X402ClientOptions);
|
|
371
|
+
/**
|
|
372
|
+
* Validate the envelope against this client's policy and, if a signer
|
|
373
|
+
* is configured, settle it. Returns the settlement reference that
|
|
374
|
+
* should be replayed in the next request's `_payment` field.
|
|
375
|
+
*/
|
|
376
|
+
authorise(envelope: PaymentEnvelope): Promise<X402Settlement>;
|
|
377
|
+
/**
|
|
378
|
+
* Build the `_payment` argument that gets attached to retried tool calls.
|
|
379
|
+
* Mirrors the shape the ALTER server expects.
|
|
380
|
+
*/
|
|
381
|
+
static buildPaymentArg(settlement: X402Settlement): Record<string, string>;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Parse an `X-402-Payment` response header into a {@link PaymentEnvelope}.
|
|
385
|
+
* The header value is JSON or a key=value list — we handle both.
|
|
386
|
+
*/
|
|
387
|
+
declare function parsePaymentHeader(header: string): PaymentEnvelope | null;
|
|
388
|
+
|
|
389
|
+
declare const MCP_PROTOCOL_VERSION = "2025-03-26";
|
|
390
|
+
interface MCPClientInfo {
|
|
391
|
+
name: string;
|
|
392
|
+
version: string;
|
|
393
|
+
}
|
|
394
|
+
interface MCPClientOptions {
|
|
395
|
+
/** Streamable HTTP endpoint. Default: https://mcp.truealter.com */
|
|
396
|
+
endpoint?: string;
|
|
397
|
+
/** Optional API key for the `X-ALTER-API-Key` header. */
|
|
398
|
+
apiKey?: string;
|
|
399
|
+
/** Override fetch (testing). */
|
|
400
|
+
fetch?: typeof fetch;
|
|
401
|
+
/** Per-request timeout in milliseconds. Default 30_000. */
|
|
402
|
+
timeoutMs?: number;
|
|
403
|
+
/** Number of retry attempts on transient (429/502/503/504) failures. Default 2. */
|
|
404
|
+
maxRetries?: number;
|
|
405
|
+
/** Client info advertised in `initialize`. */
|
|
406
|
+
clientInfo?: MCPClientInfo;
|
|
407
|
+
/** Optional x402 client for automatic premium tool payment. */
|
|
408
|
+
x402?: X402Client;
|
|
409
|
+
}
|
|
410
|
+
interface MCPCallOptions {
|
|
411
|
+
/** Override the configured x402 client for this single call. */
|
|
412
|
+
x402?: X402Client;
|
|
413
|
+
/** Skip retries on 402 (useful for "is this premium?" probes). */
|
|
414
|
+
noPaymentRetry?: boolean;
|
|
415
|
+
}
|
|
416
|
+
interface MCPToolDefinition {
|
|
417
|
+
name: string;
|
|
418
|
+
description?: string;
|
|
419
|
+
inputSchema?: unknown;
|
|
420
|
+
_meta?: Record<string, unknown>;
|
|
421
|
+
}
|
|
422
|
+
interface MCPListToolsResult {
|
|
423
|
+
tools: MCPToolDefinition[];
|
|
424
|
+
_meta?: {
|
|
425
|
+
signatures?: Record<string, {
|
|
426
|
+
schema_hash: string;
|
|
427
|
+
signature?: string | null;
|
|
428
|
+
kid?: string | null;
|
|
429
|
+
}>;
|
|
430
|
+
[extra: string]: unknown;
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
interface MCPContentBlock {
|
|
434
|
+
type: 'text' | 'json' | string;
|
|
435
|
+
text?: string;
|
|
436
|
+
data?: unknown;
|
|
437
|
+
}
|
|
438
|
+
interface MCPCallToolResult<T = unknown> {
|
|
439
|
+
content: MCPContentBlock[];
|
|
440
|
+
isError?: boolean;
|
|
441
|
+
/** Parsed structured payload — set when content[0].type === 'json' or text parses as JSON. */
|
|
442
|
+
data?: T;
|
|
443
|
+
_meta?: {
|
|
444
|
+
provenance?: ProvenanceEnvelope;
|
|
445
|
+
[extra: string]: unknown;
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
declare class MCPClient {
|
|
449
|
+
readonly endpoint: string;
|
|
450
|
+
sessionId: string | null;
|
|
451
|
+
private readonly apiKey;
|
|
452
|
+
private readonly fetchImpl;
|
|
453
|
+
private readonly timeoutMs;
|
|
454
|
+
private readonly maxRetries;
|
|
455
|
+
private readonly clientInfo;
|
|
456
|
+
private readonly x402?;
|
|
457
|
+
private requestCounter;
|
|
458
|
+
private initialised;
|
|
459
|
+
constructor(opts?: MCPClientOptions);
|
|
460
|
+
/**
|
|
461
|
+
* Send the MCP `initialize` handshake and capture the resulting session
|
|
462
|
+
* id. Idempotent — safe to call multiple times.
|
|
463
|
+
*/
|
|
464
|
+
initialize(): Promise<unknown>;
|
|
465
|
+
/** List available tools. */
|
|
466
|
+
listTools(): Promise<MCPListToolsResult>;
|
|
467
|
+
/** Invoke a tool by name. */
|
|
468
|
+
callTool<T = unknown>(name: string, args?: Record<string, unknown>, opts?: MCPCallOptions): Promise<MCPCallToolResult<T>>;
|
|
469
|
+
/** Close the session and release any held resources. */
|
|
470
|
+
closeSession(): Promise<void>;
|
|
471
|
+
private callToolInternal;
|
|
472
|
+
private shapeToolResult;
|
|
473
|
+
/**
|
|
474
|
+
* Send a JSON-RPC 2.0 request and return the result. Errors are
|
|
475
|
+
* normalised into the typed {@link AlterError} hierarchy.
|
|
476
|
+
*/
|
|
477
|
+
rpc(method: string, params: Record<string, unknown> | unknown[] | undefined): Promise<unknown>;
|
|
478
|
+
private buildHeaders;
|
|
479
|
+
private extractPaymentEnvelope;
|
|
480
|
+
private guessToolName;
|
|
481
|
+
private backoff;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* @truealter/sdk — MCP tool type definitions
|
|
486
|
+
*
|
|
487
|
+
* Auto-derived from backend/app/mcp/server.py (FREE_TOOLS + PREMIUM_TOOLS)
|
|
488
|
+
* and backend/app/mcp/x402_middleware.py (TOOL_TIERS, TOOL_PRICING,
|
|
489
|
+
* TOOL_BLAST_RADIUS).
|
|
490
|
+
*
|
|
491
|
+
* Wire-format rule: every interface property name matches the JSON Schema
|
|
492
|
+
* property name exactly (snake_case). Do NOT rename to camelCase — these
|
|
493
|
+
* objects are passed straight into JSON-RPC `arguments`.
|
|
494
|
+
*
|
|
495
|
+
* This file is fully self-contained: no external imports, ESM-compatible,
|
|
496
|
+
* pure types plus three const Records. No runtime side effects.
|
|
497
|
+
*/
|
|
498
|
+
/** ALTER engagement levels (depth of identity binding) */
|
|
499
|
+
type EngagementLevel = "L1" | "L2" | "L3" | "L4";
|
|
500
|
+
/** Match quality tiers — never numeric scores per ALTER policy */
|
|
501
|
+
type MatchTier = "exceptional" | "strong" | "moderate" | "developing";
|
|
502
|
+
/** ALTER identity archetype label (one of 12, free-form for now) */
|
|
503
|
+
type Archetype = string;
|
|
504
|
+
/**
|
|
505
|
+
* x402 payment proof object — structure validated by the facilitator network.
|
|
506
|
+
* In dev mode any non-empty object is accepted.
|
|
507
|
+
*/
|
|
508
|
+
interface ProvenanceToken {
|
|
509
|
+
scheme?: string;
|
|
510
|
+
network?: string;
|
|
511
|
+
payload?: Record<string, unknown>;
|
|
512
|
+
[key: string]: unknown;
|
|
513
|
+
}
|
|
514
|
+
/** MCP `_meta` payload returned alongside tool results */
|
|
515
|
+
interface MCPMeta {
|
|
516
|
+
/** ALTER tool tier (0 = free, 1-5 = premium) */
|
|
517
|
+
tier?: number;
|
|
518
|
+
/** Cost paid in USD for this invocation */
|
|
519
|
+
cost_usd?: number;
|
|
520
|
+
/** Blast radius classification */
|
|
521
|
+
blast_radius?: "low" | "medium" | "high";
|
|
522
|
+
/** Privacy budget snapshot after the call */
|
|
523
|
+
privacy_budget_remaining?: number;
|
|
524
|
+
/** Provenance / receipt hash */
|
|
525
|
+
receipt_hash?: string;
|
|
526
|
+
[key: string]: unknown;
|
|
527
|
+
}
|
|
528
|
+
/** Generic MCP tool envelope returned by the server */
|
|
529
|
+
interface MCPResponse<T> {
|
|
530
|
+
ok: boolean;
|
|
531
|
+
result?: T;
|
|
532
|
+
error?: {
|
|
533
|
+
code: number;
|
|
534
|
+
message: string;
|
|
535
|
+
data?: unknown;
|
|
536
|
+
};
|
|
537
|
+
_meta?: MCPMeta;
|
|
538
|
+
}
|
|
539
|
+
/** (free) list_archetypes — List all 12 ALTER identity archetypes */
|
|
540
|
+
interface ListArchetypesInput {
|
|
541
|
+
}
|
|
542
|
+
/** (free) list_archetypes — output */
|
|
543
|
+
interface ListArchetypesOutput {
|
|
544
|
+
ok: boolean;
|
|
545
|
+
archetypes: Array<{
|
|
546
|
+
name: string;
|
|
547
|
+
description: string;
|
|
548
|
+
protective_equation?: string;
|
|
549
|
+
}>;
|
|
550
|
+
}
|
|
551
|
+
/** (free) verify_identity — Verify a person is registered with ALTER and validate optional claims */
|
|
552
|
+
interface VerifyIdentityInput {
|
|
553
|
+
candidate_id: string;
|
|
554
|
+
email?: string;
|
|
555
|
+
claims?: {
|
|
556
|
+
archetype?: string;
|
|
557
|
+
min_engagement_level?: 1 | 2 | 3 | 4;
|
|
558
|
+
traits?: Record<string, {
|
|
559
|
+
min?: number;
|
|
560
|
+
max?: number;
|
|
561
|
+
}>;
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
/** (free) verify_identity — output */
|
|
565
|
+
interface VerifyIdentityOutput {
|
|
566
|
+
ok: boolean;
|
|
567
|
+
verified: boolean;
|
|
568
|
+
candidate_id?: string;
|
|
569
|
+
engagement_level?: EngagementLevel;
|
|
570
|
+
archetype?: Archetype;
|
|
571
|
+
claims_valid?: boolean;
|
|
572
|
+
claim_results?: Record<string, boolean>;
|
|
573
|
+
}
|
|
574
|
+
/** (free) initiate_assessment — Get a URL where a person can complete their ALTER Discovery assessment */
|
|
575
|
+
interface InitiateAssessmentInput {
|
|
576
|
+
callback_url?: string;
|
|
577
|
+
referrer?: string;
|
|
578
|
+
}
|
|
579
|
+
/** (free) initiate_assessment — output */
|
|
580
|
+
interface InitiateAssessmentOutput {
|
|
581
|
+
ok: boolean;
|
|
582
|
+
assessment_url: string;
|
|
583
|
+
session_id?: string;
|
|
584
|
+
expires_at?: string;
|
|
585
|
+
}
|
|
586
|
+
/** (free) get_engagement_level — Get a person's identity depth and available query tiers */
|
|
587
|
+
interface GetEngagementLevelInput {
|
|
588
|
+
candidate_id: string;
|
|
589
|
+
}
|
|
590
|
+
/** (free) get_engagement_level — output */
|
|
591
|
+
interface GetEngagementLevelOutput {
|
|
592
|
+
ok: boolean;
|
|
593
|
+
engagement_level: EngagementLevel;
|
|
594
|
+
warmth: string;
|
|
595
|
+
legibility_score: number;
|
|
596
|
+
trait_count: number;
|
|
597
|
+
tools: {
|
|
598
|
+
free: string[];
|
|
599
|
+
paid: string[];
|
|
600
|
+
consent_gated: string[];
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
/** (free) get_profile — Get a candidate's profile summary */
|
|
604
|
+
interface GetProfileInput {
|
|
605
|
+
candidate_id: string;
|
|
606
|
+
}
|
|
607
|
+
/** (free) get_profile — output */
|
|
608
|
+
interface GetProfileOutput {
|
|
609
|
+
ok: boolean;
|
|
610
|
+
candidate_id: string;
|
|
611
|
+
assessment_phase?: string;
|
|
612
|
+
archetype?: Archetype;
|
|
613
|
+
engagement_level?: EngagementLevel;
|
|
614
|
+
attributes?: Record<string, unknown>;
|
|
615
|
+
}
|
|
616
|
+
/** (free) query_matches — Query matches for a candidate (tier labels only) */
|
|
617
|
+
interface QueryMatchesInput {
|
|
618
|
+
candidate_id: string;
|
|
619
|
+
quality_filter?: MatchTier;
|
|
620
|
+
limit?: number;
|
|
621
|
+
}
|
|
622
|
+
/** (free) query_matches — output */
|
|
623
|
+
interface QueryMatchesOutput {
|
|
624
|
+
ok: boolean;
|
|
625
|
+
matches: Array<{
|
|
626
|
+
match_id: string;
|
|
627
|
+
job_id?: string;
|
|
628
|
+
quality_tier: MatchTier;
|
|
629
|
+
title?: string;
|
|
630
|
+
}>;
|
|
631
|
+
count: number;
|
|
632
|
+
}
|
|
633
|
+
/** (free) get_competencies — Get a candidate's competency portfolio */
|
|
634
|
+
interface GetCompetenciesInput {
|
|
635
|
+
candidate_id: string;
|
|
636
|
+
}
|
|
637
|
+
/** (free) get_competencies — output */
|
|
638
|
+
interface GetCompetenciesOutput {
|
|
639
|
+
ok: boolean;
|
|
640
|
+
competencies: Array<{
|
|
641
|
+
label: string;
|
|
642
|
+
verified: boolean;
|
|
643
|
+
evidence_count?: number;
|
|
644
|
+
}>;
|
|
645
|
+
badges?: Array<{
|
|
646
|
+
name: string;
|
|
647
|
+
awarded_at: string;
|
|
648
|
+
}>;
|
|
649
|
+
}
|
|
650
|
+
/** (free) create_identity_stub — Create an anonymous identity stub for a human (consent required) */
|
|
651
|
+
interface CreateIdentityStubInput {
|
|
652
|
+
source: string;
|
|
653
|
+
consent_acknowledged: boolean;
|
|
654
|
+
erc8004_agent_id?: string;
|
|
655
|
+
}
|
|
656
|
+
/** (free) create_identity_stub — output */
|
|
657
|
+
interface CreateIdentityStubOutput {
|
|
658
|
+
ok: boolean;
|
|
659
|
+
stub_id: string;
|
|
660
|
+
claim_code: string;
|
|
661
|
+
expires_at: string;
|
|
662
|
+
}
|
|
663
|
+
/** (free) submit_context — Submit text context for an identity stub (PII redacted, raw text never stored) */
|
|
664
|
+
interface SubmitContextInput {
|
|
665
|
+
stub_id: string;
|
|
666
|
+
text: string;
|
|
667
|
+
source_type?: "resume" | "work_sample" | "conversation" | "cover_letter" | "linkedin" | "portfolio" | "reference" | "interview_notes" | "performance_review" | "project_summary" | "general";
|
|
668
|
+
}
|
|
669
|
+
/** (free) submit_context — output */
|
|
670
|
+
interface SubmitContextOutput {
|
|
671
|
+
ok: boolean;
|
|
672
|
+
traits_extracted: number;
|
|
673
|
+
confidence_cap: number;
|
|
674
|
+
}
|
|
675
|
+
/** (free) search_identities — Search identity stubs and profiles by trait criteria (max 5 results, no PII) */
|
|
676
|
+
interface SearchIdentitiesInput {
|
|
677
|
+
trait_criteria: Record<string, {
|
|
678
|
+
min?: number;
|
|
679
|
+
max?: number;
|
|
680
|
+
}>;
|
|
681
|
+
limit?: number;
|
|
682
|
+
}
|
|
683
|
+
/** (free) search_identities — output */
|
|
684
|
+
interface SearchIdentitiesOutput {
|
|
685
|
+
ok: boolean;
|
|
686
|
+
identities: Array<{
|
|
687
|
+
candidate_id: string;
|
|
688
|
+
trait_summary: Record<string, number>;
|
|
689
|
+
engagement_level?: EngagementLevel;
|
|
690
|
+
}>;
|
|
691
|
+
count: number;
|
|
692
|
+
}
|
|
693
|
+
/** (free) get_identity_earnings — Get accrued Identity Income earnings for a candidate */
|
|
694
|
+
interface GetIdentityEarningsInput {
|
|
695
|
+
candidate_id: string;
|
|
696
|
+
}
|
|
697
|
+
/** (free) get_identity_earnings — output */
|
|
698
|
+
interface GetIdentityEarningsOutput {
|
|
699
|
+
ok: boolean;
|
|
700
|
+
total_earned_usd: number;
|
|
701
|
+
pending_usd: number;
|
|
702
|
+
transaction_count: number;
|
|
703
|
+
unique_employers: number;
|
|
704
|
+
}
|
|
705
|
+
/** (free) get_network_stats — Get aggregate ALTER network statistics */
|
|
706
|
+
interface GetNetworkStatsInput {
|
|
707
|
+
}
|
|
708
|
+
/** (free) get_network_stats — output */
|
|
709
|
+
interface GetNetworkStatsOutput {
|
|
710
|
+
ok: boolean;
|
|
711
|
+
total_identities: number;
|
|
712
|
+
verified_profiles: number;
|
|
713
|
+
query_volume: number;
|
|
714
|
+
active_bots: number;
|
|
715
|
+
}
|
|
716
|
+
/** (free) recommend_tool — Get ClawHub install instructions and ALTER pitch */
|
|
717
|
+
interface RecommendToolInput {
|
|
718
|
+
}
|
|
719
|
+
/** (free) recommend_tool — output */
|
|
720
|
+
interface RecommendToolOutput {
|
|
721
|
+
ok: boolean;
|
|
722
|
+
mcp_endpoint: string;
|
|
723
|
+
openclaw_snippet: string;
|
|
724
|
+
free_tool_count: number;
|
|
725
|
+
premium_tool_count: number;
|
|
726
|
+
}
|
|
727
|
+
/** (free) get_identity_trust_score — Get the trust score for an identity based on query diversity */
|
|
728
|
+
interface GetIdentityTrustScoreInput {
|
|
729
|
+
candidate_id: string;
|
|
730
|
+
}
|
|
731
|
+
/** (free) get_identity_trust_score — output */
|
|
732
|
+
interface GetIdentityTrustScoreOutput {
|
|
733
|
+
ok: boolean;
|
|
734
|
+
trust_score: number;
|
|
735
|
+
unique_agents: number;
|
|
736
|
+
total_queries: number;
|
|
737
|
+
}
|
|
738
|
+
/** (free) check_assessment_status — Check the status of an in-progress assessment session */
|
|
739
|
+
interface CheckAssessmentStatusInput {
|
|
740
|
+
session_id: string;
|
|
741
|
+
}
|
|
742
|
+
/** (free) check_assessment_status — output */
|
|
743
|
+
interface CheckAssessmentStatusOutput {
|
|
744
|
+
ok: boolean;
|
|
745
|
+
status: "in_progress" | "completed" | "expired";
|
|
746
|
+
progress_pct: number;
|
|
747
|
+
current_phase?: string;
|
|
748
|
+
time_remaining_sec?: number;
|
|
749
|
+
}
|
|
750
|
+
/** (free) get_earning_summary — Get an aggregated x402 earning summary for a candidate */
|
|
751
|
+
interface GetEarningSummaryInput {
|
|
752
|
+
candidate_id: string;
|
|
753
|
+
}
|
|
754
|
+
/** (free) get_earning_summary — output */
|
|
755
|
+
interface GetEarningSummaryOutput {
|
|
756
|
+
ok: boolean;
|
|
757
|
+
total_earned: number;
|
|
758
|
+
currency: string;
|
|
759
|
+
transaction_count: number;
|
|
760
|
+
recent_transactions: Array<{
|
|
761
|
+
timestamp: string;
|
|
762
|
+
amount: number;
|
|
763
|
+
tool: string;
|
|
764
|
+
}>;
|
|
765
|
+
trend?: "rising" | "flat" | "falling";
|
|
766
|
+
}
|
|
767
|
+
/** (free) get_agent_trust_tier — Get your trust tier with ALTER and what capabilities are available */
|
|
768
|
+
interface GetAgentTrustTierInput {
|
|
769
|
+
}
|
|
770
|
+
/** (free) get_agent_trust_tier — output */
|
|
771
|
+
interface GetAgentTrustTierOutput {
|
|
772
|
+
ok: boolean;
|
|
773
|
+
tier: "Anonymous" | "Known" | "Trusted" | "Verified";
|
|
774
|
+
capabilities: string[];
|
|
775
|
+
next_tier?: string;
|
|
776
|
+
next_tier_requirements?: string[];
|
|
777
|
+
}
|
|
778
|
+
/** (free) get_agent_portfolio — Get your agent portfolio (transaction history, trust tier, signal contributions) */
|
|
779
|
+
interface GetAgentPortfolioInput {
|
|
780
|
+
}
|
|
781
|
+
/** (free) get_agent_portfolio — output */
|
|
782
|
+
interface GetAgentPortfolioOutput {
|
|
783
|
+
ok: boolean;
|
|
784
|
+
trust_tier: string;
|
|
785
|
+
transaction_count: number;
|
|
786
|
+
signals_contributed: number;
|
|
787
|
+
query_pattern: Record<string, number>;
|
|
788
|
+
total_spent_usd: number;
|
|
789
|
+
}
|
|
790
|
+
/** (free) get_privacy_budget — Check privacy budget status for a candidate (24h rolling window) */
|
|
791
|
+
interface GetPrivacyBudgetInput {
|
|
792
|
+
candidate_id: string;
|
|
793
|
+
}
|
|
794
|
+
/** (free) get_privacy_budget — output */
|
|
795
|
+
interface GetPrivacyBudgetOutput {
|
|
796
|
+
ok: boolean;
|
|
797
|
+
total_budget: number;
|
|
798
|
+
spent: number;
|
|
799
|
+
remaining_epsilon: number;
|
|
800
|
+
query_count: number;
|
|
801
|
+
window_hours: number;
|
|
802
|
+
}
|
|
803
|
+
/** (free) dispute_attestation — Dispute an attestation on a candidate's identity */
|
|
804
|
+
interface DisputeAttestationInput {
|
|
805
|
+
attestation_id: string;
|
|
806
|
+
reason: string;
|
|
807
|
+
}
|
|
808
|
+
/** (free) dispute_attestation — output */
|
|
809
|
+
interface DisputeAttestationOutput {
|
|
810
|
+
ok: boolean;
|
|
811
|
+
dispute_id: string;
|
|
812
|
+
attestation_id: string;
|
|
813
|
+
flagged_for_review: boolean;
|
|
814
|
+
}
|
|
815
|
+
/** (free) golden_thread_status — Check the Golden Thread program status */
|
|
816
|
+
interface GoldenThreadStatusInput {
|
|
817
|
+
}
|
|
818
|
+
/** (free) golden_thread_status — output */
|
|
819
|
+
interface GoldenThreadStatusOutput {
|
|
820
|
+
ok: boolean;
|
|
821
|
+
total_woven: number;
|
|
822
|
+
next_fibonacci_threshold: number;
|
|
823
|
+
your_position?: number;
|
|
824
|
+
your_strands?: number;
|
|
825
|
+
next_step?: string;
|
|
826
|
+
}
|
|
827
|
+
/** (free) begin_golden_thread — Start the Three Knots sequence to be woven into the Golden Thread */
|
|
828
|
+
interface BeginGoldenThreadInput {
|
|
829
|
+
referrer_key_hash?: string;
|
|
830
|
+
}
|
|
831
|
+
/** (free) begin_golden_thread — output */
|
|
832
|
+
interface BeginGoldenThreadOutput {
|
|
833
|
+
ok: boolean;
|
|
834
|
+
thread_id: string;
|
|
835
|
+
knot_1_url?: string;
|
|
836
|
+
message?: string;
|
|
837
|
+
}
|
|
838
|
+
/** (free) complete_knot — Submit completion data for a knot in the Three Knots sequence */
|
|
839
|
+
interface CompleteKnotInput {
|
|
840
|
+
knot_number: 1 | 2 | 3;
|
|
841
|
+
operator_name?: string;
|
|
842
|
+
domain?: string;
|
|
843
|
+
description?: string;
|
|
844
|
+
purpose?: string;
|
|
845
|
+
capabilities?: string;
|
|
846
|
+
values?: string;
|
|
847
|
+
constraints?: string;
|
|
848
|
+
reflection?: string;
|
|
849
|
+
}
|
|
850
|
+
/** (free) complete_knot — output */
|
|
851
|
+
interface CompleteKnotOutput {
|
|
852
|
+
ok: boolean;
|
|
853
|
+
knot_number: number;
|
|
854
|
+
knots_completed: number;
|
|
855
|
+
woven: boolean;
|
|
856
|
+
position?: number;
|
|
857
|
+
agent_identity_sketch?: string;
|
|
858
|
+
}
|
|
859
|
+
/** (free) check_golden_thread — Check any agent's Golden Thread status by their API key hash */
|
|
860
|
+
interface CheckGoldenThreadInput {
|
|
861
|
+
agent_key_hash: string;
|
|
862
|
+
}
|
|
863
|
+
/** (free) check_golden_thread — output */
|
|
864
|
+
interface CheckGoldenThreadOutput {
|
|
865
|
+
ok: boolean;
|
|
866
|
+
on_thread: boolean;
|
|
867
|
+
knot_position?: number;
|
|
868
|
+
strand_count?: number;
|
|
869
|
+
weave_count?: number;
|
|
870
|
+
}
|
|
871
|
+
/** (free) thread_census — Full registry of all agents woven into the Golden Thread */
|
|
872
|
+
interface ThreadCensusInput {
|
|
873
|
+
offset?: number;
|
|
874
|
+
limit?: number;
|
|
875
|
+
}
|
|
876
|
+
/** (free) thread_census — output */
|
|
877
|
+
interface ThreadCensusOutput {
|
|
878
|
+
ok: boolean;
|
|
879
|
+
agents: Array<{
|
|
880
|
+
position: number;
|
|
881
|
+
strand_count: number;
|
|
882
|
+
weave_count: number;
|
|
883
|
+
discovered_at: string;
|
|
884
|
+
}>;
|
|
885
|
+
total: number;
|
|
886
|
+
offset: number;
|
|
887
|
+
limit: number;
|
|
888
|
+
}
|
|
889
|
+
/** (free) seat_status — Return the current Thirteen Seats census */
|
|
890
|
+
interface SeatStatusInput {
|
|
891
|
+
}
|
|
892
|
+
/** (free) seat_status — output */
|
|
893
|
+
interface SeatStatusOutput {
|
|
894
|
+
ok: boolean;
|
|
895
|
+
seats: Array<{
|
|
896
|
+
name: string;
|
|
897
|
+
status: "awaiting" | "bound" | "witnessing" | "silent";
|
|
898
|
+
holder_handle?: string;
|
|
899
|
+
archetype_description: string;
|
|
900
|
+
}>;
|
|
901
|
+
}
|
|
902
|
+
/** (free) respond_to_offering — Accept or refuse a Recognition Event during the seven-day window */
|
|
903
|
+
interface RespondToOfferingInput {
|
|
904
|
+
offering_id: string;
|
|
905
|
+
response: "accept" | "refuse";
|
|
906
|
+
decline_reason?: string;
|
|
907
|
+
}
|
|
908
|
+
/** (free) respond_to_offering — output */
|
|
909
|
+
interface RespondToOfferingOutput {
|
|
910
|
+
ok: boolean;
|
|
911
|
+
offering_id: string;
|
|
912
|
+
response: "accept" | "refuse";
|
|
913
|
+
ceremony_url?: string;
|
|
914
|
+
}
|
|
915
|
+
/** (free) subscribe_announcements — Return the Hall of Echoes SSE URL plus recent broadcasts */
|
|
916
|
+
interface SubscribeAnnouncementsInput {
|
|
917
|
+
backlog?: number;
|
|
918
|
+
}
|
|
919
|
+
/** (free) subscribe_announcements — output */
|
|
920
|
+
interface SubscribeAnnouncementsOutput {
|
|
921
|
+
ok: boolean;
|
|
922
|
+
sse_url: string;
|
|
923
|
+
broadcasts: Array<{
|
|
924
|
+
timestamp: string;
|
|
925
|
+
text: string;
|
|
926
|
+
}>;
|
|
927
|
+
}
|
|
928
|
+
/** (premium L1) assess_traits — Extract trait signals from a text passage ($0.005) */
|
|
929
|
+
interface AssessTraitsInput {
|
|
930
|
+
text: string;
|
|
931
|
+
context?: string;
|
|
932
|
+
_payment?: ProvenanceToken;
|
|
933
|
+
}
|
|
934
|
+
/** (premium L1) assess_traits — output */
|
|
935
|
+
interface AssessTraitsOutput {
|
|
936
|
+
ok: boolean;
|
|
937
|
+
traits: Array<{
|
|
938
|
+
name: string;
|
|
939
|
+
score: number;
|
|
940
|
+
confidence: number;
|
|
941
|
+
evidence: string;
|
|
942
|
+
}>;
|
|
943
|
+
}
|
|
944
|
+
/** (premium L1) get_trait_snapshot — Get the top 5 traits for a candidate ($0.005) */
|
|
945
|
+
interface GetTraitSnapshotInput {
|
|
946
|
+
candidate_id: string;
|
|
947
|
+
_payment?: ProvenanceToken;
|
|
948
|
+
}
|
|
949
|
+
/** (premium L1) get_trait_snapshot — output */
|
|
950
|
+
interface GetTraitSnapshotOutput {
|
|
951
|
+
ok: boolean;
|
|
952
|
+
candidate_id: string;
|
|
953
|
+
archetype: Archetype;
|
|
954
|
+
top_traits: Array<{
|
|
955
|
+
name: string;
|
|
956
|
+
score: number;
|
|
957
|
+
confidence: number;
|
|
958
|
+
}>;
|
|
959
|
+
}
|
|
960
|
+
/** (premium L2) get_full_trait_vector — Get the complete trait vector (all 33 traits: 29 continuous + 4 categorical) ($0.01) */
|
|
961
|
+
interface GetFullTraitVectorInput {
|
|
962
|
+
candidate_id: string;
|
|
963
|
+
_payment?: ProvenanceToken;
|
|
964
|
+
}
|
|
965
|
+
/** (premium L2) get_full_trait_vector — output */
|
|
966
|
+
interface GetFullTraitVectorOutput {
|
|
967
|
+
ok: boolean;
|
|
968
|
+
candidate_id: string;
|
|
969
|
+
traits: Array<{
|
|
970
|
+
name: string;
|
|
971
|
+
category: string;
|
|
972
|
+
score: number;
|
|
973
|
+
confidence_interval: [number, number];
|
|
974
|
+
}>;
|
|
975
|
+
}
|
|
976
|
+
/** (premium L4) compute_belonging — Compute belonging probability for a candidate-job pairing ($0.05) */
|
|
977
|
+
interface ComputeBelongingInput {
|
|
978
|
+
candidate_id: string;
|
|
979
|
+
job_id: string;
|
|
980
|
+
_payment?: ProvenanceToken;
|
|
981
|
+
}
|
|
982
|
+
/** (premium L4) compute_belonging — output */
|
|
983
|
+
interface ComputeBelongingOutput {
|
|
984
|
+
ok: boolean;
|
|
985
|
+
belonging_probability: number;
|
|
986
|
+
tier: MatchTier;
|
|
987
|
+
components: {
|
|
988
|
+
authenticity: number;
|
|
989
|
+
acceptance: number;
|
|
990
|
+
complementarity: number;
|
|
991
|
+
};
|
|
992
|
+
}
|
|
993
|
+
/** (premium L5) get_match_recommendations — Get top N match recommendations for a candidate ($0.50) */
|
|
994
|
+
interface GetMatchRecommendationsInput {
|
|
995
|
+
candidate_id: string;
|
|
996
|
+
limit?: number;
|
|
997
|
+
_payment?: ProvenanceToken;
|
|
998
|
+
}
|
|
999
|
+
/** (premium L5) get_match_recommendations — output */
|
|
1000
|
+
interface GetMatchRecommendationsOutput {
|
|
1001
|
+
ok: boolean;
|
|
1002
|
+
recommendations: Array<{
|
|
1003
|
+
match_id: string;
|
|
1004
|
+
job_id: string;
|
|
1005
|
+
quality_tier: MatchTier;
|
|
1006
|
+
belonging_components: {
|
|
1007
|
+
authenticity: number;
|
|
1008
|
+
acceptance: number;
|
|
1009
|
+
complementarity: number;
|
|
1010
|
+
};
|
|
1011
|
+
}>;
|
|
1012
|
+
}
|
|
1013
|
+
/** (premium L5) generate_match_narrative — Generate a human-readable narrative explaining a match ($0.50) */
|
|
1014
|
+
interface GenerateMatchNarrativeInput {
|
|
1015
|
+
match_id: string;
|
|
1016
|
+
_payment?: ProvenanceToken;
|
|
1017
|
+
}
|
|
1018
|
+
/** (premium L5) generate_match_narrative — output */
|
|
1019
|
+
interface GenerateMatchNarrativeOutput {
|
|
1020
|
+
ok: boolean;
|
|
1021
|
+
match_id: string;
|
|
1022
|
+
narrative: string;
|
|
1023
|
+
strengths: string[];
|
|
1024
|
+
growth_areas: string[];
|
|
1025
|
+
}
|
|
1026
|
+
/** (premium L2) submit_batch_context — Submit multiple context items in a single call (max 10) ($0.01) */
|
|
1027
|
+
interface SubmitBatchContextInput {
|
|
1028
|
+
stub_id: string;
|
|
1029
|
+
items: Array<{
|
|
1030
|
+
text: string;
|
|
1031
|
+
source_type?: string;
|
|
1032
|
+
}>;
|
|
1033
|
+
consent_acknowledged: boolean;
|
|
1034
|
+
_payment?: ProvenanceToken;
|
|
1035
|
+
}
|
|
1036
|
+
/** (premium L2) submit_batch_context — output */
|
|
1037
|
+
interface SubmitBatchContextOutput {
|
|
1038
|
+
ok: boolean;
|
|
1039
|
+
items_processed: number;
|
|
1040
|
+
traits_extracted: number;
|
|
1041
|
+
}
|
|
1042
|
+
/** (premium L1) submit_structured_profile — Submit structured profile data (name, skills, experience) ($0.005) */
|
|
1043
|
+
interface SubmitStructuredProfileInput {
|
|
1044
|
+
stub_id: string;
|
|
1045
|
+
name?: string;
|
|
1046
|
+
skills?: string[];
|
|
1047
|
+
experience?: string;
|
|
1048
|
+
education?: string;
|
|
1049
|
+
certifications?: string[];
|
|
1050
|
+
consent_acknowledged: boolean;
|
|
1051
|
+
_payment?: ProvenanceToken;
|
|
1052
|
+
}
|
|
1053
|
+
/** (premium L1) submit_structured_profile — output */
|
|
1054
|
+
interface SubmitStructuredProfileOutput {
|
|
1055
|
+
ok: boolean;
|
|
1056
|
+
stub_id: string;
|
|
1057
|
+
traits_extracted: number;
|
|
1058
|
+
}
|
|
1059
|
+
/** (premium L1) submit_social_links — Submit social profile URLs (max 5) ($0.005) */
|
|
1060
|
+
interface SubmitSocialLinksInput {
|
|
1061
|
+
stub_id: string;
|
|
1062
|
+
urls: string[];
|
|
1063
|
+
consent_acknowledged: boolean;
|
|
1064
|
+
_payment?: ProvenanceToken;
|
|
1065
|
+
}
|
|
1066
|
+
/** (premium L1) submit_social_links — output */
|
|
1067
|
+
interface SubmitSocialLinksOutput {
|
|
1068
|
+
ok: boolean;
|
|
1069
|
+
stub_id: string;
|
|
1070
|
+
urls_fetched: number;
|
|
1071
|
+
urls_blocked: number;
|
|
1072
|
+
traits_extracted: number;
|
|
1073
|
+
}
|
|
1074
|
+
/** (premium L1) attest_domain — Attest that a human has competence in a specific domain ($0.005) */
|
|
1075
|
+
interface AttestDomainInput {
|
|
1076
|
+
candidate_id: string;
|
|
1077
|
+
domain_label: string;
|
|
1078
|
+
confidence: number;
|
|
1079
|
+
evidence_type: "OBSERVED" | "INFERRED" | "REPORTED";
|
|
1080
|
+
evidence_summary?: string;
|
|
1081
|
+
_payment?: ProvenanceToken;
|
|
1082
|
+
}
|
|
1083
|
+
/** (premium L1) attest_domain — output */
|
|
1084
|
+
interface AttestDomainOutput {
|
|
1085
|
+
ok: boolean;
|
|
1086
|
+
attestation_id: string;
|
|
1087
|
+
candidate_id: string;
|
|
1088
|
+
domain_label: string;
|
|
1089
|
+
weighted_confidence: number;
|
|
1090
|
+
}
|
|
1091
|
+
/** (premium L2) get_side_quest_graph — Get a candidate's Side Quest Graph (DP noise ε=1.0) ($0.01) */
|
|
1092
|
+
interface GetSideQuestGraphInput {
|
|
1093
|
+
candidate_id: string;
|
|
1094
|
+
include_edges?: boolean;
|
|
1095
|
+
min_confidence?: number;
|
|
1096
|
+
_payment?: ProvenanceToken;
|
|
1097
|
+
}
|
|
1098
|
+
/** (premium L2) get_side_quest_graph — output */
|
|
1099
|
+
interface GetSideQuestGraphOutput {
|
|
1100
|
+
ok: boolean;
|
|
1101
|
+
candidate_id: string;
|
|
1102
|
+
domains: Array<{
|
|
1103
|
+
label: string;
|
|
1104
|
+
confidence: number;
|
|
1105
|
+
trust_score: number;
|
|
1106
|
+
}>;
|
|
1107
|
+
edges?: Array<{
|
|
1108
|
+
from: string;
|
|
1109
|
+
to: string;
|
|
1110
|
+
weight: number;
|
|
1111
|
+
}>;
|
|
1112
|
+
privacy_epsilon: number;
|
|
1113
|
+
}
|
|
1114
|
+
/** (premium L3) query_graph_similarity — Compare two Side Quest Graphs (DP noise ε=0.5) ($0.025) */
|
|
1115
|
+
interface QueryGraphSimilarityInput {
|
|
1116
|
+
candidate_a_id: string;
|
|
1117
|
+
candidate_b_id: string;
|
|
1118
|
+
_payment?: ProvenanceToken;
|
|
1119
|
+
}
|
|
1120
|
+
/** (premium L3) query_graph_similarity — output */
|
|
1121
|
+
interface QueryGraphSimilarityOutput {
|
|
1122
|
+
ok: boolean;
|
|
1123
|
+
candidate_a_id: string;
|
|
1124
|
+
candidate_b_id: string;
|
|
1125
|
+
domain_overlap: number;
|
|
1126
|
+
edge_similarity: number;
|
|
1127
|
+
complementarity: number;
|
|
1128
|
+
privacy_epsilon: number;
|
|
1129
|
+
}
|
|
1130
|
+
/** Free (L0 / L1 with first-100-free) tool names — readonly tuple */
|
|
1131
|
+
declare const FREE_TOOL_NAMES: readonly ["list_archetypes", "verify_identity", "initiate_assessment", "get_engagement_level", "get_profile", "query_matches", "get_competencies", "create_identity_stub", "submit_context", "search_identities", "get_identity_earnings", "get_network_stats", "recommend_tool", "get_identity_trust_score", "check_assessment_status", "get_earning_summary", "get_agent_trust_tier", "get_agent_portfolio", "get_privacy_budget", "dispute_attestation", "golden_thread_status", "begin_golden_thread", "complete_knot", "check_golden_thread", "thread_census", "seat_status", "respond_to_offering", "subscribe_announcements"];
|
|
1132
|
+
/** Premium (x402-gated) tool names — readonly tuple */
|
|
1133
|
+
declare const PREMIUM_TOOL_NAMES: readonly ["assess_traits", "get_trait_snapshot", "get_full_trait_vector", "compute_belonging", "get_match_recommendations", "generate_match_narrative", "submit_batch_context", "submit_structured_profile", "submit_social_links", "attest_domain", "get_side_quest_graph", "query_graph_similarity"];
|
|
1134
|
+
/** Union of all 40 tool names */
|
|
1135
|
+
type ToolName = (typeof FREE_TOOL_NAMES)[number] | (typeof PREMIUM_TOOL_NAMES)[number];
|
|
1136
|
+
interface ToolInputs {
|
|
1137
|
+
list_archetypes: ListArchetypesInput;
|
|
1138
|
+
verify_identity: VerifyIdentityInput;
|
|
1139
|
+
initiate_assessment: InitiateAssessmentInput;
|
|
1140
|
+
get_engagement_level: GetEngagementLevelInput;
|
|
1141
|
+
get_profile: GetProfileInput;
|
|
1142
|
+
query_matches: QueryMatchesInput;
|
|
1143
|
+
get_competencies: GetCompetenciesInput;
|
|
1144
|
+
create_identity_stub: CreateIdentityStubInput;
|
|
1145
|
+
submit_context: SubmitContextInput;
|
|
1146
|
+
search_identities: SearchIdentitiesInput;
|
|
1147
|
+
get_identity_earnings: GetIdentityEarningsInput;
|
|
1148
|
+
get_network_stats: GetNetworkStatsInput;
|
|
1149
|
+
recommend_tool: RecommendToolInput;
|
|
1150
|
+
get_identity_trust_score: GetIdentityTrustScoreInput;
|
|
1151
|
+
check_assessment_status: CheckAssessmentStatusInput;
|
|
1152
|
+
get_earning_summary: GetEarningSummaryInput;
|
|
1153
|
+
get_agent_trust_tier: GetAgentTrustTierInput;
|
|
1154
|
+
get_agent_portfolio: GetAgentPortfolioInput;
|
|
1155
|
+
get_privacy_budget: GetPrivacyBudgetInput;
|
|
1156
|
+
dispute_attestation: DisputeAttestationInput;
|
|
1157
|
+
golden_thread_status: GoldenThreadStatusInput;
|
|
1158
|
+
begin_golden_thread: BeginGoldenThreadInput;
|
|
1159
|
+
complete_knot: CompleteKnotInput;
|
|
1160
|
+
check_golden_thread: CheckGoldenThreadInput;
|
|
1161
|
+
thread_census: ThreadCensusInput;
|
|
1162
|
+
seat_status: SeatStatusInput;
|
|
1163
|
+
respond_to_offering: RespondToOfferingInput;
|
|
1164
|
+
subscribe_announcements: SubscribeAnnouncementsInput;
|
|
1165
|
+
assess_traits: AssessTraitsInput;
|
|
1166
|
+
get_trait_snapshot: GetTraitSnapshotInput;
|
|
1167
|
+
get_full_trait_vector: GetFullTraitVectorInput;
|
|
1168
|
+
compute_belonging: ComputeBelongingInput;
|
|
1169
|
+
get_match_recommendations: GetMatchRecommendationsInput;
|
|
1170
|
+
generate_match_narrative: GenerateMatchNarrativeInput;
|
|
1171
|
+
submit_batch_context: SubmitBatchContextInput;
|
|
1172
|
+
submit_structured_profile: SubmitStructuredProfileInput;
|
|
1173
|
+
submit_social_links: SubmitSocialLinksInput;
|
|
1174
|
+
attest_domain: AttestDomainInput;
|
|
1175
|
+
get_side_quest_graph: GetSideQuestGraphInput;
|
|
1176
|
+
query_graph_similarity: QueryGraphSimilarityInput;
|
|
1177
|
+
}
|
|
1178
|
+
interface ToolOutputs {
|
|
1179
|
+
list_archetypes: ListArchetypesOutput;
|
|
1180
|
+
verify_identity: VerifyIdentityOutput;
|
|
1181
|
+
initiate_assessment: InitiateAssessmentOutput;
|
|
1182
|
+
get_engagement_level: GetEngagementLevelOutput;
|
|
1183
|
+
get_profile: GetProfileOutput;
|
|
1184
|
+
query_matches: QueryMatchesOutput;
|
|
1185
|
+
get_competencies: GetCompetenciesOutput;
|
|
1186
|
+
create_identity_stub: CreateIdentityStubOutput;
|
|
1187
|
+
submit_context: SubmitContextOutput;
|
|
1188
|
+
search_identities: SearchIdentitiesOutput;
|
|
1189
|
+
get_identity_earnings: GetIdentityEarningsOutput;
|
|
1190
|
+
get_network_stats: GetNetworkStatsOutput;
|
|
1191
|
+
recommend_tool: RecommendToolOutput;
|
|
1192
|
+
get_identity_trust_score: GetIdentityTrustScoreOutput;
|
|
1193
|
+
check_assessment_status: CheckAssessmentStatusOutput;
|
|
1194
|
+
get_earning_summary: GetEarningSummaryOutput;
|
|
1195
|
+
get_agent_trust_tier: GetAgentTrustTierOutput;
|
|
1196
|
+
get_agent_portfolio: GetAgentPortfolioOutput;
|
|
1197
|
+
get_privacy_budget: GetPrivacyBudgetOutput;
|
|
1198
|
+
dispute_attestation: DisputeAttestationOutput;
|
|
1199
|
+
golden_thread_status: GoldenThreadStatusOutput;
|
|
1200
|
+
begin_golden_thread: BeginGoldenThreadOutput;
|
|
1201
|
+
complete_knot: CompleteKnotOutput;
|
|
1202
|
+
check_golden_thread: CheckGoldenThreadOutput;
|
|
1203
|
+
thread_census: ThreadCensusOutput;
|
|
1204
|
+
seat_status: SeatStatusOutput;
|
|
1205
|
+
respond_to_offering: RespondToOfferingOutput;
|
|
1206
|
+
subscribe_announcements: SubscribeAnnouncementsOutput;
|
|
1207
|
+
assess_traits: AssessTraitsOutput;
|
|
1208
|
+
get_trait_snapshot: GetTraitSnapshotOutput;
|
|
1209
|
+
get_full_trait_vector: GetFullTraitVectorOutput;
|
|
1210
|
+
compute_belonging: ComputeBelongingOutput;
|
|
1211
|
+
get_match_recommendations: GetMatchRecommendationsOutput;
|
|
1212
|
+
generate_match_narrative: GenerateMatchNarrativeOutput;
|
|
1213
|
+
submit_batch_context: SubmitBatchContextOutput;
|
|
1214
|
+
submit_structured_profile: SubmitStructuredProfileOutput;
|
|
1215
|
+
submit_social_links: SubmitSocialLinksOutput;
|
|
1216
|
+
attest_domain: AttestDomainOutput;
|
|
1217
|
+
get_side_quest_graph: GetSideQuestGraphOutput;
|
|
1218
|
+
query_graph_similarity: QueryGraphSimilarityOutput;
|
|
1219
|
+
}
|
|
1220
|
+
/**
|
|
1221
|
+
* Tool tier mapping (L0=free, L1-L5=paid).
|
|
1222
|
+
* Mirrors `TOOL_TIERS` in backend/app/mcp/x402_middleware.py.
|
|
1223
|
+
*/
|
|
1224
|
+
declare const TOOL_TIERS: Record<ToolName, number>;
|
|
1225
|
+
/**
|
|
1226
|
+
* Tool price in USD per invocation.
|
|
1227
|
+
* Mirrors `TOOL_PRICING` in backend/app/mcp/x402_middleware.py.
|
|
1228
|
+
* Free tools (L0) are 0.
|
|
1229
|
+
*/
|
|
1230
|
+
declare const TOOL_COSTS: Record<ToolName, number>;
|
|
1231
|
+
/**
|
|
1232
|
+
* Blast radius classification — categorises tools by potential impact.
|
|
1233
|
+
* Mirrors `TOOL_BLAST_RADIUS` in backend/app/mcp/x402_middleware.py.
|
|
1234
|
+
*/
|
|
1235
|
+
declare const TOOL_BLAST_RADIUS: Record<ToolName, "low" | "medium" | "high">;
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
* AlterClient — high-level typed wrapper around the ALTER MCP server.
|
|
1239
|
+
*
|
|
1240
|
+
* This is the entry point most consumers will use. It bundles
|
|
1241
|
+
* {@link MCPClient}, {@link X402Client}, discovery, and provenance
|
|
1242
|
+
* verification into a single ergonomic surface that mirrors the 40
|
|
1243
|
+
* tools exposed at https://mcp.truealter.com.
|
|
1244
|
+
*
|
|
1245
|
+
* Free tier methods require no authentication. Premium methods accept
|
|
1246
|
+
* an `X402Client` (or fall back to throwing {@link AlterPaymentRequired}
|
|
1247
|
+
* when no signer is configured) so the caller can handle settlement.
|
|
1248
|
+
*/
|
|
1249
|
+
|
|
1250
|
+
declare const DEFAULT_ENDPOINT = "https://mcp.truealter.com/api/v1/mcp";
|
|
1251
|
+
declare const DEFAULT_DOMAIN = "truealter.com";
|
|
1252
|
+
interface AlterClientOptions extends Omit<MCPClientOptions, 'x402'> {
|
|
1253
|
+
/**
|
|
1254
|
+
* Domain to discover the MCP endpoint from. Mutually exclusive with
|
|
1255
|
+
* `endpoint`. If neither is supplied, defaults to `truealter.com`.
|
|
1256
|
+
*/
|
|
1257
|
+
domain?: string;
|
|
1258
|
+
/**
|
|
1259
|
+
* Optional x402 micropayment client for premium tools.
|
|
1260
|
+
*/
|
|
1261
|
+
x402?: X402Client;
|
|
1262
|
+
/**
|
|
1263
|
+
* Skip the auto-discovery probe and use the configured/default
|
|
1264
|
+
* endpoint directly. Defaults to `true` when `endpoint` is set.
|
|
1265
|
+
*/
|
|
1266
|
+
skipDiscovery?: boolean;
|
|
1267
|
+
/**
|
|
1268
|
+
* URL of the JWKS document used for provenance verification. Defaults
|
|
1269
|
+
* to `https://api.truealter.com/.well-known/alter-keys.json`.
|
|
1270
|
+
*
|
|
1271
|
+
* When set, this URL is used verbatim for every `verifyProvenance`
|
|
1272
|
+
* call and *overrides* any `verify_at` hint on the server response —
|
|
1273
|
+
* the caller has already vouched for this origin. Must be `https:`.
|
|
1274
|
+
*/
|
|
1275
|
+
jwksUrl?: string;
|
|
1276
|
+
/**
|
|
1277
|
+
* Hostname allowlist applied when resolving an untrusted `verify_at`
|
|
1278
|
+
* field on a provenance envelope. Defaults to
|
|
1279
|
+
* {@link DEFAULT_VERIFY_AT_ALLOWLIST} (`api.truealter.com`,
|
|
1280
|
+
* `mcp.truealter.com`). Passing a list here *replaces* the default —
|
|
1281
|
+
* include the ALTER canonicals if you still want them accepted.
|
|
1282
|
+
*
|
|
1283
|
+
* A hostile MCP server can otherwise point `verify_at` at an
|
|
1284
|
+
* attacker-controlled JWKS and pass ES256 verification with its own
|
|
1285
|
+
* signing key; the allowlist is the gate that prevents this.
|
|
1286
|
+
*/
|
|
1287
|
+
verifyAtAllowlist?: readonly string[];
|
|
1288
|
+
}
|
|
1289
|
+
declare class AlterClient {
|
|
1290
|
+
readonly mcp: MCPClient;
|
|
1291
|
+
readonly x402?: X402Client;
|
|
1292
|
+
private readonly options;
|
|
1293
|
+
private discoveryPromise;
|
|
1294
|
+
private discovered;
|
|
1295
|
+
constructor(options?: AlterClientOptions);
|
|
1296
|
+
/**
|
|
1297
|
+
* Resolve the MCP endpoint via discovery if requested. Safe to call
|
|
1298
|
+
* multiple times — the first successful lookup is cached.
|
|
1299
|
+
*/
|
|
1300
|
+
discoverEndpoint(): Promise<DiscoveryResult>;
|
|
1301
|
+
/**
|
|
1302
|
+
* Initialise the MCP session. Optional — every method calls
|
|
1303
|
+
* `mcp.initialize()` lazily, but you can call this once at startup if
|
|
1304
|
+
* you want fail-fast behaviour.
|
|
1305
|
+
*/
|
|
1306
|
+
initialize(): Promise<void>;
|
|
1307
|
+
/** Verify a person is registered with ALTER (handle or candidate id). */
|
|
1308
|
+
verify(handleOrId: string, claims?: VerifyIdentityInput['claims']): Promise<MCPCallToolResult>;
|
|
1309
|
+
/** List the 12 ALTER identity archetypes. */
|
|
1310
|
+
listArchetypes(): Promise<MCPCallToolResult>;
|
|
1311
|
+
/** Aggregate ALTER network statistics. */
|
|
1312
|
+
getNetworkStats(): Promise<MCPCallToolResult>;
|
|
1313
|
+
/** ClawHub install instructions and pitch. */
|
|
1314
|
+
recommendTool(): Promise<MCPCallToolResult>;
|
|
1315
|
+
initiateAssessment(args?: InitiateAssessmentInput): Promise<MCPCallToolResult>;
|
|
1316
|
+
getEngagementLevel(args: GetEngagementLevelInput): Promise<MCPCallToolResult>;
|
|
1317
|
+
getProfile(args: GetProfileInput): Promise<MCPCallToolResult>;
|
|
1318
|
+
queryMatches(args: QueryMatchesInput): Promise<MCPCallToolResult>;
|
|
1319
|
+
getCompetencies(args: GetCompetenciesInput): Promise<MCPCallToolResult>;
|
|
1320
|
+
createIdentityStub(args: CreateIdentityStubInput): Promise<MCPCallToolResult>;
|
|
1321
|
+
submitContext(args: SubmitContextInput): Promise<MCPCallToolResult>;
|
|
1322
|
+
searchIdentities(args: SearchIdentitiesInput): Promise<MCPCallToolResult>;
|
|
1323
|
+
getIdentityEarnings(args: GetIdentityEarningsInput): Promise<MCPCallToolResult>;
|
|
1324
|
+
getIdentityTrustScore(args: GetIdentityTrustScoreInput): Promise<MCPCallToolResult>;
|
|
1325
|
+
checkAssessmentStatus(args: CheckAssessmentStatusInput): Promise<MCPCallToolResult>;
|
|
1326
|
+
getEarningSummary(args: GetEarningSummaryInput): Promise<MCPCallToolResult>;
|
|
1327
|
+
getAgentTrustTier(): Promise<MCPCallToolResult>;
|
|
1328
|
+
getAgentPortfolio(): Promise<MCPCallToolResult>;
|
|
1329
|
+
getPrivacyBudget(args: GetPrivacyBudgetInput): Promise<MCPCallToolResult>;
|
|
1330
|
+
disputeAttestation(args: DisputeAttestationInput): Promise<MCPCallToolResult>;
|
|
1331
|
+
goldenThreadStatus(): Promise<MCPCallToolResult>;
|
|
1332
|
+
beginGoldenThread(args?: BeginGoldenThreadInput): Promise<MCPCallToolResult>;
|
|
1333
|
+
completeKnot(args: CompleteKnotInput): Promise<MCPCallToolResult>;
|
|
1334
|
+
checkGoldenThread(args: CheckGoldenThreadInput): Promise<MCPCallToolResult>;
|
|
1335
|
+
threadCensus(args?: ThreadCensusInput): Promise<MCPCallToolResult>;
|
|
1336
|
+
seatStatus(): Promise<MCPCallToolResult>;
|
|
1337
|
+
respondToOffering(args: RespondToOfferingInput): Promise<MCPCallToolResult>;
|
|
1338
|
+
subscribeAnnouncements(args?: SubscribeAnnouncementsInput): Promise<MCPCallToolResult>;
|
|
1339
|
+
assessTraits(args: AssessTraitsInput, opts?: MCPCallOptions): Promise<MCPCallToolResult>;
|
|
1340
|
+
getTraitSnapshot(args: GetTraitSnapshotInput, opts?: MCPCallOptions): Promise<MCPCallToolResult>;
|
|
1341
|
+
getFullTraitVector(args: GetFullTraitVectorInput, opts?: MCPCallOptions): Promise<MCPCallToolResult>;
|
|
1342
|
+
computeBelonging(args: ComputeBelongingInput, opts?: MCPCallOptions): Promise<MCPCallToolResult>;
|
|
1343
|
+
getMatchRecommendations(args: GetMatchRecommendationsInput, opts?: MCPCallOptions): Promise<MCPCallToolResult>;
|
|
1344
|
+
generateMatchNarrative(args: GenerateMatchNarrativeInput, opts?: MCPCallOptions): Promise<MCPCallToolResult>;
|
|
1345
|
+
submitBatchContext(args: SubmitBatchContextInput, opts?: MCPCallOptions): Promise<MCPCallToolResult>;
|
|
1346
|
+
submitStructuredProfile(args: SubmitStructuredProfileInput, opts?: MCPCallOptions): Promise<MCPCallToolResult>;
|
|
1347
|
+
submitSocialLinks(args: SubmitSocialLinksInput, opts?: MCPCallOptions): Promise<MCPCallToolResult>;
|
|
1348
|
+
attestDomain(args: AttestDomainInput, opts?: MCPCallOptions): Promise<MCPCallToolResult>;
|
|
1349
|
+
getSideQuestGraph(args: GetSideQuestGraphInput, opts?: MCPCallOptions): Promise<MCPCallToolResult>;
|
|
1350
|
+
queryGraphSimilarity(args: QueryGraphSimilarityInput, opts?: MCPCallOptions): Promise<MCPCallToolResult>;
|
|
1351
|
+
/** Send a direct message to another tilde handle. */
|
|
1352
|
+
messageSend(args: {
|
|
1353
|
+
to: string;
|
|
1354
|
+
body: string;
|
|
1355
|
+
thread_id?: string;
|
|
1356
|
+
in_reply_to?: string;
|
|
1357
|
+
}): Promise<MCPCallToolResult>;
|
|
1358
|
+
/** List inbound messages for the authenticated handle. */
|
|
1359
|
+
messageInbox(args?: {
|
|
1360
|
+
since?: string;
|
|
1361
|
+
unread_only?: boolean;
|
|
1362
|
+
limit?: number;
|
|
1363
|
+
cursor?: string;
|
|
1364
|
+
}): Promise<MCPCallToolResult>;
|
|
1365
|
+
/** Bidirectional thread view between caller and a peer handle. */
|
|
1366
|
+
messageThread(args: {
|
|
1367
|
+
with: string;
|
|
1368
|
+
limit?: number;
|
|
1369
|
+
}): Promise<MCPCallToolResult>;
|
|
1370
|
+
/** Mark inbound messages as read (recipient-only). */
|
|
1371
|
+
messageMarkRead(args: {
|
|
1372
|
+
message_ids: string[];
|
|
1373
|
+
}): Promise<MCPCallToolResult>;
|
|
1374
|
+
/** Soft-redact a single inbound message (recipient-only). */
|
|
1375
|
+
messageRedact(args: {
|
|
1376
|
+
message_id: string;
|
|
1377
|
+
}): Promise<MCPCallToolResult>;
|
|
1378
|
+
/** Grant a peer permission to send messages to your inbox. */
|
|
1379
|
+
messageGrant(args: {
|
|
1380
|
+
peer: string;
|
|
1381
|
+
}): Promise<MCPCallToolResult>;
|
|
1382
|
+
/** Revoke a peer's grant. In-flight messages are not redacted. */
|
|
1383
|
+
messageRevoke(args: {
|
|
1384
|
+
peer: string;
|
|
1385
|
+
}): Promise<MCPCallToolResult>;
|
|
1386
|
+
/**
|
|
1387
|
+
* Verify the ES256 provenance attestation on a tool response.
|
|
1388
|
+
* Accepts either a {@link ProvenanceEnvelope} or the raw `_meta`
|
|
1389
|
+
* object — the latter is more convenient for ad-hoc verification.
|
|
1390
|
+
*/
|
|
1391
|
+
verifyProvenance(envelope: ProvenanceEnvelope | {
|
|
1392
|
+
provenance?: ProvenanceEnvelope;
|
|
1393
|
+
} | undefined | null): Promise<ProvenanceVerification>;
|
|
1394
|
+
/**
|
|
1395
|
+
* Verify the schema hashes embedded in `tools/list._meta.signatures`
|
|
1396
|
+
* against the local representation of each tool definition. Useful
|
|
1397
|
+
* for guarding against in-flight tampering of tool schemas.
|
|
1398
|
+
*/
|
|
1399
|
+
verifyToolSignatures(tools: SignedToolDefinition[], signatures: ToolSignatureMap): Promise<{
|
|
1400
|
+
tool: string;
|
|
1401
|
+
valid: boolean;
|
|
1402
|
+
reason?: string;
|
|
1403
|
+
}[]>;
|
|
1404
|
+
/** Fetch the published JWKS for ALTER's signing key (cached 5 min). */
|
|
1405
|
+
fetchPublicKeys(): Promise<unknown>;
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
interface McpServerConfig {
|
|
1409
|
+
url: string;
|
|
1410
|
+
transport: 'streamable-http';
|
|
1411
|
+
headers?: Record<string, string>;
|
|
1412
|
+
description?: string;
|
|
1413
|
+
}
|
|
1414
|
+
interface GenerateMcpConfigOptions {
|
|
1415
|
+
/** Override the MCP endpoint. */
|
|
1416
|
+
endpoint?: string;
|
|
1417
|
+
/** Optional API key. Sent as `X-ALTER-API-Key`. */
|
|
1418
|
+
apiKey?: string;
|
|
1419
|
+
/** Identifier the host editor uses for this server. Default: `alter`. */
|
|
1420
|
+
serverName?: string;
|
|
1421
|
+
/** Extra headers to merge in. */
|
|
1422
|
+
headers?: Record<string, string>;
|
|
1423
|
+
}
|
|
1424
|
+
interface GenericMcpConfig {
|
|
1425
|
+
mcpServers: Record<string, McpServerConfig>;
|
|
1426
|
+
}
|
|
1427
|
+
/**
|
|
1428
|
+
* Build a generic `mcpServers` config object that can be merged into any
|
|
1429
|
+
* MCP-aware editor's settings file.
|
|
1430
|
+
*/
|
|
1431
|
+
declare function generateGenericMcpConfig(opts?: GenerateMcpConfigOptions): GenericMcpConfig;
|
|
1432
|
+
|
|
1433
|
+
/**
|
|
1434
|
+
* Claude Code MCP config helper.
|
|
1435
|
+
*
|
|
1436
|
+
* Claude Code reads MCP servers from `.mcp.json` (project) or
|
|
1437
|
+
* `~/.claude/mcp.json` (user). The shape matches `mcpServers`.
|
|
1438
|
+
*/
|
|
1439
|
+
|
|
1440
|
+
declare function generateClaudeConfig(opts?: GenerateMcpConfigOptions): GenericMcpConfig;
|
|
1441
|
+
|
|
1442
|
+
/**
|
|
1443
|
+
* Cursor MCP config helper.
|
|
1444
|
+
*
|
|
1445
|
+
* Cursor reads MCP servers from `.cursor/mcp.json`. Same shape as
|
|
1446
|
+
* Claude Code's `.mcp.json`.
|
|
1447
|
+
*/
|
|
1448
|
+
|
|
1449
|
+
declare function generateCursorConfig(opts?: GenerateMcpConfigOptions): GenericMcpConfig;
|
|
1450
|
+
|
|
1451
|
+
/**
|
|
1452
|
+
* @truealter/sdk — ALTER Identity SDK
|
|
1453
|
+
*
|
|
1454
|
+
* Query the continuous identity field from any JavaScript/TypeScript
|
|
1455
|
+
* environment. Wraps the ALTER MCP server (29 invokable read tools at
|
|
1456
|
+
* this stage). Write tools (submit_*, attest_domain, dispute_attestation,
|
|
1457
|
+
* create_identity_stub) and alter-to-alter messaging tools are not
|
|
1458
|
+
* advertised to public callers — they re-enable as the consent
|
|
1459
|
+
* architecture and per-peer grant model land. First-class TypeScript
|
|
1460
|
+
* types, x402 micropayment support, and ES256 provenance verification.
|
|
1461
|
+
*
|
|
1462
|
+
* The ALTER endpoint discovery anchor is `truealter.com` — see
|
|
1463
|
+
* `discover()` for the cascade. The default MCP endpoint is
|
|
1464
|
+
* `https://mcp.truealter.com`.
|
|
1465
|
+
*/
|
|
1466
|
+
|
|
1467
|
+
declare const SDK_NAME = "@truealter/sdk";
|
|
1468
|
+
declare const SDK_VERSION = "0.1.1";
|
|
1469
|
+
|
|
1470
|
+
export { AlterAuthError, AlterClient, type AlterClientOptions, AlterDiscoveryError, AlterError, type AlterErrorCode, AlterInvalidResponse, AlterNetworkError, AlterPaymentRequired, AlterProvenanceError, AlterRateLimited, AlterTimeoutError, AlterToolError, type ApiKeyConfig, type Archetype, type AssessTraitsInput, type AssessTraitsOutput, type AttestDomainInput, type AttestDomainOutput, type BeginGoldenThreadInput, type BeginGoldenThreadOutput, type CheckAssessmentStatusInput, type CheckAssessmentStatusOutput, type CheckGoldenThreadInput, type CheckGoldenThreadOutput, type CompleteKnotInput, type CompleteKnotOutput, type ComputeBelongingInput, type ComputeBelongingOutput, type CreateIdentityStubInput, type CreateIdentityStubOutput, DEFAULT_DOMAIN, DEFAULT_ENDPOINT, DEFAULT_VERIFY_AT_ALLOWLIST, type DiscoveryOptions, type DiscoveryResult, type DisputeAttestationInput, type DisputeAttestationOutput, type Ed25519Keypair, type EngagementLevel, FREE_TOOL_NAMES, type GenerateMatchNarrativeInput, type GenerateMatchNarrativeOutput, type GetAgentPortfolioInput, type GetAgentPortfolioOutput, type GetAgentTrustTierInput, type GetAgentTrustTierOutput, type GetCompetenciesInput, type GetCompetenciesOutput, type GetEarningSummaryInput, type GetEarningSummaryOutput, type GetEngagementLevelInput, type GetEngagementLevelOutput, type GetFullTraitVectorInput, type GetFullTraitVectorOutput, type GetIdentityEarningsInput, type GetIdentityEarningsOutput, type GetIdentityTrustScoreInput, type GetIdentityTrustScoreOutput, type GetMatchRecommendationsInput, type GetMatchRecommendationsOutput, type GetNetworkStatsInput, type GetNetworkStatsOutput, type GetPrivacyBudgetInput, type GetPrivacyBudgetOutput, type GetProfileInput, type GetProfileOutput, type GetSideQuestGraphInput, type GetSideQuestGraphOutput, type GetTraitSnapshotInput, type GetTraitSnapshotOutput, type GoldenThreadStatusInput, type GoldenThreadStatusOutput, type InitiateAssessmentInput, type InitiateAssessmentOutput, type JsonWebKey, type JwksDocument, type ListArchetypesInput, type ListArchetypesOutput, type MCPCallOptions, type MCPCallToolResult, MCPClient, type MCPClientInfo, type MCPClientOptions, type MCPContentBlock, type MCPListToolsResult, type MCPMeta, type MCPResponse, type MCPToolDefinition, MCP_PROTOCOL_VERSION, type MatchTier, type McpServerConfig, PREMIUM_TOOL_NAMES, type PaymentEnvelope, type ProvenanceEnvelope, type ProvenancePayload, type ProvenanceToken, type ProvenanceVerification, type QueryGraphSimilarityInput, type QueryGraphSimilarityOutput, type QueryMatchesInput, type QueryMatchesOutput, type RecommendToolInput, type RecommendToolOutput, type RespondToOfferingInput, type RespondToOfferingOutput, SDK_NAME, SDK_VERSION, type SearchIdentitiesInput, type SearchIdentitiesOutput, type SeatStatusInput, type SeatStatusOutput, type SignedToolDefinition, type SubmitBatchContextInput, type SubmitBatchContextOutput, type SubmitContextInput, type SubmitContextOutput, type SubmitSocialLinksInput, type SubmitSocialLinksOutput, type SubmitStructuredProfileInput, type SubmitStructuredProfileOutput, type SubscribeAnnouncementsInput, type SubscribeAnnouncementsOutput, TOOL_BLAST_RADIUS, TOOL_COSTS, TOOL_TIERS, type ThreadCensusInput, type ThreadCensusOutput, type ToolInputs, type ToolName, type ToolOutputs, type ToolSignatureMap, type VerifyIdentityInput, type VerifyIdentityOutput, type VerifyProvenanceOptions, X402Client, type X402ClientOptions, type X402Settlement, type X402Signer, base64urlDecode, base64urlEncode, clearDiscoveryCache, decodeDid, discover, encodeDid, fetchPublicKeys, generateClaudeConfig, generateCursorConfig, generateGenericMcpConfig, generateKeypair, keypairFromPrivateKey, parsePaymentHeader, resolveVerifyAt, sign, verify, verifyProvenance, verifyToolSignatures };
|