Skip to content

Script

This document specifies the Script extension, a flexible data-layer solution that enables extensible functionality through three primary execution contexts: LLM Tools, Table Actions, and User-Defined Functions (UDFs). The Script extension provides a unified interface for custom logic execution within data processing workflows.

The Script extension addresses the need for extensible data processing capabilities by providing a standardized framework for executing custom logic across multiple contexts. This specification defines the meta configuration structure and execution patterns for each supported script type.

When the type property is set to "tool", scripts function as callable tools within Large Language Model (LLM) workflows, enabling AI agents to execute custom functions with structured input/output schemas.

interface ToolMeta {
type: "tool"
funcName: string
tool: {
name: string
description: string
inputJSONSchema: JSONSchema
outputJSONSchema: JSONSchema
}
}
export const meta = {
type: "tool",
funcName: "hello",
tool: {
name: "hello",
description: "This is a hello world block",
inputJSONSchema: {
type: "object",
properties: {
name: {
type: "string",
},
},
},
outputJSONSchema: {
type: "string",
},
},
}
function hello(name: string) {
return `Hello, ${name}!`
}

When the type property is set to "action", scripts serve as table-level operations that can be triggered on selected records. These actions extend the table interface with custom functionality accessible through context menus.

interface ActionMeta {
type: "action"
funcName: string
action: {
name: string
description: string
}
}

Table action functions receive two parameters:

  • input: The selected record data as Record<string, any>
  • ctx: Context object containing tableId, viewId, and rowId
export const meta = {
type: "action",
funcName: "toggleChecked",
action: {
name: "Toggle Checked Status",
description: "Toggles the checked status of the selected record",
},
}
async function toggleChecked(
input: Record<string, any>,
ctx: {
tableId: string
viewId: string
rowId: string
}
) {
const { tableId, viewId, rowId } = ctx
await eidos.currentSpace.table(tableId).rows.update(rowId, {
checked: !input.checked,
})
return {
success: true,
}
}

When the type property is set to "udf", scripts create database functions that can be invoked within SQL queries, extending the database’s computational capabilities.

interface UDFMeta {
type: "udf"
funcName: string
udf: {
name: string
deterministic?: boolean
}
}

Scalar UDFs operate on individual values and return a single result per invocation.

export const meta = {
type: "udf",
funcName: "myAdd",
udf: {
name: "add",
deterministic: true,
},
}
function myAdd(a: number, b: number) {
return a + b
}

Script execution should be sandboxed appropriately to prevent unauthorized system access. Implementations must validate input parameters and enforce proper access controls based on the execution context.

  • All scripts MUST export a meta object conforming to the specified interface
  • Function names in the meta.funcName property MUST match the actual exported function
  • Input validation SHOULD be implemented for all script types
  • Error handling MUST be consistent across all execution contexts

This specification may be extended to support additional script types such as:

  • Event handlers
  • Data validators
  • Custom field types
  • Workflow triggers