@taco_tsinghua/graphnode-sdk 0.1.17 → 0.1.19

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.
Files changed (52) hide show
  1. package/README.md +91 -333
  2. package/dist/endpoints/ai.d.ts +25 -30
  3. package/dist/endpoints/ai.d.ts.map +1 -1
  4. package/dist/endpoints/ai.js +220 -31
  5. package/dist/endpoints/ai.js.map +1 -1
  6. package/dist/endpoints/graph.d.ts +4 -1
  7. package/dist/endpoints/graph.d.ts.map +1 -1
  8. package/dist/endpoints/graph.js +10 -0
  9. package/dist/endpoints/graph.js.map +1 -1
  10. package/dist/endpoints/graphAi.d.ts +21 -0
  11. package/dist/endpoints/graphAi.d.ts.map +1 -1
  12. package/dist/endpoints/graphAi.js +24 -0
  13. package/dist/endpoints/graphAi.js.map +1 -1
  14. package/dist/endpoints/notification.d.ts +12 -0
  15. package/dist/endpoints/notification.d.ts.map +1 -1
  16. package/dist/endpoints/notification.js +16 -0
  17. package/dist/endpoints/notification.js.map +1 -1
  18. package/dist/endpoints/sync.d.ts +3 -1
  19. package/dist/endpoints/sync.d.ts.map +1 -1
  20. package/dist/endpoints/sync.js.map +1 -1
  21. package/dist/http-builder.d.ts +1 -0
  22. package/dist/http-builder.d.ts.map +1 -1
  23. package/dist/http-builder.js +37 -6
  24. package/dist/http-builder.js.map +1 -1
  25. package/dist/types/graph.d.ts +66 -0
  26. package/dist/types/graph.d.ts.map +1 -1
  27. package/package.json +2 -1
  28. package/src/client.ts +105 -0
  29. package/src/config.ts +9 -0
  30. package/src/endpoints/agent.ts +171 -0
  31. package/src/endpoints/ai.ts +296 -0
  32. package/src/endpoints/auth.apple.ts +39 -0
  33. package/src/endpoints/auth.google.ts +39 -0
  34. package/src/endpoints/conversations.ts +362 -0
  35. package/src/endpoints/graph.ts +398 -0
  36. package/src/endpoints/graphAi.ts +111 -0
  37. package/src/endpoints/health.ts +40 -0
  38. package/src/endpoints/me.ts +97 -0
  39. package/src/endpoints/note.ts +351 -0
  40. package/src/endpoints/notification.ts +68 -0
  41. package/src/endpoints/sync.ts +71 -0
  42. package/src/http-builder.ts +247 -0
  43. package/src/index.ts +60 -0
  44. package/src/types/aiInput.ts +111 -0
  45. package/src/types/conversation.ts +51 -0
  46. package/src/types/graph.ts +201 -0
  47. package/src/types/graphAi.ts +21 -0
  48. package/src/types/me.ts +49 -0
  49. package/src/types/message.ts +40 -0
  50. package/src/types/note.ts +89 -0
  51. package/src/types/problem.ts +22 -0
  52. package/src/types/sync.ts +35 -0
package/README.md CHANGED
@@ -1,381 +1,139 @@
1
- # GraphNode BE SDK
1
+ # GraphNode SDK for Frontend
2
2
 
3
- This SDK provides a convenient way to interact with the GraphNode Backend API from a TypeScript/JavaScript client.
3
+ > **TACO 4기 - GraphNode 서비스 프론트엔드 연동 SDK**
4
4
 
5
- ## Installation
5
+ GraphNode 백엔드 API를 타입 안전(Type-Safe)하게 사용할 수 있도록 제공되는 공식 클라이언트 라이브러리입니다.
6
+
7
+ ## 📦 설치 (Installation)
6
8
 
7
9
  ```bash
8
10
  npm install @taco_tsinghua/graphnode-sdk
9
11
  ```
10
12
 
11
- ## Getting Started
12
-
13
- ### Initialization
14
-
15
- Create a client instance. The base URL is automatically configured to point to the GraphNode backend.
16
-
17
- ```typescript
18
- import { createGraphNodeClient } from '@taco_tsinghua/graphnode-sdk';
19
-
20
- // No need to pass baseUrl, it defaults to the internal constant
21
- const client = createGraphNodeClient();
22
- ```
23
-
24
- If you need to pass custom fetch options (e.g., for testing or specific environments):
13
+ *(현재는 모노레포 내부 패키지로 관리되고 있습니다.)*
25
14
 
26
- ```typescript
27
- const client = createGraphNodeClient({
28
- // fetch: customFetch
29
- });
30
- ```
31
-
32
- ### API Usage Examples
33
-
34
- The client is organized by API resources.
35
-
36
- #### Health
37
-
38
- Check the health of the API server.
39
-
40
- ```typescript
41
- const health = await client.health.check();
42
- console.log(health); // { ok: true }
43
- ```
44
-
45
- #### Me (User Profile)
46
-
47
- Get the profile of the currently authenticated user.
48
-
49
- ```typescript
50
- try {
51
- const me = await client.me.getProfile();
52
- console.log(me); // { id: '...', displayName: '...' }
53
- } catch (error) {
54
- console.error('Not authenticated');
55
- }
56
- ```
57
-
58
- #### Conversations
59
-
60
- **Create a single conversation:**
61
-
62
- ```typescript
63
- const newConversation = await client.conversations.create({
64
- id: 'client-generated-uuid-1',
65
- title: 'My First Conversation',
66
- });
67
- console.log(newConversation);
68
- ```
69
-
70
- **Bulk create multiple conversations:**
71
-
72
- ```typescript
73
- const response = await client.conversations.bulkCreate({
74
- conversations: [
75
- { id: 'bulk-uuid-1', title: 'Bulk Conversation 1' },
76
- {
77
- id: 'bulk-uuid-2',
78
- title: 'Bulk Conversation 2 with messages',
79
- messages: [{ id: 'msg-uuid-1', role: 'user', content: 'Hello!' }],
80
- },
81
- ],
82
- });
83
- console.log(response.conversations); // Array of created conversations
84
- ```
85
-
86
- **List all conversations:**
87
-
88
- ```typescript
89
- const conversations = await client.conversations.list();
90
- console.log(conversations);
91
- ```
92
-
93
- **Get a specific conversation:**
94
-
95
- ```typescript
96
- const conversation = await client.conversations.get('conversation-id-123');
97
- console.log(conversation);
98
- ```
15
+ ## 🚀 시작하기 (Getting Started)
99
16
 
100
- #### Messages
17
+ ### 클라이언트 초기화
101
18
 
102
- Create a message within a conversation:
19
+ API 요청을 보내기 위해 `GraphNodeClient`를 초기화해야 합니다. 기본적으로 서버와의 세션(Cookie) 인증을 사용하므로 `credentials: 'include'` 옵션이 내장되어 있습니다.
103
20
 
104
21
  ```typescript
105
- const newMessage = await client.conversations.createMessage('conversation-id-123', {
106
- id: 'message-uuid-456',
107
- role: 'user',
108
- content: 'Hello, this is a new message.',
109
- });
110
- console.log(newMessage);
111
- ```
112
-
113
- #### Graph
22
+ import { createGraphNodeClient } from 'graphnode-sdk';
114
23
 
115
- **Nodes:**
116
-
117
- ```typescript
118
- // Create a node
119
- const node = await client.graph.createNode({
120
- id: 1,
121
- label: 'My Node',
122
- type: 'concept',
123
- properties: { color: 'red' },
24
+ // 기본 설정으로 클라이언트 생성 (localhost:3000 기준)
25
+ const client = createGraphNodeClient({
26
+ baseUrl: 'http://localhost:3000' // 배포 환경에 따라 URL 변경
124
27
  });
125
-
126
- // List nodes
127
- const nodes = await client.graph.listNodes();
128
-
129
- // Get node
130
- const myNode = await client.graph.getNode(1);
131
-
132
- // Update node
133
- await client.graph.updateNode(1, { label: 'Updated Node' });
134
-
135
- // Delete node
136
- await client.graph.deleteNode(1);
137
-
138
- // Delete node cascade (with edges)
139
- await client.graph.deleteNodeCascade(1);
140
28
  ```
141
29
 
142
- **Edges:**
30
+ ---
143
31
 
144
- ```typescript
145
- // Create an edge
146
- const edge = await client.graph.createEdge({
147
- source: 1,
148
- target: 2,
149
- relationship: 'related_to',
150
- });
32
+ ## 📚 API Reference
151
33
 
152
- // List edges
153
- const edges = await client.graph.listEdges();
34
+ ### 1. 인증 (Authentication)
154
35
 
155
- // Delete edge
156
- await client.graph.deleteEdge('edge-id');
157
- ```
36
+ | Method | Endpoint | Description | Status Codes |
37
+ | :--- | :--- | :--- | :--- |
38
+ | `client.me.getMe()` | `GET /v1/me` | 현재 로그인한 사용자 정보 조회 | `200` OK<br>`401` Unauth |
39
+ | `client.auth.google.getStartUrl()` | - | Google 로그인 시작 URL 반환 | - |
40
+ | `client.auth.apple.getStartUrl()` | - | Apple 로그인 시작 URL 반환 | - |
41
+ | `client.auth.logout()` | `POST /auth/logout` | 로그아웃 (세션 쿠키 삭제) | `204` Destroyed<br>`401` Unauth |
158
42
 
159
- **Clusters:**
43
+ ### 2. AI 대화 (AI Chat)
160
44
 
161
- ```typescript
162
- // Create cluster
163
- const cluster = await client.graph.createCluster({
164
- name: 'My Cluster',
165
- nodeIds: [1, 2],
166
- });
45
+ | Method | Endpoint | Description | Status Codes |
46
+ | :--- | :--- | :--- | :--- |
47
+ | `client.ai.createConversation()` | `POST /v1/ai/conversations` | 새로운 대화방 생성 | `201` Created<br>`400` Bad Request |
48
+ | `client.ai.listConversations()` | `GET /v1/ai/conversations` | 대화방 목록 조회 | `200` OK |
49
+ | `client.ai.chat(convId, dto)` | `POST /v1/ai/conversations/:id/chat` | 메시지 전송 (파일 첨부 가능) | `200` OK<br>`400` Bad Req<br>`401` Unauth<br>`502` Upstream |
50
+ | `openAgentChatStream()` | `POST /v1/agent/stream` | 실시간 에이전트 스트리밍 (SSE) | `200` OK (Stream) |
167
51
 
168
- // List clusters
169
- const clusters = await client.graph.listClusters();
52
+ ### 3. 그래프 AI (Graph AI)
170
53
 
171
- // Get cluster
172
- const myCluster = await client.graph.getCluster('cluster-id');
54
+ | Method | Endpoint | Description | Status Codes |
55
+ | :--- | :--- | :--- | :--- |
56
+ | `client.graphAi.generateGraph()` | `POST /v1/graph-ai/generate` | 그래프 생성 요청 (Async Task) | `202` Accepted<br>`401` Unauth<br>`409` Conflict |
57
+ | `client.graphAi.requestSummary()` | `POST /v1/graph-ai/summary` | 그래프 요약 생성 요청 (Async Task) | `202` Accepted<br>`401` Unauth<br>`409` Conflict |
58
+ | `client.graphAi.getSummary()` | `GET /v1/graph-ai/summary` | 생성된 그래프 요약 조회 | `200` OK<br>`404` Not Found |
173
59
 
174
- // Delete cluster
175
- await client.graph.deleteCluster('cluster-id');
60
+ ### 4. 그래프 관리 (Graph Knowledge)
176
61
 
177
- // Delete cluster cascade
178
- await client.graph.deleteClusterCascade('cluster-id');
179
- ```
62
+ | Method | Endpoint | Description | Status Codes |
63
+ | :--- | :--- | :--- | :--- |
64
+ | `client.graph.listNodes()` | `GET /v1/graph/nodes` | 노드 목록 조회 | `200` OK<br>`401` Unauth |
65
+ | `client.graph.createNode()` | `POST /v1/graph/nodes` | 노드 생성 | `201` Created<br>`400` Bad Req |
66
+ | `client.graph.getNode(id)` | `GET /v1/graph/nodes/:id` | 노드 상세 조회 | `200` OK<br>`404` Not Found |
67
+ | `client.graph.updateNode()` | `PATCH /v1/graph/nodes/:id` | 노드 수정 | `204` Updated<br>`404` Not Found |
68
+ | `client.graph.deleteNode()` | `DELETE /v1/graph/nodes/:id` | 노드 삭제 | `204` Deleted<br>`401` Unauth |
69
+ | `client.graph.createEdge()` | `POST /v1/graph/edges` | 엣지 생성 | `201` Created<br>`400` Bad Req |
70
+ | `client.graph.getSnapshot()` | `GET /v1/graph/snapshot` | 전체 그래프 데이터 스냅샷 조회 | `200` OK<br>`401` Unauth |
180
71
 
181
- **Stats & Snapshot:**
72
+ ### 5. 노트 관리 (Notes & Folders)
182
73
 
183
- ```typescript
184
- // Get stats
185
- const stats = await client.graph.getStats();
74
+ | Method | Endpoint | Description | Status Codes |
75
+ | :--- | :--- | :--- | :--- |
76
+ | `client.note.createFolder()` | `POST /v1/folders` | 폴더 생성 | `201` Created<br>`400` Bad Req |
77
+ | `client.note.createNote()` | `POST /v1/notes` | 노트 생성 | `201` Created<br>`400` Bad Req |
78
+ | `client.note.listNotes()` | `GET /v1/notes` | 노트 목록 조회 | `200` OK<br>`401` Unauth |
79
+ | `client.note.updateNote()` | `PATCH /v1/notes/:id` | 노트 수정 | `200` OK<br>`404` Not Found |
186
80
 
187
- // Get snapshot
188
- const snapshot = await client.graph.getSnapshot();
81
+ ### 6. 동기화 (Sync)
189
82
 
190
- // Save snapshot
191
- await client.graph.saveSnapshot(snapshot);
192
- ```
83
+ 오프라인 우선(Offline-first) 아키텍처 지원을 위한 변경사항 동기화 API.
193
84
 
194
- #### Graph AI (Graph Generation)
85
+ | Method | Endpoint | Description | Status Codes |
86
+ | :--- | :--- | :--- | :--- |
87
+ | `client.sync.pull()` | `GET /v1/sync/pull` | 서버 변경사항 가져오기 | `200` OK<br>`400` Bad Req |
88
+ | `client.sync.push()` | `POST /v1/sync/push` | 클라이언트 변경사항 반영 | `200` OK<br>`400` Bad Req<br>`502` Upstream |
195
89
 
196
- **Generate Graph from User Conversations:**
90
+ ---
197
91
 
198
- Starts a background task to analyze the user's conversation history and generate a knowledge graph.
92
+ ## 💡 주요 타입 정의 (Types)
199
93
 
94
+ ### GraphSummaryDto
200
95
  ```typescript
201
- const response = await client.graphAi.generateGraph();
202
-
203
- if (response.isSuccess) {
204
- console.log('Task Started:', response.data.taskId);
205
- console.log('Status:', response.data.status);
96
+ interface GraphSummaryDto {
97
+ overview: {
98
+ total_conversations: number;
99
+ summary_text: string;
100
+ ...
101
+ };
102
+ clusters: Array<{ name: string; insight_text: string; ... }>;
103
+ patterns: Array<{ pattern_type: string; description: string; ... }>;
104
+ connections: Array<{ source_cluster: string; target_cluster: string; ... }>;
105
+ recommendations: Array<{ title: string; priority: string; ... }>;
206
106
  }
207
107
  ```
208
108
 
209
- **Generate Graph from JSON (Test Mode):**
210
-
211
- Directly sends conversation data (in ChatGPT export format) to the AI engine for graph generation. Useful for testing without existing DB data.
212
-
109
+ ### SyncPushRequest
213
110
  ```typescript
214
- import { AiInputData } from '@taco_tsinghua/graphnode-sdk';
215
-
216
- const mockData: AiInputData[] = [
217
- {
218
- title: 'Test Conversation',
219
- create_time: 1678900000,
220
- update_time: 1678900100,
221
- mapping: {
222
- 'msg-1': {
223
- id: 'msg-1',
224
- message: {
225
- id: 'msg-1',
226
- author: { role: 'user' },
227
- content: { content_type: 'text', parts: ['Hello'] },
228
- },
229
- parent: null,
230
- children: [],
231
- },
232
- },
233
- },
234
- ];
235
-
236
- const response = await client.graphAi.generateGraphTest(mockData);
237
- ```
238
-
239
- #### Notes & Folders
240
-
241
- **Notes:**
242
-
243
- ```typescript
244
- // Create a note
245
- const note = await client.note.createNote({
246
- title: 'My Note',
247
- content: '# Hello World',
248
- folderId: null, // Optional
249
- });
250
-
251
- // List notes
252
- const notes = await client.note.listNotes();
253
-
254
- // Get note
255
- const myNote = await client.note.getNote('note-id');
256
-
257
- // Update note
258
- const updatedNote = await client.note.updateNote('note-id', {
259
- content: '# Updated Content',
260
- });
261
-
262
- // Delete note
263
- await client.note.deleteNote('note-id');
111
+ interface SyncPushRequest {
112
+ conversations?: ConversationDto[];
113
+ messages?: MessageDto[];
114
+ notes?: NoteDto[];
115
+ folders?: FolderDto[];
116
+ }
264
117
  ```
265
118
 
266
- **Folders:**
119
+ ---
267
120
 
268
- ```typescript
269
- // Create a folder
270
- const folder = await client.note.createFolder({
271
- name: 'My Folder',
272
- parentId: null, // Optional
273
- });
274
-
275
- // List folders
276
- const folders = await client.note.listFolders();
121
+ ## 🛠️ Error Handling
277
122
 
278
- // Get folder
279
- const myFolder = await client.note.getFolder('folder-id');
280
-
281
- // Update folder
282
- const updatedFolder = await client.note.updateFolder('folder-id', {
283
- name: 'Updated Folder Name',
284
- });
285
-
286
- // Delete folder
287
- await client.note.deleteFolder('folder-id');
288
- ```
289
-
290
- ### Error Handling
291
-
292
- The SDK uses a unified `HttpResponse` object for all API responses, eliminating the need for `try...catch` blocks for handling HTTP errors. Each API method returns a `Promise<HttpResponse<T>>`, which is a discriminated union type. You can check the `isSuccess` property to determine if the call was successful.
123
+ API 요청 실패 시 `HttpError`가 발생하며, 백엔드의 `ProblemDetails` 규격(`RFC 9457`)을 따릅니다.
293
124
 
294
125
  ```typescript
295
- import { createGraphNodeClient, HttpResponse } from '@taco_tsinghua/graphnode-sdk';
296
-
297
- const client = createGraphNodeClient();
298
-
299
- async function fetchConversation() {
300
- const response = await client.conversations.get('non-existent-id');
301
-
302
- if (response.isSuccess) {
303
- // Type-safe access to `data` and `statusCode`
304
- console.log('Success:', response.data);
305
- } else {
306
- // Type-safe access to `error`
307
- console.error('API Error:', response.error.message);
308
- console.error('Status:', response.error.statusCode);
309
-
310
- // The error body might contain RFC 9457 Problem Details
311
- const problem = response.error.body as { title: string; detail: string };
312
- if (problem) {
313
- console.error('Problem Title:', problem.title);
314
- console.error('Problem Detail:', problem.detail);
315
- }
126
+ try {
127
+ await client.note.createNote({ ... });
128
+ } catch (err) {
129
+ if (err.name === 'HttpError') {
130
+ // 400 Bad Request 등의 경우
131
+ console.error('Status:', err.response.status);
132
+ console.error('Problem:', err.response.data); // { type, title, detail, ... }
316
133
  }
317
134
  }
318
135
  ```
319
136
 
320
- ### HTTP 상태 코드 가이드 (HTTP Status Codes Guide)
321
-
322
- API는 표준 HTTP 상태 코드를 사용하여 요청의 성공 또는 실패를 나타냅니다.
323
-
324
- #### 성공 코드 (General Success Codes)
325
-
326
- - **`200 OK`**: 요청이 성공적으로 처리되었습니다. 응답 본문에 요청한 데이터가 포함됩니다. (예: `GET`, `PATCH`, `PUT`)
327
- - **`201 Created`**: 리소스가 성공적으로 생성되었습니다. `Location` 헤더에 새 리소스의 URL이 포함되며, 본문에 생성된 리소스가 포함됩니다. (예: `POST`)
328
- - **`204 No Content`**: 요청은 성공했으나 반환할 본문이 없습니다. (예: `DELETE`, 본문 없는 `PATCH`)
329
-
330
- #### 에러 코드 (General Error Codes)
331
-
332
- 모든 에러 응답은 **RFC 9457 Problem Details** 형식(`application/problem+json`)을 따릅니다.
333
-
334
- - **`400 Bad Request`**: 클라이언트 오류로 인해 서버가 요청을 처리할 수 없습니다(예: 잘못된 구문, 유효성 검사 실패). 응답 본문에 유효성 검사 실패에 대한 세부 정보가 포함됩니다.
335
- - **`401 Unauthorized`**: 요청된 응답을 받으려면 인증이 필요합니다. 세션이 유효하지 않거나 만료된 경우 발생합니다.
336
- - **`403 Forbidden`**: 클라이언트가 콘텐츠에 대한 접근 권한이 없습니다. 401과 달리 서버가 클라이언트의 신원을 알고 있습니다.
337
- - **`404 Not Found`**: 서버가 요청한 리소스를 찾을 수 없습니다.
338
- - **`409 Conflict`**: 요청이 서버의 현재 상태와 충돌할 때 전송됩니다(예: 이미 존재하는 리소스 생성).
339
- - **`429 Too Many Requests`**: 사용자가 일정 시간 동안 너무 많은 요청을 보냈습니다("속도 제한").
340
- - **`500 Internal Server Error`**: 서버가 처리 방법을 모르는 상황에 직면했습니다.
341
- - **`502 Bad Gateway`**: 업스트림 오류. 외부 서비스(예: OpenAI, DB)가 유효하지 않은 응답을 반환했습니다.
342
- - **`503 Service Unavailable`**: 서비스 불가. DB 연결 실패 등 일시적으로 서비스를 이용할 수 없습니다.
343
- - **`504 Gateway Timeout`**: 업스트림 타임아웃. 외부 서비스의 응답이 지연되어 타임아웃이 발생했습니다.
344
-
345
- #### 엔드포인트별 상태 코드 (Endpoint-Specific Status Codes)
346
-
347
- | Endpoint | Method | Success Codes | Error Codes | Description |
348
- | -------------------------------------- | -------- | ------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
349
- | **/healthz** | `GET` | `200` | `503` | API 상태를 확인합니다. <br> `503`: DB 등 필수 의존성 서비스가 다운된 경우. |
350
- | **/auth/logout** | `POST` | `204` | `401` | 사용자를 로그아웃하고 세션을 무효화합니다. <br> `401`: 이미 로그아웃되었거나 세션이 유효하지 않은 경우. |
351
- | **/v1/me** | `GET` | `200` | `401` | 현재 사용자의 프로필을 조회합니다. <br> `401`: 로그인하지 않은 사용자. |
352
- | **/v1/me/api-keys/{model}** | `GET` | `200` | `401`, `404` | 특정 모델의 API 키를 조회합니다. <br> `401`: 미인증. <br> `404`: 해당 모델의 키가 설정되지 않음. |
353
- | | `PATCH` | `204` | `400`, `401` | API 키를 업데이트합니다. <br> `400`: 키 형식이 잘못됨. <br> `401`: 미인증. |
354
- | | `DELETE` | `204` | `401` | API 키를 삭제합니다. <br> `401`: 미인증. |
355
- | **/v1/ai/conversations** | `POST` | `201` | `400`, `401`, `409` | 새 대화를 생성합니다. <br> `400`: 제목 누락 등 입력값 오류. <br> `401`: 미인증. <br> `409`: 클라이언트가 제공한 ID가 이미 존재함. |
356
- | | `GET` | `200` | `401` | 모든 대화를 조회합니다. <br> `401`: 미인증. |
357
- | **/v1/ai/conversations/bulk** | `POST` | `201` | `400`, `401` | 대화를 일괄 생성합니다. <br> `400`: 배열 형식이 아니거나 데이터 오류. <br> `401`: 미인증. |
358
- | **/v1/ai/conversations/{id}** | `GET` | `200` | `401`, `404` | 단일 대화를 조회합니다. <br> `401`: 미인증. <br> `404`: 대화를 찾을 수 없거나 삭제됨. |
359
- | | `PATCH` | `200` | `400`, `401`, `404` | 대화를 업데이트합니다. <br> `400`: 입력값 오류. <br> `401`: 미인증. <br> `404`: 대화 없음. |
360
- | | `DELETE` | `204` | `401`, `404` | 대화를 삭제합니다. <br> `401`: 미인증. <br> `404`: 대화 없음. |
361
- | **/v1/ai/conversations/{id}/restore** | `POST` | `200` | `401`, `404` | 삭제된 대화를 복원합니다. <br> `401`: 미인증. <br> `404`: 삭제된 대화 기록을 찾을 수 없음. |
362
- | **/v1/ai/conversations/{id}/messages** | `POST` | `201` | `400`, `401`, `404` | 대화에 메시지를 추가합니다. <br> `400`: 내용 누락 등. <br> `401`: 미인증. <br> `404`: 대화가 존재하지 않음. |
363
- | **/v1/graph/nodes** | `POST` | `201` | `400`, `401`, `409` | 그래프 노드를 생성합니다. <br> `400`: 필수 필드 누락. <br> `401`: 미인증. <br> `409`: 노드 ID 중복. |
364
- | | `GET` | `200` | `401` | 모든 그래프 노드를 조회합니다. <br> `401`: 미인증. |
365
- | **/v1/graph/nodes/{id}** | `GET` | `200` | `401`, `404` | 단일 노드를 조회합니다. <br> `401`: 미인증. <br> `404`: 노드 없음. |
366
- | | `PATCH` | `204` | `400`, `401`, `404` | 노드를 업데이트합니다. <br> `400`: 입력값 오류. <br> `401`: 미인증. <br> `404`: 노드 없음. |
367
- | | `DELETE` | `204` | `401`, `404` | 노드를 삭제합니다. <br> `401`: 미인증. <br> `404`: 노드 없음. |
368
- | **/v1/graph/edges** | `POST` | `201` | `400`, `401` | 그래프 엣지를 생성합니다. <br> `400`: Source/Target 노드 ID 오류. <br> `401`: 미인증. |
369
- | | `GET` | `200` | `401` | 모든 그래프 엣지를 조회합니다. <br> `401`: 미인증. |
370
- | | `DELETE` | `204` | `401`, `404` | 엣지를 삭제합니다. <br> `401`: 미인증. <br> `404`: 엣지 없음. |
371
- | **/v1/notes** | `POST` | `201` | `400`, `401` | 노트를 생성합니다. <br> `400`: 제목/내용 누락. <br> `401`: 미인증. |
372
- | | `GET` | `200` | `401` | 모든 노트를 조회합니다. <br> `401`: 미인증. |
373
- | **/v1/notes/{id}** | `GET` | `200` | `401`, `404` | 단일 노트를 조회합니다. <br> `401`: 미인증. <br> `404`: 노트 없음. |
374
- | | `PATCH` | `200` | `400`, `401`, `404` | 노트를 업데이트합니다. <br> `400`: 입력값 오류. <br> `401`: 미인증. <br> `404`: 노트 없음. |
375
- | | `DELETE` | `204` | `401`, `404` | 노트를 삭제합니다. <br> `401`: 미인증. <br> `404`: 노트 없음. |
376
- | **/v1/folders** | `POST` | `201` | `400`, `401` | 폴더를 생성합니다. <br> `400`: 이름 누락. <br> `401`: 미인증. |
377
- | | `GET` | `200` | `401` | 모든 폴더를 조회합니다. <br> `401`: 미인증. |
378
- | **/v1/sync/pull** | `GET` | `200` | `400`, `401` | 변경 사항을 가져옵니다. <br> `400`: `since` 파라미터 형식 오류. <br> `401`: 미인증. |
379
- | **/v1/sync/push** | `POST` | `204` | `400`, `401`, `409` | 변경 사항을 푸시합니다. <br> `400`: 데이터 형식 오류. <br> `401`: 미인증. <br> `409`: 데이터 버전 충돌 (클라이언트가 구버전 데이터 수정 시도). |
380
- | **/v1/graph-ai/generate** | `POST` | `202` | `401`, `409` | 그래프 생성 요청을 시작합니다. <br> `401`: 미인증. <br> `409`: 이미 진행 중인 작업이 있음. |
381
- | **/v1/graph-ai/test/generate-json** | `POST` | `202` | `400` | [테스트용] JSON 기반 그래프 생성 요청. <br> `400`: JSON 형식이 잘못되었거나 필수 필드 누락. |
137
+ ## 📝 License
138
+
139
+ This SDK is proprietary software of the TACO 4 Team.
@@ -39,38 +39,33 @@ export declare class AiApi {
39
39
  constructor(rb: RequestBuilder);
40
40
  /**
41
41
  * 대화 내에서 AI와 채팅을 진행합니다.
42
+ * - 파일 첨부 가능 (files 인자)
43
+ * - 스트리밍 기본 지원 (Server-Sent Events)
44
+ * - onStream 콜백을 통해 청크 수신 가능
45
+ * - Promise는 최종 완료된 응답(AIChatResponseDto)으로 resolve됨 (기존 호환성 유지)
46
+ *
42
47
  * @param conversationId - 대화 ID
43
48
  * @param dto - 채팅 요청 데이터
44
- * - `model` ('openai' | 'deepseek'): 사용할 AI 모델
45
- * - `chatContent` (string): 사용자 입력 메시지 내용
46
- * @returns 업데이트된 메시지 목록
47
- * - `messages` (MessageDto[]): 생성된 메시지 목록 (사용자 메시지 + AI 응답 메시지)
48
- * @example
49
- * const response = await client.ai.chat('c_123', {
50
- * model: 'openai',
51
- * chatContent: 'Hello, how are you?'
52
- * });
53
- * console.log(response.data);
54
- * // Output:
55
- * {
56
- * messages: [
57
- * {
58
- * id: 'm_user_1',
59
- * role: 'user',
60
- * content: 'Hello, how are you?',
61
- * createdAt: '2024-02-20T10:00:00Z',
62
- * ...
63
- * },
64
- * {
65
- * id: 'm_ai_1',
66
- * role: 'assistant',
67
- * content: 'I am doing well, thank you!',
68
- * createdAt: '2024-02-20T10:00:01Z',
69
- * ...
70
- * }
71
- * ]
72
- * }
49
+ * @param files - (선택) 업로드할 파일 리스트
50
+ * @param onStream - (선택) 스트림 청크 수신 콜백
73
51
  */
74
- chat(conversationId: string, dto: AIChatRequestDto): Promise<HttpResponse<AIChatResponseDto>>;
52
+ chat(conversationId: string, dto: AIChatRequestDto, files?: File[], onStream?: (chunk: string) => void): Promise<HttpResponse<AIChatResponseDto>>;
53
+ /**
54
+ * AI 채팅 스트림을 엽니다.
55
+ * @param conversationId
56
+ * @param dto
57
+ * @param onEvent
58
+ * @param options
59
+ */
60
+ chatStream(conversationId: string, dto: AIChatRequestDto, files: File[] | undefined, onEvent: (event: any) => void, options?: {
61
+ signal?: AbortSignal;
62
+ fetchImpl?: any;
63
+ }): Promise<() => void>;
64
+ /**
65
+ * AI 관련 파일을 다운로드합니다.
66
+ * @param fileKey 파일 키 (S3 Key)
67
+ * @returns Blob 객체
68
+ */
69
+ downloadFile(fileKey: string): Promise<Blob>;
75
70
  }
76
71
  //# sourceMappingURL=ai.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../src/endpoints/ai.ts"],"names":[],"mappings":"AAAA,OAA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