MCPcopy Create free account
hub / github.com/allocnode/oh-my-sage / getGraphs

Function getGraphs

src/core/tools/graph.ts:10–27  ·  view source on GitHub ↗
(gateway: GatewayClient)

Source from the content-addressed store, hash-verified

8import type { ToolResponse } from '../types';
9import { validateGraph } from './base';
10import { arrangeNodes, type LayoutMode, type LayoutReport } from './layout';
11import { validateGraphCapabilitiesWithGateway } from './capabilityValidation';
12import { getDeviceList, invalidateGraph, scanGraphs } from './gatewayCache';
13
14function nextGraphId(): string {
15 return String(randomInt(1_000_000_000_000, 10_000_000_000_000));
16}
17
18function replaceRuleScope(value: unknown, scope: string): unknown {
19 if (Array.isArray(value)) return value.map((item) => replaceRuleScope(item, scope));
20 if (!value || typeof value !== 'object') return value;
21 return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, key === 'scope' && item === 'rule' ? scope : replaceRuleScope(item, scope)]));
22}
23
24function comparableNodes(nodes: Graph['nodes']): unknown {
25 return nodes.map((node) => {
26 const { pos: _pos, ...cfg } = node.cfg || {};
27 return { ...node, cfg };
28 });
29}
30

Callers 2

createCoreToolsFunction · 0.90
registerGraphToolsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected