kweo for Python
Drive your real, signed-in kweo browser and use your own AI from Python.
import kweo
k = kweo.connect() # finds kweo on this computer
tab = k.open("https://github.com/notifications")
print(tab.text()) # the page, as you see it — you're signed in
print(tab.ask("Which of these need my review?")) # your AI, about this page
- Your sessions, not a headless robot. Scripts work in your kweo — Gmail, banking, LinkedIn, internal dashboards — already signed in, past bot walls, no cookies to export.
- Your AI, without keys in code. Claude (through Claude Code), your ChatGPT or Copilot plan, Gemini, API keys, OpenCode's free models, on-device models: whatever you connected in kweo. kweo speaks the OpenAI API, so LangChain, LlamaIndex, CrewAI and the OpenAI SDK work too.
- kweo's agent as a function.
k.agent.run("…")hands a whole job to kweo's agent and returns its answer (or the JSON you asked for). - Safe by default. Localhost only, a key per app, the same safety checks as kweo's agent (risky clicks follow your autonomy setting, blocked sites stay blocked), saved passwords are typed by kweo and never reach Python, and everything a script does is in kweo's activity log.
No dependencies — standard library only, Python 3.9+.
Install
pip install kweo
(or straight from kweo.ai: pip install https://kweo.ai/downloads/kweo-<version>-py3-none-any.whl)
The one requirement is the kweo app itself (5.0 or later, free at https://kweo.ai/#get). Its API is on by default (Settings → Developers). kweo writes its address and a key to ~/.kweo/api.json, readable only by you, so kweo.connect() needs no arguments. To use another key, set KWEO_API_KEY (and KWEO_URL), or pass kweo.connect(key=…).
When kweo can't be reached, connect() handles it:
- Installed but closed: it starts kweo and waits for it. This also covers scripts run from cron. Use
connect(launch=False)to only report it. - Not installed: it raises
KweoNotInstalledand opens the download page in your browser, but only if you're at the keyboard. It never does this from cron or CI, andKWEO_NO_BROWSER=1turns it off. - Older than 5.0: it raises
KweoTooOld. kweo updates itself and installs the update when restarted.
The core library has no dependencies. Extras: pip install "kweo[langchain]" adds LangChain, and "kweo[openai]" adds the OpenAI SDK for k.ai.openai().
Pages
tab = k.open("https://news.ycombinator.com") # a new background tab
tab = k.active_tab() # …or the one you're looking at
for t in k.tabs(): print(t.id, t.title, t.url)
tab.goto("https://example.com") # waits for the page to settle
tab.text(find="price") # visible text (optionally just matching lines)
tab.elements(interactive=True) # [N] role "name" — buttons, links, fields
tab.links(match="*/item?id=*") # [{"text", "url"}]
tab.screenshot("page.png", full_page=True)
tab.pdf("page.pdf")
tab.evaluate("document.title") # JavaScript (needs the "script" permission)
Acting
Name an element by its visible text ("Sign in"), its [N] index from elements(), or an Element. kweo prefers the control you mean: the text box over its label, the button over its caption. When two different controls really match, you get KweoAmbiguous listing them, and you add role= or nth=.
tab.type("Search", "wireless earbuds", submit=True)
tab.click("Add to cart")
tab.fill({"Email": "ada@example.com", "Name": "Ada"}, submit="Continue")
tab.select("Country", "India")
tab.press("Escape")
tab.scroll("down")
tab.wait(text="Order placed", seconds=30)
tab.fill_password("Password", submit=True) # your saved password — never seen by Python
tab.upload("Attach resume", "~/Documents/cv.pdf")
Every action goes through kweo's safety checks. A risky click (pay, delete, send) may ask you first, depending on Settings → AI & models → Agent autonomy. If you decline, Python gets KweoPermissionError.
AI on a page
tab.ask("What's the cheapest option and its delivery date?")
rows = tab.extract({"title": str, "points": int, "comments": int}, many=True)
from pydantic import BaseModel
class Order(BaseModel):
number: str
total: float
status: str
orders = k.open("https://www.amazon.in/your-orders").extract(Order, many=True) # list[Order]
extract accepts a dict of types, a Pydantic model, a dataclass, a TypedDict, or a JSON schema. model= picks the AI. Without it, kweo uses the one you chose in kweo.
Your AI, from anywhere
k.ai.chat("Write a haiku about browsers") # your default model
k.ai.chat("Plan my week", model="claude-code:opus") # Claude Code, a chosen model
k.ai.chat("Classify: ...", json={"label": str, "score": float}) # parsed JSON
for piece in k.ai.chat("Tell me a story", stream=True): print(piece, end="")
k.ai.models() # what's connected
OpenAI-compatible: base URL http://127.0.0.1:7333/v1, any kweo key.
from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:7333/v1", api_key=k.key) # or k.ai.openai()
client.chat.completions.create(model="default", messages=[{"role": "user", "content": "Hi"}])
Model names:
default: your pick in kweo.claude-code,claude-code:opus,:sonnet,:haiku.opencodeandopencode:<provider/model>.- kweo's own ids for everything else:
chatgpt:…,copilot:…,openai:gpt-4o,google:…,local:….
Tool calling works with every model. Claude Code and OpenCode get it through kweo's emulation, enforced with a JSON schema on Claude Code. response_format (JSON mode / JSON schema) works too.
kweo's agent
run = k.agent.run("Find my last 3 Amazon orders and their totals",
url="https://www.amazon.in/your-orders",
output={"orders": [{"date": str, "total": float}]})
print(run.status, run.output) # done {'orders': [...]}
run = k.agent.start("Compare prices for 'AirPods Pro' on three shops") # don't wait
for event in run.events(): print(event) # steps as they happen
run.stop()
The agent is kweo's own, running on Claude Code or OpenCode (engine=, model=). It works in a tab you can watch. If it needs you (a login, a CAPTCHA), it asks in kweo and the run waits (status == "waiting").
Workflows as code
A workflow is a YAML file you keep in git and deploy to kweo. The same workflow opens in kweo's visual editor.
# price-check.yaml
name: Price check
parameters:
- { name: product, required: true }
schedule: "0 9 * * 1-5" # 9:00 on weekdays (optional)
trigger: { kind: webhook } # or file-watch (path:), page-condition (url:, text:) (optional)
steps: # a straight line of steps…
- task: Open {{product}} on example.com and read its price
start_url: https://example.com
output_as: price
- python: |
print("{{price}}".lstrip("$"))
# graph: { entry: n1, nodes: { … } } # …or the full node graph, for branches, loops and sub-workflows
wf = k.workflows.deploy("price-check.yaml") # creates it, or updates the one with the same id/name
k.workflows.validate("price-check.yaml") # {"ok": False, "errors": [...], "plan": [...]} — saves nothing
run = k.workflows.run("Price check", product="AirPods Pro")
for ev in run.events(): # step.started / step.done / step.failed, run.waiting, run.end
print(ev["type"], ev.get("step", {}).get("label", ""))
run.wait()
print(run.status, run.output) # done {'price': '249'}
print(run.log()) # every step, every tool the agent used
k.workflows.export("Price check", "price-check.yaml")
k.workflows.schedule("Price check", "30 8 * * *") # None clears it
k.workflows.trigger("Price check", "webhook")["trigger"]["url"]
k.workflows.get("Price check"); k.workflows.update("Price check", description="…"); k.workflows.delete("Price check")
An invalid workflow is refused with every problem at once: KweoError with code == "invalid_workflow" and details["errors"]. A run is running, waiting (a step needs you in kweo: a login, a CAPTCHA, a check), done, failed or stopped (run.stop()).
Webhooks
kweo can POST to your server when a run ends (run.done), fails (run.failed) or waits for you (run.waiting), for workflow runs and agent runs:
hook = k.webhooks.create("https://example.com/kweo", events=["run.done", "run.failed"])
secret = hook["secret"] # shown this once
Each delivery is {"event", "workflow": {"id", "name"} | null, "run": {...}, "at"} with the header X-Kweo-Signature: sha256=<HMAC-SHA256 of the raw body with the secret>. Check it with kweo.verify_webhook(secret, raw_body, signature). A failed delivery (no answer, 5xx, 429) is retried 3 times with growing waits. k.webhooks.list(), k.webhooks.delete(id).
Agents
An agent is a small open-source automation you install in kweo: a folder with an agent.yaml, packed into one signed
file (<id>-<version>.kweoagent). Before anything is installed kweo shows its permission screen — the sites it may open,
what it may do, its author, licence and source, and whether kweo reviewed it ("Verified by kweo") or not ("Not reviewed").
An installed agent becomes a workflow (it opens in the editor; its runs are in the run history) and gets its own key
with only the permissions it declared, held to its sites: kweo refuses every other site to the key and blocks the agent's
tab from leaving them.
# agent.yaml
format: kweo-agent/1
id: example-heading # [a-z0-9-]{3,40}
name: Example heading
version: "0.1.0" # semver (quote it)
description: Reads the main heading of a page on example.com.
author: { name: Ada, url: "https://ada.dev" }
license: Apache-2.0 # an OSI licence is required
repository: https://github.com/ada/example-heading
category: other # shopping, jobs, social, finance, research, productivity, dev, other
sites: [example.com] # every site it may open or act on (subdomains included) — enforced
permissions: [browse, ai] # browse, act, script, ai, agent — enforced (a goal agent declares ai)
inputs:
path: { type: string, default: "/", label: "Page to read" } # string, number, integer, boolean, enum (options:)
outputs:
heading: { type: string } # JSON schema of what a run returns
run: # exactly one of:
goal: "Open https://example.com{{inputs.path}} and read the page's main heading." # kweo's agent
# workflow: workflow.yaml # a kweo workflow (see Workflows as code; its parameters are the inputs)
# python: main.py # Python, in kweo's contained Python, using this library
schedule: { cron: "0 9 * * 1-5", enabled: false } # optional default
A python agent runs in kweo's contained Python with this library already importable and KWEO_URL /
KWEO_API_KEY set to the agent's own key, so kweo.connect() just works — and can only do what the agent declared:
import kweo
k = kweo.connect()
tab = k.open("https://example.com" + kweo.agent_inputs().get("path", "/"))
kweo.agent_output({"heading": tab.text()[:80]}) # what the run returns
Its network is limited to kweo on this computer on macOS (the Seatbelt jail allows only kweo's port). Linux's jail
(bubblewrap) can't limit a sandbox to the host's loopback, so there a python agent's network stays open — its key is
still limited to its sites and permissions. run: { python: main.py, packages: [requests], timeout_sec: 120 } installs
PyPI packages first.
kweo agent init my-agent [--kind goal|python|workflow] # a working template
kweo agent validate my-agent # checks agent.yaml and prints the permission screen
kweo agent keygen # once: your author key (kweo keeps it in ~/.kweo/agent-signing.key, owner-only)
kweo agent test my-agent -i path=/ # installs it in kweo, runs it, prints what it returned
kweo agent pack my-agent # → my-agent/example-heading-0.1.0.kweoagent, signed
kweo agent install ./example-heading-0.1.0.kweoagent # or a folder, an https:// link, a registry id
kweo agent run example-heading -i path=/about
kweo agent list · kweo agent rm example-heading
k.agents.install("example-heading-0.1.0.kweoagent") # {"status": "installed", "agent": {...}, "summary": {...}}
k.agents.run("example-heading", path="/about") # waits → what it returned: {'heading': 'Example Domain'}
run = k.agents.start("example-heading", path="/about") # or don't wait: a run like a WorkflowRun (.wait(), .events(), .log(), .stop())
print(run.wait().output)
k.agents.list(); k.agents.get("example-heading"); k.agents.runs("example-heading"); k.agents.uninstall("example-heading")
k.agents.run(...) raises kweo.KweoAgentFailed (its .run has the status, detail and log) when the agent fails or is
stopped; timeout= seconds raises KweoTimeout (the run goes on). An input named inputs, engine, wait or timeout
goes in the inputs dict.
What a run may do is enforced, not just its key. An agent without act is read-only: its run gets kweo's reading tools
only (open its sites, read the text, links and elements, wait) and every click, typed text or form fill is refused with a
reason — in kweo's own tool handlers, not only in the CLI's allow-list. Without script there's no Python; agents never get
the workflow builder's tools, your browsing memory, your sticky notes or your files. A goal agent is kweo's agent, so a new
one declares ai (kweo agent validate / pack say so).
Agents as building blocks
Every installed agent is a typed tool — its inputs are a JSON schema (GET /v1/agents has input_schema and
output_schema for each):
k.agents.schema("example-heading") # {"name", "description", "input_schema", "output_schema"}
# LangChain / LangGraph: one StructuredTool per installed agent, typed from its inputs (agent_<id>, dashes → _)
from kweo.langchain import chat_model, kweo_agent_tools
from langchain.agents import create_agent
agent = create_agent(chat_model("claude-code"), kweo_agent_tools())
- MCP: kweo's MCP server (
http://127.0.0.1:7333/mcp) lists every installed agent asagent_<id>for apps that connect to it (Claude Desktop, Claude Code, any MCP client) — the call runs the agent as itself and returns its JSON. kweo's own agent runs never see these tools (no agent runs an agent from inside a run). A client that was connected before you installed an agent sees it after it reconnects. - A workflow step:
- agent: <id>withinputs:(values or{{param.x}}/{{output.x}}) andoutput_as:— the agent runs in its own window, as itself, and its JSON lands in the run's outputs. Only your own workflows can have one; an installed agent's workflow never runs another agent. In the editor it's 🤖 Agent.
name: Morning reading
parameters: { n: number }
steps:
- agent: hn-top-stories
inputs: { count: "{{param.n}}" }
output_as: stories
- task: "Pick the three stories in {{output.stories}} I'd like most and say why."
Remix
kweo agent init my-remix --from <id> (or k.agents.remix("<id>", "my-remix")) writes an installed agent — or one from
kweo's registry — into a folder as a new package: a new id (<id>-remix unless --id), version 0.1.0, you as the author
(--author), and the original credited in remix_of: and the README. Change it, then validate, test and publish it under
its own id. In kweo, Remix (on an installed agent) and Remix as workflow (in Discover) make an editable copy as a
workflow of your own — not tied to the agent any more (no key of its own, no site lock).
Signing: the author signature (Ed25519 over the bundle's content hash) is required — a bundle changed after it was signed is
refused. Packing goes through the running kweo, which holds your author key; the Python library stays dependency-free.
Installing with this computer's own key (~/.kweo/api.json) installs at once; any other key — or confirm=False /
kweo agent install --ask — opens the permission screen in kweo and waits for your answer (status == "pending",
k.agents.install_status(request)). Websites link to kweo://agents/install?id=<id> (or ?url=<https link>), which opens
the same screen.
kweo's agent registry
Reviewed agents live at kweo.ai/agents. Search it and install by id (kweo checks the signatures and shows its permission screen); an agent kweo reviewed carries kweo's co-signature and shows Verified by kweo.
for a in k.agents.search("gmail"): # or search(category="shopping")
print(a["id"], a["latest"], a["installs"], a["sites"])
k.agents.info("gmail-digest") # inputs, sites, permissions, versions, source
k.agents.install("gmail-digest") # from the registry
r = k.agents.publish("./my-agent") # pack + sign through kweo, submit for review
print(r["status_url"]) # pending → approved (listed) or rejected (with the reason)
From the shell: kweo agent search gmail, kweo agent publish ./my-agent. Publishing needs repository: (its public
source) in agent.yaml. The author guide: kweo.ai/developers/agents.
In kweo (Agents → Installed → an agent from the registry) you can give it a 👍 or 👎 — one per install, anonymous: kweo sends a hash made from a random per-install token and the agent's id, never anything about you. The score shows in Discover and on kweo.ai/agents.
Team catalogues. Agents → Discover → Add a catalogue takes an https address that answers like kweo's registry
(GET <url>?q=&category= → {agents: [...]}, GET <url>/<id>, GET <url>/<id>/<version>/bundle). Its agents show in
Discover with the catalogue's label; installs from it are checked for their author's signature but are never "Verified by
kweo" (only kweo's registry reviews), they don't auto-update, and they can't be rated.
Routines, downloads, events
k.routines.run("Morning inbox")
k.downloads()
k.wait_for_download(timeout=120)
for ev in k.events(): print(ev["type"], ev.get("tab")) # tab.opened / navigated / loaded / closed, download.*
LangChain / LangGraph
pip install "kweo[langchain]" # LangChain + its OpenAI client; the core library needs nothing
from kweo.langchain import chat_model, kweo_tools
from langchain.agents import create_agent
agent = create_agent(chat_model("claude-code"), kweo_tools())
agent.invoke({"messages": [{"role": "user", "content": "What's in my GitHub notifications?"}]})
kweo_tools() gives the agent one tab of its own: open_page, read_page, list_elements, click, type_text, page_links, extract_from_page, ask_about_page, run_browser_agent. Any MCP-capable framework can also connect to kweo's MCP server at http://127.0.0.1:7333/mcp. kweo_agent_tools() adds one typed tool per installed agent (see Agents as building blocks).
Async
from kweo.aio import connect
k = await connect()
tab = await k.open("https://example.com")
print(await tab.text())
The kweo command
kweo status
kweo tabs
kweo text https://example.com --find price
kweo ask "What is this page about?" --url https://example.com
kweo chat "Summarize this:" - < notes.txt
kweo extract https://news.ycombinator.com --shape '{"title":"str","points":"int"}' --many
kweo run "Find a 4-star hotel in Lisbon under €150 for next Friday" --url https://booking.com
kweo shot https://example.com -o page.png --full
kweo workflows
kweo workflow deploy price-check.yaml
kweo workflow run "Price check" -p product="AirPods Pro" --wait
kweo workflow logs "Price check" # the latest run's trace (or give a run id)
kweo workflow export "Price check" -o price-check.yaml
kweo workflow rm "Price check"
kweo agent init|validate|keygen|test|pack|install|run|list|rm # see Agents
Keys and permissions
The This computer key (in ~/.kweo/api.json) can do everything, the same as you. For a tool you don't fully trust, make a key in Settings → Developers → New key with only what it needs:
| Permission | Allows |
|---|---|
browse |
List and open tabs, go to pages, read text, elements and links, screenshots, downloads |
act |
Click, type, fill, select, press keys, upload, close tabs |
script |
Run JavaScript in pages |
ai |
Models, chat completions, ask/extract on pages |
agent |
Run kweo's agent |
workflows |
Run workflows and routines; create, change, schedule and delete workflows; webhooks |
Revoke a key at any time. Ghost (private) windows and kweo's own pages are never reachable from scripts.
Errors
All errors are kweo.KweoError, with .status, .code and .message. The subclasses:
KweoNotRunning: kweo isn't open, or its API is off.KweoNotInstalled(a subclass) means it isn't installed at all.KweoTooOld: the kweo here is older than 5.0.KweoAuthError: the key is missing or wrong.KweoPermissionError: the key lacks the permission, the site is blocked, or you declined the action.KweoNotFound: no such tab, element, model, run or workflow.KweoAmbiguous: several elements match..details["candidates"]lists them.KweoTimeout: kweo didn't answer in time.
HTTP API
Everything above is plain HTTP and JSON on http://127.0.0.1:7333/v1 with Authorization: Bearer <key>, so any language works. See https://kweo.ai/developers for the full reference.
The workflow endpoints (all need the workflows permission):
GET /v1/workflows · POST /v1/workflows |
list · create ({name, steps | graph, parameters, context, schedule, trigger}, or {yaml}; "upsert": true updates the one with that id/name) |
GET/PUT/DELETE /v1/workflows/{id} |
read (?format=yaml for YAML) · change what you send · delete |
POST /v1/workflows/validate |
{ok, errors, plan}, nothing saved |
PUT /v1/workflows/{id}/schedule · …/trigger |
{cron, enabled} · {kind, …}; {} clears |
POST /v1/workflows/{id}/run |
{params} → {run: {id, status, …}} |
GET /v1/workflow-runs/{id} · …/events · …/log · POST …/stop |
the run · its events (SSE) · its trace · stop it |
GET/POST /v1/webhooks · DELETE /v1/webhooks/{id} |
outgoing webhooks |
Apache-2.0 · https://kweo.ai/developers
Metadata
Release files for kweo 5.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kweo-5.1.0-py3-none-any.whl | Python 3 | none | any | Details for kweo-5.1.0-py3-none-any.whl |
Release files / kweo-5.1.0-py3-none-any.whl
| Download URL | kweo-5.1.0-py3-none-any.whl |
|---|---|
| Size | 51.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0909bb71eb3ff1659101276b1d8d8e541561a036a7f312a886cb187391ac85e3
|
|
BLAKE2b-256 checksum How to use checksums |
caefd2178378bd7cc6a9af2635f7a1d686631f9d6f68d804e4d542fba32d29a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Security for kweo 5.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.