Skip to content

API Reference


API Reference / Policy

Class: Policy

Defined in: src/agent/Policy.ts:49

Permission policy for the agent and MCP surfaces.

Two independent gates guard writes: the caller must hold the scope, and live trading must be switched on. Read tools need only the scope.

Constructors

Constructor

new Policy(options?): Policy

Defined in: src/agent/Policy.ts:53

Parameters

options?

PolicyOptions = {}

Returns

Policy

Properties

scopes

readonly scopes: readonly AgentScope[]

Defined in: src/agent/Policy.ts:50

Methods

readOnly()

static readOnly(): Policy

Defined in: src/agent/Policy.ts:68

Read scopes only — the safe default for an unattended agent.

Returns

Policy


full()

static full(): Policy

Defined in: src/agent/Policy.ts:73

Every scope. Writes still require the live-trading gate.

Returns

Policy


fromEnv()

static fromEnv(env?): Policy

Defined in: src/agent/Policy.ts:81

Reads DHANHQ_AGENT_SCOPES (comma or space separated), defaulting to read-only when unset.

Parameters

env?

ProcessEnv = process.env

Returns

Policy


allows()

allows(scope): boolean

Defined in: src/agent/Policy.ts:90

Parameters

scope

AgentScope

Returns

boolean


require()

require(scope): true

Defined in: src/agent/Policy.ts:95

Throws unless the policy holds scope.

Parameters

scope

AgentScope

Returns

true


writesEnabled()

writesEnabled(env?): boolean

Defined in: src/agent/Policy.ts:107

True only when both env flags are set, unless explicitly overridden.

Parameters

env?

ProcessEnv = process.env

Returns

boolean


requireWrite()

requireWrite(scope, env?): true

Defined in: src/agent/Policy.ts:118

Throws unless the policy holds scope and writes are enabled.

Parameters

scope

AgentScope

env?

ProcessEnv = process.env

Returns

true

Community project — not affiliated with Dhan. MIT License.