MCPcopy Create free account
hub / github.com/Noumena-Network/code / assertAllowed

Function assertAllowed

src/commands/commit.e2e.test.ts:61–85  ·  view source on GitHub ↗
(
  command: string,
  allowedTools: string[],
  cwd?: string,
)

Source from the content-addressed store, hash-verified

59}
60
61async function assertAllowed(
62 command: string,
63 allowedTools: string[],
64 cwd?: string,
65): Promise<void> {
66 const ctx = createMockContext(allowedTools)
67 const result = await hasPermissionsToUseTool(
68 BashTool,
69 { command },
70 cwd ? { ...ctx, getCwd: () => cwd } : ctx,
71 createAssistantMessage({ content: [] }),
72 'test-' + command,
73 )
74
75 if (result.behavior !== 'allow') {
76 const reason =
77 typeof result.decisionReason === 'object' && result.decisionReason !== null
78 ? JSON.stringify(result.decisionReason)
79 : 'no reason'
80 const msg = result.message ?? 'no message'
81 throw new Error(
82 `Expected "${command}" to be allowed, got behavior=${result.behavior} message="${msg}" reason=${reason}`,
83 )
84 }
85}
86
87async function assertDenied(command: string, allowedTools: string[]): Promise<void> {
88 const ctx = createMockContext(allowedTools)

Callers 1

commit.e2e.test.tsFile · 0.85

Calls 3

hasPermissionsToUseToolFunction · 0.85
createMockContextFunction · 0.70
createAssistantMessageFunction · 0.50

Tested by

no test coverage detected