@blade-hq/agent-kit 1.0.20 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{SkillStatusBar-DskumalP.d.ts → SkillStatusBar-DluiBsVj.d.ts} +1 -1
- package/dist/{blade-client-KZiBuBHI.d.ts → blade-client-CseN7OW9.d.ts} +69 -1
- package/dist/{chunk-ADVQBVGQ.js → chunk-3S5Z6J7V.js} +2 -2
- package/dist/{chunk-V74REX3Q.js → chunk-7F6UP5LP.js} +250 -2
- package/dist/chunk-7F6UP5LP.js.map +1 -0
- package/dist/{chunk-MKZ4VTJ2.js → chunk-MPGRAWLS.js} +2 -2
- package/dist/{chunk-ZKOSOL3V.js → chunk-O4TRZMGD.js} +10 -6
- package/dist/chunk-O4TRZMGD.js.map +1 -0
- package/dist/{chunk-JWWU2GWP.js → chunk-XEKYDE2R.js} +5 -5
- package/dist/{chunk-TLB4ORQT.js → chunk-YVAP7QQ7.js} +17 -2
- package/dist/{chunk-TLB4ORQT.js.map → chunk-YVAP7QQ7.js.map} +1 -1
- package/dist/client/index.d.ts +172 -1
- package/dist/client/index.js +3 -1
- package/dist/react/api/vibe-coding.d.ts +2 -2
- package/dist/react/api/vibe-coding.js +2 -2
- package/dist/react/components/chat/index.d.ts +3 -3
- package/dist/react/components/chat/index.js +5 -5
- package/dist/react/components/plan/index.js +4 -4
- package/dist/react/components/session/index.js +3 -3
- package/dist/react/components/workspace/index.d.ts +2 -2
- package/dist/react/components/workspace/index.js +31 -3
- package/dist/react/components/workspace/index.js.map +1 -1
- package/dist/react/index.d.ts +7 -5
- package/dist/react/index.js +6 -6
- package/dist/{sessions-BX8qHBN3.d.ts → sessions-DI9DVun7.d.ts} +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/chunk-V74REX3Q.js.map +0 -1
- package/dist/chunk-ZKOSOL3V.js.map +0 -1
- /package/dist/{chunk-ADVQBVGQ.js.map → chunk-3S5Z6J7V.js.map} +0 -0
- /package/dist/{chunk-MKZ4VTJ2.js.map → chunk-MPGRAWLS.js.map} +0 -0
- /package/dist/{chunk-JWWU2GWP.js.map → chunk-XEKYDE2R.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-
|
|
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 {
|
|
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,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useSessionStore
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YVAP7QQ7.js";
|
|
4
4
|
|
|
5
5
|
// src/react/hooks/use-session.ts
|
|
6
6
|
function useSession() {
|
|
@@ -27,4 +27,4 @@ function useSession() {
|
|
|
27
27
|
export {
|
|
28
28
|
useSession
|
|
29
29
|
};
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
30
|
+
//# sourceMappingURL=chunk-3S5Z6J7V.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-
|
|
1759
|
+
//# sourceMappingURL=chunk-7F6UP5LP.js.map
|