vibes-diy 14.3.368 → 14.3.369

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.
@@ -336226,11 +336226,11 @@ async function underRemindersLock(vctx, actor, fn4) {
336226
336226
  localLocks.set(key, queued);
336227
336227
  await before;
336228
336228
  try {
336229
- if (vctx.sql.flavour !== "pg") return await fn4();
336229
+ if (vctx.sql.flavour !== "pg") return await fn4(vctx);
336230
336230
  return await vctx.sql.db.transaction(async (tx) => {
336231
336231
  const pgTx = tx;
336232
336232
  await pgTx.execute(sql`SELECT pg_advisory_xact_lock(hashtextextended(${key}, 0))`);
336233
- return await fn4();
336233
+ return await fn4({ ...vctx, sql: { ...vctx.sql, db: tx } });
336234
336234
  });
336235
336235
  } finally {
336236
336236
  release3();
@@ -336243,12 +336243,12 @@ async function updateReminders(vctx, actor, change) {
336243
336243
  () => underRemindersLock(
336244
336244
  vctx,
336245
336245
  actor,
336246
- async () => {
336247
- const rFresh = await readRemindersDoc(vctx, actor);
336246
+ async (locked) => {
336247
+ const rFresh = await readRemindersDoc(locked, actor);
336248
336248
  if (rFresh.isErr()) return { ok: false, err: rFresh };
336249
- const { next: next3, out } = await change(rFresh.Ok());
336249
+ const { next: next3, out } = await change(rFresh.Ok(), locked);
336250
336250
  if (next3 === void 0) return { ok: true, out };
336251
- const rPut = await writeRemindersDoc(vctx, actor, next3);
336251
+ const rPut = await writeRemindersDoc(locked, actor, next3);
336252
336252
  return rPut.isErr() ? { ok: false, err: rPut } : { ok: true, out };
336253
336253
  }
336254
336254
  )
@@ -352594,18 +352594,24 @@ async function setGroupPayer(vctx, args3) {
352594
352594
  if (written.result.isErr())
352595
352595
  return refuse7(GROUP_PAYER_ERROR.unavailable, "Couldn't record that. Try again in a moment.", written.causeClass);
352596
352596
  if (asker) {
352597
- const hb = vctx.sql.tables.handleBinding;
352598
- const own2 = await exception2Result(
352599
- () => vctx.sql.db.select({ handle: hb.handle }).from(hb).where(eq(hb.userId, args3.callerUserId))
352600
- );
352601
- const recorded = await recordGroupChat(vctx.sql, {
352602
- personUserId: args3.callerUserId,
352603
- groupUserId: args3.groupUserId,
352604
- ...args3.memberHandles === void 0 ? {} : { memberHandles: args3.memberHandles },
352605
- selfHandles: own2.isOk() ? own2.Ok().map((r2) => r2.handle) : []
352597
+ const noted = (async () => {
352598
+ const hb = vctx.sql.tables.handleBinding;
352599
+ const own2 = await exception2Result(
352600
+ () => vctx.sql.db.select({ handle: hb.handle }).from(hb).where(eq(hb.userId, args3.callerUserId))
352601
+ );
352602
+ const recorded = await recordGroupChat(vctx.sql, {
352603
+ personUserId: args3.callerUserId,
352604
+ groupUserId: args3.groupUserId,
352605
+ ...args3.memberHandles === void 0 ? {} : { memberHandles: args3.memberHandles },
352606
+ selfHandles: own2.isOk() ? own2.Ok().map((r2) => r2.handle) : []
352607
+ });
352608
+ if (recorded.isErr()) vctx.logger.Warn().Err(recorded).Str("groupUserId", args3.groupUserId).Msg("group-chats: record failed");
352609
+ await noteMemberTurn(vctx, args3.groupUserId);
352610
+ })().catch((e3) => {
352611
+ vctx.logger.Warn().Err(e3).Str("groupUserId", args3.groupUserId).Msg("group-chats: record failed");
352606
352612
  });
352607
- if (recorded.isErr()) vctx.logger.Warn().Err(recorded).Str("groupUserId", args3.groupUserId).Msg("group-chats: record failed");
352608
- await noteMemberTurn(vctx, args3.groupUserId);
352613
+ if (vctx.waitUntil === void 0) await noted;
352614
+ else vctx.waitUntil(noted);
352609
352615
  }
352610
352616
  return { type: "vibes.diy.res-set-group-payer", groupUserId: args3.groupUserId, payerUserId };
352611
352617
  }
@@ -357329,16 +357335,30 @@ async function makePicture(vctx, mctx, args3) {
357329
357335
  mark("input");
357330
357336
  if (rInput.isErr()) return refusal("no-input", rInput.Err().message);
357331
357337
  const start2 = rInput.Ok();
357332
- const vibeModel = await modelFor(vctx, {
357333
- ...space,
357334
- editing: start2 !== void 0,
357335
- ownKey: vibe2 === void 0 || ownsVibe
357336
- });
357337
- const named3 = await recordImageModel(vctx, recordModel, start2 !== void 0);
357338
+ const pPause = imgGenPauseRefusal(vctx, { userId: mctx.actor.userId, chatId: mctx.chatId, lane: "make-picture" });
357339
+ const [vibeModel, named3] = await Promise.all([
357340
+ modelFor(vctx, {
357341
+ ...space,
357342
+ editing: start2 !== void 0,
357343
+ ownKey: vibe2 === void 0 || ownsVibe
357344
+ }),
357345
+ recordImageModel(vctx, recordModel, start2 !== void 0)
357346
+ ]);
357338
357347
  const { model, apiKey } = named3 === void 0 || named3 === vibeModel.model ? vibeModel : { model: named3, apiKey: void 0 };
357339
357348
  const byok = apiKey !== void 0;
357349
+ const [rCheck, pause, authz] = await Promise.all([
357350
+ byok ? void 0 : vctx.billing.checkCredits({ userId: mctx.actor.userId }),
357351
+ pPause,
357352
+ vibe2 === void 0 ? void 0 : authorizeImgGenWrite(vctx, {
357353
+ userId: writer.userId,
357354
+ ownerHandle: vibe2.ownerHandle,
357355
+ appSlug: vibe2.appSlug,
357356
+ target: { dbName: vibe2.dbName, docId: vibe2.docId, regen: true },
357357
+ promptText: prompt,
357358
+ model
357359
+ })
357360
+ ]);
357340
357361
  let payerUserId;
357341
- const rCheck = byok ? void 0 : await vctx.billing.checkCredits({ userId: mctx.actor.userId });
357342
357362
  if (rCheck === void 0) {
357343
357363
  } else if (rCheck.isErr()) {
357344
357364
  vctx.logger.Warn().Err(rCheck).Str("chatId", mctx.chatId).Msg("make_picture: billing-check-failed-open");
@@ -357346,25 +357366,14 @@ async function makePicture(vctx, mctx, args3) {
357346
357366
  payerUserId = rCheck.Ok().payerUserId;
357347
357367
  if (rCheck.Ok().allowed === false) return refusal("credits", "Out of credits for pictures right now.");
357348
357368
  }
357349
- const pause = await imgGenPauseRefusal(vctx, { userId: mctx.actor.userId, chatId: mctx.chatId, lane: "make-picture" });
357350
357369
  if (pause !== void 0) {
357351
357370
  return refusal(
357352
357371
  IMG_GEN_PAUSED_CODE,
357353
357372
  "This account's sketchbook is full for now; more pictures in a few minutes. Offer to try later."
357354
357373
  );
357355
357374
  }
357356
- if (vibe2 !== void 0) {
357357
- const authz = await authorizeImgGenWrite(vctx, {
357358
- userId: writer.userId,
357359
- ownerHandle: vibe2.ownerHandle,
357360
- appSlug: vibe2.appSlug,
357361
- target: { dbName: vibe2.dbName, docId: vibe2.docId, regen: true },
357362
- promptText: prompt,
357363
- model
357364
- });
357365
- if (authz.allowed === false) {
357366
- return refusal("denied", authz.reason ?? "That vibe's rules don't let this picture be saved there.");
357367
- }
357375
+ if (authz !== void 0 && authz.allowed === false) {
357376
+ return refusal("denied", authz.reason ?? "That vibe's rules don't let this picture be saved there.");
357368
357377
  }
357369
357378
  const hold2 = vibe2 === void 0 ? void 0 : await holdImgGenForAgentPaint(vctx, {
357370
357379
  ownerHandle: vibe2.ownerHandle,
@@ -96033,11 +96033,11 @@ async function underRemindersLock(vctx, actor, fn) {
96033
96033
  localLocks.set(key, queued);
96034
96034
  await before;
96035
96035
  try {
96036
- if (vctx.sql.flavour !== "pg") return await fn();
96036
+ if (vctx.sql.flavour !== "pg") return await fn(vctx);
96037
96037
  return await vctx.sql.db.transaction(async (tx) => {
96038
96038
  const pgTx = tx;
96039
96039
  await pgTx.execute(sql23`SELECT pg_advisory_xact_lock(hashtextextended(${key}, 0))`);
96040
- return await fn();
96040
+ return await fn({ ...vctx, sql: { ...vctx.sql, db: tx } });
96041
96041
  });
96042
96042
  } finally {
96043
96043
  release();
@@ -96049,12 +96049,12 @@ async function updateReminders(vctx, actor, change) {
96049
96049
  () => underRemindersLock(
96050
96050
  vctx,
96051
96051
  actor,
96052
- async () => {
96053
- const rFresh = await readRemindersDoc(vctx, actor);
96052
+ async (locked) => {
96053
+ const rFresh = await readRemindersDoc(locked, actor);
96054
96054
  if (rFresh.isErr()) return { ok: false, err: rFresh };
96055
- const { next, out } = await change(rFresh.Ok());
96055
+ const { next, out } = await change(rFresh.Ok(), locked);
96056
96056
  if (next === void 0) return { ok: true, out };
96057
- const rPut = await writeRemindersDoc(vctx, actor, next);
96057
+ const rPut = await writeRemindersDoc(locked, actor, next);
96058
96058
  return rPut.isErr() ? { ok: false, err: rPut } : { ok: true, out };
96059
96059
  }
96060
96060
  )
@@ -102774,18 +102774,24 @@ async function setGroupPayer(vctx, args) {
102774
102774
  if (written.result.isErr())
102775
102775
  return refuse7(GROUP_PAYER_ERROR.unavailable, "Couldn't record that. Try again in a moment.", written.causeClass);
102776
102776
  if (asker) {
102777
- const hb = vctx.sql.tables.handleBinding;
102778
- const own = await exception2Result196(
102779
- () => vctx.sql.db.select({ handle: hb.handle }).from(hb).where(eq127(hb.userId, args.callerUserId))
102780
- );
102781
- const recorded = await recordGroupChat(vctx.sql, {
102782
- personUserId: args.callerUserId,
102783
- groupUserId: args.groupUserId,
102784
- ...args.memberHandles === void 0 ? {} : { memberHandles: args.memberHandles },
102785
- selfHandles: own.isOk() ? own.Ok().map((r) => r.handle) : []
102777
+ const noted = (async () => {
102778
+ const hb = vctx.sql.tables.handleBinding;
102779
+ const own = await exception2Result196(
102780
+ () => vctx.sql.db.select({ handle: hb.handle }).from(hb).where(eq127(hb.userId, args.callerUserId))
102781
+ );
102782
+ const recorded = await recordGroupChat(vctx.sql, {
102783
+ personUserId: args.callerUserId,
102784
+ groupUserId: args.groupUserId,
102785
+ ...args.memberHandles === void 0 ? {} : { memberHandles: args.memberHandles },
102786
+ selfHandles: own.isOk() ? own.Ok().map((r) => r.handle) : []
102787
+ });
102788
+ if (recorded.isErr()) vctx.logger.Warn().Err(recorded).Str("groupUserId", args.groupUserId).Msg("group-chats: record failed");
102789
+ await noteMemberTurn(vctx, args.groupUserId);
102790
+ })().catch((e) => {
102791
+ vctx.logger.Warn().Err(e).Str("groupUserId", args.groupUserId).Msg("group-chats: record failed");
102786
102792
  });
102787
- if (recorded.isErr()) vctx.logger.Warn().Err(recorded).Str("groupUserId", args.groupUserId).Msg("group-chats: record failed");
102788
- await noteMemberTurn(vctx, args.groupUserId);
102793
+ if (vctx.waitUntil === void 0) await noted;
102794
+ else vctx.waitUntil(noted);
102789
102795
  }
102790
102796
  return { type: "vibes.diy.res-set-group-payer", groupUserId: args.groupUserId, payerUserId };
102791
102797
  }
@@ -107650,16 +107656,30 @@ async function makePicture(vctx, mctx, args) {
107650
107656
  mark("input");
107651
107657
  if (rInput.isErr()) return refusal("no-input", rInput.Err().message);
107652
107658
  const start = rInput.Ok();
107653
- const vibeModel = await modelFor(vctx, {
107654
- ...space,
107655
- editing: start !== void 0,
107656
- ownKey: vibe2 === void 0 || ownsVibe
107657
- });
107658
- const named3 = await recordImageModel(vctx, recordModel, start !== void 0);
107659
+ const pPause = imgGenPauseRefusal(vctx, { userId: mctx.actor.userId, chatId: mctx.chatId, lane: "make-picture" });
107660
+ const [vibeModel, named3] = await Promise.all([
107661
+ modelFor(vctx, {
107662
+ ...space,
107663
+ editing: start !== void 0,
107664
+ ownKey: vibe2 === void 0 || ownsVibe
107665
+ }),
107666
+ recordImageModel(vctx, recordModel, start !== void 0)
107667
+ ]);
107659
107668
  const { model, apiKey } = named3 === void 0 || named3 === vibeModel.model ? vibeModel : { model: named3, apiKey: void 0 };
107660
107669
  const byok = apiKey !== void 0;
107670
+ const [rCheck, pause, authz] = await Promise.all([
107671
+ byok ? void 0 : vctx.billing.checkCredits({ userId: mctx.actor.userId }),
107672
+ pPause,
107673
+ vibe2 === void 0 ? void 0 : authorizeImgGenWrite(vctx, {
107674
+ userId: writer.userId,
107675
+ ownerHandle: vibe2.ownerHandle,
107676
+ appSlug: vibe2.appSlug,
107677
+ target: { dbName: vibe2.dbName, docId: vibe2.docId, regen: true },
107678
+ promptText: prompt,
107679
+ model
107680
+ })
107681
+ ]);
107661
107682
  let payerUserId;
107662
- const rCheck = byok ? void 0 : await vctx.billing.checkCredits({ userId: mctx.actor.userId });
107663
107683
  if (rCheck === void 0) {
107664
107684
  } else if (rCheck.isErr()) {
107665
107685
  vctx.logger.Warn().Err(rCheck).Str("chatId", mctx.chatId).Msg("make_picture: billing-check-failed-open");
@@ -107667,25 +107687,14 @@ async function makePicture(vctx, mctx, args) {
107667
107687
  payerUserId = rCheck.Ok().payerUserId;
107668
107688
  if (rCheck.Ok().allowed === false) return refusal("credits", "Out of credits for pictures right now.");
107669
107689
  }
107670
- const pause = await imgGenPauseRefusal(vctx, { userId: mctx.actor.userId, chatId: mctx.chatId, lane: "make-picture" });
107671
107690
  if (pause !== void 0) {
107672
107691
  return refusal(
107673
107692
  IMG_GEN_PAUSED_CODE,
107674
107693
  "This account's sketchbook is full for now; more pictures in a few minutes. Offer to try later."
107675
107694
  );
107676
107695
  }
107677
- if (vibe2 !== void 0) {
107678
- const authz = await authorizeImgGenWrite(vctx, {
107679
- userId: writer.userId,
107680
- ownerHandle: vibe2.ownerHandle,
107681
- appSlug: vibe2.appSlug,
107682
- target: { dbName: vibe2.dbName, docId: vibe2.docId, regen: true },
107683
- promptText: prompt,
107684
- model
107685
- });
107686
- if (authz.allowed === false) {
107687
- return refusal("denied", authz.reason ?? "That vibe's rules don't let this picture be saved there.");
107688
- }
107696
+ if (authz !== void 0 && authz.allowed === false) {
107697
+ return refusal("denied", authz.reason ?? "That vibe's rules don't let this picture be saved there.");
107689
107698
  }
107690
107699
  const hold2 = vibe2 === void 0 ? void 0 : await holdImgGenForAgentPaint(vctx, {
107691
107700
  ownerHandle: vibe2.ownerHandle,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibes-diy",
3
- "version": "14.3.368",
3
+ "version": "14.3.369",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "description": "Command-line tool for vibes.diy — generate, edit, pull, push, and publish AI-built apps",
@@ -41,13 +41,13 @@
41
41
  "@neondatabase/serverless": "~1.2.0",
42
42
  "@noble/hashes": "~2.4.0",
43
43
  "@shadcn/lint": "~0.2.3",
44
- "@vibes.diy/api-impl": "14.3.368",
45
- "@vibes.diy/api-types": "14.3.368",
46
- "@vibes.diy/call-ai-v2": "14.3.368",
47
- "@vibes.diy/cmd-harness": "14.3.368",
48
- "@vibes.diy/cmd-tools": "14.3.368",
49
- "@vibes.diy/identity": "14.3.368",
50
- "@vibes.diy/prompts": "14.3.368",
44
+ "@vibes.diy/api-impl": "14.3.369",
45
+ "@vibes.diy/api-types": "14.3.369",
46
+ "@vibes.diy/call-ai-v2": "14.3.369",
47
+ "@vibes.diy/cmd-harness": "14.3.369",
48
+ "@vibes.diy/cmd-tools": "14.3.369",
49
+ "@vibes.diy/identity": "14.3.369",
50
+ "@vibes.diy/prompts": "14.3.369",
51
51
  "acorn": "~8.19.0",
52
52
  "acorn-jsx": "~5.3.2",
53
53
  "arktype": "~2.2.9",