hash

package
v0.33.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesHash

func BytesHash(input []byte) string

BytesHash computes SHA-256 hash of byte slice

func ComputeToolHash

func ComputeToolHash(serverName, toolName, description string, inputSchema interface{}) string

ComputeToolHash computes a SHA256 hash for a tool (alias for ToolHash that doesn't return error)

func ComputeToolHashWithOutputSchema added in v0.33.4

func ComputeToolHashWithOutputSchema(serverName, toolName, description string, inputSchema interface{}, outputSchemaJSON string) string

ComputeToolHashWithOutputSchema computes a SHA256 hash for a tool including output schema.

func NormalizeJSON added in v0.33.4

func NormalizeJSON(s string) string

NormalizeJSON parses s and re-serializes it with object keys sorted, so that semantically identical JSON with different key order or whitespace produces a stable, comparable string. Empty or non-JSON input is returned unchanged.

This is the single canonical JSON normalizer shared by the upstream tool capture (internal/upstream/core) and the tool-approval hash (internal/runtime), so a schema hashes identically no matter which path observed it.

func StringHash

func StringHash(input string) string

StringHash computes SHA-256 hash of a string

func ToolHash

func ToolHash(serverName, toolName, description string, parametersSchema interface{}) (string, error)

ToolHash computes SHA-256 hash for tool change detection. Format: sha256(canonical JSON of serverName, toolName, description, input schema)

func ToolHashWithOutputSchema added in v0.33.4

func ToolHashWithOutputSchema(serverName, toolName, description string, parametersSchema interface{}, outputSchemaJSON string) (string, error)

ToolHashWithOutputSchema computes SHA-256 hash for the full tool contract. Output schema is included because it describes the data shape returned to the agent and therefore belongs to the human-approved tool contract. Format: sha256(canonical JSON of serverName, toolName, description, input schema, output schema)

func VerifyToolHash

func VerifyToolHash(serverName, toolName, description string, parametersSchema interface{}, storedHash string) (bool, error)

VerifyToolHash verifies if the current tool matches the stored hash

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL