@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.
- package/corpus/README.md +1 -1
- package/corpus/core/CHANGELOG.md +7 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/cli/design-connect.ts +28 -2
- package/corpus/core/src/cli/skills.ts +45 -24
- package/corpus/templates/design/DESIGN-STUDIO-PLAN.md +717 -0
- package/corpus/templates/design/actions/add-breakpoint.ts +143 -0
- package/corpus/templates/design/actions/add-localhost-screens.ts +5 -0
- package/corpus/templates/design/actions/apply-a11y-fix.ts +317 -0
- package/corpus/templates/design/actions/apply-component-prop-edit.ts +433 -0
- package/corpus/templates/design/actions/apply-design-state.ts +200 -0
- package/corpus/templates/design/actions/apply-design-token-edit.ts +202 -0
- package/corpus/templates/design/actions/apply-motion-edit.ts +450 -0
- package/corpus/templates/design/actions/apply-shader-fill.ts +404 -0
- package/corpus/templates/design/actions/apply-visual-edit.ts +191 -5
- package/corpus/templates/design/actions/capture-design-state.ts +224 -0
- package/corpus/templates/design/actions/connect-builder-app.ts +162 -0
- package/corpus/templates/design/actions/create-component.ts +447 -0
- package/corpus/templates/design/actions/create-design-branch.ts +263 -0
- package/corpus/templates/design/actions/create-design-state.ts +162 -0
- package/corpus/templates/design/actions/delete-design-state.ts +55 -0
- package/corpus/templates/design/actions/deploy-design-preview.ts +275 -0
- package/corpus/templates/design/actions/get-component-details.ts +242 -0
- package/corpus/templates/design/actions/get-design-branch-diff.ts +362 -0
- package/corpus/templates/design/actions/get-design-review.ts +314 -0
- package/corpus/templates/design/actions/get-design-surface-index.ts +582 -0
- package/corpus/templates/design/actions/get-motion-timeline.ts +99 -0
- package/corpus/templates/design/actions/index-components.ts +258 -0
- package/corpus/templates/design/actions/index-design-tokens.ts +273 -0
- package/corpus/templates/design/actions/list-design-extensions.ts +309 -0
- package/corpus/templates/design/actions/list-design-source-capabilities.ts +153 -0
- package/corpus/templates/design/actions/list-design-states.ts +72 -0
- package/corpus/templates/design/actions/migrate-inline-design-to-app.ts +298 -0
- package/corpus/templates/design/actions/open-component-source.ts +237 -0
- package/corpus/templates/design/actions/preview-component-prop-edit.ts +254 -0
- package/corpus/templates/design/actions/preview-design-token-edit.ts +113 -0
- package/corpus/templates/design/actions/preview-shader-fill.ts +189 -0
- package/corpus/templates/design/actions/remove-breakpoint.ts +103 -0
- package/corpus/templates/design/actions/remove-motion-timeline.ts +196 -0
- package/corpus/templates/design/actions/run-design-audit.ts +421 -0
- package/corpus/templates/design/actions/run-design-extension-action.ts +284 -0
- package/corpus/templates/design/actions/set-active-breakpoint.ts +39 -0
- package/corpus/templates/design/app/components/design/DesignCanvas.tsx +1414 -71
- package/corpus/templates/design/app/components/design/DesignExtensionsPanel.tsx +632 -43
- package/corpus/templates/design/app/components/design/DrawOverlay.tsx +1 -1
- package/corpus/templates/design/app/components/design/EditPanel.tsx +1391 -52
- package/corpus/templates/design/app/components/design/LayersPanel.tsx +4 -3
- package/corpus/templates/design/app/components/design/LocalSourceEditBanner.tsx +157 -0
- package/corpus/templates/design/app/components/design/MotionDock.tsx +1062 -0
- package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +1052 -98
- package/corpus/templates/design/app/components/design/ReviewPanel.tsx +759 -0
- package/corpus/templates/design/app/components/design/StatesPanel.tsx +579 -0
- package/corpus/templates/design/app/components/design/TokensPanel.tsx +573 -0
- package/corpus/templates/design/app/components/design/canvas-primitive-style.ts +241 -0
- package/corpus/templates/design/app/components/design/index.ts +16 -0
- package/corpus/templates/design/app/components/design/inspector/AutoLayoutMatrix.tsx +15 -6
- package/corpus/templates/design/app/components/design/inspector/DesignColorPicker.tsx +66 -3
- package/corpus/templates/design/app/components/design/inspector/InspectorAiActions.tsx +145 -0
- package/corpus/templates/design/app/components/design/inspector/SHADER_INTEGRATION.md +42 -12
- package/corpus/templates/design/app/components/visual-editor/DrawOverlay.tsx +1 -1
- package/corpus/templates/design/app/hooks/useAgentEditRequest.ts +131 -0
- package/corpus/templates/design/app/hooks/useDesignHotkeys.ts +3 -1
- package/corpus/templates/design/app/i18n/zh-TW.ts +31 -0
- package/corpus/templates/design/app/i18n-data.ts +269 -0
- package/corpus/templates/design/app/pages/DesignEditor.tsx +2478 -386
- package/corpus/templates/design/changelog/2026-06-29-added-a-review-panel-in-the-design-editor-s-inspector-with-a.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-copying-and-pasting-layers-no-longer-shows-success-notificat.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-device-presets-in-all-screens-view-resize-the-selected-previ.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-layer-and-canvas-drags-keep-the-layer-list-stable-while-chan.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-layer-moves-can-be-undone-and-redone-without-flashing-the-ca.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-previews-use-a-single-blue-hover-border-in-all-screen.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-selected-containers-show-draggable-padding-and-gap-guides-on.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-the-design-editor-adds-a-studio-layer-with-tokens-respon.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-accessibility-findings-now-offer-a-one-click-fix.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-component-instances-now-have-editable-props-in-the-inspe.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-inspect-code-now-shows-the-elements-opening-tag-at-a-gla.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-shader-fill-presets-can-now-be-applied-to-an-element.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-the-motion-timeline-can-now-add-a-track-to-any-element-a.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-visual-editor-selection-layer-paint-and-drawing-controls-are-more-reliable.md +6 -0
- package/corpus/templates/design/e2e/helpers.ts +10 -4
- package/corpus/templates/design/server/db/schema.ts +123 -0
- package/corpus/templates/design/server/plugins/db.ts +90 -0
- package/corpus/templates/design/shared/builder-app.ts +297 -0
- package/corpus/templates/design/shared/capability-resolver.ts +123 -0
- package/corpus/templates/design/shared/capture-sanitize.ts +70 -0
- package/corpus/templates/design/shared/code-layer.ts +1016 -71
- package/corpus/templates/design/shared/component-model.ts +239 -0
- package/corpus/templates/design/shared/design-review.ts +275 -0
- package/corpus/templates/design/shared/design-source-capabilities.ts +286 -0
- package/corpus/templates/design/shared/design-state.ts +112 -0
- package/corpus/templates/design/shared/design-surface-index.ts +258 -0
- package/corpus/templates/design/shared/motion-compiler.ts +278 -0
- package/corpus/templates/design/shared/motion-timeline.ts +193 -0
- package/corpus/templates/design/shared/responsive-classes.ts +452 -0
- package/corpus/templates/design/shared/shader-fill.ts +323 -0
- package/corpus/templates/design/shared/source-mode.ts +245 -0
- package/corpus/templates/plan/app/components/plan/CanvasArea.tsx +6 -2
- package/corpus/templates/plan/changelog/2026-06-29-plan-canvases-open-without-an-initial-pan-and-zoom-flicker.md +6 -0
- package/dist/cli/design-connect.d.ts.map +1 -1
- package/dist/cli/design-connect.js +28 -2
- package/dist/cli/design-connect.js.map +1 -1
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +37 -21
- package/dist/cli/skills.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/file-upload/actions/upload-image.d.ts +2 -2
- package/dist/notifications/routes.d.ts +2 -2
- package/dist/observability/routes.d.ts +7 -7
- package/dist/resources/handlers.d.ts +2 -2
- package/dist/server/transcribe-voice.d.ts +1 -1
- 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
|
+
}
|