Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Merge pull request #3577 from zicochaos/fix/pages-stop-aborts-upload

milind-soni8e0e896a9cfa
diff --cc server/index.ts
index ee4bf87987,b8a0e19b70..4acf0a000f
--- a/server/index.ts
+++ b/server/index.ts
@@@ -637,10 -627,9 +637,10 @@@ import { createReactionRoutes } from ".
import { createReactions, withReactionNotes, type Reactor } from "./reactions.ts";
import { createPersonReplies } from "./person-replies.ts";
import { personKey, relayedPersonKey } from "./person-key.ts";
-import { createTeamOwners, type AskViewer } from "./host/team-owners.ts"; import { createTeamMessages } from "./host/team-messages.ts"; import { relayedTurn } from "./host/relayed-turn.ts"; import { createPersonCalendar } from "./host/person-calendar.ts";
+import { createOutsideLineage, OUTSIDE_STAYS_HERE } from "./host/outside-lineage.ts"; import { OUTSIDE_REFUSAL, outsideRouteRefused } from "./host/outside-fence.ts"; import { createOutsideWrites } from "./host/outside-writes.ts";
+import { teamAiOwner } from "./host/team-ai-owner.ts"; import { createTeamOwners, type AskViewer } from "./host/team-owners.ts"; import { createTeamMessages } from "./host/team-messages.ts"; import { createPlaceInbox, guestNameIn, placeInboxViewer } from "./host/place-inbox.ts"; import { relayedTurn } from "./host/relayed-turn.ts"; import { createPersonCalendar } from "./host/person-calendar.ts";
import { createDevsReports } from "./host/devs-reports.ts"; import { bugReportEndpoint, devsReportSender, devsStatusAsker } from "./devs-report-send.ts"; import { captureRecentLog } from "./recent-log.ts"; import { createShareAnswer } from "./host/share-answer.ts";
- import { createCardRequester, linePersonKey } from "./host/thread-person.ts"; import { selfThreadRefusal } from "./host/self-threads.ts"; import { lookedAfterBy } from "./host/looked-after.ts"; import { createActingPeople, HANDED_PEOPLE_FILE, HandedPeople, type HandedRun, keptPrivate, privateHandBack, withPerson } from "./host/acting-person.ts";
-import { createCardRequester, linePersonKey } from "./host/thread-person.ts"; import { createActingPeople, HANDED_PEOPLE_FILE, HandedPeople, type HandedRun, keptPrivate, privateHandBack, withPerson } from "./host/acting-person.ts"; import { createTurnCallSignals } from "./host/turn-call-signals.ts";
++import { createCardRequester, linePersonKey } from "./host/thread-person.ts"; import { selfThreadRefusal } from "./host/self-threads.ts"; import { lookedAfterBy } from "./host/looked-after.ts"; import { createActingPeople, HANDED_PEOPLE_FILE, HandedPeople, type HandedRun, keptPrivate, privateHandBack, withPerson } from "./host/acting-person.ts"; import { createTurnCallSignals } from "./host/turn-call-signals.ts";
import { createThreadRoutes } from "./routes/threads.ts";
import { createWebhookRoutes } from "./routes/webhooks.ts";
import { withScopeHint } from "./connector-scope-hint.ts";
@@@ -13006,10 -13161,10 +13005,10 @@@ const handleRequest = async (req: Incom
};
const requireActiveInternalCapability = () => {
if (!internalCapabilityIsActive(internalCapability)) {
- throw Object.assign(new Error("the internal turn capability has expired"), { status: 401 });
+ throw Object.assign(new Error(TURN_ENDED_REFUSAL), { status: 401 });
}
};
- const botFolders = async () => ({ roots: messageFileRootsForThread(internalSender.id, internalCapability.threadId).filter((root) => root !== ATTACHMENTS_DIR), vmWorkspace: (await attachmentVmForTurn(internalCapability))?.workspaceDir ?? null }); if (await lentMcp.route({ method, path, req, res, json, turn: internalCapability, readBody: readInternalBody }) !== PASS || await internalToolRoutes({ method, path, res, json, botId: internalSender.id, threadId: internalCapability.threadId, readBody: readInternalBody, folders: botFolders }) !== PASS || await waitRoutes({ method, path, res, json, botId: internalSender.id, threadId: internalCapability.threadId, readBody: readInternalBody, ...waitTurnChecks(internalCapability, internalSender) }) !== PASS || await teamMessages.internal({ method, path, res, json, botId: internalSender.id, threadId: internalCapability.threadId, readBody: readInternalBody }) !== PASS || await devsReports.internal({ method, path, res, json, botId: internalSender.id, threadId: internalCapability.threadId, readBody: readInternalBody }) !== PASS || (computerAsks && await computerAsks.internal({ method, path, res, json, turn: internalCapability, readBody: readInternalBody }) !== PASS) || await meetingsHost.internal({ method, path, res, json, readBody: readInternalBody, bot: internalSender, threadId: internalCapability.threadId, active: () => internalCapabilityIsActive(internalCapability) }) !== PASS || await imageTools.internal({ method, path, res, json, readBody: readInternalBody, threadId: internalCapability.threadId, requireActive: requireActiveInternalCapability, personTurn: turnOrigin(internalCapability).kind === "user" || (Boolean(roomRun(internalCapability.generation)?.requestMessageId) && guestDrivenTurns.get(internalCapability.threadId) !== internalCapability.generation) }) !== PASS) return; const pagesCall = new AbortController(); res.once("close", () => { if (!res.writableEnded) pagesCall.abort(); }); if (await publishedPages.internal({ method, path, res, json, botId: internalSender.id, threadId: internalCapability.threadId, readBody: readInternalBody, requireActive: requireActiveInternalCapability, signal: pagesCall.signal, folders: botFolders, post: (text, publishedPage, bundle) => { const source = connectorThread(internalSender.id, internalCapability.threadId); return !source ? null : (bundle && publishedPages.show({ threadId: internalCapability.threadId, card: publishedPage, bundle, bot: internalSender })) || store.appendMessage(internalCapability.threadId, { role: "bot", kind: "text", text, publishedPage, ...(source.group ? { from: { botId: internalSender.id, name: internalSender.name, color: internalSender.color } } : {}) }).id; } }) !== PASS) return;
- const botFolders = async () => ({ roots: messageFileRootsForThread(internalSender.id, internalCapability.threadId).filter((root) => root !== ATTACHMENTS_DIR), vmWorkspace: (await attachmentVmForTurn(internalCapability))?.workspaceDir ?? null }); if (await internalToolRoutes({ method, path, res, json, botId: internalSender.id, readBody: readInternalBody, folders: botFolders }) !== PASS || await waitRoutes({ method, path, res, json, botId: internalSender.id, threadId: internalCapability.threadId, readBody: readInternalBody, ...waitTurnChecks(internalCapability, internalSender) }) !== PASS || await teamMessages.internal({ method, path, res, json, botId: internalSender.id, threadId: internalCapability.threadId, readBody: readInternalBody }) !== PASS || await devsReports.internal({ method, path, res, json, botId: internalSender.id, threadId: internalCapability.threadId, readBody: readInternalBody }) !== PASS || (computerAsks && await computerAsks.internal({ method, path, res, json, turn: internalCapability, readBody: readInternalBody }) !== PASS)) return; if (await publishedPages.internal({ method, path, res, json, botId: internalSender.id, threadId: internalCapability.threadId, readBody: readInternalBody, requireActive: requireActiveInternalCapability, signal: turnCallSignals.signal(internalCapability, res), folders: botFolders, post: (text, publishedPage, bundle) => { const source = connectorThread(internalSender.id, internalCapability.threadId); return !source ? null : (!source.group && bundle && publishedPages.show({ threadId: internalCapability.threadId, card: publishedPage, bundle })) || store.appendMessage(internalCapability.threadId, { role: "bot", kind: "text", text, publishedPage, ...(source.group ? { from: { botId: internalSender.id, name: internalSender.name, color: internalSender.color } } : {}) }).id; } }) !== PASS) return;
++ const botFolders = async () => ({ roots: messageFileRootsForThread(internalSender.id, internalCapability.threadId).filter((root) => root !== ATTACHMENTS_DIR), vmWorkspace: (await attachmentVmForTurn(internalCapability))?.workspaceDir ?? null }); if (await lentMcp.route({ method, path, req, res, json, turn: internalCapability, readBody: readInternalBody }) !== PASS || await internalToolRoutes({ method, path, res, json, botId: internalSender.id, threadId: internalCapability.threadId, readBody: readInternalBody, folders: botFolders }) !== PASS || await waitRoutes({ method, path, res, json, botId: internalSender.id, threadId: internalCapability.threadId, readBody: readInternalBody, ...waitTurnChecks(internalCapability, internalSender) }) !== PASS || await teamMessages.internal({ method, path, res, json, botId: internalSender.id, threadId: internalCapability.threadId, readBody: readInternalBody }) !== PASS || await devsReports.internal({ method, path, res, json, botId: internalSender.id, threadId: internalCapability.threadId, readBody: readInternalBody }) !== PASS || (computerAsks && await computerAsks.internal({ method, path, res, json, turn: internalCapability, readBody: readInternalBody }) !== PASS) || await meetingsHost.internal({ method, path, res, json, readBody: readInternalBody, bot: internalSender, threadId: internalCapability.threadId, active: () => internalCapabilityIsActive(internalCapability) }) !== PASS || await imageTools.internal({ method, path, res, json, readBody: readInternalBody, threadId: internalCapability.threadId, requireActive: requireActiveInternalCapability, personTurn: turnOrigin(internalCapability).kind === "user" || (Boolean(roomRun(internalCapability.generation)?.requestMessageId) && guestDrivenTurns.get(internalCapability.threadId) !== internalCapability.generation) }) !== PASS) return; const callSignal = turnCallSignals.signal(internalCapability, res); if (await publishedPages.internal({ method, path, res, json, botId: internalSender.id, threadId: internalCapability.threadId, readBody: readInternalBody, requireActive: requireActiveInternalCapability, signal: callSignal, folders: botFolders, post: (text, publishedPage, bundle) => { const source = connectorThread(internalSender.id, internalCapability.threadId); return !source ? null : (bundle && publishedPages.show({ threadId: internalCapability.threadId, card: publishedPage, bundle, bot: internalSender })) || store.appendMessage(internalCapability.threadId, { role: "bot", kind: "text", text, publishedPage, ...(source.group ? { from: { botId: internalSender.id, name: internalSender.name, color: internalSender.color } } : {}) }).id; } }) !== PASS) return;
const delegatedThisTurn = (taskId: string) => {
(internalCapability.delegatedThisTurn ??= new Set()).add(taskId);
};
@@@ -14410,7 -14562,7 +14409,7 @@@
return json(res, 403, { error: "voice notes are turned off for this bot" });
}
try {
- const audio = await tts.speak(cfg, text, voiceBot.voice, undefined, pagesCall.signal);
- const audio = await tts.speak(cfg, text, voiceBot.voice);
++ const audio = await tts.speak(cfg, text, voiceBot.voice, undefined, callSignal);
// Synthesis can outlive its turn: re-check before saving, so the clip never parks onto a later turn.
requireActiveInternalCapability();
const turnId = liveTurnByThread.get(internalCapability.threadId);
diff --cc server/pages/published-pages.test.ts
index 9c9dce552a,92b708ad6e..320761f1f5
--- a/server/pages/published-pages.test.ts
+++ b/server/pages/published-pages.test.ts
@@@ -5,7 -5,8 +5,8 @@@ import { afterEach, beforeEach, describ
import type { PublishedPageCard } from "../../shared/published-page.ts";
import { FAKE_DESKTOP_TOKEN, FAKE_HOME, FAKE_TOKEN_URL, fakePagesService } from "../testing/fake-pages.ts";
import { applyIncludedPagesMessage, pagesHomeSignature } from "./access.ts";
-import { PageBundleError, readPageBundle } from "./bundle.ts";
+import { PageBundleError, readPageBundle, skippedNote } from "./bundle.ts";
+ import * as bundle from "./bundle.ts";
import { PublishedPagesStore } from "./store.ts";
import { createPublishedPages } from "./service.ts";
import { createPagesInternalRoutes, createPublishedPageRoutes, type AppPages } from "../routes/published-pages.ts";
@@@ -29,7 -30,13 +30,13 @@@ function writeSite(folder: string, file
}
const signIn = () => applyIncludedPagesMessage({ type: "openmausbot:included-pages", access: { url: FAKE_TOKEN_URL, token: FAKE_DESKTOP_TOKEN } });
+ function deferred() {
+ let resolve!: () => void;
+ const promise = new Promise<void>((done) => { resolve = done; });
+ return { promise, resolve };
+ }
+
-function setup(options: { home?: boolean; quota?: number } = {}) {
+function setup(options: { home?: boolean; quota?: number; selfHosted?: boolean; liveRoots?: (botId: string, threadId: string) => readonly string[] | null; paused?: () => boolean } = {}) {
const service = fakePagesService({ quota: options.quota });
const work = join(dir, "work"), data = join(dir, "data");
mkdirSync(work, { recursive: true });
diff --cc server/pages/publisher.ts
index 681991fc24,1636f6f27d..e574c493bc
--- a/server/pages/publisher.ts
+++ b/server/pages/publisher.ts
@@@ -107,27 -92,39 +111,48 @@@ export function createPagePublisher(dep
};
- function publishBundle(input: Pick<PublishInput, "botId" | "threadId" | "title" | "pageId" | "post" | "call">, bundle: PageBundle): Promise<PageOutcome> {
++ // A live republish names its page, so it takes only the page's queue.
+ function publishBundle(input: LivePublish, bundle: PageBundle): Promise<PageOutcome> {
- return serially(JSON.stringify([input.botId, bundle.source]), () => publishNow(input, bundle));
+ const onPage = () => {
+ const target = input.pageId ?? store.fromSource(input.botId, bundle.source)?.pageId;
+ return target ? serially(pageKey(target), () => publishNow(input, bundle, target)) : publishNow(input, bundle);
+ };
+ return input.pageId ? onPage() : serially(JSON.stringify([input.botId, bundle.source]), onPage);
}
- async function publishNow(input: LivePublish, bundle: PageBundle): Promise<PageOutcome> {
- async function publishNow(input: Pick<PublishInput, "botId" | "threadId" | "title" | "pageId" | "post" | "call">, bundle: PageBundle, target?: string): Promise<PageOutcome> {
++ async function publishNow(input: LivePublish, bundle: PageBundle, target?: string): Promise<PageOutcome> {
const title = pageTitle(input.title);
if (!title) return TITLE_REQUIRED;
+ // A republish that waited its turn behind an unpublish, or a publish that turned live off, is no longer wanted.
+ if (input.refresh && !(input.pageId && store.get(input.pageId)?.live)) return { status: 409, text: "The page is no longer live." };
- const remembered = input.pageId ? store.get(input.pageId) : store.fromSource(input.botId, bundle.source);
- const target = input.pageId ?? remembered?.pageId;
+ const remembered = target ? store.get(target) : null;
+ const live = input.live ?? remembered?.live === true;
+ const signature = live ? input.signature ?? null : null;
+ const files = live ? liveFiles(bundle.files) : bundle.files;
- let result = await client.publish({ title, files, ...(target ? { pageId: target } : {}) }, input.call);
++ // A page that may be public is recorded before its upload, so it can always be taken down. Its old fingerprint
++ // stays, so a live page whose upload is uncertain is published again.
++ const uncertainRecord = (page: { pageId: string; url: string }, card: { threadId: string; messageId: string } | null) => store.published({
++ ...page, title, botId: remembered?.botId ?? input.botId, source: bundle.source, card, uncertain: true, live, signature: remembered?.signature ?? null });
+ let pending: string | undefined;
+ const beforeUpload = (page: { pageId: string; url: string }) => {
+ if (store.get(page.pageId)) return;
- store.published({ ...page, title, botId: remembered?.botId ?? input.botId, source: bundle.source, card: null, uncertain: true });
++ uncertainRecord(page, null);
+ pending = page.pageId;
+ };
- let result = await client.publish({ title, files: bundle.files, ...(target ? { pageId: target } : {}), beforeUpload }, input.call);
++ let result = await client.publish({ title, files, ...(target ? { pageId: target } : {}), beforeUpload }, input.call);
// The page this folder was published to before is gone (unpublished, or taken down): it gets a new link.
if (!result.ok && result.reason === "gone" && !input.pageId && target) {
store.forget(target);
- result = await client.publish({ title, files }, input.call);
- result = await client.publish({ title, files: bundle.files, beforeUpload }, input.call);
++ result = await client.publish({ title, files, beforeUpload }, input.call);
}
if (!result.ok) {
+ if (result.uncertain) {
+ const card: PublishedPageCard = { state: "live", title, ...result.uncertain, uncertain: true };
+ const messageId = input.post(cardText(card), card);
- store.published({ ...result.uncertain, title, botId: remembered?.botId ?? input.botId, source: bundle.source, uncertain: true,
- card: messageId ? { threadId: input.threadId, messageId } : null });
++ uncertainRecord(result.uncertain, messageId ? { threadId: input.threadId, messageId } : null);
+ return { status: failureStatus[result.reason], text: cardText(card), card };
+ }
+ if (pending) store.forget(pending);
if (result.reason === "limit") {
const card: PublishedPageCard = { state: "limit", title, message: result.message, ...(result.usage ? { usage: result.usage } : {}), ...(result.upgrade ? { upgrade: true } : {}),
...(result.plan ? { plan: result.plan } : {}) };
@@@ -145,81 -142,47 +170,94 @@@
updated ? `Updated “${title}” at the same link: ${result.url}` : `Published “${title}” at ${result.url}`,
`Page id ${result.pageId}. This account now has ${usageWords(result.usage)}.`,
"A card with the link, Copy link and Unpublish is in the chat. Publishing the same file or folder again updates this same link.",
+ ...(live ? ["It is live: when a file in its folder changes, it is published again by itself (at most once a minute) and open copies reload."] : []),
...(result.badge ? ["Free pages carry a small “Made with MausBot” badge."] : []),
- ...(bundle.skipped.length ? [`Left out ${bundle.skipped.length} file${bundle.skipped.length === 1 ? "" : "s"} a page can't serve: ${bundle.skipped.slice(0, 5).join(", ")}${bundle.skipped.length > 5 ? ", …" : ""}.`] : []),
+ skippedNote(bundle.skipped),
];
- return { status: 200, text: lines.join("\n"), card };
+ return { status: 200, text: lines.filter(Boolean).join("\n"), card };
}
+ async function unpublishNow(pageId: string, call: PagesCall | undefined): Promise<PageOutcome> {
+ const title = store.get(pageId)?.title;
+ const result = await client.unpublish(pageId, call);
+ if (!result.ok && result.reason !== "gone") return { status: failureStatus[result.reason], text: result.message };
+ const card = markUnpublished(pageId, result.ok ? result.usage : null)
+ ?? { state: "unpublished" as const, title: title ?? pageId, pageId, ...(result.ok && result.usage ? { usage: result.usage } : {}) };
+ return { status: 200, text: result.ok ? `Unpublished${title ? ` “${title}”` : ""}. Its link no longer opens.` : "That page was already taken down.", card };
+ }
+
+ // When each live page may next be tried: one that fails to publish waits as long as one that changed, and one whose
+ // folder can't be published as it is waits longer.
+ const nextTry = new Map<string, number>();
+ let refreshing = false;
+
return {
...pages,
+ /** Publishes each live page whose folder changed again, to the same link; how many were published. */
+ async refreshLive(now = Date.now()): Promise<number> {
+ if (refreshing || deps.paused?.()) return 0;
+ refreshing = true;
+ let changed = 0;
+ try {
+ for (const record of store.list().filter((each) => each.live)) {
+ if (now < Math.max(record.updatedAt + LIVE_MIN_MS, nextTry.get(record.pageId) ?? 0)) continue;
+ // The bot is gone or no longer has the folder: the page stays at its link as it is, and stops being republished.
+ const threadId = record.cards.at(-1)?.threadId;
+ if (deps.liveRoots && !(await stillReadable(record.source, threadId ? deps.liveRoots(record.botId, threadId) : null))) {
+ store.published({ ...record, card: null, live: false }, record.updatedAt);
+ continue;
+ }
+ const signature = await pageSignature(record.source);
+ if (signature === null || signature === record.signature) continue;
+ nextTry.set(record.pageId, now + LIVE_MIN_MS);
+ let bundle;
+ try {
+ bundle = await readPageBundle(record.source, [record.source], undefined, { exactRoots: true });
+ } catch (error) {
+ if (!(error instanceof PageBundleError)) throw error;
+ nextTry.set(record.pageId, now + LIVE_BROKEN_MS);
+ continue;
+ }
+ if (bundle.source !== record.source) continue;
+ // A backup or move began while the folder was read: nothing is sent; the folder is read again after it.
+ if (deps.paused?.()) { nextTry.delete(record.pageId); break; }
+ const outcome = await publishBundle({ botId: record.botId, threadId: "", title: record.title, pageId: record.pageId, post: () => null, live: true, signature, refresh: true }, bundle);
+ if (outcome.status === 200) changed++;
+ // Taken down elsewhere: its cards say so, and it stops being published.
+ else if (outcome.status === 410) markUnpublished(record.pageId, null);
+ }
+ } catch (error) {
+ console.error("pages: live page refresh failed", error);
+ } finally {
+ refreshing = false;
+ }
+ return changed;
+ },
+
/** Takes a page down, by its id or the file or folder it came from (with the bot's folders). */
async unpublish(input: { pageId?: string; path?: string; botId?: string; roots?: readonly string[]; call?: PagesCall }): Promise<PageOutcome> {
- let pageId = input.pageId;
+ const pageId = input.pageId;
if (pageId !== undefined && !PAGE_ID.test(pageId)) return { status: 400, text: "page_id must be the id of a page you published, from its link." };
+ const takeDown = (id: string) => serially(pageKey(id), () => unpublishNow(id, input.call));
if (!pageId && input.path && input.botId && input.roots) {
+ const botId = input.botId;
+ const notFound: PageOutcome = { status: 404, text: `No page was published from ${input.path}. Pass the page_id from its link instead.` };
+ let source: string;
try {
- pageId = store.fromSource(input.botId, await pageSource(input.path, input.roots))?.pageId;
+ source = await pageSource(input.path, input.roots);
} catch (error) {
if (!(error instanceof PageBundleError)) throw error;
+ return notFound;
}
- if (!pageId) return { status: 404, text: `No page was published from ${input.path}. Pass the page_id from its link instead.` };
+ return serially(JSON.stringify([botId, source]), async () => {
+ const record = store.fromSource(botId, source);
+ return record ? takeDown(record.pageId) : notFound;
+ });
}
if (!pageId) return { status: 400, text: "Pass the page_id of the page to unpublish, or the path it was published from." };
- const title = store.get(pageId)?.title;
- const result = await client.unpublish(pageId, input.call);
- if (!result.ok && result.reason !== "gone") return { status: failureStatus[result.reason], text: result.message };
- const card = markUnpublished(pageId, result.ok ? result.usage : null)
- ?? { state: "unpublished" as const, title: title ?? pageId, pageId, ...(result.ok && result.usage ? { usage: result.usage } : {}) };
- return { status: 200, text: result.ok ? `Unpublished${title ? ` “${title}”` : ""}. Its link no longer opens.` : "That page was already taken down.", card };
+ const record = store.get(pageId);
+ return record ? serially(JSON.stringify([record.botId, record.source]), () => takeDown(pageId)) : takeDown(pageId);
},
};
}
diff --cc server/pages/store.ts
index a169dd7304,e6da2586e2..58319bdd35
--- a/server/pages/store.ts
+++ b/server/pages/store.ts
@@@ -14,10 -14,7 +14,12 @@@ export interface PublishedPageRecord
cards: Array<{ threadId: string; messageId: string }>;
createdAt: number;
updatedAt: number;
+ /** Published again by itself whenever its folder changes (publish_page `live`). */
+ live?: true;
+ /** The folder's fingerprint when it was last published, for a live page. */
+ signature?: string;
++ /** The upload's answer was lost: the page may be public, and stays listed so it can be unpublished. */
+ uncertain?: boolean;
}
const MAX_RECORDS = 5_000, MAX_CARDS = 50;
@@@ -62,13 -59,11 +64,13 @@@ export class PublishedPagesStore
}
/** Records a publish (a new page or an update) and the card that shows it. */
- published(input: { pageId: string; url: string; title: string; botId: string; source: string; card: { threadId: string; messageId: string } | null; uncertain?: boolean }, now = Date.now()): PublishedPageRecord {
+ published(input: { pageId: string; url: string; title: string; botId: string; source: string; card: { threadId: string; messageId: string } | null;
- live?: boolean; signature?: string | null }, now = Date.now()): PublishedPageRecord {
++ live?: boolean; signature?: string | null; uncertain?: boolean }, now = Date.now()): PublishedPageRecord {
const existing = this.get(input.pageId);
const cards = [...(existing?.cards ?? []), ...(input.card ? [input.card] : [])].slice(-MAX_CARDS);
const record: PublishedPageRecord = { pageId: input.pageId, url: input.url, title: input.title, botId: input.botId, source: input.source, cards,
- createdAt: existing?.createdAt ?? now, updatedAt: now, ...(input.uncertain ? { uncertain: true } : {}) };
+ createdAt: existing?.createdAt ?? now, updatedAt: now,
- ...(input.live ? { live: true as const, ...(input.signature ? { signature: input.signature } : {}) } : {}) };
++ ...(input.live ? { live: true as const, ...(input.signature ? { signature: input.signature } : {}) } : {}), ...(input.uncertain ? { uncertain: true } : {}) };
this.records = [...this.records.filter((each) => each.pageId !== input.pageId), record].slice(-MAX_RECORDS);
this.save();
return record;
diff --cc src/locales/pt-br.json
index 0727fd67f3,6432bfef13..6b1b22bc53
--- a/src/locales/pt-br.json
+++ b/src/locales/pt-br.json
@@@ -7222,10 -6154,10 +7222,11 @@@
"chat.page.open": "Abrir",
"chat.page.unpublish": "Tirar do ar",
"chat.page.unpublished": "Tirada do ar. O link não abre mais.",
- "chat.page.unpublishFailed": "Não deu para tirar esta página do ar. Tente de novo daqui a pouco.",
- "chat.page.freeLimit": "Você já usou suas {limit} páginas grátis. O MausBot Cloud dá mais, e páginas sem o selo.",
- "chat.page.planLimit": "Você usou todas as {limit} páginas do seu plano {plan}. Tire uma página do ar para abrir espaço.",
- "chat.page.morePages": "Ter mais páginas",
++ "chat.page.uncertain": "Esta página pode estar no ar. Tire do ar para removê-la.",
+ "chat.page.unpublishFailed": "Não foi possível tirar esta página do ar. Tente novamente em instantes.",
+ "chat.page.freeLimit": "Você chegou ao limite de páginas grátis: {limit}. Com o MausBot Cloud, você tem mais páginas, sem o selo.",
+ "chat.page.planLimit": "Você chegou ao limite de páginas do plano {plan}: {limit}. Tire uma página do ar para abrir espaço.",
+ "chat.page.morePages": "Obter mais páginas",
"chat.preview.older": "Versão anterior",
"chat.preview.newer": "Versão seguinte",
"chat.preview.version": "v{n}",