@tano.page/protocol 0.14.0 → 0.15.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.
@@ -0,0 +1,419 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://tano.page/schemas/manifest.schema.json",
4
+ "title": "Tano Plugin Manifest",
5
+ "description": "Official JSON Schema for Tano (同页) declarative (manifestVersion 1) and executable code (manifestVersion 2) plugin manifests across Phases 0–4.",
6
+ "oneOf": [
7
+ { "$ref": "#/$defs/declarativeManifest" },
8
+ { "$ref": "#/$defs/executableManifest" }
9
+ ],
10
+ "$defs": {
11
+ "pluginId": {
12
+ "type": "string",
13
+ "pattern": "^[a-z][a-z0-9-]{0,39}$",
14
+ "description": "Lowercase plugin identifier (1–40 chars)."
15
+ },
16
+ "pluginKey": {
17
+ "type": "string",
18
+ "pattern": "^[a-z][a-z0-9.-]{0,79}$"
19
+ },
20
+ "semver": {
21
+ "type": "string",
22
+ "pattern": "^\\d+\\.\\d+\\.\\d+$"
23
+ },
24
+ "platform": {
25
+ "type": "string",
26
+ "enum": ["desktop-local", "desktop-online", "web", "mobile"]
27
+ },
28
+ "engines": {
29
+ "type": "object",
30
+ "additionalProperties": false,
31
+ "properties": {
32
+ "tano": {
33
+ "type": "string",
34
+ "pattern": "^>=\\d+\\.\\d+\\.\\d+$",
35
+ "description": "Minimum supported Tano Core semver, e.g. \">=0.14.0\"."
36
+ }
37
+ }
38
+ },
39
+ "permission": {
40
+ "type": "string",
41
+ "enum": [
42
+ "attachments.read",
43
+ "attachments.write",
44
+ "documents.read",
45
+ "documents.write",
46
+ "documents.move",
47
+ "documents.trash",
48
+ "objects.read",
49
+ "objects.write",
50
+ "relations.read",
51
+ "relations.write",
52
+ "storage",
53
+ "network",
54
+ "connections",
55
+ "native",
56
+ "ui",
57
+ "ai.invoke"
58
+ ]
59
+ },
60
+ "menuLocation": {
61
+ "type": "string",
62
+ "enum": ["workspace", "document", "file"]
63
+ },
64
+ "viewLocation": {
65
+ "type": "string",
66
+ "enum": [
67
+ "panel",
68
+ "tab",
69
+ "sidebar",
70
+ "settings",
71
+ "documentSidebar",
72
+ "documentHeader",
73
+ "documentFooter",
74
+ "homeTab",
75
+ "newTab"
76
+ ]
77
+ },
78
+ "viewLayout": {
79
+ "type": "string",
80
+ "enum": ["contained", "fill"]
81
+ },
82
+ "commandDefinition": {
83
+ "type": "object",
84
+ "additionalProperties": false,
85
+ "required": ["id", "label"],
86
+ "properties": {
87
+ "id": { "$ref": "#/$defs/pluginKey" },
88
+ "label": { "type": "string", "minLength": 1, "maxLength": 80 },
89
+ "shortcut": { "type": "string", "minLength": 1, "maxLength": 40 },
90
+ "menus": {
91
+ "type": "array",
92
+ "items": { "$ref": "#/$defs/menuLocation" },
93
+ "uniqueItems": true
94
+ }
95
+ }
96
+ },
97
+ "slashCommandDefinition": {
98
+ "type": "object",
99
+ "additionalProperties": false,
100
+ "required": ["id", "label", "command"],
101
+ "properties": {
102
+ "id": { "$ref": "#/$defs/pluginKey" },
103
+ "label": { "type": "string", "minLength": 1, "maxLength": 80 },
104
+ "command": { "$ref": "#/$defs/pluginKey" },
105
+ "description": { "type": "string", "maxLength": 200 },
106
+ "keywords": {
107
+ "type": "array",
108
+ "maxItems": 12,
109
+ "items": { "type": "string", "minLength": 1, "maxLength": 40 }
110
+ }
111
+ }
112
+ },
113
+ "viewDefinition": {
114
+ "type": "object",
115
+ "additionalProperties": false,
116
+ "required": ["id", "label"],
117
+ "properties": {
118
+ "id": { "$ref": "#/$defs/pluginKey" },
119
+ "label": { "type": "string", "minLength": 1, "maxLength": 80 },
120
+ "location": { "$ref": "#/$defs/viewLocation" },
121
+ "layout": { "$ref": "#/$defs/viewLayout" }
122
+ }
123
+ },
124
+ "codeBlockRendererDefinition": {
125
+ "type": "object",
126
+ "additionalProperties": false,
127
+ "required": ["languages", "view"],
128
+ "properties": {
129
+ "languages": {
130
+ "type": "array",
131
+ "minItems": 1,
132
+ "maxItems": 12,
133
+ "items": { "type": "string", "pattern": "^[a-z0-9][a-z0-9.+#_-]{0,31}$" }
134
+ },
135
+ "view": { "$ref": "#/$defs/pluginKey" },
136
+ "label": { "type": "string", "minLength": 1, "maxLength": 80 },
137
+ "height": { "type": "integer", "minimum": 80, "maximum": 1200 }
138
+ }
139
+ },
140
+ "fileHandlerDefinition": {
141
+ "type": "object",
142
+ "additionalProperties": false,
143
+ "required": ["extensions", "mode", "view", "command"],
144
+ "properties": {
145
+ "extensions": {
146
+ "type": "array",
147
+ "minItems": 1,
148
+ "maxItems": 12,
149
+ "items": { "type": "string", "pattern": "^\\.[a-z0-9][a-z0-9.-]{0,30}$" }
150
+ },
151
+ "mode": { "type": "string", "enum": ["preview", "editor"] },
152
+ "view": { "$ref": "#/$defs/pluginKey" },
153
+ "command": { "$ref": "#/$defs/pluginKey" }
154
+ }
155
+ },
156
+ "assistantToolDefinition": {
157
+ "type": "object",
158
+ "additionalProperties": false,
159
+ "required": ["name", "label", "description", "effect", "parameters"],
160
+ "properties": {
161
+ "name": { "$ref": "#/$defs/pluginKey" },
162
+ "label": { "type": "string", "minLength": 1, "maxLength": 80 },
163
+ "description": { "type": "string", "minLength": 1, "maxLength": 400 },
164
+ "effect": { "type": "string", "enum": ["read", "write", "external"] },
165
+ "parameters": { "type": "object" }
166
+ }
167
+ },
168
+ "assistantContextProviderDefinition": {
169
+ "type": "object",
170
+ "additionalProperties": false,
171
+ "required": ["id", "label", "description"],
172
+ "properties": {
173
+ "id": { "$ref": "#/$defs/pluginKey" },
174
+ "label": { "type": "string", "minLength": 1, "maxLength": 80 },
175
+ "description": { "type": "string", "minLength": 1, "maxLength": 400 },
176
+ "maxBytes": { "type": "integer", "minimum": 256, "maximum": 16000 }
177
+ }
178
+ },
179
+ "serviceDefinition": {
180
+ "type": "object",
181
+ "additionalProperties": false,
182
+ "required": ["name", "description"],
183
+ "properties": {
184
+ "name": { "$ref": "#/$defs/pluginKey" },
185
+ "description": { "type": "string", "minLength": 1, "maxLength": 400 },
186
+ "parameters": { "type": "object" },
187
+ "returns": { "type": "object" }
188
+ }
189
+ },
190
+ "serviceDependency": {
191
+ "type": "object",
192
+ "additionalProperties": false,
193
+ "required": ["pluginId", "service"],
194
+ "properties": {
195
+ "pluginId": { "$ref": "#/$defs/pluginId" },
196
+ "service": { "$ref": "#/$defs/pluginKey" },
197
+ "optional": { "type": "boolean" }
198
+ }
199
+ },
200
+ "settingField": {
201
+ "type": "object",
202
+ "additionalProperties": false,
203
+ "required": ["key", "label", "type"],
204
+ "properties": {
205
+ "key": { "$ref": "#/$defs/pluginKey" },
206
+ "label": { "type": "string", "minLength": 1, "maxLength": 80 },
207
+ "description": { "type": "string", "maxLength": 300 },
208
+ "type": { "type": "string", "enum": ["string", "number", "boolean", "select"] },
209
+ "default": { "type": ["string", "number", "boolean"] },
210
+ "options": {
211
+ "type": "array",
212
+ "items": {
213
+ "type": "object",
214
+ "additionalProperties": false,
215
+ "required": ["value", "label"],
216
+ "properties": {
217
+ "value": { "type": "string", "minLength": 1, "maxLength": 80 },
218
+ "label": { "type": "string", "minLength": 1, "maxLength": 80 }
219
+ }
220
+ }
221
+ },
222
+ "min": { "type": "number" },
223
+ "max": { "type": "number" },
224
+ "required": { "type": "boolean" }
225
+ }
226
+ },
227
+ "activationEvent": {
228
+ "type": "string",
229
+ "pattern": "^(onStartup|onCommand:[a-z][a-z0-9.-]{0,79}|onView:[a-z][a-z0-9.-]{0,79}|onFile:\\.[a-z0-9][a-z0-9.-]{0,30}|onAssistantTool:[a-z][a-z0-9.-]{0,79}|onAssistantContext:[a-z][a-z0-9.-]{0,79}|onService:[a-z][a-z0-9.-]{0,79})$"
230
+ },
231
+ "automationDefinition": {
232
+ "type": "object",
233
+ "additionalProperties": false,
234
+ "required": ["id", "label"],
235
+ "properties": {
236
+ "id": { "$ref": "#/$defs/pluginKey" },
237
+ "label": { "type": "string", "minLength": 1, "maxLength": 80 }
238
+ }
239
+ },
240
+ "objectTypeDefinition": {
241
+ "type": "object",
242
+ "required": ["type", "label", "fields"],
243
+ "properties": {
244
+ "type": { "type": "string", "minLength": 1, "maxLength": 80 },
245
+ "label": { "type": "string", "minLength": 1, "maxLength": 80 },
246
+ "fields": { "type": "array" }
247
+ }
248
+ },
249
+ "relationTypeDefinition": {
250
+ "type": "object",
251
+ "required": ["type", "label"],
252
+ "properties": {
253
+ "type": { "type": "string", "minLength": 1, "maxLength": 80 },
254
+ "label": { "type": "string", "minLength": 1, "maxLength": 80 }
255
+ }
256
+ },
257
+ "declarativeManifest": {
258
+ "type": "object",
259
+ "additionalProperties": false,
260
+ "required": [
261
+ "manifestVersion",
262
+ "id",
263
+ "name",
264
+ "version",
265
+ "description",
266
+ "objectTypes",
267
+ "relationTypes"
268
+ ],
269
+ "properties": {
270
+ "$schema": { "type": "string" },
271
+ "manifestVersion": { "const": 1 },
272
+ "id": { "$ref": "#/$defs/pluginId" },
273
+ "name": { "type": "string", "minLength": 1, "maxLength": 80 },
274
+ "version": { "$ref": "#/$defs/semver" },
275
+ "description": { "type": "string", "maxLength": 2000 },
276
+ "engines": { "$ref": "#/$defs/engines" },
277
+ "platforms": {
278
+ "type": "array",
279
+ "minItems": 1,
280
+ "uniqueItems": true,
281
+ "items": { "$ref": "#/$defs/platform" }
282
+ },
283
+ "appearance": { "type": "object" },
284
+ "objectTypes": {
285
+ "type": "array",
286
+ "maxItems": 50,
287
+ "items": { "$ref": "#/$defs/objectTypeDefinition" }
288
+ },
289
+ "relationTypes": {
290
+ "type": "array",
291
+ "maxItems": 100,
292
+ "items": { "$ref": "#/$defs/relationTypeDefinition" }
293
+ }
294
+ }
295
+ },
296
+ "executableManifest": {
297
+ "type": "object",
298
+ "additionalProperties": false,
299
+ "required": [
300
+ "manifestVersion",
301
+ "apiVersion",
302
+ "id",
303
+ "name",
304
+ "version",
305
+ "description",
306
+ "objectTypes",
307
+ "relationTypes",
308
+ "permissions",
309
+ "networkOrigins",
310
+ "nativeCommands",
311
+ "commands",
312
+ "views"
313
+ ],
314
+ "properties": {
315
+ "$schema": { "type": "string" },
316
+ "manifestVersion": { "const": 2 },
317
+ "apiVersion": { "const": 1 },
318
+ "id": { "$ref": "#/$defs/pluginId" },
319
+ "name": { "type": "string", "minLength": 1, "maxLength": 80 },
320
+ "version": { "$ref": "#/$defs/semver" },
321
+ "description": { "type": "string", "maxLength": 2000 },
322
+ "engines": { "$ref": "#/$defs/engines" },
323
+ "platforms": {
324
+ "type": "array",
325
+ "minItems": 1,
326
+ "uniqueItems": true,
327
+ "items": { "$ref": "#/$defs/platform" }
328
+ },
329
+ "appearance": { "type": "object" },
330
+ "objectTypes": {
331
+ "type": "array",
332
+ "maxItems": 50,
333
+ "items": { "$ref": "#/$defs/objectTypeDefinition" }
334
+ },
335
+ "relationTypes": {
336
+ "type": "array",
337
+ "maxItems": 100,
338
+ "items": { "$ref": "#/$defs/relationTypeDefinition" }
339
+ },
340
+ "permissions": {
341
+ "type": "array",
342
+ "uniqueItems": true,
343
+ "items": { "$ref": "#/$defs/permission" }
344
+ },
345
+ "networkOrigins": {
346
+ "type": "array",
347
+ "maxItems": 20,
348
+ "items": { "type": "string", "format": "uri", "pattern": "^https://" }
349
+ },
350
+ "nativeCommands": {
351
+ "type": "array",
352
+ "maxItems": 20,
353
+ "items": { "$ref": "#/$defs/pluginKey" }
354
+ },
355
+ "commands": {
356
+ "type": "array",
357
+ "maxItems": 50,
358
+ "items": { "$ref": "#/$defs/commandDefinition" }
359
+ },
360
+ "slashCommands": {
361
+ "type": "array",
362
+ "maxItems": 20,
363
+ "items": { "$ref": "#/$defs/slashCommandDefinition" }
364
+ },
365
+ "views": {
366
+ "type": "array",
367
+ "maxItems": 20,
368
+ "items": { "$ref": "#/$defs/viewDefinition" }
369
+ },
370
+ "codeBlockRenderers": {
371
+ "type": "array",
372
+ "maxItems": 10,
373
+ "items": { "$ref": "#/$defs/codeBlockRendererDefinition" }
374
+ },
375
+ "fileHandlers": {
376
+ "type": "array",
377
+ "maxItems": 10,
378
+ "items": { "$ref": "#/$defs/fileHandlerDefinition" }
379
+ },
380
+ "assistantTools": {
381
+ "type": "array",
382
+ "maxItems": 20,
383
+ "items": { "$ref": "#/$defs/assistantToolDefinition" }
384
+ },
385
+ "assistantContextProviders": {
386
+ "type": "array",
387
+ "maxItems": 10,
388
+ "items": { "$ref": "#/$defs/assistantContextProviderDefinition" }
389
+ },
390
+ "services": {
391
+ "type": "array",
392
+ "maxItems": 16,
393
+ "items": { "$ref": "#/$defs/serviceDefinition" }
394
+ },
395
+ "usesServices": {
396
+ "type": "array",
397
+ "maxItems": 16,
398
+ "items": { "$ref": "#/$defs/serviceDependency" }
399
+ },
400
+ "settingsSchema": {
401
+ "type": "array",
402
+ "maxItems": 40,
403
+ "items": { "$ref": "#/$defs/settingField" }
404
+ },
405
+ "activationEvents": {
406
+ "type": "array",
407
+ "maxItems": 32,
408
+ "uniqueItems": true,
409
+ "items": { "$ref": "#/$defs/activationEvent" }
410
+ },
411
+ "automations": {
412
+ "type": "array",
413
+ "maxItems": 20,
414
+ "items": { "$ref": "#/$defs/automationDefinition" }
415
+ }
416
+ }
417
+ }
418
+ }
419
+ }
package/package.json CHANGED
@@ -1,16 +1,23 @@
1
1
  {
2
2
  "name": "@tano.page/protocol",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.ts",
7
+ "./agent-inbox": "./src/domain/agent-inbox.ts",
8
+ "./assistant-files": "./src/domain/assistant-files.ts",
9
+ "./assistant-history": "./src/domain/assistant-history.ts",
7
10
  "./features": "./src/features.ts",
8
11
  "./frontmatter": "./src/frontmatter.ts",
9
- "./markdown-file-metadata": "./src/markdown-file-metadata.ts"
12
+ "./markdown-file-metadata": "./src/markdown-file-metadata.ts",
13
+ "./untrusted-data": "./src/domain/untrusted-data.ts",
14
+ "./workspace-comments": "./src/domain/workspace-comments.ts",
15
+ "./manifest.schema.json": "./manifest.schema.json"
10
16
  },
11
17
  "license": "MIT",
12
18
  "files": [
13
19
  "src",
20
+ "manifest.schema.json",
14
21
  "LICENSE"
15
22
  ],
16
23
  "dependencies": {
@@ -25,8 +32,8 @@
25
32
  "url": "git+https://github.com/Dramwig/Tano.git"
26
33
  },
27
34
  "tanoCore": {
28
- "sourceCommit": "b29ddb71202c3b993965e52a1459eea3b0cc42b7",
29
- "version": "0.14.0",
35
+ "sourceCommit": "70164f251c3bacf688734a440d682dba28e38eae",
36
+ "version": "0.15.0",
30
37
  "importName": "@tano/protocol"
31
38
  }
32
39
  }
package/src/appearance.ts CHANGED
@@ -54,10 +54,17 @@ export interface FileIconTheme {
54
54
  folderNames?: Readonly<Record<string, string>>;
55
55
  folderNamesExpanded?: Readonly<Record<string, string>>;
56
56
  }
57
+ export interface FileIconThemeRef {
58
+ id: string;
59
+ label: string;
60
+ notice?: string;
61
+ }
57
62
  export interface PluginAppearance {
58
63
  version: typeof appearanceVersion;
59
64
  colors?: ColorThemeDefinition[];
60
65
  icons?: FileIconTheme[];
66
+ /** Lightweight metadata for heavy raster icon themes stored in PluginPackage.assets.icons. */
67
+ iconRefs?: FileIconThemeRef[];
61
68
  layouts?: LayoutThemeDefinition[];
62
69
  shapes?: ShapeThemeDefinition[];
63
70
  presets?: ThemePresetDefinition[];
@@ -184,7 +191,7 @@ export function parseFileIconTheme(value: unknown): FileIconTheme {
184
191
  return result as unknown as FileIconTheme;
185
192
  }
186
193
  export function parsePluginAppearance(value: unknown): PluginAppearance {
187
- keys(value, ['version', 'colors', 'icons', 'layouts', 'shapes', 'presets']);
194
+ keys(value, ['version', 'colors', 'icons', 'iconRefs', 'layouts', 'shapes', 'presets']);
188
195
  if (value.version !== appearanceVersion) throw new Error('不支持此主题契约版本');
189
196
  const parseList = <T extends { id: string }>(input: unknown, parse: (value: unknown) => T): T[] => {
190
197
  if (!Array.isArray(input) || input.length > 12) throw new Error('主题列表无效');
@@ -211,6 +218,14 @@ export function parsePluginAppearance(value: unknown): PluginAppearance {
211
218
  return { id: item.id, label: item.label, tokens: parseThemeTokens(item.tokens) };
212
219
  });
213
220
  const icons = value.icons === undefined ? undefined : parseList(value.icons, parseFileIconTheme);
221
+ const iconRefs = value.iconRefs === undefined ? undefined : parseList<FileIconThemeRef>(value.iconRefs, item => {
222
+ keys(item, ['id', 'label', 'notice']); id(item.id); label(item.label);
223
+ if (item.notice !== undefined && (typeof item.notice !== 'string' || item.notice.length > 4096 || /[\u0000-\u0008\u000b\u000c\u000e-\u001f]/.test(item.notice)))
224
+ throw new Error('图标许可声明无效');
225
+ return { id: item.id, label: item.label, ...(item.notice === undefined ? {} : { notice: item.notice }) };
226
+ });
227
+ const allIconChoices = [...(icons ?? []), ...(iconRefs ?? [])];
228
+ if (new Set(allIconChoices.map(item => item.id)).size !== allIconChoices.length) throw new Error('主题 ID 重复');
214
229
  const layouts = value.layouts === undefined ? undefined : parseList(value.layouts, item => {
215
230
  keys(item, ['id', 'label', 'structure', 'surface', 'gap', 'pageWidth']); id(item.id); label(item.label);
216
231
  // The skeuomorphic notebook structure was retired in favour of the calmer paper document.
@@ -232,8 +247,8 @@ export function parsePluginAppearance(value: unknown): PluginAppearance {
232
247
  return { [key]: target };
233
248
  };
234
249
  if (['color', 'icons', 'layout', 'shape'].every(key => item[key] === undefined)) throw new Error('主题预设至少需要指定一项');
235
- return { id: item.id, label: item.label, ...reference('color', colors), ...reference('icons', icons), ...reference('layout', layouts), ...reference('shape', shapes) };
250
+ return { id: item.id, label: item.label, ...reference('color', colors), ...reference('icons', allIconChoices.length ? allIconChoices : undefined), ...reference('layout', layouts), ...reference('shape', shapes) };
236
251
  });
237
- if (!colors?.length && !icons?.length && !layouts?.length && !shapes?.length && !presets?.length) throw new Error('主题包至少需要一套配色、图标、布局、形态或预设');
238
- return { version: value.version, ...(colors ? { colors } : {}), ...(icons ? { icons } : {}), ...(layouts ? { layouts } : {}), ...(shapes ? { shapes } : {}), ...(presets ? { presets } : {}) };
252
+ if (!colors?.length && !icons?.length && !iconRefs?.length && !layouts?.length && !shapes?.length && !presets?.length) throw new Error('主题包至少需要一套配色、图标、布局、形态或预设');
253
+ return { version: value.version, ...(colors ? { colors } : {}), ...(icons ? { icons } : {}), ...(iconRefs ? { iconRefs } : {}), ...(layouts ? { layouts } : {}), ...(shapes ? { shapes } : {}), ...(presets ? { presets } : {}) };
239
254
  }
package/src/assistant.ts CHANGED
@@ -69,11 +69,25 @@ export interface AssistantPreview {
69
69
  path: string;
70
70
  destination?: string;
71
71
  }
72
+ export interface AssistantProposalPluginAction {
73
+ pluginId: string;
74
+ pluginName: string;
75
+ toolName: string;
76
+ label?: string;
77
+ effect: 'write' | 'external';
78
+ }
79
+ export interface AssistantProposalExtensionAction {
80
+ namespace: string;
81
+ action: string;
82
+ label?: string;
83
+ effect: 'write' | 'external';
84
+ payload: Record<string, unknown>;
85
+ }
72
86
  export interface AssistantProposal {
73
87
  id: string;
74
88
  runId: string;
75
89
  workspaceId: string;
76
- kind: 'edit' | 'create' | 'delete' | 'rename' | 'move' | 'object' | 'relation';
90
+ kind: 'edit' | 'create' | 'delete' | 'rename' | 'move' | 'object' | 'relation' | 'plugin' | 'extension';
77
91
  fileId?: string;
78
92
  path: string;
79
93
  destination?: string;
@@ -84,10 +98,14 @@ export interface AssistantProposal {
84
98
  /** Omitted on legacy and manually reviewed proposals. */
85
99
  execution?: 'direct';
86
100
  preview?: AssistantPreview;
87
- applied?: { before: string; after: string; hash: string; fileId: string };
101
+ applied?: { before: string; after: string; hash: string; fileId: string; undoSnapshot?: string };
88
102
  error?: string;
89
103
  /** Once published, per-edit review belongs to the portable document records. */
90
104
  suggestionGroupId?: string;
105
+ /** Present only when kind === 'plugin' (write/external plugin tool awaiting confirmation). */
106
+ pluginAction?: AssistantProposalPluginAction;
107
+ /** Present only when kind === 'extension' (host extension action awaiting confirmation). */
108
+ extensionAction?: AssistantProposalExtensionAction;
91
109
  }
92
110
 
93
111
  /** Application-recorded receipts; never inferred from the model's answer. */
@@ -373,11 +391,23 @@ export function parseAssistantSession(value: unknown): AssistantSession {
373
391
  }
374
392
  for (const proposal of message.proposals ?? []) {
375
393
  if (!proposal || proposal.workspaceId !== session.workspaceId || !text(proposal.id, 80) ||
376
- !text(proposal.runId, 80) || !['edit', 'create', 'delete', 'rename', 'move', 'object', 'relation'].includes(proposal.kind) ||
394
+ !text(proposal.runId, 80) || !['edit', 'create', 'delete', 'rename', 'move', 'object', 'relation', 'plugin', 'extension'].includes(proposal.kind) ||
377
395
  !['ready', 'applying', 'applied', 'rejected', 'conflicted', 'unknown'].includes(proposal.status) ||
378
396
  (proposal.execution !== undefined && proposal.execution !== 'direct') ||
379
397
  !text(proposal.path, 220) || !text(proposal.base, 512_000) || !text(proposal.content, 512_000) ||
380
398
  !text(proposal.reason, 4000) || (proposal.suggestionGroupId !== undefined && (proposal.kind !== 'edit' || !text(proposal.suggestionGroupId, 80))) || ((['edit', 'delete', 'rename', 'move'].includes(proposal.kind) || (proposal.kind === 'object' && proposal.base !== '')) && !text(proposal.fileId, 80)) ||
399
+ (proposal.kind === 'plugin'
400
+ ? (!proposal.pluginAction || !text(proposal.pluginAction.pluginId, 80) || !text(proposal.pluginAction.pluginName, 120) ||
401
+ !text(proposal.pluginAction.toolName, 80) || !['write', 'external'].includes(proposal.pluginAction.effect) ||
402
+ (proposal.pluginAction.label !== undefined && !text(proposal.pluginAction.label, 80)))
403
+ : proposal.pluginAction !== undefined) ||
404
+ (proposal.kind === 'extension'
405
+ ? (!proposal.extensionAction || !text(proposal.extensionAction.namespace, 80) || !proposal.extensionAction.namespace.trim() ||
406
+ !text(proposal.extensionAction.action, 80) || !proposal.extensionAction.action.trim() ||
407
+ !['write', 'external'].includes(proposal.extensionAction.effect) ||
408
+ (proposal.extensionAction.label !== undefined && !text(proposal.extensionAction.label, 80)) ||
409
+ !proposal.extensionAction.payload || typeof proposal.extensionAction.payload !== 'object' || Array.isArray(proposal.extensionAction.payload))
410
+ : proposal.extensionAction !== undefined) ||
381
411
  (['rename', 'move'].includes(proposal.kind) ? !text(proposal.destination, 220) || !proposal.destination : proposal.destination !== undefined) ||
382
412
  (proposal.preview && (!text(proposal.preview.before, 512_000) ||
383
413
  !text(proposal.preview.after, 512_000) || !text(proposal.preview.path, 220) ||
@@ -385,7 +415,8 @@ export function parseAssistantSession(value: unknown): AssistantSession {
385
415
  (proposal.preview.diskHash !== null && !text(proposal.preview.diskHash, 128)))) ||
386
416
  (proposal.applied && (!text(proposal.applied.before, 512_000) ||
387
417
  !text(proposal.applied.after, 512_000) || !text(proposal.applied.hash, 128) ||
388
- !text(proposal.applied.fileId, 80))))
418
+ !text(proposal.applied.fileId, 80) ||
419
+ (proposal.applied.undoSnapshot !== undefined && !text(proposal.applied.undoSnapshot, 512_000)))))
389
420
  throw new Error('助手修改记录格式无效,原记录已保留');
390
421
  }
391
422
  }