Agent-readable docs index: /llms.txt. Full docs in one file: /llms-full.txt. Download /docs.zip to grep all markdown files locally.

Read-only code mode

Code mode gives an AI client one extra tool, stackyapper_run_code. Instead of calling tools one at a time and reading every response, the client writes a short JavaScript script. The script calls your connected apps, filters and combines the results, and returns only the summary. One run can make up to 12 discovery or read calls and return a compact summary instead of every raw response.
Code mode is on by default and uses your current permissions. If the tool is missing, refresh or reconnect your AI client. Stackyapper can turn code mode off for a workspace; contact support if it stays unavailable.

When to use it

Use code mode when a question needs several reads or more data than you want in the conversation:
  • Across apps: "Which companies have open Priority 1 tickets and offline servers?"
  • Paging: count or group every alert, not just the first page.
  • Filtering and summarizing: return totals by status instead of 300 raw records.
For a single lookup, such as one ticket or one user, call the tool directly. It is simpler and just as fast.
To help your agent decide when to use code mode and how to report what it found, share the code mode agent guide with it or import it as a skill.

What it can and cannot do

Code mode is read-only. Scripts can only discover tools and call read tools, through the same authorization, app connections, and audit trail as direct calls:
  • The script runs as the person using the AI client, with exactly their permissions in the current workspace.
  • Create, update, delete, and execute tools are rejected before they reach the app.
  • Every app or discovery call is checked, audited, and counted like the same call made directly. Budget checks use no app tool-call slot.
  • Scripts have no network access, credentials, files, packages, timers, or storage. They see only the results Stackyapper returns to them.
  • Reads that need confirmation can't be confirmed from a script. Run those directly.
Access is checked again on every call. If a workspace admin turns off an app or tool while a script runs, the next call to it returns ok: false. If code mode access is removed, the run stops and its result is withheld.

Writing a script

A script is the body of an async function. Use await and end with return. The returned value, converted to JSON, is the result. A script pasted inside a single Markdown code fence is accepted as-is.
Scripts use a tools object:
CallWhat it does
tools.search({ query })Find tools by describing the task.
tools.schemas({ tool_names })Get the exact arguments for tools you found. Each schema includes a TypeScript-style signature.
tools.connections({ service })List connections for an app when there is more than one.
tools.call({ tool_name, arguments, connection_id })Run a read tool. connection_id is only needed when an app has several connections.
tools.budget()Check the remaining calls, read bytes, and time. The snapshot uses no app tool-call slot; at most 32 checks are allowed.
For independent reads, await Promise.all(...). At most two calls run at once; all calls share the same run limits. Keep dependent reads and continuation pages sequential. Await every call before returning.
Every discovery/read call counts toward the 12-call limit when you create it, including calls waiting for a slot. Creating a 13th call stops the run and withholds its result, so cap the list before you map it to calls.
Every call resolves to one of two shapes. Branch on ok:
const result = await tools.call({ tool_name: 'cw_get_ticket', arguments: { ticketId: 42 } }); if (!result.ok) { // result.error = { code, message, retryable } return { ticket: null, unavailable: result.error.message }; } return { summary: result.data.summary, status: result.data.status?.name };
  • { ok: true, data }: data is the tool's result.
  • { ok: false, error: { code, message, retryable } }: the call failed, but the script keeps running. Treat that source as unavailable, not empty.
Common error codes include tool_unavailable (the tool doesn't exist or isn't available to you), tool_call_timeout (the app didn't answer in time), read_limit (the result was withheld because the run reached its 1 MiB read limit), and the app's own error codes. tool_call_busy means earlier calls still occupy both slots, including an app request that timed out but has not finished stopping. Return what you have and identify that source as unavailable.

Signatures

tools.schemas returns each tool's JSON Schema plus a compact signature, for example:
(args: { after?: string; pageSize?: number; sourceType?: string }) => { alerts: unknown[]; pagination: { next_page_token: string | null; complete: boolean; upstream_count: number; returned_count: number } }
Long signatures keep an output section and mark omitted details with …. Read the full schema for those details.
Optional arguments end in ?. Don't invent tool names or arguments. Search, then read the schema.

Check the remaining budget

Use await tools.budget() before starting another page. Its data contains calls_remaining, read_bytes_remaining, and time_remaining_ms. The time leaves two seconds for finishing. At most 32 budget checks are allowed per run. Checks use no tool-call slot, but their responses count toward the read limit. Await outstanding calls before checking; the snapshot does not reserve capacity or guarantee that the next page fits. Keep a page cap and allow room for a slow or large response.

Continue in another run

Return resume as an object with the exact filters, chosen connection, next safe provider cursor, and summary accumulated so far. Stackyapper wraps it in continuation: { version: 1, workspace_id, state } in the response. Pass that whole envelope as the next stackyapper_run_code call's continuation argument. The script can read its state as input; input is null in a fresh run.
Compare the saved query scope with the requested scope before reading. Resume the cumulative summary rather than adding it to the previous total again. Changing filters or connections starts a new task. Continuations belong to one workspace, are held by the caller, and must fit 32 KiB. They do not schedule work, save a data source, or grant access. Every read checks current access.
An oversized checkpoint or truncated result returns no new continuation. Keep the last valid checkpoint and narrow the query or return a smaller summary. Do not use a cursor extracted from incomplete JSON.

Report each source separately

Return a sources list with a source label, status, pages_read, records_examined, and reason. Use complete only when the requested scope and the app's completion rules are established; partial for known remaining or omitted results; unavailable for a failed read; and unknown when you cannot establish completeness. These are observations reported by the script. A successful run does not establish a complete answer, and reading zero records successfully differs from being unable to read a source.

Logging

console.log, info, warn, error, and debug work. Output is returned with the result, including when a script fails, which makes a failed script easy to fix. Output is limited to 50 lines and 8,000 characters, with at most 1,000 characters per line. It is never stored.

Examples

Tool names below come from two example apps. Use the names, arguments, and output fields that tools.search and tools.schemas return in your workspace. If your workspace renamed its AI tools, they use your prefix.

Page through results within a cap

Discover the tool and read its schema first. This example uses NinjaOne alert snapshot pagination. Stackyapper checks that the collection stays unchanged between pages. A null next_page_token together with the accumulated count matching upstream_count ends the snapshot. Here, pagination.complete describes a collection returned in one page; it can stay false on the last of several pages.
Set the connection explicitly and keep a page cap. If the cap stops the loop, report partial and pass the continuation into another run. A changed snapshot requires restarting and discarding the old summary. This example remembers at most 128 cursors across runs and rejects repeats before counting a page. Reaching that history cap requires a narrower query. Other tools have different completion rules; follow their schemas and app guidance.
const scope = { tool_name: 'ninja_list_alerts', connection_id: 'YOUR_DISCOVERED_CONNECTION_ID', arguments: {pageSize: 50}, }; const record = v => v !== null && typeof v === 'object' && !Array.isArray(v); // JSON clients may reorder object members; array order and values still matter. const canonical = v => Array.isArray(v) ? v.map(canonical) : record(v) ? Object.fromEntries(Object.keys(v).sort().map(key => [key, canonical(v[key])])) : v; if (input && JSON.stringify(canonical(input.scope)) !== JSON.stringify(canonical(scope))) throw new Error('query scope changed'); const state = input ?? {scope, next: null, pages: 0, records: 0, seen_tokens: [], upstream_count: null}; if (!record(state) || !Number.isSafeInteger(state.pages) || state.pages < 0 || !Number.isSafeInteger(state.records) || state.records < 0 || !(state.next === null || typeof state.next === 'string' && state.next.length > 0) || !Array.isArray(state.seen_tokens) || state.seen_tokens.length > 128 || state.seen_tokens.some(token => typeof token !== 'string' || !token.length) || new Set(state.seen_tokens).size !== state.seen_tokens.length || state.seen_tokens.length !== state.pages || (state.pages > 0 && state.seen_tokens[state.pages - 1] !== state.next) || !(state.upstream_count === null || Number.isSafeInteger(state.upstream_count) && state.upstream_count >= state.records)) throw new Error('invalid checkpoint'); let status = state.pages ? 'partial' : 'unknown', reason = 'page_cap'; for (let pages = 0; pages < 3; pages++) { const budget = await tools.budget(); if (!budget.ok) {reason = budget.error.code; break;} if (budget.data.calls_remaining < 1 || budget.data.read_bytes_remaining < 8192 || budget.data.time_remaining_ms < 5000) {reason = 'run_budget'; break;} const page = await tools.call({tool_name:scope.tool_name,connection_id:scope.connection_id, arguments:{...scope.arguments,...(state.next === null ? {} : {after:state.next})}}); if (!page.ok) {status = 'unavailable'; reason = page.error.code; break;} const data = page.data, pagination = data && data.pagination; if (!record(data) || !Array.isArray(data.alerts) || !record(pagination) || typeof pagination.complete !== 'boolean' || pagination.mode !== 'local_snapshot' || !Number.isSafeInteger(pagination.upstream_count) || pagination.upstream_count < 0 || pagination.returned_count !== data.alerts.length || data.truncated === true) { status = 'unknown'; reason = 'invalid_or_truncated_page'; break; } const next = pagination.next_page_token; if (!(next === null || typeof next === 'string' && next.length > 0) || (next !== null && state.seen_tokens.includes(next)) || (pagination.complete === true && next !== null)) { status = 'unknown'; reason = 'invalid_continuation'; break; } const total = state.records + data.alerts.length; if ((state.upstream_count !== null && state.upstream_count !== pagination.upstream_count) || total > pagination.upstream_count || (next === null && total !== pagination.upstream_count) || (next !== null && total >= pagination.upstream_count)) { status = 'unknown'; reason = 'snapshot_count_mismatch'; break; } if (next !== null && state.seen_tokens.length >= 128) { status = 'partial'; reason = 'cursor_history_cap'; break; } // Commit a page only after validating its result and continuation. state.pages++; state.records = total; state.upstream_count = pagination.upstream_count; if (next === null) { status = 'complete'; reason = 'end_of_snapshot'; break; } status = 'partial'; state.seen_tokens.push(next); state.next = next; } const resumable = reason === 'page_cap' || reason === 'run_budget'; return {sources:[{source:'alerts',status,pages_read:state.pages, records_examined:state.records,reason}],summary:{records:state.records}, resume:resumable ? state : null};

Combine two apps and report partial results

const [tickets, alerts] = await Promise.all([ tools.call({ tool_name: 'cw_search_tickets', arguments: { conditions: 'closedFlag=false AND priority/name contains "Priority 1"', pageSize: 50 }, }), tools.call({ tool_name: 'ninja_list_alerts', arguments: { pageSize: 100 } }), ]); return { openP1TicketsOnFirstPage: tickets.ok ? tickets.data.length : null, ticketsComplete: tickets.ok ? false : null, // This example fetches one page, not the full total. alertsRead: alerts.ok ? alerts.data.alerts.length : null, alertsComplete: alerts.ok ? alerts.data.pagination.complete === true : null, unavailable: [tickets, alerts].filter((r) => !r.ok).map((r) => r.error.message), };
At most two independent calls run at once, and every call must be awaited before the script returns. Matching records across apps needs a shared identifier. Names that look alike are not proof that two records are the same company or device.

Limits

LimitValue
Script size16 KiB
Continuation envelope32 KiB
Budget checks per run32
Tool calls per run12 (including search and schema calls)
Tool calls at the same time2
Time per tool call20 seconds, always leaving 2 seconds for the script to finish
Time per run30 seconds
Tool results read per run1 MiB in total
Returned result64 KiB. Larger results are truncated and marked truncated. Results over 1 MiB stop the run.
Memory16 MiB
Runs at the same time2 per workspace
Runs per day500 per workspace, resetting at midnight UTC
Return summaries, not raw records. If a result is truncated, the response includes the beginning of the JSON as result_preview and says it is incomplete.
When the next tool result would take the run past 1 MiB, Stackyapper withholds it and the call returns ok: false with the code read_limit. The script keeps running, so it can still return what it already gathered and say the result is incomplete.

When a run stops

A run stops early when it hits a limit, access changes, the client cancels, the script fails, or Stackyapper cannot finish the run. A stopped run returns no result, only the reason, run ID, and any available console output. Calls that already finished may have happened; nothing is retried automatically.
ReasonWhat to do
The script failed at line NFix the error shown. Syntax errors are reported the same way.
More than 32 budget checksCheck once before each page or batch.
More than 12 tool callsCheck the budget before another page. Move discovery outside the script or resume in another run.
Passed the 30-second limitMake fewer or faster calls, or split the work into two runs.
Tool results passed 1 MiBRequest smaller pages or fewer fields. Handle read_limit errors so the script returns a partial result instead.
Returned more than 1 MiBReturn a smaller summary.
The client cancelledStart a new run if the result is still needed.
Code mode access was turned offRefresh your tools and contact support if access is expected.
A call had an invalid shapeCheck the script API and discovered schema.
Too many promise jobsReduce the work scheduled by the script.
An internal tool call or access check failed, or the sandbox was unavailableRead the error before trying again. Contact support if it persists.
Used its work budget or memorySimplify loops over large results, or keep fewer values.
Returned before awaiting every callawait every tools call, or await independent calls with Promise.all(...). At most two run at once; fetch dependent pages sequentially.
Code mode is busy in this workspaceTwo runs are already in progress. Try again shortly.
Today's limit reachedThe workspace has used its 500 runs for today (UTC).
Invalid continuationUse an envelope from this workspace or start a fresh task.
Missing scope, tenant, or connectionCheck the selected connection and its setup. Repeating the same run does not repair access.
A read requires confirmationUse the normal tool and approval flow. Code mode cannot confirm it.

Building a dashboard from a run

A successful run also returns artifact_handoff: suggested tool bindings and schema signatures your agent can use to draft a saved artifact. It contains no app data, credentials, or connection IDs, and it isn't saved. The run is not a data source; a saved artifact uses its own declared tools for later reads.

Usage and privacy

For each run, Stackyapper records operational details: when it ran, whether it completed or why it stopped, how many calls it made, how long they took, how many bytes were read and returned, the names of the tools called, and the CPU time it used. Stackyapper does not store your script, its arguments, the data it read, its logs, or its result. These records are kept for up to 90 days, and a workspace's run records are deleted with the workspace.
The tool calls a script makes are recorded in your workspace's audit log like direct calls. Code mode has no separate charge. Each tool call a script makes counts toward usage the same as a direct call.