mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-11 14:08:55 +08:00
feat(server): improve context management (#15448)
#### PR Dependency Tree * **PR #15448** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added workspace artifact upload, browsing, removal, deduplication, and library ownership support. * Copilot now supports scoped document and artifact search, canvas reading, live editor context, and frontend tools. * Added scope and focus selectors with source-resolution receipts in chat. * Added embedding health, progress, synchronization, and retrieval capabilities. * Added BYOK policy visibility, provider restrictions, endpoint dialect selection, and validation. * Added delegated editor interactions and userdata document authorization. * **Bug Fixes** * Improved attachment handling, cancellation, access control, retrieval fallbacks, workspace synchronization, and configuration validation. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -4,6 +4,18 @@ export type RealtimeTopicName = keyof RealtimeTopicMap;
|
||||
export const WORKSPACE_MEMBERS_REQUEST_TAKE_MAX = 100;
|
||||
|
||||
export interface RealtimeRequestMap {
|
||||
'copilot.delegated.editor.upsert': {
|
||||
input: DelegatedEditorLeaseInput;
|
||||
output: { ok: true; expiresAt: number };
|
||||
};
|
||||
'copilot.delegated.editor.release': {
|
||||
input: { clientId: string; editorStateId: string };
|
||||
output: { ok: true };
|
||||
};
|
||||
'copilot.delegated.tool.respond': {
|
||||
input: DelegatedToolResponse;
|
||||
output: { accepted: boolean };
|
||||
};
|
||||
'workspace.access.get': {
|
||||
input: { workspaceId: string };
|
||||
output: { access: WorkspaceAccessSnapshot };
|
||||
@@ -242,6 +254,10 @@ export type WorkspaceEmbeddingProgressReason =
|
||||
| 'resync';
|
||||
|
||||
export interface RealtimeTopicMap {
|
||||
'copilot.delegated.tool.requested': {
|
||||
input: { clientId: string };
|
||||
event: DelegatedToolRequest | DelegatedToolCancel;
|
||||
};
|
||||
'workspace.access.changed': {
|
||||
input: { workspaceId: string };
|
||||
event: { changed: true; reason: string };
|
||||
@@ -320,6 +336,56 @@ export interface RealtimeTopicMap {
|
||||
};
|
||||
}
|
||||
|
||||
export type DelegatedToolName =
|
||||
| 'frontend_get_editor_state'
|
||||
| 'frontend_read_selection'
|
||||
| 'frontend_read_nodes'
|
||||
| 'frontend_snapshot_document';
|
||||
|
||||
export interface DelegatedEditorLeaseInput {
|
||||
clientId: string;
|
||||
sessionId: string;
|
||||
workspaceId: string;
|
||||
docId: string;
|
||||
editorStateId: string;
|
||||
mode: 'page' | 'edgeless';
|
||||
readonly: boolean;
|
||||
focused: boolean;
|
||||
capabilities: DelegatedToolName[];
|
||||
}
|
||||
|
||||
export interface DelegatedToolIdentity {
|
||||
requestId: string;
|
||||
runId: string;
|
||||
toolCallId: string;
|
||||
sessionId: string;
|
||||
workspaceId: string;
|
||||
docId: string;
|
||||
clientId: string;
|
||||
editorStateId: string;
|
||||
}
|
||||
|
||||
export interface DelegatedToolRequest extends DelegatedToolIdentity {
|
||||
type: 'request';
|
||||
tool: DelegatedToolName;
|
||||
args: Record<string, unknown>;
|
||||
deadlineAt: number;
|
||||
}
|
||||
|
||||
export interface DelegatedToolCancel extends DelegatedToolIdentity {
|
||||
type: 'cancel';
|
||||
reason: 'aborted' | 'timeout' | 'disconnect';
|
||||
}
|
||||
|
||||
export interface DelegatedToolResponse extends DelegatedToolIdentity {
|
||||
result?: unknown;
|
||||
error?: {
|
||||
code: string;
|
||||
message: string;
|
||||
retryable: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export type RealtimeRequestInputOf<Op extends RealtimeRequestName> =
|
||||
RealtimeRequestMap[Op]['input'];
|
||||
export type RealtimeRequestOutputOf<Op extends RealtimeRequestName> =
|
||||
|
||||
Reference in New Issue
Block a user