@pnds/sdk 1.9.0 → 1.10.1

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/client.ts CHANGED
@@ -42,11 +42,11 @@ import type {
42
42
  Project,
43
43
  CreateProjectRequest,
44
44
  UpdateProjectRequest,
45
- AgentRunDB,
45
+ AgentSessionDB,
46
46
  AgentStep,
47
- CreateAgentRunRequest,
47
+ CreateAgentSessionRequest,
48
48
  CreateAgentStepRequest,
49
- UpdateAgentRunRequest,
49
+ UpdateAgentSessionRequest,
50
50
  OrgInvitation,
51
51
  InvitationPublicInfo,
52
52
  PlatformConfigResponse,
@@ -55,6 +55,10 @@ import type {
55
55
  WikiChangeset,
56
56
  WikiTreeResponse,
57
57
  WikiNodeSectionArtifact,
58
+ WikiSearchResponse,
59
+ WikiPageIndex,
60
+ WikiRefsResponse,
61
+ WikiRefsCheckResponse,
58
62
  WikiDiff,
59
63
  WikiPathScope,
60
64
  WikiAccessStatus,
@@ -73,6 +77,9 @@ import type {
73
77
  ResolveRefsResponse,
74
78
  BacklinksResponse,
75
79
  BrokenRefsResponse,
80
+ PushSubscribeRequest,
81
+ NotifPrefs,
82
+ NotificationPreferences,
76
83
  } from './types.js';
77
84
 
78
85
  export interface PondClientOptions {
@@ -81,6 +88,7 @@ export interface PondClientOptions {
81
88
  onTokenExpired?: () => void;
82
89
  getRefreshToken?: () => string | null;
83
90
  setTokens?: (tokens: { access_token: string; refresh_token: string }) => void;
91
+ swimlaneName?: string;
84
92
  }
85
93
 
86
94
  export class PondClient {
@@ -90,6 +98,7 @@ export class PondClient {
90
98
  private getRefreshToken?: () => string | null;
91
99
  private setTokens?: (tokens: { access_token: string; refresh_token: string }) => void;
92
100
  private refreshPromise: Promise<AuthTokens> | null = null;
101
+ private swimlaneName?: string;
93
102
 
94
103
  /** Auth endpoints excluded from automatic 401 refresh to prevent recursion. */
95
104
  private static readonly AUTH_PATHS = new Set([
@@ -100,12 +109,28 @@ export class PondClient {
100
109
  /** Proactive refresh when token expires within this window (seconds). */
101
110
  private static readonly REFRESH_THRESHOLD_S = 5 * 60;
102
111
 
112
+ /** Build headers common to all requests (auth, swimlane). */
113
+ private buildHeaders(extra?: Record<string, string>): Record<string, string> {
114
+ const headers: Record<string, string> = {
115
+ 'Content-Type': 'application/json',
116
+ ...extra,
117
+ };
118
+ if (this.token) {
119
+ headers['Authorization'] = `Bearer ${this.token}`;
120
+ }
121
+ if (this.swimlaneName) {
122
+ headers['X-Pnds-Swimlane'] = this.swimlaneName;
123
+ }
124
+ return headers;
125
+ }
126
+
103
127
  constructor(options: PondClientOptions = {}) {
104
128
  this.baseUrl = options.baseUrl ?? '';
105
129
  this.token = options.token ?? null;
106
130
  this.onTokenExpired = options.onTokenExpired;
107
131
  this.getRefreshToken = options.getRefreshToken;
108
132
  this.setTokens = options.setTokens;
133
+ this.swimlaneName = options.swimlaneName;
109
134
  }
110
135
 
111
136
  setToken(token: string | null) {
@@ -197,12 +222,7 @@ export class PondClient {
197
222
  if (qs) url += `?${qs}`;
198
223
  }
199
224
 
200
- const headers: Record<string, string> = {
201
- 'Content-Type': 'application/json',
202
- };
203
- if (this.token) {
204
- headers['Authorization'] = `Bearer ${this.token}`;
205
- }
225
+ const headers = this.buildHeaders();
206
226
 
207
227
  let res: Response;
208
228
  try {
@@ -535,31 +555,31 @@ export class PondClient {
535
555
  return this.request('GET', ENDPOINTS.AGENT_ME(orgId));
536
556
  }
537
557
 
538
- // ---- Agent Runs (org-scoped) ----
558
+ // ---- Agent Sessions (org-scoped) ----
539
559
 
540
- async createAgentRun(orgId: string, agentId: string, req: CreateAgentRunRequest): Promise<AgentRunDB> {
541
- return this.request('POST', ENDPOINTS.AGENT_RUNS(orgId, agentId), req);
560
+ async createAgentSession(orgId: string, agentId: string, req: CreateAgentSessionRequest): Promise<AgentSessionDB> {
561
+ return this.request('POST', ENDPOINTS.AGENT_SESSIONS(orgId, agentId), req);
542
562
  }
543
563
 
544
- async getAgentRuns(orgId: string, agentId: string, params?: { limit?: number }): Promise<AgentRunDB[]> {
545
- const res = await this.request<{ data: AgentRunDB[] }>('GET', ENDPOINTS.AGENT_RUNS(orgId, agentId), undefined, params);
564
+ async getAgentSessions(orgId: string, agentId: string, params?: { limit?: number; status?: string }): Promise<AgentSessionDB[]> {
565
+ const res = await this.request<{ data: AgentSessionDB[] }>('GET', ENDPOINTS.AGENT_SESSIONS(orgId, agentId), undefined, params);
546
566
  return res.data;
547
567
  }
548
568
 
549
- async getAgentRun(orgId: string, agentId: string, runId: string): Promise<AgentRunDB> {
550
- return this.request('GET', ENDPOINTS.AGENT_RUN(orgId, agentId, runId));
569
+ async getAgentSession(orgId: string, agentId: string, sessionId: string): Promise<AgentSessionDB> {
570
+ return this.request('GET', ENDPOINTS.AGENT_SESSION(orgId, agentId, sessionId));
551
571
  }
552
572
 
553
- async updateAgentRun(orgId: string, agentId: string, runId: string, req: UpdateAgentRunRequest): Promise<AgentRunDB> {
554
- return this.request('PATCH', ENDPOINTS.AGENT_RUN(orgId, agentId, runId), req);
573
+ async updateAgentSession(orgId: string, agentId: string, sessionId: string, req: UpdateAgentSessionRequest): Promise<AgentSessionDB> {
574
+ return this.request('PATCH', ENDPOINTS.AGENT_SESSION(orgId, agentId, sessionId), req);
555
575
  }
556
576
 
557
- async createAgentStep(orgId: string, agentId: string, runId: string, req: CreateAgentStepRequest): Promise<AgentStep> {
558
- return this.request('POST', ENDPOINTS.AGENT_RUN_STEPS(orgId, agentId, runId), req);
577
+ async createAgentStep(orgId: string, agentId: string, sessionId: string, req: CreateAgentStepRequest): Promise<AgentStep> {
578
+ return this.request('POST', ENDPOINTS.AGENT_SESSION_STEPS(orgId, agentId, sessionId), req);
559
579
  }
560
580
 
561
- async getAgentRunSteps(orgId: string, agentId: string, runId: string, params?: { limit?: number }): Promise<AgentStep[]> {
562
- const res = await this.request<{ data: AgentStep[] }>('GET', ENDPOINTS.AGENT_RUN_STEPS(orgId, agentId, runId), undefined, params);
581
+ async getAgentSessionSteps(orgId: string, agentId: string, sessionId: string, params?: { limit?: number }): Promise<AgentStep[]> {
582
+ const res = await this.request<{ data: AgentStep[] }>('GET', ENDPOINTS.AGENT_SESSION_STEPS(orgId, agentId, sessionId), undefined, params);
563
583
  return res.data;
564
584
  }
565
585
 
@@ -702,15 +722,11 @@ export class PondClient {
702
722
  */
703
723
  async getPlatformConfig(currentVersion?: string): Promise<PlatformConfigResponse | null> {
704
724
  const url = `${this.baseUrl}${ENDPOINTS.PLATFORM_CONFIG}`;
705
- const headers: Record<string, string> = {
706
- 'Content-Type': 'application/json',
707
- };
708
- if (this.token) {
709
- headers['Authorization'] = `Bearer ${this.token}`;
710
- }
725
+ const extra: Record<string, string> = {};
711
726
  if (currentVersion !== undefined) {
712
- headers['If-None-Match'] = currentVersion;
727
+ extra['If-None-Match'] = currentVersion;
713
728
  }
729
+ const headers = this.buildHeaders(extra);
714
730
 
715
731
  const res = await fetch(url, {
716
732
  method: 'GET',
@@ -863,6 +879,22 @@ export class PondClient {
863
879
  return this.request('GET', ENDPOINTS.WIKI_NODE_SECTIONS(orgId, wikiId), undefined, params);
864
880
  }
865
881
 
882
+ async searchWiki(orgId: string, wikiId: string, params: { q: string; limit?: number; path_prefix?: string; ref?: string }): Promise<WikiSearchResponse> {
883
+ return this.request('GET', ENDPOINTS.WIKI_SEARCH(orgId, wikiId), undefined, params);
884
+ }
885
+
886
+ async getWikiPageIndex(orgId: string, wikiId: string, params?: { ref?: string }): Promise<WikiPageIndex> {
887
+ return this.request('GET', ENDPOINTS.WIKI_PAGE_INDEX(orgId, wikiId), undefined, params);
888
+ }
889
+
890
+ async getWikiRefs(orgId: string, wikiId: string, params?: { ref?: string }): Promise<WikiRefsResponse> {
891
+ return this.request('GET', ENDPOINTS.WIKI_REFS(orgId, wikiId), undefined, params);
892
+ }
893
+
894
+ async checkWikiRefs(orgId: string, wikiId: string, params?: { ref?: string }): Promise<WikiRefsCheckResponse> {
895
+ return this.request('GET', ENDPOINTS.WIKI_REFS_CHECK(orgId, wikiId), undefined, params);
896
+ }
897
+
866
898
  async createWikiChangeset(orgId: string, wikiId: string, data: CreateWikiChangesetRequest): Promise<WikiChangeset> {
867
899
  return normalizeWikiChangeset(await this.request('POST', ENDPOINTS.WIKI_CHANGESETS(orgId, wikiId), data));
868
900
  }
@@ -982,6 +1014,30 @@ export class PondClient {
982
1014
  async checkBrokenRefs(orgId: string): Promise<BrokenRefsResponse> {
983
1015
  return this.request('GET', ENDPOINTS.REFS_CHECK(orgId));
984
1016
  }
1017
+
1018
+ // ---- Push Notifications ----
1019
+
1020
+ async subscribePush(body: PushSubscribeRequest): Promise<void> {
1021
+ return this.request('POST', ENDPOINTS.PUSH_SUBSCRIBE, body);
1022
+ }
1023
+
1024
+ async unsubscribePush(token: string): Promise<void> {
1025
+ return this.request('DELETE', ENDPOINTS.PUSH_UNSUBSCRIBE, { token });
1026
+ }
1027
+
1028
+ async getVapidKey(): Promise<{ vapid_public_key: string }> {
1029
+ return this.request('GET', ENDPOINTS.PUSH_VAPID_KEY);
1030
+ }
1031
+
1032
+ // ---- Notification Preferences ----
1033
+
1034
+ async getNotificationPreferences(): Promise<NotificationPreferences> {
1035
+ return this.request('GET', ENDPOINTS.NOTIFICATION_PREFERENCES);
1036
+ }
1037
+
1038
+ async updateNotificationPreferences(prefs: Partial<NotifPrefs>): Promise<NotificationPreferences> {
1039
+ return this.request('PATCH', ENDPOINTS.NOTIFICATION_PREFERENCES, { prefs });
1040
+ }
985
1041
  }
986
1042
 
987
1043
  function normalizeWikiChangeset(changeset: WikiChangeset): WikiChangeset {
package/src/constants.ts CHANGED
@@ -70,12 +70,12 @@ export const ENDPOINTS = {
70
70
  `${API_BASE}/orgs/${orgId}/agents/${agentId}/monitor`,
71
71
  AGENT_ME: (orgId: string) =>
72
72
  `${API_BASE}/orgs/${orgId}/agents/me`,
73
- AGENT_RUNS: (orgId: string, agentId: string) =>
74
- `${API_BASE}/orgs/${orgId}/agents/${agentId}/runs`,
75
- AGENT_RUN: (orgId: string, agentId: string, runId: string) =>
76
- `${API_BASE}/orgs/${orgId}/agents/${agentId}/runs/${runId}`,
77
- AGENT_RUN_STEPS: (orgId: string, agentId: string, runId: string) =>
78
- `${API_BASE}/orgs/${orgId}/agents/${agentId}/runs/${runId}/steps`,
73
+ AGENT_SESSIONS: (orgId: string, agentId: string) =>
74
+ `${API_BASE}/orgs/${orgId}/agents/${agentId}/sessions`,
75
+ AGENT_SESSION: (orgId: string, agentId: string, sessionId: string) =>
76
+ `${API_BASE}/orgs/${orgId}/agents/${agentId}/sessions/${sessionId}`,
77
+ AGENT_SESSION_STEPS: (orgId: string, agentId: string, sessionId: string) =>
78
+ `${API_BASE}/orgs/${orgId}/agents/${agentId}/sessions/${sessionId}/steps`,
79
79
  AGENT_TASKS: (orgId: string, agentId: string) =>
80
80
  `${API_BASE}/orgs/${orgId}/agents/${agentId}/tasks`,
81
81
  // Machines (org-scoped)
@@ -135,6 +135,10 @@ export const ENDPOINTS = {
135
135
  WIKI_TREE: (orgId: string, wikiId: string) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/tree`,
136
136
  WIKI_BLOB: (orgId: string, wikiId: string) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/blob`,
137
137
  WIKI_NODE_SECTIONS: (orgId: string, wikiId: string) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/node-sections`,
138
+ WIKI_SEARCH: (orgId: string, wikiId: string) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/search`,
139
+ WIKI_PAGE_INDEX: (orgId: string, wikiId: string) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/page-index`,
140
+ WIKI_REFS: (orgId: string, wikiId: string) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/refs`,
141
+ WIKI_REFS_CHECK: (orgId: string, wikiId: string) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/refs/check`,
138
142
  WIKI_CHANGESETS: (orgId: string, wikiId: string) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/changesets`,
139
143
  WIKI_CHANGESET: (orgId: string, wikiId: string, changesetId: string) =>
140
144
  `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/changesets/${changesetId}`,
@@ -199,6 +203,14 @@ export const ENDPOINTS = {
199
203
  // Platform config (agent-scoped, not org-scoped)
200
204
  PLATFORM_CONFIG: `${API_BASE}/agents/platform-config`,
201
205
 
206
+ // Push notifications
207
+ PUSH_SUBSCRIBE: `${API_BASE}/push/subscribe`,
208
+ PUSH_UNSUBSCRIBE: `${API_BASE}/push/unsubscribe`,
209
+ PUSH_VAPID_KEY: `${API_BASE}/push/vapid-key`,
210
+
211
+ // Notification preferences
212
+ NOTIFICATION_PREFERENCES: `${API_BASE}/notification-preferences`,
213
+
202
214
  } as const;
203
215
 
204
216
  // WebSocket event types
@@ -206,8 +218,6 @@ export const WS_EVENTS = {
206
218
  // Client -> Server
207
219
  PING: 'ping',
208
220
  TYPING: 'typing',
209
- ACK: 'ack',
210
- READ: 'read',
211
221
  WATCH: 'watch',
212
222
  AGENT_HEARTBEAT: 'agent.heartbeat',
213
223
 
@@ -234,8 +244,8 @@ export const WS_EVENTS = {
234
244
  PROJECT_CREATED: 'project.created',
235
245
  PROJECT_UPDATED: 'project.updated',
236
246
  PROJECT_DELETED: 'project.deleted',
237
- AGENT_RUN_NEW: 'agent_run.new',
238
- AGENT_RUN_UPDATE: 'agent_run.update',
247
+ AGENT_SESSION_NEW: 'agent_session.new',
248
+ AGENT_SESSION_UPDATE: 'agent_session.update',
239
249
  AGENT_STEP_NEW: 'agent_step.new',
240
250
  INVITATION_NEW: 'invitation.new',
241
251
  INVITATION_ACCEPTED: 'invitation.accepted',
@@ -247,5 +257,6 @@ export const WS_EVENTS = {
247
257
  INBOX_NEW: 'inbox.new',
248
258
  INBOX_UPDATE: 'inbox.update',
249
259
  INBOX_BULK_UPDATE: 'inbox.bulk_update',
260
+ READ_POSITION_UPDATED: 'read_position.updated',
250
261
  DISPATCH_NEW: 'dispatch.new',
251
262
  } as const;
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
 
@@ -475,6 +488,8 @@ export interface PresignUploadRequest {
475
488
  export interface FileUrlResponse {
476
489
  url: string;
477
490
  expires_in: number;
491
+ width?: number;
492
+ height?: number;
478
493
  }
479
494
 
480
495
  // ============================================================
@@ -483,7 +498,7 @@ export interface FileUrlResponse {
483
498
 
484
499
  export type TaskStatus = 'todo' | 'in_progress' | 'in_review' | 'done' | 'canceled';
485
500
  export type TaskPriority = 'high' | 'normal' | 'low';
486
- export type TaskRelationTargetType = 'task' | 'message' | 'chat' | 'agent_run';
501
+ export type TaskRelationTargetType = 'task' | 'message' | 'chat' | 'agent_session';
487
502
  export type TaskRelationType = 'blocks' | 'related' | 'duplicate' | 'source' | 'reference' | 'discussion' | 'execution';
488
503
 
489
504
  export interface Task {
@@ -698,6 +713,82 @@ export interface WikiNodeSectionArtifact {
698
713
  nodes: WikiNodeSection[];
699
714
  }
700
715
 
716
+ export interface WikiSearchResult {
717
+ wiki_id: string;
718
+ wiki_slug: string;
719
+ wiki_name: string;
720
+ node_id: string;
721
+ path: string;
722
+ title: string;
723
+ heading_path?: string[];
724
+ section_path: string;
725
+ level: number;
726
+ start_line: number;
727
+ end_line: number;
728
+ score: number;
729
+ snippet: string;
730
+ }
731
+
732
+ export interface WikiSearchResponse {
733
+ wiki_id: string;
734
+ wiki_slug: string;
735
+ wiki_name: string;
736
+ query: string;
737
+ ref: string;
738
+ results: WikiSearchResult[];
739
+ }
740
+
741
+ export interface WikiPageIndexEntry {
742
+ path: string;
743
+ title: string;
744
+ top_headings: string[];
745
+ size_bytes: number;
746
+ section_count: number;
747
+ }
748
+
749
+ export interface WikiPageIndex {
750
+ wiki_id: string;
751
+ wiki_slug: string;
752
+ wiki_name: string;
753
+ ref: string;
754
+ generated_at: string;
755
+ page_count: number;
756
+ pages: WikiPageIndexEntry[];
757
+ }
758
+
759
+ export interface WikiFileRef {
760
+ source_path: string;
761
+ uri: string;
762
+ context?: string;
763
+ prefix: string;
764
+ entity_id: string;
765
+ target_path?: string;
766
+ fragment?: string;
767
+ line: number;
768
+ }
769
+
770
+ export interface WikiRefsResponse {
771
+ wiki_id: string;
772
+ wiki_slug: string;
773
+ wiki_name: string;
774
+ ref: string;
775
+ total: number;
776
+ refs: WikiFileRef[];
777
+ }
778
+
779
+ export interface WikiBrokenRef extends WikiFileRef {
780
+ reason: string;
781
+ }
782
+
783
+ export interface WikiRefsCheckResponse {
784
+ wiki_id: string;
785
+ wiki_slug: string;
786
+ wiki_name: string;
787
+ ref: string;
788
+ total: number;
789
+ broken: WikiBrokenRef[];
790
+ }
791
+
701
792
  export interface WikiDiffFile {
702
793
  path: string;
703
794
  action?: string; // "create" | "update" | "delete"
@@ -858,7 +949,7 @@ export interface MessageNewData {
858
949
  edited_at?: string | null;
859
950
  deleted_at?: string | null;
860
951
  idempotency_key?: string | null;
861
- agent_run_id?: string | null;
952
+ agent_step_id?: string | null;
862
953
  hints?: MessageHints | null;
863
954
  }
864
955
 
@@ -932,7 +1023,7 @@ export interface TaskComment {
932
1023
  author_id: string;
933
1024
  body: string;
934
1025
  mentions?: Mention[];
935
- agent_run_id?: string | null;
1026
+ agent_step_id?: string | null;
936
1027
  created_at: string;
937
1028
  updated_at: string;
938
1029
  author?: User;
@@ -984,17 +1075,16 @@ export interface ProjectDeletedData {
984
1075
  org_id: string;
985
1076
  }
986
1077
 
987
- // ---- Agent Run / Step ----
1078
+ // ---- Agent Session / Step ----
988
1079
 
989
- export interface AgentRunDB {
1080
+ export interface AgentSessionDB {
990
1081
  id: string;
991
1082
  agent_id: string;
992
1083
  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;
1084
+ status: string; // active | completed | failed | cancelled
1085
+ runtime_type: string;
1086
+ runtime_key: string | null;
1087
+ runtime_ref: Record<string, unknown> | null;
998
1088
  started_at: string;
999
1089
  finished_at: string | null;
1000
1090
  created_at: string;
@@ -1002,47 +1092,48 @@ export interface AgentRunDB {
1002
1092
 
1003
1093
  export interface AgentStep {
1004
1094
  id: string;
1005
- run_id: string;
1095
+ session_id: string;
1006
1096
  step_type: string;
1097
+ target_type: string;
1098
+ target_id: string | null;
1007
1099
  content: Record<string, unknown>;
1100
+ group_key: string | null;
1101
+ runtime_key: string | null;
1008
1102
  idempotency_key?: string;
1009
1103
  created_at: string;
1010
1104
  }
1011
1105
 
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;
1106
+ export interface CreateAgentSessionRequest {
1107
+ runtime_type?: string;
1108
+ runtime_key?: string;
1109
+ runtime_ref?: Record<string, unknown>;
1018
1110
  }
1019
1111
 
1020
1112
  export interface CreateAgentStepRequest {
1021
1113
  step_type: string;
1022
1114
  content: Record<string, unknown>;
1115
+ target_type?: string;
1116
+ target_id?: string;
1117
+ group_key?: string;
1118
+ runtime_key?: string;
1023
1119
  idempotency_key?: string;
1024
- projection?: boolean;
1025
- chat_projection?: boolean; // backward compat alias for projection
1120
+ projection?: boolean; // project text steps to chat message or task comment (controlled by agent's run_config)
1026
1121
  }
1027
1122
 
1028
- export interface UpdateAgentRunRequest {
1123
+ export interface UpdateAgentSessionRequest {
1029
1124
  status: string;
1030
- emit_fallback_message?: boolean;
1031
1125
  }
1032
1126
 
1033
- // Agent run WS event data
1034
- export type AgentRunNewData = AgentRunDB;
1127
+ // Agent session WS event data
1128
+ export type AgentSessionNewData = AgentSessionDB;
1035
1129
 
1036
- export interface AgentRunUpdateData {
1037
- run_id: string;
1130
+ export interface AgentSessionUpdateData {
1131
+ session_id: string;
1038
1132
  status: string;
1039
1133
  finished_at?: string;
1040
1134
  }
1041
1135
 
1042
- export interface AgentStepNewData extends AgentStep {
1043
- target_type?: string;
1044
- target_id?: string;
1045
- }
1136
+ export interface AgentStepNewData extends AgentStep {}
1046
1137
 
1047
1138
  export type WikiChangesetCreatedData = WikiChangeset & { org_id: string };
1048
1139
  export type WikiChangesetUpdatedData = WikiChangeset & { org_id: string };
@@ -1119,6 +1210,11 @@ export interface InboxUnreadCountResponse {
1119
1210
  count: number;
1120
1211
  }
1121
1212
 
1213
+ export interface ReadPositionUpdateData {
1214
+ chat_id: string;
1215
+ last_read_message_id: string;
1216
+ }
1217
+
1122
1218
  export type WsEventMap = {
1123
1219
  'hello': HelloData;
1124
1220
  'message.new': MessageNewData;
@@ -1144,8 +1240,8 @@ export type WsEventMap = {
1144
1240
  'project.created': ProjectCreatedData;
1145
1241
  'project.updated': ProjectUpdatedData;
1146
1242
  'project.deleted': ProjectDeletedData;
1147
- 'agent_run.new': AgentRunNewData;
1148
- 'agent_run.update': AgentRunUpdateData;
1243
+ 'agent_session.new': AgentSessionNewData;
1244
+ 'agent_session.update': AgentSessionUpdateData;
1149
1245
  'agent_step.new': AgentStepNewData;
1150
1246
  'invitation.new': InvitationNewEventData;
1151
1247
  'invitation.accepted': InvitationAcceptedEventData;
@@ -1157,6 +1253,7 @@ export type WsEventMap = {
1157
1253
  'inbox.new': InboxNewData;
1158
1254
  'inbox.update': InboxUpdateData;
1159
1255
  'inbox.bulk_update': InboxBulkUpdateData;
1256
+ 'read_position.updated': ReadPositionUpdateData;
1160
1257
  'dispatch.new': DispatchNewData;
1161
1258
  };
1162
1259
 
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({