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

Function onAllow

src/utils/swarm/inProcessRunner.ts:251–292  ·  view source on GitHub ↗
(
              updatedInput: Record<string, unknown>,
              permissionUpdates: PermissionUpdate[],
              feedback?: string,
              contentBlocks?: ContentBlockParam[],
            )

Source from the content-addressed store, hash-verified

249 resolve({ behavior: 'ask', message: SUBAGENT_REJECT_MESSAGE })
250 },
251 async onAllow(
252 updatedInput: Record<string, unknown>,
253 permissionUpdates: PermissionUpdate[],
254 feedback?: string,
255 contentBlocks?: ContentBlockParam[],
256 ) {
257 if (decisionMade) return
258 decisionMade = true
259 abortController.signal.removeEventListener(
260 'abort',
261 onAbortListener,
262 )
263 reportPermissionWait()
264 persistPermissionUpdates(permissionUpdates)
265 // Write back permission updates to the leader's shared context
266 if (permissionUpdates.length > 0) {
267 const setToolPermissionContext =
268 getLeaderSetToolPermissionContext()
269 if (setToolPermissionContext) {
270 const currentAppState = toolUseContext.getAppState()
271 const updatedContext = applyPermissionUpdates(
272 currentAppState.toolPermissionContext,
273 permissionUpdates,
274 )
275 // Preserve the leader's mode to prevent workers'
276 // transformed 'acceptEdits' context from leaking back
277 // to the coordinator
278 setToolPermissionContext(updatedContext, {
279 preserveMode: true,
280 })
281 }
282 }
283 const trimmedFeedback = feedback?.trim()
284 resolve({
285 behavior: 'allow',
286 updatedInput,
287 userModified: false,
288 acceptFeedback: trimmedFeedback || undefined,
289 ...(contentBlocks &&
290 contentBlocks.length > 0 && { contentBlocks }),
291 })
292 },
293 onReject(feedback?: string, contentBlocks?: ContentBlockParam[]) {
294 if (decisionMade) return
295 decisionMade = true

Callers

nothing calls this directly

Calls 8

reportPermissionWaitFunction · 0.85
persistPermissionUpdatesFunction · 0.85
applyPermissionUpdatesFunction · 0.85
setToolPermissionContextFunction · 0.85
keysMethod · 0.80
cleanupFunction · 0.70
resolveFunction · 0.50

Tested by

no test coverage detected