@blade-hq/agent-client 2612.0.0-beta.11 → 2612.0.0-beta.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/README.md +59 -2
- package/dist/{chunk-SCG5SRXE.js → chunk-KPS6X6QX.js} +13 -16
- package/dist/chunk-KPS6X6QX.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +1 -1
- package/dist/resources/sessions.d.ts +42 -6
- package/dist/schemas/session.d.ts +1 -42
- package/dist/session/agent-session.d.ts +0 -1
- package/dist/session/events.d.ts +0 -1
- 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 +36 -17
- package/dist/chunk-SCG5SRXE.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ 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, McpSourceConfig, 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
26
|
export type { ChatMessage, FileContentPart, ImageUrlContentPart, MemoryRefInfo, MessageContent, MessageContentPart, TextContentPart, ToolCallInfo, WorkflowStepInfo, } from "./schemas/message";
|
package/dist/index.js
CHANGED
package/dist/internal.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export type { ContentBlock, FinalArtifact, MemoryRef, PatchEnvelope, PendingQues
|
|
|
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";
|
package/dist/internal.js
CHANGED
|
@@ -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";
|
|
@@ -88,7 +88,6 @@ export interface SessionPluginConfigUpdate {
|
|
|
88
88
|
}
|
|
89
89
|
export interface CreateSessionRequest {
|
|
90
90
|
intent?: string;
|
|
91
|
-
template_id?: TemplateId;
|
|
92
91
|
/** 正式 Solution 来源。Hub 使用 { source: "hub", org, name }。 */
|
|
93
92
|
solution_ref?: PublishedSolutionRef;
|
|
94
93
|
/** @deprecated 请使用结构化的 solution_ref;继续支持以保证现有 SDK 调用无感升级。 */
|
|
@@ -96,7 +95,6 @@ export interface CreateSessionRequest {
|
|
|
96
95
|
/** 从已有会话复制其不可变 Solution 与 Skill 运行快照。 */
|
|
97
96
|
solution_snapshot_session_id?: string;
|
|
98
97
|
biz_role_id?: string | null;
|
|
99
|
-
primary_skill_id?: string | null;
|
|
100
98
|
model?: string | null;
|
|
101
99
|
enable_thinking?: boolean | null;
|
|
102
100
|
memory_enabled?: boolean | null;
|
|
@@ -121,6 +119,42 @@ export interface McpSourceConfig {
|
|
|
121
119
|
include_tools?: string[] | null;
|
|
122
120
|
eager_tools?: string[];
|
|
123
121
|
}
|
|
122
|
+
/** Sandbox only. Omitted fields are retained; lists/maps replace their previous value. */
|
|
123
|
+
export interface UpdateSessionConfigurationRequest {
|
|
124
|
+
version: string;
|
|
125
|
+
expected_revision?: number;
|
|
126
|
+
solution_ref?: PublishedSolutionRef;
|
|
127
|
+
solution_id?: string;
|
|
128
|
+
session_solution_asset_id?: string;
|
|
129
|
+
biz_role_id?: string;
|
|
130
|
+
model?: string;
|
|
131
|
+
enable_thinking?: boolean | null;
|
|
132
|
+
memory_enabled?: boolean;
|
|
133
|
+
env?: Record<string, string>;
|
|
134
|
+
disable_tools?: string[];
|
|
135
|
+
mcp_sources?: McpSourceConfig[];
|
|
136
|
+
skip_confirmations?: boolean;
|
|
137
|
+
compaction_ratio?: number | null;
|
|
138
|
+
}
|
|
139
|
+
export interface SessionConfiguration {
|
|
140
|
+
session_id: string;
|
|
141
|
+
version: string | null;
|
|
142
|
+
revision: number;
|
|
143
|
+
configuration: {
|
|
144
|
+
solution_identity: Record<string, unknown> | null;
|
|
145
|
+
solution_version: string | null;
|
|
146
|
+
biz_role_id: string | null;
|
|
147
|
+
biz_role_version: string | null;
|
|
148
|
+
model: string | null;
|
|
149
|
+
enable_thinking: boolean | null;
|
|
150
|
+
memory_enabled: boolean;
|
|
151
|
+
env: Record<string, string>;
|
|
152
|
+
disable_tools: string[];
|
|
153
|
+
mcp_sources: Omit<McpSourceConfig, "bearer_token">[];
|
|
154
|
+
skip_confirmations: boolean;
|
|
155
|
+
compaction_ratio: number | null;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
124
158
|
export interface CheckpointNode {
|
|
125
159
|
id: string;
|
|
126
160
|
parent_id: string | null;
|
|
@@ -409,11 +443,10 @@ export declare class SessionsResource {
|
|
|
409
443
|
private prepareSolution;
|
|
410
444
|
private cleanupSolutionAsset;
|
|
411
445
|
private fetchSessionsPage;
|
|
412
|
-
listSessions(
|
|
446
|
+
listSessions(solution_id?: string): Promise<SessionInfo[]>;
|
|
413
447
|
listSessionsPaginated(params: {
|
|
414
448
|
limit: number;
|
|
415
449
|
offset: number;
|
|
416
|
-
template_id_prefix?: string;
|
|
417
450
|
solution_id?: string;
|
|
418
451
|
solution_registry_id?: string;
|
|
419
452
|
q?: string;
|
|
@@ -424,7 +457,7 @@ export declare class SessionsResource {
|
|
|
424
457
|
q: string;
|
|
425
458
|
limit?: number;
|
|
426
459
|
}): Promise<GlobalSearchResult>;
|
|
427
|
-
createSession(intent?: string
|
|
460
|
+
createSession(intent?: string): Promise<{
|
|
428
461
|
session_id: string;
|
|
429
462
|
}>;
|
|
430
463
|
createSessionWithRequest(request: CreateSessionRequest): Promise<{
|
|
@@ -441,6 +474,9 @@ export declare class SessionsResource {
|
|
|
441
474
|
intent?: string;
|
|
442
475
|
chat_group_id?: string | null;
|
|
443
476
|
}): Promise<SessionDetail>;
|
|
477
|
+
getSessionConfiguration(sessionId: string, init?: RequestInit): Promise<SessionConfiguration>;
|
|
478
|
+
/** Updates atomically between turns. A running/handoff session returns HTTP 409. */
|
|
479
|
+
updateSessionConfiguration(sessionId: string, request: UpdateSessionConfigurationRequest): Promise<SessionConfiguration>;
|
|
444
480
|
setSessionEnv(sessionId: string, env: Record<string, string>): Promise<SessionDetail>;
|
|
445
481
|
pinSession(sessionId: string, pinned: boolean): Promise<SessionInfo>;
|
|
446
482
|
startReplaySession(sourceSessionId: string, speed?: ReplaySpeed): Promise<{
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { Solution } from "./solution";
|
|
2
2
|
export declare const SessionStatus: import("arktype/internal/variants/string.ts").StringType<"completed" | "created" | "failed" | "interrupted" | "running" | "waiting_for_input", {}>;
|
|
3
3
|
export type SessionStatus = typeof SessionStatus.infer;
|
|
4
|
-
export type TemplateId = "default" | "skill_editor" | "ship_attack";
|
|
5
|
-
export type SkillEditorTemplateId = "skill_editor";
|
|
6
4
|
export type ModeId = "planning" | "executing";
|
|
7
5
|
export type PublishedSolutionRef = {
|
|
8
6
|
source: "builtin";
|
|
@@ -65,7 +63,6 @@ export declare const SessionInfo: import("arktype/internal/variants/object.ts").
|
|
|
65
63
|
initiator?: "sdk" | "ui" | "unknown" | null | undefined;
|
|
66
64
|
is_headless?: boolean | undefined;
|
|
67
65
|
viewer_role?: "owner" | "viewer" | undefined;
|
|
68
|
-
template_id?: string | null | undefined;
|
|
69
66
|
model?: string | null | undefined;
|
|
70
67
|
enable_thinking?: boolean | null | undefined;
|
|
71
68
|
solution_id?: string | null | undefined;
|
|
@@ -73,8 +70,6 @@ export declare const SessionInfo: import("arktype/internal/variants/object.ts").
|
|
|
73
70
|
biz_role_id?: string | null | undefined;
|
|
74
71
|
solution?: unknown;
|
|
75
72
|
plan_summary?: string | null | undefined;
|
|
76
|
-
primary_skill_id?: string | null | undefined;
|
|
77
|
-
bound_skill_id?: string | null | undefined;
|
|
78
73
|
replay_state?: unknown;
|
|
79
74
|
is_pinned?: boolean | undefined;
|
|
80
75
|
pinned_at?: string | null | undefined;
|
|
@@ -90,21 +85,18 @@ export declare const SessionInfo: import("arktype/internal/variants/object.ts").
|
|
|
90
85
|
chat_group_id?: string | null | undefined;
|
|
91
86
|
match?: unknown;
|
|
92
87
|
}, {}>;
|
|
93
|
-
export type SessionInfo = Omit<typeof SessionInfo.infer, "
|
|
88
|
+
export type SessionInfo = Omit<typeof SessionInfo.infer, "solution" | "ports" | "match"> & {
|
|
94
89
|
shared?: boolean;
|
|
95
90
|
memory_enabled?: boolean;
|
|
96
91
|
is_persistent?: boolean;
|
|
97
92
|
is_headless?: boolean;
|
|
98
93
|
viewer_role?: "owner" | "viewer";
|
|
99
|
-
template_id?: TemplateId | null;
|
|
100
94
|
model?: string | null;
|
|
101
95
|
enable_thinking?: boolean | null;
|
|
102
96
|
solution_id?: string | null;
|
|
103
97
|
solution_ref?: PublishedSolutionRef | null;
|
|
104
98
|
biz_role_id?: string | null;
|
|
105
99
|
solution?: Solution | null;
|
|
106
|
-
primary_skill_id?: string | null;
|
|
107
|
-
bound_skill_id?: string | null;
|
|
108
100
|
replay_state?: ReplayState | null;
|
|
109
101
|
is_pinned?: boolean;
|
|
110
102
|
pinned_at?: string | null;
|
|
@@ -121,40 +113,7 @@ export type SessionInfo = Omit<typeof SessionInfo.infer, "template_id" | "soluti
|
|
|
121
113
|
/** 仅在带 q 搜索的列表响应中出现;普通列表里此字段缺省。 */
|
|
122
114
|
match?: SessionSearchMatch | null;
|
|
123
115
|
};
|
|
124
|
-
/**
|
|
125
|
-
* 主 skill 配置快照(v2)。创建 session 时从 SKILL.md frontmatter 抽出并
|
|
126
|
-
* 固化到 session_root/.blade/primary-skill.json;ship-attack 页面骨架的唯
|
|
127
|
-
* 一数据源。
|
|
128
|
-
*/
|
|
129
|
-
export interface PrimarySkillStepSpec {
|
|
130
|
-
n: number;
|
|
131
|
-
label: string;
|
|
132
|
-
}
|
|
133
|
-
export interface PrimarySkillStageSpec {
|
|
134
|
-
id: string;
|
|
135
|
-
name: string;
|
|
136
|
-
steps: PrimarySkillStepSpec[];
|
|
137
|
-
}
|
|
138
|
-
export interface PrimarySkillParallelMode {
|
|
139
|
-
id: string;
|
|
140
|
-
name: string;
|
|
141
|
-
prompt_hint: string;
|
|
142
|
-
}
|
|
143
|
-
export interface PrimarySkillSnapshot {
|
|
144
|
-
version: number;
|
|
145
|
-
skill_id: string;
|
|
146
|
-
title: string;
|
|
147
|
-
description: string;
|
|
148
|
-
stages: PrimarySkillStageSpec[];
|
|
149
|
-
parallel_modes: PrimarySkillParallelMode[];
|
|
150
|
-
captured_at: string;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* 单 session detail(GET /api/sessions/:id)。列表接口返回 SessionInfo,
|
|
154
|
-
* detail 在此基础上附加 primary_skill_snapshot。
|
|
155
|
-
*/
|
|
156
116
|
export interface SessionDetail extends SessionInfo {
|
|
157
|
-
primary_skill_snapshot?: PrimarySkillSnapshot | null;
|
|
158
117
|
preview_url?: string | null;
|
|
159
118
|
/**
|
|
160
119
|
* 会话级环境变量(owner-only)。后端仅在 GET detail 和 PUT /env 响应中返回,
|
package/dist/session/events.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export declare const nextTick: (callback: Function, ...args: any[]) => void;
|
|
|
2
2
|
export declare const globalThisShim: typeof globalThis;
|
|
3
3
|
export declare const defaultBinaryType = "nodebuffer";
|
|
4
4
|
export declare function createCookieJar(): CookieJar;
|
|
5
|
-
interface Cookie {
|
|
5
|
+
export interface Cookie {
|
|
6
6
|
name: string;
|
|
7
7
|
value: string;
|
|
8
8
|
expires?: Date;
|
|
@@ -14,8 +14,7 @@ export declare function parse(setCookieString: string): Cookie;
|
|
|
14
14
|
export declare class CookieJar {
|
|
15
15
|
private _cookies;
|
|
16
16
|
parseCookies(values: string[]): void;
|
|
17
|
-
get cookies():
|
|
17
|
+
get cookies(): MapIterator<[string, Cookie]>;
|
|
18
18
|
addCookies(xhr: any): void;
|
|
19
19
|
appendCookies(headers: Headers): void;
|
|
20
20
|
}
|
|
21
|
-
export {};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Socket } from "./socket.js";
|
|
2
2
|
export { Socket };
|
|
3
|
-
export { SocketOptions,
|
|
3
|
+
export { HandshakeData, SocketOptions, SocketReservedEvents, WriteOptions, TransportCtor, TransportName, } from "./socket.js";
|
|
4
4
|
export declare const protocol: number;
|
|
5
|
-
export { Transport, TransportError } from "./transport.js";
|
|
5
|
+
export { Transport, TransportError, TransportReservedEvents, } from "./transport.js";
|
|
6
6
|
export { transports } from "./transports/index.js";
|
|
7
7
|
export { installTimerFunctions } from "./util.js";
|
|
8
8
|
export { parse } from "./contrib/parseuri.js";
|
|
9
|
-
export { nextTick } from "./globals.node.js";
|
|
9
|
+
export { Cookie, nextTick } from "./globals.node.js";
|
|
10
10
|
export { Fetch } from "./transports/polling-fetch.js";
|
|
11
11
|
export { XHR as NodeXHR } from "./transports/polling-xhr.node.js";
|
|
12
12
|
export { XHR } from "./transports/polling-xhr.js";
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WebTransport = exports.WebSocket = exports.NodeWebSocket = exports.XHR = exports.NodeXHR = exports.Fetch = exports.nextTick = exports.parse = exports.installTimerFunctions = exports.transports = exports.TransportError = exports.Transport = exports.protocol = exports.
|
|
3
|
+
exports.WebTransport = exports.WebSocket = exports.NodeWebSocket = exports.XHR = exports.NodeXHR = exports.Fetch = exports.nextTick = exports.parse = exports.installTimerFunctions = exports.transports = exports.TransportError = exports.Transport = exports.protocol = exports.Socket = void 0;
|
|
4
4
|
const socket_js_1 = require("./socket.js");
|
|
5
5
|
Object.defineProperty(exports, "Socket", { enumerable: true, get: function () { return socket_js_1.Socket; } });
|
|
6
|
-
var socket_js_2 = require("./socket.js");
|
|
7
|
-
Object.defineProperty(exports, "SocketWithoutUpgrade", { enumerable: true, get: function () { return socket_js_2.SocketWithoutUpgrade; } });
|
|
8
|
-
Object.defineProperty(exports, "SocketWithUpgrade", { enumerable: true, get: function () { return socket_js_2.SocketWithUpgrade; } });
|
|
9
6
|
exports.protocol = socket_js_1.Socket.protocol;
|
|
10
7
|
var transport_js_1 = require("./transport.js");
|
|
11
8
|
Object.defineProperty(exports, "Transport", { enumerable: true, get: function () { return transport_js_1.Transport; } });
|
|
@@ -64,7 +64,20 @@ export interface SocketOptions {
|
|
|
64
64
|
*
|
|
65
65
|
* @default ['polling','websocket', 'webtransport']
|
|
66
66
|
*/
|
|
67
|
-
transports?:
|
|
67
|
+
transports?: TransportName[] | TransportCtor[];
|
|
68
|
+
/**
|
|
69
|
+
* A list of low-level transport implementations to use instead of the defaults.
|
|
70
|
+
*
|
|
71
|
+
* The order of the array determines the order in which transports are tried.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* import { Fetch, WebSocket } from "engine.io-client";
|
|
75
|
+
*
|
|
76
|
+
* const socket = new Socket({
|
|
77
|
+
* transportImplementations: [Fetch, WebSocket]
|
|
78
|
+
* });
|
|
79
|
+
*/
|
|
80
|
+
transportImplementations?: TransportCtor[];
|
|
68
81
|
/**
|
|
69
82
|
* Whether all the transports should be tested, instead of just the first one.
|
|
70
83
|
*
|
|
@@ -197,20 +210,18 @@ export interface SocketOptions {
|
|
|
197
210
|
*/
|
|
198
211
|
protocols?: string | string[];
|
|
199
212
|
}
|
|
200
|
-
type
|
|
213
|
+
export type TransportName = "polling" | "websocket" | "webtransport" | (string & {});
|
|
214
|
+
export type TransportCtor = {
|
|
201
215
|
new (o: any): Transport;
|
|
202
216
|
};
|
|
203
|
-
|
|
204
|
-
transports: TransportCtor[];
|
|
205
|
-
};
|
|
206
|
-
interface HandshakeData {
|
|
217
|
+
export interface HandshakeData {
|
|
207
218
|
sid: string;
|
|
208
219
|
upgrades: string[];
|
|
209
220
|
pingInterval: number;
|
|
210
221
|
pingTimeout: number;
|
|
211
222
|
maxPayload: number;
|
|
212
223
|
}
|
|
213
|
-
interface SocketReservedEvents {
|
|
224
|
+
export interface SocketReservedEvents {
|
|
214
225
|
open: () => void;
|
|
215
226
|
handshake: (data: HandshakeData) => void;
|
|
216
227
|
packet: (packet: Packet) => void;
|
|
@@ -229,43 +240,38 @@ interface SocketReservedEvents {
|
|
|
229
240
|
close: (reason: string, description?: CloseDetails | Error) => void;
|
|
230
241
|
}
|
|
231
242
|
type SocketState = "opening" | "open" | "closing" | "closed";
|
|
232
|
-
interface WriteOptions {
|
|
243
|
+
export interface WriteOptions {
|
|
233
244
|
compress?: boolean;
|
|
234
245
|
}
|
|
235
246
|
/**
|
|
236
247
|
* This class provides a WebSocket-like interface to connect to an Engine.IO server. The connection will be established
|
|
237
|
-
* with one of the available low-level transports, like HTTP long-polling, WebSocket or WebTransport.
|
|
248
|
+
* with one of the available low-level transports, like HTTP long-polling, WebSocket, or WebTransport.
|
|
238
249
|
*
|
|
239
|
-
* This class comes
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
* In order to allow tree-shaking, there are no transports included, that's why the `transports` option is mandatory.
|
|
250
|
+
* This class comes with an upgrade mechanism, which means that once the connection is established with the first
|
|
251
|
+
* low-level transport, it will try to upgrade to a better transport.
|
|
243
252
|
*
|
|
244
253
|
* @example
|
|
245
|
-
* import {
|
|
254
|
+
* import { Socket } from "engine.io-client";
|
|
246
255
|
*
|
|
247
|
-
* const socket = new
|
|
248
|
-
* transports: [WebSocket]
|
|
249
|
-
* });
|
|
256
|
+
* const socket = new Socket();
|
|
250
257
|
*
|
|
251
258
|
* socket.on("open", () => {
|
|
252
259
|
* socket.send("hello");
|
|
253
260
|
* });
|
|
254
261
|
*
|
|
255
|
-
* @see SocketWithUpgrade
|
|
256
|
-
* @see Socket
|
|
257
262
|
*/
|
|
258
|
-
export declare class
|
|
263
|
+
export declare class Socket extends Emitter<Record<never, never>, Record<never, never>, SocketReservedEvents> {
|
|
259
264
|
id: string;
|
|
260
265
|
transport: Transport;
|
|
261
266
|
binaryType: BinaryType;
|
|
262
267
|
readyState: SocketState;
|
|
263
268
|
writeBuffer: Packet[];
|
|
264
|
-
protected readonly opts:
|
|
265
|
-
protected readonly transports:
|
|
269
|
+
protected readonly opts: SocketOptions;
|
|
270
|
+
protected readonly transports: TransportName[];
|
|
266
271
|
protected upgrading: boolean;
|
|
267
272
|
protected setTimeoutFn: typeof setTimeout;
|
|
268
273
|
private _prevBufferLen;
|
|
274
|
+
private _upgrades;
|
|
269
275
|
private _pingInterval;
|
|
270
276
|
private _pingTimeout;
|
|
271
277
|
private _maxPayload?;
|
|
@@ -294,7 +300,9 @@ export declare class SocketWithoutUpgrade extends Emitter<Record<never, never>,
|
|
|
294
300
|
* @param {String|Object} uri - uri or options
|
|
295
301
|
* @param {Object} opts - options
|
|
296
302
|
*/
|
|
297
|
-
constructor(
|
|
303
|
+
constructor();
|
|
304
|
+
constructor(uri: string, opts?: SocketOptions);
|
|
305
|
+
constructor(opts: SocketOptions);
|
|
298
306
|
/**
|
|
299
307
|
* Creates transport of the given type.
|
|
300
308
|
*
|
|
@@ -315,6 +323,13 @@ export declare class SocketWithoutUpgrade extends Emitter<Record<never, never>,
|
|
|
315
323
|
* @private
|
|
316
324
|
*/
|
|
317
325
|
protected setTransport(transport: Transport): void;
|
|
326
|
+
/**
|
|
327
|
+
* Probes a transport.
|
|
328
|
+
*
|
|
329
|
+
* @param {String} name - transport name
|
|
330
|
+
* @private
|
|
331
|
+
*/
|
|
332
|
+
private _probe;
|
|
318
333
|
/**
|
|
319
334
|
* Called when connection is deemed open.
|
|
320
335
|
*
|
|
@@ -390,7 +405,7 @@ export declare class SocketWithoutUpgrade extends Emitter<Record<never, never>,
|
|
|
390
405
|
/**
|
|
391
406
|
* Sends a packet.
|
|
392
407
|
*
|
|
393
|
-
* @param {String} type
|
|
408
|
+
* @param {String} type - packet type.
|
|
394
409
|
* @param {String} data.
|
|
395
410
|
* @param {Object} options.
|
|
396
411
|
* @param {Function} fn - callback function.
|
|
@@ -413,41 +428,6 @@ export declare class SocketWithoutUpgrade extends Emitter<Record<never, never>,
|
|
|
413
428
|
* @private
|
|
414
429
|
*/
|
|
415
430
|
private _onClose;
|
|
416
|
-
}
|
|
417
|
-
/**
|
|
418
|
-
* This class provides a WebSocket-like interface to connect to an Engine.IO server. The connection will be established
|
|
419
|
-
* with one of the available low-level transports, like HTTP long-polling, WebSocket or WebTransport.
|
|
420
|
-
*
|
|
421
|
-
* This class comes with an upgrade mechanism, which means that once the connection is established with the first
|
|
422
|
-
* low-level transport, it will try to upgrade to a better transport.
|
|
423
|
-
*
|
|
424
|
-
* In order to allow tree-shaking, there are no transports included, that's why the `transports` option is mandatory.
|
|
425
|
-
*
|
|
426
|
-
* @example
|
|
427
|
-
* import { SocketWithUpgrade, WebSocket } from "engine.io-client";
|
|
428
|
-
*
|
|
429
|
-
* const socket = new SocketWithUpgrade({
|
|
430
|
-
* transports: [WebSocket]
|
|
431
|
-
* });
|
|
432
|
-
*
|
|
433
|
-
* socket.on("open", () => {
|
|
434
|
-
* socket.send("hello");
|
|
435
|
-
* });
|
|
436
|
-
*
|
|
437
|
-
* @see SocketWithoutUpgrade
|
|
438
|
-
* @see Socket
|
|
439
|
-
*/
|
|
440
|
-
export declare class SocketWithUpgrade extends SocketWithoutUpgrade {
|
|
441
|
-
private _upgrades;
|
|
442
|
-
onOpen(): void;
|
|
443
|
-
/**
|
|
444
|
-
* Probes a transport.
|
|
445
|
-
*
|
|
446
|
-
* @param {String} name - transport name
|
|
447
|
-
* @private
|
|
448
|
-
*/
|
|
449
|
-
private _probe;
|
|
450
|
-
onHandshake(data: HandshakeData): void;
|
|
451
431
|
/**
|
|
452
432
|
* Filters upgrades, returning only those matching client transports.
|
|
453
433
|
*
|
|
@@ -456,27 +436,4 @@ export declare class SocketWithUpgrade extends SocketWithoutUpgrade {
|
|
|
456
436
|
*/
|
|
457
437
|
private _filterUpgrades;
|
|
458
438
|
}
|
|
459
|
-
/**
|
|
460
|
-
* This class provides a WebSocket-like interface to connect to an Engine.IO server. The connection will be established
|
|
461
|
-
* with one of the available low-level transports, like HTTP long-polling, WebSocket or WebTransport.
|
|
462
|
-
*
|
|
463
|
-
* This class comes with an upgrade mechanism, which means that once the connection is established with the first
|
|
464
|
-
* low-level transport, it will try to upgrade to a better transport.
|
|
465
|
-
*
|
|
466
|
-
* @example
|
|
467
|
-
* import { Socket } from "engine.io-client";
|
|
468
|
-
*
|
|
469
|
-
* const socket = new Socket();
|
|
470
|
-
*
|
|
471
|
-
* socket.on("open", () => {
|
|
472
|
-
* socket.send("hello");
|
|
473
|
-
* });
|
|
474
|
-
*
|
|
475
|
-
* @see SocketWithoutUpgrade
|
|
476
|
-
* @see SocketWithUpgrade
|
|
477
|
-
*/
|
|
478
|
-
export declare class Socket extends SocketWithUpgrade {
|
|
479
|
-
constructor(uri?: string, opts?: SocketOptions);
|
|
480
|
-
constructor(opts: SocketOptions);
|
|
481
|
-
}
|
|
482
439
|
export {};
|