@truealter/sdk 0.2.4 → 0.5.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/README.md +50 -36
- package/dist/bin/alter-identity.js +841 -31
- package/dist/bin/mcp-bridge.js +201 -9
- package/dist/index.cjs +785 -24
- package/dist/index.d.cts +677 -41
- package/dist/index.d.ts +677 -41
- package/dist/index.js +712 -28
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -5,13 +5,14 @@ ALTER Identity SDK — query the continuous identity field from any JavaScript/T
|
|
|
5
5
|
[](https://www.npmjs.com/package/@truealter/sdk)
|
|
6
6
|
[](./LICENSE)
|
|
7
7
|
[](https://glama.ai/mcp/servers/true-alter/alter-identity)
|
|
8
|
+
[](https://www.deepnlp.org/store/ai-agent/identity/pub-truealter/alter-identity)
|
|
8
9
|
|
|
9
10
|
A thin client over the ALTER MCP server (Streamable HTTP, JSON-RPC 2.0, MCP spec `2025-11-25`) with x402 micropayment support, ES256 provenance verification, and config generators for Claude Code, Cursor, and generic MCP clients.
|
|
10
11
|
|
|
11
12
|
- **Branded host:** `https://mcp.truealter.com` (serves `.well-known/mcp.json` for discovery)
|
|
12
13
|
- **JSON-RPC wire endpoint:** `https://mcp.truealter.com/api/v1/mcp` — this is what Streamable HTTP POSTs target (the SDK default)
|
|
13
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)
|
|
14
|
-
- **Tools:** **
|
|
15
|
+
- **Tools:** **40 typed and wired** — 24 free (L0) + 9 premium (L1–L5) + 7 alter-to-alter messaging. Mirrors the live server's `tools/list` response byte-for-byte; every name in `FREE_TOOL_NAMES` / `PREMIUM_TOOL_NAMES` / `MESSAGING_TOOL_NAMES` has a matching server handler at `mcp.truealter.com/api/v1/mcp`.
|
|
15
16
|
- **Runtime:** Node 18+, Deno, Bun, Cloudflare Workers, modern browsers
|
|
16
17
|
- **Crypto:** `@noble/ed25519` + `@noble/hashes` (no other dependencies)
|
|
17
18
|
- **Bundle:** ESM + CJS dual output
|
|
@@ -24,6 +25,38 @@ npx alter-identity init
|
|
|
24
25
|
npx alter-identity verify ~truealter
|
|
25
26
|
```
|
|
26
27
|
|
|
28
|
+
## Bridge vs SDK
|
|
29
|
+
|
|
30
|
+
The `alter-mcp-bridge` binary shipped in this package (`bin/mcp-bridge.ts`)
|
|
31
|
+
is a **dev/demo surface** for dropping ALTER into MCP hosts that speak the
|
|
32
|
+
stdio transport (Claude Code, Cursor, Continue, Windsurf). It is useful for
|
|
33
|
+
handshake, `tools/list`, and L0 tool calls, but it does not carry Q5c
|
|
34
|
+
per-invocation signing — authenticated MCP tools will fail at the server
|
|
35
|
+
edge when reached through the bridge. For production use, import
|
|
36
|
+
`@truealter/sdk` directly and construct an `MCPClient` / `AlterClient` with
|
|
37
|
+
the optional `signing` parameter; that path is the load-bearing one and
|
|
38
|
+
carries the provenance envelope end-to-end. Bridge signing lands in Wave-2
|
|
39
|
+
alongside the CLI wallet/consent verbs.
|
|
40
|
+
|
|
41
|
+
## CLI
|
|
42
|
+
|
|
43
|
+
The package ships two binaries. `alter-identity` is the full SDK-feature
|
|
44
|
+
binary (`init`, `verify`, `whoami`, wire/unwire, signing, etc). `alter`
|
|
45
|
+
is a slim, task-oriented binary for day-to-day use:
|
|
46
|
+
|
|
47
|
+
| Command | Purpose |
|
|
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
|
+
<!-- TODO(D4): "claim" is a Recognition Over Qualification violation — rename to "redeem" or "accept-invite" in alter-cli + update here -->
|
|
52
|
+
| `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`. |
|
|
53
|
+
| `alter mirror` | Day-2 Mirror phase + streak. `alter mirror daily` claims today's Mirror; `alter mirror next` shows the next revelation window. |
|
|
54
|
+
| `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. |
|
|
55
|
+
|
|
56
|
+
The session file is created with `0600` permissions; its parent dir
|
|
57
|
+
(`~/.config/alter/`) is created with `0700`. Override the config root
|
|
58
|
+
via `XDG_CONFIG_HOME`. Run `alter --help` for the inline reference.
|
|
59
|
+
|
|
27
60
|
## Why ALTER ≠ IAM
|
|
28
61
|
|
|
29
62
|
Identity Access Management answers *who is logged in*. ALTER answers *who they actually are* — a continuous field of recognition that any IAM stack can sit on top of.
|
|
@@ -64,7 +97,7 @@ const archetypes = await alter.listArchetypes();
|
|
|
64
97
|
|
|
65
98
|
// Identity depth and available tool tiers
|
|
66
99
|
const depth = await alter.getEngagementLevel({
|
|
67
|
-
|
|
100
|
+
member_id: "550e8400-e29b-41d4-a716-446655440000",
|
|
68
101
|
});
|
|
69
102
|
|
|
70
103
|
// Search by trait criteria — no PII exposed, max 5 results
|
|
@@ -90,18 +123,18 @@ const signals = await alter.assessTraits({
|
|
|
90
123
|
|
|
91
124
|
// L2 — Full 33-trait vector ($0.01)
|
|
92
125
|
const vector = await alter.getFullTraitVector({
|
|
93
|
-
|
|
126
|
+
member_id: "550e8400-e29b-41d4-a716-446655440000",
|
|
94
127
|
});
|
|
95
128
|
|
|
96
129
|
// L4 — Belonging probability for a person-job pairing ($0.05)
|
|
97
130
|
const belonging = await alter.computeBelonging({
|
|
98
|
-
|
|
131
|
+
member_id: "550e8400-e29b-41d4-a716-446655440000",
|
|
99
132
|
job_id: "f47ac10b-58cc-4372-a567-0e02b2c3d479",
|
|
100
133
|
});
|
|
101
134
|
|
|
102
135
|
// L5 — Top match recommendations ($0.50)
|
|
103
136
|
const recommendations = await alter.getMatchRecommendations({
|
|
104
|
-
|
|
137
|
+
member_id: "550e8400-e29b-41d4-a716-446655440000",
|
|
105
138
|
limit: 5,
|
|
106
139
|
});
|
|
107
140
|
|
|
@@ -117,7 +150,7 @@ const narrative = await alter.generateMatchNarrative({
|
|
|
117
150
|
// Every medium- and high-blast-radius response is signed with ES256.
|
|
118
151
|
// Verification is opt-in — call alter.verifyProvenance(...) yourself.
|
|
119
152
|
const result = await alter.getFullTraitVector({
|
|
120
|
-
|
|
153
|
+
member_id: "550e8400-e29b-41d4-a716-446655440000",
|
|
121
154
|
});
|
|
122
155
|
|
|
123
156
|
const check = await alter.verifyProvenance(result._meta?.provenance);
|
|
@@ -151,7 +184,7 @@ const mcp = new MCPClient({ endpoint: "https://mcp.truealter.com/api/v1/mcp" });
|
|
|
151
184
|
await mcp.initialize();
|
|
152
185
|
const tools = await mcp.listTools();
|
|
153
186
|
const response = await mcp.callTool("verify_identity", {
|
|
154
|
-
|
|
187
|
+
member_id: "550e8400-e29b-41d4-a716-446655440000",
|
|
155
188
|
});
|
|
156
189
|
```
|
|
157
190
|
|
|
@@ -237,34 +270,17 @@ ALTER monetises premium tools via the [x402](https://x402.org) standard — HTTP
|
|
|
237
270
|
2. Server replies `402 Payment Required` with a payment requirement (amount, recipient, asset, network).
|
|
238
271
|
3. Client signs and broadcasts a USDC transfer on Base L2, attaches the proof, retries.
|
|
239
272
|
4. Server validates the proof, executes the tool, signs the response with ES256, returns it.
|
|
240
|
-
5.
|
|
273
|
+
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.
|
|
241
274
|
|
|
242
275
|
The SDK handles steps 2–4 automatically when an `X402Client` with a configured `signer` is passed in.
|
|
243
276
|
|
|
244
277
|
### Tier structure
|
|
245
278
|
|
|
246
|
-
|
|
247
|
-
|------|----------|-----------------------------------------------------|
|
|
248
|
-
| L1 | $0.005 | `assess_traits`, `get_trait_snapshot` |
|
|
249
|
-
| L2 | $0.01 | `get_full_trait_vector`, `get_side_quest_graph` |
|
|
250
|
-
| L3 | $0.025 | `query_graph_similarity` |
|
|
251
|
-
| L4 | $0.05 | `compute_belonging` |
|
|
252
|
-
| L5 | $0.50 | `get_match_recommendations`, `generate_match_narrative` |
|
|
253
|
-
|
|
254
|
-
The first **100 calls per bot are free** before x402 settlement engages — enough to evaluate the network without spending a cent.
|
|
279
|
+
x402 micropayments at L0–L5 trust tiers. Per-call pricing visible after `alter login`.
|
|
255
280
|
|
|
256
281
|
### Identity income split
|
|
257
282
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
| Recipient | Share |
|
|
261
|
-
|----------------------|-------|
|
|
262
|
-
| Data subject | 75% |
|
|
263
|
-
| Facilitator agent | 5% |
|
|
264
|
-
| ALTER (protocol) | 15% |
|
|
265
|
-
| Cooperative treasury | 5% |
|
|
266
|
-
|
|
267
|
-
The 75% to the data subject is the foundation of *Identity Income* — humans earn from queries against their own identity field, automatically, without intermediation.
|
|
283
|
+
The majority of every settled call flows to the data subject as Identity Income. Split details available post-authentication via `alter status`.
|
|
268
284
|
|
|
269
285
|
### Code example
|
|
270
286
|
|
|
@@ -301,7 +317,7 @@ const alter = new AlterClient({
|
|
|
301
317
|
|
|
302
318
|
// Auto-retries with payment when the server returns 402
|
|
303
319
|
const vector = await alter.getFullTraitVector({
|
|
304
|
-
|
|
320
|
+
member_id: "550e8400-e29b-41d4-a716-446655440000",
|
|
305
321
|
});
|
|
306
322
|
```
|
|
307
323
|
|
|
@@ -313,7 +329,7 @@ Every response from a medium- or high-blast-radius tool ships with an ES256 JWS
|
|
|
313
329
|
|
|
314
330
|
```ts
|
|
315
331
|
const result = await alter.getFullTraitVector({
|
|
316
|
-
|
|
332
|
+
member_id: "550e8400-e29b-41d4-a716-446655440000",
|
|
317
333
|
});
|
|
318
334
|
|
|
319
335
|
const check = await alter.verifyProvenance(result._meta?.provenance);
|
|
@@ -363,7 +379,7 @@ const descriptor = await discover("truealter.com");
|
|
|
363
379
|
const httpsOnly = await discover("truealter.com", { skipDns: true });
|
|
364
380
|
```
|
|
365
381
|
|
|
366
|
-
|
|
382
|
+
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.
|
|
367
383
|
|
|
368
384
|
## Local Daemon vs Remote MCP
|
|
369
385
|
|
|
@@ -385,12 +401,12 @@ Until then, use `endpoint: "https://mcp.truealter.com/api/v1/mcp"` (the default)
|
|
|
385
401
|
|---------------------------|------|-------|----------------------------------------------------------------------------------------------------------------------|
|
|
386
402
|
| `hello_agent` | L0 | free | First handshake with ALTER — returns server version, authentication status, your trust tier, and available tool counts. |
|
|
387
403
|
| `alter_resolve_handle` | L0 | free | Resolve a `~handle` (e.g. `~drew`) to its canonical form and kind. No auth required — the handle-wedge entry point. |
|
|
388
|
-
| `list_archetypes` | L0 | free |
|
|
404
|
+
| `list_archetypes` | L0 | free | Returns archetype reference data. |
|
|
389
405
|
| `verify_identity` | L0 | free | Verify whether a person is registered with ALTER and validate optional identity claims. |
|
|
390
406
|
| `initiate_assessment` | L0 | free | Get a URL where a person can complete their ALTER Discovery assessment. |
|
|
391
407
|
| `get_engagement_level` | L0 | free | Get a person's identity depth — engagement level, data quality tier, and available query tiers. |
|
|
392
408
|
| `get_profile` | L0 | free | Get a person's profile summary including assessment phase, archetype, engagement level, and key attributes. |
|
|
393
|
-
| `query_matches` | L0 | free | Query matches for a person. Returns a list of
|
|
409
|
+
| `query_matches` | L0 | free | Query matches for a person. Returns a list of matches with quality tiers (never numeric scores). |
|
|
394
410
|
| `get_competencies` | L0 | free | Get a person's competency portfolio including verified competencies, evidence records, and earned badges. |
|
|
395
411
|
| `search_identities` | L0 | free | Search identity stubs and profiles by trait criteria. Returns up to 5 matches with no PII. |
|
|
396
412
|
| `get_identity_earnings` | L0 | free | Get accrued Identity Income earnings for a person (75% of every x402 transaction goes to the data subject). |
|
|
@@ -412,9 +428,9 @@ Until then, use `endpoint: "https://mcp.truealter.com/api/v1/mcp"` (the default)
|
|
|
412
428
|
|
|
413
429
|
| Name | Tier | Cost | Description |
|
|
414
430
|
|----------------------------|------|---------|---------------------------------------------------------------------------------------------------------------|
|
|
415
|
-
| `assess_traits` | L1 | $0.005 | Extract trait signals from a text passage against ALTER's
|
|
431
|
+
| `assess_traits` | L1 | $0.005 | Extract trait signals from a text passage against ALTER's trait taxonomy. |
|
|
416
432
|
| `get_trait_snapshot` | L1 | $0.005 | Get the top 5 traits for a person with confidence scores and archetype. |
|
|
417
|
-
| `get_full_trait_vector` | L2 | $0.01 | Get the complete trait vector for a person —
|
|
433
|
+
| `get_full_trait_vector` | L2 | $0.01 | Get the complete trait vector for a person — complete trait vector with scores and confidence intervals. |
|
|
418
434
|
| `get_side_quest_graph` | L2 | $0.01 | Get a person's Side Quest Graph — multi-domain identity model with differential privacy noise (ε=1.0). |
|
|
419
435
|
| `query_graph_similarity` | L3 | $0.025 | Compare two Side Quest Graphs for team composition and matching (ε=0.5 differential privacy). |
|
|
420
436
|
| `compute_belonging` | L4 | $0.05 | Compute belonging probability for a person-job pairing (authenticity, acceptance, complementarity). |
|
|
@@ -428,5 +444,3 @@ Until then, use `endpoint: "https://mcp.truealter.com/api/v1/mcp"` (the default)
|
|
|
428
444
|
Apache License 2.0. See [LICENSE](./LICENSE) for the full text.
|
|
429
445
|
|
|
430
446
|
Copyright 2026 Alter Meridian Pty Ltd (ABN 54 696 662 049).
|
|
431
|
-
|
|
432
|
-
ALTER, the Trill (`~`), and the Golden Thread are trademarks of Alter Meridian Pty Ltd.
|