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

Function policiesUpdate

packages/core/sdk/src/executor.ts:6019–6053  ·  view source on GitHub ↗
(
      input: UpdateToolPolicyInput,
    )

Source from the content-addressed store, hash-verified

6017 );
6018
6019 const policiesUpdate = (
6020 input: UpdateToolPolicyInput,
6021 ): Effect.Effect<ToolPolicy, OrgWriteDeniedError | StorageFailure> =>
6022 transaction(
6023 Effect.gen(function* () {
6024 yield* guardOrgWrite(input.owner);
6025 if (input.pattern !== undefined && !isValidPattern(input.pattern)) {
6026 return yield* new StorageError({
6027 message: `Invalid tool policy pattern: ${input.pattern}`,
6028 cause: undefined,
6029 });
6030 }
6031 const where = (b: AnyCb) => b.and(byOwner(input.owner)(b), b("id", "=", input.id));
6032 const existing = yield* core.findFirst("tool_policy", { where });
6033 if (!existing) {
6034 return yield* new StorageError({
6035 message: `Tool policy not found: ${input.id}`,
6036 cause: undefined,
6037 });
6038 }
6039 const set: Record<string, unknown> = { updated_at: new Date() };
6040 if (input.pattern !== undefined) set.pattern = input.pattern;
6041 if (input.action !== undefined) set.action = input.action;
6042 if (input.position !== undefined) set.position = input.position;
6043 yield* core.updateMany("tool_policy", { where, set });
6044 const updated = yield* core.findFirst("tool_policy", { where });
6045 if (!updated) {
6046 return yield* new StorageError({
6047 message: `Tool policy disappeared while it was being updated: ${input.id}`,
6048 cause: undefined,
6049 });
6050 }
6051 return rowToToolPolicy(updated);
6052 }),
6053 );
6054
6055 const policiesRemove = (
6056 input: RemoveToolPolicyInput,

Callers 1

createExecutorFunction · 0.85

Calls 4

isValidPatternFunction · 0.90
rowToToolPolicyFunction · 0.90
guardOrgWriteFunction · 0.85
transactionFunction · 0.70

Tested by

no test coverage detected