@blade-hq/agent-kit 0.4.11 → 0.4.13
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-CHnXqybx.d.ts → SkillStatusBar-DhEw_C2P.d.ts} +2 -2
- package/dist/{blade-client-BfYaHLco.d.ts → blade-client-Brjw8njI.d.ts} +80 -2
- package/dist/{chunk-3LCNDPP6.js → chunk-6RVI56IR.js} +2 -2
- package/dist/{chunk-CDSCC4OQ.js → chunk-6UVM6PBD.js} +2 -2
- package/dist/{chunk-PJJ3Y3DZ.js → chunk-ACHKHQEO.js} +2 -2
- package/dist/{chunk-4XID5JVK.js → chunk-AGRVE5NY.js} +2 -2
- package/dist/{chunk-O2BVC7QE.js → chunk-C34J6GD3.js} +5 -5
- package/dist/{chunk-Z4FPELIQ.js → chunk-JMNQIZOC.js} +2 -2
- package/dist/{chunk-VCCMO7G5.js → chunk-UWUDHCVV.js} +206 -2
- package/dist/chunk-UWUDHCVV.js.map +1 -0
- package/dist/client/index.d.ts +223 -2
- package/dist/client/index.js +7 -1
- package/dist/{licenses-BGw5jiC4.d.ts → licenses-DZzDCfd0.d.ts} +1 -1
- package/dist/react/api/licenses.d.ts +3 -3
- package/dist/react/api/licenses.js +3 -3
- package/dist/react/api/vibe-coding.d.ts +3 -3
- package/dist/react/api/vibe-coding.js +2 -2
- package/dist/react/components/chat/index.d.ts +4 -4
- package/dist/react/components/chat/index.js +5 -5
- package/dist/react/components/plan/index.js +3 -3
- package/dist/react/components/session/index.d.ts +1 -1
- package/dist/react/components/session/index.js +3 -3
- package/dist/react/components/workspace/index.js +3 -3
- package/dist/react/index.d.ts +38 -8
- package/dist/react/index.js +63 -52
- package/dist/react/index.js.map +1 -1
- package/dist/{session-BKOc2lsz.d.ts → session-C7m4f0Gl.d.ts} +7 -2
- package/package.json +2 -1
- package/dist/chunk-VCCMO7G5.js.map +0 -1
- /package/dist/{chunk-3LCNDPP6.js.map → chunk-6RVI56IR.js.map} +0 -0
- /package/dist/{chunk-CDSCC4OQ.js.map → chunk-6UVM6PBD.js.map} +0 -0
- /package/dist/{chunk-PJJ3Y3DZ.js.map → chunk-ACHKHQEO.js.map} +0 -0
- /package/dist/{chunk-4XID5JVK.js.map → chunk-AGRVE5NY.js.map} +0 -0
- /package/dist/{chunk-O2BVC7QE.js.map → chunk-C34J6GD3.js.map} +0 -0
- /package/dist/{chunk-Z4FPELIQ.js.map → chunk-JMNQIZOC.js.map} +0 -0
|
@@ -3,8 +3,8 @@ import * as react from 'react';
|
|
|
3
3
|
import { ComponentType, ReactNode } from 'react';
|
|
4
4
|
import { C as ChatMessage, A as AskUserAnswerData, T as ToolCallInfo, M as MessageContent } from './AskUserQuestionBlock-CjvG_pUY.js';
|
|
5
5
|
import * as zustand from 'zustand';
|
|
6
|
-
import { M as ModeId, S as SessionInfo, a as SessionStatus } from './session-
|
|
7
|
-
import { m as BladeClient } from './blade-client-
|
|
6
|
+
import { M as ModeId, S as SessionInfo, a as SessionStatus } from './session-C7m4f0Gl.js';
|
|
7
|
+
import { m as BladeClient } from './blade-client-Brjw8njI.js';
|
|
8
8
|
import { C as ContentBlock } from './projection-DIfyh6RK.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as arktype_internal_variants_object_ts from 'arktype/internal/variants/object.ts';
|
|
2
2
|
import * as arktype_internal_variants_string_ts from 'arktype/internal/variants/string.ts';
|
|
3
3
|
import { T as TurnProjection } from './projection-DIfyh6RK.js';
|
|
4
|
-
import { S as SessionInfo, T as TemplateId, b as SessionDetail, c as Solution, B as BizRole } from './session-
|
|
4
|
+
import { S as SessionInfo, T as TemplateId, b as SessionDetail, c as Solution, B as BizRole } from './session-C7m4f0Gl.js';
|
|
5
5
|
import { Socket } from 'socket.io-client';
|
|
6
6
|
|
|
7
7
|
declare class BladeApiError extends Error {
|
|
@@ -147,6 +147,25 @@ declare class GisResource {
|
|
|
147
147
|
fetchRuntimeConfig(init?: RequestInit): Promise<RuntimeConfig>;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
+
type JsonSchemaObject = Record<string, unknown>;
|
|
151
|
+
interface HeadlessRunOptions {
|
|
152
|
+
schema?: JsonSchemaObject | null;
|
|
153
|
+
model?: string | null;
|
|
154
|
+
timeoutMs?: number;
|
|
155
|
+
}
|
|
156
|
+
declare class HeadlessError extends Error {
|
|
157
|
+
readonly detail?: unknown | undefined;
|
|
158
|
+
constructor(message: string, detail?: unknown | undefined);
|
|
159
|
+
}
|
|
160
|
+
declare class HeadlessResource {
|
|
161
|
+
private client;
|
|
162
|
+
constructor(client: BladeClient);
|
|
163
|
+
run<T = unknown>(prompt: string, options: HeadlessRunOptions & {
|
|
164
|
+
schema: JsonSchemaObject;
|
|
165
|
+
}): Promise<T>;
|
|
166
|
+
run(prompt: string, options?: HeadlessRunOptions): Promise<string>;
|
|
167
|
+
}
|
|
168
|
+
|
|
150
169
|
interface DeviceUuidResponse {
|
|
151
170
|
device_uuid: string;
|
|
152
171
|
}
|
|
@@ -258,6 +277,52 @@ declare class ModelsResource {
|
|
|
258
277
|
getModelsConfig(init?: RequestInit): Promise<ModelsConfig>;
|
|
259
278
|
}
|
|
260
279
|
|
|
280
|
+
declare const PublishedAppStatus: arktype_internal_variants_string_ts.StringType<"running" | "restarting" | "exited", {}>;
|
|
281
|
+
type PublishedAppStatus = typeof PublishedAppStatus.infer;
|
|
282
|
+
declare const PublishedApp: arktype_internal_variants_object_ts.ObjectType<{
|
|
283
|
+
session_id: string;
|
|
284
|
+
name: string;
|
|
285
|
+
url: string;
|
|
286
|
+
host_port: number;
|
|
287
|
+
app_port: number;
|
|
288
|
+
icon: string;
|
|
289
|
+
open_in: string;
|
|
290
|
+
created_at: number;
|
|
291
|
+
status: "running" | "restarting" | "exited";
|
|
292
|
+
os_app_id: string;
|
|
293
|
+
os_registered: boolean;
|
|
294
|
+
}, {}>;
|
|
295
|
+
type PublishedApp = typeof PublishedApp.infer;
|
|
296
|
+
declare const PublishedAppListResponse: arktype_internal_variants_object_ts.ObjectType<{
|
|
297
|
+
items: {
|
|
298
|
+
session_id: string;
|
|
299
|
+
name: string;
|
|
300
|
+
url: string;
|
|
301
|
+
host_port: number;
|
|
302
|
+
app_port: number;
|
|
303
|
+
icon: string;
|
|
304
|
+
open_in: string;
|
|
305
|
+
created_at: number;
|
|
306
|
+
status: "running" | "restarting" | "exited";
|
|
307
|
+
os_app_id: string;
|
|
308
|
+
os_registered: boolean;
|
|
309
|
+
}[];
|
|
310
|
+
}, {}>;
|
|
311
|
+
type PublishedAppListResponse = typeof PublishedAppListResponse.infer;
|
|
312
|
+
declare const UnpublishAppResponse: arktype_internal_variants_object_ts.ObjectType<{
|
|
313
|
+
ok: boolean;
|
|
314
|
+
os_app_id?: string | undefined;
|
|
315
|
+
os_registered?: boolean | undefined;
|
|
316
|
+
}, {}>;
|
|
317
|
+
type UnpublishAppResponse = typeof UnpublishAppResponse.infer;
|
|
318
|
+
|
|
319
|
+
declare class PublishedAppsResource {
|
|
320
|
+
private client;
|
|
321
|
+
constructor(client: BladeClient);
|
|
322
|
+
listPublishedApps(): Promise<PublishedApp[]>;
|
|
323
|
+
unpublishApp(sessionId: string): Promise<UnpublishAppResponse>;
|
|
324
|
+
}
|
|
325
|
+
|
|
261
326
|
declare const AgentDriver: arktype_internal_variants_string_ts.StringType<"dify", {}>;
|
|
262
327
|
type AgentDriver = typeof AgentDriver.infer;
|
|
263
328
|
declare const AgentResource: arktype_internal_variants_object_ts.ObjectType<{
|
|
@@ -493,6 +558,7 @@ interface CreateSessionRequest {
|
|
|
493
558
|
model?: string | null;
|
|
494
559
|
software_factory_id?: number | null;
|
|
495
560
|
memory_enabled?: boolean | null;
|
|
561
|
+
env?: Record<string, string>;
|
|
496
562
|
}
|
|
497
563
|
interface CheckpointNode {
|
|
498
564
|
id: string;
|
|
@@ -626,6 +692,7 @@ declare class SessionsResource {
|
|
|
626
692
|
updateSession(sessionId: string, payload: {
|
|
627
693
|
intent?: string;
|
|
628
694
|
}): Promise<SessionDetail>;
|
|
695
|
+
setSessionEnv(sessionId: string, env: Record<string, string>): Promise<SessionDetail>;
|
|
629
696
|
pinSession(sessionId: string, pinned: boolean): Promise<SessionInfo>;
|
|
630
697
|
startReplaySession(sourceSessionId: string, speed?: 1 | 2 | 5): Promise<{
|
|
631
698
|
session_id: string;
|
|
@@ -1118,6 +1185,10 @@ declare namespace ChatSendPayloadSchema {
|
|
|
1118
1185
|
[k: string]: unknown;
|
|
1119
1186
|
} | null);
|
|
1120
1187
|
type Model = (string | null);
|
|
1188
|
+
type Headless = boolean;
|
|
1189
|
+
type OutputSchema = ({
|
|
1190
|
+
[k: string]: unknown;
|
|
1191
|
+
} | null);
|
|
1121
1192
|
type FromStep = (number | string | null);
|
|
1122
1193
|
type Quotes = (unknown[] | null);
|
|
1123
1194
|
type DeprecateEntryIds = (string[] | null);
|
|
@@ -1131,6 +1202,8 @@ declare namespace ChatSendPayloadSchema {
|
|
|
1131
1202
|
mode?: Mode;
|
|
1132
1203
|
askuser_answer?: AskuserAnswer;
|
|
1133
1204
|
model?: Model;
|
|
1205
|
+
headless?: Headless;
|
|
1206
|
+
output_schema?: OutputSchema;
|
|
1134
1207
|
whatif?: (WhatIfPayload | null);
|
|
1135
1208
|
replay_decision?: ReplayDecision;
|
|
1136
1209
|
runtime_env?: RuntimeEnv;
|
|
@@ -1190,9 +1263,12 @@ type ChatStartPayload = ChatStartPayloadSchema.ChatStartPayload;
|
|
|
1190
1263
|
declare namespace ChatEndPayloadSchema {
|
|
1191
1264
|
type SessionId = (string | null);
|
|
1192
1265
|
type Status = (string | null);
|
|
1266
|
+
type FinishReason = (string | null);
|
|
1193
1267
|
interface ChatEndPayload {
|
|
1194
1268
|
session_id?: SessionId;
|
|
1195
1269
|
status?: Status;
|
|
1270
|
+
result?: unknown;
|
|
1271
|
+
finish_reason?: FinishReason;
|
|
1196
1272
|
[k: string]: unknown;
|
|
1197
1273
|
}
|
|
1198
1274
|
}
|
|
@@ -1528,9 +1604,11 @@ declare class BladeClient {
|
|
|
1528
1604
|
readonly auth: AuthResource;
|
|
1529
1605
|
readonly envBuckets: EnvBucketsResource;
|
|
1530
1606
|
readonly gis: GisResource;
|
|
1607
|
+
readonly headless: HeadlessResource;
|
|
1531
1608
|
readonly licenses: LicensesResource;
|
|
1532
1609
|
readonly memories: MemoriesResource;
|
|
1533
1610
|
readonly models: ModelsResource;
|
|
1611
|
+
readonly publishedApps: PublishedAppsResource;
|
|
1534
1612
|
readonly registry: RegistryResource;
|
|
1535
1613
|
readonly scenarios: ScenariosResource;
|
|
1536
1614
|
readonly sessions: SessionsResource;
|
|
@@ -1569,4 +1647,4 @@ declare class BladeClient {
|
|
|
1569
1647
|
private resolveToken;
|
|
1570
1648
|
}
|
|
1571
1649
|
|
|
1572
|
-
export {
|
|
1650
|
+
export { type MemoryCreateBody as $, type ApiKeyCreateResponse as A, BladeApiError as B, type CreateVibeCodingSessionResult as C, type DeviceUuidResponse as D, type CreateSessionRequest as E, type CreateSocketOptions as F, type CreateSoftwareFactorySharedFilePayload as G, type CreateSoftwareFactorySoftwarePayload as H, type FileEntry as I, GisResource as J, type GlobalSkillStats as K, LicensesResource as L, HeadlessError as M, HeadlessResource as N, type HeadlessRunOptions as O, type PortMapping as P, type HistoryNode as Q, type HttpMethod as R, type ImportPreview as S, type ImportPreviewScenario as T, type UploadLicenseResponse as U, VibeCodingResource as V, type ImportPreviewSkill as W, type InstalledRegistrySkill as X, type JsonSchemaObject as Y, MemoriesResource as Z, type Memory as _, type LicenseStatusResponse as a, type GisTarget as a$, type MemoryListParams as a0, type MemoryListResponse as a1, ModelOption as a2, ModelsConfig as a3, ModelsResource as a4, type PaginatedSessionsResult as a5, type PreviewUrlItem as a6, type ProvidersResponse as a7, PublishedAppsResource as a8, type QuickScenario as a9, type UpdateQuickScenarioPayload as aA, type UpgradeComputerResponse as aB, type UploadFileEntry as aC, type UserInfo as aD, UserPreferencesResource as aE, createSocket as aF, normalizeResource as aG, EnvBucketsResource as aH, type EnvBucket as aI, type PlatformEnvBucket as aJ, type GisState as aK, type RuntimeConfig as aL, type SkillDetail as aM, type SkillStats as aN, type SkillSummary as aO, type SkillSearchResult as aP, PartnerSkillInstallPayload as aQ, PartnerSkillInstallResult as aR, SessionSkillUploadPayload as aS, SessionSkillUploadResult as aT, PublishedApp as aU, PublishedAppListResponse as aV, PublishedAppStatus as aW, UnpublishAppResponse as aX, type BackgroundTask as aY, type GisGoal as aZ, type GisResource$1 as a_, REGISTRY_PREFIX as aa, RegistryResource as ab, type ResourceApi as ac, ScenariosResource as ad, type ServerToClientEvents as ae, type SessionContextStats as af, type SessionHistory as ag, type SessionUpdatedPayload as ah, SessionsResource as ai, type ShareLinkResult as aj, type SkillDevSession as ak, type SkillOrgListResponse as al, type SkillOrgOption as am, SkillsResource as an, type SoftwareFactoryModuleBlueprint as ao, SoftwareFactoryResource as ap, type SoftwareFactorySharedFile as aq, type SoftwareFactorySoftware as ar, type SoftwareFactoryTopic as as, type SoftwareFactoryTopicModule as at, SolutionsResource as au, type SystemErrorPayload as av, type SystemNotificationPayload as aw, type TokenizeResult as ax, type TurnProjectionPayload as ay, type TypedSocket as az, type LicenseValidateResponse as b, type GisMapCommand as b0, Task as b1, AgentDriver as b2, AgentResource as b3, DatabaseDriver as b4, DatabaseResource as b5, DifyKnowledgeConfig as b6, type GisGoalStatus as b7, HttpToolConfig as b8, KnowledgeDriver as b9, KnowledgeResource as ba, McpToolConfig as bb, MysqlConfig as bc, type ParallelMode as bd, PartnerSkillFile as be, PartnerSkillName as bf, PostgresqlConfig as bg, SessionSkillFile as bh, SessionSkillName as bi, type StageSpec as bj, type StepSpec as bk, TaskStatus as bl, ToolDriver as bm, ToolResource as bn, skillDisplayName as bo, type VibeCodingDeployStatus as c, type VibeCodingDebugSessionStatus as d, type VibeCodingSessionStatus as e, type VibeCodingDeployRecord as f, type VibeCodingSessionInfo as g, type CreateVibeCodingSessionParams as h, type DeployBumpMode as i, type ApiKeyPublic as j, ApiKeysResource as k, AuthResource as l, BladeClient as m, type BladeClientOptions as n, type BladeFetchInit as o, type BladeHubScenarioResource as p, type ChatEndPayload as q, type ChatSendPayload as r, type CheckpointNode as s, type ClientToServerEvents as t, type CodingTask as u, type CodingTaskTopic as v, type ComputerUpgradeReason as w, type ComputerUpgradeStatusResponse as x, type ContentPart as y, type CreateQuickScenarioPayload as z };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
apiFetchResponse,
|
|
3
3
|
getAuthedUrl
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-6UVM6PBD.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"]);
|
|
@@ -124,4 +124,4 @@ export {
|
|
|
124
124
|
CollapsibleTrigger,
|
|
125
125
|
CollapsibleContent
|
|
126
126
|
};
|
|
127
|
-
//# sourceMappingURL=chunk-
|
|
127
|
+
//# sourceMappingURL=chunk-6RVI56IR.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-J3XVFPOV.js";
|
|
4
4
|
import {
|
|
5
5
|
BladeClient
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-UWUDHCVV.js";
|
|
7
7
|
import {
|
|
8
8
|
createClientActions,
|
|
9
9
|
useCardStateStore
|
|
@@ -3052,4 +3052,4 @@ export {
|
|
|
3052
3052
|
bootstrapBladeClient,
|
|
3053
3053
|
getBootstrappedClient
|
|
3054
3054
|
};
|
|
3055
|
-
//# sourceMappingURL=chunk-
|
|
3055
|
+
//# sourceMappingURL=chunk-6UVM6PBD.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6UVM6PBD.js";
|
|
4
4
|
import {
|
|
5
5
|
__export
|
|
6
6
|
} from "./chunk-PZ5AY32C.js";
|
|
@@ -26,4 +26,4 @@ export {
|
|
|
26
26
|
uploadLicense,
|
|
27
27
|
licenses_exports
|
|
28
28
|
};
|
|
29
|
-
//# sourceMappingURL=chunk-
|
|
29
|
+
//# sourceMappingURL=chunk-ACHKHQEO.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useSessionStore
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6UVM6PBD.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-AGRVE5NY.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
CollapsibleContent,
|
|
4
4
|
CollapsibleTrigger,
|
|
5
5
|
resolveSessionFilePreviewTarget
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-6RVI56IR.js";
|
|
7
7
|
import {
|
|
8
8
|
AskUserQuestionBlock,
|
|
9
9
|
CardCodeBlock,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
getCodeLanguageFromFilename,
|
|
15
15
|
parseAskUserQuestion,
|
|
16
16
|
useHighlightedCodeHtml
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-JMNQIZOC.js";
|
|
18
18
|
import {
|
|
19
19
|
buildMessageContent,
|
|
20
20
|
buildToolPreviewKey,
|
|
@@ -56,7 +56,7 @@ import {
|
|
|
56
56
|
useUiBridgeStore,
|
|
57
57
|
useUiStore,
|
|
58
58
|
writeFile
|
|
59
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-6UVM6PBD.js";
|
|
60
60
|
import {
|
|
61
61
|
registerBridgeIframe,
|
|
62
62
|
tapBridgeEvent
|
|
@@ -65,7 +65,7 @@ import {
|
|
|
65
65
|
ModelOption,
|
|
66
66
|
ModelsConfig,
|
|
67
67
|
ModelsResource
|
|
68
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-UWUDHCVV.js";
|
|
69
69
|
import {
|
|
70
70
|
cn,
|
|
71
71
|
copyToClipboard
|
|
@@ -8154,4 +8154,4 @@ use-stick-to-bottom/dist/StickToBottom.js:
|
|
|
8154
8154
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
8155
8155
|
*--------------------------------------------------------------------------------------------*)
|
|
8156
8156
|
*/
|
|
8157
|
-
//# sourceMappingURL=chunk-
|
|
8157
|
+
//# sourceMappingURL=chunk-C34J6GD3.js.map
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
getAuthedUrl,
|
|
7
7
|
useUiStore
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-6UVM6PBD.js";
|
|
9
9
|
import {
|
|
10
10
|
cn,
|
|
11
11
|
copyToClipboard
|
|
@@ -1544,4 +1544,4 @@ export {
|
|
|
1544
1544
|
PlanSummaryCard,
|
|
1545
1545
|
extractLatestPlanMessages
|
|
1546
1546
|
};
|
|
1547
|
-
//# sourceMappingURL=chunk-
|
|
1547
|
+
//# sourceMappingURL=chunk-JMNQIZOC.js.map
|
|
@@ -137,6 +137,155 @@ var GisResource = class {
|
|
|
137
137
|
}
|
|
138
138
|
};
|
|
139
139
|
|
|
140
|
+
// src/client/resources/headless.ts
|
|
141
|
+
var HeadlessError = class extends Error {
|
|
142
|
+
constructor(message, detail) {
|
|
143
|
+
super(message);
|
|
144
|
+
this.detail = detail;
|
|
145
|
+
this.name = "HeadlessError";
|
|
146
|
+
}
|
|
147
|
+
detail;
|
|
148
|
+
};
|
|
149
|
+
var SYSTEM_ERROR_CHAT_END_GRACE_MS = 1e3;
|
|
150
|
+
var HeadlessResource = class {
|
|
151
|
+
constructor(client) {
|
|
152
|
+
this.client = client;
|
|
153
|
+
}
|
|
154
|
+
client;
|
|
155
|
+
async run(prompt, options = {}) {
|
|
156
|
+
const timeoutMs = options.timeoutMs ?? 3e5;
|
|
157
|
+
const { session_id } = await this.client.sessions.createSessionWithRequest({
|
|
158
|
+
intent: prompt,
|
|
159
|
+
model: options.model ?? null
|
|
160
|
+
});
|
|
161
|
+
const socket = this.client.socket();
|
|
162
|
+
await ensureSocketConnected(socket, timeoutMs);
|
|
163
|
+
return new Promise((resolve, reject) => {
|
|
164
|
+
let settled = false;
|
|
165
|
+
let stopSent = false;
|
|
166
|
+
let systemErrorTimeout = null;
|
|
167
|
+
const timeout = setTimeout(() => {
|
|
168
|
+
fail(new HeadlessError(`headless run timed out after ${timeoutMs}ms`, { session_id }));
|
|
169
|
+
}, timeoutMs);
|
|
170
|
+
const cleanup = (sendStop) => {
|
|
171
|
+
clearTimeout(timeout);
|
|
172
|
+
if (systemErrorTimeout) {
|
|
173
|
+
clearTimeout(systemErrorTimeout);
|
|
174
|
+
systemErrorTimeout = null;
|
|
175
|
+
}
|
|
176
|
+
socket.off("chat:end", onChatEnd);
|
|
177
|
+
socket.off("system:error", onSystemError);
|
|
178
|
+
if (sendStop && !stopSent) {
|
|
179
|
+
stopSent = true;
|
|
180
|
+
socket.emit("chat:stop", { session_id });
|
|
181
|
+
}
|
|
182
|
+
socket.emit("session:unsubscribe", { session_id });
|
|
183
|
+
};
|
|
184
|
+
const finish = (value) => {
|
|
185
|
+
if (settled) return;
|
|
186
|
+
settled = true;
|
|
187
|
+
cleanup(false);
|
|
188
|
+
resolve(value);
|
|
189
|
+
};
|
|
190
|
+
const fail = (error) => {
|
|
191
|
+
if (settled) return;
|
|
192
|
+
settled = true;
|
|
193
|
+
cleanup(true);
|
|
194
|
+
reject(error);
|
|
195
|
+
};
|
|
196
|
+
const rejectAfterChatEnd = (error) => {
|
|
197
|
+
if (settled) return;
|
|
198
|
+
settled = true;
|
|
199
|
+
cleanup(false);
|
|
200
|
+
reject(error);
|
|
201
|
+
};
|
|
202
|
+
function onSystemError(payload) {
|
|
203
|
+
if (payload.session_id !== session_id) return;
|
|
204
|
+
if (systemErrorTimeout) {
|
|
205
|
+
clearTimeout(systemErrorTimeout);
|
|
206
|
+
}
|
|
207
|
+
systemErrorTimeout = setTimeout(() => {
|
|
208
|
+
systemErrorTimeout = null;
|
|
209
|
+
fail(new HeadlessError(payload.message || "headless run failed", payload));
|
|
210
|
+
}, SYSTEM_ERROR_CHAT_END_GRACE_MS);
|
|
211
|
+
}
|
|
212
|
+
function onChatEnd(payload) {
|
|
213
|
+
if (payload.session_id && payload.session_id !== session_id) return;
|
|
214
|
+
const result = payload.result;
|
|
215
|
+
if (payload.status === "failed") {
|
|
216
|
+
rejectAfterChatEnd(new HeadlessError(errorMessageFromResult(result) ?? "headless run failed", payload));
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
try {
|
|
220
|
+
finish(normalizeResult(result, Boolean(options.schema)));
|
|
221
|
+
} catch (error) {
|
|
222
|
+
rejectAfterChatEnd(error);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
socket.on("chat:end", onChatEnd);
|
|
226
|
+
socket.on("system:error", onSystemError);
|
|
227
|
+
socket.emit("session:subscribe", { session_id });
|
|
228
|
+
socket.emit("chat:send", {
|
|
229
|
+
session_id,
|
|
230
|
+
message: prompt,
|
|
231
|
+
headless: true,
|
|
232
|
+
output_schema: options.schema ?? null,
|
|
233
|
+
model: options.model ?? null
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
function normalizeResult(result, hasSchema) {
|
|
239
|
+
if (!isRecord(result)) {
|
|
240
|
+
throw new HeadlessError("headless run finished without a result", result);
|
|
241
|
+
}
|
|
242
|
+
const errMsg = typeof result.err_msg === "string" ? result.err_msg : "";
|
|
243
|
+
if (errMsg) {
|
|
244
|
+
throw new HeadlessError(errMsg, result);
|
|
245
|
+
}
|
|
246
|
+
if (!hasSchema) {
|
|
247
|
+
const text = result.result;
|
|
248
|
+
return typeof text === "string" ? text : String(text ?? "");
|
|
249
|
+
}
|
|
250
|
+
const { err_msg: _errMsg, ...businessResult } = result;
|
|
251
|
+
return businessResult;
|
|
252
|
+
}
|
|
253
|
+
function errorMessageFromResult(result) {
|
|
254
|
+
if (isRecord(result) && typeof result.err_msg === "string" && result.err_msg) {
|
|
255
|
+
return result.err_msg;
|
|
256
|
+
}
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
function isRecord(value) {
|
|
260
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
261
|
+
}
|
|
262
|
+
function ensureSocketConnected(socket, timeoutMs) {
|
|
263
|
+
if (socket.connected) {
|
|
264
|
+
return Promise.resolve();
|
|
265
|
+
}
|
|
266
|
+
return new Promise((resolve, reject) => {
|
|
267
|
+
let settled = false;
|
|
268
|
+
const timeout = setTimeout(() => {
|
|
269
|
+
finish(() => reject(new HeadlessError(`socket connection timed out after ${timeoutMs}ms`)));
|
|
270
|
+
}, timeoutMs);
|
|
271
|
+
const onConnect = () => finish(resolve);
|
|
272
|
+
const onConnectError = (error) => {
|
|
273
|
+
finish(() => reject(new HeadlessError("socket connection failed", error)));
|
|
274
|
+
};
|
|
275
|
+
const finish = (callback) => {
|
|
276
|
+
if (settled) return;
|
|
277
|
+
settled = true;
|
|
278
|
+
clearTimeout(timeout);
|
|
279
|
+
socket.off("connect", onConnect);
|
|
280
|
+
socket.off("connect_error", onConnectError);
|
|
281
|
+
callback();
|
|
282
|
+
};
|
|
283
|
+
socket.on("connect", onConnect);
|
|
284
|
+
socket.on("connect_error", onConnectError);
|
|
285
|
+
socket.connect();
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
|
|
140
289
|
// src/client/resources/licenses.ts
|
|
141
290
|
var LicensesResource = class {
|
|
142
291
|
constructor(client) {
|
|
@@ -222,6 +371,50 @@ var ModelsResource = class {
|
|
|
222
371
|
}
|
|
223
372
|
};
|
|
224
373
|
|
|
374
|
+
// src/react/schemas/published-apps.ts
|
|
375
|
+
import { type as type2 } from "arktype";
|
|
376
|
+
var PublishedAppStatus = type2("'running' | 'restarting' | 'exited'");
|
|
377
|
+
var PublishedApp = type2({
|
|
378
|
+
session_id: "string",
|
|
379
|
+
name: "string",
|
|
380
|
+
url: "string",
|
|
381
|
+
host_port: "number",
|
|
382
|
+
app_port: "number",
|
|
383
|
+
icon: "string",
|
|
384
|
+
open_in: "string",
|
|
385
|
+
created_at: "number",
|
|
386
|
+
status: PublishedAppStatus,
|
|
387
|
+
os_app_id: "string",
|
|
388
|
+
os_registered: "boolean"
|
|
389
|
+
});
|
|
390
|
+
var PublishedAppListResponse = type2({
|
|
391
|
+
items: PublishedApp.array()
|
|
392
|
+
});
|
|
393
|
+
var UnpublishAppResponse = type2({
|
|
394
|
+
ok: "boolean",
|
|
395
|
+
"os_app_id?": "string",
|
|
396
|
+
"os_registered?": "boolean"
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
// src/client/resources/published-apps.ts
|
|
400
|
+
var PublishedAppsResource = class {
|
|
401
|
+
constructor(client) {
|
|
402
|
+
this.client = client;
|
|
403
|
+
}
|
|
404
|
+
client;
|
|
405
|
+
async listPublishedApps() {
|
|
406
|
+
const data = await this.client.json("GET", "/api/published-apps");
|
|
407
|
+
return PublishedAppListResponse.assert(data).items;
|
|
408
|
+
}
|
|
409
|
+
async unpublishApp(sessionId) {
|
|
410
|
+
const data = await this.client.json(
|
|
411
|
+
"DELETE",
|
|
412
|
+
`/api/published-apps/${encodeURIComponent(sessionId)}`
|
|
413
|
+
);
|
|
414
|
+
return UnpublishAppResponse.assert(data);
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
|
|
225
418
|
// src/client/resources/registry.ts
|
|
226
419
|
var REGISTRY_PREFIX = "/api-registry";
|
|
227
420
|
var API_TO_FRONTEND_TYPE = {
|
|
@@ -334,7 +527,8 @@ function toCreateSessionPayload(request) {
|
|
|
334
527
|
model: request.model ?? null,
|
|
335
528
|
memory_enabled: request.memory_enabled ?? null,
|
|
336
529
|
primary_skill_id: request.primary_skill_id ?? null,
|
|
337
|
-
software_factory_id: request.software_factory_id ?? null
|
|
530
|
+
software_factory_id: request.software_factory_id ?? null,
|
|
531
|
+
env: request.env
|
|
338
532
|
};
|
|
339
533
|
}
|
|
340
534
|
var SessionsResource = class {
|
|
@@ -385,6 +579,9 @@ var SessionsResource = class {
|
|
|
385
579
|
updateSession(sessionId, payload) {
|
|
386
580
|
return this.client.json("PATCH", `/api/sessions/${sessionId}`, payload);
|
|
387
581
|
}
|
|
582
|
+
setSessionEnv(sessionId, env) {
|
|
583
|
+
return this.client.json("PUT", `/api/sessions/${sessionId}/env`, { env });
|
|
584
|
+
}
|
|
388
585
|
pinSession(sessionId, pinned) {
|
|
389
586
|
return this.client.json("PATCH", `/api/sessions/${sessionId}/pin`, { pinned });
|
|
390
587
|
}
|
|
@@ -908,9 +1105,11 @@ var BladeClient = class {
|
|
|
908
1105
|
auth;
|
|
909
1106
|
envBuckets;
|
|
910
1107
|
gis;
|
|
1108
|
+
headless;
|
|
911
1109
|
licenses;
|
|
912
1110
|
memories;
|
|
913
1111
|
models;
|
|
1112
|
+
publishedApps;
|
|
914
1113
|
registry;
|
|
915
1114
|
scenarios;
|
|
916
1115
|
sessions;
|
|
@@ -928,9 +1127,11 @@ var BladeClient = class {
|
|
|
928
1127
|
this.auth = new AuthResource(this);
|
|
929
1128
|
this.envBuckets = new EnvBucketsResource(this);
|
|
930
1129
|
this.gis = new GisResource(this);
|
|
1130
|
+
this.headless = new HeadlessResource(this);
|
|
931
1131
|
this.licenses = new LicensesResource(this);
|
|
932
1132
|
this.memories = new MemoriesResource(this);
|
|
933
1133
|
this.models = new ModelsResource(this);
|
|
1134
|
+
this.publishedApps = new PublishedAppsResource(this);
|
|
934
1135
|
this.registry = new RegistryResource(this);
|
|
935
1136
|
this.scenarios = new ScenariosResource(this);
|
|
936
1137
|
this.sessions = new SessionsResource(this);
|
|
@@ -1150,11 +1351,14 @@ export {
|
|
|
1150
1351
|
ApiKeysResource,
|
|
1151
1352
|
AuthResource,
|
|
1152
1353
|
GisResource,
|
|
1354
|
+
HeadlessError,
|
|
1355
|
+
HeadlessResource,
|
|
1153
1356
|
LicensesResource,
|
|
1154
1357
|
MemoriesResource,
|
|
1155
1358
|
ModelOption,
|
|
1156
1359
|
ModelsConfig,
|
|
1157
1360
|
ModelsResource,
|
|
1361
|
+
PublishedAppsResource,
|
|
1158
1362
|
REGISTRY_PREFIX,
|
|
1159
1363
|
normalizeResource,
|
|
1160
1364
|
RegistryResource,
|
|
@@ -1168,4 +1372,4 @@ export {
|
|
|
1168
1372
|
createSocket,
|
|
1169
1373
|
BladeClient
|
|
1170
1374
|
};
|
|
1171
|
-
//# sourceMappingURL=chunk-
|
|
1375
|
+
//# sourceMappingURL=chunk-UWUDHCVV.js.map
|