@blade-hq/agent-client 2612.0.0-beta.2 → 2612.0.0-beta.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/README.md +203 -19
- package/dist/blade-client.d.ts +13 -1
- package/dist/{chunk-PWJJJATA.js → chunk-J3XXTHHK.js} +1723 -701
- package/dist/chunk-J3XXTHHK.js.map +1 -0
- package/dist/index.d.ts +12 -3
- package/dist/index.js +9 -1
- package/dist/internal.d.ts +9 -3
- package/dist/internal.js +13 -1
- package/dist/internal.js.map +1 -1
- package/dist/resources/auth.d.ts +3 -1
- package/dist/resources/chat-groups.d.ts +92 -0
- package/dist/resources/headless.d.ts +5 -0
- package/dist/resources/models.d.ts +6 -1
- package/dist/resources/plugins.d.ts +1 -0
- package/dist/resources/sessions.d.ts +96 -11
- package/dist/schemas/context-attachments.d.ts +16 -0
- package/dist/schemas/event.d.ts +2 -0
- package/dist/schemas/message-utils.d.ts +3 -9
- package/dist/schemas/message.d.ts +18 -1
- package/dist/schemas/plugin-refs.d.ts +15 -0
- package/dist/schemas/projection.d.ts +31 -0
- package/dist/schemas/session.d.ts +2 -42
- package/dist/schemas/topic-assets.d.ts +7 -0
- package/dist/server-clock.d.ts +2 -0
- package/dist/session/agent-session.d.ts +51 -7
- package/dist/session/background.d.ts +14 -0
- package/dist/session/events.d.ts +0 -1
- package/dist/session/hub.d.ts +3 -0
- package/dist/session/log-cursor.d.ts +14 -0
- package/dist/session/state.d.ts +2 -1
- package/dist/session/workflow.d.ts +10 -3
- package/dist/shared/projection/builder.d.ts +5 -0
- package/dist/shared/projection/helpers.d.ts +2 -0
- package/dist/shared/projection/index.d.ts +1 -0
- package/dist/shared/projection/workflow.d.ts +24 -0
- package/dist/tool-provider.d.ts +51 -0
- package/dist/types/socket-events.d.ts +179 -6
- package/node_modules/engine.io-client/build/cjs/globals.node.d.ts +2 -3
- package/node_modules/engine.io-client/build/cjs/index.d.ts +3 -3
- package/node_modules/engine.io-client/build/cjs/index.js +1 -4
- package/node_modules/engine.io-client/build/cjs/socket.d.ts +39 -82
- package/node_modules/engine.io-client/build/cjs/socket.js +151 -218
- package/node_modules/engine.io-client/build/cjs/transport.d.ts +1 -1
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.d.ts +4 -4
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.js +2 -2
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.js +17 -7
- package/node_modules/engine.io-client/build/cjs/transports/websocket.node.js +17 -7
- package/node_modules/engine.io-client/build/esm/globals.node.d.ts +2 -3
- package/node_modules/engine.io-client/build/esm/index.d.ts +3 -3
- package/node_modules/engine.io-client/build/esm/index.js +1 -2
- package/node_modules/engine.io-client/build/esm/socket.d.ts +39 -82
- package/node_modules/engine.io-client/build/esm/socket.js +141 -206
- package/node_modules/engine.io-client/build/esm/transport.d.ts +1 -1
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.d.ts +4 -4
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.js +2 -2
- package/node_modules/engine.io-client/build/esm-debug/globals.node.d.ts +2 -3
- package/node_modules/engine.io-client/build/esm-debug/index.d.ts +3 -3
- package/node_modules/engine.io-client/build/esm-debug/index.js +1 -2
- package/node_modules/engine.io-client/build/esm-debug/socket.d.ts +39 -82
- package/node_modules/engine.io-client/build/esm-debug/socket.js +150 -215
- package/node_modules/engine.io-client/build/esm-debug/transport.d.ts +1 -1
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.d.ts +4 -4
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.js +2 -2
- package/node_modules/engine.io-client/dist/engine.io.esm.min.js +3 -3
- package/node_modules/engine.io-client/dist/engine.io.esm.min.js.map +1 -1
- package/node_modules/engine.io-client/dist/engine.io.js +164 -239
- package/node_modules/engine.io-client/dist/engine.io.js.map +1 -1
- package/node_modules/engine.io-client/dist/engine.io.min.js +3 -3
- package/node_modules/engine.io-client/dist/engine.io.min.js.map +1 -1
- package/node_modules/engine.io-client/package.json +2 -2
- package/node_modules/socket.io-parser/build/cjs/binary.js +4 -1
- package/node_modules/socket.io-parser/build/cjs/index.d.ts +14 -4
- package/node_modules/socket.io-parser/build/cjs/index.js +18 -11
- package/node_modules/socket.io-parser/build/esm/binary.js +4 -1
- package/node_modules/socket.io-parser/build/esm/index.d.ts +14 -4
- package/node_modules/socket.io-parser/build/esm/index.js +14 -10
- package/node_modules/socket.io-parser/build/esm-debug/binary.js +4 -1
- package/node_modules/socket.io-parser/build/esm-debug/index.d.ts +14 -4
- package/node_modules/socket.io-parser/build/esm-debug/index.js +14 -10
- package/node_modules/socket.io-parser/package.json +1 -1
- package/node_modules/ws/index.js +15 -6
- package/node_modules/ws/lib/constants.js +1 -0
- package/node_modules/ws/lib/permessage-deflate.js +9 -7
- package/node_modules/ws/lib/receiver.js +37 -0
- package/node_modules/ws/lib/sender.js +6 -1
- package/node_modules/ws/lib/websocket-server.js +18 -6
- package/node_modules/ws/lib/websocket.js +50 -17
- package/node_modules/ws/package.json +8 -3
- package/node_modules/ws/wrapper.mjs +14 -1
- package/package.json +4 -4
- package/public-api.md +335 -28
- package/dist/chunk-PWJJJATA.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { BladeApiError } from "./rest";
|
|
|
4
4
|
export type { LoginOptions, LoginResult, TokenStorageMode } from "./auth-login";
|
|
5
5
|
export { SDK_NAME, SDK_VERSION } from "./version";
|
|
6
6
|
export { AgentSession } from "./session/agent-session";
|
|
7
|
-
export type { AttachAppOptions, SendOptions } from "./session/agent-session";
|
|
7
|
+
export type { AttachAppOptions, SendOptions, PreparedSend, PreparedSendOptions, DeliveryReceipt } from "./session/agent-session";
|
|
8
8
|
export { AgentSessionError } from "./session/errors";
|
|
9
9
|
export type { AgentSessionEvents, AgentSessionEventName } from "./session/events";
|
|
10
10
|
export type { WorkflowRunEntry, WorkflowRunState } from "./session/workflow";
|
|
@@ -20,10 +20,19 @@ export type { RunOptions, RunResult, RunTrace } from "./types/sdk-profile";
|
|
|
20
20
|
export type { ModelsResource, ModelCatalog, ModelOption } from "./resources/models";
|
|
21
21
|
export type { ComputersResource } from "./resources/computers";
|
|
22
22
|
export type { AccountComputer, SessionComputer } from "./resources/computers";
|
|
23
|
-
export type { AppCliAttachment, AppCliDefinition, CreateSessionRequest, FileEntry, PaginatedSessionsResult, SessionsResource, SessionTurnsPage, SessionTurnsQuery, UploadFileEntry, UploadFilesOptions, } from "./resources/sessions";
|
|
23
|
+
export type { AppCliAttachment, AppCliDefinition, CreateSessionRequest, UpdateSessionConfigurationRequest, SessionConfiguration, McpSourceConfig, FileEntry, PaginatedSessionsResult, SessionsResource, SessionTurnsPage, SessionTurnsQuery, UploadFileEntry, UploadFilesOptions, } from "./resources/sessions";
|
|
24
24
|
export { DEFAULT_REPLAY_SPEED, SessionInfo, SessionStatus } from "./schemas/session";
|
|
25
25
|
export type { ReplaySpeed, ReplayState, SessionDetail } from "./schemas/session";
|
|
26
|
-
export type { ChatMessage, FileContentPart, ImageUrlContentPart, MemoryRefInfo, MessageContent, MessageContentPart, TextContentPart, ToolCallInfo, } from "./schemas/message";
|
|
26
|
+
export type { ChatMessage, FileContentPart, ImageUrlContentPart, MemoryRefInfo, MessageContent, MessageContentPart, TextContentPart, ToolCallInfo, WorkflowStepInfo, } from "./schemas/message";
|
|
27
27
|
export { chatErrorForDisplay, contentPreview, getFileParts, getImageParts, getTextContent, groupMessagesByLoop, transformSlashCommand, } from "./schemas/message-utils";
|
|
28
28
|
export type { SkillMentionAvailability } from "./schemas/message-utils";
|
|
29
29
|
export { userFacingErrorText } from "./shared/oom";
|
|
30
|
+
export { normalizeTopicAssetRefs } from "./schemas/topic-assets";
|
|
31
|
+
export type { TopicAssetRef } from "./schemas/topic-assets";
|
|
32
|
+
export type { ChatGroup, ChatGroupRole, ChatGroupMember, ChatGroupTask, CreateChatGroupTask, UpdateChatGroupTask, ChatGroupAsset, ChatGroupAssetList } from "./resources/chat-groups";
|
|
33
|
+
export { normalizePluginRefs, normalizeMessageRefs } from "./schemas/plugin-refs";
|
|
34
|
+
export type { PluginRef, SkillRef, MessageRef } from "./schemas/plugin-refs";
|
|
35
|
+
export type { ToolEvidence } from "./schemas/projection";
|
|
36
|
+
export { ToolProvider } from "./tool-provider";
|
|
37
|
+
export type { ToolProviderOptions, ProviderTool, ProviderToolResult } from "./tool-provider";
|
|
38
|
+
export type { ContextAttachment } from "./schemas/context-attachments";
|
package/dist/index.js
CHANGED
|
@@ -9,15 +9,19 @@ import {
|
|
|
9
9
|
SessionInfo,
|
|
10
10
|
SessionSetupError,
|
|
11
11
|
SessionStatus,
|
|
12
|
+
ToolProvider,
|
|
12
13
|
chatErrorForDisplay,
|
|
13
14
|
contentPreview,
|
|
14
15
|
getFileParts,
|
|
15
16
|
getImageParts,
|
|
16
17
|
getTextContent,
|
|
17
18
|
groupMessagesByLoop,
|
|
19
|
+
normalizeMessageRefs,
|
|
20
|
+
normalizePluginRefs,
|
|
21
|
+
normalizeTopicAssetRefs,
|
|
18
22
|
transformSlashCommand,
|
|
19
23
|
userFacingErrorText
|
|
20
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-J3XXTHHK.js";
|
|
21
25
|
export {
|
|
22
26
|
AgentSession,
|
|
23
27
|
AgentSessionError,
|
|
@@ -29,12 +33,16 @@ export {
|
|
|
29
33
|
SessionInfo,
|
|
30
34
|
SessionSetupError,
|
|
31
35
|
SessionStatus,
|
|
36
|
+
ToolProvider,
|
|
32
37
|
chatErrorForDisplay,
|
|
33
38
|
contentPreview,
|
|
34
39
|
getFileParts,
|
|
35
40
|
getImageParts,
|
|
36
41
|
getTextContent,
|
|
37
42
|
groupMessagesByLoop,
|
|
43
|
+
normalizeMessageRefs,
|
|
44
|
+
normalizePluginRefs,
|
|
45
|
+
normalizeTopicAssetRefs,
|
|
38
46
|
transformSlashCommand,
|
|
39
47
|
userFacingErrorText
|
|
40
48
|
};
|
package/dist/internal.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export { ComputersResource } from "./resources/computers";
|
|
|
24
24
|
export type { SessionPlugin, SessionPluginActivation } from "./resources/sessions";
|
|
25
25
|
export type { SessionPluginConfigError, SessionPluginConfigSet, SessionPluginConfigState, SessionPluginConfigStateName, SessionPluginConfigSummary, SessionPluginConfigUpdate, } from "./resources/sessions";
|
|
26
26
|
export { ChatGroupsResource } from "./resources/chat-groups";
|
|
27
|
-
export type { ChatGroup } from "./resources/chat-groups";
|
|
27
|
+
export type { ChatGroup, ChatGroupRole, ChatGroupMember, ChatGroupTask, CreateChatGroupTask, UpdateChatGroupTask, ChatGroupAsset, ChatGroupAssetList } from "./resources/chat-groups";
|
|
28
28
|
export { PluginsResource } from "./resources/plugins";
|
|
29
29
|
export type { PluginCatalogEntry } from "./resources/plugins";
|
|
30
30
|
export type { SiteVisitsResource, SiteVisitsSummary } from "./resources/site-visits";
|
|
@@ -36,11 +36,11 @@ export { buildMessageContent, extractTextAttachments, isBackgroundWakeMessage, i
|
|
|
36
36
|
export type { ParsedTextAttachment, ParsedTextContext } from "./schemas/message-utils";
|
|
37
37
|
export { contextProjectionData, getContextDisplayState, getContextGroupDisplayState, groupAdjacentContextRuns, } from "./schemas/context";
|
|
38
38
|
export type { ContextAction, ContextDisplayState, ContextGroupDisplayState, ContextProjectionData, ContextProjectionFields, ContextSourceInfo, } from "./schemas/context";
|
|
39
|
-
export type { ContentBlock, FinalArtifact, MemoryRef, PatchEnvelope, PendingQuestionRef, PostChatFollowup, RunTiming, ToolCallProjection, TurnProjection, } from "./schemas/projection";
|
|
39
|
+
export type { ContentBlock, FinalArtifact, MemoryRef, PatchEnvelope, PendingQuestionRef, PostChatFollowup, RunTiming, ToolCallProjection, WorkflowStepProjection, TurnProjection, } from "./schemas/projection";
|
|
40
40
|
export { latestPostChatFollowup } from "./schemas/projection-utils";
|
|
41
41
|
export { buildToolUiCardKey, collectInlineToolUiCards, collectPreviewToolUiCards, isAppDevToolUiCard, isInternalStatusToolUiCard, isToolUiCard, resolveToolUiCardContent, } from "./shared/tool-ui-card";
|
|
42
42
|
export type { InlineToolUiCardEntry, PreviewToolUiCardEntry, ToolUiCard, ToolUiCardContentType, } from "./shared/tool-ui-card";
|
|
43
|
-
export type { ModeId,
|
|
43
|
+
export type { ModeId, PublishedSolutionRef, ReplayPreview, SessionPortMapping, SessionSearchMatch, } from "./schemas/session";
|
|
44
44
|
export { LayoutType } from "./schemas/solution";
|
|
45
45
|
export type { BizRole, Solution, SolutionAppField, SolutionAppState, SolutionAppUiConfig, } from "./schemas/solution";
|
|
46
46
|
export { Task, TaskStatus } from "./schemas/task";
|
|
@@ -53,3 +53,9 @@ export { isOomText, OOM_MESSAGE } from "./shared/oom";
|
|
|
53
53
|
export { createSocket } from "./socket";
|
|
54
54
|
export type { CreateSocketOptions, TypedSocket } from "./socket";
|
|
55
55
|
export type { AsrAudioPayload } from "./types/socket-events";
|
|
56
|
+
export { normalizeTopicAssetRefs } from "./schemas/topic-assets";
|
|
57
|
+
export type { TopicAssetRef } from "./schemas/topic-assets";
|
|
58
|
+
export { normalizePluginRefs } from "./schemas/plugin-refs";
|
|
59
|
+
export type { PluginRef } from "./schemas/plugin-refs";
|
|
60
|
+
export type { ToolEvidence } from "./schemas/projection";
|
|
61
|
+
export { getServerTime, syncServerTime } from "./server-clock";
|
package/dist/internal.js
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
SessionInfo,
|
|
19
19
|
SessionSetupError,
|
|
20
20
|
SessionStatus,
|
|
21
|
+
ToolProvider,
|
|
21
22
|
acceptedPostChatFollowupCompletesLatestRun,
|
|
22
23
|
acknowledgeTurnEvents,
|
|
23
24
|
applyTurnPatch,
|
|
@@ -44,6 +45,7 @@ import {
|
|
|
44
45
|
getContextGroupDisplayState,
|
|
45
46
|
getFileParts,
|
|
46
47
|
getImageParts,
|
|
48
|
+
getServerTime,
|
|
47
49
|
getTextContent,
|
|
48
50
|
groupAdjacentContextRuns,
|
|
49
51
|
groupMessagesByLoop,
|
|
@@ -61,6 +63,9 @@ import {
|
|
|
61
63
|
isToolUiCard,
|
|
62
64
|
isWorkflowRunToolName,
|
|
63
65
|
normalizeMessageContent,
|
|
66
|
+
normalizeMessageRefs,
|
|
67
|
+
normalizePluginRefs,
|
|
68
|
+
normalizeTopicAssetRefs,
|
|
64
69
|
parentForkToolCallIdFromTurn,
|
|
65
70
|
parseQueueAck,
|
|
66
71
|
prependOlder,
|
|
@@ -73,6 +78,7 @@ import {
|
|
|
73
78
|
sessionStatusFromChatEnd,
|
|
74
79
|
shouldApplySnapshot,
|
|
75
80
|
sortComputers,
|
|
81
|
+
syncServerTime,
|
|
76
82
|
toReplaySnapshot,
|
|
77
83
|
transformSlashCommand,
|
|
78
84
|
upsertTurn,
|
|
@@ -80,7 +86,7 @@ import {
|
|
|
80
86
|
withTurns,
|
|
81
87
|
workflowEntriesFromOutput,
|
|
82
88
|
workflowNameFromArguments
|
|
83
|
-
} from "./chunk-
|
|
89
|
+
} from "./chunk-J3XXTHHK.js";
|
|
84
90
|
|
|
85
91
|
// src/polling-backoff.ts
|
|
86
92
|
var MAX_BACKOFF_MS = 6e4;
|
|
@@ -270,6 +276,7 @@ export {
|
|
|
270
276
|
SessionStatus,
|
|
271
277
|
Task,
|
|
272
278
|
TaskStatus,
|
|
279
|
+
ToolProvider,
|
|
273
280
|
acceptedPostChatFollowupCompletesLatestRun,
|
|
274
281
|
acknowledgeTurnEvents,
|
|
275
282
|
applyTurnPatch,
|
|
@@ -296,6 +303,7 @@ export {
|
|
|
296
303
|
getContextGroupDisplayState,
|
|
297
304
|
getFileParts,
|
|
298
305
|
getImageParts,
|
|
306
|
+
getServerTime,
|
|
299
307
|
getTextContent,
|
|
300
308
|
groupAdjacentContextRuns,
|
|
301
309
|
groupMessagesByLoop,
|
|
@@ -316,6 +324,9 @@ export {
|
|
|
316
324
|
latestPostChatFollowup,
|
|
317
325
|
loadPlatformEndpoints,
|
|
318
326
|
normalizeMessageContent,
|
|
327
|
+
normalizeMessageRefs,
|
|
328
|
+
normalizePluginRefs,
|
|
329
|
+
normalizeTopicAssetRefs,
|
|
319
330
|
parentForkToolCallIdFromTurn,
|
|
320
331
|
parseQueueAck,
|
|
321
332
|
prependOlder,
|
|
@@ -329,6 +340,7 @@ export {
|
|
|
329
340
|
sessionStatusFromChatEnd,
|
|
330
341
|
shouldApplySnapshot,
|
|
331
342
|
sortComputers,
|
|
343
|
+
syncServerTime,
|
|
332
344
|
toReplaySnapshot,
|
|
333
345
|
transformSlashCommand,
|
|
334
346
|
upsertTurn,
|
package/dist/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/polling-backoff.ts","../src/platform-endpoints.ts","../src/commands/protocol.ts","../src/schemas/projection-utils.ts","../src/schemas/solution.ts","../src/schemas/task.ts"],"sourcesContent":["import { BladeApiError } from \"./rest\"\n\nconst MAX_BACKOFF_MS = 60_000\nconst MAX_TIMER_MS = 2_147_483_647\n\n/** Scheduling policy for read-only polling; never sends or replays a request. */\nexport class PollingBackoff {\n private failures = 0\n private nextAt: number | false = 0\n\n constructor(private readonly intervalMs: number) {\n if (!Number.isFinite(intervalMs) || intervalMs <= 0 || intervalMs > MAX_BACKOFF_MS) {\n throw new RangeError(\"Polling interval must be between 0 and 60000 ms\")\n }\n }\n\n reset(): void {\n this.failures = 0\n this.nextAt = 0\n }\n\n failed(error: unknown): void {\n if (\n (error instanceof Error && error.name === \"AbortError\") ||\n (error instanceof BladeApiError && error.status < 500 &&\n error.status !== 408 && error.status !== 429)\n ) {\n this.nextAt = false\n return\n }\n this.failures = Math.min(this.failures + 1, 10)\n const ceiling = Math.min(MAX_BACKOFF_MS, this.intervalMs * 2 ** this.failures)\n const backoff = Math.max(this.intervalMs, ceiling * (0.5 + Math.random() * 0.5))\n const header = error instanceof BladeApiError\n ? error.response.headers.get(\"Retry-After\")?.trim()\n : undefined\n const retryAfter = header\n ? /^\\d+$/.test(header) ? Number(header) * 1000 : Date.parse(header) - Date.now()\n : 0\n const delay = Math.max(backoff, Number.isNaN(retryAfter) ? 0 : retryAfter)\n // Oversized server delays must not overflow browser timers into a hot loop.\n this.nextAt = delay > MAX_TIMER_MS ? false : Date.now() + delay\n }\n\n /** Zero means ready, false means stop, otherwise wait at least this many ms. */\n waitMs(): number | false {\n return this.nextAt === false ? false : Math.max(0, this.nextAt - Date.now())\n }\n}\n","import { isRecord } from \"./shared/type-guards\"\n\nexport const PLATFORM_SERVICE_NAMES = [\n \"os\",\n \"hub\",\n \"agent\",\n \"oauth\",\n \"llmGateway\",\n \"gitea\",\n \"tile\",\n] as const\n\nexport type PlatformServiceName = (typeof PLATFORM_SERVICE_NAMES)[number]\n\nexport interface PlatformEndpoints {\n services: Partial<Record<PlatformServiceName, string>>\n}\n\nexport const EMPTY_PLATFORM_ENDPOINTS: PlatformEndpoints = Object.freeze({\n services: Object.freeze({}),\n})\n\nexport interface LoadPlatformEndpointsOptions {\n baseUrl?: string\n fetchImpl?: typeof fetch\n timeoutMs?: number\n}\n\nfunction defaultDocumentBaseUrl(): string | undefined {\n if (typeof document === \"undefined\") return undefined\n if (document.querySelector(\"base[href]\")) return document.baseURI\n if (typeof location !== \"undefined\" && location.origin) return `${location.origin}/`\n return document.baseURI\n}\n\nfunction normalizeServiceUrl(value: unknown): string | null {\n if (typeof value !== \"string\" || !value.trim()) return null\n if (value.includes(\"?\") || value.includes(\"#\")) return null\n try {\n const url = new URL(value.trim())\n if (url.protocol !== \"http:\" && url.protocol !== \"https:\") return null\n if (url.username || url.password || url.search || url.hash) return null\n return url.toString().replace(/\\/$/, \"\")\n } catch {\n return null\n }\n}\n\nexport function parsePlatformEndpoints(value: unknown): PlatformEndpoints | null {\n if (!isRecord(value) || !isRecord(value.services)) return null\n\n const services: Partial<Record<PlatformServiceName, string>> = {}\n for (const name of PLATFORM_SERVICE_NAMES) {\n if (!(name in value.services)) continue\n const url = normalizeServiceUrl(value.services[name])\n if (!url) return null\n if (name === \"agent\" && new URL(url).pathname !== \"/\") return null\n services[name] = url\n }\n\n return { services }\n}\n\nexport async function loadPlatformEndpoints(\n options: LoadPlatformEndpointsOptions = {},\n): Promise<PlatformEndpoints> {\n const fetchImpl = options.fetchImpl ?? globalThis.fetch\n const baseUrl = options.baseUrl ?? defaultDocumentBaseUrl()\n if (!fetchImpl || !baseUrl) return EMPTY_PLATFORM_ENDPOINTS\n\n const controller = new AbortController()\n const timeout = globalThis.setTimeout(() => controller.abort(), options.timeoutMs ?? 3_000)\n try {\n const response = await fetchImpl(new URL(\"config.json\", baseUrl), {\n cache: \"no-store\",\n credentials: \"same-origin\",\n headers: { Accept: \"application/json\" },\n signal: controller.signal,\n })\n if (!response.ok) return EMPTY_PLATFORM_ENDPOINTS\n return parsePlatformEndpoints(await response.json()) ?? EMPTY_PLATFORM_ENDPOINTS\n } catch {\n return EMPTY_PLATFORM_ENDPOINTS\n } finally {\n globalThis.clearTimeout(timeout)\n }\n}\n\nexport function resolveServiceUrl(\n endpoints: PlatformEndpoints,\n name: PlatformServiceName,\n path = \"\",\n): string | null {\n const baseUrl = endpoints.services[name]\n if (!baseUrl) return null\n if (!path) return baseUrl\n const pathReference = path.trimStart()\n if (\n path.includes(\"\\\\\") ||\n pathReference.startsWith(\"//\") ||\n /^[a-z][a-z0-9+.-]*:/i.test(pathReference)\n ) {\n return null\n }\n const base = new URL(`${baseUrl}/`)\n const target = new URL(path.replace(/^\\/+/, \"\"), base)\n if (target.origin !== base.origin || !target.pathname.startsWith(base.pathname)) {\n return null\n }\n return target.toString()\n}\n","/**\n * 页面协作协议(对应后端 `_meta.bridge` 通道,见 docs/specs/260417-embed-bridge)。\n *\n * ## action 从哪里来\n *\n * 智能体 → 宿主方向的每一条指令,都源自**技能作者写的工具代码**:工具返回值\n * JSON 里带 `_meta.bridge: { action, payload }`,后端在持久化前把它剥离成独立\n * 事件送达前端(LLM 的对话历史里读不到它)。因此:\n *\n * - action 字符串(如 \"map.highlight\")是**技能作者与宿主页面开发者之间的业务\n * 契约**,LLM 不参与协议、SDK 不做枚举校验;\n * - 宿主页面用 `session.onCommand(\"map.highlight\", fn)` 消费;\n * - 未注册 handler 的 action 会进入有限缓冲等待注册,超限后丢弃并 console 告警。\n *\n * 宿主 → 智能体方向只有三个白名单动作:attach(附件入输入框)/ insertText\n * (追加输入文本)/ send(直接发消息),对应协议层的 addContext / appendInput /\n * sendMessage。\n */\n\nexport interface CommandEnvelope {\n __bladeBridge: true\n direction: \"agent-to-host\"\n action: string\n payload: unknown\n meta: {\n sessionId: string\n toolCallId?: string\n timestamp: number\n }\n}\n\nexport type InboundAction = \"addContext\" | \"appendInput\" | \"sendMessage\"\n\nexport interface InboundEnvelope {\n __bladeBridge: true\n direction: \"host-to-agent\"\n action: InboundAction\n payload: unknown\n}\n\nexport function isCommandEnvelope(value: unknown): value is CommandEnvelope {\n if (typeof value !== \"object\" || value === null) return false\n const record = value as Record<string, unknown>\n return (\n record.__bladeBridge === true &&\n record.direction === \"agent-to-host\" &&\n typeof record.action === \"string\"\n )\n}\n\nexport function isInboundEnvelope(value: unknown): value is InboundEnvelope {\n if (typeof value !== \"object\" || value === null) return false\n const record = value as Record<string, unknown>\n return (\n record.__bladeBridge === true &&\n record.direction === \"host-to-agent\" &&\n (record.action === \"addContext\" || record.action === \"appendInput\" || record.action === \"sendMessage\")\n )\n}\n","import type { PostChatFollowup, TurnProjection } from \"./projection\"\n\n/** 返回最新根会话轮次的小结;新用户消息到达后旧小结立即失效。 */\nexport function latestPostChatFollowup(turns: TurnProjection[]): PostChatFollowup | null {\n for (let index = turns.length - 1; index >= 0; index -= 1) {\n const turn = turns[index]\n if (\n turn.loop_id === \"root\" &&\n (turn.role === \"user\" || turn.role === \"assistant\") &&\n (turn.kind ?? \"message\") === \"message\" &&\n !turn.blocks.some((block) =>\n [\"mode_change\", \"plan_status\", \"ask_user_answer\"].includes(block.type),\n )\n ) {\n return turn.role === \"assistant\" ? (turn.post_chat_followup ?? null) : null\n }\n }\n return null\n}\n","export enum LayoutType {\n Default = \"default\",\n SkillEditor = \"skill-editor\",\n SolutionEditor = \"solution-editor\",\n SolutionApp = \"solution-app\",\n Custom = \"custom\",\n}\n\nexport interface Solution {\n id: string\n name: string\n version: string\n description?: string | null\n source?: \"builtin\" | \"personal\" | string | null\n layout_type: LayoutType | string\n initial_mode?: \"planning\" | \"executing\" | string | null\n initial_message?: string | null\n preview?: { url: string; title?: string | null } | null\n layout?: {\n available?: boolean\n source_dir?: string\n entry?: string\n export?: string\n } | null\n roles?: BizRole[] | null\n data?: Record<string, unknown> | null\n ui_config?: SolutionAppUiConfig | null\n}\n\nexport interface SolutionAppUiConfig {\n branding: {\n name: string\n subtitle?: string\n icon_text: string\n icon_gradient?: string\n }\n list: {\n title: string\n create_button: string\n card?: {\n subtitle?: string\n stats?: Array<{\n label: string\n value: string\n color?: string\n }>\n }\n }\n create: {\n title: string\n description?: string\n submit_button: string\n sections: Array<{\n id: string\n title: string\n description?: string\n fields: Array<SolutionAppField>\n }>\n }\n}\n\nexport type SolutionAppField =\n | {\n id: string\n kind: \"textarea\"\n label: string\n placeholder?: string\n }\n | {\n id: string\n kind: \"file-upload\"\n accept?: string[]\n categories?: Array<{\n label: string\n description: string\n color: string\n }>\n }\n\nexport interface SolutionAppState {\n pipeline: Array<{\n id: string\n label: string\n status: \"done\" | \"active\" | \"pending\" | \"error\"\n }>\n meta: Record<\n string,\n {\n label: string\n value: string\n color?: string\n }\n >\n}\n\nexport interface BizRole {\n id: string\n name: string\n description?: string | null\n preview?: { url: string; title?: string | null } | null\n}\n","import { type } from \"arktype\"\n\nexport const TaskStatus = type(\"'pending' | 'in_progress' | 'done' | 'failed' | 'skipped'\")\nexport type TaskStatus = typeof TaskStatus.infer\n\nexport const Task = type({\n id: \"string\",\n goal: \"string\",\n skills: \"string[]\",\n depends_on: \"string[]\",\n status: TaskStatus,\n result_summary: \"string\",\n number: \"string\",\n})\nexport type Task = typeof Task.infer\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;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ands/protocol.ts","../src/schemas/projection-utils.ts","../src/schemas/solution.ts","../src/schemas/task.ts"],"sourcesContent":["import { BladeApiError } from \"./rest\"\n\nconst MAX_BACKOFF_MS = 60_000\nconst MAX_TIMER_MS = 2_147_483_647\n\n/** Scheduling policy for read-only polling; never sends or replays a request. */\nexport class PollingBackoff {\n private failures = 0\n private nextAt: number | false = 0\n\n constructor(private readonly intervalMs: number) {\n if (!Number.isFinite(intervalMs) || intervalMs <= 0 || intervalMs > MAX_BACKOFF_MS) {\n throw new RangeError(\"Polling interval must be between 0 and 60000 ms\")\n }\n }\n\n reset(): void {\n this.failures = 0\n this.nextAt = 0\n }\n\n failed(error: unknown): void {\n if (\n (error instanceof Error && error.name === \"AbortError\") ||\n (error instanceof BladeApiError && error.status < 500 &&\n error.status !== 408 && error.status !== 429)\n ) {\n this.nextAt = false\n return\n }\n this.failures = Math.min(this.failures + 1, 10)\n const ceiling = Math.min(MAX_BACKOFF_MS, this.intervalMs * 2 ** this.failures)\n const backoff = Math.max(this.intervalMs, ceiling * (0.5 + Math.random() * 0.5))\n const header = error instanceof BladeApiError\n ? error.response.headers.get(\"Retry-After\")?.trim()\n : undefined\n const retryAfter = header\n ? /^\\d+$/.test(header) ? Number(header) * 1000 : Date.parse(header) - Date.now()\n : 0\n const delay = Math.max(backoff, Number.isNaN(retryAfter) ? 0 : retryAfter)\n // Oversized server delays must not overflow browser timers into a hot loop.\n this.nextAt = delay > MAX_TIMER_MS ? false : Date.now() + delay\n }\n\n /** Zero means ready, false means stop, otherwise wait at least this many ms. */\n waitMs(): number | false {\n return this.nextAt === false ? false : Math.max(0, this.nextAt - Date.now())\n }\n}\n","import { isRecord } from \"./shared/type-guards\"\n\nexport const PLATFORM_SERVICE_NAMES = [\n \"os\",\n \"hub\",\n \"agent\",\n \"oauth\",\n \"llmGateway\",\n \"gitea\",\n \"tile\",\n] as const\n\nexport type PlatformServiceName = (typeof PLATFORM_SERVICE_NAMES)[number]\n\nexport interface PlatformEndpoints {\n services: Partial<Record<PlatformServiceName, string>>\n}\n\nexport const EMPTY_PLATFORM_ENDPOINTS: PlatformEndpoints = Object.freeze({\n services: Object.freeze({}),\n})\n\nexport interface LoadPlatformEndpointsOptions {\n baseUrl?: string\n fetchImpl?: typeof fetch\n timeoutMs?: number\n}\n\nfunction defaultDocumentBaseUrl(): string | undefined {\n if (typeof document === \"undefined\") return undefined\n if (document.querySelector(\"base[href]\")) return document.baseURI\n if (typeof location !== \"undefined\" && location.origin) return `${location.origin}/`\n return document.baseURI\n}\n\nfunction normalizeServiceUrl(value: unknown): string | null {\n if (typeof value !== \"string\" || !value.trim()) return null\n if (value.includes(\"?\") || value.includes(\"#\")) return null\n try {\n const url = new URL(value.trim())\n if (url.protocol !== \"http:\" && url.protocol !== \"https:\") return null\n if (url.username || url.password || url.search || url.hash) return null\n return url.toString().replace(/\\/$/, \"\")\n } catch {\n return null\n }\n}\n\nexport function parsePlatformEndpoints(value: unknown): PlatformEndpoints | null {\n if (!isRecord(value) || !isRecord(value.services)) return null\n\n const services: Partial<Record<PlatformServiceName, string>> = {}\n for (const name of PLATFORM_SERVICE_NAMES) {\n if (!(name in value.services)) continue\n const url = normalizeServiceUrl(value.services[name])\n if (!url) return null\n if (name === \"agent\" && new URL(url).pathname !== \"/\") return null\n services[name] = url\n }\n\n return { services }\n}\n\nexport async function loadPlatformEndpoints(\n options: LoadPlatformEndpointsOptions = {},\n): Promise<PlatformEndpoints> {\n const fetchImpl = options.fetchImpl ?? globalThis.fetch\n const baseUrl = options.baseUrl ?? defaultDocumentBaseUrl()\n if (!fetchImpl || !baseUrl) return EMPTY_PLATFORM_ENDPOINTS\n\n const controller = new AbortController()\n const timeout = globalThis.setTimeout(() => controller.abort(), options.timeoutMs ?? 3_000)\n try {\n const response = await fetchImpl(new URL(\"config.json\", baseUrl), {\n cache: \"no-store\",\n credentials: \"same-origin\",\n headers: { Accept: \"application/json\" },\n signal: controller.signal,\n })\n if (!response.ok) return EMPTY_PLATFORM_ENDPOINTS\n return parsePlatformEndpoints(await response.json()) ?? EMPTY_PLATFORM_ENDPOINTS\n } catch {\n return EMPTY_PLATFORM_ENDPOINTS\n } finally {\n globalThis.clearTimeout(timeout)\n }\n}\n\nexport function resolveServiceUrl(\n endpoints: PlatformEndpoints,\n name: PlatformServiceName,\n path = \"\",\n): string | null {\n const baseUrl = endpoints.services[name]\n if (!baseUrl) return null\n if (!path) return baseUrl\n const pathReference = path.trimStart()\n if (\n path.includes(\"\\\\\") ||\n pathReference.startsWith(\"//\") ||\n /^[a-z][a-z0-9+.-]*:/i.test(pathReference)\n ) {\n return null\n }\n const base = new URL(`${baseUrl}/`)\n const target = new URL(path.replace(/^\\/+/, \"\"), base)\n if (target.origin !== base.origin || !target.pathname.startsWith(base.pathname)) {\n return null\n }\n return target.toString()\n}\n","/**\n * 页面协作协议(对应后端 `_meta.bridge` 通道,见 docs/specs/260417-embed-bridge)。\n *\n * ## action 从哪里来\n *\n * 智能体 → 宿主方向的每一条指令,都源自**技能作者写的工具代码**:工具返回值\n * JSON 里带 `_meta.bridge: { action, payload }`,后端在持久化前把它剥离成独立\n * 事件送达前端(LLM 的对话历史里读不到它)。因此:\n *\n * - action 字符串(如 \"map.highlight\")是**技能作者与宿主页面开发者之间的业务\n * 契约**,LLM 不参与协议、SDK 不做枚举校验;\n * - 宿主页面用 `session.onCommand(\"map.highlight\", fn)` 消费;\n * - 未注册 handler 的 action 会进入有限缓冲等待注册,超限后丢弃并 console 告警。\n *\n * 宿主 → 智能体方向只有三个白名单动作:attach(附件入输入框)/ insertText\n * (追加输入文本)/ send(直接发消息),对应协议层的 addContext / appendInput /\n * sendMessage。\n */\n\nexport interface CommandEnvelope {\n __bladeBridge: true\n direction: \"agent-to-host\"\n action: string\n payload: unknown\n meta: {\n sessionId: string\n toolCallId?: string\n timestamp: number\n }\n}\n\nexport type InboundAction = \"addContext\" | \"appendInput\" | \"sendMessage\"\n\nexport interface InboundEnvelope {\n __bladeBridge: true\n direction: \"host-to-agent\"\n action: InboundAction\n payload: unknown\n}\n\nexport function isCommandEnvelope(value: unknown): value is CommandEnvelope {\n if (typeof value !== \"object\" || value === null) return false\n const record = value as Record<string, unknown>\n return (\n record.__bladeBridge === true &&\n record.direction === \"agent-to-host\" &&\n typeof record.action === \"string\"\n )\n}\n\nexport function isInboundEnvelope(value: unknown): value is InboundEnvelope {\n if (typeof value !== \"object\" || value === null) return false\n const record = value as Record<string, unknown>\n return (\n record.__bladeBridge === true &&\n record.direction === \"host-to-agent\" &&\n (record.action === \"addContext\" || record.action === \"appendInput\" || record.action === \"sendMessage\")\n )\n}\n","import type { PostChatFollowup, TurnProjection } from \"./projection\"\n\n/** 返回最新根会话轮次的小结;新用户消息到达后旧小结立即失效。 */\nexport function latestPostChatFollowup(turns: TurnProjection[]): PostChatFollowup | null {\n for (let index = turns.length - 1; index >= 0; index -= 1) {\n const turn = turns[index]\n if (\n turn.loop_id === \"root\" &&\n (turn.role === \"user\" || turn.role === \"assistant\") &&\n (turn.kind ?? \"message\") === \"message\" &&\n !turn.blocks.some((block) =>\n [\"mode_change\", \"plan_status\", \"ask_user_answer\"].includes(block.type),\n )\n ) {\n return turn.role === \"assistant\" ? (turn.post_chat_followup ?? null) : null\n }\n }\n return null\n}\n","export enum LayoutType {\n Default = \"default\",\n SkillEditor = \"skill-editor\",\n SolutionEditor = \"solution-editor\",\n SolutionApp = \"solution-app\",\n Custom = \"custom\",\n}\n\nexport interface Solution {\n id: string\n name: string\n version: string\n description?: string | null\n source?: \"builtin\" | \"personal\" | string | null\n layout_type: LayoutType | string\n initial_mode?: \"planning\" | \"executing\" | string | null\n initial_message?: string | null\n preview?: { url: string; title?: string | null } | null\n layout?: {\n available?: boolean\n source_dir?: string\n entry?: string\n export?: string\n } | null\n roles?: BizRole[] | null\n data?: Record<string, unknown> | null\n ui_config?: SolutionAppUiConfig | null\n}\n\nexport interface SolutionAppUiConfig {\n branding: {\n name: string\n subtitle?: string\n icon_text: string\n icon_gradient?: string\n }\n list: {\n title: string\n create_button: string\n card?: {\n subtitle?: string\n stats?: Array<{\n label: string\n value: string\n color?: string\n }>\n }\n }\n create: {\n title: string\n description?: string\n submit_button: string\n sections: Array<{\n id: string\n title: string\n description?: string\n fields: Array<SolutionAppField>\n }>\n }\n}\n\nexport type SolutionAppField =\n | {\n id: string\n kind: \"textarea\"\n label: string\n placeholder?: string\n }\n | {\n id: string\n kind: \"file-upload\"\n accept?: string[]\n categories?: Array<{\n label: string\n description: string\n color: string\n }>\n }\n\nexport interface SolutionAppState {\n pipeline: Array<{\n id: string\n label: string\n status: \"done\" | \"active\" | \"pending\" | \"error\"\n }>\n meta: Record<\n string,\n {\n label: string\n value: string\n color?: string\n }\n >\n}\n\nexport interface BizRole {\n id: string\n name: string\n description?: string | null\n preview?: { url: string; title?: string | null } | null\n}\n","import { type } from \"arktype\"\n\nexport const TaskStatus = type(\"'pending' | 'in_progress' | 'done' | 'failed' | 'skipped'\")\nexport type TaskStatus = typeof TaskStatus.infer\n\nexport const Task = type({\n id: \"string\",\n goal: \"string\",\n skills: \"string[]\",\n depends_on: \"string[]\",\n status: TaskStatus,\n result_summary: \"string\",\n number: \"string\",\n})\nexport type Task = typeof Task.infer\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAM,iBAAiB;AACvB,IAAM,eAAe;AAGd,IAAM,iBAAN,MAAqB;AAAA,EAI1B,YAA6B,YAAoB;AAApB;AAC3B,QAAI,CAAC,OAAO,SAAS,UAAU,KAAK,cAAc,KAAK,aAAa,gBAAgB;AAClF,YAAM,IAAI,WAAW,iDAAiD;AAAA,IACxE;AAAA,EACF;AAAA,EAJ6B;AAAA,EAHrB,WAAW;AAAA,EACX,SAAyB;AAAA,EAQjC,QAAc;AACZ,SAAK,WAAW;AAChB,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,OAAO,OAAsB;AAC3B,QACG,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AAK;AACxB,QACE,KAAK,YAAY,WAChB,KAAK,SAAS,UAAU,KAAK,SAAS,iBACtC,KAAK,QAAQ,eAAe,aAC7B,CAAC,KAAK,OAAO;AAAA,MAAK,CAAC,UACjB,CAAC,eAAe,eAAe,iBAAiB,EAAE,SAAS,MAAM,IAAI;AAAA,IACvE,GACA;AACA,aAAO,KAAK,SAAS,cAAe,KAAK,sBAAsB,OAAQ;AAAA,IACzE;AAAA,EACF;AACA,SAAO;AACT;;;AClBO,IAAK,aAAL,kBAAKA,gBAAL;AACL,EAAAA,YAAA,aAAU;AACV,EAAAA,YAAA,iBAAc;AACd,EAAAA,YAAA,oBAAiB;AACjB,EAAAA,YAAA,iBAAc;AACd,EAAAA,YAAA,YAAS;AALC,SAAAA;AAAA,GAAA;;;ACAZ,SAAS,YAAY;AAEd,IAAM,aAAa,KAAK,2DAA2D;AAGnF,IAAM,OAAO,KAAK;AAAA,EACvB,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAChB,QAAQ;AACV,CAAC;","names":["LayoutType"]}
|
package/dist/resources/auth.d.ts
CHANGED
|
@@ -53,7 +53,9 @@ export declare class AuthResource {
|
|
|
53
53
|
/** 清除 login() 存储的令牌。 */
|
|
54
54
|
logoutToken(): void;
|
|
55
55
|
getProviders(): Promise<ProvidersResponse>;
|
|
56
|
-
getMe(
|
|
56
|
+
getMe(options?: {
|
|
57
|
+
signal?: AbortSignal;
|
|
58
|
+
}): Promise<UserInfo>;
|
|
57
59
|
logout(): Promise<{
|
|
58
60
|
logout_url: string;
|
|
59
61
|
}>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BladeClient } from "../blade-client";
|
|
2
|
+
export type ChatGroupRole = "owner" | "editor" | "viewer";
|
|
2
3
|
export interface ChatGroup {
|
|
3
4
|
id: string;
|
|
4
5
|
name: string;
|
|
@@ -6,12 +7,67 @@ export interface ChatGroup {
|
|
|
6
7
|
created_at: string;
|
|
7
8
|
updated_at: string;
|
|
8
9
|
session_count: number;
|
|
10
|
+
member_count: number;
|
|
11
|
+
role: ChatGroupRole;
|
|
9
12
|
initiator: "ui" | "sdk" | null;
|
|
10
13
|
workspace_path: string;
|
|
11
14
|
}
|
|
15
|
+
export interface ChatGroupMember {
|
|
16
|
+
user_id: string;
|
|
17
|
+
display_name: string | null;
|
|
18
|
+
username: string;
|
|
19
|
+
role: ChatGroupRole;
|
|
20
|
+
added_by: string;
|
|
21
|
+
added_at: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ChatGroupTask {
|
|
24
|
+
id: string;
|
|
25
|
+
group_id: string;
|
|
26
|
+
number: number;
|
|
27
|
+
title: string;
|
|
28
|
+
description: string;
|
|
29
|
+
owner_user_id: string;
|
|
30
|
+
owner_display_name: string;
|
|
31
|
+
owner_left: boolean;
|
|
32
|
+
due_date: string | null;
|
|
33
|
+
status: "todo" | "doing" | "done";
|
|
34
|
+
/** Only returned to the owner of this private session. */
|
|
35
|
+
session_id: string | null;
|
|
36
|
+
can_open_session: boolean;
|
|
37
|
+
agent_started: boolean;
|
|
38
|
+
created_by: string;
|
|
39
|
+
created_at: string;
|
|
40
|
+
updated_at: string;
|
|
41
|
+
}
|
|
42
|
+
export interface CreateChatGroupTask {
|
|
43
|
+
title: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
owner_user_id: string;
|
|
46
|
+
due_date?: string | null;
|
|
47
|
+
start_agent?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface UpdateChatGroupTask extends Partial<Omit<CreateChatGroupTask, "start_agent">> {
|
|
50
|
+
status?: ChatGroupTask["status"];
|
|
51
|
+
}
|
|
52
|
+
export interface ChatGroupAsset {
|
|
53
|
+
path: string;
|
|
54
|
+
is_dir: boolean;
|
|
55
|
+
size: number;
|
|
56
|
+
sha256: string;
|
|
57
|
+
submitted_by: string;
|
|
58
|
+
submitted_by_name: string;
|
|
59
|
+
session_id: string | null;
|
|
60
|
+
message: string;
|
|
61
|
+
updated_at: string;
|
|
62
|
+
}
|
|
63
|
+
export interface ChatGroupAssetList {
|
|
64
|
+
group_id: string;
|
|
65
|
+
items: ChatGroupAsset[];
|
|
66
|
+
}
|
|
12
67
|
export declare class ChatGroupsResource {
|
|
13
68
|
private readonly client;
|
|
14
69
|
constructor(client: BladeClient);
|
|
70
|
+
private path;
|
|
15
71
|
list(): Promise<ChatGroup[]>;
|
|
16
72
|
create(payload: {
|
|
17
73
|
name: string;
|
|
@@ -28,4 +84,40 @@ export declare class ChatGroupsResource {
|
|
|
28
84
|
deleted: boolean;
|
|
29
85
|
deleted_sessions: number;
|
|
30
86
|
}>;
|
|
87
|
+
listMembers(groupId: string): Promise<ChatGroupMember[]>;
|
|
88
|
+
addMembers(groupId: string, userIds: string[], role: "editor" | "viewer"): Promise<ChatGroupMember[]>;
|
|
89
|
+
updateMember(groupId: string, userId: string, role: "editor" | "viewer"): Promise<ChatGroupMember>;
|
|
90
|
+
removeMember(groupId: string, userId: string): Promise<{
|
|
91
|
+
deleted: boolean;
|
|
92
|
+
}>;
|
|
93
|
+
listTasks(groupId: string): Promise<ChatGroupTask[]>;
|
|
94
|
+
createTask(groupId: string, payload: CreateChatGroupTask): Promise<ChatGroupTask>;
|
|
95
|
+
updateTask(groupId: string, taskId: string, payload: UpdateChatGroupTask): Promise<ChatGroupTask>;
|
|
96
|
+
deleteTask(groupId: string, taskId: string): Promise<{
|
|
97
|
+
deleted: boolean;
|
|
98
|
+
}>;
|
|
99
|
+
listAssets(groupId: string): Promise<ChatGroupAssetList>;
|
|
100
|
+
readAsset(groupId: string, path: string, signal?: AbortSignal): Promise<Blob>;
|
|
101
|
+
/** Read at most the first 1 MiB. Full downloads continue to use readAsset. */
|
|
102
|
+
readAssetPreview(groupId: string, path: string, signal?: AbortSignal): Promise<{
|
|
103
|
+
blob: Blob;
|
|
104
|
+
truncated: boolean;
|
|
105
|
+
}>;
|
|
106
|
+
uploadAsset(groupId: string, file: File, path: string, message?: string): Promise<{
|
|
107
|
+
file: ChatGroupAsset;
|
|
108
|
+
}>;
|
|
109
|
+
createAssetFolder(groupId: string, path: string): Promise<{
|
|
110
|
+
file: ChatGroupAsset;
|
|
111
|
+
}>;
|
|
112
|
+
deleteAsset(groupId: string, path: string): Promise<{
|
|
113
|
+
deleted: boolean;
|
|
114
|
+
}>;
|
|
115
|
+
submitSessionAsset(payload: {
|
|
116
|
+
session_id: string;
|
|
117
|
+
path: string;
|
|
118
|
+
target_path: string;
|
|
119
|
+
message?: string;
|
|
120
|
+
}): Promise<{
|
|
121
|
+
file: ChatGroupAsset;
|
|
122
|
+
}>;
|
|
31
123
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import type { TopicAssetRef } from "../schemas/topic-assets";
|
|
1
2
|
import type { BladeClient } from "../blade-client";
|
|
2
3
|
export type JsonSchemaObject = Record<string, unknown>;
|
|
3
4
|
export interface HeadlessRunOptions {
|
|
4
5
|
schema?: JsonSchemaObject | null;
|
|
5
6
|
model?: string | null;
|
|
6
7
|
timeoutMs?: number;
|
|
8
|
+
/** Assets explicitly selected for this message in a topic-linked session. */
|
|
9
|
+
refs?: import("../schemas/plugin-refs").MessageRef[];
|
|
10
|
+
topicAssetRefs?: TopicAssetRef[];
|
|
7
11
|
}
|
|
8
12
|
export interface HeadlessRunInSessionResult<T = unknown> {
|
|
9
13
|
session_id: string;
|
|
@@ -16,6 +20,7 @@ export declare class HeadlessError extends Error {
|
|
|
16
20
|
}
|
|
17
21
|
export declare class HeadlessResource {
|
|
18
22
|
private client;
|
|
23
|
+
private readonly subscriptions;
|
|
19
24
|
constructor(client: BladeClient);
|
|
20
25
|
run<T = unknown>(prompt: string, options: HeadlessRunOptions & {
|
|
21
26
|
schema: JsonSchemaObject;
|
|
@@ -2,6 +2,9 @@ import type { BladeClient } from "../blade-client";
|
|
|
2
2
|
export interface ModelOption {
|
|
3
3
|
id: string;
|
|
4
4
|
label: string;
|
|
5
|
+
thinkingAvailable?: boolean;
|
|
6
|
+
reasoningLevels?: string[];
|
|
7
|
+
defaultReasoningLevel?: string;
|
|
5
8
|
/**
|
|
6
9
|
* 把这个模型发给 `baseUrl` 时该用的名字。`id` 是平台内部标识,接了多个模型服务时
|
|
7
10
|
* 形如 `provider-xxx::name`,直接发过去会被拒。不在 `baseUrl` 那个服务上的模型
|
|
@@ -35,5 +38,7 @@ export interface ModelCatalog {
|
|
|
35
38
|
export declare class ModelsResource {
|
|
36
39
|
private client;
|
|
37
40
|
constructor(client: BladeClient);
|
|
38
|
-
list(
|
|
41
|
+
list(options?: {
|
|
42
|
+
signal?: AbortSignal;
|
|
43
|
+
}): Promise<ModelCatalog>;
|
|
39
44
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BackgroundTask, BackgroundTaskStopResult } from "../schemas/background";
|
|
2
2
|
import type { TurnProjection } from "../schemas/projection";
|
|
3
3
|
import type { McpAppArchive } from "../schemas/mcp-app";
|
|
4
|
-
import type { PublishedSolutionRef, ReplayPreview, ReplaySpeed, SessionDetail, SessionInfo
|
|
4
|
+
import type { PublishedSolutionRef, ReplayPreview, ReplaySpeed, SessionDetail, SessionInfo } from "../schemas/session";
|
|
5
5
|
import type { McpAppContextState, McpAppContextUpdate } from "../schemas/mcp-app";
|
|
6
6
|
import type { Task } from "../schemas/task";
|
|
7
7
|
import type { BladeClient, UploadProgress } from "../blade-client";
|
|
@@ -52,6 +52,14 @@ export interface SessionPluginConfigError {
|
|
|
52
52
|
/** Value-free message; the platform never echoes submitted secrets. */
|
|
53
53
|
message: string;
|
|
54
54
|
}
|
|
55
|
+
export interface SessionPluginHostState {
|
|
56
|
+
digest: string;
|
|
57
|
+
revision: string;
|
|
58
|
+
state: string;
|
|
59
|
+
reason: string;
|
|
60
|
+
restarts: number;
|
|
61
|
+
recent?: string[];
|
|
62
|
+
}
|
|
55
63
|
export interface SessionPluginConfigState {
|
|
56
64
|
state: SessionPluginConfigStateName;
|
|
57
65
|
reason: string | null;
|
|
@@ -64,6 +72,8 @@ export interface SessionPluginConfigState {
|
|
|
64
72
|
/** Opaque revision for optimistic concurrency; null when nothing is stored. */
|
|
65
73
|
revision: string | null;
|
|
66
74
|
errors: SessionPluginConfigError[];
|
|
75
|
+
auth_status?: "login_required" | "ready" | "expired";
|
|
76
|
+
global_ready?: boolean;
|
|
67
77
|
}
|
|
68
78
|
export interface SessionPluginConfigSet {
|
|
69
79
|
/** JSON Pointer; arrays are replaced as a whole. */
|
|
@@ -77,8 +87,11 @@ export interface SessionPluginConfigUpdate {
|
|
|
77
87
|
remove?: string[];
|
|
78
88
|
}
|
|
79
89
|
export interface CreateSessionRequest {
|
|
90
|
+
/** Notification owner. Built-in Web declares ui; external applications default to sdk. */
|
|
91
|
+
initiator?: "ui" | "sdk";
|
|
92
|
+
/** 认证创建独立匿名沙盒;链接持有者可继续聊天,不继承个人资源。 */
|
|
93
|
+
anonymous?: boolean;
|
|
80
94
|
intent?: string;
|
|
81
|
-
template_id?: TemplateId;
|
|
82
95
|
/** 正式 Solution 来源。Hub 使用 { source: "hub", org, name }。 */
|
|
83
96
|
solution_ref?: PublishedSolutionRef;
|
|
84
97
|
/** @deprecated 请使用结构化的 solution_ref;继续支持以保证现有 SDK 调用无感升级。 */
|
|
@@ -86,12 +99,14 @@ export interface CreateSessionRequest {
|
|
|
86
99
|
/** 从已有会话复制其不可变 Solution 与 Skill 运行快照。 */
|
|
87
100
|
solution_snapshot_session_id?: string;
|
|
88
101
|
biz_role_id?: string | null;
|
|
89
|
-
primary_skill_id?: string | null;
|
|
90
102
|
model?: string | null;
|
|
91
103
|
enable_thinking?: boolean | null;
|
|
92
104
|
memory_enabled?: boolean | null;
|
|
93
105
|
env?: Record<string, string>;
|
|
94
106
|
disable_tools?: string[] | null;
|
|
107
|
+
mcp_sources?: McpSourceConfig[];
|
|
108
|
+
/** 此会话的所有普通轮次直接执行工具,不弹审批。 */
|
|
109
|
+
skip_confirmations?: boolean;
|
|
95
110
|
session_solution_asset_id?: string | null;
|
|
96
111
|
compaction_ratio?: number | null;
|
|
97
112
|
runtime_type?: "sandbox" | "daemon" | "native" | null;
|
|
@@ -100,6 +115,52 @@ export interface CreateSessionRequest {
|
|
|
100
115
|
agent_runtime_id?: string | null;
|
|
101
116
|
chat_group_id?: string | null;
|
|
102
117
|
}
|
|
118
|
+
export interface McpSourceConfig {
|
|
119
|
+
/** Source summary shown before lazy tool discovery. */
|
|
120
|
+
description?: string;
|
|
121
|
+
id: string;
|
|
122
|
+
url: string;
|
|
123
|
+
bearer_token?: string | null;
|
|
124
|
+
exposure?: "lazy" | "eager";
|
|
125
|
+
include_tools?: string[] | null;
|
|
126
|
+
eager_tools?: string[];
|
|
127
|
+
}
|
|
128
|
+
/** Sandbox only. Omitted fields are retained; lists/maps replace their previous value. */
|
|
129
|
+
export interface UpdateSessionConfigurationRequest {
|
|
130
|
+
version: string;
|
|
131
|
+
expected_revision?: number;
|
|
132
|
+
solution_ref?: PublishedSolutionRef;
|
|
133
|
+
solution_id?: string;
|
|
134
|
+
session_solution_asset_id?: string;
|
|
135
|
+
biz_role_id?: string;
|
|
136
|
+
model?: string;
|
|
137
|
+
enable_thinking?: boolean | null;
|
|
138
|
+
memory_enabled?: boolean;
|
|
139
|
+
env?: Record<string, string>;
|
|
140
|
+
disable_tools?: string[];
|
|
141
|
+
mcp_sources?: McpSourceConfig[];
|
|
142
|
+
skip_confirmations?: boolean;
|
|
143
|
+
compaction_ratio?: number | null;
|
|
144
|
+
}
|
|
145
|
+
export interface SessionConfiguration {
|
|
146
|
+
session_id: string;
|
|
147
|
+
version: string | null;
|
|
148
|
+
revision: number;
|
|
149
|
+
configuration: {
|
|
150
|
+
solution_identity: Record<string, unknown> | null;
|
|
151
|
+
solution_version: string | null;
|
|
152
|
+
biz_role_id: string | null;
|
|
153
|
+
biz_role_version: string | null;
|
|
154
|
+
model: string | null;
|
|
155
|
+
enable_thinking: boolean | null;
|
|
156
|
+
memory_enabled: boolean;
|
|
157
|
+
env: Record<string, string>;
|
|
158
|
+
disable_tools: string[];
|
|
159
|
+
mcp_sources: Omit<McpSourceConfig, "bearer_token">[];
|
|
160
|
+
skip_confirmations: boolean;
|
|
161
|
+
compaction_ratio: number | null;
|
|
162
|
+
};
|
|
163
|
+
}
|
|
103
164
|
export interface CheckpointNode {
|
|
104
165
|
id: string;
|
|
105
166
|
parent_id: string | null;
|
|
@@ -281,6 +342,7 @@ export interface ImportPreviewSkill {
|
|
|
281
342
|
description: string;
|
|
282
343
|
path: string;
|
|
283
344
|
}
|
|
345
|
+
/** Legacy archive decode shape only; custom scenario scripts are never executed. */
|
|
284
346
|
export interface ImportPreviewScenario {
|
|
285
347
|
scenario?: {
|
|
286
348
|
name?: string;
|
|
@@ -294,6 +356,7 @@ export interface ImportPreview {
|
|
|
294
356
|
user_messages: string[];
|
|
295
357
|
turn_count: number;
|
|
296
358
|
skills: ImportPreviewSkill[];
|
|
359
|
+
/** Retained for older responses. Current servers always return null. */
|
|
297
360
|
scenario: ImportPreviewScenario | null;
|
|
298
361
|
}
|
|
299
362
|
export interface ImportSessionOptions {
|
|
@@ -360,32 +423,36 @@ export declare class SessionsResource {
|
|
|
360
423
|
*
|
|
361
424
|
* Secrets are never returned: `write_only` lists the pointers that hold one.
|
|
362
425
|
*/
|
|
363
|
-
getSessionPluginConfig(sessionId: string, name: string, init?: RequestInit): Promise<{
|
|
426
|
+
getSessionPluginConfig(sessionId: string, name: string, init?: RequestInit, scope?: "personal" | "global"): Promise<{
|
|
364
427
|
plugin: string;
|
|
365
428
|
config: SessionPluginConfigState;
|
|
429
|
+
can_configure_global?: boolean;
|
|
430
|
+
host?: SessionPluginHostState | null;
|
|
366
431
|
}>;
|
|
367
432
|
/**
|
|
368
|
-
*
|
|
433
|
+
* Save explicit set/remove operations to encrypted server storage.
|
|
369
434
|
*
|
|
370
435
|
* Fields absent from both lists keep their stored value, so a form never has
|
|
371
|
-
* to round-trip a secret. Rejections
|
|
372
|
-
*
|
|
436
|
+
* to round-trip a secret. Rejections preserve the previous values; the
|
|
437
|
+
* shared settings restart only the affected hosted plugin.
|
|
373
438
|
*/
|
|
374
|
-
updateSessionPluginConfig(sessionId: string, name: string, update: SessionPluginConfigUpdate, init?: RequestInit): Promise<{
|
|
439
|
+
updateSessionPluginConfig(sessionId: string, name: string, update: SessionPluginConfigUpdate, init?: RequestInit, scope?: "personal" | "global"): Promise<{
|
|
375
440
|
plugin: string;
|
|
376
441
|
config: SessionPluginConfigState;
|
|
377
442
|
}>;
|
|
443
|
+
restartSessionPluginHost(sessionId: string, name: string): Promise<{
|
|
444
|
+
host: SessionPluginHostState | null;
|
|
445
|
+
}>;
|
|
378
446
|
/** 创建新会话并直接连接,返回可收发消息的 AgentSession。 */
|
|
379
447
|
create(request?: CreateSessionRequest | SessionDefinition): Promise<AgentSession>;
|
|
380
448
|
private createDeclared;
|
|
381
449
|
private prepareSolution;
|
|
382
450
|
private cleanupSolutionAsset;
|
|
383
451
|
private fetchSessionsPage;
|
|
384
|
-
listSessions(
|
|
452
|
+
listSessions(solution_id?: string): Promise<SessionInfo[]>;
|
|
385
453
|
listSessionsPaginated(params: {
|
|
386
454
|
limit: number;
|
|
387
455
|
offset: number;
|
|
388
|
-
template_id_prefix?: string;
|
|
389
456
|
solution_id?: string;
|
|
390
457
|
solution_registry_id?: string;
|
|
391
458
|
q?: string;
|
|
@@ -396,7 +463,7 @@ export declare class SessionsResource {
|
|
|
396
463
|
q: string;
|
|
397
464
|
limit?: number;
|
|
398
465
|
}): Promise<GlobalSearchResult>;
|
|
399
|
-
createSession(intent?: string
|
|
466
|
+
createSession(intent?: string): Promise<{
|
|
400
467
|
session_id: string;
|
|
401
468
|
}>;
|
|
402
469
|
createSessionWithRequest(request: CreateSessionRequest): Promise<{
|
|
@@ -413,6 +480,9 @@ export declare class SessionsResource {
|
|
|
413
480
|
intent?: string;
|
|
414
481
|
chat_group_id?: string | null;
|
|
415
482
|
}): Promise<SessionDetail>;
|
|
483
|
+
getSessionConfiguration(sessionId: string, init?: RequestInit): Promise<SessionConfiguration>;
|
|
484
|
+
/** Updates atomically between turns. A running/handoff session returns HTTP 409. */
|
|
485
|
+
updateSessionConfiguration(sessionId: string, request: UpdateSessionConfigurationRequest): Promise<SessionConfiguration>;
|
|
416
486
|
setSessionEnv(sessionId: string, env: Record<string, string>): Promise<SessionDetail>;
|
|
417
487
|
pinSession(sessionId: string, pinned: boolean): Promise<SessionInfo>;
|
|
418
488
|
startReplaySession(sourceSessionId: string, speed?: ReplaySpeed): Promise<{
|
|
@@ -478,15 +548,30 @@ export declare class SessionsResource {
|
|
|
478
548
|
mode?: string;
|
|
479
549
|
files_restored?: boolean;
|
|
480
550
|
linear?: boolean;
|
|
551
|
+
history_committed?: boolean;
|
|
552
|
+
file_checkpoint_cleanup_failed?: boolean;
|
|
553
|
+
warning?: string;
|
|
481
554
|
}>;
|
|
482
555
|
rewindSession(sessionId: string, checkpointId: string): Promise<{
|
|
483
556
|
id: string;
|
|
484
557
|
content: string;
|
|
558
|
+
history_committed?: boolean;
|
|
559
|
+
file_checkpoint_cleanup_failed?: boolean;
|
|
560
|
+
warning?: string;
|
|
485
561
|
}>;
|
|
486
562
|
switchBranch(sessionId: string, checkpointId: string): Promise<{
|
|
487
563
|
id: string;
|
|
488
564
|
leaf_id: string;
|
|
489
565
|
}>;
|
|
566
|
+
listAnonymousSessions(): Promise<Array<{
|
|
567
|
+
id: string;
|
|
568
|
+
intent: string;
|
|
569
|
+
created_at: string;
|
|
570
|
+
status: string;
|
|
571
|
+
}>>;
|
|
572
|
+
deleteAnonymousSession(sessionId: string): Promise<{
|
|
573
|
+
deleted: boolean;
|
|
574
|
+
}>;
|
|
490
575
|
deleteSession(sessionId: string, options?: {
|
|
491
576
|
deleteWorkspace?: boolean;
|
|
492
577
|
}): Promise<{
|