Run code against Sinatra's tools
run_codeRun a JavaScript async arrow function that calls Sinatra's tools as functions, to chain, filter or loop over them in one step and return only what you need.
declare const sinatra: { /** Show the Sinatra user this connection acts as and the workspaces they belong to, with their role in each. The workspace ids are the workspace_id the other tools take. Reads only. / whoami(args?: {}): Promise; /* List a workspace's tasks, most recently active first, with each task's status, repository and pull request. Use it to find a task or see what's running; pass nextCursor as cursor for the next page. Reads only. / list_tasks(args: { workspace_id: string; // The workspace id (from whoami). status?: string; // Only tasks in this status, e.g. implementing or pr_open. limit?: number; cursor?: string; // nextCursor from the previous page. }): Promise; /* Get one task's status, title, repository and pull request. Works for any task in the workspace, wherever it started. Reads only. / get_task(args: { workspace_id?: string; // The task's workspace id (from whoami). Optional: Sinatra finds it from task_id. task_id: string; // The task id (from list_tasks). }): Promise; /* Start a new coding task in a workspace. Sinatra's agent works on the prompt in its own sandbox and answers in the task's conversation. Depending on the prompt, it may push a branch and open a pull request in a connected GitHub repository. Each call starts a separate task unless it repeats an earlier idempotency_key. The task's url is its page in the Sinatra dashboard, where a person can follow it and reply. / start_task(args: { workspace_id: string; // The workspace id (from whoami). prompt: string; // What to do, as you'd ask a teammate. title?: string; // A short title; defaults to the prompt's first line. repo?: string; // owner/name of a connected repository. Omit to let the agent choose. model?: string; // A model id from Sinatra's catalog, such as anthropic/claude-opus-5-5 or openai-codex/gpt-6.1-sol, for every agent on this task. Omit to use the repository's or workspace's model. idempotency_key?: string; // Retrying with the same key returns the same task instead of starting another. }): Promise; /* Send a message on a task started with start_task, such as an answer to the agent's question or a change of plan. A message sent while an agent is working waits and starts the next agent. A task that has stopped picks up again, and the agent may push more commits to the task's pull request. / follow_up(args: { workspace_id?: string; // The task's workspace id (from whoami). Optional: Sinatra finds it from task_id. task_id: string; // The task id (from list_tasks). text: string; idempotency_key?: string; // Retrying with the same key sends the message once. }): Promise; /* Read the conversation of a task started with start_task, oldest first: your messages, the agent's answers and questions, and Sinatra's notices. Pass after to read only newer messages. Reads only. / get_messages(args: { workspace_id?: string; // The task's workspace id (from whoami). Optional: Sinatra finds it from task_id. task_id: string; // The task id (from list_tasks). after?: string; // The id of the last message already read (or next from the previous page). limit?: number; }): Promise; /* Stop the agent working on a running task, interrupting the work in progress. Works for any task in the workspace, wherever it started; any member may stop any task, a teammate's included. / stop_task(args: { workspace_id?: string; // The task's workspace id (from whoami). Optional: Sinatra finds it from task_id. task_id: string; // The task id (from list_tasks). }): Promise; /* Search the open Linear and GitHub issues you could delegate to Sinatra: yours first, then your team's unassigned ones, leaving out issues assigned to someone else or already being worked on. Pass a ticket to delegate_ticket: for Linear, its identifier as id; for GitHub, its identifier's owner/name as repo and number. linear and github say whether each tracker is connected and your Linear account linked. Reads only. / search_tickets(args: { workspace_id: string; // The workspace id (from whoami). query?: string; // Text to match: GitHub search terms, or a substring of a Linear issue's title. Omit to list without filtering. repo?: string; // owner/name of a connected repository to search first on GitHub. }): Promise; /* Hand an existing Linear issue or GitHub issue to Sinatra as you, as if you'd assigned it to Sinatra yourself. Sinatra assigns or labels the issue, and its agent may push a branch and open a pull request. The task's conversation stays on that issue (follow_up and get_messages don't apply); list_tasks shows its progress. */ delegate_ticket(args: { workspace_id: string; // The workspace id (from whoami). source: "linear" | "github"; id?: string; // Linear only: the issue identifier (e.g. ENG-123) or id. repo?: string; // GitHub only: owner/name of a connected repository. number?: number; // GitHub only: the issue number. }): Promise; };
Each function resolves with the JSON its tool returns, and throws an Error with the tool's message when the tool refuses. Calls run as you, with the same checks as calling the tool directly. console.log output comes back as logs. There is no network, filesystem or timer access.
Per run: at most 50 tool calls, 200 ms of computation and 30 s in all; return at most 50,000 characters of JSON.
Example: async () => { const { workspaces } = await sinatra.whoami(); const { tickets } = await sinatra.search_tickets({ workspace_id: workspaces[0].id, query: "flaky" }); return tickets.map((t) => t.identifier); }
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | An async arrow function, like async () => { ... }; what it returns is the result. |