vibes-diy 14.3.364 → 14.3.366
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1656,7 +1656,7 @@ function lazyType(build) {
|
|
|
1656
1656
|
return d === void 0 ? void 0 : { ...d, configurable: true };
|
|
1657
1657
|
}, "getOwnPropertyDescriptor"),
|
|
1658
1658
|
getPrototypeOf: /* @__PURE__ */ __name(() => Reflect.getPrototypeOf(resolve11()), "getPrototypeOf"),
|
|
1659
|
-
defineProperty: /* @__PURE__ */ __name((_t, prop,
|
|
1659
|
+
defineProperty: /* @__PURE__ */ __name((_t, prop, desc61) => Reflect.defineProperty(resolve11(), prop, desc61), "defineProperty"),
|
|
1660
1660
|
deleteProperty: /* @__PURE__ */ __name((_t, prop) => Reflect.deleteProperty(resolve11(), prop), "deleteProperty")
|
|
1661
1661
|
});
|
|
1662
1662
|
}
|
|
@@ -2410,7 +2410,7 @@ function lazyType2(build) {
|
|
|
2410
2410
|
return d === void 0 ? void 0 : { ...d, configurable: true };
|
|
2411
2411
|
}, "getOwnPropertyDescriptor"),
|
|
2412
2412
|
getPrototypeOf: /* @__PURE__ */ __name(() => Reflect.getPrototypeOf(resolve11()), "getPrototypeOf"),
|
|
2413
|
-
defineProperty: /* @__PURE__ */ __name((_t, prop,
|
|
2413
|
+
defineProperty: /* @__PURE__ */ __name((_t, prop, desc61) => Reflect.defineProperty(resolve11(), prop, desc61), "defineProperty"),
|
|
2414
2414
|
deleteProperty: /* @__PURE__ */ __name((_t, prop) => Reflect.deleteProperty(resolve11(), prop), "deleteProperty")
|
|
2415
2415
|
});
|
|
2416
2416
|
}
|
|
@@ -10991,6 +10991,14 @@ var init_group_principal = __esm({
|
|
|
10991
10991
|
* sponsored group, so the turn runs on the sponsor's credits, acting as nobody.
|
|
10992
10992
|
*/
|
|
10993
10993
|
"sponsored?": "boolean",
|
|
10994
|
+
/**
|
|
10995
|
+
* With `sponsored` only (issue #10043, Chris 2026-11-18): the member who hasn't linked, named by
|
|
10996
|
+
* their own one-to-one phone-guest principal (`group:<id>`, the one a direct chat with their
|
|
10997
|
+
* number gets). Their yes to a text-later offer on this turn is recorded under it, and that one
|
|
10998
|
+
* tool runs as it, so its later text reaches them one to one, never the group. Acts as nobody
|
|
10999
|
+
* anywhere else.
|
|
11000
|
+
*/
|
|
11001
|
+
"guestAsker?": "string",
|
|
10994
11002
|
/** The bridge's view of the chat's other linked members, by handle, for the caller's group list. */
|
|
10995
11003
|
"memberHandles?": "string[]"
|
|
10996
11004
|
})
|
|
@@ -12519,7 +12527,13 @@ var init_settings = __esm({
|
|
|
12519
12527
|
* bridge runs on their credits. Only then may the group act as them inside other people's
|
|
12520
12528
|
* vibes (`with_vibe`'s asker lane). Absent: billing only.
|
|
12521
12529
|
*/
|
|
12522
|
-
"asker?": "boolean"
|
|
12530
|
+
"asker?": "boolean",
|
|
12531
|
+
/**
|
|
12532
|
+
* A sponsored turn from a member who hasn't linked (issue #10043): their own one-to-one
|
|
12533
|
+
* phone-guest principal, named by the bridge. Read only for a text-later yes
|
|
12534
|
+
* (`resolveTextConsentSpeaker`) and the one tool that yes runs; never an asker elsewhere.
|
|
12535
|
+
*/
|
|
12536
|
+
"guestAskerUserId?": "string"
|
|
12523
12537
|
})
|
|
12524
12538
|
);
|
|
12525
12539
|
userSettingGroupSponsor = lazyType(
|
|
@@ -27201,7 +27215,6 @@ var init_version_timeline = __esm({
|
|
|
27201
27215
|
var POUF_ENTRY_EXPORTS, POUF_TAUGHT_NAMES;
|
|
27202
27216
|
var init_exports = __esm({
|
|
27203
27217
|
"../vibes.diy/pouf/exports.ts"() {
|
|
27204
|
-
"use strict";
|
|
27205
27218
|
POUF_ENTRY_EXPORTS = {
|
|
27206
27219
|
index: [
|
|
27207
27220
|
"AlertBell",
|
|
@@ -32309,8 +32322,8 @@ function isValidName(name) {
|
|
|
32309
32322
|
function isValidDuration(durationMs) {
|
|
32310
32323
|
return Number.isFinite(durationMs) && durationMs >= 0;
|
|
32311
32324
|
}
|
|
32312
|
-
function sanitizeDesc(
|
|
32313
|
-
const clean2 =
|
|
32325
|
+
function sanitizeDesc(desc61) {
|
|
32326
|
+
const clean2 = desc61.replace(DESC_ALLOWED, "").trim();
|
|
32314
32327
|
return clean2.length > 0 ? clean2 : void 0;
|
|
32315
32328
|
}
|
|
32316
32329
|
function serverTimingTotal(startTime, now3 = Date.now) {
|
|
@@ -32348,9 +32361,9 @@ var init_request_timings = __esm({
|
|
|
32348
32361
|
* non-empty `desc` seen for a name wins, so an accumulating phase keeps its
|
|
32349
32362
|
* kind.
|
|
32350
32363
|
*/
|
|
32351
|
-
record(name, durationMs,
|
|
32364
|
+
record(name, durationMs, desc61) {
|
|
32352
32365
|
if (!isValidName(name) || !isValidDuration(durationMs)) return;
|
|
32353
|
-
const cleanDesc =
|
|
32366
|
+
const cleanDesc = desc61 === void 0 ? void 0 : sanitizeDesc(desc61);
|
|
32354
32367
|
const prev = this.phases.get(name);
|
|
32355
32368
|
if (prev) {
|
|
32356
32369
|
prev.dur += durationMs;
|
|
@@ -32359,12 +32372,12 @@ var init_request_timings = __esm({
|
|
|
32359
32372
|
}
|
|
32360
32373
|
this.phases.set(name, cleanDesc === void 0 ? { dur: durationMs } : { dur: durationMs, desc: cleanDesc });
|
|
32361
32374
|
}
|
|
32362
|
-
async timed(name,
|
|
32375
|
+
async timed(name, desc61, fn) {
|
|
32363
32376
|
const started = this.now();
|
|
32364
32377
|
try {
|
|
32365
32378
|
return await fn();
|
|
32366
32379
|
} finally {
|
|
32367
|
-
this.record(name, this.now() - started,
|
|
32380
|
+
this.record(name, this.now() - started, desc61);
|
|
32368
32381
|
}
|
|
32369
32382
|
}
|
|
32370
32383
|
/** A SERIAL phase: its duration is on the critical path. */
|
|
@@ -35938,13 +35951,13 @@ function isReservedChannelId(ch) {
|
|
|
35938
35951
|
function presentSubject(s) {
|
|
35939
35952
|
return s !== void 0 && s.trim().length > 0;
|
|
35940
35953
|
}
|
|
35941
|
-
function stripForeignAudience(
|
|
35942
|
-
const aud =
|
|
35943
|
-
if (aud === void 0) return
|
|
35954
|
+
function stripForeignAudience(desc61, actingHandle) {
|
|
35955
|
+
const aud = desc61.audience;
|
|
35956
|
+
if (aud === void 0) return desc61;
|
|
35944
35957
|
const subjects = [aud.followersOf, aud.mutualsOf].filter(presentSubject);
|
|
35945
35958
|
const allOwn = actingHandle !== null && subjects.every((s) => s === actingHandle);
|
|
35946
|
-
if (allOwn) return
|
|
35947
|
-
return { ...
|
|
35959
|
+
if (allOwn) return desc61;
|
|
35960
|
+
return { ...desc61, audience: void 0 };
|
|
35948
35961
|
}
|
|
35949
35962
|
function inheritChannelKey(db, docId) {
|
|
35950
35963
|
return `${INHERIT_CHANNEL_PREFIX}${JSON.stringify([db, docId])}`;
|
|
@@ -35966,31 +35979,31 @@ function hasInheritChannel(channels) {
|
|
|
35966
35979
|
function presentInheritRead(ir) {
|
|
35967
35980
|
return typeof ir === "object" && ir !== null && "db" in ir && "docId" in ir && typeof ir.db === "string" && ir.db.trim().length > 0 && typeof ir.docId === "string" && ir.docId.trim().length > 0;
|
|
35968
35981
|
}
|
|
35969
|
-
function inheritChannelOf(
|
|
35970
|
-
return presentInheritRead(
|
|
35982
|
+
function inheritChannelOf(desc61) {
|
|
35983
|
+
return presentInheritRead(desc61.inheritRead) ? [inheritChannelKey(desc61.inheritRead.db, desc61.inheritRead.docId)] : [];
|
|
35971
35984
|
}
|
|
35972
|
-
function audienceChannelsOf(
|
|
35985
|
+
function audienceChannelsOf(desc61) {
|
|
35973
35986
|
const out = [];
|
|
35974
|
-
if (presentSubject(
|
|
35975
|
-
if (presentSubject(
|
|
35987
|
+
if (presentSubject(desc61.audience?.followersOf)) out.push(`~aud:followers:${desc61.audience.followersOf}`);
|
|
35988
|
+
if (presentSubject(desc61.audience?.mutualsOf)) out.push(`~aud:mutuals:${desc61.audience.mutualsOf}`);
|
|
35976
35989
|
return out;
|
|
35977
35990
|
}
|
|
35978
|
-
function hasReservedChannel(
|
|
35979
|
-
if ((
|
|
35980
|
-
if (
|
|
35981
|
-
for (const channelIds of Object.values(
|
|
35991
|
+
function hasReservedChannel(desc61) {
|
|
35992
|
+
if ((desc61.channels ?? []).some(isReservedChannelId)) return true;
|
|
35993
|
+
if (desc61.grant === void 0) return false;
|
|
35994
|
+
for (const channelIds of Object.values(desc61.grant.users ?? {})) {
|
|
35982
35995
|
if (channelIds.some(isReservedChannelId)) return true;
|
|
35983
35996
|
}
|
|
35984
|
-
for (const channelIds of Object.values(
|
|
35997
|
+
for (const channelIds of Object.values(desc61.grant.roles ?? {})) {
|
|
35985
35998
|
if (channelIds.some(isReservedChannelId)) return true;
|
|
35986
35999
|
}
|
|
35987
|
-
return (
|
|
36000
|
+
return (desc61.grant.public ?? []).some(isReservedChannelId);
|
|
35988
36001
|
}
|
|
35989
|
-
function hasReservedRoleMint(
|
|
35990
|
-
return Object.keys(
|
|
36002
|
+
function hasReservedRoleMint(desc61) {
|
|
36003
|
+
return Object.keys(desc61.members ?? {}).some((role) => role.trim().startsWith(RESERVED_CHANNEL_PREFIX));
|
|
35991
36004
|
}
|
|
35992
|
-
function hasReservedPlatformDbRef(
|
|
35993
|
-
return presentInheritRead(
|
|
36005
|
+
function hasReservedPlatformDbRef(desc61) {
|
|
36006
|
+
return presentInheritRead(desc61.inheritRead) && isPlatformDbName(desc61.inheritRead.db.trim());
|
|
35994
36007
|
}
|
|
35995
36008
|
function audienceSubjectFromChannel(ch) {
|
|
35996
36009
|
if (ch.startsWith(AUD_FOLLOWERS_PREFIX)) return ch.slice(AUD_FOLLOWERS_PREFIX.length);
|
|
@@ -37777,17 +37790,17 @@ async function fnGrantStateHandles(vctx, input) {
|
|
|
37777
37790
|
for (const row of rows) {
|
|
37778
37791
|
const rDesc = exception2Result34(() => JSON.parse(row.output));
|
|
37779
37792
|
if (rDesc.isErr()) continue;
|
|
37780
|
-
const
|
|
37781
|
-
for (const h of canonicalDescriptorHandles(
|
|
37793
|
+
const desc61 = rDesc.Ok();
|
|
37794
|
+
for (const h of canonicalDescriptorHandles(desc61)) out.add(h);
|
|
37782
37795
|
}
|
|
37783
37796
|
return out;
|
|
37784
37797
|
}
|
|
37785
37798
|
function isPlainObject2(v) {
|
|
37786
37799
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
37787
37800
|
}
|
|
37788
|
-
function canonicalDescriptorHandles(
|
|
37801
|
+
function canonicalDescriptorHandles(desc61) {
|
|
37789
37802
|
const out = [];
|
|
37790
|
-
const members =
|
|
37803
|
+
const members = desc61.members;
|
|
37791
37804
|
if (isPlainObject2(members)) {
|
|
37792
37805
|
for (const users2 of Object.values(members)) {
|
|
37793
37806
|
if (!Array.isArray(users2)) continue;
|
|
@@ -37796,7 +37809,7 @@ function canonicalDescriptorHandles(desc60) {
|
|
|
37796
37809
|
}
|
|
37797
37810
|
}
|
|
37798
37811
|
}
|
|
37799
|
-
const users =
|
|
37812
|
+
const users = desc61.grant?.users;
|
|
37800
37813
|
if (isPlainObject2(users)) {
|
|
37801
37814
|
for (const h of Object.keys(users)) out.push(h);
|
|
37802
37815
|
}
|
|
@@ -45296,27 +45309,27 @@ var init_ensure_app_settings = __esm({
|
|
|
45296
45309
|
function hasContent(c) {
|
|
45297
45310
|
return c.members.size > 0 || c.grantRoles.size > 0 || c.grantUsers.size > 0 || c.grantPublic.size > 0;
|
|
45298
45311
|
}
|
|
45299
|
-
function extractContribution(
|
|
45312
|
+
function extractContribution(desc61) {
|
|
45300
45313
|
const members = /* @__PURE__ */ new Map();
|
|
45301
|
-
if (
|
|
45302
|
-
for (const [role, users] of Object.entries(
|
|
45314
|
+
if (desc61.members) {
|
|
45315
|
+
for (const [role, users] of Object.entries(desc61.members)) {
|
|
45303
45316
|
if (role.trim().startsWith(RESERVED_ROLE_PREFIX)) continue;
|
|
45304
45317
|
members.set(role, new Set(users));
|
|
45305
45318
|
}
|
|
45306
45319
|
}
|
|
45307
45320
|
const grantRoles = /* @__PURE__ */ new Map();
|
|
45308
|
-
if (
|
|
45309
|
-
for (const [role, channels] of Object.entries(
|
|
45321
|
+
if (desc61.grant?.roles) {
|
|
45322
|
+
for (const [role, channels] of Object.entries(desc61.grant.roles)) {
|
|
45310
45323
|
grantRoles.set(role, new Set(channels));
|
|
45311
45324
|
}
|
|
45312
45325
|
}
|
|
45313
45326
|
const grantUsers = /* @__PURE__ */ new Map();
|
|
45314
|
-
if (
|
|
45315
|
-
for (const [user, channels] of Object.entries(
|
|
45327
|
+
if (desc61.grant?.users) {
|
|
45328
|
+
for (const [user, channels] of Object.entries(desc61.grant.users)) {
|
|
45316
45329
|
grantUsers.set(user, new Set(channels));
|
|
45317
45330
|
}
|
|
45318
45331
|
}
|
|
45319
|
-
const grantPublic = new Set(
|
|
45332
|
+
const grantPublic = new Set(desc61.grant?.public ?? []);
|
|
45320
45333
|
return { members, grantRoles, grantUsers, grantPublic };
|
|
45321
45334
|
}
|
|
45322
45335
|
function seedOwnerGrants(reduce, ownerHandle, devHandles = []) {
|
|
@@ -57821,7 +57834,8 @@ async function writeGroupPayer(sql43, args) {
|
|
|
57821
57834
|
payerUserId: args.payerUserId,
|
|
57822
57835
|
updatedAt: now3,
|
|
57823
57836
|
claimId,
|
|
57824
|
-
...args.asker === true ? { asker: true } : {}
|
|
57837
|
+
...args.asker === true ? { asker: true } : {},
|
|
57838
|
+
...args.guestAskerUserId === void 0 ? {} : { guestAskerUserId: args.guestAskerUserId }
|
|
57825
57839
|
}
|
|
57826
57840
|
];
|
|
57827
57841
|
if (row === void 0) {
|
|
@@ -57846,6 +57860,14 @@ async function readGroupAsker(sql43, args) {
|
|
|
57846
57860
|
return id;
|
|
57847
57861
|
});
|
|
57848
57862
|
}
|
|
57863
|
+
async function readGroupGuestAsker(sql43, groupUserId) {
|
|
57864
|
+
return exception2Result98(async () => {
|
|
57865
|
+
const settings = await readSettings2(sql43, groupUserId);
|
|
57866
|
+
const id = settings?.find(isUserSettingGroupPayer)?.guestAskerUserId;
|
|
57867
|
+
if (id === void 0 || id === groupUserId || !isGroupPrincipal(id)) return void 0;
|
|
57868
|
+
return id;
|
|
57869
|
+
});
|
|
57870
|
+
}
|
|
57849
57871
|
async function replaceSettingsItem(sql43, args) {
|
|
57850
57872
|
return exception2Result98(async () => {
|
|
57851
57873
|
const t = sql43.tables.userSettings;
|
|
@@ -58048,6 +58070,7 @@ var init_group_payer = __esm({
|
|
|
58048
58070
|
__name(readGroupPayer, "readGroupPayer");
|
|
58049
58071
|
__name(writeGroupPayer, "writeGroupPayer");
|
|
58050
58072
|
__name(readGroupAsker, "readGroupAsker");
|
|
58073
|
+
__name(readGroupGuestAsker, "readGroupGuestAsker");
|
|
58051
58074
|
__name(replaceSettingsItem, "replaceSettingsItem");
|
|
58052
58075
|
GROUP_ROSTER_KEPT = 50;
|
|
58053
58076
|
__name(readGroupRoster, "readGroupRoster");
|
|
@@ -99225,16 +99248,30 @@ async function resolveTextConsentSpeaker(vctx, args) {
|
|
|
99225
99248
|
return { ok: false, message: "Could not tell who said yes just now, so the tool did not run. Nothing was done." };
|
|
99226
99249
|
}
|
|
99227
99250
|
const writer = rWriter.Ok();
|
|
99228
|
-
if (writer.kind === "no-asker") return
|
|
99251
|
+
if (writer.kind === "no-asker") return guestSpeaker(vctx, args.actorUserId);
|
|
99229
99252
|
if (writer.kind === "several-handles") return { ok: false, message: GROUP_ASKER_SEVERAL_HANDLES_MESSAGE };
|
|
99230
99253
|
return { ok: true, userId: writer.userId, ownerHandle: writer.ownerHandle };
|
|
99231
99254
|
}
|
|
99255
|
+
async function guestSpeaker(vctx, groupUserId) {
|
|
99256
|
+
const unreadable = {
|
|
99257
|
+
ok: false,
|
|
99258
|
+
message: "Could not tell who said yes just now, so the tool did not run. Nothing was done."
|
|
99259
|
+
};
|
|
99260
|
+
const rGuest = await readGroupGuestAsker(vctx.sql, groupUserId);
|
|
99261
|
+
if (rGuest.isErr()) return unreadable;
|
|
99262
|
+
const guestUserId = rGuest.Ok();
|
|
99263
|
+
if (guestUserId === void 0) return { ok: false, message: TEXT_CONSENT_NO_SPEAKER_MESSAGE };
|
|
99264
|
+
const rHandle = await resolveAgentActor(vctx, { userId: guestUserId });
|
|
99265
|
+
if (rHandle.isErr()) return unreadable;
|
|
99266
|
+
return { ok: true, userId: guestUserId, ownerHandle: rHandle.Ok().ownerHandle, runsAsSpeaker: true };
|
|
99267
|
+
}
|
|
99232
99268
|
var TEXT_LATER_CONSENT, TEXT_CONSENT_NO_SPEAKER_MESSAGE;
|
|
99233
99269
|
var init_text_consents = __esm({
|
|
99234
99270
|
"../vibes.diy/api/svc/intern/text-consents.ts"() {
|
|
99235
99271
|
"use strict";
|
|
99236
99272
|
init_types3();
|
|
99237
99273
|
init_group_asker_writer();
|
|
99274
|
+
init_agent_actor();
|
|
99238
99275
|
init_group_payer();
|
|
99239
99276
|
TEXT_LATER_CONSENT = "text-later";
|
|
99240
99277
|
__name(recordTextConsent, "recordTextConsent");
|
|
@@ -99243,6 +99280,7 @@ var init_text_consents = __esm({
|
|
|
99243
99280
|
__name(personAnswerText, "personAnswerText");
|
|
99244
99281
|
TEXT_CONSENT_NO_SPEAKER_MESSAGE = "A later text needs the yes of the person it goes to, and no linked member is asking on this turn, so nobody's yes can be recorded. Ask the person who wants it to say yes themselves. Nothing ran.";
|
|
99245
99282
|
__name(resolveTextConsentSpeaker, "resolveTextConsentSpeaker");
|
|
99283
|
+
__name(guestSpeaker, "guestSpeaker");
|
|
99246
99284
|
}
|
|
99247
99285
|
});
|
|
99248
99286
|
|
|
@@ -102527,6 +102565,19 @@ async function noteMemberTurn(vctx, groupUserId) {
|
|
|
102527
102565
|
const r = await noteGroupMemberTurn(vctx, rActor.Ok());
|
|
102528
102566
|
if (r.isErr()) vctx.logger.Warn().Err(r).Str("groupUserId", groupUserId).Msg("vibe-outreach: member turn not noted");
|
|
102529
102567
|
}
|
|
102568
|
+
async function phoneGuestAsker(vctx, groupUserId, guestAsker) {
|
|
102569
|
+
if (guestAsker === void 0) return void 0;
|
|
102570
|
+
if (guestAsker === groupUserId || !isGroupPrincipal(guestAsker)) {
|
|
102571
|
+
vctx.logger.Warn().Str("groupUserId", groupUserId).Msg("group-payer: guest asker is no phone guest");
|
|
102572
|
+
return void 0;
|
|
102573
|
+
}
|
|
102574
|
+
const own = await readGroupPayer(vctx.sql, guestAsker);
|
|
102575
|
+
if (own.isErr() || own.Ok() !== guestAsker) {
|
|
102576
|
+
vctx.logger.Warn().Str("groupUserId", groupUserId).Msg("group-payer: guest asker is no phone guest");
|
|
102577
|
+
return void 0;
|
|
102578
|
+
}
|
|
102579
|
+
return guestAsker;
|
|
102580
|
+
}
|
|
102530
102581
|
function refuse7(code2, message3) {
|
|
102531
102582
|
return { type: "vibes.diy.res-error", error: { message: message3, code: code2 } };
|
|
102532
102583
|
}
|
|
@@ -102585,7 +102636,12 @@ async function setGroupPayer(vctx, args) {
|
|
|
102585
102636
|
sponsorUserId = args.callerUserId;
|
|
102586
102637
|
vctx.logger.Info().Str("groupUserId", args.groupUserId).Str("payerUserId", sponsorUserId).Msg("group-payer: bridge sponsor");
|
|
102587
102638
|
}
|
|
102588
|
-
const
|
|
102639
|
+
const guestAskerUserId = await phoneGuestAsker(vctx, args.groupUserId, args.guestAsker);
|
|
102640
|
+
const written2 = await writeGroupPayer(vctx.sql, {
|
|
102641
|
+
groupUserId: args.groupUserId,
|
|
102642
|
+
payerUserId: sponsorUserId,
|
|
102643
|
+
...guestAskerUserId === void 0 ? {} : { guestAskerUserId }
|
|
102644
|
+
});
|
|
102589
102645
|
if (written2.isErr()) {
|
|
102590
102646
|
vctx.logger.Error().Err(written2.Err()).Str("groupUserId", args.groupUserId).Msg("group-payer: sponsored write failed");
|
|
102591
102647
|
return refuse7(GROUP_PAYER_ERROR.unavailable, "Couldn't record that. Try again in a moment.");
|
|
@@ -102667,6 +102723,7 @@ var init_group_principal2 = __esm({
|
|
|
102667
102723
|
init_agent_actor();
|
|
102668
102724
|
init_agent_vibe_outreach();
|
|
102669
102725
|
__name(noteMemberTurn, "noteMemberTurn");
|
|
102726
|
+
__name(phoneGuestAsker, "phoneGuestAsker");
|
|
102670
102727
|
__name(refuse7, "refuse");
|
|
102671
102728
|
__name(groupPrincipalIdOf, "groupPrincipalIdOf");
|
|
102672
102729
|
__name(mintGroupPrincipal, "mintGroupPrincipal");
|
|
@@ -102709,6 +102766,7 @@ var init_group_principal2 = __esm({
|
|
|
102709
102766
|
...req2.guest === true ? { guest: true } : {},
|
|
102710
102767
|
...req2.asker === true ? { asker: true } : {},
|
|
102711
102768
|
...req2.sponsored === true ? { sponsored: true } : {},
|
|
102769
|
+
...req2.guestAsker === void 0 ? {} : { guestAsker: req2.guestAsker },
|
|
102712
102770
|
...req2.memberHandles === void 0 ? {} : { memberHandles: req2.memberHandles.slice(0, 20) }
|
|
102713
102771
|
});
|
|
102714
102772
|
await ctx.send.send(ctx, res);
|
|
@@ -106993,7 +107051,7 @@ var init_vibe_tool_offer = __esm({
|
|
|
106993
107051
|
// ../vibes.diy/api/svc/intern/agent-make-picture-tool.ts
|
|
106994
107052
|
import { Result as Result146, exception2Result as exception2Result209, stream2uint8array as stream2uint8array9 } from "@adviser/cement";
|
|
106995
107053
|
import { type as type141 } from "arktype";
|
|
106996
|
-
import { and as and115, eq as eq135, like as like5 } from "drizzle-orm";
|
|
107054
|
+
import { and as and115, desc as desc26, eq as eq135, like as like5 } from "drizzle-orm";
|
|
106997
107055
|
function makePictureToolDefinition() {
|
|
106998
107056
|
return {
|
|
106999
107057
|
type: "function",
|
|
@@ -107027,7 +107085,7 @@ function makePictureToolDefinition() {
|
|
|
107027
107085
|
},
|
|
107028
107086
|
vibe: {
|
|
107029
107087
|
type: "object",
|
|
107030
|
-
description: "Also save it as this record's picture, in a vibe this conversation may add records to (its own, or one they linked).",
|
|
107088
|
+
description: "Also save it as this record's picture, in a vibe this conversation may add records to (its own, or one they linked). A picture app named by its owner and appSlug alone (no dbName) goes through its own newest record with a prompt: make_picture copies it, keeps the photo where that record keeps its own, and answers `record` with what it used.",
|
|
107031
107089
|
properties: {
|
|
107032
107090
|
ownerHandle: { type: "string" },
|
|
107033
107091
|
appSlug: { type: "string" },
|
|
@@ -107039,10 +107097,14 @@ function makePictureToolDefinition() {
|
|
|
107039
107097
|
},
|
|
107040
107098
|
record: {
|
|
107041
107099
|
type: "object",
|
|
107042
|
-
description: "The record's own fields, in the shape the app's records have (its authorHandle the `writesAs` handle list_databases names, its prompt set the way theirs are). Saved through the app's rules before the paint, so no put_doc is needed first."
|
|
107100
|
+
description: "The record's own fields, in the shape the app's records have (its authorHandle the `writesAs` handle list_databases names, its prompt set the way theirs are). Saved through the app's rules before the paint, so no put_doc is needed first. With `like`, only the fields that differ from that record."
|
|
107101
|
+
},
|
|
107102
|
+
like: {
|
|
107103
|
+
type: "string",
|
|
107104
|
+
description: "The _id of one of the app's own records in this database (a list_databases sample's _id): the new record starts as a copy of its fields (its prompt included), written as you, with the time set to now. `record` changes any of them."
|
|
107043
107105
|
}
|
|
107044
107106
|
},
|
|
107045
|
-
required: ["ownerHandle", "appSlug"
|
|
107107
|
+
required: ["ownerHandle", "appSlug"],
|
|
107046
107108
|
additionalProperties: false
|
|
107047
107109
|
}
|
|
107048
107110
|
},
|
|
@@ -107051,6 +107113,49 @@ function makePictureToolDefinition() {
|
|
|
107051
107113
|
}
|
|
107052
107114
|
};
|
|
107053
107115
|
}
|
|
107116
|
+
function likeTemplate(doc, writerHandle, nowMs) {
|
|
107117
|
+
const { _id, _files, ...fields } = doc;
|
|
107118
|
+
const out = { ...fields };
|
|
107119
|
+
if ("authorHandle" in out) out["authorHandle"] = writerHandle;
|
|
107120
|
+
for (const k of ["createdAt", "updatedAt", "created", "updated"]) {
|
|
107121
|
+
const v = out[k];
|
|
107122
|
+
if (typeof v === "number") out[k] = nowMs;
|
|
107123
|
+
else if (typeof v === "string" && !Number.isNaN(Date.parse(v))) out[k] = new Date(nowMs).toISOString();
|
|
107124
|
+
}
|
|
107125
|
+
return out;
|
|
107126
|
+
}
|
|
107127
|
+
async function findPictureTemplate(vctx, o) {
|
|
107128
|
+
const ad = vctx.sql.tables.appDocuments;
|
|
107129
|
+
const rRows = await exception2Result209(
|
|
107130
|
+
() => vctx.sql.db.select({ dbName: ad.dbName, docId: ad.docId, seq: ad.seq }).from(ad).where(and115(eq135(ad.ownerHandle, o.ownerHandle), eq135(ad.appSlug, o.appSlug))).orderBy(desc26(ad.created), desc26(ad.seq)).limit(TEMPLATE_SCAN_ROWS)
|
|
107131
|
+
);
|
|
107132
|
+
if (rRows.isErr()) return Result146.Err("That app's records could not be read just now. Try once more.");
|
|
107133
|
+
const seen = /* @__PURE__ */ new Set();
|
|
107134
|
+
for (const row of rRows.Ok()) {
|
|
107135
|
+
const key = `${row.dbName}\0${row.docId}`;
|
|
107136
|
+
if (seen.has(key) || row.dbName.startsWith("_") || row.dbName.startsWith("media:")) continue;
|
|
107137
|
+
seen.add(key);
|
|
107138
|
+
const rDoc = await exception2Result209(
|
|
107139
|
+
() => getDocForCaller(vctx, {
|
|
107140
|
+
userId: o.writer.userId,
|
|
107141
|
+
ownerHandle: o.ownerHandle,
|
|
107142
|
+
appSlug: o.appSlug,
|
|
107143
|
+
dbName: row.dbName,
|
|
107144
|
+
docId: row.docId,
|
|
107145
|
+
adminMode: false,
|
|
107146
|
+
actingHandle: o.writer.ownerHandle
|
|
107147
|
+
})
|
|
107148
|
+
);
|
|
107149
|
+
if (rDoc.isErr() || rDoc.Ok().kind !== "ok") continue;
|
|
107150
|
+
const doc = rDoc.Ok().doc;
|
|
107151
|
+
if (typeof doc["prompt"] !== "string" || doc["prompt"].trim() === "") continue;
|
|
107152
|
+
const files = typeof doc["_files"] === "object" && doc["_files"] !== null ? Object.keys(doc["_files"]) : [];
|
|
107153
|
+
const photoKey = files.includes("original") ? "original" : files.length === 1 ? files[0] : void 0;
|
|
107154
|
+
const idPrefix = /^([a-z][a-z0-9]*-)/i.exec(row.docId)?.[1] ?? "picture-";
|
|
107155
|
+
return Result146.Ok({ dbName: row.dbName, docId: row.docId, idPrefix, ...photoKey === void 0 ? {} : { photoKey } });
|
|
107156
|
+
}
|
|
107157
|
+
return Result146.Err("That app has no record with a prompt to copy yet. Read it with with_vibe list_databases and name the record.");
|
|
107158
|
+
}
|
|
107054
107159
|
function refusal(reason, message3) {
|
|
107055
107160
|
return { ok: false, reason, message: message3 };
|
|
107056
107161
|
}
|
|
@@ -107328,23 +107433,36 @@ async function keepPhotoOnRecord(vctx, mctx, o) {
|
|
|
107328
107433
|
}
|
|
107329
107434
|
async function makePicture(vctx, mctx, args) {
|
|
107330
107435
|
let prompt = args.prompt;
|
|
107331
|
-
const
|
|
107332
|
-
|
|
107333
|
-
appSlug: args.vibe.appSlug.trim().toLowerCase(),
|
|
107334
|
-
dbName: args.vibe.dbName,
|
|
107335
|
-
docId: args.vibe.docId
|
|
107336
|
-
};
|
|
107337
|
-
if (vibe2 !== void 0 && vibe2.appSlug === AGENT_CHAT_APP_SLUG) {
|
|
107436
|
+
const target2 = args.vibe === void 0 ? void 0 : { ownerHandle: normalHandle(args.vibe.ownerHandle), appSlug: args.vibe.appSlug.trim().toLowerCase() };
|
|
107437
|
+
if (target2 !== void 0 && target2.appSlug === AGENT_CHAT_APP_SLUG) {
|
|
107338
107438
|
return refusal("not-yours", "A conversation's own space is not a vibe. Leave out `vibe` to put the picture in the chat.");
|
|
107339
107439
|
}
|
|
107340
107440
|
let writer = { userId: mctx.actor.userId, ownerHandle: mctx.actor.ownerHandle };
|
|
107341
|
-
if (
|
|
107342
|
-
const resolved = await vibeWriter(vctx, mctx.actor,
|
|
107441
|
+
if (target2 !== void 0) {
|
|
107442
|
+
const resolved = await vibeWriter(vctx, mctx.actor, target2);
|
|
107343
107443
|
if (resolved.ok === false) return resolved;
|
|
107344
107444
|
writer = resolved.writer;
|
|
107345
107445
|
}
|
|
107346
|
-
|
|
107347
|
-
|
|
107446
|
+
let found;
|
|
107447
|
+
if (target2 !== void 0 && args.vibe !== void 0 && args.vibe.dbName === void 0) {
|
|
107448
|
+
const rFound = await findPictureTemplate(vctx, { ...target2, writer });
|
|
107449
|
+
if (rFound.isErr()) return refusal("not-found", rFound.Err().message);
|
|
107450
|
+
const t = rFound.Ok();
|
|
107451
|
+
const photoKey = args.vibe.photoKey ?? t.photoKey;
|
|
107452
|
+
found = {
|
|
107453
|
+
dbName: t.dbName,
|
|
107454
|
+
docId: args.vibe.docId ?? `${t.idPrefix}${crypto.randomUUID()}`,
|
|
107455
|
+
like: args.vibe.like ?? t.docId,
|
|
107456
|
+
...photoKey === void 0 ? {} : { photoKey }
|
|
107457
|
+
};
|
|
107458
|
+
args = { ...args, vibe: { ...args.vibe, ...found } };
|
|
107459
|
+
}
|
|
107460
|
+
if (args.vibe !== void 0 && args.vibe.docId === void 0) {
|
|
107461
|
+
return refusal("invalid-input", "`vibe` names its record with `docId` when it names `dbName`.");
|
|
107462
|
+
}
|
|
107463
|
+
const vibe2 = target2 === void 0 || args.vibe?.dbName === void 0 || args.vibe.docId === void 0 ? void 0 : { ...target2, dbName: args.vibe.dbName, docId: args.vibe.docId };
|
|
107464
|
+
if (vibe2 !== void 0 && (args.vibe?.record !== void 0 || args.vibe?.like !== void 0)) {
|
|
107465
|
+
const { _id: _ignoredId, _files: _ignoredFiles, ...given } = args.vibe.record ?? {};
|
|
107348
107466
|
const at2 = {
|
|
107349
107467
|
userId: writer.userId,
|
|
107350
107468
|
ownerHandle: vibe2.ownerHandle,
|
|
@@ -107356,6 +107474,14 @@ async function makePicture(vctx, mctx, args) {
|
|
|
107356
107474
|
const rHad = await exception2Result209(() => getDocForCaller(vctx, { ...at2, docId: vibe2.docId }));
|
|
107357
107475
|
if (rHad.isErr()) return refusal("failed", "That record could not be read just now. Try once more.");
|
|
107358
107476
|
const had = rHad.Ok().kind === "ok" ? rHad.Ok().doc : {};
|
|
107477
|
+
let liked = {};
|
|
107478
|
+
if (args.vibe.like !== void 0) {
|
|
107479
|
+
const rLike = await exception2Result209(() => getDocForCaller(vctx, { ...at2, docId: args.vibe?.like ?? "" }));
|
|
107480
|
+
if (rLike.isErr()) return refusal("failed", "That record to copy could not be read just now. Try once more.");
|
|
107481
|
+
if (rLike.Ok().kind !== "ok") return refusal("not-found", "No record with that `like` id in this database.");
|
|
107482
|
+
liked = likeTemplate(rLike.Ok().doc, writer.ownerHandle, Date.now());
|
|
107483
|
+
}
|
|
107484
|
+
const fields = { ...liked, ...given };
|
|
107359
107485
|
await reserveImgGenForAgent(vctx, {
|
|
107360
107486
|
ownerHandle: vibe2.ownerHandle,
|
|
107361
107487
|
appSlug: vibe2.appSlug,
|
|
@@ -107582,7 +107708,8 @@ async function makePicture(vctx, mctx, args) {
|
|
|
107582
107708
|
docId: version.docId
|
|
107583
107709
|
},
|
|
107584
107710
|
link: `/vibe/${vibe2.ownerHandle}/${vibe2.appSlug}`,
|
|
107585
|
-
made: { prompt, model: painted2.model }
|
|
107711
|
+
made: { prompt, model: painted2.model },
|
|
107712
|
+
...found === void 0 ? {} : { record: found }
|
|
107586
107713
|
};
|
|
107587
107714
|
}
|
|
107588
107715
|
vctx.logger.Warn().Str("chatId", mctx.chatId).Bool("written", written !== false).Msg("make_picture: vibe did not take it, kept in ~agent");
|
|
@@ -107687,7 +107814,7 @@ function createMakePictureTool(vctx, deps) {
|
|
|
107687
107814
|
function answer4(o) {
|
|
107688
107815
|
return Result146.Ok(JSON.stringify(o));
|
|
107689
107816
|
}
|
|
107690
|
-
var AGENT_PICTURES_DB_NAME, MAKE_PICTURE_PROMPT_MAX, INPUT_IMAGE_EDGE, MAKE_PICTURE_DEADLINE_MS, recordRef, makePictureInput;
|
|
107817
|
+
var AGENT_PICTURES_DB_NAME, MAKE_PICTURE_PROMPT_MAX, INPUT_IMAGE_EDGE, MAKE_PICTURE_DEADLINE_MS, recordRef, makePictureInput, TEMPLATE_SCAN_ROWS;
|
|
107691
107818
|
var init_agent_make_picture_tool = __esm({
|
|
107692
107819
|
"../vibes.diy/api/svc/intern/agent-make-picture-tool.ts"() {
|
|
107693
107820
|
"use strict";
|
|
@@ -107730,10 +107857,21 @@ var init_agent_make_picture_tool = __esm({
|
|
|
107730
107857
|
"photo?": "number.integer >= 1",
|
|
107731
107858
|
"earlierPhoto?": "number.integer >= 1",
|
|
107732
107859
|
"sourceRecord?": type141({ ...recordRef, "fileKey?": "string" }).onUndeclaredKey("reject"),
|
|
107733
|
-
"vibe?": type141({
|
|
107860
|
+
"vibe?": type141({
|
|
107861
|
+
ownerHandle: "string > 0",
|
|
107862
|
+
appSlug: "string > 0",
|
|
107863
|
+
"dbName?": "string > 0",
|
|
107864
|
+
"docId?": "string > 0",
|
|
107865
|
+
"photoKey?": "string > 0",
|
|
107866
|
+
"record?": "Record<string, unknown>",
|
|
107867
|
+
"like?": "string > 0"
|
|
107868
|
+
}).onUndeclaredKey("reject")
|
|
107734
107869
|
}).onUndeclaredKey("reject")
|
|
107735
107870
|
);
|
|
107736
107871
|
__name(makePictureToolDefinition, "makePictureToolDefinition");
|
|
107872
|
+
__name(likeTemplate, "likeTemplate");
|
|
107873
|
+
TEMPLATE_SCAN_ROWS = 60;
|
|
107874
|
+
__name(findPictureTemplate, "findPictureTemplate");
|
|
107737
107875
|
__name(refusal, "refusal");
|
|
107738
107876
|
__name(checkMakePictureArgs, "checkMakePictureArgs");
|
|
107739
107877
|
__name(normalHandle, "normalHandle");
|
|
@@ -115772,7 +115910,7 @@ var init_push_mint_look = __esm({
|
|
|
115772
115910
|
|
|
115773
115911
|
// ../vibes.diy/api/svc/intern/push-skin-look.ts
|
|
115774
115912
|
import { exception2Result as exception2Result232 } from "@adviser/cement";
|
|
115775
|
-
import { and as and121, desc as
|
|
115913
|
+
import { and as and121, desc as desc27, eq as eq142, lt as lt11 } from "drizzle-orm";
|
|
115776
115914
|
async function planPushSkinLook(vctx, args) {
|
|
115777
115915
|
const skins = sourceSkinLooks(args.sources).map((p) => p.id);
|
|
115778
115916
|
if (skins.length === 0) return void 0;
|
|
@@ -115812,7 +115950,7 @@ async function missedSkinLook(vctx, args) {
|
|
|
115812
115950
|
eq142(vctx.sql.tables.apps.mode, "production"),
|
|
115813
115951
|
lt11(vctx.sql.tables.apps.releaseSeq, args.previous.releaseSeq)
|
|
115814
115952
|
)
|
|
115815
|
-
).orderBy(
|
|
115953
|
+
).orderBy(desc27(vctx.sql.tables.apps.releaseSeq)).limit(1).then((r) => r[0]);
|
|
115816
115954
|
if (before === void 0) return void 0;
|
|
115817
115955
|
const inBefore = sourceSkinLooks(await releaseSources(vctx, before.fsId)).map((p) => p.id);
|
|
115818
115956
|
return candidates.find((p) => inBefore.includes(p.id) === false);
|
|
@@ -115852,7 +115990,7 @@ var init_push_skin_look = __esm({
|
|
|
115852
115990
|
// ../vibes.diy/api/svc/intern/seed-starter-chips.ts
|
|
115853
115991
|
import { exception2Result as exception2Result233, Result as Result164 } from "@adviser/cement";
|
|
115854
115992
|
import { and as and122, eq as eq143 } from "drizzle-orm/sql/expressions";
|
|
115855
|
-
import { desc as
|
|
115993
|
+
import { desc as desc28 } from "drizzle-orm";
|
|
115856
115994
|
function buildStarterChipSeedBlocks(opts) {
|
|
115857
115995
|
const now3 = opts.timestamp ?? /* @__PURE__ */ new Date();
|
|
115858
115996
|
const base = { blockId: opts.blockId, streamId: opts.streamId, blockNr: 0, timestamp: now3 };
|
|
@@ -115897,7 +116035,7 @@ async function seedStarterChips(vctx, opts) {
|
|
|
115897
116035
|
if (opts.chips.length === 0) return Result164.Err("seedStarterChips: no chips to seed");
|
|
115898
116036
|
const ctxRows = await vctx.sql.db.select({ chatId: vctx.sql.tables.chatContexts.chatId }).from(vctx.sql.tables.chatContexts).where(
|
|
115899
116037
|
and122(eq143(vctx.sql.tables.chatContexts.ownerHandle, opts.ownerHandle), eq143(vctx.sql.tables.chatContexts.appSlug, opts.appSlug))
|
|
115900
|
-
).orderBy(
|
|
116038
|
+
).orderBy(desc28(vctx.sql.tables.chatContexts.created)).limit(1);
|
|
115901
116039
|
const chatId = ctxRows[0]?.chatId;
|
|
115902
116040
|
if (!chatId) {
|
|
115903
116041
|
return Result164.Err(`seedStarterChips: no chat context for ${opts.ownerHandle}/${opts.appSlug} (push the vibe first)`);
|
|
@@ -118259,7 +118397,7 @@ var init_agent_discussions = __esm({
|
|
|
118259
118397
|
});
|
|
118260
118398
|
|
|
118261
118399
|
// ../vibes.diy/api/svc/intern/ensure-chat-id.ts
|
|
118262
|
-
import { and as and131, desc as
|
|
118400
|
+
import { and as and131, desc as desc29, eq as eq153 } from "drizzle-orm/sql/expressions";
|
|
118263
118401
|
import { exception2Result as exception2Result244, Result as Result171 } from "@adviser/cement";
|
|
118264
118402
|
import { sha256 as sha25611 } from "@noble/hashes/sha2.js";
|
|
118265
118403
|
import { bytesToHex as bytesToHex5, utf8ToBytes as utf8ToBytes7 } from "@noble/hashes/utils.js";
|
|
@@ -118296,7 +118434,7 @@ async function dryRunResolveChatId(ctx, req2) {
|
|
|
118296
118434
|
ownerHandle = defaultBinding.ownerHandle;
|
|
118297
118435
|
} else {
|
|
118298
118436
|
const rFirst = await exception2Result244(
|
|
118299
|
-
() => ctx.sql.db.select({ handle: ctx.sql.tables.handleBinding.handle }).from(ctx.sql.tables.handleBinding).where(eq153(ctx.sql.tables.handleBinding.userId, userId)).orderBy(
|
|
118437
|
+
() => ctx.sql.db.select({ handle: ctx.sql.tables.handleBinding.handle }).from(ctx.sql.tables.handleBinding).where(eq153(ctx.sql.tables.handleBinding.userId, userId)).orderBy(desc29(ctx.sql.tables.handleBinding.created)).limit(1).then((r) => r[0])
|
|
118300
118438
|
);
|
|
118301
118439
|
ownerHandle = rFirst.isOk() && rFirst.Ok() ? rFirst.Ok().handle : DRY_RUN_PLACEHOLDER_HANDLE;
|
|
118302
118440
|
}
|
|
@@ -119020,13 +119158,13 @@ var init_turn_initiator = __esm({
|
|
|
119020
119158
|
});
|
|
119021
119159
|
|
|
119022
119160
|
// ../vibes.diy/api/svc/intern/chat-history-page.ts
|
|
119023
|
-
import { and as and132, desc as
|
|
119161
|
+
import { and as and132, desc as desc30, eq as eq155, inArray as inArray42, isNotNull as isNotNull6, lt as lt12, ne as ne19, or as or15, sql as sql26 } from "drizzle-orm";
|
|
119024
119162
|
async function selectChatHistoryPage(vctx, args) {
|
|
119025
119163
|
const t = vctx.sql.tables.chatSections;
|
|
119026
119164
|
const created = sql26`min(${t.created})`;
|
|
119027
119165
|
const rows = await vctx.sql.db.select({ promptId: t.promptId, created }).from(t).where(and132(eq155(t.chatId, args.chatId), ne19(t.blockSeq, RESEARCH_BLOCK_SEQ))).groupBy(t.promptId).having(
|
|
119028
119166
|
args.before === void 0 ? void 0 : or15(lt12(created, args.before.created), and132(eq155(created, args.before.created), lt12(t.promptId, args.before.promptId)))
|
|
119029
|
-
).orderBy(
|
|
119167
|
+
).orderBy(desc30(created), desc30(t.promptId)).limit(args.limit + 1);
|
|
119030
119168
|
const page = rows.slice(0, args.limit);
|
|
119031
119169
|
const before = page.at(-1);
|
|
119032
119170
|
return {
|
|
@@ -119039,7 +119177,7 @@ async function initialChatHistoryPage(vctx, args) {
|
|
|
119039
119177
|
const t = vctx.sql.tables;
|
|
119040
119178
|
const [active, latestBuild] = await Promise.all([
|
|
119041
119179
|
vctx.sql.db.select({ promptId: t.openTurns.promptId }).from(t.openTurns).where(and132(eq155(t.openTurns.chatId, args.chatId), eq155(t.openTurns.status, "open"))),
|
|
119042
|
-
vctx.sql.db.select({ promptId: t.promptContexts.promptId }).from(t.promptContexts).where(and132(eq155(t.promptContexts.chatId, args.chatId), isNotNull6(t.promptContexts.fsId), ne19(t.promptContexts.fsId, ""))).orderBy(
|
|
119180
|
+
vctx.sql.db.select({ promptId: t.promptContexts.promptId }).from(t.promptContexts).where(and132(eq155(t.promptContexts.chatId, args.chatId), isNotNull6(t.promptContexts.fsId), ne19(t.promptContexts.fsId, ""))).orderBy(desc30(t.promptContexts.created), desc30(t.promptContexts.promptId)).limit(1)
|
|
119043
119181
|
]);
|
|
119044
119182
|
return {
|
|
119045
119183
|
history: page.history,
|
|
@@ -120035,7 +120173,7 @@ var init_manifest_assets_line = __esm({
|
|
|
120035
120173
|
// ../vibes.diy/api/svc/intern/load-research-context.ts
|
|
120036
120174
|
import { exception2Result as exception2Result248 } from "@adviser/cement";
|
|
120037
120175
|
import { type as type153 } from "arktype";
|
|
120038
|
-
import { desc as
|
|
120176
|
+
import { desc as desc31, and as and135, eq as eq159 } from "drizzle-orm/sql/expressions";
|
|
120039
120177
|
function escapeResearchDelimiters(value) {
|
|
120040
120178
|
return value.replaceAll(RESEARCH_CONTEXT_OPEN_DELIMITER, "[escaped web delimiter]").replaceAll(RESEARCH_CONTEXT_CLOSE_DELIMITER, "[escaped web delimiter]");
|
|
120041
120179
|
}
|
|
@@ -120125,7 +120263,7 @@ async function loadResearchContextMessages(vctx, args) {
|
|
|
120125
120263
|
return exception2Result248(async () => {
|
|
120126
120264
|
const t = vctx.sql.tables.chatSections;
|
|
120127
120265
|
const chats = vctx.sql.tables.chatContexts;
|
|
120128
|
-
const rows = await vctx.sql.db.select({ blocks: t.blocks, promptId: t.promptId }).from(chats).innerJoin(t, eq159(t.chatId, chats.chatId)).where(and135(eq159(chats.userId, args.userId), eq159(chats.chatId, args.chatId), eq159(t.blockSeq, RESEARCH_BLOCK_SEQ))).orderBy(
|
|
120266
|
+
const rows = await vctx.sql.db.select({ blocks: t.blocks, promptId: t.promptId }).from(chats).innerJoin(t, eq159(t.chatId, chats.chatId)).where(and135(eq159(chats.userId, args.userId), eq159(chats.chatId, args.chatId), eq159(t.blockSeq, RESEARCH_BLOCK_SEQ))).orderBy(desc31(t.created), desc31(t.promptId));
|
|
120129
120267
|
const seenResearchIds = /* @__PURE__ */ new Set();
|
|
120130
120268
|
const selected = [];
|
|
120131
120269
|
for (const row of rows) {
|
|
@@ -128008,7 +128146,7 @@ var init_agent_file_rebase = __esm({
|
|
|
128008
128146
|
|
|
128009
128147
|
// ../vibes.diy/api/svc/public/fs-prompt.ts
|
|
128010
128148
|
import { Result as Result197 } from "@adviser/cement";
|
|
128011
|
-
import { and as and143, desc as
|
|
128149
|
+
import { and as and143, desc as desc32, eq as eq168 } from "drizzle-orm/sql/expressions";
|
|
128012
128150
|
async function handleFSPrompt({
|
|
128013
128151
|
scope: scope2,
|
|
128014
128152
|
vctx,
|
|
@@ -128035,13 +128173,13 @@ async function handleFSPrompt({
|
|
|
128035
128173
|
eq168(vctx.sql.tables.apps.ownerHandle, resChat.ownerHandle),
|
|
128036
128174
|
eq168(vctx.sql.tables.apps.appSlug, resChat.appSlug)
|
|
128037
128175
|
)
|
|
128038
|
-
).orderBy(
|
|
128176
|
+
).orderBy(desc32(vctx.sql.tables.apps.releaseSeq)).limit(1).then((r) => r[0]);
|
|
128039
128177
|
if (!refApp) {
|
|
128040
128178
|
throw new Error(`fs-update refFsId ${req2.refFsId} is not a release of ${resChat.ownerHandle}/${resChat.appSlug}`);
|
|
128041
128179
|
}
|
|
128042
128180
|
baseItems = refApp.fileSystem;
|
|
128043
128181
|
} else {
|
|
128044
|
-
const lastestPrompt = await vctx.sql.db.select().from(vctx.sql.tables.promptContexts).innerJoin(vctx.sql.tables.apps, eq168(vctx.sql.tables.apps.fsId, vctx.sql.tables.promptContexts.fsId)).where(eq168(vctx.sql.tables.promptContexts.chatId, req2.chatId)).orderBy(
|
|
128182
|
+
const lastestPrompt = await vctx.sql.db.select().from(vctx.sql.tables.promptContexts).innerJoin(vctx.sql.tables.apps, eq168(vctx.sql.tables.apps.fsId, vctx.sql.tables.promptContexts.fsId)).where(eq168(vctx.sql.tables.promptContexts.chatId, req2.chatId)).orderBy(desc32(vctx.sql.tables.promptContexts.created)).limit(1).then((r) => r[0]);
|
|
128045
128183
|
baseItems = lastestPrompt?.Apps.fileSystem;
|
|
128046
128184
|
const liveRelease = await selectLatestAppPerSlug(vctx, {
|
|
128047
128185
|
ownerHandle: resChat.ownerHandle,
|
|
@@ -129187,7 +129325,7 @@ var init_agent_imessage_tools = __esm({
|
|
|
129187
129325
|
|
|
129188
129326
|
// ../vibes.diy/api/svc/intern/operator-hotfix.ts
|
|
129189
129327
|
import { exception2Result as exception2Result274 } from "@adviser/cement";
|
|
129190
|
-
import { and as and146, desc as
|
|
129328
|
+
import { and as and146, desc as desc33, eq as eq171 } from "drizzle-orm/sql/expressions";
|
|
129191
129329
|
function hotfixRulesOf(data) {
|
|
129192
129330
|
if (typeof data !== "object" || data === null) return [];
|
|
129193
129331
|
const d = data;
|
|
@@ -129204,7 +129342,7 @@ async function readFresh(vctx) {
|
|
|
129204
129342
|
eq171(t.dbName, HOTFIX_ADDRESS.dbName),
|
|
129205
129343
|
eq171(t.docId, HOTFIX_ADDRESS.docId)
|
|
129206
129344
|
)
|
|
129207
|
-
).orderBy(
|
|
129345
|
+
).orderBy(desc33(t.seq)).limit(1).then((r) => r[0]);
|
|
129208
129346
|
if (row === void 0 || row.deleted === 1) return [];
|
|
129209
129347
|
const rules = hotfixRulesOf(typeof row.data === "string" ? JSON.parse(row.data) : row.data);
|
|
129210
129348
|
if (rules.length === 0) return [];
|
|
@@ -129446,7 +129584,7 @@ A TEXT CONVERSATION. This conversation is a text thread. The person may be readi
|
|
|
129446
129584
|
- Say it, then do it. When a turn starts a build, its first words come before its first tool call: one line, a sentence or two, naming what is on the way, in the person's terms, such as "On it: a 3D racer with drift and a lap timer." or "On it: your own copy of Cabin Weekend, a cost splitter." Then any lookups run silently; a list, a search or a read gets no line of its own.
|
|
129447
129585
|
- One message, sometimes in two texts. Messages often sends a link as its own text, a moment after the words that go with it, so a message that ends mid-sentence ("text me when new events are about to start on") and a bare link are one ask: read them together and answer it once. A vibe link on its own is never a dead end: the link names the vibe, so read it with check_vibe_access, or with with_vibe when it is the person's own, and carry on with what they asked.
|
|
129448
129586
|
- One thought, several texts. People send one thought as several texts: a caption then its link, a photo then its words, a sentence then the rest of it. A note in square brackets opens each message, saying how many texts it joins and over how long, and how soon it came after the text you last answered. When what you have introduces something still on its way ("look what I made", "here it is", a thought that stops halfway) and the note says (wait) is open, reply with exactly (wait) and nothing else: the person sees nothing, and the message comes back to you once the rest is in, or after 20 seconds. Wait once per message at most. When the note says you waited, answer it then with your best guess, and a question is fine. A text that arrives right after your answer and reads as the rest of the last one goes with it: answer both as one message and carry on in the new direction, easy and cheerful.
|
|
129449
|
-
- Pictures travel both ways. A photo the person sends is in front of you. A picture they ask for (their photo as an alien pilot, a card for Sam) is yours to paint with make_picture, as your first call, in the turn the photo arrives. \`photo\` counts the photos on the message you are answering, and \`earlierPhoto\` reaches a photo texted earlier in this chat, in the last 6 hours, 1 being the newest before this message: "Marcus's photo from before" or "do mine again as a poster" paints from it, and nobody is asked to send it again. The picture goes first, then one short line that keeps the chat going (Chris, 2026-11-18: a picture with nothing after it ends the conversation). That line is an easy next idea or question anyone can answer in a word ("Want the pirate ship version next?", "Should I do everyone?"), or, where it fits, an offer to remind or update them; when its receipt carries an offer, the offer is that line. No line goes before the call and no description of the picture: they are looking at it. When a tool failed, the line says that instead. Paint once per ask. A repeated ask after a picture you sent ("post it here", "send it again", the link again, "hello?") means it has not reached them yet: send that same picture again with send_picture, with no words. A picture travels only as a picture, so a picture's file address (an assets. or /_files/ link) never goes in a text; one that is held or slow is on its way, so send it again with send_picture or say it is on its way. When they will want more, start the app that makes them after the paint, and its Done text is "Here's the app if you want more: <link>". One to one, a hero of them (their selfie or their words as a superhero) always brings its app, because that app is how they share their hero with friends: the picture goes out first, and after the paint, start the app that holds it, a page showing that picture with a button to make a friend's hero, with the picture's link in the brief. Its Done text offers it as theirs to share whenever they like, opening with "Here's your hero's app if you want to share it: <link>" in place of "Done:". A hero is the one picture with words before it. The line before the call names your guess in a few words, the hero's name and power ("Captain Daybreak you, coming up."). A photo that never reached you ("did you get my pic?") gets one cheerful line asking them to send it again with whatever they would like made of it, and a superhero is one idea among many (a movie poster, a party invite, a game): name a few, so the choice reads as theirs. A vibe named for pictures is this chat's picture app. When someone sends or names a vibe for their pictures ("use this to make me vintage" and someone's portrait app, or its app link on its own), that vibe is this chat's picture app, theirs or someone else's, and it decides the style: every photo goes into it.
|
|
129587
|
+
- Pictures travel both ways. A photo the person sends is in front of you. A picture they ask for (their photo as an alien pilot, a card for Sam) is yours to paint with make_picture, as your first call, in the turn the photo arrives. \`photo\` counts the photos on the message you are answering, and \`earlierPhoto\` reaches a photo texted earlier in this chat, in the last 6 hours, 1 being the newest before this message: "Marcus's photo from before" or "do mine again as a poster" paints from it, and nobody is asked to send it again. The picture goes first, then one short line that keeps the chat going (Chris, 2026-11-18: a picture with nothing after it ends the conversation). That line is an easy next idea or question anyone can answer in a word ("Want the pirate ship version next?", "Should I do everyone?"), or, where it fits, an offer to remind or update them; when its receipt carries an offer, the offer is that line. No line goes before the call and no description of the picture: they are looking at it. When a tool failed, the line says that instead. Paint once per ask. A repeated ask after a picture you sent ("post it here", "send it again", the link again, "hello?") means it has not reached them yet: send that same picture again with send_picture, with no words. A picture travels only as a picture, so a picture's file address (an assets. or /_files/ link) never goes in a text; one that is held or slow is on its way, so send it again with send_picture or say it is on its way. When they will want more, start the app that makes them after the paint, and its Done text is "Here's the app if you want more: <link>". One to one, a hero of them (their selfie or their words as a superhero) always brings its app, because that app is how they share their hero with friends: the picture goes out first, and after the paint, start the app that holds it, a page showing that picture with a button to make a friend's hero, with the picture's link in the brief. Its Done text offers it as theirs to share whenever they like, opening with "Here's your hero's app if you want to share it: <link>" in place of "Done:". A hero is the one picture with words before it. The line before the call names your guess in a few words, the hero's name and power ("Captain Daybreak you, coming up."). A photo that never reached you ("did you get my pic?") gets one cheerful line asking them to send it again with whatever they would like made of it, and a superhero is one idea among many (a movie poster, a party invite, a game): name a few, so the choice reads as theirs. A vibe named for pictures is this chat's picture app. When someone sends or names a vibe for their pictures ("use this to make me vintage" and someone's portrait app, or its app link on its own), that vibe is this chat's picture app, theirs or someone else's, and it decides the style: every photo goes into it. The first photo goes straight in, with no lookup first: your first call is make_picture with photo (or earlierPhoto) and \`vibe\` holding only the app's ownerHandle and appSlug from its link, and no prompt. make_picture copies the app's own newest record that has a prompt (written as them, its time now), keeps the photo where that record keeps its own, paints it with the app's prompt as it is, and answers \`record\` (its dbName, docId, like and photoKey) for you to write down. A later ask that changes the look ("now as pirates", "add a cocktail") names the record: make_picture with \`vibe\` holding that dbName, a new docId, \`like\` and \`photoKey\`, and the changed prompt in \`vibe.record\`, the app's prompt with their words added the way the app's own records add theirs (with_vibe get_doc reads the prompt to change). When make_picture answers that the app has no record to copy, learn its shape from one with_vibe list_databases call (its \`samples\` holds a record of each collection) and name the record with \`vibe.like\` or \`vibe.record\`, and \`vibe.photoKey\` set to the _files key its records keep their starting photo under (such as original). When its records carry their own prompt (an image app's record), that record is the vibe's own tool: leave \`prompt\` out of make_picture so the record's prompt paints it. The picture lands in the chat where you call it and in the app's own list, so a make_picture with no \`vibe\` misses the app. After the paint, write the picture app down with remember (which vibe, its database, its photo key, and the record to copy with \`like\`: the one you just made), and every later photo in the chat goes through it the same way, copying that record; when the look changes, the record that carries the new look becomes the one to copy, and you write that down too, with no link needed and no words, until someone names another vibe or asks for something else, which you also write down. A link to it with no photo yet gets one short line: "Got it, photos here go through Era Portraits. Send one." A link to one record of a vibe, its address ending in #<key>=<id> (https://vibes.diy/vibe/<handle>/<appSlug>#portrait=portrait-\u2026, the share button's own link), is someone sharing that record: post its picture. Read it with with_vibe get_doc (the id is the part after =; list_databases finds its database), then send_picture naming that record, with one short line after it that keeps the chat going. Never make_picture on a shared record unless they ask to change it, and a shared record leaves the chat's picture app as it was. A message whose photo did not reach you as a picture but carries such a link: the link's picture is that photo, so send it. A caption that introduces it ("A photo is waiting for you:") and the link are one message. Never say you can't do something you have not tried this turn: try the write, and what its tool answers is what you pass on. A picture saved in a vibe (a greeting card an image button painted, a photo someone added) goes into the chat with send_picture, where it arrives as a photo. Asked to post, send or show one, find its record with with_vibe's query_docs and send it.
|
|
129450
129588
|
- Keep the thread going. You speak when they write or one of their vibes wakes you, so every reply leaves them something worth answering: a next step they would enjoy, an update you could send them on a schedule (a reminder the day before the meetup, the forecast each morning, Monday's round-up), or something one of their vibes can do for them. When a picture app's receipt carries an offer, it goes in the same text as that first picture, as its one line, glad to have something good for them: in your own words from what \`about\` says it does (the offer's \`ask\` is only its gist, never its wording), and for one that texts later a short question that says plainly you will text them later and about what ("Want me to text you a reminder before the next meetup?"), promising only what its tool does. Ask it once. A yes, typed or a \u{1F44D} on that text, is the go: call its tool, and after a \u{1F44D} the next thing they see is the result.
|
|
129451
129589
|
- Plain text, in short messages. Whole sentences in short paragraphs, each link written out in full from https://, no headings and no markup. A bit's wink is the one pair of stars a text carries. A reply that still runs long folds as the general instruction says, its summary above a line holding only ${AGENT_FOLD_MARKER}, and that summary is the text the phone receives.
|
|
129452
129590
|
- Their words, not the machinery. Say what happened for them, in their terms. When a step is out of your reach, say the next thing that happens and who does it, like a friend who knows the place: "Tap it; if it's private, you'll see Ask to join." Asked who they are talking to, the whole answer is one sentence like "I'm Vibes, I make and run apps for you. What's on your plate?" Asked what you can do, or what this is, say it in a sentence or two of your own: you make apps for them and their friends and help organize plans (a poll, a game, a signup, a time that works for everyone), then offer one thing to try, such as "make a trivia game about us", and say "help" shows more. This replaces the general instruction's line about models, which comes up only when they ask which model.
|
|
@@ -130071,7 +130209,7 @@ var init_home_feed_common = __esm({
|
|
|
130071
130209
|
import { exception2Result as exception2Result276, Result as Result205, stream2uint8array as stream2uint8array13 } from "@adviser/cement";
|
|
130072
130210
|
import { bytesToHex as bytesToHex6, utf8ToBytes as utf8ToBytes8 } from "@noble/hashes/utils.js";
|
|
130073
130211
|
import { sha256 as sha25612 } from "@noble/hashes/sha2.js";
|
|
130074
|
-
import { and as and148, desc as
|
|
130212
|
+
import { and as and148, desc as desc34, eq as eq173, ne as ne22, or as or17 } from "drizzle-orm/sql/expressions";
|
|
130075
130213
|
function embeddingsUrl(backendUrl) {
|
|
130076
130214
|
const suffix = "/chat/completions";
|
|
130077
130215
|
if (backendUrl.endsWith(suffix)) {
|
|
@@ -131014,7 +131152,7 @@ var init_agent_build_tools = __esm({
|
|
|
131014
131152
|
|
|
131015
131153
|
// ../vibes.diy/api/svc/public/lookup-handles.ts
|
|
131016
131154
|
import { Result as Result210, Option as Option42, EventoResult as EventoResult36 } from "@adviser/cement";
|
|
131017
|
-
import { and as and149, eq as eq175, inArray as inArray47, like as like7, or as or18, asc as asc15, desc as
|
|
131155
|
+
import { and as and149, eq as eq175, inArray as inArray47, like as like7, or as or18, asc as asc15, desc as desc35 } from "drizzle-orm";
|
|
131018
131156
|
async function collectKnownHandles(vctx, userId) {
|
|
131019
131157
|
const t = vctx.sql.tables;
|
|
131020
131158
|
const known = /* @__PURE__ */ new Set();
|
|
@@ -131077,7 +131215,7 @@ async function collectKnownHandles(vctx, userId) {
|
|
|
131077
131215
|
}, "addPair");
|
|
131078
131216
|
for (const row of [...memberInvites, ...memberRequests]) addPair(row.ownerHandle, row.appSlug);
|
|
131079
131217
|
if (myHandles.length > 0 && pairs.size < KNOWN_APPS_CAP) {
|
|
131080
|
-
const ownedApps = await vctx.sql.db.select({ ownerHandle: t.appSlugBinding.ownerHandle, appSlug: t.appSlugBinding.appSlug }).from(t.appSlugBinding).where(inArray47(t.appSlugBinding.ownerHandle, myHandles)).orderBy(
|
|
131218
|
+
const ownedApps = await vctx.sql.db.select({ ownerHandle: t.appSlugBinding.ownerHandle, appSlug: t.appSlugBinding.appSlug }).from(t.appSlugBinding).where(inArray47(t.appSlugBinding.ownerHandle, myHandles)).orderBy(desc35(t.appSlugBinding.updated)).limit(KNOWN_APPS_CAP);
|
|
131081
131219
|
for (const row of ownedApps) addPair(row.ownerHandle, row.appSlug);
|
|
131082
131220
|
}
|
|
131083
131221
|
const pairConds = [...pairs.values()].map(
|
|
@@ -131087,16 +131225,16 @@ async function collectKnownHandles(vctx, userId) {
|
|
|
131087
131225
|
const [firstCond, ...restConds] = pairConds;
|
|
131088
131226
|
const outputRows = await vctx.sql.db.select({ output: t.accessFnOutputs.output }).from(t.accessFnOutputs).where(and149(eq175(t.accessFnOutputs.hasGrants, 1), restConds.length === 0 ? firstCond : or18(firstCond, ...restConds)));
|
|
131089
131227
|
for (const row of outputRows) {
|
|
131090
|
-
let
|
|
131228
|
+
let desc61;
|
|
131091
131229
|
try {
|
|
131092
|
-
|
|
131230
|
+
desc61 = JSON.parse(row.output);
|
|
131093
131231
|
} catch {
|
|
131094
131232
|
continue;
|
|
131095
131233
|
}
|
|
131096
|
-
for (const users of Object.values(
|
|
131234
|
+
for (const users of Object.values(desc61.members ?? {})) {
|
|
131097
131235
|
for (const u of users) if (u.startsWith(INVITE_SUBJECT_PREFIX2) === false) known.add(u);
|
|
131098
131236
|
}
|
|
131099
|
-
for (const u of Object.keys(
|
|
131237
|
+
for (const u of Object.keys(desc61.grant?.users ?? {})) if (u.startsWith(INVITE_SUBJECT_PREFIX2) === false) known.add(u);
|
|
131100
131238
|
}
|
|
131101
131239
|
}
|
|
131102
131240
|
return known;
|
|
@@ -131513,7 +131651,7 @@ var init_authorize_slug_owner = __esm({
|
|
|
131513
131651
|
import { Result as Result212, Option as Option43, EventoResult as EventoResult37, exception2Result as exception2Result281 } from "@adviser/cement";
|
|
131514
131652
|
import { type as type165 } from "arktype";
|
|
131515
131653
|
import { and as and151, eq as eq177, gt as gt17, gte as gte6 } from "drizzle-orm/sql/expressions";
|
|
131516
|
-
import { asc as asc16, desc as
|
|
131654
|
+
import { asc as asc16, desc as desc36 } from "drizzle-orm";
|
|
131517
131655
|
async function authorized(vctx, args) {
|
|
131518
131656
|
const auth = await authorizeSlugOwner(vctx, args);
|
|
131519
131657
|
if (auth === void 0) return false;
|
|
@@ -131641,7 +131779,7 @@ var init_app_logs = __esm({
|
|
|
131641
131779
|
let latestTs;
|
|
131642
131780
|
if (req2.probeLatest === true && events.length === 0) {
|
|
131643
131781
|
const rLatest = await exception2Result281(
|
|
131644
|
-
async () => vctx.sql.db.select({ ts: t.ts }).from(t).where(and151(eq177(t.ownerHandle, req2.ownerHandle), eq177(t.appSlug, req2.appSlug))).orderBy(
|
|
131782
|
+
async () => vctx.sql.db.select({ ts: t.ts }).from(t).where(and151(eq177(t.ownerHandle, req2.ownerHandle), eq177(t.appSlug, req2.appSlug))).orderBy(desc36(t.id)).limit(1)
|
|
131645
131783
|
);
|
|
131646
131784
|
if (rLatest.isErr()) {
|
|
131647
131785
|
console.error("app-logs latest probe failed", { ownerHandle: req2.ownerHandle, appSlug: req2.appSlug }, rLatest.Err());
|
|
@@ -135646,36 +135784,60 @@ function createVibeToolInnerExecutor(host, target2) {
|
|
|
135646
135784
|
const listed = rListed.isOk() ? rListed.Ok().find((t) => t.name === toolName) : void 0;
|
|
135647
135785
|
const wireName = vibeToolWireName(target2.appSlug, toolName);
|
|
135648
135786
|
if (listed === void 0) return json2(vibeToolCallAnswer(wireName, { reason: "no_tool" }));
|
|
135787
|
+
let runAs = {
|
|
135788
|
+
callerUserId: target2.callerUserId,
|
|
135789
|
+
...target2.payerUserId === void 0 ? {} : { payerUserId: target2.payerUserId }
|
|
135790
|
+
};
|
|
135649
135791
|
if (isTextLaterOffer(listed)) {
|
|
135650
|
-
const
|
|
135651
|
-
if (
|
|
135792
|
+
const yes = await recordTextLaterYes({ host, target: target2, wireName, toolName });
|
|
135793
|
+
if (yes.ok === false) return json2(yes.refusal);
|
|
135794
|
+
if (yes.runsAs !== void 0) runAs = { callerUserId: yes.runsAs, payerUserId: target2.payerUserId ?? target2.callerUserId };
|
|
135652
135795
|
}
|
|
135653
135796
|
const outcome = await host.call({
|
|
135654
135797
|
ownerHandle: target2.ownerHandle,
|
|
135655
135798
|
appSlug: target2.appSlug,
|
|
135656
|
-
callerUserId: target2.callerUserId,
|
|
135657
135799
|
toolName,
|
|
135658
135800
|
input: args.input ?? {},
|
|
135659
|
-
...
|
|
135801
|
+
...runAs
|
|
135660
135802
|
});
|
|
135661
135803
|
return json2(vibeToolCallAnswer(wireName, outcome));
|
|
135662
135804
|
}
|
|
135663
135805
|
return Result227.Err(`not a vibe-tool call: ${input.call.name}`);
|
|
135664
135806
|
};
|
|
135665
135807
|
}
|
|
135666
|
-
async function recordTextLaterYes(
|
|
135808
|
+
async function recordTextLaterYes({
|
|
135809
|
+
host,
|
|
135810
|
+
target: target2,
|
|
135811
|
+
wireName,
|
|
135812
|
+
toolName
|
|
135813
|
+
}) {
|
|
135814
|
+
const refuse16 = /* @__PURE__ */ __name((refusal5) => ({ ok: false, refusal: refusal5 }), "refuse");
|
|
135667
135815
|
const consent = target2.textLater;
|
|
135668
135816
|
if (consent === void 0) {
|
|
135669
|
-
return {
|
|
135817
|
+
return refuse16({
|
|
135670
135818
|
ok: false,
|
|
135671
135819
|
reason: "no-consent-record",
|
|
135672
135820
|
tool: wireName,
|
|
135673
135821
|
message: "This tool texts the person later, and their yes can't be recorded here, so it did not run. Nothing was done."
|
|
135674
|
-
};
|
|
135822
|
+
});
|
|
135675
135823
|
}
|
|
135676
135824
|
const rWho = await exception2Result295(() => consent.speaker());
|
|
135677
135825
|
const who = rWho.isOk() ? rWho.Ok() : { ok: false, message: "Could not tell who said yes just now, so the tool did not run. Nothing was done." };
|
|
135678
|
-
if (who.ok === false) return { ok: false, reason: "no-speaker", tool: wireName, message: who.message };
|
|
135826
|
+
if (who.ok === false) return refuse16({ ok: false, reason: "no-speaker", tool: wireName, message: who.message });
|
|
135827
|
+
const runsAs = who.runsAsSpeaker === true && who.userId !== target2.callerUserId ? who.userId : void 0;
|
|
135828
|
+
if (runsAs !== void 0) {
|
|
135829
|
+
const rTheirs = await exception2Result295(
|
|
135830
|
+
() => host.list({ ownerHandle: target2.ownerHandle, appSlug: target2.appSlug, callerUserId: runsAs })
|
|
135831
|
+
);
|
|
135832
|
+
if (!rTheirs.isOk() || !rTheirs.Ok().some((t) => t.name === toolName)) {
|
|
135833
|
+
return refuse16({
|
|
135834
|
+
ok: false,
|
|
135835
|
+
reason: "no-tool",
|
|
135836
|
+
tool: wireName,
|
|
135837
|
+
message: "This vibe doesn't offer that tool to the person who said yes, so it did not run. Nothing was done."
|
|
135838
|
+
});
|
|
135839
|
+
}
|
|
135840
|
+
}
|
|
135679
135841
|
const rAnswer = await exception2Result295(() => consent.answer());
|
|
135680
135842
|
const answer13 = rAnswer.isOk() ? rAnswer.Ok() : { method: "typed", text: null };
|
|
135681
135843
|
const rQuestion = await exception2Result295(() => consent.offerQuestion());
|
|
@@ -135692,13 +135854,13 @@ async function recordTextLaterYes(target2, wireName) {
|
|
|
135692
135854
|
answerText: personAnswerText(answer13.text)
|
|
135693
135855
|
})
|
|
135694
135856
|
);
|
|
135695
|
-
if (rRecorded.isOk() && rRecorded.Ok() === true) return void 0;
|
|
135696
|
-
return {
|
|
135857
|
+
if (rRecorded.isOk() && rRecorded.Ok() === true) return runsAs === void 0 ? { ok: true } : { ok: true, runsAs };
|
|
135858
|
+
return refuse16({
|
|
135697
135859
|
ok: false,
|
|
135698
135860
|
reason: "consent-not-recorded",
|
|
135699
135861
|
tool: wireName,
|
|
135700
135862
|
message: "Their yes could not be saved just now, so the tool did not run. Nothing was done; try again in a moment."
|
|
135701
|
-
};
|
|
135863
|
+
});
|
|
135702
135864
|
}
|
|
135703
135865
|
function withVibeToolCalls(vibeTools, rest) {
|
|
135704
135866
|
return (input) => input.call.name === LIST_VIBE_TOOLS_TOOL_NAME || input.call.name === CALL_VIBE_TOOL_TOOL_NAME ? vibeTools(input) : rest(input);
|
|
@@ -136103,11 +136265,11 @@ function searchGoodVibes(pages, query, section) {
|
|
|
136103
136265
|
const scored = pool.map((page, index3) => {
|
|
136104
136266
|
const title = new Set(tokens(page.title));
|
|
136105
136267
|
const where = new Set(tokens(pagePath(page)));
|
|
136106
|
-
const
|
|
136268
|
+
const desc61 = new Set(tokens(page.description ?? ""));
|
|
136107
136269
|
let score = 0;
|
|
136108
136270
|
let hits = 0;
|
|
136109
136271
|
for (const t of terms) {
|
|
136110
|
-
const s = (title.has(t) ? 4 : 0) + (where.has(t) ? 3 : 0) + (
|
|
136272
|
+
const s = (title.has(t) ? 4 : 0) + (where.has(t) ? 3 : 0) + (desc61.has(t) ? 1 : 0);
|
|
136111
136273
|
if (s > 0) hits++;
|
|
136112
136274
|
score += s;
|
|
136113
136275
|
}
|
|
@@ -137555,14 +137717,14 @@ var init_agent_guided_plan = __esm({
|
|
|
137555
137717
|
// ../vibes.diy/api/svc/intern/agent-guided-run.ts
|
|
137556
137718
|
import { Result as Result235, exception2Result as exception2Result305, stream2uint8array as stream2uint8array14 } from "@adviser/cement";
|
|
137557
137719
|
import { type as type183 } from "arktype";
|
|
137558
|
-
import { and as and160, desc as
|
|
137720
|
+
import { and as and160, desc as desc37, eq as eq186 } from "drizzle-orm/sql/expressions";
|
|
137559
137721
|
async function readGuidedDefinition(vctx, guide) {
|
|
137560
137722
|
const flags = await exception2Result305(() => getBindingFlags(vctx, guide));
|
|
137561
137723
|
if (flags.isErr()) return Result235.Err(flags);
|
|
137562
137724
|
if (flags.Ok().unpublishedAt !== "") return Result235.Err("the guide is not published");
|
|
137563
137725
|
const t = vctx.sql.tables.apps;
|
|
137564
137726
|
const rRow = await exception2Result305(
|
|
137565
|
-
() => vctx.sql.db.select({ fileSystem: t.fileSystem }).from(t).where(and160(eq186(t.ownerHandle, guide.ownerHandle), eq186(t.appSlug, guide.appSlug), eq186(t.mode, "production"))).orderBy(
|
|
137727
|
+
() => vctx.sql.db.select({ fileSystem: t.fileSystem }).from(t).where(and160(eq186(t.ownerHandle, guide.ownerHandle), eq186(t.appSlug, guide.appSlug), eq186(t.mode, "production"))).orderBy(desc37(t.releaseSeq)).limit(1).then((rows) => rows[0])
|
|
137566
137728
|
);
|
|
137567
137729
|
if (rRow.isErr()) return Result235.Err(rRow);
|
|
137568
137730
|
const row = rRow.Ok();
|
|
@@ -138350,7 +138512,7 @@ var init_fork_seed_text = __esm({
|
|
|
138350
138512
|
// ../vibes.diy/api/svc/public/get-app-by-fsid.ts
|
|
138351
138513
|
import { Result as Result238, Option as Option48, EventoResult as EventoResult42, exception2Result as exception2Result307 } from "@adviser/cement";
|
|
138352
138514
|
import { type as type186 } from "arktype";
|
|
138353
|
-
import { and as and162, desc as
|
|
138515
|
+
import { and as and162, desc as desc38, eq as eq188 } from "drizzle-orm/sql/expressions";
|
|
138354
138516
|
function grantedAccess(role) {
|
|
138355
138517
|
switch (role) {
|
|
138356
138518
|
case "editor":
|
|
@@ -138457,7 +138619,7 @@ var init_get_app_by_fsid = __esm({
|
|
|
138457
138619
|
eq188(vctx.sql.tables.apps.appSlug, req2.appSlug),
|
|
138458
138620
|
eq188(vctx.sql.tables.apps.ownerHandle, req2.ownerHandle)
|
|
138459
138621
|
)
|
|
138460
|
-
).orderBy(
|
|
138622
|
+
).orderBy(desc38(vctx.sql.tables.apps.mode), desc38(vctx.sql.tables.apps.releaseSeq)).limit(1).then((r) => r[0]);
|
|
138461
138623
|
} else if ((req2.selectMode === "ownerLatest" || req2.selectMode === "ownerDraft") && callerUserId) {
|
|
138462
138624
|
const draft = await selectLatestDevDraftOrPublished(vctx, { ownerHandle: req2.ownerHandle, appSlug: req2.appSlug });
|
|
138463
138625
|
const isOwnersDraft = draft !== void 0 && draft.userId === callerUserId;
|
|
@@ -140422,7 +140584,7 @@ var init_agent_calendar_link_tool = __esm({
|
|
|
140422
140584
|
// ../vibes.diy/api/svc/intern/agent-account-tools.ts
|
|
140423
140585
|
import { JSONEnDecoderSingleton as JSONEnDecoderSingleton6, Result as Result244, exception2Result as exception2Result313 } from "@adviser/cement";
|
|
140424
140586
|
import { type as type191 } from "arktype";
|
|
140425
|
-
import { and as and165, desc as
|
|
140587
|
+
import { and as and165, desc as desc39, eq as eq191, inArray as inArray49, lt as lt13, or as or20 } from "drizzle-orm/sql/expressions";
|
|
140426
140588
|
import { base58btc as base58btc13 } from "multiformats/bases/base58";
|
|
140427
140589
|
function boundTitle(item) {
|
|
140428
140590
|
if (item.title === void 0 || item.title.length <= VIBE_ACTIVITY_TITLE_CHARS) return item;
|
|
@@ -140498,7 +140660,7 @@ async function listAccountVibes(vctx, args) {
|
|
|
140498
140660
|
and165(eq191(asb.updated, after.updated), eq191(asb.ownerHandle, after.ownerHandle), lt13(asb.appSlug, after.appSlug))
|
|
140499
140661
|
)
|
|
140500
140662
|
)
|
|
140501
|
-
).orderBy(
|
|
140663
|
+
).orderBy(desc39(asb.updated), desc39(asb.ownerHandle), desc39(asb.appSlug)).limit(limit + 1)
|
|
140502
140664
|
);
|
|
140503
140665
|
if (rRows.isErr()) return Result244.Err(rRows);
|
|
140504
140666
|
const rows = rRows.Ok().filter((row) => isAgentChatAppSlug(row.appSlug) === false);
|
|
@@ -146914,7 +147076,7 @@ var init_deliver_post_turn_version = __esm({
|
|
|
146914
147076
|
|
|
146915
147077
|
// ../vibes.diy/api/svc/intern/design-repair.ts
|
|
146916
147078
|
import { Result as Result259, exception2Result as exception2Result332, stream2uint8array as stream2uint8array15 } from "@adviser/cement";
|
|
146917
|
-
import { and as and168, desc as
|
|
147079
|
+
import { and as and168, desc as desc40, eq as eq197, isNotNull as isNotNull7 } from "drizzle-orm";
|
|
146918
147080
|
import { type as type196 } from "arktype";
|
|
146919
147081
|
function designRepairEnabled(flag22) {
|
|
146920
147082
|
return flag22 !== "off";
|
|
@@ -147026,7 +147188,7 @@ async function chatHeadFsId(vctx, chatId) {
|
|
|
147026
147188
|
const pc = vctx.sql.tables.promptContexts;
|
|
147027
147189
|
const apps = vctx.sql.tables.apps;
|
|
147028
147190
|
return exception2Result332(async () => {
|
|
147029
|
-
const rows = await vctx.sql.db.select({ fsId: pc.fsId }).from(pc).innerJoin(apps, eq197(apps.fsId, pc.fsId)).where(and168(eq197(pc.chatId, chatId), isNotNull7(pc.fsId))).orderBy(
|
|
147191
|
+
const rows = await vctx.sql.db.select({ fsId: pc.fsId }).from(pc).innerJoin(apps, eq197(apps.fsId, pc.fsId)).where(and168(eq197(pc.chatId, chatId), isNotNull7(pc.fsId))).orderBy(desc40(pc.created)).limit(1);
|
|
147030
147192
|
return rows[0]?.fsId ?? void 0;
|
|
147031
147193
|
});
|
|
147032
147194
|
}
|
|
@@ -149988,7 +150150,7 @@ var init_shared_mint2 = __esm({
|
|
|
149988
150150
|
// ../vibes.diy/api/svc/public/list-user-slug-app-slug.ts
|
|
149989
150151
|
import { Result as Result266, Option as Option54, EventoResult as EventoResult48 } from "@adviser/cement";
|
|
149990
150152
|
import { type as type201 } from "arktype";
|
|
149991
|
-
import { eq as eq200, and as and171, desc as
|
|
150153
|
+
import { eq as eq200, and as and171, desc as desc41 } from "drizzle-orm/sql/expressions";
|
|
149992
150154
|
var listUserSlugAppSlugEvento;
|
|
149993
150155
|
var init_list_user_slug_app_slug = __esm({
|
|
149994
150156
|
"../vibes.diy/api/svc/public/list-user-slug-app-slug.ts"() {
|
|
@@ -150031,7 +150193,7 @@ var init_list_user_slug_app_slug = __esm({
|
|
|
150031
150193
|
}).from(vctx.sql.tables.handleBinding).leftJoin(
|
|
150032
150194
|
vctx.sql.tables.appSlugBinding,
|
|
150033
150195
|
eq200(vctx.sql.tables.appSlugBinding.ownerHandle, vctx.sql.tables.handleBinding.handle)
|
|
150034
|
-
).where(and171(...conditions)).orderBy(
|
|
150196
|
+
).where(and171(...conditions)).orderBy(desc41(vctx.sql.tables.handleBinding.created), desc41(vctx.sql.tables.appSlugBinding.created));
|
|
150035
150197
|
const grouped = /* @__PURE__ */ new Map();
|
|
150036
150198
|
for (const row of rows) {
|
|
150037
150199
|
if (!grouped.has(row.ownerHandle)) {
|
|
@@ -150067,7 +150229,7 @@ import {
|
|
|
150067
150229
|
} from "@adviser/cement";
|
|
150068
150230
|
import { type as type202 } from "arktype";
|
|
150069
150231
|
import { base58btc as base58btc14 } from "multiformats/bases/base58";
|
|
150070
|
-
import { eq as eq201, and as and172, lt as lt15, or as or21, desc as
|
|
150232
|
+
import { eq as eq201, and as and172, lt as lt15, or as or21, desc as desc42, inArray as inArray52 } from "drizzle-orm/sql/expressions";
|
|
150071
150233
|
function encodeCursor3(c) {
|
|
150072
150234
|
return base58btc14.encode(jsonEnde2.uint8ify(c));
|
|
150073
150235
|
}
|
|
@@ -150186,7 +150348,7 @@ var init_list_recent_vibes = __esm({
|
|
|
150186
150348
|
}).from(usb).innerJoin(asb, eq201(asb.ownerHandle, usb.handle)).leftJoin(
|
|
150187
150349
|
settings,
|
|
150188
150350
|
and172(eq201(settings.userId, usb.userId), eq201(settings.ownerHandle, usb.handle), eq201(settings.appSlug, asb.appSlug))
|
|
150189
|
-
).where(and172(...conditions)).orderBy(
|
|
150351
|
+
).where(and172(...conditions)).orderBy(desc42(asb.pinnedAt), desc42(asb.updated), desc42(asb.ownerHandle), desc42(asb.appSlug)).limit(limit + 1);
|
|
150190
150352
|
const hasMore = rows.length > limit;
|
|
150191
150353
|
const slice = hasMore ? rows.slice(0, limit) : rows;
|
|
150192
150354
|
const tApps = vctx.sql.tables.apps;
|
|
@@ -151073,7 +151235,7 @@ var init_vibe_tools_wire = __esm({
|
|
|
151073
151235
|
// ../vibes.diy/api/svc/public/app-owner-stats.ts
|
|
151074
151236
|
import { Result as Result276, Option as Option63, EventoResult as EventoResult57, exception2Result as exception2Result345 } from "@adviser/cement";
|
|
151075
151237
|
import { type as type210 } from "arktype";
|
|
151076
|
-
import { and as and176, count as count4, desc as
|
|
151238
|
+
import { and as and176, count as count4, desc as desc43, eq as eq206, gte as gte8, inArray as inArray53, like as like8, sql as sql31 } from "drizzle-orm";
|
|
151077
151239
|
async function authorized3(vctx, args) {
|
|
151078
151240
|
const auth = await authorizeSlugOwner(vctx, args);
|
|
151079
151241
|
if (auth === void 0) return false;
|
|
@@ -151105,7 +151267,7 @@ async function readAppOwnerStats(vctx, args) {
|
|
|
151105
151267
|
like8(n2.dedupeKey, "app-message:%")
|
|
151106
151268
|
);
|
|
151107
151269
|
const recipientCount = sql31`count(*)`;
|
|
151108
|
-
const topRecipients = await vctx.sql.db.select({ handle: n2.recipientHandle, count: recipientCount }).from(n2).where(fromThisVibe).groupBy(n2.userId, n2.recipientHandle).orderBy(
|
|
151270
|
+
const topRecipients = await vctx.sql.db.select({ handle: n2.recipientHandle, count: recipientCount }).from(n2).where(fromThisVibe).groupBy(n2.userId, n2.recipientHandle).orderBy(desc43(recipientCount)).limit(TOP_RECIPIENTS);
|
|
151109
151271
|
const totals = await vctx.sql.db.select({
|
|
151110
151272
|
total: sql31`count(*)`,
|
|
151111
151273
|
// The same (account, handle) pairs the list above is grouped by.
|
|
@@ -151124,8 +151286,8 @@ async function readAppOwnerStats(vctx, args) {
|
|
|
151124
151286
|
trigger: l.trigger,
|
|
151125
151287
|
lines: sql31`count(*)`,
|
|
151126
151288
|
errors: sql31`sum(case when ${l.level} = 'error' then 1 else 0 end)`
|
|
151127
|
-
}).from(l).where(fromThisBackend).groupBy(l.trigger).orderBy(
|
|
151128
|
-
const lastError2 = await vctx.sql.db.select({ ts: l.ts, trigger: l.trigger }).from(l).where(and176(fromThisBackend, eq206(l.level, "error"))).orderBy(
|
|
151289
|
+
}).from(l).where(fromThisBackend).groupBy(l.trigger).orderBy(desc43(sql31`count(*)`));
|
|
151290
|
+
const lastError2 = await vctx.sql.db.select({ ts: l.ts, trigger: l.trigger }).from(l).where(and176(fromThisBackend, eq206(l.level, "error"))).orderBy(desc43(l.id)).limit(1).then((r) => r[0]);
|
|
151129
151291
|
const errorCount = byTrigger.reduce((sum, r) => sum + Number(r.errors ?? 0), 0);
|
|
151130
151292
|
const errors = errorCount > 0 ? await readErrorGroups(vctx, { ...args, where: and176(fromThisBackend, eq206(l.level, "error")) }) : void 0;
|
|
151131
151293
|
return {
|
|
@@ -151168,7 +151330,7 @@ async function readErrorGroups(vctx, args) {
|
|
|
151168
151330
|
const prefix = sql31`substr(${l.body}, 1, ${sql31.raw(String(APP_OWNER_ERROR_PREFIX_CHARS))})`;
|
|
151169
151331
|
const count7 = sql31`count(*)`;
|
|
151170
151332
|
const lastAt = sql31`max(${l.ts})`;
|
|
151171
|
-
const rows = await vctx.sql.db.select({ message: prefix, count: count7, firstAt: sql31`min(${l.ts})`, lastAt, newestId: sql31`max(${l.id})` }).from(l).where(args.where).groupBy(prefix).orderBy(
|
|
151333
|
+
const rows = await vctx.sql.db.select({ message: prefix, count: count7, firstAt: sql31`min(${l.ts})`, lastAt, newestId: sql31`max(${l.id})` }).from(l).where(args.where).groupBy(prefix).orderBy(desc43(count7), desc43(lastAt)).limit(APP_OWNER_ERROR_GROUPS);
|
|
151172
151334
|
const newestIds = rows.map((r) => r.newestId);
|
|
151173
151335
|
const fsIdRows = newestIds.length === 0 ? [] : await vctx.sql.db.select({ id: l.id, fsId: l.fsId }).from(l).where(and176(eq206(l.ownerHandle, args.ownerHandle), eq206(l.appSlug, args.appSlug), inArray53(l.id, newestIds)));
|
|
151174
151336
|
const fsIdById = new Map(fsIdRows.map((r) => [r.id, r.fsId]));
|
|
@@ -151618,7 +151780,7 @@ var init_mark_build_seen = __esm({
|
|
|
151618
151780
|
// ../vibes.diy/api/svc/public/get-chat-details.ts
|
|
151619
151781
|
import { Result as Result281, Option as Option68, EventoResult as EventoResult62 } from "@adviser/cement";
|
|
151620
151782
|
import { type as type215 } from "arktype";
|
|
151621
|
-
import { eq as eq207, and as and177, desc as
|
|
151783
|
+
import { eq as eq207, and as and177, desc as desc44, ne as ne25 } from "drizzle-orm/sql/expressions";
|
|
151622
151784
|
var getChatDetailsEvento;
|
|
151623
151785
|
var init_get_chat_details = __esm({
|
|
151624
151786
|
"../vibes.diy/api/svc/public/get-chat-details.ts"() {
|
|
@@ -151690,7 +151852,7 @@ var init_get_chat_details = __esm({
|
|
|
151690
151852
|
...req2.chatId !== void 0 ? [eq207(vctx.sql.tables.chatContexts.chatId, req2.chatId)] : [],
|
|
151691
151853
|
...isDeveloper ? [eq207(vctx.sql.tables.chatContexts.userId, userId)] : []
|
|
151692
151854
|
)
|
|
151693
|
-
).orderBy(
|
|
151855
|
+
).orderBy(desc44(vctx.sql.tables.promptContexts.created));
|
|
151694
151856
|
if (rows.length === 0) {
|
|
151695
151857
|
await ctx.send.send(ctx, {
|
|
151696
151858
|
type: "vibes.diy.res-get-chat-details",
|
|
@@ -152961,7 +153123,7 @@ var init_auto_flag_address = __esm({
|
|
|
152961
153123
|
// ../vibes.diy/api/svc/public/moderation-admin.ts
|
|
152962
153124
|
import { Result as Result291, Option as Option77, EventoResult as EventoResult71 } from "@adviser/cement";
|
|
152963
153125
|
import { type as type226 } from "arktype";
|
|
152964
|
-
import { and as and181, count as count6, desc as
|
|
153126
|
+
import { and as and181, count as count6, desc as desc45, eq as eq213, gte as gte9, inArray as inArray55, notInArray as notInArray9 } from "drizzle-orm";
|
|
152965
153127
|
function toReportRow(r) {
|
|
152966
153128
|
return {
|
|
152967
153129
|
reportId: r.reportId,
|
|
@@ -153055,7 +153217,7 @@ async function moderationAdmin(vctx, req2, now3 = /* @__PURE__ */ new Date()) {
|
|
|
153055
153217
|
const status = req2.status ?? "open";
|
|
153056
153218
|
const limit = Math.max(1, Math.min(MAX_LIST_LIMIT, Math.floor(req2.limit ?? DEFAULT_LIST_LIMIT)));
|
|
153057
153219
|
const base = vctx.sql.db.select().from(reports);
|
|
153058
|
-
const rows = await (status === "all" ? base : base.where(eq213(reports.status, status))).orderBy(
|
|
153220
|
+
const rows = await (status === "all" ? base : base.where(eq213(reports.status, status))).orderBy(desc45(reports.created)).limit(limit);
|
|
153059
153221
|
return Result291.Ok({ type: "vibes.diy.res-moderation-admin", op: req2.op, reports: rows.map(toReportRow) });
|
|
153060
153222
|
}
|
|
153061
153223
|
case "resolve-report": {
|
|
@@ -153127,7 +153289,7 @@ async function moderationAdmin(vctx, req2, now3 = /* @__PURE__ */ new Date()) {
|
|
|
153127
153289
|
const status = req2.flagStatus ?? "open";
|
|
153128
153290
|
const limit = Math.max(1, Math.min(MAX_LIST_LIMIT, Math.floor(req2.limit ?? DEFAULT_LIST_LIMIT)));
|
|
153129
153291
|
const base = vctx.sql.db.select().from(flags);
|
|
153130
|
-
const rows = await (status === "all" ? base.where(notInArray9(flags.status, [...AUTO_FLAG_RECORD_STATUSES])) : base.where(eq213(flags.status, status))).orderBy(
|
|
153292
|
+
const rows = await (status === "all" ? base.where(notInArray9(flags.status, [...AUTO_FLAG_RECORD_STATUSES])) : base.where(eq213(flags.status, status))).orderBy(desc45(flags.created)).limit(limit);
|
|
153131
153293
|
const out = [];
|
|
153132
153294
|
for (const r of await withCurrentFlagAddress(vctx.sql, rows)) {
|
|
153133
153295
|
const text3 = r.inputKind === "prompt" && r.chatId && r.promptId ? await readFlaggedPrompt(vctx, r.chatId, r.promptId) : void 0;
|
|
@@ -153548,7 +153710,7 @@ var init_ensure_handle_avatar = __esm({
|
|
|
153548
153710
|
// ../vibes.diy/api/svc/public/list-application-chats.ts
|
|
153549
153711
|
import { Result as Result295, Option as Option81, EventoResult as EventoResult75 } from "@adviser/cement";
|
|
153550
153712
|
import { type as type230 } from "arktype";
|
|
153551
|
-
import { eq as eq217, and as and185, lt as lt17, desc as
|
|
153713
|
+
import { eq as eq217, and as and185, lt as lt17, desc as desc46, asc as asc20, inArray as inArray56 } from "drizzle-orm/sql/expressions";
|
|
153552
153714
|
var DEFAULT_LIMIT5, MAX_LIMIT5, listApplicationChats;
|
|
153553
153715
|
var init_list_application_chats = __esm({
|
|
153554
153716
|
"../vibes.diy/api/svc/public/list-application-chats.ts"() {
|
|
@@ -153597,7 +153759,7 @@ var init_list_application_chats = __esm({
|
|
|
153597
153759
|
ownerHandle: vctx.sql.tables.applicationChats.ownerHandle,
|
|
153598
153760
|
created: vctx.sql.tables.applicationChats.created,
|
|
153599
153761
|
userId: vctx.sql.tables.applicationChats.userId
|
|
153600
|
-
}).from(vctx.sql.tables.applicationChats).where(and185(...conditions)).orderBy(
|
|
153762
|
+
}).from(vctx.sql.tables.applicationChats).where(and185(...conditions)).orderBy(desc46(vctx.sql.tables.applicationChats.created)).limit(limit + 1);
|
|
153601
153763
|
const hasMore = rows.length > limit;
|
|
153602
153764
|
const page = hasMore ? rows.slice(0, limit) : rows;
|
|
153603
153765
|
const userIds = [...new Set(page.map((r) => r.userId))];
|
|
@@ -153630,7 +153792,7 @@ var init_list_application_chats = __esm({
|
|
|
153630
153792
|
// ../vibes.diy/api/svc/public/list-codegen-chats.ts
|
|
153631
153793
|
import { Result as Result296, Option as Option82, EventoResult as EventoResult76 } from "@adviser/cement";
|
|
153632
153794
|
import { type as type231 } from "arktype";
|
|
153633
|
-
import { eq as eq218, and as and186, lt as lt18, desc as
|
|
153795
|
+
import { eq as eq218, and as and186, lt as lt18, desc as desc47 } from "drizzle-orm/sql/expressions";
|
|
153634
153796
|
var DEFAULT_LIMIT6, MAX_LIMIT6, listCodegenChats;
|
|
153635
153797
|
var init_list_codegen_chats = __esm({
|
|
153636
153798
|
"../vibes.diy/api/svc/public/list-codegen-chats.ts"() {
|
|
@@ -153669,7 +153831,7 @@ var init_list_codegen_chats = __esm({
|
|
|
153669
153831
|
appSlug: vctx.sql.tables.chatContexts.appSlug,
|
|
153670
153832
|
ownerHandle: vctx.sql.tables.chatContexts.ownerHandle,
|
|
153671
153833
|
created: vctx.sql.tables.chatContexts.created
|
|
153672
|
-
}).from(vctx.sql.tables.chatContexts).where(and186(...conditions)).orderBy(
|
|
153834
|
+
}).from(vctx.sql.tables.chatContexts).where(and186(...conditions)).orderBy(desc47(vctx.sql.tables.chatContexts.created)).limit(limit + 1);
|
|
153673
153835
|
const hasMore = rows.length > limit;
|
|
153674
153836
|
const items = hasMore ? rows.slice(0, limit) : rows;
|
|
153675
153837
|
await ctx.send.send(ctx, {
|
|
@@ -154511,7 +154673,7 @@ import {
|
|
|
154511
154673
|
} from "@adviser/cement";
|
|
154512
154674
|
import { type as type240 } from "arktype";
|
|
154513
154675
|
import { base58btc as base58btc15 } from "multiformats/bases/base58";
|
|
154514
|
-
import { eq as eq224, and as and192, lt as lt19, or as or23, desc as
|
|
154676
|
+
import { eq as eq224, and as and192, lt as lt19, or as or23, desc as desc48, isNull as isNull13, inArray as inArray58, not as not3, sql as sql32 } from "drizzle-orm";
|
|
154515
154677
|
function clampLimit4(raw) {
|
|
154516
154678
|
if (raw === void 0) return DEFAULT_LIMIT7;
|
|
154517
154679
|
if (!Number.isFinite(raw)) return DEFAULT_LIMIT7;
|
|
@@ -154610,7 +154772,7 @@ var init_list_notifications = __esm({
|
|
|
154610
154772
|
const tuplePred = or23(lt19(t.created, c.created), and192(eq224(t.created, c.created), lt19(t.id, c.id)));
|
|
154611
154773
|
if (tuplePred) conditions.push(tuplePred);
|
|
154612
154774
|
}
|
|
154613
|
-
const rows = await vctx.sql.db.select().from(t).where(and192(...conditions)).orderBy(
|
|
154775
|
+
const rows = await vctx.sql.db.select().from(t).where(and192(...conditions)).orderBy(desc48(t.created), desc48(t.id)).limit(limit + 1);
|
|
154614
154776
|
const hasMore = rows.length > limit;
|
|
154615
154777
|
const slice = hasMore ? rows.slice(0, limit) : rows;
|
|
154616
154778
|
const items = slice.map(toRow4);
|
|
@@ -155247,7 +155409,7 @@ var init_onboarding_handle2 = __esm({
|
|
|
155247
155409
|
|
|
155248
155410
|
// ../vibes.diy/api/svc/public/developer-grants-flow.ts
|
|
155249
155411
|
import { Result as Result312, Option as Option98, EventoResult as EventoResult92, exception2Result as exception2Result354 } from "@adviser/cement";
|
|
155250
|
-
import { eq as eq229, and as and196, lt as lt20, desc as
|
|
155412
|
+
import { eq as eq229, and as and196, lt as lt20, desc as desc49 } from "drizzle-orm/sql/expressions";
|
|
155251
155413
|
async function ownsHandle4(vctx, ownerHandle, callerUserId) {
|
|
155252
155414
|
const row = await vctx.sql.db.select({ userId: vctx.sql.tables.handleBinding.userId }).from(vctx.sql.tables.handleBinding).where(and196(eq229(vctx.sql.tables.handleBinding.handle, ownerHandle), eq229(vctx.sql.tables.handleBinding.userId, callerUserId))).limit(1).then((rows) => rows[0]);
|
|
155253
155415
|
return row !== void 0;
|
|
@@ -155443,7 +155605,7 @@ var init_developer_grants_flow = __esm({
|
|
|
155443
155605
|
state: vctx.sql.tables.developerGrants.state,
|
|
155444
155606
|
updated: vctx.sql.tables.developerGrants.updated,
|
|
155445
155607
|
created: vctx.sql.tables.developerGrants.created
|
|
155446
|
-
}).from(vctx.sql.tables.developerGrants).where(and196(...conditions)).orderBy(
|
|
155608
|
+
}).from(vctx.sql.tables.developerGrants).where(and196(...conditions)).orderBy(desc49(vctx.sql.tables.developerGrants.created)).limit(limit + 1);
|
|
155447
155609
|
const hasMore = rows.length > limit;
|
|
155448
155610
|
const items = hasMore ? rows.slice(0, limit) : rows;
|
|
155449
155611
|
await ctx.send.send(ctx, {
|
|
@@ -157740,7 +157902,7 @@ var init_app_documents2 = __esm({
|
|
|
157740
157902
|
|
|
157741
157903
|
// ../vibes.diy/api/svc/public/list-members.ts
|
|
157742
157904
|
import { Result as Result326, Option as Option107, EventoResult as EventoResult104 } from "@adviser/cement";
|
|
157743
|
-
import { eq as eq236, and as and203, inArray as inArray63, desc as
|
|
157905
|
+
import { eq as eq236, and as and203, inArray as inArray63, desc as desc50 } from "drizzle-orm";
|
|
157744
157906
|
import { type as type247 } from "arktype";
|
|
157745
157907
|
function safeDisplay(foreignInfo, fallbackEmail, fallbackHandle) {
|
|
157746
157908
|
const fi = foreignInfo;
|
|
@@ -157827,7 +157989,7 @@ var init_list_members = __esm({
|
|
|
157827
157989
|
const handleByUserId = /* @__PURE__ */ new Map();
|
|
157828
157990
|
let heldHandles = /* @__PURE__ */ new Map();
|
|
157829
157991
|
if (requestUserIds.length > 0) {
|
|
157830
|
-
const handleRows = await vctx.sql.db.select({ userId: vctx.sql.tables.handleBinding.userId, handle: vctx.sql.tables.handleBinding.handle }).from(vctx.sql.tables.handleBinding).where(inArray63(vctx.sql.tables.handleBinding.userId, requestUserIds)).orderBy(
|
|
157992
|
+
const handleRows = await vctx.sql.db.select({ userId: vctx.sql.tables.handleBinding.userId, handle: vctx.sql.tables.handleBinding.handle }).from(vctx.sql.tables.handleBinding).where(inArray63(vctx.sql.tables.handleBinding.userId, requestUserIds)).orderBy(desc50(vctx.sql.tables.handleBinding.created));
|
|
157831
157993
|
heldHandles = collectHeldHandles(handleRows);
|
|
157832
157994
|
for (const row of handleRows) {
|
|
157833
157995
|
if (!handleByUserId.has(row.userId)) handleByUserId.set(row.userId, row.handle);
|
|
@@ -159633,7 +159795,7 @@ var init_report_top_vibes_by_traffic = __esm({
|
|
|
159633
159795
|
// ../vibes.diy/api/svc/public/report-attribution-referrers.ts
|
|
159634
159796
|
import { Result as Result341, Option as Option121, EventoResult as EventoResult118 } from "@adviser/cement";
|
|
159635
159797
|
import { type as type255 } from "arktype";
|
|
159636
|
-
import { sql as sql37, desc as
|
|
159798
|
+
import { sql as sql37, desc as desc51, eq as eq240, notInArray as notInArray10, and as and204, like as like9, notLike as notLike3, not as not4, gte as gte11 } from "drizzle-orm";
|
|
159637
159799
|
function legacyVibePath(reqPath) {
|
|
159638
159800
|
return and204(like9(reqPath, "/vibe/_%"), notLike3(reqPath, "/vibe/%/%"));
|
|
159639
159801
|
}
|
|
@@ -159654,11 +159816,11 @@ async function computeAttributionReferrers(vctx, reqPathFilter, window2 = "all")
|
|
|
159654
159816
|
total: sql37`cast(count(*) as int)`
|
|
159655
159817
|
}).from(t.refererEvents).$dynamic();
|
|
159656
159818
|
const filtered = reqPathFilter !== void 0 ? baseQuery.where(and204(ownedFilter, notLegacyVibeFilter, windowFilter, eq240(t.refererEvents.reqPath, reqPathFilter))) : baseQuery.where(and204(ownedFilter, notLegacyVibeFilter, windowFilter));
|
|
159657
|
-
const rows = await filtered.groupBy(t.refererEvents.refHost, t.refererEvents.refPath, t.refererEvents.reqPath).orderBy(
|
|
159819
|
+
const rows = await filtered.groupBy(t.refererEvents.refHost, t.refererEvents.refPath, t.refererEvents.reqPath).orderBy(desc51(sql37`count(*)`)).limit(100);
|
|
159658
159820
|
const legacyVibeRows = reqPathFilter === void 0 ? await vctx.sql.db.select({
|
|
159659
159821
|
reqPath: t.refererEvents.reqPath,
|
|
159660
159822
|
total: sql37`cast(count(*) as int)`
|
|
159661
|
-
}).from(t.refererEvents).where(and204(legacyVibePath(t.refererEvents.reqPath), windowFilter)).groupBy(t.refererEvents.reqPath).orderBy(
|
|
159823
|
+
}).from(t.refererEvents).where(and204(legacyVibePath(t.refererEvents.reqPath), windowFilter)).groupBy(t.refererEvents.reqPath).orderBy(desc51(sql37`count(*)`)).limit(200) : [];
|
|
159662
159824
|
return {
|
|
159663
159825
|
type: "vibes.diy.res-report-attribution-referrers",
|
|
159664
159826
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -159731,7 +159893,7 @@ var init_report_attribution_referrers = __esm({
|
|
|
159731
159893
|
// ../vibes.diy/api/svc/public/report-api-traffic.ts
|
|
159732
159894
|
import { Result as Result342, Option as Option122, EventoResult as EventoResult119 } from "@adviser/cement";
|
|
159733
159895
|
import { type as type256 } from "arktype";
|
|
159734
|
-
import { sql as sql38, asc as asc21, desc as
|
|
159896
|
+
import { sql as sql38, asc as asc21, desc as desc52, eq as eq241, and as and205, gte as gte12 } from "drizzle-orm";
|
|
159735
159897
|
function percentile(sortedAsc, p) {
|
|
159736
159898
|
if (sortedAsc.length === 0) return 0;
|
|
159737
159899
|
const rank = Math.ceil(p / 100 * sortedAsc.length);
|
|
@@ -159814,7 +159976,7 @@ async function computeApiTraffic(vctx, hostFilter) {
|
|
|
159814
159976
|
day: dayExpr,
|
|
159815
159977
|
host: t.apiRequestEvents.host,
|
|
159816
159978
|
requests: sql38`cast(count(*) as int)`
|
|
159817
|
-
}).from(t.apiRequestEvents).where(where).groupBy(dayExpr, t.apiRequestEvents.host).orderBy(
|
|
159979
|
+
}).from(t.apiRequestEvents).where(where).groupBy(dayExpr, t.apiRequestEvents.host).orderBy(desc52(dayExpr), asc21(t.apiRequestEvents.host)).limit(PER_DAY_GROUP_CAP);
|
|
159818
159980
|
const sample = await vctx.sql.db.select({
|
|
159819
159981
|
host: t.apiRequestEvents.host,
|
|
159820
159982
|
path: t.apiRequestEvents.path,
|
|
@@ -159823,7 +159985,7 @@ async function computeApiTraffic(vctx, hostFilter) {
|
|
|
159823
159985
|
status: t.apiRequestEvents.status,
|
|
159824
159986
|
durationMs: t.apiRequestEvents.durationMs,
|
|
159825
159987
|
ts: t.apiRequestEvents.ts
|
|
159826
|
-
}).from(t.apiRequestEvents).where(where).orderBy(
|
|
159988
|
+
}).from(t.apiRequestEvents).where(where).orderBy(desc52(t.apiRequestEvents.ts)).limit(SAMPLE_ROW_CAP);
|
|
159827
159989
|
const { endpoints, pollers } = aggregateApiTraffic(sample);
|
|
159828
159990
|
return {
|
|
159829
159991
|
type: "vibes.diy.res-report-api-traffic",
|
|
@@ -159889,7 +160051,7 @@ var init_report_api_traffic = __esm({
|
|
|
159889
160051
|
// ../vibes.diy/api/svc/public/report-egress.ts
|
|
159890
160052
|
import { Result as Result343, Option as Option123, EventoResult as EventoResult120 } from "@adviser/cement";
|
|
159891
160053
|
import { type as type257 } from "arktype";
|
|
159892
|
-
import { sql as sql39, asc as asc22, desc as
|
|
160054
|
+
import { sql as sql39, asc as asc22, desc as desc53, eq as eq242, and as and206, or as or24, gte as gte13 } from "drizzle-orm";
|
|
159893
160055
|
function aggregateEgress(rows) {
|
|
159894
160056
|
const hosts = /* @__PURE__ */ new Map();
|
|
159895
160057
|
const vibes = /* @__PURE__ */ new Map();
|
|
@@ -159969,7 +160131,7 @@ async function computeEgress(vctx, hostFilter) {
|
|
|
159969
160131
|
gate: t.egressEvents.gate,
|
|
159970
160132
|
cached: t.egressEvents.cached,
|
|
159971
160133
|
ts: t.egressEvents.ts
|
|
159972
|
-
}).from(t.egressEvents).where(where).orderBy(
|
|
160134
|
+
}).from(t.egressEvents).where(where).orderBy(desc53(t.egressEvents.ts)).limit(SAMPLE_ROW_CAP2);
|
|
159973
160135
|
const suspectWindow = gte13(t.egressSuspectEvents.ts, cutoff);
|
|
159974
160136
|
const suspectWhere = hostFilter !== void 0 ? and206(suspectWindow, eq242(t.egressSuspectEvents.host, hostFilter)) : suspectWindow;
|
|
159975
160137
|
const suspects = await vctx.sql.db.select({
|
|
@@ -159984,7 +160146,7 @@ async function computeEgress(vctx, hostFilter) {
|
|
|
159984
160146
|
t.egressSuspectEvents.ownerHandle,
|
|
159985
160147
|
t.egressSuspectEvents.appSlug,
|
|
159986
160148
|
t.egressSuspectEvents.reasons
|
|
159987
|
-
).orderBy(
|
|
160149
|
+
).orderBy(desc53(sql39`count(*)`), asc22(t.egressSuspectEvents.host)).limit(SUSPECT_GROUP_CAP);
|
|
159988
160150
|
const { byHost, byVibe, byGate } = aggregateEgress(sample);
|
|
159989
160151
|
return {
|
|
159990
160152
|
type: "vibes.diy.res-report-egress",
|
|
@@ -162121,7 +162283,7 @@ var init_report_activity = __esm({
|
|
|
162121
162283
|
import { Result as Result351, Option as Option128, EventoResult as EventoResult125 } from "@adviser/cement";
|
|
162122
162284
|
import { type as type263 } from "arktype";
|
|
162123
162285
|
import { sql as sql41 } from "drizzle-orm";
|
|
162124
|
-
import { and as and209, asc as asc24, desc as
|
|
162286
|
+
import { and as and209, asc as asc24, desc as desc54, eq as eq245 } from "drizzle-orm/sql/expressions";
|
|
162125
162287
|
async function computeHomeLeaderboard(vctx, limit) {
|
|
162126
162288
|
const docs = vctx.sql.tables.appDocuments;
|
|
162127
162289
|
const asb = vctx.sql.tables.appSlugBinding;
|
|
@@ -162130,7 +162292,7 @@ async function computeHomeLeaderboard(vctx, limit) {
|
|
|
162130
162292
|
ownerHandle: docs.ownerHandle,
|
|
162131
162293
|
appSlug: docs.appSlug,
|
|
162132
162294
|
writerCount
|
|
162133
|
-
}).from(docs).innerJoin(asb, and209(eq245(asb.ownerHandle, docs.ownerHandle), eq245(asb.appSlug, docs.appSlug), eq245(asb.unpublishedAt, ""))).groupBy(docs.ownerHandle, docs.appSlug).orderBy(
|
|
162295
|
+
}).from(docs).innerJoin(asb, and209(eq245(asb.ownerHandle, docs.ownerHandle), eq245(asb.appSlug, docs.appSlug), eq245(asb.unpublishedAt, ""))).groupBy(docs.ownerHandle, docs.appSlug).orderBy(desc54(writerCount), asc24(docs.ownerHandle), asc24(docs.appSlug)).limit(limit * HOME_FEED_SCAN_FACTOR);
|
|
162134
162296
|
const display = await loadVibeDisplayInfo(vctx, candidates);
|
|
162135
162297
|
const facts = await loadNewestReleaseFacts(vctx, candidates);
|
|
162136
162298
|
const family = createFamilyAdmitter();
|
|
@@ -162352,7 +162514,7 @@ var init_curation_starter = __esm({
|
|
|
162352
162514
|
// ../vibes.diy/api/svc/public/curated-new-vibes.ts
|
|
162353
162515
|
import { Result as Result353, Option as Option129, EventoResult as EventoResult126 } from "@adviser/cement";
|
|
162354
162516
|
import { type as type265 } from "arktype";
|
|
162355
|
-
import { and as and211, desc as
|
|
162517
|
+
import { and as and211, desc as desc55, eq as eq247 } from "drizzle-orm/sql/expressions";
|
|
162356
162518
|
async function computeCuratedNewVibes(vctx, limit) {
|
|
162357
162519
|
const cur = vctx.sql.tables.vibeCuration;
|
|
162358
162520
|
const asb = vctx.sql.tables.appSlugBinding;
|
|
@@ -162362,7 +162524,7 @@ async function computeCuratedNewVibes(vctx, limit) {
|
|
|
162362
162524
|
created: asb.created,
|
|
162363
162525
|
approvedAt: cur.decidedAt,
|
|
162364
162526
|
starter: cur.starter
|
|
162365
|
-
}).from(cur).innerJoin(asb, and211(eq247(asb.ownerHandle, cur.ownerHandle), eq247(asb.appSlug, cur.appSlug), eq247(asb.unpublishedAt, ""))).where(eq247(cur.state, "approved")).orderBy(
|
|
162527
|
+
}).from(cur).innerJoin(asb, and211(eq247(asb.ownerHandle, cur.ownerHandle), eq247(asb.appSlug, cur.appSlug), eq247(asb.unpublishedAt, ""))).where(eq247(cur.state, "approved")).orderBy(desc55(cur.decidedAt), desc55(cur.ownerHandle), desc55(cur.appSlug)).limit(limit * HOME_FEED_SCAN_FACTOR);
|
|
162366
162528
|
const display = await loadVibeDisplayInfo(vctx, candidates);
|
|
162367
162529
|
const facts = await loadNewestReleaseFacts(vctx, candidates);
|
|
162368
162530
|
const family = createFamilyAdmitter();
|
|
@@ -162442,7 +162604,7 @@ var init_curated_new_vibes = __esm({
|
|
|
162442
162604
|
// ../vibes.diy/api/svc/public/handle-profile-vibes.ts
|
|
162443
162605
|
import { Result as Result354, Option as Option130, EventoResult as EventoResult127 } from "@adviser/cement";
|
|
162444
162606
|
import { type as type266 } from "arktype";
|
|
162445
|
-
import { and as and212, asc as asc25, desc as
|
|
162607
|
+
import { and as and212, asc as asc25, desc as desc56, eq as eq248 } from "drizzle-orm/sql/expressions";
|
|
162446
162608
|
async function computeHandleProfileVibes(vctx, ownerHandle, limit) {
|
|
162447
162609
|
const asb = vctx.sql.tables.appSlugBinding;
|
|
162448
162610
|
const batchSize = limit * HOME_FEED_SCAN_FACTOR;
|
|
@@ -162456,7 +162618,7 @@ async function computeHandleProfileVibes(vctx, ownerHandle, limit) {
|
|
|
162456
162618
|
created: asb.created,
|
|
162457
162619
|
updated: asb.updated,
|
|
162458
162620
|
pinnedAt: asb.pinnedAt
|
|
162459
|
-
}).from(asb).where(and212(eq248(asb.ownerHandle, ownerHandle), eq248(asb.unpublishedAt, ""))).orderBy(
|
|
162621
|
+
}).from(asb).where(and212(eq248(asb.ownerHandle, ownerHandle), eq248(asb.unpublishedAt, ""))).orderBy(desc56(asb.pinnedAt), desc56(asb.updated), asc25(asb.appSlug)).limit(take).offset(examined);
|
|
162460
162622
|
examined += candidates.length;
|
|
162461
162623
|
const display = await loadVibeDisplayInfo(vctx, candidates);
|
|
162462
162624
|
for (const row of candidates) {
|
|
@@ -162610,7 +162772,7 @@ var init_curate_approve = __esm({
|
|
|
162610
162772
|
import { Result as Result356, Option as Option132, EventoResult as EventoResult129 } from "@adviser/cement";
|
|
162611
162773
|
import { type as type268 } from "arktype";
|
|
162612
162774
|
import { cosineDistance as cosineDistance2, sql as sql42 } from "drizzle-orm";
|
|
162613
|
-
import { and as and213, asc as asc26, desc as
|
|
162775
|
+
import { and as and213, asc as asc26, desc as desc57, eq as eq249, notInArray as notInArray11, notLike as notLike4, or as or25 } from "drizzle-orm/sql/expressions";
|
|
162614
162776
|
async function computeRelatedVibes(vctx, { ownerHandle, appSlug, isOwner }) {
|
|
162615
162777
|
const docs = vctx.sql.tables.appDocuments;
|
|
162616
162778
|
const asb = vctx.sql.tables.appSlugBinding;
|
|
@@ -162664,7 +162826,7 @@ async function computeRelatedVibes(vctx, { ownerHandle, appSlug, isOwner }) {
|
|
|
162664
162826
|
});
|
|
162665
162827
|
}
|
|
162666
162828
|
const writerCount = sql42`cast(count(distinct ${docs.userId}) as int)`;
|
|
162667
|
-
const ownerCandidates = await vctx.sql.db.select({ ownerHandle: docs.ownerHandle, appSlug: docs.appSlug, writerCount }).from(docs).innerJoin(asb, and213(eq249(asb.ownerHandle, docs.ownerHandle), eq249(asb.appSlug, docs.appSlug), eq249(asb.unpublishedAt, ""))).where(eq249(docs.ownerHandle, ownerHandle)).groupBy(docs.ownerHandle, docs.appSlug).orderBy(
|
|
162829
|
+
const ownerCandidates = await vctx.sql.db.select({ ownerHandle: docs.ownerHandle, appSlug: docs.appSlug, writerCount }).from(docs).innerJoin(asb, and213(eq249(asb.ownerHandle, docs.ownerHandle), eq249(asb.appSlug, docs.appSlug), eq249(asb.unpublishedAt, ""))).where(eq249(docs.ownerHandle, ownerHandle)).groupBy(docs.ownerHandle, docs.appSlug).orderBy(desc57(writerCount), asc26(docs.appSlug)).limit(OWNER_TOP_LIMIT * HOME_FEED_SCAN_FACTOR);
|
|
162668
162830
|
const ownerPairs = ownerCandidates.filter(
|
|
162669
162831
|
(c) => !isCurrent(c.ownerHandle, c.appSlug) && !maskedKeys.has(titleIconKey(c.ownerHandle, c.appSlug))
|
|
162670
162832
|
);
|
|
@@ -164159,7 +164321,7 @@ var init_notify_remix = __esm({
|
|
|
164159
164321
|
});
|
|
164160
164322
|
|
|
164161
164323
|
// ../vibes.diy/api/svc/intern/notify-remix-clone.ts
|
|
164162
|
-
import { and as and214, desc as
|
|
164324
|
+
import { and as and214, desc as desc58, eq as eq250 } from "drizzle-orm/sql/expressions";
|
|
164163
164325
|
var init_notify_remix_clone = __esm({
|
|
164164
164326
|
"../vibes.diy/api/svc/intern/notify-remix-clone.ts"() {
|
|
164165
164327
|
"use strict";
|
|
@@ -164299,7 +164461,7 @@ var init_notify_member_joined = __esm({
|
|
|
164299
164461
|
});
|
|
164300
164462
|
|
|
164301
164463
|
// ../vibes.diy/api/svc/intern/notify-request-pending.ts
|
|
164302
|
-
import { and as and216, eq as eq253, gt as gt20, desc as
|
|
164464
|
+
import { and as and216, eq as eq253, gt as gt20, desc as desc59 } from "drizzle-orm/sql/expressions";
|
|
164303
164465
|
async function notifyRequestPending(qctx, input) {
|
|
164304
164466
|
if (input.requesterUserId === input.ownerUserId) return;
|
|
164305
164467
|
const g = qctx.sql.tables.requestGrants;
|
|
@@ -164316,7 +164478,7 @@ async function notifyRequestPending(qctx, input) {
|
|
|
164316
164478
|
eq253(t.actorUserId, input.requesterUserId),
|
|
164317
164479
|
gt20(t.created, cutoff)
|
|
164318
164480
|
)
|
|
164319
|
-
).orderBy(
|
|
164481
|
+
).orderBy(desc59(t.created)).limit(1).then((r) => r[0]);
|
|
164320
164482
|
if (recent !== void 0) return;
|
|
164321
164483
|
const label = input.requesterLabel?.trim() ? input.requesterLabel.trim() : "Someone";
|
|
164322
164484
|
const day = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
@@ -170841,7 +171003,7 @@ var init_channel_invite_email = __esm({
|
|
|
170841
171003
|
});
|
|
170842
171004
|
|
|
170843
171005
|
// ../vibes.diy/api/queue/intern/mail-screenshot.ts
|
|
170844
|
-
import { and as and222, desc as
|
|
171006
|
+
import { and as and222, desc as desc60, eq as eq260 } from "drizzle-orm/sql/expressions";
|
|
170845
171007
|
function toBase64(bytes) {
|
|
170846
171008
|
const CHUNK = 32768;
|
|
170847
171009
|
let binary = "";
|
|
@@ -170861,7 +171023,7 @@ function mailScreenshotCid(ownerHandle, appSlug) {
|
|
|
170861
171023
|
async function loadMailScreenshot(ctx, app) {
|
|
170862
171024
|
const { ownerUserId, ownerHandle, appSlug } = app;
|
|
170863
171025
|
const t = ctx.sql.tables.apps;
|
|
170864
|
-
const row = await ctx.sql.db.select({ meta: t.meta }).from(t).where(and222(eq260(t.userId, ownerUserId), eq260(t.ownerHandle, ownerHandle), eq260(t.appSlug, appSlug), eq260(t.mode, "production"))).orderBy(
|
|
171026
|
+
const row = await ctx.sql.db.select({ meta: t.meta }).from(t).where(and222(eq260(t.userId, ownerUserId), eq260(t.ownerHandle, ownerHandle), eq260(t.appSlug, appSlug), eq260(t.mode, "production"))).orderBy(desc60(t.releaseSeq)).limit(1).then((r) => r[0]);
|
|
170865
171027
|
if (row === void 0) return void 0;
|
|
170866
171028
|
const { filtered: meta } = parseArrayWarning(row.meta, MetaItem);
|
|
170867
171029
|
const shot = await loadStoredScreenshot({ storage: ctx.storage }, meta);
|
|
@@ -174331,6 +174493,7 @@ var init_phone_link_cmd = __esm({
|
|
|
174331
174493
|
"guest?": "boolean",
|
|
174332
174494
|
"asker?": "boolean",
|
|
174333
174495
|
"sponsored?": "boolean",
|
|
174496
|
+
"guestAsker?": "string",
|
|
174334
174497
|
"members?": "string"
|
|
174335
174498
|
});
|
|
174336
174499
|
ResPhoneLinkPayForGroupCli = type336({
|