rivet-design 0.27.0 → 0.28.0
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/agent-variants/DirectionRefReservations.d.ts +11 -0
- package/dist/agent-variants/DirectionRefReservations.js +47 -0
- package/dist/agent-variants/PreviewRuntime.d.ts +4 -0
- package/dist/agent-variants/PreviewRuntime.js +5 -3
- package/dist/agent-variants/SessionStore.d.ts +10 -1
- package/dist/agent-variants/SessionStore.js +25 -2
- package/dist/agent-variants/WorkItemRequestTimes.d.ts +6 -0
- package/dist/agent-variants/WorkItemRequestTimes.js +21 -0
- package/dist/agent-variants/WorktreeOrchestrator.d.ts +2 -1
- package/dist/agent-variants/WorktreeOrchestrator.js +92 -78
- package/dist/agent-variants/contracts.d.ts +8 -0
- package/dist/agent-variants/existingStaticEntry.d.ts +34 -0
- package/dist/agent-variants/existingStaticEntry.js +136 -0
- package/dist/agent-variants/staticPreviewFiles.js +1 -1
- package/dist/agent-variants/variant-project-runtime.d.ts +2 -1
- package/dist/agent-variants/variantsTelemetry.d.ts +4 -0
- package/dist/agent-variants/variantsTelemetry.js +2 -0
- package/dist/agent-variants/workItemInput.d.ts +22 -0
- package/dist/agent-variants/workItemInput.js +12 -1
- package/dist/cli/commands/directionTarget.d.ts +23 -0
- package/dist/cli/commands/directionTarget.js +87 -0
- package/dist/cli/commands/open.js +28 -4
- package/dist/cli/commands/variants.js +36 -43
- package/dist/cli/envelope.d.ts +1 -1
- package/dist/cli/envelope.js +1 -0
- package/dist/cli/projectRuntimeUpgrade.d.ts +11 -0
- package/dist/cli/projectRuntimeUpgrade.js +43 -11
- package/dist/config/pluginMetrics.js +2 -0
- package/dist/config/posthog.d.ts +2 -0
- package/dist/config/posthog.js +5 -0
- package/dist/mcp/explorationSchema.js +1 -1
- package/dist/mcp/getExploration.js +11 -5
- package/dist/proxy-middleware/proxy-config.js +7 -0
- package/dist/routes/agentVariants.js +4 -0
- package/dist/routes/cli.js +10 -1
- package/dist/server.js +12 -6
- package/dist/services/DependencyPreparationService.js +44 -6
- package/dist/services/FeatureFlagService.js +2 -2
- package/dist/services/ProjectLibrary.d.ts +4 -1
- package/dist/services/ProjectLibrary.js +14 -9
- package/dist/services/ProjectRuntimeService.d.ts +8 -0
- package/dist/services/ProjectRuntimeService.js +15 -2
- package/dist/services/TelemetryService.d.ts +5 -0
- package/dist/services/TelemetryService.js +21 -2
- package/dist/services/VariantHistoryService.d.ts +8 -0
- package/dist/services/VariantHistoryService.js +40 -0
- package/dist/services/WorktreeManager.d.ts +1 -0
- package/dist/services/WorktreeManager.js +12 -0
- package/dist/services/createAgentVariantsOrchestrator.js +9 -2
- package/dist/services/directionRefs.d.ts +21 -0
- package/dist/services/directionRefs.js +148 -0
- package/dist/services/projectDirections.d.ts +22 -0
- package/dist/services/projectDirections.js +38 -0
- package/dist/types/direction-ref.d.ts +36 -0
- package/dist/types/direction-ref.js +3 -0
- package/dist/types/variant-history.d.ts +3 -1
- package/dist/utils/failureReason.d.ts +1 -1
- package/dist/utils/failureReason.js +3 -0
- package/dist/utils/skills/cli-guidance.js +4 -3
- package/dist/utils/subprocessEnvironment.d.ts +1 -1
- package/dist/utils/subprocessEnvironment.js +0 -1
- package/package.json +4 -4
- package/src/ui/dist/assets/LibraryEntry-BE8nZneH.js +37 -0
- package/src/ui/dist/assets/logo.png +0 -0
- package/src/ui/dist/assets/main-1EDrDqgn.js +498 -0
- package/src/ui/dist/assets/main-qgqnlUkI.css +1 -0
- package/src/ui/dist/assets/rivet-wordmark-orange-CYKVQDmG.svg +7 -0
- package/src/ui/dist/index.html +2 -2
- package/dist/services/StaticPreviewServer.d.ts +0 -8
- package/dist/services/StaticPreviewServer.js +0 -207
- package/src/ui/dist/assets/LibraryEntry-RI9Lc7P3.js +0 -37
- package/src/ui/dist/assets/main-D0UmAaUe.css +0 -1
- package/src/ui/dist/assets/main-DgrLzS5j.js +0 -497
- package/src/ui/dist/assets/rivet.svg +0 -3
- package/src/ui/dist/fonts/Goldman-Bold.woff2 +0 -0
- package/src/ui/dist/fonts/Goldman-Regular.woff2 +0 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveDirectionAddress = exports.parseDirectionAddress = exports.withDirectionRefs = exports.nextDirectionRef = exports.slugifyDirectionLabel = exports.isDirectionActive = void 0;
|
|
4
|
+
const SLUG_MAX_LENGTH = 40;
|
|
5
|
+
const EMPTY_LABEL_SLUG = 'direction';
|
|
6
|
+
const LAST_KEYWORD = 'last';
|
|
7
|
+
const FIRST_COLLISION_SUFFIX = 2;
|
|
8
|
+
const MIN_VARIANT_ID_PREFIX_LENGTH = 4;
|
|
9
|
+
const MAX_UNKNOWN_CANDIDATES = 10;
|
|
10
|
+
const TOKEN_PATTERN = /^[A-Za-z0-9_-]+$/;
|
|
11
|
+
const INACTIVE_STATUSES = new Set([
|
|
12
|
+
'removed',
|
|
13
|
+
'cancelled',
|
|
14
|
+
]);
|
|
15
|
+
const isDirectionActive = (status) => !INACTIVE_STATUSES.has(status);
|
|
16
|
+
exports.isDirectionActive = isDirectionActive;
|
|
17
|
+
const slugifyDirectionLabel = (label) => {
|
|
18
|
+
const slug = label
|
|
19
|
+
.normalize('NFKD')
|
|
20
|
+
.replace(/\p{M}/gu, '')
|
|
21
|
+
.toLowerCase()
|
|
22
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
23
|
+
.replace(/^-+|-+$/g, '');
|
|
24
|
+
if (!slug)
|
|
25
|
+
return EMPTY_LABEL_SLUG;
|
|
26
|
+
if (slug.length <= SLUG_MAX_LENGTH)
|
|
27
|
+
return slug;
|
|
28
|
+
const boundary = slug.lastIndexOf('-', SLUG_MAX_LENGTH);
|
|
29
|
+
return slug.slice(0, boundary > 0 ? boundary : SLUG_MAX_LENGTH);
|
|
30
|
+
};
|
|
31
|
+
exports.slugifyDirectionLabel = slugifyDirectionLabel;
|
|
32
|
+
const nextDirectionRef = (args) => {
|
|
33
|
+
const slug = (0, exports.slugifyDirectionLabel)(args.label);
|
|
34
|
+
const isTaken = (candidate) => candidate === LAST_KEYWORD || args.taken.has(candidate);
|
|
35
|
+
let candidate = slug;
|
|
36
|
+
for (let suffix = FIRST_COLLISION_SUFFIX; isTaken(candidate); suffix++)
|
|
37
|
+
candidate = `${slug}-${suffix}`;
|
|
38
|
+
return candidate;
|
|
39
|
+
};
|
|
40
|
+
exports.nextDirectionRef = nextDirectionRef;
|
|
41
|
+
const directionKey = (manifest) => `${manifest.sessionId}:${manifest.variantId}`;
|
|
42
|
+
const byCreation = (a, b) => a.manifest.createdAt.localeCompare(b.manifest.createdAt) ||
|
|
43
|
+
a.manifest.sessionId.localeCompare(b.manifest.sessionId) ||
|
|
44
|
+
a.manifest.variantId.localeCompare(b.manifest.variantId);
|
|
45
|
+
const withDirectionRefs = (entries) => {
|
|
46
|
+
const taken = new Set(entries.flatMap(({ manifest }) => manifest.directionRef ? [manifest.directionRef] : []));
|
|
47
|
+
const legacyRefs = new Map();
|
|
48
|
+
const legacyRefOf = (manifest) => {
|
|
49
|
+
const key = directionKey(manifest);
|
|
50
|
+
const known = legacyRefs.get(key);
|
|
51
|
+
if (known)
|
|
52
|
+
return known;
|
|
53
|
+
const directionRef = (0, exports.nextDirectionRef)({ label: manifest.label, taken });
|
|
54
|
+
taken.add(directionRef);
|
|
55
|
+
legacyRefs.set(key, directionRef);
|
|
56
|
+
return directionRef;
|
|
57
|
+
};
|
|
58
|
+
for (const { manifest } of [...entries].sort(byCreation))
|
|
59
|
+
if (!manifest.directionRef)
|
|
60
|
+
legacyRefOf(manifest);
|
|
61
|
+
return entries.map((entry) => ({
|
|
62
|
+
...entry,
|
|
63
|
+
directionRef: entry.manifest.directionRef ?? legacyRefOf(entry.manifest),
|
|
64
|
+
}));
|
|
65
|
+
};
|
|
66
|
+
exports.withDirectionRefs = withDirectionRefs;
|
|
67
|
+
const parseDirectionIds = (raw) => {
|
|
68
|
+
const projectSeparator = raw.indexOf('/');
|
|
69
|
+
const projectId = projectSeparator === -1 ? undefined : raw.slice(0, projectSeparator);
|
|
70
|
+
const direction = projectSeparator === -1 ? raw : raw.slice(projectSeparator + 1);
|
|
71
|
+
if (projectSeparator !== -1 && (!projectId || direction.includes('/')))
|
|
72
|
+
return null;
|
|
73
|
+
const variantSeparator = direction.indexOf(':');
|
|
74
|
+
if (variantSeparator <= 0 || variantSeparator === direction.length - 1)
|
|
75
|
+
return null;
|
|
76
|
+
if (direction.indexOf(':', variantSeparator + 1) !== -1)
|
|
77
|
+
return null;
|
|
78
|
+
const sessionId = direction.slice(0, variantSeparator).trim();
|
|
79
|
+
const variantId = direction.slice(variantSeparator + 1).trim();
|
|
80
|
+
if (!sessionId || !variantId)
|
|
81
|
+
return null;
|
|
82
|
+
return {
|
|
83
|
+
kind: 'ids',
|
|
84
|
+
...(projectId ? { projectId } : {}),
|
|
85
|
+
sessionId,
|
|
86
|
+
variantId,
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
const parseDirectionAddress = (raw) => {
|
|
90
|
+
const value = raw.trim();
|
|
91
|
+
if (value.toLowerCase() === LAST_KEYWORD)
|
|
92
|
+
return { kind: 'last' };
|
|
93
|
+
if (value.includes(':') || value.includes('/'))
|
|
94
|
+
return parseDirectionIds(value);
|
|
95
|
+
return TOKEN_PATTERN.test(value) ? { kind: 'token', token: value } : null;
|
|
96
|
+
};
|
|
97
|
+
exports.parseDirectionAddress = parseDirectionAddress;
|
|
98
|
+
const newestFirst = (a, b) => b.createdAt.localeCompare(a.createdAt);
|
|
99
|
+
const notFound = (args) => {
|
|
100
|
+
const candidates = args.newest.slice(0, MAX_UNKNOWN_CANDIDATES);
|
|
101
|
+
const knownRefs = candidates.map((candidate) => candidate.directionRef);
|
|
102
|
+
const knownRefsSentence = knownRefs.length > 0 ? ` Known refs: ${knownRefs.join(', ')}.` : '';
|
|
103
|
+
return {
|
|
104
|
+
isResolved: false,
|
|
105
|
+
code: 'WORK_ITEM_NOT_FOUND',
|
|
106
|
+
message: `No direction matches "${args.input}".${knownRefsSentence}`,
|
|
107
|
+
candidates,
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
const resolveToken = (args) => {
|
|
111
|
+
const needle = args.token.toLowerCase();
|
|
112
|
+
const exact = args.newest.filter((candidate) => candidate.directionRef.toLowerCase() === needle);
|
|
113
|
+
const prefixed = needle.length >= MIN_VARIANT_ID_PREFIX_LENGTH
|
|
114
|
+
? args.newest.filter((candidate) => candidate.variantId.toLowerCase().startsWith(needle))
|
|
115
|
+
: [];
|
|
116
|
+
const matches = exact.length > 0 ? exact : prefixed;
|
|
117
|
+
if (matches.length === 1)
|
|
118
|
+
return { isResolved: true, direction: matches[0] };
|
|
119
|
+
if (matches.length === 0)
|
|
120
|
+
return notFound({ input: args.token, newest: args.newest });
|
|
121
|
+
return {
|
|
122
|
+
isResolved: false,
|
|
123
|
+
code: 'DIRECTION_AMBIGUOUS',
|
|
124
|
+
message: `"${args.token}" matches ${matches.length} directions: ${matches
|
|
125
|
+
.map((candidate) => candidate.directionRef)
|
|
126
|
+
.join(', ')}.`,
|
|
127
|
+
candidates: matches,
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
const resolveDirectionAddress = (args) => {
|
|
131
|
+
const newest = [...args.candidates].sort(newestFirst);
|
|
132
|
+
switch (args.address.kind) {
|
|
133
|
+
case 'last': {
|
|
134
|
+
const direction = newest.find((candidate) => (0, exports.isDirectionActive)(candidate.status));
|
|
135
|
+
return direction
|
|
136
|
+
? { isResolved: true, direction }
|
|
137
|
+
: notFound({ input: LAST_KEYWORD, newest });
|
|
138
|
+
}
|
|
139
|
+
case 'token':
|
|
140
|
+
return resolveToken({ token: args.address.token, newest });
|
|
141
|
+
default: {
|
|
142
|
+
const unhandled = args.address;
|
|
143
|
+
return unhandled;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
exports.resolveDirectionAddress = resolveDirectionAddress;
|
|
148
|
+
//# sourceMappingURL=directionRefs.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ProjectLibrary } from './ProjectLibrary';
|
|
2
|
+
import type { VariantHistoryEntry, VariantHistoryService } from './VariantHistoryService';
|
|
3
|
+
import type { DirectionRef, DirectionResolution, DirectionSearchAddress } from '../types/direction-ref';
|
|
4
|
+
export type ProjectDirectionSource = {
|
|
5
|
+
kind: 'library';
|
|
6
|
+
library: ProjectLibrary;
|
|
7
|
+
projectId: string;
|
|
8
|
+
} | {
|
|
9
|
+
kind: 'history';
|
|
10
|
+
history: VariantHistoryService;
|
|
11
|
+
projectPath: string;
|
|
12
|
+
};
|
|
13
|
+
export type ProjectDirection = VariantHistoryEntry & {
|
|
14
|
+
projectPath: string;
|
|
15
|
+
directionRef: DirectionRef;
|
|
16
|
+
};
|
|
17
|
+
export declare const listProjectDirections: (source: ProjectDirectionSource) => Promise<ProjectDirection[]>;
|
|
18
|
+
export declare const resolveProjectDirection: (args: {
|
|
19
|
+
source: ProjectDirectionSource;
|
|
20
|
+
address: DirectionSearchAddress;
|
|
21
|
+
}) => Promise<DirectionResolution>;
|
|
22
|
+
//# sourceMappingURL=projectDirections.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveProjectDirection = exports.listProjectDirections = void 0;
|
|
4
|
+
const directionRefs_1 = require("./directionRefs");
|
|
5
|
+
const historyRoots_1 = require("./historyRoots");
|
|
6
|
+
const listSourceEntries = async (source) => {
|
|
7
|
+
switch (source.kind) {
|
|
8
|
+
case 'library':
|
|
9
|
+
return source.library.listVariants(source.projectId, {
|
|
10
|
+
isRemovedIncluded: true,
|
|
11
|
+
});
|
|
12
|
+
case 'history':
|
|
13
|
+
return (await Promise.all([
|
|
14
|
+
source.projectPath,
|
|
15
|
+
...(0, historyRoots_1.nestedFreshSessionWorkdirs)(source.projectPath),
|
|
16
|
+
].map(async (projectPath) => (await source.history.listVariants({ projectPath })).map((entry) => ({ ...entry, projectPath }))))).flat();
|
|
17
|
+
default: {
|
|
18
|
+
const unhandled = source;
|
|
19
|
+
return unhandled;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const listProjectDirections = async (source) => (0, directionRefs_1.withDirectionRefs)(await listSourceEntries(source));
|
|
24
|
+
exports.listProjectDirections = listProjectDirections;
|
|
25
|
+
const directionCandidateOf = (direction) => ({
|
|
26
|
+
directionRef: direction.directionRef,
|
|
27
|
+
sessionId: direction.manifest.sessionId,
|
|
28
|
+
variantId: direction.manifest.variantId,
|
|
29
|
+
label: direction.manifest.label,
|
|
30
|
+
status: direction.manifest.status,
|
|
31
|
+
createdAt: direction.manifest.createdAt,
|
|
32
|
+
});
|
|
33
|
+
const resolveProjectDirection = async (args) => (0, directionRefs_1.resolveDirectionAddress)({
|
|
34
|
+
address: args.address,
|
|
35
|
+
candidates: (await (0, exports.listProjectDirections)(args.source)).map(directionCandidateOf),
|
|
36
|
+
});
|
|
37
|
+
exports.resolveProjectDirection = resolveProjectDirection;
|
|
38
|
+
//# sourceMappingURL=projectDirections.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { VariantHistoryStatus } from './variant-history';
|
|
2
|
+
export type DirectionRef = string & {
|
|
3
|
+
readonly __brand: 'DirectionRef';
|
|
4
|
+
};
|
|
5
|
+
export type DirectionAddress = {
|
|
6
|
+
kind: 'ids';
|
|
7
|
+
projectId?: string;
|
|
8
|
+
sessionId: string;
|
|
9
|
+
variantId: string;
|
|
10
|
+
} | {
|
|
11
|
+
kind: 'token';
|
|
12
|
+
token: string;
|
|
13
|
+
} | {
|
|
14
|
+
kind: 'last';
|
|
15
|
+
};
|
|
16
|
+
export type DirectionSearchAddress = Exclude<DirectionAddress, {
|
|
17
|
+
kind: 'ids';
|
|
18
|
+
}>;
|
|
19
|
+
export interface DirectionCandidate {
|
|
20
|
+
directionRef: DirectionRef;
|
|
21
|
+
sessionId: string;
|
|
22
|
+
variantId: string;
|
|
23
|
+
label: string;
|
|
24
|
+
status: VariantHistoryStatus;
|
|
25
|
+
createdAt: string;
|
|
26
|
+
}
|
|
27
|
+
export type DirectionResolution = {
|
|
28
|
+
isResolved: true;
|
|
29
|
+
direction: DirectionCandidate;
|
|
30
|
+
} | {
|
|
31
|
+
isResolved: false;
|
|
32
|
+
code: 'WORK_ITEM_NOT_FOUND' | 'DIRECTION_AMBIGUOUS';
|
|
33
|
+
message: string;
|
|
34
|
+
candidates: DirectionCandidate[];
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=direction-ref.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DirectionRef } from './direction-ref';
|
|
1
2
|
import type { VariantReference } from './variant-reference';
|
|
2
3
|
export type { VariantReference } from './variant-reference';
|
|
3
4
|
export type VariantHistoryStatus = 'completed' | 'committed' | 'rejected' | 'cancelled' | 'removed';
|
|
@@ -91,6 +92,7 @@ export interface VariantHistoryManifest {
|
|
|
91
92
|
variantId: string;
|
|
92
93
|
sessionId: string;
|
|
93
94
|
requestId?: string;
|
|
95
|
+
directionRef?: DirectionRef;
|
|
94
96
|
label: string;
|
|
95
97
|
brief: string;
|
|
96
98
|
references?: VariantReference[];
|
|
@@ -120,7 +122,7 @@ export interface VariantHistoryManifest {
|
|
|
120
122
|
deployments?: VariantDeployment[];
|
|
121
123
|
runtime?: import('../agent-variants/contracts').WorkerRuntimeInfo;
|
|
122
124
|
}
|
|
123
|
-
export type VariantHistoryRow = Pick<VariantHistoryManifest, 'sessionId' | 'variantId' | 'requestId' | 'label' | 'brief' | 'references' | 'previewRoutes' | 'runLabel' | 'projectKind' | 'status' | 'createdAt' | 'statusChangedAt' | 'changedFilesCount' | 'preview' | 'artifact' | 'parentVariant' | 'serve' | 'runtime'> & {
|
|
125
|
+
export type VariantHistoryRow = Pick<VariantHistoryManifest, 'sessionId' | 'variantId' | 'requestId' | 'directionRef' | 'label' | 'brief' | 'references' | 'previewRoutes' | 'runLabel' | 'projectKind' | 'status' | 'createdAt' | 'statusChangedAt' | 'changedFilesCount' | 'preview' | 'artifact' | 'parentVariant' | 'serve' | 'runtime'> & {
|
|
124
126
|
kind: VariantHistoryKind;
|
|
125
127
|
hasStaticPreview: boolean;
|
|
126
128
|
hasTree: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const FAILURE_REASON_CODES: readonly ["multiple_lockfiles", "unsupported_package_manager", "invalid_package_manager_field", "invalid_manifest", "invalid_workspace", "path_outside_workspace", "dangling_symlink", "version_unreadable", "version_mismatch", "no_install_command", "install_failed", "installer_unstoppable", "inputs_changed", "ENOENT", "EACCES", "EPERM", "EEXIST", "ENOTDIR", "EISDIR", "ELOOP", "ENOSPC", "EMFILE", "EADDRINUSE", "ECONNREFUSED", "ECONNRESET", "ETIMEDOUT", "EBUSY", "ENOTSUP", "EINVAL", "ENOTEMPTY", "EROFS", "EAI_AGAIN", "timeout", "aborted", "unknown"];
|
|
1
|
+
export declare const FAILURE_REASON_CODES: readonly ["multiple_lockfiles", "unsupported_package_manager", "invalid_package_manager_field", "invalid_manifest", "invalid_workspace", "path_outside_workspace", "dangling_symlink", "version_unreadable", "version_mismatch", "no_install_command", "install_failed", "lockfile_outdated", "engine_incompatible", "install_script_failed", "installer_unstoppable", "inputs_changed", "ENOENT", "EACCES", "EPERM", "EEXIST", "ENOTDIR", "EISDIR", "ELOOP", "ENOSPC", "EMFILE", "EADDRINUSE", "ECONNREFUSED", "ECONNRESET", "ETIMEDOUT", "EBUSY", "ENOTSUP", "EINVAL", "ENOTEMPTY", "EROFS", "EAI_AGAIN", "timeout", "aborted", "unknown"];
|
|
2
2
|
export type FailureReasonCode = (typeof FAILURE_REASON_CODES)[number];
|
|
3
3
|
export interface FailureReason {
|
|
4
4
|
reasonCode: FailureReasonCode;
|
|
@@ -28,7 +28,7 @@ exports.CLI_GUIDANCE_BODY = `Rivet helps you **explore multiple design direction
|
|
|
28
28
|
|
|
29
29
|
Use these independently exposed tools for their named purposes:
|
|
30
30
|
|
|
31
|
-
- \`rivet_explore_designs\` starts directions with \`project\`, \`instruction\`, \`runLabel\`, and one authored \`briefs\` entry per direction. Use \`baseDirectionId
|
|
31
|
+
- \`rivet_explore_designs\` starts directions with \`project\`, \`instruction\`, \`runLabel\`, and one authored \`briefs\` entry per direction. Use \`baseDirectionId\` with a direction's \`directionRef\` (for example \`"warm-editorial-green"\`) or \`"sessionId:variantId"\` to vary a result.
|
|
32
32
|
- \`rivet_get_exploration\` reads progress and results with \`project\`. Add \`sessionId\`, \`variantId\`, \`includeHistory\`, or the start response's \`workId\` for recorded context receipts.
|
|
33
33
|
- \`rivet_cancel_exploration\` cancels the named \`project\` and \`sessionId\` only when the user asks.
|
|
34
34
|
- \`rivet_find_references\` searches retained titles, text, notes, and analysis with \`query\`, optional \`sourceId\`, and optional \`limit\`. Its \`saved_text\` ranking is lexical. It does not start workers, create an index, or perform semantic model search.
|
|
@@ -95,12 +95,13 @@ The export returns \`{checks:[{id,status:"pass"|"fail"|"blocked",priority:"high"
|
|
|
95
95
|
- \`rivet open [--project <path>] [--agent claude|codex|cursor] [--rivet-port N] [--user-port N] [--framework nextjs|vite|cra|remix|svelte|static] [--entry <path>] [--no-browser] [--no-git]\` — start or attach the project's editor server (idempotent; returns \`editorUrl\`). It detects the app, attaches to an already-running dev server, or starts one from the app's standard \`dev\`/\`start\`/\`serve\`/\`storybook\` script when possible. Follow the browser behavior above for interactive work.
|
|
96
96
|
- **Attach, don't rebuild.** If the user's dev server is already running (including Storybook — component-library teams often run only Storybook), pass \`--user-port <port>\` to attach directly: this skips detection and never starts a second server. Auto-detection scans common ports (3000, 5173, 6006, …), but an explicit \`--user-port\` is always the most reliable path — when in doubt, ask the user which port their app is on, or start the dev server yourself first and pass its port.
|
|
97
97
|
- **Rivet never installs dependencies.** If \`open\` fails because the app's start command failed, the error carries the exact command and its output. YOU own the fix: diagnose the output, run the project's install yourself if dependencies are missing, or start the dev server yourself — then re-run \`rivet open --user-port <port>\`. Do not retry \`rivet open\` unchanged expecting a different result.
|
|
98
|
-
- \`rivet variants start --project <path> --instruction <text> [--run-label <text>] [--briefs <json>] [--count N] [--fidelity low|medium|high] [--element <selector>] [--files <json>] [--fresh] [--profile auto|off] [--context-images <json>] [--reference-pages <json>] [--reference-videos <json>] [--target <sessionId>:<variantId>] [--worker-provider claude|codex|cursor] [--worker-model <id>]\` — explore design directions. For every start, including fresh apps and \`--target\` requests, agent invocations MUST pass an AI-authored 1–3 word batch label through \`rivet_explore_designs\` \`runLabel\` or CLI \`--run-label\`, plus one AI-authored brief per direction; \`briefs.length\` sets the count. Fresh starts use the same host-authored briefs and batch label; Rivet prepares reference context for the workers without calling a planning model. Use \`--files\` for already-known project paths and \`--target\` to Vary an existing direction. Returns a \`workId\` and \`nextAction\` after workspace provisioning.
|
|
98
|
+
- \`rivet variants start --project <path> --instruction <text> [--run-label <text>] [--briefs <json>] [--count N] [--fidelity low|medium|high] [--element <selector>] [--files <json>] [--fresh] [--profile auto|off] [--context-images <json>] [--reference-pages <json>] [--reference-videos <json>] [--target <directionRef>|<sessionId>:<variantId>] [--worker-provider claude|codex|cursor] [--worker-model <id>]\` — explore design directions. For every start, including fresh apps and \`--target\` requests, agent invocations MUST pass an AI-authored 1–3 word batch label through \`rivet_explore_designs\` \`runLabel\` or CLI \`--run-label\`, plus one AI-authored brief per direction; \`briefs.length\` sets the count. Fresh starts use the same host-authored briefs and batch label; Rivet prepares reference context for the workers without calling a planning model. Use \`--files\` for already-known project paths and \`--target\` to Vary an existing direction. Returns a \`workId\` and \`nextAction\` after workspace provisioning.
|
|
99
99
|
- \`rivet variants complete <workId> --project <path> [--session <sessionId>] [--status succeeded|failed|cancelled] [--output <json>] [--error <message>]\` — report one host-agent work item complete after you edit its assigned workspace. Static artifacts are read from disk; do not send them through \`--output\`.
|
|
100
100
|
- \`rivet wait <workId> --project <path> [--timeout <seconds>]\` — bounded block until a work id settles (exit 5 on timeout; re-issue or check status).
|
|
101
101
|
- \`rivet status --project <path> [--watch]\` — session, resolved runner, active run, and the variants snapshot. \`--watch\` streams NDJSON.
|
|
102
102
|
- \`rivet variants status --project <path>\` / \`rivet variants list --project <path> [--history]\` — inspect live or past directions.
|
|
103
103
|
- \`rivet variants get <projectId>/<sessionId>:<variantId> [--detail]\` — resolve a copied direction from any working directory through the local project library, even when its editor is closed. The default response is compact metadata and an artifact path; add \`--detail\` for the full diff, file list, and design notes.
|
|
104
|
+
- \`rivet variants get <directionRef>|last --project <path> [--detail]\` — resolve a direction by the short \`directionRef\` shown in status, history, and \`nextAction\` work items (for example \`warm-editorial-green\`), or the newest direction with \`last\`. Refs never change once assigned. An ambiguous or unknown ref fails with \`DIRECTION_AMBIGUOUS\` or \`WORK_ITEM_NOT_FOUND\` and lists the candidate refs in \`error.details.candidates\`.
|
|
104
105
|
- \`rivet variants cancel <sessionId> --project <path>\` — cancel a running variants session.
|
|
105
106
|
- \`rivet evidence capture --url <url>\` — rendered design evidence (root variables, element styles, fonts) for a reference URL.
|
|
106
107
|
- \`rivet reference fetch <url>\` — Pinterest / Are.na reference data via the user's connected account. Accepts full pin/board URLs and \`pin.it\` share links. Pinterest images are downloaded into \`.rivet/references/\` and returned as absolute paths (\`data.images\`, plus \`local_path\` per pin) — view them directly and pass them to variants via \`--context-images\` instead of relaying URLs. If Pinterest returns \`status: not_connected\`, present the returned \`authUrl\` to the user and retry after they authorize. On failure the error message says exactly what to tell the user (e.g. save the pin to a board first).
|
|
@@ -125,7 +126,7 @@ Existing app, using CLI commands when MCP is unavailable. With MCP use \`rivet_g
|
|
|
125
126
|
|
|
126
127
|
Fresh 0-to-1: with MCP use \`rivet_explore_designs\` with \`fresh: true\` after reading \`rivet_get_design_context\`. For the CLI flow, create or use an empty directory and run \`rivet open --project <path> ...\`. Resolve the selected saved instructions with \`rivet context resolve\`, then author a batch label and one distinct brief per direction from the user's request, supplied references, and saved instructions. Include concrete section, layout, typography, and interaction choices in each brief's notes. Run \`rivet variants start --project <path> --fresh --instruction "build a SaaS landing page" --run-label "Landing layouts" --briefs '<json>' ...\`, omitting \`--count\` because the briefs set the count. Rivet uses those briefs directly without a hosted planning call. Pass local reference images via \`--context-images '["/abs/path.png"]'\` (\`rivet_explore_designs\` \`contextImages\`) — Rivet copies them into the run context and every worker views them natively. Pass reference page URLs via \`--reference-pages '["https://example.com"]'\` (\`referencePages\`) — Rivet renders each page server-side for design evidence + a screenshot; never capture evidence or screenshot pages yourself. Pass local reference videos via \`--reference-videos '["/abs/clip.mp4"]'\` (\`referenceVideos\`) — Rivet samples keyframes server-side; never run ffmpeg yourself. Never substitute a prose description of media you can pass directly.
|
|
127
128
|
|
|
128
|
-
Vary an existing direction: with MCP read \`rivet_get_exploration\` and pass \`
|
|
129
|
+
Vary an existing direction: with MCP read \`rivet_get_exploration\` and pass the direction's \`directionRef\` as \`baseDirectionId\` to \`rivet_explore_designs\`. For the CLI flow, after status/list gives you its \`directionRef\`, author a batch label and two distinct delta briefs by default, then run \`rivet variants start --project <path> --target <directionRef> --instruction "make this calmer" --run-label "Calmer direction" --briefs '<json>' ...\`. Include \`--files '["src/known-target.tsx"]'\` when the relevant files are already known. Explicit briefs/counts remain authoritative.
|
|
129
130
|
|
|
130
131
|
Rivet owns orchestration; the host agent owns implementation. Do not wait for Rivet to spawn a separate agent. When \`rivet variants start\`, \`rivet status\`, \`rivet_explore_designs\`, or \`rivet_get_exploration\` returns \`nextAction.action="complete_host_variant_work"\`, complete those work items from the current host session. Follow the returned parallelism strategy: direct work stays in the current host; native delegation can be required even for one item with a requested model. Spawn one native worker per delegated workspace in the same turn, and have each worker report its own completion immediately via its \`completeCommand\` (or \`rivet_complete_variant_work\`) — a variant's completion must never wait for its siblings.
|
|
131
132
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
type ProviderPurpose = 'claude' | 'codex' | 'cursor' | 'verifier';
|
|
2
|
-
type ChildPurpose = ProviderPurpose | 'devServer' | 'packageManager' | '
|
|
2
|
+
type ChildPurpose = ProviderPurpose | 'devServer' | 'packageManager' | 'profileMemory' | 'git' | 'desktop';
|
|
3
3
|
type SubprocessPurpose = ChildPurpose | 'rivetRuntime';
|
|
4
4
|
export declare const subprocessEnvironment: (purpose: SubprocessPurpose, inherited?: NodeJS.ProcessEnv) => NodeJS.ProcessEnv;
|
|
5
5
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rivet-design",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "Local visual web development tool with AI-powered code modification",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"workspaces": [
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"markdown-it": "^14.1.0",
|
|
88
88
|
"open": "^8.4.0",
|
|
89
89
|
"package-manager-detector": "^1.8.0",
|
|
90
|
-
"parse5": "^
|
|
90
|
+
"parse5": "^8.1.0",
|
|
91
91
|
"playwright-core": "^1.58.2",
|
|
92
92
|
"posthog-node": "^5.52.4",
|
|
93
93
|
"simple-git": "^4.0.2",
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"eslint": "^9.36.0",
|
|
121
121
|
"eslint-config-prettier": "^10.1.8",
|
|
122
122
|
"eslint-plugin-react": "^7.37.5",
|
|
123
|
-
"eslint-plugin-react-hooks": "^
|
|
123
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
124
124
|
"globals": "^17.14.0",
|
|
125
125
|
"husky": "^9.1.7",
|
|
126
126
|
"jest": "^30.1.3",
|
|
@@ -212,5 +212,5 @@
|
|
|
212
212
|
"rivetPlugin": {
|
|
213
213
|
"toolContract": "intent-v2"
|
|
214
214
|
},
|
|
215
|
-
"gitHead": "
|
|
215
|
+
"gitHead": "24cfc02a15b83a2b7c9e324780ee1997b1120722"
|
|
216
216
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var ze=t=>{throw TypeError(t)};var we=(t,s,r)=>s.has(t)||ze("Cannot "+r);var k=(t,s,r)=>(we(t,s,"read from private field"),r?r.call(t):s.get(t)),V=(t,s,r)=>s.has(t)?ze("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,r),q=(t,s,r,i)=>(we(t,s,"write to private field"),i?i.call(t,r):s.set(t,r),r),W=(t,s,r)=>(we(t,s,"access private method"),r);import{S as Rt,n as je,s as It,r as Ct,Q as Ye,u as Pe,a as Pt,b as Et,c as u,e as Lt,d as At,f as Ot,g as Mt,h as $e,i as Tt,j as Dt,k as re,l as le,m as qt,o as e,B as G,p as Ne,P as zt,q as $t,t as Ft,v as Ht,w as Ut,X as Je,D as Xe,x as Ze,y as et,z as tt,A as st,C as rt,E as Kt,F as at,G as Fe,H as Qt,I as Bt,J as Vt,K as Wt,L as Z,M as be,N as z,R as Gt,O as it,T as se,U as Yt,V as Jt,W as ce,Y as Xt,Z as ie,_ as U,$ as nt,a0 as ye,a1 as Zt,a2 as es,a3 as H,a4 as ot,a5 as ts,a6 as de,a7 as ss,a8 as Se,a9 as rs,aa as He,ab as as,ac as is,ad as ns,ae as os,af as cs,ag as ls,ah as ds,ai as us,aj as hs,ak as ms,al as ps,am as xs,an as fs,ao as bs,ap as ct,aq as ys,ar as vs,as as gs,at as ws,au as js,av as Ns,aw as Ss,ax as ks}from"./main-1EDrDqgn.js";function Ue(t,s){const r=new Set(s);return t.filter(i=>!r.has(i))}var ne,F,oe,ee,Q,te,ue,he,me,pe,L,ke,_e,lt,Re,Ie,Ce,Ge,_s=(Ge=class extends Rt{constructor(s,r,i){super();V(this,L);V(this,ne);V(this,F);V(this,oe);V(this,ee);V(this,Q);V(this,te);V(this,ue);V(this,he);V(this,me);V(this,pe,[]);q(this,ne,s),q(this,ee,i),q(this,oe,[]),q(this,Q,[]),q(this,F,[]),this.setQueries(r)}onSubscribe(){this.listeners.size===1&&k(this,Q).forEach(s=>{s.subscribe(r=>{W(this,L,Ie).call(this,s,r)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,k(this,Q).forEach(s=>{s.destroy()})}setQueries(s,r){q(this,oe,s),q(this,ee,r),je.batch(()=>{const i=k(this,Q),n=W(this,L,Re).call(this,k(this,oe));n.forEach(h=>h.observer.setOptions(h.defaultedQueryOptions));const o=n.map(h=>h.observer),a=o.map(h=>h.getCurrentResult()),l=i.length!==o.length,m=o.some((h,g)=>h!==i[g]),y=l||m,v=y?!0:a.some((h,g)=>{const w=k(this,F)[g];return!w||!It(h,w)});!y&&!v||(y&&(q(this,pe,n),q(this,Q,o)),q(this,F,a),this.hasListeners()&&(y&&(Ue(i,o).forEach(h=>{h.destroy()}),Ue(o,i).forEach(h=>{h.subscribe(g=>{W(this,L,Ie).call(this,h,g)})})),W(this,L,Ce).call(this)))})}getCurrentResult(){return k(this,F)}getQueries(){return k(this,Q).map(s=>s.getCurrentQuery())}getObservers(){return k(this,Q)}getOptimisticResult(s,r){const i=W(this,L,Re).call(this,s),n=i.map(a=>a.observer.getOptimisticResult(a.defaultedQueryOptions)),o=i.map(a=>a.defaultedQueryOptions.queryHash);return[n,a=>W(this,L,_e).call(this,a??n,r,o),()=>W(this,L,ke).call(this,n,i)]}},ne=new WeakMap,F=new WeakMap,oe=new WeakMap,ee=new WeakMap,Q=new WeakMap,te=new WeakMap,ue=new WeakMap,he=new WeakMap,me=new WeakMap,pe=new WeakMap,L=new WeakSet,ke=function(s,r){const i=new Set;return r.map((n,o)=>{const a=s[o];return n.defaultedQueryOptions.notifyOnChangeProps?a:n.observer.trackResult(a,l=>{i.has(l)||(i.add(l),r.forEach(m=>{m.observer.trackProp(l)}))})})},_e=function(s,r,i){if(r){const n=k(this,me),o=i!==void 0&&n!==void 0&&(n.length!==i.length||i.some((a,l)=>a!==n[l]));return(k(this,F)!==k(this,he)||o||r!==k(this,ue))&&(q(this,ue,r),q(this,he,k(this,F)),i!==void 0&&q(this,me,i),q(this,te,Ct(k(this,te),r(s)))),k(this,te)}return s},lt=function(){var s;return!((s=k(this,ee))!=null&&s.combine)||k(this,Q).some((r,i)=>{var n;return r.options.suspense&&((n=k(this,F)[i])==null?void 0:n.data)===void 0})},Re=function(s){const r=new Map;k(this,Q).forEach(n=>{const o=n.options.queryHash;if(!o)return;const a=r.get(o);a?a.push(n):r.set(o,[n])});const i=[];return s.forEach(n=>{var l;const o=k(this,ne).defaultQueryOptions(n),a=((l=r.get(o.queryHash))==null?void 0:l.shift())??new Ye(k(this,ne),o);i.push({defaultedQueryOptions:o,observer:a})}),i},Ie=function(s,r){const i=k(this,Q).indexOf(s);i!==-1&&(q(this,F,k(this,F).slice()),k(this,F)[i]=r,W(this,L,Ce).call(this))},Ce=function(){var s;if(this.hasListeners()){const r=W(this,L,lt).call(this),i=k(this,te),n=r?i:W(this,L,_e).call(this,W(this,L,ke).call(this,k(this,F),k(this,pe)),(s=k(this,ee))==null?void 0:s.combine);(r||i!==n)&&je.batch(()=>{this.listeners.forEach(o=>{o(k(this,F))})})}},Ge);function Rs({queries:t,...s},r){const i=Pe(),n=Pt(),o=Et(),a=s.subscribed!==!1,l=u.useMemo(()=>t.map(N=>{const p=i.defaultQueryOptions(N);return p._optimisticResults=n?"isRestoring":a?"optimistic":void 0,p}),[t,i,n,a]);l.forEach(N=>{Lt(N);const p=i.getQueryCache().get(N.queryHash);At(N,o,p)}),Ot(o);const[m]=u.useState(()=>new _s(i,l,s)),[y,v,h]=m.getOptimisticResult(l,s.combine);u.useEffect(()=>{m.setQueries(l,s)},[l,s,m]);const g=!n&&a;u.useSyncExternalStore(u.useCallback(N=>g?m.subscribe(je.batchCalls(N)):Mt,[m,g]),()=>m.getCurrentResult(),()=>m.getCurrentResult());const w=y.some((N,p)=>$e(l[p],N))?y.flatMap((N,p)=>{const j=l[p];if(j&&$e(j,N)){const T=new Ye(i,j);return Tt(j,T,o)}return[]}):[];if(w.length>0)throw Promise.all(w);const R=y.find((N,p)=>{const j=l[p];return j&&Dt({result:N,errorResetBoundary:o,throwOnError:j.throwOnError,query:i.getQueryCache().get(j.queryHash),suspense:j.suspense})});if(R)throw R.error;return v(h())}/**
|
|
2
|
+
* @license lucide-react v1.70.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const dt={name:"arrow-up-right",size:24,node:[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]};dt.node;const ut=re(dt);/**
|
|
7
|
+
* @license lucide-react v1.70.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const ht={name:"clipboard-copy",size:24,node:[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]};ht.node;const Is=re(ht);/**
|
|
12
|
+
* @license lucide-react v1.70.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const mt={name:"ellipsis",size:24,node:[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],aliases:["more-horizontal"]};mt.node;const Cs=re(mt);/**
|
|
17
|
+
* @license lucide-react v1.70.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const pt={name:"folder-open",size:24,node:[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]};pt.node;const Ke=re(pt);/**
|
|
22
|
+
* @license lucide-react v1.70.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const xt={name:"image-off",size:24,node:[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M10.41 10.41a2 2 0 1 1-2.83-2.83",key:"1bzlo9"}],["line",{x1:"13.5",x2:"6",y1:"13.5",y2:"21",key:"1q0aeu"}],["line",{x1:"18",x2:"21",y1:"12",y2:"15",key:"5mozeu"}],["path",{d:"M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59",key:"mmje98"}],["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}]]};xt.node;const Ps=re(xt);/**
|
|
27
|
+
* @license lucide-react v1.70.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const ft={name:"images",size:24,node:[["path",{d:"m22 11-1.296-1.296a2.4 2.4 0 0 0-3.408 0L11 16",key:"9kzy35"}],["path",{d:"M4 8a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2",key:"1t0f0t"}],["circle",{cx:"13",cy:"7",r:"1",fill:"currentColor",key:"1obus6"}],["rect",{x:"8",y:"2",width:"14",height:"14",rx:"2",key:"1gvhby"}]]};ft.node;const Es=re(ft);/**
|
|
32
|
+
* @license lucide-react v1.70.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/const bt={name:"loader-circle",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],aliases:["loader-2"]};bt.node;const yt=re(bt),Ls=({project:t,onRename:s,onRemove:r,onSetPinned:i})=>{const n=le(),o=u.useRef(null),a=u.useRef(null),l=u.useRef(null),[m,y]=u.useState(!1),[v,h]=u.useState(!1),g=!!t.pinnedAt,[w,R]=u.useState(null),[N,p]=u.useState(t.name),[j,T]=u.useState(!1),[f,S]=u.useState(null),{containerRef:C,onKeyDown:O}=qt();let Y=w==="rename"?"Save name":"Remove from projects";j&&(Y="Saving…"),u.useEffect(()=>{var M;if(v||!l.current)return;const x=l.current==="button"?a:o;l.current=null,(M=x.current)==null||M.focus()},[v]);const A=x=>{y(x),n==null||n.capture(x?"library_project_menu_opened":"library_project_menu_closed")},E=async x=>{if(!v){l.current=x,h(!0),n==null||n.capture("library_project_pin_clicked",{is_pinning:!g,method:x});try{await i(t.id,!g)}catch(M){at.error(Fe(M,"Could not save pin. Try again."))}finally{h(!1)}}},B=x=>{A(!1),p(t.name),S(null),R(x),n==null||n.capture("library_project_action_opened",{action:x})},K=x=>{n==null||n.capture("library_project_action_closed",{action:w,outcome:x}),R(null)},_=async()=>{if(!(j||!w||w==="rename"&&!N.trim())){T(!0),S(null);try{w==="rename"?await s(t.id,N.trim()):await r(t.id),K("completed")}catch(x){S(Fe(x,"Could not save changes. Try again."))}finally{T(!1)}}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`flex items-center gap-0.5 group-hover/project:pointer-events-auto group-hover/project:opacity-100 has-[:focus-visible]:pointer-events-auto has-[:focus-visible]:opacity-100 [@media(hover:none)]:pointer-events-auto [@media(hover:none)]:opacity-100 ${m?"pointer-events-auto opacity-100":"pointer-events-none opacity-0"}`,children:[e.jsx(G,{ref:a,type:"button",variant:"ghost",size:"icon-compact",title:g?"Unpin project":"Pin project","aria-label":`${g?"Unpin":"Pin"} ${t.name}`,"aria-pressed":g,disabled:v,onClick:()=>{E("button")},children:e.jsx(Ne,{weight:g?"fill":"bold",size:16,"aria-hidden":!0})}),e.jsxs(zt,{open:m,onOpenChange:A,children:[e.jsx($t,{asChild:!0,children:e.jsx(G,{ref:o,type:"button",variant:"ghost",size:"icon-compact","aria-label":`Actions for ${t.name}`,children:e.jsx(Cs,{size:16,"aria-hidden":!0})})}),e.jsx(Ft,{children:e.jsxs(Ht,{"data-rivet-private":!0,ref:C,onKeyDown:O,role:"menu","aria-label":"Project actions",align:"start",sideOffset:4,onCloseAutoFocus:x=>{w&&x.preventDefault()},className:"ph-no-capture bg-surface-2 text-content z-ui-primary min-w-44 rounded-lg p-1 shadow-lg",children:[e.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,disabled:v,onClick:()=>{A(!1),E("menu")},className:"hover:bg-hover focus:bg-hover flex w-full items-center gap-2 rounded-md px-3 py-2 text-xs focus:outline-none disabled:opacity-50",children:[e.jsx(Ne,{size:14,weight:g?"fill":"bold","aria-hidden":!0}),g?"Unpin":"Pin"]}),e.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:()=>B("rename"),className:"hover:bg-hover focus:bg-hover flex w-full items-center gap-2 rounded-md px-3 py-2 text-xs focus:outline-none",children:[e.jsx(Ut,{size:14,"aria-hidden":!0}),"Rename"]}),e.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:()=>B("remove"),className:"hover:bg-hover focus:bg-hover flex w-full items-center gap-2 rounded-md px-3 py-2 text-xs focus:outline-none",children:[e.jsx(Je,{size:14,"aria-hidden":!0}),"Remove from projects"]})]})})]})]}),e.jsx(Xe,{open:w!==null,onOpenChange:x=>{!x&&!j&&K("cancelled")},children:e.jsxs(Ze,{children:[e.jsx(et,{className:"z-modal fixed inset-0 bg-black/60"}),e.jsxs(tt,{"data-rivet-private":!0,onCloseAutoFocus:x=>{var M;x.preventDefault(),(M=o.current)==null||M.focus()},className:"ph-no-capture bg-surface-2 text-content z-ui-secondary fixed top-1/2 left-1/2 w-[calc(100%-2rem)] max-w-sm -translate-x-1/2 -translate-y-1/2 rounded-xl p-6 shadow-lg",children:[e.jsx(st,{className:"text-base font-medium break-words",children:w==="rename"?"Rename project":`Remove “${t.name}” from projects?`}),e.jsx(rt,{className:"mt-2 text-sm leading-6 text-white/60",children:w==="rename"?"Choose a display name for this project. Its folder name will stay the same.":"Your folders and saved variants will remain on this computer. Open the project again to restore it."}),e.jsxs("form",{onSubmit:x=>{x.preventDefault(),_()},children:[w==="rename"?e.jsxs("label",{className:"mt-5 block text-xs text-white/70",children:["Project name",e.jsx("input",{autoFocus:!0,value:N,onChange:x=>p(x.target.value),maxLength:Kt,disabled:j,className:"mt-2 w-full rounded-lg border border-white/15 bg-white/5 px-3 py-2 text-sm text-white outline-none focus:border-white/50"})]}):null,f?e.jsx("p",{role:"alert",className:"mt-4 text-xs text-red-300",children:f}):null,e.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[e.jsx(G,{type:"button",variant:"ghost",disabled:j,onClick:()=>K("cancelled"),children:"Cancel"}),e.jsx(G,{type:"submit",variant:"secondary",disabled:j||w==="rename"&&!N.trim(),children:Y})]})]})]})]})})]})},vt=6e4,gt=60*vt,ve=24*gt,As=7*ve,Os=30*ve,Ms=365*ve,Ts=[["year",Ms],["month",Os],["week",As],["day",ve],["hour",gt],["minute",vt]],Ds=new Intl.RelativeTimeFormat("en",{numeric:"always"}),qs=t=>{const s=new Map;for(const r of t??[]){const i=Date.parse(r.createdAt);if(!Number.isFinite(i))continue;const n=s.get(r.projectId);(n===void 0||i>n)&&s.set(r.projectId,i)}return s},zs=({projects:t,latestEdits:s})=>[...t].sort((r,i)=>{if(r.pinnedAt&&!i.pinnedAt)return-1;if(i.pinnedAt&&!r.pinnedAt)return 1;if(r.pinnedAt&&i.pinnedAt)return r.pinnedAt.localeCompare(i.pinnedAt)||r.id.localeCompare(i.id);const n=s.get(r.id),o=s.get(i.id);return n===void 0&&o!==void 0?1:o===void 0&&n!==void 0?-1:(o??0)-(n??0)||r.name.localeCompare(i.name)||r.id.localeCompare(i.id)}),$s=({editedAt:t,now:s})=>{const r=Math.max(0,s-t);for(const[i,n]of Ts)if(r>=n)return`Edited ${Ds.format(-Math.floor(r/n),i)}`;return"Edited just now"},wt=u.createContext(null),Fs=({navigation:t,onBrowseProjects:s,controls:r,isHeaderVisible:i=!0,children:n})=>{const[o,a]=u.useState(null);return e.jsxs(wt.Provider,{value:o,children:[i?e.jsxs("div",{className:"grid shrink-0 grid-cols-[auto_minmax(0,1fr)] items-center gap-4 px-10 py-5 max-sm:px-5 sm:grid-cols-[auto_minmax(0,1fr)_auto]",children:[e.jsx("button",{onClick:s,"aria-label":"Projects",className:"flex items-center",children:e.jsx("img",{src:Qt,alt:"","aria-hidden":!0,draggable:!1,className:"h-8 w-8"})}),e.jsx("div",{ref:a,className:"col-span-2 row-start-2 flex min-w-0 items-center gap-3 sm:col-span-1 sm:col-start-2 sm:row-start-1",children:r}),e.jsx("div",{className:"col-start-2 row-start-1 justify-self-end sm:col-start-3",children:t})]}):null,n]})},jt=({children:t})=>{const s=u.useContext(wt);return s?Bt.createPortal(t,s):null},Ee=({label:t,value:s,onChange:r,onBlur:i,isDisabled:n=!1})=>e.jsxs("label",{className:"flex w-64 min-w-0 items-center gap-2 rounded-lg border border-white/[0.08] bg-white/[0.02] px-3 py-2.5 text-white/35 max-sm:flex-1",children:[e.jsx(Vt,{size:14,className:"shrink-0","aria-hidden":!0}),e.jsx("input",{type:"search","aria-label":t,placeholder:`${t}…`,value:s,onChange:o=>r==null?void 0:r(o.target.value),onBlur:i,disabled:n,className:"min-w-0 flex-1 bg-transparent text-xs text-white outline-none placeholder:text-white/30 disabled:opacity-40 [&::-webkit-search-cancel-button]:hidden"})]}),Hs=({projects:t,variants:s,historyError:r,onRetryHistory:i,projectPreviews:n={},selectedProjectId:o,onSelectProject:a,onBrowseLibrary:l,onOpenProject:m,onRenameProject:y,onRemoveProject:v,onSetProjectPinned:h,isOpeningProject:g=!1,projectOpenError:w,onSearchCompleted:R,accountMenu:N,navigation:p,view:j="library",children:T})=>{const[f,S]=u.useState(""),C=o===null||T===void 0,O=u.useRef(null),Y=qs(s),[A]=u.useState(Date.now),E=t.find(_=>_.id===o),B=new Map;if(s)for(const _ of t)_.historyIssue||B.set(_.id,0);for(const{projectId:_}of s??[]){const x=B.get(_);x!==void 0&&B.set(_,x+1)}const K=zs({projects:t.filter(_=>_.name.toLowerCase().includes(f.toLowerCase())),latestEdits:Y});return e.jsx("div",{className:"ph-no-capture bg-background text-foreground flex h-screen min-h-0","data-rivet-private":!0,children:e.jsx("main",{className:"relative flex min-w-0 flex-1 flex-col overflow-hidden",children:e.jsxs(Fs,{navigation:p,onBrowseProjects:l,isHeaderVisible:C,controls:j==="library"?e.jsx(Ee,{label:"Search projects",value:f,onChange:S,onBlur:()=>R==null?void 0:R(f.length)}):null,children:[w?e.jsx("p",{role:"alert",className:"px-10 pt-5 text-xs text-red-200",children:w}):null,T!==void 0?T:e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-10 pb-10 max-sm:px-5",children:[e.jsx("h1",{ref:O,tabIndex:-1,className:"sr-only",children:"Projects"}),e.jsx("div",{className:"mb-9 flex items-center justify-end",children:e.jsx(G,{onClick:()=>m(),variant:"secondary",disabled:g,leadingIcon:Ke,className:"shrink-0",children:"Open project…"})}),r?e.jsxs("div",{role:"alert",className:"mb-6 flex items-center gap-3 text-xs text-white/60",children:[e.jsx("span",{children:r}),e.jsx("button",{onClick:i,className:"shrink-0 underline underline-offset-4",children:"Retry history"})]}):null,E!=null&&E.issue?e.jsx("p",{role:"alert",className:"mb-6 rounded-lg border border-amber-200/10 bg-amber-200/[0.03] p-4 text-xs leading-6 text-white/70",children:E.issue}):null,E&&!E.isAvailable?e.jsxs("div",{className:"mb-6 flex items-center justify-between gap-4 rounded-lg border border-amber-200/10 bg-amber-200/[0.03] p-4 text-xs text-white/60",children:[e.jsxs("span",{children:["Locate ",E.name,"’s working folder to open its workspace."]}),e.jsx("button",{disabled:g,onClick:()=>m(E.id),className:"shrink-0 text-white underline decoration-white/30 underline-offset-4",children:"Locate folder"})]}):null,e.jsxs("div",{className:"grid items-start gap-x-6 gap-y-8 sm:grid-cols-2",children:[K.map(_=>{const x=B.get(_.id);let M="Loading variants…";x!==void 0?M=`${x.toLocaleString()} ${x===1?"variant":"variants"}`:(r||_.historyIssue)&&(M="Variants unavailable");const d=Y.get(_.id);let I="No edits yet";r||_.historyIssue?I="Edit history unavailable":s===void 0?I="Loading edits…":x&&(I="Edit date unavailable");const $=n[_.id];return e.jsxs("div",{className:"group/project grid min-w-0",children:[e.jsxs("button",{onClick:()=>{S(""),a(_.id)},className:"group col-start-1 row-span-2 row-start-1 -m-2 grid w-[calc(100%+1rem)] min-w-0 grid-rows-subgrid rounded-2xl p-2 text-left hover:bg-white/[0.06] focus-visible:bg-white/[0.06] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-white/60",children:[e.jsx("span",{className:"group-hover:border-border relative block aspect-video overflow-hidden rounded-xl border border-white/[0.08] bg-white/[0.02]",children:$?e.jsx("img",{src:$.dataUrl,alt:`${_.name} — ${$.label}`,draggable:!1,className:"h-full w-full object-cover object-top"}):null}),e.jsxs("span",{className:"mt-3 block pr-16",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-sm font-medium",children:[_.pinnedAt?e.jsx(Ne,{size:12,weight:"fill","aria-hidden":!0,className:"text-content-muted shrink-0"}):null,e.jsx("span",{className:"truncate",children:_.name})]}),e.jsxs("span",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-white/40 group-hover:text-white/65 group-focus-visible:text-white/65",children:[d!==void 0?e.jsx("time",{dateTime:new Date(d).toISOString(),title:new Date(d).toLocaleString(),children:$s({editedAt:d,now:A})}):e.jsx("span",{children:I}),e.jsx("span",{className:"shrink-0",children:M})]}),_.isAvailable?null:e.jsx("span",{className:"mt-2 block text-xs text-amber-200/65",children:"Folder unavailable"})]})]}),e.jsx("div",{className:"z-content col-start-1 row-start-2 mt-3 self-center justify-self-end",children:e.jsx(Ls,{project:_,onRename:y,onSetPinned:h,onRemove:async J=>{var ae;await v(J),(ae=O.current)==null||ae.focus()}})})]},_.id)}),K.length===0?e.jsxs("div",{className:"col-span-full flex min-h-80 flex-col items-center justify-center rounded-xl border border-dashed border-white/10 px-8 text-center",children:[e.jsx(Ke,{size:26,className:"mb-5 text-white/25"}),e.jsx("h2",{className:"text-sm font-medium",children:f?"No matching projects":"Add your projects"}),e.jsx("p",{className:"mt-2 max-w-sm text-xs leading-6 text-white/40",children:f?"Try another project name.":"Open an existing project to add it as a project here"}),f?null:e.jsx(G,{onClick:()=>m(),variant:"secondary",disabled:g,className:"mt-5",children:"Open project"})]}):null]})]}),C&&N?e.jsx("footer",{className:"border-main-border bg-main-light shrink-0 border-t px-2.5 py-2.5",children:N}):null]})})})},Nt=8,Qe=1,Us=({children:t})=>e.jsx("ul",{className:"grid grid-cols-1 items-start gap-x-5 min-[400px]:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5",style:{gridAutoRows:`${Nt}px`},children:t}),Ks=({children:t})=>{const[s,r]=u.useState(Qe),i=u.useRef(null),n=u.useCallback(o=>{var l;if((l=i.current)==null||l.disconnect(),!o)return;const a=()=>r(Math.max(Qe,Math.ceil(o.getBoundingClientRect().height/Nt)));a(),i.current=new ResizeObserver(a),i.current.observe(o)},[]);return e.jsx("li",{className:"min-w-0",style:{gridRowEnd:`span ${s}`},children:e.jsx("div",{ref:n,className:"relative pb-8",children:t})})},Qs=async({profileId:t,referenceId:s,hash:r,signal:i})=>{const n=await Wt(`/api/library/profile/references/${encodeURIComponent(s)}/media/${r}?${new URLSearchParams({profileId:t})}`,{signal:i});if(!n.ok)throw new Error("Image unavailable");return n.blob()},Bs="200px",St=({profileId:t,referenceId:s,hash:r,title:i,isDetail:n=!1})=>{const[o,a]=u.useState(!1),[l,m]=u.useState(!1),y=u.useRef(null),v=u.useCallback(w=>{var R;(R=y.current)==null||R.disconnect(),w&&(y.current=new IntersectionObserver(N=>{var p;N.some(j=>j.isIntersecting)&&(a(!0),(p=y.current)==null||p.disconnect())},{rootMargin:Bs}),y.current.observe(w))},[]),h=Z({queryKey:z.designLibraryImage({profileId:t,referenceId:s,hash:r}),queryFn:async({signal:w})=>{const R=await Qs({profileId:t,referenceId:s,hash:r,signal:w});return new Promise((N,p)=>{const j=new FileReader;j.onload=()=>typeof j.result=="string"?N(j.result):p(new Error("Image unavailable")),j.onerror=()=>p(new Error("Image unavailable")),j.readAsDataURL(R)})},enabled:o,staleTime:1/0,gcTime:0,retry:!1}),g=!!h.data&&!l;return e.jsxs("div",{ref:v,className:be("flex items-center justify-center overflow-hidden bg-white/[0.025]",n?"min-h-32":null,!n&&!g?"aspect-[4/3]":null),children:[h.isError||l?e.jsxs("span",{className:"flex items-center gap-2 p-5 text-xs text-white/35",children:[e.jsx(Ps,{size:16,"aria-hidden":!0}),"Image unavailable"]}):null,h.data&&!l?e.jsx("img",{src:h.data,alt:i,onError:()=>m(!0),className:n?"max-h-[65vh] w-full object-contain":"block h-auto w-full"}):null,!h.data&&!h.isError?e.jsx("span",{className:"text-xs text-white/25",children:"Loading image…"}):null]})},Vs={arena:"Are.na",cosmos:"Cosmos",pinterest:"Pinterest",x:"X",image:"Uploaded image",text:"Saved text",variant:"Saved direction",pdf:"PDF"},Ws=({provider:t})=>e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t==="arena"||t==="cosmos"||t==="pinterest"||t==="x"?e.jsx(Gt,{provider:t,className:"h-3.5 w-3.5"}):null,Vs[t]]}),Gs=({label:t,onCopy:s,referenceCount:r=1})=>{const i=le(),[n,o]=u.useState("idle"),a=async()=>{o("copying");try{await s(),o("copied"),i==null||i.capture("library_reference_copy_completed",{reference_count:r,copy_kind:"agent"})}catch{o("failed"),at.error("Could not copy. Check clipboard access and try again."),i==null||i.capture("library_reference_copy_failed",{reference_count:r,copy_kind:"agent"})}},l=n==="copied"?it:Is,m=n==="copied"?"Copied":t;return e.jsxs(e.Fragment,{children:[e.jsx(G,{variant:"secondary",size:"compact",leadingIcon:l,disabled:n==="copying",onClick:()=>void a(),"aria-label":m,"aria-live":"polite",children:e.jsxs("span",{className:"grid whitespace-nowrap",children:[e.jsx("span",{"aria-hidden":!0,className:"invisible col-start-1 row-start-1",children:t}),e.jsx("span",{className:"col-start-1 row-start-1",children:m})]})}),n==="failed"?e.jsx("span",{role:"alert",className:"sr-only",children:"Could not copy. Check clipboard access and try again."}):null]})},kt=se({id:U(),title:U(),provider:nt,isIncluded:ye()}),Ys=Yt.extend({sourceIds:ce(U()),observation:Jt.nullable()}),Js=se({profileId:U(),revision:ie(),isEnabled:ye(),sources:ce(kt),references:ce(Ys)});se({query:U().trim().min(2).max(1e3),sourceId:U().min(1).max(200).optional(),limit:ie().int().min(1).max(100).default(24),runtime:Xt.default("codex")});const Xs=se({profileId:U(),query:U(),coverage:se({saved:ie(),analyzed:ie(),indexed:ie()}),results:ce(se({id:U(),key:U(),title:U(),provider:nt,url:U().optional(),description:U().nullable(),imageCount:ie(),sources:ce(kt),isIncluded:ye()}))}),_t=50,Be=12,Zs=U().regex(/^[a-f0-9]{12,64}@[1-9][0-9]*$/).refine(t=>Number.isSafeInteger(Number(t.split("@")[1])),"Invalid reference revision"),er=se({profileId:U().uuid(),keys:ce(Zs).min(1).max(_t),isDetailed:ye().default(!1)}),tr=t=>{const s=new Map;for(const r of t){const i=r.id.slice(0,Be);s.set(i,(s.get(i)??0)+1)}return new Map(t.map(r=>{const i=r.id.slice(0,Be),n=s.get(i)===1?i:r.id;return[r.id,`${n}@${r.revision}`]}))},sr=({profileId:t,referenceKeys:s})=>{const r=er.parse({profileId:t,keys:s});return["rivet","profile","reference",r.profileId,...r.keys].join(" ")},Le=t=>{const s=t.referenceKeys.length===1?"Copy to agent":`Copy ${t.referenceKeys.length} to agent`;return e.jsx(Gs,{label:s,referenceCount:t.referenceKeys.length,onCopy:()=>navigator.clipboard.writeText(sr(t))})},rr=({profileId:t,reference:s,sources:r,referenceKey:i,children:n})=>{var m,y;const o=le(),a=s.title||"Untitled reference",l=s.url&&/^https?:\/\//i.test(s.url)?s.url:void 0;return e.jsxs(Xe,{onOpenChange:v=>o==null?void 0:o.capture(v?"library_reference_opened":"library_reference_closed",{provider:s.provider,media_count:s.media.length}),children:[e.jsx(Zt,{asChild:!0,children:n}),e.jsxs(Ze,{children:[e.jsx(et,{className:"fixed inset-0 z-50 bg-black/55"}),e.jsxs(tt,{className:"ph-no-capture bg-background text-foreground fixed inset-y-0 right-0 z-50 flex w-full max-w-2xl flex-col border-l border-white/10 shadow-2xl outline-none","data-rivet-private":!0,children:[e.jsxs("header",{className:"flex items-start justify-between gap-6 border-b border-white/[0.07] px-7 py-6",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(rt,{className:"mb-2 text-xs text-white/40",children:e.jsx(Ws,{provider:s.provider})}),e.jsx(st,{className:"text-lg leading-snug font-medium tracking-tight break-words",children:a})]}),e.jsx(es,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon-compact","aria-label":"Close reference",children:e.jsx(Je,{size:18})})})]}),e.jsx("div",{className:"border-b border-white/[0.07] px-7 py-4",children:e.jsx(Le,{profileId:t,referenceKeys:[i]},s.revision)}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-7 overflow-y-auto px-7 py-6",children:[s.media.map(v=>e.jsx(St,{profileId:t,referenceId:s.id,hash:v.hash,title:a,isDetail:!0},v.hash)),s.text?e.jsx("p",{className:"text-sm leading-7 break-words whitespace-pre-wrap text-white/70",children:s.text}):null,s.note?e.jsxs("section",{children:[e.jsx("h3",{className:"mb-2 text-xs font-medium text-white/45",children:"Your note"}),e.jsx("p",{className:"text-sm leading-7 break-words whitespace-pre-wrap text-white/75",children:s.note})]}):null,e.jsxs("section",{children:[e.jsx("h3",{className:"mb-2 text-xs font-medium text-white/45",children:((m=s.observation)==null?void 0:m.evidence)==="preference"?"Your preference":"Rivet’s analysis"}),e.jsx("p",{className:"text-sm leading-7 break-words whitespace-pre-wrap text-white/75",children:((y=s.observation)==null?void 0:y.description)??s.unsupportedReason??"No analysis saved yet."})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"mb-3 text-xs font-medium text-white/45",children:"Saved in"}),e.jsx("ul",{className:"space-y-2",children:r.filter(v=>s.sourceIds.includes(v.id)).map(v=>e.jsxs("li",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md bg-white/[0.035] px-3 py-2.5 text-xs",children:[e.jsx("span",{children:v.title}),v.isIncluded?null:e.jsx("span",{className:"text-white/35",children:"Excluded from generation"})]},v.id))})]}),l?e.jsxs("a",{href:l,target:"_blank",rel:"noopener noreferrer",onClick:()=>o==null?void 0:o.capture("library_reference_original_opened",{provider:s.provider}),className:"inline-flex items-center gap-1 text-xs text-white/70 underline-offset-4 hover:underline",children:["Open original",e.jsx(ut,{size:14,"aria-hidden":!0})]}):null]})]})]})]})},Ve="opacity-0 group-hover/card:opacity-100 group-focus-within/card:opacity-100 [@media(hover:none)]:opacity-100",ar="pointer-events-none group-hover/card:pointer-events-auto group-focus-within/card:pointer-events-auto [@media(hover:none)]:pointer-events-auto",ir=({profileId:t,reference:s,sources:r,referenceKey:i,isSelected:n,isSelectionDisabled:o,onSelect:a})=>{var y;const l=s.title||"Untitled reference",m=s.media[0];return e.jsxs("div",{className:"group/card relative",children:[e.jsx(rr,{profileId:t,reference:s,sources:r,referenceKey:i,children:e.jsx("button",{"aria-label":`Inspect ${l}`,className:"block w-full overflow-hidden text-left outline-none focus-visible:ring-2 focus-visible:ring-white/50 focus-visible:ring-offset-4 focus-visible:ring-offset-background",children:m?e.jsx(St,{profileId:t,referenceId:s.id,hash:m.hash,title:l},m.hash):e.jsxs("div",{className:"min-h-44 border border-white/10 bg-white/[0.03] p-5 pb-14",children:[e.jsx("p",{className:"text-sm font-medium text-white/80",children:l}),e.jsx("p",{className:"mt-3 line-clamp-3 text-xs leading-5 text-white/45",children:((y=s.observation)==null?void 0:y.description)??s.text})]})})}),e.jsx("div",{"aria-hidden":!0,className:be("pointer-events-none absolute inset-0 bg-black/40",Ve)}),e.jsxs("div",{className:be("absolute inset-x-0 bottom-0 z-10 flex items-center justify-between gap-2 p-2",n?null:Ve,n?null:ar),children:[e.jsxs("label",{className:"relative shrink-0 cursor-pointer",title:n?"Deselect":"Select",children:[e.jsx("input",{type:"checkbox","aria-label":`Select ${l}`,checked:n,disabled:o,onChange:a,className:"peer absolute inset-0 h-full w-full cursor-pointer opacity-0 disabled:cursor-default"}),e.jsx("span",{className:be("flex h-7 w-7 items-center justify-center rounded-full border shadow-sm peer-focus-visible:ring-2 peer-focus-visible:ring-white peer-focus-visible:ring-offset-2 peer-disabled:opacity-40",n?"border-orange-400 bg-orange-500 text-white":"border-white/35 bg-black/60 text-white/70"),children:e.jsx(it,{size:14,"aria-hidden":!0})})]}),e.jsx(Le,{profileId:t,referenceKeys:[i]},s.revision)]})]})},xe=24,nr="200px",or=350,cr=100,lr=({snapshot:t})=>{var M;const s=le(),[r,i]=u.useState(""),[n,o]=u.useState(""),a=u.useRef(null),[l,m]=u.useState(""),[y,v]=u.useState(xe),[h,g]=u.useState([]),w=u.useRef(null),R=tr(t.references),N=t.references.filter(d=>d.media.length>0),p=Z({queryKey:z.designReferenceSearch({profileId:t.profileId,revision:t.revision,references:t.references.map(({id:d,revision:I,sourceIds:$})=>[d,I,$]),search:n,sourceId:l}),queryFn:({signal:d})=>H("/profile/search",{schema:Xs,method:"POST",body:{query:n,sourceId:l||void 0,limit:cr},signal:d}),enabled:n.length>=2&&t.references.length>0,retry:!1}),j=t.references.filter(d=>h.includes(d.id)),T=j.flatMap(d=>{const I=R.get(d.id);return I?[I]:[]}),f=r.trim(),S=f.length>=2,C=S&&t.references.length>0&&(n!==f||p.isLoading),O=S&&!C&&p.isError,Y=new Map(t.references.map(d=>[d.id,d])),A=S?(((M=p.data)==null?void 0:M.results)??[]).flatMap(({id:d})=>{const I=Y.get(d);return I?[I]:[]}):N.filter(d=>!l||d.sourceIds.includes(l)),E=N.length>0,B=A.length,K=t.references.length>0?"No images yet":"Your library starts here",_=u.useCallback(d=>{var I;(I=w.current)==null||I.disconnect(),d&&(w.current=new IntersectionObserver($=>{var J;$.some(ae=>ae.isIntersecting)&&((J=w.current)==null||J.disconnect(),v(Math.min(y+xe,B)))},{root:d.parentElement,rootMargin:nr}),w.current.observe(d))},[y,B]),x=d=>{const I=j.map(J=>J.id),$=I.includes(d)?I.filter(J=>J!==d):[...I,d];g($),s==null||s.capture("library_reference_selection_changed",{selected_count:$.length})};return e.jsxs("div",{className:"ph-no-capture flex min-h-0 flex-1 flex-col","data-rivet-private":!0,children:[e.jsx(jt,{children:e.jsx(Ee,{label:"Search references",value:r,onChange:d=>{i(d),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>o(d.trim()),or),v(xe)},onBlur:()=>{var d;return s==null?void 0:s.capture("library_reference_search_completed",{query_length:r.length,result_count:S?((d=p.data)==null?void 0:d.results.length)??0:A.length})}})}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-10 pb-10 max-sm:px-5",children:[!t.isEnabled&&E?e.jsx("p",{className:"mb-5 text-xs text-white/40",children:"Automatic use is paused. Your saved references are still here."}):null,E?e.jsx("div",{className:"mb-7 flex flex-wrap items-center gap-3",children:e.jsxs("select",{"aria-label":"Source",value:l,onChange:d=>{m(d.target.value),v(xe),s==null||s.capture("library_reference_source_filtered",{is_filtered:!!d.target.value})},className:"bg-background max-w-64 rounded-lg border border-white/[0.08] px-3 py-2.5 text-xs text-white/60 focus-visible:outline-2",children:[e.jsx("option",{value:"",children:"All sources"}),t.sources.map(d=>e.jsx("option",{value:d.id,children:d.title},d.id))]})}):null,T.length?e.jsxs("div",{className:"bg-background sticky top-0 z-20 mb-6 flex flex-wrap items-center gap-3 rounded-lg border border-white/10 p-3 shadow-lg",children:[e.jsxs("span",{className:"text-xs text-white/50",children:[T.length," selected"]}),e.jsx(Le,{profileId:t.profileId,referenceKeys:T},T.join(" ")),e.jsx(G,{variant:"ghost",size:"compact",onClick:()=>{g([]),s==null||s.capture("library_reference_selection_changed",{selected_count:0})},children:"Clear selection"})]}):null,S&&p.data&&p.data.coverage.analyzed<p.data.coverage.saved?e.jsxs("p",{role:"status",className:"mb-5 text-xs text-white/45",children:[p.data.coverage.analyzed," of"," ",p.data.coverage.saved," references analyzed; results may be incomplete."]}):null,C?e.jsx("p",{role:"status",className:"py-10 text-center text-xs text-white/45",children:"Searching references…"}):null,O?e.jsxs("div",{role:"alert",className:"py-10 text-center text-xs text-white/50",children:[e.jsxs("p",{children:["Search is unavailable: ",p.error.message]}),e.jsx(G,{variant:"ghost",onClick:()=>{s==null||s.capture("library_reference_search_retry"),p.refetch()},children:"Try again"})]}):null,!C&&!O&&A.length?e.jsx(Us,{children:A.slice(0,y).map(d=>{const I=R.get(d.id);return I?e.jsx(Ks,{children:e.jsx(ir,{profileId:t.profileId,reference:d,sources:t.sources,referenceKey:I,isSelected:h.includes(d.id),isSelectionDisabled:!h.includes(d.id)&&T.length>=_t,onSelect:()=>x(d.id)})},d.id):null})}):null,!C&&!O&&!A.length?e.jsxs("div",{className:"flex min-h-72 flex-col items-center justify-center rounded-xl border border-dashed border-white/[0.08] px-6 text-center",children:[e.jsx(Es,{size:28,strokeWidth:1,className:"mb-5 text-white/25","aria-hidden":!0}),e.jsx("h2",{className:"text-sm text-white/75",children:E||S?"No references found":K}),e.jsx("p",{className:"mt-2 max-w-sm text-xs leading-6 text-white/35",children:E||S?"Try another search or choose a different source.":"Ask your agent to save a design reference with an image to your library. It will appear here, ready to browse."})]}):null,!C&&!O&&A.length>y?e.jsx("div",{ref:_,role:"status",className:"py-8 text-center text-xs text-white/35",children:"Loading more references…"}):null]})]})},dr=1e4,ur=({onBrowseProjects:t})=>{var a,l;const s=ot(),r=le(),i=Z({queryKey:z.designLibrary((a=s.data)==null?void 0:a.userId,(l=s.data)==null?void 0:l.isAuthenticated),queryFn:({signal:m})=>H("/profile/library",{schema:Js,signal:m}),enabled:!s.isPending,refetchInterval:dr,gcTime:0,retry:!1}),n=()=>{r==null||r.capture("library_reference_retry"),i.refetch()},o=e.jsx(jt,{children:e.jsx(Ee,{label:"Search references",value:"",isDisabled:!0})});return i.isError&&!i.data?e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[o,e.jsxs("div",{className:"m-auto max-w-md px-8 text-center",children:[e.jsx("h1",{className:"mb-3 text-lg font-medium",children:"References"}),e.jsx("p",{role:"alert",className:"text-sm text-white/50",children:i.error.message}),e.jsx("div",{className:"mt-5 flex justify-center gap-3",children:e.jsx(G,{variant:"ghost",onClick:t,children:"Projects"})})]})]}):i.data?e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[i.isError?e.jsxs("div",{role:"alert",className:"flex items-center justify-between gap-4 border-b border-white/10 px-8 py-3 text-xs text-white/50",children:[e.jsx("span",{children:"Could not refresh. Showing the last saved results."}),e.jsx(G,{variant:"ghost",onClick:n,children:"Try again"})]}):null,e.jsx(lr,{snapshot:i.data},i.data.profileId)]}):e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[o,e.jsx("p",{role:"status",className:"m-auto text-xs text-white/40",children:"Loading references…"})]})},hr=({view:t,onNavigate:s})=>e.jsx("nav",{"aria-label":"Library",className:"flex items-center gap-1 rounded-lg bg-white/[0.03] p-1",children:["library","references"].map(r=>e.jsx("a",{href:r==="library"?"/rivet/library":"/rivet/library/references","aria-current":t===r?"page":void 0,onClick:i=>{i.metaKey||i.ctrlKey||i.shiftKey||i.altKey||(i.preventDefault(),s(r))},className:ts("rounded-md px-3 py-2 text-xs focus-visible:outline-2 focus-visible:outline-offset-2",t===r?"bg-white/[0.08] text-white":"text-white/45 hover:text-white/80"),children:r==="library"?"Projects":"References"},r))}),mr=()=>{const t=Pe(),s=async o=>{await t.cancelQueries({queryKey:z.projectLibrary.all}),t.setQueryData(z.projectLibrary.projects,a=>a&&{projects:o(a.projects)}),t.setQueriesData({queryKey:z.projectLibrary.histories},a=>{if(!a)return a;const l=o(a.projects),m=new Set(l.map(({id:y})=>y));return{projects:l,variants:a.variants.filter(({projectId:y})=>m.has(y))}}),t.invalidateQueries({queryKey:z.projectLibrary.all})},r=de({mutationFn:({projectId:o,name:a})=>H(`/projects/${encodeURIComponent(o)}`,{schema:Se,method:"PATCH",body:{name:a}}),onSuccess:({project:o})=>s(a=>a.map(l=>l.id===o.id?{...l,name:o.name}:l))}),i=de({mutationFn:({projectId:o,isPinned:a})=>H(`/projects/${encodeURIComponent(o)}/pin`,{schema:Se,method:a?"PUT":"DELETE"}),onSuccess:({project:o})=>s(a=>a.map(l=>l.id===o.id?{...l,pinnedAt:o.pinnedAt}:l))}),n=de({mutationFn:o=>H(`/projects/${encodeURIComponent(o)}`,{schema:ss,method:"DELETE"}),onSuccess:async(o,a)=>{await s(l=>l.filter(({id:m})=>m!==a)),await t.cancelQueries({queryKey:z.libraryProjectPreview.project(a)}),t.removeQueries({queryKey:z.libraryProjectPreview.project(a)})}});return{setProjectPinned:async(o,a)=>{await i.mutateAsync({projectId:o,isPinned:a})},renameProject:async(o,a)=>{await r.mutateAsync({projectId:o,name:a})},removeProject:async o=>{await n.mutateAsync(o)}}},We=2500,pr=500,xr=6e4,fr=[],br=[],fe=({error:t,retry:s})=>e.jsxs("div",{className:"m-auto max-w-md px-8 text-center",children:[e.jsx("p",{className:"text-sm text-white/70",children:t.message}),e.jsx("button",{onClick:s,className:"mt-5 rounded-lg border border-white/15 px-4 py-2 text-xs text-white/70",children:"Try again"})]}),yr=()=>{var Ae,Oe,Me,Te,De,qe;const t=le();rs(ot().data);const s=Pe(),{renameProject:r,removeProject:i,setProjectPinned:n}=mr(),o=u.useRef(),[a,l]=u.useState(()=>He(new URL(window.location.href))),[m]=u.useState(()=>crypto.randomUUID()),y=u.useRef(0),v=u.useRef(null),h=Z({queryKey:z.projectLibrary.projects,queryFn:({signal:c})=>H("/projects",{schema:ps,signal:c}),refetchInterval:We,retry:!1}),g=((Ae=h.data)==null?void 0:Ae.projects)??fr,w=g.map(({id:c,projectPath:b})=>({id:c,projectPath:b})).sort((c,b)=>c.id.localeCompare(b.id)),R=Z({queryKey:z.projectLibrary.history(w),queryFn:({signal:c})=>H("",{schema:xs,signal:c}),placeholderData:c=>{if(!c)return;const b=new Map(c.projects.map(({id:D,projectPath:X})=>[D,X]));if(!g.every(({id:D,projectPath:X})=>b.get(D)===X))return;const P=new Set(g.map(({id:D})=>D));return{projects:c.projects.filter(({id:D})=>P.has(D)),variants:c.variants.filter(({projectId:D})=>P.has(D))}},enabled:g.length>0,refetchInterval:We,retry:!1}),N=new Map((Oe=R.data)==null?void 0:Oe.projects.map(c=>[c.id,c])),p=g.map(c=>{const b=N.get(c.id);return{...c,issue:b?b.issue:c.issue,historyIssue:b?b.historyIssue:c.historyIssue}}),j=((Me=R.data)==null?void 0:Me.variants)??br,T=Rs({queries:p.map(c=>({queryKey:z.libraryProjectPreview.thumbnail(c.id,c.projectPath),queryFn:({signal:b})=>H(`/projects/${c.id}/thumbnail`,{schema:ms,signal:b}),enabled:a.kind==="library",refetchInterval:xr,retry:!1}))}),f=p.find(c=>c.id===a.projectId),S=j.find(c=>c.projectId===a.projectId&&c.sessionId===a.sessionId&&c.variantId===a.variantId),C=u.useCallback(c=>{window.history.pushState(null,"",as(c)),l(c)},[]);u.useEffect(()=>{f?o.current=f.id:h.isSuccess&&!h.isFetching&&a.projectId===o.current&&a.projectId&&(o.current=void 0,C({kind:"library"}))},[f,a.projectId,h.isSuccess,h.isFetching,C]),u.useEffect(()=>{const c=()=>l(He(new URL(window.location.href)));return window.addEventListener("popstate",c),()=>window.removeEventListener("popstate",c)},[]),u.useEffect(()=>{const c=new AbortController;let b;const P=async()=>{try{const D=await H(`/views/${m}`,{schema:cs,method:"PUT",body:{isFocused:document.visibilityState==="visible"&&document.hasFocus()},signal:c.signal});for(const X of D.navigations){if(c.signal.aborted)return;if(X.sequence>y.current){let ge="library";X.projectId&&(ge="workspace"),X.variantId&&(ge="preview"),C({...X,kind:ge}),y.current=X.sequence}await H(`/views/${m}/acknowledgements`,{schema:ls,method:"POST",body:{sequence:X.sequence},signal:c.signal})}}catch{}c.signal.aborted||(b=setTimeout(()=>{P()},pr))};return P(),()=>{c.abort(),clearTimeout(b)}},[m,C]);const O=Z({queryKey:z.libraryWorkspace(a.projectId),queryFn:()=>H(`/projects/${a.projectId}/runtime`,{schema:fs,method:"POST"}),enabled:a.kind==="workspace"&&!!a.projectId&&(f==null?void 0:f.isAvailable)===!0,retry:!1,refetchOnWindowFocus:!1}),Y=O.data?new URL(O.data.editorUrl).origin:null;u.useEffect(()=>{if(a.kind!=="workspace"||!Y)return;const c=b=>{!v.current||b.source!==v.current.contentWindow||b.origin!==Y||b.data!==ds||(t==null||t.capture("library_view_changed",{view:"projects"}),C({kind:"library"}))};return window.addEventListener("message",c),()=>window.removeEventListener("message",c)},[a.kind,Y,C,t]);const A=Z({queryKey:z.libraryPreview({projectId:a.projectId,sessionId:a.sessionId,variantId:a.variantId}),queryFn:()=>H(`/projects/${a.projectId}/variants/${a.sessionId}/${a.variantId}/preview`,{schema:bs,method:"POST"}),enabled:a.kind==="preview"&&!!(S!=null&&S.hasStaticPreview),retry:!1,refetchOnWindowFocus:!1}),E=de({mutationFn:c=>H(`/projects/${a.projectId}/variants/${a.sessionId}/${a.variantId}`,{schema:us,method:"PATCH",body:{label:c}}),onSuccess:()=>s.invalidateQueries({queryKey:z.projectLibrary.all})}),B=c=>{const b=p.find(P=>P.id===c);t==null||t.capture("library_project_selected",{project_id:c,workspace_available:(b==null?void 0:b.isAvailable)??!1}),C({kind:"workspace",projectId:c})},K=de({mutationFn:async c=>{const{projectPath:b}=await H("/folder-selections",{schema:hs,method:"POST"});return b===null?null:H(c?`/projects/${c}/workspace`:"/projects",{schema:Se,method:c?"PATCH":"POST",body:{projectPath:b}})},onSuccess:c=>{c&&(s.invalidateQueries({queryKey:z.projectLibrary.all}),t==null||t.capture("library_project_selected",{project_id:c.project.id,workspace_available:c.project.isAvailable}),C({kind:"workspace",projectId:c.project.id}))},onSettled:(c,b,P)=>{t==null||t.capture("library_open_project_closed",{is_relink:!!P})}}),_=c=>{K.isPending||(t==null||t.capture("library_open_project_opened",{is_relink:!!c}),K.mutate(c))},x=()=>{t==null||t.capture("library_view_changed",{view:"projects"}),C({kind:"library"})},M=()=>{t==null||t.capture("library_view_changed",{view:"workspace"}),C({...a,kind:"workspace"})},d=()=>{t==null||t.capture("library_history_retry"),R.refetch()};let I;if(a.kind==="workspace"&&(f==null?void 0:f.isAvailable)!==!1||a.kind==="preview"){let c=!1,b=e.jsxs("div",{className:"m-auto flex items-center gap-2 text-xs text-white/40",children:[e.jsx(yt,{size:14,className:"animate-spin"}),"Opening ",(f==null?void 0:f.name)??"project","…"]});if(h.data&&!f||R.data&&a.variantId&&!S)b=e.jsx("div",{className:"m-auto text-sm text-white/60",children:"This project or direction is no longer in your library."});else if(a.kind==="preview"&&R.error&&!R.data)b=e.jsx(fe,{error:R.error,retry:d});else if(a.kind==="workspace"&&O.error)b=e.jsx(fe,{error:O.error,retry:()=>{O.refetch()}});else if(a.kind==="workspace"&&O.data){c=!0;const P=new URL(O.data.editorUrl);P.searchParams.set("library","1"),P.searchParams.set("libraryOrigin",window.location.origin),a.sessionId&&a.variantId&&(P.searchParams.set("historySession",a.sessionId),P.searchParams.set("historyVariant",a.variantId)),b=e.jsx("iframe",{ref:v,title:`${(f==null?void 0:f.name)??"Project"} workspace`,src:P.toString(),allow:"clipboard-write","data-rivet-private":!0,className:"ph-no-capture min-h-0 w-full flex-1 border-0"},P.toString())}else a.kind==="preview"&&A.error?b=e.jsx(fe,{error:A.error,retry:()=>{A.refetch()}}):a.kind==="preview"&&A.data?b=e.jsx("iframe",{title:`${(S==null?void 0:S.label)??"Saved direction"} preview`,src:A.data.url,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",className:"min-h-0 w-full flex-1 border-0 bg-white"}):a.kind==="preview"&&S&&!S.hasStaticPreview&&(b=e.jsxs("div",{className:"m-auto max-w-sm text-center",children:[e.jsx("p",{className:"text-sm",children:S.hasInteractivePreview?"Open this direction in its workspace":"This direction contains saved code changes"}),e.jsx("p",{className:"mt-2 text-xs leading-6 text-white/40",children:S.hasInteractivePreview?"Rivet will start the preview with this project’s dependencies and configuration.":"Open the project to continue working with its saved history."}),e.jsx("button",{onClick:M,disabled:(f==null?void 0:f.isAvailable)===!1,className:"mt-5 rounded-lg bg-white px-4 py-2.5 text-xs font-medium text-black disabled:opacity-30",children:"Open workspace"})]}));I=e.jsxs(e.Fragment,{children:[a.kind==="preview"?e.jsxs("header",{className:"flex h-14 shrink-0 items-center gap-3 border-b border-white/[0.07] px-5",children:[e.jsx("button",{"aria-label":"Back to projects",onClick:x,className:"rounded p-1.5 text-white/45 hover:bg-white/5",children:e.jsx(is,{size:15})}),e.jsx("span",{className:"text-xs text-white/40",children:f==null?void 0:f.name}),S?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-white/20",children:"/"}),e.jsxs("form",{onSubmit:P=>{P.preventDefault();const D=new FormData(P.currentTarget);E.mutate(String(D.get("label")))},className:"flex min-w-0 flex-1 gap-2",children:[e.jsx("input",{name:"label","aria-label":"Direction name",defaultValue:S.label,className:"max-w-xs min-w-0 flex-1 bg-transparent text-xs text-white/80 outline-none"}),e.jsx("button",{disabled:E.isPending,className:"text-[10px] text-white/30 hover:text-white",children:"Rename"})]},`${S.projectId}:${S.variantId}`)]}):e.jsx("span",{className:"flex-1"}),a.kind==="preview"?e.jsxs("button",{onClick:M,disabled:(f==null?void 0:f.isAvailable)===!1,className:"flex items-center gap-1.5 rounded-md border border-white/10 px-3 py-1.5 text-[11px] text-white/70 disabled:opacity-30",children:["Edit in project",e.jsx(ut,{size:12})]}):null]}):null,a.kind==="workspace"&&!c?e.jsx("button",{onClick:x,className:"absolute top-5 left-5 rounded px-2 py-1 text-xs text-white/50 hover:bg-white/5 hover:text-white",children:"Projects"}):null,E.error?e.jsx("p",{role:"alert",className:"px-5 py-2 text-xs text-red-200",children:E.error.message}):null,b]})}let $=I;h.error&&!h.data?$=e.jsx(fe,{error:h.error,retry:()=>{h.refetch()}}):h.isPending&&($=e.jsx("div",{role:"status",className:"flex min-h-0 flex-1 items-center justify-center text-xs text-white/40",children:"Loading projects…"}));const J=a.kind==="references"?"references":"library",ae=e.jsx(hr,{view:J,onNavigate:c=>{t==null||t.capture("library_view_changed",{view:c==="references"?"references":"projects"}),C({kind:c})}});return a.kind==="references"&&($=e.jsx(ur,{onBrowseProjects:x})),e.jsxs(e.Fragment,{children:[e.jsx(Hs,{projects:p,variants:(Te=R.data)==null?void 0:Te.variants,historyError:(De=R.error)==null?void 0:De.message,onRetryHistory:d,projectPreviews:Object.fromEntries(p.map((c,b)=>{var P,D;return[c.id,(D=(P=T[b])==null?void 0:P.data)==null?void 0:D.preview]})),selectedProjectId:a.projectId??null,onSelectProject:B,onBrowseLibrary:x,navigation:ae,view:J,onOpenProject:_,onRenameProject:r,onRemoveProject:i,onSetProjectPinned:n,accountMenu:e.jsx(ns,{side:"top",align:"start"}),isOpeningProject:K.isPending,projectOpenError:(qe=K.error)==null?void 0:qe.message,onSearchCompleted:c=>t==null?void 0:t.capture("library_search_completed",{query_length:c}),children:$}),e.jsx(os,{position:"bottom-right",theme:"dark"})]})},vr=async t=>{const s=ks(),r=await ws("/api/library/browser-sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const i=js.safeParse(await r.json().catch(()=>null));throw new Error(i.success?i.data.error:"Could not start a library session.")}Ns(Ss(await r.json()),s)},gr=()=>{const t=u.useSyncExternalStore(ct,vs),{startLogin:s,isStartingLogin:r,loginError:i}=gs("library",vr);return e.jsx("main",{className:"flex min-h-screen items-center justify-center bg-[#111215] px-6 text-white",children:e.jsxs("div",{className:"w-full max-w-sm rounded-2xl border border-white/10 bg-white/[0.04] p-8 text-center shadow-2xl",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Rivet"}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-white/60",children:"Sign in to open your project library on this computer."}),e.jsxs("button",{type:"button",onClick:()=>void s(),disabled:r,className:"mt-7 inline-flex h-10 w-full items-center justify-center gap-2 rounded-lg bg-white px-4 text-sm font-medium text-black disabled:opacity-60",children:[r?e.jsx(yt,{size:16,className:"animate-spin"}):null,r?"Connecting…":"Continue with Google"]}),i||t?e.jsx("p",{role:"alert",className:"mt-4 text-sm text-red-300",children:i??t}):null]})})},Nr=()=>u.useSyncExternalStore(ct,ys)?e.jsx(yr,{}):e.jsx(gr,{});export{Nr as default};
|
|
37
|
+
//# sourceMappingURL=LibraryEntry-BE8nZneH.js.map
|
|
Binary file
|