Docs menu
DocsAPI reference

Shared data & tools

scopedData, scopedTools, the durable/ephemeral shared-data channels, and publishing tools to ChatOSS's agents.

Three surfaces for sharing data and tools — app-private storage, app-private AI tools, and the OS-wide shared store. Read the runtime bridge for scopedData — this page covers the rest.

App-private AI tools (no capability, never prompts)

scopedTools are tools only YOUR app's own chat.runTurn calls can see. They never enter the global registry other apps' agents read, so they need no approval and no toolsStoreRequests entry. Note them in the manifest's scopedTools array as documentation.

window.chatoss.scopedTools.register(toolDef);          // synchronous, no prompt
const mine = window.chatoss.scopedTools.list();        // this app's scoped tools

Passing tools: directly to chat.runTurn is the simpler path and usually what you want; register a scoped tool when you need the same tool available to every turn without threading it through each call.

Shared data across apps

const v  = await window.chatoss.data.get('some.key');          // any app may read any key
const ok = await window.chatoss.data.set('myapp.public', v);   // needs a dataStoreRequests entry + user approval
window.chatoss.data.onChanged('some.key', (v) => render(v));  // fires until the app closes
const ok2 = await window.chatoss.data.requestSet('other.key', v); // always routes through approval

set() is the durable path: it writes to SQLite and broadcasts to every ChatOSS window.

await window.chatoss.data.publish('myapp.stream', { kind: 'token', text: chunk });

publish(key, value) is its EPHEMERAL sibling: it notifies subscribers in this window and updates the in-memory cache, but performs no SQLite write and no cross-window broadcast. Use it for high-frequency streams — agent tokens, progress ticks, cursor positions — where a set() per event would hammer the database with rows nobody will ever read again. Nothing published this way survives a store reload, and another window will not see it, so never publish state you need later: publish the stream, set() the result.

The Agent Engine publishes its progress events to engine.progress through this channel.

Publishing a tool to ChatOSS's own agents (advanced, usually skip)

await window.chatoss.tools.register(toolDef, async (args) => 'result');
// Needs a toolsStoreRequests entry + user approval. The handler only answers
// while YOUR app is open; agents calling it when the app is closed get an
// honest "app isn't open" error.

Every app's exported app-to-app APIs ALSO become global tools automatically — prefer apiExports over this.