dsh-act 0.5.0 → 0.6.0

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 +12 -7
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -183,14 +183,18 @@ export class ActService {
183
183
  }
184
184
 
185
185
  const capability = `act:invoke:${action.id}`
186
+ // The kernel projects actions as `act.<id>` and asks Allow for
187
+ // `cap:act.<id>`; accept either name so one human approval is enough.
188
+ const alternate = `cap:act.${action.id}`
186
189
  const gated = action.risk !== 'read' && action.authorize !== false
187
- if (gated && !(await this.#authorized(capability, meta))) {
190
+ if (gated && !(await this.#authorized(capability, meta, alternate))) {
188
191
  return this.#grantRequired(action, capability)
189
192
  }
190
193
  // Minimal taint gate: a caller/host claim raises the bar for writes and
191
194
  // danger actions. It never lowers it; Act does not verify the token.
192
195
  const taintedCapability = `${capability}${TAINT_SUFFIX}`
193
- if (gated && isTainted(meta) && !(await this.#authorized(taintedCapability, meta))) {
196
+ const taintedAlternate = `${alternate}${TAINT_SUFFIX}`
197
+ if (gated && isTainted(meta) && !(await this.#authorized(taintedCapability, meta, taintedAlternate))) {
194
198
  return this.#grantRequired(action, taintedCapability, true)
195
199
  }
196
200
 
@@ -222,18 +226,19 @@ export class ActService {
222
226
  return ctx.allow
223
227
  }
224
228
 
225
- async #authorized(capability, meta) {
229
+ async #authorized(capability, meta, alternate) {
226
230
  const allow = this.#allow()
227
231
  if (allow === null || typeof allow?.check !== 'function') return false
228
232
  // A missing subject must fail closed: a shared 'anonymous' identity would
229
233
  // let one grant authorize every background/plugin call.
230
234
  const subject = meta?.subject ?? meta?.sessionId
231
235
  if (typeof subject !== 'string' || subject === '') return false
232
- try {
233
- return granted(await allow.check({ subject, capability }))
234
- } catch {
235
- return false
236
+ for (const name of [capability, alternate].filter(Boolean)) {
237
+ try {
238
+ if (granted(await allow.check({ subject, capability: name }))) return true
239
+ } catch { /* try the other name */ }
236
240
  }
241
+ return false
237
242
  }
238
243
  }
239
244
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-act",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Typed action registry with filesystem actions, previews and undo for DeepSeek Harness.",
5
5
  "type": "module",
6
6
  "main": "index.js",