MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / transformPermissionRule

Function transformPermissionRule

packages/agent-core/src/config/toml.ts:396–421  ·  view source on GitHub ↗
(value: unknown, decision?: 'allow' | 'deny' | 'ask')

Source from the content-addressed store, hash-verified

394}
395
396function transformPermissionRule(value: unknown, decision?: 'allow' | 'deny' | 'ask'): unknown {
397 if (!isPlainObject(value)) return value;
398
399 const rule = transformPlainObject(value);
400 const tool = rule['tool'];
401 const match = rule['match'];
402 const pattern = rule['pattern'];
403 const out: Record<string, unknown> = {};
404
405 if (decision !== undefined) {
406 out['decision'] = decision;
407 } else {
408 out['decision'] = rule['decision'];
409 }
410 out['scope'] = rule['scope'];
411 out['reason'] = rule['reason'];
412
413 if (typeof tool === 'string') {
414 const argPattern = typeof match === 'string' ? match : pattern;
415 out['pattern'] = typeof argPattern === 'string' ? `${tool}(${argPattern})` : tool;
416 } else {
417 out['pattern'] = pattern;
418 }
419
420 return out;
421}
422
423function transformServiceData(data: Record<string, unknown>): Record<string, unknown> {
424 const out: Record<string, unknown> = {};

Callers 1

appendPermissionRulesFunction · 0.85

Calls 2

transformPlainObjectFunction · 0.85
isPlainObjectFunction · 0.70

Tested by

no test coverage detected