@soba-so/mcp 0.0.3 → 0.0.4

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 (2) hide show
  1. package/dist/mcp.mjs +6 -301
  2. package/package.json +1 -1
package/dist/mcp.mjs CHANGED
@@ -1,300 +1,5 @@
1
1
  #!/usr/bin/env node
2
- var u=class extends Error{constructor(e,r){super(r);this.status=e;this.name="ApiError"}},c=class{constructor(t,e){this.token=t;this.baseUrl=e}get(t){return this.call("GET",t)}post(t,e){return this.call("POST",t,e)}patch(t,e){return this.call("PATCH",t,e)}async call(t,e,r){let s=await fetch(`${this.baseUrl}${e}`,{method:t,headers:{authorization:`Bearer ${this.token}`,...r===void 0?{}:{"content-type":"application/json"}},body:r===void 0?void 0:JSON.stringify(r)}),o=await s.text(),i=null;try{i=o?JSON.parse(o):null}catch{throw new u(s.status,`${t} ${e} did not return json (${o.slice(0,120)})`)}if(!s.ok){let l=i?.error;throw new u(s.status,typeof l=="string"?l:`${t} ${e} failed with ${s.status}`)}return i}};var y=36e5,b=24*y,B={returnAfterMs:24*y,expiryMs:30*b,uniquenessMs:365*b};var H=10*6e4;var M=864e5,E=30,ee={abandonedAfterMs:E*M};var re=30*24*60*60*1e3;var oe=5*60*1e3;var _e=60*6e4;var T="https://soba.so/skill",ve=`npx skills add ${T}`;var w=`Soba is the LLM layer for an application whose users bring their own compute.
3
- Requests go to Soba instead of to a model provider; Soba routes each one to the
4
- machine or plan belonging to the user it names, meters it, and bills for it.
5
-
6
- ## The two edits
7
-
8
- Two edits make a Soba app work. Everything after them makes it worth having, and
9
- an app that stops at two has nowhere for a run to land \u2014 so do these first, then
10
- keep going.
11
-
12
- ### 1. Point every LLM call site at Soba
13
-
14
- baseURL https://api.soba.so/v1
15
- apiKey process.env.SOBA_KEY
16
-
17
- An OpenAI client already speaks this, so on most projects the base URL is the
18
- only line that changes. Prompts, tools, streaming and error handling stay
19
- exactly as they are.
20
-
21
- Pass the signed-in user's id as the \`user\` field on every request.
22
-
23
- **Resolve that id on the SERVER, from the session, never from the request
24
- body.** It is what decides whose machine a run may reach, so a value the browser
25
- can choose is a value any user can use to spend any other user's compute. This
26
- is the one line in the integration that must not be guessed at: if the project's
27
- auth is not obvious, read it until it is, or stop and ask. A wrong id here does
28
- not throw \u2014 it silently pairs runs to the wrong person.
29
-
30
- ### Where the key comes from
31
-
32
- If \`.env.local\` already sets \`SOBA_KEY\`, use it. Otherwise run this from the
33
- project root:
34
-
35
- \`\`\`bash
36
- npx -y @soba-so/cli login
37
- \`\`\`
38
-
39
- It opens the person's browser, they pick the app, and it writes \`SOBA_KEY\` (a
40
- development key, for this machine) and \`SOBA_PROD_KEY\` (production) into
41
- \`.env.local\`, adding that file to \`.gitignore\` if git would commit it. The key
42
- never passes through you. Tell the person to approve in the browser before you
43
- run it; it waits up to fifteen minutes for them, so give the command a long
44
- timeout or run it in the background. Add \`--headless\` where no browser can
45
- open, and pass the link it prints on to the person.
46
-
47
- \`.env.local\` is right for Next.js, Vite and most Node servers. Where the code
48
- that holds the key reads a different file, pass that file with \`--env-file\`
49
- instead, from the project root, so the key lands where the server will look:
50
-
51
- | Server | File |
52
- |---|---|
53
- | Cloudflare Worker (\`wrangler dev\`) | \`--env-file <worker dir>/.dev.vars\` |
54
- | A server in a subfolder of a monorepo or an extension repo | \`--env-file <server dir>/.env.local\` |
55
-
56
- Find the file by reading how that server loads its environment, not by its
57
- framework's reputation. The CLI adds whatever file it writes to \`.gitignore\`
58
- if git would commit it.
59
-
60
- On a host that keeps secrets itself \u2014 \`wrangler secret put SOBA_KEY\`, Vercel's
61
- or Railway's environment \u2014 production takes \`SOBA_PROD_KEY\`'s value under the
62
- name \`SOBA_KEY\`. That is the person's to paste; tell them the command.
63
-
64
- A development key reaches only the user's own AI \u2014 their machine, their
65
- subscription, their API key. In production, \`SOBA_KEY\` is set to the value of
66
- \`SOBA_PROD_KEY\` in the host's environment; say so to the person rather than
67
- doing it.
68
-
69
- If you cannot run commands but have a \`soba_create_key\` tool, call it: the
70
- secret is returned once and nothing can show it again, so write it into
71
- \`.env.local\` in the same step. Failing both, ask the person to run the command
72
- above themselves. Do not leave \`SOBA_KEY\`
73
- empty and do not invent a value; both fail at the first request, and the first
74
- fails as an auth error rather than as a missing variable.
75
-
76
- Put \`SOBA_KEY\` in \`.env.local\` (or the server's own file, above), and check
77
- that file is gitignored before writing it. Never in \`.env\`, never in \`.env.example\`, never in anything
78
- tracked, and never echoed back to the terminal.
79
-
80
- ### 2. Mount the connect component
81
-
82
- On the page where a user manages their own account, so they can connect a
83
- machine of their own:
84
-
85
- \`\`\`jsx
86
- import { SobaProvider, ConnectCompute } from "@soba-so/react";
87
-
88
- // Wherever a user manages their own account.
89
- <SobaProvider sessionEndpoint="/api/soba/session">
90
- <ConnectCompute />
91
- </SobaProvider>
92
- \`\`\`
93
-
94
- Back it with \`POST /api/soba/session\`, a route in the customer's own app that
95
- proxies \`POST /v1/end_users/session\` using the secret key and the same
96
- server-resolved user id. It returns a short-lived \`est_\` credential. The
97
- browser never sees \`SOBA_KEY\`.
98
-
99
- Alongside it, \`<ComputeStatus />\`: asleep, offline, signed out of its CLI, or
100
- serving a run right now. When the compute is the user's own machine, the state of
101
- that machine is user-facing: they are the only one who can do anything about it.
102
-
103
- If there is no settings page yet, build one. Do not point the connect return URL
104
- at a page that does not render \`<ConnectCompute />\`.
105
-
106
- ## The rest of the components, which are not optional in practice
107
-
108
- A settings page is where somebody checks on a machine they already attached. It
109
- is not where they decide to attach one, because nobody visits it wondering
110
- whether to. An app that mounts only \`<ConnectCompute />\` there has nowhere for a
111
- run to land until a user happens to wander in, and meets \`no_compute\` first.
112
-
113
- Put the decision where it is made. All of these come from \`@soba-so/react\`, and
114
- all of them raise the same modal \u2014 the provider mounts exactly one, so an app
115
- with all of them cannot put two pairings on screen at once.
116
-
117
- | Component | Where |
118
- |---|---|
119
- | \`<ModelPicker />\` | In the composer, beside the send button. Which of THEIR models answers |
120
- | \`<RunLimit />\` | Where a run just failed for a reason the user can fix. Render it in the place the answer was going to be |
121
- | \`<RunError />\` | Beside it, for every other failure. The two never both speak |
122
- | \`<ConnectNudge />\` | While the allowance is running down and they still have a choice |
123
- | \`<SobaBilling />\` | The current plan, then the grid. The billing page you probably want |
124
- | \`<SobaPlans showConnect />\` | A pricing page with no current-plan card on it |
125
- | \`<SobaCurrentPlan />\` | The card alone, when composing the page yourself |
126
- | \`<SobaCheckout />\` | Takes the payment and grants the entitlement |
127
- | \`<SobaGate feature="workspaces" />\` | Around anything a plan limits \u2014 a "New workspace" button, an export. Shows it while allowed, otherwise the reason and the plans |
128
-
129
- A gate draws the button; it does not secure the action. On the server, ask
130
- before you create: \`soba.users.check(user, "workspaces", { use: 1 })\` answers
131
- \`{ allowed, reason }\` and counts the use in the same call, so two requests for
132
- the last one cannot both get it. Record use you did not ask about with
133
- \`soba.users.track(user, "workspaces", -1)\` when one is deleted.
134
-
135
- Prices, allowances and the connected reward come from the plan objects, so
136
- changing them later is not a deploy. Pass \`showConnect\` only on a page with no
137
- current-plan card: a bring-your-own plan would otherwise state a requirement with
138
- no way to meet it.
139
-
140
- ## Components or hooks: decide this by looking at the repo
141
-
142
- Both halves ship. **Every component above is one rendering of an exported hook,
143
- and the components derive nothing of their own** \u2014 so what you build from a hook
144
- and what we draw cannot disagree. Which half to reach for is not a matter of
145
- taste, and not a question to ask the person. Open the files first:
146
-
147
- **The app has no surface for this yet** \u2014 no settings page, no pricing page, a
148
- composer with nothing in its footer \u2014 then **mount the component.** It brings
149
- its own stylesheet, reads from the provider, and there is nothing left to
150
- decide. Do not build a settings page by hand so that you can fill it with hooks.
151
-
152
- **The app already has its own** \u2014 a chat composer with its own controls, a
153
- billing page in its own cards, a design system, Tailwind classes everywhere,
154
- anything that plainly belongs to somebody's product \u2014 then **import the hook and
155
- keep their markup.** Our CSS will not match the screen it lands on, and a card
156
- of ours in the middle of their chat reads as something the assistant said. The
157
- rules are ours; the pixels stay theirs.
158
-
159
- | Component | Hook | What the hook decides |
160
- |---|---|---|
161
- | \`<ModelPicker />\` | \`useModel()\` | Which models this person could be answered by, the one in force, and the two fields to put on the run |
162
- | \`<RunLimit />\` | \`useRunLimit()\` | The two failures a person can act on, and the offer that answers each |
163
- | \`<RunError />\` | \`runErrorMessage()\` | What to say about a failure, or null when it is not this one's to say |
164
- | \`<ConnectNudge />\` | \`useConnectNudge()\` | Whether there is anything worth saying at all, which of four reasons, and how big |
165
- | \`<ComputeStatus />\` | \`useCompute()\` | The machines in words, and "nothing connected" versus "we have not looked yet" |
166
- | \`<ConnectButton />\` | \`useConnectButton()\` | What the control says once something is attached, and what pressing it means |
167
- | \`<SobaPlans />\` | \`usePlans()\` | The catalogue as decisions: price, allowance, compute, the connect row, one \`take()\` per plan |
168
- | \`<SobaCurrentPlan />\` | \`useCurrentPlan()\` | The allowance arithmetic and the one sentence that is true of it |
169
- | \`<SobaCheckout />\` | \`useCheckout()\` | The session, the label, and the rule that nothing is granted in the browser |
170
- | \`<SobaGate />\` | \`useFeature()\` | Whether this person may use a feature, and why not: no plan, plan ended, not included, limit reached |
171
-
172
- \`<ConnectCompute />\`, \`<SobaBilling />\` and \`<ConnectModal />\` are compositions
173
- of the above and have no rule of their own. \`<ConnectPill />\` is the half of
174
- \`<ConnectButton />\` that reports \u2014 the mark, the state and the machine, with no
175
- popover under it and no flow behind it \u2014 for an app putting the readout in its
176
- own header and opening its own panel. Pressing it is yours to wire; everything
177
- it says is \`connectSays\`. \`<SobaProvider>\` is needed either way: the hooks
178
- read from it, so a hook with no provider above it is the one mistake this split
179
- invites.
180
-
181
- Two belong to no component of their own. \`useOpenSobaConnect()\` brings the
182
- Soba app forward on this person's machine and hands back the one honest thing a
183
- page can say about having tried \u2014 a browser cannot tell whether a \`soba://\`
184
- link was answered, and a page that claims it worked is guessing.
185
- \`useMachineRuns()\` is the "Running now" list out of \`<ConnectButton />\`'s
186
- panel with no panel around it: what this person's machines are running FOR THIS
187
- APP, and \`stop(runId)\` to end one as the person whose machine it is on. The app
188
- that started that run sees it finish with \`reason: "stopped_by_user"\`, which is
189
- the point: a surface built on this is a kill switch its owner holds, not a
190
- request to somebody's server.
191
-
192
- \`useRedeemCode()\` is a promo code field's behaviour: \`redeem(code)\` gives the
193
- user what the app's reward hands out \u2014 AI usage on top of their plan, a plan for
194
- some days, or a discount at their next checkout \u2014 and re-reads their plan, so
195
- the allowance on screen moves without a reload. Its \`error\` is a sentence ready
196
- to show. Put the field where somebody arrives with a code, usually the billing
197
- page. \`<RedeemCode />\` is that field already drawn \u2014 an input and an Apply
198
- button \u2014 for an app with no billing page of its own to put one in.
199
-
200
- \`useSoba()\` is the raw provider state. Reach for a named hook first and use
201
- this one for what no hook covers \u2014 \`run()\`, \`connect.open()\`,
202
- \`plan.refresh()\`. A page that reads \`compute.connected\` or \`plan.remaining\`
203
- straight off it is re-deriving a decision that is already exported, and the two
204
- copies are how our own apps drifted.
205
-
206
- ### What not to write yourself
207
-
208
- These are not style preferences. Each one is a judgement this package already
209
- makes, and each has been got wrong in production \u2014 in our own code, which is why
210
- they are exported at all. If you find yourself writing one of them, delete it
211
- and import the answer:
212
-
213
- - **A list of model names.** The names come off the person's own machine, so a
214
- list in your code refuses the model they can see on their own screen.
215
- \`useModel()\` reads it from what they have connected.
216
- - **A model id on a run without its agent.** Soba applies a person's own agent
217
- preference only to a run whose model is blank or a size, so a named model
218
- travelling alone goes to whichever agent is found first. Spread
219
- \`useModel().run\` whole \u2014 it is \`{ model, runtime? }\` \u2014 and have your route
220
- forward both fields.
221
- - **"Nothing connected yet."** That is a claim about somebody's account and it
222
- is only true once the account has been read. Said while the first request is
223
- in flight, or after it failed, it tells a person with a paired laptop that it
224
- has vanished. \`useCompute().view\` is the four-way answer.
225
- - **A match on an error message.** \`useRunLimit\` and \`runErrorMessage\` read the
226
- CODE. Messages are prose we rewrite, and matching on them breaks on a copy
227
- edit.
228
- - **Words for a cost class.** \`tierLabel(tier)\` is the one glossary for the five
229
- economics this product is about. Four hand-written copies in this repo
230
- disagreed with each other, and three reported somebody's own API key as
231
- frontier supply the app had paid for.
232
- - **Where the pick is remembered, or how a stale one is handled.** A model whose
233
- machine is gone falls back to Automatic and stays picked. \`useModel()\` does
234
- that and tells you with \`unavailable\`.
235
-
236
- Read \`https://soba.so/docs/components\` for each hook's full shape.
237
-
238
- ## Reaching Claude Code and Codex
239
-
240
- \`chat/completions\` is stateless and the caller owns the agent loop, so it
241
- reaches models. Reaching a user's own Claude or ChatGPT subscription means
242
- letting Soba own the loop instead:
243
-
244
- \`\`\`js
245
- import { Soba } from "@soba-so/sdk";
246
- import { sobaUserId } from "@soba-so/sdk/identity";
247
-
248
- const soba = new Soba({ apiKey: process.env.SOBA_KEY });
249
-
250
- const run = await soba.run({
251
- // Derived from something that outlives your database. A primary key
252
- // minted at sign-up is not: reset it and the same person arrives as
253
- // somebody new, stranded from the machine they paired.
254
- // https://soba.so/docs/identity
255
- user: sobaUserId(session.user.username),
256
- model: "auto",
257
- prompt: "Summarise everything I saved this week",
258
- tools: [listNotes, readNote], // your code, executed in your app
259
- });
260
- \`\`\`
261
-
262
- Tools passed to a run execute in the customer's own process, so they can read
263
- the app's own data. The model asks for data by calling them; the data does not
264
- travel in the prompt.
265
-
266
- ## Proving it
267
-
268
- \`soba/echo\` is answered by Soba itself \u2014 no machine, no metered supply,
269
- nothing billed \u2014 and still proves the key, the base URL and the \`user\` field:
270
-
271
- \`\`\`sh
272
- curl https://api.soba.so/v1/chat/completions \\
273
- -H "Authorization: Bearer $SOBA_KEY" \\
274
- -H "Content-Type: application/json" \\
275
- -d '{ "model": "soba/echo", "user": "usr_123",
276
- "messages": [{ "role": "user", "content": "ping" }] }'
277
- \`\`\`
278
-
279
- A curl is evidence the credential works. It is NOT evidence the app is
280
- integrated \u2014 the dashboard's integrate step ticks on a request arriving from the
281
- real call site, and it cannot tell a curl from a deployment. Do not send one to
282
- make a checklist go green.
283
-
284
- ## A new project rather than an existing one
285
-
286
- There is no separate procedure for this and no question to ask the person: look
287
- at the directory. If there is no app yet, run \`npx create-soba@latest\` and let
288
- it write one \u2014 it ships a correct \`/api/soba/session\`, which is the security
289
- boundary of the whole integration, and a plausible hand-written one is the
290
- failure mode that matters. Then the two edits above are already done and what
291
- remains is the key.
292
-
293
- ## What is not yours to do
294
-
295
- Pairing is a person installing the Soba app on their own laptop and approving
296
- it. Pricing, allowances and rewards are decisions about somebody's business.
297
- Do neither on their behalf; say what is left and stop.`;var C=2.5*1e6,d=[{upTo:null,microsPerUnit:C}];var Ae=[{id:"hobby",name:"Hobby",feeMicros:19*1e6,includedActivations:12,seatLimit:2,appLimit:3,bands:d,features:["All three envelope dials: duration, volume and feature scope","3 projects","2 seats","Owner and Member roles","Activation counts","Docs support"]},{id:"starter",seatLimit:null,appLimit:null,name:"Starter",feeMicros:199*1e6,includedActivations:90,bands:d,features:["Unlimited projects","Unlimited seats","Admin and Billing roles","Cohort and conversion attribution","Email support"]},{id:"growth",seatLimit:null,appLimit:null,name:"Growth",feeMicros:599*1e6,includedActivations:300,bands:d,features:["Window A/B experimentation","Email support, one business day"]},{id:"scale",seatLimit:null,appLimit:null,name:"Scale",feeMicros:1999*1e6,includedActivations:1500,bands:d,features:["Custom roles and audit log","Effective-vs-configured window analytics","Shared channel with an SLA"]}];var p=[{name:"set_up",title:"Set Soba up in this repo",description:"Works through Soba's setup checklist one step at a time, editing this repo and showing you each diff.",text:`Set this project up on Soba, working from the real checklist rather than from memory.
2
+ var u=class extends Error{constructor(e,r){super(r);this.status=e;this.name="ApiError"}},c=class{constructor(t,e){this.token=t;this.baseUrl=e}get(t){return this.call("GET",t)}post(t,e){return this.call("POST",t,e)}patch(t,e){return this.call("PATCH",t,e)}async call(t,e,r){let s=await fetch(`${this.baseUrl}${e}`,{method:t,headers:{authorization:`Bearer ${this.token}`,...r===void 0?{}:{"content-type":"application/json"}},body:r===void 0?void 0:JSON.stringify(r)}),o=await s.text(),i=null;try{i=o?JSON.parse(o):null}catch{throw new u(s.status,`${t} ${e} did not return json (${o.slice(0,120)})`)}if(!s.ok){let l=i?.error;throw new u(s.status,typeof l=="string"?l:`${t} ${e} failed with ${s.status}`)}return i}};var y=36e5,b=24*y,B={returnAfterMs:24*y,expiryMs:30*b,uniquenessMs:365*b};var H=10*6e4;var M=864e5,T=30,ee={abandonedAfterMs:T*M};var re=30*24*60*60*1e3;var oe=5*60*1e3;var _e=60*6e4;var E="https://soba.so/skill",xe=`npx skills add ${E}`;var w='Soba is the LLM layer for an application whose users bring their own compute.\nRequests go to Soba instead of to a model provider; Soba routes each one to the\nmachine or plan belonging to the user it names, meters it, and bills for it.\n\n## The two edits\n\nTwo edits make a Soba app work. Everything after them makes it worth having, and\nan app that stops at two has nowhere for a run to land \u2014 so do these first, then\nkeep going.\n\n### 1. Point every LLM call site at Soba\n\n baseURL https://api.soba.so/v1\n apiKey process.env.SOBA_KEY\n\nAn OpenAI client already speaks this, so on most projects the base URL is the\nonly line that changes. Prompts, tools, streaming and error handling stay\nexactly as they are.\n\nPass the signed-in user\'s id as the `user` field on every request.\n\n**Resolve that id on the SERVER, from the session, never from the request\nbody.** It is what decides whose machine a run may reach, so a value the browser\ncan choose is a value any user can use to spend any other user\'s compute. This\nis the one line in the integration that must not be guessed at: if the project\'s\nauth is not obvious, read it until it is, or stop and ask. A wrong id here does\nnot throw \u2014 it silently pairs runs to the wrong person.\n\n### Where the key comes from\n\nIf `.env.local` already sets `SOBA_KEY`, use it. Otherwise run this from the\nproject root:\n\n```bash\nnpx -y @soba-so/cli login\n```\n\nIt opens the person\'s browser, they pick the app, and it writes `SOBA_KEY` (a\ndevelopment key, for this machine) and `SOBA_PROD_KEY` (production) into\n`.env.local`, adding that file to `.gitignore` if git would commit it. The key\nnever passes through you. Tell the person to approve in the browser before you\nrun it; it waits up to fifteen minutes for them, so give the command a long\ntimeout or run it in the background. Add `--headless` where no browser can\nopen, and pass the link it prints on to the person.\n\n`.env.local` is right for Next.js, Vite and most Node servers. Where the code\nthat holds the key reads a different file, pass that file with `--env-file`\ninstead, from the project root, so the key lands where the server will look:\n\n| Server | File |\n|---|---|\n| Cloudflare Worker (`wrangler dev`) | `--env-file <worker dir>/.dev.vars` |\n| A server in a subfolder of a monorepo or an extension repo | `--env-file <server dir>/.env.local` |\n\nFind the file by reading how that server loads its environment, not by its\nframework\'s reputation. The CLI adds whatever file it writes to `.gitignore`\nif git would commit it.\n\nOn a host that keeps secrets itself \u2014 `wrangler secret put SOBA_KEY`, Vercel\'s\nor Railway\'s environment \u2014 production takes `SOBA_PROD_KEY`\'s value under the\nname `SOBA_KEY`. That is the person\'s to paste; tell them the command.\n\nA development key reaches only the user\'s own AI \u2014 their machine, their\nsubscription, their API key. In production, `SOBA_KEY` is set to the value of\n`SOBA_PROD_KEY` in the host\'s environment; say so to the person rather than\ndoing it.\n\nIf you cannot run commands but have a `soba_create_key` tool, call it: the\nsecret is returned once and nothing can show it again, so write it into\n`.env.local` in the same step. Failing both, ask the person to run the command\nabove themselves. Do not leave `SOBA_KEY`\nempty and do not invent a value; both fail at the first request, and the first\nfails as an auth error rather than as a missing variable.\n\nPut `SOBA_KEY` in `.env.local` (or the server\'s own file, above), and check\nthat file is gitignored before writing it. Never in `.env`, never in `.env.example`, never in anything\ntracked, and never echoed back to the terminal.\n\n### 2. Mount the connect component\n\nOn the page where a user manages their own account, so they can connect a\nmachine of their own:\n\n```jsx\nimport { SobaProvider, ConnectCompute } from "@soba-so/react";\n\n// Wherever a user manages their own account.\n<SobaProvider sessionEndpoint="/api/soba/session">\n <ConnectCompute />\n</SobaProvider>\n```\n\nBack it with `POST /api/soba/session`, a route in the customer\'s own app that\nproxies `POST /v1/end_users/session` using the secret key and the same\nserver-resolved user id. It returns a short-lived `est_` credential. The\nbrowser never sees `SOBA_KEY`.\n\nAlongside it, `<ComputeStatus />`: asleep, offline, signed out of its CLI, or\nserving a run right now. When the compute is the user\'s own machine, the state of\nthat machine is user-facing: they are the only one who can do anything about it.\n\nIf there is no settings page yet, build one. Do not point the connect return URL\nat a page that does not render `<ConnectCompute />`.\n\n## The rest of the components, which are not optional in practice\n\nA settings page is where somebody checks on a machine they already attached. It\nis not where they decide to attach one, because nobody visits it wondering\nwhether to. An app that mounts only `<ConnectCompute />` there has nowhere for a\nrun to land until a user happens to wander in, and meets `no_compute` first.\n\nPut the decision where it is made. All of these come from `@soba-so/react`, and\nall of them raise the same modal \u2014 the provider mounts exactly one, so an app\nwith all of them cannot put two pairings on screen at once.\n\n| Component | Where |\n|---|---|\n| `<ConnectButton />` | In the app\'s header or navbar, on every page. Says "Connect compute" until something is attached, then names the machine and its state; pressing it opens the panel with the machines and what they are running |\n| `<ModelPicker />` | In the composer, beside the send button. Which of THEIR models answers |\n| `<RunLimit />` | Where a run just failed for a reason the user can fix. Render it in the place the answer was going to be |\n| `<RunError />` | Beside it, for every other failure. The two never both speak |\n| `<ConnectNudge />` | While the allowance is running down and they still have a choice |\n| `<SobaBilling />` | The current plan, then the grid. The billing page you probably want |\n| `<SobaPlans showConnect />` | A pricing page with no current-plan card on it |\n| `<SobaCurrentPlan />` | The card alone, when composing the page yourself |\n| `<SobaCheckout />` | Takes the payment and grants the entitlement |\n| `<SobaGate feature="workspaces" />` | Around anything a plan limits \u2014 a "New workspace" button, an export. Shows it while allowed, otherwise the reason and the plans |\n| `<RedeemCode />` | Wherever somebody arrives with a promo code, usually the billing page |\n\nA gate draws the button; it does not secure the action. On the server, ask\nbefore you create: `soba.users.check(user, "workspaces", { use: 1 })` answers\n`{ allowed, reason }` and counts the use in the same call, so two requests for\nthe last one cannot both get it. Record use you did not ask about with\n`soba.users.track(user, "workspaces", -1)` when one is deleted.\n\nPrices, allowances and the connected reward come from the plan objects, so\nchanging them later is not a deploy. Pass `showConnect` only on a page with no\ncurrent-plan card: a bring-your-own plan would otherwise state a requirement with\nno way to meet it.\n\n## Mount the component. The hooks are not a styling option\n\nBoth halves ship, and **the component is the answer.** Mount it even when the\napp already has its own composer, its own billing cards, its own design system\nand Tailwind everywhere. Do not look at the repo\'s styling and decide to\nrebuild one of these from its hook.\n\nThe reason is that the components are not just markup. The vendor configures\nthem in the Soba dashboard: the model picker\'s layout (by provider, one list,\ncustom only), which of Automatic, Fast and Best are offered, search, the agents\'\nmarks and the line under each choice, the connect popup\'s look and theme. The\ncomponent reads all of that from the provider and draws it. A hand-built copy\nreads none of it, so every setting the vendor changes in the dashboard silently\ndoes nothing in their app, and nobody finds out until they compare the two.\n\nWhat that looks like in practice, from a real integration: an app with its own\nTailwind composer took `useModel()` and rendered it as a native\n`<select>` \u2014 no marks, no descriptions, no submenu per agent, a flat list\nwhere the dashboard said "by provider". It worked, and it was wrong.\n\nThe components fit a foreign screen on purpose: `className` on each one for\nplacement and size, `theme` on `<SobaProvider>` (or the dashboard) for\nlight and dark, and `<ModelPicker />` is a pill beside a send button, not a\ncard. If it still clashes, say so to the person and leave the component in.\n\n**Reach for a hook only when the person asks for their own markup**, or for a\ndecision no component draws (`useMachineRuns()`, `useOpenSobaConnect()`,\ngating a server action on `useFeature()`). That goes for every row below, the\nnavbar\'s connect button as much as the model picker. Every component is one\nrendering of an exported hook and derives nothing of its own, and a surface\nbuilt from a hook must still show everything the component shows. Each line in\nthe last column is something a hand-built copy has dropped:\n\n| Component | Hook | Built from the hook, it must still show |\n|---|---|---|\n| `<ModelPicker />` | `useModel()` | A menu, never a `<select>`. Automatic, Fast and Best (the `auto` and `size` options) each with its `note`; the app\'s models laid out as `layout` says (`providers`, `models`, `choices` or `automatic`, which is the vendor\'s dashboard setting); every agent in `agents` with its logo, as its own submenu, and an agent with no models (Codex) as a single row; `providers` with their marks (`<ProviderMark />` draws each), and locked when the plan says so. A search field when `search` is on. `unavailable` as the reason a stale pick fell back. Nothing at all when `pickable` is false. Spread `run` onto the request |\n| `<ConnectButton />` | `useConnectButton()` | In the header, on every page. `label`, which names the machine once one is attached; the state dot from `state.tone` with `state.word`; disabled when `canOpen` is false. Pressing it calls `open()`, which raises Soba\'s connect flow \u2014 never a page of your own. Its panel\'s machine list and "Running now" with Stop come from `useCompute()` and `useMachineRuns()` |\n| `<ConnectCompute />` | `useCompute()` + `useConnectButton()` | The settings page\'s block: the button above, then the status below |\n| `<ComputeStatus />` | `useCompute()` | All four of `view`: loading, error, empty, machines. Each machine\'s state in words, and `stalled` called out. "Nothing connected" only when `view` is `"empty"` |\n| `<ConnectNudge />` | `useConnectNudge()` | Nothing unless `visible`. `title`, `detail`, the `meter`, the `steps` and `stalled`; a dismiss only when `dismissible`; the action is `open()` |\n| `<RunLimit />` | `useRunLimit()` | In the place the answer was going to be. `title` and `body`; Connect only when `connectOffer` is not null, with that text; Upgrade only when `upgradeTo` is, calling `upgrade()` |\n| `<RunError />` | `runErrorMessage()` | Its sentence as given, nothing when it is null, and never beside a `<RunLimit />` that is speaking |\n| `<SobaPlans />` | `usePlans()` | Every offer: price, `allowance` and `allowanceNote`, `features`, the compute it runs on, the connect row, and its `cta` calling `take()`. The current plan and the featured one marked. `failed` when it is set |\n| `<SobaCurrentPlan />` | `useCurrentPlan()` | `summary`; used and remaining as a meter unless `unlimited`; `trialDaysLeft`, `periodEnd` and the `reward` when there are any |\n| `<SobaCheckout />` | `useCheckout()` | `label` on the button, `busy` and `error`, and `buy()`. Nothing is granted in the browser |\n| `<SobaGate />` | `useFeature()` | The children while allowed; otherwise the reason it is not and the plans that would allow it |\n| `<RedeemCode />` | `useRedeemCode()` | A field and an Apply that call `redeem()`, `busy`, `error` as given, and the `reward` once it lands |\n\n`<ConnectCompute />`, `<SobaBilling />` and `<ConnectModal />` are compositions\nof the above and have no rule of their own. `<ConnectPill />` is the half of\n`<ConnectButton />` that reports \u2014 the mark, the state and the machine, with no\npopover under it and no flow behind it. It is for an app whose person asked for\ntheir own panel; otherwise the header gets `<ConnectButton />`, panel included.\nPressing the pill is yours to wire, and it still opens Soba\'s flow through\n`useSoba().connect.open()`; everything it says is `connectSays`. `<SobaProvider>` is needed either way: the hooks\nread from it, so a hook with no provider above it is the one mistake this split\ninvites.\n\nTwo belong to no component of their own. `useOpenSobaConnect()` brings the\nSoba app forward on this person\'s machine and hands back the one honest thing a\npage can say about having tried \u2014 a browser cannot tell whether a `soba://`\nlink was answered, and a page that claims it worked is guessing.\n`useMachineRuns()` is the "Running now" list out of `<ConnectButton />`\'s\npanel with no panel around it: what this person\'s machines are running FOR THIS\nAPP, and `stop(runId)` to end one as the person whose machine it is on. The app\nthat started that run sees it finish with `reason: "stopped_by_user"`, which is\nthe point: a surface built on this is a kill switch its owner holds, not a\nrequest to somebody\'s server.\n\n`useRedeemCode()` is a promo code field\'s behaviour: `redeem(code)` gives the\nuser what the app\'s reward hands out \u2014 AI usage on top of their plan, a plan for\nsome days, or a discount at their next checkout \u2014 and re-reads their plan, so\nthe allowance on screen moves without a reload. Its `error` is a sentence ready\nto show. Put the field where somebody arrives with a code, usually the billing\npage. `<RedeemCode />` is that field already drawn \u2014 an input and an Apply\nbutton \u2014 and it is what goes there, on the app\'s own billing page too.\n\n`useSoba()` is the raw provider state. Reach for a named hook first and use\nthis one for what no hook covers \u2014 `run()`, `connect.open()`,\n`plan.refresh()`. A page that reads `compute.connected` or `plan.remaining`\nstraight off it is re-deriving a decision that is already exported, and the two\ncopies are how our own apps drifted.\n\n### What not to write yourself\n\nThese are not style preferences. Each one is a judgement this package already\nmakes, and each has been got wrong in production \u2014 in our own code, which is why\nthey are exported at all. If you find yourself writing one of them, delete it\nand import the answer:\n\n- **A list of model names.** The names come off the person\'s own machine, so a\n list in your code refuses the model they can see on their own screen.\n `useModel()` reads it from what they have connected.\n- **A model id on a run without its agent.** Soba applies a person\'s own agent\n preference only to a run whose model is blank or a size, so a named model\n travelling alone goes to whichever agent is found first. Spread\n `useModel().run` whole \u2014 it is `{ model, runtime? }` \u2014 and have your route\n forward both fields.\n- **"Nothing connected yet."** That is a claim about somebody\'s account and it\n is only true once the account has been read. Said while the first request is\n in flight, or after it failed, it tells a person with a paired laptop that it\n has vanished. `useCompute().view` is the four-way answer.\n- **A match on an error message.** `useRunLimit` and `runErrorMessage` read the\n CODE. Messages are prose we rewrite, and matching on them breaks on a copy\n edit.\n- **Words for a cost class.** `tierLabel(tier)` is the one glossary for the five\n economics this product is about. Four hand-written copies in this repo\n disagreed with each other, and three reported somebody\'s own API key as\n frontier supply the app had paid for.\n- **Where the pick is remembered, or how a stale one is handled.** A model whose\n machine is gone falls back to Automatic and stays picked. `useModel()` does\n that and tells you with `unavailable`.\n\nRead `https://soba.so/docs/components` for each hook\'s full shape.\n\n## The chat stays theirs\n\nThere is no chat component, on purpose. An app built on Soba already has its own\ncomposer and its own messages, and they are the product. Keep every line of\nthat markup. What Soba adds goes INTO it, and these are the things a chat on\nSoba has to handle \u2014 check each one against the code, not against memory:\n\n**In the composer**\n\n- `<ModelPicker />` in the composer\'s footer, beside the send button. The\n component, per the section above, not a copy.\n- Spread `useModel().run` onto the request, and have the route forward\n `model` and `runtime` both.\n- Send becomes Stop while a run is going. Stop aborts the request\'s\n `signal`, and a run the person stopped is not an error to show. Neither is\n `reason: "stopped_by_user"`, which is the machine\'s owner stopping it\n from their side.\n- `<ConnectNudge />` above the composer. It draws nothing until it has\n something to say.\n- Images, only if the composer already takes them: forward each message\'s\n `images` and the runtimes that can see them will.\n\n**In the messages**\n\n- `delta` text is appended as it arrives. `thinking` is the running total\n and REPLACES what is shown \u2014 appending it repeats every sentence. Fold it\n away by default.\n- `status` events are what the agent is doing: show `message`, and\n `toolInput` beside it when there is one. `state: "interrupted"` means\n the person\'s machine went offline mid-run and `"resumed"` that it came\n back; say so in the answer, because the run goes on either way.\n- A failed run renders `<RunLimit />` where the answer was going to be, and\n `<RunError />` beside it for everything else. Branch on the `reason`\n code, never the message. Offer Retry only when `retryable` is not false.\n- Copy on every answer, on hover, copying the text as written (markdown, not\n rendered HTML). Retry on the last one.\n- `done` carries `usage` and `tier`. If the app shows what answered,\n word the tier with `tierLabel()`.\n\n**Across turns**\n\n- `done` and `error` carry a `session`. Send it back as `resume`\n on the next run, and have the route forward it, so a follow-up continues the agent\'s conversation instead of\n starting a new one with the whole transcript pasted in.\n\nAn app with no chat at all gets one built in its own components and styles,\nthe same way it would build any other screen \u2014 with everything above in it.\n\n## Reaching Claude Code and Codex\n\n`chat/completions` is stateless and the caller owns the agent loop, so it\nreaches models. Reaching a user\'s own Claude or ChatGPT subscription means\nletting Soba own the loop instead:\n\n```js\nimport { Soba } from "@soba-so/sdk";\nimport { sobaUserId } from "@soba-so/sdk/identity";\n\nconst soba = new Soba({ apiKey: process.env.SOBA_KEY });\n\nconst run = await soba.run({\n // Derived from something that outlives your database. A primary key\n // minted at sign-up is not: reset it and the same person arrives as\n // somebody new, stranded from the machine they paired.\n // https://soba.so/docs/identity\n user: sobaUserId(session.user.username),\n model: "auto",\n prompt: "Summarise everything I saved this week",\n tools: [listNotes, readNote], // your code, executed in your app\n});\n```\n\nTools passed to a run execute in the customer\'s own process, so they can read\nthe app\'s own data. The model asks for data by calling them; the data does not\ntravel in the prompt.\n\n## Proving it\n\n`soba/echo` is answered by Soba itself \u2014 no machine, no metered supply,\nnothing billed \u2014 and still proves the key, the base URL and the `user` field:\n\n```sh\ncurl https://api.soba.so/v1/chat/completions \\\n -H "Authorization: Bearer $SOBA_KEY" \\\n -H "Content-Type: application/json" \\\n -d \'{ "model": "soba/echo", "user": "usr_123",\n "messages": [{ "role": "user", "content": "ping" }] }\'\n```\n\nA curl is evidence the credential works. It is NOT evidence the app is\nintegrated \u2014 the dashboard\'s integrate step ticks on a request arriving from the\nreal call site, and it cannot tell a curl from a deployment. Do not send one to\nmake a checklist go green.\n\n## A new project rather than an existing one\n\nThere is no separate procedure for this and no question to ask the person: look\nat the directory. If there is no app yet, run `npx create-soba@latest` and let\nit write one \u2014 it ships a correct `/api/soba/session`, which is the security\nboundary of the whole integration, and a plausible hand-written one is the\nfailure mode that matters. Then the two edits above are already done and what\nremains is the key.\n\n## What is not yours to do\n\nPairing is a person installing the Soba app on their own laptop and approving\nit. Pricing, allowances and rewards are decisions about somebody\'s business.\nDo neither on their behalf; say what is left and stop.';var C=2.5*1e6,d=[{upTo:null,microsPerUnit:C}];var Ae=[{id:"hobby",name:"Hobby",feeMicros:19*1e6,includedActivations:12,seatLimit:2,appLimit:3,bands:d,features:["All three envelope dials: duration, volume and feature scope","3 projects","2 seats","Owner and Member roles","Activation counts","Docs support"]},{id:"starter",seatLimit:null,appLimit:null,name:"Starter",feeMicros:199*1e6,includedActivations:90,bands:d,features:["Unlimited projects","Unlimited seats","Admin and Billing roles","Cohort and conversion attribution","Email support"]},{id:"growth",seatLimit:null,appLimit:null,name:"Growth",feeMicros:599*1e6,includedActivations:300,bands:d,features:["Window A/B experimentation","Email support, one business day"]},{id:"scale",seatLimit:null,appLimit:null,name:"Scale",feeMicros:1999*1e6,includedActivations:1500,bands:d,features:["Custom roles and audit log","Effective-vs-configured window analytics","Shared channel with an SLA"]}];var p=[{name:"set_up",title:"Set Soba up in this repo",description:"Works through Soba's setup checklist one step at a time, editing this repo and showing you each diff.",text:`Set this project up on Soba, working from the real checklist rather than from memory.
298
3
 
299
4
  The loop, and keep to it:
300
5
 
@@ -326,13 +31,13 @@ What the codebase steps actually involve, so you are not working from memory
326
31
  there either:
327
32
 
328
33
  ${w}`}],_=new Map(p.map(n=>[n.name,n]));function a(n){process.stderr.write(`soba-mcp: ${n}
329
- `)}function x(n){process.stdout.write(`${JSON.stringify(n)}
330
- `)}function k(n){let t="",e=new Set,r=!1,s=o=>{e.add(o),o.finally(()=>{e.delete(o),r&&e.size===0&&process.exit(0)})};process.stdin.setEncoding("utf8"),process.stdin.on("data",o=>{t+=o;let i=t.indexOf(`
34
+ `)}function k(n){process.stdout.write(`${JSON.stringify(n)}
35
+ `)}function v(n){let t="",e=new Set,r=!1,s=o=>{e.add(o),o.finally(()=>{e.delete(o),r&&e.size===0&&process.exit(0)})};process.stdin.setEncoding("utf8"),process.stdin.on("data",o=>{t+=o;let i=t.indexOf(`
331
36
  `);for(;i!==-1;){let l=t.slice(0,i).trim();t=t.slice(i+1),l&&s(I(l,n)),i=t.indexOf(`
332
- `)}}),process.stdin.on("end",()=>{r=!0,e.size===0&&process.exit(0),setTimeout(()=>process.exit(0),1e4).unref()})}async function I(n,t){let e;try{e=JSON.parse(n)}catch{a("ignored a line that was not json");return}let r=e.id===void 0||e.id===null;try{let s=await t(e.method,e.params??{});r||x({jsonrpc:"2.0",id:e.id,result:s})}catch(s){if(r)return;let o=s instanceof Error?s.message:String(s),i=o==="method not found"?-32601:-32603;x({jsonrpc:"2.0",id:e.id,error:{code:i,message:o}})}}var v={type:"object",properties:{},additionalProperties:!1};function S(n){let t=n.steps.map(r=>`${r.done?"[x]":"[ ]"} ${r.title} \u2014 ${r.state}`),e=n.complete?"Every step is done. Nothing here needs you again.":`Next: ${n.next}. Call soba_next_step for what to do.`;return`${t.join(`
37
+ `)}}),process.stdin.on("end",()=>{r=!0,e.size===0&&process.exit(0),setTimeout(()=>process.exit(0),1e4).unref()})}async function I(n,t){let e;try{e=JSON.parse(n)}catch{a("ignored a line that was not json");return}let r=e.id===void 0||e.id===null;try{let s=await t(e.method,e.params??{});r||k({jsonrpc:"2.0",id:e.id,result:s})}catch(s){if(r)return;let o=s instanceof Error?s.message:String(s),i=o==="method not found"?-32601:-32603;k({jsonrpc:"2.0",id:e.id,error:{code:i,message:o}})}}var x={type:"object",properties:{},additionalProperties:!1};function S(n){let t=n.steps.map(r=>`${r.done?"[x]":"[ ]"} ${r.title} \u2014 ${r.state}`),e=n.complete?"Every step is done. Nothing here needs you again.":`Next: ${n.next}. Call soba_next_step for what to do.`;return`${t.join(`
333
38
  `)}
334
39
 
335
- ${e}`}function P(n,t){return n.steps.find(e=>e.id===t)}var m=[{name:"soba_status",title:"Read the setup checklist",description:"Soba's setup checklist for this app and which steps are done. Call this first, and again after every change, so you are acting on what is true rather than on what you did last.",inputSchema:v,run:async n=>S(await n.get("/v1/manage/progress"))},{name:"soba_next_step",title:"What to do next",description:"The first outstanding step, with an instruction written for you. Do what it says using your own tools \u2014 read the repo, make the edits, show the diff. Then call soba_status again to confirm it took.",inputSchema:v,run:async n=>{let t=await n.get("/v1/manage/progress");if(t.complete)return"Setup is complete. There is nothing to do.";let e=P(t,t.next);return e?e.effect==="human"?e.id==="price"?`Next: ${e.title}
40
+ ${e}`}function P(n,t){return n.steps.find(e=>e.id===t)}var h=[{name:"soba_status",title:"Read the setup checklist",description:"Soba's setup checklist for this app and which steps are done. Call this first, and again after every change, so you are acting on what is true rather than on what you did last.",inputSchema:x,run:async n=>S(await n.get("/v1/manage/progress"))},{name:"soba_next_step",title:"What to do next",description:"The first outstanding step, with an instruction written for you. Do what it says using your own tools \u2014 read the repo, make the edits, show the diff. Then call soba_status again to confirm it took.",inputSchema:x,run:async n=>{let t=await n.get("/v1/manage/progress");if(t.complete)return"Setup is complete. There is nothing to do.";let e=P(t,t.next);return e?e.effect==="human"?e.id==="price"?`Next: ${e.title}
336
41
 
337
42
  ${e.lede}
338
43
 
@@ -352,4 +57,4 @@ When you are done, call soba_status to confirm it registered.`:S(t)}},{name:"sob
352
57
 
353
58
  SOBA_KEY=${e.key}
354
59
 
355
- This is the only time it exists. Put it in .env.local now.`}},{name:"soba_set_connect_url",title:"Point Connect back at the app",description:"Sets where someone who started pairing in their terminal gets sent to sign in. It must be the public https page that renders <ConnectCompute />. If no such page exists yet, do not guess one \u2014 build the page first.",inputSchema:{type:"object",properties:{url:{type:"string",description:"The https URL of the page. Loopback is allowed in development."}},required:["url"],additionalProperties:!1},run:async(n,t)=>(await n.patch("/v1/manage/app",{connect_return_url:t.url}),`Connect now returns to ${t.url}.`)},{name:"soba_create_plan",title:"Create a plan",description:"Creates a plan: the price, the allowance, what a run may fall back to, and what connecting a machine earns back. Only call this with numbers a person gave you. Do not invent a price.",inputSchema:{type:"object",properties:{name:{type:"string"},description:{type:"string"},price:{type:"number",description:"Dollars a month. 0 is a free plan."},unit:{type:"string",enum:["run","token","cost"],description:"What both allowances are counted in. `cost` counts hundredths of a cent (10,000 to the dollar); a token or cost overage price is per 1M tokens or per $1."},included_units:{type:["number","null"],description:"Runs a month on AI the app pays for (open-weights, frontier). Null is unlimited."},trial_days:{type:"number"},route_prefer:{type:"array",items:{type:"string",enum:["user-subscription","user-hardware","open-weights","frontier"]},description:"What a run may use, best first. This is also the ceiling: a class left out can never be billed to this app."},max_cost_per_run:{type:["number","null"],description:"Dollars one run may cost."},own_included_units:{type:["number","null"],description:"Runs a month on the user's own AI (their machine, subscription or key), counted apart from included_units. Null is unlimited."},own_unit:{type:["string","null"],enum:["run","token","credit","task",null],description:"What own_included_units counts, when not unit: a hybrid plan gives 200 runs on the user's own AI and 2,000 credits on yours. Null means the same as unit."},connected_reward:{type:"string",enum:["none","included","credit"]},connected_included_units:{type:["number","null"]},connected_credit:{type:["number","null"]}},required:["name","price","route_prefer"],additionalProperties:!1},run:async(n,t)=>{let e=await n.post("/v1/manage/plans",t);return`Created the plan "${e.name}"${e.id?` (${e.id})`:""}.`}},{name:"soba_give_reward",title:"Give a user a reward",description:"Gives one user a reward the app already has \u2014 money off, extra AI usage, or a plan for some days. Once per user per reward. Only call this when a person asked for that user to get it.",inputSchema:{type:"object",properties:{reward:{type:"string",description:"The reward's ID, e.g. early_bird."},user:{type:"string",description:"The app's own id for the user."}},required:["reward","user"],additionalProperties:!1},run:async(n,t)=>(await n.post("/v1/manage/rewards/give",t),`Gave ${t.user} the reward ${t.reward}.`)}],A=new Map(m.map(n=>[n.name,n]));var O="https://soba.so",U="2025-06-18",N="0.0.3";function L(n){let t={token:process.env.SOBA_MANAGEMENT_KEY??null,baseUrl:process.env.SOBA_MANAGE_URL??O};for(let e=0;e<n.length;e++){let r=n[e];r==="--token"?t.token=n[++e]??null:r?.startsWith("--token=")?t.token=r.slice(8):r==="--url"?t.baseUrl=n[++e]??t.baseUrl:r?.startsWith("--url=")&&(t.baseUrl=r.slice(6))}return t.baseUrl=t.baseUrl.replace(/\/+$/,""),t}var h=L(process.argv.slice(2)),g=h.token;g||(a("no management key. Pass --token mk_soba_\u2026 or set SOBA_MANAGEMENT_KEY."),a("Mint one in your Soba dashboard, on the Set up page."),process.exit(2));g.startsWith("mk_soba_")||(a("that is not a management key. It starts with mk_soba_, and sk_soba_ is a"),a("different credential \u2014 your app's secret key. Do not paste that here."),process.exit(2));var D=new c(g,h.baseUrl);k(async(n,t)=>{switch(n){case"initialize":return{protocolVersion:U,capabilities:{tools:{},prompts:{}},serverInfo:{name:"soba",version:N},instructions:"Soba's setup checklist. Call soba_status first, then soba_next_step, and do what it says with your own tools \u2014 the repo is yours to edit, not this server's. Call soba_status again afterwards to confirm the step registered rather than assuming it did."};case"notifications/initialized":case"notifications/cancelled":return{};case"ping":return{};case"prompts/list":return{prompts:p.map(e=>({name:e.name,title:e.title,description:e.description}))};case"prompts/get":{let e=typeof t.name=="string"?t.name:"",r=_.get(e);if(!r)throw new Error(`no such prompt: ${e}`);return{description:r.description,messages:[{role:"user",content:{type:"text",text:r.text}}]}}case"tools/list":return{tools:m.map(e=>({name:e.name,title:e.title,description:e.description,inputSchema:e.inputSchema}))};case"tools/call":{let e=typeof t.name=="string"?t.name:"",r=A.get(e);if(!r)return f(`no such tool: ${e}`);let s=t.arguments??{};try{return{content:[{type:"text",text:await r.run(D,s)}]}}catch(o){return o instanceof u?f(F(o)):f(o instanceof Error?o.message:String(o))}}default:throw new Error("method not found")}});function f(n){return{content:[{type:"text",text:n}],isError:!0}}function F(n){return n.status===401?"Soba refused the management key. It may have been revoked, or it may belong to a different app. Mint a new one on the Set up page.":n.message}a(`ready \u2014 ${m.length} tools, ${p.length} prompt against ${h.baseUrl}`);
60
+ This is the only time it exists. Put it in .env.local now.`}},{name:"soba_set_connect_url",title:"Point Connect back at the app",description:"Sets where someone who started pairing in their terminal gets sent to sign in. It must be the public https page that renders <ConnectCompute />. If no such page exists yet, do not guess one \u2014 build the page first.",inputSchema:{type:"object",properties:{url:{type:"string",description:"The https URL of the page. Loopback is allowed in development."}},required:["url"],additionalProperties:!1},run:async(n,t)=>(await n.patch("/v1/manage/app",{connect_return_url:t.url}),`Connect now returns to ${t.url}.`)},{name:"soba_create_plan",title:"Create a plan",description:"Creates a plan: the price, the allowance, what a run may fall back to, and what connecting a machine earns back. Only call this with numbers a person gave you. Do not invent a price.",inputSchema:{type:"object",properties:{name:{type:"string"},description:{type:"string"},price:{type:"number",description:"Dollars a month. 0 is a free plan."},unit:{type:"string",enum:["run","token","cost"],description:"What both allowances are counted in. `cost` counts hundredths of a cent (10,000 to the dollar); a token or cost overage price is per 1M tokens or per $1."},included_units:{type:["number","null"],description:"Runs a month on AI the app pays for (open-weights, frontier). Null is unlimited."},trial_days:{type:"number"},route_prefer:{type:"array",items:{type:"string",enum:["user-subscription","user-hardware","open-weights","frontier"]},description:"What a run may use, best first. This is also the ceiling: a class left out can never be billed to this app."},max_cost_per_run:{type:["number","null"],description:"Dollars one run may cost."},own_included_units:{type:["number","null"],description:"Runs a month on the user's own AI (their machine, subscription or key), counted apart from included_units. Null is unlimited."},own_unit:{type:["string","null"],enum:["run","token","credit","task",null],description:"What own_included_units counts, when not unit: a hybrid plan gives 200 runs on the user's own AI and 2,000 credits on yours. Null means the same as unit."},connected_reward:{type:"string",enum:["none","included","credit"]},connected_included_units:{type:["number","null"]},connected_credit:{type:["number","null"]}},required:["name","price","route_prefer"],additionalProperties:!1},run:async(n,t)=>{let e=await n.post("/v1/manage/plans",t);return`Created the plan "${e.name}"${e.id?` (${e.id})`:""}.`}},{name:"soba_give_reward",title:"Give a user a reward",description:"Gives one user a reward the app already has \u2014 money off, extra AI usage, or a plan for some days. Once per user per reward. Only call this when a person asked for that user to get it.",inputSchema:{type:"object",properties:{reward:{type:"string",description:"The reward's ID, e.g. early_bird."},user:{type:"string",description:"The app's own id for the user."}},required:["reward","user"],additionalProperties:!1},run:async(n,t)=>(await n.post("/v1/manage/rewards/give",t),`Gave ${t.user} the reward ${t.reward}.`)}],A=new Map(h.map(n=>[n.name,n]));var O="https://soba.so",U="2025-06-18",N="0.0.4";function L(n){let t={token:process.env.SOBA_MANAGEMENT_KEY??null,baseUrl:process.env.SOBA_MANAGE_URL??O};for(let e=0;e<n.length;e++){let r=n[e];r==="--token"?t.token=n[++e]??null:r?.startsWith("--token=")?t.token=r.slice(8):r==="--url"?t.baseUrl=n[++e]??t.baseUrl:r?.startsWith("--url=")&&(t.baseUrl=r.slice(6))}return t.baseUrl=t.baseUrl.replace(/\/+$/,""),t}var f=L(process.argv.slice(2)),g=f.token;g||(a("no management key. Pass --token mk_soba_\u2026 or set SOBA_MANAGEMENT_KEY."),a("Mint one in your Soba dashboard, on the Set up page."),process.exit(2));g.startsWith("mk_soba_")||(a("that is not a management key. It starts with mk_soba_, and sk_soba_ is a"),a("different credential \u2014 your app's secret key. Do not paste that here."),process.exit(2));var D=new c(g,f.baseUrl);v(async(n,t)=>{switch(n){case"initialize":return{protocolVersion:U,capabilities:{tools:{},prompts:{}},serverInfo:{name:"soba",version:N},instructions:"Soba's setup checklist. Call soba_status first, then soba_next_step, and do what it says with your own tools \u2014 the repo is yours to edit, not this server's. Call soba_status again afterwards to confirm the step registered rather than assuming it did."};case"notifications/initialized":case"notifications/cancelled":return{};case"ping":return{};case"prompts/list":return{prompts:p.map(e=>({name:e.name,title:e.title,description:e.description}))};case"prompts/get":{let e=typeof t.name=="string"?t.name:"",r=_.get(e);if(!r)throw new Error(`no such prompt: ${e}`);return{description:r.description,messages:[{role:"user",content:{type:"text",text:r.text}}]}}case"tools/list":return{tools:h.map(e=>({name:e.name,title:e.title,description:e.description,inputSchema:e.inputSchema}))};case"tools/call":{let e=typeof t.name=="string"?t.name:"",r=A.get(e);if(!r)return m(`no such tool: ${e}`);let s=t.arguments??{};try{return{content:[{type:"text",text:await r.run(D,s)}]}}catch(o){return o instanceof u?m(F(o)):m(o instanceof Error?o.message:String(o))}}default:throw new Error("method not found")}});function m(n){return{content:[{type:"text",text:n}],isError:!0}}function F(n){return n.status===401?"Soba refused the management key. It may have been revoked, or it may belong to a different app. Mint a new one on the Set up page.":n.message}a(`ready \u2014 ${h.length} tools, ${p.length} prompt against ${f.baseUrl}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soba-so/mcp",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Sets Soba up from inside your coding agent: it reads the checklist, does the next step, and reads it back.",
5
5
  "license": "UNLICENSED",
6
6
  "homepage": "https://soba.so/docs/quickstart",