Code Blocks
Tools for managing TypeScript code blocks that run on Val.town/Deno. Code blocks can be called from HAL expressions via thecode function and have auto-synced adapters generated for them.
Get Code Block
Retrieve a code block’s metadata, code, argument schemas, and version history. When called without an ID, lists code blocks with optional filtering.Parameters
Returns
- Metadata — Name, intent, creation date
- Code — Full TypeScript source for the selected version
- Argument schemas — Input and output schemas extracted from the deployed endpoint
- Versions — List of all versions with publish status
- Auto-synced adapter ID — The adapter that stays in sync with this code block
Create Code Block
Create a new code block with TypeScript source code. The code is deployed to Val.town and an adapter is auto-generated.Parameters
Code Format
Code blocks must use the@herd-labs/code-blocks-framework package:
Update Code Block
Update a code block’s metadata and/or TypeScript code. Code changes trigger redeployment and schema re-extraction.Parameters
When code is provided: if the latest version is an unpublished draft, it’s updated in-place; otherwise a new draft version is created.
Delete Code Block
Delete a code block and its auto-synced adapter.Parameters
Execute Code Block
Run a code block with given arguments. Uses the test branch (safe for iteration).Parameters
Returns
- Result — Output values from the code block
- Logs — Console output from execution (useful for debugging)
How Code Blocks Work in HAL
Once created, code blocks are callable in HAL expressions via thecode function:
Related Tools
- Use in actions → Actions & Adapters
- Test expressions → Evaluation
- HAL language reference → HAL Expression System
Next Steps
Actions & Adapters
Use code blocks in actions
Evaluation
Test your code blocks in expressions

