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

Function policiesResolve

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

Source from the content-addressed store, hash-verified

6064 );
6065
6066 const policiesResolve = (
6067 address: ToolAddress,
6068 ): Effect.Effect<EffectivePolicy, StorageFailure> =>
6069 Effect.gen(function* () {
6070 const parsed = parseToolAddress(String(address));
6071 const policyRows = yield* core.findMany("tool_policy", {});
6072 const toolId = parsed
6073 ? `${parsed.integration}.${parsed.owner}.${parsed.connection}.${parsed.tool}`
6074 : String(address);
6075 // Find the tool to read its default approval annotation.
6076 let requiresApproval: boolean | undefined;
6077 if (parsed) {
6078 const row = yield* core.findFirst("tool", {
6079 where: (b: AnyCb) =>
6080 b.and(
6081 byOwner(parsed.owner)(b),
6082 b("integration", "=", String(parsed.integration)),
6083 b("connection", "=", String(parsed.connection)),
6084 b("name", "=", String(parsed.tool)),
6085 ),
6086 });
6087 if (row) {
6088 const annotations = decodeJsonColumn(row.annotations) as ToolAnnotations | undefined;
6089 requiresApproval = annotations?.requiresApproval;
6090 }
6091 }
6092 return resolveEffectivePolicy(toolId, policyRows, ownerRankForRow, requiresApproval);
6093 });
6094
6095 // ------------------------------------------------------------------
6096 // 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