Appearance
Interface: Context
Defined in: packages/sdk/src/context/index.ts:153
The skill context, passed to the skill's entry function by the Assistant runtime. It bundles the page/browser automation handles, the Assistant bridge (assistant), skill metadata, and lifecycle control (Context.onStop / Context.stopSkill).
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
assistant | AssistantAPI & { tabGroup: AssistantTabGroupAPI; } | Assistant bridge: skill secrets, key-value storage, organization colors, plus `tabGroup` for controlling the skill's Chrome tab group. | packages/sdk/src/context/index.ts:159 |
browser | Browser | Puppeteer browser connected to the user's browser. | packages/sdk/src/context/index.ts:161 |
languageCode | | "en" | "cs" | "da" | "de" | "el" | "es" | "fi" | "fr" | "hi" | "hu" | "it" | "nl" | "no" | "pl" | "pt" | "ro" | "ru" | "sv" | "tr" | The user's Assistant UI language (e.g. 'en', 'de'). | packages/sdk/src/context/index.ts:163 |
onStop | (callback: SkillStopCallback) => () => void | Register a cleanup callback that runs when the skill run ends (Assistant >= v11.139.0). Fires exactly once per run with one of the four SkillStopReasons. Semantics: - Callbacks may be async and are awaited sequentially, last-registered-first (LIFO — teardown mirrors setup). - A shared 4-second budget covers all callbacks together; when it expires, remaining waits are abandoned. - A throwing/rejecting callback is caught and logged and does not block the others. - Returns an unregister function; call it to remove the callback (e.g. after a commit point when rollback is no longer needed). - Registering after the skill already stopped invokes the callback immediately with the original stop info (unregister is then a no-op). - ctx.signal is already aborted when callbacks run. During a graceful external stop the page/browser automation and API bridges stay live through the grace window, so callbacks can still drive the page (e.g. discard a draft). Do not call ctx.render from a callback — on external stops the skill UI is already gone. - Not supported in workflow (WDK) sandboxes. In the standalone Chromebook extension only 'finished'/'error' fire. Example const draft = await createDraft(ctx); const unregister = ctx.onStop(async ({reason, errorMessage}) => { if (reason === 'error') console.error('skill failed:', errorMessage); await discardDraft(ctx, draft); // page is still reachable here }); await submitDraft(ctx, draft); unregister(); // committed — rollback no longer needed | packages/sdk/src/context/index.ts:200 |
page | Page | Frame | Puppeteer page (or frame) the skill automates. | packages/sdk/src/context/index.ts:202 |
render | RenderFunction | Legacy render entry-point; prefer render(ctx, tree) from the renderer. | packages/sdk/src/context/index.ts:204 |
signal | AbortSignal | Aborted when the skill run ends; passed to cancelable operations. | packages/sdk/src/context/index.ts:206 |
skillEnv | SkillEnv | Skill identity metadata: identifiers, tag, and Assistant version. | packages/sdk/src/context/index.ts:208 |
stopSkill | () => void | End the skill run programmatically (Assistant >= v11.139.0). Runs the registered Context.onStop callbacks with reason 'stopped'. Fire-and-forget: code after the call may briefly keep executing with ctx.signal.aborted === true. Idempotent — repeated calls are no-ops. Not available in workflow (WDK) sandboxes or the standalone Chromebook extension. | packages/sdk/src/context/index.ts:218 |
telemetry | SkillTelemetryTracker | Telemetry tracker; sendEvent(key, payload) reports skill events. | packages/sdk/src/context/index.ts:220 |
theme? | ThemeType | Organization theme colors, when configured. | packages/sdk/src/context/index.ts:222 |