MCPcopy
hub / github.com/codeaashu/claude-code / createGetAppStateWithAllowedTools

Function createGetAppStateWithAllowedTools

src/utils/forkedAgent.ts:147–171  ·  view source on GitHub ↗
(
  baseGetAppState: ToolUseContext['getAppState'],
  allowedTools: string[],
)

Source from the content-addressed store, hash-verified

145 * This is used by forked skill/command execution to grant tool permissions.
146 */
147export function createGetAppStateWithAllowedTools(
148 baseGetAppState: ToolUseContext['getAppState'],
149 allowedTools: string[],
150): ToolUseContext['getAppState'] {
151 if (allowedTools.length === 0) return baseGetAppState
152 return () => {
153 const appState = baseGetAppState()
154 return {
155 ...appState,
156 toolPermissionContext: {
157 ...appState.toolPermissionContext,
158 alwaysAllowRules: {
159 ...appState.toolPermissionContext.alwaysAllowRules,
160 command: [
161 ...new Set([
162 ...(appState.toolPermissionContext.alwaysAllowRules.command ||
163 []),
164 ...allowedTools,
165 ]),
166 ],
167 },
168 },
169 }
170 }
171}
172
173/**
174 * Result from preparing a forked command context.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected