@finogeeks2026/finshield-kilo 0.0.0-stage → 0.11.1-debug.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/LICENSE.rtf +28 -0
- package/README-zh.md +52 -0
- package/README.md +185 -3
- package/THIRD-PARTY-NOTICES.md +212 -0
- package/bin/finshield_kilo_native.dll +0 -0
- package/install/download-source.json +3 -0
- package/install/runtime.js +138 -0
- package/package.json +67 -6
- package/policy/candidate.yaml +364 -0
- package/src/activation.js +75 -0
- package/src/arguments.mjs +32 -0
- package/src/connector.js +91 -0
- package/src/handoff.mjs +26 -0
- package/src/known-folders.mjs +20 -0
- package/src/lifecycle-settings.mjs +29 -0
- package/src/management.mjs +113 -0
- package/src/native.mjs +112 -0
- package/src/options.mjs +23 -0
- package/src/preparation.js +55 -0
- package/src/tui.mjs +42 -0
- package/updater/coordinator.js +296 -0
- package/updater/host.mjs +89 -0
- package/updater/native.js +28 -0
- package/updater/protocol.js +40 -0
- package/updater/server.mjs +143 -0
package/package.json
CHANGED
|
@@ -1,6 +1,67 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@finogeeks2026/finshield-kilo",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@finogeeks2026/finshield-kilo",
|
|
3
|
+
"version": "0.11.1-debug.1",
|
|
4
|
+
"description": "FinShield lifecycle and AppContainer protection for the Windows Kilo CLI",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "SEE LICENSE IN LICENSE.rtf",
|
|
7
|
+
"homepage": "https://finaios.ai/zh-hans/products/finshield/",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/finogeeks/finsafe.git",
|
|
11
|
+
"directory": "integrations/kilo/windows"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
"./tui": "./src/tui.mjs",
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"src/tui.mjs",
|
|
19
|
+
"src/lifecycle-settings.mjs",
|
|
20
|
+
"src/management.mjs",
|
|
21
|
+
"src/activation.js",
|
|
22
|
+
"src/known-folders.mjs",
|
|
23
|
+
"src/native.mjs",
|
|
24
|
+
"src/options.mjs",
|
|
25
|
+
"src/arguments.mjs",
|
|
26
|
+
"src/handoff.mjs",
|
|
27
|
+
"src/connector.js",
|
|
28
|
+
"src/preparation.js",
|
|
29
|
+
"updater",
|
|
30
|
+
"install",
|
|
31
|
+
"bin/finshield_kilo_native.dll",
|
|
32
|
+
"policy/candidate.yaml",
|
|
33
|
+
"README.md",
|
|
34
|
+
"README-zh.md",
|
|
35
|
+
"LICENSE.rtf",
|
|
36
|
+
"THIRD-PARTY-NOTICES.md"
|
|
37
|
+
],
|
|
38
|
+
"os": [
|
|
39
|
+
"win32"
|
|
40
|
+
],
|
|
41
|
+
"cpu": [
|
|
42
|
+
"x64"
|
|
43
|
+
],
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=22"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"koffi": "3.3.8"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"test": "node --test test/*.test.mjs",
|
|
52
|
+
"build:policy": "finsafe config resolve --manifest ../../../windows/config/kilo-plugin/manifest.yaml --output policy/candidate.yaml",
|
|
53
|
+
"build:runtime": "python build-runtime.py",
|
|
54
|
+
"build:native": "python build-native.py",
|
|
55
|
+
"prepack": "python build-runtime.py --check && node check-package.mjs"
|
|
56
|
+
},
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"access": "public",
|
|
59
|
+
"registry": "https://registry.npmjs.org/"
|
|
60
|
+
},
|
|
61
|
+
"bugs": {
|
|
62
|
+
"url": "https://github.com/finogeeks/finsafe/issues"
|
|
63
|
+
},
|
|
64
|
+
"finshield": {
|
|
65
|
+
"nativeVersion": "0.11.1"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
schema_version: 1
|
|
2
|
+
platform: windows
|
|
3
|
+
security_domain_id: finsafe.kilo
|
|
4
|
+
integrations: []
|
|
5
|
+
policy:
|
|
6
|
+
filesystem_coverage:
|
|
7
|
+
root: read_write
|
|
8
|
+
rules:
|
|
9
|
+
- id: host-recycle-bin
|
|
10
|
+
source: windows_mandatory
|
|
11
|
+
path: $Recycle.Bin
|
|
12
|
+
access: host
|
|
13
|
+
lifecycle: existing
|
|
14
|
+
inheritance: descendants
|
|
15
|
+
filesystem:
|
|
16
|
+
- id: kilo-cli-install-root
|
|
17
|
+
source: kilo_compatibility
|
|
18
|
+
path: ${KILO_CLI_INSTALL_ROOT}
|
|
19
|
+
access: read_only
|
|
20
|
+
lifecycle: existing
|
|
21
|
+
inheritance: descendants
|
|
22
|
+
- id: kilo-plugin-install-root
|
|
23
|
+
source: kilo_compatibility
|
|
24
|
+
path: ${KILO_PLUGIN_INSTALL_ROOT}
|
|
25
|
+
access: read_only
|
|
26
|
+
lifecycle: existing
|
|
27
|
+
inheritance: descendants
|
|
28
|
+
- id: kilo-plugin-runtime-root
|
|
29
|
+
source: kilo_compatibility
|
|
30
|
+
path: ${KILO_PLUGIN_RUNTIME_ROOT}
|
|
31
|
+
access: read_only
|
|
32
|
+
lifecycle: existing
|
|
33
|
+
inheritance: descendants
|
|
34
|
+
- id: kilo-temp
|
|
35
|
+
source: kilo_compatibility
|
|
36
|
+
path: ${TEMP}\kilo
|
|
37
|
+
access: read_write
|
|
38
|
+
lifecycle: prepare_created
|
|
39
|
+
inheritance: descendants
|
|
40
|
+
- id: kilo-cache
|
|
41
|
+
source: kilo_compatibility
|
|
42
|
+
path: ${USERPROFILE}\.cache\kilo
|
|
43
|
+
access: read_write
|
|
44
|
+
lifecycle: prepare_created
|
|
45
|
+
inheritance: descendants
|
|
46
|
+
- id: kilo-config
|
|
47
|
+
source: kilo_compatibility
|
|
48
|
+
path: ${USERPROFILE}\.config\kilo
|
|
49
|
+
access: read_write
|
|
50
|
+
lifecycle: prepare_created
|
|
51
|
+
inheritance: descendants
|
|
52
|
+
- id: kilo-home
|
|
53
|
+
source: kilo_compatibility
|
|
54
|
+
path: ${USERPROFILE}\.kilo
|
|
55
|
+
access: read_write
|
|
56
|
+
lifecycle: prepare_created
|
|
57
|
+
inheritance: descendants
|
|
58
|
+
- id: kilocode-home
|
|
59
|
+
source: kilo_compatibility
|
|
60
|
+
path: ${USERPROFILE}\.kilocode
|
|
61
|
+
access: read_write
|
|
62
|
+
lifecycle: prepare_created
|
|
63
|
+
inheritance: descendants
|
|
64
|
+
- id: kilo-data
|
|
65
|
+
source: kilo_compatibility
|
|
66
|
+
path: ${USERPROFILE}\.local\share\kilo
|
|
67
|
+
access: read_write
|
|
68
|
+
lifecycle: prepare_created
|
|
69
|
+
inheritance: descendants
|
|
70
|
+
- id: kilo-state
|
|
71
|
+
source: kilo_compatibility
|
|
72
|
+
path: ${USERPROFILE}\.local\state\kilo
|
|
73
|
+
access: read_write
|
|
74
|
+
lifecycle: prepare_created
|
|
75
|
+
inheritance: descendants
|
|
76
|
+
- id: deny-360se-profile
|
|
77
|
+
source: windows_mandatory
|
|
78
|
+
path: ${APPDATA}\360se6\User Data
|
|
79
|
+
access: deny
|
|
80
|
+
lifecycle: existing
|
|
81
|
+
inheritance: descendants
|
|
82
|
+
- id: deny-bitwarden-desktop
|
|
83
|
+
source: windows_mandatory
|
|
84
|
+
path: ${APPDATA}\Bitwarden
|
|
85
|
+
access: deny
|
|
86
|
+
lifecycle: existing
|
|
87
|
+
inheritance: descendants
|
|
88
|
+
- id: deny-bitwarden-cli
|
|
89
|
+
source: windows_mandatory
|
|
90
|
+
path: ${APPDATA}\Bitwarden CLI
|
|
91
|
+
access: deny
|
|
92
|
+
lifecycle: existing
|
|
93
|
+
inheritance: descendants
|
|
94
|
+
- id: deny-dingtalk-state
|
|
95
|
+
source: windows_mandatory
|
|
96
|
+
path: ${APPDATA}\DingTalk
|
|
97
|
+
access: deny
|
|
98
|
+
lifecycle: existing
|
|
99
|
+
inheritance: descendants
|
|
100
|
+
- id: deny-gcloud
|
|
101
|
+
source: windows_mandatory
|
|
102
|
+
path: ${APPDATA}\gcloud
|
|
103
|
+
access: deny
|
|
104
|
+
lifecycle: existing
|
|
105
|
+
inheritance: descendants
|
|
106
|
+
- id: deny-gh
|
|
107
|
+
source: windows_mandatory
|
|
108
|
+
path: ${APPDATA}\GitHub CLI
|
|
109
|
+
access: deny
|
|
110
|
+
lifecycle: existing
|
|
111
|
+
inheritance: descendants
|
|
112
|
+
- id: deny-feishu-roaming-state
|
|
113
|
+
source: windows_mandatory
|
|
114
|
+
path: ${APPDATA}\LarkShell
|
|
115
|
+
access: deny
|
|
116
|
+
lifecycle: existing
|
|
117
|
+
inheritance: descendants
|
|
118
|
+
- id: readonly-roaming-microsoft
|
|
119
|
+
source: windows_mandatory
|
|
120
|
+
path: ${APPDATA}\Microsoft
|
|
121
|
+
access: read_only
|
|
122
|
+
lifecycle: existing
|
|
123
|
+
inheritance: descendants
|
|
124
|
+
- id: deny-teams-classic
|
|
125
|
+
source: windows_mandatory
|
|
126
|
+
path: ${APPDATA}\Microsoft\Teams
|
|
127
|
+
access: deny
|
|
128
|
+
lifecycle: existing
|
|
129
|
+
inheritance: descendants
|
|
130
|
+
- id: deny-firefox-profiles
|
|
131
|
+
source: windows_mandatory
|
|
132
|
+
path: ${APPDATA}\Mozilla\Firefox\Profiles
|
|
133
|
+
access: deny
|
|
134
|
+
lifecycle: existing
|
|
135
|
+
inheritance: descendants
|
|
136
|
+
- id: deny-opera-profile
|
|
137
|
+
source: windows_mandatory
|
|
138
|
+
path: ${APPDATA}\Opera Software\Opera Stable
|
|
139
|
+
access: deny
|
|
140
|
+
lifecycle: existing
|
|
141
|
+
inheritance: descendants
|
|
142
|
+
- id: deny-signal-desktop
|
|
143
|
+
source: windows_mandatory
|
|
144
|
+
path: ${APPDATA}\Signal
|
|
145
|
+
access: deny
|
|
146
|
+
lifecycle: existing
|
|
147
|
+
inheritance: descendants
|
|
148
|
+
- id: deny-slack-desktop
|
|
149
|
+
source: windows_mandatory
|
|
150
|
+
path: ${APPDATA}\slack
|
|
151
|
+
access: deny
|
|
152
|
+
lifecycle: existing
|
|
153
|
+
inheritance: descendants
|
|
154
|
+
- id: deny-qq-state
|
|
155
|
+
source: windows_mandatory
|
|
156
|
+
path: ${APPDATA}\Tencent\QQ
|
|
157
|
+
access: deny
|
|
158
|
+
lifecycle: existing
|
|
159
|
+
inheritance: descendants
|
|
160
|
+
- id: deny-qqnt-state
|
|
161
|
+
source: windows_mandatory
|
|
162
|
+
path: ${APPDATA}\Tencent\QQNT
|
|
163
|
+
access: deny
|
|
164
|
+
lifecycle: existing
|
|
165
|
+
inheritance: descendants
|
|
166
|
+
- id: deny-wechat3-state
|
|
167
|
+
source: windows_mandatory
|
|
168
|
+
path: ${APPDATA}\Tencent\WeChat
|
|
169
|
+
access: deny
|
|
170
|
+
lifecycle: existing
|
|
171
|
+
inheritance: descendants
|
|
172
|
+
- id: deny-wecom-state
|
|
173
|
+
source: windows_mandatory
|
|
174
|
+
path: ${APPDATA}\Tencent\WXWork
|
|
175
|
+
access: deny
|
|
176
|
+
lifecycle: existing
|
|
177
|
+
inheritance: descendants
|
|
178
|
+
- id: deny-wechat4-state
|
|
179
|
+
source: windows_mandatory
|
|
180
|
+
path: ${APPDATA}\Tencent\xwechat
|
|
181
|
+
access: deny
|
|
182
|
+
lifecycle: existing
|
|
183
|
+
inheritance: descendants
|
|
184
|
+
- id: deny-thunderbird-profiles
|
|
185
|
+
source: windows_mandatory
|
|
186
|
+
path: ${APPDATA}\Thunderbird\Profiles
|
|
187
|
+
access: deny
|
|
188
|
+
lifecycle: existing
|
|
189
|
+
inheritance: descendants
|
|
190
|
+
- id: finsafe-config
|
|
191
|
+
source: windows_mandatory
|
|
192
|
+
path: ${FINSAFE_CONFIG_DIR}
|
|
193
|
+
access: read_only
|
|
194
|
+
lifecycle: existing
|
|
195
|
+
inheritance: descendants
|
|
196
|
+
- id: finsafe-install
|
|
197
|
+
source: windows_mandatory
|
|
198
|
+
path: ${FINSAFE_INSTALL_DIR}
|
|
199
|
+
access: read_only
|
|
200
|
+
lifecycle: existing
|
|
201
|
+
inheritance: descendants
|
|
202
|
+
- id: deny-360chromex-profile
|
|
203
|
+
source: windows_mandatory
|
|
204
|
+
path: ${LOCALAPPDATA}\360ChromeX\Chrome\User Data
|
|
205
|
+
access: deny
|
|
206
|
+
lifecycle: existing
|
|
207
|
+
inheritance: descendants
|
|
208
|
+
- id: deny-brave-profile
|
|
209
|
+
source: windows_mandatory
|
|
210
|
+
path: ${LOCALAPPDATA}\BraveSoftware\Brave-Browser\User Data
|
|
211
|
+
access: deny
|
|
212
|
+
lifecycle: existing
|
|
213
|
+
inheritance: descendants
|
|
214
|
+
- id: deny-feishu-profile
|
|
215
|
+
source: windows_mandatory
|
|
216
|
+
path: ${LOCALAPPDATA}\Feishu\User Data
|
|
217
|
+
access: deny
|
|
218
|
+
lifecycle: existing
|
|
219
|
+
inheritance: descendants
|
|
220
|
+
- id: finsafe-root
|
|
221
|
+
source: windows_mandatory
|
|
222
|
+
path: ${LOCALAPPDATA}\FinSAFE
|
|
223
|
+
access: read_only
|
|
224
|
+
lifecycle: prepare_created
|
|
225
|
+
inheritance: descendants
|
|
226
|
+
- id: deny-chrome-profile
|
|
227
|
+
source: windows_mandatory
|
|
228
|
+
path: ${LOCALAPPDATA}\Google\Chrome\User Data
|
|
229
|
+
access: deny
|
|
230
|
+
lifecycle: existing
|
|
231
|
+
inheritance: descendants
|
|
232
|
+
- id: deny-feishu-local-state
|
|
233
|
+
source: windows_mandatory
|
|
234
|
+
path: ${LOCALAPPDATA}\Lark
|
|
235
|
+
access: deny
|
|
236
|
+
lifecycle: existing
|
|
237
|
+
inheritance: descendants
|
|
238
|
+
- id: readonly-local-microsoft
|
|
239
|
+
source: windows_mandatory
|
|
240
|
+
path: ${LOCALAPPDATA}\Microsoft
|
|
241
|
+
access: read_only
|
|
242
|
+
lifecycle: existing
|
|
243
|
+
inheritance: descendants
|
|
244
|
+
- id: deny-edge-profile
|
|
245
|
+
source: windows_mandatory
|
|
246
|
+
path: ${LOCALAPPDATA}\Microsoft\Edge\User Data
|
|
247
|
+
access: deny
|
|
248
|
+
lifecycle: existing
|
|
249
|
+
inheritance: descendants
|
|
250
|
+
- id: deny-outlook-data
|
|
251
|
+
source: windows_mandatory
|
|
252
|
+
path: ${LOCALAPPDATA}\Microsoft\Outlook
|
|
253
|
+
access: deny
|
|
254
|
+
lifecycle: existing
|
|
255
|
+
inheritance: descendants
|
|
256
|
+
- id: deny-bitwarden-store
|
|
257
|
+
source: windows_mandatory
|
|
258
|
+
path: ${LOCALAPPDATA}\Packages\8bitSolutionsLLC.bitwardendesktop_h4e712dmw3xyy
|
|
259
|
+
access: deny
|
|
260
|
+
lifecycle: existing
|
|
261
|
+
inheritance: descendants
|
|
262
|
+
- id: deny-slack-store
|
|
263
|
+
source: windows_mandatory
|
|
264
|
+
path: ${LOCALAPPDATA}\Packages\com.tinyspeck.slackdesktop_8yrtsj140pw4g
|
|
265
|
+
access: deny
|
|
266
|
+
lifecycle: existing
|
|
267
|
+
inheritance: descendants
|
|
268
|
+
- id: deny-teams-store
|
|
269
|
+
source: windows_mandatory
|
|
270
|
+
path: ${LOCALAPPDATA}\Packages\MSTeams_8wekyb3d8bbwe
|
|
271
|
+
access: deny
|
|
272
|
+
lifecycle: existing
|
|
273
|
+
inheritance: descendants
|
|
274
|
+
- id: deny-sogou-browser-profile
|
|
275
|
+
source: windows_mandatory
|
|
276
|
+
path: ${LOCALAPPDATA}\Sogou\SogouExplorer\User Data
|
|
277
|
+
access: deny
|
|
278
|
+
lifecycle: existing
|
|
279
|
+
inheritance: descendants
|
|
280
|
+
- id: deny-qqbrowser-profile
|
|
281
|
+
source: windows_mandatory
|
|
282
|
+
path: ${LOCALAPPDATA}\Tencent\QQBrowser\User Data
|
|
283
|
+
access: deny
|
|
284
|
+
lifecycle: existing
|
|
285
|
+
inheritance: descendants
|
|
286
|
+
- id: deny-vivaldi-profile
|
|
287
|
+
source: windows_mandatory
|
|
288
|
+
path: ${LOCALAPPDATA}\Vivaldi\User Data
|
|
289
|
+
access: deny
|
|
290
|
+
lifecycle: existing
|
|
291
|
+
inheritance: descendants
|
|
292
|
+
- id: readonly-common-microsoft
|
|
293
|
+
source: windows_mandatory
|
|
294
|
+
path: ${ProgramData}\Microsoft
|
|
295
|
+
access: read_only
|
|
296
|
+
lifecycle: existing
|
|
297
|
+
inheritance: descendants
|
|
298
|
+
- id: deny-aws
|
|
299
|
+
source: windows_mandatory
|
|
300
|
+
path: ${USERPROFILE}\.aws
|
|
301
|
+
access: deny
|
|
302
|
+
lifecycle: existing
|
|
303
|
+
inheritance: descendants
|
|
304
|
+
- id: deny-gnupg
|
|
305
|
+
source: windows_mandatory
|
|
306
|
+
path: ${USERPROFILE}\.gnupg
|
|
307
|
+
access: deny
|
|
308
|
+
lifecycle: existing
|
|
309
|
+
inheritance: descendants
|
|
310
|
+
- id: deny-kube
|
|
311
|
+
source: windows_mandatory
|
|
312
|
+
path: ${USERPROFILE}\.kube
|
|
313
|
+
access: deny
|
|
314
|
+
lifecycle: existing
|
|
315
|
+
inheritance: descendants
|
|
316
|
+
- id: deny-ssh
|
|
317
|
+
source: windows_mandatory
|
|
318
|
+
path: ${USERPROFILE}\.ssh
|
|
319
|
+
access: deny
|
|
320
|
+
lifecycle: existing
|
|
321
|
+
inheritance: descendants
|
|
322
|
+
- id: deny-outlook-archives-default
|
|
323
|
+
source: windows_mandatory
|
|
324
|
+
path: ${USERPROFILE}\Documents\Outlook Files
|
|
325
|
+
access: deny
|
|
326
|
+
lifecycle: existing
|
|
327
|
+
inheritance: descendants
|
|
328
|
+
- id: deny-qq-files-default
|
|
329
|
+
source: windows_mandatory
|
|
330
|
+
path: ${USERPROFILE}\Documents\Tencent Files
|
|
331
|
+
access: deny
|
|
332
|
+
lifecycle: existing
|
|
333
|
+
inheritance: descendants
|
|
334
|
+
- id: deny-wechat3-files-default
|
|
335
|
+
source: windows_mandatory
|
|
336
|
+
path: ${USERPROFILE}\Documents\WeChat Files
|
|
337
|
+
access: deny
|
|
338
|
+
lifecycle: existing
|
|
339
|
+
inheritance: descendants
|
|
340
|
+
- id: deny-wecom-data-default
|
|
341
|
+
source: windows_mandatory
|
|
342
|
+
path: ${USERPROFILE}\Documents\WXWork
|
|
343
|
+
access: deny
|
|
344
|
+
lifecycle: existing
|
|
345
|
+
inheritance: descendants
|
|
346
|
+
- id: deny-wecom-files-default
|
|
347
|
+
source: windows_mandatory
|
|
348
|
+
path: ${USERPROFILE}\Documents\WXWork Files
|
|
349
|
+
access: deny
|
|
350
|
+
lifecycle: existing
|
|
351
|
+
inheritance: descendants
|
|
352
|
+
- id: deny-wechat4-files-default
|
|
353
|
+
source: windows_mandatory
|
|
354
|
+
path: ${USERPROFILE}\Documents\xwechat_files
|
|
355
|
+
access: deny
|
|
356
|
+
lifecycle: existing
|
|
357
|
+
inheritance: descendants
|
|
358
|
+
network:
|
|
359
|
+
mode: host
|
|
360
|
+
resources:
|
|
361
|
+
timeout_ms: max
|
|
362
|
+
memory_max: max
|
|
363
|
+
pids_max: max
|
|
364
|
+
cpu_max: '100000 100000'
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export function createActivation({observe,obtain,existing,running=false,restartAllowed=()=>true,report=()=>{}}) {
|
|
2
|
+
let bindFailed=false;
|
|
3
|
+
let active=true,state={phase:'starting'},connection,client,binding,currentProtected=false;
|
|
4
|
+
const failure=error=>{if(active){state={phase:'failed',currentProtected,error:error.message};report(error);}};
|
|
5
|
+
const bind=value=>{
|
|
6
|
+
connection=value;
|
|
7
|
+
binding=(async()=>{
|
|
8
|
+
client=(await connection.request('bind',{context:connection.context})).client;
|
|
9
|
+
return connection;
|
|
10
|
+
})();
|
|
11
|
+
return binding;
|
|
12
|
+
};
|
|
13
|
+
async function run() {
|
|
14
|
+
if(!active||!connection) return;
|
|
15
|
+
// This runs in the next turn, after the plugin's apply has completed.
|
|
16
|
+
if(connection.period==='keep')await connection.request('keep',{context:connection.context});
|
|
17
|
+
if(!active)return;
|
|
18
|
+
try {await bind(connection);}catch(error){bindFailed=true;throw error;}
|
|
19
|
+
if(!active) return;
|
|
20
|
+
await connection.request('ensure',{client});
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
start() {
|
|
24
|
+
const startup=(async()=>{
|
|
25
|
+
if(!active) return;
|
|
26
|
+
const token=observe();
|
|
27
|
+
currentProtected=token.appContainer===true;
|
|
28
|
+
const selected=await (currentProtected?existing():obtain({startup:!running}));
|
|
29
|
+
if(!active) return;
|
|
30
|
+
connection=selected;
|
|
31
|
+
if(!running&&!currentProtected&&!connection.admitted&&!connection.runningPeriod)
|
|
32
|
+
{const decision=await connection.request('admit',{context:connection.context});connection.period=decision.period;connection.startupError=decision.error;}
|
|
33
|
+
// A timely admission response releases startup cleanup ownership. Only
|
|
34
|
+
// this old plugin apply remains unfinished while updater performs wrap.
|
|
35
|
+
if(connection.startupError){state={phase:'starting',error:connection.startupError};report(Error(connection.startupError));}
|
|
36
|
+
if(connection.period==='wrap')await new Promise(()=>{});
|
|
37
|
+
})().catch(failure);
|
|
38
|
+
startup.then(()=>{setImmediate(()=>void run().catch(failure));},failure);
|
|
39
|
+
return startup;
|
|
40
|
+
},
|
|
41
|
+
async status() {
|
|
42
|
+
if(!connection||!client||state.phase==='failed') return {...state,currentProtected};
|
|
43
|
+
try {const observed=await connection.request('status',{client});return state.phase==='failed'?state:
|
|
44
|
+
{...observed,currentProtected,...(running?{restartAllowed:restartAllowed()}: {})};}
|
|
45
|
+
catch(error){failure(error);return state;}
|
|
46
|
+
},
|
|
47
|
+
async restart() {
|
|
48
|
+
if(!active||!connection||!client) throw Error('Updater client is unavailable');
|
|
49
|
+
if(running&&!restartAllowed())throw Error('DSH plugin operation has not settled');
|
|
50
|
+
try {
|
|
51
|
+
const result=await connection.request('restart',{client});
|
|
52
|
+
return result;
|
|
53
|
+
} catch(error){failure(error);throw error;}
|
|
54
|
+
},
|
|
55
|
+
async later() {
|
|
56
|
+
if(!active||!connection||!client)throw Error('Updater client is unavailable');
|
|
57
|
+
return connection.request('later',{client});
|
|
58
|
+
},
|
|
59
|
+
async restore() {
|
|
60
|
+
if(binding)await binding;
|
|
61
|
+
if(!connection||!client)throw Error('Updater client is unavailable');
|
|
62
|
+
return connection.request('restore',{client});
|
|
63
|
+
},
|
|
64
|
+
async dispose() {
|
|
65
|
+
active=false;
|
|
66
|
+
try {
|
|
67
|
+
if(bindFailed)return;
|
|
68
|
+
if(binding) await binding;
|
|
69
|
+
else if(connection) await bind(connection);
|
|
70
|
+
else await bind(await existing());
|
|
71
|
+
if(client) await connection.request('release',{client});
|
|
72
|
+
} catch(error) {report(Error(`FinShield cleanup failed; the sandbox override may remain: ${error.message}`));throw error;}
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {parseArgs} from 'node:util';
|
|
2
|
+
import {win32} from 'node:path';
|
|
3
|
+
|
|
4
|
+
// Audited Kilo 7.8.27 local TUI and global options. This only identifies the
|
|
5
|
+
// consumed project token; option values must never be mistaken for a project.
|
|
6
|
+
const options = {};
|
|
7
|
+
for (const [type, names] of [
|
|
8
|
+
['string', ['project', 'model', 'session', 'prompt', 'agent', 'worktree', 'port', 'hostname', 'mdns-domain', 'cors', 'log-level', 'replay-limit']],
|
|
9
|
+
['boolean', ['continue', 'fork', 'cloud-fork', 'auto', 'yolo', 'dangerously-skip-permissions', 'mini', 'replay', 'no-replay', 'demo', 'mdns', 'no-mdns', 'print-logs', 'pure', 'help', 'version']],
|
|
10
|
+
]) for (const name of names) {
|
|
11
|
+
options[name] = {type};
|
|
12
|
+
const camel = name.replace(/-([a-z])/g, (_, char) => char.toUpperCase());
|
|
13
|
+
if (camel !== name) options[camel] = {type};
|
|
14
|
+
}
|
|
15
|
+
for (const [name, short] of Object.entries({model: 'm', session: 's', continue: 'c', help: 'h', version: 'v'})) options[name].short = short;
|
|
16
|
+
|
|
17
|
+
export function replacementArgs(args, cwd) {
|
|
18
|
+
const parsed = parseArgs({args, options, allowPositionals: true, allowNegative: true, tokens: true});
|
|
19
|
+
const project = parsed.tokens.find(token => token.kind === 'positional');
|
|
20
|
+
const terminated = parsed.tokens.some(token => token.kind === 'option-terminator' && token.index < project?.index);
|
|
21
|
+
if (project?.value === 'attach' && !terminated) throw Error('kilo attach uses an outside server; use the local Kilo TUI with FinShield');
|
|
22
|
+
if (parsed.values.mini) throw Error('FinShield supports the full local Kilo TUI, not mini mode');
|
|
23
|
+
const result = [...args];
|
|
24
|
+
for (const token of parsed.tokens) {
|
|
25
|
+
if (token.kind === 'positional' && !win32.isAbsolute(token.value)) result[token.index] = cwd;
|
|
26
|
+
if (token.kind === 'option' && token.name === 'project' && !win32.isAbsolute(token.value)) {
|
|
27
|
+
if (token.inlineValue) result[token.index] = `${token.rawName}=${cwd}`;
|
|
28
|
+
else result[token.index + 1] = cwd;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
}
|
package/src/connector.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { execFile, spawn } from 'node:child_process';
|
|
2
|
+
import {StringDecoder} from 'node:string_decoder';
|
|
3
|
+
import {EventEmitter} from 'node:events';
|
|
4
|
+
|
|
5
|
+
// The fixed native adapter starts the selected Desktop CLI outside the updater
|
|
6
|
+
// Job. Reuse the same acknowledgment/terminal parser for both process transports.
|
|
7
|
+
export function nativeDesktopChild({start,read}) {
|
|
8
|
+
const child=new EventEmitter();child.stdout=new EventEmitter();child.stderr=new EventEmitter();
|
|
9
|
+
queueMicrotask(async()=>{
|
|
10
|
+
try {
|
|
11
|
+
const owner=await start();
|
|
12
|
+
for(;;) {
|
|
13
|
+
const result=await read(owner.owner);
|
|
14
|
+
if(result.stdout)child.stdout.emit('data',result.stdout);
|
|
15
|
+
if(result.stderr)child.stderr.emit('data',result.stderr);
|
|
16
|
+
if(result.eof){child.emit('close',result.code,null);return;}
|
|
17
|
+
}
|
|
18
|
+
}catch(error){child.emit('error',error);}
|
|
19
|
+
});
|
|
20
|
+
return child;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Resolve the flushed Desktop acknowledgment while retaining its finite native owner. */
|
|
24
|
+
export function submitDesktopAuthorization(executable,args,{spawnChild=spawn,env}={}) {
|
|
25
|
+
return new Promise((resolve,reject)=>{
|
|
26
|
+
const child=spawnChild(executable,args,{env,windowsHide:true,stdio:['ignore','pipe','pipe']});
|
|
27
|
+
const decoder=new StringDecoder('utf8');
|
|
28
|
+
let buffer='',diagnostics='',ack,terminal,resolveCompletion,rejectCompletion,transportError;
|
|
29
|
+
const completion=new Promise((yes,no)=>{resolveCompletion=yes;rejectCompletion=no;});
|
|
30
|
+
// The owner is retained even when its consumer disappears. Its error remains
|
|
31
|
+
// observable through completion without becoming an unhandled rejection.
|
|
32
|
+
completion.catch(()=>{});
|
|
33
|
+
child.stderr.on('data',bytes=>{diagnostics=(diagnostics+bytes).slice(-65536);});
|
|
34
|
+
child.stdout.on('data',bytes=>{
|
|
35
|
+
if(transportError)return;
|
|
36
|
+
buffer+=Buffer.isBuffer(bytes)?decoder.write(bytes):bytes;
|
|
37
|
+
try {
|
|
38
|
+
let end;
|
|
39
|
+
while((end=buffer.indexOf('\n'))>=0) {
|
|
40
|
+
if(Buffer.byteLength(buffer.slice(0,end))>16384)throw Error('Desktop result frame exceeds 16 KiB');
|
|
41
|
+
const frame=JSON.parse(buffer.slice(0,end));buffer=buffer.slice(end+1);
|
|
42
|
+
if(!frame.value||typeof frame.value!=='object')throw Error('Invalid Desktop result');
|
|
43
|
+
if(frame.record==='ack'&&!ack&&!terminal) {
|
|
44
|
+
ack=frame.value;
|
|
45
|
+
if(ack.error)throw Error(ack.error);
|
|
46
|
+
resolve({...ack,completion});
|
|
47
|
+
} else if(frame.record==='terminal'&&ack&&!terminal)terminal=frame.value;
|
|
48
|
+
else throw Error('Unexpected Desktop result frame');
|
|
49
|
+
}
|
|
50
|
+
if(Buffer.byteLength(buffer)>16384)throw Error('Desktop result frame exceeds 16 KiB');
|
|
51
|
+
} catch(error) {transportError=error;if(!ack)reject(error);}
|
|
52
|
+
});
|
|
53
|
+
child.on('error',error=>{transportError=error;reject(error);rejectCompletion(error);});
|
|
54
|
+
child.on('close',(code,signal)=>{
|
|
55
|
+
buffer+=decoder.end();
|
|
56
|
+
const error=transportError??(buffer.length?Error('Desktop result ended with a truncated frame'):
|
|
57
|
+
signal||!Number.isInteger(code)?Error(`Desktop task ended by ${signal??'unknown exit'}`):
|
|
58
|
+
terminal&&Number.isInteger(terminal.exit_code)&&terminal.exit_code!==code?Error(`Desktop task exit ${code} differs from terminal ${terminal.exit_code}`):
|
|
59
|
+
!ack?Error(`Desktop acknowledgment missing (${code}): ${diagnostics}`):
|
|
60
|
+
ack.accepted&&!terminal?Error(`Desktop task exited without terminal result (${code}): ${diagnostics}`):
|
|
61
|
+
code&&!terminal?Error(`Desktop task exited (${code}): ${diagnostics}`):undefined);
|
|
62
|
+
if(error){reject(error);rejectCompletion(error);return;}
|
|
63
|
+
resolveCompletion(terminal??ack);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
/** Invoke an installed executable directly. No shell or model-supplied arguments. */
|
|
70
|
+
export function runFinSafe(executable, args, { signal, timeoutMs = 30000, env, readOnlyResult=false } = {}) {
|
|
71
|
+
return new Promise((resolve, reject) => {
|
|
72
|
+
execFile(executable, args, { signal, env, timeout: timeoutMs, windowsHide: true, maxBuffer: 1024 * 1024 }, (error, stdout, stderr) => {
|
|
73
|
+
let result;
|
|
74
|
+
try {
|
|
75
|
+
result = JSON.parse(stdout);
|
|
76
|
+
if (!result || typeof result !== 'object' || Array.isArray(result)) throw new Error('Invalid JSON result');
|
|
77
|
+
} catch {
|
|
78
|
+
reject(error ?? new Error(`FinSAFE returned invalid JSON: ${stderr.trim() || stdout.trim()}`));
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (error || (!readOnlyResult && typeof result.exit_code === 'number' && result.exit_code !== 0)) {
|
|
82
|
+
const failure=new Error(result.detail || result.error || stderr.trim() || error?.message || `FinSAFE failed: ${result.exit_code}`);
|
|
83
|
+
failure.authority=result.authority;
|
|
84
|
+
failure.result=result;
|
|
85
|
+
reject(failure);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
resolve(result);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
package/src/handoff.mjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {absolutePath} from './options.mjs';
|
|
2
|
+
|
|
3
|
+
export function buildLaunch(plan, environment = process.env) {
|
|
4
|
+
for (const key of ['kilo', 'cwd', 'finsafe', 'yamlPath']) absolutePath(plan[key], key);
|
|
5
|
+
if (!Array.isArray(plan.args) || plan.args.some(arg => typeof arg !== 'string' || arg.includes('\0')))
|
|
6
|
+
throw Error('Kilo arguments must be strings without NUL');
|
|
7
|
+
if (!Number.isSafeInteger(plan.original?.pid) || plan.original.pid <= 0
|
|
8
|
+
|| typeof plan.original.created !== 'string' || !/^\d+$/.test(plan.original.created))
|
|
9
|
+
throw Error('Invalid original process identity');
|
|
10
|
+
// These Windows control-variable names are ASCII and case-insensitive.
|
|
11
|
+
const env = Object.fromEntries(Object.entries(environment).filter(([key]) =>
|
|
12
|
+
!['BUN_BE_BUN', 'KILO_NO_DAEMON'].includes(key.toUpperCase())));
|
|
13
|
+
env.KILO_NO_DAEMON = '1';
|
|
14
|
+
return {executable: plan.finsafe, cwd: plan.cwd, env,
|
|
15
|
+
args: ['self-confine', '--yaml-path', plan.yamlPath, '--integration-id', 'kilo', '--', plan.kilo, ...plan.args]};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function replaceProcess(plan, ports) {
|
|
19
|
+
const launch = buildLaunch(plan, ports.env);
|
|
20
|
+
const original = ports.openOriginal(plan.original);
|
|
21
|
+
try {
|
|
22
|
+
await ports.stopOriginal(original);
|
|
23
|
+
ports.record({phase: 'original-exited'});
|
|
24
|
+
return ports.startProtected(launch);
|
|
25
|
+
} finally {original.close();}
|
|
26
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import koffi from 'koffi';
|
|
2
|
+
|
|
3
|
+
// Same known-folder contract as DSH: preserve relocation, exclude MSIX redirection.
|
|
4
|
+
export function knownFolderEnvironment() {
|
|
5
|
+
const ole = koffi.load('ole32.dll'), shell = koffi.load('shell32.dll');
|
|
6
|
+
const guid = ole.func('int32 __stdcall CLSIDFromString(str16, void*)');
|
|
7
|
+
const folder = shell.func('int32 __stdcall SHGetKnownFolderPath(void*, uint32, void*, void*)');
|
|
8
|
+
const free = ole.func('void __stdcall CoTaskMemFree(void*)');
|
|
9
|
+
const result = {...process.env};
|
|
10
|
+
for (const [key, id] of Object.entries({ProgramFiles: '{905E63B6-C1BF-494E-B29C-65B732D3D21A}',
|
|
11
|
+
ProgramData: '{62AB5D82-FDC1-4DC3-A9DD-070D1D495D97}', LOCALAPPDATA: '{F1B32785-6FBA-4FCF-9D55-7B8E7F157091}'})) {
|
|
12
|
+
const identifier = Buffer.alloc(16), out = Buffer.alloc(8);
|
|
13
|
+
if (guid(id, identifier) !== 0) throw Error('Invalid known-folder identifier');
|
|
14
|
+
const code = folder(identifier, 0x00010000, null, out);
|
|
15
|
+
if (code !== 0) throw Error(`SHGetKnownFolderPath ${key}: HRESULT ${code}`);
|
|
16
|
+
const pointer = koffi.decode(out, 'void*');
|
|
17
|
+
try {result[key] = koffi.decode.string16(pointer);} finally {free(pointer);}
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
}
|