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

Function policiesUpdate

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

Source from the content-addressed store, hash-verified

5423 });
5424
5425 const policiesUpdate = (
5426 input: UpdateToolPolicyInput,
5427 ): Effect.Effect<ToolPolicy, StorageFailure> =>
5428 Effect.gen(function* () {
5429 if (input.pattern !== undefined && !isValidPattern(input.pattern)) {
5430 return yield* new StorageError({
5431 message: `Invalid tool policy pattern: ${input.pattern}`,
5432 cause: undefined,
5433 });
5434 }
5435 const where = (b: AnyCb) => b.and(byOwner(input.owner)(b), b("id", "=", input.id));
5436 const existing = yield* core.findFirst("tool_policy", { where });
5437 if (!existing) {
5438 return yield* new StorageError({
5439 message: `Tool policy not found: ${input.id}`,
5440 cause: undefined,
5441 });
5442 }
5443 const set: Record<string, unknown> = { updated_at: new Date() };
5444 if (input.pattern !== undefined) set.pattern = input.pattern;
5445 if (input.action !== undefined) set.action = input.action;
5446 if (input.position !== undefined) set.position = input.position;
5447 yield* core.updateMany("tool_policy", { where, set });
5448 const updated = yield* core.findFirst("tool_policy", { where });
5449 return rowToToolPolicy(updated ?? ({ ...existing, ...set } as ToolPolicyRow));
5450 });
5451
5452 const policiesRemove = (input: RemoveToolPolicyInput): Effect.Effect<void, StorageFailure> =>
5453 core.deleteMany("tool_policy", {

Callers 1

createExecutorFunction · 0.85

Calls 2

isValidPatternFunction · 0.90
rowToToolPolicyFunction · 0.90

Tested by

no test coverage detected