Naming Conventions
Python usessnake_case for all identifiers. TypeScript uses camelCase for properties and methods, and PascalCase for types and classes.
| Python | TypeScript | Context |
|---|---|---|
risk_scorer | riskScorer | Constructor / gate option |
audit_logger | auditLogger | Constructor / gate option |
risk_hints | riskHints | Gate option |
min_review_seconds | minReviewSeconds | Gate option / policy key |
fail_mode | failMode | Timeout policy option (deny | allow | escalate) |
timeout_seconds | approvalTimeoutSeconds | Timeout threshold (seconds) |
agent_id | agentId | Gate option / context field |
session_id | sessionId | Gate option / context field |
challenge_map | challengeMap | Policy key |
function_name | functionName | ActionContext field |
function_doc | functionDoc | ActionContext field |
risk_assessment | riskAssessment | ApprovalResult field |
challenge_result | challengeResult | ApprovalResult field |
review_time_seconds | reviewTimeSeconds | ApprovalResult field |
from_config | Constructor (new Attesta()) | No TS equivalent; use constructor |
render_approval | renderApproval | Renderer method |
render_challenge | renderChallenge | Renderer method |
render_info | renderInfo | Renderer method |
render_auto_approved | renderAutoApproved | Renderer method |
challenge_type | challengeType | ChallengeProtocol property |
Gate Syntax
The@gate decorator in Python has no direct equivalent in TypeScript. Instead, TypeScript uses gate() as a higher-order function.
- Python
- TypeScript
Python supports three calling styles:
Async Patterns
Python’sasyncio and TypeScript’s Promise model have significant differences that affect how Attesta works in each language.
- Python
- TypeScript
The Python SDK supports both sync and async functions. When a sync function is decorated with The
@gate, Attesta internally bridges to async using asyncio.run() or schedules a task if a loop is already running (e.g., Jupyter).sync_timeout parameter (default 300s) controls how long Attesta waits when bridging from sync to async.In TypeScript, if you wrap a synchronous function with
gate(), it is automatically treated as an async function. The return type becomes Promise<T> regardless of the original function’s return type.Configuration Loading
- Python
- TypeScript
from_config() is synchronous and returns an Attesta instance directly.Evaluate API
Theevaluate() method is available on both SDKs and runs the full approval pipeline without raising AttestaDenied. The caller is responsible for checking the verdict.
- Python
ActionContextuses keyword arguments to the constructor; TypeScript uses an object literal matching the interface shape. - Python uses
==for enum comparison; TypeScript uses===. - Python accesses
result.risk_assessment; TypeScript accessesresult.riskAssessment.
Custom Implementations
Both SDKs use structural typing for pluggable components (scorers, renderers, loggers), but the mechanism differs.- Python
- TypeScript
Python uses
Protocol classes with @runtime_checkable. Any object with the right methods satisfies the protocol — no inheritance needed.Error Handling
| Aspect | Python | TypeScript |
|---|---|---|
| Exception class | AttestaDenied | AttestaDenied (extends Error) |
| Null result check | if e.result: | error.result?.verdict (optional chaining) |
| Catch syntax | except AttestaDenied as e | catch (error) + instanceof check |
Feature Parity
Most features are available in both SDKs. The table below documents known differences as of v0.1.x.| Feature | Python | TypeScript | Notes |
|---|---|---|---|
gate() / @gate | Yes | Yes | Decorator vs. wrapper function |
Attesta class | Yes | Yes | |
Attesta.fromConfig() | Yes (sync) | No (use constructor) | TypeScript uses new Attesta() |
evaluate() | Yes | Yes | |
DefaultRiskScorer | Yes | Yes | |
CompositeRiskScorer | Yes | Yes | |
MaxRiskScorer | Yes | Yes | |
| Domain profiles | Yes | No | Python-only; use attesta.yaml domain config with the CLI |
| Multi-party challenge | Yes | Yes | Supported in core; renderer support is implementation-specific |
| Trust engine | Yes | Yes | |
| Audit logger (JSONL) | Yes | Yes | |
| Hash-chain verification | Yes | Yes | Python: verify_chain() / CLI, TypeScript: verifyChain() |
TerminalRenderer (rich UI) | Yes | Basic | TypeScript uses a basic console renderer |
| LangChain integration | Yes | Yes | |
| OpenAI Agents SDK | Yes | No | Python-only |
| Anthropic Claude | Yes | No | Python-only |
| CrewAI | Yes | No | Python-only |
| MCP decorator | Yes | No | Python-only |
MCP proxy (MCPProxy) | Yes | No | Use attesta mcp wrap CLI from TypeScript projects |
| Vercel AI SDK integration | No | Yes | TypeScript-only |
sync_timeout bridging | Yes | N/A | TypeScript is always async |
CLI (attesta) | Yes | N/A | CLI is Python-only; usable from any project |
Audit Log Compatibility
Both SDKs use hash-chained JSONL audit logs, but the serialized field names differ (snake_case in Python, camelCase in TypeScript). Do not mix Python- and TypeScript-produced entries in the same file if you need chain verification to pass.
Next Steps
TypeScript Getting Started
Install and configure the TypeScript SDK
Attesta Class
Full API reference for the Attesta class
Protocols
Implement custom scorers, renderers, and loggers
Vercel AI SDK
TypeScript-native Vercel AI integration