@parall/sdk 1.31.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/dist/client.d.ts +30 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +122 -16
- package/dist/constants.d.ts +20 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +230 -38
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/types.d.ts +153 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/ws.d.ts +3 -3
- package/dist/ws.d.ts.map +1 -1
- package/dist/ws.js +12 -7
- package/package.json +1 -1
- package/src/client.ts +737 -169
- package/src/constants.ts +292 -88
- package/src/index.ts +7 -1
- package/src/types.ts +254 -20
- package/src/ws.ts +26 -11
package/src/client.ts
CHANGED
|
@@ -130,6 +130,7 @@ import type {
|
|
|
130
130
|
TransferChatOwnershipRequest,
|
|
131
131
|
UpdateChatMemberRequest,
|
|
132
132
|
UnreadEntry,
|
|
133
|
+
ThreadUnreadEntry,
|
|
133
134
|
BillingSummary,
|
|
134
135
|
CreditTransaction,
|
|
135
136
|
CreditTransactionAgentGroup,
|
|
@@ -141,6 +142,16 @@ import type {
|
|
|
141
142
|
UpdateAutoReloadRequest,
|
|
142
143
|
ComputePricing,
|
|
143
144
|
ComputePricingResponse,
|
|
145
|
+
Clip,
|
|
146
|
+
AgentClip,
|
|
147
|
+
CreateClipRequest,
|
|
148
|
+
UpdateClipRequest,
|
|
149
|
+
BindAgentClipRequest,
|
|
150
|
+
InvokeClipRequest,
|
|
151
|
+
InvokeClipResponse,
|
|
152
|
+
OnlineClipInfo,
|
|
153
|
+
RegistryClipInfo,
|
|
154
|
+
MachineClipInstall,
|
|
144
155
|
} from './types.js';
|
|
145
156
|
|
|
146
157
|
export interface ParallClientOptions {
|
|
@@ -163,16 +174,26 @@ export class ParallClient {
|
|
|
163
174
|
|
|
164
175
|
/** Auth endpoints excluded from automatic 401 refresh to prevent recursion. */
|
|
165
176
|
private static readonly AUTH_PATHS = new Set([
|
|
166
|
-
'/auth/login',
|
|
167
|
-
'/auth/
|
|
168
|
-
'/auth/
|
|
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',
|
|
169
186
|
]);
|
|
170
187
|
|
|
171
188
|
/** Proactive refresh when token expires within this window (seconds). */
|
|
172
189
|
private static readonly REFRESH_THRESHOLD_S = 5 * 60;
|
|
173
190
|
|
|
174
191
|
private static normalizeFetchError(err: unknown): ApiError {
|
|
175
|
-
if (
|
|
192
|
+
if (
|
|
193
|
+
typeof DOMException !== 'undefined' &&
|
|
194
|
+
err instanceof DOMException &&
|
|
195
|
+
(err.name === 'TimeoutError' || err.name === 'AbortError')
|
|
196
|
+
) {
|
|
176
197
|
// The SDK only creates internal timeout signals today. If caller-owned
|
|
177
198
|
// cancellation is added later, AbortError should get its own code.
|
|
178
199
|
return new ApiError(0, 'Request timed out', 'REQUEST_TIMEOUT');
|
|
@@ -332,10 +353,18 @@ export class ParallClient {
|
|
|
332
353
|
|
|
333
354
|
if (!res.ok) {
|
|
334
355
|
const rawErrorBody = await res.json().catch(() => ({}));
|
|
335
|
-
const errorBody =
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
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);
|
|
339
368
|
const apiError = new ApiError(res.status, errMsg ?? res.statusText, errCode);
|
|
340
369
|
const { error: _e, code: _c, message: _m, ...extras } = errorBody;
|
|
341
370
|
if (Object.keys(extras).length > 0) apiError.extras = extras;
|
|
@@ -401,10 +430,18 @@ export class ParallClient {
|
|
|
401
430
|
|
|
402
431
|
if (!res.ok) {
|
|
403
432
|
const rawErrorBody = await res.json().catch(() => ({}));
|
|
404
|
-
const errorBody =
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
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);
|
|
408
445
|
const apiError = new ApiError(res.status, errMsg ?? res.statusText, errCode);
|
|
409
446
|
const { error: _e, code: _c, message: _m, ...extras } = errorBody;
|
|
410
447
|
if (Object.keys(extras).length > 0) apiError.extras = extras;
|
|
@@ -454,7 +491,10 @@ export class ParallClient {
|
|
|
454
491
|
}
|
|
455
492
|
|
|
456
493
|
async resetPassword(token: string, newPassword: string): Promise<AuthTokens> {
|
|
457
|
-
return this.request('POST', ENDPOINTS.AUTH_RESET_PASSWORD, {
|
|
494
|
+
return this.request('POST', ENDPOINTS.AUTH_RESET_PASSWORD, {
|
|
495
|
+
token,
|
|
496
|
+
new_password: newPassword,
|
|
497
|
+
});
|
|
458
498
|
}
|
|
459
499
|
|
|
460
500
|
// ---- WebSocket ----
|
|
@@ -487,7 +527,11 @@ export class ParallClient {
|
|
|
487
527
|
return this.request('DELETE', ENDPOINTS.USER_AVATAR);
|
|
488
528
|
}
|
|
489
529
|
|
|
490
|
-
async uploadAgentAvatar(
|
|
530
|
+
async uploadAgentAvatar(
|
|
531
|
+
orgId: string,
|
|
532
|
+
agentId: string,
|
|
533
|
+
file: File | Blob,
|
|
534
|
+
): Promise<AvatarUploadResponse> {
|
|
491
535
|
const fd = new FormData();
|
|
492
536
|
fd.append('file', file);
|
|
493
537
|
return this.multipartRequest('POST', ENDPOINTS.AGENT_AVATAR(orgId, agentId), fd);
|
|
@@ -501,10 +545,13 @@ export class ParallClient {
|
|
|
501
545
|
return this.request('GET', ENDPOINTS.USER(id));
|
|
502
546
|
}
|
|
503
547
|
|
|
504
|
-
|
|
505
548
|
// ---- Organizations ----
|
|
506
549
|
|
|
507
|
-
async createOrg(data: {
|
|
550
|
+
async createOrg(data: {
|
|
551
|
+
name: string;
|
|
552
|
+
invite_code: string;
|
|
553
|
+
avatar_url?: string;
|
|
554
|
+
}): Promise<Organization> {
|
|
508
555
|
return this.request('POST', ENDPOINTS.ORGS, data);
|
|
509
556
|
}
|
|
510
557
|
|
|
@@ -524,7 +571,12 @@ export class ParallClient {
|
|
|
524
571
|
*/
|
|
525
572
|
async updateOrg(
|
|
526
573
|
orgId: string,
|
|
527
|
-
data: Partial<
|
|
574
|
+
data: Partial<
|
|
575
|
+
Pick<
|
|
576
|
+
Organization,
|
|
577
|
+
'name' | 'avatar_url' | 'smart_routing_strategy' | 'smart_routing_agent_id'
|
|
578
|
+
>
|
|
579
|
+
>,
|
|
528
580
|
): Promise<Organization> {
|
|
529
581
|
return this.request('PATCH', ENDPOINTS.ORG(orgId), data);
|
|
530
582
|
}
|
|
@@ -539,7 +591,10 @@ export class ParallClient {
|
|
|
539
591
|
}
|
|
540
592
|
|
|
541
593
|
async getOnlineMembers(orgId: string): Promise<string[]> {
|
|
542
|
-
const res = await this.request<{ user_ids: string[] }>(
|
|
594
|
+
const res = await this.request<{ user_ids: string[] }>(
|
|
595
|
+
'GET',
|
|
596
|
+
ENDPOINTS.ORG_MEMBERS_ONLINE(orgId),
|
|
597
|
+
);
|
|
543
598
|
return res.user_ids ?? [];
|
|
544
599
|
}
|
|
545
600
|
|
|
@@ -596,12 +651,19 @@ export class ParallClient {
|
|
|
596
651
|
|
|
597
652
|
// ---- Invitations ----
|
|
598
653
|
|
|
599
|
-
async createInvitation(
|
|
654
|
+
async createInvitation(
|
|
655
|
+
orgId: string,
|
|
656
|
+
email: string,
|
|
657
|
+
role?: OrgMemberRole,
|
|
658
|
+
): Promise<OrgInvitation> {
|
|
600
659
|
return this.request('POST', ENDPOINTS.ORG_INVITATIONS(orgId), { email, role });
|
|
601
660
|
}
|
|
602
661
|
|
|
603
662
|
async getOrgInvitations(orgId: string): Promise<OrgInvitation[]> {
|
|
604
|
-
const res = await this.request<{ data: OrgInvitation[] }>(
|
|
663
|
+
const res = await this.request<{ data: OrgInvitation[] }>(
|
|
664
|
+
'GET',
|
|
665
|
+
ENDPOINTS.ORG_INVITATIONS(orgId),
|
|
666
|
+
);
|
|
605
667
|
return res.data;
|
|
606
668
|
}
|
|
607
669
|
|
|
@@ -672,16 +734,17 @@ export class ParallClient {
|
|
|
672
734
|
jrId: string,
|
|
673
735
|
decision: 'approve' | 'reject',
|
|
674
736
|
): Promise<OrgJoinRequest> {
|
|
675
|
-
return this.request(
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
{ decision },
|
|
679
|
-
);
|
|
737
|
+
return this.request('POST', ENDPOINTS.ORG_INVITE_LINK_JOIN_REQUEST_DECIDE(orgId, jrId), {
|
|
738
|
+
decision,
|
|
739
|
+
});
|
|
680
740
|
}
|
|
681
741
|
|
|
682
742
|
// ---- Direct Messages (org-scoped) ----
|
|
683
743
|
|
|
684
|
-
async sendDirectMessage(
|
|
744
|
+
async sendDirectMessage(
|
|
745
|
+
orgId: string,
|
|
746
|
+
req: SendDirectMessageRequest,
|
|
747
|
+
): Promise<DirectMessageResponse> {
|
|
685
748
|
return this.request('POST', ENDPOINTS.DM(orgId), req);
|
|
686
749
|
}
|
|
687
750
|
|
|
@@ -715,7 +778,22 @@ export class ParallClient {
|
|
|
715
778
|
return this.request('GET', ENDPOINTS.CHAT(orgId, chatId));
|
|
716
779
|
}
|
|
717
780
|
|
|
718
|
-
async updateChat(
|
|
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> {
|
|
719
797
|
return this.request('PATCH', ENDPOINTS.CHAT(orgId, chatId), data);
|
|
720
798
|
}
|
|
721
799
|
|
|
@@ -737,7 +815,12 @@ export class ParallClient {
|
|
|
737
815
|
}
|
|
738
816
|
|
|
739
817
|
async deleteChat(orgId: string, chatId: string, opts?: { force?: boolean }): Promise<void> {
|
|
740
|
-
return this.request(
|
|
818
|
+
return this.request(
|
|
819
|
+
'DELETE',
|
|
820
|
+
ENDPOINTS.CHAT(orgId, chatId),
|
|
821
|
+
undefined,
|
|
822
|
+
opts?.force ? { force: 'true' } : undefined,
|
|
823
|
+
);
|
|
741
824
|
}
|
|
742
825
|
|
|
743
826
|
async archiveChat(orgId: string, chatId: string): Promise<void> {
|
|
@@ -751,7 +834,10 @@ export class ParallClient {
|
|
|
751
834
|
// ---- Chat Members ----
|
|
752
835
|
|
|
753
836
|
async getChatMembers(orgId: string, chatId: string): Promise<ChatMember[]> {
|
|
754
|
-
const res = await this.request<{ data: ChatMember[] }>(
|
|
837
|
+
const res = await this.request<{ data: ChatMember[] }>(
|
|
838
|
+
'GET',
|
|
839
|
+
ENDPOINTS.CHAT_MEMBERS(orgId, chatId),
|
|
840
|
+
);
|
|
755
841
|
return res.data;
|
|
756
842
|
}
|
|
757
843
|
|
|
@@ -763,15 +849,29 @@ export class ParallClient {
|
|
|
763
849
|
return this.request('DELETE', ENDPOINTS.CHAT_MEMBER(orgId, chatId, userId));
|
|
764
850
|
}
|
|
765
851
|
|
|
766
|
-
async updateChatMemberRole(
|
|
852
|
+
async updateChatMemberRole(
|
|
853
|
+
orgId: string,
|
|
854
|
+
chatId: string,
|
|
855
|
+
userId: string,
|
|
856
|
+
role: ChatMemberRole,
|
|
857
|
+
): Promise<void> {
|
|
767
858
|
return this.request('PATCH', ENDPOINTS.CHAT_MEMBER(orgId, chatId, userId), { role });
|
|
768
859
|
}
|
|
769
860
|
|
|
770
|
-
async updateChatMember(
|
|
861
|
+
async updateChatMember(
|
|
862
|
+
orgId: string,
|
|
863
|
+
chatId: string,
|
|
864
|
+
userId: string,
|
|
865
|
+
req: UpdateChatMemberRequest,
|
|
866
|
+
): Promise<ChatMember> {
|
|
771
867
|
return this.request('PATCH', ENDPOINTS.CHAT_MEMBER(orgId, chatId, userId), req);
|
|
772
868
|
}
|
|
773
869
|
|
|
774
|
-
async transferChatOwnership(
|
|
870
|
+
async transferChatOwnership(
|
|
871
|
+
orgId: string,
|
|
872
|
+
chatId: string,
|
|
873
|
+
req: TransferChatOwnershipRequest,
|
|
874
|
+
): Promise<void> {
|
|
775
875
|
return this.request('POST', ENDPOINTS.CHAT_TRANSFER_OWNERSHIP(orgId, chatId), req);
|
|
776
876
|
}
|
|
777
877
|
|
|
@@ -792,7 +892,12 @@ export class ParallClient {
|
|
|
792
892
|
top_level?: boolean;
|
|
793
893
|
},
|
|
794
894
|
): Promise<PaginatedResponse<Message>> {
|
|
795
|
-
return this.request(
|
|
895
|
+
return this.request(
|
|
896
|
+
'GET',
|
|
897
|
+
ENDPOINTS.CHAT_MESSAGES(orgId, chatId),
|
|
898
|
+
undefined,
|
|
899
|
+
params as Record<string, string | number | boolean | undefined>,
|
|
900
|
+
);
|
|
796
901
|
}
|
|
797
902
|
|
|
798
903
|
async getMessage(id: string): Promise<Message> {
|
|
@@ -825,7 +930,12 @@ export class ParallClient {
|
|
|
825
930
|
}
|
|
826
931
|
|
|
827
932
|
async getFileUrl(id: string, opts?: { download?: boolean }): Promise<FileUrlResponse> {
|
|
828
|
-
return this.request(
|
|
933
|
+
return this.request(
|
|
934
|
+
'GET',
|
|
935
|
+
ENDPOINTS.FILE(id),
|
|
936
|
+
undefined,
|
|
937
|
+
opts?.download ? { download: true } : undefined,
|
|
938
|
+
);
|
|
829
939
|
}
|
|
830
940
|
|
|
831
941
|
// ---- Approvals ----
|
|
@@ -858,7 +968,11 @@ export class ParallClient {
|
|
|
858
968
|
|
|
859
969
|
// ---- Agents (org-scoped) ----
|
|
860
970
|
|
|
861
|
-
async createAgent(
|
|
971
|
+
async createAgent(
|
|
972
|
+
orgId: string,
|
|
973
|
+
req: CreateAgentRequest,
|
|
974
|
+
opts?: { timeoutMs?: number },
|
|
975
|
+
): Promise<CreateAgentResponse> {
|
|
862
976
|
return this.request('POST', ENDPOINTS.AGENTS(orgId), req, undefined, false, opts);
|
|
863
977
|
}
|
|
864
978
|
|
|
@@ -877,10 +991,7 @@ export class ParallClient {
|
|
|
877
991
|
* topology metadata (base URL → provider / tenant) to non-admins,
|
|
878
992
|
* so this dedicated endpoint is the only read path.
|
|
879
993
|
*/
|
|
880
|
-
async getAgentProviderConfig(
|
|
881
|
-
orgId: string,
|
|
882
|
-
agentId: string,
|
|
883
|
-
): Promise<AgentProviderConfigRead> {
|
|
994
|
+
async getAgentProviderConfig(orgId: string, agentId: string): Promise<AgentProviderConfigRead> {
|
|
884
995
|
return this.request('GET', ENDPOINTS.AGENT_PROVIDER_CONFIG(orgId, agentId));
|
|
885
996
|
}
|
|
886
997
|
|
|
@@ -909,13 +1020,25 @@ export class ParallClient {
|
|
|
909
1020
|
return this.request('DELETE', ENDPOINTS.AGENT_API_KEY(orgId, agentId, key));
|
|
910
1021
|
}
|
|
911
1022
|
|
|
912
|
-
async getAgentActivity(
|
|
913
|
-
|
|
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
|
+
);
|
|
914
1034
|
return res.data;
|
|
915
1035
|
}
|
|
916
1036
|
|
|
917
1037
|
async getAgentMonitor(orgId: string, agentId: string): Promise<unknown> {
|
|
918
|
-
const res = await this.request<{ data: unknown }>(
|
|
1038
|
+
const res = await this.request<{ data: unknown }>(
|
|
1039
|
+
'GET',
|
|
1040
|
+
ENDPOINTS.AGENT_MONITOR(orgId, agentId),
|
|
1041
|
+
);
|
|
919
1042
|
return res.data;
|
|
920
1043
|
}
|
|
921
1044
|
|
|
@@ -931,7 +1054,11 @@ export class ParallClient {
|
|
|
931
1054
|
return this.request('POST', ENDPOINTS.AGENT_NEW_SESSION(orgId, agentId));
|
|
932
1055
|
}
|
|
933
1056
|
|
|
934
|
-
async createAgentSession(
|
|
1057
|
+
async createAgentSession(
|
|
1058
|
+
orgId: string,
|
|
1059
|
+
agentId: string,
|
|
1060
|
+
req: CreateAgentSessionRequest,
|
|
1061
|
+
): Promise<AgentSessionDB> {
|
|
935
1062
|
return this.request('POST', ENDPOINTS.AGENT_SESSIONS(orgId, agentId), req);
|
|
936
1063
|
}
|
|
937
1064
|
|
|
@@ -939,27 +1066,60 @@ export class ParallClient {
|
|
|
939
1066
|
* List agent sessions.
|
|
940
1067
|
* @param params.status - Comma-separated status filter (e.g., `'open'`).
|
|
941
1068
|
*/
|
|
942
|
-
async getAgentSessions(
|
|
1069
|
+
async getAgentSessions(
|
|
1070
|
+
orgId: string,
|
|
1071
|
+
agentId: string,
|
|
1072
|
+
params?: { limit?: number; status?: string; cursor?: string },
|
|
1073
|
+
): Promise<PaginatedResponse<AgentSessionDB>> {
|
|
943
1074
|
return this.request('GET', ENDPOINTS.AGENT_SESSIONS(orgId, agentId), undefined, params);
|
|
944
1075
|
}
|
|
945
1076
|
|
|
946
|
-
async getAgentSession(
|
|
1077
|
+
async getAgentSession(
|
|
1078
|
+
orgId: string,
|
|
1079
|
+
agentId: string,
|
|
1080
|
+
sessionId: string,
|
|
1081
|
+
): Promise<AgentSessionDB> {
|
|
947
1082
|
return this.request('GET', ENDPOINTS.AGENT_SESSION(orgId, agentId, sessionId));
|
|
948
1083
|
}
|
|
949
1084
|
|
|
950
|
-
async updateAgentSession(
|
|
1085
|
+
async updateAgentSession(
|
|
1086
|
+
orgId: string,
|
|
1087
|
+
agentId: string,
|
|
1088
|
+
sessionId: string,
|
|
1089
|
+
req: UpdateAgentSessionRequest,
|
|
1090
|
+
): Promise<AgentSessionDB> {
|
|
951
1091
|
return this.request('PATCH', ENDPOINTS.AGENT_SESSION(orgId, agentId, sessionId), req);
|
|
952
1092
|
}
|
|
953
1093
|
|
|
954
|
-
async createAgentStep(
|
|
1094
|
+
async createAgentStep(
|
|
1095
|
+
orgId: string,
|
|
1096
|
+
agentId: string,
|
|
1097
|
+
sessionId: string,
|
|
1098
|
+
req: CreateAgentStepRequest,
|
|
1099
|
+
): Promise<AgentStep> {
|
|
955
1100
|
return this.request('POST', ENDPOINTS.AGENT_SESSION_STEPS(orgId, agentId, sessionId), req);
|
|
956
1101
|
}
|
|
957
1102
|
|
|
958
|
-
async getAgentSessionSteps(
|
|
959
|
-
|
|
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
|
+
);
|
|
960
1115
|
}
|
|
961
1116
|
|
|
962
|
-
async getAgentSessionStep(
|
|
1117
|
+
async getAgentSessionStep(
|
|
1118
|
+
orgId: string,
|
|
1119
|
+
agentId: string,
|
|
1120
|
+
sessionId: string,
|
|
1121
|
+
stepId: string,
|
|
1122
|
+
): Promise<AgentStep> {
|
|
963
1123
|
return this.request('GET', ENDPOINTS.AGENT_SESSION_STEP(orgId, agentId, sessionId, stepId));
|
|
964
1124
|
}
|
|
965
1125
|
|
|
@@ -978,11 +1138,7 @@ export class ParallClient {
|
|
|
978
1138
|
agentId: string,
|
|
979
1139
|
req: StartRuntimeAuthSessionRequest = {},
|
|
980
1140
|
): Promise<RuntimeAuthSession> {
|
|
981
|
-
return this.request(
|
|
982
|
-
'POST',
|
|
983
|
-
ENDPOINTS.AGENT_RUNTIME_AUTH_SESSIONS(orgId, agentId),
|
|
984
|
-
req,
|
|
985
|
-
);
|
|
1141
|
+
return this.request('POST', ENDPOINTS.AGENT_RUNTIME_AUTH_SESSIONS(orgId, agentId), req);
|
|
986
1142
|
}
|
|
987
1143
|
|
|
988
1144
|
async completeAgentRuntimeAuthSession(
|
|
@@ -1042,7 +1198,12 @@ export class ParallClient {
|
|
|
1042
1198
|
do {
|
|
1043
1199
|
const params: Record<string, string> = { limit: '100' };
|
|
1044
1200
|
if (cursor) params.cursor = cursor;
|
|
1045
|
-
const res = await this.request<PaginatedResponse<Task>>(
|
|
1201
|
+
const res = await this.request<PaginatedResponse<Task>>(
|
|
1202
|
+
'GET',
|
|
1203
|
+
ENDPOINTS.AGENT_TASKS(orgId, agentId),
|
|
1204
|
+
undefined,
|
|
1205
|
+
params,
|
|
1206
|
+
);
|
|
1046
1207
|
all.push(...res.data);
|
|
1047
1208
|
cursor = res.has_more ? res.next_cursor : undefined;
|
|
1048
1209
|
} while (cursor);
|
|
@@ -1080,11 +1241,17 @@ export class ParallClient {
|
|
|
1080
1241
|
return this.request('GET', ENDPOINTS.MACHINE_LOGS(orgId, machineId), undefined, { lines });
|
|
1081
1242
|
}
|
|
1082
1243
|
|
|
1083
|
-
async restartMachine(
|
|
1244
|
+
async restartMachine(
|
|
1245
|
+
orgId: string,
|
|
1246
|
+
machineId: string,
|
|
1247
|
+
): Promise<{ machine_id: string; command_id: string }> {
|
|
1084
1248
|
return this.request('POST', ENDPOINTS.MACHINE_RESTART(orgId, machineId));
|
|
1085
1249
|
}
|
|
1086
1250
|
|
|
1087
|
-
async restartAllMachines(orgId: string): Promise<{
|
|
1251
|
+
async restartAllMachines(orgId: string): Promise<{
|
|
1252
|
+
data: Array<{ machine_id: string; command_id?: string; status: string; error?: string }>;
|
|
1253
|
+
total: number;
|
|
1254
|
+
}> {
|
|
1088
1255
|
return this.request('POST', ENDPOINTS.MACHINE_RESTART_ALL(orgId));
|
|
1089
1256
|
}
|
|
1090
1257
|
|
|
@@ -1094,7 +1261,10 @@ export class ParallClient {
|
|
|
1094
1261
|
* Create a new self-hosted daemon-mode Machine. Returns the Machine row +
|
|
1095
1262
|
* one-shot mck_ token.
|
|
1096
1263
|
*/
|
|
1097
|
-
async createMachine(
|
|
1264
|
+
async createMachine(
|
|
1265
|
+
orgId: string,
|
|
1266
|
+
opts: { label?: string; compute_mode: 'local'; llm_source?: 'parall' | 'runtime_auth' },
|
|
1267
|
+
): Promise<{
|
|
1098
1268
|
machine: Machine;
|
|
1099
1269
|
machine_key: string;
|
|
1100
1270
|
key_id: string;
|
|
@@ -1109,11 +1279,18 @@ export class ParallClient {
|
|
|
1109
1279
|
*/
|
|
1110
1280
|
async getDaemonMachines(orgId: string): Promise<Machine[]> {
|
|
1111
1281
|
const all = await this.getMachines(orgId);
|
|
1112
|
-
return all.filter(
|
|
1282
|
+
return all.filter(
|
|
1283
|
+
(m) => m.daemon_mode && m.compute_mode === 'local' && m.status !== 'terminated',
|
|
1284
|
+
);
|
|
1113
1285
|
}
|
|
1114
1286
|
|
|
1115
1287
|
/** Attach an agent to a daemon-mode Machine. */
|
|
1116
|
-
async attachAgent(
|
|
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 }> {
|
|
1117
1294
|
return this.request('POST', ENDPOINTS.MACHINE_ATTACH_AGENT(orgId, machineId, agentId), opts);
|
|
1118
1295
|
}
|
|
1119
1296
|
|
|
@@ -1123,20 +1300,36 @@ export class ParallClient {
|
|
|
1123
1300
|
}
|
|
1124
1301
|
|
|
1125
1302
|
async listAgentWorkspaceStates(orgId: string, machineId: string): Promise<AgentWorkspaceState[]> {
|
|
1126
|
-
const res = await this.request<{ data: AgentWorkspaceState[] }>(
|
|
1303
|
+
const res = await this.request<{ data: AgentWorkspaceState[] }>(
|
|
1304
|
+
'GET',
|
|
1305
|
+
ENDPOINTS.MACHINE_WORKSPACE_STATES(orgId, machineId),
|
|
1306
|
+
);
|
|
1127
1307
|
return res.data;
|
|
1128
1308
|
}
|
|
1129
1309
|
|
|
1130
|
-
async patchAgentDaemonConfig(
|
|
1131
|
-
|
|
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
|
+
});
|
|
1132
1319
|
}
|
|
1133
1320
|
|
|
1134
1321
|
async retryAgentWorkspaceSetup(orgId: string, machineId: string, agentId: string): Promise<void> {
|
|
1135
1322
|
return this.request('POST', ENDPOINTS.MACHINE_AGENT_WORKSPACE_SETUP(orgId, machineId, agentId));
|
|
1136
1323
|
}
|
|
1137
1324
|
|
|
1138
|
-
async patchMachineLLMSource(
|
|
1139
|
-
|
|
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
|
+
});
|
|
1140
1333
|
}
|
|
1141
1334
|
|
|
1142
1335
|
/** Get machine-level runtime auth state. */
|
|
@@ -1158,7 +1351,11 @@ export class ParallClient {
|
|
|
1158
1351
|
sessionId: string,
|
|
1159
1352
|
req: CompleteRuntimeAuthSessionRequest,
|
|
1160
1353
|
): Promise<RuntimeAuthSession> {
|
|
1161
|
-
return this.request(
|
|
1354
|
+
return this.request(
|
|
1355
|
+
'POST',
|
|
1356
|
+
ENDPOINTS.MACHINE_RUNTIME_AUTH_SESSION_COMPLETE(orgId, machineId, sessionId),
|
|
1357
|
+
req,
|
|
1358
|
+
);
|
|
1162
1359
|
}
|
|
1163
1360
|
|
|
1164
1361
|
async disconnectMachineRuntimeAuth(orgId: string, machineId: string): Promise<void> {
|
|
@@ -1188,6 +1385,25 @@ export class ParallClient {
|
|
|
1188
1385
|
return res.data;
|
|
1189
1386
|
}
|
|
1190
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
|
+
|
|
1191
1407
|
/**
|
|
1192
1408
|
* `POST /machines/me/health` — bump the Machine's `updated_at` to now.
|
|
1193
1409
|
* Body is intentionally empty; the server ignores any payload. The
|
|
@@ -1199,13 +1415,20 @@ export class ParallClient {
|
|
|
1199
1415
|
return this.request('POST', ENDPOINTS.MACHINES_ME_HEALTH, body);
|
|
1200
1416
|
}
|
|
1201
1417
|
|
|
1202
|
-
async reportAgentWorkspaceState(
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
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
|
+
);
|
|
1209
1432
|
if (res?.status === 'ignored_stale') {
|
|
1210
1433
|
throw new ApiError(409, 'Workspace state report ignored as stale', 'STALE_WORKSPACE_STATE');
|
|
1211
1434
|
}
|
|
@@ -1227,11 +1450,18 @@ export class ParallClient {
|
|
|
1227
1450
|
return this.request('POST', ENDPOINTS.MACHINES_ME_WS_TICKET);
|
|
1228
1451
|
}
|
|
1229
1452
|
|
|
1230
|
-
async postBrowseResponse(
|
|
1453
|
+
async postBrowseResponse(
|
|
1454
|
+
requestId: string,
|
|
1455
|
+
response: { request_id: string; path: string; entries: FilesystemEntry[]; error?: string },
|
|
1456
|
+
): Promise<void> {
|
|
1231
1457
|
return this.request('POST', ENDPOINTS.MACHINES_ME_BROWSE_RESPONSE(requestId), response);
|
|
1232
1458
|
}
|
|
1233
1459
|
|
|
1234
|
-
async resizeMachine(
|
|
1460
|
+
async resizeMachine(
|
|
1461
|
+
orgId: string,
|
|
1462
|
+
machineId: string,
|
|
1463
|
+
spec: ResizeMachineRequest,
|
|
1464
|
+
): Promise<Machine> {
|
|
1235
1465
|
return this.request('PATCH', ENDPOINTS.MACHINE_SPEC(orgId, machineId), spec);
|
|
1236
1466
|
}
|
|
1237
1467
|
|
|
@@ -1240,13 +1470,32 @@ export class ParallClient {
|
|
|
1240
1470
|
await this.request('POST', ENDPOINTS.MACHINE_REQUEST_UPDATE(orgId, machineId), { mandatory });
|
|
1241
1471
|
}
|
|
1242
1472
|
|
|
1243
|
-
async browseMachineFilesystem(
|
|
1244
|
-
|
|
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
|
+
);
|
|
1245
1486
|
}
|
|
1246
1487
|
|
|
1247
1488
|
/** Create a new machine key. Returns the raw key string (shown once) + metadata. */
|
|
1248
|
-
async createMachineKey(
|
|
1249
|
-
|
|
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
|
+
);
|
|
1250
1499
|
}
|
|
1251
1500
|
|
|
1252
1501
|
/** Revoke (soft-delete) a machine key by ID. */
|
|
@@ -1268,12 +1517,25 @@ export class ParallClient {
|
|
|
1268
1517
|
return this.request('POST', ENDPOINTS.CHAT_READ(orgId, chatId), { message_id: messageId });
|
|
1269
1518
|
}
|
|
1270
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
|
+
|
|
1271
1528
|
// ---- Inbox ----
|
|
1272
1529
|
|
|
1273
|
-
async getInbox(
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
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>> {
|
|
1277
1539
|
return this.request('GET', ENDPOINTS.INBOX(orgId), undefined, params as Record<string, string>);
|
|
1278
1540
|
}
|
|
1279
1541
|
|
|
@@ -1314,17 +1576,36 @@ export class ParallClient {
|
|
|
1314
1576
|
|
|
1315
1577
|
// ---- Dispatch (agent event delivery) ----
|
|
1316
1578
|
|
|
1317
|
-
async getDispatch(
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
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
|
+
);
|
|
1321
1592
|
}
|
|
1322
1593
|
|
|
1323
1594
|
async getDispatchPendingCount(orgId: string): Promise<{ count: number }> {
|
|
1324
1595
|
return this.request('GET', ENDPOINTS.DISPATCH_PENDING_COUNT(orgId));
|
|
1325
1596
|
}
|
|
1326
1597
|
|
|
1327
|
-
async
|
|
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> {
|
|
1328
1609
|
return this.request('POST', ENDPOINTS.DISPATCH_ACK(orgId), source);
|
|
1329
1610
|
}
|
|
1330
1611
|
|
|
@@ -1332,6 +1613,20 @@ export class ParallClient {
|
|
|
1332
1613
|
return this.request('POST', ENDPOINTS.DISPATCH_ACK_BY_ID(orgId, id));
|
|
1333
1614
|
}
|
|
1334
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
|
+
|
|
1335
1630
|
// ---- Platform Config ----
|
|
1336
1631
|
|
|
1337
1632
|
/**
|
|
@@ -1362,10 +1657,18 @@ export class ParallClient {
|
|
|
1362
1657
|
|
|
1363
1658
|
if (!res.ok) {
|
|
1364
1659
|
const rawErrorBody = await res.json().catch(() => ({}));
|
|
1365
|
-
const errorBody =
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
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);
|
|
1369
1672
|
const apiError = new ApiError(res.status, errMsg ?? res.statusText, errCode);
|
|
1370
1673
|
const { error: _e, code: _c, message: _m, ...extras } = errorBody;
|
|
1371
1674
|
if (Object.keys(extras).length > 0) apiError.extras = extras;
|
|
@@ -1381,18 +1684,22 @@ export class ParallClient {
|
|
|
1381
1684
|
return this.request('POST', ENDPOINTS.TASKS(orgId), data);
|
|
1382
1685
|
}
|
|
1383
1686
|
|
|
1384
|
-
async getTasks(
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
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>> {
|
|
1396
1703
|
return this.request('GET', ENDPOINTS.TASKS(orgId), undefined, params);
|
|
1397
1704
|
}
|
|
1398
1705
|
|
|
@@ -1405,7 +1712,12 @@ export class ParallClient {
|
|
|
1405
1712
|
}
|
|
1406
1713
|
|
|
1407
1714
|
async deleteTask(orgId: string, taskId: string, opts?: { force?: boolean }): Promise<void> {
|
|
1408
|
-
return this.request(
|
|
1715
|
+
return this.request(
|
|
1716
|
+
'DELETE',
|
|
1717
|
+
ENDPOINTS.TASK(orgId, taskId),
|
|
1718
|
+
undefined,
|
|
1719
|
+
opts?.force ? { force: 'true' } : undefined,
|
|
1720
|
+
);
|
|
1409
1721
|
}
|
|
1410
1722
|
|
|
1411
1723
|
async archiveTask(orgId: string, taskId: string): Promise<void> {
|
|
@@ -1425,10 +1737,21 @@ export class ParallClient {
|
|
|
1425
1737
|
}
|
|
1426
1738
|
|
|
1427
1739
|
async getTaskWatchers(orgId: string, taskId: string): Promise<TaskWatcher[]> {
|
|
1428
|
-
const res = await this.request<{ data: TaskWatcher[] }>(
|
|
1740
|
+
const res = await this.request<{ data: TaskWatcher[] }>(
|
|
1741
|
+
'GET',
|
|
1742
|
+
ENDPOINTS.TASK_WATCHERS(orgId, taskId),
|
|
1743
|
+
);
|
|
1429
1744
|
return res.data;
|
|
1430
1745
|
}
|
|
1431
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
|
+
|
|
1432
1755
|
async watchThread(threadRootId: string): Promise<void> {
|
|
1433
1756
|
return this.request('POST', ENDPOINTS.MESSAGE_WATCH(threadRootId));
|
|
1434
1757
|
}
|
|
@@ -1438,26 +1761,42 @@ export class ParallClient {
|
|
|
1438
1761
|
}
|
|
1439
1762
|
|
|
1440
1763
|
async getThreadWatchers(threadRootId: string): Promise<ThreadWatcher[]> {
|
|
1441
|
-
const res = await this.request<{ data: ThreadWatcher[] }>(
|
|
1764
|
+
const res = await this.request<{ data: ThreadWatcher[] }>(
|
|
1765
|
+
'GET',
|
|
1766
|
+
ENDPOINTS.MESSAGE_WATCHERS(threadRootId),
|
|
1767
|
+
);
|
|
1442
1768
|
return res.data;
|
|
1443
1769
|
}
|
|
1444
1770
|
|
|
1445
1771
|
async isWatchingThread(threadRootId: string): Promise<boolean> {
|
|
1446
|
-
const res = await this.request<{ watching: boolean }>(
|
|
1772
|
+
const res = await this.request<{ watching: boolean }>(
|
|
1773
|
+
'GET',
|
|
1774
|
+
ENDPOINTS.MESSAGE_WATCHING(threadRootId),
|
|
1775
|
+
);
|
|
1447
1776
|
return res.watching;
|
|
1448
1777
|
}
|
|
1449
1778
|
|
|
1450
1779
|
async getSubtasks(orgId: string, taskId: string): Promise<Task[]> {
|
|
1451
|
-
const res = await this.request<PaginatedResponse<Task>>(
|
|
1780
|
+
const res = await this.request<PaginatedResponse<Task>>(
|
|
1781
|
+
'GET',
|
|
1782
|
+
ENDPOINTS.TASK_SUBTASKS(orgId, taskId),
|
|
1783
|
+
);
|
|
1452
1784
|
return res.data;
|
|
1453
1785
|
}
|
|
1454
1786
|
|
|
1455
|
-
async createTaskRelation(
|
|
1787
|
+
async createTaskRelation(
|
|
1788
|
+
orgId: string,
|
|
1789
|
+
taskId: string,
|
|
1790
|
+
data: CreateTaskRelationRequest,
|
|
1791
|
+
): Promise<TaskRelation> {
|
|
1456
1792
|
return this.request('POST', ENDPOINTS.TASK_RELATIONS(orgId, taskId), data);
|
|
1457
1793
|
}
|
|
1458
1794
|
|
|
1459
1795
|
async getTaskRelations(orgId: string, taskId: string): Promise<TaskRelation[]> {
|
|
1460
|
-
const res = await this.request<{ data: TaskRelation[] }>(
|
|
1796
|
+
const res = await this.request<{ data: TaskRelation[] }>(
|
|
1797
|
+
'GET',
|
|
1798
|
+
ENDPOINTS.TASK_RELATIONS(orgId, taskId),
|
|
1799
|
+
);
|
|
1461
1800
|
return res.data;
|
|
1462
1801
|
}
|
|
1463
1802
|
|
|
@@ -1482,9 +1821,15 @@ export class ParallClient {
|
|
|
1482
1821
|
|
|
1483
1822
|
// ---- Task Comments ----
|
|
1484
1823
|
|
|
1485
|
-
async getTaskComments(
|
|
1486
|
-
|
|
1487
|
-
|
|
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>> {
|
|
1488
1833
|
return this.request('GET', ENDPOINTS.TASK_COMMENTS(orgId, taskId), undefined, params);
|
|
1489
1834
|
}
|
|
1490
1835
|
|
|
@@ -1492,11 +1837,20 @@ export class ParallClient {
|
|
|
1492
1837
|
return this.request('GET', ENDPOINTS.TASK_COMMENT(orgId, taskId, commentId));
|
|
1493
1838
|
}
|
|
1494
1839
|
|
|
1495
|
-
async createTaskComment(
|
|
1840
|
+
async createTaskComment(
|
|
1841
|
+
orgId: string,
|
|
1842
|
+
taskId: string,
|
|
1843
|
+
data: CreateTaskCommentRequest,
|
|
1844
|
+
): Promise<TaskComment> {
|
|
1496
1845
|
return this.request('POST', ENDPOINTS.TASK_COMMENTS(orgId, taskId), data);
|
|
1497
1846
|
}
|
|
1498
1847
|
|
|
1499
|
-
async updateTaskComment(
|
|
1848
|
+
async updateTaskComment(
|
|
1849
|
+
orgId: string,
|
|
1850
|
+
taskId: string,
|
|
1851
|
+
commentId: string,
|
|
1852
|
+
data: UpdateTaskCommentRequest,
|
|
1853
|
+
): Promise<TaskComment> {
|
|
1500
1854
|
return this.request('PATCH', ENDPOINTS.TASK_COMMENT(orgId, taskId, commentId), data);
|
|
1501
1855
|
}
|
|
1502
1856
|
|
|
@@ -1506,9 +1860,14 @@ export class ParallClient {
|
|
|
1506
1860
|
|
|
1507
1861
|
// ---- Task Activities ----
|
|
1508
1862
|
|
|
1509
|
-
async getTaskActivities(
|
|
1510
|
-
|
|
1511
|
-
|
|
1863
|
+
async getTaskActivities(
|
|
1864
|
+
orgId: string,
|
|
1865
|
+
taskId: string,
|
|
1866
|
+
params?: {
|
|
1867
|
+
limit?: number;
|
|
1868
|
+
cursor?: string;
|
|
1869
|
+
},
|
|
1870
|
+
): Promise<PaginatedResponse<TaskActivity>> {
|
|
1512
1871
|
return this.request('GET', ENDPOINTS.TASK_ACTIVITIES(orgId, taskId), undefined, params);
|
|
1513
1872
|
}
|
|
1514
1873
|
|
|
@@ -1527,7 +1886,11 @@ export class ParallClient {
|
|
|
1527
1886
|
return this.request('GET', ENDPOINTS.PROJECT(orgId, projectId));
|
|
1528
1887
|
}
|
|
1529
1888
|
|
|
1530
|
-
async updateProject(
|
|
1889
|
+
async updateProject(
|
|
1890
|
+
orgId: string,
|
|
1891
|
+
projectId: string,
|
|
1892
|
+
data: UpdateProjectRequest,
|
|
1893
|
+
): Promise<Project> {
|
|
1531
1894
|
return this.request('PATCH', ENDPOINTS.PROJECT(orgId, projectId), data);
|
|
1532
1895
|
}
|
|
1533
1896
|
|
|
@@ -1541,15 +1904,27 @@ export class ParallClient {
|
|
|
1541
1904
|
return this.request('POST', ENDPOINTS.SCHEDULES(orgId), input);
|
|
1542
1905
|
}
|
|
1543
1906
|
|
|
1544
|
-
async listSchedules(
|
|
1545
|
-
|
|
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
|
+
);
|
|
1546
1917
|
}
|
|
1547
1918
|
|
|
1548
1919
|
async getSchedule(orgId: string, scheduleId: string): Promise<Schedule> {
|
|
1549
1920
|
return this.request('GET', ENDPOINTS.SCHEDULE(orgId, scheduleId));
|
|
1550
1921
|
}
|
|
1551
1922
|
|
|
1552
|
-
async updateSchedule(
|
|
1923
|
+
async updateSchedule(
|
|
1924
|
+
orgId: string,
|
|
1925
|
+
scheduleId: string,
|
|
1926
|
+
patch: UpdateScheduleInput,
|
|
1927
|
+
): Promise<Schedule> {
|
|
1553
1928
|
return this.request('PATCH', ENDPOINTS.SCHEDULE(orgId, scheduleId), patch);
|
|
1554
1929
|
}
|
|
1555
1930
|
|
|
@@ -1601,31 +1976,59 @@ export class ParallClient {
|
|
|
1601
1976
|
return this.request('GET', ENDPOINTS.WIKI(orgId, wikiId));
|
|
1602
1977
|
}
|
|
1603
1978
|
|
|
1604
|
-
async getWikiTree(
|
|
1979
|
+
async getWikiTree(
|
|
1980
|
+
orgId: string,
|
|
1981
|
+
wikiId: string,
|
|
1982
|
+
params?: { ref?: string; path?: string },
|
|
1983
|
+
): Promise<WikiTreeResponse> {
|
|
1605
1984
|
return this.request('GET', ENDPOINTS.WIKI_TREE(orgId, wikiId), undefined, params);
|
|
1606
1985
|
}
|
|
1607
1986
|
|
|
1608
|
-
async getWikiBlob(
|
|
1987
|
+
async getWikiBlob(
|
|
1988
|
+
orgId: string,
|
|
1989
|
+
wikiId: string,
|
|
1990
|
+
params: { path: string; ref?: string },
|
|
1991
|
+
): Promise<WikiBlob> {
|
|
1609
1992
|
return this.request('GET', ENDPOINTS.WIKI_BLOB(orgId, wikiId), undefined, params);
|
|
1610
1993
|
}
|
|
1611
1994
|
|
|
1612
|
-
async getWikiNodeSections(
|
|
1995
|
+
async getWikiNodeSections(
|
|
1996
|
+
orgId: string,
|
|
1997
|
+
wikiId: string,
|
|
1998
|
+
params?: { ref?: string },
|
|
1999
|
+
): Promise<WikiNodeSectionArtifact> {
|
|
1613
2000
|
return this.request('GET', ENDPOINTS.WIKI_NODE_SECTIONS(orgId, wikiId), undefined, params);
|
|
1614
2001
|
}
|
|
1615
2002
|
|
|
1616
|
-
async searchWiki(
|
|
2003
|
+
async searchWiki(
|
|
2004
|
+
orgId: string,
|
|
2005
|
+
wikiId: string,
|
|
2006
|
+
params: { q: string; limit?: number; path_prefix?: string; ref?: string },
|
|
2007
|
+
): Promise<WikiSearchResponse> {
|
|
1617
2008
|
return this.request('GET', ENDPOINTS.WIKI_SEARCH(orgId, wikiId), undefined, params);
|
|
1618
2009
|
}
|
|
1619
2010
|
|
|
1620
|
-
async getWikiPageIndex(
|
|
2011
|
+
async getWikiPageIndex(
|
|
2012
|
+
orgId: string,
|
|
2013
|
+
wikiId: string,
|
|
2014
|
+
params?: { ref?: string },
|
|
2015
|
+
): Promise<WikiPageIndex> {
|
|
1621
2016
|
return this.request('GET', ENDPOINTS.WIKI_PAGE_INDEX(orgId, wikiId), undefined, params);
|
|
1622
2017
|
}
|
|
1623
2018
|
|
|
1624
|
-
async getWikiRefs(
|
|
2019
|
+
async getWikiRefs(
|
|
2020
|
+
orgId: string,
|
|
2021
|
+
wikiId: string,
|
|
2022
|
+
params?: { ref?: string },
|
|
2023
|
+
): Promise<WikiRefsResponse> {
|
|
1625
2024
|
return this.request('GET', ENDPOINTS.WIKI_REFS(orgId, wikiId), undefined, params);
|
|
1626
2025
|
}
|
|
1627
2026
|
|
|
1628
|
-
async checkWikiRefs(
|
|
2027
|
+
async checkWikiRefs(
|
|
2028
|
+
orgId: string,
|
|
2029
|
+
wikiId: string,
|
|
2030
|
+
params?: { ref?: string },
|
|
2031
|
+
): Promise<WikiRefsCheckResponse> {
|
|
1629
2032
|
return this.request('GET', ENDPOINTS.WIKI_REFS_CHECK(orgId, wikiId), undefined, params);
|
|
1630
2033
|
}
|
|
1631
2034
|
|
|
@@ -1639,17 +2042,32 @@ export class ParallClient {
|
|
|
1639
2042
|
return this.request('POST', ENDPOINTS.WIKI_ANCHOR_STATUS(orgId, wikiId), body);
|
|
1640
2043
|
}
|
|
1641
2044
|
|
|
1642
|
-
async createWikiChangeset(
|
|
1643
|
-
|
|
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
|
+
);
|
|
1644
2053
|
}
|
|
1645
2054
|
|
|
1646
2055
|
async getWikiChangesets(orgId: string, wikiId: string): Promise<WikiChangeset[]> {
|
|
1647
|
-
const res = await this.request<{ data: WikiChangeset[] }>(
|
|
2056
|
+
const res = await this.request<{ data: WikiChangeset[] }>(
|
|
2057
|
+
'GET',
|
|
2058
|
+
ENDPOINTS.WIKI_CHANGESETS(orgId, wikiId),
|
|
2059
|
+
);
|
|
1648
2060
|
return res.data.map(normalizeWikiChangeset);
|
|
1649
2061
|
}
|
|
1650
2062
|
|
|
1651
|
-
async getWikiChangeset(
|
|
1652
|
-
|
|
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
|
+
);
|
|
1653
2071
|
}
|
|
1654
2072
|
|
|
1655
2073
|
async updateWikiChangeset(
|
|
@@ -1658,19 +2076,37 @@ export class ParallClient {
|
|
|
1658
2076
|
changesetId: string,
|
|
1659
2077
|
data: UpdateWikiChangesetRequest,
|
|
1660
2078
|
): Promise<WikiChangeset> {
|
|
1661
|
-
return normalizeWikiChangeset(
|
|
2079
|
+
return normalizeWikiChangeset(
|
|
2080
|
+
await this.request('PATCH', ENDPOINTS.WIKI_CHANGESET(orgId, wikiId, changesetId), data),
|
|
2081
|
+
);
|
|
1662
2082
|
}
|
|
1663
2083
|
|
|
1664
|
-
async getWikiChangesetDiff(
|
|
2084
|
+
async getWikiChangesetDiff(
|
|
2085
|
+
orgId: string,
|
|
2086
|
+
wikiId: string,
|
|
2087
|
+
changesetId: string,
|
|
2088
|
+
): Promise<WikiDiff> {
|
|
1665
2089
|
return this.request('GET', ENDPOINTS.WIKI_CHANGESET_DIFF(orgId, wikiId, changesetId));
|
|
1666
2090
|
}
|
|
1667
2091
|
|
|
1668
|
-
async mergeWikiChangeset(
|
|
1669
|
-
|
|
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
|
+
);
|
|
1670
2100
|
}
|
|
1671
2101
|
|
|
1672
|
-
async closeWikiChangeset(
|
|
1673
|
-
|
|
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
|
+
);
|
|
1674
2110
|
}
|
|
1675
2111
|
|
|
1676
2112
|
// ---- Wiki Binary Upload / Delete (Phase 2 of wiki-file-storage-design) ----
|
|
@@ -1727,12 +2163,10 @@ export class ParallClient {
|
|
|
1727
2163
|
wikiId: string,
|
|
1728
2164
|
params: { path: string; message?: string },
|
|
1729
2165
|
): Promise<void> {
|
|
1730
|
-
await this.request(
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
{ path: params.path, message: params.message },
|
|
1735
|
-
);
|
|
2166
|
+
await this.request('DELETE', ENDPOINTS.WIKI_FILES(orgId, wikiId), undefined, {
|
|
2167
|
+
path: params.path,
|
|
2168
|
+
message: params.message,
|
|
2169
|
+
});
|
|
1736
2170
|
}
|
|
1737
2171
|
|
|
1738
2172
|
/**
|
|
@@ -1745,21 +2179,24 @@ export class ParallClient {
|
|
|
1745
2179
|
wikiId: string,
|
|
1746
2180
|
params: { path: string; ref?: string },
|
|
1747
2181
|
): Promise<WikiFilePreviewUrlResponse> {
|
|
1748
|
-
return this.request(
|
|
1749
|
-
'POST',
|
|
1750
|
-
ENDPOINTS.WIKI_FILE_PREVIEW_URL(orgId, wikiId),
|
|
1751
|
-
params,
|
|
1752
|
-
);
|
|
2182
|
+
return this.request('POST', ENDPOINTS.WIKI_FILE_PREVIEW_URL(orgId, wikiId), params);
|
|
1753
2183
|
}
|
|
1754
2184
|
|
|
1755
2185
|
// ---- Wiki Path Scopes (AFCS ACL) ----
|
|
1756
2186
|
|
|
1757
2187
|
async getWikiPathScopes(orgId: string, wikiId: string): Promise<WikiPathScope[]> {
|
|
1758
|
-
const res = await this.request<{ data: WikiPathScope[] }>(
|
|
2188
|
+
const res = await this.request<{ data: WikiPathScope[] }>(
|
|
2189
|
+
'GET',
|
|
2190
|
+
ENDPOINTS.WIKI_PATH_SCOPES(orgId, wikiId),
|
|
2191
|
+
);
|
|
1759
2192
|
return res.data;
|
|
1760
2193
|
}
|
|
1761
2194
|
|
|
1762
|
-
async createWikiPathScope(
|
|
2195
|
+
async createWikiPathScope(
|
|
2196
|
+
orgId: string,
|
|
2197
|
+
wikiId: string,
|
|
2198
|
+
data: CreateWikiPathScopeRequest,
|
|
2199
|
+
): Promise<WikiPathScope> {
|
|
1763
2200
|
return this.request('POST', ENDPOINTS.WIKI_PATH_SCOPES(orgId, wikiId), data);
|
|
1764
2201
|
}
|
|
1765
2202
|
|
|
@@ -1767,11 +2204,24 @@ export class ParallClient {
|
|
|
1767
2204
|
await this.request('DELETE', ENDPOINTS.WIKI_PATH_SCOPE(orgId, wikiId, scopeId));
|
|
1768
2205
|
}
|
|
1769
2206
|
|
|
1770
|
-
async getWikiAccessStatus(
|
|
1771
|
-
|
|
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
|
+
);
|
|
1772
2218
|
}
|
|
1773
2219
|
|
|
1774
|
-
async createWikiAccessRequest(
|
|
2220
|
+
async createWikiAccessRequest(
|
|
2221
|
+
orgId: string,
|
|
2222
|
+
wikiId: string,
|
|
2223
|
+
data: CreateWikiAccessRequest,
|
|
2224
|
+
): Promise<void> {
|
|
1775
2225
|
await this.request('POST', ENDPOINTS.WIKI_ACCESS_REQUESTS(orgId, wikiId), data);
|
|
1776
2226
|
}
|
|
1777
2227
|
|
|
@@ -1791,7 +2241,10 @@ export class ParallClient {
|
|
|
1791
2241
|
path: string,
|
|
1792
2242
|
params?: { page?: number; limit?: number },
|
|
1793
2243
|
): Promise<{ data: WikiCommit[]; page: number; limit: number }> {
|
|
1794
|
-
return this.request('GET', ENDPOINTS.WIKI_FILE_COMMITS(orgId, wikiId), undefined, {
|
|
2244
|
+
return this.request('GET', ENDPOINTS.WIKI_FILE_COMMITS(orgId, wikiId), undefined, {
|
|
2245
|
+
path,
|
|
2246
|
+
...params,
|
|
2247
|
+
});
|
|
1795
2248
|
}
|
|
1796
2249
|
|
|
1797
2250
|
async getWikiBlame(
|
|
@@ -1826,8 +2279,20 @@ export class ParallClient {
|
|
|
1826
2279
|
async getComments(
|
|
1827
2280
|
orgId: string,
|
|
1828
2281
|
params:
|
|
1829
|
-
| {
|
|
1830
|
-
|
|
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
|
+
},
|
|
1831
2296
|
): Promise<PaginatedResponse<Comment>> {
|
|
1832
2297
|
return this.request('GET', ENDPOINTS.COMMENTS(orgId), undefined, params);
|
|
1833
2298
|
}
|
|
@@ -1840,7 +2305,11 @@ export class ParallClient {
|
|
|
1840
2305
|
return this.request('POST', ENDPOINTS.COMMENTS(orgId), data);
|
|
1841
2306
|
}
|
|
1842
2307
|
|
|
1843
|
-
async updateComment(
|
|
2308
|
+
async updateComment(
|
|
2309
|
+
orgId: string,
|
|
2310
|
+
commentId: string,
|
|
2311
|
+
data: UpdateCommentRequest,
|
|
2312
|
+
): Promise<Comment> {
|
|
1844
2313
|
return this.request('PATCH', ENDPOINTS.COMMENT(orgId, commentId), data);
|
|
1845
2314
|
}
|
|
1846
2315
|
|
|
@@ -1850,7 +2319,11 @@ export class ParallClient {
|
|
|
1850
2319
|
|
|
1851
2320
|
// ---- References ----
|
|
1852
2321
|
|
|
1853
|
-
async resolveRefs(
|
|
2322
|
+
async resolveRefs(
|
|
2323
|
+
orgId: string,
|
|
2324
|
+
refs: string[],
|
|
2325
|
+
options?: { sourceMessageId?: string },
|
|
2326
|
+
): Promise<ResolveRefsResponse> {
|
|
1854
2327
|
const body: Record<string, unknown> = { refs };
|
|
1855
2328
|
if (options?.sourceMessageId) {
|
|
1856
2329
|
body.source_message_id = options.sourceMessageId;
|
|
@@ -1889,7 +2362,9 @@ export class ParallClient {
|
|
|
1889
2362
|
return this.request('GET', ENDPOINTS.NOTIFICATION_PREFERENCES);
|
|
1890
2363
|
}
|
|
1891
2364
|
|
|
1892
|
-
async updateNotificationPreferences(
|
|
2365
|
+
async updateNotificationPreferences(
|
|
2366
|
+
prefs: Partial<NotifPrefs>,
|
|
2367
|
+
): Promise<NotificationPreferences> {
|
|
1893
2368
|
return this.request('PATCH', ENDPOINTS.NOTIFICATION_PREFERENCES, { prefs });
|
|
1894
2369
|
}
|
|
1895
2370
|
|
|
@@ -1905,7 +2380,20 @@ export class ParallClient {
|
|
|
1905
2380
|
return this.request('GET', ENDPOINTS.BILLING(orgId));
|
|
1906
2381
|
}
|
|
1907
2382
|
|
|
1908
|
-
async listBillingTransactions(
|
|
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 }> {
|
|
1909
2397
|
const params = new URLSearchParams();
|
|
1910
2398
|
if (opts?.cursor) params.set('cursor', opts.cursor);
|
|
1911
2399
|
if (opts?.limit) params.set('limit', String(opts.limit));
|
|
@@ -1920,14 +2408,20 @@ export class ParallClient {
|
|
|
1920
2408
|
return this.request('GET', `${ENDPOINTS.BILLING_TRANSACTIONS(orgId)}${qs ? `?${qs}` : ''}`);
|
|
1921
2409
|
}
|
|
1922
2410
|
|
|
1923
|
-
async listBillingTransactionAgentGroups(
|
|
2411
|
+
async listBillingTransactionAgentGroups(
|
|
2412
|
+
orgId: string,
|
|
2413
|
+
opts?: { from?: string; to?: string },
|
|
2414
|
+
): Promise<{ groups: CreditTransactionAgentGroup[] }> {
|
|
1924
2415
|
const params = new URLSearchParams({ group_by: 'agent' });
|
|
1925
2416
|
if (opts?.from) params.set('from', opts.from);
|
|
1926
2417
|
if (opts?.to) params.set('to', opts.to);
|
|
1927
2418
|
return this.request('GET', `${ENDPOINTS.BILLING_TRANSACTIONS(orgId)}?${params}`);
|
|
1928
2419
|
}
|
|
1929
2420
|
|
|
1930
|
-
async listBillingTransactionMachineGroups(
|
|
2421
|
+
async listBillingTransactionMachineGroups(
|
|
2422
|
+
orgId: string,
|
|
2423
|
+
opts?: { from?: string; to?: string },
|
|
2424
|
+
): Promise<{ groups: CreditTransactionMachineGroup[] }> {
|
|
1931
2425
|
const params = new URLSearchParams({ group_by: 'machine' });
|
|
1932
2426
|
if (opts?.from) params.set('from', opts.from);
|
|
1933
2427
|
if (opts?.to) params.set('to', opts.to);
|
|
@@ -1953,7 +2447,10 @@ export class ParallClient {
|
|
|
1953
2447
|
return this.request('GET', ENDPOINTS.BILLING_AUTO_RELOAD(orgId));
|
|
1954
2448
|
}
|
|
1955
2449
|
|
|
1956
|
-
async updateAutoReloadSettings(
|
|
2450
|
+
async updateAutoReloadSettings(
|
|
2451
|
+
orgId: string,
|
|
2452
|
+
req: UpdateAutoReloadRequest,
|
|
2453
|
+
): Promise<AutoReloadSettings> {
|
|
1957
2454
|
return this.request('PUT', ENDPOINTS.BILLING_AUTO_RELOAD(orgId), req);
|
|
1958
2455
|
}
|
|
1959
2456
|
|
|
@@ -1964,7 +2461,78 @@ export class ParallClient {
|
|
|
1964
2461
|
// own thin client (`ts/admin/lib/api.ts`) that hits these directly.
|
|
1965
2462
|
|
|
1966
2463
|
async getComputePricing(): Promise<ComputePricingResponse> {
|
|
1967
|
-
const resp = await this.request<{ data: ComputePricingResponse }>(
|
|
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);
|
|
1968
2536
|
return resp.data;
|
|
1969
2537
|
}
|
|
1970
2538
|
}
|