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

Function updatePolicy

packages/plugins/toolkits/src/server.ts:401–426  ·  view source on GitHub ↗
(
    toolkitId: string,
    policyId: string,
    input: {
      readonly pattern?: string;
      readonly action?: ToolPolicyAction;
      readonly position?: string;
    },
  )

Source from the content-addressed store, hash-verified

399 });
400
401 const updatePolicy = (
402 toolkitId: string,
403 policyId: string,
404 input: {
405 readonly pattern?: string;
406 readonly action?: ToolPolicyAction;
407 readonly position?: string;
408 },
409 ) =>
410 Effect.gen(function* () {
411 if (input.pattern !== undefined) yield* validatePolicyPattern(input.pattern);
412 const toolkit = yield* requireToolkit(toolkitId);
413 const existing = yield* requirePolicy(toolkitId, policyId, toolkit.owner);
414 const entry = yield* storage.policies.put({
415 owner: toolkit.owner,
416 key: policyId,
417 data: {
418 ...existing.data,
419 ...(input.pattern !== undefined ? { pattern: input.pattern } : {}),
420 ...(input.action !== undefined ? { action: input.action } : {}),
421 ...(input.position !== undefined ? { position: input.position } : {}),
422 updatedAt: Date.now(),
423 },
424 });
425 return policyToResponse(entry.data);
426 });
427
428 const removePolicy = (toolkitId: string, policyId: string) =>
429 Effect.gen(function* () {

Callers

nothing calls this directly

Calls 5

validatePolicyPatternFunction · 0.85
requireToolkitFunction · 0.85
requirePolicyFunction · 0.85
policyToResponseFunction · 0.70
putMethod · 0.65

Tested by

no test coverage detected