dashclaw 2.1.3 → 2.1.5
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/dashclaw.js +12 -1
- package/package.json +1 -1
package/dashclaw.js
CHANGED
|
@@ -113,9 +113,15 @@ 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
120
|
|
|
121
|
+
if (action.status === 'pending_approval') {
|
|
122
|
+
wasPending = true;
|
|
123
|
+
}
|
|
124
|
+
|
|
119
125
|
// Explicitly unblocked by approval metadata
|
|
120
126
|
if (action.approved_by) return action;
|
|
121
127
|
|
|
@@ -126,10 +132,15 @@ class DashClaw {
|
|
|
126
132
|
|
|
127
133
|
// Requirement 4: If an action leaves pending_approval without approval metadata, throw an error.
|
|
128
134
|
// This prevents "auto-approval" bugs where status is changed by non-approval paths.
|
|
129
|
-
if (action.status !== 'pending_approval') {
|
|
135
|
+
if (wasPending && action.status !== 'pending_approval') {
|
|
130
136
|
throw new Error(`Action ${actionId} left pending_approval state without explicit approval metadata (Status: ${action.status})`);
|
|
131
137
|
}
|
|
132
138
|
|
|
139
|
+
// If allowed directly (never intercepted), return immediately
|
|
140
|
+
if (!wasPending && action.status === 'running') {
|
|
141
|
+
return { action };
|
|
142
|
+
}
|
|
143
|
+
|
|
133
144
|
await new Promise(r => setTimeout(r, interval));
|
|
134
145
|
}
|
|
135
146
|
throw new Error(`Timed out waiting for approval of action ${actionId}`);
|