@vcp-dev/contracts 0.3.14

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.
@@ -0,0 +1,11 @@
1
+ export interface SiteEditRepeatInstanceKeyPart {
2
+ repeatIndex: number;
3
+ }
4
+ export interface ParsedSiteEditRepeatInstanceKey {
5
+ baseKey: string;
6
+ parts: SiteEditRepeatInstanceKeyPart[];
7
+ }
8
+ export declare function makeSiteEditRepeatInstanceKey(baseKey: string, repeatIndex: number): string;
9
+ export declare function composeSiteEditRepeatInstanceKey(baseKey: string, repeatIndexes: readonly number[]): string;
10
+ export declare function parseSiteEditRepeatInstanceKey(key: string | null | undefined): ParsedSiteEditRepeatInstanceKey | null;
11
+ export declare function stripSiteEditRepeatInstanceKeys(key: string | null | undefined): string | null;
@@ -0,0 +1,21 @@
1
+ export declare const SITE_EDIT_RUNTIME_VOID_ELEMENT_TAGS: readonly ["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"];
2
+ export declare const SITE_EDIT_RUNTIME_CONTAINER_TAGS: readonly ["article", "aside", "div", "footer", "form", "header", "li", "main", "nav", "ol", "section", "select", "table", "tbody", "tfoot", "thead", "tr", "ul"];
3
+ export declare const SITE_EDIT_RUNTIME_TEXT_TAGS: readonly ["a", "button", "em", "h1", "h2", "h3", "h4", "h5", "h6", "label", "p", "small", "span", "strong"];
4
+ export type SiteEditRuntimeVoidElementTag = (typeof SITE_EDIT_RUNTIME_VOID_ELEMENT_TAGS)[number];
5
+ export type SiteEditRuntimeContainerTag = (typeof SITE_EDIT_RUNTIME_CONTAINER_TAGS)[number];
6
+ export type SiteEditRuntimeTextTag = (typeof SITE_EDIT_RUNTIME_TEXT_TAGS)[number];
7
+ export type SiteEditRuntimeFallbackMode = "preview" | "strict";
8
+ export type SiteEditRuntimeOperationSummary = {
9
+ canUpdateText: boolean;
10
+ canInsertChild: boolean;
11
+ canMove: boolean;
12
+ canRemove: boolean;
13
+ };
14
+ export declare function isSiteEditRuntimeVoidElementTag(tagName?: string | null): boolean;
15
+ export declare function isSiteEditRuntimeContainerTag(tagName?: string | null): boolean;
16
+ export declare function isSiteEditRuntimeTextTag(tagName?: string | null): boolean;
17
+ export declare function resolveSiteEditRuntimeOperationSummary(params: {
18
+ operationSummary?: SiteEditRuntimeOperationSummary | null;
19
+ tagName?: string | null;
20
+ fallbackMode?: SiteEditRuntimeFallbackMode;
21
+ }): SiteEditRuntimeOperationSummary;
@@ -0,0 +1 @@
1
+ var a=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],o=["article","aside","div","footer","form","header","li","main","nav","ol","section","select","table","tbody","tfoot","thead","tr","ul"],T=["a","button","em","h1","h2","h3","h4","h5","h6","label","p","small","span","strong"],r=new Set(a),i=new Set(o),E=new Set(T),c={canUpdateText:!1,canInsertChild:!1,canMove:!1,canRemove:!1};function I(e){return r.has(n(e))}function _(e){return i.has(n(e))}function s(e){return E.has(n(e))}function l(e){let{operationSummary:t}=e;return t?{canUpdateText:t.canUpdateText,canInsertChild:t.canInsertChild,canMove:t.canMove,canRemove:t.canRemove}:e.fallbackMode!=="preview"?{...c}:{canUpdateText:s(e.tagName),canInsertChild:_(e.tagName),canMove:!1,canRemove:!1}}function n(e){return e?.trim().toLowerCase()??""}export{o as SITE_EDIT_RUNTIME_CONTAINER_TAGS,T as SITE_EDIT_RUNTIME_TEXT_TAGS,a as SITE_EDIT_RUNTIME_VOID_ELEMENT_TAGS,_ as isSiteEditRuntimeContainerTag,s as isSiteEditRuntimeTextTag,I as isSiteEditRuntimeVoidElementTag,l as resolveSiteEditRuntimeOperationSummary};
@@ -0,0 +1,23 @@
1
+ /**
2
+ * 当前 edit-engine 公开包统一版本号。
3
+ * 三个包(@vcp-dev/contracts / @vcp-dev/site-edit-engine / @vcp-dev/site-edit-bridge)
4
+ * 始终同号发布。
5
+ *
6
+ * 由 release-edit-engine-packages.ts 在 bump 版本时自动更新。
7
+ */
8
+ export declare const CURRENT_EDIT_ENGINE_VERSION = "0.3.14";
9
+ export declare const EDIT_ENGINE_VERSION_HEADER = "x-vcp-edit-engine-version";
10
+ export declare const EDIT_ENGINE_VERSION_SOURCE_HEADER = "x-vcp-edit-engine-version-source";
11
+ export type EditEngineVersionSource = "explicit" | "fallback_current" | "system_current";
12
+ export interface ResolvedEditEngineVersion {
13
+ version: string;
14
+ source: EditEngineVersionSource;
15
+ }
16
+ export declare class EditEngineVersionParseError extends Error {
17
+ readonly code: "EDIT_ENGINE_VERSION_INVALID";
18
+ constructor(message?: string);
19
+ }
20
+ export declare function isExactEditEngineVersion(value: string): boolean;
21
+ export declare function parseExactEditEngineVersion(value: unknown): string;
22
+ export declare function resolveRequestedEditEngineVersion(value: unknown): ResolvedEditEngineVersion;
23
+ export declare function resolveSystemCurrentEditEngineVersion(): ResolvedEditEngineVersion;
@@ -0,0 +1,94 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * 白名单 BCP-47 code(与 {@link SUPPORTED_SITE_LOCALES} 同序同值)。
4
+ * 显式 literal tuple 以便 `z.enum` 推导出精确联合类型。
5
+ */
6
+ export declare const SITE_LOCALE_CODES: readonly ["zh-CN", "en", "ja", "es", "fr", "de", "zh-TW", "ko", "pt", "pt-BR", "it", "ru", "ar", "hi", "id", "vi", "th", "tr", "nl", "pl", "uk", "sv", "da", "fi", "no", "cs", "el", "hu", "ro", "he", "ms", "fil", "bn", "ta", "ca", "sk", "hr", "bg", "lt", "lv", "et", "fa", "sw", "sr", "is"];
7
+ export declare const SiteLocaleSchema: z.ZodEnum<{
8
+ "zh-CN": "zh-CN";
9
+ en: "en";
10
+ ja: "ja";
11
+ es: "es";
12
+ fr: "fr";
13
+ de: "de";
14
+ "zh-TW": "zh-TW";
15
+ ko: "ko";
16
+ pt: "pt";
17
+ "pt-BR": "pt-BR";
18
+ it: "it";
19
+ ru: "ru";
20
+ ar: "ar";
21
+ hi: "hi";
22
+ id: "id";
23
+ vi: "vi";
24
+ th: "th";
25
+ tr: "tr";
26
+ nl: "nl";
27
+ pl: "pl";
28
+ uk: "uk";
29
+ sv: "sv";
30
+ da: "da";
31
+ fi: "fi";
32
+ no: "no";
33
+ cs: "cs";
34
+ el: "el";
35
+ hu: "hu";
36
+ ro: "ro";
37
+ he: "he";
38
+ ms: "ms";
39
+ fil: "fil";
40
+ bn: "bn";
41
+ ta: "ta";
42
+ ca: "ca";
43
+ sk: "sk";
44
+ hr: "hr";
45
+ bg: "bg";
46
+ lt: "lt";
47
+ lv: "lv";
48
+ et: "et";
49
+ fa: "fa";
50
+ sw: "sw";
51
+ sr: "sr";
52
+ is: "is";
53
+ }>;
54
+ export type SiteLocale = z.infer<typeof SiteLocaleSchema>;
55
+ /**
56
+ * 站点产出语种(访客看到的语言)的事实源白名单。
57
+ *
58
+ * - `code`:BCP-47 标签,持久化进 `SiteRecord.default_locale`,并直接用于
59
+ * 生成站点产物的 `<html lang>`。
60
+ * - `label`:语种自称(endonym,如 `日本語` / `Español`),**不随界面语言变**,
61
+ * 控件主显示。
62
+ * - `common`:是否常用,控件浮层默认置顶展示。
63
+ *
64
+ * 语种在当前界面语言下的释义(exonym,如「日语」/「Japanese」)**不放这里**——
65
+ * 它随界面语言变化,由前端 i18n(`clarify` 命名空间 `siteLanguage.names.<code>`)
66
+ * 提供,避免界面切到英文时右侧仍显示中文。
67
+ *
68
+ * `default_locale` 为 NOT NULL:Step 1 创建站点时由后端轻量语言检测写入
69
+ * (识别不出兜底 {@link DEFAULT_SITE_LOCALE}),用户可在 Step 2 覆盖。
70
+ */
71
+ export interface SiteLocaleOption {
72
+ code: SiteLocale;
73
+ label: string;
74
+ common?: boolean;
75
+ }
76
+ /**
77
+ * 控件展示用元数据(前 6 项为常用,控件默认置顶)。code 必须落在白名单内。
78
+ * `label` 是语种自称(endonym),不随界面语言变;释义(exonym)走前端 i18n。
79
+ */
80
+ export declare const SUPPORTED_SITE_LOCALES: readonly SiteLocaleOption[];
81
+ /**
82
+ * 识别不确定 / 失败时的兜底语种。`default_locale` 不可为空,故必须有终极兜底。
83
+ */
84
+ export declare const DEFAULT_SITE_LOCALE: SiteLocale;
85
+ /**
86
+ * 轻量语言检测库(franc 系)输出的 ISO 639-3 → 白名单 BCP-47。
87
+ * 映射未命中时由调用方兜底为 {@link DEFAULT_SITE_LOCALE}。
88
+ * 注:franc 不区分简繁,`cmn` 统一归 `zh-CN`,繁体靠用户在 Step 2 手选。
89
+ */
90
+ export declare const ISO_639_3_TO_SITE_LOCALE: Readonly<Record<string, SiteLocale>>;
91
+ /**
92
+ * 把检测库输出的 ISO 639-3 归一到白名单 BCP-47;未命中返回 {@link DEFAULT_SITE_LOCALE}。
93
+ */
94
+ export declare function resolveSiteLocaleFromIso6393(iso6393: string): SiteLocale;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Platform-curated theme presets for the workspace design panel. Each preset
3
+ * carries ONLY brand/accent anchor seeds — the full token set derives via
4
+ * deriveDesignColors, so contrast safety is computed, not authored.
5
+ * zh-CN labels are end-user facing (generated sites are zh-CN-first).
6
+ */
7
+ export interface ThemePreset {
8
+ id: string;
9
+ /** End-user facing label (zh-CN). */
10
+ label: string;
11
+ colorSeeds: {
12
+ primary: string;
13
+ accent: string;
14
+ };
15
+ }
16
+ export declare const THEME_PRESETS: readonly ThemePreset[];
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Workspace iteration 用户面文案 single source of truth(详见 Plan Task 11)。
3
+ *
4
+ * 凡是会被用户看到的字符串(错误 banner、拒绝模板、澄清卡片标签、聊天提示)
5
+ * 必须从这里导出,前后端共用。禁止在 app 代码里硬编码 user-facing 英文/中文文案。
6
+ *
7
+ * - `ERROR_COPY`:用户面错误兜底;任何 agent `run.failed` 的 `error_code` 必须能
8
+ * 映射到这里的一个 key,找不到时由前端回退到 `GENERIC`。
9
+ * - `REFUSAL_COPY`:模型拒绝越界请求时的统一英文模板(system prompt 注入)。
10
+ * - `CLARIFICATION_COPY`:澄清卡片 UI 文案。
11
+ * - `CHAT_COPY`:聊天面板小型提示文案。
12
+ */
13
+ export declare const ERROR_COPY: {
14
+ readonly PATCH_VALIDATION_FAILED: "The code didn't pass validation. Try describing the change more specifically.";
15
+ readonly PATCH_BATCH_FAILED: "The site code couldn't be generated. Please regenerate the site.";
16
+ readonly PATCH_BATCH_INVALID: "The change couldn't be applied. Try simpler instructions.";
17
+ readonly VALIDATION_FAILED: "Your message couldn't be sent as written. Please edit it and try again.";
18
+ readonly WORKSPACE_MESSAGE_CONTAINS_SECRET: "Your message looks like it contains a secret or token, so it wasn't sent. Remove it and try again.";
19
+ readonly WORKSPACE_TOOL_RESULT_INVALID: "This change couldn't be completed and was rolled back. Please try again.";
20
+ readonly WORKSPACE_TOOL_FAILED: "A tool step failed. Please try again.";
21
+ readonly WORKSPACE_TOOL_RESULT_MISSING: "The tool didn't return a usable result. Please try again.";
22
+ readonly WORKSPACE_MODEL_STREAM_FAILED: "The model stream ended unexpectedly. Please try again.";
23
+ readonly WORKSPACE_MODEL_STREAM_ABORTED: "Generation was interrupted before finishing. Please try again.";
24
+ readonly MODEL_OUTPUT_TRUNCATED: "The response was too long and was cut off before any change was applied. Try again, or split the request into smaller changes.";
25
+ readonly WORKSPACE_EDIT_NOT_APPLIED: "No change was applied. Try describing the change differently.";
26
+ readonly WORKSPACE_INITIAL_EXECUTION_FAILED: "Initial generation failed. Please retry from the brief.";
27
+ readonly WORKSPACE_INITIAL_GENERATION_CHECK_FAILED: "Initial generation could not be verified. Please retry.";
28
+ readonly WORKSPACE_INITIAL_GENERATION_FINALIZE_FAILED: "Initial generation could not finalize. Please retry.";
29
+ readonly WORKSPACE_INITIAL_GENERATION_QUALITY_GATE_FAILED: "Initial generation failed quality checks. Please regenerate the site.";
30
+ readonly WORKSPACE_ITERATION_QUALITY_GATE_FAILED: "Quality check failed. The change was rolled back; try a smaller or more specific request.";
31
+ readonly WORKSPACE_SOCKET_DEAD: "The workspace connection was lost. Please retry.";
32
+ readonly WORKSPACE_RUN_CANCELLED: "The run was cancelled.";
33
+ readonly WORKSPACE_RUN_ABANDONED: "This run was interrupted and did not finish. Please try again.";
34
+ readonly WORKSPACE_RUN_REQUEST_FAILED: "Couldn't start the workspace. Please try again.";
35
+ readonly WORKSPACE_RUN_BAD_RESPONSE: "The server response was malformed. Please try again.";
36
+ readonly WORKSPACE_SOCKET_UNAVAILABLE: "Workspace connection unavailable. Please try again.";
37
+ readonly WORKSPACE_SOCKET_ERROR: "The workspace connection had an error. Please try again.";
38
+ readonly WORKSPACE_SOCKET_CLOSED: "The workspace connection closed. Please try again.";
39
+ readonly WORKSPACE_SOCKET_OPEN_TIMEOUT: "Couldn't reach the workspace in time. Please try again.";
40
+ readonly WORKSPACE_CLIENT_MESSAGE_ID_MISSING: "Something went wrong sending your message. Please try again.";
41
+ readonly SITE_SNAPSHOT_REQUIRED: "This site has no usable snapshot yet. Complete Step 3 first.";
42
+ readonly AGENT_TIMEOUT: "That took longer than expected. Try breaking the change into smaller pieces.";
43
+ readonly SANDBOX_NOT_AVAILABLE: "The preview environment isn't ready. Your edits have still been saved.";
44
+ readonly PREVIEW_BUILD_FAILED: "Preview is available, but the production build failed. Fix the reported build error before deploying.";
45
+ readonly PREVIEW_BUILD_NOT_CONFIGURED: "Preview is available, but the production build check is not configured.";
46
+ readonly PREVIEW_BUILD_SANDBOX_NOT_FOUND: "Preview is available, but the build check could not find the active preview sandbox.";
47
+ readonly WS_CONNECTION_ERROR: "Connection lost. Reconnecting…";
48
+ readonly USER_MESSAGE_PERSIST_FAILED: "Your message wasn't saved. Please send it again.";
49
+ readonly CLARIFICATION_REPLY_STALE: "That question has expired. Please tell me what you'd like to do now.";
50
+ readonly CLARIFY_MODEL_FAILED: "Clarify couldn't finish generating questions. Please try again.";
51
+ readonly WORKSPACE_RUN_IN_FLIGHT: "Another session is already running. Please try again in a moment.";
52
+ readonly SITE_OPERATION_LOCKED: "Another change is already running for this site. Wait for it to finish, then try again.";
53
+ readonly EDIT_ENGINE_VERSION_INVALID: "Invalid editor version. Refresh the page and try again.";
54
+ readonly SANDBOX_DEPENDENCY_SYNC_FAILED: "The preview runtime could not be prepared. Please try again.";
55
+ readonly SANDBOX_DEPENDENCY_VERSION_MISMATCH: "The preview runtime could not be verified. Please try again.";
56
+ readonly SANDBOX_RUNTIME_NOT_READY: "The preview needs to be refreshed before this change can be applied. Refresh the preview and try again.";
57
+ readonly GENERIC: "Something went wrong. Please try again.";
58
+ };
59
+ export declare const REFUSAL_COPY: {
60
+ readonly UNDO_OR_ROLLBACK: "I can't roll back from chat. Use the version history at the top right to pick a restore point.";
61
+ readonly HISTORY_RECALL: "Tell me what you'd like to change now—I'll work from the current page state.";
62
+ readonly OUT_OF_SCOPE: "That's outside what I can do from chat. Try the corresponding panel on the right.";
63
+ };
64
+ export declare const CLARIFICATION_COPY: {
65
+ readonly CARD_HEADER: "Needs your confirmation";
66
+ readonly FREE_TEXT_PLACEHOLDER: "Or describe what you'd like instead";
67
+ readonly SUBMIT_LABEL: "Submit";
68
+ };
69
+ export declare const CHAT_COPY: {
70
+ readonly SEND_FAILED_RETRY: "Send failed — tap to retry";
71
+ };
72
+ export type ErrorCopyKey = keyof typeof ERROR_COPY;
73
+ export type RefusalCopyKey = keyof typeof REFUSAL_COPY;
74
+ export type ClarificationCopyKey = keyof typeof CLARIFICATION_COPY;
75
+ export type ChatCopyKey = keyof typeof CHAT_COPY;
@@ -0,0 +1,19 @@
1
+ import { z } from "zod";
2
+ /** Anchor-seed + font selection applied by the workspace design panel. */
3
+ export declare const WorkspaceDesignApplyRequestSchema: z.ZodObject<{
4
+ colorSeeds: z.ZodOptional<z.ZodObject<{
5
+ primary: z.ZodString;
6
+ accent: z.ZodString;
7
+ }, z.core.$strict>>;
8
+ fonts: z.ZodOptional<z.ZodObject<{
9
+ heading: z.ZodString;
10
+ body: z.ZodString;
11
+ }, z.core.$strict>>;
12
+ }, z.core.$strict>;
13
+ export type WorkspaceDesignApplyRequest = z.infer<typeof WorkspaceDesignApplyRequestSchema>;
14
+ export declare const WorkspaceDesignApplyResponseSchema: z.ZodObject<{
15
+ ok: z.ZodLiteral<true>;
16
+ design_plan_version: z.ZodNumber;
17
+ snapshot_id: z.ZodString;
18
+ }, z.core.$strip>;
19
+ export type WorkspaceDesignApplyResponse = z.infer<typeof WorkspaceDesignApplyResponseSchema>;
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@vcp-dev/contracts",
3
+ "version": "0.3.14",
4
+ "type": "module",
5
+ "license": "UNLICENSED",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://gitlab.cedemo.cn/vibe-coding-platform/vcp.git"
9
+ },
10
+ "homepage": "https://gitlab.cedemo.cn/vibe-coding-platform/vcp",
11
+ "bugs": {
12
+ "url": "https://gitlab.cedemo.cn/vibe-coding-platform/vcp/-/issues"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "main": "./dist/index.js",
18
+ "types": "./dist/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "development": "./src/index.ts",
22
+ "types": "./dist/index.d.ts",
23
+ "default": "./dist/index.js"
24
+ },
25
+ "./site-edit-runtime-capability": {
26
+ "development": "./src/site-edit-runtime-capability.ts",
27
+ "types": "./dist/site-edit-runtime-capability.d.ts",
28
+ "default": "./dist/site-edit-runtime-capability.js"
29
+ },
30
+ "./design-tokens": {
31
+ "development": "./src/design-tokens.ts",
32
+ "types": "./dist/design-tokens.d.ts",
33
+ "default": "./dist/design-tokens.js"
34
+ },
35
+ "./colorway-distinctness": {
36
+ "development": "./src/colorway-distinctness.ts",
37
+ "types": "./dist/colorway-distinctness.d.ts",
38
+ "default": "./dist/colorway-distinctness.js"
39
+ }
40
+ },
41
+ "files": [
42
+ "dist",
43
+ "README.md"
44
+ ],
45
+ "engines": {
46
+ "node": ">=24.0.0"
47
+ },
48
+ "scripts": {
49
+ "build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.build.json",
50
+ "test": "vitest run --root ../.. packages/contracts/src",
51
+ "typecheck": "tsc -p tsconfig.json --noEmit"
52
+ },
53
+ "dependencies": {
54
+ "culori": "^4.0.2",
55
+ "zod": "^4.0.0"
56
+ },
57
+ "devDependencies": {
58
+ "@types/culori": "^4.0.1",
59
+ "typescript": "^5.8.0"
60
+ }
61
+ }