@vibes.diy/prompts 14.3.242 → 14.3.244

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.
@@ -89,15 +89,25 @@ function ConnectInstagram() {
89
89
  if (state === "pending") return null; // still resolving — never flash a Connect button
90
90
  // A connection that already works keeps working, whatever `available` says.
91
91
  if (consented && (state === "live" || state === "expiring"))
92
- return <Text>Connected as {accountLabel}</Text>;
92
+ return (
93
+ <Text>
94
+ Connected as {accountLabel}
95
+ {state === "expiring" && <Button type="button" variant="quiet" onClick={link}>Renew</Button>}
96
+ </Text>
97
+ );
93
98
  // Everything below asks the visitor to start or redo a connection, which is
94
99
  // the only thing `available` can stop.
95
- if (!available) return <Text muted>Connecting Instagram is not available right now.</Text>;
96
- if (state === "dead") return <Text muted>Your Instagram connection expired. Reconnect it in Settings.</Text>;
97
- return <Button type="button" onClick={link}>Connect Instagram</Button>;
100
+ if (!available) return <Text muted>Connecting Instagram opens up again soon.</Text>;
101
+ return <Button type="button" onClick={link}>{state === "dead" ? "Reconnect Instagram" : "Connect Instagram"}</Button>;
98
102
  }
99
103
  ```
100
104
 
105
+ **An `expiring` connection gets a Renew button that calls `link()`**, and a
106
+ `dead` one a Reconnect button that does the same: signing in again is how a
107
+ connection renews (LinkedIn's lasts 60 days and renews no other way), and the
108
+ platform's expiry notice tells the person to press Renew in the app. Show it
109
+ beside "Connected as …" while `state === "expiring"`.
110
+
101
111
  `useConnection(provider)` returns `state` (`pending` | `absent` | `live` |
102
112
  `expiring` | `dead`), `consented` (whether _this_ app has been approved — a
103
113
  `live` account with `consented: false` is a one-click ask, not a full
@@ -147,29 +157,30 @@ provider call as a typed request with a typed response, so there is no
147
157
 
148
158
  - `connectionState(ctx, provider)` → `{ state: "live" | "needs_consent" | "dead" | "error" }`.
149
159
  Spends nothing. `needs_consent` means render the Connect button; `dead` means
150
- tell the person to reconnect in Settings; `error` carries a `reason`.
160
+ render the Reconnect button (it calls `link()`); `error` carries a `reason`.
151
161
  - `github(ctx).me()` → `{ id, login, name, bio, avatarUrl, htmlUrl }`.
152
162
  - `threads(ctx).me()` → `{ id, username }`; `threads(ctx).posts({ limit, cursor })` →
153
163
  `{ items: [{ id, text, permalink, timestamp, mediaType }], cursor? }`.
154
164
  - `instagram(ctx).me()` → `{ id, username }`; `instagram(ctx).media({ limit, cursor })` →
155
165
  `{ items: [{ id, caption, mediaType, permalink, timestamp, likeCount, commentsCount }], cursor? }`
156
166
  (`likeCount` is `null` when the person hides likes, never `0`).
157
- - `threads(ctx).publish({ text, imageUrl?, replyToId? })` → `{ id }`. Needs
167
+ - `threads(ctx).publish({ text, imageUrl?, replyToId? })` → `{ id, permalink? }`. Needs
158
168
  `threads_content_publish`. A text post needs `text`; an image post needs a
159
169
  publicly reachable `imageUrl` the provider fetches itself.
160
- - `instagram(ctx).publish({ imageUrl, caption? })` → `{ id }`. Needs
170
+ - `instagram(ctx).publish({ imageUrl, caption? })` → `{ id, permalink? }`. Needs
161
171
  `instagram_business_content_publish`. Instagram has no text-only post, so
162
172
  `imageUrl` is required.
163
173
  - `linkedin(ctx).me()` → `{ id, name, givenName, familyName, picture, personUrn }`.
164
174
  Needs `profile`.
165
- - `linkedin(ctx).post({ text, visibility?, link? })` → `{ id }`. Needs
175
+ - `linkedin(ctx).post({ text, visibility?, link?, imageUrl?, altText? })` → `{ id, permalink }`. Needs
166
176
  `w_member_social` and `profile` (a post is authored as the member, and
167
177
  `profile` is where their id comes from). `text` is plain prose: the library
168
178
  escapes LinkedIn's formatting characters and keeps `#hashtags` live.
169
179
  `visibility` is `"PUBLIC"` (default) or `"CONNECTIONS"`. `link` is
170
180
  `{ url, title?, description? }` and becomes the post's card exactly as given,
171
- since LinkedIn shows what the request carries. LinkedIn posts carry text and
172
- a link card.
181
+ since LinkedIn shows what the request carries. `imageUrl` is a public https
182
+ JPEG, PNG or GIF up to 8 MB, which the platform uploads to LinkedIn for the
183
+ member; a post carries a picture or a link card.
173
184
 
174
185
  **Video posting is not available on any provider yet** — the provider hands
175
186
  back a container while the video is still processing, and the platform cannot
@@ -177,6 +188,9 @@ yet read that container's status, so a video post would intermittently fail
177
188
  rather than land. Build on text and images; do not work around it with a raw
178
189
  `ctx.connections` call, which hits the same race.
179
190
 
191
+ A composer that posts one update to several networks is the `social-post`
192
+ skill.
193
+
180
194
  Posting on someone's behalf is a real act, so **let the person press the
181
195
  button** — post from a `fetch` route the app calls on the person's own action, and
182
196
  never from a `scheduled` tick that posts for a visitor who is not there. A post
package/llms/index.d.ts CHANGED
@@ -18,6 +18,7 @@ export { createVibeConfig } from "./create-vibe.js";
18
18
  export { accessConfig } from "./access.js";
19
19
  export { connectionsConfig } from "./connections.js";
20
20
  export { githubConfig } from "./github.js";
21
+ export { socialPostConfig } from "./social-post.js";
21
22
  export { youtubeConfig } from "./youtube.js";
22
23
  export { blueskyConfig } from "./bluesky.js";
23
24
  export { spotifyConfig } from "./spotify.js";
@@ -61,7 +62,7 @@ export { uiCalendarConfig } from "./ui-calendar.js";
61
62
  export { uiTestimonialsConfig } from "./ui-testimonials.js";
62
63
  export type { LlmConfig } from "./types.js";
63
64
  export { cueMatches, cueMatchedSkills, type CueCatalogEntry } from "./cues.js";
64
- export declare const allConfigs: readonly [LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig];
65
+ export declare const allConfigs: readonly [LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig];
65
66
  export { mapsConfig } from "./maps.js";
66
67
  export declare const SKILL_ALIASES: ReadonlyMap<string, string>;
67
68
  export declare function canonicalSkillName(name: string): string;
package/llms/index.js CHANGED
@@ -18,6 +18,7 @@ import { createVibeConfig } from "./create-vibe.js";
18
18
  import { accessConfig } from "./access.js";
19
19
  import { connectionsConfig } from "./connections.js";
20
20
  import { githubConfig } from "./github.js";
21
+ import { socialPostConfig } from "./social-post.js";
21
22
  import { youtubeConfig } from "./youtube.js";
22
23
  import { blueskyConfig } from "./bluesky.js";
23
24
  import { spotifyConfig } from "./spotify.js";
@@ -78,6 +79,7 @@ export { createVibeConfig } from "./create-vibe.js";
78
79
  export { accessConfig } from "./access.js";
79
80
  export { connectionsConfig } from "./connections.js";
80
81
  export { githubConfig } from "./github.js";
82
+ export { socialPostConfig } from "./social-post.js";
81
83
  export { youtubeConfig } from "./youtube.js";
82
84
  export { blueskyConfig } from "./bluesky.js";
83
85
  export { spotifyConfig } from "./spotify.js";
@@ -140,6 +142,7 @@ export const allConfigs = [
140
142
  boardGamesConfig,
141
143
  accessConfig,
142
144
  connectionsConfig,
145
+ socialPostConfig,
143
146
  githubConfig,
144
147
  youtubeConfig,
145
148
  blueskyConfig,
package/llms/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../jsr/llms/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,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MAAM,CAAC,MAAM,aAAa,GAAgC,IAAI,GAAG,CAC/D,UAAU,CAAC,OAAO,CAAC,CAAC,CAAY,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAoB,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAC1G,CAAC;AAOF,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,OAAO,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;AACzC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { LlmConfig } from "./types.js";
2
+ export declare const socialPostConfig: LlmConfig;
@@ -0,0 +1,24 @@
1
+ export const socialPostConfig = {
2
+ name: "social-post",
3
+ label: "Post as you",
4
+ description: "Post as the visitor to their own Threads, LinkedIn and Instagram — a composer that cross-posts one update with an optional photo, a Connect and Renew button per network, one result and link per network — config.connections posting scopes, useConnection, apiFetch, threads/linkedin/instagram from @vibes.diy/social",
5
+ cues: [
6
+ "post to my linkedin",
7
+ "post to linkedin",
8
+ "share on linkedin",
9
+ "post to threads",
10
+ "post to my threads",
11
+ "post to instagram",
12
+ "post to my instagram",
13
+ "cross-post",
14
+ "crosspost",
15
+ "post it everywhere",
16
+ "all my socials",
17
+ "social media post",
18
+ "social composer",
19
+ "post as me",
20
+ ],
21
+ importModule: "use-vibes",
22
+ importName: "useConnection",
23
+ };
24
+ //# sourceMappingURL=social-post.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"social-post.js","sourceRoot":"","sources":["../../jsr/llms/social-post.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,gBAAgB,GAAc;IACzC,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,aAAa;IACpB,WAAW,EACT,2TAA2T;IAC7T,IAAI,EAAE;QACJ,qBAAqB;QACrB,kBAAkB;QAClB,mBAAmB;QACnB,iBAAiB;QACjB,oBAAoB;QACpB,mBAAmB;QACnB,sBAAsB;QACtB,YAAY;QACZ,WAAW;QACX,oBAAoB;QACpB,gBAAgB;QAChB,mBAAmB;QACnB,iBAAiB;QACjB,YAAY;KACb;IACD,YAAY,EAAE,WAAW;IACzB,UAAU,EAAE,eAAe;CAC5B,CAAC"}
@@ -0,0 +1,348 @@
1
+ # Post as you — one draft, out to Threads, LinkedIn and Instagram
2
+
3
+ A **post-as-you** app lets each visitor connect their own Threads, LinkedIn and
4
+ Instagram accounts, write one update, and send it to the networks they pick with
5
+ one press. The post lands on **their** feed, under their own name. The platform
6
+ shows the consent screen, signs them in, holds the credential, and uploads
7
+ pictures where a network needs it, so the app contains no client id, secret,
8
+ token field or upload code.
9
+
10
+ Signal words: "post to my LinkedIn", "share on Threads and Instagram",
11
+ "cross-post", "one update to all my socials", "a composer for my social
12
+ accounts", "share my sketch to Instagram".
13
+
14
+ ## The four parts, every time
15
+
16
+ **Declare each network with its posting scope in `config.connections`, give
17
+ each one its own Connect button from `useConnection`, post from a `fetch` route
18
+ through `@vibes.diy/social`, and call that route from the page with `apiFetch`.**
19
+ Leave out any one and the app breaks: an undeclared network has no consent
20
+ card, a missing button can never be approved, and a plain `fetch("/_api/…")`
21
+ reaches the backend as nobody, so every post is refused.
22
+
23
+ ## Declare — `backend.js`
24
+
25
+ | network | scopes to declare | what the post can carry |
26
+ | ----------- | ------------------------------------------------------------------- | -------------------------------------------------------------- |
27
+ | `threads` | `threads_basic`, `threads_content_publish` | text up to 500 characters, optionally one picture |
28
+ | `linkedin` | `profile`, `w_member_social` | text up to 3,000 characters, plus one picture **or** one link card |
29
+ | `instagram` | `instagram_business_basic`, `instagram_business_content_publish` | **a picture is required**, caption up to 2,200 characters |
30
+
31
+ **A scope that posts is a separate scope, and asking for it is the whole
32
+ authorization.** The visitor sees "Post to your LinkedIn feed as you" beside
33
+ your `why` and decides; an app that declared only the read scope cannot post.
34
+ Declare the read scope beside it as the table shows: LinkedIn needs `profile`
35
+ to know who the author is, and the Threads and Instagram read scopes are how a
36
+ post comes back with its link.
37
+
38
+ `why` is quoted to the visitor as the app's own words. Say what is posted and
39
+ when: "Post your update to your Threads feed when you press Post."
40
+
41
+ Instagram connects **Creator and Business accounts**. A visitor with a personal
42
+ account is shown how to switch (it is free, keeps their posts and followers, and
43
+ can be switched back), so the app needs no extra step for it.
44
+
45
+ ## Connect and renew — `App.jsx`
46
+
47
+ **Each network gets its own button, and each button follows the connection's
48
+ state.** `useConnection(network)` gives `state` (`pending` | `absent` | `live` |
49
+ `expiring` | `dead`), `consented`, `available`, `accountLabel` and `link()`.
50
+
51
+ **Offer a Renew button while a connection is `expiring`.** LinkedIn's sign-in
52
+ lasts 60 days and cannot renew by itself: the person renews it by signing in
53
+ again, and while they are still signed in to LinkedIn that takes one tap with
54
+ no new consent screen. So `expiring` shows "Connected as … · Renew", and Renew
55
+ calls the same `link()` as Connect. A `dead` connection gets a Reconnect button
56
+ that calls `link()` too. `link()` resolves when the sign-in starts, not when it
57
+ finishes, so after it the button re-reads with `refresh()` every few seconds,
58
+ a handful of times, while the page is in view.
59
+
60
+ Render the connected branch first: `available` only stops a connection being
61
+ _started_, never one that already works.
62
+
63
+ ## Post — `backend.js`
64
+
65
+ - `threads(ctx).publish({ text, imageUrl? })` → `{ id, permalink? }`
66
+ - `linkedin(ctx).post({ text, imageUrl?, altText?, link?, visibility? })` → `{ id, permalink }`.
67
+ `text` is plain prose (the library escapes LinkedIn's formatting characters
68
+ and keeps `#hashtags` live). `visibility` is `"PUBLIC"` (default) or
69
+ `"CONNECTIONS"`. A post carries `imageUrl` **or** `link`, never both.
70
+ - `instagram(ctx).publish({ imageUrl, caption? })` → `{ id, permalink? }`
71
+ - `connectionState(ctx, network)` → `{ state: "live" | "needs_consent" | "dead" | "error" }`,
72
+ spending nothing. Check it before posting so an unconnected network comes back
73
+ as a sentence, not a thrown error.
74
+
75
+ **A picture is a public https URL that every network can fetch.** Use a JPEG to
76
+ post the same picture everywhere: Instagram takes JPEG only, Threads takes JPEG
77
+ or PNG, and LinkedIn takes JPEG, PNG or GIF up to 8 MB. A picture the visitor
78
+ picks is saved as a file on a record every visitor can read (its own
79
+ `grant.public` channel in `access.js`), holding the picture alone (the post's
80
+ words stay off it until a network has them); wait for that save's `synced`
81
+ receipt to read `"accepted"`, then read the record back and its
82
+ `_files.photo.shareUrl` is the `imageUrl`. (`url` is a `blob:` address only this
83
+ page can open until then; `shareUrl` is the public one.) Threads and Instagram
84
+ fetch it themselves; for LinkedIn the platform uploads it for the member, so the
85
+ same URL works on all three.
86
+
87
+ **Post one network at a time and answer for each.** A post that fails on one
88
+ network still lands on the others, so the route returns one result per network
89
+ — `{ ok: true, permalink }` or `{ ok: false, error }` — and the page shows each
90
+ beside its network, with the link to the live post. A thrown error carries
91
+ `detail` (a plain sentence, from the picture step), `reason` (a connection
92
+ word such as `needs_consent`) or `message`; show the first one present.
93
+
94
+ **Post only when the person presses the button.** Posting is an act done in
95
+ someone's name, so it happens in a `fetch` route the page calls on their press,
96
+ never in a `scheduled` tick and never on page load. A visitor's connection can
97
+ only be spent while they are there: `scheduled` runs as the app's owner.
98
+
99
+ Build posts from text and pictures.
100
+
101
+ ## A complete composer
102
+
103
+ ### `backend.js`
104
+ ```js app=post-as-you
105
+ import { threads, linkedin, instagram, connectionState } from "@vibes.diy/social";
106
+
107
+ export const config = {
108
+ connections: [
109
+ {
110
+ provider: "threads",
111
+ scopes: ["threads_basic", "threads_content_publish"],
112
+ why: "Post your update to your Threads feed when you press Post.",
113
+ },
114
+ {
115
+ provider: "linkedin",
116
+ scopes: ["profile", "w_member_social"],
117
+ why: "Post your update to your LinkedIn feed when you press Post.",
118
+ },
119
+ {
120
+ provider: "instagram",
121
+ scopes: ["instagram_business_basic", "instagram_business_content_publish"],
122
+ why: "Post your photo and caption to your Instagram when you press Post.",
123
+ },
124
+ ],
125
+ };
126
+
127
+ const LIMITS = { threads: 500, linkedin: 3000, instagram: 2200 };
128
+
129
+ function postTo(ctx, network, text, imageUrl) {
130
+ if (network === "threads") return threads(ctx).publish({ text, imageUrl });
131
+ if (network === "linkedin") return linkedin(ctx).post({ text, imageUrl });
132
+ return instagram(ctx).publish({ imageUrl, caption: text });
133
+ }
134
+
135
+ async function postEverywhere(ctx, { text, imageUrl, networks }) {
136
+ const results = {};
137
+ for (const network of new Set(networks)) {
138
+ if (!(network in LIMITS)) continue;
139
+ const conn = await connectionState(ctx, network);
140
+ if (conn.state !== "live") {
141
+ results[network] = { ok: false, error: conn.state === "dead" ? "Reconnect to post here." : "Connect to post here." };
142
+ } else if (text.length > LIMITS[network]) {
143
+ results[network] = { ok: false, error: `Keep it under ${LIMITS[network]} characters here.` };
144
+ } else if (network === "instagram" && !imageUrl) {
145
+ results[network] = { ok: false, error: "Add a photo to post to Instagram." };
146
+ } else {
147
+ try {
148
+ const { permalink } = await postTo(ctx, network, text, imageUrl);
149
+ results[network] = { ok: true, permalink: permalink ?? null };
150
+ } catch (err) {
151
+ ctx.log(`post to ${network} failed: ${err.message}`);
152
+ results[network] = { ok: false, error: err.detail ?? err.reason ?? err.message };
153
+ }
154
+ }
155
+ }
156
+ return results;
157
+ }
158
+
159
+ export async function fetch(request, ctx) {
160
+ const url = new URL(request.url);
161
+ if (url.pathname.endsWith("/post") && request.method === "POST") {
162
+ const { text = "", imageUrl, networks = [] } = await request.json();
163
+ const results = await postEverywhere(ctx, { text, imageUrl: imageUrl || undefined, networks });
164
+ return Response.json({ results });
165
+ }
166
+ return new Response("not found", { status: 404 });
167
+ }
168
+ ```
169
+
170
+ ### `access.js`
171
+ ```js app=post-as-you
172
+ // The picture record is the one thing the networks read: Threads and Instagram fetch
173
+ // its file themselves, and the platform fetches it for LinkedIn. So it goes on its own
174
+ // channel that anyone can read, and it holds the picture alone.
175
+ export default function (doc, oldDoc, user) {
176
+ if (doc.type === "picture") {
177
+ if (!user) throw { forbidden: "Sign in to add a picture." };
178
+ // Create-only: everyone can read it, so nobody may swap another visitor's picture.
179
+ if (oldDoc) throw { forbidden: "A saved picture stays as it is." };
180
+ const ch = `picture:${doc._id}`;
181
+ return { channels: [ch], grant: { public: [ch] } };
182
+ }
183
+ throw { forbidden: "unknown record type" };
184
+ }
185
+ ```
186
+
187
+ ### `App.jsx`
188
+ ```jsx app=post-as-you
189
+ import React, { useRef, useState } from "react";
190
+ import { useFireproof } from "use-fireproof";
191
+ import { useConnection, apiFetch } from "use-vibes";
192
+ import { Badge, Button, Card, ErrorNote, Field, Heading, Row, Stack, Text, Textarea } from "@vibes.diy/ui";
193
+
194
+ const NETWORKS = [
195
+ { id: "threads", name: "Threads", limit: 500 },
196
+ { id: "linkedin", name: "LinkedIn", limit: 3000 },
197
+ { id: "instagram", name: "Instagram", limit: 2200 },
198
+ ];
199
+
200
+ // Resolves when the server has answered for this save: "accepted", "refused" or "held".
201
+ function whenSettled(synced) {
202
+ return new Promise((resolve) => synced.on((s) => s.status !== "pending" && resolve(s)));
203
+ }
204
+
205
+ function NetworkRow({ network, picked, onPick, result }) {
206
+ const { state, consented, available, accountLabel, link, refresh } = useConnection(network.id);
207
+ // link() resolves when sign-in STARTS, so re-read a few times while the page is in view.
208
+ async function connect() {
209
+ await link();
210
+ for (let i = 0; i < 6; i++) {
211
+ await new Promise((r) => setTimeout(r, 3000));
212
+ if (document.visibilityState === "visible") await refresh();
213
+ }
214
+ }
215
+ if (state === "pending") return null;
216
+ const connected = consented && (state === "live" || state === "expiring");
217
+ return (
218
+ <Row gap={2} align="center" wrap>
219
+ <Text>{network.name}</Text>
220
+ {connected ? (
221
+ <>
222
+ <Button type="button" variant={picked ? "primary" : "quiet"} onClick={() => onPick(!picked)}>
223
+ {picked ? "Posting here" : `Post as ${accountLabel}`}
224
+ </Button>
225
+ {state === "expiring" && (
226
+ <Button type="button" variant="quiet" onClick={connect}>
227
+ Renew
228
+ </Button>
229
+ )}
230
+ </>
231
+ ) : !available ? (
232
+ <Text muted>Connecting {network.name} opens up again soon.</Text>
233
+ ) : (
234
+ <Button type="button" onClick={connect}>
235
+ {state === "dead" ? `Reconnect ${network.name}` : `Connect ${network.name}`}
236
+ </Button>
237
+ )}
238
+ {result?.ok && (result.permalink ? <a href={result.permalink} target="_blank" rel="noreferrer">See the post</a> : <Badge tone="up">Posted</Badge>)}
239
+ {result && !result.ok && <Text muted>{result.error}</Text>}
240
+ </Row>
241
+ );
242
+ }
243
+
244
+ export default function App() {
245
+ const { database } = useFireproof("posts");
246
+ const [text, setText] = useState("");
247
+ const [photo, setPhoto] = useState(null);
248
+ const [picked, setPicked] = useState({});
249
+ const [results, setResults] = useState({});
250
+ const [busy, setBusy] = useState(false);
251
+ const [problem, setProblem] = useState("");
252
+ const fileRef = useRef(null);
253
+
254
+ const networks = NETWORKS.filter((n) => picked[n.id]).map((n) => n.id);
255
+ // Instagram takes a photo with no caption; every other network needs words.
256
+ const ready = text.trim() !== "" || (photo !== null && networks.every((n) => n === "instagram"));
257
+ const editDraft = (next) => {
258
+ setText(next);
259
+ setResults({});
260
+ };
261
+
262
+ async function post() {
263
+ setBusy(true);
264
+ setProblem("");
265
+ setResults({});
266
+ try {
267
+ let imageUrl;
268
+ if (photo) {
269
+ // The picture alone lives on a record every visitor can read, so each network can fetch it.
270
+ const saved = await database.put({ type: "picture", createdAt: Date.now(), _files: { photo } });
271
+ const receipt = await whenSettled(saved.synced);
272
+ if (receipt.status !== "accepted") {
273
+ setProblem(receipt.message || "Sign in to post your photo.");
274
+ return;
275
+ }
276
+ const doc = await database.get(saved.id);
277
+ imageUrl = doc._files.photo.shareUrl;
278
+ }
279
+ const res = await apiFetch("/post", {
280
+ method: "POST",
281
+ headers: { "content-type": "application/json" },
282
+ body: JSON.stringify({ text, imageUrl, networks }),
283
+ });
284
+ const data = await res.json();
285
+ if (res.ok) setResults(data.results);
286
+ else setProblem("The post did not go out. Try again in a moment.");
287
+ } catch (err) {
288
+ setProblem(err.message);
289
+ } finally {
290
+ setBusy(false);
291
+ }
292
+ }
293
+
294
+ return (
295
+ <div className="min-h-screen p-6 max-w-xl mx-auto bg-background text-foreground font-sans">
296
+ <Stack gap={4}>
297
+ <Heading level={1}>Post as you</Heading>
298
+ <Card>
299
+ <Stack gap={3}>
300
+ <Field label="Your update">
301
+ {(id, describedBy) => <Textarea id={id} describedBy={describedBy} rows={5} value={text} onChange={editDraft} />}
302
+ </Field>
303
+ <Text muted size="sm">{text.length} characters</Text>
304
+ <Row gap={3} align="center">
305
+ <Button type="button" variant="quiet" onClick={() => fileRef.current?.click()}>
306
+ {photo ? "Pick a different photo" : "Add a photo"}
307
+ </Button>
308
+ {photo && <Text muted size="sm">{photo.name}</Text>}
309
+ </Row>
310
+ <input ref={fileRef} type="file" accept="image/jpeg" hidden onChange={(e) => setPhoto(e.target.files?.[0] ?? null)} />
311
+ </Stack>
312
+ </Card>
313
+ <Stack gap={2}>
314
+ {NETWORKS.map((n) => (
315
+ <NetworkRow
316
+ key={n.id}
317
+ network={n}
318
+ picked={!!picked[n.id]}
319
+ onPick={(on) => setPicked((p) => ({ ...p, [n.id]: on }))}
320
+ result={results[n.id]}
321
+ />
322
+ ))}
323
+ </Stack>
324
+ <Button type="button" size="lg" disabled={busy || networks.length === 0 || !ready} onClick={post}>
325
+ {busy ? "Posting…" : `Post to ${networks.length || "your"} ${networks.length === 1 ? "network" : "networks"}`}
326
+ </Button>
327
+ {problem && <ErrorNote>{problem}</ErrorNote>}
328
+ </Stack>
329
+ </div>
330
+ );
331
+ }
332
+ ```
333
+
334
+ ## Building it well
335
+
336
+ - One draft, many networks: show each network's character count against its
337
+ own limit, and say before the press that Instagram needs a photo.
338
+ - A network the visitor has not connected shows its Connect button in place;
339
+ the rest of the composer keeps working.
340
+ - Keep the post's text exactly as written. Hashtags work everywhere; an
341
+ @-mention is plain text on LinkedIn.
342
+ - Save what was posted (text, picture, the per-network links) once it has
343
+ posted, as a record the visitor reads, so they can see their history. Give it
344
+ its own arm in `access.js` on the visitor's own channel, apart from the
345
+ public picture.
346
+ - A visitor's account is never a pasted token or a `ctx.secrets` value, and the
347
+ app never builds an `Authorization` header: the platform attaches the
348
+ credential.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibes.diy/prompts",
3
- "version": "14.3.242",
3
+ "version": "14.3.244",
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.242",
43
- "@vibes.diy/call-ai-v2": "14.3.242",
44
- "@vibes.diy/identity": "14.3.242",
45
- "@vibes.diy/use-vibes-types": "14.3.242",
42
+ "@vibes.diy/api-types": "14.3.244",
43
+ "@vibes.diy/call-ai-v2": "14.3.244",
44
+ "@vibes.diy/identity": "14.3.244",
45
+ "@vibes.diy/use-vibes-types": "14.3.244",
46
46
  "arktype": "~2.2.8",
47
47
  "json-schema-faker": "~0.6.3"
48
48
  },