js

package
v1.164.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandMapFunc

func ExpandMapFunc(values map[string]string, objName string, lookup, preprocess func(string) string) map[string]string

ExpandMapFunc expands JavaScript template literals in map values. It binds a dynamic object with the given name to the JS runtime, using lookup to resolve property accesses. Each value is optionally preprocessed with preprocess before expansion (pass nil to skip).

Types

type Expander

type Expander struct {
	// contains filtered or unexported fields
}

Expander expands JavaScript template literals in strings. It can be configured with an environment provider for ${env.X} access and/or agent tools for ${tool({...})} calls.

func NewEvaluator

func NewEvaluator(agentTools []tools.Tool) *Expander

NewEvaluator creates a new Expander with the given tools (for command evaluation).

func NewJsExpander

func NewJsExpander(env environment.Provider) *Expander

NewJsExpander creates a new Expander with the given environment provider.

func (*Expander) Evaluate added in v1.45.0

func (exp *Expander) Evaluate(ctx context.Context, input string, args []string) string

Evaluate finds and evaluates ${...} JavaScript expressions in the input string. args are available as the 'args' array in JavaScript.

func (*Expander) Expand

func (exp *Expander) Expand(ctx context.Context, text string, values map[string]string) string

Expand expands JavaScript template literals using the provided values map. The values are bound as top-level variables in the JS runtime alongside env and tools bindings.

func (*Expander) ExpandCommands

func (exp *Expander) ExpandCommands(ctx context.Context, cmds types.Commands) types.Commands

ExpandCommands expands JavaScript template literals in all command fields.

func (*Expander) ExpandMap

func (exp *Expander) ExpandMap(ctx context.Context, kv map[string]string) map[string]string

ExpandMap expands JavaScript template literals in all values of the given map.

Jump to

Keyboard shortcuts

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