@twinsearth/ai-prison-dsh-plugin 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.md +8 -8
- package/client.js +28 -46
- package/lib/api.js +4 -4
- package/lib/tools.js +7 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@twinsearth/ai-prison-dsh-plugin` are recorded here.
|
|
4
4
|
|
|
5
|
+
## [1.1.4] — 2026-11-18
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- **Run drill failed on a second drill**: like `demo`, the CLI replays an
|
|
10
|
+
existing ledger and then refuses to re-seed credentials that an earlier drill
|
|
11
|
+
already revoked, so pressing **Run drill** on a ledger that already contained
|
|
12
|
+
drill events failed with `seed allocate: … credential "cred:resource:drl-N" is
|
|
13
|
+
present in the global revocation set`. A fresh ledger passes (157 records), and
|
|
14
|
+
demo-then-drill passes (233 records); only a second drill failed.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- **Both actions now start from a clean baseline**: pressing **Run demo** or
|
|
19
|
+
**Run drill** clears the CLI's own `seg-*.log` files first (two-click
|
|
20
|
+
confirmation when the ledger is not empty), so every run is deterministic.
|
|
21
|
+
The action posts `reset-demo` / `reset-drill` to `POST /api/ai-prison/run`;
|
|
22
|
+
the separate rebuild button is gone.
|
|
23
|
+
- `ai_prison_drill` attaches a `hint` for replay/seed-allocation failures, and
|
|
24
|
+
the panel explains the clear-first behaviour under the buttons.
|
|
25
|
+
|
|
5
26
|
## [1.1.3] — 2026-11-18
|
|
6
27
|
|
|
7
28
|
### Added
|
package/README.md
CHANGED
|
@@ -34,14 +34,14 @@ panel; the six tools become visible to the Agent on the next session step.
|
|
|
34
34
|
|
|
35
35
|
The panel shows the matrix from `ai_prison_levels` data plus the ledger
|
|
36
36
|
directory, integrity pill, record/segment/file counts; it refreshes every 20
|
|
37
|
-
seconds and on demand. Below the audit-chain card sit
|
|
38
|
-
**Run demo
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
`
|
|
37
|
+
seconds and on demand. Below the audit-chain card sit two explicit buttons —
|
|
38
|
+
**Run demo** and **Run drill** — which call `POST /api/ai-prison/run` and
|
|
39
|
+
therefore write the ledger only when pressed; the panel never writes on its own.
|
|
40
|
+
Both runs start from a clean baseline: when the ledger already has segments the
|
|
41
|
+
first click asks for confirmation, then the CLI's own `seg-*.log` files are
|
|
42
|
+
deleted and the action runs, because the CLI replays an existing ledger and
|
|
43
|
+
refuses to re-seed credentials that earlier runs already revoked (`demo` twice,
|
|
44
|
+
or a second `drill`, would otherwise fail).
|
|
45
45
|
|
|
46
46
|
## Ledger directory
|
|
47
47
|
|
package/client.js
CHANGED
|
@@ -39,14 +39,13 @@ window.__ModuleLoader__.load({
|
|
|
39
39
|
'cli.source': 'Source',
|
|
40
40
|
'action.refresh': 'Refresh',
|
|
41
41
|
'action.loading': 'Reading…',
|
|
42
|
-
'action.runDemo': 'Run demo
|
|
43
|
-
'action.runDrill': 'Run
|
|
44
|
-
'action.
|
|
45
|
-
'action.confirmReset': 'Click again to clear {records} records',
|
|
42
|
+
'action.runDemo': 'Run demo',
|
|
43
|
+
'action.runDrill': 'Run drill',
|
|
44
|
+
'action.confirmRun': 'Click again: clear {records} records and run',
|
|
46
45
|
'action.running': 'Running…',
|
|
47
46
|
'ledger.actions': 'Explicit actions',
|
|
48
|
-
'ledger.actionsHint': 'These buttons run the bundled CLI
|
|
49
|
-
'ledger.
|
|
47
|
+
'ledger.actionsHint': 'These buttons run the bundled CLI. An existing ledger is cleared first, so every run starts from a consistent baseline.',
|
|
48
|
+
'ledger.resetHint': 'The ledger already exists: a run clears its segments first, then executes. Click twice to confirm.',
|
|
50
49
|
'ledger.lastAction': 'Last action',
|
|
51
50
|
'meta.updated': 'Updated {time}',
|
|
52
51
|
'meta.readonly': 'Read-only view: the panel never writes by itself; only the buttons above do.',
|
|
@@ -79,14 +78,13 @@ window.__ModuleLoader__.load({
|
|
|
79
78
|
'cli.source': '来源',
|
|
80
79
|
'action.refresh': '刷新',
|
|
81
80
|
'action.loading': '读取中…',
|
|
82
|
-
'action.runDemo': '运行 demo
|
|
83
|
-
'action.runDrill': '
|
|
84
|
-
'action.
|
|
85
|
-
'action.confirmReset': '再次点击确认清空 {records} 条记录',
|
|
81
|
+
'action.runDemo': '运行 demo',
|
|
82
|
+
'action.runDrill': '运行演练',
|
|
83
|
+
'action.confirmRun': '再次点击:清空 {records} 条记录并运行',
|
|
86
84
|
'action.running': '运行中…',
|
|
87
85
|
'ledger.actions': '显式操作',
|
|
88
|
-
'ledger.actionsHint': '
|
|
89
|
-
'ledger.
|
|
86
|
+
'ledger.actionsHint': '这些按钮运行内置 CLI;账本已存在时会先清空,保证每次从一致基线开始。',
|
|
87
|
+
'ledger.resetHint': '账本已存在:运行会先清空账本段再执行;再次点击确认。',
|
|
90
88
|
'ledger.lastAction': '最近操作',
|
|
91
89
|
'meta.updated': '更新于 {time}',
|
|
92
90
|
'meta.readonly': '只读视图:面板不会自行写入账本,只有上方按钮会写入。',
|
|
@@ -271,9 +269,9 @@ window.__ModuleLoader__.load({
|
|
|
271
269
|
}
|
|
272
270
|
|
|
273
271
|
function LedgerCard({ ledger, cliFound, busy, onAction, lastResult }) {
|
|
274
|
-
const [
|
|
272
|
+
const [pending, setPending] = React.useState(null)
|
|
275
273
|
const exists = Boolean(ledger && ledger.exists)
|
|
276
|
-
const
|
|
274
|
+
const needsReset = exists && Number(ledger.segments ?? 0) > 0
|
|
277
275
|
const integrityTone = !exists ? 'none' : ledger.integrity === 'ok' ? 'ok' : 'error'
|
|
278
276
|
const integrityText = !exists ? t('integrity.none') : ledger.integrity === 'ok' ? t('integrity.ok') : t('integrity.failed')
|
|
279
277
|
const entries = [
|
|
@@ -289,14 +287,22 @@ window.__ModuleLoader__.load({
|
|
|
289
287
|
entries.push({ key: 'detail', label: t('ledger.detail'), value: h('span', { style: { ...C.mono, wordBreak: 'break-word' } }, ledger.detail) })
|
|
290
288
|
}
|
|
291
289
|
const disabled = Boolean(busy) || !cliFound
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
290
|
+
/** A non-empty ledger is cleared first; that run needs a second click. */
|
|
291
|
+
const run = (action) => {
|
|
292
|
+
if (needsReset && pending !== action) {
|
|
293
|
+
setPending(action)
|
|
295
294
|
return
|
|
296
295
|
}
|
|
297
|
-
|
|
298
|
-
onAction(
|
|
296
|
+
setPending(null)
|
|
297
|
+
onAction(needsReset ? `reset-${action}` : action)
|
|
299
298
|
}
|
|
299
|
+
const labelOf = (action, idle) => {
|
|
300
|
+
if (busy === action || busy === `reset-${action}`) return t('action.running')
|
|
301
|
+
if (needsReset && pending === action) return t('action.confirmRun', { records: ledger.records ?? '?' })
|
|
302
|
+
return t(idle)
|
|
303
|
+
}
|
|
304
|
+
const confirmStyle = (action) =>
|
|
305
|
+
needsReset && pending === action ? { ...C.actionBtn, color: '#b45309', borderColor: '#f59e0b' } : C.actionBtn
|
|
300
306
|
return h(
|
|
301
307
|
'section',
|
|
302
308
|
{ style: C.card },
|
|
@@ -313,35 +319,11 @@ window.__ModuleLoader__.load({
|
|
|
313
319
|
h(
|
|
314
320
|
'div',
|
|
315
321
|
{ style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap', marginTop: 10 } },
|
|
316
|
-
h(
|
|
317
|
-
|
|
318
|
-
{ type: 'button', style: C.actionBtn, disabled: disabled || !canDemo, onClick: () => onAction('demo') },
|
|
319
|
-
busy === 'demo' ? t('action.running') : t('action.runDemo'),
|
|
320
|
-
),
|
|
321
|
-
h(
|
|
322
|
-
'button',
|
|
323
|
-
{ type: 'button', style: C.actionBtn, disabled, onClick: () => onAction('drill') },
|
|
324
|
-
busy === 'drill' ? t('action.running') : t('action.runDrill'),
|
|
325
|
-
),
|
|
326
|
-
exists
|
|
327
|
-
? h(
|
|
328
|
-
'button',
|
|
329
|
-
{
|
|
330
|
-
type: 'button',
|
|
331
|
-
style: confirmReset ? { ...C.actionBtn, color: '#b45309', borderColor: '#f59e0b' } : C.actionBtn,
|
|
332
|
-
disabled,
|
|
333
|
-
onClick: rebuild,
|
|
334
|
-
},
|
|
335
|
-
busy === 'reset-demo'
|
|
336
|
-
? t('action.running')
|
|
337
|
-
: confirmReset
|
|
338
|
-
? t('action.confirmReset', { records: ledger.records ?? '?' })
|
|
339
|
-
: t('action.resetDemo'),
|
|
340
|
-
)
|
|
341
|
-
: null,
|
|
322
|
+
h('button', { type: 'button', style: confirmStyle('demo'), disabled, onClick: () => run('demo') }, labelOf('demo', 'action.runDemo')),
|
|
323
|
+
h('button', { type: 'button', style: confirmStyle('drill'), disabled, onClick: () => run('drill') }, labelOf('drill', 'action.runDrill')),
|
|
342
324
|
h('span', { style: { ...C.muted, fontSize: 11.5 } }, t('ledger.actionsHint')),
|
|
343
325
|
),
|
|
344
|
-
|
|
326
|
+
needsReset ? h('p', { style: { ...C.muted, fontSize: 12, margin: '8px 0 0' } }, t('ledger.resetHint')) : null,
|
|
345
327
|
lastResult
|
|
346
328
|
? h(
|
|
347
329
|
'p',
|
package/lib/api.js
CHANGED
|
@@ -31,7 +31,7 @@ export function resolveSessionCwd(ctx) {
|
|
|
31
31
|
return undefined
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
const ACTIONS = new Set(['demo', 'drill', 'reset', 'reset-demo'])
|
|
34
|
+
const ACTIONS = new Set(['demo', 'drill', 'reset', 'reset-demo', 'reset-drill'])
|
|
35
35
|
|
|
36
36
|
function jsonResponse(payload, status = 200) {
|
|
37
37
|
return Response.json(payload, { status, headers: { 'cache-control': 'no-store' } })
|
|
@@ -95,7 +95,7 @@ export function registerApi({ ctx, config = {}, logger } = {}) {
|
|
|
95
95
|
const dataDir = requested ? requested : resolveDataDir({ config, cwd })
|
|
96
96
|
|
|
97
97
|
let removed = []
|
|
98
|
-
if (action === 'reset' || action === 'reset-demo') {
|
|
98
|
+
if (action === 'reset' || action === 'reset-demo' || action === 'reset-drill') {
|
|
99
99
|
const reset = resetLedger(dataDir)
|
|
100
100
|
if (!reset.ok) {
|
|
101
101
|
return jsonResponse({ ok: false, action, dataDir, error: reset.error || 'reset failed' }, 500)
|
|
@@ -116,7 +116,7 @@ export function registerApi({ ctx, config = {}, logger } = {}) {
|
|
|
116
116
|
return jsonResponse({ ok: false, error: resolved.missing, reason: 'cli-missing' }, 409)
|
|
117
117
|
}
|
|
118
118
|
const timeoutMs = Number(config.timeoutMs) > 0 ? Number(config.timeoutMs) : 120_000
|
|
119
|
-
const runAction = action
|
|
119
|
+
const runAction = action.startsWith('reset-') ? action.slice('reset-'.length) : action
|
|
120
120
|
if (runAction === 'demo' && listSegments(dataDir).length > 0) {
|
|
121
121
|
return jsonResponse(
|
|
122
122
|
{
|
|
@@ -124,7 +124,7 @@ export function registerApi({ ctx, config = {}, logger } = {}) {
|
|
|
124
124
|
action,
|
|
125
125
|
dataDir,
|
|
126
126
|
error: 'ledger-not-empty',
|
|
127
|
-
hint: '账本已有记录:demo
|
|
127
|
+
hint: '账本已有记录:demo 需要空账本。请点「重置账本并重建」,或改用「运行演练」。',
|
|
128
128
|
},
|
|
129
129
|
409,
|
|
130
130
|
)
|
package/lib/tools.js
CHANGED
|
@@ -190,6 +190,13 @@ export async function installTools({ ctx, config = {}, logger } = {}) {
|
|
|
190
190
|
output: stringOutput,
|
|
191
191
|
async execute(args, exec) {
|
|
192
192
|
const outcome = await invoke({ ctx, config, exec, subcommand: 'drill', dataDir: args?.data_dir })
|
|
193
|
+
if (!outcome.ok) {
|
|
194
|
+
const text = `${outcome.payload.stdout || ''}\n${outcome.payload.stderr || ''}`
|
|
195
|
+
if (/reopened ledger|seed allocate/i.test(text)) {
|
|
196
|
+
outcome.payload.hint =
|
|
197
|
+
'账本已被此前的演练写入:再次演练会重放旧事件并拒绝重新分配已吊销的凭据。请清空该数据目录下的 seg-*.log(或换一个空 data_dir)后重试;面板的「运行演练」会自动先清空。'
|
|
198
|
+
}
|
|
199
|
+
}
|
|
193
200
|
return toolResult(outcome.payload)
|
|
194
201
|
},
|
|
195
202
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twinsearth/ai-prison-dsh-plugin",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "AI Prison for DSH: six governance tools wrapping the aiprison CLI (levels, 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",
|