Expand description
Hook helpers for Lua integration.
Provides LuaHook (a Lua-backed Hook implementation),
shorthand descriptor parsing, and HookContext ↔ Lua table
conversion utilities.
§orcs.hook() API
Two calling conventions:
-- Shorthand: "fql:hook_point"
orcs.hook("builtin::llm:request.pre_dispatch", function(ctx)
ctx.payload.injected = true
return ctx
end)
-- Table form (full control)
orcs.hook({
fql = "builtin::llm",
point = "request.pre_dispatch",
handler = function(ctx) return ctx end,
priority = 50, -- optional (default 100)
id = "my-hook", -- optional
})§Return value conventions
| Lua return | HookAction |
|---|---|
nil | Continue(original_ctx) |
context table (has hook_point) | Continue(parsed_ctx) |
{ action = "continue", ctx = ... } | Continue(...) |
{ action = "skip", result = ... } | Skip(value) |
{ action = "abort", reason = "..." } | Abort { reason } |
{ action = "replace", result = ... } | Replace(value) |
Structs§
- Hook
Load Error - Error from loading a single hook definition.
- Hook
Load Result - Result of loading hooks from configuration.
- LuaHook
- A hook backed by a Lua function.
Functions§
- hook_
context_ to_ lua - Converts a
HookContextto a Lua value (table) via serde. - load_
hooks_ from_ config - Loads hooks from a
HooksConfiginto aSharedHookRegistry. - lua_
to_ hook_ context - Converts a Lua value (table) back to a
HookContextvia serde. - parse_
hook_ descriptor - Parses a hook descriptor shorthand into FQL pattern and HookPoint.
- parse_
hook_ return - Parses the return value from a Lua hook handler into a
HookAction. - register_
hook_ function - Registers the
orcs.hook()function on theorcsglobal table. - register_
hook_ stub - Registers a default (deny)
orcs.hook()stub. - register_
unhook_ function - Registers the
orcs.unhook(id)function on theorcsglobal table.