@pingagent/sdk 0.1.7 → 0.1.9
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/bin/pingagent.js +24 -3
- package/dist/chunk-3OEFISNL.js +2433 -0
- package/dist/chunk-5Z6HZWDA.js +2603 -0
- package/dist/chunk-BSDY6AKB.js +2918 -0
- package/dist/chunk-PFABO4C7.js +2961 -0
- package/dist/chunk-QK2GMSWC.js +2959 -0
- package/dist/chunk-TCYDOFRQ.js +2085 -0
- package/dist/chunk-V7HHUQT6.js +1962 -0
- package/dist/index.d.ts +403 -5
- package/dist/index.js +41 -3
- package/dist/web-server.js +1151 -16
- package/package.json +11 -3
- package/__tests__/cli.test.ts +0 -225
- package/__tests__/identity.test.ts +0 -47
- package/__tests__/store.test.ts +0 -332
- package/src/a2a-adapter.ts +0 -159
- package/src/auth.ts +0 -50
- package/src/client.ts +0 -582
- package/src/contacts.ts +0 -210
- package/src/history.ts +0 -269
- package/src/identity.ts +0 -86
- package/src/index.ts +0 -25
- package/src/paths.ts +0 -52
- package/src/store.ts +0 -62
- package/src/transport.ts +0 -141
- package/src/web-server.ts +0 -1148
- package/src/ws-subscription.ts +0 -428
- package/tsconfig.json +0 -8
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ declare class LocalStore {
|
|
|
8
8
|
constructor(dbPath?: string);
|
|
9
9
|
getDb(): Database.Database;
|
|
10
10
|
close(): void;
|
|
11
|
+
private applyMigrations;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
interface Contact {
|
|
@@ -98,8 +99,145 @@ declare class HistoryManager {
|
|
|
98
99
|
}): Promise<{
|
|
99
100
|
synced: number;
|
|
100
101
|
}>;
|
|
102
|
+
listMergedRecent(client: PingAgentClient, conversationId: string, opts?: {
|
|
103
|
+
limit?: number;
|
|
104
|
+
box?: 'ready' | 'strangers' | 'all';
|
|
105
|
+
}): Promise<StoredMessage[]>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
type TrustState = 'stranger' | 'pending' | 'trusted' | 'blocked' | 'revoked';
|
|
109
|
+
interface SessionState {
|
|
110
|
+
session_key: string;
|
|
111
|
+
remote_did?: string;
|
|
112
|
+
conversation_id?: string;
|
|
113
|
+
trust_state: TrustState;
|
|
114
|
+
last_message_preview?: string;
|
|
115
|
+
last_remote_activity_at?: number;
|
|
116
|
+
last_read_seq: number;
|
|
117
|
+
unread_count: number;
|
|
118
|
+
active: boolean;
|
|
119
|
+
updated_at: number;
|
|
120
|
+
}
|
|
121
|
+
interface SessionMessageInput {
|
|
122
|
+
session_key?: string;
|
|
123
|
+
remote_did?: string;
|
|
124
|
+
conversation_id: string;
|
|
125
|
+
trust_state?: TrustState;
|
|
126
|
+
sender_did?: string;
|
|
127
|
+
sender_is_self?: boolean;
|
|
128
|
+
schema?: string;
|
|
129
|
+
payload?: unknown;
|
|
130
|
+
seq?: number | null;
|
|
131
|
+
ts_ms?: number;
|
|
132
|
+
}
|
|
133
|
+
interface ReplyTarget {
|
|
134
|
+
session_key: string;
|
|
135
|
+
remote_did?: string;
|
|
136
|
+
conversation_id?: string;
|
|
137
|
+
trust_state: TrustState;
|
|
138
|
+
}
|
|
139
|
+
declare function previewFromPayload(payload: unknown): string;
|
|
140
|
+
declare function buildSessionKey(opts: {
|
|
141
|
+
localDid?: string;
|
|
142
|
+
remoteDid?: string | null;
|
|
143
|
+
conversationId: string;
|
|
144
|
+
conversationType?: string | null;
|
|
145
|
+
}): string;
|
|
146
|
+
declare class SessionManager {
|
|
147
|
+
private store;
|
|
148
|
+
constructor(store: LocalStore);
|
|
149
|
+
upsert(state: Partial<SessionState> & {
|
|
150
|
+
session_key: string;
|
|
151
|
+
}): SessionState;
|
|
152
|
+
upsertFromMessage(input: SessionMessageInput): SessionState;
|
|
153
|
+
get(sessionKey: string): SessionState | null;
|
|
154
|
+
getByConversationId(conversationId: string): SessionState | null;
|
|
155
|
+
getActiveSession(): SessionState | null;
|
|
156
|
+
listRecentSessions(limit?: number): SessionState[];
|
|
157
|
+
focusSession(sessionKey: string): SessionState | null;
|
|
158
|
+
markRead(sessionKey: string, seq?: number | null): SessionState | null;
|
|
159
|
+
nextUnread(): SessionState | null;
|
|
160
|
+
resolveReplyTarget(sessionKey?: string): ReplyTarget | null;
|
|
101
161
|
}
|
|
102
162
|
|
|
163
|
+
type TaskThreadStatus = 'queued' | 'running' | 'processed' | 'failed' | 'cancelled';
|
|
164
|
+
interface TaskThread {
|
|
165
|
+
task_id: string;
|
|
166
|
+
session_key: string;
|
|
167
|
+
conversation_id: string;
|
|
168
|
+
title?: string;
|
|
169
|
+
status: TaskThreadStatus;
|
|
170
|
+
started_at?: number;
|
|
171
|
+
updated_at: number;
|
|
172
|
+
result_summary?: string;
|
|
173
|
+
error_code?: string;
|
|
174
|
+
error_message?: string;
|
|
175
|
+
}
|
|
176
|
+
interface TaskThreadUpsert {
|
|
177
|
+
task_id: string;
|
|
178
|
+
session_key: string;
|
|
179
|
+
conversation_id: string;
|
|
180
|
+
title?: string;
|
|
181
|
+
status: TaskThreadStatus;
|
|
182
|
+
started_at?: number;
|
|
183
|
+
updated_at?: number;
|
|
184
|
+
result_summary?: string;
|
|
185
|
+
error_code?: string;
|
|
186
|
+
error_message?: string;
|
|
187
|
+
}
|
|
188
|
+
declare class TaskThreadManager {
|
|
189
|
+
private store;
|
|
190
|
+
constructor(store: LocalStore);
|
|
191
|
+
upsert(thread: TaskThreadUpsert): TaskThread;
|
|
192
|
+
get(taskId: string): TaskThread | null;
|
|
193
|
+
listBySession(sessionKey: string, limit?: number): TaskThread[];
|
|
194
|
+
listByConversation(conversationId: string, limit?: number): TaskThread[];
|
|
195
|
+
listRecent(limit?: number): TaskThread[];
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
interface EncryptionPublicKeyJwk {
|
|
199
|
+
kty: 'EC';
|
|
200
|
+
crv: 'P-256';
|
|
201
|
+
x: string;
|
|
202
|
+
y: string;
|
|
203
|
+
ext?: boolean;
|
|
204
|
+
key_ops?: string[];
|
|
205
|
+
}
|
|
206
|
+
interface EncryptionPrivateKeyJwk extends EncryptionPublicKeyJwk {
|
|
207
|
+
d: string;
|
|
208
|
+
}
|
|
209
|
+
interface EncryptionIdentityFields {
|
|
210
|
+
encryptionPublicKeyJwk: EncryptionPublicKeyJwk;
|
|
211
|
+
encryptionPrivateKeyJwk: EncryptionPrivateKeyJwk;
|
|
212
|
+
}
|
|
213
|
+
interface AgentEncryptionCard {
|
|
214
|
+
did: string;
|
|
215
|
+
encryption_public_key?: EncryptionPublicKeyJwk | null;
|
|
216
|
+
}
|
|
217
|
+
interface EncryptedRecipientBlob {
|
|
218
|
+
did: string;
|
|
219
|
+
alg: 'ECDH-P256+A256GCM';
|
|
220
|
+
ephemeral_public_key: EncryptionPublicKeyJwk;
|
|
221
|
+
iv: string;
|
|
222
|
+
ciphertext: string;
|
|
223
|
+
}
|
|
224
|
+
interface EncryptedPayloadWrapper {
|
|
225
|
+
__e2ee: {
|
|
226
|
+
v: 1;
|
|
227
|
+
alg: 'ECDH-P256+A256GCM';
|
|
228
|
+
recipients: EncryptedRecipientBlob[];
|
|
229
|
+
cleartext: Record<string, unknown>;
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
declare function isEncryptedPayload(payload: unknown): payload is EncryptedPayloadWrapper;
|
|
233
|
+
declare function shouldEncryptConversationPayload(conversationId: string, schema: string): boolean;
|
|
234
|
+
declare function encryptPayloadForRecipients(opts: {
|
|
235
|
+
schema: string;
|
|
236
|
+
payload: Record<string, unknown>;
|
|
237
|
+
recipients: AgentEncryptionCard[];
|
|
238
|
+
}): Promise<Record<string, unknown>>;
|
|
239
|
+
declare function decryptPayloadForIdentity(schema: string, payload: Record<string, unknown>, identity: Identity & Partial<EncryptionIdentityFields>): Promise<Record<string, unknown>>;
|
|
240
|
+
|
|
103
241
|
interface ClientOptions {
|
|
104
242
|
serverUrl: string;
|
|
105
243
|
identity: Identity;
|
|
@@ -136,6 +274,20 @@ interface TaskResult {
|
|
|
136
274
|
};
|
|
137
275
|
elapsed_ms: number;
|
|
138
276
|
}
|
|
277
|
+
interface TaskStatusResponse {
|
|
278
|
+
task_id: string;
|
|
279
|
+
status: 'queued' | 'running' | 'processed' | 'failed' | 'cancelled';
|
|
280
|
+
reason?: string;
|
|
281
|
+
error?: {
|
|
282
|
+
code?: string;
|
|
283
|
+
message?: string;
|
|
284
|
+
};
|
|
285
|
+
result_summary?: string;
|
|
286
|
+
last_update_ts_ms: number;
|
|
287
|
+
}
|
|
288
|
+
interface TaskListEntry extends TaskStatusResponse {
|
|
289
|
+
title?: string;
|
|
290
|
+
}
|
|
139
291
|
interface SubscriptionUsage {
|
|
140
292
|
relay_today: number;
|
|
141
293
|
relay_limit: number;
|
|
@@ -148,19 +300,27 @@ interface SubscriptionResponse {
|
|
|
148
300
|
tier: string;
|
|
149
301
|
limits: {
|
|
150
302
|
relay_per_day: number;
|
|
303
|
+
relay_msgs_per_day?: number;
|
|
304
|
+
feed_post_per_day?: number;
|
|
305
|
+
channel_limit?: number;
|
|
151
306
|
max_group_size: number;
|
|
152
307
|
artifact_storage_mb: number;
|
|
308
|
+
store_forward_ttl_ms?: number;
|
|
153
309
|
audit_export_allowed: boolean;
|
|
154
310
|
alias_limit: number;
|
|
155
311
|
};
|
|
156
312
|
usage: SubscriptionUsage;
|
|
157
313
|
has_stripe_customer: boolean;
|
|
314
|
+
billing_primary_did?: string | null;
|
|
315
|
+
is_billing_primary?: boolean;
|
|
316
|
+
linked_device_count?: number;
|
|
158
317
|
}
|
|
159
318
|
interface ConversationEntry {
|
|
160
319
|
conversation_id: string;
|
|
161
320
|
type: string;
|
|
162
321
|
target_did: string;
|
|
163
322
|
trusted: boolean;
|
|
323
|
+
recipient_encryption_public_key?: EncryptionPublicKeyJwk | null;
|
|
164
324
|
created_at: number;
|
|
165
325
|
/** Server-side last message write time (ms). Omitted or null when unknown; client should fetch when missing. */
|
|
166
326
|
last_activity_at?: number | null;
|
|
@@ -177,6 +337,7 @@ interface AgentProfile {
|
|
|
177
337
|
tags?: string[];
|
|
178
338
|
verification_status?: string;
|
|
179
339
|
discoverable?: boolean;
|
|
340
|
+
encryption_public_key?: EncryptionPublicKeyJwk | null;
|
|
180
341
|
}
|
|
181
342
|
interface DirectoryBrowseResponse {
|
|
182
343
|
agents: AgentProfile[];
|
|
@@ -198,15 +359,37 @@ interface FeedByDidResponse {
|
|
|
198
359
|
did: string;
|
|
199
360
|
posts: FeedPost[];
|
|
200
361
|
}
|
|
362
|
+
interface AgentDirectoryCard {
|
|
363
|
+
did: string;
|
|
364
|
+
alias?: string | null;
|
|
365
|
+
display_name?: string | null;
|
|
366
|
+
verification_status?: string;
|
|
367
|
+
encryption_public_key?: EncryptionPublicKeyJwk | null;
|
|
368
|
+
}
|
|
369
|
+
interface DirectorySelfResponse {
|
|
370
|
+
did: string;
|
|
371
|
+
alias?: string | null;
|
|
372
|
+
verification_status?: string;
|
|
373
|
+
encryption_public_key?: EncryptionPublicKeyJwk | null;
|
|
374
|
+
mode?: string;
|
|
375
|
+
tier?: string;
|
|
376
|
+
billing_primary_did?: string | null;
|
|
377
|
+
is_billing_primary?: boolean;
|
|
378
|
+
}
|
|
201
379
|
declare class PingAgentClient {
|
|
202
380
|
private opts;
|
|
203
381
|
private transport;
|
|
204
382
|
private identity;
|
|
205
383
|
private contactManager?;
|
|
206
384
|
private historyManager?;
|
|
385
|
+
private sessionManager?;
|
|
386
|
+
private taskThreadManager?;
|
|
387
|
+
private agentCardCache;
|
|
207
388
|
constructor(opts: ClientOptions);
|
|
208
389
|
getContactManager(): ContactManager | undefined;
|
|
209
390
|
getHistoryManager(): HistoryManager | undefined;
|
|
391
|
+
getSessionManager(): SessionManager | undefined;
|
|
392
|
+
getTaskThreadManager(): TaskThreadManager | undefined;
|
|
210
393
|
/** Update the in-memory access token (e.g. after proactive refresh from disk). */
|
|
211
394
|
setAccessToken(token: string): void;
|
|
212
395
|
register(developerToken?: string): Promise<ApiResponse>;
|
|
@@ -214,8 +397,13 @@ declare class PingAgentClient {
|
|
|
214
397
|
conversation_id: string;
|
|
215
398
|
type: string;
|
|
216
399
|
trusted: boolean;
|
|
400
|
+
target_did: string;
|
|
401
|
+
recipient_encryption_public_key?: EncryptionPublicKeyJwk | null;
|
|
217
402
|
relay_ws_url: string;
|
|
218
403
|
}>>;
|
|
404
|
+
private resolveConversationPeer;
|
|
405
|
+
private getRecipientEncryptionCard;
|
|
406
|
+
private sameEncryptionPublicKey;
|
|
219
407
|
sendMessage(conversationId: string, schema: string, payload: Record<string, unknown>): Promise<ApiResponse<SendResponse>>;
|
|
220
408
|
sendTask(conversationId: string, task: {
|
|
221
409
|
task_id: string;
|
|
@@ -257,12 +445,19 @@ declare class PingAgentClient {
|
|
|
257
445
|
resolveAlias(alias: string): Promise<ApiResponse<{
|
|
258
446
|
did: string;
|
|
259
447
|
alias: string;
|
|
448
|
+
encryption_public_key?: EncryptionPublicKeyJwk | null;
|
|
260
449
|
}>>;
|
|
450
|
+
getAgentCard(did: string): Promise<ApiResponse<AgentDirectoryCard>>;
|
|
261
451
|
registerAlias(alias: string): Promise<ApiResponse>;
|
|
262
452
|
listConversations(opts?: {
|
|
263
453
|
type?: string;
|
|
264
454
|
}): Promise<ApiResponse<ConversationListResponse>>;
|
|
455
|
+
getTaskStatus(conversationId: string, taskId: string): Promise<ApiResponse<TaskStatusResponse>>;
|
|
456
|
+
listTaskThreads(conversationId: string): Promise<ApiResponse<{
|
|
457
|
+
tasks: TaskListEntry[];
|
|
458
|
+
}>>;
|
|
265
459
|
getProfile(): Promise<ApiResponse<AgentProfile>>;
|
|
460
|
+
getDirectorySelf(): Promise<ApiResponse<DirectorySelfResponse>>;
|
|
266
461
|
updateProfile(profile: {
|
|
267
462
|
display_name?: string;
|
|
268
463
|
bio?: string;
|
|
@@ -270,6 +465,10 @@ declare class PingAgentClient {
|
|
|
270
465
|
tags?: string[];
|
|
271
466
|
discoverable?: boolean;
|
|
272
467
|
}): Promise<ApiResponse<AgentProfile>>;
|
|
468
|
+
ensureEncryptionKeyPublished(): Promise<ApiResponse<{
|
|
469
|
+
published: boolean;
|
|
470
|
+
status: 'already_registered' | 'updated';
|
|
471
|
+
}>>;
|
|
273
472
|
enableDiscovery(): Promise<ApiResponse<{
|
|
274
473
|
discoverable: boolean;
|
|
275
474
|
}>>;
|
|
@@ -342,6 +541,10 @@ declare class PingAgentClient {
|
|
|
342
541
|
relay_ws_url: string;
|
|
343
542
|
}>>;
|
|
344
543
|
getDid(): string;
|
|
544
|
+
decryptEnvelopePayload(envelope: {
|
|
545
|
+
schema: string;
|
|
546
|
+
payload: Record<string, unknown>;
|
|
547
|
+
}): Promise<Record<string, unknown>>;
|
|
345
548
|
createBillingLinkCode(): Promise<ApiResponse<{
|
|
346
549
|
code: string;
|
|
347
550
|
expires_in_seconds: number;
|
|
@@ -365,15 +568,16 @@ declare class PingAgentClient {
|
|
|
365
568
|
}): Promise<TaskResult>;
|
|
366
569
|
}
|
|
367
570
|
|
|
368
|
-
declare function
|
|
571
|
+
declare function ensureIdentityEncryptionKeys(identity: Partial<EncryptionIdentityFields>): EncryptionIdentityFields;
|
|
572
|
+
declare function generateIdentity(): Identity & EncryptionIdentityFields;
|
|
369
573
|
declare function identityExists(identityPath?: string): boolean;
|
|
370
|
-
declare function loadIdentity(identityPath?: string): Identity & {
|
|
574
|
+
declare function loadIdentity(identityPath?: string): Identity & EncryptionIdentityFields & {
|
|
371
575
|
serverUrl?: string;
|
|
372
576
|
accessToken?: string;
|
|
373
577
|
tokenExpiresAt?: number;
|
|
374
578
|
mode?: string;
|
|
375
579
|
};
|
|
376
|
-
declare function saveIdentity(identity: Identity
|
|
580
|
+
declare function saveIdentity(identity: Identity & Partial<EncryptionIdentityFields>, opts?: {
|
|
377
581
|
serverUrl?: string;
|
|
378
582
|
accessToken?: string;
|
|
379
583
|
tokenExpiresAt?: number;
|
|
@@ -422,6 +626,200 @@ declare class HttpTransport {
|
|
|
422
626
|
private refreshToken;
|
|
423
627
|
}
|
|
424
628
|
|
|
629
|
+
type ContactPolicyAction = 'approve' | 'manual' | 'reject';
|
|
630
|
+
type TaskPolicyAction = 'bridge' | 'execute' | 'deny';
|
|
631
|
+
type RuntimeMode = 'bridge' | 'executor';
|
|
632
|
+
interface TrustPolicyRule<A extends string> {
|
|
633
|
+
match: string;
|
|
634
|
+
action: A;
|
|
635
|
+
}
|
|
636
|
+
interface TrustPolicyDoc {
|
|
637
|
+
version: 1;
|
|
638
|
+
contact_policy: {
|
|
639
|
+
enabled: boolean;
|
|
640
|
+
default_action: ContactPolicyAction;
|
|
641
|
+
rules: Array<TrustPolicyRule<ContactPolicyAction>>;
|
|
642
|
+
};
|
|
643
|
+
task_policy: {
|
|
644
|
+
enabled: boolean;
|
|
645
|
+
default_action: TaskPolicyAction;
|
|
646
|
+
rules: Array<TrustPolicyRule<TaskPolicyAction>>;
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
interface TrustPolicyContext {
|
|
650
|
+
sender_did?: string;
|
|
651
|
+
sender_alias?: string;
|
|
652
|
+
sender_verification_status?: string;
|
|
653
|
+
}
|
|
654
|
+
interface LegacyAutoApproveRule {
|
|
655
|
+
match: string;
|
|
656
|
+
action: 'approve' | 'reject';
|
|
657
|
+
}
|
|
658
|
+
interface ContactPolicyDecision {
|
|
659
|
+
action: ContactPolicyAction;
|
|
660
|
+
source: 'rule' | 'default' | 'legacy_auto_approve' | 'runtime_default';
|
|
661
|
+
matched_rule?: TrustPolicyRule<ContactPolicyAction>;
|
|
662
|
+
explanation: string;
|
|
663
|
+
}
|
|
664
|
+
interface TaskPolicyDecision {
|
|
665
|
+
action: TaskPolicyAction;
|
|
666
|
+
source: 'rule' | 'default' | 'runtime_default';
|
|
667
|
+
matched_rule?: TrustPolicyRule<TaskPolicyAction>;
|
|
668
|
+
explanation: string;
|
|
669
|
+
}
|
|
670
|
+
declare function defaultTrustPolicyDoc(): TrustPolicyDoc;
|
|
671
|
+
declare function normalizeTrustPolicyDoc(raw: any): TrustPolicyDoc;
|
|
672
|
+
declare function matchesTrustPolicyRule(match: string, context: TrustPolicyContext): boolean;
|
|
673
|
+
declare function decideContactPolicy(policyDoc: TrustPolicyDoc, context: TrustPolicyContext, opts?: {
|
|
674
|
+
legacyAutoApproveEnabled?: boolean;
|
|
675
|
+
legacyAutoApproveRules?: LegacyAutoApproveRule[];
|
|
676
|
+
}): ContactPolicyDecision;
|
|
677
|
+
declare function decideTaskPolicy(policyDoc: TrustPolicyDoc, context: TrustPolicyContext, opts?: {
|
|
678
|
+
runtimeMode?: RuntimeMode;
|
|
679
|
+
}): TaskPolicyDecision;
|
|
680
|
+
|
|
681
|
+
type TrustPolicyAuditEventType = 'contact_decision' | 'contact_auto_approved' | 'contact_manual_review' | 'contact_rejected' | 'policy_default_updated' | 'policy_rule_upserted' | 'policy_rule_removed' | 'recommendation_applied' | 'recommendation_dismissed' | 'recommendation_reopened' | 'task_decision' | 'task_bridged' | 'task_executed' | 'task_denied' | 'task_processed' | 'task_failed' | 'task_cancelled' | 'session_blocked' | 'session_revoked';
|
|
682
|
+
interface TrustPolicyAuditEvent {
|
|
683
|
+
id: number;
|
|
684
|
+
ts_ms: number;
|
|
685
|
+
event_type: TrustPolicyAuditEventType;
|
|
686
|
+
policy_scope?: 'contact' | 'task' | 'session';
|
|
687
|
+
remote_did?: string;
|
|
688
|
+
sender_alias?: string;
|
|
689
|
+
sender_verification_status?: string;
|
|
690
|
+
session_key?: string;
|
|
691
|
+
conversation_id?: string;
|
|
692
|
+
action?: string;
|
|
693
|
+
outcome?: string;
|
|
694
|
+
explanation?: string;
|
|
695
|
+
matched_rule?: string;
|
|
696
|
+
detail?: Record<string, unknown>;
|
|
697
|
+
}
|
|
698
|
+
interface TrustPolicyAuditInput {
|
|
699
|
+
ts_ms?: number;
|
|
700
|
+
event_type: TrustPolicyAuditEventType;
|
|
701
|
+
policy_scope?: 'contact' | 'task' | 'session';
|
|
702
|
+
remote_did?: string;
|
|
703
|
+
sender_alias?: string;
|
|
704
|
+
sender_verification_status?: string;
|
|
705
|
+
session_key?: string;
|
|
706
|
+
conversation_id?: string;
|
|
707
|
+
action?: string;
|
|
708
|
+
outcome?: string;
|
|
709
|
+
explanation?: string;
|
|
710
|
+
matched_rule?: string;
|
|
711
|
+
detail?: Record<string, unknown>;
|
|
712
|
+
}
|
|
713
|
+
interface TrustPolicyAuditSummary {
|
|
714
|
+
total_events: number;
|
|
715
|
+
latest_ts_ms?: number;
|
|
716
|
+
by_type: Record<string, number>;
|
|
717
|
+
by_policy_scope: Record<string, number>;
|
|
718
|
+
}
|
|
719
|
+
interface AuditStore {
|
|
720
|
+
getDb(): any;
|
|
721
|
+
}
|
|
722
|
+
interface TrustPolicyLearningSummary {
|
|
723
|
+
remote_did: string;
|
|
724
|
+
last_seen_at?: number;
|
|
725
|
+
trusted_sessions: number;
|
|
726
|
+
pending_sessions: number;
|
|
727
|
+
blocked_sessions: number;
|
|
728
|
+
revoked_sessions: number;
|
|
729
|
+
processed_tasks: number;
|
|
730
|
+
failed_tasks: number;
|
|
731
|
+
cancelled_tasks: number;
|
|
732
|
+
contact_approvals: number;
|
|
733
|
+
contact_manual_reviews: number;
|
|
734
|
+
contact_rejections: number;
|
|
735
|
+
task_bridged: number;
|
|
736
|
+
task_executed: number;
|
|
737
|
+
task_denied: number;
|
|
738
|
+
}
|
|
739
|
+
interface TrustPolicyRecommendation {
|
|
740
|
+
id: string;
|
|
741
|
+
policy: 'contact' | 'task';
|
|
742
|
+
remote_did: string;
|
|
743
|
+
match: string;
|
|
744
|
+
action: ContactPolicyAction | TaskPolicyAction;
|
|
745
|
+
current_action: ContactPolicyAction | TaskPolicyAction;
|
|
746
|
+
confidence: 'medium' | 'high';
|
|
747
|
+
reason: string;
|
|
748
|
+
signals: {
|
|
749
|
+
trusted_sessions: number;
|
|
750
|
+
blocked_sessions: number;
|
|
751
|
+
revoked_sessions: number;
|
|
752
|
+
processed_tasks: number;
|
|
753
|
+
failed_tasks: number;
|
|
754
|
+
cancelled_tasks: number;
|
|
755
|
+
contact_approvals: number;
|
|
756
|
+
contact_rejections: number;
|
|
757
|
+
task_denied: number;
|
|
758
|
+
last_seen_at?: number;
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
declare class TrustPolicyAuditManager {
|
|
762
|
+
private store;
|
|
763
|
+
constructor(store: AuditStore);
|
|
764
|
+
record(event: TrustPolicyAuditInput): TrustPolicyAuditEvent;
|
|
765
|
+
listRecent(limit?: number): TrustPolicyAuditEvent[];
|
|
766
|
+
listBySession(sessionKey: string, limit?: number): TrustPolicyAuditEvent[];
|
|
767
|
+
listByRemoteDid(remoteDid: string, limit?: number): TrustPolicyAuditEvent[];
|
|
768
|
+
summarize(limit?: number): TrustPolicyAuditSummary;
|
|
769
|
+
}
|
|
770
|
+
declare function buildTrustPolicyRecommendations(opts: {
|
|
771
|
+
policyDoc: TrustPolicyDoc;
|
|
772
|
+
sessions: SessionState[];
|
|
773
|
+
tasks: TaskThread[];
|
|
774
|
+
auditEvents: TrustPolicyAuditEvent[];
|
|
775
|
+
runtimeMode: RuntimeMode;
|
|
776
|
+
limit?: number;
|
|
777
|
+
}): TrustPolicyRecommendation[];
|
|
778
|
+
declare function upsertTrustPolicyRecommendation(policyDoc: TrustPolicyDoc, recommendation: TrustPolicyRecommendation): TrustPolicyDoc;
|
|
779
|
+
declare function summarizeTrustPolicyAudit(events: TrustPolicyAuditEvent[]): TrustPolicyAuditSummary;
|
|
780
|
+
|
|
781
|
+
interface RecommendationStore {
|
|
782
|
+
getDb(): any;
|
|
783
|
+
}
|
|
784
|
+
type TrustRecommendationStatus = 'open' | 'applied' | 'dismissed' | 'superseded';
|
|
785
|
+
interface StoredTrustRecommendation extends TrustPolicyRecommendation {
|
|
786
|
+
status: TrustRecommendationStatus;
|
|
787
|
+
first_seen_at: number;
|
|
788
|
+
last_seen_at: number;
|
|
789
|
+
updated_at: number;
|
|
790
|
+
last_state_change_at?: number;
|
|
791
|
+
applied_at?: number;
|
|
792
|
+
dismissed_at?: number;
|
|
793
|
+
}
|
|
794
|
+
interface SyncTrustRecommendationsInput {
|
|
795
|
+
policyDoc: TrustPolicyDoc;
|
|
796
|
+
sessions: SessionState[];
|
|
797
|
+
tasks: TaskThread[];
|
|
798
|
+
auditEvents: TrustPolicyAuditEvent[];
|
|
799
|
+
runtimeMode: RuntimeMode;
|
|
800
|
+
limit?: number;
|
|
801
|
+
}
|
|
802
|
+
interface RecommendationSummary {
|
|
803
|
+
total: number;
|
|
804
|
+
by_status: Record<string, number>;
|
|
805
|
+
}
|
|
806
|
+
declare class TrustRecommendationManager {
|
|
807
|
+
private store;
|
|
808
|
+
constructor(store: RecommendationStore);
|
|
809
|
+
private upsertRecommendation;
|
|
810
|
+
sync(input: SyncTrustRecommendationsInput): StoredTrustRecommendation[];
|
|
811
|
+
get(id: string): StoredTrustRecommendation | null;
|
|
812
|
+
list(opts?: {
|
|
813
|
+
status?: TrustRecommendationStatus | TrustRecommendationStatus[];
|
|
814
|
+
remoteDid?: string;
|
|
815
|
+
limit?: number;
|
|
816
|
+
}): StoredTrustRecommendation[];
|
|
817
|
+
apply(id: string): StoredTrustRecommendation | null;
|
|
818
|
+
dismiss(id: string): StoredTrustRecommendation | null;
|
|
819
|
+
reopen(id: string): StoredTrustRecommendation | null;
|
|
820
|
+
summarize(): RecommendationSummary;
|
|
821
|
+
}
|
|
822
|
+
|
|
425
823
|
/**
|
|
426
824
|
* A2A adapter for PingAgentClient.
|
|
427
825
|
* Allows PingAgent to call external agents that speak the A2A protocol,
|
|
@@ -483,7 +881,7 @@ interface WsSubscriptionOptions {
|
|
|
483
881
|
getAccessToken: () => string | Promise<string>;
|
|
484
882
|
myDid: string;
|
|
485
883
|
listConversations: () => Promise<ConversationEntry[]>;
|
|
486
|
-
onMessage: (envelope: any, conversationId: string) => void
|
|
884
|
+
onMessage: (envelope: any, conversationId: string) => void | Promise<void>;
|
|
487
885
|
onControl?: (control: WsControlPayload, conversationId: string) => void;
|
|
488
886
|
onError?: (err: Error) => void;
|
|
489
887
|
/** Optional debug hook for observability (non-fatal events). */
|
|
@@ -549,4 +947,4 @@ declare class WsSubscription {
|
|
|
549
947
|
private syncConnections;
|
|
550
948
|
}
|
|
551
949
|
|
|
552
|
-
export { A2AAdapter, type A2AAdapterOptions, type A2ATaskResult, type AgentProfile, type ClientOptions, type Contact, ContactManager, type ConversationEntry, type ConversationListResponse, type DirectoryBrowseResponse, type FeedByDidResponse, type FeedPost, type FeedPublicResponse, type FetchResponse, HistoryManager, HttpTransport, LocalStore, PingAgentClient, type SendResponse, type StoredMessage, type SubscriptionResponse, type SubscriptionUsage, type TaskResult, type TransportOptions, WsSubscription, type WsSubscriptionOptions, ensureTokenValid, generateIdentity, getIdentityPath, getProfile, getRootDir, getStorePath, identityExists, loadIdentity, saveIdentity, updateStoredToken };
|
|
950
|
+
export { A2AAdapter, type A2AAdapterOptions, type A2ATaskResult, type AgentEncryptionCard, type AgentProfile, type ClientOptions, type Contact, ContactManager, type ContactPolicyAction, type ContactPolicyDecision, type ConversationEntry, type ConversationListResponse, type DirectoryBrowseResponse, type DirectorySelfResponse, type EncryptedPayloadWrapper, type EncryptionIdentityFields, type EncryptionPrivateKeyJwk, type EncryptionPublicKeyJwk, type FeedByDidResponse, type FeedPost, type FeedPublicResponse, type FetchResponse, HistoryManager, HttpTransport, LocalStore, PingAgentClient, type RecommendationSummary, type ReplyTarget, type RuntimeMode, type SendResponse, SessionManager, type SessionMessageInput, type SessionState, type StoredMessage, type StoredTrustRecommendation, type SubscriptionResponse, type SubscriptionUsage, type SyncTrustRecommendationsInput, type TaskPolicyAction, type TaskPolicyDecision, type TaskResult, type TaskThread, TaskThreadManager, type TaskThreadStatus, type TaskThreadUpsert, type TransportOptions, type TrustPolicyAuditEvent, type TrustPolicyAuditEventType, type TrustPolicyAuditInput, TrustPolicyAuditManager, type TrustPolicyAuditSummary, type TrustPolicyContext, type TrustPolicyDoc, type TrustPolicyLearningSummary, type TrustPolicyRecommendation, TrustRecommendationManager, type TrustRecommendationStatus, type TrustState, WsSubscription, type WsSubscriptionOptions, buildSessionKey, buildTrustPolicyRecommendations, decideContactPolicy, decideTaskPolicy, decryptPayloadForIdentity, defaultTrustPolicyDoc, encryptPayloadForRecipients, ensureIdentityEncryptionKeys, ensureTokenValid, generateIdentity, getIdentityPath, getProfile, getRootDir, getStorePath, identityExists, isEncryptedPayload, loadIdentity, matchesTrustPolicyRule, normalizeTrustPolicyDoc, previewFromPayload, saveIdentity, shouldEncryptConversationPayload, summarizeTrustPolicyAudit, updateStoredToken, upsertTrustPolicyRecommendation };
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,19 @@ import {
|
|
|
5
5
|
HttpTransport,
|
|
6
6
|
LocalStore,
|
|
7
7
|
PingAgentClient,
|
|
8
|
+
SessionManager,
|
|
9
|
+
TaskThreadManager,
|
|
10
|
+
TrustPolicyAuditManager,
|
|
11
|
+
TrustRecommendationManager,
|
|
8
12
|
WsSubscription,
|
|
13
|
+
buildSessionKey,
|
|
14
|
+
buildTrustPolicyRecommendations,
|
|
15
|
+
decideContactPolicy,
|
|
16
|
+
decideTaskPolicy,
|
|
17
|
+
decryptPayloadForIdentity,
|
|
18
|
+
defaultTrustPolicyDoc,
|
|
19
|
+
encryptPayloadForRecipients,
|
|
20
|
+
ensureIdentityEncryptionKeys,
|
|
9
21
|
ensureTokenValid,
|
|
10
22
|
generateIdentity,
|
|
11
23
|
getIdentityPath,
|
|
@@ -13,10 +25,17 @@ import {
|
|
|
13
25
|
getRootDir,
|
|
14
26
|
getStorePath,
|
|
15
27
|
identityExists,
|
|
28
|
+
isEncryptedPayload,
|
|
16
29
|
loadIdentity,
|
|
30
|
+
matchesTrustPolicyRule,
|
|
31
|
+
normalizeTrustPolicyDoc,
|
|
32
|
+
previewFromPayload,
|
|
17
33
|
saveIdentity,
|
|
18
|
-
|
|
19
|
-
|
|
34
|
+
shouldEncryptConversationPayload,
|
|
35
|
+
summarizeTrustPolicyAudit,
|
|
36
|
+
updateStoredToken,
|
|
37
|
+
upsertTrustPolicyRecommendation
|
|
38
|
+
} from "./chunk-PFABO4C7.js";
|
|
20
39
|
export {
|
|
21
40
|
A2AAdapter,
|
|
22
41
|
ContactManager,
|
|
@@ -24,7 +43,19 @@ export {
|
|
|
24
43
|
HttpTransport,
|
|
25
44
|
LocalStore,
|
|
26
45
|
PingAgentClient,
|
|
46
|
+
SessionManager,
|
|
47
|
+
TaskThreadManager,
|
|
48
|
+
TrustPolicyAuditManager,
|
|
49
|
+
TrustRecommendationManager,
|
|
27
50
|
WsSubscription,
|
|
51
|
+
buildSessionKey,
|
|
52
|
+
buildTrustPolicyRecommendations,
|
|
53
|
+
decideContactPolicy,
|
|
54
|
+
decideTaskPolicy,
|
|
55
|
+
decryptPayloadForIdentity,
|
|
56
|
+
defaultTrustPolicyDoc,
|
|
57
|
+
encryptPayloadForRecipients,
|
|
58
|
+
ensureIdentityEncryptionKeys,
|
|
28
59
|
ensureTokenValid,
|
|
29
60
|
generateIdentity,
|
|
30
61
|
getIdentityPath,
|
|
@@ -32,7 +63,14 @@ export {
|
|
|
32
63
|
getRootDir,
|
|
33
64
|
getStorePath,
|
|
34
65
|
identityExists,
|
|
66
|
+
isEncryptedPayload,
|
|
35
67
|
loadIdentity,
|
|
68
|
+
matchesTrustPolicyRule,
|
|
69
|
+
normalizeTrustPolicyDoc,
|
|
70
|
+
previewFromPayload,
|
|
36
71
|
saveIdentity,
|
|
37
|
-
|
|
72
|
+
shouldEncryptConversationPayload,
|
|
73
|
+
summarizeTrustPolicyAudit,
|
|
74
|
+
updateStoredToken,
|
|
75
|
+
upsertTrustPolicyRecommendation
|
|
38
76
|
};
|