@vibes.diy/vibe-runtime 14.3.369 → 14.3.371

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/VibeContext.d.ts CHANGED
@@ -3,7 +3,12 @@ import type { VibeMountParams } from "./vibe.js";
3
3
  import { type EvtVibeColorOverride, type EvtVibeLookCss } from "@vibes.diy/vibe-types";
4
4
  export declare const COLOR_OVERRIDE_STYLE_ID = "vibe-color-override";
5
5
  export declare const FONT_IMPORT_LINK_ID = "vibe-font-import";
6
- export declare function renderColorOverrideCss(colors: Record<string, string>, colorsDark?: Record<string, string>, colorScheme?: "light" | "dark", colorSchemeDark?: "light" | "dark"): string;
6
+ export declare function renderColorOverrideCss({ colors, colorsDark, colorScheme, colorSchemeDark, }: {
7
+ colors: Record<string, string>;
8
+ colorsDark?: Record<string, string>;
9
+ colorScheme?: "light" | "dark";
10
+ colorSchemeDark?: "light" | "dark";
11
+ }): string;
7
12
  export declare function applyFontImport(url: string | undefined): void;
8
13
  export declare function applyColorOverrideMessage(msg: EvtVibeColorOverride): void;
9
14
  export declare function applyLookCssMessage(msg: EvtVibeLookCss): void;
package/VibeContext.js CHANGED
@@ -16,7 +16,7 @@ function renderTokens(map) {
16
16
  .map(([k, v]) => ` --${OVERRIDE_TOKEN_RENAMES[k] ?? k}: ${v} !important;`)
17
17
  .join("\n");
18
18
  }
19
- export function renderColorOverrideCss(colors, colorsDark, colorScheme, colorSchemeDark) {
19
+ export function renderColorOverrideCss({ colors, colorsDark, colorScheme, colorSchemeDark, }) {
20
20
  const schemeLine = (scheme, indent) => scheme === undefined ? "" : `${indent}color-scheme: ${scheme} !important;\n`;
21
21
  const light = `:root {\n${schemeLine(colorScheme, " ")}${renderTokens(colors)}\n}`;
22
22
  const dark = colorsDark
@@ -45,7 +45,7 @@ export function applyFontImport(url) {
45
45
  link.href = url;
46
46
  document.head.appendChild(link);
47
47
  }
48
- function applyColorOverride(colors, colorsDark, revert, colorScheme, colorSchemeDark) {
48
+ function applyColorOverride({ colors, colorsDark, revert, colorScheme, colorSchemeDark, }) {
49
49
  if (typeof document === "undefined")
50
50
  return;
51
51
  if (revert === true) {
@@ -54,7 +54,7 @@ function applyColorOverride(colors, colorsDark, revert, colorScheme, colorScheme
54
54
  }
55
55
  if (Object.keys(colors).length === 0)
56
56
  return;
57
- const css = renderColorOverrideCss(colors, colorsDark, colorScheme, colorSchemeDark);
57
+ const css = renderColorOverrideCss({ colors, colorsDark, colorScheme, colorSchemeDark });
58
58
  let el = document.getElementById(COLOR_OVERRIDE_STYLE_ID);
59
59
  if (el === null) {
60
60
  el = document.createElement("style");
@@ -67,11 +67,16 @@ export function applyColorOverrideMessage(msg) {
67
67
  if (msg.revert === true) {
68
68
  if (typeof document !== "undefined")
69
69
  document.getElementById(FONT_IMPORT_LINK_ID)?.remove();
70
- applyColorOverride({}, undefined, true);
70
+ applyColorOverride({ colors: {}, revert: true });
71
71
  return;
72
72
  }
73
73
  applyFontImport(msg.fontImportUrl);
74
- applyColorOverride(msg.colors, msg.colorsDark, undefined, msg.colorScheme, msg.colorSchemeDark);
74
+ applyColorOverride({
75
+ colors: msg.colors,
76
+ colorsDark: msg.colorsDark,
77
+ colorScheme: msg.colorScheme,
78
+ colorSchemeDark: msg.colorSchemeDark,
79
+ });
75
80
  }
76
81
  export function applyLookCssMessage(msg) {
77
82
  if (typeof document === "undefined")
@@ -34,6 +34,7 @@ export interface BackendToolDecl {
34
34
  readonly run: BackendToolRun;
35
35
  readonly offer?: true;
36
36
  readonly textsLater?: true;
37
+ readonly picturePrompt?: true;
37
38
  }
38
39
  export interface ToolInputJsonSchema {
39
40
  readonly type: "object";
@@ -3,8 +3,19 @@ export declare function rewriteRelativeSpecifiers(code: string, baseUrl: string
3
3
  export declare const HOT_SWAP_ENTRY_PATH = "App.jsx";
4
4
  export declare function resolveCompanionPath(importerPath: string, spec: string): string | undefined;
5
5
  export declare function collectRelativeImports(code: string): string[];
6
- export declare function rewriteRelativeSpecifiersWithBlobs(code: string, importerPath: string, blobMap: ReadonlyMap<string, string>, baseUrl: string | undefined, scriptBaseFallback?: boolean): string;
7
- export declare function rewriteHotSwapEntrySpecifiers(code: string, files: readonly unknown[] | undefined, blobMap: ReadonlyMap<string, string>, baseUrl: string | undefined): string;
6
+ export declare function rewriteRelativeSpecifiersWithBlobs({ code, importerPath, blobMap, baseUrl, scriptBaseFallback, }: {
7
+ code: string;
8
+ importerPath: string;
9
+ blobMap: ReadonlyMap<string, string>;
10
+ baseUrl: string | undefined;
11
+ scriptBaseFallback?: boolean;
12
+ }): string;
13
+ export declare function rewriteHotSwapEntrySpecifiers({ code, files, blobMap, baseUrl, }: {
14
+ code: string;
15
+ files: readonly unknown[] | undefined;
16
+ blobMap: ReadonlyMap<string, string>;
17
+ baseUrl: string | undefined;
18
+ }): string;
8
19
  export declare function orderCompanionGraph(modules: readonly {
9
20
  readonly path: string;
10
21
  readonly code: string;
@@ -229,7 +229,7 @@ export function collectRelativeImports(code) {
229
229
  });
230
230
  return out;
231
231
  }
232
- export function rewriteRelativeSpecifiersWithBlobs(code, importerPath, blobMap, baseUrl, scriptBaseFallback = true) {
232
+ export function rewriteRelativeSpecifiersWithBlobs({ code, importerPath, blobMap, baseUrl, scriptBaseFallback = true, }) {
233
233
  return rewriteImportRegion(code, (spec) => {
234
234
  if (!RELATIVE_SPEC.test(spec))
235
235
  return undefined;
@@ -248,10 +248,16 @@ export function rewriteRelativeSpecifiersWithBlobs(code, importerPath, blobMap,
248
248
  });
249
249
  }
250
250
  const SCRIPT_MODULE_PATH = /\.(?:jsx?|tsx?|mjs|cjs)$/i;
251
- export function rewriteHotSwapEntrySpecifiers(code, files, blobMap, baseUrl) {
251
+ export function rewriteHotSwapEntrySpecifiers({ code, files, blobMap, baseUrl, }) {
252
252
  if (files === undefined)
253
253
  return rewriteRelativeSpecifiers(code, baseUrl);
254
- return rewriteRelativeSpecifiersWithBlobs(code, HOT_SWAP_ENTRY_PATH, blobMap, baseUrl, files.length > 0);
254
+ return rewriteRelativeSpecifiersWithBlobs({
255
+ code,
256
+ importerPath: HOT_SWAP_ENTRY_PATH,
257
+ blobMap,
258
+ baseUrl,
259
+ scriptBaseFallback: files.length > 0,
260
+ });
255
261
  }
256
262
  export function orderCompanionGraph(modules) {
257
263
  const byPath = new Map();
@@ -50,7 +50,7 @@ export function decorateFiles(doc, fetcher = defaultFetcher, local) {
50
50
  next[key] = {
51
51
  ...meta,
52
52
  ...(shareUrl === undefined ? {} : { shareUrl }),
53
- file: () => fetchAsFile(fetcher, meta.url, key, meta.type, meta.lastModified),
53
+ file: () => fetchAsFile({ fetcher, url: meta.url, name: key, type: meta.type, lastModified: meta.lastModified }),
54
54
  };
55
55
  }
56
56
  return { ...doc, _files: next };
@@ -67,7 +67,7 @@ async function fetchWithRetry(fetcher, url) {
67
67
  await new Promise((resolve) => setTimeout(resolve, READ_RETRY_DELAYS_MS[attempt]));
68
68
  }
69
69
  }
70
- async function fetchAsFile(fetcher, url, name, type, lastModified) {
70
+ async function fetchAsFile({ fetcher, url, name, type, lastModified, }) {
71
71
  const r = await fetchWithRetry(fetcher, url);
72
72
  if (!r.ok) {
73
73
  throw new Error(`fetch _files ${url}: ${r.status} ${r.statusText}`);
package/index.d.ts CHANGED
@@ -44,3 +44,4 @@ export { useVibe, type UseVibeResult, type CanVerdict, type UseVibeMe } from "./
44
44
  export { useEnv } from "./use-env.js";
45
45
  export { createVibe, buildCreateVibeUrl, resolveBuilderOrigin, resolveBuilderOriginFrom, VIBES_DIY_BUILDER_URL, CREATE_VIBE_SAFE_URL_LENGTH, type CreateVibeOptions, } from "./create-vibe.js";
46
46
  export { buildGithubInstallUrl, buildGithubInstallUrlFrom, type GithubInstallVibe } from "./github-install-url.js";
47
+ export { publicVibeBase } from "./short-self-link.js";
package/index.js CHANGED
@@ -40,3 +40,4 @@ export { useVibe } from "./use-vibe.js";
40
40
  export { useEnv } from "./use-env.js";
41
41
  export { createVibe, buildCreateVibeUrl, resolveBuilderOrigin, resolveBuilderOriginFrom, VIBES_DIY_BUILDER_URL, CREATE_VIBE_SAFE_URL_LENGTH, } from "./create-vibe.js";
42
42
  export { buildGithubInstallUrl, buildGithubInstallUrlFrom } from "./github-install-url.js";
43
+ export { publicVibeBase } from "./short-self-link.js";
@@ -275,7 +275,7 @@ export class IndexedDbStore {
275
275
  const queueStore = tx.objectStore(PUSH_QUEUE);
276
276
  const queued = [];
277
277
  for (const id of toEnqueue)
278
- queued.push(this.writeQueueEntry(queueStore, id, false));
278
+ queued.push(this.writeQueueEntry({ store: queueStore, docId: id, deleted: false }));
279
279
  await transactionDone(tx);
280
280
  for (const entry of queued)
281
281
  this.pushQueue.push(entry);
@@ -318,12 +318,12 @@ export class IndexedDbStore {
318
318
  for (const doc of legacyDocs.values()) {
319
319
  docsStore.put(doc);
320
320
  if (this.persistent)
321
- queued.push(this.writeQueueEntry(queueStore, doc._id, false));
321
+ queued.push(this.writeQueueEntry({ store: queueStore, docId: doc._id, deleted: false }));
322
322
  }
323
323
  for (const id of deletedIds) {
324
324
  docsStore.delete(id);
325
325
  if (this.persistent)
326
- queued.push(this.writeQueueEntry(queueStore, id, true));
326
+ queued.push(this.writeQueueEntry({ store: queueStore, docId: id, deleted: true }));
327
327
  }
328
328
  tx.objectStore(META).put(true, MIGRATION_KEY);
329
329
  await transactionDone(tx);
@@ -728,7 +728,7 @@ export class IndexedDbStore {
728
728
  const written = await this.writeTx(this.db, [DOCS, PUSH_QUEUE], (tx) => {
729
729
  tx.objectStore(DOCS).put(saved);
730
730
  if (this.persistent)
731
- queued = this.writeQueueEntry(tx.objectStore(PUSH_QUEUE), id, false, opId);
731
+ queued = this.writeQueueEntry({ store: tx.objectStore(PUSH_QUEUE), docId: id, deleted: false, opId });
732
732
  });
733
733
  if (written.isErr())
734
734
  return Result.Err(written.Err());
@@ -769,7 +769,7 @@ export class IndexedDbStore {
769
769
  tx.objectStore(DOCS).delete(id);
770
770
  tx.objectStore(SYNC_META).delete(id);
771
771
  if (this.persistent)
772
- queued = this.writeQueueEntry(tx.objectStore(PUSH_QUEUE), id, true, opId);
772
+ queued = this.writeQueueEntry({ store: tx.objectStore(PUSH_QUEUE), docId: id, deleted: true, opId });
773
773
  });
774
774
  if (written.isErr())
775
775
  return Result.Err(written.Err());
@@ -786,7 +786,7 @@ export class IndexedDbStore {
786
786
  return Result.Ok({ id, ok: true, synced });
787
787
  });
788
788
  }
789
- writeQueueEntry(store, docId, deleted, opId = newOpId()) {
789
+ writeQueueEntry({ store, docId, deleted, opId = newOpId(), }) {
790
790
  const entry = { id: 0, docId, deleted, opId };
791
791
  const req = store.put({ docId, deleted, opId });
792
792
  req.onsuccess = () => {
package/mount-vibes.js CHANGED
@@ -96,7 +96,7 @@ export function mountVibe(comps, iprops, hotSwapAttempt, hotSwapRollback) {
96
96
  throw new Error(`Can't find the dom element root`);
97
97
  }
98
98
  activeProps = iprops;
99
- const renderElement = buildVibeTree(comps, props, hotSwapAttempt, hotSwapRollback);
99
+ const renderElement = buildVibeTree({ comps, props, hotSwapAttempt, hotSwapRollback });
100
100
  if (activeRoot === undefined) {
101
101
  const container = element[0];
102
102
  setAppContainer(container);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibes.diy/vibe-runtime",
3
- "version": "14.3.369",
3
+ "version": "14.3.371",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -36,9 +36,9 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@adviser/cement": "~0.5.37",
39
- "@vibes.diy/api-types": "14.3.369",
40
- "@vibes.diy/base": "14.3.369",
41
- "@vibes.diy/vibe-types": "14.3.369",
39
+ "@vibes.diy/api-types": "14.3.371",
40
+ "@vibes.diy/base": "14.3.371",
41
+ "@vibes.diy/vibe-types": "14.3.371",
42
42
  "arktype": "~2.2.9",
43
43
  "charwise": "~3.0.1",
44
44
  "es-module-lexer": "~3.0.4",
@@ -545,7 +545,7 @@ const GITHUB_LANE = {
545
545
  subject: "config.github",
546
546
  shadowable: ["github", "bind", "why", "permissions"],
547
547
  };
548
- const duplicateKeyError = (lane, where, key, count) => `${lane.subject} is ambiguous: ${where} declares a duplicate \`${key}\` key (${count} times) — JavaScript keeps only the LAST one, so the declaration in the source is not the declaration that runs. Remove the extra \`${key}\` key(s) so exactly one remains, then push again`;
548
+ const duplicateKeyError = ({ lane, where, key, count }) => `${lane.subject} is ambiguous: ${where} declares a duplicate \`${key}\` key (${count} times) — JavaScript keeps only the LAST one, so the declaration in the source is not the declaration that runs. Remove the extra \`${key}\` key(s) so exactly one remains, then push again`;
549
549
  const ambiguousKeyError = (lane, where) => `${lane.subject} is ambiguous: ${where} has a property key this push-time parser cannot read statically — a computed \`[key]\`, a spread, an accessor/generator, or a quoted name with escapes. Any of those could shadow ${lane.shadowable
550
550
  .map((k) => `\`${k}\``)
551
551
  .join("/")}, so write those keys literally (bare or plainly quoted) alongside no unreadable siblings, then push again`;
@@ -574,7 +574,16 @@ function extractFetchUnfilteredReads(src) {
574
574
  return { errors: configKeys.errors };
575
575
  const fetchKeys = named(configKeys.keys, "fetch");
576
576
  if (fetchKeys.length > 1)
577
- return { errors: [duplicateKeyError(FETCH_UNFILTERED_READS_LANE, "the exported config object", "fetch", fetchKeys.length)] };
577
+ return {
578
+ errors: [
579
+ duplicateKeyError({
580
+ lane: FETCH_UNFILTERED_READS_LANE,
581
+ where: "the exported config object",
582
+ key: "fetch",
583
+ count: fetchKeys.length,
584
+ }),
585
+ ],
586
+ };
578
587
  const fetchStart = fetchKeys[0]?.valueStart;
579
588
  const fetchObj = fetchStart === undefined ? undefined : objectAt(configObj, fetchStart);
580
589
  if (fetchObj === undefined)
@@ -584,7 +593,16 @@ function extractFetchUnfilteredReads(src) {
584
593
  return { errors: fetchLaneKeys.errors };
585
594
  const declKeys = named(fetchLaneKeys.keys, "unfilteredReads");
586
595
  if (declKeys.length > 1)
587
- return { errors: [duplicateKeyError(FETCH_UNFILTERED_READS_LANE, "config.fetch", "unfilteredReads", declKeys.length)] };
596
+ return {
597
+ errors: [
598
+ duplicateKeyError({
599
+ lane: FETCH_UNFILTERED_READS_LANE,
600
+ where: "config.fetch",
601
+ key: "unfilteredReads",
602
+ count: declKeys.length,
603
+ }),
604
+ ],
605
+ };
588
606
  const declStart = declKeys[0]?.valueStart;
589
607
  const decl = declStart === undefined ? undefined : objectAt(fetchObj, declStart);
590
608
  if (decl === undefined)
@@ -598,9 +616,19 @@ function extractFetchUnfilteredReads(src) {
598
616
  if (dbsKeys.length > 1 || whyKeys.length > 1) {
599
617
  const dupes = [];
600
618
  if (dbsKeys.length > 1)
601
- dupes.push(duplicateKeyError(FETCH_UNFILTERED_READS_LANE, "config.fetch.unfilteredReads", "dbs", dbsKeys.length));
619
+ dupes.push(duplicateKeyError({
620
+ lane: FETCH_UNFILTERED_READS_LANE,
621
+ where: "config.fetch.unfilteredReads",
622
+ key: "dbs",
623
+ count: dbsKeys.length,
624
+ }));
602
625
  if (whyKeys.length > 1)
603
- dupes.push(duplicateKeyError(FETCH_UNFILTERED_READS_LANE, "config.fetch.unfilteredReads", "why", whyKeys.length));
626
+ dupes.push(duplicateKeyError({
627
+ lane: FETCH_UNFILTERED_READS_LANE,
628
+ where: "config.fetch.unfilteredReads",
629
+ key: "why",
630
+ count: whyKeys.length,
631
+ }));
604
632
  return { errors: dupes };
605
633
  }
606
634
  const dbsStart = dbsKeys[0]?.valueStart;
@@ -682,7 +710,9 @@ function extractConnections(src) {
682
710
  return { errors: configKeys.errors };
683
711
  const connKeys = named(configKeys.keys, "connections");
684
712
  if (connKeys.length > 1) {
685
- return { errors: [duplicateKeyError(lane, "the exported config object", "connections", connKeys.length)] };
713
+ return {
714
+ errors: [duplicateKeyError({ lane, where: "the exported config object", key: "connections", count: connKeys.length })],
715
+ };
686
716
  }
687
717
  const connStart = connKeys[0]?.valueStart;
688
718
  if (connStart === undefined)
@@ -718,7 +748,7 @@ function extractConnections(src) {
718
748
  ["why", whyKeys],
719
749
  ].filter(([, ks]) => ks.length > 1);
720
750
  if (dupes.length > 0) {
721
- errors.push(...dupes.map(([key, ks]) => duplicateKeyError(lane, where, key, ks.length)));
751
+ errors.push(...dupes.map(([key, ks]) => duplicateKeyError({ lane, where, key, count: ks.length })));
722
752
  continue;
723
753
  }
724
754
  const provider = stringPropertyAt(entryObj, providerKeys[0]);
@@ -799,7 +829,7 @@ function extractGithub(src) {
799
829
  if (githubKeys.length === 0)
800
830
  return { errors: [] };
801
831
  if (githubKeys.length > 1) {
802
- return { errors: [duplicateKeyError(lane, "the exported config object", "github", githubKeys.length)] };
832
+ return { errors: [duplicateKeyError({ lane, where: "the exported config object", key: "github", count: githubKeys.length })] };
803
833
  }
804
834
  const githubStart = githubKeys[0].valueStart;
805
835
  if (githubStart === undefined) {
@@ -825,7 +855,7 @@ function extractGithub(src) {
825
855
  ["permissions", permissionsKeys],
826
856
  ].filter(([, ks]) => ks.length > 1);
827
857
  if (dupes.length > 0)
828
- return { errors: dupes.map(([key, ks]) => duplicateKeyError(lane, "config.github", key, ks.length)) };
858
+ return { errors: dupes.map(([key, ks]) => duplicateKeyError({ lane, where: "config.github", key, count: ks.length })) };
829
859
  const errors = [];
830
860
  let bind = "owner";
831
861
  if (bindKeys.length === 1) {
@@ -933,6 +963,7 @@ const TOOLS_LANE = {
933
963
  "write",
934
964
  "offer",
935
965
  "textsLater",
966
+ "picturePrompt",
936
967
  "db",
937
968
  "set",
938
969
  "key",
@@ -941,7 +972,7 @@ const TOOLS_LANE = {
941
972
  "enum",
942
973
  ],
943
974
  };
944
- const TOOL_KEYS = ["description", "for", "input", "handler", "write", "offer", "textsLater"];
975
+ const TOOL_KEYS = ["description", "for", "input", "handler", "write", "offer", "textsLater", "picturePrompt"];
945
976
  const TOOL_FIELD_KEYS = ["type", "description", "optional", "enum"];
946
977
  const TOOL_WRITE_KEYS = ["db", "set", "key"];
947
978
  const TOOLS_SHAPE = 'tools must be `export const tools = { vote: { description: "…", input: { choice: "string" }, handler(input, ctx) { … } } }` with static literals';
@@ -1044,7 +1075,7 @@ function toolObjectKeys(obj, where, allowed) {
1044
1075
  continue;
1045
1076
  }
1046
1077
  if (out.has(name)) {
1047
- errors.push(duplicateKeyError(TOOLS_LANE, where, name, named(read.keys, name).length));
1078
+ errors.push(duplicateKeyError({ lane: TOOLS_LANE, where, key: name, count: named(read.keys, name).length }));
1048
1079
  continue;
1049
1080
  }
1050
1081
  out.set(name, k);
@@ -1171,6 +1202,19 @@ function extractToolWrite(tool, key, where) {
1171
1202
  return { errors };
1172
1203
  return { value: { kind: "write", db, set, ...(recordKey === undefined ? {} : { key: recordKey }) }, errors };
1173
1204
  }
1205
+ const BUILDER_INPUT_SHAPE = 'input: { addition: { type: "string", optional: true } }, because the builder is called with { addition } for a new look and with {} for a first photo';
1206
+ function builderInputProblem(input) {
1207
+ const addition = input.find((f) => f.name === "addition");
1208
+ if (addition === undefined)
1209
+ return `needs ${BUILDER_INPUT_SHAPE}`;
1210
+ if (addition.type !== "string" || addition.optional === false || addition.enum !== undefined) {
1211
+ return `declares addition as an optional string with no enum: ${BUILDER_INPUT_SHAPE}`;
1212
+ }
1213
+ const required = input.filter((f) => f.name !== "addition" && f.optional === false).map((f) => f.name);
1214
+ if (required.length > 0)
1215
+ return `takes no other required field (${required.join(", ")}): ${BUILDER_INPUT_SHAPE}`;
1216
+ return undefined;
1217
+ }
1174
1218
  function extractTool(tools, key) {
1175
1219
  const name = key.name ?? "";
1176
1220
  const where = `tools.${name}`;
@@ -1216,7 +1260,12 @@ function extractTool(tools, key) {
1216
1260
  else {
1217
1261
  for (const fk of read.keys) {
1218
1262
  if (input.some((f) => f.name === fk.name)) {
1219
- errors.push(duplicateKeyError(TOOLS_LANE, `${where}.input`, fk.name ?? "?", named(read.keys, fk.name ?? "").length));
1263
+ errors.push(duplicateKeyError({
1264
+ lane: TOOLS_LANE,
1265
+ where: `${where}.input`,
1266
+ key: fk.name ?? "?",
1267
+ count: named(read.keys, fk.name ?? "").length,
1268
+ }));
1220
1269
  continue;
1221
1270
  }
1222
1271
  const field = extractToolField(fields, fk, `${where}.input`);
@@ -1260,6 +1309,21 @@ function extractTool(tools, key) {
1260
1309
  else
1261
1310
  textsLater = v;
1262
1311
  }
1312
+ let picturePrompt = false;
1313
+ if (keys.keys.has("picturePrompt")) {
1314
+ const start = keys.keys.get("picturePrompt")?.valueStart;
1315
+ const v = start === undefined ? undefined : literalValue(valueTextAt(tool, start));
1316
+ if (typeof v !== "boolean")
1317
+ errors.push(`${TOOLS_SHAPE} — ${where}.picturePrompt must be true or false`);
1318
+ else if (v && hasWrite)
1319
+ errors.push(`${TOOLS_SHAPE} — ${where}.picturePrompt goes on a handler tool, one that answers the prompt string from { addition }`);
1320
+ else if (v && (offer || textsLater))
1321
+ errors.push(`${TOOLS_SHAPE} — ${where}.picturePrompt goes on its own tool, apart from offer and textsLater: the builder runs on every picture, with no yes asked for`);
1322
+ else if (v && builderInputProblem(input) !== undefined)
1323
+ errors.push(`${TOOLS_SHAPE} — ${where}.picturePrompt ${builderInputProblem(input)}`);
1324
+ else
1325
+ picturePrompt = v;
1326
+ }
1263
1327
  if (errors.length > 0 || description === undefined || run === undefined)
1264
1328
  return { errors };
1265
1329
  return {
@@ -1271,6 +1335,7 @@ function extractTool(tools, key) {
1271
1335
  run,
1272
1336
  ...(offer ? { offer: true } : {}),
1273
1337
  ...(textsLater ? { textsLater: true } : {}),
1338
+ ...(picturePrompt ? { picturePrompt: true } : {}),
1274
1339
  },
1275
1340
  errors,
1276
1341
  };
@@ -1295,7 +1360,12 @@ function extractTools(src) {
1295
1360
  const decls = [];
1296
1361
  for (const key of read.keys) {
1297
1362
  if (decls.some((d) => d.name === key.name)) {
1298
- errors.push(duplicateKeyError(TOOLS_LANE, "the exported tools object", key.name ?? "?", named(read.keys, key.name ?? "").length));
1363
+ errors.push(duplicateKeyError({
1364
+ lane: TOOLS_LANE,
1365
+ where: "the exported tools object",
1366
+ key: key.name ?? "?",
1367
+ count: named(read.keys, key.name ?? "").length,
1368
+ }));
1299
1369
  continue;
1300
1370
  }
1301
1371
  const t = extractTool(tools, key);
@@ -1307,6 +1377,10 @@ function extractTools(src) {
1307
1377
  if (offered.length > 1) {
1308
1378
  errors.push(`${TOOLS_SHAPE} — ${offered.map((d) => `tools.${d.name}`).join(" and ")} both say offer: true; at most one tool may be the offer, the one the agent asks about after posting this vibe's picture`);
1309
1379
  }
1380
+ const builders = decls.filter((d) => d.picturePrompt === true);
1381
+ if (builders.length > 1) {
1382
+ errors.push(`${TOOLS_SHAPE} — ${builders.map((d) => `tools.${d.name}`).join(" and ")} both say picturePrompt: true; at most one tool may build the picture prompt`);
1383
+ }
1310
1384
  if (errors.length > 0)
1311
1385
  return { errors };
1312
1386
  return { value: decls, errors };
@@ -930,7 +930,7 @@ export function transformForHotSwap(src, imports = getActiveImportMap()) {
930
930
  return Result.Err(rTransform.Err());
931
931
  return Result.Ok(rewriteBareSpecifiers(rTransform.Ok().code, imports));
932
932
  }
933
- function buildCompanionBlobGraph(files, baseUrl, mintedBlobUrls, blobMap) {
933
+ function buildCompanionBlobGraph({ files, baseUrl, mintedBlobUrls, blobMap, }) {
934
934
  const authored = [];
935
935
  for (const file of files) {
936
936
  const path = file.path.replace(/^(?:\.?\/)+/, "");
@@ -942,7 +942,7 @@ function buildCompanionBlobGraph(files, baseUrl, mintedBlobUrls, blobMap) {
942
942
  if (ordered === undefined)
943
943
  return Result.Ok(undefined);
944
944
  for (const mod of ordered) {
945
- const rCode = rewriteThenTransform(mod.code, mod.path, blobMap, baseUrl);
945
+ const rCode = rewriteThenTransform({ authoredSource: mod.code, importerPath: mod.path, blobMap, baseUrl });
946
946
  if (rCode.isErr())
947
947
  return Result.Err(rCode.Err());
948
948
  const blob = new Blob([rCode.Ok()], { type: "application/javascript" });
@@ -952,8 +952,8 @@ function buildCompanionBlobGraph(files, baseUrl, mintedBlobUrls, blobMap) {
952
952
  }
953
953
  return Result.Ok(undefined);
954
954
  }
955
- function rewriteThenTransform(authoredSource, importerPath, blobMap, baseUrl) {
956
- return transformForHotSwap(rewriteRelativeSpecifiersWithBlobs(authoredSource, importerPath, blobMap, baseUrl));
955
+ function rewriteThenTransform({ authoredSource, importerPath, blobMap, baseUrl, }) {
956
+ return transformForHotSwap(rewriteRelativeSpecifiersWithBlobs({ code: authoredSource, importerPath, blobMap, baseUrl }));
957
957
  }
958
958
  async function applyHotSwap(args) {
959
959
  const { source, attempt, rollbackToken, files } = args;
@@ -964,14 +964,14 @@ async function applyHotSwap(args) {
964
964
  const mintedBlobUrls = [];
965
965
  const blobMap = new Map();
966
966
  if (files !== undefined && files.length > 0) {
967
- const rGraph = buildCompanionBlobGraph(files, baseUrl, mintedBlobUrls, blobMap);
967
+ const rGraph = buildCompanionBlobGraph({ files, baseUrl, mintedBlobUrls, blobMap });
968
968
  if (rGraph.isErr()) {
969
969
  for (const url of mintedBlobUrls)
970
970
  URL.revokeObjectURL(url);
971
971
  return Result.Err(rGraph.Err());
972
972
  }
973
973
  }
974
- const rResolved = transformForHotSwap(rewriteHotSwapEntrySpecifiers(source, files, blobMap, baseUrl));
974
+ const rResolved = transformForHotSwap(rewriteHotSwapEntrySpecifiers({ code: source, files, blobMap, baseUrl }));
975
975
  if (rResolved.isErr()) {
976
976
  for (const url of mintedBlobUrls)
977
977
  URL.revokeObjectURL(url);
package/render-vibes.js CHANGED
@@ -25,5 +25,5 @@ export function renderVibeToString(comps, iprops) {
25
25
  if (props instanceof type.errors) {
26
26
  throw new Error(`Invalid mount params: ${props.summary}`);
27
27
  }
28
- return renderToString(buildVibeTree(comps, props));
28
+ return renderToString(buildVibeTree({ comps, props }));
29
29
  }
package/resize-image.js CHANGED
@@ -12,9 +12,9 @@ export async function resizeImageToBase64(input, maxDim = 1024, quality = 0.85)
12
12
  const blob = await resolveBlob(input);
13
13
  if (blob === undefined)
14
14
  return Result.Err(new Error(IMG_GEN_SOURCE_UNUSABLE));
15
- return Result.Ok(await blobToDataUrl(await drawJpeg(await createImageBitmap(blob), maxDim, quality)));
15
+ return Result.Ok(await blobToDataUrl(await drawJpeg({ bitmap: await createImageBitmap(blob), maxDim, quality })));
16
16
  }
17
- async function drawJpeg(bitmap, maxDim, quality, background) {
17
+ async function drawJpeg({ bitmap, maxDim, quality, background, }) {
18
18
  const { width, height } = bitmap;
19
19
  const scale = Math.min(1, maxDim / Math.max(width, height));
20
20
  const w = Math.round(width * scale);
@@ -79,7 +79,7 @@ export async function downscaleImageDataUrl(dataUrl, opts = {}) {
79
79
  bitmap.close();
80
80
  return dataUrl;
81
81
  }
82
- const rShrunk = await exception2Result(async () => blobToDataUrl(await drawJpeg(bitmap, maxDim, quality, "#fff")));
82
+ const rShrunk = await exception2Result(async () => blobToDataUrl(await drawJpeg({ bitmap, maxDim, quality, background: "#fff" })));
83
83
  if (rShrunk.isErr()) {
84
84
  console.warn("[vibe.callAI] could not shrink the image; sending it as is:", rShrunk.Err().message);
85
85
  return dataUrl;
@@ -1,4 +1,5 @@
1
1
  export declare const SHORT_LINK_STRIP_PARAMS: ReadonlySet<string>;
2
+ export declare function publicVibeBase(host: string): string | undefined;
2
3
  export declare function shortSelfLinks(text: string, host: string): string;
3
4
  export interface ShortSelfLinkHooks {
4
5
  readonly nav?: Navigator;
@@ -26,6 +26,9 @@ function appOwnedSearch(search) {
26
26
  }
27
27
  const PUBLIC_ORIGIN = "https://vibes.diy";
28
28
  const VIBE_LABEL_RE = /^([a-z0-9][a-z0-9-]*?)--([a-z0-9][a-z0-9-]+)$/i;
29
+ export function publicVibeBase(host) {
30
+ return publicBaseFor(host);
31
+ }
29
32
  function publicBaseFor(host) {
30
33
  const label = host.split(":")[0]?.split(".")[0] ?? "";
31
34
  const m = VIBE_LABEL_RE.exec(label);
package/social/index.js CHANGED
@@ -75,7 +75,7 @@ export function metaContainerNotReady(body) {
75
75
  return true;
76
76
  return (typeof error.message === "string" && /not (?:yet )?(?:ready|available)|being processed|still processing/i.test(error.message));
77
77
  }
78
- async function publishWhenReady(ctx, provider, path, waits) {
78
+ async function publishWhenReady({ ctx, provider, path, waits, }) {
79
79
  for (let attempt = 0;; attempt++) {
80
80
  const res = await ctx.connections.fetch(provider, path, { method: "POST" });
81
81
  if (res.ok)
@@ -147,7 +147,12 @@ export function threads(ctx) {
147
147
  const creationId = str(container.id);
148
148
  if (creationId === "")
149
149
  throw new ProviderResponseError("threads", "/v1.0/me/threads", 502);
150
- const published = await publishWhenReady(ctx, "threads", `/v1.0/me/threads_publish?${new URLSearchParams({ creation_id: creationId })}`, mediaType === "TEXT" ? [] : META_PUBLISH_RETRY_MS);
150
+ const published = await publishWhenReady({
151
+ ctx,
152
+ provider: "threads",
153
+ path: `/v1.0/me/threads_publish?${new URLSearchParams({ creation_id: creationId })}`,
154
+ waits: mediaType === "TEXT" ? [] : META_PUBLISH_RETRY_MS,
155
+ });
151
156
  const id = str(published.id);
152
157
  const permalink = await permalinkFor(() => api.posts({ limit: 5 }), id);
153
158
  return permalink === undefined ? { id } : { id, permalink };
@@ -195,7 +200,12 @@ export function instagram(ctx) {
195
200
  const creationId = str(container.id);
196
201
  if (creationId === "")
197
202
  throw new ProviderResponseError("instagram", "/v23.0/me/media", 502);
198
- const published = await publishWhenReady(ctx, "instagram", `/v23.0/me/media_publish?${new URLSearchParams({ creation_id: creationId })}`, META_PUBLISH_RETRY_MS);
203
+ const published = await publishWhenReady({
204
+ ctx,
205
+ provider: "instagram",
206
+ path: `/v23.0/me/media_publish?${new URLSearchParams({ creation_id: creationId })}`,
207
+ waits: META_PUBLISH_RETRY_MS,
208
+ });
199
209
  const id = str(published.id);
200
210
  const permalink = await permalinkFor(() => api.media({ limit: 5 }), id);
201
211
  return permalink === undefined ? { id } : { id, permalink };
package/sync-engine.js CHANGED
@@ -339,7 +339,12 @@ export class SyncEngine {
339
339
  }
340
340
  if (this.stopped)
341
341
  return;
342
- await this.evictLostChannels(heldBefore, pull.grantedChannels, pull.interestChannels ?? [], identityTrusted);
342
+ await this.evictLostChannels({
343
+ heldBefore,
344
+ grantedChannels: pull.grantedChannels,
345
+ interestChannels: pull.interestChannels ?? [],
346
+ identityTrusted,
347
+ });
343
348
  if (this.stopped)
344
349
  return;
345
350
  }
@@ -358,7 +363,7 @@ export class SyncEngine {
358
363
  this.refreshStatus();
359
364
  }
360
365
  }
361
- async evictLostChannels(heldBefore, grantedChannels, interestChannels, identityTrusted) {
366
+ async evictLostChannels({ heldBefore, grantedChannels, interestChannels, identityTrusted, }) {
362
367
  const granted = new Set(grantedChannels);
363
368
  const interest = new Set(interestChannels);
364
369
  for (const ch of heldBefore) {
@@ -93,9 +93,9 @@ function ensureEphemeralWiring(app, name, store) {
93
93
  ephemeralWiredStores.add(key);
94
94
  const appIdentity = api.svc.vibeApp;
95
95
  store.enableEphemeral((docId, doc) => api.broadcastEphemeral(docId, doc, name));
96
- wireEphemeralInbound(api, appIdentity, name, store);
96
+ wireEphemeralInbound({ api, appIdentity, name, store });
97
97
  }
98
- function getOrCreateMirrorStore(app, name, seedDocs, api) {
98
+ function getOrCreateMirrorStore({ app, name, seedDocs, api, }) {
99
99
  const key = storeCacheKey(app, name);
100
100
  const existing = mirrorStoreCache.get(key);
101
101
  if (existing !== undefined) {
@@ -157,7 +157,7 @@ function getOrCreateFacadeStore({ app, name, seedDocs, captureRender, }) {
157
157
  const api = getRegisteredVibeApi();
158
158
  let store;
159
159
  if (app !== undefined && supportsMirror(api)) {
160
- store = getOrCreateMirrorStore(app, name, seedDocs, api);
160
+ store = getOrCreateMirrorStore({ app, name, seedDocs, api });
161
161
  ensureEphemeralWiring(app, name, store);
162
162
  if (supportsMirrorInterest(api))
163
163
  ensureMirrorInterestBridge(api);
@@ -221,14 +221,14 @@ export function armOnePaint(app, store, name) {
221
221
  };
222
222
  void store.ready().then(() => {
223
223
  clearDeadline();
224
- holdIfCold(app, store, name, deliver, deliverSoon);
224
+ holdIfCold({ app, store, name, deliverSoon });
225
225
  }, (err) => {
226
226
  clearDeadline();
227
227
  deliverSoon(`ready() rejected: ${String(err)}`);
228
228
  });
229
229
  }
230
230
  export const COLD_HOLD_MS = 4_000;
231
- function holdIfCold(app, store, name, deliver, deliverSoon) {
231
+ function holdIfCold({ app, store, name, deliverSoon, }) {
232
232
  const surface = store;
233
233
  const docCount = () => surface.snapshot?.().length ?? 0;
234
234
  let cold = false;
@@ -321,7 +321,7 @@ function useSettled(source) {
321
321
  const getSnapshot = useCallback(() => source.settled(), [source]);
322
322
  return useSyncExternalStore(subscribe, getSnapshot, SSR_SETTLED);
323
323
  }
324
- function wireEphemeralInbound(api, appIdentity, name, store) {
324
+ function wireEphemeralInbound({ api, appIdentity, name, store, }) {
325
325
  api.onMsg((event) => {
326
326
  const data = event.data;
327
327
  if (isEvtDocEphemeral(data) &&
package/vibe-tree.d.ts CHANGED
@@ -5,4 +5,9 @@ export interface HotSwapRollbackMount {
5
5
  readonly onCommit: () => void;
6
6
  readonly onError: (error: unknown, errorInfo: ErrorInfo) => void;
7
7
  }
8
- export declare function buildVibeTree(comps: FunctionComponent[], props: VibeMountParams, hotSwapAttempt?: HotSwapAttempt, hotSwapRollback?: HotSwapRollbackMount): ReactElement;
8
+ export declare function buildVibeTree({ comps, props, hotSwapAttempt, hotSwapRollback, }: {
9
+ comps: FunctionComponent[];
10
+ props: VibeMountParams;
11
+ hotSwapAttempt?: HotSwapAttempt;
12
+ hotSwapRollback?: HotSwapRollbackMount;
13
+ }): ReactElement;
package/vibe-tree.js CHANGED
@@ -41,7 +41,7 @@ class HotSwapErrorBoundary extends Component {
41
41
  return this.props.children;
42
42
  }
43
43
  }
44
- export function buildVibeTree(comps, props, hotSwapAttempt, hotSwapRollback) {
44
+ export function buildVibeTree({ comps, props, hotSwapAttempt, hotSwapRollback, }) {
45
45
  const appChildren = React.createElement(Fragment, null, ...comps.map((Comp, index) => React.createElement(Comp, { key: index })), React.createElement(HotSwapCommitConfirmation, { attempt: hotSwapAttempt, rollback: hotSwapRollback }));
46
46
  const vibeElement = React.createElement(HotSwapErrorBoundary, { attempt: hotSwapAttempt, rollback: hotSwapRollback }, appChildren);
47
47
  return React.createElement(VibeContextProvider, {