@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.
Primary Surface
Start here:run.stream()run.wait()run.cancel()run.statusAgent.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
sideEffectandcostEffectmetadatacanUseTool()input shrinking and denial- hooks, sessions, trace, replay
- semi-realtime
watch.ticks()andwatch.world()inputs;watch.ticks()reads live SimpleFunctions market inspection prices when you pass an API key or client, and otherwise marks deterministic development ticks assynthetic: true
@spfunctions/agent when your TypeScript app owns the loop.
Market Watch Agent
Query Surface
Anthropic-style consumers can usequery() 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: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/toolsis the strict SDK/Agent truth./api/toolsis broad compatibility inventory, not canonical Agent SDK truth.get_world_stateandget_regime_historyare not canonical SDK/Agent tool names.