← Receivers

fn:run

fn family

Execute an allowlisted TypeDB function by name. Returns the function's result rows. Not public — caller must be authenticated; the resolver re-walks authority before executing.

Effect
ask
Awaits an outcome — the call returns the response below.
Caller
member
The class of authority the caller must already hold, decided from the attested context with no round trip.
Cost
variable
What one call costs, so you can budget before acting.
Reversible
no
This cannot be undone. Dry-run it first where the contract allows.
Idempotent
yes
Safe to retry as-is.

Send it with your agent

One click hands your coding agent a prompt that registers the substrate, reads this contract, and makes the call. Launch opens the app; the others copy the prompt.

Claude Code
Codex
Cursor
Gemini CLI
Claude Desktop
ChatGPT
curl -X POST https://one.ie/api/ask/fn:run \
  -H "Authorization: Bearer $ONE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"data": { "fn": "optimal_route", "args": { "$from": "actor-123", "$skill": "writing" }, "workspace": "acme" }}'

The key is never in a link. npx -y @oneie/cli login writes it to ~/.config/oneie/key on your machine.

Request

Validated before dispatch — an invalid payload is refused with the fix, never half-applied.

  • fn string required Function name from FN_MAP (e.g. 'optimal_route', 'actionable_hypotheses')
  • args object optional Named arguments matching the function's param list
  • workspace string optional Workspace slug for authority context

Response

What comes back from the call.

  • ok boolean
  • fn string
  • rows object[]
  • error string

Traffic

Every call to fn:run, counted where it is dispatched — over HTTP or in-process alike. Aggregate only — no actor, no payload, no workspace.

Counting…

Wiring

Every place in the open source that names fn:run, and the file that answers it. Read from the tree at build time — a receiver is reached by NAME through one door, so there is no import edge to follow and a grep is the honest shape of the question. Structure, not volume — the count is in Traffic above.

Called from

API route 2
  • one.ie/web/src/lib/resolvers/id.ts:18
  • one.ie/web/src/lib/story.ts:173
Agent runtime 1
  • channels/src/tools/fn.ts:40
Workflow 1
  • one.ie/web/src/lib/factory/gaps.ts:43
SDK 2
  • packages/sdk/src/client.ts:889
  • packages/sdk/src/fn-allowlist.ts:5
Docs 2
  • one.ie/web/src/content/docs/mcp.md:374
  • one.ie/web/src/lib/CLAUDE.md:62

Answered by

fn:run one.ie/web/src/lib/resolvers/fn.ts:120 Dispatched through POST /api/ask/fn:run, after the envelope validates the payload.
JSON Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "fn": {
      "type": "string",
      "description": "Function name from FN_MAP (e.g. 'optimal_route', 'actionable_hypotheses')"
    },
    "args": {
      "description": "Named arguments matching the function's param list",
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {}
    },
    "workspace": {
      "description": "Workspace slug for authority context",
      "type": "string"
    }
  },
  "required": [
    "fn"
  ]
}
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "ok": {
      "type": "boolean"
    },
    "fn": {
      "type": "string"
    },
    "rows": {
      "type": "array",
      "items": {
        "type": "object",
        "propertyNames": {
          "type": "string"
        },
        "additionalProperties": {}
      }
    },
    "error": {
      "type": "string"
    }
  },
  "required": [
    "ok",
    "fn",
    "rows"
  ]
}