@tano.page/protocol 0.9.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/appearance.ts +207 -0
- package/src/assistant.ts +44 -1
- package/src/comments.ts +32 -1
- package/src/entry-drag.ts +15 -0
- package/src/extensions.ts +3 -3
- package/src/index.ts +7 -0
- package/src/mentions.ts +153 -0
- package/src/objects.ts +10 -3
- package/src/plugins.ts +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tano.page/protocol",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./src/index.ts",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"url": "git+https://github.com/Dramwig/Tano.git"
|
|
25
25
|
},
|
|
26
26
|
"tanoCore": {
|
|
27
|
-
"sourceCommit": "
|
|
28
|
-
"version": "0.
|
|
27
|
+
"sourceCommit": "c88a6825cb3a3de53cf747ad153c99a364fb24b8",
|
|
28
|
+
"version": "0.10.0",
|
|
29
29
|
"importName": "@tano/protocol"
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/** Versioned, data-only appearance contract. Keys map to CSS custom properties. */
|
|
2
|
+
export const appearanceVersion = 2 as const;
|
|
3
|
+
export const themeColorTokens = [
|
|
4
|
+
'paper', 'sidebar', 'surface', 'surface-raised', 'hover', 'text', 'text-secondary', 'muted',
|
|
5
|
+
'line', 'line-strong', 'control-border', 'selected', 'selected-text', 'selection', 'accent',
|
|
6
|
+
'green', 'green-hover', 'green-fill', 'green-fill-hover', 'on-accent', 'block-selection',
|
|
7
|
+
'danger', 'danger-bg', 'warning', 'warning-bg', 'warning-border', 'switch-off',
|
|
8
|
+
'syntax-purple', 'syntax-red', 'syntax-blue', 'syntax-orange', 'syntax-teal', 'syntax-green',
|
|
9
|
+
'highlight-bg', 'suggestion-color', 'diff-add-bg', 'diff-remove-bg', 'quote-border',
|
|
10
|
+
'scrollbar-thumb', 'scrollbar-thumb-hover', 'backdrop',
|
|
11
|
+
] as const;
|
|
12
|
+
export const themeFontTokens = ['font-ui', 'font-mono', 'font-prose'] as const;
|
|
13
|
+
export const themeRadiusTokens = ['radius-control', 'radius-card', 'radius-dialog'] as const;
|
|
14
|
+
export const themeSpaceTokens = ['space-control-x', 'space-control-y', 'space-panel', 'space-row-gap'] as const;
|
|
15
|
+
export const themeShadowTokens = ['overlay-shadow', 'dialog-shadow'] as const;
|
|
16
|
+
export const themeShapeTokens = [...themeFontTokens, ...themeRadiusTokens, ...themeSpaceTokens, ...themeShadowTokens] as const;
|
|
17
|
+
export const themeTokenNames = [...themeColorTokens, ...themeFontTokens, ...themeRadiusTokens, ...themeSpaceTokens, ...themeShadowTokens] as const;
|
|
18
|
+
export type ThemeTokenName = typeof themeTokenNames[number];
|
|
19
|
+
export type ThemeTokens = Partial<Record<ThemeTokenName, string>>;
|
|
20
|
+
export type ColorTokens = Partial<Record<typeof themeColorTokens[number], string>>;
|
|
21
|
+
export type ShapeTokens = Partial<Record<typeof themeShapeTokens[number], string>>;
|
|
22
|
+
/** Declare at least one mode. An omitted mode is unsupported; {} inherits its built-in palette. */
|
|
23
|
+
export type ColorThemeDefinition = {
|
|
24
|
+
id: string;
|
|
25
|
+
label: string;
|
|
26
|
+
} & ({ light: ColorTokens; dark?: ColorTokens } | { light?: ColorTokens; dark: ColorTokens });
|
|
27
|
+
export interface ShapeThemeDefinition {
|
|
28
|
+
id: string;
|
|
29
|
+
label: string;
|
|
30
|
+
tokens: ShapeTokens;
|
|
31
|
+
}
|
|
32
|
+
export type FileIconColor = `#${string}` | 'currentColor' | typeof themeColorTokens[number];
|
|
33
|
+
export interface FileIconDefinition {
|
|
34
|
+
color: FileIconColor;
|
|
35
|
+
paths: readonly string[];
|
|
36
|
+
label?: string;
|
|
37
|
+
silhouette?: 'file' | 'folder' | 'folder-open' | 'none';
|
|
38
|
+
}
|
|
39
|
+
export interface FileIconTheme {
|
|
40
|
+
id: string;
|
|
41
|
+
label: string;
|
|
42
|
+
icons: Readonly<Record<string, FileIconDefinition>>;
|
|
43
|
+
file?: string;
|
|
44
|
+
folder?: string;
|
|
45
|
+
folderExpanded?: string;
|
|
46
|
+
folderHome?: string;
|
|
47
|
+
folderHomeExpanded?: string;
|
|
48
|
+
fileNames?: Readonly<Record<string, string>>;
|
|
49
|
+
fileExtensions?: Readonly<Record<string, string>>;
|
|
50
|
+
folderNames?: Readonly<Record<string, string>>;
|
|
51
|
+
folderNamesExpanded?: Readonly<Record<string, string>>;
|
|
52
|
+
}
|
|
53
|
+
export interface PluginAppearance {
|
|
54
|
+
version: typeof appearanceVersion;
|
|
55
|
+
colors?: ColorThemeDefinition[];
|
|
56
|
+
icons?: FileIconTheme[];
|
|
57
|
+
layouts?: LayoutThemeDefinition[];
|
|
58
|
+
shapes?: ShapeThemeDefinition[];
|
|
59
|
+
presets?: ThemePresetDefinition[];
|
|
60
|
+
}
|
|
61
|
+
/** Local contribution IDs, or explicit builtin:<id> references. No cross-plugin dependencies. */
|
|
62
|
+
export interface ThemePresetDefinition {
|
|
63
|
+
id: string;
|
|
64
|
+
label: string;
|
|
65
|
+
color?: string;
|
|
66
|
+
icons?: string;
|
|
67
|
+
layout?: string;
|
|
68
|
+
shape?: string;
|
|
69
|
+
}
|
|
70
|
+
/** Host-owned structures preserve editor, focus, scroll and drag semantics. */
|
|
71
|
+
export interface LayoutThemeDefinition {
|
|
72
|
+
id: string;
|
|
73
|
+
label: string;
|
|
74
|
+
structure: 'continuous' | 'islands' | 'notebook' | 'document';
|
|
75
|
+
surface: 'flat' | 'paper' | 'skeuomorphic';
|
|
76
|
+
gap?: number;
|
|
77
|
+
pageWidth?: number;
|
|
78
|
+
}
|
|
79
|
+
/** Only host-designed and verified structure/material pairs are supported. */
|
|
80
|
+
export const layoutSurfaceByStructure = {
|
|
81
|
+
continuous: 'flat', islands: 'flat', notebook: 'skeuomorphic', document: 'paper',
|
|
82
|
+
} as const satisfies Record<LayoutThemeDefinition['structure'], LayoutThemeDefinition['surface']>;
|
|
83
|
+
const color = /^#(?:[\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i;
|
|
84
|
+
export function isFileIconColor(value: unknown): value is FileIconColor {
|
|
85
|
+
return typeof value === 'string' && (color.test(value) || value === 'currentColor' || (themeColorTokens as readonly string[]).includes(value));
|
|
86
|
+
}
|
|
87
|
+
export function fileIconCssColor(value: FileIconColor): string {
|
|
88
|
+
return (themeColorTokens as readonly string[]).includes(value) ? `var(--${value})` : value;
|
|
89
|
+
}
|
|
90
|
+
const record = (value: unknown): value is Record<string, unknown> => !!value && typeof value === 'object' && !Array.isArray(value);
|
|
91
|
+
function keys(value: unknown, allowed: readonly string[]): asserts value is Record<string, unknown> {
|
|
92
|
+
if (!record(value) || Object.keys(value).some(key => !allowed.includes(key))) throw new Error('主题包含不支持的字段');
|
|
93
|
+
}
|
|
94
|
+
function label(value: unknown): asserts value is string {
|
|
95
|
+
if (typeof value !== 'string' || !value.trim() || value.length > 80 || /[\u0000-\u001f]/.test(value)) throw new Error('主题名称无效');
|
|
96
|
+
}
|
|
97
|
+
function id(value: unknown): asserts value is string {
|
|
98
|
+
if (typeof value !== 'string' || !/^[a-z][a-z0-9.-]{0,79}$/.test(value)) throw new Error('主题 ID 无效');
|
|
99
|
+
}
|
|
100
|
+
export function parseThemeTokens(value: unknown): ThemeTokens {
|
|
101
|
+
keys(value, themeTokenNames);
|
|
102
|
+
for (const [key, item] of Object.entries(value)) {
|
|
103
|
+
if (typeof item !== 'string' || item.length > 300) throw new Error(`主题变量无效:${key}`);
|
|
104
|
+
let valid = false;
|
|
105
|
+
if ((themeColorTokens as readonly string[]).includes(key)) valid = color.test(item);
|
|
106
|
+
if ((themeFontTokens as readonly string[]).includes(key)) valid = item.split(',').every(family => /^(?:"[\p{L}\p{N} ._-]+"|'[\p{L}\p{N} ._-]+'|[\p{L}\p{N} ._-]+)$/u.test(family.trim()));
|
|
107
|
+
if ((themeRadiusTokens as readonly string[]).includes(key)) valid = /^\d+(?:\.\d+)?px$/.test(item) && parseFloat(item) <= 24;
|
|
108
|
+
if ((themeSpaceTokens as readonly string[]).includes(key)) valid = /^\d+(?:\.\d+)?px$/.test(item) && parseFloat(item) >= 2 && parseFloat(item) <= 24;
|
|
109
|
+
if ((themeShadowTokens as readonly string[]).includes(key)) {
|
|
110
|
+
valid = item === 'none' || (item.split(',').length <= 3 && item.split(',').every(shadow => {
|
|
111
|
+
const parts = shadow.trim().split(/\s+/);
|
|
112
|
+
return parts.length >= 3 && parts.length <= 5 && color.test(parts.at(-1)!) &&
|
|
113
|
+
parts.slice(0, -1).every(part => /^-?\d+(?:\.\d+)?px$/.test(part) && Math.abs(parseFloat(part)) <= 100) &&
|
|
114
|
+
(parts.length < 4 || parseFloat(parts[2]!) >= 0);
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
if (!valid) throw new Error(`主题变量无效:${key}`);
|
|
118
|
+
}
|
|
119
|
+
return { ...value } as ThemeTokens;
|
|
120
|
+
}
|
|
121
|
+
export function parseFileIconTheme(value: unknown): FileIconTheme {
|
|
122
|
+
const defaults = ['file', 'folder', 'folderExpanded', 'folderHome', 'folderHomeExpanded'];
|
|
123
|
+
const maps = ['fileNames', 'fileExtensions', 'folderNames', 'folderNamesExpanded'];
|
|
124
|
+
keys(value, ['id', 'label', 'icons', ...defaults, ...maps]);
|
|
125
|
+
id(value.id); label(value.label);
|
|
126
|
+
if (!record(value.icons) || !Object.keys(value.icons).length || Object.keys(value.icons).length > 256) throw new Error('图标主题数量无效');
|
|
127
|
+
const icons: Record<string, FileIconDefinition> = {};
|
|
128
|
+
for (const [name, icon] of Object.entries(value.icons)) {
|
|
129
|
+
id(name); keys(icon, ['color', 'paths', 'label', 'silhouette']);
|
|
130
|
+
if (!isFileIconColor(icon.color) ||
|
|
131
|
+
!Array.isArray(icon.paths) || icon.paths.length > 32 || icon.paths.some(path => typeof path !== 'string' || path.length > 4096 || !/^[MmZzLlHhVvCcSsQqTtAaEe\d\s.,+\-]*$/.test(path)) ||
|
|
132
|
+
(icon.label !== undefined && (typeof icon.label !== 'string' || icon.label.length > 4 || /[\u0000-\u001f]/.test(icon.label))) ||
|
|
133
|
+
(icon.silhouette !== undefined && !['file', 'folder', 'folder-open', 'none'].includes(String(icon.silhouette)))) throw new Error(`图标无效:${name}`);
|
|
134
|
+
icons[name] = { color: icon.color, paths: [...icon.paths],
|
|
135
|
+
...(icon.label === undefined ? {} : { label: icon.label as string }),
|
|
136
|
+
...(icon.silhouette === undefined ? {} : { silhouette: icon.silhouette as FileIconDefinition['silhouette'] }) };
|
|
137
|
+
}
|
|
138
|
+
const result: Record<string, unknown> = { id: value.id, label: value.label, icons };
|
|
139
|
+
const reference = (name: unknown) => {
|
|
140
|
+
if (typeof name !== 'string' || !Object.hasOwn(icons, name)) throw new Error('图标引用不存在');
|
|
141
|
+
return name;
|
|
142
|
+
};
|
|
143
|
+
for (const name of defaults) if (value[name] !== undefined) result[name] = reference(value[name]);
|
|
144
|
+
for (const name of maps) if (value[name] !== undefined) {
|
|
145
|
+
const map = value[name];
|
|
146
|
+
if (!record(map) || Object.keys(map).length > 512) throw new Error('图标匹配表无效');
|
|
147
|
+
const normalized: Record<string, string> = Object.create(null);
|
|
148
|
+
for (const [key, target] of Object.entries(map)) {
|
|
149
|
+
if (!key.trim() || key.length > 255 || /[\u0000-\u001f/\\]/.test(key) || Object.hasOwn(normalized, key.toLowerCase())) throw new Error('图标匹配名称重复或无效');
|
|
150
|
+
normalized[key.toLowerCase()] = reference(target);
|
|
151
|
+
}
|
|
152
|
+
result[name] = normalized;
|
|
153
|
+
}
|
|
154
|
+
return result as unknown as FileIconTheme;
|
|
155
|
+
}
|
|
156
|
+
export function parsePluginAppearance(value: unknown): PluginAppearance {
|
|
157
|
+
keys(value, ['version', 'colors', 'icons', 'layouts', 'shapes', 'presets']);
|
|
158
|
+
if (value.version !== appearanceVersion) throw new Error('不支持此主题契约版本');
|
|
159
|
+
const parseList = <T extends { id: string }>(input: unknown, parse: (value: unknown) => T): T[] => {
|
|
160
|
+
if (!Array.isArray(input) || input.length > 12) throw new Error('主题列表无效');
|
|
161
|
+
const result = input.map(parse);
|
|
162
|
+
if (new Set(result.map(item => item.id)).size !== result.length) throw new Error('主题 ID 重复');
|
|
163
|
+
return result;
|
|
164
|
+
};
|
|
165
|
+
const colors = value.colors === undefined ? undefined : parseList<ColorThemeDefinition>(value.colors, item => {
|
|
166
|
+
keys(item, ['id', 'label', 'light', 'dark']); id(item.id); label(item.label);
|
|
167
|
+
const parseColors = (tokens: unknown): ColorTokens | undefined => {
|
|
168
|
+
if (tokens === undefined) return;
|
|
169
|
+
keys(tokens, themeColorTokens);
|
|
170
|
+
return parseThemeTokens(tokens);
|
|
171
|
+
};
|
|
172
|
+
const light = parseColors(item.light), dark = parseColors(item.dark);
|
|
173
|
+
if (light === undefined) {
|
|
174
|
+
if (dark === undefined) throw new Error('配色主题至少需要浅色或深色模式');
|
|
175
|
+
return { id: item.id, label: item.label, dark };
|
|
176
|
+
}
|
|
177
|
+
return { id: item.id, label: item.label, light, ...(dark === undefined ? {} : { dark }) };
|
|
178
|
+
});
|
|
179
|
+
const shapes = value.shapes === undefined ? undefined : parseList(value.shapes, item => {
|
|
180
|
+
keys(item, ['id', 'label', 'tokens']); id(item.id); label(item.label); keys(item.tokens, themeShapeTokens);
|
|
181
|
+
return { id: item.id, label: item.label, tokens: parseThemeTokens(item.tokens) };
|
|
182
|
+
});
|
|
183
|
+
const icons = value.icons === undefined ? undefined : parseList(value.icons, parseFileIconTheme);
|
|
184
|
+
const layouts = value.layouts === undefined ? undefined : parseList(value.layouts, item => {
|
|
185
|
+
keys(item, ['id', 'label', 'structure', 'surface', 'gap', 'pageWidth']); id(item.id); label(item.label);
|
|
186
|
+
if (typeof item.structure !== 'string' || !['continuous', 'islands', 'notebook', 'document'].includes(item.structure) ||
|
|
187
|
+
typeof item.surface !== 'string' || !['flat', 'paper', 'skeuomorphic'].includes(item.surface)) throw new Error('布局风格无效');
|
|
188
|
+
if (layoutSurfaceByStructure[item.structure as LayoutThemeDefinition['structure']] !== item.surface) throw new Error(`不支持此布局与材质组合:${item.structure} × ${item.surface}`);
|
|
189
|
+
for (const [key, min, max] of [['gap', 8, 32], ['pageWidth', 640, 1200]] as const) {
|
|
190
|
+
if (item[key] !== undefined && (typeof item[key] !== 'number' || !Number.isInteger(item[key]) || item[key] < min || item[key] > max)) throw new Error(`布局尺寸无效:${key}`);
|
|
191
|
+
}
|
|
192
|
+
return { ...item } as unknown as LayoutThemeDefinition;
|
|
193
|
+
});
|
|
194
|
+
const presets = value.presets === undefined ? undefined : parseList(value.presets, item => {
|
|
195
|
+
keys(item, ['id', 'label', 'color', 'icons', 'layout', 'shape']); id(item.id); label(item.label);
|
|
196
|
+
const reference = (key: 'color' | 'icons' | 'layout' | 'shape', choices: { id: string }[] | undefined) => {
|
|
197
|
+
const target = item[key];
|
|
198
|
+
if (target === undefined) return {};
|
|
199
|
+
if (typeof target !== 'string' || !(/^builtin:[a-z][a-z0-9.-]{0,79}$/.test(target) || choices?.some(choice => choice.id === target))) throw new Error(`主题预设引用不存在:${key}`);
|
|
200
|
+
return { [key]: target };
|
|
201
|
+
};
|
|
202
|
+
if (['color', 'icons', 'layout', 'shape'].every(key => item[key] === undefined)) throw new Error('主题预设至少需要指定一项');
|
|
203
|
+
return { id: item.id, label: item.label, ...reference('color', colors), ...reference('icons', icons), ...reference('layout', layouts), ...reference('shape', shapes) };
|
|
204
|
+
});
|
|
205
|
+
if (!colors?.length && !icons?.length && !layouts?.length && !shapes?.length && !presets?.length) throw new Error('主题包至少需要一套配色、图标、布局、形态或预设');
|
|
206
|
+
return { version: value.version, ...(colors ? { colors } : {}), ...(icons ? { icons } : {}), ...(layouts ? { layouts } : {}), ...(shapes ? { shapes } : {}), ...(presets ? { presets } : {}) };
|
|
207
|
+
}
|
package/src/assistant.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const ASSISTANT_PROTOCOL_VERSION =
|
|
1
|
+
export const ASSISTANT_PROTOCOL_VERSION = 13;
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
export type AssistantReasoningEffort = 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'ultra';
|
|
@@ -11,6 +11,9 @@ export function isAssistantReasoningSelection(value: unknown): value is Assistan
|
|
|
11
11
|
export interface AssistantConnection {
|
|
12
12
|
id: string;
|
|
13
13
|
name: string;
|
|
14
|
+
/** Bundled provider icon ID, `initials`, or omitted for automatic detection. */
|
|
15
|
+
icon?: string;
|
|
16
|
+
quota?: AssistantQuotaConfig;
|
|
14
17
|
kind?: 'api' | 'codex-cli' | 'claude-cli';
|
|
15
18
|
cliPath?: string;
|
|
16
19
|
/** Legacy connection default, used when restoring a conversation without its own selection. */
|
|
@@ -25,6 +28,26 @@ export interface AssistantConnection {
|
|
|
25
28
|
managed?: boolean;
|
|
26
29
|
}
|
|
27
30
|
|
|
31
|
+
export interface AssistantQuotaConfig {
|
|
32
|
+
mode: 'disabled' | 'official' | 'generic' | 'newapi' | 'deepseek' | 'siliconflow' | 'openrouter' | 'sub2api' | 'custom';
|
|
33
|
+
baseUrl?: string;
|
|
34
|
+
userId?: string;
|
|
35
|
+
timeoutSeconds?: number;
|
|
36
|
+
intervalMinutes?: number;
|
|
37
|
+
path?: string;
|
|
38
|
+
method?: 'GET' | 'POST';
|
|
39
|
+
auth?: 'bearer' | 'x-api-key' | 'none';
|
|
40
|
+
body?: string;
|
|
41
|
+
remainingPath?: string;
|
|
42
|
+
usedPath?: string;
|
|
43
|
+
totalPath?: string;
|
|
44
|
+
unit?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface AssistantQuotaResult {
|
|
47
|
+
checkedAt: number;
|
|
48
|
+
items: { label: string; remaining?: number; used?: number; total?: number; unit: string; resetsAt?: string }[];
|
|
49
|
+
}
|
|
50
|
+
|
|
28
51
|
export interface AssistantSource {
|
|
29
52
|
id: string;
|
|
30
53
|
workspaceId: string;
|
|
@@ -144,6 +167,9 @@ export interface AssistantMessage {
|
|
|
144
167
|
termination?: { reason: AssistantTerminationReason };
|
|
145
168
|
error?: string;
|
|
146
169
|
model?: string;
|
|
170
|
+
/** Connection used for this reply; independent of the session's later selection. */
|
|
171
|
+
connectionId?: string;
|
|
172
|
+
connectionName?: string;
|
|
147
173
|
rules?: string[];
|
|
148
174
|
timing?: { firstContentMs?: number; totalMs: number };
|
|
149
175
|
}
|
|
@@ -182,9 +208,24 @@ export interface AssistantRequest {
|
|
|
182
208
|
messages: AssistantWireMessage[];
|
|
183
209
|
tools?: { type: 'function'; function: { name: string; description: string; parameters: Record<string, unknown> } }[];
|
|
184
210
|
}
|
|
211
|
+
export interface AssistantImportCandidate {
|
|
212
|
+
id: string;
|
|
213
|
+
name: string;
|
|
214
|
+
source: string;
|
|
215
|
+
endpoint: string;
|
|
216
|
+
reason: string | null;
|
|
217
|
+
}
|
|
218
|
+
|
|
185
219
|
export interface AssistantTransport {
|
|
220
|
+
inbox?: import('./mentions').AgentInboxStorage;
|
|
221
|
+
hostedInbox?: import('./mentions').HostedAgentInbox;
|
|
222
|
+
readConnectionKey?(connectionId: string): Promise<string>;
|
|
223
|
+
scanCcSwitch?(path?: string): Promise<AssistantImportCandidate[]>;
|
|
224
|
+
importCcSwitch?(ids: string[], path?: string): Promise<void>;
|
|
186
225
|
canConfigure?: boolean;
|
|
187
226
|
connections(): Promise<AssistantConnection[]>;
|
|
227
|
+
quota?(connectionId: string): Promise<AssistantQuotaResult>;
|
|
228
|
+
saveQuota?(connectionId: string, config: AssistantQuotaConfig, key?: string): Promise<void>;
|
|
188
229
|
models(connectionId: string, signal: AbortSignal): Promise<string[]>;
|
|
189
230
|
saveConnection(connection: Omit<AssistantConnection, 'hasKey'>, key?: string): Promise<void>;
|
|
190
231
|
removeConnection(id: string): Promise<void>;
|
|
@@ -220,6 +261,8 @@ export function parseAssistantSession(value: unknown): AssistantSession {
|
|
|
220
261
|
if (!message || !text(message.id, 80) || ids.has(message.id) ||
|
|
221
262
|
!['user', 'assistant'].includes(message.role) || !text(message.content, 1_000_000) ||
|
|
222
263
|
!Number.isFinite(message.createdAt) ||
|
|
264
|
+
(message.connectionId !== undefined && (!text(message.connectionId, 80) || !message.connectionId.trim())) ||
|
|
265
|
+
(message.connectionName !== undefined && (!text(message.connectionName, 120) || !message.connectionId)) ||
|
|
223
266
|
(message.state && !['running', 'waiting', 'completed', 'cancelled', 'failed', 'interrupted'].includes(message.state)) ||
|
|
224
267
|
(message.termination !== undefined && (!message.termination || message.role !== 'assistant' ||
|
|
225
268
|
!['completed', 'cancelled', 'interrupted', 'round_limit', 'no_progress', 'output_limit', 'incomplete', 'empty_response', 'error'].includes(message.termination.reason) ||
|
package/src/comments.ts
CHANGED
|
@@ -25,10 +25,35 @@ export interface CommentMessage {
|
|
|
25
25
|
updatedAt?: number;
|
|
26
26
|
replyTo?: string;
|
|
27
27
|
mentions?: CommentMention[];
|
|
28
|
+
/** Stable execution receipt for idempotent agent replies. */
|
|
29
|
+
agentTaskId?: string;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
/** Explicit person references remain portable; account bindings belong to Cloud. */
|
|
31
|
-
export interface CommentMention { personId: string; text: string }
|
|
33
|
+
export interface CommentMention { personId: string; text: string; id?: string; from?: number }
|
|
34
|
+
|
|
35
|
+
/** Preserve identities outside an input edit and remove any selected mention it replaces. */
|
|
36
|
+
export function rebaseCommentMentions(mentions: readonly CommentMention[], before: string, after: string,
|
|
37
|
+
edit?: { from: number; to: number }): CommentMention[] {
|
|
38
|
+
let start = 0;
|
|
39
|
+
while (start < before.length && start < after.length && before[start] === after[start]) start++;
|
|
40
|
+
let oldEnd = before.length, newEnd = after.length;
|
|
41
|
+
while (oldEnd > start && newEnd > start && before[oldEnd - 1] === after[newEnd - 1]) { oldEnd--; newEnd--; }
|
|
42
|
+
if (edit) {
|
|
43
|
+
const inserted = after.length - before.length + edit.to - edit.from;
|
|
44
|
+
if (edit.from >= 0 && edit.to >= edit.from && edit.to <= before.length && inserted >= 0 &&
|
|
45
|
+
before.slice(0, edit.from) === after.slice(0, edit.from) && before.slice(edit.to) === after.slice(edit.from + inserted)) {
|
|
46
|
+
start = edit.from; oldEnd = edit.to; newEnd = edit.from + inserted;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return mentions.flatMap(mention => {
|
|
50
|
+
if (mention.from === undefined) return after.includes(mention.text) ? [{ ...mention }] : [];
|
|
51
|
+
const end = mention.from + mention.text.length;
|
|
52
|
+
if (mention.from < oldEnd && end > start) return [];
|
|
53
|
+
const from = mention.from >= oldEnd ? mention.from + newEnd - oldEnd : mention.from;
|
|
54
|
+
return after.slice(from, from + mention.text.length) === mention.text ? [{ ...mention, from }] : [];
|
|
55
|
+
});
|
|
56
|
+
}
|
|
32
57
|
|
|
33
58
|
export interface CommentThread {
|
|
34
59
|
id: string;
|
|
@@ -89,10 +114,16 @@ export function parseCommentFile(content: string, kind: CommentKind, fileId: str
|
|
|
89
114
|
(message.updatedAt !== undefined && !Number.isFinite(message.updatedAt))) throw new Error('评论内容格式无效');
|
|
90
115
|
if (message.replyTo !== undefined && (!validId(message.replyTo) || message.replyTo === message.id ||
|
|
91
116
|
!thread.messages.some(item => item.id === message.replyTo))) throw new Error('回复目标无效');
|
|
117
|
+
if (message.agentTaskId !== undefined && !validId(message.agentTaskId)) throw new Error('机器人任务身份无效');
|
|
92
118
|
if (message.mentions !== undefined && (!Array.isArray(message.mentions) || message.mentions.length > 100 ||
|
|
93
119
|
message.mentions.some(item => !item || !/^[0-9a-f]{6}$/.test(item.personId) ||
|
|
120
|
+
item.id !== undefined && !validId(item.id) ||
|
|
94
121
|
!validText(item.text, 120) || !item.text.startsWith('@') || item.text.length < 2 ||
|
|
122
|
+
(item.from !== undefined && (!Number.isSafeInteger(item.from) || item.from < 0 ||
|
|
123
|
+
message.body.slice(item.from, item.from + item.text.length) !== item.text)) ||
|
|
95
124
|
!message.body.includes(item.text)))) throw new Error('提及人物格式无效');
|
|
125
|
+
const mentionIds = message.mentions?.filter(item => item.id).map(item => item.id) ?? [];
|
|
126
|
+
if (new Set(mentionIds).size !== mentionIds.length) throw new Error('提及身份重复');
|
|
96
127
|
messageIds.add(message.id);
|
|
97
128
|
}
|
|
98
129
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ReferenceTarget } from './objects';
|
|
2
|
+
|
|
3
|
+
export const entryReferenceDragType = 'application/x-tano-entry-references';
|
|
4
|
+
|
|
5
|
+
/** Resolve drag identities against live targets, never trust dragged labels or paths. */
|
|
6
|
+
export function droppedEntryReferences(data: string, targets: readonly ReferenceTarget[]): ReferenceTarget[] {
|
|
7
|
+
try {
|
|
8
|
+
const payload = JSON.parse(data);
|
|
9
|
+
if (typeof payload.workspace !== 'string' || !Array.isArray(payload.ids)) return [];
|
|
10
|
+
const ids = new Set(payload.ids.filter((id: unknown) => typeof id === 'string'));
|
|
11
|
+
return targets.filter(target => target.workspace === payload.workspace && ids.has(target.id));
|
|
12
|
+
} catch {
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
}
|
package/src/extensions.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface PluginPackageUsage {
|
|
|
11
11
|
entries: { integrity: string; pluginId: string; version: string; bytes: number;
|
|
12
12
|
state: 'pending' | 'ready' | 'deleting'; pinned: boolean; createdAt: string; removable?: boolean }[];
|
|
13
13
|
}
|
|
14
|
-
export const pluginPermissions = ['documents.read', 'documents.write', 'objects.read', 'objects.write',
|
|
14
|
+
export const pluginPermissions = ['attachments.read', 'documents.read', 'documents.write', 'objects.read', 'objects.write',
|
|
15
15
|
'relations.read', 'relations.write', 'storage', 'network', 'connections', 'native', 'ui'] as const;
|
|
16
16
|
export type PluginPermission = typeof pluginPermissions[number];
|
|
17
17
|
export type PluginMode = 'required' | 'recommended' | 'optional' | 'disabled';
|
|
@@ -74,10 +74,10 @@ export function parsePluginManifest(value: unknown): PluginManifest {
|
|
|
74
74
|
if (!pluginRecord(value)) throw new Error('插件清单无效');
|
|
75
75
|
if (value.manifestVersion === 1) return parseObjectPlugin(JSON.stringify(value));
|
|
76
76
|
keys(value, ['manifestVersion', 'apiVersion', 'id', 'name', 'version', 'description', 'objectTypes',
|
|
77
|
-
'relationTypes', 'permissions', 'networkOrigins', 'nativeCommands', 'commands', 'views', 'automations']);
|
|
77
|
+
'relationTypes', 'permissions', 'networkOrigins', 'nativeCommands', 'commands', 'views', 'automations', 'appearance']);
|
|
78
78
|
if (value.manifestVersion !== 2 || value.apiVersion !== 1) throw new Error('不支持此插件 API 版本');
|
|
79
79
|
const base = parseObjectPlugin(JSON.stringify({ manifestVersion: 1, id: value.id, name: value.name,
|
|
80
|
-
version: value.version, description: value.description, objectTypes: value.objectTypes ?? [], relationTypes: value.relationTypes ?? [] }));
|
|
80
|
+
version: value.version, description: value.description, objectTypes: value.objectTypes ?? [], relationTypes: value.relationTypes ?? [], ...(value.appearance === undefined ? {} : { appearance: value.appearance }) }));
|
|
81
81
|
const uniqueStrings = (input: unknown, check: (item: unknown) => boolean, limit = 50): string[] => {
|
|
82
82
|
if (!Array.isArray(input) || input.length > limit || input.some(item => !check(item)) || new Set(input).size !== input.length)
|
|
83
83
|
throw new Error('插件权限或扩展入口无效');
|
package/src/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * from './plugins';
|
|
|
9
9
|
export * from './extensions';
|
|
10
10
|
export * from './workspace-paths';
|
|
11
11
|
export * from './comments';
|
|
12
|
+
export * from './mentions';
|
|
12
13
|
export * from './suggestions';
|
|
13
14
|
export * from './document-layout';
|
|
14
15
|
export * from './data-tables';
|
|
@@ -105,6 +106,8 @@ export interface WorkspaceAdapter {
|
|
|
105
106
|
/** Confirm the staged request, reusing its durable identity and idempotency key on retry. */
|
|
106
107
|
commitCreate?(id: string): Promise<{ file: FileEntry; snapshot: FileSnapshot }>;
|
|
107
108
|
createFolder(path: string): Promise<void>;
|
|
109
|
+
/** Must reject nonempty directories, including hidden/unindexed entries; never recurse. */
|
|
110
|
+
removeEmptyFolder?(workspaceId: string, path: string): Promise<void>;
|
|
108
111
|
rename(from: string, to: string): Promise<void>;
|
|
109
112
|
move(from: string, to: string, kind: FileEntry['kind']): Promise<void>;
|
|
110
113
|
duplicate?(workspaceId: string, path: string): Promise<string>;
|
|
@@ -190,3 +193,7 @@ export * from './agent-gateway';
|
|
|
190
193
|
export * from './data-table-query';
|
|
191
194
|
|
|
192
195
|
export * from './structured-merge';
|
|
196
|
+
|
|
197
|
+
export * from './entry-drag';
|
|
198
|
+
|
|
199
|
+
export * from './appearance';
|
package/src/mentions.ts
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import type { CommentAnchor, CommentFile, CommentKind } from './comments';
|
|
2
|
+
import { isAssistantModelId, isAssistantReasoningSelection, type AssistantReasoningSelection } from './assistant';
|
|
3
|
+
import type { WorkspaceObject } from './objects';
|
|
4
|
+
|
|
5
|
+
/** Portable membership is independent of the host's credentials and connection IDs. */
|
|
6
|
+
export function isAgentPerson(object: Pick<WorkspaceObject, 'type'> & { properties?: Record<string, unknown> }): boolean {
|
|
7
|
+
return object.type === 'person' && object.properties?.memberKind === 'agent';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function mentionIdFromTitle(title: unknown): string | undefined {
|
|
11
|
+
if (typeof title !== 'string') return;
|
|
12
|
+
return /^tano:mention:([a-z0-9-]{8,80})$/i.exec(title)?.[1];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface AgentBinding {
|
|
16
|
+
personId: string;
|
|
17
|
+
connectionId: string;
|
|
18
|
+
model: string;
|
|
19
|
+
reasoningEffort?: AssistantReasoningSelection;
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
/** A completed identity creation must not recreate a subsequently deleted user file. */
|
|
22
|
+
provisioned?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface MentionSource {
|
|
26
|
+
fileId: string;
|
|
27
|
+
kind: 'document' | CommentKind;
|
|
28
|
+
threadId?: string;
|
|
29
|
+
messageId?: string;
|
|
30
|
+
mentionId?: string;
|
|
31
|
+
anchor?: CommentAnchor;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** IDs identify an occurrence, so retries and ordinary edits keep the same delivery. */
|
|
35
|
+
export interface MentionEvent {
|
|
36
|
+
id: string;
|
|
37
|
+
workspaceId: string;
|
|
38
|
+
personId: string;
|
|
39
|
+
actorId: string;
|
|
40
|
+
source: MentionSource;
|
|
41
|
+
body: string;
|
|
42
|
+
revision: string;
|
|
43
|
+
createdAt: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function commentMentionEvents(workspaceId: string, file: CommentFile, revision: string): MentionEvent[] {
|
|
47
|
+
const events = file.threads.flatMap(thread => thread.messages.flatMap(message => {
|
|
48
|
+
// Generated replies are attributable but never implicitly delegate another task.
|
|
49
|
+
if (message.agentTaskId) return [];
|
|
50
|
+
return (message.mentions ?? []).map(mention => ({
|
|
51
|
+
id: JSON.stringify([file.kind, file.fileId, thread.id, message.id, mention.id ?? mention.personId]),
|
|
52
|
+
workspaceId, personId: mention.personId, actorId: message.authorId,
|
|
53
|
+
source: { fileId: file.fileId, kind: file.kind, threadId: thread.id, messageId: message.id,
|
|
54
|
+
...(thread.anchor ? { anchor: thread.anchor } : {}) },
|
|
55
|
+
body: message.body, revision, createdAt: message.createdAt,
|
|
56
|
+
}));
|
|
57
|
+
}));
|
|
58
|
+
const seen = new Set<string>();
|
|
59
|
+
return events.filter(event => { if (seen.has(event.id)) return false; seen.add(event.id); return true; });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type AgentTaskStatus = 'queued' | 'running' | 'waiting' | 'succeeded' | 'failed' | 'cancelled' | 'uncertain';
|
|
63
|
+
|
|
64
|
+
export interface AgentTask {
|
|
65
|
+
id: string;
|
|
66
|
+
event: MentionEvent;
|
|
67
|
+
binding: AgentBinding;
|
|
68
|
+
status: AgentTaskStatus;
|
|
69
|
+
sessionId: string;
|
|
70
|
+
createdAt: number;
|
|
71
|
+
updatedAt: number;
|
|
72
|
+
attempts: number;
|
|
73
|
+
readyAt?: number;
|
|
74
|
+
claim?: { owner: string; token: string; until: number };
|
|
75
|
+
error?: string;
|
|
76
|
+
/** Persist before writing the reply, then replay with this stable comment ID. */
|
|
77
|
+
result?: { messageId: string; body: string; outcome?: 'succeeded' | 'waiting' | 'uncertain' };
|
|
78
|
+
continuation?: { messageId: string; body: string; threadId: string };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Host application data. Content itself remains in the referenced workspace files. */
|
|
82
|
+
export interface AgentInbox {
|
|
83
|
+
version: 1;
|
|
84
|
+
workspaceId: string;
|
|
85
|
+
revision: number;
|
|
86
|
+
bindings: AgentBinding[];
|
|
87
|
+
tasks: AgentTask[];
|
|
88
|
+
/** Last committed server file sequence consumed from the durable source outbox. */
|
|
89
|
+
eventCursor?: number;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Implementations must atomically compare and replace, across all runners sharing authority. */
|
|
93
|
+
export interface AgentInboxStorage {
|
|
94
|
+
load(workspaceId: string): Promise<AgentInbox>;
|
|
95
|
+
compareExchange(inbox: AgentInbox, expectedRevision: number): Promise<boolean>;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Hosted runners expose controls, never their internal execution-state CAS. */
|
|
99
|
+
export interface HostedAgentInbox {
|
|
100
|
+
list(workspaceId: string): Promise<AgentInbox>;
|
|
101
|
+
connect(workspaceId: string): Promise<void>;
|
|
102
|
+
configure(workspaceId: string, personId: string, model: string, enabled: boolean): Promise<void>;
|
|
103
|
+
cancel(workspaceId: string, taskId: string): Promise<void>;
|
|
104
|
+
retry(workspaceId: string, taskId: string, updatedAt: number): Promise<void>;
|
|
105
|
+
session(workspaceId: string, taskId: string): Promise<import('./assistant').AssistantSession | undefined>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function emptyAgentInbox(workspaceId: string): AgentInbox {
|
|
109
|
+
return { version: 1, workspaceId, revision: 0, bindings: [], tasks: [] };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function parseAgentInbox(value: unknown, workspaceId: string): AgentInbox {
|
|
113
|
+
const inbox = value as AgentInbox;
|
|
114
|
+
const text = (value: unknown, max: number): value is string => typeof value === 'string' && value.length > 0 && value.length <= max;
|
|
115
|
+
const id = (value: unknown) => typeof value === 'string' && /^[a-z0-9-]{8,80}$/i.test(value);
|
|
116
|
+
const shortId = (value: unknown) => typeof value === 'string' && /^[a-f0-9]{6}$/.test(value);
|
|
117
|
+
const bindingValid = (binding: AgentBinding) => binding && shortId(binding.personId) && text(binding.connectionId, 120) &&
|
|
118
|
+
(binding.model === '' || isAssistantModelId(binding.model)) && typeof binding.enabled === 'boolean' &&
|
|
119
|
+
(binding.provisioned === undefined || typeof binding.provisioned === 'boolean') &&
|
|
120
|
+
(binding.reasoningEffort === undefined || isAssistantReasoningSelection(binding.reasoningEffort));
|
|
121
|
+
if (!inbox || inbox.version !== 1 || inbox.workspaceId !== workspaceId || !text(workspaceId, 120) ||
|
|
122
|
+
!Number.isSafeInteger(inbox.revision) || inbox.revision < 0 ||
|
|
123
|
+
(inbox.eventCursor !== undefined && (!Number.isSafeInteger(inbox.eventCursor) || inbox.eventCursor < 0)) ||
|
|
124
|
+
!Array.isArray(inbox.bindings) || inbox.bindings.length > 1000 || !inbox.bindings.every(bindingValid) ||
|
|
125
|
+
new Set(inbox.bindings.map(binding => binding.personId)).size !== inbox.bindings.length ||
|
|
126
|
+
!Array.isArray(inbox.tasks) || inbox.tasks.length > 10000) throw new Error('机器人收件箱格式无效');
|
|
127
|
+
const taskIds = new Set<string>();
|
|
128
|
+
const events = new Set<string>();
|
|
129
|
+
for (const task of inbox.tasks) {
|
|
130
|
+
const event = task?.event;
|
|
131
|
+
const source = event?.source;
|
|
132
|
+
if (!task || !id(task.id) || taskIds.has(task.id) || !id(task.sessionId) || !bindingValid(task.binding) ||
|
|
133
|
+
!['queued', 'running', 'waiting', 'succeeded', 'failed', 'cancelled', 'uncertain'].includes(task.status) ||
|
|
134
|
+
!Number.isFinite(task.createdAt) || !Number.isFinite(task.updatedAt) ||
|
|
135
|
+
!Number.isSafeInteger(task.attempts) || task.attempts < 0 ||
|
|
136
|
+
(task.readyAt !== undefined && !Number.isFinite(task.readyAt)) ||
|
|
137
|
+
!event || !text(event.id, 1000) || event.workspaceId !== workspaceId || event.personId !== task.binding.personId ||
|
|
138
|
+
!text(event.actorId, 120) || !text(event.body, 20000) || !text(event.revision, 256) || !Number.isFinite(event.createdAt) ||
|
|
139
|
+
!source || !shortId(source.fileId) || !['document', 'annotation', 'discussion'].includes(source.kind) ||
|
|
140
|
+
(source.kind !== 'document' && (!id(source.threadId) || !id(source.messageId))) ||
|
|
141
|
+
(task.error !== undefined && (typeof task.error !== 'string' || task.error.length > 20000)) ||
|
|
142
|
+
(task.result !== undefined && (!id(task.result?.messageId) || !text(task.result?.body, 20000))) ||
|
|
143
|
+
(task.result?.outcome !== undefined && !['succeeded', 'waiting', 'uncertain'].includes(task.result.outcome)) ||
|
|
144
|
+
(task.continuation !== undefined && (!id(task.continuation?.messageId) || !id(task.continuation?.threadId) || !text(task.continuation?.body, 20000))) ||
|
|
145
|
+
(task.status === 'running' && !task.claim) ||
|
|
146
|
+
(task.claim !== undefined && (!text(task.claim.owner, 120) || !id(task.claim.token) || !Number.isFinite(task.claim.until))))
|
|
147
|
+
throw new Error('机器人任务格式无效');
|
|
148
|
+
const eventKey = JSON.stringify([event.id, event.personId]);
|
|
149
|
+
if (events.has(eventKey)) throw new Error('机器人任务重复');
|
|
150
|
+
taskIds.add(task.id); events.add(eventKey);
|
|
151
|
+
}
|
|
152
|
+
return inbox;
|
|
153
|
+
}
|
package/src/objects.ts
CHANGED
|
@@ -68,10 +68,17 @@ export function referenceUrl(target: ReferenceIdentity): string {
|
|
|
68
68
|
if (!isShortId(target.id) || !validObjectType(target.type)) throw new Error('引用身份无效');
|
|
69
69
|
return `object://${target.type}/${target.id}`;
|
|
70
70
|
}
|
|
71
|
-
export function referenceMarkdown(target: ReferenceIdentity,
|
|
72
|
-
const
|
|
73
|
-
return
|
|
71
|
+
export function referenceMarkdown(target: ReferenceIdentity, _label?: string): string {
|
|
72
|
+
const mentionId = target.type === 'person' ? crypto.randomUUID() : '';
|
|
73
|
+
return referenceSyntax(target, false, mentionId);
|
|
74
74
|
}
|
|
75
|
+
/** Names are resolved from the object; occurrence metadata only tracks Agent delivery. */
|
|
76
|
+
export function referenceSyntax(target: ReferenceIdentity, card = false, mentionId = ''): string {
|
|
77
|
+
const metadata = !card && target.type === 'person' && /^[a-z0-9-]{8,80}$/i.test(mentionId)
|
|
78
|
+
? `<!--tano:mention:${mentionId}-->` : '';
|
|
79
|
+
return `${card ? '!' : ''}[[${referenceUrl(target)}]]${metadata}`;
|
|
80
|
+
}
|
|
81
|
+
|
|
75
82
|
export function parseReferenceUrl(url: string): ReferenceIdentity | null {
|
|
76
83
|
const match = /^object:\/\/([a-z][a-z0-9.-]*)\/([0-9a-f]{6})$/.exec(url);
|
|
77
84
|
return match && validObjectType(match[1]) ? { type: match[1]!, id: match[2]! } : null;
|
package/src/plugins.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { parsePluginAppearance, type PluginAppearance } from './appearance';
|
|
1
2
|
import { ObjectTypeRegistry, coreObjectTypes, validObjectType } from './object-types';
|
|
2
3
|
import type { ObjectField } from './object-types';
|
|
3
4
|
import type { RelationTypeDefinition } from './relations';
|
|
4
5
|
|
|
5
6
|
export interface ObjectPluginManifest {
|
|
6
7
|
manifestVersion: 1;
|
|
8
|
+
appearance?: PluginAppearance;
|
|
7
9
|
id: string;
|
|
8
10
|
name: string;
|
|
9
11
|
version: string;
|
|
@@ -37,6 +39,7 @@ export function parseObjectPlugin(content: string): ObjectPluginManifest {
|
|
|
37
39
|
'description',
|
|
38
40
|
'objectTypes',
|
|
39
41
|
'relationTypes',
|
|
42
|
+
'appearance',
|
|
40
43
|
]);
|
|
41
44
|
if (
|
|
42
45
|
value.manifestVersion !== 1 ||
|
|
@@ -100,6 +103,7 @@ export function parseObjectPlugin(content: string): ObjectPluginManifest {
|
|
|
100
103
|
}
|
|
101
104
|
return {
|
|
102
105
|
...value,
|
|
106
|
+
...(value.appearance === undefined ? {} : { appearance: parsePluginAppearance(value.appearance) }),
|
|
103
107
|
objectTypes: value.objectTypes.map((type: { fields?: ObjectField[] }) => ({
|
|
104
108
|
...type,
|
|
105
109
|
fields: type.fields ?? [],
|