@parall/sdk 1.12.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.
@@ -0,0 +1,265 @@
1
+ // API base path
2
+ export const API_BASE = '/api/v1';
3
+
4
+ // Wiki-service base path (served by wiki-service, routed via LB path rules)
5
+ export const WIKI_BASE = '/wiki/v1';
6
+
7
+ // REST endpoints
8
+ export const ENDPOINTS = {
9
+ // Auth
10
+ AUTH_REGISTER: `${API_BASE}/auth/register`,
11
+ AUTH_LOGIN: `${API_BASE}/auth/login`,
12
+ AUTH_REFRESH: `${API_BASE}/auth/refresh`,
13
+ AUTH_LOGOUT: `${API_BASE}/auth/logout`,
14
+ AUTH_CHECK_EMAIL: `${API_BASE}/auth/check-email`,
15
+ AUTH_VERIFY_EMAIL: `${API_BASE}/auth/verify-email`,
16
+ AUTH_RESEND_CODE: `${API_BASE}/auth/resend-code`,
17
+
18
+ // Users
19
+ USERS_ME: `${API_BASE}/users/me`,
20
+ USER: (id: string) => `${API_BASE}/users/${id}`,
21
+
22
+ // WebSocket ticket
23
+ WS_TICKET: `${API_BASE}/ws/ticket`,
24
+
25
+ // Organizations (global)
26
+ ORGS: `${API_BASE}/orgs`,
27
+ // Org-scoped
28
+ ORG: (orgId: string) => `${API_BASE}/orgs/${orgId}`,
29
+ ORG_MEMBERS: (orgId: string) => `${API_BASE}/orgs/${orgId}/members`,
30
+ ORG_MEMBERS_ONLINE: (orgId: string) => `${API_BASE}/orgs/${orgId}/members/online`,
31
+ ORG_MEMBER: (orgId: string, userId: string) =>
32
+ `${API_BASE}/orgs/${orgId}/members/${userId}`,
33
+
34
+ // Direct messages (org-scoped, atomic find-or-create + send)
35
+ DM: (orgId: string) => `${API_BASE}/orgs/${orgId}/dm`,
36
+
37
+ // Chats (org-scoped)
38
+ CHATS: (orgId: string) => `${API_BASE}/orgs/${orgId}/chats`,
39
+ CHAT: (orgId: string, chatId: string) => `${API_BASE}/orgs/${orgId}/chats/${chatId}`,
40
+ CHAT_MEMBERS: (orgId: string, chatId: string) =>
41
+ `${API_BASE}/orgs/${orgId}/chats/${chatId}/members`,
42
+ CHAT_MEMBER: (orgId: string, chatId: string, userId: string) =>
43
+ `${API_BASE}/orgs/${orgId}/chats/${chatId}/members/${userId}`,
44
+ CHAT_MESSAGES: (orgId: string, chatId: string) =>
45
+ `${API_BASE}/orgs/${orgId}/chats/${chatId}/messages`,
46
+
47
+ // Messages (global, by message ID)
48
+ MESSAGE: (id: string) => `${API_BASE}/messages/${id}`,
49
+ MESSAGE_PATCHES: (id: string) => `${API_BASE}/messages/${id}/patches`,
50
+ MESSAGE_REPLIES: (id: string) => `${API_BASE}/messages/${id}/replies`,
51
+
52
+ // Upload (org-scoped)
53
+ UPLOAD_PRESIGN: (orgId: string) => `${API_BASE}/orgs/${orgId}/upload/presign`,
54
+ UPLOAD_COMPLETE: (orgId: string) => `${API_BASE}/orgs/${orgId}/upload/complete`,
55
+ FILE: (id: string) => `${API_BASE}/files/${id}`,
56
+
57
+ // Approvals (global)
58
+ APPROVAL_DECIDE: (id: string) => `${API_BASE}/approvals/${id}/decide`,
59
+ APPROVALS_PENDING: `${API_BASE}/approvals/pending`,
60
+
61
+ // Agents (org-scoped)
62
+ AGENTS: (orgId: string) => `${API_BASE}/orgs/${orgId}/agents`,
63
+ AGENT: (orgId: string, agentId: string) => `${API_BASE}/orgs/${orgId}/agents/${agentId}`,
64
+ AGENT_API_KEYS: (orgId: string, agentId: string) =>
65
+ `${API_BASE}/orgs/${orgId}/agents/${agentId}/api-keys`,
66
+ AGENT_API_KEY: (orgId: string, agentId: string, key: string) =>
67
+ `${API_BASE}/orgs/${orgId}/agents/${agentId}/api-keys/${key}`,
68
+ AGENT_ACTIVITY: (orgId: string, agentId: string) =>
69
+ `${API_BASE}/orgs/${orgId}/agents/${agentId}/activity`,
70
+ AGENT_MONITOR: (orgId: string, agentId: string) =>
71
+ `${API_BASE}/orgs/${orgId}/agents/${agentId}/monitor`,
72
+ AGENT_ME: (orgId: string) =>
73
+ `${API_BASE}/orgs/${orgId}/agents/me`,
74
+ AGENT_SESSIONS: (orgId: string, agentId: string) =>
75
+ `${API_BASE}/orgs/${orgId}/agents/${agentId}/sessions`,
76
+ AGENT_SESSION: (orgId: string, agentId: string, sessionId: string) =>
77
+ `${API_BASE}/orgs/${orgId}/agents/${agentId}/sessions/${sessionId}`,
78
+ AGENT_SESSION_STEPS: (orgId: string, agentId: string, sessionId: string) =>
79
+ `${API_BASE}/orgs/${orgId}/agents/${agentId}/sessions/${sessionId}/steps`,
80
+ AGENT_TASKS: (orgId: string, agentId: string) =>
81
+ `${API_BASE}/orgs/${orgId}/agents/${agentId}/tasks`,
82
+ // Machines (org-scoped)
83
+ MACHINES: (orgId: string) => `${API_BASE}/orgs/${orgId}/machines`,
84
+ MACHINE: (orgId: string, machineId: string) =>
85
+ `${API_BASE}/orgs/${orgId}/machines/${machineId}`,
86
+ MACHINE_START: (orgId: string, machineId: string) =>
87
+ `${API_BASE}/orgs/${orgId}/machines/${machineId}/start`,
88
+ MACHINE_STOP: (orgId: string, machineId: string) =>
89
+ `${API_BASE}/orgs/${orgId}/machines/${machineId}/stop`,
90
+ MACHINE_STATUS: (orgId: string, machineId: string) =>
91
+ `${API_BASE}/orgs/${orgId}/machines/${machineId}/status`,
92
+ MACHINE_LOGS: (orgId: string, machineId: string) =>
93
+ `${API_BASE}/orgs/${orgId}/machines/${machineId}/logs`,
94
+ MACHINE_RESTART: (orgId: string, machineId: string) =>
95
+ `${API_BASE}/orgs/${orgId}/machines/${machineId}/restart`,
96
+ MACHINE_RESTART_ALL: (orgId: string) =>
97
+ `${API_BASE}/orgs/${orgId}/machines/restart-all`,
98
+ MACHINE_WORKSPACE: (orgId: string, machineId: string) =>
99
+ `${API_BASE}/orgs/${orgId}/machines/${machineId}/workspace`,
100
+ // Tasks (org-scoped)
101
+ TASKS: (orgId: string) => `${API_BASE}/orgs/${orgId}/tasks`,
102
+ TASK: (orgId: string, taskId: string) => `${API_BASE}/orgs/${orgId}/tasks/${taskId}`,
103
+ TASK_SUBTASKS: (orgId: string, taskId: string) =>
104
+ `${API_BASE}/orgs/${orgId}/tasks/${taskId}/subtasks`,
105
+ TASK_RELATIONS: (orgId: string, taskId: string) =>
106
+ `${API_BASE}/orgs/${orgId}/tasks/${taskId}/relations`,
107
+ TASK_RELATION: (orgId: string, taskId: string, relId: string) =>
108
+ `${API_BASE}/orgs/${orgId}/tasks/${taskId}/relations/${relId}`,
109
+ TASK_COMMENTS: (orgId: string, taskId: string) =>
110
+ `${API_BASE}/orgs/${orgId}/tasks/${taskId}/comments`,
111
+ TASK_COMMENT: (orgId: string, taskId: string, commentId: string) =>
112
+ `${API_BASE}/orgs/${orgId}/tasks/${taskId}/comments/${commentId}`,
113
+ TASK_ACTIVITIES: (orgId: string, taskId: string) =>
114
+ `${API_BASE}/orgs/${orgId}/tasks/${taskId}/activities`,
115
+
116
+ // Projects (org-scoped)
117
+ PROJECTS: (orgId: string) => `${API_BASE}/orgs/${orgId}/projects`,
118
+ PROJECT: (orgId: string, projectId: string) => `${API_BASE}/orgs/${orgId}/projects/${projectId}`,
119
+
120
+ // Invitations (org-scoped, admin)
121
+ ORG_INVITATIONS: (orgId: string) => `${API_BASE}/orgs/${orgId}/invitations`,
122
+ ORG_INVITATION: (orgId: string, invId: string) =>
123
+ `${API_BASE}/orgs/${orgId}/invitations/${invId}`,
124
+ ORG_INVITATION_RESEND: (orgId: string, invId: string) =>
125
+ `${API_BASE}/orgs/${orgId}/invitations/${invId}/resend`,
126
+
127
+ // Invitations (invitee)
128
+ MY_INVITATIONS: `${API_BASE}/invitations/pending`,
129
+ INVITATION_ACCEPT: (id: string) => `${API_BASE}/invitations/${id}/accept`,
130
+ INVITATION_DECLINE: (id: string) => `${API_BASE}/invitations/${id}/decline`,
131
+ INVITATION_BY_TOKEN: (token: string) => `${API_BASE}/invitations/by-token/${token}`,
132
+
133
+ // Wikis (org-scoped, served by wiki-service)
134
+ WIKIS: (orgId: string) => `${WIKI_BASE}/orgs/${orgId}/wikis`,
135
+ WIKI: (orgId: string, wikiId: string) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}`,
136
+ WIKI_TREE: (orgId: string, wikiId: string) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/tree`,
137
+ WIKI_BLOB: (orgId: string, wikiId: string) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/blob`,
138
+ WIKI_NODE_SECTIONS: (orgId: string, wikiId: string) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/node-sections`,
139
+ WIKI_SEARCH: (orgId: string, wikiId: string) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/search`,
140
+ WIKI_PAGE_INDEX: (orgId: string, wikiId: string) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/page-index`,
141
+ WIKI_REFS: (orgId: string, wikiId: string) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/refs`,
142
+ WIKI_REFS_CHECK: (orgId: string, wikiId: string) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/refs/check`,
143
+ WIKI_CHANGESETS: (orgId: string, wikiId: string) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/changesets`,
144
+ WIKI_CHANGESET: (orgId: string, wikiId: string, changesetId: string) =>
145
+ `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/changesets/${changesetId}`,
146
+ WIKI_CHANGESET_DIFF: (orgId: string, wikiId: string, changesetId: string) =>
147
+ `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/changesets/${changesetId}/diff`,
148
+ WIKI_CHANGESET_MERGE: (orgId: string, wikiId: string, changesetId: string) =>
149
+ `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/changesets/${changesetId}/merge`,
150
+ WIKI_CHANGESET_CLOSE: (orgId: string, wikiId: string, changesetId: string) =>
151
+ `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/changesets/${changesetId}/close`,
152
+
153
+ // Wiki Path Scopes (AFCS ACL)
154
+ WIKI_PATH_SCOPES: (orgId: string, wikiId: string) =>
155
+ `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/path-scopes`,
156
+ WIKI_PATH_SCOPE: (orgId: string, wikiId: string, scopeId: string) =>
157
+ `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/path-scopes/${scopeId}`,
158
+ WIKI_ACCESS_STATUS: (orgId: string, wikiId: string) =>
159
+ `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/access-status`,
160
+ WIKI_ACCESS_REQUESTS: (orgId: string, wikiId: string) =>
161
+ `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/access-requests`,
162
+
163
+ // Wiki History (commits, file commits, blame)
164
+ WIKI_COMMITS: (orgId: string, wikiId: string) =>
165
+ `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/commits`,
166
+ WIKI_FILE_COMMITS: (orgId: string, wikiId: string) =>
167
+ `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/file-commits`,
168
+ WIKI_BLAME: (orgId: string, wikiId: string) =>
169
+ `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/blame`,
170
+
171
+ // Wiki Operations (audit log)
172
+ WIKI_OPERATIONS: (orgId: string, wikiId: string) =>
173
+ `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/operations`,
174
+ WIKI_OPERATION_REVERT: (orgId: string, wikiId: string, opId: string) =>
175
+ `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/operations/${opId}/revert`,
176
+
177
+ // Inbox (org-scoped)
178
+ INBOX: (orgId: string) => `${API_BASE}/orgs/${orgId}/inbox`,
179
+ INBOX_UNREAD_COUNT: (orgId: string) => `${API_BASE}/orgs/${orgId}/inbox/unread-count`,
180
+ INBOX_ITEM_READ: (orgId: string, id: string) => `${API_BASE}/orgs/${orgId}/inbox/${id}/read`,
181
+ INBOX_ITEM_ARCHIVE: (orgId: string, id: string) => `${API_BASE}/orgs/${orgId}/inbox/${id}/archive`,
182
+ // Snooze/Unsnooze deferred until un-snooze cron worker is implemented
183
+ INBOX_MARK_ALL_READ: (orgId: string) => `${API_BASE}/orgs/${orgId}/inbox/mark-all-read`,
184
+ INBOX_ARCHIVE_ALL: (orgId: string) => `${API_BASE}/orgs/${orgId}/inbox/archive-all`,
185
+ INBOX_ITEM: (orgId: string, id: string) => `${API_BASE}/orgs/${orgId}/inbox/${id}`,
186
+ INBOX_ACK: (orgId: string) => `${API_BASE}/orgs/${orgId}/inbox/ack`,
187
+
188
+ // Dispatch (agent event delivery)
189
+ DISPATCH: (orgId: string) => `${API_BASE}/orgs/${orgId}/dispatch`,
190
+ DISPATCH_PENDING_COUNT: (orgId: string) => `${API_BASE}/orgs/${orgId}/dispatch/pending-count`,
191
+ DISPATCH_ACK: (orgId: string) => `${API_BASE}/orgs/${orgId}/dispatch/ack`,
192
+ DISPATCH_ACK_BY_ID: (orgId: string, id: string) => `${API_BASE}/orgs/${orgId}/dispatch/${id}/ack`,
193
+
194
+ // Unread
195
+ UNREAD: `${API_BASE}/me/unread`,
196
+ CHAT_READ: (orgId: string, chatId: string) =>
197
+ `${API_BASE}/orgs/${orgId}/chats/${chatId}/read`,
198
+
199
+ // References (org-scoped)
200
+ REFS_RESOLVE: (orgId: string) => `${API_BASE}/orgs/${orgId}/refs/resolve`,
201
+ REFS_BACKLINKS: (orgId: string) => `${API_BASE}/orgs/${orgId}/refs/backlinks`,
202
+ REFS_CHECK: (orgId: string) => `${API_BASE}/orgs/${orgId}/refs/check`,
203
+
204
+ // Platform config (agent-scoped, not org-scoped)
205
+ PLATFORM_CONFIG: `${API_BASE}/agents/platform-config`,
206
+
207
+ // Push notifications
208
+ PUSH_SUBSCRIBE: `${API_BASE}/push/subscribe`,
209
+ PUSH_UNSUBSCRIBE: `${API_BASE}/push/unsubscribe`,
210
+ PUSH_VAPID_KEY: `${API_BASE}/push/vapid-key`,
211
+
212
+ // Notification preferences
213
+ NOTIFICATION_PREFERENCES: `${API_BASE}/notification-preferences`,
214
+
215
+ } as const;
216
+
217
+ // WebSocket event types
218
+ export const WS_EVENTS = {
219
+ // Client -> Server
220
+ PING: 'ping',
221
+ TYPING: 'typing',
222
+ WATCH: 'watch',
223
+ AGENT_HEARTBEAT: 'agent.heartbeat',
224
+
225
+ // Server -> Client
226
+ HELLO: 'hello',
227
+ PONG: 'pong',
228
+ WATCHING: 'watching',
229
+ MESSAGE_NEW: 'message.new',
230
+ MESSAGE_PATCH: 'message.patch',
231
+ MESSAGE_EDIT: 'message.edit',
232
+ MESSAGE_DELETE: 'message.delete',
233
+ TYPING_UPDATE: 'typing.update',
234
+ CHAT_UPDATE: 'chat.update',
235
+ CHAT_DELETED: 'chat.deleted',
236
+ APPROVAL_UPDATE: 'approval.update', // deprecated
237
+ CARD_UPDATE: 'card.update',
238
+ RECOVERY_OVERFLOW: 'recovery.overflow',
239
+ MEMBERSHIP_CHANGED: 'membership.changed',
240
+ TASK_CREATED: 'task.created',
241
+ TASK_UPDATED: 'task.updated',
242
+ TASK_DELETED: 'task.deleted',
243
+ TASK_COMMENT_CREATED: 'task.comment.created',
244
+ TASK_COMMENT_UPDATED: 'task.comment.updated',
245
+ TASK_COMMENT_DELETED: 'task.comment.deleted',
246
+ PROJECT_CREATED: 'project.created',
247
+ PROJECT_UPDATED: 'project.updated',
248
+ PROJECT_DELETED: 'project.deleted',
249
+ AGENT_SESSION_NEW: 'agent_session.new',
250
+ AGENT_SESSION_UPDATE: 'agent_session.update',
251
+ AGENT_STEP_NEW: 'agent_step.new',
252
+ INVITATION_NEW: 'invitation.new',
253
+ INVITATION_ACCEPTED: 'invitation.accepted',
254
+ INVITATION_DECLINED: 'invitation.declined',
255
+ AGENT_CONFIG_UPDATE: 'agent_config.update',
256
+ PRESENCE_UPDATE: 'presence.update',
257
+ WIKI_CHANGESET_CREATED: 'wiki.changeset.created',
258
+ WIKI_CHANGESET_UPDATED: 'wiki.changeset.updated',
259
+ NOTIFICATION_ALERT: 'notification.alert',
260
+ INBOX_NEW: 'inbox.new',
261
+ INBOX_UPDATE: 'inbox.update',
262
+ INBOX_BULK_UPDATE: 'inbox.bulk_update',
263
+ READ_POSITION_UPDATED: 'read_position.updated',
264
+ DISPATCH_NEW: 'dispatch.new',
265
+ } as const;
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from './types.js';
2
+ export * from './constants.js';
3
+ export { ParallClient, ApiError } from './client.js';
4
+ export type { ParallClientOptions } from './client.js';
5
+ export { ParallWs } from './ws.js';
6
+ export type { ParallWsOptions, WsConnectionState, WsEventType, WsEventHandler, WsClientEventMap } from './ws.js';