@blade-hq/agent-kit 0.5.24 → 0.5.26

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 (38) hide show
  1. package/dist/{SkillStatusBar-DO-ltefK.d.ts → SkillStatusBar-qjGb3eKD.d.ts} +7 -4
  2. package/dist/{blade-client-Bhp0hHiZ.d.ts → blade-client-DA2h2P5I.d.ts} +48 -3
  3. package/dist/{chunk-QKSZPJQX.js → chunk-4FCXKLXT.js} +11 -5
  4. package/dist/chunk-4FCXKLXT.js.map +1 -0
  5. package/dist/{chunk-63IWZ3AO.js → chunk-6L6JFSR5.js} +2 -2
  6. package/dist/{chunk-7FGJNW56.js → chunk-QCDNRR74.js} +403 -326
  7. package/dist/chunk-QCDNRR74.js.map +1 -0
  8. package/dist/{chunk-DTDZFQRY.js → chunk-UNO53NPU.js} +27 -2
  9. package/dist/chunk-UNO53NPU.js.map +1 -0
  10. package/dist/{chunk-KW66QITV.js → chunk-Y7FRTBUT.js} +20 -4
  11. package/dist/chunk-Y7FRTBUT.js.map +1 -0
  12. package/dist/{chunk-7EVVRQ7G.js → chunk-ZWO6YBLA.js} +4 -3
  13. package/dist/chunk-ZWO6YBLA.js.map +1 -0
  14. package/dist/client/index.d.ts +4615 -2834
  15. package/dist/client/index.js +1 -1
  16. package/dist/react/api/vibe-coding.d.ts +3 -3
  17. package/dist/react/api/vibe-coding.js +2 -2
  18. package/dist/react/components/chat/index.d.ts +4 -4
  19. package/dist/react/components/chat/index.js +5 -5
  20. package/dist/react/components/plan/index.js +4 -4
  21. package/dist/react/components/session/index.d.ts +1 -1
  22. package/dist/react/components/session/index.js +3 -3
  23. package/dist/react/components/workspace/index.d.ts +22 -2
  24. package/dist/react/components/workspace/index.js +31 -15
  25. package/dist/react/components/workspace/index.js.map +1 -1
  26. package/dist/react/index.d.ts +24 -179
  27. package/dist/react/index.js +10 -7
  28. package/dist/react/index.js.map +1 -1
  29. package/dist/{session-BuaeCsMC.d.ts → session-B5v5KkVd.d.ts} +5 -3
  30. package/dist/sessions-BZ3y17sP.d.ts +174 -0
  31. package/dist/style.css +1 -1
  32. package/package.json +1 -1
  33. package/dist/chunk-7EVVRQ7G.js.map +0 -1
  34. package/dist/chunk-7FGJNW56.js.map +0 -1
  35. package/dist/chunk-DTDZFQRY.js.map +0 -1
  36. package/dist/chunk-KW66QITV.js.map +0 -1
  37. package/dist/chunk-QKSZPJQX.js.map +0 -1
  38. /package/dist/{chunk-63IWZ3AO.js.map → chunk-6L6JFSR5.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---kOTouk.js';
5
5
  import * as zustand from 'zustand';
6
- import { M as ModeId, S as SessionInfo, a as SessionStatus } from './session-BuaeCsMC.js';
7
- import { j as BladeClient } from './blade-client-Bhp0hHiZ.js';
6
+ import { M as ModeId, a as SessionInfo, b as SessionStatus } from './session-B5v5KkVd.js';
7
+ import { v as BladeClient } from './blade-client-DA2h2P5I.js';
8
8
  import { C as ContentBlock } from './projection-BWYEFYNn.js';
9
9
 
10
10
  /**
@@ -172,8 +172,9 @@ interface ChatViewProps extends ChatViewCustomization {
172
172
  canShareSession?: boolean;
173
173
  onResyncSkills?: () => void;
174
174
  isResyncingSkills?: boolean;
175
+ inputLabel?: string;
175
176
  }
176
- declare function ChatView({ sessionId, renderAttachments, onBeforeSend, onCommand, canShareSession, onResyncSkills, isResyncingSkills, classNames, components, renderers, }: ChatViewProps): react_jsx_runtime.JSX.Element;
177
+ declare function ChatView({ sessionId, renderAttachments, onBeforeSend, onCommand, canShareSession, onResyncSkills, isResyncingSkills, inputLabel, classNames, components, renderers, }: ChatViewProps): react_jsx_runtime.JSX.Element;
177
178
 
178
179
  type SessionMode = ModeId;
179
180
  interface SessionState extends ClientAwareState {
@@ -218,6 +219,7 @@ declare const useSessionStore: zustand.UseBoundStore<zustand.StoreApi<SessionSta
218
219
 
219
220
  interface Props$2 {
220
221
  onSend: (message: MessageContent, targetSessionId?: string, model?: string | null) => void;
222
+ onAppend?: (message: string) => void;
221
223
  onStop: () => void | Promise<void>;
222
224
  isStreaming: boolean;
223
225
  isStopping?: boolean;
@@ -269,6 +271,7 @@ interface Props$2 {
269
271
  skillStatusBarInnerClassName?: string;
270
272
  onResyncSkills?: () => void;
271
273
  isResyncingSkills?: boolean;
274
+ inputLabel?: string;
272
275
  }
273
276
  type FileComposerAttachment = {
274
277
  id: string;
@@ -282,7 +285,7 @@ type FileComposerAttachment = {
282
285
  textContent?: string | null;
283
286
  uploadProgress?: number | null;
284
287
  };
285
- declare function ChatInput({ onSend, onStop, isStreaming, isStopping, mode, onToggleMode, renderAttachments, onBeforeSend, ensureSession, onCommand, canShareSession, slotAboveTextarea, externalDraft, externalAttachments, maxWidthClassName, className, innerClassName, SkillStatusBarComponent, skillStatusBarClassName, skillStatusBarInnerClassName, onResyncSkills, isResyncingSkills, }: Props$2): react_jsx_runtime.JSX.Element;
288
+ declare function ChatInput({ onSend, onAppend, onStop, isStreaming, isStopping, mode, onToggleMode, renderAttachments, onBeforeSend, ensureSession, onCommand, canShareSession, slotAboveTextarea, externalDraft, externalAttachments, maxWidthClassName, className, innerClassName, SkillStatusBarComponent, skillStatusBarClassName, skillStatusBarInnerClassName, onResyncSkills, isResyncingSkills, inputLabel, }: Props$2): react_jsx_runtime.JSX.Element;
286
289
 
287
290
  interface Props$1 {
288
291
  open: boolean;
@@ -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-BWYEFYNn.js';
4
- import { S as SessionInfo, T as TemplateId, b as SessionDetail, c as Solution, B as BizRole } from './session-BuaeCsMC.js';
4
+ import { a as SessionInfo, T as TemplateId, S as SessionDetail, c as Solution, B as BizRole } from './session-B5v5KkVd.js';
5
5
  import { Socket } from 'socket.io-client';
6
6
 
7
7
  declare class BladeApiError extends Error {
@@ -313,7 +313,7 @@ declare class PublishedAppsResource {
313
313
  private client;
314
314
  constructor(client: BladeClient);
315
315
  listPublishedApps(): Promise<PublishedApp[]>;
316
- unpublishApp(sessionId: string): Promise<UnpublishAppResponse>;
316
+ unpublishApp(sessionId: string, appName?: string): Promise<UnpublishAppResponse>;
317
317
  }
318
318
 
319
319
  declare const AgentDriver: arktype_internal_variants_string_ts.StringType<"dify", {}>;
@@ -1235,6 +1235,16 @@ declare namespace ChatStopPayloadSchema {
1235
1235
  }
1236
1236
  }
1237
1237
  type ChatStopPayload = ChatStopPayloadSchema.ChatStopPayload;
1238
+ declare namespace ChatAppendPayloadSchema {
1239
+ type SessionId = string;
1240
+ type Message = string;
1241
+ interface ChatAppendPayload {
1242
+ session_id: SessionId;
1243
+ message: Message;
1244
+ [k: string]: unknown;
1245
+ }
1246
+ }
1247
+ type ChatAppendPayload = ChatAppendPayloadSchema.ChatAppendPayload;
1238
1248
  declare namespace ChatCompactPayloadSchema {
1239
1249
  type SessionId = string;
1240
1250
  interface ChatCompactPayload {
@@ -1259,6 +1269,22 @@ declare namespace SessionUnsubscribePayloadSchema {
1259
1269
  }
1260
1270
  }
1261
1271
  type SessionUnsubscribePayload = SessionUnsubscribePayloadSchema.SessionUnsubscribePayload;
1272
+ declare namespace AgentBoardProjectSubscribePayloadSchema {
1273
+ type ProjectId = number;
1274
+ interface AgentBoardProjectSubscribePayload {
1275
+ project_id: ProjectId;
1276
+ [k: string]: unknown;
1277
+ }
1278
+ }
1279
+ type AgentBoardProjectSubscribePayload = AgentBoardProjectSubscribePayloadSchema.AgentBoardProjectSubscribePayload;
1280
+ declare namespace AgentBoardProjectUnsubscribePayloadSchema {
1281
+ type ProjectId = number;
1282
+ interface AgentBoardProjectUnsubscribePayload {
1283
+ project_id: ProjectId;
1284
+ [k: string]: unknown;
1285
+ }
1286
+ }
1287
+ type AgentBoardProjectUnsubscribePayload = AgentBoardProjectUnsubscribePayloadSchema.AgentBoardProjectUnsubscribePayload;
1262
1288
  declare namespace ChatStartPayloadSchema {
1263
1289
  type SessionId = (string | null);
1264
1290
  interface ChatStartPayload {
@@ -1537,6 +1563,20 @@ declare namespace VibeLogsEndPayloadSchema {
1537
1563
  }
1538
1564
  }
1539
1565
  type VibeLogsEndPayload = VibeLogsEndPayloadSchema.VibeLogsEndPayload;
1566
+ declare namespace AgentBoardBoardTaskChangedPayloadSchema {
1567
+ type ProjectId = number;
1568
+ type Action = ("created" | "updated" | "deleted");
1569
+ interface AgentBoardBoardTaskChangedPayload {
1570
+ project_id: ProjectId;
1571
+ action: Action;
1572
+ task: Task;
1573
+ [k: string]: unknown;
1574
+ }
1575
+ interface Task {
1576
+ [k: string]: unknown;
1577
+ }
1578
+ }
1579
+ type AgentBoardBoardTaskChangedPayload = AgentBoardBoardTaskChangedPayloadSchema.AgentBoardBoardTaskChangedPayload;
1540
1580
  declare namespace ChatStopAckSchema {
1541
1581
  type Status = string;
1542
1582
  type Message = (string | null);
@@ -1564,9 +1604,12 @@ type ChatCompactAck = ChatCompactAckSchema.ChatCompactAck;
1564
1604
  interface ClientToServerEvents {
1565
1605
  "chat:send": (payload: ChatSendPayload) => void;
1566
1606
  "chat:stop": (payload: ChatStopPayload, ack: (response: ChatStopAck) => void) => void;
1607
+ "chat:append": (payload: ChatAppendPayload) => void;
1567
1608
  "chat:compact": (payload: ChatCompactPayload, ack: (response: ChatCompactAck) => void) => void;
1568
1609
  "session:subscribe": (payload: SessionSubscribePayload) => void;
1569
1610
  "session:unsubscribe": (payload: SessionUnsubscribePayload) => void;
1611
+ "agent-board:project:subscribe": (payload: AgentBoardProjectSubscribePayload) => void;
1612
+ "agent-board:project:unsubscribe": (payload: AgentBoardProjectUnsubscribePayload) => void;
1570
1613
  "asr:start": (payload: unknown) => void;
1571
1614
  "asr:audio": (payload: AsrAudioPayload) => void;
1572
1615
  "asr:stop": (payload: unknown) => void;
@@ -1577,6 +1620,7 @@ interface ClientToServerEvents {
1577
1620
  interface ServerToClientEvents {
1578
1621
  "chat:start": (payload: ChatStartPayload) => void;
1579
1622
  "chat:end": (payload: ChatEndPayload) => void;
1623
+ "chat:append:ack": (payload: unknown) => void;
1580
1624
  "session:updated": (payload: SessionUpdatedPayload) => void;
1581
1625
  "workspace:files_changed": (payload: WorkspaceFilesChangedPayload) => void;
1582
1626
  "system:error": (payload: SystemErrorPayload) => void;
@@ -1600,6 +1644,7 @@ interface ServerToClientEvents {
1600
1644
  "vibe:logs:line": (payload: VibeLogsLinePayload) => void;
1601
1645
  "vibe:logs:end": (payload: VibeLogsEndPayload) => void;
1602
1646
  "replay:input_mismatch": (payload: unknown) => void;
1647
+ "agent-board:board-task:changed": (payload: AgentBoardBoardTaskChangedPayload) => void;
1603
1648
  }
1604
1649
 
1605
1650
  type TypedSocket = Socket<ServerToClientEvents, ClientToServerEvents>;
@@ -1674,4 +1719,4 @@ interface UploadProgress {
1674
1719
  percent?: number;
1675
1720
  }
1676
1721
 
1677
- export { ModelsConfig as $, type ApiKeyCreateResponse as A, BladeApiError as B, type CreateVibeCodingSessionResult as C, type DeployBumpMode as D, type CreateSoftwareFactorySoftwarePayload as E, type FileEntry as F, GisResource as G, type GlobalSkillStats as H, HeadlessError as I, HeadlessResource as J, type HeadlessRunInSessionResult as K, type HeadlessRunOptions as L, type HistoryNode as M, type HttpMethod as N, type ImportPreview as O, type PortMapping as P, type ImportPreviewScenario as Q, type ImportPreviewSkill as R, type InstalledRegistrySkill as S, type JsonSchemaObject as T, MemoriesResource as U, VibeCodingResource as V, type Memory as W, type MemoryCreateBody as X, type MemoryListParams as Y, type MemoryListResponse as Z, ModelOption as _, type VibeCodingDeployStatus as a, AgentDriver as a$, ModelsResource as a0, type PaginatedSessionsResult as a1, type PreviewUrlItem as a2, type ProvidersResponse as a3, PublishedAppsResource as a4, type QuickScenario as a5, REGISTRY_PREFIX as a6, RegistryResource as a7, type ResourceApi as a8, ScenariosResource as a9, type UserInfo as aA, UserPreferencesResource as aB, createSocket as aC, normalizeResource as aD, EnvBucketsResource as aE, type EnvBucket as aF, type PlatformEnvBucket as aG, type GisState as aH, type RuntimeConfig as aI, type SkillDetail as aJ, type SkillStats as aK, type SkillSummary as aL, type SkillSearchResult as aM, PartnerSkillInstallPayload as aN, PartnerSkillInstallResult as aO, SessionSkillUploadPayload as aP, SessionSkillUploadResult as aQ, PublishedApp as aR, PublishedAppListResponse as aS, PublishedAppStatus as aT, UnpublishAppResponse as aU, type BackgroundTask as aV, type GisGoal as aW, type GisResource$1 as aX, type GisTarget as aY, type GisMapCommand as aZ, Task as a_, type ServerToClientEvents as aa, type SessionContextStats as ab, type SessionHistory as ac, type SessionUpdatedPayload as ad, SessionsResource as ae, type ShareLinkResult as af, type SkillDevSession as ag, type SkillOrgListResponse as ah, type SkillOrgOption as ai, SkillsResource as aj, type SoftwareFactoryModuleBlueprint as ak, SoftwareFactoryResource as al, type SoftwareFactorySharedFile as am, type SoftwareFactorySoftware as an, type SoftwareFactoryTopic as ao, type SoftwareFactoryTopicModule as ap, SolutionsResource as aq, type SystemErrorPayload as ar, type SystemNotificationPayload as as, type TokenizeResult as at, type TurnProjectionPayload as au, type TypedSocket as av, type UpdateQuickScenarioPayload as aw, type UpgradeComputerResponse as ax, type UploadFileEntry as ay, type UploadFilesOptions as az, type VibeCodingDebugSessionStatus as b, AgentResource as b0, DatabaseDriver as b1, DatabaseResource as b2, DifyKnowledgeConfig as b3, type GisGoalStatus as b4, HttpToolConfig as b5, KnowledgeDriver as b6, KnowledgeResource as b7, McpToolConfig as b8, MysqlConfig as b9, type ParallelMode as ba, PartnerSkillFile as bb, PartnerSkillName as bc, PostgresqlConfig as bd, SessionSkillFile as be, SessionSkillName as bf, type StageSpec as bg, type StepSpec as bh, TaskStatus as bi, ToolDriver as bj, ToolResource as bk, skillDisplayName as bl, type VibeCodingSessionStatus as c, type VibeCodingDeployRecord as d, type VibeCodingSessionInfo as e, type CreateVibeCodingSessionParams as f, type ApiKeyPublic as g, ApiKeysResource as h, AuthResource as i, BladeClient as j, type BladeClientOptions as k, type BladeFetchInit as l, type BladeHubScenarioResource as m, type ChatEndPayload as n, type ChatSendPayload as o, type CheckpointNode as p, type ClientToServerEvents as q, type CodingTask as r, type CodingTaskTopic as s, type ComputerUpgradeReason as t, type ComputerUpgradeStatusResponse as u, type ContentPart as v, type CreateQuickScenarioPayload as w, type CreateSessionRequest as x, type CreateSocketOptions as y, type CreateSoftwareFactorySharedFilePayload as z };
1722
+ export { type HeadlessRunOptions 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, GisResource as W, type GlobalSkillStats as X, HeadlessError as Y, HeadlessResource as Z, type HeadlessRunInSessionResult as _, type VibeCodingDeployStatus as a, AgentDriver as a$, type HttpMethod as a0, type InstalledRegistrySkill as a1, type JsonSchemaObject as a2, MemoriesResource as a3, type Memory as a4, type MemoryCreateBody as a5, type MemoryListParams as a6, type MemoryListResponse as a7, ModelOption as a8, ModelsConfig as a9, type UpgradeComputerResponse as aA, type UserInfo as aB, UserPreferencesResource as aC, createSocket as aD, normalizeResource as aE, EnvBucketsResource as aF, type EnvBucket as aG, type PlatformEnvBucket as aH, type GisState as aI, type RuntimeConfig as aJ, type SkillDetail as aK, type SkillStats as aL, type SkillSummary as aM, type SkillSearchResult as aN, PartnerSkillInstallPayload as aO, PartnerSkillInstallResult as aP, SessionSkillUploadPayload as aQ, SessionSkillUploadResult as aR, PublishedApp as aS, PublishedAppListResponse as aT, PublishedAppStatus as aU, UnpublishAppResponse as aV, type GisGoal as aW, type GisResource$1 as aX, type GisTarget as aY, type GisMapCommand as aZ, Task as a_, ModelsResource as aa, type PreviewUrlItem as ab, type ProvidersResponse as ac, PublishedAppsResource as ad, type QuickScenario as ae, REGISTRY_PREFIX as af, RegistryResource as ag, type ResourceApi as ah, ScenariosResource as ai, type ServerToClientEvents as aj, type SessionUpdatedPayload 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 TurnProjectionPayload as ax, type TypedSocket as ay, type UpdateQuickScenarioPayload as az, type VibeCodingDebugSessionStatus as b, AgentResource as b0, DatabaseDriver as b1, DatabaseResource as b2, DifyKnowledgeConfig as b3, type GisGoalStatus as b4, HttpToolConfig as b5, KnowledgeDriver as b6, KnowledgeResource as b7, McpToolConfig as b8, MysqlConfig as b9, type ParallelMode as ba, PartnerSkillFile as bb, PartnerSkillName as bc, PostgresqlConfig as bd, SessionSkillFile as be, SessionSkillName as bf, type StageSpec as bg, type StepSpec as bh, TaskStatus as bi, ToolDriver as bj, ToolResource as bk, skillDisplayName as bl, 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-DTDZFQRY.js";
4
+ } from "./chunk-UNO53NPU.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"]);
@@ -54,6 +54,13 @@ function buildSessionBinaryPreviewTarget(sessionId, filePath, fileName) {
54
54
  }
55
55
  return null;
56
56
  }
57
+ function resolveTextPreviewType(fileName) {
58
+ const ext = getExt(fileName);
59
+ if (MARKDOWN_EXTS.has(ext)) return "markdown";
60
+ if (CSV_EXTS.has(ext)) return "csv";
61
+ if (HTML_EXTS.has(ext)) return "html";
62
+ return "file";
63
+ }
57
64
  async function resolveSessionFilePreviewTarget(sessionId, filePath, fileName) {
58
65
  const resolvedFileName = getDisplayFileName(filePath, fileName);
59
66
  const binaryTarget = buildSessionBinaryPreviewTarget(sessionId, filePath, resolvedFileName);
@@ -76,10 +83,8 @@ async function resolveSessionFilePreviewTarget(sessionId, filePath, fileName) {
76
83
  return { type: "download", content: downloadUrl, title: resolvedFileName, key: filePath };
77
84
  }
78
85
  const content = await res.text();
79
- const ext = getExt(resolvedFileName);
80
- const type = MARKDOWN_EXTS.has(ext) ? "markdown" : CSV_EXTS.has(ext) ? "csv" : HTML_EXTS.has(ext) ? "html" : "file";
81
86
  return {
82
- type,
87
+ type: resolveTextPreviewType(resolvedFileName),
83
88
  content,
84
89
  title: resolvedFileName,
85
90
  key: filePath
@@ -89,6 +94,7 @@ async function resolveSessionFilePreviewTarget(sessionId, filePath, fileName) {
89
94
  export {
90
95
  getSessionFilePath,
91
96
  buildSessionBinaryPreviewTarget,
97
+ resolveTextPreviewType,
92
98
  resolveSessionFilePreviewTarget
93
99
  };
94
- //# sourceMappingURL=chunk-QKSZPJQX.js.map
100
+ //# sourceMappingURL=chunk-4FCXKLXT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/react/lib/session-file-preview.ts"],"sourcesContent":["import { apiFetchResponse, getAuthedUrl } from \"../api/client\"\nimport type { PreviewTarget } from \"../stores/ui-store\"\n\nconst IMAGE_EXTS = new Set([\"png\", \"jpg\", \"jpeg\", \"gif\", \"svg\", \"webp\", \"ico\", \"bmp\"])\nconst DOCX_EXTS = new Set([\"docx\", \"doc\"])\nconst EXCEL_EXTS = new Set([\"xlsx\", \"xls\", \"xlsm\", \"xlsb\"])\nconst PPT_EXTS = new Set([\"pptx\", \"ppt\"])\nconst CSV_EXTS = new Set([\"csv\"])\nconst MARKDOWN_EXTS = new Set([\"md\", \"markdown\"])\nconst HTML_EXTS = new Set([\"html\", \"htm\"])\n\nfunction getExt(fileName: string): string {\n return fileName.split(\".\").pop()?.toLowerCase() ?? \"\"\n}\n\nfunction getDisplayFileName(filePath: string, fileName?: string): string {\n return fileName?.trim() || filePath.split(\"/\").pop() || filePath\n}\n\nexport function getSessionFilePath(sessionId: string, filePath: string): string {\n return `/api/sessions/${sessionId}/files/${encodeURIComponent(filePath)}`\n}\n\nfunction getSessionFileDownloadUrl(sessionId: string, filePath: string): string {\n return getAuthedUrl(getSessionFilePath(sessionId, filePath))\n}\n\n/**\n * 后端把可解码为 UTF-8 的文件返回为 text/plain,二进制文件返回各自的 MIME。\n * 只有文本类内容才能安全地整体读进内存渲染——其余一律不能读 body。\n */\nfunction isTextualContentType(contentType: string): boolean {\n return (\n contentType.startsWith(\"text/\") ||\n contentType.includes(\"json\") ||\n contentType.includes(\"xml\") ||\n contentType.includes(\"yaml\") ||\n contentType.includes(\"javascript\")\n )\n}\n\nexport function buildSessionBinaryPreviewTarget(\n sessionId: string,\n filePath: string,\n fileName?: string,\n): PreviewTarget | null {\n const resolvedFileName = getDisplayFileName(filePath, fileName)\n const ext = getExt(resolvedFileName)\n const filePathUrl = getSessionFilePath(sessionId, filePath)\n const downloadUrl = getSessionFileDownloadUrl(sessionId, filePath)\n\n if (IMAGE_EXTS.has(ext)) {\n return { type: \"image\", content: downloadUrl, title: resolvedFileName, key: filePath }\n }\n\n if (ext === \"pdf\") {\n return { type: \"pdf\", content: downloadUrl, title: resolvedFileName, key: filePath }\n }\n\n if (DOCX_EXTS.has(ext)) {\n return { type: \"docx\", content: downloadUrl, title: resolvedFileName, key: filePath }\n }\n\n if (EXCEL_EXTS.has(ext)) {\n return { type: \"excel\", content: downloadUrl, title: resolvedFileName, key: filePath }\n }\n\n if (PPT_EXTS.has(ext)) {\n return {\n type: \"ppt\",\n content: filePathUrl,\n sourceUrl: downloadUrl,\n title: resolvedFileName,\n key: filePath,\n }\n }\n\n return null\n}\n\nexport function resolveTextPreviewType(fileName: string): PreviewTarget[\"type\"] {\n const ext = getExt(fileName)\n if (MARKDOWN_EXTS.has(ext)) return \"markdown\"\n if (CSV_EXTS.has(ext)) return \"csv\"\n if (HTML_EXTS.has(ext)) return \"html\"\n return \"file\"\n}\n\nexport async function resolveSessionFilePreviewTarget(\n sessionId: string,\n filePath: string,\n fileName?: string,\n): Promise<PreviewTarget> {\n const resolvedFileName = getDisplayFileName(filePath, fileName)\n const binaryTarget = buildSessionBinaryPreviewTarget(sessionId, filePath, resolvedFileName)\n if (binaryTarget) {\n return binaryTarget\n }\n\n const downloadUrl = getSessionFileDownloadUrl(sessionId, filePath)\n\n // 其余文件按后端返回的 Content-Type 分派,而不是猜扩展名:\n // 视频/音频/压缩包等二进制文件绝不能读 body(整体读进内存会卡死页面),\n // 改为把下载 URL 交给原生 <video>/<audio> 流式播放,或回退为下载。\n const res = await apiFetchResponse(getSessionFilePath(sessionId, filePath))\n const contentType = (res.headers.get(\"content-type\") ?? \"\").toLowerCase()\n\n if (contentType.startsWith(\"video/\")) {\n void res.body?.cancel()\n return { type: \"video\", content: downloadUrl, title: resolvedFileName, key: filePath }\n }\n\n if (contentType.startsWith(\"audio/\")) {\n void res.body?.cancel()\n return { type: \"audio\", content: downloadUrl, title: resolvedFileName, key: filePath }\n }\n\n if (!isTextualContentType(contentType)) {\n void res.body?.cancel()\n return { type: \"download\", content: downloadUrl, title: resolvedFileName, key: filePath }\n }\n\n const content = await res.text()\n\n return {\n type: resolveTextPreviewType(resolvedFileName),\n content,\n title: resolvedFileName,\n key: filePath,\n }\n}\n"],"mappings":"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","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useSessionStore
3
- } from "./chunk-DTDZFQRY.js";
3
+ } from "./chunk-UNO53NPU.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-63IWZ3AO.js.map
30
+ //# sourceMappingURL=chunk-6L6JFSR5.js.map