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

Function handleSetPermissionMode

src/cli/print.ts:4602–4676  ·  view source on GitHub ↗
(
  request: { mode: InternalPermissionMode },
  requestId: string,
  toolPermissionContext: ToolPermissionContext,
  output: Stream<StdoutMessage>,
)

Source from the content-addressed store, hash-verified

4600}
4601
4602function handleSetPermissionMode(
4603 request: { mode: InternalPermissionMode },
4604 requestId: string,
4605 toolPermissionContext: ToolPermissionContext,
4606 output: Stream<StdoutMessage>,
4607): ToolPermissionContext {
4608 // Check if trying to switch to bypassPermissions mode
4609 if (request.mode === 'bypassPermissions') {
4610 if (isBypassPermissionsModeDisabled()) {
4611 output.enqueue({
4612 type: 'control_response',
4613 response: {
4614 subtype: 'error',
4615 request_id: requestId,
4616 error:
4617 'Cannot set permission mode to bypassPermissions because it is disabled by settings or configuration',
4618 },
4619 })
4620 return toolPermissionContext
4621 }
4622 if (!toolPermissionContext.isBypassPermissionsModeAvailable) {
4623 output.enqueue({
4624 type: 'control_response',
4625 response: {
4626 subtype: 'error',
4627 request_id: requestId,
4628 error:
4629 'Cannot set permission mode to bypassPermissions because the session was not launched with --dangerously-skip-permissions',
4630 },
4631 })
4632 return toolPermissionContext
4633 }
4634 }
4635
4636 // Check if trying to switch to auto mode without the classifier gate
4637 if (
4638 feature('TRANSCRIPT_CLASSIFIER') &&
4639 request.mode === 'auto' &&
4640 !isAutoModeGateEnabled()
4641 ) {
4642 const reason = getAutoModeUnavailableReason()
4643 output.enqueue({
4644 type: 'control_response',
4645 response: {
4646 subtype: 'error',
4647 request_id: requestId,
4648 error: reason
4649 ? `Cannot set permission mode to auto: ${getAutoModeUnavailableNotification(reason)}`
4650 : 'Cannot set permission mode to auto',
4651 },
4652 })
4653 return toolPermissionContext
4654 }
4655
4656 // Allow the mode switch
4657 output.enqueue({
4658 type: 'control_response',
4659 response: {

Callers 1

runHeadlessStreamingFunction · 0.85

Calls 6

isAutoModeGateEnabledFunction · 0.85
transitionPermissionModeFunction · 0.85
enqueueMethod · 0.45

Tested by

no test coverage detected