dsh-input-assistant 0.0.0-stage → 0.1.3
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/LICENSE +21 -0
- package/README.md +183 -2
- package/cordis.patch.yml +3 -0
- package/docs/CHANGELOG-0.1.2.md +102 -0
- package/docs/evaluation.md +111 -0
- package/docs/references.md +39 -0
- package/docs/smoke-comparison.md +37 -0
- package/docs/validation.md +100 -0
- package/lib/browser/components.d.ts +11 -0
- package/lib/browser/controller.d.ts +144 -0
- package/lib/browser/dom.d.ts +29 -0
- package/lib/browser/floating.d.ts +21 -0
- package/lib/browser/index.d.ts +6 -0
- package/lib/browser/public.d.ts +2 -0
- package/lib/browser/runtime.d.ts +53 -0
- package/lib/browser/settings.d.ts +8 -0
- package/lib/browser/styles.d.ts +1 -0
- package/lib/client.js +1704 -0
- package/lib/client.meta.json +274 -0
- package/lib/core/config.d.ts +17 -0
- package/lib/core/context.d.ts +4 -0
- package/lib/core/diff.d.ts +6 -0
- package/lib/core/generation.d.ts +15 -0
- package/lib/core/index.d.ts +8 -0
- package/lib/core/protection.d.ts +19 -0
- package/lib/core/scheduler.d.ts +10 -0
- package/lib/core/snapshot.d.ts +2 -0
- package/lib/core/types.d.ts +81 -0
- package/lib/core.js +523 -0
- package/lib/core.js.map +7 -0
- package/lib/host/rpc.d.ts +29 -0
- package/lib/host/runtime.d.ts +26 -0
- package/lib/host/storage.d.ts +54 -0
- package/lib/host/transcript.d.ts +19 -0
- package/lib/index.d.ts +64 -0
- package/lib/index.js +869 -0
- package/lib/index.js.map +7 -0
- package/package.json +121 -3
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
{
|
|
2
|
+
"inputs": {
|
|
3
|
+
"src/core/diff.ts": {
|
|
4
|
+
"bytes": 3749,
|
|
5
|
+
"imports": [],
|
|
6
|
+
"format": "esm"
|
|
7
|
+
},
|
|
8
|
+
"src/browser/dom.ts": {
|
|
9
|
+
"bytes": 6524,
|
|
10
|
+
"imports": [],
|
|
11
|
+
"format": "esm"
|
|
12
|
+
},
|
|
13
|
+
"src/browser/floating.ts": {
|
|
14
|
+
"bytes": 1614,
|
|
15
|
+
"imports": [],
|
|
16
|
+
"format": "esm"
|
|
17
|
+
},
|
|
18
|
+
"src/browser/components.tsx": {
|
|
19
|
+
"bytes": 19464,
|
|
20
|
+
"imports": [
|
|
21
|
+
{
|
|
22
|
+
"path": "react",
|
|
23
|
+
"kind": "import-statement",
|
|
24
|
+
"external": true
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"path": "react-dom",
|
|
28
|
+
"kind": "import-statement",
|
|
29
|
+
"external": true
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"path": "src/core/diff.ts",
|
|
33
|
+
"kind": "import-statement",
|
|
34
|
+
"original": "../core/diff"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"path": "src/browser/dom.ts",
|
|
38
|
+
"kind": "import-statement",
|
|
39
|
+
"original": "./dom"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"path": "src/browser/floating.ts",
|
|
43
|
+
"kind": "import-statement",
|
|
44
|
+
"original": "./floating"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"path": "react/jsx-runtime",
|
|
48
|
+
"kind": "import-statement",
|
|
49
|
+
"external": true
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
"format": "esm"
|
|
53
|
+
},
|
|
54
|
+
"src/core/types.ts": {
|
|
55
|
+
"bytes": 2407,
|
|
56
|
+
"imports": [],
|
|
57
|
+
"format": "esm"
|
|
58
|
+
},
|
|
59
|
+
"src/core/snapshot.ts": {
|
|
60
|
+
"bytes": 580,
|
|
61
|
+
"imports": [],
|
|
62
|
+
"format": "esm"
|
|
63
|
+
},
|
|
64
|
+
"src/core/context.ts": {
|
|
65
|
+
"bytes": 1845,
|
|
66
|
+
"imports": [],
|
|
67
|
+
"format": "esm"
|
|
68
|
+
},
|
|
69
|
+
"src/browser/controller.ts": {
|
|
70
|
+
"bytes": 31969,
|
|
71
|
+
"imports": [
|
|
72
|
+
{
|
|
73
|
+
"path": "src/core/types.ts",
|
|
74
|
+
"kind": "import-statement",
|
|
75
|
+
"original": "../core/types"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"path": "src/browser/dom.ts",
|
|
79
|
+
"kind": "import-statement",
|
|
80
|
+
"original": "./dom"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"path": "src/core/snapshot.ts",
|
|
84
|
+
"kind": "import-statement",
|
|
85
|
+
"original": "../core/snapshot"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"path": "src/core/context.ts",
|
|
89
|
+
"kind": "import-statement",
|
|
90
|
+
"original": "../core/context"
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
"format": "esm"
|
|
94
|
+
},
|
|
95
|
+
"src/browser/runtime.ts": {
|
|
96
|
+
"bytes": 4196,
|
|
97
|
+
"imports": [
|
|
98
|
+
{
|
|
99
|
+
"path": "src/browser/controller.ts",
|
|
100
|
+
"kind": "import-statement",
|
|
101
|
+
"original": "./controller"
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
"format": "esm"
|
|
105
|
+
},
|
|
106
|
+
"src/browser/styles.ts": {
|
|
107
|
+
"bytes": 4413,
|
|
108
|
+
"imports": [],
|
|
109
|
+
"format": "esm"
|
|
110
|
+
},
|
|
111
|
+
"src/core/config.ts": {
|
|
112
|
+
"bytes": 3624,
|
|
113
|
+
"imports": [
|
|
114
|
+
{
|
|
115
|
+
"path": "src/core/types.ts",
|
|
116
|
+
"kind": "import-statement",
|
|
117
|
+
"original": "./types"
|
|
118
|
+
}
|
|
119
|
+
],
|
|
120
|
+
"format": "esm"
|
|
121
|
+
},
|
|
122
|
+
"src/browser/settings.tsx": {
|
|
123
|
+
"bytes": 7679,
|
|
124
|
+
"imports": [
|
|
125
|
+
{
|
|
126
|
+
"path": "react",
|
|
127
|
+
"kind": "import-statement",
|
|
128
|
+
"external": true
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"path": "src/core/config.ts",
|
|
132
|
+
"kind": "import-statement",
|
|
133
|
+
"original": "../core/config"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"path": "src/core/types.ts",
|
|
137
|
+
"kind": "import-statement",
|
|
138
|
+
"original": "../core/types"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"path": "react/jsx-runtime",
|
|
142
|
+
"kind": "import-statement",
|
|
143
|
+
"external": true
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
"format": "esm"
|
|
147
|
+
},
|
|
148
|
+
"src/browser/public.ts": {
|
|
149
|
+
"bytes": 99,
|
|
150
|
+
"imports": [
|
|
151
|
+
{
|
|
152
|
+
"path": "src/browser/runtime.ts",
|
|
153
|
+
"kind": "import-statement",
|
|
154
|
+
"original": "./runtime"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"path": "src/browser/controller.ts",
|
|
158
|
+
"kind": "import-statement",
|
|
159
|
+
"original": "./controller"
|
|
160
|
+
}
|
|
161
|
+
],
|
|
162
|
+
"format": "esm"
|
|
163
|
+
},
|
|
164
|
+
"src/browser/index.ts": {
|
|
165
|
+
"bytes": 2048,
|
|
166
|
+
"imports": [
|
|
167
|
+
{
|
|
168
|
+
"path": "src/browser/components.tsx",
|
|
169
|
+
"kind": "import-statement",
|
|
170
|
+
"original": "./components"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"path": "src/browser/runtime.ts",
|
|
174
|
+
"kind": "import-statement",
|
|
175
|
+
"original": "./runtime"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"path": "src/browser/styles.ts",
|
|
179
|
+
"kind": "import-statement",
|
|
180
|
+
"original": "./styles"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"path": "src/browser/settings.tsx",
|
|
184
|
+
"kind": "import-statement",
|
|
185
|
+
"original": "./settings"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"path": "src/browser/public.ts",
|
|
189
|
+
"kind": "import-statement",
|
|
190
|
+
"original": "./public"
|
|
191
|
+
}
|
|
192
|
+
],
|
|
193
|
+
"format": "esm"
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
"outputs": {
|
|
197
|
+
"index.js": {
|
|
198
|
+
"imports": [
|
|
199
|
+
{
|
|
200
|
+
"path": "react",
|
|
201
|
+
"kind": "require-call",
|
|
202
|
+
"external": true
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"path": "react-dom",
|
|
206
|
+
"kind": "require-call",
|
|
207
|
+
"external": true
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"path": "react/jsx-runtime",
|
|
211
|
+
"kind": "require-call",
|
|
212
|
+
"external": true
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"path": "react",
|
|
216
|
+
"kind": "require-call",
|
|
217
|
+
"external": true
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"path": "react/jsx-runtime",
|
|
221
|
+
"kind": "require-call",
|
|
222
|
+
"external": true
|
|
223
|
+
}
|
|
224
|
+
],
|
|
225
|
+
"exports": [],
|
|
226
|
+
"entryPoint": "src/browser/index.ts",
|
|
227
|
+
"inputs": {
|
|
228
|
+
"src/browser/index.ts": {
|
|
229
|
+
"bytesInOutput": 1490
|
|
230
|
+
},
|
|
231
|
+
"src/browser/components.tsx": {
|
|
232
|
+
"bytesInOutput": 26371
|
|
233
|
+
},
|
|
234
|
+
"src/core/diff.ts": {
|
|
235
|
+
"bytesInOutput": 2610
|
|
236
|
+
},
|
|
237
|
+
"src/browser/dom.ts": {
|
|
238
|
+
"bytesInOutput": 5368
|
|
239
|
+
},
|
|
240
|
+
"src/browser/floating.ts": {
|
|
241
|
+
"bytesInOutput": 1060
|
|
242
|
+
},
|
|
243
|
+
"src/core/types.ts": {
|
|
244
|
+
"bytesInOutput": 571
|
|
245
|
+
},
|
|
246
|
+
"src/core/snapshot.ts": {
|
|
247
|
+
"bytesInOutput": 459
|
|
248
|
+
},
|
|
249
|
+
"src/core/context.ts": {
|
|
250
|
+
"bytesInOutput": 51
|
|
251
|
+
},
|
|
252
|
+
"src/browser/controller.ts": {
|
|
253
|
+
"bytesInOutput": 29007
|
|
254
|
+
},
|
|
255
|
+
"src/browser/runtime.ts": {
|
|
256
|
+
"bytesInOutput": 3422
|
|
257
|
+
},
|
|
258
|
+
"src/browser/styles.ts": {
|
|
259
|
+
"bytesInOutput": 4405
|
|
260
|
+
},
|
|
261
|
+
"src/browser/settings.tsx": {
|
|
262
|
+
"bytesInOutput": 11851
|
|
263
|
+
},
|
|
264
|
+
"src/core/config.ts": {
|
|
265
|
+
"bytesInOutput": 1956
|
|
266
|
+
},
|
|
267
|
+
"src/browser/public.ts": {
|
|
268
|
+
"bytesInOutput": 0
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
"bytes": 89842
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type AssistantConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Strict resolution for author-supplied input: the plugin's own Cordis config and
|
|
4
|
+
* every `settings/set` patch. Unknown keys are a caller mistake and must fail loudly
|
|
5
|
+
* rather than be silently dropped from a partial update.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveConfig(input?: Partial<AssistantConfig>): AssistantConfig;
|
|
8
|
+
/**
|
|
9
|
+
* Lenient resolution for settings already on disk.
|
|
10
|
+
*
|
|
11
|
+
* Stored settings outlive the code that wrote them: a downgrade, a newer build
|
|
12
|
+
* that added a key, or a partially-written record must never make the plugin
|
|
13
|
+
* unusable. Unknown keys are ignored and unusable values fall back to their
|
|
14
|
+
* default, so a bad record degrades one setting instead of locking every
|
|
15
|
+
* endpoint. The next successful `settings/set` rewrites a clean record.
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveStoredConfig(input: unknown): AssistantConfig;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { HistoryMessage } from './types';
|
|
2
|
+
export declare const charCount: (text: string) => number;
|
|
3
|
+
/** Preserve the initial task, latest correction, and latest answer before filling the remaining tail. */
|
|
4
|
+
export declare function buildContext(history: readonly HistoryMessage[], budget?: number): HistoryMessage[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type AssistantConfig, type GenerationRequest, type HistoryMessage, type Operation } from './types';
|
|
2
|
+
import { type ProtectedText } from './protection';
|
|
3
|
+
export declare const NO_SUGGESTION = "[[NO_SUGGESTION]]";
|
|
4
|
+
export interface PreparedGeneration {
|
|
5
|
+
operation: Operation;
|
|
6
|
+
system: string;
|
|
7
|
+
input: string;
|
|
8
|
+
timeoutMs: number;
|
|
9
|
+
maxOutputTokens: number;
|
|
10
|
+
protection: ProtectedText | null;
|
|
11
|
+
request: GenerationRequest;
|
|
12
|
+
config: AssistantConfig;
|
|
13
|
+
}
|
|
14
|
+
export declare function prepareGeneration(request: GenerationRequest, history: readonly HistoryMessage[], config: AssistantConfig): PreparedGeneration;
|
|
15
|
+
export declare function finishGeneration(raw: string, prepared: PreparedGeneration): string | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface ProtectedFragment {
|
|
2
|
+
token: string;
|
|
3
|
+
original: string;
|
|
4
|
+
}
|
|
5
|
+
export interface ProtectedText {
|
|
6
|
+
original: string;
|
|
7
|
+
masked: string;
|
|
8
|
+
fragments: ProtectedFragment[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Protect syntax and user-locked literals, without trying to prove semantic equivalence.
|
|
12
|
+
*
|
|
13
|
+
* Order matters: the broad shapes (fenced code, inline code, URL, absolute
|
|
14
|
+
* path) are collected first and the narrower path/file rules afterwards; the
|
|
15
|
+
* merge step below folds overlapping matches into one fragment, so a file name
|
|
16
|
+
* inside inline code or inside a URL is protected exactly once.
|
|
17
|
+
*/
|
|
18
|
+
export declare function protectText(text: string, locked?: readonly string[]): ProtectedText;
|
|
19
|
+
export declare function restoreProtected(output: string, protectedText: ProtectedText): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Operation } from './types';
|
|
2
|
+
/** Cancellation settles callers even if a provider ignores AbortSignal. Late results cannot win. */
|
|
3
|
+
export declare class SessionScheduler {
|
|
4
|
+
private flights;
|
|
5
|
+
run<T>(sessionId: string, requestId: string, operation: Operation, timeoutMs: number, work: (signal: AbortSignal) => Promise<T>, external?: AbortSignal): Promise<T>;
|
|
6
|
+
cancel(sessionId: string, requestId?: string): boolean;
|
|
7
|
+
/** Abort every in-flight request (a generation-affecting settings change invalidates them all). */
|
|
8
|
+
cancelAll(): void;
|
|
9
|
+
dispose(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/** Carrier-neutral contracts shared by the host, browser and offline evaluation. */
|
|
2
|
+
export type Operation = 'optimize' | 'next' | 'complete';
|
|
3
|
+
export interface TokenSpan {
|
|
4
|
+
start: number;
|
|
5
|
+
end: number;
|
|
6
|
+
draftRev: number;
|
|
7
|
+
}
|
|
8
|
+
export interface ModelRoute {
|
|
9
|
+
provider: string;
|
|
10
|
+
model: string;
|
|
11
|
+
}
|
|
12
|
+
export type OptimizationStrength = 'light' | 'standard' | 'deep';
|
|
13
|
+
export interface AssistantConfig {
|
|
14
|
+
optimizeEnabled: boolean;
|
|
15
|
+
stashEnabled: boolean;
|
|
16
|
+
optimizationStrength: OptimizationStrength;
|
|
17
|
+
nextEnabled: boolean;
|
|
18
|
+
completionEnabled: boolean;
|
|
19
|
+
displayMode: 'ghost' | 'panel';
|
|
20
|
+
debounceMs: number;
|
|
21
|
+
minIntervalMs: number;
|
|
22
|
+
maxHistoryChars: number;
|
|
23
|
+
maxDraftChars: number;
|
|
24
|
+
maxNextChars: number;
|
|
25
|
+
maxCompletionChars: number;
|
|
26
|
+
optimizeTimeoutMs: number;
|
|
27
|
+
suggestionTimeoutMs: number;
|
|
28
|
+
provider: string;
|
|
29
|
+
model: string;
|
|
30
|
+
}
|
|
31
|
+
export declare const DEFAULT_CONFIG: Readonly<AssistantConfig>;
|
|
32
|
+
export interface InputSnapshot {
|
|
33
|
+
requestId: string;
|
|
34
|
+
sessionId: string;
|
|
35
|
+
sourceTurnId: string | null;
|
|
36
|
+
draft: string;
|
|
37
|
+
draftRev: number;
|
|
38
|
+
span: TokenSpan;
|
|
39
|
+
connectionGeneration: string;
|
|
40
|
+
routeKey: string;
|
|
41
|
+
}
|
|
42
|
+
export interface GenerationRequest extends InputSnapshot {
|
|
43
|
+
operation: Operation;
|
|
44
|
+
targetText?: string;
|
|
45
|
+
lockedFragments?: readonly string[];
|
|
46
|
+
provider?: string;
|
|
47
|
+
model?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface GenerationResult {
|
|
50
|
+
text: string | null;
|
|
51
|
+
requestId: string;
|
|
52
|
+
sessionId: string;
|
|
53
|
+
sourceTurnId: string | null;
|
|
54
|
+
draftRev: number;
|
|
55
|
+
span: TokenSpan;
|
|
56
|
+
connectionGeneration: string;
|
|
57
|
+
routeKey: string;
|
|
58
|
+
}
|
|
59
|
+
export interface HistoryMessage {
|
|
60
|
+
role: 'user' | 'assistant';
|
|
61
|
+
text: string;
|
|
62
|
+
turnId?: string;
|
|
63
|
+
}
|
|
64
|
+
export interface AssistantStatus {
|
|
65
|
+
sourceTurnId: string | null;
|
|
66
|
+
running: boolean;
|
|
67
|
+
settings: AssistantConfig;
|
|
68
|
+
generation: string;
|
|
69
|
+
route?: ModelRoute;
|
|
70
|
+
}
|
|
71
|
+
export interface StoredDraft {
|
|
72
|
+
id: string;
|
|
73
|
+
text: string;
|
|
74
|
+
createdAt: number;
|
|
75
|
+
}
|
|
76
|
+
export declare const RPC_CHANNEL = "/api";
|
|
77
|
+
export declare const RPC_PREFIX = "input-assistant/";
|
|
78
|
+
export declare class AssistantError extends Error {
|
|
79
|
+
readonly code: string;
|
|
80
|
+
constructor(code: string, message: string);
|
|
81
|
+
}
|