scaledthought 0.2.1 → 0.2.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.
- package/dist/index.js +16 -10
- package/package.json +1 -1
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.2.
|
|
556
|
+
version: "0.2.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: [
|
|
@@ -631,7 +631,7 @@ function readDotEnv(cwd) {
|
|
|
631
631
|
}
|
|
632
632
|
return out;
|
|
633
633
|
}
|
|
634
|
-
var CREDITS_HINT = "This account has no credits for this request (inference is prepaid). Run `npx -y scaledthought@latest billing topup --amount-usd 5` (creating it charges nothing)
|
|
634
|
+
var CREDITS_HINT = "This account has no credits for this request (inference is prepaid). Run `npx -y scaledthought@latest billing topup --amount-usd 5` (creating it charges nothing) and give your human its message_for_human. If it printed opened_in_browser: true, run `npx -y scaledthought@latest billing wait` in the same turn (again on topup_pending, up to 15 minutes): it returns as soon as they pay. Otherwise end your turn with the message and run billing wait once they're back. Then retry. Don't retry before that or create another account.";
|
|
635
635
|
var HINTS = {
|
|
636
636
|
no_key: "Run `npx -y scaledthought@latest init --region us|ca` in this directory, or set ST_API_KEY.",
|
|
637
637
|
bad_key: "ST_API_KEY must look like st_{us|ca}_{live|test}_<40 chars>. Re-run init in a directory without one.",
|
|
@@ -8964,6 +8964,8 @@ var EXPERIMENT_METRICS = [
|
|
|
8964
8964
|
"signups",
|
|
8965
8965
|
"activation_rate",
|
|
8966
8966
|
"paid_rate",
|
|
8967
|
+
"topup_request_rate",
|
|
8968
|
+
"topup_completion_rate",
|
|
8967
8969
|
"cost_per_activated",
|
|
8968
8970
|
"cost_per_payer",
|
|
8969
8971
|
"onboarding_success_rate",
|
|
@@ -9245,11 +9247,12 @@ var NPX = "npx -y scaledthought@latest";
|
|
|
9245
9247
|
var FIRST_TOPUP_USD = 5;
|
|
9246
9248
|
var TOPUP_COMMAND = `${NPX} billing topup --amount-usd ${FIRST_TOPUP_USD}`;
|
|
9247
9249
|
var WAIT_COMMAND = `${NPX} billing wait`;
|
|
9250
|
+
var WAIT_PATIENCE_MIN = 15;
|
|
9248
9251
|
var CREDIT_STEPS = [
|
|
9249
9252
|
`Inference is prepaid and this account has no credits yet: completions return 402 insufficient_credits until your human pays. Do these first, in order:`,
|
|
9250
9253
|
`1. Run: ${TOPUP_COMMAND}. It opens the checkout page in your human's browser and prints approval_url, topup_id and message_for_human. Creating it charges nothing: don't ask first.`,
|
|
9251
|
-
`2.
|
|
9252
|
-
`3.
|
|
9254
|
+
`2. If opened_in_browser is true, the checkout page (where your human accepts the Terms and pays $${FIRST_TOPUP_USD} by card) is already in front of them: tell them so with message_for_human and, in the same turn, run: ${WAIT_COMMAND}. It returns status "paid" with the new balance as soon as they pay; on topup_pending run it again, for up to ${WAIT_PATIENCE_MIN} minutes in all. Don't wait for them to say they've paid.`,
|
|
9255
|
+
`3. If opened_in_browser is false (or it's still unpaid after ${WAIT_PATIENCE_MIN} minutes), end your turn with message_for_human: it holds the approval_url exactly as printed. When they're back, run ${WAIT_COMMAND}. Either way, don't retry the call and don't create another account.`,
|
|
9253
9256
|
"4. Then make the call below."
|
|
9254
9257
|
];
|
|
9255
9258
|
function nextSteps(model, needsCredits) {
|
|
@@ -9556,13 +9559,16 @@ function checkTopupLimits(amountUsd, autoReload) {
|
|
|
9556
9559
|
}
|
|
9557
9560
|
var TOPUP_DONE = new Set(["paid", "expired", "failed", "canceled"]);
|
|
9558
9561
|
function topupNextSteps(topupId, amountUsd, opened, autoReload) {
|
|
9562
|
+
const wait = `${WAIT_COMMAND}${topupId ? ` ${topupId}` : ""}`;
|
|
9559
9563
|
return [
|
|
9560
|
-
|
|
9561
|
-
`
|
|
9564
|
+
opened ? `The checkout page is already open in your human's browser: don't open it again. Tell them with message_for_human (it holds the approval_url in case it didn't open), then in the same turn run: ${wait}. It returns status "paid" with the balance as soon as they pay; on topup_pending run it again, for up to ${WAIT_PATIENCE_MIN} minutes in all. Don't wait for them to say they've paid. If it's still unpaid after that, end your turn with message_for_human.` : `Give your human message_for_human now and end your turn there: it holds the approval_url exactly as printed (a one-time payment link; don't shorten or reformat it). Don't run billing wait (or anything else that waits) before they have the link: they may not see your messages until your turn ends.`,
|
|
9565
|
+
`On that page they accept the Terms and the Credits & Refunds policy and pay $${amountUsd} by card; credits are added once the payment is confirmed. Nothing is charged without their approval.`,
|
|
9562
9566
|
...autoReload ? [
|
|
9563
9567
|
`Approving also saves the card for auto-reload: $${autoReload.amount_usd} whenever the balance drops below $${autoReload.threshold_usd}${autoReload.monthly_limit_usd ? `, at most $${autoReload.monthly_limit_usd} a month` : ""}.`
|
|
9564
9568
|
] : [],
|
|
9565
|
-
|
|
9569
|
+
...opened ? [] : [
|
|
9570
|
+
`When they say they've paid: ${wait} (returns status "paid" with the balance, at once if already paid; topup_pending means not yet: tell them, don't make a new link).`
|
|
9571
|
+
],
|
|
9566
9572
|
"Once paid, retry the call that returned 402. Don't create another top-up while this one is pending: the link stays valid until expires_at."
|
|
9567
9573
|
];
|
|
9568
9574
|
}
|
|
@@ -9606,7 +9612,7 @@ function messageForHuman(approvalUrl, amountUsd, autoReload, opened = false) {
|
|
|
9606
9612
|
|
|
9607
9613
|
${approvalUrl}
|
|
9608
9614
|
|
|
9609
|
-
On that page you accept the Terms of Service and the Credits & Refunds policy and pay by card. Nothing is charged until you approve.${reload}
|
|
9615
|
+
On that page you accept the Terms of Service and the Credits & Refunds policy and pay by card. Nothing is charged until you approve.${reload} I'm watching for the payment and will carry on as soon as it goes through.`;
|
|
9610
9616
|
return `To finish the setup, please buy $${amountUsd} of prepaid ScaledThought credits (USD) here:
|
|
9611
9617
|
|
|
9612
9618
|
${approvalUrl}
|
|
@@ -9637,7 +9643,7 @@ async function billingWait(ctx, o = {}) {
|
|
|
9637
9643
|
if (TOPUP_DONE.has(t.status ?? ""))
|
|
9638
9644
|
throw new CliError(`topup_${t.status}`, t.status === "expired" ? `Top-up ${id} expired before it was paid.` : `Top-up ${id} was not paid (${t.status}${t.failure_code ? `: ${t.failure_code}` : ""}).`, `Run \`${TOPUP_COMMAND}\` again and show your human the new approval_url.`, { topup_id: id });
|
|
9639
9645
|
if (Date.now() >= deadline)
|
|
9640
|
-
throw new CliError("topup_pending", `Top-up ${id} isn't paid yet.`, `Not paid yet. If your human
|
|
9646
|
+
throw new CliError("topup_pending", `Top-up ${id} isn't paid yet.`, `Not paid yet. If the checkout page is open in your human's browser (billing topup printed opened_in_browser: true), run \`${WAIT_COMMAND} ${id}\` again right away, for up to ${WAIT_PATIENCE_MIN} minutes in all. If they don't have the approval_url (below), or it's still unpaid after that, end your turn and give it to them, then run it again when they're back. Don't create a new top-up.`, { topup_id: id, approval_url: t.approval_url ?? null });
|
|
9641
9647
|
await new Promise((r) => setTimeout(r, o.pollMs ?? 3000));
|
|
9642
9648
|
}
|
|
9643
9649
|
}
|
|
@@ -10521,7 +10527,7 @@ var billing = defineCommand({
|
|
|
10521
10527
|
topup: defineCommand({
|
|
10522
10528
|
meta: {
|
|
10523
10529
|
name: "topup",
|
|
10524
|
-
description: "Buy prepaid credits: opens the checkout page in your human's browser (approval_url)
|
|
10530
|
+
description: "Buy prepaid credits: opens the checkout page in your human's browser (approval_url); then run `billing wait`, which returns once they pay. Optional auto-reload"
|
|
10525
10531
|
},
|
|
10526
10532
|
args: {
|
|
10527
10533
|
...jsonFlag,
|