@dev.fast/whiteboard 0.4.1-preview.20261026.140 → 0.4.1-preview.20261028.142
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.
- package/dist/{account-alias-DpQNSiaM.js → account-alias-D1iIc7j5.js} +4 -5
- package/dist/{agent-cli-z_qF_J8n.js → agent-cli-B_gSzrhA.js} +8 -9
- package/dist/agent-cli-DtjnkDSL.js +2 -0
- package/dist/{agent-client-3980WBdQ.js → agent-client-DudPjH3I.js} +3 -3
- package/dist/{authoring-tools-CphR87Aa.js → authoring-tools-B-OyXmtR.js} +5 -5
- package/dist/{background-server-GMGjm8xu.js → background-server-CORnMQmu.js} +1 -1
- package/dist/{background-server-Dq8Zf4OM.js → background-server-CesuMV6N.js} +7 -6
- package/dist/build-info.json +1 -1
- package/dist/{cli-BPd7DLd-.js → cli-CIP_-Fvm.js} +1 -1
- package/dist/{cli-runner-iHNaGXZg.js → cli-runner-dHnKnyNw.js} +22 -23
- package/dist/cli.js +2 -2
- package/dist/{fuzzy-match-bbbTSBPK.js → fuzzy-match-CTvayutE.js} +3 -3
- package/dist/{headless-host-BEdTaS2j.js → headless-host-CWuFw-CO.js} +147 -231
- package/dist/{headless-host-CpqwtaaX.js → headless-host-Cnu-o0xk.js} +1 -1
- package/dist/{import-DG435Ifj.js → import-FOpJL22V.js} +198 -505
- package/dist/{lens-selection-fz59ca6x.js → lens-selection-B_LTVyTB.js} +1 -1
- package/dist/{local-data-C4TFet-6.js → local-data-BhNZ1Yep.js} +72 -91
- package/dist/{mcp-C__btJSK.js → mcp-2bWqlJNW.js} +3 -3
- package/dist/{package-paths-LcO6HNp_.js → package-paths-Cg6fnaGp.js} +1 -1
- package/dist/profile-BmtFpq8d.js +2 -0
- package/dist/{profile-Bpsilnd7.js → profile-DnwIJvlh.js} +2 -2
- package/dist/{remote-attach-BM9FaV1Q.js → remote-attach-C79X5M2Z.js} +4 -4
- package/dist/{remote-extensions-VLpt_4Tn.js → remote-extensions-Bw029iIS.js} +1 -1
- package/dist/{remote-extensions-DMKyDjAs.js → remote-extensions-MUUgbLJn.js} +2 -2
- package/dist/{remote-language-server-c4fdgeA8.js → remote-language-server-Dw1o27aF.js} +4 -4
- package/dist/{remote-uninstall-DvBENfrg.js → remote-uninstall-Aza0u1_3.js} +5 -5
- package/dist/{request-origin-CtTmXRoS.js → request-origin-DEQd09Db.js} +3 -3
- package/dist/{review-app-launcher-CffrNlrU.js → review-app-launcher-L7xKjTLQ.js} +2 -2
- package/dist/{src-KTjWplV9.js → review-home-paths-LdGS4SpR.js} +48 -8
- package/dist/{review-telemetry-_54CVkjH.js → review-telemetry-lmK8HPLI.js} +4 -5
- package/dist/{runtime-5WG8rRgg.js → runtime-Bhk5L_SN.js} +1 -1
- package/dist/runtime.js +1 -1
- package/dist/server/desktop-host.js +34 -48
- package/dist/{server-discovery-BjelO8cl.js → server-discovery-D-2vz5gG.js} +2 -3
- package/dist/sharing/index.d.ts +51 -144
- package/dist/sharing/index.js +2 -2
- package/dist/{src-D0h06Qsl.js → src-Bew3mW9I.js} +7 -2
- package/dist/{src-BTCRHmRM.js → src-Y30gweiK.js} +7 -1
- package/dist/{stored-document-migration-B2Wp1ePB.js → stored-document-migration-CZe65mkx.js} +20 -6
- package/dist/{thread-state-Dbs5siMf.js → thread-state-XgVKaQ3-.js} +1 -1
- package/dist/{tool-failure-pgc2CD1C.js → tool-failure-Bi_-Zck-.js} +2 -2
- package/instructions/animation.md +18 -68
- package/instructions/authoring.md +1 -1
- package/package.json +4 -4
- package/src/review-api/README.md +5 -5
- package/src/review-api/ask-history.ts +3 -13
- package/src/review-api/authoring-tools.ts +2 -2
- package/src/review-api/blocks/animation.ts +50 -0
- package/src/review-api/http.ts +259 -414
- package/src/review-api/local-data.ts +24 -53
- package/src/review-api/onboarding.ts +29 -2
- package/src/review-api/review-progress.ts +1 -5
- package/src/review-api/store.ts +95 -16
- package/src/review-api/workspaces.ts +17 -48
- package/src/review-checkout-paths.ts +2 -5
- package/src/review-head-checkout.ts +3 -14
- package/src/server/background-server.ts +4 -2
- package/src/server/desktop-host.ts +17 -9
- package/src/server/desktop-server.ts +4 -6
- package/src/server/json-review-reporting.ts +4 -23
- package/src/server/review-gateway-pushes.ts +1 -10
- package/src/server/review-server-core.ts +8 -13
- package/src/sharing/client.ts +86 -2
- package/src/sharing/host.ts +111 -88
- package/src/sharing/import.ts +173 -710
- package/src/sharing/index.ts +1 -7
- package/src/sharing/repository.ts +18 -49
- package/dist/agent-cli-D4JapSBa.js +0 -2
- package/dist/profile-DPqMPFYS.js +0 -2
- package/dist/review-home-paths-CjHB5c8m.js +0 -39
- package/src/sharing/routes.ts +0 -35
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import { b as resolveRepoContext, d as git, r as defaultBranch, w as runVcs } from "./src-
|
|
1
|
+
import { b as resolveRepoContext, d as git, r as defaultBranch, w as runVcs } from "./src-Y30gweiK.js";
|
|
2
2
|
import { c as jsonString, m as isStringValue, n as isJsonObject, p as isObjectValue, u as parseJsonText } from "./src-X9phtB2j.js";
|
|
3
|
-
import { _ as
|
|
4
|
-
import { d as invalidateStructuralComparisons, f as diffrExecutable, i as inspectSnapshot, m as readGitHubPullRequests, p as diffrMissingError, r as commandSchema } from "./local-data-
|
|
5
|
-
import { I as decodeStructuralDiffEvent, N as reviewDiffrLoginsSchema, O as ReviewFeedbackContactSchema, P as reviewDiffrSummarizerInputSchema, a as parseReviewVerbRequest, c as boardIconKind, i as parseReviewDesktopVerbResult, j as ReviewOnboardingRunRequestSchema, k as ReviewFeedbackSchema, l as boardTitle, m as REVIEW_CLIENT_REMOTE, p as REVIEW_CLIENT_HEADER, y as REVIEW_HOST_HEADER } from "./src-
|
|
6
|
-
import {
|
|
7
|
-
import { _ as scopedCoverage, s as formatAnchor, u as selectionKey } from "./lens-selection-
|
|
8
|
-
import {
|
|
3
|
+
import { _ as parseShareLink, a as readShareRepository, c as exportShare, d as lensReport, f as progressUpdateSchema, g as readBoundedStream, h as StreamLimitError, i as forgetSharedCommits, l as validateShareSources, m as uncategorizedReport, n as shareKey, o as ShareAuthError, p as reviewProgress, s as ShareClient, t as importShare, u as legacyModeSchema, v as shareIdSchema } from "./import-FOpJL22V.js";
|
|
4
|
+
import { d as invalidateStructuralComparisons, f as diffrExecutable, i as inspectSnapshot, m as readGitHubPullRequests, p as diffrMissingError, r as commandSchema } from "./local-data-BhNZ1Yep.js";
|
|
5
|
+
import { I as decodeStructuralDiffEvent, N as reviewDiffrLoginsSchema, O as ReviewFeedbackContactSchema, P as reviewDiffrSummarizerInputSchema, a as parseReviewVerbRequest, c as boardIconKind, i as parseReviewDesktopVerbResult, j as ReviewOnboardingRunRequestSchema, k as ReviewFeedbackSchema, l as boardTitle, m as REVIEW_CLIENT_REMOTE, p as REVIEW_CLIENT_HEADER, y as REVIEW_HOST_HEADER } from "./src-Bew3mW9I.js";
|
|
6
|
+
import { B as TraceStorageDeniedError, D as listReviewTraceSessions, I as isTraceStorageConfigured, O as loadReviewAgentTrace, R as resolveTraceStorage, T as traceMachineEnabled, at as readStoreAuth, et as shellQuote, it as clearStoreAuth, ot as runStoreLogin, rt as DEFAULT_STORE_ORIGIN, z as selectTraceStorage } from "./review-home-paths-LdGS4SpR.js";
|
|
7
|
+
import { _ as scopedCoverage, s as formatAnchor, u as selectionKey } from "./lens-selection-B_LTVyTB.js";
|
|
8
|
+
import { K as selectionReferences, M as elements, O as boardRepositoryId, Z as stepSources, f as sourceBranchName, l as pullRequestKey, p as pullRequestProvider, w as anchorPins } from "./stored-document-migration-CZe65mkx.js";
|
|
9
9
|
import { t as ReviewInputError } from "./input-error-OLgB_h31.js";
|
|
10
10
|
import { A as processStartIdentity, L as writePrivateJsonAtomic, N as devReviewHome, h as TraceConfigurationError, i as isS3MockMode, j as withFileLock } from "./s3-config-CjcLyFV5.js";
|
|
11
11
|
import { t as errorMessage } from "./error-message-OtiDonty.js";
|
|
12
|
-
import { i as readReviewPackageVersion, n as readBuildCommit, t as findReviewPackageRoot } from "./package-paths-
|
|
13
|
-
import "./
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { t as
|
|
17
|
-
import {
|
|
18
|
-
import { a as
|
|
19
|
-
import { a as
|
|
20
|
-
import { a as headlessServerOwner, c as stopBackgroundServer, o as recordedBackgroundServer } from "./background-server-Dq8Zf4OM.js";
|
|
12
|
+
import { i as readReviewPackageVersion, n as readBuildCommit, t as findReviewPackageRoot } from "./package-paths-Cg6fnaGp.js";
|
|
13
|
+
import { _ as reviewInstanceIdentity, n as desktopOwnsHome, o as reviewServerDiscoveryPath, p as desktopUsesHome, r as headlessServerLockPath, t as DESKTOP_TAKEOVER_SIGNAL } from "./server-discovery-D-2vz5gG.js";
|
|
14
|
+
import { c as askPicksSchema, d as selectionMarkdown, l as askQuestionSchema, n as askAgentIds, r as askChoiceKinds, s as askPermissionsSchema, t as applyAskChange, u as AgentSelectionSchema } from "./thread-state-XgVKaQ3-.js";
|
|
15
|
+
import { t as openReviewProfile } from "./profile-DnwIJvlh.js";
|
|
16
|
+
import { c as REVIEW_APP_SESSION_ID_HEADER, d as sanitizeUiTelemetryEvent, f as cleanTelemetryText, o as reviewRequestOrigin, r as REVIEW_PERSON_HEADER, s as BUNDLE_FRAME_PATTERN, t as ASK_THREAD_ENV, u as isReportableCleanedMessage } from "./request-origin-DEQd09Db.js";
|
|
17
|
+
import { a as defaultAskPermissions, i as askAgents, l as launchAskAgent, n as askAgentSettings, o as detectAskAgents, r as askAgentTakesMcp, t as fuzzyRank } from "./fuzzy-match-CTvayutE.js";
|
|
18
|
+
import { a as inspectQuerySchema, i as renderInstructions, o as queryAnchor, r as instructionsQuerySchema, s as readQuerySchemas, t as authoringTools } from "./authoring-tools-B-OyXmtR.js";
|
|
19
|
+
import { a as headlessServerOwner, c as stopBackgroundServer, o as recordedBackgroundServer } from "./background-server-CesuMV6N.js";
|
|
21
20
|
import crypto$1, { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
22
21
|
import { z } from "zod";
|
|
23
22
|
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
@@ -2610,18 +2609,30 @@ const publishSchema = z.strictObject({
|
|
|
2610
2609
|
requestId: z.uuid().optional()
|
|
2611
2610
|
});
|
|
2612
2611
|
/** Mounted behind local host authentication. Account credentials never enter the renderer. */
|
|
2613
|
-
function mountSharingHost(app, store, data,
|
|
2612
|
+
function mountSharingHost(app, store, data, options = {}) {
|
|
2614
2613
|
const startLogin = options.login ?? runStoreLogin;
|
|
2615
2614
|
let login = { pending: false };
|
|
2616
|
-
|
|
2615
|
+
let warmedAt = 0;
|
|
2616
|
+
const readAccount = async () => {
|
|
2617
2617
|
const account = await readStoreAuth();
|
|
2618
|
-
|
|
2618
|
+
if (account && Date.now() - warmedAt > 6e4) {
|
|
2619
|
+
warmedAt = Date.now();
|
|
2620
|
+
new ShareClient(account.origin, account.token, options.fetch).warm().catch(() => {});
|
|
2621
|
+
}
|
|
2622
|
+
return {
|
|
2619
2623
|
account: account ? {
|
|
2620
2624
|
login: account.login,
|
|
2621
|
-
origin: account.origin
|
|
2625
|
+
origin: account.origin,
|
|
2626
|
+
email: account.email,
|
|
2627
|
+
githubLogin: account.githubLogin
|
|
2622
2628
|
} : null,
|
|
2623
2629
|
...login
|
|
2624
|
-
}
|
|
2630
|
+
};
|
|
2631
|
+
};
|
|
2632
|
+
app.get("/sharing/account", async (context) => context.json(await readAccount()));
|
|
2633
|
+
app.post("/sharing/logout", async (context) => {
|
|
2634
|
+
await clearStoreAuth();
|
|
2635
|
+
return context.json(await readAccount());
|
|
2625
2636
|
});
|
|
2626
2637
|
app.post("/sharing/login", async (context) => {
|
|
2627
2638
|
if (!login.pending) {
|
|
@@ -2654,52 +2665,61 @@ function mountSharingHost(app, store, data, shared, options = {}) {
|
|
|
2654
2665
|
});
|
|
2655
2666
|
mountSharingPublisher(app, store, data, options);
|
|
2656
2667
|
const imports = /* @__PURE__ */ new Map();
|
|
2668
|
+
let importing = Promise.resolve();
|
|
2657
2669
|
app.get("/sharing/import/:id", (context) => {
|
|
2658
2670
|
const id = context.req.param("id");
|
|
2659
|
-
const status =
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
...status
|
|
2671
|
+
const { reviewId = id, ...status } = imports.get(id) ?? {
|
|
2672
|
+
stage: "error",
|
|
2673
|
+
error: "Shared review is not available."
|
|
2663
2674
|
};
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2675
|
+
return context.json({
|
|
2676
|
+
reviewId,
|
|
2677
|
+
...status,
|
|
2678
|
+
...status.stage === "ready" && { title: store.read(reviewId).title }
|
|
2667
2679
|
});
|
|
2668
|
-
return context.json(result);
|
|
2669
2680
|
});
|
|
2670
2681
|
app.post("/sharing/import", async (context) => {
|
|
2671
2682
|
const { url } = z.strictObject({ url: z.string().max(2048) }).parse(await readBoundedRequestJson(context.req.raw));
|
|
2672
2683
|
const parsed = parseShareLink(url);
|
|
2673
2684
|
const account = await readStoreAuth();
|
|
2674
2685
|
if (parsed.origin !== DEFAULT_STORE_ORIGIN && parsed.origin !== account?.origin) throw new ReviewInputError("This share uses an untrusted service. Sign in to that service before opening its links.", 400);
|
|
2675
|
-
const id =
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
const
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2686
|
+
const id = shareKey(parsed.origin, parsed.capability);
|
|
2687
|
+
const known = imports.get(id)?.stage;
|
|
2688
|
+
if (!known || known === "ready" || known === "error") {
|
|
2689
|
+
const copy = store.copyOf(id);
|
|
2690
|
+
const status = copy ? {
|
|
2691
|
+
stage: "ready",
|
|
2692
|
+
reviewId: copy
|
|
2693
|
+
} : { stage: "downloading" };
|
|
2694
|
+
imports.set(id, status);
|
|
2695
|
+
if (!copy) importing = importing.then(async () => {
|
|
2683
2696
|
const { bundle, attribution } = await new ShareClient(parsed.origin).download(parsed.capability);
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2697
|
+
status.reviewId = await importShare({
|
|
2698
|
+
store,
|
|
2699
|
+
data,
|
|
2700
|
+
fetchRepository: options.fetchRepository,
|
|
2701
|
+
cloneRepository: options.cloneRepository,
|
|
2702
|
+
onStage: (stage) => {
|
|
2703
|
+
status.stage = stage;
|
|
2704
|
+
}
|
|
2705
|
+
}, id, bundle, attribution);
|
|
2706
|
+
status.stage = "ready";
|
|
2707
|
+
}).catch((error) => {
|
|
2708
|
+
status.stage = "error";
|
|
2709
|
+
status.error = error instanceof ReviewInputError ? error.message : "This share is unavailable, revoked, or needs a newer Whiteboard version.";
|
|
2710
|
+
});
|
|
2690
2711
|
}
|
|
2712
|
+
const { reviewId: _reviewId, ...status } = imports.get(id);
|
|
2691
2713
|
return context.json({
|
|
2692
2714
|
reviewId: id,
|
|
2693
|
-
...
|
|
2715
|
+
...status
|
|
2694
2716
|
}, 202);
|
|
2695
2717
|
});
|
|
2696
2718
|
}
|
|
2697
2719
|
/** Publishing needs only an authored store, never Desktop or recipient workspaces. */
|
|
2698
2720
|
function mountSharingPublisher(app, store, data, options = {}) {
|
|
2699
|
-
const verifyRepository = options.verifyRepository ?? verifyShareRepository;
|
|
2700
2721
|
app.post("/sharing/publish", async (context) => {
|
|
2701
2722
|
const input = publishSchema.parse(await readBoundedRequestJson(context.req.raw));
|
|
2702
|
-
if (input.reviewId.startsWith("shared-")) throw new ReviewInputError("Only the authoring review can be shared.", 409);
|
|
2703
2723
|
const snapshot = store.read(input.reviewId, input.version);
|
|
2704
2724
|
if (snapshot.target?.kind === "worktree") throw new ReviewInputError("Pin this review to commits before sharing it.");
|
|
2705
2725
|
validateShareSources(snapshot);
|
|
@@ -2707,18 +2727,7 @@ function mountSharingPublisher(app, store, data, options = {}) {
|
|
|
2707
2727
|
if (!account) throw new ReviewInputError("Set DEV_REVIEW_SHARE_TOKEN for CI, or run whiteboard login before sharing.", 409);
|
|
2708
2728
|
const repositoryId = snapshot.pins?.repositoryId ?? snapshot.target?.repositoryId;
|
|
2709
2729
|
const root = repositoryId ? store.repositoryPath(repositoryId) : void 0;
|
|
2710
|
-
const
|
|
2711
|
-
const commits = referenceCommits(snapshot);
|
|
2712
|
-
const repository = (async () => {
|
|
2713
|
-
if (!root) return void 0;
|
|
2714
|
-
try {
|
|
2715
|
-
const repository = await readRepository(root);
|
|
2716
|
-
if (snapshot.pins || commits.length) await verifyRepository(root, snapshot.pins, commits);
|
|
2717
|
-
return repository;
|
|
2718
|
-
} catch {
|
|
2719
|
-
return;
|
|
2720
|
-
}
|
|
2721
|
-
})();
|
|
2730
|
+
const repository = root ? (options.readRepository ?? readShareRepository)(root).catch(() => void 0) : void 0;
|
|
2722
2731
|
const bundle = await exportShare({
|
|
2723
2732
|
store,
|
|
2724
2733
|
data,
|
|
@@ -2762,32 +2771,6 @@ function mountSharingPublisher(app, store, data, options = {}) {
|
|
|
2762
2771
|
});
|
|
2763
2772
|
}
|
|
2764
2773
|
//#endregion
|
|
2765
|
-
//#region src/sharing/routes.ts
|
|
2766
|
-
/** Snapshot-backed reads used by the same HTTP routes as local reviews. */
|
|
2767
|
-
var SharedReviewData = class {
|
|
2768
|
-
store;
|
|
2769
|
-
constructor(store) {
|
|
2770
|
-
this.store = store;
|
|
2771
|
-
}
|
|
2772
|
-
map(id, resourceId) {
|
|
2773
|
-
const { maps } = this.store.get(id);
|
|
2774
|
-
if (!Object.hasOwn(maps, resourceId)) throw new ReviewInputError("Map is not included in this share.", 404);
|
|
2775
|
-
return maps[resourceId];
|
|
2776
|
-
}
|
|
2777
|
-
async resource(id, resourceId) {
|
|
2778
|
-
const { bundle } = this.store.get(id);
|
|
2779
|
-
if (Object.hasOwn(bundle.images, resourceId)) return {
|
|
2780
|
-
data: Buffer.from(bundle.images[resourceId].png, "base64"),
|
|
2781
|
-
mimeType: "image/png"
|
|
2782
|
-
};
|
|
2783
|
-
if (Object.hasOwn(bundle.traces, resourceId)) return {
|
|
2784
|
-
data: Buffer.from(JSON.stringify(bundle.traces[resourceId])),
|
|
2785
|
-
mimeType: "application/json"
|
|
2786
|
-
};
|
|
2787
|
-
throw new ReviewInputError("Resource is not included in this share.", 404);
|
|
2788
|
-
}
|
|
2789
|
-
};
|
|
2790
|
-
//#endregion
|
|
2791
2774
|
//#region src/review-api/anchor-quotes.ts
|
|
2792
2775
|
const QUOTE_LIMIT = 20;
|
|
2793
2776
|
const clip = (line) => line.trim() === "" ? "(blank line)" : line.length > 120 ? `${line.slice(0, 119)}…` : line;
|
|
@@ -3034,7 +3017,8 @@ async function recentFolders(input = {}) {
|
|
|
3034
3017
|
//#region src/review-api/onboarding.ts
|
|
3035
3018
|
const COMMAND_TIMEOUT_MS = 15e3;
|
|
3036
3019
|
const PULL_REQUEST_LIMIT = 10;
|
|
3037
|
-
/**
|
|
3020
|
+
/** Where the reader picks nothing; ignored when the agent does not offer
|
|
3021
|
+
* the model. */
|
|
3038
3022
|
const RUN_PICKS = {
|
|
3039
3023
|
claude: { model: "sonnet" },
|
|
3040
3024
|
codex: { model: "gpt-6-luna" }
|
|
@@ -3285,6 +3269,14 @@ async function runContext(ask, agent, threadId, reviewId) {
|
|
|
3285
3269
|
* it, and start an agent drawing it in its Ask panel. */
|
|
3286
3270
|
function registerOnboardingRoutes(app, store, ask, host, run = runCommand) {
|
|
3287
3271
|
app.get("/onboarding/agents", async (context) => context.json({ agents: await ask.agents() }));
|
|
3272
|
+
app.get("/onboarding/agents/:agent/offer", async (context) => {
|
|
3273
|
+
const agent = z.enum(askAgentIds).parse(context.req.param("agent"));
|
|
3274
|
+
const { path: directory, model } = z.object({
|
|
3275
|
+
path: z.string().min(1),
|
|
3276
|
+
model: askPicksSchema.shape.model
|
|
3277
|
+
}).parse(context.req.query());
|
|
3278
|
+
return context.json({ offer: await host.offer(agent, model ?? RUN_PICKS[agent]?.model, async () => directory) });
|
|
3279
|
+
});
|
|
3288
3280
|
app.get("/onboarding/projects", async (context) => context.json({ projects: await onboardingProjects([...store.repositories().map((repository) => repository.path), ...await recentFolders()], { run }) }));
|
|
3289
3281
|
app.get("/onboarding/targets", async (context) => {
|
|
3290
3282
|
const directory = context.req.query("path");
|
|
@@ -3345,7 +3337,10 @@ function registerOnboardingRoutes(app, store, ask, host, run = runCommand) {
|
|
|
3345
3337
|
head,
|
|
3346
3338
|
selection: { title },
|
|
3347
3339
|
context: await runContext(ask, input.agent, id, reviewId),
|
|
3348
|
-
picks:
|
|
3340
|
+
picks: {
|
|
3341
|
+
...RUN_PICKS[input.agent],
|
|
3342
|
+
...input.picks
|
|
3343
|
+
},
|
|
3349
3344
|
question: { text: input.prompt }
|
|
3350
3345
|
});
|
|
3351
3346
|
host.handOff(reviewId, id);
|
|
@@ -3482,7 +3477,7 @@ const PERSON_EDIT_MAX_BYTES = 16777216;
|
|
|
3482
3477
|
/** A request the gateway forwarded from another machine. */
|
|
3483
3478
|
const remoteCaller = (context) => context.req.header(REVIEW_CLIENT_HEADER) === REVIEW_CLIENT_REMOTE;
|
|
3484
3479
|
/** Both hosts mount this behind their token authentication. */
|
|
3485
|
-
function createReviewApi(store, data, open,
|
|
3480
|
+
function createReviewApi(store, data, open, sharing = false, capabilities = () => ({
|
|
3486
3481
|
desktopAvailable: Boolean(open),
|
|
3487
3482
|
softwareMapEnabled: false
|
|
3488
3483
|
}), traceEnabled = async () => false, status = () => ({}), hooks = {}, ask, animationsEnabled = () => false) {
|
|
@@ -3501,38 +3496,12 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
3501
3496
|
if (context.req.method === "GET" && !context.req.query("version")) await store.refreshWorktrees();
|
|
3502
3497
|
await next();
|
|
3503
3498
|
});
|
|
3504
|
-
const
|
|
3505
|
-
|
|
3506
|
-
const assertWritable = (id) => {
|
|
3507
|
-
if (isShared(id)) shared?.assertWritable(id);
|
|
3508
|
-
else store.assertWritable(id);
|
|
3509
|
-
};
|
|
3510
|
-
const reviewAccess = (access) => async (context, next) => {
|
|
3511
|
-
const id = context.req.param("id");
|
|
3512
|
-
if (access !== "read") assertWritable(id);
|
|
3513
|
-
if (access === "edit" && isShared(id)) throw new ReviewInputError("Shared reviews are read-only.", 409);
|
|
3499
|
+
const writable = async (context, next) => {
|
|
3500
|
+
store.assertWritable(context.req.param("id"));
|
|
3514
3501
|
await next();
|
|
3515
3502
|
};
|
|
3516
|
-
|
|
3517
|
-
const
|
|
3518
|
-
const id = context.req.param("id");
|
|
3519
|
-
if (!id || !isShared(id)) return next();
|
|
3520
|
-
const query = readQuerySchemas.get.parse({ version: context.req.query("version") });
|
|
3521
|
-
readReview(id, query.version);
|
|
3522
|
-
return next();
|
|
3523
|
-
};
|
|
3524
|
-
app.use("/:id", sharedGuard);
|
|
3525
|
-
app.use("/:id/*", sharedGuard);
|
|
3526
|
-
if (shared && data) {
|
|
3527
|
-
shared.connect(store, data);
|
|
3528
|
-
mountSharingHost(app, store, data, shared, hooks.sharing);
|
|
3529
|
-
}
|
|
3530
|
-
const readReview = (id, version) => {
|
|
3531
|
-
if (!id.startsWith("shared-")) return store.read(id, version);
|
|
3532
|
-
const snapshot = shared?.get(id).snapshot;
|
|
3533
|
-
if (!snapshot || version !== void 0 && version !== snapshot.version) throw new ReviewInputError("Shared review version is unavailable.", 404);
|
|
3534
|
-
return snapshot;
|
|
3535
|
-
};
|
|
3503
|
+
if (sharing && data) mountSharingHost(app, store, data, hooks.sharing);
|
|
3504
|
+
const readReview = (id, version) => store.read(id, version);
|
|
3536
3505
|
/** Adds a PR board's state, as this host last read it from GitHub. */
|
|
3537
3506
|
const withPullRequestState = (board) => {
|
|
3538
3507
|
const state = data?.pullRequestState(board.origin?.pullRequestUrl ?? board.pullRequestUrl);
|
|
@@ -3541,11 +3510,11 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
3541
3510
|
pullRequestState: state
|
|
3542
3511
|
} : board;
|
|
3543
3512
|
};
|
|
3544
|
-
const catalog = () =>
|
|
3513
|
+
const catalog = () => store.list().map(withPullRequestState);
|
|
3545
3514
|
/** Where a board sits among its project's, and its PR's facts, for the
|
|
3546
3515
|
* board's header. */
|
|
3547
3516
|
const placeOf = (id) => {
|
|
3548
|
-
if (
|
|
3517
|
+
if (!store.has(id)) return { siblings: [] };
|
|
3549
3518
|
const { board, parent, siblings, children } = store.place(id);
|
|
3550
3519
|
const url = board.origin?.pullRequestUrl;
|
|
3551
3520
|
const state = data?.pullRequestState(url);
|
|
@@ -3602,7 +3571,7 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
3602
3571
|
}
|
|
3603
3572
|
return context.json(await reviewProgress(store, data, snapshot, context.req.raw.signal));
|
|
3604
3573
|
});
|
|
3605
|
-
app.post("/:id/progress",
|
|
3574
|
+
app.post("/:id/progress", writable, async (context) => {
|
|
3606
3575
|
if (!data) throw new ReviewInputError("Source data is unavailable.", 409);
|
|
3607
3576
|
const input = progressUpdateSchema.parse(await readBoundedRequestJson(context.req.raw));
|
|
3608
3577
|
const id = context.req.param("id");
|
|
@@ -3643,16 +3612,13 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
3643
3612
|
app.get("/:id/activity", (context) => {
|
|
3644
3613
|
const id = context.req.param("id");
|
|
3645
3614
|
readReview(id);
|
|
3646
|
-
return context.json(
|
|
3647
|
-
workingCount: 0,
|
|
3648
|
-
expiresAt: null
|
|
3649
|
-
} : store.activity.read(id));
|
|
3615
|
+
return context.json(store.activity.read(id));
|
|
3650
3616
|
});
|
|
3651
3617
|
for (const action of [
|
|
3652
3618
|
"begin",
|
|
3653
3619
|
"update",
|
|
3654
3620
|
"end"
|
|
3655
|
-
]) app.post(`/:id/activity/${action}`,
|
|
3621
|
+
]) app.post(`/:id/activity/${action}`, writable, async (context) => {
|
|
3656
3622
|
const input = await readBoundedRequestJson(context.req.raw);
|
|
3657
3623
|
const id = context.req.param("id");
|
|
3658
3624
|
store.assertExists(id);
|
|
@@ -3682,13 +3648,13 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
3682
3648
|
let sentList;
|
|
3683
3649
|
const linksRevision = /* @__PURE__ */ new Map();
|
|
3684
3650
|
const linksKey = (id) => {
|
|
3685
|
-
if (!data ||
|
|
3651
|
+
if (!data || !store.has(id)) return "";
|
|
3686
3652
|
const { outgoing, backlinks } = store.links(id);
|
|
3687
3653
|
return JSON.stringify([...outgoing, ...backlinks].map((link) => link.pullRequestUrl && data.pullRequestState(link.pullRequestUrl, { seen: false })));
|
|
3688
3654
|
};
|
|
3689
3655
|
const linksKeys = new Map([...reviewIds].map((reviewId) => [reviewId, linksKey(reviewId)]));
|
|
3690
3656
|
const placeKey = (id) => {
|
|
3691
|
-
const project =
|
|
3657
|
+
const project = store.summary(id)?.project;
|
|
3692
3658
|
const branches = project ? store.listProject(project.id).filter(({ origin }) => origin?.branch).map(({ reviewId, origin, trashedAt }) => [
|
|
3693
3659
|
reviewId,
|
|
3694
3660
|
origin,
|
|
@@ -3788,9 +3754,6 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
3788
3754
|
}
|
|
3789
3755
|
if (marked) notify();
|
|
3790
3756
|
}) ?? (() => {}),
|
|
3791
|
-
shared?.subscribe(() => {
|
|
3792
|
-
if (markLists()) notify();
|
|
3793
|
-
}) ?? (() => {}),
|
|
3794
3757
|
store.subscribeCatalog(() => {
|
|
3795
3758
|
const marked = refreshPlaces();
|
|
3796
3759
|
if (markLists() || marked) notify();
|
|
@@ -3808,7 +3771,7 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
3808
3771
|
});
|
|
3809
3772
|
let environmentIssues;
|
|
3810
3773
|
try {
|
|
3811
|
-
if (review.target?.kind === "commits" && review.pins) data?.workspaces.
|
|
3774
|
+
if (review.target?.kind === "commits" && review.pins) data?.workspaces.source(review.reviewId, review.pins).catch(() => {});
|
|
3812
3775
|
environmentIssues = data?.currentEnvironmentIssues(review);
|
|
3813
3776
|
} catch (error) {
|
|
3814
3777
|
environmentIssues = [{ message: `Could not check language checkouts: ${errorMessage(error)}. Recheck with review_environment.` }];
|
|
@@ -3836,12 +3799,10 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
3836
3799
|
};
|
|
3837
3800
|
}
|
|
3838
3801
|
};
|
|
3839
|
-
app.post("/:id/open",
|
|
3840
|
-
const id = context.req.param("id");
|
|
3841
|
-
if (isShared(id)) await shared?.assertReady(id);
|
|
3802
|
+
app.post("/:id/open", writable, async (context) => {
|
|
3842
3803
|
return context.json({
|
|
3843
3804
|
ok: true,
|
|
3844
|
-
...await openReview(readReview(id))
|
|
3805
|
+
...await openReview(readReview(context.req.param("id")))
|
|
3845
3806
|
});
|
|
3846
3807
|
});
|
|
3847
3808
|
if (data) {
|
|
@@ -3868,9 +3829,8 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
3868
3829
|
}, result.status);
|
|
3869
3830
|
return context.json(result);
|
|
3870
3831
|
});
|
|
3871
|
-
app.post("/:id/navigator",
|
|
3872
|
-
const input = readQuerySchemas.file.extend({
|
|
3873
|
-
side: z.enum(["base", "head"]).default("head"),
|
|
3832
|
+
app.post("/:id/navigator", writable, async (context) => {
|
|
3833
|
+
const input = readQuerySchemas.file.omit({ side: true }).extend({
|
|
3874
3834
|
file: z.string().min(1).optional(),
|
|
3875
3835
|
empty: z.literal("true").optional()
|
|
3876
3836
|
}).parse(context.req.query());
|
|
@@ -3896,7 +3856,6 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
3896
3856
|
app.get("/:id/maps/:resourceId", async (context) => {
|
|
3897
3857
|
const query = readQuerySchemas.maps.parse(context.req.query());
|
|
3898
3858
|
const id = context.req.param("id");
|
|
3899
|
-
if (id && isShared(id)) return context.json(sharedData.map(id, z.string().parse(context.req.param("resourceId"))));
|
|
3900
3859
|
return context.json(await data.map(await data.sourcePins(readReview(id, query.version)), z.string().parse(context.req.param("resourceId"))));
|
|
3901
3860
|
});
|
|
3902
3861
|
app.post("/repositories", async (context) => {
|
|
@@ -3916,10 +3875,7 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
3916
3875
|
app.get("/:id/resources/:resourceId", async (context) => {
|
|
3917
3876
|
const id = context.req.param("id");
|
|
3918
3877
|
const snapshot = readReview(id);
|
|
3919
|
-
const resource =
|
|
3920
|
-
...await sharedData.resource(id, z.string().parse(context.req.param("resourceId"))),
|
|
3921
|
-
repositoryId: snapshot.pins?.repositoryId ?? ""
|
|
3922
|
-
} : store.resource(z.string().parse(context.req.param("resourceId")));
|
|
3878
|
+
const resource = store.resource(z.string().parse(context.req.param("resourceId")));
|
|
3923
3879
|
if (snapshot.pins && resource.repositoryId !== snapshot.pins.repositoryId) throw new ReviewInputError("Resource is outside this repository.", 404);
|
|
3924
3880
|
return new Response(Buffer.from(resource.data), { headers: {
|
|
3925
3881
|
"content-type": resource.mimeType,
|
|
@@ -3928,14 +3884,13 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
3928
3884
|
});
|
|
3929
3885
|
app.get("/:id/language-context", async (context) => {
|
|
3930
3886
|
const input = readQuerySchemas.maps.extend({
|
|
3931
|
-
side: z.enum(["base", "head"]).default("head"),
|
|
3932
3887
|
commit: z.string().optional(),
|
|
3933
3888
|
repositoryId: z.string().optional(),
|
|
3934
3889
|
head: z.string().optional(),
|
|
3935
3890
|
base: z.string().optional()
|
|
3936
3891
|
}).parse(context.req.query());
|
|
3937
3892
|
const snapshot = readReview(context.req.param("id"), input.version);
|
|
3938
|
-
const environment = await data.languageEnvironment(snapshot, input.
|
|
3893
|
+
const environment = await data.languageEnvironment(snapshot, input.commit, false, queryAnchor(input));
|
|
3939
3894
|
if (context.req.header("x-review-client") !== "remote") return context.json(environment);
|
|
3940
3895
|
const { rootPath, ...rest } = environment;
|
|
3941
3896
|
return context.json({
|
|
@@ -3944,7 +3899,7 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
3944
3899
|
serverId: store.serverId()
|
|
3945
3900
|
});
|
|
3946
3901
|
});
|
|
3947
|
-
app.post("/:id/environment",
|
|
3902
|
+
app.post("/:id/environment", writable, async (context) => {
|
|
3948
3903
|
const input = z.strictObject({ retry: z.boolean().optional() }).parse(await readBoundedRequestJson(context.req.raw));
|
|
3949
3904
|
return context.json({ issues: await data.environmentIssues(readReview(context.req.param("id")), input.retry) });
|
|
3950
3905
|
});
|
|
@@ -3957,7 +3912,7 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
3957
3912
|
readReview(context.req.param("id"));
|
|
3958
3913
|
return context.json(data.workspaces.list(context.req.param("id")));
|
|
3959
3914
|
});
|
|
3960
|
-
app.post("/:id/workspaces/:workspaceId/retry",
|
|
3915
|
+
app.post("/:id/workspaces/:workspaceId/retry", writable, async (context) => {
|
|
3961
3916
|
return context.json(await data.workspaces.retry(context.req.param("id"), context.req.param("workspaceId")));
|
|
3962
3917
|
});
|
|
3963
3918
|
app.get("/:id/file", async (context) => {
|
|
@@ -4029,7 +3984,7 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
4029
3984
|
return context.json(await data.commits((await data.resolveSource(readReview(context.req.param("id"), input.version))).pins));
|
|
4030
3985
|
});
|
|
4031
3986
|
}
|
|
4032
|
-
app.post("/:id/copy-context",
|
|
3987
|
+
app.post("/:id/copy-context", async (context) => {
|
|
4033
3988
|
const query = readQuerySchemas.get.pick({ version: true }).extend({ mode: legacyModeSchema }).parse(context.req.query());
|
|
4034
3989
|
const selection = AgentSelectionSchema.parse(await readBoundedRequestJson(context.req.raw));
|
|
4035
3990
|
return context.json({ text: await selectionContext(context.req.param("id"), selection, query.version) });
|
|
@@ -4071,7 +4026,7 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
4071
4026
|
].join("\n");
|
|
4072
4027
|
}
|
|
4073
4028
|
if (ask && data) {
|
|
4074
|
-
const projectOf = (reviewId) =>
|
|
4029
|
+
const projectOf = (reviewId) => store.has(reviewId) ? store.projectOf(reviewId) : void 0;
|
|
4075
4030
|
const readThread = (reviewId, threadId) => {
|
|
4076
4031
|
const thread = ask.threads.get(threadId);
|
|
4077
4032
|
if (!thread) throw new ReviewInputError("This conversation has ended.", 404);
|
|
@@ -4133,27 +4088,31 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
4133
4088
|
await selectionContext(reviewId, selection, version)
|
|
4134
4089
|
].join("\n");
|
|
4135
4090
|
};
|
|
4091
|
+
const askOffer = async (agent, model, cwd) => {
|
|
4092
|
+
const stored = store.askHistory.offer(agent);
|
|
4093
|
+
const last = stored && Object.keys(stored.choices).length ? stored : void 0;
|
|
4094
|
+
const models = last?.choices.model;
|
|
4095
|
+
const another = model !== void 0 && model !== models?.current && (!models || models.options.some((option) => option.value === model));
|
|
4096
|
+
const known = another ? store.askHistory.offer(agent, model) : last;
|
|
4097
|
+
if (known) return known;
|
|
4098
|
+
const offer = await ask.threads.offered(agent, await cwd(), another ? model : void 0);
|
|
4099
|
+
if (last) store.askHistory.saveModelOffer(agent, offer);
|
|
4100
|
+
else store.askHistory.saveOffer(agent, offer);
|
|
4101
|
+
return offer;
|
|
4102
|
+
};
|
|
4136
4103
|
registerOnboardingRoutes(app, store, ask, {
|
|
4137
4104
|
register: (root) => data.register(root),
|
|
4138
4105
|
historyHooks,
|
|
4139
4106
|
handOff,
|
|
4140
|
-
open: openCreated
|
|
4107
|
+
open: openCreated,
|
|
4108
|
+
offer: askOffer
|
|
4141
4109
|
});
|
|
4142
4110
|
app.get("/ask/working", (context) => context.json({ agents: ask.threads.working() }));
|
|
4143
4111
|
app.get("/:id/ask/agents", async (context) => context.json({ agents: await ask.agents() }));
|
|
4144
4112
|
app.get("/:id/ask/agents/:agent/offer", async (context) => {
|
|
4145
4113
|
const agent = z.enum(askAgentIds).parse(context.req.param("agent"));
|
|
4146
4114
|
const { model } = askOfferQuerySchema.parse(context.req.query());
|
|
4147
|
-
const
|
|
4148
|
-
const last = stored && Object.keys(stored.choices).length ? stored : void 0;
|
|
4149
|
-
const models = last?.choices.model;
|
|
4150
|
-
const another = model !== void 0 && model !== models?.current && (!models || models.options.some((option) => option.value === model));
|
|
4151
|
-
const known = another ? store.askHistory.offer(agent, model) : last;
|
|
4152
|
-
if (known) return context.json({ offer: known });
|
|
4153
|
-
const checkout = await data.agentCheckout(readReview(context.req.param("id")));
|
|
4154
|
-
const offer = await ask.threads.offered(agent, checkout.rootPath, another ? model : void 0);
|
|
4155
|
-
if (last) store.askHistory.saveModelOffer(agent, offer);
|
|
4156
|
-
else store.askHistory.saveOffer(agent, offer);
|
|
4115
|
+
const offer = await askOffer(agent, model, async () => (await data.agentCheckout(readReview(context.req.param("id")))).rootPath);
|
|
4157
4116
|
return context.json({ offer });
|
|
4158
4117
|
});
|
|
4159
4118
|
app.get("/:id/ask/mentions", async (context) => {
|
|
@@ -4163,7 +4122,7 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
4163
4122
|
const files = fuzzyRank(query, await mentionableFiles(cwd), (file) => [file, file.slice(file.lastIndexOf("/") + 1)]);
|
|
4164
4123
|
return context.json({ paths: files.slice(0, MENTION_LIMIT) });
|
|
4165
4124
|
});
|
|
4166
|
-
app.post("/:id/ask",
|
|
4125
|
+
app.post("/:id/ask", writable, async (context) => {
|
|
4167
4126
|
const reviewId = context.req.param("id");
|
|
4168
4127
|
const { version } = readQuerySchemas.get.pick({ version: true }).parse(context.req.query());
|
|
4169
4128
|
const input = askStartSchema.parse(await readBoundedRequestJson(context.req.raw, ASK_REQUEST_MAX_BYTES));
|
|
@@ -4174,7 +4133,7 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
4174
4133
|
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
4175
4134
|
const permissions = input.permissions ?? defaultAskPermissions(input.agent);
|
|
4176
4135
|
const initialContext = await askContext(id, input.agent, snapshot, checkout, input.selection, version);
|
|
4177
|
-
assertWritable(reviewId);
|
|
4136
|
+
store.assertWritable(reviewId);
|
|
4178
4137
|
store.askHistory.markViewed(id, createdAt);
|
|
4179
4138
|
const thread = ask.threads.open({
|
|
4180
4139
|
id,
|
|
@@ -4292,7 +4251,7 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
4292
4251
|
board: reviewId
|
|
4293
4252
|
});
|
|
4294
4253
|
});
|
|
4295
|
-
app.post("/:id/ask/watch",
|
|
4254
|
+
app.post("/:id/ask/watch", async (context) => {
|
|
4296
4255
|
const reviewId = context.req.param("id");
|
|
4297
4256
|
readReview(reviewId);
|
|
4298
4257
|
const { threads } = askWatchSchema.parse(await readBoundedRequestJson(context.req.raw));
|
|
@@ -4327,7 +4286,7 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
4327
4286
|
entries: record.entries ?? []
|
|
4328
4287
|
});
|
|
4329
4288
|
});
|
|
4330
|
-
app.post("/:id/ask/:threadId/open",
|
|
4289
|
+
app.post("/:id/ask/:threadId/open", writable, async (context) => {
|
|
4331
4290
|
const reviewId = context.req.param("id");
|
|
4332
4291
|
const threadId = context.req.param("threadId");
|
|
4333
4292
|
if (ask.threads.get(threadId)) return context.json({ threadId });
|
|
@@ -4339,7 +4298,7 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
4339
4298
|
const checkout = await data.agentCheckout(snapshot);
|
|
4340
4299
|
const target = record.selection.target;
|
|
4341
4300
|
const initialContext = await askContext(record.id, record.agent, snapshot, checkout, record.selection, record.version);
|
|
4342
|
-
assertWritable(reviewId);
|
|
4301
|
+
store.assertWritable(reviewId);
|
|
4343
4302
|
ask.threads.open({
|
|
4344
4303
|
id: record.id,
|
|
4345
4304
|
reviewId: anchor,
|
|
@@ -4361,7 +4320,7 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
4361
4320
|
});
|
|
4362
4321
|
return context.json({ threadId: record.id });
|
|
4363
4322
|
});
|
|
4364
|
-
app.post("/:id/ask/:threadId/prompt",
|
|
4323
|
+
app.post("/:id/ask/:threadId/prompt", writable, async (context) => {
|
|
4365
4324
|
const thread = readThread(context.req.param("id"), context.req.param("threadId"));
|
|
4366
4325
|
const { question } = askFollowUpSchema.parse(await readBoundedRequestJson(context.req.raw, ASK_REQUEST_MAX_BYTES));
|
|
4367
4326
|
const refusal = thread.askRefusal();
|
|
@@ -4369,13 +4328,13 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
4369
4328
|
thread.ask(question);
|
|
4370
4329
|
return context.json({ ok: true });
|
|
4371
4330
|
});
|
|
4372
|
-
app.post("/:id/ask/:threadId/permission",
|
|
4331
|
+
app.post("/:id/ask/:threadId/permission", writable, async (context) => {
|
|
4373
4332
|
const thread = readThread(context.req.param("id"), context.req.param("threadId"));
|
|
4374
4333
|
const decision = askDecisionSchema.parse(await readBoundedRequestJson(context.req.raw));
|
|
4375
4334
|
if (!thread.decide(decision.permissionId, decision.optionId)) throw new ReviewInputError("This request was already answered.", 409);
|
|
4376
4335
|
return context.json({ ok: true });
|
|
4377
4336
|
});
|
|
4378
|
-
app.post("/:id/ask/:threadId/files",
|
|
4337
|
+
app.post("/:id/ask/:threadId/files", writable, async (context) => {
|
|
4379
4338
|
const thread = readThread(context.req.param("id"), context.req.param("threadId"));
|
|
4380
4339
|
const { paths } = askFilesSchema.parse(await readBoundedRequestJson(context.req.raw));
|
|
4381
4340
|
const { cwd, entries } = thread.read();
|
|
@@ -4386,7 +4345,7 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
4386
4345
|
file
|
|
4387
4346
|
})) });
|
|
4388
4347
|
});
|
|
4389
|
-
app.post("/:id/ask/:threadId/choice",
|
|
4348
|
+
app.post("/:id/ask/:threadId/choice", writable, async (context) => {
|
|
4390
4349
|
const thread = readThread(context.req.param("id"), context.req.param("threadId"));
|
|
4391
4350
|
const { kind, value } = askChoiceSchema.parse(await readBoundedRequestJson(context.req.raw));
|
|
4392
4351
|
if (thread.read().status !== "idle") throw new ReviewInputError("Settings can change once the agent finishes answering.", 409);
|
|
@@ -4397,7 +4356,7 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
4397
4356
|
}
|
|
4398
4357
|
return context.json({ ok: true });
|
|
4399
4358
|
});
|
|
4400
|
-
app.post("/:id/ask/:threadId/permissions",
|
|
4359
|
+
app.post("/:id/ask/:threadId/permissions", writable, async (context) => {
|
|
4401
4360
|
const thread = readThread(context.req.param("id"), context.req.param("threadId"));
|
|
4402
4361
|
const { permissions } = askPermitSchema.parse(await readBoundedRequestJson(context.req.raw));
|
|
4403
4362
|
if (thread.read().status !== "idle") throw new ReviewInputError("Settings can change once the agent finishes answering.", 409);
|
|
@@ -4408,13 +4367,13 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
4408
4367
|
}
|
|
4409
4368
|
return context.json({ ok: true });
|
|
4410
4369
|
});
|
|
4411
|
-
app.post("/:id/ask/:threadId/retry",
|
|
4370
|
+
app.post("/:id/ask/:threadId/retry", writable, (context) => {
|
|
4412
4371
|
const thread = readThread(context.req.param("id"), context.req.param("threadId"));
|
|
4413
4372
|
if (thread.read().status !== "failed") throw new ReviewInputError("Only a conversation that failed can try again.", 409);
|
|
4414
4373
|
thread.retry();
|
|
4415
4374
|
return context.json({ ok: true });
|
|
4416
4375
|
});
|
|
4417
|
-
app.post("/:id/ask/:threadId/cancel",
|
|
4376
|
+
app.post("/:id/ask/:threadId/cancel", async (context) => {
|
|
4418
4377
|
await readThread(context.req.param("id"), context.req.param("threadId")).cancel();
|
|
4419
4378
|
return context.json({ ok: true });
|
|
4420
4379
|
});
|
|
@@ -4424,12 +4383,12 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
4424
4383
|
store.askHistory.markViewed(threadId);
|
|
4425
4384
|
return context.json({ ok: true });
|
|
4426
4385
|
});
|
|
4427
|
-
app.post("/:id/ask/:threadId/close",
|
|
4386
|
+
app.post("/:id/ask/:threadId/close", (context) => {
|
|
4428
4387
|
readThread(context.req.param("id"), context.req.param("threadId"));
|
|
4429
4388
|
ask.threads.close(context.req.param("threadId"), !readReview(context.req.param("id")).trashedAt);
|
|
4430
4389
|
return context.json({ ok: true });
|
|
4431
4390
|
});
|
|
4432
|
-
app.delete("/:id/ask/:threadId",
|
|
4391
|
+
app.delete("/:id/ask/:threadId", writable, (context) => {
|
|
4433
4392
|
context.req.param("id");
|
|
4434
4393
|
const threadId = context.req.param("threadId");
|
|
4435
4394
|
if (!store.askHistory.get(threadId)) throw new ReviewInputError("This conversation was not found.", 404);
|
|
@@ -4440,14 +4399,14 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
4440
4399
|
}
|
|
4441
4400
|
app.get("/:id/place", (context) => {
|
|
4442
4401
|
const id = context.req.param("id");
|
|
4443
|
-
|
|
4402
|
+
store.assertExists(id);
|
|
4444
4403
|
return context.json(placeOf(id));
|
|
4445
4404
|
});
|
|
4446
4405
|
app.get("/:id/stack", async (context) => {
|
|
4447
4406
|
const query = readQuerySchemas.get.parse(context.req.query());
|
|
4448
4407
|
const id = context.req.param("id");
|
|
4449
4408
|
let snapshot = readReview(id, query.version);
|
|
4450
|
-
if (
|
|
4409
|
+
if (!snapshot.pins) return context.json({ layers: [] });
|
|
4451
4410
|
if (data) snapshot = await data.discoverPullRequest(snapshot);
|
|
4452
4411
|
const repositoryPath = store.repositories().find((repository) => repository.id === snapshot.pins.repositoryId)?.path;
|
|
4453
4412
|
const layers = await resolveReviewStackLayers(snapshot, store.list(), { repositoryPath });
|
|
@@ -4465,10 +4424,6 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
4465
4424
|
});
|
|
4466
4425
|
app.get("/:id/project", (context) => {
|
|
4467
4426
|
const id = context.req.param("id");
|
|
4468
|
-
if (isShared(id)) return context.json({
|
|
4469
|
-
project: null,
|
|
4470
|
-
boards: []
|
|
4471
|
-
});
|
|
4472
4427
|
const project = store.summary(id)?.project ?? null;
|
|
4473
4428
|
return context.json({
|
|
4474
4429
|
project,
|
|
@@ -4477,15 +4432,6 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
4477
4432
|
});
|
|
4478
4433
|
app.get("/:id/links", (context) => {
|
|
4479
4434
|
const id = context.req.param("id");
|
|
4480
|
-
if (isShared(id)) return context.json({
|
|
4481
|
-
outgoing: boardLinks(id, readReview(id).document).map(({ from, to }) => ({
|
|
4482
|
-
from,
|
|
4483
|
-
to,
|
|
4484
|
-
missing: true,
|
|
4485
|
-
elsewhere: true
|
|
4486
|
-
})),
|
|
4487
|
-
backlinks: []
|
|
4488
|
-
});
|
|
4489
4435
|
const { version } = readQuerySchemas.get.pick({ version: true }).parse({ version: context.req.query("version") });
|
|
4490
4436
|
const { outgoing, backlinks } = store.links(id, version);
|
|
4491
4437
|
return context.json({
|
|
@@ -4495,7 +4441,6 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
4495
4441
|
});
|
|
4496
4442
|
app.get("/:id/links/peek", (context) => {
|
|
4497
4443
|
const id = context.req.param("id");
|
|
4498
|
-
if (isShared(id)) return context.json({});
|
|
4499
4444
|
const { version } = readQuerySchemas.get.pick({ version: true }).parse({ version: context.req.query("version") });
|
|
4500
4445
|
const board = context.req.query("board");
|
|
4501
4446
|
const block = context.req.query("block");
|
|
@@ -4506,15 +4451,7 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
4506
4451
|
}, version));
|
|
4507
4452
|
});
|
|
4508
4453
|
app.get("/:id/history", (context) => {
|
|
4509
|
-
|
|
4510
|
-
if (!isShared(id)) return context.json(store.history(id));
|
|
4511
|
-
const snapshot = readReview(id);
|
|
4512
|
-
return context.json([{
|
|
4513
|
-
version: snapshot.version,
|
|
4514
|
-
title: snapshot.title,
|
|
4515
|
-
createdAt: snapshot.createdAt,
|
|
4516
|
-
author: "agent"
|
|
4517
|
-
}]);
|
|
4454
|
+
return context.json(store.history(context.req.param("id")));
|
|
4518
4455
|
});
|
|
4519
4456
|
/** A board's relations as session_list reports them: only those it has. */
|
|
4520
4457
|
const listedRelations = ({ parentId, children, dependsOn }) => {
|
|
@@ -4541,15 +4478,15 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
4541
4478
|
const query = inspectQuerySchema.parse(context.req.query());
|
|
4542
4479
|
const id = context.req.param("id");
|
|
4543
4480
|
const snapshot = readReview(id, query.version);
|
|
4544
|
-
return context.json(query.format === "text" ? documentText(snapshot, query.targetId, Boolean(query.full),
|
|
4481
|
+
return context.json(query.format === "text" ? documentText(snapshot, query.targetId, Boolean(query.full), relatedBoards(id)) : query.targetId !== void 0 ? inspectSnapshot(snapshot, query.targetId) : {
|
|
4545
4482
|
...query.full ? snapshot : inspectSnapshot(snapshot),
|
|
4546
|
-
|
|
4483
|
+
...listedRelations(store.relations(id))
|
|
4547
4484
|
});
|
|
4548
4485
|
});
|
|
4549
4486
|
app.get("/:id", async (context) => {
|
|
4550
4487
|
const query = readQuerySchemas.get.parse(context.req.query());
|
|
4551
4488
|
let snapshot = { ...readReview(context.req.param("id"), query.version) };
|
|
4552
|
-
if (data && query.full && query.version === void 0
|
|
4489
|
+
if (data && query.full && query.version === void 0) snapshot = await data.discoverPullRequest(snapshot);
|
|
4553
4490
|
if (data && query.full) try {
|
|
4554
4491
|
const pins = await data.sourcePins(snapshot);
|
|
4555
4492
|
if (pins) snapshot.pins = pins;
|
|
@@ -4581,35 +4518,16 @@ function createReviewApi(store, data, open, shared, capabilities = () => ({
|
|
|
4581
4518
|
const target = "targetId" in edit ? elements(readReview(reviewId).document).find((element) => element.id === edit.targetId) : void 0;
|
|
4582
4519
|
if (incoming.some((element) => element.type === "animation") || target?.type === "animation") throw new ReviewInputError("Animation authoring is disabled. Enable Animations in Settings under Experimental Features to edit animations. Existing animations can still be viewed.", 409);
|
|
4583
4520
|
}
|
|
4584
|
-
const command = sharedCommandSchema.safeParse(input);
|
|
4585
|
-
if (command.success && command.data.operation.reviewId?.startsWith("shared-")) {
|
|
4586
|
-
const parsed = commandSchema.parse(input);
|
|
4587
|
-
if (shared && parsed.operation.type === "delete") {
|
|
4588
|
-
if (!shared.get(parsed.operation.reviewId).snapshot.trashedAt) throw new ReviewInputError("Move this whiteboard to Trash before deleting it.", 409);
|
|
4589
|
-
await shared.removeLocal(parsed.operation.reviewId);
|
|
4590
|
-
return context.json({
|
|
4591
|
-
reviewId: parsed.operation.reviewId,
|
|
4592
|
-
version: 0,
|
|
4593
|
-
deleted: true
|
|
4594
|
-
});
|
|
4595
|
-
}
|
|
4596
|
-
if (shared && (parsed.operation.type === "attention" || parsed.operation.type === "lifecycle")) {
|
|
4597
|
-
if (parsed.operation.type === "lifecycle") await shared.setLifecycle(parsed.operation.reviewId, parsed.operation.state);
|
|
4598
|
-
else await shared.setAttention(parsed.operation.reviewId);
|
|
4599
|
-
return context.json({
|
|
4600
|
-
reviewId: parsed.operation.reviewId,
|
|
4601
|
-
version: shared.get(parsed.operation.reviewId).snapshot.version,
|
|
4602
|
-
attention: true
|
|
4603
|
-
});
|
|
4604
|
-
}
|
|
4605
|
-
throw new ReviewInputError("Shared reviews are read-only.", 409);
|
|
4606
|
-
}
|
|
4607
4521
|
const threadId = remoteCaller(context) ? void 0 : context.req.header("x-review-thread")?.trim() || void 0;
|
|
4608
4522
|
const author = !remoteCaller(context) && context.req.header("x-review-person") !== void 0 ? { kind: "person" } : {
|
|
4609
4523
|
kind: "agent",
|
|
4610
4524
|
...threadId && { threadId }
|
|
4611
4525
|
};
|
|
4526
|
+
const copy = input.operation.type === "delete" && store.has(input.operation.reviewId) ? store.read(input.operation.reviewId) : void 0;
|
|
4612
4527
|
const result = await store.execute(input, void 0, author);
|
|
4528
|
+
const key = copy?.shared?.key;
|
|
4529
|
+
const kept = copy && boardRepositoryId(copy);
|
|
4530
|
+
if (result.deleted && key && kept) await Promise.resolve().then(() => forgetSharedCommits(store.repositoryPath(kept), key)).catch((error) => console.error("Could not drop a copy's kept commits:", error));
|
|
4613
4531
|
if (input.operation.type === "edit" && data && !result.deleted) {
|
|
4614
4532
|
const { quotes, unquoted } = await anchorQuotes(result.version > 0 ? store.read(result.reviewId, result.version - 1) : void 0, store.read(result.reviewId, result.version), async (pins, side, file) => (await data.file(pins, side, file)).text);
|
|
4615
4533
|
return context.json({
|
|
@@ -4931,7 +4849,7 @@ function answerErrorsAsJson(app) {
|
|
|
4931
4849
|
});
|
|
4932
4850
|
}
|
|
4933
4851
|
function createWhiteboardCore(input) {
|
|
4934
|
-
const { store, data
|
|
4852
|
+
const { store, data } = input.profile;
|
|
4935
4853
|
const app = createReviewServerApp({
|
|
4936
4854
|
token: input.token,
|
|
4937
4855
|
instanceId: input.instanceId,
|
|
@@ -4948,22 +4866,20 @@ function createWhiteboardCore(input) {
|
|
|
4948
4866
|
takesMcp: async (agent) => askAgentTakesMcp(agent, await ask.env),
|
|
4949
4867
|
...ask.tools
|
|
4950
4868
|
});
|
|
4951
|
-
const closeDeletedThreads = () => askThreads?.closeDeletedReviews((id) =>
|
|
4869
|
+
const closeDeletedThreads = () => askThreads?.closeDeletedReviews((id) => !store.has(id) || Boolean(store.read(id).trashedAt));
|
|
4952
4870
|
const stopLocal = askThreads && store.subscribe((result) => {
|
|
4953
4871
|
if (result.deleted || result.lifecycle) closeDeletedThreads();
|
|
4954
4872
|
});
|
|
4955
|
-
const
|
|
4956
|
-
const api = createReviewApi(store, data, callbacks.open, shared, callbacks.capabilities, () => traceMachineEnabled(), input.status, input.hooks, askThreads && {
|
|
4873
|
+
const api = createReviewApi(store, data, callbacks.open, input.sharing, callbacks.capabilities, () => traceMachineEnabled(), input.status, input.hooks, askThreads && {
|
|
4957
4874
|
threads: askThreads,
|
|
4958
4875
|
agents: async () => detectAskAgents(await ask?.env)
|
|
4959
4876
|
}, input.animations);
|
|
4960
|
-
if (!
|
|
4877
|
+
if (!input.sharing) mountSharingPublisher(api, store, data);
|
|
4961
4878
|
return {
|
|
4962
4879
|
app,
|
|
4963
4880
|
api,
|
|
4964
4881
|
close: () => {
|
|
4965
4882
|
stopLocal?.();
|
|
4966
|
-
stopShared?.();
|
|
4967
4883
|
closeDeletedThreads();
|
|
4968
4884
|
askThreads?.closeAll();
|
|
4969
4885
|
}
|