Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.simplefunctions.dev/llms.txt

Use this file to discover all available pages before exploring further.

Summary

SimpleFunctions should let builders use the SDK and Agent SDK to build full-chain applications and agent swarms:
  1. research markets and theses,
  2. monitor world, market, and user state,
  3. propose and execute Kalshi or Polymarket orders,
  4. manage live intents, fills, orders, positions, and risk.
The execution surface is not hard-forbidden at the contract layer. Execution is an explicit side-effect class that applications can allow through configurable safety valves.

Product goal

Builders should be able to create:
  • desk apps that scan, inspect, and place bounded Kalshi or Polymarket orders;
  • agent swarms where different agents own research, risk, execution, and reconciliation;
  • autonomous loops that can create intents, start or observe runtime, manage orders, and close or cancel exposure;
  • audit-ready workflows where every action is traceable and policy-reviewed.

Non-goals

  • No unguarded autonomous trading.
  • No promise of profitability or investment performance.
  • No replacement of venue terms, geography restrictions, credential requirements, or compliance review.
  • No SDK dependency on the CLI package.

Safety model

Execution must be supported, but applications need configurable safety valves:
  • maxSideEffect: maximum side-effect class allowed by the agent policy.
  • maxCostEffect: maximum provider/API/venue cost class allowed.
  • trade.maxOrderCostCents: maximum notional per order.
  • trade.maxQuantity: maximum contracts per order.
  • trade.allowedVenues: venue allowlist, such as ["kalshi"] or ["polymarket"].
  • trade.blockedVenues: explicit venue denylist.
  • trade.requireJurisdiction: require a jurisdiction field before live execution.
  • trade.blockedJurisdictions: jurisdiction denylist for venue-specific compliance safety valves.
  • trade.allowedTickers: optional ticker allowlist.
  • trade.requireLimitPrice: require maxPrice or limitPrice for order-producing tools.
  • trade.allowRuntimeStart: allow SDK runtime orchestration to start or wake a runtime.
  • trade.confirmToken: optional operator-provided token that must match input.confirm.
The default Agent SDK policy remains conservative. Trading tools are callable only after the application opts into live-trade side effects, venue cost, auth, and trade guardrails.

Contract surfaces

Read and research surfaces:
  • world.read
  • markets.search
  • markets.screen
  • market.inspect
  • market.candles
  • portfolio.state
  • portfolio.ticks.list
  • portfolio.trades.list
  • intents.list
Intent management:
  • intents.create
  • intents.get
  • intents.cancel
Runtime and execution:
  • runtime.status
  • runtime.ensure
  • execution.place
live_trade is a side-effect class and compatibility alias for execution.place, not the canonical SDK method name.

SDK requirements

The SDK exposes typed wrappers:
await sf.intents.create({
  action: "buy",
  venue: "kalshi",
  marketId: "KXFED-27APR-T3.50",
  marketTitle: "Fed target rate",
  direction: "yes",
  targetQuantity: 2,
  maxPrice: 32,
  triggerType: "immediate",
  autoExecute: true,
})

await sf.runtime.status()
await sf.runtime.ensure()

await sf.execution.place({
  ticker: "KXFED-27APR-T3.50",
  action: "buy",
  quantity: 2,
  limitPrice: 32,
  runtime: { startIfNeeded: true },
})

await sf.execution.place({
  venue: "polymarket",
  tokenId: "POLYMARKET_CLOB_TOKEN_ID",
  action: "buy",
  quantity: 2,
  limitPrice: 32,
  runtime: { startIfNeeded: true },
})
Polymarket calls require a CLOB token id and explicit limit pricing. Venue signing is runtime-backed with user-configured credentials.

Agent SDK requirements

The Agent SDK exposes the same canonical tools:
await agent.call("execution.place", {
  ticker: "KXFED-27APR-T3.50",
  action: "buy",
  quantity: 2,
  limitPrice: 32,
  confirm: "operator-token",
})

await agent.call("execution.place", {
  venue: "polymarket",
  tokenId: "POLYMARKET_CLOB_TOKEN_ID",
  action: "buy",
  quantity: 2,
  limitPrice: 32,
  jurisdiction: "CA",
  confirm: "operator-token",
})
Policies must deny execution unless maxSideEffect, maxCostEffect, and trade guardrails explicitly allow it.

Runtime routing

execution.place checks cloud and configured SDK runtime candidates before creating the intent. Hosted cloud status is daemon-aware: a started machine without a live runtime daemon is not treated as executable. If none is running, runtime.ensure starts or wakes one when allowed. Set runtime: { mode: "none" } only for explicit intent-only workflows.

Routing boundary

  • SDK and Agent SDK reads go to the configured SimpleFunctions API base URL. Default: https://simplefunctions.dev.
  • Agent SDK tools use the SDK client; they do not shell out to the CLI.
  • SDK packages do not depend on CLI packages.
  • Local/self-hosted runtimes are plugged in through SDK runtime controllers or an explicit SF_API_URL.

Verification gates

Before exposing a full-chain workflow to users:
  • SDK and Agent SDK tests pass.
  • Contract manifest maps every tool to side-effect, cost, auth, trace, replay, HTTP, SDK, and Agent metadata.
  • Consumer smoke installs published packages from npm.
  • Runtime status proves the daemon is live, not only that a machine is started.
  • Trading examples use limit prices and policy guardrails.
  • Docs show Kalshi and Polymarket as dual-venue surfaces.