scaledthought 0.3.1 → 0.3.2

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 +1 -1
  2. package/dist/index.js +19 -15
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -41,7 +41,7 @@ ends, so the link would reach the human only after the payment it is waiting for
41
41
 
42
42
  ```bash
43
43
  npx -y scaledthought@0.3 models --live # models serving in your region now
44
- npx -y scaledthought@0.3 chat -m auto "Reply with OK" # one real completion
44
+ npx -y scaledthought@0.3 chat -m <id> "Reply with OK" # one real completion (an id from models --live)
45
45
  npx -y scaledthought@0.3 mcp # `claude mcp add …` command + JSON config
46
46
  npx -y scaledthought@0.3 account # plan, region, spend
47
47
  npx -y scaledthought@0.3 account ad-measurement off # opt out of ad measurement
package/dist/index.js CHANGED
@@ -553,7 +553,7 @@ import { join } from "node:path";
553
553
  // package.json
554
554
  var package_default = {
555
555
  name: "scaledthought",
556
- version: "0.3.1",
556
+ version: "0.3.2",
557
557
  description: "Headless open-model inference, run by your agent. Prepaid, pay per token. US or Canada.",
558
558
  license: "MIT",
559
559
  keywords: [
@@ -677,10 +677,11 @@ var HINTS = {
677
677
  video_not_ready: "Poll `video get <id>` until status is completed, or pass --wait.",
678
678
  video_expired: "Videos are deleted 24 hours after they complete. Generate it again.",
679
679
  video_failed: "Your credits were returned. Retry, or try another model or size.",
680
- model_not_found: "Use an id from `models --live`, or model auto.",
680
+ model_not_found: "Use an id from `models --live`.",
681
+ model_required: "Pick a live chat model from `models --live` and pass its id with -m.",
681
682
  insufficient_scope: "This key lacks the scope. Use the account's default key or create one with the scope.",
682
683
  account_suspended: "Stop and tell your human. Contact hello@scaledthought.com.",
683
- upstream_error: "Transient model-server error. Retry with backoff, or use model auto to fail over.",
684
+ upstream_error: "Transient model-server error. Retry with backoff, or try another model from `models --live`.",
684
685
  service_unavailable: "Transient. Retry in a few seconds.",
685
686
  invalid_body: "Fix the field named in the message. Retrying unchanged will fail again.",
686
687
  invalid_request: "Fix the field named in the message. Retrying unchanged will fail again.",
@@ -9809,7 +9810,6 @@ function nextSteps(model, needsCredits) {
9809
9810
  return [
9810
9811
  ...needsCredits ? CREDIT_STEPS : [],
9811
9812
  model ? `Verify with one real completion: ${NPX} chat -m ${model} "Reply with OK" (or POST $ST_BASE_URL/chat/completions with that model)` : `No chat model is live in this region right now. Check again with: ${NPX} models --live`,
9812
- `Or let the router pick: ${NPX} chat -m auto "Reply with OK"`,
9813
9813
  "Use it from code: any OpenAI SDK with base_url=$ST_BASE_URL and api_key=$ST_API_KEY (both are in .env)",
9814
9814
  `Optional, connect MCP: ${NPX} mcp`,
9815
9815
  ...needsCredits ? [] : [`More credits when needed: ${TOPUP_COMMAND} returns an approval_url for your human (inference is prepaid)`]
@@ -9831,7 +9831,7 @@ async function liveSummary(ctx, region, balanceUsd) {
9831
9831
  return {
9832
9832
  balance_usd: balanceUsd ?? 0,
9833
9833
  needs_credits: needsCredits,
9834
- next_command: needsCredits ? TOPUP_COMMAND : `${NPX} chat -m ${suggested ?? "auto"} "Reply with OK"`,
9834
+ next_command: needsCredits ? TOPUP_COMMAND : suggested ? `${NPX} chat -m ${suggested} "Reply with OK"` : `${NPX} models --live`,
9835
9835
  newest_models: live.slice(0, 5),
9836
9836
  suggested_model: suggested,
9837
9837
  next_steps: nextSteps(suggested, needsCredits)
@@ -10051,12 +10051,15 @@ var keysRotate = async (ctx, id, o = {}) => api(ctx, "POST", `/v1/keys/${encodeU
10051
10051
  var keysRevokeSelf = (ctx) => api(ctx, "DELETE", "/v1/keys/self");
10052
10052
  var usage = (ctx, o) => api(ctx, "GET", `/v1/usage?days=${o.days}&group_by=${encodeURIComponent(o.by)}`);
10053
10053
  async function chat(ctx, o) {
10054
+ const requested = o.model?.trim();
10055
+ if (!requested)
10056
+ throw new CliError("model_required", 'chat needs a model id: chat -m <id> "your message".');
10054
10057
  const { key, region } = resolveKey(ctx);
10055
10058
  const res = await ctx.fetch(`${inferenceUrl(region, ctx.env)}/chat/completions`, {
10056
10059
  method: "POST",
10057
10060
  headers: { authorization: `Bearer ${key}`, "content-type": "application/json", "user-agent": USER_AGENT },
10058
10061
  body: JSON.stringify({
10059
- model: o.model,
10062
+ model: requested,
10060
10063
  messages: [{ role: "user", content: o.prompt }],
10061
10064
  stream: true,
10062
10065
  stream_options: { include_usage: true }
@@ -10066,7 +10069,7 @@ async function chat(ctx, o) {
10066
10069
  throw await responseError(res);
10067
10070
  let text = "";
10068
10071
  let usageOut = null;
10069
- let model = o.model;
10072
+ let model = requested;
10070
10073
  const decoder = new TextDecoder;
10071
10074
  let buf = "";
10072
10075
  for await (const chunk of res.body) {
@@ -10097,7 +10100,6 @@ async function chat(ctx, o) {
10097
10100
  }
10098
10101
  return {
10099
10102
  model,
10100
- routed_to: res.headers.get("x-st-routed-to"),
10101
10103
  region: res.headers.get("x-st-region"),
10102
10104
  request_id: res.headers.get("x-st-request-id"),
10103
10105
  text,
@@ -11317,7 +11319,9 @@ async function connect(ctx, tool, o = {}) {
11317
11319
  const { region } = resolveKey(ctx);
11318
11320
  const baseUrl = inferenceUrl(region, ctx.env);
11319
11321
  const models = await liveChatModels(ctx);
11320
- const model = o.model ?? models[0]?.id ?? "auto";
11322
+ const model = o.model ?? models[0]?.id;
11323
+ if (!model)
11324
+ throw new CliError("no_live_model", "No chat model is live in this region right now, so there is nothing to configure. Nothing was changed.", "Check `models --live` again later, or pass --model <id>.");
11321
11325
  if (!/^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/.test(model))
11322
11326
  throw new CliError("bad_argument", "--model isn't a model id.", "Pick one from `models --live`.");
11323
11327
  const host = machineName();
@@ -11345,7 +11349,7 @@ async function connect(ctx, tool, o = {}) {
11345
11349
  daily_budget_usd: k.daily_budget_usd,
11346
11350
  configured: ".env (OPENAI_API_BASE, OPENAI_API_KEY, AIDER_MODEL), mode 0600, git-ignored",
11347
11351
  model: `openai/${model}`,
11348
- models: ["auto", ...models.map((m) => m.id)],
11352
+ models: models.map((m) => m.id),
11349
11353
  next: "Run `aider` in this directory. Aider may warn that it doesn't know the model's context window; that's harmless."
11350
11354
  };
11351
11355
  }
@@ -11355,7 +11359,7 @@ async function connect(ctx, tool, o = {}) {
11355
11359
  const config = readJsonObject(configPath, "opencode.json");
11356
11360
  const auth = readJsonObject(authPath, authPath);
11357
11361
  const providers = config.provider && typeof config.provider === "object" ? config.provider : {};
11358
- const modelEntries = { auto: { name: "auto (ScaledThought picks per request)" } };
11362
+ const modelEntries = {};
11359
11363
  for (const m of models)
11360
11364
  modelEntries[m.id] = {
11361
11365
  name: m.id,
@@ -11396,11 +11400,11 @@ async function connect(ctx, tool, o = {}) {
11396
11400
  model: `${PROVIDER_ID}/${model}`,
11397
11401
  models: Object.keys(modelEntries),
11398
11402
  restart_needed: true,
11399
- next: `Restart OpenCode in this directory and pick a ${PROVIDER_ID}/… model (or ${PROVIDER_ID}/auto).`
11403
+ next: `Restart OpenCode in this directory and pick a ${PROVIDER_ID}/… model.`
11400
11404
  };
11401
11405
  }
11402
11406
  function instructions(tool, baseUrl, model, models, name) {
11403
- const ids = ["auto", ...models.map((m) => m.id)];
11407
+ const ids = models.some((m) => m.id === model) ? models.map((m) => m.id) : [model, ...models.map((m) => m.id)];
11404
11408
  if (tool === "cursor")
11405
11409
  return {
11406
11410
  tool,
@@ -11956,10 +11960,10 @@ var usage3 = defineCommand({
11956
11960
  run: ({ args }) => run2(() => usage(makeCtx(), { days: num("days", args.days) ?? 7, by: args.by }), args)
11957
11961
  });
11958
11962
  var chat2 = defineCommand({
11959
- meta: { name: "chat", description: "Send one message. Use -m auto to let the router pick" },
11963
+ meta: { name: "chat", description: 'Send one message to a model: chat -m <id> "…" (ids from `models --live`)' },
11960
11964
  args: {
11961
11965
  ...jsonFlag,
11962
- model: { type: "string", alias: "m", default: "auto", description: "Model id or auto" },
11966
+ model: { type: "string", alias: "m", description: "Model id, required (from `models --live`)" },
11963
11967
  prompt: { type: "positional", required: true, description: "The message" }
11964
11968
  },
11965
11969
  run: async ({ args }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scaledthought",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Headless open-model inference, run by your agent. Prepaid, pay per token. US or Canada.",
5
5
  "license": "MIT",
6
6
  "keywords": [