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

Function policiesResolve

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

Source from the content-addressed store, hash-verified

4017 });
4018
4019 const policiesResolve = (
4020 address: ToolAddress,
4021 ): Effect.Effect<EffectivePolicy, StorageFailure> =>
4022 Effect.gen(function* () {
4023 const parsed = parseToolAddress(String(address));
4024 const policyRows = yield* core.findMany("tool_policy", {});
4025 const toolId = parsed
4026 ? `${parsed.integration}.${parsed.owner}.${parsed.connection}.${parsed.tool}`
4027 : String(address);
4028 // Find the tool to read its default approval annotation.
4029 let requiresApproval: boolean | undefined;
4030 if (parsed) {
4031 const row = yield* core.findFirst("tool", {
4032 where: (b: AnyCb) =>
4033 b.and(
4034 byOwner(parsed.owner)(b),
4035 b("integration", "=", String(parsed.integration)),
4036 b("connection", "=", String(parsed.connection)),
4037 b("name", "=", String(parsed.tool)),
4038 ),
4039 });
4040 if (row) {
4041 const annotations = decodeJsonColumn(row.annotations) as ToolAnnotations | undefined;
4042 requiresApproval = annotations?.requiresApproval;
4043 }
4044 }
4045 return resolveEffectivePolicy(toolId, policyRows, ownerRankForRow, requiresApproval);
4046 });
4047
4048 // ------------------------------------------------------------------
4049 // Artifacts — saved generative-UI components, owner-scoped.

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