@xpert-ai/plugin-sdk 3.15.9 → 3.15.11
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/CHANGELOG.md +16 -0
- package/README.md +15 -0
- package/collaboration-client.cjs.default.js +1 -0
- package/collaboration-client.cjs.js +12 -0
- package/collaboration-client.cjs.mjs +2 -0
- package/collaboration-client.cjs2.js +406 -0
- package/collaboration-client.d.ts +1 -0
- package/collaboration-client.esm.js +1 -0
- package/collaboration-client.esm2.js +398 -0
- package/index.cjs.default.js +1 -0
- package/index.cjs.js +44 -20
- package/index.cjs.mjs +2 -0
- package/index.esm.js +27 -12
- package/package.json +17 -2
- package/src/collaboration-client.d.ts +3 -0
- package/src/index.d.ts +1 -0
- package/src/lib/agent/middleware/capabilities/assistant-task.d.ts +1 -0
- package/src/lib/collaboration/client.d.ts +118 -0
- package/src/lib/collaboration/index.d.ts +5 -0
- package/src/lib/collaboration/provider.decorator.d.ts +3 -0
- package/src/lib/collaboration/provider.registry.d.ts +7 -0
- package/src/lib/collaboration/runtime-capability.d.ts +3 -0
- package/src/lib/collaboration/types.d.ts +190 -0
- package/src/lib/runtime/capabilities/artifacts.d.ts +163 -0
- package/src/lib/runtime/capabilities/index.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpert-ai/plugin-sdk",
|
|
3
|
-
"version": "3.15.
|
|
3
|
+
"version": "3.15.11",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@langchain/openai": "0.6.9",
|
|
20
|
-
"@xpert-ai/contracts": "3.15.
|
|
20
|
+
"@xpert-ai/contracts": "3.15.11",
|
|
21
21
|
"express": "^4.22.1",
|
|
22
22
|
"js-tiktoken": "^1.0.21"
|
|
23
23
|
},
|
|
@@ -38,5 +38,20 @@
|
|
|
38
38
|
"yaml": "*",
|
|
39
39
|
"zod": "*"
|
|
40
40
|
},
|
|
41
|
+
"exports": {
|
|
42
|
+
"./package.json": "./package.json",
|
|
43
|
+
".": {
|
|
44
|
+
"module": "./index.esm.js",
|
|
45
|
+
"types": "./index.d.ts",
|
|
46
|
+
"import": "./index.cjs.mjs",
|
|
47
|
+
"default": "./index.cjs.js"
|
|
48
|
+
},
|
|
49
|
+
"./collaboration-client": {
|
|
50
|
+
"module": "./collaboration-client.esm.js",
|
|
51
|
+
"types": "./collaboration-client.d.ts",
|
|
52
|
+
"import": "./collaboration-client.cjs.mjs",
|
|
53
|
+
"default": "./collaboration-client.cjs.js"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
41
56
|
"types": "./index.d.ts"
|
|
42
57
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { ApplyCollaborationUpdateResult, CollaborationPresencePatch, CollaborationSessionDescriptor, ICollaborationActor, ICollaborationPresence } from './types';
|
|
2
|
+
export type CollaborationTransportPayload = Record<string, unknown>;
|
|
3
|
+
export type CollaborationTransportHandler = (payload: CollaborationTransportPayload) => void;
|
|
4
|
+
/** Framework-neutral event transport used by the collaboration client. */
|
|
5
|
+
export interface CollaborationTransport {
|
|
6
|
+
readonly connected: boolean;
|
|
7
|
+
/** Socket/session identifier for this exact browser client, when the transport exposes one. */
|
|
8
|
+
readonly clientId?: string | null;
|
|
9
|
+
connect(): void;
|
|
10
|
+
disconnect(): void;
|
|
11
|
+
emit(event: string, payload?: CollaborationTransportPayload): void;
|
|
12
|
+
on(event: string, handler: CollaborationTransportHandler): () => void;
|
|
13
|
+
}
|
|
14
|
+
/** Minimal Socket.IO-compatible shape; keeps socket.io-client out of the SDK bundle. */
|
|
15
|
+
export interface CollaborationSocketLike {
|
|
16
|
+
readonly connected: boolean;
|
|
17
|
+
readonly id?: string;
|
|
18
|
+
connect(): unknown;
|
|
19
|
+
disconnect(): unknown;
|
|
20
|
+
emit(event: string, payload?: CollaborationTransportPayload): unknown;
|
|
21
|
+
on(event: string, handler: CollaborationTransportHandler): unknown;
|
|
22
|
+
off(event: string, handler: CollaborationTransportHandler): unknown;
|
|
23
|
+
}
|
|
24
|
+
/** Adapt a caller-owned Socket.IO client to the SDK's framework-neutral transport. */
|
|
25
|
+
export declare function createSocketIoTransportAdapter(socket: CollaborationSocketLike): CollaborationTransport;
|
|
26
|
+
export type CollaborationDocumentUpdateHandler = (update: Uint8Array, origin: unknown) => void;
|
|
27
|
+
/** Binary CRDT operations required by the generic collaboration client. */
|
|
28
|
+
export interface CollaborationBinaryDocumentAdapter {
|
|
29
|
+
applyUpdate(update: Uint8Array, origin: unknown): void;
|
|
30
|
+
encodeStateVector(): Uint8Array;
|
|
31
|
+
mergeUpdates(updates: Uint8Array[]): Uint8Array;
|
|
32
|
+
onUpdate(handler: CollaborationDocumentUpdateHandler): () => void;
|
|
33
|
+
}
|
|
34
|
+
/** Minimal observable Yjs document surface accepted by `createYjsDocumentAdapter`. */
|
|
35
|
+
export interface YjsDocumentLike {
|
|
36
|
+
on(event: 'update', handler: CollaborationDocumentUpdateHandler): void;
|
|
37
|
+
off(event: 'update', handler: CollaborationDocumentUpdateHandler): void;
|
|
38
|
+
}
|
|
39
|
+
/** Caller-supplied Yjs functions, avoiding a second Yjs runtime in plugin bundles. */
|
|
40
|
+
export interface YjsApiLike<TDocument extends YjsDocumentLike> {
|
|
41
|
+
applyUpdate(document: TDocument, update: Uint8Array, origin?: unknown): void;
|
|
42
|
+
encodeStateVector(document: TDocument): Uint8Array;
|
|
43
|
+
mergeUpdates(updates: Uint8Array[]): Uint8Array;
|
|
44
|
+
}
|
|
45
|
+
/** Wrap a caller-owned `Y.Doc` without passing it across the runtime capability boundary. */
|
|
46
|
+
export declare function createYjsDocumentAdapter<TDocument extends YjsDocumentLike>(document: TDocument, yjs: YjsApiLike<TDocument>): CollaborationBinaryDocumentAdapter;
|
|
47
|
+
/** Timings, callbacks, transport, and document adapter used by a browser client. */
|
|
48
|
+
export type CollaborationClientOptions = {
|
|
49
|
+
session: CollaborationSessionDescriptor;
|
|
50
|
+
transport: CollaborationTransport;
|
|
51
|
+
document: CollaborationBinaryDocumentAdapter;
|
|
52
|
+
initialPresence?: CollaborationPresencePatch;
|
|
53
|
+
batchMs?: number;
|
|
54
|
+
syncIntervalMs?: number;
|
|
55
|
+
presenceHeartbeatMs?: number;
|
|
56
|
+
/** Remove a presence locally when no refresh has been received within this interval. */
|
|
57
|
+
presenceStaleMs?: number;
|
|
58
|
+
onAck?: (ack: ApplyCollaborationUpdateResult) => void;
|
|
59
|
+
onPresence?: (presence: ICollaborationPresence) => void;
|
|
60
|
+
onPresenceSnapshot?: (items: ICollaborationPresence[], metadata: CollaborationPresenceSnapshotMetadata) => void;
|
|
61
|
+
onPresenceRemove?: (clientId: string) => void;
|
|
62
|
+
onConnectionChange?: (state: 'connecting' | 'connected' | 'disconnected') => void;
|
|
63
|
+
onError?: (error: Error) => void;
|
|
64
|
+
};
|
|
65
|
+
/** Lifecycle and presence controls returned by `createCollaborationClient`. */
|
|
66
|
+
export interface CollaborationClient {
|
|
67
|
+
/** Stable origin applied to remote updates so local observers can prevent echo loops. */
|
|
68
|
+
readonly remoteOrigin: object;
|
|
69
|
+
/** Socket id for this exact tab/device; distinct from the stable actor `presenceId`. */
|
|
70
|
+
readonly selfClientId: string | null;
|
|
71
|
+
connect(): void;
|
|
72
|
+
disconnect(): void;
|
|
73
|
+
flush(): void;
|
|
74
|
+
requestSync(): void;
|
|
75
|
+
setPresence(patch: CollaborationPresencePatch): void;
|
|
76
|
+
}
|
|
77
|
+
/** Connection-specific metadata delivered with a presence snapshot. */
|
|
78
|
+
export type CollaborationPresenceSnapshotMetadata = {
|
|
79
|
+
selfClientId: string | null;
|
|
80
|
+
};
|
|
81
|
+
/** Stable, framework-neutral view of active collaboration sessions and deduplicated actors. */
|
|
82
|
+
export type CollaborationPresenceStoreSnapshot = {
|
|
83
|
+
selfClientId: string | null;
|
|
84
|
+
/** Every active browser/Agent session keyed by `clientId`. */
|
|
85
|
+
sessions: ICollaborationPresence[];
|
|
86
|
+
/** Sessions excluding only this exact browser client. */
|
|
87
|
+
remoteSessions: ICollaborationPresence[];
|
|
88
|
+
/** One entry per actor identity, including the local actor when supplied. */
|
|
89
|
+
collaborators: ICollaborationPresence[];
|
|
90
|
+
};
|
|
91
|
+
export type CollaborationPresenceStoreOptions = {
|
|
92
|
+
selfActor?: ICollaborationActor | null;
|
|
93
|
+
includeSelf?: boolean;
|
|
94
|
+
onChange?: (snapshot: CollaborationPresenceStoreSnapshot) => void;
|
|
95
|
+
};
|
|
96
|
+
/** Mutable presence projection used by plugin UIs without coupling them to a framework. */
|
|
97
|
+
export interface CollaborationPresenceStore {
|
|
98
|
+
setSelfClientId(clientId: string | null): void;
|
|
99
|
+
replace(items: ICollaborationPresence[], selfClientId?: string | null): void;
|
|
100
|
+
upsert(item: ICollaborationPresence): void;
|
|
101
|
+
remove(clientId: string): void;
|
|
102
|
+
clear(): void;
|
|
103
|
+
snapshot(): CollaborationPresenceStoreSnapshot;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Keep per-client sessions for cursors while exposing one collaborator per stable actor identity.
|
|
107
|
+
* This prevents a second tab owned by the same user from either duplicating or hiding that user.
|
|
108
|
+
*/
|
|
109
|
+
export declare function createCollaborationPresenceStore(options?: CollaborationPresenceStoreOptions): CollaborationPresenceStore;
|
|
110
|
+
/**
|
|
111
|
+
* Create a collaboration client with update batching, state-vector repair, presence heartbeat,
|
|
112
|
+
* and reconnect synchronization. The caller retains ownership of the document and transport.
|
|
113
|
+
*/
|
|
114
|
+
export declare function createCollaborationClient(options: CollaborationClientOptions): CollaborationClient;
|
|
115
|
+
/** Encode bytes in browsers without Node.js `Buffer`; chunks avoid argument-size limits. */
|
|
116
|
+
export declare function bytesToBase64(bytes: Uint8Array): string;
|
|
117
|
+
/** Decode base64 in browsers without requiring Node.js polyfills. */
|
|
118
|
+
export declare function base64ToBytes(value: string): Uint8Array;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const COLLABORATION_DOCUMENT_PROVIDER = "COLLABORATION_DOCUMENT_PROVIDER";
|
|
2
|
+
/** Register a plugin adapter for one stable collaboration resource type. */
|
|
3
|
+
export declare const CollaborationDocumentProvider: (providerKey: string) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
2
|
+
import { BaseStrategyRegistry } from '../strategy';
|
|
3
|
+
import type { ICollaborationDocumentProvider } from './types';
|
|
4
|
+
/** Discovers system and organization-scoped collaboration providers from loaded plugins. */
|
|
5
|
+
export declare class CollaborationDocumentProviderRegistry extends BaseStrategyRegistry<ICollaborationDocumentProvider> {
|
|
6
|
+
constructor(discoveryService: DiscoveryService, reflector: Reflector);
|
|
7
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { CollaborationApi } from './types';
|
|
2
|
+
/** Platform-owned real-time collaboration capability available to scoped plugin runtimes. */
|
|
3
|
+
export declare const CollaborationRuntimeCapability: import("../core/runtime-capability").RuntimeCapabilityKey<CollaborationApi>;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import type { CollaborationAccess, CollaborationActorStatus, CollaborationActorType, CollaborationDocumentStatus, CollaborationEngine, CollaborationMaterializationStatus, ICollaborationActor, ICollaborationFocus, ICollaborationPointer, ICollaborationPresence, ICollaborationSelection, ICollaborationViewport } from '@xpert-ai/contracts';
|
|
2
|
+
export type { CollaborationAccess, CollaborationActorStatus, CollaborationActorType, CollaborationDocumentStatus, CollaborationEngine, CollaborationMaterializationStatus, ICollaborationActor, ICollaborationFocus, ICollaborationPointer, ICollaborationPresence, ICollaborationSelection, ICollaborationViewport } from '@xpert-ai/contracts';
|
|
3
|
+
/** Tenant and business scope inherited by every collaboration operation. */
|
|
4
|
+
export type CollaborationScope = {
|
|
5
|
+
tenantId?: string | null;
|
|
6
|
+
organizationId?: string | null;
|
|
7
|
+
workspaceId?: string | null;
|
|
8
|
+
projectId?: string | null;
|
|
9
|
+
xpertId?: string | null;
|
|
10
|
+
userId?: string | null;
|
|
11
|
+
};
|
|
12
|
+
/** Optional identity override for Agent or system initiated runtime calls. */
|
|
13
|
+
export type CollaborationRuntimeActor = {
|
|
14
|
+
actorType?: CollaborationActorType | null;
|
|
15
|
+
actorKey?: string | null;
|
|
16
|
+
displayName?: string | null;
|
|
17
|
+
avatarUrl?: string | null;
|
|
18
|
+
};
|
|
19
|
+
/** Metadata-only representation of the platform collaboration document. */
|
|
20
|
+
export type CollaborationDocumentRecord = CollaborationScope & {
|
|
21
|
+
id: string;
|
|
22
|
+
providerKey: string;
|
|
23
|
+
resourceId: string;
|
|
24
|
+
engine: CollaborationEngine;
|
|
25
|
+
schemaVersion: number;
|
|
26
|
+
status: CollaborationDocumentStatus;
|
|
27
|
+
sequenceNumber: number;
|
|
28
|
+
updateCount: number;
|
|
29
|
+
materializedSequence: number;
|
|
30
|
+
materializationStatus: CollaborationMaterializationStatus;
|
|
31
|
+
lastMaterializationError?: string | null;
|
|
32
|
+
metadata?: Record<string, unknown> | null;
|
|
33
|
+
createdAt?: string | Date;
|
|
34
|
+
updatedAt?: string | Date;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* A full or state-vector-relative Yjs update together with its document metadata.
|
|
38
|
+
* `updateBase64` is safe to apply to a client whose vector was supplied in the request.
|
|
39
|
+
*/
|
|
40
|
+
export type CollaborationDocumentState = {
|
|
41
|
+
document: CollaborationDocumentRecord;
|
|
42
|
+
updateBase64: string;
|
|
43
|
+
stateVectorBase64: string;
|
|
44
|
+
sequenceNumber: number;
|
|
45
|
+
};
|
|
46
|
+
/** Creates the platform document lazily through the registered plugin provider. */
|
|
47
|
+
export type EnsureCollaborationDocumentInput = {
|
|
48
|
+
providerKey: string;
|
|
49
|
+
resourceId: string;
|
|
50
|
+
schemaVersion?: number | null;
|
|
51
|
+
metadata?: Record<string, unknown> | null;
|
|
52
|
+
};
|
|
53
|
+
/** Locate a document either by platform id or by the provider's business resource key. */
|
|
54
|
+
export type GetCollaborationDocumentInput = {
|
|
55
|
+
documentId: string;
|
|
56
|
+
providerKey?: never;
|
|
57
|
+
resourceId?: never;
|
|
58
|
+
} | {
|
|
59
|
+
documentId?: never;
|
|
60
|
+
providerKey: string;
|
|
61
|
+
resourceId: string;
|
|
62
|
+
};
|
|
63
|
+
export type GetCollaborationDocumentStateInput = GetCollaborationDocumentInput & {
|
|
64
|
+
/** Omit for complete state; provide a Yjs state vector to receive only the missing delta. */
|
|
65
|
+
stateVectorBase64?: string | null;
|
|
66
|
+
};
|
|
67
|
+
/** Submit one Yjs update to the authoritative platform document. */
|
|
68
|
+
export type ApplyCollaborationUpdateInput = {
|
|
69
|
+
documentId: string;
|
|
70
|
+
updateBase64: string;
|
|
71
|
+
origin?: string | null;
|
|
72
|
+
/** Optional compare-and-set guard for destructive or order-sensitive operations. */
|
|
73
|
+
expectedSequence?: number | null;
|
|
74
|
+
actor?: CollaborationRuntimeActor | null;
|
|
75
|
+
};
|
|
76
|
+
/** Acknowledgement for a unique or deduplicated collaboration update. */
|
|
77
|
+
export type ApplyCollaborationUpdateResult = {
|
|
78
|
+
documentId: string;
|
|
79
|
+
duplicate: boolean;
|
|
80
|
+
sequenceNumber: number;
|
|
81
|
+
updateId?: string | null;
|
|
82
|
+
stateVectorBase64: string;
|
|
83
|
+
materializationStatus: CollaborationMaterializationStatus;
|
|
84
|
+
};
|
|
85
|
+
/** Request a short-lived browser session with no platform token exposure. */
|
|
86
|
+
export type CreateCollaborationSessionInput = {
|
|
87
|
+
documentId: string;
|
|
88
|
+
access?: Exclude<CollaborationAccess, 'manage'> | null;
|
|
89
|
+
};
|
|
90
|
+
/** Credentials and backend URL required by a browser transport. */
|
|
91
|
+
export type CollaborationSessionDescriptor = {
|
|
92
|
+
sessionId: string;
|
|
93
|
+
clientKey: string;
|
|
94
|
+
documentId: string;
|
|
95
|
+
namespace: string;
|
|
96
|
+
/** Backend public base URL; clients must not derive this from `window.location`. */
|
|
97
|
+
connectionUrl: string;
|
|
98
|
+
access: Exclude<CollaborationAccess, 'manage'>;
|
|
99
|
+
actor: ICollaborationActor;
|
|
100
|
+
expiresAt: number;
|
|
101
|
+
};
|
|
102
|
+
/** Bounded, ephemeral state that may be broadcast without persisting document content. */
|
|
103
|
+
export type CollaborationPresencePatch = {
|
|
104
|
+
pageId?: string | null;
|
|
105
|
+
pointer?: ICollaborationPointer | null;
|
|
106
|
+
focus?: ICollaborationFocus | null;
|
|
107
|
+
selection?: ICollaborationSelection | null;
|
|
108
|
+
viewport?: ICollaborationViewport | null;
|
|
109
|
+
mode?: string | null;
|
|
110
|
+
status?: CollaborationActorStatus | null;
|
|
111
|
+
toolName?: string | null;
|
|
112
|
+
operationLabel?: string | null;
|
|
113
|
+
};
|
|
114
|
+
/** Create or refresh an Agent/system presence without opening a WebSocket connection. */
|
|
115
|
+
export type UpsertVirtualPresenceInput = {
|
|
116
|
+
documentId: string;
|
|
117
|
+
actor?: CollaborationRuntimeActor | null;
|
|
118
|
+
presence: CollaborationPresencePatch;
|
|
119
|
+
};
|
|
120
|
+
/** Remove a virtual presence explicitly; otherwise it disappears through TTL expiry. */
|
|
121
|
+
export type RemoveVirtualPresenceInput = {
|
|
122
|
+
documentId: string;
|
|
123
|
+
presenceId?: string | null;
|
|
124
|
+
actorKey?: string | null;
|
|
125
|
+
};
|
|
126
|
+
/** Runtime capability exposed to scoped plugin and Agent executions. */
|
|
127
|
+
export interface CollaborationApi {
|
|
128
|
+
/** Ensure a provider/resource pair has one platform collaboration document. */
|
|
129
|
+
ensureDocument(input: EnsureCollaborationDocumentInput): Promise<CollaborationDocumentRecord>;
|
|
130
|
+
/** Read document metadata and trigger materialization read repair when required. */
|
|
131
|
+
getDocument(input: GetCollaborationDocumentInput): Promise<CollaborationDocumentRecord>;
|
|
132
|
+
/** Read complete state or a state-vector-relative Yjs delta. */
|
|
133
|
+
getDocumentState(input: GetCollaborationDocumentStateInput): Promise<CollaborationDocumentState>;
|
|
134
|
+
/** Authorize, deduplicate, merge, persist, broadcast, and materialize an update. */
|
|
135
|
+
applyUpdate(input: ApplyCollaborationUpdateInput): Promise<ApplyCollaborationUpdateResult>;
|
|
136
|
+
/** Issue single-document browser credentials with read or write access. */
|
|
137
|
+
createSession(input: CreateCollaborationSessionInput): Promise<CollaborationSessionDescriptor>;
|
|
138
|
+
/** List currently active user and virtual collaborator presence. */
|
|
139
|
+
listPresence(input: {
|
|
140
|
+
documentId: string;
|
|
141
|
+
}): Promise<ICollaborationPresence[]>;
|
|
142
|
+
/** Publish or refresh an Agent/system collaborator. */
|
|
143
|
+
upsertVirtualPresence(input: UpsertVirtualPresenceInput): Promise<ICollaborationPresence | null>;
|
|
144
|
+
/** Remove an Agent/system collaborator before its TTL expires. */
|
|
145
|
+
removeVirtualPresence(input: RemoveVirtualPresenceInput): Promise<void>;
|
|
146
|
+
/** Stop normal editing while retaining the document. */
|
|
147
|
+
archiveDocument(input: GetCollaborationDocumentInput): Promise<CollaborationDocumentRecord>;
|
|
148
|
+
/** Soft-delete the platform document and notify its provider. */
|
|
149
|
+
deleteDocument(input: GetCollaborationDocumentInput): Promise<CollaborationDocumentRecord>;
|
|
150
|
+
}
|
|
151
|
+
export type CollaborationProviderOperation = CollaborationAccess | 'initialize' | 'materialize' | 'delete';
|
|
152
|
+
/** Context passed to a plugin provider for every authorization and lifecycle operation. */
|
|
153
|
+
export type CollaborationProviderContext = CollaborationScope & {
|
|
154
|
+
documentId?: string | null;
|
|
155
|
+
providerKey: string;
|
|
156
|
+
resourceId: string;
|
|
157
|
+
operation: CollaborationProviderOperation;
|
|
158
|
+
actor?: ICollaborationActor | null;
|
|
159
|
+
};
|
|
160
|
+
/** Initial Yjs snapshot returned when the platform first sees a business resource. */
|
|
161
|
+
export type CollaborationDocumentInitialization = {
|
|
162
|
+
stateBase64: string;
|
|
163
|
+
schemaVersion: number;
|
|
164
|
+
/** Preserve an existing plugin revision when migrating legacy collaborative data. */
|
|
165
|
+
initialSequence?: number | null;
|
|
166
|
+
metadata?: Record<string, unknown> | null;
|
|
167
|
+
};
|
|
168
|
+
/** Authoritative state delivered to the plugin after an accepted update or read repair. */
|
|
169
|
+
export type CollaborationMaterializationEvent = CollaborationProviderContext & {
|
|
170
|
+
documentId: string;
|
|
171
|
+
stateBase64: string;
|
|
172
|
+
stateVectorBase64: string;
|
|
173
|
+
sequenceNumber: number;
|
|
174
|
+
updateBase64?: string | null;
|
|
175
|
+
origin?: string | null;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Plugin-owned adapter between a business resource and the platform collaboration engine.
|
|
179
|
+
* Authorization remains the plugin's responsibility; the platform owns transport and CRDT state.
|
|
180
|
+
*/
|
|
181
|
+
export interface ICollaborationDocumentProvider {
|
|
182
|
+
/** Authorize the exact resource and requested operation in the supplied platform scope. */
|
|
183
|
+
authorize(context: CollaborationProviderContext): Promise<boolean> | boolean;
|
|
184
|
+
/** Return an idempotent initial snapshot without creating a business version. */
|
|
185
|
+
initializeDocument(context: CollaborationProviderContext): Promise<CollaborationDocumentInitialization> | CollaborationDocumentInitialization;
|
|
186
|
+
/** Project platform state into plugin query/export entities. The method must be idempotent. */
|
|
187
|
+
materializeDocument(event: CollaborationMaterializationEvent): Promise<void> | void;
|
|
188
|
+
/** Optionally clean plugin-owned associations after a platform soft delete. */
|
|
189
|
+
onDocumentDeleted?(context: CollaborationProviderContext): Promise<void> | void;
|
|
190
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import type { ArtifactAccessMode, ArtifactKind, ArtifactLinkDisposition, ArtifactLinkStatus, ArtifactLinkVersionMode, ArtifactSafeHtmlProfile, ArtifactStatus, ArtifactVersionStatus } from '@xpert-ai/contracts';
|
|
2
|
+
import type { WorkspacePortableFileReference } from './workspace-files';
|
|
3
|
+
export type { ArtifactAccessMode, ArtifactKind, ArtifactLinkDisposition, ArtifactLinkStatus, ArtifactLinkVersionMode, ArtifactSafeHtmlProfile, ArtifactStatus, ArtifactVersionStatus } from '@xpert-ai/contracts';
|
|
4
|
+
/** Scope fields used when an Artifact belongs to a user/workspace/project/Xpert context. */
|
|
5
|
+
export type ArtifactScopeInput = {
|
|
6
|
+
tenantId?: string | null;
|
|
7
|
+
organizationId?: string | null;
|
|
8
|
+
userId?: string | null;
|
|
9
|
+
workspaceId?: string | null;
|
|
10
|
+
projectId?: string | null;
|
|
11
|
+
xpertId?: string | null;
|
|
12
|
+
};
|
|
13
|
+
/** Stable plugin-owned business identity for an Artifact container. */
|
|
14
|
+
export type ArtifactSourceInput = {
|
|
15
|
+
pluginName: string;
|
|
16
|
+
resourceType: string;
|
|
17
|
+
resourceId: string;
|
|
18
|
+
checksum?: string | null;
|
|
19
|
+
};
|
|
20
|
+
/** Creates or locates an Artifact container without uploading content bytes. */
|
|
21
|
+
export type CreateArtifactInput = {
|
|
22
|
+
source: ArtifactSourceInput;
|
|
23
|
+
kind?: ArtifactKind | null;
|
|
24
|
+
title?: string | null;
|
|
25
|
+
description?: string | null;
|
|
26
|
+
scope?: ArtifactScopeInput | null;
|
|
27
|
+
metadata?: Record<string, unknown> | null;
|
|
28
|
+
};
|
|
29
|
+
/** Immutable content payload metadata for a new Artifact version. */
|
|
30
|
+
export type ArtifactVersionInput = {
|
|
31
|
+
workspaceFileRef: WorkspacePortableFileReference;
|
|
32
|
+
mimeType: string;
|
|
33
|
+
fileName?: string | null;
|
|
34
|
+
title?: string | null;
|
|
35
|
+
description?: string | null;
|
|
36
|
+
size?: number | null;
|
|
37
|
+
sha256?: string | null;
|
|
38
|
+
sourceVersionId?: string | null;
|
|
39
|
+
checksum?: string | null;
|
|
40
|
+
setCurrent?: boolean | null;
|
|
41
|
+
metadata?: Record<string, unknown> | null;
|
|
42
|
+
};
|
|
43
|
+
export type CreateArtifactVersionInput = ArtifactVersionInput & {
|
|
44
|
+
artifactId: string;
|
|
45
|
+
};
|
|
46
|
+
/** Access policy requested for an Artifact link. */
|
|
47
|
+
export type ArtifactLinkAccessInput = {
|
|
48
|
+
mode: ArtifactAccessMode;
|
|
49
|
+
customPrincipals?: string[] | null;
|
|
50
|
+
expiresAt?: string | Date | null;
|
|
51
|
+
ttlSeconds?: number | null;
|
|
52
|
+
userConfirmedPublicLink?: boolean | null;
|
|
53
|
+
};
|
|
54
|
+
/** Browser response hints and HTML safety profile for an Artifact link. */
|
|
55
|
+
export type ArtifactLinkPresentationInput = {
|
|
56
|
+
disposition?: ArtifactLinkDisposition | null;
|
|
57
|
+
allowDownload?: boolean | null;
|
|
58
|
+
safeHtmlProfile?: ArtifactSafeHtmlProfile | null;
|
|
59
|
+
};
|
|
60
|
+
/** Creates a share/open/download entrypoint for an Artifact. */
|
|
61
|
+
export type CreateArtifactLinkInput = {
|
|
62
|
+
artifactId: string;
|
|
63
|
+
artifactVersionId?: string | null;
|
|
64
|
+
versionMode?: ArtifactLinkVersionMode | null;
|
|
65
|
+
access: ArtifactLinkAccessInput;
|
|
66
|
+
presentation?: ArtifactLinkPresentationInput | null;
|
|
67
|
+
metadata?: Record<string, unknown> | null;
|
|
68
|
+
};
|
|
69
|
+
/** Creates a short-lived signed preview link; never use this as a durable share URL. */
|
|
70
|
+
export type CreateSignedArtifactPreviewLinkInput = Omit<CreateArtifactLinkInput, 'access'> & {
|
|
71
|
+
ttlSeconds?: number | null;
|
|
72
|
+
};
|
|
73
|
+
/** Immutable Artifact version returned to plugins. */
|
|
74
|
+
export type ArtifactVersionRecord = {
|
|
75
|
+
id: string;
|
|
76
|
+
artifactId: string;
|
|
77
|
+
versionNumber: number;
|
|
78
|
+
status: ArtifactVersionStatus;
|
|
79
|
+
sourceVersionId?: string | null;
|
|
80
|
+
checksum?: string | null;
|
|
81
|
+
mimeType: string;
|
|
82
|
+
fileName?: string | null;
|
|
83
|
+
title?: string | null;
|
|
84
|
+
description?: string | null;
|
|
85
|
+
size?: number | null;
|
|
86
|
+
sha256?: string | null;
|
|
87
|
+
createdAt?: string | Date;
|
|
88
|
+
};
|
|
89
|
+
/** Durable Artifact container returned to plugins. */
|
|
90
|
+
export type ArtifactRecord = ArtifactScopeInput & {
|
|
91
|
+
id: string;
|
|
92
|
+
pluginName: string;
|
|
93
|
+
resourceType: string;
|
|
94
|
+
resourceId: string;
|
|
95
|
+
checksum?: string | null;
|
|
96
|
+
kind: ArtifactKind;
|
|
97
|
+
status: ArtifactStatus;
|
|
98
|
+
title?: string | null;
|
|
99
|
+
description?: string | null;
|
|
100
|
+
currentVersionId?: string | null;
|
|
101
|
+
currentVersion?: ArtifactVersionRecord | null;
|
|
102
|
+
createdAt?: string | Date;
|
|
103
|
+
updatedAt?: string | Date;
|
|
104
|
+
};
|
|
105
|
+
/** Share/open/download entrypoint returned to plugins. */
|
|
106
|
+
export type ArtifactLinkRecord = ArtifactScopeInput & {
|
|
107
|
+
id: string;
|
|
108
|
+
artifactId: string;
|
|
109
|
+
artifactVersionId?: string | null;
|
|
110
|
+
versionMode: ArtifactLinkVersionMode;
|
|
111
|
+
slug: string;
|
|
112
|
+
publicUrl: string;
|
|
113
|
+
accessMode: ArtifactAccessMode;
|
|
114
|
+
status: ArtifactLinkStatus;
|
|
115
|
+
customPrincipals?: string[] | null;
|
|
116
|
+
expiresAt?: string | Date | null;
|
|
117
|
+
revokedAt?: string | Date | null;
|
|
118
|
+
accessCount?: number;
|
|
119
|
+
downloadCount?: number;
|
|
120
|
+
disposition: ArtifactLinkDisposition;
|
|
121
|
+
allowDownload: boolean;
|
|
122
|
+
safeHtmlProfile?: ArtifactSafeHtmlProfile | null;
|
|
123
|
+
createdAt?: string | Date;
|
|
124
|
+
updatedAt?: string | Date;
|
|
125
|
+
artifact?: ArtifactRecord;
|
|
126
|
+
version?: ArtifactVersionRecord | null;
|
|
127
|
+
};
|
|
128
|
+
/** Filter used when listing Artifacts visible to the current plugin/runtime scope. */
|
|
129
|
+
export type ListArtifactsInput = {
|
|
130
|
+
pluginName?: string | null;
|
|
131
|
+
resourceType?: string | null;
|
|
132
|
+
resourceId?: string | null;
|
|
133
|
+
status?: ArtifactStatus | 'all' | null;
|
|
134
|
+
page?: number | null;
|
|
135
|
+
pageSize?: number | null;
|
|
136
|
+
};
|
|
137
|
+
export type ListArtifactsResult = {
|
|
138
|
+
items: ArtifactRecord[];
|
|
139
|
+
total: number;
|
|
140
|
+
page: number;
|
|
141
|
+
pageSize: number;
|
|
142
|
+
};
|
|
143
|
+
/** Mutable parts of an Artifact link; content versions remain immutable. */
|
|
144
|
+
export type UpdateArtifactLinkAccessInput = {
|
|
145
|
+
access?: ArtifactLinkAccessInput | null;
|
|
146
|
+
presentation?: ArtifactLinkPresentationInput | null;
|
|
147
|
+
artifactVersionId?: string | null;
|
|
148
|
+
versionMode?: ArtifactLinkVersionMode | null;
|
|
149
|
+
};
|
|
150
|
+
/** Platform runtime capability exposed to plugins for managing generated Artifacts. */
|
|
151
|
+
export interface ArtifactsApi {
|
|
152
|
+
createArtifact(input: CreateArtifactInput): Promise<ArtifactRecord>;
|
|
153
|
+
createArtifactVersion(input: CreateArtifactVersionInput): Promise<ArtifactVersionRecord>;
|
|
154
|
+
getArtifact(idOrSlug: string): Promise<ArtifactRecord>;
|
|
155
|
+
listArtifacts(input?: ListArtifactsInput): Promise<ListArtifactsResult>;
|
|
156
|
+
archiveArtifact(idOrSlug: string): Promise<ArtifactRecord>;
|
|
157
|
+
deleteArtifact(idOrSlug: string): Promise<ArtifactRecord>;
|
|
158
|
+
createArtifactLink(input: CreateArtifactLinkInput): Promise<ArtifactLinkRecord>;
|
|
159
|
+
createSignedPreviewLink(input: CreateSignedArtifactPreviewLinkInput): Promise<ArtifactLinkRecord>;
|
|
160
|
+
updateArtifactLinkAccess(idOrSlug: string, patch: UpdateArtifactLinkAccessInput): Promise<ArtifactLinkRecord>;
|
|
161
|
+
revokeArtifactLink(idOrSlug: string): Promise<ArtifactLinkRecord>;
|
|
162
|
+
}
|
|
163
|
+
export declare const ArtifactsRuntimeCapability: import("../../core/runtime-capability").RuntimeCapabilityKey<ArtifactsApi>;
|