Skip to content

ToolContext

What a tool’s run and drop receive: the extension’s usual ctx, plus what tools need.

dataDir: string

A folder only this extension writes to, created on first use. A file a tool returns (files, image, a drop’s outputs) must be inside it or be one the user gave the tool in this run; anything else is dropped from the output.


extensionId: string

Context.extensionId


log: Logger

Context.log


oauth: OAuth

Sign-in to the services your manifest declares in oauth, run by the app.

Context.oauth


preferences: Preferences

Context.preferences


secrets: Secrets

Keychain-backed; use for tokens, never storage (a plain file).

Context.secrets


signal: AbortSignal

Aborted when the run times out. Pass it to fetch so a slow request stops with it.


storage: Storage

Context.storage


trigger: Trigger

Context.trigger

emit(blip): void

Emits a full snapshot for one blip. Call once per changed item, not a diff.

Parameter Type
blip BlipInput

void

Context.emit


end(key, options?): void

Marks a blip finished; surfaces show the final state, then dismiss it.

Parameter Type
key string
options? { dismissAfter?: number; state?: "success" | "failure"; }
options.dismissAfter? number
options.state? "success" | "failure"

void

Context.end


exec(file, args?, options?): Promise<ExecResult>

Runs an executable listed in permissions.exec. Rejects if it isn’t.

Parameter Type
file string
args? string[]
options? { cwd?: string; timeoutMs?: number; }
options.cwd? string
options.timeoutMs? number

Promise<ExecResult>

Context.exec


notify(title, body?): Promise<void>

A line under the notch for a few seconds, for the result of something the user just did.

Parameter Type
title string
body? string

Promise<void>

Context.notify


openURL(url): Promise<void>

Opens a URL with the user’s default handler.

Parameter Type
url string

Promise<void>

Context.openURL


remove(key): void

Removes a blip immediately, with no final-state flourish.

Parameter Type
key string

void

Context.remove


respond(replyId, body, status?): void

Completes a webhook request that’s being held on event.replyId.

Parameter Type
replyId string
body unknown
status? number

void

Context.respond


setPreference(name, value): Promise<void>

Changes one of your own options (never a password), as if it were changed in Settings: it’s saved, and update() runs again with it. For a button that sets something up in one press (“Keep watching this repository”). undefined clears it.

Parameter Type
name string
value string | number | boolean | undefined

Promise<void>

Context.setPreference


workingHours(): Promise<WorkingHours | undefined>

The person’s working hours, or undefined when they haven’t set any (every hour is one).

Promise<WorkingHours | undefined>

Context.workingHours