@finogeeks2026/finshield-opencode 0.0.0-stage → 0.11.50
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/DESIGN.md +593 -0
- package/LICENSE.rtf +28 -0
- package/README.md +132 -2
- package/THIRD-PARTY-NOTICES.md +3131 -0
- package/bin/node.exe +4 -0
- package/dist/gui-experimental.cjs +96 -0
- package/dist/updater/server.js +1046 -0
- package/install/download-source.json +3 -0
- package/install/runtime.js +60 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/LICENSE.rtf +28 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/README.md +116 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/bin/finsafe_native.dll +0 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/native-build.json +5 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/@koromix/koffi-win32-x64/README.md +6 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/@koromix/koffi-win32-x64/index.js +12 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/@koromix/koffi-win32-x64/package.json +24 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/@koromix/koffi-win32-x64/win32_x64/koffi.lib +0 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/@koromix/koffi-win32-x64/win32_x64/koffi.node +0 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/CHANGELOG.md +1183 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/LICENSE.txt +22 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/README.md +42 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/cnoke.cjs +816 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/doc/benchmarks.md +80 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/doc/callbacks.md +182 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/doc/composites.md +549 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/doc/contribute.md +163 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/doc/index.md +46 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/doc/load.md +191 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/doc/migration.md +256 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/doc/misc.md +76 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/doc/output.md +299 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/doc/pointers.md +385 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/doc/primitives.md +151 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/doc/start.md +110 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/doc/types.md +88 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/doc/unions.md +0 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/doc/values.md +134 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/index.cjs +1 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/index.d.ts +389 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/index.js +2 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/indirect.cjs +1 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/indirect.js +2 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/lib/native/base/base.cc +11064 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/lib/native/base/base.hh +5951 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/lib/native/base/unicode.inc +408 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/package.json +68 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/CMakeLists.txt +249 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/index.cjs +296 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/index.js +281 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/indirect.cjs +295 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/indirect.js +280 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/abi/arm64.cc +1408 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/abi/arm64_asm.S +216 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/abi/arm64_asm.asm +181 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/abi/loong64.cc +5 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/abi/loong64_asm.S +200 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/abi/riscv64.cc +1345 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/abi/riscv64_asm.S +200 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/abi/x64sysv.cc +1434 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/abi/x64sysv_asm.S +224 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/abi/x64win.cc +1086 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/abi/x64win_asm.S +162 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/abi/x64win_asm.asm +189 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/abi/x86.cc +1185 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/abi/x86_asm.S +217 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/abi/x86_asm.asm +174 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/call.cc +2094 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/call.hh +179 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/errno.inc +462 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/ffi.cc +3009 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/ffi.hh +461 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/parser.cc +218 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/parser.hh +54 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/primitives.inc +36 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/static.cjs +130 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/static.js +133 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/trampolines.cjs +77 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/type.cc +725 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/type.hh +71 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/util.cc +1040 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/util.hh +493 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/uv.cc +214 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/uv.def +11 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/uv.hh +112 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/win32.cc +198 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/src/koffi/src/win32.hh +148 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/vendor/node-addon-api/LICENSE.md +9 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/vendor/node-addon-api/README.md +95 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/vendor/node-addon-api/napi-inl.deprecated.h +186 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/vendor/node-addon-api/napi-inl.h +7211 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/vendor/node-addon-api/napi.h +3421 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/vendor/node-api-headers/LICENSE +21 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/vendor/node-api-headers/README.md +95 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/vendor/node-api-headers/def/js_native_api.def +125 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/vendor/node-api-headers/def/node_api.def +157 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/vendor/node-api-headers/include/js_native_api.h +591 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/vendor/node-api-headers/include/js_native_api_types.h +210 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/vendor/node-api-headers/include/node_api.h +265 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/node_modules/koffi/vendor/node-api-headers/include/node_api_types.h +58 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/package.json +36 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/release.json +4 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/src/native.js +85 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/src/shell.js +20 -0
- package/node_modules/@finogeeks2026/finsafe-sdk/src/status.js +57 -0
- package/package.json +47 -4
- package/policy/candidate.yaml +347 -0
- package/release.json +4 -0
- package/src/activation.js +2 -0
- package/src/attachment.js +34 -0
- package/src/connector.js +91 -0
- package/src/contract.js +8 -0
- package/src/desktop-contract.js +4 -0
- package/src/desktop.js +25 -0
- package/src/gui.tsx +58 -0
- package/src/host.js +38 -0
- package/src/index.js +12 -0
- package/src/instance-settings.js +27 -0
- package/src/known-folders.js +22 -0
- package/src/management.js +17 -0
- package/src/preparation.js +18 -0
- package/src/presentation.js +153 -0
- package/src/settings.js +18 -0
- package/ui/feedback.cjs +45 -0
- package/ui/page.cjs +225 -0
- package/ui/state.cjs +44 -0
- package/updater/bootstrap.js +41 -0
- package/updater/common/activation.js +81 -0
- package/updater/common/coordinator.js +329 -0
- package/updater/common/download.js +57 -0
- package/updater/common/index.js +12 -0
- package/updater/common/package.js +53 -0
- package/updater/common/protocol.js +38 -0
- package/updater/common/transport.js +65 -0
- package/updater/coordinator.js +2 -0
- package/updater/launch.js +40 -0
- package/updater/management.js +9 -0
- package/updater/native.js +18 -0
- package/updater/operations.js +45 -0
- package/updater/protocol.js +1 -0
- package/updater/server.js +100 -0
- package/updater/transport.js +10 -0
- package/updater/windows-launch-reader.js +40 -0
- package/updater/windows-launch.js +96 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** Stateless Shell HTTP calls. Each call owns its request or event stream. */
|
|
2
|
+
export function createStatusClient({origin,nonce,fetch:request=globalThis.fetch,timeoutMs=30000,onSlow}={}) {
|
|
3
|
+
const headers={Origin:origin,...(nonce?{'X-FinSAFE-Instance':nonce}:{})};
|
|
4
|
+
async function read(path) {
|
|
5
|
+
const controller=new AbortController();
|
|
6
|
+
const timeout=setTimeout(()=>controller.abort(Error('Shell status read timed out')),timeoutMs);
|
|
7
|
+
const notice=setTimeout(()=>{try{onSlow?.(path);}catch{}},5000);
|
|
8
|
+
try {
|
|
9
|
+
const response=await request(origin+path,{method:'GET',redirect:'error',cache:'no-store',headers,signal:controller.signal});
|
|
10
|
+
const value=await response.json();
|
|
11
|
+
if(!response.ok)throw Object.assign(Error(value.detail??value.error??`Shell HTTP ${response.status}`),
|
|
12
|
+
{status:response.status,code:value.code,resource:value.resource??path});
|
|
13
|
+
return value;
|
|
14
|
+
} catch(error) {
|
|
15
|
+
if(controller.signal.aborted)throw controller.signal.reason;
|
|
16
|
+
throw error;
|
|
17
|
+
} finally {clearTimeout(timeout);clearTimeout(notice);}
|
|
18
|
+
}
|
|
19
|
+
function subscribe(onResource,{onError=()=>{}}={}) {
|
|
20
|
+
const controller=new AbortController();
|
|
21
|
+
void (async()=>{
|
|
22
|
+
const response=await request(origin+'/api/events',{method:'GET',redirect:'error',cache:'no-store',headers,signal:controller.signal});
|
|
23
|
+
if(!response.ok)throw Error(`Shell event subscription failed: ${response.status}`);
|
|
24
|
+
const decoder=new TextDecoder();let buffer='';
|
|
25
|
+
for await(const chunk of response.body) {
|
|
26
|
+
buffer=(buffer+decoder.decode(chunk,{stream:true})).replaceAll('\r\n','\n');
|
|
27
|
+
if(buffer.length>16384)throw Error('Shell event exceeds 16 KiB');
|
|
28
|
+
let end;
|
|
29
|
+
while((end=buffer.indexOf('\n\n'))>=0) {
|
|
30
|
+
const lines=buffer.slice(0,end).split('\n');buffer=buffer.slice(end+2);
|
|
31
|
+
const event=lines.find(line=>line.startsWith('event:'))?.slice(6).trim();
|
|
32
|
+
if(event==='resync')onResource(undefined);
|
|
33
|
+
if(event==='resource_changed') {
|
|
34
|
+
const data=lines.filter(line=>line.startsWith('data:')).map(line=>line.slice(5).trim()).join('\n');
|
|
35
|
+
onResource(JSON.parse(data).resource);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if(!controller.signal.aborted)throw Error('Shell event subscription ended');
|
|
40
|
+
})().catch(error=>{if(!controller.signal.aborted)onError(error);});
|
|
41
|
+
return ()=>controller.abort();
|
|
42
|
+
}
|
|
43
|
+
const application=id=>{
|
|
44
|
+
if(typeof id!=='string'||!/^[a-z][a-z0-9-]*$/.test(id))throw Error('Invalid application ID');
|
|
45
|
+
return `/api/apps/${id}`;
|
|
46
|
+
};
|
|
47
|
+
return {
|
|
48
|
+
authorizationState:()=>read('/api/authorization/state'),
|
|
49
|
+
authorizationProgress:attempt=>{
|
|
50
|
+
if(attempt!==undefined&&!/^[a-f0-9]{32}$/i.test(attempt))throw Error('Invalid authorization attempt');
|
|
51
|
+
return read('/api/authorization/progress'+(attempt?`?attempt=${attempt}`:''));
|
|
52
|
+
},
|
|
53
|
+
applicationStatus:id=>read(application(id)+'/status'),
|
|
54
|
+
applicationInstallation:id=>read(application(id)+'/installation'),
|
|
55
|
+
applications:()=>read('/api/apps'),update:()=>read('/api/update'),subscribe,
|
|
56
|
+
};
|
|
57
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finogeeks2026/finshield-opencode",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.11.50",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE.rtf",
|
|
6
|
+
"description": "FinShield protection for the native OpenCode desktop backend",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./src/index.js",
|
|
9
|
+
"./gui-experimental": "./dist/gui-experimental.cjs"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"src",
|
|
13
|
+
"dist",
|
|
14
|
+
"updater",
|
|
15
|
+
"bin/node.exe",
|
|
16
|
+
"policy",
|
|
17
|
+
"LICENSE.rtf",
|
|
18
|
+
"release.json",
|
|
19
|
+
"THIRD-PARTY-NOTICES.md",
|
|
20
|
+
"README.md",
|
|
21
|
+
"DESIGN.md",
|
|
22
|
+
"install",
|
|
23
|
+
"ui"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "vite build && node build-updater.mjs",
|
|
27
|
+
"build:policy": "finsafe config resolve --manifest ../../../windows/config/opencode-plugin/manifest.yaml --output policy/candidate.yaml",
|
|
28
|
+
"pretest": "node ../../common/windows/build.mjs .",
|
|
29
|
+
"test": "node --test test/*.test.js",
|
|
30
|
+
"prepack": "npm run build"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@finogeeks2026/finsafe-sdk": "0.11.50"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@opencode/plugin": "2.3.0",
|
|
37
|
+
"react": "18.2.0",
|
|
38
|
+
"react-dom": "18.2.0",
|
|
39
|
+
"effect": "4.1.0",
|
|
40
|
+
"esbuild": "0.25.12",
|
|
41
|
+
"node-win-x64": "24.22.1",
|
|
42
|
+
"solid-js": "1.9.19",
|
|
43
|
+
"vite": "7.3.8",
|
|
44
|
+
"vite-plugin-solid": "2.11.9"
|
|
45
|
+
},
|
|
46
|
+
"bundleDependencies": [
|
|
47
|
+
"@finogeeks2026/finsafe-sdk"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
schema_version: 1
|
|
2
|
+
platform: windows
|
|
3
|
+
security_domain_id: finshield.opencode
|
|
4
|
+
integrations:
|
|
5
|
+
- opencode
|
|
6
|
+
policy:
|
|
7
|
+
filesystem_coverage:
|
|
8
|
+
root: read_write
|
|
9
|
+
rules:
|
|
10
|
+
- id: host-recycle-bin
|
|
11
|
+
source: windows_mandatory
|
|
12
|
+
path: $Recycle.Bin
|
|
13
|
+
access: host
|
|
14
|
+
lifecycle: existing
|
|
15
|
+
inheritance: descendants
|
|
16
|
+
filesystem:
|
|
17
|
+
- id: opencode-plugin-install-root
|
|
18
|
+
source: opencode_compatibility
|
|
19
|
+
path: ${FINSAFE_INSTALL_DIR}\..
|
|
20
|
+
access: read_only
|
|
21
|
+
lifecycle: existing
|
|
22
|
+
inheritance: descendants
|
|
23
|
+
- id: opencode-cache
|
|
24
|
+
source: opencode_compatibility
|
|
25
|
+
path: '{opencode_cache_dir}'
|
|
26
|
+
access: read_write
|
|
27
|
+
lifecycle: prepare_created
|
|
28
|
+
inheritance: descendants
|
|
29
|
+
- id: opencode-config
|
|
30
|
+
source: opencode_compatibility
|
|
31
|
+
path: '{opencode_config_dir}'
|
|
32
|
+
access: read_write
|
|
33
|
+
lifecycle: prepare_created
|
|
34
|
+
inheritance: descendants
|
|
35
|
+
- id: opencode-data
|
|
36
|
+
source: opencode_compatibility
|
|
37
|
+
path: '{opencode_data_dir}'
|
|
38
|
+
access: read_write
|
|
39
|
+
lifecycle: prepare_created
|
|
40
|
+
inheritance: descendants
|
|
41
|
+
- id: opencode-default-workspace
|
|
42
|
+
source: opencode_compatibility
|
|
43
|
+
path: '{opencode_default_workspace}'
|
|
44
|
+
access: read_write
|
|
45
|
+
lifecycle: prepare_created
|
|
46
|
+
inheritance: descendants
|
|
47
|
+
- id: opencode-install
|
|
48
|
+
source: opencode_compatibility
|
|
49
|
+
path: '{opencode_install_dir}'
|
|
50
|
+
access: read_write
|
|
51
|
+
lifecycle: existing
|
|
52
|
+
inheritance: descendants
|
|
53
|
+
- id: opencode-state
|
|
54
|
+
source: opencode_compatibility
|
|
55
|
+
path: '{opencode_state_dir}'
|
|
56
|
+
access: read_write
|
|
57
|
+
lifecycle: prepare_created
|
|
58
|
+
inheritance: descendants
|
|
59
|
+
- id: deny-360se-profile
|
|
60
|
+
source: windows_mandatory
|
|
61
|
+
path: ${APPDATA}\360se6\User Data
|
|
62
|
+
access: deny
|
|
63
|
+
lifecycle: existing
|
|
64
|
+
inheritance: descendants
|
|
65
|
+
- id: deny-bitwarden-desktop
|
|
66
|
+
source: windows_mandatory
|
|
67
|
+
path: ${APPDATA}\Bitwarden
|
|
68
|
+
access: deny
|
|
69
|
+
lifecycle: existing
|
|
70
|
+
inheritance: descendants
|
|
71
|
+
- id: deny-bitwarden-cli
|
|
72
|
+
source: windows_mandatory
|
|
73
|
+
path: ${APPDATA}\Bitwarden CLI
|
|
74
|
+
access: deny
|
|
75
|
+
lifecycle: existing
|
|
76
|
+
inheritance: descendants
|
|
77
|
+
- id: deny-dingtalk-state
|
|
78
|
+
source: windows_mandatory
|
|
79
|
+
path: ${APPDATA}\DingTalk
|
|
80
|
+
access: deny
|
|
81
|
+
lifecycle: existing
|
|
82
|
+
inheritance: descendants
|
|
83
|
+
- id: deny-gcloud
|
|
84
|
+
source: windows_mandatory
|
|
85
|
+
path: ${APPDATA}\gcloud
|
|
86
|
+
access: deny
|
|
87
|
+
lifecycle: existing
|
|
88
|
+
inheritance: descendants
|
|
89
|
+
- id: deny-gh
|
|
90
|
+
source: windows_mandatory
|
|
91
|
+
path: ${APPDATA}\GitHub CLI
|
|
92
|
+
access: deny
|
|
93
|
+
lifecycle: existing
|
|
94
|
+
inheritance: descendants
|
|
95
|
+
- id: deny-feishu-roaming-state
|
|
96
|
+
source: windows_mandatory
|
|
97
|
+
path: ${APPDATA}\LarkShell
|
|
98
|
+
access: deny
|
|
99
|
+
lifecycle: existing
|
|
100
|
+
inheritance: descendants
|
|
101
|
+
- id: readonly-roaming-microsoft
|
|
102
|
+
source: windows_mandatory
|
|
103
|
+
path: ${APPDATA}\Microsoft
|
|
104
|
+
access: read_only
|
|
105
|
+
lifecycle: existing
|
|
106
|
+
inheritance: descendants
|
|
107
|
+
- id: deny-teams-classic
|
|
108
|
+
source: windows_mandatory
|
|
109
|
+
path: ${APPDATA}\Microsoft\Teams
|
|
110
|
+
access: deny
|
|
111
|
+
lifecycle: existing
|
|
112
|
+
inheritance: descendants
|
|
113
|
+
- id: deny-firefox-profiles
|
|
114
|
+
source: windows_mandatory
|
|
115
|
+
path: ${APPDATA}\Mozilla\Firefox\Profiles
|
|
116
|
+
access: deny
|
|
117
|
+
lifecycle: existing
|
|
118
|
+
inheritance: descendants
|
|
119
|
+
- id: deny-opera-profile
|
|
120
|
+
source: windows_mandatory
|
|
121
|
+
path: ${APPDATA}\Opera Software\Opera Stable
|
|
122
|
+
access: deny
|
|
123
|
+
lifecycle: existing
|
|
124
|
+
inheritance: descendants
|
|
125
|
+
- id: deny-signal-desktop
|
|
126
|
+
source: windows_mandatory
|
|
127
|
+
path: ${APPDATA}\Signal
|
|
128
|
+
access: deny
|
|
129
|
+
lifecycle: existing
|
|
130
|
+
inheritance: descendants
|
|
131
|
+
- id: deny-slack-desktop
|
|
132
|
+
source: windows_mandatory
|
|
133
|
+
path: ${APPDATA}\slack
|
|
134
|
+
access: deny
|
|
135
|
+
lifecycle: existing
|
|
136
|
+
inheritance: descendants
|
|
137
|
+
- id: deny-qq-state
|
|
138
|
+
source: windows_mandatory
|
|
139
|
+
path: ${APPDATA}\Tencent\QQ
|
|
140
|
+
access: deny
|
|
141
|
+
lifecycle: existing
|
|
142
|
+
inheritance: descendants
|
|
143
|
+
- id: deny-qqnt-state
|
|
144
|
+
source: windows_mandatory
|
|
145
|
+
path: ${APPDATA}\Tencent\QQNT
|
|
146
|
+
access: deny
|
|
147
|
+
lifecycle: existing
|
|
148
|
+
inheritance: descendants
|
|
149
|
+
- id: deny-wechat3-state
|
|
150
|
+
source: windows_mandatory
|
|
151
|
+
path: ${APPDATA}\Tencent\WeChat
|
|
152
|
+
access: deny
|
|
153
|
+
lifecycle: existing
|
|
154
|
+
inheritance: descendants
|
|
155
|
+
- id: deny-wecom-state
|
|
156
|
+
source: windows_mandatory
|
|
157
|
+
path: ${APPDATA}\Tencent\WXWork
|
|
158
|
+
access: deny
|
|
159
|
+
lifecycle: existing
|
|
160
|
+
inheritance: descendants
|
|
161
|
+
- id: deny-wechat4-state
|
|
162
|
+
source: windows_mandatory
|
|
163
|
+
path: ${APPDATA}\Tencent\xwechat
|
|
164
|
+
access: deny
|
|
165
|
+
lifecycle: existing
|
|
166
|
+
inheritance: descendants
|
|
167
|
+
- id: deny-thunderbird-profiles
|
|
168
|
+
source: windows_mandatory
|
|
169
|
+
path: ${APPDATA}\Thunderbird\Profiles
|
|
170
|
+
access: deny
|
|
171
|
+
lifecycle: existing
|
|
172
|
+
inheritance: descendants
|
|
173
|
+
- id: finsafe-config
|
|
174
|
+
source: windows_mandatory
|
|
175
|
+
path: ${FINSAFE_CONFIG_DIR}
|
|
176
|
+
access: read_only
|
|
177
|
+
lifecycle: existing
|
|
178
|
+
inheritance: descendants
|
|
179
|
+
- id: finsafe-install
|
|
180
|
+
source: windows_mandatory
|
|
181
|
+
path: ${FINSAFE_INSTALL_DIR}
|
|
182
|
+
access: read_only
|
|
183
|
+
lifecycle: existing
|
|
184
|
+
inheritance: descendants
|
|
185
|
+
- id: deny-360chromex-profile
|
|
186
|
+
source: windows_mandatory
|
|
187
|
+
path: ${LOCALAPPDATA}\360ChromeX\Chrome\User Data
|
|
188
|
+
access: deny
|
|
189
|
+
lifecycle: existing
|
|
190
|
+
inheritance: descendants
|
|
191
|
+
- id: deny-brave-profile
|
|
192
|
+
source: windows_mandatory
|
|
193
|
+
path: ${LOCALAPPDATA}\BraveSoftware\Brave-Browser\User Data
|
|
194
|
+
access: deny
|
|
195
|
+
lifecycle: existing
|
|
196
|
+
inheritance: descendants
|
|
197
|
+
- id: deny-feishu-profile
|
|
198
|
+
source: windows_mandatory
|
|
199
|
+
path: ${LOCALAPPDATA}\Feishu\User Data
|
|
200
|
+
access: deny
|
|
201
|
+
lifecycle: existing
|
|
202
|
+
inheritance: descendants
|
|
203
|
+
- id: finsafe-root
|
|
204
|
+
source: windows_mandatory
|
|
205
|
+
path: ${LOCALAPPDATA}\FinSAFE
|
|
206
|
+
access: read_only
|
|
207
|
+
lifecycle: prepare_created
|
|
208
|
+
inheritance: descendants
|
|
209
|
+
- id: deny-chrome-profile
|
|
210
|
+
source: windows_mandatory
|
|
211
|
+
path: ${LOCALAPPDATA}\Google\Chrome\User Data
|
|
212
|
+
access: deny
|
|
213
|
+
lifecycle: existing
|
|
214
|
+
inheritance: descendants
|
|
215
|
+
- id: deny-feishu-local-state
|
|
216
|
+
source: windows_mandatory
|
|
217
|
+
path: ${LOCALAPPDATA}\Lark
|
|
218
|
+
access: deny
|
|
219
|
+
lifecycle: existing
|
|
220
|
+
inheritance: descendants
|
|
221
|
+
- id: readonly-local-microsoft
|
|
222
|
+
source: windows_mandatory
|
|
223
|
+
path: ${LOCALAPPDATA}\Microsoft
|
|
224
|
+
access: read_only
|
|
225
|
+
lifecycle: existing
|
|
226
|
+
inheritance: descendants
|
|
227
|
+
- id: deny-edge-profile
|
|
228
|
+
source: windows_mandatory
|
|
229
|
+
path: ${LOCALAPPDATA}\Microsoft\Edge\User Data
|
|
230
|
+
access: deny
|
|
231
|
+
lifecycle: existing
|
|
232
|
+
inheritance: descendants
|
|
233
|
+
- id: deny-outlook-data
|
|
234
|
+
source: windows_mandatory
|
|
235
|
+
path: ${LOCALAPPDATA}\Microsoft\Outlook
|
|
236
|
+
access: deny
|
|
237
|
+
lifecycle: existing
|
|
238
|
+
inheritance: descendants
|
|
239
|
+
- id: deny-bitwarden-store
|
|
240
|
+
source: windows_mandatory
|
|
241
|
+
path: ${LOCALAPPDATA}\Packages\8bitSolutionsLLC.bitwardendesktop_h4e712dmw3xyy
|
|
242
|
+
access: deny
|
|
243
|
+
lifecycle: existing
|
|
244
|
+
inheritance: descendants
|
|
245
|
+
- id: deny-slack-store
|
|
246
|
+
source: windows_mandatory
|
|
247
|
+
path: ${LOCALAPPDATA}\Packages\com.tinyspeck.slackdesktop_8yrtsj140pw4g
|
|
248
|
+
access: deny
|
|
249
|
+
lifecycle: existing
|
|
250
|
+
inheritance: descendants
|
|
251
|
+
- id: deny-teams-store
|
|
252
|
+
source: windows_mandatory
|
|
253
|
+
path: ${LOCALAPPDATA}\Packages\MSTeams_8wekyb3d8bbwe
|
|
254
|
+
access: deny
|
|
255
|
+
lifecycle: existing
|
|
256
|
+
inheritance: descendants
|
|
257
|
+
- id: deny-sogou-browser-profile
|
|
258
|
+
source: windows_mandatory
|
|
259
|
+
path: ${LOCALAPPDATA}\Sogou\SogouExplorer\User Data
|
|
260
|
+
access: deny
|
|
261
|
+
lifecycle: existing
|
|
262
|
+
inheritance: descendants
|
|
263
|
+
- id: deny-qqbrowser-profile
|
|
264
|
+
source: windows_mandatory
|
|
265
|
+
path: ${LOCALAPPDATA}\Tencent\QQBrowser\User Data
|
|
266
|
+
access: deny
|
|
267
|
+
lifecycle: existing
|
|
268
|
+
inheritance: descendants
|
|
269
|
+
- id: deny-vivaldi-profile
|
|
270
|
+
source: windows_mandatory
|
|
271
|
+
path: ${LOCALAPPDATA}\Vivaldi\User Data
|
|
272
|
+
access: deny
|
|
273
|
+
lifecycle: existing
|
|
274
|
+
inheritance: descendants
|
|
275
|
+
- id: readonly-common-microsoft
|
|
276
|
+
source: windows_mandatory
|
|
277
|
+
path: ${ProgramData}\Microsoft
|
|
278
|
+
access: read_only
|
|
279
|
+
lifecycle: existing
|
|
280
|
+
inheritance: descendants
|
|
281
|
+
- id: deny-aws
|
|
282
|
+
source: windows_mandatory
|
|
283
|
+
path: ${USERPROFILE}\.aws
|
|
284
|
+
access: deny
|
|
285
|
+
lifecycle: existing
|
|
286
|
+
inheritance: descendants
|
|
287
|
+
- id: deny-gnupg
|
|
288
|
+
source: windows_mandatory
|
|
289
|
+
path: ${USERPROFILE}\.gnupg
|
|
290
|
+
access: deny
|
|
291
|
+
lifecycle: existing
|
|
292
|
+
inheritance: descendants
|
|
293
|
+
- id: deny-kube
|
|
294
|
+
source: windows_mandatory
|
|
295
|
+
path: ${USERPROFILE}\.kube
|
|
296
|
+
access: deny
|
|
297
|
+
lifecycle: existing
|
|
298
|
+
inheritance: descendants
|
|
299
|
+
- id: deny-ssh
|
|
300
|
+
source: windows_mandatory
|
|
301
|
+
path: ${USERPROFILE}\.ssh
|
|
302
|
+
access: deny
|
|
303
|
+
lifecycle: existing
|
|
304
|
+
inheritance: descendants
|
|
305
|
+
- id: deny-outlook-archives-default
|
|
306
|
+
source: windows_mandatory
|
|
307
|
+
path: ${USERPROFILE}\Documents\Outlook Files
|
|
308
|
+
access: deny
|
|
309
|
+
lifecycle: existing
|
|
310
|
+
inheritance: descendants
|
|
311
|
+
- id: deny-qq-files-default
|
|
312
|
+
source: windows_mandatory
|
|
313
|
+
path: ${USERPROFILE}\Documents\Tencent Files
|
|
314
|
+
access: deny
|
|
315
|
+
lifecycle: existing
|
|
316
|
+
inheritance: descendants
|
|
317
|
+
- id: deny-wechat3-files-default
|
|
318
|
+
source: windows_mandatory
|
|
319
|
+
path: ${USERPROFILE}\Documents\WeChat Files
|
|
320
|
+
access: deny
|
|
321
|
+
lifecycle: existing
|
|
322
|
+
inheritance: descendants
|
|
323
|
+
- id: deny-wecom-data-default
|
|
324
|
+
source: windows_mandatory
|
|
325
|
+
path: ${USERPROFILE}\Documents\WXWork
|
|
326
|
+
access: deny
|
|
327
|
+
lifecycle: existing
|
|
328
|
+
inheritance: descendants
|
|
329
|
+
- id: deny-wecom-files-default
|
|
330
|
+
source: windows_mandatory
|
|
331
|
+
path: ${USERPROFILE}\Documents\WXWork Files
|
|
332
|
+
access: deny
|
|
333
|
+
lifecycle: existing
|
|
334
|
+
inheritance: descendants
|
|
335
|
+
- id: deny-wechat4-files-default
|
|
336
|
+
source: windows_mandatory
|
|
337
|
+
path: ${USERPROFILE}\Documents\xwechat_files
|
|
338
|
+
access: deny
|
|
339
|
+
lifecycle: existing
|
|
340
|
+
inheritance: descendants
|
|
341
|
+
network:
|
|
342
|
+
mode: host
|
|
343
|
+
resources:
|
|
344
|
+
timeout_ms: max
|
|
345
|
+
memory_max: max
|
|
346
|
+
pids_max: max
|
|
347
|
+
cpu_max: '100000 100000'
|
package/release.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// One activation per verified desktop. The native adapter verifies the PID.
|
|
2
|
+
export function createDesktopAttachment({activate,observe,report=()=>{}}){
|
|
3
|
+
let current,closed=false;
|
|
4
|
+
return {
|
|
5
|
+
attach(mainPid,activation=String(mainPid),desktop,connectedHostPid,startup=false){
|
|
6
|
+
if(closed)throw Error('FinShield plugin is unloading');
|
|
7
|
+
if(current?.activation===activation&¤t.mainPid===mainPid
|
|
8
|
+
&¤t.connectedHostPid===connectedHostPid)return {accepted:true};
|
|
9
|
+
const previous=current;
|
|
10
|
+
const next={mainPid,activation,connectedHostPid};current=next;
|
|
11
|
+
next.host=(async()=>{
|
|
12
|
+
if(previous)await previous.host.then(host=>host.dispose(),()=>{}).catch(report);
|
|
13
|
+
return activate(mainPid,desktop,connectedHostPid,{startup,prepare:startup});
|
|
14
|
+
})();
|
|
15
|
+
next.host.then(host=>{next.value=host;},error=>{next.error=error;report(error);});
|
|
16
|
+
return {accepted:true};
|
|
17
|
+
},
|
|
18
|
+
async status(){
|
|
19
|
+
let state;
|
|
20
|
+
try{state=current?.value?await current.value.status():
|
|
21
|
+
current?.error?{error:current.error.message}:{phase:'starting'};}
|
|
22
|
+
catch(error){state={error:error.message};}
|
|
23
|
+
if(!observe)return state;
|
|
24
|
+
try{
|
|
25
|
+
const token=await observe();
|
|
26
|
+
return {...state,protected:token.protected,currentProtected:token.protected,hostPid:token.pid};
|
|
27
|
+
}catch(error){return {...state,error:[state.error,error.message].filter(Boolean).join('; ')};}
|
|
28
|
+
},
|
|
29
|
+
async install(release){if(!current?.value)throw current?.error??Error('Updater startup is incomplete');return current.value.install(release);},
|
|
30
|
+
async exit(){if(!current?.value)throw current?.error??Error('Updater startup is incomplete');return current.value.exit();},
|
|
31
|
+
async later(){if(!current?.value)throw current?.error??Error('Updater startup is incomplete');return current.value.later();},
|
|
32
|
+
async dispose(){closed=true;if(current)await current.host.then(host=>host.dispose(),()=>{});},
|
|
33
|
+
};
|
|
34
|
+
}
|
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/contract.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const empty={type:'object',properties:{},additionalProperties:false};
|
|
2
|
+
export const Management={id:'finshield.opencode.management',methods:{
|
|
3
|
+
version:{input:empty,output:{type:'object',properties:{version:{type:'string'}},required:['version'],additionalProperties:false}},
|
|
4
|
+
...Object.fromEntries(['status','exit','later'].map(name=>[name,{input:empty,output:{type:'object',additionalProperties:true}}])),
|
|
5
|
+
install:{input:{type:'object',properties:{release:{type:'string'}},required:['release'],additionalProperties:false},output:{type:'object',additionalProperties:true}},
|
|
6
|
+
attach:{input:{type:'object',properties:{mainPid:{type:'integer',minimum:1},desktop:{type:'string',minLength:1},activation:{type:'string',minLength:1,maxLength:64},connectedHostPid:{type:'integer',minimum:1},startup:{type:'boolean'}},required:['mainPid','desktop','activation','connectedHostPid'],additionalProperties:false},
|
|
7
|
+
output:{type:'object',additionalProperties:true}},
|
|
8
|
+
},events:{}};
|
package/src/desktop.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {Management} from './contract.js';
|
|
2
|
+
import {DesktopAttachment} from './desktop-contract.js';
|
|
3
|
+
|
|
4
|
+
// OpenCode calls main for each desktop activation, including a reused service.
|
|
5
|
+
export function attachDesktop(ctx,mainPid=process.pid,activation=globalThis.crypto.randomUUID()){
|
|
6
|
+
const attach=async startup=>{
|
|
7
|
+
const client=ctx.client;
|
|
8
|
+
const host=await client.server.info({signal:ctx.signal});
|
|
9
|
+
await client.rpc(Management).attach({mainPid,desktop:process.execPath,activation,connectedHostPid:host.pid,startup},{signal:ctx.signal});
|
|
10
|
+
};
|
|
11
|
+
const initial=attach(true);
|
|
12
|
+
ctx.provide(DesktopAttachment,{attach:()=>initial.catch(()=>{}).then(()=>attach(false))});
|
|
13
|
+
void initial
|
|
14
|
+
.catch(error=>{if(!ctx.signal.aborted)ctx.log.write('error','FinShield desktop attachment failed',{error:String(error.message??error)});});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// The native sidecar reference is reactive; do not poll or call private IPC.
|
|
18
|
+
export function createEndpointAttachment({attach,report}){
|
|
19
|
+
let previous;
|
|
20
|
+
return server=>{
|
|
21
|
+
if(!server?.connected||!server.url||server.url===previous)return;
|
|
22
|
+
previous=server.url;
|
|
23
|
+
void Promise.resolve().then(attach).catch(report);
|
|
24
|
+
};
|
|
25
|
+
}
|