JavaScript
js_script · Nodes · Scripting
Runs JavaScript against workflow input.
JavaScript Script#
Runs sandboxed JavaScript or TypeScript against workflow inputs. verdalia.api gives the script HTTP, GraphQL, Feather tables, the Library, market data, Google, and a Verdalia Relay, so one node can fetch, loop, and shape data end to end.
Configuration#
input_names- named input sockets (default: singleinput)language-javascript(default) ortypescriptscript- JavaScript or TypeScript codetimeout_secs- execution timeout in seconds for the whole script,verdalia.apicalls included (default: 30); capped by the workflow's remaining timeoutput_names- named output sockets (default:null, shown as Disabled: oneoutputsocket carrying the returned value unchanged). See Named Outputs.
Multiple Inputs#
Use named inputs instead of inserting Merge nodes just to pack several wires into one object.
{ "input_names": ["email", "config", "rows"] }
const email = inputs.email;
const config = inputs.config;
const rows = inputs.rows;
This is the idiomatic Verdalia shape. Reach for Merge only when you need Merge's output as data: collected arrays, intentional object merge semantics, or select-after-side-effect behavior.
Named Outputs#
Set output_names to give the node several output sockets. The sockets are exactly the listed names, and the script returns an object with one key per output: each key's value goes out on the output of that name.
{ "output_names": ["ok", "refused"] }
const plan = inputs.input;
if (plan.approved) {
return { ok: plan, refused: skip('accepted') };
}
return { ok: skip('refused'), refused: plan.reason };
- Per-output skip. A key whose value is
skip(reason)ends that output's wire, exactly as anIfnode's untaken arm does; the other outputs carry on. Returningskip(reason)as the whole value ends every output. - Missing key. A listed name missing from the returned object goes out as
undefined. The node behind it still runs; onlyskipends a branch. - Undeclared key. A returned key that is not a listed name fails the node, and the error names the key and the listed outputs.
- Not an object. With named outputs, returning anything but a plain object - an array, string, number,
null, orundefined- fails the node. - One output.
["result"]expects{ result: ... }. To pass a value through as it is, leaveoutput_namesunset (null): the returned value then goes out onoutputuntouched, an object included. - Invalid names. An empty list, a blank name, a repeated name, or
errorwhile the failure mode is Route to error output still saves, but the node reports it as a validation finding and the workflow does not run until it is fixed.
The sockets come from configuration, not from what the script returns. Switching between Disabled and a list of names changes the sockets; an edge from a socket that no longer exists is reported by graph validation like any other.
Prefer Dedicated Nodes First#
For standard webhook signature verification, prefer Verify Signature instead of handwritten JavaScript. Prepare { payload, signature, timestamp } upstream, then let Verify Signature do the verification. Use js_script when you need custom message construction, unsupported algorithms, or more advanced crypto orchestration than the dedicated node exposes.
Doing Work in Code#
A JavaScript node does end-to-end work: it calls APIs through verdalia.api, loops over pages and items, combines sources, and shapes the result. A loop that fetches twenty pages is a loop in this node, not a chain of HTTP and JavaScript nodes. The graph around it keeps the trigger, the visible fetch or send, branches between behaviors, and the workflow output.
const items = [];
let cursor = null;
do {
const res = await verdalia.api.http.fetch('https://api.example.com/items', {
connection: inputs.settings.connection_id,
query: cursor ? [['cursor', cursor]] : [],
});
items.push(...res.body.value.items);
cursor = res.body.value.next_cursor;
} while (cursor);
return items.map(item => ({ id: item.id, title: item.title }));
- Modules.
http,graphql,tables,library,alpaca,polygon,indicators,gmail,google_calendar,drive,docs,sheets,slides, andrelay, each underverdalia.api.relayholds namespaces of its own:relay.fs,relay.shell,relay.audio,relay.hue,relay.codingandrelay.coding.paseo. Every module is available in every JavaScript node. The reference below lists every method, its arguments, and its result. - Library.
library.get(identifier)takes an item's id or slug and resolves to what the Library node's Get emits:id,slug,name,path,kind,object_idand a document's body as markdown oncontent; pass{ format: 'json_block' }for the block tree onblockstoo. An identifier that names nothing throws.library.listandlibrary.searchreturn items in the shape thelibrary_listandlibrary_searchtools use, each with itsurl. Like the Library node, all three read every item: an item set not readable by AI is hidden from AI tools, not from workflows. Creating and changing documents stays with the Library node. - Awaiting. The script body runs inside an async function, so top-level
await,return, andskip()work. - Connections. Pass a connection's id, from
list_connections, asconnection. A display name never references a connection. A connection that does not exist, or does not fit the module, throws. - Errors. A failed call throws. Uncaught, it fails the node and the run results show its message. Catch it only when the script has something else to do.
- At most 8 calls in flight. A ninth concurrent
verdalia.apicall throws instead of waiting, soPromise.allover more than 8 calls fails. Run larger batches in groups of 8 or one at a time. - Time.
timeout_secscovers the whole script. Raise it for a script that pages through many requests. - HTTP and GraphQL.
http.fetchandgraphql.querysend through the same code and public-address rules as theHTTP RequestandGraphQLnodes.http.fetchthrows on a non-2xx status unlessnever_erroris set;graphql.queryreturns GraphQL errors inerrorsrather than throwing. Pagination is a loop. - Tables.
tablesworks as thetablenode does: unrestricted access to the workspace's tables, attributed to the workflow run. - Trading.
alpacaplaces real orders with no approval step, the same as the Alpaca Trading node.modedefaults topaper; withmode: 'live', a script that submits an order trades real money. - Relay.
relaycalls what the Relay nodes call:relay.status,relay.requestfor any route without a method of its own, files in a mount, shell commands and programs, audio, Hue by light, room and scene id, and coding sessions. Name the Relay withconnection; left out, the workspace's only Relay is used, and a workspace with none or several throws.relay.codingtakes a coding session or project by its Verdalia id and needs no connection;coding.promptresolves once the Relay accepts the prompt, so readcoding.readagain for what follows, or react to it with anon_coding_agent_eventtrigger. Computer use is not reachable:relay.requestand the Relay Request node refuse a/api/computer/…path in any spelling. - Relay time. Every Relay call runs inside
timeout_secs, and one Relay request is cut off after 60 seconds. A script that runs a long command withshell.runneedstimeout_secsabove the command'stimeout_seconds. - What stays a node. Discord messages and document saves are steps the graph should show; feed them from this node's output. When a decision picks which of several visible steps runs, give this node named outputs and
skipthe ones not taken, or return the decision and route it withIforBranch. - Debugging. The run results show this node's inputs, output, and error, not the calls inside it. One script trades the visibility of intermediates that node boundaries give for the ergonomics of one script. When an intermediate value matters to someone reading the run, return it or make it its own step.
Shared Constants#
When several scripts need the same fixed value — the order of a pipeline's stages, a set of labels, a block of prompt text — put it in a table and read it with verdalia.api.tables in each script that uses it. The table row is the one place the value is written; editing it changes every reader without touching a script.
With a table workflow_constants whose ids are strings naming each constant, and a json column value:
const { rows } = await verdalia.api.tables.query({
table: 'workflow_constants',
filters: [{ target: 'id', operator: 'in', operand: ['stage_order', 'review_preamble'] }],
});
const constants = Object.fromEntries(rows.map(row => [row.id, row.value]));
const next = constants.stage_order[constants.stage_order.indexOf(inputs.input.stage) + 1];
return { ...inputs.input, stage: next ?? 'done' };
Do not wrap a constant in a subworkflow island, a small Input → JavaScript → Set Workflow Output group that returns a literal and is called with a Subworkflow node. Each call starts a run of its own to fetch one value, and the call nodes and the island crowd the graph until it no longer reads as the workflow's structure. Do not paste the same list into several scripts either: the copies drift apart.
Available in Script#
inputs- object with named input valuesverdalia.api- the modules above; see the reference below_has exactly these helpers:map,filter,reduce,groupBy,countBy,sortBy,uniq,uniqBy,flatten,flattenDeep,chunk,compact,first,last,sum,sumBy,mean,min,max,maxBy,pick,omit,get,set,keyBy,mapValues,isEmpty,isNil,cloneDeep._is not lodash; other helpers areundefined.dayjs()- date helpers (format,add,subtract,diff,startOf,endOf)Intl.DateTimeFormat- host-backed date/time formatter subsetIntl.supportedValuesOf('timeZone')- supported IANA timezone namesDateTime- preferred host-backed helper for timezone-aware parsing, formatting, arithmetic, and DST handlingrequire('crypto')- limited Node-style Ed25519 verification supportrequire('buffer')- limitedBuffercompatibility layer- global
Buffer- same limitedBufferimplementation without importing Ulid- constructor for a ULID value that stringifies and serializes as a ULID string. Usenew Ulid()when you want to provide explicit transcript entry IDs.skip(reason)- returns a control value that ends this branch. See Return Value.
Timezones and Dates#
Default timezone is UTC. The runtime never uses the server local timezone as an implicit default.
Use DateTime for timezone-sensitive logic. dayjs() remains available for compatibility and simple date helpers, but it is not the preferred API for timezone conversion, local wall-clock parsing, DST, or scheduling logic.
When a script works in the workspace's local time, pass the timezone from await verdalia.api.workspace.day() to DateTime. The call reads the current timezone from the workspace that owns the run.
Format an instant in the workspace's timezone#
const { timezone } = await verdalia.api.workspace.day();
const dt = DateTime.fromISO('2026-06-20T12:00:00Z', { timeZone: timezone });
return dt.format({
locale: 'cs-CZ',
timeZone: timezone,
dateStyle: 'medium',
timeStyle: 'short'
});
Convert timezone, preserve instant#
const instant = DateTime.fromISO('2026-06-20T12:00:00Z');
const tokyo = instant.withTimeZone('Asia/Tokyo');
return {
instant: tokyo.toISO(),
local: tokyo.toISO({ local: true }),
timezone: tokyo.timeZone(),
hour: tokyo.hour
};
Parse a local wall-clock time#
const { timezone } = await verdalia.api.workspace.day();
const meeting = DateTime.parseLocal('2026-06-20T09:30:00', {
timeZone: timezone
});
return meeting.toISO(); // UTC instant with trailing Z
Date-only input is local midnight in the selected timezone.
Reject a DST gap#
return DateTime.parseLocal('2026-03-29T02:30:00', {
timeZone: 'Europe/Prague',
nonexistent: 'reject'
}); // throws RangeError
DST rules:
- nonexistent local times default to
nonexistent: 'shift-forward' nonexistent: 'reject'throwsRangeError- repeated local times default to
disambiguation: 'compatible', same asearlier disambiguation: 'earlier' | 'later' | 'reject'is supported
Format to parts#
const { timezone } = await verdalia.api.workspace.day();
const parts = new Intl.DateTimeFormat('de-DE', {
timeZone: timezone,
year: 'numeric',
month: 'long',
day: 'numeric',
hour: '2-digit',
minute: '2-digit'
}).formatToParts('2026-06-20T12:00:00Z');
return parts.filter(part => part.type !== 'literal');
Supported DateTime surface#
- Constructors:
DateTime.now(options),DateTime.fromISO(value, options),DateTime.fromEpochMillis(ms, options),DateTime.parseLocal(value, options),DateTime.format(value, options) - Options:
timeZone,disambiguation,nonexistent - Instance methods:
toISO({ local }),toEpochMillis(),timeZone(),withTimeZone(timeZone),plus(duration),minus(duration),startOf(unit),endOf(unit),format(options),toJSON(),toString(),valueOf() - Getters:
year,month,day,hour,minute,second,millisecond,weekday,offsetMinutes - Duration fields:
years,months,weeks,days,hours,minutes,seconds,milliseconds startOf/endOfunits:year,month,week,day,hour,minute,secondplus plural aliases. Week starts on Sunday.
years, months, weeks, and days use calendar/wall-clock arithmetic in the object's timezone. hours, minutes, seconds, and milliseconds use instant duration arithmetic.
Supported Intl Surface#
The JS runtime is not full browser or Node.js Intl. Only this subset is available:
new Intl.DateTimeFormat(locales, options)format(value)formatToParts(value)resolvedOptions()Intl.supportedValuesOf('timeZone')
Supported formatter options:
timeZone(default:UTC)locales/options.locale: omitted ornulldefaults toen-US; valid BCP-47 locale strings are ICU-backed with normal data fallback. Common locales such ascs-CZ,de-DE,fr-FR, andja-JPwork.dateStyle,timeStyleweekday,era,year,month,day,hour,minute,second,fractionalSecondDigits,timeZoneNamehour12,hourCyclelocaleMatcher,formatMatcheras accepted no-op compatibility fields
Limitations:
- only IANA timezone names returned by
Intl.supportedValuesOf('timeZone')plusUTCare supported - unknown timezone names throw
RangeError - empty timezone strings throw
RangeError; only missing,undefined, ornulltimeZone defaults toUTC resolvedOptions().localeand.timeZonereflect the accepted locale and normalized timezone- formatter output uses ICU4X locale ordering, literals, names, hour cycles, and best-effort field widths for the supported subset; it is not a byte-for-byte browser
Intlclone formatToParts()returns locale-ordered ICU datetime parts plus literal segments for the supported fields- unsupported option keys throw
TypeError calendarandnumberingSystemoption keys are not supporteddateStyle/timeStylecannot be mixed with component fieldshour12andhourCyclecannot both be presentIntl.supportedValuesOf(...)only supports'timeZone'
Supported crypto Surface#
The JS runtime is not full Node.js. Only this allowlisted crypto surface is available:
crypto.verify(null | 'ed25519', data, key, signature)crypto.createPublicKey(input)
Public key inputs follow a small Node-style subset:
crypto.createPublicKey(Buffer)for raw 32-byte Ed25519 keys or DER SPKI Ed25519 keyscrypto.createPublicKey({ key: Buffer, format: 'der', type: 'spki' })crypto.verify(..., key, ...)wherekeyis either thatBufferform or the returned public key object
Supported Buffer operations are intentionally small:
Buffer.from(...)Buffer.concat(...)Buffer.isBuffer(...)buffer.toString('utf8' | 'utf-8' | 'hex')
Binary Data#
Runtime binary inputs arrive as Uint8Array. return inputs.input passes bytes through unchanged. Returning Uint8Array, ArrayBuffer, or Buffer.from(...) produces runtime binary output.
verdalia.api returns downloads, exports, and binary HTTP bodies as Uint8Array, and uploads take a Uint8Array directly.
Public/agent previews redact binary bytes as:
{"bytes":"<binary>","mime_type":"image/png","filename":"image.png","size_bytes":12345}
bytes: "<binary>" is not byte content or base64. Do not copy preview JSON into configs or test inputs.
Buffer.toString('base64') is not supported. If you need base64 JSON from media, use read_media with output_format = "base64".
Return Value#
null is an ordinary value and flows down the edge like any other, and so is undefined - which is what a code path that falls off the end without returning produces. Neither ends a branch: a downstream node still runs and can decide what to make of the value it was handed.
Ending a branch#
skip(reason) stops this branch. Downstream nodes do not run, and the editor fades the edge out with the reason on hover.
const captures = inputs.input;
if (captures.length === 0) {
return skip('Nothing to process today');
}
return captures;
The reason is optional. skip() alone is valid.
Any node can carry the value skip() builds:
{ "$$verdalia_node_control$$": { "op": "skip", "reason": "Nothing to process today" } }
Rules for it:
- It is read at the top level of the returned value only. Nested inside an object or array it is inert data.
- It must be the object's only key. Returning it alongside real fields fails the node.
opmust be exactlyskip. An unrecognisedop-"Skip", say - fails the node rather than flowing on as data.
A skip carries the node that raised it, so an edge several hops downstream still names where the branch actually ended.
skip(reason) is the only way to end a branch. A null return does not end one, so a node written to gate a send by returning null sends what it was meant to suppress - rewrite those to skip(reason).
Examples#
Filter input data#
const items = inputs.input;
return _.filter(items, item => item.score > 50);
Build an AI conversation transcript entry#
Use new Ulid() when you want to provide an explicit transcript ID. Do not hand-format IDs like msg_123.
return [{
id: new Ulid(),
timestamp: new Date().toISOString(),
kind: {
type: 'user_message',
content: [{ type: 'text', text: 'Hello' }],
},
}];
Advanced: Verify a Discord interaction signature in custom JavaScript#
Most Discord workflows should now use Verify Signature. This example remains useful when you need custom scripting around verification.
const crypto = require('crypto');
const event = inputs.input;
const signature = Buffer.from(event.headers['x-signature-ed25519'], 'hex');
const timestamp = event.headers['x-signature-timestamp'];
const body = event.raw_body ?? '';
const publicKey = crypto.createPublicKey({
key: Buffer.from('302a300506032b6570032100' + inputs.public_key, 'hex'),
format: 'der',
type: 'spki',
});
const message = Buffer.concat([
Buffer.from(timestamp, 'utf8'),
Buffer.from(body, 'utf8'),
]);
return crypto.verify(null, message, publicKey, signature);
Limitations#
- No filesystem, process, timers, or arbitrary package loading. Network access goes through
verdalia.apionly. - Each run may use at most 128 MiB of memory and 512 KiB of interpreter stack. Exceeding memory fails the node with
InternalError: out of memory; recursing too deep fails it withRangeError: Maximum call stack size exceeded. Split large data upstream, and prefer loops to deep recursion. require(...)only supports'crypto'and'buffer'- Crypto support is limited to
crypto.createPublicKey(...)andcrypto.verify(...)for Ed25519 verification flows Bufferonly supports the documented methods andutf8/hexencodings; base64 encoding is not supported- This runtime is not Node.js: only the APIs listed here exist
verdalia.api reference#
Generated from the code by verdalia api-reference; edit the code, not this section.
Every method returns a promise and throws on failure. Arguments are one object, checked strictly: a field the method does not take is an error. The exceptions are http.fetch(url, opts), which takes the URL first, and library.get(identifier, opts), which takes the item's id or slug first; each takes the rest as an object. A connection is named by its id; a relay method given no connection uses the workspace's only Relay. Bytes are Uint8Array in both directions. At most 8 calls may be in flight at once. Alpaca trading methods place, amend, cancel and close real orders with no approval step, the same as the alpaca_trading node; a live account trades real money.
verdalia.api.http#
http.fetch#
One HTTP request, sent through the workspace egress policy and read whole (at most 20 MiB).
A non-2xx response fails unless never_error is set.
fetch(url: string, opts?: {
// No body unless given.
body?: HttpBody;
// The id of the connection whose credential authenticates the request, resolved when it is
// sent.
connection?: DocId | null;
// Sent in order after the default `Accept: application/json` and `User-Agent` headers; a
// repeated name is sent repeatedly.
headers?: Array<[string, string]>;
// `GET` unless given.
method?: HttpMethod;
// Returns a non-2xx response instead of failing with its status and body.
never_error?: boolean;
// Appended to the URL's own query, in order.
query?: Array<[string, string]>;
// `auto` unless given.
response_format?: HttpResponseFormat;
// Sends the request again after a transient failure, judged by its method and
// `Idempotency-Key` header. Off unless given.
retry?: HttpRetryPolicy;
// Bounds each redirect hop. Defaults to 30.
timeout_secs?: number;
}): Promise<{
body: HttpResponseBody;
// Response headers by lowercase name. A repeated header keeps its last value; a value that
// is not visible ASCII is empty.
headers: Record<string, string>;
// The HTTP status code.
status: number;
}>
Types#
// The bounds of a policy that retries.
type BoundedRetry = {
// The wait before the first retry, doubling for each later one. 100 to 60000; 500 unless
// given.
initial_delay_ms?: number;
// Attempts in all, the first included. 2 to 10; 3 unless given.
max_attempts?: number;
// The longest single wait, `Retry-After` included. 1 to 300; 30 unless given.
max_delay_secs?: number;
};
// The identifier of a persisted record.
type DocId = string;
// The body a request sends.
type HttpBody = {
kind: "none";
} | {
kind: "json";
value: unknown;
} | {
fields: Array<[string, string]>;
kind: "form";
} | {
kind: "text";
text: string;
} | {
bytes: Uint8Array;
kind: "bytes";
};
// The HTTP method of a request.
type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
// A response body, decoded by the request's [`HttpResponseFormat`].
type HttpResponseBody = {
kind: "json";
value: unknown;
} | {
kind: "text";
text: string;
} | {
bytes: Uint8Array;
content_type: string;
kind: "bytes";
};
// How a response body is decoded.
type HttpResponseFormat = "auto" | "json" | "text";
// Whether, and how, one HTTP request is sent again after a transient failure.
type HttpRetryPolicy = {
mode: "off";
} | BoundedRetry & {
mode: "bounded";
};
verdalia.api.graphql#
graphql.query#
One GraphQL query or mutation, posted as {query, variables}. A non-2xx response fails;
GraphQL errors in a 2xx response are returned in errors, not raised.
query(args: {
// The id of the connection whose credential authenticates the request, resolved when it is
// sent.
connection?: DocId | null;
// Must reach an address the workspace egress policy permits.
endpoint: string;
// The query or mutation document.
query: string;
// Sends the request again after a transient failure. GraphQL is posted, so only a refused
// attempt is sent again. Off unless given.
retry?: HttpRetryPolicy;
// Bounds each redirect hop. Defaults to 30.
timeout_secs?: number;
// The operation's variables, by name.
variables?: Record<string, unknown>;
}): Promise<{
data: unknown;
errors: Array<GraphQlError> | null;
}>
Types#
// The bounds of a policy that retries.
type BoundedRetry = {
// The wait before the first retry, doubling for each later one. 100 to 60000; 500 unless
// given.
initial_delay_ms?: number;
// Attempts in all, the first included. 2 to 10; 3 unless given.
max_attempts?: number;
// The longest single wait, `Retry-After` included. 1 to 300; 30 unless given.
max_delay_secs?: number;
};
// The identifier of a persisted record.
type DocId = string;
// One entry of a GraphQL response's `errors`, as the GraphQL specification defines it.
type GraphQlError = {
// Server-defined detail; the specification leaves its shape to each server.
extensions?: Record<string, unknown> | null;
locations?: Array<GraphQlErrorLocation> | null;
message: string;
// The response field the error belongs to, from the root.
path?: Array<GraphQlPathSegment> | null;
};
// A position in the GraphQL document, both counted from 1.
type GraphQlErrorLocation = {
column: number;
line: number;
};
// A step of a GraphQL error path: a field name, or an index into a list.
type GraphQlPathSegment = number | string;
// Whether, and how, one HTTP request is sent again after a transient failure.
type HttpRetryPolicy = {
mode: "off";
} | BoundedRetry & {
mode: "bounded";
};
verdalia.api.tables#
tables.query#
One page of a table's rows, filtered, searched and ordered.
query(args: {
// Every filter must match.
filters?: Array<TableFilterInput>;
// How many rows to return: 25 when absent, at most 1000.
limit?: number | null;
// How many matching rows to skip.
offset?: number;
search?: RowSearch | null;
sort?: RowSort | null;
// The table's slug or id.
table: TableRef;
}): Promise<{
// Whether another page follows this one.
has_more: boolean;
// Where the next page starts, when there is one.
next_offset?: number | null;
rows: Array<Record<string, unknown>>;
// Every row the query matches, when the query asked storage to count them.
total?: number | null;
}>
tables.get#
One row, by its id.
get(args: {
row_id: FeatherRowId;
// The table's slug or id.
table: TableRef;
}): Promise<Record<string, unknown>>
tables.insert#
Insert one row or a batch of at most 1000; a row that carries an id is written at it.
Resolves to the id storage assigned, or to the ids in submission order.
insert(args: {
rows: Batch;
// The table's slug or id.
table: TableRef;
}): Promise<FeatherRowId | Array<FeatherRowId>>
tables.update#
Patch each row its id names. Every named row must exist, or nothing is written.
update(args: {
rows: Batch;
// The table's slug or id.
table: TableRef;
}): Promise<FeatherRowId | Array<FeatherRowId>>
tables.upsert#
Write each row at its id, inserting a row that names none or names one not yet stored.
upsert(args: {
rows: Batch;
// The table's slug or id.
table: TableRef;
}): Promise<UpsertedRow | Array<UpsertedRow>>
tables.delete#
Delete the rows named. Every named row must exist, or nothing is deleted.
delete(args: {
row_ids: Batch;
// The table's slug or id.
table: TableRef;
}): Promise<FeatherRowId | Array<FeatherRowId>>
Types#
// One item, or a batch of them. A result keeps the shape its arguments arrived in.
type Batch = FeatherRowId | Array<FeatherRowId>;
// A row's id: an integer on a number-id table, a string on a string-id one.
type FeatherRowId = number | string;
// Free-text search over one query.
type RowSearch = {
// The columns to search. Absent searches every searchable column.
targets?: Array<string> | null;
term: string;
};
// The order a query returns its rows in.
type RowSort = {
direction: TableSortDirection;
// The column to order by.
target: string;
};
// Shared transport filter decoded at REST and tool boundaries.
type TableFilterInput = {
// A scalar, a list for the membership operators, a JSON document for `includes`; ignored by
// `is_null` and `is_not_null`.
operand: unknown;
operator: TableFilterOperator;
// The column the filter tests.
target: string;
};
// Supported canonical Feather filter operators.
type TableFilterOperator = "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "is_null" | "is_not_null" | "in" | "not_in" | "contains" | "includes" | "includes_any";
// A table named by its slug or its id; resolution accepts either.
type TableRef = string;
// Query sort direction.
type TableSortDirection = "asc" | "desc";
// A patch to the row its `id` names.
type UpdateRow = {
id: FeatherRowId;
};
// One row to write at its id, or to insert when it names none.
type UpsertRow = {
id?: FeatherRowId | null;
};
// What one upserted row became.
type UpsertedRow = {
// Whether the row was created, rather than overwritten.
inserted: boolean;
row_id: FeatherRowId;
};
verdalia.api.library#
library.get#
One Library item by its id or slug, as the library node's get emits it: a document's
body as markdown on content, and its block tree on blocks when format is json_block.
Throws when the identifier names no item.
get(identifier: string, opts?: {
// `markdown` (the default) renders a document's body as prose on `content`; `json_block`
// also returns its block tree on `blocks`, which keeps what markdown cannot spell.
format?: DocumentFormat;
}): Promise<{
// The document's content, `{ blocks: [...] }`, each block BlockNode JSON with its id; null
// for a folder or file.
blocks?: {
blocks: Array<Record<string, unknown>>;
} | null;
// A document's body as markdown, links resolved to the names of what they point at.
content: string | null;
id: DocId;
kind: LibraryItemKind;
// A file's stored object, when it is still available.
media?: ObjectDescriptor | null;
name: string;
// A file's media object; null for a document or folder.
object_id: DocId | null;
// Parent folder slugs; `[]` is the root and `null` is unfiled.
path: Array<string> | null;
slug: string;
}>
library.list#
The Library from a folder to a depth, or the unfiled items, in the shape library_list
returns: in tree order, each folder followed by what is inside it. Page with cursor.
list(args?: {
// `next_cursor` from the previous page of the same listing.
cursor?: string | null;
// How many levels to list below the folder: a number from 1, 1 being the items directly in
// it, or "all" for every level. One level when omitted.
depth?: ListDepth;
// Only items of this kind; `folder` lists the folders alone.
kind?: LibraryItemKind | null;
// Most items to return: 1 to 200, 50 when omitted.
limit?: number | null;
// The folder to list from, as folder slugs or ids from the root, e.g.
// ['projects-ab12cd', 'q1-x9y8z7']. Omit, or [], for the root.
path?: Array<string> | null;
// true lists the unfiled items, shown in the Library tree as the Other folder. Leave `path`
// out with it.
unfiled?: boolean;
}): Promise<{
has_more: boolean;
// In tree order: within a level folders first, then by name, and each folder followed by
// what is inside it. Each item's `name` is what a person reads; its `slug`, not its name,
// is what a `path` takes.
items: Array<LibraryItem>;
// Where the next page starts; `null` on the last page.
next_cursor: string | null;
// The folder listed from, as its folders' current slugs; `null` for the unfiled items.
path: Array<string> | null;
}>
library.search#
Item names and documents' text searched by words and meaning, in the shape library_search
returns: most relevant first, each with its score.
search(args: {
// Only items of this kind.
kind?: LibraryItemKind | null;
// Most items to return: 1 to 50, 20 when omitted.
limit?: number | null;
// Only files of this media kind.
media_kind?: MediaKind | null;
// What to look for, in words.
query: string;
// true searches only the unfiled items, shown in the Library tree as the Other folder.
unfiled?: boolean;
}): Promise<{
items: Array<LibrarySearchHit>;
}>
Types#
type AiAccessPolicy = {
read: boolean;
write: boolean;
};
// The identifier of a persisted record.
type DocId = string;
// How document content is expressed when it crosses a workflow node boundary.
type DocumentFormat = "json_block" | "markdown";
// The word that asks a listing for every level.
type EveryLevel = "all";
// Where a stored image came from, for the images whose source a consumer acts on.
type ImageOrigin = "screen_capture" | "screen_crop";
// A file item's object id, with what the media components show when the object is readable.
type LibraryFileSummary = {
content_type?: string;
// When a temporary object expires (and its item with it).
delete_after?: string | null;
filename?: string | null;
media_kind?: MediaKind;
object_id: DocId;
properties?: MediaObjectProperties;
size_bytes?: number;
};
// One item as every Library tool, and `verdalia.api.library`, returns it: the Library's wire
// summary (`kind`, `object_id`, `path`, `revision`, ...) and the link a person opens it at.
type LibraryItem = ({
ai_access_policy: AiAccessPolicy;
color: string | null;
created_at: string;
// Set while the item is in the trash.
deleted_at: string | null;
icon: string | null;
id: DocId;
name: string;
// Parent folder slugs; `[]` is the root and `null` is unfiled. A folder rename or move
// rewrites it; address a folder by its ULID for anything that must survive that.
path: Array<string> | null;
// The same path as the folder names a person reads; `null` exactly when `path` is.
path_names: Array<string> | null;
// Incremented by every write; the save, rename, appearance and move requests send it back.
revision: number;
slug: string;
updated_at: string;
// The link a person opens the item at.
url: string;
}) & ({
kind: "document";
} | {
kind: "folder";
} | LibraryFileSummary & {
kind: "file";
});
// What a Library item is: a document with content, a folder, or a file owning one media object.
type LibraryItemKind = "document" | "folder" | "file";
// One search hit: the item and its relevance.
type LibrarySearchHit = ({
ai_access_policy: AiAccessPolicy;
color: string | null;
created_at: string;
// Set while the item is in the trash.
deleted_at: string | null;
icon: string | null;
id: DocId;
name: string;
// Parent folder slugs; `[]` is the root and `null` is unfiled. A folder rename or move
// rewrites it; address a folder by its ULID for anything that must survive that.
path: Array<string> | null;
// The same path as the folder names a person reads; `null` exactly when `path` is.
path_names: Array<string> | null;
// Incremented by every write; the save, rename, appearance and move requests send it back.
revision: number;
// How relevant the item is; higher is more relevant.
score: number;
slug: string;
updated_at: string;
// The link a person opens the item at.
url: string;
}) & ({
kind: "document";
} | {
kind: "folder";
} | LibraryFileSummary & {
kind: "file";
});
// How many levels below its scope a Library listing goes: a number from 1, or `"all"`.
type ListDepth = number | EveryLevel;
type MediaKind = "image" | "pdf" | "file" | "audio" | "video";
type MediaObjectProperties = {
height: number;
// Where the image came from; absent for an image nothing captured from a screen.
origin?: ImageOrigin | null;
type: "image";
width: number;
} | {
page_count: number | null;
type: "pdf";
} | {
artist: string | null;
duration_ms: number | null;
type: "audio";
} | {
duration_ms: number | null;
height: number | null;
type: "video";
width: number | null;
} | {
type: "file";
};
// A stored object as it travels between nodes, transcripts, and the frontend.
type ObjectDescriptor = {
content_type: string;
expires_at?: string | null;
filename: string | null;
kind: ObjectKind;
metadata: ObjectMetadata;
object_id: DocId;
public_url: string | null;
size_bytes: number;
};
// What a stored object is, as far as anything consuming it needs to care.
type ObjectKind = "image" | "video" | "audio" | "pdf" | "file";
// Kind-specific facts about an object, carried only where they apply.
type ObjectMetadata = {
height: number;
// Where the image came from; absent for an image nothing captured from a screen.
origin?: ImageOrigin | null;
type: "image";
width: number;
} | {
duration_ms: number | null;
height: number | null;
type: "video";
width: number | null;
} | {
artist: string | null;
duration_ms: number | null;
type: "audio";
} | {
page_count: number | null;
type: "pdf";
} | {
type: "file";
};
verdalia.api.workspace#
workspace.day#
Reads the current timezone, working day, and calendar hours of the workspace that owns the run.
day(): Promise<{
// The hours the calendar draws, in the workspace's local time.
calendar_window: ClockWindow;
// IANA timezone, such as `Europe/Prague`.
timezone: string;
// The hours work is planned into, in the workspace's local time.
working_day: ClockWindow;
}>
Types#
// A window of local time from `HH:MM` to `HH:MM`; `24:00` is the end of the day.
type ClockWindow = {
// Local end time in `HH:MM`, or `24:00` for the end of the day.
end: string;
// Local start time in `HH:MM`.
start: string;
};
verdalia.api.alpaca#
alpaca.quotes#
The latest quote for each symbol, read in one request. A symbol Alpaca has no quote for is absent from the result.
quotes(args: {
// The id of the Alpaca connection.
connection: DocId;
// `iex` (the default, a single venue) or `sip` (the consolidated tape, which needs
// an Alpaca market data subscription).
feed?: MarketFeed;
// Ticker symbols, for example `["AAPL", "MSFT"]`.
symbols: Array<Symbol>;
}): Promise<Record<string, MarketQuote>>
alpaca.trades#
The latest trade for each symbol, read in one request. A symbol Alpaca has no trade for is absent from the result.
trades(args: {
// The id of the Alpaca connection.
connection: DocId;
// `iex` (the default, a single venue) or `sip` (the consolidated tape, which needs
// an Alpaca market data subscription).
feed?: MarketFeed;
// Ticker symbols, for example `["AAPL", "MSFT"]`.
symbols: Array<Symbol>;
}): Promise<Record<string, MarketTrade>>
alpaca.bars#
Up to lookback OHLC bars for one symbol, newest first and split-adjusted by default.
Requires exactly lookback unless min_bars accepts a shorter series.
bars(args: {
// `split` (the default), `raw`, `dividend` or `all`. `split` and `all` also adjust volume.
adjustment?: BarAdjustment;
// The Alpaca account the connection's key belongs to (`paper` by default).
// The market calendar is read from it when `exclude_forming` is on for `1Day`, `1Week` or `1Month`.
calendar_account?: AlpacaMode;
// The id of the Alpaca connection.
connection: DocId;
// Leave out the current, still-forming bar, so every bar returned is complete.
exclude_forming?: boolean;
// `iex` (the default) or `sip`.
feed?: MarketFeed;
// How many bars to return. Defaults to 30.
lookback?: number;
// Fewest bars accepted. Absent means exactly `lookback`.
min_bars?: number | null;
// Ticker symbol, for example `AAPL`.
symbol: Symbol;
// Length of one bar. Defaults to `1Day`.
timeframe?: Timeframe;
}): Promise<Array<MarketBar>>
alpaca.submitOrder#
Place one real order, with no approval step: {order, deduplicated, resolved}.
submitOrder(args: {
// Protective legs Alpaca holds at the exchange. Defaults to `{"class": "simple"}`.
class?: OrderClass;
// Idempotency key. Absent mints one; a caller that may retry after a crash should
// derive its own from something it knew before calling, so a retry finds the order
// rather than placing a second one.
client_order_id?: ClientOrderId | null;
// The id of the Alpaca connection.
connection: DocId;
// The order type and its prices. Defaults to `{"type": "market"}`.
kind?: OrderKind;
// `paper` (the default) or `live`. A live account trades real money.
mode?: AlpacaMode;
// `regular_hours` (the default) or `extended_hours`.
session?: SessionScope;
// `buy` or `sell`.
side: OrderSide;
// `{"shares": 10}` or `{"notional": 500}`.
size: OrderSize;
// Ticker symbol, for example `SPY`.
symbol: Symbol;
// Defaults to `day`.
time_in_force?: TimeInForce;
// Wait up to this many seconds (1 to 3600) for the order to fill, cancel or expire.
// Absent returns as soon as Alpaca accepts the order.
wait_seconds?: number | null;
}): Promise<{
// True when this submission found an order already standing under its
// `client_order_id`. The position exists either way.
deduplicated: boolean;
order: Order;
// False when the order was still working when the wait ran out, or no wait was
// asked for. The order is then live; reconcile from `order` rather than
// submitting again.
resolved: boolean;
} | {
order: Order;
} | {
orders: Array<Order>;
} | {
// Absent when the account holds nothing in the symbol.
position: Position | null;
} | {
positions: Array<Position>;
} | {
account: Account;
} | {
clock: MarketClock;
} | {
sessions: Array<MarketSession>;
} | {
cancelled: boolean;
} | {
history: PortfolioHistory;
} | {
activities: Array<AccountActivity>;
}>
alpaca.getOrder#
Read one order: {order}.
getOrder(args: {
// The id of the Alpaca connection.
connection: DocId;
// `paper` (the default) or `live`. A live account trades real money.
mode?: AlpacaMode;
// `{"id": "..."}` for Alpaca's id, or `{"client_order_id": "..."}`.
order: OrderRef;
}): Promise<{
// True when this submission found an order already standing under its
// `client_order_id`. The position exists either way.
deduplicated: boolean;
order: Order;
// False when the order was still working when the wait ran out, or no wait was
// asked for. The order is then live; reconcile from `order` rather than
// submitting again.
resolved: boolean;
} | {
order: Order;
} | {
orders: Array<Order>;
} | {
// Absent when the account holds nothing in the symbol.
position: Position | null;
} | {
positions: Array<Position>;
} | {
account: Account;
} | {
clock: MarketClock;
} | {
sessions: Array<MarketSession>;
} | {
cancelled: boolean;
} | {
history: PortfolioHistory;
} | {
activities: Array<AccountActivity>;
}>
alpaca.listOrders#
List orders: {orders}.
listOrders(args: {
// The id of the Alpaca connection.
connection: DocId;
direction?: SortDirection;
// Most orders to return; Alpaca's own default is 50 and its ceiling 500.
limit?: number | null;
// `paper` (the default) or `live`. A live account trades real money.
mode?: AlpacaMode;
// `open` (the default), `closed` or `all`.
status?: OrderStatusFilter;
// Only orders in these symbols. Empty lists every symbol.
symbols?: Array<Symbol>;
}): Promise<{
// True when this submission found an order already standing under its
// `client_order_id`. The position exists either way.
deduplicated: boolean;
order: Order;
// False when the order was still working when the wait ran out, or no wait was
// asked for. The order is then live; reconcile from `order` rather than
// submitting again.
resolved: boolean;
} | {
order: Order;
} | {
orders: Array<Order>;
} | {
// Absent when the account holds nothing in the symbol.
position: Position | null;
} | {
positions: Array<Position>;
} | {
account: Account;
} | {
clock: MarketClock;
} | {
sessions: Array<MarketSession>;
} | {
cancelled: boolean;
} | {
history: PortfolioHistory;
} | {
activities: Array<AccountActivity>;
}>
alpaca.replaceOrder#
Amend a resting order, with no approval step: {order}.
replaceOrder(args: {
// The attributes to change. One left out stays as it is.
change: OrderChange;
// The id of the Alpaca connection.
connection: DocId;
// `paper` (the default) or `live`. A live account trades real money.
mode?: AlpacaMode;
order_id: AlpacaOrderId;
}): Promise<{
// True when this submission found an order already standing under its
// `client_order_id`. The position exists either way.
deduplicated: boolean;
order: Order;
// False when the order was still working when the wait ran out, or no wait was
// asked for. The order is then live; reconcile from `order` rather than
// submitting again.
resolved: boolean;
} | {
order: Order;
} | {
orders: Array<Order>;
} | {
// Absent when the account holds nothing in the symbol.
position: Position | null;
} | {
positions: Array<Position>;
} | {
account: Account;
} | {
clock: MarketClock;
} | {
sessions: Array<MarketSession>;
} | {
cancelled: boolean;
} | {
history: PortfolioHistory;
} | {
activities: Array<AccountActivity>;
}>
alpaca.cancelOrder#
Cancel a resting order: {cancelled}.
cancelOrder(args: {
// The id of the Alpaca connection.
connection: DocId;
// `paper` (the default) or `live`. A live account trades real money.
mode?: AlpacaMode;
order_id: AlpacaOrderId;
}): Promise<{
// True when this submission found an order already standing under its
// `client_order_id`. The position exists either way.
deduplicated: boolean;
order: Order;
// False when the order was still working when the wait ran out, or no wait was
// asked for. The order is then live; reconcile from `order` rather than
// submitting again.
resolved: boolean;
} | {
order: Order;
} | {
orders: Array<Order>;
} | {
// Absent when the account holds nothing in the symbol.
position: Position | null;
} | {
positions: Array<Position>;
} | {
account: Account;
} | {
clock: MarketClock;
} | {
sessions: Array<MarketSession>;
} | {
cancelled: boolean;
} | {
history: PortfolioHistory;
} | {
activities: Array<AccountActivity>;
}>
alpaca.getPosition#
The open position in one symbol: {position}, null when the account holds none.
getPosition(args: {
// The id of the Alpaca connection.
connection: DocId;
// `paper` (the default) or `live`. A live account trades real money.
mode?: AlpacaMode;
symbol: Symbol;
}): Promise<{
// True when this submission found an order already standing under its
// `client_order_id`. The position exists either way.
deduplicated: boolean;
order: Order;
// False when the order was still working when the wait ran out, or no wait was
// asked for. The order is then live; reconcile from `order` rather than
// submitting again.
resolved: boolean;
} | {
order: Order;
} | {
orders: Array<Order>;
} | {
// Absent when the account holds nothing in the symbol.
position: Position | null;
} | {
positions: Array<Position>;
} | {
account: Account;
} | {
clock: MarketClock;
} | {
sessions: Array<MarketSession>;
} | {
cancelled: boolean;
} | {
history: PortfolioHistory;
} | {
activities: Array<AccountActivity>;
}>
alpaca.listPositions#
Every open position: {positions}.
listPositions(args: {
// The id of the Alpaca connection.
connection: DocId;
// `paper` (the default) or `live`. A live account trades real money.
mode?: AlpacaMode;
}): Promise<{
// True when this submission found an order already standing under its
// `client_order_id`. The position exists either way.
deduplicated: boolean;
order: Order;
// False when the order was still working when the wait ran out, or no wait was
// asked for. The order is then live; reconcile from `order` rather than
// submitting again.
resolved: boolean;
} | {
order: Order;
} | {
orders: Array<Order>;
} | {
// Absent when the account holds nothing in the symbol.
position: Position | null;
} | {
positions: Array<Position>;
} | {
account: Account;
} | {
clock: MarketClock;
} | {
sessions: Array<MarketSession>;
} | {
cancelled: boolean;
} | {
history: PortfolioHistory;
} | {
activities: Array<AccountActivity>;
}>
alpaca.closePosition#
Liquidate a position, with no approval step: {order}.
closePosition(args: {
// `"entire"` (the default), `{"shares": 5}` or `{"percent": 50}`.
amount?: ClosePositionAmount;
// The id of the Alpaca connection.
connection: DocId;
// `paper` (the default) or `live`. A live account trades real money.
mode?: AlpacaMode;
symbol: Symbol;
}): Promise<{
// True when this submission found an order already standing under its
// `client_order_id`. The position exists either way.
deduplicated: boolean;
order: Order;
// False when the order was still working when the wait ran out, or no wait was
// asked for. The order is then live; reconcile from `order` rather than
// submitting again.
resolved: boolean;
} | {
order: Order;
} | {
orders: Array<Order>;
} | {
// Absent when the account holds nothing in the symbol.
position: Position | null;
} | {
positions: Array<Position>;
} | {
account: Account;
} | {
clock: MarketClock;
} | {
sessions: Array<MarketSession>;
} | {
cancelled: boolean;
} | {
history: PortfolioHistory;
} | {
activities: Array<AccountActivity>;
}>
alpaca.getAccount#
The account's balances and status: {account}.
getAccount(args: {
// The id of the Alpaca connection.
connection: DocId;
// `paper` (the default) or `live`. A live account trades real money.
mode?: AlpacaMode;
}): Promise<{
// True when this submission found an order already standing under its
// `client_order_id`. The position exists either way.
deduplicated: boolean;
order: Order;
// False when the order was still working when the wait ran out, or no wait was
// asked for. The order is then live; reconcile from `order` rather than
// submitting again.
resolved: boolean;
} | {
order: Order;
} | {
orders: Array<Order>;
} | {
// Absent when the account holds nothing in the symbol.
position: Position | null;
} | {
positions: Array<Position>;
} | {
account: Account;
} | {
clock: MarketClock;
} | {
sessions: Array<MarketSession>;
} | {
cancelled: boolean;
} | {
history: PortfolioHistory;
} | {
activities: Array<AccountActivity>;
}>
alpaca.getClock#
Whether the market is open, and its next open and close: {clock}.
getClock(args: {
// The id of the Alpaca connection.
connection: DocId;
// `paper` (the default) or `live`. A live account trades real money.
mode?: AlpacaMode;
}): Promise<{
// True when this submission found an order already standing under its
// `client_order_id`. The position exists either way.
deduplicated: boolean;
order: Order;
// False when the order was still working when the wait ran out, or no wait was
// asked for. The order is then live; reconcile from `order` rather than
// submitting again.
resolved: boolean;
} | {
order: Order;
} | {
orders: Array<Order>;
} | {
// Absent when the account holds nothing in the symbol.
position: Position | null;
} | {
positions: Array<Position>;
} | {
account: Account;
} | {
clock: MarketClock;
} | {
sessions: Array<MarketSession>;
} | {
cancelled: boolean;
} | {
history: PortfolioHistory;
} | {
activities: Array<AccountActivity>;
}>
alpaca.getCalendar#
The trading sessions in a range of days: {sessions}.
getCalendar(args: {
// The id of the Alpaca connection.
connection: DocId;
end: string;
// `paper` (the default) or `live`. A live account trades real money.
mode?: AlpacaMode;
start: string;
}): Promise<{
// True when this submission found an order already standing under its
// `client_order_id`. The position exists either way.
deduplicated: boolean;
order: Order;
// False when the order was still working when the wait ran out, or no wait was
// asked for. The order is then live; reconcile from `order` rather than
// submitting again.
resolved: boolean;
} | {
order: Order;
} | {
orders: Array<Order>;
} | {
// Absent when the account holds nothing in the symbol.
position: Position | null;
} | {
positions: Array<Position>;
} | {
account: Account;
} | {
clock: MarketClock;
} | {
sessions: Array<MarketSession>;
} | {
cancelled: boolean;
} | {
history: PortfolioHistory;
} | {
activities: Array<AccountActivity>;
}>
alpaca.getPortfolioHistory#
The account's value over time: {history}.
getPortfolioHistory(args: {
// The id of the Alpaca connection.
connection: DocId;
intraday_reporting?: IntradayReporting;
// `paper` (the default) or `live`. A live account trades real money.
mode?: AlpacaMode;
// Absent lets Alpaca choose, which is the only safe choice for a long period:
// it accepts nothing below `1D` beyond 30 days.
timeframe?: PortfolioTimeframe | null;
window?: PortfolioWindow;
}): Promise<{
// True when this submission found an order already standing under its
// `client_order_id`. The position exists either way.
deduplicated: boolean;
order: Order;
// False when the order was still working when the wait ran out, or no wait was
// asked for. The order is then live; reconcile from `order` rather than
// submitting again.
resolved: boolean;
} | {
order: Order;
} | {
orders: Array<Order>;
} | {
// Absent when the account holds nothing in the symbol.
position: Position | null;
} | {
positions: Array<Position>;
} | {
account: Account;
} | {
clock: MarketClock;
} | {
sessions: Array<MarketSession>;
} | {
cancelled: boolean;
} | {
history: PortfolioHistory;
} | {
activities: Array<AccountActivity>;
}>
alpaca.listAccountActivities#
The account's ledger entries: {activities}.
listAccountActivities(args: {
// `YYYY-MM-DD` or RFC3339, passed through as written; Alpaca accepts both.
after?: string | null;
// The id of the Alpaca connection.
connection: DocId;
direction?: SortDirection;
// `paper` (the default) or `live`. A live account trades real money.
mode?: AlpacaMode;
page_size?: number | null;
// The id of the last entry on the previous page.
page_token?: string | null;
// Alpaca activity types. Empty means every type.
types?: Array<string>;
until?: string | null;
}): Promise<{
// True when this submission found an order already standing under its
// `client_order_id`. The position exists either way.
deduplicated: boolean;
order: Order;
// False when the order was still working when the wait ran out, or no wait was
// asked for. The order is then live; reconcile from `order` rather than
// submitting again.
resolved: boolean;
} | {
order: Order;
} | {
orders: Array<Order>;
} | {
// Absent when the account holds nothing in the symbol.
position: Position | null;
} | {
positions: Array<Position>;
} | {
account: Account;
} | {
clock: MarketClock;
} | {
sessions: Array<MarketSession>;
} | {
cancelled: boolean;
} | {
history: PortfolioHistory;
} | {
activities: Array<AccountActivity>;
}>
Types#
// The trading account behind a connection.
type Account = {
account_blocked: boolean;
account_number: string;
accrued_fees: string | null;
buying_power: string;
cash: string;
created_at: string | null;
currency: string;
daytrade_count: number | null;
daytrading_buying_power: string | null;
equity: string;
initial_margin: string | null;
last_equity: string | null;
long_market_value: string | null;
maintenance_margin: string | null;
multiplier: string | null;
non_marginable_buying_power: string | null;
pattern_day_trader: boolean;
portfolio_value: string | null;
regt_buying_power: string | null;
short_market_value: string | null;
shorting_enabled: boolean;
sma: string | null;
status: string;
trading_blocked: boolean;
transfers_blocked: boolean;
};
// One entry in Alpaca's own account ledger.
type AccountActivity = {
activity_sub_type: string | null;
activity_type: string;
cum_qty: string | null;
cusip: string | null;
date: string | null;
description: string | null;
group_id: string | null;
id: string;
leaves_qty: string | null;
net_amount: string | null;
order_id: AlpacaOrderId | null;
order_status: string | null;
per_share_amount: string | null;
price: string | null;
qty: string | null;
side: string | null;
status: string | null;
// A plain string: option contract symbols such as `AAPL240119C00150000` appear
// here, and [`Symbol`] would reject them and fail the whole read.
symbol: string | null;
transaction_time: string | null;
type: string | null;
};
// Which Alpaca trading environment an operation acts on.
type AlpacaMode = "paper" | "live";
// Alpaca's own identifier for an order.
type AlpacaOrderId = string;
// How Alpaca adjusts historical bars for corporate actions.
// `split` is the default: a series that crosses a split unadjusted shows a 2:1 or 10:1 gap no
// trade made, and every average, cross and range computed over it is wrong.
type BarAdjustment = "raw" | "split" | "dividend" | "all";
// A caller-chosen idempotency key for one order.
type ClientOrderId = string;
// How much of a position to close.
type ClosePositionAmount = "entire" | {
shares: string | number;
} | {
percent: string | number;
};
// The identifier of a persisted record.
type DocId = string;
// Which part of the session the intraday points cover.
type IntradayReporting = "market_hours" | "extended_hours" | "continuous";
// OHLC bar for historical price data.
type MarketBar = {
close: string;
high: string;
low: string;
open: string;
timestamp: string;
volume: number;
// Volume Weighted Average Price, when the provider reports one.
vwap: string | null;
};
// Whether the market is open now, and when it next changes.
type MarketClock = {
is_open: boolean;
next_close: string;
next_open: string;
timestamp: string;
};
// Which Alpaca data feed a request draws on.
type MarketFeed = "iex" | "sip";
// Market quote with bid/ask spread.
type MarketQuote = {
ask: string | null;
ask_size: number;
bid: string | null;
bid_size: number;
symbol: Symbol;
timestamp: string;
};
// One trading session, with the hours that session actually keeps.
type MarketSession = {
close: string;
date: string;
open: string;
};
// Latest eligible executed trade, distinct from a quote or bar close.
type MarketTrade = {
price: string;
size: number;
symbol: Symbol;
timestamp: string;
};
// One order as Alpaca reports it.
type Order = {
canceled_at: string | null;
client_order_id: ClientOrderId;
expired_at: string | null;
extended_hours: boolean;
filled_at: string | null;
filled_avg_price: string | null;
filled_qty: string | null;
id: AlpacaOrderId;
// Child orders of a protected entry.
legs?: Array<Order> | null;
limit_price: string | null;
notional: string | null;
order_class: OrderClassName;
qty: string | null;
side: OrderSide;
status: OrderStatus;
stop_price: string | null;
submitted_at: string | null;
symbol: Symbol;
time_in_force: TimeInForce;
trail_percent: string | null;
trail_price: string | null;
type: OrderType;
updated_at: string | null;
};
// A change to a resting order.
type OrderChange = {
limit_price?: string | number | null;
qty?: string | number | null;
stop_price?: string | number | null;
time_in_force?: TimeInForce | null;
// The new trail amount of a trailing stop.
trail?: string | number | null;
};
// What protective orders accompany the entry, and who holds them.
type OrderClass = {
class: "simple";
} | {
class: "bracket";
stop_loss: StopLoss;
take_profit: TakeProfit;
} | {
class: "oco";
stop_loss: StopLoss;
take_profit: TakeProfit;
} | {
class: "oto";
leg: ProtectiveLeg;
};
// The flat `order_class` Alpaca reports an order under.
type OrderClassName = "bracket" | "oco" | "oto" | "mleg" | "simple";
// An order type together with the prices that type requires.
type OrderKind = {
type: "market";
} | {
limit_price: string | number;
type: "limit";
} | {
stop_price: string | number;
type: "stop";
} | {
limit_price: string | number;
stop_price: string | number;
type: "stop_limit";
} | {
trail: Trail;
type: "trailing_stop";
};
// How to name an order when asking Alpaca about it.
type OrderRef = {
id: AlpacaOrderId;
} | {
client_order_id: ClientOrderId;
};
// Which way an order trades.
type OrderSide = "buy" | "sell";
// How much to trade, in shares or in dollars.
type OrderSize = {
shares: string | number;
} | {
notional: string | number;
};
// Where an order stands in its lifecycle.
type OrderStatus = "new" | "partially_filled" | "filled" | "done_for_day" | "canceled" | "expired" | "replaced" | "pending_cancel" | "pending_replace" | "accepted" | "pending_new" | "accepted_for_bidding" | "stopped" | "rejected" | "suspended" | "calculated" | "held" | "unknown";
// Which orders to list.
type OrderStatusFilter = "open" | "closed" | "all";
// The flat `type` Alpaca reports an order under.
type OrderType = "market" | "limit" | "stop" | "stop_limit" | "trailing_stop";
// The account's equity and profit/loss over time, as Alpaca reports it.
type PortfolioHistory = {
base_value: string | null;
base_value_asof: string | null;
points: Array<PortfolioPoint>;
// The resolution Alpaca actually used, which it chooses when none was asked for.
timeframe: string;
};
// One sample of the account's value.
type PortfolioPoint = {
equity: string | null;
profit_loss: string | null;
profit_loss_pct: string | null;
timestamp: string;
};
// The resolution of one portfolio history point.
type PortfolioTimeframe = "1Min" | "5Min" | "15Min" | "1H" | "1D";
// Which slice of the account's history to report.
type PortfolioWindow = {
period?: string | null;
window: "period";
} | {
end: string;
start: string;
window: "range";
};
// One open position.
type Position = {
avg_entry_price: string;
change_today: string | null;
cost_basis: string | null;
current_price: string | null;
lastday_price: string | null;
market_value: string | null;
qty: string;
// Shares not already committed to a resting order.
qty_available: string | null;
side: PositionSide;
symbol: Symbol;
unrealized_pl: string | null;
unrealized_plpc: string | null;
};
// Which way a position is held.
type PositionSide = "long" | "short";
// The single follow-on leg of a one-triggers-other order.
type ProtectiveLeg = {
take_profit: TakeProfit;
} | {
stop_loss: StopLoss;
};
// Whether an order may execute outside regular market hours.
type SessionScope = "regular_hours" | "extended_hours";
// Newest-first or oldest-first.
type SortDirection = "asc" | "desc";
// The protective leg of a protected order.
type StopLoss = {
stop_price: string | number;
type: "market";
} | {
limit_price: string | number;
stop_price: string | number;
type: "limit";
};
// A ticker symbol, uppercased and safe to place in a request path.
type Symbol = string;
// The profit-taking leg of a protected order.
type TakeProfit = {
limit_price: string | number;
};
// How long an order rests before it expires.
type TimeInForce = "day" | "gtc" | "opg" | "cls" | "ioc" | "fok";
// Timeframe for OHLC bars.
type Timeframe = "1Min" | "5Min" | "15Min" | "1Hour" | "1Day" | "1Week" | "1Month";
// How a trailing stop follows the price. Written `{"percent": 2}` or `{"price": 1.5}`.
type Trail = {
percent: string | number;
} | {
price: string | number;
};
verdalia.api.polygon#
polygon.quote#
The latest quote for one ticker, falling back to the previous close when Polygon has no live book or last trade.
quote(args: {
// The id of the Polygon connection.
connection: DocId;
// Polygon ticker, for example `AAPL`, or `X:BTCUSD` for a crypto pair.
ticker: PolygonTicker;
}): Promise<{
ask: string;
bid: string;
last: string;
ticker: string;
timestamp: string;
volume: number;
}>
polygon.bars#
Up to lookback OHLC bars for one ticker, newest first.
bars(args: {
// The id of the Polygon connection.
connection: DocId;
// `1m`, `5m`, `15m`, `1h` or `1d` (the default).
interval?: Interval;
// Most bars to return. Defaults to 30.
lookback?: number;
// Polygon ticker, for example `AAPL`.
ticker: PolygonTicker;
}): Promise<Array<MarketBar>>
Types#
// The identifier of a persisted record.
type DocId = string;
// Interval types for OHLC data
type Interval = "1m" | "5m" | "15m" | "1h" | "1d";
// OHLC bar for historical price data.
type MarketBar = {
close: string;
high: string;
low: string;
open: string;
timestamp: string;
volume: number;
// Volume Weighted Average Price, when the provider reports one.
vwap: string | null;
};
// A Polygon ticker: trimmed and never empty.
type PolygonTicker = string;
verdalia.api.indicators#
indicators.compute#
Indicators to compute over one series of bars.
compute(args: {
// OHLC bars, newest first, as Alpaca and Polygon return them.
bars: Array<MarketBar>;
// Each indicator with the name its value is keyed by in the result, for example
// `{"name": "rsi", "type": "relative_strength_index", "period": 14}`.
indicators: Array<NamedIndicator>;
// `latest` (the default) gives each indicator's newest value; `series` gives one
// value per bar, aligned with `bars`, null where none is defined.
output_mode?: IndicatorOutputMode;
}): Promise<Record<string, IndicatorOutput>>
Types#
// Complete ADX observation; directional indices share the same smoothed range.
type AdxResult = {
adx: number;
minus_di: number;
plus_di: number;
};
// Wilder trend strength and directional movement over newest-first bars.
type AverageDirectionalIndex = {
period?: number;
};
// Executable ATR configuration for newest-first market bars.
type AverageTrueRange = {
period: number;
};
// A bar in this exact supplied snapshot; indices shift when newer bars are prepended.
type BarReference = {
index: number;
timestamp: string;
};
// Population-deviation bands over the current and preceding close prices.
type BollingerBands = {
period?: number;
standard_deviations?: string | number;
};
// Exact SMA and price bands, with unavailable zero-denominator ratios explicit.
type BollingerBandsResult = {
bandwidth: number | null;
lower: string;
middle: string;
percent_b: number | null;
upper: string;
};
// Whether a strict level crossing requires the close or only the corresponding wick.
type BreakConfirmation = "close" | "wick";
// A strict pivot's source bar and the later bar on which it became known.
type ConfirmedSwing = {
confirmed_at: BarReference;
kind: SwingKind;
origin: BarReference;
price: string;
};
// Strict pivots published only after their complete right-hand confirmation span.
type ConfirmedSwings = {
left_span?: number;
right_span?: number;
};
// Cross signal (golden/death cross).
type CrossSignal = {
strength: CrossStrength;
type: "golden";
} | {
strength: CrossStrength;
type: "death";
} | {
type: "none";
};
// How far apart the two averages are.
type CrossStrength = "strong" | "weak";
// Price channel over the preceding complete window, excluding the current bar.
type DonchianChannels = {
period?: number;
};
// Prior-window bounds, midpoint, and absolute price range.
type DonchianChannelsResult = {
lower: string;
middle: string;
range: string;
upper: string;
};
// Executable EMA Deviation configuration for newest-first market bars.
type EmaDeviation = {
period: number;
};
// Executable EMA configuration for newest-first market bars.
type ExponentialMovingAverage = {
period: number;
};
// Fixed gap bounds and the three bars that established them in this input snapshot.
type FairValueGap = {
direction: PriceDirection;
formed_at: BarReference;
lower: string;
middle: BarReference;
start: BarReference;
upper: string;
};
// Three-bar fair value gaps and their causal first-touch/full-fill events.
type FairValueGaps = {
require_direction?: boolean;
};
// Fibonacci retracement levels
type FibonacciLevels = {
high: string;
level_0: string;
level_100: string;
level_236: string;
level_382: string;
level_500: string;
level_618: string;
level_786: string;
low: string;
};
// Executable Fibonacci configuration for newest-first market bars.
type FibonacciRetracement = Record<string, unknown>;
// An immutable gap creation or a subsequent wick-based lifecycle transition.
type FvgEvent = {
gap: FairValueGap;
type: "created";
} | {
at: BarReference;
gap_formed_at: BarReference;
type: "touched";
} | {
at: BarReference;
gap_formed_at: BarReference;
type: "filled";
};
// Events known on one bar; an empty list is a computed, quiet observation.
type FvgEvents = {
events: Array<FvgEvent>;
};
// Executable Golden Cross configuration for newest-first market bars.
type GoldenCross = {
long_period: number;
short_period: number;
};
// The name a user gave one configured indicator.
type IndicatorName = string;
// One indicator's result.
type IndicatorOutput = IndicatorValue | Array<IndicatorValue | null>;
// Evaluate the newest bar or every supplied bar, without retaining streaming state.
type IndicatorOutputMode = "latest" | "series";
// The value one indicator produced.
type IndicatorValue = string | number | MacdResult | StochasticResult | FibonacciLevels | CrossSignal | FvgEvents | AdxResult | BollingerBandsResult | DonchianChannelsResult | SwingEvents | MarketStructureReading | StructureBreakEvents | ZoneEvents;
// How the latest confirmed level compares with the preceding level of its kind.
type LevelChange = "higher" | "lower" | "equal";
// Executable MACD configuration for newest-first market bars.
type Macd = {
fast: number;
signal: number;
slow: number;
};
// Which side of the signal line the MACD histogram is on.
type MacdLevel = "bullish" | "bearish";
// MACD result
type MacdResult = {
histogram: number;
macd_level: MacdLevel;
macd_line: number;
signal_line: number;
};
// OHLC bar for historical price data.
type MarketBar = {
close: string | number;
high: string | number;
low: string | number;
open: string | number;
timestamp: string;
volume: number;
// Volume Weighted Average Price, when the provider reports one.
vwap?: string | number | null;
};
// Causal trend readings from independently confirmed high and low swings.
type MarketStructure = {
left_span?: number;
right_span?: number;
};
// Confirmed structure known on one bar, without any price-break regime override.
type MarketStructureReading = {
high_change: LevelChange | null;
last_high: ConfirmedSwing | null;
last_low: ConfirmedSwing | null;
low_change: LevelChange | null;
trend: MarketTrend;
};
// Agreement between consecutive confirmed highs and consecutive confirmed lows.
type MarketTrend = "undetermined" | "bullish" | "bearish" | "mixed";
// One configured indicator and the name its result will carry.
type NamedIndicator = {
name: IndicatorName;
} & (SimpleMovingAverage & {
type: "simple_moving_average";
} | ExponentialMovingAverage & {
type: "exponential_moving_average";
} | RelativeStrengthIndex & {
type: "relative_strength_index";
} | Macd & {
type: "macd";
} | AverageTrueRange & {
type: "average_true_range";
} | StochasticOscillator & {
type: "stochastic_oscillator";
} | FibonacciRetracement & {
type: "fibonacci_retracement";
} | VolumeWeightedAveragePrice & {
type: "volume_weighted_average_price";
} | GoldenCross & {
type: "golden_cross";
} | EmaDeviation & {
type: "ema_deviation";
} | WeightedPriceMovement & {
type: "weighted_price_movement";
} | FairValueGaps & {
type: "fair_value_gaps";
} | AverageDirectionalIndex & {
type: "average_directional_index";
} | BollingerBands & {
type: "bollinger_bands";
} | DonchianChannels & {
type: "donchian_channels";
} | RelativeVolume & {
type: "relative_volume";
} | ConfirmedSwings & {
type: "confirmed_swings";
} | MarketStructure & {
type: "market_structure";
} | StructureBreaks & {
type: "structure_breaks";
} | SupportResistanceZones & {
type: "support_resistance_zones";
});
// The price direction of a gap or structure break.
type PriceDirection = "bullish" | "bearish";
// Executable RSI configuration for newest-first market bars.
type RelativeStrengthIndex = {
period: number;
};
// Current volume divided by the mean of the preceding complete volume window.
type RelativeVolume = {
period?: number;
};
// Executable SMA configuration for newest-first market bars.
type SimpleMovingAverage = {
period: number;
};
// Where a stochastic reading sits in its range.
type StochasticLevel = "overbought" | "oversold" | "neutral";
// Executable Stochastic configuration for newest-first market bars.
type StochasticOscillator = {
d_period: number;
k_period: number;
};
// Stochastic oscillator result
type StochasticResult = {
d: number;
k: number;
level: StochasticLevel;
};
// The crossed level and its prior confirmation, published on the breaking bar only.
type StructureBreak = {
at: BarReference;
direction: PriceDirection;
kind: StructureBreakKind;
level: string;
swing: ConfirmedSwing;
};
// Breaks on one bar; bullish precedes bearish without claiming intrabar chronology.
type StructureBreakEvents = {
events: Array<StructureBreak>;
};
// A break's relationship to the established pre-bar trend, if one exists.
type StructureBreakKind = "unclassified" | "break_of_structure" | "change_of_character";
// One-shot breaks of confirmed levels, classified with structure known before the bar.
type StructureBreaks = {
confirmation?: BreakConfirmation;
left_span?: number;
right_span?: number;
};
// Immutable activation payload retaining the original bounds and activating pivot.
type SupportResistanceZone = {
confirmed_at: BarReference;
id: ZoneId;
last_touch: ConfirmedSwing;
lower: string;
touches: number;
upper: string;
};
// Fixed price bands activated by repeated confirmed same-side swing touches.
type SupportResistanceZones = {
left_span?: number;
min_touches?: number;
right_span?: number;
tolerance_percent?: string | number;
};
// Confirmations on one bar, ordered High then Low when both sides qualify.
type SwingEvents = {
events: Array<ConfirmedSwing>;
};
// The price extreme established by a confirmed pivot.
type SwingKind = "high" | "low";
// Executable VWAP configuration for newest-first market bars.
type VolumeWeightedAveragePrice = Record<string, unknown>;
// Executable WPM configuration for newest-first market bars.
type WeightedPriceMovement = {
period: number;
};
// A zone activation, subsequent confirmed pivot touch, or strict closing-price break.
type ZoneEvent = {
type: "created";
zone: SupportResistanceZone;
} | {
pivot: ConfirmedSwing;
touches: number;
type: "touched";
zone_id: ZoneId;
} | {
at: BarReference;
close: string;
type: "broken";
zone_id: ZoneId;
};
// Events on one bar, with prior-zone breaks before High then Low confirmations.
type ZoneEvents = {
events: Array<ZoneEvent>;
};
// Snapshot-local identity supplied by a zone's first pivot, not its activation bar.
type ZoneId = {
kind: ZoneKind;
origin: BarReference;
};
// The side of price defended by a cluster of confirmed pivots.
type ZoneKind = "support" | "resistance";
verdalia.api.gmail#
gmail.list_emails#
List and search messages.
list_emails(args: {
// The id of the Google connection.
connection: DocId;
// Only messages carrying every one of these label ids.
label_ids?: Array<string>;
// Most messages to return, 1-500.
max_results?: number | null;
// The `nextPageToken` of the previous page, to continue from it.
page_token?: string | null;
// A Gmail search query, as typed in Gmail's search box, such as `from:ana is:unread`.
query?: string | null;
}): Promise<{
// The messages on this page; absent, as Gmail sends it, when the page is empty.
messages?: Array<GmailMessage>;
// The token for the next page, when there is one.
nextPageToken?: string | null;
// Gmail's estimate of the total number of results.
resultSizeEstimate?: number | null;
}>
gmail.get_email#
Get one message.
get_email(args: {
// The id of the Google connection.
connection: DocId;
// The message id, from a listing or a trigger's `message_id`.
email_id: string;
// How much of the message to return; `full` when omitted.
format?: GmailMessageFormat;
}): Promise<{
// The id of the last history record that modified the message.
historyId?: string | null;
// The message id.
id: string;
// When Gmail received the message, in milliseconds since the epoch, as text.
internalDate?: string | null;
// The ids of the labels on the message, system labels such as `INBOX` and `UNREAD` included.
labelIds?: Array<string>;
// The parsed MIME structure, for the `full` and `metadata` formats.
payload?: GmailMessagePart | null;
// The whole RFC 2822 message as base64url text, for the `raw` format.
raw?: string | null;
// The estimated size of the message in bytes.
sizeEstimate?: number | null;
// A short part of the message text.
snippet?: string | null;
// The id of the thread the message belongs to.
threadId?: string | null;
}>
gmail.list_threads#
List and search threads.
list_threads(args: {
// The id of the Google connection.
connection: DocId;
// Only threads carrying every one of these label ids.
label_ids?: Array<string>;
// Most threads to return, 1-500.
max_results?: number | null;
// The `nextPageToken` of the previous page, to continue from it.
page_token?: string | null;
// A Gmail search query, as typed in Gmail's search box.
query?: string | null;
}): Promise<{
// The token for the next page, when there is one.
nextPageToken?: string | null;
// Gmail's estimate of the total number of results.
resultSizeEstimate?: number | null;
// The threads on this page.
threads: Array<GmailThread>;
}>
gmail.get_thread#
Get one thread and its messages.
get_thread(args: {
// The id of the Google connection.
connection: DocId;
// How much of each message to return; `full` when omitted.
format?: GmailMessageFormat;
// The thread id.
thread_id: string;
}): Promise<{
// The id of the last history record that modified the thread.
historyId?: string | null;
// The thread id.
id: string;
// The thread's messages, oldest first.
messages?: Array<GmailMessage>;
// A short part of the thread's text.
snippet?: string | null;
}>
gmail.send_email#
Send a new message.
send_email(args: {
// Files to attach.
attachments?: Array<GmailAttachment>;
// An HTML body, sent beside the plain text.
body_html?: string;
// The plain-text body.
body_text?: string;
// The id of the Google connection.
connection: DocId;
// An accepted send-as alias to send from; the account's default sender when omitted.
from_email?: string | null;
// A display name for the sender.
from_name?: string | null;
// The subject.
subject: string;
// The recipients' addresses.
to: Array<string>;
}): Promise<{
// The id of the last history record that modified the message.
historyId?: string | null;
// The message id.
id: string;
// When Gmail received the message, in milliseconds since the epoch, as text.
internalDate?: string | null;
// The ids of the labels on the message, system labels such as `INBOX` and `UNREAD` included.
labelIds?: Array<string>;
// The parsed MIME structure, for the `full` and `metadata` formats.
payload?: GmailMessagePart | null;
// The whole RFC 2822 message as base64url text, for the `raw` format.
raw?: string | null;
// The estimated size of the message in bytes.
sizeEstimate?: number | null;
// A short part of the message text.
snippet?: string | null;
// The id of the thread the message belongs to.
threadId?: string | null;
}>
gmail.reply_to_email#
Reply to a message in its thread, to its Reply-To or else its From.
reply_to_email(args: {
// Files to attach.
attachments?: Array<GmailAttachment>;
// An HTML body, sent beside the plain text.
body_html?: string;
// The plain-text body.
body_text?: string;
// The id of the Google connection.
connection: DocId;
// The id of the message to reply to. Its recipient, subject and thread are inherited;
// replying needs Gmail read and send permission.
email_id: string;
// An accepted send-as alias to send from; the account's default sender when omitted.
from_email?: string | null;
// A display name for the sender.
from_name?: string | null;
}): Promise<{
// The id of the last history record that modified the message.
historyId?: string | null;
// The message id.
id: string;
// When Gmail received the message, in milliseconds since the epoch, as text.
internalDate?: string | null;
// The ids of the labels on the message, system labels such as `INBOX` and `UNREAD` included.
labelIds?: Array<string>;
// The parsed MIME structure, for the `full` and `metadata` formats.
payload?: GmailMessagePart | null;
// The whole RFC 2822 message as base64url text, for the `raw` format.
raw?: string | null;
// The estimated size of the message in bytes.
sizeEstimate?: number | null;
// A short part of the message text.
snippet?: string | null;
// The id of the thread the message belongs to.
threadId?: string | null;
}>
gmail.forward_email#
Forward a message: a new message to new recipients, carrying the original as an attached
message under its subject with Fwd: before it.
forward_email(args: {
// Further files to attach beside the forwarded message.
attachments?: Array<GmailAttachment>;
// An HTML note, sent beside the plain text.
body_html?: string;
// A plain-text note above the forwarded message.
body_text?: string;
// The id of the Google connection.
connection: DocId;
// The id of the message to forward.
email_id: string;
// An accepted send-as alias to send from; the account's default sender when omitted.
from_email?: string | null;
// A display name for the sender.
from_name?: string | null;
// The recipients' addresses.
to: Array<string>;
}): Promise<{
// The id of the last history record that modified the message.
historyId?: string | null;
// The message id.
id: string;
// When Gmail received the message, in milliseconds since the epoch, as text.
internalDate?: string | null;
// The ids of the labels on the message, system labels such as `INBOX` and `UNREAD` included.
labelIds?: Array<string>;
// The parsed MIME structure, for the `full` and `metadata` formats.
payload?: GmailMessagePart | null;
// The whole RFC 2822 message as base64url text, for the `raw` format.
raw?: string | null;
// The estimated size of the message in bytes.
sizeEstimate?: number | null;
// A short part of the message text.
snippet?: string | null;
// The id of the thread the message belongs to.
threadId?: string | null;
}>
gmail.list_drafts#
List drafts.
list_drafts(args: {
// The id of the Google connection.
connection: DocId;
// Most drafts to return, 1-500.
max_results?: number | null;
// The `nextPageToken` of the previous page, to continue from it.
page_token?: string | null;
// A Gmail search query the drafts must match.
query?: string | null;
}): Promise<{
// The drafts on this page; each message carries its id and thread id only.
drafts: Array<GmailDraft>;
// The token for the next page, when there is one.
nextPageToken?: string | null;
// Gmail's estimate of the total number of results.
resultSizeEstimate?: number | null;
}>
gmail.get_draft#
Get one draft.
get_draft(args: {
// The id of the Google connection.
connection: DocId;
// The draft id.
draft_id: string;
// How much of the draft's message to return; `full` when omitted.
format?: GmailMessageFormat;
}): Promise<{
// The draft id.
id: string;
// The draft's message.
message: GmailMessage;
}>
gmail.create_draft#
Create a draft: a new message, or a reply when reply_to_email_id is given.
create_draft(args: {
// Files to attach.
attachments?: Array<GmailAttachment>;
// An HTML body, beside the plain text.
body_html?: string;
// The plain-text body.
body_text?: string;
// The id of the Google connection.
connection: DocId;
// An accepted send-as alias to send from; the account's default sender when omitted.
from_email?: string | null;
// A display name for the sender.
from_name?: string | null;
// The id of a message to draft a reply to. Its recipient, subject and thread are inherited.
reply_to_email_id?: string | null;
// The subject of a new message. Leave empty for a reply draft, which keeps the original's.
subject?: string;
// The recipients of a new message. Leave empty for a reply draft.
to?: Array<string>;
}): Promise<{
// The draft id.
id: string;
// The draft's message.
message: GmailMessage;
}>
gmail.update_draft#
Replace a draft's message: a new message, or a reply when reply_to_email_id is given.
update_draft(args: {
// Files to attach.
attachments?: Array<GmailAttachment>;
// An HTML body, beside the plain text.
body_html?: string;
// The plain-text body.
body_text?: string;
// The id of the Google connection.
connection: DocId;
// The draft id.
draft_id: string;
// An accepted send-as alias to send from; the account's default sender when omitted.
from_email?: string | null;
// A display name for the sender.
from_name?: string | null;
// The id of a message to draft a reply to. Its recipient, subject and thread are inherited.
reply_to_email_id?: string | null;
// The subject of a new message. Leave empty for a reply draft, which keeps the original's.
subject?: string;
// The recipients of a new message. Leave empty for a reply draft.
to?: Array<string>;
}): Promise<{
// The draft id.
id: string;
// The draft's message.
message: GmailMessage;
}>
gmail.send_draft#
Send a draft as it stands.
send_draft(args: {
// The id of the Google connection.
connection: DocId;
// The draft id.
draft_id: string;
}): Promise<{
// The id of the last history record that modified the message.
historyId?: string | null;
// The message id.
id: string;
// When Gmail received the message, in milliseconds since the epoch, as text.
internalDate?: string | null;
// The ids of the labels on the message, system labels such as `INBOX` and `UNREAD` included.
labelIds?: Array<string>;
// The parsed MIME structure, for the `full` and `metadata` formats.
payload?: GmailMessagePart | null;
// The whole RFC 2822 message as base64url text, for the `raw` format.
raw?: string | null;
// The estimated size of the message in bytes.
sizeEstimate?: number | null;
// A short part of the message text.
snippet?: string | null;
// The id of the thread the message belongs to.
threadId?: string | null;
}>
gmail.delete_draft#
Delete a draft for good.
delete_draft(args: {
// The id of the Google connection.
connection: DocId;
// The draft id.
draft_id: string;
}): Promise<null>
gmail.modify_labels#
Add and remove labels on a message.
modify_labels(args: {
// Label ids to add.
add_label_ids?: Array<string>;
// The id of the Google connection.
connection: DocId;
// The message id.
email_id: string;
// Label ids to remove.
remove_label_ids?: Array<string>;
}): Promise<{
// The id of the last history record that modified the message.
historyId?: string | null;
// The message id.
id: string;
// When Gmail received the message, in milliseconds since the epoch, as text.
internalDate?: string | null;
// The ids of the labels on the message, system labels such as `INBOX` and `UNREAD` included.
labelIds?: Array<string>;
// The parsed MIME structure, for the `full` and `metadata` formats.
payload?: GmailMessagePart | null;
// The whole RFC 2822 message as base64url text, for the `raw` format.
raw?: string | null;
// The estimated size of the message in bytes.
sizeEstimate?: number | null;
// A short part of the message text.
snippet?: string | null;
// The id of the thread the message belongs to.
threadId?: string | null;
}>
gmail.mark_read#
Mark a message read or unread.
mark_read(args: {
// The id of the Google connection.
connection: DocId;
// The message id.
email_id: string;
// `true` marks it read, `false` unread; read when omitted.
read?: boolean;
}): Promise<{
// The id of the last history record that modified the message.
historyId?: string | null;
// The message id.
id: string;
// When Gmail received the message, in milliseconds since the epoch, as text.
internalDate?: string | null;
// The ids of the labels on the message, system labels such as `INBOX` and `UNREAD` included.
labelIds?: Array<string>;
// The parsed MIME structure, for the `full` and `metadata` formats.
payload?: GmailMessagePart | null;
// The whole RFC 2822 message as base64url text, for the `raw` format.
raw?: string | null;
// The estimated size of the message in bytes.
sizeEstimate?: number | null;
// A short part of the message text.
snippet?: string | null;
// The id of the thread the message belongs to.
threadId?: string | null;
}>
gmail.archive#
Archive a message: take it out of the inbox.
archive(args: {
// The id of the Google connection.
connection: DocId;
// The message id.
email_id: string;
}): Promise<{
// The id of the last history record that modified the message.
historyId?: string | null;
// The message id.
id: string;
// When Gmail received the message, in milliseconds since the epoch, as text.
internalDate?: string | null;
// The ids of the labels on the message, system labels such as `INBOX` and `UNREAD` included.
labelIds?: Array<string>;
// The parsed MIME structure, for the `full` and `metadata` formats.
payload?: GmailMessagePart | null;
// The whole RFC 2822 message as base64url text, for the `raw` format.
raw?: string | null;
// The estimated size of the message in bytes.
sizeEstimate?: number | null;
// A short part of the message text.
snippet?: string | null;
// The id of the thread the message belongs to.
threadId?: string | null;
}>
gmail.trash#
Move a message to the trash, where Gmail keeps it for 30 days.
trash(args: {
// The id of the Google connection.
connection: DocId;
// The message id.
email_id: string;
}): Promise<{
// The id of the last history record that modified the message.
historyId?: string | null;
// The message id.
id: string;
// When Gmail received the message, in milliseconds since the epoch, as text.
internalDate?: string | null;
// The ids of the labels on the message, system labels such as `INBOX` and `UNREAD` included.
labelIds?: Array<string>;
// The parsed MIME structure, for the `full` and `metadata` formats.
payload?: GmailMessagePart | null;
// The whole RFC 2822 message as base64url text, for the `raw` format.
raw?: string | null;
// The estimated size of the message in bytes.
sizeEstimate?: number | null;
// A short part of the message text.
snippet?: string | null;
// The id of the thread the message belongs to.
threadId?: string | null;
}>
gmail.untrash#
Restore a message from the trash.
untrash(args: {
// The id of the Google connection.
connection: DocId;
// The message id.
email_id: string;
}): Promise<{
// The id of the last history record that modified the message.
historyId?: string | null;
// The message id.
id: string;
// When Gmail received the message, in milliseconds since the epoch, as text.
internalDate?: string | null;
// The ids of the labels on the message, system labels such as `INBOX` and `UNREAD` included.
labelIds?: Array<string>;
// The parsed MIME structure, for the `full` and `metadata` formats.
payload?: GmailMessagePart | null;
// The whole RFC 2822 message as base64url text, for the `raw` format.
raw?: string | null;
// The estimated size of the message in bytes.
sizeEstimate?: number | null;
// A short part of the message text.
snippet?: string | null;
// The id of the thread the message belongs to.
threadId?: string | null;
}>
gmail.download_attachment#
Download one attachment of a message.
download_attachment(args: {
// The attachment id, from the message part's `body.attachmentId`.
attachment_id: string;
// The id of the Google connection.
connection: DocId;
// The id of the message holding the attachment.
email_id: string;
}): Promise<{
// The content.
content: Uint8Array;
// The content's size in bytes.
size: number;
}>
gmail.list_labels#
List the account's labels.
list_labels(args: {
// The id of the Google connection.
connection: DocId;
}): Promise<{
// Every label, system and user.
labels: Array<GmailLabel>;
}>
gmail.create_label#
Create a label.
create_label(args: {
// The background color as a hex code from Gmail's palette; give it with `text_color`.
background_color?: string | null;
// The id of the Google connection.
connection: DocId;
// Whether the label shows in the label list.
label_list_visibility?: GmailLabelListVisibility | null;
// Whether messages show the label in the message list.
message_list_visibility?: GmailMessageListVisibility | null;
// The label's name; `/` nests it under another label, as in `Clients/Acme`.
name: string;
// The text color as a hex code from Gmail's palette; give it with `background_color`.
text_color?: string | null;
}): Promise<{
// The label's colors, when it has any.
color?: GmailLabelColor | null;
// The label id, used to add or remove the label on a message.
id: string;
// Whether the label shows in the label list.
labelListVisibility?: GmailLabelListVisibility | null;
// Whether messages show the label in the message list.
messageListVisibility?: GmailMessageListVisibility | null;
// How many messages carry the label.
messagesTotal?: number | null;
// How many unread messages carry the label.
messagesUnread?: number | null;
// The label's display name.
name: string;
// How many threads carry the label.
threadsTotal?: number | null;
// How many unread threads carry the label.
threadsUnread?: number | null;
// Whether Gmail or the user made the label.
type?: GmailLabelType | null;
}>
gmail.update_label#
Change a label; what is omitted stays as it is.
update_label(args: {
// A new background color as a hex code from Gmail's palette; give it with `text_color`.
background_color?: string | null;
// The id of the Google connection.
connection: DocId;
// The label id.
label_id: string;
// Whether the label shows in the label list.
label_list_visibility?: GmailLabelListVisibility | null;
// Whether messages show the label in the message list.
message_list_visibility?: GmailMessageListVisibility | null;
// A new name.
name?: string | null;
// A new text color as a hex code from Gmail's palette; give it with `background_color`.
text_color?: string | null;
}): Promise<{
// The label's colors, when it has any.
color?: GmailLabelColor | null;
// The label id, used to add or remove the label on a message.
id: string;
// Whether the label shows in the label list.
labelListVisibility?: GmailLabelListVisibility | null;
// Whether messages show the label in the message list.
messageListVisibility?: GmailMessageListVisibility | null;
// How many messages carry the label.
messagesTotal?: number | null;
// How many unread messages carry the label.
messagesUnread?: number | null;
// The label's display name.
name: string;
// How many threads carry the label.
threadsTotal?: number | null;
// How many unread threads carry the label.
threadsUnread?: number | null;
// Whether Gmail or the user made the label.
type?: GmailLabelType | null;
}>
gmail.delete_label#
Delete a label; messages keep their place but lose the label.
delete_label(args: {
// The id of the Google connection.
connection: DocId;
// The label id.
label_id: string;
}): Promise<null>
Types#
// The identifier of a persisted record.
type DocId = string;
// A file to attach to an outgoing message.
type GmailAttachment = {
// The file's content.
content: Uint8Array;
// The MIME type, such as `application/pdf`; `application/octet-stream` when omitted.
content_type?: string | null;
// The file name the recipient sees; `attachment` when omitted.
filename?: string | null;
};
// A draft and the message it holds.
type GmailDraft = {
// The draft id.
id: string;
// The draft's message.
message: GmailMessage;
};
// One message header, as written in the message.
type GmailHeader = {
// The header name, such as `Subject`.
name: string;
// The header value.
value: string;
};
// A Gmail label.
type GmailLabel = {
// The label's colors, when it has any.
color?: GmailLabelColor | null;
// The label id, used to add or remove the label on a message.
id: string;
// Whether the label shows in the label list.
labelListVisibility?: GmailLabelListVisibility | null;
// Whether messages show the label in the message list.
messageListVisibility?: GmailMessageListVisibility | null;
// How many messages carry the label.
messagesTotal?: number | null;
// How many unread messages carry the label.
messagesUnread?: number | null;
// The label's display name.
name: string;
// How many threads carry the label.
threadsTotal?: number | null;
// How many unread threads carry the label.
threadsUnread?: number | null;
// Whether Gmail or the user made the label.
type?: GmailLabelType | null;
};
// A label's colors, as hex codes from Gmail's palette.
type GmailLabelColor = {
// The background color, such as `#16a766`.
backgroundColor: string;
// The text color, such as `#ffffff`.
textColor: string;
};
// Whether a label shows in the label list.
type GmailLabelListVisibility = "labelShow" | "labelShowIfUnread" | "labelHide";
// Who made a label.
type GmailLabelType = "system" | "user";
// A Gmail message resource as Gmail returns it. A listing, a send or a label change returns only
// some fields; a get returns what its format asks for.
type GmailMessage = {
// The id of the last history record that modified the message.
historyId?: string | null;
// The message id.
id: string;
// When Gmail received the message, in milliseconds since the epoch, as text.
internalDate?: string | null;
// The ids of the labels on the message, system labels such as `INBOX` and `UNREAD` included.
labelIds?: Array<string>;
// The parsed MIME structure, for the `full` and `metadata` formats.
payload?: GmailMessagePart | null;
// The whole RFC 2822 message as base64url text, for the `raw` format.
raw?: string | null;
// The estimated size of the message in bytes.
sizeEstimate?: number | null;
// A short part of the message text.
snippet?: string | null;
// The id of the thread the message belongs to.
threadId?: string | null;
};
// How much of a message Gmail returns.
type GmailMessageFormat = "minimal" | "full" | "raw" | "metadata";
// Whether messages show a label in the message list.
type GmailMessageListVisibility = "show" | "hide";
// One part of a message's MIME structure; the top part is the message itself.
type GmailMessagePart = {
// The part's body, or the attachment id to download it with.
body?: GmailPartBody | null;
// The attachment's file name, when the part is an attachment.
filename?: string | null;
// The part's headers.
headers?: Array<GmailHeader>;
// The part's MIME type, such as `text/plain`.
mimeType?: string | null;
// The part's id within the message.
partId?: string | null;
// The child parts of a multipart part.
parts?: Array<GmailMessagePart>;
};
// The body of one message part.
type GmailPartBody = {
// The id to download an attachment's content with, when the content is not inline.
attachmentId?: string | null;
// The inline content as base64url text.
data?: string | null;
// The body's size in bytes.
size?: number | null;
};
// A Gmail thread: listing returns its id and snippet, getting it adds its messages.
type GmailThread = {
// The id of the last history record that modified the thread.
historyId?: string | null;
// The thread id.
id: string;
// The thread's messages, oldest first.
messages?: Array<GmailMessage>;
// A short part of the thread's text.
snippet?: string | null;
};
verdalia.api.google_calendar#
google_calendar.list_events#
Lists a calendar's events in start order, with recurring events expanded into occurrences.
list_events(args: {
// Calendar ID; `primary` is the account's main calendar.
calendar_id?: string;
// The id of the Google connection.
connection: DocId;
// Most events to return, 1-2500; left out, Google's own default applies. The result's
// `nextPageToken` says more exist.
max_results?: number | null;
// Free-text search over the events' summary, description, location and attendees.
query?: string | null;
// Only events starting before this time (RFC 3339).
time_max?: string | null;
// Only events ending after this time (RFC 3339, e.g. `2026-11-05T09:00:00Z`).
time_min?: string | null;
}): Promise<Record<string, unknown>>
google_calendar.search_events#
Searches a calendar's events by free text, in start order.
search_events(args: {
// Calendar ID; `primary` is the account's main calendar.
calendar_id?: string;
// The id of the Google connection.
connection: DocId;
// Most events to return, 1-2500; left out, Google's own default applies.
max_results?: number | null;
// Text matched against the events' summary, description, location and attendees.
query: string;
// Only events starting before this time (RFC 3339).
time_max?: string | null;
// Only events ending after this time (RFC 3339).
time_min?: string | null;
}): Promise<Record<string, unknown>>
google_calendar.get_event#
Gets one event.
get_event(args: {
// Calendar ID; `primary` is the account's main calendar.
calendar_id?: string;
// The id of the Google connection.
connection: DocId;
// Event ID, from a list or search.
event_id: string;
}): Promise<Record<string, unknown>>
google_calendar.create_event#
Creates an event. Guests are emailed only when send_notifications is set.
create_event(args: {
// Email addresses of the guests to invite.
attendees?: Array<string>;
// Calendar ID; `primary` is the account's main calendar.
calendar_id?: string;
// The id of the Google connection.
connection: DocId;
// Event description.
description?: string | null;
// End time (RFC 3339).
end_time: string;
// Event location, such as an address or a meeting link.
location?: string | null;
// Email the guests about the new event. Off unless set.
send_notifications?: boolean;
// Start time (RFC 3339, e.g. `2026-11-05T10:00:00+01:00`).
start_time: string;
// Event title.
summary?: string | null;
}): Promise<Record<string, unknown>>
google_calendar.update_event#
Changes an event's fields; a field left out keeps its value. Guests are emailed only when
send_notifications is set.
update_event(args: {
// The whole new guest list, as email addresses; replaces the current one. Left out, the
// guests stay as they are.
attendees?: Array<string> | null;
// Calendar ID; `primary` is the account's main calendar.
calendar_id?: string;
// The id of the Google connection.
connection: DocId;
// New description.
description?: string | null;
// New end time (RFC 3339).
end_time?: string | null;
// Event ID, from a list or search.
event_id: string;
// New location.
location?: string | null;
// Email the guests about the change. Off unless set.
send_notifications?: boolean;
// New start time (RFC 3339).
start_time?: string | null;
// New title.
summary?: string | null;
}): Promise<Record<string, unknown>>
google_calendar.delete_event#
Deletes an event. Guests are emailed the cancellation only when send_notifications is set.
delete_event(args: {
// Calendar ID; `primary` is the account's main calendar.
calendar_id?: string;
// The id of the Google connection.
connection: DocId;
// Event ID, from a list or search.
event_id: string;
// Email the guests the cancellation. Off unless set.
send_notifications?: boolean;
}): Promise<{
// Always `true`: a delete that fails is an error instead.
deleted: boolean;
// The deleted event's ID.
event_id: string;
}>
google_calendar.respond_to_invitation#
Answers an invitation to an event as the connection's Google account. The organizer is
emailed the answer only when send_notifications is set.
respond_to_invitation(args: {
// Calendar ID; `primary` is the account's main calendar.
calendar_id?: string;
// A note to the organizer with the answer.
comment?: string | null;
// The id of the Google connection.
connection: DocId;
// Event ID, from a list or search.
event_id: string;
// The answer.
response: InvitationResponse;
// Email the organizer the answer. Off unless set.
send_notifications?: boolean;
}): Promise<Record<string, unknown>>
google_calendar.free_busy#
Reads when calendars are busy between two times.
free_busy(args: {
// IDs of the calendars to read; default the primary calendar. A person's email address is
// their primary calendar's ID.
calendar_ids?: Array<string>;
// The id of the Google connection.
connection: DocId;
// End of the window (RFC 3339).
time_max: string;
// Start of the window (RFC 3339).
time_min: string;
}): Promise<{
// Each queried calendar's busy periods, by calendar ID.
calendars: Record<string, CalendarFreeBusy>;
}>
google_calendar.list_calendars#
Lists the calendars on the account's calendar list.
list_calendars(args: {
// The id of the Google connection.
connection: DocId;
// Only calendars granting at least this access.
min_access_role?: CalendarAccessRole | null;
}): Promise<Record<string, unknown>>
google_calendar.create_calendar#
Creates a secondary calendar owned by the account.
create_calendar(args: {
// The id of the Google connection.
connection: DocId;
// Calendar description.
description?: string | null;
// Calendar location.
location?: string | null;
// Calendar title.
summary: string;
// IANA time zone, such as `Europe/Stockholm`.
time_zone?: string | null;
}): Promise<Record<string, unknown>>
google_calendar.update_calendar#
Changes a calendar's fields; a field left out keeps its value.
update_calendar(args: {
// Calendar ID, from the calendar list.
calendar_id: string;
// The id of the Google connection.
connection: DocId;
// New description.
description?: string | null;
// New location.
location?: string | null;
// New title.
summary?: string | null;
// New IANA time zone, such as `Europe/Stockholm`.
time_zone?: string | null;
}): Promise<Record<string, unknown>>
google_calendar.delete_calendar#
Deletes a secondary calendar and every event on it. The primary calendar cannot be deleted.
delete_calendar(args: {
// Calendar ID, from the calendar list.
calendar_id: string;
// The id of the Google connection.
connection: DocId;
}): Promise<{
// The deleted calendar's ID.
calendar_id: string;
// Always `true`: a delete that fails is an error instead.
deleted: boolean;
}>
Types#
// One busy period.
type BusyPeriod = {
// When the period ends (RFC 3339).
end: string;
// When the period starts (RFC 3339).
start: string;
};
// The least access a listed calendar must grant the account, in Google's spelling.
type CalendarAccessRole = "freeBusyReader" | "reader" | "writer" | "owner";
// One calendar's busy periods in the window.
type CalendarFreeBusy = {
// The busy periods, in order.
busy: Array<BusyPeriod>;
// Why the calendar could not be read, when it could not.
errors?: Array<FreeBusyError>;
};
// The identifier of a persisted record.
type DocId = string;
// Why Google could not read one calendar's free/busy.
type FreeBusyError = {
// Google's reason code, such as `notFound`.
reason: string;
};
// An answer to an invitation.
type InvitationResponse = "accepted" | "declined" | "tentative";
verdalia.api.drive#
drive.list_files#
List the files in a folder, or in all of Drive, leaving out trashed files.
list_files(args: {
// The id of the Google connection.
connection: DocId;
// The folder to list. Omit to list across all of Drive.
folder_id?: string | null;
// Most files to return; Drive's default when omitted.
page_size?: number | null;
// An extra filter in Drive's query syntax, such as `mimeType='application/pdf'`.
query?: string | null;
}): Promise<{
// The files, in Drive's order.
files: Array<DriveFile>;
}>
drive.search_files#
Find files whose name contains some text, leaving out trashed files.
search_files(args: {
// The id of the Google connection.
connection: DocId;
// Only files of this MIME type, such as `application/vnd.google-apps.document`.
mime_type?: string | null;
// Most files to return; Drive's default when omitted.
page_size?: number | null;
// Text the file name contains.
query: string;
}): Promise<{
// The files, in Drive's order.
files: Array<DriveFile>;
}>
drive.get_file#
Get a file's metadata.
get_file(args: {
// The id of the Google connection.
connection: DocId;
// The file's Drive id.
file_id: string;
}): Promise<{
// When the file was created.
createdTime?: string | null;
// The file's description.
description?: string | null;
// The file's Drive id.
id: string;
// Drive's resource kind, in a write's answer.
kind?: DriveFileKind | null;
// The file's MIME type; Google's own formats are `application/vnd.google-apps.*`.
mimeType: string;
// When the file was last modified.
modifiedTime?: string | null;
// The file name.
name: string;
// Ids of the folders holding the file.
parents?: Array<string> | null;
// The SHA-256 of the file's stored content, read only by a download into the Library.
sha256Checksum?: string | null;
// Size in bytes, as Drive's decimal string. Absent for Google's own formats and folders.
size?: string | null;
// Link that downloads the file's content, for files that have stored content.
webContentLink?: string | null;
// Link that opens the file in Drive.
webViewLink?: string | null;
}>
drive.download_file#
Download a file's stored content. Google's own formats have none; export them instead.
download_file(args: {
// The id of the Google connection.
connection: DocId;
// The file's Drive id.
file_id: string;
}): Promise<{
// The content.
content: Uint8Array;
// The file's metadata.
file: DriveFile;
// The MIME type of `content`: the file's own, or the export format's.
mime_type: string;
}>
drive.export_file#
Export a Google Docs, Sheets or Slides file to another format.
export_file(args: {
// The id of the Google connection.
connection: DocId;
// The file's Drive id.
file_id: string;
// The format to export to.
format: DriveExportFormat;
}): Promise<{
// The content.
content: Uint8Array;
// The file's metadata.
file: DriveFile;
// The MIME type of `content`: the file's own, or the export format's.
mime_type: string;
}>
drive.upload_file#
Upload a new file.
upload_file(args: {
// The id of the Google connection.
connection: DocId;
// The content.
content: Uint8Array;
// The folder to put the file in. Omit for the Drive root.
folder_id?: string | null;
// The content's MIME type.
mime_type: string;
// The new file's name.
name: string;
}): Promise<{
// When the file was created.
createdTime?: string | null;
// The file's description.
description?: string | null;
// The file's Drive id.
id: string;
// Drive's resource kind, in a write's answer.
kind?: DriveFileKind | null;
// The file's MIME type; Google's own formats are `application/vnd.google-apps.*`.
mimeType: string;
// When the file was last modified.
modifiedTime?: string | null;
// The file name.
name: string;
// Ids of the folders holding the file.
parents?: Array<string> | null;
// The SHA-256 of the file's stored content, read only by a download into the Library.
sha256Checksum?: string | null;
// Size in bytes, as Drive's decimal string. Absent for Google's own formats and folders.
size?: string | null;
// Link that downloads the file's content, for files that have stored content.
webContentLink?: string | null;
// Link that opens the file in Drive.
webViewLink?: string | null;
}>
drive.create_folder#
Create a folder.
create_folder(args: {
// The id of the Google connection.
connection: DocId;
// The folder's name.
name: string;
// The folder to create it in. Omit for the Drive root.
parent_id?: string | null;
}): Promise<{
// When the file was created.
createdTime?: string | null;
// The file's description.
description?: string | null;
// The file's Drive id.
id: string;
// Drive's resource kind, in a write's answer.
kind?: DriveFileKind | null;
// The file's MIME type; Google's own formats are `application/vnd.google-apps.*`.
mimeType: string;
// When the file was last modified.
modifiedTime?: string | null;
// The file name.
name: string;
// Ids of the folders holding the file.
parents?: Array<string> | null;
// The SHA-256 of the file's stored content, read only by a download into the Library.
sha256Checksum?: string | null;
// Size in bytes, as Drive's decimal string. Absent for Google's own formats and folders.
size?: string | null;
// Link that downloads the file's content, for files that have stored content.
webContentLink?: string | null;
// Link that opens the file in Drive.
webViewLink?: string | null;
}>
drive.update_file#
Change a file's name, description or content. Fields left out stay as they are.
update_file(args: {
// The id of the Google connection.
connection: DocId;
// New content, replacing the file's stored content.
content?: DriveContent | null;
// A new description.
description?: string | null;
// The file's Drive id.
file_id: string;
// A new name, to rename the file.
name?: string | null;
}): Promise<{
// When the file was created.
createdTime?: string | null;
// The file's description.
description?: string | null;
// The file's Drive id.
id: string;
// Drive's resource kind, in a write's answer.
kind?: DriveFileKind | null;
// The file's MIME type; Google's own formats are `application/vnd.google-apps.*`.
mimeType: string;
// When the file was last modified.
modifiedTime?: string | null;
// The file name.
name: string;
// Ids of the folders holding the file.
parents?: Array<string> | null;
// The SHA-256 of the file's stored content, read only by a download into the Library.
sha256Checksum?: string | null;
// Size in bytes, as Drive's decimal string. Absent for Google's own formats and folders.
size?: string | null;
// Link that downloads the file's content, for files that have stored content.
webContentLink?: string | null;
// Link that opens the file in Drive.
webViewLink?: string | null;
}>
drive.move_file#
Move a file into another folder, out of every folder it is in now.
move_file(args: {
// The id of the Google connection.
connection: DocId;
// The file's Drive id.
file_id: string;
// The folder to move it to.
folder_id: string;
}): Promise<{
// When the file was created.
createdTime?: string | null;
// The file's description.
description?: string | null;
// The file's Drive id.
id: string;
// Drive's resource kind, in a write's answer.
kind?: DriveFileKind | null;
// The file's MIME type; Google's own formats are `application/vnd.google-apps.*`.
mimeType: string;
// When the file was last modified.
modifiedTime?: string | null;
// The file name.
name: string;
// Ids of the folders holding the file.
parents?: Array<string> | null;
// The SHA-256 of the file's stored content, read only by a download into the Library.
sha256Checksum?: string | null;
// Size in bytes, as Drive's decimal string. Absent for Google's own formats and folders.
size?: string | null;
// Link that downloads the file's content, for files that have stored content.
webContentLink?: string | null;
// Link that opens the file in Drive.
webViewLink?: string | null;
}>
drive.copy_file#
Copy a file.
copy_file(args: {
// The id of the Google connection.
connection: DocId;
// The Drive id of the file to copy.
file_id: string;
// The folder to put the copy in. Omit to keep the original's folder.
folder_id?: string | null;
// The copy's name. Omit to let Drive name it after the original.
name?: string | null;
}): Promise<{
// When the file was created.
createdTime?: string | null;
// The file's description.
description?: string | null;
// The file's Drive id.
id: string;
// Drive's resource kind, in a write's answer.
kind?: DriveFileKind | null;
// The file's MIME type; Google's own formats are `application/vnd.google-apps.*`.
mimeType: string;
// When the file was last modified.
modifiedTime?: string | null;
// The file name.
name: string;
// Ids of the folders holding the file.
parents?: Array<string> | null;
// The SHA-256 of the file's stored content, read only by a download into the Library.
sha256Checksum?: string | null;
// Size in bytes, as Drive's decimal string. Absent for Google's own formats and folders.
size?: string | null;
// Link that downloads the file's content, for files that have stored content.
webContentLink?: string | null;
// Link that opens the file in Drive.
webViewLink?: string | null;
}>
drive.trash_file#
Move a file to the trash, from where it can be restored.
trash_file(args: {
// The id of the Google connection.
connection: DocId;
// The file's Drive id.
file_id: string;
}): Promise<{
// When the file was created.
createdTime?: string | null;
// The file's description.
description?: string | null;
// The file's Drive id.
id: string;
// Drive's resource kind, in a write's answer.
kind?: DriveFileKind | null;
// The file's MIME type; Google's own formats are `application/vnd.google-apps.*`.
mimeType: string;
// When the file was last modified.
modifiedTime?: string | null;
// The file name.
name: string;
// Ids of the folders holding the file.
parents?: Array<string> | null;
// The SHA-256 of the file's stored content, read only by a download into the Library.
sha256Checksum?: string | null;
// Size in bytes, as Drive's decimal string. Absent for Google's own formats and folders.
size?: string | null;
// Link that downloads the file's content, for files that have stored content.
webContentLink?: string | null;
// Link that opens the file in Drive.
webViewLink?: string | null;
}>
drive.untrash_file#
Restore a file from the trash.
untrash_file(args: {
// The id of the Google connection.
connection: DocId;
// The file's Drive id.
file_id: string;
}): Promise<{
// When the file was created.
createdTime?: string | null;
// The file's description.
description?: string | null;
// The file's Drive id.
id: string;
// Drive's resource kind, in a write's answer.
kind?: DriveFileKind | null;
// The file's MIME type; Google's own formats are `application/vnd.google-apps.*`.
mimeType: string;
// When the file was last modified.
modifiedTime?: string | null;
// The file name.
name: string;
// Ids of the folders holding the file.
parents?: Array<string> | null;
// The SHA-256 of the file's stored content, read only by a download into the Library.
sha256Checksum?: string | null;
// Size in bytes, as Drive's decimal string. Absent for Google's own formats and folders.
size?: string | null;
// Link that downloads the file's content, for files that have stored content.
webContentLink?: string | null;
// Link that opens the file in Drive.
webViewLink?: string | null;
}>
drive.delete_file#
Delete a file: move it to the trash, or delete it for good.
delete_file(args: {
// The id of the Google connection.
connection: DocId;
// The file's Drive id.
file_id: string;
// Delete for good, skipping the trash. A permanent delete cannot be undone.
permanent?: boolean;
}): Promise<{
// The deleted file's Drive id.
file_id: string;
// Whether the file was deleted for good rather than moved to the trash.
permanent: boolean;
}>
drive.list_permissions#
List who a file is shared with.
list_permissions(args: {
// The id of the Google connection.
connection: DocId;
// The file's Drive id.
file_id: string;
}): Promise<{
// The file's permissions.
permissions: Array<DrivePermission>;
}>
drive.add_permission#
Share a file: grant a user, group, domain or anyone with the link access to it.
add_permission(args: {
// The id of the Google connection.
connection: DocId;
// The file's Drive id.
file_id: string;
// Who gets access.
grantee: DriveGrantee;
// A message for the notification email.
message?: string | null;
// Whether Google emails the user or group about the share. Google's default (yes) when
// omitted; only for a user or group.
notify?: boolean | null;
// The access they get.
role: DriveRole;
}): Promise<{
// The grantee's display name.
displayName?: string | null;
// The domain, for a domain permission.
domain?: string | null;
// The user's or group's email address.
emailAddress?: string | null;
// The permission's id, which changing or removing access takes.
id: string;
// The access granted.
role: DrivePermissionRole;
// Who the permission grants access to.
type: DrivePermissionKind;
}>
drive.update_permission#
Change the access one permission grants.
update_permission(args: {
// The id of the Google connection.
connection: DocId;
// The file's Drive id.
file_id: string;
// The permission's id, from listing the file's permissions.
permission_id: string;
// The access it grants from now on.
role: DriveRole;
}): Promise<{
// The grantee's display name.
displayName?: string | null;
// The domain, for a domain permission.
domain?: string | null;
// The user's or group's email address.
emailAddress?: string | null;
// The permission's id, which changing or removing access takes.
id: string;
// The access granted.
role: DrivePermissionRole;
// Who the permission grants access to.
type: DrivePermissionKind;
}>
drive.remove_permission#
Remove one permission, taking that access away.
remove_permission(args: {
// The id of the Google connection.
connection: DocId;
// The file's Drive id.
file_id: string;
// The permission's id, from listing the file's permissions.
permission_id: string;
}): Promise<null>
Types#
// The identifier of a persisted record.
type DocId = string;
// New content for an existing file.
type DriveContent = {
// The content.
data: Uint8Array;
// The content's MIME type.
mime_type: string;
};
// A format Drive exports a Google file to.
type DriveExportFormat = "pdf" | "docx" | "xlsx" | "pptx";
// A Drive file's metadata, as Drive returns it: the fields the operation asked for. Reads ask
// for the listed fields; writes take Drive's default answer (`kind`, `id`, `name`, `mimeType`).
type DriveFile = {
// When the file was created.
createdTime?: string | null;
// The file's description.
description?: string | null;
// The file's Drive id.
id: string;
// Drive's resource kind, in a write's answer.
kind?: DriveFileKind | null;
// The file's MIME type; Google's own formats are `application/vnd.google-apps.*`.
mimeType: string;
// When the file was last modified.
modifiedTime?: string | null;
// The file name.
name: string;
// Ids of the folders holding the file.
parents?: Array<string> | null;
// The SHA-256 of the file's stored content, read only by a download into the Library.
sha256Checksum?: string | null;
// Size in bytes, as Drive's decimal string. Absent for Google's own formats and folders.
size?: string | null;
// Link that downloads the file's content, for files that have stored content.
webContentLink?: string | null;
// Link that opens the file in Drive.
webViewLink?: string | null;
};
// Drive's `kind` for a file resource.
type DriveFileKind = "drive#file";
// Who to share a file with.
type DriveGrantee = {
email_address: string;
type: "user";
} | {
email_address: string;
type: "group";
} | {
domain: string;
type: "domain";
} | {
type: "anyone";
};
// One grant of access to a file, as Drive returns it.
type DrivePermission = {
// The grantee's display name.
displayName?: string | null;
// The domain, for a domain permission.
domain?: string | null;
// The user's or group's email address.
emailAddress?: string | null;
// The permission's id, which changing or removing access takes.
id: string;
// The access granted.
role: DrivePermissionRole;
// Who the permission grants access to.
type: DrivePermissionKind;
};
// Who a permission grants access to, as Drive names it.
type DrivePermissionKind = "user" | "group" | "domain" | "anyone";
// The access an existing permission holds, as Drive reports it: a shared role, or ownership.
type DrivePermissionRole = "owner" | "organizer" | "fileOrganizer" | "writer" | "commenter" | "reader";
// The access a share grants. Ownership is not granted by sharing.
type DriveRole = "organizer" | "fileOrganizer" | "writer" | "commenter" | "reader";
verdalia.api.docs#
docs.create#
Creates an empty Google Doc in the root of the user's Drive.
create(args: {
// The id of the Google connection.
connection: DocId;
// Title of the new document.
title: string;
}): Promise<{
// Id of the new document; Drive uses the same id for the file.
documentId: string;
// Title of the new document.
title: string;
}>
docs.get#
Reads a document's full structure as Google returns it.
get(args: {
// The id of the Google connection.
connection: DocId;
// Id of the document, from its URL or a Drive file id.
document_id: string;
}): Promise<Record<string, unknown>>
docs.get_text#
Reads a document's text with its structure stripped.
get_text(args: {
// The id of the Google connection.
connection: DocId;
// Id of the document, from its URL or a Drive file id.
document_id: string;
}): Promise<{
// Id of the document.
documentId: string;
// The body's text in reading order, table cells and the table of contents included; each
// paragraph ends with a newline.
text: string;
// Title of the document.
title: string;
}>
docs.insert_text#
Inserts text at an index of a document's body.
insert_text(args: {
// The id of the Google connection.
connection: DocId;
// Id of the document.
document_id: string;
// Position in the body, in UTF-16 code units; 1 is the start of the body. Read positions
// with the document's structure.
index: number;
// Text to insert. A newline starts a new paragraph.
text: string;
}): Promise<{
// Id of the edited document.
documentId: string;
// One reply per request, in request order, as Google returns them.
replies: Array<Record<string, unknown>>;
}>
docs.replace_text#
Replaces every occurrence of a text in a document.
replace_text(args: {
// The id of the Google connection.
connection: DocId;
// Id of the document.
document_id: string;
// Text to find.
find: string;
// Whether the match is case-sensitive.
match_case?: boolean;
// Text that replaces each occurrence; empty removes them.
replace_with: string;
}): Promise<{
// Id of the document.
documentId: string;
// Number of occurrences replaced; 0 when the text was not found.
occurrencesChanged: number;
}>
docs.delete_text#
Deletes the text between two indexes of a document's body.
delete_text(args: {
// The id of the Google connection.
connection: DocId;
// Id of the document.
document_id: string;
// Position after the last one deleted; greater than `start_index`.
end_index: number;
// First position to delete, in UTF-16 code units; 1 is the start of the body.
start_index: number;
}): Promise<{
// Id of the edited document.
documentId: string;
// One reply per request, in request order, as Google returns them.
replies: Array<Record<string, unknown>>;
}>
docs.append_text#
Appends text to the end of a document's body.
append_text(args: {
// The id of the Google connection.
connection: DocId;
// Id of the document.
document_id: string;
// Text to append. Start it with a newline to begin a new paragraph.
text: string;
}): Promise<{
// Id of the edited document.
documentId: string;
// One reply per request, in request order, as Google returns them.
replies: Array<Record<string, unknown>>;
}>
docs.batch_update#
Applies Google's own list of Docs edit requests in one call, for formatting, tables and every other edit the named operations do not cover.
batch_update(args: {
// The id of the Google connection.
connection: DocId;
// Id of the document.
document_id: string;
// Google Docs API `Request` objects, applied in order, all or none, such as
// `{"insertText": {"location": {"index": 1}, "text": "Hello"}}` or
// `{"updateTextStyle": {...}}`.
requests: Array<Record<string, unknown>>;
}): Promise<{
// Id of the edited document.
documentId: string;
// One reply per request, in request order, as Google returns them.
replies: Array<Record<string, unknown>>;
}>
docs.delete#
Moves a document to the Drive trash, where it can be restored from for 30 days.
delete(args: {
// The id of the Google connection.
connection: DocId;
// Id of the document.
document_id: string;
}): Promise<{
// When the file was created.
createdTime?: string | null;
// The file's description.
description?: string | null;
// The file's Drive id.
id: string;
// Drive's resource kind, in a write's answer.
kind?: DriveFileKind | null;
// The file's MIME type; Google's own formats are `application/vnd.google-apps.*`.
mimeType: string;
// When the file was last modified.
modifiedTime?: string | null;
// The file name.
name: string;
// Ids of the folders holding the file.
parents?: Array<string> | null;
// The SHA-256 of the file's stored content, read only by a download into the Library.
sha256Checksum?: string | null;
// Size in bytes, as Drive's decimal string. Absent for Google's own formats and folders.
size?: string | null;
// Link that downloads the file's content, for files that have stored content.
webContentLink?: string | null;
// Link that opens the file in Drive.
webViewLink?: string | null;
}>
Types#
// The identifier of a persisted record.
type DocId = string;
// Drive's `kind` for a file resource.
type DriveFileKind = "drive#file";
verdalia.api.sheets#
sheets.create#
Create a spreadsheet with one empty tab.
create(args: {
// The id of the Google connection.
connection: DocId;
// The new spreadsheet's title.
title: string;
}): Promise<{
// The spreadsheet's title.
properties: SpreadsheetProperties;
// The spreadsheet's tabs, in order.
sheets: Array<Sheet>;
// The spreadsheet's id, which every other Sheets operation takes.
spreadsheetId: string;
// The link that opens the spreadsheet in Google Sheets.
spreadsheetUrl: string;
}>
sheets.get#
Get a spreadsheet's structure: its properties, tabs and named ranges, without cell values.
get(args: {
// The id of the Google connection.
connection: DocId;
// The spreadsheet's id, from its URL (`/spreadsheets/d/<id>/`) or a create.
spreadsheet_id: string;
}): Promise<Record<string, unknown>>
sheets.read_range#
Read the cells of one A1 range.
read_range(args: {
// The id of the Google connection.
connection: DocId;
// The range in A1 notation, such as `Q3!A1:F40`, or a tab title alone for the whole tab.
range: string;
// The spreadsheet's id.
spreadsheet_id: string;
// How cells are rendered; defaults to `FORMATTED_VALUE`.
value_render?: ValueRender;
}): Promise<{
// The A1 range the rows cover, as Google normalized it (`Sheet1!A1:C3`).
range: string;
// The rows, top to bottom; absent when the range is empty.
values: Array<Array<CellValue>>;
}>
sheets.write_range#
Write rows of values into one A1 range, starting at its top-left cell.
write_range(args: {
// The id of the Google connection.
connection: DocId;
// The range in A1 notation, such as `Sheet1!A1` or `Sheet1!A1:C3`.
range: string;
// The spreadsheet's id.
spreadsheet_id: string;
// How Google reads the values; defaults to `USER_ENTERED`.
value_input?: ValueInput;
// The rows to write, top to bottom; each row is its cells left to right.
values: Array<Array<CellValue>>;
}): Promise<{
// How many cells were written.
updatedCells: number;
// How many columns had a cell written.
updatedColumns: number;
// The A1 range that was written.
updatedRange: string;
// How many rows had a cell written.
updatedRows: number;
}>
sheets.append_rows#
Append rows after the last row of the table found in an A1 range.
append_rows(args: {
// The id of the Google connection.
connection: DocId;
// The range in A1 notation that holds the table, such as `Sheet1!A:F` or `Sheet1`.
range: string;
// The rows to append, top to bottom; each row is its cells left to right.
rows: Array<Array<CellValue>>;
// The spreadsheet's id.
spreadsheet_id: string;
// How Google reads the values; defaults to `USER_ENTERED`.
value_input?: ValueInput;
}): Promise<{
// The existing table the rows were appended after, when the range held one.
tableRange: string | null;
// The cells the appended rows were written to.
updates: UpdatedValues;
}>
sheets.clear_range#
Clear the values of one A1 range, keeping its formatting.
clear_range(args: {
// The id of the Google connection.
connection: DocId;
// The range in A1 notation, such as `Sheet1!A2:F`.
range: string;
// The spreadsheet's id.
spreadsheet_id: string;
}): Promise<{
// The A1 range whose values were cleared.
clearedRange: string;
}>
sheets.add_tab#
Add an empty tab at the end of a spreadsheet.
add_tab(args: {
// The id of the Google connection.
connection: DocId;
// The spreadsheet's id.
spreadsheet_id: string;
// The new tab's title; it must differ from every other tab's.
title: string;
}): Promise<{
// The tab's position, from 0.
index: number;
// The tab's id, which renaming and deleting a tab take. The first tab's is usually 0.
sheetId: number;
// The tab's title, which A1 ranges name before `!`.
title: string;
}>
sheets.rename_tab#
Rename one tab of a spreadsheet.
rename_tab(args: {
// The id of the Google connection.
connection: DocId;
// The tab's id (`sheetId`), from a get or an add tab.
sheet_id: number;
// The spreadsheet's id.
spreadsheet_id: string;
// The tab's new title; it must differ from every other tab's.
title: string;
}): Promise<{
// The id of the spreadsheet that was changed.
spreadsheetId: string;
}>
sheets.delete_tab#
Delete one tab of a spreadsheet, with its cells.
delete_tab(args: {
// The id of the Google connection.
connection: DocId;
// The tab's id (`sheetId`), from a get or an add tab. A spreadsheet keeps at least one tab.
sheet_id: number;
// The spreadsheet's id.
spreadsheet_id: string;
}): Promise<{
// The id of the spreadsheet that was changed.
spreadsheetId: string;
}>
sheets.batch_update#
Apply Google's own Sheets edit requests (formatting, charts, sorting, merges and every other
edit spreadsheets.batchUpdate accepts) in one atomic call.
batch_update(args: {
// The id of the Google connection.
connection: DocId;
// Google's `Request` objects, applied in order, such as
// `{"repeatCell": {...}}` or `{"sortRange": {...}}`.
requests: Array<Record<string, unknown>>;
// The spreadsheet's id.
spreadsheet_id: string;
}): Promise<Record<string, unknown>>
sheets.delete#
Move a spreadsheet to Drive's trash, from which it can be restored.
delete(args: {
// The id of the Google connection.
connection: DocId;
// The spreadsheet's id.
spreadsheet_id: string;
}): Promise<{
// When the file was created.
createdTime?: string | null;
// The file's description.
description?: string | null;
// The file's Drive id.
id: string;
// Drive's resource kind, in a write's answer.
kind?: DriveFileKind | null;
// The file's MIME type; Google's own formats are `application/vnd.google-apps.*`.
mimeType: string;
// When the file was last modified.
modifiedTime?: string | null;
// The file name.
name: string;
// Ids of the folders holding the file.
parents?: Array<string> | null;
// The SHA-256 of the file's stored content, read only by a download into the Library.
sha256Checksum?: string | null;
// Size in bytes, as Drive's decimal string. Absent for Google's own formats and folders.
size?: string | null;
// Link that downloads the file's content, for files that have stored content.
webContentLink?: string | null;
// Link that opens the file in Drive.
webViewLink?: string | null;
}>
Types#
// One cell's value as Google's `ValueRange` carries it: a boolean, a number or text.
type CellValue = boolean | number | string;
// The identifier of a persisted record.
type DocId = string;
// Drive's `kind` for a file resource.
type DriveFileKind = "drive#file";
// One tab of a spreadsheet.
type Sheet = {
// The tab's id, title and position.
properties: SheetProperties;
};
// A tab's id, title and position.
type SheetProperties = {
// The tab's position, from 0.
index: number;
// The tab's id, which renaming and deleting a tab take. The first tab's is usually 0.
sheetId: number;
// The tab's title, which A1 ranges name before `!`.
title: string;
};
// The spreadsheet-wide properties an operation reads or sets.
type SpreadsheetProperties = {
// The spreadsheet's title.
title: string;
};
// What a write changed: the range Google wrote and how many rows, columns and cells it touched.
type UpdatedValues = {
// How many cells were written.
updatedCells: number;
// How many columns had a cell written.
updatedColumns: number;
// The A1 range that was written.
updatedRange: string;
// How many rows had a cell written.
updatedRows: number;
};
// How Google reads the values a write sends: `USER_ENTERED` parses them as if typed into the
// sheet (formulas, numbers, dates), `RAW` stores them exactly as given.
type ValueInput = "USER_ENTERED" | "RAW";
// How a read renders cells: `FORMATTED_VALUE` as the sheet displays them, `UNFORMATTED_VALUE`
// as the underlying values, `FORMULA` as the formulas themselves.
type ValueRender = "FORMATTED_VALUE" | "UNFORMATTED_VALUE" | "FORMULA";
verdalia.api.slides#
slides.create#
Creates a presentation in the root of the user's Drive, holding one title slide.
create(args: {
// The id of the Google connection.
connection: DocId;
// Title of the new presentation.
title: string;
}): Promise<{
// Id of the new presentation; Drive uses the same id for the file.
presentationId: string;
// The slides it starts with, in order.
slides: Array<SlideRef>;
// Title of the new presentation.
title: string;
}>
slides.get#
Reads a presentation's full structure as Google returns it.
get(args: {
// The id of the Google connection.
connection: DocId;
// Id of the presentation, from its URL or a Drive file id.
presentation_id: string;
}): Promise<Record<string, unknown>>
slides.read_text#
Reads the text of every slide and its speaker notes, with the layout stripped.
read_text(args: {
// The id of the Google connection.
connection: DocId;
// Id of the presentation, from its URL or a Drive file id.
presentation_id: string;
}): Promise<{
// Id of the presentation.
presentationId: string;
// Every slide in presentation order.
slides: Array<SlideText>;
// Title of the presentation.
title: string;
}>
slides.add_slide#
Adds a slide built on one of Google's predefined layouts.
add_slide(args: {
// The id of the Google connection.
connection: DocId;
// Zero-based position of the new slide; omit to add it at the end.
insertion_index?: number | null;
// The predefined layout the slide uses; `BLANK` when omitted.
layout?: SlideLayout;
// Id of the presentation.
presentation_id: string;
}): Promise<{
// Object id of the new slide.
slideId: string;
}>
slides.duplicate_slide#
Duplicates a slide; the copy lands right after the original.
duplicate_slide(args: {
// The id of the Google connection.
connection: DocId;
// Id of the presentation.
presentation_id: string;
// Object id of the slide to copy.
slide_id: string;
}): Promise<{
// Object id of the new slide.
slideId: string;
}>
slides.delete_slide#
Removes a slide from a presentation.
delete_slide(args: {
// The id of the Google connection.
connection: DocId;
// Id of the presentation.
presentation_id: string;
// Object id of the slide to remove.
slide_id: string;
}): Promise<{
// Id of the presentation.
presentationId: string;
// Object id of the removed slide.
slideId: string;
}>
slides.replace_text#
Replaces every occurrence of a text in a presentation's shapes and tables.
replace_text(args: {
// The id of the Google connection.
connection: DocId;
// Text to find.
find: string;
// Whether a match must have the same case as `find`.
match_case?: boolean;
// Id of the presentation.
presentation_id: string;
// Text each match becomes; empty removes every match.
replace_with: string;
// Object ids of the slides to search; empty searches every slide.
slide_ids?: Array<string>;
}): Promise<{
// Number of occurrences replaced.
occurrencesChanged: number;
}>
slides.insert_image#
Places an image from a URL on a slide, at its own size in the slide's top-left corner.
insert_image(args: {
// The id of the Google connection.
connection: DocId;
// Public URL of a PNG, JPEG or GIF image under 50 MB, which Google fetches once.
image_url: string;
// Id of the presentation.
presentation_id: string;
// Object id of the slide the image goes on.
slide_id: string;
}): Promise<{
// Object id of the new image element.
imageId: string;
// Object id of the slide it is on.
slideId: string;
}>
slides.batch_update#
Applies Google's own list of Slides edit requests in one call, for shapes, styling, tables, placement and every other edit the named operations do not cover.
batch_update(args: {
// The id of the Google connection.
connection: DocId;
// Id of the presentation.
presentation_id: string;
// Google Slides API `Request` objects, applied in order, all or none, such as
// `{"createShape": {...}}` or `{"updateTextStyle": {...}}`.
requests: Array<Record<string, unknown>>;
}): Promise<{
// Id of the edited presentation.
presentationId: string;
// One reply per request, in request order, as Google returns them.
replies: Array<Record<string, unknown>>;
}>
slides.delete#
Moves a presentation to the Drive trash, where it can be restored from for 30 days.
delete(args: {
// The id of the Google connection.
connection: DocId;
// Id of the presentation.
presentation_id: string;
}): Promise<{
// When the file was created.
createdTime?: string | null;
// The file's description.
description?: string | null;
// The file's Drive id.
id: string;
// Drive's resource kind, in a write's answer.
kind?: DriveFileKind | null;
// The file's MIME type; Google's own formats are `application/vnd.google-apps.*`.
mimeType: string;
// When the file was last modified.
modifiedTime?: string | null;
// The file name.
name: string;
// Ids of the folders holding the file.
parents?: Array<string> | null;
// The SHA-256 of the file's stored content, read only by a download into the Library.
sha256Checksum?: string | null;
// Size in bytes, as Drive's decimal string. Absent for Google's own formats and folders.
size?: string | null;
// Link that downloads the file's content, for files that have stored content.
webContentLink?: string | null;
// Link that opens the file in Drive.
webViewLink?: string | null;
}>
Types#
// The identifier of a persisted record.
type DocId = string;
// Drive's `kind` for a file resource.
type DriveFileKind = "drive#file";
// Google's predefined slide layouts, as named in the Slides API: `BLANK` (empty), `CAPTION_ONLY`,
// `TITLE` (title and subtitle), `TITLE_AND_BODY`, `TITLE_AND_TWO_COLUMNS`, `TITLE_ONLY`,
// `SECTION_HEADER`, `SECTION_TITLE_AND_DESCRIPTION`, `ONE_COLUMN_TEXT`, `MAIN_POINT` and
// `BIG_NUMBER`.
type SlideLayout = "BLANK" | "CAPTION_ONLY" | "TITLE" | "TITLE_AND_BODY" | "TITLE_AND_TWO_COLUMNS" | "TITLE_ONLY" | "SECTION_HEADER" | "SECTION_TITLE_AND_DESCRIPTION" | "ONE_COLUMN_TEXT" | "MAIN_POINT" | "BIG_NUMBER";
// One slide of a presentation, by its object id.
type SlideRef = {
// Object id of the slide, which the slide operations take as `slide_id`.
objectId: string;
};
// The text one slide shows and the speaker notes it carries.
type SlideText = {
// Text of the slide's speaker notes, empty when it has none.
notes: string;
// Object id of the slide.
slideId: string;
// Text of the slide's shapes, tables and groups in the order Google lists them, one line
// per paragraph; table cells are separated by tabs.
text: string;
};
verdalia.api.relay#
relay.status#
The Relay's status: its version, uptime, registered plugins, and whether computer use is on.
status(args?: {
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
}): Promise<{
// Whether computer use is turned on in the relay's config; `None` from a relay older
// than the flag, which cannot say.
computer_use: boolean | null;
plugins_registered: number;
status: string;
uptime_seconds: number;
version: string;
}>
relay.request#
Any Relay route by its path, answering the route's JSON body: a route with no method of its own, such as a newer plugin's. Computer-use routes are refused, in any spelling.
request(args: {
// The JSON body; none is sent when left out.
body?: unknown;
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
// The HTTP method.
method: RelayRequestMethod;
// The route's path, starting `/api/`.
path: string;
// Query parameters, URL-encoded and appended to `path` in order.
query?: Array<RelayQueryPair>;
}): Promise<unknown>
Types#
// The identifier of a persisted record.
type DocId = string;
// One query parameter of a Relay request, its value rendered.
type RelayQueryPair = {
// The parameter's name.
key: string;
// The parameter's value.
value: string;
};
// The HTTP method of a Relay request.
type RelayRequestMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
verdalia.api.relay.fs#
relay.fs.mounts#
The filesystem mounts the Relay exposes, and whether each refuses writes.
mounts(args?: {
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
}): Promise<{
mounts: Array<RelayFilesystemMountInfo>;
}>
relay.fs.list#
The entries of a directory in a mount; path is relative to the mount, its root when empty.
list(args: {
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
include_hidden?: boolean;
// The mount's name.
mount: string;
path?: string;
recursive?: boolean;
}): Promise<{
entries: Array<FilesystemEntryMeta>;
mount: string;
path: string;
}>
relay.fs.stat#
The metadata of one path in a mount.
stat(args: {
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
follow_symlinks?: boolean;
// The mount's name.
mount: string;
path?: string;
}): Promise<{
entry: FilesystemEntryMeta;
mount: string;
path: string;
}>
relay.fs.read#
A text file's content, as UTF-8; readBytes reads any file as bytes.
read(args: {
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
// Read at most this many bytes; the Relay's own limit when left out.
max_bytes?: number | null;
// The mount's name.
mount: string;
// The file, relative to the mount.
path: string;
}): Promise<{
bytes_read: number;
content: string;
encoding: FileEncoding;
entry: FilesystemEntryMeta;
mount: string;
path: string;
truncated: boolean;
}>
relay.fs.readBytes#
A file's bytes, whatever they hold.
readBytes(args: {
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
// Read at most this many bytes; the Relay's own limit when left out.
max_bytes?: number | null;
// The mount's name.
mount: string;
// The file, relative to the mount.
path: string;
}): Promise<{
// How many bytes were read.
bytes_read: number;
// The bytes read.
content: Uint8Array;
// The file's metadata.
entry: FilesystemEntryMeta;
// The mount the file is in.
mount: string;
// The file, relative to the mount.
path: string;
// Whether the file holds more than was read.
truncated: boolean;
}>
relay.fs.write#
Write text to a file, as UTF-8; writeBytes writes bytes.
write(args: {
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
// The text to write.
content: string;
// Create the file's missing parent directories.
create_parents?: boolean;
// The mount's name.
mount: string;
// Replace a file that is already there; refused otherwise.
overwrite?: boolean;
// The file, relative to the mount.
path: string;
}): Promise<{
bytes_written: number;
created: boolean;
mount: string;
path: string;
}>
relay.fs.writeBytes#
Write bytes to a file.
writeBytes(args: {
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
// The bytes to write.
content: Uint8Array;
// Create the file's missing parent directories.
create_parents?: boolean;
// The mount's name.
mount: string;
// Replace a file that is already there; refused otherwise.
overwrite?: boolean;
// The file, relative to the mount.
path: string;
}): Promise<{
bytes_written: number;
created: boolean;
mount: string;
path: string;
}>
relay.fs.append#
Append text to a file, as UTF-8.
append(args: {
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
// The text to append.
content: string;
// Create the file when it is not there; refused otherwise.
create?: boolean;
// The mount's name.
mount: string;
// The file, relative to the mount.
path: string;
}): Promise<{
bytes_written: number;
mount: string;
path: string;
}>
relay.fs.edit#
Replace text in a file: every edit applies, in order, or none does.
edit(args: {
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
edits: Array<FileEdit>;
// The mount's name.
mount: string;
path: string;
}): Promise<{
applied: Array<AppliedEditResult>;
bytes_written: number;
mount: string;
path: string;
}>
relay.fs.mkdir#
Create a directory in a mount.
mkdir(args: {
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
create_parents?: boolean;
// The mount's name.
mount: string;
path: string;
}): Promise<{
created: boolean;
mount: string;
path: string;
}>
relay.fs.move#
Move or rename a path within one mount.
move(args: {
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
from_path: string;
// The mount's name.
mount: string;
overwrite?: boolean;
to_path: string;
}): Promise<{
from_path: string;
mount: string;
moved: boolean;
to_path: string;
}>
relay.fs.delete#
Delete a path in a mount.
delete(args: {
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
missing_ok?: boolean;
// The mount's name.
mount: string;
path: string;
recursive?: boolean;
}): Promise<{
deleted: boolean;
mount: string;
path: string;
}>
relay.fs.grep#
The lines matching a regular expression in the files under a path in a mount.
grep(args: {
case_sensitive?: boolean;
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
context_lines?: number;
include?: string | null;
max_matches?: number | null;
// The mount's name.
mount: string;
path?: string;
pattern: string;
}): Promise<{
matches: Array<GrepMatch>;
mount: string;
path: string;
truncated: boolean;
}>
relay.fs.hash#
The path, name, size and SHA-256 of every regular file under a directory in a mount, in path order.
hash(args: {
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
// The mount's name.
mount: string;
path: string;
}): Promise<{
files: Array<HashedFile>;
}>
Types#
// How many times one replacement matched.
type AppliedEditResult = {
old_text: string;
replacements: number;
};
// The identifier of a persisted record.
type DocId = string;
// One text replacement in a file: `old_text` must match once, or every time with `replace_all`.
type FileEdit = {
new_text: string;
old_text: string;
replace_all?: boolean;
};
// How a file's content is carried: as UTF-8 text, or as base64 of its bytes.
type FileEncoding = "utf8" | "base64";
// What a filesystem entry is.
type FilesystemEntryKind = "file" | "directory" | "symlink";
// One file, directory or symlink in a Relay filesystem mount.
type FilesystemEntryMeta = {
kind: FilesystemEntryKind;
modified_at: string | null;
name: string;
path: string;
readonly: boolean;
size_bytes: number | null;
};
// One line a search matched.
type GrepMatch = {
line: string;
line_number: number;
path: string;
};
// One hashed file: its mount-relative path, file name, size in bytes and SHA-256.
type HashedFile = {
name: string;
path: string;
// The SHA-256 of the file's bytes, as 64 lowercase hex characters.
sha256: string;
size: number;
};
// One filesystem mount: its name, and whether it refuses writes.
type RelayFilesystemMountInfo = {
name: string;
readonly: boolean;
};
verdalia.api.relay.shell#
relay.shell.run#
Run a command line through the Relay user's shell, in a directory of a mount. A non-zero exit
is answered in exit_code, not thrown.
run(args: {
// The command line the Relay user's shell reads.
command: string;
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
// The mount's name.
mount: string;
// The directory the command runs in, relative to the mount; the mount's root when empty.
path?: string;
// Stop the command after this many seconds, from 1 to 50; the Relay's default when left out.
timeout_seconds?: number | null;
}): Promise<{
duration_ms: number;
exit_code: number | null;
mount: string;
path: string;
shell: string | null;
signal: number | null;
stderr: string;
stderr_truncated: boolean;
stdout: string;
stdout_truncated: boolean;
timed_out: boolean;
}>
relay.shell.exec#
Start a program with its arguments, without a shell, in a directory of a mount. A non-zero
exit is answered in exit_code, not thrown.
exec(args: {
// The program and its arguments, the program first.
argv: Array<string>;
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
// The mount's name.
mount: string;
// The directory the program runs in, relative to the mount; the mount's root when empty.
path?: string;
// Stop the program after this many seconds, from 1 to 50; the Relay's default when left out.
timeout_seconds?: number | null;
}): Promise<{
duration_ms: number;
exit_code: number | null;
mount: string;
path: string;
shell: string | null;
signal: number | null;
stderr: string;
stderr_truncated: boolean;
stdout: string;
stdout_truncated: boolean;
timed_out: boolean;
}>
Types#
// The identifier of a persisted record.
type DocId = string;
verdalia.api.relay.audio#
relay.audio.play#
Play an audio clip on the Relay machine's sound device. Resolves once the Relay starts it.
play(args: {
// The clip's bytes.
clip: Uint8Array;
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
// The clip's media type, such as `audio/mpeg`.
content_type: string;
// The volume, from 0.0 to 1.0; 1.0 when left out.
volume?: number | null;
}): Promise<{
active_clips: number;
clip_id: string;
duration_secs: number | null;
}>
relay.audio.stop#
Stop one playing clip, or every playing clip when no clip_id is given.
stop(args?: {
clip_id?: string | null;
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
}): Promise<{
active_clips: number;
stopped: number;
}>
relay.audio.status#
What the Relay is playing right now.
status(args?: {
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
}): Promise<{
active_clips: Array<ActiveClip>;
stream_open: boolean;
}>
Types#
// One clip the Relay is playing.
type ActiveClip = {
bytes: number;
clip_id: string;
content_type: string;
duration_secs: number | null;
elapsed_secs: number;
};
// The identifier of a persisted record.
type DocId = string;
verdalia.api.relay.hue#
relay.hue.bridge#
Whether a Hue Bridge is paired with the Relay, and whether it answers.
bridge(args?: {
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
}): Promise<{
bridge_id: string | null;
bridge_name: string | null;
configured: boolean;
connected: boolean;
error: string | null;
ip_address: string | null;
}>
relay.hue.lights#
Every light the bridge knows, with its id and current state.
lights(args?: {
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
}): Promise<Array<LightInfo>>
relay.hue.light#
One light's current state.
light(args: {
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
// The light's id, as `lights` gives it.
light_id: string;
}): Promise<{
brightness: number;
color: Color;
on: boolean;
}>
relay.hue.setLight#
Change one light, and answer its resulting state. A field left out is left as it is.
setLight(args: {
// Brightness level (0.0-1.0)
brightness?: number | null;
// Brightness step (-1.0 to 1.0, non-zero), applied to the current level. The bridge
// takes this or `brightness`, never both.
brightness_delta?: number | null;
// Color settings
color?: Color | null;
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
// The light's id, as `lights` gives it.
light_id: string;
// Whether the light should be on. `None` leaves the switch as it is.
on?: boolean | null;
// Transition time in seconds
transition?: number | null;
}): Promise<{
brightness: number;
color: Color;
on: boolean;
}>
relay.hue.groups#
Every room and zone the bridge knows, with the ids of its lights.
groups(args?: {
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
}): Promise<Array<GroupInfo>>
relay.hue.group#
The aggregated state of one room or zone.
group(args: {
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
// The room's or zone's id, as `groups` gives it.
group_id: string;
}): Promise<{
brightness: number;
id: string;
on: boolean;
}>
relay.hue.setGroup#
Change every light in a room or zone, and answer the resulting state. A field left out is left as it is.
setGroup(args: {
// Brightness level (0.0-1.0)
brightness?: number | null;
// Brightness step (-1.0 to 1.0, non-zero), applied to the current level. The bridge
// takes this or `brightness`, never both.
brightness_delta?: number | null;
// Color settings
color?: Color | null;
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
// The room's or zone's id, as `groups` gives it.
group_id: string;
// Whether the light should be on. `None` leaves the switch as it is.
on?: boolean | null;
// Transition time in seconds
transition?: number | null;
}): Promise<{
brightness: number;
id: string;
on: boolean;
}>
relay.hue.scenes#
Every scene the bridge knows, with the room it belongs to and whether it is showing.
scenes(args?: {
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
}): Promise<Array<SceneInfo>>
relay.hue.scene#
One scene's content: what it does to each light, and its palette.
scene(args: {
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
// The scene's id, as `scenes` gives it.
scene_id: string;
}): Promise<{
actions: Array<SceneLightAction>;
active: SceneActive;
auto_dynamic: boolean;
group_id: string | null;
id: string;
image_id: string | null;
last_recall: string | null;
name: string;
palette: Array<PaletteEntry>;
speed: number;
}>
relay.hue.activateScene#
Recall a scene, and answer the scene as it stands afterwards.
activateScene(args: {
// Brightness the scene is recalled at (0.0-1.0), over its own stored levels
brightness?: number | null;
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
// How the bridge plays the scene back; `active` when left out.
mode?: SceneRecallMode;
// The scene's id, as `scenes` gives it.
scene_id: string;
// Fade to the scene over this many seconds
transition?: number | null;
}): Promise<{
actions: Array<SceneLightAction>;
active: SceneActive;
auto_dynamic: boolean;
group_id: string | null;
id: string;
image_id: string | null;
last_recall: string | null;
name: string;
palette: Array<PaletteEntry>;
speed: number;
}>
Types#
// Color representation for lights
type Color = {
hue: number;
saturation: number;
} | {
blue: number;
green: number;
red: number;
} | {
kelvin: number;
};
// The identifier of a persisted record.
type DocId = string;
// Hue group info from Relay
type GroupInfo = {
id: string;
lights: Array<string>;
name: string;
};
// Light info from Relay
type LightInfo = {
brightness: number;
color: Color | null;
id: string;
name: string;
on: boolean;
reachable: boolean;
};
// One colour of a scene's palette, which a dynamic recall cycles between.
type PaletteEntry = {
brightness: number | null;
color: Color;
};
// Whether the bridge reports a scene as the one currently showing.
type SceneActive = "inactive" | "static" | "dynamic_palette" | "unknown";
// Hue scene info from Relay. The fields past `group_id` are absent from an older relay.
type SceneInfo = {
active: SceneActive;
auto_dynamic: boolean;
group_id: string | null;
id: string;
image_id: string | null;
last_recall: string | null;
name: string;
speed: number;
};
// What a scene does to one light.
type SceneLightAction = {
brightness: number | null;
color: Color | null;
light_id: string;
on: boolean;
};
// How the bridge plays a scene back.
type SceneRecallMode = "active" | "dynamic_palette" | "static";
verdalia.api.relay.coding#
relay.coding.list#
Every coding session of the workspace, with the hosts and projects they are grouped under; each host's projects are first brought in step with what it reports.
list(): Promise<{
hosts: Array<HostView>;
projects: Array<CodingProjectView>;
sessions: Array<CodingSessionView>;
// Every coding workspace of the workspace, those holding no session included.
workspaces: Array<CodingWorkspaceView>;
}>
relay.coding.get#
One coding session as stored, without reaching its Relay.
get(args: {
// The coding session's Verdalia id.
session_id: DocId;
}): Promise<{
// The agent session that claims it, when one does.
agent_claim?: DocId | null;
// The coding workspace the session belongs to.
coding_workspace_id: DocId;
connection_id: DocId;
created_at: string;
id: DocId;
// Where in its project the session runs.
location: CodingLocationView;
project_id: DocId;
// The Paseo workspace a Paseo session runs in, by Paseo's workspace id, as its coding
// workspace keeps it; `null` for mount sessions. Sessions sharing one are grouped under it.
project_workspace: string | null;
provider: AgentKind;
// The provider's own id for the session.
provider_session_id: SessionRef;
state: CodingSessionState;
title?: string | null;
updated_at: string;
}>
relay.coding.findByProviderId#
The coding session a provider's own session is on a Relay, or null when no coding
session holds it.
findByProviderId(args: {
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
// The provider that runs the session.
provider: AgentKind;
// The provider's own id for the session.
provider_session_id: SessionRef;
}): Promise<CodingSessionView | null>
relay.coding.importable#
One page of a mount provider's stored sessions in a project directory, the imported ones marked.
importable(): Promise<{
next_cursor?: string | null;
sessions: Array<ImportCandidate>;
}>
relay.coding.import#
Adds a mount provider's stored session as a coding session; refused when already imported.
import(): Promise<{
// The agent session that claims it, when one does.
agent_claim?: DocId | null;
// The coding workspace the session belongs to.
coding_workspace_id: DocId;
connection_id: DocId;
created_at: string;
id: DocId;
// Where in its project the session runs.
location: CodingLocationView;
project_id: DocId;
// The Paseo workspace a Paseo session runs in, by Paseo's workspace id, as its coding
// workspace keeps it; `null` for mount sessions. Sessions sharing one are grouped under it.
project_workspace: string | null;
provider: AgentKind;
// The provider's own id for the session.
provider_session_id: SessionRef;
state: CodingSessionState;
title?: string | null;
updated_at: string;
}>
relay.coding.start#
Starts a coding session: OpenCode (opencode), Oh My Pi (omp), or Claude Code (claude)
in a directory of a mount project, or paseo in a Paseo project.
A Paseo start may fork from a turn of another Paseo session.
start(): Promise<{
read: SessionRead;
session: CodingSessionView;
}>
relay.coding.open#
Opens a coding session, reopening it on its Relay when it is not running, with every event
of its last limit items (all when omitted): messages, tool calls, plans, requests.
open(args: {
// How many of the last items to read every event of; omitted, every one.
limit?: number | null;
// The coding session's Verdalia id.
session_id: DocId;
}): Promise<{
read: SessionRead;
session: CodingSessionView;
}>
relay.coding.read#
A coding session as it runs on its Relay now, with every event, without reopening it; refused when it is not running.
read(args: {
// The coding session's Verdalia id.
session_id: DocId;
}): Promise<{
read: SessionRead;
session: CodingSessionView;
}>
relay.coding.history#
The page of a running session's older history just before a cursor its read or an
earlier page gave as older.
history(args: {
// Where the page ends: the `older` cursor a read or an earlier page gave.
before: HistoryCursor;
// The coding session's Verdalia id.
session_id: DocId;
}): Promise<{
events: Array<HistoryEvent>;
older: HistoryCursor | null;
}>
relay.coding.commands#
The slash commands a running session's agent accepts, or that its provider cannot tell them.
commands(args: {
// The coding session's Verdalia id.
session_id: DocId;
}): Promise<{
commands: Array<AvailableCommand>;
state: "listed";
} | {
state: "unsupported";
}>
relay.coding.prompt#
Sends a message, opening the session on its Relay when it is not running. Resolves with the
message's id once the Relay has it (message_id, minted when omitted); its prompt events
name that id, and the turn's outcome arrives as session events. A Relay too old for the
send route refuses as needing an update.
while_running: 'interrupt' stops the running turn first and runs the message as the next
one; only Paseo sessions take it.
prompt(args: {
// Files, issues, pull requests and review comments to send to a Paseo agent.
attachments?: Array<PromptAttachment>;
images?: Array<PromptImage>;
message_id?: ItemId | null;
// The coding session's Verdalia id.
session_id: DocId;
text: string;
while_running?: WhileRunning;
}): Promise<{
message_id: ItemId;
}>
relay.coding.cancel#
Cancels the turn the running session is working on, dropping messages not yet delivered;
resolves with the id of the message whose turn it was, or null.
cancel(args: {
// The coding session's Verdalia id.
session_id: DocId;
}): Promise<{
message_id: ItemId | null;
}>
relay.coding.answerPermission#
Answers a permission request of the running session with one of the options it offered.
answerPermission(args: {
option_id: PermissionOptionId;
request_id: PermissionRequestId;
// The coding session's Verdalia id.
session_id: DocId;
}): Promise<{
// How the request ended, as the relay's event log records it. An older relay sends none.
resolution?: PermissionResolution | null;
resolved: boolean;
}>
relay.coding.answerQuestion#
Answers a question request of the running session: one answer per question, in the request's order.
answerQuestion(args: {
// One answer per question, in the request's order.
answers: Array<ScriptQuestionAnswer>;
// The pending question request.
request_id: QuestionRequestId;
// The coding session's Verdalia id.
session_id: DocId;
}): Promise<{
// How the request ended, as the relay's event log records it. An older relay sends none.
resolution?: QuestionResolution | null;
resolved: boolean;
}>
relay.coding.declineQuestion#
Declines a question request of the running session.
declineQuestion(args: {
// The pending question request.
request_id: QuestionRequestId;
// The coding session's Verdalia id.
session_id: DocId;
}): Promise<{
// How the request ended, as the relay's event log records it. An older relay sends none.
resolution?: QuestionResolution | null;
resolved: boolean;
}>
relay.coding.setConfig#
Changes a config option of the running session, answering the agent's full set after it.
setConfig(args: {
config_id: ConfigId;
// The coding session's Verdalia id.
session_id: DocId;
value: ConfigValue;
}): Promise<{
config_options: Array<ConfigOption>;
}>
relay.coding.rename#
Retitles a coding session, opening it if needed and renaming it with its provider where the provider can.
rename(args: {
// The coding session's Verdalia id.
session_id: DocId;
// The new title.
title: string;
}): Promise<{
// The agent session that claims it, when one does.
agent_claim?: DocId | null;
// The coding workspace the session belongs to.
coding_workspace_id: DocId;
connection_id: DocId;
created_at: string;
id: DocId;
// Where in its project the session runs.
location: CodingLocationView;
project_id: DocId;
// The Paseo workspace a Paseo session runs in, by Paseo's workspace id, as its coding
// workspace keeps it; `null` for mount sessions. Sessions sharing one are grouped under it.
project_workspace: string | null;
provider: AgentKind;
// The provider's own id for the session.
provider_session_id: SessionRef;
state: CodingSessionState;
title?: string | null;
updated_at: string;
}>
relay.coding.close#
Stops a coding session on its Relay; the session stays. A Paseo agent runs on in Paseo.
close(args: {
// The coding session's Verdalia id.
session_id: DocId;
}): Promise<{
// The agent session that claims it, when one does.
agent_claim?: DocId | null;
// The coding workspace the session belongs to.
coding_workspace_id: DocId;
connection_id: DocId;
created_at: string;
id: DocId;
// Where in its project the session runs.
location: CodingLocationView;
project_id: DocId;
// The Paseo workspace a Paseo session runs in, by Paseo's workspace id, as its coding
// workspace keeps it; `null` for mount sessions. Sessions sharing one are grouped under it.
project_workspace: string | null;
provider: AgentKind;
// The provider's own id for the session.
provider_session_id: SessionRef;
state: CodingSessionState;
title?: string | null;
updated_at: string;
}>
relay.coding.remove#
Removes a coding session from Verdalia: a mount provider keeps its session on the machine, a Paseo agent is archived in Paseo.
remove(args: {
// The coding session's Verdalia id.
session_id: DocId;
}): Promise<null>
relay.coding.unlinkProject#
Unlinks a coding project: it and its sessions leave Verdalia and nothing on the machine changes. A Relay that still reports it brings it back on the next listing.
unlinkProject(args: {
// The coding project's Verdalia id.
project_id: DocId;
}): Promise<null>
Types#
// One event of a session. Ordering and resend live in the relay's outbox, not here. `at` is
// when it happened: the provider's own time for an event from its timeline, else the relay's.
type AgentControlEnvelope = {
at: string;
event: AgentControlEvent;
// Absent from a relay older than timeline places, and for an event no timeline holds.
place?: TimelinePlace | null;
};
// Something one agent session did or had done to it.
type AgentControlEvent = SessionOpened & {
type: "session_opened";
} | {
type: "history_replay_started";
} | {
type: "history_replay_finished";
} | {
message_id: ItemId;
sender: MessageSender | null;
type: "prompt_queued";
} | {
message_id: ItemId;
text: string;
type: "prompt_started";
} | {
message_id: ItemId;
text: string;
type: "prompt_steered";
} | {
message_id: ItemId;
type: "cancel_requested";
} | {
message_id: ItemId;
stop_reason: StopReason;
type: "prompt_finished";
} | {
message_id: ItemId;
type: "prompt_recorded";
} | {
error: PromptError;
message_id: ItemId;
type: "prompt_failed";
} | {
exit: AgentExit;
expected: boolean;
type: "agent_exited";
} | {
type: "session_closed";
} | MessageChunk & {
type: "user_message_chunk";
} | MessageChunk & {
type: "agent_message_chunk";
} | MessageChunk & {
type: "agent_thought_chunk";
} | ToolCallView & {
type: "tool_call";
} | ToolCallPatch & {
type: "tool_call_update";
} | {
entries: Array<PlanEntry>;
item_id: ItemId;
type: "plan";
} | {
commands: Array<AvailableCommand>;
type: "available_commands_update";
} | {
mode_id: ModeId;
type: "current_mode_update";
} | {
config_options: Array<ConfigOption>;
type: "config_option_update";
} | {
title?: string | null;
type: "session_info_update";
updated_at?: string | null;
} | {
// Cached input tokens in the latest report that included them.
cached?: number | null;
cost?: Cost | null;
// What the reported cost covers, when known.
cost_span?: UsageSpan | null;
// Input tokens in the latest report that included them.
input?: number | null;
// Output tokens in the latest report that included them.
output?: number | null;
size: number;
// What the input, cached and output token counts cover, when known.
token_span?: UsageSpan | null;
type: "usage_update";
used: number;
} | {
capabilities: AgentFeatures;
type: "capabilities_update";
} | {
background: Array<BackgroundWorkView>;
delegates: Array<DelegateView>;
type: "activity_update";
} | PermissionRequest & {
type: "permission_requested";
} | {
item_id: ItemId;
request_id: PermissionRequestId;
resolution: PermissionResolution;
type: "permission_resolved";
} | QuestionRequest & {
type: "question_requested";
} | {
item_id: ItemId;
request_id: QuestionRequestId;
resolution: QuestionResolution;
type: "question_resolved";
} | {
request: QuestionRequest;
resolution: QuestionResolution;
type: "question_restated";
} | {
item_id: ItemId;
level: NoticeLevel;
message: string;
type: "notice";
} | {
item_id: ItemId;
pre_tokens?: number | null;
status: CompactionStatus;
trigger?: CompactionTrigger | null;
type: "compaction";
} | {
event: AgentMessageEvent;
item_id: ItemId;
sender: AgentMessageSender;
text: string;
tool_call_id: ToolCallId;
type: "agent_message";
} | {
type: "history_reset";
} | {
error: string;
frame: FrameKind;
type: "frame_undecodable";
};
// How the agent behind a session ended.
type AgentExit = {
code: number | null;
kind: "process";
signal: number | null;
stderr_tail: string;
} | {
kind: "disconnected";
reason: string;
};
// The optional session features the agent advertised.
type AgentFeatures = {
// Prompts may carry files, issues and pull requests.
attachments: boolean;
close: boolean;
// The session's history can be searched and its prompts listed.
find: boolean;
// A new session can start with this one's conversation up to a turn.
fork: boolean;
// The agent accepts images in a prompt.
images: boolean;
// A message can stop the running turn and start the next one.
interrupt: boolean;
list: boolean;
load: boolean;
// The coding agent account's plan and quota usage can be read.
plan_usage: boolean;
// The agent can be reloaded in its coding agent.
reload: boolean;
// Conversation and files can be rewound together.
rewind_both: boolean;
// The conversation can be rewound to a user message.
rewind_conversation: boolean;
// The files the agent changed can be put back as they were before a user message.
rewind_files: boolean;
};
// The agent program behind a session, as it introduced itself.
type AgentInfo = {
name: string;
title?: string | null;
version?: string | null;
};
// Which coding agent program runs, or stores, a session.
type AgentKind = "opencode" | "omp" | "claude" | "paseo";
// What another agent's message to this one was.
type AgentMessageEvent = "message" | "finished" | "errored" | "permission_required" | "closed";
// The agent that sent a message to this one.
type AgentMessageSender = {
id: string;
title?: string | null;
};
// A path the agent reported, inside the session's mount or elsewhere on the host.
type AgentPath = {
path: string;
scope: "mount";
} | {
path: string;
scope: "host";
};
// A slash command the agent accepts.
type AvailableCommand = {
description: string;
input_hint?: string | null;
name: string;
};
// One item of background work, as its coding agent named it.
type BackgroundWorkId = string;
// The kind of background work; unknown kinds read as `other`.
type BackgroundWorkKind = "shell" | "monitor" | "other";
// One item of background work the coding agent reports.
type BackgroundWorkView = {
// Whether the relay can stop the item.
can_stop: boolean;
command?: string | null;
description?: string | null;
id: BackgroundWorkId;
kind: BackgroundWorkKind;
started_at: string;
};
// Where in its project a coding session runs.
type CodingLocationView = {
directory: string;
kind: "mount";
} | {
agent_provider: string;
branch: string | null;
kind: "paseo";
model: string | null;
workspace_name: string | null;
};
// What backs a coding project: a mount of the host, or a Paseo project on it.
type CodingProjectSourceView = {
kind: "mount";
mount: string;
read_only: boolean;
} | {
kind: "paseo";
project_id: string;
root_path: string;
};
// One root of the coding-session tree on a host.
type CodingProjectView = {
// The chosen header colour, or the stable default for this backing.
color: "ruby" | "amber" | "forest" | "emerald" | "teal" | "sapphire" | "amethyst" | "lotus" | "tangerine" | "white" | string;
connection_id: DocId;
id: DocId;
name: string;
source: CodingProjectSourceView;
};
// What a coding session is doing now: a mount session as its relay runs it, a Paseo session as
// Paseo reports its agent.
type CodingSessionState = "off" | "working" | "ready" | "permission" | "question" | "error" | "idle";
// One coding session, with its live state.
type CodingSessionView = {
// The agent session that claims it, when one does.
agent_claim?: DocId | null;
// The coding workspace the session belongs to.
coding_workspace_id: DocId;
connection_id: DocId;
created_at: string;
id: DocId;
// Where in its project the session runs.
location: CodingLocationView;
project_id: DocId;
// The Paseo workspace a Paseo session runs in, by Paseo's workspace id, as its coding
// workspace keeps it; `null` for mount sessions. Sessions sharing one are grouped under it.
project_workspace: string | null;
provider: AgentKind;
// The provider's own id for the session.
provider_session_id: SessionRef;
state: CodingSessionState;
title?: string | null;
updated_at: string;
};
// What a coding workspace is, lowered once from its project's kind and its row.
type CodingWorkspaceSourceView = {
branch: string | null;
kind: "paseo";
name: string | null;
paseo_workspace_id: string;
} | {
kind: "session";
};
// A coding workspace as the tree shows it: the rail's item.
type CodingWorkspaceView = {
// When the workspace was made, as stored.
created_at: string;
id: DocId;
pinned: boolean;
project_id: DocId;
source: CodingWorkspaceSourceView;
};
// Where a compaction is.
type CompactionStatus = "loading" | "completed";
// What started a compaction.
type CompactionTrigger = "auto" | "manual";
// Whether a ready host's relay has computer use (the `relay_computer_use` tools) turned on.
type ComputerUse = "on" | "off" | "unknown";
// What a config option selects, for placing it; `Other` carries any category the relay adds
// later or an agent's own `_`-prefixed one.
type ConfigCategory = "mode" | "model" | "model_config" | "thought_level" | string;
// One value a select option can take.
type ConfigChoice = {
description?: string | null;
name: string;
value: ConfigValueId;
};
// A named group of select values.
type ConfigChoiceGroup = {
group: ConfigGroupId;
name: string;
options: Array<ConfigChoice>;
};
// The values a select option offers, flat or in named groups.
type ConfigChoices = {
kind: "ungrouped";
options: Array<ConfigChoice>;
} | {
groups: Array<ConfigChoiceGroup>;
kind: "grouped";
};
// How a config option is set.
type ConfigControl = {
choices: ConfigChoices;
current_value: ConfigValueId;
type: "select";
} | {
current_value: boolean;
type: "boolean";
};
// A named group of select values.
type ConfigGroupId = string;
// One session setting.
type ConfigId = string;
// One session setting the agent exposes, such as its model or mode.
type ConfigOption = {
category?: ConfigCategory | null;
control: ConfigControl;
description?: string | null;
id: ConfigId;
name: string;
};
// The new value of a config option.
type ConfigValue = {
type: "value_id";
value: ConfigValueId;
} | {
type: "boolean";
value: boolean;
};
// One value a select setting can take.
type ConfigValueId = string;
// Message or tool content. Binary payloads are dropped by the relay; their kind and address
// are kept.
type ContentPart = {
text: string;
type: "text";
} | {
mime_type?: string | null;
name: string;
title?: string | null;
type: "resource_link";
uri: string;
} | {
mime_type?: string | null;
text?: string | null;
type: "resource";
uri: string;
} | {
mime_type: string;
type: "image";
uri?: string | null;
} | {
mime_type: string;
type: "audio";
} | {
type: "unsupported";
};
// An agent's reported cost, in its stated currency.
type Cost = {
amount: number;
currency: string;
};
// A new coding session to start in a coding project, by the provider that runs it: a mount
// provider in a directory of a mount project, or Paseo in a Paseo project.
type CreateCodingSession = {
directory: string;
project_id: DocId;
provider: "opencode";
} | {
directory: string;
project_id: DocId;
provider: "omp";
} | {
directory: string;
project_id: DocId;
provider: "claude";
} | {
agent_provider: string;
// The turn of a Paseo coding session to fork from: the new agent starts with the conversation up to it.
// Boxed to keep the other variants small.
fork?: ForkRequest | null;
mode?: string | null;
model?: string | null;
placement: PaseoPlacement;
// The saved Paseo profile the session starts from, by its id: Paseo applies that
// profile's own options with the given model, mode and thinking.
profile?: string | null;
project_id: DocId;
// Boxed: a prompt is far larger than every other variant's fields.
prompt?: PromptRequest | null;
provider: "paseo";
thinking?: string | null;
};
// One subagent, as its coding agent named it.
type DelegateId = string;
// The state of a subagent's work as the coding agent reports it.
type DelegateStatus = "running" | "completed" | "failed" | "canceled";
// An agent a coding agent handed work to.
type DelegateView = {
description?: string | null;
id: DelegateId;
status: DelegateStatus;
title?: string | null;
};
// How an update changes a tool call's detail.
type DetailChange = {
detail: ToolDetail;
op: "set";
} | {
op: "clear";
};
// Whether a diff line was added, removed or unchanged.
type DiffLineKind = "add" | "remove" | "context";
// The comparison used to read a diff or address review comments.
type DiffMode = "uncommitted" | "base";
// The side of the diff that a review comment's line number addresses.
type DiffSide = "old" | "new";
// The identifier of a persisted record.
type DocId = string;
// A forge supported by Paseo for issue and change request attachments.
type Forge = "github" | "gitlab" | "gitea" | "forgejo" | "codeberg";
// A pull or merge request. Scripts send its item fields as for an issue, plus the base and
// head branch names if available.
type ForgeChangeReference = {
base_ref_name?: string | null;
body?: string | null;
forge: Forge;
head_ref_name?: string | null;
number: number;
project_path?: string | null;
title: string;
url: string;
};
// A forge issue. Scripts send the item's forge, number, title and URL, with its body and
// project path if available.
type ForgeReference = {
body?: string | null;
forge: Forge;
number: number;
project_path?: string | null;
title: string;
url: string;
};
// A turn of a Paseo coding session, by the place of one of its items as its events give it.
type ForkRequest = {
// The Verdalia id of the coding session to fork.
coding_session_id: DocId;
// The `epoch` of that item's `place`.
epoch: string;
// The `seq` of that item's `place`.
seq: number;
};
// Which kind of frame the relay could not read.
type FrameKind = "line" | "session_update" | "permission_request" | "response";
// Where a page of older history ends; opaque to everyone but the session that made it.
type HistoryCursor = string;
// One event of a page of earlier history: its time and place when the relay sent them; an
// older relay sends bare events, which have neither.
type HistoryEvent = {
at: string | null;
event: AgentControlEvent;
place?: TimelinePlace | null;
};
// Whether a host can run coding sessions now.
type HostState = {
state: "offline";
} | {
state: "outdated";
} | {
computer_use: ComputerUse;
mounts: Array<MountView>;
paseo: PaseoHostState | null;
providers: Array<AgentKind>;
state: "ready";
unavailable: Array<UnavailableProvider>;
};
// One relay connection of the workspace, as the session tree heads a group with it.
type HostView = {
connection_id: DocId;
// The connection's display name.
name: string;
state: HostState;
};
// One stored session a user can import.
type ImportCandidate = {
// The coding session it already is, when it was imported before.
imported?: DocId | null;
// The provider's own id for the session.
provider_session_id: SessionRef;
title?: string | null;
// When the provider last changed it, as the provider wrote it.
updated_at?: string | null;
};
// A mount provider's stored session to add to Verdalia as a coding session.
type ImportCodingSession = {
// The path inside the mount; `""` is its root.
directory: string;
// The mount project the session lives in.
project_id: DocId;
// The provider that stores the session.
provider: MountProvider;
// The provider's own id for the session.
provider_session_id: SessionRef;
// The title to give it; `None` keeps the provider's.
title?: string | null;
};
// One page of a mount provider's stored sessions in a project directory, to import from.
type ImportQuery = {
// The page to read, as the previous page's `next_cursor` gave it; `None` reads the first.
cursor?: string | null;
// The path inside the mount; `""` is its root.
directory: string;
// The mount project to list in.
project_id: DocId;
// The provider whose stored sessions are listed.
provider: MountProvider;
};
// One item of a session (a message, thought, tool call, plan, permission, question,
// notice, compaction or peer message), minted by the producer when the item opens and
// never reused while the relay has the session open.
type ItemId = string;
// An append to a message item, with the message id exactly as the agent sent it.
type MessageChunk = {
content: ContentPart;
item_id: ItemId;
message_id?: MessageId | null;
// The item's length before this chunk: UTF-16 code units of its text, plus one per
// non-text part.
offset: number;
};
// One message, shared by every chunk of it.
type MessageId = string;
// Who sent a user message through Verdalia: the person signed in, an agent session, a
// workflow run, or an MCP client. The kind only, never an identity.
type MessageSender = "person" | "agent" | "workflow" | "mcp_client";
// One mode a session can be switched to.
type Mode = {
description?: string | null;
id: ModeId;
name: string;
};
// One session mode.
type ModeId = string;
// The session's modes and the one in effect.
type ModeState = {
available_modes: Array<Mode>;
current_mode_id: ModeId;
};
// A mount provider, whose stored sessions can be listed and imported.
type MountProvider = "opencode" | "omp" | "claude";
// One mount of a ready host.
type MountView = {
name: string;
read_only: boolean;
};
// How serious a notice is.
type NoticeLevel = "info" | "warning" | "error";
// How a session came to be open.
type OpenMode = "new" | "load";
// Whether a ready host's relay is connected to Paseo, and why not.
type PaseoHostState = {
state: "connected";
} | {
reason: string;
state: "disconnected";
};
// Where in its Paseo project a new Paseo session runs.
type PaseoPlacement = {
kind: "existing_workspace";
workspace_id: string;
} | {
kind: "new_local";
} | {
kind: "new_worktree";
slug?: string | null;
worktree: PaseoWorktree;
};
// How a new Paseo worktree gets its branch.
type PaseoWorktree = {
base?: string | null;
mode: "branch_off";
new_branch: string;
} | {
branch: string;
mode: "checkout_branch";
} | {
forge?: string | null;
mode: "checkout_pr";
pr_number: number;
};
// One answer the agent offered to a permission request.
type PermissionChoice = {
kind: PermissionOptionKind;
name: string;
option_id: PermissionOptionId;
};
// One answer a permission request offers.
type PermissionOptionId = string;
// What answering with a permission option means.
type PermissionOptionKind = "allow_once" | "allow_always" | "reject_once" | "reject_always";
// The agent asks before running a tool; the options are verbatim and in order.
type PermissionRequest = {
item_id: ItemId;
options: Array<PermissionChoice>;
request_id: PermissionRequestId;
tool_call: ToolCallPatch;
};
// A permission request, as the agent numbered it.
type PermissionRequestId = string;
// How a permission request ended.
type PermissionResolution = {
option_id: PermissionOptionId;
outcome: "selected";
} | {
outcome: "cancelled";
} | {
outcome: "withdrawn";
} | {
outcome: "agent_exited";
} | {
outcome: "unknown";
};
// One step of the agent's plan.
type PlanEntry = {
content: string;
priority: PlanEntryPriority;
status: PlanEntryStatus;
};
// How much a plan step matters.
type PlanEntryPriority = "high" | "medium" | "low";
// Where a plan step is.
type PlanEntryStatus = "pending" | "in_progress" | "completed";
// An attachment Paseo renders into the agent's prompt: a file, forge item or diff review.
// Send a forge item's fields directly, or use the answer from the page's upload route for a file.
type PromptAttachment = UploadedFile & {
type: "uploaded_file";
} | ForgeReference & {
type: "forge_issue";
} | ForgeChangeReference & {
type: "forge_change_request";
} | ReviewAttachment & {
type: "review";
};
// Why a prompt ended without a stop reason.
type PromptError = {
code: number;
kind: "rpc";
message: string;
} | {
error: string;
kind: "undecodable";
} | {
kind: "agent_exited";
} | {
kind: "dropped";
} | {
code?: string | null;
kind: "provider";
message: string;
};
// One image of a prompt: its type and its bytes in standard base64.
type PromptImage = {
// The image's bytes.
data: Uint8Array;
mime_type: PromptImageType;
};
// The type of a prompt image, by its MIME type; any type a prompt may not carry reads as
// [`Self::Unsupported`], so it can be refused by name.
type PromptImageType = "image/jpeg" | "image/png" | "image/webp";
// A prompt's text, images and attachments. The body of a Paseo start request's `prompt`, and
// the part of [`SendMessageRequest`] that the user wrote. `message_id` is the id the page
// minted for the message; the backend mints one when a caller names none.
type PromptRequest = {
// Files, issues, pull requests and review comments to send to a Paseo agent.
attachments?: Array<PromptAttachment>;
images?: Array<PromptImage>;
message_id?: ItemId | null;
text: string;
while_running?: WhileRunning;
};
// One question of a [`QuestionRequest`].
type Question = {
// Whether the question may be left unanswered.
allow_empty: boolean;
// Whether an answer in the user's own words is taken beside the options. A question
// without options takes only one.
allow_other: boolean;
// Extra information shown below the question.
detail?: string | null;
// What declining the request is called, when the agent names it.
dismiss_label?: string | null;
// A short name for the question, when the agent gave one.
header?: string | null;
// An address the user is asked to open.
link?: WebLink | null;
// Whether more than one option may be picked.
multi_select: boolean;
options: Array<QuestionOption>;
// What the own-words field shows while empty.
placeholder?: string | null;
question: string;
};
// The user's answer to one question: the labels picked, in the order picked, and any
// answer in their own words.
type QuestionAnswer = {
custom?: string | null;
selected: Array<string>;
};
// One option a question offers, picked by its label.
type QuestionOption = {
// What picking it means, when the agent says more than its label.
description?: string | null;
label: string;
// Preformatted text that shows what the option would produce.
preview?: string | null;
};
// The agent asks the user something: one or more questions, each answered by picking among its
// options, in its own words, or both, as the question allows. Verbatim and in order.
type QuestionRequest = {
// What the agent says around its questions, when it says anything.
description?: string | null;
// What the agent says before its questions.
intro?: string | null;
item_id: ItemId;
questions: Array<Question>;
request_id: QuestionRequestId;
// The request's own title, when the agent gave one.
title?: string | null;
};
// A question request, as the agent numbered it.
type QuestionRequestId = string;
// How a question request ended.
type QuestionResolution = {
// Exactly as the agent received it; `None` when Paseo did not report that answer.
answers: Array<string | null>;
// The same answers lowered once by the relay: what was picked and the own words.
// `None` when Paseo did not report the answer or it was empty; empty from an older relay.
given: Array<QuestionAnswer | null>;
outcome: "answered";
} | {
outcome: "declined";
} | {
outcome: "withdrawn";
} | {
outcome: "agent_exited";
} | {
outcome: "unknown";
};
// Review comments from one comparison, sent to the coding agent with a prompt.
type ReviewAttachment = {
// The branch used for a comparison against the base.
base_ref?: string | null;
// The comments to send as one review block.
comments: Array<ReviewComment>;
// The checkout's directory on the Paseo computer.
cwd: string;
// Which comparison the comments refer to.
mode: DiffMode;
};
// A comment on a specific line of a file's diff, with the context it was written against.
type ReviewComment = {
// The comment for the coding agent.
body: string;
// The diff hunk and nearby lines at the time of the comment.
context: ReviewContext;
// The file's path as shown in the diff.
file_path: string;
// The one-based line number on that side of the diff.
line_number: number;
// Which revision the line number addresses.
side: DiffSide;
};
// A review comment's target line and surrounding context from the same hunk.
type ReviewContext = {
// The unified diff header of the hunk.
hunk_header: string;
// Context lines in their order in the diff.
lines: Array<ReviewLine>;
// The line the comment addresses.
target_line: ReviewLine;
};
// A line captured from the diff for a review comment.
type ReviewLine = {
// The line's text without a diff marker.
content: string;
// One-based line number after the change, or null for a removed line.
new_line_number?: number | null;
// One-based line number before the change, or null for an added line.
old_line_number?: number | null;
// Whether the line was added, removed or unchanged.
type: DiffLineKind;
};
// A script's answer to one question: the labels picked, in the order picked, and any answer
// in its own words. Strict, unlike the relay's `QuestionAnswer`, so a misspelt field throws.
type ScriptQuestionAnswer = {
// An answer in the script's own words, where the question takes one.
custom?: string | null;
// The labels of the options picked, in the order picked.
selected?: Array<string>;
};
// Which search a search tool call ran.
type SearchTool = "search" | "grep" | "glob" | "web_search";
// Where a session runs, by how its provider places sessions.
type SessionLocation = {
mount: string;
path: string;
scope: "mount";
} | {
branch: string | null;
model: string | null;
project_id: string;
provider: string;
scope: "paseo";
workspace_id: string;
};
// A session is open and accepts prompts.
type SessionOpened = {
agent?: AgentInfo | null;
capabilities: AgentFeatures;
config_options: Array<ConfigOption>;
mode: OpenMode;
modes?: ModeState | null;
session_id: SessionRef;
};
// `GET /api/coding_agents/sessions/:id`: a running session, its state now and its events.
type SessionRead = {
agent?: AgentInfo | null;
agent_kind: AgentKind;
available_commands: Array<AvailableCommand>;
background: Array<BackgroundWorkView>;
capabilities: AgentFeatures;
config_options: Array<ConfigOption>;
delegates: Array<DelegateView>;
// The events in the read's [`SessionWindow`], oldest first and compacted: consecutive
// chunks of one item are one entry.
events: Array<AgentControlEnvelope>;
exit?: AgentExit | null;
location: SessionLocation;
modes?: ModeState | null;
// Where a Paseo session's history before the relay's events begins, when the session
// pages it; `None` when the relay's events are the whole history.
older: HistoryCursor | null;
open_mode?: OpenMode | null;
pending_permissions: Array<PermissionRequest>;
// Question requests asked and not yet resolved, oldest first. A relay older than
// question events sends none.
pending_questions: Array<QuestionRequest>;
session_id: SessionRef;
status: SessionStatus;
title?: string | null;
updated_at?: string | null;
usage?: UsageView | null;
// User messages the relay holds until the agent takes them, in arrival order. A relay
// older than waiting messages sends none.
waiting: Array<WaitingMessage>;
};
// A session as its provider names it: unique only among one provider's sessions.
type SessionRef = string;
// Where a session is in its life.
type SessionStatus = "idle" | "prompting" | "closed" | "exited";
// Why the agent stopped working on a prompt.
type StopReason = "end_turn" | "max_tokens" | "max_turn_requests" | "refusal" | "cancelled";
// A terminal a tool call runs in.
type TerminalId = string;
// Where an event sits in a Paseo agent's timeline: the timeline's epoch, the sequence number
// Paseo gave the row or live event it comes from, and the turn it belongs to when Paseo names one.
type TimelinePlace = {
epoch: string;
seq: number;
turn?: string | null;
};
// One tool call within a session.
type ToolCallId = string;
// The fields of a tool call an update changed, forwarded unmerged.
type ToolCallPatch = {
content?: Array<ToolContent> | null;
// Absent leaves the call's detail as it was; otherwise the change to make to it.
detail?: DetailChange | null;
item_id: ItemId;
kind?: ToolKind | null;
locations?: Array<ToolLocation> | null;
name?: string | null;
raw_input?: unknown;
status?: ToolCallStatus | null;
title?: string | null;
tool_call_id: ToolCallId;
};
// Where a tool call is in its life.
type ToolCallStatus = "pending" | "in_progress" | "completed" | "failed";
// A tool call as the agent first reported it.
type ToolCallView = {
content: Array<ToolContent>;
// What the call does, structured, when the agent reports it so.
detail?: ToolDetail | null;
item_id: ItemId;
kind: ToolKind;
locations: Array<ToolLocation>;
name?: string | null;
raw_input?: unknown;
status: ToolCallStatus;
title: string;
tool_call_id: ToolCallId;
};
// What a tool call produced.
type ToolContent = {
content: ContentPart;
type: "content";
} | {
new_text: string;
old_text?: string | null;
path: AgentPath;
type: "diff";
} | {
terminal_id: TerminalId;
type: "terminal";
};
// What a tool call does, structured by the kind of work.
type ToolDetail = {
command: string;
cwd?: AgentPath | null;
exit_code?: number | null;
output?: string | null;
type: "shell";
} | {
content?: string | null;
limit?: number | null;
offset?: number | null;
path: AgentPath;
type: "read";
} | {
new_text?: string | null;
old_text?: string | null;
path: AgentPath;
type: "edit";
unified_diff?: string | null;
} | {
content?: string | null;
path: AgentPath;
type: "write";
} | {
content?: string | null;
matches?: number | null;
paths: Array<AgentPath>;
query: string;
tool?: SearchTool | null;
type: "search";
} | {
result?: string | null;
status?: number | null;
type: "fetch";
url: string;
} | {
branch: string;
commands: Array<string>;
log: string;
path: AgentPath;
type: "worktree_setup";
};
// What kind of work a tool call does.
type ToolKind = "read" | "edit" | "delete" | "move" | "search" | "execute" | "think" | "fetch" | "switch_mode" | "other";
// A place a tool call touched.
type ToolLocation = {
line?: number | null;
path: AgentPath;
};
// An enabled mount provider whose command could not be found, with the relay's explanation.
type UnavailableProvider = {
message: string;
provider: AgentKind;
};
// A file stored on the Paseo computer. Scripts send the fields exactly as the page's upload
// route answered them; the scripting API does not upload files.
type UploadedFile = {
file_name: string;
id: string;
mime_type: string;
path: string;
size: number;
};
// What a usage report's figures cover.
type UsageSpan = "last_turn" | "session";
// The agent's latest context-window report.
type UsageView = {
// Cached input tokens in the latest report that included them.
cached?: number | null;
cost?: Cost | null;
// What the reported cost covers, when known.
cost_span?: UsageSpan | null;
// Input tokens in the latest report that included them.
input?: number | null;
// Output tokens in the latest report that included them.
output?: number | null;
size: number;
// What the input, cached and output token counts cover, when known.
token_span?: UsageSpan | null;
used: number;
};
// A user message the relay holds until the agent takes it, and who sent it; `sender` is
// `None` for a session start's first prompt, whose request names no sender.
type WaitingMessage = {
message_id: ItemId;
sender: MessageSender | null;
};
// An absolute `http` or `https` address, which a person may be asked to open: never a
// `javascript:`, `file:` or other scheme. Validated once, by its deserialization; written
// as the URL.
type WebLink = string;
// What a message does to a turn already running: joins it (the default), or stops it and
// runs as the next turn. Only Paseo sessions take `interrupt`.
type WhileRunning = "steer" | "interrupt";
verdalia.api.relay.coding.paseo#
relay.coding.paseo.options#
Where and with what a Paseo session can start in a Paseo project: its Paseo workspaces, every coding agent Paseo reports there, and the start the Relay remembers for it.
options(args: {
// The Paseo coding project's Verdalia id.
project_id: DocId;
}): Promise<{
// The last start the relay remembers for the project; `null` when it remembers none.
last_start: PaseoLastStart | null;
// Paseo's saved profiles in its order; empty when the computer's Paseo has none,
// or its Relay or Paseo predates them.
profiles: Array<PaseoProfileView>;
// The coding agents Paseo reports in the project, with models matched to Verdalia's catalogue.
providers: Array<PaseoCodingAgentOption>;
// The project's Paseo workspaces.
workspaces: Array<PaseoWorkspaceView>;
}>
relay.coding.paseo.hostOptions#
What one Relay's Paseo offers its Paseo projects, in one connect: the workspaces of each,
and the coding agents available for each requested project. Unlike every other coding method, project_ids are
Paseo's own project ids, as coding.list() reports them in a Paseo project's source.
hostOptions(args: {
// The id of the Relay connection. Omitted, the workspace's only Relay; a workspace with
// none, or with several, refuses the call.
connection?: DocId | null;
// Paseo's own ids of the projects whose coding agents to read.
project_ids: Array<string>;
}): Promise<{
// Each requested project's coding agents, or why they could not be read.
providers: Record<string, PaseoProvidersOutcome>;
// Every Paseo workspace on the Relay, grouped by its project.
workspaces: Record<string, Array<PaseoWorkspaceView>>;
}>
relay.coding.paseo.branches#
The branches of a Paseo project whose names match query, or its first branches without
one.
branches(args: {
// The Paseo coding project's Verdalia id.
project_id: DocId;
// The text branch names are matched against; omitted, the project's first branches.
query?: string | null;
}): Promise<{
branches: Array<BranchView>;
}>
relay.coding.paseo.validateBranch#
Whether a branch name exists in a Paseo project, and the ref it resolves to; refused with Paseo's message when it is not a valid branch name.
validateBranch(args: {
// The branch name to check.
name: string;
// The Paseo coding project's Verdalia id.
project_id: DocId;
}): Promise<{
exists: boolean;
is_remote: boolean;
resolved_ref: string | null;
}>
relay.coding.paseo.worktrees#
Every Paseo worktree of a Paseo project, with the workspaces its Relay lists on each.
worktrees(args: {
// The Paseo coding project's Verdalia id.
project_id: DocId;
}): Promise<{
worktrees: Array<PaseoWorktreeView>;
}>
relay.coding.paseo.removeWorktree#
Removes a Paseo worktree of a Paseo project, archiving every workspace on it; the branch stays. The coding sessions of the archived agents are gone when it resolves.
removeWorktree(args: {
// Remove it even with uncommitted changes, losing them.
discard_changes?: boolean;
// The Paseo coding project's Verdalia id.
project_id: DocId;
// The worktree to remove: `{by: "branch", branch}` or `{by: "path", worktree_path}`.
target: WorktreeTarget;
}): Promise<{
archived_agents: Array<string>;
branch: string | null;
removed: boolean;
worktree_path: string;
}>
relay.coding.paseo.archiveWorkspace#
Archives a Paseo workspace of a Paseo project with its agents, and its worktree when Paseo owns it. The coding sessions of the archived agents are gone when it resolves.
archiveWorkspace(args: {
discard_changes?: boolean;
// The Paseo workspace, by Paseo's workspace id.
paseo_workspace_id: string;
// The Paseo coding project's Verdalia id.
project_id: DocId;
}): Promise<{
archived_at: string;
directory: string;
kind: PaseoWorkspaceKind;
workspace_id: string;
// Whether the worktree directory is gone; `null` for a workspace that is not a worktree.
worktree_removed: boolean | null;
}>
relay.coding.paseo.file#
An image a Paseo session's agent can read, by its path: PNG, JPEG, GIF or WebP. Refused for an ACP session and for any other file.
file(args: {
// The image's path, as the session's agent sees it.
path: string;
// The Paseo coding session's Verdalia id.
session_id: DocId;
}): Promise<{
// The image's bytes.
content: Uint8Array;
// The image's MIME type.
content_type: PaseoFileType;
}>
Types#
// One branch of a Paseo project, and where it exists.
type BranchView = {
has_local: boolean;
has_remote: boolean;
name: string;
};
// The identifier of a persisted record.
type DocId = string;
// The provider a Paseo model is reached through, named as its model metadata reports it.
// Regional and plan routes keep their own names; `Other` keeps a name Verdalia does not know.
type ModelProvider = "anthropic" | "openai" | "openai-codex" | "google" | "google-vertex" | "google-gemini-cli" | "google-antigravity" | "xai" | "deepseek" | "mistral" | "moonshot" | "kimi-code" | "zai" | "minimax" | "minimax-cn" | "minimax-code" | "minimax-code-cn" | "qwen" | "qwen-portal" | "nvidia" | "openrouter" | "ollama" | "ollama-cloud" | "opencode" | "cohere" | "cursor" | string;
// One selectable Paseo mode.
type PaseoChoiceView = {
id: string;
label: string;
};
// A coding agent Paseo runs, by its Paseo id; `Other` keeps an id with no default model
// provider, such as `omp` or `opencode`.
type PaseoCodingAgent = "claude" | "codex" | "gemini" | "cursor" | string;
// One coding agent Paseo can run in a project, as the new-session form and the session toolbar
// show it, with its provider's connection icon and its models matched to the catalogue.
type PaseoCodingAgentOption = {
coding_agent: PaseoCodingAgent;
default_mode: string | null;
enabled: boolean;
error: string | null;
// Its provider's connection icon; `null` for a coding agent with no provider of its own.
icon: string | null;
label: string;
models: Array<PaseoModelOption>;
modes: Array<PaseoChoiceView>;
status: PaseoProviderStatus;
};
// The type of an image file a Paseo agent's file route serves.
type PaseoFileType = "image/png" | "image/jpeg" | "image/gif" | "image/webp";
// The last Paseo start the relay remembers for a project: the coding agent and placement of the
// newest start, and the newest model, mode and thinking chosen per coding agent.
type PaseoLastStart = {
choices: Array<PaseoRememberedChoice>;
// The coding agent last started; older relays name this field `provider`.
coding_agent: PaseoCodingAgent;
placement: RememberedPlacement;
};
// One model a Paseo coding agent offers, with the release date Verdalia's catalogue holds
// for it and its provider's connection icon; both are absent for a model the catalogue does not know.
type PaseoModelOption = {
// The maximum context window in tokens, if Paseo states it.
context_window?: number | null;
description: string | null;
icon: string | null;
id: string;
is_default: boolean;
label: string;
provider: ModelProvider | null;
provider_model: string | null;
released: string | null;
thinking: Array<PaseoThinkingView>;
};
// One model a Paseo coding agent offers, with its thinking options and any description and
// provider metadata Paseo reports.
type PaseoModelView = {
// The maximum context window in tokens, if Paseo states it.
context_window?: number | null;
description: string | null;
id: string;
is_default: boolean;
label: string;
provider: ModelProvider | null;
provider_model: string | null;
thinking: Array<PaseoThinkingView>;
};
// A saved Paseo profile as Relay reports it, without its provider options.
type PaseoProfileView = {
coding_agent: PaseoCodingAgent;
color: string | null;
icon: string | null;
id: string;
mode: string | null;
model: string | null;
name: string;
notes: string | null;
thinking: string | null;
};
// Whether a Paseo provider can run agents right now.
type PaseoProviderStatus = "ready" | "loading" | "error" | "unavailable" | "unknown";
// One coding agent reported by `GET /api/coding_agents/paseo/providers` for a project,
// whatever its status, with Paseo's error for it and its modes and models.
type PaseoProviderView = {
// The coding agent's id; older relays name this field `provider`.
coding_agent: PaseoCodingAgent;
default_mode: string | null;
enabled: boolean;
error: string | null;
label: string;
models: Array<PaseoModelView>;
modes: Array<PaseoChoiceView>;
status: PaseoProviderStatus;
};
// One project's coding agents, or why they could not be read.
type PaseoProvidersOutcome = {
providers: Array<PaseoProviderView>;
} | {
error: string;
};
// The model, mode and thinking last started with one Paseo coding agent in a project.
type PaseoRememberedChoice = {
// The coding agent these choices belong to; older relays name this field `provider`.
coding_agent: PaseoCodingAgent;
mode: string | null;
model: string | null;
thinking: string | null;
};
// One thinking option of a Paseo model.
type PaseoThinkingView = {
id: string;
is_default: boolean;
label: string;
};
// What kind of checkout a Paseo workspace is.
type PaseoWorkspaceKind = "directory" | "local_checkout" | "checkout" | "worktree" | "unknown";
// A Paseo workspace: one checkout of a project that agents run in.
type PaseoWorkspaceView = {
branch: string | null;
// When Paseo made the workspace (its `createdAt`). A relay older than this field sends none.
created_at: string | null;
// Where the checkout is on the relay's computer: a worktree's own directory, else the
// project root. A relay older than this field sends none.
directory: string | null;
kind: PaseoWorkspaceKind;
name: string;
project_id: string;
workspace_id: string;
};
// One Paseo worktree of a project, with the workspaces the relay lists on it.
type PaseoWorktreeView = {
// `null` for a detached worktree.
branch: string | null;
created_at: string;
head: string | null;
// The foreground, unarchived workspaces the relay lists on it; empty when it lists none.
workspace_ids: Array<string>;
worktree_path: string;
};
// Where a remembered Paseo start ran: an existing workspace, or a new local or worktree one.
type RememberedPlacement = {
kind: "existing_workspace";
workspace_id: string;
} | {
kind: "new_local";
} | {
kind: "new_worktree";
};
// Which of a project's Paseo worktrees: by its branch, or by its path, the only handle on a
// detached one.
type WorktreeTarget = {
branch: string;
by: "branch";
} | {
by: "path";
worktree_path: string;
};
Inputs
inputOptional
Outputs
output
Configuration
| Field | Type | Required | Description |
|---|---|---|---|
language | enum(javascript, typescript) | No | Script language |
script | code(javascript) | No | JavaScript/TypeScript code to execute. Access input data via the 'inputs' object. |
input_names | array<string> | No | |
output_names | nullable<array<string>> | No | Named outputs. Disabled: the returned value goes out unchanged on `output`. Enabled: the script returns an object and each key's value goes out on the output of that name. `error` is reserved when the failure mode is Route to error output. |
timeout_secs | integer | No | |
base_config | record | No | Shared node configuration. failure_mode decides what a failure of this node does to the workflow; leave it at the default stop unless the workflow handles the failure itself on the node's error output (route_to_error) or the node is a rare emergency kill switch (stop_workflow). |