MCPcopy Create free account
hub / github.com/arctic-cli/interface / mergeAgentPermissions

Function mergeAgentPermissions

packages/arctic/src/agent/agent.ts:293–336  ·  view source on GitHub ↗
(basePermission: any, overridePermission: any)

Source from the content-addressed store, hash-verified

291}
292
293function mergeAgentPermissions(basePermission: any, overridePermission: any): Agent.Info["permission"] {
294 if (typeof basePermission.bash === "string") {
295 basePermission.bash = {
296 "*": basePermission.bash,
297 }
298 }
299 if (typeof overridePermission.bash === "string") {
300 overridePermission.bash = {
301 "*": overridePermission.bash,
302 }
303 }
304 const merged = mergeDeep(basePermission ?? {}, overridePermission ?? {}) as any
305
306 let mergedBash
307 if (merged.bash) {
308 if (typeof merged.bash === "string") {
309 mergedBash = {
310 "*": merged.bash,
311 }
312 } else if (typeof merged.bash === "object") {
313 // If we have an object, we want to respect any specific denials from the override
314 // but still allow things that were allowed in base (unless overridden)
315 // and respect the wildcard from the override if present
316
317 const wildcard = merged.bash["*"] ?? "allow"
318 mergedBash = { ...merged.bash }
319
320 // Ensure wildcard is set correctly
321 if (!mergedBash["*"]) {
322 mergedBash["*"] = wildcard
323 }
324 }
325 }
326
327 const result: Agent.Info["permission"] = {
328 edit: merged.edit ?? "allow",
329 webfetch: merged.webfetch ?? "allow",
330 bash: mergedBash ?? { "*": "allow" },
331 doom_loop: merged.doom_loop,
332 external_directory: merged.external_directory,
333 }
334
335 return result
336}

Callers 1

agent.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected