@soba-so/mcp 0.0.4 → 0.0.6

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 (3) hide show
  1. package/README.md +6 -3
  2. package/dist/mcp.mjs +536 -13
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -36,6 +36,8 @@ step, and reads it back — and the dashboard ticks along as it goes.
36
36
  | `soba_next_step` | The first outstanding one, with an instruction written for an agent |
37
37
  | `soba_create_key` | Mints your app's secret key, once |
38
38
  | `soba_set_connect_url` | Points Connect back at your app |
39
+ | `soba_use_soba` | Answers the provider step with "Just use Soba for now" and ticks it |
40
+ | `soba_create_free_plan` | Adds the free "Bring your own" plan, the default, and starts new users on it |
39
41
  | `soba_create_plan` | Creates a plan from numbers **you** gave it |
40
42
 
41
43
  ## What it deliberately does not do
@@ -60,9 +62,10 @@ for this:
60
62
  It also never stamps `last_seen_at`, so an agent working on your behalf cannot
61
63
  make your dashboard claim your integration is live when it isn't.
62
64
 
63
- **It will not price your product.** `soba_create_plan` exists; there is no
64
- instruction telling an agent to call it. A plan is a price, an allowance, a
65
- ceiling and a reward, and those are decisions about your business.
65
+ **It will not price your product.** By default an agent adds only the free
66
+ "Bring your own" plan, which costs you nothing. `soba_create_plan` exists, but
67
+ only for numbers you gave it: a price, an allowance, a ceiling and a reward are
68
+ decisions about your business.
66
69
 
67
70
  ## Options
68
71
 
package/dist/mcp.mjs CHANGED
@@ -1,5 +1,520 @@
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,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.
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,w=24*y,q={returnAfterMs:24*y,expiryMs:30*w,uniquenessMs:365*w};var G=10*6e4;var E=864e5,T=30,te={abandonedAfterMs:T*E};var oe=30*24*60*60*1e3;var se=5*60*1e3;var C=2.5*1e6,d=[{upTo:null,microsPerUnit:C}];var _="lite",fe=[{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 ge={hobby:["owner","member"],[_]:["owner","member"]};var Ae=60*6e4;var I="https://soba.so/skill",Ee=`npx skills add ${I}`;var k=`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
+ ## How an integration is shaped
7
+
8
+ Every app, whatever it is \u2014 a chat, one AI button, a background job with a
9
+ page \u2014 gets the same two halves:
10
+
11
+ 1. **The server**: every LLM call goes through Soba as the signed-in user, a
12
+ session route lets the browser act for that user, and Soba's answer
13
+ (including a refusal) reaches the browser intact.
14
+ 2. **The browser**: one \`<SobaProvider>\`, and a surface for each moment
15
+ somebody meets their compute \u2014 the settings page, every control that
16
+ starts a run, the place a run's result appears and, when the app's AI only
17
+ works on the user's own compute, the navbar.
18
+
19
+ Each surface has a component and a hook. **Mount the component**; build from
20
+ the hook only when the person asks for their own markup, and then show
21
+ everything the component would (see "Component or hook"). The integration is
22
+ finished when every surface in the required list exists, not when the first
23
+ request succeeds.
24
+
25
+ ## The server
26
+
27
+ ### 1. Point every LLM call site at Soba
28
+
29
+ baseURL https://api.soba.so/v1
30
+ apiKey process.env.SOBA_KEY
31
+
32
+ An OpenAI client already speaks this, so on most projects the base URL is the
33
+ only line that changes. Prompts, tools, streaming and error handling stay
34
+ exactly as they are. Find every call site \u2014 a shared client, a route that
35
+ builds its own, a raw \`fetch\` to the provider's REST API \u2014 and move all of them.
36
+
37
+ Pass the signed-in user's id as the \`user\` field on every request.
38
+
39
+ **Resolve that id on the SERVER, from the session, never from the request
40
+ body.** It is what decides whose machine a run may reach, so a value the browser
41
+ can choose is a value any user can use to spend any other user's compute. This
42
+ is the one line in the integration that must not be guessed at: if the project's
43
+ auth is not obvious, read it until it is, or stop and ask. A wrong id here does
44
+ not throw \u2014 it silently pairs runs to the wrong person.
45
+
46
+ **Derive it from something that outlives the database.** A primary key minted
47
+ at sign-up (an autoincrement, a random UUID) is not: reset the database and the
48
+ same person arrives as somebody new, stranded from the machine they paired. An
49
+ email is not either, if the app lets people change it. \`sobaUserId(stable)\`
50
+ from \`@soba-so/sdk/identity\` turns a stable value \u2014 a username, an auth
51
+ provider's subject \u2014 into the id; use one helper for it and call it everywhere
52
+ the user is named. See \`https://soba.so/docs/identity\`.
53
+
54
+ ### 2. Where the key comes from
55
+
56
+ If \`.env.local\` already sets \`SOBA_KEY\`, use it. Otherwise sign the terminal in,
57
+ from the project root:
58
+
59
+ \`\`\`bash
60
+ npx -y @soba-so/cli login --no-link
61
+ \`\`\`
62
+
63
+ It opens the person's browser once, they approve, and the terminal keeps a token
64
+ of its own; no key passes through you. Tell the person to approve before you run
65
+ it; it waits up to fifteen minutes, so give the command a long timeout or run it
66
+ in the background. Add \`--headless\` where no browser can open, and pass the
67
+ link it prints on to the person.
68
+
69
+ Then find out which app this project is. \`npx -y @soba-so/cli apps\` lists
70
+ theirs by workspace. Ask the person which one, or whether to make a new one, and
71
+ do not guess from the names; then link it:
72
+
73
+ \`\`\`bash
74
+ npx -y @soba-so/cli link --workspace "<workspace>" --app "<app>"
75
+ npx -y @soba-so/cli link --workspace "<workspace>" --new "<name>" # a new app
76
+ \`\`\`
77
+
78
+ That writes \`SOBA_KEY\` (a development key, for this machine), \`SOBA_PROD_KEY\`
79
+ (production) and \`SOBA_APP_ID\` into \`.env.local\`, adding that file to
80
+ \`.gitignore\` if git would commit it. With nobody at the terminal the CLI never
81
+ waits on a question: a choice it needs ends the command with the flag to pass.
82
+ Every command is on \`https://soba.so/docs/reference/cli\`.
83
+
84
+ \`.env.local\` is right for Next.js, Vite and most Node servers. Where the code
85
+ that holds the key reads a different file, pass that file with \`--env-file\`
86
+ to \`link\` instead, from the project root, so the key lands where the server
87
+ will look:
88
+
89
+ | Server | File |
90
+ |---|---|
91
+ | Cloudflare Worker (\`wrangler dev\`) | \`--env-file <worker dir>/.dev.vars\` |
92
+ | A server in a subfolder of a monorepo or an extension repo | \`--env-file <server dir>/.env.local\` |
93
+
94
+ Find the file by reading how that server loads its environment, not by its
95
+ framework's reputation. The CLI adds whatever file it writes to \`.gitignore\`
96
+ if git would commit it.
97
+
98
+ On a host that keeps secrets itself \u2014 \`wrangler secret put SOBA_KEY\`, Vercel's
99
+ or Railway's environment \u2014 production takes \`SOBA_PROD_KEY\`'s value under the
100
+ name \`SOBA_KEY\`. That is the person's to paste; tell them the command.
101
+
102
+ A development key reaches only the user's own AI \u2014 their machine, their
103
+ subscription, their API key. In production, \`SOBA_KEY\` is set to the value of
104
+ \`SOBA_PROD_KEY\` in the host's environment; say so to the person rather than
105
+ doing it.
106
+
107
+ If you cannot run commands but have a \`soba_create_key\` tool, call it: the
108
+ secret is returned once and nothing can show it again, so write it into
109
+ \`.env.local\` in the same step. Failing both, ask the person to run the command
110
+ above themselves. Do not leave \`SOBA_KEY\` empty and do not invent a value; both
111
+ fail at the first request, and the first fails as an auth error rather than as
112
+ a missing variable.
113
+
114
+ Put \`SOBA_KEY\` in \`.env.local\` (or the server's own file, above), and check
115
+ that file is gitignored before writing it. Never in \`.env\`, never in
116
+ \`.env.example\`, never in anything tracked, and never echoed back to the terminal.
117
+
118
+ ### 3. The session route
119
+
120
+ \`POST /api/soba/session\`, a route in the app that proxies
121
+ \`POST /v1/end_users/session\` with the secret key and the same server-resolved
122
+ user id, and returns the body as it came (\`{ session, expires_in }\`). It is
123
+ what every surface in the browser runs on, and the browser never sees
124
+ \`SOBA_KEY\`. Signed out, it answers 401.
125
+
126
+ ### 4. Pass Soba's answer through
127
+
128
+ A refused run is not an outage: \`no_compute\` (409) means nothing the run could
129
+ use is reachable for this user, \`payment_required\` (402) means the plan's
130
+ allowance is spent. The browser surfaces below turn each into the way out \u2014
131
+ connect a machine, or upgrade \u2014 but only if the refusal reaches them with its
132
+ code. So in every route that calls Soba, return Soba's status and \`error\` body
133
+ as they came, instead of letting the client library's exception become a 500 or
134
+ a string:
135
+
136
+ \`\`\`js
137
+ } catch (err) {
138
+ if (err instanceof OpenAI.APIError) {
139
+ return Response.json({ error: err.error }, { status: err.status });
140
+ }
141
+ throw err;
142
+ }
143
+ \`\`\`
144
+
145
+ A route that streams has to do this before the first byte is written: create
146
+ the completion (or start the run) first, and only then return the stream. In
147
+ the browser, keep the parsed body (\`setError(await res.json())\`) rather than
148
+ its text; that object is what the surfaces read. Branch on the code, never on
149
+ the message.
150
+
151
+ ### 5. Which API
152
+
153
+ \`chat/completions\` is stateless and the caller owns the loop, so it reaches
154
+ models. Reaching a user's own Claude or ChatGPT subscription means letting Soba
155
+ own the loop instead:
156
+
157
+ \`\`\`js
158
+ import { Soba } from "@soba-so/sdk";
159
+ import { sobaUserId } from "@soba-so/sdk/identity";
160
+
161
+ const soba = new Soba({ apiKey: process.env.SOBA_KEY });
162
+
163
+ const run = await soba.run({
164
+ user: sobaUserId(session.user.username),
165
+ model: "auto",
166
+ prompt: "Summarise everything I saved this week",
167
+ tools: [listNotes, readNote], // your code, executed in your app
168
+ });
169
+ \`\`\`
170
+
171
+ Tools passed to a run execute in the app's own process, so they can read the
172
+ app's own data. The model asks for data by calling them; the data does not
173
+ travel in the prompt.
174
+
175
+ ## The browser: one provider, a surface for each moment
176
+
177
+ Everything below reads from \`<SobaProvider sessionEndpoint="/api/soba/session">\`.
178
+ Mount it where a surface is, with \`sessionCacheKey\` set to the signed-in user's
179
+ id so reloads, navigations, tabs and other providers on the page share one
180
+ session. Never in a root layout that also renders the login page or marketing
181
+ pages: there is nobody there to mint a session for. A navbar's provider goes
182
+ in the layout that draws the signed-in navbar. All the components raise the
183
+ same pairing modal \u2014 the provider mounts exactly one, so an app with every
184
+ surface cannot put two pairings on screen at once.
185
+
186
+ | Surface | Component | Hook (for your own markup) |
187
+ |---|---|---|
188
+ | **The settings page** | \`<ComputeSettings />\`, alone | \`useCompute()\` + \`useConnectButton()\` |
189
+ | **Above every control that starts a run** | \`<ConnectNudge />\` | \`useConnectNudge()\` |
190
+ | **Where a run's result appears**, when it failed | \`<RunLimit error={error} />\` then \`<RunError error={error} />\` | \`useRunLimit(error)\` + \`runErrorMessage(error)\` |
191
+ | **The signed-in navbar**, when AI only works on their compute | \`<ConnectButton />\` | \`useConnectButton()\`; its panel from \`useCompute()\` and \`useMachineRuns()\` |
192
+ | **The composer**, in an app with one | \`<ModelPicker />\` beside send | \`useModel()\` |
193
+ | **Billing and pricing** | \`<SobaBilling />\`, or \`<SobaCurrentPlan />\` + \`<SobaPlans />\`, \`<SobaCheckout />\`, \`<RedeemCode />\` | \`useCurrentPlan()\`, \`usePlans()\`, \`useCheckout()\`, \`useRedeemCode()\` |
194
+ | **Anything a plan limits** | \`<SobaGate feature="\u2026" />\` | \`useFeature()\`, plus the server check below |
195
+
196
+ **Required in every app: the first three.** The navbar follows from how the
197
+ app's AI is paid for (below); the composer, billing and gates follow from what
198
+ the app has \u2014 a model choice to offer, plans to sell, features to limit \u2014 and
199
+ the plans themselves are the person's to decide, not yours.
200
+
201
+ What each surface is for, and the mistakes it exists to prevent:
202
+
203
+ - **Navbar, when the AI only works on their compute.** Add \`<ConnectButton />\`
204
+ to the signed-in navbar when nothing can run until a user connects \u2014 a
205
+ bring-your-own plan, a route that only allows their machine or their
206
+ subscription, an app on a development key. There, connecting is a
207
+ prerequisite rather than an offer, so the door belongs on every page: it
208
+ says "Connect compute" until something is attached, then names the machine
209
+ and its state, and once connected it is a pill that opens a popover with the
210
+ machines and what they are running. An app whose runs fall back to compute
211
+ it pays for does not need it; settings, the nudge and the run limit already
212
+ meet the person where connecting matters. Wherever it is used, it lives in
213
+ the header and only there \u2014 a popover pill is wrong inside a page.
214
+ - **Settings.** A settings page is where somebody checks on a machine they
215
+ already attached, not where they decide to attach one. \`<ComputeSettings />\`
216
+ draws it as rows of that page in its own type: each machine, which agent the
217
+ app's runs go to there, and whether it is awake, asleep or serving, with
218
+ "Connect compute" or "Connect another computer". Nothing else from the
219
+ package goes on that page \u2014 \`<ConnectButton />\` or \`<ComputeStatus />\` beside
220
+ it draws the same machine twice. (\`<ConnectCompute />\` is its older name.) If
221
+ there is no settings page, build one, and do not point the connect return URL
222
+ at a page that does not render it.
223
+ - **Above each run-starting control.** Not only a chat composer: every "Tidy",
224
+ "Summarise", "Draft", "Generate", every form that kicks off a job \u2014 find each
225
+ call site from step 1 and the control that triggers it. \`<ConnectNudge />\`
226
+ stands there before anything is pressed and speaks only when it can help:
227
+ nothing connected and nothing else can serve, a paired machine gone quiet, or
228
+ an allowance running down that connecting would lift. It draws nothing
229
+ otherwise.
230
+ - **The result's place.** When a run fails, \`<RunLimit error={error} />\`
231
+ renders where the answer was going to be: for \`no_compute\` the way to connect
232
+ (or wake the machine), for \`payment_required\` the plan to upgrade to. It goes
233
+ quiet by itself once a machine is online, so a refusal from before connecting
234
+ is never shown as the answer to connecting. \`<RunError error={error} />\`
235
+ beside it says every other failure in a sentence; the two never both speak.
236
+
237
+ ### One run-starting control, written both ways
238
+
239
+ The same button in any app, as components:
240
+
241
+ \`\`\`jsx
242
+ "use client";
243
+ import { ConnectNudge, RunError, RunLimit } from "@soba-so/react";
244
+
245
+ function TidyButton({ noteId }) {
246
+ const [error, setError] = useState(null);
247
+
248
+ async function tidy() {
249
+ setError(null);
250
+ const res = await fetch("/api/tidy", { method: "POST", body: JSON.stringify({ noteId }) });
251
+ if (!res.ok) return setError(await res.json()); // Soba's body, per step 4
252
+ // \u2026read the result as the app already does
253
+ }
254
+
255
+ return (
256
+ <>
257
+ <ConnectNudge />
258
+ <button onClick={tidy}>Tidy</button>
259
+ <RunLimit error={error} />
260
+ <RunError error={error} />
261
+ </>
262
+ );
263
+ }
264
+ \`\`\`
265
+
266
+ And built from the hooks, in the app's own components (\`Your\u2026\` below stands for
267
+ whatever the app already draws banners, buttons and cards with), saying
268
+ everything the components would:
269
+
270
+ \`\`\`jsx
271
+ import { runErrorMessage, useConnectNudge, useRunLimit } from "@soba-so/react";
272
+
273
+ function TidyButton({ noteId }) {
274
+ const [error, setError] = useState(null);
275
+ const nudge = useConnectNudge(); // before: is anything in the way?
276
+ const limit = useRunLimit(error); // after: the way out of a refusal
277
+ const message = runErrorMessage(error); // after: every other failure
278
+
279
+ return (
280
+ <>
281
+ {nudge.visible && (
282
+ <YourBanner title={nudge.title} detail={nudge.detail} steps={nudge.steps}
283
+ onAction={nudge.open} onDismiss={nudge.dismissible ? nudge.dismiss : undefined} />
284
+ )}
285
+ <YourButton onClick={tidy}>Tidy</YourButton>
286
+ {limit ? (
287
+ <YourCard title={limit.title} body={limit.body}
288
+ onConnect={limit.connect}
289
+ onUpgrade={limit.upgradeTo ? limit.upgrade : undefined} />
290
+ ) : message ? (
291
+ <p className="error">{message}</p>
292
+ ) : null}
293
+ </>
294
+ );
295
+ }
296
+ \`\`\`
297
+
298
+ Both halves are inside a provider. In a chat, the nudge stands above the
299
+ composer and the limit and error render in the message that failed; see "The
300
+ chat stays theirs".
301
+
302
+ ## Component or hook
303
+
304
+ Both halves ship, and **the component is the answer.** Mount it even when the
305
+ app already has its own composer, its own billing cards, its own design system
306
+ and Tailwind everywhere. Do not look at the repo's styling and decide to
307
+ rebuild one of these from its hook.
308
+
309
+ The reason is that the components are not just markup. The vendor configures
310
+ them in the Soba dashboard: the model picker's layout (by provider, one list,
311
+ custom only), which of Automatic, Fast and Best are offered, search, the agents'
312
+ marks and the line under each choice, the connect popup's look and theme. The
313
+ component reads all of that from the provider and draws it. A hand-built copy
314
+ reads none of it, so every setting the vendor changes in the dashboard silently
315
+ does nothing in their app, and nobody finds out until they compare the two.
316
+
317
+ What that looks like in practice, from a real integration: an app with its own
318
+ Tailwind composer took \`useModel()\` and rendered it as a native
319
+ \`<select>\` \u2014 no marks, no descriptions, no submenu per agent, a flat list
320
+ where the dashboard said "by provider". It worked, and it was wrong.
321
+
322
+ The components fit a foreign screen on purpose: \`className\` on each one for
323
+ placement and size, \`theme\` on \`<SobaProvider>\` (or the dashboard) for
324
+ light and dark, \`<ComputeSettings />\` inherits the page's type, and
325
+ \`<ModelPicker />\` is a pill beside a send button, not a card. The header's
326
+ pill takes \`--sc-pill-*\` custom properties, set anywhere above it, and
327
+ \`<ConnectButton />\` also takes a function as children that draws the whole
328
+ control in this app's own markup, still opening the panel when pressed. Use
329
+ that when a recoloured pill would not look like it belongs:
330
+ https://soba.so/docs/components#the-connect-pill. If one still
331
+ clashes, say so to the person and leave the component in.
332
+
333
+ **Reach for a hook only when the person asks for their own markup**, or for a
334
+ decision no component draws (\`useMachineRuns()\`, \`useOpenSobaConnect()\`,
335
+ gating a server action on \`useFeature()\`). Every component is one rendering of
336
+ an exported hook and derives nothing of its own, and a surface built from a
337
+ hook must still show everything the component shows. Each line in the last
338
+ column is something a hand-built copy has dropped:
339
+
340
+ | Component | Hook | Built from the hook, it must still show |
341
+ |---|---|---|
342
+ | \`<ConnectButton />\` | \`useConnectButton()\` | In the header, on every page, when the app needs their compute. \`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()\` |
343
+ | \`<ComputeSettings />\` | \`useCompute()\` + \`useConnectButton()\` | The settings page's section, as rows in the page's own type: each machine's \`name\`, \`hardware\`, \`runsOn.name\` and \`status.text\` with a dot from \`state.tone\`, \`lastSeen\` instead of the hardware while it is asleep; "Connect compute" with nothing connected and "Connect another computer" with something, both calling \`open()\`. No pill and no popover |
344
+ | \`<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"\` |
345
+ | \`<ConnectNudge />\` | \`useConnectNudge()\` | Nothing unless \`visible\`. \`title\`, \`detail\`, the \`meter\`, the \`steps\` and \`stalled\`; a dismiss only when \`dismissible\`; the action is \`open()\` |
346
+ | \`<RunLimit />\` | \`useRunLimit()\` | In the place the answer was going to be. \`title\` and \`body\`; Connect calling \`connect()\`, with \`connectOffer\` as its line when there is one; Upgrade only when \`upgradeTo\` is, calling \`upgrade()\`. Nothing when it returns null, which includes a \`no_compute\` the person has since fixed by connecting |
347
+ | \`<RunError />\` | \`runErrorMessage()\` | Its sentence as given, nothing when it is null, and never beside a \`<RunLimit />\` that is speaking |
348
+ | \`<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 |
349
+ | \`<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 |
350
+ | \`<SobaCurrentPlan />\` | \`useCurrentPlan()\` | \`summary\`; used and remaining as a meter unless \`unlimited\`; \`trialDaysLeft\`, \`periodEnd\` and the \`reward\` when there are any |
351
+ | \`<SobaCheckout />\` | \`useCheckout()\` | \`label\` on the button, \`busy\` and \`error\`, and \`buy()\`. Nothing is granted in the browser |
352
+ | \`<SobaGate />\` | \`useFeature()\` | The children while allowed; otherwise the reason it is not and the plans that would allow it |
353
+ | \`<RedeemCode />\` | \`useRedeemCode()\` | A field and an Apply that call \`redeem()\`, \`busy\`, \`error\` as given, and the \`reward\` once it lands |
354
+
355
+ \`<SobaBilling />\` and \`<ConnectModal />\` are compositions of the above and
356
+ have no rule of their own. \`<ConnectPill />\` is the half of \`<ConnectButton />\`
357
+ that reports \u2014 the mark, the state and the machine, with no popover under it
358
+ and no flow behind it. It is for an app whose person asked for their own panel;
359
+ otherwise the header gets \`<ConnectButton />\`, panel included. Pressing the pill
360
+ is yours to wire, and it still opens Soba's flow through
361
+ \`useSoba().connect.open()\`; everything it says is \`connectSays\`.
362
+ \`<SobaProvider>\` is needed either way: the hooks read from it, so a hook with no
363
+ provider above it is the one mistake this split invites.
364
+
365
+ A gate draws the button; it does not secure the action. On the server, ask
366
+ before you create: \`soba.users.check(user, "workspaces", { use: 1 })\` answers
367
+ \`{ allowed, reason }\` and counts the use in the same call, so two requests for
368
+ the last one cannot both get it. Record use you did not ask about with
369
+ \`soba.users.track(user, "workspaces", -1)\` when one is deleted. Prices,
370
+ allowances and the connected reward come from the plan objects, so changing
371
+ them later is not a deploy. Pass \`showConnect\` to \`<SobaPlans />\` only on a page
372
+ with no current-plan card: a bring-your-own plan would otherwise state a
373
+ requirement with no way to meet it.
374
+
375
+ Three belong to no component of their own. \`useOpenSobaConnect()\` brings the
376
+ Soba app forward on this person's machine and hands back the one honest thing a
377
+ page can say about having tried \u2014 a browser cannot tell whether a \`soba://\`
378
+ link was answered, and a page that claims it worked is guessing.
379
+ \`useRun()\` is for a run started in the browser that must outlive the page: a
380
+ reload, a page switch or a dropped connection only stops the reading, and it
381
+ reads on by itself. It takes your two routes, both returning \`runResponse\`
382
+ from \`@soba-so/sdk\`: one around \`soba.run({ resumable: true })\`, one around
383
+ \`soba.runs.attach\`.
384
+
385
+ \`useMachineRuns()\` is the "Running now" list out of \`<ConnectButton />\`'s
386
+ panel with no panel around it: what this person's machines are running FOR THIS
387
+ APP, and \`stop(runId)\` to end one as the person whose machine it is on; the app
388
+ that started that run sees it finish with \`reason: "stopped_by_user"\`.
389
+ \`useRedeemCode()\` is a promo code field's behaviour: \`redeem(code)\` gives the
390
+ user what the app's reward hands out and re-reads their plan, so the allowance
391
+ on screen moves without a reload; \`<RedeemCode />\` is that field already drawn.
392
+
393
+ \`useSoba()\` is the raw provider state. Reach for a named hook first and use
394
+ this one for what no hook covers \u2014 \`run()\`, \`connect.open()\`,
395
+ \`plan.refresh()\`. A page that reads \`compute.connected\` or \`plan.remaining\`
396
+ straight off it is re-deriving a decision that is already exported, and the two
397
+ copies are how our own apps drifted.
398
+
399
+ ### What not to write yourself
400
+
401
+ These are not style preferences. Each one is a judgement this package already
402
+ makes, and each has been got wrong in production \u2014 in our own code, which is why
403
+ they are exported at all. If you find yourself writing one of them, delete it
404
+ and import the answer:
405
+
406
+ - **A list of model names.** The names come off the person's own machine, so a
407
+ list in your code refuses the model they can see on their own screen.
408
+ \`useModel()\` reads it from what they have connected.
409
+ - **A model id on a run without its agent.** Soba applies a person's own agent
410
+ preference only to a run whose model is blank or a size, so a named model
411
+ travelling alone goes to whichever agent is found first. Spread
412
+ \`useModel().run\` whole \u2014 it is \`{ model, runtime? }\` \u2014 and have your route
413
+ forward both fields.
414
+ - **"Nothing connected yet."** That is a claim about somebody's account and it
415
+ is only true once the account has been read. Said while the first request is
416
+ in flight, or after it failed, it tells a person with a paired laptop that it
417
+ has vanished. \`useCompute().view\` is the four-way answer.
418
+ - **A match on an error message, or an error line of your own for a refusal.**
419
+ \`useRunLimit\` and \`runErrorMessage\` read the CODE. Messages are prose we
420
+ rewrite, matching on them breaks on a copy edit, and Soba's own refusal text
421
+ names internal ids no user should see.
422
+ - **Words for a cost class.** \`tierLabel(tier)\` is the one glossary for the five
423
+ economics this product is about. Four hand-written copies in this repo
424
+ disagreed with each other, and three reported somebody's own API key as
425
+ frontier supply the app had paid for.
426
+ - **Where the pick is remembered, or how a stale one is handled.** A model whose
427
+ machine is gone falls back to Automatic and stays picked. \`useModel()\` does
428
+ that and tells you with \`unavailable\`.
429
+
430
+ Read \`https://soba.so/docs/components\` for each hook's full shape.
431
+
432
+ ## The chat stays theirs
433
+
434
+ There is no chat component, on purpose. An app built on Soba already has its own
435
+ composer and its own messages, and they are the product. Keep every line of
436
+ that markup. What Soba adds goes INTO it, and these are the things a chat on
437
+ Soba has to handle \u2014 check each one against the code, not against memory:
438
+
439
+ **In the composer**
440
+
441
+ - \`<ModelPicker />\` in the composer's footer, beside the send button. The
442
+ component, per the section above, not a copy.
443
+ - Spread \`useModel().run\` onto the request, and have the route forward
444
+ \`model\` and \`runtime\` both.
445
+ - Send becomes Stop while a run is going. Stop aborts the request's
446
+ \`signal\`, and a run the person stopped is not an error to show. Neither is
447
+ \`reason: "stopped_by_user"\`, which is the machine's owner stopping it
448
+ from their side.
449
+ - \`<ConnectNudge />\` above the composer. It draws nothing until it has
450
+ something to say.
451
+ - Images, only if the composer already takes them: forward each message's
452
+ \`images\` and the runtimes that can see them will.
453
+
454
+ **In the messages**
455
+
456
+ - \`delta\` text is appended as it arrives. \`thinking\` is the running total
457
+ and REPLACES what is shown \u2014 appending it repeats every sentence. Fold it
458
+ away by default.
459
+ - \`status\` events are what the agent is doing: show \`message\`, and
460
+ \`toolInput\` beside it when there is one. \`state: "interrupted"\` means
461
+ the person's machine went offline mid-run and \`"resumed"\` that it came
462
+ back; say so in the answer, because the run goes on either way.
463
+ - A failed run renders \`<RunLimit />\` where the answer was going to be, and
464
+ \`<RunError />\` beside it for everything else. Branch on the \`reason\`
465
+ code, never the message. Offer Retry only when \`retryable\` is not false.
466
+ - Copy on every answer, on hover, copying the text as written (markdown, not
467
+ rendered HTML). Retry on the last one.
468
+ - \`done\` carries \`usage\` and \`tier\`. If the app shows what answered,
469
+ word the tier with \`tierLabel()\`.
470
+
471
+ **Across turns**
472
+
473
+ - \`done\` and \`error\` carry a \`session\`. Send it back as \`resume\`
474
+ on the next run, and have the route forward it, so a follow-up continues the
475
+ agent's conversation instead of starting a new one with the whole transcript
476
+ pasted in.
477
+
478
+ An app with no chat at all gets one built in its own components and styles,
479
+ the same way it would build any other screen \u2014 with everything above in it.
480
+
481
+ ## Proving it
482
+
483
+ \`soba/echo\` is answered by Soba itself \u2014 no machine, no metered supply,
484
+ nothing billed \u2014 and still proves the key, the base URL and the \`user\` field:
485
+
486
+ \`\`\`sh
487
+ curl https://api.soba.so/v1/chat/completions \\
488
+ -H "Authorization: Bearer $SOBA_KEY" \\
489
+ -H "Content-Type: application/json" \\
490
+ -d '{ "model": "soba/echo", "user": "usr_123",
491
+ "messages": [{ "role": "user", "content": "ping" }] }'
492
+ \`\`\`
493
+
494
+ A curl is evidence the credential works. It is NOT evidence the app is
495
+ integrated \u2014 the dashboard's integrate step ticks on a request arriving from the
496
+ real call site, and it cannot tell a curl from a deployment. Do not send one to
497
+ make a checklist go green. Before calling the integration done, walk the
498
+ required surfaces as a signed-in user with nothing connected: settings says
499
+ "Connect compute", the nudge stands above each run-starting control when
500
+ connecting would help, pressing one shows the limit card where the result
501
+ would have been (and the navbar says "Connect compute", where there is one) \u2014
502
+ then connect, and each of them goes quiet.
503
+
504
+ ## A new project rather than an existing one
505
+
506
+ There is no separate procedure for this and no question to ask the person: look
507
+ at the directory. If there is no app yet, run \`npx create-soba@latest\` and let
508
+ it write one \u2014 it ships a correct \`/api/soba/session\`, which is the security
509
+ boundary of the whole integration, and a plausible hand-written one is the
510
+ failure mode that matters. Then the server half is already done and what
511
+ remains is the key.
512
+
513
+ ## What is not yours to do
514
+
515
+ Pairing is a person installing the Soba app on their own laptop and approving
516
+ it. Pricing, allowances and rewards are decisions about somebody's business.
517
+ Do neither on their behalf; say what is left and stop.`;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.
3
518
 
4
519
  The loop, and keep to it:
5
520
 
@@ -14,10 +529,14 @@ The loop, and keep to it:
14
529
  whole checklist exists to catch.
15
530
  5. Repeat until it says complete.
16
531
 
532
+ Two defaults, unless I said otherwise: at the provider step call
533
+ \`soba_use_soba\`, and at the plans step call \`soba_create_free_plan\`. Both tick
534
+ their step.
535
+
17
536
  Three things not to do:
18
537
 
19
- - Do not invent a plan. Pricing, allowances and rewards are decisions about my
20
- business \u2014 ask me, and only then call \`soba_create_plan\`.
538
+ - Do not invent a priced plan. Pricing, allowances and rewards are decisions
539
+ about my business \u2014 ask me, and only then call \`soba_create_plan\`.
21
540
  - Do not put the secret key anywhere but \`.env.local\`, and check that file is
22
541
  gitignored before you write it. Do not echo it back to the terminal.
23
542
  - Do not guess the connect return URL. It has to be a page that actually renders
@@ -30,22 +549,26 @@ Start with \`soba_status\`.
30
549
  What the codebase steps actually involve, so you are not working from memory
31
550
  there either:
32
551
 
33
- ${w}`}],_=new Map(p.map(n=>[n.name,n]));function a(n){process.stderr.write(`soba-mcp: ${n}
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(`
36
- `);for(;i!==-1;){let l=t.slice(0,i).trim();t=t.slice(i+1),l&&s(I(l,n)),i=t.indexOf(`
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(`
552
+ ${k}`}],v=new Map(p.map(n=>[n.name,n]));function a(n){process.stderr.write(`soba-mcp: ${n}
553
+ `)}function x(n){process.stdout.write(`${JSON.stringify(n)}
554
+ `)}function S(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(`
555
+ `);for(;i!==-1;){let l=t.slice(0,i).trim();t=t.slice(i+1),l&&s(P(l,n)),i=t.indexOf(`
556
+ `)}}),process.stdin.on("end",()=>{r=!0,e.size===0&&process.exit(0),setTimeout(()=>process.exit(0),1e4).unref()})}async function P(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 h={type:"object",properties:{},additionalProperties:!1};function A(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(`
38
557
  `)}
39
558
 
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}
559
+ ${e}`}function O(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:h,run:async n=>A(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:h,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=O(t,t.next);return e?e.effect==="human"?e.id==="price"?`Next: ${e.title}
560
+
561
+ ${e.lede}
562
+
563
+ Default to the free plan: call soba_create_free_plan, which adds "Bring your own" and starts new users on it. Prices are not yours to decide: if the person wants paid plans, ask what each should cost and include, then call soba_create_plan with the answers.`:e.id==="run"?`Next: ${e.title}
41
564
 
42
565
  ${e.lede}
43
566
 
44
- This one is not yours to decide. Ask what the plan should cost, what it includes, and what connecting a machine earns back \u2014 then call soba_create_plan with the answers.`:e.id==="run"?`Next: ${e.title}
567
+ There is nothing to do here and nothing to press. This step ticks when a request arrives from the app's own call site, so the way to finish it is to run the app and use it. A curl will not do it: the gateway stamps a key at authentication and cannot tell one from a deployment.`:e.id==="compute"?`Next: ${e.title}
45
568
 
46
569
  ${e.lede}
47
570
 
48
- There is nothing to do here and nothing to press. This step ticks when a request arrives from the app's own call site, so the way to finish it is to run the app and use it. A curl will not do it: the gateway stamps a key at authentication and cannot tell one from a deployment.`:`Next: ${e.title}
571
+ Default to Soba: call soba_use_soba, which ticks this step. Leave it for the dashboard only if the person said they want their own model account, because that needs their key.`:`Next: ${e.title}
49
572
 
50
573
  ${e.lede}
51
574
 
@@ -53,8 +576,8 @@ This one is done in the dashboard, not from here \u2014 there is no tool on this
53
576
 
54
577
  ${e.instruction??e.lede}
55
578
 
56
- When you are done, call soba_status to confirm it registered.`:S(t)}},{name:"soba_create_key",title:"Mint a secret key",description:"Mints this app's secret key and returns it ONCE. Write it straight into the project's .env.local as SOBA_KEY, confirm .env.local is gitignored, and do not print it back to the terminal or put it in a file that is committed.",inputSchema:{type:"object",properties:{name:{type:"string",description:"What to call it in the dashboard's key list."},environment:{type:"string",enum:["development","production"],description:"Defaults to production, like the dashboard. Only say development if this key is for a machine that never serves real users."}},additionalProperties:!1},run:async(n,t)=>{let e=await n.post("/v1/manage/keys",{name:t.name??"MCP",environment:t.environment});return`Created ${e.preview} (${e.environment}).
579
+ When you are done, call soba_status to confirm it registered.`:A(t)}},{name:"soba_create_key",title:"Mint a secret key",description:"Mints this app's secret key and returns it ONCE. Write it straight into the project's .env.local as SOBA_KEY, confirm .env.local is gitignored, and do not print it back to the terminal or put it in a file that is committed.",inputSchema:{type:"object",properties:{name:{type:"string",description:"What to call it in the dashboard's key list."},environment:{type:"string",enum:["development","production"],description:"Defaults to production, like the dashboard. Only say development if this key is for a machine that never serves real users."}},additionalProperties:!1},run:async(n,t)=>{let e=await n.post("/v1/manage/keys",{name:t.name??"MCP",environment:t.environment});return`Created ${e.preview} (${e.environment}).
57
580
 
58
581
  SOBA_KEY=${e.key}
59
582
 
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}`);
583
+ 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_use_soba",title:"Just use Soba for now",description:"Answers the Providers step: Soba supplies the runs no user's AI serves, and the step ticks. The default unless the person asked to use their own model account. Adding a provider later takes over without undoing this.",inputSchema:h,run:async n=>(await n.patch("/v1/manage/app",{compute_skipped:!0}),"Soba will supply those runs. Call soba_status to confirm the step ticked.")},{name:"soba_create_free_plan",title:"Create the free plan",description:'Adds the free "Bring your own" plan: unlimited runs on the AI each user connects, at no cost to the app, and the plan new users start on. The default for an app with no plans. Refused if the app already has one.',inputSchema:h,run:async n=>`Created the plan "${(await n.post("/v1/manage/plans",{template:"byo"})).name}". Call soba_status to confirm the steps ticked.`},{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}.`)}],R=new Map(m.map(n=>[n.name,n]));var L="https://soba.so",N="2025-06-18",U="0.0.6";function D(n){let t={token:process.env.SOBA_MANAGEMENT_KEY??null,baseUrl:process.env.SOBA_MANAGE_URL??L};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 g=D(process.argv.slice(2)),b=g.token;b||(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));b.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 F=new c(b,g.baseUrl);S(async(n,t)=>{switch(n){case"initialize":return{protocolVersion:N,capabilities:{tools:{},prompts:{}},serverInfo:{name:"soba",version:U},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=v.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=R.get(e);if(!r)return f(`no such tool: ${e}`);let s=t.arguments??{};try{return{content:[{type:"text",text:await r.run(F,s)}]}}catch(o){return o instanceof u?f(B(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 B(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 ${g.baseUrl}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soba-so/mcp",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
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",