vibes-diy 14.3.340 → 14.3.341

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.
@@ -80724,10 +80724,10 @@ function extractAssetSessionCookie(req2) {
80724
80724
  if (!header) return void 0;
80725
80725
  for (const pair of header.split(";")) {
80726
80726
  const trimmed2 = pair.trim();
80727
- const eq252 = trimmed2.indexOf("=");
80728
- if (eq252 <= 0) continue;
80729
- if (trimmed2.slice(0, eq252) === COOKIE_NAME) {
80730
- return trimmed2.slice(eq252 + 1);
80727
+ const eq253 = trimmed2.indexOf("=");
80728
+ if (eq253 <= 0) continue;
80729
+ if (trimmed2.slice(0, eq253) === COOKIE_NAME) {
80730
+ return trimmed2.slice(eq253 + 1);
80731
80731
  }
80732
80732
  }
80733
80733
  return void 0;
@@ -107985,6 +107985,38 @@ var init_import_synth = __esm({
107985
107985
  }
107986
107986
  });
107987
107987
 
107988
+ // ../vibes.diy/api/svc/intern/backend-path-finding.ts
107989
+ function maskComments(source) {
107990
+ return source.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/(^|\s)\/\/[^\n]*/g, "$1");
107991
+ }
107992
+ function isClientCode(path2) {
107993
+ return /\.(jsx?|tsx?)$/.test(path2) && path2 !== "/backend.js" && path2 !== "/access.js";
107994
+ }
107995
+ function sameOriginApiFinding(args) {
107996
+ if (args.backendHandlers.includes("fetch") === false) return void 0;
107997
+ for (const file of args.changes) {
107998
+ if (isClientCode(file.path) === false) continue;
107999
+ const match = SAME_ORIGIN_API.exec(maskComments(file.contents));
108000
+ if (match !== null) return { path: file.path, literal: match[2] };
108001
+ }
108002
+ return void 0;
108003
+ }
108004
+ function sameOriginApiMessage(finding) {
108005
+ const fixed = finding.literal.replace(/^\/api\//, "/_api/");
108006
+ return `${finding.path}: calls "${finding.literal}", but backend.js answers at the app's /_api/ URL, so this call gets the app's HTML page and no data. Call "${fixed}" instead.`;
108007
+ }
108008
+ var SAME_ORIGIN_API;
108009
+ var init_backend_path_finding = __esm({
108010
+ "../vibes.diy/api/svc/intern/backend-path-finding.ts"() {
108011
+ "use strict";
108012
+ SAME_ORIGIN_API = /(["'`])(\/api\/[^"'`\s$?#]*)/;
108013
+ __name(maskComments, "maskComments");
108014
+ __name(isClientCode, "isClientCode");
108015
+ __name(sameOriginApiFinding, "sameOriginApiFinding");
108016
+ __name(sameOriginApiMessage, "sameOriginApiMessage");
108017
+ }
108018
+ });
108019
+
107988
108020
  // ../vibes.diy/api/svc/intern/egress-cors.ts
107989
108021
  function isForbiddenHeaderName(name) {
107990
108022
  const n2 = name.toLowerCase();
@@ -108444,10 +108476,10 @@ function parseCacheControl(res) {
108444
108476
  for (const token of (res.headers.get("cache-control") ?? "").split(",")) {
108445
108477
  const trimmed2 = token.trim();
108446
108478
  if (trimmed2.length === 0) continue;
108447
- const eq252 = trimmed2.indexOf("=");
108448
- const name = (eq252 < 0 ? trimmed2 : trimmed2.slice(0, eq252)).trim().toLowerCase();
108479
+ const eq253 = trimmed2.indexOf("=");
108480
+ const name = (eq253 < 0 ? trimmed2 : trimmed2.slice(0, eq253)).trim().toLowerCase();
108449
108481
  if (name.length === 0) continue;
108450
- const arg = eq252 < 0 ? "" : trimmed2.slice(eq252 + 1).trim().replace(/^"|"$/g, "");
108482
+ const arg = eq253 < 0 ? "" : trimmed2.slice(eq253 + 1).trim().replace(/^"|"$/g, "");
108451
108483
  if (!directives.has(name)) directives.set(name, arg);
108452
108484
  }
108453
108485
  return directives;
@@ -111220,6 +111252,8 @@ async function validateAgentFiles(vctx, args) {
111220
111252
  "backend",
111221
111253
  "backend.js runs through a top-level `export async function fetch(request, ctx)`, `scheduled`, `onChange` or an `export const tools = { \u2026 }`; this file exports none of them, so nothing would answer."
111222
111254
  );
111255
+ const apiPath = sameOriginApiFinding({ backendHandlers: parsed.handlers, changes: args.changes });
111256
+ if (apiPath !== void 0) return refuse12("backend", sameOriginApiMessage(apiPath));
111223
111257
  }
111224
111258
  const access4 = args.vfs.get("/access.js");
111225
111259
  if (access4 !== void 0 && args.changes.some((file) => file.path === "/access.js")) {
@@ -111282,6 +111316,7 @@ var init_agent_file_validation = __esm({
111282
111316
  init_lazy_type();
111283
111317
  init_types3();
111284
111318
  init_parse_backend_config();
111319
+ init_backend_path_finding();
111285
111320
  init_work_tools();
111286
111321
  init_access_function2();
111287
111322
  init_process_access_bindings();
@@ -117146,7 +117181,7 @@ async function resendChatSectionsPrevMsg(args) {
117146
117181
  }
117147
117182
  async function* readChatReplaySections(vctx, args) {
117148
117183
  const rows = await vctx.sql.db.select().from(vctx.sql.tables.chatSections).where(selectedChatTurns(vctx, args.chatId, args.promptIds)).orderBy(vctx.sql.tables.chatSections.created, vctx.sql.tables.chatSections.promptId, vctx.sql.tables.chatSections.blockSeq);
117149
- const sections = rows.map((row) => ({ ...row, blocks: expandChatSectionBlocks(row.blocks) }));
117184
+ const sections = rows;
117150
117185
  const promptContextRows = await vctx.sql.db.select({ promptId: vctx.sql.tables.promptContexts.promptId, ref: vctx.sql.tables.promptContexts.ref }).from(vctx.sql.tables.promptContexts).where(
117151
117186
  and127(
117152
117187
  eq150(vctx.sql.tables.promptContexts.chatId, args.chatId),
@@ -117174,7 +117209,7 @@ async function* readChatReplaySections(vctx, args) {
117174
117209
  const receipts = args.promptIds === void 0 ? /* @__PURE__ */ new Set() : receiptReplayTurnIds(sections.map((section) => ({ promptId: section.promptId, blocks: section.blocks })));
117175
117210
  const openedReceipts = /* @__PURE__ */ new Set();
117176
117211
  for (const section of sections) {
117177
- const { filtered: parsedBlocks, warning } = parseArrayWarning(section.blocks, PromptAndBlockMsgs);
117212
+ const { filtered: parsedBlocks, warning } = parseArrayWarning(expandChatSectionBlocks(section.blocks), PromptAndBlockMsgs);
117178
117213
  const blocks = parsedBlocks.filter((block) => !isPromptResearch(block));
117179
117214
  if (warning.length > 0) {
117180
117215
  ensureLogger(vctx.sthis, "resendChatSectionsPrevMsg").Warn().Any({ parseErrors: warning }).Msg("skip");
@@ -118404,6 +118439,7 @@ var init_shared_prefix_cache = __esm({
118404
118439
 
118405
118440
  // ../vibes.diy/api/svc/intern/history-section-msgs.ts
118406
118441
  import { type as type154 } from "arktype";
118442
+ import { and as and130, eq as eq154, inArray as inArray43, ne as ne20 } from "drizzle-orm/sql/expressions";
118407
118443
  function historySectionMsgs(blocks) {
118408
118444
  const msgs = [];
118409
118445
  const warning = [];
@@ -118422,17 +118458,115 @@ function historySectionMsgs(blocks) {
118422
118458
  });
118423
118459
  return { msgs, warning };
118424
118460
  }
118461
+ function isCodeSummaryMsg(msg) {
118462
+ return typeof msg === "object" && msg !== null && msg.type === "history.code.summary";
118463
+ }
118464
+ async function readChatHistory(vctx, chatId, opts) {
118465
+ const t = vctx.sql.tables.chatSections;
118466
+ const pageRows = opts.pageRows ?? HISTORY_PAGE_ROWS;
118467
+ const reducer = historyReducer(opts.compact);
118468
+ const keys = await vctx.sql.db.select({ promptId: t.promptId, blockSeq: t.blockSeq, created: t.created }).from(t).where(and130(eq154(t.chatId, chatId), ne20(t.blockSeq, RESEARCH_BLOCK_SEQ)));
118469
+ keys.sort(compareSectionKeys);
118470
+ for (let start = 0; start < keys.length; start += pageRows) {
118471
+ const pageKeys = keys.slice(start, start + pageRows);
118472
+ const want = new Set(pageKeys.map(sectionKey));
118473
+ const rows = await vctx.sql.db.select({ promptId: t.promptId, blockSeq: t.blockSeq, blocks: t.blocks }).from(t).where(
118474
+ and130(
118475
+ eq154(t.chatId, chatId),
118476
+ inArray43(t.promptId, [...new Set(pageKeys.map((k) => k.promptId))]),
118477
+ inArray43(t.blockSeq, [...new Set(pageKeys.map((k) => k.blockSeq))])
118478
+ )
118479
+ );
118480
+ const byKey = /* @__PURE__ */ new Map();
118481
+ for (const row of rows) {
118482
+ const key = sectionKey(row);
118483
+ if (want.has(key)) byKey.set(key, row.blocks);
118484
+ }
118485
+ for (const k of pageKeys) {
118486
+ const { msgs, warning } = historySectionMsgs(byKey.get(sectionKey(k)));
118487
+ if (warning.length > 0) opts.onWarning?.(warning);
118488
+ for (const msg of msgs) reducer.push(msg);
118489
+ }
118490
+ }
118491
+ return reducer.done();
118492
+ }
118493
+ function sectionKey(k) {
118494
+ return `${k.promptId}\0${k.blockSeq}`;
118495
+ }
118496
+ function compareSectionKeys(a, b) {
118497
+ if (a.created !== b.created) return a.created < b.created ? -1 : 1;
118498
+ if (a.promptId !== b.promptId) return a.promptId < b.promptId ? -1 : 1;
118499
+ return a.blockSeq - b.blockSeq;
118500
+ }
118501
+ function keepForHistory(msg) {
118502
+ return isPromptReq(msg) || isToplevelLine(msg) || isCodeBegin(msg) || isCodeEnd(msg) || isCodeLine(msg) || isCodeLinesMsg(msg) || isPromptAgentEvidence(msg) && msg.evidence.kind === "active";
118503
+ }
118504
+ function historyReducer(compact) {
118505
+ const out = [];
118506
+ let inBlock = false;
118507
+ let summary;
118508
+ function line2(text3) {
118509
+ summary ??= { lineCount: 0, hunkCount: 0 };
118510
+ summary.lineCount++;
118511
+ const trimmed2 = text3.trim();
118512
+ if (trimmed2 === "<<<<<<< SEARCH") summary.hunkCount++;
118513
+ if (summary.firstNonBlank === void 0 && trimmed2.length > 0) summary.firstNonBlank = trimmed2;
118514
+ }
118515
+ __name(line2, "line");
118516
+ function flush3() {
118517
+ if (summary === void 0) return;
118518
+ out.push({ type: "history.code.summary", ...summary });
118519
+ summary = void 0;
118520
+ }
118521
+ __name(flush3, "flush");
118522
+ return {
118523
+ push(msg) {
118524
+ if (!keepForHistory(msg)) return;
118525
+ if (compact && inBlock) {
118526
+ if (isCodeLinesMsg(msg)) {
118527
+ for (const l of msg.lines) line2(l);
118528
+ return;
118529
+ }
118530
+ if (isCodeLine(msg)) {
118531
+ line2(msg.line);
118532
+ return;
118533
+ }
118534
+ }
118535
+ if (compact && isCodeBegin(msg)) {
118536
+ flush3();
118537
+ inBlock = true;
118538
+ } else if (compact && isCodeEnd(msg)) {
118539
+ flush3();
118540
+ inBlock = false;
118541
+ }
118542
+ out.push(msg);
118543
+ },
118544
+ done() {
118545
+ flush3();
118546
+ return out;
118547
+ }
118548
+ };
118549
+ }
118550
+ var HISTORY_PAGE_ROWS;
118425
118551
  var init_history_section_msgs = __esm({
118426
118552
  "../vibes.diy/api/svc/intern/history-section-msgs.ts"() {
118427
118553
  "use strict";
118428
118554
  init_types3();
118555
+ init_v2();
118429
118556
  __name(historySectionMsgs, "historySectionMsgs");
118557
+ __name(isCodeSummaryMsg, "isCodeSummaryMsg");
118558
+ HISTORY_PAGE_ROWS = 200;
118559
+ __name(readChatHistory, "readChatHistory");
118560
+ __name(sectionKey, "sectionKey");
118561
+ __name(compareSectionKeys, "compareSectionKeys");
118562
+ __name(keepForHistory, "keepForHistory");
118563
+ __name(historyReducer, "historyReducer");
118430
118564
  }
118431
118565
  });
118432
118566
 
118433
118567
  // ../vibes.diy/api/svc/intern/prompt-assembly.ts
118434
118568
  import { Result as Result175, exception2Result as exception2Result243 } from "@adviser/cement";
118435
- import { and as and130, eq as eq154, ne as ne20 } from "drizzle-orm/sql/expressions";
118569
+ import { and as and131, eq as eq155 } from "drizzle-orm/sql/expressions";
118436
118570
  function escapeAttrValue(value) {
118437
118571
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
118438
118572
  }
@@ -118481,6 +118615,14 @@ function reconstructConversationMessages(sectionMsgs, opts = {}) {
118481
118615
  for (const line2 of msg.lines) codeLine(line2);
118482
118616
  continue;
118483
118617
  }
118618
+ if (isCodeSummaryMsg(msg)) {
118619
+ if (blockBuffer) {
118620
+ blockBuffer.lineCount += msg.lineCount;
118621
+ blockBuffer.hunkCount += msg.hunkCount;
118622
+ if (!blockBuffer.firstNonBlank && msg.firstNonBlank !== void 0) blockBuffer.firstNonBlank = msg.firstNonBlank;
118623
+ }
118624
+ continue;
118625
+ }
118484
118626
  switch (true) {
118485
118627
  case isPromptReq(msg): {
118486
118628
  const users = msg.request.messages.filter(isUserChatMessage);
@@ -118566,7 +118708,7 @@ async function loadActiveSettings(vctx, chatId) {
118566
118708
  () => vctx.sql.db.select({
118567
118709
  appSlug: vctx.sql.tables.chatContexts.appSlug,
118568
118710
  ownerHandle: vctx.sql.tables.chatContexts.ownerHandle
118569
- }).from(vctx.sql.tables.chatContexts).where(eq154(vctx.sql.tables.chatContexts.chatId, chatId)).limit(1).then((r) => r[0])
118711
+ }).from(vctx.sql.tables.chatContexts).where(eq155(vctx.sql.tables.chatContexts.chatId, chatId)).limit(1).then((r) => r[0])
118570
118712
  );
118571
118713
  if (rChat.isErr() || !rChat.Ok()) return {};
118572
118714
  const { appSlug, ownerHandle } = rChat.Ok();
@@ -118663,7 +118805,7 @@ async function loadChatOwnerAndResearch(vctx, chatId, userId) {
118663
118805
  userId: vctx.sql.tables.chatContexts.userId,
118664
118806
  ownerHandle: vctx.sql.tables.chatContexts.ownerHandle,
118665
118807
  appSlug: vctx.sql.tables.chatContexts.appSlug
118666
- }).from(vctx.sql.tables.chatContexts).where(eq154(vctx.sql.tables.chatContexts.chatId, chatId)).limit(1).then((rows) => rows[0]);
118808
+ }).from(vctx.sql.tables.chatContexts).where(eq155(vctx.sql.tables.chatContexts.chatId, chatId)).limit(1).then((rows) => rows[0]);
118667
118809
  if (userId !== void 0 && chatOwner !== void 0 && chatOwner.userId !== userId) {
118668
118810
  return { kind: "not-owned" };
118669
118811
  }
@@ -118673,8 +118815,13 @@ async function loadChatOwnerAndResearch(vctx, chatId, userId) {
118673
118815
  async function assemblePromptPayload(vctx, args) {
118674
118816
  const { chatId, model, newUserMessages } = args;
118675
118817
  const [sSections, sTimeline, sStored, sOwner, sActive] = await Promise.all([
118818
+ // Paged and reduced as it is read, so a long chat's rows are never all in
118819
+ // memory at once (history-section-msgs.ts `readChatHistory`).
118676
118820
  settleRead(
118677
- vctx.sql.db.select().from(vctx.sql.tables.chatSections).where(and130(eq154(vctx.sql.tables.chatSections.chatId, chatId), ne20(vctx.sql.tables.chatSections.blockSeq, RESEARCH_BLOCK_SEQ))).orderBy(vctx.sql.tables.chatSections.created)
118821
+ readChatHistory(vctx, chatId, {
118822
+ compact: args.slots?.compaction !== "off",
118823
+ onWarning: /* @__PURE__ */ __name((parseErrors) => ensureLogger(vctx.sthis, "assemblePromptPayload").Warn().Any({ parseErrors }).Msg("skip"), "onWarning")
118824
+ })
118678
118825
  ),
118679
118826
  // #6870: the timeline is metadata; only the versions rendered below (the
118680
118827
  // slot sources and a `selected` version) have their contents fetched.
@@ -118684,16 +118831,7 @@ async function assemblePromptPayload(vctx, args) {
118684
118831
  settleRead(loadActiveSettings(vctx, chatId))
118685
118832
  ]);
118686
118833
  if (sSections.isErr()) return Result175.Err(sSections.Err());
118687
- const sections = sSections.Ok().value;
118688
- const allSectionMsgs = [];
118689
- for (const rowSection of sections) {
118690
- const { msgs: parsedSectionMsgs, warning: sectionWarning } = historySectionMsgs(rowSection.blocks);
118691
- const sectionMsgs = parsedSectionMsgs.filter((block) => !isPromptResearch(block) && !isPromptStatus(block));
118692
- if (sectionWarning.length > 0) {
118693
- ensureLogger(vctx.sthis, "assemblePromptPayload").Warn().Any({ parseErrors: sectionWarning }).Msg("skip");
118694
- }
118695
- allSectionMsgs.push(...sectionMsgs);
118696
- }
118834
+ const allSectionMsgs = sSections.Ok().value;
118697
118835
  if (sTimeline.isErr()) return Result175.Err(sTimeline.Err());
118698
118836
  const timelineResult = sTimeline.Ok().value;
118699
118837
  if (timelineResult.isErr()) return Result175.Err(timelineResult);
@@ -118978,7 +119116,7 @@ This is the app's owner, the person building it. Seed records are written as thi
118978
119116
  async function persistCodegenThemeMarker(vctx, args) {
118979
119117
  const t = vctx.sql.tables.appSettings;
118980
119118
  const key = { userId: args.userId, ownerHandle: args.ownerHandle, appSlug: args.appSlug };
118981
- const existing = await vctx.sql.db.select({ userId: t.userId }).from(t).where(and130(eq154(t.appSlug, args.appSlug), eq154(t.ownerHandle, args.ownerHandle), eq154(t.userId, args.userId))).limit(1).then((r) => r[0]);
119119
+ const existing = await vctx.sql.db.select({ userId: t.userId }).from(t).where(and131(eq155(t.appSlug, args.appSlug), eq155(t.ownerHandle, args.ownerHandle), eq155(t.userId, args.userId))).limit(1).then((r) => r[0]);
118982
119120
  if (existing === void 0) return;
118983
119121
  const filtered = await readComposedSettings(vctx, key);
118984
119122
  const markedTheme = filtered.findLast(isActiveCodegenTheme)?.theme;
@@ -118994,7 +119132,7 @@ async function persistCodegenThemeMarker(vctx, args) {
118994
119132
  async function persistCodegenVarietyMarker(vctx, args) {
118995
119133
  const t = vctx.sql.tables.appSettings;
118996
119134
  const key = { userId: args.userId, ownerHandle: args.ownerHandle, appSlug: args.appSlug };
118997
- const existing = await vctx.sql.db.select({ userId: t.userId }).from(t).where(and130(eq154(t.appSlug, args.appSlug), eq154(t.ownerHandle, args.ownerHandle), eq154(t.userId, args.userId))).limit(1).then((r) => r[0]);
119135
+ const existing = await vctx.sql.db.select({ userId: t.userId }).from(t).where(and131(eq155(t.appSlug, args.appSlug), eq155(t.ownerHandle, args.ownerHandle), eq155(t.userId, args.userId))).limit(1).then((r) => r[0]);
118998
119136
  if (existing === void 0) return;
118999
119137
  const filtered = await readComposedSettings(vctx, key);
119000
119138
  const marked = filtered.findLast(isActiveCodegenVariety);
@@ -119076,14 +119214,14 @@ var init_prompt_assembly = __esm({
119076
119214
 
119077
119215
  // ../vibes.diy/api/svc/intern/bump-app-recency.ts
119078
119216
  import { exception2Result as exception2Result244 } from "@adviser/cement";
119079
- import { and as and131, eq as eq155 } from "drizzle-orm/sql/expressions";
119217
+ import { and as and132, eq as eq156 } from "drizzle-orm/sql/expressions";
119080
119218
  async function bumpAppRecency(vctx, args) {
119081
119219
  return exception2Result244(async () => {
119082
119220
  const ts = args.ts ?? (/* @__PURE__ */ new Date()).toISOString();
119083
119221
  await vctx.sql.db.update(vctx.sql.tables.appSlugBinding).set({ updated: ts }).where(
119084
- and131(
119085
- eq155(vctx.sql.tables.appSlugBinding.ownerHandle, args.ownerHandle),
119086
- eq155(vctx.sql.tables.appSlugBinding.appSlug, args.appSlug)
119222
+ and132(
119223
+ eq156(vctx.sql.tables.appSlugBinding.ownerHandle, args.ownerHandle),
119224
+ eq156(vctx.sql.tables.appSlugBinding.appSlug, args.appSlug)
119087
119225
  )
119088
119226
  );
119089
119227
  });
@@ -119154,7 +119292,7 @@ var init_chat_persist_gate = __esm({
119154
119292
 
119155
119293
  // ../vibes.diy/api/svc/intern/client-message-dedupe.ts
119156
119294
  import { exception2Result as exception2Result245, Future as Future3, Result as Result177 } from "@adviser/cement";
119157
- import { and as and132, eq as eq156, like as like5, sql as sql27 } from "drizzle-orm";
119295
+ import { and as and133, eq as eq157, like as like5, sql as sql27 } from "drizzle-orm";
119158
119296
  function keyOf2(chatId, clientMessageId) {
119159
119297
  return `${chatId}\0${clientMessageId}`;
119160
119298
  }
@@ -119174,7 +119312,7 @@ function remember(args) {
119174
119312
  async function findAcceptedClientMessage(args) {
119175
119313
  const t = args.sql.tables.chatSections;
119176
119314
  const rRows = await exception2Result245(
119177
- () => args.sql.db.select({ promptId: t.promptId, blocks: t.blocks }).from(t).where(and132(eq156(t.chatId, args.chatId), like5(sql27`CAST(${t.blocks} AS TEXT)`, `%${args.clientMessageId}%`)))
119315
+ () => args.sql.db.select({ promptId: t.promptId, blocks: t.blocks }).from(t).where(and133(eq157(t.chatId, args.chatId), like5(sql27`CAST(${t.blocks} AS TEXT)`, `%${args.clientMessageId}%`)))
119178
119316
  );
119179
119317
  if (rRows.isErr()) return Result177.Err(rRows);
119180
119318
  for (const row of rRows.Ok()) {
@@ -119836,11 +119974,11 @@ var init_append_block_event = __esm({
119836
119974
 
119837
119975
  // ../vibes.diy/api/svc/public/auto-publish-on-persist.ts
119838
119976
  import { exception2Result as exception2Result250 } from "@adviser/cement";
119839
- import { eq as eq157 } from "drizzle-orm/sql/expressions";
119977
+ import { eq as eq158 } from "drizzle-orm/sql/expressions";
119840
119978
  async function autoPublishOnPersist(vctx, args) {
119841
119979
  const rMint = await exception2Result250(async () => {
119842
119980
  const hb = vctx.sql.tables.handleBinding;
119843
- const ownerRow = await vctx.sql.db.select({ userId: hb.userId }).from(hb).where(eq157(hb.handle, args.ownerHandle)).limit(1).then((r) => r[0]);
119981
+ const ownerRow = await vctx.sql.db.select({ userId: hb.userId }).from(hb).where(eq158(hb.handle, args.ownerHandle)).limit(1).then((r) => r[0]);
119844
119982
  if (ownerRow === void 0 || ownerRow.userId !== args.callerUserId) {
119845
119983
  vctx.logger.Debug().Any("event", { ownerHandle: args.ownerHandle, appSlug: args.appSlug, promptId: args.promptId }).Msg("auto-publish-mint-skipped-not-owner");
119846
119984
  return;
@@ -119902,7 +120040,7 @@ var init_usage_rounds = __esm({
119902
120040
  // ../vibes.diy/api/svc/intern/turn-credit-back.ts
119903
120041
  import { exception2Result as exception2Result251, Result as Result181 } from "@adviser/cement";
119904
120042
  import { type as type155 } from "arktype";
119905
- import { and as and133, eq as eq158, gte as gte4 } from "drizzle-orm";
120043
+ import { and as and134, eq as eq159, gte as gte4 } from "drizzle-orm";
119906
120044
  function chargedCredits(o) {
119907
120045
  const tracked = Math.max(0, Math.floor(o.trackedCredits));
119908
120046
  if (Number.isFinite(o.remainingBefore) === false) return 0;
@@ -119911,7 +120049,7 @@ function chargedCredits(o) {
119911
120049
  async function stampTurnCharge(sql43, args) {
119912
120050
  if (args.credits <= 0) return Result181.Ok(void 0);
119913
120051
  const pc = sql43.tables.promptContexts;
119914
- const where = and133(eq158(pc.promptId, args.promptId), eq158(pc.userId, args.userId));
120052
+ const where = and134(eq159(pc.promptId, args.promptId), eq159(pc.userId, args.userId));
119915
120053
  const charge = { userId: args.payerUserId ?? args.userId, credits: args.credits, at: new Date(args.nowMs).toISOString() };
119916
120054
  const written = await exception2Result251(
119917
120055
  () => sql43.db.update(pc).set({ ref: refWithKey({ flavour: sql43.flavour, refColumn: pc.ref, key: "charge", value: charge }) }).where(where)
@@ -119969,7 +120107,7 @@ var init_free_repair_builds = __esm({
119969
120107
  // ../vibes.diy/api/svc/intern/persist-url-research.ts
119970
120108
  import { exception2Result as exception2Result252, Result as Result182 } from "@adviser/cement";
119971
120109
  import { type as type156 } from "arktype";
119972
- import { and as and134, eq as eq159 } from "drizzle-orm/sql/expressions";
120110
+ import { and as and135, eq as eq160 } from "drizzle-orm/sql/expressions";
119973
120111
  function pointerForEvent(event) {
119974
120112
  const parsed = ResearchPointer({
119975
120113
  researchId: event.researchId,
@@ -119981,7 +120119,7 @@ function pointerForEvent(event) {
119981
120119
  }
119982
120120
  async function ownsChat({ db, vctx, userId, chatId }) {
119983
120121
  const t = vctx.sql.tables.chatContexts;
119984
- const row = await db.select({ chatId: t.chatId }).from(t).where(and134(eq159(t.userId, userId), eq159(t.chatId, chatId))).limit(1).then((rows) => rows[0]);
120122
+ const row = await db.select({ chatId: t.chatId }).from(t).where(and135(eq160(t.userId, userId), eq160(t.chatId, chatId))).limit(1).then((rows) => rows[0]);
119985
120123
  return row !== void 0;
119986
120124
  }
119987
120125
  function storedEventMatchesScope(event, args) {
@@ -119990,12 +120128,12 @@ function storedEventMatchesScope(event, args) {
119990
120128
  async function readResearchEvent(db, vctx, args) {
119991
120129
  const sections = vctx.sql.tables.chatSections;
119992
120130
  const chats = vctx.sql.tables.chatContexts;
119993
- const row = await db.select({ blocks: sections.blocks }).from(chats).innerJoin(sections, eq159(sections.chatId, chats.chatId)).where(
119994
- and134(
119995
- eq159(chats.userId, args.userId),
119996
- eq159(chats.chatId, args.chatId),
119997
- eq159(sections.promptId, args.promptId),
119998
- eq159(sections.blockSeq, RESEARCH_BLOCK_SEQ)
120131
+ const row = await db.select({ blocks: sections.blocks }).from(chats).innerJoin(sections, eq160(sections.chatId, chats.chatId)).where(
120132
+ and135(
120133
+ eq160(chats.userId, args.userId),
120134
+ eq160(chats.chatId, args.chatId),
120135
+ eq160(sections.promptId, args.promptId),
120136
+ eq160(sections.blockSeq, RESEARCH_BLOCK_SEQ)
119999
120137
  )
120000
120138
  ).limit(1).then((rows) => rows[0]);
120001
120139
  if (row === void 0) return void 0;
@@ -120012,7 +120150,7 @@ async function attachStoredResearchPointerWithDb(input) {
120012
120150
  if (pointerResult.isErr()) return Result182.Err(pointerResult);
120013
120151
  const pointer = pointerResult.Ok();
120014
120152
  const t = vctx.sql.tables.promptContexts;
120015
- const row = await db.select({ ref: t.ref }).from(t).where(and134(eq159(t.userId, args.userId), eq159(t.chatId, args.chatId), eq159(t.promptId, args.promptId))).limit(1).then((rows) => rows[0]);
120153
+ const row = await db.select({ ref: t.ref }).from(t).where(and135(eq160(t.userId, args.userId), eq160(t.chatId, args.chatId), eq160(t.promptId, args.promptId))).limit(1).then((rows) => rows[0]);
120016
120154
  if (row === void 0) return Result182.Ok({ attached: false });
120017
120155
  const parsedRef = PromptContextSql(row.ref);
120018
120156
  if (parsedRef instanceof type156.errors) return Result182.Err("prompt_context_ref_invalid");
@@ -120024,7 +120162,7 @@ async function attachStoredResearchPointerWithDb(input) {
120024
120162
  }
120025
120163
  const nextRef = PromptContextSql({ ...parsedRef, research: pointer });
120026
120164
  if (nextRef instanceof type156.errors) return Result182.Err("prompt_context_ref_invalid");
120027
- await db.update(t).set({ ref: refWithKey({ flavour: vctx.sql.flavour, refColumn: t.ref, key: "research", value: pointer }) }).where(and134(eq159(t.userId, args.userId), eq159(t.chatId, args.chatId), eq159(t.promptId, args.promptId)));
120165
+ await db.update(t).set({ ref: refWithKey({ flavour: vctx.sql.flavour, refColumn: t.ref, key: "research", value: pointer }) }).where(and135(eq160(t.userId, args.userId), eq160(t.chatId, args.chatId), eq160(t.promptId, args.promptId)));
120028
120166
  return Result182.Ok({ attached: true });
120029
120167
  }
120030
120168
  async function reconcileResearchPointer(vctx, args) {
@@ -120057,7 +120195,7 @@ var init_persist_url_research = __esm({
120057
120195
  // ../vibes.diy/api/svc/intern/chat-only-claim.ts
120058
120196
  import { exception2Result as exception2Result253, Result as Result183 } from "@adviser/cement";
120059
120197
  import { type as type157 } from "arktype";
120060
- import { and as and135, eq as eq160, inArray as inArray43, isNull as isNull11 } from "drizzle-orm/sql/expressions";
120198
+ import { and as and136, eq as eq161, inArray as inArray44, isNull as isNull11 } from "drizzle-orm/sql/expressions";
120061
120199
  function chatOnlyAddressRecord(appSlug) {
120062
120200
  return { chatOnlyAppSlug: appSlug };
120063
120201
  }
@@ -120104,7 +120242,7 @@ async function claimChatOnlyAddress(vctx, args) {
120104
120242
  const cc = vctx.sql.tables.chatContexts;
120105
120243
  const mj = vctx.sql.tables.mintJobs;
120106
120244
  const rChat = await exception2Result253(
120107
- () => vctx.sql.db.select({ userId: cc.userId, ownerHandle: cc.ownerHandle, appSlug: cc.appSlug, draftPreAlloc: cc.draftPreAlloc }).from(cc).where(eq160(cc.chatId, args.chatId)).limit(1).then((r) => r[0])
120245
+ () => vctx.sql.db.select({ userId: cc.userId, ownerHandle: cc.ownerHandle, appSlug: cc.appSlug, draftPreAlloc: cc.draftPreAlloc }).from(cc).where(eq161(cc.chatId, args.chatId)).limit(1).then((r) => r[0])
120108
120246
  );
120109
120247
  if (rChat.isErr()) return Result183.Err(rChat);
120110
120248
  const chat = rChat.Ok();
@@ -120114,7 +120252,7 @@ async function claimChatOnlyAddress(vctx, args) {
120114
120252
  if (claimed !== void 0) {
120115
120253
  if (claimed === chat.appSlug && job.appSlug !== claimed) {
120116
120254
  const rFix = await exception2Result253(
120117
- () => vctx.sql.db.update(mj).set({ appSlug: claimed, updated: (/* @__PURE__ */ new Date()).toISOString() }).where(and135(eq160(mj.chatId, args.chatId), inArray43(mj.status, [...CHAT_ONLY_CLAIM_FROM])))
120255
+ () => vctx.sql.db.update(mj).set({ appSlug: claimed, updated: (/* @__PURE__ */ new Date()).toISOString() }).where(and136(eq161(mj.chatId, args.chatId), inArray44(mj.status, [...CHAT_ONLY_CLAIM_FROM])))
120118
120256
  );
120119
120257
  if (rFix.isErr()) log.Warn().Err(rFix).Str("chatId", args.chatId).Msg("chat-only claim: job reconcile failed");
120120
120258
  else log.Info().Str("chatId", args.chatId).Str("appSlug", claimed).Msg("chat-only claim: job reconciled");
@@ -120135,12 +120273,12 @@ async function claimChatOnlyAddress(vctx, args) {
120135
120273
  let lost = false;
120136
120274
  const rMove = await exception2Result253(
120137
120275
  () => vctx.sql.db.transaction(async (tx) => {
120138
- const movedJob = await tx.update(mj).set({ appSlug, updated: (/* @__PURE__ */ new Date()).toISOString() }).where(and135(eq160(mj.chatId, args.chatId), inArray43(mj.status, [...CHAT_ONLY_CLAIM_FROM]), eq160(mj.appSlug, provisional))).returning({ chatId: mj.chatId });
120276
+ const movedJob = await tx.update(mj).set({ appSlug, updated: (/* @__PURE__ */ new Date()).toISOString() }).where(and136(eq161(mj.chatId, args.chatId), inArray44(mj.status, [...CHAT_ONLY_CLAIM_FROM]), eq161(mj.appSlug, provisional))).returning({ chatId: mj.chatId });
120139
120277
  if (movedJob.length === 0) {
120140
120278
  lost = true;
120141
120279
  throw new ChatOnlyClaimLostError("job row moved on");
120142
120280
  }
120143
- const movedChat = await tx.update(cc).set({ appSlug, draftPreAlloc: chatOnlyAddressRecord(appSlug) }).where(and135(eq160(cc.chatId, args.chatId), eq160(cc.appSlug, provisional), isNull11(cc.draftPreAlloc))).returning({ chatId: cc.chatId });
120281
+ const movedChat = await tx.update(cc).set({ appSlug, draftPreAlloc: chatOnlyAddressRecord(appSlug) }).where(and136(eq161(cc.chatId, args.chatId), eq161(cc.appSlug, provisional), isNull11(cc.draftPreAlloc))).returning({ chatId: cc.chatId });
120144
120282
  if (movedChat.length === 0) {
120145
120283
  lost = true;
120146
120284
  throw new ChatOnlyClaimLostError("chat row moved on");
@@ -120150,7 +120288,7 @@ async function claimChatOnlyAddress(vctx, args) {
120150
120288
  if (rMove.isErr()) {
120151
120289
  const asb = vctx.sql.tables.appSlugBinding;
120152
120290
  await exception2Result253(
120153
- () => vctx.sql.db.delete(asb).where(and135(eq160(asb.ownerHandle, chat.ownerHandle), eq160(asb.appSlug, appSlug)))
120291
+ () => vctx.sql.db.delete(asb).where(and136(eq161(asb.ownerHandle, chat.ownerHandle), eq161(asb.appSlug, appSlug)))
120154
120292
  );
120155
120293
  if (lost || isChatOnlyClaimLost(rMove.Err())) {
120156
120294
  log.Info().Str("chatId", args.chatId).Msg("chat-only claim: another claim took the chat first");
@@ -120160,7 +120298,7 @@ async function claimChatOnlyAddress(vctx, args) {
120160
120298
  }
120161
120299
  const au = vctx.sql.tables.assetUploads;
120162
120300
  const rAssets = await exception2Result253(
120163
- () => vctx.sql.db.update(au).set({ appSlug }).where(and135(eq160(au.ownerHandle, chat.ownerHandle), eq160(au.appSlug, provisional)))
120301
+ () => vctx.sql.db.update(au).set({ appSlug }).where(and136(eq161(au.ownerHandle, chat.ownerHandle), eq161(au.appSlug, provisional)))
120164
120302
  );
120165
120303
  if (rAssets.isErr()) log.Warn().Err(rAssets).Str("chatId", args.chatId).Msg("chat-only claim: asset upload repoint failed");
120166
120304
  if (title !== void 0) {
@@ -120180,7 +120318,7 @@ async function isChatOnlyClaimed(vctx, job) {
120180
120318
  if (CHAT_ONLY_CLAIM_FROM.includes(job.status) === false) return false;
120181
120319
  const cc = vctx.sql.tables.chatContexts;
120182
120320
  const r = await exception2Result253(
120183
- () => vctx.sql.db.select({ appSlug: cc.appSlug, draftPreAlloc: cc.draftPreAlloc }).from(cc).where(eq160(cc.chatId, job.chatId)).limit(1).then((rows) => rows[0])
120321
+ () => vctx.sql.db.select({ appSlug: cc.appSlug, draftPreAlloc: cc.draftPreAlloc }).from(cc).where(eq161(cc.chatId, job.chatId)).limit(1).then((rows) => rows[0])
120184
120322
  );
120185
120323
  if (r.isErr()) return false;
120186
120324
  const chat = r.Ok();
@@ -125887,7 +126025,7 @@ var init_agent_file_rebase = __esm({
125887
126025
 
125888
126026
  // ../vibes.diy/api/svc/public/fs-prompt.ts
125889
126027
  import { Result as Result194 } from "@adviser/cement";
125890
- import { and as and136, desc as desc31, eq as eq161 } from "drizzle-orm/sql/expressions";
126028
+ import { and as and137, desc as desc31, eq as eq162 } from "drizzle-orm/sql/expressions";
125891
126029
  async function handleFSPrompt({
125892
126030
  scope: scope2,
125893
126031
  vctx,
@@ -125909,10 +126047,10 @@ async function handleFSPrompt({
125909
126047
  let baseItems;
125910
126048
  if (req2.refFsId) {
125911
126049
  const refApp = await vctx.sql.db.select({ fileSystem: vctx.sql.tables.apps.fileSystem }).from(vctx.sql.tables.apps).where(
125912
- and136(
125913
- eq161(vctx.sql.tables.apps.fsId, req2.refFsId),
125914
- eq161(vctx.sql.tables.apps.ownerHandle, resChat.ownerHandle),
125915
- eq161(vctx.sql.tables.apps.appSlug, resChat.appSlug)
126050
+ and137(
126051
+ eq162(vctx.sql.tables.apps.fsId, req2.refFsId),
126052
+ eq162(vctx.sql.tables.apps.ownerHandle, resChat.ownerHandle),
126053
+ eq162(vctx.sql.tables.apps.appSlug, resChat.appSlug)
125916
126054
  )
125917
126055
  ).orderBy(desc31(vctx.sql.tables.apps.releaseSeq)).limit(1).then((r) => r[0]);
125918
126056
  if (!refApp) {
@@ -125920,14 +126058,14 @@ async function handleFSPrompt({
125920
126058
  }
125921
126059
  baseItems = refApp.fileSystem;
125922
126060
  } else {
125923
- const lastestPrompt = await vctx.sql.db.select().from(vctx.sql.tables.promptContexts).innerJoin(vctx.sql.tables.apps, eq161(vctx.sql.tables.apps.fsId, vctx.sql.tables.promptContexts.fsId)).where(eq161(vctx.sql.tables.promptContexts.chatId, req2.chatId)).orderBy(desc31(vctx.sql.tables.promptContexts.created)).limit(1).then((r) => r[0]);
126061
+ const lastestPrompt = await vctx.sql.db.select().from(vctx.sql.tables.promptContexts).innerJoin(vctx.sql.tables.apps, eq162(vctx.sql.tables.apps.fsId, vctx.sql.tables.promptContexts.fsId)).where(eq162(vctx.sql.tables.promptContexts.chatId, req2.chatId)).orderBy(desc31(vctx.sql.tables.promptContexts.created)).limit(1).then((r) => r[0]);
125924
126062
  baseItems = lastestPrompt?.Apps.fileSystem;
125925
126063
  const liveRelease = await selectLatestAppPerSlug(vctx, {
125926
126064
  ownerHandle: resChat.ownerHandle,
125927
126065
  appSlug: resChat.appSlug
125928
126066
  });
125929
126067
  if (liveRelease?.fsId !== void 0) {
125930
- const chainFsIds = await vctx.sql.db.select({ fsId: vctx.sql.tables.promptContexts.fsId }).from(vctx.sql.tables.promptContexts).where(eq161(vctx.sql.tables.promptContexts.chatId, req2.chatId)).then((rows) => new Set(rows.map((r) => r.fsId)));
126068
+ const chainFsIds = await vctx.sql.db.select({ fsId: vctx.sql.tables.promptContexts.fsId }).from(vctx.sql.tables.promptContexts).where(eq162(vctx.sql.tables.promptContexts.chatId, req2.chatId)).then((rows) => new Set(rows.map((r) => r.fsId)));
125931
126069
  if (chainFsIds.has(liveRelease.fsId) === false) {
125932
126070
  baseItems = liveRelease.fileSystem;
125933
126071
  }
@@ -126573,10 +126711,10 @@ var init_nature_rewrite = __esm({
126573
126711
 
126574
126712
  // ../vibes.diy/api/svc/public/prompt-turn-envelope.ts
126575
126713
  import { Result as Result197 } from "@adviser/cement";
126576
- import { and as and137, eq as eq162 } from "drizzle-orm/sql/expressions";
126714
+ import { and as and138, eq as eq163 } from "drizzle-orm/sql/expressions";
126577
126715
  async function getResChatFromMode(vctx, req2, orig) {
126578
126716
  if (isReqCreationPromptChatSection(orig) && orig.dryRun === true && orig.ownerHandle !== void 0 && orig.appSlug !== void 0) {
126579
- const anyRow = await vctx.sql.db.select({ chatId: vctx.sql.tables.chatContexts.chatId }).from(vctx.sql.tables.chatContexts).where(eq162(vctx.sql.tables.chatContexts.chatId, req2.chatId)).limit(1).then((r) => r[0]);
126717
+ const anyRow = await vctx.sql.db.select({ chatId: vctx.sql.tables.chatContexts.chatId }).from(vctx.sql.tables.chatContexts).where(eq163(vctx.sql.tables.chatContexts.chatId, req2.chatId)).limit(1).then((r) => r[0]);
126580
126718
  if (!anyRow) {
126581
126719
  const userId = req2._auth.verifiedAuth.claims.userId;
126582
126720
  const rForeign = await dryRunHandleIsForeign(vctx, orig.ownerHandle, userId);
@@ -126593,16 +126731,16 @@ async function getResChatFromMode(vctx, req2, orig) {
126593
126731
  let iResChat;
126594
126732
  if (isReqPromptApplicationChatSection(orig) || isReqPromptImageChatSection(orig)) {
126595
126733
  iResChat = await vctx.sql.db.select().from(vctx.sql.tables.applicationChats).where(
126596
- and137(
126597
- eq162(vctx.sql.tables.applicationChats.userId, req2._auth.verifiedAuth.claims.userId),
126598
- eq162(vctx.sql.tables.applicationChats.chatId, req2.chatId)
126734
+ and138(
126735
+ eq163(vctx.sql.tables.applicationChats.userId, req2._auth.verifiedAuth.claims.userId),
126736
+ eq163(vctx.sql.tables.applicationChats.chatId, req2.chatId)
126599
126737
  )
126600
126738
  ).limit(1).then((r) => r[0]);
126601
126739
  } else {
126602
126740
  iResChat = await vctx.sql.db.select().from(vctx.sql.tables.chatContexts).where(
126603
- and137(
126604
- eq162(vctx.sql.tables.chatContexts.userId, req2._auth.verifiedAuth.claims.userId),
126605
- eq162(vctx.sql.tables.chatContexts.chatId, req2.chatId)
126741
+ and138(
126742
+ eq163(vctx.sql.tables.chatContexts.userId, req2._auth.verifiedAuth.claims.userId),
126743
+ eq163(vctx.sql.tables.chatContexts.chatId, req2.chatId)
126606
126744
  )
126607
126745
  ).limit(1).then((r) => r[0]);
126608
126746
  }
@@ -126727,7 +126865,7 @@ var init_agent_router = __esm({
126727
126865
 
126728
126866
  // ../vibes.diy/api/svc/public/codegen-turn-route.ts
126729
126867
  import { Result as Result198, exception2Result as exception2Result265 } from "@adviser/cement";
126730
- import { and as and138, eq as eq163, ne as ne21 } from "drizzle-orm/sql/expressions";
126868
+ import { and as and139, eq as eq164, ne as ne21 } from "drizzle-orm/sql/expressions";
126731
126869
  function instantBuildFor(args) {
126732
126870
  const storedKey = args.defaults.codegen.apiKey;
126733
126871
  return args.defaults.instantBuild === true && args.agentDispatched && args.dryRun === false && args.fastPass !== false && args.promptModel === void 0 && (args.perCallApiKey === void 0 || args.perCallApiKey === "") && (storedKey === void 0 || storedKey === "");
@@ -126744,8 +126882,8 @@ async function routeCodegenTurn(vctx, args) {
126744
126882
  getModelDefaults(vctx, { appSlug: resChat.appSlug, ownerHandle: resChat.ownerHandle }),
126745
126883
  orig.dryRun !== true ? exception2Result265(
126746
126884
  () => vctx.sql.db.select({ chatId: vctx.sql.tables.chatSections.chatId }).from(vctx.sql.tables.chatSections).where(
126747
- and138(
126748
- eq163(vctx.sql.tables.chatSections.chatId, req2.chatId),
126885
+ and139(
126886
+ eq164(vctx.sql.tables.chatSections.chatId, req2.chatId),
126749
126887
  ne21(vctx.sql.tables.chatSections.blockSeq, RESEARCH_BLOCK_SEQ)
126750
126888
  )
126751
126889
  ).limit(1).then((r) => r[0])
@@ -127598,7 +127736,7 @@ var init_agent_memory = __esm({
127598
127736
 
127599
127737
  // ../vibes.diy/api/svc/public/home-feed-common.ts
127600
127738
  import { sql as sql28 } from "drizzle-orm";
127601
- import { and as and139, eq as eq164, or as or16 } from "drizzle-orm/sql/expressions";
127739
+ import { and as and140, eq as eq165, or as or16 } from "drizzle-orm/sql/expressions";
127602
127740
  function clampHomeFeedLimit(raw) {
127603
127741
  if (raw === void 0 || !Number.isFinite(raw)) return HOME_FEED_DEFAULT_LIMIT;
127604
127742
  const i = Math.floor(raw);
@@ -127614,14 +127752,14 @@ async function loadVibeDisplayInfo(vctx, pairs) {
127614
127752
  if (pairs.length === 0) return out;
127615
127753
  const settings = vctx.sql.tables.appSettings;
127616
127754
  const usb = vctx.sql.tables.handleBinding;
127617
- const pairPred = or16(...pairs.map((p) => and139(eq164(settings.ownerHandle, p.ownerHandle), eq164(settings.appSlug, p.appSlug))));
127755
+ const pairPred = or16(...pairs.map((p) => and140(eq165(settings.ownerHandle, p.ownerHandle), eq165(settings.appSlug, p.appSlug))));
127618
127756
  const rows = await vctx.sql.db.select({
127619
127757
  userId: settings.userId,
127620
127758
  ownerHandle: settings.ownerHandle,
127621
127759
  appSlug: settings.appSlug,
127622
127760
  settings: settings.settings,
127623
127761
  settingsItemizedAt: settings.settingsItemizedAt
127624
- }).from(settings).innerJoin(usb, and139(eq164(usb.handle, settings.ownerHandle), eq164(usb.userId, settings.userId))).where(pairPred);
127762
+ }).from(settings).innerJoin(usb, and140(eq165(usb.handle, settings.ownerHandle), eq165(usb.userId, settings.userId))).where(pairPred);
127625
127763
  const composed = await composeSettingsRows(
127626
127764
  vctx,
127627
127765
  rows.map((row) => ({
@@ -127651,7 +127789,7 @@ async function resolveLivePublicPairs(ctx, pairs) {
127651
127789
  if (pairs.length === 0) return out;
127652
127790
  const asb = ctx.sql.tables.appSlugBinding;
127653
127791
  const publishedRows = await ctx.sql.db.select({ ownerHandle: asb.ownerHandle, appSlug: asb.appSlug }).from(asb).where(
127654
- and139(eq164(asb.unpublishedAt, ""), or16(...pairs.map((p) => and139(eq164(asb.ownerHandle, p.ownerHandle), eq164(asb.appSlug, p.appSlug)))))
127792
+ and140(eq165(asb.unpublishedAt, ""), or16(...pairs.map((p) => and140(eq165(asb.ownerHandle, p.ownerHandle), eq165(asb.appSlug, p.appSlug)))))
127655
127793
  );
127656
127794
  const published = new Set(publishedRows.map((r) => titleIconKey(r.ownerHandle, r.appSlug)));
127657
127795
  const display = await loadVibeDisplayInfo(ctx, pairs);
@@ -127727,12 +127865,12 @@ async function loadNewestReleaseFacts(vctx, pairs) {
127727
127865
  const out = /* @__PURE__ */ new Map();
127728
127866
  if (pairs.length === 0) return out;
127729
127867
  const apps = vctx.sql.tables.apps;
127730
- const pairPred = or16(...pairs.map((p) => and139(eq164(apps.ownerHandle, p.ownerHandle), eq164(apps.appSlug, p.appSlug))));
127868
+ const pairPred = or16(...pairs.map((p) => and140(eq165(apps.ownerHandle, p.ownerHandle), eq165(apps.appSlug, p.appSlug))));
127731
127869
  const newest = await vctx.sql.db.select({
127732
127870
  ownerHandle: apps.ownerHandle,
127733
127871
  appSlug: apps.appSlug,
127734
127872
  releaseSeq: sql28`cast(max(${apps.releaseSeq}) as int)`
127735
- }).from(apps).where(and139(eq164(apps.mode, "production"), pairPred)).groupBy(apps.ownerHandle, apps.appSlug);
127873
+ }).from(apps).where(and140(eq165(apps.mode, "production"), pairPred)).groupBy(apps.ownerHandle, apps.appSlug);
127736
127874
  if (newest.length === 0) return out;
127737
127875
  const rows = await vctx.sql.db.select({ ownerHandle: apps.ownerHandle, appSlug: apps.appSlug, meta: apps.meta }).from(apps).where(
127738
127876
  // `mode` is re-asserted, not redundant: `releaseSeq` happens to be unique
@@ -127741,11 +127879,11 @@ async function loadNewestReleaseFacts(vctx, pairs) {
127741
127879
  // a production row's releaseSeq could lend its screenshot to a production
127742
127880
  // release that has none — admitting exactly the blank card this gate exists
127743
127881
  // to exclude.
127744
- and139(
127745
- eq164(apps.mode, "production"),
127882
+ and140(
127883
+ eq165(apps.mode, "production"),
127746
127884
  or16(
127747
127885
  ...newest.map(
127748
- (n2) => and139(eq164(apps.ownerHandle, n2.ownerHandle), eq164(apps.appSlug, n2.appSlug), eq164(apps.releaseSeq, Number(n2.releaseSeq)))
127886
+ (n2) => and140(eq165(apps.ownerHandle, n2.ownerHandle), eq165(apps.appSlug, n2.appSlug), eq165(apps.releaseSeq, Number(n2.releaseSeq)))
127749
127887
  )
127750
127888
  )
127751
127889
  )
@@ -127791,7 +127929,7 @@ var init_home_feed_common = __esm({
127791
127929
  import { exception2Result as exception2Result267, Result as Result201, stream2uint8array as stream2uint8array13 } from "@adviser/cement";
127792
127930
  import { bytesToHex as bytesToHex6, utf8ToBytes as utf8ToBytes8 } from "@noble/hashes/utils.js";
127793
127931
  import { sha256 as sha25612 } from "@noble/hashes/sha2.js";
127794
- import { and as and140, desc as desc32, eq as eq165, ne as ne22, or as or17 } from "drizzle-orm/sql/expressions";
127932
+ import { and as and141, desc as desc32, eq as eq166, ne as ne22, or as or17 } from "drizzle-orm/sql/expressions";
127795
127933
  function embeddingsUrl(backendUrl) {
127796
127934
  const suffix = "/chat/completions";
127797
127935
  if (backendUrl.endsWith(suffix)) {
@@ -127861,7 +127999,7 @@ var init_research_vector_arm = __esm({
127861
127999
  // ../vibes.diy/api/svc/intern/agent-find-vibes-tool.ts
127862
128000
  import { Result as Result203, exception2Result as exception2Result269 } from "@adviser/cement";
127863
128001
  import { type as type163 } from "arktype";
127864
- import { inArray as inArray44 } from "drizzle-orm/sql/expressions";
128002
+ import { inArray as inArray45 } from "drizzle-orm/sql/expressions";
127865
128003
  function quoteUntrusted(text3) {
127866
128004
  return `\xAB${text3.replace(/[«»]/g, "")}\xBB`;
127867
128005
  }
@@ -127883,7 +128021,7 @@ function isHiddenHandle(handle) {
127883
128021
  async function guestHeldHandles(vctx, handles) {
127884
128022
  if (handles.length === 0) return /* @__PURE__ */ new Set();
127885
128023
  const hb = vctx.sql.tables.handleBinding;
127886
- const rows = await vctx.sql.db.select({ handle: hb.handle, userId: hb.userId }).from(hb).where(inArray44(hb.handle, [...new Set(handles)]));
128024
+ const rows = await vctx.sql.db.select({ handle: hb.handle, userId: hb.userId }).from(hb).where(inArray45(hb.handle, [...new Set(handles)]));
127887
128025
  return new Set(rows.filter((r) => isGuestPrincipal(r.userId)).map((r) => r.handle));
127888
128026
  }
127889
128027
  async function findPublishedVibes(vctx, deps, args) {
@@ -128021,7 +128159,7 @@ var init_agent_find_vibes_tool = __esm({
128021
128159
 
128022
128160
  // ../vibes.diy/api/svc/intern/agent-assembly.ts
128023
128161
  import { Result as Result204 } from "@adviser/cement";
128024
- import { and as and141, eq as eq166, ne as ne23 } from "drizzle-orm/sql/expressions";
128162
+ import { eq as eq167 } from "drizzle-orm/sql/expressions";
128025
128163
  function addedVibeContextLine(link) {
128026
128164
  const line2 = vibeLinkContextLine(link);
128027
128165
  const tools = link.tools ?? [];
@@ -128080,25 +128218,18 @@ function messagesCarryRefusedUrl(newUserMessages) {
128080
128218
  return false;
128081
128219
  }
128082
128220
  async function assembleAgentPayload(vctx, args) {
128083
- const pChatOwner = vctx.sql.db.select({ userId: vctx.sql.tables.chatContexts.userId }).from(vctx.sql.tables.chatContexts).where(eq166(vctx.sql.tables.chatContexts.chatId, args.chatId)).limit(1).then((rows) => rows[0]);
128084
- const pSections = vctx.sql.db.select().from(vctx.sql.tables.chatSections).where(and141(eq166(vctx.sql.tables.chatSections.chatId, args.chatId), ne23(vctx.sql.tables.chatSections.blockSeq, RESEARCH_BLOCK_SEQ))).orderBy(vctx.sql.tables.chatSections.created).then((rows) => rows);
128221
+ const pChatOwner = vctx.sql.db.select({ userId: vctx.sql.tables.chatContexts.userId }).from(vctx.sql.tables.chatContexts).where(eq167(vctx.sql.tables.chatContexts.chatId, args.chatId)).limit(1).then((rows) => rows[0]);
128222
+ const pSections = readChatHistory(vctx, args.chatId, {
128223
+ compact: true,
128224
+ onWarning: /* @__PURE__ */ __name((parseErrors) => ensureLogger(vctx.sthis, "assembleAgentPayload").Warn().Any({ parseErrors }).Msg("skip"), "onWarning")
128225
+ });
128085
128226
  const pTimeline = loadVersionTimeline(vctx, args.chatId);
128086
128227
  void pSections.catch(() => void 0);
128087
128228
  const chatOwner = await pChatOwner;
128088
128229
  if (chatOwner !== void 0 && chatOwner.userId !== args.userId) {
128089
128230
  return Result204.Err("chat_not_owned");
128090
128231
  }
128091
- const sections = await pSections;
128092
- const allSectionMsgs = [];
128093
- for (const rowSection of sections) {
128094
- const { msgs: filtered, warning } = historySectionMsgs(rowSection.blocks);
128095
- if (warning.length > 0) {
128096
- ensureLogger(vctx.sthis, "assembleAgentPayload").Warn().Any({ parseErrors: warning }).Msg("skip");
128097
- }
128098
- allSectionMsgs.push(
128099
- ...filtered.filter((block) => !isPromptResearch(block) && !isPromptStatus(block) && !isPromptProgressLabel(block))
128100
- );
128101
- }
128232
+ const allSectionMsgs = await pSections;
128102
128233
  const { messages: reconstructed } = reconstructConversationMessages(allSectionMsgs, { compact: true });
128103
128234
  const alternativeLabel = alternativeReadyLabel(allSectionMsgs);
128104
128235
  const alternative = alternativeLabel === void 0 ? [] : [alternativeContextLine(alternativeLabel)];
@@ -128718,32 +128849,32 @@ var init_agent_build_tools = __esm({
128718
128849
 
128719
128850
  // ../vibes.diy/api/svc/public/lookup-handles.ts
128720
128851
  import { Result as Result206, Option as Option42, EventoResult as EventoResult36 } from "@adviser/cement";
128721
- import { and as and142, eq as eq167, inArray as inArray45, like as like6, or as or18, asc as asc14, desc as desc33 } from "drizzle-orm";
128852
+ import { and as and142, eq as eq168, inArray as inArray46, like as like6, or as or18, asc as asc14, desc as desc33 } from "drizzle-orm";
128722
128853
  async function collectKnownHandles(vctx, userId) {
128723
128854
  const t = vctx.sql.tables;
128724
128855
  const known = /* @__PURE__ */ new Set();
128725
- const myHandleRows = await vctx.sql.db.select({ handle: t.handleBinding.handle }).from(t.handleBinding).where(eq167(t.handleBinding.userId, userId));
128856
+ const myHandleRows = await vctx.sql.db.select({ handle: t.handleBinding.handle }).from(t.handleBinding).where(eq168(t.handleBinding.userId, userId));
128726
128857
  const myHandles = myHandleRows.map((r) => r.handle);
128727
128858
  for (const h of myHandles) known.add(h);
128728
128859
  if (myHandles.length > 0) {
128729
- const dmRows = await vctx.sql.db.select({ channelHandle: t.directChannelIndex.channelHandle, handle: t.directChannelIndex.handle }).from(t.directChannelIndex).where(inArray45(t.directChannelIndex.handle, myHandles));
128860
+ const dmRows = await vctx.sql.db.select({ channelHandle: t.directChannelIndex.channelHandle, handle: t.directChannelIndex.handle }).from(t.directChannelIndex).where(inArray46(t.directChannelIndex.handle, myHandles));
128730
128861
  for (const row of dmRows) {
128731
128862
  const peer = (directChannelParticipants(row.channelHandle) ?? []).find((h) => h !== row.handle);
128732
128863
  if (peer) known.add(peer);
128733
128864
  }
128734
128865
  }
128735
- const memberInvites = await vctx.sql.db.select({ ownerHandle: t.inviteGrants.ownerHandle, appSlug: t.inviteGrants.appSlug }).from(t.inviteGrants).where(and142(eq167(t.inviteGrants.tokenOrGrantUserId, userId), eq167(t.inviteGrants.state, "accepted")));
128736
- const memberRequests = await vctx.sql.db.select({ ownerHandle: t.requestGrants.ownerHandle, appSlug: t.requestGrants.appSlug }).from(t.requestGrants).where(and142(eq167(t.requestGrants.foreignUserId, userId), eq167(t.requestGrants.state, "approved")));
128866
+ const memberInvites = await vctx.sql.db.select({ ownerHandle: t.inviteGrants.ownerHandle, appSlug: t.inviteGrants.appSlug }).from(t.inviteGrants).where(and142(eq168(t.inviteGrants.tokenOrGrantUserId, userId), eq168(t.inviteGrants.state, "accepted")));
128867
+ const memberRequests = await vctx.sql.db.select({ ownerHandle: t.requestGrants.ownerHandle, appSlug: t.requestGrants.appSlug }).from(t.requestGrants).where(and142(eq168(t.requestGrants.foreignUserId, userId), eq168(t.requestGrants.state, "approved")));
128737
128868
  const ownedInvites = await vctx.sql.db.select({
128738
128869
  memberUserId: t.inviteGrants.tokenOrGrantUserId,
128739
128870
  ownerHandle: t.inviteGrants.ownerHandle,
128740
128871
  appSlug: t.inviteGrants.appSlug
128741
- }).from(t.inviteGrants).where(and142(eq167(t.inviteGrants.userId, userId), eq167(t.inviteGrants.state, "accepted")));
128872
+ }).from(t.inviteGrants).where(and142(eq168(t.inviteGrants.userId, userId), eq168(t.inviteGrants.state, "accepted")));
128742
128873
  const ownedRequests = await vctx.sql.db.select({
128743
128874
  memberUserId: t.requestGrants.foreignUserId,
128744
128875
  ownerHandle: t.requestGrants.ownerHandle,
128745
128876
  appSlug: t.requestGrants.appSlug
128746
- }).from(t.requestGrants).where(and142(eq167(t.requestGrants.userId, userId), eq167(t.requestGrants.state, "approved")));
128877
+ }).from(t.requestGrants).where(and142(eq168(t.requestGrants.userId, userId), eq168(t.requestGrants.state, "approved")));
128747
128878
  const memberUserIds = /* @__PURE__ */ new Set();
128748
128879
  for (const row of [...ownedInvites, ...ownedRequests]) {
128749
128880
  if (row.memberUserId && row.memberUserId !== userId) memberUserIds.add(row.memberUserId);
@@ -128755,23 +128886,23 @@ async function collectKnownHandles(vctx, userId) {
128755
128886
  const memberPairConds = [...memberPairMap.values()];
128756
128887
  if (memberPairConds.length > 0) {
128757
128888
  const inviteConds = memberPairConds.map(
128758
- (p) => and142(eq167(t.inviteGrants.ownerHandle, p.ownerHandle), eq167(t.inviteGrants.appSlug, p.appSlug))
128889
+ (p) => and142(eq168(t.inviteGrants.ownerHandle, p.ownerHandle), eq168(t.inviteGrants.appSlug, p.appSlug))
128759
128890
  );
128760
128891
  const requestConds = memberPairConds.map(
128761
- (p) => and142(eq167(t.requestGrants.ownerHandle, p.ownerHandle), eq167(t.requestGrants.appSlug, p.appSlug))
128892
+ (p) => and142(eq168(t.requestGrants.ownerHandle, p.ownerHandle), eq168(t.requestGrants.appSlug, p.appSlug))
128762
128893
  );
128763
128894
  const [firstInvite, ...restInvites] = inviteConds;
128764
128895
  const [firstRequest, ...restRequests] = requestConds;
128765
- const peerInvites = await vctx.sql.db.select({ memberUserId: t.inviteGrants.tokenOrGrantUserId }).from(t.inviteGrants).where(and142(eq167(t.inviteGrants.state, "accepted"), restInvites.length === 0 ? firstInvite : or18(firstInvite, ...restInvites)));
128896
+ const peerInvites = await vctx.sql.db.select({ memberUserId: t.inviteGrants.tokenOrGrantUserId }).from(t.inviteGrants).where(and142(eq168(t.inviteGrants.state, "accepted"), restInvites.length === 0 ? firstInvite : or18(firstInvite, ...restInvites)));
128766
128897
  const peerRequests = await vctx.sql.db.select({ memberUserId: t.requestGrants.foreignUserId }).from(t.requestGrants).where(
128767
- and142(eq167(t.requestGrants.state, "approved"), restRequests.length === 0 ? firstRequest : or18(firstRequest, ...restRequests))
128898
+ and142(eq168(t.requestGrants.state, "approved"), restRequests.length === 0 ? firstRequest : or18(firstRequest, ...restRequests))
128768
128899
  );
128769
128900
  for (const row of [...peerInvites, ...peerRequests]) {
128770
128901
  if (row.memberUserId && row.memberUserId !== userId) memberUserIds.add(row.memberUserId);
128771
128902
  }
128772
128903
  }
128773
128904
  if (memberUserIds.size > 0) {
128774
- const memberHandleRows = await vctx.sql.db.select({ handle: t.handleBinding.handle }).from(t.handleBinding).where(inArray45(t.handleBinding.userId, [...memberUserIds]));
128905
+ const memberHandleRows = await vctx.sql.db.select({ handle: t.handleBinding.handle }).from(t.handleBinding).where(inArray46(t.handleBinding.userId, [...memberUserIds]));
128775
128906
  for (const r of memberHandleRows) known.add(r.handle);
128776
128907
  }
128777
128908
  const pairs = /* @__PURE__ */ new Map();
@@ -128781,15 +128912,15 @@ async function collectKnownHandles(vctx, userId) {
128781
128912
  }, "addPair");
128782
128913
  for (const row of [...memberInvites, ...memberRequests]) addPair(row.ownerHandle, row.appSlug);
128783
128914
  if (myHandles.length > 0 && pairs.size < KNOWN_APPS_CAP) {
128784
- const ownedApps = await vctx.sql.db.select({ ownerHandle: t.appSlugBinding.ownerHandle, appSlug: t.appSlugBinding.appSlug }).from(t.appSlugBinding).where(inArray45(t.appSlugBinding.ownerHandle, myHandles)).orderBy(desc33(t.appSlugBinding.updated)).limit(KNOWN_APPS_CAP);
128915
+ const ownedApps = await vctx.sql.db.select({ ownerHandle: t.appSlugBinding.ownerHandle, appSlug: t.appSlugBinding.appSlug }).from(t.appSlugBinding).where(inArray46(t.appSlugBinding.ownerHandle, myHandles)).orderBy(desc33(t.appSlugBinding.updated)).limit(KNOWN_APPS_CAP);
128785
128916
  for (const row of ownedApps) addPair(row.ownerHandle, row.appSlug);
128786
128917
  }
128787
128918
  const pairConds = [...pairs.values()].map(
128788
- (p) => and142(eq167(t.accessFnOutputs.ownerHandle, p.ownerHandle), eq167(t.accessFnOutputs.appSlug, p.appSlug))
128919
+ (p) => and142(eq168(t.accessFnOutputs.ownerHandle, p.ownerHandle), eq168(t.accessFnOutputs.appSlug, p.appSlug))
128789
128920
  );
128790
128921
  if (pairConds.length > 0) {
128791
128922
  const [firstCond, ...restConds] = pairConds;
128792
- const outputRows = await vctx.sql.db.select({ output: t.accessFnOutputs.output }).from(t.accessFnOutputs).where(and142(eq167(t.accessFnOutputs.hasGrants, 1), restConds.length === 0 ? firstCond : or18(firstCond, ...restConds)));
128923
+ const outputRows = await vctx.sql.db.select({ output: t.accessFnOutputs.output }).from(t.accessFnOutputs).where(and142(eq168(t.accessFnOutputs.hasGrants, 1), restConds.length === 0 ? firstCond : or18(firstCond, ...restConds)));
128793
128924
  for (const row of outputRows) {
128794
128925
  let desc59;
128795
128926
  try {
@@ -129192,13 +129323,13 @@ var init_agent_read_tools = __esm({
129192
129323
  });
129193
129324
 
129194
129325
  // ../vibes.diy/api/svc/public/authorize-slug-owner.ts
129195
- import { and as and143, eq as eq168 } from "drizzle-orm/sql/expressions";
129326
+ import { and as and143, eq as eq169 } from "drizzle-orm/sql/expressions";
129196
129327
  async function authorizeSlugOwner(vctx, args) {
129197
129328
  const asb = vctx.sql.tables.appSlugBinding;
129198
129329
  const usb = vctx.sql.tables.handleBinding;
129199
129330
  const [appRow, ownerRow] = await Promise.all([
129200
- vctx.sql.db.select({ ownerHandle: asb.ownerHandle, appSlug: asb.appSlug, unpublishedAt: asb.unpublishedAt, lockedFsId: asb.lockedFsId }).from(asb).where(and143(eq168(asb.ownerHandle, args.ownerHandle), eq168(asb.appSlug, args.appSlug))).limit(1).then((r) => r[0]),
129201
- vctx.sql.db.select({ userId: usb.userId }).from(usb).where(and143(eq168(usb.handle, args.ownerHandle), eq168(usb.userId, args.userId))).limit(1).then((r) => r[0])
129331
+ vctx.sql.db.select({ ownerHandle: asb.ownerHandle, appSlug: asb.appSlug, unpublishedAt: asb.unpublishedAt, lockedFsId: asb.lockedFsId }).from(asb).where(and143(eq169(asb.ownerHandle, args.ownerHandle), eq169(asb.appSlug, args.appSlug))).limit(1).then((r) => r[0]),
129332
+ vctx.sql.db.select({ userId: usb.userId }).from(usb).where(and143(eq169(usb.handle, args.ownerHandle), eq169(usb.userId, args.userId))).limit(1).then((r) => r[0])
129202
129333
  ]);
129203
129334
  if (appRow === void 0) return void 0;
129204
129335
  const isOwner = ownerRow !== void 0;
@@ -129216,7 +129347,7 @@ var init_authorize_slug_owner = __esm({
129216
129347
  // ../vibes.diy/api/svc/public/app-logs.ts
129217
129348
  import { Result as Result208, Option as Option43, EventoResult as EventoResult37, exception2Result as exception2Result271 } from "@adviser/cement";
129218
129349
  import { type as type165 } from "arktype";
129219
- import { and as and144, eq as eq169, gt as gt17, gte as gte5 } from "drizzle-orm/sql/expressions";
129350
+ import { and as and144, eq as eq170, gt as gt17, gte as gte5 } from "drizzle-orm/sql/expressions";
129220
129351
  import { asc as asc15, desc as desc34 } from "drizzle-orm";
129221
129352
  async function authorized(vctx, args) {
129222
129353
  const auth = await authorizeSlugOwner(vctx, args);
@@ -129258,13 +129389,13 @@ function clampLogLimit(limit) {
129258
129389
  async function readAppLogsPage(vctx, opts) {
129259
129390
  const t = vctx.sql.tables.vibeLogEvents;
129260
129391
  const limit = clampLogLimit(opts.limit);
129261
- const conds = [eq169(t.ownerHandle, opts.ownerHandle), eq169(t.appSlug, opts.appSlug)];
129392
+ const conds = [eq170(t.ownerHandle, opts.ownerHandle), eq170(t.appSlug, opts.appSlug)];
129262
129393
  if (opts.sinceId !== void 0 && opts.sinceId !== "") conds.push(gt17(t.id, opts.sinceId));
129263
129394
  if (opts.sinceTs !== void 0 && opts.sinceTs !== "") {
129264
129395
  const sinceMs = Date.parse(opts.sinceTs);
129265
129396
  if (Number.isFinite(sinceMs)) conds.push(gte5(t.id, logEventIdFloor(sinceMs)));
129266
129397
  }
129267
- if (opts.level !== void 0) conds.push(eq169(t.level, opts.level));
129398
+ if (opts.level !== void 0) conds.push(eq170(t.level, opts.level));
129268
129399
  const rRows = await exception2Result271(
129269
129400
  async () => vctx.sql.db.select({
129270
129401
  id: t.id,
@@ -129345,7 +129476,7 @@ var init_app_logs = __esm({
129345
129476
  let latestTs;
129346
129477
  if (req2.probeLatest === true && events.length === 0) {
129347
129478
  const rLatest = await exception2Result271(
129348
- async () => vctx.sql.db.select({ ts: t.ts }).from(t).where(and144(eq169(t.ownerHandle, req2.ownerHandle), eq169(t.appSlug, req2.appSlug))).orderBy(desc34(t.id)).limit(1)
129479
+ async () => vctx.sql.db.select({ ts: t.ts }).from(t).where(and144(eq170(t.ownerHandle, req2.ownerHandle), eq170(t.appSlug, req2.appSlug))).orderBy(desc34(t.id)).limit(1)
129349
129480
  );
129350
129481
  if (rLatest.isErr()) {
129351
129482
  console.error("app-logs latest probe failed", { ownerHandle: req2.ownerHandle, appSlug: req2.appSlug }, rLatest.Err());
@@ -129371,10 +129502,10 @@ var init_app_logs = __esm({
129371
129502
 
129372
129503
  // ../vibes.diy/api/svc/intern/build-version-ordinal.ts
129373
129504
  import { exception2Result as exception2Result272 } from "@adviser/cement";
129374
- import { and as and145, eq as eq170 } from "drizzle-orm/sql/expressions";
129505
+ import { and as and145, eq as eq171 } from "drizzle-orm/sql/expressions";
129375
129506
  async function loadVersionItems(vctx, opts) {
129376
129507
  const t = vctx.sql.tables.apps;
129377
- const rows = await vctx.sql.db.select({ userId: t.userId, fsId: t.fsId, mode: t.mode, releaseSeq: t.releaseSeq, created: t.created }).from(t).where(and145(eq170(t.ownerHandle, opts.ownerHandle), eq170(t.appSlug, opts.appSlug)));
129508
+ const rows = await vctx.sql.db.select({ userId: t.userId, fsId: t.fsId, mode: t.mode, releaseSeq: t.releaseSeq, created: t.created }).from(t).where(and145(eq171(t.ownerHandle, opts.ownerHandle), eq171(t.appSlug, opts.appSlug)));
129378
129509
  let topProdSeq = -Infinity;
129379
129510
  for (const r of rows) {
129380
129511
  if (r.mode === "production" && r.releaseSeq > topProdSeq) topProdSeq = r.releaseSeq;
@@ -129770,7 +129901,7 @@ var init_agent_file_tools = __esm({
129770
129901
 
129771
129902
  // ../vibes.diy/api/svc/intern/agent-debug-tools.ts
129772
129903
  import { Result as Result210, exception2Result as exception2Result275 } from "@adviser/cement";
129773
- import { and as and146, eq as eq171, sql as sql29 } from "drizzle-orm";
129904
+ import { and as and146, eq as eq172, sql as sql29 } from "drizzle-orm";
129774
129905
  function createAgentDebugTools(vctx, args) {
129775
129906
  const scopeOwner = args.actor.scope?.ownerHandle ?? args.actor.ownerHandle;
129776
129907
  const scopeSlug = args.actor.scope?.appSlug;
@@ -130171,7 +130302,7 @@ async function readReleaseState(vctx, app, chatId) {
130171
130302
  headFsId = timeline.length > 0 ? timeline[timeline.length - 1].fsId : void 0;
130172
130303
  }
130173
130304
  const tApps = vctx.sql.tables.apps;
130174
- const publishedRow = published === void 0 ? void 0 : await vctx.sql.db.select({ fileSystem: tApps.fileSystem }).from(tApps).where(and146(eq171(tApps.ownerHandle, app.ownerHandle), eq171(tApps.appSlug, app.appSlug), eq171(tApps.fsId, published.fsId))).orderBy(sql29`${tApps.releaseSeq} desc`).limit(1).then((r) => r[0]);
130305
+ const publishedRow = published === void 0 ? void 0 : await vctx.sql.db.select({ fileSystem: tApps.fileSystem }).from(tApps).where(and146(eq172(tApps.ownerHandle, app.ownerHandle), eq172(tApps.appSlug, app.appSlug), eq172(tApps.fsId, published.fsId))).orderBy(sql29`${tApps.releaseSeq} desc`).limit(1).then((r) => r[0]);
130175
130306
  const files = publishedRow?.fileSystem ?? [];
130176
130307
  const has = /* @__PURE__ */ __name((name) => files.some((f) => f.fileName === name), "has");
130177
130308
  const backendJsInRelease = has("/backend.js");
@@ -132009,7 +132140,7 @@ var init_agent_web_search_tool = __esm({
132009
132140
 
132010
132141
  // ../vibes.diy/api/svc/public/hide-app-history.ts
132011
132142
  import { EventoResult as EventoResult39, Option as Option45, Result as Result219 } from "@adviser/cement";
132012
- import { and as and147, eq as eq172 } from "drizzle-orm/sql/expressions";
132143
+ import { and as and147, eq as eq173 } from "drizzle-orm/sql/expressions";
132013
132144
  import { type as type173 } from "arktype";
132014
132145
  function applyAppHistoryHide({
132015
132146
  prev,
@@ -132032,7 +132163,7 @@ function isHiddenFromAppHistory(hidden, entry2) {
132032
132163
  }
132033
132164
  async function readSettingsRow(vctx, userId) {
132034
132165
  const tSettings = vctx.sql.tables.userSettings;
132035
- return vctx.sql.db.select().from(tSettings).where(eq172(tSettings.userId, userId)).limit(1).then((r) => r[0]);
132166
+ return vctx.sql.db.select().from(tSettings).where(eq173(tSettings.userId, userId)).limit(1).then((r) => r[0]);
132036
132167
  }
132037
132168
  async function readAppHistoryHidden(vctx, userId) {
132038
132169
  const row = await readSettingsRow(vctx, userId);
@@ -132047,7 +132178,7 @@ async function hideAppHistory(vctx, req2, attempt = 0) {
132047
132178
  const now3 = (/* @__PURE__ */ new Date()).toISOString();
132048
132179
  const item = applyAppHistoryHide({ prev: raw.find(isUserSettingAppHistoryHidden), req: req2, now: now3 });
132049
132180
  const next = [...raw.filter((i) => !isUserSettingAppHistoryHidden(i)), item];
132050
- const written = existing === void 0 ? await vctx.sql.db.insert(tSettings).values({ userId, settings: next, updated: now3, created: now3 }).onConflictDoNothing({ target: tSettings.userId }).returning({ userId: tSettings.userId }) : await vctx.sql.db.update(tSettings).set({ settings: next, updated: now3 }).where(and147(eq172(tSettings.userId, userId), eq172(tSettings.settings, existing.settings))).returning({ userId: tSettings.userId });
132181
+ const written = existing === void 0 ? await vctx.sql.db.insert(tSettings).values({ userId, settings: next, updated: now3, created: now3 }).onConflictDoNothing({ target: tSettings.userId }).returning({ userId: tSettings.userId }) : await vctx.sql.db.update(tSettings).set({ settings: next, updated: now3 }).where(and147(eq173(tSettings.userId, userId), eq173(tSettings.settings, existing.settings))).returning({ userId: tSettings.userId });
132051
132182
  if (written.length === 0) {
132052
132183
  if (attempt + 1 < WRITE_ATTEMPTS) return hideAppHistory(vctx, req2, attempt + 1);
132053
132184
  return Result219.Err(new Error(`hide-app-history: settings write kept conflicting for ${userId}`));
@@ -132098,7 +132229,7 @@ import {
132098
132229
  } from "@adviser/cement";
132099
132230
  import { type as type174 } from "arktype";
132100
132231
  import { base58btc as base58btc11 } from "multiformats/bases/base58";
132101
- import { eq as eq173, and as and148, or as or19 } from "drizzle-orm/sql/expressions";
132232
+ import { eq as eq174, and as and148, or as or19 } from "drizzle-orm/sql/expressions";
132102
132233
  import { max as max9 } from "drizzle-orm";
132103
132234
  function encodeCursor2(c) {
132104
132235
  return base58btc11.encode(jsonEnde.uint8ify(c));
@@ -132132,14 +132263,14 @@ async function listMembershipsForUser(vctx, req2) {
132132
132263
  appSlug: t.inviteGrants.appSlug,
132133
132264
  role: t.inviteGrants.role,
132134
132265
  grantUpdated: t.inviteGrants.updated
132135
- }).from(t.inviteGrants).where(and148(eq173(t.inviteGrants.tokenOrGrantUserId, myUserId), eq173(t.inviteGrants.state, "accepted")));
132266
+ }).from(t.inviteGrants).where(and148(eq174(t.inviteGrants.tokenOrGrantUserId, myUserId), eq174(t.inviteGrants.state, "accepted")));
132136
132267
  const requestRows = await vctx.sql.db.select({
132137
132268
  ownerUserId: t.requestGrants.userId,
132138
132269
  ownerUserSlug: t.requestGrants.ownerHandle,
132139
132270
  appSlug: t.requestGrants.appSlug,
132140
132271
  role: t.requestGrants.role,
132141
132272
  grantUpdated: t.requestGrants.updated
132142
- }).from(t.requestGrants).where(and148(eq173(t.requestGrants.foreignUserId, myUserId), eq173(t.requestGrants.state, "approved")));
132273
+ }).from(t.requestGrants).where(and148(eq174(t.requestGrants.foreignUserId, myUserId), eq174(t.requestGrants.state, "approved")));
132143
132274
  const roleRank = { editor: 2, submitter: 1, viewer: 0 };
132144
132275
  const mergedMap = /* @__PURE__ */ new Map();
132145
132276
  for (const r of [...inviteRows, ...requestRows]) {
@@ -132169,9 +132300,9 @@ async function listMembershipsForUser(vctx, req2) {
132169
132300
  appKeys.map(
132170
132301
  (k) => vctx.sql.db.select({ lastWrite: max9(t.appDocuments.created) }).from(t.appDocuments).where(
132171
132302
  and148(
132172
- eq173(t.appDocuments.userId, myUserId),
132173
- eq173(t.appDocuments.ownerHandle, k.ownerHandle),
132174
- eq173(t.appDocuments.appSlug, k.appSlug)
132303
+ eq174(t.appDocuments.userId, myUserId),
132304
+ eq174(t.appDocuments.ownerHandle, k.ownerHandle),
132305
+ eq174(t.appDocuments.appSlug, k.appSlug)
132175
132306
  )
132176
132307
  )
132177
132308
  )
@@ -132208,9 +132339,9 @@ async function listMembershipsForUser(vctx, req2) {
132208
132339
  if (page.length > 0) {
132209
132340
  const settingsConds = page.map(
132210
132341
  (p) => and148(
132211
- eq173(t.appSettings.userId, p.ownerUserId),
132212
- eq173(t.appSettings.ownerHandle, p.ownerUserSlug),
132213
- eq173(t.appSettings.appSlug, p.appSlug)
132342
+ eq174(t.appSettings.userId, p.ownerUserId),
132343
+ eq174(t.appSettings.ownerHandle, p.ownerUserSlug),
132344
+ eq174(t.appSettings.appSlug, p.appSlug)
132214
132345
  )
132215
132346
  );
132216
132347
  const [firstSettingsCond, ...otherSettingsConds] = settingsConds;
@@ -133069,7 +133200,7 @@ var init_agent_good_vibes_tool = __esm({
133069
133200
  // ../vibes.diy/api/svc/intern/agent-follow-vibe-tool.ts
133070
133201
  import { Result as Result225, exception2Result as exception2Result288 } from "@adviser/cement";
133071
133202
  import { type as type178 } from "arktype";
133072
- import { and as and149, eq as eq174 } from "drizzle-orm";
133203
+ import { and as and149, eq as eq175 } from "drizzle-orm";
133073
133204
  function subscriberDocId(handle) {
133074
133205
  return `subscriber:${handle}`;
133075
133206
  }
@@ -133114,7 +133245,7 @@ function createFollowVibeTool(vctx, args) {
133114
133245
  async function takesFollowers(target2) {
133115
133246
  const t = vctx.sql.tables.accessFunctionBindings;
133116
133247
  const r = await exception2Result288(
133117
- () => vctx.sql.db.select({ dbName: t.dbName }).from(t).where(and149(eq174(t.ownerHandle, target2.ownerHandle), eq174(t.appSlug, target2.appSlug), eq174(t.dbName, SUBSCRIBERS_DB_NAME))).limit(1)
133248
+ () => vctx.sql.db.select({ dbName: t.dbName }).from(t).where(and149(eq175(t.ownerHandle, target2.ownerHandle), eq175(t.appSlug, target2.appSlug), eq175(t.dbName, SUBSCRIBERS_DB_NAME))).limit(1)
133118
133249
  );
133119
133250
  if (r.isErr()) return Result225.Err(r);
133120
133251
  return Result225.Ok(r.Ok().length > 0);
@@ -133424,7 +133555,7 @@ var init_agent_feedback_tool = __esm({
133424
133555
  import { JSONEnDecoderSingleton as JSONEnDecoderSingleton5, Result as Result227, exception2Result as exception2Result290 } from "@adviser/cement";
133425
133556
  import { type as type180 } from "arktype";
133426
133557
  import { max as max10, sql as sql30 } from "drizzle-orm";
133427
- import { and as and150, eq as eq175, inArray as inArray46, ne as ne24, notLike } from "drizzle-orm/sql/expressions";
133558
+ import { and as and150, eq as eq176, inArray as inArray47, ne as ne23, notLike } from "drizzle-orm/sql/expressions";
133428
133559
  import { base58btc as base58btc12 } from "multiformats/bases/base58";
133429
133560
  function encodeVibeActivityCursor(c) {
133430
133561
  return base58btc12.encode(
@@ -133505,10 +133636,10 @@ async function listAccountVibeActivity(vctx, args) {
133505
133636
  const asb = vctx.sql.tables.appSlugBinding;
133506
133637
  const usb = vctx.sql.tables.handleBinding;
133507
133638
  const rVibes = await exception2Result290(
133508
- () => vctx.sql.db.select({ ownerHandle: asb.ownerHandle, appSlug: asb.appSlug, updated: asb.updated, unpublishedAt: asb.unpublishedAt }).from(usb).innerJoin(asb, eq175(asb.ownerHandle, usb.handle)).where(
133639
+ () => vctx.sql.db.select({ ownerHandle: asb.ownerHandle, appSlug: asb.appSlug, updated: asb.updated, unpublishedAt: asb.unpublishedAt }).from(usb).innerJoin(asb, eq176(asb.ownerHandle, usb.handle)).where(
133509
133640
  and150(
133510
- eq175(usb.userId, args.userId),
133511
- filter.handles === void 0 ? void 0 : inArray46(usb.handle, filter.handles.length === 0 ? [""] : [...filter.handles])
133641
+ eq176(usb.userId, args.userId),
133642
+ filter.handles === void 0 ? void 0 : inArray47(usb.handle, filter.handles.length === 0 ? [""] : [...filter.handles])
133512
133643
  )
133513
133644
  )
133514
133645
  );
@@ -133523,7 +133654,7 @@ async function listAccountVibeActivity(vctx, args) {
133523
133654
  dbName: docs.dbName,
133524
133655
  docId: docs.docId,
133525
133656
  headSeq: max10(docs.seq).as("headSeq")
133526
- }).from(docs).where(and150(inArray46(docs.ownerHandle, handles), notLike(docs.docId, `${SEED_DOC_PREFIX}%`))).groupBy(docs.ownerHandle, docs.appSlug, docs.dbName, docs.docId).as("heads");
133657
+ }).from(docs).where(and150(inArray47(docs.ownerHandle, handles), notLike(docs.docId, `${SEED_DOC_PREFIX}%`))).groupBy(docs.ownerHandle, docs.appSlug, docs.dbName, docs.docId).as("heads");
133527
133658
  const records = sql30`cast(count(*) as int)`;
133528
133659
  const lastWrite = sql30`max(${docs.created})`;
133529
133660
  const reqG = vctx.sql.tables.requestGrants;
@@ -133533,21 +133664,21 @@ async function listAccountVibeActivity(vctx, args) {
133533
133664
  vctx.sql.db.select({ ownerHandle: docs.ownerHandle, appSlug: docs.appSlug, userId: docs.userId, records, lastWrite }).from(docs).innerJoin(
133534
133665
  heads,
133535
133666
  and150(
133536
- eq175(docs.ownerHandle, heads.ownerHandle),
133537
- eq175(docs.appSlug, heads.appSlug),
133538
- eq175(docs.dbName, heads.dbName),
133539
- eq175(docs.docId, heads.docId),
133540
- eq175(docs.seq, heads.headSeq)
133667
+ eq176(docs.ownerHandle, heads.ownerHandle),
133668
+ eq176(docs.appSlug, heads.appSlug),
133669
+ eq176(docs.dbName, heads.dbName),
133670
+ eq176(docs.docId, heads.docId),
133671
+ eq176(docs.seq, heads.headSeq)
133541
133672
  )
133542
- ).where(and150(eq175(docs.deleted, 0), ne24(docs.userId, args.userId))).groupBy(docs.ownerHandle, docs.appSlug, docs.userId),
133673
+ ).where(and150(eq176(docs.deleted, 0), ne23(docs.userId, args.userId))).groupBy(docs.ownerHandle, docs.appSlug, docs.userId),
133543
133674
  // 3. THE TEAM'S TEST ACCOUNTS: any account holding a team test handle.
133544
- vctx.sql.db.select({ userId: usb.userId }).from(usb).where(inArray46(usb.handle, [...TEAM_TEST_HANDLES])),
133675
+ vctx.sql.db.select({ userId: usb.userId }).from(usb).where(inArray47(usb.handle, [...TEAM_TEST_HANDLES])),
133545
133676
  // 4. WHO WAS LET IN, AND WHO ASKED: grant rows the owner's account holds,
133546
133677
  // one row per person so a member with two ways in (an approved request
133547
133678
  // AND an accepted invite) is one member — report-growth-memberships.ts
133548
133679
  // dedupes the same way.
133549
- vctx.sql.db.selectDistinct({ ownerHandle: reqG.ownerHandle, appSlug: reqG.appSlug, state: reqG.state, memberId: reqG.foreignUserId }).from(reqG).where(and150(eq175(reqG.userId, args.userId), inArray46(reqG.ownerHandle, handles), inArray46(reqG.state, ["approved", "pending"]))),
133550
- vctx.sql.db.selectDistinct({ ownerHandle: invG.ownerHandle, appSlug: invG.appSlug, memberId: invG.tokenOrGrantUserId }).from(invG).where(and150(eq175(invG.userId, args.userId), inArray46(invG.ownerHandle, handles), eq175(invG.state, "accepted")))
133680
+ vctx.sql.db.selectDistinct({ ownerHandle: reqG.ownerHandle, appSlug: reqG.appSlug, state: reqG.state, memberId: reqG.foreignUserId }).from(reqG).where(and150(eq176(reqG.userId, args.userId), inArray47(reqG.ownerHandle, handles), inArray47(reqG.state, ["approved", "pending"]))),
133681
+ vctx.sql.db.selectDistinct({ ownerHandle: invG.ownerHandle, appSlug: invG.appSlug, memberId: invG.tokenOrGrantUserId }).from(invG).where(and150(eq176(invG.userId, args.userId), inArray47(invG.ownerHandle, handles), eq176(invG.state, "accepted")))
133551
133682
  ])
133552
133683
  );
133553
133684
  if (rReads.isErr()) return Result227.Err(rReads);
@@ -133602,14 +133733,14 @@ async function listAccountVibeActivity(vctx, args) {
133602
133733
  const settings = vctx.sql.tables.appSettings;
133603
133734
  const rDetails = await exception2Result290(
133604
133735
  () => Promise.all([
133605
- vctx.sql.db.select({ ownerHandle: tApps.ownerHandle, appSlug: tApps.appSlug }).from(tApps).where(and150(eq175(tApps.mode, "production"), inArray46(tApps.ownerHandle, pageHandles), inArray46(tApps.appSlug, pageSlugs))),
133736
+ vctx.sql.db.select({ ownerHandle: tApps.ownerHandle, appSlug: tApps.appSlug }).from(tApps).where(and150(eq176(tApps.mode, "production"), inArray47(tApps.ownerHandle, pageHandles), inArray47(tApps.appSlug, pageSlugs))),
133606
133737
  vctx.sql.db.select({
133607
133738
  ownerHandle: settings.ownerHandle,
133608
133739
  appSlug: settings.appSlug,
133609
133740
  settings: settings.settings,
133610
133741
  settingsItemizedAt: settings.settingsItemizedAt
133611
133742
  }).from(settings).where(
133612
- and150(eq175(settings.userId, args.userId), inArray46(settings.ownerHandle, pageHandles), inArray46(settings.appSlug, pageSlugs))
133743
+ and150(eq176(settings.userId, args.userId), inArray47(settings.ownerHandle, pageHandles), inArray47(settings.appSlug, pageSlugs))
133613
133744
  ),
133614
133745
  resolveActiveHandles(
133615
133746
  vctx,
@@ -134068,7 +134199,7 @@ var init_guided_remix = __esm({
134068
134199
 
134069
134200
  // ../vibes.diy/api/svc/public/stripe-connect.ts
134070
134201
  import { BuildURI as BuildURI20, exception2Result as exception2Result292, URI as URI40 } from "@adviser/cement";
134071
- import { and as and151, eq as eq176 } from "drizzle-orm/sql/expressions";
134202
+ import { and as and151, eq as eq177 } from "drizzle-orm/sql/expressions";
134072
134203
  var init_stripe_connect = __esm({
134073
134204
  "../vibes.diy/api/svc/public/stripe-connect.ts"() {
134074
134205
  "use strict";
@@ -134084,10 +134215,10 @@ var init_stripe_connect = __esm({
134084
134215
 
134085
134216
  // ../vibes.diy/api/svc/public/github-status.ts
134086
134217
  import { exception2Result as exception2Result293, URI as URI41 } from "@adviser/cement";
134087
- import { and as and152, asc as asc16, eq as eq177 } from "drizzle-orm/sql/expressions";
134218
+ import { and as and152, asc as asc16, eq as eq178 } from "drizzle-orm/sql/expressions";
134088
134219
  async function readGithubRepos(sql43, owner, slug) {
134089
134220
  const t = sql43.tables.githubRepoRoutes;
134090
- const rows = await sql43.db.select({ repo: t.repoFullName }).from(t).where(and152(eq177(t.ownerHandle, owner), eq177(t.appSlug, slug), eq177(t.removedAt, ""))).orderBy(asc16(t.created), asc16(t.repoFullName));
134221
+ const rows = await sql43.db.select({ repo: t.repoFullName }).from(t).where(and152(eq178(t.ownerHandle, owner), eq178(t.appSlug, slug), eq178(t.removedAt, ""))).orderBy(asc16(t.created), asc16(t.repoFullName));
134091
134222
  return [...new Set(rows.map((r) => r.repo))].map((repo) => ({ repo }));
134092
134223
  }
134093
134224
  var init_github_status = __esm({
@@ -134287,14 +134418,14 @@ var init_agent_guided_plan = __esm({
134287
134418
  // ../vibes.diy/api/svc/intern/agent-guided-run.ts
134288
134419
  import { Result as Result229, exception2Result as exception2Result294, stream2uint8array as stream2uint8array14 } from "@adviser/cement";
134289
134420
  import { type as type182 } from "arktype";
134290
- import { and as and153, desc as desc35, eq as eq178 } from "drizzle-orm/sql/expressions";
134421
+ import { and as and153, desc as desc35, eq as eq179 } from "drizzle-orm/sql/expressions";
134291
134422
  async function readGuidedDefinition(vctx, guide) {
134292
134423
  const flags = await exception2Result294(() => getBindingFlags(vctx, guide));
134293
134424
  if (flags.isErr()) return Result229.Err(flags);
134294
134425
  if (flags.Ok().unpublishedAt !== "") return Result229.Err("the guide is not published");
134295
134426
  const t = vctx.sql.tables.apps;
134296
134427
  const rRow = await exception2Result294(
134297
- () => vctx.sql.db.select({ fileSystem: t.fileSystem }).from(t).where(and153(eq178(t.ownerHandle, guide.ownerHandle), eq178(t.appSlug, guide.appSlug), eq178(t.mode, "production"))).orderBy(desc35(t.releaseSeq)).limit(1).then((rows) => rows[0])
134428
+ () => vctx.sql.db.select({ fileSystem: t.fileSystem }).from(t).where(and153(eq179(t.ownerHandle, guide.ownerHandle), eq179(t.appSlug, guide.appSlug), eq179(t.mode, "production"))).orderBy(desc35(t.releaseSeq)).limit(1).then((rows) => rows[0])
134298
134429
  );
134299
134430
  if (rRow.isErr()) return Result229.Err(rRow);
134300
134431
  const row = rRow.Ok();
@@ -134973,7 +135104,7 @@ var init_agent_own_vibe_tools = __esm({
134973
135104
  // ../vibes.diy/api/svc/public/set-unpublish.ts
134974
135105
  import { Result as Result231, Option as Option47, EventoResult as EventoResult41 } from "@adviser/cement";
134975
135106
  import { type as type184 } from "arktype";
134976
- import { eq as eq179, and as and154 } from "drizzle-orm/sql/expressions";
135107
+ import { eq as eq180, and as and154 } from "drizzle-orm/sql/expressions";
134977
135108
  async function setUnpublishFor(vctx, req2) {
134978
135109
  const userId = req2.userId;
134979
135110
  const auth = await authorizeSlugOwner(vctx, { ownerHandle: req2.ownerHandle, appSlug: req2.appSlug, userId });
@@ -135002,7 +135133,7 @@ async function setUnpublishFor(vctx, req2) {
135002
135133
  const asb = vctx.sql.tables.appSlugBinding;
135003
135134
  const previousUnpublishedAt = auth.appRow.unpublishedAt;
135004
135135
  const unpublishedAt = req2.unpublish ? (/* @__PURE__ */ new Date()).toISOString() : "";
135005
- await vctx.sql.db.update(asb).set({ unpublishedAt }).where(and154(eq179(asb.ownerHandle, req2.ownerHandle), eq179(asb.appSlug, req2.appSlug)));
135136
+ await vctx.sql.db.update(asb).set({ unpublishedAt }).where(and154(eq180(asb.ownerHandle, req2.ownerHandle), eq180(asb.appSlug, req2.appSlug)));
135006
135137
  purgeRootHtmlCacheSameColo(vctx, req2.ownerHandle, req2.appSlug);
135007
135138
  if (req2.unpublish) {
135008
135139
  await enqueueAppClipDeactivate(vctx, { ownerHandle: req2.ownerHandle, appSlug: req2.appSlug });
@@ -135082,7 +135213,7 @@ var init_fork_seed_text = __esm({
135082
135213
  // ../vibes.diy/api/svc/public/get-app-by-fsid.ts
135083
135214
  import { Result as Result232, Option as Option48, EventoResult as EventoResult42, exception2Result as exception2Result296 } from "@adviser/cement";
135084
135215
  import { type as type185 } from "arktype";
135085
- import { and as and155, desc as desc36, eq as eq180 } from "drizzle-orm/sql/expressions";
135216
+ import { and as and155, desc as desc36, eq as eq181 } from "drizzle-orm/sql/expressions";
135086
135217
  function grantedAccess(role) {
135087
135218
  switch (role) {
135088
135219
  case "editor":
@@ -135097,7 +135228,7 @@ function grantedAccess(role) {
135097
135228
  async function readAgentDispatched(vctx, runId) {
135098
135229
  if (runId === void 0 || runId === null || runId === "") return void 0;
135099
135230
  const rRow = await exception2Result296(
135100
- () => vctx.sql.db.select({ ref: vctx.sql.tables.promptContexts.ref }).from(vctx.sql.tables.promptContexts).where(eq180(vctx.sql.tables.promptContexts.promptId, runId)).limit(1).then((r) => r[0])
135231
+ () => vctx.sql.db.select({ ref: vctx.sql.tables.promptContexts.ref }).from(vctx.sql.tables.promptContexts).where(eq181(vctx.sql.tables.promptContexts.promptId, runId)).limit(1).then((r) => r[0])
135101
135232
  );
135102
135233
  if (rRow.isErr()) return void 0;
135103
135234
  const row = rRow.Ok();
@@ -135107,10 +135238,10 @@ async function readAgentDispatched(vctx, runId) {
135107
135238
  async function cachedSuggestionSourceIsPublic(vctx, args) {
135108
135239
  const srcProd = await vctx.sql.db.select({ fsId: vctx.sql.tables.apps.fsId }).from(vctx.sql.tables.apps).where(
135109
135240
  and155(
135110
- eq180(vctx.sql.tables.apps.fsId, args.sourceFsId),
135111
- eq180(vctx.sql.tables.apps.appSlug, args.appSlug),
135112
- eq180(vctx.sql.tables.apps.ownerHandle, args.ownerHandle),
135113
- eq180(vctx.sql.tables.apps.mode, "production")
135241
+ eq181(vctx.sql.tables.apps.fsId, args.sourceFsId),
135242
+ eq181(vctx.sql.tables.apps.appSlug, args.appSlug),
135243
+ eq181(vctx.sql.tables.apps.ownerHandle, args.ownerHandle),
135244
+ eq181(vctx.sql.tables.apps.mode, "production")
135114
135245
  )
135115
135246
  ).limit(1).then((r) => r[0]);
135116
135247
  return !!srcProd;
@@ -135185,9 +135316,9 @@ var init_get_app_by_fsid = __esm({
135185
135316
  if (req2.fsId) {
135186
135317
  app = await vctx.sql.db.select().from(vctx.sql.tables.apps).where(
135187
135318
  and155(
135188
- eq180(vctx.sql.tables.apps.fsId, req2.fsId),
135189
- eq180(vctx.sql.tables.apps.appSlug, req2.appSlug),
135190
- eq180(vctx.sql.tables.apps.ownerHandle, req2.ownerHandle)
135319
+ eq181(vctx.sql.tables.apps.fsId, req2.fsId),
135320
+ eq181(vctx.sql.tables.apps.appSlug, req2.appSlug),
135321
+ eq181(vctx.sql.tables.apps.ownerHandle, req2.ownerHandle)
135191
135322
  )
135192
135323
  ).orderBy(desc36(vctx.sql.tables.apps.mode), desc36(vctx.sql.tables.apps.releaseSeq)).limit(1).then((r) => r[0]);
135193
135324
  } else if ((req2.selectMode === "ownerLatest" || req2.selectMode === "ownerDraft") && callerUserId) {
@@ -135290,7 +135421,7 @@ var init_get_app_by_fsid = __esm({
135290
135421
  const settings = rAppSet.Ok().settings;
135291
135422
  const ownerIsGuest = isGuestPrincipal(app.userId);
135292
135423
  const publicReadable = settings.entry.publicAccess?.enable === true;
135293
- const ownerSettingsRow = await vctx.sql.db.select({ settings: vctx.sql.tables.userSettings.settings }).from(vctx.sql.tables.userSettings).where(eq180(vctx.sql.tables.userSettings.userId, app.userId)).limit(1).then((r) => r[0]);
135424
+ const ownerSettingsRow = await vctx.sql.db.select({ settings: vctx.sql.tables.userSettings.settings }).from(vctx.sql.tables.userSettings).where(eq181(vctx.sql.tables.userSettings.userId, app.userId)).limit(1).then((r) => r[0]);
135294
135425
  const ownerDisplayName = resolveOwnerDisplayName(
135295
135426
  ownerSettingsRow?.settings,
135296
135427
  // The token claims are a fallback for the OWNER'S OWN name, so they
@@ -135597,7 +135728,7 @@ import {
135597
135728
  TxtEnDecoderSingleton as TxtEnDecoderSingleton19
135598
135729
  } from "@adviser/cement";
135599
135730
  import { type as type186 } from "arktype";
135600
- import { and as and156, eq as eq181, gte as gte6 } from "drizzle-orm/sql/expressions";
135731
+ import { and as and156, eq as eq182, gte as gte6 } from "drizzle-orm/sql/expressions";
135601
135732
  import { generate as generate5 } from "random-words";
135602
135733
  function sanitizeSlug(raw) {
135603
135734
  return raw.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-+|-+$/g, "");
@@ -135621,9 +135752,9 @@ async function loadForkSource(vctx, ref, callerUserId) {
135621
135752
  if (hasPinnedFsId) {
135622
135753
  src = await vctx.sql.db.select().from(vctx.sql.tables.apps).where(
135623
135754
  and156(
135624
- eq181(vctx.sql.tables.apps.fsId, ref.srcFsId),
135625
- eq181(vctx.sql.tables.apps.appSlug, ref.srcAppSlug),
135626
- eq181(vctx.sql.tables.apps.ownerHandle, ref.srcUserSlug)
135755
+ eq182(vctx.sql.tables.apps.fsId, ref.srcFsId),
135756
+ eq182(vctx.sql.tables.apps.appSlug, ref.srcAppSlug),
135757
+ eq182(vctx.sql.tables.apps.ownerHandle, ref.srcUserSlug)
135627
135758
  )
135628
135759
  ).limit(1).then((r) => r[0]);
135629
135760
  } else {
@@ -135689,16 +135820,16 @@ async function findRepeatedFork(vctx, args) {
135689
135820
  const t = vctx.sql.tables;
135690
135821
  const cutoff = new Date(Date.now() - FORK_REQUEST_WINDOW_MS).toISOString();
135691
135822
  const rows = await vctx.sql.db.select({ chatId: t.promptContexts.chatId, ref: t.promptContexts.ref, created: t.promptContexts.created }).from(t.promptContexts).where(
135692
- and156(eq181(t.promptContexts.userId, args.userId), gte6(t.promptContexts.created, cutoff), eq181(t.promptContexts.totalTokens, 0))
135823
+ and156(eq182(t.promptContexts.userId, args.userId), gte6(t.promptContexts.created, cutoff), eq182(t.promptContexts.totalTokens, 0))
135693
135824
  );
135694
135825
  const hit = rows.filter((r) => {
135695
135826
  const ref = r.ref;
135696
135827
  return ref?.fork === true && ref.forkRequestKey === args.keyHash;
135697
135828
  }).sort((a, b) => a.created.localeCompare(b.created))[0];
135698
135829
  if (hit === void 0) return void 0;
135699
- const chat = await vctx.sql.db.select({ appSlug: t.chatContexts.appSlug, ownerHandle: t.chatContexts.ownerHandle }).from(t.chatContexts).where(and156(eq181(t.chatContexts.chatId, hit.chatId), eq181(t.chatContexts.userId, args.userId))).limit(1).then((r) => r[0]);
135830
+ const chat = await vctx.sql.db.select({ appSlug: t.chatContexts.appSlug, ownerHandle: t.chatContexts.ownerHandle }).from(t.chatContexts).where(and156(eq182(t.chatContexts.chatId, hit.chatId), eq182(t.chatContexts.userId, args.userId))).limit(1).then((r) => r[0]);
135700
135831
  if (chat === void 0) return void 0;
135701
- const app = await vctx.sql.db.select({ appSlug: t.apps.appSlug }).from(t.apps).where(and156(eq181(t.apps.appSlug, chat.appSlug), eq181(t.apps.ownerHandle, chat.ownerHandle), eq181(t.apps.userId, args.userId))).limit(1).then((r) => r[0]);
135832
+ const app = await vctx.sql.db.select({ appSlug: t.apps.appSlug }).from(t.apps).where(and156(eq182(t.apps.appSlug, chat.appSlug), eq182(t.apps.ownerHandle, chat.ownerHandle), eq182(t.apps.userId, args.userId))).limit(1).then((r) => r[0]);
135702
135833
  if (app === void 0) return void 0;
135703
135834
  return { chatId: hit.chatId, ownerHandle: chat.ownerHandle, appSlug: chat.appSlug };
135704
135835
  }
@@ -135759,7 +135890,7 @@ async function forkApp(vctx, req2, userId, claims) {
135759
135890
  }
135760
135891
  let destUserSlug;
135761
135892
  if (req2.dstOwnerHandle !== void 0) {
135762
- const bound = await vctx.sql.db.select({ handle: vctx.sql.tables.handleBinding.handle }).from(vctx.sql.tables.handleBinding).where(and156(eq181(vctx.sql.tables.handleBinding.userId, userId), eq181(vctx.sql.tables.handleBinding.handle, req2.dstOwnerHandle))).limit(1).then((r) => r[0]);
135893
+ const bound = await vctx.sql.db.select({ handle: vctx.sql.tables.handleBinding.handle }).from(vctx.sql.tables.handleBinding).where(and156(eq182(vctx.sql.tables.handleBinding.userId, userId), eq182(vctx.sql.tables.handleBinding.handle, req2.dstOwnerHandle))).limit(1).then((r) => r[0]);
135763
135894
  if (bound === void 0) {
135764
135895
  return Result233.Err(
135765
135896
  mkResError(`handle-not-bound: ${req2.dstOwnerHandle} is not a handle of this account`, FORK_DST_HANDLE_NOT_BOUND_CODE)
@@ -136053,7 +136184,7 @@ var init_fork_app = __esm({
136053
136184
  // ../vibes.diy/api/svc/intern/agent-vibe-settings-tools.ts
136054
136185
  import { Result as Result234, exception2Result as exception2Result298 } from "@adviser/cement";
136055
136186
  import { type as type187 } from "arktype";
136056
- import { and as and157, eq as eq182 } from "drizzle-orm/sql/expressions";
136187
+ import { and as and157, eq as eq183 } from "drizzle-orm/sql/expressions";
136057
136188
  function vibeSettingsToolDefinitions() {
136058
136189
  return [
136059
136190
  {
@@ -136131,8 +136262,8 @@ function createAgentVibeSettingsTools(vctx, args) {
136131
136262
  const asb = vctx.sql.tables.appSlugBinding;
136132
136263
  const tApps = vctx.sql.tables.apps;
136133
136264
  const r = await exception2Result298(async () => {
136134
- const binding = await vctx.sql.db.select({ unpublishedAt: asb.unpublishedAt }).from(asb).where(and157(eq182(asb.ownerHandle, ownerHandle), eq182(asb.appSlug, appSlug))).limit(1);
136135
- const prod = await vctx.sql.db.select({ appSlug: tApps.appSlug }).from(tApps).where(and157(eq182(tApps.ownerHandle, ownerHandle), eq182(tApps.appSlug, appSlug), eq182(tApps.mode, "production"))).limit(1);
136265
+ const binding = await vctx.sql.db.select({ unpublishedAt: asb.unpublishedAt }).from(asb).where(and157(eq183(asb.ownerHandle, ownerHandle), eq183(asb.appSlug, appSlug))).limit(1);
136266
+ const prod = await vctx.sql.db.select({ appSlug: tApps.appSlug }).from(tApps).where(and157(eq183(tApps.ownerHandle, ownerHandle), eq183(tApps.appSlug, appSlug), eq183(tApps.mode, "production"))).limit(1);
136136
136267
  const row = binding[0];
136137
136268
  return row === void 0 ? void 0 : { unpublishedAt: row.unpublishedAt, released: prod.length > 0 };
136138
136269
  });
@@ -137137,7 +137268,7 @@ var init_agent_calendar_link_tool = __esm({
137137
137268
  // ../vibes.diy/api/svc/intern/agent-account-tools.ts
137138
137269
  import { JSONEnDecoderSingleton as JSONEnDecoderSingleton6, Result as Result238, exception2Result as exception2Result302 } from "@adviser/cement";
137139
137270
  import { type as type190 } from "arktype";
137140
- import { and as and158, desc as desc37, eq as eq183, inArray as inArray47, lt as lt12, or as or20 } from "drizzle-orm/sql/expressions";
137271
+ import { and as and158, desc as desc37, eq as eq184, inArray as inArray48, lt as lt12, or as or20 } from "drizzle-orm/sql/expressions";
137141
137272
  import { base58btc as base58btc13 } from "multiformats/bases/base58";
137142
137273
  function boundTitle(item) {
137143
137274
  if (item.title === void 0 || item.title.length <= VIBE_ACTIVITY_TITLE_CHARS) return item;
@@ -137199,18 +137330,18 @@ async function listAccountVibes(vctx, args) {
137199
137330
  unpublishedAt: asb.unpublishedAt,
137200
137331
  settings: settings.settings,
137201
137332
  settingsItemizedAt: settings.settingsItemizedAt
137202
- }).from(usb).innerJoin(asb, eq183(asb.ownerHandle, usb.handle)).leftJoin(
137333
+ }).from(usb).innerJoin(asb, eq184(asb.ownerHandle, usb.handle)).leftJoin(
137203
137334
  settings,
137204
- and158(eq183(settings.userId, usb.userId), eq183(settings.ownerHandle, usb.handle), eq183(settings.appSlug, asb.appSlug))
137335
+ and158(eq184(settings.userId, usb.userId), eq184(settings.ownerHandle, usb.handle), eq184(settings.appSlug, asb.appSlug))
137205
137336
  ).where(
137206
137337
  and158(
137207
- eq183(usb.userId, args.userId),
137338
+ eq184(usb.userId, args.userId),
137208
137339
  // Strictly after the cursor under the order below — the tuple
137209
137340
  // predicate `list-recent-vibes` uses, without its pin key.
137210
137341
  after === void 0 ? void 0 : or20(
137211
137342
  lt12(asb.updated, after.updated),
137212
- and158(eq183(asb.updated, after.updated), lt12(asb.ownerHandle, after.ownerHandle)),
137213
- and158(eq183(asb.updated, after.updated), eq183(asb.ownerHandle, after.ownerHandle), lt12(asb.appSlug, after.appSlug))
137343
+ and158(eq184(asb.updated, after.updated), lt12(asb.ownerHandle, after.ownerHandle)),
137344
+ and158(eq184(asb.updated, after.updated), eq184(asb.ownerHandle, after.ownerHandle), lt12(asb.appSlug, after.appSlug))
137214
137345
  )
137215
137346
  )
137216
137347
  ).orderBy(desc37(asb.updated), desc37(asb.ownerHandle), desc37(asb.appSlug)).limit(limit + 1)
@@ -137224,9 +137355,9 @@ async function listAccountVibes(vctx, args) {
137224
137355
  const rProd = await exception2Result302(
137225
137356
  () => vctx.sql.db.select({ ownerHandle: tApps.ownerHandle, appSlug: tApps.appSlug }).from(tApps).where(
137226
137357
  and158(
137227
- eq183(tApps.mode, "production"),
137228
- inArray47(tApps.ownerHandle, [...new Set(page.map((r) => r.ownerHandle))]),
137229
- inArray47(tApps.appSlug, [...new Set(page.map((r) => r.appSlug))])
137358
+ eq184(tApps.mode, "production"),
137359
+ inArray48(tApps.ownerHandle, [...new Set(page.map((r) => r.ownerHandle))]),
137360
+ inArray48(tApps.appSlug, [...new Set(page.map((r) => r.appSlug))])
137230
137361
  )
137231
137362
  )
137232
137363
  );
@@ -137275,7 +137406,7 @@ async function loadTopLevelAgentBrief(vctx, args) {
137275
137406
  const rHandles = await exception2Result302(
137276
137407
  () => (
137277
137408
  // A handle migrated away from is still owned but never listed.
137278
- vctx.sql.db.select({ handle: hb.handle }).from(hb).where(and158(eq183(hb.userId, args.userId), eq183(hb.migratedAway, 0))).orderBy(hb.created, hb.handle)
137409
+ vctx.sql.db.select({ handle: hb.handle }).from(hb).where(and158(eq184(hb.userId, args.userId), eq184(hb.migratedAway, 0))).orderBy(hb.created, hb.handle)
137279
137410
  )
137280
137411
  );
137281
137412
  if (rHandles.isErr()) return Result238.Err(rHandles);
@@ -137691,7 +137822,7 @@ function createAccountAgentBelt(vctx, args) {
137691
137822
  if (rScope.isErr()) return { ok: false, refusal: refused2(toolName, rScope.Err().refusal) };
137692
137823
  const asb = vctx.sql.tables.appSlugBinding;
137693
137824
  const rBound = await exception2Result302(
137694
- () => vctx.sql.db.select({ appSlug: asb.appSlug }).from(asb).where(and158(eq183(asb.ownerHandle, ownerHandle), eq183(asb.appSlug, appSlug))).limit(1)
137825
+ () => vctx.sql.db.select({ appSlug: asb.appSlug }).from(asb).where(and158(eq184(asb.ownerHandle, ownerHandle), eq184(asb.appSlug, appSlug))).limit(1)
137695
137826
  );
137696
137827
  if (rBound.isErr()) {
137697
137828
  vctx.logger.Warn().Err(rBound).Str("chatId", args.chatId).Msg(`top-level-${logKind}-binding-read-failed`);
@@ -137749,7 +137880,7 @@ function createAccountAgentBelt(vctx, args) {
137749
137880
  if (ownerHandle === args.actor.ownerHandle) return true;
137750
137881
  const r = await exception2Result302(
137751
137882
  () => vctx.sql.db.select({ handle: vctx.sql.tables.handleBinding.handle }).from(vctx.sql.tables.handleBinding).where(
137752
- and158(eq183(vctx.sql.tables.handleBinding.userId, args.actor.userId), eq183(vctx.sql.tables.handleBinding.handle, ownerHandle))
137883
+ and158(eq184(vctx.sql.tables.handleBinding.userId, args.actor.userId), eq184(vctx.sql.tables.handleBinding.handle, ownerHandle))
137753
137884
  ).limit(1)
137754
137885
  );
137755
137886
  return r.isErr() || r.Ok().length > 0;
@@ -137778,7 +137909,7 @@ function createAccountAgentBelt(vctx, args) {
137778
137909
  }
137779
137910
  const asb = vctx.sql.tables.appSlugBinding;
137780
137911
  const rBound = await exception2Result302(
137781
- () => vctx.sql.db.select({ appSlug: asb.appSlug }).from(asb).where(and158(eq183(asb.ownerHandle, ownerHandle), eq183(asb.appSlug, appSlug))).limit(1)
137912
+ () => vctx.sql.db.select({ appSlug: asb.appSlug }).from(asb).where(and158(eq184(asb.ownerHandle, ownerHandle), eq184(asb.appSlug, appSlug))).limit(1)
137782
137913
  );
137783
137914
  if (rBound.isErr()) {
137784
137915
  vctx.logger.Warn().Err(rBound).Str("chatId", args.chatId).Msg("top-level-with-member-vibe-binding-read-failed");
@@ -137932,7 +138063,7 @@ function createAccountAgentBelt(vctx, args) {
137932
138063
  async function ownsHandleOf(userId, ownerHandle) {
137933
138064
  const hb = vctx.sql.tables.handleBinding;
137934
138065
  const r = await exception2Result302(
137935
- () => vctx.sql.db.select({ handle: hb.handle }).from(hb).where(and158(eq183(hb.userId, userId), eq183(hb.handle, ownerHandle))).limit(1)
138066
+ () => vctx.sql.db.select({ handle: hb.handle }).from(hb).where(and158(eq184(hb.userId, userId), eq184(hb.handle, ownerHandle))).limit(1)
137936
138067
  );
137937
138068
  return r.isOk() && r.Ok().length > 0;
137938
138069
  }
@@ -137942,7 +138073,7 @@ function createAccountAgentBelt(vctx, args) {
137942
138073
  async function listReadableDatabases(ownerHandle, appSlug, person = args.actor) {
137943
138074
  const ad = vctx.sql.tables.appDocuments;
137944
138075
  const rNames = await exception2Result302(
137945
- () => vctx.sql.db.selectDistinct({ dbName: ad.dbName }).from(ad).where(and158(eq183(ad.ownerHandle, ownerHandle), eq183(ad.appSlug, appSlug))).limit(MEMBER_DB_PROBE_LIMIT)
138076
+ () => vctx.sql.db.selectDistinct({ dbName: ad.dbName }).from(ad).where(and158(eq184(ad.ownerHandle, ownerHandle), eq184(ad.appSlug, appSlug))).limit(MEMBER_DB_PROBE_LIMIT)
137946
138077
  );
137947
138078
  if (rNames.isErr()) {
137948
138079
  return toolJson7({ ok: false, reason: "failed", message: "Could not read this app's record collections just now." });
@@ -139777,7 +139908,7 @@ var init_prompt_step = __esm({
139777
139908
 
139778
139909
  // ../vibes.diy/api/svc/intern/agent-dispatcher.ts
139779
139910
  import { Result as Result244, exception2Result as exception2Result309 } from "@adviser/cement";
139780
- import { and as and159, eq as eq184 } from "drizzle-orm/sql/expressions";
139911
+ import { and as and159, eq as eq185 } from "drizzle-orm/sql/expressions";
139781
139912
  function dispatchedBuildHasTurn(args) {
139782
139913
  const prior = args.prior.isOk() ? new Set(args.prior.Ok()) : void 0;
139783
139914
  return async () => {
@@ -139978,7 +140109,7 @@ function createAgentBuildDispatcher(args) {
139978
140109
  appSlug: vctx.sql.tables.chatContexts.appSlug,
139979
140110
  ownerHandle: vctx.sql.tables.chatContexts.ownerHandle,
139980
140111
  draftPreAlloc: vctx.sql.tables.chatContexts.draftPreAlloc
139981
- }).from(vctx.sql.tables.chatContexts).where(eq184(vctx.sql.tables.chatContexts.chatId, chatId))
140112
+ }).from(vctx.sql.tables.chatContexts).where(eq185(vctx.sql.tables.chatContexts.chatId, chatId))
139982
140113
  );
139983
140114
  if (rProvisional.isErr()) return Result244.Err(rProvisional);
139984
140115
  const provisional = rProvisional.Ok()[0];
@@ -139989,8 +140120,8 @@ function createAgentBuildDispatcher(args) {
139989
140120
  const rAdopt = pinnedAppSlug === void 0 && provisionalSlug !== void 0 && chatOnlySlug2 === provisionalSlug && provisionalHandle === mintArgs.ownerHandle ? await exception2Result309(
139990
140121
  () => vctx.sql.db.select({ appSlug: vctx.sql.tables.appSlugBinding.appSlug }).from(vctx.sql.tables.appSlugBinding).where(
139991
140122
  and159(
139992
- eq184(vctx.sql.tables.appSlugBinding.ownerHandle, provisionalHandle),
139993
- eq184(vctx.sql.tables.appSlugBinding.appSlug, provisionalSlug)
140123
+ eq185(vctx.sql.tables.appSlugBinding.ownerHandle, provisionalHandle),
140124
+ eq185(vctx.sql.tables.appSlugBinding.appSlug, provisionalSlug)
139994
140125
  )
139995
140126
  ).limit(1).then((r) => r[0])
139996
140127
  ) : void 0;
@@ -140024,7 +140155,7 @@ function createAgentBuildDispatcher(args) {
140024
140155
  chosenTitle = rApp.Ok().chosenTitle;
140025
140156
  }
140026
140157
  const rPoint = await exception2Result309(
140027
- () => vctx.sql.db.update(vctx.sql.tables.chatContexts).set({ appSlug, ...pinnedAppSlug === void 0 ? {} : { draftPreAlloc: null } }).where(eq184(vctx.sql.tables.chatContexts.chatId, chatId))
140158
+ () => vctx.sql.db.update(vctx.sql.tables.chatContexts).set({ appSlug, ...pinnedAppSlug === void 0 ? {} : { draftPreAlloc: null } }).where(eq185(vctx.sql.tables.chatContexts.chatId, chatId))
140028
140159
  );
140029
140160
  if (rPoint.isErr()) return Result244.Err(rPoint);
140030
140161
  const rJob = await repointMintJobAppSlug(vctx, { chatId, appSlug });
@@ -140037,8 +140168,8 @@ function createAgentBuildDispatcher(args) {
140037
140168
  const rAssets = await exception2Result309(
140038
140169
  () => vctx.sql.db.update(vctx.sql.tables.assetUploads).set({ appSlug }).where(
140039
140170
  and159(
140040
- eq184(vctx.sql.tables.assetUploads.ownerHandle, provisionalHandle),
140041
- eq184(vctx.sql.tables.assetUploads.appSlug, provisionalSlug)
140171
+ eq185(vctx.sql.tables.assetUploads.ownerHandle, provisionalHandle),
140172
+ eq185(vctx.sql.tables.assetUploads.appSlug, provisionalSlug)
140042
140173
  )
140043
140174
  ).returning({ uploadId: vctx.sql.tables.assetUploads.uploadId })
140044
140175
  );
@@ -140283,7 +140414,7 @@ async function claimPinnedAppSlug(vctx, o) {
140283
140414
  const refuse16 = /* @__PURE__ */ __name((why) => Result244.Err(new PinnedAppSlugUnavailableError(o.appSlug, o.ownerHandle, why)), "refuse");
140284
140415
  const hb = vctx.sql.tables.handleBinding;
140285
140416
  const rOwns = await exception2Result309(
140286
- () => vctx.sql.db.select({ handle: hb.handle }).from(hb).where(and159(eq184(hb.handle, o.ownerHandle), eq184(hb.userId, o.userId))).limit(1)
140417
+ () => vctx.sql.db.select({ handle: hb.handle }).from(hb).where(and159(eq185(hb.handle, o.ownerHandle), eq185(hb.userId, o.userId))).limit(1)
140287
140418
  );
140288
140419
  if (rOwns.isErr()) return Result244.Err(rOwns);
140289
140420
  if (rOwns.Ok().length === 0) return refuse16("only the handle's owner can create an app at a named address");
@@ -140345,7 +140476,7 @@ var init_agent_dispatcher = __esm({
140345
140476
 
140346
140477
  // ../vibes.diy/api/svc/intern/parent-build-link.ts
140347
140478
  import { exception2Result as exception2Result310 } from "@adviser/cement";
140348
- import { eq as eq185 } from "drizzle-orm/sql/expressions";
140479
+ import { eq as eq186 } from "drizzle-orm/sql/expressions";
140349
140480
  async function queueParkedBuildOnSession(vctx, live, args) {
140350
140481
  if (args.buildChatId === args.parentChatId) return;
140351
140482
  const rHandle = await live.queueParkedBuild(args.buildChatId);
@@ -140355,7 +140486,7 @@ async function queueParkedBuildOnSession(vctx, live, args) {
140355
140486
  }
140356
140487
  const mj = vctx.sql.tables.mintJobs;
140357
140488
  const written = await exception2Result310(
140358
- () => vctx.sql.db.update(mj).set({ parentHandleId: rHandle.Ok(), parentChatId: args.parentChatId }).where(eq185(mj.chatId, args.buildChatId))
140489
+ () => vctx.sql.db.update(mj).set({ parentHandleId: rHandle.Ok(), parentChatId: args.parentChatId }).where(eq186(mj.chatId, args.buildChatId))
140359
140490
  );
140360
140491
  if (written.isErr()) {
140361
140492
  vctx.logger.Warn().Err(written).Str("chatId", args.buildChatId).Msg("parked-build-parent-handle-write-failed");
@@ -141146,7 +141277,7 @@ var init_first_build_race = __esm({
141146
141277
 
141147
141278
  // ../vibes.diy/api/svc/intern/agent-closing-options.ts
141148
141279
  import { Result as Result246, exception2Result as exception2Result311 } from "@adviser/cement";
141149
- import { and as and160, eq as eq186, lt as lt13 } from "drizzle-orm";
141280
+ import { and as and160, eq as eq187, lt as lt13 } from "drizzle-orm";
141150
141281
  function createAgentClosingOptions(vctx, args) {
141151
141282
  return /* @__PURE__ */ __name(async function settle2(held2) {
141152
141283
  const { prose, asked } = parseClosingOptionLines(held2);
@@ -141239,7 +141370,7 @@ async function seedOfferState(vctx, app) {
141239
141370
  }
141240
141371
  async function chatOfferHistory(vctx, chatId) {
141241
141372
  const t = vctx.sql.tables.chatSections;
141242
- const rows = await vctx.sql.db.select({ blocks: t.blocks }).from(t).where(and160(eq186(t.chatId, chatId), lt13(t.blockSeq, AGENT_EVIDENCE_FIRST_SEQ)));
141373
+ const rows = await vctx.sql.db.select({ blocks: t.blocks }).from(t).where(and160(eq187(t.chatId, chatId), lt13(t.blockSeq, AGENT_EVIDENCE_FIRST_SEQ)));
141243
141374
  let seedOffered = false;
141244
141375
  const goldKinds = /* @__PURE__ */ new Set();
141245
141376
  for (const row of rows) {
@@ -143844,7 +143975,7 @@ var init_prompt_section_actions = __esm({
143844
143975
  // ../vibes.diy/api/svc/public/list-app-models.ts
143845
143976
  import { Result as Result252, Option as Option50, EventoResult as EventoResult44, exception2Result as exception2Result318 } from "@adviser/cement";
143846
143977
  import { type as type195 } from "arktype";
143847
- import { eq as eq187 } from "drizzle-orm/sql/expressions";
143978
+ import { eq as eq188 } from "drizzle-orm/sql/expressions";
143848
143979
  function catalogServes(model, kind) {
143849
143980
  const supports = model.supports ?? [];
143850
143981
  return kind === "image" ? supports.includes("img") || supports.includes("img-edit") : supports.includes("runtime");
@@ -143882,7 +144013,7 @@ function composeAppModelOptions(args) {
143882
144013
  }
143883
144014
  async function readCallerModelDefaults(vctx, userId) {
143884
144015
  const rRow = await exception2Result318(
143885
- () => vctx.sql.db.select().from(vctx.sql.tables.userSettings).where(eq187(vctx.sql.tables.userSettings.userId, userId)).limit(1).then((r) => r[0])
144016
+ () => vctx.sql.db.select().from(vctx.sql.tables.userSettings).where(eq188(vctx.sql.tables.userSettings.userId, userId)).limit(1).then((r) => r[0])
143886
144017
  );
143887
144018
  if (rRow.isErr()) return Result252.Err(rRow);
143888
144019
  const row = rRow.Ok();
@@ -144041,12 +144172,12 @@ var init_caller_model = __esm({
144041
144172
  });
144042
144173
 
144043
144174
  // ../vibes.diy/api/svc/intern/settle-time-turn-state.ts
144044
- import { eq as eq188 } from "drizzle-orm/sql/expressions";
144175
+ import { eq as eq189 } from "drizzle-orm/sql/expressions";
144045
144176
  import { exception2Result as exception2Result319 } from "@adviser/cement";
144046
144177
  async function settleTimeTurnState(vctx, args) {
144047
144178
  const rRow = await exception2Result319(() => {
144048
144179
  const cc = vctx.sql.tables.chatContexts;
144049
- return vctx.sql.db.select({ ownerHandle: cc.ownerHandle, appSlug: cc.appSlug, userId: cc.userId }).from(cc).where(eq188(cc.chatId, args.chatId)).limit(1).then((r) => r[0]);
144180
+ return vctx.sql.db.select({ ownerHandle: cc.ownerHandle, appSlug: cc.appSlug, userId: cc.userId }).from(cc).where(eq189(cc.chatId, args.chatId)).limit(1).then((r) => r[0]);
144050
144181
  });
144051
144182
  if (rRow.isErr()) vctx.logger.Warn().Err(rRow).Str("chatId", args.chatId).Msg("settle-address-read-failed");
144052
144183
  const row = rRow.isOk() ? rRow.Ok() : void 0;
@@ -144296,7 +144427,7 @@ var init_deliver_post_turn_version = __esm({
144296
144427
 
144297
144428
  // ../vibes.diy/api/svc/intern/design-repair.ts
144298
144429
  import { Result as Result255, exception2Result as exception2Result321, stream2uint8array as stream2uint8array15 } from "@adviser/cement";
144299
- import { and as and161, desc as desc38, eq as eq189, isNotNull as isNotNull7 } from "drizzle-orm";
144430
+ import { and as and161, desc as desc38, eq as eq190, isNotNull as isNotNull7 } from "drizzle-orm";
144300
144431
  import { type as type196 } from "arktype";
144301
144432
  function designRepairEnabled(flag22) {
144302
144433
  return flag22 !== "off";
@@ -144385,7 +144516,7 @@ async function resolveSourcesStrict(vctx, items) {
144385
144516
  return sources;
144386
144517
  }
144387
144518
  async function loadDesignRepairInputs(vctx, args) {
144388
- const rows = await vctx.sql.db.select({ fileSystem: vctx.sql.tables.apps.fileSystem }).from(vctx.sql.tables.apps).where(eq189(vctx.sql.tables.apps.fsId, args.fsId)).limit(1);
144519
+ const rows = await vctx.sql.db.select({ fileSystem: vctx.sql.tables.apps.fileSystem }).from(vctx.sql.tables.apps).where(eq190(vctx.sql.tables.apps.fsId, args.fsId)).limit(1);
144389
144520
  const row = rows[0];
144390
144521
  if (row === void 0) return void 0;
144391
144522
  const items = parseArray(row.fileSystem, fileSystemItem);
@@ -144408,7 +144539,7 @@ async function chatHeadFsId(vctx, chatId) {
144408
144539
  const pc = vctx.sql.tables.promptContexts;
144409
144540
  const apps = vctx.sql.tables.apps;
144410
144541
  return exception2Result321(async () => {
144411
- const rows = await vctx.sql.db.select({ fsId: pc.fsId }).from(pc).innerJoin(apps, eq189(apps.fsId, pc.fsId)).where(and161(eq189(pc.chatId, chatId), isNotNull7(pc.fsId))).orderBy(desc38(pc.created)).limit(1);
144542
+ const rows = await vctx.sql.db.select({ fsId: pc.fsId }).from(pc).innerJoin(apps, eq190(apps.fsId, pc.fsId)).where(and161(eq190(pc.chatId, chatId), isNotNull7(pc.fsId))).orderBy(desc38(pc.created)).limit(1);
144412
144543
  return rows[0]?.fsId ?? void 0;
144413
144544
  });
144414
144545
  }
@@ -144677,11 +144808,11 @@ async function persistRepair(vctx, args, o) {
144677
144808
  const rDel = await exception2Result321(
144678
144809
  () => vctx.sql.db.delete(a).where(
144679
144810
  and161(
144680
- eq189(a.appSlug, args.appSlug),
144681
- eq189(a.ownerHandle, args.ownerHandle),
144682
- eq189(a.runId, repairPromptId),
144683
- eq189(a.fsId, fsRef.fsId),
144684
- eq189(a.mode, "dev")
144811
+ eq190(a.appSlug, args.appSlug),
144812
+ eq190(a.ownerHandle, args.ownerHandle),
144813
+ eq190(a.runId, repairPromptId),
144814
+ eq190(a.fsId, fsRef.fsId),
144815
+ eq190(a.mode, "dev")
144685
144816
  )
144686
144817
  )
144687
144818
  );
@@ -144967,7 +145098,7 @@ var init_prompt_dispatch_context = __esm({
144967
145098
 
144968
145099
  // ../vibes.diy/api/svc/public/turn-summary-dispatch.ts
144969
145100
  import { exception2Result as exception2Result322 } from "@adviser/cement";
144970
- import { and as and162, asc as asc17, eq as eq190, inArray as inArray48, ne as ne25 } from "drizzle-orm/sql/expressions";
145101
+ import { and as and162, asc as asc17, eq as eq191, inArray as inArray49, ne as ne24 } from "drizzle-orm/sql/expressions";
144971
145102
  function turnSummaryEnabled(flag22) {
144972
145103
  return flag22 !== "off";
144973
145104
  }
@@ -144976,13 +145107,13 @@ function wantsTurnSummary(i) {
144976
145107
  }
144977
145108
  async function turnMsgs(vctx, chatId, promptId) {
144978
145109
  const t = vctx.sql.tables.chatSections;
144979
- const rows = await vctx.sql.db.select({ blocks: t.blocks }).from(t).where(and162(eq190(t.chatId, chatId), eq190(t.promptId, promptId))).orderBy(asc17(t.blockSeq));
145110
+ const rows = await vctx.sql.db.select({ blocks: t.blocks }).from(t).where(and162(eq191(t.chatId, chatId), eq191(t.promptId, promptId))).orderBy(asc17(t.blockSeq));
144980
145111
  return rows.flatMap((row) => readChatSectionBlocks(row.blocks));
144981
145112
  }
144982
145113
  async function joinedMsgs(vctx, turn) {
144983
145114
  const { chatId, promptId } = turn;
144984
145115
  const t = vctx.sql.tables.chatSections;
144985
- const rows = await vctx.sql.db.select({ promptId: t.promptId, blocks: t.blocks }).from(t).where(and162(eq190(t.chatId, chatId), ne25(t.promptId, promptId), inArray48(t.blockSeq, [0, AGENT_EVIDENCE_FIRST_SEQ - 1]))).orderBy(asc17(t.created), asc17(t.promptId), asc17(t.blockSeq));
145116
+ const rows = await vctx.sql.db.select({ promptId: t.promptId, blocks: t.blocks }).from(t).where(and162(eq191(t.chatId, chatId), ne24(t.promptId, promptId), inArray49(t.blockSeq, [0, AGENT_EVIDENCE_FIRST_SEQ - 1]))).orderBy(asc17(t.created), asc17(t.promptId), asc17(t.blockSeq));
144986
145117
  const turns2 = /* @__PURE__ */ new Map();
144987
145118
  for (const row of rows) {
144988
145119
  const msgs = turns2.get(row.promptId) ?? [];
@@ -145181,18 +145312,18 @@ var init_discussion_title = __esm({
145181
145312
  // ../vibes.diy/api/svc/public/discussion-title-dispatch.ts
145182
145313
  import { exception2Result as exception2Result324 } from "@adviser/cement";
145183
145314
  import { max as max11 } from "drizzle-orm";
145184
- import { and as and163, asc as asc18, eq as eq191, inArray as inArray49 } from "drizzle-orm/sql/expressions";
145315
+ import { and as and163, asc as asc18, eq as eq192, inArray as inArray50 } from "drizzle-orm/sql/expressions";
145185
145316
  function wantsDiscussionTitle(i) {
145186
145317
  return i.enabled && i.appSlug === AGENT_CHAT_APP_SLUG && i.agentTurn && i.turnBegan && !i.errored && !i.byok;
145187
145318
  }
145188
145319
  async function firstPersonTurn(vctx, chatId) {
145189
145320
  const t = vctx.sql.tables.chatSections;
145190
- const openers = await vctx.sql.db.select({ promptId: t.promptId, blocks: t.blocks }).from(t).where(and163(eq191(t.chatId, chatId), inArray49(t.blockSeq, [...TURN_OPENING_BLOCK_SEQS]))).orderBy(asc18(t.created), asc18(t.promptId), asc18(t.blockSeq));
145321
+ const openers = await vctx.sql.db.select({ promptId: t.promptId, blocks: t.blocks }).from(t).where(and163(eq192(t.chatId, chatId), inArray50(t.blockSeq, [...TURN_OPENING_BLOCK_SEQS]))).orderBy(asc18(t.created), asc18(t.promptId), asc18(t.blockSeq));
145191
145322
  const first = openers.find(
145192
145323
  (row) => readChatSectionBlocks(row.blocks).some((msg) => isPromptReq(msg) && personPromptText(msg) !== void 0)
145193
145324
  );
145194
145325
  if (first === void 0) return void 0;
145195
- const last = await vctx.sql.db.select({ lastWrite: max11(t.created) }).from(t).where(and163(eq191(t.chatId, chatId), eq191(t.promptId, first.promptId)));
145326
+ const last = await vctx.sql.db.select({ lastWrite: max11(t.created) }).from(t).where(and163(eq192(t.chatId, chatId), eq192(t.promptId, first.promptId)));
145196
145327
  const lastWrite = last[0]?.lastWrite;
145197
145328
  return { promptId: first.promptId, lastWrite: typeof lastWrite === "string" ? lastWrite : "" };
145198
145329
  }
@@ -145204,12 +145335,12 @@ function ownsDiscussionTitle(i) {
145204
145335
  }
145205
145336
  async function hasDiscussionTitle(vctx, chatId) {
145206
145337
  const t = vctx.sql.tables.chatSections;
145207
- const rows = await vctx.sql.db.select({ promptId: t.promptId }).from(t).where(and163(eq191(t.chatId, chatId), eq191(t.blockSeq, DISCUSSION_TITLE_BLOCK_SEQ))).limit(1);
145338
+ const rows = await vctx.sql.db.select({ promptId: t.promptId }).from(t).where(and163(eq192(t.chatId, chatId), eq192(t.blockSeq, DISCUSSION_TITLE_BLOCK_SEQ))).limit(1);
145208
145339
  return rows.length > 0;
145209
145340
  }
145210
145341
  async function turnMsgs2(vctx, chatId, promptId) {
145211
145342
  const t = vctx.sql.tables.chatSections;
145212
- const rows = await vctx.sql.db.select({ blocks: t.blocks }).from(t).where(and163(eq191(t.chatId, chatId), eq191(t.promptId, promptId))).orderBy(asc18(t.blockSeq));
145343
+ const rows = await vctx.sql.db.select({ blocks: t.blocks }).from(t).where(and163(eq192(t.chatId, chatId), eq192(t.promptId, promptId))).orderBy(asc18(t.blockSeq));
145213
145344
  return rows.flatMap((row) => readChatSectionBlocks(row.blocks)).filter((msg) => {
145214
145345
  const streamId = msg.streamId;
145215
145346
  return typeof streamId !== "string" || streamId === promptId;
@@ -147359,7 +147490,7 @@ var init_shared_mint2 = __esm({
147359
147490
  // ../vibes.diy/api/svc/public/list-user-slug-app-slug.ts
147360
147491
  import { Result as Result262, Option as Option54, EventoResult as EventoResult48 } from "@adviser/cement";
147361
147492
  import { type as type201 } from "arktype";
147362
- import { eq as eq192, and as and164, desc as desc39 } from "drizzle-orm/sql/expressions";
147493
+ import { eq as eq193, and as and164, desc as desc39 } from "drizzle-orm/sql/expressions";
147363
147494
  var listUserSlugAppSlugEvento;
147364
147495
  var init_list_user_slug_app_slug = __esm({
147365
147496
  "../vibes.diy/api/svc/public/list-user-slug-app-slug.ts"() {
@@ -147386,12 +147517,12 @@ var init_list_user_slug_app_slug = __esm({
147386
147517
  const req2 = ctx.validated.payload;
147387
147518
  const vctx = ctx.ctx.getOrThrow("vibesApiCtx");
147388
147519
  const userId = req2._auth.verifiedAuth.claims.userId;
147389
- const conditions = [eq192(vctx.sql.tables.handleBinding.userId, userId)];
147520
+ const conditions = [eq193(vctx.sql.tables.handleBinding.userId, userId)];
147390
147521
  if (req2.ownerHandle) {
147391
- conditions.push(eq192(vctx.sql.tables.handleBinding.handle, req2.ownerHandle));
147522
+ conditions.push(eq193(vctx.sql.tables.handleBinding.handle, req2.ownerHandle));
147392
147523
  }
147393
147524
  if (req2.appSlug) {
147394
- conditions.push(eq192(vctx.sql.tables.appSlugBinding.appSlug, req2.appSlug));
147525
+ conditions.push(eq193(vctx.sql.tables.appSlugBinding.appSlug, req2.appSlug));
147395
147526
  }
147396
147527
  const rows = await vctx.sql.db.select({
147397
147528
  ownerHandle: vctx.sql.tables.handleBinding.handle,
@@ -147401,7 +147532,7 @@ var init_list_user_slug_app_slug = __esm({
147401
147532
  userCreated: vctx.sql.tables.handleBinding.created
147402
147533
  }).from(vctx.sql.tables.handleBinding).leftJoin(
147403
147534
  vctx.sql.tables.appSlugBinding,
147404
- eq192(vctx.sql.tables.appSlugBinding.ownerHandle, vctx.sql.tables.handleBinding.handle)
147535
+ eq193(vctx.sql.tables.appSlugBinding.ownerHandle, vctx.sql.tables.handleBinding.handle)
147405
147536
  ).where(and164(...conditions)).orderBy(desc39(vctx.sql.tables.handleBinding.created), desc39(vctx.sql.tables.appSlugBinding.created));
147406
147537
  const grouped = /* @__PURE__ */ new Map();
147407
147538
  for (const row of rows) {
@@ -147438,7 +147569,7 @@ import {
147438
147569
  } from "@adviser/cement";
147439
147570
  import { type as type202 } from "arktype";
147440
147571
  import { base58btc as base58btc14 } from "multiformats/bases/base58";
147441
- import { eq as eq193, and as and165, lt as lt14, or as or21, desc as desc40, inArray as inArray50 } from "drizzle-orm/sql/expressions";
147572
+ import { eq as eq194, and as and165, lt as lt14, or as or21, desc as desc40, inArray as inArray51 } from "drizzle-orm/sql/expressions";
147442
147573
  function encodeCursor3(c) {
147443
147574
  return base58btc14.encode(jsonEnde2.uint8ify(c));
147444
147575
  }
@@ -147519,9 +147650,9 @@ var init_list_recent_vibes = __esm({
147519
147650
  const asb = vctx.sql.tables.appSlugBinding;
147520
147651
  const usb = vctx.sql.tables.handleBinding;
147521
147652
  const settings = vctx.sql.tables.appSettings;
147522
- const conditions = [eq193(usb.userId, userId)];
147653
+ const conditions = [eq194(usb.userId, userId)];
147523
147654
  if (req2.includeUnpublished === false) {
147524
- conditions.push(eq193(asb.unpublishedAt, ""));
147655
+ conditions.push(eq194(asb.unpublishedAt, ""));
147525
147656
  }
147526
147657
  if (req2.cursor) {
147527
147658
  const rDecoded = decodeCursor3(req2.cursor);
@@ -147535,12 +147666,12 @@ var init_list_recent_vibes = __esm({
147535
147666
  const c = rDecoded.Ok();
147536
147667
  const tuplePred = or21(
147537
147668
  lt14(asb.pinnedAt, c.pinnedAt),
147538
- and165(eq193(asb.pinnedAt, c.pinnedAt), lt14(asb.updated, c.updated)),
147539
- and165(eq193(asb.pinnedAt, c.pinnedAt), eq193(asb.updated, c.updated), lt14(asb.ownerHandle, c.ownerHandle)),
147669
+ and165(eq194(asb.pinnedAt, c.pinnedAt), lt14(asb.updated, c.updated)),
147670
+ and165(eq194(asb.pinnedAt, c.pinnedAt), eq194(asb.updated, c.updated), lt14(asb.ownerHandle, c.ownerHandle)),
147540
147671
  and165(
147541
- eq193(asb.pinnedAt, c.pinnedAt),
147542
- eq193(asb.updated, c.updated),
147543
- eq193(asb.ownerHandle, c.ownerHandle),
147672
+ eq194(asb.pinnedAt, c.pinnedAt),
147673
+ eq194(asb.updated, c.updated),
147674
+ eq194(asb.ownerHandle, c.ownerHandle),
147544
147675
  lt14(asb.appSlug, c.appSlug)
147545
147676
  )
147546
147677
  );
@@ -147554,9 +147685,9 @@ var init_list_recent_vibes = __esm({
147554
147685
  unpublishedAt: asb.unpublishedAt,
147555
147686
  settings: settings.settings,
147556
147687
  settingsItemizedAt: settings.settingsItemizedAt
147557
- }).from(usb).innerJoin(asb, eq193(asb.ownerHandle, usb.handle)).leftJoin(
147688
+ }).from(usb).innerJoin(asb, eq194(asb.ownerHandle, usb.handle)).leftJoin(
147558
147689
  settings,
147559
- and165(eq193(settings.userId, usb.userId), eq193(settings.ownerHandle, usb.handle), eq193(settings.appSlug, asb.appSlug))
147690
+ and165(eq194(settings.userId, usb.userId), eq194(settings.ownerHandle, usb.handle), eq194(settings.appSlug, asb.appSlug))
147560
147691
  ).where(and165(...conditions)).orderBy(desc40(asb.pinnedAt), desc40(asb.updated), desc40(asb.ownerHandle), desc40(asb.appSlug)).limit(limit + 1);
147561
147692
  const hasMore = rows.length > limit;
147562
147693
  const slice = hasMore ? rows.slice(0, limit) : rows;
@@ -147565,7 +147696,7 @@ var init_list_recent_vibes = __esm({
147565
147696
  if (slice.length > 0) {
147566
147697
  const pageHandles = [...new Set(slice.map((row) => row.ownerHandle))];
147567
147698
  const pageSlugs = [...new Set(slice.map((row) => row.appSlug))];
147568
- const prodRows = await vctx.sql.db.select({ ownerHandle: tApps.ownerHandle, appSlug: tApps.appSlug }).from(tApps).where(and165(eq193(tApps.mode, "production"), inArray50(tApps.ownerHandle, pageHandles), inArray50(tApps.appSlug, pageSlugs)));
147699
+ const prodRows = await vctx.sql.db.select({ ownerHandle: tApps.ownerHandle, appSlug: tApps.appSlug }).from(tApps).where(and165(eq194(tApps.mode, "production"), inArray51(tApps.ownerHandle, pageHandles), inArray51(tApps.appSlug, pageSlugs)));
147569
147700
  for (const row of prodRows) publishedKeys.add(`${row.ownerHandle}/${row.appSlug}`);
147570
147701
  }
147571
147702
  const composedSettings = await composeSettingsRows(
@@ -147683,7 +147814,7 @@ var init_list_vibe_activity = __esm({
147683
147814
  // ../vibes.diy/api/svc/public/pin-recent-vibe.ts
147684
147815
  import { Result as Result265, Option as Option57, EventoResult as EventoResult51 } from "@adviser/cement";
147685
147816
  import { type as type204 } from "arktype";
147686
- import { eq as eq194, and as and166 } from "drizzle-orm/sql/expressions";
147817
+ import { eq as eq195, and as and166 } from "drizzle-orm/sql/expressions";
147687
147818
  var pinRecentVibeEvento;
147688
147819
  var init_pin_recent_vibe = __esm({
147689
147820
  "../vibes.diy/api/svc/public/pin-recent-vibe.ts"() {
@@ -147707,7 +147838,7 @@ var init_pin_recent_vibe = __esm({
147707
147838
  const userId = req2._auth.verifiedAuth.claims.userId;
147708
147839
  const usb = vctx.sql.tables.handleBinding;
147709
147840
  const asb = vctx.sql.tables.appSlugBinding;
147710
- const appRow = await vctx.sql.db.select({ ownerHandle: asb.ownerHandle, appSlug: asb.appSlug }).from(asb).innerJoin(usb, and166(eq194(usb.handle, asb.ownerHandle), eq194(usb.userId, userId))).where(and166(eq194(asb.ownerHandle, req2.ownerHandle), eq194(asb.appSlug, req2.appSlug))).limit(1).then((r) => r[0]);
147841
+ const appRow = await vctx.sql.db.select({ ownerHandle: asb.ownerHandle, appSlug: asb.appSlug }).from(asb).innerJoin(usb, and166(eq195(usb.handle, asb.ownerHandle), eq195(usb.userId, userId))).where(and166(eq195(asb.ownerHandle, req2.ownerHandle), eq195(asb.appSlug, req2.appSlug))).limit(1).then((r) => r[0]);
147711
147842
  if (appRow === void 0) {
147712
147843
  await ctx.send.send(ctx, {
147713
147844
  type: "vibes.diy.res-error",
@@ -147719,7 +147850,7 @@ var init_pin_recent_vibe = __esm({
147719
147850
  return Result265.Ok(EventoResult51.Continue);
147720
147851
  }
147721
147852
  const pinnedAt = req2.pin ? (/* @__PURE__ */ new Date()).toISOString() : "";
147722
- await vctx.sql.db.update(asb).set({ pinnedAt }).where(and166(eq194(asb.ownerHandle, req2.ownerHandle), eq194(asb.appSlug, req2.appSlug)));
147853
+ await vctx.sql.db.update(asb).set({ pinnedAt }).where(and166(eq195(asb.ownerHandle, req2.ownerHandle), eq195(asb.appSlug, req2.appSlug)));
147723
147854
  await ctx.send.send(ctx, {
147724
147855
  type: "vibes.diy.res-pin-recent-vibe",
147725
147856
  ownerHandle: req2.ownerHandle,
@@ -147831,11 +147962,11 @@ var init_set_vibe_chips = __esm({
147831
147962
  });
147832
147963
 
147833
147964
  // ../vibes.diy/api/svc/intern/notify-tick-silent.ts
147834
- import { eq as eq195 } from "drizzle-orm/sql/expressions";
147965
+ import { eq as eq196 } from "drizzle-orm/sql/expressions";
147835
147966
  async function notifyTickSilent(qctx, input) {
147836
147967
  if (input.state !== "dead" && input.state !== "overdue") return;
147837
147968
  const hb = qctx.sql.tables.handleBinding;
147838
- const owner = await qctx.sql.db.select({ userId: hb.userId }).from(hb).where(eq195(hb.handle, input.ownerHandle)).limit(1).then((r) => r[0]);
147969
+ const owner = await qctx.sql.db.select({ userId: hb.userId }).from(hb).where(eq196(hb.handle, input.ownerHandle)).limit(1).then((r) => r[0]);
147839
147970
  if (owner === void 0) return;
147840
147971
  const app = `${input.ownerHandle}/${input.appSlug}`;
147841
147972
  const since = input.silenceMs > 0 ? ` It last tried about ${humanizeDuration(input.silenceMs)} ago.` : "";
@@ -148203,12 +148334,12 @@ var init_recapture_screenshot = __esm({
148203
148334
 
148204
148335
  // ../vibes.diy/api/svc/intern/app-clip-eligibility.ts
148205
148336
  import { exception2Result as exception2Result332, Result as Result269 } from "@adviser/cement";
148206
- import { and as and167, eq as eq196 } from "drizzle-orm/sql/expressions";
148337
+ import { and as and167, eq as eq197 } from "drizzle-orm/sql/expressions";
148207
148338
  async function appClipCardEligibility(ctx, target2) {
148208
148339
  const { ownerHandle, appSlug } = target2;
148209
148340
  const asb = ctx.sql.tables.appSlugBinding;
148210
148341
  const rBinding = await exception2Result332(
148211
- () => ctx.sql.db.select({ unpublishedAt: asb.unpublishedAt }).from(asb).where(and167(eq196(asb.ownerHandle, ownerHandle), eq196(asb.appSlug, appSlug))).limit(1).then((r) => r[0])
148342
+ () => ctx.sql.db.select({ unpublishedAt: asb.unpublishedAt }).from(asb).where(and167(eq197(asb.ownerHandle, ownerHandle), eq197(asb.appSlug, appSlug))).limit(1).then((r) => r[0])
148212
148343
  );
148213
148344
  if (rBinding.isErr()) return Result269.Err(rBinding);
148214
148345
  const binding = rBinding.Ok();
@@ -148230,7 +148361,7 @@ var init_app_clip_eligibility = __esm({
148230
148361
  // ../vibes.diy/api/svc/public/request-app-clip-card.ts
148231
148362
  import { Result as Result270, Option as Option61, EventoResult as EventoResult55, exception2Result as exception2Result333 } from "@adviser/cement";
148232
148363
  import { type as type208 } from "arktype";
148233
- import { and as and168, eq as eq197 } from "drizzle-orm/sql/expressions";
148364
+ import { and as and168, eq as eq198 } from "drizzle-orm/sql/expressions";
148234
148365
  function decodeStatus(raw) {
148235
148366
  const status = appClipCardStatus(raw);
148236
148367
  return status instanceof type208.errors ? null : status;
@@ -148284,11 +148415,11 @@ async function requestAppClipCard(vctx, req2) {
148284
148415
  );
148285
148416
  if (rPost.isErr()) {
148286
148417
  ensureLogger(vctx.sthis, "requestAppClipCard").Error().Err(rPost.Err()).Str("ownerHandle", req2.ownerHandle).Str("appSlug", req2.appSlug).Msg("enqueue failed; removing the requested row so the next request retries");
148287
- await vctx.sql.db.delete(t).where(and168(eq197(t.ownerHandle, req2.ownerHandle), eq197(t.appSlug, req2.appSlug)));
148418
+ await vctx.sql.db.delete(t).where(and168(eq198(t.ownerHandle, req2.ownerHandle), eq198(t.appSlug, req2.appSlug)));
148288
148419
  return noCard();
148289
148420
  }
148290
148421
  }
148291
- const row = await vctx.sql.db.select({ status: t.status }).from(t).where(and168(eq197(t.ownerHandle, req2.ownerHandle), eq197(t.appSlug, req2.appSlug))).limit(1).then((r) => r[0]);
148422
+ const row = await vctx.sql.db.select({ status: t.status }).from(t).where(and168(eq198(t.ownerHandle, req2.ownerHandle), eq198(t.appSlug, req2.appSlug))).limit(1).then((r) => r[0]);
148292
148423
  return { type: "vibes.diy.res-request-app-clip-card", status: row === void 0 ? null : decodeStatus(row.status) };
148293
148424
  }
148294
148425
  var requestAppClipCardEvento;
@@ -148430,7 +148561,7 @@ var init_vibe_tools_wire = __esm({
148430
148561
  // ../vibes.diy/api/svc/public/app-owner-stats.ts
148431
148562
  import { Result as Result272, Option as Option63, EventoResult as EventoResult57, exception2Result as exception2Result334 } from "@adviser/cement";
148432
148563
  import { type as type210 } from "arktype";
148433
- import { and as and169, desc as desc41, eq as eq198, gte as gte7, inArray as inArray51, like as like7, sql as sql31 } from "drizzle-orm";
148564
+ import { and as and169, desc as desc41, eq as eq199, gte as gte7, inArray as inArray52, like as like7, sql as sql31 } from "drizzle-orm";
148434
148565
  async function authorized3(vctx, args) {
148435
148566
  const auth = await authorizeSlugOwner(vctx, args);
148436
148567
  if (auth === void 0) return false;
@@ -148455,10 +148586,10 @@ async function readAppOwnerStats(vctx, args) {
148455
148586
  const sinceIso = new Date(sinceMs).toISOString();
148456
148587
  const n2 = vctx.sql.tables.notifications;
148457
148588
  const fromThisVibe = and169(
148458
- eq198(n2.ownerHandle, args.ownerHandle),
148459
- eq198(n2.appSlug, args.appSlug),
148589
+ eq199(n2.ownerHandle, args.ownerHandle),
148590
+ eq199(n2.appSlug, args.appSlug),
148460
148591
  gte7(n2.created, sinceIso),
148461
- eq198(n2.notificationType, "app-message"),
148592
+ eq199(n2.notificationType, "app-message"),
148462
148593
  like7(n2.dedupeKey, "app-message:%")
148463
148594
  );
148464
148595
  const recipientCount = sql31`count(*)`;
@@ -148472,19 +148603,19 @@ async function readAppOwnerStats(vctx, args) {
148472
148603
  const distinct = Number(totals?.people ?? 0);
148473
148604
  const l = vctx.sql.tables.vibeLogEvents;
148474
148605
  const fromThisBackend = and169(
148475
- eq198(l.ownerHandle, args.ownerHandle),
148476
- eq198(l.appSlug, args.appSlug),
148606
+ eq199(l.ownerHandle, args.ownerHandle),
148607
+ eq199(l.appSlug, args.appSlug),
148477
148608
  gte7(l.id, logEventIdFloor(sinceMs)),
148478
- eq198(l.lane, "backend")
148609
+ eq199(l.lane, "backend")
148479
148610
  );
148480
148611
  const byTrigger = await vctx.sql.db.select({
148481
148612
  trigger: l.trigger,
148482
148613
  lines: sql31`count(*)`,
148483
148614
  errors: sql31`sum(case when ${l.level} = 'error' then 1 else 0 end)`
148484
148615
  }).from(l).where(fromThisBackend).groupBy(l.trigger).orderBy(desc41(sql31`count(*)`));
148485
- const lastError2 = await vctx.sql.db.select({ ts: l.ts, trigger: l.trigger }).from(l).where(and169(fromThisBackend, eq198(l.level, "error"))).orderBy(desc41(l.id)).limit(1).then((r) => r[0]);
148616
+ const lastError2 = await vctx.sql.db.select({ ts: l.ts, trigger: l.trigger }).from(l).where(and169(fromThisBackend, eq199(l.level, "error"))).orderBy(desc41(l.id)).limit(1).then((r) => r[0]);
148486
148617
  const errorCount = byTrigger.reduce((sum, r) => sum + Number(r.errors ?? 0), 0);
148487
- const errors = errorCount > 0 ? await readErrorGroups(vctx, { ...args, where: and169(fromThisBackend, eq198(l.level, "error")) }) : void 0;
148618
+ const errors = errorCount > 0 ? await readErrorGroups(vctx, { ...args, where: and169(fromThisBackend, eq199(l.level, "error")) }) : void 0;
148488
148619
  return {
148489
148620
  ownerHandle: args.ownerHandle,
148490
148621
  appSlug: args.appSlug,
@@ -148513,7 +148644,7 @@ async function readErrorGroups(vctx, args) {
148513
148644
  const lastAt = sql31`max(${l.ts})`;
148514
148645
  const rows = await vctx.sql.db.select({ message: prefix, count: count6, firstAt: sql31`min(${l.ts})`, lastAt, newestId: sql31`max(${l.id})` }).from(l).where(args.where).groupBy(prefix).orderBy(desc41(count6), desc41(lastAt)).limit(APP_OWNER_ERROR_GROUPS);
148515
148646
  const newestIds = rows.map((r) => r.newestId);
148516
- const fsIdRows = newestIds.length === 0 ? [] : await vctx.sql.db.select({ id: l.id, fsId: l.fsId }).from(l).where(and169(eq198(l.ownerHandle, args.ownerHandle), eq198(l.appSlug, args.appSlug), inArray51(l.id, newestIds)));
148647
+ const fsIdRows = newestIds.length === 0 ? [] : await vctx.sql.db.select({ id: l.id, fsId: l.fsId }).from(l).where(and169(eq199(l.ownerHandle, args.ownerHandle), eq199(l.appSlug, args.appSlug), inArray52(l.id, newestIds)));
148517
148648
  const fsIdById = new Map(fsIdRows.map((r) => [r.id, r.fsId]));
148518
148649
  const rVersions = await exception2Result334(() => loadVersionItems(vctx, args));
148519
148650
  if (rVersions.isErr()) {
@@ -148770,7 +148901,7 @@ var init_mark_build_seen = __esm({
148770
148901
  // ../vibes.diy/api/svc/public/get-chat-details.ts
148771
148902
  import { Result as Result276, Option as Option67, EventoResult as EventoResult61 } from "@adviser/cement";
148772
148903
  import { type as type214 } from "arktype";
148773
- import { eq as eq199, and as and170, desc as desc42, ne as ne26 } from "drizzle-orm/sql/expressions";
148904
+ import { eq as eq200, and as and170, desc as desc42, ne as ne25 } from "drizzle-orm/sql/expressions";
148774
148905
  var getChatDetailsEvento;
148775
148906
  var init_get_chat_details = __esm({
148776
148907
  "../vibes.diy/api/svc/public/get-chat-details.ts"() {
@@ -148812,7 +148943,7 @@ var init_get_chat_details = __esm({
148812
148943
  });
148813
148944
  return Result276.Ok(EventoResult61.Continue);
148814
148945
  }
148815
- const ownerRow = await vctx.sql.db.select({ userId: vctx.sql.tables.handleBinding.userId }).from(vctx.sql.tables.handleBinding).where(and170(eq199(vctx.sql.tables.handleBinding.handle, req2.ownerHandle), eq199(vctx.sql.tables.handleBinding.userId, userId))).limit(1).then((r) => r[0]);
148946
+ const ownerRow = await vctx.sql.db.select({ userId: vctx.sql.tables.handleBinding.userId }).from(vctx.sql.tables.handleBinding).where(and170(eq200(vctx.sql.tables.handleBinding.handle, req2.ownerHandle), eq200(vctx.sql.tables.handleBinding.userId, userId))).limit(1).then((r) => r[0]);
148816
148947
  const isOwner = ownerRow !== void 0;
148817
148948
  const isDeveloper = isOwner === false && await resolveDeveloperAccess(vctx, {
148818
148949
  ownerHandle: req2.ownerHandle,
@@ -148827,20 +148958,20 @@ var init_get_chat_details = __esm({
148827
148958
  blocks: vctx.sql.tables.chatSections.blocks
148828
148959
  }).from(vctx.sql.tables.chatContexts).innerJoin(
148829
148960
  vctx.sql.tables.promptContexts,
148830
- eq199(vctx.sql.tables.promptContexts.chatId, vctx.sql.tables.chatContexts.chatId)
148961
+ eq200(vctx.sql.tables.promptContexts.chatId, vctx.sql.tables.chatContexts.chatId)
148831
148962
  ).innerJoin(
148832
148963
  vctx.sql.tables.chatSections,
148833
148964
  and170(
148834
- eq199(vctx.sql.tables.chatSections.chatId, vctx.sql.tables.promptContexts.chatId),
148835
- eq199(vctx.sql.tables.chatSections.promptId, vctx.sql.tables.promptContexts.promptId)
148965
+ eq200(vctx.sql.tables.chatSections.chatId, vctx.sql.tables.promptContexts.chatId),
148966
+ eq200(vctx.sql.tables.chatSections.promptId, vctx.sql.tables.promptContexts.promptId)
148836
148967
  )
148837
148968
  ).where(
148838
148969
  and170(
148839
- eq199(vctx.sql.tables.chatContexts.ownerHandle, req2.ownerHandle),
148840
- eq199(vctx.sql.tables.chatContexts.appSlug, req2.appSlug),
148841
- ne26(vctx.sql.tables.chatSections.blockSeq, RESEARCH_BLOCK_SEQ),
148842
- ...req2.chatId !== void 0 ? [eq199(vctx.sql.tables.chatContexts.chatId, req2.chatId)] : [],
148843
- ...isDeveloper ? [eq199(vctx.sql.tables.chatContexts.userId, userId)] : []
148970
+ eq200(vctx.sql.tables.chatContexts.ownerHandle, req2.ownerHandle),
148971
+ eq200(vctx.sql.tables.chatContexts.appSlug, req2.appSlug),
148972
+ ne25(vctx.sql.tables.chatSections.blockSeq, RESEARCH_BLOCK_SEQ),
148973
+ ...req2.chatId !== void 0 ? [eq200(vctx.sql.tables.chatContexts.chatId, req2.chatId)] : [],
148974
+ ...isDeveloper ? [eq200(vctx.sql.tables.chatContexts.userId, userId)] : []
148844
148975
  )
148845
148976
  ).orderBy(desc42(vctx.sql.tables.promptContexts.created));
148846
148977
  if (rows.length === 0) {
@@ -149010,7 +149141,7 @@ var init_prompt_usage = __esm({
149010
149141
  // ../vibes.diy/api/svc/public/get-chat-response.ts
149011
149142
  import { Result as Result277, Option as Option68, EventoResult as EventoResult62 } from "@adviser/cement";
149012
149143
  import { type as type216 } from "arktype";
149013
- import { eq as eq200, and as and171, ne as ne27 } from "drizzle-orm/sql/expressions";
149144
+ import { eq as eq201, and as and171, ne as ne26 } from "drizzle-orm/sql/expressions";
149014
149145
  var getChatResponseEvento;
149015
149146
  var init_get_chat_response = __esm({
149016
149147
  "../vibes.diy/api/svc/public/get-chat-response.ts"() {
@@ -149055,7 +149186,7 @@ var init_get_chat_response = __esm({
149055
149186
  }
149056
149187
  const t = vctx.sql.tables.chatContexts;
149057
149188
  const [chat] = await vctx.sql.db.select({ chatId: t.chatId }).from(t).where(
149058
- and171(eq200(t.chatId, req2.chatId), eq200(t.userId, userId), eq200(t.ownerHandle, req2.ownerHandle), eq200(t.appSlug, req2.appSlug))
149189
+ and171(eq201(t.chatId, req2.chatId), eq201(t.userId, userId), eq201(t.ownerHandle, req2.ownerHandle), eq201(t.appSlug, req2.appSlug))
149059
149190
  ).limit(1);
149060
149191
  if (chat === void 0) {
149061
149192
  await ctx.send.send(ctx, {
@@ -149114,16 +149245,16 @@ var init_get_chat_response = __esm({
149114
149245
  ref: t.promptContexts.ref,
149115
149246
  fsId: t.promptContexts.fsId,
149116
149247
  journalCreated: t.openTurns.created
149117
- }).from(t.chatContexts).leftJoin(t.handleBinding, eq200(t.chatContexts.ownerHandle, t.handleBinding.handle)).innerJoin(t.promptContexts, eq200(t.promptContexts.chatId, t.chatContexts.chatId)).leftJoin(
149248
+ }).from(t.chatContexts).leftJoin(t.handleBinding, eq201(t.chatContexts.ownerHandle, t.handleBinding.handle)).innerJoin(t.promptContexts, eq201(t.promptContexts.chatId, t.chatContexts.chatId)).leftJoin(
149118
149249
  t.openTurns,
149119
- and171(eq200(t.openTurns.chatId, t.chatContexts.chatId), eq200(t.openTurns.promptId, AGENT_SESSION_RECORD_ID))
149250
+ and171(eq201(t.openTurns.chatId, t.chatContexts.chatId), eq201(t.openTurns.promptId, AGENT_SESSION_RECORD_ID))
149120
149251
  ).where(
149121
149252
  and171(
149122
- eq200(t.handleBinding.userId, userId),
149123
- eq200(t.chatContexts.ownerHandle, req2.ownerHandle),
149124
- eq200(t.chatContexts.appSlug, req2.appSlug),
149125
- eq200(t.chatContexts.chatId, req2.chatId),
149126
- ...req2.promptId !== void 0 ? [eq200(t.promptContexts.promptId, req2.promptId)] : []
149253
+ eq201(t.handleBinding.userId, userId),
149254
+ eq201(t.chatContexts.ownerHandle, req2.ownerHandle),
149255
+ eq201(t.chatContexts.appSlug, req2.appSlug),
149256
+ eq201(t.chatContexts.chatId, req2.chatId),
149257
+ ...req2.promptId !== void 0 ? [eq201(t.promptContexts.promptId, req2.promptId)] : []
149127
149258
  )
149128
149259
  );
149129
149260
  await ctx.send.send(ctx, {
@@ -149154,20 +149285,20 @@ var init_get_chat_response = __esm({
149154
149285
  sectionCreated: vctx.sql.tables.chatSections.created,
149155
149286
  blockSeq: vctx.sql.tables.chatSections.blockSeq,
149156
149287
  blocks: vctx.sql.tables.chatSections.blocks
149157
- }).from(vctx.sql.tables.chatContexts).leftJoin(vctx.sql.tables.handleBinding, eq200(vctx.sql.tables.chatContexts.ownerHandle, vctx.sql.tables.handleBinding.handle)).innerJoin(vctx.sql.tables.chatSections, eq200(vctx.sql.tables.chatSections.chatId, vctx.sql.tables.chatContexts.chatId)).leftJoin(
149288
+ }).from(vctx.sql.tables.chatContexts).leftJoin(vctx.sql.tables.handleBinding, eq201(vctx.sql.tables.chatContexts.ownerHandle, vctx.sql.tables.handleBinding.handle)).innerJoin(vctx.sql.tables.chatSections, eq201(vctx.sql.tables.chatSections.chatId, vctx.sql.tables.chatContexts.chatId)).leftJoin(
149158
149289
  vctx.sql.tables.promptContexts,
149159
149290
  and171(
149160
- eq200(vctx.sql.tables.promptContexts.chatId, vctx.sql.tables.chatSections.chatId),
149161
- eq200(vctx.sql.tables.promptContexts.promptId, vctx.sql.tables.chatSections.promptId)
149291
+ eq201(vctx.sql.tables.promptContexts.chatId, vctx.sql.tables.chatSections.chatId),
149292
+ eq201(vctx.sql.tables.promptContexts.promptId, vctx.sql.tables.chatSections.promptId)
149162
149293
  )
149163
149294
  ).where(
149164
149295
  and171(
149165
- eq200(vctx.sql.tables.handleBinding.userId, userId),
149166
- eq200(vctx.sql.tables.chatContexts.ownerHandle, req2.ownerHandle),
149167
- eq200(vctx.sql.tables.chatContexts.appSlug, req2.appSlug),
149168
- ne27(vctx.sql.tables.chatSections.blockSeq, RESEARCH_BLOCK_SEQ),
149169
- ...req2.chatId !== void 0 ? [eq200(vctx.sql.tables.chatContexts.chatId, req2.chatId)] : [],
149170
- ...req2.promptId !== void 0 ? [eq200(vctx.sql.tables.chatSections.promptId, req2.promptId)] : []
149296
+ eq201(vctx.sql.tables.handleBinding.userId, userId),
149297
+ eq201(vctx.sql.tables.chatContexts.ownerHandle, req2.ownerHandle),
149298
+ eq201(vctx.sql.tables.chatContexts.appSlug, req2.appSlug),
149299
+ ne26(vctx.sql.tables.chatSections.blockSeq, RESEARCH_BLOCK_SEQ),
149300
+ ...req2.chatId !== void 0 ? [eq201(vctx.sql.tables.chatContexts.chatId, req2.chatId)] : [],
149301
+ ...req2.promptId !== void 0 ? [eq201(vctx.sql.tables.chatSections.promptId, req2.promptId)] : []
149171
149302
  )
149172
149303
  );
149173
149304
  const turns2 = /* @__PURE__ */ new Map();
@@ -149699,7 +149830,7 @@ var init_nature_rewrite_suggestion3 = __esm({
149699
149830
  // ../vibes.diy/api/svc/public/seed-starter-chips-handler.ts
149700
149831
  import { Result as Result282, Option as Option72, EventoResult as EventoResult66 } from "@adviser/cement";
149701
149832
  import { type as type221 } from "arktype";
149702
- import { eq as eq201 } from "drizzle-orm/sql/expressions";
149833
+ import { eq as eq202 } from "drizzle-orm/sql/expressions";
149703
149834
  var seedStarterChipsEvento;
149704
149835
  var init_seed_starter_chips_handler = __esm({
149705
149836
  "../vibes.diy/api/svc/public/seed-starter-chips-handler.ts"() {
@@ -149727,7 +149858,7 @@ var init_seed_starter_chips_handler = __esm({
149727
149858
  await ctx.send.send(ctx, mkResError("seedStarterChips: authentication required", "unauthorized"));
149728
149859
  return Result282.Ok(EventoResult66.Continue);
149729
149860
  }
149730
- const ownerRow = await vctx.sql.db.select({ userId: vctx.sql.tables.handleBinding.userId }).from(vctx.sql.tables.handleBinding).where(eq201(vctx.sql.tables.handleBinding.handle, req2.ownerHandle)).limit(1).then((r2) => r2[0]);
149861
+ const ownerRow = await vctx.sql.db.select({ userId: vctx.sql.tables.handleBinding.userId }).from(vctx.sql.tables.handleBinding).where(eq202(vctx.sql.tables.handleBinding.handle, req2.ownerHandle)).limit(1).then((r2) => r2[0]);
149731
149862
  if (!ownerRow || ownerRow.userId !== callerUserId) {
149732
149863
  await ctx.send.send(ctx, mkResError(`seedStarterChips: not the owner of ${req2.ownerHandle}`, "forbidden"));
149733
149864
  return Result282.Ok(EventoResult66.Continue);
@@ -149768,7 +149899,7 @@ var init_seed_starter_chips_handler = __esm({
149768
149899
 
149769
149900
  // ../vibes.diy/api/svc/public/ensure-user-settings.ts
149770
149901
  import { Result as Result283, Option as Option73, EventoResult as EventoResult67 } from "@adviser/cement";
149771
- import { and as and172, eq as eq202 } from "drizzle-orm/sql/expressions";
149902
+ import { and as and172, eq as eq203 } from "drizzle-orm/sql/expressions";
149772
149903
  import { type as type222 } from "arktype";
149773
149904
  function isWireVisible(t) {
149774
149905
  return !SERVER_ONLY_SETTINGS.has(t);
@@ -149780,7 +149911,7 @@ function warnGeoCountryMissingOnce(vctx) {
149780
149911
  }
149781
149912
  async function ensureUserSettings(vctx, req2, attempt = 0) {
149782
149913
  const userId = req2._auth.verifiedAuth.claims.userId;
149783
- const existing = await vctx.sql.db.select().from(vctx.sql.tables.userSettings).where(eq202(vctx.sql.tables.userSettings.userId, userId)).limit(1).then((r) => r[0]);
149914
+ const existing = await vctx.sql.db.select().from(vctx.sql.tables.userSettings).where(eq203(vctx.sql.tables.userSettings.userId, userId)).limit(1).then((r) => r[0]);
149784
149915
  const now3 = (/* @__PURE__ */ new Date()).toISOString();
149785
149916
  if (!existing) {
149786
149917
  await vctx.sql.db.insert(vctx.sql.tables.userSettings).values({ userId, settings: [], updated: now3, created: now3 }).onConflictDoNothing({ target: vctx.sql.tables.userSettings.userId });
@@ -149819,7 +149950,7 @@ async function ensureUserSettings(vctx, req2, attempt = 0) {
149819
149950
  ensureLogger(vctx.sthis, "ensureUserSettings").Warn().Any({ parseErrors: settingsWarning }).Msg("skip");
149820
149951
  }
149821
149952
  const tSettings = vctx.sql.tables.userSettings;
149822
- const written = await vctx.sql.db.update(tSettings).set({ settings, updated: now3 }).where(and172(eq202(tSettings.userId, userId), eq202(tSettings.settings, existing.settings))).returning({ userId: tSettings.userId });
149953
+ const written = await vctx.sql.db.update(tSettings).set({ settings, updated: now3 }).where(and172(eq203(tSettings.userId, userId), eq203(tSettings.settings, existing.settings))).returning({ userId: tSettings.userId });
149823
149954
  if (written.length === 0) {
149824
149955
  if (attempt + 1 < SETTINGS_WRITE_ATTEMPTS) return ensureUserSettings(vctx, req2, attempt + 1);
149825
149956
  return Result283.Err(new Error(`user settings write kept conflicting for ${userId} \u2014 not writing a stale snapshot`));
@@ -149903,17 +150034,17 @@ var init_ensure_user_settings = __esm({
149903
150034
 
149904
150035
  // ../vibes.diy/api/svc/public/set-egress-status.ts
149905
150036
  import { Result as Result284, Option as Option74, EventoResult as EventoResult68 } from "@adviser/cement";
149906
- import { eq as eq203 } from "drizzle-orm/sql/expressions";
150037
+ import { eq as eq204 } from "drizzle-orm/sql/expressions";
149907
150038
  import { type as type223 } from "arktype";
149908
150039
  async function setEgressStatus(vctx, req2) {
149909
150040
  const callerUserId = req2._auth.verifiedAuth.claims.userId;
149910
150041
  if (!adminUserIdSet(vctx).has(callerUserId)) {
149911
150042
  return Result284.Err("egress-status: admin only");
149912
150043
  }
149913
- const binding = await vctx.sql.db.select({ userId: vctx.sql.tables.handleBinding.userId }).from(vctx.sql.tables.handleBinding).where(eq203(vctx.sql.tables.handleBinding.handle, req2.ownerHandle)).limit(1).then((r) => r[0]);
150044
+ const binding = await vctx.sql.db.select({ userId: vctx.sql.tables.handleBinding.userId }).from(vctx.sql.tables.handleBinding).where(eq204(vctx.sql.tables.handleBinding.handle, req2.ownerHandle)).limit(1).then((r) => r[0]);
149914
150045
  if (!binding) return Result284.Err(`egress-status: unknown ownerHandle ${req2.ownerHandle}`);
149915
150046
  const now3 = (/* @__PURE__ */ new Date()).toISOString();
149916
- const existing = await vctx.sql.db.select().from(vctx.sql.tables.userSettings).where(eq203(vctx.sql.tables.userSettings.userId, binding.userId)).limit(1).then((r) => r[0]);
150047
+ const existing = await vctx.sql.db.select().from(vctx.sql.tables.userSettings).where(eq204(vctx.sql.tables.userSettings.userId, binding.userId)).limit(1).then((r) => r[0]);
149917
150048
  if (!existing) {
149918
150049
  await vctx.sql.db.insert(vctx.sql.tables.userSettings).values({ userId: binding.userId, settings: [], updated: now3, created: now3 });
149919
150050
  }
@@ -149922,7 +150053,7 @@ async function setEgressStatus(vctx, req2) {
149922
150053
  if (req2.status !== "default") {
149923
150054
  kept.push({ type: "egressStatus", status: req2.status, updatedAt: now3, setBy: callerUserId });
149924
150055
  }
149925
- await vctx.sql.db.update(vctx.sql.tables.userSettings).set({ settings: kept, updated: now3 }).where(eq203(vctx.sql.tables.userSettings.userId, binding.userId));
150056
+ await vctx.sql.db.update(vctx.sql.tables.userSettings).set({ settings: kept, updated: now3 }).where(eq204(vctx.sql.tables.userSettings.userId, binding.userId));
149926
150057
  return Result284.Ok({ type: "vibes.diy.res-set-egress-status", ownerHandle: req2.ownerHandle, status: req2.status, updated: now3 });
149927
150058
  }
149928
150059
  var setEgressStatusEvento;
@@ -149957,7 +150088,7 @@ var init_set_egress_status = __esm({
149957
150088
  // ../vibes.diy/api/svc/public/report-vibe.ts
149958
150089
  import { Result as Result285, Option as Option75, EventoResult as EventoResult69 } from "@adviser/cement";
149959
150090
  import { type as type224 } from "arktype";
149960
- import { and as and173, count as count4, eq as eq204, gt as gt18, lt as lt15, or as or22 } from "drizzle-orm";
150091
+ import { and as and173, count as count4, eq as eq205, gt as gt18, lt as lt15, or as or22 } from "drizzle-orm";
149961
150092
  function rateLimitAddress(ip) {
149962
150093
  if (ip.includes(":") === false || ip.includes(".")) return ip;
149963
150094
  const [head = "", tail = ""] = ip.split("::");
@@ -149981,13 +150112,13 @@ async function reporterKeyFor(args) {
149981
150112
  async function reportVibe(vctx, req2) {
149982
150113
  const now3 = req2.now ?? /* @__PURE__ */ new Date();
149983
150114
  const asb = vctx.sql.tables.appSlugBinding;
149984
- const app = await vctx.sql.db.select({ appSlug: asb.appSlug }).from(asb).where(and173(eq204(asb.ownerHandle, req2.ownerHandle), eq204(asb.appSlug, req2.appSlug))).limit(1).then((r) => r[0]);
150115
+ const app = await vctx.sql.db.select({ appSlug: asb.appSlug }).from(asb).where(and173(eq205(asb.ownerHandle, req2.ownerHandle), eq205(asb.appSlug, req2.appSlug))).limit(1).then((r) => r[0]);
149985
150116
  if (app === void 0) return { kind: "app-not-found" };
149986
150117
  const t = vctx.sql.tables.vibeReports;
149987
150118
  const reporterKey = await reporterKeyFor({ userId: req2.reporterUserId, clientIp: req2.clientIp });
149988
150119
  const since = new Date(now3.getTime() - REPORT_WINDOW_MS).toISOString();
149989
150120
  const cap = reporterKey === "anon" ? REPORT_CAP_PER_WINDOW * 10 : REPORT_CAP_PER_WINDOW;
149990
- const countRecent = /* @__PURE__ */ __name(() => vctx.sql.db.select({ n: count4() }).from(t).where(and173(eq204(t.reporterKey, reporterKey), gt18(t.created, since))).then((r) => r[0]?.n ?? 0), "countRecent");
150121
+ const countRecent = /* @__PURE__ */ __name(() => vctx.sql.db.select({ n: count4() }).from(t).where(and173(eq205(t.reporterKey, reporterKey), gt18(t.created, since))).then((r) => r[0]?.n ?? 0), "countRecent");
149991
150122
  if (await countRecent() >= cap) return { kind: "rate-limited" };
149992
150123
  const reportId = crypto.randomUUID();
149993
150124
  const created = now3.toISOString();
@@ -150004,13 +150135,13 @@ async function reportVibe(vctx, req2) {
150004
150135
  });
150005
150136
  const ahead = await vctx.sql.db.select({ n: count4() }).from(t).where(
150006
150137
  and173(
150007
- eq204(t.reporterKey, reporterKey),
150138
+ eq205(t.reporterKey, reporterKey),
150008
150139
  gt18(t.created, since),
150009
- or22(lt15(t.created, created), and173(eq204(t.created, created), lt15(t.reportId, reportId)))
150140
+ or22(lt15(t.created, created), and173(eq205(t.created, created), lt15(t.reportId, reportId)))
150010
150141
  )
150011
150142
  ).then((r) => r[0]?.n ?? 0);
150012
150143
  if (ahead >= cap) {
150013
- await vctx.sql.db.delete(t).where(eq204(t.reportId, reportId));
150144
+ await vctx.sql.db.delete(t).where(eq205(t.reportId, reportId));
150014
150145
  return { kind: "rate-limited" };
150015
150146
  }
150016
150147
  postQueueFact({
@@ -150078,14 +150209,14 @@ var init_report_vibe = __esm({
150078
150209
  });
150079
150210
 
150080
150211
  // ../vibes.diy/api/svc/intern/auto-flag-address.ts
150081
- import { inArray as inArray52 } from "drizzle-orm/sql/expressions";
150212
+ import { inArray as inArray53 } from "drizzle-orm/sql/expressions";
150082
150213
  async function withCurrentFlagAddress(sql43, rows) {
150083
150214
  const chatIds = [
150084
150215
  ...new Set(rows.flatMap((r) => r.inputKind === "prompt" && r.chatId !== void 0 && r.chatId !== null ? [r.chatId] : []))
150085
150216
  ];
150086
150217
  if (chatIds.length === 0) return [...rows];
150087
150218
  const cc = sql43.tables.chatContexts;
150088
- const chats = await sql43.db.select({ chatId: cc.chatId, ownerHandle: cc.ownerHandle, appSlug: cc.appSlug }).from(cc).where(inArray52(cc.chatId, chatIds));
150219
+ const chats = await sql43.db.select({ chatId: cc.chatId, ownerHandle: cc.ownerHandle, appSlug: cc.appSlug }).from(cc).where(inArray53(cc.chatId, chatIds));
150089
150220
  const byChat = new Map(chats.map((c) => [c.chatId, c]));
150090
150221
  return rows.map((r) => {
150091
150222
  const chat = r.inputKind === "prompt" && r.chatId !== void 0 && r.chatId !== null ? byChat.get(r.chatId) : void 0;
@@ -150102,7 +150233,7 @@ var init_auto_flag_address = __esm({
150102
150233
  // ../vibes.diy/api/svc/public/moderation-admin.ts
150103
150234
  import { Result as Result286, Option as Option76, EventoResult as EventoResult70 } from "@adviser/cement";
150104
150235
  import { type as type225 } from "arktype";
150105
- import { and as and174, count as count5, desc as desc43, eq as eq205, gte as gte8, inArray as inArray53, notInArray as notInArray9 } from "drizzle-orm";
150236
+ import { and as and174, count as count5, desc as desc43, eq as eq206, gte as gte8, inArray as inArray54, notInArray as notInArray9 } from "drizzle-orm";
150106
150237
  function toReportRow(r) {
150107
150238
  return {
150108
150239
  reportId: r.reportId,
@@ -150142,7 +150273,7 @@ function toFlagRow(r, promptText) {
150142
150273
  }
150143
150274
  async function readFlaggedPrompt(vctx, chatId, promptId) {
150144
150275
  const cs = vctx.sql.tables.chatSections;
150145
- const rows = await vctx.sql.db.select({ blocks: cs.blocks }).from(cs).where(and174(eq205(cs.chatId, chatId), eq205(cs.promptId, promptId))).limit(20);
150276
+ const rows = await vctx.sql.db.select({ blocks: cs.blocks }).from(cs).where(and174(eq206(cs.chatId, chatId), eq206(cs.promptId, promptId))).limit(20);
150146
150277
  for (const row of rows) {
150147
150278
  for (const msg of readChatSectionBlocks(row.blocks)) {
150148
150279
  if (isPromptReq(msg)) {
@@ -150157,7 +150288,7 @@ async function resolveTargetUserId(vctx, req2) {
150157
150288
  if (req2.userId !== void 0 && req2.userId !== "") return Result286.Ok(req2.userId);
150158
150289
  if (req2.handle !== void 0 && req2.handle !== "") {
150159
150290
  const hb = vctx.sql.tables.handleBinding;
150160
- const row = await vctx.sql.db.select({ userId: hb.userId }).from(hb).where(eq205(hb.handle, req2.handle)).limit(1).then((r) => r[0]);
150291
+ const row = await vctx.sql.db.select({ userId: hb.userId }).from(hb).where(eq206(hb.handle, req2.handle)).limit(1).then((r) => r[0]);
150161
150292
  if (row === void 0) return Result286.Err(`moderation: no account holds the handle ${req2.handle}`);
150162
150293
  return Result286.Ok(row.userId);
150163
150294
  }
@@ -150166,14 +150297,14 @@ async function resolveTargetUserId(vctx, req2) {
150166
150297
  async function purgeAccountApps(vctx, userId) {
150167
150298
  const hb = vctx.sql.tables.handleBinding;
150168
150299
  const asb = vctx.sql.tables.appSlugBinding;
150169
- const handles = await vctx.sql.db.select({ handle: hb.handle }).from(hb).where(eq205(hb.userId, userId)).then((r) => r.map((x) => x.handle));
150300
+ const handles = await vctx.sql.db.select({ handle: hb.handle }).from(hb).where(eq206(hb.userId, userId)).then((r) => r.map((x) => x.handle));
150170
150301
  if (handles.length === 0) return;
150171
- const apps = await vctx.sql.db.select({ ownerHandle: asb.ownerHandle, appSlug: asb.appSlug }).from(asb).where(inArray53(asb.ownerHandle, handles));
150302
+ const apps = await vctx.sql.db.select({ ownerHandle: asb.ownerHandle, appSlug: asb.appSlug }).from(asb).where(inArray54(asb.ownerHandle, handles));
150172
150303
  for (const a of apps) purgeRootHtmlCacheSameColo(vctx, a.ownerHandle, a.appSlug);
150173
150304
  }
150174
150305
  async function readPublishing(vctx) {
150175
150306
  const t = vctx.sql.tables.platformSwitches;
150176
- const row = await vctx.sql.db.select().from(t).where(eq205(t.name, PUBLISHING_PAUSED_SWITCH)).limit(1).then((r) => r[0]);
150307
+ const row = await vctx.sql.db.select().from(t).where(eq206(t.name, PUBLISHING_PAUSED_SWITCH)).limit(1).then((r) => r[0]);
150177
150308
  if (row === void 0) return { paused: false };
150178
150309
  return { paused: row.enabled === 1, reason: row.reason, setBy: row.setBy, updated: row.updated };
150179
150310
  }
@@ -150196,14 +150327,14 @@ async function moderationAdmin(vctx, req2, now3 = /* @__PURE__ */ new Date()) {
150196
150327
  const status = req2.status ?? "open";
150197
150328
  const limit = Math.max(1, Math.min(MAX_LIST_LIMIT, Math.floor(req2.limit ?? DEFAULT_LIST_LIMIT)));
150198
150329
  const base = vctx.sql.db.select().from(reports);
150199
- const rows = await (status === "all" ? base : base.where(eq205(reports.status, status))).orderBy(desc43(reports.created)).limit(limit);
150330
+ const rows = await (status === "all" ? base : base.where(eq206(reports.status, status))).orderBy(desc43(reports.created)).limit(limit);
150200
150331
  return Result286.Ok({ type: "vibes.diy.res-moderation-admin", op: req2.op, reports: rows.map(toReportRow) });
150201
150332
  }
150202
150333
  case "resolve-report": {
150203
150334
  if (req2.reportId === void 0 || req2.reportId === "") return Result286.Err("moderation: resolve-report needs --report");
150204
- const existing = await vctx.sql.db.select().from(reports).where(eq205(reports.reportId, req2.reportId)).limit(1).then((r) => r[0]);
150335
+ const existing = await vctx.sql.db.select().from(reports).where(eq206(reports.reportId, req2.reportId)).limit(1).then((r) => r[0]);
150205
150336
  if (existing === void 0) return Result286.Err(`moderation: no report ${req2.reportId}`);
150206
- await vctx.sql.db.update(reports).set({ status: "resolved", resolvedAt: nowIso2, resolvedBy: actingUserId, resolution: reason }).where(eq205(reports.reportId, req2.reportId));
150337
+ await vctx.sql.db.update(reports).set({ status: "resolved", resolvedAt: nowIso2, resolvedBy: actingUserId, resolution: reason }).where(eq206(reports.reportId, req2.reportId));
150207
150338
  logAdminAccountAction(vctx, { op: "resolve-report", actingUserId, reportId: req2.reportId, why: reason });
150208
150339
  return Result286.Ok({
150209
150340
  type: "vibes.diy.res-moderation-admin",
@@ -150220,12 +150351,12 @@ async function moderationAdmin(vctx, req2, now3 = /* @__PURE__ */ new Date()) {
150220
150351
  return Result286.Err("moderation: a platform admin account cannot be suspended; take it off VIBES_ADMIN_USER_IDS first");
150221
150352
  }
150222
150353
  const suspended = req2.op === "suspend" ? 1 : 0;
150223
- const existing = await vctx.sql.db.select({ userId: suspensions.userId }).from(suspensions).where(eq205(suspensions.userId, userId)).limit(1).then((r) => r[0]);
150354
+ const existing = await vctx.sql.db.select({ userId: suspensions.userId }).from(suspensions).where(eq206(suspensions.userId, userId)).limit(1).then((r) => r[0]);
150224
150355
  if (existing === void 0) {
150225
150356
  if (suspended === 0) return Result286.Err(`moderation: ${userId} is not suspended`);
150226
150357
  await vctx.sql.db.insert(suspensions).values({ userId, suspended, reason, setBy: actingUserId, updated: nowIso2, created: nowIso2 });
150227
150358
  } else {
150228
- await vctx.sql.db.update(suspensions).set({ suspended, reason, setBy: actingUserId, updated: nowIso2 }).where(eq205(suspensions.userId, userId));
150359
+ await vctx.sql.db.update(suspensions).set({ suspended, reason, setBy: actingUserId, updated: nowIso2 }).where(eq206(suspensions.userId, userId));
150229
150360
  }
150230
150361
  forgetModerationMemo(vctx);
150231
150362
  logAdminAccountAction(vctx, { op: req2.op, actingUserId, targetUserId: userId, why: reason });
@@ -150240,11 +150371,11 @@ async function moderationAdmin(vctx, req2, now3 = /* @__PURE__ */ new Date()) {
150240
150371
  if (req2.paused === void 0) return Result286.Err("moderation: set-publishing-paused needs paused true or false");
150241
150372
  const t = vctx.sql.tables.platformSwitches;
150242
150373
  const enabled = req2.paused ? 1 : 0;
150243
- const existing = await vctx.sql.db.select({ name: t.name }).from(t).where(eq205(t.name, PUBLISHING_PAUSED_SWITCH)).limit(1).then((r) => r[0]);
150374
+ const existing = await vctx.sql.db.select({ name: t.name }).from(t).where(eq206(t.name, PUBLISHING_PAUSED_SWITCH)).limit(1).then((r) => r[0]);
150244
150375
  if (existing === void 0) {
150245
150376
  await vctx.sql.db.insert(t).values({ name: PUBLISHING_PAUSED_SWITCH, enabled, reason, setBy: actingUserId, updated: nowIso2 });
150246
150377
  } else {
150247
- await vctx.sql.db.update(t).set({ enabled, reason, setBy: actingUserId, updated: nowIso2 }).where(eq205(t.name, PUBLISHING_PAUSED_SWITCH));
150378
+ await vctx.sql.db.update(t).set({ enabled, reason, setBy: actingUserId, updated: nowIso2 }).where(eq206(t.name, PUBLISHING_PAUSED_SWITCH));
150248
150379
  }
150249
150380
  forgetModerationMemo(vctx);
150250
150381
  logAdminAccountAction(vctx, { op: req2.paused ? "pause-publishing" : "resume-publishing", actingUserId, why: reason });
@@ -150268,7 +150399,7 @@ async function moderationAdmin(vctx, req2, now3 = /* @__PURE__ */ new Date()) {
150268
150399
  const status = req2.flagStatus ?? "open";
150269
150400
  const limit = Math.max(1, Math.min(MAX_LIST_LIMIT, Math.floor(req2.limit ?? DEFAULT_LIST_LIMIT)));
150270
150401
  const base = vctx.sql.db.select().from(flags);
150271
- const rows = await (status === "all" ? base.where(notInArray9(flags.status, [...AUTO_FLAG_RECORD_STATUSES])) : base.where(eq205(flags.status, status))).orderBy(desc43(flags.created)).limit(limit);
150402
+ const rows = await (status === "all" ? base.where(notInArray9(flags.status, [...AUTO_FLAG_RECORD_STATUSES])) : base.where(eq206(flags.status, status))).orderBy(desc43(flags.created)).limit(limit);
150272
150403
  const out = [];
150273
150404
  for (const r of await withCurrentFlagAddress(vctx.sql, rows)) {
150274
150405
  const text3 = r.inputKind === "prompt" && r.chatId && r.promptId ? await readFlaggedPrompt(vctx, r.chatId, r.promptId) : void 0;
@@ -150280,7 +150411,7 @@ async function moderationAdmin(vctx, req2, now3 = /* @__PURE__ */ new Date()) {
150280
150411
  if (req2.flagId === void 0 || req2.flagId === "") return Result286.Err("moderation: triage needs --flag");
150281
150412
  if (req2.triage === void 0) return Result286.Err("moderation: triage needs --as false_alarm, escalated or resolved");
150282
150413
  const flags = vctx.sql.tables.autoModerationFlags;
150283
- const existing = await vctx.sql.db.select().from(flags).where(eq205(flags.flagId, req2.flagId)).limit(1).then((r) => withCurrentFlagAddress(vctx.sql, r)).then((r) => r[0]);
150414
+ const existing = await vctx.sql.db.select().from(flags).where(eq206(flags.flagId, req2.flagId)).limit(1).then((r) => withCurrentFlagAddress(vctx.sql, r)).then((r) => r[0]);
150284
150415
  if (existing === void 0) return Result286.Err(`moderation: no flag ${req2.flagId}`);
150285
150416
  if (existing.status === AUTO_FLAG_ALLOWED_STATUS) {
150286
150417
  return Result286.Err(`moderation: ${req2.flagId} records an allow, not a flag; there is nothing to triage`);
@@ -150296,7 +150427,7 @@ async function moderationAdmin(vctx, req2, now3 = /* @__PURE__ */ new Date()) {
150296
150427
  triageNote: reason,
150297
150428
  ...escalating ? { firstPingAt: nowIso2, widenedAt: null } : {}
150298
150429
  };
150299
- await vctx.sql.db.update(flags).set(set).where(eq205(flags.flagId, req2.flagId));
150430
+ await vctx.sql.db.update(flags).set(set).where(eq206(flags.flagId, req2.flagId));
150300
150431
  if (escalating) {
150301
150432
  postQueueFact({
150302
150433
  ctx: vctx,
@@ -150322,8 +150453,8 @@ async function moderationAdmin(vctx, req2, now3 = /* @__PURE__ */ new Date()) {
150322
150453
  });
150323
150454
  }
150324
150455
  case "status": {
150325
- const active = await vctx.sql.db.select().from(suspensions).where(eq205(suspensions.suspended, 1));
150326
- const openReports = await vctx.sql.db.select({ n: count5() }).from(reports).where(and174(eq205(reports.status, "open"))).then((r) => r[0]?.n ?? 0);
150456
+ const active = await vctx.sql.db.select().from(suspensions).where(eq206(suspensions.suspended, 1));
150457
+ const openReports = await vctx.sql.db.select({ n: count5() }).from(reports).where(and174(eq206(reports.status, "open"))).then((r) => r[0]?.n ?? 0);
150327
150458
  return Result286.Ok({
150328
150459
  type: "vibes.diy.res-moderation-admin",
150329
150460
  op: req2.op,
@@ -150381,7 +150512,7 @@ var init_moderation_admin = __esm({
150381
150512
 
150382
150513
  // ../vibes.diy/api/svc/public/retention-admin.ts
150383
150514
  import { EventoResult as EventoResult71, Option as Option77, Result as Result287 } from "@adviser/cement";
150384
- import { and as and175, eq as eq206 } from "drizzle-orm/sql/expressions";
150515
+ import { and as and175, eq as eq207 } from "drizzle-orm/sql/expressions";
150385
150516
  import { type as type226 } from "arktype";
150386
150517
  async function gateTarget(arg) {
150387
150518
  const { vctx, op, callerUserId, targetUserId } = arg;
@@ -150389,7 +150520,7 @@ async function gateTarget(arg) {
150389
150520
  return Result287.Err(`${op}: admin only \u2014 your userId must be in VIBES_ADMIN_USER_IDS`);
150390
150521
  }
150391
150522
  const t = vctx.sql.tables.userSettings;
150392
- const row = await vctx.sql.db.select().from(t).where(eq206(t.userId, targetUserId)).limit(1).then((r) => r[0]);
150523
+ const row = await vctx.sql.db.select().from(t).where(eq207(t.userId, targetUserId)).limit(1).then((r) => r[0]);
150393
150524
  if (row === void 0) {
150394
150525
  return Result287.Err(`${op}: no UserSettings row for ${targetUserId} \u2014 that account has never been seen server-side`);
150395
150526
  }
@@ -150481,8 +150612,8 @@ async function retentionResetClaim(vctx, req2) {
150481
150612
  const rest = rawSettings.filter((s) => s?.type !== "retentionDrip");
150482
150613
  const nextSettings = Object.keys(nextSent).length === 0 ? rest : [...rest, { type: "retentionDrip", sent: nextSent, updatedAt: now3 }];
150483
150614
  const t = vctx.sql.tables.userSettings;
150484
- await vctx.sql.db.update(t).set({ settings: nextSettings, updated: now3 }).where(and175(eq206(t.userId, req2.userId), eq206(t.updated, updated)));
150485
- const after = await vctx.sql.db.select().from(t).where(eq206(t.userId, req2.userId)).limit(1).then((r) => r[0]);
150615
+ await vctx.sql.db.update(t).set({ settings: nextSettings, updated: now3 }).where(and175(eq207(t.userId, req2.userId), eq207(t.updated, updated)));
150616
+ const after = await vctx.sql.db.select().from(t).where(eq207(t.userId, req2.userId)).limit(1).then((r) => r[0]);
150486
150617
  const { filtered: afterSettings } = parseArrayWarning(after?.settings ?? [], userSettingItem);
150487
150618
  const afterSent = afterSettings.find(isUserSettingRetentionDrip)?.sent ?? {};
150488
150619
  const stillThere = cleared.filter((id) => Object.hasOwn(afterSent, id));
@@ -150544,7 +150675,7 @@ var init_retention_admin = __esm({
150544
150675
 
150545
150676
  // ../vibes.diy/api/svc/public/terms-ack.ts
150546
150677
  import { EventoResult as EventoResult72, Option as Option78, Result as Result288 } from "@adviser/cement";
150547
- import { and as and176, eq as eq207 } from "drizzle-orm/sql/expressions";
150678
+ import { and as and176, eq as eq208 } from "drizzle-orm/sql/expressions";
150548
150679
  import { type as type227 } from "arktype";
150549
150680
  function shouldShowTermsNotice(state3, revision = CURRENT_TERMS_REVISION) {
150550
150681
  if (state3.accountCreated === void 0 || state3.accountCreated >= revision) return false;
@@ -150557,7 +150688,7 @@ function readAck(items) {
150557
150688
  async function termsAck(vctx, req2, attempt = 0) {
150558
150689
  const userId = req2._auth.verifiedAuth.claims.userId;
150559
150690
  const tSettings = vctx.sql.tables.userSettings;
150560
- const existing = await vctx.sql.db.select().from(tSettings).where(eq207(tSettings.userId, userId)).limit(1).then((r) => r[0]);
150691
+ const existing = await vctx.sql.db.select().from(tSettings).where(eq208(tSettings.userId, userId)).limit(1).then((r) => r[0]);
150561
150692
  const raw = Array.isArray(existing?.settings) ? existing.settings : [];
150562
150693
  const items = raw.filter((i) => userSettingItem.allows(i));
150563
150694
  let acked = readAck(items);
@@ -150567,7 +150698,7 @@ async function termsAck(vctx, req2, attempt = 0) {
150567
150698
  if (existing === void 0) {
150568
150699
  await vctx.sql.db.insert(tSettings).values({ userId, settings: next, updated: now3, created: now3 }).onConflictDoNothing({ target: tSettings.userId });
150569
150700
  } else {
150570
- const written = await vctx.sql.db.update(tSettings).set({ settings: next, updated: now3 }).where(and176(eq207(tSettings.userId, userId), eq207(tSettings.settings, existing.settings))).returning({ userId: tSettings.userId });
150701
+ const written = await vctx.sql.db.update(tSettings).set({ settings: next, updated: now3 }).where(and176(eq208(tSettings.userId, userId), eq208(tSettings.settings, existing.settings))).returning({ userId: tSettings.userId });
150571
150702
  if (written.length === 0) {
150572
150703
  if (attempt + 1 < WRITE_ATTEMPTS2) return termsAck(vctx, req2, attempt + 1);
150573
150704
  return Result288.Err(new Error(`terms-ack: settings write kept conflicting for ${userId}`));
@@ -150616,17 +150747,17 @@ var init_terms_ack = __esm({
150616
150747
 
150617
150748
  // ../vibes.diy/api/svc/public/ensure-handle-avatar.ts
150618
150749
  import { Result as Result289, Option as Option79, EventoResult as EventoResult73 } from "@adviser/cement";
150619
- import { and as and177, eq as eq208 } from "drizzle-orm/sql/expressions";
150750
+ import { and as and177, eq as eq209 } from "drizzle-orm/sql/expressions";
150620
150751
  import { type as type228 } from "arktype";
150621
150752
  async function ensureHandleAvatar(vctx, req2) {
150622
150753
  const userId = req2._auth.verifiedAuth.claims.userId;
150623
150754
  const hb = vctx.sql.tables.handleBinding;
150624
- const binding = await vctx.sql.db.select({ handle: hb.handle }).from(hb).where(and177(eq208(hb.handle, req2.handle), eq208(hb.userId, userId))).limit(1).then((r) => r[0]);
150755
+ const binding = await vctx.sql.db.select({ handle: hb.handle }).from(hb).where(and177(eq209(hb.handle, req2.handle), eq209(hb.userId, userId))).limit(1).then((r) => r[0]);
150625
150756
  if (!binding) {
150626
150757
  return Result289.Ok({ type: "vibes.diy.res-error", error: { message: "Access denied" } });
150627
150758
  }
150628
150759
  const au = vctx.sql.tables.assetUploads;
150629
- const upload = await vctx.sql.db.select({ assetURI: au.assetURI, mimeType: au.mimeType, size: au.size }).from(au).where(and177(eq208(au.cid, req2.cid), eq208(au.userId, userId))).limit(1).then((r) => r[0]);
150760
+ const upload = await vctx.sql.db.select({ assetURI: au.assetURI, mimeType: au.mimeType, size: au.size }).from(au).where(and177(eq209(au.cid, req2.cid), eq209(au.userId, userId))).limit(1).then((r) => r[0]);
150630
150761
  if (!upload) {
150631
150762
  return Result289.Ok({
150632
150763
  type: "vibes.diy.res-error",
@@ -150689,7 +150820,7 @@ var init_ensure_handle_avatar = __esm({
150689
150820
  // ../vibes.diy/api/svc/public/list-application-chats.ts
150690
150821
  import { Result as Result290, Option as Option80, EventoResult as EventoResult74 } from "@adviser/cement";
150691
150822
  import { type as type229 } from "arktype";
150692
- import { eq as eq209, and as and178, lt as lt16, desc as desc44, asc as asc19, inArray as inArray54 } from "drizzle-orm/sql/expressions";
150823
+ import { eq as eq210, and as and178, lt as lt16, desc as desc44, asc as asc19, inArray as inArray55 } from "drizzle-orm/sql/expressions";
150693
150824
  var DEFAULT_LIMIT5, MAX_LIMIT5, listApplicationChats;
150694
150825
  var init_list_application_chats = __esm({
150695
150826
  "../vibes.diy/api/svc/public/list-application-chats.ts"() {
@@ -150728,9 +150859,9 @@ var init_list_application_chats = __esm({
150728
150859
  return Result290.Ok(EventoResult74.Continue);
150729
150860
  }
150730
150861
  const limit = Math.min(req2.limit ?? DEFAULT_LIMIT5, MAX_LIMIT5);
150731
- const conditions = [eq209(vctx.sql.tables.applicationChats.userId, userId)];
150732
- if (req2.appSlug) conditions.push(eq209(vctx.sql.tables.applicationChats.appSlug, req2.appSlug));
150733
- if (req2.ownerHandle) conditions.push(eq209(vctx.sql.tables.applicationChats.ownerHandle, req2.ownerHandle));
150862
+ const conditions = [eq210(vctx.sql.tables.applicationChats.userId, userId)];
150863
+ if (req2.appSlug) conditions.push(eq210(vctx.sql.tables.applicationChats.appSlug, req2.appSlug));
150864
+ if (req2.ownerHandle) conditions.push(eq210(vctx.sql.tables.applicationChats.ownerHandle, req2.ownerHandle));
150734
150865
  if (req2.cursor) conditions.push(lt16(vctx.sql.tables.applicationChats.created, req2.cursor));
150735
150866
  const rows = await vctx.sql.db.select({
150736
150867
  chatId: vctx.sql.tables.applicationChats.chatId,
@@ -150747,7 +150878,7 @@ var init_list_application_chats = __esm({
150747
150878
  const handleRows = await vctx.sql.db.select({
150748
150879
  userId: vctx.sql.tables.handleBinding.userId,
150749
150880
  handle: vctx.sql.tables.handleBinding.handle
150750
- }).from(vctx.sql.tables.handleBinding).where(inArray54(vctx.sql.tables.handleBinding.userId, userIds)).orderBy(asc19(vctx.sql.tables.handleBinding.created));
150881
+ }).from(vctx.sql.tables.handleBinding).where(inArray55(vctx.sql.tables.handleBinding.userId, userIds)).orderBy(asc19(vctx.sql.tables.handleBinding.created));
150751
150882
  for (const r of handleRows) {
150752
150883
  if (!handleByUser.has(r.userId)) handleByUser.set(r.userId, r.handle);
150753
150884
  }
@@ -150771,7 +150902,7 @@ var init_list_application_chats = __esm({
150771
150902
  // ../vibes.diy/api/svc/public/list-codegen-chats.ts
150772
150903
  import { Result as Result291, Option as Option81, EventoResult as EventoResult75 } from "@adviser/cement";
150773
150904
  import { type as type230 } from "arktype";
150774
- import { eq as eq210, and as and179, lt as lt17, desc as desc45 } from "drizzle-orm/sql/expressions";
150905
+ import { eq as eq211, and as and179, lt as lt17, desc as desc45 } from "drizzle-orm/sql/expressions";
150775
150906
  var DEFAULT_LIMIT6, MAX_LIMIT6, listCodegenChats;
150776
150907
  var init_list_codegen_chats = __esm({
150777
150908
  "../vibes.diy/api/svc/public/list-codegen-chats.ts"() {
@@ -150801,9 +150932,9 @@ var init_list_codegen_chats = __esm({
150801
150932
  const vctx = ctx.ctx.getOrThrow("vibesApiCtx");
150802
150933
  const userId = req2._auth.verifiedAuth.claims.userId;
150803
150934
  const limit = Math.min(req2.limit ?? DEFAULT_LIMIT6, MAX_LIMIT6);
150804
- const conditions = [eq210(vctx.sql.tables.chatContexts.userId, userId)];
150805
- if (req2.appSlug) conditions.push(eq210(vctx.sql.tables.chatContexts.appSlug, req2.appSlug));
150806
- if (req2.ownerHandle) conditions.push(eq210(vctx.sql.tables.chatContexts.ownerHandle, req2.ownerHandle));
150935
+ const conditions = [eq211(vctx.sql.tables.chatContexts.userId, userId)];
150936
+ if (req2.appSlug) conditions.push(eq211(vctx.sql.tables.chatContexts.appSlug, req2.appSlug));
150937
+ if (req2.ownerHandle) conditions.push(eq211(vctx.sql.tables.chatContexts.ownerHandle, req2.ownerHandle));
150807
150938
  if (req2.cursor) conditions.push(lt17(vctx.sql.tables.chatContexts.created, req2.cursor));
150808
150939
  const rows = await vctx.sql.db.select({
150809
150940
  chatId: vctx.sql.tables.chatContexts.chatId,
@@ -150933,7 +151064,7 @@ var init_set_agent_discussion = __esm({
150933
151064
  // ../vibes.diy/api/svc/public/get-application-chat.ts
150934
151065
  import { Result as Result294, Option as Option84, EventoResult as EventoResult78 } from "@adviser/cement";
150935
151066
  import { type as type233 } from "arktype";
150936
- import { eq as eq211, and as and180, ne as ne28 } from "drizzle-orm/sql/expressions";
151067
+ import { eq as eq212, and as and180, ne as ne27 } from "drizzle-orm/sql/expressions";
150937
151068
  var getApplicationChatEvento;
150938
151069
  var init_get_application_chat = __esm({
150939
151070
  "../vibes.diy/api/svc/public/get-application-chat.ts"() {
@@ -150962,11 +151093,11 @@ var init_get_application_chat = __esm({
150962
151093
  const vctx = ctx.ctx.getOrThrow("vibesApiCtx");
150963
151094
  const userId = req2._auth.verifiedAuth.claims.userId;
150964
151095
  const conditions = [
150965
- eq211(vctx.sql.tables.applicationChats.userId, userId),
150966
- eq211(vctx.sql.tables.applicationChats.chatId, req2.chatId)
151096
+ eq212(vctx.sql.tables.applicationChats.userId, userId),
151097
+ eq212(vctx.sql.tables.applicationChats.chatId, req2.chatId)
150967
151098
  ];
150968
- if (req2.appSlug) conditions.push(eq211(vctx.sql.tables.applicationChats.appSlug, req2.appSlug));
150969
- if (req2.ownerHandle) conditions.push(eq211(vctx.sql.tables.applicationChats.ownerHandle, req2.ownerHandle));
151099
+ if (req2.appSlug) conditions.push(eq212(vctx.sql.tables.applicationChats.appSlug, req2.appSlug));
151100
+ if (req2.ownerHandle) conditions.push(eq212(vctx.sql.tables.applicationChats.ownerHandle, req2.ownerHandle));
150970
151101
  const appRows = await vctx.sql.db.select({
150971
151102
  chatId: vctx.sql.tables.applicationChats.chatId,
150972
151103
  appSlug: vctx.sql.tables.applicationChats.appSlug,
@@ -150989,11 +151120,11 @@ var init_get_application_chat = __esm({
150989
151120
  }).from(vctx.sql.tables.chatSections).leftJoin(
150990
151121
  vctx.sql.tables.promptContexts,
150991
151122
  and180(
150992
- eq211(vctx.sql.tables.promptContexts.chatId, vctx.sql.tables.chatSections.chatId),
150993
- eq211(vctx.sql.tables.promptContexts.promptId, vctx.sql.tables.chatSections.promptId)
151123
+ eq212(vctx.sql.tables.promptContexts.chatId, vctx.sql.tables.chatSections.chatId),
151124
+ eq212(vctx.sql.tables.promptContexts.promptId, vctx.sql.tables.chatSections.promptId)
150994
151125
  )
150995
151126
  ).where(
150996
- and180(eq211(vctx.sql.tables.chatSections.chatId, req2.chatId), ne28(vctx.sql.tables.chatSections.blockSeq, RESEARCH_BLOCK_SEQ))
151127
+ and180(eq212(vctx.sql.tables.chatSections.chatId, req2.chatId), ne27(vctx.sql.tables.chatSections.blockSeq, RESEARCH_BLOCK_SEQ))
150997
151128
  );
150998
151129
  const turns2 = /* @__PURE__ */ new Map();
150999
151130
  for (const row of sectionRows) {
@@ -151032,10 +151163,10 @@ var init_get_application_chat = __esm({
151032
151163
  // ../vibes.diy/api/svc/public/set-mode-fsid.ts
151033
151164
  import { Result as Result295, Option as Option85, EventoResult as EventoResult79, exception2Result as exception2Result337 } from "@adviser/cement";
151034
151165
  import { type as type234 } from "arktype";
151035
- import { eq as eq212, and as and181 } from "drizzle-orm/sql/expressions";
151166
+ import { eq as eq213, and as and181 } from "drizzle-orm/sql/expressions";
151036
151167
  async function ownerUserIdOfHandle(vctx, ownerHandle) {
151037
151168
  const usb = vctx.sql.tables.handleBinding;
151038
- const row = await vctx.sql.db.select({ userId: usb.userId }).from(usb).where(eq212(usb.handle, ownerHandle)).limit(1).then((r) => r[0]);
151169
+ const row = await vctx.sql.db.select({ userId: usb.userId }).from(usb).where(eq213(usb.handle, ownerHandle)).limit(1).then((r) => r[0]);
151039
151170
  return row?.userId;
151040
151171
  }
151041
151172
  async function setModeFsId(vctx, req2, userId) {
@@ -151070,7 +151201,7 @@ async function setModeFsId(vctx, req2, userId) {
151070
151201
  }
151071
151202
  const apps = vctx.sql.tables.apps;
151072
151203
  const fsRow = await vctx.sql.db.select({ fsId: apps.fsId }).from(apps).where(
151073
- and181(eq212(apps.userId, rowUserId), eq212(apps.ownerHandle, req2.ownerHandle), eq212(apps.appSlug, req2.appSlug), eq212(apps.fsId, req2.fsId))
151204
+ and181(eq213(apps.userId, rowUserId), eq213(apps.ownerHandle, req2.ownerHandle), eq213(apps.appSlug, req2.appSlug), eq213(apps.fsId, req2.fsId))
151074
151205
  ).limit(1).then((r) => r[0]);
151075
151206
  if (fsRow === void 0) {
151076
151207
  return notFound();
@@ -151079,10 +151210,10 @@ async function setModeFsId(vctx, req2, userId) {
151079
151210
  const rReset = await exception2Result337(
151080
151211
  () => vctx.sql.db.update(vctx.sql.tables.apps).set({ mode: "dev" }).where(
151081
151212
  and181(
151082
- eq212(vctx.sql.tables.apps.userId, rowUserId),
151083
- eq212(vctx.sql.tables.apps.ownerHandle, req2.ownerHandle),
151084
- eq212(vctx.sql.tables.apps.appSlug, req2.appSlug),
151085
- eq212(vctx.sql.tables.apps.mode, "production")
151213
+ eq213(vctx.sql.tables.apps.userId, rowUserId),
151214
+ eq213(vctx.sql.tables.apps.ownerHandle, req2.ownerHandle),
151215
+ eq213(vctx.sql.tables.apps.appSlug, req2.appSlug),
151216
+ eq213(vctx.sql.tables.apps.mode, "production")
151086
151217
  )
151087
151218
  )
151088
151219
  );
@@ -151093,10 +151224,10 @@ async function setModeFsId(vctx, req2, userId) {
151093
151224
  const rUpdate = await exception2Result337(
151094
151225
  () => vctx.sql.db.update(vctx.sql.tables.apps).set({ mode: req2.mode }).where(
151095
151226
  and181(
151096
- eq212(vctx.sql.tables.apps.userId, rowUserId),
151097
- eq212(vctx.sql.tables.apps.ownerHandle, req2.ownerHandle),
151098
- eq212(vctx.sql.tables.apps.appSlug, req2.appSlug),
151099
- eq212(vctx.sql.tables.apps.fsId, req2.fsId)
151227
+ eq213(vctx.sql.tables.apps.userId, rowUserId),
151228
+ eq213(vctx.sql.tables.apps.ownerHandle, req2.ownerHandle),
151229
+ eq213(vctx.sql.tables.apps.appSlug, req2.appSlug),
151230
+ eq213(vctx.sql.tables.apps.fsId, req2.fsId)
151100
151231
  )
151101
151232
  ).returning({ fsId: vctx.sql.tables.apps.fsId })
151102
151233
  );
@@ -151225,7 +151356,7 @@ var init_set_mode_fsid = __esm({
151225
151356
  // ../vibes.diy/api/svc/public/set-version-lock.ts
151226
151357
  import { Result as Result296, Option as Option86, EventoResult as EventoResult80, exception2Result as exception2Result338 } from "@adviser/cement";
151227
151358
  import { type as type235 } from "arktype";
151228
- import { eq as eq213, and as and182 } from "drizzle-orm/sql/expressions";
151359
+ import { eq as eq214, and as and182 } from "drizzle-orm/sql/expressions";
151229
151360
  var setVersionLockEvento;
151230
151361
  var init_set_version_lock = __esm({
151231
151362
  "../vibes.diy/api/svc/public/set-version-lock.ts"() {
@@ -151284,11 +151415,11 @@ var init_set_version_lock = __esm({
151284
151415
  const asb = vctx.sql.tables.appSlugBinding;
151285
151416
  let newLockedFsId = "";
151286
151417
  if (isUnlock) {
151287
- await vctx.sql.db.update(asb).set({ lockedFsId: "" }).where(and182(eq213(asb.ownerHandle, req2.ownerHandle), eq213(asb.appSlug, req2.appSlug)));
151418
+ await vctx.sql.db.update(asb).set({ lockedFsId: "" }).where(and182(eq214(asb.ownerHandle, req2.ownerHandle), eq214(asb.appSlug, req2.appSlug)));
151288
151419
  } else {
151289
151420
  const lockedFsId = req2.fsId;
151290
151421
  const apps = vctx.sql.tables.apps;
151291
- const fsRow = await vctx.sql.db.select({ userId: apps.userId, fileSystem: apps.fileSystem }).from(apps).where(and182(eq213(apps.fsId, lockedFsId), eq213(apps.appSlug, req2.appSlug), eq213(apps.ownerHandle, req2.ownerHandle))).limit(1).then((r) => r[0]);
151422
+ const fsRow = await vctx.sql.db.select({ userId: apps.userId, fileSystem: apps.fileSystem }).from(apps).where(and182(eq214(apps.fsId, lockedFsId), eq214(apps.appSlug, req2.appSlug), eq214(apps.ownerHandle, req2.ownerHandle))).limit(1).then((r) => r[0]);
151292
151423
  if (fsRow === void 0) {
151293
151424
  return notFound();
151294
151425
  }
@@ -151381,7 +151512,7 @@ var init_set_version_lock = __esm({
151381
151512
  // ../vibes.diy/api/svc/public/carry-app-settings-evento.ts
151382
151513
  import { Result as Result297, Option as Option87, EventoResult as EventoResult81 } from "@adviser/cement";
151383
151514
  import { type as type236 } from "arktype";
151384
- import { and as and183, eq as eq214 } from "drizzle-orm/sql/expressions";
151515
+ import { and as and183, eq as eq215 } from "drizzle-orm/sql/expressions";
151385
151516
  function srcRefusal(message3) {
151386
151517
  for (const code2 of [
151387
151518
  CARRY_SRC_NOT_FOUND_CODE,
@@ -151396,9 +151527,9 @@ function srcRefusal(message3) {
151396
151527
  async function carryAppSettingsForOwnedApp(vctx, req2, userId) {
151397
151528
  const dst = await vctx.sql.db.select().from(vctx.sql.tables.apps).where(
151398
151529
  and183(
151399
- eq214(vctx.sql.tables.apps.ownerHandle, req2.dstOwnerHandle),
151400
- eq214(vctx.sql.tables.apps.appSlug, req2.dstAppSlug),
151401
- eq214(vctx.sql.tables.apps.userId, userId)
151530
+ eq215(vctx.sql.tables.apps.ownerHandle, req2.dstOwnerHandle),
151531
+ eq215(vctx.sql.tables.apps.appSlug, req2.dstAppSlug),
151532
+ eq215(vctx.sql.tables.apps.userId, userId)
151402
151533
  )
151403
151534
  ).limit(1).then((r) => r[0]);
151404
151535
  if (dst === void 0) {
@@ -151534,7 +151665,7 @@ var init_list_versions = __esm({
151534
151665
  // ../vibes.diy/api/svc/public/asset-safety-status.ts
151535
151666
  import { EventoResult as EventoResult83, Option as Option89, Result as Result299, exception2Result as exception2Result339 } from "@adviser/cement";
151536
151667
  import { type as type238 } from "arktype";
151537
- import { and as and184, eq as eq215, inArray as inArray55 } from "drizzle-orm";
151668
+ import { and as and184, eq as eq216, inArray as inArray56 } from "drizzle-orm";
151538
151669
  async function sendError(ctx, message3) {
151539
151670
  await ctx.send.send(ctx, {
151540
151671
  type: "vibes.diy.res-error",
@@ -151579,7 +151710,7 @@ var init_asset_safety_status = __esm({
151579
151710
  const cids = Array.from(new Set(req2.cids.filter((c) => c.length > 0))).slice(0, MAX_CIDS);
151580
151711
  if (cids.length === 0) return empty();
151581
151712
  const rOwner = await exception2Result339(
151582
- () => vctx.sql.db.select({ userId: vctx.sql.tables.handleBinding.userId }).from(vctx.sql.tables.handleBinding).where(eq215(vctx.sql.tables.handleBinding.handle, req2.ownerHandle)).limit(1).then((rows) => rows[0])
151713
+ () => vctx.sql.db.select({ userId: vctx.sql.tables.handleBinding.userId }).from(vctx.sql.tables.handleBinding).where(eq216(vctx.sql.tables.handleBinding.handle, req2.ownerHandle)).limit(1).then((rows) => rows[0])
151583
151714
  );
151584
151715
  if (rOwner.isErr()) {
151585
151716
  return sendError(ctx, rOwner.Err().message);
@@ -151596,7 +151727,7 @@ var init_asset_safety_status = __esm({
151596
151727
  }
151597
151728
  const a = vctx.sql.tables.apps;
151598
151729
  const rRelease = await exception2Result339(
151599
- () => vctx.sql.db.select({ fileSystem: a.fileSystem, mode: a.mode, created: a.created, releaseSeq: a.releaseSeq }).from(a).where(and184(eq215(a.ownerHandle, req2.ownerHandle), eq215(a.appSlug, req2.appSlug)))
151730
+ () => vctx.sql.db.select({ fileSystem: a.fileSystem, mode: a.mode, created: a.created, releaseSeq: a.releaseSeq }).from(a).where(and184(eq216(a.ownerHandle, req2.ownerHandle), eq216(a.appSlug, req2.appSlug)))
151600
151731
  );
151601
151732
  if (rRelease.isErr()) {
151602
151733
  return sendError(ctx, rRelease.Err().message);
@@ -151618,7 +151749,7 @@ var init_asset_safety_status = __esm({
151618
151749
  if (owned.length === 0) return empty();
151619
151750
  const s = vctx.sql.tables.assetSafety;
151620
151751
  const rRows = await exception2Result339(
151621
- () => vctx.sql.db.select({ cid: s.cid, verdict: s.verdict }).from(s).where(inArray55(s.cid, owned))
151752
+ () => vctx.sql.db.select({ cid: s.cid, verdict: s.verdict }).from(s).where(inArray56(s.cid, owned))
151622
151753
  );
151623
151754
  if (rRows.isErr()) {
151624
151755
  return sendError(ctx, rRows.Err().message);
@@ -151652,7 +151783,7 @@ import {
151652
151783
  } from "@adviser/cement";
151653
151784
  import { type as type239 } from "arktype";
151654
151785
  import { base58btc as base58btc15 } from "multiformats/bases/base58";
151655
- import { eq as eq216, and as and185, lt as lt18, or as or23, desc as desc46, isNull as isNull12, inArray as inArray56, not as not3, sql as sql32 } from "drizzle-orm";
151786
+ import { eq as eq217, and as and185, lt as lt18, or as or23, desc as desc46, isNull as isNull12, inArray as inArray57, not as not3, sql as sql32 } from "drizzle-orm";
151656
151787
  function clampLimit4(raw) {
151657
151788
  if (raw === void 0) return DEFAULT_LIMIT7;
151658
151789
  if (!Number.isFinite(raw)) return DEFAULT_LIMIT7;
@@ -151725,11 +151856,11 @@ var init_list_notifications = __esm({
151725
151856
  const userId = req2._auth.verifiedAuth.claims.userId;
151726
151857
  const t = vctx.sql.tables.notifications;
151727
151858
  const limit = clampLimit4(req2.limit);
151728
- const conditions = [eq216(t.userId, userId)];
151729
- if (req2.id !== void 0) conditions.push(eq216(t.id, req2.id));
151730
- if (req2.appSlug) conditions.push(eq216(t.appSlug, req2.appSlug));
151731
- if (req2.ownerHandle) conditions.push(eq216(t.ownerHandle, req2.ownerHandle));
151732
- if (req2.notificationType) conditions.push(eq216(t.notificationType, req2.notificationType));
151859
+ const conditions = [eq217(t.userId, userId)];
151860
+ if (req2.id !== void 0) conditions.push(eq217(t.id, req2.id));
151861
+ if (req2.appSlug) conditions.push(eq217(t.appSlug, req2.appSlug));
151862
+ if (req2.ownerHandle) conditions.push(eq217(t.ownerHandle, req2.ownerHandle));
151863
+ if (req2.notificationType) conditions.push(eq217(t.notificationType, req2.notificationType));
151733
151864
  const fromTeamTests = notificationsFromTeamTestActors(t, vctx.sql.flavour);
151734
151865
  if (fromTeamTests !== void 0) conditions.push(not3(fromTeamTests));
151735
151866
  const prefs = await loadNotificationPrefs(vctx, userId);
@@ -151748,7 +151879,7 @@ var init_list_notifications = __esm({
151748
151879
  return Result300.Ok(EventoResult84.Continue);
151749
151880
  }
151750
151881
  const c = rDecoded.Ok();
151751
- const tuplePred = or23(lt18(t.created, c.created), and185(eq216(t.created, c.created), lt18(t.id, c.id)));
151882
+ const tuplePred = or23(lt18(t.created, c.created), and185(eq217(t.created, c.created), lt18(t.id, c.id)));
151752
151883
  if (tuplePred) conditions.push(tuplePred);
151753
151884
  }
151754
151885
  const rows = await vctx.sql.db.select().from(t).where(and185(...conditions)).orderBy(desc46(t.created), desc46(t.id)).limit(limit + 1);
@@ -151759,7 +151890,7 @@ var init_list_notifications = __esm({
151759
151890
  const nextCursor = lastRow ? encodeCursor4({ created: lastRow.created, id: lastRow.id }) : void 0;
151760
151891
  const unreadRow = await vctx.sql.db.select({ count: sql32`count(*)` }).from(t).where(
151761
151892
  and185(
151762
- eq216(t.userId, userId),
151893
+ eq217(t.userId, userId),
151763
151894
  isNull12(t.readAt),
151764
151895
  fromTeamTests === void 0 ? void 0 : not3(fromTeamTests),
151765
151896
  hidden === void 0 ? void 0 : not3(hidden),
@@ -151793,7 +151924,7 @@ var init_list_notifications = __esm({
151793
151924
  const userId = req2._auth.verifiedAuth.claims.userId;
151794
151925
  const t = vctx.sql.tables.notifications;
151795
151926
  const now3 = (/* @__PURE__ */ new Date()).toISOString();
151796
- const conditions = [eq216(t.userId, userId), isNull12(t.readAt)];
151927
+ const conditions = [eq217(t.userId, userId), isNull12(t.readAt)];
151797
151928
  if (req2.ids !== void 0) {
151798
151929
  if (req2.ids.length === 0) {
151799
151930
  await ctx.send.send(ctx, {
@@ -151802,7 +151933,7 @@ var init_list_notifications = __esm({
151802
151933
  });
151803
151934
  return Result300.Ok(EventoResult84.Continue);
151804
151935
  }
151805
- conditions.push(inArray56(t.id, req2.ids));
151936
+ conditions.push(inArray57(t.id, req2.ids));
151806
151937
  }
151807
151938
  const updated = await vctx.sql.db.update(t).set({ readAt: now3 }).where(and185(...conditions)).returning({ id: t.id });
151808
151939
  await ctx.send.send(ctx, {
@@ -151870,7 +152001,7 @@ var init_notifications_summary2 = __esm({
151870
152001
  });
151871
152002
 
151872
152003
  // ../vibes.diy/api/svc/public/cli-cert-pickup-store.ts
151873
- import { and as and186, eq as eq217, gt as gt19, lte as lte7 } from "drizzle-orm/sql/expressions";
152004
+ import { and as and186, eq as eq218, gt as gt19, lte as lte7 } from "drizzle-orm/sql/expressions";
151874
152005
  import { sha256 as sha25613 } from "@noble/hashes/sha2.js";
151875
152006
  import { bytesToHex as bytesToHex7, utf8ToBytes as utf8ToBytes9 } from "@noble/hashes/utils.js";
151876
152007
  function cliCertPickupKey(csr) {
@@ -151889,7 +152020,7 @@ async function upsertCliCertPickup(sql43, input) {
151889
152020
  }
151890
152021
  async function selectCliCertPickup(sql43, input) {
151891
152022
  const t = sql43.tables.cliCertPickups;
151892
- return sql43.db.select().from(t).where(and186(eq217(t.csrHash, cliCertPickupKey(input.csr)), gt19(t.expires, input.nowIso))).limit(1).then((r) => r[0]);
152023
+ return sql43.db.select().from(t).where(and186(eq218(t.csrHash, cliCertPickupKey(input.csr)), gt19(t.expires, input.nowIso))).limit(1).then((r) => r[0]);
151893
152024
  }
151894
152025
  async function sweepExpiredCliCertPickups(sql43, input) {
151895
152026
  const t = sql43.tables.cliCertPickups;
@@ -151909,7 +152040,7 @@ var init_cli_cert_pickup_store = __esm({
151909
152040
  import { Result as Result302, Option as Option92, EventoResult as EventoResult86, exception2Result as exception2Result341 } from "@adviser/cement";
151910
152041
  import { type as type241 } from "arktype";
151911
152042
  import { decodeJwt as decodeJwt5 } from "jose";
151912
- import { eq as eq218 } from "drizzle-orm/sql/expressions";
152043
+ import { eq as eq219 } from "drizzle-orm/sql/expressions";
151913
152044
  function refuse15(code2, message3) {
151914
152045
  return { type: "vibes.diy.res-error", error: { message: message3, code: code2 } };
151915
152046
  }
@@ -151967,7 +152098,7 @@ async function pickupCliCert(vctx, args) {
151967
152098
  const row = await selectCliCertPickup(vctx.sql, { csr: args.csr, nowIso: nowIso2 });
151968
152099
  if (row === void 0) return { type: "vibes.diy.res-pickup-cli-cert", state: "pending", expiresAt };
151969
152100
  const t = vctx.sql.tables.handleBinding;
151970
- const handles = await vctx.sql.db.select({ handle: t.handle }).from(t).where(eq218(t.userId, row.userId)).then((rows) => rows.map((r) => r.handle));
152101
+ const handles = await vctx.sql.db.select({ handle: t.handle }).from(t).where(eq219(t.userId, row.userId)).then((rows) => rows.map((r) => r.handle));
151971
152102
  return {
151972
152103
  type: "vibes.diy.res-pickup-cli-cert",
151973
152104
  state: "issued",
@@ -152068,7 +152199,7 @@ var init_get_cert_from_csr = __esm({
152068
152199
 
152069
152200
  // ../vibes.diy/api/svc/public/user-slug-bindings.ts
152070
152201
  import { Result as Result304, Option as Option94, EventoResult as EventoResult88 } from "@adviser/cement";
152071
- import { and as and187, eq as eq219, inArray as inArray57 } from "drizzle-orm/sql/expressions";
152202
+ import { and as and187, eq as eq220, inArray as inArray58 } from "drizzle-orm/sql/expressions";
152072
152203
  import { sql as sql33 } from "drizzle-orm/sql";
152073
152204
  async function listUserHandleBindings(vctx, userId) {
152074
152205
  const t_hb = vctx.sql.tables.handleBinding;
@@ -152079,7 +152210,7 @@ async function listUserHandleBindings(vctx, userId) {
152079
152210
  provisional: t_hb.provisional,
152080
152211
  migratedAway: t_hb.migratedAway,
152081
152212
  appSlugCount: sql33`count(${vctx.sql.tables.appSlugBinding.appSlug})`
152082
- }).from(t_hb).leftJoin(vctx.sql.tables.appSlugBinding, eq219(vctx.sql.tables.appSlugBinding.ownerHandle, t_hb.handle)).where(eq219(t_hb.userId, userId)).groupBy(t_hb.handle, t_hb.tenant, t_hb.created, t_hb.provisional, t_hb.migratedAway).orderBy(t_hb.created, t_hb.handle);
152213
+ }).from(t_hb).leftJoin(vctx.sql.tables.appSlugBinding, eq220(vctx.sql.tables.appSlugBinding.ownerHandle, t_hb.handle)).where(eq220(t_hb.userId, userId)).groupBy(t_hb.handle, t_hb.tenant, t_hb.created, t_hb.provisional, t_hb.migratedAway).orderBy(t_hb.created, t_hb.handle);
152083
152214
  return rows.map((r) => ({
152084
152215
  ...r,
152085
152216
  appSlugCount: Number(r.appSlugCount),
@@ -152210,19 +152341,19 @@ var init_user_slug_bindings = __esm({
152210
152341
  const userId = req2._auth.verifiedAuth.claims.userId;
152211
152342
  const { ownerHandle } = req2;
152212
152343
  const t = vctx.sql.tables;
152213
- const chatIdSubquery = vctx.sql.db.select({ chatId: t.chatContexts.chatId }).from(t.chatContexts).where(and187(eq219(t.chatContexts.ownerHandle, ownerHandle), eq219(t.chatContexts.userId, userId)));
152214
- await vctx.sql.db.delete(t.chatSections).where(inArray57(t.chatSections.chatId, chatIdSubquery));
152215
- await vctx.sql.db.delete(t.promptContexts).where(inArray57(t.promptContexts.chatId, chatIdSubquery));
152216
- await vctx.sql.db.delete(t.chatContexts).where(and187(eq219(t.chatContexts.ownerHandle, ownerHandle), eq219(t.chatContexts.userId, userId)));
152217
- await vctx.sql.db.delete(t.applicationChats).where(and187(eq219(t.applicationChats.ownerHandle, ownerHandle), eq219(t.applicationChats.userId, userId)));
152218
- await vctx.sql.db.delete(t.appSettings).where(and187(eq219(t.appSettings.ownerHandle, ownerHandle), eq219(t.appSettings.userId, userId)));
152219
- await vctx.sql.db.delete(t.appSettingItems).where(and187(eq219(t.appSettingItems.ownerHandle, ownerHandle), eq219(t.appSettingItems.userId, userId)));
152220
- await vctx.sql.db.delete(t.requestGrants).where(and187(eq219(t.requestGrants.ownerHandle, ownerHandle), eq219(t.requestGrants.userId, userId)));
152221
- await vctx.sql.db.delete(t.inviteGrants).where(and187(eq219(t.inviteGrants.ownerHandle, ownerHandle), eq219(t.inviteGrants.userId, userId)));
152222
- await vctx.sql.db.delete(t.apps).where(and187(eq219(t.apps.ownerHandle, ownerHandle), eq219(t.apps.userId, userId)));
152223
- await vctx.sql.db.delete(t.appSlugBinding).where(eq219(t.appSlugBinding.ownerHandle, ownerHandle));
152224
- await vctx.sql.db.delete(t.handleSettings).where(and187(eq219(t.handleSettings.userId, userId), eq219(t.handleSettings.handle, ownerHandle)));
152225
- await vctx.sql.db.delete(t.handleBinding).where(and187(eq219(t.handleBinding.userId, userId), eq219(t.handleBinding.handle, ownerHandle)));
152344
+ const chatIdSubquery = vctx.sql.db.select({ chatId: t.chatContexts.chatId }).from(t.chatContexts).where(and187(eq220(t.chatContexts.ownerHandle, ownerHandle), eq220(t.chatContexts.userId, userId)));
152345
+ await vctx.sql.db.delete(t.chatSections).where(inArray58(t.chatSections.chatId, chatIdSubquery));
152346
+ await vctx.sql.db.delete(t.promptContexts).where(inArray58(t.promptContexts.chatId, chatIdSubquery));
152347
+ await vctx.sql.db.delete(t.chatContexts).where(and187(eq220(t.chatContexts.ownerHandle, ownerHandle), eq220(t.chatContexts.userId, userId)));
152348
+ await vctx.sql.db.delete(t.applicationChats).where(and187(eq220(t.applicationChats.ownerHandle, ownerHandle), eq220(t.applicationChats.userId, userId)));
152349
+ await vctx.sql.db.delete(t.appSettings).where(and187(eq220(t.appSettings.ownerHandle, ownerHandle), eq220(t.appSettings.userId, userId)));
152350
+ await vctx.sql.db.delete(t.appSettingItems).where(and187(eq220(t.appSettingItems.ownerHandle, ownerHandle), eq220(t.appSettingItems.userId, userId)));
152351
+ await vctx.sql.db.delete(t.requestGrants).where(and187(eq220(t.requestGrants.ownerHandle, ownerHandle), eq220(t.requestGrants.userId, userId)));
152352
+ await vctx.sql.db.delete(t.inviteGrants).where(and187(eq220(t.inviteGrants.ownerHandle, ownerHandle), eq220(t.inviteGrants.userId, userId)));
152353
+ await vctx.sql.db.delete(t.apps).where(and187(eq220(t.apps.ownerHandle, ownerHandle), eq220(t.apps.userId, userId)));
152354
+ await vctx.sql.db.delete(t.appSlugBinding).where(eq220(t.appSlugBinding.ownerHandle, ownerHandle));
152355
+ await vctx.sql.db.delete(t.handleSettings).where(and187(eq220(t.handleSettings.userId, userId), eq220(t.handleSettings.handle, ownerHandle)));
152356
+ await vctx.sql.db.delete(t.handleBinding).where(and187(eq220(t.handleBinding.userId, userId), eq220(t.handleBinding.handle, ownerHandle)));
152226
152357
  await ctx.send.send(ctx, {
152227
152358
  type: "vibes.diy.res-delete-user-slug-binding",
152228
152359
  ownerHandle,
@@ -152237,14 +152368,14 @@ var init_user_slug_bindings = __esm({
152237
152368
 
152238
152369
  // ../vibes.diy/api/svc/public/has-owned-writes.ts
152239
152370
  import { Result as Result305, Option as Option95, EventoResult as EventoResult89 } from "@adviser/cement";
152240
- import { and as and188, eq as eq220, notLike as notLike2 } from "drizzle-orm/sql/expressions";
152371
+ import { and as and188, eq as eq221, notLike as notLike2 } from "drizzle-orm/sql/expressions";
152241
152372
  async function hasOwnedWrites(vctx, input) {
152242
152373
  const t = vctx.sql.tables.appDocuments;
152243
152374
  const candidates = /* @__PURE__ */ __name((limit) => vctx.sql.db.selectDistinct({ dbName: t.dbName, docId: t.docId }).from(t).where(
152244
152375
  and188(
152245
- eq220(t.ownerHandle, input.ownerHandle),
152246
- eq220(t.appSlug, input.appSlug),
152247
- eq220(t.userId, input.userId),
152376
+ eq221(t.ownerHandle, input.ownerHandle),
152377
+ eq221(t.appSlug, input.appSlug),
152378
+ eq221(t.userId, input.userId),
152248
152379
  notLike2(t.docId, `${SEED_DOC_PREFIX}%`)
152249
152380
  )
152250
152381
  ).limit(limit), "candidates");
@@ -152281,7 +152412,7 @@ var init_has_owned_writes = __esm({
152281
152412
  const vctx = ctx.ctx.getOrThrow("vibesApiCtx");
152282
152413
  const callerUserId = req2._auth.verifiedAuth.claims.userId;
152283
152414
  const owned = await vctx.sql.db.select({ handle: vctx.sql.tables.handleBinding.handle }).from(vctx.sql.tables.handleBinding).where(
152284
- and188(eq220(vctx.sql.tables.handleBinding.userId, callerUserId), eq220(vctx.sql.tables.handleBinding.handle, req2.ownerHandle))
152415
+ and188(eq221(vctx.sql.tables.handleBinding.userId, callerUserId), eq221(vctx.sql.tables.handleBinding.handle, req2.ownerHandle))
152285
152416
  ).limit(1).then((r) => r[0]);
152286
152417
  if (owned === void 0) {
152287
152418
  await ctx.send.send(ctx, {
@@ -152388,17 +152519,17 @@ var init_onboarding_handle2 = __esm({
152388
152519
 
152389
152520
  // ../vibes.diy/api/svc/public/developer-grants-flow.ts
152390
152521
  import { Result as Result307, Option as Option97, EventoResult as EventoResult91, exception2Result as exception2Result342 } from "@adviser/cement";
152391
- import { eq as eq221, and as and189, lt as lt19, desc as desc47 } from "drizzle-orm/sql/expressions";
152522
+ import { eq as eq222, and as and189, lt as lt19, desc as desc47 } from "drizzle-orm/sql/expressions";
152392
152523
  async function ownsHandle4(vctx, ownerHandle, callerUserId) {
152393
- const row = await vctx.sql.db.select({ userId: vctx.sql.tables.handleBinding.userId }).from(vctx.sql.tables.handleBinding).where(and189(eq221(vctx.sql.tables.handleBinding.handle, ownerHandle), eq221(vctx.sql.tables.handleBinding.userId, callerUserId))).limit(1).then((rows) => rows[0]);
152524
+ const row = await vctx.sql.db.select({ userId: vctx.sql.tables.handleBinding.userId }).from(vctx.sql.tables.handleBinding).where(and189(eq222(vctx.sql.tables.handleBinding.handle, ownerHandle), eq222(vctx.sql.tables.handleBinding.userId, callerUserId))).limit(1).then((rows) => rows[0]);
152394
152525
  return row !== void 0;
152395
152526
  }
152396
152527
  async function appExists2(vctx, ownerHandle, appSlug) {
152397
- const row = await vctx.sql.db.select({ appSlug: vctx.sql.tables.appSlugBinding.appSlug }).from(vctx.sql.tables.appSlugBinding).where(and189(eq221(vctx.sql.tables.appSlugBinding.ownerHandle, ownerHandle), eq221(vctx.sql.tables.appSlugBinding.appSlug, appSlug))).limit(1).then((rows) => rows[0]);
152528
+ const row = await vctx.sql.db.select({ appSlug: vctx.sql.tables.appSlugBinding.appSlug }).from(vctx.sql.tables.appSlugBinding).where(and189(eq222(vctx.sql.tables.appSlugBinding.ownerHandle, ownerHandle), eq222(vctx.sql.tables.appSlugBinding.appSlug, appSlug))).limit(1).then((rows) => rows[0]);
152398
152529
  return row !== void 0;
152399
152530
  }
152400
152531
  async function userIdForHandle2(vctx, handle) {
152401
- const row = await vctx.sql.db.select({ userId: vctx.sql.tables.handleBinding.userId }).from(vctx.sql.tables.handleBinding).where(eq221(vctx.sql.tables.handleBinding.handle, handle)).limit(1).then((rows) => rows[0]);
152532
+ const row = await vctx.sql.db.select({ userId: vctx.sql.tables.handleBinding.userId }).from(vctx.sql.tables.handleBinding).where(eq222(vctx.sql.tables.handleBinding.handle, handle)).limit(1).then((rows) => rows[0]);
152402
152533
  return row?.userId ?? null;
152403
152534
  }
152404
152535
  var DEFAULT_LIMIT8, MAX_LIMIT8, OWNER_ERROR, ensureDeveloperGrantEvento, revokeDeveloperGrantEvento, listDeveloperGrantsEvento;
@@ -152484,9 +152615,9 @@ var init_developer_grants_flow = __esm({
152484
152615
  if (rUpd.isErr()) return Result307.Err(rUpd);
152485
152616
  const persisted = await vctx.sql.db.select({ created: vctx.sql.tables.developerGrants.created }).from(vctx.sql.tables.developerGrants).where(
152486
152617
  and189(
152487
- eq221(vctx.sql.tables.developerGrants.ownerHandle, req2.ownerHandle),
152488
- eq221(vctx.sql.tables.developerGrants.appSlug, req2.appSlug),
152489
- eq221(vctx.sql.tables.developerGrants.devHandle, req2.devHandle)
152618
+ eq222(vctx.sql.tables.developerGrants.ownerHandle, req2.ownerHandle),
152619
+ eq222(vctx.sql.tables.developerGrants.appSlug, req2.appSlug),
152620
+ eq222(vctx.sql.tables.developerGrants.devHandle, req2.devHandle)
152490
152621
  )
152491
152622
  ).limit(1).then((rows) => rows[0]);
152492
152623
  await ctx.send.send(ctx, {
@@ -152522,9 +152653,9 @@ var init_developer_grants_flow = __esm({
152522
152653
  return Result307.Ok(EventoResult91.Continue);
152523
152654
  }
152524
152655
  const where = and189(
152525
- eq221(vctx.sql.tables.developerGrants.ownerHandle, req2.ownerHandle),
152526
- eq221(vctx.sql.tables.developerGrants.appSlug, req2.appSlug),
152527
- eq221(vctx.sql.tables.developerGrants.devHandle, req2.devHandle)
152656
+ eq222(vctx.sql.tables.developerGrants.ownerHandle, req2.ownerHandle),
152657
+ eq222(vctx.sql.tables.developerGrants.appSlug, req2.appSlug),
152658
+ eq222(vctx.sql.tables.developerGrants.devHandle, req2.devHandle)
152528
152659
  );
152529
152660
  const existing = await vctx.sql.db.select({ devHandle: vctx.sql.tables.developerGrants.devHandle }).from(vctx.sql.tables.developerGrants).where(where).limit(1).then((rows) => rows[0]);
152530
152661
  if (existing === void 0) {
@@ -152572,8 +152703,8 @@ var init_developer_grants_flow = __esm({
152572
152703
  return Result307.Ok(EventoResult91.Continue);
152573
152704
  }
152574
152705
  const conditions = [
152575
- eq221(vctx.sql.tables.developerGrants.ownerHandle, req2.ownerHandle),
152576
- eq221(vctx.sql.tables.developerGrants.appSlug, req2.appSlug)
152706
+ eq222(vctx.sql.tables.developerGrants.ownerHandle, req2.ownerHandle),
152707
+ eq222(vctx.sql.tables.developerGrants.appSlug, req2.appSlug)
152577
152708
  ];
152578
152709
  if (req2.pager.cursor !== void 0) {
152579
152710
  conditions.push(lt19(vctx.sql.tables.developerGrants.created, req2.pager.cursor));
@@ -152603,7 +152734,7 @@ var init_developer_grants_flow = __esm({
152603
152734
 
152604
152735
  // ../vibes.diy/api/svc/public/social-flow.ts
152605
152736
  import { Result as Result308, Option as Option98, EventoResult as EventoResult92, exception2Result as exception2Result343 } from "@adviser/cement";
152606
- import { and as and190, eq as eq222 } from "drizzle-orm/sql/expressions";
152737
+ import { and as and190, eq as eq223 } from "drizzle-orm/sql/expressions";
152607
152738
  function clientWsSend3(ctx) {
152608
152739
  return ctx.send.provider;
152609
152740
  }
@@ -152628,7 +152759,7 @@ async function sendSocialEdgeEvent(vctx, value, senderConnId) {
152628
152759
  }
152629
152760
  async function selectEdge(vctx, pair) {
152630
152761
  const t = vctx.sql.tables.socialEdges;
152631
- const row = await vctx.sql.db.select().from(t).where(and190(eq222(t.followerHandle, pair.follower), eq222(t.followeeHandle, pair.followee))).limit(1).then((r) => r[0]);
152762
+ const row = await vctx.sql.db.select().from(t).where(and190(eq223(t.followerHandle, pair.follower), eq223(t.followeeHandle, pair.followee))).limit(1).then((r) => r[0]);
152632
152763
  if (row === void 0) return void 0;
152633
152764
  return {
152634
152765
  followerHandle: row.followerHandle,
@@ -152926,7 +153057,7 @@ var init_social_flow = __esm({
152926
153057
  }
152927
153058
  if (req2.asHandle === void 0) {
152928
153059
  const t_hb = vctx.sql.tables.handleBinding;
152929
- const rows = await vctx.sql.db.select({ handle: t_hb.handle }).from(t_hb).where(eq222(t_hb.userId, userId));
153060
+ const rows = await vctx.sql.db.select({ handle: t_hb.handle }).from(t_hb).where(eq223(t_hb.userId, userId));
152930
153061
  return sendStatus({
152931
153062
  status: "choose-handle",
152932
153063
  inviterHandle: channelInvite.inviterHandle,
@@ -153749,7 +153880,7 @@ var init_invite_note_check = __esm({
153749
153880
 
153750
153881
  // ../vibes.diy/api/svc/public/channel-invite-flow.ts
153751
153882
  import { Result as Result311, Option as Option100, EventoResult as EventoResult94, exception2Result as exception2Result345 } from "@adviser/cement";
153752
- import { and as and191, eq as eq223 } from "drizzle-orm/sql/expressions";
153883
+ import { and as and191, eq as eq224 } from "drizzle-orm/sql/expressions";
153753
153884
  async function decideInviteNote({
153754
153885
  vctx,
153755
153886
  userId,
@@ -153854,7 +153985,7 @@ var init_channel_invite_flow = __esm({
153854
153985
  }
153855
153986
  const contactKey = canonicalEmail(req2.contact);
153856
153987
  const t = vctx.sql.tables.appSlugBinding;
153857
- const appRow = await vctx.sql.db.select({ appSlug: t.appSlug }).from(t).where(and191(eq223(t.ownerHandle, req2.ownerHandle), eq223(t.appSlug, req2.appSlug))).limit(1).then((rows) => rows[0]);
153988
+ const appRow = await vctx.sql.db.select({ appSlug: t.appSlug }).from(t).where(and191(eq224(t.ownerHandle, req2.ownerHandle), eq224(t.appSlug, req2.appSlug))).limit(1).then((rows) => rows[0]);
153858
153989
  if (appRow === void 0) {
153859
153990
  await ctx.send.send(ctx, {
153860
153991
  type: "vibes.diy.res-error",
@@ -153948,7 +154079,7 @@ var init_channel_invite_flow = __esm({
153948
154079
 
153949
154080
  // ../vibes.diy/api/svc/public/resolve-invite-subjects.ts
153950
154081
  import { Result as Result312, Option as Option101, EventoResult as EventoResult95 } from "@adviser/cement";
153951
- import { and as and192, eq as eq224, inArray as inArray58 } from "drizzle-orm/sql/expressions";
154082
+ import { and as and192, eq as eq225, inArray as inArray59 } from "drizzle-orm/sql/expressions";
153952
154083
  var RESOLVE_INVITE_SUBJECTS_MAX, resolveInviteSubjectsEvento;
153953
154084
  var init_resolve_invite_subjects = __esm({
153954
154085
  "../vibes.diy/api/svc/public/resolve-invite-subjects.ts"() {
@@ -153982,7 +154113,7 @@ var init_resolve_invite_subjects = __esm({
153982
154113
  }
153983
154114
  if (idToSubject.size > 0) {
153984
154115
  const t = vctx.sql.tables.channelInvites;
153985
- const rows = await vctx.sql.db.select({ id: t.id, state: t.state, boundHandle: t.boundHandle, expires: t.expires }).from(t).where(and192(inArray58(t.id, [...idToSubject.keys()]), eq224(t.ownerHandle, req2.ownerHandle), eq224(t.appSlug, req2.appSlug)));
154116
+ const rows = await vctx.sql.db.select({ id: t.id, state: t.state, boundHandle: t.boundHandle, expires: t.expires }).from(t).where(and192(inArray59(t.id, [...idToSubject.keys()]), eq225(t.ownerHandle, req2.ownerHandle), eq225(t.appSlug, req2.appSlug)));
153986
154117
  const nowIso2 = (/* @__PURE__ */ new Date()).toISOString();
153987
154118
  for (const row of rows) {
153988
154119
  const subject = idToSubject.get(row.id);
@@ -154079,7 +154210,7 @@ var init_invite_peek = __esm({
154079
154210
 
154080
154211
  // ../vibes.diy/api/svc/intern/platform-daily-counter.ts
154081
154212
  import { exception2Result as exception2Result346, Result as Result314 } from "@adviser/cement";
154082
- import { and as and193, eq as eq225, sql as sql34 } from "drizzle-orm";
154213
+ import { and as and193, eq as eq226, sql as sql34 } from "drizzle-orm";
154083
154214
  function utcDay2(nowMs) {
154084
154215
  return new Date(nowMs).toISOString().slice(0, 10);
154085
154216
  }
@@ -154097,7 +154228,7 @@ async function bumpPlatformDailyCounter(vctx, args) {
154097
154228
  async function readPlatformDailyCounter(vctx, args) {
154098
154229
  const t = vctx.sql.tables.platformDailyCounters;
154099
154230
  const rRows = await exception2Result346(
154100
- () => vctx.sql.db.select({ count: t.count }).from(t).where(and193(eq225(t.counter, args.counter), eq225(t.day, utcDay2(args.nowMs)))).limit(1)
154231
+ () => vctx.sql.db.select({ count: t.count }).from(t).where(and193(eq226(t.counter, args.counter), eq226(t.day, utcDay2(args.nowMs)))).limit(1)
154101
154232
  );
154102
154233
  if (rRows.isErr()) return Result314.Err(rRows);
154103
154234
  return Result314.Ok(rRows.Ok()[0]?.count ?? 0);
@@ -154279,7 +154410,7 @@ var init_places_map_mode = __esm({
154279
154410
 
154280
154411
  // ../vibes.diy/api/svc/public/app-documents-dm-eventos.ts
154281
154412
  import { Result as Result317, Option as Option105, EventoResult as EventoResult99 } from "@adviser/cement";
154282
- import { eq as eq226, and as and194, inArray as inArray59, sql as sql35 } from "drizzle-orm";
154413
+ import { eq as eq227, and as and194, inArray as inArray60, sql as sql35 } from "drizzle-orm";
154283
154414
  import { max as max12 } from "drizzle-orm/sql";
154284
154415
  import { type as type245 } from "arktype";
154285
154416
  var listDmThreadsEvento, markDmReadEvento;
@@ -154302,29 +154433,29 @@ var init_app_documents_dm_eventos = __esm({
154302
154433
  const vctx = ctx.ctx.getOrThrow("vibesApiCtx");
154303
154434
  const userId = req2._auth.verifiedAuth.claims.userId;
154304
154435
  const t_usb = vctx.sql.tables.handleBinding;
154305
- const mySlugRows = await vctx.sql.db.select({ handle: t_usb.handle }).from(t_usb).where(eq226(t_usb.userId, userId));
154436
+ const mySlugRows = await vctx.sql.db.select({ handle: t_usb.handle }).from(t_usb).where(eq227(t_usb.userId, userId));
154306
154437
  const myUserSlugs = mySlugRows.map((r) => r.handle);
154307
154438
  if (myUserSlugs.length === 0) {
154308
154439
  await ctx.send.send(ctx, { type: "vibes.diy.res-list-dm-threads", status: "ok", items: [] });
154309
154440
  return Result317.Ok(EventoResult99.Continue);
154310
154441
  }
154311
154442
  const t_idx = vctx.sql.tables.directChannelIndex;
154312
- const channelRows = await vctx.sql.db.select({ channelUserSlug: t_idx.channelHandle, ownerHandle: t_idx.handle }).from(t_idx).where(inArray59(t_idx.handle, myUserSlugs));
154443
+ const channelRows = await vctx.sql.db.select({ channelUserSlug: t_idx.channelHandle, ownerHandle: t_idx.handle }).from(t_idx).where(inArray60(t_idx.handle, myUserSlugs));
154313
154444
  const t_docs = vctx.sql.tables.appDocuments;
154314
154445
  const t_reads = vctx.sql.tables.directChannelReads;
154315
154446
  const limit = req2.pager?.limit ?? 50;
154316
154447
  const channelSlugs = channelRows.map((r) => r.channelUserSlug);
154317
154448
  const subq = vctx.sql.db.select({ ownerHandle: t_docs.ownerHandle, maxSeq: max12(t_docs.seq).as("maxSeq") }).from(t_docs).where(
154318
154449
  and194(
154319
- inArray59(t_docs.ownerHandle, channelSlugs),
154320
- eq226(t_docs.appSlug, "dm"),
154321
- eq226(t_docs.dbName, "messages"),
154322
- eq226(t_docs.deleted, 0)
154450
+ inArray60(t_docs.ownerHandle, channelSlugs),
154451
+ eq227(t_docs.appSlug, "dm"),
154452
+ eq227(t_docs.dbName, "messages"),
154453
+ eq227(t_docs.deleted, 0)
154323
154454
  )
154324
154455
  ).groupBy(t_docs.ownerHandle).as("latest");
154325
- const latestDocs = await vctx.sql.db.select().from(t_docs).innerJoin(subq, and194(eq226(t_docs.ownerHandle, subq.ownerHandle), eq226(t_docs.seq, subq.maxSeq)));
154456
+ const latestDocs = await vctx.sql.db.select().from(t_docs).innerJoin(subq, and194(eq227(t_docs.ownerHandle, subq.ownerHandle), eq227(t_docs.seq, subq.maxSeq)));
154326
154457
  const latestDocByChannel = new Map(latestDocs.map((row) => [row.AppDocuments.ownerHandle, row.AppDocuments]));
154327
- const readRows = await vctx.sql.db.select({ channelUserSlug: t_reads.channelHandle, lastSeenSeq: t_reads.lastSeenSeq }).from(t_reads).where(and194(inArray59(t_reads.channelHandle, channelSlugs), inArray59(t_reads.handle, myUserSlugs)));
154458
+ const readRows = await vctx.sql.db.select({ channelUserSlug: t_reads.channelHandle, lastSeenSeq: t_reads.lastSeenSeq }).from(t_reads).where(and194(inArray60(t_reads.channelHandle, channelSlugs), inArray60(t_reads.handle, myUserSlugs)));
154328
154459
  const lastSeenByChannel = new Map(readRows.map((r) => [r.channelUserSlug, r.lastSeenSeq]));
154329
154460
  const items = channelRows.map(({ channelUserSlug, ownerHandle: mySlug }) => {
154330
154461
  const otherUserSlug = (directChannelParticipants(channelUserSlug) ?? []).find((h) => h !== mySlug) ?? "";
@@ -154364,7 +154495,7 @@ var init_app_documents_dm_eventos = __esm({
154364
154495
  const userId = req2._auth.verifiedAuth.claims.userId;
154365
154496
  const participants = directChannelParticipants(req2.channelUserSlug) ?? ["", ""];
154366
154497
  const t_usb = vctx.sql.tables.handleBinding;
154367
- const slugRow = await vctx.sql.db.select({ handle: t_usb.handle }).from(t_usb).where(and194(eq226(t_usb.userId, userId), inArray59(t_usb.handle, participants))).then((r) => r[0]);
154498
+ const slugRow = await vctx.sql.db.select({ handle: t_usb.handle }).from(t_usb).where(and194(eq227(t_usb.userId, userId), inArray60(t_usb.handle, participants))).then((r) => r[0]);
154368
154499
  if (!slugRow) {
154369
154500
  await ctx.send.send(ctx, { type: "vibes.diy.res-error", error: { message: "Access denied" } });
154370
154501
  return Result317.Ok(EventoResult99.Continue);
@@ -154500,7 +154631,7 @@ var init_dm_read_eventos = __esm({
154500
154631
 
154501
154632
  // ../vibes.diy/api/svc/public/dm-write-eventos.ts
154502
154633
  import { EventoResult as EventoResult101, Result as Result319 } from "@adviser/cement";
154503
- import { and as and195, eq as eq227, inArray as inArray60, sql as sql36 } from "drizzle-orm";
154634
+ import { and as and195, eq as eq228, inArray as inArray61, sql as sql36 } from "drizzle-orm";
154504
154635
  function refusal4(denial) {
154505
154636
  switch (denial) {
154506
154637
  case "anonymous":
@@ -154520,7 +154651,7 @@ async function emitDmWriteEffects(vctx, p) {
154520
154651
  { handle: participants[1], channelHandle: ownerHandle }
154521
154652
  ]).onConflictDoNothing();
154522
154653
  const t_usb = vctx.sql.tables.handleBinding;
154523
- const senderRow = await vctx.sql.db.select({ handle: t_usb.handle }).from(t_usb).where(and195(eq227(t_usb.userId, userId ?? ""), inArray60(t_usb.handle, participants))).then((r) => r[0]);
154654
+ const senderRow = await vctx.sql.db.select({ handle: t_usb.handle }).from(t_usb).where(and195(eq228(t_usb.userId, userId ?? ""), inArray61(t_usb.handle, participants))).then((r) => r[0]);
154524
154655
  const senderUserSlug = senderRow?.handle ?? "";
154525
154656
  const recipientUserSlug = participants.find((h) => h !== senderUserSlug) ?? participants[1];
154526
154657
  await vctx.postQueue({
@@ -154667,10 +154798,10 @@ var init_dm_write_eventos = __esm({
154667
154798
  const dropSidecar = /* @__PURE__ */ __name(async (_seq, exec) => {
154668
154799
  await exec.delete(tOutputs).where(
154669
154800
  and195(
154670
- eq227(tOutputs.ownerHandle, req2.ownerHandle),
154671
- eq227(tOutputs.appSlug, req2.appSlug),
154672
- eq227(tOutputs.dbName, req2.dbName),
154673
- eq227(tOutputs.docId, req2.docId)
154801
+ eq228(tOutputs.ownerHandle, req2.ownerHandle),
154802
+ eq228(tOutputs.appSlug, req2.appSlug),
154803
+ eq228(tOutputs.dbName, req2.dbName),
154804
+ eq228(tOutputs.docId, req2.docId)
154674
154805
  )
154675
154806
  );
154676
154807
  orThrow(
@@ -154881,7 +155012,7 @@ var init_app_documents2 = __esm({
154881
155012
 
154882
155013
  // ../vibes.diy/api/svc/public/list-members.ts
154883
155014
  import { Result as Result321, Option as Option106, EventoResult as EventoResult103 } from "@adviser/cement";
154884
- import { eq as eq228, and as and196, inArray as inArray61, desc as desc48 } from "drizzle-orm";
155015
+ import { eq as eq229, and as and196, inArray as inArray62, desc as desc48 } from "drizzle-orm";
154885
155016
  import { type as type246 } from "arktype";
154886
155017
  function safeDisplay(foreignInfo, fallbackEmail, fallbackHandle) {
154887
155018
  const fi = foreignInfo;
@@ -154927,7 +155058,7 @@ var init_list_members = __esm({
154927
155058
  });
154928
155059
  return Result321.Ok(EventoResult103.Continue);
154929
155060
  }
154930
- const binding = await vctx.sql.db.select({ userId: vctx.sql.tables.handleBinding.userId }).from(vctx.sql.tables.handleBinding).where(eq228(vctx.sql.tables.handleBinding.handle, req2.ownerHandle)).limit(1).then((r) => r[0]);
155061
+ const binding = await vctx.sql.db.select({ userId: vctx.sql.tables.handleBinding.userId }).from(vctx.sql.tables.handleBinding).where(eq229(vctx.sql.tables.handleBinding.handle, req2.ownerHandle)).limit(1).then((r) => r[0]);
154931
155062
  if (!binding) {
154932
155063
  await ctx.send.send(ctx, {
154933
155064
  type: "vibes.diy.res-list-members",
@@ -154943,10 +155074,10 @@ var init_list_members = __esm({
154943
155074
  state: vctx.sql.tables.inviteGrants.state
154944
155075
  }).from(vctx.sql.tables.inviteGrants).where(
154945
155076
  and196(
154946
- eq228(vctx.sql.tables.inviteGrants.userId, ownerUserId),
154947
- eq228(vctx.sql.tables.inviteGrants.appSlug, req2.appSlug),
154948
- eq228(vctx.sql.tables.inviteGrants.ownerHandle, req2.ownerHandle),
154949
- eq228(vctx.sql.tables.inviteGrants.state, "accepted")
155077
+ eq229(vctx.sql.tables.inviteGrants.userId, ownerUserId),
155078
+ eq229(vctx.sql.tables.inviteGrants.appSlug, req2.appSlug),
155079
+ eq229(vctx.sql.tables.inviteGrants.ownerHandle, req2.ownerHandle),
155080
+ eq229(vctx.sql.tables.inviteGrants.state, "accepted")
154950
155081
  )
154951
155082
  );
154952
155083
  const requestRows = await vctx.sql.db.select({
@@ -154956,10 +155087,10 @@ var init_list_members = __esm({
154956
155087
  state: vctx.sql.tables.requestGrants.state
154957
155088
  }).from(vctx.sql.tables.requestGrants).where(
154958
155089
  and196(
154959
- eq228(vctx.sql.tables.requestGrants.userId, ownerUserId),
154960
- eq228(vctx.sql.tables.requestGrants.appSlug, req2.appSlug),
154961
- eq228(vctx.sql.tables.requestGrants.ownerHandle, req2.ownerHandle),
154962
- eq228(vctx.sql.tables.requestGrants.state, "approved")
155090
+ eq229(vctx.sql.tables.requestGrants.userId, ownerUserId),
155091
+ eq229(vctx.sql.tables.requestGrants.appSlug, req2.appSlug),
155092
+ eq229(vctx.sql.tables.requestGrants.ownerHandle, req2.ownerHandle),
155093
+ eq229(vctx.sql.tables.requestGrants.state, "approved")
154963
155094
  )
154964
155095
  );
154965
155096
  const requestUserIds = [
@@ -154968,7 +155099,7 @@ var init_list_members = __esm({
154968
155099
  const handleByUserId = /* @__PURE__ */ new Map();
154969
155100
  let heldHandles = /* @__PURE__ */ new Map();
154970
155101
  if (requestUserIds.length > 0) {
154971
- 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(inArray61(vctx.sql.tables.handleBinding.userId, requestUserIds)).orderBy(desc48(vctx.sql.tables.handleBinding.created));
155102
+ 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(inArray62(vctx.sql.tables.handleBinding.userId, requestUserIds)).orderBy(desc48(vctx.sql.tables.handleBinding.created));
154972
155103
  heldHandles = collectHeldHandles(handleRows);
154973
155104
  for (const row of handleRows) {
154974
155105
  if (!handleByUserId.has(row.userId)) handleByUserId.set(row.userId, row.handle);
@@ -155503,11 +155634,11 @@ var init_viewer_api_fetch2 = __esm({
155503
155634
 
155504
155635
  // ../vibes.diy/api/svc/public/profile-info.ts
155505
155636
  import { Result as Result324, Option as Option109, EventoResult as EventoResult106 } from "@adviser/cement";
155506
- import { eq as eq229 } from "drizzle-orm";
155637
+ import { eq as eq230 } from "drizzle-orm";
155507
155638
  async function resolveProfileInfo(vctx, args) {
155508
155639
  const handle = args.handle;
155509
155640
  const t = vctx.sql.tables.handleBinding;
155510
- const row = await vctx.sql.db.select({ handle: t.handle }).from(t).where(eq229(t.handle, handle)).limit(1).then((r) => r[0]);
155641
+ const row = await vctx.sql.db.select({ handle: t.handle }).from(t).where(eq230(t.handle, handle)).limit(1).then((r) => r[0]);
155511
155642
  if (row === void 0) return { handle: args.handle, exists: false };
155512
155643
  return { handle: args.handle, exists: true, private: await isHandlePrivate(vctx, handle) };
155513
155644
  }
@@ -155974,7 +156105,7 @@ var init_report_dates = __esm({
155974
156105
  // ../vibes.diy/api/svc/public/report-growth-memberships.ts
155975
156106
  import { Result as Result330, Option as Option115, EventoResult as EventoResult112 } from "@adviser/cement";
155976
156107
  import { type as type249 } from "arktype";
155977
- import { eq as eq230, inArray as inArray62 } from "drizzle-orm";
156108
+ import { eq as eq231, inArray as inArray63 } from "drizzle-orm";
155978
156109
  async function computeMemberships(vctx) {
155979
156110
  const t = vctx.sql.tables;
155980
156111
  const reqRows = await vctx.sql.db.select({
@@ -155982,13 +156113,13 @@ async function computeMemberships(vctx) {
155982
156113
  memberId: t.requestGrants.foreignUserId,
155983
156114
  ownerHandle: t.requestGrants.ownerHandle,
155984
156115
  appSlug: t.requestGrants.appSlug
155985
- }).from(t.requestGrants).where(eq230(t.requestGrants.state, "approved"));
156116
+ }).from(t.requestGrants).where(eq231(t.requestGrants.state, "approved"));
155986
156117
  const invRows = await vctx.sql.db.select({
155987
156118
  created: t.inviteGrants.created,
155988
156119
  memberId: t.inviteGrants.tokenOrGrantUserId,
155989
156120
  ownerHandle: t.inviteGrants.ownerHandle,
155990
156121
  appSlug: t.inviteGrants.appSlug
155991
- }).from(t.inviteGrants).where(eq230(t.inviteGrants.state, "accepted"));
156122
+ }).from(t.inviteGrants).where(eq231(t.inviteGrants.state, "accepted"));
155992
156123
  const earliest = /* @__PURE__ */ new Map();
155993
156124
  for (const r of [...reqRows, ...invRows]) {
155994
156125
  const key = `${r.memberId} ${r.ownerHandle} ${r.appSlug}`;
@@ -156018,7 +156149,7 @@ async function computeMemberships(vctx) {
156018
156149
  }
156019
156150
  const slugById = /* @__PURE__ */ new Map();
156020
156151
  if (memberIdsNeedingSlug.size > 0) {
156021
- const bindings = await vctx.sql.db.select({ userId: t.handleBinding.userId, ownerHandle: t.handleBinding.handle }).from(t.handleBinding).where(inArray62(t.handleBinding.userId, [...memberIdsNeedingSlug]));
156152
+ const bindings = await vctx.sql.db.select({ userId: t.handleBinding.userId, ownerHandle: t.handleBinding.handle }).from(t.handleBinding).where(inArray63(t.handleBinding.userId, [...memberIdsNeedingSlug]));
156022
156153
  for (const b of bindings) slugById.set(b.userId, b.ownerHandle);
156023
156154
  }
156024
156155
  const earliestList = [...earliest.values()].sort();
@@ -156748,7 +156879,7 @@ var init_report_top_vibes_by_traffic = __esm({
156748
156879
  // ../vibes.diy/api/svc/public/report-attribution-referrers.ts
156749
156880
  import { Result as Result336, Option as Option120, EventoResult as EventoResult117 } from "@adviser/cement";
156750
156881
  import { type as type254 } from "arktype";
156751
- import { sql as sql37, desc as desc49, eq as eq231, notInArray as notInArray10, and as and197, like as like8, notLike as notLike3, not as not4, gte as gte10 } from "drizzle-orm";
156882
+ import { sql as sql37, desc as desc49, eq as eq232, notInArray as notInArray10, and as and197, like as like8, notLike as notLike3, not as not4, gte as gte10 } from "drizzle-orm";
156752
156883
  function legacyVibePath(reqPath) {
156753
156884
  return and197(like8(reqPath, "/vibe/_%"), notLike3(reqPath, "/vibe/%/%"));
156754
156885
  }
@@ -156768,7 +156899,7 @@ async function computeAttributionReferrers(vctx, reqPathFilter, window2 = "all")
156768
156899
  reqPath: t.refererEvents.reqPath,
156769
156900
  total: sql37`cast(count(*) as int)`
156770
156901
  }).from(t.refererEvents).$dynamic();
156771
- const filtered = reqPathFilter !== void 0 ? baseQuery.where(and197(ownedFilter, notLegacyVibeFilter, windowFilter, eq231(t.refererEvents.reqPath, reqPathFilter))) : baseQuery.where(and197(ownedFilter, notLegacyVibeFilter, windowFilter));
156902
+ const filtered = reqPathFilter !== void 0 ? baseQuery.where(and197(ownedFilter, notLegacyVibeFilter, windowFilter, eq232(t.refererEvents.reqPath, reqPathFilter))) : baseQuery.where(and197(ownedFilter, notLegacyVibeFilter, windowFilter));
156772
156903
  const rows = await filtered.groupBy(t.refererEvents.refHost, t.refererEvents.refPath, t.refererEvents.reqPath).orderBy(desc49(sql37`count(*)`)).limit(100);
156773
156904
  const legacyVibeRows = reqPathFilter === void 0 ? await vctx.sql.db.select({
156774
156905
  reqPath: t.refererEvents.reqPath,
@@ -156846,7 +156977,7 @@ var init_report_attribution_referrers = __esm({
156846
156977
  // ../vibes.diy/api/svc/public/report-api-traffic.ts
156847
156978
  import { Result as Result337, Option as Option121, EventoResult as EventoResult118 } from "@adviser/cement";
156848
156979
  import { type as type255 } from "arktype";
156849
- import { sql as sql38, asc as asc20, desc as desc50, eq as eq232, and as and198, gte as gte11 } from "drizzle-orm";
156980
+ import { sql as sql38, asc as asc20, desc as desc50, eq as eq233, and as and198, gte as gte11 } from "drizzle-orm";
156850
156981
  function percentile(sortedAsc, p) {
156851
156982
  if (sortedAsc.length === 0) return 0;
156852
156983
  const rank = Math.ceil(p / 100 * sortedAsc.length);
@@ -156923,7 +157054,7 @@ async function computeApiTraffic(vctx, hostFilter) {
156923
157054
  const t = vctx.sql.tables;
156924
157055
  const cutoff = new Date(Date.now() - WINDOW_DAYS2 * 24 * 60 * 60 * 1e3).toISOString();
156925
157056
  const windowFilter = gte11(t.apiRequestEvents.ts, cutoff);
156926
- const where = hostFilter !== void 0 ? and198(windowFilter, eq232(t.apiRequestEvents.host, hostFilter)) : windowFilter;
157057
+ const where = hostFilter !== void 0 ? and198(windowFilter, eq233(t.apiRequestEvents.host, hostFilter)) : windowFilter;
156927
157058
  const dayExpr = sql38`substr(${t.apiRequestEvents.ts}, 1, 10)`;
156928
157059
  const perDay = await vctx.sql.db.select({
156929
157060
  day: dayExpr,
@@ -157004,7 +157135,7 @@ var init_report_api_traffic = __esm({
157004
157135
  // ../vibes.diy/api/svc/public/report-egress.ts
157005
157136
  import { Result as Result338, Option as Option122, EventoResult as EventoResult119 } from "@adviser/cement";
157006
157137
  import { type as type256 } from "arktype";
157007
- import { sql as sql39, asc as asc21, desc as desc51, eq as eq233, and as and199, or as or24, gte as gte12 } from "drizzle-orm";
157138
+ import { sql as sql39, asc as asc21, desc as desc51, eq as eq234, and as and199, or as or24, gte as gte12 } from "drizzle-orm";
157008
157139
  function aggregateEgress(rows) {
157009
157140
  const hosts = /* @__PURE__ */ new Map();
157010
157141
  const vibes = /* @__PURE__ */ new Map();
@@ -157073,7 +157204,7 @@ async function computeEgress(vctx, hostFilter) {
157073
157204
  const t = vctx.sql.tables;
157074
157205
  const cutoff = new Date(Date.now() - WINDOW_DAYS3 * 24 * 60 * 60 * 1e3).toISOString();
157075
157206
  const windowFilter = gte12(t.egressEvents.ts, cutoff);
157076
- const where = hostFilter !== void 0 ? and199(windowFilter, or24(eq233(t.egressEvents.host, hostFilter), eq233(t.egressEvents.finalHost, hostFilter))) : windowFilter;
157207
+ const where = hostFilter !== void 0 ? and199(windowFilter, or24(eq234(t.egressEvents.host, hostFilter), eq234(t.egressEvents.finalHost, hostFilter))) : windowFilter;
157077
157208
  const sample = await vctx.sql.db.select({
157078
157209
  host: t.egressEvents.host,
157079
157210
  finalHost: t.egressEvents.finalHost,
@@ -157086,7 +157217,7 @@ async function computeEgress(vctx, hostFilter) {
157086
157217
  ts: t.egressEvents.ts
157087
157218
  }).from(t.egressEvents).where(where).orderBy(desc51(t.egressEvents.ts)).limit(SAMPLE_ROW_CAP2);
157088
157219
  const suspectWindow = gte12(t.egressSuspectEvents.ts, cutoff);
157089
- const suspectWhere = hostFilter !== void 0 ? and199(suspectWindow, eq233(t.egressSuspectEvents.host, hostFilter)) : suspectWindow;
157220
+ const suspectWhere = hostFilter !== void 0 ? and199(suspectWindow, eq234(t.egressSuspectEvents.host, hostFilter)) : suspectWindow;
157090
157221
  const suspects = await vctx.sql.db.select({
157091
157222
  host: t.egressSuspectEvents.host,
157092
157223
  ownerHandle: t.egressSuspectEvents.ownerHandle,
@@ -157164,7 +157295,7 @@ var init_report_egress = __esm({
157164
157295
  // ../vibes.diy/api/svc/public/report-prompt-cache.ts
157165
157296
  import { Result as Result339, Option as Option123, EventoResult as EventoResult120, exception2Result as exception2Result351 } from "@adviser/cement";
157166
157297
  import { type as type257 } from "arktype";
157167
- import { asc as asc22, eq as eq234, gte as gte13 } from "drizzle-orm";
157298
+ import { asc as asc22, eq as eq235, gte as gte13 } from "drizzle-orm";
157168
157299
  function summarizeUsageGiven(ref) {
157169
157300
  const num4 = /* @__PURE__ */ __name((v) => {
157170
157301
  if (typeof v === "number") return Number.isFinite(v) ? v : void 0;
@@ -157280,7 +157411,7 @@ async function loadJournalCreatedByChat(vctx) {
157280
157411
  created: t.openTurns.created,
157281
157412
  value: t.openTurns.agentSession,
157282
157413
  revision: t.openTurns.agentSessionRevision
157283
- }).from(t.openTurns).where(eq234(t.openTurns.promptId, AGENT_SESSION_RECORD_ID)).limit(JOURNAL_ROW_CAP);
157414
+ }).from(t.openTurns).where(eq235(t.openTurns.promptId, AGENT_SESSION_RECORD_ID)).limit(JOURNAL_ROW_CAP);
157284
157415
  const byChat = /* @__PURE__ */ new Map();
157285
157416
  const parsed = [];
157286
157417
  for (const row of rows) {
@@ -158209,7 +158340,7 @@ var init_campaign_health_readout_source = __esm({
158209
158340
  // ../vibes.diy/api/svc/public/report-campaign-health.ts
158210
158341
  import { Result as Result341, Option as Option124, EventoResult as EventoResult121, exception2Result as exception2Result353 } from "@adviser/cement";
158211
158342
  import { type as type258 } from "arktype";
158212
- import { and as and200, eq as eq235, gte as gte14, lte as lte8 } from "drizzle-orm";
158343
+ import { and as and200, eq as eq236, gte as gte14, lte as lte8 } from "drizzle-orm";
158213
158344
  async function metaGet(path2, token) {
158214
158345
  return metaGraphGet((input, init) => fetch(input, init), path2, token);
158215
158346
  }
@@ -158234,7 +158365,7 @@ function goodVibesLandingPath(websiteUrl) {
158234
158365
  async function fetchGoodVibesClickThroughs(vctx, sinceIso, untilIso) {
158235
158366
  const t = vctx.sql.tables;
158236
158367
  const rows = await vctx.sql.db.select({ refPath: t.refererEvents.refPath, refHref: t.refererEvents.refHref }).from(t.refererEvents).where(
158237
- and200(eq235(t.refererEvents.refHost, "good.vibes.diy"), gte14(t.refererEvents.ts, sinceIso), lte8(t.refererEvents.ts, untilIso))
158368
+ and200(eq236(t.refererEvents.refHost, "good.vibes.diy"), gte14(t.refererEvents.ts, sinceIso), lte8(t.refererEvents.ts, untilIso))
158238
158369
  );
158239
158370
  const byPath = /* @__PURE__ */ Object.create(null);
158240
158371
  const byCampaignId = /* @__PURE__ */ Object.create(null);
@@ -158771,7 +158902,7 @@ var init_prompt_turn_sql = __esm({
158771
158902
  // ../vibes.diy/api/svc/public/report-activity.ts
158772
158903
  import { Result as Result345, Option as Option126, EventoResult as EventoResult123 } from "@adviser/cement";
158773
158904
  import { type as type261 } from "arktype";
158774
- import { and as and201, gte as gte15, inArray as inArray63, lt as lt20, max as max13, min, sql as sql40 } from "drizzle-orm";
158905
+ import { and as and201, gte as gte15, inArray as inArray64, lt as lt20, max as max13, min, sql as sql40 } from "drizzle-orm";
158775
158906
  function turnFilter(vctx) {
158776
158907
  const t = vctx.sql.tables;
158777
158908
  return and201(gte15(t.promptContexts.totalTokens, MIN_TURN_TOKENS), sql40.raw(promptBuildTurnSql(vctx.sql.flavour)));
@@ -158876,7 +159007,7 @@ async function computeActivity(vctx, days) {
158876
159007
  ownerHandle: t.signupAttributions.ownerHandle,
158877
159008
  appSlug: t.signupAttributions.appSlug,
158878
159009
  entryKind: t.signupAttributions.entryKind
158879
- }).from(t.signupAttributions).where(inArray63(t.signupAttributions.userId, signupUserIds));
159010
+ }).from(t.signupAttributions).where(inArray64(t.signupAttributions.userId, signupUserIds));
158880
159011
  for (const a of attributions) viaByUserId.set(a.userId, `${a.ownerHandle}/${a.appSlug} (${a.entryKind})`);
158881
159012
  }
158882
159013
  const accountDays = /* @__PURE__ */ new Map();
@@ -158917,7 +159048,7 @@ async function computeActivity(vctx, days) {
158917
159048
  const ownerUserIdByHandle = /* @__PURE__ */ new Map();
158918
159049
  const handlesByUserId = /* @__PURE__ */ new Map();
158919
159050
  if (ownerHandles.size > 0) {
158920
- const bindings = await vctx.sql.db.select({ userId: t.handleBinding.userId, handle: t.handleBinding.handle }).from(t.handleBinding).where(inArray63(t.handleBinding.handle, [...ownerHandles]));
159051
+ const bindings = await vctx.sql.db.select({ userId: t.handleBinding.userId, handle: t.handleBinding.handle }).from(t.handleBinding).where(inArray64(t.handleBinding.handle, [...ownerHandles]));
158921
159052
  for (const b of bindings) ownerUserIdByHandle.set(b.handle, b.userId);
158922
159053
  }
158923
159054
  const buckets = /* @__PURE__ */ new Map();
@@ -158960,13 +159091,13 @@ async function computeActivity(vctx, days) {
158960
159091
  for (const accounts of accountDays.values()) for (const userId of accounts.keys()) eventUserIds.add(userId);
158961
159092
  const accountsToResolve = /* @__PURE__ */ new Set([...writerUserIds, ...ownerUserIdByHandle.values(), ...eventUserIds]);
158962
159093
  if (accountsToResolve.size > 0) {
158963
- const bindings = await vctx.sql.db.select({ userId: t.handleBinding.userId, handle: t.handleBinding.handle }).from(t.handleBinding).where(inArray63(t.handleBinding.userId, [...accountsToResolve]));
159094
+ const bindings = await vctx.sql.db.select({ userId: t.handleBinding.userId, handle: t.handleBinding.handle }).from(t.handleBinding).where(inArray64(t.handleBinding.userId, [...accountsToResolve]));
158964
159095
  for (const b of bindings) {
158965
159096
  const prev = handleByWriterId.get(b.userId);
158966
159097
  if (prev === void 0 || b.handle < prev) handleByWriterId.set(b.userId, b.handle);
158967
159098
  addHandle(handlesByUserId, b.userId, b.handle);
158968
159099
  }
158969
- const settings = await vctx.sql.db.select({ userId: t.userSettings.userId, settings: t.userSettings.settings, created: t.userSettings.created }).from(t.userSettings).where(inArray63(t.userSettings.userId, [...accountsToResolve]));
159100
+ const settings = await vctx.sql.db.select({ userId: t.userSettings.userId, settings: t.userSettings.settings, created: t.userSettings.created }).from(t.userSettings).where(inArray64(t.userSettings.userId, [...accountsToResolve]));
158970
159101
  for (const r of settings) {
158971
159102
  noteFirstSeen(r.userId, r.created);
158972
159103
  if (!Array.isArray(r.settings)) continue;
@@ -158976,15 +159107,15 @@ async function computeActivity(vctx, days) {
158976
159107
  }
158977
159108
  const rowUserIds = [.../* @__PURE__ */ new Set([...ownerUserIdByHandle.values(), ...eventUserIds])].filter((u) => u !== ANONYMOUS_USER_ID);
158978
159109
  if (rowUserIds.length > 0) {
158979
- const turnRow = and201(inArray63(t.promptContexts.userId, rowUserIds), turnFilter(vctx));
159110
+ const turnRow = and201(inArray64(t.promptContexts.userId, rowUserIds), turnFilter(vctx));
158980
159111
  const [turnSpans, firstApps, lastApps] = await Promise.all([
158981
159112
  vctx.sql.db.select({
158982
159113
  userId: t.promptContexts.userId,
158983
159114
  first: min(t.promptContexts.created),
158984
159115
  lastBefore: sql40`max(case when ${t.promptContexts.created} < ${since} then ${t.promptContexts.created} end)`
158985
159116
  }).from(t.promptContexts).where(turnRow).groupBy(t.promptContexts.userId),
158986
- vctx.sql.db.select({ userId: t.apps.userId, at: min(t.apps.created) }).from(t.apps).where(inArray63(t.apps.userId, rowUserIds)).groupBy(t.apps.userId),
158987
- vctx.sql.db.select({ userId: t.apps.userId, at: max13(t.apps.created) }).from(t.apps).where(and201(inArray63(t.apps.userId, rowUserIds), lt20(t.apps.created, since))).groupBy(t.apps.userId)
159117
+ vctx.sql.db.select({ userId: t.apps.userId, at: min(t.apps.created) }).from(t.apps).where(inArray64(t.apps.userId, rowUserIds)).groupBy(t.apps.userId),
159118
+ vctx.sql.db.select({ userId: t.apps.userId, at: max13(t.apps.created) }).from(t.apps).where(and201(inArray64(t.apps.userId, rowUserIds), lt20(t.apps.created, since))).groupBy(t.apps.userId)
158988
159119
  ]);
158989
159120
  const firstTurns = turnSpans.map((r) => ({ userId: r.userId, at: r.first }));
158990
159121
  const lastTurns = turnSpans.map((r) => ({ userId: r.userId, at: r.lastBefore }));
@@ -159236,7 +159367,7 @@ var init_report_activity = __esm({
159236
159367
  import { Result as Result346, Option as Option127, EventoResult as EventoResult124 } from "@adviser/cement";
159237
159368
  import { type as type262 } from "arktype";
159238
159369
  import { sql as sql41 } from "drizzle-orm";
159239
- import { and as and202, asc as asc23, desc as desc52, eq as eq236 } from "drizzle-orm/sql/expressions";
159370
+ import { and as and202, asc as asc23, desc as desc52, eq as eq237 } from "drizzle-orm/sql/expressions";
159240
159371
  async function computeHomeLeaderboard(vctx, limit) {
159241
159372
  const docs = vctx.sql.tables.appDocuments;
159242
159373
  const asb = vctx.sql.tables.appSlugBinding;
@@ -159245,7 +159376,7 @@ async function computeHomeLeaderboard(vctx, limit) {
159245
159376
  ownerHandle: docs.ownerHandle,
159246
159377
  appSlug: docs.appSlug,
159247
159378
  writerCount
159248
- }).from(docs).innerJoin(asb, and202(eq236(asb.ownerHandle, docs.ownerHandle), eq236(asb.appSlug, docs.appSlug), eq236(asb.unpublishedAt, ""))).groupBy(docs.ownerHandle, docs.appSlug).orderBy(desc52(writerCount), asc23(docs.ownerHandle), asc23(docs.appSlug)).limit(limit * HOME_FEED_SCAN_FACTOR);
159379
+ }).from(docs).innerJoin(asb, and202(eq237(asb.ownerHandle, docs.ownerHandle), eq237(asb.appSlug, docs.appSlug), eq237(asb.unpublishedAt, ""))).groupBy(docs.ownerHandle, docs.appSlug).orderBy(desc52(writerCount), asc23(docs.ownerHandle), asc23(docs.appSlug)).limit(limit * HOME_FEED_SCAN_FACTOR);
159249
159380
  const display = await loadVibeDisplayInfo(vctx, candidates);
159250
159381
  const facts = await loadNewestReleaseFacts(vctx, candidates);
159251
159382
  const family = createFamilyAdmitter();
@@ -159315,7 +159446,7 @@ var init_home_leaderboard = __esm({
159315
159446
  // ../vibes.diy/api/svc/intern/curation-starter.ts
159316
159447
  import { exception2Result as exception2Result357, Result as Result347 } from "@adviser/cement";
159317
159448
  import { type as type263 } from "arktype";
159318
- import { and as and203, eq as eq237 } from "drizzle-orm/sql/expressions";
159449
+ import { and as and203, eq as eq238 } from "drizzle-orm/sql/expressions";
159319
159450
  function curationStarterMessages(input) {
159320
159451
  const title = input.title?.trim();
159321
159452
  const lines = [...title === void 0 || title === "" ? [] : [`<title>${title}</title>`], `<slug>${input.appSlug}</slug>`];
@@ -159384,7 +159515,7 @@ async function fillCurationStarter(vctx, pair, llm = curationStarterLlm(vctx)) {
159384
159515
  try {
159385
159516
  const t = vctx.sql.tables.vibeCuration;
159386
159517
  const rRow = await exception2Result357(
159387
- () => vctx.sql.db.select({ state: t.state, starter: t.starter }).from(t).where(and203(eq237(t.ownerHandle, pair.ownerHandle), eq237(t.appSlug, pair.appSlug))).limit(1).then((r) => r[0])
159518
+ () => vctx.sql.db.select({ state: t.state, starter: t.starter }).from(t).where(and203(eq238(t.ownerHandle, pair.ownerHandle), eq238(t.appSlug, pair.appSlug))).limit(1).then((r) => r[0])
159388
159519
  );
159389
159520
  if (rRow.isErr()) {
159390
159521
  vctx.logger.Warn().Str("vibe", key).Err(rRow.Err()).Msg("curation-starter-read-failed");
@@ -159401,7 +159532,7 @@ async function fillCurationStarter(vctx, pair, llm = curationStarterLlm(vctx)) {
159401
159532
  }
159402
159533
  const starter = rStarter.Ok();
159403
159534
  const rWrite = await exception2Result357(
159404
- () => vctx.sql.db.update(t).set({ starter }).where(and203(eq237(t.ownerHandle, pair.ownerHandle), eq237(t.appSlug, pair.appSlug), eq237(t.state, "approved"), eq237(t.starter, "")))
159535
+ () => vctx.sql.db.update(t).set({ starter }).where(and203(eq238(t.ownerHandle, pair.ownerHandle), eq238(t.appSlug, pair.appSlug), eq238(t.state, "approved"), eq238(t.starter, "")))
159405
159536
  );
159406
159537
  if (rWrite.isErr()) {
159407
159538
  vctx.logger.Warn().Str("vibe", key).Err(rWrite.Err()).Msg("curation-starter-write-failed");
@@ -159467,7 +159598,7 @@ var init_curation_starter = __esm({
159467
159598
  // ../vibes.diy/api/svc/public/curated-new-vibes.ts
159468
159599
  import { Result as Result348, Option as Option128, EventoResult as EventoResult125 } from "@adviser/cement";
159469
159600
  import { type as type264 } from "arktype";
159470
- import { and as and204, desc as desc53, eq as eq238 } from "drizzle-orm/sql/expressions";
159601
+ import { and as and204, desc as desc53, eq as eq239 } from "drizzle-orm/sql/expressions";
159471
159602
  async function computeCuratedNewVibes(vctx, limit) {
159472
159603
  const cur = vctx.sql.tables.vibeCuration;
159473
159604
  const asb = vctx.sql.tables.appSlugBinding;
@@ -159477,7 +159608,7 @@ async function computeCuratedNewVibes(vctx, limit) {
159477
159608
  created: asb.created,
159478
159609
  approvedAt: cur.decidedAt,
159479
159610
  starter: cur.starter
159480
- }).from(cur).innerJoin(asb, and204(eq238(asb.ownerHandle, cur.ownerHandle), eq238(asb.appSlug, cur.appSlug), eq238(asb.unpublishedAt, ""))).where(eq238(cur.state, "approved")).orderBy(desc53(cur.decidedAt), desc53(cur.ownerHandle), desc53(cur.appSlug)).limit(limit * HOME_FEED_SCAN_FACTOR);
159611
+ }).from(cur).innerJoin(asb, and204(eq239(asb.ownerHandle, cur.ownerHandle), eq239(asb.appSlug, cur.appSlug), eq239(asb.unpublishedAt, ""))).where(eq239(cur.state, "approved")).orderBy(desc53(cur.decidedAt), desc53(cur.ownerHandle), desc53(cur.appSlug)).limit(limit * HOME_FEED_SCAN_FACTOR);
159481
159612
  const display = await loadVibeDisplayInfo(vctx, candidates);
159482
159613
  const facts = await loadNewestReleaseFacts(vctx, candidates);
159483
159614
  const family = createFamilyAdmitter();
@@ -159557,7 +159688,7 @@ var init_curated_new_vibes = __esm({
159557
159688
  // ../vibes.diy/api/svc/public/handle-profile-vibes.ts
159558
159689
  import { Result as Result349, Option as Option129, EventoResult as EventoResult126 } from "@adviser/cement";
159559
159690
  import { type as type265 } from "arktype";
159560
- import { and as and205, asc as asc24, desc as desc54, eq as eq239 } from "drizzle-orm/sql/expressions";
159691
+ import { and as and205, asc as asc24, desc as desc54, eq as eq240 } from "drizzle-orm/sql/expressions";
159561
159692
  async function computeHandleProfileVibes(vctx, ownerHandle, limit) {
159562
159693
  const asb = vctx.sql.tables.appSlugBinding;
159563
159694
  const batchSize = limit * HOME_FEED_SCAN_FACTOR;
@@ -159571,7 +159702,7 @@ async function computeHandleProfileVibes(vctx, ownerHandle, limit) {
159571
159702
  created: asb.created,
159572
159703
  updated: asb.updated,
159573
159704
  pinnedAt: asb.pinnedAt
159574
- }).from(asb).where(and205(eq239(asb.ownerHandle, ownerHandle), eq239(asb.unpublishedAt, ""))).orderBy(desc54(asb.pinnedAt), desc54(asb.updated), asc24(asb.appSlug)).limit(take).offset(examined);
159705
+ }).from(asb).where(and205(eq240(asb.ownerHandle, ownerHandle), eq240(asb.unpublishedAt, ""))).orderBy(desc54(asb.pinnedAt), desc54(asb.updated), asc24(asb.appSlug)).limit(take).offset(examined);
159575
159706
  examined += candidates.length;
159576
159707
  const display = await loadVibeDisplayInfo(vctx, candidates);
159577
159708
  for (const row of candidates) {
@@ -159725,7 +159856,7 @@ var init_curate_approve = __esm({
159725
159856
  import { Result as Result351, Option as Option131, EventoResult as EventoResult128 } from "@adviser/cement";
159726
159857
  import { type as type267 } from "arktype";
159727
159858
  import { cosineDistance as cosineDistance2, sql as sql42 } from "drizzle-orm";
159728
- import { and as and206, asc as asc25, desc as desc55, eq as eq240, notInArray as notInArray11, notLike as notLike4, or as or25 } from "drizzle-orm/sql/expressions";
159859
+ import { and as and206, asc as asc25, desc as desc55, eq as eq241, notInArray as notInArray11, notLike as notLike4, or as or25 } from "drizzle-orm/sql/expressions";
159729
159860
  async function computeRelatedVibes(vctx, { ownerHandle, appSlug, isOwner }) {
159730
159861
  const docs = vctx.sql.tables.appDocuments;
159731
159862
  const asb = vctx.sql.tables.appSlugBinding;
@@ -159779,7 +159910,7 @@ async function computeRelatedVibes(vctx, { ownerHandle, appSlug, isOwner }) {
159779
159910
  });
159780
159911
  }
159781
159912
  const writerCount = sql42`cast(count(distinct ${docs.userId}) as int)`;
159782
- const ownerCandidates = await vctx.sql.db.select({ ownerHandle: docs.ownerHandle, appSlug: docs.appSlug, writerCount }).from(docs).innerJoin(asb, and206(eq240(asb.ownerHandle, docs.ownerHandle), eq240(asb.appSlug, docs.appSlug), eq240(asb.unpublishedAt, ""))).where(eq240(docs.ownerHandle, ownerHandle)).groupBy(docs.ownerHandle, docs.appSlug).orderBy(desc55(writerCount), asc25(docs.appSlug)).limit(OWNER_TOP_LIMIT * HOME_FEED_SCAN_FACTOR);
159913
+ const ownerCandidates = await vctx.sql.db.select({ ownerHandle: docs.ownerHandle, appSlug: docs.appSlug, writerCount }).from(docs).innerJoin(asb, and206(eq241(asb.ownerHandle, docs.ownerHandle), eq241(asb.appSlug, docs.appSlug), eq241(asb.unpublishedAt, ""))).where(eq241(docs.ownerHandle, ownerHandle)).groupBy(docs.ownerHandle, docs.appSlug).orderBy(desc55(writerCount), asc25(docs.appSlug)).limit(OWNER_TOP_LIMIT * HOME_FEED_SCAN_FACTOR);
159783
159914
  const ownerPairs = ownerCandidates.filter(
159784
159915
  (c) => !isCurrent(c.ownerHandle, c.appSlug) && !maskedKeys.has(titleIconKey(c.ownerHandle, c.appSlug))
159785
159916
  );
@@ -159803,19 +159934,19 @@ async function computeRelatedVibes(vctx, { ownerHandle, appSlug, isOwner }) {
159803
159934
  if (sourceVisible === false) {
159804
159935
  const sourceWorldReadable = deriveIsWorldReadable(entries, ownerUserId);
159805
159936
  if (sourceWorldReadable) {
159806
- const pubRows = await vctx.sql.db.select({ unpublishedAt: asb.unpublishedAt }).from(asb).where(and206(eq240(asb.ownerHandle, ownerHandle), eq240(asb.appSlug, appSlug))).limit(1);
159937
+ const pubRows = await vctx.sql.db.select({ unpublishedAt: asb.unpublishedAt }).from(asb).where(and206(eq241(asb.ownerHandle, ownerHandle), eq241(asb.appSlug, appSlug))).limit(1);
159807
159938
  sourceVisible = pubRows[0]?.unpublishedAt === "";
159808
159939
  }
159809
159940
  }
159810
159941
  if (vctx.sql.flavour === "pg" && sourceVisible) {
159811
159942
  const emb = vctx.sql.tables.appFirstMessageEmbeddings;
159812
- const selfRows = await vctx.sql.db.select({ embedding: emb.embedding }).from(emb).where(and206(eq240(emb.ownerHandle, ownerHandle), eq240(emb.appSlug, appSlug))).limit(1);
159943
+ const selfRows = await vctx.sql.db.select({ embedding: emb.embedding }).from(emb).where(and206(eq241(emb.ownerHandle, ownerHandle), eq241(emb.appSlug, appSlug))).limit(1);
159813
159944
  const selfVec = selfRows[0]?.embedding;
159814
159945
  if (selfVec !== void 0 && selfVec.length > 0) {
159815
159946
  const distance = cosineDistance2(emb.embedding, selfVec);
159816
159947
  const hiddenElsewhere = TEAM_TEST_HANDLES.filter((h) => h !== ownerHandle);
159817
- const notFamily = /* @__PURE__ */ __name((prefix) => or25(eq240(emb.ownerHandle, ownerHandle), notLike4(emb.ownerHandle, `${prefix}%`)), "notFamily");
159818
- const neighborRows = await vctx.sql.db.select({ ownerHandle: emb.ownerHandle, appSlug: emb.appSlug }).from(emb).innerJoin(asb, and206(eq240(asb.ownerHandle, emb.ownerHandle), eq240(asb.appSlug, emb.appSlug), eq240(asb.unpublishedAt, ""))).where(
159948
+ const notFamily = /* @__PURE__ */ __name((prefix) => or25(eq241(emb.ownerHandle, ownerHandle), notLike4(emb.ownerHandle, `${prefix}%`)), "notFamily");
159949
+ const neighborRows = await vctx.sql.db.select({ ownerHandle: emb.ownerHandle, appSlug: emb.appSlug }).from(emb).innerJoin(asb, and206(eq241(asb.ownerHandle, emb.ownerHandle), eq241(asb.appSlug, emb.appSlug), eq241(asb.unpublishedAt, ""))).where(
159819
159950
  and206(
159820
159951
  sql42`not (${emb.ownerHandle} = ${ownerHandle} and ${emb.appSlug} = ${appSlug})`,
159821
159952
  // The test-handle drop runs in the query, ahead of the over-fetch
@@ -159932,7 +160063,7 @@ var init_related_vibes2 = __esm({
159932
160063
  let isOwner = false;
159933
160064
  if (userId) {
159934
160065
  const usb = vctx.sql.tables.handleBinding;
159935
- const rows = await vctx.sql.db.select({ userId: usb.userId }).from(usb).where(eq240(usb.handle, req2.ownerHandle)).limit(1);
160066
+ const rows = await vctx.sql.db.select({ userId: usb.userId }).from(usb).where(eq241(usb.handle, req2.ownerHandle)).limit(1);
159936
160067
  isOwner = rows[0]?.userId === userId;
159937
160068
  }
159938
160069
  const res = isOwner ? await computeRelatedVibes(vctx, { ownerHandle: req2.ownerHandle, appSlug: req2.appSlug, isOwner: true }) : await cachedReport({
@@ -161271,7 +161402,7 @@ var init_notify_remix = __esm({
161271
161402
  });
161272
161403
 
161273
161404
  // ../vibes.diy/api/svc/intern/notify-remix-clone.ts
161274
- import { and as and207, desc as desc56, eq as eq241 } from "drizzle-orm/sql/expressions";
161405
+ import { and as and207, desc as desc56, eq as eq242 } from "drizzle-orm/sql/expressions";
161275
161406
  var init_notify_remix_clone = __esm({
161276
161407
  "../vibes.diy/api/svc/intern/notify-remix-clone.ts"() {
161277
161408
  "use strict";
@@ -161280,7 +161411,7 @@ var init_notify_remix_clone = __esm({
161280
161411
  });
161281
161412
 
161282
161413
  // ../vibes.diy/api/svc/intern/notify-vibe-published.ts
161283
- import { eq as eq242 } from "drizzle-orm/sql/expressions";
161414
+ import { eq as eq243 } from "drizzle-orm/sql/expressions";
161284
161415
  var init_notify_vibe_published = __esm({
161285
161416
  "../vibes.diy/api/svc/intern/notify-vibe-published.ts"() {
161286
161417
  "use strict";
@@ -161289,7 +161420,7 @@ var init_notify_vibe_published = __esm({
161289
161420
  });
161290
161421
 
161291
161422
  // ../vibes.diy/api/svc/intern/notify-comment-posted.ts
161292
- import { and as and208, eq as eq243 } from "drizzle-orm/sql/expressions";
161423
+ import { and as and208, eq as eq244 } from "drizzle-orm/sql/expressions";
161293
161424
  function commentQuote(text3, max14 = COMMENT_QUOTE_MAX) {
161294
161425
  const flat = text3.replace(/\s+/g, " ").trim();
161295
161426
  if (flat.length <= max14) return flat;
@@ -161301,11 +161432,11 @@ async function loadComment(qctx, payload) {
161301
161432
  const d = qctx.sql.tables.appDocuments;
161302
161433
  const row = await qctx.sql.db.select({ data: d.data }).from(d).where(
161303
161434
  and208(
161304
- eq243(d.ownerHandle, payload.ownerHandle),
161305
- eq243(d.appSlug, payload.appSlug),
161306
- eq243(d.dbName, COMMENTS_DB_NAME),
161307
- eq243(d.docId, payload.docId),
161308
- eq243(d.seq, 1)
161435
+ eq244(d.ownerHandle, payload.ownerHandle),
161436
+ eq244(d.appSlug, payload.appSlug),
161437
+ eq244(d.dbName, COMMENTS_DB_NAME),
161438
+ eq244(d.docId, payload.docId),
161439
+ eq244(d.seq, 1)
161309
161440
  )
161310
161441
  ).limit(1).then((r) => r[0]).catch(() => void 0);
161311
161442
  const data = typeof row?.data === "string" ? safeJson(row.data) : row?.data;
@@ -161328,7 +161459,7 @@ function commentBody(p) {
161328
161459
  }
161329
161460
  async function notifyCommentPosted(qctx, payload) {
161330
161461
  const usb = qctx.sql.tables.handleBinding;
161331
- const ownerRow = await qctx.sql.db.select({ userId: usb.userId }).from(usb).where(eq243(usb.handle, payload.ownerHandle)).limit(1).then((r) => r[0] ?? null);
161462
+ const ownerRow = await qctx.sql.db.select({ userId: usb.userId }).from(usb).where(eq244(usb.handle, payload.ownerHandle)).limit(1).then((r) => r[0] ?? null);
161332
161463
  if (!ownerRow?.userId) return;
161333
161464
  const comment = await loadComment(qctx, payload);
161334
161465
  await emitNotification(qctx, {
@@ -161411,21 +161542,21 @@ var init_notify_member_joined = __esm({
161411
161542
  });
161412
161543
 
161413
161544
  // ../vibes.diy/api/svc/intern/notify-request-pending.ts
161414
- import { and as and209, eq as eq244, gt as gt20, desc as desc57 } from "drizzle-orm/sql/expressions";
161545
+ import { and as and209, eq as eq245, gt as gt20, desc as desc57 } from "drizzle-orm/sql/expressions";
161415
161546
  async function notifyRequestPending(qctx, input) {
161416
161547
  if (input.requesterUserId === input.ownerUserId) return;
161417
161548
  const g = qctx.sql.tables.requestGrants;
161418
- const grantRow = await qctx.sql.db.select({ state: g.state }).from(g).where(and209(eq244(g.foreignUserId, input.requesterUserId), eq244(g.appSlug, input.appSlug), eq244(g.ownerHandle, input.ownerHandle))).limit(1).then((r) => r[0]);
161549
+ const grantRow = await qctx.sql.db.select({ state: g.state }).from(g).where(and209(eq245(g.foreignUserId, input.requesterUserId), eq245(g.appSlug, input.appSlug), eq245(g.ownerHandle, input.ownerHandle))).limit(1).then((r) => r[0]);
161419
161550
  if (grantRow?.state !== "pending") return;
161420
161551
  const t = qctx.sql.tables.notifications;
161421
161552
  const cutoff = new Date(Date.now() - REQUEST_NOTIFY_REARM_MS).toISOString();
161422
161553
  const recent = await qctx.sql.db.select({ id: t.id }).from(t).where(
161423
161554
  and209(
161424
- eq244(t.userId, input.ownerUserId),
161425
- eq244(t.ownerHandle, input.ownerHandle),
161426
- eq244(t.appSlug, input.appSlug),
161427
- eq244(t.notificationType, "access-requested"),
161428
- eq244(t.actorUserId, input.requesterUserId),
161555
+ eq245(t.userId, input.ownerUserId),
161556
+ eq245(t.ownerHandle, input.ownerHandle),
161557
+ eq245(t.appSlug, input.appSlug),
161558
+ eq245(t.notificationType, "access-requested"),
161559
+ eq245(t.actorUserId, input.requesterUserId),
161429
161560
  gt20(t.created, cutoff)
161430
161561
  )
161431
161562
  ).orderBy(desc57(t.created)).limit(1).then((r) => r[0]);
@@ -161453,7 +161584,7 @@ var init_notify_request_pending = __esm({
161453
161584
  });
161454
161585
 
161455
161586
  // ../vibes.diy/api/svc/intern/notify-dm-received.ts
161456
- import { eq as eq245 } from "drizzle-orm/sql/expressions";
161587
+ import { eq as eq246 } from "drizzle-orm/sql/expressions";
161457
161588
  var init_notify_dm_received = __esm({
161458
161589
  "../vibes.diy/api/svc/intern/notify-dm-received.ts"() {
161459
161590
  "use strict";
@@ -161499,7 +161630,7 @@ var init_hubspot_email_facts = __esm({
161499
161630
  });
161500
161631
 
161501
161632
  // ../vibes.diy/api/svc/intern/notify-connection-expiring.ts
161502
- import { and as and210, eq as eq246 } from "drizzle-orm/sql/expressions";
161633
+ import { and as and210, eq as eq247 } from "drizzle-orm/sql/expressions";
161503
161634
  var CONNECTION_EXPIRY_THRESHOLD_DAYS, CONNECTION_EXPIRY_MAX_THRESHOLD_DAYS;
161504
161635
  var init_notify_connection_expiring = __esm({
161505
161636
  "../vibes.diy/api/svc/intern/notify-connection-expiring.ts"() {
@@ -161513,7 +161644,7 @@ var init_notify_connection_expiring = __esm({
161513
161644
  });
161514
161645
 
161515
161646
  // ../vibes.diy/api/svc/intern/notify-checkout-unfinished.ts
161516
- import { eq as eq247 } from "drizzle-orm/sql/expressions";
161647
+ import { eq as eq248 } from "drizzle-orm/sql/expressions";
161517
161648
  import { Result as Result358 } from "@adviser/cement";
161518
161649
  var init_notify_checkout_unfinished = __esm({
161519
161650
  "../vibes.diy/api/svc/intern/notify-checkout-unfinished.ts"() {
@@ -161821,7 +161952,7 @@ var init_backend_do_control_plane = __esm({
161821
161952
  });
161822
161953
 
161823
161954
  // ../vibes.diy/api/svc/public/email-unsubscribe.ts
161824
- import { and as and212, eq as eq248 } from "drizzle-orm/sql/expressions";
161955
+ import { and as and212, eq as eq249 } from "drizzle-orm/sql/expressions";
161825
161956
  import { exception2Result as exception2Result364, Result as Result360 } from "@adviser/cement";
161826
161957
  var init_email_unsubscribe2 = __esm({
161827
161958
  "../vibes.diy/api/svc/public/email-unsubscribe.ts"() {
@@ -161858,7 +161989,7 @@ var init_github_install = __esm({
161858
161989
 
161859
161990
  // ../vibes.diy/api/svc/public/github-repos.ts
161860
161991
  import { exception2Result as exception2Result365, Result as Result361 } from "@adviser/cement";
161861
- import { and as and213, eq as eq249, inArray as inArray64, ne as ne29, or as or26 } from "drizzle-orm/sql/expressions";
161992
+ import { and as and213, eq as eq250, inArray as inArray65, ne as ne28, or as or26 } from "drizzle-orm/sql/expressions";
161862
161993
  var init_github_repos = __esm({
161863
161994
  "../vibes.diy/api/svc/public/github-repos.ts"() {
161864
161995
  "use strict";
@@ -166993,7 +167124,7 @@ var init_asc_client = __esm({
166993
167124
 
166994
167125
  // ../vibes.diy/api/queue/intern/app-clip-poller.ts
166995
167126
  import { exception2Result as exception2Result380 } from "@adviser/cement";
166996
- import { and as and214, eq as eq250, inArray as inArray65, isNotNull as isNotNull8, lt as lt22, ne as ne30 } from "drizzle-orm/sql/expressions";
167127
+ import { and as and214, eq as eq251, inArray as inArray66, isNotNull as isNotNull8, lt as lt22, ne as ne29 } from "drizzle-orm/sql/expressions";
166997
167128
  function appClipLaneEnabled(env) {
166998
167129
  return appClipCardsOnThisPlane({ flag: env.APP_CLIP_CARDS, plane: env.APP_CLIP_CARDS_PLANE, envName: env.VIBES_ENV_NAME });
166999
167130
  }
@@ -167897,7 +168028,7 @@ var init_channel_invite_email = __esm({
167897
168028
  });
167898
168029
 
167899
168030
  // ../vibes.diy/api/queue/intern/mail-screenshot.ts
167900
- import { and as and215, desc as desc58, eq as eq251 } from "drizzle-orm/sql/expressions";
168031
+ import { and as and215, desc as desc58, eq as eq252 } from "drizzle-orm/sql/expressions";
167901
168032
  function toBase64(bytes) {
167902
168033
  const CHUNK = 32768;
167903
168034
  let binary = "";
@@ -167917,7 +168048,7 @@ function mailScreenshotCid(ownerHandle, appSlug) {
167917
168048
  async function loadMailScreenshot(ctx, app) {
167918
168049
  const { ownerUserId, ownerHandle, appSlug } = app;
167919
168050
  const t = ctx.sql.tables.apps;
167920
- const row = await ctx.sql.db.select({ meta: t.meta }).from(t).where(and215(eq251(t.userId, ownerUserId), eq251(t.ownerHandle, ownerHandle), eq251(t.appSlug, appSlug), eq251(t.mode, "production"))).orderBy(desc58(t.releaseSeq)).limit(1).then((r) => r[0]);
168051
+ const row = await ctx.sql.db.select({ meta: t.meta }).from(t).where(and215(eq252(t.userId, ownerUserId), eq252(t.ownerHandle, ownerHandle), eq252(t.appSlug, appSlug), eq252(t.mode, "production"))).orderBy(desc58(t.releaseSeq)).limit(1).then((r) => r[0]);
167921
168052
  if (row === void 0) return void 0;
167922
168053
  const { filtered: meta } = parseArrayWarning(row.meta, MetaItem);
167923
168054
  const shot = await loadStoredScreenshot({ storage: ctx.storage }, meta);