@truealter/sdk 0.5.1 → 0.5.3
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 +115 -50
- package/dist/bin/alter-identity.js +383 -48
- package/dist/bin/mcp-bridge.js +40 -4
- package/dist/index.cjs +517 -64
- package/dist/index.d.cts +480 -128
- package/dist/index.d.ts +480 -128
- package/dist/index.js +496 -65
- package/package.json +3 -3
- package/dist/mcp-bridge.js +0 -166
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ A thin client over the ALTER MCP server (Streamable HTTP, JSON-RPC 2.0, MCP spec
|
|
|
12
12
|
- **Branded host:** `https://mcp.truealter.com` (serves `.well-known/mcp.json` for discovery)
|
|
13
13
|
- **JSON-RPC wire endpoint:** `https://mcp.truealter.com/api/v1/mcp` - this is what Streamable HTTP POSTs target (the SDK default)
|
|
14
14
|
- **Wire protocol:** Streamable HTTP, JSON-RPC 2.0, MCP `2025-11-25` (server negotiates `2025-06-18` + `2025-03-26` for backwards-compatible clients)
|
|
15
|
-
- **Tools:** **
|
|
15
|
+
- **Tools:** **34 publicly advertised**, 26 free (L0) + 8 premium (L1-L5), kept in sync with ALTER's live MCP server at every publish.
|
|
16
16
|
- **Runtime:** Node 18+, Deno, Bun, Cloudflare Workers, modern browsers
|
|
17
17
|
- **Crypto:** `@noble/ed25519` + `@noble/hashes` (no other dependencies)
|
|
18
18
|
- **Bundle:** ESM + CJS dual output
|
|
@@ -34,27 +34,20 @@ handshake, `tools/list`, and L0 tool calls, but it does not carry ES256
|
|
|
34
34
|
per-invocation signing - authenticated MCP tools will fail at the server
|
|
35
35
|
edge when reached through the bridge. For production use, import
|
|
36
36
|
`@truealter/sdk` directly and construct an `MCPClient` / `AlterClient` with
|
|
37
|
-
the optional `signing` parameter; that path is the
|
|
38
|
-
carries the provenance envelope end-to-end. Bridge signing
|
|
39
|
-
|
|
37
|
+
the optional `signing` parameter; that path is the primary one and
|
|
38
|
+
carries the provenance envelope end-to-end. Bridge signing is planned for a
|
|
39
|
+
future release.
|
|
40
40
|
|
|
41
41
|
## CLI
|
|
42
42
|
|
|
43
43
|
The package ships two binaries. `alter-identity` is the full SDK-feature
|
|
44
|
-
binary (`init`, `verify`, `whoami`, wire/unwire, signing, etc).
|
|
45
|
-
is
|
|
44
|
+
binary (`init`, `verify`, `whoami`, wire/unwire, signing, etc).
|
|
45
|
+
`alter-mcp-bridge` is the stdio bridge described above. The day-to-day
|
|
46
|
+
`alter` command line is distributed separately as
|
|
47
|
+
[`@truealter/cli`](https://www.npmjs.com/package/@truealter/cli) - it is
|
|
48
|
+
not part of this package.
|
|
46
49
|
|
|
47
|
-
|
|
48
|
-
|---|---|
|
|
49
|
-
| `alter login` | OAuth loopback sign-in; stores a session at `~/.config/alter/session.json` (mode `0600`). |
|
|
50
|
-
| `alter depth [--json]` | GET `/api/v1/identity/depth` - identity-depth score, agentic activity, top/bottom five traits. |
|
|
51
|
-
| `alter claim <claim_code>` | Accept an identity invite. Prompts for email, password (min 12 chars, hidden), and explicit TOS acceptance, then POSTs `/api/v1/identity/claim`. |
|
|
52
|
-
| `alter mirror` | Day-2 Mirror phase + streak. `alter mirror daily` claims today's Mirror; `alter mirror next` shows the next revelation window. |
|
|
53
|
-
| `alter discover [--limit N]` | MCP-backed summary - calls `alter_whoami` and `alter_verify` against your bound handle. Degrades gracefully if the MCP endpoint is 5xx. |
|
|
54
|
-
|
|
55
|
-
The session file is created with `0600` permissions; its parent dir
|
|
56
|
-
(`~/.config/alter/`) is created with `0700`. Override the config root
|
|
57
|
-
via `XDG_CONFIG_HOME`. Run `alter --help` for the inline reference.
|
|
50
|
+
Run `alter-identity --help` for the inline reference.
|
|
58
51
|
|
|
59
52
|
## Why ALTER ≠ IAM
|
|
60
53
|
|
|
@@ -94,6 +87,90 @@ const alter = new AlterClient({
|
|
|
94
87
|
});
|
|
95
88
|
```
|
|
96
89
|
|
|
90
|
+
### Minimum-version preflight (required)
|
|
91
|
+
|
|
92
|
+
ALTER's backend publishes a per-client minimum-version floor. The SDK
|
|
93
|
+
preflights this floor lazily on the first network call: no explicit
|
|
94
|
+
call is required for the common case. If the running SDK is below the
|
|
95
|
+
floor for `alter-identity`, the SDK throws `BelowFloorError` with the
|
|
96
|
+
upgrade command attached.
|
|
97
|
+
|
|
98
|
+
The floor document is signed by the backend with a floor-only Ed25519
|
|
99
|
+
private key. The SDK ships only the corresponding public keys
|
|
100
|
+
(`KNOWN_FLOOR_PUBLIC_KEYS`, a `key_id` to SPKI-PEM map): no signing
|
|
101
|
+
secret ships in the client, and a compromised client cannot forge floor
|
|
102
|
+
documents. The `key_id` is the first 8 hex chars of SHA-256 of the raw
|
|
103
|
+
32-byte Ed25519 public key, so clients select the right key during a
|
|
104
|
+
rotation. An unknown `key_id` or an invalid signature is treated as a
|
|
105
|
+
cache miss (refetch), never as a pass.
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
import { AlterClient, BelowFloorError, checkMinVersion } from "@truealter/sdk";
|
|
109
|
+
|
|
110
|
+
// Optional: run the preflight explicitly to surface the upgrade
|
|
111
|
+
// prompt at startup, before any real work happens:
|
|
112
|
+
try {
|
|
113
|
+
await checkMinVersion();
|
|
114
|
+
} catch (err) {
|
|
115
|
+
if (err instanceof BelowFloorError) {
|
|
116
|
+
console.error(`upgrade required: ${err.upgrade_cmd}`);
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
throw err;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// The constructor installs the same hook lazily: it fires on your
|
|
123
|
+
// first request automatically:
|
|
124
|
+
const alter = new AlterClient();
|
|
125
|
+
try {
|
|
126
|
+
await alter.verify("~alter");
|
|
127
|
+
} catch (err) {
|
|
128
|
+
if (err instanceof BelowFloorError) {
|
|
129
|
+
// Re-thrown on every subsequent call until you upgrade.
|
|
130
|
+
console.error(`upgrade: ${err.upgrade_cmd}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
`BelowFloorError` carries the canonical envelope fields as enumerable
|
|
136
|
+
properties so consumers can branch without re-parsing:
|
|
137
|
+
|
|
138
|
+
| Property | Type | Example |
|
|
139
|
+
| ---------------- | ------ | ------------------------------------ |
|
|
140
|
+
| `code` | string | `"client_below_floor"` |
|
|
141
|
+
| `client_version` | string | `"0.5.2"` |
|
|
142
|
+
| `min_version` | string | `"0.6.0"` |
|
|
143
|
+
| `upgrade_cmd` | string | `"npm install -g @truealter/sdk"` |
|
|
144
|
+
| `channel` | string | `"npm"` |
|
|
145
|
+
| `envelope` | object | full `{ error: {...} }` envelope |
|
|
146
|
+
|
|
147
|
+
**Opt-out (discouraged).** Pass `unsafe_skipVersionCheck: true` to skip
|
|
148
|
+
the client-side preflight. The server-side floor gate still rejects
|
|
149
|
+
below-floor clients with HTTP 426 regardless: disabling the SDK-side
|
|
150
|
+
preflight only swaps a clean typed error for an opaque network failure
|
|
151
|
+
on every subsequent call.
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
const alter = new AlterClient({ unsafe_skipVersionCheck: true });
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Worked example: see [`examples/min-version-check/`](./examples/min-version-check/).
|
|
158
|
+
|
|
159
|
+
### Identity headers
|
|
160
|
+
|
|
161
|
+
Every outbound request from `AlterClient` / `MCPClient` carries three
|
|
162
|
+
identity headers that the server-side floor middleware consults:
|
|
163
|
+
|
|
164
|
+
| Header | Value (this SDK) |
|
|
165
|
+
| -------------------------- | ------------------ |
|
|
166
|
+
| `X-Alter-Client-Id` | `alter-identity` |
|
|
167
|
+
| `X-Alter-Client-Version` | the running `SDK_VERSION` |
|
|
168
|
+
| `X-Alter-Client-Channel` | `npm` |
|
|
169
|
+
|
|
170
|
+
These are MANDATORY on every authenticated backend endpoint per
|
|
171
|
+
D-MIN-VERSION-FLOOR-1 §3. The User-Agent header remains informational
|
|
172
|
+
and is NEVER used for floor enforcement.
|
|
173
|
+
|
|
97
174
|
### Free tier (L0 - no payment required)
|
|
98
175
|
|
|
99
176
|
```ts
|
|
@@ -128,33 +205,33 @@ const matches = await alter.searchIdentities({
|
|
|
128
205
|
const thread = await alter.goldenThreadStatus();
|
|
129
206
|
```
|
|
130
207
|
|
|
131
|
-
### Premium tier (L1
|
|
208
|
+
### Premium tier (L1-L5 - x402 payment required)
|
|
132
209
|
|
|
133
210
|
```ts
|
|
134
|
-
// L1 - Extract trait signals from text ($0.
|
|
211
|
+
// L1 - Extract trait signals from text ($0.01, first 100 free per bot)
|
|
135
212
|
const signals = await alter.assessTraits({
|
|
136
213
|
text: "I led the incident response when our payment rails went down...",
|
|
137
214
|
context: "interview transcript",
|
|
138
215
|
});
|
|
139
216
|
|
|
140
|
-
// L2 - Full 33-trait vector ($0.
|
|
217
|
+
// L2 - Full 33-trait vector ($0.10)
|
|
141
218
|
const vector = await alter.getFullTraitVector({
|
|
142
219
|
member_id: "550e8400-e29b-41d4-a716-446655440000",
|
|
143
220
|
});
|
|
144
221
|
|
|
145
|
-
// L4 - Belonging probability for a person-job pairing ($0.
|
|
222
|
+
// L4 - Belonging probability for a person-job pairing ($0.60)
|
|
146
223
|
const belonging = await alter.computeBelonging({
|
|
147
224
|
member_id: "550e8400-e29b-41d4-a716-446655440000",
|
|
148
225
|
job_id: "f47ac10b-58cc-4372-a567-0e02b2c3d479",
|
|
149
226
|
});
|
|
150
227
|
|
|
151
|
-
// L5 - Top match recommendations ($
|
|
228
|
+
// L5 - Top match recommendations ($1.00)
|
|
152
229
|
const recommendations = await alter.getMatchRecommendations({
|
|
153
230
|
member_id: "550e8400-e29b-41d4-a716-446655440000",
|
|
154
231
|
limit: 5,
|
|
155
232
|
});
|
|
156
233
|
|
|
157
|
-
// L5 - Human-readable narrative explaining a match ($
|
|
234
|
+
// L5 - Human-readable narrative explaining a match ($1.00)
|
|
158
235
|
const narrative = await alter.generateMatchNarrative({
|
|
159
236
|
match_id: "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
|
|
160
237
|
});
|
|
@@ -186,9 +263,9 @@ if (tampered.length) throw new Error(`tampered tools: ${tampered.map((t) => t.to
|
|
|
186
263
|
```ts
|
|
187
264
|
import { discover } from "@truealter/sdk";
|
|
188
265
|
|
|
189
|
-
// Three-step discovery cascade: DNS TXT
|
|
266
|
+
// Three-step discovery cascade: DNS TXT to mcp.json to alter.json
|
|
190
267
|
const descriptor = await discover("truealter.com");
|
|
191
|
-
//
|
|
268
|
+
// returns { url: "https://mcp.truealter.com/api/v1/mcp", transport, source, publicKey, x402Contract, capability }
|
|
192
269
|
```
|
|
193
270
|
|
|
194
271
|
### Low-level MCPClient
|
|
@@ -288,11 +365,11 @@ ALTER monetises premium tools via the [x402](https://x402.org) standard - HTTP `
|
|
|
288
365
|
4. Server validates the proof, executes the tool, signs the response with ES256, returns it.
|
|
289
366
|
5. AlterRouter executes the split on-chain in the same transaction. The data subject receives Identity Income directly; ALTER receives only its protocol cut. No custodian, no broker.
|
|
290
367
|
|
|
291
|
-
The SDK handles steps 2
|
|
368
|
+
The SDK handles steps 2-4 automatically when an `X402Client` with a configured `signer` is passed in.
|
|
292
369
|
|
|
293
370
|
### Tier structure
|
|
294
371
|
|
|
295
|
-
x402 micropayments at L0
|
|
372
|
+
x402 micropayments at L0-L5 trust tiers. Per-call pricing visible after `alter login`.
|
|
296
373
|
|
|
297
374
|
### Identity income split
|
|
298
375
|
|
|
@@ -388,7 +465,7 @@ ALTER follows the discovery cascade specified in [draft-morrison-mcp-dns-discove
|
|
|
388
465
|
```ts
|
|
389
466
|
import { discover } from "@truealter/sdk";
|
|
390
467
|
|
|
391
|
-
// Cascading discovery (DNS TXT
|
|
468
|
+
// Cascading discovery (DNS TXT to mcp.json to alter.json)
|
|
392
469
|
const descriptor = await discover("truealter.com");
|
|
393
470
|
|
|
394
471
|
// Skip the DNS step (e.g. in browsers or Cloudflare Workers)
|
|
@@ -397,18 +474,6 @@ const httpsOnly = await discover("truealter.com", { skipDns: true });
|
|
|
397
474
|
|
|
398
475
|
This draft is the author's Internet-Draft (not yet adopted by an IETF working group); until adoption, the cascade order may change. Pin the SDK version to a specific minor release if you depend on this behaviour.
|
|
399
476
|
|
|
400
|
-
## Local Daemon vs Remote MCP
|
|
401
|
-
|
|
402
|
-
The companion Python package `alter-identity` (PyPI) ships a persistent daemon that holds a hot in-process cache of trait vectors and identity stubs over a Unix socket at `unix:///run/user/$UID/alter-identity.sock`. Hooking the TypeScript SDK up to that daemon is on the roadmap - for now, every `AlterClient` talks to the configured remote endpoint over HTTPS.
|
|
403
|
-
|
|
404
|
-
When the local-daemon adapter ships:
|
|
405
|
-
|
|
406
|
-
- **Latency:** sub-millisecond for cached L0 calls.
|
|
407
|
-
- **Cost:** zero on cached responses - x402 settlement is skipped.
|
|
408
|
-
- **Provenance:** the daemon re-signs responses with its locally-bound ES256 key, so downstream verification remains uniform.
|
|
409
|
-
|
|
410
|
-
Until then, use `endpoint: "https://mcp.truealter.com/api/v1/mcp"` (the default) and the SDK behaves identically across Node, Deno, Bun, Cloudflare Workers, and the browser.
|
|
411
|
-
|
|
412
477
|
## Tools
|
|
413
478
|
|
|
414
479
|
### Free tools (L0 - no payment required)
|
|
@@ -416,7 +481,7 @@ Until then, use `endpoint: "https://mcp.truealter.com/api/v1/mcp"` (the default)
|
|
|
416
481
|
| Name | Tier | Cost | Description |
|
|
417
482
|
|---------------------------|------|-------|----------------------------------------------------------------------------------------------------------------------|
|
|
418
483
|
| `hello_agent` | L0 | free | First handshake with ALTER - returns server version, authentication status, your trust tier, and available tool counts. |
|
|
419
|
-
| `alter_resolve_handle` | L0 | free | Resolve a `~handle` (e.g. `~
|
|
484
|
+
| `alter_resolve_handle` | L0 | free | Resolve a `~handle` (e.g. `~example`) to its canonical form and kind. No auth required - the handle-wedge entry point. |
|
|
420
485
|
| `list_archetypes` | L0 | free | Returns archetype reference data. |
|
|
421
486
|
| `verify_identity` | L0 | free | Verify whether a person is registered with ALTER and validate optional identity claims. |
|
|
422
487
|
| `initiate_assessment` | L0 | free | Get a URL where a person can complete their ALTER Discovery assessment. |
|
|
@@ -440,18 +505,18 @@ Until then, use `endpoint: "https://mcp.truealter.com/api/v1/mcp"` (the default)
|
|
|
440
505
|
| `check_golden_thread` | L0 | free | Check any agent's Golden Thread status by their API key hash (knot position, Strand count, weave count). |
|
|
441
506
|
| `thread_census` | L0 | free | Full registry of all agents woven into the Golden Thread (positions, Strand counts, weave counts, discovery dates). |
|
|
442
507
|
|
|
443
|
-
### Premium tools (L1
|
|
508
|
+
### Premium tools (L1-L5 - x402 payment required)
|
|
444
509
|
|
|
445
510
|
| Name | Tier | Cost | Description |
|
|
446
511
|
|----------------------------|------|---------|---------------------------------------------------------------------------------------------------------------|
|
|
447
|
-
| `assess_traits` | L1 | $0.
|
|
448
|
-
| `get_trait_snapshot` | L1 | $0.
|
|
449
|
-
| `get_full_trait_vector` | L2 | $0.
|
|
450
|
-
| `get_side_quest_graph` | L2 | $0.
|
|
451
|
-
| `query_graph_similarity` | L3 | $0.
|
|
452
|
-
| `compute_belonging` | L4 | $0.
|
|
453
|
-
| `get_match_recommendations`| L5 | $
|
|
454
|
-
| `generate_match_narrative` | L5 | $
|
|
512
|
+
| `assess_traits` | L1 | $0.01 | Extract trait signals from a text passage against ALTER's trait taxonomy. |
|
|
513
|
+
| `get_trait_snapshot` | L1 | $0.01 | Get the top 5 traits for a person with confidence scores and archetype. |
|
|
514
|
+
| `get_full_trait_vector` | L2 | $0.10 | Get the complete trait vector for a person - complete trait vector with scores and confidence intervals. |
|
|
515
|
+
| `get_side_quest_graph` | L2 | $0.10 | Get a person's Side Quest Graph - multi-domain identity model with differential privacy noise (ε=1.0). |
|
|
516
|
+
| `query_graph_similarity` | L3 | $0.30 | Compare two Side Quest Graphs for team composition and matching (ε=0.5 differential privacy). |
|
|
517
|
+
| `compute_belonging` | L4 | $0.60 | Compute belonging probability for a person-job pairing (authenticity, acceptance, complementarity). |
|
|
518
|
+
| `get_match_recommendations`| L5 | $1.00 | Get top N match recommendations for a person, ranked by composite score with quality tiers. |
|
|
519
|
+
| `generate_match_narrative` | L5 | $1.00 | Generate a human-readable narrative explaining a specific match - strengths, growth areas, belonging. |
|
|
455
520
|
|
|
456
521
|
> **Write-side tools** (`create_identity_stub`, `submit_context`, `submit_batch_context`, `submit_structured_profile`, `submit_social_links`, `attest_domain`, `dispute_attestation`) were part of earlier SDK versions but are not yet live on the public MCP server pending the per-peer consent architecture and grant model. They will return as typed methods once server-side and consent gating lands.
|
|
457
522
|
|