@tacitprotocol/sdk 0.1.1 → 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/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(): Promise<void>;
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(): Promise<void>;
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 Factory ───────────────────────────────────────────
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 Factory ───────────────────────────────────────────
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.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 Factory ───────────────────────────────────────────
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
  /**
@@ -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 }