@duke-dsh-plugins/dsh-agent-approval 1.4.1 → 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.
Files changed (2) hide show
  1. package/index.js +20 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -338,9 +338,26 @@ export class AgentApprovalService extends TypertRemoteService {
338
338
 
339
339
  // ---- knob plumbing --------------------------------------------------------
340
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
+
341
358
  /** Last `sandbox/mode` / `approval/policy` value in the session log fold. */
342
359
  _lastKnob(session, type, field) {
343
- const events = session.events;
360
+ const events = this._eventsOf(session);
344
361
  for (let i = events.length - 1; i >= 0; i--) {
345
362
  const e = events[i];
346
363
  if (e.type === type) return e.data[field];
@@ -683,7 +700,7 @@ export class AgentApprovalService extends TypertRemoteService {
683
700
  /** Read the exact tool-call arguments JSON from the session log by callId. */
684
701
  _callArgsOf(session, callId) {
685
702
  if (callId === undefined) return undefined;
686
- const events = session.events;
703
+ const events = this._eventsOf(session);
687
704
  for (let i = events.length - 1; i >= 0; i--) {
688
705
  const e = events[i];
689
706
  if (e.type === "tool/call" && e.data.callId === callId) return e.data.arguments;
@@ -701,7 +718,7 @@ export class AgentApprovalService extends TypertRemoteService {
701
718
  * the requesting agent phrased its justification.
702
719
  */
703
720
  _recentUserContext(session) {
704
- const events = session.events;
721
+ const events = this._eventsOf(session);
705
722
  let first = "";
706
723
  const last = []; // chronological, capped at 3
707
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.1",
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",