@intutic/clawde
v3.2.3
Published
TypeScript SDK for governing Claude and other agents: the gate client, rule records and refusal types
Readme
@intutic/clawde
Programmatic client SDK for intercepting, wrapping, and enforcing policies on AI coding agent scripts.
Installation
npm install @intutic/clawdeFeatures
- Governed chat:
chat()sends a request through the proxy and resolves withverdict: 'allow'. A governance refusal (policy block, reask, loop run held for review, spend cap, DLP block) throwsClawdeBlockedErrorwith the proxy'sverdict,code,ruleId(when the proxy names the rule) and reason, and is never retried; transport failures and 5xx answers are retried, except a 5xx the proxy already retried upstream. - Withheld tool calls: when the proxy withholds a tool call from the model's answer (a tool an SOP denies, the SSO group policy, destructive SQL, sensitive output), the answer arrives as a 200 that names the refusal in the
x-intutic-refusalandx-intutic-refusal-ruleheaders.chat()reads them and throwsClawdeBlockedErrortoo. For a stream you read yourself, pass each line tostreamRefusal(), which finds the: intutic-refusalmarker the proxy writes before the refusal text. See Verdicts and Errors for every refusal code. - Verdict Events:
client.on('kill' | 'reask' | 'hold', ...)fires on a refusal, beforechat()throws. - Anthropic requests:
provider: 'anthropic'translates OpenAI-style parameters to an Anthropic Messages body, sends it to the proxy's/v1/messagesroute, and translates the reply back. - Budget Check:
checkBudget()reports whether the workspace has budget left, from the control plane'sGET /api/v1/budget. It needs a control plane address (controlPlaneUrlorINTUTIC_CONTROL_PLANE_URL); without one it throwsClawdeConnectionError, and no session is registered. - Circuit Breaker:
client.circuitBreaker(toolName, options)(fn)runsfn, after a workspace budget check whenrequireBudgetis set, failing closed unlessfailOpenis set. - Context Resolution:
resolveContext()takes each field (git branch, Jira ticket, PagerDuty incident, CI pipeline, workspace, session) from~/.intutic/config.jsonwhen the file carries it, and from environment variables otherwise (GIT_BRANCH,PD_INCIDENT_ID, the CI run id,INTUTIC_WORKSPACE_ID,INTUTIC_SESSION_ID); the Jira ticket comes from the file only. - Git context (
autoContext, on by default): with an Intutic virtual key, in a git repository, the firstchat()registers a session with the control plane carrying the repository (theoriginremote ashost/path, credentials removed), the branch and the HEAD commit, so the calls count in cost per branch, commit and pull request. PassautoContext: falseto send none of it. See Git context and cost attribution. - Control-Plane Management (
ControlPlaneClient): The operator APIs the CLI exposes, callable programmatically against the control plane you name (baseUrlorINTUTIC_CONTROL_PLANE_URL; the constructor throws without one): org and workspace setup, gateways, settings and provider credentials, the MCP registry, notification rules, SIEM destinations, usage, the AI inventory, compliance evidence (withverifyEvidenceArchive()to check an archive offline), policy guardrails, held decisions and loop runs, incidents, findings, traces, trace integrity (withverifyIntegrityRoot()to check a sealed root's signature offline), WASM rules, SOPs, API keys (listApiKeysand the rest), the SOP Optimizer's settings (getOptimizerSettings,updateOptimizerSettings) and task-management connections (listTaskConnections). The Python SDK has the same methods in snake_case. See the SDK reference. - Decide questions:
decide(state, questions, opts)asks a self-hosted model a few narrow yes/no or pick-one questions about a piece of text, written as a decide rule'squestions, and returns each answer's probability and reading (withopts.when, the outcome the rule would reach). The engine comes from~/.intutic/decide/engine.jsonand theINTUTIC_DECIDE_*variables; a hosted decision API is refused before anything is sent. An engine that is not configured, refused or cannot answer in time throwsDecideEngineError. See Decide rules.
Every export, with its signature and defaults: API reference.
License
MIT
