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

Function policiesUpdate

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

Source from the content-addressed store, hash-verified

4415 });
4416
4417 const policiesUpdate = (
4418 input: UpdateToolPolicyInput,
4419 ): Effect.Effect<ToolPolicy, StorageFailure> =>
4420 Effect.gen(function* () {
4421 if (input.pattern !== undefined && !isValidPattern(input.pattern)) {
4422 return yield* new StorageError({
4423 message: `Invalid tool policy pattern: ${input.pattern}`,
4424 cause: undefined,
4425 });
4426 }
4427 const where = (b: AnyCb) => b.and(byOwner(input.owner)(b), b("id", "=", input.id));
4428 const existing = yield* core.findFirst("tool_policy", { where });
4429 if (!existing) {
4430 return yield* new StorageError({
4431 message: `Tool policy not found: ${input.id}`,
4432 cause: undefined,
4433 });
4434 }
4435 const set: Record<string, unknown> = { updated_at: new Date() };
4436 if (input.pattern !== undefined) set.pattern = input.pattern;
4437 if (input.action !== undefined) set.action = input.action;
4438 if (input.position !== undefined) set.position = input.position;
4439 yield* core.updateMany("tool_policy", { where, set });
4440 const updated = yield* core.findFirst("tool_policy", { where });
4441 return rowToToolPolicy(updated ?? ({ ...existing, ...set } as ToolPolicyRow));
4442 });
4443
4444 const policiesRemove = (input: RemoveToolPolicyInput): Effect.Effect<void, StorageFailure> =>
4445 core.deleteMany("tool_policy", {

Callers 1

createExecutorFunction · 0.85

Calls 2

isValidPatternFunction · 0.90
rowToToolPolicyFunction · 0.90

Tested by

no test coverage detected