@spfunctions/cli 2.0.6 → 2.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +268 -144
- package/dist/122.index.js +1 -0
- package/dist/160.index.js +1 -1
- package/dist/340.index.js +1 -0
- package/dist/563.index.js +1 -1
- package/dist/634.index.js +13 -0
- package/dist/77.index.js +1 -0
- package/dist/index.js +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,109 +1,247 @@
|
|
|
1
1
|
# SimpleFunctions CLI (`sf`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A terminal-native prediction market agent. Builds causal models of the world, scans 4,000+ Kalshi and Polymarket contracts for mispricings, and trades on your thesis — autonomously or with you in the loop.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
```
|
|
6
|
+
$ sf world
|
|
7
|
+
# World State — 2026-04-05T05:38 UTC
|
|
8
|
+
SF Index: Uncertainty 22/100 | Geopolitical Risk 53/100
|
|
9
|
+
|
|
10
|
+
Markets: SPY $655.94 (+0.12%) | GLD $429.08 (-1.79%) | USO $138.18 (+11.99%)
|
|
11
|
+
|
|
12
|
+
## Geopolitical
|
|
13
|
+
- Will the U.S. invade Iran before 2027?: 54c (-7c)
|
|
14
|
+
- Russia x Ukraine ceasefire by end of 2026?: 30c
|
|
15
|
+
|
|
16
|
+
## Economy
|
|
17
|
+
- US recession by end of 2026?: 28c
|
|
18
|
+
- How many Fed rate cuts in 2026?: 0 (0 bps): 36c
|
|
19
|
+
```
|
|
6
20
|
|
|
7
|
-
##
|
|
21
|
+
## Install
|
|
8
22
|
|
|
9
23
|
```bash
|
|
10
24
|
npm install -g @spfunctions/cli
|
|
11
|
-
sf
|
|
12
|
-
sf
|
|
13
|
-
|
|
25
|
+
sf login # browser auth (recommended)
|
|
26
|
+
sf status # verify everything works
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## What it does
|
|
30
|
+
|
|
31
|
+
**World model** — Real-time prediction index distilled from thousands of markets. One command gives any LLM situational awareness.
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
sf world # ~800 token world state snapshot
|
|
35
|
+
sf world --delta # what changed since last check (~30 tokens)
|
|
36
|
+
sf world --focus energy,geo # deep coverage on specific topics
|
|
37
|
+
sf ideas # S&T-style trade ideas with catalyst + risk
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Thesis engine** — Structured causal models with Bayesian node trees, continuous evaluation against live market data, and automatic edge detection.
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
sf create "Oil will exceed $120 by Q3 due to Hormuz disruption"
|
|
44
|
+
sf list # all theses with confidence + status
|
|
45
|
+
sf context <id> # causal tree + top edges + positions
|
|
46
|
+
sf evaluate <id> # trigger deep re-evaluation
|
|
47
|
+
sf signal <id> "OPEC cuts" # inject a signal for next eval cycle
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Edge detection** — Cross-venue scanner compares your model's probabilities against Kalshi and Polymarket prices.
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
sf edges # top mispricings across all theses
|
|
54
|
+
sf scan "recession" # search 4,000+ markets by keyword
|
|
55
|
+
sf book KXRECSSNBER-26 # orderbook depth
|
|
56
|
+
sf watch oil orderbook # live terminal orderbook stream
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Intent system** — Declarative execution: describe what you want, the runtime handles when and how.
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
sf intent buy KXRECSSNBER-26 10 --price 30 --trigger below:28 --auto
|
|
63
|
+
sf intent list # active intents + fill status
|
|
64
|
+
sf runtime start # daemon evaluates triggers, executes orders
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Interactive agent** — Natural language interface with 30+ tools. Maintains a persistent workspace, shares context across sessions, and can schedule its own future actions.
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
sf agent <id> # TUI agent with tool calling
|
|
71
|
+
sf agent <id> --once "summarize my portfolio risk" # single-shot
|
|
72
|
+
sf agent <id> --plain # readline mode, no TUI
|
|
73
|
+
sf telegram --daemon # Telegram bot (text + voice)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**X / Twitter intelligence** — Social signal layer.
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
sf x "tariff impact" # discussion summary + top posts
|
|
80
|
+
sf x-volume "iran oil" # volume and velocity trend
|
|
81
|
+
sf x-news "fed rate" # Grok-aggregated news stories
|
|
82
|
+
sf x-account @elikinosian # recent posts from an account
|
|
14
83
|
```
|
|
15
84
|
|
|
16
85
|
## Setup
|
|
17
86
|
|
|
18
|
-
###
|
|
87
|
+
### Quick (browser login)
|
|
19
88
|
|
|
20
89
|
```bash
|
|
21
|
-
sf
|
|
90
|
+
sf login
|
|
22
91
|
```
|
|
23
92
|
|
|
24
|
-
|
|
25
|
-
1. **SF API key** (required) — get one at [simplefunctions.dev](https://simplefunctions.dev)
|
|
26
|
-
2. **Kalshi credentials** (optional) — for positions, trading, and orderbook data
|
|
27
|
-
3. **Trading mode** (optional) — enable `sf buy`/`sf sell` commands
|
|
93
|
+
### Power user
|
|
28
94
|
|
|
29
|
-
|
|
95
|
+
```bash
|
|
96
|
+
sf setup # interactive wizard: API key, Kalshi, Polymarket, trading
|
|
97
|
+
sf setup --check # show config status
|
|
98
|
+
sf setup --polymarket # configure Polymarket wallet
|
|
99
|
+
sf setup --enable-trading # unlock buy/sell/intent commands
|
|
100
|
+
```
|
|
30
101
|
|
|
31
|
-
|
|
102
|
+
Config is saved to `~/.sf/config.json`. Environment variables override config values:
|
|
32
103
|
|
|
33
104
|
```bash
|
|
34
|
-
export SF_API_KEY=sf_live_xxx
|
|
35
|
-
export KALSHI_API_KEY_ID=xxx
|
|
36
|
-
export KALSHI_PRIVATE_KEY_PATH=~/.
|
|
105
|
+
export SF_API_KEY=sf_live_xxx
|
|
106
|
+
export KALSHI_API_KEY_ID=xxx
|
|
107
|
+
export KALSHI_PRIVATE_KEY_PATH=~/.kalshi/private.pem
|
|
37
108
|
```
|
|
38
109
|
|
|
39
110
|
### Verify
|
|
40
111
|
|
|
41
112
|
```bash
|
|
42
|
-
sf
|
|
43
|
-
|
|
113
|
+
$ sf status
|
|
114
|
+
API ok simplefunctions.dev 252ms
|
|
115
|
+
Auth ok sf_live_8838...
|
|
116
|
+
Kalshi ok $156.42 balance
|
|
117
|
+
Polymarket ok 0xd53b9354...
|
|
118
|
+
Theses ok 4 active, 4 total
|
|
119
|
+
Trading ok enabled
|
|
120
|
+
Runtime -- not running (sf runtime start)
|
|
121
|
+
Telegram ok PID 84372
|
|
44
122
|
```
|
|
45
123
|
|
|
46
|
-
##
|
|
124
|
+
## Command Reference
|
|
47
125
|
|
|
48
|
-
###
|
|
126
|
+
### World Model (no auth required)
|
|
49
127
|
|
|
50
128
|
| Command | Description |
|
|
51
129
|
|---------|-------------|
|
|
52
|
-
| `sf
|
|
53
|
-
| `sf
|
|
54
|
-
| `sf
|
|
55
|
-
| `sf
|
|
56
|
-
| `sf
|
|
57
|
-
| `sf
|
|
58
|
-
| `sf publish <id>` | Make thesis publicly viewable |
|
|
59
|
-
| `sf unpublish <id>` | Remove from public view |
|
|
130
|
+
| `sf world` | Prediction index: markets + geopolitics + economy + crypto + elections |
|
|
131
|
+
| `sf world --delta` | Changes since last check (~30 tokens, ideal for agent polling) |
|
|
132
|
+
| `sf world --focus <topics>` | Deep coverage on specific topics |
|
|
133
|
+
| `sf ideas` | Trade ideas with conviction, catalyst, direction, risk |
|
|
134
|
+
| `sf query "question"` | LLM-enhanced market knowledge search |
|
|
135
|
+
| `sf markets` | Traditional markets: SPY, VIX, bonds, gold, oil |
|
|
60
136
|
|
|
61
|
-
###
|
|
137
|
+
### Thesis
|
|
62
138
|
|
|
63
139
|
| Command | Description |
|
|
64
140
|
|---------|-------------|
|
|
65
|
-
| `sf
|
|
66
|
-
| `sf
|
|
67
|
-
| `sf
|
|
68
|
-
| `sf
|
|
141
|
+
| `sf list` | All theses with status, confidence, last update |
|
|
142
|
+
| `sf get <id>` | Full details: causal tree, edges, evaluation history |
|
|
143
|
+
| `sf context [id]` | No id: global market snapshot. With id: thesis context |
|
|
144
|
+
| `sf create "thesis"` | Create a new thesis |
|
|
145
|
+
| `sf signal <id> "text"` | Inject signal for next evaluation |
|
|
146
|
+
| `sf evaluate <id>` | Trigger deep re-evaluation |
|
|
147
|
+
| `sf augment <id>` | Evolve causal tree with new nodes |
|
|
148
|
+
| `sf heartbeat <id>` | View/configure autonomous evaluation schedule + costs |
|
|
149
|
+
| `sf publish` / `sf unpublish <id>` | Manage public visibility |
|
|
150
|
+
|
|
151
|
+
### Markets
|
|
69
152
|
|
|
70
|
-
|
|
153
|
+
| Command | Description |
|
|
154
|
+
|---------|-------------|
|
|
155
|
+
| `sf scan "keywords"` | Search Kalshi + Polymarket by keyword |
|
|
156
|
+
| `sf scan --series TICKER` | Browse all markets in a Kalshi series |
|
|
157
|
+
| `sf edges [--json]` | Top mispricings across all theses |
|
|
158
|
+
| `sf watch [query] [mode]` | Live market watch (modes: orderbook, flow, cross-venue, all) |
|
|
159
|
+
| `sf book <ticker> [...]` | Orderbook depth for specific markets |
|
|
160
|
+
| `sf whatif <id>` | What-if scenario analysis on causal tree |
|
|
161
|
+
| `sf liquidity [topic]` | Orderbook liquidity scanner |
|
|
162
|
+
| `sf forecast <event>` | Market distribution (P50/P75/P90) |
|
|
163
|
+
| `sf explore [slug]` | Browse public theses |
|
|
164
|
+
|
|
165
|
+
### Portfolio
|
|
71
166
|
|
|
72
167
|
| Command | Description |
|
|
73
168
|
|---------|-------------|
|
|
74
|
-
| `sf
|
|
75
|
-
| `sf positions` | Current positions with P&L and edge overlay |
|
|
169
|
+
| `sf positions` | Kalshi + Polymarket positions with P&L |
|
|
76
170
|
| `sf balance` | Account balance |
|
|
77
171
|
| `sf orders` | Resting (open) orders |
|
|
78
172
|
| `sf fills` | Recent trade fills |
|
|
79
|
-
| `sf performance` | P&L over time with thesis event annotations |
|
|
80
173
|
| `sf settlements` | Settled contracts with final P&L |
|
|
81
|
-
| `sf
|
|
174
|
+
| `sf performance` | P&L over time with event annotations |
|
|
175
|
+
| `sf dashboard` | Interactive TUI portfolio overview |
|
|
176
|
+
|
|
177
|
+
### Intents & Runtime
|
|
82
178
|
|
|
83
|
-
|
|
179
|
+
Intents are declarative execution orders. You define the trade and trigger condition; the runtime daemon evaluates and executes.
|
|
84
180
|
|
|
85
181
|
| Command | Description |
|
|
86
182
|
|---------|-------------|
|
|
87
|
-
| `sf buy <ticker> <qty>` |
|
|
183
|
+
| `sf intent buy <ticker> <qty>` | Create buy intent (`--trigger below:28`, `--trigger time:<ISO>`, `--soft "condition"`, `--auto`) |
|
|
184
|
+
| `sf intent sell <ticker> <qty>` | Create sell intent |
|
|
185
|
+
| `sf intent list` | Active intents (`--all` for history) |
|
|
186
|
+
| `sf intent status <id>` | Detailed status + fills |
|
|
187
|
+
| `sf intent cancel <id>` | Cancel an intent |
|
|
188
|
+
| `sf runtime start` | Start execution daemon (Kalshi + Polymarket) |
|
|
189
|
+
| `sf runtime stop` | Stop daemon |
|
|
190
|
+
| `sf runtime status` | Active intents + runtime state |
|
|
191
|
+
| `sf backtest <ticker>` | Strategy backtest (`--entry-below 35 --stop 20 --tp 60 --days 30`) |
|
|
192
|
+
| `sf heartbeat <id>` | View/configure heartbeat + closed-loop (`--closed-loop-entry`, `--closed-loop-exit`) |
|
|
193
|
+
|
|
194
|
+
### Trading (requires `--enable-trading`)
|
|
195
|
+
|
|
196
|
+
| Command | Description |
|
|
197
|
+
|---------|-------------|
|
|
198
|
+
| `sf buy <ticker> <qty>` | Buy contracts (`--price 31`, `--market`, `--side yes\|no`) |
|
|
88
199
|
| `sf sell <ticker> <qty>` | Sell contracts |
|
|
89
200
|
| `sf cancel [orderId]` | Cancel order(s) |
|
|
90
201
|
| `sf rfq <ticker> <qty>` | Request for quote on large orders |
|
|
91
202
|
|
|
92
|
-
###
|
|
203
|
+
### Agent
|
|
93
204
|
|
|
94
205
|
| Command | Description |
|
|
95
206
|
|---------|-------------|
|
|
96
|
-
| `sf
|
|
97
|
-
| `sf
|
|
98
|
-
| `sf
|
|
99
|
-
| `sf
|
|
207
|
+
| `sf agent [id]` | Interactive agent (TUI with panels) |
|
|
208
|
+
| `sf agent [id] --plain` | Readline mode, pipe-friendly |
|
|
209
|
+
| `sf agent [id] --once "prompt"` | Single-shot: run, answer, exit |
|
|
210
|
+
| `sf prompt [id]` | Print dynamic system prompt for any LLM |
|
|
211
|
+
| `sf telegram [--daemon]` | Telegram bot (text + voice messages) |
|
|
212
|
+
|
|
213
|
+
The agent has 30+ tools including market scanning, trading, workspace read/write, X search, self-wake scheduling, and a math calculator. Slash commands inside the agent: `/voice` `/tree` `/edges` `/pos` `/eval` `/balance` `/intents` `/wakes` `/alerts` `/switch` `/model` `/help` `/exit`.
|
|
214
|
+
|
|
215
|
+
### X / Twitter
|
|
100
216
|
|
|
101
|
-
|
|
217
|
+
| Command | Description |
|
|
218
|
+
|---------|-------------|
|
|
219
|
+
| `sf x "query"` | Discussion summary + top posts |
|
|
220
|
+
| `sf x-volume "query"` | Discussion volume and velocity trend |
|
|
221
|
+
| `sf x-news "query"` | Grok-aggregated news stories |
|
|
222
|
+
| `sf x-account @username` | Recent posts from a specific account |
|
|
223
|
+
|
|
224
|
+
### Info
|
|
102
225
|
|
|
103
226
|
| Command | Description |
|
|
104
227
|
|---------|-------------|
|
|
105
|
-
| `sf
|
|
106
|
-
| `sf
|
|
228
|
+
| `sf feed` | Evaluation history stream |
|
|
229
|
+
| `sf delta <id>` | Changes since last check |
|
|
230
|
+
| `sf milestones` | Upcoming Kalshi events |
|
|
231
|
+
| `sf schedule` | Exchange status |
|
|
232
|
+
| `sf announcements` | Exchange announcements |
|
|
233
|
+
| `sf history <ticker>` | Historical market data |
|
|
234
|
+
| `sf status` | Full system health check |
|
|
235
|
+
|
|
236
|
+
### Sharing
|
|
237
|
+
|
|
238
|
+
Any command with `--share` generates a short URL:
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
sf scan "gold" --share
|
|
242
|
+
sf query "fed rate" --share
|
|
243
|
+
sf context --share
|
|
244
|
+
```
|
|
107
245
|
|
|
108
246
|
## JSON Output
|
|
109
247
|
|
|
@@ -113,139 +251,121 @@ Most commands support `--json` for machine-readable output:
|
|
|
113
251
|
sf list --json
|
|
114
252
|
sf context f582bf76 --json
|
|
115
253
|
sf edges --json
|
|
116
|
-
sf
|
|
117
|
-
sf
|
|
254
|
+
sf world --json
|
|
255
|
+
sf ideas --json
|
|
256
|
+
sf intent list --json
|
|
118
257
|
```
|
|
119
258
|
|
|
120
259
|
## For AI Agents
|
|
121
260
|
|
|
122
|
-
|
|
261
|
+
If you are an AI agent (Claude, GPT, Cursor, etc.), these are the commands that matter:
|
|
123
262
|
|
|
124
|
-
###
|
|
263
|
+
### Setup
|
|
125
264
|
|
|
126
265
|
```bash
|
|
127
266
|
npm install -g @spfunctions/cli
|
|
128
|
-
sf
|
|
267
|
+
sf login # or: export SF_API_KEY=sf_live_xxx
|
|
268
|
+
sf list # verify: should print theses
|
|
129
269
|
```
|
|
130
270
|
|
|
131
|
-
|
|
132
|
-
```bash
|
|
133
|
-
export SF_API_KEY=sf_live_YOUR_KEY_HERE
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### Step 2: Verify it works
|
|
271
|
+
### Primary commands
|
|
137
272
|
|
|
138
273
|
```bash
|
|
139
|
-
|
|
140
|
-
|
|
274
|
+
# World state in ~800 tokens — give your agent situational awareness
|
|
275
|
+
sf world --json
|
|
141
276
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
ID Status Conf Updated Title
|
|
145
|
-
f582bf76 active 82% Mar 12 11:13 Oil prices will exceed $100...
|
|
146
|
-
a1b2c3d4 active 65% Mar 11 09:30 Fed will cut rates by June...
|
|
147
|
-
```
|
|
277
|
+
# What changed since last poll — ~30 tokens, efficient for loops
|
|
278
|
+
sf world --delta --json
|
|
148
279
|
|
|
149
|
-
|
|
280
|
+
# Thesis context: causal tree + edges + positions + evaluation
|
|
281
|
+
sf context <thesisId> --json
|
|
150
282
|
|
|
151
|
-
|
|
283
|
+
# Top mispricings across all theses
|
|
284
|
+
sf edges --json
|
|
152
285
|
|
|
153
|
-
|
|
154
|
-
sf
|
|
286
|
+
# Single-shot agent: ask a question, get an answer, exit
|
|
287
|
+
sf agent <thesisId> --once "what is the biggest risk to my portfolio?"
|
|
155
288
|
```
|
|
156
289
|
|
|
157
|
-
|
|
290
|
+
### Key JSON fields
|
|
291
|
+
|
|
292
|
+
`sf context <id> --json` returns:
|
|
158
293
|
|
|
159
294
|
```json
|
|
160
295
|
{
|
|
161
|
-
"
|
|
162
|
-
"thesis": "Oil prices will exceed $100 by end of 2026",
|
|
163
|
-
"title": "Oil Bull Thesis",
|
|
164
|
-
"status": "active",
|
|
165
|
-
"confidence": 0.82,
|
|
296
|
+
"confidence": 0.31,
|
|
166
297
|
"causalTree": {
|
|
167
|
-
"
|
|
168
|
-
"nodes": [
|
|
169
|
-
{
|
|
170
|
-
"id": "n1",
|
|
171
|
-
"label": "Supply disruption",
|
|
172
|
-
"probability": 0.75,
|
|
173
|
-
"importance": 0.6,
|
|
174
|
-
"depth": 0
|
|
175
|
-
}
|
|
176
|
-
]
|
|
298
|
+
"nodes": [{ "id": "n1", "label": "...", "probability": 0.95 }]
|
|
177
299
|
},
|
|
178
|
-
"edges": [
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
"thesisPrice": 55,
|
|
186
|
-
"edge": 20,
|
|
187
|
-
"confidence": 0.8
|
|
188
|
-
}
|
|
189
|
-
],
|
|
190
|
-
"lastEvaluation": {
|
|
191
|
-
"summary": "Supply concerns rising due to...",
|
|
192
|
-
"newConfidence": 0.82,
|
|
193
|
-
"confidenceDelta": 0.03
|
|
194
|
-
}
|
|
300
|
+
"edges": [{
|
|
301
|
+
"marketId": "KXWTIMAX-26DEC31-T140",
|
|
302
|
+
"venue": "kalshi",
|
|
303
|
+
"marketPrice": 62,
|
|
304
|
+
"thesisPrice": 95,
|
|
305
|
+
"edge": 33
|
|
306
|
+
}]
|
|
195
307
|
}
|
|
196
308
|
```
|
|
197
309
|
|
|
198
|
-
**Key fields:**
|
|
199
310
|
- `confidence` — overall thesis probability (0 to 1)
|
|
200
|
-
- `edges[].edge` — mispricing
|
|
201
|
-
- `edges[].marketPrice` — current market price
|
|
202
|
-
- `edges[].thesisPrice` — what the thesis model thinks the price should be
|
|
203
|
-
- `lastEvaluation.summary` — human-readable summary of latest analysis
|
|
311
|
+
- `edges[].edge` — mispricing in cents (positive = market underpriced vs model)
|
|
312
|
+
- `edges[].marketPrice` — current market price (0-100 cents)
|
|
204
313
|
|
|
205
|
-
###
|
|
314
|
+
### Patterns
|
|
206
315
|
|
|
207
316
|
```bash
|
|
208
|
-
#
|
|
209
|
-
sf
|
|
210
|
-
|
|
211
|
-
# View top edges (mispricings) across all theses
|
|
212
|
-
sf edges --json
|
|
213
|
-
|
|
214
|
-
# Search Kalshi markets by keyword
|
|
215
|
-
sf scan "recession" --json
|
|
317
|
+
# Monitor: poll world state, react to deltas
|
|
318
|
+
sf world --delta --json
|
|
216
319
|
|
|
217
|
-
#
|
|
218
|
-
sf
|
|
320
|
+
# React to news: inject signal, re-evaluate, read updated state
|
|
321
|
+
sf signal <id> "Breaking: OPEC cuts production" --type news
|
|
322
|
+
sf evaluate <id>
|
|
323
|
+
sf context <id> --json
|
|
219
324
|
|
|
220
|
-
#
|
|
221
|
-
sf
|
|
325
|
+
# Trade: create intent with trigger, let runtime execute
|
|
326
|
+
sf intent buy KXRECSSNBER-26 5 --price 30 --trigger below:28 --auto
|
|
327
|
+
sf runtime start
|
|
222
328
|
```
|
|
223
329
|
|
|
224
|
-
###
|
|
330
|
+
### Error codes
|
|
225
331
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
332
|
+
| Error | Fix |
|
|
333
|
+
|-------|-----|
|
|
334
|
+
| "API key required" | `sf login` or set `SF_API_KEY` |
|
|
335
|
+
| "Thesis not found" | `sf list` to get valid IDs (8-char prefix works) |
|
|
336
|
+
| "Kalshi not configured" | `sf setup` to add Kalshi credentials |
|
|
337
|
+
| "Trading disabled" | `sf setup --enable-trading` |
|
|
230
338
|
|
|
231
|
-
|
|
232
|
-
```bash
|
|
233
|
-
sf signal <id> "Reuters: Iran nuclear deal collapses" --type news
|
|
234
|
-
sf evaluate <id> # trigger re-evaluation after injecting signal
|
|
235
|
-
sf context <id> --json # read updated state
|
|
236
|
-
```
|
|
339
|
+
## Architecture
|
|
237
340
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
341
|
+
```
|
|
342
|
+
You ──→ sf agent ──→ LLM (Claude/GPT) ──→ 30+ tools
|
|
343
|
+
│ │
|
|
344
|
+
│ ┌────────────────────────┘
|
|
345
|
+
▼ ▼
|
|
346
|
+
┌─────────────────────┐
|
|
347
|
+
│ SF API Server │
|
|
348
|
+
│ thesis · edges · │
|
|
349
|
+
│ intents · eval · │
|
|
350
|
+
│ proxy (LLM/TTS) │
|
|
351
|
+
└────────┬────────────┘
|
|
352
|
+
│
|
|
353
|
+
┌────────┴────────┐
|
|
354
|
+
│ │
|
|
355
|
+
┌────▼────┐ ┌──────▼──────┐
|
|
356
|
+
│ Kalshi │ │ Polymarket │
|
|
357
|
+
│ API │ │ API │
|
|
358
|
+
└─────────┘ └─────────────┘
|
|
359
|
+
|
|
360
|
+
Local only (never leaves your machine):
|
|
361
|
+
~/.sf/config.json — API keys, Kalshi private key path
|
|
362
|
+
~/.sf/workspace/ — agent scratchpad (notes, context logs)
|
|
363
|
+
~/.sf/wake/ — scheduled agent wake conditions
|
|
364
|
+
~/.sf/bus/ — daemon ↔ agent message bus
|
|
365
|
+
~/.sf/trade-journal.jsonl — local trade log
|
|
241
366
|
```
|
|
242
367
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
- **"API key required"** — set `SF_API_KEY` env var or run `sf setup --key <key>`
|
|
246
|
-
- **"Thesis not found"** — use `sf list` to get valid thesis IDs. IDs can be short prefixes (first 8 chars)
|
|
247
|
-
- **"Kalshi not configured"** — positions/trading commands need Kalshi credentials via `sf setup`
|
|
248
|
-
- **Exit code 0** — success. **Exit code 1** — error (message printed to stderr)
|
|
368
|
+
**Kalshi credentials never leave your machine.** Orders are signed locally with your RSA private key and sent directly to the Kalshi API. The SF server never sees your trading keys.
|
|
249
369
|
|
|
250
370
|
## Local Development
|
|
251
371
|
|
|
@@ -254,6 +374,10 @@ cd cli
|
|
|
254
374
|
npm install
|
|
255
375
|
npm run dev -- list # run without building
|
|
256
376
|
npm run build # compile to dist/
|
|
257
|
-
npm run test # run
|
|
377
|
+
npm run test # run tests
|
|
258
378
|
npm link # install as global 'sf' command
|
|
259
379
|
```
|
|
380
|
+
|
|
381
|
+
## License
|
|
382
|
+
|
|
383
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";exports.id=122,exports.ids=[122],exports.modules={93122:(t,e,i)=>{e.syncPositionsIfEnabled=async function(){const t=(0,s.loadConfig)();if(!t.syncPositions)return null;if(!t.apiKey)return null;const e=[];try{const{getPositions:t,isKalshiConfigured:s}=await Promise.resolve().then(i.t.bind(i,96139,23));if(s()){const i=await t();if(i)for(const t of i)t.quantity>0&&e.push({ticker:t.ticker,venue:"kalshi",side:t.side||"yes",quantity:t.quantity,avgPrice:t.average_price_paid||0,title:t.market_title||t.ticker})}}catch{}try{const{polymarketGetPositions:s}=await Promise.resolve().then(i.bind(i,34331)),n=t.polymarketWalletAddress||process.env.POLYMARKET_WALLET_ADDRESS;if(n){const t=await s(n);for(const i of t){const t=parseFloat(String(i.size||"0"));t>0&&e.push({ticker:i.asset||i.conditionId||"",venue:"polymarket",side:"Yes"===i.outcome?"yes":"no",quantity:Math.round(t),avgPrice:100*parseFloat(String(i.avgPrice||"0")),title:i.title||i.asset||""})}}}catch{}if(0===e.length)return{synced:0,matched:0};try{const t=new n.SFClient,i=await t.syncPositions(e);return{synced:i.synced||0,matched:i.matched||0}}catch{return null}};const s=i(11627),n=i(19218)}};
|