@duke-dsh-plugins/dsh-agent-approval 1.4.0 → 1.4.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/client.js +16 -2
- package/index.js +35 -5
- 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 :
|
|
647
|
+
title !== "" ? title : sidShort,
|
|
634
648
|
),
|
|
635
649
|
title !== ""
|
|
636
|
-
? h("span", { className: "aapr-chip-id" },
|
|
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
|
-
/**
|
|
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
|
-
|
|
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. */
|
|
@@ -325,9 +338,26 @@ export class AgentApprovalService extends TypertRemoteService {
|
|
|
325
338
|
|
|
326
339
|
// ---- knob plumbing --------------------------------------------------------
|
|
327
340
|
|
|
341
|
+
/**
|
|
342
|
+
* The session's durable events as a plain readonly array. DSH 0.1.2-rc.1
|
|
343
|
+
* removed the public `session.events` snapshot array in favor of
|
|
344
|
+
* `snapshotEvents(from?, to?)` / `eventAt(seq)` / `seq` — reading the old
|
|
345
|
+
* field yields undefined and every fold below threw TypeError, which the
|
|
346
|
+
* listeners' try/catch swallowed, so no session could ever enter `_enabled`
|
|
347
|
+
* (every escalation fell through to the human answerer). Prefer the new
|
|
348
|
+
* accessor; fall back to the legacy array on 0.1.1.
|
|
349
|
+
*/
|
|
350
|
+
_eventsOf(session) {
|
|
351
|
+
if (session && typeof session.snapshotEvents === "function") {
|
|
352
|
+
return session.snapshotEvents();
|
|
353
|
+
}
|
|
354
|
+
const legacy = session ? session.events : undefined;
|
|
355
|
+
return Array.isArray(legacy) ? legacy : [];
|
|
356
|
+
}
|
|
357
|
+
|
|
328
358
|
/** Last `sandbox/mode` / `approval/policy` value in the session log fold. */
|
|
329
359
|
_lastKnob(session, type, field) {
|
|
330
|
-
const events = session
|
|
360
|
+
const events = this._eventsOf(session);
|
|
331
361
|
for (let i = events.length - 1; i >= 0; i--) {
|
|
332
362
|
const e = events[i];
|
|
333
363
|
if (e.type === type) return e.data[field];
|
|
@@ -670,7 +700,7 @@ export class AgentApprovalService extends TypertRemoteService {
|
|
|
670
700
|
/** Read the exact tool-call arguments JSON from the session log by callId. */
|
|
671
701
|
_callArgsOf(session, callId) {
|
|
672
702
|
if (callId === undefined) return undefined;
|
|
673
|
-
const events = session
|
|
703
|
+
const events = this._eventsOf(session);
|
|
674
704
|
for (let i = events.length - 1; i >= 0; i--) {
|
|
675
705
|
const e = events[i];
|
|
676
706
|
if (e.type === "tool/call" && e.data.callId === callId) return e.data.arguments;
|
|
@@ -688,7 +718,7 @@ export class AgentApprovalService extends TypertRemoteService {
|
|
|
688
718
|
* the requesting agent phrased its justification.
|
|
689
719
|
*/
|
|
690
720
|
_recentUserContext(session) {
|
|
691
|
-
const events = session
|
|
721
|
+
const events = this._eventsOf(session);
|
|
692
722
|
let first = "";
|
|
693
723
|
const last = []; // chronological, capped at 3
|
|
694
724
|
for (let i = 0; i < events.length; i++) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duke-dsh-plugins/dsh-agent-approval",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
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",
|