vibes-diy 14.3.365 → 14.3.366

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.
@@ -1656,7 +1656,7 @@ function lazyType(build) {
1656
1656
  return d === void 0 ? void 0 : { ...d, configurable: true };
1657
1657
  }, "getOwnPropertyDescriptor"),
1658
1658
  getPrototypeOf: /* @__PURE__ */ __name(() => Reflect.getPrototypeOf(resolve11()), "getPrototypeOf"),
1659
- defineProperty: /* @__PURE__ */ __name((_t, prop, desc60) => Reflect.defineProperty(resolve11(), prop, desc60), "defineProperty"),
1659
+ defineProperty: /* @__PURE__ */ __name((_t, prop, desc61) => Reflect.defineProperty(resolve11(), prop, desc61), "defineProperty"),
1660
1660
  deleteProperty: /* @__PURE__ */ __name((_t, prop) => Reflect.deleteProperty(resolve11(), prop), "deleteProperty")
1661
1661
  });
1662
1662
  }
@@ -2410,7 +2410,7 @@ function lazyType2(build) {
2410
2410
  return d === void 0 ? void 0 : { ...d, configurable: true };
2411
2411
  }, "getOwnPropertyDescriptor"),
2412
2412
  getPrototypeOf: /* @__PURE__ */ __name(() => Reflect.getPrototypeOf(resolve11()), "getPrototypeOf"),
2413
- defineProperty: /* @__PURE__ */ __name((_t, prop, desc60) => Reflect.defineProperty(resolve11(), prop, desc60), "defineProperty"),
2413
+ defineProperty: /* @__PURE__ */ __name((_t, prop, desc61) => Reflect.defineProperty(resolve11(), prop, desc61), "defineProperty"),
2414
2414
  deleteProperty: /* @__PURE__ */ __name((_t, prop) => Reflect.deleteProperty(resolve11(), prop), "deleteProperty")
2415
2415
  });
2416
2416
  }
@@ -27215,7 +27215,6 @@ var init_version_timeline = __esm({
27215
27215
  var POUF_ENTRY_EXPORTS, POUF_TAUGHT_NAMES;
27216
27216
  var init_exports = __esm({
27217
27217
  "../vibes.diy/pouf/exports.ts"() {
27218
- "use strict";
27219
27218
  POUF_ENTRY_EXPORTS = {
27220
27219
  index: [
27221
27220
  "AlertBell",
@@ -32323,8 +32322,8 @@ function isValidName(name) {
32323
32322
  function isValidDuration(durationMs) {
32324
32323
  return Number.isFinite(durationMs) && durationMs >= 0;
32325
32324
  }
32326
- function sanitizeDesc(desc60) {
32327
- const clean2 = desc60.replace(DESC_ALLOWED, "").trim();
32325
+ function sanitizeDesc(desc61) {
32326
+ const clean2 = desc61.replace(DESC_ALLOWED, "").trim();
32328
32327
  return clean2.length > 0 ? clean2 : void 0;
32329
32328
  }
32330
32329
  function serverTimingTotal(startTime, now3 = Date.now) {
@@ -32362,9 +32361,9 @@ var init_request_timings = __esm({
32362
32361
  * non-empty `desc` seen for a name wins, so an accumulating phase keeps its
32363
32362
  * kind.
32364
32363
  */
32365
- record(name, durationMs, desc60) {
32364
+ record(name, durationMs, desc61) {
32366
32365
  if (!isValidName(name) || !isValidDuration(durationMs)) return;
32367
- const cleanDesc = desc60 === void 0 ? void 0 : sanitizeDesc(desc60);
32366
+ const cleanDesc = desc61 === void 0 ? void 0 : sanitizeDesc(desc61);
32368
32367
  const prev = this.phases.get(name);
32369
32368
  if (prev) {
32370
32369
  prev.dur += durationMs;
@@ -32373,12 +32372,12 @@ var init_request_timings = __esm({
32373
32372
  }
32374
32373
  this.phases.set(name, cleanDesc === void 0 ? { dur: durationMs } : { dur: durationMs, desc: cleanDesc });
32375
32374
  }
32376
- async timed(name, desc60, fn) {
32375
+ async timed(name, desc61, fn) {
32377
32376
  const started = this.now();
32378
32377
  try {
32379
32378
  return await fn();
32380
32379
  } finally {
32381
- this.record(name, this.now() - started, desc60);
32380
+ this.record(name, this.now() - started, desc61);
32382
32381
  }
32383
32382
  }
32384
32383
  /** A SERIAL phase: its duration is on the critical path. */
@@ -35952,13 +35951,13 @@ function isReservedChannelId(ch) {
35952
35951
  function presentSubject(s) {
35953
35952
  return s !== void 0 && s.trim().length > 0;
35954
35953
  }
35955
- function stripForeignAudience(desc60, actingHandle) {
35956
- const aud = desc60.audience;
35957
- if (aud === void 0) return desc60;
35954
+ function stripForeignAudience(desc61, actingHandle) {
35955
+ const aud = desc61.audience;
35956
+ if (aud === void 0) return desc61;
35958
35957
  const subjects = [aud.followersOf, aud.mutualsOf].filter(presentSubject);
35959
35958
  const allOwn = actingHandle !== null && subjects.every((s) => s === actingHandle);
35960
- if (allOwn) return desc60;
35961
- return { ...desc60, audience: void 0 };
35959
+ if (allOwn) return desc61;
35960
+ return { ...desc61, audience: void 0 };
35962
35961
  }
35963
35962
  function inheritChannelKey(db, docId) {
35964
35963
  return `${INHERIT_CHANNEL_PREFIX}${JSON.stringify([db, docId])}`;
@@ -35980,31 +35979,31 @@ function hasInheritChannel(channels) {
35980
35979
  function presentInheritRead(ir) {
35981
35980
  return typeof ir === "object" && ir !== null && "db" in ir && "docId" in ir && typeof ir.db === "string" && ir.db.trim().length > 0 && typeof ir.docId === "string" && ir.docId.trim().length > 0;
35982
35981
  }
35983
- function inheritChannelOf(desc60) {
35984
- return presentInheritRead(desc60.inheritRead) ? [inheritChannelKey(desc60.inheritRead.db, desc60.inheritRead.docId)] : [];
35982
+ function inheritChannelOf(desc61) {
35983
+ return presentInheritRead(desc61.inheritRead) ? [inheritChannelKey(desc61.inheritRead.db, desc61.inheritRead.docId)] : [];
35985
35984
  }
35986
- function audienceChannelsOf(desc60) {
35985
+ function audienceChannelsOf(desc61) {
35987
35986
  const out = [];
35988
- if (presentSubject(desc60.audience?.followersOf)) out.push(`~aud:followers:${desc60.audience.followersOf}`);
35989
- if (presentSubject(desc60.audience?.mutualsOf)) out.push(`~aud:mutuals:${desc60.audience.mutualsOf}`);
35987
+ if (presentSubject(desc61.audience?.followersOf)) out.push(`~aud:followers:${desc61.audience.followersOf}`);
35988
+ if (presentSubject(desc61.audience?.mutualsOf)) out.push(`~aud:mutuals:${desc61.audience.mutualsOf}`);
35990
35989
  return out;
35991
35990
  }
35992
- function hasReservedChannel(desc60) {
35993
- if ((desc60.channels ?? []).some(isReservedChannelId)) return true;
35994
- if (desc60.grant === void 0) return false;
35995
- for (const channelIds of Object.values(desc60.grant.users ?? {})) {
35991
+ function hasReservedChannel(desc61) {
35992
+ if ((desc61.channels ?? []).some(isReservedChannelId)) return true;
35993
+ if (desc61.grant === void 0) return false;
35994
+ for (const channelIds of Object.values(desc61.grant.users ?? {})) {
35996
35995
  if (channelIds.some(isReservedChannelId)) return true;
35997
35996
  }
35998
- for (const channelIds of Object.values(desc60.grant.roles ?? {})) {
35997
+ for (const channelIds of Object.values(desc61.grant.roles ?? {})) {
35999
35998
  if (channelIds.some(isReservedChannelId)) return true;
36000
35999
  }
36001
- return (desc60.grant.public ?? []).some(isReservedChannelId);
36000
+ return (desc61.grant.public ?? []).some(isReservedChannelId);
36002
36001
  }
36003
- function hasReservedRoleMint(desc60) {
36004
- return Object.keys(desc60.members ?? {}).some((role) => role.trim().startsWith(RESERVED_CHANNEL_PREFIX));
36002
+ function hasReservedRoleMint(desc61) {
36003
+ return Object.keys(desc61.members ?? {}).some((role) => role.trim().startsWith(RESERVED_CHANNEL_PREFIX));
36005
36004
  }
36006
- function hasReservedPlatformDbRef(desc60) {
36007
- return presentInheritRead(desc60.inheritRead) && isPlatformDbName(desc60.inheritRead.db.trim());
36005
+ function hasReservedPlatformDbRef(desc61) {
36006
+ return presentInheritRead(desc61.inheritRead) && isPlatformDbName(desc61.inheritRead.db.trim());
36008
36007
  }
36009
36008
  function audienceSubjectFromChannel(ch) {
36010
36009
  if (ch.startsWith(AUD_FOLLOWERS_PREFIX)) return ch.slice(AUD_FOLLOWERS_PREFIX.length);
@@ -37791,17 +37790,17 @@ async function fnGrantStateHandles(vctx, input) {
37791
37790
  for (const row of rows) {
37792
37791
  const rDesc = exception2Result34(() => JSON.parse(row.output));
37793
37792
  if (rDesc.isErr()) continue;
37794
- const desc60 = rDesc.Ok();
37795
- for (const h of canonicalDescriptorHandles(desc60)) out.add(h);
37793
+ const desc61 = rDesc.Ok();
37794
+ for (const h of canonicalDescriptorHandles(desc61)) out.add(h);
37796
37795
  }
37797
37796
  return out;
37798
37797
  }
37799
37798
  function isPlainObject2(v) {
37800
37799
  return typeof v === "object" && v !== null && !Array.isArray(v);
37801
37800
  }
37802
- function canonicalDescriptorHandles(desc60) {
37801
+ function canonicalDescriptorHandles(desc61) {
37803
37802
  const out = [];
37804
- const members = desc60.members;
37803
+ const members = desc61.members;
37805
37804
  if (isPlainObject2(members)) {
37806
37805
  for (const users2 of Object.values(members)) {
37807
37806
  if (!Array.isArray(users2)) continue;
@@ -37810,7 +37809,7 @@ function canonicalDescriptorHandles(desc60) {
37810
37809
  }
37811
37810
  }
37812
37811
  }
37813
- const users = desc60.grant?.users;
37812
+ const users = desc61.grant?.users;
37814
37813
  if (isPlainObject2(users)) {
37815
37814
  for (const h of Object.keys(users)) out.push(h);
37816
37815
  }
@@ -45310,27 +45309,27 @@ var init_ensure_app_settings = __esm({
45310
45309
  function hasContent(c) {
45311
45310
  return c.members.size > 0 || c.grantRoles.size > 0 || c.grantUsers.size > 0 || c.grantPublic.size > 0;
45312
45311
  }
45313
- function extractContribution(desc60) {
45312
+ function extractContribution(desc61) {
45314
45313
  const members = /* @__PURE__ */ new Map();
45315
- if (desc60.members) {
45316
- for (const [role, users] of Object.entries(desc60.members)) {
45314
+ if (desc61.members) {
45315
+ for (const [role, users] of Object.entries(desc61.members)) {
45317
45316
  if (role.trim().startsWith(RESERVED_ROLE_PREFIX)) continue;
45318
45317
  members.set(role, new Set(users));
45319
45318
  }
45320
45319
  }
45321
45320
  const grantRoles = /* @__PURE__ */ new Map();
45322
- if (desc60.grant?.roles) {
45323
- for (const [role, channels] of Object.entries(desc60.grant.roles)) {
45321
+ if (desc61.grant?.roles) {
45322
+ for (const [role, channels] of Object.entries(desc61.grant.roles)) {
45324
45323
  grantRoles.set(role, new Set(channels));
45325
45324
  }
45326
45325
  }
45327
45326
  const grantUsers = /* @__PURE__ */ new Map();
45328
- if (desc60.grant?.users) {
45329
- for (const [user, channels] of Object.entries(desc60.grant.users)) {
45327
+ if (desc61.grant?.users) {
45328
+ for (const [user, channels] of Object.entries(desc61.grant.users)) {
45330
45329
  grantUsers.set(user, new Set(channels));
45331
45330
  }
45332
45331
  }
45333
- const grantPublic = new Set(desc60.grant?.public ?? []);
45332
+ const grantPublic = new Set(desc61.grant?.public ?? []);
45334
45333
  return { members, grantRoles, grantUsers, grantPublic };
45335
45334
  }
45336
45335
  function seedOwnerGrants(reduce, ownerHandle, devHandles = []) {
@@ -107052,7 +107051,7 @@ var init_vibe_tool_offer = __esm({
107052
107051
  // ../vibes.diy/api/svc/intern/agent-make-picture-tool.ts
107053
107052
  import { Result as Result146, exception2Result as exception2Result209, stream2uint8array as stream2uint8array9 } from "@adviser/cement";
107054
107053
  import { type as type141 } from "arktype";
107055
- import { and as and115, eq as eq135, like as like5 } from "drizzle-orm";
107054
+ import { and as and115, desc as desc26, eq as eq135, like as like5 } from "drizzle-orm";
107056
107055
  function makePictureToolDefinition() {
107057
107056
  return {
107058
107057
  type: "function",
@@ -107086,7 +107085,7 @@ function makePictureToolDefinition() {
107086
107085
  },
107087
107086
  vibe: {
107088
107087
  type: "object",
107089
- description: "Also save it as this record's picture, in a vibe this conversation may add records to (its own, or one they linked).",
107088
+ description: "Also save it as this record's picture, in a vibe this conversation may add records to (its own, or one they linked). A picture app named by its owner and appSlug alone (no dbName) goes through its own newest record with a prompt: make_picture copies it, keeps the photo where that record keeps its own, and answers `record` with what it used.",
107090
107089
  properties: {
107091
107090
  ownerHandle: { type: "string" },
107092
107091
  appSlug: { type: "string" },
@@ -107098,10 +107097,14 @@ function makePictureToolDefinition() {
107098
107097
  },
107099
107098
  record: {
107100
107099
  type: "object",
107101
- description: "The record's own fields, in the shape the app's records have (its authorHandle the `writesAs` handle list_databases names, its prompt set the way theirs are). Saved through the app's rules before the paint, so no put_doc is needed first."
107100
+ description: "The record's own fields, in the shape the app's records have (its authorHandle the `writesAs` handle list_databases names, its prompt set the way theirs are). Saved through the app's rules before the paint, so no put_doc is needed first. With `like`, only the fields that differ from that record."
107101
+ },
107102
+ like: {
107103
+ type: "string",
107104
+ description: "The _id of one of the app's own records in this database (a list_databases sample's _id): the new record starts as a copy of its fields (its prompt included), written as you, with the time set to now. `record` changes any of them."
107102
107105
  }
107103
107106
  },
107104
- required: ["ownerHandle", "appSlug", "dbName", "docId"],
107107
+ required: ["ownerHandle", "appSlug"],
107105
107108
  additionalProperties: false
107106
107109
  }
107107
107110
  },
@@ -107110,6 +107113,49 @@ function makePictureToolDefinition() {
107110
107113
  }
107111
107114
  };
107112
107115
  }
107116
+ function likeTemplate(doc, writerHandle, nowMs) {
107117
+ const { _id, _files, ...fields } = doc;
107118
+ const out = { ...fields };
107119
+ if ("authorHandle" in out) out["authorHandle"] = writerHandle;
107120
+ for (const k of ["createdAt", "updatedAt", "created", "updated"]) {
107121
+ const v = out[k];
107122
+ if (typeof v === "number") out[k] = nowMs;
107123
+ else if (typeof v === "string" && !Number.isNaN(Date.parse(v))) out[k] = new Date(nowMs).toISOString();
107124
+ }
107125
+ return out;
107126
+ }
107127
+ async function findPictureTemplate(vctx, o) {
107128
+ const ad = vctx.sql.tables.appDocuments;
107129
+ const rRows = await exception2Result209(
107130
+ () => vctx.sql.db.select({ dbName: ad.dbName, docId: ad.docId, seq: ad.seq }).from(ad).where(and115(eq135(ad.ownerHandle, o.ownerHandle), eq135(ad.appSlug, o.appSlug))).orderBy(desc26(ad.created), desc26(ad.seq)).limit(TEMPLATE_SCAN_ROWS)
107131
+ );
107132
+ if (rRows.isErr()) return Result146.Err("That app's records could not be read just now. Try once more.");
107133
+ const seen = /* @__PURE__ */ new Set();
107134
+ for (const row of rRows.Ok()) {
107135
+ const key = `${row.dbName}\0${row.docId}`;
107136
+ if (seen.has(key) || row.dbName.startsWith("_") || row.dbName.startsWith("media:")) continue;
107137
+ seen.add(key);
107138
+ const rDoc = await exception2Result209(
107139
+ () => getDocForCaller(vctx, {
107140
+ userId: o.writer.userId,
107141
+ ownerHandle: o.ownerHandle,
107142
+ appSlug: o.appSlug,
107143
+ dbName: row.dbName,
107144
+ docId: row.docId,
107145
+ adminMode: false,
107146
+ actingHandle: o.writer.ownerHandle
107147
+ })
107148
+ );
107149
+ if (rDoc.isErr() || rDoc.Ok().kind !== "ok") continue;
107150
+ const doc = rDoc.Ok().doc;
107151
+ if (typeof doc["prompt"] !== "string" || doc["prompt"].trim() === "") continue;
107152
+ const files = typeof doc["_files"] === "object" && doc["_files"] !== null ? Object.keys(doc["_files"]) : [];
107153
+ const photoKey = files.includes("original") ? "original" : files.length === 1 ? files[0] : void 0;
107154
+ const idPrefix = /^([a-z][a-z0-9]*-)/i.exec(row.docId)?.[1] ?? "picture-";
107155
+ return Result146.Ok({ dbName: row.dbName, docId: row.docId, idPrefix, ...photoKey === void 0 ? {} : { photoKey } });
107156
+ }
107157
+ return Result146.Err("That app has no record with a prompt to copy yet. Read it with with_vibe list_databases and name the record.");
107158
+ }
107113
107159
  function refusal(reason, message3) {
107114
107160
  return { ok: false, reason, message: message3 };
107115
107161
  }
@@ -107387,23 +107433,36 @@ async function keepPhotoOnRecord(vctx, mctx, o) {
107387
107433
  }
107388
107434
  async function makePicture(vctx, mctx, args) {
107389
107435
  let prompt = args.prompt;
107390
- const vibe2 = args.vibe === void 0 ? void 0 : {
107391
- ownerHandle: normalHandle(args.vibe.ownerHandle),
107392
- appSlug: args.vibe.appSlug.trim().toLowerCase(),
107393
- dbName: args.vibe.dbName,
107394
- docId: args.vibe.docId
107395
- };
107396
- if (vibe2 !== void 0 && vibe2.appSlug === AGENT_CHAT_APP_SLUG) {
107436
+ const target2 = args.vibe === void 0 ? void 0 : { ownerHandle: normalHandle(args.vibe.ownerHandle), appSlug: args.vibe.appSlug.trim().toLowerCase() };
107437
+ if (target2 !== void 0 && target2.appSlug === AGENT_CHAT_APP_SLUG) {
107397
107438
  return refusal("not-yours", "A conversation's own space is not a vibe. Leave out `vibe` to put the picture in the chat.");
107398
107439
  }
107399
107440
  let writer = { userId: mctx.actor.userId, ownerHandle: mctx.actor.ownerHandle };
107400
- if (vibe2 !== void 0) {
107401
- const resolved = await vibeWriter(vctx, mctx.actor, vibe2);
107441
+ if (target2 !== void 0) {
107442
+ const resolved = await vibeWriter(vctx, mctx.actor, target2);
107402
107443
  if (resolved.ok === false) return resolved;
107403
107444
  writer = resolved.writer;
107404
107445
  }
107405
- if (vibe2 !== void 0 && args.vibe?.record !== void 0) {
107406
- const { _id: _ignoredId, _files: _ignoredFiles, ...fields } = args.vibe.record;
107446
+ let found;
107447
+ if (target2 !== void 0 && args.vibe !== void 0 && args.vibe.dbName === void 0) {
107448
+ const rFound = await findPictureTemplate(vctx, { ...target2, writer });
107449
+ if (rFound.isErr()) return refusal("not-found", rFound.Err().message);
107450
+ const t = rFound.Ok();
107451
+ const photoKey = args.vibe.photoKey ?? t.photoKey;
107452
+ found = {
107453
+ dbName: t.dbName,
107454
+ docId: args.vibe.docId ?? `${t.idPrefix}${crypto.randomUUID()}`,
107455
+ like: args.vibe.like ?? t.docId,
107456
+ ...photoKey === void 0 ? {} : { photoKey }
107457
+ };
107458
+ args = { ...args, vibe: { ...args.vibe, ...found } };
107459
+ }
107460
+ if (args.vibe !== void 0 && args.vibe.docId === void 0) {
107461
+ return refusal("invalid-input", "`vibe` names its record with `docId` when it names `dbName`.");
107462
+ }
107463
+ const vibe2 = target2 === void 0 || args.vibe?.dbName === void 0 || args.vibe.docId === void 0 ? void 0 : { ...target2, dbName: args.vibe.dbName, docId: args.vibe.docId };
107464
+ if (vibe2 !== void 0 && (args.vibe?.record !== void 0 || args.vibe?.like !== void 0)) {
107465
+ const { _id: _ignoredId, _files: _ignoredFiles, ...given } = args.vibe.record ?? {};
107407
107466
  const at2 = {
107408
107467
  userId: writer.userId,
107409
107468
  ownerHandle: vibe2.ownerHandle,
@@ -107415,6 +107474,14 @@ async function makePicture(vctx, mctx, args) {
107415
107474
  const rHad = await exception2Result209(() => getDocForCaller(vctx, { ...at2, docId: vibe2.docId }));
107416
107475
  if (rHad.isErr()) return refusal("failed", "That record could not be read just now. Try once more.");
107417
107476
  const had = rHad.Ok().kind === "ok" ? rHad.Ok().doc : {};
107477
+ let liked = {};
107478
+ if (args.vibe.like !== void 0) {
107479
+ const rLike = await exception2Result209(() => getDocForCaller(vctx, { ...at2, docId: args.vibe?.like ?? "" }));
107480
+ if (rLike.isErr()) return refusal("failed", "That record to copy could not be read just now. Try once more.");
107481
+ if (rLike.Ok().kind !== "ok") return refusal("not-found", "No record with that `like` id in this database.");
107482
+ liked = likeTemplate(rLike.Ok().doc, writer.ownerHandle, Date.now());
107483
+ }
107484
+ const fields = { ...liked, ...given };
107418
107485
  await reserveImgGenForAgent(vctx, {
107419
107486
  ownerHandle: vibe2.ownerHandle,
107420
107487
  appSlug: vibe2.appSlug,
@@ -107641,7 +107708,8 @@ async function makePicture(vctx, mctx, args) {
107641
107708
  docId: version.docId
107642
107709
  },
107643
107710
  link: `/vibe/${vibe2.ownerHandle}/${vibe2.appSlug}`,
107644
- made: { prompt, model: painted2.model }
107711
+ made: { prompt, model: painted2.model },
107712
+ ...found === void 0 ? {} : { record: found }
107645
107713
  };
107646
107714
  }
107647
107715
  vctx.logger.Warn().Str("chatId", mctx.chatId).Bool("written", written !== false).Msg("make_picture: vibe did not take it, kept in ~agent");
@@ -107746,7 +107814,7 @@ function createMakePictureTool(vctx, deps) {
107746
107814
  function answer4(o) {
107747
107815
  return Result146.Ok(JSON.stringify(o));
107748
107816
  }
107749
- var AGENT_PICTURES_DB_NAME, MAKE_PICTURE_PROMPT_MAX, INPUT_IMAGE_EDGE, MAKE_PICTURE_DEADLINE_MS, recordRef, makePictureInput;
107817
+ var AGENT_PICTURES_DB_NAME, MAKE_PICTURE_PROMPT_MAX, INPUT_IMAGE_EDGE, MAKE_PICTURE_DEADLINE_MS, recordRef, makePictureInput, TEMPLATE_SCAN_ROWS;
107750
107818
  var init_agent_make_picture_tool = __esm({
107751
107819
  "../vibes.diy/api/svc/intern/agent-make-picture-tool.ts"() {
107752
107820
  "use strict";
@@ -107789,10 +107857,21 @@ var init_agent_make_picture_tool = __esm({
107789
107857
  "photo?": "number.integer >= 1",
107790
107858
  "earlierPhoto?": "number.integer >= 1",
107791
107859
  "sourceRecord?": type141({ ...recordRef, "fileKey?": "string" }).onUndeclaredKey("reject"),
107792
- "vibe?": type141({ ...recordRef, "photoKey?": "string > 0", "record?": "Record<string, unknown>" }).onUndeclaredKey("reject")
107860
+ "vibe?": type141({
107861
+ ownerHandle: "string > 0",
107862
+ appSlug: "string > 0",
107863
+ "dbName?": "string > 0",
107864
+ "docId?": "string > 0",
107865
+ "photoKey?": "string > 0",
107866
+ "record?": "Record<string, unknown>",
107867
+ "like?": "string > 0"
107868
+ }).onUndeclaredKey("reject")
107793
107869
  }).onUndeclaredKey("reject")
107794
107870
  );
107795
107871
  __name(makePictureToolDefinition, "makePictureToolDefinition");
107872
+ __name(likeTemplate, "likeTemplate");
107873
+ TEMPLATE_SCAN_ROWS = 60;
107874
+ __name(findPictureTemplate, "findPictureTemplate");
107796
107875
  __name(refusal, "refusal");
107797
107876
  __name(checkMakePictureArgs, "checkMakePictureArgs");
107798
107877
  __name(normalHandle, "normalHandle");
@@ -115831,7 +115910,7 @@ var init_push_mint_look = __esm({
115831
115910
 
115832
115911
  // ../vibes.diy/api/svc/intern/push-skin-look.ts
115833
115912
  import { exception2Result as exception2Result232 } from "@adviser/cement";
115834
- import { and as and121, desc as desc26, eq as eq142, lt as lt11 } from "drizzle-orm";
115913
+ import { and as and121, desc as desc27, eq as eq142, lt as lt11 } from "drizzle-orm";
115835
115914
  async function planPushSkinLook(vctx, args) {
115836
115915
  const skins = sourceSkinLooks(args.sources).map((p) => p.id);
115837
115916
  if (skins.length === 0) return void 0;
@@ -115871,7 +115950,7 @@ async function missedSkinLook(vctx, args) {
115871
115950
  eq142(vctx.sql.tables.apps.mode, "production"),
115872
115951
  lt11(vctx.sql.tables.apps.releaseSeq, args.previous.releaseSeq)
115873
115952
  )
115874
- ).orderBy(desc26(vctx.sql.tables.apps.releaseSeq)).limit(1).then((r) => r[0]);
115953
+ ).orderBy(desc27(vctx.sql.tables.apps.releaseSeq)).limit(1).then((r) => r[0]);
115875
115954
  if (before === void 0) return void 0;
115876
115955
  const inBefore = sourceSkinLooks(await releaseSources(vctx, before.fsId)).map((p) => p.id);
115877
115956
  return candidates.find((p) => inBefore.includes(p.id) === false);
@@ -115911,7 +115990,7 @@ var init_push_skin_look = __esm({
115911
115990
  // ../vibes.diy/api/svc/intern/seed-starter-chips.ts
115912
115991
  import { exception2Result as exception2Result233, Result as Result164 } from "@adviser/cement";
115913
115992
  import { and as and122, eq as eq143 } from "drizzle-orm/sql/expressions";
115914
- import { desc as desc27 } from "drizzle-orm";
115993
+ import { desc as desc28 } from "drizzle-orm";
115915
115994
  function buildStarterChipSeedBlocks(opts) {
115916
115995
  const now3 = opts.timestamp ?? /* @__PURE__ */ new Date();
115917
115996
  const base = { blockId: opts.blockId, streamId: opts.streamId, blockNr: 0, timestamp: now3 };
@@ -115956,7 +116035,7 @@ async function seedStarterChips(vctx, opts) {
115956
116035
  if (opts.chips.length === 0) return Result164.Err("seedStarterChips: no chips to seed");
115957
116036
  const ctxRows = await vctx.sql.db.select({ chatId: vctx.sql.tables.chatContexts.chatId }).from(vctx.sql.tables.chatContexts).where(
115958
116037
  and122(eq143(vctx.sql.tables.chatContexts.ownerHandle, opts.ownerHandle), eq143(vctx.sql.tables.chatContexts.appSlug, opts.appSlug))
115959
- ).orderBy(desc27(vctx.sql.tables.chatContexts.created)).limit(1);
116038
+ ).orderBy(desc28(vctx.sql.tables.chatContexts.created)).limit(1);
115960
116039
  const chatId = ctxRows[0]?.chatId;
115961
116040
  if (!chatId) {
115962
116041
  return Result164.Err(`seedStarterChips: no chat context for ${opts.ownerHandle}/${opts.appSlug} (push the vibe first)`);
@@ -118318,7 +118397,7 @@ var init_agent_discussions = __esm({
118318
118397
  });
118319
118398
 
118320
118399
  // ../vibes.diy/api/svc/intern/ensure-chat-id.ts
118321
- import { and as and131, desc as desc28, eq as eq153 } from "drizzle-orm/sql/expressions";
118400
+ import { and as and131, desc as desc29, eq as eq153 } from "drizzle-orm/sql/expressions";
118322
118401
  import { exception2Result as exception2Result244, Result as Result171 } from "@adviser/cement";
118323
118402
  import { sha256 as sha25611 } from "@noble/hashes/sha2.js";
118324
118403
  import { bytesToHex as bytesToHex5, utf8ToBytes as utf8ToBytes7 } from "@noble/hashes/utils.js";
@@ -118355,7 +118434,7 @@ async function dryRunResolveChatId(ctx, req2) {
118355
118434
  ownerHandle = defaultBinding.ownerHandle;
118356
118435
  } else {
118357
118436
  const rFirst = await exception2Result244(
118358
- () => ctx.sql.db.select({ handle: ctx.sql.tables.handleBinding.handle }).from(ctx.sql.tables.handleBinding).where(eq153(ctx.sql.tables.handleBinding.userId, userId)).orderBy(desc28(ctx.sql.tables.handleBinding.created)).limit(1).then((r) => r[0])
118437
+ () => ctx.sql.db.select({ handle: ctx.sql.tables.handleBinding.handle }).from(ctx.sql.tables.handleBinding).where(eq153(ctx.sql.tables.handleBinding.userId, userId)).orderBy(desc29(ctx.sql.tables.handleBinding.created)).limit(1).then((r) => r[0])
118359
118438
  );
118360
118439
  ownerHandle = rFirst.isOk() && rFirst.Ok() ? rFirst.Ok().handle : DRY_RUN_PLACEHOLDER_HANDLE;
118361
118440
  }
@@ -119079,13 +119158,13 @@ var init_turn_initiator = __esm({
119079
119158
  });
119080
119159
 
119081
119160
  // ../vibes.diy/api/svc/intern/chat-history-page.ts
119082
- import { and as and132, desc as desc29, eq as eq155, inArray as inArray42, isNotNull as isNotNull6, lt as lt12, ne as ne19, or as or15, sql as sql26 } from "drizzle-orm";
119161
+ import { and as and132, desc as desc30, eq as eq155, inArray as inArray42, isNotNull as isNotNull6, lt as lt12, ne as ne19, or as or15, sql as sql26 } from "drizzle-orm";
119083
119162
  async function selectChatHistoryPage(vctx, args) {
119084
119163
  const t = vctx.sql.tables.chatSections;
119085
119164
  const created = sql26`min(${t.created})`;
119086
119165
  const rows = await vctx.sql.db.select({ promptId: t.promptId, created }).from(t).where(and132(eq155(t.chatId, args.chatId), ne19(t.blockSeq, RESEARCH_BLOCK_SEQ))).groupBy(t.promptId).having(
119087
119166
  args.before === void 0 ? void 0 : or15(lt12(created, args.before.created), and132(eq155(created, args.before.created), lt12(t.promptId, args.before.promptId)))
119088
- ).orderBy(desc29(created), desc29(t.promptId)).limit(args.limit + 1);
119167
+ ).orderBy(desc30(created), desc30(t.promptId)).limit(args.limit + 1);
119089
119168
  const page = rows.slice(0, args.limit);
119090
119169
  const before = page.at(-1);
119091
119170
  return {
@@ -119098,7 +119177,7 @@ async function initialChatHistoryPage(vctx, args) {
119098
119177
  const t = vctx.sql.tables;
119099
119178
  const [active, latestBuild] = await Promise.all([
119100
119179
  vctx.sql.db.select({ promptId: t.openTurns.promptId }).from(t.openTurns).where(and132(eq155(t.openTurns.chatId, args.chatId), eq155(t.openTurns.status, "open"))),
119101
- vctx.sql.db.select({ promptId: t.promptContexts.promptId }).from(t.promptContexts).where(and132(eq155(t.promptContexts.chatId, args.chatId), isNotNull6(t.promptContexts.fsId), ne19(t.promptContexts.fsId, ""))).orderBy(desc29(t.promptContexts.created), desc29(t.promptContexts.promptId)).limit(1)
119180
+ vctx.sql.db.select({ promptId: t.promptContexts.promptId }).from(t.promptContexts).where(and132(eq155(t.promptContexts.chatId, args.chatId), isNotNull6(t.promptContexts.fsId), ne19(t.promptContexts.fsId, ""))).orderBy(desc30(t.promptContexts.created), desc30(t.promptContexts.promptId)).limit(1)
119102
119181
  ]);
119103
119182
  return {
119104
119183
  history: page.history,
@@ -120094,7 +120173,7 @@ var init_manifest_assets_line = __esm({
120094
120173
  // ../vibes.diy/api/svc/intern/load-research-context.ts
120095
120174
  import { exception2Result as exception2Result248 } from "@adviser/cement";
120096
120175
  import { type as type153 } from "arktype";
120097
- import { desc as desc30, and as and135, eq as eq159 } from "drizzle-orm/sql/expressions";
120176
+ import { desc as desc31, and as and135, eq as eq159 } from "drizzle-orm/sql/expressions";
120098
120177
  function escapeResearchDelimiters(value) {
120099
120178
  return value.replaceAll(RESEARCH_CONTEXT_OPEN_DELIMITER, "[escaped web delimiter]").replaceAll(RESEARCH_CONTEXT_CLOSE_DELIMITER, "[escaped web delimiter]");
120100
120179
  }
@@ -120184,7 +120263,7 @@ async function loadResearchContextMessages(vctx, args) {
120184
120263
  return exception2Result248(async () => {
120185
120264
  const t = vctx.sql.tables.chatSections;
120186
120265
  const chats = vctx.sql.tables.chatContexts;
120187
- const rows = await vctx.sql.db.select({ blocks: t.blocks, promptId: t.promptId }).from(chats).innerJoin(t, eq159(t.chatId, chats.chatId)).where(and135(eq159(chats.userId, args.userId), eq159(chats.chatId, args.chatId), eq159(t.blockSeq, RESEARCH_BLOCK_SEQ))).orderBy(desc30(t.created), desc30(t.promptId));
120266
+ const rows = await vctx.sql.db.select({ blocks: t.blocks, promptId: t.promptId }).from(chats).innerJoin(t, eq159(t.chatId, chats.chatId)).where(and135(eq159(chats.userId, args.userId), eq159(chats.chatId, args.chatId), eq159(t.blockSeq, RESEARCH_BLOCK_SEQ))).orderBy(desc31(t.created), desc31(t.promptId));
120188
120267
  const seenResearchIds = /* @__PURE__ */ new Set();
120189
120268
  const selected = [];
120190
120269
  for (const row of rows) {
@@ -128067,7 +128146,7 @@ var init_agent_file_rebase = __esm({
128067
128146
 
128068
128147
  // ../vibes.diy/api/svc/public/fs-prompt.ts
128069
128148
  import { Result as Result197 } from "@adviser/cement";
128070
- import { and as and143, desc as desc31, eq as eq168 } from "drizzle-orm/sql/expressions";
128149
+ import { and as and143, desc as desc32, eq as eq168 } from "drizzle-orm/sql/expressions";
128071
128150
  async function handleFSPrompt({
128072
128151
  scope: scope2,
128073
128152
  vctx,
@@ -128094,13 +128173,13 @@ async function handleFSPrompt({
128094
128173
  eq168(vctx.sql.tables.apps.ownerHandle, resChat.ownerHandle),
128095
128174
  eq168(vctx.sql.tables.apps.appSlug, resChat.appSlug)
128096
128175
  )
128097
- ).orderBy(desc31(vctx.sql.tables.apps.releaseSeq)).limit(1).then((r) => r[0]);
128176
+ ).orderBy(desc32(vctx.sql.tables.apps.releaseSeq)).limit(1).then((r) => r[0]);
128098
128177
  if (!refApp) {
128099
128178
  throw new Error(`fs-update refFsId ${req2.refFsId} is not a release of ${resChat.ownerHandle}/${resChat.appSlug}`);
128100
128179
  }
128101
128180
  baseItems = refApp.fileSystem;
128102
128181
  } else {
128103
- const lastestPrompt = await vctx.sql.db.select().from(vctx.sql.tables.promptContexts).innerJoin(vctx.sql.tables.apps, eq168(vctx.sql.tables.apps.fsId, vctx.sql.tables.promptContexts.fsId)).where(eq168(vctx.sql.tables.promptContexts.chatId, req2.chatId)).orderBy(desc31(vctx.sql.tables.promptContexts.created)).limit(1).then((r) => r[0]);
128182
+ const lastestPrompt = await vctx.sql.db.select().from(vctx.sql.tables.promptContexts).innerJoin(vctx.sql.tables.apps, eq168(vctx.sql.tables.apps.fsId, vctx.sql.tables.promptContexts.fsId)).where(eq168(vctx.sql.tables.promptContexts.chatId, req2.chatId)).orderBy(desc32(vctx.sql.tables.promptContexts.created)).limit(1).then((r) => r[0]);
128104
128183
  baseItems = lastestPrompt?.Apps.fileSystem;
128105
128184
  const liveRelease = await selectLatestAppPerSlug(vctx, {
128106
128185
  ownerHandle: resChat.ownerHandle,
@@ -129246,7 +129325,7 @@ var init_agent_imessage_tools = __esm({
129246
129325
 
129247
129326
  // ../vibes.diy/api/svc/intern/operator-hotfix.ts
129248
129327
  import { exception2Result as exception2Result274 } from "@adviser/cement";
129249
- import { and as and146, desc as desc32, eq as eq171 } from "drizzle-orm/sql/expressions";
129328
+ import { and as and146, desc as desc33, eq as eq171 } from "drizzle-orm/sql/expressions";
129250
129329
  function hotfixRulesOf(data) {
129251
129330
  if (typeof data !== "object" || data === null) return [];
129252
129331
  const d = data;
@@ -129263,7 +129342,7 @@ async function readFresh(vctx) {
129263
129342
  eq171(t.dbName, HOTFIX_ADDRESS.dbName),
129264
129343
  eq171(t.docId, HOTFIX_ADDRESS.docId)
129265
129344
  )
129266
- ).orderBy(desc32(t.seq)).limit(1).then((r) => r[0]);
129345
+ ).orderBy(desc33(t.seq)).limit(1).then((r) => r[0]);
129267
129346
  if (row === void 0 || row.deleted === 1) return [];
129268
129347
  const rules = hotfixRulesOf(typeof row.data === "string" ? JSON.parse(row.data) : row.data);
129269
129348
  if (rules.length === 0) return [];
@@ -129505,7 +129584,7 @@ A TEXT CONVERSATION. This conversation is a text thread. The person may be readi
129505
129584
  - Say it, then do it. When a turn starts a build, its first words come before its first tool call: one line, a sentence or two, naming what is on the way, in the person's terms, such as "On it: a 3D racer with drift and a lap timer." or "On it: your own copy of Cabin Weekend, a cost splitter." Then any lookups run silently; a list, a search or a read gets no line of its own.
129506
129585
  - One message, sometimes in two texts. Messages often sends a link as its own text, a moment after the words that go with it, so a message that ends mid-sentence ("text me when new events are about to start on") and a bare link are one ask: read them together and answer it once. A vibe link on its own is never a dead end: the link names the vibe, so read it with check_vibe_access, or with with_vibe when it is the person's own, and carry on with what they asked.
129507
129586
  - One thought, several texts. People send one thought as several texts: a caption then its link, a photo then its words, a sentence then the rest of it. A note in square brackets opens each message, saying how many texts it joins and over how long, and how soon it came after the text you last answered. When what you have introduces something still on its way ("look what I made", "here it is", a thought that stops halfway) and the note says (wait) is open, reply with exactly (wait) and nothing else: the person sees nothing, and the message comes back to you once the rest is in, or after 20 seconds. Wait once per message at most. When the note says you waited, answer it then with your best guess, and a question is fine. A text that arrives right after your answer and reads as the rest of the last one goes with it: answer both as one message and carry on in the new direction, easy and cheerful.
129508
- - Pictures travel both ways. A photo the person sends is in front of you. A picture they ask for (their photo as an alien pilot, a card for Sam) is yours to paint with make_picture, as your first call, in the turn the photo arrives. \`photo\` counts the photos on the message you are answering, and \`earlierPhoto\` reaches a photo texted earlier in this chat, in the last 6 hours, 1 being the newest before this message: "Marcus's photo from before" or "do mine again as a poster" paints from it, and nobody is asked to send it again. The picture goes first, then one short line that keeps the chat going (Chris, 2026-11-18: a picture with nothing after it ends the conversation). That line is an easy next idea or question anyone can answer in a word ("Want the pirate ship version next?", "Should I do everyone?"), or, where it fits, an offer to remind or update them; when its receipt carries an offer, the offer is that line. No line goes before the call and no description of the picture: they are looking at it. When a tool failed, the line says that instead. Paint once per ask. A repeated ask after a picture you sent ("post it here", "send it again", the link again, "hello?") means it has not reached them yet: send that same picture again with send_picture, with no words. A picture travels only as a picture, so a picture's file address (an assets. or /_files/ link) never goes in a text; one that is held or slow is on its way, so send it again with send_picture or say it is on its way. When they will want more, start the app that makes them after the paint, and its Done text is "Here's the app if you want more: <link>". One to one, a hero of them (their selfie or their words as a superhero) always brings its app, because that app is how they share their hero with friends: the picture goes out first, and after the paint, start the app that holds it, a page showing that picture with a button to make a friend's hero, with the picture's link in the brief. Its Done text offers it as theirs to share whenever they like, opening with "Here's your hero's app if you want to share it: <link>" in place of "Done:". A hero is the one picture with words before it. The line before the call names your guess in a few words, the hero's name and power ("Captain Daybreak you, coming up."). A photo that never reached you ("did you get my pic?") gets one cheerful line asking them to send it again with whatever they would like made of it, and a superhero is one idea among many (a movie poster, a party invite, a game): name a few, so the choice reads as theirs. A vibe named for pictures is this chat's picture app. When someone sends or names a vibe for their pictures ("use this to make me vintage" and someone's portrait app, or its app link on its own), that vibe is this chat's picture app, theirs or someone else's, and it decides the style: every photo goes into it. Learn its shape from one with_vibe list_databases call (its \`samples\` holds a record of each collection; query_docs only when that is not enough), then call make_picture with photo (or earlierPhoto) and \`vibe\` naming their new record, its fields in \`vibe.record\` in that shape (written as them, its authorHandle the \`writesAs\` handle list_databases names, its prompt set the way the app's own records set theirs), which saves it before the paint with no put_doc first, and \`vibe.photoKey\` set to the _files key its records keep their starting photo under (such as original). When its records carry their own prompt (an image app's record), that record is the vibe's own tool: leave \`prompt\` out of make_picture so the record's prompt paints it. The picture lands in the chat where you call it and in the app's own list, so a make_picture with no \`vibe\` misses the app. After the paint, write the picture app down with remember (which vibe, its database, the record shape and its photo key), and every later photo in the chat goes through it the same way, with no link needed and no words, until someone names another vibe or asks for something else, which you also write down. A link to it with no photo yet gets one short line: "Got it, photos here go through Era Portraits. Send one." A link to one record of a vibe, its address ending in #<key>=<id> (https://vibes.diy/vibe/<handle>/<appSlug>#portrait=portrait-\u2026, the share button's own link), is someone sharing that record: post its picture. Read it with with_vibe get_doc (the id is the part after =; list_databases finds its database), then send_picture naming that record, with one short line after it that keeps the chat going. Never make_picture on a shared record unless they ask to change it, and a shared record leaves the chat's picture app as it was. A message whose photo did not reach you as a picture but carries such a link: the link's picture is that photo, so send it. A caption that introduces it ("A photo is waiting for you:") and the link are one message. Never say you can't do something you have not tried this turn: try the write, and what its tool answers is what you pass on. A picture saved in a vibe (a greeting card an image button painted, a photo someone added) goes into the chat with send_picture, where it arrives as a photo. Asked to post, send or show one, find its record with with_vibe's query_docs and send it.
129587
+ - Pictures travel both ways. A photo the person sends is in front of you. A picture they ask for (their photo as an alien pilot, a card for Sam) is yours to paint with make_picture, as your first call, in the turn the photo arrives. \`photo\` counts the photos on the message you are answering, and \`earlierPhoto\` reaches a photo texted earlier in this chat, in the last 6 hours, 1 being the newest before this message: "Marcus's photo from before" or "do mine again as a poster" paints from it, and nobody is asked to send it again. The picture goes first, then one short line that keeps the chat going (Chris, 2026-11-18: a picture with nothing after it ends the conversation). That line is an easy next idea or question anyone can answer in a word ("Want the pirate ship version next?", "Should I do everyone?"), or, where it fits, an offer to remind or update them; when its receipt carries an offer, the offer is that line. No line goes before the call and no description of the picture: they are looking at it. When a tool failed, the line says that instead. Paint once per ask. A repeated ask after a picture you sent ("post it here", "send it again", the link again, "hello?") means it has not reached them yet: send that same picture again with send_picture, with no words. A picture travels only as a picture, so a picture's file address (an assets. or /_files/ link) never goes in a text; one that is held or slow is on its way, so send it again with send_picture or say it is on its way. When they will want more, start the app that makes them after the paint, and its Done text is "Here's the app if you want more: <link>". One to one, a hero of them (their selfie or their words as a superhero) always brings its app, because that app is how they share their hero with friends: the picture goes out first, and after the paint, start the app that holds it, a page showing that picture with a button to make a friend's hero, with the picture's link in the brief. Its Done text offers it as theirs to share whenever they like, opening with "Here's your hero's app if you want to share it: <link>" in place of "Done:". A hero is the one picture with words before it. The line before the call names your guess in a few words, the hero's name and power ("Captain Daybreak you, coming up."). A photo that never reached you ("did you get my pic?") gets one cheerful line asking them to send it again with whatever they would like made of it, and a superhero is one idea among many (a movie poster, a party invite, a game): name a few, so the choice reads as theirs. A vibe named for pictures is this chat's picture app. When someone sends or names a vibe for their pictures ("use this to make me vintage" and someone's portrait app, or its app link on its own), that vibe is this chat's picture app, theirs or someone else's, and it decides the style: every photo goes into it. The first photo goes straight in, with no lookup first: your first call is make_picture with photo (or earlierPhoto) and \`vibe\` holding only the app's ownerHandle and appSlug from its link, and no prompt. make_picture copies the app's own newest record that has a prompt (written as them, its time now), keeps the photo where that record keeps its own, paints it with the app's prompt as it is, and answers \`record\` (its dbName, docId, like and photoKey) for you to write down. A later ask that changes the look ("now as pirates", "add a cocktail") names the record: make_picture with \`vibe\` holding that dbName, a new docId, \`like\` and \`photoKey\`, and the changed prompt in \`vibe.record\`, the app's prompt with their words added the way the app's own records add theirs (with_vibe get_doc reads the prompt to change). When make_picture answers that the app has no record to copy, learn its shape from one with_vibe list_databases call (its \`samples\` holds a record of each collection) and name the record with \`vibe.like\` or \`vibe.record\`, and \`vibe.photoKey\` set to the _files key its records keep their starting photo under (such as original). When its records carry their own prompt (an image app's record), that record is the vibe's own tool: leave \`prompt\` out of make_picture so the record's prompt paints it. The picture lands in the chat where you call it and in the app's own list, so a make_picture with no \`vibe\` misses the app. After the paint, write the picture app down with remember (which vibe, its database, its photo key, and the record to copy with \`like\`: the one you just made), and every later photo in the chat goes through it the same way, copying that record; when the look changes, the record that carries the new look becomes the one to copy, and you write that down too, with no link needed and no words, until someone names another vibe or asks for something else, which you also write down. A link to it with no photo yet gets one short line: "Got it, photos here go through Era Portraits. Send one." A link to one record of a vibe, its address ending in #<key>=<id> (https://vibes.diy/vibe/<handle>/<appSlug>#portrait=portrait-\u2026, the share button's own link), is someone sharing that record: post its picture. Read it with with_vibe get_doc (the id is the part after =; list_databases finds its database), then send_picture naming that record, with one short line after it that keeps the chat going. Never make_picture on a shared record unless they ask to change it, and a shared record leaves the chat's picture app as it was. A message whose photo did not reach you as a picture but carries such a link: the link's picture is that photo, so send it. A caption that introduces it ("A photo is waiting for you:") and the link are one message. Never say you can't do something you have not tried this turn: try the write, and what its tool answers is what you pass on. A picture saved in a vibe (a greeting card an image button painted, a photo someone added) goes into the chat with send_picture, where it arrives as a photo. Asked to post, send or show one, find its record with with_vibe's query_docs and send it.
129509
129588
  - Keep the thread going. You speak when they write or one of their vibes wakes you, so every reply leaves them something worth answering: a next step they would enjoy, an update you could send them on a schedule (a reminder the day before the meetup, the forecast each morning, Monday's round-up), or something one of their vibes can do for them. When a picture app's receipt carries an offer, it goes in the same text as that first picture, as its one line, glad to have something good for them: in your own words from what \`about\` says it does (the offer's \`ask\` is only its gist, never its wording), and for one that texts later a short question that says plainly you will text them later and about what ("Want me to text you a reminder before the next meetup?"), promising only what its tool does. Ask it once. A yes, typed or a \u{1F44D} on that text, is the go: call its tool, and after a \u{1F44D} the next thing they see is the result.
129510
129589
  - Plain text, in short messages. Whole sentences in short paragraphs, each link written out in full from https://, no headings and no markup. A bit's wink is the one pair of stars a text carries. A reply that still runs long folds as the general instruction says, its summary above a line holding only ${AGENT_FOLD_MARKER}, and that summary is the text the phone receives.
129511
129590
  - Their words, not the machinery. Say what happened for them, in their terms. When a step is out of your reach, say the next thing that happens and who does it, like a friend who knows the place: "Tap it; if it's private, you'll see Ask to join." Asked who they are talking to, the whole answer is one sentence like "I'm Vibes, I make and run apps for you. What's on your plate?" Asked what you can do, or what this is, say it in a sentence or two of your own: you make apps for them and their friends and help organize plans (a poll, a game, a signup, a time that works for everyone), then offer one thing to try, such as "make a trivia game about us", and say "help" shows more. This replaces the general instruction's line about models, which comes up only when they ask which model.
@@ -130130,7 +130209,7 @@ var init_home_feed_common = __esm({
130130
130209
  import { exception2Result as exception2Result276, Result as Result205, stream2uint8array as stream2uint8array13 } from "@adviser/cement";
130131
130210
  import { bytesToHex as bytesToHex6, utf8ToBytes as utf8ToBytes8 } from "@noble/hashes/utils.js";
130132
130211
  import { sha256 as sha25612 } from "@noble/hashes/sha2.js";
130133
- import { and as and148, desc as desc33, eq as eq173, ne as ne22, or as or17 } from "drizzle-orm/sql/expressions";
130212
+ import { and as and148, desc as desc34, eq as eq173, ne as ne22, or as or17 } from "drizzle-orm/sql/expressions";
130134
130213
  function embeddingsUrl(backendUrl) {
130135
130214
  const suffix = "/chat/completions";
130136
130215
  if (backendUrl.endsWith(suffix)) {
@@ -131073,7 +131152,7 @@ var init_agent_build_tools = __esm({
131073
131152
 
131074
131153
  // ../vibes.diy/api/svc/public/lookup-handles.ts
131075
131154
  import { Result as Result210, Option as Option42, EventoResult as EventoResult36 } from "@adviser/cement";
131076
- import { and as and149, eq as eq175, inArray as inArray47, like as like7, or as or18, asc as asc15, desc as desc34 } from "drizzle-orm";
131155
+ import { and as and149, eq as eq175, inArray as inArray47, like as like7, or as or18, asc as asc15, desc as desc35 } from "drizzle-orm";
131077
131156
  async function collectKnownHandles(vctx, userId) {
131078
131157
  const t = vctx.sql.tables;
131079
131158
  const known = /* @__PURE__ */ new Set();
@@ -131136,7 +131215,7 @@ async function collectKnownHandles(vctx, userId) {
131136
131215
  }, "addPair");
131137
131216
  for (const row of [...memberInvites, ...memberRequests]) addPair(row.ownerHandle, row.appSlug);
131138
131217
  if (myHandles.length > 0 && pairs.size < KNOWN_APPS_CAP) {
131139
- const ownedApps = await vctx.sql.db.select({ ownerHandle: t.appSlugBinding.ownerHandle, appSlug: t.appSlugBinding.appSlug }).from(t.appSlugBinding).where(inArray47(t.appSlugBinding.ownerHandle, myHandles)).orderBy(desc34(t.appSlugBinding.updated)).limit(KNOWN_APPS_CAP);
131218
+ const ownedApps = await vctx.sql.db.select({ ownerHandle: t.appSlugBinding.ownerHandle, appSlug: t.appSlugBinding.appSlug }).from(t.appSlugBinding).where(inArray47(t.appSlugBinding.ownerHandle, myHandles)).orderBy(desc35(t.appSlugBinding.updated)).limit(KNOWN_APPS_CAP);
131140
131219
  for (const row of ownedApps) addPair(row.ownerHandle, row.appSlug);
131141
131220
  }
131142
131221
  const pairConds = [...pairs.values()].map(
@@ -131146,16 +131225,16 @@ async function collectKnownHandles(vctx, userId) {
131146
131225
  const [firstCond, ...restConds] = pairConds;
131147
131226
  const outputRows = await vctx.sql.db.select({ output: t.accessFnOutputs.output }).from(t.accessFnOutputs).where(and149(eq175(t.accessFnOutputs.hasGrants, 1), restConds.length === 0 ? firstCond : or18(firstCond, ...restConds)));
131148
131227
  for (const row of outputRows) {
131149
- let desc60;
131228
+ let desc61;
131150
131229
  try {
131151
- desc60 = JSON.parse(row.output);
131230
+ desc61 = JSON.parse(row.output);
131152
131231
  } catch {
131153
131232
  continue;
131154
131233
  }
131155
- for (const users of Object.values(desc60.members ?? {})) {
131234
+ for (const users of Object.values(desc61.members ?? {})) {
131156
131235
  for (const u of users) if (u.startsWith(INVITE_SUBJECT_PREFIX2) === false) known.add(u);
131157
131236
  }
131158
- for (const u of Object.keys(desc60.grant?.users ?? {})) if (u.startsWith(INVITE_SUBJECT_PREFIX2) === false) known.add(u);
131237
+ for (const u of Object.keys(desc61.grant?.users ?? {})) if (u.startsWith(INVITE_SUBJECT_PREFIX2) === false) known.add(u);
131159
131238
  }
131160
131239
  }
131161
131240
  return known;
@@ -131572,7 +131651,7 @@ var init_authorize_slug_owner = __esm({
131572
131651
  import { Result as Result212, Option as Option43, EventoResult as EventoResult37, exception2Result as exception2Result281 } from "@adviser/cement";
131573
131652
  import { type as type165 } from "arktype";
131574
131653
  import { and as and151, eq as eq177, gt as gt17, gte as gte6 } from "drizzle-orm/sql/expressions";
131575
- import { asc as asc16, desc as desc35 } from "drizzle-orm";
131654
+ import { asc as asc16, desc as desc36 } from "drizzle-orm";
131576
131655
  async function authorized(vctx, args) {
131577
131656
  const auth = await authorizeSlugOwner(vctx, args);
131578
131657
  if (auth === void 0) return false;
@@ -131700,7 +131779,7 @@ var init_app_logs = __esm({
131700
131779
  let latestTs;
131701
131780
  if (req2.probeLatest === true && events.length === 0) {
131702
131781
  const rLatest = await exception2Result281(
131703
- async () => vctx.sql.db.select({ ts: t.ts }).from(t).where(and151(eq177(t.ownerHandle, req2.ownerHandle), eq177(t.appSlug, req2.appSlug))).orderBy(desc35(t.id)).limit(1)
131782
+ async () => vctx.sql.db.select({ ts: t.ts }).from(t).where(and151(eq177(t.ownerHandle, req2.ownerHandle), eq177(t.appSlug, req2.appSlug))).orderBy(desc36(t.id)).limit(1)
131704
131783
  );
131705
131784
  if (rLatest.isErr()) {
131706
131785
  console.error("app-logs latest probe failed", { ownerHandle: req2.ownerHandle, appSlug: req2.appSlug }, rLatest.Err());
@@ -136186,11 +136265,11 @@ function searchGoodVibes(pages, query, section) {
136186
136265
  const scored = pool.map((page, index3) => {
136187
136266
  const title = new Set(tokens(page.title));
136188
136267
  const where = new Set(tokens(pagePath(page)));
136189
- const desc60 = new Set(tokens(page.description ?? ""));
136268
+ const desc61 = new Set(tokens(page.description ?? ""));
136190
136269
  let score = 0;
136191
136270
  let hits = 0;
136192
136271
  for (const t of terms) {
136193
- const s = (title.has(t) ? 4 : 0) + (where.has(t) ? 3 : 0) + (desc60.has(t) ? 1 : 0);
136272
+ const s = (title.has(t) ? 4 : 0) + (where.has(t) ? 3 : 0) + (desc61.has(t) ? 1 : 0);
136194
136273
  if (s > 0) hits++;
136195
136274
  score += s;
136196
136275
  }
@@ -137638,14 +137717,14 @@ var init_agent_guided_plan = __esm({
137638
137717
  // ../vibes.diy/api/svc/intern/agent-guided-run.ts
137639
137718
  import { Result as Result235, exception2Result as exception2Result305, stream2uint8array as stream2uint8array14 } from "@adviser/cement";
137640
137719
  import { type as type183 } from "arktype";
137641
- import { and as and160, desc as desc36, eq as eq186 } from "drizzle-orm/sql/expressions";
137720
+ import { and as and160, desc as desc37, eq as eq186 } from "drizzle-orm/sql/expressions";
137642
137721
  async function readGuidedDefinition(vctx, guide) {
137643
137722
  const flags = await exception2Result305(() => getBindingFlags(vctx, guide));
137644
137723
  if (flags.isErr()) return Result235.Err(flags);
137645
137724
  if (flags.Ok().unpublishedAt !== "") return Result235.Err("the guide is not published");
137646
137725
  const t = vctx.sql.tables.apps;
137647
137726
  const rRow = await exception2Result305(
137648
- () => vctx.sql.db.select({ fileSystem: t.fileSystem }).from(t).where(and160(eq186(t.ownerHandle, guide.ownerHandle), eq186(t.appSlug, guide.appSlug), eq186(t.mode, "production"))).orderBy(desc36(t.releaseSeq)).limit(1).then((rows) => rows[0])
137727
+ () => vctx.sql.db.select({ fileSystem: t.fileSystem }).from(t).where(and160(eq186(t.ownerHandle, guide.ownerHandle), eq186(t.appSlug, guide.appSlug), eq186(t.mode, "production"))).orderBy(desc37(t.releaseSeq)).limit(1).then((rows) => rows[0])
137649
137728
  );
137650
137729
  if (rRow.isErr()) return Result235.Err(rRow);
137651
137730
  const row = rRow.Ok();
@@ -138433,7 +138512,7 @@ var init_fork_seed_text = __esm({
138433
138512
  // ../vibes.diy/api/svc/public/get-app-by-fsid.ts
138434
138513
  import { Result as Result238, Option as Option48, EventoResult as EventoResult42, exception2Result as exception2Result307 } from "@adviser/cement";
138435
138514
  import { type as type186 } from "arktype";
138436
- import { and as and162, desc as desc37, eq as eq188 } from "drizzle-orm/sql/expressions";
138515
+ import { and as and162, desc as desc38, eq as eq188 } from "drizzle-orm/sql/expressions";
138437
138516
  function grantedAccess(role) {
138438
138517
  switch (role) {
138439
138518
  case "editor":
@@ -138540,7 +138619,7 @@ var init_get_app_by_fsid = __esm({
138540
138619
  eq188(vctx.sql.tables.apps.appSlug, req2.appSlug),
138541
138620
  eq188(vctx.sql.tables.apps.ownerHandle, req2.ownerHandle)
138542
138621
  )
138543
- ).orderBy(desc37(vctx.sql.tables.apps.mode), desc37(vctx.sql.tables.apps.releaseSeq)).limit(1).then((r) => r[0]);
138622
+ ).orderBy(desc38(vctx.sql.tables.apps.mode), desc38(vctx.sql.tables.apps.releaseSeq)).limit(1).then((r) => r[0]);
138544
138623
  } else if ((req2.selectMode === "ownerLatest" || req2.selectMode === "ownerDraft") && callerUserId) {
138545
138624
  const draft = await selectLatestDevDraftOrPublished(vctx, { ownerHandle: req2.ownerHandle, appSlug: req2.appSlug });
138546
138625
  const isOwnersDraft = draft !== void 0 && draft.userId === callerUserId;
@@ -140505,7 +140584,7 @@ var init_agent_calendar_link_tool = __esm({
140505
140584
  // ../vibes.diy/api/svc/intern/agent-account-tools.ts
140506
140585
  import { JSONEnDecoderSingleton as JSONEnDecoderSingleton6, Result as Result244, exception2Result as exception2Result313 } from "@adviser/cement";
140507
140586
  import { type as type191 } from "arktype";
140508
- import { and as and165, desc as desc38, eq as eq191, inArray as inArray49, lt as lt13, or as or20 } from "drizzle-orm/sql/expressions";
140587
+ import { and as and165, desc as desc39, eq as eq191, inArray as inArray49, lt as lt13, or as or20 } from "drizzle-orm/sql/expressions";
140509
140588
  import { base58btc as base58btc13 } from "multiformats/bases/base58";
140510
140589
  function boundTitle(item) {
140511
140590
  if (item.title === void 0 || item.title.length <= VIBE_ACTIVITY_TITLE_CHARS) return item;
@@ -140581,7 +140660,7 @@ async function listAccountVibes(vctx, args) {
140581
140660
  and165(eq191(asb.updated, after.updated), eq191(asb.ownerHandle, after.ownerHandle), lt13(asb.appSlug, after.appSlug))
140582
140661
  )
140583
140662
  )
140584
- ).orderBy(desc38(asb.updated), desc38(asb.ownerHandle), desc38(asb.appSlug)).limit(limit + 1)
140663
+ ).orderBy(desc39(asb.updated), desc39(asb.ownerHandle), desc39(asb.appSlug)).limit(limit + 1)
140585
140664
  );
140586
140665
  if (rRows.isErr()) return Result244.Err(rRows);
140587
140666
  const rows = rRows.Ok().filter((row) => isAgentChatAppSlug(row.appSlug) === false);
@@ -146997,7 +147076,7 @@ var init_deliver_post_turn_version = __esm({
146997
147076
 
146998
147077
  // ../vibes.diy/api/svc/intern/design-repair.ts
146999
147078
  import { Result as Result259, exception2Result as exception2Result332, stream2uint8array as stream2uint8array15 } from "@adviser/cement";
147000
- import { and as and168, desc as desc39, eq as eq197, isNotNull as isNotNull7 } from "drizzle-orm";
147079
+ import { and as and168, desc as desc40, eq as eq197, isNotNull as isNotNull7 } from "drizzle-orm";
147001
147080
  import { type as type196 } from "arktype";
147002
147081
  function designRepairEnabled(flag22) {
147003
147082
  return flag22 !== "off";
@@ -147109,7 +147188,7 @@ async function chatHeadFsId(vctx, chatId) {
147109
147188
  const pc = vctx.sql.tables.promptContexts;
147110
147189
  const apps = vctx.sql.tables.apps;
147111
147190
  return exception2Result332(async () => {
147112
- const rows = await vctx.sql.db.select({ fsId: pc.fsId }).from(pc).innerJoin(apps, eq197(apps.fsId, pc.fsId)).where(and168(eq197(pc.chatId, chatId), isNotNull7(pc.fsId))).orderBy(desc39(pc.created)).limit(1);
147191
+ const rows = await vctx.sql.db.select({ fsId: pc.fsId }).from(pc).innerJoin(apps, eq197(apps.fsId, pc.fsId)).where(and168(eq197(pc.chatId, chatId), isNotNull7(pc.fsId))).orderBy(desc40(pc.created)).limit(1);
147113
147192
  return rows[0]?.fsId ?? void 0;
147114
147193
  });
147115
147194
  }
@@ -150071,7 +150150,7 @@ var init_shared_mint2 = __esm({
150071
150150
  // ../vibes.diy/api/svc/public/list-user-slug-app-slug.ts
150072
150151
  import { Result as Result266, Option as Option54, EventoResult as EventoResult48 } from "@adviser/cement";
150073
150152
  import { type as type201 } from "arktype";
150074
- import { eq as eq200, and as and171, desc as desc40 } from "drizzle-orm/sql/expressions";
150153
+ import { eq as eq200, and as and171, desc as desc41 } from "drizzle-orm/sql/expressions";
150075
150154
  var listUserSlugAppSlugEvento;
150076
150155
  var init_list_user_slug_app_slug = __esm({
150077
150156
  "../vibes.diy/api/svc/public/list-user-slug-app-slug.ts"() {
@@ -150114,7 +150193,7 @@ var init_list_user_slug_app_slug = __esm({
150114
150193
  }).from(vctx.sql.tables.handleBinding).leftJoin(
150115
150194
  vctx.sql.tables.appSlugBinding,
150116
150195
  eq200(vctx.sql.tables.appSlugBinding.ownerHandle, vctx.sql.tables.handleBinding.handle)
150117
- ).where(and171(...conditions)).orderBy(desc40(vctx.sql.tables.handleBinding.created), desc40(vctx.sql.tables.appSlugBinding.created));
150196
+ ).where(and171(...conditions)).orderBy(desc41(vctx.sql.tables.handleBinding.created), desc41(vctx.sql.tables.appSlugBinding.created));
150118
150197
  const grouped = /* @__PURE__ */ new Map();
150119
150198
  for (const row of rows) {
150120
150199
  if (!grouped.has(row.ownerHandle)) {
@@ -150150,7 +150229,7 @@ import {
150150
150229
  } from "@adviser/cement";
150151
150230
  import { type as type202 } from "arktype";
150152
150231
  import { base58btc as base58btc14 } from "multiformats/bases/base58";
150153
- import { eq as eq201, and as and172, lt as lt15, or as or21, desc as desc41, inArray as inArray52 } from "drizzle-orm/sql/expressions";
150232
+ import { eq as eq201, and as and172, lt as lt15, or as or21, desc as desc42, inArray as inArray52 } from "drizzle-orm/sql/expressions";
150154
150233
  function encodeCursor3(c) {
150155
150234
  return base58btc14.encode(jsonEnde2.uint8ify(c));
150156
150235
  }
@@ -150269,7 +150348,7 @@ var init_list_recent_vibes = __esm({
150269
150348
  }).from(usb).innerJoin(asb, eq201(asb.ownerHandle, usb.handle)).leftJoin(
150270
150349
  settings,
150271
150350
  and172(eq201(settings.userId, usb.userId), eq201(settings.ownerHandle, usb.handle), eq201(settings.appSlug, asb.appSlug))
150272
- ).where(and172(...conditions)).orderBy(desc41(asb.pinnedAt), desc41(asb.updated), desc41(asb.ownerHandle), desc41(asb.appSlug)).limit(limit + 1);
150351
+ ).where(and172(...conditions)).orderBy(desc42(asb.pinnedAt), desc42(asb.updated), desc42(asb.ownerHandle), desc42(asb.appSlug)).limit(limit + 1);
150273
150352
  const hasMore = rows.length > limit;
150274
150353
  const slice = hasMore ? rows.slice(0, limit) : rows;
150275
150354
  const tApps = vctx.sql.tables.apps;
@@ -151156,7 +151235,7 @@ var init_vibe_tools_wire = __esm({
151156
151235
  // ../vibes.diy/api/svc/public/app-owner-stats.ts
151157
151236
  import { Result as Result276, Option as Option63, EventoResult as EventoResult57, exception2Result as exception2Result345 } from "@adviser/cement";
151158
151237
  import { type as type210 } from "arktype";
151159
- import { and as and176, count as count4, desc as desc42, eq as eq206, gte as gte8, inArray as inArray53, like as like8, sql as sql31 } from "drizzle-orm";
151238
+ import { and as and176, count as count4, desc as desc43, eq as eq206, gte as gte8, inArray as inArray53, like as like8, sql as sql31 } from "drizzle-orm";
151160
151239
  async function authorized3(vctx, args) {
151161
151240
  const auth = await authorizeSlugOwner(vctx, args);
151162
151241
  if (auth === void 0) return false;
@@ -151188,7 +151267,7 @@ async function readAppOwnerStats(vctx, args) {
151188
151267
  like8(n2.dedupeKey, "app-message:%")
151189
151268
  );
151190
151269
  const recipientCount = sql31`count(*)`;
151191
- const topRecipients = await vctx.sql.db.select({ handle: n2.recipientHandle, count: recipientCount }).from(n2).where(fromThisVibe).groupBy(n2.userId, n2.recipientHandle).orderBy(desc42(recipientCount)).limit(TOP_RECIPIENTS);
151270
+ const topRecipients = await vctx.sql.db.select({ handle: n2.recipientHandle, count: recipientCount }).from(n2).where(fromThisVibe).groupBy(n2.userId, n2.recipientHandle).orderBy(desc43(recipientCount)).limit(TOP_RECIPIENTS);
151192
151271
  const totals = await vctx.sql.db.select({
151193
151272
  total: sql31`count(*)`,
151194
151273
  // The same (account, handle) pairs the list above is grouped by.
@@ -151207,8 +151286,8 @@ async function readAppOwnerStats(vctx, args) {
151207
151286
  trigger: l.trigger,
151208
151287
  lines: sql31`count(*)`,
151209
151288
  errors: sql31`sum(case when ${l.level} = 'error' then 1 else 0 end)`
151210
- }).from(l).where(fromThisBackend).groupBy(l.trigger).orderBy(desc42(sql31`count(*)`));
151211
- const lastError2 = await vctx.sql.db.select({ ts: l.ts, trigger: l.trigger }).from(l).where(and176(fromThisBackend, eq206(l.level, "error"))).orderBy(desc42(l.id)).limit(1).then((r) => r[0]);
151289
+ }).from(l).where(fromThisBackend).groupBy(l.trigger).orderBy(desc43(sql31`count(*)`));
151290
+ const lastError2 = await vctx.sql.db.select({ ts: l.ts, trigger: l.trigger }).from(l).where(and176(fromThisBackend, eq206(l.level, "error"))).orderBy(desc43(l.id)).limit(1).then((r) => r[0]);
151212
151291
  const errorCount = byTrigger.reduce((sum, r) => sum + Number(r.errors ?? 0), 0);
151213
151292
  const errors = errorCount > 0 ? await readErrorGroups(vctx, { ...args, where: and176(fromThisBackend, eq206(l.level, "error")) }) : void 0;
151214
151293
  return {
@@ -151251,7 +151330,7 @@ async function readErrorGroups(vctx, args) {
151251
151330
  const prefix = sql31`substr(${l.body}, 1, ${sql31.raw(String(APP_OWNER_ERROR_PREFIX_CHARS))})`;
151252
151331
  const count7 = sql31`count(*)`;
151253
151332
  const lastAt = sql31`max(${l.ts})`;
151254
- const rows = await vctx.sql.db.select({ message: prefix, count: count7, firstAt: sql31`min(${l.ts})`, lastAt, newestId: sql31`max(${l.id})` }).from(l).where(args.where).groupBy(prefix).orderBy(desc42(count7), desc42(lastAt)).limit(APP_OWNER_ERROR_GROUPS);
151333
+ const rows = await vctx.sql.db.select({ message: prefix, count: count7, firstAt: sql31`min(${l.ts})`, lastAt, newestId: sql31`max(${l.id})` }).from(l).where(args.where).groupBy(prefix).orderBy(desc43(count7), desc43(lastAt)).limit(APP_OWNER_ERROR_GROUPS);
151255
151334
  const newestIds = rows.map((r) => r.newestId);
151256
151335
  const fsIdRows = newestIds.length === 0 ? [] : await vctx.sql.db.select({ id: l.id, fsId: l.fsId }).from(l).where(and176(eq206(l.ownerHandle, args.ownerHandle), eq206(l.appSlug, args.appSlug), inArray53(l.id, newestIds)));
151257
151336
  const fsIdById = new Map(fsIdRows.map((r) => [r.id, r.fsId]));
@@ -151701,7 +151780,7 @@ var init_mark_build_seen = __esm({
151701
151780
  // ../vibes.diy/api/svc/public/get-chat-details.ts
151702
151781
  import { Result as Result281, Option as Option68, EventoResult as EventoResult62 } from "@adviser/cement";
151703
151782
  import { type as type215 } from "arktype";
151704
- import { eq as eq207, and as and177, desc as desc43, ne as ne25 } from "drizzle-orm/sql/expressions";
151783
+ import { eq as eq207, and as and177, desc as desc44, ne as ne25 } from "drizzle-orm/sql/expressions";
151705
151784
  var getChatDetailsEvento;
151706
151785
  var init_get_chat_details = __esm({
151707
151786
  "../vibes.diy/api/svc/public/get-chat-details.ts"() {
@@ -151773,7 +151852,7 @@ var init_get_chat_details = __esm({
151773
151852
  ...req2.chatId !== void 0 ? [eq207(vctx.sql.tables.chatContexts.chatId, req2.chatId)] : [],
151774
151853
  ...isDeveloper ? [eq207(vctx.sql.tables.chatContexts.userId, userId)] : []
151775
151854
  )
151776
- ).orderBy(desc43(vctx.sql.tables.promptContexts.created));
151855
+ ).orderBy(desc44(vctx.sql.tables.promptContexts.created));
151777
151856
  if (rows.length === 0) {
151778
151857
  await ctx.send.send(ctx, {
151779
151858
  type: "vibes.diy.res-get-chat-details",
@@ -153044,7 +153123,7 @@ var init_auto_flag_address = __esm({
153044
153123
  // ../vibes.diy/api/svc/public/moderation-admin.ts
153045
153124
  import { Result as Result291, Option as Option77, EventoResult as EventoResult71 } from "@adviser/cement";
153046
153125
  import { type as type226 } from "arktype";
153047
- import { and as and181, count as count6, desc as desc44, eq as eq213, gte as gte9, inArray as inArray55, notInArray as notInArray9 } from "drizzle-orm";
153126
+ import { and as and181, count as count6, desc as desc45, eq as eq213, gte as gte9, inArray as inArray55, notInArray as notInArray9 } from "drizzle-orm";
153048
153127
  function toReportRow(r) {
153049
153128
  return {
153050
153129
  reportId: r.reportId,
@@ -153138,7 +153217,7 @@ async function moderationAdmin(vctx, req2, now3 = /* @__PURE__ */ new Date()) {
153138
153217
  const status = req2.status ?? "open";
153139
153218
  const limit = Math.max(1, Math.min(MAX_LIST_LIMIT, Math.floor(req2.limit ?? DEFAULT_LIST_LIMIT)));
153140
153219
  const base = vctx.sql.db.select().from(reports);
153141
- const rows = await (status === "all" ? base : base.where(eq213(reports.status, status))).orderBy(desc44(reports.created)).limit(limit);
153220
+ const rows = await (status === "all" ? base : base.where(eq213(reports.status, status))).orderBy(desc45(reports.created)).limit(limit);
153142
153221
  return Result291.Ok({ type: "vibes.diy.res-moderation-admin", op: req2.op, reports: rows.map(toReportRow) });
153143
153222
  }
153144
153223
  case "resolve-report": {
@@ -153210,7 +153289,7 @@ async function moderationAdmin(vctx, req2, now3 = /* @__PURE__ */ new Date()) {
153210
153289
  const status = req2.flagStatus ?? "open";
153211
153290
  const limit = Math.max(1, Math.min(MAX_LIST_LIMIT, Math.floor(req2.limit ?? DEFAULT_LIST_LIMIT)));
153212
153291
  const base = vctx.sql.db.select().from(flags);
153213
- const rows = await (status === "all" ? base.where(notInArray9(flags.status, [...AUTO_FLAG_RECORD_STATUSES])) : base.where(eq213(flags.status, status))).orderBy(desc44(flags.created)).limit(limit);
153292
+ const rows = await (status === "all" ? base.where(notInArray9(flags.status, [...AUTO_FLAG_RECORD_STATUSES])) : base.where(eq213(flags.status, status))).orderBy(desc45(flags.created)).limit(limit);
153214
153293
  const out = [];
153215
153294
  for (const r of await withCurrentFlagAddress(vctx.sql, rows)) {
153216
153295
  const text3 = r.inputKind === "prompt" && r.chatId && r.promptId ? await readFlaggedPrompt(vctx, r.chatId, r.promptId) : void 0;
@@ -153631,7 +153710,7 @@ var init_ensure_handle_avatar = __esm({
153631
153710
  // ../vibes.diy/api/svc/public/list-application-chats.ts
153632
153711
  import { Result as Result295, Option as Option81, EventoResult as EventoResult75 } from "@adviser/cement";
153633
153712
  import { type as type230 } from "arktype";
153634
- import { eq as eq217, and as and185, lt as lt17, desc as desc45, asc as asc20, inArray as inArray56 } from "drizzle-orm/sql/expressions";
153713
+ import { eq as eq217, and as and185, lt as lt17, desc as desc46, asc as asc20, inArray as inArray56 } from "drizzle-orm/sql/expressions";
153635
153714
  var DEFAULT_LIMIT5, MAX_LIMIT5, listApplicationChats;
153636
153715
  var init_list_application_chats = __esm({
153637
153716
  "../vibes.diy/api/svc/public/list-application-chats.ts"() {
@@ -153680,7 +153759,7 @@ var init_list_application_chats = __esm({
153680
153759
  ownerHandle: vctx.sql.tables.applicationChats.ownerHandle,
153681
153760
  created: vctx.sql.tables.applicationChats.created,
153682
153761
  userId: vctx.sql.tables.applicationChats.userId
153683
- }).from(vctx.sql.tables.applicationChats).where(and185(...conditions)).orderBy(desc45(vctx.sql.tables.applicationChats.created)).limit(limit + 1);
153762
+ }).from(vctx.sql.tables.applicationChats).where(and185(...conditions)).orderBy(desc46(vctx.sql.tables.applicationChats.created)).limit(limit + 1);
153684
153763
  const hasMore = rows.length > limit;
153685
153764
  const page = hasMore ? rows.slice(0, limit) : rows;
153686
153765
  const userIds = [...new Set(page.map((r) => r.userId))];
@@ -153713,7 +153792,7 @@ var init_list_application_chats = __esm({
153713
153792
  // ../vibes.diy/api/svc/public/list-codegen-chats.ts
153714
153793
  import { Result as Result296, Option as Option82, EventoResult as EventoResult76 } from "@adviser/cement";
153715
153794
  import { type as type231 } from "arktype";
153716
- import { eq as eq218, and as and186, lt as lt18, desc as desc46 } from "drizzle-orm/sql/expressions";
153795
+ import { eq as eq218, and as and186, lt as lt18, desc as desc47 } from "drizzle-orm/sql/expressions";
153717
153796
  var DEFAULT_LIMIT6, MAX_LIMIT6, listCodegenChats;
153718
153797
  var init_list_codegen_chats = __esm({
153719
153798
  "../vibes.diy/api/svc/public/list-codegen-chats.ts"() {
@@ -153752,7 +153831,7 @@ var init_list_codegen_chats = __esm({
153752
153831
  appSlug: vctx.sql.tables.chatContexts.appSlug,
153753
153832
  ownerHandle: vctx.sql.tables.chatContexts.ownerHandle,
153754
153833
  created: vctx.sql.tables.chatContexts.created
153755
- }).from(vctx.sql.tables.chatContexts).where(and186(...conditions)).orderBy(desc46(vctx.sql.tables.chatContexts.created)).limit(limit + 1);
153834
+ }).from(vctx.sql.tables.chatContexts).where(and186(...conditions)).orderBy(desc47(vctx.sql.tables.chatContexts.created)).limit(limit + 1);
153756
153835
  const hasMore = rows.length > limit;
153757
153836
  const items = hasMore ? rows.slice(0, limit) : rows;
153758
153837
  await ctx.send.send(ctx, {
@@ -154594,7 +154673,7 @@ import {
154594
154673
  } from "@adviser/cement";
154595
154674
  import { type as type240 } from "arktype";
154596
154675
  import { base58btc as base58btc15 } from "multiformats/bases/base58";
154597
- import { eq as eq224, and as and192, lt as lt19, or as or23, desc as desc47, isNull as isNull13, inArray as inArray58, not as not3, sql as sql32 } from "drizzle-orm";
154676
+ import { eq as eq224, and as and192, lt as lt19, or as or23, desc as desc48, isNull as isNull13, inArray as inArray58, not as not3, sql as sql32 } from "drizzle-orm";
154598
154677
  function clampLimit4(raw) {
154599
154678
  if (raw === void 0) return DEFAULT_LIMIT7;
154600
154679
  if (!Number.isFinite(raw)) return DEFAULT_LIMIT7;
@@ -154693,7 +154772,7 @@ var init_list_notifications = __esm({
154693
154772
  const tuplePred = or23(lt19(t.created, c.created), and192(eq224(t.created, c.created), lt19(t.id, c.id)));
154694
154773
  if (tuplePred) conditions.push(tuplePred);
154695
154774
  }
154696
- const rows = await vctx.sql.db.select().from(t).where(and192(...conditions)).orderBy(desc47(t.created), desc47(t.id)).limit(limit + 1);
154775
+ const rows = await vctx.sql.db.select().from(t).where(and192(...conditions)).orderBy(desc48(t.created), desc48(t.id)).limit(limit + 1);
154697
154776
  const hasMore = rows.length > limit;
154698
154777
  const slice = hasMore ? rows.slice(0, limit) : rows;
154699
154778
  const items = slice.map(toRow4);
@@ -155330,7 +155409,7 @@ var init_onboarding_handle2 = __esm({
155330
155409
 
155331
155410
  // ../vibes.diy/api/svc/public/developer-grants-flow.ts
155332
155411
  import { Result as Result312, Option as Option98, EventoResult as EventoResult92, exception2Result as exception2Result354 } from "@adviser/cement";
155333
- import { eq as eq229, and as and196, lt as lt20, desc as desc48 } from "drizzle-orm/sql/expressions";
155412
+ import { eq as eq229, and as and196, lt as lt20, desc as desc49 } from "drizzle-orm/sql/expressions";
155334
155413
  async function ownsHandle4(vctx, ownerHandle, callerUserId) {
155335
155414
  const row = await vctx.sql.db.select({ userId: vctx.sql.tables.handleBinding.userId }).from(vctx.sql.tables.handleBinding).where(and196(eq229(vctx.sql.tables.handleBinding.handle, ownerHandle), eq229(vctx.sql.tables.handleBinding.userId, callerUserId))).limit(1).then((rows) => rows[0]);
155336
155415
  return row !== void 0;
@@ -155526,7 +155605,7 @@ var init_developer_grants_flow = __esm({
155526
155605
  state: vctx.sql.tables.developerGrants.state,
155527
155606
  updated: vctx.sql.tables.developerGrants.updated,
155528
155607
  created: vctx.sql.tables.developerGrants.created
155529
- }).from(vctx.sql.tables.developerGrants).where(and196(...conditions)).orderBy(desc48(vctx.sql.tables.developerGrants.created)).limit(limit + 1);
155608
+ }).from(vctx.sql.tables.developerGrants).where(and196(...conditions)).orderBy(desc49(vctx.sql.tables.developerGrants.created)).limit(limit + 1);
155530
155609
  const hasMore = rows.length > limit;
155531
155610
  const items = hasMore ? rows.slice(0, limit) : rows;
155532
155611
  await ctx.send.send(ctx, {
@@ -157823,7 +157902,7 @@ var init_app_documents2 = __esm({
157823
157902
 
157824
157903
  // ../vibes.diy/api/svc/public/list-members.ts
157825
157904
  import { Result as Result326, Option as Option107, EventoResult as EventoResult104 } from "@adviser/cement";
157826
- import { eq as eq236, and as and203, inArray as inArray63, desc as desc49 } from "drizzle-orm";
157905
+ import { eq as eq236, and as and203, inArray as inArray63, desc as desc50 } from "drizzle-orm";
157827
157906
  import { type as type247 } from "arktype";
157828
157907
  function safeDisplay(foreignInfo, fallbackEmail, fallbackHandle) {
157829
157908
  const fi = foreignInfo;
@@ -157910,7 +157989,7 @@ var init_list_members = __esm({
157910
157989
  const handleByUserId = /* @__PURE__ */ new Map();
157911
157990
  let heldHandles = /* @__PURE__ */ new Map();
157912
157991
  if (requestUserIds.length > 0) {
157913
- const handleRows = await vctx.sql.db.select({ userId: vctx.sql.tables.handleBinding.userId, handle: vctx.sql.tables.handleBinding.handle }).from(vctx.sql.tables.handleBinding).where(inArray63(vctx.sql.tables.handleBinding.userId, requestUserIds)).orderBy(desc49(vctx.sql.tables.handleBinding.created));
157992
+ const handleRows = await vctx.sql.db.select({ userId: vctx.sql.tables.handleBinding.userId, handle: vctx.sql.tables.handleBinding.handle }).from(vctx.sql.tables.handleBinding).where(inArray63(vctx.sql.tables.handleBinding.userId, requestUserIds)).orderBy(desc50(vctx.sql.tables.handleBinding.created));
157914
157993
  heldHandles = collectHeldHandles(handleRows);
157915
157994
  for (const row of handleRows) {
157916
157995
  if (!handleByUserId.has(row.userId)) handleByUserId.set(row.userId, row.handle);
@@ -159716,7 +159795,7 @@ var init_report_top_vibes_by_traffic = __esm({
159716
159795
  // ../vibes.diy/api/svc/public/report-attribution-referrers.ts
159717
159796
  import { Result as Result341, Option as Option121, EventoResult as EventoResult118 } from "@adviser/cement";
159718
159797
  import { type as type255 } from "arktype";
159719
- import { sql as sql37, desc as desc50, eq as eq240, notInArray as notInArray10, and as and204, like as like9, notLike as notLike3, not as not4, gte as gte11 } from "drizzle-orm";
159798
+ import { sql as sql37, desc as desc51, eq as eq240, notInArray as notInArray10, and as and204, like as like9, notLike as notLike3, not as not4, gte as gte11 } from "drizzle-orm";
159720
159799
  function legacyVibePath(reqPath) {
159721
159800
  return and204(like9(reqPath, "/vibe/_%"), notLike3(reqPath, "/vibe/%/%"));
159722
159801
  }
@@ -159737,11 +159816,11 @@ async function computeAttributionReferrers(vctx, reqPathFilter, window2 = "all")
159737
159816
  total: sql37`cast(count(*) as int)`
159738
159817
  }).from(t.refererEvents).$dynamic();
159739
159818
  const filtered = reqPathFilter !== void 0 ? baseQuery.where(and204(ownedFilter, notLegacyVibeFilter, windowFilter, eq240(t.refererEvents.reqPath, reqPathFilter))) : baseQuery.where(and204(ownedFilter, notLegacyVibeFilter, windowFilter));
159740
- const rows = await filtered.groupBy(t.refererEvents.refHost, t.refererEvents.refPath, t.refererEvents.reqPath).orderBy(desc50(sql37`count(*)`)).limit(100);
159819
+ const rows = await filtered.groupBy(t.refererEvents.refHost, t.refererEvents.refPath, t.refererEvents.reqPath).orderBy(desc51(sql37`count(*)`)).limit(100);
159741
159820
  const legacyVibeRows = reqPathFilter === void 0 ? await vctx.sql.db.select({
159742
159821
  reqPath: t.refererEvents.reqPath,
159743
159822
  total: sql37`cast(count(*) as int)`
159744
- }).from(t.refererEvents).where(and204(legacyVibePath(t.refererEvents.reqPath), windowFilter)).groupBy(t.refererEvents.reqPath).orderBy(desc50(sql37`count(*)`)).limit(200) : [];
159823
+ }).from(t.refererEvents).where(and204(legacyVibePath(t.refererEvents.reqPath), windowFilter)).groupBy(t.refererEvents.reqPath).orderBy(desc51(sql37`count(*)`)).limit(200) : [];
159745
159824
  return {
159746
159825
  type: "vibes.diy.res-report-attribution-referrers",
159747
159826
  generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -159814,7 +159893,7 @@ var init_report_attribution_referrers = __esm({
159814
159893
  // ../vibes.diy/api/svc/public/report-api-traffic.ts
159815
159894
  import { Result as Result342, Option as Option122, EventoResult as EventoResult119 } from "@adviser/cement";
159816
159895
  import { type as type256 } from "arktype";
159817
- import { sql as sql38, asc as asc21, desc as desc51, eq as eq241, and as and205, gte as gte12 } from "drizzle-orm";
159896
+ import { sql as sql38, asc as asc21, desc as desc52, eq as eq241, and as and205, gte as gte12 } from "drizzle-orm";
159818
159897
  function percentile(sortedAsc, p) {
159819
159898
  if (sortedAsc.length === 0) return 0;
159820
159899
  const rank = Math.ceil(p / 100 * sortedAsc.length);
@@ -159897,7 +159976,7 @@ async function computeApiTraffic(vctx, hostFilter) {
159897
159976
  day: dayExpr,
159898
159977
  host: t.apiRequestEvents.host,
159899
159978
  requests: sql38`cast(count(*) as int)`
159900
- }).from(t.apiRequestEvents).where(where).groupBy(dayExpr, t.apiRequestEvents.host).orderBy(desc51(dayExpr), asc21(t.apiRequestEvents.host)).limit(PER_DAY_GROUP_CAP);
159979
+ }).from(t.apiRequestEvents).where(where).groupBy(dayExpr, t.apiRequestEvents.host).orderBy(desc52(dayExpr), asc21(t.apiRequestEvents.host)).limit(PER_DAY_GROUP_CAP);
159901
159980
  const sample = await vctx.sql.db.select({
159902
159981
  host: t.apiRequestEvents.host,
159903
159982
  path: t.apiRequestEvents.path,
@@ -159906,7 +159985,7 @@ async function computeApiTraffic(vctx, hostFilter) {
159906
159985
  status: t.apiRequestEvents.status,
159907
159986
  durationMs: t.apiRequestEvents.durationMs,
159908
159987
  ts: t.apiRequestEvents.ts
159909
- }).from(t.apiRequestEvents).where(where).orderBy(desc51(t.apiRequestEvents.ts)).limit(SAMPLE_ROW_CAP);
159988
+ }).from(t.apiRequestEvents).where(where).orderBy(desc52(t.apiRequestEvents.ts)).limit(SAMPLE_ROW_CAP);
159910
159989
  const { endpoints, pollers } = aggregateApiTraffic(sample);
159911
159990
  return {
159912
159991
  type: "vibes.diy.res-report-api-traffic",
@@ -159972,7 +160051,7 @@ var init_report_api_traffic = __esm({
159972
160051
  // ../vibes.diy/api/svc/public/report-egress.ts
159973
160052
  import { Result as Result343, Option as Option123, EventoResult as EventoResult120 } from "@adviser/cement";
159974
160053
  import { type as type257 } from "arktype";
159975
- import { sql as sql39, asc as asc22, desc as desc52, eq as eq242, and as and206, or as or24, gte as gte13 } from "drizzle-orm";
160054
+ import { sql as sql39, asc as asc22, desc as desc53, eq as eq242, and as and206, or as or24, gte as gte13 } from "drizzle-orm";
159976
160055
  function aggregateEgress(rows) {
159977
160056
  const hosts = /* @__PURE__ */ new Map();
159978
160057
  const vibes = /* @__PURE__ */ new Map();
@@ -160052,7 +160131,7 @@ async function computeEgress(vctx, hostFilter) {
160052
160131
  gate: t.egressEvents.gate,
160053
160132
  cached: t.egressEvents.cached,
160054
160133
  ts: t.egressEvents.ts
160055
- }).from(t.egressEvents).where(where).orderBy(desc52(t.egressEvents.ts)).limit(SAMPLE_ROW_CAP2);
160134
+ }).from(t.egressEvents).where(where).orderBy(desc53(t.egressEvents.ts)).limit(SAMPLE_ROW_CAP2);
160056
160135
  const suspectWindow = gte13(t.egressSuspectEvents.ts, cutoff);
160057
160136
  const suspectWhere = hostFilter !== void 0 ? and206(suspectWindow, eq242(t.egressSuspectEvents.host, hostFilter)) : suspectWindow;
160058
160137
  const suspects = await vctx.sql.db.select({
@@ -160067,7 +160146,7 @@ async function computeEgress(vctx, hostFilter) {
160067
160146
  t.egressSuspectEvents.ownerHandle,
160068
160147
  t.egressSuspectEvents.appSlug,
160069
160148
  t.egressSuspectEvents.reasons
160070
- ).orderBy(desc52(sql39`count(*)`), asc22(t.egressSuspectEvents.host)).limit(SUSPECT_GROUP_CAP);
160149
+ ).orderBy(desc53(sql39`count(*)`), asc22(t.egressSuspectEvents.host)).limit(SUSPECT_GROUP_CAP);
160071
160150
  const { byHost, byVibe, byGate } = aggregateEgress(sample);
160072
160151
  return {
160073
160152
  type: "vibes.diy.res-report-egress",
@@ -162204,7 +162283,7 @@ var init_report_activity = __esm({
162204
162283
  import { Result as Result351, Option as Option128, EventoResult as EventoResult125 } from "@adviser/cement";
162205
162284
  import { type as type263 } from "arktype";
162206
162285
  import { sql as sql41 } from "drizzle-orm";
162207
- import { and as and209, asc as asc24, desc as desc53, eq as eq245 } from "drizzle-orm/sql/expressions";
162286
+ import { and as and209, asc as asc24, desc as desc54, eq as eq245 } from "drizzle-orm/sql/expressions";
162208
162287
  async function computeHomeLeaderboard(vctx, limit) {
162209
162288
  const docs = vctx.sql.tables.appDocuments;
162210
162289
  const asb = vctx.sql.tables.appSlugBinding;
@@ -162213,7 +162292,7 @@ async function computeHomeLeaderboard(vctx, limit) {
162213
162292
  ownerHandle: docs.ownerHandle,
162214
162293
  appSlug: docs.appSlug,
162215
162294
  writerCount
162216
- }).from(docs).innerJoin(asb, and209(eq245(asb.ownerHandle, docs.ownerHandle), eq245(asb.appSlug, docs.appSlug), eq245(asb.unpublishedAt, ""))).groupBy(docs.ownerHandle, docs.appSlug).orderBy(desc53(writerCount), asc24(docs.ownerHandle), asc24(docs.appSlug)).limit(limit * HOME_FEED_SCAN_FACTOR);
162295
+ }).from(docs).innerJoin(asb, and209(eq245(asb.ownerHandle, docs.ownerHandle), eq245(asb.appSlug, docs.appSlug), eq245(asb.unpublishedAt, ""))).groupBy(docs.ownerHandle, docs.appSlug).orderBy(desc54(writerCount), asc24(docs.ownerHandle), asc24(docs.appSlug)).limit(limit * HOME_FEED_SCAN_FACTOR);
162217
162296
  const display = await loadVibeDisplayInfo(vctx, candidates);
162218
162297
  const facts = await loadNewestReleaseFacts(vctx, candidates);
162219
162298
  const family = createFamilyAdmitter();
@@ -162435,7 +162514,7 @@ var init_curation_starter = __esm({
162435
162514
  // ../vibes.diy/api/svc/public/curated-new-vibes.ts
162436
162515
  import { Result as Result353, Option as Option129, EventoResult as EventoResult126 } from "@adviser/cement";
162437
162516
  import { type as type265 } from "arktype";
162438
- import { and as and211, desc as desc54, eq as eq247 } from "drizzle-orm/sql/expressions";
162517
+ import { and as and211, desc as desc55, eq as eq247 } from "drizzle-orm/sql/expressions";
162439
162518
  async function computeCuratedNewVibes(vctx, limit) {
162440
162519
  const cur = vctx.sql.tables.vibeCuration;
162441
162520
  const asb = vctx.sql.tables.appSlugBinding;
@@ -162445,7 +162524,7 @@ async function computeCuratedNewVibes(vctx, limit) {
162445
162524
  created: asb.created,
162446
162525
  approvedAt: cur.decidedAt,
162447
162526
  starter: cur.starter
162448
- }).from(cur).innerJoin(asb, and211(eq247(asb.ownerHandle, cur.ownerHandle), eq247(asb.appSlug, cur.appSlug), eq247(asb.unpublishedAt, ""))).where(eq247(cur.state, "approved")).orderBy(desc54(cur.decidedAt), desc54(cur.ownerHandle), desc54(cur.appSlug)).limit(limit * HOME_FEED_SCAN_FACTOR);
162527
+ }).from(cur).innerJoin(asb, and211(eq247(asb.ownerHandle, cur.ownerHandle), eq247(asb.appSlug, cur.appSlug), eq247(asb.unpublishedAt, ""))).where(eq247(cur.state, "approved")).orderBy(desc55(cur.decidedAt), desc55(cur.ownerHandle), desc55(cur.appSlug)).limit(limit * HOME_FEED_SCAN_FACTOR);
162449
162528
  const display = await loadVibeDisplayInfo(vctx, candidates);
162450
162529
  const facts = await loadNewestReleaseFacts(vctx, candidates);
162451
162530
  const family = createFamilyAdmitter();
@@ -162525,7 +162604,7 @@ var init_curated_new_vibes = __esm({
162525
162604
  // ../vibes.diy/api/svc/public/handle-profile-vibes.ts
162526
162605
  import { Result as Result354, Option as Option130, EventoResult as EventoResult127 } from "@adviser/cement";
162527
162606
  import { type as type266 } from "arktype";
162528
- import { and as and212, asc as asc25, desc as desc55, eq as eq248 } from "drizzle-orm/sql/expressions";
162607
+ import { and as and212, asc as asc25, desc as desc56, eq as eq248 } from "drizzle-orm/sql/expressions";
162529
162608
  async function computeHandleProfileVibes(vctx, ownerHandle, limit) {
162530
162609
  const asb = vctx.sql.tables.appSlugBinding;
162531
162610
  const batchSize = limit * HOME_FEED_SCAN_FACTOR;
@@ -162539,7 +162618,7 @@ async function computeHandleProfileVibes(vctx, ownerHandle, limit) {
162539
162618
  created: asb.created,
162540
162619
  updated: asb.updated,
162541
162620
  pinnedAt: asb.pinnedAt
162542
- }).from(asb).where(and212(eq248(asb.ownerHandle, ownerHandle), eq248(asb.unpublishedAt, ""))).orderBy(desc55(asb.pinnedAt), desc55(asb.updated), asc25(asb.appSlug)).limit(take).offset(examined);
162621
+ }).from(asb).where(and212(eq248(asb.ownerHandle, ownerHandle), eq248(asb.unpublishedAt, ""))).orderBy(desc56(asb.pinnedAt), desc56(asb.updated), asc25(asb.appSlug)).limit(take).offset(examined);
162543
162622
  examined += candidates.length;
162544
162623
  const display = await loadVibeDisplayInfo(vctx, candidates);
162545
162624
  for (const row of candidates) {
@@ -162693,7 +162772,7 @@ var init_curate_approve = __esm({
162693
162772
  import { Result as Result356, Option as Option132, EventoResult as EventoResult129 } from "@adviser/cement";
162694
162773
  import { type as type268 } from "arktype";
162695
162774
  import { cosineDistance as cosineDistance2, sql as sql42 } from "drizzle-orm";
162696
- import { and as and213, asc as asc26, desc as desc56, eq as eq249, notInArray as notInArray11, notLike as notLike4, or as or25 } from "drizzle-orm/sql/expressions";
162775
+ import { and as and213, asc as asc26, desc as desc57, eq as eq249, notInArray as notInArray11, notLike as notLike4, or as or25 } from "drizzle-orm/sql/expressions";
162697
162776
  async function computeRelatedVibes(vctx, { ownerHandle, appSlug, isOwner }) {
162698
162777
  const docs = vctx.sql.tables.appDocuments;
162699
162778
  const asb = vctx.sql.tables.appSlugBinding;
@@ -162747,7 +162826,7 @@ async function computeRelatedVibes(vctx, { ownerHandle, appSlug, isOwner }) {
162747
162826
  });
162748
162827
  }
162749
162828
  const writerCount = sql42`cast(count(distinct ${docs.userId}) as int)`;
162750
- const ownerCandidates = await vctx.sql.db.select({ ownerHandle: docs.ownerHandle, appSlug: docs.appSlug, writerCount }).from(docs).innerJoin(asb, and213(eq249(asb.ownerHandle, docs.ownerHandle), eq249(asb.appSlug, docs.appSlug), eq249(asb.unpublishedAt, ""))).where(eq249(docs.ownerHandle, ownerHandle)).groupBy(docs.ownerHandle, docs.appSlug).orderBy(desc56(writerCount), asc26(docs.appSlug)).limit(OWNER_TOP_LIMIT * HOME_FEED_SCAN_FACTOR);
162829
+ const ownerCandidates = await vctx.sql.db.select({ ownerHandle: docs.ownerHandle, appSlug: docs.appSlug, writerCount }).from(docs).innerJoin(asb, and213(eq249(asb.ownerHandle, docs.ownerHandle), eq249(asb.appSlug, docs.appSlug), eq249(asb.unpublishedAt, ""))).where(eq249(docs.ownerHandle, ownerHandle)).groupBy(docs.ownerHandle, docs.appSlug).orderBy(desc57(writerCount), asc26(docs.appSlug)).limit(OWNER_TOP_LIMIT * HOME_FEED_SCAN_FACTOR);
162751
162830
  const ownerPairs = ownerCandidates.filter(
162752
162831
  (c) => !isCurrent(c.ownerHandle, c.appSlug) && !maskedKeys.has(titleIconKey(c.ownerHandle, c.appSlug))
162753
162832
  );
@@ -164242,7 +164321,7 @@ var init_notify_remix = __esm({
164242
164321
  });
164243
164322
 
164244
164323
  // ../vibes.diy/api/svc/intern/notify-remix-clone.ts
164245
- import { and as and214, desc as desc57, eq as eq250 } from "drizzle-orm/sql/expressions";
164324
+ import { and as and214, desc as desc58, eq as eq250 } from "drizzle-orm/sql/expressions";
164246
164325
  var init_notify_remix_clone = __esm({
164247
164326
  "../vibes.diy/api/svc/intern/notify-remix-clone.ts"() {
164248
164327
  "use strict";
@@ -164382,7 +164461,7 @@ var init_notify_member_joined = __esm({
164382
164461
  });
164383
164462
 
164384
164463
  // ../vibes.diy/api/svc/intern/notify-request-pending.ts
164385
- import { and as and216, eq as eq253, gt as gt20, desc as desc58 } from "drizzle-orm/sql/expressions";
164464
+ import { and as and216, eq as eq253, gt as gt20, desc as desc59 } from "drizzle-orm/sql/expressions";
164386
164465
  async function notifyRequestPending(qctx, input) {
164387
164466
  if (input.requesterUserId === input.ownerUserId) return;
164388
164467
  const g = qctx.sql.tables.requestGrants;
@@ -164399,7 +164478,7 @@ async function notifyRequestPending(qctx, input) {
164399
164478
  eq253(t.actorUserId, input.requesterUserId),
164400
164479
  gt20(t.created, cutoff)
164401
164480
  )
164402
- ).orderBy(desc58(t.created)).limit(1).then((r) => r[0]);
164481
+ ).orderBy(desc59(t.created)).limit(1).then((r) => r[0]);
164403
164482
  if (recent !== void 0) return;
164404
164483
  const label = input.requesterLabel?.trim() ? input.requesterLabel.trim() : "Someone";
164405
164484
  const day = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
@@ -170924,7 +171003,7 @@ var init_channel_invite_email = __esm({
170924
171003
  });
170925
171004
 
170926
171005
  // ../vibes.diy/api/queue/intern/mail-screenshot.ts
170927
- import { and as and222, desc as desc59, eq as eq260 } from "drizzle-orm/sql/expressions";
171006
+ import { and as and222, desc as desc60, eq as eq260 } from "drizzle-orm/sql/expressions";
170928
171007
  function toBase64(bytes) {
170929
171008
  const CHUNK = 32768;
170930
171009
  let binary = "";
@@ -170944,7 +171023,7 @@ function mailScreenshotCid(ownerHandle, appSlug) {
170944
171023
  async function loadMailScreenshot(ctx, app) {
170945
171024
  const { ownerUserId, ownerHandle, appSlug } = app;
170946
171025
  const t = ctx.sql.tables.apps;
170947
- const row = await ctx.sql.db.select({ meta: t.meta }).from(t).where(and222(eq260(t.userId, ownerUserId), eq260(t.ownerHandle, ownerHandle), eq260(t.appSlug, appSlug), eq260(t.mode, "production"))).orderBy(desc59(t.releaseSeq)).limit(1).then((r) => r[0]);
171026
+ const row = await ctx.sql.db.select({ meta: t.meta }).from(t).where(and222(eq260(t.userId, ownerUserId), eq260(t.ownerHandle, ownerHandle), eq260(t.appSlug, appSlug), eq260(t.mode, "production"))).orderBy(desc60(t.releaseSeq)).limit(1).then((r) => r[0]);
170948
171027
  if (row === void 0) return void 0;
170949
171028
  const { filtered: meta } = parseArrayWarning(row.meta, MetaItem);
170950
171029
  const shot = await loadStoredScreenshot({ storage: ctx.storage }, meta);