@twinsearth/ai-prison-dsh-plugin 1.7.2 → 1.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/README.md +19 -9
- package/client.js +8 -5
- package/docs/SUPPLY-CHAIN.md +166 -0
- package/lib/notifier.js +1 -0
- package/lib/remediation.js +1 -1
- package/lib/status.js +3 -1
- package/lib/tools.js +29 -6
- package/lib/version.js +17 -0
- package/lib/watchdog-enforcement.js +11 -0
- package/lib/watchdog-persistence.js +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,47 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@twinsearth/ai-prison-dsh-plugin` are recorded here.
|
|
4
4
|
|
|
5
|
+
## [1.7.4] — 2026-11-19
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- Enforcement card: the Top5 action button now reads **立即缉拿 / Arrest now**
|
|
10
|
+
(previously 立即关闭 / Close now), and its confirmation prompt uses the same
|
|
11
|
+
wording. The underlying action is unchanged (close the plugin); only the
|
|
12
|
+
AI-Prison-themed label changed.
|
|
13
|
+
- Enabling a quarantined plugin from the UI is immediately closed again and raises
|
|
14
|
+
a tray notification: **请到 AI 监狱释放该插件!再开启。** The reminder is forced
|
|
15
|
+
even when general notifications are off (rate limited per kind).
|
|
16
|
+
- Header version pill shows the **plugin version** (`AI Prison vX.Y.Z`) instead of
|
|
17
|
+
the bundled aiprison CLI version; the CLI version stays in the footer. Before,
|
|
18
|
+
the pill always read `aiprison 1.0.9` regardless of plugin releases.
|
|
19
|
+
|
|
20
|
+
## [1.7.3] — 2026-11-19
|
|
21
|
+
## [1.7.3] — 2026-11-19
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- **Official tool API**: tools register through `ctx.tools.register(plainDefinition)`
|
|
26
|
+
first (Host `ToolDefinition` contract); `defineTool` from
|
|
27
|
+
`@deepseek-ai/dsh-tools` is now only a legacy fallback, so registration no
|
|
28
|
+
longer depends on installation-path guessing.
|
|
29
|
+
- **Artifact attestation**: the release workflow attests the npm tarball, the
|
|
30
|
+
six platform-lite tarballs and `SHA256SUMS` (`actions/attest-build-provenance`).
|
|
31
|
+
- **SignPath OSS signing wired**: conditional workflow steps upload the Windows
|
|
32
|
+
CLIs, request Authenticode signing (wait for completion), replace the binaries
|
|
33
|
+
and continue; without SignPath variables the build stays unsigned with an
|
|
34
|
+
explicit warning. Setup, variables and verification are documented in
|
|
35
|
+
`docs/SUPPLY-CHAIN.md`.
|
|
36
|
+
- **Full-platform distribution**: the release also builds six platform-lite
|
|
37
|
+
tarballs (1.37–1.56 MB each) next to the all-platform tarball, with checksums
|
|
38
|
+
and attestation; the npm package layout is unchanged.
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
|
|
42
|
+
- `scripts/pack-platform.mjs` gained `--all`, exported argument parsing, target
|
|
43
|
+
suffixes and three tests; release assets no longer overwrite each other.
|
|
44
|
+
|
|
45
|
+
## [1.7.2] — 2026-11-19
|
|
5
46
|
## [1.7.2] — 2026-11-19
|
|
6
47
|
|
|
7
48
|
### Fixed
|
package/README.md
CHANGED
|
@@ -109,25 +109,35 @@ library, `CGO_ENABLED=0`, no module downloads) and are not committed to git.
|
|
|
109
109
|
|
|
110
110
|
### Per-platform packaging (size)
|
|
111
111
|
|
|
112
|
-
The published tarball carries all six CLIs (about 8.8 MB packed). For a
|
|
113
|
-
single-machine deployment
|
|
114
|
-
|
|
112
|
+
The published npm tarball carries all six CLIs (about 8.8 MB packed). For a
|
|
113
|
+
single-machine deployment, build a platform-lite tarball that keeps only one
|
|
114
|
+
`bin/<platform>-<arch>/` tree:
|
|
115
115
|
|
|
116
116
|
```bash
|
|
117
117
|
cd dsh-plugin
|
|
118
118
|
node scripts/pack-platform.mjs --platform windows --arch amd64 --out ../dist
|
|
119
|
-
# prints { target, tarball, sizeMB,
|
|
120
|
-
node scripts/pack-platform.mjs --
|
|
119
|
+
# prints { target, tarball, sizeMB, platformBinaryMB, skippedTargets }
|
|
120
|
+
node scripts/pack-platform.mjs --all --out ../dist/platform-packs # six assets
|
|
121
|
+
node scripts/pack-platform.mjs --all --dry-run
|
|
121
122
|
```
|
|
122
123
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
The release workflow now builds all six lite tarballs, checksums them together
|
|
125
|
+
with the all-platform tarball, attests the whole set and attaches them to the
|
|
126
|
+
GitHub Release. The npm package keeps the all-platform layout: the lite
|
|
127
|
+
tarballs are an offline/air-gapped option, not a replacement for `npm install`.
|
|
127
128
|
|
|
128
129
|
On a platform without a bundled build, point `cliPath` / `AIPRISON_BIN` at a
|
|
129
130
|
binary built from `cmd/aiprison`.
|
|
130
131
|
|
|
132
|
+
## Supply chain
|
|
133
|
+
|
|
134
|
+
Tool registration uses the official `ctx.tools.register(plainDefinition)` seam
|
|
135
|
+
(`defineTool` remains only as a legacy fallback), and release artifacts get a
|
|
136
|
+
GitHub artifact attestation. Code signing (Windows Authenticode, macOS
|
|
137
|
+
notarization, Linux detached signatures) needs a certificate/upstream decision;
|
|
138
|
+
see [docs/SUPPLY-CHAIN.md](docs/SUPPLY-CHAIN.md) for the concrete options and
|
|
139
|
+
verification commands.
|
|
140
|
+
|
|
131
141
|
## Development
|
|
132
142
|
|
|
133
143
|
```bash
|
package/client.js
CHANGED
|
@@ -17,6 +17,7 @@ window.__ModuleLoader__.load({
|
|
|
17
17
|
const DICTS = {
|
|
18
18
|
en: {
|
|
19
19
|
'panel.label': 'AI Prison',
|
|
20
|
+
'panel.version': 'AI Prison v{version}',
|
|
20
21
|
'page.title': 'AI Prison',
|
|
21
22
|
'page.subtitle': 'Graduated capability deprivation for agents. Every backend is simulated.',
|
|
22
23
|
'matrix.title': 'L0–L5 grading matrix',
|
|
@@ -63,7 +64,7 @@ window.__ModuleLoader__.load({
|
|
|
63
64
|
'watchdog.noQuarantine': 'No quarantined plugins.',
|
|
64
65
|
'watchdog.release': 'Release',
|
|
65
66
|
'watchdog.topFive': 'Top {n} by estimated heap',
|
|
66
|
-
'watchdog.close': '
|
|
67
|
+
'watchdog.close': 'Arrest now',
|
|
67
68
|
'watchdog.plans': 'Crash plans',
|
|
68
69
|
'watchdog.baseline': 'Clean baseline: {at}',
|
|
69
70
|
'watchdog.tamper': 'Profile watch: {n} critical file(s) · policy {policy} · last check {at}',
|
|
@@ -97,6 +98,7 @@ window.__ModuleLoader__.load({
|
|
|
97
98
|
},
|
|
98
99
|
zh: {
|
|
99
100
|
'panel.label': 'AI Prison',
|
|
101
|
+
'panel.version': 'AI Prison v{version}',
|
|
100
102
|
'page.title': 'AI Prison · AI 监狱',
|
|
101
103
|
'page.subtitle': '面向 AI Agent 的分级能力剥夺与行为矫正;所有后端均为内存模拟。',
|
|
102
104
|
'matrix.title': 'L0–L5 分级矩阵',
|
|
@@ -143,7 +145,7 @@ window.__ModuleLoader__.load({
|
|
|
143
145
|
'watchdog.noQuarantine': '没有被隔离的插件。',
|
|
144
146
|
'watchdog.release': '假释',
|
|
145
147
|
'watchdog.topFive': '按估算内存排序的前 {n} 个插件',
|
|
146
|
-
'watchdog.close': '
|
|
148
|
+
'watchdog.close': '立即缉拿',
|
|
147
149
|
'watchdog.plans': '崩溃降级计划',
|
|
148
150
|
'watchdog.baseline': '干净基线:{at}',
|
|
149
151
|
'watchdog.tamper': '配置监控:{n} 个关键文件 · 策略 {policy} · 最近检查 {at}',
|
|
@@ -524,7 +526,7 @@ window.__ModuleLoader__.load({
|
|
|
524
526
|
h('td', { style: { ...C.td, ...C.mono, fontSize: 11.5, wordBreak: 'break-all' } }, row.target),
|
|
525
527
|
h('td', { style: C.td }, row.estimateMB + ' MB'),
|
|
526
528
|
h('td', { style: C.td }, (row.rssMB || 0) + ' MB'),
|
|
527
|
-
h('td', { style: C.td }, h('button', { style: button, onClick: () => act('close', row.target, '
|
|
529
|
+
h('td', { style: C.td }, h('button', { style: button, onClick: () => act('close', row.target, '立即缉拿 ' + row.target + ' ?') }, t('watchdog.close'))),
|
|
528
530
|
))),
|
|
529
531
|
),
|
|
530
532
|
),
|
|
@@ -719,6 +721,7 @@ window.__ModuleLoader__.load({
|
|
|
719
721
|
|
|
720
722
|
const cli = data?.cli
|
|
721
723
|
const cliText = cli && cli.found ? t('cli.found', { version: cli.version || '?' }) : t('cli.missing')
|
|
724
|
+
const pillText = data && data.pluginVersion ? t('panel.version', { version: data.pluginVersion }) : cliText
|
|
722
725
|
const timeText = updated ? updated.toLocaleTimeString() : ''
|
|
723
726
|
|
|
724
727
|
return h(
|
|
@@ -729,7 +732,7 @@ window.__ModuleLoader__.load({
|
|
|
729
732
|
{ style: C.header },
|
|
730
733
|
h('span', { style: { display: 'inline-flex' } }, h(PrisonIcon, { size: 26, active: true })),
|
|
731
734
|
h('div', { style: { minWidth: 0 } }, h('h1', { style: C.title }, t('page.title')), h('p', { style: C.sub }, t('page.subtitle'))),
|
|
732
|
-
h(Pill, { tone: cli && cli.found ? 'ok' : 'error', text:
|
|
735
|
+
h(Pill, { tone: cli && cli.found ? 'ok' : 'error', text: pillText }),
|
|
733
736
|
h('button', { type: 'button', style: C.btn, onClick: load, disabled: loading }, loading ? t('action.loading') : t('action.refresh')),
|
|
734
737
|
),
|
|
735
738
|
error
|
|
@@ -756,7 +759,7 @@ window.__ModuleLoader__.load({
|
|
|
756
759
|
'p',
|
|
757
760
|
{ style: { ...C.muted, fontSize: 12, margin: '2px 0 0', display: 'flex', gap: 12, flexWrap: 'wrap' } },
|
|
758
761
|
h('span', null, t('meta.readonly')),
|
|
759
|
-
cli && cli.path ? h('span', { style: C.mono }, `${t('cli.source')}: ${cli.source} · ${cli.path}`) : null,
|
|
762
|
+
cli && cli.path ? h('span', { style: C.mono }, `${t('cli.source')}: ${cli.source} · ${cli.path} · aiprison ${cli.version || '?'}`) : null,
|
|
760
763
|
timeText ? h('span', null, t('meta.updated', { time: timeText })) : null,
|
|
761
764
|
),
|
|
762
765
|
)
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# Supply chain: official tool API, signing and provenance
|
|
2
|
+
|
|
3
|
+
Status: strategy document, 2026-11-19. Code signing needs a certificate/upstream
|
|
4
|
+
decision; everything in “Implemented now” already ships with 1.7.2.
|
|
5
|
+
|
|
6
|
+
## 1. Official Host API for tool registration
|
|
7
|
+
|
|
8
|
+
Fact from the installed DSH version (`cordis_inspect_query` → `tools` service):
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
register(definition: ToolDefinition, options?: ToolRegistrationOptions): () => void;
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
`ToolDefinition` is a plain object: `name`, `description`, `parameters`,
|
|
15
|
+
`output` and `execute`. `defineTool` from `@deepseek-ai/dsh-tools` is not part of
|
|
16
|
+
the required seam.
|
|
17
|
+
|
|
18
|
+
What the plugin does now:
|
|
19
|
+
|
|
20
|
+
1. `ctx.inject(['tools'])` → `child.tools.register(plainDefinition)` — official
|
|
21
|
+
path, no package-path guessing.
|
|
22
|
+
2. Only if that throws (older harness build) it falls back to
|
|
23
|
+
`defineTool(definition)` resolved through `lib/harness.js`.
|
|
24
|
+
3. The path-guessing anchors therefore no longer gate tool registration; they
|
|
25
|
+
are a best-effort compatibility fallback and never the primary code path.
|
|
26
|
+
|
|
27
|
+
Bundled packages resolve from the DSH installation and profile bundles from the
|
|
28
|
+
profile, so a bundle must not guess `@deepseek-ai/*` locations from
|
|
29
|
+
`$DSH_PROFILE_DIR` (see the installed DSH plugin-development documentation).
|
|
30
|
+
`lib/harness.js` remains only for the legacy fallback and is covered by tests.
|
|
31
|
+
|
|
32
|
+
## 2. Signing strategy (needs a certificate / upstream decision)
|
|
33
|
+
|
|
34
|
+
| Target | Recommended option | Requirements | Status |
|
|
35
|
+
|---|---|---|---|
|
|
36
|
+
| Windows `aiprison.exe` (6 builds) | Azure Trusted Signing (cheaper, CI-native) or an OV/EV Authenticode certificate; SignPath.io offers free OSS signing | Azure account/subscription or CA-issued cert; `signtool` with timestamp server | not signed |
|
|
37
|
+
| macOS `aiprison` | Apple Developer ID Application + `notarytool` (hardened runtime), staple the ticket | Apple Developer Program (~99 USD/year) | not signed/not notarized |
|
|
38
|
+
| Linux `aiprison` | Detached signature: `minisign`/`cosign` over `SHA256SUMS`, or upstream distro signing | maintainer key, published public key | checksums only |
|
|
39
|
+
| npm tarball | npm registry integrity (`sha512`) + GitHub Release `SHA256SUMS` | none (already done) | done |
|
|
40
|
+
| CI artifacts | GitHub artifact attestation (`actions/attest-build-provenance`) | public repo; `id-token`/`attestations` permissions | added in 1.7.2 workflow |
|
|
41
|
+
| npm provenance | `npm publish --provenance` from CI with OIDC | publish must move from a maintainer laptop into CI (currently manual due 2FA) | not enabled |
|
|
42
|
+
|
|
43
|
+
No private key belongs in the repository. Signing steps run in CI with secrets
|
|
44
|
+
(`WINDOWS_CERT_*`, `APPLE_ID_*`, `APPLE_TEAM_ID`, `APPLE_APP_PASSWORD` or a
|
|
45
|
+
self-hosted signer); the repo only documents and verifies the result.
|
|
46
|
+
|
|
47
|
+
### Verification users can run today
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# npm integrity (registry)
|
|
51
|
+
npm view @twinsearth/ai-prison-dsh-plugin@1.7.2 dist.integrity
|
|
52
|
+
|
|
53
|
+
# GitHub Release checksum
|
|
54
|
+
curl -LO https://github.com/TwinsEarth/Ai-PRISON/releases/download/dsh-plugin-v1.7.2/SHA256SUMS
|
|
55
|
+
sha256sum -c SHA256SUMS # or: Get-FileHash <tgz> -Algorithm SHA256
|
|
56
|
+
|
|
57
|
+
# per-platform lite tarball (unsigned, local build)
|
|
58
|
+
node dsh-plugin/scripts/pack-platform.mjs --platform windows --arch amd64
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Recommended rollout once a certificate exists
|
|
62
|
+
|
|
63
|
+
1. Windows: sign all six `aiprison.exe` in `scripts/build-binaries.mjs` before
|
|
64
|
+
the tarball is packed; verify with `Get-AuthenticodeSignature`.
|
|
65
|
+
2. macOS: codesign + notarize the two Mach-O builds, staple and verify with
|
|
66
|
+
`codesign --verify --strict` / `spctl -a`.
|
|
67
|
+
3. Publish `SHA256SUMS` plus a detached `SHA256SUMS.minisig`.
|
|
68
|
+
4. Move `npm publish` into the tag workflow with `--provenance` (removes the
|
|
69
|
+
manual 2FA step) once the release guard/approval policy allows it.
|
|
70
|
+
5. Add a CI check that fails when a Windows/macOS artifact is unsigned.
|
|
71
|
+
|
|
72
|
+
## 3. What remains open (honest list)
|
|
73
|
+
|
|
74
|
+
- No code-signing certificate is available to this project yet; the binaries
|
|
75
|
+
remain unsigned, and the README “Limitations” notes the Controlled Folder
|
|
76
|
+
Access / SmartScreen consequences.
|
|
77
|
+
- Official-API adoption is implemented (plain `register` first); the legacy
|
|
78
|
+
`defineTool` fallback can be removed after the minimum supported DSH version
|
|
79
|
+
is known to accept plain definitions everywhere.
|
|
80
|
+
- npm provenance requires publishing from CI, which conflicts with the current
|
|
81
|
+
manual/2FA publish flow; decide whether to move publishing.
|
|
82
|
+
|
|
83
|
+
## 4. Full-platform distribution strategy (P2-5)
|
|
84
|
+
|
|
85
|
+
**Current (implemented in the release workflow):**
|
|
86
|
+
|
|
87
|
+
| Channel | Artifact | Size |
|
|
88
|
+
|---|---|---|
|
|
89
|
+
| npm | one tarball with all six `bin/<platform>-<arch>/` trees | ~7.1 MB tgz (~8.8 MB unpacked) |
|
|
90
|
+
| GitHub Release | the same all-platform tarball **plus six lite tarballs** `<name>-<version>-<platform>-<arch>.tgz` | ~1.4–1.6 MB each |
|
|
91
|
+
| GitHub Release | `SHA256SUMS` covering the full tarball **and** the six lite ones | — |
|
|
92
|
+
| GitHub Release | artifact attestation over all tarballs + `SHA256SUMS` | — |
|
|
93
|
+
|
|
94
|
+
Lite tarballs are built with `scripts/pack-platform.mjs --all`; each keeps only
|
|
95
|
+
one binary tree and still contains the same Host/Client code, locale, docs and
|
|
96
|
+
manifest. They are meant for offline/air-gapped machines:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# on the target machine, after downloading the matching lite tarball
|
|
100
|
+
npm install ./twinsearth-ai-prison-dsh-plugin-<version>-windows-amd64.tgz
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Measured with 1.7.2: windows-amd64 1.56 MB, windows-arm64 1.40 MB,
|
|
104
|
+
macos-amd64 1.52 MB, macos-arm64 1.41 MB, linux-amd64 1.50 MB, linux-arm64 1.37 MB
|
|
105
|
+
(six together 8.8 MB, i.e. the same bytes as one all-platform tarball).
|
|
106
|
+
|
|
107
|
+
**Not done yet (needs a decision):** splitting the npm package itself into a
|
|
108
|
+
meta-package plus six `@twinsearth/ai-prison-cli-<platform>` optional
|
|
109
|
+
dependencies (the esbuild/swc pattern). That would cut a normal `npm install`
|
|
110
|
+
to ~1.5 MB, but it requires publishing seven packages, keeping their versions in
|
|
111
|
+
lockstep, and reworking the release/2FA flow. The all-platform npm package stays
|
|
112
|
+
the default until that is explicitly approved.
|
|
113
|
+
|
|
114
|
+
## 5. SignPath OSS signing (CI wired)
|
|
115
|
+
|
|
116
|
+
SignPath.io signs open-source Windows binaries for free. The release workflow
|
|
117
|
+
already contains the integration; it stays inactive until the repository is
|
|
118
|
+
configured, and prints a warning with an unsigned fallback otherwise.
|
|
119
|
+
|
|
120
|
+
### One-time SignPath setup
|
|
121
|
+
|
|
122
|
+
1. Apply to the [SignPath Foundation/OSS program](https://signpath.io/) and
|
|
123
|
+
install the SignPath GitHub app on `TwinsEarth/Ai-PRISON`.
|
|
124
|
+
2. Create an organization and a project for this repository.
|
|
125
|
+
3. Artifact configuration (ZIP-root paths):
|
|
126
|
+
- `windows-amd64/aiprison.exe`
|
|
127
|
+
- `windows-arm64/aiprison.exe`
|
|
128
|
+
The workflow uploads `dsh-plugin/bin/windows-*` as the `unsigned-windows-clis`
|
|
129
|
+
artifact; the artifact configuration signs every `aiprison.exe` with
|
|
130
|
+
Authenticode and returns the same layout under `signed-windows/`.
|
|
131
|
+
4. Create a signing policy (e.g. `release-signing`) with the Authenticode
|
|
132
|
+
signing tool; note the policy slug.
|
|
133
|
+
|
|
134
|
+
### Repository variables and secret
|
|
135
|
+
|
|
136
|
+
| Kind | Name | Value |
|
|
137
|
+
|---|---|---|
|
|
138
|
+
| Variable | `SIGNPATH_ORGANIZATION_ID` | SignPath organization id |
|
|
139
|
+
| Variable | `SIGNPATH_PROJECT_SLUG` | project slug |
|
|
140
|
+
| Variable | `SIGNPATH_SIGNING_POLICY_SLUG` | signing policy slug |
|
|
141
|
+
| Variable | `SIGNPATH_ARTIFACT_CONFIGURATION_SLUG` | artifact configuration slug |
|
|
142
|
+
| Secret | `SIGNPATH_API_TOKEN` | API token (never committed) |
|
|
143
|
+
|
|
144
|
+
### Workflow behavior
|
|
145
|
+
|
|
146
|
+
- Steps `Upload unsigned Windows CLIs`, `Sign Windows CLIs with SignPath` and
|
|
147
|
+
`Install signed Windows CLIs` run only when the two variables above are set;
|
|
148
|
+
the action is `signpath/github-action-submit-signing-request@v3` with
|
|
149
|
+
`wait-for-completion: true` and `output-artifact-directory: signed-windows`;
|
|
150
|
+
- the job needs `actions: read` (download the uploaded artifact) in addition to
|
|
151
|
+
`contents: read`;
|
|
152
|
+
- after a successful signing request the signed `aiprison.exe` files replace the
|
|
153
|
+
unsigned ones before tests, tarballs, checksums and attestation run;
|
|
154
|
+
- without credentials the steps are skipped and `::warning::` names this doc;
|
|
155
|
+
Windows binaries stay unsigned (current default).
|
|
156
|
+
|
|
157
|
+
### Verification once signing is active
|
|
158
|
+
|
|
159
|
+
```powershell
|
|
160
|
+
# on a Windows machine after downloading the release binary
|
|
161
|
+
Get-AuthenticodeSignature .\aiprison.exe | Format-List Status,SignerCertificate
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
The GitHub Release attestation also covers the signed tarballs, so a verifier
|
|
165
|
+
can tie the artifact back to the workflow run (`gh attestation verify <tgz>
|
|
166
|
+
--repo TwinsEarth/Ai-PRISON`).
|
package/lib/notifier.js
CHANGED
package/lib/remediation.js
CHANGED
|
@@ -24,7 +24,7 @@ const REMEDIATION = {
|
|
|
24
24
|
steps: [
|
|
25
25
|
'先重启 DSH,确认在没有该插件时环境稳定。',
|
|
26
26
|
'检查插件版本是否有修复(升级到最新版),或查看其 README 的已知崩溃问题。',
|
|
27
|
-
'
|
|
27
|
+
'确需继续使用时,先在面板"插件监狱"点"假释",再开启;直接开启会被立即缉拿并弹窗提醒。',
|
|
28
28
|
],
|
|
29
29
|
release: '仅手动释放(面板"假释");重启不会自动解除,防止崩溃循环。',
|
|
30
30
|
},
|
package/lib/status.js
CHANGED
|
@@ -2,6 +2,7 @@ import { existsSync, readdirSync } from 'node:fs'
|
|
|
2
2
|
import { describeCli, resolveCli, resolveDataDir, runCli } from './cli.js'
|
|
3
3
|
import { parseLevels } from './levels.js'
|
|
4
4
|
import { listSegments } from './ledger.js'
|
|
5
|
+
import { PLUGIN_VERSION } from './version.js'
|
|
5
6
|
|
|
6
7
|
const MAX_DETAIL = 600
|
|
7
8
|
|
|
@@ -70,6 +71,7 @@ export async function buildStatus({ config = {}, cwd, timeoutMs = 120_000, root
|
|
|
70
71
|
generatedAt: new Date().toISOString(),
|
|
71
72
|
cwd: cwd || null,
|
|
72
73
|
platform: `${process.platform}-${process.arch}`,
|
|
74
|
+
pluginVersion: PLUGIN_VERSION,
|
|
73
75
|
cli,
|
|
74
76
|
levels,
|
|
75
77
|
ledger,
|
|
@@ -79,7 +81,7 @@ export async function buildStatus({ config = {}, cwd, timeoutMs = 120_000, root
|
|
|
79
81
|
/** Bounded human summary used by tool results. */
|
|
80
82
|
export function statusSummary(status) {
|
|
81
83
|
const cliLine = status.cli.found
|
|
82
|
-
? `aiprison ${status.cli.version || '?'}(${status.cli.source}: ${status.cli.path})`
|
|
84
|
+
? `AI Prison v${status.pluginVersion || '?'} · aiprison ${status.cli.version || '?'}(${status.cli.source}: ${status.cli.path})`
|
|
83
85
|
: `CLI 不可用:${status.cli.error || 'unknown'}`
|
|
84
86
|
const ledgerLine = status.ledger.exists
|
|
85
87
|
? `账本 ${status.ledger.dir}:${status.ledger.integrity === 'ok' ? `INTEGRITY OK(${status.ledger.records ?? '?'} 条记录)` : `校验失败(${status.ledger.detail})`}`
|
package/lib/tools.js
CHANGED
|
@@ -97,17 +97,39 @@ function toolResult(payload) {
|
|
|
97
97
|
return JSON.stringify(payload, null, 2)
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Register one tool definition.
|
|
102
|
+
*
|
|
103
|
+
* The official Host API is `ctx.tools.register(definition)` and accepts a plain
|
|
104
|
+
* ToolDefinition (name/description/parameters/output/execute). `defineTool` from
|
|
105
|
+
* @deepseek-ai/dsh-tools is only a compatibility fallback for older harness
|
|
106
|
+
* builds; resolving it by guessing an installation path must never be required.
|
|
107
|
+
*/
|
|
108
|
+
export function registerToolDefinition(tools, definition, { defineTool } = {}) {
|
|
109
|
+
try {
|
|
110
|
+
tools.register(definition)
|
|
111
|
+
return 'plain'
|
|
112
|
+
} catch (error) {
|
|
113
|
+
if (typeof defineTool !== 'function') throw error
|
|
114
|
+
tools.register(defineTool(definition))
|
|
115
|
+
return 'fallback'
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
100
119
|
export async function installTools({ ctx, config = {}, logger } = {}) {
|
|
101
120
|
if (!ctx || typeof ctx.inject !== 'function') {
|
|
102
121
|
logger?.warn?.('ctx.inject 不可用,跳过 aiprison_* 工具注册')
|
|
103
122
|
return false
|
|
104
123
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
124
|
+
// Official API first: ctx.tools.register accepts a plain ToolDefinition.
|
|
125
|
+
// defineTool is loaded lazily only as a fallback for older harness builds.
|
|
126
|
+
let defineTool
|
|
127
|
+
try {
|
|
128
|
+
const loaded = await loadDefineTool()
|
|
129
|
+
defineTool = loaded && loaded.defineTool
|
|
130
|
+
} catch {
|
|
131
|
+
defineTool = undefined
|
|
109
132
|
}
|
|
110
|
-
const { defineTool } = loaded
|
|
111
133
|
const stringOutput = {
|
|
112
134
|
schema: { type: 'string' },
|
|
113
135
|
render: (_args, value) => [{ type: 'text', text: String(value) }],
|
|
@@ -120,7 +142,8 @@ export async function installTools({ ctx, config = {}, logger } = {}) {
|
|
|
120
142
|
ctx.inject(['tools'], (child) => {
|
|
121
143
|
const register = (definition) => {
|
|
122
144
|
try {
|
|
123
|
-
child.tools
|
|
145
|
+
const mode = registerToolDefinition(child.tools, definition, { defineTool })
|
|
146
|
+
if (mode === 'fallback') logger?.info?.(`工具 ${definition.name} 使用 defineTool 兼容路径注册`)
|
|
124
147
|
} catch (error) {
|
|
125
148
|
logger?.warn?.(`注册工具 ${definition.name} 失败:${String(error && error.message)}`)
|
|
126
149
|
}
|
package/lib/version.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import { fileURLToPath } from 'node:url'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Version of the installed plugin package.
|
|
6
|
+
*
|
|
7
|
+
* The panel must show the bundle version (which follows releases), not the
|
|
8
|
+
* bundled aiprison CLI version (which is the Go tool's own 1.0.x line).
|
|
9
|
+
*/
|
|
10
|
+
export const PLUGIN_VERSION = (() => {
|
|
11
|
+
try {
|
|
12
|
+
const manifest = fileURLToPath(new URL('../package.json', import.meta.url))
|
|
13
|
+
return JSON.parse(fs.readFileSync(manifest, 'utf8')).version || null
|
|
14
|
+
} catch {
|
|
15
|
+
return null
|
|
16
|
+
}
|
|
17
|
+
})()
|
|
@@ -124,6 +124,17 @@ export function createEnforcement({ watchdogState, refs, dataDir, journalDir, ex
|
|
|
124
124
|
entry.lastApplication = operation.application || null
|
|
125
125
|
watchdogState.operations.set(target, entry)
|
|
126
126
|
const additive = operation.stage === 'install' || (operation.stage === 'enable' && operation.enabled !== false)
|
|
127
|
+
if (operation.stage === 'enable' && operation.enabled !== false && watchdogState.enforce && watchdogState.quarantine.has(target)) {
|
|
128
|
+
const quarantined = watchdogState.quarantine.get(target)
|
|
129
|
+
appendIncident({
|
|
130
|
+
kind: 'quarantine-reminder',
|
|
131
|
+
target,
|
|
132
|
+
level: quarantined.level,
|
|
133
|
+
notify: true,
|
|
134
|
+
detail: '请到,AI监狱释放该插件!再开启。(原因:' + quarantined.reason + ';本次开启已被立即关闭)',
|
|
135
|
+
})
|
|
136
|
+
void disableTarget(target, 'quarantined-enable')
|
|
137
|
+
}
|
|
127
138
|
if (
|
|
128
139
|
watchdogState.enforce
|
|
129
140
|
&& additive
|
|
@@ -95,7 +95,8 @@ export function createPersistence({ watchdogState, stateFile, incidentsFile }) {
|
|
|
95
95
|
|
|
96
96
|
function appendIncident(incident) {
|
|
97
97
|
const record = { at: new Date().toISOString(), mode: watchdogState.mode, ...incident }
|
|
98
|
-
|
|
98
|
+
const notificationKinds = ['freeze', 'pause', 'quarantine', 'tamper', 'crash-enforced', 'budget', 'quarantine-reminder']
|
|
99
|
+
if ((record.notify === true || (watchdogState.config && watchdogState.config.notify === true)) && notificationKinds.includes(record.kind)) {
|
|
99
100
|
try {
|
|
100
101
|
notify(record)
|
|
101
102
|
} catch {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twinsearth/ai-prison-dsh-plugin",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.4",
|
|
4
4
|
"description": "AI Prison for DSH: eight governance tools wrapping the aiprison CLI (levels, status, watchdog status, demo, drill, inspect, verify, repair-tail) plus a panel for the L0–L5 matrix and the audit-chain state. The CLI ships bundled for Windows, macOS and Linux; every capability-removal backend stays simulated.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|