@duke-dsh-plugins/dsh-agent-approval 1.4.0 → 1.4.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.
Files changed (3) hide show
  1. package/client.js +16 -2
  2. package/index.js +15 -2
  3. package/package.json +1 -1
package/client.js CHANGED
@@ -353,6 +353,19 @@ window.__ModuleLoader__.load({
353
353
  return typeof s === "string" && s.length > n ? s.slice(0, n) + "…" : s || "";
354
354
  }
355
355
 
356
+ /**
357
+ Mirror of Host `shortId()`: DSH prefixes session ids with the literal
358
+ `"session-"` before the UUID, so a naive `slice(0, 8)` shows nothing
359
+ but `"session-"`. Strip the known prefix so the chip displays 8 chars
360
+ of the UUID proper. Kept here too because the bundle has no shared
361
+ module with the Host half.
362
+ */
363
+ function shortSessionId(id) {
364
+ const s = String(id);
365
+ const tail = s.indexOf("session-") === 0 ? s.slice("session-".length) : s;
366
+ return tail.slice(0, 8);
367
+ }
368
+
356
369
  function fmtTime(iso) {
357
370
  try {
358
371
  const d = new Date(iso);
@@ -624,16 +637,17 @@ window.__ModuleLoader__.load({
624
637
  const cwd = typeof info.cwd === "string" && info.cwd !== "" ? info.cwd : "";
625
638
  const tip =
626
639
  "会话 ID:" + sid + (cwd !== "" ? "\n工作区:" + cwd : "");
640
+ const sidShort = shortSessionId(sid);
627
641
  return h(
628
642
  "span",
629
643
  { key: sid, className: "aapr-chip", title: tip },
630
644
  h(
631
645
  "span",
632
646
  { className: "aapr-chip-title" },
633
- title !== "" ? title : sid.slice(0, 8),
647
+ title !== "" ? title : sidShort,
634
648
  ),
635
649
  title !== ""
636
- ? h("span", { className: "aapr-chip-id" }, sid.slice(0, 8))
650
+ ? h("span", { className: "aapr-chip-id" }, sidShort)
637
651
  : null,
638
652
  h(
639
653
  "button",
package/index.js CHANGED
@@ -145,9 +145,22 @@ function trunc(value, n) {
145
145
  return value.length > n ? value.slice(0, n) + "…[truncated]" : value;
146
146
  }
147
147
 
148
- /** First 8 chars of a session id (display form in records and chips). */
148
+ /**
149
+ * First 8 chars of a session / run id (display form in records and chips).
150
+ * DSH prefixes session ids with the literal `"session-"` before the UUID
151
+ * (see `@deepseek-ai/dsh-host-apiproxy` `session create` and
152
+ * `@deepseek-ai/dsh-headless` SessionId(`session-${randomUUID()}`)); a naive
153
+ * `slice(0, 8)` lands on that meaningless 8-char prefix and every audit row
154
+ * shows nothing but `"session-"`. Strip the known prefix before truncating
155
+ * so the displayed fragment comes from the UUID proper (where the real
156
+ * discriminator lives); id shapes without the prefix (subagent `run.id`
157
+ * = raw `randomUUID()`) are unaffected.
158
+ */
159
+ const SESSION_ID_PREFIX = "session-";
149
160
  function shortId(id) {
150
- return String(id).slice(0, 8);
161
+ const s = String(id);
162
+ const tail = s.startsWith(SESSION_ID_PREFIX) ? s.slice(SESSION_ID_PREFIX.length) : s;
163
+ return tail.slice(0, 8);
151
164
  }
152
165
 
153
166
  /** Best-effort error text. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duke-dsh-plugins/dsh-agent-approval",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Agent-decided approvals for DeepSeek Harness: a workspace-write base permission mode where an independent approval subagent judges every sandbox escalation (risky operations are rejected), with a configurable approval model and an audit log in Settings.",
5
5
  "repository": {
6
6
  "type": "git",