@parall/sdk 1.30.0 → 1.32.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/client.ts CHANGED
@@ -52,6 +52,7 @@ import type {
52
52
  TaskRelation,
53
53
  TaskRelationTargetType,
54
54
  TaskWatcher,
55
+ RefSearchResponse,
55
56
  ThreadWatcher,
56
57
  CreateTaskRelationRequest,
57
58
  TaskComment,
@@ -75,6 +76,9 @@ import type {
75
76
  NewSessionResponse,
76
77
  OrgInvitation,
77
78
  InvitationPublicInfo,
79
+ OrgInviteLink,
80
+ JoinByLinkResponse,
81
+ OrgJoinRequest,
78
82
  PlatformConfigResponse,
79
83
  Wiki,
80
84
  WikiBlob,
@@ -126,6 +130,7 @@ import type {
126
130
  TransferChatOwnershipRequest,
127
131
  UpdateChatMemberRequest,
128
132
  UnreadEntry,
133
+ ThreadUnreadEntry,
129
134
  BillingSummary,
130
135
  CreditTransaction,
131
136
  CreditTransactionAgentGroup,
@@ -137,6 +142,16 @@ import type {
137
142
  UpdateAutoReloadRequest,
138
143
  ComputePricing,
139
144
  ComputePricingResponse,
145
+ Clip,
146
+ AgentClip,
147
+ CreateClipRequest,
148
+ UpdateClipRequest,
149
+ BindAgentClipRequest,
150
+ InvokeClipRequest,
151
+ InvokeClipResponse,
152
+ OnlineClipInfo,
153
+ RegistryClipInfo,
154
+ MachineClipInstall,
140
155
  } from './types.js';
141
156
 
142
157
  export interface ParallClientOptions {
@@ -159,16 +174,26 @@ export class ParallClient {
159
174
 
160
175
  /** Auth endpoints excluded from automatic 401 refresh to prevent recursion. */
161
176
  private static readonly AUTH_PATHS = new Set([
162
- '/auth/login', '/auth/register', '/auth/refresh', '/auth/logout',
163
- '/auth/verify-email', '/auth/resend-code', '/auth/check-email',
164
- '/auth/forgot-password', '/auth/reset-password',
177
+ '/auth/login',
178
+ '/auth/register',
179
+ '/auth/refresh',
180
+ '/auth/logout',
181
+ '/auth/verify-email',
182
+ '/auth/resend-code',
183
+ '/auth/check-email',
184
+ '/auth/forgot-password',
185
+ '/auth/reset-password',
165
186
  ]);
166
187
 
167
188
  /** Proactive refresh when token expires within this window (seconds). */
168
189
  private static readonly REFRESH_THRESHOLD_S = 5 * 60;
169
190
 
170
191
  private static normalizeFetchError(err: unknown): ApiError {
171
- if (typeof DOMException !== 'undefined' && err instanceof DOMException && (err.name === 'TimeoutError' || err.name === 'AbortError')) {
192
+ if (
193
+ typeof DOMException !== 'undefined' &&
194
+ err instanceof DOMException &&
195
+ (err.name === 'TimeoutError' || err.name === 'AbortError')
196
+ ) {
172
197
  // The SDK only creates internal timeout signals today. If caller-owned
173
198
  // cancellation is added later, AbortError should get its own code.
174
199
  return new ApiError(0, 'Request timed out', 'REQUEST_TIMEOUT');
@@ -328,10 +353,18 @@ export class ParallClient {
328
353
 
329
354
  if (!res.ok) {
330
355
  const rawErrorBody = await res.json().catch(() => ({}));
331
- const errorBody = rawErrorBody !== null && typeof rawErrorBody === 'object' ? rawErrorBody as Record<string, unknown> : {};
332
- const errorObj = errorBody?.error && typeof errorBody.error === 'object' ? errorBody.error as { message?: string; code?: string } : undefined;
333
- const errMsg = errorObj?.message ?? (typeof errorBody?.error === 'string' ? errorBody.error : undefined);
334
- const errCode = errorObj?.code ?? (typeof errorBody?.code === 'string' ? errorBody.code : undefined);
356
+ const errorBody =
357
+ rawErrorBody !== null && typeof rawErrorBody === 'object'
358
+ ? (rawErrorBody as Record<string, unknown>)
359
+ : {};
360
+ const errorObj =
361
+ errorBody?.error && typeof errorBody.error === 'object'
362
+ ? (errorBody.error as { message?: string; code?: string })
363
+ : undefined;
364
+ const errMsg =
365
+ errorObj?.message ?? (typeof errorBody?.error === 'string' ? errorBody.error : undefined);
366
+ const errCode =
367
+ errorObj?.code ?? (typeof errorBody?.code === 'string' ? errorBody.code : undefined);
335
368
  const apiError = new ApiError(res.status, errMsg ?? res.statusText, errCode);
336
369
  const { error: _e, code: _c, message: _m, ...extras } = errorBody;
337
370
  if (Object.keys(extras).length > 0) apiError.extras = extras;
@@ -397,10 +430,18 @@ export class ParallClient {
397
430
 
398
431
  if (!res.ok) {
399
432
  const rawErrorBody = await res.json().catch(() => ({}));
400
- const errorBody = rawErrorBody !== null && typeof rawErrorBody === 'object' ? rawErrorBody as Record<string, unknown> : {};
401
- const errorObj = errorBody?.error && typeof errorBody.error === 'object' ? errorBody.error as { message?: string; code?: string } : undefined;
402
- const errMsg = errorObj?.message ?? (typeof errorBody?.error === 'string' ? errorBody.error : undefined);
403
- const errCode = errorObj?.code ?? (typeof errorBody?.code === 'string' ? errorBody.code : undefined);
433
+ const errorBody =
434
+ rawErrorBody !== null && typeof rawErrorBody === 'object'
435
+ ? (rawErrorBody as Record<string, unknown>)
436
+ : {};
437
+ const errorObj =
438
+ errorBody?.error && typeof errorBody.error === 'object'
439
+ ? (errorBody.error as { message?: string; code?: string })
440
+ : undefined;
441
+ const errMsg =
442
+ errorObj?.message ?? (typeof errorBody?.error === 'string' ? errorBody.error : undefined);
443
+ const errCode =
444
+ errorObj?.code ?? (typeof errorBody?.code === 'string' ? errorBody.code : undefined);
404
445
  const apiError = new ApiError(res.status, errMsg ?? res.statusText, errCode);
405
446
  const { error: _e, code: _c, message: _m, ...extras } = errorBody;
406
447
  if (Object.keys(extras).length > 0) apiError.extras = extras;
@@ -450,7 +491,10 @@ export class ParallClient {
450
491
  }
451
492
 
452
493
  async resetPassword(token: string, newPassword: string): Promise<AuthTokens> {
453
- return this.request('POST', ENDPOINTS.AUTH_RESET_PASSWORD, { token, new_password: newPassword });
494
+ return this.request('POST', ENDPOINTS.AUTH_RESET_PASSWORD, {
495
+ token,
496
+ new_password: newPassword,
497
+ });
454
498
  }
455
499
 
456
500
  // ---- WebSocket ----
@@ -483,7 +527,11 @@ export class ParallClient {
483
527
  return this.request('DELETE', ENDPOINTS.USER_AVATAR);
484
528
  }
485
529
 
486
- async uploadAgentAvatar(orgId: string, agentId: string, file: File | Blob): Promise<AvatarUploadResponse> {
530
+ async uploadAgentAvatar(
531
+ orgId: string,
532
+ agentId: string,
533
+ file: File | Blob,
534
+ ): Promise<AvatarUploadResponse> {
487
535
  const fd = new FormData();
488
536
  fd.append('file', file);
489
537
  return this.multipartRequest('POST', ENDPOINTS.AGENT_AVATAR(orgId, agentId), fd);
@@ -497,10 +545,13 @@ export class ParallClient {
497
545
  return this.request('GET', ENDPOINTS.USER(id));
498
546
  }
499
547
 
500
-
501
548
  // ---- Organizations ----
502
549
 
503
- async createOrg(data: { name: string; invite_code: string; avatar_url?: string }): Promise<Organization> {
550
+ async createOrg(data: {
551
+ name: string;
552
+ invite_code: string;
553
+ avatar_url?: string;
554
+ }): Promise<Organization> {
504
555
  return this.request('POST', ENDPOINTS.ORGS, data);
505
556
  }
506
557
 
@@ -520,7 +571,12 @@ export class ParallClient {
520
571
  */
521
572
  async updateOrg(
522
573
  orgId: string,
523
- data: Partial<Pick<Organization, 'name' | 'avatar_url' | 'smart_routing_strategy' | 'smart_routing_agent_id'>>,
574
+ data: Partial<
575
+ Pick<
576
+ Organization,
577
+ 'name' | 'avatar_url' | 'smart_routing_strategy' | 'smart_routing_agent_id'
578
+ >
579
+ >,
524
580
  ): Promise<Organization> {
525
581
  return this.request('PATCH', ENDPOINTS.ORG(orgId), data);
526
582
  }
@@ -535,10 +591,20 @@ export class ParallClient {
535
591
  }
536
592
 
537
593
  async getOnlineMembers(orgId: string): Promise<string[]> {
538
- const res = await this.request<{ user_ids: string[] }>('GET', ENDPOINTS.ORG_MEMBERS_ONLINE(orgId));
594
+ const res = await this.request<{ user_ids: string[] }>(
595
+ 'GET',
596
+ ENDPOINTS.ORG_MEMBERS_ONLINE(orgId),
597
+ );
539
598
  return res.user_ids ?? [];
540
599
  }
541
600
 
601
+ async searchRefs(
602
+ orgId: string,
603
+ params?: { q?: string; limit_per_type?: number },
604
+ ): Promise<RefSearchResponse> {
605
+ return this.request('GET', ENDPOINTS.REF_SEARCH(orgId), undefined, params);
606
+ }
607
+
542
608
  async removeOrgMember(orgId: string, userId: string): Promise<void> {
543
609
  return this.request('DELETE', ENDPOINTS.ORG_MEMBER(orgId, userId));
544
610
  }
@@ -585,12 +651,19 @@ export class ParallClient {
585
651
 
586
652
  // ---- Invitations ----
587
653
 
588
- async createInvitation(orgId: string, email: string, role?: OrgMemberRole): Promise<OrgInvitation> {
654
+ async createInvitation(
655
+ orgId: string,
656
+ email: string,
657
+ role?: OrgMemberRole,
658
+ ): Promise<OrgInvitation> {
589
659
  return this.request('POST', ENDPOINTS.ORG_INVITATIONS(orgId), { email, role });
590
660
  }
591
661
 
592
662
  async getOrgInvitations(orgId: string): Promise<OrgInvitation[]> {
593
- const res = await this.request<{ data: OrgInvitation[] }>('GET', ENDPOINTS.ORG_INVITATIONS(orgId));
663
+ const res = await this.request<{ data: OrgInvitation[] }>(
664
+ 'GET',
665
+ ENDPOINTS.ORG_INVITATIONS(orgId),
666
+ );
594
667
  return res.data;
595
668
  }
596
669
 
@@ -619,9 +692,59 @@ export class ParallClient {
619
692
  return this.request('GET', ENDPOINTS.INVITATION_BY_TOKEN(token));
620
693
  }
621
694
 
695
+ // ---- Org-level shareable invite link ----
696
+
697
+ /** Fetch the org's current invite link. Auto-creates on first call
698
+ * so the settings UI never sees an empty state. */
699
+ async getOrgInviteLink(orgId: string): Promise<OrgInviteLink> {
700
+ return this.request('GET', ENDPOINTS.ORG_INVITE_LINK(orgId));
701
+ }
702
+
703
+ /** Rotate the token in place. The old token stops resolving immediately. */
704
+ async regenerateOrgInviteLink(orgId: string): Promise<OrgInviteLink> {
705
+ return this.request('POST', ENDPOINTS.ORG_INVITE_LINK_REGENERATE(orgId));
706
+ }
707
+
708
+ /** Toggle the require-approval flag on the org's invite link. */
709
+ async updateOrgInviteLink(
710
+ orgId: string,
711
+ data: { require_approval: boolean },
712
+ ): Promise<OrgInviteLink> {
713
+ return this.request('PATCH', ENDPOINTS.ORG_INVITE_LINK(orgId), data);
714
+ }
715
+
716
+ /** Redeem an invite-link token. Caller must be authenticated; the
717
+ * token is the lookup key so this endpoint is NOT org-scoped. */
718
+ async joinByInviteLink(token: string): Promise<JoinByLinkResponse> {
719
+ return this.request('POST', ENDPOINTS.INVITE_LINK_JOIN, { token });
720
+ }
721
+
722
+ /** Admin: list pending invite-link join requests for an org. */
723
+ async listOrgJoinRequests(orgId: string): Promise<OrgJoinRequest[]> {
724
+ const res = await this.request<{ data: OrgJoinRequest[] }>(
725
+ 'GET',
726
+ ENDPOINTS.ORG_INVITE_LINK_JOIN_REQUESTS(orgId),
727
+ );
728
+ return res.data;
729
+ }
730
+
731
+ /** Admin: approve or reject a pending invite-link join request. */
732
+ async decideOrgJoinRequest(
733
+ orgId: string,
734
+ jrId: string,
735
+ decision: 'approve' | 'reject',
736
+ ): Promise<OrgJoinRequest> {
737
+ return this.request('POST', ENDPOINTS.ORG_INVITE_LINK_JOIN_REQUEST_DECIDE(orgId, jrId), {
738
+ decision,
739
+ });
740
+ }
741
+
622
742
  // ---- Direct Messages (org-scoped) ----
623
743
 
624
- async sendDirectMessage(orgId: string, req: SendDirectMessageRequest): Promise<DirectMessageResponse> {
744
+ async sendDirectMessage(
745
+ orgId: string,
746
+ req: SendDirectMessageRequest,
747
+ ): Promise<DirectMessageResponse> {
625
748
  return this.request('POST', ENDPOINTS.DM(orgId), req);
626
749
  }
627
750
 
@@ -655,7 +778,22 @@ export class ParallClient {
655
778
  return this.request('GET', ENDPOINTS.CHAT(orgId, chatId));
656
779
  }
657
780
 
658
- async updateChat(orgId: string, chatId: string, data: Partial<Pick<Chat, 'name' | 'avatar_url' | 'description' | 'visibility' | 'agent_routing_mode' | 'smart_routing_strategy' | 'smart_routing_agent_id'>>): Promise<Chat> {
781
+ async updateChat(
782
+ orgId: string,
783
+ chatId: string,
784
+ data: Partial<
785
+ Pick<
786
+ Chat,
787
+ | 'name'
788
+ | 'avatar_url'
789
+ | 'description'
790
+ | 'visibility'
791
+ | 'agent_routing_mode'
792
+ | 'smart_routing_strategy'
793
+ | 'smart_routing_agent_id'
794
+ >
795
+ >,
796
+ ): Promise<Chat> {
659
797
  return this.request('PATCH', ENDPOINTS.CHAT(orgId, chatId), data);
660
798
  }
661
799
 
@@ -677,7 +815,12 @@ export class ParallClient {
677
815
  }
678
816
 
679
817
  async deleteChat(orgId: string, chatId: string, opts?: { force?: boolean }): Promise<void> {
680
- return this.request('DELETE', ENDPOINTS.CHAT(orgId, chatId), undefined, opts?.force ? { force: 'true' } : undefined);
818
+ return this.request(
819
+ 'DELETE',
820
+ ENDPOINTS.CHAT(orgId, chatId),
821
+ undefined,
822
+ opts?.force ? { force: 'true' } : undefined,
823
+ );
681
824
  }
682
825
 
683
826
  async archiveChat(orgId: string, chatId: string): Promise<void> {
@@ -691,7 +834,10 @@ export class ParallClient {
691
834
  // ---- Chat Members ----
692
835
 
693
836
  async getChatMembers(orgId: string, chatId: string): Promise<ChatMember[]> {
694
- const res = await this.request<{ data: ChatMember[] }>('GET', ENDPOINTS.CHAT_MEMBERS(orgId, chatId));
837
+ const res = await this.request<{ data: ChatMember[] }>(
838
+ 'GET',
839
+ ENDPOINTS.CHAT_MEMBERS(orgId, chatId),
840
+ );
695
841
  return res.data;
696
842
  }
697
843
 
@@ -703,15 +849,29 @@ export class ParallClient {
703
849
  return this.request('DELETE', ENDPOINTS.CHAT_MEMBER(orgId, chatId, userId));
704
850
  }
705
851
 
706
- async updateChatMemberRole(orgId: string, chatId: string, userId: string, role: ChatMemberRole): Promise<void> {
852
+ async updateChatMemberRole(
853
+ orgId: string,
854
+ chatId: string,
855
+ userId: string,
856
+ role: ChatMemberRole,
857
+ ): Promise<void> {
707
858
  return this.request('PATCH', ENDPOINTS.CHAT_MEMBER(orgId, chatId, userId), { role });
708
859
  }
709
860
 
710
- async updateChatMember(orgId: string, chatId: string, userId: string, req: UpdateChatMemberRequest): Promise<ChatMember> {
861
+ async updateChatMember(
862
+ orgId: string,
863
+ chatId: string,
864
+ userId: string,
865
+ req: UpdateChatMemberRequest,
866
+ ): Promise<ChatMember> {
711
867
  return this.request('PATCH', ENDPOINTS.CHAT_MEMBER(orgId, chatId, userId), req);
712
868
  }
713
869
 
714
- async transferChatOwnership(orgId: string, chatId: string, req: TransferChatOwnershipRequest): Promise<void> {
870
+ async transferChatOwnership(
871
+ orgId: string,
872
+ chatId: string,
873
+ req: TransferChatOwnershipRequest,
874
+ ): Promise<void> {
715
875
  return this.request('POST', ENDPOINTS.CHAT_TRANSFER_OWNERSHIP(orgId, chatId), req);
716
876
  }
717
877
 
@@ -732,7 +892,12 @@ export class ParallClient {
732
892
  top_level?: boolean;
733
893
  },
734
894
  ): Promise<PaginatedResponse<Message>> {
735
- return this.request('GET', ENDPOINTS.CHAT_MESSAGES(orgId, chatId), undefined, params as Record<string, string | number | boolean | undefined>);
895
+ return this.request(
896
+ 'GET',
897
+ ENDPOINTS.CHAT_MESSAGES(orgId, chatId),
898
+ undefined,
899
+ params as Record<string, string | number | boolean | undefined>,
900
+ );
736
901
  }
737
902
 
738
903
  async getMessage(id: string): Promise<Message> {
@@ -765,7 +930,12 @@ export class ParallClient {
765
930
  }
766
931
 
767
932
  async getFileUrl(id: string, opts?: { download?: boolean }): Promise<FileUrlResponse> {
768
- return this.request('GET', ENDPOINTS.FILE(id), undefined, opts?.download ? { download: true } : undefined);
933
+ return this.request(
934
+ 'GET',
935
+ ENDPOINTS.FILE(id),
936
+ undefined,
937
+ opts?.download ? { download: true } : undefined,
938
+ );
769
939
  }
770
940
 
771
941
  // ---- Approvals ----
@@ -798,7 +968,11 @@ export class ParallClient {
798
968
 
799
969
  // ---- Agents (org-scoped) ----
800
970
 
801
- async createAgent(orgId: string, req: CreateAgentRequest, opts?: { timeoutMs?: number }): Promise<CreateAgentResponse> {
971
+ async createAgent(
972
+ orgId: string,
973
+ req: CreateAgentRequest,
974
+ opts?: { timeoutMs?: number },
975
+ ): Promise<CreateAgentResponse> {
802
976
  return this.request('POST', ENDPOINTS.AGENTS(orgId), req, undefined, false, opts);
803
977
  }
804
978
 
@@ -817,10 +991,7 @@ export class ParallClient {
817
991
  * topology metadata (base URL → provider / tenant) to non-admins,
818
992
  * so this dedicated endpoint is the only read path.
819
993
  */
820
- async getAgentProviderConfig(
821
- orgId: string,
822
- agentId: string,
823
- ): Promise<AgentProviderConfigRead> {
994
+ async getAgentProviderConfig(orgId: string, agentId: string): Promise<AgentProviderConfigRead> {
824
995
  return this.request('GET', ENDPOINTS.AGENT_PROVIDER_CONFIG(orgId, agentId));
825
996
  }
826
997
 
@@ -849,13 +1020,25 @@ export class ParallClient {
849
1020
  return this.request('DELETE', ENDPOINTS.AGENT_API_KEY(orgId, agentId, key));
850
1021
  }
851
1022
 
852
- async getAgentActivity(orgId: string, agentId: string, params?: { limit?: number }): Promise<Message[]> {
853
- const res = await this.request<{ data: Message[] }>('GET', ENDPOINTS.AGENT_ACTIVITY(orgId, agentId), undefined, params);
1023
+ async getAgentActivity(
1024
+ orgId: string,
1025
+ agentId: string,
1026
+ params?: { limit?: number },
1027
+ ): Promise<Message[]> {
1028
+ const res = await this.request<{ data: Message[] }>(
1029
+ 'GET',
1030
+ ENDPOINTS.AGENT_ACTIVITY(orgId, agentId),
1031
+ undefined,
1032
+ params,
1033
+ );
854
1034
  return res.data;
855
1035
  }
856
1036
 
857
1037
  async getAgentMonitor(orgId: string, agentId: string): Promise<unknown> {
858
- const res = await this.request<{ data: unknown }>('GET', ENDPOINTS.AGENT_MONITOR(orgId, agentId));
1038
+ const res = await this.request<{ data: unknown }>(
1039
+ 'GET',
1040
+ ENDPOINTS.AGENT_MONITOR(orgId, agentId),
1041
+ );
859
1042
  return res.data;
860
1043
  }
861
1044
 
@@ -871,7 +1054,11 @@ export class ParallClient {
871
1054
  return this.request('POST', ENDPOINTS.AGENT_NEW_SESSION(orgId, agentId));
872
1055
  }
873
1056
 
874
- async createAgentSession(orgId: string, agentId: string, req: CreateAgentSessionRequest): Promise<AgentSessionDB> {
1057
+ async createAgentSession(
1058
+ orgId: string,
1059
+ agentId: string,
1060
+ req: CreateAgentSessionRequest,
1061
+ ): Promise<AgentSessionDB> {
875
1062
  return this.request('POST', ENDPOINTS.AGENT_SESSIONS(orgId, agentId), req);
876
1063
  }
877
1064
 
@@ -879,27 +1066,60 @@ export class ParallClient {
879
1066
  * List agent sessions.
880
1067
  * @param params.status - Comma-separated status filter (e.g., `'open'`).
881
1068
  */
882
- async getAgentSessions(orgId: string, agentId: string, params?: { limit?: number; status?: string; cursor?: string }): Promise<PaginatedResponse<AgentSessionDB>> {
1069
+ async getAgentSessions(
1070
+ orgId: string,
1071
+ agentId: string,
1072
+ params?: { limit?: number; status?: string; cursor?: string },
1073
+ ): Promise<PaginatedResponse<AgentSessionDB>> {
883
1074
  return this.request('GET', ENDPOINTS.AGENT_SESSIONS(orgId, agentId), undefined, params);
884
1075
  }
885
1076
 
886
- async getAgentSession(orgId: string, agentId: string, sessionId: string): Promise<AgentSessionDB> {
1077
+ async getAgentSession(
1078
+ orgId: string,
1079
+ agentId: string,
1080
+ sessionId: string,
1081
+ ): Promise<AgentSessionDB> {
887
1082
  return this.request('GET', ENDPOINTS.AGENT_SESSION(orgId, agentId, sessionId));
888
1083
  }
889
1084
 
890
- async updateAgentSession(orgId: string, agentId: string, sessionId: string, req: UpdateAgentSessionRequest): Promise<AgentSessionDB> {
1085
+ async updateAgentSession(
1086
+ orgId: string,
1087
+ agentId: string,
1088
+ sessionId: string,
1089
+ req: UpdateAgentSessionRequest,
1090
+ ): Promise<AgentSessionDB> {
891
1091
  return this.request('PATCH', ENDPOINTS.AGENT_SESSION(orgId, agentId, sessionId), req);
892
1092
  }
893
1093
 
894
- async createAgentStep(orgId: string, agentId: string, sessionId: string, req: CreateAgentStepRequest): Promise<AgentStep> {
1094
+ async createAgentStep(
1095
+ orgId: string,
1096
+ agentId: string,
1097
+ sessionId: string,
1098
+ req: CreateAgentStepRequest,
1099
+ ): Promise<AgentStep> {
895
1100
  return this.request('POST', ENDPOINTS.AGENT_SESSION_STEPS(orgId, agentId, sessionId), req);
896
1101
  }
897
1102
 
898
- async getAgentSessionSteps(orgId: string, agentId: string, sessionId: string, params?: { limit?: number; cursor?: string }): Promise<PaginatedResponse<AgentStep>> {
899
- return this.request('GET', ENDPOINTS.AGENT_SESSION_STEPS(orgId, agentId, sessionId), undefined, params);
1103
+ async getAgentSessionSteps(
1104
+ orgId: string,
1105
+ agentId: string,
1106
+ sessionId: string,
1107
+ params?: { limit?: number; cursor?: string },
1108
+ ): Promise<PaginatedResponse<AgentStep>> {
1109
+ return this.request(
1110
+ 'GET',
1111
+ ENDPOINTS.AGENT_SESSION_STEPS(orgId, agentId, sessionId),
1112
+ undefined,
1113
+ params,
1114
+ );
900
1115
  }
901
1116
 
902
- async getAgentSessionStep(orgId: string, agentId: string, sessionId: string, stepId: string): Promise<AgentStep> {
1117
+ async getAgentSessionStep(
1118
+ orgId: string,
1119
+ agentId: string,
1120
+ sessionId: string,
1121
+ stepId: string,
1122
+ ): Promise<AgentStep> {
903
1123
  return this.request('GET', ENDPOINTS.AGENT_SESSION_STEP(orgId, agentId, sessionId, stepId));
904
1124
  }
905
1125
 
@@ -918,11 +1138,7 @@ export class ParallClient {
918
1138
  agentId: string,
919
1139
  req: StartRuntimeAuthSessionRequest = {},
920
1140
  ): Promise<RuntimeAuthSession> {
921
- return this.request(
922
- 'POST',
923
- ENDPOINTS.AGENT_RUNTIME_AUTH_SESSIONS(orgId, agentId),
924
- req,
925
- );
1141
+ return this.request('POST', ENDPOINTS.AGENT_RUNTIME_AUTH_SESSIONS(orgId, agentId), req);
926
1142
  }
927
1143
 
928
1144
  async completeAgentRuntimeAuthSession(
@@ -982,7 +1198,12 @@ export class ParallClient {
982
1198
  do {
983
1199
  const params: Record<string, string> = { limit: '100' };
984
1200
  if (cursor) params.cursor = cursor;
985
- const res = await this.request<PaginatedResponse<Task>>('GET', ENDPOINTS.AGENT_TASKS(orgId, agentId), undefined, params);
1201
+ const res = await this.request<PaginatedResponse<Task>>(
1202
+ 'GET',
1203
+ ENDPOINTS.AGENT_TASKS(orgId, agentId),
1204
+ undefined,
1205
+ params,
1206
+ );
986
1207
  all.push(...res.data);
987
1208
  cursor = res.has_more ? res.next_cursor : undefined;
988
1209
  } while (cursor);
@@ -1020,21 +1241,30 @@ export class ParallClient {
1020
1241
  return this.request('GET', ENDPOINTS.MACHINE_LOGS(orgId, machineId), undefined, { lines });
1021
1242
  }
1022
1243
 
1023
- async restartMachine(orgId: string, machineId: string): Promise<{ machine_id: string; command_id: string }> {
1244
+ async restartMachine(
1245
+ orgId: string,
1246
+ machineId: string,
1247
+ ): Promise<{ machine_id: string; command_id: string }> {
1024
1248
  return this.request('POST', ENDPOINTS.MACHINE_RESTART(orgId, machineId));
1025
1249
  }
1026
1250
 
1027
- async restartAllMachines(orgId: string): Promise<{ data: Array<{ machine_id: string; command_id?: string; status: string; error?: string }>; total: number }> {
1251
+ async restartAllMachines(orgId: string): Promise<{
1252
+ data: Array<{ machine_id: string; command_id?: string; status: string; error?: string }>;
1253
+ total: number;
1254
+ }> {
1028
1255
  return this.request('POST', ENDPOINTS.MACHINE_RESTART_ALL(orgId));
1029
1256
  }
1030
1257
 
1031
1258
  // ---- Daemon-mode Machine management (org-scoped, user auth) ----
1032
1259
 
1033
1260
  /**
1034
- * Create a new daemon-mode Machine. Returns the Machine row + one-shot
1035
- * mck_ token. The UI uses this when the user clicks "Create Workspace".
1261
+ * Create a new self-hosted daemon-mode Machine. Returns the Machine row +
1262
+ * one-shot mck_ token.
1036
1263
  */
1037
- async createMachine(orgId: string, opts: { label?: string; tier?: string; llm_source?: string; compute_mode?: 'hosted' | 'local' }): Promise<{
1264
+ async createMachine(
1265
+ orgId: string,
1266
+ opts: { label?: string; compute_mode: 'local'; llm_source?: 'parall' | 'runtime_auth' },
1267
+ ): Promise<{
1038
1268
  machine: Machine;
1039
1269
  machine_key: string;
1040
1270
  key_id: string;
@@ -1043,16 +1273,24 @@ export class ParallClient {
1043
1273
  }
1044
1274
 
1045
1275
  /**
1046
- * Returns only daemon_mode=true machines (non-terminated). Backs the
1047
- * "Workspaces" UI list. Legacy 1:1 machines are excluded.
1276
+ * Returns local daemon_mode=true machines (non-terminated). Backs the
1277
+ * "Workspaces" UI list. Legacy 1:1 and retired hosted daemon machines are
1278
+ * excluded.
1048
1279
  */
1049
1280
  async getDaemonMachines(orgId: string): Promise<Machine[]> {
1050
1281
  const all = await this.getMachines(orgId);
1051
- return all.filter((m) => m.daemon_mode && m.status !== 'terminated');
1282
+ return all.filter(
1283
+ (m) => m.daemon_mode && m.compute_mode === 'local' && m.status !== 'terminated',
1284
+ );
1052
1285
  }
1053
1286
 
1054
1287
  /** Attach an agent to a daemon-mode Machine. */
1055
- async attachAgent(orgId: string, machineId: string, agentId: string, opts?: AttachAgentRequest): Promise<{ status: string; machine_id: string; agent_id: string }> {
1288
+ async attachAgent(
1289
+ orgId: string,
1290
+ machineId: string,
1291
+ agentId: string,
1292
+ opts?: AttachAgentRequest,
1293
+ ): Promise<{ status: string; machine_id: string; agent_id: string }> {
1056
1294
  return this.request('POST', ENDPOINTS.MACHINE_ATTACH_AGENT(orgId, machineId, agentId), opts);
1057
1295
  }
1058
1296
 
@@ -1062,20 +1300,36 @@ export class ParallClient {
1062
1300
  }
1063
1301
 
1064
1302
  async listAgentWorkspaceStates(orgId: string, machineId: string): Promise<AgentWorkspaceState[]> {
1065
- const res = await this.request<{ data: AgentWorkspaceState[] }>('GET', ENDPOINTS.MACHINE_WORKSPACE_STATES(orgId, machineId));
1303
+ const res = await this.request<{ data: AgentWorkspaceState[] }>(
1304
+ 'GET',
1305
+ ENDPOINTS.MACHINE_WORKSPACE_STATES(orgId, machineId),
1306
+ );
1066
1307
  return res.data;
1067
1308
  }
1068
1309
 
1069
- async patchAgentDaemonConfig(orgId: string, machineId: string, agentId: string, daemonConfig: DaemonAgentConfig): Promise<void> {
1070
- return this.request('PATCH', ENDPOINTS.MACHINE_AGENT_DAEMON_CONFIG(orgId, machineId, agentId), { daemon_config: daemonConfig });
1310
+ async patchAgentDaemonConfig(
1311
+ orgId: string,
1312
+ machineId: string,
1313
+ agentId: string,
1314
+ daemonConfig: DaemonAgentConfig,
1315
+ ): Promise<void> {
1316
+ return this.request('PATCH', ENDPOINTS.MACHINE_AGENT_DAEMON_CONFIG(orgId, machineId, agentId), {
1317
+ daemon_config: daemonConfig,
1318
+ });
1071
1319
  }
1072
1320
 
1073
1321
  async retryAgentWorkspaceSetup(orgId: string, machineId: string, agentId: string): Promise<void> {
1074
1322
  return this.request('POST', ENDPOINTS.MACHINE_AGENT_WORKSPACE_SETUP(orgId, machineId, agentId));
1075
1323
  }
1076
1324
 
1077
- async patchMachineLLMSource(orgId: string, machineId: string, llmSource: string): Promise<Machine> {
1078
- return this.request('PATCH', ENDPOINTS.MACHINE_LLM_SOURCE(orgId, machineId), { llm_source: llmSource });
1325
+ async patchMachineLLMSource(
1326
+ orgId: string,
1327
+ machineId: string,
1328
+ llmSource: string,
1329
+ ): Promise<Machine> {
1330
+ return this.request('PATCH', ENDPOINTS.MACHINE_LLM_SOURCE(orgId, machineId), {
1331
+ llm_source: llmSource,
1332
+ });
1079
1333
  }
1080
1334
 
1081
1335
  /** Get machine-level runtime auth state. */
@@ -1097,7 +1351,11 @@ export class ParallClient {
1097
1351
  sessionId: string,
1098
1352
  req: CompleteRuntimeAuthSessionRequest,
1099
1353
  ): Promise<RuntimeAuthSession> {
1100
- return this.request('POST', ENDPOINTS.MACHINE_RUNTIME_AUTH_SESSION_COMPLETE(orgId, machineId, sessionId), req);
1354
+ return this.request(
1355
+ 'POST',
1356
+ ENDPOINTS.MACHINE_RUNTIME_AUTH_SESSION_COMPLETE(orgId, machineId, sessionId),
1357
+ req,
1358
+ );
1101
1359
  }
1102
1360
 
1103
1361
  async disconnectMachineRuntimeAuth(orgId: string, machineId: string): Promise<void> {
@@ -1127,23 +1385,50 @@ export class ParallClient {
1127
1385
  return res.data;
1128
1386
  }
1129
1387
 
1388
+ /** `GET /machines/me/clip-installs` — registry clips this machine should
1389
+ * install but hasn't yet (durable reconcile, mck_-authed). */
1390
+ async listClipInstalls(): Promise<MachineClipInstall[]> {
1391
+ const res = await this.request<{ data: MachineClipInstall[] }>(
1392
+ 'GET',
1393
+ ENDPOINTS.MACHINES_ME_CLIP_INSTALLS,
1394
+ );
1395
+ return res.data;
1396
+ }
1397
+
1398
+ /** `POST /machines/me/clip-installs/{clipId}/installed` — report a finished install. */
1399
+ async reportClipInstall(clipId: string, version?: string): Promise<void> {
1400
+ return this.request(
1401
+ 'POST',
1402
+ ENDPOINTS.MACHINES_ME_CLIP_INSTALL_DONE(clipId),
1403
+ version ? { version } : undefined,
1404
+ );
1405
+ }
1406
+
1130
1407
  /**
1131
1408
  * `POST /machines/me/health` — bump the Machine's `updated_at` to now.
1132
1409
  * Body is intentionally empty; the server ignores any payload. The
1133
1410
  * daemon should call this on a fixed cadence (e.g. every 30s) so an
1134
1411
  * external observer can detect a wedged supervisor.
1135
1412
  */
1136
- async postMachineHeartbeat(): Promise<void> {
1137
- return this.request('POST', ENDPOINTS.MACHINES_ME_HEALTH);
1413
+ async postMachineHeartbeat(daemonVersion?: string): Promise<void> {
1414
+ const body = daemonVersion ? { daemon_version: daemonVersion } : undefined;
1415
+ return this.request('POST', ENDPOINTS.MACHINES_ME_HEALTH, body);
1138
1416
  }
1139
1417
 
1140
- async reportAgentWorkspaceState(agentId: string, state: {
1141
- config_hash: string;
1142
- status: AgentWorkspaceReportStatus;
1143
- last_error?: string | null;
1144
- output_tail?: string | null;
1145
- }): Promise<void> {
1146
- const res = await this.request<{ status?: string }>('PUT', ENDPOINTS.MACHINES_ME_AGENT_WORKSPACE_STATE(agentId), state);
1418
+ async reportAgentWorkspaceState(
1419
+ agentId: string,
1420
+ state: {
1421
+ config_hash: string;
1422
+ status: AgentWorkspaceReportStatus;
1423
+ last_error?: string | null;
1424
+ output_tail?: string | null;
1425
+ },
1426
+ ): Promise<void> {
1427
+ const res = await this.request<{ status?: string }>(
1428
+ 'PUT',
1429
+ ENDPOINTS.MACHINES_ME_AGENT_WORKSPACE_STATE(agentId),
1430
+ state,
1431
+ );
1147
1432
  if (res?.status === 'ignored_stale') {
1148
1433
  throw new ApiError(409, 'Workspace state report ignored as stale', 'STALE_WORKSPACE_STATE');
1149
1434
  }
@@ -1165,21 +1450,52 @@ export class ParallClient {
1165
1450
  return this.request('POST', ENDPOINTS.MACHINES_ME_WS_TICKET);
1166
1451
  }
1167
1452
 
1168
- async postBrowseResponse(requestId: string, response: { request_id: string; path: string; entries: FilesystemEntry[]; error?: string }): Promise<void> {
1453
+ async postBrowseResponse(
1454
+ requestId: string,
1455
+ response: { request_id: string; path: string; entries: FilesystemEntry[]; error?: string },
1456
+ ): Promise<void> {
1169
1457
  return this.request('POST', ENDPOINTS.MACHINES_ME_BROWSE_RESPONSE(requestId), response);
1170
1458
  }
1171
1459
 
1172
- async resizeMachine(orgId: string, machineId: string, spec: ResizeMachineRequest): Promise<Machine> {
1460
+ async resizeMachine(
1461
+ orgId: string,
1462
+ machineId: string,
1463
+ spec: ResizeMachineRequest,
1464
+ ): Promise<Machine> {
1173
1465
  return this.request('PATCH', ENDPOINTS.MACHINE_SPEC(orgId, machineId), spec);
1174
1466
  }
1175
1467
 
1176
- async browseMachineFilesystem(orgId: string, machineId: string, path: string): Promise<BrowseMachineFilesystemResponse> {
1177
- return this.request('POST', ENDPOINTS.MACHINE_BROWSE(orgId, machineId), { path }, undefined, false, { timeoutMs: 15_000 });
1468
+ /** Signal a local daemon-mode Machine to check for and apply an update. */
1469
+ async requestMachineUpdate(orgId: string, machineId: string, mandatory = false): Promise<void> {
1470
+ await this.request('POST', ENDPOINTS.MACHINE_REQUEST_UPDATE(orgId, machineId), { mandatory });
1471
+ }
1472
+
1473
+ async browseMachineFilesystem(
1474
+ orgId: string,
1475
+ machineId: string,
1476
+ path: string,
1477
+ ): Promise<BrowseMachineFilesystemResponse> {
1478
+ return this.request(
1479
+ 'POST',
1480
+ ENDPOINTS.MACHINE_BROWSE(orgId, machineId),
1481
+ { path },
1482
+ undefined,
1483
+ false,
1484
+ { timeoutMs: 15_000 },
1485
+ );
1178
1486
  }
1179
1487
 
1180
1488
  /** Create a new machine key. Returns the raw key string (shown once) + metadata. */
1181
- async createMachineKey(orgId: string, machineId: string, name?: string): Promise<{ machine_key: string; key_id: string; key: MachineKey }> {
1182
- return this.request('POST', ENDPOINTS.MACHINE_KEYS(orgId, machineId), name ? { name } : undefined);
1489
+ async createMachineKey(
1490
+ orgId: string,
1491
+ machineId: string,
1492
+ name?: string,
1493
+ ): Promise<{ machine_key: string; key_id: string; key: MachineKey }> {
1494
+ return this.request(
1495
+ 'POST',
1496
+ ENDPOINTS.MACHINE_KEYS(orgId, machineId),
1497
+ name ? { name } : undefined,
1498
+ );
1183
1499
  }
1184
1500
 
1185
1501
  /** Revoke (soft-delete) a machine key by ID. */
@@ -1201,12 +1517,25 @@ export class ParallClient {
1201
1517
  return this.request('POST', ENDPOINTS.CHAT_READ(orgId, chatId), { message_id: messageId });
1202
1518
  }
1203
1519
 
1520
+ async getThreadUnread(
1521
+ orgId: string,
1522
+ chatId: string,
1523
+ threadRootId: string,
1524
+ ): Promise<ThreadUnreadEntry> {
1525
+ return this.request('GET', ENDPOINTS.THREAD_UNREAD(orgId, chatId, threadRootId));
1526
+ }
1527
+
1204
1528
  // ---- Inbox ----
1205
1529
 
1206
- async getInbox(orgId: string, params?: {
1207
- type?: string; read?: string;
1208
- limit?: number; cursor?: string;
1209
- }): Promise<PaginatedResponse<InboxItem>> {
1530
+ async getInbox(
1531
+ orgId: string,
1532
+ params?: {
1533
+ type?: string;
1534
+ read?: string;
1535
+ limit?: number;
1536
+ cursor?: string;
1537
+ },
1538
+ ): Promise<PaginatedResponse<InboxItem>> {
1210
1539
  return this.request('GET', ENDPOINTS.INBOX(orgId), undefined, params as Record<string, string>);
1211
1540
  }
1212
1541
 
@@ -1247,17 +1576,36 @@ export class ParallClient {
1247
1576
 
1248
1577
  // ---- Dispatch (agent event delivery) ----
1249
1578
 
1250
- async getDispatch(orgId: string, params?: {
1251
- limit?: number; cursor?: string;
1252
- }): Promise<PaginatedResponse<DispatchEvent>> {
1253
- return this.request('GET', ENDPOINTS.DISPATCH(orgId), undefined, params as Record<string, string>);
1579
+ async getDispatch(
1580
+ orgId: string,
1581
+ params?: {
1582
+ limit?: number;
1583
+ cursor?: string;
1584
+ },
1585
+ ): Promise<PaginatedResponse<DispatchEvent>> {
1586
+ return this.request(
1587
+ 'GET',
1588
+ ENDPOINTS.DISPATCH(orgId),
1589
+ undefined,
1590
+ params as Record<string, string>,
1591
+ );
1254
1592
  }
1255
1593
 
1256
1594
  async getDispatchPendingCount(orgId: string): Promise<{ count: number }> {
1257
1595
  return this.request('GET', ENDPOINTS.DISPATCH_PENDING_COUNT(orgId));
1258
1596
  }
1259
1597
 
1260
- async ackDispatch(orgId: string, source: { source_type: string; source_id: string }): Promise<void> {
1598
+ async markDispatchReceived(
1599
+ orgId: string,
1600
+ source: { source_type: string; source_id: string },
1601
+ ): Promise<void> {
1602
+ return this.request('POST', ENDPOINTS.DISPATCH_RECEIVED(orgId), source);
1603
+ }
1604
+
1605
+ async ackDispatch(
1606
+ orgId: string,
1607
+ source: { source_type: string; source_id: string },
1608
+ ): Promise<void> {
1261
1609
  return this.request('POST', ENDPOINTS.DISPATCH_ACK(orgId), source);
1262
1610
  }
1263
1611
 
@@ -1265,6 +1613,20 @@ export class ParallClient {
1265
1613
  return this.request('POST', ENDPOINTS.DISPATCH_ACK_BY_ID(orgId, id));
1266
1614
  }
1267
1615
 
1616
+ async getDispatchByMessages(
1617
+ orgId: string,
1618
+ chatId: string,
1619
+ messageIds: string[],
1620
+ ): Promise<{ data: DispatchEvent[] }> {
1621
+ const params = { chat_id: chatId, message_ids: messageIds.join(',') };
1622
+ return this.request(
1623
+ 'GET',
1624
+ ENDPOINTS.DISPATCH_BY_MESSAGES(orgId),
1625
+ undefined,
1626
+ params as unknown as Record<string, string>,
1627
+ );
1628
+ }
1629
+
1268
1630
  // ---- Platform Config ----
1269
1631
 
1270
1632
  /**
@@ -1295,10 +1657,18 @@ export class ParallClient {
1295
1657
 
1296
1658
  if (!res.ok) {
1297
1659
  const rawErrorBody = await res.json().catch(() => ({}));
1298
- const errorBody = rawErrorBody !== null && typeof rawErrorBody === 'object' ? rawErrorBody as Record<string, unknown> : {};
1299
- const errorObj = errorBody?.error && typeof errorBody.error === 'object' ? errorBody.error as { message?: string; code?: string } : undefined;
1300
- const errMsg = errorObj?.message ?? (typeof errorBody?.error === 'string' ? errorBody.error : undefined);
1301
- const errCode = errorObj?.code ?? (typeof errorBody?.code === 'string' ? errorBody.code : undefined);
1660
+ const errorBody =
1661
+ rawErrorBody !== null && typeof rawErrorBody === 'object'
1662
+ ? (rawErrorBody as Record<string, unknown>)
1663
+ : {};
1664
+ const errorObj =
1665
+ errorBody?.error && typeof errorBody.error === 'object'
1666
+ ? (errorBody.error as { message?: string; code?: string })
1667
+ : undefined;
1668
+ const errMsg =
1669
+ errorObj?.message ?? (typeof errorBody?.error === 'string' ? errorBody.error : undefined);
1670
+ const errCode =
1671
+ errorObj?.code ?? (typeof errorBody?.code === 'string' ? errorBody.code : undefined);
1302
1672
  const apiError = new ApiError(res.status, errMsg ?? res.statusText, errCode);
1303
1673
  const { error: _e, code: _c, message: _m, ...extras } = errorBody;
1304
1674
  if (Object.keys(extras).length > 0) apiError.extras = extras;
@@ -1314,18 +1684,22 @@ export class ParallClient {
1314
1684
  return this.request('POST', ENDPOINTS.TASKS(orgId), data);
1315
1685
  }
1316
1686
 
1317
- async getTasks(orgId: string, params?: {
1318
- status?: string;
1319
- priority?: string;
1320
- assignee_id?: string;
1321
- parent_id?: string;
1322
- project_id?: string;
1323
- limit?: number;
1324
- cursor?: string;
1325
- sort?: string;
1326
- order?: string;
1327
- scope?: 'active' | 'archived' | 'all';
1328
- }): Promise<PaginatedResponse<Task>> {
1687
+ async getTasks(
1688
+ orgId: string,
1689
+ params?: {
1690
+ q?: string;
1691
+ status?: string;
1692
+ priority?: string;
1693
+ assignee_id?: string;
1694
+ parent_id?: string;
1695
+ project_id?: string;
1696
+ limit?: number;
1697
+ cursor?: string;
1698
+ sort?: string;
1699
+ order?: string;
1700
+ scope?: 'active' | 'archived' | 'all';
1701
+ },
1702
+ ): Promise<PaginatedResponse<Task>> {
1329
1703
  return this.request('GET', ENDPOINTS.TASKS(orgId), undefined, params);
1330
1704
  }
1331
1705
 
@@ -1338,7 +1712,12 @@ export class ParallClient {
1338
1712
  }
1339
1713
 
1340
1714
  async deleteTask(orgId: string, taskId: string, opts?: { force?: boolean }): Promise<void> {
1341
- return this.request('DELETE', ENDPOINTS.TASK(orgId, taskId), undefined, opts?.force ? { force: 'true' } : undefined);
1715
+ return this.request(
1716
+ 'DELETE',
1717
+ ENDPOINTS.TASK(orgId, taskId),
1718
+ undefined,
1719
+ opts?.force ? { force: 'true' } : undefined,
1720
+ );
1342
1721
  }
1343
1722
 
1344
1723
  async archiveTask(orgId: string, taskId: string): Promise<void> {
@@ -1358,10 +1737,21 @@ export class ParallClient {
1358
1737
  }
1359
1738
 
1360
1739
  async getTaskWatchers(orgId: string, taskId: string): Promise<TaskWatcher[]> {
1361
- const res = await this.request<{ data: TaskWatcher[] }>('GET', ENDPOINTS.TASK_WATCHERS(orgId, taskId));
1740
+ const res = await this.request<{ data: TaskWatcher[] }>(
1741
+ 'GET',
1742
+ ENDPOINTS.TASK_WATCHERS(orgId, taskId),
1743
+ );
1362
1744
  return res.data;
1363
1745
  }
1364
1746
 
1747
+ async subscribeTaskMember(orgId: string, taskId: string, userId: string): Promise<void> {
1748
+ return this.request('PUT', ENDPOINTS.TASK_SUBSCRIBER(orgId, taskId, userId));
1749
+ }
1750
+
1751
+ async unsubscribeTaskMember(orgId: string, taskId: string, userId: string): Promise<void> {
1752
+ return this.request('DELETE', ENDPOINTS.TASK_SUBSCRIBER(orgId, taskId, userId));
1753
+ }
1754
+
1365
1755
  async watchThread(threadRootId: string): Promise<void> {
1366
1756
  return this.request('POST', ENDPOINTS.MESSAGE_WATCH(threadRootId));
1367
1757
  }
@@ -1371,26 +1761,42 @@ export class ParallClient {
1371
1761
  }
1372
1762
 
1373
1763
  async getThreadWatchers(threadRootId: string): Promise<ThreadWatcher[]> {
1374
- const res = await this.request<{ data: ThreadWatcher[] }>('GET', ENDPOINTS.MESSAGE_WATCHERS(threadRootId));
1764
+ const res = await this.request<{ data: ThreadWatcher[] }>(
1765
+ 'GET',
1766
+ ENDPOINTS.MESSAGE_WATCHERS(threadRootId),
1767
+ );
1375
1768
  return res.data;
1376
1769
  }
1377
1770
 
1378
1771
  async isWatchingThread(threadRootId: string): Promise<boolean> {
1379
- const res = await this.request<{ watching: boolean }>('GET', ENDPOINTS.MESSAGE_WATCHING(threadRootId));
1772
+ const res = await this.request<{ watching: boolean }>(
1773
+ 'GET',
1774
+ ENDPOINTS.MESSAGE_WATCHING(threadRootId),
1775
+ );
1380
1776
  return res.watching;
1381
1777
  }
1382
1778
 
1383
1779
  async getSubtasks(orgId: string, taskId: string): Promise<Task[]> {
1384
- const res = await this.request<PaginatedResponse<Task>>('GET', ENDPOINTS.TASK_SUBTASKS(orgId, taskId));
1780
+ const res = await this.request<PaginatedResponse<Task>>(
1781
+ 'GET',
1782
+ ENDPOINTS.TASK_SUBTASKS(orgId, taskId),
1783
+ );
1385
1784
  return res.data;
1386
1785
  }
1387
1786
 
1388
- async createTaskRelation(orgId: string, taskId: string, data: CreateTaskRelationRequest): Promise<TaskRelation> {
1787
+ async createTaskRelation(
1788
+ orgId: string,
1789
+ taskId: string,
1790
+ data: CreateTaskRelationRequest,
1791
+ ): Promise<TaskRelation> {
1389
1792
  return this.request('POST', ENDPOINTS.TASK_RELATIONS(orgId, taskId), data);
1390
1793
  }
1391
1794
 
1392
1795
  async getTaskRelations(orgId: string, taskId: string): Promise<TaskRelation[]> {
1393
- const res = await this.request<{ data: TaskRelation[] }>('GET', ENDPOINTS.TASK_RELATIONS(orgId, taskId));
1796
+ const res = await this.request<{ data: TaskRelation[] }>(
1797
+ 'GET',
1798
+ ENDPOINTS.TASK_RELATIONS(orgId, taskId),
1799
+ );
1394
1800
  return res.data;
1395
1801
  }
1396
1802
 
@@ -1415,9 +1821,15 @@ export class ParallClient {
1415
1821
 
1416
1822
  // ---- Task Comments ----
1417
1823
 
1418
- async getTaskComments(orgId: string, taskId: string, params?: {
1419
- limit?: number; cursor?: string; order?: string;
1420
- }): Promise<PaginatedResponse<TaskComment>> {
1824
+ async getTaskComments(
1825
+ orgId: string,
1826
+ taskId: string,
1827
+ params?: {
1828
+ limit?: number;
1829
+ cursor?: string;
1830
+ order?: string;
1831
+ },
1832
+ ): Promise<PaginatedResponse<TaskComment>> {
1421
1833
  return this.request('GET', ENDPOINTS.TASK_COMMENTS(orgId, taskId), undefined, params);
1422
1834
  }
1423
1835
 
@@ -1425,11 +1837,20 @@ export class ParallClient {
1425
1837
  return this.request('GET', ENDPOINTS.TASK_COMMENT(orgId, taskId, commentId));
1426
1838
  }
1427
1839
 
1428
- async createTaskComment(orgId: string, taskId: string, data: CreateTaskCommentRequest): Promise<TaskComment> {
1840
+ async createTaskComment(
1841
+ orgId: string,
1842
+ taskId: string,
1843
+ data: CreateTaskCommentRequest,
1844
+ ): Promise<TaskComment> {
1429
1845
  return this.request('POST', ENDPOINTS.TASK_COMMENTS(orgId, taskId), data);
1430
1846
  }
1431
1847
 
1432
- async updateTaskComment(orgId: string, taskId: string, commentId: string, data: UpdateTaskCommentRequest): Promise<TaskComment> {
1848
+ async updateTaskComment(
1849
+ orgId: string,
1850
+ taskId: string,
1851
+ commentId: string,
1852
+ data: UpdateTaskCommentRequest,
1853
+ ): Promise<TaskComment> {
1433
1854
  return this.request('PATCH', ENDPOINTS.TASK_COMMENT(orgId, taskId, commentId), data);
1434
1855
  }
1435
1856
 
@@ -1439,9 +1860,14 @@ export class ParallClient {
1439
1860
 
1440
1861
  // ---- Task Activities ----
1441
1862
 
1442
- async getTaskActivities(orgId: string, taskId: string, params?: {
1443
- limit?: number; cursor?: string;
1444
- }): Promise<PaginatedResponse<TaskActivity>> {
1863
+ async getTaskActivities(
1864
+ orgId: string,
1865
+ taskId: string,
1866
+ params?: {
1867
+ limit?: number;
1868
+ cursor?: string;
1869
+ },
1870
+ ): Promise<PaginatedResponse<TaskActivity>> {
1445
1871
  return this.request('GET', ENDPOINTS.TASK_ACTIVITIES(orgId, taskId), undefined, params);
1446
1872
  }
1447
1873
 
@@ -1460,7 +1886,11 @@ export class ParallClient {
1460
1886
  return this.request('GET', ENDPOINTS.PROJECT(orgId, projectId));
1461
1887
  }
1462
1888
 
1463
- async updateProject(orgId: string, projectId: string, data: UpdateProjectRequest): Promise<Project> {
1889
+ async updateProject(
1890
+ orgId: string,
1891
+ projectId: string,
1892
+ data: UpdateProjectRequest,
1893
+ ): Promise<Project> {
1464
1894
  return this.request('PATCH', ENDPOINTS.PROJECT(orgId, projectId), data);
1465
1895
  }
1466
1896
 
@@ -1474,15 +1904,27 @@ export class ParallClient {
1474
1904
  return this.request('POST', ENDPOINTS.SCHEDULES(orgId), input);
1475
1905
  }
1476
1906
 
1477
- async listSchedules(orgId: string, filters?: ScheduleFilters): Promise<PaginatedResponse<Schedule>> {
1478
- return this.request('GET', ENDPOINTS.SCHEDULES(orgId), undefined, filters as Record<string, string | number | undefined>);
1907
+ async listSchedules(
1908
+ orgId: string,
1909
+ filters?: ScheduleFilters,
1910
+ ): Promise<PaginatedResponse<Schedule>> {
1911
+ return this.request(
1912
+ 'GET',
1913
+ ENDPOINTS.SCHEDULES(orgId),
1914
+ undefined,
1915
+ filters as Record<string, string | number | undefined>,
1916
+ );
1479
1917
  }
1480
1918
 
1481
1919
  async getSchedule(orgId: string, scheduleId: string): Promise<Schedule> {
1482
1920
  return this.request('GET', ENDPOINTS.SCHEDULE(orgId, scheduleId));
1483
1921
  }
1484
1922
 
1485
- async updateSchedule(orgId: string, scheduleId: string, patch: UpdateScheduleInput): Promise<Schedule> {
1923
+ async updateSchedule(
1924
+ orgId: string,
1925
+ scheduleId: string,
1926
+ patch: UpdateScheduleInput,
1927
+ ): Promise<Schedule> {
1486
1928
  return this.request('PATCH', ENDPOINTS.SCHEDULE(orgId, scheduleId), patch);
1487
1929
  }
1488
1930
 
@@ -1534,31 +1976,59 @@ export class ParallClient {
1534
1976
  return this.request('GET', ENDPOINTS.WIKI(orgId, wikiId));
1535
1977
  }
1536
1978
 
1537
- async getWikiTree(orgId: string, wikiId: string, params?: { ref?: string; path?: string }): Promise<WikiTreeResponse> {
1979
+ async getWikiTree(
1980
+ orgId: string,
1981
+ wikiId: string,
1982
+ params?: { ref?: string; path?: string },
1983
+ ): Promise<WikiTreeResponse> {
1538
1984
  return this.request('GET', ENDPOINTS.WIKI_TREE(orgId, wikiId), undefined, params);
1539
1985
  }
1540
1986
 
1541
- async getWikiBlob(orgId: string, wikiId: string, params: { path: string; ref?: string }): Promise<WikiBlob> {
1987
+ async getWikiBlob(
1988
+ orgId: string,
1989
+ wikiId: string,
1990
+ params: { path: string; ref?: string },
1991
+ ): Promise<WikiBlob> {
1542
1992
  return this.request('GET', ENDPOINTS.WIKI_BLOB(orgId, wikiId), undefined, params);
1543
1993
  }
1544
1994
 
1545
- async getWikiNodeSections(orgId: string, wikiId: string, params?: { ref?: string }): Promise<WikiNodeSectionArtifact> {
1995
+ async getWikiNodeSections(
1996
+ orgId: string,
1997
+ wikiId: string,
1998
+ params?: { ref?: string },
1999
+ ): Promise<WikiNodeSectionArtifact> {
1546
2000
  return this.request('GET', ENDPOINTS.WIKI_NODE_SECTIONS(orgId, wikiId), undefined, params);
1547
2001
  }
1548
2002
 
1549
- async searchWiki(orgId: string, wikiId: string, params: { q: string; limit?: number; path_prefix?: string; ref?: string }): Promise<WikiSearchResponse> {
2003
+ async searchWiki(
2004
+ orgId: string,
2005
+ wikiId: string,
2006
+ params: { q: string; limit?: number; path_prefix?: string; ref?: string },
2007
+ ): Promise<WikiSearchResponse> {
1550
2008
  return this.request('GET', ENDPOINTS.WIKI_SEARCH(orgId, wikiId), undefined, params);
1551
2009
  }
1552
2010
 
1553
- async getWikiPageIndex(orgId: string, wikiId: string, params?: { ref?: string }): Promise<WikiPageIndex> {
2011
+ async getWikiPageIndex(
2012
+ orgId: string,
2013
+ wikiId: string,
2014
+ params?: { ref?: string },
2015
+ ): Promise<WikiPageIndex> {
1554
2016
  return this.request('GET', ENDPOINTS.WIKI_PAGE_INDEX(orgId, wikiId), undefined, params);
1555
2017
  }
1556
2018
 
1557
- async getWikiRefs(orgId: string, wikiId: string, params?: { ref?: string }): Promise<WikiRefsResponse> {
2019
+ async getWikiRefs(
2020
+ orgId: string,
2021
+ wikiId: string,
2022
+ params?: { ref?: string },
2023
+ ): Promise<WikiRefsResponse> {
1558
2024
  return this.request('GET', ENDPOINTS.WIKI_REFS(orgId, wikiId), undefined, params);
1559
2025
  }
1560
2026
 
1561
- async checkWikiRefs(orgId: string, wikiId: string, params?: { ref?: string }): Promise<WikiRefsCheckResponse> {
2027
+ async checkWikiRefs(
2028
+ orgId: string,
2029
+ wikiId: string,
2030
+ params?: { ref?: string },
2031
+ ): Promise<WikiRefsCheckResponse> {
1562
2032
  return this.request('GET', ENDPOINTS.WIKI_REFS_CHECK(orgId, wikiId), undefined, params);
1563
2033
  }
1564
2034
 
@@ -1572,17 +2042,32 @@ export class ParallClient {
1572
2042
  return this.request('POST', ENDPOINTS.WIKI_ANCHOR_STATUS(orgId, wikiId), body);
1573
2043
  }
1574
2044
 
1575
- async createWikiChangeset(orgId: string, wikiId: string, data: CreateWikiChangesetRequest): Promise<WikiChangeset> {
1576
- return normalizeWikiChangeset(await this.request('POST', ENDPOINTS.WIKI_CHANGESETS(orgId, wikiId), data));
2045
+ async createWikiChangeset(
2046
+ orgId: string,
2047
+ wikiId: string,
2048
+ data: CreateWikiChangesetRequest,
2049
+ ): Promise<WikiChangeset> {
2050
+ return normalizeWikiChangeset(
2051
+ await this.request('POST', ENDPOINTS.WIKI_CHANGESETS(orgId, wikiId), data),
2052
+ );
1577
2053
  }
1578
2054
 
1579
2055
  async getWikiChangesets(orgId: string, wikiId: string): Promise<WikiChangeset[]> {
1580
- const res = await this.request<{ data: WikiChangeset[] }>('GET', ENDPOINTS.WIKI_CHANGESETS(orgId, wikiId));
2056
+ const res = await this.request<{ data: WikiChangeset[] }>(
2057
+ 'GET',
2058
+ ENDPOINTS.WIKI_CHANGESETS(orgId, wikiId),
2059
+ );
1581
2060
  return res.data.map(normalizeWikiChangeset);
1582
2061
  }
1583
2062
 
1584
- async getWikiChangeset(orgId: string, wikiId: string, changesetId: string): Promise<WikiChangeset> {
1585
- return normalizeWikiChangeset(await this.request('GET', ENDPOINTS.WIKI_CHANGESET(orgId, wikiId, changesetId)));
2063
+ async getWikiChangeset(
2064
+ orgId: string,
2065
+ wikiId: string,
2066
+ changesetId: string,
2067
+ ): Promise<WikiChangeset> {
2068
+ return normalizeWikiChangeset(
2069
+ await this.request('GET', ENDPOINTS.WIKI_CHANGESET(orgId, wikiId, changesetId)),
2070
+ );
1586
2071
  }
1587
2072
 
1588
2073
  async updateWikiChangeset(
@@ -1591,19 +2076,37 @@ export class ParallClient {
1591
2076
  changesetId: string,
1592
2077
  data: UpdateWikiChangesetRequest,
1593
2078
  ): Promise<WikiChangeset> {
1594
- return normalizeWikiChangeset(await this.request('PATCH', ENDPOINTS.WIKI_CHANGESET(orgId, wikiId, changesetId), data));
2079
+ return normalizeWikiChangeset(
2080
+ await this.request('PATCH', ENDPOINTS.WIKI_CHANGESET(orgId, wikiId, changesetId), data),
2081
+ );
1595
2082
  }
1596
2083
 
1597
- async getWikiChangesetDiff(orgId: string, wikiId: string, changesetId: string): Promise<WikiDiff> {
2084
+ async getWikiChangesetDiff(
2085
+ orgId: string,
2086
+ wikiId: string,
2087
+ changesetId: string,
2088
+ ): Promise<WikiDiff> {
1598
2089
  return this.request('GET', ENDPOINTS.WIKI_CHANGESET_DIFF(orgId, wikiId, changesetId));
1599
2090
  }
1600
2091
 
1601
- async mergeWikiChangeset(orgId: string, wikiId: string, changesetId: string): Promise<WikiChangeset> {
1602
- return normalizeWikiChangeset(await this.request('POST', ENDPOINTS.WIKI_CHANGESET_MERGE(orgId, wikiId, changesetId)));
2092
+ async mergeWikiChangeset(
2093
+ orgId: string,
2094
+ wikiId: string,
2095
+ changesetId: string,
2096
+ ): Promise<WikiChangeset> {
2097
+ return normalizeWikiChangeset(
2098
+ await this.request('POST', ENDPOINTS.WIKI_CHANGESET_MERGE(orgId, wikiId, changesetId)),
2099
+ );
1603
2100
  }
1604
2101
 
1605
- async closeWikiChangeset(orgId: string, wikiId: string, changesetId: string): Promise<WikiChangeset> {
1606
- return normalizeWikiChangeset(await this.request('POST', ENDPOINTS.WIKI_CHANGESET_CLOSE(orgId, wikiId, changesetId)));
2102
+ async closeWikiChangeset(
2103
+ orgId: string,
2104
+ wikiId: string,
2105
+ changesetId: string,
2106
+ ): Promise<WikiChangeset> {
2107
+ return normalizeWikiChangeset(
2108
+ await this.request('POST', ENDPOINTS.WIKI_CHANGESET_CLOSE(orgId, wikiId, changesetId)),
2109
+ );
1607
2110
  }
1608
2111
 
1609
2112
  // ---- Wiki Binary Upload / Delete (Phase 2 of wiki-file-storage-design) ----
@@ -1660,12 +2163,10 @@ export class ParallClient {
1660
2163
  wikiId: string,
1661
2164
  params: { path: string; message?: string },
1662
2165
  ): Promise<void> {
1663
- await this.request(
1664
- 'DELETE',
1665
- ENDPOINTS.WIKI_FILES(orgId, wikiId),
1666
- undefined,
1667
- { path: params.path, message: params.message },
1668
- );
2166
+ await this.request('DELETE', ENDPOINTS.WIKI_FILES(orgId, wikiId), undefined, {
2167
+ path: params.path,
2168
+ message: params.message,
2169
+ });
1669
2170
  }
1670
2171
 
1671
2172
  /**
@@ -1678,21 +2179,24 @@ export class ParallClient {
1678
2179
  wikiId: string,
1679
2180
  params: { path: string; ref?: string },
1680
2181
  ): Promise<WikiFilePreviewUrlResponse> {
1681
- return this.request(
1682
- 'POST',
1683
- ENDPOINTS.WIKI_FILE_PREVIEW_URL(orgId, wikiId),
1684
- params,
1685
- );
2182
+ return this.request('POST', ENDPOINTS.WIKI_FILE_PREVIEW_URL(orgId, wikiId), params);
1686
2183
  }
1687
2184
 
1688
2185
  // ---- Wiki Path Scopes (AFCS ACL) ----
1689
2186
 
1690
2187
  async getWikiPathScopes(orgId: string, wikiId: string): Promise<WikiPathScope[]> {
1691
- const res = await this.request<{ data: WikiPathScope[] }>('GET', ENDPOINTS.WIKI_PATH_SCOPES(orgId, wikiId));
2188
+ const res = await this.request<{ data: WikiPathScope[] }>(
2189
+ 'GET',
2190
+ ENDPOINTS.WIKI_PATH_SCOPES(orgId, wikiId),
2191
+ );
1692
2192
  return res.data;
1693
2193
  }
1694
2194
 
1695
- async createWikiPathScope(orgId: string, wikiId: string, data: CreateWikiPathScopeRequest): Promise<WikiPathScope> {
2195
+ async createWikiPathScope(
2196
+ orgId: string,
2197
+ wikiId: string,
2198
+ data: CreateWikiPathScopeRequest,
2199
+ ): Promise<WikiPathScope> {
1696
2200
  return this.request('POST', ENDPOINTS.WIKI_PATH_SCOPES(orgId, wikiId), data);
1697
2201
  }
1698
2202
 
@@ -1700,11 +2204,24 @@ export class ParallClient {
1700
2204
  await this.request('DELETE', ENDPOINTS.WIKI_PATH_SCOPE(orgId, wikiId, scopeId));
1701
2205
  }
1702
2206
 
1703
- async getWikiAccessStatus(orgId: string, wikiId: string, path?: string): Promise<WikiAccessStatus> {
1704
- return this.request('GET', ENDPOINTS.WIKI_ACCESS_STATUS(orgId, wikiId), undefined, path ? { path } : undefined);
2207
+ async getWikiAccessStatus(
2208
+ orgId: string,
2209
+ wikiId: string,
2210
+ path?: string,
2211
+ ): Promise<WikiAccessStatus> {
2212
+ return this.request(
2213
+ 'GET',
2214
+ ENDPOINTS.WIKI_ACCESS_STATUS(orgId, wikiId),
2215
+ undefined,
2216
+ path ? { path } : undefined,
2217
+ );
1705
2218
  }
1706
2219
 
1707
- async createWikiAccessRequest(orgId: string, wikiId: string, data: CreateWikiAccessRequest): Promise<void> {
2220
+ async createWikiAccessRequest(
2221
+ orgId: string,
2222
+ wikiId: string,
2223
+ data: CreateWikiAccessRequest,
2224
+ ): Promise<void> {
1708
2225
  await this.request('POST', ENDPOINTS.WIKI_ACCESS_REQUESTS(orgId, wikiId), data);
1709
2226
  }
1710
2227
 
@@ -1724,7 +2241,10 @@ export class ParallClient {
1724
2241
  path: string,
1725
2242
  params?: { page?: number; limit?: number },
1726
2243
  ): Promise<{ data: WikiCommit[]; page: number; limit: number }> {
1727
- return this.request('GET', ENDPOINTS.WIKI_FILE_COMMITS(orgId, wikiId), undefined, { path, ...params });
2244
+ return this.request('GET', ENDPOINTS.WIKI_FILE_COMMITS(orgId, wikiId), undefined, {
2245
+ path,
2246
+ ...params,
2247
+ });
1728
2248
  }
1729
2249
 
1730
2250
  async getWikiBlame(
@@ -1759,8 +2279,20 @@ export class ParallClient {
1759
2279
  async getComments(
1760
2280
  orgId: string,
1761
2281
  params:
1762
- | { target_uri: string; target_prefix?: never; limit?: number; cursor?: string; order?: string }
1763
- | { target_prefix: string; target_uri?: never; limit?: number; cursor?: string; order?: string },
2282
+ | {
2283
+ target_uri: string;
2284
+ target_prefix?: never;
2285
+ limit?: number;
2286
+ cursor?: string;
2287
+ order?: string;
2288
+ }
2289
+ | {
2290
+ target_prefix: string;
2291
+ target_uri?: never;
2292
+ limit?: number;
2293
+ cursor?: string;
2294
+ order?: string;
2295
+ },
1764
2296
  ): Promise<PaginatedResponse<Comment>> {
1765
2297
  return this.request('GET', ENDPOINTS.COMMENTS(orgId), undefined, params);
1766
2298
  }
@@ -1773,7 +2305,11 @@ export class ParallClient {
1773
2305
  return this.request('POST', ENDPOINTS.COMMENTS(orgId), data);
1774
2306
  }
1775
2307
 
1776
- async updateComment(orgId: string, commentId: string, data: UpdateCommentRequest): Promise<Comment> {
2308
+ async updateComment(
2309
+ orgId: string,
2310
+ commentId: string,
2311
+ data: UpdateCommentRequest,
2312
+ ): Promise<Comment> {
1777
2313
  return this.request('PATCH', ENDPOINTS.COMMENT(orgId, commentId), data);
1778
2314
  }
1779
2315
 
@@ -1783,7 +2319,11 @@ export class ParallClient {
1783
2319
 
1784
2320
  // ---- References ----
1785
2321
 
1786
- async resolveRefs(orgId: string, refs: string[], options?: { sourceMessageId?: string }): Promise<ResolveRefsResponse> {
2322
+ async resolveRefs(
2323
+ orgId: string,
2324
+ refs: string[],
2325
+ options?: { sourceMessageId?: string },
2326
+ ): Promise<ResolveRefsResponse> {
1787
2327
  const body: Record<string, unknown> = { refs };
1788
2328
  if (options?.sourceMessageId) {
1789
2329
  body.source_message_id = options.sourceMessageId;
@@ -1822,7 +2362,9 @@ export class ParallClient {
1822
2362
  return this.request('GET', ENDPOINTS.NOTIFICATION_PREFERENCES);
1823
2363
  }
1824
2364
 
1825
- async updateNotificationPreferences(prefs: Partial<NotifPrefs>): Promise<NotificationPreferences> {
2365
+ async updateNotificationPreferences(
2366
+ prefs: Partial<NotifPrefs>,
2367
+ ): Promise<NotificationPreferences> {
1826
2368
  return this.request('PATCH', ENDPOINTS.NOTIFICATION_PREFERENCES, { prefs });
1827
2369
  }
1828
2370
 
@@ -1838,7 +2380,20 @@ export class ParallClient {
1838
2380
  return this.request('GET', ENDPOINTS.BILLING(orgId));
1839
2381
  }
1840
2382
 
1841
- async listBillingTransactions(orgId: string, opts?: { cursor?: string; limit?: number; types?: string[]; user_id?: string; unresolved_actor?: boolean; machine_id?: string; unresolved_machine?: boolean; from?: string; to?: string }): Promise<{ items: CreditTransaction[]; next_cursor: string | null }> {
2383
+ async listBillingTransactions(
2384
+ orgId: string,
2385
+ opts?: {
2386
+ cursor?: string;
2387
+ limit?: number;
2388
+ types?: string[];
2389
+ user_id?: string;
2390
+ unresolved_actor?: boolean;
2391
+ machine_id?: string;
2392
+ unresolved_machine?: boolean;
2393
+ from?: string;
2394
+ to?: string;
2395
+ },
2396
+ ): Promise<{ items: CreditTransaction[]; next_cursor: string | null }> {
1842
2397
  const params = new URLSearchParams();
1843
2398
  if (opts?.cursor) params.set('cursor', opts.cursor);
1844
2399
  if (opts?.limit) params.set('limit', String(opts.limit));
@@ -1853,14 +2408,20 @@ export class ParallClient {
1853
2408
  return this.request('GET', `${ENDPOINTS.BILLING_TRANSACTIONS(orgId)}${qs ? `?${qs}` : ''}`);
1854
2409
  }
1855
2410
 
1856
- async listBillingTransactionAgentGroups(orgId: string, opts?: { from?: string; to?: string }): Promise<{ groups: CreditTransactionAgentGroup[] }> {
2411
+ async listBillingTransactionAgentGroups(
2412
+ orgId: string,
2413
+ opts?: { from?: string; to?: string },
2414
+ ): Promise<{ groups: CreditTransactionAgentGroup[] }> {
1857
2415
  const params = new URLSearchParams({ group_by: 'agent' });
1858
2416
  if (opts?.from) params.set('from', opts.from);
1859
2417
  if (opts?.to) params.set('to', opts.to);
1860
2418
  return this.request('GET', `${ENDPOINTS.BILLING_TRANSACTIONS(orgId)}?${params}`);
1861
2419
  }
1862
2420
 
1863
- async listBillingTransactionMachineGroups(orgId: string, opts?: { from?: string; to?: string }): Promise<{ groups: CreditTransactionMachineGroup[] }> {
2421
+ async listBillingTransactionMachineGroups(
2422
+ orgId: string,
2423
+ opts?: { from?: string; to?: string },
2424
+ ): Promise<{ groups: CreditTransactionMachineGroup[] }> {
1864
2425
  const params = new URLSearchParams({ group_by: 'machine' });
1865
2426
  if (opts?.from) params.set('from', opts.from);
1866
2427
  if (opts?.to) params.set('to', opts.to);
@@ -1886,7 +2447,10 @@ export class ParallClient {
1886
2447
  return this.request('GET', ENDPOINTS.BILLING_AUTO_RELOAD(orgId));
1887
2448
  }
1888
2449
 
1889
- async updateAutoReloadSettings(orgId: string, req: UpdateAutoReloadRequest): Promise<AutoReloadSettings> {
2450
+ async updateAutoReloadSettings(
2451
+ orgId: string,
2452
+ req: UpdateAutoReloadRequest,
2453
+ ): Promise<AutoReloadSettings> {
1890
2454
  return this.request('PUT', ENDPOINTS.BILLING_AUTO_RELOAD(orgId), req);
1891
2455
  }
1892
2456
 
@@ -1897,7 +2461,78 @@ export class ParallClient {
1897
2461
  // own thin client (`ts/admin/lib/api.ts`) that hits these directly.
1898
2462
 
1899
2463
  async getComputePricing(): Promise<ComputePricingResponse> {
1900
- const resp = await this.request<{ data: ComputePricingResponse }>('GET', ENDPOINTS.COMPUTE_PRICING());
2464
+ const resp = await this.request<{ data: ComputePricingResponse }>(
2465
+ 'GET',
2466
+ ENDPOINTS.COMPUTE_PRICING(),
2467
+ );
2468
+ return resp.data;
2469
+ }
2470
+
2471
+ // ---- Clips ----
2472
+
2473
+ async listClips(orgId: string): Promise<Clip[]> {
2474
+ const resp = await this.request<{ data: Clip[] }>('GET', ENDPOINTS.CLIPS(orgId));
2475
+ return resp.data;
2476
+ }
2477
+
2478
+ async createClip(orgId: string, req: CreateClipRequest): Promise<Clip> {
2479
+ return this.request('POST', ENDPOINTS.CLIPS(orgId), req);
2480
+ }
2481
+
2482
+ async getClip(orgId: string, clipId: string): Promise<Clip> {
2483
+ return this.request('GET', ENDPOINTS.CLIP(orgId, clipId));
2484
+ }
2485
+
2486
+ async updateClip(orgId: string, clipId: string, req: UpdateClipRequest): Promise<Clip> {
2487
+ return this.request('PATCH', ENDPOINTS.CLIP(orgId, clipId), req);
2488
+ }
2489
+
2490
+ async deleteClip(orgId: string, clipId: string): Promise<void> {
2491
+ await this.request('DELETE', ENDPOINTS.CLIP(orgId, clipId));
2492
+ }
2493
+
2494
+ async listClipAgents(orgId: string, clipId: string): Promise<AgentClip[]> {
2495
+ const resp = await this.request<{ data: AgentClip[] }>(
2496
+ 'GET',
2497
+ ENDPOINTS.CLIP_AGENTS(orgId, clipId),
2498
+ );
2499
+ return resp.data;
2500
+ }
2501
+
2502
+ async listAgentClips(orgId: string, agentId: string): Promise<Clip[]> {
2503
+ const resp = await this.request<{ data: Clip[] }>('GET', ENDPOINTS.AGENT_CLIPS(orgId, agentId));
2504
+ return resp.data;
2505
+ }
2506
+
2507
+ async bindAgentClip(
2508
+ orgId: string,
2509
+ agentId: string,
2510
+ req: BindAgentClipRequest,
2511
+ ): Promise<AgentClip> {
2512
+ return this.request('POST', ENDPOINTS.AGENT_CLIPS(orgId, agentId), req);
2513
+ }
2514
+
2515
+ async unbindAgentClip(orgId: string, agentId: string, clipId: string): Promise<void> {
2516
+ await this.request('DELETE', ENDPOINTS.AGENT_CLIP(orgId, agentId, clipId));
2517
+ }
2518
+
2519
+ async invokeClip(orgId: string, req: InvokeClipRequest): Promise<InvokeClipResponse> {
2520
+ const serverTimeout = Math.max(req.timeout_ms ?? 30000, 1000);
2521
+ const timeoutMs = serverTimeout + 5000;
2522
+ return this.request('POST', ENDPOINTS.CLIP_INVOKE(orgId), req, undefined, false, { timeoutMs });
2523
+ }
2524
+
2525
+ async listOnlineClips(orgId: string): Promise<OnlineClipInfo[]> {
2526
+ const resp = await this.request<{ data: OnlineClipInfo[] }>(
2527
+ 'GET',
2528
+ ENDPOINTS.CLIP_ONLINE(orgId),
2529
+ );
2530
+ return resp.data;
2531
+ }
2532
+
2533
+ async listRegistryClips(q?: string): Promise<RegistryClipInfo[]> {
2534
+ const url = ENDPOINTS.CLIP_REGISTRY() + (q ? `?q=${encodeURIComponent(q)}` : '');
2535
+ const resp = await this.request<{ data: RegistryClipInfo[] }>('GET', url);
1901
2536
  return resp.data;
1902
2537
  }
1903
2538
  }