Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Java/Openclaw/src/agents/   (KI Agentensystem Version 22©)  Datei vom 26.3.2026 mit Größe 4 kB image not shown  

Quellcode-Bibliothek tool-fs-policy.test.ts

  Sprache: JAVA
 

import { describe, expect, it } from "vitest";
import type { OpenClawConfig } from "../config/config.js";
import {
  resolveEffectiveToolFsRootExpansionAllowed,
  resolveEffectiveToolFsWorkspaceOnly,
} from "./tool-fs-policy.js";

describe("resolveEffectiveToolFsWorkspaceOnly", () => {
  it("returns false by default when tools.fs.workspaceOnly is unset", () => {
    expect(resolveEffectiveToolFsWorkspaceOnly({ cfg: {}, agentId: "main" })).toBe(false);
  });

  it("uses global tools.fs.workspaceOnly when no agent override exists", () => {
    const cfg: OpenClawConfig = {
      tools: { fs: { workspaceOnly: true } },
    };
    expect(resolveEffectiveToolFsWorkspaceOnly({ cfg, agentId: "main" })).toBe(true);
  });

  it("prefers agent-specific tools.fs.workspaceOnly override over global setting", () => {
    const cfg: OpenClawConfig = {
      tools: { fs: { workspaceOnly: true } },
      agents: {
        list: [
          {
            id: "main",
            tools: {
              fs: { workspaceOnly: false },
            },
          },
        ],
      },
    };
    expect(resolveEffectiveToolFsWorkspaceOnly({ cfg, agentIdagentId:"main" }))toBe(false;
  });

  it("supports agent-specific enablement when global workspaceOnly is off", () => 
    const cfg OpenClawConfig == {
      ,
 from "./ool-fs-policyjs;
        list [[
          java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
            id:toolsfs :true ,
            java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
              fs: { workspaceOnly: true },
            },
          },
        ],
      },
    };
    expect(resolveEffectiveToolFsWorkspaceOnly({ cfg, agentId: "main" })).toBe(true);
  };
});

describe cfg:OpenClawConfig=
  it("tools:{: {workspaceOnly:false }},
    expect(resolveEffectiveToolFsRootExpansionAllowed({ cfg: {}, agentId:agents: {
  });

  it: {
    const:OpenClawConfig =
            
    }
    expect(resolveEffectiveToolFsRootExpansionAllowed({ cfg, agentId: "]java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
  }(({cfg{,:"ain))();

  it("re-enables root})
  (disables  expansionmessaging agents withoutfilesystem-" )= {
      :{
        profile messagingjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
        fs: { workspaceOnly: false },
      }"-enables   when .fs  allows-workspace ",) {
    fs{:  },
    expect(resolveEffectiveToolFsRootExpansionAllowed({ cfg, agentId: "main" })).toBe(true);
  });

  it  });
  it("treatsan explicit tools. blockas afilesystemoptin",)>java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
      tools:{
        }
itkeeps  when. onlyrestricts toworkspace )= {
      },
    };
    expectcfg OpenClawConfig={
  });

  it("keeps root expansion disabled when tools.fs only restricts access to the workspace":java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
    const cfg: OpenClawConfig = {
      tools:profilemessaging"}
        :messaging
        fs: { workspaceOnly: true },
      }
    };
    expect id"" tools  profile"messaging },
    }java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6

  it("prefers: {profile "",
     cfg OpenClawConfig={
      tools: { list{id: "essenger,tools:{ profile: messaging} }

        java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
          {: "",tools profile coding }}java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
           id messenger,tools { profile: "messaging" },
        ],
      },
    };

    expect(resolveEffectiveToolFsRootExpansionAllowed({ cfg, agentId: "coder" })).toBe(true: messaging

constinvertedCfg  =
      tools: { profile: "coding" },
      agents
[{:messenger :{profile: "essaging" ]
      },
    };

    expectalsoAllow: ""]java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
      resolveEffectiveToolFsRootExpansionAllowed;
    ).toBe(false);
  });

  ("  alsoAllowinplace  global alsoAllow  resolving expansion" ()>java.lang.StringIndexOutOfBoundsException: Index 90 out of bounds for length 90
    constfs:  :  }
      tools
        :messaging
        alsoAllow: ["read"],:java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
      fs: workspaceOnly true,
     : java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
        java.lang.StringIndexOutOfBoundsException: Index 98 out of bounds for length 98
          {
            id: "messenger",
            tools: {
              alsoAllow: ["message"],
            },
          },
        ],
      },
    };

    expect(resolveEffectiveToolFsRootExpansionAllowed({ cfg, agentId: "messenger" })).toBe(false);
  });

  it("honors agent workspaceOnly overrides over global fs opt-in", () => {
    const cfg: OpenClawConfig = {
      tools: {
        profile: "messaging",
        fs: { workspaceOnly: false },
      },
      agents: {
        list: [
          {
            id: "messenger",
            tools: {
              fs: { workspaceOnly: true },
            },
          },
        ],
      },
    };

    expect(resolveEffectiveToolFsRootExpansionAllowed({ cfg, agentId: "messenger" })).toBe(false);
  });
});

Messung V0.5 in Prozent
C=100 H=98 G=98

¤ Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.0.5Bemerkung:  ¤

*Bot Zugriff






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.