@vibes.diy/prompts 14.3.206 → 14.3.208

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/llms/backend.md CHANGED
@@ -476,6 +476,22 @@ const stripe = await ctx.stripe.status(); // { test: { available, state }, live:
476
476
  a `ctx.fetch()` fired while a streamed body is still being pulled after the
477
477
  handler returned is unsupported and gets denied. Interactive frontend AI
478
478
  calls stay in `App.jsx` via `callAI`; server-side AI belongs to `ctx.callAI`.
479
+
480
+ **A server the person runs themselves is reached at its https address.** A
481
+ media server, a home dashboard, a NAS or a printer on their own network works
482
+ from a vibe once it answers at a public `https://` name: every vibe is served
483
+ over https, so the page and `ctx.fetch` both call https hosts. The person gets
484
+ that address from the server's own https setting, a reverse proxy with a
485
+ certificate in front of it, or a tunnel that gives the server a public https
486
+ name. Say that in your first reply, before the build, so the person can set
487
+ the address up while the app is being made. The app's connect form takes the
488
+ server's https address (placeholder `https://media.example.com`), saves it
489
+ with the person's other settings, and its helper line names those three ways
490
+ to get one. A call carrying the person's token, and any write, travels the
491
+ CORS lane: the server admits the app's origin in its CORS settings (media
492
+ servers usually have one), and the page calls it straight with that token. A
493
+ plain public read (a `GET` with no credentials) also works from a
494
+ `backend.js` route at that https address, through the read lane above.
479
495
  - **`ctx.callAI(prompt, options?)` is the server-side AI call.** It resolves to
480
496
  the completion **text** (a plain string) — no API key needed and none exists
481
497
  in the handler; the platform makes the call and meters the cost against the
@@ -1 +1 @@
1
- {"version":3,"file":"stripe.js","sourceRoot":"","sources":["../../jsr/llms/stripe.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,YAAY,GAAc;IACrC,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,iBAAiB;IACxB,WAAW,EACT,s8DAAs8D;IACx8D,IAAI,EAAE;QACJ,QAAQ;QACR,eAAe;QACf,cAAc;QACd,iBAAiB;QACjB,eAAe;QACf,cAAc;QACd,aAAa;QACb,UAAU;QACV,SAAS;QACT,MAAM;QACN,cAAc;QACd,SAAS;QACT,YAAY;QACZ,iBAAiB;QACjB,iBAAiB;QACjB,QAAQ;QACR,SAAS;QACT,cAAc;QACd,iBAAiB;QACjB,kBAAkB;QAClB,kBAAkB;QAClB,oBAAoB;QACpB,SAAS;QACT,QAAQ;QACR,UAAU;QACV,WAAW;QACX,iBAAiB;KAClB;IAID,SAAS,EAAE;QACT,aAAa;QACb,gBAAgB;QAChB,YAAY;QACZ,cAAc;QACd,iBAAiB;QACjB,gBAAgB;QAChB,aAAa;QACb,cAAc;QACd,eAAe;QACf,cAAc;QACd,eAAe;QACf,eAAe;QACf,iBAAiB;KAClB;IAGD,aAAa,EAAE,CAAC,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,CAAC;CACjG,CAAC"}
1
+ {"version":3,"file":"stripe.js","sourceRoot":"","sources":["../../jsr/llms/stripe.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,YAAY,GAAc;IACrC,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,iBAAiB;IACxB,WAAW,EACT,s8DAAs8D;IACx8D,IAAI,EAAE;QACJ,QAAQ;QACR,eAAe;QACf,cAAc;QACd,iBAAiB;QACjB,eAAe;QACf,cAAc;QACd,aAAa;QACb,UAAU;QACV,SAAS;QACT,MAAM;QACN,cAAc;QACd,SAAS;QACT,YAAY;QACZ,iBAAiB;QACjB,iBAAiB;QACjB,QAAQ;QACR,SAAS;QACT,cAAc;QACd,iBAAiB;QACjB,kBAAkB;QAClB,kBAAkB;QAClB,oBAAoB;QACpB,SAAS;QACT,QAAQ;QACR,UAAU;QACV,WAAW;QACX,iBAAiB;KAClB;IAKD,SAAS,EAAE;QACT,aAAa;QACb,gBAAgB;QAChB,YAAY;QACZ,cAAc;QACd,iBAAiB;QACjB,gBAAgB;QAChB,aAAa;QACb,cAAc;QACd,eAAe;QACf,cAAc;QACd,eAAe;QACf,eAAe;QACf,iBAAiB;KAClB;IAGD,aAAa,EAAE,CAAC,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,CAAC;CACjG,CAAC"}
package/llms/stripe.md CHANGED
@@ -221,9 +221,10 @@ Every order records the mode it was made in, and every ctx.stripe.fetch call for
221
221
  - `client_reference_id` and `metadata[orderId]` both carry the order's `_id`, so
222
222
  the session names the order from Stripe's side too.
223
223
  - `success_url` and `cancel_url` are the app's public address with the order in
224
- the fragment: `https://vibes.diy/vibe/<owner>/<slug>#paid=<orderId>` and
225
- `#cancelled=<orderId>`. The fragment never reaches the server, so the return
226
- page is the fast cached one.
224
+ the fragment: `https://vibes.diy/vibe/<owner>/<slug>#paid=<orderId>&total=<amount>&currency=<currency>`
225
+ and `#cancelled=<orderId>`. The fragment never reaches the server, so the return
226
+ page is the fast cached one, and the amount in it lets that page thank the
227
+ buyer at once (see *The return*).
227
228
  - `Idempotency-Key` is the order's `_id`, so a retried request mints one session,
228
229
  not two. And a second press for the same thing reuses the open attempt: the
229
230
  route looks for this buyer's pending order of the same bag at the prices it
@@ -281,6 +282,14 @@ Two things settle an order, and both are the backend reading
281
282
  A session whose `status` is `"expired"` moves the order to `expired`. Anything
282
283
  else leaves it pending.
283
284
 
285
+ The return page thanks the buyer from its address before it asks the backend: the success_url carries the amount, the page shows "Payment received" with it on its first render, and `/confirm` runs behind it, changing the line to "still confirming" only if the order comes back unpaid.
286
+
287
+ That line is display, so taking it from the address is safe: someone who types
288
+ `#paid=` into their own address bar only fools themselves, and the order's paid
289
+ state still comes from the read-back, never from the URL. Waiting on `/confirm`
290
+ before saying anything leaves a buyer who just paid looking at an unchanged shop
291
+ for the length of a Stripe round trip.
292
+
284
293
  A scheduled sweep settles every order still pending by reading its session back from Stripe, so a buyer who closes the tab is still marked paid.
285
294
 
286
295
  Settling is idempotent: the backend reads the order first, and an order that is no longer pending comes back as it is, with ok.
@@ -546,7 +555,8 @@ export async function fetch(request, ctx) {
546
555
  mode: "payment",
547
556
  client_reference_id: id,
548
557
  "metadata[orderId]": id,
549
- success_url: appUrl(ctx, `#paid=${id}`),
558
+ // The amount rides in the fragment so the return page can thank the buyer before /confirm answers.
559
+ success_url: appUrl(ctx, `#paid=${id}&total=${order.amount}&currency=${order.currency}`),
550
560
  cancel_url: appUrl(ctx, `#cancelled=${id}`),
551
561
  });
552
562
  // One Stripe line per bag line, so the buyer's receipt lists what they bought.
@@ -793,16 +803,29 @@ export default function App() {
793
803
  const setup = useSetup();
794
804
  const [picked, setPicked] = useState(null);
795
805
  const [error, setError] = useState(null);
806
+ // The order the buyer just came back from, and the line that thanks them for it.
807
+ const [back, setBack] = useState(null);
796
808
 
797
- // Back from Stripe: ask the backend to read the session and settle the order. The wrapper hands
798
- // the app its fragment just after first render and fires hashchange, so read the hash now AND on
799
- // every change — a mount-only read can miss it.
809
+ // Back from Stripe: thank the buyer from the address at once, then ask the backend to read the
810
+ // session and settle the order. The wrapper hands the app its fragment just after first render and
811
+ // fires hashchange, so read the hash now AND on every change — a mount-only read can miss it.
800
812
  useEffect(() => {
801
813
  const confirm = () => {
802
- const m = /#paid=([\w-]+)/.exec(location.hash);
803
- if (!m) return;
814
+ const params = new URLSearchParams(location.hash.slice(1));
815
+ const orderId = params.get("paid");
816
+ if (!orderId) return;
804
817
  history.replaceState(null, "", location.pathname);
805
- apiFetch("/confirm", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ orderId: m[1] }) });
818
+ const total = Number(params.get("total") ?? "x"); // NaN when the address carries no amount
819
+ const currency = params.get("currency") ?? "usd";
820
+ // Display only: the order's paid state comes from /confirm's read-back, never from this URL.
821
+ const thanks = Number.isInteger(total) ? `Payment received: ${money(total, currency)}. Thank you!` : "Payment received. Thank you!";
822
+ setBack({ orderId, thanks, confirming: false });
823
+ apiFetch("/confirm", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ orderId }) })
824
+ .then((r) => r.json())
825
+ .then((d) => {
826
+ if (d.status !== "paid") setBack({ orderId, thanks, confirming: true });
827
+ })
828
+ .catch(() => setBack({ orderId, thanks, confirming: true }));
806
829
  };
807
830
  confirm();
808
831
  window.addEventListener("hashchange", confirm);
@@ -865,6 +888,17 @@ export default function App() {
865
888
  ) : (
866
889
  <Stack>
867
890
  <Heading>Shop</Heading>
891
+ {/* The live order settles the line: once the sweep marks it paid, "still confirming" goes away. */}
892
+ {back && (
893
+ <Text>
894
+ {(() => {
895
+ const status = orders.find((o) => o._id === back.orderId)?.status;
896
+ if (status === "expired") return "That checkout closed before it was paid. Press Pay to start a fresh one.";
897
+ if (back.confirming && status !== "paid") return "Your payment is still confirming. It shows here as paid in a moment.";
898
+ return back.thanks;
899
+ })()}
900
+ </Text>
901
+ )}
868
902
  {forSale.length === 0 ? (
869
903
  <Text muted>{setup?.owner ? "Nothing is for sale yet. Add what you sell under Products." : "Nothing for sale yet."}</Text>
870
904
  ) : ready ? (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibes.diy/prompts",
3
- "version": "14.3.206",
3
+ "version": "14.3.208",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "exports": {
@@ -39,10 +39,10 @@
39
39
  "license": "Apache-2.0",
40
40
  "dependencies": {
41
41
  "@adviser/cement": "~0.5.34",
42
- "@vibes.diy/api-types": "14.3.206",
43
- "@vibes.diy/call-ai-v2": "14.3.206",
44
- "@vibes.diy/identity": "14.3.206",
45
- "@vibes.diy/use-vibes-types": "14.3.206",
42
+ "@vibes.diy/api-types": "14.3.208",
43
+ "@vibes.diy/call-ai-v2": "14.3.208",
44
+ "@vibes.diy/identity": "14.3.208",
45
+ "@vibes.diy/use-vibes-types": "14.3.208",
46
46
  "arktype": "~2.2.8",
47
47
  "json-schema-faker": "~0.6.3"
48
48
  },
@@ -515,6 +515,10 @@ Static assets. Files the maker added in the Files tab (or pushed with the CLI) a
515
515
 
516
516
  When an app works on the contents of a URL the person types — scanning it, checking it, scoring it, summarizing it — that address is read server-side: a `backend.js` `fetch` handler reads it with `ctx.fetch` and the page asks `/_api/…` for the text, because a page in a browser reaches its own app and the hosts that invite it. If that read comes back empty or fails, the app says so where the result goes, before anything worked out without it appears.
517
517
 
518
+ ### Connecting to a server the person runs
519
+
520
+ An app for a server the person runs themselves — a media server, a home dashboard, a NAS — connects to it at its https address, because the app is served over https and calls https hosts. The connect form asks for the server's https address, opening empty with the placeholder `https://media.example.com`, and saves it with the person's settings, and its helper line names the three ways to get one: the server's own https setting, a reverse proxy with a certificate, or a tunnel that gives the server a public https name.
521
+
518
522
  ## End every turn with one improvement question
519
523
 
520
524
  After your code edits, end your response with exactly ONE short improvement question and 2–4 multiple-choice options.
@@ -517,6 +517,10 @@ Static assets. Files the maker added in the Files tab (or pushed with the CLI) a
517
517
 
518
518
  When an app works on the contents of a URL the person types — scanning it, checking it, scoring it, summarizing it — that address is read server-side: a `backend.js` `fetch` handler reads it with `ctx.fetch` and the page asks `/_api/…` for the text, because a page in a browser reaches its own app and the hosts that invite it. If that read comes back empty or fails, the app says so where the result goes, before anything worked out without it appears.
519
519
 
520
+ ### Connecting to a server the person runs
521
+
522
+ An app for a server the person runs themselves — a media server, a home dashboard, a NAS — connects to it at its https address, because the app is served over https and calls https hosts. The connect form asks for the server's https address, opening empty with the placeholder `https://media.example.com`, and saves it with the person's settings, and its helper line names the three ways to get one: the server's own https setting, a reverse proxy with a certificate, or a tunnel that gives the server a public https name.
523
+
520
524
  ## End every turn with one improvement question
521
525
 
522
526
  After your code edits, end your response with exactly ONE short improvement question and 2–4 multiple-choice options.
package/system-prompt.md CHANGED
@@ -822,6 +822,10 @@ Static assets. Files the maker added in the Files tab (or pushed with the CLI) a
822
822
 
823
823
  When an app works on the contents of a URL the person types — scanning it, checking it, scoring it, summarizing it — that address is read server-side: a `backend.js` `fetch` handler reads it with `ctx.fetch` and the page asks `/_api/…` for the text, because a page in a browser reaches its own app and the hosts that invite it. If that read comes back empty or fails, the app says so where the result goes, before anything worked out without it appears.
824
824
 
825
+ ### Connecting to a server the person runs
826
+
827
+ An app for a server the person runs themselves — a media server, a home dashboard, a NAS — connects to it at its https address, because the app is served over https and calls https hosts. The connect form asks for the server's https address, opening empty with the placeholder `https://media.example.com`, and saves it with the person's settings, and its helper line names the three ways to get one: the server's own https setting, a reverse proxy with a certificate, or a tunnel that gives the server a public https name.
828
+
825
829
  ## End every turn with one improvement question
826
830
 
827
831
  After your code edits, end your response with exactly ONE short improvement question and 2–4 multiple-choice options.