Skip to content

URI schemes for agents (ctx.agents.uri)

An init file (or omfp_eval) declares a scheme the workspace’s agents read with read:

ctx.agents.uri("ticket", {
description: "A ticket of our tracker as Markdown: ticket://<id>; ticket:// lists the open ones.",
async read(uri, { signal }) {
const id = uri.slice("ticket://".length);
const response = await fetch(`https://tracker.example/api/${id}`, { signal });
return { text: await response.text(), contentType: "application/json" };
},
list: () => "- ticket://12: Login fails\n- ticket://13: Slow search",
});
Field What it is
scheme Lowercase letters, digits, +, -, ., starting with a letter, no ://. omfp’s own (local, omfp, thread, job) and file fail the declaration.
description What read’s description tells the model about these URIs: their forms and what they hold.
read(uri, call) Reads one URI. call = { threadId, folders, signal }: the reading thread, the workspace’s top-level folders (absolute), aborted when the agent’s call is. Returns a string (Markdown) or { text, contentType? } (text/markdown, application/json, text/plain); a throw fails the call with its message.
list(call) Optional: answers the bare <scheme>://; without it read gets that URI too.

The code runs in the workspace’s host. read pages the text by lines (offset, limit) as it does omfp://; text longer than 4 MB is cut with a note. Reads change nothing, so none asks for approval; write, edit, grep, find and ls refuse the URIs. A thread reads its workspace’s schemes when its session starts: a scheme declared or removed later reaches a running thread once it is idle, by restarting its session. A scheme goes with the plugin that declared it, aborting its running reads. Local files of a type of their own (archives, databases, …) take a file reader instead (ctx.agents.reader, omfp://docs/readers).

@omfp/flavor (omfp://docs/flavor) declares, in each workspace:

  • https://…, http://…: the page as Markdown, the article Mozilla Readability finds (else the whole page) under its title and address, links absolute; text, Markdown and JSON as they are; other types refused. Pages needing JavaScript or a login read empty: use the browser tool when the workspace has one. Loopback and private addresses are read (a dev server on localhost) unless web: { private: false }.
  • pr://<n>, issue://<n>: a pull request (body, checks, reviews, comments) or an issue of the workspace’s repository — the one the upstream (else origin) remotes of its folders name; several ask for the long form — through gh with the user’s login. pr://<owner>/<repo>/<n> any repository’s, pr://<n>/diff its diff, bare pr:// / issue:// the open ones.