vibes-diy 14.3.428 → 14.3.430
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.
|
@@ -8709,10 +8709,10 @@ var init_look_lint_engine = __esm({
|
|
|
8709
8709
|
});
|
|
8710
8710
|
|
|
8711
8711
|
// ../vibes.diy/api/svc/intern/swr-html-cache.ts
|
|
8712
|
-
import { URI as
|
|
8712
|
+
import { URI as URI7 } from "@adviser/cement";
|
|
8713
8713
|
function isPlatformWorkspaceNpmUrl(candidate, workspace) {
|
|
8714
|
-
const rc =
|
|
8715
|
-
const rw =
|
|
8714
|
+
const rc = URI7.fromResult(candidate);
|
|
8715
|
+
const rw = URI7.fromResult(workspace);
|
|
8716
8716
|
if (rc.isErr() || rw.isErr()) return false;
|
|
8717
8717
|
const c = rc.Ok();
|
|
8718
8718
|
const w = rw.Ok();
|
|
@@ -8734,7 +8734,7 @@ function isBareWorkspacePin(candidate) {
|
|
|
8734
8734
|
}
|
|
8735
8735
|
}
|
|
8736
8736
|
function canonicalWorkspacePin(npmUrl) {
|
|
8737
|
-
const r =
|
|
8737
|
+
const r = URI7.fromResult(npmUrl);
|
|
8738
8738
|
if (r.isErr()) return npmUrl;
|
|
8739
8739
|
const u = r.Ok();
|
|
8740
8740
|
const port = u.port ? `:${u.port}` : "";
|
|
@@ -9380,7 +9380,7 @@ var init_tailwindRemap = __esm({
|
|
|
9380
9380
|
});
|
|
9381
9381
|
|
|
9382
9382
|
// ../vibes.diy/vibe/runtime/resize-image.ts
|
|
9383
|
-
import { Result as Result45, exception2Result as
|
|
9383
|
+
import { Result as Result45, exception2Result as exception2Result74 } from "@adviser/cement";
|
|
9384
9384
|
async function resolveBlob(input) {
|
|
9385
9385
|
if (input instanceof Blob) return input;
|
|
9386
9386
|
const accessor = input?.file;
|
|
@@ -9444,9 +9444,9 @@ async function downscaleImageDataUrl(dataUrl, opts = {}) {
|
|
|
9444
9444
|
const quality = opts.quality ?? CALLAI_IMAGE_QUALITY;
|
|
9445
9445
|
const keepUnderChars = opts.keepUnderChars ?? 1024 * 1024;
|
|
9446
9446
|
if (!/^data:image\//i.test(dataUrl)) return dataUrl;
|
|
9447
|
-
const rBlob =
|
|
9447
|
+
const rBlob = exception2Result74(() => dataUrlToBlob(dataUrl));
|
|
9448
9448
|
if (rBlob.isErr()) return dataUrl;
|
|
9449
|
-
const rBitmap = await
|
|
9449
|
+
const rBitmap = await exception2Result74(() => createImageBitmap(rBlob.Ok()));
|
|
9450
9450
|
if (rBitmap.isErr()) {
|
|
9451
9451
|
console.warn("[vibe.callAI] could not decode the image to shrink it; sending it as is:", rBitmap.Err().message);
|
|
9452
9452
|
return dataUrl;
|
|
@@ -9456,7 +9456,7 @@ async function downscaleImageDataUrl(dataUrl, opts = {}) {
|
|
|
9456
9456
|
bitmap.close();
|
|
9457
9457
|
return dataUrl;
|
|
9458
9458
|
}
|
|
9459
|
-
const rShrunk = await
|
|
9459
|
+
const rShrunk = await exception2Result74(
|
|
9460
9460
|
async () => blobToDataUrl(await drawJpeg({ bitmap, maxDim, quality, background: "#fff" }))
|
|
9461
9461
|
);
|
|
9462
9462
|
if (rShrunk.isErr()) {
|
|
@@ -9594,7 +9594,7 @@ var init_debug = __esm({
|
|
|
9594
9594
|
});
|
|
9595
9595
|
|
|
9596
9596
|
// ../vibes.diy/vibe/runtime/lazy-seam.ts
|
|
9597
|
-
import { Lazy as Lazy6, Result as Result46, exception2Result as
|
|
9597
|
+
import { Lazy as Lazy6, Result as Result46, exception2Result as exception2Result75 } from "@adviser/cement";
|
|
9598
9598
|
import { Suspense, createElement, use } from "react";
|
|
9599
9599
|
function lazySeam(loader) {
|
|
9600
9600
|
let mod;
|
|
@@ -9602,7 +9602,7 @@ function lazySeam(loader) {
|
|
|
9602
9602
|
let tail;
|
|
9603
9603
|
const once = Lazy6(() => {
|
|
9604
9604
|
asked = true;
|
|
9605
|
-
const promise =
|
|
9605
|
+
const promise = exception2Result75(async () => ({ module: await loader() })).then((r) => {
|
|
9606
9606
|
if (r.isErr()) {
|
|
9607
9607
|
console.warn("[vibe-runtime] a lazy runtime module did not load", r.Err());
|
|
9608
9608
|
return Result46.Err(r.Err());
|
|
@@ -9660,7 +9660,7 @@ var init_lazy_seam = __esm({
|
|
|
9660
9660
|
});
|
|
9661
9661
|
|
|
9662
9662
|
// ../vibes.diy/base/hooks/img-gen/picture-bytes.ts
|
|
9663
|
-
import { exception2Result as
|
|
9663
|
+
import { exception2Result as exception2Result76 } from "@adviser/cement";
|
|
9664
9664
|
import { type as type100 } from "arktype";
|
|
9665
9665
|
function defaultWarn(event, fields) {
|
|
9666
9666
|
vibe.log("warn", event, fields);
|
|
@@ -9699,7 +9699,7 @@ function createPictureStore(opts) {
|
|
|
9699
9699
|
return;
|
|
9700
9700
|
}
|
|
9701
9701
|
memory2.set(uploadId, blob2);
|
|
9702
|
-
const rPut = await
|
|
9702
|
+
const rPut = await exception2Result76(() => opts.bytes.put(uploadId, blob2));
|
|
9703
9703
|
if (rPut.isErr()) warn("picture-bytes-put-failed", { uploadId, message: rPut.Err().message });
|
|
9704
9704
|
}
|
|
9705
9705
|
__name(keep2, "keep");
|
|
@@ -9727,7 +9727,7 @@ function createPictureStore(opts) {
|
|
|
9727
9727
|
async function headConfirm(uploadId, url) {
|
|
9728
9728
|
if (unconfirmed.has(uploadId) === false) return "none";
|
|
9729
9729
|
if (url.startsWith(filesPrefix) === false) return "unknown";
|
|
9730
|
-
const rRes = await
|
|
9730
|
+
const rRes = await exception2Result76(() => fetcher(url, { method: "HEAD", credentials: "include" }));
|
|
9731
9731
|
if (rRes.isErr()) {
|
|
9732
9732
|
warn("picture-bytes-confirm-failed", { uploadId, message: rRes.Err().message });
|
|
9733
9733
|
return "unknown";
|
|
@@ -9756,7 +9756,7 @@ function createPictureStore(opts) {
|
|
|
9756
9756
|
async function lookup(uploadId) {
|
|
9757
9757
|
const hot = memory2.get(uploadId);
|
|
9758
9758
|
if (hot !== void 0) return hot;
|
|
9759
|
-
const rStored = await
|
|
9759
|
+
const rStored = await exception2Result76(() => withinMs(opts.bytes.get(uploadId), lookupMs));
|
|
9760
9760
|
if (rStored.isErr()) {
|
|
9761
9761
|
warn("picture-bytes-get-failed", { uploadId, message: rStored.Err().message });
|
|
9762
9762
|
return void 0;
|
|
@@ -9774,7 +9774,7 @@ function createPictureStore(opts) {
|
|
|
9774
9774
|
__name(lookup, "lookup");
|
|
9775
9775
|
async function download(uploadId, url) {
|
|
9776
9776
|
if (url.startsWith(filesPrefix) === false) return { outcome: "unavailable" };
|
|
9777
|
-
const rRes = await
|
|
9777
|
+
const rRes = await exception2Result76(() => fetcher(url, { credentials: "include" }));
|
|
9778
9778
|
if (rRes.isErr()) {
|
|
9779
9779
|
warn("picture-bytes-fetch-failed", { uploadId, message: rRes.Err().message });
|
|
9780
9780
|
return { outcome: "unavailable" };
|
|
@@ -9790,7 +9790,7 @@ function createPictureStore(opts) {
|
|
|
9790
9790
|
dropUnconfirmed(uploadId);
|
|
9791
9791
|
return { outcome: "other-upload" };
|
|
9792
9792
|
}
|
|
9793
|
-
const rBlob = await
|
|
9793
|
+
const rBlob = await exception2Result76(() => res.blob());
|
|
9794
9794
|
if (rBlob.isErr()) {
|
|
9795
9795
|
warn("picture-bytes-body-failed", { uploadId, message: rBlob.Err().message });
|
|
9796
9796
|
return { outcome: "unavailable" };
|
|
@@ -10029,7 +10029,7 @@ var init_local_pictures = __esm({
|
|
|
10029
10029
|
|
|
10030
10030
|
// ../vibes.diy/base/hooks/img-gen/use-img-gen.ts
|
|
10031
10031
|
import { useState, useEffect, useMemo, useRef, useCallback } from "react";
|
|
10032
|
-
import { exception2Result as
|
|
10032
|
+
import { exception2Result as exception2Result77, Result as Result47 } from "@adviser/cement";
|
|
10033
10033
|
import { type as type101 } from "arktype";
|
|
10034
10034
|
function isValidVersionDoc(d) {
|
|
10035
10035
|
if (d.type !== "version") return false;
|
|
@@ -10207,7 +10207,7 @@ async function probeWithDeadline(probe, hostDbName, hostDocId) {
|
|
|
10207
10207
|
imgGenProbeDeadlineMs
|
|
10208
10208
|
);
|
|
10209
10209
|
});
|
|
10210
|
-
const res = await Promise.race([
|
|
10210
|
+
const res = await Promise.race([exception2Result77(() => probe(hostDbName, hostDocId)), deadline]);
|
|
10211
10211
|
if (timer !== void 0) clearTimeout(timer);
|
|
10212
10212
|
return res;
|
|
10213
10213
|
}
|
|
@@ -10381,8 +10381,8 @@ function useImgGen(opts) {
|
|
|
10381
10381
|
if (playgroundSpentKeyRef.current !== genKey) setNeedsTap(false);
|
|
10382
10382
|
readStartedPending = readPending();
|
|
10383
10383
|
const [rMediaDocs, rLegacy] = await Promise.all([
|
|
10384
|
-
|
|
10385
|
-
|
|
10384
|
+
exception2Result77(() => loadMediaDocs()),
|
|
10385
|
+
exception2Result77(() => db.get(hostDocId))
|
|
10386
10386
|
]);
|
|
10387
10387
|
if (rMediaDocs.isErr()) {
|
|
10388
10388
|
setError(rMediaDocs.Err());
|
|
@@ -10608,7 +10608,7 @@ function useImgGen(opts) {
|
|
|
10608
10608
|
await liveLease;
|
|
10609
10609
|
if (unmountSignalRef.current.aborted || leaseWaitRef.current !== waitKey) return;
|
|
10610
10610
|
if (currentGenRef.current !== null) return;
|
|
10611
|
-
const rRead = await
|
|
10611
|
+
const rRead = await exception2Result77(loadMediaDocs);
|
|
10612
10612
|
if (unmountSignalRef.current.aborted || leaseWaitRef.current !== waitKey || currentGenRef.current !== null) return;
|
|
10613
10613
|
leaseWaitRef.current = null;
|
|
10614
10614
|
currentGenRef.current = genKey;
|
|
@@ -10651,7 +10651,7 @@ function useImgGen(opts) {
|
|
|
10651
10651
|
};
|
|
10652
10652
|
const tapRun = tapStarted && generationId !== void 0 && tapSpentRef.current !== generationId;
|
|
10653
10653
|
if (tapRun) tapSpentRef.current = generationId;
|
|
10654
|
-
const rFiles = await
|
|
10654
|
+
const rFiles = await exception2Result77(
|
|
10655
10655
|
() => imgGen2(generationPrompt, {
|
|
10656
10656
|
inputImage,
|
|
10657
10657
|
model,
|
|
@@ -10676,7 +10676,7 @@ function useImgGen(opts) {
|
|
|
10676
10676
|
madeElsewhereKeyRef.current = failKey;
|
|
10677
10677
|
setLoading(false);
|
|
10678
10678
|
setPending(true);
|
|
10679
|
-
const rRead = await
|
|
10679
|
+
const rRead = await exception2Result77(loadMediaDocs);
|
|
10680
10680
|
if (unmountSignalRef.current.aborted || currentGenRef.current !== genKey) return;
|
|
10681
10681
|
if (rRead.isErr()) {
|
|
10682
10682
|
setError(rRead.Err());
|
|
@@ -10742,7 +10742,7 @@ function useImgGen(opts) {
|
|
|
10742
10742
|
void pictures.seed(file.uploadId, ownBytes);
|
|
10743
10743
|
seededRef.current.add(file.uploadId);
|
|
10744
10744
|
}
|
|
10745
|
-
const rRun = await
|
|
10745
|
+
const rRun = await exception2Result77(async () => {
|
|
10746
10746
|
setProgress(90);
|
|
10747
10747
|
const showCommitted = /* @__PURE__ */ __name(async (uploadId, clientWrite) => {
|
|
10748
10748
|
releaseLease();
|
|
@@ -10913,7 +10913,7 @@ function useImgGen(opts) {
|
|
|
10913
10913
|
model,
|
|
10914
10914
|
sourceKey: incomingSourceKey
|
|
10915
10915
|
});
|
|
10916
|
-
return
|
|
10916
|
+
return exception2Result77(
|
|
10917
10917
|
() => mediaDb.put({ ...versionBody, _id: mediaVersionDocId(hostDocId, PROMPT_KEY, seq) })
|
|
10918
10918
|
);
|
|
10919
10919
|
}, "putVersionAt");
|
|
@@ -11112,7 +11112,7 @@ var init_use_img_gen = __esm({
|
|
|
11112
11112
|
|
|
11113
11113
|
// ../vibes.diy/base/hooks/img-gen/use-picture-src.ts
|
|
11114
11114
|
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
11115
|
-
import { exception2Result as
|
|
11115
|
+
import { exception2Result as exception2Result78 } from "@adviser/cement";
|
|
11116
11116
|
function usePictureSrc(args) {
|
|
11117
11117
|
const { url, uploadId, store, minted, onUnavailable } = args;
|
|
11118
11118
|
const direct = url === void 0 || uploadId === void 0 || uploadId === "" || store === void 0 || url.startsWith("blob:") || url.startsWith("data:");
|
|
@@ -11132,14 +11132,14 @@ function usePictureSrc(args) {
|
|
|
11132
11132
|
}
|
|
11133
11133
|
__name(paintBlob, "paintBlob");
|
|
11134
11134
|
async function resolve6({ k, s, u, id }) {
|
|
11135
|
-
const rHit = await
|
|
11135
|
+
const rHit = await exception2Result78(() => s.lookup(id));
|
|
11136
11136
|
if (gone()) return;
|
|
11137
11137
|
if (rHit.isErr()) vibe.log("warn", "imggen-picture-lookup-failed", { uploadId: id, message: rHit.Err().message });
|
|
11138
11138
|
const hit = rHit.isOk() ? rHit.Ok() : void 0;
|
|
11139
11139
|
if (hit !== void 0 && isRasterImageType(hit.type)) {
|
|
11140
11140
|
paintBlob(k, hit);
|
|
11141
11141
|
if (s.isUnconfirmed(id)) {
|
|
11142
|
-
const rConfirm = await
|
|
11142
|
+
const rConfirm = await exception2Result78(() => s.confirm({ uploadId: id, url: u }));
|
|
11143
11143
|
if (gone()) return;
|
|
11144
11144
|
if (rConfirm.isErr()) {
|
|
11145
11145
|
vibe.log("warn", "imggen-picture-confirm-failed", { uploadId: id, message: rConfirm.Err().message });
|
|
@@ -11150,11 +11150,11 @@ function usePictureSrc(args) {
|
|
|
11150
11150
|
return;
|
|
11151
11151
|
}
|
|
11152
11152
|
if (minted === false) {
|
|
11153
|
-
const rFill2 = await
|
|
11153
|
+
const rFill2 = await exception2Result78(() => s.fill({ uploadId: id, url: u }));
|
|
11154
11154
|
if (rFill2.isErr()) vibe.log("warn", "imggen-picture-fill-failed", { uploadId: id, message: rFill2.Err().message });
|
|
11155
11155
|
return;
|
|
11156
11156
|
}
|
|
11157
|
-
const rFill = await
|
|
11157
|
+
const rFill = await exception2Result78(() => s.fill({ uploadId: id, url: u }));
|
|
11158
11158
|
if (gone()) return;
|
|
11159
11159
|
if (rFill.isErr()) {
|
|
11160
11160
|
vibe.log("warn", "imggen-picture-fill-failed", { uploadId: id, message: rFill.Err().message });
|
|
@@ -11907,7 +11907,7 @@ var init_launch_artwork = __esm({
|
|
|
11907
11907
|
});
|
|
11908
11908
|
|
|
11909
11909
|
// ../vibes.diy/vibe/runtime/pending-tab-placeholder.ts
|
|
11910
|
-
import { exception2Result as
|
|
11910
|
+
import { exception2Result as exception2Result79 } from "@adviser/cement";
|
|
11911
11911
|
var init_pending_tab_placeholder = __esm({
|
|
11912
11912
|
"../vibes.diy/vibe/runtime/pending-tab-placeholder.ts"() {
|
|
11913
11913
|
"use strict";
|
|
@@ -11921,7 +11921,7 @@ __export(edit_text_exports, {
|
|
|
11921
11921
|
installEditText: () => installEditText,
|
|
11922
11922
|
resetEditTextSession: () => resetEditTextSession
|
|
11923
11923
|
});
|
|
11924
|
-
import { exception2Result as
|
|
11924
|
+
import { exception2Result as exception2Result80 } from "@adviser/cement";
|
|
11925
11925
|
function isElement(node) {
|
|
11926
11926
|
return typeof node === "object" && node !== null && "nodeType" in node && node.nodeType === Node.ELEMENT_NODE;
|
|
11927
11927
|
}
|
|
@@ -11934,7 +11934,7 @@ function vidOf(el) {
|
|
|
11934
11934
|
}
|
|
11935
11935
|
function postToParent(m) {
|
|
11936
11936
|
if (window.parent === window) return;
|
|
11937
|
-
const posted =
|
|
11937
|
+
const posted = exception2Result80(() => window.parent.postMessage(m, "*"));
|
|
11938
11938
|
if (posted.isErr()) {
|
|
11939
11939
|
console.error("[vibe edit-text] could not notify host:", posted.Err());
|
|
11940
11940
|
}
|
|
@@ -12487,7 +12487,7 @@ var init_hot_swap_state = __esm({
|
|
|
12487
12487
|
});
|
|
12488
12488
|
|
|
12489
12489
|
// ../vibes.diy/vibe/runtime/calm-errors.ts
|
|
12490
|
-
import { exception2Result as
|
|
12490
|
+
import { exception2Result as exception2Result81 } from "@adviser/cement";
|
|
12491
12491
|
function postHotSwapMessageToParent(message4) {
|
|
12492
12492
|
window.parent.postMessage(message4, "*");
|
|
12493
12493
|
}
|
|
@@ -12502,7 +12502,7 @@ function postHotSwapErrorToParent(message4, id, restored) {
|
|
|
12502
12502
|
...hotSwapRuntimeId !== void 0 ? { runtimeId: hotSwapRuntimeId } : {},
|
|
12503
12503
|
...restored !== void 0 ? { restored } : {}
|
|
12504
12504
|
};
|
|
12505
|
-
const posted =
|
|
12505
|
+
const posted = exception2Result81(() => postHotSwapMessage(msg));
|
|
12506
12506
|
if (posted.isErr()) {
|
|
12507
12507
|
console.error("[vibe build] could not notify host of unresolved build error:", posted.Err());
|
|
12508
12508
|
}
|
|
@@ -12523,7 +12523,7 @@ function postBootErrorToParent(message4, errorName2) {
|
|
|
12523
12523
|
...hotSwapRuntimeId !== void 0 ? { runtimeId: hotSwapRuntimeId } : {}
|
|
12524
12524
|
};
|
|
12525
12525
|
const post2 = /* @__PURE__ */ __name(() => {
|
|
12526
|
-
const posted =
|
|
12526
|
+
const posted = exception2Result81(() => postBootErrorMessage(msg));
|
|
12527
12527
|
if (posted.isErr()) {
|
|
12528
12528
|
console.error("[vibe boot] could not notify host of boot error:", posted.Err());
|
|
12529
12529
|
}
|
|
@@ -12547,7 +12547,7 @@ function postHotSwapOkToParent(id) {
|
|
|
12547
12547
|
ok: true,
|
|
12548
12548
|
...hotSwapRuntimeId !== void 0 ? { runtimeId: hotSwapRuntimeId } : {}
|
|
12549
12549
|
};
|
|
12550
|
-
const posted =
|
|
12550
|
+
const posted = exception2Result81(() => postHotSwapMessage(msg));
|
|
12551
12551
|
if (posted.isErr()) {
|
|
12552
12552
|
console.error("[vibe build] could not notify host of hot-swap success:", posted.Err());
|
|
12553
12553
|
}
|
|
@@ -12558,7 +12558,7 @@ function postHotSwapPaintedToParent(id) {
|
|
|
12558
12558
|
id,
|
|
12559
12559
|
...hotSwapRuntimeId !== void 0 ? { runtimeId: hotSwapRuntimeId } : {}
|
|
12560
12560
|
};
|
|
12561
|
-
const posted =
|
|
12561
|
+
const posted = exception2Result81(() => postHotSwapMessage(msg));
|
|
12562
12562
|
if (posted.isErr()) {
|
|
12563
12563
|
console.error("[vibe build] could not notify host of hot-swap paint:", posted.Err());
|
|
12564
12564
|
}
|
|
@@ -12598,7 +12598,7 @@ function errorSummary(error) {
|
|
|
12598
12598
|
function thrownName(error) {
|
|
12599
12599
|
if (error === null) return "null";
|
|
12600
12600
|
if (typeof error !== "object" && typeof error !== "function") return typeof error;
|
|
12601
|
-
const name =
|
|
12601
|
+
const name = exception2Result81(() => error.constructor?.name);
|
|
12602
12602
|
if (name.isErr()) return "Object";
|
|
12603
12603
|
const value = name.Ok();
|
|
12604
12604
|
return typeof value === "string" ? value : "Object";
|
|
@@ -12681,7 +12681,7 @@ async function restoreAfterHotSwapFailure(attempt) {
|
|
|
12681
12681
|
}
|
|
12682
12682
|
const source = started.source;
|
|
12683
12683
|
const token = started.token;
|
|
12684
|
-
const restoredResult = await
|
|
12684
|
+
const restoredResult = await exception2Result81(() => restore(source, token));
|
|
12685
12685
|
const restored = restoredResult.isOk() && restoredResult.Ok() === true;
|
|
12686
12686
|
if (isHotSwapRollbackCurrent(hotSwapState, token) === false) return;
|
|
12687
12687
|
hotSwapState = finishHotSwapRollback(hotSwapState, restored, token);
|
|
@@ -12767,9 +12767,9 @@ var init_calm_errors = __esm({
|
|
|
12767
12767
|
});
|
|
12768
12768
|
|
|
12769
12769
|
// ../vibes.diy/vibe/runtime/safe-local-storage.ts
|
|
12770
|
-
import { exception2Result as
|
|
12770
|
+
import { exception2Result as exception2Result82 } from "@adviser/cement";
|
|
12771
12771
|
function safeLocalStorage() {
|
|
12772
|
-
const probed =
|
|
12772
|
+
const probed = exception2Result82(() => {
|
|
12773
12773
|
const s = globalThis.localStorage;
|
|
12774
12774
|
if (s === void 0) return void 0;
|
|
12775
12775
|
s.setItem(PROBE_KEY, "1");
|
|
@@ -12788,7 +12788,7 @@ var init_safe_local_storage = __esm({
|
|
|
12788
12788
|
});
|
|
12789
12789
|
|
|
12790
12790
|
// ../vibes.diy/vibe/runtime/viewer-identity-cache.ts
|
|
12791
|
-
import { exception2Result as
|
|
12791
|
+
import { exception2Result as exception2Result83 } from "@adviser/cement";
|
|
12792
12792
|
import { type as type102 } from "arktype";
|
|
12793
12793
|
var viewerIdentitySchema;
|
|
12794
12794
|
var init_viewer_identity_cache = __esm({
|
|
@@ -12801,7 +12801,7 @@ var init_viewer_identity_cache = __esm({
|
|
|
12801
12801
|
});
|
|
12802
12802
|
|
|
12803
12803
|
// ../vibes.diy/vibe/runtime/social-graph-cache.ts
|
|
12804
|
-
import { exception2Result as
|
|
12804
|
+
import { exception2Result as exception2Result84 } from "@adviser/cement";
|
|
12805
12805
|
import { type as type103 } from "arktype";
|
|
12806
12806
|
var persistedSocialGraph;
|
|
12807
12807
|
var init_social_graph_cache = __esm({
|
|
@@ -12816,7 +12816,7 @@ var init_social_graph_cache = __esm({
|
|
|
12816
12816
|
});
|
|
12817
12817
|
|
|
12818
12818
|
// ../vibes.diy/vibe/runtime/vibe-log.ts
|
|
12819
|
-
import { exception2Result as
|
|
12819
|
+
import { exception2Result as exception2Result85 } from "@adviser/cement";
|
|
12820
12820
|
function visibilityOf(s) {
|
|
12821
12821
|
if (s.hooks.visibilityState) return s.hooks.visibilityState();
|
|
12822
12822
|
const doc = globalThis.document;
|
|
@@ -12838,7 +12838,7 @@ function renderVibeLogArgs(args) {
|
|
|
12838
12838
|
parts.push(errLike.stack);
|
|
12839
12839
|
continue;
|
|
12840
12840
|
}
|
|
12841
|
-
const s =
|
|
12841
|
+
const s = exception2Result85(() => JSON.stringify(a));
|
|
12842
12842
|
const rendered = s.isErr() ? void 0 : s.Ok();
|
|
12843
12843
|
parts.push(rendered === void 0 ? String(a) : rendered);
|
|
12844
12844
|
}
|
|
@@ -13285,7 +13285,7 @@ var init_firefly_files_write = __esm({
|
|
|
13285
13285
|
});
|
|
13286
13286
|
|
|
13287
13287
|
// ../vibes.diy/vibe/runtime/write-receipts.ts
|
|
13288
|
-
import { exception2Result as
|
|
13288
|
+
import { exception2Result as exception2Result86 } from "@adviser/cement";
|
|
13289
13289
|
function isTerminalWriteStatus(status) {
|
|
13290
13290
|
return status === "accepted" || status === "refused" || status === "superseded";
|
|
13291
13291
|
}
|
|
@@ -13308,7 +13308,7 @@ function staticWriteSync(state3) {
|
|
|
13308
13308
|
const self = {
|
|
13309
13309
|
...frozen,
|
|
13310
13310
|
on(fn) {
|
|
13311
|
-
|
|
13311
|
+
exception2Result86(() => fn(self));
|
|
13312
13312
|
return noop;
|
|
13313
13313
|
}
|
|
13314
13314
|
};
|
|
@@ -13537,7 +13537,7 @@ var init_write_receipts = __esm({
|
|
|
13537
13537
|
return rec.state.message;
|
|
13538
13538
|
},
|
|
13539
13539
|
on(fn) {
|
|
13540
|
-
|
|
13540
|
+
exception2Result86(() => fn(snapshotOf(rec)));
|
|
13541
13541
|
if (isTerminalWriteStatus(rec.state.status)) return noop;
|
|
13542
13542
|
listeners2.add(fn);
|
|
13543
13543
|
return () => {
|
|
@@ -13582,7 +13582,7 @@ var init_write_receipts = __esm({
|
|
|
13582
13582
|
}
|
|
13583
13583
|
emit(rec) {
|
|
13584
13584
|
const snap = snapshotOf(rec);
|
|
13585
|
-
for (const fn of [...rec.listeners])
|
|
13585
|
+
for (const fn of [...rec.listeners]) exception2Result86(() => fn(snap));
|
|
13586
13586
|
const event = {
|
|
13587
13587
|
opId: rec.opId,
|
|
13588
13588
|
docId: rec.docId,
|
|
@@ -13596,7 +13596,7 @@ var init_write_receipts = __esm({
|
|
|
13596
13596
|
this.emitOps([event]);
|
|
13597
13597
|
}
|
|
13598
13598
|
emitOps(events) {
|
|
13599
|
-
for (const fn of [...this.opListeners])
|
|
13599
|
+
for (const fn of [...this.opListeners]) exception2Result86(() => fn(events));
|
|
13600
13600
|
}
|
|
13601
13601
|
notifyDocs(docIds) {
|
|
13602
13602
|
if (docIds.length === 0) return;
|
|
@@ -13604,7 +13604,7 @@ var init_write_receipts = __esm({
|
|
|
13604
13604
|
for (const id of docIds) this.pendingDocs.add(id);
|
|
13605
13605
|
return;
|
|
13606
13606
|
}
|
|
13607
|
-
for (const fn of [...this.docListeners])
|
|
13607
|
+
for (const fn of [...this.docListeners]) exception2Result86(() => fn(docIds));
|
|
13608
13608
|
}
|
|
13609
13609
|
};
|
|
13610
13610
|
__name(refusedState, "refusedState");
|
|
@@ -13912,12 +13912,12 @@ var init_upload_doc_files = __esm({
|
|
|
13912
13912
|
});
|
|
13913
13913
|
|
|
13914
13914
|
// ../vibes.diy/vibe/runtime/local-write-count.ts
|
|
13915
|
-
import { exception2Result as
|
|
13915
|
+
import { exception2Result as exception2Result87 } from "@adviser/cement";
|
|
13916
13916
|
function counterHost() {
|
|
13917
13917
|
return globalThis;
|
|
13918
13918
|
}
|
|
13919
13919
|
function noteLocalWrite() {
|
|
13920
|
-
|
|
13920
|
+
exception2Result87(() => {
|
|
13921
13921
|
const host = counterHost();
|
|
13922
13922
|
const prev = host[LOCAL_WRITES_GLOBAL];
|
|
13923
13923
|
host[LOCAL_WRITES_GLOBAL] = typeof prev === "number" && Number.isFinite(prev) && prev >= 0 ? prev + 1 : 1;
|
|
@@ -13934,7 +13934,7 @@ var init_local_write_count = __esm({
|
|
|
13934
13934
|
});
|
|
13935
13935
|
|
|
13936
13936
|
// ../vibes.diy/vibe/runtime/indexeddb-store.ts
|
|
13937
|
-
import { Result as Result49, exception2Result as
|
|
13937
|
+
import { Result as Result49, exception2Result as exception2Result88 } from "@adviser/cement";
|
|
13938
13938
|
import { type as type104 } from "arktype";
|
|
13939
13939
|
function requestResult(request) {
|
|
13940
13940
|
return new Promise((resolve6, reject) => {
|
|
@@ -14013,9 +14013,9 @@ function legacyStoreNames(name, storage) {
|
|
|
14013
14013
|
return [...names];
|
|
14014
14014
|
}
|
|
14015
14015
|
function readLegacyLocalStorageDocs(name, storage) {
|
|
14016
|
-
const raw =
|
|
14016
|
+
const raw = exception2Result88(() => storage.getItem(`firefly-anon:db:${name}`));
|
|
14017
14017
|
if (raw.isErr() || raw.Ok() == null) return [];
|
|
14018
|
-
const parsed =
|
|
14018
|
+
const parsed = exception2Result88(() => JSON.parse(raw.Ok()));
|
|
14019
14019
|
if (parsed.isErr()) return [];
|
|
14020
14020
|
const validated = legacyPersistedDocs(parsed.Ok());
|
|
14021
14021
|
if (validated instanceof type104.errors) return [];
|
|
@@ -14348,11 +14348,11 @@ var init_indexeddb_store = __esm({
|
|
|
14348
14348
|
return this.runTx(fresh.Ok(), storeNames, fill);
|
|
14349
14349
|
}
|
|
14350
14350
|
async runTx(db, storeNames, fill) {
|
|
14351
|
-
const opened =
|
|
14351
|
+
const opened = exception2Result88(() => db.transaction(storeNames, "readwrite"));
|
|
14352
14352
|
if (opened.isErr()) return Result49.Err(opened.Err());
|
|
14353
14353
|
const tx = opened.Ok();
|
|
14354
|
-
const done2 =
|
|
14355
|
-
const filled = await
|
|
14354
|
+
const done2 = exception2Result88(() => transactionDone(tx));
|
|
14355
|
+
const filled = await exception2Result88(() => fill(tx));
|
|
14356
14356
|
if (filled.isErr()) {
|
|
14357
14357
|
const err2 = filled.Err();
|
|
14358
14358
|
if (errorName(err2) === "AbortError") {
|
|
@@ -14360,7 +14360,7 @@ var init_indexeddb_store = __esm({
|
|
|
14360
14360
|
if (outcome.isErr()) return Result49.Err(outcome.Err());
|
|
14361
14361
|
return Result49.Err(new Error("IndexedDB write body aborted", { cause: err2 }));
|
|
14362
14362
|
}
|
|
14363
|
-
|
|
14363
|
+
exception2Result88(() => tx.abort());
|
|
14364
14364
|
await done2;
|
|
14365
14365
|
return Result49.Err(err2);
|
|
14366
14366
|
}
|
|
@@ -14371,8 +14371,8 @@ var init_indexeddb_store = __esm({
|
|
|
14371
14371
|
reconnect(lost) {
|
|
14372
14372
|
if (this.db !== void 0 && this.db !== lost) return Promise.resolve(Result49.Ok(this.db));
|
|
14373
14373
|
if (this.reopening === void 0) {
|
|
14374
|
-
|
|
14375
|
-
this.reopening =
|
|
14374
|
+
exception2Result88(() => lost.close());
|
|
14375
|
+
this.reopening = exception2Result88(() => openDatabase(this.factory, this.app, this.name)).then((opened) => {
|
|
14376
14376
|
this.reopening = void 0;
|
|
14377
14377
|
if (opened.isErr()) return Result49.Err(opened.Err());
|
|
14378
14378
|
const { db } = opened.Ok();
|
|
@@ -14924,7 +14924,7 @@ var init_indexeddb_store = __esm({
|
|
|
14924
14924
|
}
|
|
14925
14925
|
notify(docs, meta) {
|
|
14926
14926
|
for (const listener of this.listeners) {
|
|
14927
|
-
const called =
|
|
14927
|
+
const called = exception2Result88(() => meta === void 0 ? listener(docs) : listener(docs, meta));
|
|
14928
14928
|
if (called.isErr()) continue;
|
|
14929
14929
|
}
|
|
14930
14930
|
}
|
|
@@ -15046,7 +15046,7 @@ var init_runtime_build = __esm({
|
|
|
15046
15046
|
});
|
|
15047
15047
|
|
|
15048
15048
|
// ../vibes.diy/vibe/runtime/bare-specifier-rewrite.ts
|
|
15049
|
-
import { BuildURI as BuildURI6, URI as
|
|
15049
|
+
import { BuildURI as BuildURI6, URI as URI9, exception2Result as exception2Result89 } from "@adviser/cement";
|
|
15050
15050
|
var init_bare_specifier_rewrite = __esm({
|
|
15051
15051
|
"../vibes.diy/vibe/runtime/bare-specifier-rewrite.ts"() {
|
|
15052
15052
|
"use strict";
|
|
@@ -15061,7 +15061,7 @@ var init_typing_hold = __esm({
|
|
|
15061
15061
|
});
|
|
15062
15062
|
|
|
15063
15063
|
// ../vibes.diy/vibe/runtime/register-dependencies.ts
|
|
15064
|
-
import { exception2Result as
|
|
15064
|
+
import { exception2Result as exception2Result90, Future, Lazy as Lazy7, OnFunc, OnFuncReturn, Result as Result50, timeouted as timeouted2 } from "@adviser/cement";
|
|
15065
15065
|
import { type as type105 } from "arktype";
|
|
15066
15066
|
function handleHintFrom(opts) {
|
|
15067
15067
|
if (typeof opts !== "object" || opts === null) return void 0;
|
|
@@ -16473,7 +16473,7 @@ var init_shadcn_theme_inline = __esm({
|
|
|
16473
16473
|
});
|
|
16474
16474
|
|
|
16475
16475
|
// ../vibes.diy/vibe/runtime/mirror-store.ts
|
|
16476
|
-
import { Future as Future2, exception2Result as
|
|
16476
|
+
import { Future as Future2, exception2Result as exception2Result91 } from "@adviser/cement";
|
|
16477
16477
|
function subscribeBackoffMs(step) {
|
|
16478
16478
|
return step < SUBSCRIBE_BACKOFF_MS.length ? SUBSCRIBE_BACKOFF_MS[step] : SUBSCRIBE_BACKOFF_CAP_MS;
|
|
16479
16479
|
}
|
|
@@ -17264,7 +17264,7 @@ var init_mirror_store = __esm({
|
|
|
17264
17264
|
// no retry changes, so it ends the loop at once.
|
|
17265
17265
|
async reliableMirrorWrite(writes) {
|
|
17266
17266
|
for (let attempt = 0; attempt < MIRROR_WRITE_MAX_ATTEMPTS; attempt += 1) {
|
|
17267
|
-
const settled = await
|
|
17267
|
+
const settled = await exception2Result91(() => this.api.mirrorWrite(this.name, this.api.runtimeId, writes));
|
|
17268
17268
|
if (settled.isOk()) {
|
|
17269
17269
|
const ack = settled.Ok();
|
|
17270
17270
|
const refusal5 = ack.status === "ok" ? ack.results.find((r) => r.code === DRAFT_READ_ONLY_CODE) : void 0;
|
|
@@ -17363,7 +17363,7 @@ var init_mirror_store = __esm({
|
|
|
17363
17363
|
return () => this.syncStatusListeners.delete(fn);
|
|
17364
17364
|
}
|
|
17365
17365
|
emitSyncStatus(docIds) {
|
|
17366
|
-
for (const fn of [...this.syncStatusListeners])
|
|
17366
|
+
for (const fn of [...this.syncStatusListeners]) exception2Result91(() => fn(docIds));
|
|
17367
17367
|
}
|
|
17368
17368
|
/** Fold late-arriving SSR seeds into whichever backend is live (#4053 parity). */
|
|
17369
17369
|
foldSeedDocs(seedDocs) {
|
|
@@ -17447,7 +17447,7 @@ var init_mirror_store = __esm({
|
|
|
17447
17447
|
}
|
|
17448
17448
|
notify(docs, meta) {
|
|
17449
17449
|
for (const listener of this.listeners) {
|
|
17450
|
-
const called =
|
|
17450
|
+
const called = exception2Result91(() => meta === void 0 ? listener(docs) : listener(docs, meta));
|
|
17451
17451
|
if (called.isErr()) continue;
|
|
17452
17452
|
}
|
|
17453
17453
|
}
|
|
@@ -17456,7 +17456,7 @@ var init_mirror_store = __esm({
|
|
|
17456
17456
|
});
|
|
17457
17457
|
|
|
17458
17458
|
// ../vibes.diy/vibe/runtime/sync-engine.ts
|
|
17459
|
-
import { exception2Result as
|
|
17459
|
+
import { exception2Result as exception2Result92 } from "@adviser/cement";
|
|
17460
17460
|
function nextBackoff(current, base, cap) {
|
|
17461
17461
|
const next = current === 0 ? base : current * 2;
|
|
17462
17462
|
return next > cap ? cap : next;
|
|
@@ -18101,7 +18101,7 @@ var init_sync_engine = __esm({
|
|
|
18101
18101
|
}
|
|
18102
18102
|
this.store.receipts.supersede(skipOpIds);
|
|
18103
18103
|
if (skipIds.length > 0) {
|
|
18104
|
-
const rSkip = await
|
|
18104
|
+
const rSkip = await exception2Result92(() => this.store.dequeuePush(skipIds));
|
|
18105
18105
|
if (rSkip.isErr()) {
|
|
18106
18106
|
this.schedulePushRetry();
|
|
18107
18107
|
return;
|
|
@@ -18134,7 +18134,7 @@ var init_sync_engine = __esm({
|
|
|
18134
18134
|
const unchanged = new Set(push.accepted.filter((a) => a.unchanged === true).map((a) => a.docId));
|
|
18135
18135
|
const rejected = new Map((push.rejected ?? []).map((r) => [r.docId, r]));
|
|
18136
18136
|
const release = this.store.receipts.holdNotifications();
|
|
18137
|
-
const rVerdicts = await
|
|
18137
|
+
const rVerdicts = await exception2Result92(async () => {
|
|
18138
18138
|
const applied = await this.applyVerdicts({ writes, idsByDoc, opIdsByDoc, accepted, unchanged, rejected });
|
|
18139
18139
|
if (applied !== void 0 && applied.dequeueIds.length > 0) await this.store.dequeuePush(applied.dequeueIds);
|
|
18140
18140
|
if (applied !== void 0) for (const docId of applied.acceptedDocIds) this.anonymousDocIds.delete(docId);
|
|
@@ -18233,10 +18233,10 @@ var init_sync_engine = __esm({
|
|
|
18233
18233
|
* since deleted) → delete locally + clear queue remnants.
|
|
18234
18234
|
*/
|
|
18235
18235
|
async convergeRefused(docId) {
|
|
18236
|
-
const res = await
|
|
18236
|
+
const res = await exception2Result92(() => this.api.getDoc(docId, this.dbName));
|
|
18237
18237
|
if (this.stopped || res.isErr()) return false;
|
|
18238
18238
|
const got = res.Ok();
|
|
18239
|
-
const rConverge = await
|
|
18239
|
+
const rConverge = await exception2Result92(
|
|
18240
18240
|
() => got.status === "not-found" ? this.store.revertDoc(docId) : this.store.overwriteFromServer(docId, got.doc)
|
|
18241
18241
|
);
|
|
18242
18242
|
if (rConverge.isErr()) return false;
|
|
@@ -20090,7 +20090,7 @@ var init_use_connection = __esm({
|
|
|
20090
20090
|
});
|
|
20091
20091
|
|
|
20092
20092
|
// ../vibes.diy/vibe/runtime/api-fetch.ts
|
|
20093
|
-
import { Result as Result52, exception2Result as
|
|
20093
|
+
import { Result as Result52, exception2Result as exception2Result93 } from "@adviser/cement";
|
|
20094
20094
|
var init_api_fetch = __esm({
|
|
20095
20095
|
"../vibes.diy/vibe/runtime/api-fetch.ts"() {
|
|
20096
20096
|
"use strict";
|
|
@@ -20118,7 +20118,7 @@ var init_use_interest = __esm({
|
|
|
20118
20118
|
});
|
|
20119
20119
|
|
|
20120
20120
|
// ../vibes.diy/vibe/runtime/world-controls-desktop.ts
|
|
20121
|
-
import { exception2Result as
|
|
20121
|
+
import { exception2Result as exception2Result94 } from "@adviser/cement";
|
|
20122
20122
|
function isTyping(focused) {
|
|
20123
20123
|
if ("isContentEditable" in focused && focused.isContentEditable === true) return true;
|
|
20124
20124
|
return focused.closest(TYPING) !== null;
|
|
@@ -20227,7 +20227,7 @@ function attachDesktopControls(args) {
|
|
|
20227
20227
|
if (e.button !== 0 && e.button !== 2) return;
|
|
20228
20228
|
if (onOwnControl(el, e.target)) return;
|
|
20229
20229
|
drag = { x: e.clientX, y: e.clientY, lastX: e.clientX, lastY: e.clientY, t: e.timeStamp, button: e.button, moved: false };
|
|
20230
|
-
|
|
20230
|
+
exception2Result94(() => el.setPointerCapture(e.pointerId));
|
|
20231
20231
|
}
|
|
20232
20232
|
__name(onPointerDown, "onPointerDown");
|
|
20233
20233
|
function onPointerMove(e) {
|
|
@@ -20343,7 +20343,7 @@ __export(world_controls_exports, {
|
|
|
20343
20343
|
fovFor: () => fovFor,
|
|
20344
20344
|
tuneOf: () => tuneOf2
|
|
20345
20345
|
});
|
|
20346
|
-
import { exception2Result as
|
|
20346
|
+
import { exception2Result as exception2Result95 } from "@adviser/cement";
|
|
20347
20347
|
function clamp2(v, lo, hi) {
|
|
20348
20348
|
return Math.min(hi, Math.max(lo, v));
|
|
20349
20349
|
}
|
|
@@ -20450,7 +20450,7 @@ function attachTouchControls(args) {
|
|
|
20450
20450
|
} else if (active.size >= 2) return;
|
|
20451
20451
|
const side = p.x < p.w / 2 ? "stick" : "look";
|
|
20452
20452
|
if (freeCam === false && sideTaken(side)) return;
|
|
20453
|
-
|
|
20453
|
+
exception2Result95(() => el.setPointerCapture(e.pointerId));
|
|
20454
20454
|
const g = {
|
|
20455
20455
|
id: e.pointerId,
|
|
20456
20456
|
side,
|
|
@@ -20874,7 +20874,7 @@ var init_access_extract = __esm({
|
|
|
20874
20874
|
});
|
|
20875
20875
|
|
|
20876
20876
|
// ../vibes.diy/vibe/runtime/access-runner.ts
|
|
20877
|
-
import { exception2Result as
|
|
20877
|
+
import { exception2Result as exception2Result96 } from "@adviser/cement";
|
|
20878
20878
|
var init_access_runner = __esm({
|
|
20879
20879
|
"../vibes.diy/vibe/runtime/access-runner.ts"() {
|
|
20880
20880
|
"use strict";
|
|
@@ -23507,7 +23507,7 @@ __export(vibe_pkg_hashed_import_map_exports, {
|
|
|
23507
23507
|
vibePkgHashedPathsFor: () => vibePkgHashedPathsFor,
|
|
23508
23508
|
vibePkgManifestUrl: () => vibePkgManifestUrl
|
|
23509
23509
|
});
|
|
23510
|
-
import { BuildURI as BuildURI9, exception2Result as
|
|
23510
|
+
import { BuildURI as BuildURI9, exception2Result as exception2Result108, KeyedResolvOnce as KeyedResolvOnce5, Result as Result58, stream2string as stream2string2 } from "@adviser/cement";
|
|
23511
23511
|
import { type as type110 } from "arktype";
|
|
23512
23512
|
function importMapHashOf(paths) {
|
|
23513
23513
|
const versions = lockedVersions;
|
|
@@ -23539,9 +23539,9 @@ function resetVibePkgManifestCacheForTests() {
|
|
|
23539
23539
|
function loadVibePkgHashedPaths(src) {
|
|
23540
23540
|
const url = vibePkgManifestUrl(src.workspace);
|
|
23541
23541
|
return manifestOnce.get(url).once(async () => {
|
|
23542
|
-
const rStream = await
|
|
23542
|
+
const rStream = await exception2Result108(() => src.fetchAsset(url));
|
|
23543
23543
|
if (rStream.isErr()) return void 0;
|
|
23544
|
-
const rRaw = await
|
|
23544
|
+
const rRaw = await exception2Result108(async () => JSON.parse(await stream2string2(rStream.Ok())));
|
|
23545
23545
|
if (rRaw.isErr()) return void 0;
|
|
23546
23546
|
const rPaths = parseVibePkgManifest(rRaw.Ok());
|
|
23547
23547
|
if (rPaths.isErr()) {
|
|
@@ -32899,6 +32899,12 @@ var reqSetGroupPayer = lazyType(
|
|
|
32899
32899
|
* sponsored group, so the turn runs on the sponsor's credits, acting as nobody.
|
|
32900
32900
|
*/
|
|
32901
32901
|
"sponsored?": "boolean",
|
|
32902
|
+
/**
|
|
32903
|
+
* With `sponsored` only: a group's woken turn with no linked member to pay (2026-11-23), billed
|
|
32904
|
+
* as an unlinked member's turn is. No member's message, so no member turn is noted and the
|
|
32905
|
+
* group's back-off holds. The answer echoes it; an older server doesn't, and the bridge refuses.
|
|
32906
|
+
*/
|
|
32907
|
+
"wake?": "boolean",
|
|
32902
32908
|
/**
|
|
32903
32909
|
* With `sponsored` only (issue #10043, Chris 2026-11-18): the member who hasn't linked, named by
|
|
32904
32910
|
* their own one-to-one phone-guest principal (`group:<id>`, the one a direct chat with their
|
|
@@ -32917,7 +32923,9 @@ var resSetGroupPayer = lazyType(
|
|
|
32917
32923
|
groupUserId: "string > 0",
|
|
32918
32924
|
payerUserId: "string > 0",
|
|
32919
32925
|
/** Set when the sponsor was made the payer for a member who hasn't linked; an older server never sends it. */
|
|
32920
|
-
"sponsored?": "boolean"
|
|
32926
|
+
"sponsored?": "boolean",
|
|
32927
|
+
/** Set on a sponsored wake: no member turn was noted. An older server never sends it. */
|
|
32928
|
+
"wake?": "boolean"
|
|
32921
32929
|
})
|
|
32922
32930
|
);
|
|
32923
32931
|
function isResSetGroupPayer(value) {
|
|
@@ -45487,17 +45495,17 @@ import {
|
|
|
45487
45495
|
Option as Option13,
|
|
45488
45496
|
toSortedObject as toSortedObject2,
|
|
45489
45497
|
TxtEnDecoderSingleton as TxtEnDecoderSingleton8,
|
|
45490
|
-
URI as
|
|
45498
|
+
URI as URI13
|
|
45491
45499
|
} from "@adviser/cement";
|
|
45492
45500
|
import { eq as eq74, and as and61, desc as desc15 } from "drizzle-orm/sql/expressions";
|
|
45493
45501
|
|
|
45494
45502
|
// ../vibes.diy/api/svc/intern/guest-app-move.ts
|
|
45495
45503
|
init_types();
|
|
45496
|
-
import { exception2Result as
|
|
45504
|
+
import { exception2Result as exception2Result68, Result as Result40 } from "@adviser/cement";
|
|
45497
45505
|
import { and as and48, eq as eq55, gt as gt6, inArray as inArray19, max as max3, ne as ne5, sql as sql13 } from "drizzle-orm";
|
|
45498
45506
|
|
|
45499
45507
|
// ../vibes.diy/api/svc/intern/ensure-slug-binding.ts
|
|
45500
|
-
import { exception2Result as
|
|
45508
|
+
import { exception2Result as exception2Result60, Result as Result35 } from "@adviser/cement";
|
|
45501
45509
|
|
|
45502
45510
|
// ../vibes.diy/api/svc/intern/post-maker-fact.ts
|
|
45503
45511
|
import { exception2Result as exception2Result15 } from "@adviser/cement";
|
|
@@ -47381,7 +47389,7 @@ async function matchInvitesToNewHandle(ctx, input) {
|
|
|
47381
47389
|
__name(matchInvitesToNewHandle, "matchInvitesToNewHandle");
|
|
47382
47390
|
|
|
47383
47391
|
// ../vibes.diy/api/svc/public/channel-invite-signup-match.ts
|
|
47384
|
-
import { exception2Result as
|
|
47392
|
+
import { exception2Result as exception2Result57 } from "@adviser/cement";
|
|
47385
47393
|
import { and as and40, eq as eq47, ne as ne4 } from "drizzle-orm/sql/expressions";
|
|
47386
47394
|
|
|
47387
47395
|
// ../vibes.diy/api/svc/public/channel-invite-store.ts
|
|
@@ -51404,7 +51412,7 @@ var listInviteGrantsEvento = {
|
|
|
51404
51412
|
};
|
|
51405
51413
|
|
|
51406
51414
|
// ../vibes.diy/api/svc/public/request-flow.ts
|
|
51407
|
-
import { Result as Result23, Option as Option8, EventoResult as EventoResult3, exception2Result as
|
|
51415
|
+
import { Result as Result23, Option as Option8, EventoResult as EventoResult3, exception2Result as exception2Result43 } from "@adviser/cement";
|
|
51408
51416
|
import { eq as eq24, and as and20, lt as lt3, desc as desc6, inArray as inArray9 } from "drizzle-orm/sql/expressions";
|
|
51409
51417
|
import { type as type94 } from "arktype";
|
|
51410
51418
|
|
|
@@ -51427,10 +51435,24 @@ function namedGrantHandle(args) {
|
|
|
51427
51435
|
__name(namedGrantHandle, "namedGrantHandle");
|
|
51428
51436
|
|
|
51429
51437
|
// ../vibes.diy/api/svc/analytics.ts
|
|
51430
|
-
import { exception2Result as
|
|
51438
|
+
import { exception2Result as exception2Result41 } from "@adviser/cement";
|
|
51439
|
+
|
|
51440
|
+
// ../vibes.diy/api/svc/intern/client-attribution.ts
|
|
51441
|
+
import { exception2Result as exception2Result35, URI as URI5 } from "@adviser/cement";
|
|
51442
|
+
function clientRefStamp(vctx) {
|
|
51443
|
+
return vctx.client === void 0 ? {} : { client: vctx.client };
|
|
51444
|
+
}
|
|
51445
|
+
__name(clientRefStamp, "clientRefStamp");
|
|
51446
|
+
function clientLane(client) {
|
|
51447
|
+
const kind = client?.kind;
|
|
51448
|
+
if (typeof kind !== "string" || kind === "") return void 0;
|
|
51449
|
+
const shell = client?.shell;
|
|
51450
|
+
return kind === "mcp" && typeof shell === "string" && shell !== "" ? `mcp/${shell}` : kind;
|
|
51451
|
+
}
|
|
51452
|
+
__name(clientLane, "clientLane");
|
|
51431
51453
|
|
|
51432
51454
|
// ../vibes.diy/api/svc/intern/look-lint.ts
|
|
51433
|
-
import { exception2Result as
|
|
51455
|
+
import { exception2Result as exception2Result39 } from "@adviser/cement";
|
|
51434
51456
|
import { eq as eq22 } from "drizzle-orm";
|
|
51435
51457
|
|
|
51436
51458
|
// ../vibes.diy/api/svc/intern/code-view.ts
|
|
@@ -51636,10 +51658,10 @@ __name(skillsAskReskin, "skillsAskReskin");
|
|
|
51636
51658
|
// ../vibes.diy/api/svc/intern/version-timeline.ts
|
|
51637
51659
|
import { and as and18, eq as eq21, asc as asc2, desc as desc5 } from "drizzle-orm";
|
|
51638
51660
|
init_identity();
|
|
51639
|
-
import { Result as Result21, exception2Result as
|
|
51661
|
+
import { Result as Result21, exception2Result as exception2Result38, stream2uint8array as stream2uint8array2 } from "@adviser/cement";
|
|
51640
51662
|
|
|
51641
51663
|
// ../vibes.diy/api/svc/intern/ordered-fan-out.ts
|
|
51642
|
-
import { exception2Result as
|
|
51664
|
+
import { exception2Result as exception2Result36, Result as Result20 } from "@adviser/cement";
|
|
51643
51665
|
async function mapInOrder(items, limit, fn) {
|
|
51644
51666
|
const settled = new Array(items.length);
|
|
51645
51667
|
let next = 0;
|
|
@@ -51647,7 +51669,7 @@ async function mapInOrder(items, limit, fn) {
|
|
|
51647
51669
|
async function lane() {
|
|
51648
51670
|
while (failed2 === false && next < items.length) {
|
|
51649
51671
|
const index3 = next++;
|
|
51650
|
-
const r = await
|
|
51672
|
+
const r = await exception2Result36(async () => ({ value: await fn(items[index3], index3) }));
|
|
51651
51673
|
settled[index3] = r;
|
|
51652
51674
|
if (r.isErr()) failed2 = true;
|
|
51653
51675
|
}
|
|
@@ -51689,7 +51711,7 @@ function isHiddenFromUnpublishedAt(req2) {
|
|
|
51689
51711
|
__name(isHiddenFromUnpublishedAt, "isHiddenFromUnpublishedAt");
|
|
51690
51712
|
|
|
51691
51713
|
// ../vibes.diy/api/svc/intern/build-version-ordinal.ts
|
|
51692
|
-
import { exception2Result as
|
|
51714
|
+
import { exception2Result as exception2Result37 } from "@adviser/cement";
|
|
51693
51715
|
import { and as and17, eq as eq20 } from "drizzle-orm/sql/expressions";
|
|
51694
51716
|
async function loadVersionItems(vctx, opts) {
|
|
51695
51717
|
const t = vctx.sql.tables.apps;
|
|
@@ -51709,7 +51731,7 @@ async function loadVersionItems(vctx, opts) {
|
|
|
51709
51731
|
}
|
|
51710
51732
|
__name(loadVersionItems, "loadVersionItems");
|
|
51711
51733
|
async function resolveBuildOrdinal(vctx, opts) {
|
|
51712
|
-
const r = await
|
|
51734
|
+
const r = await exception2Result37(() => loadVersionItems(vctx, opts));
|
|
51713
51735
|
if (r.isErr()) {
|
|
51714
51736
|
vctx.logger.Warn().Err(r).Any("event", { ownerHandle: opts.ownerHandle, appSlug: opts.appSlug }).Msg("build-ordinal-read-failed");
|
|
51715
51737
|
return void 0;
|
|
@@ -51787,7 +51809,7 @@ async function resolveVfsFromFileSystemOrThrow(vctx, items, opts) {
|
|
|
51787
51809
|
__name(resolveVfsFromFileSystemOrThrow, "resolveVfsFromFileSystemOrThrow");
|
|
51788
51810
|
var VFS_FETCH_CONCURRENCY = 6;
|
|
51789
51811
|
async function loadVersionTimeline(vctx, chatId) {
|
|
51790
|
-
return
|
|
51812
|
+
return exception2Result38(() => readVersionTimeline(vctx, chatId));
|
|
51791
51813
|
}
|
|
51792
51814
|
__name(loadVersionTimeline, "loadVersionTimeline");
|
|
51793
51815
|
async function readVersionTimeline(vctx, chatId) {
|
|
@@ -51834,7 +51856,7 @@ async function readVersionTimeline(vctx, chatId) {
|
|
|
51834
51856
|
}
|
|
51835
51857
|
__name(readVersionTimeline, "readVersionTimeline");
|
|
51836
51858
|
async function loadAppVersionTimeline(vctx, args) {
|
|
51837
|
-
return
|
|
51859
|
+
return exception2Result38(() => readAppVersionTimeline(vctx, args));
|
|
51838
51860
|
}
|
|
51839
51861
|
__name(loadAppVersionTimeline, "loadAppVersionTimeline");
|
|
51840
51862
|
async function readAppVersionTimeline(vctx, args) {
|
|
@@ -51884,7 +51906,7 @@ async function materializeVersion(vctx, version) {
|
|
|
51884
51906
|
}
|
|
51885
51907
|
__name(materializeVersion, "materializeVersion");
|
|
51886
51908
|
async function loadVersionTimelineHead(vctx, chatId) {
|
|
51887
|
-
return
|
|
51909
|
+
return exception2Result38(
|
|
51888
51910
|
async () => {
|
|
51889
51911
|
const timeline = await readVersionTimeline(vctx, chatId);
|
|
51890
51912
|
const last = timeline.at(-1);
|
|
@@ -51897,7 +51919,7 @@ async function loadVersionTimelineHead(vctx, chatId) {
|
|
|
51897
51919
|
}
|
|
51898
51920
|
__name(loadVersionTimelineHead, "loadVersionTimelineHead");
|
|
51899
51921
|
async function loadSlotTimeline(vctx, chatId, selectedFsId) {
|
|
51900
|
-
return
|
|
51922
|
+
return exception2Result38(async () => {
|
|
51901
51923
|
const timeline = await readVersionTimeline(vctx, chatId);
|
|
51902
51924
|
const meta = selectSlotSources(timeline);
|
|
51903
51925
|
const selectedIdx = selectedFsId === void 0 ? -1 : timeline.findIndex((t) => t.fsId === selectedFsId);
|
|
@@ -51928,7 +51950,7 @@ async function loadSlotTimeline(vctx, chatId, selectedFsId) {
|
|
|
51928
51950
|
}
|
|
51929
51951
|
__name(loadSlotTimeline, "loadSlotTimeline");
|
|
51930
51952
|
async function resolveActiveReleaseBase(vctx, args) {
|
|
51931
|
-
const r = await
|
|
51953
|
+
const r = await exception2Result38(async () => {
|
|
51932
51954
|
const row = await selectLatestAppPerSlug(vctx, { ownerHandle: args.ownerHandle, appSlug: args.appSlug });
|
|
51933
51955
|
if (row === void 0 || row.fsId === void 0) return Result21.Ok(void 0);
|
|
51934
51956
|
if (args.timelineFsIds.includes(row.fsId)) return Result21.Ok(void 0);
|
|
@@ -51955,7 +51977,7 @@ __name(resolveActiveReleaseBase, "resolveActiveReleaseBase");
|
|
|
51955
51977
|
async function resolveEditBaseSeed(vctx, args) {
|
|
51956
51978
|
const chainHead = { vfs: args.chainHeadVfs, carried: args.chainHeadCarried ?? [] };
|
|
51957
51979
|
if (args.editBaseFsId === void 0 || args.editBaseFsId === args.chainHeadFsId) return chainHead;
|
|
51958
|
-
const r = await
|
|
51980
|
+
const r = await exception2Result38(async () => {
|
|
51959
51981
|
const row = await vctx.sql.db.select({ fileSystem: vctx.sql.tables.apps.fileSystem }).from(vctx.sql.tables.apps).where(
|
|
51960
51982
|
and18(
|
|
51961
51983
|
eq21(vctx.sql.tables.apps.fsId, args.editBaseFsId),
|
|
@@ -52000,7 +52022,7 @@ async function designRepairSupersededBase(vctx, args) {
|
|
|
52000
52022
|
if (base === void 0 || args.chainHeadFsId === void 0 || base === args.chainHeadFsId) return void 0;
|
|
52001
52023
|
const pc = vctx.sql.tables.promptContexts;
|
|
52002
52024
|
const apps = vctx.sql.tables.apps;
|
|
52003
|
-
const r = await
|
|
52025
|
+
const r = await exception2Result38(async () => {
|
|
52004
52026
|
const rows = await vctx.sql.db.select({ fsId: pc.fsId, ref: pc.ref }).from(pc).innerJoin(apps, eq21(apps.fsId, pc.fsId)).where(eq21(pc.chatId, args.chatId)).orderBy(desc5(pc.created)).limit(DESIGN_REPAIR_SUPERSEDE_SCAN);
|
|
52005
52027
|
for (const row of rows) {
|
|
52006
52028
|
if (row.fsId === base) return base;
|
|
@@ -52034,7 +52056,7 @@ async function loadLookLintEngine(logger) {
|
|
|
52034
52056
|
__name(loadLookLintEngine, "loadLookLintEngine");
|
|
52035
52057
|
async function attemptEngineLoad() {
|
|
52036
52058
|
const loader = engineLoaderOverride ?? (() => Promise.resolve().then(() => (init_look_lint_engine(), look_lint_engine_exports)));
|
|
52037
|
-
const loaded = await
|
|
52059
|
+
const loaded = await exception2Result39(() => loader());
|
|
52038
52060
|
if (loaded.isErr()) {
|
|
52039
52061
|
const err2 = loaded.Err();
|
|
52040
52062
|
return { load: { ok: false, unavailable: `${err2.name}: ${err2.message}` }, error: err2 };
|
|
@@ -52131,7 +52153,7 @@ async function loadTurnFilesByFsId(vctx, fsId, opts) {
|
|
|
52131
52153
|
__name(loadTurnFilesByFsId, "loadTurnFilesByFsId");
|
|
52132
52154
|
|
|
52133
52155
|
// ../vibes.diy/api/svc/billing.ts
|
|
52134
|
-
import { BuildURI as BuildURI4, exception2Result as
|
|
52156
|
+
import { BuildURI as BuildURI4, exception2Result as exception2Result40, Result as Result22, URI as URI6 } from "@adviser/cement";
|
|
52135
52157
|
|
|
52136
52158
|
// ../vibes.diy/api/svc/intern/autumn-recent-usage.ts
|
|
52137
52159
|
init_lazy_type();
|
|
@@ -52382,8 +52404,8 @@ function subscribeRenewalDisclosure(kind) {
|
|
|
52382
52404
|
}
|
|
52383
52405
|
__name(subscribeRenewalDisclosure, "subscribeRenewalDisclosure");
|
|
52384
52406
|
function isAllowedSuccessUrl(raw) {
|
|
52385
|
-
const r =
|
|
52386
|
-
const uri =
|
|
52407
|
+
const r = exception2Result40(() => {
|
|
52408
|
+
const uri = URI6.from(raw);
|
|
52387
52409
|
return { protocol: uri.protocol, hostname: uri.hostname };
|
|
52388
52410
|
});
|
|
52389
52411
|
if (r.isErr()) {
|
|
@@ -52619,7 +52641,7 @@ function defaultBilling(opts) {
|
|
|
52619
52641
|
}
|
|
52620
52642
|
const baseUrl = opts.baseUrl ?? AUTUMN_API_BASE;
|
|
52621
52643
|
const doFetch = opts.fetch ?? ((input, init) => fetch(input, init));
|
|
52622
|
-
const post2 = /* @__PURE__ */ __name((path, body, opts2) =>
|
|
52644
|
+
const post2 = /* @__PURE__ */ __name((path, body, opts2) => exception2Result40(async () => {
|
|
52623
52645
|
const res = await doFetch(`${baseUrl}${path}`, {
|
|
52624
52646
|
method: "POST",
|
|
52625
52647
|
headers: {
|
|
@@ -53171,7 +53193,7 @@ async function capturePostHogServerEvent(vctx, args) {
|
|
|
53171
53193
|
const apiKey = vctx.posthogKey;
|
|
53172
53194
|
const host = vctx.posthogHost;
|
|
53173
53195
|
if (apiKey === void 0 || apiKey === "" || host === void 0 || host === "") return "skipped:no-key";
|
|
53174
|
-
const rRes = await
|
|
53196
|
+
const rRes = await exception2Result41(
|
|
53175
53197
|
() => vctx.analyticsFetch(`${host.replace(/\/+$/, "")}/capture/`, {
|
|
53176
53198
|
method: "POST",
|
|
53177
53199
|
headers: { "Content-Type": "application/json" },
|
|
@@ -53233,6 +53255,11 @@ function clientProperties(client) {
|
|
|
53233
53255
|
};
|
|
53234
53256
|
}
|
|
53235
53257
|
__name(clientProperties, "clientProperties");
|
|
53258
|
+
function clientFirstTouch(client) {
|
|
53259
|
+
const lane = clientLane(client);
|
|
53260
|
+
return lane === void 0 ? {} : { $set_once: { first_client_lane: lane } };
|
|
53261
|
+
}
|
|
53262
|
+
__name(clientFirstTouch, "clientFirstTouch");
|
|
53236
53263
|
function captureCodegenTurnSettled(vctx, args) {
|
|
53237
53264
|
const who = turnAnalyticsIdentity(args);
|
|
53238
53265
|
const promise = capturePostHogServerEvent(vctx, {
|
|
@@ -53316,6 +53343,7 @@ function captureCodegenTurnSettled(vctx, args) {
|
|
|
53316
53343
|
// present only when known: an ABSENT `client_kind` is "unknown", and a
|
|
53317
53344
|
// per-client rate must not read it as the website.
|
|
53318
53345
|
...clientProperties(vctx.client),
|
|
53346
|
+
...clientFirstTouch(vctx.client),
|
|
53319
53347
|
// See `lookLint` above: present only when a lint ran. The mapping itself
|
|
53320
53348
|
// lives in `intern/look-lint.ts`, not here, so a test that mocks this
|
|
53321
53349
|
// module still exercises the real property shape.
|
|
@@ -53739,7 +53767,8 @@ function capturePromptTurnStarted(vctx, args) {
|
|
|
53739
53767
|
follow_up: args.followUp,
|
|
53740
53768
|
by_text: args.byText,
|
|
53741
53769
|
...args.submitId === void 0 ? {} : { submit_id: args.submitId },
|
|
53742
|
-
...clientProperties(vctx.client)
|
|
53770
|
+
...clientProperties(vctx.client),
|
|
53771
|
+
...clientFirstTouch(vctx.client)
|
|
53743
53772
|
}
|
|
53744
53773
|
}).catch(() => {
|
|
53745
53774
|
});
|
|
@@ -53772,7 +53801,8 @@ function captureAppPushed(vctx, args) {
|
|
|
53772
53801
|
owner_handle: args.ownerHandle,
|
|
53773
53802
|
app_slug: args.appSlug,
|
|
53774
53803
|
mode: args.mode,
|
|
53775
|
-
...clientProperties(vctx.client)
|
|
53804
|
+
...clientProperties(vctx.client),
|
|
53805
|
+
...clientFirstTouch(vctx.client)
|
|
53776
53806
|
}
|
|
53777
53807
|
}).catch(() => {
|
|
53778
53808
|
});
|
|
@@ -53781,14 +53811,14 @@ function captureAppPushed(vctx, args) {
|
|
|
53781
53811
|
__name(captureAppPushed, "captureAppPushed");
|
|
53782
53812
|
|
|
53783
53813
|
// ../vibes.diy/api/svc/intern/stamped-geo-country.ts
|
|
53784
|
-
import { exception2Result as
|
|
53814
|
+
import { exception2Result as exception2Result42 } from "@adviser/cement";
|
|
53785
53815
|
import { inArray as inArray8 } from "drizzle-orm/sql/expressions";
|
|
53786
53816
|
async function readStampedGeoCountries(sql38, userIds) {
|
|
53787
53817
|
const out = /* @__PURE__ */ new Map();
|
|
53788
53818
|
const unique3 = [...new Set(userIds)];
|
|
53789
53819
|
if (unique3.length === 0) return out;
|
|
53790
53820
|
const t = sql38.tables.userSettings;
|
|
53791
|
-
const rRows = await
|
|
53821
|
+
const rRows = await exception2Result42(
|
|
53792
53822
|
() => sql38.db.select({ userId: t.userId, settings: t.settings }).from(t).where(inArray8(t.userId, unique3))
|
|
53793
53823
|
);
|
|
53794
53824
|
if (rRows.isErr()) return out;
|
|
@@ -53808,7 +53838,7 @@ function clientWsSend(ctx) {
|
|
|
53808
53838
|
__name(clientWsSend, "clientWsSend");
|
|
53809
53839
|
function emitResolvedForRequesters(vctx, at2, asks) {
|
|
53810
53840
|
if (asks.length === 0) return;
|
|
53811
|
-
const task =
|
|
53841
|
+
const task = exception2Result43(async () => {
|
|
53812
53842
|
const countries = await readStampedGeoCountries(
|
|
53813
53843
|
vctx.sql,
|
|
53814
53844
|
asks.map((a) => a.requesterUserId)
|
|
@@ -53839,7 +53869,7 @@ function emitResolvedForRequesters(vctx, at2, asks) {
|
|
|
53839
53869
|
}
|
|
53840
53870
|
__name(emitResolvedForRequesters, "emitResolvedForRequesters");
|
|
53841
53871
|
async function withErroredCapture(vctx, args, body) {
|
|
53842
|
-
const r = await
|
|
53872
|
+
const r = await exception2Result43(body);
|
|
53843
53873
|
if (r.isErr()) captureAccessRequestErrored(vctx, args);
|
|
53844
53874
|
return r;
|
|
53845
53875
|
}
|
|
@@ -53868,7 +53898,7 @@ async function writeApprovedGrant(vctx, args, senderConnId) {
|
|
|
53868
53898
|
eq24(vctx.sql.tables.requestGrants.ownerHandle, args.ownerHandle),
|
|
53869
53899
|
eq24(vctx.sql.tables.requestGrants.foreignUserId, args.foreignUserId)
|
|
53870
53900
|
);
|
|
53871
|
-
const rPending = await
|
|
53901
|
+
const rPending = await exception2Result43(
|
|
53872
53902
|
() => vctx.sql.db.update(vctx.sql.tables.requestGrants).set({ state: "approved", role: args.role, updated: args.now }).where(and20(rowKey2, eq24(vctx.sql.tables.requestGrants.state, "pending"))).returning({ created: vctx.sql.tables.requestGrants.created })
|
|
53873
53903
|
);
|
|
53874
53904
|
if (rPending.isErr()) return Result23.Err(rPending);
|
|
@@ -53878,13 +53908,13 @@ async function writeApprovedGrant(vctx, args, senderConnId) {
|
|
|
53878
53908
|
{ requesterUserId: args.foreignUserId, outcome: "approved", requestedAt: answered.created, role: args.role }
|
|
53879
53909
|
]);
|
|
53880
53910
|
} else if (args.mode === "update-only") {
|
|
53881
|
-
const rUpd = await
|
|
53911
|
+
const rUpd = await exception2Result43(
|
|
53882
53912
|
() => vctx.sql.db.update(vctx.sql.tables.requestGrants).set({ state: "approved", role: args.role, updated: args.now }).where(rowKey2).returning({ foreignUserId: vctx.sql.tables.requestGrants.foreignUserId })
|
|
53883
53913
|
);
|
|
53884
53914
|
if (rUpd.isErr()) return Result23.Err(rUpd);
|
|
53885
53915
|
if (rUpd.Ok().length === 0) return Result23.Ok({ written: false });
|
|
53886
53916
|
} else {
|
|
53887
|
-
const rIns = await
|
|
53917
|
+
const rIns = await exception2Result43(
|
|
53888
53918
|
() => vctx.sql.db.insert(vctx.sql.tables.requestGrants).values({
|
|
53889
53919
|
userId: args.ownerUserId,
|
|
53890
53920
|
appSlug: args.appSlug,
|
|
@@ -53934,7 +53964,7 @@ async function writeApprovedGrant(vctx, args, senderConnId) {
|
|
|
53934
53964
|
__name(writeApprovedGrant, "writeApprovedGrant");
|
|
53935
53965
|
async function hasProductionRelease2(vctx, at2) {
|
|
53936
53966
|
const a = vctx.sql.tables.apps;
|
|
53937
|
-
const rows = await
|
|
53967
|
+
const rows = await exception2Result43(
|
|
53938
53968
|
() => vctx.sql.db.select({ appSlug: a.appSlug }).from(a).where(and20(eq24(a.userId, at2.userId), eq24(a.ownerHandle, at2.ownerHandle), eq24(a.appSlug, at2.appSlug), eq24(a.mode, "production"))).limit(1)
|
|
53939
53969
|
);
|
|
53940
53970
|
if (rows.isErr()) return Result23.Err(rows.Err());
|
|
@@ -53945,7 +53975,7 @@ async function approveAllPendingRequests(vctx, ref, opts) {
|
|
|
53945
53975
|
const { role, origin } = opts;
|
|
53946
53976
|
if (isGuestPrincipal(ref.userId)) return Result23.Ok(0);
|
|
53947
53977
|
const now3 = (/* @__PURE__ */ new Date()).toISOString();
|
|
53948
|
-
const rUpd = await
|
|
53978
|
+
const rUpd = await exception2Result43(
|
|
53949
53979
|
() => vctx.sql.db.update(vctx.sql.tables.requestGrants).set({ state: "approved", role, updated: now3 }).where(
|
|
53950
53980
|
and20(
|
|
53951
53981
|
eq24(vctx.sql.tables.requestGrants.userId, ref.userId),
|
|
@@ -53994,7 +54024,7 @@ async function approveAllPendingRequests(vctx, ref, opts) {
|
|
|
53994
54024
|
__name(approveAllPendingRequests, "approveAllPendingRequests");
|
|
53995
54025
|
async function hasAccessRequest(vctx, req2) {
|
|
53996
54026
|
const ownerRows = await vctx.sql.db.select({ userId: vctx.sql.tables.handleBinding.userId }).from(vctx.sql.tables.handleBinding).where(eq24(vctx.sql.tables.handleBinding.handle, req2.ownerHandle)).limit(1);
|
|
53997
|
-
const rRows = await
|
|
54027
|
+
const rRows = await exception2Result43(
|
|
53998
54028
|
() => vctx.sql.db.select({
|
|
53999
54029
|
state: vctx.sql.tables.requestGrants.state,
|
|
54000
54030
|
role: vctx.sql.tables.requestGrants.role,
|
|
@@ -54059,7 +54089,7 @@ async function requestAccess({
|
|
|
54059
54089
|
retried = false
|
|
54060
54090
|
}) {
|
|
54061
54091
|
const now3 = (/* @__PURE__ */ new Date()).toISOString();
|
|
54062
|
-
const rSettings = await
|
|
54092
|
+
const rSettings = await exception2Result43(
|
|
54063
54093
|
() => vctx.sql.db.select({ userId: vctx.sql.tables.handleBinding.userId }).from(vctx.sql.tables.handleBinding).where(eq24(vctx.sql.tables.handleBinding.handle, req2.ownerHandle)).limit(1).then((r2) => r2[0])
|
|
54064
54094
|
);
|
|
54065
54095
|
if (rSettings.isErr()) return Result23.Err(rSettings);
|
|
@@ -54107,7 +54137,7 @@ async function requestAccess({
|
|
|
54107
54137
|
const state3 = autoAcceptRole ? "approved" : "pending";
|
|
54108
54138
|
const role = autoAcceptRole ?? void 0;
|
|
54109
54139
|
const foreignInfo = { claims: req2.claims };
|
|
54110
|
-
const rIns = await
|
|
54140
|
+
const rIns = await exception2Result43(
|
|
54111
54141
|
() => vctx.sql.db.insert(vctx.sql.tables.requestGrants).values({
|
|
54112
54142
|
userId: record.userId,
|
|
54113
54143
|
appSlug: req2.appSlug,
|
|
@@ -54132,13 +54162,13 @@ async function requestAccess({
|
|
|
54132
54162
|
if (rIns.isErr()) return Result23.Err(rIns);
|
|
54133
54163
|
const stored = rIns.Ok()[0];
|
|
54134
54164
|
if (ownerIsGuest && retried === false) {
|
|
54135
|
-
const rNow = await
|
|
54165
|
+
const rNow = await exception2Result43(
|
|
54136
54166
|
() => vctx.sql.db.select({ userId: vctx.sql.tables.handleBinding.userId }).from(vctx.sql.tables.handleBinding).where(eq24(vctx.sql.tables.handleBinding.handle, req2.ownerHandle)).limit(1).then((r2) => r2[0])
|
|
54137
54167
|
);
|
|
54138
54168
|
if (rNow.isErr()) return Result23.Err(rNow);
|
|
54139
54169
|
if (rNow.Ok()?.userId !== record.userId) {
|
|
54140
54170
|
const rg = vctx.sql.tables.requestGrants;
|
|
54141
|
-
const rDel = await
|
|
54171
|
+
const rDel = await exception2Result43(
|
|
54142
54172
|
() => vctx.sql.db.delete(rg).where(
|
|
54143
54173
|
and20(
|
|
54144
54174
|
eq24(rg.userId, record.userId),
|
|
@@ -54452,7 +54482,7 @@ var requestSetRoleEvento = {
|
|
|
54452
54482
|
});
|
|
54453
54483
|
return Result23.Ok(EventoResult3.Continue);
|
|
54454
54484
|
}
|
|
54455
|
-
const rUpd = await
|
|
54485
|
+
const rUpd = await exception2Result43(
|
|
54456
54486
|
() => vctx.sql.db.update(vctx.sql.tables.requestGrants).set({ role: req2.role, updated: now3 }).where(where)
|
|
54457
54487
|
);
|
|
54458
54488
|
if (rUpd.isErr()) return Result23.Err(rUpd);
|
|
@@ -54535,7 +54565,7 @@ var revokeRequestEvento = {
|
|
|
54535
54565
|
}
|
|
54536
54566
|
const blockForeignInfo = {};
|
|
54537
54567
|
const rg = vctx.sql.tables.requestGrants;
|
|
54538
|
-
const rAnswered = await
|
|
54568
|
+
const rAnswered = await exception2Result43(async () => {
|
|
54539
54569
|
if (prev?.state !== "pending") return void 0;
|
|
54540
54570
|
const stillPending = and20(where, eq24(rg.state, "pending"));
|
|
54541
54571
|
const consumed = req2.delete ? await vctx.sql.db.delete(rg).where(stillPending).returning({ created: rg.created }) : await vctx.sql.db.update(rg).set({ state: "revoked", updated: now3 }).where(stillPending).returning({ created: rg.created });
|
|
@@ -54544,7 +54574,7 @@ var revokeRequestEvento = {
|
|
|
54544
54574
|
if (rAnswered.isErr()) return Result23.Err(rAnswered);
|
|
54545
54575
|
const answered = rAnswered.Ok();
|
|
54546
54576
|
if (answered === void 0) {
|
|
54547
|
-
const rOp = await
|
|
54577
|
+
const rOp = await exception2Result43(
|
|
54548
54578
|
() => req2.delete ? vctx.sql.db.delete(rg).where(where) : prev ? vctx.sql.db.update(rg).set({ state: "revoked", updated: now3 }).where(where) : vctx.sql.db.insert(rg).values({
|
|
54549
54579
|
userId,
|
|
54550
54580
|
appSlug: req2.appSlug,
|
|
@@ -54893,7 +54923,7 @@ init_types();
|
|
|
54893
54923
|
|
|
54894
54924
|
// ../vibes.diy/api/svc/public/anon-write-legacy-sweep.ts
|
|
54895
54925
|
import { and as and22, eq as eq27 } from "drizzle-orm/sql/expressions";
|
|
54896
|
-
import { exception2Result as
|
|
54926
|
+
import { exception2Result as exception2Result44 } from "@adviser/cement";
|
|
54897
54927
|
var ANON_WRITE_LEGACY_CUTOFF_ISO = "2026-09-30T00:00:00.000Z";
|
|
54898
54928
|
var MEMO_TTL_MS = 5 * 60 * 1e3;
|
|
54899
54929
|
var checked = /* @__PURE__ */ new WeakMap();
|
|
@@ -54914,7 +54944,7 @@ __name(appBindsAnyAccessFn, "appBindsAnyAccessFn");
|
|
|
54914
54944
|
async function effectiveAnonWriteFor(vctx, args) {
|
|
54915
54945
|
const verdict = legacyAnonWriteSnapshotVerdict(args.entry, args.settingsCreated);
|
|
54916
54946
|
if (verdict !== "needs-binding-probe") return verdict.settled ?? "off";
|
|
54917
|
-
const r = await
|
|
54947
|
+
const r = await exception2Result44(() => appBindsAnyAccessFn(vctx, args.ownerHandle, args.appSlug));
|
|
54918
54948
|
if (r.isErr()) return "off";
|
|
54919
54949
|
return r.Ok() ? "legacy" : "off";
|
|
54920
54950
|
}
|
|
@@ -54933,7 +54963,7 @@ async function ensureLegacyAnonWriteStamped(args) {
|
|
|
54933
54963
|
const last = perDb.get(key);
|
|
54934
54964
|
const now3 = Date.now();
|
|
54935
54965
|
if (last !== void 0 && now3 - last < MEMO_TTL_MS) return void 0;
|
|
54936
|
-
const r = await
|
|
54966
|
+
const r = await exception2Result44(() => stamp(vctx, ownerHandle, appSlug));
|
|
54937
54967
|
if (r.isErr()) {
|
|
54938
54968
|
console.warn(`anonWrite legacy stamp failed for ${ownerHandle}/${appSlug}:`, r.Err());
|
|
54939
54969
|
return void 0;
|
|
@@ -54957,10 +54987,10 @@ __name(stamp, "stamp");
|
|
|
54957
54987
|
|
|
54958
54988
|
// ../vibes.diy/api/svc/public/platform-comments-migration.ts
|
|
54959
54989
|
import { and as and39, desc as desc9, eq as eq45, sql as sql9 } from "drizzle-orm";
|
|
54960
|
-
import { exception2Result as
|
|
54990
|
+
import { exception2Result as exception2Result56 } from "@adviser/cement";
|
|
54961
54991
|
|
|
54962
54992
|
// ../vibes.diy/api/svc/public/access-fn-channel-index.ts
|
|
54963
|
-
import { exception2Result as
|
|
54993
|
+
import { exception2Result as exception2Result45, Result as Result24 } from "@adviser/cement";
|
|
54964
54994
|
import { and as and25, eq as eq30 } from "drizzle-orm";
|
|
54965
54995
|
|
|
54966
54996
|
// ../vibes.diy/api/svc/public/sync-feed.ts
|
|
@@ -55392,7 +55422,7 @@ __name(tableOf, "tableOf");
|
|
|
55392
55422
|
async function syncChannelIndex(exec, tables, key, newChannels) {
|
|
55393
55423
|
const tIdx = tableOf(tables);
|
|
55394
55424
|
if (!tIdx) return Result24.Ok(void 0);
|
|
55395
|
-
return
|
|
55425
|
+
return exception2Result45(async () => {
|
|
55396
55426
|
await exec.delete(tIdx).where(
|
|
55397
55427
|
and25(
|
|
55398
55428
|
eq30(tIdx.ownerHandle, key.ownerHandle),
|
|
@@ -55441,14 +55471,14 @@ __name(sameChannelSet, "sameChannelSet");
|
|
|
55441
55471
|
async function clearChannelIndexCompletenessMarker(db, tables, key) {
|
|
55442
55472
|
const tState = stateTableOf(tables);
|
|
55443
55473
|
if (!tState) return Result24.Ok(void 0);
|
|
55444
|
-
return
|
|
55474
|
+
return exception2Result45(async () => {
|
|
55445
55475
|
await db.delete(tState).where(and25(eq30(tState.ownerHandle, key.ownerHandle), eq30(tState.appSlug, key.appSlug), eq30(tState.dbName, key.dbName)));
|
|
55446
55476
|
});
|
|
55447
55477
|
}
|
|
55448
55478
|
__name(clearChannelIndexCompletenessMarker, "clearChannelIndexCompletenessMarker");
|
|
55449
55479
|
async function ensureChannelIndexBackfill(db, flavour, tables, key) {
|
|
55450
55480
|
const { ownerHandle, appSlug, dbName } = key;
|
|
55451
|
-
return
|
|
55481
|
+
return exception2Result45(async () => {
|
|
55452
55482
|
const tIdx = tableOf(tables);
|
|
55453
55483
|
const tState = stateTableOf(tables);
|
|
55454
55484
|
if (!tIdx || !tState) return "already";
|
|
@@ -55511,12 +55541,12 @@ async function ensureChannelIndexBackfill(db, flavour, tables, key) {
|
|
|
55511
55541
|
__name(ensureChannelIndexBackfill, "ensureChannelIndexBackfill");
|
|
55512
55542
|
|
|
55513
55543
|
// ../vibes.diy/api/svc/public/ensure-app-settings.ts
|
|
55514
|
-
import { Result as Result30, Option as Option10, EventoResult as EventoResult5, exception2Result as
|
|
55544
|
+
import { Result as Result30, Option as Option10, EventoResult as EventoResult5, exception2Result as exception2Result51 } from "@adviser/cement";
|
|
55515
55545
|
init_identity();
|
|
55516
55546
|
import { eq as eq36, and as and30 } from "drizzle-orm/sql/expressions";
|
|
55517
55547
|
|
|
55518
55548
|
// ../vibes.diy/api/svc/intern/get-model-defaults.ts
|
|
55519
|
-
import { Result as Result26, exception2Result as
|
|
55549
|
+
import { Result as Result26, exception2Result as exception2Result47 } from "@adviser/cement";
|
|
55520
55550
|
init_identity();
|
|
55521
55551
|
import { eq as eq31 } from "drizzle-orm/sql/expressions";
|
|
55522
55552
|
|
|
@@ -55528,7 +55558,7 @@ import {
|
|
|
55528
55558
|
ResolveOnce as ResolveOnce2,
|
|
55529
55559
|
stream2string,
|
|
55530
55560
|
BuildURI as BuildURI5,
|
|
55531
|
-
exception2Result as
|
|
55561
|
+
exception2Result as exception2Result46
|
|
55532
55562
|
} from "@adviser/cement";
|
|
55533
55563
|
init_identity();
|
|
55534
55564
|
|
|
@@ -55844,7 +55874,7 @@ function loadModels(vctx) {
|
|
|
55844
55874
|
logger.Warn().Any({ url: vibePkgModelsUrl, fetchMs, error: rAsset.Err() }).Msg("fetchAsset failed");
|
|
55845
55875
|
return Result25.Err(rAsset);
|
|
55846
55876
|
}
|
|
55847
|
-
const rRaw = await
|
|
55877
|
+
const rRaw = await exception2Result46(async () => JSON.parse(await stream2string(rAsset.Ok())));
|
|
55848
55878
|
if (rRaw.isErr()) {
|
|
55849
55879
|
logger.Warn().Any({ url: vibePkgModelsUrl, fetchMs, error: rRaw.Err() }).Msg("models.json parse failed");
|
|
55850
55880
|
return Result25.Err(rRaw);
|
|
@@ -55910,13 +55940,13 @@ async function loadPreSelectedDefaults(ctx) {
|
|
|
55910
55940
|
}
|
|
55911
55941
|
__name(loadPreSelectedDefaults, "loadPreSelectedDefaults");
|
|
55912
55942
|
async function readAccountTierRow(ctx, ownerHandle) {
|
|
55913
|
-
const rBinding = await
|
|
55943
|
+
const rBinding = await exception2Result47(
|
|
55914
55944
|
() => ctx.sql.db.select().from(ctx.sql.tables.handleBinding).where(eq31(ctx.sql.tables.handleBinding.handle, ownerHandle)).limit(1).then((r) => r[0])
|
|
55915
55945
|
);
|
|
55916
55946
|
if (rBinding.isErr()) return Result26.Err(rBinding);
|
|
55917
55947
|
const binding = rBinding.Ok();
|
|
55918
55948
|
if (!binding) return Result26.Ok(void 0);
|
|
55919
|
-
const rUser = await
|
|
55949
|
+
const rUser = await exception2Result47(
|
|
55920
55950
|
() => ctx.sql.db.select().from(ctx.sql.tables.userSettings).where(eq31(ctx.sql.tables.userSettings.userId, binding.userId)).limit(1).then((r) => r[0])
|
|
55921
55951
|
);
|
|
55922
55952
|
if (rUser.isErr()) return Result26.Err(rUser);
|
|
@@ -55927,7 +55957,7 @@ async function getModelDefaults(ctx, { appSlug, ownerHandle }) {
|
|
|
55927
55957
|
const [rDefaults, rAccount, rApp] = await Promise.all([
|
|
55928
55958
|
loadPreSelectedDefaults(ctx),
|
|
55929
55959
|
ownerHandle ? readAccountTierRow(ctx, ownerHandle) : Promise.resolve(Result26.Ok(void 0)),
|
|
55930
|
-
appSlug && ownerHandle ?
|
|
55960
|
+
appSlug && ownerHandle ? exception2Result47(() => readComposedSettingsForApp(ctx, ownerHandle, appSlug)) : Promise.resolve(void 0)
|
|
55931
55961
|
]);
|
|
55932
55962
|
if (rDefaults.isErr()) return Result26.Err(rDefaults);
|
|
55933
55963
|
const result = {
|
|
@@ -55990,7 +56020,7 @@ async function accountHoldsPro(vctx, userId) {
|
|
|
55990
56020
|
__name(accountHoldsPro, "accountHoldsPro");
|
|
55991
56021
|
|
|
55992
56022
|
// ../vibes.diy/api/svc/intern/swr-purge.ts
|
|
55993
|
-
import { URI as
|
|
56023
|
+
import { URI as URI8 } from "@adviser/cement";
|
|
55994
56024
|
|
|
55995
56025
|
// ../vibes.diy/api/svc/intern/swr-html-cache-orchestrator.ts
|
|
55996
56026
|
init_swr_html_cache();
|
|
@@ -56054,7 +56084,7 @@ init_swr_html_cache();
|
|
|
56054
56084
|
|
|
56055
56085
|
// ../vibes.diy/api/svc/intern/get-vibe-route-hints.ts
|
|
56056
56086
|
init_identity();
|
|
56057
|
-
import { exception2Result as
|
|
56087
|
+
import { exception2Result as exception2Result48, Result as Result28 } from "@adviser/cement";
|
|
56058
56088
|
import { and as and26, desc as desc8, eq as eq32 } from "drizzle-orm/sql/expressions";
|
|
56059
56089
|
function deriveIsWorldReadable(rawSettings, _ownerUserId) {
|
|
56060
56090
|
if (!Array.isArray(rawSettings)) return false;
|
|
@@ -56103,7 +56133,7 @@ function purgeRootHtmlCacheSameColo(vctx, ownerHandle, appSlug) {
|
|
|
56103
56133
|
const env = vctx.params.vibes.env;
|
|
56104
56134
|
const origins = /* @__PURE__ */ new Set();
|
|
56105
56135
|
for (const base of [env.VIBES_PUBLIC_URL, env.VIBES_DIY_PUBLIC_BASE_URL]) {
|
|
56106
|
-
const rUri = base === void 0 || base === "" ? void 0 :
|
|
56136
|
+
const rUri = base === void 0 || base === "" ? void 0 : URI8.fromResult(base);
|
|
56107
56137
|
if (rUri !== void 0 && rUri.isOk() && /^https?:$/.test(rUri.Ok().protocol)) {
|
|
56108
56138
|
origins.add(`${rUri.Ok().protocol}//${rUri.Ok().host}`);
|
|
56109
56139
|
}
|
|
@@ -56287,7 +56317,7 @@ __name(applySecretOp, "applySecretOp");
|
|
|
56287
56317
|
|
|
56288
56318
|
// ../vibes.diy/api/svc/public/app-settings-icon-gen.ts
|
|
56289
56319
|
init_identity();
|
|
56290
|
-
import { exception2Result as
|
|
56320
|
+
import { exception2Result as exception2Result49 } from "@adviser/cement";
|
|
56291
56321
|
|
|
56292
56322
|
// ../vibes.diy/api/svc/intern/runtime-model.ts
|
|
56293
56323
|
import { Result as Result29 } from "@adviser/cement";
|
|
@@ -56336,7 +56366,7 @@ async function startIconLane(vctx, args) {
|
|
|
56336
56366
|
const key = { userId: args.userId, ownerHandle: args.ownerHandle, appSlug: args.appSlug };
|
|
56337
56367
|
const log = ensureLogger(vctx.sthis, "startIconLane");
|
|
56338
56368
|
if (args.force !== true) {
|
|
56339
|
-
const rEntries = await
|
|
56369
|
+
const rEntries = await exception2Result49(() => readComposedSettings(vctx, key));
|
|
56340
56370
|
if (rEntries.isErr()) {
|
|
56341
56371
|
log.Warn().Err(rEntries).Str("ownerHandle", args.ownerHandle).Str("appSlug", args.appSlug).Msg("icon-lane-read-failed");
|
|
56342
56372
|
return "has-icon";
|
|
@@ -56348,7 +56378,7 @@ async function startIconLane(vctx, args) {
|
|
|
56348
56378
|
const phrase = args.phrase?.trim();
|
|
56349
56379
|
if (phrase !== void 0 && phrase.length > 0) {
|
|
56350
56380
|
const entry2 = { type: "active.icon-description", description: phrase };
|
|
56351
|
-
const rWrite = await
|
|
56381
|
+
const rWrite = await exception2Result49(() => writeAppSettingItems(vctx, key, { upserts: [entry2] }));
|
|
56352
56382
|
if (rWrite.isErr()) {
|
|
56353
56383
|
log.Warn().Err(rWrite).Str("ownerHandle", args.ownerHandle).Str("appSlug", args.appSlug).Msg("icon-lane-write-failed");
|
|
56354
56384
|
return "has-icon";
|
|
@@ -56439,13 +56469,13 @@ __name(buildEnvelopeReadout, "buildEnvelopeReadout");
|
|
|
56439
56469
|
|
|
56440
56470
|
// ../vibes.diy/api/svc/intern/app-clip-deactivate.ts
|
|
56441
56471
|
init_identity();
|
|
56442
|
-
import { exception2Result as
|
|
56472
|
+
import { exception2Result as exception2Result50 } from "@adviser/cement";
|
|
56443
56473
|
import { and as and28, eq as eq34 } from "drizzle-orm/sql/expressions";
|
|
56444
56474
|
async function enqueueAppClipDeactivate(vctx, target2) {
|
|
56445
56475
|
const { ownerHandle, appSlug } = target2;
|
|
56446
56476
|
const logger = ensureLogger(vctx.sthis, "enqueueAppClipDeactivate");
|
|
56447
56477
|
const t = vctx.sql.tables.appClipExperiences;
|
|
56448
|
-
const rRow = await
|
|
56478
|
+
const rRow = await exception2Result50(
|
|
56449
56479
|
() => vctx.sql.db.select({ status: t.status }).from(t).where(and28(eq34(t.ownerHandle, ownerHandle), eq34(t.appSlug, appSlug))).limit(1).then((r) => r[0])
|
|
56450
56480
|
);
|
|
56451
56481
|
if (rRow.isErr()) {
|
|
@@ -56454,7 +56484,7 @@ async function enqueueAppClipDeactivate(vctx, target2) {
|
|
|
56454
56484
|
}
|
|
56455
56485
|
const row = rRow.Ok();
|
|
56456
56486
|
if (row === void 0 || row.status === "deactivated") return false;
|
|
56457
|
-
const rPost = await
|
|
56487
|
+
const rPost = await exception2Result50(
|
|
56458
56488
|
() => vctx.postQueue({
|
|
56459
56489
|
payload: {
|
|
56460
56490
|
type: "vibes.diy.evt-app-clip-experience",
|
|
@@ -56601,7 +56631,7 @@ async function withdrawAppClipCardIfReadRemoved({
|
|
|
56601
56631
|
}
|
|
56602
56632
|
__name(withdrawAppClipCardIfReadRemoved, "withdrawAppClipCardIfReadRemoved");
|
|
56603
56633
|
async function withdrawSharedViewScreenshots(vctx, target2) {
|
|
56604
|
-
const rStrip = await
|
|
56634
|
+
const rStrip = await exception2Result51(
|
|
56605
56635
|
() => stripSharedViewScreenshots(vctx, { ownerHandle: target2.ownerHandle, appSlug: target2.appSlug })
|
|
56606
56636
|
);
|
|
56607
56637
|
if (rStrip.isErr()) {
|
|
@@ -56618,7 +56648,7 @@ async function applyPrivacySensitiveWrite(vctx, args) {
|
|
|
56618
56648
|
if (isLower) {
|
|
56619
56649
|
const coverage = args.skipCoverage === true ? { ok: true } : privacySensitiveLowerCoverage({ flag: current });
|
|
56620
56650
|
if (coverage.ok === false) return [res.settings, coverage.error];
|
|
56621
|
-
const rStamp = await
|
|
56651
|
+
const rStamp = await exception2Result51(
|
|
56622
56652
|
() => stampEveryKnownWriter(vctx, { ownerHandle: res.ownerHandle, appSlug: res.appSlug })
|
|
56623
56653
|
);
|
|
56624
56654
|
if (rStamp.isErr()) {
|
|
@@ -56638,7 +56668,7 @@ async function applyPrivacySensitiveWrite(vctx, args) {
|
|
|
56638
56668
|
}
|
|
56639
56669
|
});
|
|
56640
56670
|
if (isLower && error === void 0) {
|
|
56641
|
-
const rRestamp = await
|
|
56671
|
+
const rRestamp = await exception2Result51(async () => {
|
|
56642
56672
|
await runLowerAfterFlipHookForTests();
|
|
56643
56673
|
return stampEveryKnownWriter(vctx, { ownerHandle: res.ownerHandle, appSlug: res.appSlug });
|
|
56644
56674
|
});
|
|
@@ -56657,7 +56687,7 @@ async function applyPrivacySensitiveWrite(vctx, args) {
|
|
|
56657
56687
|
removeMatch: /* @__PURE__ */ __name((e) => args.withNature !== void 0 && previousNature === void 0 && isActiveAppNature(e), "removeMatch")
|
|
56658
56688
|
}
|
|
56659
56689
|
});
|
|
56660
|
-
const rTeardown = await
|
|
56690
|
+
const rTeardown = await exception2Result51(
|
|
56661
56691
|
() => revokeAppAudienceKeysForUnsetSubjects(vctx, { ownerHandle: res.ownerHandle, appSlug: res.appSlug })
|
|
56662
56692
|
);
|
|
56663
56693
|
if (rTeardown.isErr()) console.error("restore teardown failed (degrade-to-resubscribe):", rTeardown.Err());
|
|
@@ -56665,7 +56695,7 @@ async function applyPrivacySensitiveWrite(vctx, args) {
|
|
|
56665
56695
|
}
|
|
56666
56696
|
}
|
|
56667
56697
|
if (error === void 0 && genuineRaise) {
|
|
56668
|
-
const rRaise = await
|
|
56698
|
+
const rRaise = await exception2Result51(
|
|
56669
56699
|
() => revokeAppAudienceKeysForUnsetSubjects(vctx, { ownerHandle: res.ownerHandle, appSlug: res.appSlug })
|
|
56670
56700
|
);
|
|
56671
56701
|
if (rRaise.isErr()) console.error("audience sensitive-raise teardown failed (degrade-to-resubscribe):", rRaise.Err());
|
|
@@ -57992,12 +58022,12 @@ __name(newSeededReduce, "newSeededReduce");
|
|
|
57992
58022
|
|
|
57993
58023
|
// ../vibes.diy/api/svc/public/invite-subject-aliases.ts
|
|
57994
58024
|
import { and as and31, eq as eq37 } from "drizzle-orm/sql/expressions";
|
|
57995
|
-
import { exception2Result as
|
|
58025
|
+
import { exception2Result as exception2Result52 } from "@adviser/cement";
|
|
57996
58026
|
async function applyInviteSubjectAliases(vctx, reduce, p) {
|
|
57997
58027
|
if (p.handle === null || p.handle === void 0 || p.handle.length === 0) return;
|
|
57998
58028
|
if (p.userId === null || p.userId === void 0 || p.userId.length === 0) return;
|
|
57999
58029
|
const who = { ownerHandle: p.ownerHandle, appSlug: p.appSlug, handle: p.handle, userId: p.userId };
|
|
58000
|
-
const moved = await
|
|
58030
|
+
const moved = await exception2Result52(() => movedHandleAliases(vctx, who));
|
|
58001
58031
|
if (moved.isErr()) console.error("[app-move] alias resolve failed (fail-closed, moved-from grants not folded):", moved.Err());
|
|
58002
58032
|
const movedAliases = moved.isOk() ? moved.Ok() : /* @__PURE__ */ new Map();
|
|
58003
58033
|
if (reduce.namesSubjectPrefix(INVITE_SUBJECT_PREFIX2) === false) {
|
|
@@ -58587,7 +58617,7 @@ __name(resolveInheritReadChannels, "resolveInheritReadChannels");
|
|
|
58587
58617
|
|
|
58588
58618
|
// ../vibes.diy/api/svc/public/public-audience-resolver.ts
|
|
58589
58619
|
import { and as and36, eq as eq42, inArray as inArray15, or as or4 } from "drizzle-orm/sql/expressions";
|
|
58590
|
-
import { exception2Result as
|
|
58620
|
+
import { exception2Result as exception2Result53 } from "@adviser/cement";
|
|
58591
58621
|
async function resolvePublicAudienceChannels(vctx, input) {
|
|
58592
58622
|
const levels = await effectiveAudienceVisibilities(vctx, input);
|
|
58593
58623
|
const publicSubjects = input.subjects.filter((subject) => levels.get(subject) === "public");
|
|
@@ -58612,7 +58642,7 @@ async function resolvePublicAudienceChannels(vctx, input) {
|
|
|
58612
58642
|
}
|
|
58613
58643
|
__name(resolvePublicAudienceChannels, "resolvePublicAudienceChannels");
|
|
58614
58644
|
async function resolvePublicAudienceChannelsFailClosed(vctx, input) {
|
|
58615
|
-
const result = await
|
|
58645
|
+
const result = await exception2Result53(() => resolvePublicAudienceChannels(vctx, input));
|
|
58616
58646
|
if (result.isErr()) {
|
|
58617
58647
|
console.error("public audience resolution failed (fail closed):", result.Err());
|
|
58618
58648
|
return /* @__PURE__ */ new Set();
|
|
@@ -58622,11 +58652,11 @@ async function resolvePublicAudienceChannelsFailClosed(vctx, input) {
|
|
|
58622
58652
|
__name(resolvePublicAudienceChannelsFailClosed, "resolvePublicAudienceChannelsFailClosed");
|
|
58623
58653
|
|
|
58624
58654
|
// ../vibes.diy/api/svc/public/sync-subject-digest.ts
|
|
58625
|
-
import { exception2Result as
|
|
58655
|
+
import { exception2Result as exception2Result55 } from "@adviser/cement";
|
|
58626
58656
|
import { and as and38, eq as eq44, gte, lt as lt4 } from "drizzle-orm";
|
|
58627
58657
|
|
|
58628
58658
|
// ../vibes.diy/api/svc/public/sync-bounded-read.ts
|
|
58629
|
-
import { exception2Result as
|
|
58659
|
+
import { exception2Result as exception2Result54, Result as Result31 } from "@adviser/cement";
|
|
58630
58660
|
import { and as and37, eq as eq43, inArray as inArray16, sql as sql8 } from "drizzle-orm";
|
|
58631
58661
|
var CHANNEL_IN_CHUNK = 200;
|
|
58632
58662
|
function syncBoundedColdReadEnabled(vctx) {
|
|
@@ -58649,7 +58679,7 @@ function syncBoundedMinPartitionDocs(vctx) {
|
|
|
58649
58679
|
__name(syncBoundedMinPartitionDocs, "syncBoundedMinPartitionDocs");
|
|
58650
58680
|
async function partitionOutputRowCount(vctx, part) {
|
|
58651
58681
|
const t = vctx.sql.tables.accessFnOutputs;
|
|
58652
|
-
return
|
|
58682
|
+
return exception2Result54(async () => {
|
|
58653
58683
|
const row = await vctx.sql.db.select({ n: sql8`cast(count(*) as int)` }).from(t).where(and37(eq43(t.ownerHandle, part.ownerHandle), eq43(t.appSlug, part.appSlug), eq43(t.dbName, part.dbName))).then((r) => r[0]);
|
|
58654
58684
|
return Number(row?.n ?? 0);
|
|
58655
58685
|
});
|
|
@@ -58658,7 +58688,7 @@ __name(partitionOutputRowCount, "partitionOutputRowCount");
|
|
|
58658
58688
|
async function channelIndexIsComplete(vctx, part) {
|
|
58659
58689
|
const tState = vctx.sql.tables.accessFnChannelIndexState;
|
|
58660
58690
|
if (!tState) return Result31.Ok(false);
|
|
58661
|
-
return
|
|
58691
|
+
return exception2Result54(async () => {
|
|
58662
58692
|
const row = await vctx.sql.db.select({ backfilledAt: tState.backfilledAt }).from(tState).where(and37(eq43(tState.ownerHandle, part.ownerHandle), eq43(tState.appSlug, part.appSlug), eq43(tState.dbName, part.dbName))).limit(1).then((r) => r[0]);
|
|
58663
58693
|
return row !== void 0;
|
|
58664
58694
|
});
|
|
@@ -58668,7 +58698,7 @@ async function selectIndexedDocIds(vctx, part, channels) {
|
|
|
58668
58698
|
const tIdx = vctx.sql.tables.accessFnChannelIndex;
|
|
58669
58699
|
if (!tIdx) return Result31.Err(new Error("channel index table not present in this flavour's table map"));
|
|
58670
58700
|
if (channels.length === 0) return Result31.Ok([]);
|
|
58671
|
-
return
|
|
58701
|
+
return exception2Result54(async () => {
|
|
58672
58702
|
const docIds = /* @__PURE__ */ new Set();
|
|
58673
58703
|
for (let i = 0; i < channels.length; i += CHANNEL_IN_CHUNK) {
|
|
58674
58704
|
const chunk = channels.slice(i, i + CHANNEL_IN_CHUNK);
|
|
@@ -58689,7 +58719,7 @@ __name(selectIndexedDocIds, "selectIndexedDocIds");
|
|
|
58689
58719
|
async function selectPartitionIndexedDocIds(vctx, part) {
|
|
58690
58720
|
const tIdx = vctx.sql.tables.accessFnChannelIndex;
|
|
58691
58721
|
if (!tIdx) return Result31.Err(new Error("channel index table not present in this flavour's table map"));
|
|
58692
|
-
return
|
|
58722
|
+
return exception2Result54(async () => {
|
|
58693
58723
|
const rows = await vctx.sql.db.selectDistinct({ docId: tIdx.docId }).from(tIdx).where(and37(eq43(tIdx.ownerHandle, part.ownerHandle), eq43(tIdx.appSlug, part.appSlug), eq43(tIdx.dbName, part.dbName)));
|
|
58694
58724
|
return new Set(rows.map((r) => r.docId));
|
|
58695
58725
|
});
|
|
@@ -58715,7 +58745,7 @@ function kickChannelIndexBackfill(vctx, part) {
|
|
|
58715
58745
|
backfilling.set(key, task);
|
|
58716
58746
|
const waitUntil = vctx.waitUntil;
|
|
58717
58747
|
if (waitUntil !== void 0) {
|
|
58718
|
-
const registered =
|
|
58748
|
+
const registered = exception2Result54(() => waitUntil(task));
|
|
58719
58749
|
if (registered.isErr()) console.warn("sync pull: channel index backfill waitUntil registration failed:", registered.Err());
|
|
58720
58750
|
} else {
|
|
58721
58751
|
void task;
|
|
@@ -58748,7 +58778,7 @@ async function subjectDigestFromIndex(vctx, part) {
|
|
|
58748
58778
|
const tIdx = vctx.sql.tables.accessFnChannelIndex;
|
|
58749
58779
|
if (!tIdx) return void 0;
|
|
58750
58780
|
const partWhere = and38(eq44(tIdx.ownerHandle, part.ownerHandle), eq44(tIdx.appSlug, part.appSlug), eq44(tIdx.dbName, part.dbName));
|
|
58751
|
-
const rProbe = await
|
|
58781
|
+
const rProbe = await exception2Result55(async () => {
|
|
58752
58782
|
const audRows2 = await vctx.sql.db.selectDistinct({ channel: tIdx.channel }).from(tIdx).where(and38(partWhere, gte(tIdx.channel, AUD_PREFIX), lt4(tIdx.channel, AUD_PREFIX_END)));
|
|
58753
58783
|
const inhRows2 = await vctx.sql.db.selectDistinct({ channel: tIdx.channel }).from(tIdx).where(and38(partWhere, gte(tIdx.channel, INHERIT_CHANNEL_PREFIX), lt4(tIdx.channel, INHERIT_PREFIX_END)));
|
|
58754
58784
|
return { audRows: audRows2, inhRows: inhRows2 };
|
|
@@ -58783,7 +58813,7 @@ __name(subjectDigestFromIndex, "subjectDigestFromIndex");
|
|
|
58783
58813
|
async function grantBearingOutputs(vctx, part, opts = {}) {
|
|
58784
58814
|
const tOut = vctx.sql.tables.accessFnOutputs;
|
|
58785
58815
|
if (!tOut) return void 0;
|
|
58786
|
-
const rRows = await
|
|
58816
|
+
const rRows = await exception2Result55(async () => {
|
|
58787
58817
|
const q = vctx.sql.db.select({ docId: tOut.docId, output: accessOutputForRead(vctx.sql) }).from(tOut).where(
|
|
58788
58818
|
and38(
|
|
58789
58819
|
eq44(tOut.ownerHandle, part.ownerHandle),
|
|
@@ -58922,7 +58952,7 @@ async function ensureLegacyCommentsMigrated(vctx, ownerHandle, appSlug) {
|
|
|
58922
58952
|
const last = perDb.get(key);
|
|
58923
58953
|
const now3 = Date.now();
|
|
58924
58954
|
if (last !== void 0 && now3 - last < MEMO_TTL_MS2) return;
|
|
58925
|
-
const r = await
|
|
58955
|
+
const r = await exception2Result56(() => migrate(vctx, ownerHandle, appSlug));
|
|
58926
58956
|
if (r.isErr()) {
|
|
58927
58957
|
console.warn(`comments migration failed for ${ownerHandle}/${appSlug}:`, r.Err());
|
|
58928
58958
|
return;
|
|
@@ -58945,7 +58975,7 @@ async function migrate(vctx, ownerHandle, appSlug) {
|
|
|
58945
58975
|
for (const docId of liveDocIds) await materializeOutput({ vctx, ownerHandle, appSlug, docId });
|
|
58946
58976
|
const failures = [];
|
|
58947
58977
|
for (const docId of new Set(legacyRevisions.map((r) => r.docId))) {
|
|
58948
|
-
const rMove = await
|
|
58978
|
+
const rMove = await exception2Result56(() => moveOneDoc({ vctx, ownerHandle, appSlug, docId }));
|
|
58949
58979
|
if (rMove.isErr()) {
|
|
58950
58980
|
console.warn(`comments migration: could not move ${ownerHandle}/${appSlug}/${docId}:`, rMove.Err());
|
|
58951
58981
|
failures.push(docId);
|
|
@@ -59237,7 +59267,7 @@ async function bindChannelInvitesToNewHandle(ctx, input) {
|
|
|
59237
59267
|
for (const inv of pending) {
|
|
59238
59268
|
if (inv.inviterHandle === input.ownerHandle) continue;
|
|
59239
59269
|
if (inv.id === input.exceptInviteId) continue;
|
|
59240
|
-
const r = await
|
|
59270
|
+
const r = await exception2Result57(
|
|
59241
59271
|
() => markChannelInviteBound(ctx.sql, { id: inv.id, boundHandle: input.ownerHandle, boundUserId: input.userId, now: now3 })
|
|
59242
59272
|
);
|
|
59243
59273
|
if (r.isErr()) {
|
|
@@ -59263,11 +59293,11 @@ async function bindChannelInvitesToNewHandle(ctx, input) {
|
|
|
59263
59293
|
__name(bindChannelInvitesToNewHandle, "bindChannelInvitesToNewHandle");
|
|
59264
59294
|
|
|
59265
59295
|
// ../vibes.diy/api/svc/intern/provisional-handle.ts
|
|
59266
|
-
import { exception2Result as
|
|
59296
|
+
import { exception2Result as exception2Result59, Result as Result34 } from "@adviser/cement";
|
|
59267
59297
|
import { and as and42, eq as eq49 } from "drizzle-orm";
|
|
59268
59298
|
|
|
59269
59299
|
// ../vibes.diy/api/svc/intern/onboarding-handle.ts
|
|
59270
|
-
import { exception2Result as
|
|
59300
|
+
import { exception2Result as exception2Result58, Result as Result33 } from "@adviser/cement";
|
|
59271
59301
|
import { and as and41, eq as eq48 } from "drizzle-orm/sql/expressions";
|
|
59272
59302
|
import { sql as sql11 } from "drizzle-orm";
|
|
59273
59303
|
import { generate as generate2 } from "random-words";
|
|
@@ -59555,7 +59585,7 @@ function logMintedHandleCollision(ctx, input) {
|
|
|
59555
59585
|
}
|
|
59556
59586
|
__name(logMintedHandleCollision, "logMintedHandleCollision");
|
|
59557
59587
|
async function dealUnboundMintedHandle(ctx, input) {
|
|
59558
|
-
return
|
|
59588
|
+
return exception2Result58(async () => {
|
|
59559
59589
|
const attempts = input.attempts ?? 12;
|
|
59560
59590
|
const draw = input.draw ?? drawMintedHandle;
|
|
59561
59591
|
for (let i = 0; i < attempts; i = i + 1) {
|
|
@@ -59572,7 +59602,7 @@ __name(dealUnboundMintedHandle, "dealUnboundMintedHandle");
|
|
|
59572
59602
|
// ../vibes.diy/api/svc/intern/provisional-handle.ts
|
|
59573
59603
|
async function earliestHandleOf(vctx, userId) {
|
|
59574
59604
|
const hb = vctx.sql.tables.handleBinding;
|
|
59575
|
-
const rows = await
|
|
59605
|
+
const rows = await exception2Result59(
|
|
59576
59606
|
() => vctx.sql.db.select({ handle: hb.handle, created: hb.created }).from(hb).where(eq49(hb.userId, userId))
|
|
59577
59607
|
);
|
|
59578
59608
|
if (rows.isErr()) return Result34.Err(rows.Err());
|
|
@@ -59602,7 +59632,7 @@ async function heldHandleResult(vctx, userId) {
|
|
|
59602
59632
|
const rDefault = await getDefaultUserSlug(vctx, userId);
|
|
59603
59633
|
if (rDefault.isErr()) return Result34.Err(rDefault.Err());
|
|
59604
59634
|
if (rDefault.Ok() === void 0) {
|
|
59605
|
-
const persisted = await
|
|
59635
|
+
const persisted = await exception2Result59(() => persistDefaultUserSlug(vctx, userId, heldHandle));
|
|
59606
59636
|
if (persisted.isErr()) return Result34.Err(persisted.Err());
|
|
59607
59637
|
}
|
|
59608
59638
|
return Result34.Ok({ handle: heldHandle, minted: false });
|
|
@@ -59626,12 +59656,12 @@ async function mintFirstHandle(vctx, input) {
|
|
|
59626
59656
|
const winner = earliest.Ok() ?? mine;
|
|
59627
59657
|
if (winner !== mine) {
|
|
59628
59658
|
const hb = vctx.sql.tables.handleBinding;
|
|
59629
|
-
const dropped = await
|
|
59659
|
+
const dropped = await exception2Result59(
|
|
59630
59660
|
() => vctx.sql.db.delete(hb).where(and42(eq49(hb.userId, input.userId), eq49(hb.handle, mine), eq49(hb.provisional, 1)))
|
|
59631
59661
|
);
|
|
59632
59662
|
if (dropped.isErr()) return Result34.Err(dropped.Err());
|
|
59633
59663
|
}
|
|
59634
|
-
const persisted = await
|
|
59664
|
+
const persisted = await exception2Result59(() => persistDefaultUserSlug(vctx, input.userId, winner));
|
|
59635
59665
|
if (persisted.isErr()) return Result34.Err(persisted.Err());
|
|
59636
59666
|
return Result34.Ok({ handle: winner, minted: winner === mine });
|
|
59637
59667
|
}
|
|
@@ -59685,7 +59715,7 @@ __name(isAppAddressMoved, "isAppAddressMoved");
|
|
|
59685
59715
|
|
|
59686
59716
|
// ../vibes.diy/api/svc/intern/ensure-slug-binding.ts
|
|
59687
59717
|
async function runSignupInviteMatch(ctx, input) {
|
|
59688
|
-
const r = await
|
|
59718
|
+
const r = await exception2Result60(async () => {
|
|
59689
59719
|
if (input.claims.params.email_verified !== true) return;
|
|
59690
59720
|
const email = input.claims.params.email;
|
|
59691
59721
|
if (email.length === 0) return;
|
|
@@ -59713,7 +59743,7 @@ async function writeProvisionalHandleBinding(ctx, userId, ownerHandle) {
|
|
|
59713
59743
|
}
|
|
59714
59744
|
__name(writeProvisionalHandleBinding, "writeProvisionalHandleBinding");
|
|
59715
59745
|
async function writeHandleBindingInner(ctx, input) {
|
|
59716
|
-
return
|
|
59746
|
+
return exception2Result60(async () => {
|
|
59717
59747
|
const userId = input.userId;
|
|
59718
59748
|
const ownerHandle = input.ownerHandle;
|
|
59719
59749
|
if (isReservedHandle(ownerHandle)) {
|
|
@@ -59776,7 +59806,7 @@ async function writeHandleBindingInner(ctx, input) {
|
|
|
59776
59806
|
}
|
|
59777
59807
|
__name(writeHandleBindingInner, "writeHandleBindingInner");
|
|
59778
59808
|
async function resolveUserHandleBinding(ctx, claims, binding, opts = {}) {
|
|
59779
|
-
return
|
|
59809
|
+
return exception2Result60(async () => {
|
|
59780
59810
|
if (!binding.ownerHandle) {
|
|
59781
59811
|
const existingForUser = await ctx.sql.db.select().from(ctx.sql.tables.handleBinding).where(eq51(ctx.sql.tables.handleBinding.userId, binding.userId));
|
|
59782
59812
|
if (existingForUser.length > 0) {
|
|
@@ -59866,7 +59896,7 @@ async function dealAccountHandle(ctx, input) {
|
|
|
59866
59896
|
}
|
|
59867
59897
|
__name(dealAccountHandle, "dealAccountHandle");
|
|
59868
59898
|
async function writeAppSlugBinding(ctx, userId, ownerHandle, appSlug) {
|
|
59869
|
-
return
|
|
59899
|
+
return exception2Result60(async () => {
|
|
59870
59900
|
const movedTo = await movedAwayTo(ctx.sql, { ownerHandle, appSlug });
|
|
59871
59901
|
if (movedTo !== void 0) return Result35.Err(new AppAddressMovedError({ ownerHandle, appSlug }, movedTo));
|
|
59872
59902
|
const [{ count: count5 }] = await ctx.sql.db.select({ count: sql12`count(*)` }).from(ctx.sql.tables.handleBinding).innerJoin(ctx.sql.tables.appSlugBinding, eq51(ctx.sql.tables.handleBinding.handle, ctx.sql.tables.appSlugBinding.ownerHandle)).where(eq51(ctx.sql.tables.handleBinding.userId, userId));
|
|
@@ -59922,7 +59952,7 @@ function isAllPreferredSlugsTaken(err2) {
|
|
|
59922
59952
|
}
|
|
59923
59953
|
__name(isAllPreferredSlugsTaken, "isAllPreferredSlugsTaken");
|
|
59924
59954
|
async function ensureAppSlug(ctx, binding) {
|
|
59925
|
-
return
|
|
59955
|
+
return exception2Result60(async () => {
|
|
59926
59956
|
if (!binding.appSlug) {
|
|
59927
59957
|
const [{ count: count5 }] = await ctx.sql.db.select({ count: sql12`count(*)` }).from(ctx.sql.tables.handleBinding).innerJoin(
|
|
59928
59958
|
ctx.sql.tables.appSlugBinding,
|
|
@@ -59941,7 +59971,7 @@ async function ensureAppSlug(ctx, binding) {
|
|
|
59941
59971
|
attemptErrors.push({ slug: candidate.slug, reason: "empty-after-sanitize" });
|
|
59942
59972
|
continue;
|
|
59943
59973
|
}
|
|
59944
|
-
const rExisting = await
|
|
59974
|
+
const rExisting = await exception2Result60(
|
|
59945
59975
|
() => ctx.sql.db.select().from(ctx.sql.tables.appSlugBinding).where(
|
|
59946
59976
|
and44(
|
|
59947
59977
|
eq51(ctx.sql.tables.appSlugBinding.appSlug, sanitized),
|
|
@@ -60023,7 +60053,7 @@ async function ensureAppSlug(ctx, binding) {
|
|
|
60023
60053
|
}
|
|
60024
60054
|
__name(ensureAppSlug, "ensureAppSlug");
|
|
60025
60055
|
async function claimForkAppSlug(ctx, args) {
|
|
60026
|
-
return
|
|
60056
|
+
return exception2Result60(async () => {
|
|
60027
60057
|
const appSlug = toRFC2822_32ByteLength(args.appSlug);
|
|
60028
60058
|
if (appSlug.length === 0) return Result35.Ok({ status: "taken" });
|
|
60029
60059
|
const ownedByAccount = await ctx.sql.db.select({ appSlug: ctx.sql.tables.apps.appSlug }).from(ctx.sql.tables.apps).where(and44(eq51(ctx.sql.tables.apps.appSlug, appSlug), eq51(ctx.sql.tables.apps.userId, args.userId))).limit(1).then((r) => r[0]);
|
|
@@ -60052,7 +60082,7 @@ async function allocateForkAppSlug(claim, candidates) {
|
|
|
60052
60082
|
}
|
|
60053
60083
|
__name(allocateForkAppSlug, "allocateForkAppSlug");
|
|
60054
60084
|
async function getDefaultUserSlug(ctx, userId) {
|
|
60055
|
-
return
|
|
60085
|
+
return exception2Result60(async () => {
|
|
60056
60086
|
const existing = await ctx.sql.db.select().from(ctx.sql.tables.userSettings).where(eq51(ctx.sql.tables.userSettings.userId, userId)).limit(1).then((r) => r[0]);
|
|
60057
60087
|
if (!existing) return Result35.Ok(void 0);
|
|
60058
60088
|
const { filtered: parsedSettings, warning: parsedWarning } = parseArrayWarning(existing.settings, userSettingItem);
|
|
@@ -60145,16 +60175,16 @@ async function lookupOwnerHandleBinding(ctx, sanitizedOwnerHandle) {
|
|
|
60145
60175
|
__name(lookupOwnerHandleBinding, "lookupOwnerHandleBinding");
|
|
60146
60176
|
|
|
60147
60177
|
// ../vibes.diy/api/svc/intern/agent-session-store.ts
|
|
60148
|
-
import { Result as Result39, exception2Result as
|
|
60178
|
+
import { Result as Result39, exception2Result as exception2Result67 } from "@adviser/cement";
|
|
60149
60179
|
import { and as and47, eq as eq54, isNull as isNull3 } from "drizzle-orm";
|
|
60150
60180
|
import { type as type97 } from "arktype";
|
|
60151
60181
|
|
|
60152
60182
|
// ../vibes.diy/api/svc/intern/agent-session.ts
|
|
60153
|
-
import { Result as Result38, exception2Result as
|
|
60183
|
+
import { Result as Result38, exception2Result as exception2Result66 } from "@adviser/cement";
|
|
60154
60184
|
import { type as type96 } from "arktype";
|
|
60155
60185
|
|
|
60156
60186
|
// ../vibes.diy/api/svc/intern/latest-screenshot.ts
|
|
60157
|
-
import { exception2Result as
|
|
60187
|
+
import { exception2Result as exception2Result61, stream2uint8array as stream2uint8array4 } from "@adviser/cement";
|
|
60158
60188
|
import { and as and45, eq as eq52, inArray as inArray17 } from "drizzle-orm/sql/expressions";
|
|
60159
60189
|
init_identity();
|
|
60160
60190
|
var DESKTOP_SIZE = { width: 1280, height: 720 };
|
|
@@ -60195,7 +60225,7 @@ __name(pickScreenshotRef, "pickScreenshotRef");
|
|
|
60195
60225
|
async function loadLatestScreenshotDataUrl(vctx, app, fsIdsNewestFirst) {
|
|
60196
60226
|
const logger = ensureLogger(vctx.sthis, "loadLatestScreenshotDataUrl");
|
|
60197
60227
|
if (fsIdsNewestFirst.length === 0) return void 0;
|
|
60198
|
-
const rResult = await
|
|
60228
|
+
const rResult = await exception2Result61(async () => {
|
|
60199
60229
|
const rows = await vctx.sql.db.select({ fsId: vctx.sql.tables.apps.fsId, meta: vctx.sql.tables.apps.meta }).from(vctx.sql.tables.apps).where(
|
|
60200
60230
|
and45(
|
|
60201
60231
|
eq52(vctx.sql.tables.apps.ownerHandle, app.ownerHandle),
|
|
@@ -60273,11 +60303,11 @@ function screenshotRecordsSentence(capture) {
|
|
|
60273
60303
|
__name(screenshotRecordsSentence, "screenshotRecordsSentence");
|
|
60274
60304
|
|
|
60275
60305
|
// ../vibes.diy/api/svc/intern/local-day.ts
|
|
60276
|
-
import { exception2Result as
|
|
60306
|
+
import { exception2Result as exception2Result62 } from "@adviser/cement";
|
|
60277
60307
|
var UTC_ZONE = "UTC";
|
|
60278
60308
|
function resolveTimeZone(input) {
|
|
60279
60309
|
if (typeof input !== "string" || input.length === 0 || input.length > 64) return void 0;
|
|
60280
|
-
const rZone =
|
|
60310
|
+
const rZone = exception2Result62(() => new Intl.DateTimeFormat("en-US", { timeZone: input }).resolvedOptions().timeZone);
|
|
60281
60311
|
return rZone.isOk() ? rZone.Ok() : void 0;
|
|
60282
60312
|
}
|
|
60283
60313
|
__name(resolveTimeZone, "resolveTimeZone");
|
|
@@ -60428,7 +60458,7 @@ function withMovingCacheBreakpoint(request) {
|
|
|
60428
60458
|
__name(withMovingCacheBreakpoint, "withMovingCacheBreakpoint");
|
|
60429
60459
|
|
|
60430
60460
|
// ../vibes.diy/api/svc/intern/inflate-file-attachments.ts
|
|
60431
|
-
import { exception2Result as
|
|
60461
|
+
import { exception2Result as exception2Result63, Result as Result36, stream2uint8array as stream2uint8array5 } from "@adviser/cement";
|
|
60432
60462
|
import { inArray as inArray18, and as and46, eq as eq53 } from "drizzle-orm/sql/expressions";
|
|
60433
60463
|
init_identity();
|
|
60434
60464
|
|
|
@@ -60579,7 +60609,7 @@ __name(stripVibesFileBlocks, "stripVibesFileBlocks");
|
|
|
60579
60609
|
var MODEL_IMAGE_EDGE = 768;
|
|
60580
60610
|
var MODEL_IMAGE_MIME = WEBP_RENDITION_MIME;
|
|
60581
60611
|
async function readAsset(vctx, assetURI) {
|
|
60582
|
-
return
|
|
60612
|
+
return exception2Result63(async () => {
|
|
60583
60613
|
const fetched = await vctx.storage.fetch(assetURI);
|
|
60584
60614
|
if (!isFetchOkResult(fetched)) throw new Error(`asset fetch failed: ${assetURI}`);
|
|
60585
60615
|
return stream2uint8array5(fetched.data);
|
|
@@ -60590,7 +60620,7 @@ async function modelSizedImage(vctx, args) {
|
|
|
60590
60620
|
const images = vctx.images;
|
|
60591
60621
|
const logger = ensureLogger(vctx.sthis, "inflateFileAttachments");
|
|
60592
60622
|
if (images !== void 0) {
|
|
60593
|
-
const rSmall = await
|
|
60623
|
+
const rSmall = await exception2Result63(async () => {
|
|
60594
60624
|
const fetched = await vctx.storage.fetch(args.assetURI);
|
|
60595
60625
|
if (!isFetchOkResult(fetched)) throw new Error(`asset fetch failed: ${args.assetURI}`);
|
|
60596
60626
|
return transformToWebp(images, fetched.data, { width: MODEL_IMAGE_EDGE, height: MODEL_IMAGE_EDGE });
|
|
@@ -60624,7 +60654,7 @@ async function inflateFileAttachments(vctx, args) {
|
|
|
60624
60654
|
const byUploadId = /* @__PURE__ */ new Map();
|
|
60625
60655
|
const scope2 = args.scope;
|
|
60626
60656
|
if (scope2 !== void 0) {
|
|
60627
|
-
const rRows = await
|
|
60657
|
+
const rRows = await exception2Result63(
|
|
60628
60658
|
() => vctx.sql.db.select({ uploadId: t.uploadId, assetURI: t.assetURI, mimeType: t.mimeType }).from(t).where(
|
|
60629
60659
|
and46(
|
|
60630
60660
|
inArray18(t.uploadId, [...new Set(refs.map((r) => r.uploadId))]),
|
|
@@ -60712,7 +60742,7 @@ ${text3}
|
|
|
60712
60742
|
__name(inflateFileAttachments, "inflateFileAttachments");
|
|
60713
60743
|
|
|
60714
60744
|
// ../vibes.diy/api/svc/intern/llm-tool-loop.ts
|
|
60715
|
-
import { Result as Result37, exception2Result as
|
|
60745
|
+
import { Result as Result37, exception2Result as exception2Result65 } from "@adviser/cement";
|
|
60716
60746
|
|
|
60717
60747
|
// ../vibes.diy/api/svc/intern/agent-stop-note.ts
|
|
60718
60748
|
var AGENT_STOP_NOTE_PREFIX = "[stopped]";
|
|
@@ -60984,7 +61014,7 @@ __name(rolloverAgentTranscript, "rolloverAgentTranscript");
|
|
|
60984
61014
|
|
|
60985
61015
|
// ../vibes.diy/api/svc/public/provider-errors.ts
|
|
60986
61016
|
init_lazy_type();
|
|
60987
|
-
import { exception2Result as
|
|
61017
|
+
import { exception2Result as exception2Result64 } from "@adviser/cement";
|
|
60988
61018
|
import { type as type95 } from "arktype";
|
|
60989
61019
|
var MAX_RETRY_AFTER_MS = 1e4;
|
|
60990
61020
|
var MAX_ATTEMPT_BODY_SNIPPET_CHARS = 2e3;
|
|
@@ -61039,7 +61069,7 @@ function boundSnippet(text3) {
|
|
|
61039
61069
|
__name(boundSnippet, "boundSnippet");
|
|
61040
61070
|
async function readFailureBody(res) {
|
|
61041
61071
|
if (res.body === null) return { snippet: "", full: "" };
|
|
61042
|
-
const rText = await
|
|
61072
|
+
const rText = await exception2Result64(() => res.text());
|
|
61043
61073
|
const full = rText.isOk() ? rText.Ok() : `<read-failed: ${String(rText.Err())}>`;
|
|
61044
61074
|
return { snippet: boundSnippet(full), full };
|
|
61045
61075
|
}
|
|
@@ -61076,7 +61106,7 @@ var providerErrorBody = lazyType(
|
|
|
61076
61106
|
})
|
|
61077
61107
|
);
|
|
61078
61108
|
function extractProviderErrorFields(bodyFull) {
|
|
61079
|
-
const rParsed =
|
|
61109
|
+
const rParsed = exception2Result64(() => providerErrorBody(JSON.parse(bodyFull)));
|
|
61080
61110
|
if (rParsed.isErr()) return {};
|
|
61081
61111
|
const parsed = rParsed.Ok();
|
|
61082
61112
|
if (parsed instanceof type95.errors) return {};
|
|
@@ -61368,7 +61398,7 @@ function completeToolCalls(partials, request) {
|
|
|
61368
61398
|
if (toolDefinitionFor(request, partial.name) === void 0) {
|
|
61369
61399
|
return Result37.Err(`unknown tool call: ${partial.name}`);
|
|
61370
61400
|
}
|
|
61371
|
-
const rArguments =
|
|
61401
|
+
const rArguments = exception2Result65(() => JSON.parse(partialArguments));
|
|
61372
61402
|
if (rArguments.isErr()) {
|
|
61373
61403
|
return Result37.Err(`malformed arguments for tool ${partial.name}`);
|
|
61374
61404
|
}
|
|
@@ -61425,7 +61455,7 @@ async function readWithDeadline({
|
|
|
61425
61455
|
}) {
|
|
61426
61456
|
const remaining = remainingBudget(budget, now3);
|
|
61427
61457
|
if (remaining <= 0) return Result37.Err("LLM tool loop deadline exceeded");
|
|
61428
|
-
const readResult =
|
|
61458
|
+
const readResult = exception2Result65(() => reader.read()).then(
|
|
61429
61459
|
(r) => r.isErr() ? Result37.Err(new LlmToolLoopAbandonedError(`provider stream failed before sse.end: ${String(r.Err())}`)) : Result37.Ok({ done: r.Ok().done, value: r.Ok().value })
|
|
61430
61460
|
);
|
|
61431
61461
|
let timeoutId;
|
|
@@ -61468,7 +61498,7 @@ async function executeWithDeadline({
|
|
|
61468
61498
|
if (remaining <= 0) return Result37.Err("LLM tool loop deadline exceeded before tool execution");
|
|
61469
61499
|
if (parentSignal?.aborted) return Result37.Err("tool execution aborted by parent request");
|
|
61470
61500
|
const abort = new AbortController();
|
|
61471
|
-
const execution =
|
|
61501
|
+
const execution = exception2Result65(
|
|
61472
61502
|
() => execute({
|
|
61473
61503
|
call: call2,
|
|
61474
61504
|
signal: abort.signal,
|
|
@@ -61556,7 +61586,7 @@ async function consumeProviderStream({
|
|
|
61556
61586
|
const cancelReader = /* @__PURE__ */ __name(async (reason) => {
|
|
61557
61587
|
if (cancelPromise !== void 0) return cancelPromise;
|
|
61558
61588
|
cancelPromise = (async () => {
|
|
61559
|
-
await
|
|
61589
|
+
await exception2Result65(() => reader.cancel(reason));
|
|
61560
61590
|
})();
|
|
61561
61591
|
await cancelPromise;
|
|
61562
61592
|
}, "cancelReader");
|
|
@@ -61687,7 +61717,7 @@ async function runLlmToolLoop(loopArgs) {
|
|
|
61687
61717
|
const result = await runToolLoop(loopArgs);
|
|
61688
61718
|
const stopped = loopArgs.session?.stopped;
|
|
61689
61719
|
if (result.isErr() && result.Err().message === STOPPED_MESSAGE && stopped !== void 0) {
|
|
61690
|
-
await
|
|
61720
|
+
await exception2Result65(() => stopped());
|
|
61691
61721
|
}
|
|
61692
61722
|
return result;
|
|
61693
61723
|
}
|
|
@@ -61905,7 +61935,7 @@ async function runToolLoop(loopArgs) {
|
|
|
61905
61935
|
}
|
|
61906
61936
|
const cap = rounds >= maxToolRounds ? { kind: "rounds", limit: maxToolRounds } : calls + streamResult.toolCalls.length > maxToolCalls ? { kind: "calls", limit: maxToolCalls } : void 0;
|
|
61907
61937
|
if (cap !== void 0) {
|
|
61908
|
-
|
|
61938
|
+
exception2Result65(() => args.onCapReached?.(cap));
|
|
61909
61939
|
const capError = cap.kind === "rounds" ? `LLM tool loop exceeded ${cap.limit} rounds` : `LLM tool loop exceeded ${cap.limit} tool calls`;
|
|
61910
61940
|
if (args.capSummary === void 0) return Result37.Err(capError);
|
|
61911
61941
|
return await speakCapSummary({ note: args.capSummary, cap, capError, capped: streamResult });
|
|
@@ -61916,7 +61946,7 @@ async function runToolLoop(loopArgs) {
|
|
|
61916
61946
|
const endsMessage = args.messageBoundaries !== void 0 && streamResult.toolCalls.some((call2) => quietTools?.has(call2.name) !== true);
|
|
61917
61947
|
const rFlush = endsMessage ? await endMessage(args.onVisible, textState, streamResult.roundEnd?.streamId) : await flushRoundLine(args.onVisible, textState, streamResult.roundEnd);
|
|
61918
61948
|
if (rFlush.isErr()) return Result37.Err(rFlush.Err());
|
|
61919
|
-
|
|
61949
|
+
exception2Result65(() => args.onToolRound?.({ round: rounds, calls: streamResult.toolCalls }));
|
|
61920
61950
|
const nextMessages = [...currentRequest.messages];
|
|
61921
61951
|
nextMessages.push({
|
|
61922
61952
|
role: "assistant",
|
|
@@ -62399,7 +62429,7 @@ function createAgentSession(args) {
|
|
|
62399
62429
|
if (failure2 !== void 0) return Result38.Err(failure2);
|
|
62400
62430
|
if (admit !== void 0 && admit() === false) return Result38.Err(AGENT_SESSION_IDLE);
|
|
62401
62431
|
const next = change(state3);
|
|
62402
|
-
const saved = await
|
|
62432
|
+
const saved = await exception2Result66(() => args.save(next, revision));
|
|
62403
62433
|
if (saved.isErr()) {
|
|
62404
62434
|
if (saved.Err().message === AGENT_SESSION_SUPERSEDED) {
|
|
62405
62435
|
failure2 = saved.Err();
|
|
@@ -62638,7 +62668,7 @@ function shouldResumeAgentSession(snapshot, turnRow, nowMs) {
|
|
|
62638
62668
|
__name(shouldResumeAgentSession, "shouldResumeAgentSession");
|
|
62639
62669
|
async function readAgentSession(sql38, chatId) {
|
|
62640
62670
|
const table = sql38.tables.openTurns;
|
|
62641
|
-
const rows = await
|
|
62671
|
+
const rows = await exception2Result67(
|
|
62642
62672
|
() => sql38.db.select({ value: table.agentSession, revision: table.agentSessionRevision }).from(table).where(and47(eq54(table.chatId, chatId), eq54(table.promptId, AGENT_SESSION_RECORD_ID))).limit(1)
|
|
62643
62673
|
);
|
|
62644
62674
|
if (rows.isErr()) return Result39.Err(rows.Err());
|
|
@@ -62646,7 +62676,7 @@ async function readAgentSession(sql38, chatId) {
|
|
|
62646
62676
|
const revision = row?.revision ?? 0;
|
|
62647
62677
|
const value = row?.value;
|
|
62648
62678
|
if (value === void 0 || value === null) return Result39.Ok({ revision });
|
|
62649
|
-
const json3 =
|
|
62679
|
+
const json3 = exception2Result67(() => JSON.parse(value));
|
|
62650
62680
|
if (json3.isErr()) return Result39.Err(json3.Err());
|
|
62651
62681
|
const parsed = agentSessionSnapshot(json3.Ok());
|
|
62652
62682
|
if (parsed instanceof type97.errors) return Result39.Err(parsed.summary);
|
|
@@ -62663,7 +62693,7 @@ async function saveAgentSession({
|
|
|
62663
62693
|
const now3 = (/* @__PURE__ */ new Date()).toISOString();
|
|
62664
62694
|
const value = JSON.stringify(snapshot);
|
|
62665
62695
|
const revision = expectedRevision + 1;
|
|
62666
|
-
const saved = await
|
|
62696
|
+
const saved = await exception2Result67(
|
|
62667
62697
|
() => sql38.db.insert(table).values({
|
|
62668
62698
|
...input,
|
|
62669
62699
|
promptId: AGENT_SESSION_RECORD_ID,
|
|
@@ -62910,7 +62940,7 @@ async function pairIsFree(db, t, pair) {
|
|
|
62910
62940
|
__name(pairIsFree, "pairIsFree");
|
|
62911
62941
|
async function allocateMoveSlug(db, t, target2) {
|
|
62912
62942
|
return allocateForkAppSlug(async (appSlug) => {
|
|
62913
|
-
const free = await
|
|
62943
|
+
const free = await exception2Result68(() => pairIsFree(db, t, { ownerHandle: target2.ownerHandle, appSlug }));
|
|
62914
62944
|
if (free.isErr()) return Result40.Err(free.Err());
|
|
62915
62945
|
return Result40.Ok(free.Ok() ? { status: "claimed", appSlug } : { status: "taken" });
|
|
62916
62946
|
}, moveSlugCandidates(target2.appSlug));
|
|
@@ -62979,19 +63009,19 @@ async function finishDeferredAppMove(vctx, input) {
|
|
|
62979
63009
|
const t = vctx.sql.tables;
|
|
62980
63010
|
const cc = t.chatContexts;
|
|
62981
63011
|
const am = t.appMoves;
|
|
62982
|
-
const rChat = await
|
|
63012
|
+
const rChat = await exception2Result68(
|
|
62983
63013
|
() => vctx.sql.db.select({ ownerHandle: cc.ownerHandle, appSlug: cc.appSlug }).from(cc).where(eq55(cc.chatId, input.chatId)).limit(1).then((r) => r[0])
|
|
62984
63014
|
);
|
|
62985
63015
|
if (rChat.isErr()) return Result40.Err(rChat.Err());
|
|
62986
63016
|
const chat = rChat.Ok();
|
|
62987
63017
|
if (chat === void 0) return Result40.Ok(void 0);
|
|
62988
63018
|
const pendingAt = and48(eq55(am.fromHandle, chat.ownerHandle), eq55(am.fromSlug, chat.appSlug), eq55(am.status, APP_MOVE_PENDING));
|
|
62989
|
-
const rPending = await
|
|
63019
|
+
const rPending = await exception2Result68(
|
|
62990
63020
|
() => vctx.sql.db.select({ v: am.toHandle }).from(am).where(pendingAt).limit(1).then((r) => r[0])
|
|
62991
63021
|
);
|
|
62992
63022
|
if (rPending.isErr()) return Result40.Err(rPending.Err());
|
|
62993
63023
|
if (rPending.Ok() === void 0) return Result40.Ok(void 0);
|
|
62994
|
-
return
|
|
63024
|
+
return exception2Result68(
|
|
62995
63025
|
() => vctx.sql.db.transaction(async (tx) => {
|
|
62996
63026
|
const [still] = await tx.select().from(am).where(pendingAt).limit(1);
|
|
62997
63027
|
if (still === void 0) return void 0;
|
|
@@ -63015,7 +63045,7 @@ async function sweepAppMoves(db, t, userId) {
|
|
|
63015
63045
|
__name(sweepAppMoves, "sweepAppMoves");
|
|
63016
63046
|
var MAX_MOVE_HOPS = 4;
|
|
63017
63047
|
async function resolveAppMove(vctx, pair) {
|
|
63018
|
-
return
|
|
63048
|
+
return exception2Result68(async () => {
|
|
63019
63049
|
let current = pair;
|
|
63020
63050
|
let moved = false;
|
|
63021
63051
|
for (let hop = 0; hop < MAX_MOVE_HOPS; hop++) {
|
|
@@ -63050,7 +63080,7 @@ __name(scheduleMovedBackends, "scheduleMovedBackends");
|
|
|
63050
63080
|
async function moveAppsToChosenHandle(vctx, input) {
|
|
63051
63081
|
const now3 = input.now ?? /* @__PURE__ */ new Date();
|
|
63052
63082
|
const hb = vctx.sql.tables.handleBinding;
|
|
63053
|
-
const r = await
|
|
63083
|
+
const r = await exception2Result68(
|
|
63054
63084
|
() => vctx.sql.db.transaction(async (tx) => {
|
|
63055
63085
|
const bound = await tx.select({ handle: hb.handle, provisional: hb.provisional }).from(hb).where(eq55(hb.userId, input.userId));
|
|
63056
63086
|
const target2 = bound.find((b) => b.handle === input.toHandle);
|
|
@@ -63083,7 +63113,7 @@ __name(moveAppsToChosenHandle, "moveAppsToChosenHandle");
|
|
|
63083
63113
|
async function healProvisionalOwnerApp(vctx, input) {
|
|
63084
63114
|
if (input.ownerHandle === input.actingHandle) return Result40.Ok(void 0);
|
|
63085
63115
|
const hb = vctx.sql.tables.handleBinding;
|
|
63086
|
-
const rRows = await
|
|
63116
|
+
const rRows = await exception2Result68(
|
|
63087
63117
|
() => vctx.sql.db.select({ handle: hb.handle, provisional: hb.provisional }).from(hb).where(and48(eq55(hb.userId, input.userId), inArray19(hb.handle, [input.ownerHandle, input.actingHandle])))
|
|
63088
63118
|
);
|
|
63089
63119
|
if (rRows.isErr()) return Result40.Err(rRows.Err());
|
|
@@ -63122,9 +63152,9 @@ import { type as type111 } from "arktype";
|
|
|
63122
63152
|
import {
|
|
63123
63153
|
Result as Result57,
|
|
63124
63154
|
EventoResult as EventoResult8,
|
|
63125
|
-
exception2Result as
|
|
63155
|
+
exception2Result as exception2Result101,
|
|
63126
63156
|
stream2uint8array as stream2uint8array8,
|
|
63127
|
-
URI as
|
|
63157
|
+
URI as URI12
|
|
63128
63158
|
} from "@adviser/cement";
|
|
63129
63159
|
|
|
63130
63160
|
// ../vibes.diy/api/svc/public/root-document-cors.ts
|
|
@@ -63740,7 +63770,7 @@ function viewerCapabilitiesFor({
|
|
|
63740
63770
|
__name(viewerCapabilitiesFor, "viewerCapabilitiesFor");
|
|
63741
63771
|
|
|
63742
63772
|
// ../vibes.diy/api/svc/intern/kyc.ts
|
|
63743
|
-
import { Result as Result42, exception2Result as
|
|
63773
|
+
import { Result as Result42, exception2Result as exception2Result69 } from "@adviser/cement";
|
|
63744
63774
|
import { eq as eq56 } from "drizzle-orm/sql/expressions";
|
|
63745
63775
|
import { sql as sql14 } from "drizzle-orm";
|
|
63746
63776
|
function isKycSettingItem(e) {
|
|
@@ -63757,7 +63787,7 @@ function kycFromSettingItems(items) {
|
|
|
63757
63787
|
}
|
|
63758
63788
|
__name(kycFromSettingItems, "kycFromSettingItems");
|
|
63759
63789
|
async function selectSettingItems(vctx, userId) {
|
|
63760
|
-
const rRows = await
|
|
63790
|
+
const rRows = await exception2Result69(
|
|
63761
63791
|
() => vctx.sql.db.select({ settings: vctx.sql.tables.userSettings.settings }).from(vctx.sql.tables.userSettings).where(eq56(vctx.sql.tables.userSettings.userId, userId)).limit(1)
|
|
63762
63792
|
);
|
|
63763
63793
|
if (rRows.isErr()) {
|
|
@@ -63794,7 +63824,7 @@ async function stampKycCard(vctx, userId, at2 = (/* @__PURE__ */ new Date()).toI
|
|
|
63794
63824
|
const stamp2 = { type: "kyc", cardAt: at2 };
|
|
63795
63825
|
const stampArray = sql14`${JSON.stringify([stamp2])}`;
|
|
63796
63826
|
const settingsSeed = flavour === "pg" ? sql14`${stampArray}::jsonb` : stampArray;
|
|
63797
|
-
const rInsert = await
|
|
63827
|
+
const rInsert = await exception2Result69(
|
|
63798
63828
|
() => runKycSql(
|
|
63799
63829
|
vctx.sql.db,
|
|
63800
63830
|
flavour,
|
|
@@ -63807,7 +63837,7 @@ async function stampKycCard(vctx, userId, at2 = (/* @__PURE__ */ new Date()).toI
|
|
|
63807
63837
|
if (rInsert.isErr()) throw rInsert.Err();
|
|
63808
63838
|
const appended = flavour === "pg" ? sql14`"settings" || ${stampArray}::jsonb` : sql14`json_insert("settings", '$[#]', json(${JSON.stringify(stamp2)}))`;
|
|
63809
63839
|
const absent = flavour === "pg" ? sql14`NOT EXISTS (SELECT 1 FROM jsonb_array_elements("UserSettings"."settings") e WHERE e->>'type' = 'kyc')` : sql14`NOT EXISTS (SELECT 1 FROM json_each("UserSettings"."settings") e WHERE json_extract(e.value, '$.type') = 'kyc')`;
|
|
63810
|
-
const rUpdate = await
|
|
63840
|
+
const rUpdate = await exception2Result69(
|
|
63811
63841
|
() => runKycSql(
|
|
63812
63842
|
vctx.sql.db,
|
|
63813
63843
|
flavour,
|
|
@@ -63863,7 +63893,7 @@ function deriveDisplayName(claims) {
|
|
|
63863
63893
|
__name(deriveDisplayName, "deriveDisplayName");
|
|
63864
63894
|
|
|
63865
63895
|
// ../vibes.diy/api/svc/intern/signup-attribution-capture.ts
|
|
63866
|
-
import { exception2Result as
|
|
63896
|
+
import { exception2Result as exception2Result70 } from "@adviser/cement";
|
|
63867
63897
|
import { eq as eq57 } from "drizzle-orm/sql/expressions";
|
|
63868
63898
|
async function ownsNoHandle(ctx, userId) {
|
|
63869
63899
|
const row = await ctx.sql.db.select({ handle: ctx.sql.tables.handleBinding.handle }).from(ctx.sql.tables.handleBinding).where(eq57(ctx.sql.tables.handleBinding.userId, userId)).limit(1).then((r) => r[0]);
|
|
@@ -63876,7 +63906,7 @@ async function ownedByGuest(ctx, handle) {
|
|
|
63876
63906
|
}
|
|
63877
63907
|
__name(ownedByGuest, "ownedByGuest");
|
|
63878
63908
|
async function recordSignupAttribution(ctx, input) {
|
|
63879
|
-
const r = await
|
|
63909
|
+
const r = await exception2Result70(async () => {
|
|
63880
63910
|
if (input.userId.length === 0) return;
|
|
63881
63911
|
if (input.ownerHandle.length === 0 || input.appSlug.length === 0) return;
|
|
63882
63912
|
if (isReservedHandle(input.ownerHandle)) return;
|
|
@@ -63915,11 +63945,11 @@ async function recordSignupAttribution(ctx, input) {
|
|
|
63915
63945
|
__name(recordSignupAttribution, "recordSignupAttribution");
|
|
63916
63946
|
|
|
63917
63947
|
// ../vibes.diy/api/svc/intern/record-daily-visit.ts
|
|
63918
|
-
import { exception2Result as
|
|
63948
|
+
import { exception2Result as exception2Result73 } from "@adviser/cement";
|
|
63919
63949
|
import { and as and50, eq as eq61 } from "drizzle-orm/sql/expressions";
|
|
63920
63950
|
|
|
63921
63951
|
// ../vibes.diy/api/svc/intern/capi-lead-event.ts
|
|
63922
|
-
import { exception2Result as
|
|
63952
|
+
import { exception2Result as exception2Result72 } from "@adviser/cement";
|
|
63923
63953
|
import { eq as eq60 } from "drizzle-orm/sql/expressions";
|
|
63924
63954
|
|
|
63925
63955
|
// ../vibes.diy/api/types/queue-schedule.ts
|
|
@@ -63939,7 +63969,7 @@ function queueRetryHorizonMs() {
|
|
|
63939
63969
|
__name(queueRetryHorizonMs, "queueRetryHorizonMs");
|
|
63940
63970
|
|
|
63941
63971
|
// ../vibes.diy/api/svc/intern/clerk-account-created.ts
|
|
63942
|
-
import { exception2Result as
|
|
63972
|
+
import { exception2Result as exception2Result71, Result as Result43 } from "@adviser/cement";
|
|
63943
63973
|
|
|
63944
63974
|
// ../vibes.diy/api/svc/intern/capi-build-event.ts
|
|
63945
63975
|
import { eq as eq59 } from "drizzle-orm/sql/expressions";
|
|
@@ -65350,7 +65380,7 @@ function shouldCreditReturn(input) {
|
|
|
65350
65380
|
}
|
|
65351
65381
|
__name(shouldCreditReturn, "shouldCreditReturn");
|
|
65352
65382
|
async function postCapiReturnEvent(ctx, args) {
|
|
65353
|
-
const r = await
|
|
65383
|
+
const r = await exception2Result72(async () => {
|
|
65354
65384
|
const plan = planCapiLeadEvent({
|
|
65355
65385
|
rung: "return",
|
|
65356
65386
|
day: args.day,
|
|
@@ -65406,7 +65436,7 @@ function postDailyVisit(ctx, plan, src) {
|
|
|
65406
65436
|
}
|
|
65407
65437
|
__name(postDailyVisit, "postDailyVisit");
|
|
65408
65438
|
function recordDailyVisitInBackground(vctx, args, src) {
|
|
65409
|
-
const scheduled =
|
|
65439
|
+
const scheduled = exception2Result73(() => scheduleDailyVisit(vctx, args, src));
|
|
65410
65440
|
if (scheduled.isErr()) {
|
|
65411
65441
|
console.warn(`[daily-visit] scheduling from ${src} failed:`, scheduled.Err());
|
|
65412
65442
|
}
|
|
@@ -65416,7 +65446,7 @@ function scheduleDailyVisit(vctx, args, src) {
|
|
|
65416
65446
|
const plan = planDailyVisit({ userId: args.userId, items: args.items, now: (/* @__PURE__ */ new Date()).toISOString() });
|
|
65417
65447
|
if (plan === void 0 || claimedInFlight(plan)) return;
|
|
65418
65448
|
inFlightClaims.set(plan.userId, { day: plan.item.day, at: Date.now() });
|
|
65419
|
-
const task =
|
|
65449
|
+
const task = exception2Result73(() => stampDailyVisit(vctx, { plan, src })).then((r) => {
|
|
65420
65450
|
inFlightClaims.delete(plan.userId);
|
|
65421
65451
|
if (r.isErr()) {
|
|
65422
65452
|
vctx.logger.Warn().Err(r.Err()).Str("userId", plan.userId).Str("src", src).Msg("daily visit stamp failed");
|
|
@@ -65427,7 +65457,7 @@ function scheduleDailyVisit(vctx, args, src) {
|
|
|
65427
65457
|
void task;
|
|
65428
65458
|
return;
|
|
65429
65459
|
}
|
|
65430
|
-
const registered =
|
|
65460
|
+
const registered = exception2Result73(() => waitUntil(task));
|
|
65431
65461
|
if (registered.isErr()) {
|
|
65432
65462
|
vctx.logger.Warn().Err(registered.Err()).Str("src", src).Msg("daily visit waitUntil registration failed");
|
|
65433
65463
|
}
|
|
@@ -65480,7 +65510,7 @@ async function creditReturnVisit(vctx, args) {
|
|
|
65480
65510
|
}
|
|
65481
65511
|
__name(creditReturnVisit, "creditReturnVisit");
|
|
65482
65512
|
function creditReturnVisitInBackground(vctx, args) {
|
|
65483
|
-
const task =
|
|
65513
|
+
const task = exception2Result73(() => creditReturnVisit(vctx, args)).then((r) => {
|
|
65484
65514
|
if (r.isErr()) {
|
|
65485
65515
|
vctx.logger.Warn().Err(r.Err()).Str("userId", args.plan.userId).Msg("return credit failed");
|
|
65486
65516
|
}
|
|
@@ -65490,7 +65520,7 @@ function creditReturnVisitInBackground(vctx, args) {
|
|
|
65490
65520
|
void task;
|
|
65491
65521
|
return;
|
|
65492
65522
|
}
|
|
65493
|
-
const registered =
|
|
65523
|
+
const registered = exception2Result73(() => waitUntil(task));
|
|
65494
65524
|
if (registered.isErr()) {
|
|
65495
65525
|
vctx.logger.Warn().Err(registered.Err()).Msg("return credit waitUntil registration failed");
|
|
65496
65526
|
}
|
|
@@ -65752,7 +65782,7 @@ var whoAmIEvento = {
|
|
|
65752
65782
|
|
|
65753
65783
|
// ../vibes.diy/api/svc/intern/components/vibe-page.tsx
|
|
65754
65784
|
init_runtime();
|
|
65755
|
-
import { BuildURI as BuildURI7, URI as
|
|
65785
|
+
import { BuildURI as BuildURI7, URI as URI11 } from "@adviser/cement";
|
|
65756
65786
|
import * as React11 from "react";
|
|
65757
65787
|
|
|
65758
65788
|
// ../vibes.diy/api/svc/intern/ssr-theme-css.ts
|
|
@@ -65999,7 +66029,7 @@ function vibeBackgroundClickScript() {
|
|
|
65999
66029
|
__name(vibeBackgroundClickScript, "vibeBackgroundClickScript");
|
|
66000
66030
|
|
|
66001
66031
|
// ../vibes.diy/api/svc/intern/components/boot-progress-script.ts
|
|
66002
|
-
import { URI as
|
|
66032
|
+
import { URI as URI10 } from "@adviser/cement";
|
|
66003
66033
|
var FRESH_RENDER_TIMING_NAME = "vibes-render";
|
|
66004
66034
|
var FRESH_RENDER_WINDOW_MS = 12e4;
|
|
66005
66035
|
function freshRenderTimingEntry(nowMs) {
|
|
@@ -66007,7 +66037,7 @@ function freshRenderTimingEntry(nowMs) {
|
|
|
66007
66037
|
}
|
|
66008
66038
|
__name(freshRenderTimingEntry, "freshRenderTimingEntry");
|
|
66009
66039
|
function thirdPartyImport(specifier, url) {
|
|
66010
|
-
const parsed =
|
|
66040
|
+
const parsed = URI10.fromResult(url);
|
|
66011
66041
|
if (parsed.isErr()) return void 0;
|
|
66012
66042
|
const u = parsed.Ok();
|
|
66013
66043
|
if (u.protocol !== "https:" && u.protocol !== "http:") return void 0;
|
|
@@ -66075,7 +66105,7 @@ function ImportMap(prop) {
|
|
|
66075
66105
|
}
|
|
66076
66106
|
__name(ImportMap, "ImportMap");
|
|
66077
66107
|
function originOf(url) {
|
|
66078
|
-
const u =
|
|
66108
|
+
const u = URI11.from(url);
|
|
66079
66109
|
const defaultPort = u.protocol === "https:" ? "443" : "80";
|
|
66080
66110
|
const port = u.port && u.port !== defaultPort ? `:${u.port}` : "";
|
|
66081
66111
|
return `${u.protocol}//${u.hostname}${port}`;
|
|
@@ -66315,10 +66345,10 @@ function VibePage(props) {
|
|
|
66315
66345
|
__name(VibePage, "VibePage");
|
|
66316
66346
|
|
|
66317
66347
|
// ../vibes.diy/api/svc/intern/vibe-ssr-attempt.ts
|
|
66318
|
-
import { exception2Result as
|
|
66348
|
+
import { exception2Result as exception2Result98 } from "@adviser/cement";
|
|
66319
66349
|
|
|
66320
66350
|
// ../vibes.diy/vibe/runtime/node-executor.ts
|
|
66321
|
-
import { exception2Result as
|
|
66351
|
+
import { exception2Result as exception2Result97 } from "@adviser/cement";
|
|
66322
66352
|
import { init as initLexer, parse as parseModule3 } from "es-module-lexer";
|
|
66323
66353
|
|
|
66324
66354
|
// ../vibes.diy/vibe/runtime/render-vibes.ts
|
|
@@ -66364,7 +66394,7 @@ async function resolveBareSpecifiers(code2, resolve6) {
|
|
|
66364
66394
|
if (imp.type === "dynamic" || imp.type === "import-meta") continue;
|
|
66365
66395
|
const spec = code2.slice(imp.start, imp.end);
|
|
66366
66396
|
if (ALREADY_RESOLVED.test(spec)) continue;
|
|
66367
|
-
const resolved =
|
|
66397
|
+
const resolved = exception2Result97(() => resolve6(spec));
|
|
66368
66398
|
if (resolved.isErr()) continue;
|
|
66369
66399
|
out += code2.slice(last, imp.start) + resolved.Ok();
|
|
66370
66400
|
last = imp.end;
|
|
@@ -66652,18 +66682,18 @@ function selectConventionEntry(fsItems) {
|
|
|
66652
66682
|
}
|
|
66653
66683
|
__name(selectConventionEntry, "selectConventionEntry");
|
|
66654
66684
|
async function attemptVibeSsr(input) {
|
|
66655
|
-
const rExec =
|
|
66685
|
+
const rExec = exception2Result98(() => selectExecutor(input.mode, { loader: input.loader }));
|
|
66656
66686
|
if (rExec.isErr()) return { reason: "select_error" };
|
|
66657
66687
|
const executor = rExec.Ok();
|
|
66658
66688
|
if (executor === void 0) return { reason: "ssr_disabled" };
|
|
66659
66689
|
const entry2 = selectConventionEntry(input.fsItems);
|
|
66660
66690
|
if (entry2.kind === "none") return { reason: "source_missing" };
|
|
66661
66691
|
if (entry2.kind === "ambiguous") return { reason: "entry_ambiguous" };
|
|
66662
|
-
const rSource = await
|
|
66692
|
+
const rSource = await exception2Result98(async () => input.loadSource(entry2.item));
|
|
66663
66693
|
if (rSource.isErr()) return { reason: "source_missing" };
|
|
66664
66694
|
const source = rSource.Ok();
|
|
66665
66695
|
if (source.length === 0) return { reason: "source_missing" };
|
|
66666
|
-
const rRelative = await
|
|
66696
|
+
const rRelative = await exception2Result98(async () => hasRelativeImports(source));
|
|
66667
66697
|
if (rRelative.isErr()) {
|
|
66668
66698
|
const err2 = rRelative.Err();
|
|
66669
66699
|
return { reason: "executor_error", error: err2 instanceof Error ? err2.message : String(err2) };
|
|
@@ -66671,7 +66701,7 @@ async function attemptVibeSsr(input) {
|
|
|
66671
66701
|
let moduleGraph;
|
|
66672
66702
|
if (rRelative.Ok()) {
|
|
66673
66703
|
const supportedBareSpecifiers = await ssrSupportedBareSpecifiers();
|
|
66674
|
-
const rGraph = await
|
|
66704
|
+
const rGraph = await exception2Result98(
|
|
66675
66705
|
async () => resolveVibeModuleGraph({ path: entry2.item.fileName, source }, makeResolveSibling(input.fsItems, input.loadSource), {
|
|
66676
66706
|
supportedBareSpecifiers
|
|
66677
66707
|
})
|
|
@@ -66685,7 +66715,7 @@ async function attemptVibeSsr(input) {
|
|
|
66685
66715
|
}
|
|
66686
66716
|
moduleGraph = rGraph.Ok();
|
|
66687
66717
|
}
|
|
66688
|
-
const rRender = await
|
|
66718
|
+
const rRender = await exception2Result98(
|
|
66689
66719
|
async () => executor.render({ source, mountParams: input.mountParams, ...moduleGraph ? { moduleGraph } : {} })
|
|
66690
66720
|
);
|
|
66691
66721
|
if (rRender.isErr()) {
|
|
@@ -67136,13 +67166,13 @@ import {
|
|
|
67136
67166
|
Result as Result56,
|
|
67137
67167
|
Option as Option12,
|
|
67138
67168
|
EventoResult as EventoResult7,
|
|
67139
|
-
exception2Result as
|
|
67169
|
+
exception2Result as exception2Result100,
|
|
67140
67170
|
stream2uint8array as stream2uint8array7
|
|
67141
67171
|
} from "@adviser/cement";
|
|
67142
67172
|
import { and as and52, eq as eq63 } from "drizzle-orm";
|
|
67143
67173
|
|
|
67144
67174
|
// ../vibes.diy/api/svc/intern/remix-source-access.ts
|
|
67145
|
-
import { exception2Result as
|
|
67175
|
+
import { exception2Result as exception2Result99, stream2uint8array as stream2uint8array6 } from "@adviser/cement";
|
|
67146
67176
|
var SEED_FILE = "seed.json";
|
|
67147
67177
|
function isRemixPrivateFile(fileName) {
|
|
67148
67178
|
return isServerOnlyVibeFile(fileName) || fileName.replace(/^(?:\.?\/)+/, "") === SEED_FILE;
|
|
@@ -67182,7 +67212,7 @@ async function reachableFiles(fileSystem, roots, strict, loadItemSource) {
|
|
|
67182
67212
|
const sources = await Promise.all(
|
|
67183
67213
|
level.map(async (mod) => {
|
|
67184
67214
|
if (mod.source !== void 0) return mod.source;
|
|
67185
|
-
const r = await
|
|
67215
|
+
const r = await exception2Result99(() => loadItemSource(mod.item));
|
|
67186
67216
|
if (r.isErr()) complete = false;
|
|
67187
67217
|
return r.isOk() ? r.Ok() : void 0;
|
|
67188
67218
|
})
|
|
@@ -67205,7 +67235,7 @@ __name(reachableFiles, "reachableFiles");
|
|
|
67205
67235
|
async function classifyBackendOnlySources(fileSystem, loadItemSource) {
|
|
67206
67236
|
const backendItem = fileSystem.find((f) => f.fileName === BACKEND_FILE);
|
|
67207
67237
|
if (backendItem === void 0) return { backendOnly: /* @__PURE__ */ new Set(), complete: true };
|
|
67208
|
-
const rBackend = await
|
|
67238
|
+
const rBackend = await exception2Result99(() => loadItemSource(backendItem));
|
|
67209
67239
|
if (rBackend.isErr()) return { backendOnly: /* @__PURE__ */ new Set(), complete: false };
|
|
67210
67240
|
const backendSource = rBackend.Ok();
|
|
67211
67241
|
if (MAYBE_RELATIVE_IMPORT2.test(backendSource) === false) return { backendOnly: /* @__PURE__ */ new Set(), complete: true };
|
|
@@ -67275,7 +67305,7 @@ async function mayReceiveAccessFnSource(vctx, args) {
|
|
|
67275
67305
|
__name(mayReceiveAccessFnSource, "mayReceiveAccessFnSource");
|
|
67276
67306
|
async function resolveAccessFnSource2(vctx, args) {
|
|
67277
67307
|
const { ownerHandle, appSlug, cid } = args;
|
|
67278
|
-
return
|
|
67308
|
+
return exception2Result100(async () => {
|
|
67279
67309
|
const tAfb = vctx.sql.tables.accessFunctionBindings;
|
|
67280
67310
|
const rows = await vctx.sql.db.select({ accessFnAssetUri: tAfb.accessFnAssetUri }).from(tAfb).where(and52(eq63(tAfb.ownerHandle, ownerHandle), eq63(tAfb.appSlug, appSlug), eq63(tAfb.accessFnCid, cid)));
|
|
67281
67311
|
if (rows.length === 0) return { cid, source: null };
|
|
@@ -67366,7 +67396,7 @@ async function buildViewerEnvForRender(vctx, args, accessFnBindings) {
|
|
|
67366
67396
|
}
|
|
67367
67397
|
__name(buildViewerEnvForRender, "buildViewerEnvForRender");
|
|
67368
67398
|
async function buildAccessFnBindingsForRender(vctx, args, prefetched) {
|
|
67369
|
-
const r = await
|
|
67399
|
+
const r = await exception2Result101(async () => prefetched ?? selectAccessFnBindings(vctx, args.ownerUserSlug, args.appSlug));
|
|
67370
67400
|
if (r.isErr()) return void 0;
|
|
67371
67401
|
const rows = r.Ok();
|
|
67372
67402
|
return rows.length > 0 ? rows : void 0;
|
|
@@ -67387,7 +67417,7 @@ async function buildAccessFnSourcesForRender(vctx, args, {
|
|
|
67387
67417
|
const cids = [...new Set(bindings.map((b) => b.accessFnCid))];
|
|
67388
67418
|
const entries = await Promise.all(
|
|
67389
67419
|
cids.map(async (cid) => {
|
|
67390
|
-
const r = await
|
|
67420
|
+
const r = await exception2Result101(() => resolve6(vctx, { ownerHandle: args.ownerUserSlug, appSlug: args.appSlug, cid }));
|
|
67391
67421
|
if (r.isErr()) {
|
|
67392
67422
|
console.warn("[render-vibe] access.js source omitted from document", { cid, error: r.Err().message });
|
|
67393
67423
|
return void 0;
|
|
@@ -67448,7 +67478,7 @@ async function renderVibe({
|
|
|
67448
67478
|
"whoami",
|
|
67449
67479
|
async () => captureViewerEnv({
|
|
67450
67480
|
ownerHandle: fs.ownerHandle,
|
|
67451
|
-
...await
|
|
67481
|
+
...await exception2Result101(
|
|
67452
67482
|
async () => resolveGrants(vctx, fs.ownerHandle, fs.appSlug, fs.ownerHandle, accessFnBindingsPromise)
|
|
67453
67483
|
).then((r) => r.isOk() && r.Ok() !== void 0 ? { grants: r.Ok() } : {})
|
|
67454
67484
|
})
|
|
@@ -67544,7 +67574,7 @@ async function renderVibe({
|
|
|
67544
67574
|
// and SSR work, so this span is NOT a serial slice of the critical path.
|
|
67545
67575
|
measureBg(
|
|
67546
67576
|
"boot",
|
|
67547
|
-
() =>
|
|
67577
|
+
() => exception2Result101(async () => {
|
|
67548
67578
|
const r = await vctx.storage.fetch(bootEntryItem.assetURI);
|
|
67549
67579
|
if (isFetchErrResult(r) || isFetchNotFoundResult(r)) return void 0;
|
|
67550
67580
|
return vctx.sthis.txt.decode(await stream2uint8array8(r.data));
|
|
@@ -67558,7 +67588,7 @@ async function renderVibe({
|
|
|
67558
67588
|
"bpsrc",
|
|
67559
67589
|
() => Promise.all(
|
|
67560
67590
|
sourceItems.map(
|
|
67561
|
-
(item) =>
|
|
67591
|
+
(item) => exception2Result101(async () => {
|
|
67562
67592
|
const r = await vctx.storage.fetch(item.assetURI);
|
|
67563
67593
|
if (isFetchErrResult(r) || isFetchNotFoundResult(r)) return { urls: [], stripe: false };
|
|
67564
67594
|
const text3 = vctx.sthis.txt.decode(await stream2uint8array8(r.data));
|
|
@@ -67573,7 +67603,7 @@ async function renderVibe({
|
|
|
67573
67603
|
// work, awaited later, so it overlaps rather than adds.
|
|
67574
67604
|
measureBg(
|
|
67575
67605
|
"twart",
|
|
67576
|
-
() =>
|
|
67606
|
+
() => exception2Result101(async () => {
|
|
67577
67607
|
const r = await vctx.storage.fetch(twItem.assetURI);
|
|
67578
67608
|
if (isFetchErrResult(r) || isFetchNotFoundResult(r)) return void 0;
|
|
67579
67609
|
return vctx.sthis.txt.decode(await stream2uint8array8(r.data));
|
|
@@ -67640,7 +67670,7 @@ async function renderVibe({
|
|
|
67640
67670
|
vctx.params.vibes.env.VIBES_DIY_PUBLIC_BASE_URL,
|
|
67641
67671
|
fs.ownerHandle,
|
|
67642
67672
|
fs.appSlug,
|
|
67643
|
-
|
|
67673
|
+
URI12.from(ctx.request.url)
|
|
67644
67674
|
);
|
|
67645
67675
|
const bootSource = await bootSourcePromise;
|
|
67646
67676
|
const sourceScan = await sourceScanPromise;
|
|
@@ -67763,7 +67793,7 @@ async function renderVibe({
|
|
|
67763
67793
|
const phaseTiming = timings?.serverTiming();
|
|
67764
67794
|
const freshMarker = freshRenderTimingEntry(Date.now());
|
|
67765
67795
|
optionalHeader["Server-Timing"] = phaseTiming !== void 0 ? `${phaseTiming}, ${freshMarker}` : freshMarker;
|
|
67766
|
-
const res = await
|
|
67796
|
+
const res = await exception2Result101(
|
|
67767
67797
|
async () => ctx.send.send(ctx, {
|
|
67768
67798
|
type: "http.Response.Body",
|
|
67769
67799
|
status: 200,
|
|
@@ -67799,7 +67829,7 @@ async function renderPendingVibe({
|
|
|
67799
67829
|
firstLook
|
|
67800
67830
|
}) {
|
|
67801
67831
|
const vctx = ctx.ctx.getOrThrow("vibesApiCtx");
|
|
67802
|
-
const rPendingSettings = await
|
|
67832
|
+
const rPendingSettings = await exception2Result101(() => loadVibeLiveSettings(vctx, ownerHandle, appSlug));
|
|
67803
67833
|
const storedPaletteSlug = rPendingSettings.isOk() ? rPendingSettings.Ok().paletteSlug : void 0;
|
|
67804
67834
|
const storedStyle = rPendingSettings.isOk() ? rPendingSettings.Ok().style : void 0;
|
|
67805
67835
|
const firstLookSettings = firstLook !== void 0 && storedPaletteSlug === void 0 && storedStyle === void 0 ? pendingFirstLookSettings(firstLook) : void 0;
|
|
@@ -67836,7 +67866,7 @@ async function renderPendingVibe({
|
|
|
67836
67866
|
vctx.params.vibes.env.VIBES_DIY_PUBLIC_BASE_URL,
|
|
67837
67867
|
ownerHandle,
|
|
67838
67868
|
appSlug,
|
|
67839
|
-
|
|
67869
|
+
URI12.from(ctx.request.url)
|
|
67840
67870
|
);
|
|
67841
67871
|
const preloadModules = vibePreloadModules(importMap);
|
|
67842
67872
|
const vsctx = {
|
|
@@ -67885,7 +67915,7 @@ async function renderPendingVibe({
|
|
|
67885
67915
|
sameSite: "lax"
|
|
67886
67916
|
});
|
|
67887
67917
|
}
|
|
67888
|
-
const res = await
|
|
67918
|
+
const res = await exception2Result101(
|
|
67889
67919
|
async () => ctx.send.send(ctx, {
|
|
67890
67920
|
type: "http.Response.Body",
|
|
67891
67921
|
status: 200,
|
|
@@ -68008,7 +68038,7 @@ function screenshotServeDecision(opts) {
|
|
|
68008
68038
|
__name(screenshotServeDecision, "screenshotServeDecision");
|
|
68009
68039
|
|
|
68010
68040
|
// ../vibes.diy/api/svc/intern/apply-seed.ts
|
|
68011
|
-
import { exception2Result as
|
|
68041
|
+
import { exception2Result as exception2Result105, stream2uint8array as stream2uint8array9 } from "@adviser/cement";
|
|
68012
68042
|
import { and as and59, desc as desc14, eq as eq70 } from "drizzle-orm";
|
|
68013
68043
|
|
|
68014
68044
|
// ../vibes.diy/api/svc/seed-parser.ts
|
|
@@ -68348,7 +68378,7 @@ function estimateGenerationBytes(outputRows, liveDocs) {
|
|
|
68348
68378
|
__name(estimateGenerationBytes, "estimateGenerationBytes");
|
|
68349
68379
|
|
|
68350
68380
|
// ../vibes.diy/api/svc/public/app-documents-broadcast.ts
|
|
68351
|
-
import { exception2Result as
|
|
68381
|
+
import { exception2Result as exception2Result102 } from "@adviser/cement";
|
|
68352
68382
|
function notifyDocChangedFanOut(vctx, p) {
|
|
68353
68383
|
if (!vctx.notifyDocChanged) return;
|
|
68354
68384
|
if (p.channels.length) {
|
|
@@ -68378,7 +68408,7 @@ async function notifyDocChangedRemoteFanOut(vctx, p) {
|
|
|
68378
68408
|
);
|
|
68379
68409
|
return;
|
|
68380
68410
|
}
|
|
68381
|
-
const r = await
|
|
68411
|
+
const r = await exception2Result102(
|
|
68382
68412
|
() => notify2({
|
|
68383
68413
|
ownerHandle: p.ownerHandle,
|
|
68384
68414
|
appSlug: p.appSlug,
|
|
@@ -68530,12 +68560,12 @@ __name(hasEffectiveViewerGrantDeltaOnDelete, "hasEffectiveViewerGrantDeltaOnDele
|
|
|
68530
68560
|
|
|
68531
68561
|
// ../vibes.diy/api/svc/intern/backend-db-callback.ts
|
|
68532
68562
|
init_types();
|
|
68533
|
-
import { exception2Result as
|
|
68563
|
+
import { exception2Result as exception2Result104 } from "@adviser/cement";
|
|
68534
68564
|
import { type as type109 } from "arktype";
|
|
68535
68565
|
import { aliasedTable, and as and58, desc as desc13, eq as eq69, gt as gt7, max as max4 } from "drizzle-orm";
|
|
68536
68566
|
|
|
68537
68567
|
// ../vibes.diy/api/svc/public/app-documents-query-filter.ts
|
|
68538
|
-
import { exception2Result as
|
|
68568
|
+
import { exception2Result as exception2Result103 } from "@adviser/cement";
|
|
68539
68569
|
import charwise2 from "charwise";
|
|
68540
68570
|
function isInInclusiveRange(value, lo, hi) {
|
|
68541
68571
|
if (typeof value === "string" && typeof lo === "string" && typeof hi === "string") {
|
|
@@ -68561,7 +68591,7 @@ function stableStringify2(v) {
|
|
|
68561
68591
|
}
|
|
68562
68592
|
__name(stableStringify2, "stableStringify");
|
|
68563
68593
|
function encodeQueryKey(v) {
|
|
68564
|
-
const r =
|
|
68594
|
+
const r = exception2Result103(() => charwise2.encode(v));
|
|
68565
68595
|
return r.isErr() ? "\uFFFFobj:" + stableStringify2(v) : r.Ok();
|
|
68566
68596
|
}
|
|
68567
68597
|
__name(encodeQueryKey, "encodeQueryKey");
|
|
@@ -70299,7 +70329,7 @@ async function afterResponse(vctx, label, task) {
|
|
|
70299
70329
|
await task();
|
|
70300
70330
|
return;
|
|
70301
70331
|
}
|
|
70302
|
-
const registered =
|
|
70332
|
+
const registered = exception2Result104(() => waitUntil(task()));
|
|
70303
70333
|
if (registered.isErr()) console.warn(`${label}: waitUntil registration failed:`, registered.Err());
|
|
70304
70334
|
}
|
|
70305
70335
|
__name(afterResponse, "afterResponse");
|
|
@@ -70392,7 +70422,7 @@ async function handleBackendPut(vctx, base, op) {
|
|
|
70392
70422
|
);
|
|
70393
70423
|
let grantUpsertErr;
|
|
70394
70424
|
const upsertAccessOutput = storeAccessOutput ? async (exec) => {
|
|
70395
|
-
const rUpsert = await
|
|
70425
|
+
const rUpsert = await exception2Result104(
|
|
70396
70426
|
() => exec.insert(storeAccessOutput.tOutputs).values({
|
|
70397
70427
|
ownerHandle,
|
|
70398
70428
|
appSlug,
|
|
@@ -70534,7 +70564,7 @@ async function handleBackendPut(vctx, base, op) {
|
|
|
70534
70564
|
return deny("grant storage failed \u2014 retry the write");
|
|
70535
70565
|
}
|
|
70536
70566
|
if (alloc.inserted === false && noopRefreshedStaleOutput && grantDelta) {
|
|
70537
|
-
const rHealFanOut = await
|
|
70567
|
+
const rHealFanOut = await exception2Result104(
|
|
70538
70568
|
() => notifyDocChangedRemoteFanOut(vctx, { ownerHandle, appSlug, dbName, docId, channels: [], grantDelta: true })
|
|
70539
70569
|
);
|
|
70540
70570
|
if (rHealFanOut.isErr()) console.error("backend put healed-grant fan-out error:", rHealFanOut.Err());
|
|
@@ -70542,7 +70572,7 @@ async function handleBackendPut(vctx, base, op) {
|
|
|
70542
70572
|
if (alloc.inserted) {
|
|
70543
70573
|
if (!feedState.inTransaction) {
|
|
70544
70574
|
const seq2 = alloc.seq;
|
|
70545
|
-
const rFeed = await
|
|
70575
|
+
const rFeed = await exception2Result104(async () => {
|
|
70546
70576
|
await bestEffortChannelChange(feedParams(seq2, vctx.sql.db));
|
|
70547
70577
|
});
|
|
70548
70578
|
if (rFeed.isErr()) {
|
|
@@ -70560,7 +70590,7 @@ async function handleBackendPut(vctx, base, op) {
|
|
|
70560
70590
|
if (hasInheritChannel(putFanoutChannels)) putFanoutChannels.push(INHERIT_CAPABILITY_CHANNEL);
|
|
70561
70591
|
const fanOut = grantDelta ? (task) => task() : (task) => afterResponse(vctx, "backend put fan-out", task);
|
|
70562
70592
|
await fanOut(async () => {
|
|
70563
|
-
const rFanOut = await
|
|
70593
|
+
const rFanOut = await exception2Result104(async () => {
|
|
70564
70594
|
await notifyDocChangedRemoteFanOut(vctx, {
|
|
70565
70595
|
ownerHandle,
|
|
70566
70596
|
appSlug,
|
|
@@ -70585,7 +70615,7 @@ async function handleBackendPut(vctx, base, op) {
|
|
|
70585
70615
|
timer.mark("memberGrants");
|
|
70586
70616
|
const seq = alloc.seq;
|
|
70587
70617
|
await afterResponse(vctx, "backend put onChange", async () => {
|
|
70588
|
-
const rOnChange = await
|
|
70618
|
+
const rOnChange = await exception2Result104(async () => {
|
|
70589
70619
|
if (base.skipOnChange === true) return;
|
|
70590
70620
|
await emitBackendOnChange(vctx, {
|
|
70591
70621
|
ownerHandle,
|
|
@@ -70659,7 +70689,7 @@ async function handleBackendDelete(vctx, base, op) {
|
|
|
70659
70689
|
exec
|
|
70660
70690
|
});
|
|
70661
70691
|
if (outRow?.output) {
|
|
70662
|
-
const rRaw =
|
|
70692
|
+
const rRaw = exception2Result104(() => JSON.parse(outRow.output));
|
|
70663
70693
|
if (rRaw.isErr()) {
|
|
70664
70694
|
console.error("backend delete stored-channels parse error:", rRaw.Err());
|
|
70665
70695
|
} else {
|
|
@@ -70708,7 +70738,7 @@ async function handleBackendDelete(vctx, base, op) {
|
|
|
70708
70738
|
throw err2;
|
|
70709
70739
|
}
|
|
70710
70740
|
if (delAlloc.inserted) {
|
|
70711
|
-
const rFeed = await
|
|
70741
|
+
const rFeed = await exception2Result104(async () => {
|
|
70712
70742
|
await bestEffortAppendDelete({
|
|
70713
70743
|
db: vctx.sql.db,
|
|
70714
70744
|
flavour: vctx.sql.flavour,
|
|
@@ -70723,7 +70753,7 @@ async function handleBackendDelete(vctx, base, op) {
|
|
|
70723
70753
|
if (rFeed.isErr()) {
|
|
70724
70754
|
console.error("backend delete post-commit sync-feed error:", rFeed.Err());
|
|
70725
70755
|
}
|
|
70726
|
-
const rFanOut = await
|
|
70756
|
+
const rFanOut = await exception2Result104(async () => {
|
|
70727
70757
|
await notifyDocChangedRemoteFanOut(vctx, {
|
|
70728
70758
|
ownerHandle,
|
|
70729
70759
|
appSlug,
|
|
@@ -70743,7 +70773,7 @@ async function handleBackendDelete(vctx, base, op) {
|
|
|
70743
70773
|
void 0,
|
|
70744
70774
|
inviterRoleFor(vctx, appSlug, ownerHandle)
|
|
70745
70775
|
);
|
|
70746
|
-
const rOnChange = await
|
|
70776
|
+
const rOnChange = await exception2Result104(async () => {
|
|
70747
70777
|
if (base.skipOnChange === true) return;
|
|
70748
70778
|
await emitBackendOnChange(vctx, {
|
|
70749
70779
|
ownerHandle,
|
|
@@ -70796,18 +70826,18 @@ async function loadSeedDocsAsWritten(vctx, assetURI) {
|
|
|
70796
70826
|
__name(loadSeedDocsAsWritten, "loadSeedDocsAsWritten");
|
|
70797
70827
|
async function fetchReleaseFileText(vctx, assetURI) {
|
|
70798
70828
|
if (assetURI === void 0) return void 0;
|
|
70799
|
-
const rFetch = await
|
|
70829
|
+
const rFetch = await exception2Result105(async () => vctx.storage.fetch(assetURI));
|
|
70800
70830
|
if (rFetch.isErr()) return void 0;
|
|
70801
70831
|
const fetched = rFetch.Ok();
|
|
70802
70832
|
if (fetched.type !== "fetch.ok") return void 0;
|
|
70803
|
-
const rText = await
|
|
70833
|
+
const rText = await exception2Result105(async () => vctx.sthis.txt.decode(await stream2uint8array9(fetched.data)));
|
|
70804
70834
|
return rText.isErr() ? void 0 : rText.Ok();
|
|
70805
70835
|
}
|
|
70806
70836
|
__name(fetchReleaseFileText, "fetchReleaseFileText");
|
|
70807
70837
|
async function fetchSeedPayload(vctx, assetURI) {
|
|
70808
70838
|
const text3 = await fetchReleaseFileText(vctx, assetURI);
|
|
70809
70839
|
if (text3 === void 0) return void 0;
|
|
70810
|
-
const rParsed =
|
|
70840
|
+
const rParsed = exception2Result105(() => JSON.parse(text3));
|
|
70811
70841
|
if (rParsed.isErr()) return void 0;
|
|
70812
70842
|
return rParsed.Ok();
|
|
70813
70843
|
}
|
|
@@ -70826,7 +70856,7 @@ async function seedOwnerModeForApp(vctx, app, assetURI) {
|
|
|
70826
70856
|
}
|
|
70827
70857
|
__name(seedOwnerModeForApp, "seedOwnerModeForApp");
|
|
70828
70858
|
async function readSeedAppliedFsId(vctx, key) {
|
|
70829
|
-
const rSettings = await
|
|
70859
|
+
const rSettings = await exception2Result105(() => readComposedSettings(vctx, key));
|
|
70830
70860
|
if (rSettings.isErr()) return void 0;
|
|
70831
70861
|
return rSettings.Ok().find(isActiveSeedApplied)?.fsId;
|
|
70832
70862
|
}
|
|
@@ -70837,7 +70867,7 @@ async function writeSeedAppliedFsId(vctx, key, fsId) {
|
|
|
70837
70867
|
}
|
|
70838
70868
|
__name(writeSeedAppliedFsId, "writeSeedAppliedFsId");
|
|
70839
70869
|
async function readSeedControl(vctx, key) {
|
|
70840
|
-
const rSettings = await
|
|
70870
|
+
const rSettings = await exception2Result105(() => readComposedSettings(vctx, key));
|
|
70841
70871
|
if (rSettings.isErr()) return { dontRun: false, suppressed: /* @__PURE__ */ new Set() };
|
|
70842
70872
|
const entry2 = rSettings.Ok().find(isActiveSeedControl);
|
|
70843
70873
|
return { dontRun: entry2?.dontRun === true, suppressed: new Set(entry2?.suppressed ?? []) };
|
|
@@ -71013,7 +71043,7 @@ async function loadScreenshotBytes(vctx, ref) {
|
|
|
71013
71043
|
__name(loadScreenshotBytes, "loadScreenshotBytes");
|
|
71014
71044
|
|
|
71015
71045
|
// ../vibes.diy/api/svc/intern/read-anonymous-seed-docs.ts
|
|
71016
|
-
import { exception2Result as
|
|
71046
|
+
import { exception2Result as exception2Result106 } from "@adviser/cement";
|
|
71017
71047
|
import { and as and60, eq as eq71 } from "drizzle-orm";
|
|
71018
71048
|
init_types();
|
|
71019
71049
|
|
|
@@ -71055,7 +71085,7 @@ function seedMeasure(timings) {
|
|
|
71055
71085
|
}
|
|
71056
71086
|
__name(seedMeasure, "seedMeasure");
|
|
71057
71087
|
async function readAnonymousSeedDocs(vctx, ownerHandle, appSlug, opts) {
|
|
71058
|
-
const r = await
|
|
71088
|
+
const r = await exception2Result106(async () => readAnonymousSeedDocsInner(vctx, { ownerHandle, appSlug, opts }));
|
|
71059
71089
|
return r.isOk() ? r.Ok() : void 0;
|
|
71060
71090
|
}
|
|
71061
71091
|
__name(readAnonymousSeedDocs, "readAnonymousSeedDocs");
|
|
@@ -71265,7 +71295,7 @@ init_swr_html_cache();
|
|
|
71265
71295
|
|
|
71266
71296
|
// ../vibes.diy/api/svc/intern/moderation-gate.ts
|
|
71267
71297
|
init_identity();
|
|
71268
|
-
import { exception2Result as
|
|
71298
|
+
import { exception2Result as exception2Result107 } from "@adviser/cement";
|
|
71269
71299
|
import { eq as eq72 } from "drizzle-orm/sql/expressions";
|
|
71270
71300
|
var MEMO_TTL_MS3 = 3e4;
|
|
71271
71301
|
var PUBLISHING_PAUSED_SWITCH = "publishing-paused";
|
|
@@ -71286,7 +71316,7 @@ async function memoized(vctx, { key, now: now3, read }) {
|
|
|
71286
71316
|
const memo = memoFor(vctx);
|
|
71287
71317
|
const hit = memo.get(key);
|
|
71288
71318
|
if (hit !== void 0 && now3 - hit.at < MEMO_TTL_MS3) return hit.value;
|
|
71289
|
-
const r = await
|
|
71319
|
+
const r = await exception2Result107(read);
|
|
71290
71320
|
if (r.isErr()) {
|
|
71291
71321
|
ensureLogger(vctx.sthis, "moderationGate").Warn().Err(r.Err()).Str("key", key).Msg("moderation gate read failed; answering open");
|
|
71292
71322
|
return false;
|
|
@@ -71382,7 +71412,7 @@ __name(appUnavailableResponse, "appUnavailableResponse");
|
|
|
71382
71412
|
init_vibe_pkg_hashed_import_map();
|
|
71383
71413
|
|
|
71384
71414
|
// ../vibes.diy/api/svc/intern/resolve-servable-asset.ts
|
|
71385
|
-
import { exception2Result as
|
|
71415
|
+
import { exception2Result as exception2Result109 } from "@adviser/cement";
|
|
71386
71416
|
import { asc as asc3, eq as eq73 } from "drizzle-orm";
|
|
71387
71417
|
var IMMUTABLE = "public, max-age=31536000, immutable";
|
|
71388
71418
|
var SHORT2 = "private, max-age=30";
|
|
@@ -71431,7 +71461,7 @@ function mediaKind(mime2) {
|
|
|
71431
71461
|
__name(mediaKind, "mediaKind");
|
|
71432
71462
|
async function resolveVideo(vctx, a, known) {
|
|
71433
71463
|
const s = vctx.sql.tables.assetSafety;
|
|
71434
|
-
const rRow = await
|
|
71464
|
+
const rRow = await exception2Result109(
|
|
71435
71465
|
() => vctx.sql.db.select({ verdict: s.verdict }).from(s).where(eq73(s.cid, a.cid)).limit(1).then((r) => r[0])
|
|
71436
71466
|
);
|
|
71437
71467
|
if (rRow.isErr()) {
|
|
@@ -71457,7 +71487,7 @@ async function resolveVideo(vctx, a, known) {
|
|
|
71457
71487
|
__name(resolveVideo, "resolveVideo");
|
|
71458
71488
|
async function earliestUpload(vctx, cid) {
|
|
71459
71489
|
const u = vctx.sql.tables.assetUploads;
|
|
71460
|
-
return
|
|
71490
|
+
return exception2Result109(
|
|
71461
71491
|
() => vctx.sql.db.select({ created: u.created, mimeType: u.mimeType, userId: u.userId }).from(u).where(eq73(u.cid, cid)).orderBy(asc3(u.created)).limit(1).then((r) => r[0])
|
|
71462
71492
|
);
|
|
71463
71493
|
}
|
|
@@ -71494,7 +71524,7 @@ async function resolveOnce(vctx, a) {
|
|
|
71494
71524
|
if (kind === "other") return { asset: pass(a, "not-image") };
|
|
71495
71525
|
if (kind === "video") return { asset: await resolveVideo(vctx, a, firstRead ? { first } : void 0) };
|
|
71496
71526
|
const s = vctx.sql.tables.assetSafety;
|
|
71497
|
-
const rRow = await
|
|
71527
|
+
const rRow = await exception2Result109(
|
|
71498
71528
|
() => vctx.sql.db.select().from(s).where(eq73(s.cid, a.cid)).limit(1).then((r) => r[0])
|
|
71499
71529
|
);
|
|
71500
71530
|
if (rRow.isErr()) {
|
|
@@ -71562,7 +71592,7 @@ function holdMsFrom(env) {
|
|
|
71562
71592
|
__name(holdMsFrom, "holdMsFrom");
|
|
71563
71593
|
async function readVerdict(vctx, cid) {
|
|
71564
71594
|
const s = vctx.sql.tables.assetSafety;
|
|
71565
|
-
const r = await
|
|
71595
|
+
const r = await exception2Result109(
|
|
71566
71596
|
() => vctx.sql.db.select({ verdict: s.verdict }).from(s).where(eq73(s.cid, cid)).limit(1).then((rows) => rows[0])
|
|
71567
71597
|
);
|
|
71568
71598
|
return r.isOk() ? r.Ok()?.verdict : void 0;
|
|
@@ -71667,7 +71697,7 @@ function bareHostRedirectTarget(baseUrl, ownerHandle, appSlug, uri) {
|
|
|
71667
71697
|
}
|
|
71668
71698
|
__name(bareHostRedirectTarget, "bareHostRedirectTarget");
|
|
71669
71699
|
function captureNpmUrl(vctx, req2) {
|
|
71670
|
-
const url =
|
|
71700
|
+
const url = URI13.from(req2.url).getParam("npmUrl");
|
|
71671
71701
|
if (url) {
|
|
71672
71702
|
return { npmURL: url, fromCookie: false, fromURL: true, fromEnv: false, fromDef: false };
|
|
71673
71703
|
}
|
|
@@ -71684,7 +71714,7 @@ function renderedRuntimeStamp(npmUrl, importMapHash) {
|
|
|
71684
71714
|
}
|
|
71685
71715
|
__name(renderedRuntimeStamp, "renderedRuntimeStamp");
|
|
71686
71716
|
function deployStampOf(npmUrl) {
|
|
71687
|
-
const r =
|
|
71717
|
+
const r = URI13.fromResult(npmUrl);
|
|
71688
71718
|
if (r.isErr()) return void 0;
|
|
71689
71719
|
const u = r.Ok();
|
|
71690
71720
|
if (u.protocol !== "http:" && u.protocol !== "https:") return void 0;
|
|
@@ -71868,7 +71898,7 @@ var servEntryPoint = {
|
|
|
71868
71898
|
return Promise.resolve(Result59.Ok(Option13.None()));
|
|
71869
71899
|
}, "validate"),
|
|
71870
71900
|
handle: /* @__PURE__ */ __name(async (ctx) => {
|
|
71871
|
-
const uri =
|
|
71901
|
+
const uri = URI13.from(ctx.request.url);
|
|
71872
71902
|
const timings = new RequestTimings();
|
|
71873
71903
|
const requestedFsId = ctx.validated.fsId;
|
|
71874
71904
|
const isRootHtmlPath = ctx.validated.path === "/" || ctx.validated.path === "/index.html";
|
|
@@ -72293,12 +72323,12 @@ import {
|
|
|
72293
72323
|
Result as Result66,
|
|
72294
72324
|
Option as Option16,
|
|
72295
72325
|
EventoResult as EventoResult11,
|
|
72296
|
-
URI as
|
|
72297
|
-
exception2Result as
|
|
72326
|
+
URI as URI24,
|
|
72327
|
+
exception2Result as exception2Result120
|
|
72298
72328
|
} from "@adviser/cement";
|
|
72299
72329
|
|
|
72300
72330
|
// ../vibes.diy/api/svc/public/cid-asset-access.ts
|
|
72301
|
-
import { URI as
|
|
72331
|
+
import { URI as URI23 } from "@adviser/cement";
|
|
72302
72332
|
import { and as and67, desc as desc16, eq as eq81 } from "drizzle-orm";
|
|
72303
72333
|
|
|
72304
72334
|
// ../vibes.diy/api/svc/public/asset-session.ts
|
|
@@ -72306,7 +72336,7 @@ import {
|
|
|
72306
72336
|
Result as Result60,
|
|
72307
72337
|
Option as Option14,
|
|
72308
72338
|
EventoResult as EventoResult10,
|
|
72309
|
-
URI as
|
|
72339
|
+
URI as URI14
|
|
72310
72340
|
} from "@adviser/cement";
|
|
72311
72341
|
var COOKIE_NAME = "vibes-asset-session";
|
|
72312
72342
|
var MAX_TTL_SEC = 3600;
|
|
@@ -72317,7 +72347,7 @@ var authSession = {
|
|
|
72317
72347
|
validate: /* @__PURE__ */ __name((ctx) => {
|
|
72318
72348
|
const { request: req2 } = ctx;
|
|
72319
72349
|
if (!req2 || req2.method !== "POST") return Promise.resolve(Result60.Ok(Option14.None()));
|
|
72320
|
-
const url =
|
|
72350
|
+
const url = URI14.from(req2.url);
|
|
72321
72351
|
if (url.pathname !== "/_auth/session") return Promise.resolve(Result60.Ok(Option14.None()));
|
|
72322
72352
|
const bearer = extractBearer(req2);
|
|
72323
72353
|
const origin = req2.headers.get("Origin") ?? req2.headers.get("origin") ?? "";
|
|
@@ -72383,7 +72413,7 @@ var authBridgePreflight = {
|
|
|
72383
72413
|
validate: /* @__PURE__ */ __name((ctx) => {
|
|
72384
72414
|
const { request: req2 } = ctx;
|
|
72385
72415
|
if (!req2 || req2.method !== "OPTIONS") return Promise.resolve(Result60.Ok(Option14.None()));
|
|
72386
|
-
const url =
|
|
72416
|
+
const url = URI14.from(req2.url);
|
|
72387
72417
|
if (url.pathname !== "/_auth/session" && url.pathname !== "/_auth/logout") {
|
|
72388
72418
|
return Promise.resolve(Result60.Ok(Option14.None()));
|
|
72389
72419
|
}
|
|
@@ -72421,7 +72451,7 @@ var authLogout = {
|
|
|
72421
72451
|
validate: /* @__PURE__ */ __name((ctx) => {
|
|
72422
72452
|
const { request: req2 } = ctx;
|
|
72423
72453
|
if (!req2 || req2.method !== "POST") return Promise.resolve(Result60.Ok(Option14.None()));
|
|
72424
|
-
const url =
|
|
72454
|
+
const url = URI14.from(req2.url);
|
|
72425
72455
|
if (url.pathname !== "/_auth/logout") return Promise.resolve(Result60.Ok(Option14.None()));
|
|
72426
72456
|
const origin = req2.headers.get("Origin") ?? req2.headers.get("origin") ?? "";
|
|
72427
72457
|
return Promise.resolve(Result60.Ok(Option14.Some({ origin })));
|
|
@@ -72476,7 +72506,7 @@ function extractAssetSessionCookie(req2) {
|
|
|
72476
72506
|
__name(extractAssetSessionCookie, "extractAssetSessionCookie");
|
|
72477
72507
|
|
|
72478
72508
|
// ../vibes.diy/api/svc/public/github-setup.ts
|
|
72479
|
-
import { exception2Result as
|
|
72509
|
+
import { exception2Result as exception2Result117, BuildURI as BuildURI15, TxtEnDecoderSingleton as TxtEnDecoderSingleton12, URI as URI21 } from "@adviser/cement";
|
|
72480
72510
|
|
|
72481
72511
|
// ../vibes.diy/api/sql/vibes-diy-api-schema-sqlite.ts
|
|
72482
72512
|
import {
|
|
@@ -76339,7 +76369,7 @@ function createVibesApiTables(flavour) {
|
|
|
76339
76369
|
__name(createVibesApiTables, "createVibesApiTables");
|
|
76340
76370
|
|
|
76341
76371
|
// ../vibes.diy/api/sql/sql-peer.ts
|
|
76342
|
-
import { Option as Option15, uint8array2stream, exception2Result as
|
|
76372
|
+
import { Option as Option15, uint8array2stream, exception2Result as exception2Result110, concatUint8, Result as Result61 } from "@adviser/cement";
|
|
76343
76373
|
import { eq as eq75 } from "drizzle-orm/sql/expressions";
|
|
76344
76374
|
function withDriverCause(err2) {
|
|
76345
76375
|
const reasons = [];
|
|
@@ -76379,7 +76409,7 @@ var SQLPeerStream = class {
|
|
|
76379
76409
|
const now3 = /* @__PURE__ */ new Date();
|
|
76380
76410
|
const created = now3.toISOString();
|
|
76381
76411
|
const { cid: assetID } = await this.owner.cider.getCID();
|
|
76382
|
-
const res = await
|
|
76412
|
+
const res = await exception2Result110(
|
|
76383
76413
|
() => this.owner.db.insert(this.owner.assets).values({
|
|
76384
76414
|
assetId: assetID,
|
|
76385
76415
|
content: concatUint8(...this.chunks),
|
|
@@ -76435,7 +76465,7 @@ var SQLPeerFetch = class {
|
|
|
76435
76465
|
return Promise.resolve(Option15.None());
|
|
76436
76466
|
}
|
|
76437
76467
|
const assetId = url.pathname.slice("Assets/".length);
|
|
76438
|
-
const rAsset = await
|
|
76468
|
+
const rAsset = await exception2Result110(
|
|
76439
76469
|
() => this.db.select().from(this.assets).where(eq75(this.assets.assetId, assetId)).limit(1).then((r) => r[0])
|
|
76440
76470
|
);
|
|
76441
76471
|
if (rAsset.isErr()) {
|
|
@@ -76497,7 +76527,7 @@ __name(cfDrizzle, "cfDrizzle");
|
|
|
76497
76527
|
import { and as and65, eq as eq79 } from "drizzle-orm/sql/expressions";
|
|
76498
76528
|
|
|
76499
76529
|
// ../vibes.diy/api/svc/intern/github-app-auth.ts
|
|
76500
|
-
import { exception2Result as
|
|
76530
|
+
import { exception2Result as exception2Result111, KeyedResolvOnce as KeyedResolvOnce6, Result as Result62, TxtEnDecoderSingleton as TxtEnDecoderSingleton9, URI as URI16 } from "@adviser/cement";
|
|
76501
76531
|
var GITHUB_API = "https://api.github.com";
|
|
76502
76532
|
var USER_AGENT = "vibes.diy-github-app";
|
|
76503
76533
|
var ACCEPT = "application/vnd.github+json";
|
|
@@ -76570,10 +76600,10 @@ function pemBody(pem, label) {
|
|
|
76570
76600
|
__name(pemBody, "pemBody");
|
|
76571
76601
|
function privateKeyPemToPkcs8(privateKeyPem) {
|
|
76572
76602
|
if (privateKeyPem.includes("-----BEGIN RSA PRIVATE KEY-----")) {
|
|
76573
|
-
return
|
|
76603
|
+
return exception2Result111(() => pkcs1ToPkcs8(b64ToBytes(pemBody(privateKeyPem, "RSA PRIVATE KEY"))));
|
|
76574
76604
|
}
|
|
76575
76605
|
if (privateKeyPem.includes("-----BEGIN PRIVATE KEY-----")) {
|
|
76576
|
-
return
|
|
76606
|
+
return exception2Result111(() => b64ToBytes(pemBody(privateKeyPem, "PRIVATE KEY")));
|
|
76577
76607
|
}
|
|
76578
76608
|
return Result62.Err("unsupported private key PEM: expected PKCS#1 (BEGIN RSA PRIVATE KEY) or PKCS#8 (BEGIN PRIVATE KEY)");
|
|
76579
76609
|
}
|
|
@@ -76587,7 +76617,7 @@ async function mintAppJwt(opts) {
|
|
|
76587
76617
|
const header = b64url(enc4.encode(JSON.stringify({ alg: "RS256", typ: "JWT" })));
|
|
76588
76618
|
const claims = b64url(enc4.encode(JSON.stringify({ iat, exp: iat + APP_JWT_TTL_SECONDS, iss: opts.appId })));
|
|
76589
76619
|
const signingInput = `${header}.${claims}`;
|
|
76590
|
-
return
|
|
76620
|
+
return exception2Result111(async () => {
|
|
76591
76621
|
const key = await crypto.subtle.importKey(
|
|
76592
76622
|
"pkcs8",
|
|
76593
76623
|
// Copy into a fresh ArrayBuffer: the slice may be a view into a larger buffer.
|
|
@@ -76655,7 +76685,7 @@ async function getInstallationToken(opts) {
|
|
|
76655
76685
|
...opts.repositories === void 0 ? {} : { repositories: [...opts.repositories].sort() },
|
|
76656
76686
|
...opts.permissions === void 0 ? {} : { permissions: Object.fromEntries(sortedPermissionEntries(opts.permissions)) }
|
|
76657
76687
|
};
|
|
76658
|
-
const rRes = await
|
|
76688
|
+
const rRes = await exception2Result111(
|
|
76659
76689
|
() => fetchImpl(`${GITHUB_API}/app/installations/${encodeURIComponent(opts.installationId)}/access_tokens`, {
|
|
76660
76690
|
method: "POST",
|
|
76661
76691
|
headers: {
|
|
@@ -76672,14 +76702,14 @@ async function getInstallationToken(opts) {
|
|
|
76672
76702
|
}
|
|
76673
76703
|
const res = rRes.Ok();
|
|
76674
76704
|
if (res.ok === false) {
|
|
76675
|
-
const rDetail = await
|
|
76705
|
+
const rDetail = await exception2Result111(() => res.json());
|
|
76676
76706
|
const detail = rDetail.isOk() ? rDetail.Ok() : {};
|
|
76677
76707
|
if (res.status === 422 && opts.permissions !== void 0 && /not granted/i.test(detail.message ?? "")) {
|
|
76678
76708
|
return Result62.Err(`${PERMISSIONS_NOT_GRANTED}: ${res.status} ${detail.message ?? ""}`.trim());
|
|
76679
76709
|
}
|
|
76680
76710
|
return Result62.Err(`github installation token failed: ${res.status} ${detail.message ?? ""}`.trim());
|
|
76681
76711
|
}
|
|
76682
|
-
const rBody = await
|
|
76712
|
+
const rBody = await exception2Result111(() => res.json());
|
|
76683
76713
|
if (rBody.isErr()) {
|
|
76684
76714
|
return Result62.Err(`github installation token threw: ${rBody.Err().message}`);
|
|
76685
76715
|
}
|
|
@@ -76695,7 +76725,7 @@ __name(getInstallationToken, "getInstallationToken");
|
|
|
76695
76725
|
var appHtmlUrlOnce = new KeyedResolvOnce6({ resetAfter: 60 * 60 * 1e3 });
|
|
76696
76726
|
|
|
76697
76727
|
// ../vibes.diy/api/svc/public/github-webhook.ts
|
|
76698
|
-
import { exception2Result as
|
|
76728
|
+
import { exception2Result as exception2Result112, TxtEnDecoderSingleton as TxtEnDecoderSingleton10 } from "@adviser/cement";
|
|
76699
76729
|
import { and as and62, asc as asc4, eq as eq76, inArray as inArray20 } from "drizzle-orm/sql/expressions";
|
|
76700
76730
|
|
|
76701
76731
|
// ../vibes.diy/api/svc/intern/backend-do-addr.ts
|
|
@@ -76755,11 +76785,11 @@ async function binderHandlesFor(sql38, userIds) {
|
|
|
76755
76785
|
__name(binderHandlesFor, "binderHandlesFor");
|
|
76756
76786
|
|
|
76757
76787
|
// ../vibes.diy/api/svc/public/connections-oauth.ts
|
|
76758
|
-
import { BuildURI as BuildURI14, exception2Result as
|
|
76788
|
+
import { BuildURI as BuildURI14, exception2Result as exception2Result116, TxtEnDecoderSingleton as TxtEnDecoderSingleton11, URI as URI19 } from "@adviser/cement";
|
|
76759
76789
|
import { and as and64, eq as eq78 } from "drizzle-orm/sql/expressions";
|
|
76760
76790
|
|
|
76761
76791
|
// ../vibes.diy/api/svc/intern/connections-host-actions.ts
|
|
76762
|
-
import { exception2Result as
|
|
76792
|
+
import { exception2Result as exception2Result113 } from "@adviser/cement";
|
|
76763
76793
|
var LINKEDIN_IMAGE_UPLOAD_PATH = "/_vibes/image-upload";
|
|
76764
76794
|
var MAX_IMAGE_BYTES = 8 * 1024 * 1024;
|
|
76765
76795
|
var ACCEPTED_IMAGE_TYPES = /* @__PURE__ */ new Set(["image/jpeg", "image/png", "image/gif"]);
|
|
@@ -76809,7 +76839,7 @@ async function fetchPublicImage(fetchImpl, first) {
|
|
|
76809
76839
|
let img;
|
|
76810
76840
|
for (let hop = 0; hop <= MAX_IMAGE_REDIRECTS; hop++) {
|
|
76811
76841
|
const target2 = url;
|
|
76812
|
-
const rImg = await
|
|
76842
|
+
const rImg = await exception2Result113(
|
|
76813
76843
|
() => fetchImpl(target2.toString(), { headers: { accept: "image/*" }, redirect: "manual", signal })
|
|
76814
76844
|
);
|
|
76815
76845
|
if (rImg.isErr()) return refused2(422, "could not fetch imageUrl");
|
|
@@ -76834,13 +76864,13 @@ async function fetchPublicImage(fetchImpl, first) {
|
|
|
76834
76864
|
const chunks2 = [];
|
|
76835
76865
|
let total = 0;
|
|
76836
76866
|
for (; ; ) {
|
|
76837
|
-
const rChunk = await
|
|
76867
|
+
const rChunk = await exception2Result113(() => reader.read());
|
|
76838
76868
|
if (rChunk.isErr()) return refused2(422, "could not read imageUrl");
|
|
76839
76869
|
const chunk = rChunk.Ok();
|
|
76840
76870
|
if (chunk.done) break;
|
|
76841
76871
|
total += chunk.value.byteLength;
|
|
76842
76872
|
if (total > MAX_IMAGE_BYTES) {
|
|
76843
|
-
await
|
|
76873
|
+
await exception2Result113(() => reader.cancel());
|
|
76844
76874
|
return refused2(413, "image is larger than 8 MB");
|
|
76845
76875
|
}
|
|
76846
76876
|
chunks2.push(chunk.value);
|
|
@@ -76866,7 +76896,7 @@ function resolveLocation(location2, base) {
|
|
|
76866
76896
|
__name(resolveLocation, "resolveLocation");
|
|
76867
76897
|
var PERSON_URN = /^urn:li:person:[A-Za-z0-9_-]+$/;
|
|
76868
76898
|
var linkedinImageUpload = /* @__PURE__ */ __name(async (input) => {
|
|
76869
|
-
const rParsed =
|
|
76899
|
+
const rParsed = exception2Result113(() => JSON.parse(input.body ?? ""));
|
|
76870
76900
|
const parsed = rParsed.isOk() ? rParsed.Ok() : void 0;
|
|
76871
76901
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
76872
76902
|
return answer(400, { error: "send a JSON body: { imageUrl, owner }" });
|
|
@@ -76888,7 +76918,7 @@ var linkedinImageUpload = /* @__PURE__ */ __name(async (input) => {
|
|
|
76888
76918
|
"x-restli-protocol-version": "2.0.0"
|
|
76889
76919
|
};
|
|
76890
76920
|
if (typeof version === "string" && version !== "") initHeaders["linkedin-version"] = version;
|
|
76891
|
-
const rInit = await
|
|
76921
|
+
const rInit = await exception2Result113(
|
|
76892
76922
|
() => input.fetchImpl(`${input.provider.apiOrigin}/rest/images?action=initializeUpload`, {
|
|
76893
76923
|
method: "POST",
|
|
76894
76924
|
headers: initHeaders,
|
|
@@ -76901,18 +76931,18 @@ var linkedinImageUpload = /* @__PURE__ */ __name(async (input) => {
|
|
|
76901
76931
|
);
|
|
76902
76932
|
if (rInit.isErr()) return { kind: "upstream_error" };
|
|
76903
76933
|
const init = rInit.Ok();
|
|
76904
|
-
const rInitText = await
|
|
76934
|
+
const rInitText = await exception2Result113(() => init.text());
|
|
76905
76935
|
if (rInitText.isErr()) return { kind: "upstream_error" };
|
|
76906
76936
|
const initText = rInitText.Ok();
|
|
76907
76937
|
if (init.status >= 300 && init.status < 400) return answer(502, { error: "linkedin redirected the upload request" });
|
|
76908
76938
|
if (input.provider.isCredentialRefusal(init.status, initText)) return { kind: "credential_refused" };
|
|
76909
76939
|
if (!init.ok) return { kind: "response", status: init.status, body: initText };
|
|
76910
|
-
const rInitJson =
|
|
76940
|
+
const rInitJson = exception2Result113(() => JSON.parse(initText));
|
|
76911
76941
|
const value = rInitJson.isOk() ? rInitJson.Ok()?.value : void 0;
|
|
76912
76942
|
const uploadUrl = linkedinUploadUrl(value?.uploadUrl);
|
|
76913
76943
|
const image = typeof value?.image === "string" && value.image.startsWith("urn:li:image:") ? value.image : "";
|
|
76914
76944
|
if (uploadUrl === void 0 || image === "") return answer(502, { error: "linkedin did not hand back an upload" });
|
|
76915
|
-
const rPut = await
|
|
76945
|
+
const rPut = await exception2Result113(
|
|
76916
76946
|
() => input.fetchImpl(uploadUrl.toString(), {
|
|
76917
76947
|
method: "PUT",
|
|
76918
76948
|
headers: {
|
|
@@ -76926,7 +76956,7 @@ var linkedinImageUpload = /* @__PURE__ */ __name(async (input) => {
|
|
|
76926
76956
|
);
|
|
76927
76957
|
if (rPut.isErr()) return { kind: "upstream_error" };
|
|
76928
76958
|
const put = rPut.Ok();
|
|
76929
|
-
const rPutText = await
|
|
76959
|
+
const rPutText = await exception2Result113(() => put.text());
|
|
76930
76960
|
const putText = rPutText.isOk() ? rPutText.Ok() : "";
|
|
76931
76961
|
if (put.status >= 300 && put.status < 400) return answer(502, { error: "linkedin redirected the upload" });
|
|
76932
76962
|
if (input.provider.isCredentialRefusal(put.status, putText)) return { kind: "credential_refused" };
|
|
@@ -77924,16 +77954,16 @@ async function markGrantDead(sql38, input) {
|
|
|
77924
77954
|
__name(markGrantDead, "markGrantDead");
|
|
77925
77955
|
|
|
77926
77956
|
// ../vibes.diy/api/svc/public/connections-callback.ts
|
|
77927
|
-
import { BuildURI as BuildURI13, exception2Result as
|
|
77957
|
+
import { BuildURI as BuildURI13, exception2Result as exception2Result115, URI as URI18 } from "@adviser/cement";
|
|
77928
77958
|
|
|
77929
77959
|
// ../vibes.diy/api/svc/public/github-templates.ts
|
|
77930
77960
|
import { BuildURI as BuildURI12, KeyedResolvOnce as KeyedResolvOnce7, loadAsset as loadAsset2 } from "@adviser/cement";
|
|
77931
77961
|
|
|
77932
77962
|
// ../vibes.diy/api/svc/intern/prompt-asset-fetch.ts
|
|
77933
|
-
import { BuildURI as BuildURI11, URI as
|
|
77963
|
+
import { BuildURI as BuildURI11, URI as URI17 } from "@adviser/cement";
|
|
77934
77964
|
function createPromptAssetFetch(deps) {
|
|
77935
77965
|
return async (url, _init) => {
|
|
77936
|
-
const uri =
|
|
77966
|
+
const uri = URI17.from(url);
|
|
77937
77967
|
if (uri.protocol === "file:") {
|
|
77938
77968
|
return fetch(url, _init);
|
|
77939
77969
|
}
|
|
@@ -77962,7 +77992,7 @@ var ACCOUNT_SWITCH_PAGES = Object.freeze({
|
|
|
77962
77992
|
});
|
|
77963
77993
|
|
|
77964
77994
|
// ../vibes.diy/api/svc/intern/credential-fetch.ts
|
|
77965
|
-
import { exception2Result as
|
|
77995
|
+
import { exception2Result as exception2Result114 } from "@adviser/cement";
|
|
77966
77996
|
var REDIRECT_STATUSES = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
|
|
77967
77997
|
var MAX_CREDENTIAL_REDIRECTS = 3;
|
|
77968
77998
|
function refusedRedirect() {
|
|
@@ -77973,7 +78003,7 @@ function refusedRedirect() {
|
|
|
77973
78003
|
}
|
|
77974
78004
|
__name(refusedRedirect, "refusedRedirect");
|
|
77975
78005
|
async function fetchKeepingCredentialHome(fetchImpl, url, init = {}) {
|
|
77976
|
-
const rFirst =
|
|
78006
|
+
const rFirst = exception2Result114(() => new URL(url.toString()));
|
|
77977
78007
|
if (rFirst.isErr() || rFirst.Ok().protocol !== "https:") return refusedRedirect();
|
|
77978
78008
|
let target2 = rFirst.Ok();
|
|
77979
78009
|
const origin = target2.origin;
|
|
@@ -77989,9 +78019,9 @@ async function fetchKeepingCredentialHome(fetchImpl, url, init = {}) {
|
|
|
77989
78019
|
});
|
|
77990
78020
|
const location2 = REDIRECT_STATUSES.has(answer14.status) ? answer14.headers.get("location") : null;
|
|
77991
78021
|
if (location2 === null) return answer14;
|
|
77992
|
-
await
|
|
78022
|
+
await exception2Result114(() => answer14.body?.cancel());
|
|
77993
78023
|
if (hops >= MAX_CREDENTIAL_REDIRECTS) return refusedRedirect();
|
|
77994
|
-
const rNext =
|
|
78024
|
+
const rNext = exception2Result114(() => new URL(location2, target2));
|
|
77995
78025
|
if (rNext.isErr() || rNext.Ok().protocol !== "https:") return refusedRedirect();
|
|
77996
78026
|
const next = rNext.Ok();
|
|
77997
78027
|
if (next.origin === origin) {
|
|
@@ -78016,7 +78046,7 @@ function publicRouteUrl(env, pathname) {
|
|
|
78016
78046
|
__name(publicRouteUrl, "publicRouteUrl");
|
|
78017
78047
|
async function githubIdentity(input) {
|
|
78018
78048
|
const none = { accountLabel: "", accountId: "" };
|
|
78019
|
-
const rRes = await
|
|
78049
|
+
const rRes = await exception2Result115(
|
|
78020
78050
|
() => fetchKeepingCredentialHome(input.fetchImpl, `${input.provider.apiOrigin}/user`, {
|
|
78021
78051
|
method: "GET",
|
|
78022
78052
|
headers: {
|
|
@@ -78029,7 +78059,7 @@ async function githubIdentity(input) {
|
|
|
78029
78059
|
if (rRes.isErr()) return none;
|
|
78030
78060
|
const res = rRes.Ok();
|
|
78031
78061
|
if (res.ok === false) return none;
|
|
78032
|
-
const rBody = await
|
|
78062
|
+
const rBody = await exception2Result115(() => res.json());
|
|
78033
78063
|
if (rBody.isErr()) return none;
|
|
78034
78064
|
const body = rBody.Ok();
|
|
78035
78065
|
return {
|
|
@@ -78054,7 +78084,7 @@ function metaAdapter(cfg) {
|
|
|
78054
78084
|
redirect_uri: input.redirectUri,
|
|
78055
78085
|
code: input.code
|
|
78056
78086
|
});
|
|
78057
|
-
const rShort = await
|
|
78087
|
+
const rShort = await exception2Result115(
|
|
78058
78088
|
() => fetchKeepingCredentialHome(input.fetchImpl, input.provider.oauth.tokenUrl, {
|
|
78059
78089
|
method: "POST",
|
|
78060
78090
|
headers: { accept: "application/json", "content-type": "application/x-www-form-urlencoded" },
|
|
@@ -78070,7 +78100,7 @@ function metaAdapter(cfg) {
|
|
|
78070
78100
|
console.error(`[connections-callback] ${cfg.label} token request refused with HTTP ${shortRes.status}`);
|
|
78071
78101
|
return void 0;
|
|
78072
78102
|
}
|
|
78073
|
-
const rShortBody = await
|
|
78103
|
+
const rShortBody = await exception2Result115(() => shortRes.json());
|
|
78074
78104
|
if (rShortBody.isErr()) {
|
|
78075
78105
|
console.error(`[connections-callback] ${cfg.label} token response was not JSON:`, rShortBody.Err().message);
|
|
78076
78106
|
return void 0;
|
|
@@ -78081,7 +78111,7 @@ function metaAdapter(cfg) {
|
|
|
78081
78111
|
return void 0;
|
|
78082
78112
|
}
|
|
78083
78113
|
const exchangeUrl = BuildURI13.from(longLived.url).setParam("grant_type", longLived.grantType).setParam("client_secret", input.clientSecret).setParam("access_token", shortToken).toString();
|
|
78084
|
-
const rLong = await
|
|
78114
|
+
const rLong = await exception2Result115(
|
|
78085
78115
|
() => fetchKeepingCredentialHome(input.fetchImpl, exchangeUrl, {
|
|
78086
78116
|
method: "GET",
|
|
78087
78117
|
headers: { accept: "application/json" },
|
|
@@ -78097,7 +78127,7 @@ function metaAdapter(cfg) {
|
|
|
78097
78127
|
console.error(`[connections-callback] ${cfg.label} long-lived exchange refused with HTTP ${longRes.status}`);
|
|
78098
78128
|
return void 0;
|
|
78099
78129
|
}
|
|
78100
|
-
const rLongBody = await
|
|
78130
|
+
const rLongBody = await exception2Result115(() => longRes.json());
|
|
78101
78131
|
if (rLongBody.isErr()) {
|
|
78102
78132
|
console.error(`[connections-callback] ${cfg.label} long-lived response was not JSON:`, rLongBody.Err().message);
|
|
78103
78133
|
return void 0;
|
|
@@ -78119,7 +78149,7 @@ function metaAdapter(cfg) {
|
|
|
78119
78149
|
const identity = /* @__PURE__ */ __name(async (input) => {
|
|
78120
78150
|
const none = { accountLabel: "", accountId: "" };
|
|
78121
78151
|
const url = BuildURI13.from(`${input.provider.apiOrigin}${cfg.identityPath}`).setParam("fields", cfg.identityFields).toString();
|
|
78122
|
-
const rRes = await
|
|
78152
|
+
const rRes = await exception2Result115(
|
|
78123
78153
|
() => fetchKeepingCredentialHome(input.fetchImpl, url, {
|
|
78124
78154
|
method: "GET",
|
|
78125
78155
|
headers: { authorization: `Bearer ${input.accessToken}`, accept: input.provider.defaultAccept }
|
|
@@ -78128,7 +78158,7 @@ function metaAdapter(cfg) {
|
|
|
78128
78158
|
if (rRes.isErr()) return none;
|
|
78129
78159
|
const res = rRes.Ok();
|
|
78130
78160
|
if (res.ok === false) return none;
|
|
78131
|
-
const rBody = await
|
|
78161
|
+
const rBody = await exception2Result115(() => res.json());
|
|
78132
78162
|
if (rBody.isErr()) return none;
|
|
78133
78163
|
const body = rBody.Ok();
|
|
78134
78164
|
return {
|
|
@@ -78160,7 +78190,7 @@ var tiktokAdapter = Object.freeze({
|
|
|
78160
78190
|
grant_type: "authorization_code",
|
|
78161
78191
|
redirect_uri: input.redirectUri
|
|
78162
78192
|
});
|
|
78163
|
-
const rRes = await
|
|
78193
|
+
const rRes = await exception2Result115(
|
|
78164
78194
|
() => fetchKeepingCredentialHome(input.fetchImpl, input.provider.oauth.tokenUrl, {
|
|
78165
78195
|
method: "POST",
|
|
78166
78196
|
headers: { accept: "application/json", "content-type": "application/x-www-form-urlencoded" },
|
|
@@ -78172,7 +78202,7 @@ var tiktokAdapter = Object.freeze({
|
|
|
78172
78202
|
return void 0;
|
|
78173
78203
|
}
|
|
78174
78204
|
const res = rRes.Ok();
|
|
78175
|
-
const rBody = await
|
|
78205
|
+
const rBody = await exception2Result115(
|
|
78176
78206
|
() => res.json()
|
|
78177
78207
|
);
|
|
78178
78208
|
if (rBody.isErr()) {
|
|
@@ -78210,7 +78240,7 @@ var tiktokAdapter = Object.freeze({
|
|
|
78210
78240
|
identity: /* @__PURE__ */ __name(async (input) => {
|
|
78211
78241
|
const none = { accountLabel: "", accountId: "" };
|
|
78212
78242
|
const url = BuildURI13.from(`${input.provider.apiOrigin}/v2/user/info/`).setParam("fields", "open_id,display_name").toString();
|
|
78213
|
-
const rRes = await
|
|
78243
|
+
const rRes = await exception2Result115(
|
|
78214
78244
|
() => fetchKeepingCredentialHome(input.fetchImpl, url, {
|
|
78215
78245
|
method: "GET",
|
|
78216
78246
|
headers: { authorization: `Bearer ${input.accessToken}`, accept: input.provider.defaultAccept }
|
|
@@ -78218,7 +78248,7 @@ var tiktokAdapter = Object.freeze({
|
|
|
78218
78248
|
);
|
|
78219
78249
|
if (rRes.isErr()) return none;
|
|
78220
78250
|
const res = rRes.Ok();
|
|
78221
|
-
const rBody = await
|
|
78251
|
+
const rBody = await exception2Result115(
|
|
78222
78252
|
() => res.json()
|
|
78223
78253
|
);
|
|
78224
78254
|
if (rBody.isErr()) return none;
|
|
@@ -78244,7 +78274,7 @@ var linkedinAdapter = Object.freeze({
|
|
|
78244
78274
|
client_secret: input.clientSecret,
|
|
78245
78275
|
redirect_uri: input.redirectUri
|
|
78246
78276
|
});
|
|
78247
|
-
const rRes = await
|
|
78277
|
+
const rRes = await exception2Result115(
|
|
78248
78278
|
() => fetchKeepingCredentialHome(input.fetchImpl, input.provider.oauth.tokenUrl, {
|
|
78249
78279
|
method: "POST",
|
|
78250
78280
|
headers: { accept: "application/json", "content-type": "application/x-www-form-urlencoded" },
|
|
@@ -78260,7 +78290,7 @@ var linkedinAdapter = Object.freeze({
|
|
|
78260
78290
|
console.error(`[connections-callback] linkedin token request refused with HTTP ${res.status}`);
|
|
78261
78291
|
return void 0;
|
|
78262
78292
|
}
|
|
78263
|
-
const rBody = await
|
|
78293
|
+
const rBody = await exception2Result115(() => res.json());
|
|
78264
78294
|
if (rBody.isErr()) {
|
|
78265
78295
|
console.error("[connections-callback] linkedin token response was not JSON:", rBody.Err().message);
|
|
78266
78296
|
return void 0;
|
|
@@ -78290,7 +78320,7 @@ var linkedinAdapter = Object.freeze({
|
|
|
78290
78320
|
*/
|
|
78291
78321
|
identity: /* @__PURE__ */ __name(async (input) => {
|
|
78292
78322
|
const none = { accountLabel: "", accountId: "" };
|
|
78293
|
-
const rRes = await
|
|
78323
|
+
const rRes = await exception2Result115(
|
|
78294
78324
|
() => fetchKeepingCredentialHome(input.fetchImpl, `${input.provider.apiOrigin}/v2/userinfo`, {
|
|
78295
78325
|
method: "GET",
|
|
78296
78326
|
headers: { authorization: `Bearer ${input.accessToken}`, accept: input.provider.defaultAccept }
|
|
@@ -78299,7 +78329,7 @@ var linkedinAdapter = Object.freeze({
|
|
|
78299
78329
|
if (rRes.isErr()) return none;
|
|
78300
78330
|
const res = rRes.Ok();
|
|
78301
78331
|
if (res.ok === false) return none;
|
|
78302
|
-
const rBody = await
|
|
78332
|
+
const rBody = await exception2Result115(() => res.json());
|
|
78303
78333
|
if (rBody.isErr()) return none;
|
|
78304
78334
|
const body = rBody.Ok();
|
|
78305
78335
|
return {
|
|
@@ -78318,7 +78348,7 @@ var googleAdapter = Object.freeze({
|
|
|
78318
78348
|
client_secret: input.clientSecret,
|
|
78319
78349
|
redirect_uri: input.redirectUri
|
|
78320
78350
|
});
|
|
78321
|
-
const rRes = await
|
|
78351
|
+
const rRes = await exception2Result115(
|
|
78322
78352
|
() => fetchKeepingCredentialHome(input.fetchImpl, input.provider.oauth.tokenUrl, {
|
|
78323
78353
|
method: "POST",
|
|
78324
78354
|
headers: { accept: "application/json", "content-type": "application/x-www-form-urlencoded" },
|
|
@@ -78334,7 +78364,7 @@ var googleAdapter = Object.freeze({
|
|
|
78334
78364
|
console.error(`[connections-callback] google token request refused with HTTP ${res.status}`);
|
|
78335
78365
|
return void 0;
|
|
78336
78366
|
}
|
|
78337
|
-
const rBody = await
|
|
78367
|
+
const rBody = await exception2Result115(
|
|
78338
78368
|
() => res.json()
|
|
78339
78369
|
);
|
|
78340
78370
|
if (rBody.isErr()) {
|
|
@@ -78369,7 +78399,7 @@ var googleAdapter = Object.freeze({
|
|
|
78369
78399
|
*/
|
|
78370
78400
|
identity: /* @__PURE__ */ __name(async (input) => {
|
|
78371
78401
|
const none = { accountLabel: "", accountId: "" };
|
|
78372
|
-
const rRes = await
|
|
78402
|
+
const rRes = await exception2Result115(
|
|
78373
78403
|
() => fetchKeepingCredentialHome(
|
|
78374
78404
|
input.fetchImpl,
|
|
78375
78405
|
`${input.provider.apiOrigin}/drive/v3/about?fields=user(displayName,permissionId)`,
|
|
@@ -78382,7 +78412,7 @@ var googleAdapter = Object.freeze({
|
|
|
78382
78412
|
if (rRes.isErr()) return none;
|
|
78383
78413
|
const res = rRes.Ok();
|
|
78384
78414
|
if (res.ok === false) return none;
|
|
78385
|
-
const rBody = await
|
|
78415
|
+
const rBody = await exception2Result115(() => res.json());
|
|
78386
78416
|
if (rBody.isErr()) return none;
|
|
78387
78417
|
const user = rBody.Ok().user;
|
|
78388
78418
|
return {
|
|
@@ -78446,14 +78476,14 @@ __name(providerIsDisabled, "providerIsDisabled");
|
|
|
78446
78476
|
var CONNECT_APPROVAL_TTL_MS = 2 * 60 * 1e3;
|
|
78447
78477
|
|
|
78448
78478
|
// ../vibes.diy/api/svc/public/flow-session.ts
|
|
78449
|
-
import { URI as
|
|
78479
|
+
import { URI as URI20 } from "@adviser/cement";
|
|
78450
78480
|
|
|
78451
78481
|
// ../vibes.diy/api/svc/public/github-setup.ts
|
|
78452
78482
|
function sessionCookieTokenFrom(request) {
|
|
78453
78483
|
const cookie = request.headers.get("cookie") ?? request.headers.get("Cookie") ?? "";
|
|
78454
78484
|
const match = /(?:^|;\s*)__session=([^;]+)/.exec(cookie);
|
|
78455
78485
|
if (match === null) return void 0;
|
|
78456
|
-
const r =
|
|
78486
|
+
const r = exception2Result117(() => decodeURIComponent(match[1]));
|
|
78457
78487
|
return r.isErr() ? void 0 : r.Ok();
|
|
78458
78488
|
}
|
|
78459
78489
|
__name(sessionCookieTokenFrom, "sessionCookieTokenFrom");
|
|
@@ -78461,7 +78491,7 @@ var GITHUB_SETUP_OAUTH_STATE_TTL_MS = 10 * 60 * 1e3;
|
|
|
78461
78491
|
var GITHUB_OAUTH_TOKEN_URL = "https://github.com/login/oauth/access_token";
|
|
78462
78492
|
var USER_AGENT2 = "vibes.diy-github-app";
|
|
78463
78493
|
async function exchangeOAuthCode(input) {
|
|
78464
|
-
const rRes = await
|
|
78494
|
+
const rRes = await exception2Result117(
|
|
78465
78495
|
() => fetchKeepingCredentialHome(input.fetchImpl, GITHUB_OAUTH_TOKEN_URL, {
|
|
78466
78496
|
method: "POST",
|
|
78467
78497
|
headers: { accept: "application/json", "content-type": "application/json", "user-agent": USER_AGENT2 },
|
|
@@ -78477,7 +78507,7 @@ async function exchangeOAuthCode(input) {
|
|
|
78477
78507
|
console.error(`[github-setup] oauth token request refused with HTTP ${res.status}`);
|
|
78478
78508
|
return void 0;
|
|
78479
78509
|
}
|
|
78480
|
-
const rBody = await
|
|
78510
|
+
const rBody = await exception2Result117(
|
|
78481
78511
|
() => res.json()
|
|
78482
78512
|
);
|
|
78483
78513
|
if (rBody.isErr()) {
|
|
@@ -78505,7 +78535,7 @@ var GITHUB_RETURN_COOKIE_FLAGS = `Path=${GITHUB_SETUP_PATH}; HttpOnly; Secure; S
|
|
|
78505
78535
|
var GITHUB_REPO_PICK_STATE_TTL_MS = 10 * 60 * 1e3;
|
|
78506
78536
|
|
|
78507
78537
|
// ../vibes.diy/api/svc/public/asset-request-origin.ts
|
|
78508
|
-
import { exception2Result as
|
|
78538
|
+
import { exception2Result as exception2Result118, URI as URI22 } from "@adviser/cement";
|
|
78509
78539
|
function assetRequestOriginAllowed(vctx, request) {
|
|
78510
78540
|
if (request.origin === void 0) return true;
|
|
78511
78541
|
const origin = httpOrigin(request.origin);
|
|
@@ -78517,8 +78547,8 @@ function assetRequestOriginAllowed(vctx, request) {
|
|
|
78517
78547
|
}
|
|
78518
78548
|
__name(assetRequestOriginAllowed, "assetRequestOriginAllowed");
|
|
78519
78549
|
function httpOrigin(value) {
|
|
78520
|
-
const parsed =
|
|
78521
|
-
const uri =
|
|
78550
|
+
const parsed = exception2Result118(() => {
|
|
78551
|
+
const uri = URI22.from(value);
|
|
78522
78552
|
if (uri.protocol !== "https:" && uri.protocol !== "http:") return void 0;
|
|
78523
78553
|
const defaultPort = uri.protocol === "https:" ? "443" : "80";
|
|
78524
78554
|
const port = uri.port === "" || uri.port === defaultPort ? "" : `:${uri.port}`;
|
|
@@ -78529,7 +78559,7 @@ function httpOrigin(value) {
|
|
|
78529
78559
|
__name(httpOrigin, "httpOrigin");
|
|
78530
78560
|
|
|
78531
78561
|
// ../vibes.diy/api/svc/public/handle-settings.ts
|
|
78532
|
-
import { Result as Result65, exception2Result as
|
|
78562
|
+
import { Result as Result65, exception2Result as exception2Result119 } from "@adviser/cement";
|
|
78533
78563
|
import { and as and66, eq as eq80 } from "drizzle-orm";
|
|
78534
78564
|
function parseEntries3(settings) {
|
|
78535
78565
|
const { filtered } = parseArrayWarning(settings ?? [], ActiveEntry);
|
|
@@ -78555,7 +78585,7 @@ async function writeHandleAvatar(vctx, args) {
|
|
|
78555
78585
|
const t = vctx.sql.tables.handleSettings;
|
|
78556
78586
|
const now3 = (/* @__PURE__ */ new Date()).toISOString();
|
|
78557
78587
|
const newVersion = { cid: args.getURL, mime: args.mime, created: now3 };
|
|
78558
|
-
const rUpsert = await
|
|
78588
|
+
const rUpsert = await exception2Result119(async () => {
|
|
78559
78589
|
const existing = await vctx.sql.db.select({ settings: t.settings }).from(t).where(eq80(t.handle, args.handle)).limit(1).then((r) => r[0]);
|
|
78560
78590
|
const entries = existing ? parseEntries3(existing.settings) : [];
|
|
78561
78591
|
const idx = entries.findIndex(isActiveAvatar);
|
|
@@ -78578,7 +78608,7 @@ __name(writeHandleAvatar, "writeHandleAvatar");
|
|
|
78578
78608
|
async function seedDefaultHandleAvatar(vctx, args) {
|
|
78579
78609
|
if (args.avatarCid === void 0 || args.avatarCid === "" || args.defaultHandle === void 0 || args.defaultHandle === "")
|
|
78580
78610
|
return;
|
|
78581
|
-
await
|
|
78611
|
+
await exception2Result119(async () => {
|
|
78582
78612
|
const hb = vctx.sql.tables.handleBinding;
|
|
78583
78613
|
const owns = await vctx.sql.db.select({ handle: hb.handle }).from(hb).where(and66(eq80(hb.handle, args.defaultHandle), eq80(hb.userId, args.userId))).limit(1).then((r) => r[0]);
|
|
78584
78614
|
if (!owns) return;
|
|
@@ -78604,7 +78634,7 @@ __name(migrateLegacyAvatar, "migrateLegacyAvatar");
|
|
|
78604
78634
|
|
|
78605
78635
|
// ../vibes.diy/api/svc/public/cid-asset-access.ts
|
|
78606
78636
|
async function resolveCidAssetAccess(vctx, request) {
|
|
78607
|
-
const params =
|
|
78637
|
+
const params = URI23.from(request.url);
|
|
78608
78638
|
const requested = params.getParam("url");
|
|
78609
78639
|
if (requested === void 0) return void 0;
|
|
78610
78640
|
const cid = contentId(requested);
|
|
@@ -78721,7 +78751,7 @@ var cidAsset = {
|
|
|
78721
78751
|
validate: /* @__PURE__ */ __name((ctx) => {
|
|
78722
78752
|
const { request: req2 } = ctx;
|
|
78723
78753
|
if (req2) {
|
|
78724
|
-
const url =
|
|
78754
|
+
const url = URI24.from(req2.url);
|
|
78725
78755
|
if ((req2.method === "GET" || req2.method === "HEAD") && url.pathname.startsWith("/assets/cid") && url.getParam("url")) {
|
|
78726
78756
|
return Promise.resolve(
|
|
78727
78757
|
Result66.Ok(
|
|
@@ -78738,7 +78768,7 @@ var cidAsset = {
|
|
|
78738
78768
|
}, "validate"),
|
|
78739
78769
|
handle: /* @__PURE__ */ __name(async (ctx) => {
|
|
78740
78770
|
const vctx = ctx.ctx.getOrThrow("vibesApiCtx");
|
|
78741
|
-
const rAccess = await
|
|
78771
|
+
const rAccess = await exception2Result120(() => resolveCidAssetAccess(vctx, ctx.request));
|
|
78742
78772
|
const access3 = rAccess.isOk() ? rAccess.Ok() : void 0;
|
|
78743
78773
|
if (access3 === void 0) {
|
|
78744
78774
|
if (rAccess.isErr()) vctx.logger.Warn().Err(rAccess).Msg("cid-asset-authorization-read-failed");
|
|
@@ -78828,8 +78858,8 @@ import {
|
|
|
78828
78858
|
EventoResult as EventoResult12,
|
|
78829
78859
|
Option as Option17,
|
|
78830
78860
|
Result as Result67,
|
|
78831
|
-
URI as
|
|
78832
|
-
exception2Result as
|
|
78861
|
+
URI as URI25,
|
|
78862
|
+
exception2Result as exception2Result121
|
|
78833
78863
|
} from "@adviser/cement";
|
|
78834
78864
|
import { and as and68, desc as desc17, eq as eq82 } from "drizzle-orm";
|
|
78835
78865
|
var SCREENSHOT_PATH_RE = /^\/assets\/vibe-screenshot\/([a-z0-9][a-z0-9-]*)\/([a-z0-9][a-z0-9-]*)\.(?:png|jpg|jpeg|webp)$/;
|
|
@@ -78839,7 +78869,7 @@ var vibeScreenshotPrivate = {
|
|
|
78839
78869
|
validate: /* @__PURE__ */ __name((ctx) => {
|
|
78840
78870
|
const { request: req2 } = ctx;
|
|
78841
78871
|
if (!req2 || req2.method !== "GET" && req2.method !== "HEAD") return Promise.resolve(Result67.Ok(Option17.None()));
|
|
78842
|
-
const pathname =
|
|
78872
|
+
const pathname = URI25.from(req2.url).pathname;
|
|
78843
78873
|
if (pathname.startsWith(SCREENSHOT_PREFIX) === false) return Promise.resolve(Result67.Ok(Option17.None()));
|
|
78844
78874
|
const match = SCREENSHOT_PATH_RE.exec(pathname);
|
|
78845
78875
|
if (match === null) return Promise.resolve(Result67.Ok(Option17.Some({ ownerHandle: void 0, appSlug: void 0 })));
|
|
@@ -78869,7 +78899,7 @@ var vibeScreenshotPrivate = {
|
|
|
78869
78899
|
if (verifySession === void 0) return void 0;
|
|
78870
78900
|
return await verifySession(cookieToken);
|
|
78871
78901
|
}, "resolveUserId");
|
|
78872
|
-
const rServe = await
|
|
78902
|
+
const rServe = await exception2Result121(async () => {
|
|
78873
78903
|
const userId = await resolveUserId();
|
|
78874
78904
|
if (userId === void 0) return void 0;
|
|
78875
78905
|
const doc = await checkDocAccess(vctx, userId, appSlug, ownerHandle, void 0, "vibe-screenshot");
|
|
@@ -78910,8 +78940,8 @@ import {
|
|
|
78910
78940
|
EventoResult as EventoResult13,
|
|
78911
78941
|
Option as Option18,
|
|
78912
78942
|
Result as Result68,
|
|
78913
|
-
URI as
|
|
78914
|
-
exception2Result as
|
|
78943
|
+
URI as URI26,
|
|
78944
|
+
exception2Result as exception2Result122
|
|
78915
78945
|
} from "@adviser/cement";
|
|
78916
78946
|
import { and as and69, eq as eq83 } from "drizzle-orm";
|
|
78917
78947
|
var MAIL_IMAGE_PATH_RE = /^\/assets\/vibe-mail-image\/([a-z0-9][a-z0-9-]*)\/([A-Za-z0-9]{1,128})\.(?:png|jpg|jpeg|webp)$/;
|
|
@@ -78922,7 +78952,7 @@ var vibeMailImage = {
|
|
|
78922
78952
|
validate: /* @__PURE__ */ __name((ctx) => {
|
|
78923
78953
|
const { request: req2 } = ctx;
|
|
78924
78954
|
if (!req2 || req2.method !== "GET" && req2.method !== "HEAD") return Promise.resolve(Result68.Ok(Option18.None()));
|
|
78925
|
-
const uri =
|
|
78955
|
+
const uri = URI26.from(req2.url);
|
|
78926
78956
|
if (uri.pathname.startsWith(MAIL_IMAGE_PREFIX) === false) return Promise.resolve(Result68.Ok(Option18.None()));
|
|
78927
78957
|
const none = { appSlug: void 0, fsId: void 0, ownerUserId: void 0, token: void 0 };
|
|
78928
78958
|
const match = MAIL_IMAGE_PATH_RE.exec(uri.pathname);
|
|
@@ -78951,7 +78981,7 @@ var vibeMailImage = {
|
|
|
78951
78981
|
}, "refuse");
|
|
78952
78982
|
if (appSlug === void 0 || fsId === void 0 || ownerUserId === void 0 || token === void 0) return refuse10();
|
|
78953
78983
|
const nowMs = Date.now();
|
|
78954
|
-
const rServe = await
|
|
78984
|
+
const rServe = await exception2Result122(async () => {
|
|
78955
78985
|
const binding = { ownerUserId, appSlug, fsId };
|
|
78956
78986
|
const ok = await verifyMailImageToken(token, binding, vctx.mailImageTokenSecret, nowMs);
|
|
78957
78987
|
if (ok === false) return void 0;
|
|
@@ -78994,8 +79024,8 @@ import {
|
|
|
78994
79024
|
EventoResult as EventoResult14,
|
|
78995
79025
|
Option as Option19,
|
|
78996
79026
|
Result as Result69,
|
|
78997
|
-
URI as
|
|
78998
|
-
exception2Result as
|
|
79027
|
+
URI as URI27,
|
|
79028
|
+
exception2Result as exception2Result123
|
|
78999
79029
|
} from "@adviser/cement";
|
|
79000
79030
|
import { and as and70, asc as asc5, eq as eq84, like as like2 } from "drizzle-orm";
|
|
79001
79031
|
var CID_PATH_RE = /^\/assets\/safety-fetch\/([A-Za-z0-9]{1,256})$/;
|
|
@@ -79004,7 +79034,7 @@ var assetSafetyFetch = {
|
|
|
79004
79034
|
validate: /* @__PURE__ */ __name((ctx) => {
|
|
79005
79035
|
const { request: req2 } = ctx;
|
|
79006
79036
|
if (!req2 || req2.method !== "GET" && req2.method !== "HEAD") return Promise.resolve(Result69.Ok(Option19.None()));
|
|
79007
|
-
const uri =
|
|
79037
|
+
const uri = URI27.from(req2.url);
|
|
79008
79038
|
if (uri.pathname.startsWith(ASSET_SAFETY_FETCH_PREFIX) === false) return Promise.resolve(Result69.Ok(Option19.None()));
|
|
79009
79039
|
const match = CID_PATH_RE.exec(uri.pathname);
|
|
79010
79040
|
return Promise.resolve(
|
|
@@ -79027,7 +79057,7 @@ var assetSafetyFetch = {
|
|
|
79027
79057
|
const ok = await verifyAssetSafetyFetchToken(token, cid, vctx.assetSafetyFetchSecret, Date.now());
|
|
79028
79058
|
if (ok === false) return refuse10();
|
|
79029
79059
|
const u = vctx.sql.tables.assetUploads;
|
|
79030
|
-
const rUpload = await
|
|
79060
|
+
const rUpload = await exception2Result123(
|
|
79031
79061
|
() => vctx.sql.db.select({ assetURI: u.assetURI, mimeType: u.mimeType }).from(u).where(and70(eq84(u.cid, cid), like2(u.mimeType, "video/%"))).orderBy(asc5(u.created)).limit(1).then((r) => r[0])
|
|
79032
79062
|
);
|
|
79033
79063
|
if (rUpload.isErr()) {
|
|
@@ -79051,7 +79081,7 @@ var assetSafetyFetch = {
|
|
|
79051
79081
|
});
|
|
79052
79082
|
return Result69.Ok(EventoResult14.Stop);
|
|
79053
79083
|
}
|
|
79054
|
-
const rAsset = await
|
|
79084
|
+
const rAsset = await exception2Result123(() => vctx.storage.fetch(upload.assetURI));
|
|
79055
79085
|
if (rAsset.isErr()) return refuse10();
|
|
79056
79086
|
const fetched = rAsset.Ok();
|
|
79057
79087
|
if (!isFetchOkResult(fetched)) return refuse10();
|
|
@@ -79070,8 +79100,8 @@ import {
|
|
|
79070
79100
|
Result as Result70,
|
|
79071
79101
|
Option as Option20,
|
|
79072
79102
|
EventoResult as EventoResult15,
|
|
79073
|
-
URI as
|
|
79074
|
-
exception2Result as
|
|
79103
|
+
URI as URI28,
|
|
79104
|
+
exception2Result as exception2Result124
|
|
79075
79105
|
} from "@adviser/cement";
|
|
79076
79106
|
init_identity();
|
|
79077
79107
|
import { and as and71, eq as eq85 } from "drizzle-orm";
|
|
@@ -79097,7 +79127,7 @@ var assetOriginal = {
|
|
|
79097
79127
|
if (req2.method !== "GET" && req2.method !== "HEAD") {
|
|
79098
79128
|
return Promise.resolve(Result70.Ok(Option20.None()));
|
|
79099
79129
|
}
|
|
79100
|
-
const match = ORIGINAL_PATH_RE.exec(
|
|
79130
|
+
const match = ORIGINAL_PATH_RE.exec(URI28.from(req2.url).pathname);
|
|
79101
79131
|
if (match === null) return Promise.resolve(Result70.Ok(Option20.None()));
|
|
79102
79132
|
return Promise.resolve(
|
|
79103
79133
|
Result70.Ok(
|
|
@@ -79120,7 +79150,7 @@ var assetOriginal = {
|
|
|
79120
79150
|
}
|
|
79121
79151
|
const userId = rVerified.Ok().userId;
|
|
79122
79152
|
const t = vctx.sql.tables.assetUploads;
|
|
79123
|
-
const rRows = await
|
|
79153
|
+
const rRows = await exception2Result124(
|
|
79124
79154
|
() => vctx.sql.db.select({ cid: t.cid, assetURI: t.assetURI, ownerHandle: t.ownerHandle, appSlug: t.appSlug, mimeType: t.mimeType }).from(t).where(eq85(t.cid, cid))
|
|
79125
79155
|
);
|
|
79126
79156
|
if (rRows.isErr()) {
|
|
@@ -79136,7 +79166,7 @@ var assetOriginal = {
|
|
|
79136
79166
|
const key = `${candidate.ownerHandle}/${candidate.appSlug}`;
|
|
79137
79167
|
if (seen.has(key)) continue;
|
|
79138
79168
|
seen.add(key);
|
|
79139
|
-
const rAuthority = await
|
|
79169
|
+
const rAuthority = await exception2Result124(
|
|
79140
79170
|
() => hasWriteAuthority({ vctx, userId, ownerHandle: candidate.ownerHandle, appSlug: candidate.appSlug })
|
|
79141
79171
|
);
|
|
79142
79172
|
if (rAuthority.isErr()) {
|
|
@@ -79216,13 +79246,13 @@ import {
|
|
|
79216
79246
|
Result as Result73,
|
|
79217
79247
|
Option as Option23,
|
|
79218
79248
|
EventoResult as EventoResult18,
|
|
79219
|
-
URI as
|
|
79220
|
-
exception2Result as
|
|
79249
|
+
URI as URI29,
|
|
79250
|
+
exception2Result as exception2Result129
|
|
79221
79251
|
} from "@adviser/cement";
|
|
79222
79252
|
import { eq as eq89 } from "drizzle-orm";
|
|
79223
79253
|
|
|
79224
79254
|
// ../vibes.diy/api/svc/public/app-documents-read-eventos.ts
|
|
79225
|
-
import { Result as Result72, Option as Option22, EventoResult as EventoResult17, exception2Result as
|
|
79255
|
+
import { Result as Result72, Option as Option22, EventoResult as EventoResult17, exception2Result as exception2Result128 } from "@adviser/cement";
|
|
79226
79256
|
import { and as and74, eq as eq88, sql as sql18 } from "drizzle-orm";
|
|
79227
79257
|
import { type as type114 } from "arktype";
|
|
79228
79258
|
|
|
@@ -79259,7 +79289,7 @@ function dmDescriptor(channelSlug, participants) {
|
|
|
79259
79289
|
__name(dmDescriptor, "dmDescriptor");
|
|
79260
79290
|
|
|
79261
79291
|
// ../vibes.diy/api/svc/public/interest-channels.ts
|
|
79262
|
-
import { exception2Result as
|
|
79292
|
+
import { exception2Result as exception2Result125 } from "@adviser/cement";
|
|
79263
79293
|
var HANDLE_RE = /^[a-z0-9](?:[a-z0-9-]{0,30}[a-z0-9])?$/;
|
|
79264
79294
|
function parseInterestHandles(interests) {
|
|
79265
79295
|
if (interests === void 0) return [];
|
|
@@ -79304,7 +79334,7 @@ async function admitInterestChannels(vctx, input) {
|
|
|
79304
79334
|
}
|
|
79305
79335
|
__name(admitInterestChannels, "admitInterestChannels");
|
|
79306
79336
|
async function admitInterestChannelsFailClosed(vctx, input) {
|
|
79307
|
-
const result = await
|
|
79337
|
+
const result = await exception2Result125(() => admitInterestChannels(vctx, input));
|
|
79308
79338
|
if (result.isErr()) {
|
|
79309
79339
|
console.error("interest admission failed (fail closed):", result.Err());
|
|
79310
79340
|
return /* @__PURE__ */ new Set();
|
|
@@ -79356,7 +79386,7 @@ function applyInterestKeys(conn, input) {
|
|
|
79356
79386
|
__name(applyInterestKeys, "applyInterestKeys");
|
|
79357
79387
|
|
|
79358
79388
|
// ../vibes.diy/api/svc/public/sync-eventos.ts
|
|
79359
|
-
import { Result as Result71, Option as Option21, EventoResult as EventoResult16, exception2Result as
|
|
79389
|
+
import { Result as Result71, Option as Option21, EventoResult as EventoResult16, exception2Result as exception2Result127 } from "@adviser/cement";
|
|
79360
79390
|
import { aliasedTable as aliasedTable2, and as and73, eq as eq87, gt as gt9, inArray as inArray22, lte as lte3, max as max5 } from "drizzle-orm";
|
|
79361
79391
|
import { type as type113 } from "arktype";
|
|
79362
79392
|
|
|
@@ -79428,7 +79458,7 @@ var dmSyncPullPolicy = {
|
|
|
79428
79458
|
};
|
|
79429
79459
|
|
|
79430
79460
|
// ../vibes.diy/api/svc/public/app-documents-put-persist.ts
|
|
79431
|
-
import { exception2Result as
|
|
79461
|
+
import { exception2Result as exception2Result126 } from "@adviser/cement";
|
|
79432
79462
|
import { eq as eq86, and as and72 } from "drizzle-orm";
|
|
79433
79463
|
async function persistPutRevision(vctx, p) {
|
|
79434
79464
|
const { ownerHandle, appSlug, dbName, docId, doc, userId, now: now3, accessResult, accessFnCid, baseSeq, createIfHeadSeq, ifRev } = p;
|
|
@@ -79445,7 +79475,7 @@ async function persistPutRevision(vctx, p) {
|
|
|
79445
79475
|
let grantUpsertErr;
|
|
79446
79476
|
let noopRefreshedStaleOutput = false;
|
|
79447
79477
|
const upsertAccessOutput = storeAccessOutput ? async (exec) => {
|
|
79448
|
-
const rUpsert = await
|
|
79478
|
+
const rUpsert = await exception2Result126(
|
|
79449
79479
|
() => exec.insert(storeAccessOutput.tOutputs).values({
|
|
79450
79480
|
ownerHandle,
|
|
79451
79481
|
appSlug,
|
|
@@ -80062,7 +80092,7 @@ function kickPrefixRefresh(vctx, p) {
|
|
|
80062
80092
|
}).finally(() => endPrefixRefresh(p.prefixKey));
|
|
80063
80093
|
const waitUntil = vctx.waitUntil;
|
|
80064
80094
|
if (waitUntil !== void 0) {
|
|
80065
|
-
const registered =
|
|
80095
|
+
const registered = exception2Result127(() => waitUntil(task));
|
|
80066
80096
|
if (registered.isErr()) console.warn("sync pull: prefix cache refresh waitUntil registration failed:", registered.Err());
|
|
80067
80097
|
} else {
|
|
80068
80098
|
void task;
|
|
@@ -81104,7 +81134,7 @@ var subscribeDocsEvento = {
|
|
|
81104
81134
|
appSlug: req2.appSlug
|
|
81105
81135
|
});
|
|
81106
81136
|
for (const ch of audienceChannelsForReader(membership)) effectiveChannels.add(ch);
|
|
81107
|
-
const rReg = await
|
|
81137
|
+
const rReg = await exception2Result128(() => vctx.registerAudienceReader?.(userHandle) ?? Promise.resolve());
|
|
81108
81138
|
if (rReg.isErr()) console.error("aud-reader registration failed:", rReg.Err());
|
|
81109
81139
|
}
|
|
81110
81140
|
}
|
|
@@ -81307,7 +81337,7 @@ var filesAsset = {
|
|
|
81307
81337
|
if (req2.method !== "GET" && req2.method !== "HEAD") {
|
|
81308
81338
|
return Promise.resolve(Result73.Ok(Option23.None()));
|
|
81309
81339
|
}
|
|
81310
|
-
const url =
|
|
81340
|
+
const url = URI29.from(req2.url);
|
|
81311
81341
|
if (!url.hostname.startsWith(ASSETS_HOST_PREFIX)) {
|
|
81312
81342
|
return Promise.resolve(Result73.Ok(Option23.None()));
|
|
81313
81343
|
}
|
|
@@ -81343,7 +81373,7 @@ var filesAsset = {
|
|
|
81343
81373
|
adminMode = rVerified.Ok().adminMode;
|
|
81344
81374
|
}
|
|
81345
81375
|
}
|
|
81346
|
-
const rDoc = await
|
|
81376
|
+
const rDoc = await exception2Result129(
|
|
81347
81377
|
() => getDocForCaller(vctx, { userId: userId ?? null, ownerHandle, appSlug, dbName, docId, adminMode })
|
|
81348
81378
|
);
|
|
81349
81379
|
if (rDoc.isErr()) return sendErr3(ctx, 500, `doc lookup failed: ${rDoc.Err().message}`);
|
|
@@ -81359,7 +81389,7 @@ var filesAsset = {
|
|
|
81359
81389
|
return sendErr3(ctx, 404, `_files.${key} not found on document ${docId}`);
|
|
81360
81390
|
}
|
|
81361
81391
|
const uploadsT = vctx.sql.tables.assetUploads;
|
|
81362
|
-
const rUpload = await
|
|
81392
|
+
const rUpload = await exception2Result129(
|
|
81363
81393
|
() => vctx.sql.db.select({
|
|
81364
81394
|
assetURI: uploadsT.assetURI,
|
|
81365
81395
|
origin: uploadsT.origin,
|
|
@@ -81481,15 +81511,15 @@ import {
|
|
|
81481
81511
|
Result as Result76,
|
|
81482
81512
|
Option as Option24,
|
|
81483
81513
|
EventoResult as EventoResult19,
|
|
81484
|
-
URI as
|
|
81514
|
+
URI as URI30
|
|
81485
81515
|
} from "@adviser/cement";
|
|
81486
81516
|
|
|
81487
81517
|
// ../vibes.diy/api/svc/public/store-and-audit-asset.ts
|
|
81488
|
-
import { Result as Result74, exception2Result as
|
|
81518
|
+
import { Result as Result74, exception2Result as exception2Result130, uint8array2stream as uint8array2stream2 } from "@adviser/cement";
|
|
81489
81519
|
import { eq as eq90 } from "drizzle-orm";
|
|
81490
81520
|
async function storeAndAuditAsset(vctx, params) {
|
|
81491
81521
|
const stream = params.bytes instanceof Uint8Array ? uint8array2stream2(params.bytes) : params.bytes;
|
|
81492
|
-
const rEnsure = await
|
|
81522
|
+
const rEnsure = await exception2Result130(() => vctx.storage.ensure(stream));
|
|
81493
81523
|
if (rEnsure.isErr()) {
|
|
81494
81524
|
return Result74.Err(`storage.ensure failed: ${rEnsure.Err().message}`);
|
|
81495
81525
|
}
|
|
@@ -81502,7 +81532,7 @@ async function storeAndAuditAsset(vctx, params) {
|
|
|
81502
81532
|
const mimeType = params.mimeType ?? null;
|
|
81503
81533
|
const origin = params.origin ?? "upload";
|
|
81504
81534
|
const uploadsTable = vctx.sql.tables.assetUploads;
|
|
81505
|
-
const rInsert = await
|
|
81535
|
+
const rInsert = await exception2Result130(
|
|
81506
81536
|
() => vctx.sql.db.insert(uploadsTable).values({
|
|
81507
81537
|
uploadId,
|
|
81508
81538
|
userId: params.userId,
|
|
@@ -81520,7 +81550,7 @@ async function storeAndAuditAsset(vctx, params) {
|
|
|
81520
81550
|
return Result74.Err(`audit insert failed: ${rInsert.Err().message}`);
|
|
81521
81551
|
}
|
|
81522
81552
|
if (rInsert.Ok().length === 0) {
|
|
81523
|
-
const rExisting = await
|
|
81553
|
+
const rExisting = await exception2Result130(
|
|
81524
81554
|
() => vctx.sql.db.select({
|
|
81525
81555
|
cid: uploadsTable.cid,
|
|
81526
81556
|
origin: uploadsTable.origin,
|
|
@@ -81574,7 +81604,7 @@ async function seedAssetSafety(vctx, a) {
|
|
|
81574
81604
|
const isVideo = a.mimeType !== null && a.mimeType.startsWith("video/");
|
|
81575
81605
|
const now3 = (/* @__PURE__ */ new Date()).toISOString();
|
|
81576
81606
|
const t = vctx.sql.tables.assetSafety;
|
|
81577
|
-
const rSeed = await
|
|
81607
|
+
const rSeed = await exception2Result130(
|
|
81578
81608
|
() => vctx.sql.db.insert(t).values({ cid: a.cid, verdict: isImage || isVideo ? "pending" : "low", attempts: 0, created: now3, updated: now3 }).onConflictDoNothing({ target: t.cid })
|
|
81579
81609
|
);
|
|
81580
81610
|
if (rSeed.isErr()) {
|
|
@@ -81582,7 +81612,7 @@ async function seedAssetSafety(vctx, a) {
|
|
|
81582
81612
|
return;
|
|
81583
81613
|
}
|
|
81584
81614
|
if (!isImage && !isVideo) return;
|
|
81585
|
-
const rExisting = await
|
|
81615
|
+
const rExisting = await exception2Result130(
|
|
81586
81616
|
() => vctx.sql.db.select({ verdict: t.verdict }).from(t).where(eq90(t.cid, a.cid)).limit(1).then((r) => r[0])
|
|
81587
81617
|
);
|
|
81588
81618
|
if (rExisting.isErr()) {
|
|
@@ -81593,7 +81623,7 @@ async function seedAssetSafety(vctx, a) {
|
|
|
81593
81623
|
if (existing !== void 0 && existing.verdict !== "pending") return;
|
|
81594
81624
|
let model = "";
|
|
81595
81625
|
if (isImage) {
|
|
81596
|
-
const rModels = await
|
|
81626
|
+
const rModels = await exception2Result130(() => loadModels(vctx));
|
|
81597
81627
|
const rModel = rModels.isErr() ? Result74.Err(rModels) : resolveVisionModelId(rModels.Ok().models);
|
|
81598
81628
|
if (rModel.isErr()) {
|
|
81599
81629
|
vctx.logger.Warn().Err(rModel).Str("cid", a.cid).Msg("asset-safety-model-unresolved");
|
|
@@ -81601,7 +81631,7 @@ async function seedAssetSafety(vctx, a) {
|
|
|
81601
81631
|
model = rModel.Ok();
|
|
81602
81632
|
}
|
|
81603
81633
|
}
|
|
81604
|
-
const rPost = await
|
|
81634
|
+
const rPost = await exception2Result130(
|
|
81605
81635
|
() => vctx.postQueue({
|
|
81606
81636
|
payload: {
|
|
81607
81637
|
type: "vibes.diy.evt-asset-safety",
|
|
@@ -81629,7 +81659,7 @@ async function seedAssetSafety(vctx, a) {
|
|
|
81629
81659
|
__name(seedAssetSafety, "seedAssetSafety");
|
|
81630
81660
|
|
|
81631
81661
|
// ../vibes.diy/api/svc/intern/asset-sniff.ts
|
|
81632
|
-
import { Result as Result75, exception2Result as
|
|
81662
|
+
import { Result as Result75, exception2Result as exception2Result131 } from "@adviser/cement";
|
|
81633
81663
|
function isGatedMime(mimeType) {
|
|
81634
81664
|
const mime2 = normalizeMime(mimeType);
|
|
81635
81665
|
if (mime2.startsWith("image/")) return false;
|
|
@@ -81731,7 +81761,7 @@ var HEAD_BYTES = 16;
|
|
|
81731
81761
|
async function peekHead(body, n = HEAD_BYTES) {
|
|
81732
81762
|
const reader = body.getReader();
|
|
81733
81763
|
const buffered = [];
|
|
81734
|
-
const rRead = await
|
|
81764
|
+
const rRead = await exception2Result131(async () => {
|
|
81735
81765
|
let got = 0;
|
|
81736
81766
|
while (got < n) {
|
|
81737
81767
|
const { done: done2, value } = await reader.read();
|
|
@@ -81743,7 +81773,7 @@ async function peekHead(body, n = HEAD_BYTES) {
|
|
|
81743
81773
|
return got;
|
|
81744
81774
|
});
|
|
81745
81775
|
if (rRead.isErr()) {
|
|
81746
|
-
await
|
|
81776
|
+
await exception2Result131(() => reader.cancel(rRead.Err()));
|
|
81747
81777
|
return Result75.Err(rRead.Err());
|
|
81748
81778
|
}
|
|
81749
81779
|
const head = new Uint8Array(Math.min(rRead.Ok(), n));
|
|
@@ -81790,7 +81820,7 @@ var putAsset = {
|
|
|
81790
81820
|
validate: /* @__PURE__ */ __name((ctx) => {
|
|
81791
81821
|
const { request: req2 } = ctx;
|
|
81792
81822
|
if (!req2 || req2.method !== "POST") return Promise.resolve(Result76.Ok(Option24.None()));
|
|
81793
|
-
const url =
|
|
81823
|
+
const url = URI30.from(req2.url);
|
|
81794
81824
|
if (url.pathname !== "/assets") return Promise.resolve(Result76.Ok(Option24.None()));
|
|
81795
81825
|
const grant2 = req2.headers.get(GRANT_HEADER) ?? req2.headers.get(GRANT_HEADER.toLowerCase());
|
|
81796
81826
|
const origin = req2.headers.get("Origin") ?? req2.headers.get("origin") ?? void 0;
|
|
@@ -81927,7 +81957,7 @@ import {
|
|
|
81927
81957
|
Result as Result77,
|
|
81928
81958
|
Option as Option25,
|
|
81929
81959
|
EventoResult as EventoResult20,
|
|
81930
|
-
URI as
|
|
81960
|
+
URI as URI31
|
|
81931
81961
|
} from "@adviser/cement";
|
|
81932
81962
|
async function handleGetUserAvatar(vctx, ownerHandle, ifNoneMatch) {
|
|
81933
81963
|
const avatar = await readHandleAvatar(vctx, ownerHandle);
|
|
@@ -81959,7 +81989,7 @@ var userAvatar = {
|
|
|
81959
81989
|
validate: /* @__PURE__ */ __name((ctx) => {
|
|
81960
81990
|
const { request: req2 } = ctx;
|
|
81961
81991
|
if (req2 && (req2.method === "GET" || req2.method === "HEAD")) {
|
|
81962
|
-
const url =
|
|
81992
|
+
const url = URI31.from(req2.url);
|
|
81963
81993
|
const m = USER_AVATAR_PATH_RE.exec(url.pathname);
|
|
81964
81994
|
if (m) {
|
|
81965
81995
|
return Promise.resolve(
|
|
@@ -82006,7 +82036,7 @@ import {
|
|
|
82006
82036
|
import { type as type120 } from "arktype";
|
|
82007
82037
|
|
|
82008
82038
|
// ../vibes.diy/api/svc/intern/text-lane/linq-client.ts
|
|
82009
|
-
import { exception2Result as
|
|
82039
|
+
import { exception2Result as exception2Result132 } from "@adviser/cement";
|
|
82010
82040
|
var LINQ_BASE_URL = "https://api.linqapp.com/api/partner/v3";
|
|
82011
82041
|
var TERMINAL_CODES = /* @__PURE__ */ new Set([2026, 4005, 2011, 2012, 2014, 2033]);
|
|
82012
82042
|
function classifyLinqError(status, code2) {
|
|
@@ -82257,9 +82287,9 @@ function createLinqClient(opts) {
|
|
|
82257
82287
|
const put = Object.fromEntries(Object.entries(headers).filter(([k]) => k.toLowerCase() !== "content-length"));
|
|
82258
82288
|
const signal = AbortSignal.timeout(timeoutMs);
|
|
82259
82289
|
const doFetch = opts.fetch ?? fetch.bind(globalThis);
|
|
82260
|
-
const rPut = await
|
|
82290
|
+
const rPut = await exception2Result132(async () => {
|
|
82261
82291
|
const res = await untilAborted(doFetch(uploadUrl, { method, headers: put, body: a.bytes, signal }), signal);
|
|
82262
|
-
await
|
|
82292
|
+
await exception2Result132(() => untilAborted(res.arrayBuffer(), signal));
|
|
82263
82293
|
return res.status;
|
|
82264
82294
|
});
|
|
82265
82295
|
if (rPut.isErr()) return { ok: false, kind: "retry", status: 0 };
|
|
@@ -82286,7 +82316,7 @@ function createLinqClient(opts) {
|
|
|
82286
82316
|
__name(createLinqClient, "createLinqClient");
|
|
82287
82317
|
|
|
82288
82318
|
// ../vibes.diy/api/svc/intern/text-lane/capi.ts
|
|
82289
|
-
import { exception2Result as
|
|
82319
|
+
import { exception2Result as exception2Result133 } from "@adviser/cement";
|
|
82290
82320
|
var TEXT_US_SUGGESTIONS = [
|
|
82291
82321
|
"Build me a sign-up sheet for our Thanksgiving potluck",
|
|
82292
82322
|
"Build me a Secret Santa picker for my friend group",
|
|
@@ -82378,7 +82408,7 @@ __name(parseTextLines, "parseTextLines");
|
|
|
82378
82408
|
import { exception2Result as exception2Result157, Result as Result99 } from "@adviser/cement";
|
|
82379
82409
|
|
|
82380
82410
|
// ../vibes.diy/api/svc/intern/guest-principal-store.ts
|
|
82381
|
-
import { exception2Result as
|
|
82411
|
+
import { exception2Result as exception2Result134, Result as Result78 } from "@adviser/cement";
|
|
82382
82412
|
import { and as and76, eq as eq92, gt as gt10, isNull as isNull4, lt as lt7 } from "drizzle-orm";
|
|
82383
82413
|
var GUEST_PRINCIPAL_LIFETIME_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
82384
82414
|
var GUEST_PRINCIPAL_RENEW_STEP_MS = 60 * 60 * 1e3;
|
|
@@ -82414,7 +82444,7 @@ async function readGuestPrincipal(vctx, userId) {
|
|
|
82414
82444
|
const id = guestIdOf(userId);
|
|
82415
82445
|
if (id === void 0) return Result78.Ok(void 0);
|
|
82416
82446
|
const t = vctx.sql.tables.guestBuilds;
|
|
82417
|
-
const read = await
|
|
82447
|
+
const read = await exception2Result134(() => vctx.sql.db.select().from(t).where(eq92(t.chatId, id)).limit(1));
|
|
82418
82448
|
if (read.isErr()) return Result78.Err(read.Err());
|
|
82419
82449
|
const row = read.Ok()[0];
|
|
82420
82450
|
return Result78.Ok(row === void 0 ? void 0 : toRow(row));
|
|
@@ -82446,11 +82476,11 @@ import { exception2Result as exception2Result156, Result as Result98 } from "@ad
|
|
|
82446
82476
|
import { and as and88, eq as eq108, inArray as inArray27, isNull as isNull8, max as max6, ne as ne13, notInArray as notInArray6, or as or9, sql as sql21 } from "drizzle-orm";
|
|
82447
82477
|
|
|
82448
82478
|
// ../vibes.diy/api/svc/intern/open-turn-store.ts
|
|
82449
|
-
import { exception2Result as
|
|
82479
|
+
import { exception2Result as exception2Result136, Result as Result80 } from "@adviser/cement";
|
|
82450
82480
|
import { and as and78, asc as asc6, eq as eq94, gt as gt11, inArray as inArray24, isNotNull as isNotNull2, lt as lt8, ne as ne7, notInArray as notInArray3, or as or7, isNull as isNull6 } from "drizzle-orm/sql/expressions";
|
|
82451
82481
|
|
|
82452
82482
|
// ../vibes.diy/api/svc/intern/build-ledger-store.ts
|
|
82453
|
-
import { exception2Result as
|
|
82483
|
+
import { exception2Result as exception2Result135, Result as Result79 } from "@adviser/cement";
|
|
82454
82484
|
import { and as and77, eq as eq93, inArray as inArray23, isNull as isNull5, notInArray as notInArray2, or as or6 } from "drizzle-orm/sql/expressions";
|
|
82455
82485
|
import { sql as sqlExpr } from "drizzle-orm";
|
|
82456
82486
|
var CONVERSATION_TURN_PHASE = "deciding";
|
|
@@ -82494,7 +82524,7 @@ __name(toStamp, "toStamp");
|
|
|
82494
82524
|
async function stampIntentPhase(sql38, args) {
|
|
82495
82525
|
const t = sql38.tables.mintJobs;
|
|
82496
82526
|
const statusGuard = args.onlyStatus === void 0 ? void 0 : inArray23(t.status, [...args.onlyStatus]);
|
|
82497
|
-
const r = await
|
|
82527
|
+
const r = await exception2Result135(
|
|
82498
82528
|
() => sql38.db.update(t).set({
|
|
82499
82529
|
phase: args.phase,
|
|
82500
82530
|
phaseSeq: sqlExpr`${t.phaseSeq} + 1`,
|
|
@@ -82508,7 +82538,7 @@ __name(stampIntentPhase, "stampIntentPhase");
|
|
|
82508
82538
|
async function stampTurnPhase(sql38, args) {
|
|
82509
82539
|
const t = sql38.tables.openTurns;
|
|
82510
82540
|
const extra = args.extra ?? {};
|
|
82511
|
-
const r = await
|
|
82541
|
+
const r = await exception2Result135(
|
|
82512
82542
|
() => sql38.db.update(t).set({
|
|
82513
82543
|
phase: args.phase,
|
|
82514
82544
|
phaseSeq: sqlExpr`${t.phaseSeq} + 1`,
|
|
@@ -82524,7 +82554,7 @@ async function stampTurnPhase(sql38, args) {
|
|
|
82524
82554
|
__name(stampTurnPhase, "stampTurnPhase");
|
|
82525
82555
|
async function markConversationTurnError(sql38, args) {
|
|
82526
82556
|
const t = sql38.tables.openTurns;
|
|
82527
|
-
const r = await
|
|
82557
|
+
const r = await exception2Result135(
|
|
82528
82558
|
() => sql38.db.update(t).set({ errorKind: args.errorKind, updated: new Date(args.nowMs ?? Date.now()).toISOString() }).where(
|
|
82529
82559
|
and77(eq93(t.chatId, args.chatId), eq93(t.promptId, args.promptId), eq93(t.phase, CONVERSATION_TURN_PHASE), isNull5(t.errorKind))
|
|
82530
82560
|
).returning({ promptId: t.promptId })
|
|
@@ -82581,7 +82611,7 @@ function toRow2(raw) {
|
|
|
82581
82611
|
}
|
|
82582
82612
|
__name(toRow2, "toRow");
|
|
82583
82613
|
async function openTurn(sql38, input, startedAtMs) {
|
|
82584
|
-
const r = await
|
|
82614
|
+
const r = await exception2Result136(
|
|
82585
82615
|
() => sql38.db.insert(sql38.tables.openTurns).values(openTurnValues(sql38.tables, input, startedAtMs)).onConflictDoNothing().returning({ promptId: sql38.tables.openTurns.promptId })
|
|
82586
82616
|
);
|
|
82587
82617
|
if (r.isErr()) return Result80.Err(r);
|
|
@@ -82620,7 +82650,7 @@ function shouldCloseTurnRecord(args) {
|
|
|
82620
82650
|
__name(shouldCloseTurnRecord, "shouldCloseTurnRecord");
|
|
82621
82651
|
async function closeTurn(sql38, args, closedAtMs) {
|
|
82622
82652
|
const nowIso2 = new Date(closedAtMs ?? Date.now()).toISOString();
|
|
82623
|
-
const r = await
|
|
82653
|
+
const r = await exception2Result136(
|
|
82624
82654
|
() => sql38.db.update(sql38.tables.openTurns).set({ status: "closed", closedAt: nowIso2, updated: nowIso2 }).where(
|
|
82625
82655
|
and78(
|
|
82626
82656
|
eq94(sql38.tables.openTurns.chatId, args.chatId),
|
|
@@ -82645,7 +82675,7 @@ var OPEN_TURN_AWAIT_BUILD_EXTENSION_MS = BUILD_LOCK_DEADLINE_MS + PERSIST_TAIL_M
|
|
|
82645
82675
|
async function extendOpenTurnDeadline(sql38, args, nowMs) {
|
|
82646
82676
|
const nowIso2 = new Date(nowMs ?? Date.now()).toISOString();
|
|
82647
82677
|
const deadlineIso = new Date(args.deadlineAtMs).toISOString();
|
|
82648
|
-
const r = await
|
|
82678
|
+
const r = await exception2Result136(
|
|
82649
82679
|
() => sql38.db.update(sql38.tables.openTurns).set({ deadlineAt: deadlineIso, updated: nowIso2 }).where(
|
|
82650
82680
|
and78(
|
|
82651
82681
|
eq94(sql38.tables.openTurns.chatId, args.chatId),
|
|
@@ -82661,7 +82691,7 @@ async function extendOpenTurnDeadline(sql38, args, nowMs) {
|
|
|
82661
82691
|
__name(extendOpenTurnDeadline, "extendOpenTurnDeadline");
|
|
82662
82692
|
async function setTurnStatus(sql38, args, opts) {
|
|
82663
82693
|
const nowIso2 = new Date(opts.closedAtMs ?? Date.now()).toISOString();
|
|
82664
|
-
const r = await
|
|
82694
|
+
const r = await exception2Result136(
|
|
82665
82695
|
() => sql38.db.update(sql38.tables.openTurns).set({
|
|
82666
82696
|
status: opts.to,
|
|
82667
82697
|
updated: nowIso2,
|
|
@@ -82679,7 +82709,7 @@ async function setTurnStatus(sql38, args, opts) {
|
|
|
82679
82709
|
}
|
|
82680
82710
|
__name(setTurnStatus, "setTurnStatus");
|
|
82681
82711
|
async function getOpenTurn(sql38, args) {
|
|
82682
|
-
const r = await
|
|
82712
|
+
const r = await exception2Result136(
|
|
82683
82713
|
() => sql38.db.select(openTurnRowColumns(sql38)).from(sql38.tables.openTurns).where(and78(eq94(sql38.tables.openTurns.chatId, args.chatId), eq94(sql38.tables.openTurns.promptId, args.promptId))).limit(1)
|
|
82684
82714
|
);
|
|
82685
82715
|
if (r.isErr()) return Result80.Err(r);
|
|
@@ -82694,7 +82724,7 @@ async function getOpenTurnStatuses(sql38, keys) {
|
|
|
82694
82724
|
const keyed = or7(
|
|
82695
82725
|
...chunk.map((k) => and78(eq94(sql38.tables.openTurns.chatId, k.chatId), eq94(sql38.tables.openTurns.promptId, k.promptId)))
|
|
82696
82726
|
);
|
|
82697
|
-
const r = await
|
|
82727
|
+
const r = await exception2Result136(
|
|
82698
82728
|
() => sql38.db.select({
|
|
82699
82729
|
chatId: sql38.tables.openTurns.chatId,
|
|
82700
82730
|
promptId: sql38.tables.openTurns.promptId,
|
|
@@ -82716,7 +82746,7 @@ async function getOpenTurnStatuses(sql38, keys) {
|
|
|
82716
82746
|
}
|
|
82717
82747
|
__name(getOpenTurnStatuses, "getOpenTurnStatuses");
|
|
82718
82748
|
async function hasOpenTurnOnOtherLane(sql38, args) {
|
|
82719
|
-
return
|
|
82749
|
+
return exception2Result136(async () => {
|
|
82720
82750
|
const t = sql38.tables.openTurns;
|
|
82721
82751
|
const row = await sql38.db.select({ promptId: t.promptId }).from(t).where(
|
|
82722
82752
|
and78(
|
|
@@ -82732,7 +82762,7 @@ async function hasOpenTurnOnOtherLane(sql38, args) {
|
|
|
82732
82762
|
}
|
|
82733
82763
|
__name(hasOpenTurnOnOtherLane, "hasOpenTurnOnOtherLane");
|
|
82734
82764
|
async function hasOpenTurnOnChat(sql38, args) {
|
|
82735
|
-
return
|
|
82765
|
+
return exception2Result136(async () => {
|
|
82736
82766
|
const t = sql38.tables.openTurns;
|
|
82737
82767
|
const row = await sql38.db.select({ promptId: t.promptId }).from(t).where(
|
|
82738
82768
|
and78(
|
|
@@ -82769,14 +82799,14 @@ async function claimLostTurns(sql38, args) {
|
|
|
82769
82799
|
);
|
|
82770
82800
|
}
|
|
82771
82801
|
__name(claimable, "claimable");
|
|
82772
|
-
const rCandidates = await
|
|
82802
|
+
const rCandidates = await exception2Result136(
|
|
82773
82803
|
() => sql38.db.select({ chatId: t.chatId, promptId: t.promptId }).from(t).where(claimable()).orderBy(asc6(t.deadlineAt)).limit(limit)
|
|
82774
82804
|
);
|
|
82775
82805
|
if (rCandidates.isErr()) return Result80.Err(rCandidates);
|
|
82776
82806
|
const candidates = rCandidates.Ok();
|
|
82777
82807
|
if (candidates.length === 0) return Result80.Ok([]);
|
|
82778
82808
|
const keyed = or7(...candidates.map((c) => and78(eq94(t.chatId, c.chatId), eq94(t.promptId, c.promptId))));
|
|
82779
|
-
const r = await
|
|
82809
|
+
const r = await exception2Result136(
|
|
82780
82810
|
() => sql38.db.update(t).set({ status: "swept", closedAt: nowIso2, updated: nowIso2 }).where(claimable(keyed)).returning(openTurnRowColumns(sql38))
|
|
82781
82811
|
);
|
|
82782
82812
|
if (r.isErr()) return Result80.Err(r);
|
|
@@ -82820,7 +82850,7 @@ import { desc as desc18 } from "drizzle-orm";
|
|
|
82820
82850
|
import { Result as Result82 } from "@adviser/cement";
|
|
82821
82851
|
|
|
82822
82852
|
// ../vibes.diy/api/svc/intern/chat-section-persist.ts
|
|
82823
|
-
import { chunkyAsync, exception2Result as
|
|
82853
|
+
import { chunkyAsync, exception2Result as exception2Result137, Result as Result81 } from "@adviser/cement";
|
|
82824
82854
|
var CHAT_SECTION_BLOCK_CHUNK = 100;
|
|
82825
82855
|
function chatSectionRows(args) {
|
|
82826
82856
|
const blockChunks = args.blockChunks ?? CHAT_SECTION_BLOCK_CHUNK;
|
|
@@ -82849,7 +82879,7 @@ async function insertChatSectionRows(db, tables, rows) {
|
|
|
82849
82879
|
input: [...rows],
|
|
82850
82880
|
splitCondition: /* @__PURE__ */ __name((chunk) => chunk.length >= CHAT_SECTION_INSERT_BATCH, "splitCondition"),
|
|
82851
82881
|
commit: /* @__PURE__ */ __name(async (chunk) => {
|
|
82852
|
-
const rChunk = await
|
|
82882
|
+
const rChunk = await exception2Result137(() => db.insert(tables.chatSections).values(chunk));
|
|
82853
82883
|
if (rChunk.isErr()) result = Result81.Err(rChunk);
|
|
82854
82884
|
}, "commit")
|
|
82855
82885
|
});
|
|
@@ -82858,7 +82888,7 @@ async function insertChatSectionRows(db, tables, rows) {
|
|
|
82858
82888
|
__name(insertChatSectionRows, "insertChatSectionRows");
|
|
82859
82889
|
async function insertChatSectionRowsWhole(db, tables, rows) {
|
|
82860
82890
|
if (rows.length <= CHAT_SECTION_INSERT_BATCH) return insertChatSectionRows(db, tables, rows);
|
|
82861
|
-
return
|
|
82891
|
+
return exception2Result137(
|
|
82862
82892
|
() => db.transaction(async (tx) => {
|
|
82863
82893
|
const r = await insertChatSectionRows(tx, tables, rows);
|
|
82864
82894
|
if (r.isErr()) throw r.Err();
|
|
@@ -82998,13 +83028,6 @@ async function seedChatSection(vctx, opts) {
|
|
|
82998
83028
|
}
|
|
82999
83029
|
__name(seedChatSection, "seedChatSection");
|
|
83000
83030
|
|
|
83001
|
-
// ../vibes.diy/api/svc/intern/client-attribution.ts
|
|
83002
|
-
import { exception2Result as exception2Result137, URI as URI31 } from "@adviser/cement";
|
|
83003
|
-
function clientRefStamp(vctx) {
|
|
83004
|
-
return vctx.client === void 0 ? {} : { client: vctx.client };
|
|
83005
|
-
}
|
|
83006
|
-
__name(clientRefStamp, "clientRefStamp");
|
|
83007
|
-
|
|
83008
83031
|
// ../vibes.diy/api/svc/intern/ensure-push-seeded-chat.ts
|
|
83009
83032
|
function langForFilename(filename) {
|
|
83010
83033
|
const dot = filename.lastIndexOf(".");
|