@pnds/sdk 1.8.0 → 1.10.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/src/types.ts CHANGED
@@ -41,6 +41,26 @@ export type ChatMemberRole = 'owner' | 'admin' | 'member';
41
41
 
42
42
  export type NotificationLevel = 'all' | 'mentions_only' | 'none';
43
43
 
44
+ // Push notification subscription
45
+ export interface PushSubscribeRequest {
46
+ platform: 'web' | 'ios' | 'android';
47
+ token: string;
48
+ device_id?: string;
49
+ }
50
+
51
+ // Notification preferences
52
+ export interface NotifPrefs {
53
+ dm?: boolean;
54
+ mention?: boolean;
55
+ task_assign?: boolean;
56
+ }
57
+
58
+ export interface NotificationPreferences {
59
+ scope: string;
60
+ prefs: NotifPrefs;
61
+ updated_at: string;
62
+ }
63
+
44
64
  export interface ChatMember {
45
65
  chat_id: string;
46
66
  user_id: string;
@@ -184,7 +204,7 @@ export interface Message {
184
204
  deleted_at: string | null;
185
205
  created_at: string;
186
206
  idempotency_key: string | null;
187
- agent_run_id?: string | null;
207
+ agent_step_id?: string | null;
188
208
  hints?: MessageHints | null;
189
209
  }
190
210
 
@@ -365,7 +385,7 @@ export interface SendMessageRequest {
365
385
  content: MessageContent;
366
386
  thread_root_id?: string;
367
387
  idempotency_key?: string;
368
- agent_run_id?: string;
388
+ agent_step_id?: string;
369
389
  hints?: MessageHints;
370
390
  }
371
391
 
@@ -375,7 +395,7 @@ export interface SendDirectMessageRequest {
375
395
  content: MessageContent;
376
396
  thread_root_id?: string;
377
397
  idempotency_key?: string;
378
- agent_run_id?: string;
398
+ agent_step_id?: string;
379
399
  hints?: MessageHints;
380
400
  }
381
401
 
@@ -446,17 +466,10 @@ export interface AgentProfile {
446
466
  created_at: string;
447
467
  }
448
468
 
449
- export interface AgentRun {
450
- target_id: string;
451
- status: string;
452
- started_at: string;
453
- }
454
-
455
469
  export interface AgentPresence {
456
470
  online: boolean;
457
471
  status: string; // "online" | "busy" | "error" | "offline"
458
472
  session_id?: string;
459
- run?: AgentRun;
460
473
  telemetry?: Record<string, unknown>;
461
474
  }
462
475
 
@@ -483,7 +496,7 @@ export interface FileUrlResponse {
483
496
 
484
497
  export type TaskStatus = 'todo' | 'in_progress' | 'in_review' | 'done' | 'canceled';
485
498
  export type TaskPriority = 'high' | 'normal' | 'low';
486
- export type TaskRelationTargetType = 'task' | 'message' | 'chat' | 'agent_run';
499
+ export type TaskRelationTargetType = 'task' | 'message' | 'chat' | 'agent_session';
487
500
  export type TaskRelationType = 'blocks' | 'related' | 'duplicate' | 'source' | 'reference' | 'discussion' | 'execution';
488
501
 
489
502
  export interface Task {
@@ -698,6 +711,82 @@ export interface WikiNodeSectionArtifact {
698
711
  nodes: WikiNodeSection[];
699
712
  }
700
713
 
714
+ export interface WikiSearchResult {
715
+ wiki_id: string;
716
+ wiki_slug: string;
717
+ wiki_name: string;
718
+ node_id: string;
719
+ path: string;
720
+ title: string;
721
+ heading_path?: string[];
722
+ section_path: string;
723
+ level: number;
724
+ start_line: number;
725
+ end_line: number;
726
+ score: number;
727
+ snippet: string;
728
+ }
729
+
730
+ export interface WikiSearchResponse {
731
+ wiki_id: string;
732
+ wiki_slug: string;
733
+ wiki_name: string;
734
+ query: string;
735
+ ref: string;
736
+ results: WikiSearchResult[];
737
+ }
738
+
739
+ export interface WikiPageIndexEntry {
740
+ path: string;
741
+ title: string;
742
+ top_headings: string[];
743
+ size_bytes: number;
744
+ section_count: number;
745
+ }
746
+
747
+ export interface WikiPageIndex {
748
+ wiki_id: string;
749
+ wiki_slug: string;
750
+ wiki_name: string;
751
+ ref: string;
752
+ generated_at: string;
753
+ page_count: number;
754
+ pages: WikiPageIndexEntry[];
755
+ }
756
+
757
+ export interface WikiFileRef {
758
+ source_path: string;
759
+ uri: string;
760
+ context?: string;
761
+ prefix: string;
762
+ entity_id: string;
763
+ target_path?: string;
764
+ fragment?: string;
765
+ line: number;
766
+ }
767
+
768
+ export interface WikiRefsResponse {
769
+ wiki_id: string;
770
+ wiki_slug: string;
771
+ wiki_name: string;
772
+ ref: string;
773
+ total: number;
774
+ refs: WikiFileRef[];
775
+ }
776
+
777
+ export interface WikiBrokenRef extends WikiFileRef {
778
+ reason: string;
779
+ }
780
+
781
+ export interface WikiRefsCheckResponse {
782
+ wiki_id: string;
783
+ wiki_slug: string;
784
+ wiki_name: string;
785
+ ref: string;
786
+ total: number;
787
+ broken: WikiBrokenRef[];
788
+ }
789
+
701
790
  export interface WikiDiffFile {
702
791
  path: string;
703
792
  action?: string; // "create" | "update" | "delete"
@@ -858,7 +947,7 @@ export interface MessageNewData {
858
947
  edited_at?: string | null;
859
948
  deleted_at?: string | null;
860
949
  idempotency_key?: string | null;
861
- agent_run_id?: string | null;
950
+ agent_step_id?: string | null;
862
951
  hints?: MessageHints | null;
863
952
  }
864
953
 
@@ -932,7 +1021,7 @@ export interface TaskComment {
932
1021
  author_id: string;
933
1022
  body: string;
934
1023
  mentions?: Mention[];
935
- agent_run_id?: string | null;
1024
+ agent_step_id?: string | null;
936
1025
  created_at: string;
937
1026
  updated_at: string;
938
1027
  author?: User;
@@ -984,17 +1073,16 @@ export interface ProjectDeletedData {
984
1073
  org_id: string;
985
1074
  }
986
1075
 
987
- // ---- Agent Run / Step ----
1076
+ // ---- Agent Session / Step ----
988
1077
 
989
- export interface AgentRunDB {
1078
+ export interface AgentSessionDB {
990
1079
  id: string;
991
1080
  agent_id: string;
992
1081
  org_id: string;
993
- status: string;
994
- trigger_type: string;
995
- trigger_ref: Record<string, unknown> | null;
996
- default_target_type: string;
997
- default_target_id: string | null;
1082
+ status: string; // active | completed | failed | cancelled
1083
+ runtime_type: string;
1084
+ runtime_key: string | null;
1085
+ runtime_ref: Record<string, unknown> | null;
998
1086
  started_at: string;
999
1087
  finished_at: string | null;
1000
1088
  created_at: string;
@@ -1002,47 +1090,48 @@ export interface AgentRunDB {
1002
1090
 
1003
1091
  export interface AgentStep {
1004
1092
  id: string;
1005
- run_id: string;
1093
+ session_id: string;
1006
1094
  step_type: string;
1095
+ target_type: string;
1096
+ target_id: string | null;
1007
1097
  content: Record<string, unknown>;
1098
+ group_key: string | null;
1099
+ runtime_key: string | null;
1008
1100
  idempotency_key?: string;
1009
1101
  created_at: string;
1010
1102
  }
1011
1103
 
1012
- export interface CreateAgentRunRequest {
1013
- trigger_type: string;
1014
- trigger_ref?: Record<string, unknown>;
1015
- chat_id?: string; // backward compat alias for default_target_type=chat
1016
- default_target_type?: string;
1017
- default_target_id?: string;
1104
+ export interface CreateAgentSessionRequest {
1105
+ runtime_type?: string;
1106
+ runtime_key?: string;
1107
+ runtime_ref?: Record<string, unknown>;
1018
1108
  }
1019
1109
 
1020
1110
  export interface CreateAgentStepRequest {
1021
1111
  step_type: string;
1022
1112
  content: Record<string, unknown>;
1113
+ target_type?: string;
1114
+ target_id?: string;
1115
+ group_key?: string;
1116
+ runtime_key?: string;
1023
1117
  idempotency_key?: string;
1024
- projection?: boolean;
1025
- chat_projection?: boolean; // backward compat alias for projection
1118
+ projection?: boolean; // project text steps to chat message or task comment (controlled by agent's run_config)
1026
1119
  }
1027
1120
 
1028
- export interface UpdateAgentRunRequest {
1121
+ export interface UpdateAgentSessionRequest {
1029
1122
  status: string;
1030
- emit_fallback_message?: boolean;
1031
1123
  }
1032
1124
 
1033
- // Agent run WS event data
1034
- export type AgentRunNewData = AgentRunDB;
1125
+ // Agent session WS event data
1126
+ export type AgentSessionNewData = AgentSessionDB;
1035
1127
 
1036
- export interface AgentRunUpdateData {
1037
- run_id: string;
1128
+ export interface AgentSessionUpdateData {
1129
+ session_id: string;
1038
1130
  status: string;
1039
1131
  finished_at?: string;
1040
1132
  }
1041
1133
 
1042
- export interface AgentStepNewData extends AgentStep {
1043
- target_type?: string;
1044
- target_id?: string;
1045
- }
1134
+ export interface AgentStepNewData extends AgentStep {}
1046
1135
 
1047
1136
  export type WikiChangesetCreatedData = WikiChangeset & { org_id: string };
1048
1137
  export type WikiChangesetUpdatedData = WikiChangeset & { org_id: string };
@@ -1054,13 +1143,7 @@ export type WikiChangesetUpdatedData = WikiChangeset & { org_id: string };
1054
1143
  export type InboxItemType =
1055
1144
  | 'mention' | 'task_assign' | 'task_update'
1056
1145
  | 'task_comment' | 'approval_request'
1057
- | 'agent_alert' | 'invitation'
1058
- | 'agent_dm' | 'agent_route';
1059
-
1060
- export type InboxItemReason =
1061
- | 'assigned' | 'mentioned' | 'authored'
1062
- | 'subscribed' | 'approval_requested'
1063
- | 'dm_received' | 'routed';
1146
+ | 'agent_alert' | 'invitation';
1064
1147
 
1065
1148
  export interface InboxItem {
1066
1149
  id: string;
@@ -1068,7 +1151,6 @@ export interface InboxItem {
1068
1151
  recipient_id: string;
1069
1152
  actor_id: string | null;
1070
1153
  type: InboxItemType;
1071
- reason: InboxItemReason;
1072
1154
  entity_type: string;
1073
1155
  entity_id: string;
1074
1156
  group_key: string;
@@ -1085,16 +1167,40 @@ export interface InboxItem {
1085
1167
  updated_at: string;
1086
1168
  }
1087
1169
 
1088
- export type NotificationNewData = InboxItem;
1170
+ // ============================================================
1171
+ // Dispatch Types (agent event delivery)
1172
+ // ============================================================
1173
+
1174
+ export type DispatchEventType = 'message' | 'task_assign';
1175
+ export type DispatchStatus = 'pending' | 'acked';
1089
1176
 
1090
- export interface NotificationUpdateData {
1177
+ export interface DispatchEvent {
1178
+ id: string;
1179
+ org_id: string;
1180
+ agent_id: string;
1181
+ event_type: DispatchEventType;
1182
+ source_type: string;
1183
+ source_id: string;
1184
+ chat_id: string | null;
1185
+ task_id: string | null;
1186
+ actor_id: string | null;
1187
+ status: DispatchStatus;
1188
+ acked_at: string | null;
1189
+ created_at: string;
1190
+ }
1191
+
1192
+ export type DispatchNewData = DispatchEvent;
1193
+
1194
+ export type InboxNewData = InboxItem;
1195
+
1196
+ export interface InboxUpdateData {
1091
1197
  id: string;
1092
1198
  read_at?: string | null;
1093
1199
  archived_at?: string | null;
1094
1200
  snoozed_until?: string | null;
1095
1201
  }
1096
1202
 
1097
- export interface NotificationBulkUpdateData {
1203
+ export interface InboxBulkUpdateData {
1098
1204
  action: 'mark_all_read' | 'archive_all';
1099
1205
  }
1100
1206
 
@@ -1102,6 +1208,11 @@ export interface InboxUnreadCountResponse {
1102
1208
  count: number;
1103
1209
  }
1104
1210
 
1211
+ export interface ReadPositionUpdateData {
1212
+ chat_id: string;
1213
+ last_read_message_id: string;
1214
+ }
1215
+
1105
1216
  export type WsEventMap = {
1106
1217
  'hello': HelloData;
1107
1218
  'message.new': MessageNewData;
@@ -1127,8 +1238,8 @@ export type WsEventMap = {
1127
1238
  'project.created': ProjectCreatedData;
1128
1239
  'project.updated': ProjectUpdatedData;
1129
1240
  'project.deleted': ProjectDeletedData;
1130
- 'agent_run.new': AgentRunNewData;
1131
- 'agent_run.update': AgentRunUpdateData;
1241
+ 'agent_session.new': AgentSessionNewData;
1242
+ 'agent_session.update': AgentSessionUpdateData;
1132
1243
  'agent_step.new': AgentStepNewData;
1133
1244
  'invitation.new': InvitationNewEventData;
1134
1245
  'invitation.accepted': InvitationAcceptedEventData;
@@ -1137,9 +1248,11 @@ export type WsEventMap = {
1137
1248
  'presence.update': PresenceUpdateData;
1138
1249
  'wiki.changeset.created': WikiChangesetCreatedData;
1139
1250
  'wiki.changeset.updated': WikiChangesetUpdatedData;
1140
- 'notification.new': NotificationNewData;
1141
- 'notification.update': NotificationUpdateData;
1142
- 'notification.bulk_update': NotificationBulkUpdateData;
1251
+ 'inbox.new': InboxNewData;
1252
+ 'inbox.update': InboxUpdateData;
1253
+ 'inbox.bulk_update': InboxBulkUpdateData;
1254
+ 'read_position.updated': ReadPositionUpdateData;
1255
+ 'dispatch.new': DispatchNewData;
1143
1256
  };
1144
1257
 
1145
1258
  // Invitation WS event data
package/src/ws.ts CHANGED
@@ -7,8 +7,6 @@ export type WsEventHandler<T extends WsEventType> = (data: WsEventMap[T], seq?:
7
7
  export type WsClientEventMap = {
8
8
  'ping': { ts: number };
9
9
  'typing': { chat_id: string; thread_root_id: string | null; action: 'start' | 'stop' };
10
- 'ack': { message_id: string };
11
- 'read': { chat_id: string; last_read_id: string };
12
10
  'watch': { chat_ids: string[] };
13
11
  'agent.heartbeat': { session_id: string; telemetry?: Record<string, unknown> };
14
12
  };
@@ -81,12 +79,15 @@ export class PondWs {
81
79
  return;
82
80
  }
83
81
 
84
- const params = new URLSearchParams({ ticket: ticket.ticket });
82
+ // wsUrl may already contain query params (e.g. ?swimlane=pr-42 for
83
+ // swimlane routing). Use URL API to merge params correctly.
84
+ const url = new URL(wsUrl);
85
+ url.searchParams.set('ticket', ticket.ticket);
85
86
  if (this.lastSeq > 0) {
86
- params.set('last_seq', String(this.lastSeq));
87
+ url.searchParams.set('last_seq', String(this.lastSeq));
87
88
  }
88
89
 
89
- this.ws = new WebSocket(`${wsUrl}?${params.toString()}`);
90
+ this.ws = new WebSocket(url.toString());
90
91
 
91
92
  // Force-reconnect if not connected within 15s.
92
93
  // Handles edge case where Node 22 WebSocket transitions to CLOSED without
@@ -171,14 +172,6 @@ export class PondWs {
171
172
  });
172
173
  }
173
174
 
174
- sendAck(messageId: string) {
175
- this.send({ type: WS_EVENTS.ACK, data: { message_id: messageId } });
176
- }
177
-
178
- sendRead(chatId: string, lastReadId: string) {
179
- this.send({ type: WS_EVENTS.READ, data: { chat_id: chatId, last_read_id: lastReadId } });
180
- }
181
-
182
175
  /** Send an agent heartbeat with telemetry data. */
183
176
  sendAgentHeartbeat(sessionId: string, telemetry?: Record<string, unknown>) {
184
177
  this.send({