@blade-hq/agent-kit 0.4.4 → 0.4.6

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 (51) hide show
  1. package/README.md +8 -1
  2. package/dist/chunk-2UP7MG3J.js +66 -0
  3. package/dist/chunk-2UP7MG3J.js.map +1 -0
  4. package/dist/chunk-4VWLTG5L.js +2984 -0
  5. package/dist/chunk-4VWLTG5L.js.map +1 -0
  6. package/dist/chunk-7LEKQI47.js +32 -0
  7. package/dist/chunk-7LEKQI47.js.map +1 -0
  8. package/dist/chunk-DQCXSPHP.js +33 -0
  9. package/dist/chunk-DQCXSPHP.js.map +1 -0
  10. package/dist/chunk-I3FFV63W.js +30 -0
  11. package/dist/chunk-I3FFV63W.js.map +1 -0
  12. package/dist/chunk-J3XVFPOV.js +58 -0
  13. package/dist/chunk-J3XVFPOV.js.map +1 -0
  14. package/dist/chunk-JCJFFJ42.js +39 -0
  15. package/dist/chunk-JCJFFJ42.js.map +1 -0
  16. package/dist/chunk-LIL4FIZP.js +7992 -0
  17. package/dist/chunk-LIL4FIZP.js.map +1 -0
  18. package/dist/chunk-OKQWPNE3.js +1077 -0
  19. package/dist/chunk-OKQWPNE3.js.map +1 -0
  20. package/dist/chunk-PZ5AY32C.js +10 -0
  21. package/dist/chunk-PZ5AY32C.js.map +1 -0
  22. package/dist/chunk-TC5BBLWO.js +29 -0
  23. package/dist/chunk-TC5BBLWO.js.map +1 -0
  24. package/dist/chunk-VD4CKRMT.js +127 -0
  25. package/dist/chunk-VD4CKRMT.js.map +1 -0
  26. package/dist/chunk-X6MEYCU7.js +1401 -0
  27. package/dist/chunk-X6MEYCU7.js.map +1 -0
  28. package/dist/client/index.d.ts +529 -40
  29. package/dist/client/index.js +24 -1033
  30. package/dist/client/index.js.map +1 -1
  31. package/dist/react/api/licenses.js +11 -1470
  32. package/dist/react/api/licenses.js.map +1 -1
  33. package/dist/react/api/vibe-coding.js +25 -1481
  34. package/dist/react/api/vibe-coding.js.map +1 -1
  35. package/dist/react/cards/register.js +45 -138
  36. package/dist/react/cards/register.js.map +1 -1
  37. package/dist/react/components/chat/index.js +28 -11366
  38. package/dist/react/components/chat/index.js.map +1 -1
  39. package/dist/react/components/plan/index.js +135 -3054
  40. package/dist/react/components/plan/index.js.map +1 -1
  41. package/dist/react/components/session/index.js +21 -1499
  42. package/dist/react/components/session/index.js.map +1 -1
  43. package/dist/react/components/workspace/index.js +116 -1715
  44. package/dist/react/components/workspace/index.js.map +1 -1
  45. package/dist/react/devtools/bridge-devtools/index.js +8 -51
  46. package/dist/react/devtools/bridge-devtools/index.js.map +1 -1
  47. package/dist/react/index.d.ts +74 -2
  48. package/dist/react/index.js +656 -13958
  49. package/dist/react/index.js.map +1 -1
  50. package/dist/style.css +2 -0
  51. package/package.json +5 -2
@@ -1,1036 +1,27 @@
1
- // src/client/rest.ts
2
- var BladeApiError = class extends Error {
3
- response;
4
- status;
5
- statusText;
6
- constructor(response, message) {
7
- super(message ?? `Blade API request failed with ${response.status} ${response.statusText}`);
8
- this.name = "BladeApiError";
9
- this.response = response;
10
- this.status = response.status;
11
- this.statusText = response.statusText;
12
- }
13
- };
14
-
15
- // src/client/resources/api-keys.ts
16
- var ApiKeysResource = class {
17
- constructor(client) {
18
- this.client = client;
19
- }
20
- client;
21
- listApiKeys() {
22
- return this.client.json("GET", "/api/user/api-keys/");
23
- }
24
- createApiKey(name) {
25
- return this.client.json("POST", "/api/user/api-keys/", { name });
26
- }
27
- renameApiKey(id, name) {
28
- return this.client.json("PATCH", `/api/user/api-keys/${encodeURIComponent(id)}`, { name });
29
- }
30
- async deleteApiKey(id) {
31
- await this.client.json("DELETE", `/api/user/api-keys/${encodeURIComponent(id)}`);
32
- }
33
- };
34
-
35
- // src/client/resources/auth.ts
36
- var AuthResource = class {
37
- constructor(client) {
38
- this.client = client;
39
- }
40
- client;
41
- getProviders() {
42
- return this.client.json("GET", "/api/auth/providers");
43
- }
44
- getMe() {
45
- return this.client.json("GET", "/api/auth/me");
46
- }
47
- logout() {
48
- return this.client.json("POST", "/api/auth/logout");
49
- }
50
- };
51
-
52
- // src/client/resources/gis.ts
53
- var GisResource = class {
54
- constructor(client) {
55
- this.client = client;
56
- }
57
- client;
58
- fetchGisState(sessionId, init) {
59
- return this.client.jsonFromInit(`/api/gis/${sessionId}/state`, init);
60
- }
61
- fetchRuntimeConfig(init) {
62
- return this.client.jsonFromInit("/api/config", init);
63
- }
64
- };
65
-
66
- // src/client/resources/licenses.ts
67
- var LicensesResource = class {
68
- constructor(client) {
69
- this.client = client;
70
- }
71
- client;
72
- getDeviceUuid() {
73
- return this.client.json("GET", "/api/licenses/device-uuid");
74
- }
75
- validateLicense() {
76
- return this.client.json("GET", "/api/licenses/validate");
77
- }
78
- getLicenseStatus() {
79
- return this.client.json("GET", "/api/licenses/status");
80
- }
81
- async uploadLicense(file) {
82
- const formData = new FormData();
83
- formData.append("file", file);
84
- const response = await this.client.formData("POST", "/api/licenses/upload", formData);
85
- return response.json();
86
- }
87
- };
88
-
89
- // src/client/resources/memories.ts
90
- var MemoriesResource = class {
91
- constructor(client) {
92
- this.client = client;
93
- }
94
- client;
95
- createMemory(body) {
96
- return this.client.json("POST", "/api/memories", body);
97
- }
98
- listMemories(params) {
99
- const search = new URLSearchParams();
100
- if (params?.keyword) search.set("keyword", params.keyword);
101
- if (params?.skill_name != null) search.set("skill_name", params.skill_name);
102
- if (params?.type) search.set("type", params.type);
103
- if (params?.record_type) search.set("record_type", params.record_type);
104
- if (params?.scope) search.set("scope", params.scope);
105
- if (params?.owner) search.set("owner", params.owner);
106
- if (params?.topic) search.set("topic", params.topic);
107
- if (params?.status) search.set("status", params.status);
108
- if (params?.offset !== void 0) search.set("offset", String(params.offset));
109
- if (params?.limit !== void 0) search.set("limit", String(params.limit));
110
- const qs = search.toString();
111
- return this.client.json("GET", `/api/memories${qs ? `?${qs}` : ""}`);
112
- }
113
- getMemory(id) {
114
- return this.client.json("GET", `/api/memories/${id}`);
115
- }
116
- updateMemory(id, body) {
117
- return this.client.json("PUT", `/api/memories/${id}`, body);
118
- }
119
- patchMemory(id, disabled) {
120
- return this.client.json("PATCH", `/api/memories/${id}`, { disabled });
121
- }
122
- deleteMemory(id) {
123
- return this.client.json("DELETE", `/api/memories/${id}`);
124
- }
125
- batchMemories(action, ids) {
126
- return this.client.json("POST", "/api/memories/batch", { action, ids });
127
- }
128
- };
129
-
130
- // src/client/resources/models.ts
131
- import { type } from "arktype";
132
- var ModelOption = type({
133
- id: "string",
134
- label: "string"
135
- });
136
- var ModelsConfig = type({
137
- default: "string",
138
- models: ModelOption.array()
139
- });
140
- var ModelsResource = class {
141
- constructor(client) {
142
- this.client = client;
143
- }
144
- client;
145
- async getModelsConfig(init) {
146
- const data = await this.client.jsonFromInit("/api/config/models", init);
147
- return ModelsConfig.assert(data);
148
- }
149
- };
150
-
151
- // src/client/resources/registry.ts
152
- var REGISTRY_PREFIX = "/api-registry";
153
- var API_TO_FRONTEND_TYPE = {
154
- tool: "tools",
155
- datasource: "data",
156
- knowledgebase: "knowledge",
157
- agent: "agent"
158
- };
159
- function normalizeResource(raw) {
160
- return {
161
- ...raw,
162
- id: String(raw.id),
163
- type: API_TO_FRONTEND_TYPE[raw.type] ?? raw.type
164
- };
165
- }
166
- var RegistryResource = class {
167
- constructor(client) {
168
- this.client = client;
169
- this.databaseApi = this.createResourceApi("datasource");
170
- this.toolApi = this.createResourceApi("tool");
171
- this.knowledgeApi = this.createResourceApi("knowledgebase");
172
- this.agentApi = this.createResourceApi("agent");
173
- }
174
- client;
175
- databaseApi;
176
- toolApi;
177
- knowledgeApi;
178
- agentApi;
179
- createResourceApi(apiType) {
180
- return {
181
- list: (init) => this.client.jsonFromInit(`${REGISTRY_PREFIX}/resources?type=${apiType}`, init).then((response) => (response.items ?? []).map((item) => normalizeResource(item))),
182
- get: (id, init) => this.client.jsonFromInit(`${REGISTRY_PREFIX}/resources/${encodeURIComponent(id)}`, init).then((item) => normalizeResource(item)),
183
- create: (data, init) => this.client.jsonFromInit(`${REGISTRY_PREFIX}/resources`, {
184
- method: "POST",
185
- headers: { "Content-Type": "application/json" },
186
- body: JSON.stringify(data),
187
- ...init
188
- }),
189
- update: (id, data, init) => this.client.jsonFromInit(`${REGISTRY_PREFIX}/resources/${encodeURIComponent(id)}`, {
190
- method: "PUT",
191
- headers: { "Content-Type": "application/json" },
192
- body: JSON.stringify(data),
193
- ...init
194
- }),
195
- delete: async (id, init) => {
196
- await this.client.textFromInit(`${REGISTRY_PREFIX}/resources/${encodeURIComponent(id)}`, {
197
- method: "DELETE",
198
- ...init
199
- });
200
- }
201
- };
202
- }
203
- listSkillOrgs() {
204
- return this.client.json("GET", `${REGISTRY_PREFIX}/skills/orgs`);
205
- }
206
- publishSkill(sessionId, org, version) {
207
- return this.client.json("POST", `/api/sessions/${encodeURIComponent(sessionId)}/skill-publish`, {
208
- org,
209
- version
210
- });
211
- }
212
- };
213
-
214
- // src/client/resources/scenarios.ts
215
- var ScenariosResource = class {
216
- constructor(client) {
217
- this.client = client;
218
- }
219
- client;
220
- listQuickScenarios(init) {
221
- return this.client.jsonFromInit("/api/scenarios", init);
222
- }
223
- createQuickScenario(payload, init) {
224
- return this.client.jsonFromInit("/api/scenarios", {
225
- method: "POST",
226
- body: JSON.stringify(payload),
227
- ...init
228
- });
229
- }
230
- deleteQuickScenario(scenarioId, init) {
231
- return this.client.jsonFromInit(`/api/scenarios/${scenarioId}`, {
232
- method: "DELETE",
233
- ...init
234
- });
235
- }
236
- updateQuickScenario(scenarioId, payload, init) {
237
- return this.client.jsonFromInit(`/api/scenarios/${scenarioId}`, {
238
- method: "PUT",
239
- body: JSON.stringify(payload),
240
- ...init
241
- });
242
- }
243
- async listBladeHubScenarioResources(limit = 500, init) {
244
- const params = new URLSearchParams({ limit: String(limit) });
245
- const response = await this.client.jsonFromInit(
246
- `/api/skills/scenario-resources?${params}`,
247
- init
248
- );
249
- return response.items ?? [];
250
- }
251
- };
252
-
253
- // src/client/resources/sessions.ts
254
- function toCreateSessionPayload(request) {
255
- return {
256
- intent: request.intent ?? "",
257
- template_id: request.template_id,
258
- solution_id: request.solution_id,
259
- biz_role_id: request.biz_role_id ?? null,
260
- model: request.model ?? null,
261
- memory_enabled: request.memory_enabled ?? null,
262
- primary_skill_id: request.primary_skill_id ?? null,
263
- software_factory_id: request.software_factory_id ?? null
264
- };
265
- }
266
- var SessionsResource = class {
267
- constructor(client) {
268
- this.client = client;
269
- }
270
- client;
271
- fetchSessionsPage({
272
- limit,
273
- offset,
274
- template_id_prefix,
275
- q
276
- }) {
277
- const searchParams = new URLSearchParams();
278
- searchParams.set("limit", String(limit));
279
- searchParams.set("offset", String(offset));
280
- if (template_id_prefix) searchParams.set("template_id_prefix", template_id_prefix);
281
- const trimmedQuery = q?.trim();
282
- if (trimmedQuery) searchParams.set("q", trimmedQuery);
283
- return this.client.json("GET", `/api/sessions?${searchParams.toString()}`);
284
- }
285
- async listSessions(template_id_prefix) {
286
- const pageSize = 100;
287
- const sessions = [];
288
- let offset = 0;
289
- while (true) {
290
- const page = await this.fetchSessionsPage({ limit: pageSize, offset, template_id_prefix });
291
- sessions.push(...page.items);
292
- if (sessions.length >= page.total || page.items.length === 0) return sessions;
293
- offset += page.items.length;
294
- }
295
- }
296
- listSessionsPaginated(params) {
297
- return this.fetchSessionsPage(params);
298
- }
299
- listSessionsWithSkillData() {
300
- return this.client.json("GET", "/api/sessions/with-skill-data");
301
- }
302
- createSession(intent, template_id, primary_skill_id) {
303
- return this.createSessionWithRequest({ intent, template_id, primary_skill_id });
304
- }
305
- createSessionWithRequest(request) {
306
- return this.client.json("POST", "/api/sessions", toCreateSessionPayload(request));
307
- }
308
- getSession(sessionId, init) {
309
- return this.client.jsonFromInit(`/api/sessions/${sessionId}`, init);
310
- }
311
- updateSession(sessionId, payload) {
312
- return this.client.json("PATCH", `/api/sessions/${sessionId}`, payload);
313
- }
314
- pinSession(sessionId, pinned) {
315
- return this.client.json("PATCH", `/api/sessions/${sessionId}/pin`, { pinned });
316
- }
317
- startReplaySession(sourceSessionId, speed = 5) {
318
- return this.client.json("POST", `/api/sessions/${sourceSessionId}/replay`, { speed });
319
- }
320
- updateReplaySession(sessionId, payload) {
321
- return this.client.json("PATCH", `/api/sessions/${sessionId}/replay`, payload);
322
- }
323
- updateSharing(sessionId, shared) {
324
- return this.client.json("PATCH", `/api/sessions/${sessionId}/sharing`, { shared });
325
- }
326
- updateSessionMemory(sessionId, memoryEnabled) {
327
- return this.client.json("PATCH", `/api/sessions/${sessionId}/memory`, {
328
- memory_enabled: memoryEnabled
329
- });
330
- }
331
- createShare(sessionId) {
332
- return this.client.json("POST", `/api/sessions/${sessionId}/share`, {});
333
- }
334
- revokeShare(sessionId, token) {
335
- return this.client.json("DELETE", `/api/sessions/${sessionId}/share/${encodeURIComponent(token)}`);
336
- }
337
- getSharedSession(token) {
338
- return this.client.jsonFromInit(`/api/share/${encodeURIComponent(token)}`, {
339
- credentials: "omit",
340
- headers: { Accept: "application/json" }
341
- });
342
- }
343
- getSessionTasks(sessionId) {
344
- return this.client.json("GET", `/api/sessions/${sessionId}/tasks`);
345
- }
346
- getSessionTurns(sessionId) {
347
- return this.client.json("GET", `/api/sessions/${sessionId}/messages`);
348
- }
349
- getSessionContextStats(sessionId, init) {
350
- return this.client.jsonFromInit(`/api/sessions/${sessionId}/context-stats`, init);
351
- }
352
- getSessionHistory(sessionId, init) {
353
- return this.client.jsonFromInit(`/api/sessions/${sessionId}/history`, init);
354
- }
355
- tokenizePrompt(prompt, model) {
356
- return this.client.json("POST", "/api/sessions/tokenize/prompt", { prompt, model });
357
- }
358
- tokenizeMessages(messages, options) {
359
- return this.client.json("POST", "/api/sessions/tokenize/messages", {
360
- messages,
361
- model: options?.model,
362
- add_generation_prompt: options?.add_generation_prompt ?? true,
363
- enable_thinking: options?.enable_thinking ?? null,
364
- tools: options?.tools ?? null
365
- });
366
- }
367
- getSessionCheckpoints(sessionId, init) {
368
- return this.client.jsonFromInit(`/api/sessions/${sessionId}/checkpoints`, init);
369
- }
370
- checkoutSession(sessionId, checkpointId, position) {
371
- return this.client.json("POST", `/api/sessions/${sessionId}/checkout`, {
372
- checkpoint_id: checkpointId,
373
- position
374
- });
375
- }
376
- async rewindSession(sessionId, checkpointId) {
377
- const result = await this.checkoutSession(sessionId, checkpointId, "before");
378
- return { id: result.id, content: result.content };
379
- }
380
- switchBranch(sessionId, checkpointId) {
381
- return this.client.json("POST", `/api/sessions/${sessionId}/switch-branch`, {
382
- checkpoint_id: checkpointId
383
- });
384
- }
385
- deleteSession(sessionId) {
386
- return this.client.json("DELETE", `/api/sessions/${sessionId}`);
387
- }
388
- listBackgroundTasks(sessionId, init) {
389
- return this.client.jsonFromInit(`/api/sessions/${sessionId}/background-tasks`, init);
390
- }
391
- getBackgroundTask(sessionId, taskId, tail = 100, init) {
392
- return this.client.jsonFromInit(`/api/sessions/${sessionId}/background-tasks/${taskId}?tail=${tail}`, init);
393
- }
394
- stopBackgroundTask(sessionId, taskId) {
395
- return this.client.json("POST", `/api/sessions/${sessionId}/background-tasks/${taskId}/stop`);
396
- }
397
- listDir(sessionId, dirPath) {
398
- return this.client.json("GET", `/api/sessions/${sessionId}/ls/${encodeURIComponent(dirPath)}`);
399
- }
400
- async uploadFiles(sessionId, dirPath, files) {
401
- const formData = new FormData();
402
- const entries = Array.from(files).map(
403
- (f) => f instanceof File ? { file: f, name: f.name } : f
404
- );
405
- for (const entry of entries) {
406
- formData.append("files", entry.file, entry.name);
407
- }
408
- if (entries.some((e) => Boolean(e.file.webkitRelativePath))) {
409
- formData.append("paths", JSON.stringify(entries.map((e) => e.file.webkitRelativePath || e.name)));
410
- }
411
- const response = await this.client.formData(
412
- "POST",
413
- `/api/sessions/${sessionId}/upload/${encodeURIComponent(dirPath)}`,
414
- formData,
415
- { expectOk: false }
416
- );
417
- return response.json();
418
- }
419
- async deleteFile(sessionId, filePath) {
420
- await this.client.json("DELETE", `/api/sessions/${sessionId}/files/${encodeURIComponent(filePath)}`);
421
- }
422
- writeFile(sessionId, filePath, content) {
423
- return this.client.json("PUT", `/api/sessions/${sessionId}/files/${encodeURIComponent(filePath)}`, {
424
- content
425
- });
426
- }
427
- renameFile(sessionId, filePath, newName) {
428
- return this.client.json("POST", `/api/sessions/${sessionId}/files/${encodeURIComponent(filePath)}/rename`, {
429
- new_name: newName
430
- });
431
- }
432
- copyFile(sessionId, filePath) {
433
- return this.client.json("POST", `/api/sessions/${sessionId}/files/${encodeURIComponent(filePath)}/copy`);
434
- }
435
- shareFile(sessionId, sourcePath, linkName, shareFolder) {
436
- return this.client.json("POST", `/api/sessions/${sessionId}/share-file`, {
437
- source_path: sourcePath,
438
- link_name: linkName ?? "",
439
- share_folder: shareFolder ?? ""
440
- });
441
- }
442
- getDownloadDirUrl(sessionId, dirPath) {
443
- return this.client.buildAuthedUrl(`/api/sessions/${sessionId}/download-dir/${encodeURIComponent(dirPath)}`);
444
- }
445
- async exportSession(sessionId) {
446
- await this.getSession(sessionId);
447
- const a = document.createElement("a");
448
- a.href = this.client.buildAuthedUrl(`/api/sessions/${sessionId}/export`);
449
- a.download = `${sessionId}.zip`;
450
- document.body.appendChild(a);
451
- a.click();
452
- a.remove();
453
- }
454
- async previewImport(file) {
455
- const form = new FormData();
456
- form.append("file", file);
457
- const res = await this.client.formData("POST", "/api/sessions/preview-import", form);
458
- return res.json();
459
- }
460
- async importSession(file, name, solutionId) {
461
- const form = new FormData();
462
- form.append("file", file);
463
- if (name) form.append("name", name);
464
- if (solutionId) form.append("solution_id", solutionId);
465
- const res = await this.client.formData("POST", "/api/sessions/import", form);
466
- return res.json();
467
- }
468
- };
469
-
470
- // src/client/resources/skills.ts
471
- var SkillsResource = class {
472
- constructor(client) {
473
- this.client = client;
474
- }
475
- client;
476
- listSkills(init) {
477
- return this.client.jsonFromInit("/api/skills", init);
478
- }
479
- listSessionSkills(sessionId, init) {
480
- return this.client.jsonFromInit(`/api/sessions/${encodeURIComponent(sessionId)}/skills`, init);
481
- }
482
- resyncSkills(sessionId, init) {
483
- return this.client.jsonFromInit(`/api/sessions/${encodeURIComponent(sessionId)}/skills:resync`, {
484
- method: "POST",
485
- ...init
486
- });
487
- }
488
- async searchSkills(query, limit = 10, init) {
489
- const params = new URLSearchParams({ q: query, limit: String(limit) });
490
- const response = await this.client.jsonFromInit(
491
- `/api/skills/search?${params}`,
492
- init
493
- );
494
- return response.results;
495
- }
496
- getSkillStats(sessionId, init) {
497
- return this.client.jsonFromInit(`/api/sessions/${encodeURIComponent(sessionId)}/skill-stats`, init);
498
- }
499
- getGlobalSkillStats(init) {
500
- return this.client.jsonFromInit("/api/skill-store/stats", init);
501
- }
502
- getSkill(skillName, init) {
503
- return this.client.jsonFromInit(`/api/skills/${encodeURIComponent(skillName)}`, init);
504
- }
505
- installPartnerSkill(sessionId, payload, init) {
506
- return this.client.jsonFromInit(`/api/sessions/${encodeURIComponent(sessionId)}/skills/install`, {
507
- method: "POST",
508
- body: JSON.stringify(payload),
509
- ...init
510
- });
511
- }
512
- };
513
-
514
- // src/client/resources/software-factory.ts
515
- var SoftwareFactoryResource = class {
516
- constructor(client) {
517
- this.client = client;
518
- }
519
- client;
520
- listSoftware() {
521
- return this.client.json("GET", "/api/software-factory/software");
522
- }
523
- getSoftware(softwareId) {
524
- return this.client.json("GET", `/api/software-factory/software/${softwareId}`);
525
- }
526
- deleteSoftware(softwareId) {
527
- return this.client.json("DELETE", `/api/software-factory/software/${softwareId}`);
528
- }
529
- createSoftware(payload) {
530
- return this.client.json("POST", "/api/software-factory/software", payload);
531
- }
532
- updateSoftware(softwareId, payload) {
533
- return this.client.json("PATCH", `/api/software-factory/software/${softwareId}`, payload);
534
- }
535
- bindTopicModuleSession(softwareId, topicKey, moduleKey, sessionId, assignee) {
536
- return this.client.json(
537
- "PATCH",
538
- `/api/software-factory/software/${softwareId}/topics/${topicKey}/modules/${moduleKey}/session`,
539
- {
540
- session_id: sessionId,
541
- assignee_name: assignee?.name ?? null,
542
- assignee_type: assignee?.type ?? null
543
- }
544
- );
545
- }
546
- submitModuleForReview(softwareId, topicKey, moduleKey, subKey = "default") {
547
- return this.client.json(
548
- "POST",
549
- `/api/software-factory/software/${softwareId}/topics/${topicKey}/modules/${moduleKey}/submit-review`,
550
- { sub_key: subKey }
551
- );
552
- }
553
- completeModule(softwareId, topicKey, moduleKey, subKey = "default") {
554
- return this.client.json(
555
- "POST",
556
- `/api/software-factory/software/${softwareId}/topics/${topicKey}/modules/${moduleKey}/complete`,
557
- { sub_key: subKey }
558
- );
559
- }
560
- reopenModule(softwareId, topicKey, moduleKey, subKey = "default") {
561
- return this.client.json(
562
- "POST",
563
- `/api/software-factory/software/${softwareId}/topics/${topicKey}/modules/${moduleKey}/reopen`,
564
- { sub_key: subKey }
565
- );
566
- }
567
- listSharedFiles(softwareId) {
568
- return this.client.json("GET", `/api/software-factory/software/${softwareId}/shared-files`);
569
- }
570
- createSharedFile(softwareId, payload) {
571
- return this.client.json("POST", `/api/software-factory/software/${softwareId}/shared-files`, payload);
572
- }
573
- async uploadSoftwareDocuments(softwareId, files) {
574
- const formData = new FormData();
575
- for (const file of files) formData.append("files", file);
576
- const res = await this.client.formData(
577
- "POST",
578
- `/api/software-factory/software/${softwareId}/upload-documents`,
579
- formData
580
- );
581
- return res.json();
582
- }
583
- ensureIssueSession(softwareId) {
584
- return this.client.json("POST", `/api/software-factory/software/${softwareId}/issue-session`);
585
- }
586
- listCodingTasks(softwareId) {
587
- return this.client.json("GET", `/api/software-factory/software/${softwareId}/coding-tasks`);
588
- }
589
- startCoding(softwareId, payload) {
590
- return this.client.json("POST", `/api/software-factory/software/${softwareId}/start-coding`, payload);
591
- }
592
- readShareFileContent(softwareId, path) {
593
- return this.client.json(
594
- "GET",
595
- `/api/software-factory/software/${softwareId}/share-file-content?path=${encodeURIComponent(path)}`
596
- );
597
- }
598
- syncShare(softwareId) {
599
- return this.client.json("POST", `/api/software-factory/software/${softwareId}/sync-share`);
600
- }
601
- listTopics(softwareId) {
602
- return this.client.json("GET", `/api/software-factory/software/${softwareId}/topics`);
603
- }
604
- replaceTopics(softwareId, topics) {
605
- return this.client.json("PUT", `/api/software-factory/software/${softwareId}/topics`, { topics });
606
- }
607
- getFactoryExportUrl(softwareId) {
608
- return this.client.buildAuthedUrl(`/api/software-factory/software/${softwareId}/export`);
609
- }
610
- async importFactory(file) {
611
- const formData = new FormData();
612
- formData.append("file", file);
613
- const res = await this.client.formData("POST", "/api/software-factory/software/import", formData);
614
- return res.json();
615
- }
616
- };
617
-
618
- // src/client/resources/solutions.ts
619
- var SolutionsResource = class {
620
- constructor(client) {
621
- this.client = client;
622
- }
623
- client;
624
- async fetchSolutions() {
625
- const payload = await this.client.json("GET", "/api/solutions");
626
- if (Array.isArray(payload)) {
627
- return payload;
628
- }
629
- return Array.isArray(payload.items) ? payload.items : [];
630
- }
631
- fetchSolutionFile(solutionId, filePath) {
632
- return this.client.text(
633
- "GET",
634
- `/api/solutions/${encodeURIComponent(solutionId)}/files/${encodeURIComponent(filePath)}`
635
- );
636
- }
637
- async fetchSolutionBizRoles(solutionId, userId) {
638
- const params = new URLSearchParams();
639
- if (userId) {
640
- params.set("user_id", userId);
641
- }
642
- const suffix = params.toString() ? `?${params.toString()}` : "";
643
- const payload = await this.client.json(
644
- "GET",
645
- `/api/solutions/${encodeURIComponent(solutionId)}/biz-roles${suffix}`
646
- );
647
- return Array.isArray(payload.items) ? payload.items : [];
648
- }
649
- };
650
-
651
- // src/client/resources/user-preferences.ts
652
- var UserPreferencesResource = class {
653
- constructor(client) {
654
- this.client = client;
655
- }
656
- client;
657
- async getUserPreference(key) {
658
- const response = await this.client.json(
659
- "GET",
660
- `/api/user/preferences/${encodeURIComponent(key)}`
661
- );
662
- return response.value;
663
- }
664
- async setUserPreference(key, value) {
665
- await this.client.json(
666
- "PUT",
667
- `/api/user/preferences/${encodeURIComponent(key)}`,
668
- { value }
669
- );
670
- }
671
- };
672
-
673
- // src/client/resources/vibe-coding.ts
674
- var VibeCodingResource = class {
675
- constructor(client) {
676
- this.client = client;
677
- }
678
- client;
679
- createVibeCodingSession(params) {
680
- return this.client.json("POST", "/api/vibe-coding/sessions", params);
681
- }
682
- async listVibeCodingSessionInfos() {
683
- const result = await this.client.json(
684
- "GET",
685
- "/api/vibe-coding/sessions/status"
686
- );
687
- return result.items;
688
- }
689
- getVibeCodingSessionDebugStatus(sessionId) {
690
- return this.client.json("GET", `/api/vibe-coding/sessions/${sessionId}/debug/status`);
691
- }
692
- getVibeCodingSessionStatus(sessionId) {
693
- return this.client.json("GET", `/api/vibe-coding/sessions/${sessionId}/status`);
694
- }
695
- getVibeCodingDeployStatus(sessionId) {
696
- return this.client.json("GET", `/api/vibe-coding/sessions/${sessionId}/deploy/status`);
697
- }
698
- startVibeCodingService(sessionId) {
699
- return this.client.json("POST", `/api/vibe-coding/sessions/${sessionId}/start`);
700
- }
701
- stopVibeCodingService(sessionId) {
702
- return this.client.json("POST", `/api/vibe-coding/sessions/${sessionId}/stop`);
703
- }
704
- updateVibeCodingDebugService(sessionId) {
705
- return this.client.json("POST", `/api/vibe-coding/sessions/${sessionId}/update_debug_service`);
706
- }
707
- deployVibeCodingSession(sessionId, note, bump = "patch") {
708
- const payload = { bump };
709
- const normalizedNote = note?.trim();
710
- if (normalizedNote) payload.note = normalizedNote;
711
- return this.client.json("POST", `/api/vibe-coding/sessions/${sessionId}/deploy`, payload);
712
- }
713
- async listVibeCodingDeployVersions(sessionId) {
714
- const result = await this.client.json(
715
- "GET",
716
- `/api/vibe-coding/sessions/${sessionId}/deploy/versions`
717
- );
718
- return result.items;
719
- }
720
- startVibeCodingDeployService(sessionId, version) {
721
- const query = version ? `?version=${encodeURIComponent(version)}` : "";
722
- return this.client.json("POST", `/api/vibe-coding/sessions/${sessionId}/deploy/start${query}`);
723
- }
724
- stopVibeCodingDeployService(sessionId, version) {
725
- const query = version ? `?version=${encodeURIComponent(version)}` : "";
726
- return this.client.json("POST", `/api/vibe-coding/sessions/${sessionId}/deploy/stop${query}`);
727
- }
728
- deleteVibeCodingDeployVersion(sessionId, version) {
729
- return this.client.json(
730
- "DELETE",
731
- `/api/vibe-coding/sessions/${sessionId}/deploy/versions/${encodeURIComponent(version)}`
732
- );
733
- }
734
- deleteVibeCodingSession(sessionId) {
735
- return this.client.json("DELETE", `/api/vibe-coding/sessions/${sessionId}`);
736
- }
737
- probeVibeCodingService(sessionId, url) {
738
- return this.client.json(
739
- "GET",
740
- `/api/vibe-coding/sessions/${sessionId}/probe?url=${encodeURIComponent(url)}`
741
- );
742
- }
743
- async exportVibeCodingSession(sessionId) {
744
- const res = await this.client.fetch("GET", `/api/vibe-coding/sessions/${sessionId}/export`);
745
- const blob = await res.blob();
746
- const url = URL.createObjectURL(blob);
747
- const a = document.createElement("a");
748
- a.href = url;
749
- a.download = `${sessionId}.zip`;
750
- document.body.appendChild(a);
751
- a.click();
752
- a.remove();
753
- URL.revokeObjectURL(url);
754
- }
755
- async importVibeCodingSession(file, name, codingTemplate) {
756
- const form = new FormData();
757
- form.append("file", file);
758
- if (name) form.append("name", name);
759
- if (codingTemplate) form.append("coding_template", codingTemplate);
760
- const res = await this.client.formData("POST", "/api/vibe-coding/sessions/import", form);
761
- return res.json();
762
- }
763
- };
764
-
765
- // src/client/socket.ts
766
- import { io } from "socket.io-client";
767
-
768
- // src/client/auth.ts
769
- function buildSocketAuth(options) {
770
- const token = resolveAuthToken(options);
771
- return token ? { token } : void 0;
772
- }
773
- function resolveAuthToken(options) {
774
- const token = typeof options.token === "function" ? options.token() : options.token;
775
- return token ? token : null;
776
- }
777
-
778
- // src/client/socket.ts
779
- function createSocket(options) {
780
- const auth = buildSocketAuth(options);
781
- return io(options.baseUrl, {
782
- path: options.path ?? "/socket.io",
783
- withCredentials: true,
784
- auth: typeof options.token === "function" ? (cb) => cb(buildSocketAuth(options) ?? {}) : auth,
785
- autoConnect: false
786
- });
787
- }
788
-
789
- // src/client/blade-client.ts
790
- var REFRESH_PATH = "/api/auth/refresh";
791
- var BladeClient = class {
792
- refreshPromise = null;
793
- socketInstance = null;
794
- storeRestTokenResolver = null;
795
- storeSocketTokenResolver = null;
796
- options;
797
- apiKeys;
798
- auth;
799
- gis;
800
- licenses;
801
- memories;
802
- models;
803
- registry;
804
- scenarios;
805
- sessions;
806
- skills;
807
- softwareFactory;
808
- solutions;
809
- userPreferences;
810
- vibeCoding;
811
- constructor(options) {
812
- this.options = {
813
- ...options,
814
- baseUrl: normalizeBaseUrl(options.baseUrl)
815
- };
816
- this.apiKeys = new ApiKeysResource(this);
817
- this.auth = new AuthResource(this);
818
- this.gis = new GisResource(this);
819
- this.licenses = new LicensesResource(this);
820
- this.memories = new MemoriesResource(this);
821
- this.models = new ModelsResource(this);
822
- this.registry = new RegistryResource(this);
823
- this.scenarios = new ScenariosResource(this);
824
- this.sessions = new SessionsResource(this);
825
- this.skills = new SkillsResource(this);
826
- this.softwareFactory = new SoftwareFactoryResource(this);
827
- this.solutions = new SolutionsResource(this);
828
- this.userPreferences = new UserPreferencesResource(this);
829
- this.vibeCoding = new VibeCodingResource(this);
830
- }
831
- _attachStoreRestTokenResolver(fn) {
832
- this.storeRestTokenResolver = fn;
833
- }
834
- _attachStoreSocketTokenResolver(fn) {
835
- this.storeSocketTokenResolver = fn;
836
- }
837
- setBaseUrl(baseUrl) {
838
- const nextBaseUrl = normalizeBaseUrl(baseUrl);
839
- if (nextBaseUrl === this.options.baseUrl) {
840
- return;
841
- }
842
- this.options.baseUrl = nextBaseUrl;
843
- if (this.socketInstance) {
844
- this.socketInstance.removeAllListeners();
845
- this.socketInstance.disconnect();
846
- this.socketInstance = null;
847
- }
848
- }
849
- socket() {
850
- if (!this.socketInstance) {
851
- this.socketInstance = createSocket({
852
- baseUrl: this.options.baseUrl,
853
- token: () => this.resolveSocketToken()
854
- });
855
- }
856
- return this.socketInstance;
857
- }
858
- async json(method, path, body) {
859
- const response = await this.fetch(method, path, {
860
- body: body === void 0 ? void 0 : JSON.stringify(body),
861
- headers: body === void 0 ? void 0 : { "content-type": "application/json" }
862
- });
863
- return readJsonResponse(response);
864
- }
865
- async jsonFromInit(path, init = {}) {
866
- const method = (init.method ?? "GET").toUpperCase();
867
- const headers = new Headers(init.headers);
868
- if (init.body != null && !isFormData(init.body) && !headers.has("content-type")) {
869
- headers.set("content-type", "application/json");
870
- }
871
- const response = await this.fetch(method, path, {
872
- body: init.body,
873
- credentials: init.credentials,
874
- headers,
875
- signal: init.signal
876
- });
877
- return readJsonResponse(response);
878
- }
879
- async text(method, path) {
880
- const response = await this.fetch(method, path);
881
- return response.text();
882
- }
883
- async textFromInit(path, init = {}) {
884
- const method = (init.method ?? "GET").toUpperCase();
885
- const response = await this.fetch(method, path, {
886
- body: init.body,
887
- credentials: init.credentials,
888
- headers: init.headers,
889
- signal: init.signal
890
- });
891
- return response.text();
892
- }
893
- async responseFromInit(path, init = {}) {
894
- const method = (init.method ?? "GET").toUpperCase();
895
- return this.fetch(method, path, {
896
- body: init.body,
897
- credentials: init.credentials,
898
- headers: init.headers,
899
- signal: init.signal
900
- });
901
- }
902
- async blob(method, path) {
903
- const response = await this.fetch(method, path);
904
- return response.blob();
905
- }
906
- async formData(method, path, form, options = {}) {
907
- return this.fetch(method, path, { body: form, expectOk: options.expectOk });
908
- }
909
- async fetch(method, path, init = {}, isRetry = false) {
910
- const url = this.buildUrl(path);
911
- const response = await (this.options.fetchImpl ?? fetch)(url.toString(), {
912
- method,
913
- body: init.body,
914
- credentials: init.credentials ?? "include",
915
- headers: this.buildHeaders(url, init.headers),
916
- signal: init.signal
917
- });
918
- if (response.status === 401 && !isRetry && this.shouldRefreshFor401(url)) {
919
- const refreshed = await this.tryRefresh();
920
- if (refreshed) {
921
- return this.fetch(method, path, init, true);
922
- }
923
- }
924
- if (init.expectOk !== false && !response.ok) {
925
- throw new BladeApiError(response);
926
- }
927
- return response;
928
- }
929
- buildAuthedUrl(path) {
930
- const url = new URL(this.toBaseRelativePath(path), this.baseUrlWithTrailingSlash());
931
- const token = this.resolveTokenForUrl(url);
932
- if (token) {
933
- url.searchParams.set("token", token);
934
- }
935
- return url.toString();
936
- }
937
- buildHeaders(url, headers) {
938
- const result = new Headers(headers);
939
- if (!this.isSameBackendUrl(url)) {
940
- return result;
941
- }
942
- const token = this.resolveRestToken();
943
- if (token) {
944
- result.set("Authorization", `Bearer ${token}`);
945
- }
946
- return result;
947
- }
948
- buildUrl(path) {
949
- return new URL(this.toBaseRelativePath(path), this.baseUrlWithTrailingSlash());
950
- }
951
- baseUrlWithTrailingSlash() {
952
- return this.options.baseUrl.endsWith("/") ? this.options.baseUrl : `${this.options.baseUrl}/`;
953
- }
954
- toBaseRelativePath(path) {
955
- return path.startsWith("/") ? path.slice(1) : path;
956
- }
957
- isSameBackendUrl(url) {
958
- const base = new URL(this.baseUrlWithTrailingSlash());
959
- if (url.origin !== base.origin) {
960
- return false;
961
- }
962
- const basePath = base.pathname.replace(/\/+$/, "");
963
- if (basePath === "") {
964
- return true;
965
- }
966
- return url.pathname === basePath || url.pathname.startsWith(`${basePath}/`);
967
- }
968
- shouldRefreshFor401(url) {
969
- const refreshUrl = this.buildUrl(REFRESH_PATH);
970
- return this.isSameBackendUrl(url) && url.pathname !== refreshUrl.pathname && !this.hasExplicitBearerToken();
971
- }
972
- hasExplicitBearerToken() {
973
- return this.options.token !== void 0;
974
- }
975
- async tryRefresh() {
976
- if (this.refreshPromise) {
977
- return this.refreshPromise;
978
- }
979
- this.refreshPromise = (async () => {
980
- try {
981
- const response = await (this.options.fetchImpl ?? fetch)(
982
- this.buildUrl(REFRESH_PATH).toString(),
983
- {
984
- method: "POST",
985
- credentials: "include"
986
- }
987
- );
988
- if (!response.ok) {
989
- return false;
990
- }
991
- await this.options.onRefreshSuccess?.();
992
- return true;
993
- } catch {
994
- return false;
995
- } finally {
996
- this.refreshPromise = null;
997
- }
998
- })();
999
- return this.refreshPromise;
1000
- }
1001
- resolveTokenForUrl(url) {
1002
- if (!this.isSameBackendUrl(url)) {
1003
- return null;
1004
- }
1005
- return this.resolveRestToken();
1006
- }
1007
- resolveRestToken() {
1008
- return this.resolveToken(this.storeRestTokenResolver);
1009
- }
1010
- resolveSocketToken() {
1011
- return this.resolveToken(this.storeSocketTokenResolver);
1012
- }
1013
- resolveToken(resolver) {
1014
- const token = this.options.token === void 0 ? resolver?.() : typeof this.options.token === "function" ? this.options.token() : this.options.token;
1015
- return token ? token : null;
1016
- }
1017
- };
1018
- function normalizeBaseUrl(baseUrl) {
1019
- const normalized = baseUrl.trim().replace(/\/+$/, "");
1020
- if (normalized || typeof window === "undefined") {
1021
- return normalized;
1022
- }
1023
- return window.location.origin;
1024
- }
1025
- function isFormData(value) {
1026
- return typeof FormData !== "undefined" && value instanceof FormData;
1027
- }
1028
- function readJsonResponse(response) {
1029
- if (response.status === 204 || response.headers.get("content-length") === "0") {
1030
- return Promise.resolve(void 0);
1031
- }
1032
- return response.json();
1033
- }
1
+ import {
2
+ ApiKeysResource,
3
+ AuthResource,
4
+ BladeApiError,
5
+ BladeClient,
6
+ GisResource,
7
+ LicensesResource,
8
+ MemoriesResource,
9
+ ModelOption,
10
+ ModelsConfig,
11
+ ModelsResource,
12
+ REGISTRY_PREFIX,
13
+ RegistryResource,
14
+ ScenariosResource,
15
+ SessionsResource,
16
+ SkillsResource,
17
+ SoftwareFactoryResource,
18
+ SolutionsResource,
19
+ UserPreferencesResource,
20
+ VibeCodingResource,
21
+ createSocket,
22
+ normalizeResource
23
+ } from "../chunk-OKQWPNE3.js";
24
+ import "../chunk-PZ5AY32C.js";
1034
25
  export {
1035
26
  ApiKeysResource,
1036
27
  AuthResource,