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

Function policiesUpdate

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

Source from the content-addressed store, hash-verified

3459 });
3460
3461 const policiesUpdate = (
3462 input: UpdateToolPolicyInput,
3463 ): Effect.Effect<ToolPolicy, StorageFailure> =>
3464 Effect.gen(function* () {
3465 if (input.pattern !== undefined && !isValidPattern(input.pattern)) {
3466 return yield* new StorageError({
3467 message: `Invalid tool policy pattern: ${input.pattern}`,
3468 cause: undefined,
3469 });
3470 }
3471 const where = (b: AnyCb) => b.and(byOwner(input.owner)(b), b("id", "=", input.id));
3472 const existing = yield* core.findFirst("tool_policy", { where });
3473 if (!existing) {
3474 return yield* new StorageError({
3475 message: `Tool policy not found: ${input.id}`,
3476 cause: undefined,
3477 });
3478 }
3479 const set: Record<string, unknown> = { updated_at: new Date() };
3480 if (input.pattern !== undefined) set.pattern = input.pattern;
3481 if (input.action !== undefined) set.action = input.action;
3482 if (input.position !== undefined) set.position = input.position;
3483 yield* core.updateMany("tool_policy", { where, set });
3484 const updated = yield* core.findFirst("tool_policy", { where });
3485 return rowToToolPolicy(updated ?? ({ ...existing, ...set } as ToolPolicyRow));
3486 });
3487
3488 const policiesRemove = (input: RemoveToolPolicyInput): Effect.Effect<void, StorageFailure> =>
3489 core.deleteMany("tool_policy", {

Callers 1

createExecutorFunction · 0.85

Calls 2

isValidPatternFunction · 0.90
rowToToolPolicyFunction · 0.90

Tested by

no test coverage detected