@tano.page/protocol 0.12.0 → 0.14.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 +4 -3
- package/src/assistant.ts +22 -1
- package/src/features.ts +28 -0
- package/src/file-core.ts +1 -1
- package/src/index.ts +2 -168
- package/src/objects.ts +1 -1
- package/src/types.ts +166 -0
- package/src/view-engine.ts +2 -1
- package/src/workspace-contract.ts +1 -1
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tano.page/protocol",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./src/index.ts",
|
|
7
|
+
"./features": "./src/features.ts",
|
|
7
8
|
"./frontmatter": "./src/frontmatter.ts",
|
|
8
9
|
"./markdown-file-metadata": "./src/markdown-file-metadata.ts"
|
|
9
10
|
},
|
|
@@ -24,8 +25,8 @@
|
|
|
24
25
|
"url": "git+https://github.com/Dramwig/Tano.git"
|
|
25
26
|
},
|
|
26
27
|
"tanoCore": {
|
|
27
|
-
"sourceCommit": "
|
|
28
|
-
"version": "0.
|
|
28
|
+
"sourceCommit": "b29ddb71202c3b993965e52a1459eea3b0cc42b7",
|
|
29
|
+
"version": "0.14.0",
|
|
29
30
|
"importName": "@tano/protocol"
|
|
30
31
|
}
|
|
31
32
|
}
|
package/src/assistant.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const ASSISTANT_PROTOCOL_VERSION =
|
|
1
|
+
export const ASSISTANT_PROTOCOL_VERSION = 15;
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
export type AssistantReasoningEffort = 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'ultra';
|
|
@@ -151,12 +151,27 @@ export function parseAssistantAnswers(value: unknown, questions: readonly Assist
|
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
+
export type AssistantMediaKind = 'image' | 'pdf' | 'file';
|
|
155
|
+
|
|
156
|
+
export interface AssistantAttachmentInfo {
|
|
157
|
+
name: string;
|
|
158
|
+
kind: 'text' | AssistantMediaKind;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface AssistantMediaAttachment {
|
|
162
|
+
name: string;
|
|
163
|
+
mime: string;
|
|
164
|
+
data: string;
|
|
165
|
+
}
|
|
166
|
+
|
|
154
167
|
export interface AssistantMessage {
|
|
155
168
|
id: string;
|
|
156
169
|
role: 'user' | 'assistant';
|
|
157
170
|
content: string;
|
|
158
171
|
createdAt: number;
|
|
159
172
|
sources?: AssistantSource[];
|
|
173
|
+
/** Clipboard attachment names and types retained in the conversation. */
|
|
174
|
+
attachments?: AssistantAttachmentInfo[];
|
|
160
175
|
/** Initial source IDs attached to the preceding user message; later tool reads are excluded. */
|
|
161
176
|
attachedSourceIds?: string[];
|
|
162
177
|
proposals?: AssistantProposal[];
|
|
@@ -199,6 +214,8 @@ export interface AssistantToolCall {
|
|
|
199
214
|
export interface AssistantWireMessage {
|
|
200
215
|
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
201
216
|
content: string | null;
|
|
217
|
+
/** Inline media on the current user turn, encoded as base64. */
|
|
218
|
+
attachments?: AssistantMediaAttachment[];
|
|
202
219
|
tool_calls?: AssistantToolCall[];
|
|
203
220
|
tool_call_id?: string;
|
|
204
221
|
/** Transient Responses output, including reasoning needed by the next tool round. */
|
|
@@ -225,6 +242,7 @@ export interface AssistantTransport {
|
|
|
225
242
|
scanCcSwitch?(path?: string): Promise<AssistantImportCandidate[]>;
|
|
226
243
|
importCcSwitch?(ids: string[], path?: string): Promise<void>;
|
|
227
244
|
canConfigure?: boolean;
|
|
245
|
+
supportsMediaAttachments?(connection: AssistantConnection, kind: AssistantMediaKind): boolean;
|
|
228
246
|
connections(): Promise<AssistantConnection[]>;
|
|
229
247
|
quota?(connectionId: string): Promise<AssistantQuotaResult>;
|
|
230
248
|
saveQuota?(connectionId: string, config: AssistantQuotaConfig, key?: string): Promise<void>;
|
|
@@ -271,6 +289,9 @@ export function parseAssistantSession(value: unknown): AssistantSession {
|
|
|
271
289
|
!['completed', 'cancelled', 'failed', 'interrupted'].includes(message.state ?? '') ||
|
|
272
290
|
(message.termination.reason === 'completed') !== (message.state === 'completed'))) ||
|
|
273
291
|
(message.sources && (!Array.isArray(message.sources) || message.sources.length > 30)) ||
|
|
292
|
+
(message.attachments !== undefined && (message.role !== 'user' || !Array.isArray(message.attachments) ||
|
|
293
|
+
message.attachments.length > 10 || message.attachments.some(item => !item || !text(item.name, 255) ||
|
|
294
|
+
!item.name.trim() || !['text', 'image', 'pdf', 'file'].includes(item.kind)))) ||
|
|
274
295
|
(message.attachedSourceIds !== undefined && (message.role !== 'assistant' || !Array.isArray(message.attachedSourceIds) ||
|
|
275
296
|
message.attachedSourceIds.length > 20 || new Set(message.attachedSourceIds).size !== message.attachedSourceIds.length ||
|
|
276
297
|
message.attachedSourceIds.some(id => !text(id, 80) || !message.sources?.some(source => source?.id === id)))) ||
|
package/src/features.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
export type FeatureChannel = 'dev' | 'stable';
|
|
3
|
+
export type FeatureDefinition = { status: FeatureChannel; note: string };
|
|
4
|
+
|
|
5
|
+
export function defineFeatures<const T extends Record<string, FeatureDefinition>>(
|
|
6
|
+
definitions: T,
|
|
7
|
+
): T {
|
|
8
|
+
return definitions;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function resolveFeatureChannel(env: {
|
|
12
|
+
DEV?: boolean;
|
|
13
|
+
VITE_TANO_CHANNEL?: string;
|
|
14
|
+
}): FeatureChannel {
|
|
15
|
+
return env.DEV === true || env.VITE_TANO_CHANNEL === 'dev' ? 'dev' : 'stable';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function createFeatureGate<T extends Record<string, FeatureDefinition>>(
|
|
19
|
+
definitions: T,
|
|
20
|
+
channel: FeatureChannel,
|
|
21
|
+
) {
|
|
22
|
+
return {
|
|
23
|
+
isEnabled(id: keyof T): boolean {
|
|
24
|
+
if (!Object.hasOwn(definitions, id)) throw new Error(`Unknown feature: ${String(id)}`);
|
|
25
|
+
return definitions[id].status === 'stable' || channel === 'dev';
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
package/src/file-core.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FileEntry, Workspace } from './
|
|
1
|
+
import type { FileEntry, Workspace } from './types';
|
|
2
2
|
import { isWorkspaceInternalPath } from './workspace-paths';
|
|
3
3
|
|
|
4
4
|
export type FilePreviewKind = 'markdown' | 'table' | 'image' | 'pdf' | 'office' | 'csv' | 'json' | 'code' | 'text' | 'audio' | 'video' | 'binary';
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './types';
|
|
1
2
|
export * from './references';
|
|
2
3
|
export * from './agent';
|
|
3
4
|
export * from './assistant';
|
|
@@ -16,170 +17,6 @@ export * from './data-tables';
|
|
|
16
17
|
export * from './workspace-contract';
|
|
17
18
|
export * from './file-core';
|
|
18
19
|
export * from './file-metadata';
|
|
19
|
-
|
|
20
|
-
export interface FileEntry {
|
|
21
|
-
id: string;
|
|
22
|
-
path: string;
|
|
23
|
-
name: string;
|
|
24
|
-
kind: 'file' | 'directory';
|
|
25
|
-
size: number;
|
|
26
|
-
modified: number;
|
|
27
|
-
/** Content hash supplied by the authority when available, never inferred from mtime. */
|
|
28
|
-
contentHash?: string;
|
|
29
|
-
readOnly?: boolean;
|
|
30
|
-
/** Local draft; the authority has not yet confirmed creation. */
|
|
31
|
-
pendingCreation?: boolean;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface Workspace {
|
|
35
|
-
id: string;
|
|
36
|
-
name: string;
|
|
37
|
-
path: string;
|
|
38
|
-
files: FileEntry[];
|
|
39
|
-
readOnly?: boolean;
|
|
40
|
-
/** Transient creation result; omitted on subsequent opens and refreshes. */
|
|
41
|
-
newlyCreated?: boolean;
|
|
42
|
-
/** Local metadata was deleted; this open initialized a new workspace identity. */
|
|
43
|
-
reinitialized?: boolean;
|
|
44
|
-
/** True only when the current user may delete this workspace. */
|
|
45
|
-
canDelete?: boolean;
|
|
46
|
-
/** Supplied by the authority owning workspace membership, never by portable files. */
|
|
47
|
-
canManagePlugins?: boolean;
|
|
48
|
-
/** Supplied by the authority; content editing alone does not grant settings access. */
|
|
49
|
-
canManageSettings?: boolean;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export class WorkspaceAccessRevokedError extends Error {
|
|
53
|
-
constructor() {
|
|
54
|
-
super('你已失去此工作区的访问权限');
|
|
55
|
-
this.name = 'WorkspaceAccessRevokedError';
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface FileSnapshot {
|
|
60
|
-
content: string;
|
|
61
|
-
hash: string;
|
|
62
|
-
modified: number;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export type WriteResult =
|
|
66
|
-
| { status: 'saved'; snapshot: FileSnapshot }
|
|
67
|
-
| { status: 'conflict'; snapshot: FileSnapshot }
|
|
68
|
-
| { status: 'missing' };
|
|
69
|
-
|
|
70
|
-
/** Compare identity and content at the filesystem boundary before moving/deleting a document. */
|
|
71
|
-
export interface FileChangeRequest {
|
|
72
|
-
workspaceId: string;
|
|
73
|
-
fileId: string;
|
|
74
|
-
path: string;
|
|
75
|
-
expectedHash: string;
|
|
76
|
-
/** Omitted for deletion. Saved returns the source snapshot, including for deletion. */
|
|
77
|
-
destination?: string;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export interface WorkspaceAdapter {
|
|
81
|
-
readonly mode: 'desktop' | 'demo' | 'web';
|
|
82
|
-
reserveObjectId?(occupied: string[]): Promise<string>;
|
|
83
|
-
/** Reserve an externally proposed, never-used object or table ID before exclusive creation. */
|
|
84
|
-
createAgentRecord?(path: string, content: string): Promise<void>;
|
|
85
|
-
/** Select a folder without opening it or changing the active workspace; null cancels. */
|
|
86
|
-
selectWorkspacePath?(): Promise<string | null>;
|
|
87
|
-
open(path?: string): Promise<Workspace | null>;
|
|
88
|
-
close?(workspaceId: string): Promise<void>;
|
|
89
|
-
createWorkspace?(name: string): Promise<Workspace>;
|
|
90
|
-
deleteWorkspace?(workspaceId: string): Promise<void>;
|
|
91
|
-
recent?(): Promise<RecentWorkspace[]>;
|
|
92
|
-
loadSession?(workspaceId: string): Promise<WorkspaceSession | null>;
|
|
93
|
-
saveSession?(workspaceId: string, session: WorkspaceSession): Promise<void>;
|
|
94
|
-
refresh(): Promise<Workspace>;
|
|
95
|
-
search?(workspaceId: string, query: string, signal?: AbortSignal): Promise<SearchHit[]>;
|
|
96
|
-
read(path: string): Promise<FileSnapshot>;
|
|
97
|
-
/** Optional version-checked, synchronous cache. Never returns speculative content. */
|
|
98
|
-
readCached?(path: string): FileSnapshot | undefined;
|
|
99
|
-
/** Best-effort read ahead; implementations bound speculative network work. */
|
|
100
|
-
prefetch?(path: string): Promise<void>;
|
|
101
|
-
write(path: string, content: string, expectedHash: string): Promise<WriteResult>;
|
|
102
|
-
/** May return the workspace including the confirmed creation to avoid a redundant refresh. */
|
|
103
|
-
create(path: string, content: string): Promise<void | Workspace>;
|
|
104
|
-
/** Persist a recoverable local draft without waiting for the remote authority. */
|
|
105
|
-
stageCreate?(path: string, content: string): Promise<{ workspace: Workspace; file: FileEntry }>;
|
|
106
|
-
/** Confirm the staged request, reusing its durable identity and idempotency key on retry. */
|
|
107
|
-
commitCreate?(id: string): Promise<{ file: FileEntry; snapshot: FileSnapshot }>;
|
|
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>;
|
|
111
|
-
rename(from: string, to: string): Promise<void>;
|
|
112
|
-
move(from: string, to: string, kind: FileEntry['kind']): Promise<void>;
|
|
113
|
-
duplicate?(workspaceId: string, path: string): Promise<string>;
|
|
114
|
-
remove(path: string): Promise<void>;
|
|
115
|
-
changeFile?(request: FileChangeRequest): Promise<WriteResult>;
|
|
116
|
-
/** Object-only compare-and-delete. Keeps the assistant file boundary unchanged. */
|
|
117
|
-
removeObjectFile?(request: FileChangeRequest): Promise<WriteResult>;
|
|
118
|
-
reveal(): Promise<void>;
|
|
119
|
-
watch(callback: () => void): Promise<() => void>;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export interface SearchHit {
|
|
123
|
-
id: string;
|
|
124
|
-
path: string;
|
|
125
|
-
excerpt: string;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export interface RecentWorkspace {
|
|
129
|
-
id: string;
|
|
130
|
-
name: string;
|
|
131
|
-
path: string;
|
|
132
|
-
openedAt: number;
|
|
133
|
-
/** Owner display label supplied by the storage adapter, when available. */
|
|
134
|
-
owner?: string;
|
|
135
|
-
/** Stable owner identity used by workspace dashboard filters. */
|
|
136
|
-
ownerUserId?: string;
|
|
137
|
-
/** Display identity for a cloud workspace owner, when the server provides it. */
|
|
138
|
-
ownerProfile?: { userId: string; name: string; avatar?: string };
|
|
139
|
-
/** Workspace creation time in milliseconds; absent for legacy workspaces. */
|
|
140
|
-
createdAt?: number | null;
|
|
141
|
-
/** Optional user selection state supplied by a storage adapter. */
|
|
142
|
-
favorite?: boolean;
|
|
143
|
-
/** Whether this workspace was explicitly shared with the current user. */
|
|
144
|
-
shared?: boolean;
|
|
145
|
-
icon?: string;
|
|
146
|
-
}
|
|
147
|
-
export interface SessionDocument {
|
|
148
|
-
id: string;
|
|
149
|
-
path: string;
|
|
150
|
-
draft?: { content: string; base: FileSnapshot };
|
|
151
|
-
}
|
|
152
|
-
export interface WorkspaceSession {
|
|
153
|
-
version: 1;
|
|
154
|
-
activeId: string;
|
|
155
|
-
documents: SessionDocument[];
|
|
156
|
-
tabs?: string[];
|
|
157
|
-
layout?: WorkspaceLayout;
|
|
158
|
-
dataTables?: {
|
|
159
|
-
id: string;
|
|
160
|
-
fileId?: string;
|
|
161
|
-
path?: string;
|
|
162
|
-
content: string;
|
|
163
|
-
base: FileSnapshot;
|
|
164
|
-
}[];
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export interface WorkspacePane {
|
|
168
|
-
kind: 'pane';
|
|
169
|
-
id: string;
|
|
170
|
-
tabs: string[];
|
|
171
|
-
activeId: string;
|
|
172
|
-
}
|
|
173
|
-
export interface WorkspaceSplit {
|
|
174
|
-
kind: 'split';
|
|
175
|
-
id: string;
|
|
176
|
-
axis: 'horizontal' | 'vertical';
|
|
177
|
-
ratio: number;
|
|
178
|
-
first: WorkspaceLayout;
|
|
179
|
-
second: WorkspaceLayout;
|
|
180
|
-
}
|
|
181
|
-
export type WorkspaceLayout = WorkspacePane | WorkspaceSplit;
|
|
182
|
-
|
|
183
20
|
export * from './paths';
|
|
184
21
|
export * from './plugin-catalog';
|
|
185
22
|
export * from './plugin-connections';
|
|
@@ -189,11 +26,8 @@ export * from './task-repeat';
|
|
|
189
26
|
export * from './file-database';
|
|
190
27
|
export * from './view-engine';
|
|
191
28
|
export * from './agent-gateway';
|
|
192
|
-
|
|
193
29
|
export * from './data-table-query';
|
|
194
|
-
|
|
195
30
|
export * from './structured-merge';
|
|
196
|
-
|
|
197
31
|
export * from './entry-drag';
|
|
198
|
-
|
|
199
32
|
export * from './appearance';
|
|
33
|
+
export * from './features';
|
package/src/objects.ts
CHANGED
package/src/types.ts
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
export interface FileEntry {
|
|
2
|
+
id: string;
|
|
3
|
+
path: string;
|
|
4
|
+
name: string;
|
|
5
|
+
kind: 'file' | 'directory';
|
|
6
|
+
size: number;
|
|
7
|
+
modified: number;
|
|
8
|
+
/** Content hash supplied by the authority when available, never inferred from mtime. */
|
|
9
|
+
contentHash?: string;
|
|
10
|
+
readOnly?: boolean;
|
|
11
|
+
/** Local draft; the authority has not yet confirmed creation. */
|
|
12
|
+
pendingCreation?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface Workspace {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
path: string;
|
|
19
|
+
files: FileEntry[];
|
|
20
|
+
readOnly?: boolean;
|
|
21
|
+
/** Transient creation result; omitted on subsequent opens and refreshes. */
|
|
22
|
+
newlyCreated?: boolean;
|
|
23
|
+
/** Local metadata was deleted; this open initialized a new workspace identity. */
|
|
24
|
+
reinitialized?: boolean;
|
|
25
|
+
/** True only when the current user may delete this workspace. */
|
|
26
|
+
canDelete?: boolean;
|
|
27
|
+
/** Supplied by the authority owning workspace membership, never by portable files. */
|
|
28
|
+
canManagePlugins?: boolean;
|
|
29
|
+
/** Supplied by the authority; content editing alone does not grant settings access. */
|
|
30
|
+
canManageSettings?: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export class WorkspaceAccessRevokedError extends Error {
|
|
34
|
+
constructor() {
|
|
35
|
+
super('你已失去此工作区的访问权限');
|
|
36
|
+
this.name = 'WorkspaceAccessRevokedError';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface FileSnapshot {
|
|
41
|
+
content: string;
|
|
42
|
+
hash: string;
|
|
43
|
+
modified: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type WriteResult =
|
|
47
|
+
| { status: 'saved'; snapshot: FileSnapshot }
|
|
48
|
+
| { status: 'conflict'; snapshot: FileSnapshot }
|
|
49
|
+
| { status: 'missing' };
|
|
50
|
+
|
|
51
|
+
/** Compare identity and content at the filesystem boundary before moving/deleting a document. */
|
|
52
|
+
export interface FileChangeRequest {
|
|
53
|
+
workspaceId: string;
|
|
54
|
+
fileId: string;
|
|
55
|
+
path: string;
|
|
56
|
+
expectedHash: string;
|
|
57
|
+
/** Omitted for deletion. Saved returns the source snapshot, including for deletion. */
|
|
58
|
+
destination?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface WorkspaceAdapter {
|
|
62
|
+
readonly mode: 'desktop' | 'demo' | 'web';
|
|
63
|
+
reserveObjectId?(occupied: string[]): Promise<string>;
|
|
64
|
+
/** Reserve an externally proposed, never-used object or table ID before exclusive creation. */
|
|
65
|
+
createAgentRecord?(path: string, content: string): Promise<void>;
|
|
66
|
+
/** Select a folder without opening it or changing the active workspace; null cancels. */
|
|
67
|
+
selectWorkspacePath?(): Promise<string | null>;
|
|
68
|
+
open(path?: string): Promise<Workspace | null>;
|
|
69
|
+
close?(workspaceId: string): Promise<void>;
|
|
70
|
+
createWorkspace?(name: string): Promise<Workspace>;
|
|
71
|
+
deleteWorkspace?(workspaceId: string): Promise<void>;
|
|
72
|
+
recent?(): Promise<RecentWorkspace[]>;
|
|
73
|
+
loadSession?(workspaceId: string): Promise<WorkspaceSession | null>;
|
|
74
|
+
saveSession?(workspaceId: string, session: WorkspaceSession): Promise<void>;
|
|
75
|
+
refresh(): Promise<Workspace>;
|
|
76
|
+
search?(workspaceId: string, query: string, signal?: AbortSignal): Promise<SearchHit[]>;
|
|
77
|
+
read(path: string): Promise<FileSnapshot>;
|
|
78
|
+
/** Optional version-checked, synchronous cache. Never returns speculative content. */
|
|
79
|
+
readCached?(path: string): FileSnapshot | undefined;
|
|
80
|
+
/** Best-effort read ahead; implementations bound speculative network work. */
|
|
81
|
+
prefetch?(path: string): Promise<void>;
|
|
82
|
+
write(path: string, content: string, expectedHash: string): Promise<WriteResult>;
|
|
83
|
+
/** May return the workspace including the confirmed creation to avoid a redundant refresh. */
|
|
84
|
+
create(path: string, content: string): Promise<void | Workspace>;
|
|
85
|
+
/** Persist a recoverable local draft without waiting for the remote authority. */
|
|
86
|
+
stageCreate?(path: string, content: string): Promise<{ workspace: Workspace; file: FileEntry }>;
|
|
87
|
+
/** Confirm the staged request, reusing its durable identity and idempotency key on retry. */
|
|
88
|
+
commitCreate?(id: string): Promise<{ file: FileEntry; snapshot: FileSnapshot }>;
|
|
89
|
+
createFolder(path: string): Promise<void>;
|
|
90
|
+
/** Must reject nonempty directories, including hidden/unindexed entries; never recurse. */
|
|
91
|
+
removeEmptyFolder?(workspaceId: string, path: string): Promise<void>;
|
|
92
|
+
rename(from: string, to: string): Promise<void>;
|
|
93
|
+
move(from: string, to: string, kind: FileEntry['kind']): Promise<void>;
|
|
94
|
+
duplicate?(workspaceId: string, path: string): Promise<string>;
|
|
95
|
+
remove(path: string): Promise<void>;
|
|
96
|
+
changeFile?(request: FileChangeRequest): Promise<WriteResult>;
|
|
97
|
+
/** Object-only compare-and-delete. Keeps the assistant file boundary unchanged. */
|
|
98
|
+
removeObjectFile?(request: FileChangeRequest): Promise<WriteResult>;
|
|
99
|
+
reveal(): Promise<void>;
|
|
100
|
+
watch(callback: () => void): Promise<() => void>;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface SearchHit {
|
|
104
|
+
id: string;
|
|
105
|
+
path: string;
|
|
106
|
+
excerpt: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface RecentWorkspace {
|
|
110
|
+
id: string;
|
|
111
|
+
name: string;
|
|
112
|
+
path: string;
|
|
113
|
+
openedAt: number;
|
|
114
|
+
/** Owner display label supplied by the storage adapter, when available. */
|
|
115
|
+
owner?: string;
|
|
116
|
+
/** Stable owner identity used by workspace dashboard filters. */
|
|
117
|
+
ownerUserId?: string;
|
|
118
|
+
/** Display identity for a cloud workspace owner, when the server provides it. */
|
|
119
|
+
ownerProfile?: { userId: string; name: string; avatar?: string };
|
|
120
|
+
/** Workspace creation time in milliseconds; absent for legacy workspaces. */
|
|
121
|
+
createdAt?: number | null;
|
|
122
|
+
/** Optional user selection state supplied by a storage adapter. */
|
|
123
|
+
favorite?: boolean;
|
|
124
|
+
/** Whether this workspace was explicitly shared with the current user. */
|
|
125
|
+
shared?: boolean;
|
|
126
|
+
icon?: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface SessionDocument {
|
|
130
|
+
id: string;
|
|
131
|
+
path: string;
|
|
132
|
+
draft?: { content: string; base: FileSnapshot };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface WorkspaceSession {
|
|
136
|
+
version: 1;
|
|
137
|
+
activeId: string;
|
|
138
|
+
documents: SessionDocument[];
|
|
139
|
+
tabs?: string[];
|
|
140
|
+
layout?: WorkspaceLayout;
|
|
141
|
+
dataTables?: {
|
|
142
|
+
id: string;
|
|
143
|
+
fileId?: string;
|
|
144
|
+
path?: string;
|
|
145
|
+
content: string;
|
|
146
|
+
base: FileSnapshot;
|
|
147
|
+
}[];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface WorkspacePane {
|
|
151
|
+
kind: 'pane';
|
|
152
|
+
id: string;
|
|
153
|
+
tabs: string[];
|
|
154
|
+
activeId: string;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface WorkspaceSplit {
|
|
158
|
+
kind: 'split';
|
|
159
|
+
id: string;
|
|
160
|
+
axis: 'horizontal' | 'vertical';
|
|
161
|
+
ratio: number;
|
|
162
|
+
first: WorkspaceLayout;
|
|
163
|
+
second: WorkspaceLayout;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export type WorkspaceLayout = WorkspacePane | WorkspaceSplit;
|
package/src/view-engine.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReferenceIdentity, WorkspaceObject } from './objects';
|
|
2
|
+
import type { WorkspaceRelation } from './relations';
|
|
2
3
|
import { validObjectType } from './object-types';
|
|
3
4
|
import { referenceKey } from './relations';
|
|
4
5
|
|