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