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

Function policiesUpdate

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

Source from the content-addressed store, hash-verified

3872 });
3873
3874 const policiesUpdate = (
3875 input: UpdateToolPolicyInput,
3876 ): Effect.Effect<ToolPolicy, StorageFailure> =>
3877 Effect.gen(function* () {
3878 if (input.pattern !== undefined && !isValidPattern(input.pattern)) {
3879 return yield* new StorageError({
3880 message: `Invalid tool policy pattern: ${input.pattern}`,
3881 cause: undefined,
3882 });
3883 }
3884 const where = (b: AnyCb) => b.and(byOwner(input.owner)(b), b("id", "=", input.id));
3885 const existing = yield* core.findFirst("tool_policy", { where });
3886 if (!existing) {
3887 return yield* new StorageError({
3888 message: `Tool policy not found: ${input.id}`,
3889 cause: undefined,
3890 });
3891 }
3892 const set: Record<string, unknown> = { updated_at: new Date() };
3893 if (input.pattern !== undefined) set.pattern = input.pattern;
3894 if (input.action !== undefined) set.action = input.action;
3895 if (input.position !== undefined) set.position = input.position;
3896 yield* core.updateMany("tool_policy", { where, set });
3897 const updated = yield* core.findFirst("tool_policy", { where });
3898 return rowToToolPolicy(updated ?? ({ ...existing, ...set } as ToolPolicyRow));
3899 });
3900
3901 const policiesRemove = (input: RemoveToolPolicyInput): Effect.Effect<void, StorageFailure> =>
3902 core.deleteMany("tool_policy", {

Callers 1

createExecutorFunction · 0.85

Calls 2

isValidPatternFunction · 0.90
rowToToolPolicyFunction · 0.90

Tested by

no test coverage detected