rivet-design 0.22.0 → 0.23.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.
Files changed (218) hide show
  1. package/bin/rivet.js +6 -0
  2. package/dist/agent-variants/SessionStore.d.ts +2 -21
  3. package/dist/agent-variants/SessionStore.d.ts.map +1 -1
  4. package/dist/agent-variants/SessionStore.js +15 -279
  5. package/dist/agent-variants/SessionStore.js.map +1 -1
  6. package/dist/agent-variants/WorktreeOrchestrator.d.ts +0 -3
  7. package/dist/agent-variants/WorktreeOrchestrator.d.ts.map +1 -1
  8. package/dist/agent-variants/WorktreeOrchestrator.js +1 -62
  9. package/dist/agent-variants/WorktreeOrchestrator.js.map +1 -1
  10. package/dist/agent-variants/WorktreeOrchestrator.testHelpers.d.ts.map +1 -1
  11. package/dist/agent-variants/WorktreeOrchestrator.testHelpers.js +0 -12
  12. package/dist/agent-variants/WorktreeOrchestrator.testHelpers.js.map +1 -1
  13. package/dist/agent-variants/contracts.d.ts +896 -2423
  14. package/dist/agent-variants/contracts.d.ts.map +1 -1
  15. package/dist/agent-variants/contracts.js +2 -84
  16. package/dist/agent-variants/contracts.js.map +1 -1
  17. package/dist/agent-variants/directionBriefs.d.ts +7 -0
  18. package/dist/agent-variants/directionBriefs.d.ts.map +1 -0
  19. package/dist/agent-variants/directionBriefs.js +51 -0
  20. package/dist/agent-variants/directionBriefs.js.map +1 -0
  21. package/dist/agent-variants/index.d.ts +1 -1
  22. package/dist/agent-variants/index.d.ts.map +1 -1
  23. package/dist/agent-variants/runPlan.d.ts +0 -1
  24. package/dist/agent-variants/runPlan.d.ts.map +1 -1
  25. package/dist/agent-variants/runPlan.js +0 -4
  26. package/dist/agent-variants/runPlan.js.map +1 -1
  27. package/dist/agent-variants/sourceContext.d.ts +0 -2
  28. package/dist/agent-variants/sourceContext.d.ts.map +1 -1
  29. package/dist/agent-variants/sourceContext.js +1 -35
  30. package/dist/agent-variants/sourceContext.js.map +1 -1
  31. package/dist/agent-variants/variantsTelemetry.d.ts +0 -3
  32. package/dist/agent-variants/variantsTelemetry.d.ts.map +1 -1
  33. package/dist/agent-variants/variantsTelemetry.js.map +1 -1
  34. package/dist/agent-variants/workItemInput.d.ts +470 -470
  35. package/dist/cli/commands/context.d.ts +3 -1
  36. package/dist/cli/commands/context.d.ts.map +1 -1
  37. package/dist/cli/commands/context.js +38 -1
  38. package/dist/cli/commands/context.js.map +1 -1
  39. package/dist/cli/commands/contextRequest.d.ts +1 -0
  40. package/dist/cli/commands/contextRequest.d.ts.map +1 -1
  41. package/dist/cli/commands/contextRequest.js +65 -5
  42. package/dist/cli/commands/contextRequest.js.map +1 -1
  43. package/dist/cli/commands/guidanceReferences.d.ts +1 -0
  44. package/dist/cli/commands/guidanceReferences.d.ts.map +1 -1
  45. package/dist/cli/commands/guidanceReferences.js +5 -4
  46. package/dist/cli/commands/guidanceReferences.js.map +1 -1
  47. package/dist/cli/commands/guidanceVerifierPackage.d.ts +9 -0
  48. package/dist/cli/commands/guidanceVerifierPackage.d.ts.map +1 -0
  49. package/dist/cli/commands/guidanceVerifierPackage.js +41 -0
  50. package/dist/cli/commands/guidanceVerifierPackage.js.map +1 -0
  51. package/dist/cli/commands/mcpServe.d.ts +1 -0
  52. package/dist/cli/commands/mcpServe.d.ts.map +1 -1
  53. package/dist/cli/commands/mcpServe.js +457 -326
  54. package/dist/cli/commands/mcpServe.js.map +1 -1
  55. package/dist/cli/commands/variants.js +2 -2
  56. package/dist/cli/commands/variants.js.map +1 -1
  57. package/dist/cli/handoffStore.d.ts +0 -1
  58. package/dist/cli/handoffStore.d.ts.map +1 -1
  59. package/dist/cli/handoffStore.js +1 -11
  60. package/dist/cli/handoffStore.js.map +1 -1
  61. package/dist/cli/router.d.ts +3 -1
  62. package/dist/cli/router.d.ts.map +1 -1
  63. package/dist/cli/router.js +4 -3
  64. package/dist/cli/router.js.map +1 -1
  65. package/dist/config/flags.d.ts +0 -3
  66. package/dist/config/flags.d.ts.map +1 -1
  67. package/dist/config/flags.js +0 -1
  68. package/dist/config/flags.js.map +1 -1
  69. package/dist/hosts/workerDefaults.d.ts +0 -1
  70. package/dist/hosts/workerDefaults.d.ts.map +1 -1
  71. package/dist/hosts/workerDefaults.js +1 -2
  72. package/dist/hosts/workerDefaults.js.map +1 -1
  73. package/dist/index-core.d.ts +1 -2
  74. package/dist/index-core.d.ts.map +1 -1
  75. package/dist/index-core.js +1 -3
  76. package/dist/index-core.js.map +1 -1
  77. package/dist/mcp/changeBatchClassification.d.ts +1 -11
  78. package/dist/mcp/changeBatchClassification.d.ts.map +1 -1
  79. package/dist/mcp/changeBatchClassification.js +0 -38
  80. package/dist/mcp/changeBatchClassification.js.map +1 -1
  81. package/dist/routes/library/guidance.d.ts.map +1 -1
  82. package/dist/routes/library/guidance.js +7 -0
  83. package/dist/routes/library/guidance.js.map +1 -1
  84. package/dist/server.d.ts +0 -1
  85. package/dist/server.d.ts.map +1 -1
  86. package/dist/server.js +1 -3
  87. package/dist/server.js.map +1 -1
  88. package/dist/services/AuthService.d.ts +4 -10
  89. package/dist/services/AuthService.d.ts.map +1 -1
  90. package/dist/services/AuthService.js +1 -116
  91. package/dist/services/AuthService.js.map +1 -1
  92. package/dist/services/GuidanceVerifierRunner.d.ts +15 -0
  93. package/dist/services/GuidanceVerifierRunner.d.ts.map +1 -0
  94. package/dist/services/GuidanceVerifierRunner.js +373 -0
  95. package/dist/services/GuidanceVerifierRunner.js.map +1 -0
  96. package/dist/services/HubDiscovery.d.ts +2 -2
  97. package/dist/services/IntegrationsClient.d.ts +3 -3
  98. package/dist/services/MCPOnboardingTelemetry.d.ts +0 -2
  99. package/dist/services/MCPOnboardingTelemetry.d.ts.map +1 -1
  100. package/dist/services/MCPOnboardingTelemetry.js +1 -78
  101. package/dist/services/MCPOnboardingTelemetry.js.map +1 -1
  102. package/dist/services/OperatingSystemServices.d.ts.map +1 -1
  103. package/dist/services/OperatingSystemServices.js +12 -5
  104. package/dist/services/OperatingSystemServices.js.map +1 -1
  105. package/dist/services/ProjectRegistry.d.ts +2 -2
  106. package/dist/services/TelemetryService.d.ts +1 -9
  107. package/dist/services/TelemetryService.d.ts.map +1 -1
  108. package/dist/services/TelemetryService.js +0 -28
  109. package/dist/services/TelemetryService.js.map +1 -1
  110. package/dist/services/VariantGenerationService.d.ts +1 -9
  111. package/dist/services/VariantGenerationService.d.ts.map +1 -1
  112. package/dist/services/VariantGenerationService.js +16 -140
  113. package/dist/services/VariantGenerationService.js.map +1 -1
  114. package/dist/services/VariantRunService.d.ts +0 -6
  115. package/dist/services/VariantRunService.d.ts.map +1 -1
  116. package/dist/services/VariantRunService.js +1 -28
  117. package/dist/services/VariantRunService.js.map +1 -1
  118. package/dist/services/VariantsRuntime.d.ts.map +1 -1
  119. package/dist/services/VariantsRuntime.js +0 -1
  120. package/dist/services/VariantsRuntime.js.map +1 -1
  121. package/dist/services/accessTokenRefresh.d.ts +0 -3
  122. package/dist/services/accessTokenRefresh.d.ts.map +1 -1
  123. package/dist/services/accessTokenRefresh.js +1 -33
  124. package/dist/services/accessTokenRefresh.js.map +1 -1
  125. package/dist/services/guidanceDelivery.d.ts +0 -5
  126. package/dist/services/guidanceDelivery.d.ts.map +1 -1
  127. package/dist/services/guidanceDelivery.js +1 -20
  128. package/dist/services/guidanceDelivery.js.map +1 -1
  129. package/dist/services/guidanceReferences.d.ts.map +1 -1
  130. package/dist/services/guidanceReferences.js +2 -76
  131. package/dist/services/guidanceReferences.js.map +1 -1
  132. package/dist/services/profiles/DesignProfiles.d.ts +31 -16
  133. package/dist/services/profiles/DesignProfiles.d.ts.map +1 -1
  134. package/dist/services/profiles/DesignProfiles.js +71 -17
  135. package/dist/services/profiles/DesignProfiles.js.map +1 -1
  136. package/dist/services/profiles/ProfilePlanning.d.ts +5 -5
  137. package/dist/services/profiles/ReferenceReader.d.ts +2 -2
  138. package/dist/services/profiles/profileContext.d.ts +1 -1
  139. package/dist/services/retainedTextFiles.d.ts +8 -0
  140. package/dist/services/retainedTextFiles.d.ts.map +1 -0
  141. package/dist/services/retainedTextFiles.js +95 -0
  142. package/dist/services/retainedTextFiles.js.map +1 -0
  143. package/dist/services/staticProjectTarget.d.ts +0 -1
  144. package/dist/services/staticProjectTarget.d.ts.map +1 -1
  145. package/dist/services/staticProjectTarget.js +1 -5
  146. package/dist/services/staticProjectTarget.js.map +1 -1
  147. package/dist/services/templates/designCatalog.d.ts +0 -4
  148. package/dist/services/templates/designCatalog.d.ts.map +1 -1
  149. package/dist/services/templates/designCatalog.js +1 -27
  150. package/dist/services/templates/designCatalog.js.map +1 -1
  151. package/dist/storage/profiles/ProfilePlans.d.ts +18 -18
  152. package/dist/storage/profiles/ProfileRecords.d.ts +52 -3
  153. package/dist/storage/profiles/ProfileRecords.d.ts.map +1 -1
  154. package/dist/storage/profiles/ProfileRecords.js +74 -17
  155. package/dist/storage/profiles/ProfileRecords.js.map +1 -1
  156. package/dist/storage/profiles/guidanceVerifier.d.ts +3 -0
  157. package/dist/storage/profiles/guidanceVerifier.d.ts.map +1 -0
  158. package/dist/storage/profiles/guidanceVerifier.js +30 -0
  159. package/dist/storage/profiles/guidanceVerifier.js.map +1 -0
  160. package/dist/storage/profiles/migrations.d.ts +2 -2
  161. package/dist/storage/profiles/migrations.d.ts.map +1 -1
  162. package/dist/storage/profiles/migrations.js +3 -0
  163. package/dist/storage/profiles/migrations.js.map +1 -1
  164. package/dist/storage/profiles/planSchema.d.ts +5 -5
  165. package/dist/storage/profiles/schema.d.ts +28 -1
  166. package/dist/storage/profiles/schema.d.ts.map +1 -1
  167. package/dist/storage/profiles/schema.js +1 -0
  168. package/dist/storage/profiles/schema.js.map +1 -1
  169. package/dist/types/change-types.d.ts +0 -25
  170. package/dist/types/change-types.d.ts.map +1 -1
  171. package/dist/types/cosmos-profile.d.ts +12 -12
  172. package/dist/types/cosmos.d.ts +20 -20
  173. package/dist/types/design-profile.d.ts +16 -16
  174. package/dist/types/guidance-references.d.ts +16 -0
  175. package/dist/types/guidance-references.d.ts.map +1 -1
  176. package/dist/types/guidance-references.js +44 -30
  177. package/dist/types/guidance-references.js.map +1 -1
  178. package/dist/types/guidance-verifier.d.ts +265 -0
  179. package/dist/types/guidance-verifier.d.ts.map +1 -0
  180. package/dist/types/guidance-verifier.js +71 -0
  181. package/dist/types/guidance-verifier.js.map +1 -0
  182. package/dist/types/guidance.d.ts +436 -21
  183. package/dist/types/guidance.d.ts.map +1 -1
  184. package/dist/types/guidance.js +13 -2
  185. package/dist/types/guidance.js.map +1 -1
  186. package/dist/types/reference-connectors.d.ts +20 -20
  187. package/dist/types/reference-onboarding.d.ts +48 -48
  188. package/dist/types/variant-reference.d.ts +4 -4
  189. package/dist/types/x-bookmarks.d.ts +10 -10
  190. package/dist/utils/skills/cli-guidance.d.ts +1 -1
  191. package/dist/utils/skills/cli-guidance.d.ts.map +1 -1
  192. package/dist/utils/skills/cli-guidance.js +19 -6
  193. package/dist/utils/skills/cli-guidance.js.map +1 -1
  194. package/dist/utils/skills/codex-skill.d.ts +1 -1
  195. package/dist/utils/skills/codex-skill.d.ts.map +1 -1
  196. package/dist/utils/skills/codex-skill.js +1 -1
  197. package/package.json +1 -2
  198. package/src/ui/dist/assets/{LibraryEntry-CjxmVfhv.js → LibraryEntry-B9ZkJUtN.js} +8 -8
  199. package/src/ui/dist/assets/main-CXP-A-qy.css +1 -0
  200. package/src/ui/dist/assets/{main-CdSzrhWD.js → main-Dls3YqrM.js} +144 -144
  201. package/src/ui/dist/index.html +2 -2
  202. package/dist/agent-variants/directionAuthoring.d.ts +0 -27
  203. package/dist/agent-variants/directionAuthoring.d.ts.map +0 -1
  204. package/dist/agent-variants/directionAuthoring.js +0 -380
  205. package/dist/agent-variants/directionAuthoring.js.map +0 -1
  206. package/dist/services/ComponentSearchService.d.ts +0 -13
  207. package/dist/services/ComponentSearchService.d.ts.map +0 -1
  208. package/dist/services/ComponentSearchService.js +0 -167
  209. package/dist/services/ComponentSearchService.js.map +0 -1
  210. package/dist/types/style-manipulation-types.d.ts +0 -63
  211. package/dist/types/style-manipulation-types.d.ts.map +0 -1
  212. package/dist/types/style-manipulation-types.js +0 -68
  213. package/dist/types/style-manipulation-types.js.map +0 -1
  214. package/dist/types/token-types.d.ts +0 -24
  215. package/dist/types/token-types.d.ts.map +0 -1
  216. package/dist/types/token-types.js +0 -3
  217. package/dist/types/token-types.js.map +0 -1
  218. package/src/ui/dist/assets/main-DVb3ws41.css +0 -1
@@ -7,8 +7,8 @@
7
7
  <link rel="icon" type="image/x-icon" href="/favicon.ico" />
8
8
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
9
9
  <title>Rivet - The visual editor for design</title>
10
- <script type="module" crossorigin src="/assets/main-CdSzrhWD.js"></script>
11
- <link rel="stylesheet" crossorigin href="/assets/main-DVb3ws41.css">
10
+ <script type="module" crossorigin src="/assets/main-Dls3YqrM.js"></script>
11
+ <link rel="stylesheet" crossorigin href="/assets/main-CXP-A-qy.css">
12
12
  </head>
13
13
  <body>
14
14
  <div id="root"></div>
@@ -1,27 +0,0 @@
1
- import type { GatewayClient, GatewayImageContent } from '../services/GatewayClient';
2
- import type { VariantDirectionBrief } from '../types/change-request-types';
3
- import type { GuidanceDocument } from '../types/guidance';
4
- export type DirectionAuthoringInput = {
5
- guidance?: GuidanceDocument[];
6
- prompt: string;
7
- count: number;
8
- displayLocale: string;
9
- images?: GatewayImageContent[];
10
- referenceNotes?: string[];
11
- };
12
- export type AuthoredDirections = {
13
- briefs: VariantDirectionBrief[];
14
- runLabel: string;
15
- source: 'gateway' | 'claude_runtime' | 'fallback';
16
- durationMs: number;
17
- };
18
- export declare const fallbackRunLabel: (prompt: string) => string;
19
- export declare const fallbackDirections: (prompt: string, count: number) => {
20
- briefs: VariantDirectionBrief[];
21
- runLabel: string;
22
- };
23
- export declare const authorDirections: (gateway: Pick<GatewayClient, "sendToolUse">, request: DirectionAuthoringInput, options?: {
24
- timeoutMs?: number;
25
- claudeCommand?: string;
26
- }) => Promise<AuthoredDirections>;
27
- //# sourceMappingURL=directionAuthoring.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"directionAuthoring.d.ts","sourceRoot":"","sources":["../../src/agent-variants/directionAuthoring.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AA8B1D,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,qBAAqB,EAAE,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,SAAS,GAAG,gBAAgB,GAAG,UAAU,CAAC;IAClD,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AA6BF,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,KAAG,MAOjD,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,MAAM,EACd,OAAO,MAAM,KACZ;IAAE,MAAM,EAAE,qBAAqB,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAcpD,CAAC;AA+QH,eAAO,MAAM,gBAAgB,GAC3B,SAAS,IAAI,CAAC,aAAa,EAAE,aAAa,CAAC,EAC3C,SAAS,uBAAuB,EAChC,UAAU;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,KACvD,OAAO,CAAC,kBAAkB,CA+E5B,CAAC"}
@@ -1,380 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.authorDirections = exports.fallbackDirections = exports.fallbackRunLabel = void 0;
4
- const generationCapacity_1 = require("./generationCapacity");
5
- const workerRuntime_1 = require("./workerRuntime");
6
- const child_process_1 = require("child_process");
7
- const logger_1 = require("../utils/logger");
8
- const guidancePrompt_1 = require("./guidancePrompt");
9
- const guidanceDelivery_1 = require("../services/guidanceDelivery");
10
- const errorMessage_1 = require("../utils/errorMessage");
11
- class DirectionInputDeliveryError extends Error {
12
- constructor(error) {
13
- super(`Direction planner input delivery failed: ${error.message}`);
14
- this.name = 'DirectionInputDeliveryError';
15
- }
16
- }
17
- const log = (0, logger_1.createLogger)('DirectionAuthoring');
18
- const DIRECTION_AUTHOR_MODEL = 'claude-haiku-4-5-20251001';
19
- const DIRECTION_AUTHOR_MAX_TOKENS = 1200;
20
- const DIRECTION_AUTHOR_TIMEOUT_MS = 25_000;
21
- const LABEL_MAX_LENGTH = 48;
22
- const BODY_MAX_LENGTH = 200;
23
- const NOTES_MAX_LENGTH = 1200;
24
- const RUN_LABEL_MAX_LENGTH = 40;
25
- const FALLBACK_ARCHETYPES = [
26
- {
27
- label: 'Faithful',
28
- body: 'Faithful recreation of the reference design language',
29
- },
30
- {
31
- label: 'Expressive',
32
- body: 'Amplify the boldest visual ideas in the request',
33
- },
34
- {
35
- label: 'Structural Remix',
36
- body: 'Same design system, different layout architecture',
37
- },
38
- { label: 'Editorial', body: 'Typography-led, editorial interpretation' },
39
- { label: 'Minimal', body: 'Pared-back, spacious, minimal interpretation' },
40
- ];
41
- const FALLBACK_NOTES = 'Derive every design decision directly from the visual references and the ' +
42
- 'request: match palette, typography, spacing, shapes, and energy. Ship every ' +
43
- 'section and interaction the request names — never a stripped-down subset. ' +
44
- 'When the request names motion, design and IMPLEMENT a concrete motion spec ' +
45
- '(trigger, timing, easing, choreography) grounded in what the references show.';
46
- const clip = (value, max) => value.length <= max ? value : `${value.slice(0, max - 1).trimEnd()}…`;
47
- const fallbackRunLabel = (prompt) => {
48
- const words = prompt
49
- .split(/\s+/)
50
- .map((word) => word.replace(/[^\p{L}\p{N}-]/gu, ''))
51
- .filter((word) => word.length > 2);
52
- const label = words.slice(0, 3).join(' ');
53
- return clip(label || 'Design directions', RUN_LABEL_MAX_LENGTH);
54
- };
55
- exports.fallbackRunLabel = fallbackRunLabel;
56
- const fallbackDirections = (prompt, count) => ({
57
- briefs: Array.from({ length: count }, (_, index) => {
58
- const archetype = FALLBACK_ARCHETYPES[index % FALLBACK_ARCHETYPES.length];
59
- const suffix = index >= FALLBACK_ARCHETYPES.length
60
- ? ` ${Math.floor(index / FALLBACK_ARCHETYPES.length) + 1}`
61
- : '';
62
- return {
63
- label: `${archetype.label}${suffix}`,
64
- body: archetype.body,
65
- notes: FALLBACK_NOTES,
66
- };
67
- }),
68
- runLabel: (0, exports.fallbackRunLabel)(prompt),
69
- });
70
- exports.fallbackDirections = fallbackDirections;
71
- const AUTHOR_DIRECTIONS_TOOL = {
72
- name: 'author_directions',
73
- description: 'Record the design directions for this variants run. Every direction ' +
74
- 'must name a materially different layout or interaction architecture — ' +
75
- 'never a recolor or a near-duplicate of another direction.',
76
- strict: true,
77
- input_schema: {
78
- type: 'object',
79
- additionalProperties: false,
80
- required: ['runLabel', 'directions'],
81
- properties: {
82
- runLabel: {
83
- type: 'string',
84
- description: '1–3 word summary of the whole batch',
85
- },
86
- directions: {
87
- type: 'array',
88
- items: {
89
- type: 'object',
90
- additionalProperties: false,
91
- required: ['label', 'body', 'notes'],
92
- properties: {
93
- label: {
94
- type: 'string',
95
- description: 'Distinct 1–4 word direction title',
96
- },
97
- body: {
98
- type: 'string',
99
- description: 'At most 12 words naming the layout/interaction direction',
100
- },
101
- notes: {
102
- type: 'string',
103
- description: 'Steering notes for the implementer. START with "Sections: ' +
104
- '<5-7 concrete sections this direction ships>." Then concrete ' +
105
- 'observations from the references (palette hexes, type, ' +
106
- 'spacing, shapes, energy). When the request involves motion ' +
107
- 'or interaction, the notes MUST include a concrete motion ' +
108
- 'spec — trigger (scroll, hover, click), timing, easing, ' +
109
- 'choreography — that the page implements visibly. For ' +
110
- 'navigation/header motion, scroll-linked state change ' +
111
- '(condense, invert, hide-reveal) is the default expectation ' +
112
- 'unless the request names another trigger. The implementer ' +
113
- 'views the references natively — steer interpretation, do ' +
114
- 'not replace looking.',
115
- },
116
- },
117
- },
118
- },
119
- },
120
- },
121
- };
122
- const buildAuthorPrompt = (input) => {
123
- const lines = [
124
- `Design request:`,
125
- input.prompt.trim(),
126
- '',
127
- `Author exactly ${input.count} genuinely distinct, comparison-ready design directions for this request.`,
128
- `Write runLabel, label, and body naturally in ${input.displayLocale}.`,
129
- 'Keep notes in the language that most clearly guides the implementer, and preserve code identifiers verbatim.',
130
- ];
131
- if (input.guidance?.length)
132
- lines.push('', (0, guidancePrompt_1.renderGuidance)(input.guidance));
133
- if (input.images?.length) {
134
- lines.push('', 'The attached images are the primary design signal (uploaded references, rendered page screenshots, or video keyframes in order). Ground every direction in what they actually show.');
135
- }
136
- if (input.referenceNotes?.length) {
137
- lines.push('', 'Reference evidence:', ...input.referenceNotes.map((note) => `- ${note}`));
138
- }
139
- lines.push('', 'Each direction must preserve the full user deliverable (for a landing page: complete page scope, not just a hero). Call the author_directions tool once.');
140
- return lines.join('\n');
141
- };
142
- const sanitizeDirections = (raw, input) => {
143
- if (!Array.isArray(raw.directions))
144
- return undefined;
145
- const seenLabels = new Set();
146
- const briefs = [];
147
- for (const entry of raw.directions) {
148
- if (!entry || typeof entry !== 'object')
149
- continue;
150
- const candidate = entry;
151
- const label = typeof candidate.label === 'string' ? candidate.label.trim() : '';
152
- const body = typeof candidate.body === 'string' ? candidate.body.trim() : '';
153
- const notes = typeof candidate.notes === 'string' ? candidate.notes.trim() : '';
154
- if (!label || !body)
155
- continue;
156
- const key = label.toLowerCase();
157
- if (seenLabels.has(key))
158
- continue;
159
- seenLabels.add(key);
160
- briefs.push({
161
- label: clip(label, LABEL_MAX_LENGTH),
162
- body: clip(body, BODY_MAX_LENGTH),
163
- ...(notes ? { notes: clip(notes, NOTES_MAX_LENGTH) } : {}),
164
- });
165
- if (briefs.length === input.count)
166
- break;
167
- }
168
- if (briefs.length === 0)
169
- return undefined;
170
- const fallback = (0, exports.fallbackDirections)(input.prompt, input.count);
171
- for (const spare of fallback.briefs) {
172
- if (briefs.length === input.count)
173
- break;
174
- if (seenLabels.has(spare.label.toLowerCase()))
175
- continue;
176
- briefs.push(spare);
177
- }
178
- const runLabel = typeof raw.runLabel === 'string' && raw.runLabel.trim()
179
- ? clip(raw.runLabel.trim(), RUN_LABEL_MAX_LENGTH)
180
- : fallback.runLabel;
181
- return { briefs: briefs.slice(0, input.count), runLabel };
182
- };
183
- const CLAUDE_AUTHOR_MODEL = 'claude-sonnet-5';
184
- const CLAUDE_AUTHOR_TIMEOUT_MS = 25_000;
185
- const extractJsonObject = (text) => {
186
- const start = text.indexOf('{');
187
- if (start === -1)
188
- return undefined;
189
- for (let end = text.length; end > start; end -= 1) {
190
- const candidate = text.slice(start, end);
191
- if (!candidate.trimEnd().endsWith('}'))
192
- continue;
193
- try {
194
- return JSON.parse(candidate);
195
- }
196
- catch { }
197
- }
198
- return undefined;
199
- };
200
- const authorViaClaudeRuntime = async (input, options) => {
201
- const command = options?.command ?? process.env.RIVET_EXECUTOR_COMMAND ?? 'claude';
202
- const prompt = [
203
- input.images?.length
204
- ? 'The attached images are the primary design signal (uploaded references, rendered page screenshots, or video keyframes in order).\n'
205
- : '',
206
- buildAuthorPrompt(input),
207
- '',
208
- 'Respond with ONLY a compact single-line JSON object of the shape',
209
- '{"runLabel": "1-3 word batch summary", "directions": [{"label": "1-4 word title", "body": "<=12 word direction", "notes": "<=350 chars. START with: Sections: <5-7 concrete sections this direction ships>. Then concrete steering (palette hexes, type, spacing, energy). When the request names motion or interaction, notes MUST carry a terse motion spec — trigger (scroll/hover/click), timing, easing — the page implements visibly; for nav/header motion default to scroll-linked state change (condense/invert/hide-reveal)."}]}',
210
- `with exactly ${input.count} directions. Speed matters: no deliberation, no tool use, no prose, no markdown fences.`,
211
- ]
212
- .filter(Boolean)
213
- .join('\n');
214
- const userMessage = JSON.stringify({
215
- type: 'user',
216
- message: {
217
- role: 'user',
218
- content: [
219
- ...(input.images ?? []).map((image) => ({
220
- type: 'image',
221
- source: {
222
- type: 'base64',
223
- media_type: image.mediaType,
224
- data: image.data,
225
- },
226
- })),
227
- { type: 'text', text: prompt },
228
- ],
229
- },
230
- });
231
- const startedAt = Date.now();
232
- const { stdout, stderr, error, inputError } = await new Promise((resolve) => {
233
- let inputError;
234
- const child = (0, child_process_1.execFile)(command, [
235
- '--print',
236
- '--input-format',
237
- 'stream-json',
238
- '--output-format',
239
- 'stream-json',
240
- '--verbose',
241
- '--model',
242
- CLAUDE_AUTHOR_MODEL,
243
- '--effort',
244
- 'low',
245
- '--dangerously-skip-permissions',
246
- '--exclude-dynamic-system-prompt-sections',
247
- ], {
248
- timeout: options?.timeoutMs ?? CLAUDE_AUTHOR_TIMEOUT_MS,
249
- maxBuffer: 16 * 1024 * 1024,
250
- }, (error, stdout, stderr) => resolve({ error, stdout, stderr, inputError }));
251
- child.stdin?.on('error', (error) => {
252
- inputError = error;
253
- });
254
- child.stdin?.write(`${userMessage}\n`);
255
- child.stdin?.end();
256
- });
257
- let resultText = '';
258
- let childDurationMs;
259
- for (const line of stdout.split('\n')) {
260
- const trimmed = line.trim();
261
- if (!trimmed.startsWith('{'))
262
- continue;
263
- const result = (0, workerRuntime_1.parseClaudeWorkerResult)(trimmed);
264
- if (result.isFailed) {
265
- const failure = Object.assign(new Error(result.resultText ?? 'Direction authoring failed'), {
266
- status: result.apiErrorStatus,
267
- error: result.error,
268
- });
269
- const capacityError = (0, generationCapacity_1.getGenerationCapacityError)(failure);
270
- if (capacityError)
271
- throw capacityError;
272
- if (inputError)
273
- throw new DirectionInputDeliveryError(inputError);
274
- throw failure;
275
- }
276
- try {
277
- const event = JSON.parse(trimmed);
278
- if (event.type === 'result') {
279
- resultText = typeof event.result === 'string' ? event.result : '';
280
- childDurationMs = event.duration_ms;
281
- }
282
- }
283
- catch { }
284
- }
285
- if (error) {
286
- const capacityError = (0, generationCapacity_1.getGenerationCapacityError)(error) ?? (0, generationCapacity_1.getGenerationCapacityError)(stderr);
287
- if (capacityError)
288
- throw capacityError;
289
- }
290
- if (inputError) {
291
- throw new DirectionInputDeliveryError(inputError);
292
- }
293
- if (error) {
294
- throw new Error(`${error.message}${stderr ? ` — stderr: ${stderr.slice(-400)}` : ''}`);
295
- }
296
- log.info(`claude runtime authored directions in ${Date.now() - startedAt}ms (child duration_ms=${String(childDurationMs)})`);
297
- const parsed = extractJsonObject(resultText || stdout);
298
- if (parsed && typeof parsed === 'object') {
299
- return parsed;
300
- }
301
- return undefined;
302
- };
303
- const authorDirections = async (gateway, request, options) => {
304
- const input = {
305
- ...request,
306
- images: await (0, guidanceDelivery_1.guidancePlannerImages)({
307
- guidance: request.guidance ?? [],
308
- images: request.images,
309
- }),
310
- };
311
- const startedAt = Date.now();
312
- let gatewayFailure;
313
- let runtimeFailure;
314
- try {
315
- const raw = await gateway.sendToolUse({
316
- model: DIRECTION_AUTHOR_MODEL,
317
- maxTokens: DIRECTION_AUTHOR_MAX_TOKENS,
318
- temperature: 1,
319
- system: 'You are the direction planner for Rivet, which builds N parallel ' +
320
- 'design variants of a web page. You author short, materially ' +
321
- 'different direction briefs; separate implementers build each one ' +
322
- 'with the same reference media you see.',
323
- prompt: buildAuthorPrompt(input),
324
- tool: AUTHOR_DIRECTIONS_TOOL,
325
- ...(input.images?.length ? { images: input.images } : {}),
326
- timeoutMs: options?.timeoutMs ?? DIRECTION_AUTHOR_TIMEOUT_MS,
327
- });
328
- const sanitized = sanitizeDirections(raw, input);
329
- if (sanitized) {
330
- return {
331
- ...sanitized,
332
- source: 'gateway',
333
- durationMs: Date.now() - startedAt,
334
- };
335
- }
336
- gatewayFailure = 'returned no usable directions';
337
- log.warn('gateway direction author returned no usable directions');
338
- }
339
- catch (error) {
340
- const capacityError = (0, generationCapacity_1.getGenerationCapacityError)(error);
341
- if (capacityError)
342
- throw capacityError;
343
- gatewayFailure = (0, errorMessage_1.errorMessage)(error);
344
- log.warn('gateway direction authoring failed — trying claude runtime', error);
345
- }
346
- try {
347
- const raw = await authorViaClaudeRuntime(input, {
348
- ...(options?.claudeCommand ? { command: options.claudeCommand } : {}),
349
- });
350
- const sanitized = raw ? sanitizeDirections(raw, input) : undefined;
351
- if (sanitized) {
352
- return {
353
- ...sanitized,
354
- source: 'claude_runtime',
355
- durationMs: Date.now() - startedAt,
356
- };
357
- }
358
- runtimeFailure = 'returned no usable directions';
359
- log.warn('claude runtime direction author returned no usable directions');
360
- }
361
- catch (error) {
362
- if (error instanceof DirectionInputDeliveryError)
363
- throw error;
364
- const capacityError = (0, generationCapacity_1.getGenerationCapacityError)(error);
365
- if (capacityError)
366
- throw capacityError;
367
- runtimeFailure = (0, errorMessage_1.errorMessage)(error);
368
- log.warn('claude runtime direction authoring failed — using archetype fallback', error);
369
- }
370
- log.error('direction authoring degraded to generic archetypes — ' +
371
- `gateway: ${gatewayFailure ?? 'unknown failure'}; ` +
372
- `claude runtime: ${runtimeFailure ?? 'unknown failure'}`);
373
- return {
374
- ...(0, exports.fallbackDirections)(input.prompt, input.count),
375
- source: 'fallback',
376
- durationMs: Date.now() - startedAt,
377
- };
378
- };
379
- exports.authorDirections = authorDirections;
380
- //# sourceMappingURL=directionAuthoring.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"directionAuthoring.js","sourceRoot":"","sources":["../../src/agent-variants/directionAuthoring.ts"],"names":[],"mappings":";;;AAAA,6DAAkE;AAClE,mDAA0D;AAC1D,iDAAiE;AACjE,4CAA+C;AAO/C,qDAAkD;AAClD,mEAAqE;AACrE,wDAAqD;AASrD,MAAM,2BAA4B,SAAQ,KAAK;IAC7C,YAAY,KAAY;QACtB,KAAK,CAAC,4CAA4C,KAAK,CAAC,OAAO,EAAE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iB,EAAE,CAC3D,CAAC;IACF,OAAO;QACL,GAAG,IAAA,0BAAkB,EAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC;QAChD,MAAM,EAAE,UAAU;QAClB,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;KACnC,CAAC;AACJ,CAAC,CAAC;AAnFW,QAAA,gBAAgB,oBAmF3B"}
@@ -1,13 +0,0 @@
1
- import { ComponentNode, ElementContext } from '../types/change-types';
2
- export type ComponentMatch = {
3
- filePath: string;
4
- depth?: number;
5
- };
6
- export declare class ComponentSearchService {
7
- private log;
8
- private extractMeaningfulClassNames;
9
- private capitalize;
10
- findComponentsByName(projectPath: string, componentTree: ComponentNode[]): Promise<ComponentMatch[]>;
11
- findMatchingComponents(projectPath: string, element: Pick<ElementContext, 'componentTree' | 'className' | 'id' | 'textContent' | 'tagName'>): Promise<ComponentMatch[]>;
12
- }
13
- //# sourceMappingURL=ComponentSearchService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ComponentSearchService.d.ts","sourceRoot":"","sources":["../../src/services/ComponentSearchService.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAItE,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAgBF,qBAAa,sBAAsB;IACjC,OAAO,CAAC,GAAG,CAA0C;IAErD,OAAO,CAAC,2BAA2B;IAYnC,OAAO,CAAC,UAAU;IAIZ,oBAAoB,CACxB,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,aAAa,EAAE,GAC7B,OAAO,CAAC,cAAc,EAAE,CAAC;IAqFtB,sBAAsB,CAC1B,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,IAAI,CACX,cAAc,EACd,eAAe,GAAG,WAAW,GAAG,IAAI,GAAG,aAAa,GAAG,SAAS,CACjE,GACA,OAAO,CAAC,cAAc,EAAE,CAAC;CA2G7B"}
@@ -1,167 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ComponentSearchService = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
9
- const glob_1 = require("glob");
10
- const logger_1 = require("../utils/logger");
11
- const MAX_COMPONENT_MATCHES = 5;
12
- function sortComponentMatchesByDepth(matches) {
13
- return matches.sort((a, b) => {
14
- if (a.depth !== undefined && b.depth !== undefined) {
15
- return a.depth - b.depth;
16
- }
17
- if (a.depth !== undefined && b.depth === undefined)
18
- return -1;
19
- if (a.depth === undefined && b.depth !== undefined)
20
- return 1;
21
- return 0;
22
- });
23
- }
24
- class ComponentSearchService {
25
- log = (0, logger_1.createLogger)('ComponentSearchService');
26
- extractMeaningfulClassNames(className) {
27
- if (!className)
28
- return [];
29
- return className.split(/\s+/).filter((cls) => {
30
- if (cls.length < 3)
31
- return false;
32
- const utilityPatterns = /^(flex|grid|block|inline|hidden|p-\d+|px-\d+|py-\d+|m-\d+|mx-\d+|my-\d+|text-|bg-|w-\d+|h-\d+|rounded|border|shadow|hover:|focus:|active:|disabled:|opacity-|z-\d+|gap-\d+|space-|justify-|items-|cursor-|overflow-|relative|absolute|fixed|top-|left-|right-|bottom-)/;
33
- return !utilityPatterns.test(cls);
34
- });
35
- }
36
- capitalize(str) {
37
- return str.charAt(0).toUpperCase() + str.slice(1);
38
- }
39
- async findComponentsByName(projectPath, componentTree) {
40
- if (!componentTree || componentTree.length === 0) {
41
- return [];
42
- }
43
- const componentDepthMap = new Map();
44
- for (const component of componentTree) {
45
- if (component.name === 'Anonymous')
46
- continue;
47
- const currentMin = componentDepthMap.get(component.name);
48
- if (currentMin === undefined || component.depth < currentMin) {
49
- componentDepthMap.set(component.name, component.depth);
50
- }
51
- }
52
- const componentNames = Array.from(componentDepthMap.keys());
53
- this.log.info(`Searching by component names: ${componentNames.join(', ')} (${componentNames.length} unique from ${componentTree.length} total)`);
54
- const files = await (0, glob_1.glob)('**/*.{tsx,jsx}', {
55
- cwd: projectPath,
56
- ignore: [
57
- '**/node_modules/**',
58
- '**/.next/**',
59
- '**/dist/**',
60
- '**/*.test.*',
61
- '**/*.spec.*',
62
- ],
63
- });
64
- const matches = [];
65
- for (const file of files) {
66
- const filePath = path_1.default.join(projectPath, file);
67
- const content = fs_1.default.readFileSync(filePath, 'utf-8');
68
- for (const componentName of componentNames) {
69
- const patterns = [
70
- new RegExp(`export\\s+function\\s+${componentName}\\b`),
71
- new RegExp(`export\\s+const\\s+${componentName}\\s*=`),
72
- new RegExp(`export\\s+class\\s+${componentName}\\s+extends`),
73
- new RegExp(`class\\s+${componentName}\\s+extends`),
74
- new RegExp(`export\\s+default\\s+function\\s+${componentName}\\b`),
75
- new RegExp(`const\\s+${componentName}\\s*=\\s*\\(`),
76
- new RegExp(`const\\s+${componentName}\\s*:\\s*.*=\\s*\\(`),
77
- new RegExp(`function\\s+${componentName}\\s*\\(`),
78
- ];
79
- const hasDefinition = patterns.some((pattern) => pattern.test(content));
80
- if (hasDefinition) {
81
- const depth = componentDepthMap.get(componentName);
82
- this.log.debug(`Component match: ${file} - ${componentName} (depth=${depth})`);
83
- matches.push({
84
- filePath,
85
- depth,
86
- });
87
- break;
88
- }
89
- }
90
- }
91
- const sortedMatches = sortComponentMatchesByDepth(matches).slice(0, MAX_COMPONENT_MATCHES);
92
- if (sortedMatches.length > 0) {
93
- const topMatch = sortedMatches[0];
94
- this.log.info(`Found ${sortedMatches.length} component file matches (top: ${path_1.default.basename(topMatch.filePath)}, depth ${topMatch.depth ?? 'N/A'})`);
95
- }
96
- else {
97
- this.log.info('No component files found matching the component tree');
98
- }
99
- return sortedMatches;
100
- }
101
- async findMatchingComponents(projectPath, element) {
102
- if (element.componentTree && element.componentTree.length > 0) {
103
- this.log.info(`Using Fiber component tree (${element.componentTree.length} components)`);
104
- const componentMatches = await this.findComponentsByName(projectPath, element.componentTree);
105
- if (componentMatches.length > 0) {
106
- this.log.info(`Component tree search succeeded: ${componentMatches.length} matches`);
107
- return componentMatches;
108
- }
109
- this.log.info('Component tree search found no matches, falling back to string search');
110
- }
111
- const classNames = this.extractMeaningfulClassNames(element.className);
112
- const searchTerms = [];
113
- if (element.id && element.id.length > 2) {
114
- searchTerms.push({ term: element.id, weight: 10, type: 'id' });
115
- }
116
- for (const className of classNames) {
117
- searchTerms.push({ term: className, weight: 5, type: 'className' });
118
- }
119
- const textContent = element.textContent?.trim();
120
- if (textContent && textContent.length > 2) {
121
- searchTerms.push({ term: `"${textContent}"`, weight: 3, type: 'textContent' }, { term: `'${textContent}'`, weight: 3, type: 'textContent' }, { term: `>${textContent}<`, weight: 3, type: 'textContent' }, { term: `\`${textContent}\``, weight: 3, type: 'textContent' });
122
- }
123
- const tagName = element.tagName?.toLowerCase();
124
- if (tagName) {
125
- searchTerms.push({ term: `<${tagName}`, weight: 2, type: 'tagName' }, { term: `<${this.capitalize(tagName)}`, weight: 2, type: 'tagName' });
126
- }
127
- if (searchTerms.length === 0) {
128
- this.log.warn('No search terms extracted from element');
129
- return [];
130
- }
131
- this.log.info(`Searching for: ${searchTerms.map((t) => `${t.term}(${t.type})`).join(', ')}`);
132
- const filePatterns = '**/*.{tsx,jsx,ts,js,html,css}';
133
- const files = await (0, glob_1.glob)(filePatterns, {
134
- cwd: projectPath,
135
- ignore: ['**/node_modules/**', '**/.next/**', '**/dist/**'],
136
- });
137
- const matchesWithScore = [];
138
- for (const file of files) {
139
- const filePath = path_1.default.join(projectPath, file);
140
- const content = fs_1.default.readFileSync(filePath, 'utf-8');
141
- let relevanceScore = 0;
142
- const matchedTerms = [];
143
- for (const { term, weight, type } of searchTerms) {
144
- if (content.includes(term)) {
145
- relevanceScore += weight;
146
- matchedTerms.push(`${term}(${type})`);
147
- }
148
- }
149
- if (relevanceScore > 0) {
150
- const absolutePath = path_1.default.join(projectPath, file);
151
- this.log.debug(`Match: ${file} - score=${relevanceScore} [${matchedTerms.join(', ')}]`);
152
- matchesWithScore.push({
153
- filePath: absolutePath,
154
- score: relevanceScore,
155
- });
156
- }
157
- }
158
- const topMatches = matchesWithScore
159
- .sort((a, b) => b.score - a.score)
160
- .slice(0, MAX_COMPONENT_MATCHES)
161
- .map(({ filePath }) => ({ filePath }));
162
- this.log.info(`Found ${matchesWithScore.length} matches, returning top ${topMatches.length}`);
163
- return topMatches;
164
- }
165
- }
166
- exports.ComponentSearchService = ComponentSearchService;
167
- //# sourceMappingURL=ComponentSearchService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ComponentSearchService.js","sourceRoot":"","sources":["../../src/services/ComponentSearchService.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,+BAA4B;AAC5B,4CAA+C;AAG/C,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAOhC,SAAS,2BAA2B,CAClC,OAAyB;IAEzB,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC3B,IAAI,CAAC,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YACnD,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;QAC3B,CAAC;QACD,IAAI,CAAC,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,CAAC,KAAK,KAAK,SAAS;YAAE,OAAO,CAAC,CAAC,CAAC;QAC9D,IAAI,CAAC,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,CAAC,KAAK,KAAK,SAAS;YAAE,OAAO,CAAC,CAAC;QAE7D,OAAO,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAa,sBAAsB;IACzB,GAAG,GAAG,IAAA,qBAAY,EAAC,wBAAwB,CAAC,CAA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