Skip to main content
@spfunctions/agent is the SimpleFunctions Agent SDK. It gives a TypeScript runtime a Cursor-style run lifecycle plus SimpleFunctions market/world context. The package has two layers: the v0 direct runner for deterministic canonical tool calls, trace, and replay, and the v1 model loop for Agent.create().send().stream() runs. It does not shell out to the CLI.
Use the stable 1.0.1 SDK and 1.0.2 Agent SDK packages in server-side TypeScript apps.

Primary Surface

Start here:
The run handle supports:
  • run.stream()
  • run.wait()
  • run.cancel()
  • run.status
  • Agent.getRun(run.id, { agentId })
  • agent.send(prompt, { onDelta, onStep })
Agent.create({ apiKey }) mounts read-only SimpleFunctions strict tools by default. It does not mount user writes such as watchlists.add, alerts.create, or thesis writes unless you explicitly pass builtinTools: "all" or a named allowlist.

Why This Is Not A Generic Coding SDK

Claude Agent SDK, Codex SDK, and Cursor SDK give agents file, shell, editor, repo, or conversation control. SimpleFunctions gives agents a governed view of prediction markets:
  • strict canonical tools from /api/contracts/tools
  • world state, market search, market inspection, OHLCV candles, screeners, regime scans, event calendars, index snapshots, contagion scans, cross-venue pairs, yield curves, calibration summaries, and econ/gov/query reads
  • sideEffect and costEffect metadata
  • canUseTool() input shrinking and denial
  • hooks, sessions, trace, replay
  • semi-realtime watch.ticks() and watch.world() inputs; watch.ticks() reads live SimpleFunctions market inspection prices when you pass an API key or client, and otherwise marks deterministic development ticks as synthetic: true
Use CLI or MCP when Claude Code, Codex, Cursor, or another host owns the runtime. Use @spfunctions/agent when your TypeScript app owns the loop.

Market Watch Agent

Query Surface

Anthropic-style consumers can use query() directly:
query() yields ordered SDKMessage events and supports interrupt(), setModel(), setPermissionMode(), setMcpServers(), streamInput(), close(), and initializationResult().

Identity, Execution, And Replay

Live Agent execution requires an API-keyed SDK client. The no-key path is for strict manifest inspection and replay-only harnesses, not live market execution. The v0 direct runner remains available for deterministic tool calls, file traces, and replay:
Execution tools are available only when the policy explicitly permits live-trade side effects, venue-request cost, and trade guardrails:
Polymarket uses the same governed tool with venue: "polymarket" and a CLOB token id. Add jurisdiction guardrails when the application needs venue-specific compliance controls:
execution.place checks runtime candidates and starts or wakes a usable runtime before creating the intent. Set trade.allowRuntimeStart: false when runtime startup must be controlled outside the agent. Replay misses never fall through to live execution. Trace redaction removes API keys, authorization headers, tokens, secrets, passwords, signing secrets, and webhook secrets.

Boundaries

  • Live trading is available only through explicit strict execution tools and opt-in policy guardrails.
  • No browser long-lived API key examples.
  • The Agent SDK does not shell out to the CLI; runtime orchestration goes through SDK runtime resources.
  • /api/contracts/tools is the strict SDK/Agent truth.
  • /api/tools is broad compatibility inventory, not canonical Agent SDK truth.
  • get_world_state and get_regime_history are not canonical SDK/Agent tool names.