Skip to main content

yeet global

O yeet

The yeet object is the primary host-provided API surface, installed as a global before script evaluation begins.

P yeet.args

yeet.args: Record<string, string | boolean | (string | boolean)[]> & { _: string[] }

A parsed, read-only object containing CLI arguments passed when the script was run. Parsing follows minimist conventions:

InputResult
--foo bar{ foo: "bar" }
--foo=bar{ foo: "bar" }
--foo{ foo: true }
--no-foo{ foo: false }
--multi-word-flag{ multi_word_flag: true } — kebab-case is converted to snake_case
-f bar{ f: "bar" }
-abc{ a: true, b: true, c: true }
bare-wordappended to _: [...]
--halts flag parsing; remaining words go to _
Duplicate flagscoalesce into arrays
// yeet run script.js --verbose --tag alpha --count 3 file.txt
console.log(yeet.args);
// { verbose: true, tag: "alpha", count: "3", _: ["file.txt"] }
note

All values are strings or booleans. Numeric strings are not coerced to numbers automatically.


F yeet.exit

exit(): void

Terminates the running isolate. Any registered exit handlers run first.

yeet.exit();

O yeet.graph

Interface to the yeet system graph — a structured data query layer backed by GraphQL.

F yeet.graph.query

query(gql: string): Promise<{ data?: any; errors?: { message: string }[] }>

Executes a one-shot GraphQL query. Rejects with { code, message } only on transport-level failures.

const { data, errors } = await yeet.graph.query(
`{ host { uptime { uptime } } }`
);
if (errors) throw new Error(errors[0].message);
console.log(data.host.uptime.uptime);

A successful response looks like:

{
"data": { "host": { "uptime": { "uptime": 12345 } } }
}

On a GraphQL error:

{
"data": null,
"errors": [{ "message": "field 'foo' not found" }]
}

To explore what the graph exposes, run yeet graph dump for the full SDL or yeet graph query '<gql>' for ad-hoc queries from the shell.

F yeet.graph.subscribe

subscribe(gql: string, callback: (data: any) => void): string

Starts a live subscription to a GraphQL query. The callback fires each time new data arrives. Returns a ticket string — capture it if you intend to unsubscribe later.

const ticket = yeet.graph.subscribe(
`subscription {
network_interface_stats(interval_ms: 1000) {
name recv_bytes sent_bytes
}
}`,
(data) => console.log(data)
);

F yeet.graph.unsubscribe

unsubscribe(ticket: string): Promise<boolean>

Cancels a running subscription. Returns true if found and removed, false otherwise.

await yeet.graph.unsubscribe(ticket);

M yeet.alert

alert(...args: any[]): Promise<any>

Dispatches an alert event to the yeet platform and returns a Promise that settles when the platform responds.

ParameterTypeDescription
...argsany[]Any JSON-serializable values, forwarded to the platform as-is.

Returns a Promise that resolves or rejects with the JSON payload returned by the platform.

Currently, yeet.alert supports sending Slack messages. Sending a Slack alert requires connecting your Slack workspace — set up the OAuth integration at yeet.cx/settings before use.

Pass an object with method: "slack", a channel, and a text fallback. You can also include a blocks array for richer formatting using Slack Block Kit.

const result = await yeet.alert({
method: "slack",
channel: "#alerts",
text: "Container down",
blocks: [
{
type: "header",
text: { type: "plain_text", text: "Container down" },
},
{
type: "section",
fields: [
{ type: "mrkdwn", text: "*Container:*\nnginx" },
{ type: "mrkdwn", text: "*Status:*\nexited" },
],
},
],
});
console.log("alert sent", result);

Promise lifecycle

The platform responds with an HTTP status that determines how the promise settles:

StatusOutcome
200 OKResolves immediately with the response payload.
202 AcceptedParked — the platform will settle it later out-of-band.
429 Too Many RequestsRejects with RateLimited. Not retried.
Other 4xx / 5xxRejects with the response payload (up to 3 retries on auth and server errors).

Failure modes

The promise rejects if:

  • No access token is available (not logged in).
  • All retry attempts are exhausted on a server or auth error.
  • The platform returns 429 (rate limited).
  • The platform returns a non-success status after retries.