@jean2/sdk 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +34 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +102 -0
- package/dist/client.js.map +1 -0
- package/dist/emitter.d.ts +12 -0
- package/dist/emitter.d.ts.map +1 -0
- package/dist/emitter.js +59 -0
- package/dist/emitter.js.map +1 -0
- package/dist/errors.d.ts +25 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +49 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/namespaces/chat.d.ts +12 -0
- package/dist/namespaces/chat.d.ts.map +1 -0
- package/dist/namespaces/chat.js +18 -0
- package/dist/namespaces/chat.js.map +1 -0
- package/dist/namespaces/permissions.d.ts +26 -0
- package/dist/namespaces/permissions.d.ts.map +1 -0
- package/dist/namespaces/permissions.js +33 -0
- package/dist/namespaces/permissions.js.map +1 -0
- package/dist/namespaces/providers.d.ts +8 -0
- package/dist/namespaces/providers.d.ts.map +1 -0
- package/dist/namespaces/providers.js +13 -0
- package/dist/namespaces/providers.js.map +1 -0
- package/dist/namespaces/queue.d.ts +11 -0
- package/dist/namespaces/queue.d.ts.map +1 -0
- package/dist/namespaces/queue.js +19 -0
- package/dist/namespaces/queue.js.map +1 -0
- package/dist/namespaces/sessions.d.ts +28 -0
- package/dist/namespaces/sessions.d.ts.map +1 -0
- package/dist/namespaces/sessions.js +43 -0
- package/dist/namespaces/sessions.js.map +1 -0
- package/dist/namespaces/terminal.d.ts +100 -0
- package/dist/namespaces/terminal.d.ts.map +1 -0
- package/dist/namespaces/terminal.js +495 -0
- package/dist/namespaces/terminal.js.map +1 -0
- package/dist/rest/attachments.d.ts +40 -0
- package/dist/rest/attachments.d.ts.map +1 -0
- package/dist/rest/attachments.js +40 -0
- package/dist/rest/attachments.js.map +1 -0
- package/dist/rest/config.d.ts +88 -0
- package/dist/rest/config.d.ts.map +1 -0
- package/dist/rest/config.js +83 -0
- package/dist/rest/config.js.map +1 -0
- package/dist/rest/files.d.ts +37 -0
- package/dist/rest/files.d.ts.map +1 -0
- package/dist/rest/files.js +59 -0
- package/dist/rest/files.js.map +1 -0
- package/dist/rest/http-namespace.d.ts +54 -0
- package/dist/rest/http-namespace.d.ts.map +1 -0
- package/dist/rest/http-namespace.js +67 -0
- package/dist/rest/http-namespace.js.map +1 -0
- package/dist/rest/mcp.d.ts +43 -0
- package/dist/rest/mcp.d.ts.map +1 -0
- package/dist/rest/mcp.js +41 -0
- package/dist/rest/mcp.js.map +1 -0
- package/dist/rest/models.d.ts +12 -0
- package/dist/rest/models.d.ts.map +1 -0
- package/dist/rest/models.js +10 -0
- package/dist/rest/models.js.map +1 -0
- package/dist/rest/preconfigs.d.ts +51 -0
- package/dist/rest/preconfigs.d.ts.map +1 -0
- package/dist/rest/preconfigs.js +29 -0
- package/dist/rest/preconfigs.js.map +1 -0
- package/dist/rest/prompts.d.ts +12 -0
- package/dist/rest/prompts.d.ts.map +1 -0
- package/dist/rest/prompts.js +10 -0
- package/dist/rest/prompts.js.map +1 -0
- package/dist/rest/providers.d.ts +56 -0
- package/dist/rest/providers.d.ts.map +1 -0
- package/dist/rest/providers.js +59 -0
- package/dist/rest/providers.js.map +1 -0
- package/dist/rest/sessions.d.ts +54 -0
- package/dist/rest/sessions.d.ts.map +1 -0
- package/dist/rest/sessions.js +47 -0
- package/dist/rest/sessions.js.map +1 -0
- package/dist/rest/terminals.d.ts +28 -0
- package/dist/rest/terminals.d.ts.map +1 -0
- package/dist/rest/terminals.js +22 -0
- package/dist/rest/terminals.js.map +1 -0
- package/dist/rest/tools.d.ts +34 -0
- package/dist/rest/tools.d.ts.map +1 -0
- package/dist/rest/tools.js +37 -0
- package/dist/rest/tools.js.map +1 -0
- package/dist/rest/workspaces.d.ts +28 -0
- package/dist/rest/workspaces.d.ts.map +1 -0
- package/dist/rest/workspaces.js +34 -0
- package/dist/rest/workspaces.js.map +1 -0
- package/dist/shared-protocol/client.d.ts +148 -0
- package/dist/shared-protocol/client.d.ts.map +1 -0
- package/dist/shared-protocol/client.js +4 -0
- package/dist/shared-protocol/client.js.map +1 -0
- package/dist/shared-protocol/index.d.ts +4 -0
- package/dist/shared-protocol/index.d.ts.map +1 -0
- package/dist/shared-protocol/index.js +4 -0
- package/dist/shared-protocol/index.js.map +1 -0
- package/dist/shared-protocol/server.d.ts +233 -0
- package/dist/shared-protocol/server.d.ts.map +1 -0
- package/dist/shared-protocol/server.js +2 -0
- package/dist/shared-protocol/server.js.map +1 -0
- package/dist/shared-protocol/terminal.d.ts +55 -0
- package/dist/shared-protocol/terminal.d.ts.map +1 -0
- package/dist/shared-protocol/terminal.js +2 -0
- package/dist/shared-protocol/terminal.js.map +1 -0
- package/dist/shared-types/configuration.d.ts +100 -0
- package/dist/shared-types/configuration.d.ts.map +1 -0
- package/dist/shared-types/configuration.js +2 -0
- package/dist/shared-types/configuration.js.map +1 -0
- package/dist/shared-types/file.d.ts +47 -0
- package/dist/shared-types/file.d.ts.map +1 -0
- package/dist/shared-types/file.js +2 -0
- package/dist/shared-types/file.js.map +1 -0
- package/dist/shared-types/index.d.ts +20 -0
- package/dist/shared-types/index.d.ts.map +1 -0
- package/dist/shared-types/index.js +20 -0
- package/dist/shared-types/index.js.map +1 -0
- package/dist/shared-types/interrupt.d.ts +25 -0
- package/dist/shared-types/interrupt.d.ts.map +1 -0
- package/dist/shared-types/interrupt.js +2 -0
- package/dist/shared-types/interrupt.js.map +1 -0
- package/dist/shared-types/mcp.d.ts +49 -0
- package/dist/shared-types/mcp.d.ts.map +1 -0
- package/dist/shared-types/mcp.js +6 -0
- package/dist/shared-types/mcp.js.map +1 -0
- package/dist/shared-types/message.d.ts +166 -0
- package/dist/shared-types/message.d.ts.map +1 -0
- package/dist/shared-types/message.js +34 -0
- package/dist/shared-types/message.js.map +1 -0
- package/dist/shared-types/model.d.ts +60 -0
- package/dist/shared-types/model.d.ts.map +1 -0
- package/dist/shared-types/model.js +2 -0
- package/dist/shared-types/model.js.map +1 -0
- package/dist/shared-types/permission.d.ts +209 -0
- package/dist/shared-types/permission.d.ts.map +1 -0
- package/dist/shared-types/permission.js +787 -0
- package/dist/shared-types/permission.js.map +1 -0
- package/dist/shared-types/preconfig.d.ts +31 -0
- package/dist/shared-types/preconfig.d.ts.map +1 -0
- package/dist/shared-types/preconfig.js +2 -0
- package/dist/shared-types/preconfig.js.map +1 -0
- package/dist/shared-types/prompt.d.ts +6 -0
- package/dist/shared-types/prompt.d.ts.map +1 -0
- package/dist/shared-types/prompt.js +2 -0
- package/dist/shared-types/prompt.js.map +1 -0
- package/dist/shared-types/provider.d.ts +31 -0
- package/dist/shared-types/provider.d.ts.map +1 -0
- package/dist/shared-types/provider.js +2 -0
- package/dist/shared-types/provider.js.map +1 -0
- package/dist/shared-types/runtime.d.ts +27 -0
- package/dist/shared-types/runtime.d.ts.map +1 -0
- package/dist/shared-types/runtime.js +2 -0
- package/dist/shared-types/runtime.js.map +1 -0
- package/dist/shared-types/server.d.ts +16 -0
- package/dist/shared-types/server.d.ts.map +1 -0
- package/dist/shared-types/server.js +2 -0
- package/dist/shared-types/server.js.map +1 -0
- package/dist/shared-types/session.d.ts +24 -0
- package/dist/shared-types/session.d.ts.map +1 -0
- package/dist/shared-types/session.js +2 -0
- package/dist/shared-types/session.js.map +1 -0
- package/dist/shared-types/skill.d.ts +24 -0
- package/dist/shared-types/skill.d.ts.map +1 -0
- package/dist/shared-types/skill.js +2 -0
- package/dist/shared-types/skill.js.map +1 -0
- package/dist/shared-types/task.d.ts +45 -0
- package/dist/shared-types/task.d.ts.map +1 -0
- package/dist/shared-types/task.js +2 -0
- package/dist/shared-types/task.js.map +1 -0
- package/dist/shared-types/tool.d.ts +250 -0
- package/dist/shared-types/tool.d.ts.map +1 -0
- package/dist/shared-types/tool.js +3 -0
- package/dist/shared-types/tool.js.map +1 -0
- package/dist/shared-types/ui.d.ts +35 -0
- package/dist/shared-types/ui.d.ts.map +1 -0
- package/dist/shared-types/ui.js +52 -0
- package/dist/shared-types/ui.js.map +1 -0
- package/dist/shared-types/visualization.d.ts +208 -0
- package/dist/shared-types/visualization.d.ts.map +1 -0
- package/dist/shared-types/visualization.js +2 -0
- package/dist/shared-types/visualization.js.map +1 -0
- package/dist/shared-types/workspace.d.ts +9 -0
- package/dist/shared-types/workspace.d.ts.map +1 -0
- package/dist/shared-types/workspace.js +2 -0
- package/dist/shared-types/workspace.js.map +1 -0
- package/dist/shared-utils/index.d.ts +2 -0
- package/dist/shared-utils/index.d.ts.map +1 -0
- package/dist/shared-utils/index.js +2 -0
- package/dist/shared-utils/index.js.map +1 -0
- package/dist/shared-utils/model-context.d.ts +15 -0
- package/dist/shared-utils/model-context.d.ts.map +1 -0
- package/dist/shared-utils/model-context.js +22 -0
- package/dist/shared-utils/model-context.js.map +1 -0
- package/dist/shared.d.ts +4 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +4 -0
- package/dist/shared.js.map +1 -0
- package/dist/transport/http.d.ts +37 -0
- package/dist/transport/http.d.ts.map +1 -0
- package/dist/transport/http.js +75 -0
- package/dist/transport/http.js.map +1 -0
- package/dist/transport/websocket.d.ts +33 -0
- package/dist/transport/websocket.d.ts.map +1 -0
- package/dist/transport/websocket.js +145 -0
- package/dist/transport/websocket.js.map +1 -0
- package/dist/types/index.d.ts +22 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/rest-responses.d.ts +389 -0
- package/dist/types/rest-responses.d.ts.map +1 -0
- package/dist/types/rest-responses.js +2 -0
- package/dist/types/rest-responses.js.map +1 -0
- package/dist/types/sdk-types.d.ts +32 -0
- package/dist/types/sdk-types.d.ts.map +1 -0
- package/dist/types/sdk-types.js +2 -0
- package/dist/types/sdk-types.js.map +1 -0
- package/dist/types/server-messages.d.ts +132 -0
- package/dist/types/server-messages.d.ts.map +1 -0
- package/dist/types/server-messages.js +135 -0
- package/dist/types/server-messages.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/package.json +31 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types and constants for UI components
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Panel dimension constraints
|
|
6
|
+
* Used by resizable side panels (sessions, files, etc.)
|
|
7
|
+
*/
|
|
8
|
+
export declare const PANEL_MIN_WIDTH = 220;
|
|
9
|
+
export declare const PANEL_DEFAULT_WIDTH = 256;
|
|
10
|
+
export declare const PANEL_MAX_WIDTH = 512;
|
|
11
|
+
/**
|
|
12
|
+
* Validates and clamps a panel width to valid bounds
|
|
13
|
+
*/
|
|
14
|
+
export declare function clampPanelWidth(width: number): number;
|
|
15
|
+
/**
|
|
16
|
+
* Storage keys for panel state persistence
|
|
17
|
+
*/
|
|
18
|
+
export declare const PANEL_STORAGE_KEYS: {
|
|
19
|
+
readonly SESSIONS: "jean2_sessions_panel_width";
|
|
20
|
+
readonly FILES: "jean2_files_panel_width";
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Saved panel state shape
|
|
24
|
+
*/
|
|
25
|
+
export interface SavedPanelWidth {
|
|
26
|
+
width: number;
|
|
27
|
+
}
|
|
28
|
+
export declare const DRAFT_KEY_PREFIX = "jean2_draft_";
|
|
29
|
+
export declare const DRAFT_TTL_MS: number;
|
|
30
|
+
export interface SavedDraft {
|
|
31
|
+
text: string;
|
|
32
|
+
updatedAt: number;
|
|
33
|
+
}
|
|
34
|
+
export declare function cleanupExpiredDrafts(): void;
|
|
35
|
+
//# sourceMappingURL=ui.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/shared-types/ui.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,eAAO,MAAM,eAAe,MAAM,CAAC;AACnC,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;CAGrB,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAC/C,eAAO,MAAM,YAAY,QAA2B,CAAC;AAErD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,oBAAoB,IAAI,IAAI,CAyB3C"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types and constants for UI components
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Panel dimension constraints
|
|
6
|
+
* Used by resizable side panels (sessions, files, etc.)
|
|
7
|
+
*/
|
|
8
|
+
export const PANEL_MIN_WIDTH = 220;
|
|
9
|
+
export const PANEL_DEFAULT_WIDTH = 256;
|
|
10
|
+
export const PANEL_MAX_WIDTH = 512;
|
|
11
|
+
/**
|
|
12
|
+
* Validates and clamps a panel width to valid bounds
|
|
13
|
+
*/
|
|
14
|
+
export function clampPanelWidth(width) {
|
|
15
|
+
return Math.max(PANEL_MIN_WIDTH, Math.min(PANEL_MAX_WIDTH, width));
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Storage keys for panel state persistence
|
|
19
|
+
*/
|
|
20
|
+
export const PANEL_STORAGE_KEYS = {
|
|
21
|
+
SESSIONS: 'jean2_sessions_panel_width',
|
|
22
|
+
FILES: 'jean2_files_panel_width',
|
|
23
|
+
};
|
|
24
|
+
export const DRAFT_KEY_PREFIX = 'jean2_draft_';
|
|
25
|
+
export const DRAFT_TTL_MS = 30 * 24 * 60 * 60 * 1000;
|
|
26
|
+
export function cleanupExpiredDrafts() {
|
|
27
|
+
try {
|
|
28
|
+
for (let i = 0; i < localStorage.length; i++) {
|
|
29
|
+
const key = localStorage.key(i);
|
|
30
|
+
if (!key || !key.startsWith(DRAFT_KEY_PREFIX)) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const value = localStorage.getItem(key);
|
|
35
|
+
if (!value) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const draft = JSON.parse(value);
|
|
39
|
+
if (Date.now() - draft.updatedAt > DRAFT_TTL_MS) {
|
|
40
|
+
localStorage.removeItem(key);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
localStorage.removeItem(key);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// localStorage not available
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/shared-types/ui.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAC;AACnC,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AACvC,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAC;AAEnC;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa;IAC3C,OAAO,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC,CAAC;AACrE,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,QAAQ,EAAE,4BAA4B;IACtC,KAAK,EAAE,yBAAyB;CACxB,CAAC;AASX,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAC/C,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAOrD,MAAM,UAAU,oBAAoB;IAClC,IAAI,CAAC;QACH,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7C,MAAM,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAChC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE,CAAC;gBAC9C,SAAS;YACX,CAAC;YAED,IAAI,CAAC;gBACH,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;gBACxC,IAAI,CAAC,KAAK,EAAE,CAAC;oBACX,SAAS;gBACX,CAAC;gBAED,MAAM,KAAK,GAAe,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBAC5C,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,SAAS,GAAG,YAAY,EAAE,CAAC;oBAChD,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;gBAC/B,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,6BAA6B;IAC/B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported visualization types for tool outputs.
|
|
3
|
+
*/
|
|
4
|
+
export type VisualizationType = 'diff' | 'diffs' | 'code' | 'table' | 'file-list' | 'markdown' | 'shell-output' | 'none' | 'todo-list';
|
|
5
|
+
/**
|
|
6
|
+
* Base interface for all visualization types embedded in tool output.
|
|
7
|
+
*/
|
|
8
|
+
export interface ToolVisualization {
|
|
9
|
+
type: VisualizationType;
|
|
10
|
+
title?: string;
|
|
11
|
+
collapsed?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Visualization for git diff output showing file changes.
|
|
15
|
+
*/
|
|
16
|
+
export interface DiffVisualization extends ToolVisualization {
|
|
17
|
+
type: 'diff';
|
|
18
|
+
/** The file path that was modified */
|
|
19
|
+
path: string;
|
|
20
|
+
/** Language for syntax highlighting (e.g., 'typescript', 'python') */
|
|
21
|
+
language?: string;
|
|
22
|
+
/** Pre-computed diff hunks with context lines */
|
|
23
|
+
hunks: DiffHunk[];
|
|
24
|
+
/** Count of added lines */
|
|
25
|
+
additions: number;
|
|
26
|
+
/** Count of removed lines */
|
|
27
|
+
deletions: number;
|
|
28
|
+
/** Information about the match strategy used to find the diff location */
|
|
29
|
+
matchInfo?: {
|
|
30
|
+
strategy: string;
|
|
31
|
+
lineNumber: number;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A contiguous section of changes in a diff.
|
|
36
|
+
*/
|
|
37
|
+
export interface DiffHunk {
|
|
38
|
+
/** Starting line number in the old file */
|
|
39
|
+
oldStart: number;
|
|
40
|
+
/** Number of lines in the old file for this hunk */
|
|
41
|
+
oldLines: number;
|
|
42
|
+
/** Starting line number in the new file */
|
|
43
|
+
newStart: number;
|
|
44
|
+
/** Number of lines in the new file for this hunk */
|
|
45
|
+
newLines: number;
|
|
46
|
+
/** Individual line changes in this hunk */
|
|
47
|
+
changes: DiffChange[];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A single line change in a diff hunk.
|
|
51
|
+
*/
|
|
52
|
+
export interface DiffChange {
|
|
53
|
+
/** Type of change */
|
|
54
|
+
type: 'added' | 'removed' | 'context';
|
|
55
|
+
/** The content of the line */
|
|
56
|
+
content: string;
|
|
57
|
+
/** Line number in the old file (undefined for new lines) */
|
|
58
|
+
oldLineNumber?: number;
|
|
59
|
+
/** Line number in the new file (undefined for removed lines) */
|
|
60
|
+
newLineNumber?: number;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Visualization for multiple diff outputs (e.g., multiedit tool).
|
|
64
|
+
*/
|
|
65
|
+
export interface DiffsVisualization extends ToolVisualization {
|
|
66
|
+
type: 'diffs';
|
|
67
|
+
/** Array of diff visualizations */
|
|
68
|
+
items: DiffVisualization[];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Visualization for displaying full file content.
|
|
72
|
+
*/
|
|
73
|
+
export interface CodeVisualization extends ToolVisualization {
|
|
74
|
+
type: 'code';
|
|
75
|
+
/** The file path */
|
|
76
|
+
path: string;
|
|
77
|
+
/** Full file content for display */
|
|
78
|
+
content: string;
|
|
79
|
+
/** Language for syntax highlighting */
|
|
80
|
+
language?: string;
|
|
81
|
+
/** Whether the file was newly created (true) or overwrote existing (false) */
|
|
82
|
+
created: boolean;
|
|
83
|
+
/** Specific line numbers to highlight */
|
|
84
|
+
highlightLines?: number[];
|
|
85
|
+
/** Total number of lines in the file */
|
|
86
|
+
lineCount?: number;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Visualization for displaying a list of files with optional grouping.
|
|
90
|
+
*/
|
|
91
|
+
export interface FileListVisualization extends ToolVisualization {
|
|
92
|
+
type: 'file-list';
|
|
93
|
+
/** Grouped files with labels and icons */
|
|
94
|
+
groups?: Array<{
|
|
95
|
+
label: string;
|
|
96
|
+
files: FileListItem[];
|
|
97
|
+
icon: 'edit' | 'plus' | 'trash' | 'search';
|
|
98
|
+
}>;
|
|
99
|
+
/** Flat list of files (alternative to groups) */
|
|
100
|
+
files?: FileListItem[];
|
|
101
|
+
/** Total number of files */
|
|
102
|
+
total?: number;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Individual file item in a file list.
|
|
106
|
+
*/
|
|
107
|
+
export interface FileListItem {
|
|
108
|
+
/** File path */
|
|
109
|
+
path: string;
|
|
110
|
+
/** Action performed on the file */
|
|
111
|
+
action?: 'created' | 'modified' | 'deleted';
|
|
112
|
+
/** Optional line number reference */
|
|
113
|
+
line?: number;
|
|
114
|
+
/** Optional content preview */
|
|
115
|
+
content?: string;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Visualization for tabular data display.
|
|
119
|
+
*/
|
|
120
|
+
export interface TableVisualization extends ToolVisualization {
|
|
121
|
+
type: 'table';
|
|
122
|
+
/** Column definitions */
|
|
123
|
+
columns: TableColumn[];
|
|
124
|
+
/** Row data as key-value records */
|
|
125
|
+
rows: Record<string, unknown>[];
|
|
126
|
+
/** Total number of rows (for pagination) */
|
|
127
|
+
totalRows?: number;
|
|
128
|
+
/** Whether there are more rows beyond current display */
|
|
129
|
+
hasMore?: boolean;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Column definition for table visualization.
|
|
133
|
+
*/
|
|
134
|
+
export interface TableColumn {
|
|
135
|
+
/** Key name matching row data */
|
|
136
|
+
key: string;
|
|
137
|
+
/** Display label for the column */
|
|
138
|
+
label?: string;
|
|
139
|
+
/** Optional width specification */
|
|
140
|
+
width?: string;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Visualization for markdown/rendered content.
|
|
144
|
+
*/
|
|
145
|
+
export interface MarkdownVisualization extends ToolVisualization {
|
|
146
|
+
type: 'markdown';
|
|
147
|
+
/** Markdown content to render */
|
|
148
|
+
content: string;
|
|
149
|
+
/** Optional source URL for the content */
|
|
150
|
+
sourceUrl?: string;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Visualization for displaying shell/terminal command output.
|
|
154
|
+
*/
|
|
155
|
+
export interface ShellOutputVisualization extends ToolVisualization {
|
|
156
|
+
type: 'shell-output';
|
|
157
|
+
/** The command that was executed */
|
|
158
|
+
command: string;
|
|
159
|
+
/** Standard output from the command */
|
|
160
|
+
stdout?: string;
|
|
161
|
+
/** Standard error from the command */
|
|
162
|
+
stderr?: string;
|
|
163
|
+
/** Exit code from the command */
|
|
164
|
+
exitCode: number;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Visualization indicating no content to display.
|
|
168
|
+
*/
|
|
169
|
+
export interface NoneVisualization extends ToolVisualization {
|
|
170
|
+
type: 'none';
|
|
171
|
+
/** Optional message explaining why there's no visualization */
|
|
172
|
+
message?: string;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Visualization for displaying a todo/checklist with status indicators.
|
|
176
|
+
*/
|
|
177
|
+
export interface TodoListVisualization extends ToolVisualization {
|
|
178
|
+
type: 'todo-list';
|
|
179
|
+
/** List of todo items */
|
|
180
|
+
items: TodoListItem[];
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Individual todo item in a todo list visualization.
|
|
184
|
+
*/
|
|
185
|
+
export interface TodoListItem {
|
|
186
|
+
/** The task content/description */
|
|
187
|
+
content: string;
|
|
188
|
+
/** Status: pending, in_progress, completed, cancelled */
|
|
189
|
+
status: 'pending' | 'in_progress' | 'completed' | 'cancelled';
|
|
190
|
+
/** Priority: high, medium, low */
|
|
191
|
+
priority: 'high' | 'medium' | 'low';
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Union of all possible visualization types.
|
|
195
|
+
*/
|
|
196
|
+
export type AnyVisualization = DiffVisualization | DiffsVisualization | CodeVisualization | FileListVisualization | TableVisualization | MarkdownVisualization | ShellOutputVisualization | NoneVisualization | TodoListVisualization;
|
|
197
|
+
/**
|
|
198
|
+
* Tool output pattern that includes optional visualization data.
|
|
199
|
+
* The _visualization field is stored in the database but filtered
|
|
200
|
+
* out before passing tool results to the LLM to avoid token bloat.
|
|
201
|
+
*/
|
|
202
|
+
export interface VisualizableToolOutput {
|
|
203
|
+
success: boolean;
|
|
204
|
+
error?: string;
|
|
205
|
+
/** Visualization data - stripped before LLM consumption */
|
|
206
|
+
_visualization?: AnyVisualization;
|
|
207
|
+
}
|
|
208
|
+
//# sourceMappingURL=visualization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visualization.d.ts","sourceRoot":"","sources":["../../src/shared-types/visualization.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,WAAW,GAAG,UAAU,GAAG,cAAc,GAAG,MAAM,GAAG,WAAW,CAAC;AAEvI;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,iBAAiB,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,2BAA2B;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,SAAS,CAAC,EAAE;QACV,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,OAAO,EAAE,UAAU,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,MAAM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,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,iBAAiB;IAC9D,IAAI,EAAE,WAAW,CAAC;IAClB,yBAAyB;IACzB,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,yDAAyD;IACzD,MAAM,EAAE,SAAS,GAAG,aAAa,GAAG,WAAW,GAAG,WAAW,CAAC;IAC9D,kCAAkC;IAClC,QAAQ,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB,iBAAiB,GACjB,kBAAkB,GAClB,iBAAiB,GACjB,qBAAqB,GACrB,kBAAkB,GAClB,qBAAqB,GACrB,wBAAwB,GACxB,iBAAiB,GACjB,qBAAqB,CAAC;AAE1B;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,cAAc,CAAC,EAAE,gBAAgB,CAAC;CACnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visualization.js","sourceRoot":"","sources":["../../src/shared-types/visualization.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/shared-types/workspace.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../src/shared-types/workspace.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared-utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shared-utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the context window size for a model
|
|
3
|
+
* This is a fallback function - prefer using contextWindow from the server's models config
|
|
4
|
+
* @param modelId - The model identifier (unused, kept for API compatibility)
|
|
5
|
+
* @returns Always returns 0 to indicate unknown context window
|
|
6
|
+
*/
|
|
7
|
+
export declare function getModelContextWindow(_modelId: string): number;
|
|
8
|
+
/**
|
|
9
|
+
* Calculate the percentage of context window used
|
|
10
|
+
* @param tokensUsed - Number of tokens used
|
|
11
|
+
* @param modelId - The model identifier (unused, kept for API compatibility)
|
|
12
|
+
* @returns Percentage (0-100) of context window used, or 0 if context window is unknown
|
|
13
|
+
*/
|
|
14
|
+
export declare function getContextWindowPercentage(_tokensUsed: number, _modelId: string): number;
|
|
15
|
+
//# sourceMappingURL=model-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-context.d.ts","sourceRoot":"","sources":["../../src/shared-utils/model-context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAI9D;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGxF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the context window size for a model
|
|
3
|
+
* This is a fallback function - prefer using contextWindow from the server's models config
|
|
4
|
+
* @param modelId - The model identifier (unused, kept for API compatibility)
|
|
5
|
+
* @returns Always returns 0 to indicate unknown context window
|
|
6
|
+
*/
|
|
7
|
+
export function getModelContextWindow(_modelId) {
|
|
8
|
+
// Context window should come from the server's models.json config
|
|
9
|
+
// This fallback returns 0 to indicate the context window is unknown
|
|
10
|
+
return 0;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Calculate the percentage of context window used
|
|
14
|
+
* @param tokensUsed - Number of tokens used
|
|
15
|
+
* @param modelId - The model identifier (unused, kept for API compatibility)
|
|
16
|
+
* @returns Percentage (0-100) of context window used, or 0 if context window is unknown
|
|
17
|
+
*/
|
|
18
|
+
export function getContextWindowPercentage(_tokensUsed, _modelId) {
|
|
19
|
+
// With no context window info, we can't calculate percentage
|
|
20
|
+
return 0;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=model-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-context.js","sourceRoot":"","sources":["../../src/shared-utils/model-context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAgB;IACpD,kEAAkE;IAClE,oEAAoE;IACpE,OAAO,CAAC,CAAC;AACX,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CAAC,WAAmB,EAAE,QAAgB;IAC9E,6DAA6D;IAC7D,OAAO,CAAC,CAAC;AACX,CAAC"}
|
package/dist/shared.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC"}
|
package/dist/shared.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface HttpClientConfig {
|
|
2
|
+
url: string;
|
|
3
|
+
token: string;
|
|
4
|
+
apiBase?: string;
|
|
5
|
+
}
|
|
6
|
+
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
7
|
+
interface RequestOptions {
|
|
8
|
+
method?: HttpMethod;
|
|
9
|
+
body?: unknown;
|
|
10
|
+
headers?: Record<string, string>;
|
|
11
|
+
signal?: AbortSignal;
|
|
12
|
+
params?: Record<string, string>;
|
|
13
|
+
}
|
|
14
|
+
export declare class HttpClient {
|
|
15
|
+
private baseUrl;
|
|
16
|
+
private token;
|
|
17
|
+
constructor(config: HttpClientConfig);
|
|
18
|
+
request<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
19
|
+
get<T>(path: string, options?: {
|
|
20
|
+
params?: Record<string, string>;
|
|
21
|
+
signal?: AbortSignal;
|
|
22
|
+
}): Promise<T>;
|
|
23
|
+
post<T>(path: string, body?: unknown, options?: {
|
|
24
|
+
signal?: AbortSignal;
|
|
25
|
+
}): Promise<T>;
|
|
26
|
+
put<T>(path: string, body?: unknown, options?: {
|
|
27
|
+
signal?: AbortSignal;
|
|
28
|
+
}): Promise<T>;
|
|
29
|
+
patch<T>(path: string, body?: unknown, options?: {
|
|
30
|
+
signal?: AbortSignal;
|
|
31
|
+
}): Promise<T>;
|
|
32
|
+
delete<T>(path: string, options?: {
|
|
33
|
+
signal?: AbortSignal;
|
|
34
|
+
}): Promise<T>;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/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W,CAAA;KAAE,GAAG,OAAO,CAAC,CAAC,CAAC;IAIpF,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,CAAC,CAAC;IAItF,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,CAAC,CAAC;CAGxE"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { AuthError, RateLimitError, ServerError, ValidationError } from '../errors.js';
|
|
2
|
+
export class HttpClient {
|
|
3
|
+
baseUrl;
|
|
4
|
+
token;
|
|
5
|
+
constructor(config) {
|
|
6
|
+
const apiBase = config.apiBase || '/api';
|
|
7
|
+
const proto = config.url.startsWith('https') ? 'https' : 'http';
|
|
8
|
+
const clean = config.url.replace(/^https?:\/\//, '');
|
|
9
|
+
this.baseUrl = `${proto}://${clean}${apiBase}`;
|
|
10
|
+
this.token = config.token;
|
|
11
|
+
}
|
|
12
|
+
async request(path, options = {}) {
|
|
13
|
+
const { method = 'GET', body, headers = {}, signal, params, } = options;
|
|
14
|
+
let url = `${this.baseUrl}${path}`;
|
|
15
|
+
if (params) {
|
|
16
|
+
const searchParams = new URLSearchParams(params);
|
|
17
|
+
url += `?${searchParams.toString()}`;
|
|
18
|
+
}
|
|
19
|
+
const requestHeaders = { ...headers };
|
|
20
|
+
if (body !== undefined && !(body instanceof FormData)) {
|
|
21
|
+
requestHeaders['Content-Type'] = 'application/json';
|
|
22
|
+
}
|
|
23
|
+
requestHeaders['Authorization'] = `Bearer ${this.token}`;
|
|
24
|
+
const response = await fetch(url, {
|
|
25
|
+
method,
|
|
26
|
+
headers: requestHeaders,
|
|
27
|
+
body: body instanceof FormData ? body : body ? JSON.stringify(body) : undefined,
|
|
28
|
+
signal,
|
|
29
|
+
});
|
|
30
|
+
if (response.status === 401) {
|
|
31
|
+
throw new AuthError('Authentication failed. Your token may be invalid or expired.');
|
|
32
|
+
}
|
|
33
|
+
if (response.status === 429) {
|
|
34
|
+
const retryAfter = response.headers.get('Retry-After');
|
|
35
|
+
const retryAfterMs = retryAfter ? parseInt(retryAfter, 10) * 1000 : undefined;
|
|
36
|
+
throw new RateLimitError('Too many requests', retryAfterMs);
|
|
37
|
+
}
|
|
38
|
+
if (!response.ok) {
|
|
39
|
+
let errorMessage = `HTTP ${response.status}`;
|
|
40
|
+
try {
|
|
41
|
+
const errorBody = await response.json();
|
|
42
|
+
if (errorBody.message)
|
|
43
|
+
errorMessage = errorBody.message;
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
// Ignore parse error for error body
|
|
47
|
+
}
|
|
48
|
+
if (response.status >= 500) {
|
|
49
|
+
throw new ServerError(errorMessage, response.status);
|
|
50
|
+
}
|
|
51
|
+
throw new ValidationError(errorMessage, response.status);
|
|
52
|
+
}
|
|
53
|
+
const contentType = response.headers.get('Content-Type');
|
|
54
|
+
if (contentType?.includes('application/json')) {
|
|
55
|
+
return response.json();
|
|
56
|
+
}
|
|
57
|
+
return response;
|
|
58
|
+
}
|
|
59
|
+
get(path, options) {
|
|
60
|
+
return this.request(path, { ...options, method: 'GET' });
|
|
61
|
+
}
|
|
62
|
+
post(path, body, options) {
|
|
63
|
+
return this.request(path, { ...options, method: 'POST', body });
|
|
64
|
+
}
|
|
65
|
+
put(path, body, options) {
|
|
66
|
+
return this.request(path, { ...options, method: 'PUT', body });
|
|
67
|
+
}
|
|
68
|
+
patch(path, body, options) {
|
|
69
|
+
return this.request(path, { ...options, method: 'PATCH', body });
|
|
70
|
+
}
|
|
71
|
+
delete(path, options) {
|
|
72
|
+
return this.request(path, { ...options, method: 'DELETE' });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1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,EAAE,QAAQ,EAAE,CAAC,CAAC;IACjE,CAAC;CACF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ClientMessage, ServerMessage } from '../shared';
|
|
2
|
+
export interface WebSocketTransportConfig {
|
|
3
|
+
url: string;
|
|
4
|
+
token: string;
|
|
5
|
+
wsConstructor?: typeof WebSocket;
|
|
6
|
+
connectionTimeout?: number;
|
|
7
|
+
}
|
|
8
|
+
export type WsState = 'disconnected' | 'connecting' | 'connected' | 'disconnecting';
|
|
9
|
+
export declare class WebSocketTransport {
|
|
10
|
+
private _ws;
|
|
11
|
+
private config;
|
|
12
|
+
private _state;
|
|
13
|
+
onOpen: (() => void) | null;
|
|
14
|
+
onMessage: ((message: ServerMessage) => void) | null;
|
|
15
|
+
onClose: ((code: number, reason: string, wasClean: boolean) => void) | null;
|
|
16
|
+
onError: ((error: Error) => void) | null;
|
|
17
|
+
private heartbeatTimer;
|
|
18
|
+
private missedHeartbeats;
|
|
19
|
+
private static readonly HEARTBEAT_TIMEOUT_MS;
|
|
20
|
+
constructor(config: WebSocketTransportConfig);
|
|
21
|
+
connect(): Promise<void>;
|
|
22
|
+
send(message: ClientMessage): void;
|
|
23
|
+
disconnect(): Promise<void>;
|
|
24
|
+
dispose(): void;
|
|
25
|
+
get connected(): boolean;
|
|
26
|
+
get readyState(): number;
|
|
27
|
+
get ws(): WebSocket | null;
|
|
28
|
+
private resetHeartbeat;
|
|
29
|
+
private startHeartbeatMonitor;
|
|
30
|
+
private stopHeartbeatMonitor;
|
|
31
|
+
private buildWsUrl;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=websocket.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket.d.ts","sourceRoot":"","sources":["../../src/transport/websocket.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAG9D,MAAM,WAAW,wBAAwB;IACvC,GAAG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