@tacitprotocol/sdk 0.1.0 → 0.1.2
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 +158 -0
- package/dist/index.d.mts +20 -1
- package/dist/index.d.ts +20 -1
- package/dist/index.js +54 -3
- package/dist/index.mjs +54 -3
- package/package.json +1 -1
- package/src/core/agent.ts +65 -2
- package/src/types/index.ts +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# @tacitprotocol/sdk
|
|
2
|
+
|
|
3
|
+
The TypeScript SDK for the **Tacit Protocol** — verify identity, prevent fraud, and broker trusted introductions with cryptographic proof.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@tacitprotocol/sdk)
|
|
6
|
+
[](https://github.com/tacitprotocol/tacit/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @tacitprotocol/sdk
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import { TacitAgent } from '@tacitprotocol/sdk';
|
|
18
|
+
|
|
19
|
+
// Create an agent with a fresh DID identity
|
|
20
|
+
const agent = await TacitAgent.create({
|
|
21
|
+
domain: 'professional',
|
|
22
|
+
preferences: {
|
|
23
|
+
languages: ['en'],
|
|
24
|
+
introductionStyle: 'professional',
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Publish an intent to the network
|
|
29
|
+
await agent.publishIntent({
|
|
30
|
+
type: 'introduction',
|
|
31
|
+
domain: 'professional',
|
|
32
|
+
seeking: {
|
|
33
|
+
role: 'co-founder',
|
|
34
|
+
skills: ['backend', 'systems-architecture'],
|
|
35
|
+
industry: 'fintech',
|
|
36
|
+
},
|
|
37
|
+
context: {
|
|
38
|
+
offering: 'product leadership, 10 years in payments',
|
|
39
|
+
stage: 'pre-seed',
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Listen for verified matches
|
|
44
|
+
agent.on('match', async (event) => {
|
|
45
|
+
const { match } = event;
|
|
46
|
+
console.log(`Match: ${match.score.overall}/100`);
|
|
47
|
+
console.log(`Authenticity: ${match.score.breakdown.authenticityCompatibility}`);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Connect to the relay network
|
|
51
|
+
await agent.connect();
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Core Modules
|
|
55
|
+
|
|
56
|
+
### Identity (`createIdentity`, `sign`, `verify`)
|
|
57
|
+
|
|
58
|
+
W3C DID-based identity using Ed25519 keypairs. Every agent gets a `did:key` identifier that is cryptographically verifiable.
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { createIdentity, sign, verify } from '@tacitprotocol/sdk';
|
|
62
|
+
|
|
63
|
+
const identity = await createIdentity();
|
|
64
|
+
console.log(identity.did); // did:key:z6Mk...
|
|
65
|
+
|
|
66
|
+
const data = new TextEncoder().encode('hello');
|
|
67
|
+
const signature = await sign(data, identity.privateKey);
|
|
68
|
+
const valid = await verify(data, signature, identity.publicKey);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Authenticity (`AuthenticityEngine`)
|
|
72
|
+
|
|
73
|
+
Multi-dimensional trust scores that are earned over time — impossible to fake overnight. Dimensions: tenure, consistency, attestations, network trust.
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { AuthenticityEngine } from '@tacitprotocol/sdk';
|
|
77
|
+
|
|
78
|
+
const engine = new AuthenticityEngine();
|
|
79
|
+
const vector = engine.computeVector({
|
|
80
|
+
created: agent.card.agent.created,
|
|
81
|
+
consistencySignals: { intentFulfillmentRate: 0.9, responseRate: 0.85 },
|
|
82
|
+
credentials: agent.card.credentials,
|
|
83
|
+
networkTrust: { endorsements: 12, uniqueEndorsers: 8, mutualConnections: 3 },
|
|
84
|
+
});
|
|
85
|
+
console.log(vector.score); // 0-100
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Discovery (`IntentBuilder`, `IntentStore`)
|
|
89
|
+
|
|
90
|
+
Publish and discover encrypted intents on the network. The `IntentBuilder` provides a fluent API for constructing intents.
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { IntentBuilder, IntentStore } from '@tacitprotocol/sdk';
|
|
94
|
+
|
|
95
|
+
const intent = new IntentBuilder(agent.did)
|
|
96
|
+
.type('introduction')
|
|
97
|
+
.domain('professional')
|
|
98
|
+
.seeking({ role: 'backend-engineer', skills: ['rust', 'distributed-systems'] })
|
|
99
|
+
.context({ offering: 'equity + salary', stage: 'seed' })
|
|
100
|
+
.minAuthenticity(70)
|
|
101
|
+
.ttl(86400) // 24 hours
|
|
102
|
+
.build();
|
|
103
|
+
|
|
104
|
+
const store = new IntentStore();
|
|
105
|
+
store.add(intent);
|
|
106
|
+
const matches = store.query({ domain: 'professional', keywords: ['rust'] });
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Matching (`MatchScorer`)
|
|
110
|
+
|
|
111
|
+
Score compatibility between two agents across five dimensions: intent alignment, domain fit, authenticity compatibility, preference match, and timing fit.
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import { MatchScorer } from '@tacitprotocol/sdk';
|
|
115
|
+
|
|
116
|
+
const scorer = new MatchScorer({ autoPropose: 80, suggest: 60 });
|
|
117
|
+
const result = scorer.score({
|
|
118
|
+
initiator: { intent: aliceIntent, card: aliceCard },
|
|
119
|
+
responder: { intent: bobIntent, card: bobCard },
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
console.log(result.score.overall); // 0-100
|
|
123
|
+
console.log(scorer.determineAction(result.score.overall)); // 'auto-propose' | 'suggest' | 'ignore'
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## API Reference
|
|
127
|
+
|
|
128
|
+
### Exports
|
|
129
|
+
|
|
130
|
+
| Export | Type | Description |
|
|
131
|
+
|--------|------|-------------|
|
|
132
|
+
| `TacitAgent` | Class | Main agent interface — identity, intents, matching, events |
|
|
133
|
+
| `createIdentity` | Function | Generate a new Ed25519 DID identity |
|
|
134
|
+
| `publicKeyToDid` | Function | Convert a public key to a `did:key` DID |
|
|
135
|
+
| `resolveDid` | Function | Resolve a DID to its public key |
|
|
136
|
+
| `sign` / `verify` | Functions | Ed25519 signing and verification |
|
|
137
|
+
| `AuthenticityEngine` | Class | Compute multi-dimensional trust scores |
|
|
138
|
+
| `IntentBuilder` | Class | Fluent builder for constructing intents |
|
|
139
|
+
| `IntentStore` | Class | Local intent storage with lifecycle management |
|
|
140
|
+
| `MatchScorer` | Class | Score compatibility between two agents |
|
|
141
|
+
|
|
142
|
+
All types are fully exported — see the [type definitions](https://github.com/tacitprotocol/tacit/blob/main/packages/sdk-ts/src/types/index.ts) for the complete schema.
|
|
143
|
+
|
|
144
|
+
## Requirements
|
|
145
|
+
|
|
146
|
+
- Node.js >= 18.0.0 (Web Crypto API required)
|
|
147
|
+
- TypeScript >= 5.0 (recommended)
|
|
148
|
+
|
|
149
|
+
## Links
|
|
150
|
+
|
|
151
|
+
- [Protocol Spec](https://github.com/tacitprotocol/tacit/blob/main/docs/PROTOCOL_SPEC.md)
|
|
152
|
+
- [Whitepaper](https://github.com/tacitprotocol/tacit/blob/main/docs/WHITEPAPER.md)
|
|
153
|
+
- [GitHub](https://github.com/tacitprotocol/tacit)
|
|
154
|
+
- [Website](https://tacitprotocol.com)
|
|
155
|
+
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
MIT
|
package/dist/index.d.mts
CHANGED
|
@@ -176,6 +176,9 @@ type TacitEvent = {
|
|
|
176
176
|
} | {
|
|
177
177
|
type: 'intent:matched';
|
|
178
178
|
match: MatchResult;
|
|
179
|
+
} | {
|
|
180
|
+
type: 'match';
|
|
181
|
+
match: MatchResult;
|
|
179
182
|
} | {
|
|
180
183
|
type: 'intent:expired';
|
|
181
184
|
intentId: string;
|
|
@@ -253,10 +256,26 @@ declare class TacitAgent {
|
|
|
253
256
|
* Returns an AgentIdentity that can be passed to the constructor.
|
|
254
257
|
*/
|
|
255
258
|
static createIdentity(): Promise<AgentIdentity>;
|
|
259
|
+
/**
|
|
260
|
+
* Convenience factory: creates a new identity and returns a ready-to-use agent.
|
|
261
|
+
*/
|
|
262
|
+
static create(options?: {
|
|
263
|
+
domain?: DomainType;
|
|
264
|
+
preferences?: Record<string, any>;
|
|
265
|
+
seeking?: string;
|
|
266
|
+
offering?: string;
|
|
267
|
+
}): Promise<TacitAgent>;
|
|
268
|
+
/** Get the agent's DID (shorthand). */
|
|
269
|
+
get did(): string;
|
|
270
|
+
/** Get the agent's Agent Card (shorthand). */
|
|
271
|
+
get card(): AgentCard;
|
|
256
272
|
/**
|
|
257
273
|
* Connect the agent to the Tacit network via a relay node.
|
|
274
|
+
* Pass `{ demo: true }` to simulate a match after 3 seconds (no relay needed).
|
|
258
275
|
*/
|
|
259
|
-
connect(
|
|
276
|
+
connect(options?: {
|
|
277
|
+
demo?: boolean;
|
|
278
|
+
}): Promise<void>;
|
|
260
279
|
/**
|
|
261
280
|
* Disconnect the agent from the network.
|
|
262
281
|
* Active intents remain on the network until their TTL expires.
|
package/dist/index.d.ts
CHANGED
|
@@ -176,6 +176,9 @@ type TacitEvent = {
|
|
|
176
176
|
} | {
|
|
177
177
|
type: 'intent:matched';
|
|
178
178
|
match: MatchResult;
|
|
179
|
+
} | {
|
|
180
|
+
type: 'match';
|
|
181
|
+
match: MatchResult;
|
|
179
182
|
} | {
|
|
180
183
|
type: 'intent:expired';
|
|
181
184
|
intentId: string;
|
|
@@ -253,10 +256,26 @@ declare class TacitAgent {
|
|
|
253
256
|
* Returns an AgentIdentity that can be passed to the constructor.
|
|
254
257
|
*/
|
|
255
258
|
static createIdentity(): Promise<AgentIdentity>;
|
|
259
|
+
/**
|
|
260
|
+
* Convenience factory: creates a new identity and returns a ready-to-use agent.
|
|
261
|
+
*/
|
|
262
|
+
static create(options?: {
|
|
263
|
+
domain?: DomainType;
|
|
264
|
+
preferences?: Record<string, any>;
|
|
265
|
+
seeking?: string;
|
|
266
|
+
offering?: string;
|
|
267
|
+
}): Promise<TacitAgent>;
|
|
268
|
+
/** Get the agent's DID (shorthand). */
|
|
269
|
+
get did(): string;
|
|
270
|
+
/** Get the agent's Agent Card (shorthand). */
|
|
271
|
+
get card(): AgentCard;
|
|
256
272
|
/**
|
|
257
273
|
* Connect the agent to the Tacit network via a relay node.
|
|
274
|
+
* Pass `{ demo: true }` to simulate a match after 3 seconds (no relay needed).
|
|
258
275
|
*/
|
|
259
|
-
connect(
|
|
276
|
+
connect(options?: {
|
|
277
|
+
demo?: boolean;
|
|
278
|
+
}): Promise<void>;
|
|
260
279
|
/**
|
|
261
280
|
* Disconnect the agent from the network.
|
|
262
281
|
* Active intents remain on the network until their TTL expires.
|
package/dist/index.js
CHANGED
|
@@ -340,7 +340,7 @@ var EventBus = class {
|
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
342
|
};
|
|
343
|
-
var TacitAgent = class {
|
|
343
|
+
var TacitAgent = class _TacitAgent {
|
|
344
344
|
identity = null;
|
|
345
345
|
config;
|
|
346
346
|
events = new EventBus();
|
|
@@ -367,7 +367,7 @@ var TacitAgent = class {
|
|
|
367
367
|
this.identity = config.identity;
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
|
-
// ─── Static
|
|
370
|
+
// ─── Static Factories ──────────────────────────────────────────
|
|
371
371
|
/**
|
|
372
372
|
* Create a new agent identity.
|
|
373
373
|
* Returns an AgentIdentity that can be passed to the constructor.
|
|
@@ -375,11 +375,37 @@ var TacitAgent = class {
|
|
|
375
375
|
static async createIdentity() {
|
|
376
376
|
return createIdentity();
|
|
377
377
|
}
|
|
378
|
+
/**
|
|
379
|
+
* Convenience factory: creates a new identity and returns a ready-to-use agent.
|
|
380
|
+
*/
|
|
381
|
+
static async create(options = {}) {
|
|
382
|
+
const identity = await _TacitAgent.createIdentity();
|
|
383
|
+
return new _TacitAgent({
|
|
384
|
+
identity,
|
|
385
|
+
profile: {
|
|
386
|
+
name: "Tacit Agent",
|
|
387
|
+
domain: options.domain || "professional",
|
|
388
|
+
seeking: options.seeking || "",
|
|
389
|
+
offering: options.offering || ""
|
|
390
|
+
},
|
|
391
|
+
preferences: options.preferences
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
// ─── Convenience Getters ─────────────────────────────────────
|
|
395
|
+
/** Get the agent's DID (shorthand). */
|
|
396
|
+
get did() {
|
|
397
|
+
return this.getDid();
|
|
398
|
+
}
|
|
399
|
+
/** Get the agent's Agent Card (shorthand). */
|
|
400
|
+
get card() {
|
|
401
|
+
return this.getAgentCard();
|
|
402
|
+
}
|
|
378
403
|
// ─── Lifecycle ────────────────────────────────────────────────
|
|
379
404
|
/**
|
|
380
405
|
* Connect the agent to the Tacit network via a relay node.
|
|
406
|
+
* Pass `{ demo: true }` to simulate a match after 3 seconds (no relay needed).
|
|
381
407
|
*/
|
|
382
|
-
async connect() {
|
|
408
|
+
async connect(options) {
|
|
383
409
|
if (!this.identity) {
|
|
384
410
|
this.identity = await createIdentity();
|
|
385
411
|
}
|
|
@@ -388,6 +414,31 @@ var TacitAgent = class {
|
|
|
388
414
|
type: "connection:established",
|
|
389
415
|
endpoint: this.config.relayUrl
|
|
390
416
|
});
|
|
417
|
+
if (options?.demo) {
|
|
418
|
+
setTimeout(async () => {
|
|
419
|
+
const simulatedMatch = {
|
|
420
|
+
matchId: `match:demo:${Date.now()}`,
|
|
421
|
+
agents: {
|
|
422
|
+
initiator: this.identity.did,
|
|
423
|
+
responder: "did:key:z6MkdemoAgent00000000000000000000000000000000"
|
|
424
|
+
},
|
|
425
|
+
score: {
|
|
426
|
+
overall: 87,
|
|
427
|
+
breakdown: {
|
|
428
|
+
intentAlignment: 0.92,
|
|
429
|
+
domainFit: 0.88,
|
|
430
|
+
authenticityCompatibility: 0.85,
|
|
431
|
+
preferenceMatch: 0.82,
|
|
432
|
+
timingFit: 0.9
|
|
433
|
+
}
|
|
434
|
+
},
|
|
435
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
436
|
+
};
|
|
437
|
+
await this.events.emit({ type: "match", match: simulatedMatch });
|
|
438
|
+
}, 3e3);
|
|
439
|
+
await new Promise(() => {
|
|
440
|
+
});
|
|
441
|
+
}
|
|
391
442
|
}
|
|
392
443
|
/**
|
|
393
444
|
* Disconnect the agent from the network.
|
package/dist/index.mjs
CHANGED
|
@@ -305,7 +305,7 @@ var EventBus = class {
|
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
307
|
};
|
|
308
|
-
var TacitAgent = class {
|
|
308
|
+
var TacitAgent = class _TacitAgent {
|
|
309
309
|
identity = null;
|
|
310
310
|
config;
|
|
311
311
|
events = new EventBus();
|
|
@@ -332,7 +332,7 @@ var TacitAgent = class {
|
|
|
332
332
|
this.identity = config.identity;
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
|
-
// ─── Static
|
|
335
|
+
// ─── Static Factories ──────────────────────────────────────────
|
|
336
336
|
/**
|
|
337
337
|
* Create a new agent identity.
|
|
338
338
|
* Returns an AgentIdentity that can be passed to the constructor.
|
|
@@ -340,11 +340,37 @@ var TacitAgent = class {
|
|
|
340
340
|
static async createIdentity() {
|
|
341
341
|
return createIdentity();
|
|
342
342
|
}
|
|
343
|
+
/**
|
|
344
|
+
* Convenience factory: creates a new identity and returns a ready-to-use agent.
|
|
345
|
+
*/
|
|
346
|
+
static async create(options = {}) {
|
|
347
|
+
const identity = await _TacitAgent.createIdentity();
|
|
348
|
+
return new _TacitAgent({
|
|
349
|
+
identity,
|
|
350
|
+
profile: {
|
|
351
|
+
name: "Tacit Agent",
|
|
352
|
+
domain: options.domain || "professional",
|
|
353
|
+
seeking: options.seeking || "",
|
|
354
|
+
offering: options.offering || ""
|
|
355
|
+
},
|
|
356
|
+
preferences: options.preferences
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
// ─── Convenience Getters ─────────────────────────────────────
|
|
360
|
+
/** Get the agent's DID (shorthand). */
|
|
361
|
+
get did() {
|
|
362
|
+
return this.getDid();
|
|
363
|
+
}
|
|
364
|
+
/** Get the agent's Agent Card (shorthand). */
|
|
365
|
+
get card() {
|
|
366
|
+
return this.getAgentCard();
|
|
367
|
+
}
|
|
343
368
|
// ─── Lifecycle ────────────────────────────────────────────────
|
|
344
369
|
/**
|
|
345
370
|
* Connect the agent to the Tacit network via a relay node.
|
|
371
|
+
* Pass `{ demo: true }` to simulate a match after 3 seconds (no relay needed).
|
|
346
372
|
*/
|
|
347
|
-
async connect() {
|
|
373
|
+
async connect(options) {
|
|
348
374
|
if (!this.identity) {
|
|
349
375
|
this.identity = await createIdentity();
|
|
350
376
|
}
|
|
@@ -353,6 +379,31 @@ var TacitAgent = class {
|
|
|
353
379
|
type: "connection:established",
|
|
354
380
|
endpoint: this.config.relayUrl
|
|
355
381
|
});
|
|
382
|
+
if (options?.demo) {
|
|
383
|
+
setTimeout(async () => {
|
|
384
|
+
const simulatedMatch = {
|
|
385
|
+
matchId: `match:demo:${Date.now()}`,
|
|
386
|
+
agents: {
|
|
387
|
+
initiator: this.identity.did,
|
|
388
|
+
responder: "did:key:z6MkdemoAgent00000000000000000000000000000000"
|
|
389
|
+
},
|
|
390
|
+
score: {
|
|
391
|
+
overall: 87,
|
|
392
|
+
breakdown: {
|
|
393
|
+
intentAlignment: 0.92,
|
|
394
|
+
domainFit: 0.88,
|
|
395
|
+
authenticityCompatibility: 0.85,
|
|
396
|
+
preferenceMatch: 0.82,
|
|
397
|
+
timingFit: 0.9
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
401
|
+
};
|
|
402
|
+
await this.events.emit({ type: "match", match: simulatedMatch });
|
|
403
|
+
}, 3e3);
|
|
404
|
+
await new Promise(() => {
|
|
405
|
+
});
|
|
406
|
+
}
|
|
356
407
|
}
|
|
357
408
|
/**
|
|
358
409
|
* Disconnect the agent from the network.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tacitprotocol/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "The Tacit Protocol SDK — verify identity, prevent fraud, and broker trusted introductions with cryptographic proof",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
package/src/core/agent.ts
CHANGED
|
@@ -91,7 +91,7 @@ export class TacitAgent {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
// ─── Static
|
|
94
|
+
// ─── Static Factories ──────────────────────────────────────────
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
97
|
* Create a new agent identity.
|
|
@@ -101,12 +101,47 @@ export class TacitAgent {
|
|
|
101
101
|
return createIdentity();
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Convenience factory: creates a new identity and returns a ready-to-use agent.
|
|
106
|
+
*/
|
|
107
|
+
static async create(options: {
|
|
108
|
+
domain?: DomainType;
|
|
109
|
+
preferences?: Record<string, any>;
|
|
110
|
+
seeking?: string;
|
|
111
|
+
offering?: string;
|
|
112
|
+
} = {}): Promise<TacitAgent> {
|
|
113
|
+
const identity = await TacitAgent.createIdentity();
|
|
114
|
+
return new TacitAgent({
|
|
115
|
+
identity,
|
|
116
|
+
profile: {
|
|
117
|
+
name: 'Tacit Agent',
|
|
118
|
+
domain: options.domain || 'professional',
|
|
119
|
+
seeking: options.seeking || '',
|
|
120
|
+
offering: options.offering || '',
|
|
121
|
+
},
|
|
122
|
+
preferences: options.preferences as any,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// ─── Convenience Getters ─────────────────────────────────────
|
|
127
|
+
|
|
128
|
+
/** Get the agent's DID (shorthand). */
|
|
129
|
+
get did(): string {
|
|
130
|
+
return this.getDid();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Get the agent's Agent Card (shorthand). */
|
|
134
|
+
get card(): AgentCard {
|
|
135
|
+
return this.getAgentCard();
|
|
136
|
+
}
|
|
137
|
+
|
|
104
138
|
// ─── Lifecycle ────────────────────────────────────────────────
|
|
105
139
|
|
|
106
140
|
/**
|
|
107
141
|
* Connect the agent to the Tacit network via a relay node.
|
|
142
|
+
* Pass `{ demo: true }` to simulate a match after 3 seconds (no relay needed).
|
|
108
143
|
*/
|
|
109
|
-
async connect(): Promise<void> {
|
|
144
|
+
async connect(options?: { demo?: boolean }): Promise<void> {
|
|
110
145
|
if (!this.identity) {
|
|
111
146
|
this.identity = await createIdentity();
|
|
112
147
|
}
|
|
@@ -121,6 +156,34 @@ export class TacitAgent {
|
|
|
121
156
|
type: 'connection:established',
|
|
122
157
|
endpoint: this.config.relayUrl!,
|
|
123
158
|
});
|
|
159
|
+
|
|
160
|
+
// Demo mode: simulate a match after 3 seconds
|
|
161
|
+
if (options?.demo) {
|
|
162
|
+
setTimeout(async () => {
|
|
163
|
+
const simulatedMatch: MatchResult = {
|
|
164
|
+
matchId: `match:demo:${Date.now()}`,
|
|
165
|
+
agents: {
|
|
166
|
+
initiator: this.identity!.did,
|
|
167
|
+
responder: 'did:key:z6MkdemoAgent00000000000000000000000000000000' as any,
|
|
168
|
+
},
|
|
169
|
+
score: {
|
|
170
|
+
overall: 87,
|
|
171
|
+
breakdown: {
|
|
172
|
+
intentAlignment: 0.92,
|
|
173
|
+
domainFit: 0.88,
|
|
174
|
+
authenticityCompatibility: 0.85,
|
|
175
|
+
preferenceMatch: 0.82,
|
|
176
|
+
timingFit: 0.90,
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
timestamp: new Date().toISOString(),
|
|
180
|
+
};
|
|
181
|
+
await this.events.emit({ type: 'match', match: simulatedMatch });
|
|
182
|
+
}, 3000);
|
|
183
|
+
|
|
184
|
+
// Keep the process alive
|
|
185
|
+
await new Promise(() => {});
|
|
186
|
+
}
|
|
124
187
|
}
|
|
125
188
|
|
|
126
189
|
/**
|
package/src/types/index.ts
CHANGED
|
@@ -248,6 +248,7 @@ export interface ServiceAttestation {
|
|
|
248
248
|
export type TacitEvent =
|
|
249
249
|
| { type: 'intent:published'; intent: Intent }
|
|
250
250
|
| { type: 'intent:matched'; match: MatchResult }
|
|
251
|
+
| { type: 'match'; match: MatchResult }
|
|
251
252
|
| { type: 'intent:expired'; intentId: string }
|
|
252
253
|
| { type: 'proposal:received'; proposal: IntroProposal }
|
|
253
254
|
| { type: 'proposal:accepted'; proposal: IntroProposal }
|