@ahggg/dsh-side-chat 0.7.3 → 1.0.1
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 +52 -20
- package/README.zh-CN.md +52 -20
- package/lib/client/apply.js +48 -32
- package/lib/client/contracts.d.ts +3 -58
- package/lib/client/dsh/ReadOnlyConversation.d.ts +10 -0
- package/lib/client/dsh/ReadOnlyConversation.js +99 -0
- package/lib/client/dsh/SideChatOverlay.d.ts +7 -0
- package/lib/client/{rc6/Rc6SideChatOverlay.js → dsh/SideChatOverlay.js} +26 -56
- package/lib/client/{rc6 → dsh}/context.d.ts +4 -6
- package/lib/client/dsh/conversation-store.d.ts +22 -0
- package/lib/client/dsh/conversation-store.js +19 -0
- package/lib/client/dsh/primitive-labels.d.ts +2 -0
- package/lib/client/dsh/primitive-labels.js +4 -0
- package/lib/client/{rc6 → dsh}/remote-adapter.d.ts +2 -2
- package/lib/client/dsh/remote-adapter.js +22 -0
- package/lib/client/dsh/sessions-adapter.d.ts +56 -0
- package/lib/client/dsh/sessions-adapter.js +185 -0
- package/lib/client/index.d.ts +2 -2
- package/lib/client/panel/SelectionQuote.js +8 -1
- package/lib/client/panel/SideChatErrorState.js +1 -1
- package/lib/client/panel/SideChatModelSelect.d.ts +2 -1
- package/lib/client/panel/SideChatModelSelect.js +43 -24
- package/lib/client/panel/SideChatPanel.js +12 -5
- package/lib/client/panel/messages.d.ts +1 -1
- package/lib/client/panel/messages.js +8 -8
- package/lib/client/parent-composer/ParentConversationAnnotations.d.ts +3 -2
- package/lib/client/parent-composer/ParentConversationAnnotations.js +50 -30
- package/lib/client/parent-composer/add-to-conversation.d.ts +14 -28
- package/lib/client/parent-composer/add-to-conversation.js +131 -545
- package/lib/client/parent-composer/annotation-persistence.d.ts +8 -8
- package/lib/client/parent-composer/annotation-persistence.js +106 -102
- package/lib/client/parent-composer/composer-reference.d.ts +17 -55
- package/lib/client/parent-composer/composer-reference.js +20 -72
- package/lib/client/parent-composer/referenced-conversation.d.ts +5 -7
- package/lib/client/parent-composer/referenced-conversation.js +21 -73
- package/lib/client/selection/ConversationAnnotationMarkers.js +5 -1
- package/lib/client/selection/SelectionActions.js +2 -1
- package/lib/client/selection/conversation-dom.d.ts +5 -0
- package/lib/client/selection/conversation-dom.js +24 -0
- package/lib/client/selection/selection-controller.d.ts +1 -1
- package/lib/client/selection/selection-controller.js +7 -3
- package/lib/client/selection/selection-normalizer.js +1 -1
- package/lib/client/side-chat-controller.d.ts +28 -41
- package/lib/client/side-chat-controller.js +247 -337
- package/lib/client.js +84 -54
- package/lib/host/index.d.ts +1 -1
- package/lib/host/index.js +1 -1
- package/lib/host/read-only-chat-service.d.ts +30 -0
- package/lib/host/read-only-chat-service.js +315 -0
- package/lib/index.d.ts +16 -8
- package/lib/index.js +34 -13
- package/lib/remote.d.ts +23 -14
- package/lib/remote.js +2 -5
- package/lib/shared/constants.d.ts +0 -13
- package/lib/shared/constants.js +0 -13
- package/lib/shared/contracts.d.ts +52 -19
- package/lib/shared/contracts.js +2 -3
- package/lib/shared/error-codes.d.ts +1 -1
- package/lib/shared/error-codes.js +2 -2
- package/lib/shared/{archived-wire.d.ts → side-chat-wire.d.ts} +109 -20
- package/lib/shared/side-chat-wire.js +34 -0
- package/lib/typert.d.ts +3 -68
- package/lib/typert.js +60 -4
- package/package.json +76 -56
- package/lib/client/rc6/ArchivedConversation.d.ts +0 -14
- package/lib/client/rc6/ArchivedConversation.js +0 -231
- package/lib/client/rc6/Rc6SideChatOverlay.d.ts +0 -7
- package/lib/client/rc6/SideChatTool.d.ts +0 -22
- package/lib/client/rc6/SideChatTool.js +0 -404
- package/lib/client/rc6/primitive-labels.d.ts +0 -7
- package/lib/client/rc6/primitive-labels.js +0 -60
- package/lib/client/rc6/remote-adapter.js +0 -34
- package/lib/client/rc6/runtime-compat.d.ts +0 -120
- package/lib/client/rc6/runtime-compat.js +0 -187
- package/lib/client/rc6/sessions-adapter.d.ts +0 -64
- package/lib/client/rc6/sessions-adapter.js +0 -387
- package/lib/host/archived-fork-service.d.ts +0 -28
- package/lib/host/archived-fork-service.js +0 -309
- package/lib/shared/archived-wire.js +0 -47
- /package/lib/client/{rc6 → dsh}/context.js +0 -0
|
@@ -4,7 +4,11 @@ export type SessionId = string & {
|
|
|
4
4
|
readonly [brand]: 'SessionId';
|
|
5
5
|
};
|
|
6
6
|
export declare function SessionId(value: string): SessionId;
|
|
7
|
-
/**
|
|
7
|
+
/** Plugin-local identity. It is never registered as a DSH Session. */
|
|
8
|
+
export type SideChatId = string & {
|
|
9
|
+
readonly [brand]: 'SideChatId';
|
|
10
|
+
};
|
|
11
|
+
export declare function SideChatId(value: string): SideChatId;
|
|
8
12
|
export interface SideChatModelSelection {
|
|
9
13
|
readonly provider: string;
|
|
10
14
|
readonly model: string;
|
|
@@ -22,7 +26,7 @@ export interface SideChatWireError {
|
|
|
22
26
|
readonly message: string;
|
|
23
27
|
readonly recoverable: boolean;
|
|
24
28
|
}
|
|
25
|
-
export type SideChatOperation = 'create' | '
|
|
29
|
+
export type SideChatOperation = 'create' | 'prompt' | 'close';
|
|
26
30
|
export interface SideChatClientError extends SideChatWireError {
|
|
27
31
|
readonly operation: SideChatOperation;
|
|
28
32
|
}
|
|
@@ -53,55 +57,84 @@ export interface ConversationSelection {
|
|
|
53
57
|
readonly atSeq: number;
|
|
54
58
|
readonly rect: SelectionRect;
|
|
55
59
|
}
|
|
56
|
-
export
|
|
60
|
+
export interface SideChatMessage {
|
|
61
|
+
readonly id: string;
|
|
62
|
+
readonly role: 'user' | 'assistant';
|
|
63
|
+
readonly text: string;
|
|
64
|
+
readonly reasoning?: string | undefined;
|
|
65
|
+
readonly selectedText?: string | undefined;
|
|
66
|
+
readonly status: 'streaming' | 'complete' | 'stopped' | 'error';
|
|
67
|
+
}
|
|
68
|
+
export type SideChatPhase = 'closed' | 'draft' | 'creating' | 'ready' | 'running' | 'closing' | 'error';
|
|
57
69
|
export interface SideChatState {
|
|
58
70
|
readonly phase: SideChatPhase;
|
|
59
71
|
readonly modelSelection?: SideChatModelSelection | undefined;
|
|
60
72
|
readonly parentSessionId?: SessionId | undefined;
|
|
61
|
-
readonly
|
|
73
|
+
readonly chatId?: SideChatId | undefined;
|
|
62
74
|
readonly boundarySeq?: number | undefined;
|
|
63
|
-
readonly inheritedThroughSeq?: number | undefined;
|
|
64
75
|
readonly selection?: ConversationSelection | undefined;
|
|
65
76
|
readonly draft: string;
|
|
66
|
-
readonly
|
|
77
|
+
readonly messages: readonly SideChatMessage[];
|
|
67
78
|
readonly error?: SideChatClientError | undefined;
|
|
68
79
|
}
|
|
69
80
|
export interface CreateSideChatRequest {
|
|
70
81
|
readonly parentSessionId: SessionId;
|
|
71
82
|
readonly atSeq: number;
|
|
83
|
+
readonly selectedText?: string | undefined;
|
|
72
84
|
readonly modelSelection?: SideChatModelSelection | undefined;
|
|
73
85
|
}
|
|
74
86
|
export interface CreateSideChatValue {
|
|
75
87
|
readonly parentSessionId: SessionId;
|
|
76
|
-
readonly
|
|
88
|
+
readonly chatId: SideChatId;
|
|
77
89
|
readonly boundarySeq: number;
|
|
78
|
-
readonly
|
|
79
|
-
readonly modelSelection?: SideChatModelSelection | undefined;
|
|
90
|
+
readonly modelSelection: SideChatModelSelection;
|
|
80
91
|
}
|
|
81
|
-
export interface
|
|
82
|
-
readonly
|
|
92
|
+
export interface ChatRequest {
|
|
93
|
+
readonly chatId: SideChatId;
|
|
94
|
+
}
|
|
95
|
+
export interface SelectSideChatModelRequest extends ChatRequest, SideChatModelSelection {
|
|
83
96
|
}
|
|
84
97
|
export interface SelectSideChatModelValue {
|
|
85
98
|
readonly selected: SideChatModelSelection;
|
|
86
99
|
}
|
|
87
|
-
export interface
|
|
88
|
-
|
|
100
|
+
export interface SendSideChatRequest extends ChatRequest {
|
|
101
|
+
/** Stable across a retry when transport failed before admission was observed. */
|
|
102
|
+
readonly requestId: string;
|
|
103
|
+
readonly text: string;
|
|
89
104
|
}
|
|
90
105
|
export interface CloseSideChatValue {
|
|
91
106
|
readonly closed: true;
|
|
92
107
|
}
|
|
108
|
+
export type SideChatStreamEvent = {
|
|
109
|
+
readonly type: 'started';
|
|
110
|
+
readonly requestId: string;
|
|
111
|
+
readonly modelSelection: SideChatModelSelection;
|
|
112
|
+
} | {
|
|
113
|
+
readonly type: 'content';
|
|
114
|
+
readonly text: string;
|
|
115
|
+
readonly reasoning: string;
|
|
116
|
+
} | {
|
|
117
|
+
readonly type: 'finished';
|
|
118
|
+
readonly status: 'complete' | 'stopped';
|
|
119
|
+
} | {
|
|
120
|
+
readonly type: 'error';
|
|
121
|
+
readonly error: SideChatWireError;
|
|
122
|
+
};
|
|
123
|
+
export interface SideChatStream extends AsyncIterable<SideChatStreamEvent> {
|
|
124
|
+
dispose(): void;
|
|
125
|
+
}
|
|
93
126
|
export interface SideChatRemote {
|
|
94
127
|
create(request: CreateSideChatRequest): Promise<SideChatResult<CreateSideChatValue>>;
|
|
95
128
|
selectModel(request: SelectSideChatModelRequest): Promise<SideChatResult<SelectSideChatModelValue>>;
|
|
96
|
-
|
|
129
|
+
stream(request: SendSideChatRequest): SideChatStream;
|
|
130
|
+
cancel(request: ChatRequest): Promise<SideChatResult<{
|
|
131
|
+
readonly cancelled: true;
|
|
132
|
+
}>>;
|
|
133
|
+
close(request: ChatRequest): Promise<SideChatResult<CloseSideChatValue>>;
|
|
97
134
|
}
|
|
135
|
+
/** Text representation also used by the durable main-composer annotation codec. */
|
|
98
136
|
export type SideChatPromptPart = {
|
|
99
137
|
readonly type: 'text';
|
|
100
138
|
readonly text: string;
|
|
101
|
-
} | {
|
|
102
|
-
readonly type: 'image';
|
|
103
|
-
readonly mediaType: string;
|
|
104
|
-
readonly data: string;
|
|
105
|
-
readonly name?: string;
|
|
106
139
|
};
|
|
107
140
|
export {};
|
package/lib/shared/contracts.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export function SessionId(value) {
|
|
2
|
-
|
|
3
|
-
}
|
|
1
|
+
export function SessionId(value) { return value; }
|
|
2
|
+
export function SideChatId(value) { return value; }
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const SIDE_CHAT_ERROR_CODES: readonly ["selection_empty", "selection_outside_conversation", "selection_not_model_visible", "selection_too_large", "selection_stale", "selection_crosses_unsupported_nodes", "parent_session_missing", "parent_session_not_ready", "
|
|
1
|
+
export declare const SIDE_CHAT_ERROR_CODES: readonly ["selection_empty", "selection_outside_conversation", "selection_not_model_visible", "selection_too_large", "selection_stale", "selection_crosses_unsupported_nodes", "parent_session_missing", "parent_session_not_ready", "context_unavailable", "context_too_large", "side_chat_already_open", "side_chat_not_found", "side_chat_prompt_failed", "side_chat_model_failed", "side_chat_interrupt_failed", "side_chat_destroy_failed", "transport_error", "invalid_request", "internal_error"];
|
|
2
2
|
export type SideChatErrorCode = (typeof SIDE_CHAT_ERROR_CODES)[number];
|
|
3
3
|
export declare function isSideChatErrorCode(value: unknown): value is SideChatErrorCode;
|
|
@@ -7,10 +7,10 @@ export const SIDE_CHAT_ERROR_CODES = [
|
|
|
7
7
|
'selection_crosses_unsupported_nodes',
|
|
8
8
|
'parent_session_missing',
|
|
9
9
|
'parent_session_not_ready',
|
|
10
|
-
'
|
|
10
|
+
'context_unavailable',
|
|
11
|
+
'context_too_large',
|
|
11
12
|
'side_chat_already_open',
|
|
12
13
|
'side_chat_not_found',
|
|
13
|
-
'side_chat_open_failed',
|
|
14
14
|
'side_chat_prompt_failed',
|
|
15
15
|
'side_chat_model_failed',
|
|
16
16
|
'side_chat_interrupt_failed',
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
export declare const modelSelectionSchema: z.ZodObject<{
|
|
3
|
+
provider: z.ZodString;
|
|
4
|
+
model: z.ZodString;
|
|
5
|
+
reasoningEffort: z.ZodOptional<z.ZodString>;
|
|
6
|
+
}, z.core.$strict>;
|
|
2
7
|
export declare const sideChatWireErrorSchema: z.ZodObject<{
|
|
3
8
|
code: z.ZodEnum<{
|
|
4
9
|
selection_empty: "selection_empty";
|
|
@@ -9,10 +14,10 @@ export declare const sideChatWireErrorSchema: z.ZodObject<{
|
|
|
9
14
|
selection_crosses_unsupported_nodes: "selection_crosses_unsupported_nodes";
|
|
10
15
|
parent_session_missing: "parent_session_missing";
|
|
11
16
|
parent_session_not_ready: "parent_session_not_ready";
|
|
12
|
-
|
|
17
|
+
context_unavailable: "context_unavailable";
|
|
18
|
+
context_too_large: "context_too_large";
|
|
13
19
|
side_chat_already_open: "side_chat_already_open";
|
|
14
20
|
side_chat_not_found: "side_chat_not_found";
|
|
15
|
-
side_chat_open_failed: "side_chat_open_failed";
|
|
16
21
|
side_chat_prompt_failed: "side_chat_prompt_failed";
|
|
17
22
|
side_chat_model_failed: "side_chat_model_failed";
|
|
18
23
|
side_chat_interrupt_failed: "side_chat_interrupt_failed";
|
|
@@ -24,36 +29,41 @@ export declare const sideChatWireErrorSchema: z.ZodObject<{
|
|
|
24
29
|
message: z.ZodString;
|
|
25
30
|
recoverable: z.ZodBoolean;
|
|
26
31
|
}, z.core.$strict>;
|
|
27
|
-
export declare const
|
|
32
|
+
export declare const createRequestSchema: z.ZodObject<{
|
|
28
33
|
parentSessionId: z.ZodString;
|
|
29
34
|
atSeq: z.ZodNumber;
|
|
35
|
+
selectedText: z.ZodOptional<z.ZodString>;
|
|
30
36
|
modelSelection: z.ZodOptional<z.ZodObject<{
|
|
31
37
|
provider: z.ZodString;
|
|
32
38
|
model: z.ZodString;
|
|
33
39
|
reasoningEffort: z.ZodOptional<z.ZodString>;
|
|
34
40
|
}, z.core.$strict>>;
|
|
35
41
|
}, z.core.$strict>;
|
|
36
|
-
export declare const
|
|
37
|
-
|
|
42
|
+
export declare const chatRequestSchema: z.ZodObject<{
|
|
43
|
+
chatId: z.ZodString;
|
|
44
|
+
}, z.core.$strict>;
|
|
45
|
+
export declare const selectModelRequestSchema: z.ZodObject<{
|
|
46
|
+
chatId: z.ZodString;
|
|
38
47
|
provider: z.ZodString;
|
|
39
48
|
model: z.ZodString;
|
|
40
49
|
reasoningEffort: z.ZodOptional<z.ZodString>;
|
|
41
50
|
}, z.core.$strict>;
|
|
42
|
-
export declare const
|
|
43
|
-
|
|
51
|
+
export declare const sendRequestSchema: z.ZodObject<{
|
|
52
|
+
chatId: z.ZodString;
|
|
53
|
+
requestId: z.ZodString;
|
|
54
|
+
text: z.ZodString;
|
|
44
55
|
}, z.core.$strict>;
|
|
45
|
-
export declare const
|
|
56
|
+
export declare const createResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
46
57
|
ok: z.ZodLiteral<true>;
|
|
47
58
|
value: z.ZodObject<{
|
|
48
59
|
parentSessionId: z.ZodString;
|
|
49
|
-
|
|
60
|
+
chatId: z.ZodString;
|
|
50
61
|
boundarySeq: z.ZodNumber;
|
|
51
|
-
|
|
52
|
-
modelSelection: z.ZodOptional<z.ZodObject<{
|
|
62
|
+
modelSelection: z.ZodObject<{
|
|
53
63
|
provider: z.ZodString;
|
|
54
64
|
model: z.ZodString;
|
|
55
65
|
reasoningEffort: z.ZodOptional<z.ZodString>;
|
|
56
|
-
}, z.core.$strict
|
|
66
|
+
}, z.core.$strict>;
|
|
57
67
|
}, z.core.$strict>;
|
|
58
68
|
}, z.core.$strict>, z.ZodObject<{
|
|
59
69
|
ok: z.ZodLiteral<false>;
|
|
@@ -67,10 +77,10 @@ export declare const archivedCreateResultSchema: z.ZodDiscriminatedUnion<[z.ZodO
|
|
|
67
77
|
selection_crosses_unsupported_nodes: "selection_crosses_unsupported_nodes";
|
|
68
78
|
parent_session_missing: "parent_session_missing";
|
|
69
79
|
parent_session_not_ready: "parent_session_not_ready";
|
|
70
|
-
|
|
80
|
+
context_unavailable: "context_unavailable";
|
|
81
|
+
context_too_large: "context_too_large";
|
|
71
82
|
side_chat_already_open: "side_chat_already_open";
|
|
72
83
|
side_chat_not_found: "side_chat_not_found";
|
|
73
|
-
side_chat_open_failed: "side_chat_open_failed";
|
|
74
84
|
side_chat_prompt_failed: "side_chat_prompt_failed";
|
|
75
85
|
side_chat_model_failed: "side_chat_model_failed";
|
|
76
86
|
side_chat_interrupt_failed: "side_chat_interrupt_failed";
|
|
@@ -83,7 +93,7 @@ export declare const archivedCreateResultSchema: z.ZodDiscriminatedUnion<[z.ZodO
|
|
|
83
93
|
recoverable: z.ZodBoolean;
|
|
84
94
|
}, z.core.$strict>;
|
|
85
95
|
}, z.core.$strict>], "ok">;
|
|
86
|
-
export declare const
|
|
96
|
+
export declare const selectModelResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
87
97
|
ok: z.ZodLiteral<true>;
|
|
88
98
|
value: z.ZodObject<{
|
|
89
99
|
selected: z.ZodObject<{
|
|
@@ -104,10 +114,10 @@ export declare const archivedSelectModelResultSchema: z.ZodDiscriminatedUnion<[z
|
|
|
104
114
|
selection_crosses_unsupported_nodes: "selection_crosses_unsupported_nodes";
|
|
105
115
|
parent_session_missing: "parent_session_missing";
|
|
106
116
|
parent_session_not_ready: "parent_session_not_ready";
|
|
107
|
-
|
|
117
|
+
context_unavailable: "context_unavailable";
|
|
118
|
+
context_too_large: "context_too_large";
|
|
108
119
|
side_chat_already_open: "side_chat_already_open";
|
|
109
120
|
side_chat_not_found: "side_chat_not_found";
|
|
110
|
-
side_chat_open_failed: "side_chat_open_failed";
|
|
111
121
|
side_chat_prompt_failed: "side_chat_prompt_failed";
|
|
112
122
|
side_chat_model_failed: "side_chat_model_failed";
|
|
113
123
|
side_chat_interrupt_failed: "side_chat_interrupt_failed";
|
|
@@ -120,7 +130,7 @@ export declare const archivedSelectModelResultSchema: z.ZodDiscriminatedUnion<[z
|
|
|
120
130
|
recoverable: z.ZodBoolean;
|
|
121
131
|
}, z.core.$strict>;
|
|
122
132
|
}, z.core.$strict>], "ok">;
|
|
123
|
-
export declare const
|
|
133
|
+
export declare const closeResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
124
134
|
ok: z.ZodLiteral<true>;
|
|
125
135
|
value: z.ZodObject<{
|
|
126
136
|
closed: z.ZodLiteral<true>;
|
|
@@ -137,10 +147,43 @@ export declare const archivedCloseResultSchema: z.ZodDiscriminatedUnion<[z.ZodOb
|
|
|
137
147
|
selection_crosses_unsupported_nodes: "selection_crosses_unsupported_nodes";
|
|
138
148
|
parent_session_missing: "parent_session_missing";
|
|
139
149
|
parent_session_not_ready: "parent_session_not_ready";
|
|
140
|
-
|
|
150
|
+
context_unavailable: "context_unavailable";
|
|
151
|
+
context_too_large: "context_too_large";
|
|
152
|
+
side_chat_already_open: "side_chat_already_open";
|
|
153
|
+
side_chat_not_found: "side_chat_not_found";
|
|
154
|
+
side_chat_prompt_failed: "side_chat_prompt_failed";
|
|
155
|
+
side_chat_model_failed: "side_chat_model_failed";
|
|
156
|
+
side_chat_interrupt_failed: "side_chat_interrupt_failed";
|
|
157
|
+
side_chat_destroy_failed: "side_chat_destroy_failed";
|
|
158
|
+
transport_error: "transport_error";
|
|
159
|
+
invalid_request: "invalid_request";
|
|
160
|
+
internal_error: "internal_error";
|
|
161
|
+
}>;
|
|
162
|
+
message: z.ZodString;
|
|
163
|
+
recoverable: z.ZodBoolean;
|
|
164
|
+
}, z.core.$strict>;
|
|
165
|
+
}, z.core.$strict>], "ok">;
|
|
166
|
+
export declare const cancelResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
167
|
+
ok: z.ZodLiteral<true>;
|
|
168
|
+
value: z.ZodObject<{
|
|
169
|
+
cancelled: z.ZodLiteral<true>;
|
|
170
|
+
}, z.core.$strict>;
|
|
171
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
172
|
+
ok: z.ZodLiteral<false>;
|
|
173
|
+
error: z.ZodObject<{
|
|
174
|
+
code: z.ZodEnum<{
|
|
175
|
+
selection_empty: "selection_empty";
|
|
176
|
+
selection_outside_conversation: "selection_outside_conversation";
|
|
177
|
+
selection_not_model_visible: "selection_not_model_visible";
|
|
178
|
+
selection_too_large: "selection_too_large";
|
|
179
|
+
selection_stale: "selection_stale";
|
|
180
|
+
selection_crosses_unsupported_nodes: "selection_crosses_unsupported_nodes";
|
|
181
|
+
parent_session_missing: "parent_session_missing";
|
|
182
|
+
parent_session_not_ready: "parent_session_not_ready";
|
|
183
|
+
context_unavailable: "context_unavailable";
|
|
184
|
+
context_too_large: "context_too_large";
|
|
141
185
|
side_chat_already_open: "side_chat_already_open";
|
|
142
186
|
side_chat_not_found: "side_chat_not_found";
|
|
143
|
-
side_chat_open_failed: "side_chat_open_failed";
|
|
144
187
|
side_chat_prompt_failed: "side_chat_prompt_failed";
|
|
145
188
|
side_chat_model_failed: "side_chat_model_failed";
|
|
146
189
|
side_chat_interrupt_failed: "side_chat_interrupt_failed";
|
|
@@ -153,3 +196,49 @@ export declare const archivedCloseResultSchema: z.ZodDiscriminatedUnion<[z.ZodOb
|
|
|
153
196
|
recoverable: z.ZodBoolean;
|
|
154
197
|
}, z.core.$strict>;
|
|
155
198
|
}, z.core.$strict>], "ok">;
|
|
199
|
+
export declare const streamEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
200
|
+
type: z.ZodLiteral<"started">;
|
|
201
|
+
requestId: z.ZodString;
|
|
202
|
+
modelSelection: z.ZodObject<{
|
|
203
|
+
provider: z.ZodString;
|
|
204
|
+
model: z.ZodString;
|
|
205
|
+
reasoningEffort: z.ZodOptional<z.ZodString>;
|
|
206
|
+
}, z.core.$strict>;
|
|
207
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
208
|
+
type: z.ZodLiteral<"content">;
|
|
209
|
+
text: z.ZodString;
|
|
210
|
+
reasoning: z.ZodString;
|
|
211
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
212
|
+
type: z.ZodLiteral<"finished">;
|
|
213
|
+
status: z.ZodEnum<{
|
|
214
|
+
complete: "complete";
|
|
215
|
+
stopped: "stopped";
|
|
216
|
+
}>;
|
|
217
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
218
|
+
type: z.ZodLiteral<"error">;
|
|
219
|
+
error: z.ZodObject<{
|
|
220
|
+
code: z.ZodEnum<{
|
|
221
|
+
selection_empty: "selection_empty";
|
|
222
|
+
selection_outside_conversation: "selection_outside_conversation";
|
|
223
|
+
selection_not_model_visible: "selection_not_model_visible";
|
|
224
|
+
selection_too_large: "selection_too_large";
|
|
225
|
+
selection_stale: "selection_stale";
|
|
226
|
+
selection_crosses_unsupported_nodes: "selection_crosses_unsupported_nodes";
|
|
227
|
+
parent_session_missing: "parent_session_missing";
|
|
228
|
+
parent_session_not_ready: "parent_session_not_ready";
|
|
229
|
+
context_unavailable: "context_unavailable";
|
|
230
|
+
context_too_large: "context_too_large";
|
|
231
|
+
side_chat_already_open: "side_chat_already_open";
|
|
232
|
+
side_chat_not_found: "side_chat_not_found";
|
|
233
|
+
side_chat_prompt_failed: "side_chat_prompt_failed";
|
|
234
|
+
side_chat_model_failed: "side_chat_model_failed";
|
|
235
|
+
side_chat_interrupt_failed: "side_chat_interrupt_failed";
|
|
236
|
+
side_chat_destroy_failed: "side_chat_destroy_failed";
|
|
237
|
+
transport_error: "transport_error";
|
|
238
|
+
invalid_request: "invalid_request";
|
|
239
|
+
internal_error: "internal_error";
|
|
240
|
+
}>;
|
|
241
|
+
message: z.ZodString;
|
|
242
|
+
recoverable: z.ZodBoolean;
|
|
243
|
+
}, z.core.$strict>;
|
|
244
|
+
}, z.core.$strict>], "type">;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SIDE_CHAT_ERROR_CODES } from './error-codes.js';
|
|
3
|
+
const id = z.string().min(1).max(512);
|
|
4
|
+
export const modelSelectionSchema = z.object({ provider: id, model: id, reasoningEffort: id.optional() }).strict();
|
|
5
|
+
export const sideChatWireErrorSchema = z.object({
|
|
6
|
+
code: z.enum(SIDE_CHAT_ERROR_CODES), message: z.string(), recoverable: z.boolean(),
|
|
7
|
+
}).strict();
|
|
8
|
+
export const createRequestSchema = z.object({
|
|
9
|
+
parentSessionId: id, atSeq: z.number().int().nonnegative(),
|
|
10
|
+
selectedText: z.string().max(16 * 1024).optional(), modelSelection: modelSelectionSchema.optional(),
|
|
11
|
+
}).strict();
|
|
12
|
+
export const chatRequestSchema = z.object({ chatId: id }).strict();
|
|
13
|
+
export const selectModelRequestSchema = z.object({
|
|
14
|
+
chatId: id, provider: id, model: id, reasoningEffort: id.optional(),
|
|
15
|
+
}).strict();
|
|
16
|
+
export const sendRequestSchema = z.object({ chatId: id, requestId: id, text: z.string().min(1).max(64 * 1024) }).strict();
|
|
17
|
+
function resultSchema(value) {
|
|
18
|
+
return z.discriminatedUnion('ok', [
|
|
19
|
+
z.object({ ok: z.literal(true), value }).strict(),
|
|
20
|
+
z.object({ ok: z.literal(false), error: sideChatWireErrorSchema }).strict(),
|
|
21
|
+
]);
|
|
22
|
+
}
|
|
23
|
+
export const createResultSchema = resultSchema(z.object({
|
|
24
|
+
parentSessionId: id, chatId: id, boundarySeq: z.number().int().nonnegative(), modelSelection: modelSelectionSchema,
|
|
25
|
+
}).strict());
|
|
26
|
+
export const selectModelResultSchema = resultSchema(z.object({ selected: modelSelectionSchema }).strict());
|
|
27
|
+
export const closeResultSchema = resultSchema(z.object({ closed: z.literal(true) }).strict());
|
|
28
|
+
export const cancelResultSchema = resultSchema(z.object({ cancelled: z.literal(true) }).strict());
|
|
29
|
+
export const streamEventSchema = z.discriminatedUnion('type', [
|
|
30
|
+
z.object({ type: z.literal('started'), requestId: id, modelSelection: modelSelectionSchema }).strict(),
|
|
31
|
+
z.object({ type: z.literal('content'), text: z.string(), reasoning: z.string() }).strict(),
|
|
32
|
+
z.object({ type: z.literal('finished'), status: z.enum(['complete', 'stopped']) }).strict(),
|
|
33
|
+
z.object({ type: z.literal('error'), error: sideChatWireErrorSchema }).strict(),
|
|
34
|
+
]);
|
package/lib/typert.d.ts
CHANGED
|
@@ -1,37 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
service: string;
|
|
4
|
-
namespace: string;
|
|
5
|
-
method: "create" | "close" | "selectModel";
|
|
6
|
-
implementation: string;
|
|
7
|
-
invocation: {
|
|
8
|
-
kind: "direct";
|
|
9
|
-
};
|
|
10
|
-
parameters: {
|
|
11
|
-
name: string;
|
|
12
|
-
wire: string;
|
|
13
|
-
source: "json";
|
|
14
|
-
codec: {
|
|
15
|
-
mode: "strict";
|
|
16
|
-
typeSymbol: string;
|
|
17
|
-
schema: {
|
|
18
|
-
parse(value: unknown): unknown;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
}[];
|
|
22
|
-
result: {
|
|
23
|
-
mode: "strict";
|
|
24
|
-
typeSymbol: string;
|
|
25
|
-
schema: {
|
|
26
|
-
parse(value: unknown): unknown;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
sourceLocation: {
|
|
30
|
-
file: string;
|
|
31
|
-
line: number;
|
|
32
|
-
column: number;
|
|
33
|
-
};
|
|
34
|
-
}[];
|
|
1
|
+
import type { InvocationDescriptor } from '@deepseek-ai/dsh-typert-protocol';
|
|
2
|
+
export declare const SIDE_CHAT_INVOCATIONS: InvocationDescriptor[];
|
|
35
3
|
export declare const TYPERT: {
|
|
36
4
|
package: string;
|
|
37
5
|
face: string;
|
|
@@ -41,39 +9,6 @@ export declare const TYPERT: {
|
|
|
41
9
|
events: never[];
|
|
42
10
|
objects: never[];
|
|
43
11
|
};
|
|
44
|
-
invocations:
|
|
45
|
-
id: string;
|
|
46
|
-
service: string;
|
|
47
|
-
namespace: string;
|
|
48
|
-
method: "create" | "close" | "selectModel";
|
|
49
|
-
implementation: string;
|
|
50
|
-
invocation: {
|
|
51
|
-
kind: "direct";
|
|
52
|
-
};
|
|
53
|
-
parameters: {
|
|
54
|
-
name: string;
|
|
55
|
-
wire: string;
|
|
56
|
-
source: "json";
|
|
57
|
-
codec: {
|
|
58
|
-
mode: "strict";
|
|
59
|
-
typeSymbol: string;
|
|
60
|
-
schema: {
|
|
61
|
-
parse(value: unknown): unknown;
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
}[];
|
|
65
|
-
result: {
|
|
66
|
-
mode: "strict";
|
|
67
|
-
typeSymbol: string;
|
|
68
|
-
schema: {
|
|
69
|
-
parse(value: unknown): unknown;
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
sourceLocation: {
|
|
73
|
-
file: string;
|
|
74
|
-
line: number;
|
|
75
|
-
column: number;
|
|
76
|
-
};
|
|
77
|
-
}[];
|
|
12
|
+
invocations: InvocationDescriptor[];
|
|
78
13
|
};
|
|
79
14
|
export default TYPERT;
|