@vibes.diy/prompts 14.3.289 → 14.3.291

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
@@ -521,6 +521,10 @@ const budget = await ctx.youtube.status(); // { available, unitsLeftToday, daily
521
521
  `path` is optional — match the object form in the example above, which is the
522
522
  calling convention (codegen has been observed passing these positionally).
523
523
  The message lands in that person's bell, inbox, and push notifications.
524
+ A notify to the app's own owner (`ctx.appInfo.ownerHandle`) also reaches
525
+ the assistant that made the app, in the chat it was made from, so send the
526
+ owner a notify when something needs a decision or a job is done, never on
527
+ every tick.
524
528
  - `toHandle` is one handle, and the platform delivers to people already in
525
529
  this app: the owner, who always qualifies, an accepted invite or approved
526
530
  request, a handle named in the access function's persisted grant state, or
@@ -596,6 +600,66 @@ const budget = await ctx.youtube.status(); // { available, unitsLeftToday, daily
596
600
  exactly the people entitled to see it, because the platform resolves that
597
601
  audience per reader at read time. The app's own screen is the source of
598
602
  truth; that's what makes it the right surface for anything shared.
603
+ - **Followers by text: a `subscribers` collection.** A public vibe can let
604
+ anyone follow it from their phone, signed in or not: they text Vibes the
605
+ vibe's link ("please notify me about the schedule on https://vibes.diy/vibe/…"),
606
+ and Vibes writes ONE record for them into the vibe's `subscribers` database,
607
+ `{ _id: "subscriber:<handle>", type: "subscriber", handle, authorHandle, created, until }`,
608
+ then texts them each notification the vibe sends to that handle. The vibe
609
+ opts in by giving `access.js` a `subscribers` function; with none, Vibes tells
610
+ the texter this vibe doesn't send updates yet and saves nothing.
611
+
612
+ ```js
613
+ // access.js — one record per follower, written only by that follower.
614
+ export function subscribers(doc, oldDoc, user, ctx) {
615
+ if (!user?.userHandle) throw { forbidden: "sign in" };
616
+ if (doc.type !== "subscriber" || doc.handle !== user.userHandle) throw { forbidden: "follow as yourself" };
617
+ if (doc._id !== "subscriber:" + doc.handle) throw { forbidden: "one record per follower" };
618
+ return { channels: ["subscribers"] }; // no grant: followers' handles stay with the owner
619
+ }
620
+ ```
621
+
622
+ The writing is what makes a follower someone the app may `ctx.notify`. A
623
+ `scheduled` handler reads the list in admin mode and tells each follower,
624
+ keyed by the happening so a re-run sends nothing twice. Group things that
625
+ happen at once into one message (two events at 5:00 PM are one text):
626
+
627
+ ```js
628
+ export const config = { scheduled: { interval: "1m" } };
629
+ export async function scheduled(event, ctx) {
630
+ const soon = startingWithin(10); // your own schedule, in its own time zone
631
+ if (soon.length === 0) return;
632
+ const nowIso = new Date().toISOString();
633
+ const subs = [];
634
+ let after;
635
+ do {
636
+ const page = await ctx.db.query({ db: "subscribers", field: "type", key: "subscriber", limit: 500, after });
637
+ // A follow past its `until` texts nobody, so leave it out.
638
+ subs.push(...page.docs.filter((d) => !d.until || d.until > nowIso));
639
+ after = page.next;
640
+ } while (after);
641
+ const body = soon.map((e) => `${e.title} starts at ${e.time}${e.loc ? `, ${e.loc}` : ""}`).join("\n");
642
+ for (const doc of subs) {
643
+ try {
644
+ await ctx.notify({ toHandle: doc.handle, body, dedupeKey: `soon-${soon[0].slot}`, path: `#${soon[0].id}` });
645
+ } catch (err) {
646
+ ctx.log("warn", "notify failed", { handle: doc.handle, reason: err.message });
647
+ }
648
+ }
649
+ }
650
+ ```
651
+
652
+ For the button, an `sms:` link opens Messages with the ask written out.
653
+ `target="_blank"` is what lets the tap leave the app's frame for Messages:
654
+
655
+ ```jsx
656
+ const ask = `Please notify me about changes to the schedule on ${appUrl}`;
657
+ <a href={`sms:vibes@vibes.diy&body=${encodeURIComponent(ask)}`} target="_blank" rel="noopener">Text me reminders</a>
658
+ ```
659
+
660
+ It works where iMessage does (iPhone, iPad, Mac), so label it for that.
661
+ A follower ends it by replying "stop", and their follow lapses on its own
662
+ after the days Vibes set for it.
599
663
  - **`ctx.log(level?, ...args)` is the handler's diagnostic lane.** It is the
600
664
  output that reaches the owner, who reads it back with
601
665
  `vibes-diy app logs <owner>/<slug> --since 1h [--tail]` — the isolate's
@@ -133,8 +133,10 @@ the job is done, so most ticks are silent.
133
133
  The notify goes to the app's owner, and `dedupeKey` keeps it to one
134
134
  notification per reason. When a chat's assistant made the app for a group,
135
135
  the owner is the group's handle, so that notification is the job handing
136
- itself back to the chat's assistant, which reads the plan and speaks to the
137
- group.
136
+ itself back to the chat's assistant: that notification wakes the assistant in
137
+ the chat it was made from, which reads the plan and speaks to the group, so
138
+ write the `body` as one plain line the assistant can act on ("Quorum: Thursday
139
+ 7pm, 5 of 6 answered"), and pass `path` when the plan has its own screen.
138
140
 
139
141
  ### `backend.js`
140
142
  ```js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibes.diy/prompts",
3
- "version": "14.3.289",
3
+ "version": "14.3.291",
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.289",
43
- "@vibes.diy/call-ai-v2": "14.3.289",
44
- "@vibes.diy/identity": "14.3.289",
45
- "@vibes.diy/use-vibes-types": "14.3.289",
42
+ "@vibes.diy/api-types": "14.3.291",
43
+ "@vibes.diy/call-ai-v2": "14.3.291",
44
+ "@vibes.diy/identity": "14.3.291",
45
+ "@vibes.diy/use-vibes-types": "14.3.291",
46
46
  "arktype": "~2.2.9",
47
47
  "json-schema-faker": "~0.6.3"
48
48
  },