@blockrun/franklin 3.0.0

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.
Files changed (138) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +256 -0
  3. package/dist/agent/commands.d.ts +27 -0
  4. package/dist/agent/commands.js +659 -0
  5. package/dist/agent/compact.d.ts +31 -0
  6. package/dist/agent/compact.js +366 -0
  7. package/dist/agent/context.d.ts +11 -0
  8. package/dist/agent/context.js +184 -0
  9. package/dist/agent/error-classifier.d.ts +10 -0
  10. package/dist/agent/error-classifier.js +61 -0
  11. package/dist/agent/llm.d.ts +63 -0
  12. package/dist/agent/llm.js +448 -0
  13. package/dist/agent/loop.d.ts +12 -0
  14. package/dist/agent/loop.js +346 -0
  15. package/dist/agent/optimize.d.ts +53 -0
  16. package/dist/agent/optimize.js +262 -0
  17. package/dist/agent/permissions.d.ts +39 -0
  18. package/dist/agent/permissions.js +226 -0
  19. package/dist/agent/reduce.d.ts +49 -0
  20. package/dist/agent/reduce.js +317 -0
  21. package/dist/agent/streaming-executor.d.ts +36 -0
  22. package/dist/agent/streaming-executor.js +149 -0
  23. package/dist/agent/tokens.d.ts +53 -0
  24. package/dist/agent/tokens.js +185 -0
  25. package/dist/agent/types.d.ts +125 -0
  26. package/dist/agent/types.js +5 -0
  27. package/dist/banner.d.ts +1 -0
  28. package/dist/banner.js +27 -0
  29. package/dist/commands/balance.d.ts +1 -0
  30. package/dist/commands/balance.js +40 -0
  31. package/dist/commands/config.d.ts +14 -0
  32. package/dist/commands/config.js +107 -0
  33. package/dist/commands/daemon.d.ts +3 -0
  34. package/dist/commands/daemon.js +117 -0
  35. package/dist/commands/history.d.ts +5 -0
  36. package/dist/commands/history.js +31 -0
  37. package/dist/commands/init.d.ts +3 -0
  38. package/dist/commands/init.js +92 -0
  39. package/dist/commands/logs.d.ts +5 -0
  40. package/dist/commands/logs.js +89 -0
  41. package/dist/commands/models.d.ts +1 -0
  42. package/dist/commands/models.js +56 -0
  43. package/dist/commands/plugin.d.ts +14 -0
  44. package/dist/commands/plugin.js +176 -0
  45. package/dist/commands/proxy.d.ts +13 -0
  46. package/dist/commands/proxy.js +106 -0
  47. package/dist/commands/setup.d.ts +1 -0
  48. package/dist/commands/setup.js +49 -0
  49. package/dist/commands/start.d.ts +8 -0
  50. package/dist/commands/start.js +292 -0
  51. package/dist/commands/stats.d.ts +10 -0
  52. package/dist/commands/stats.js +94 -0
  53. package/dist/commands/uninit.d.ts +1 -0
  54. package/dist/commands/uninit.js +63 -0
  55. package/dist/config.d.ts +9 -0
  56. package/dist/config.js +41 -0
  57. package/dist/index.d.ts +2 -0
  58. package/dist/index.js +179 -0
  59. package/dist/mcp/client.d.ts +44 -0
  60. package/dist/mcp/client.js +147 -0
  61. package/dist/mcp/config.d.ts +20 -0
  62. package/dist/mcp/config.js +138 -0
  63. package/dist/plugin-sdk/channel.d.ts +100 -0
  64. package/dist/plugin-sdk/channel.js +10 -0
  65. package/dist/plugin-sdk/index.d.ts +14 -0
  66. package/dist/plugin-sdk/index.js +9 -0
  67. package/dist/plugin-sdk/plugin.d.ts +87 -0
  68. package/dist/plugin-sdk/plugin.js +7 -0
  69. package/dist/plugin-sdk/search.d.ts +13 -0
  70. package/dist/plugin-sdk/search.js +4 -0
  71. package/dist/plugin-sdk/tracker.d.ts +27 -0
  72. package/dist/plugin-sdk/tracker.js +5 -0
  73. package/dist/plugin-sdk/workflow.d.ts +126 -0
  74. package/dist/plugin-sdk/workflow.js +11 -0
  75. package/dist/plugins/registry.d.ts +33 -0
  76. package/dist/plugins/registry.js +155 -0
  77. package/dist/plugins/runner.d.ts +21 -0
  78. package/dist/plugins/runner.js +453 -0
  79. package/dist/plugins-bundled/social/index.d.ts +10 -0
  80. package/dist/plugins-bundled/social/index.js +363 -0
  81. package/dist/plugins-bundled/social/plugin.json +14 -0
  82. package/dist/plugins-bundled/social/prompts.d.ts +19 -0
  83. package/dist/plugins-bundled/social/prompts.js +67 -0
  84. package/dist/plugins-bundled/social/types.d.ts +58 -0
  85. package/dist/plugins-bundled/social/types.js +16 -0
  86. package/dist/pricing.d.ts +21 -0
  87. package/dist/pricing.js +91 -0
  88. package/dist/proxy/fallback.d.ts +38 -0
  89. package/dist/proxy/fallback.js +144 -0
  90. package/dist/proxy/server.d.ts +18 -0
  91. package/dist/proxy/server.js +576 -0
  92. package/dist/proxy/sse-translator.d.ts +29 -0
  93. package/dist/proxy/sse-translator.js +270 -0
  94. package/dist/router/index.d.ts +22 -0
  95. package/dist/router/index.js +269 -0
  96. package/dist/session/search.d.ts +33 -0
  97. package/dist/session/search.js +229 -0
  98. package/dist/session/storage.d.ts +48 -0
  99. package/dist/session/storage.js +173 -0
  100. package/dist/stats/insights.d.ts +55 -0
  101. package/dist/stats/insights.js +195 -0
  102. package/dist/stats/tracker.d.ts +54 -0
  103. package/dist/stats/tracker.js +165 -0
  104. package/dist/tools/askuser.d.ts +6 -0
  105. package/dist/tools/askuser.js +76 -0
  106. package/dist/tools/bash.d.ts +5 -0
  107. package/dist/tools/bash.js +336 -0
  108. package/dist/tools/edit.d.ts +5 -0
  109. package/dist/tools/edit.js +148 -0
  110. package/dist/tools/glob.d.ts +5 -0
  111. package/dist/tools/glob.js +158 -0
  112. package/dist/tools/grep.d.ts +5 -0
  113. package/dist/tools/grep.js +194 -0
  114. package/dist/tools/imagegen.d.ts +6 -0
  115. package/dist/tools/imagegen.js +172 -0
  116. package/dist/tools/index.d.ts +17 -0
  117. package/dist/tools/index.js +30 -0
  118. package/dist/tools/read.d.ts +11 -0
  119. package/dist/tools/read.js +90 -0
  120. package/dist/tools/subagent.d.ts +5 -0
  121. package/dist/tools/subagent.js +116 -0
  122. package/dist/tools/task.d.ts +5 -0
  123. package/dist/tools/task.js +91 -0
  124. package/dist/tools/webfetch.d.ts +5 -0
  125. package/dist/tools/webfetch.js +166 -0
  126. package/dist/tools/websearch.d.ts +5 -0
  127. package/dist/tools/websearch.js +103 -0
  128. package/dist/tools/write.d.ts +5 -0
  129. package/dist/tools/write.js +114 -0
  130. package/dist/ui/app.d.ts +26 -0
  131. package/dist/ui/app.js +545 -0
  132. package/dist/ui/model-picker.d.ts +14 -0
  133. package/dist/ui/model-picker.js +161 -0
  134. package/dist/ui/terminal.d.ts +35 -0
  135. package/dist/ui/terminal.js +337 -0
  136. package/dist/wallet/manager.d.ts +10 -0
  137. package/dist/wallet/manager.js +23 -0
  138. package/package.json +79 -0
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2025 BlockRun AI
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,256 @@
1
+ <h1 align="center">Franklin</h1>
2
+
3
+ <p align="center">
4
+ <strong>The AI agent with a wallet.</strong>
5
+ </p>
6
+
7
+ <p align="center">
8
+ While others chat, Franklin spends — turning your USDC into real work.
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://npmjs.com/package/@blockrun/franklin"><img src="https://img.shields.io/npm/v/@blockrun/franklin.svg?style=flat-square&color=FFD700" alt="npm version"></a>
13
+ <a href="LICENSE"><img src="https://img.shields.io/badge/License-Apache_2.0-blue?style=flat-square" alt="License: Apache-2.0"></a>
14
+ <a href="https://x402.org"><img src="https://img.shields.io/badge/x402-Payments-10B981?style=flat-square" alt="x402"></a>
15
+ <a href="https://franklin.run"><img src="https://img.shields.io/badge/Marketing-franklin.run-06B6D4?style=flat-square" alt="franklin.run"></a>
16
+ <a href="https://franklin.bet"><img src="https://img.shields.io/badge/Trading-franklin.bet-10B981?style=flat-square" alt="franklin.bet"></a>
17
+ </p>
18
+
19
+ ---
20
+
21
+ ## Franklin runs your money
22
+
23
+ Franklin is the first AI agent that can actually **spend money** to get work done. Not just write text about it.
24
+
25
+ ```bash
26
+ $ franklin marketing campaign "Launch my AI coding app to indie hackers"
27
+ Budget cap: $10
28
+
29
+ ✓ $0.50 Research competitors via Exa
30
+ ✓ $1.20 Write 5 blog post drafts (Claude Sonnet 4.6)
31
+ ✓ $0.48 Generate 3 hero images (DALL-E 3)
32
+ ✓ $3.50 Generate 15-second launch video (Runway)
33
+ ✓ $0.80 Generate background music (Suno)
34
+ ✓ $0.30 Find 20 relevant Reddit discussions
35
+ ✓ $1.50 Draft Reddit comments (Claude Sonnet 4.6)
36
+ ✓ $0.10 Post 3 casts to Farcaster
37
+
38
+ Total spent: $8.58 · Time: 4m 32s
39
+ Deliverables: 5 blog posts, 3 hero images, 1 launch video, 1 music
40
+ track, 20 Reddit drafts, 3 Farcaster casts (live)
41
+ ```
42
+
43
+ **One wallet. Every model. Every paid API. No subscriptions. No accounts.**
44
+
45
+ ---
46
+
47
+ ## Two products, one Franklin
48
+
49
+ | | | |
50
+ |---|---|---|
51
+ | 🎯 | **[franklin.run](https://franklin.run)** | **Marketing agent** — campaigns, content, outreach, growth |
52
+ | 📈 | **[franklin.bet](https://franklin.bet)** | **Trading agent** — signals, research, risk analysis |
53
+
54
+ Both paid per action in USDC. Both backed by the same [BlockRun gateway](https://blockrun.ai) and x402 protocol.
55
+
56
+ ---
57
+
58
+ ## Why Franklin is different
59
+
60
+ | | Claude Code | Hermes | OpenClaw | **Franklin** |
61
+ |---|---|---|---|---|
62
+ | Writes text | ✅ | ✅ | ✅ | ✅ |
63
+ | Reads code | ✅ | ✅ | ✅ | ✅ |
64
+ | Multi-model | ❌ Claude only | ✅ BYOK | ✅ BYOK | ✅ **55+ via one wallet** |
65
+ | **Spends money autonomously** | ❌ | ❌ | ❌ | ✅ |
66
+ | **Wallet-native identity** | ❌ | ❌ | ❌ | ✅ |
67
+ | **Pay per action** | ❌ subscription | ❌ BYOK | ❌ BYOK | ✅ USDC |
68
+ | **Marketing workflows** | ❌ | ❌ | ❌ | ✅ franklin.run |
69
+ | **Trading workflows** | ❌ | ❌ | ❌ | ✅ franklin.bet |
70
+ | No account / phone verification | ❌ | ⚠️ BYOK | ⚠️ BYOK | ✅ |
71
+
72
+ **Franklin is the first AI agent in the "Autonomous Economic Agent" category** — an agent that receives a goal, decides what to spend on, and executes autonomously within a hard budget cap enforced by the wallet.
73
+
74
+ ---
75
+
76
+ ## Quick Start
77
+
78
+ ```bash
79
+ # Install
80
+ npm install -g @blockrun/franklin
81
+
82
+ # Create a wallet (Base or Solana)
83
+ franklin setup base
84
+
85
+ # Fund wallet with USDC (any amount, $5 gets you started)
86
+ # Check address: franklin balance
87
+
88
+ # Run
89
+ franklin # Interactive agent — code, research, anything
90
+ franklin marketing run # Marketing workflow
91
+ franklin trading signal "BTC" # Trading workflow
92
+ franklin plugins # List installed plugins
93
+ ```
94
+
95
+ **Start free:** use `franklin` with NVIDIA's free models (Nemotron, Qwen3 Coder) — zero wallet funding required to try it out.
96
+
97
+ ---
98
+
99
+ ## How it works
100
+
101
+ ```
102
+ ┌─────────────────────────────────────────────────┐
103
+ │ Franklin Agent (you) │
104
+ │ Plugin SDK · CLI · Multi-model router │
105
+ ├─────────────────────────────────────────────────┤
106
+ │ BlockRun Gateway │
107
+ │ Aggregates 55+ LLMs + Exa + DALL-E + (soon) │
108
+ │ Runway + Suno + CoinGecko + Dune + Apollo │
109
+ ├─────────────────────────────────────────────────┤
110
+ │ x402 + Wallet Infrastructure │
111
+ │ HTTP 402 micropayments · USDC on Base/Solana │
112
+ └─────────────────────────────────────────────────┘
113
+ ```
114
+
115
+ Every API call is paid atomically from your wallet via the x402 protocol. You fund once; Franklin spends per task. The wallet is your identity — no accounts, no API keys, no KYC.
116
+
117
+ ---
118
+
119
+ ## Features
120
+
121
+ ### Core agent (55+ models)
122
+
123
+ - **Multi-model routing** — Claude Sonnet/Opus, GPT-5.4, Gemini 2.5 Pro, DeepSeek, Grok 4, Kimi, GLM-5.1, Llama, NVIDIA free tier
124
+ - **Automatic fallback** — if one model fails, Franklin tries the next
125
+ - **Smart tiers** — free / cheap / premium per task, user-configurable
126
+ - **Prompt caching** — 75% input token savings on Anthropic multi-turn (Hermes pattern)
127
+ - **Structured context compression** — Goal / Progress / Decisions / Files / Next Steps template
128
+ - **Session search** — `franklin search "payment loop"` — full-text across past sessions
129
+ - **Rich insights** — `franklin insights` — cost breakdown, daily activity sparklines, projections
130
+
131
+ ### Plugin SDK
132
+
133
+ Franklin is plugin-first. Core stays workflow-agnostic. Adding a new vertical requires zero core changes.
134
+
135
+ ```typescript
136
+ import type { Plugin, Workflow } from '@blockrun/franklin/plugin-sdk';
137
+
138
+ const myWorkflow: Workflow = {
139
+ id: 'my-workflow',
140
+ name: 'My Workflow',
141
+ description: '...',
142
+ steps: [
143
+ { name: 'search', modelTier: 'none', execute: async (ctx) => ({ ... }) },
144
+ { name: 'filter', modelTier: 'cheap', execute: async (ctx) => ({ ... }) },
145
+ { name: 'draft', modelTier: 'premium', execute: async (ctx) => ({ ... }) },
146
+ ],
147
+ // ...
148
+ };
149
+ ```
150
+
151
+ Full plugin guide: [docs/plugin-sdk.md](docs/plugin-sdk.md)
152
+
153
+ ### Built-in tools
154
+
155
+ Read · Write · Edit · Bash · Glob · Grep · WebFetch · WebSearch · Task · ImageGen · AskUser · SubAgent (delegated child agents with isolated toolsets)
156
+
157
+ ### MCP integration
158
+
159
+ Auto-discovers installed MCP servers including `blockrun-mcp` (market data, X data, prediction markets) and `unbrowse` (turn any website into an API). Add your own in `~/.blockrun/mcp.json`.
160
+
161
+ ---
162
+
163
+ ## Slash Commands
164
+
165
+ | Command | Description |
166
+ |---------|-------------|
167
+ | `/model` | Interactive model picker · `/model <name>` to switch |
168
+ | `/compact` | Compress conversation history (structured summary) |
169
+ | `/search <query>` | Search past sessions by keyword |
170
+ | `/insights` | Rich usage analytics — cost, trends, projections |
171
+ | `/ultrathink` | Deep reasoning mode for hard problems |
172
+ | `/plan` · `/execute` | Read-only planning mode → execution mode |
173
+ | `/history` · `/resume <id>` | Session management |
174
+ | `/commit` · `/push` · `/pr` · `/review` | Git workflow helpers |
175
+ | `/cost` | Session cost and savings vs Claude Opus |
176
+ | `/wallet` | Wallet address and USDC balance |
177
+ | `/help` | Full command list |
178
+
179
+ ---
180
+
181
+ ## Migration from RunCode
182
+
183
+ **Nothing breaks.** If you were using RunCode, your `runcode` command continues to work as an alias for `franklin` for 60 days. Your config at `~/.blockrun/` is unchanged. Your wallet, sessions, and settings all migrate automatically.
184
+
185
+ The package name is now `@blockrun/franklin`. Update when convenient:
186
+
187
+ ```bash
188
+ npm uninstall -g @blockrun/runcode
189
+ npm install -g @blockrun/franklin
190
+ ```
191
+
192
+ Both commands (`franklin` and `runcode`) work for the next 60 days. After v3.1.0 ships, `runcode` will be removed.
193
+
194
+ ---
195
+
196
+ ## Architecture
197
+
198
+ ```
199
+ src/
200
+ ├── agent/ # Core agent loop, multi-model LLM client, compaction
201
+ ├── tools/ # 12 built-in tools
202
+ ├── plugin-sdk/ # Public plugin contract (Workflow, Channel, Plugin)
203
+ ├── plugins/ # Plugin registry + runner (plugin-agnostic)
204
+ ├── plugins-bundled/ # Ships with Franklin — social, marketing (more coming)
205
+ ├── session/ # Persistent sessions + FTS search
206
+ ├── stats/ # Usage tracking + insights engine
207
+ ├── ui/ # Terminal UI (Ink-based)
208
+ ├── proxy/ # Payment proxy for Claude Code compatibility
209
+ ├── router/ # Smart model tier routing
210
+ ├── wallet/ # Wallet management (Base + Solana)
211
+ └── commands/ # CLI subcommands
212
+ ```
213
+
214
+ ---
215
+
216
+ ## Development
217
+
218
+ ```bash
219
+ git clone https://github.com/BlockRunAI/runcode.git
220
+ cd runcode
221
+ npm install
222
+ npm run build
223
+ npm test # Deterministic local tests (no API calls)
224
+ npm run test:e2e # Live end-to-end tests (hits real models)
225
+ node dist/index.js --help
226
+ ```
227
+
228
+ ---
229
+
230
+ ## Contributing
231
+
232
+ Contributions welcome. Open an issue first to discuss meaningful changes. For plugin ideas, see [docs/plugin-sdk.md](docs/plugin-sdk.md) — the plugin system is how most new features should land.
233
+
234
+ ---
235
+
236
+ ## Links
237
+
238
+ - **Marketing**: [franklin.run](https://franklin.run)
239
+ - **Trading**: [franklin.bet](https://franklin.bet)
240
+ - **Parent**: [BlockRun](https://blockrun.ai)
241
+ - **npm**: [@blockrun/franklin](https://npmjs.com/package/@blockrun/franklin)
242
+ - **Telegram**: [t.me/blockrunAI](https://t.me/blockrunAI)
243
+ - **x402 protocol**: [x402.org](https://x402.org)
244
+
245
+ ---
246
+
247
+ ## License
248
+
249
+ Apache-2.0. See [LICENSE](LICENSE).
250
+
251
+ ---
252
+
253
+ <p align="center">
254
+ <strong>Franklin runs your money.</strong><br>
255
+ <sub>Your wallet, your agent, your results.</sub>
256
+ </p>
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Slash command registry for runcode.
3
+ * Extracted from loop.ts for maintainability.
4
+ *
5
+ * Two types of commands:
6
+ * 1. "Handled" — execute directly, emit events, return { handled: true }
7
+ * 2. "Rewrite" — transform input into a prompt for the agent, return { handled: false, rewritten }
8
+ */
9
+ import type { ModelClient } from './llm.js';
10
+ import type { AgentConfig, Dialogue, StreamEvent } from './types.js';
11
+ type EventEmitter = (event: StreamEvent) => void;
12
+ interface CommandContext {
13
+ history: Dialogue[];
14
+ config: AgentConfig;
15
+ client: ModelClient;
16
+ sessionId: string;
17
+ onEvent: EventEmitter;
18
+ }
19
+ interface CommandResult {
20
+ handled: boolean;
21
+ rewritten?: string;
22
+ }
23
+ /**
24
+ * Handle a slash command. Returns result indicating what happened.
25
+ */
26
+ export declare function handleSlashCommand(input: string, ctx: CommandContext): Promise<CommandResult>;
27
+ export {};