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

Function policiesResolve

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

Source from the content-addressed store, hash-verified

5945 );
5946
5947 const policiesResolve = (
5948 address: ToolAddress,
5949 ): Effect.Effect<EffectivePolicy, StorageFailure> =>
5950 Effect.gen(function* () {
5951 const parsed = parseToolAddress(String(address));
5952 const policyRows = yield* core.findMany("tool_policy", {});
5953 const toolId = parsed
5954 ? `${parsed.integration}.${parsed.owner}.${parsed.connection}.${parsed.tool}`
5955 : String(address);
5956 // Find the tool to read its default approval annotation.
5957 let requiresApproval: boolean | undefined;
5958 if (parsed) {
5959 const row = yield* core.findFirst("tool", {
5960 where: (b: AnyCb) =>
5961 b.and(
5962 byOwner(parsed.owner)(b),
5963 b("integration", "=", String(parsed.integration)),
5964 b("connection", "=", String(parsed.connection)),
5965 b("name", "=", String(parsed.tool)),
5966 ),
5967 });
5968 if (row) {
5969 const annotations = decodeJsonColumn(row.annotations) as ToolAnnotations | undefined;
5970 requiresApproval = annotations?.requiresApproval;
5971 }
5972 }
5973 return resolveEffectivePolicy(toolId, policyRows, ownerRankForRow, requiresApproval);
5974 });
5975
5976 // ------------------------------------------------------------------
5977 // 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