@blade-hq/agent-kit 1.0.20 → 1.0.22

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 (33) hide show
  1. package/dist/{SkillStatusBar-DskumalP.d.ts → SkillStatusBar-DluiBsVj.d.ts} +1 -1
  2. package/dist/{blade-client-KZiBuBHI.d.ts → blade-client-CseN7OW9.d.ts} +69 -1
  3. package/dist/{chunk-MKZ4VTJ2.js → chunk-2QYV43YP.js} +2 -2
  4. package/dist/{chunk-V74REX3Q.js → chunk-7F6UP5LP.js} +250 -2
  5. package/dist/chunk-7F6UP5LP.js.map +1 -0
  6. package/dist/{chunk-ZKOSOL3V.js → chunk-BQKF6HJH.js} +10 -6
  7. package/dist/chunk-BQKF6HJH.js.map +1 -0
  8. package/dist/{chunk-JWWU2GWP.js → chunk-ICV7OTGX.js} +127 -26
  9. package/dist/{chunk-JWWU2GWP.js.map → chunk-ICV7OTGX.js.map} +1 -1
  10. package/dist/{chunk-TLB4ORQT.js → chunk-IMMRWXI7.js} +67 -3
  11. package/dist/chunk-IMMRWXI7.js.map +1 -0
  12. package/dist/{chunk-ADVQBVGQ.js → chunk-TYM7KL2L.js} +2 -2
  13. package/dist/client/index.d.ts +172 -1
  14. package/dist/client/index.js +3 -1
  15. package/dist/react/api/vibe-coding.d.ts +2 -2
  16. package/dist/react/api/vibe-coding.js +2 -2
  17. package/dist/react/components/chat/index.d.ts +3 -3
  18. package/dist/react/components/chat/index.js +5 -5
  19. package/dist/react/components/plan/index.js +4 -4
  20. package/dist/react/components/session/index.js +3 -3
  21. package/dist/react/components/workspace/index.d.ts +2 -2
  22. package/dist/react/components/workspace/index.js +31 -3
  23. package/dist/react/components/workspace/index.js.map +1 -1
  24. package/dist/react/index.d.ts +14 -6
  25. package/dist/react/index.js +6 -6
  26. package/dist/{sessions-BX8qHBN3.d.ts → sessions-DI9DVun7.d.ts} +1 -1
  27. package/dist/style.css +1 -1
  28. package/package.json +1 -1
  29. package/dist/chunk-TLB4ORQT.js.map +0 -1
  30. package/dist/chunk-V74REX3Q.js.map +0 -1
  31. package/dist/chunk-ZKOSOL3V.js.map +0 -1
  32. /package/dist/{chunk-MKZ4VTJ2.js.map → chunk-2QYV43YP.js.map} +0 -0
  33. /package/dist/{chunk-ADVQBVGQ.js.map → chunk-TYM7KL2L.js.map} +0 -0
@@ -4,7 +4,7 @@ import { ComponentType, ReactNode } from 'react';
4
4
  import { C as ChatMessage, A as AskUserAnswerData, T as ToolCallInfo, M as MessageContent } from './AskUserQuestionBlock---kOTouk.js';
5
5
  import * as zustand from 'zustand';
6
6
  import { M as ModeId, a as SessionInfo, b as SessionStatus } from './session-CT8Y2KHr.js';
7
- import { v as BladeClient } from './blade-client-KZiBuBHI.js';
7
+ import { v as BladeClient } from './blade-client-CseN7OW9.js';
8
8
  import { C as ContentBlock } from './projection-BWYEFYNn.js';
9
9
 
10
10
  /**
@@ -467,6 +467,61 @@ declare class RegistryResource {
467
467
  }>;
468
468
  }
469
469
 
470
+ interface ExistingSolutionRef {
471
+ kind: "existing";
472
+ solutionId: string;
473
+ bizRoleId?: string;
474
+ }
475
+ interface PreparedSolutionAsset {
476
+ kind: "prepared";
477
+ assetId: string;
478
+ bizRoleId?: string;
479
+ }
480
+ type SolutionRef = ExistingSolutionRef | PreparedSolutionAsset;
481
+ interface SessionProfile {
482
+ solution?: SolutionRef;
483
+ model?: string;
484
+ compactionRatio?: number;
485
+ enableThinking?: boolean;
486
+ memoryEnabled?: boolean;
487
+ disableTools?: string[];
488
+ env?: Record<string, string>;
489
+ }
490
+ interface RunOptions {
491
+ headless?: boolean;
492
+ outputSchema?: Record<string, unknown>;
493
+ runtimeEnv?: Record<string, string>;
494
+ timeoutMs?: number;
495
+ trace?: boolean;
496
+ compactionRatio?: number;
497
+ model?: string;
498
+ }
499
+ interface PreparedSolution extends PreparedSolutionAsset {
500
+ assetId: string;
501
+ solutionId: string;
502
+ roles: string[];
503
+ expiresAt: string;
504
+ }
505
+ interface RunResult {
506
+ sessionId: string;
507
+ chatRunId?: string;
508
+ result: unknown;
509
+ events: unknown[];
510
+ }
511
+ interface RunTrace {
512
+ events: unknown[];
513
+ history: unknown[];
514
+ result: unknown;
515
+ configSnapshot: Record<string, unknown>;
516
+ }
517
+
518
+ declare class RunsResource {
519
+ private client;
520
+ constructor(client: BladeClient);
521
+ run(sessionId: string, message: string, options?: RunOptions): Promise<RunResult>;
522
+ collectTrace(run: RunResult): Promise<RunTrace>;
523
+ }
524
+
470
525
  interface PreviewUrlItem {
471
526
  name: string;
472
527
  url: string;
@@ -560,6 +615,8 @@ interface CreateSessionRequest {
560
615
  memory_enabled?: boolean | null;
561
616
  env?: Record<string, string>;
562
617
  disable_tools?: string[] | null;
618
+ session_solution_asset_id?: string | null;
619
+ compaction_ratio?: number | null;
563
620
  }
564
621
  interface CheckpointNode {
565
622
  id: string;
@@ -693,6 +750,12 @@ declare class SessionsResource {
693
750
  createSessionWithRequest(request: CreateSessionRequest): Promise<{
694
751
  session_id: string;
695
752
  }>;
753
+ createWithProfile(params: {
754
+ intent: string;
755
+ profile: SessionProfile;
756
+ }): Promise<{
757
+ session_id: string;
758
+ }>;
696
759
  getSession(sessionId: string, init?: RequestInit): Promise<SessionDetail>;
697
760
  updateSession(sessionId: string, payload: {
698
761
  intent?: string;
@@ -1065,6 +1128,8 @@ declare class SolutionsResource {
1065
1128
  private client;
1066
1129
  constructor(client: BladeClient);
1067
1130
  fetchSolutions(): Promise<Solution[]>;
1131
+ prepareFromZip(file: File | Blob): Promise<PreparedSolution>;
1132
+ ensureFromRegistry(registryId: string): Promise<ExistingSolutionRef>;
1068
1133
  fetchSolutionFile(solutionId: string, filePath: string): Promise<string>;
1069
1134
  fetchSolutionBizRoles(solutionId: string, userId?: string): Promise<BizRole[]>;
1070
1135
  /**
@@ -1228,6 +1293,7 @@ declare namespace ChatSendPayloadSchema {
1228
1293
  type RuntimeEnv = ({
1229
1294
  [k: string]: string;
1230
1295
  } | null);
1296
+ type CompactionRatio = (number | null);
1231
1297
  interface ChatSendPayload {
1232
1298
  session_id: SessionId;
1233
1299
  message: Message;
@@ -1240,6 +1306,7 @@ declare namespace ChatSendPayloadSchema {
1240
1306
  whatif?: (WhatIfPayload | null);
1241
1307
  replay_decision?: ReplayDecision;
1242
1308
  runtime_env?: RuntimeEnv;
1309
+ compaction_ratio?: CompactionRatio;
1243
1310
  [k: string]: unknown;
1244
1311
  }
1245
1312
  interface Message {
@@ -1752,6 +1819,7 @@ declare class BladeClient {
1752
1819
  readonly models: ModelsResource;
1753
1820
  readonly publishedApps: PublishedAppsResource;
1754
1821
  readonly registry: RegistryResource;
1822
+ readonly runs: RunsResource;
1755
1823
  readonly scenarios: ScenariosResource;
1756
1824
  readonly sessions: SessionsResource;
1757
1825
  readonly skills: SkillsResource;
@@ -1796,4 +1864,4 @@ interface UploadProgress {
1796
1864
  percent?: number;
1797
1865
  }
1798
1866
 
1799
- export { type HeadlessRunInSessionResult as $, type ApiKeyCreateResponse as A, type BackgroundTask as B, type CreateVibeCodingSessionResult as C, type DeployBumpMode as D, type ChatSendPayload as E, type FileEntry as F, type ClientToServerEvents as G, type HistoryNode as H, type ImportPreview as I, type CodingTask as J, type CodingTaskTopic as K, type ComputerUpgradeReason as L, type ComputerUpgradeStatusResponse as M, type CreateQuickScenarioPayload as N, type CreateSocketOptions as O, type PortMapping as P, type CreateSoftwareFactorySharedFilePayload as Q, type CreateSoftwareFactorySoftwarePayload as R, SessionsResource as S, type TokenizeResult as T, type UploadFileEntry as U, VibeCodingResource as V, type ExportedSolutionFile as W, GisResource as X, type GlobalSkillStats as Y, HeadlessError as Z, HeadlessResource as _, type VibeCodingDeployStatus as a, Task as a$, type HeadlessRunOptions as a0, type HttpMethod as a1, type InstalledRegistrySkill as a2, type JsonSchemaObject as a3, MemoriesResource as a4, type Memory as a5, type MemoryCreateBody as a6, type MemoryListParams as a7, type MemoryListResponse as a8, ModelOption as a9, type UpdateQuickScenarioPayload as aA, type UpgradeComputerResponse as aB, type UserInfo as aC, UserPreferencesResource as aD, createSocket as aE, normalizeResource as aF, EnvBucketsResource as aG, type EnvBucket as aH, type PlatformEnvBucket as aI, type GisState as aJ, type RuntimeConfig as aK, type SkillDetail as aL, type SkillStats as aM, type SkillSummary as aN, type SkillSearchResult as aO, PartnerSkillInstallPayload as aP, PartnerSkillInstallResult as aQ, SessionSkillUploadPayload as aR, SessionSkillUploadResult as aS, PublishedApp as aT, PublishedAppListResponse as aU, PublishedAppStatus as aV, UnpublishAppResponse as aW, type GisGoal as aX, type GisResource$1 as aY, type GisTarget as aZ, type GisMapCommand as a_, ModelsConfig as aa, ModelsResource as ab, type PreviewUrlItem as ac, type ProvidersResponse as ad, PublishedAppsResource as ae, type QuickScenario as af, REGISTRY_PREFIX as ag, RegistryResource as ah, type ResourceApi as ai, ScenariosResource as aj, type ServerToClientEvents as ak, type SessionUpdatedPayload as al, type SkillOrgListResponse as am, type SkillOrgOption as an, SkillsResource as ao, type SoftwareFactoryModuleBlueprint as ap, SoftwareFactoryResource as aq, type SoftwareFactorySharedFile as ar, type SoftwareFactorySoftware as as, type SoftwareFactoryTopic as at, type SoftwareFactoryTopicModule as au, SolutionsResource as av, type SystemErrorPayload as aw, type SystemNotificationPayload as ax, type TurnProjectionPayload as ay, type TypedSocket as az, type VibeCodingDebugSessionStatus as b, AgentDriver as b0, AgentResource as b1, DatabaseDriver as b2, DatabaseResource as b3, DifyKnowledgeConfig as b4, type GisGoalStatus as b5, HttpToolConfig as b6, KnowledgeDriver as b7, KnowledgeResource as b8, McpToolConfig as b9, MysqlConfig as ba, type ParallelMode as bb, PartnerSkillFile as bc, PartnerSkillName as bd, PostgresqlConfig as be, SessionSkillFile as bf, SessionSkillName as bg, type StageSpec as bh, type StepSpec as bi, TaskStatus as bj, ToolDriver as bk, ToolResource as bl, skillDisplayName as bm, type VibeCodingSessionStatus as c, type VibeCodingDeployRecord as d, type VibeCodingSessionInfo as e, type CreateVibeCodingSessionParams as f, type ShareLinkResult as g, type CheckpointNode as h, type SessionContextStats as i, type SessionHistory as j, type PaginatedSessionsResult as k, type SkillDevSession as l, type ContentPart as m, type CreateSessionRequest as n, type ImportPreviewScenario as o, type ImportPreviewSkill as p, type UploadFilesOptions as q, type ApiKeyPublic as r, ApiKeysResource as s, AuthResource as t, BladeApiError as u, BladeClient as v, type BladeClientOptions as w, type BladeFetchInit as x, type BladeHubScenarioResource as y, type ChatEndPayload as z };
1867
+ export { HeadlessResource as $, type ApiKeyCreateResponse as A, type BackgroundTask as B, type CreateVibeCodingSessionResult as C, type DeployBumpMode as D, type ChatSendPayload as E, type FileEntry as F, type ClientToServerEvents as G, type HistoryNode as H, type ImportPreview as I, type CodingTask as J, type CodingTaskTopic as K, type ComputerUpgradeReason as L, type ComputerUpgradeStatusResponse as M, type CreateQuickScenarioPayload as N, type CreateSocketOptions as O, type PortMapping as P, type CreateSoftwareFactorySharedFilePayload as Q, type CreateSoftwareFactorySoftwarePayload as R, SessionsResource as S, type TokenizeResult as T, type UploadFileEntry as U, VibeCodingResource as V, type ExistingSolutionRef as W, type ExportedSolutionFile as X, GisResource as Y, type GlobalSkillStats as Z, HeadlessError as _, type VibeCodingDeployStatus as a, SessionSkillUploadResult as a$, type HeadlessRunInSessionResult as a0, type HeadlessRunOptions as a1, type HttpMethod as a2, type InstalledRegistrySkill as a3, type JsonSchemaObject as a4, MemoriesResource as a5, type Memory as a6, type MemoryCreateBody as a7, type MemoryListParams as a8, type MemoryListResponse as a9, type SoftwareFactorySoftware as aA, type SoftwareFactoryTopic as aB, type SoftwareFactoryTopicModule as aC, type SolutionRef as aD, SolutionsResource as aE, type SystemErrorPayload as aF, type SystemNotificationPayload as aG, type TurnProjectionPayload as aH, type TypedSocket as aI, type UpdateQuickScenarioPayload as aJ, type UpgradeComputerResponse as aK, type UserInfo as aL, UserPreferencesResource as aM, createSocket as aN, normalizeResource as aO, EnvBucketsResource as aP, type EnvBucket as aQ, type PlatformEnvBucket as aR, type GisState as aS, type RuntimeConfig as aT, type SkillDetail as aU, type SkillStats as aV, type SkillSummary as aW, type SkillSearchResult as aX, PartnerSkillInstallPayload as aY, PartnerSkillInstallResult as aZ, SessionSkillUploadPayload as a_, ModelOption as aa, ModelsConfig as ab, ModelsResource as ac, type PreparedSolution as ad, type PreparedSolutionAsset as ae, type PreviewUrlItem as af, type ProvidersResponse as ag, PublishedAppsResource as ah, type QuickScenario as ai, REGISTRY_PREFIX as aj, RegistryResource as ak, type ResourceApi as al, type RunOptions as am, type RunResult as an, type RunTrace as ao, RunsResource as ap, ScenariosResource as aq, type ServerToClientEvents as ar, type SessionProfile as as, type SessionUpdatedPayload as at, type SkillOrgListResponse as au, type SkillOrgOption as av, SkillsResource as aw, type SoftwareFactoryModuleBlueprint as ax, SoftwareFactoryResource as ay, type SoftwareFactorySharedFile as az, type VibeCodingDebugSessionStatus as b, PublishedApp as b0, PublishedAppListResponse as b1, PublishedAppStatus as b2, UnpublishAppResponse as b3, type GisGoal as b4, type GisResource$1 as b5, type GisTarget as b6, type GisMapCommand as b7, Task as b8, AgentDriver as b9, AgentResource as ba, DatabaseDriver as bb, DatabaseResource as bc, DifyKnowledgeConfig as bd, type GisGoalStatus as be, HttpToolConfig as bf, KnowledgeDriver as bg, KnowledgeResource as bh, McpToolConfig as bi, MysqlConfig as bj, type ParallelMode as bk, PartnerSkillFile as bl, PartnerSkillName as bm, PostgresqlConfig as bn, SessionSkillFile as bo, SessionSkillName as bp, type StageSpec as bq, type StepSpec as br, TaskStatus as bs, ToolDriver as bt, ToolResource as bu, skillDisplayName as bv, type VibeCodingSessionStatus as c, type VibeCodingDeployRecord as d, type VibeCodingSessionInfo as e, type CreateVibeCodingSessionParams as f, type ShareLinkResult as g, type CheckpointNode as h, type SessionContextStats as i, type SessionHistory as j, type PaginatedSessionsResult as k, type SkillDevSession as l, type ContentPart as m, type CreateSessionRequest as n, type ImportPreviewScenario as o, type ImportPreviewSkill as p, type UploadFilesOptions as q, type ApiKeyPublic as r, ApiKeysResource as s, AuthResource as t, BladeApiError as u, BladeClient as v, type BladeClientOptions as w, type BladeFetchInit as x, type BladeHubScenarioResource as y, type ChatEndPayload as z };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  apiFetchResponse,
3
3
  getAuthedUrl
4
- } from "./chunk-TLB4ORQT.js";
4
+ } from "./chunk-IMMRWXI7.js";
5
5
 
6
6
  // src/react/lib/session-file-preview.ts
7
7
  var IMAGE_EXTS = /* @__PURE__ */ new Set(["png", "jpg", "jpeg", "gif", "svg", "webp", "ico", "bmp"]);
@@ -117,4 +117,4 @@ export {
117
117
  resolveTextPreviewType,
118
118
  resolveSessionFilePreviewTarget
119
119
  };
120
- //# sourceMappingURL=chunk-MKZ4VTJ2.js.map
120
+ //# sourceMappingURL=chunk-2QYV43YP.js.map
@@ -506,6 +506,195 @@ var RegistryResource = class {
506
506
  }
507
507
  };
508
508
 
509
+ // src/client/resources/runs.ts
510
+ var SYSTEM_ERROR_CHAT_END_GRACE_MS2 = 1e3;
511
+ var RunsResource = class {
512
+ constructor(client) {
513
+ this.client = client;
514
+ }
515
+ client;
516
+ async run(sessionId, message, options = {}) {
517
+ const timeoutMs = options.timeoutMs ?? 3e5;
518
+ const socket = this.client.socket();
519
+ await ensureSocketConnected2(socket, timeoutMs, { session_id: sessionId });
520
+ return new Promise((resolve, reject) => {
521
+ const events = [];
522
+ let settled = false;
523
+ let stopSent = false;
524
+ let started = false;
525
+ let chatRunId;
526
+ let systemErrorTimeout = null;
527
+ const timeout = setTimeout(() => {
528
+ fail(new Error(`run timed out after ${timeoutMs}ms`));
529
+ }, timeoutMs);
530
+ const cleanup = (sendStop) => {
531
+ clearTimeout(timeout);
532
+ if (systemErrorTimeout) {
533
+ clearTimeout(systemErrorTimeout);
534
+ systemErrorTimeout = null;
535
+ }
536
+ socket.off("chat:start", onChatStart);
537
+ socket.off("turn:start", onTurnStart);
538
+ socket.off("turn:patch", onTurnPatch);
539
+ socket.off("turn:end", onTurnEnd);
540
+ socket.off("chat:end", onChatEnd);
541
+ socket.off("system:error", onSystemError);
542
+ if (sendStop && !stopSent) {
543
+ stopSent = true;
544
+ socket.emit("chat:stop", { session_id: sessionId }, () => void 0);
545
+ }
546
+ socket.emit("session:unsubscribe", { session_id: sessionId });
547
+ };
548
+ const finish = (payload) => {
549
+ if (settled) return;
550
+ settled = true;
551
+ cleanup(false);
552
+ const payloadChatRunId = typeof payload.chat_run_id === "string" ? payload.chat_run_id : void 0;
553
+ resolve({
554
+ sessionId,
555
+ chatRunId: chatRunId ?? payloadChatRunId,
556
+ result: payload.result,
557
+ events
558
+ });
559
+ };
560
+ const fail = (error) => {
561
+ if (settled) return;
562
+ settled = true;
563
+ cleanup(true);
564
+ reject(error);
565
+ };
566
+ const failWithoutStop = (error) => {
567
+ if (settled) return;
568
+ settled = true;
569
+ cleanup(false);
570
+ reject(error);
571
+ };
572
+ function onChatStart(payload) {
573
+ if (!isSessionEvent(payload, sessionId)) return;
574
+ started = true;
575
+ events.push({ type: "chat:start", payload });
576
+ }
577
+ function onTurnStart(payload) {
578
+ if (!isSessionEvent(payload, sessionId)) return;
579
+ events.push({ type: "turn:start", payload });
580
+ }
581
+ function onTurnPatch(payload) {
582
+ if (!isSessionEvent(payload, sessionId)) return;
583
+ events.push({ type: "turn:patch", payload });
584
+ }
585
+ function onTurnEnd(payload) {
586
+ if (!isSessionEvent(payload, sessionId)) return;
587
+ events.push({ type: "turn:end", payload });
588
+ }
589
+ function onSystemError(payload) {
590
+ if (!isSessionEvent(payload, sessionId)) return;
591
+ events.push({ type: "system:error", payload });
592
+ const error = new Error(payload.message || "run failed");
593
+ if (!started) {
594
+ failWithoutStop(error);
595
+ return;
596
+ }
597
+ if (systemErrorTimeout) {
598
+ clearTimeout(systemErrorTimeout);
599
+ }
600
+ systemErrorTimeout = setTimeout(() => {
601
+ systemErrorTimeout = null;
602
+ fail(error);
603
+ }, SYSTEM_ERROR_CHAT_END_GRACE_MS2);
604
+ }
605
+ function onChatEnd(payload) {
606
+ if (!isSessionEvent(payload, sessionId)) return;
607
+ events.push({ type: "chat:end", payload });
608
+ chatRunId = typeof payload.chat_run_id === "string" ? payload.chat_run_id : chatRunId;
609
+ if (payload.status === "failed") {
610
+ failWithoutStop(new Error(errorMessageFromResult2(payload.result) ?? "run failed"));
611
+ return;
612
+ }
613
+ finish(payload);
614
+ }
615
+ socket.on("chat:start", onChatStart);
616
+ socket.on("turn:start", onTurnStart);
617
+ socket.on("turn:patch", onTurnPatch);
618
+ socket.on("turn:end", onTurnEnd);
619
+ socket.on("chat:end", onChatEnd);
620
+ socket.on("system:error", onSystemError);
621
+ socket.emit("session:subscribe", { session_id: sessionId });
622
+ socket.emit("chat:send", buildChatSendPayload(sessionId, message, options));
623
+ });
624
+ }
625
+ async collectTrace(run) {
626
+ const history = await this.client.sessions.getSessionHistory(run.sessionId);
627
+ return {
628
+ events: run.events,
629
+ history: history.nodes,
630
+ result: run.result,
631
+ configSnapshot: collectConfigSnapshot(run.events)
632
+ };
633
+ }
634
+ };
635
+ function buildChatSendPayload(sessionId, message, options) {
636
+ return {
637
+ session_id: sessionId,
638
+ message,
639
+ headless: options.headless ?? false,
640
+ output_schema: options.outputSchema ?? null,
641
+ runtime_env: options.runtimeEnv ?? null,
642
+ compaction_ratio: options.compactionRatio ?? null,
643
+ model: options.model ?? null
644
+ };
645
+ }
646
+ function collectConfigSnapshot(events) {
647
+ const chatStart = events.find((event) => {
648
+ if (!isRecord2(event) || event.type !== "chat:start") return false;
649
+ return isRecord2(event.payload);
650
+ });
651
+ if (!isRecord2(chatStart) || !isRecord2(chatStart.payload)) {
652
+ return {};
653
+ }
654
+ return chatStart.payload;
655
+ }
656
+ function errorMessageFromResult2(result) {
657
+ if (isRecord2(result) && typeof result.err_msg === "string" && result.err_msg) {
658
+ return result.err_msg;
659
+ }
660
+ return null;
661
+ }
662
+ function isSessionEvent(payload, sessionId) {
663
+ return !payload.session_id || payload.session_id === sessionId;
664
+ }
665
+ function isRecord2(value) {
666
+ return typeof value === "object" && value !== null && !Array.isArray(value);
667
+ }
668
+ function ensureSocketConnected2(socket, timeoutMs, detail) {
669
+ if (socket.connected) {
670
+ return Promise.resolve();
671
+ }
672
+ return new Promise((resolve, reject) => {
673
+ let settled = false;
674
+ const timeout = setTimeout(() => {
675
+ const detailText = JSON.stringify(detail);
676
+ finish(
677
+ () => reject(new Error(`socket connection timed out after ${timeoutMs}ms: ${detailText}`))
678
+ );
679
+ }, timeoutMs);
680
+ const onConnect = () => finish(resolve);
681
+ const onConnectError = (error) => {
682
+ finish(() => reject(error instanceof Error ? error : new Error("socket connection failed")));
683
+ };
684
+ const finish = (callback) => {
685
+ if (settled) return;
686
+ settled = true;
687
+ clearTimeout(timeout);
688
+ socket.off("connect", onConnect);
689
+ socket.off("connect_error", onConnectError);
690
+ callback();
691
+ };
692
+ socket.on("connect", onConnect);
693
+ socket.on("connect_error", onConnectError);
694
+ socket.connect();
695
+ });
696
+ }
697
+
509
698
  // src/client/resources/scenarios.ts
510
699
  var ScenariosResource = class {
511
700
  constructor(client) {
@@ -560,7 +749,9 @@ function toCreateSessionPayload(request) {
560
749
  is_persistent: request.is_persistent ?? false,
561
750
  software_factory_id: request.software_factory_id ?? null,
562
751
  env: request.env,
563
- disable_tools: request.disable_tools ?? null
752
+ disable_tools: request.disable_tools ?? null,
753
+ session_solution_asset_id: request.session_solution_asset_id ?? null,
754
+ compaction_ratio: request.compaction_ratio ?? null
564
755
  };
565
756
  }
566
757
  var SessionsResource = class {
@@ -607,6 +798,13 @@ var SessionsResource = class {
607
798
  createSessionWithRequest(request) {
608
799
  return this.client.json("POST", "/api/sessions", toCreateSessionPayload(request));
609
800
  }
801
+ createWithProfile(params) {
802
+ const { intent, profile } = params;
803
+ return this.createSessionWithRequest({
804
+ intent,
805
+ ...profileToCreateSessionRequest(profile)
806
+ });
807
+ }
610
808
  getSession(sessionId, init) {
611
809
  return this.client.jsonFromInit(`/api/sessions/${sessionId}`, init);
612
810
  }
@@ -780,6 +978,20 @@ var SessionsResource = class {
780
978
  return res.json();
781
979
  }
782
980
  };
981
+ function profileToCreateSessionRequest(profile) {
982
+ const solution = profile.solution;
983
+ return {
984
+ solution_id: solution?.kind === "existing" ? solution.solutionId : void 0,
985
+ session_solution_asset_id: solution?.kind === "prepared" ? solution.assetId : void 0,
986
+ biz_role_id: solution?.bizRoleId ?? null,
987
+ model: profile.model ?? null,
988
+ compaction_ratio: profile.compactionRatio ?? null,
989
+ enable_thinking: profile.enableThinking ?? null,
990
+ memory_enabled: profile.memoryEnabled ?? null,
991
+ disable_tools: profile.disableTools ?? null,
992
+ env: profile.env
993
+ };
994
+ }
783
995
 
784
996
  // src/client/resources/skills.ts
785
997
  var SkillsResource = class {
@@ -948,6 +1160,21 @@ var SolutionsResource = class {
948
1160
  }
949
1161
  return Array.isArray(payload.items) ? payload.items : [];
950
1162
  }
1163
+ async prepareFromZip(file) {
1164
+ const form = new FormData();
1165
+ form.append("file", file);
1166
+ const response = await this.client.formData("POST", "/api/session-assets/solutions", form);
1167
+ const payload = await response.json();
1168
+ return toPreparedSolution(payload);
1169
+ }
1170
+ async ensureFromRegistry(registryId) {
1171
+ const payload = await this.client.json(
1172
+ "POST",
1173
+ "/api/solutions/ensure-from-registry",
1174
+ { registry_id: registryId }
1175
+ );
1176
+ return { kind: "existing", solutionId: payload.solutionId ?? payload.solution_id ?? "" };
1177
+ }
951
1178
  fetchSolutionFile(solutionId, filePath) {
952
1179
  return this.client.text(
953
1180
  "GET",
@@ -992,6 +1219,24 @@ var SolutionsResource = class {
992
1219
  );
993
1220
  }
994
1221
  };
1222
+ function toPreparedSolution(payload) {
1223
+ const data = isRecord3(payload) ? payload : {};
1224
+ const roles = Array.isArray(data.roles) ? data.roles.filter((role) => typeof role === "string") : [];
1225
+ return {
1226
+ kind: "prepared",
1227
+ assetId: stringField(data, "assetId") ?? stringField(data, "asset_id") ?? "",
1228
+ solutionId: stringField(data, "solutionId") ?? stringField(data, "solution_id") ?? "",
1229
+ roles,
1230
+ expiresAt: stringField(data, "expiresAt") ?? stringField(data, "expires_at") ?? ""
1231
+ };
1232
+ }
1233
+ function stringField(data, key) {
1234
+ const value = data[key];
1235
+ return typeof value === "string" ? value : null;
1236
+ }
1237
+ function isRecord3(value) {
1238
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1239
+ }
995
1240
  function parseContentDispositionFilename(header) {
996
1241
  if (!header) return null;
997
1242
  const starMatch = header.match(/filename\*\s*=\s*[^']*''([^;]+)/i);
@@ -1193,6 +1438,7 @@ var BladeClient = class {
1193
1438
  models;
1194
1439
  publishedApps;
1195
1440
  registry;
1441
+ runs;
1196
1442
  scenarios;
1197
1443
  sessions;
1198
1444
  skills;
@@ -1214,6 +1460,7 @@ var BladeClient = class {
1214
1460
  this.models = new ModelsResource(this);
1215
1461
  this.publishedApps = new PublishedAppsResource(this);
1216
1462
  this.registry = new RegistryResource(this);
1463
+ this.runs = new RunsResource(this);
1217
1464
  this.scenarios = new ScenariosResource(this);
1218
1465
  this.sessions = new SessionsResource(this);
1219
1466
  this.skills = new SkillsResource(this);
@@ -1498,6 +1745,7 @@ export {
1498
1745
  REGISTRY_PREFIX,
1499
1746
  normalizeResource,
1500
1747
  RegistryResource,
1748
+ RunsResource,
1501
1749
  ScenariosResource,
1502
1750
  SessionsResource,
1503
1751
  SkillsResource,
@@ -1508,4 +1756,4 @@ export {
1508
1756
  createSocket,
1509
1757
  BladeClient
1510
1758
  };
1511
- //# sourceMappingURL=chunk-V74REX3Q.js.map
1759
+ //# sourceMappingURL=chunk-7F6UP5LP.js.map