MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / enforceApproval

Function enforceApproval

packages/core/sdk/src/executor.ts:3302–3328  ·  view source on GitHub ↗
(
      annotations: ToolAnnotations | undefined,
      address: ToolAddress,
      args: unknown,
      policy: EffectivePolicy,
      handler: ElicitationHandler,
    )

Source from the content-addressed store, hash-verified

3300 };
3301
3302 const enforceApproval = (
3303 annotations: ToolAnnotations | undefined,
3304 address: ToolAddress,
3305 args: unknown,
3306 policy: EffectivePolicy,
3307 handler: ElicitationHandler,
3308 ) =>
3309 Effect.gen(function* () {
3310 if (!approvalRequired(annotations, policy)) return;
3311 const policyForcesApproval = policy.action === "require_approval";
3312 const message = annotations?.approvalDescription
3313 ? annotations.approvalDescription
3314 : policyForcesApproval && policy.pattern
3315 ? `Approve ${address}? (matched policy: ${policy.pattern})`
3316 : `Approve ${address}?`;
3317 const request = FormElicitation.make({
3318 message: `${message}\n\nArguments:\n${approvalArgumentPreview(args)}`,
3319 requestedSchema: { type: "object", properties: {} },
3320 });
3321 const response = yield* handler({ address, args, request });
3322 if (response.action !== "accept") {
3323 return yield* new ElicitationDeclinedError({
3324 address,
3325 action: response.action,
3326 });
3327 }
3328 });
3329
3330 // ------------------------------------------------------------------
3331 // execute — the invoke path.

Callers 1

executeFunction · 0.85

Calls 3

approvalRequiredFunction · 0.85
approvalArgumentPreviewFunction · 0.85
handlerFunction · 0.50

Tested by

no test coverage detected