@twinsearth/ai-prison-dsh-plugin 1.1.1 → 1.1.2

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 CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  All notable changes to `@twinsearth/ai-prison-dsh-plugin` are recorded here.
4
4
 
5
+ ## [1.1.2] — 2026-11-18
6
+
7
+ ### Fixed
8
+
9
+ - **Tool ledger default**: `workingDirectory.get` expects a `Session`, but the
10
+ tool execution context only carries an Agent id, so the lookup threw and every
11
+ `ai_prison_*` tool fell back to the Host launch directory
12
+ (`…/.dsh/profiles/desktop/.ai-prison`). The tools now resolve the Session
13
+ through `ctx.sessions.get(agent.id)`, then its effective directory, then its
14
+ original header `cwd`, and only then the Host default. Ledgers therefore land
15
+ in the session workspace by default, matching the panel.
16
+
5
17
  ## [1.1.1] — 2026-11-18
6
18
 
7
19
  ### Added
package/lib/tools.js CHANGED
@@ -14,18 +14,41 @@ export function bounded(result, { lines = TAIL_LINES, max = MAX_TEXT } = {}) {
14
14
  return clipped.length > max ? `${clipped.slice(-max)}…[截断]` : clipped
15
15
  }
16
16
 
17
- function cwdOf(ctx, exec) {
17
+ /**
18
+ * The session a tool call belongs to. `workingDirectory.get` expects a Session,
19
+ * not the Agent id the execution context carries, so map it through `sessions`.
20
+ */
21
+ export function resolveToolCwd(ctx, exec) {
22
+ const get = (key) => (ctx && typeof ctx.get === 'function' ? ctx.get(key) : undefined)
18
23
  try {
19
- const wd = ctx && typeof ctx.get === 'function' ? ctx.get('workingDirectory') : undefined
20
- const fromService = wd && typeof wd.get === 'function' && exec && exec.agent ? wd.get(exec.agent) : undefined
21
- if (typeof fromService === 'string' && fromService) return fromService
22
- if (wd && typeof wd.defaultDirectory === 'string' && wd.defaultDirectory) return wd.defaultDirectory
24
+ const sessions = get('sessions')
25
+ const workingDirectory = get('workingDirectory')
26
+ const agent = exec && exec.agent
27
+ let session
28
+ if (sessions && typeof sessions.get === 'function' && agent && agent.id) {
29
+ session = sessions.get(agent.id)
30
+ }
31
+ if (session && workingDirectory && typeof workingDirectory.get === 'function') {
32
+ try {
33
+ const dir = workingDirectory.get(session)
34
+ if (typeof dir === 'string' && dir) return dir
35
+ } catch {
36
+ // Fall through to the session's original directory.
37
+ }
38
+ }
39
+ const headerCwd = session && session.header ? session.header.cwd : undefined
40
+ if (typeof headerCwd === 'string' && headerCwd) return headerCwd
41
+ if (workingDirectory && typeof workingDirectory.defaultDirectory === 'string' && workingDirectory.defaultDirectory) {
42
+ return workingDirectory.defaultDirectory
43
+ }
23
44
  } catch {
24
- // A profile without workingDirectory still runs the CLI in the host cwd.
45
+ // A profile without sessions or workingDirectory runs the CLI in the host cwd.
25
46
  }
26
47
  return process.cwd()
27
48
  }
28
49
 
50
+ const cwdOf = (ctx, exec) => resolveToolCwd(ctx, exec)
51
+
29
52
  function parametersOf(config) {
30
53
  const timeout = Number(config && config.timeoutMs) > 0 ? Number(config.timeoutMs) : 120_000
31
54
  return timeout
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twinsearth/ai-prison-dsh-plugin",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
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",