@ddtcorex/dsh-maestro-guard 0.1.0 → 0.2.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.
- package/cordis.patch.yml +1 -0
- package/lib/approval-store.d.ts.map +1 -1
- package/lib/approval-store.js.map +1 -1
- package/lib/approve-tool.d.ts +25 -0
- package/lib/approve-tool.d.ts.map +1 -0
- package/lib/approve-tool.js +54 -0
- package/lib/approve-tool.js.map +1 -0
- package/lib/full-scan-tool.d.ts +7 -0
- package/lib/full-scan-tool.d.ts.map +1 -0
- package/lib/full-scan-tool.js +79 -0
- package/lib/full-scan-tool.js.map +1 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +144 -2
- package/lib/index.js.map +1 -1
- package/lib/pending.d.ts +44 -0
- package/lib/pending.d.ts.map +1 -0
- package/lib/pending.js +133 -0
- package/lib/pending.js.map +1 -0
- package/lib/permission-policy.d.ts.map +1 -1
- package/lib/permission-policy.js.map +1 -1
- package/lib/sandbox.d.ts +95 -0
- package/lib/sandbox.d.ts.map +1 -0
- package/lib/sandbox.js +317 -0
- package/lib/sandbox.js.map +1 -0
- package/lib/secret-redactor.d.ts.map +1 -1
- package/lib/secret-redactor.js.map +1 -1
- package/package.json +6 -1
- package/src/host/approve-tool.ts +61 -0
- package/src/host/full-scan-tool.ts +71 -0
- package/src/host/index.ts +184 -0
- package/src/host/pending.ts +144 -0
- package/src/host/sandbox.ts +318 -0
- package/src/sandbox.ts +5 -0
- package/src/index.ts +0 -38
- /package/src/{approval-store.ts → host/approval-store.ts} +0 -0
- /package/src/{augment.d.ts → host/augment.d.ts} +0 -0
- /package/src/{permission-policy.ts → host/permission-policy.ts} +0 -0
- /package/src/{secret-redactor.ts → host/secret-redactor.ts} +0 -0
package/src/index.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
|
-
import type { Context } from '@deepseek-ai/cordis'
|
|
3
|
-
import { ApprovalStore } from './approval-store.js'
|
|
4
|
-
import { PermissionPolicy } from './permission-policy.js'
|
|
5
|
-
import { containsSecret, redact } from './secret-redactor.js'
|
|
6
|
-
import type { GuardToolExecution, GuardPreToolDecision } from './augment.js'
|
|
7
|
-
|
|
8
|
-
export function createGuardHandler(store: ApprovalStore, policy: PermissionPolicy) {
|
|
9
|
-
return async (exec: GuardToolExecution, next: () => Promise<GuardPreToolDecision>): Promise<GuardPreToolDecision> => {
|
|
10
|
-
const tool = (exec as GuardToolExecution).name ?? (exec as GuardToolExecution).tool ?? ''
|
|
11
|
-
const rawArgs = (exec as any)?.args ?? (exec as any)?.arguments
|
|
12
|
-
if (!policy.isAllowed(tool, rawArgs)) {
|
|
13
|
-
throw new Error(`Guard: tool ${tool} denied by policy`)
|
|
14
|
-
}
|
|
15
|
-
if (tool === 'danger-tool' && !(await store.isApproved(tool))) {
|
|
16
|
-
throw new Error(`Guard: tool ${tool} requires approval`)
|
|
17
|
-
}
|
|
18
|
-
if (rawArgs != null) {
|
|
19
|
-
const asText = JSON.stringify(rawArgs)
|
|
20
|
-
if (containsSecret(asText)) {
|
|
21
|
-
const redacted = JSON.parse(redact(asText))
|
|
22
|
-
if ('args' in exec) (exec as any).args = redacted
|
|
23
|
-
if ('arguments' in exec) (exec as any).arguments = redacted
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return next()
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export default {
|
|
31
|
-
inject: ['tools'] as const,
|
|
32
|
-
apply(ctx: Context) {
|
|
33
|
-
const store = new ApprovalStore()
|
|
34
|
-
const policy = new PermissionPolicy({ deny: ['danger-tool'] })
|
|
35
|
-
const handler = createGuardHandler(store, policy)
|
|
36
|
-
ctx.effect(() => ctx.on('tools/pre-execute', handler))
|
|
37
|
-
}
|
|
38
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|