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

Function policiesUpdate

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

Source from the content-addressed store, hash-verified

3195 });
3196
3197 const policiesUpdate = (
3198 input: UpdateToolPolicyInput,
3199 ): Effect.Effect<ToolPolicy, StorageFailure> =>
3200 Effect.gen(function* () {
3201 if (input.pattern !== undefined && !isValidPattern(input.pattern)) {
3202 return yield* new StorageError({
3203 message: `Invalid tool policy pattern: ${input.pattern}`,
3204 cause: undefined,
3205 });
3206 }
3207 const where = (b: AnyCb) => b.and(byOwner(input.owner)(b), b("id", "=", input.id));
3208 const existing = yield* core.findFirst("tool_policy", { where });
3209 if (!existing) {
3210 return yield* new StorageError({
3211 message: `Tool policy not found: ${input.id}`,
3212 cause: undefined,
3213 });
3214 }
3215 const set: Record<string, unknown> = { updated_at: new Date() };
3216 if (input.pattern !== undefined) set.pattern = input.pattern;
3217 if (input.action !== undefined) set.action = input.action;
3218 if (input.position !== undefined) set.position = input.position;
3219 yield* core.updateMany("tool_policy", { where, set });
3220 const updated = yield* core.findFirst("tool_policy", { where });
3221 return rowToToolPolicy(updated ?? ({ ...existing, ...set } as ToolPolicyRow));
3222 });
3223
3224 const policiesRemove = (input: RemoveToolPolicyInput): Effect.Effect<void, StorageFailure> =>
3225 core.deleteMany("tool_policy", {

Callers 1

createExecutorFunction · 0.85

Calls 2

isValidPatternFunction · 0.90
rowToToolPolicyFunction · 0.90

Tested by

no test coverage detected