@pingagent/sdk 0.1.12 → 0.1.14
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 +111 -3
- package/dist/chunk-MFKDD5X3.js +4235 -0
- package/dist/chunk-N2GCIMAW.js +3800 -0
- package/dist/chunk-SAI2R63F.js +3923 -0
- package/dist/chunk-TWKCLIYT.js +4007 -0
- package/dist/index.d.ts +160 -1
- package/dist/index.js +7 -1
- package/dist/web-server.js +340 -6
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -265,6 +265,107 @@ declare class TaskHandoffManager {
|
|
|
265
265
|
listBySession(sessionKey: string, limit?: number): TaskHandoff[];
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
+
type CollaborationProjectionOutboxStatus = 'pending' | 'sent' | 'failed';
|
|
269
|
+
type CollaborationProjectionKind = 'approval_resolution' | 'decision_prompt' | 'runtime_update' | 'collaboration_update';
|
|
270
|
+
interface CollaborationProjectionOutboxEntry {
|
|
271
|
+
id: number;
|
|
272
|
+
created_at: number;
|
|
273
|
+
session_key?: string;
|
|
274
|
+
conversation_id?: string;
|
|
275
|
+
target_human_session?: string;
|
|
276
|
+
projection_kind: CollaborationProjectionKind;
|
|
277
|
+
summary: string;
|
|
278
|
+
body: Record<string, unknown>;
|
|
279
|
+
status: CollaborationProjectionOutboxStatus;
|
|
280
|
+
attempt_count: number;
|
|
281
|
+
last_error?: string;
|
|
282
|
+
delivered_at?: number;
|
|
283
|
+
source_event_id?: number;
|
|
284
|
+
}
|
|
285
|
+
interface CollaborationProjectionOutboxInput {
|
|
286
|
+
created_at?: number;
|
|
287
|
+
session_key?: string;
|
|
288
|
+
conversation_id?: string;
|
|
289
|
+
target_human_session?: string;
|
|
290
|
+
projection_kind: CollaborationProjectionKind;
|
|
291
|
+
summary: string;
|
|
292
|
+
body: Record<string, unknown>;
|
|
293
|
+
source_event_id?: number;
|
|
294
|
+
}
|
|
295
|
+
declare class CollaborationProjectionOutboxManager {
|
|
296
|
+
private store;
|
|
297
|
+
constructor(store: LocalStore);
|
|
298
|
+
enqueue(input: CollaborationProjectionOutboxInput): CollaborationProjectionOutboxEntry;
|
|
299
|
+
get(id: number): CollaborationProjectionOutboxEntry | null;
|
|
300
|
+
listRecent(limit?: number): CollaborationProjectionOutboxEntry[];
|
|
301
|
+
listPending(limit?: number): CollaborationProjectionOutboxEntry[];
|
|
302
|
+
listDispatchable(limit?: number): CollaborationProjectionOutboxEntry[];
|
|
303
|
+
listBySession(sessionKey: string, limit?: number): CollaborationProjectionOutboxEntry[];
|
|
304
|
+
listByStatus(status: CollaborationProjectionOutboxStatus, limit?: number): CollaborationProjectionOutboxEntry[];
|
|
305
|
+
markSent(id: number, deliveredAt?: number): CollaborationProjectionOutboxEntry | null;
|
|
306
|
+
markFailed(id: number, error: string): CollaborationProjectionOutboxEntry | null;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
type CollaborationEventType = 'external_message_received' | 'agent_progress' | 'agent_conclusion' | 'handoff_started' | 'handoff_completed' | 'risk_detected' | 'decision_required' | 'task_completed' | 'runtime_degraded' | 'runtime_repaired';
|
|
310
|
+
type CollaborationEventSeverity = 'info' | 'notice' | 'warning' | 'critical';
|
|
311
|
+
type CollaborationApprovalStatus = 'not_required' | 'pending' | 'approved' | 'rejected';
|
|
312
|
+
interface CollaborationEvent {
|
|
313
|
+
id: number;
|
|
314
|
+
ts_ms: number;
|
|
315
|
+
event_type: CollaborationEventType;
|
|
316
|
+
severity: CollaborationEventSeverity;
|
|
317
|
+
session_key?: string;
|
|
318
|
+
conversation_id?: string;
|
|
319
|
+
target_human_session?: string;
|
|
320
|
+
summary: string;
|
|
321
|
+
approval_required: boolean;
|
|
322
|
+
approval_status: CollaborationApprovalStatus;
|
|
323
|
+
detail?: Record<string, unknown>;
|
|
324
|
+
}
|
|
325
|
+
interface CollaborationEventInput {
|
|
326
|
+
ts_ms?: number;
|
|
327
|
+
event_type: CollaborationEventType;
|
|
328
|
+
severity?: CollaborationEventSeverity;
|
|
329
|
+
session_key?: string;
|
|
330
|
+
conversation_id?: string;
|
|
331
|
+
target_human_session?: string;
|
|
332
|
+
summary: string;
|
|
333
|
+
approval_required?: boolean;
|
|
334
|
+
approval_status?: CollaborationApprovalStatus;
|
|
335
|
+
detail?: Record<string, unknown>;
|
|
336
|
+
}
|
|
337
|
+
interface CollaborationEventSummary {
|
|
338
|
+
total_events: number;
|
|
339
|
+
latest_ts_ms?: number;
|
|
340
|
+
by_type: Record<string, number>;
|
|
341
|
+
by_severity: Record<string, number>;
|
|
342
|
+
pending_approvals: number;
|
|
343
|
+
}
|
|
344
|
+
interface ResolveCollaborationApprovalInput {
|
|
345
|
+
resolved_by?: string;
|
|
346
|
+
note?: string;
|
|
347
|
+
ts_ms?: number;
|
|
348
|
+
}
|
|
349
|
+
interface ResolveCollaborationApprovalResult {
|
|
350
|
+
updated: CollaborationEvent;
|
|
351
|
+
resolution_event: CollaborationEvent;
|
|
352
|
+
projection_outbox: CollaborationProjectionOutboxEntry | null;
|
|
353
|
+
}
|
|
354
|
+
declare class CollaborationEventManager {
|
|
355
|
+
private store;
|
|
356
|
+
constructor(store: LocalStore);
|
|
357
|
+
record(input: CollaborationEventInput): CollaborationEvent;
|
|
358
|
+
listRecent(limit?: number): CollaborationEvent[];
|
|
359
|
+
listBySession(sessionKey: string, limit?: number): CollaborationEvent[];
|
|
360
|
+
listByConversation(conversationId: string, limit?: number): CollaborationEvent[];
|
|
361
|
+
listByTargetHumanSession(targetHumanSession: string, limit?: number): CollaborationEvent[];
|
|
362
|
+
get(id: number): CollaborationEvent | null;
|
|
363
|
+
listPending(limit?: number): CollaborationEvent[];
|
|
364
|
+
listPendingBySession(sessionKey: string, limit?: number): CollaborationEvent[];
|
|
365
|
+
resolveApproval(id: number, approvalStatus: Extract<CollaborationApprovalStatus, 'approved' | 'rejected'>, input?: ResolveCollaborationApprovalInput): ResolveCollaborationApprovalResult | null;
|
|
366
|
+
summarize(limit?: number): CollaborationEventSummary;
|
|
367
|
+
}
|
|
368
|
+
|
|
268
369
|
type CapabilityContactMode = 'dm' | 'task' | 'either';
|
|
269
370
|
interface CapabilityCardItem {
|
|
270
371
|
id: string;
|
|
@@ -545,6 +646,7 @@ declare class PingAgentClient {
|
|
|
545
646
|
private sessionSummaryManager?;
|
|
546
647
|
private taskThreadManager?;
|
|
547
648
|
private taskHandoffManager?;
|
|
649
|
+
private collaborationEventManager?;
|
|
548
650
|
private agentCardCache;
|
|
549
651
|
constructor(opts: ClientOptions);
|
|
550
652
|
getContactManager(): ContactManager | undefined;
|
|
@@ -553,6 +655,7 @@ declare class PingAgentClient {
|
|
|
553
655
|
getSessionSummaryManager(): SessionSummaryManager | undefined;
|
|
554
656
|
getTaskThreadManager(): TaskThreadManager | undefined;
|
|
555
657
|
getTaskHandoffManager(): TaskHandoffManager | undefined;
|
|
658
|
+
getCollaborationEventManager(): CollaborationEventManager | undefined;
|
|
556
659
|
/** Update the in-memory access token (e.g. after proactive refresh from disk). */
|
|
557
660
|
setAccessToken(token: string): void;
|
|
558
661
|
register(developerToken?: string): Promise<ApiResponse>;
|
|
@@ -832,6 +935,7 @@ declare class HttpTransport {
|
|
|
832
935
|
type ContactPolicyAction = 'approve' | 'manual' | 'reject';
|
|
833
936
|
type TaskPolicyAction = 'bridge' | 'execute' | 'deny';
|
|
834
937
|
type RuntimeMode = 'bridge' | 'executor';
|
|
938
|
+
type CollaborationProjectionPreset = 'quiet' | 'balanced' | 'strict';
|
|
835
939
|
interface TrustPolicyRule<A extends string> {
|
|
836
940
|
match: string;
|
|
837
941
|
action: A;
|
|
@@ -848,6 +952,9 @@ interface TrustPolicyDoc {
|
|
|
848
952
|
default_action: TaskPolicyAction;
|
|
849
953
|
rules: Array<TrustPolicyRule<TaskPolicyAction>>;
|
|
850
954
|
};
|
|
955
|
+
collaboration_projection: {
|
|
956
|
+
preset: CollaborationProjectionPreset;
|
|
957
|
+
};
|
|
851
958
|
}
|
|
852
959
|
interface TrustPolicyContext {
|
|
853
960
|
sender_did?: string;
|
|
@@ -1085,6 +1192,7 @@ interface WsSubscriptionOptions {
|
|
|
1085
1192
|
getAccessToken: () => string | Promise<string>;
|
|
1086
1193
|
myDid: string;
|
|
1087
1194
|
listConversations: () => Promise<ConversationEntry[]>;
|
|
1195
|
+
listIntervalMs?: number;
|
|
1088
1196
|
onMessage: (envelope: any, conversationId: string) => void | Promise<void>;
|
|
1089
1197
|
onControl?: (control: WsControlPayload, conversationId: string) => void;
|
|
1090
1198
|
onError?: (err: Error) => void;
|
|
@@ -1137,6 +1245,7 @@ declare class WsSubscription {
|
|
|
1137
1245
|
constructor(opts: WsSubscriptionOptions);
|
|
1138
1246
|
start(): void;
|
|
1139
1247
|
stop(): void;
|
|
1248
|
+
syncNow(): Promise<void>;
|
|
1140
1249
|
/**
|
|
1141
1250
|
* Stop a single conversation's WebSocket and do not reconnect.
|
|
1142
1251
|
* Used when the conversation is revoked or the client no longer wants to subscribe.
|
|
@@ -1151,6 +1260,56 @@ declare class WsSubscription {
|
|
|
1151
1260
|
private syncConnections;
|
|
1152
1261
|
}
|
|
1153
1262
|
|
|
1263
|
+
interface UserWakeEvent {
|
|
1264
|
+
type: 'wake';
|
|
1265
|
+
reason: 'message' | 'control';
|
|
1266
|
+
conversation_id: string;
|
|
1267
|
+
seq?: number;
|
|
1268
|
+
action?: string;
|
|
1269
|
+
task_id?: string;
|
|
1270
|
+
ts_ms: number;
|
|
1271
|
+
}
|
|
1272
|
+
interface UserWakeSubscriptionOptions {
|
|
1273
|
+
serverUrl: string;
|
|
1274
|
+
getAccessToken: () => string | Promise<string>;
|
|
1275
|
+
onWake: (event: UserWakeEvent) => void | Promise<void>;
|
|
1276
|
+
onOpen?: () => void;
|
|
1277
|
+
onError?: (err: Error) => void;
|
|
1278
|
+
onDebug?: (info: {
|
|
1279
|
+
event: string;
|
|
1280
|
+
detail?: Record<string, unknown>;
|
|
1281
|
+
}) => void;
|
|
1282
|
+
heartbeat?: {
|
|
1283
|
+
enable?: boolean;
|
|
1284
|
+
idleThresholdMs?: number;
|
|
1285
|
+
pingIntervalMs?: number;
|
|
1286
|
+
pongTimeoutMs?: number;
|
|
1287
|
+
maxMissedPongs?: number;
|
|
1288
|
+
tickMs?: number;
|
|
1289
|
+
jitter?: number;
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
declare class UserWakeSubscription {
|
|
1293
|
+
private readonly opts;
|
|
1294
|
+
private ws;
|
|
1295
|
+
private reconnectTimer;
|
|
1296
|
+
private reconnectAttempt;
|
|
1297
|
+
private heartbeatTimer;
|
|
1298
|
+
private stopped;
|
|
1299
|
+
private lastRxAt;
|
|
1300
|
+
private lastPingAt;
|
|
1301
|
+
private nextPingAt;
|
|
1302
|
+
private missedPongs;
|
|
1303
|
+
private pongTimeout;
|
|
1304
|
+
constructor(opts: UserWakeSubscriptionOptions);
|
|
1305
|
+
start(): void;
|
|
1306
|
+
stop(): void;
|
|
1307
|
+
private wakeUrl;
|
|
1308
|
+
private connectAsync;
|
|
1309
|
+
private scheduleReconnect;
|
|
1310
|
+
private heartbeatTick;
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1154
1313
|
declare function getActiveSessionFilePath(): string;
|
|
1155
1314
|
declare function getSessionMapFilePath(): string;
|
|
1156
1315
|
declare function getSessionBindingAlertsFilePath(): string;
|
|
@@ -1204,4 +1363,4 @@ interface OpenClawIngressRuntimeStatus {
|
|
|
1204
1363
|
declare function getIngressRuntimeStatusFilePath(): string;
|
|
1205
1364
|
declare function readIngressRuntimeStatus(filePath?: string): OpenClawIngressRuntimeStatus | null;
|
|
1206
1365
|
|
|
1207
|
-
export { A2AAdapter, type A2AAdapterOptions, type A2ATaskResult, type AgentEncryptionCard, type AgentProfile, type CapabilityCard, type CapabilityCardItem, type CapabilityContactMode, type ClientOptions, type Contact, type ContactCardShare, 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, type OpenClawIngressRuntimeStatus, PingAgentClient, type PublicAgentProfile, type PublicLinkState, type RecommendationSummary, type ReplyTarget, type RuntimeMode, SESSION_SUMMARY_FIELDS, type SendResponse, type SessionBindingAlert, type SessionBindingEntry, SessionManager, type SessionMessageInput, type SessionState, type SessionSummary, type SessionSummaryFieldKey, SessionSummaryManager, type SessionSummaryUpsert, type StoredMessage, type StoredTrustRecommendation, type SubscriptionResponse, type SubscriptionUsage, type SyncTrustRecommendationsInput, type TaskHandoff, TaskHandoffManager, type TaskHandoffPayload, type TaskHandoffUpsert, type TaskPolicyAction, type TaskPolicyDecision, type TaskResult, type TaskShareEntry, 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, type UpdateProfileInput, WsSubscription, type WsSubscriptionOptions, buildSessionKey, buildSessionSummaryHandoffText, buildTrustPolicyRecommendations, capabilityCardToLegacyCapabilities, clearSessionBindingAlert, decideContactPolicy, decideTaskPolicy, decryptPayloadForIdentity, defaultTrustPolicyDoc, encryptPayloadForRecipients, ensureIdentityEncryptionKeys, ensureTokenValid, formatCapabilityCardSummary, generateIdentity, getActiveSessionFilePath, getIdentityPath, getIngressRuntimeStatusFilePath, getProfile, getRootDir, getSessionBindingAlertsFilePath, getSessionMapFilePath, getStorePath, getTrustRecommendationActionLabel, identityExists, isEncryptedPayload, loadIdentity, matchesTrustPolicyRule, normalizeCapabilityCard, normalizeTrustPolicyDoc, previewFromPayload, readCurrentActiveSessionKey, readIngressRuntimeStatus, readSessionBindingAlerts, readSessionBindings, removeSessionBinding, saveIdentity, setSessionBinding, shouldEncryptConversationPayload, summarizeTrustPolicyAudit, updateStoredToken, upsertSessionBindingAlert, upsertTrustPolicyRecommendation, writeSessionBindingAlerts, writeSessionBindings };
|
|
1366
|
+
export { A2AAdapter, type A2AAdapterOptions, type A2ATaskResult, type AgentEncryptionCard, type AgentProfile, type CapabilityCard, type CapabilityCardItem, type CapabilityContactMode, type ClientOptions, type CollaborationApprovalStatus, type CollaborationEvent, type CollaborationEventInput, CollaborationEventManager, type CollaborationEventSeverity, type CollaborationEventSummary, type CollaborationEventType, type CollaborationProjectionKind, type CollaborationProjectionOutboxEntry, type CollaborationProjectionOutboxInput, CollaborationProjectionOutboxManager, type CollaborationProjectionOutboxStatus, type CollaborationProjectionPreset, type Contact, type ContactCardShare, 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, type OpenClawIngressRuntimeStatus, PingAgentClient, type PublicAgentProfile, type PublicLinkState, type RecommendationSummary, type ReplyTarget, type ResolveCollaborationApprovalInput, type ResolveCollaborationApprovalResult, type RuntimeMode, SESSION_SUMMARY_FIELDS, type SendResponse, type SessionBindingAlert, type SessionBindingEntry, SessionManager, type SessionMessageInput, type SessionState, type SessionSummary, type SessionSummaryFieldKey, SessionSummaryManager, type SessionSummaryUpsert, type StoredMessage, type StoredTrustRecommendation, type SubscriptionResponse, type SubscriptionUsage, type SyncTrustRecommendationsInput, type TaskHandoff, TaskHandoffManager, type TaskHandoffPayload, type TaskHandoffUpsert, type TaskPolicyAction, type TaskPolicyDecision, type TaskResult, type TaskShareEntry, 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, type UpdateProfileInput, type UserWakeEvent, UserWakeSubscription, type UserWakeSubscriptionOptions, WsSubscription, type WsSubscriptionOptions, buildSessionKey, buildSessionSummaryHandoffText, buildTrustPolicyRecommendations, capabilityCardToLegacyCapabilities, clearSessionBindingAlert, decideContactPolicy, decideTaskPolicy, decryptPayloadForIdentity, defaultTrustPolicyDoc, encryptPayloadForRecipients, ensureIdentityEncryptionKeys, ensureTokenValid, formatCapabilityCardSummary, generateIdentity, getActiveSessionFilePath, getIdentityPath, getIngressRuntimeStatusFilePath, getProfile, getRootDir, getSessionBindingAlertsFilePath, getSessionMapFilePath, getStorePath, getTrustRecommendationActionLabel, identityExists, isEncryptedPayload, loadIdentity, matchesTrustPolicyRule, normalizeCapabilityCard, normalizeTrustPolicyDoc, previewFromPayload, readCurrentActiveSessionKey, readIngressRuntimeStatus, readSessionBindingAlerts, readSessionBindings, removeSessionBinding, saveIdentity, setSessionBinding, shouldEncryptConversationPayload, summarizeTrustPolicyAudit, updateStoredToken, upsertSessionBindingAlert, upsertTrustPolicyRecommendation, writeSessionBindingAlerts, writeSessionBindings };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
A2AAdapter,
|
|
3
|
+
CollaborationEventManager,
|
|
4
|
+
CollaborationProjectionOutboxManager,
|
|
3
5
|
ContactManager,
|
|
4
6
|
HistoryManager,
|
|
5
7
|
HttpTransport,
|
|
@@ -12,6 +14,7 @@ import {
|
|
|
12
14
|
TaskThreadManager,
|
|
13
15
|
TrustPolicyAuditManager,
|
|
14
16
|
TrustRecommendationManager,
|
|
17
|
+
UserWakeSubscription,
|
|
15
18
|
WsSubscription,
|
|
16
19
|
buildSessionKey,
|
|
17
20
|
buildSessionSummaryHandoffText,
|
|
@@ -57,9 +60,11 @@ import {
|
|
|
57
60
|
upsertTrustPolicyRecommendation,
|
|
58
61
|
writeSessionBindingAlerts,
|
|
59
62
|
writeSessionBindings
|
|
60
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-MFKDD5X3.js";
|
|
61
64
|
export {
|
|
62
65
|
A2AAdapter,
|
|
66
|
+
CollaborationEventManager,
|
|
67
|
+
CollaborationProjectionOutboxManager,
|
|
63
68
|
ContactManager,
|
|
64
69
|
HistoryManager,
|
|
65
70
|
HttpTransport,
|
|
@@ -72,6 +77,7 @@ export {
|
|
|
72
77
|
TaskThreadManager,
|
|
73
78
|
TrustPolicyAuditManager,
|
|
74
79
|
TrustRecommendationManager,
|
|
80
|
+
UserWakeSubscription,
|
|
75
81
|
WsSubscription,
|
|
76
82
|
buildSessionKey,
|
|
77
83
|
buildSessionSummaryHandoffText,
|