dashclaw 2.1.2 → 2.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.
Files changed (2) hide show
  1. package/dashclaw.js +23 -1
  2. package/package.json +1 -1
package/dashclaw.js CHANGED
@@ -113,12 +113,34 @@ class DashClaw {
113
113
  */
114
114
  async waitForApproval(actionId, { timeout = 300000, interval = 5000 } = {}) {
115
115
  const startTime = Date.now();
116
+ let wasPending = false;
117
+
116
118
  while (Date.now() - startTime < timeout) {
117
119
  const { action } = await this._request(`/api/actions/${actionId}`, 'GET');
118
- if (action.status === 'running' || action.status === 'completed') return action;
120
+
121
+ if (action.status === 'pending_approval') {
122
+ wasPending = true;
123
+ }
124
+
125
+ // Explicitly unblocked by approval metadata
126
+ if (action.approved_by) return action;
127
+
128
+ // Denial cases
119
129
  if (action.status === 'failed' || action.status === 'cancelled') {
120
130
  throw new ApprovalDeniedError(action.error_message || 'Operator denied the action.', action.status);
121
131
  }
132
+
133
+ // Requirement 4: If an action leaves pending_approval without approval metadata, throw an error.
134
+ // This prevents "auto-approval" bugs where status is changed by non-approval paths.
135
+ if (wasPending && action.status !== 'pending_approval') {
136
+ throw new Error(`Action ${actionId} left pending_approval state without explicit approval metadata (Status: ${action.status})`);
137
+ }
138
+
139
+ // If allowed directly (never intercepted), return immediately
140
+ if (!wasPending && action.status === 'running') {
141
+ return { action };
142
+ }
143
+
122
144
  await new Promise(r => setTimeout(r, interval));
123
145
  }
124
146
  throw new Error(`Timed out waiting for approval of action ${actionId}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dashclaw",
3
- "version": "2.1.2",
3
+ "version": "2.1.4",
4
4
  "description": "Minimal governance runtime for AI agents. Intercept, govern, and verify agent actions.",
5
5
  "type": "module",
6
6
  "publishConfig": {