Skip to main content

Thin client for the Cortex web cartography runtime — map, compile, and query websites from Python

Project description

cortex-client

Thin Python client for Cortex — the rapid web cartographer for AI agents.

Install

pip install cortex-client

Requires the Cortex runtime. Install with: cargo install cortex-runtime The daemon starts automatically on first use.

Quick Start

import cortex_client

# Map a website into a navigable graph
site = cortex_client.map("amazon.com")
print(f"Mapped {len(site.nodes)} pages, {len(site.edges)} links")

# Find products under $300
products = site.filter(page_type=0x04, features={48: {"lt": 300}}, limit=10)
for p in products:
    print(f"  {p.url}  price={p.features[48]}")

# Find the shortest path between two pages
path = site.pathfind(0, products[0].index)
print(f"Path: {' → '.join(str(n) for n in path.nodes)}")

Page Types

Use these codes with page_type= filters:

Code Type Description
0x01 Home Landing / home page
0x02 ProductListing Category or listing page
0x03 SearchResults Search results
0x04 ProductDetail Individual product page
0x05 Cart Shopping cart
0x06 Article Blog post or news article
0x07 Documentation Docs / help page
0x08 Login Authentication page
0x09 Checkout Checkout flow
0x0A Profile User profile
0x0B ApiEndpoint API endpoint
0x0C Media Video / audio page
0x0D Form General form page
0x0E Dashboard Dashboard / admin
0x0F Error Error page (404, 500)

Feature Dimensions

Each page has a 128-dimensional feature vector. Key dimensions:

Dim Name Example
48 Price (USD) features={48: {"lt": 300}}
49 Original price Sale detection
50 Discount 0.0 - 1.0
51 Availability 1.0 = in stock
52 Rating 0.0 - 5.0
53 Review count Absolute count
80 TLS (HTTPS) 1.0 = secure
96 Action count Available actions

API Reference

Map & Query

# Map a single site
site = cortex_client.map("github.com")

# Map multiple sites
sites = cortex_client.map_many(["amazon.com", "ebay.com"])

# Filter by type + features
products = site.filter(page_type=0x04, features={52: {"gt": 4.0}})

# Pathfind between pages
path = site.pathfind(from_node=0, to_node=42)

# Similarity search
similar = site.similar(node_index=5, limit=10)

Cross-Site Comparison

result = cortex_client.compare(["amazon.com", "ebay.com", "walmart.com"])
print(result.common_types)   # Shared page types
print(result.unique_types)   # Per-site unique types

Single Page Analysis

page = cortex_client.perceive("https://example.com/product/123")
print(page.page_type, page.features, page.actions)

Authentication

session = cortex_client.login("example.com", username="user", password="pass")
site = cortex_client.map("example.com", session=session)

Error Handling

from cortex_client import CortexConnectionError, CortexMapError, CortexTimeoutError

try:
    site = cortex_client.map("example.com")
except CortexConnectionError:
    print("Cortex daemon not running. Start with: cortex start")
except CortexTimeoutError:
    print("Mapping took too long. Try a smaller site or increase timeout.")
except CortexMapError as e:
    print(f"Mapping failed: {e}")

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cortex_agent-1.0.0.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cortex_agent-1.0.0-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file cortex_agent-1.0.0.tar.gz.

File metadata

  • Download URL: cortex_agent-1.0.0.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for cortex_agent-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f323c485a9fd7f9bf95815a80f99e8ceff04e9923d543d8e4c794d2cc7a86e46
MD5 15c27c60327af36983529036e4f7c583
BLAKE2b-256 abfd8a778e3bba2f62a1a8e52920788c8d394da67a1f36d707a3bd78a0eda3c5

See more details on using hashes here.

File details

Details for the file cortex_agent-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: cortex_agent-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 18.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for cortex_agent-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ea98e2d7f74ba481c034ba957b708cc996556275909f9dcab1cfda00133a69b2
MD5 68b8f5e02248b962ca847eec2f752ed8
BLAKE2b-256 c04173ec732b0455507ea965ed0bfac983c6333d2444f6d5cb691ba8b0afb178

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page