@foggy-projects/deepseek-harness-plugin 0.4.2-rc.5 → 0.4.5-rc.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 +224 -185
- package/THIRD-PARTY-RUNTIME-NOTICES.md +16 -16
- package/cordis.patch.yml +6 -6
- package/docs/COMMUNITY-MARKETPLACES.md +64 -64
- package/docs/PUBLIC-BETA-READINESS.md +109 -109
- package/docs/RELEASE-CANDIDATE-0.4.0-RC.2.md +38 -38
- package/docs/RELEASE-CANDIDATE-0.4.0-RC.3.md +18 -18
- package/docs/RELEASE-CANDIDATE-0.4.1-DSH-0.1.5-RC.1.md +60 -60
- package/docs/RELEASE-CANDIDATE-0.4.2-DSH-0.1.7-RC.1.md +62 -62
- package/docs/RELEASE-CANDIDATE-0.4.2-DSH-0.1.7-RC.2.md +50 -50
- package/docs/RELEASE-CANDIDATE-0.4.2-DSH-0.1.7-RC.3.md +34 -34
- package/docs/RELEASE-CANDIDATE-0.4.2-DSH-0.1.7-RC.4.md +32 -32
- package/docs/RELEASE-CANDIDATE-0.4.2-DSH-0.1.7-RC.5.md +27 -27
- package/docs/RELEASE-CANDIDATE-0.4.3-DSH-0.2.0-RC.1.md +96 -0
- package/docs/RELEASE-CANDIDATE-0.4.4-DSH-0.2.1-RC.1.md +135 -0
- package/docs/RELEASE-CANDIDATE-0.4.5-DSH-0.2.2-RC.1.md +45 -0
- package/docs/WINDOWS-BETA-ACCEPTANCE.md +113 -113
- package/experience/linux/README.md +53 -53
- package/experience/linux/prepare.sh +4 -4
- package/lib/atomic-json.js +41 -41
- package/lib/client.js +1222 -1031
- package/lib/component-manager.js +164 -0
- package/lib/component-releases.js +363 -0
- package/lib/diagnostics.js +86 -86
- package/lib/index.js +764 -698
- package/lib/operation-lock.js +139 -0
- package/lib/python-runtime.js +339 -339
- package/lib/query-tool.js +134 -131
- package/lib/remote-descriptor.js +74 -59
- package/lib/remote.js +8 -8
- package/lib/runtime-settings.js +89 -89
- package/lib/skill-provider.js +116 -116
- package/lib/typert.js +9 -9
- package/lib/version.js +20 -20
- package/lib/viewer-preview.js +50 -27
- package/package.json +20 -16
- package/skills/foggy-deepseek-onboarding/SKILL.md +149 -143
- package/skills/foggy-deepseek-onboarding/assets/connection.schema.json +48 -48
- package/skills/foggy-deepseek-onboarding/assets/datasource.example.json +14 -14
- package/skills/foggy-deepseek-onboarding/assets/env.example +14 -14
- package/skills/foggy-deepseek-onboarding/assets/onboarding-state.schema.json +71 -71
- package/skills/foggy-deepseek-onboarding/assets/semantic-plan.example.json +8 -8
- package/skills/foggy-deepseek-onboarding/assets/semantic-plan.schema.json +21 -21
- package/skills/foggy-deepseek-onboarding/assets/versions.json +24 -24
- package/skills/foggy-deepseek-onboarding/references/onboarding-workflow.md +168 -168
- package/skills/foggy-deepseek-onboarding/scripts/doctor.ps1 +4 -4
- package/skills/foggy-deepseek-onboarding/scripts/install.ps1 +4 -4
- package/skills/foggy-deepseek-onboarding/scripts/invoke-onboarding.ps1 +32 -32
- package/skills/foggy-deepseek-onboarding/scripts/onboard.ps1 +4 -4
- package/skills/foggy-deepseek-onboarding/scripts/onboarding.py +3721 -3697
- package/skills/foggy-deepseek-onboarding/scripts/runtime-start.ps1 +4 -4
- package/skills/foggy-deepseek-onboarding/scripts/runtime-stop.ps1 +4 -4
- package/skills/foggy-deepseek-onboarding/scripts/uninstall.ps1 +4 -4
package/lib/index.js
CHANGED
|
@@ -1,698 +1,764 @@
|
|
|
1
|
-
import { execFile } from 'node:child_process'
|
|
2
|
-
import { access, mkdir, readFile, writeFile } from 'node:fs/promises'
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
updateAvailable,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const
|
|
267
|
-
const
|
|
268
|
-
const
|
|
269
|
-
const
|
|
270
|
-
const
|
|
271
|
-
const
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
:
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
'
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
const
|
|
447
|
-
if (
|
|
448
|
-
return this.startOperation('
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
const
|
|
531
|
-
|
|
532
|
-
return
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
async
|
|
536
|
-
const
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
const
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
const
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
operation
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
1
|
+
import { execFile } from 'node:child_process'
|
|
2
|
+
import { access, mkdir, readFile, writeFile, rm } from 'node:fs/promises'
|
|
3
|
+
import { randomUUID } from 'node:crypto'
|
|
4
|
+
import { constants as fsConstants } from 'node:fs'
|
|
5
|
+
import { dirname, join, delimiter } from 'node:path'
|
|
6
|
+
import { fileURLToPath } from 'node:url'
|
|
7
|
+
import { promisify } from 'node:util'
|
|
8
|
+
import { Remote, TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol'
|
|
9
|
+
import { createFoggySkillProvider } from './skill-provider.js'
|
|
10
|
+
import { writeJsonAtomic } from './atomic-json.js'
|
|
11
|
+
import { ensurePythonRuntime, probePythonRuntime } from './python-runtime.js'
|
|
12
|
+
import { compatible, compatibleNode } from './version.js'
|
|
13
|
+
import { enrichRuntimeStartFailure } from './diagnostics.js'
|
|
14
|
+
import { createFoggyQueryTool, managedConnection } from './query-tool.js'
|
|
15
|
+
import { createViewerPreview } from './viewer-preview.js'
|
|
16
|
+
import { componentVersions, effectiveComponentVersions, prepareComponentVersion, rememberInstalledComponents } from './component-manager.js'
|
|
17
|
+
import { withManagedOperationLock } from './operation-lock.js'
|
|
18
|
+
import {
|
|
19
|
+
DEFAULT_RUNTIME_PORT,
|
|
20
|
+
readRuntimeSettings,
|
|
21
|
+
writeRuntimeSettings,
|
|
22
|
+
} from './runtime-settings.js'
|
|
23
|
+
|
|
24
|
+
const execFileAsync = promisify(execFile)
|
|
25
|
+
const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)))
|
|
26
|
+
const onboardingScript = join(packageRoot, 'skills', 'foggy-deepseek-onboarding', 'scripts', 'onboarding.py')
|
|
27
|
+
const versionsFile = join(packageRoot, 'skills', 'foggy-deepseek-onboarding', 'assets', 'versions.json')
|
|
28
|
+
|
|
29
|
+
function defaultRoots() {
|
|
30
|
+
if (process.platform === 'win32') {
|
|
31
|
+
const base = process.env.LOCALAPPDATA
|
|
32
|
+
if (!base) throw new Error('LOCALAPPDATA is not set')
|
|
33
|
+
return {
|
|
34
|
+
installRoot: join(base, 'Foggy', 'DeepSeekHarness'),
|
|
35
|
+
dataRoot: join(base, 'Foggy', 'DeepSeekHarnessData'),
|
|
36
|
+
profileStore: process.env.FOGGY_RUNTIME_PROFILE_STORE || join(base, 'Foggy', 'DeepSeekHarnessData', 'cli-profiles'),
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const home = process.env.HOME
|
|
40
|
+
if (!home) throw new Error('HOME is not set')
|
|
41
|
+
const dataRoot = process.env.XDG_STATE_HOME
|
|
42
|
+
? join(process.env.XDG_STATE_HOME, 'foggy', 'deepseek-harness')
|
|
43
|
+
: join(home, '.local', 'state', 'foggy', 'deepseek-harness')
|
|
44
|
+
return {
|
|
45
|
+
installRoot: process.env.XDG_DATA_HOME
|
|
46
|
+
? join(process.env.XDG_DATA_HOME, 'foggy', 'deepseek-harness')
|
|
47
|
+
: join(home, '.local', 'share', 'foggy', 'deepseek-harness'),
|
|
48
|
+
dataRoot,
|
|
49
|
+
profileStore: process.env.FOGGY_RUNTIME_PROFILE_STORE || join(dataRoot, 'cli-profiles'),
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function componentReleaseState({ installed, installedVersion, targetVersion }) {
|
|
54
|
+
const normalizedInstalled = installedVersion || null
|
|
55
|
+
const normalizedTarget = targetVersion || null
|
|
56
|
+
const updateAvailable = Boolean(installed && normalizedInstalled && normalizedTarget && normalizedInstalled !== normalizedTarget)
|
|
57
|
+
return {
|
|
58
|
+
installed: Boolean(installed && !updateAvailable),
|
|
59
|
+
installedVersion: normalizedInstalled,
|
|
60
|
+
targetVersion: normalizedTarget,
|
|
61
|
+
updateAvailable,
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function exists(path) {
|
|
66
|
+
try {
|
|
67
|
+
await access(path, fsConstants.F_OK)
|
|
68
|
+
return true
|
|
69
|
+
} catch {
|
|
70
|
+
return false
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function readJson(path) {
|
|
75
|
+
return JSON.parse(await readFile(path, 'utf8'))
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function readOptionalJson(path) {
|
|
79
|
+
try {
|
|
80
|
+
return await readJson(path)
|
|
81
|
+
} catch {
|
|
82
|
+
return null
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function effectiveVersions(roots = defaultRoots()) {
|
|
87
|
+
return effectiveComponentVersions(await readJson(versionsFile), await readOptionalJson(join(roots.installRoot, 'install-state.json')))
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async function runtimeRunningUpdateGuard() {
|
|
91
|
+
const roots = defaultRoots()
|
|
92
|
+
const runtime = await readOptionalJson(join(roots.dataRoot, 'runtime-state.json'))
|
|
93
|
+
if (runtime && processRunning(Number(runtime.pid))) {
|
|
94
|
+
return {
|
|
95
|
+
success: false,
|
|
96
|
+
accepted: false,
|
|
97
|
+
error: {
|
|
98
|
+
code: 'RUNTIME_RUNNING_UPDATE_REQUIRES_STOP',
|
|
99
|
+
message: 'Stop Foggy Runtime before updating or repairing managed components.',
|
|
100
|
+
},
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return null
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async function commandVersion(command, args) {
|
|
107
|
+
try {
|
|
108
|
+
const { stdout, stderr } = await execFileAsync(command, args, {
|
|
109
|
+
windowsHide: true,
|
|
110
|
+
timeout: 15_000,
|
|
111
|
+
maxBuffer: 256 * 1024,
|
|
112
|
+
})
|
|
113
|
+
return { available: true, output: `${stdout}\n${stderr}`.trim().split(/\r?\n/)[0] ?? '' }
|
|
114
|
+
} catch (error) {
|
|
115
|
+
return { available: false, output: '', error: error.code ?? 'COMMAND_FAILED' }
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function parseOutput(stdout, stderr) {
|
|
120
|
+
const text = String(stdout ?? '').trim()
|
|
121
|
+
if (!text) throw new Error(String(stderr ?? '').trim() || 'Foggy onboarding returned no JSON')
|
|
122
|
+
try {
|
|
123
|
+
return JSON.parse(text)
|
|
124
|
+
} catch {
|
|
125
|
+
throw new Error(`Foggy onboarding returned invalid JSON: ${text.slice(0, 240)}`)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function withAssetCacheArguments(args, cacheDirs) {
|
|
130
|
+
if (args[0] !== 'install') return [...args]
|
|
131
|
+
return [...args, ...cacheDirs.flatMap((directory) => ['--asset-cache-dir', directory])]
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async function runOnboarding(args, timeout = 15 * 60_000, options = {}) {
|
|
135
|
+
const roots = defaultRoots()
|
|
136
|
+
const manifest = options.manifest || await effectiveVersions(roots)
|
|
137
|
+
const cacheDirs = (process.env.FOGGY_ASSET_CACHE_DIRS || '').split(delimiter).filter(Boolean)
|
|
138
|
+
const python = options.ensurePython
|
|
139
|
+
? await ensurePythonRuntime({
|
|
140
|
+
installRoot: roots.installRoot,
|
|
141
|
+
manifest,
|
|
142
|
+
cacheDirs,
|
|
143
|
+
force: options.forcePython,
|
|
144
|
+
onProgress: options.onPythonProgress,
|
|
145
|
+
})
|
|
146
|
+
: await probePythonRuntime({ installRoot: roots.installRoot, manifest })
|
|
147
|
+
if (!python.available) {
|
|
148
|
+
throw new Error('Foggy managed Python is unavailable; initialize or repair the Python component')
|
|
149
|
+
}
|
|
150
|
+
await options.flushPythonProgress?.()
|
|
151
|
+
const manifestPath = join(roots.dataRoot, 'operations', `${randomUUID()}.versions.json`)
|
|
152
|
+
await writeJsonAtomic(manifestPath, manifest)
|
|
153
|
+
try {
|
|
154
|
+
const { stdout, stderr } = await execFileAsync(python.path, [onboardingScript, ...args], {
|
|
155
|
+
windowsHide: true,
|
|
156
|
+
timeout,
|
|
157
|
+
maxBuffer: 4 * 1024 * 1024,
|
|
158
|
+
cwd: process.env.FOGGY_PROJECT_ROOT || process.cwd(),
|
|
159
|
+
env: {
|
|
160
|
+
...process.env,
|
|
161
|
+
FOGGY_ONBOARDING_PYTHON: python.path,
|
|
162
|
+
FOGGY_ONBOARDING_PYTHON_SOURCE: python.source,
|
|
163
|
+
FOGGY_ONBOARDING_VERSIONS_FILE: manifestPath,
|
|
164
|
+
},
|
|
165
|
+
})
|
|
166
|
+
const result = parseOutput(stdout, stderr)
|
|
167
|
+
if (args[0] === 'install' && result.success !== false) {
|
|
168
|
+
const warnings = await rememberInstalledComponents(roots, await readOptionalJson(join(roots.installRoot, 'install-state.json')))
|
|
169
|
+
if (warnings.length) result.warnings = [...(result.warnings || []), ...warnings]
|
|
170
|
+
}
|
|
171
|
+
return result
|
|
172
|
+
} catch (error) {
|
|
173
|
+
if (error.stdout) return parseOutput(error.stdout, error.stderr)
|
|
174
|
+
throw error
|
|
175
|
+
} finally {
|
|
176
|
+
await rm(manifestPath, { force: true }).catch(() => {})
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
async function assertSystemPrerequisites(kind) {
|
|
181
|
+
if (kind === 'initialize' && !compatibleNode(process.versions.node)) {
|
|
182
|
+
throw new Error(`This DeepSeek Harness plugin requires Node.js >=24.9.0; detected ${process.versions.node}`)
|
|
183
|
+
}
|
|
184
|
+
if (kind === 'initialize' || kind === 'runtime-start') {
|
|
185
|
+
const java = compatible(await commandVersion(process.env.JAVA_EXE || 'java', ['-version']), '17.0')
|
|
186
|
+
if (!java.available) throw new Error('Java 17+ is required; install a system JRE/JDK or set JAVA_EXE')
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function createPythonProgressReporter(operation, path) {
|
|
191
|
+
let pending = Promise.resolve()
|
|
192
|
+
const runtimeStart = operation.kind === 'runtime-start'
|
|
193
|
+
const totalSteps = runtimeStart ? 6 : 7
|
|
194
|
+
return {
|
|
195
|
+
update(detail) {
|
|
196
|
+
const fraction = Math.max(0, Math.min(1, Number(detail.fraction) || 0))
|
|
197
|
+
const payload = {
|
|
198
|
+
schemaVersion: 'foggy-deepseek-onboarding-progress/v1',
|
|
199
|
+
operationId: operation.id,
|
|
200
|
+
kind: operation.kind,
|
|
201
|
+
state: 'running',
|
|
202
|
+
phase: runtimeStart ? 'runtime-preflight' : 'python',
|
|
203
|
+
message: runtimeStart ? 'Preparing the Foggy Runtime controller' : detail.message || 'Preparing managed Python',
|
|
204
|
+
currentFile: detail.currentFile || null,
|
|
205
|
+
percent: runtimeStart ? Math.round(fraction * 3) : Math.round(((1 + fraction) / totalSteps) * 100),
|
|
206
|
+
step: { index: runtimeStart ? 1 : 2, total: totalSteps },
|
|
207
|
+
startedAt: operation.startedAt,
|
|
208
|
+
updatedAt: new Date().toISOString(),
|
|
209
|
+
}
|
|
210
|
+
if (detail.bytes) payload.bytes = detail.bytes
|
|
211
|
+
operation.progress = payload
|
|
212
|
+
pending = pending.then(() => writeJsonAtomic(path, payload))
|
|
213
|
+
},
|
|
214
|
+
flush() {
|
|
215
|
+
return pending
|
|
216
|
+
},
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function processRunning(pid) {
|
|
221
|
+
if (!Number.isInteger(pid) || pid <= 0) return false
|
|
222
|
+
try {
|
|
223
|
+
process.kill(pid, 0)
|
|
224
|
+
return true
|
|
225
|
+
} catch {
|
|
226
|
+
return false
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function operationView(operation) {
|
|
231
|
+
if (!operation) return { state: 'idle' }
|
|
232
|
+
const { promise: _promise, ...view } = operation
|
|
233
|
+
return view
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export class FoggyIntegrationGateway extends TypertRemoteService {
|
|
237
|
+
static inject = ['skills', 'tools']
|
|
238
|
+
|
|
239
|
+
operation = null
|
|
240
|
+
skillProviderControl = null
|
|
241
|
+
|
|
242
|
+
constructor(ctx) {
|
|
243
|
+
super(ctx, 'foggyIntegration')
|
|
244
|
+
this.viewerTools = ctx.tools
|
|
245
|
+
const roots = defaultRoots()
|
|
246
|
+
ctx.skills.registerProvider((control) => {
|
|
247
|
+
this.skillProviderControl = control
|
|
248
|
+
return createFoggySkillProvider({ installRoot: roots.installRoot, versionsFile })
|
|
249
|
+
})
|
|
250
|
+
ctx.tools.register(createFoggyQueryTool(roots))
|
|
251
|
+
for (const initialize of markerInitializers) initialize.call(this)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
async createViewerPreview(input) {
|
|
255
|
+
const roots = defaultRoots()
|
|
256
|
+
const runtime = await readOptionalJson(join(roots.dataRoot, 'runtime-state.json'))
|
|
257
|
+
const managedRuntime = runtime && processRunning(Number(runtime.pid))
|
|
258
|
+
? { runtimeUrl: runtime.runtimeUrl, securityMode: runtime.identity?.securityMode } : null
|
|
259
|
+
return createViewerPreview(input, this.viewerTools, managedRuntime)
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
async status() {
|
|
263
|
+
// A completed operation must not be combined with files read before it
|
|
264
|
+
// completed. Keeping the entry snapshot running guarantees one fresh poll.
|
|
265
|
+
let operation = operationView(this.operation)
|
|
266
|
+
const roots = defaultRoots()
|
|
267
|
+
const statePath = join(roots.installRoot, 'install-state.json')
|
|
268
|
+
const runtimeStatePath = join(roots.dataRoot, 'runtime-state.json')
|
|
269
|
+
const progressPath = join(roots.dataRoot, 'operation-progress.json')
|
|
270
|
+
const portConflictPath = join(roots.dataRoot, 'last-runtime-port-conflict.json')
|
|
271
|
+
const manifest = await effectiveVersions(roots)
|
|
272
|
+
const runtimeSettings = await readRuntimeSettings(roots.dataRoot, {
|
|
273
|
+
defaultPort: manifest.defaults?.port ?? DEFAULT_RUNTIME_PORT,
|
|
274
|
+
})
|
|
275
|
+
const python = await probePythonRuntime({ installRoot: roots.installRoot, manifest })
|
|
276
|
+
const java = compatible(await commandVersion(process.env.JAVA_EXE || 'java', ['-version']), '17.0')
|
|
277
|
+
let state = null
|
|
278
|
+
let runtime = null
|
|
279
|
+
let lastRuntimePortConflict = null
|
|
280
|
+
try { state = await readJson(statePath) } catch {}
|
|
281
|
+
try { runtime = await readJson(runtimeStatePath) } catch {}
|
|
282
|
+
try { lastRuntimePortConflict = await readJson(portConflictPath) } catch {}
|
|
283
|
+
let onboarding = { success: true, profiles: [], profileCount: 0 }
|
|
284
|
+
let profileMigration = { success: true, entries: [], pendingCount: 0, conflictCount: 0, profileStore: roots.profileStore }
|
|
285
|
+
if (state) {
|
|
286
|
+
try { onboarding = await runOnboarding(['onboard-list']) } catch (error) {
|
|
287
|
+
onboarding = { success: false, profiles: [], profileCount: 0, error: String(error.message ?? error) }
|
|
288
|
+
}
|
|
289
|
+
try { profileMigration = await runOnboarding(['profile-migration-status']) } catch (error) {
|
|
290
|
+
profileMigration = { success: false, entries: [], pendingCount: 0, conflictCount: 0, profileStore: roots.profileStore, error: String(error.message ?? error) }
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
const cliPath = state?.cli?.command
|
|
294
|
+
const launcherPath = state?.launcher?.path
|
|
295
|
+
const analysisSkillPath = state?.skills?.analysis?.path || join(roots.installRoot, 'skills', 'foggy-ai-analysis')
|
|
296
|
+
const semanticQuerySkillPath = state?.skills?.semanticQuery?.path || join(roots.installRoot, 'skills', 'foggy-semantic-query')
|
|
297
|
+
const onboardingSkillPath = join(packageRoot, 'skills', 'foggy-deepseek-onboarding')
|
|
298
|
+
const analysisMarker = await readOptionalJson(join(analysisSkillPath, '.foggy-managed-skill.json'))
|
|
299
|
+
const semanticQueryMarker = await readOptionalJson(join(semanticQuerySkillPath, '.foggy-managed-skill.json'))
|
|
300
|
+
const cliPresent = Boolean(cliPath && await exists(cliPath))
|
|
301
|
+
const launcherPresent = Boolean(launcherPath && await exists(launcherPath))
|
|
302
|
+
const analysisSkillPresent = await exists(join(analysisSkillPath, 'SKILL.md'))
|
|
303
|
+
&& analysisMarker?.schemaVersion === 'foggy-managed-skill/v1'
|
|
304
|
+
const semanticQuerySkillPresent = await exists(join(semanticQuerySkillPath, 'SKILL.md'))
|
|
305
|
+
&& semanticQueryMarker?.schemaVersion === 'foggy-managed-skill/v1'
|
|
306
|
+
const cliRelease = componentReleaseState({
|
|
307
|
+
installed: cliPresent,
|
|
308
|
+
installedVersion: state?.cli?.version,
|
|
309
|
+
targetVersion: manifest.components.cli.version,
|
|
310
|
+
})
|
|
311
|
+
const launcherRelease = componentReleaseState({
|
|
312
|
+
installed: launcherPresent,
|
|
313
|
+
installedVersion: state?.launcher?.version,
|
|
314
|
+
targetVersion: manifest.components.launcher.version,
|
|
315
|
+
})
|
|
316
|
+
const analysisRelease = componentReleaseState({
|
|
317
|
+
installed: analysisSkillPresent,
|
|
318
|
+
installedVersion: analysisMarker?.componentVersion || state?.skills?.analysis?.version,
|
|
319
|
+
targetVersion: manifest.components.analysisSkill.version,
|
|
320
|
+
})
|
|
321
|
+
const semanticQueryRelease = componentReleaseState({
|
|
322
|
+
installed: semanticQuerySkillPresent,
|
|
323
|
+
installedVersion: semanticQueryMarker?.componentVersion || state?.skills?.semanticQuery?.version,
|
|
324
|
+
targetVersion: manifest.components.semanticQuerySkill.version,
|
|
325
|
+
})
|
|
326
|
+
const components = {
|
|
327
|
+
python,
|
|
328
|
+
java,
|
|
329
|
+
cli: {
|
|
330
|
+
...cliRelease,
|
|
331
|
+
version: cliRelease.installedVersion ?? manifest.components.cli.version,
|
|
332
|
+
},
|
|
333
|
+
launcher: {
|
|
334
|
+
...launcherRelease,
|
|
335
|
+
version: launcherRelease.installedVersion ?? manifest.components.launcher.version,
|
|
336
|
+
},
|
|
337
|
+
analysisSkill: {
|
|
338
|
+
...analysisRelease,
|
|
339
|
+
version: analysisRelease.installedVersion ?? manifest.components.analysisSkill.version,
|
|
340
|
+
},
|
|
341
|
+
semanticQuerySkill: {
|
|
342
|
+
...semanticQueryRelease,
|
|
343
|
+
version: semanticQueryRelease.installedVersion ?? manifest.components.semanticQuerySkill.version,
|
|
344
|
+
},
|
|
345
|
+
onboardingSkill: {
|
|
346
|
+
installed: await exists(join(onboardingSkillPath, 'SKILL.md')),
|
|
347
|
+
version: manifest.packageVersion,
|
|
348
|
+
provider: 'foggy-managed-skills',
|
|
349
|
+
},
|
|
350
|
+
}
|
|
351
|
+
const installed = components.python.available
|
|
352
|
+
&& components.cli.installed
|
|
353
|
+
&& components.launcher.installed
|
|
354
|
+
&& components.analysisSkill.installed
|
|
355
|
+
&& components.semanticQuerySkill.installed
|
|
356
|
+
&& components.onboardingSkill.installed
|
|
357
|
+
const updateAvailable = Object.values(components).some((component) => component?.updateAvailable)
|
|
358
|
+
const running = Boolean(runtime && processRunning(Number(runtime.pid)))
|
|
359
|
+
const activePort = running && Number.isInteger(Number(runtime?.port)) ? Number(runtime.port) : null
|
|
360
|
+
const progress = await readOptionalJson(progressPath)
|
|
361
|
+
if (operation.state === 'running' && progress?.operationId === operation.id) {
|
|
362
|
+
operation = { ...operation, progress }
|
|
363
|
+
} else if (operation.state === 'idle' && progress?.state === 'running' && progress.operationId) {
|
|
364
|
+
operation = {
|
|
365
|
+
id: progress.operationId,
|
|
366
|
+
kind: progress.kind || 'initialize',
|
|
367
|
+
state: 'running',
|
|
368
|
+
startedAt: progress.startedAt || null,
|
|
369
|
+
finishedAt: null,
|
|
370
|
+
result: null,
|
|
371
|
+
error: null,
|
|
372
|
+
progress,
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return {
|
|
376
|
+
success: true,
|
|
377
|
+
packageVersion: manifest.packageVersion,
|
|
378
|
+
state: running ? 'running' : installed ? 'ready' : state ? 'degraded' : 'not-installed',
|
|
379
|
+
installed,
|
|
380
|
+
updateAvailable,
|
|
381
|
+
running,
|
|
382
|
+
runtimeUrl: running ? runtime.runtimeUrl ?? null : null,
|
|
383
|
+
runtimeSettings: {
|
|
384
|
+
...runtimeSettings,
|
|
385
|
+
activePort,
|
|
386
|
+
activeRuntimeUrl: running ? runtime.runtimeUrl ?? null : null,
|
|
387
|
+
pendingRestart: Boolean(running && activePort && activePort !== runtimeSettings.port),
|
|
388
|
+
lastConflict: lastRuntimePortConflict,
|
|
389
|
+
conflictApplies: Number(lastRuntimePortConflict?.port) === runtimeSettings.port,
|
|
390
|
+
},
|
|
391
|
+
roots,
|
|
392
|
+
components,
|
|
393
|
+
operation,
|
|
394
|
+
onboarding,
|
|
395
|
+
profileMigration,
|
|
396
|
+
next: !state
|
|
397
|
+
? 'initialize'
|
|
398
|
+
: updateAvailable
|
|
399
|
+
? 'update-components'
|
|
400
|
+
: installed
|
|
401
|
+
? (running ? 'configure-database' : 'start-runtime')
|
|
402
|
+
: 'repair',
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
async plan() {
|
|
407
|
+
const roots = defaultRoots()
|
|
408
|
+
const manifest = await effectiveVersions(roots)
|
|
409
|
+
return {
|
|
410
|
+
success: true,
|
|
411
|
+
roots,
|
|
412
|
+
workspaceMode: 'dsh-session-cwd',
|
|
413
|
+
versions: Object.fromEntries(Object.entries(manifest.components).map(([name, value]) => [name, value.version])),
|
|
414
|
+
operations: [
|
|
415
|
+
'download and verify a pinned private Python runtime',
|
|
416
|
+
'create isolated Python environment',
|
|
417
|
+
'download and verify pinned CLI and Launcher assets',
|
|
418
|
+
'install the Foggy analysis and semantic-query Skills into the global managed component directory',
|
|
419
|
+
'register onboarding, analysis, and semantic-query Skills through the native DSH Skill registry',
|
|
420
|
+
'write global install state; resolve each workspace from the DSH session cwd',
|
|
421
|
+
],
|
|
422
|
+
secretsInDshSettings: false,
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
async initialize() {
|
|
427
|
+
const blocked = await runtimeRunningUpdateGuard()
|
|
428
|
+
if (blocked) return blocked
|
|
429
|
+
return this.startOperation('initialize', false)
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
async componentVersions() {
|
|
433
|
+
const roots = defaultRoots()
|
|
434
|
+
return componentVersions({ roots, bundled: await readJson(versionsFile), state: await readOptionalJson(join(roots.installRoot, 'install-state.json')) })
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
async checkComponentVersions() {
|
|
438
|
+
const roots = defaultRoots()
|
|
439
|
+
return componentVersions({ roots, bundled: await readJson(versionsFile), state: await readOptionalJson(join(roots.installRoot, 'install-state.json')), force: true })
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
async useComponentVersion(input) {
|
|
443
|
+
const blocked = await runtimeRunningUpdateGuard()
|
|
444
|
+
if (blocked) return blocked
|
|
445
|
+
const roots = defaultRoots()
|
|
446
|
+
const state = await readOptionalJson(join(roots.installRoot, 'install-state.json'))
|
|
447
|
+
if (!state) return { success: false, accepted: false, error: { code: 'FOGGY_NOT_INITIALIZED', message: 'Initialize Foggy before selecting component versions.' } }
|
|
448
|
+
return this.startOperation('use-component-version', false, undefined, async ({ operation, progressPath, pythonProgress }) => {
|
|
449
|
+
if (!input || !['launcher', 'cli'].includes(input.component) || typeof input.version !== 'string') throw new Error('Select a valid Launcher or CLI version.')
|
|
450
|
+
const current = await readOptionalJson(join(roots.installRoot, 'install-state.json'))
|
|
451
|
+
if (!current) throw new Error('Initialize Foggy before selecting component versions.')
|
|
452
|
+
const manifest = await prepareComponentVersion({ roots, bundled: await readJson(versionsFile), state: current, ...input })
|
|
453
|
+
const running = await runtimeRunningUpdateGuard()
|
|
454
|
+
if (running) return running
|
|
455
|
+
return runOnboarding([
|
|
456
|
+
'install', '--install-root', roots.installRoot, '--data-root', roots.dataRoot,
|
|
457
|
+
'--progress-file', progressPath, '--operation-id', operation.id, '--operation-kind', operation.kind,
|
|
458
|
+
], 15 * 60_000, {
|
|
459
|
+
manifest, ensurePython: true,
|
|
460
|
+
onPythonProgress: (detail) => pythonProgress?.update(detail),
|
|
461
|
+
flushPythonProgress: () => pythonProgress?.flush(),
|
|
462
|
+
})
|
|
463
|
+
})
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
async initializeAndStart() {
|
|
467
|
+
const status = await this.status()
|
|
468
|
+
if (status.state !== 'not-installed') {
|
|
469
|
+
return {
|
|
470
|
+
success: false,
|
|
471
|
+
accepted: false,
|
|
472
|
+
error: { code: 'FOGGY_ALREADY_INITIALIZED', message: 'Foggy is already initialized; use Start Runtime or Update components.' },
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
return this.startOperation('initialize-and-start', false, undefined, async ({ operation, progressPath, pythonProgress }) => {
|
|
476
|
+
await assertSystemPrerequisites('initialize')
|
|
477
|
+
const cacheArgs = (process.env.FOGGY_ASSET_CACHE_DIRS || '').split(delimiter).filter(Boolean)
|
|
478
|
+
.flatMap((cacheDir) => ['--asset-cache-dir', cacheDir])
|
|
479
|
+
const install = await runOnboarding([
|
|
480
|
+
'install', '--progress-file', progressPath, '--operation-id', operation.id, '--operation-kind', 'initialize',
|
|
481
|
+
...cacheArgs,
|
|
482
|
+
], 15 * 60_000, {
|
|
483
|
+
ensurePython: true,
|
|
484
|
+
onPythonProgress: (detail) => pythonProgress?.update(detail),
|
|
485
|
+
flushPythonProgress: () => pythonProgress?.flush(),
|
|
486
|
+
})
|
|
487
|
+
if (install.success === false) return install
|
|
488
|
+
|
|
489
|
+
await assertSystemPrerequisites('runtime-start')
|
|
490
|
+
const roots = defaultRoots()
|
|
491
|
+
const manifest = await readJson(versionsFile)
|
|
492
|
+
const settings = await readRuntimeSettings(roots.dataRoot, {
|
|
493
|
+
defaultPort: manifest.defaults?.port ?? DEFAULT_RUNTIME_PORT,
|
|
494
|
+
})
|
|
495
|
+
if (!settings.valid) {
|
|
496
|
+
return {
|
|
497
|
+
success: false,
|
|
498
|
+
error: { code: 'RUNTIME_SETTINGS_INVALID', message: `Runtime settings are invalid: ${settings.error}` },
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
return runOnboarding([
|
|
502
|
+
'runtime-start', '--install-root', roots.installRoot, '--data-root', roots.dataRoot,
|
|
503
|
+
'--port', String(settings.port), '--progress-file', progressPath, '--operation-id', operation.id,
|
|
504
|
+
'--operation-kind', 'runtime-start',
|
|
505
|
+
], 15 * 60_000, { ensurePython: false })
|
|
506
|
+
})
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
async repair() {
|
|
510
|
+
const blocked = await runtimeRunningUpdateGuard()
|
|
511
|
+
if (blocked) return blocked
|
|
512
|
+
return this.startOperation('repair', true)
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
async updateComponents() {
|
|
516
|
+
const blocked = await runtimeRunningUpdateGuard()
|
|
517
|
+
if (blocked) return blocked
|
|
518
|
+
const status = await this.status()
|
|
519
|
+
if (status.state === 'not-installed') {
|
|
520
|
+
return {
|
|
521
|
+
success: false,
|
|
522
|
+
accepted: false,
|
|
523
|
+
error: { code: 'FOGGY_NOT_INITIALIZED', message: 'Initialize Foggy before updating managed components.' },
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
return this.startOperation('update-components', true)
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
async repairCli() {
|
|
530
|
+
const blocked = await runtimeRunningUpdateGuard()
|
|
531
|
+
if (blocked) return blocked
|
|
532
|
+
return this.startOperation('repair-cli', false, ['install', '--repair-component', 'cli'])
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
async repairPython() {
|
|
536
|
+
const blocked = await runtimeRunningUpdateGuard()
|
|
537
|
+
if (blocked) return blocked
|
|
538
|
+
return this.startOperation('repair-python', false, ['install'])
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
async repairLauncher() {
|
|
542
|
+
const blocked = await runtimeRunningUpdateGuard()
|
|
543
|
+
if (blocked) return blocked
|
|
544
|
+
return this.startOperation('repair-launcher', false, ['install', '--repair-component', 'launcher'])
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
async repairAnalysisSkill() {
|
|
548
|
+
const blocked = await runtimeRunningUpdateGuard()
|
|
549
|
+
if (blocked) return blocked
|
|
550
|
+
return this.startOperation('repair-analysis-skill', true, ['install', '--repair-component', 'analysis-skill'])
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
async repairSemanticQuerySkill() {
|
|
554
|
+
const blocked = await runtimeRunningUpdateGuard()
|
|
555
|
+
if (blocked) return blocked
|
|
556
|
+
return this.startOperation('repair-semantic-query-skill', true, ['install', '--repair-component', 'semantic-query-skill'])
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
async migrateProfiles() {
|
|
560
|
+
return this.startOperation('profile-migration', false, ['profile-migrate', '--approve'])
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
async diagnostics() {
|
|
564
|
+
const roots = defaultRoots()
|
|
565
|
+
const status = await this.status()
|
|
566
|
+
const lastRuntimeStartFailure = await enrichRuntimeStartFailure(
|
|
567
|
+
await readOptionalJson(join(roots.dataRoot, 'last-runtime-start-failure.json')),
|
|
568
|
+
roots.dataRoot,
|
|
569
|
+
)
|
|
570
|
+
let doctor
|
|
571
|
+
try {
|
|
572
|
+
doctor = await runOnboarding(['doctor', '--no-fail'])
|
|
573
|
+
} catch (error) {
|
|
574
|
+
doctor = { success: false, error: String(error.message ?? error), bootstrapOnly: true }
|
|
575
|
+
}
|
|
576
|
+
const report = {
|
|
577
|
+
schemaVersion: 'foggy-deepseek-diagnostics/v1',
|
|
578
|
+
generatedAt: new Date().toISOString(),
|
|
579
|
+
packageVersion: status.packageVersion,
|
|
580
|
+
state: status.state,
|
|
581
|
+
installed: status.installed,
|
|
582
|
+
running: status.running,
|
|
583
|
+
runtimeUrl: status.runtimeUrl,
|
|
584
|
+
roots: status.roots,
|
|
585
|
+
components: status.components,
|
|
586
|
+
onboarding: status.onboarding,
|
|
587
|
+
profileMigration: status.profileMigration,
|
|
588
|
+
runtimeSettings: status.runtimeSettings,
|
|
589
|
+
lastRuntimeStartFailure,
|
|
590
|
+
doctor,
|
|
591
|
+
}
|
|
592
|
+
const directory = join(roots.dataRoot, 'diagnostics')
|
|
593
|
+
await mkdir(directory, { recursive: true })
|
|
594
|
+
const path = join(directory, `diagnostics-${Date.now()}.json`)
|
|
595
|
+
await writeFile(path, `${JSON.stringify(report, null, 2)}\n`, { encoding: 'utf8', mode: 0o600 })
|
|
596
|
+
return { success: true, path, report }
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
async runtimeStart() {
|
|
600
|
+
const roots = defaultRoots()
|
|
601
|
+
const manifest = await readJson(versionsFile)
|
|
602
|
+
const settings = await readRuntimeSettings(roots.dataRoot, {
|
|
603
|
+
defaultPort: manifest.defaults?.port ?? DEFAULT_RUNTIME_PORT,
|
|
604
|
+
})
|
|
605
|
+
if (!settings.valid) {
|
|
606
|
+
return {
|
|
607
|
+
success: false,
|
|
608
|
+
accepted: false,
|
|
609
|
+
error: {
|
|
610
|
+
code: 'RUNTIME_SETTINGS_INVALID',
|
|
611
|
+
message: `Runtime settings are invalid: ${settings.error}. Save a valid port in Foggy plugin settings.`,
|
|
612
|
+
},
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return this.startOperation('runtime-start', false, [
|
|
616
|
+
'runtime-start', '--install-root', roots.installRoot, '--data-root', roots.dataRoot,
|
|
617
|
+
'--port', String(settings.port),
|
|
618
|
+
])
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
async runtimeStop() {
|
|
622
|
+
const roots = defaultRoots()
|
|
623
|
+
return this.startOperation('runtime-stop', false, [
|
|
624
|
+
'runtime-stop', '--install-root', roots.installRoot, '--data-root', roots.dataRoot,
|
|
625
|
+
])
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
async saveRuntimeSettings(input) {
|
|
629
|
+
const roots = defaultRoots()
|
|
630
|
+
if (this.operation?.state === 'running') {
|
|
631
|
+
return {
|
|
632
|
+
success: false,
|
|
633
|
+
error: { code: 'OPERATION_RUNNING', message: 'Wait for the current Foggy operation to finish before changing the Runtime port.' },
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
const runtime = await readOptionalJson(join(roots.dataRoot, 'runtime-state.json'))
|
|
637
|
+
if (runtime && processRunning(Number(runtime.pid))) {
|
|
638
|
+
return {
|
|
639
|
+
success: false,
|
|
640
|
+
error: { code: 'RUNTIME_RUNNING', message: 'Stop Foggy Runtime before changing its port.' },
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
try {
|
|
644
|
+
const settings = await writeRuntimeSettings(roots.dataRoot, input)
|
|
645
|
+
if (this.operation?.state === 'failed' && this.operation.result?.error?.code === 'RUNTIME_PORT_UNAVAILABLE') {
|
|
646
|
+
this.operation = null
|
|
647
|
+
}
|
|
648
|
+
return { success: true, settings }
|
|
649
|
+
} catch (error) {
|
|
650
|
+
return {
|
|
651
|
+
success: false,
|
|
652
|
+
error: { code: 'RUNTIME_PORT_INVALID', message: String(error?.message ?? error) },
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
startOperation(kind, replaceSkill, explicitArgs, runner = null) {
|
|
658
|
+
if (this.operation?.state === 'running') {
|
|
659
|
+
return { success: false, accepted: false, operation: operationView(this.operation), error: 'another Foggy operation is running' }
|
|
660
|
+
}
|
|
661
|
+
const id = `${Date.now()}-${Math.random().toString(16).slice(2, 10)}`
|
|
662
|
+
const args = withAssetCacheArguments(explicitArgs ?? ['install'], (process.env.FOGGY_ASSET_CACHE_DIRS || '').split(delimiter).filter(Boolean))
|
|
663
|
+
const reportsProgress = args[0] === 'install' || args[0] === 'runtime-start' || runner !== null
|
|
664
|
+
const progressPath = reportsProgress ? join(defaultRoots().dataRoot, 'operation-progress.json') : null
|
|
665
|
+
if (reportsProgress) {
|
|
666
|
+
args.push('--progress-file', progressPath, '--operation-id', id, '--operation-kind', kind)
|
|
667
|
+
}
|
|
668
|
+
if (replaceSkill) args.push('--replace-skill')
|
|
669
|
+
const runtimeStart = kind === 'runtime-start' || kind.endsWith('-and-start')
|
|
670
|
+
const operation = {
|
|
671
|
+
id,
|
|
672
|
+
kind,
|
|
673
|
+
state: 'running',
|
|
674
|
+
startedAt: new Date().toISOString(),
|
|
675
|
+
finishedAt: null,
|
|
676
|
+
result: null,
|
|
677
|
+
error: null,
|
|
678
|
+
progress: reportsProgress ? {
|
|
679
|
+
schemaVersion: 'foggy-deepseek-onboarding-progress/v1',
|
|
680
|
+
operationId: id,
|
|
681
|
+
kind,
|
|
682
|
+
state: 'running',
|
|
683
|
+
phase: 'preflight',
|
|
684
|
+
message: runtimeStart ? 'Starting Foggy Runtime' : 'Starting Foggy initialization',
|
|
685
|
+
currentFile: null,
|
|
686
|
+
percent: 0,
|
|
687
|
+
step: { index: 1, total: runtimeStart ? 6 : 7 },
|
|
688
|
+
} : null,
|
|
689
|
+
promise: null,
|
|
690
|
+
}
|
|
691
|
+
const pythonProgress = reportsProgress
|
|
692
|
+
? createPythonProgressReporter(operation, progressPath)
|
|
693
|
+
: null
|
|
694
|
+
operation.promise = withManagedOperationLock(defaultRoots().dataRoot, async () => {
|
|
695
|
+
if (args[0] === 'install' || kind === 'initialize-and-start' || kind === 'use-component-version') {
|
|
696
|
+
const blocked = await runtimeRunningUpdateGuard()
|
|
697
|
+
if (blocked) return blocked
|
|
698
|
+
}
|
|
699
|
+
await assertSystemPrerequisites(kind)
|
|
700
|
+
if (runner) return runner({ operation, progressPath, pythonProgress })
|
|
701
|
+
return runOnboarding(args, 15 * 60_000, {
|
|
702
|
+
ensurePython: true,
|
|
703
|
+
forcePython: kind === 'repair-python',
|
|
704
|
+
onPythonProgress: (detail) => pythonProgress?.update(detail),
|
|
705
|
+
flushPythonProgress: () => pythonProgress?.flush(),
|
|
706
|
+
})
|
|
707
|
+
}, { kind })
|
|
708
|
+
.then((result) => {
|
|
709
|
+
operation.state = result.success === false ? 'failed' : 'succeeded'
|
|
710
|
+
operation.result = result
|
|
711
|
+
operation.finishedAt = new Date().toISOString()
|
|
712
|
+
this.skillProviderControl?.invalidate()
|
|
713
|
+
if (operation.progress) {
|
|
714
|
+
operation.progress = {
|
|
715
|
+
...operation.progress,
|
|
716
|
+
state: operation.state,
|
|
717
|
+
phase: operation.state === 'succeeded' ? (runtimeStart ? 'runtime-complete' : 'complete') : operation.progress.phase,
|
|
718
|
+
message: operation.state === 'succeeded'
|
|
719
|
+
? (runtimeStart ? 'Foggy Runtime is ready' : 'Foggy initialization completed')
|
|
720
|
+
: (runtimeStart ? 'Foggy Runtime startup failed' : 'Foggy initialization failed'),
|
|
721
|
+
percent: operation.state === 'succeeded' ? 100 : operation.progress.percent,
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
})
|
|
725
|
+
.catch((error) => {
|
|
726
|
+
operation.state = 'failed'
|
|
727
|
+
operation.error = String(error.message ?? error)
|
|
728
|
+
operation.finishedAt = new Date().toISOString()
|
|
729
|
+
this.skillProviderControl?.invalidate()
|
|
730
|
+
if (operation.progress) {
|
|
731
|
+
operation.progress = {
|
|
732
|
+
...operation.progress,
|
|
733
|
+
state: 'failed',
|
|
734
|
+
message: runtimeStart ? 'Foggy Runtime startup failed' : 'Foggy initialization failed',
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
})
|
|
738
|
+
this.operation = operation
|
|
739
|
+
return { success: true, accepted: true, operation: operationView(operation) }
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
const markerInitializers = []
|
|
744
|
+
for (const method of [
|
|
745
|
+
'status', 'plan', 'initialize', 'initializeAndStart', 'repair', 'updateComponents', 'repairPython', 'repairCli', 'repairLauncher', 'repairAnalysisSkill', 'repairSemanticQuerySkill',
|
|
746
|
+
'migrateProfiles', 'diagnostics', 'runtimeStart', 'runtimeStop',
|
|
747
|
+
'saveRuntimeSettings',
|
|
748
|
+
'createViewerPreview',
|
|
749
|
+
'componentVersions', 'checkComponentVersions', 'useComponentVersion',
|
|
750
|
+
]) {
|
|
751
|
+
Remote(method)(FoggyIntegrationGateway.prototype[method], {
|
|
752
|
+
kind: 'method',
|
|
753
|
+
name: method,
|
|
754
|
+
static: false,
|
|
755
|
+
private: false,
|
|
756
|
+
access: {
|
|
757
|
+
has: (object) => method in object,
|
|
758
|
+
get: (object) => object[method],
|
|
759
|
+
},
|
|
760
|
+
addInitializer: (initializer) => markerInitializers.push(initializer),
|
|
761
|
+
})
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
export default FoggyIntegrationGateway
|