dsh-input-assistant 0.0.0-stage → 0.1.4

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/LICENSE +21 -0
  3. package/README.en.md +100 -0
  4. package/README.md +215 -3
  5. package/cordis.patch.yml +3 -0
  6. package/docs/CHANGELOG-0.1.2.md +102 -0
  7. package/docs/evaluation.md +111 -0
  8. package/docs/images/dark.png +0 -0
  9. package/docs/images/light.png +0 -0
  10. package/docs/images/optimize.png +0 -0
  11. package/docs/references.md +39 -0
  12. package/docs/smoke-comparison.md +37 -0
  13. package/docs/validation.md +180 -0
  14. package/lib/browser/components.d.ts +11 -0
  15. package/lib/browser/controller.d.ts +187 -0
  16. package/lib/browser/dom.d.ts +29 -0
  17. package/lib/browser/floating.d.ts +21 -0
  18. package/lib/browser/index.d.ts +6 -0
  19. package/lib/browser/public.d.ts +2 -0
  20. package/lib/browser/runtime.d.ts +55 -0
  21. package/lib/browser/settings.d.ts +8 -0
  22. package/lib/browser/styles.d.ts +1 -0
  23. package/lib/client.js +2646 -0
  24. package/lib/client.meta.json +274 -0
  25. package/lib/core/config.d.ts +17 -0
  26. package/lib/core/context.d.ts +4 -0
  27. package/lib/core/diff.d.ts +6 -0
  28. package/lib/core/generation.d.ts +15 -0
  29. package/lib/core/index.d.ts +9 -0
  30. package/lib/core/models.d.ts +15 -0
  31. package/lib/core/protection.d.ts +18 -0
  32. package/lib/core/scheduler.d.ts +10 -0
  33. package/lib/core/snapshot.d.ts +2 -0
  34. package/lib/core/types.d.ts +92 -0
  35. package/lib/core.js +750 -0
  36. package/lib/core.js.map +7 -0
  37. package/lib/host/rpc.d.ts +31 -0
  38. package/lib/host/runtime.d.ts +28 -0
  39. package/lib/host/storage.d.ts +62 -0
  40. package/lib/host/transcript.d.ts +19 -0
  41. package/lib/index.d.ts +66 -0
  42. package/lib/index.js +1164 -0
  43. package/lib/index.js.map +7 -0
  44. package/package.json +128 -3
@@ -0,0 +1,274 @@
1
+ {
2
+ "inputs": {
3
+ "src/core/diff.ts": {
4
+ "bytes": 3821,
5
+ "imports": [],
6
+ "format": "esm"
7
+ },
8
+ "src/browser/dom.ts": {
9
+ "bytes": 6650,
10
+ "imports": [],
11
+ "format": "esm"
12
+ },
13
+ "src/browser/floating.ts": {
14
+ "bytes": 1635,
15
+ "imports": [],
16
+ "format": "esm"
17
+ },
18
+ "src/browser/components.tsx": {
19
+ "bytes": 27915,
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.js"
35
+ },
36
+ {
37
+ "path": "src/browser/dom.ts",
38
+ "kind": "import-statement",
39
+ "original": "./dom.js"
40
+ },
41
+ {
42
+ "path": "src/browser/floating.ts",
43
+ "kind": "import-statement",
44
+ "original": "./floating.js"
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": 2990,
56
+ "imports": [],
57
+ "format": "esm"
58
+ },
59
+ "src/core/snapshot.ts": {
60
+ "bytes": 590,
61
+ "imports": [],
62
+ "format": "esm"
63
+ },
64
+ "src/core/context.ts": {
65
+ "bytes": 1880,
66
+ "imports": [],
67
+ "format": "esm"
68
+ },
69
+ "src/browser/controller.ts": {
70
+ "bytes": 46928,
71
+ "imports": [
72
+ {
73
+ "path": "src/core/types.ts",
74
+ "kind": "import-statement",
75
+ "original": "../core/types.js"
76
+ },
77
+ {
78
+ "path": "src/browser/dom.ts",
79
+ "kind": "import-statement",
80
+ "original": "./dom.js"
81
+ },
82
+ {
83
+ "path": "src/core/snapshot.ts",
84
+ "kind": "import-statement",
85
+ "original": "../core/snapshot.js"
86
+ },
87
+ {
88
+ "path": "src/core/context.ts",
89
+ "kind": "import-statement",
90
+ "original": "../core/context.js"
91
+ }
92
+ ],
93
+ "format": "esm"
94
+ },
95
+ "src/browser/runtime.ts": {
96
+ "bytes": 6245,
97
+ "imports": [
98
+ {
99
+ "path": "src/browser/controller.ts",
100
+ "kind": "import-statement",
101
+ "original": "./controller.js"
102
+ }
103
+ ],
104
+ "format": "esm"
105
+ },
106
+ "src/browser/styles.ts": {
107
+ "bytes": 10969,
108
+ "imports": [],
109
+ "format": "esm"
110
+ },
111
+ "src/core/config.ts": {
112
+ "bytes": 4132,
113
+ "imports": [
114
+ {
115
+ "path": "src/core/types.ts",
116
+ "kind": "import-statement",
117
+ "original": "./types.js"
118
+ }
119
+ ],
120
+ "format": "esm"
121
+ },
122
+ "src/browser/settings.tsx": {
123
+ "bytes": 14673,
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.js"
134
+ },
135
+ {
136
+ "path": "src/core/types.ts",
137
+ "kind": "import-statement",
138
+ "original": "../core/types.js"
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": 107,
150
+ "imports": [
151
+ {
152
+ "path": "src/browser/runtime.ts",
153
+ "kind": "import-statement",
154
+ "original": "./runtime.js"
155
+ },
156
+ {
157
+ "path": "src/browser/controller.ts",
158
+ "kind": "import-statement",
159
+ "original": "./controller.js"
160
+ }
161
+ ],
162
+ "format": "esm"
163
+ },
164
+ "src/browser/index.ts": {
165
+ "bytes": 2104,
166
+ "imports": [
167
+ {
168
+ "path": "src/browser/components.tsx",
169
+ "kind": "import-statement",
170
+ "original": "./components.js"
171
+ },
172
+ {
173
+ "path": "src/browser/runtime.ts",
174
+ "kind": "import-statement",
175
+ "original": "./runtime.js"
176
+ },
177
+ {
178
+ "path": "src/browser/styles.ts",
179
+ "kind": "import-statement",
180
+ "original": "./styles.js"
181
+ },
182
+ {
183
+ "path": "src/browser/settings.tsx",
184
+ "kind": "import-statement",
185
+ "original": "./settings.js"
186
+ },
187
+ {
188
+ "path": "src/browser/public.ts",
189
+ "kind": "import-statement",
190
+ "original": "./public.js"
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": 37601
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": 603
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": 43757
254
+ },
255
+ "src/browser/runtime.ts": {
256
+ "bytesInOutput": 5060
257
+ },
258
+ "src/browser/styles.ts": {
259
+ "bytesInOutput": 10614
260
+ },
261
+ "src/browser/settings.tsx": {
262
+ "bytesInOutput": 22816
263
+ },
264
+ "src/core/config.ts": {
265
+ "bytesInOutput": 2160
266
+ },
267
+ "src/browser/public.ts": {
268
+ "bytesInOutput": 0
269
+ }
270
+ },
271
+ "bytes": 134870
272
+ }
273
+ }
274
+ }
@@ -0,0 +1,17 @@
1
+ import { type AssistantConfig } from './types.js';
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.js';
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,6 @@
1
+ export interface TextChange {
2
+ type: 'equal' | 'insert' | 'delete';
3
+ value: string;
4
+ }
5
+ /** A bounded token diff for inspection; never a claim about semantic fidelity. */
6
+ export declare function diffText(before: string, after: string): TextChange[];
@@ -0,0 +1,15 @@
1
+ import { type AssistantConfig, type GenerationRequest, type HistoryMessage, type Operation } from './types.js';
2
+ import { type ProtectedText } from './protection.js';
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,9 @@
1
+ export * from './types.js';
2
+ export * from './config.js';
3
+ export * from './context.js';
4
+ export * from './protection.js';
5
+ export * from './generation.js';
6
+ export * from './scheduler.js';
7
+ export * from './snapshot.js';
8
+ export * from './diff.js';
9
+ export * from './models.js';
@@ -0,0 +1,15 @@
1
+ /** Read-only model choices for the plugin's auxiliary route, independent of the main composer. */
2
+ export interface AssistantModelCatalog {
3
+ groups: {
4
+ provider: string;
5
+ name: string;
6
+ models: {
7
+ id: string;
8
+ name: string;
9
+ }[];
10
+ }[];
11
+ failures: {
12
+ provider: string;
13
+ name: string;
14
+ }[];
15
+ }
@@ -0,0 +1,18 @@
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
+ * Broad literals own their complete span, so nested paths are protected once.
14
+ * Plain candidates are consumed once and classified at their boundary; long
15
+ * prose without separators must not cause quadratic failed regex searches.
16
+ */
17
+ export declare function protectText(text: string, locked?: readonly string[]): ProtectedText;
18
+ export declare function restoreProtected(output: string, protectedText: ProtectedText): string;
@@ -0,0 +1,10 @@
1
+ import { type Operation } from './types.js';
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,2 @@
1
+ import type { InputSnapshot } from './types.js';
2
+ export declare function snapshotMatches(expected: InputSnapshot, current: Omit<InputSnapshot, 'requestId'>, checkCaret?: boolean): boolean;
@@ -0,0 +1,92 @@
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 type PredictionDetail = 'concise' | 'standard' | 'detailed';
14
+ export interface AssistantConfig {
15
+ optimizeEnabled: boolean;
16
+ stashEnabled: boolean;
17
+ optimizationStrength: OptimizationStrength;
18
+ nextEnabled: boolean;
19
+ completionEnabled: boolean;
20
+ predictionDetail: PredictionDetail;
21
+ displayMode: 'ghost' | 'panel';
22
+ debounceMs: number;
23
+ minIntervalMs: number;
24
+ maxHistoryChars: number;
25
+ maxDraftChars: number;
26
+ maxNextChars: number;
27
+ maxCompletionChars: number;
28
+ optimizeTimeoutMs: number;
29
+ suggestionTimeoutMs: number;
30
+ provider: string;
31
+ model: string;
32
+ }
33
+ export declare const DEFAULT_CONFIG: Readonly<AssistantConfig>;
34
+ export interface InputSnapshot {
35
+ requestId: string;
36
+ sessionId: string;
37
+ sourceTurnId: string | null;
38
+ draft: string;
39
+ draftRev: number;
40
+ span: TokenSpan;
41
+ connectionGeneration: string;
42
+ routeKey: string;
43
+ }
44
+ export interface GenerationRequest extends InputSnapshot {
45
+ operation: Operation;
46
+ /** Explicit user action; automatic feature toggles do not block a single manual suggestion. */
47
+ manual?: boolean;
48
+ targetText?: string;
49
+ lockedFragments?: readonly string[];
50
+ provider?: string;
51
+ model?: string;
52
+ }
53
+ export interface GenerationResult {
54
+ text: string | null;
55
+ /** Temporary throttling is not a model abstention and must never be cached as one. */
56
+ outcome?: 'suggestion' | 'abstained' | 'throttled';
57
+ retryAfterMs?: number;
58
+ requestId: string;
59
+ sessionId: string;
60
+ sourceTurnId: string | null;
61
+ draftRev: number;
62
+ span: TokenSpan;
63
+ connectionGeneration: string;
64
+ routeKey: string;
65
+ }
66
+ export interface HistoryMessage {
67
+ role: 'user' | 'assistant';
68
+ text: string;
69
+ turnId?: string;
70
+ }
71
+ export interface AssistantStatus {
72
+ sourceTurnId: string | null;
73
+ running: boolean;
74
+ settings: AssistantConfig;
75
+ generation: string;
76
+ route?: ModelRoute;
77
+ }
78
+ export interface StoredDraft {
79
+ id: string;
80
+ text: string;
81
+ createdAt: number;
82
+ }
83
+ export interface DraftMutationResult {
84
+ drafts: StoredDraft[];
85
+ removed: StoredDraft[];
86
+ }
87
+ export declare const RPC_CHANNEL = "/api";
88
+ export declare const RPC_PREFIX = "input-assistant/";
89
+ export declare class AssistantError extends Error {
90
+ readonly code: string;
91
+ constructor(code: string, message: string);
92
+ }