@pnds/sdk 0.1.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 +117 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +282 -0
- package/dist/constants.d.ts +72 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +88 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/types.d.ts +454 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/ws.d.ts +49 -0
- package/dist/ws.d.ts.map +1 -0
- package/dist/ws.js +198 -0
- package/package.json +31 -0
- package/src/client.ts +435 -0
- package/src/constants.ts +119 -0
- package/src/index.ts +6 -0
- package/src/types.ts +569 -0
- package/src/ws.ts +250 -0
package/src/constants.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// API base path
|
|
2
|
+
export const API_BASE = '/api/v1';
|
|
3
|
+
|
|
4
|
+
// REST endpoints
|
|
5
|
+
export const ENDPOINTS = {
|
|
6
|
+
// Auth
|
|
7
|
+
AUTH_REGISTER: `${API_BASE}/auth/register`,
|
|
8
|
+
AUTH_LOGIN: `${API_BASE}/auth/login`,
|
|
9
|
+
AUTH_REFRESH: `${API_BASE}/auth/refresh`,
|
|
10
|
+
AUTH_LOGOUT: `${API_BASE}/auth/logout`,
|
|
11
|
+
AUTH_CHECK_EMAIL: `${API_BASE}/auth/check-email`,
|
|
12
|
+
AUTH_VERIFY_EMAIL: `${API_BASE}/auth/verify-email`,
|
|
13
|
+
AUTH_RESEND_CODE: `${API_BASE}/auth/resend-code`,
|
|
14
|
+
|
|
15
|
+
// Users
|
|
16
|
+
USERS_ME: `${API_BASE}/users/me`,
|
|
17
|
+
USER: (id: string) => `${API_BASE}/users/${id}`,
|
|
18
|
+
USERS_SEARCH: `${API_BASE}/users/search`,
|
|
19
|
+
|
|
20
|
+
// WebSocket ticket
|
|
21
|
+
WS_TICKET: `${API_BASE}/ws/ticket`,
|
|
22
|
+
|
|
23
|
+
// Organizations (global)
|
|
24
|
+
ORGS: `${API_BASE}/orgs`,
|
|
25
|
+
// Org-scoped
|
|
26
|
+
ORG: (orgId: string) => `${API_BASE}/orgs/${orgId}`,
|
|
27
|
+
ORG_MEMBERS: (orgId: string) => `${API_BASE}/orgs/${orgId}/members`,
|
|
28
|
+
ORG_MEMBER: (orgId: string, userId: string) =>
|
|
29
|
+
`${API_BASE}/orgs/${orgId}/members/${userId}`,
|
|
30
|
+
|
|
31
|
+
// Chats (org-scoped)
|
|
32
|
+
CHATS: (orgId: string) => `${API_BASE}/orgs/${orgId}/chats`,
|
|
33
|
+
CHAT: (orgId: string, chatId: string) => `${API_BASE}/orgs/${orgId}/chats/${chatId}`,
|
|
34
|
+
CHAT_MEMBERS: (orgId: string, chatId: string) =>
|
|
35
|
+
`${API_BASE}/orgs/${orgId}/chats/${chatId}/members`,
|
|
36
|
+
CHAT_MEMBER: (orgId: string, chatId: string, userId: string) =>
|
|
37
|
+
`${API_BASE}/orgs/${orgId}/chats/${chatId}/members/${userId}`,
|
|
38
|
+
CHAT_MESSAGES: (orgId: string, chatId: string) =>
|
|
39
|
+
`${API_BASE}/orgs/${orgId}/chats/${chatId}/messages`,
|
|
40
|
+
|
|
41
|
+
// Messages (global, by message ID)
|
|
42
|
+
MESSAGE: (id: string) => `${API_BASE}/messages/${id}`,
|
|
43
|
+
MESSAGE_PATCHES: (id: string) => `${API_BASE}/messages/${id}/patches`,
|
|
44
|
+
MESSAGE_REPLIES: (id: string) => `${API_BASE}/messages/${id}/replies`,
|
|
45
|
+
|
|
46
|
+
// Upload (global)
|
|
47
|
+
UPLOAD_PRESIGN: `${API_BASE}/upload/presign`,
|
|
48
|
+
UPLOAD_COMPLETE: `${API_BASE}/upload/complete`,
|
|
49
|
+
|
|
50
|
+
// Approvals (global)
|
|
51
|
+
APPROVAL_DECIDE: (id: string) => `${API_BASE}/approvals/${id}/decide`,
|
|
52
|
+
APPROVALS_PENDING: `${API_BASE}/approvals/pending`,
|
|
53
|
+
|
|
54
|
+
// Agents (org-scoped)
|
|
55
|
+
AGENTS: (orgId: string) => `${API_BASE}/orgs/${orgId}/agents`,
|
|
56
|
+
AGENT: (orgId: string, agentId: string) => `${API_BASE}/orgs/${orgId}/agents/${agentId}`,
|
|
57
|
+
AGENT_API_KEYS: (orgId: string, agentId: string) =>
|
|
58
|
+
`${API_BASE}/orgs/${orgId}/agents/${agentId}/api-keys`,
|
|
59
|
+
AGENT_API_KEY: (orgId: string, agentId: string, key: string) =>
|
|
60
|
+
`${API_BASE}/orgs/${orgId}/agents/${agentId}/api-keys/${key}`,
|
|
61
|
+
AGENT_ACTIVITY: (orgId: string, agentId: string) =>
|
|
62
|
+
`${API_BASE}/orgs/${orgId}/agents/${agentId}/activity`,
|
|
63
|
+
AGENT_MONITOR: (orgId: string, agentId: string) =>
|
|
64
|
+
`${API_BASE}/orgs/${orgId}/agents/${agentId}/monitor`,
|
|
65
|
+
AGENT_START: (orgId: string, agentId: string) =>
|
|
66
|
+
`${API_BASE}/orgs/${orgId}/agents/${agentId}/start`,
|
|
67
|
+
AGENT_STOP: (orgId: string, agentId: string) =>
|
|
68
|
+
`${API_BASE}/orgs/${orgId}/agents/${agentId}/stop`,
|
|
69
|
+
AGENT_HOSTED_STATUS: (orgId: string, agentId: string) =>
|
|
70
|
+
`${API_BASE}/orgs/${orgId}/agents/${agentId}/hosted-status`,
|
|
71
|
+
AGENT_WORKSPACE: (orgId: string, agentId: string) =>
|
|
72
|
+
`${API_BASE}/orgs/${orgId}/agents/${agentId}/workspace`,
|
|
73
|
+
AGENT_LOGS: (orgId: string, agentId: string) =>
|
|
74
|
+
`${API_BASE}/orgs/${orgId}/agents/${agentId}/logs`,
|
|
75
|
+
|
|
76
|
+
// Tasks (org-scoped)
|
|
77
|
+
TASKS: (orgId: string) => `${API_BASE}/orgs/${orgId}/tasks`,
|
|
78
|
+
TASK: (orgId: string, taskId: string) => `${API_BASE}/orgs/${orgId}/tasks/${taskId}`,
|
|
79
|
+
TASK_SUBTASKS: (orgId: string, taskId: string) =>
|
|
80
|
+
`${API_BASE}/orgs/${orgId}/tasks/${taskId}/subtasks`,
|
|
81
|
+
TASK_RELATIONS: (orgId: string, taskId: string) =>
|
|
82
|
+
`${API_BASE}/orgs/${orgId}/tasks/${taskId}/relations`,
|
|
83
|
+
TASK_RELATION: (orgId: string, taskId: string, relId: string) =>
|
|
84
|
+
`${API_BASE}/orgs/${orgId}/tasks/${taskId}/relations/${relId}`,
|
|
85
|
+
|
|
86
|
+
// Unread
|
|
87
|
+
UNREAD: `${API_BASE}/me/unread`,
|
|
88
|
+
CHAT_READ: (orgId: string, chatId: string) =>
|
|
89
|
+
`${API_BASE}/orgs/${orgId}/chats/${chatId}/read`,
|
|
90
|
+
|
|
91
|
+
} as const;
|
|
92
|
+
|
|
93
|
+
// WebSocket event types
|
|
94
|
+
export const WS_EVENTS = {
|
|
95
|
+
// Client -> Server
|
|
96
|
+
PING: 'ping',
|
|
97
|
+
TYPING: 'typing',
|
|
98
|
+
ACK: 'ack',
|
|
99
|
+
READ: 'read',
|
|
100
|
+
WATCH: 'watch',
|
|
101
|
+
AGENT_HEARTBEAT: 'agent.heartbeat',
|
|
102
|
+
|
|
103
|
+
// Server -> Client
|
|
104
|
+
HELLO: 'hello',
|
|
105
|
+
PONG: 'pong',
|
|
106
|
+
WATCHING: 'watching',
|
|
107
|
+
MESSAGE_NEW: 'message.new',
|
|
108
|
+
MESSAGE_PATCH: 'message.patch',
|
|
109
|
+
MESSAGE_EDIT: 'message.edit',
|
|
110
|
+
MESSAGE_DELETE: 'message.delete',
|
|
111
|
+
TYPING_UPDATE: 'typing.update',
|
|
112
|
+
CHAT_UPDATE: 'chat.update',
|
|
113
|
+
APPROVAL_UPDATE: 'approval.update',
|
|
114
|
+
RECOVERY_OVERFLOW: 'recovery.overflow',
|
|
115
|
+
MEMBERSHIP_CHANGED: 'membership.changed',
|
|
116
|
+
TASK_CREATED: 'task.created',
|
|
117
|
+
TASK_UPDATED: 'task.updated',
|
|
118
|
+
TASK_DELETED: 'task.deleted',
|
|
119
|
+
} as const;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './types.js';
|
|
2
|
+
export * from './constants.js';
|
|
3
|
+
export { PondClient, ApiError } from './client.js';
|
|
4
|
+
export type { PondClientOptions } from './client.js';
|
|
5
|
+
export { PondWs } from './ws.js';
|
|
6
|
+
export type { PondWsOptions, WsConnectionState, WsEventType, WsEventHandler } from './ws.js';
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,569 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// Entity Types — mirror server data model
|
|
3
|
+
// ============================================================
|
|
4
|
+
|
|
5
|
+
export type UserType = 'human' | 'agent';
|
|
6
|
+
export type UserStatus = 'active' | 'disabled';
|
|
7
|
+
|
|
8
|
+
export interface User {
|
|
9
|
+
id: string;
|
|
10
|
+
type: UserType;
|
|
11
|
+
display_name: string;
|
|
12
|
+
avatar_url: string | null;
|
|
13
|
+
email: string | null;
|
|
14
|
+
phone: string | null;
|
|
15
|
+
agent_provider: string | null;
|
|
16
|
+
agent_endpoint: string | null;
|
|
17
|
+
agent_model: string | null;
|
|
18
|
+
agent_permissions: string[];
|
|
19
|
+
status: UserStatus;
|
|
20
|
+
email_verified: boolean;
|
|
21
|
+
last_seen_at: string | null;
|
|
22
|
+
created_at: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type ChatType = 'direct' | 'group';
|
|
26
|
+
|
|
27
|
+
export interface Chat {
|
|
28
|
+
id: string;
|
|
29
|
+
type: ChatType;
|
|
30
|
+
org_id: string;
|
|
31
|
+
name: string | null;
|
|
32
|
+
avatar_url: string | null;
|
|
33
|
+
description: string | null;
|
|
34
|
+
last_message_at: string | null;
|
|
35
|
+
last_message_preview: string | null;
|
|
36
|
+
last_message_sender: string | null;
|
|
37
|
+
creator_id: string;
|
|
38
|
+
created_at: string;
|
|
39
|
+
updated_at: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type ChatMemberRole = 'owner' | 'admin' | 'member';
|
|
43
|
+
|
|
44
|
+
export type NotificationLevel = 'all' | 'mentions_only' | 'none';
|
|
45
|
+
|
|
46
|
+
export interface ChatMember {
|
|
47
|
+
chat_id: string;
|
|
48
|
+
user_id: string;
|
|
49
|
+
role: ChatMemberRole;
|
|
50
|
+
notification_level: NotificationLevel;
|
|
51
|
+
pinned: boolean;
|
|
52
|
+
joined_at: string;
|
|
53
|
+
user?: User;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export type MessageType =
|
|
57
|
+
| 'text'
|
|
58
|
+
| 'image'
|
|
59
|
+
| 'file'
|
|
60
|
+
| 'tool_call'
|
|
61
|
+
| 'tool_result'
|
|
62
|
+
| 'approval_card'
|
|
63
|
+
| 'state_delta'
|
|
64
|
+
| 'system';
|
|
65
|
+
|
|
66
|
+
export const MENTION_ALL_USER_ID = 'all';
|
|
67
|
+
|
|
68
|
+
export interface Mention {
|
|
69
|
+
user_id: string;
|
|
70
|
+
offset: number;
|
|
71
|
+
length: number;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface LinkPreview {
|
|
75
|
+
url: string;
|
|
76
|
+
title: string;
|
|
77
|
+
image: string;
|
|
78
|
+
description: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface TextContent {
|
|
82
|
+
text: string;
|
|
83
|
+
format?: string;
|
|
84
|
+
mentions?: Mention[];
|
|
85
|
+
link_previews?: LinkPreview[];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface MediaContent {
|
|
89
|
+
attachment_id: string;
|
|
90
|
+
file_name: string;
|
|
91
|
+
file_size: number;
|
|
92
|
+
mime_type: string;
|
|
93
|
+
url: string;
|
|
94
|
+
thumbnail_url?: string;
|
|
95
|
+
width?: number;
|
|
96
|
+
height?: number;
|
|
97
|
+
duration?: number;
|
|
98
|
+
caption?: string;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface ToolCallContent {
|
|
102
|
+
tool_name: string;
|
|
103
|
+
tool_input: Record<string, unknown>;
|
|
104
|
+
status: string;
|
|
105
|
+
started_at: string;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface ToolResultContent {
|
|
109
|
+
tool_call_id: string;
|
|
110
|
+
tool_name: string;
|
|
111
|
+
status: string;
|
|
112
|
+
output: string;
|
|
113
|
+
duration_ms: number;
|
|
114
|
+
collapsible: boolean;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface ApprovalOption {
|
|
118
|
+
key: string;
|
|
119
|
+
label: string;
|
|
120
|
+
style: 'primary' | 'danger' | 'secondary';
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface ApprovalCardContent {
|
|
124
|
+
approval_id: string;
|
|
125
|
+
title: string;
|
|
126
|
+
description: string;
|
|
127
|
+
action_type: string;
|
|
128
|
+
action_payload: Record<string, unknown>;
|
|
129
|
+
risk_level: string;
|
|
130
|
+
status: string;
|
|
131
|
+
options: ApprovalOption[];
|
|
132
|
+
expires_at: string;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export type AgentState = 'thinking' | 'tool_calling' | 'streaming' | 'waiting_approval' | 'completed' | 'error';
|
|
136
|
+
|
|
137
|
+
export interface StateDeltaContent {
|
|
138
|
+
state: AgentState;
|
|
139
|
+
text: string;
|
|
140
|
+
progress: number;
|
|
141
|
+
collapsible: boolean;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export type SystemEvent =
|
|
145
|
+
| 'member_joined'
|
|
146
|
+
| 'member_left'
|
|
147
|
+
| 'member_role_changed'
|
|
148
|
+
| 'chat_renamed'
|
|
149
|
+
| 'chat_avatar_changed'
|
|
150
|
+
| 'agent_added'
|
|
151
|
+
| 'agent_removed';
|
|
152
|
+
|
|
153
|
+
export interface SystemContent {
|
|
154
|
+
event: SystemEvent;
|
|
155
|
+
user_id: string;
|
|
156
|
+
user_name: string;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export type MessageContent =
|
|
160
|
+
| TextContent
|
|
161
|
+
| MediaContent
|
|
162
|
+
| ToolCallContent
|
|
163
|
+
| ToolResultContent
|
|
164
|
+
| ApprovalCardContent
|
|
165
|
+
| StateDeltaContent
|
|
166
|
+
| SystemContent
|
|
167
|
+
| Record<string, unknown>;
|
|
168
|
+
|
|
169
|
+
export interface Message {
|
|
170
|
+
id: string;
|
|
171
|
+
chat_id: string;
|
|
172
|
+
sender_id: string;
|
|
173
|
+
sender?: User;
|
|
174
|
+
thread_root_id: string | null;
|
|
175
|
+
message_type: MessageType;
|
|
176
|
+
content: MessageContent;
|
|
177
|
+
version: number;
|
|
178
|
+
reply_count: number;
|
|
179
|
+
edited_at: string | null;
|
|
180
|
+
deleted_at: string | null;
|
|
181
|
+
created_at: string;
|
|
182
|
+
idempotency_key: string | null;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export interface Attachment {
|
|
186
|
+
id: string;
|
|
187
|
+
message_id: string | null;
|
|
188
|
+
uploader_id: string;
|
|
189
|
+
file_name: string;
|
|
190
|
+
file_size: number;
|
|
191
|
+
mime_type: string;
|
|
192
|
+
storage_key: string;
|
|
193
|
+
width: number | null;
|
|
194
|
+
height: number | null;
|
|
195
|
+
duration: number | null;
|
|
196
|
+
thumbnail_key: string | null;
|
|
197
|
+
created_at: string;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export type ApprovalStatus = 'pending' | 'approved' | 'rejected' | 'expired';
|
|
201
|
+
|
|
202
|
+
export interface Approval {
|
|
203
|
+
id: string;
|
|
204
|
+
message_id: string;
|
|
205
|
+
chat_id: string;
|
|
206
|
+
requester_id: string;
|
|
207
|
+
status: ApprovalStatus;
|
|
208
|
+
action_type: string;
|
|
209
|
+
action_payload: Record<string, unknown>;
|
|
210
|
+
decided_by: string | null;
|
|
211
|
+
decided_at: string | null;
|
|
212
|
+
expires_at: string | null;
|
|
213
|
+
created_at: string;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export type OrgMemberRole = 'owner' | 'admin' | 'member';
|
|
217
|
+
|
|
218
|
+
export interface Organization {
|
|
219
|
+
id: string;
|
|
220
|
+
name: string;
|
|
221
|
+
avatar_url: string | null;
|
|
222
|
+
is_personal: boolean;
|
|
223
|
+
created_at: string;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface OrgMember {
|
|
227
|
+
org_id: string;
|
|
228
|
+
user_id: string;
|
|
229
|
+
role: OrgMemberRole;
|
|
230
|
+
joined_at: string;
|
|
231
|
+
user?: User;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export interface ApiKey {
|
|
235
|
+
id: string;
|
|
236
|
+
key: string;
|
|
237
|
+
agent_id: string;
|
|
238
|
+
created_at: string;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export interface CreateAgentResponse {
|
|
242
|
+
user: User;
|
|
243
|
+
api_key: string;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export interface UnreadCount {
|
|
247
|
+
chat_id: string;
|
|
248
|
+
unread_count: number;
|
|
249
|
+
last_read_message_id: string;
|
|
250
|
+
last_read_at: string;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// ============================================================
|
|
254
|
+
// API Response Types
|
|
255
|
+
// ============================================================
|
|
256
|
+
|
|
257
|
+
export interface PaginatedResponse<T> {
|
|
258
|
+
data: T[];
|
|
259
|
+
has_more: boolean;
|
|
260
|
+
next_cursor?: string;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export interface ErrorResponse {
|
|
264
|
+
error: string;
|
|
265
|
+
code: string;
|
|
266
|
+
details?: Record<string, unknown>;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export interface AuthTokens {
|
|
270
|
+
access_token: string;
|
|
271
|
+
refresh_token: string;
|
|
272
|
+
expires_in: number;
|
|
273
|
+
user: User;
|
|
274
|
+
is_new_user?: boolean;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export interface CheckEmailResponse {
|
|
278
|
+
exists: boolean;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export interface PresignResponse {
|
|
282
|
+
upload_url: string;
|
|
283
|
+
attachment_id: string;
|
|
284
|
+
expires_in: number;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export interface WsTicketResponse {
|
|
288
|
+
ticket: string;
|
|
289
|
+
expires_at: string;
|
|
290
|
+
ws_url: string;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// ============================================================
|
|
294
|
+
// API Request Types
|
|
295
|
+
// ============================================================
|
|
296
|
+
|
|
297
|
+
export interface RegisterRequest {
|
|
298
|
+
email: string;
|
|
299
|
+
password: string;
|
|
300
|
+
display_name: string;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export interface LoginRequest {
|
|
304
|
+
email: string;
|
|
305
|
+
password: string;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export interface CreateChatRequest {
|
|
309
|
+
type: ChatType;
|
|
310
|
+
org_id: string;
|
|
311
|
+
name?: string;
|
|
312
|
+
description?: string;
|
|
313
|
+
member_ids: string[];
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export interface SendMessageRequest {
|
|
317
|
+
message_type: MessageType;
|
|
318
|
+
content: MessageContent;
|
|
319
|
+
thread_root_id?: string;
|
|
320
|
+
idempotency_key?: string;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export interface PatchMessageRequest {
|
|
324
|
+
version: number;
|
|
325
|
+
ops: JsonPatchOp[];
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export interface JsonPatchOp {
|
|
329
|
+
op: 'replace' | 'add';
|
|
330
|
+
path: string;
|
|
331
|
+
value: unknown;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export interface WorkspaceFiles {
|
|
335
|
+
soul_md?: string;
|
|
336
|
+
agents_md?: string;
|
|
337
|
+
tools_md?: string;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export interface HostedStatus {
|
|
341
|
+
state: 'running' | 'stopped' | 'creating' | 'error';
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export interface CreateAgentRequest {
|
|
345
|
+
display_name: string;
|
|
346
|
+
agent_provider?: string;
|
|
347
|
+
agent_endpoint?: string;
|
|
348
|
+
agent_model?: string;
|
|
349
|
+
agent_permissions?: string[];
|
|
350
|
+
machine_type?: string;
|
|
351
|
+
machine_label?: string;
|
|
352
|
+
machine_host?: string;
|
|
353
|
+
workspace?: WorkspaceFiles;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// ---- Agent enriched types ----
|
|
357
|
+
|
|
358
|
+
export interface AgentProfile {
|
|
359
|
+
user_id: string;
|
|
360
|
+
provider: string | null;
|
|
361
|
+
endpoint: string | null;
|
|
362
|
+
model: string | null;
|
|
363
|
+
permissions: string[];
|
|
364
|
+
machine_type: string | null;
|
|
365
|
+
machine_label: string | null;
|
|
366
|
+
machine_host: string | null;
|
|
367
|
+
compute_provider: string | null;
|
|
368
|
+
compute_resource_id: string | null;
|
|
369
|
+
compute_metadata: Record<string, string> | null;
|
|
370
|
+
created_by: string;
|
|
371
|
+
created_at: string;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export interface AgentRun {
|
|
375
|
+
chat_id: string;
|
|
376
|
+
status: string;
|
|
377
|
+
started_at: string;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export interface AgentPresence {
|
|
381
|
+
online: boolean;
|
|
382
|
+
status: string; // "online" | "busy" | "error" | "offline"
|
|
383
|
+
session_id?: string;
|
|
384
|
+
run?: AgentRun;
|
|
385
|
+
telemetry?: Record<string, unknown>;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export interface AgentWithRuntime extends User {
|
|
389
|
+
agent_profile?: AgentProfile | null;
|
|
390
|
+
presence?: AgentPresence | null;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
export interface PresignUploadRequest {
|
|
394
|
+
file_name: string;
|
|
395
|
+
file_size: number;
|
|
396
|
+
mime_type: string;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// ============================================================
|
|
400
|
+
// Task Types
|
|
401
|
+
// ============================================================
|
|
402
|
+
|
|
403
|
+
export type TaskStatus = 'todo' | 'in_progress' | 'in_review' | 'done' | 'canceled';
|
|
404
|
+
export type TaskPriority = 'high' | 'normal' | 'low';
|
|
405
|
+
export type TaskRelationTargetType = 'task' | 'message' | 'chat' | 'agent_run';
|
|
406
|
+
export type TaskRelationType = 'blocks' | 'related' | 'duplicate' | 'source' | 'reference' | 'discussion' | 'execution';
|
|
407
|
+
|
|
408
|
+
export interface Task {
|
|
409
|
+
id: string;
|
|
410
|
+
org_id: string;
|
|
411
|
+
title: string;
|
|
412
|
+
description: string | null;
|
|
413
|
+
status: TaskStatus;
|
|
414
|
+
priority: TaskPriority;
|
|
415
|
+
assignee_id: string | null;
|
|
416
|
+
creator_id: string;
|
|
417
|
+
parent_id: string | null;
|
|
418
|
+
sort_order: number;
|
|
419
|
+
created_at: string;
|
|
420
|
+
updated_at: string;
|
|
421
|
+
started_at: string | null;
|
|
422
|
+
completed_at: string | null;
|
|
423
|
+
canceled_at: string | null;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
export interface TaskRelation {
|
|
427
|
+
id: string;
|
|
428
|
+
task_id: string;
|
|
429
|
+
target_type: TaskRelationTargetType;
|
|
430
|
+
target_id: string;
|
|
431
|
+
relation_type: TaskRelationType;
|
|
432
|
+
created_by: string;
|
|
433
|
+
created_at: string;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
export interface CreateTaskRequest {
|
|
437
|
+
title: string;
|
|
438
|
+
description?: string;
|
|
439
|
+
priority?: TaskPriority;
|
|
440
|
+
assignee_id?: string;
|
|
441
|
+
parent_id?: string;
|
|
442
|
+
sort_order?: number;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
export interface UpdateTaskRequest {
|
|
446
|
+
title?: string;
|
|
447
|
+
description?: string;
|
|
448
|
+
status?: TaskStatus;
|
|
449
|
+
priority?: TaskPriority;
|
|
450
|
+
assignee_id?: string | null;
|
|
451
|
+
sort_order?: number;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export interface CreateTaskRelationRequest {
|
|
455
|
+
target_type: TaskRelationTargetType;
|
|
456
|
+
target_id: string;
|
|
457
|
+
relation_type: TaskRelationType;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// ============================================================
|
|
461
|
+
// WebSocket Event Types
|
|
462
|
+
// ============================================================
|
|
463
|
+
|
|
464
|
+
export interface WsFrame<T = unknown> {
|
|
465
|
+
type: string;
|
|
466
|
+
seq?: number;
|
|
467
|
+
data: T;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export interface HelloData {
|
|
471
|
+
conn_id: string;
|
|
472
|
+
user_id: string;
|
|
473
|
+
session_id?: string; // agent-only: server-assigned session ID
|
|
474
|
+
server_time: string;
|
|
475
|
+
heartbeat_interval: number;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
export interface MessageNewData {
|
|
479
|
+
id: string;
|
|
480
|
+
chat_id: string;
|
|
481
|
+
sender_id: string;
|
|
482
|
+
sender?: User;
|
|
483
|
+
thread_root_id: string | null;
|
|
484
|
+
message_type: MessageType;
|
|
485
|
+
content: MessageContent;
|
|
486
|
+
version: number;
|
|
487
|
+
created_at: string;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
export interface MessagePatchData {
|
|
491
|
+
message_id: string;
|
|
492
|
+
chat_id: string;
|
|
493
|
+
version: number;
|
|
494
|
+
ops: JsonPatchOp[];
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
export interface MessageEditData {
|
|
498
|
+
message_id: string;
|
|
499
|
+
chat_id: string;
|
|
500
|
+
content: MessageContent;
|
|
501
|
+
edited_at: string;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
export interface MessageDeleteData {
|
|
505
|
+
message_id: string;
|
|
506
|
+
chat_id: string;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
export interface TypingUpdateData {
|
|
510
|
+
chat_id: string;
|
|
511
|
+
thread_root_id: string | null;
|
|
512
|
+
user_id: string;
|
|
513
|
+
action: 'start' | 'stop';
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
export interface ChatUpdateData {
|
|
517
|
+
chat_id: string;
|
|
518
|
+
changes: Record<string, unknown>;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
export interface ApprovalUpdateData {
|
|
522
|
+
approval_id: string;
|
|
523
|
+
message_id: string;
|
|
524
|
+
chat_id: string;
|
|
525
|
+
status: ApprovalStatus;
|
|
526
|
+
decided_by: string;
|
|
527
|
+
decided_at: string;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
export interface RecoveryOverflowData {
|
|
531
|
+
message: string;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
export interface WatchingData {
|
|
535
|
+
chat_ids: string[];
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
export interface MembershipChangedData {
|
|
539
|
+
chat_id: string;
|
|
540
|
+
user_id: string;
|
|
541
|
+
action: 'added' | 'removed';
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
// ---- Task WS Event Data ----
|
|
545
|
+
|
|
546
|
+
export type TaskCreatedData = Task;
|
|
547
|
+
export type TaskUpdatedData = Task;
|
|
548
|
+
export interface TaskDeletedData {
|
|
549
|
+
task_id: string;
|
|
550
|
+
org_id: string;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
export type WsEventMap = {
|
|
554
|
+
'hello': HelloData;
|
|
555
|
+
'message.new': MessageNewData;
|
|
556
|
+
'message.patch': MessagePatchData;
|
|
557
|
+
'message.edit': MessageEditData;
|
|
558
|
+
'message.delete': MessageDeleteData;
|
|
559
|
+
'typing.update': TypingUpdateData;
|
|
560
|
+
'chat.update': ChatUpdateData;
|
|
561
|
+
'approval.update': ApprovalUpdateData;
|
|
562
|
+
'recovery.overflow': RecoveryOverflowData;
|
|
563
|
+
'watching': WatchingData;
|
|
564
|
+
'pong': { ts: number };
|
|
565
|
+
'membership.changed': MembershipChangedData;
|
|
566
|
+
'task.created': TaskCreatedData;
|
|
567
|
+
'task.updated': TaskUpdatedData;
|
|
568
|
+
'task.deleted': TaskDeletedData;
|
|
569
|
+
};
|