@agent-native/core 0.80.9 → 0.80.10

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 (111) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/core/CHANGELOG.md +7 -0
  3. package/corpus/core/package.json +1 -1
  4. package/corpus/core/src/cli/design-connect.ts +28 -2
  5. package/corpus/core/src/cli/skills.ts +45 -24
  6. package/corpus/templates/design/DESIGN-STUDIO-PLAN.md +717 -0
  7. package/corpus/templates/design/actions/add-breakpoint.ts +143 -0
  8. package/corpus/templates/design/actions/add-localhost-screens.ts +5 -0
  9. package/corpus/templates/design/actions/apply-a11y-fix.ts +317 -0
  10. package/corpus/templates/design/actions/apply-component-prop-edit.ts +433 -0
  11. package/corpus/templates/design/actions/apply-design-state.ts +200 -0
  12. package/corpus/templates/design/actions/apply-design-token-edit.ts +202 -0
  13. package/corpus/templates/design/actions/apply-motion-edit.ts +450 -0
  14. package/corpus/templates/design/actions/apply-shader-fill.ts +404 -0
  15. package/corpus/templates/design/actions/apply-visual-edit.ts +191 -5
  16. package/corpus/templates/design/actions/capture-design-state.ts +224 -0
  17. package/corpus/templates/design/actions/connect-builder-app.ts +162 -0
  18. package/corpus/templates/design/actions/create-component.ts +447 -0
  19. package/corpus/templates/design/actions/create-design-branch.ts +263 -0
  20. package/corpus/templates/design/actions/create-design-state.ts +162 -0
  21. package/corpus/templates/design/actions/delete-design-state.ts +55 -0
  22. package/corpus/templates/design/actions/deploy-design-preview.ts +275 -0
  23. package/corpus/templates/design/actions/get-component-details.ts +242 -0
  24. package/corpus/templates/design/actions/get-design-branch-diff.ts +362 -0
  25. package/corpus/templates/design/actions/get-design-review.ts +314 -0
  26. package/corpus/templates/design/actions/get-design-surface-index.ts +582 -0
  27. package/corpus/templates/design/actions/get-motion-timeline.ts +99 -0
  28. package/corpus/templates/design/actions/index-components.ts +258 -0
  29. package/corpus/templates/design/actions/index-design-tokens.ts +273 -0
  30. package/corpus/templates/design/actions/list-design-extensions.ts +309 -0
  31. package/corpus/templates/design/actions/list-design-source-capabilities.ts +153 -0
  32. package/corpus/templates/design/actions/list-design-states.ts +72 -0
  33. package/corpus/templates/design/actions/migrate-inline-design-to-app.ts +298 -0
  34. package/corpus/templates/design/actions/open-component-source.ts +237 -0
  35. package/corpus/templates/design/actions/preview-component-prop-edit.ts +254 -0
  36. package/corpus/templates/design/actions/preview-design-token-edit.ts +113 -0
  37. package/corpus/templates/design/actions/preview-shader-fill.ts +189 -0
  38. package/corpus/templates/design/actions/remove-breakpoint.ts +103 -0
  39. package/corpus/templates/design/actions/remove-motion-timeline.ts +196 -0
  40. package/corpus/templates/design/actions/run-design-audit.ts +421 -0
  41. package/corpus/templates/design/actions/run-design-extension-action.ts +284 -0
  42. package/corpus/templates/design/actions/set-active-breakpoint.ts +39 -0
  43. package/corpus/templates/design/app/components/design/DesignCanvas.tsx +1414 -71
  44. package/corpus/templates/design/app/components/design/DesignExtensionsPanel.tsx +632 -43
  45. package/corpus/templates/design/app/components/design/DrawOverlay.tsx +1 -1
  46. package/corpus/templates/design/app/components/design/EditPanel.tsx +1391 -52
  47. package/corpus/templates/design/app/components/design/LayersPanel.tsx +4 -3
  48. package/corpus/templates/design/app/components/design/LocalSourceEditBanner.tsx +157 -0
  49. package/corpus/templates/design/app/components/design/MotionDock.tsx +1062 -0
  50. package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +1052 -98
  51. package/corpus/templates/design/app/components/design/ReviewPanel.tsx +759 -0
  52. package/corpus/templates/design/app/components/design/StatesPanel.tsx +579 -0
  53. package/corpus/templates/design/app/components/design/TokensPanel.tsx +573 -0
  54. package/corpus/templates/design/app/components/design/canvas-primitive-style.ts +241 -0
  55. package/corpus/templates/design/app/components/design/index.ts +16 -0
  56. package/corpus/templates/design/app/components/design/inspector/AutoLayoutMatrix.tsx +15 -6
  57. package/corpus/templates/design/app/components/design/inspector/DesignColorPicker.tsx +66 -3
  58. package/corpus/templates/design/app/components/design/inspector/InspectorAiActions.tsx +145 -0
  59. package/corpus/templates/design/app/components/design/inspector/SHADER_INTEGRATION.md +42 -12
  60. package/corpus/templates/design/app/components/visual-editor/DrawOverlay.tsx +1 -1
  61. package/corpus/templates/design/app/hooks/useAgentEditRequest.ts +131 -0
  62. package/corpus/templates/design/app/hooks/useDesignHotkeys.ts +3 -1
  63. package/corpus/templates/design/app/i18n/zh-TW.ts +31 -0
  64. package/corpus/templates/design/app/i18n-data.ts +269 -0
  65. package/corpus/templates/design/app/pages/DesignEditor.tsx +2478 -386
  66. package/corpus/templates/design/changelog/2026-06-29-added-a-review-panel-in-the-design-editor-s-inspector-with-a.md +6 -0
  67. package/corpus/templates/design/changelog/2026-06-29-copying-and-pasting-layers-no-longer-shows-success-notificat.md +6 -0
  68. package/corpus/templates/design/changelog/2026-06-29-device-presets-in-all-screens-view-resize-the-selected-previ.md +6 -0
  69. package/corpus/templates/design/changelog/2026-06-29-layer-and-canvas-drags-keep-the-layer-list-stable-while-chan.md +6 -0
  70. package/corpus/templates/design/changelog/2026-06-29-layer-moves-can-be-undone-and-redone-without-flashing-the-ca.md +6 -0
  71. package/corpus/templates/design/changelog/2026-06-29-screen-previews-use-a-single-blue-hover-border-in-all-screen.md +6 -0
  72. package/corpus/templates/design/changelog/2026-06-29-selected-containers-show-draggable-padding-and-gap-guides-on.md +6 -0
  73. package/corpus/templates/design/changelog/2026-06-29-the-design-editor-adds-a-studio-layer-with-tokens-respon.md +6 -0
  74. package/corpus/templates/design/changelog/2026-06-30-accessibility-findings-now-offer-a-one-click-fix.md +6 -0
  75. package/corpus/templates/design/changelog/2026-06-30-component-instances-now-have-editable-props-in-the-inspe.md +6 -0
  76. package/corpus/templates/design/changelog/2026-06-30-inspect-code-now-shows-the-elements-opening-tag-at-a-gla.md +6 -0
  77. package/corpus/templates/design/changelog/2026-06-30-shader-fill-presets-can-now-be-applied-to-an-element.md +6 -0
  78. package/corpus/templates/design/changelog/2026-06-30-the-motion-timeline-can-now-add-a-track-to-any-element-a.md +6 -0
  79. package/corpus/templates/design/changelog/2026-06-30-visual-editor-selection-layer-paint-and-drawing-controls-are-more-reliable.md +6 -0
  80. package/corpus/templates/design/e2e/helpers.ts +10 -4
  81. package/corpus/templates/design/server/db/schema.ts +123 -0
  82. package/corpus/templates/design/server/plugins/db.ts +90 -0
  83. package/corpus/templates/design/shared/builder-app.ts +297 -0
  84. package/corpus/templates/design/shared/capability-resolver.ts +123 -0
  85. package/corpus/templates/design/shared/capture-sanitize.ts +70 -0
  86. package/corpus/templates/design/shared/code-layer.ts +1016 -71
  87. package/corpus/templates/design/shared/component-model.ts +239 -0
  88. package/corpus/templates/design/shared/design-review.ts +275 -0
  89. package/corpus/templates/design/shared/design-source-capabilities.ts +286 -0
  90. package/corpus/templates/design/shared/design-state.ts +112 -0
  91. package/corpus/templates/design/shared/design-surface-index.ts +258 -0
  92. package/corpus/templates/design/shared/motion-compiler.ts +278 -0
  93. package/corpus/templates/design/shared/motion-timeline.ts +193 -0
  94. package/corpus/templates/design/shared/responsive-classes.ts +452 -0
  95. package/corpus/templates/design/shared/shader-fill.ts +323 -0
  96. package/corpus/templates/design/shared/source-mode.ts +245 -0
  97. package/corpus/templates/plan/app/components/plan/CanvasArea.tsx +6 -2
  98. package/corpus/templates/plan/changelog/2026-06-29-plan-canvases-open-without-an-initial-pan-and-zoom-flicker.md +6 -0
  99. package/dist/cli/design-connect.d.ts.map +1 -1
  100. package/dist/cli/design-connect.js +28 -2
  101. package/dist/cli/design-connect.js.map +1 -1
  102. package/dist/cli/skills.d.ts.map +1 -1
  103. package/dist/cli/skills.js +37 -21
  104. package/dist/cli/skills.js.map +1 -1
  105. package/dist/collab/routes.d.ts +1 -1
  106. package/dist/file-upload/actions/upload-image.d.ts +2 -2
  107. package/dist/notifications/routes.d.ts +2 -2
  108. package/dist/observability/routes.d.ts +7 -7
  109. package/dist/resources/handlers.d.ts +2 -2
  110. package/dist/server/transcribe-voice.d.ts +1 -1
  111. package/package.json +1 -1
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Source capability resolver — pure, no DB, no side effects.
3
+ *
4
+ * Maps a `DesignSourceType` (inline | localhost | fusion) to the concrete
5
+ * `DesignSourceCapabilities` map. Callers that have already proven a richer
6
+ * capability set (e.g. a localhost bridge that has verified `readFile`) should
7
+ * override the defaults after calling this function.
8
+ *
9
+ * The canonical tier semantics live in `DESIGN-STUDIO-PLAN.md` §5:
10
+ *
11
+ * - **inline** — HTML/CSS preview + controlled writes via the deterministic
12
+ * `replace-document-content` / `apply-tweaks` path; `previewMotion` + Tier-A
13
+ * `writeMotion` (managed `<style data-agent-native-motion>` block) and CSS-var
14
+ * token edits are available without a file-write bridge.
15
+ * - **localhost** — starts read-only/preview-only; `readFile` / `applyEdit` /
16
+ * `writeFile` and real-app capabilities (`indexComponents`, `writeTokens`)
17
+ * become `available` only after bridge hardening.
18
+ * - **fusion (Builder)** — starts preview-only; unlocks the full set
19
+ * (`indexComponents`, `writeTokens`, `writeMotion`, `branch`, `deploy`) once
20
+ * the bridge proves capabilities.
21
+ *
22
+ * The UI must never infer write ability from `sourceType` alone; it must always
23
+ * read the capability map returned here (or an overridden variant).
24
+ */
25
+
26
+ import {
27
+ available,
28
+ planned,
29
+ unavailable,
30
+ INLINE_DEFAULT_CAPABILITIES,
31
+ LOCALHOST_DEFAULT_CAPABILITIES,
32
+ FUSION_DISCONNECTED_CAPABILITIES,
33
+ FUSION_CONNECTED_CAPABILITIES,
34
+ type DesignSourceCapabilities,
35
+ } from "./design-source-capabilities";
36
+ import type { DesignSourceType } from "./source-mode";
37
+
38
+ /**
39
+ * Return the default `DesignSourceCapabilities` for the given `sourceType`.
40
+ *
41
+ * These are **defaults** — they represent the conservative starting point for
42
+ * a freshly connected source. Callers that have runtime evidence of a richer
43
+ * capability set (e.g. a bridge handshake that confirmed `readFile` works)
44
+ * should spread/override specific entries rather than calling this function
45
+ * again.
46
+ *
47
+ * ```ts
48
+ * const caps = resolveSourceCapabilities(design.sourceType);
49
+ * // Override after bridge handshake:
50
+ * const proven: DesignSourceCapabilities = {
51
+ * ...caps,
52
+ * readFile: available("Bridge verified"),
53
+ * };
54
+ * ```
55
+ *
56
+ * @param sourceType - The source type from `DesignSourceType`.
57
+ * @returns A read-only snapshot of the default capability map.
58
+ */
59
+ export function resolveSourceCapabilities(
60
+ sourceType: DesignSourceType,
61
+ ): DesignSourceCapabilities {
62
+ switch (sourceType) {
63
+ case "inline":
64
+ return INLINE_DEFAULT_CAPABILITIES;
65
+ case "localhost":
66
+ return LOCALHOST_DEFAULT_CAPABILITIES;
67
+ case "fusion":
68
+ // Conservative default for fusion when connection status is unknown.
69
+ // Use resolveFusionCapabilities(connected) when Builder connection status
70
+ // is known, or resolveDescriptorCapabilities() which honours the
71
+ // descriptor's proven capabilities map.
72
+ return FUSION_DISCONNECTED_CAPABILITIES;
73
+ default: {
74
+ // Exhaustive check — TypeScript will catch unhandled variants.
75
+ const _exhaustive: never = sourceType;
76
+ void _exhaustive;
77
+ // Fallback: safest option is inline (no file writes, no real-app ops).
78
+ return INLINE_DEFAULT_CAPABILITIES;
79
+ }
80
+ }
81
+ }
82
+
83
+ /**
84
+ * Return the correct `DesignSourceCapabilities` for a **fusion** source based
85
+ * on the current Builder connection status.
86
+ *
87
+ * Per DESIGN-STUDIO-PLAN.md §5:
88
+ * - **Not connected** (`connected = false`): preview-only. No real-app write
89
+ * operations (`indexComponents`, `branch`, `deployPreview`, `deploy`,
90
+ * `writeFile`, `writeTokens`, `writeMotion`) are available.
91
+ * - **Connected** (`connected = true`): `indexComponents`, `branch`,
92
+ * `deployPreview`, and `deploy` are **available**. Source writes
93
+ * (`writeFile`, `writeTokens`, `writeMotion`) remain **planned** until
94
+ * bridge hardening is complete.
95
+ *
96
+ * Usage (in an action that already resolved Builder status):
97
+ * ```ts
98
+ * import { resolveFusionCapabilities } from "../shared/capability-resolver.js";
99
+ * import { resolveIsBuilderBranchingEnabled } from "@agent-native/core/server";
100
+ *
101
+ * const connected = await resolveIsBuilderBranchingEnabled();
102
+ * const caps = resolveFusionCapabilities(connected);
103
+ * if (hasCapability(caps, "branch")) { ... }
104
+ * ```
105
+ *
106
+ * @param connected - `true` when Builder credentials are configured AND a
107
+ * branch project is set (i.e. `resolveIsBuilderBranchingEnabled()` returns
108
+ * `true`).
109
+ */
110
+ export function resolveFusionCapabilities(
111
+ connected: boolean,
112
+ ): DesignSourceCapabilities {
113
+ return connected
114
+ ? FUSION_CONNECTED_CAPABILITIES
115
+ : FUSION_DISCONNECTED_CAPABILITIES;
116
+ }
117
+
118
+ // Re-export factory helpers so callers only need this module to build
119
+ // capability maps with override entries.
120
+ export { available, planned, unavailable };
121
+ export type { DesignSourceCapabilities };
122
+ // Re-export the fusion constants for callers that prefer direct access.
123
+ export { FUSION_CONNECTED_CAPABILITIES, FUSION_DISCONNECTED_CAPABILITIES };
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Shared sanitization helpers for design state capture payloads.
3
+ *
4
+ * Used by both create-design-state and capture-design-state to enforce a
5
+ * consistent stored-XSS guard and size cap before persisting arbitrary
6
+ * caller-supplied markup / DOM snapshots into `design_state` rows.
7
+ */
8
+
9
+ /**
10
+ * Maximum serialised size of a captured/replayed `captureData` or
11
+ * `fixtureData` payload. Caps single-row size to protect the DB and the
12
+ * shareable content each row feeds.
13
+ */
14
+ export const CAPTURE_DATA_MAX_BYTES = 256 * 1024; // 256 KB
15
+
16
+ /**
17
+ * Strip stored-XSS vectors out of an HTML/markup string before it is persisted
18
+ * and later replayed into shareable design content. Mirrors the framework's
19
+ * text-edit HTML sanitiser: removes script/style/iframe/object/embed/link/meta/
20
+ * base tags, inline `on*` handlers, and `javascript:` / `vbscript:` / `data:`
21
+ * URLs in `href` / `src` / `xlink:href`.
22
+ */
23
+ export function sanitizeMarkup(html: string): string {
24
+ return html
25
+ .replace(
26
+ /<\s*(script|style|iframe|object|embed|link|meta|base)\b[\s\S]*?<\s*\/\s*\1\s*>/gi,
27
+ "",
28
+ )
29
+ .replace(
30
+ /<\s*(script|style|iframe|object|embed|link|meta|base)\b[^>]*\/?\s*>/gi,
31
+ "",
32
+ )
33
+ .replace(/\s+on[A-Za-z]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/g, "")
34
+ .replace(
35
+ /\s+(href|src|xlink:href)\s*=\s*(?:(["'])\s*(?:javascript|vbscript|data):[\s\S]*?\2|(?:javascript|vbscript|data):[^\s>]*)/gi,
36
+ "",
37
+ );
38
+ }
39
+
40
+ /**
41
+ * A string "looks like markup" — and is therefore worth sanitising — when it
42
+ * contains an angle-bracket tag opener or an Alpine `x-`/`@`/`:` binding that
43
+ * could carry script. Plain data strings (route names, ids) are left untouched.
44
+ */
45
+ export function looksLikeMarkup(value: string): boolean {
46
+ return /<[a-zA-Z!/]/.test(value) || value.includes("</");
47
+ }
48
+
49
+ /**
50
+ * Recursively sanitise every string value inside a captured/replayed
51
+ * `captureData` or `fixtureData` object (e.g. `domHtml`, `domSnapshot`,
52
+ * `x-data` markup) so no untrusted DOM is persisted raw. Non-string leaves
53
+ * pass through unchanged.
54
+ */
55
+ export function sanitizeCaptureData(value: unknown): unknown {
56
+ if (typeof value === "string") {
57
+ return looksLikeMarkup(value) ? sanitizeMarkup(value) : value;
58
+ }
59
+ if (Array.isArray(value)) {
60
+ return value.map((entry) => sanitizeCaptureData(entry));
61
+ }
62
+ if (value && typeof value === "object") {
63
+ const out: Record<string, unknown> = {};
64
+ for (const [k, v] of Object.entries(value as Record<string, unknown>)) {
65
+ out[k] = sanitizeCaptureData(v);
66
+ }
67
+ return out;
68
+ }
69
+ return value;
70
+ }