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

Function policiesResolve

packages/core/sdk/src/executor.ts:3477–3504  ·  view source on GitHub ↗
(
      address: ToolAddress,
    )

Source from the content-addressed store, hash-verified

3475 });
3476
3477 const policiesResolve = (
3478 address: ToolAddress,
3479 ): Effect.Effect<EffectivePolicy, StorageFailure> =>
3480 Effect.gen(function* () {
3481 const parsed = parseToolAddress(String(address));
3482 const policyRows = yield* core.findMany("tool_policy", {});
3483 const toolId = parsed
3484 ? `${parsed.integration}.${parsed.owner}.${parsed.connection}.${parsed.tool}`
3485 : String(address);
3486 // Find the tool to read its default approval annotation.
3487 let requiresApproval: boolean | undefined;
3488 if (parsed) {
3489 const row = yield* core.findFirst("tool", {
3490 where: (b: AnyCb) =>
3491 b.and(
3492 byOwner(parsed.owner)(b),
3493 b("integration", "=", String(parsed.integration)),
3494 b("connection", "=", String(parsed.connection)),
3495 b("name", "=", String(parsed.tool)),
3496 ),
3497 });
3498 if (row) {
3499 const annotations = decodeJsonColumn(row.annotations) as ToolAnnotations | undefined;
3500 requiresApproval = annotations?.requiresApproval;
3501 }
3502 }
3503 return resolveEffectivePolicy(toolId, policyRows, ownerRankForRow, requiresApproval);
3504 });
3505
3506 // ------------------------------------------------------------------
3507 // Elicitation

Callers

nothing calls this directly

Calls 4

resolveEffectivePolicyFunction · 0.90
parseToolAddressFunction · 0.85
byOwnerFunction · 0.85
decodeJsonColumnFunction · 0.85

Tested by

no test coverage detected