build-kernel-ts-sdk
Use if building browser-automation apps on the Kernel TS SDK (@onkernel/sdk) — browsers, pools.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Use if building browser-automation apps on the Kernel TS SDK (@onkernel/sdk) — browsers, pools.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Use if driving agent-browser for webpage interaction, screenshots, @ref snapshots, tabs, UI verification, CDP attach, Steel Browser, or cloud providers (Browser Use, Browserbase, Browserless, Kernel).
Use if verifying claimed-done work or auditing session/plan/branch completion with evidence.
Use if creating, redesigning, or merging a Claude skill, with research before writing SKILL.md.
Use skill if you are running repeatable Codex reviews across lenses or branches, optionally verifying and fixing confirmed findings in isolated worktrees.
Use if running deep multi-file research over 5+ entities or a market — wave-dispatched corpus.
Use if finishing a project — review and merge every branch/worktree into main, retire dead branches.
| name | build-kernel-ts-sdk |
| description | Use if building browser-automation apps on the Kernel TS SDK (@onkernel/sdk) — browsers, pools. |
Build with the Kernel TypeScript SDK (@onkernel/sdk, generated from Kernel's OpenAPI spec by Stainless) and the React helper @onkernel/managed-auth-react. Kernel runs each browser as a unikernel-isolated VM and co-locates your code with the browser to remove CDP latency. The SDK and CLI surface the same API.
Use this skill if the task involves any of:
@onkernel/sdk or constructs new Kernel(...)kernel.browsers.create, cdp_ws_url, kernel.browsers.playwright.execute, or kernel.browsers.computer.*kernel deploy and invoking it via kernel.invocations.create (sync or async with invocations.follow)profiles.*), browser pools (browserPools.*), credentials (credentials.*), or replays/file I/O (browsers.fs.*, browsers.replays.*)auth.connections.* and the React <KernelManagedAuth /> componentKERNEL_API_KEY per project via defaultHeaders: { 'X-Kernel-Project-Id': '…' }browser.close() not cleaning up, sync-invocation 100 s timeout, default-context confusion, 409 profile conflictsDo NOT use this skill for:
agent-browser CLI (agent-browser -p kernel, @ref snapshots, snapshot -i --json) — use run-agent-browser. This skill owns Kernel-SDK code; run-agent-browser owns the CLI.kernel-python-sdk), or Browser Use's Python framework — no native TS package.build-langchain-ts-app).| Situation | Use |
|---|---|
TypeScript code importing @onkernel/sdk or deploying a Kernel App | build-kernel-ts-sdk |
agent-browser CLI loops, including agent-browser -p kernel | run-agent-browser |
| LangChain.js/LangGraph agent where browser tools are optional | build-langchain-ts-app |
| Mode | When | Code lives | Invocation |
|---|---|---|---|
| A. Embed | Drive Kernel from your own service (Next.js route, worker, CLI tool) | Your repo | new Kernel() → browsers.create → CDP / playwright.execute / computer.* |
| B. Deploy | Long-running, browser-co-located actions; want zero CDP latency or per-invocation isolation | A Kernel App (your repo, deployed via kernel deploy) | Register actions → kernel deploy → kernel.invocations.create({ app_name, action_name, payload }) |
Mixing is fine — most production setups deploy long-running browser work as a Kernel App and invoke it from an embedding service. Don't try to make a single function do both.
deployment.id, app name, and version.invocation.id, sync/async mode, status, logs/events, and output handling.KERNEL_API_KEY from env. Never hardcode. Env wins over apiKey: option only when the option is omitted; passing both is allowed.@onkernel/sdk is auto-generated by Stainless and rev's frequently. Pin a minor version range; verify method names from the installed node_modules/@onkernel/sdk/api.md if unsure.browser.close() as cleanup. Playwright/Puppeteer close() only severs the local CDP connection. Always call kernel.browsers.deleteByID(session_id) (or rely on timeout_seconds).async: true with async_timeout_seconds (10–3600) and invocations.follow(id) for SSE. Switching after the fact requires re-deploying.browser.contexts()[0] and pages()[0] — do not call browser.newContext() / context.newPage() to make a "fresh" one.defaultHeaders: { 'X-Kernel-Project-Id': '…' } to the constructor. The SDK does NOT auto-read KERNEL_PROJECT — wire it through. OAuth (CLI) is always org-wide."node" env), Nitro v2.6+. React Native is unsupported.browsers.fs.* or object storage.stealth: true for any non-trivial site — bot detection is the rule, not the exception.timeout_seconds: 300 minimum; the 60 s default is too aggressive for real automation. Max is 259200 (72 h).kernel.browsers.playwright.execute(id, { code }) for hot paths (runs in the browser VM with no CDP roundtrip). Reserve raw CDP for long-lived interactive sessions.save_changes: true; other parallel browsers should load it read-only.timeout_seconds countdown to deletion start.For a new scratch project, use the scaffold script so package pins come from npm at generation time:
bash scripts/scaffold-kernel-app.sh --mode embed --dir ./kernel-embed-demo
cd ./kernel-embed-demo
npm install
export KERNEL_API_KEY=... # never commit; use .env.example only as template
npm run check
npm run start
For an existing repo, install explicitly and keep a pinned range:
npm install @onkernel/sdk@^$(npm view @onkernel/sdk version) playwright
npm install -D tsx typescript @types/node
First browser creation must print the session_id, do the work, then call kernel.browsers.deleteByID(session_id) in finally. If a browser, pool lease, auth session, deployment, or invocation is intentionally left alive, report the ID, timeout, and reason.
scripts/check-kernel-sdk-version.sh before changing Kernel code. Read scripts/check-kernel-sdk-version.sh.md for output interpretation.npm view @onkernel/sdk version dist-tags --json before pinning; prefer a minor range for scaffolds, not latest.node_modules/@onkernel/sdk/api.md when present — Stainless regenerates frequently and method names move.https://www.kernel.sh/docs/llms.txt and the linked page before changing code.Before running code, name every operation that may create paid or quota-bound resources:
browsers.create, especially headful, GPU, high-resolution viewport, long timeout_seconds, proxy, extension, or profile-backed sessionscreate, acquire, and unreleased acquired browsersdeployments.create, kernel deploy, and invocations.createFor each resource, decide the cleanup path before running: deleteByID, pool release, invocation/browser cleanup by invocation_id, deployment terminal state, or explicit timeout with reason. Report anything left alive.
import Kernel from '@onkernel/sdk'. Verify env (KERNEL_API_KEY is the only required one; KERNEL_LOG, KERNEL_BASE_URL, KERNEL_CUSTOM_HEADERS, KERNEL_SUPPRESS_BUN_WARNING are optional). For local dev hitting https://localhost:3001/, pass environment: 'development', baseURL: null. For project-scoped API keys, wire X-Kernel-Project-Id through defaultHeaders. See references/guides/client-and-config.md.browsers.create with browsers.deleteByID, even on error paths. Use try/finally. See references/guides/browsers-lifecycle.md.kernel deploy and consume invocations; for Mode A, run inside your service. See references/guides/apps-deploy-invoke.md and references/examples/deploy-and-invoke-app.md.| Do this | Not that |
|---|---|
await kernel.browsers.deleteByID(session.session_id) in a finally | await browser.close() and assume the browser is gone |
chromium.connectOverCDP(session.cdp_ws_url) then browser.contexts()[0] | browser.newContext() to "isolate" the test |
kernel.browsers.playwright.execute(id, { code: '…' }) for hot paths | round-trip every call over CDP from your service |
async: true, async_timeout_seconds: 1800 + invocations.follow | depend on the sync invocation cap holding for a multi-minute scrape |
JSON.stringify(payload) and JSON.parse(invocation.output ?? 'null') | pass non-JSON-serializable objects to payload |
try { ... } catch (e) { if (e instanceof Kernel.APIError) … } | swallow errors or catch (e: any) without checking subclasses |
browsers.create({ profile: { name } }) after Managed Auth completes | re-prompt the user every session |
Pin @onkernel/sdk to a minor range and bump deliberately | track latest (Stainless regenerates frequently) |
kernel.browsers.curl(id, { url }) for HTTP from inside the browser's TLS fingerprint | spin up a separate Playwright request context and lose the fingerprint |
Wire defaultHeaders: { 'X-Kernel-Project-Id': '…' } for project-scoped API keys | rely on key scope and get cross-project lists |
browser.close()is not cleanup. Closing the PlaywrightBrowseronly disconnects CDP. The Kernel browser keeps running untiltimeout_secondselapses or you callkernel.browsers.deleteByID(session_id). Always paircreatewithdeleteByIDin afinallyblock.
There is already a default context and page. Calling
browser.newContext()makes a second context; cookies, storage, and profile state live on the default one. Usebrowser.contexts()[0].pages()[0].
Sync invocations time out at ~100 s. If your action does any non-trivial browser work, set
async: trueandinvocations.follow(id)instead. Switching after the fact requires re-deploying.
Stagehand connects via local-CDP, not Browserbase. With
@browserbasehq/stagehandand Kernel, setenv: 'LOCAL'andlocalBrowserLaunchOptions.cdpUrl: session.cdp_ws_url. Do not setapiKeyorprojectId— those are Browserbase-only.
browsers.delete(singular) is deprecated. Usebrowsers.deleteByID(id). The plural form takes apersistent_idand belongs to the deprecated persistence model.
| Script | Use |
|---|---|
scripts/check-kernel-sdk-version.sh | Preflight Node/npm, installed Kernel package versions, npm latest versions, local api.md, and KERNEL_API_KEY presence. See scripts/check-kernel-sdk-version.sh.md. |
scripts/scaffold-kernel-app.sh | Generate a minimal embedded SDK example or deployable Kernel App in an empty directory. See scripts/scaffold-kernel-app.sh.md. |
| Document | What it contains | Load when |
|---|---|---|
| references/guides/client-and-config.md | Env vars, environments, retries, idempotency, pagination, error taxonomy, request options | Constructing the client, debugging auth/network errors, handling pagination |
| references/guides/browsers-lifecycle.md | browsers.create params, BrowserCreateResponse, standby, termination, viewport, timeout semantics | Creating, configuring, or terminating browsers |
| references/guides/apps-deploy-invoke.md | deployments.*, invocations.create sync vs async, invocations.follow SSE, secrets, logs | Deploying a Kernel App or invoking it from another service |
| references/guides/managed-auth.md | 3-piece architecture, auth.connections.*, <KernelManagedAuth /> props, profile interop | Authenticating an agent on a user's behalf into a SaaS |
| references/patterns/browser-control-surfaces.md | Decision tree across CDP, playwright.execute, computer.*, curl | Picking the right control surface for a task |
| references/patterns/playwright-stagehand-integration.md | connectOverCDP idiom, default-context warning, Stagehand v3 launch options, kernel create --template | Wiring Playwright or Stagehand to a Kernel browser |
| references/patterns/profiles-pools-credentials.md | profiles.*, browserPools.*, credentials.*, credentialProviders.* (1Password) | Persistent login state, pool warm-starts, credential providers |
| references/patterns/integrations-matrix.md | Hookup snippets per integration (Stagehand, Browser Use, Claude Agent SDK, Vibium, etc.) | Connecting a third-party agent framework to a Kernel browser |
| references/examples/browser-screenshot.md | Minimal end-to-end TS example | Sanity-check first run; copy as a starting scaffold |
| references/examples/deploy-and-invoke-app.md | kernel deploy + invocations.create + invocations.follow walkthrough | Building or invoking a Kernel App |
| references/examples/managed-auth-flow.md | Full Next.js page + backend route + browser launch | Implementing the Managed Auth handoff end-to-end |
| references/troubleshooting/pitfalls.md | The 16 production gotchas in priority order | Debugging unexpected behavior or before shipping |
| references/troubleshooting/files-and-replays.md | browsers.fs.*, browsers.replays.*, download timing, multipart | File I/O or replay download is failing or slow |
| references/troubleshooting/auth-and-profile-errors.md | 409 conflict, profile not found, hosted-page handoff failures | Managed Auth or profile errors |
When finishing a Kernel task, report only fields that apply:
session_id values and whether each was deleted, pool-released, intentionally timed out, or left running with reasonsave_changes was usedflow_status/status, and profile nameEnd-to-end checks for any Kernel-TS task:
node_modules/@onkernel/sdk/api.md exists and matches the methods you call.KERNEL_API_KEY resolves at runtime; if the key is org-wide, defaultHeaders: { 'X-Kernel-Project-Id': '…' } is wired through the constructor.browsers.create is paired with a deleteByID in a finally (grep the diff).async: true and consume invocations.follow(id) events (log, invocation_state, error, sse_heartbeat).browser.contexts()[0] not newContext().stealth: true) for anything user-facing or against a real SaaS.<KernelManagedAuth /> is a client component ("use client"), the backend route calls auth.connections.create and auth.connections.login, and downstream browsers.create uses the same profile.name.session_id values must be deleted, released back to a pool, intentionally timed out, or left running with a reason.browsers.fs.*, replay download, or object storage before browser cleanup.KERNEL_API_KEY is read from env, not hardcoded.@onkernel/sdk version is pinned.browsers.create is paired with deleteByID (or wrapped by an invocation that will reap).*_timeout_seconds is set.browser.newContext() against a Kernel browser.instanceof Kernel.APIError (or specific subclass)."use client", the success handler launches a browser with the matching profile.name.package.json has "type": "module" for TS apps; kernel deploy succeeded; the action is registered.browser.close() as the only cleanup.This skill covers @onkernel/sdk and @onkernel/managed-auth-react in TypeScript. It does not cover:
kernel-python-sdk)agent-browser CLI (use run-agent-browser)kernel CLI surface beyond deploy and invoke (read kernel --help directly)