Bundled Extensions

Bundled Extensions

rill provides extensions in two forms: core extensions bundled with @rcrsr/rill and external extensions as separate packages.

Core Extensions

Core extensions ship as part of @rcrsr/rill. Import them using sub-path imports.

Import Pattern

import { createFsExtension } from '@rcrsr/rill/ext/fs';
import { createFetchExtension } from '@rcrsr/rill/ext/fetch';
import { createExecExtension } from '@rcrsr/rill/ext/exec';
import { createKvExtension } from '@rcrsr/rill/ext/kv';
import { createCryptoExtension } from '@rcrsr/rill/ext/crypto';

fs — Filesystem Operations

Provides sandboxed filesystem access via mount-based permissions.

Configuration:

interface FsConfig {
  mounts: Record<string, MountConfig>;
  maxFileSize?: number;  // bytes (default: 10485760 = 10MB)
  encoding?: 'utf-8' | 'utf8' | 'ascii';
}

interface MountConfig {
  path: string;
  mode: 'read-only' | 'read-write';
  glob?: string;  // file filter pattern
  maxFileSize?: number;
}

Functions (12 total):

FunctionParametersReturnsDescription
readmount, pathstringRead file contents
writemount, path, contentstringWrite file (bytes written)
appendmount, path, contentstringAppend to file (bytes written)
listmount, path?listDirectory contents
findmount, pattern?listRecursive file search with glob
existsmount, pathboolCheck file existence
removemount, pathboolDelete file
statmount, pathdictFile metadata (name, type, size, timestamps)
mkdirmount, pathboolCreate directory
copymount, src, destboolCopy file within mount
movemount, src, destboolMove file within mount
mountslistList configured mounts

Namespace convention: fs

fetch — HTTP Requests

Creates endpoint functions from configuration. Scripts cannot specify arbitrary URLs.

Configuration:

interface FetchConfig {
  baseUrl: string;
  headers?: Record<string, string> | (() => Record<string, string>);
  timeout?: number;  // ms (default: 30000)
  retries?: number;  // default: 0
  retryDelay?: number;  // ms (default: 1000)
  maxConcurrent?: number;
  responseFormat?: 'json' | 'text';
  responseShape?: 'body' | 'full';
  endpoints: Record<string, EndpointConfig>;
}

interface EndpointConfig {
  method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
  path: string;
  params?: EndpointParam[];
  headers?: Record<string, string>;
  body?: 'json' | 'form' | 'text';
  responseFormat?: 'json' | 'text';
  responseShape?: 'body' | 'full';
  description?: string;
}

interface EndpointParam {
  name: string;
  type: 'string' | 'number' | 'bool' | 'dict';
  required?: boolean;
  location: 'path' | 'query' | 'body' | 'header';
  defaultValue?: string | number | boolean;
}

Functions: One function per endpoint declared in endpoints config, plus endpoints() introspection function.

Namespace convention: api or domain-specific (e.g., github, slack)

exec — Command Execution

Provides sandboxed command execution via allowlist/blocklist controls.

Configuration:

interface ExecConfig {
  commands: Record<string, CommandConfig>;
  timeout?: number;  // ms (default: 30000)
  maxOutputSize?: number;  // bytes (default: 1048576 = 1MB)
  inheritEnv?: boolean;  // default: false
}

interface CommandConfig {
  binary: string;
  allowedArgs?: string[];
  blockedArgs?: string[];
  cwd?: string;
  env?: Record<string, string>;
  timeout?: number;
  maxBuffer?: number;
  description?: string;
}

Functions: One function per command declared in commands config, plus commands() introspection function.

Each command function:

ParametersReturnsDescription
args?, stdin?dictExecutes command, returns {stdout, stderr, exitCode}

Namespace convention: cmd or exec

kv — Key-Value Store

Provides persistent JSON-backed key-value storage with optional schema validation. Supports multiple named mounts for organizing data.

Configuration:

interface KvConfig {
  mounts: Record<string, KvMountConfig>;  // named mounts
}

interface KvMountConfig {
  store: string;  // file path
  schema?: Record<string, SchemaEntry>;  // optional (enables declared mode)
  maxEntries?: number;  // default: 10000
  maxValueSize?: number;  // bytes (default: 102400 = 100KB)
  maxStoreSize?: number;  // bytes (default: 10485760 = 10MB)
  writePolicy?: 'dispose' | 'immediate';  // default: 'dispose'
}

interface SchemaEntry {
  type: 'string' | 'number' | 'bool' | 'list' | 'dict';
  default?: RillValue;
  description?: string;
}

Backward compatibility: Single-store config ({ store: "path" }) is supported and creates a default mount named "default".

Functions (11 total):

FunctionParametersReturnsDescription
getmount, keyanyGet value or schema default
get_ormount, key, defaultanyGet value or provided default
setmount, key, valueboolSet value (validates against schema)
mergemount, key, partialboolMerge dict fields into existing value
deletemount, keyboolDelete key
keysmountlistGet all keys in mount
hasmount, keyboolCheck key existence
clearmountboolClear all keys in mount (restores schema defaults)
getAllmountdictGet all entries in mount as dict
schemamountlistGet schema information (empty in open mode)
mountslistGet list of available mount names

Namespace convention: kv or state

crypto — Cryptographic Operations

Wraps Node.js crypto module for hashing and random generation.

Configuration:

interface CryptoConfig {
  defaultAlgorithm?: string;  // default: 'sha256'
  hmacKey?: string;  // required only if hmac() used
}

Functions (4 total):

FunctionParametersReturnsDescription
hashinput, algorithm?stringHash content (hex output)
hmacinput, algorithm?stringGenerate HMAC signature (hex output)
uuidstringGenerate random UUID v4
randombytesstringGenerate random bytes as hex string

Namespace convention: crypto


External Extensions

External extensions ship as separate npm packages. Install and integrate as needed.

ExtensionPackageNamespaceDescription
claude-code@rcrsr/rill-ext-claude-codeclaude_codeClaude Code CLI integration
fs-s3@rcrsr/rill-ext-fs-s3fsS3-compatible object storage backend
kv-redis@rcrsr/rill-ext-kv-rediskvRedis key-value storage backend
kv-sqlite@rcrsr/rill-ext-kv-sqlitekvSQLite key-value storage backend
llm-anthropic@rcrsr/rill-ext-anthropicanthropicAnthropic Claude API integration
llm-gemini@rcrsr/rill-ext-geminigeminiGemini API integration
llm-openai@rcrsr/rill-ext-openaiopenaiOpenAI API integration
mcp@rcrsr/rill-ext-mcp(dynamic)MCP server integration
vectordb-chroma@rcrsr/rill-ext-chromachromaChromaDB vector database
vectordb-pinecone@rcrsr/rill-ext-pineconepineconePinecone vector database
vectordb-qdrant@rcrsr/rill-ext-qdrantqdrantQdrant vector database

See Also