@xpert-ai/plugin-sdk 3.26.1 → 3.27.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.
Files changed (42) hide show
  1. package/artifact-document.cjs.js +55 -16
  2. package/artifact-document.esm.js +53 -17
  3. package/data-workbench.cjs.js +4 -2
  4. package/data-workbench.esm.js +4 -2
  5. package/docs/artifact-documents.md +8 -2
  6. package/docs/en/runtime-capabilities.md +103 -0
  7. package/index.cjs.js +169 -25
  8. package/index.esm.js +159 -27
  9. package/model-provider.cjs.js +18 -0
  10. package/model-provider.esm.js +16 -1
  11. package/package.json +2 -2
  12. package/src/artifact-document.d.ts +1 -0
  13. package/src/index.d.ts +1 -0
  14. package/src/lib/agent/middleware/runtime.d.ts +2 -0
  15. package/src/lib/artifact-document/host.d.ts +3 -0
  16. package/src/lib/artifact-document/network.d.ts +21 -0
  17. package/src/lib/artifact-document/runtime.d.ts +2 -1
  18. package/src/lib/assistant-capability/index.d.ts +2 -0
  19. package/src/lib/collaboration/types.d.ts +7 -1
  20. package/src/lib/connector/document-source.d.ts +31 -0
  21. package/src/lib/connector/documents.d.ts +38 -0
  22. package/src/lib/connector/index.d.ts +1 -0
  23. package/src/lib/connector/strategy.interface.d.ts +3 -0
  24. package/src/lib/content-resource/document.d.ts +142 -0
  25. package/src/lib/content-resource/editor.d.ts +73 -0
  26. package/src/lib/content-resource/index.d.ts +91 -0
  27. package/src/lib/content-resource/reference.d.ts +38 -0
  28. package/src/lib/data/datasource/workbench-adapter.d.ts +5 -3
  29. package/src/lib/data/datasource/workbench-sql.d.ts +0 -4
  30. package/src/lib/project-pipeline/contribution-failure.d.ts +17 -0
  31. package/src/lib/project-pipeline/registry.d.ts +24 -1
  32. package/src/lib/runtime/actor.d.ts +10 -0
  33. package/src/lib/runtime/capabilities/artifacts.d.ts +5 -0
  34. package/src/lib/runtime/capabilities/assistant-middleware-access.d.ts +28 -0
  35. package/src/lib/runtime/capabilities/index.d.ts +4 -0
  36. package/src/lib/runtime/capabilities/project-access.d.ts +10 -7
  37. package/src/lib/runtime/capabilities/project-files.d.ts +40 -0
  38. package/src/lib/runtime/capabilities/project-knowledge.d.ts +14 -0
  39. package/src/lib/runtime/capabilities/project-provisioning.d.ts +6 -0
  40. package/src/lib/runtime/capabilities/sandbox-jobs.d.ts +1 -1
  41. package/src/lib/runtime/capabilities/workspace-files.d.ts +2 -0
  42. package/src/lib/view-extension/middleware-runtime.d.ts +2 -3
@@ -215,6 +215,9 @@ const WorkspaceFilesRuntimeCapability = createRuntimeCapability('platform.worksp
215
215
  'SANDBOX_VERSION_MISMATCH',
216
216
  'SANDBOX_CAPACITY_UNAVAILABLE',
217
217
  'SANDBOX_START_FAILED',
218
+ 'SANDBOX_DEPENDENCY_MISSING',
219
+ 'EXPORT_CONVERSION_FAILED',
220
+ 'EXPORT_TEXT_EXTRACTION_FAILED',
218
221
  'SANDBOX_INVOCATION_FAILED',
219
222
  'BROWSER_LAUNCH_FAILED',
220
223
  'EXPORT_TIMEOUT',
@@ -261,10 +264,22 @@ const ProjectAccessRuntimeCapability = createRuntimeCapability('platform.project
261
264
  description: 'Resolve human Project membership for platform and plugin operations.'
262
265
  });
263
266
 
267
+ const ProjectFilesRuntimeCapability = createRuntimeCapability('platform.project.files', {
268
+ description: 'Authorized Project file tree and conflict-aware atomic file writes.'
269
+ });
270
+
264
271
  const ToolImagesRuntimeCapability = createRuntimeCapability('platform.tool-images', {
265
272
  description: 'Save scoped immutable tool images and materialize verified pixels for one model request.'
266
273
  });
267
274
 
275
+ const AssistantMiddlewareAccessRuntimeCapability = createRuntimeCapability('platform.assistant.middleware-access', {
276
+ description: 'Authorize a published Assistant and its exact connected middleware feature for a trusted actor.'
277
+ });
278
+
279
+ const ProjectKnowledgeRuntimeCapability = createRuntimeCapability('platform.project.knowledge', {
280
+ description: 'Provision and bind the Project-owned built-in knowledge library.'
281
+ });
282
+
268
283
  const McpClientRuntimeCapability = createRuntimeCapability('platform.mcp.client', {
269
284
  description: 'Governed MCP client access using existing connections and viewer credentials; read-only tools initially.'
270
285
  });
@@ -411,6 +426,7 @@ exports.ActorTokenRuntimeCapability = ActorTokenRuntimeCapability;
411
426
  exports.ActorTokenRuntimeFactoryCapability = ActorTokenRuntimeFactoryCapability;
412
427
  exports.ArtifactDraftsRuntimeCapability = ArtifactDraftsRuntimeCapability;
413
428
  exports.ArtifactsRuntimeCapability = ArtifactsRuntimeCapability;
429
+ exports.AssistantMiddlewareAccessRuntimeCapability = AssistantMiddlewareAccessRuntimeCapability;
414
430
  exports.BaseTool = BaseTool;
415
431
  exports.BaseToolset = BaseToolset;
416
432
  exports.BuiltinToolset = BuiltinToolset;
@@ -418,6 +434,8 @@ exports.DefaultRuntimeCapabilityRegistry = DefaultRuntimeCapabilityRegistry;
418
434
  exports.McpClientRuntimeCapability = McpClientRuntimeCapability;
419
435
  exports.ModelProviderBuiltinToolset = ModelProviderBuiltinToolset;
420
436
  exports.ProjectAccessRuntimeCapability = ProjectAccessRuntimeCapability;
437
+ exports.ProjectFilesRuntimeCapability = ProjectFilesRuntimeCapability;
438
+ exports.ProjectKnowledgeRuntimeCapability = ProjectKnowledgeRuntimeCapability;
421
439
  exports.ProjectProvisioningRuntimeCapability = ProjectProvisioningRuntimeCapability;
422
440
  exports.RUNTIME_CAPABILITY_PROVIDER = RUNTIME_CAPABILITY_PROVIDER;
423
441
  exports.RestClientRuntimeCapability = RestClientRuntimeCapability;
@@ -213,6 +213,9 @@ const WorkspaceFilesRuntimeCapability = createRuntimeCapability('platform.worksp
213
213
  'SANDBOX_VERSION_MISMATCH',
214
214
  'SANDBOX_CAPACITY_UNAVAILABLE',
215
215
  'SANDBOX_START_FAILED',
216
+ 'SANDBOX_DEPENDENCY_MISSING',
217
+ 'EXPORT_CONVERSION_FAILED',
218
+ 'EXPORT_TEXT_EXTRACTION_FAILED',
216
219
  'SANDBOX_INVOCATION_FAILED',
217
220
  'BROWSER_LAUNCH_FAILED',
218
221
  'EXPORT_TIMEOUT',
@@ -259,10 +262,22 @@ const ProjectAccessRuntimeCapability = createRuntimeCapability('platform.project
259
262
  description: 'Resolve human Project membership for platform and plugin operations.'
260
263
  });
261
264
 
265
+ const ProjectFilesRuntimeCapability = createRuntimeCapability('platform.project.files', {
266
+ description: 'Authorized Project file tree and conflict-aware atomic file writes.'
267
+ });
268
+
262
269
  const ToolImagesRuntimeCapability = createRuntimeCapability('platform.tool-images', {
263
270
  description: 'Save scoped immutable tool images and materialize verified pixels for one model request.'
264
271
  });
265
272
 
273
+ const AssistantMiddlewareAccessRuntimeCapability = createRuntimeCapability('platform.assistant.middleware-access', {
274
+ description: 'Authorize a published Assistant and its exact connected middleware feature for a trusted actor.'
275
+ });
276
+
277
+ const ProjectKnowledgeRuntimeCapability = createRuntimeCapability('platform.project.knowledge', {
278
+ description: 'Provision and bind the Project-owned built-in knowledge library.'
279
+ });
280
+
266
281
  const McpClientRuntimeCapability = createRuntimeCapability('platform.mcp.client', {
267
282
  description: 'Governed MCP client access using existing connections and viewer credentials; read-only tools initially.'
268
283
  });
@@ -405,4 +420,4 @@ function normalizeWorkspaceScope(scope) {
405
420
  } : {});
406
421
  }
407
422
 
408
- export { ActorTokenRuntimeCapability as A, BuiltinToolset as B, DefaultRuntimeCapabilityRegistry as D, ModelProviderBuiltinToolset as M, ProjectAccessRuntimeCapability as P, RUNTIME_CAPABILITY_PROVIDER as R, SANDBOX_JOB_ERROR_CODES as S, ToolImagesRuntimeCapability as T, WorkspaceFilesRuntimeCapability as W, XPERT_RUNTIME_CAPABILITIES_TOKEN as X, ActorTokenRuntimeFactoryCapability as a, ArtifactDraftsRuntimeCapability as b, createRuntimeCapability as c, ArtifactsRuntimeCapability as d, BaseTool as e, BaseToolset as f, McpClientRuntimeCapability as g, ProjectProvisioningRuntimeCapability as h, RestClientRuntimeCapability as i, RuntimeCapabilityProvider as j, SANDBOX_JOB_INVOCATION_PREFIX as k, SANDBOX_JOB_PROGRESS_PREFIX as l, SandboxJobRuntimeError as m, SandboxJobsRuntimeCapability as n, WORKSPACE_FILES_SOURCE as o, isSandboxJobRuntimeError as p, workspaceFileMutationPath as q, workspaceRelativeFilePathSchema as r, workspaceFileMutationMetadata as w };
423
+ export { ActorTokenRuntimeCapability as A, BuiltinToolset as B, DefaultRuntimeCapabilityRegistry as D, ModelProviderBuiltinToolset as M, ProjectAccessRuntimeCapability as P, RUNTIME_CAPABILITY_PROVIDER as R, SANDBOX_JOB_ERROR_CODES as S, ToolImagesRuntimeCapability as T, WorkspaceFilesRuntimeCapability as W, XPERT_RUNTIME_CAPABILITIES_TOKEN as X, ActorTokenRuntimeFactoryCapability as a, ArtifactDraftsRuntimeCapability as b, createRuntimeCapability as c, ArtifactsRuntimeCapability as d, AssistantMiddlewareAccessRuntimeCapability as e, BaseTool as f, BaseToolset as g, McpClientRuntimeCapability as h, ProjectFilesRuntimeCapability as i, ProjectKnowledgeRuntimeCapability as j, ProjectProvisioningRuntimeCapability as k, RestClientRuntimeCapability as l, RuntimeCapabilityProvider as m, SANDBOX_JOB_INVOCATION_PREFIX as n, SANDBOX_JOB_PROGRESS_PREFIX as o, SandboxJobRuntimeError as p, SandboxJobsRuntimeCapability as q, WORKSPACE_FILES_SOURCE as r, isSandboxJobRuntimeError as s, workspaceFileMutationPath as t, workspaceRelativeFilePathSchema as u, workspaceFileMutationMetadata as w };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpert-ai/plugin-sdk",
3
- "version": "3.26.1",
3
+ "version": "3.27.0",
4
4
  "license": "AGPL-3.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -74,7 +74,7 @@
74
74
  },
75
75
  "dependencies": {
76
76
  "@langchain/openai": "0.6.9",
77
- "@xpert-ai/contracts": "3.26.1",
77
+ "@xpert-ai/contracts": "3.27.0",
78
78
  "express": "^4.22.1",
79
79
  "js-tiktoken": "^1.0.21"
80
80
  },
@@ -3,3 +3,4 @@ export * from './lib/artifact-document/protocol';
3
3
  export * from './lib/artifact-document/runtime';
4
4
  export * from './lib/artifact-document/host';
5
5
  export * from './lib/artifact-document/dependencies';
6
+ export * from './lib/artifact-document/network';
package/src/index.d.ts CHANGED
@@ -28,6 +28,7 @@ export * from './lib/managed-queue/index';
28
28
  export * from './lib/view-extension/index';
29
29
  export * from './lib/artifact-presentation/index';
30
30
  export * from './lib/collaboration/index';
31
+ export * from './lib/content-resource/index';
31
32
  export * from './lib/evolution/index';
32
33
  export * from './lib/mcp/index';
33
34
  export * from './lib/tool-provider/index';
@@ -136,6 +136,8 @@ export type AgentMiddlewareEvent = {
136
136
  [key: string]: unknown;
137
137
  };
138
138
  export interface AgentMiddlewareRuntimeApi {
139
+ /** Resolve the current scope's authorized primary chat model without exposing provider credentials. */
140
+ getDefaultChatModel?(): Promise<ICopilotModel>;
139
141
  createModelClient<T = AgentMiddlewareModelClient>(copilotModel: ICopilotModel, options: AgentMiddlewareCreateModelClientOptions): Promise<T>;
140
142
  /** Resolve an enabled model provider connection in the current tenant and organization scope. */
141
143
  getModelProvider?(provider: string): Promise<AgentMiddlewareModelProviderConnection>;
@@ -1,11 +1,14 @@
1
1
  import { type ArtifactDocumentContext, type ArtifactDocumentQuery } from './protocol';
2
2
  import type { ArtifactDocumentDependencyAsset } from './dependencies';
3
+ import type { ArtifactDocumentNetworkPolicy } from './network';
3
4
  /** Trusted integration callbacks. T is the plugin's cloneable result shape, independent of any chart library. */
4
5
  export interface ArtifactDocumentHostOptions<T> {
5
6
  /** Complete untrusted HTML; scripts run only inside the isolated frame. */
6
7
  html: string;
7
8
  /** Exact packaged bytes pinned to this Artifact version, never URLs or library names from the document. */
8
9
  dependencies?: ArtifactDocumentDependencyAsset[];
10
+ /** Optional trusted HTTPS resource allowlist. Omit to keep all external resources blocked. */
11
+ networkPolicy?: ArtifactDocumentNetworkPolicy;
9
12
  /** Public binding IDs and presentation defaults for this document generation. */
10
13
  context: ArtifactDocumentContext;
11
14
  /** Resolve against saved Bindings on the server with the current user's access; never execute a query definition from HTML. */
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod/v3';
2
+ export declare const artifactDocumentNetworkPolicy: z.ZodObject<{
3
+ scripts: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
4
+ styles: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
5
+ fonts: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
6
+ images: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
7
+ }, "strict", z.ZodTypeAny, {
8
+ scripts?: string[];
9
+ styles?: string[];
10
+ fonts?: string[];
11
+ images?: string[];
12
+ }, {
13
+ scripts?: string[];
14
+ styles?: string[];
15
+ fonts?: string[];
16
+ images?: string[];
17
+ }>;
18
+ export type ArtifactDocumentNetworkPolicy = z.output<typeof artifactDocumentNetworkPolicy>;
19
+ export declare function artifactDocumentCsp(input?: ArtifactDocumentNetworkPolicy): string;
20
+ /** For preview browser routing; CSP remains the enforcement in the displayed frame. */
21
+ export declare function isArtifactDocumentResourceAllowed(policy: ArtifactDocumentNetworkPolicy, resourceType: string, value: string): boolean;
@@ -1,4 +1,5 @@
1
1
  import { type ArtifactDocumentDependencyAsset } from './dependencies';
2
+ import { type ArtifactDocumentNetworkPolicy } from './network';
2
3
  export declare const ARTIFACT_DOCUMENT_CSP: string;
3
4
  /** Host-owned prefix precedes all authored markup, including malformed/duplicate heads. */
4
- export declare function renderArtifactDocument(html: string, sessionId: string, dependencies?: ArtifactDocumentDependencyAsset[]): string;
5
+ export declare function renderArtifactDocument(html: string, sessionId: string, dependencies?: ArtifactDocumentDependencyAsset[], networkPolicy?: ArtifactDocumentNetworkPolicy): string;
@@ -21,6 +21,8 @@ export interface IAssistantCapabilityProvider {
21
21
  readonly requiredModelFeatures?: ModelFeature[];
22
22
  /** Explicitly opt into the blank Assistant creation flow. */
23
23
  readonly availableForBlankAssistant?: boolean;
24
+ /** Opt into a simple creation switch; no additional capability-specific configuration is needed. */
25
+ readonly supportsQuickCreation?: boolean;
24
26
  /** Distribution extensions to specific templates, without changing their portable source. */
25
27
  readonly templates?: {
26
28
  templateId: string;
@@ -144,7 +144,9 @@ export interface CollaborationApi {
144
144
  /** Remove an Agent/system collaborator before its TTL expires. */
145
145
  removeVirtualPresence(input: RemoveVirtualPresenceInput): Promise<void>;
146
146
  /** Stop normal editing while retaining the document. */
147
- archiveDocument(input: GetCollaborationDocumentInput): Promise<CollaborationDocumentRecord>;
147
+ archiveDocument(input: GetCollaborationDocumentInput & {
148
+ expectedSequence?: number;
149
+ }): Promise<CollaborationDocumentRecord>;
148
150
  /** Soft-delete the platform document and notify its provider. */
149
151
  deleteDocument(input: GetCollaborationDocumentInput): Promise<CollaborationDocumentRecord>;
150
152
  }
@@ -181,6 +183,10 @@ export type CollaborationMaterializationEvent = CollaborationProviderContext & {
181
183
  export interface ICollaborationDocumentProvider {
182
184
  /** Authorize the exact resource and requested operation in the supplied platform scope. */
183
185
  authorize(context: CollaborationProviderContext): Promise<boolean> | boolean;
186
+ /** Validate the merged state before commit, including updates received through WebSockets. */
187
+ validateDocument?(context: CollaborationProviderContext & {
188
+ stateBase64: string;
189
+ }): Promise<void> | void;
184
190
  /** Return an idempotent initial snapshot without creating a business version. */
185
191
  initializeDocument(context: CollaborationProviderContext): Promise<CollaborationDocumentInitialization> | CollaborationDocumentInitialization;
186
192
  /** Project platform state into plugin query/export entities. The method must be idempotent. */
@@ -0,0 +1,31 @@
1
+ import type { ConnectorRuntimeCredentialV2 } from './strategy.interface';
2
+ export interface ConnectorDocumentEntry {
3
+ id: string;
4
+ title: string;
5
+ /** A validated public document URL, never a signed file URL. */
6
+ url: string | null;
7
+ type: 'document';
8
+ }
9
+ export interface ConnectorDocumentSnapshot extends ConnectorDocumentEntry {
10
+ revision: string;
11
+ /** Hash of the imported representation. Detects changes even if the provider revision is coarse. */
12
+ contentHash: string;
13
+ format: 'text/plain';
14
+ content: string;
15
+ warnings: string[];
16
+ }
17
+ export interface ConnectorDocumentQuery {
18
+ query: string;
19
+ cursor?: string;
20
+ pageSize: number;
21
+ }
22
+ /** Optional native connector hook. Credentials stay server-side; document access uses the same identity
23
+ * as the connection. Start with explicit representations; never label plain text as a lossless rich document.
24
+ */
25
+ export interface ConnectorDocumentSource {
26
+ search(credential: ConnectorRuntimeCredentialV2, query: ConnectorDocumentQuery): Promise<{
27
+ items: ConnectorDocumentEntry[];
28
+ nextCursor: string | null;
29
+ }>;
30
+ read(credential: ConnectorRuntimeCredentialV2, locator: string): Promise<ConnectorDocumentSnapshot>;
31
+ }
@@ -0,0 +1,38 @@
1
+ import type { I18nText } from '@xpert-ai/contracts';
2
+ import type { OrganizationRuntimeActor } from '../runtime/actor';
3
+ import type { ConnectorScope } from './strategy.interface';
4
+ export type * from './document-source';
5
+ import type { ConnectorDocumentEntry, ConnectorDocumentQuery, ConnectorDocumentSnapshot } from './document-source';
6
+ export interface ConnectorDocumentContext {
7
+ actor: OrganizationRuntimeActor;
8
+ assistantId: string;
9
+ projectId: string;
10
+ }
11
+ export interface ConnectorDocumentConnection {
12
+ bindingId: string;
13
+ provider: string;
14
+ label: I18nText;
15
+ scope: ConnectorScope;
16
+ status: string;
17
+ available: boolean;
18
+ managementUrl: string;
19
+ }
20
+ /** Interactive, authenticated host API. The host lists permissible bindings itself; a client ID is
21
+ * never a grant. This API does not grant arbitrary connectors to model/tool executions.
22
+ */
23
+ export interface ConnectorDocumentsApi {
24
+ sources(context: ConnectorDocumentContext): Promise<{
25
+ items: ConnectorDocumentConnection[];
26
+ }>;
27
+ search(input: ConnectorDocumentContext & ConnectorDocumentQuery & {
28
+ bindingId: string;
29
+ }): Promise<{
30
+ items: ConnectorDocumentEntry[];
31
+ nextCursor: string | null;
32
+ }>;
33
+ read(input: ConnectorDocumentContext & {
34
+ bindingId: string;
35
+ locator: string;
36
+ }): Promise<ConnectorDocumentSnapshot>;
37
+ }
38
+ export declare const ConnectorDocumentsRuntimeCapability: import("../core/runtime-capability").RuntimeCapabilityKey<ConnectorDocumentsApi>;
@@ -3,3 +3,4 @@ export * from './strategy.decorator';
3
3
  export * from './strategy.interface';
4
4
  export * from './strategy.registry';
5
5
  export * from './integration.interface';
6
+ export * from './documents';
@@ -1,3 +1,4 @@
1
+ import type { ConnectorDocumentSource } from './document-source';
1
2
  import type { I18nText, IconDefinition } from '@xpert-ai/contracts';
2
3
  export type RuntimeI18nText = I18nText;
3
4
  export type RuntimeCapabilityIcon = IconDefinition;
@@ -413,6 +414,8 @@ export type ConnectorAuthorizationPollResult = {
413
414
  metadata?: Record<string, unknown>;
414
415
  };
415
416
  export interface ConnectorStrategyRuntime {
417
+ /** Optional read-only document adapter, independent of knowledge ingestion and remote editing. */
418
+ documents?: ConnectorDocumentSource;
416
419
  definition: ConnectorStrategyDefinition;
417
420
  connect?(input: ConnectorConnectInput): Promise<ConnectorConnectResult>;
418
421
  exchangeAuthorizationCode?(input: ConnectorAuthorizationCodeInput): Promise<ConnectorCredential>;
@@ -0,0 +1,142 @@
1
+ import type { ContentDocumentBlock, ContentDocumentDescriptor, ContentDocumentRevision, ContentDocumentProposal, TextContentEditorRegistration, ContentDocumentComment, ContentPageHierarchy } from '@xpert-ai/contracts';
2
+ import type { CollaborationSessionDescriptor } from '../collaboration/types';
3
+ import type { ContentActor, ContentResourceReference } from './index';
4
+ export type ContentDocumentScope = {
5
+ actor: ContentActor;
6
+ projectId: string;
7
+ assistantId?: string;
8
+ };
9
+ /** resourceId identifies a platform ContentDocument. Source hooks use ContentSourceInput.sourceResourceId. */
10
+ export type ContentDocumentInput = ContentDocumentScope & {
11
+ resourceId: string;
12
+ };
13
+ export type ContentLocationChangeInput = ContentDocumentScope & {
14
+ source: ContentResourceReference;
15
+ path: string;
16
+ destination: string;
17
+ title: string;
18
+ parentResourceId: string | null;
19
+ deleted: boolean;
20
+ expectedSourceVersion: number;
21
+ };
22
+ export type ContentTextPatch = {
23
+ blockId: string;
24
+ before: string;
25
+ after: string;
26
+ expectedSequence: number;
27
+ epoch: number;
28
+ mutationId: string;
29
+ };
30
+ export type ContentDocumentState = {
31
+ document: ContentDocumentDescriptor;
32
+ stateBase64: string;
33
+ markdown: string;
34
+ blocks: ContentDocumentBlock[];
35
+ canWrite: boolean;
36
+ externalChange: boolean;
37
+ };
38
+ export interface ContentDocumentModel {
39
+ readonly descriptor: TextContentEditorRegistration;
40
+ /** Explicit, lossless upgrade only. Throw for unsupported source versions; never guess from content. */
41
+ upgrade?(stateBase64: string, fromSchemaVersion: number): string;
42
+ initialize(markdown: string, anchors?: Array<{
43
+ id: string;
44
+ text: string;
45
+ }>): string;
46
+ validate(stateBase64: string): void;
47
+ read(stateBase64: string): {
48
+ markdown: string;
49
+ blocks: ContentDocumentBlock[];
50
+ };
51
+ patch(stateBase64: string, patch: Pick<ContentTextPatch, 'blockId' | 'before' | 'after'>): string;
52
+ }
53
+ /** Callers supply only server-authenticated scope. Each operation rechecks current resource access. */
54
+ export interface ContentDocumentsApi {
55
+ /** Provider-owned logical hierarchy; file locations and project permissions remain unchanged. */
56
+ hierarchy(input: ContentDocumentInput): Promise<ContentPageHierarchy>;
57
+ /** Retry with the same requestId/title after an unknown outcome; creates exactly one independent file. */
58
+ createChild(input: ContentDocumentInput & {
59
+ title: string;
60
+ requestId: string;
61
+ }): Promise<ContentDocumentDescriptor>;
62
+ /** Recent documents visible to the caller in the current project, limited to 100. */
63
+ list(input: ContentDocumentScope & {
64
+ modelKey: string;
65
+ }): Promise<ContentDocumentDescriptor[]>;
66
+ /** Durable move/trash/restore; freezes rooms before filesystem mutation and projects metadata after commit. */
67
+ move(input: ContentLocationChangeInput): Promise<void>;
68
+ validateImport(input: ContentDocumentScope & {
69
+ modelKey: string;
70
+ markdown: string;
71
+ }): Promise<void>;
72
+ register(input: ContentDocumentScope & {
73
+ resourceId: string;
74
+ path: string;
75
+ title: string;
76
+ modelKey: string;
77
+ source: ContentResourceReference;
78
+ anchors?: Array<{
79
+ id: string;
80
+ text: string;
81
+ }>;
82
+ }): Promise<ContentDocumentDescriptor>;
83
+ get(input: ContentDocumentInput): Promise<ContentDocumentState>;
84
+ session(input: ContentDocumentInput & {
85
+ schemaVersion: number;
86
+ }): Promise<ContentDocumentState & {
87
+ session: CollaborationSessionDescriptor;
88
+ }>;
89
+ update(input: ContentDocumentInput & {
90
+ epoch: number;
91
+ schemaVersion: number;
92
+ updateBase64: string;
93
+ }): Promise<{
94
+ sequenceNumber: number;
95
+ materializationStatus: 'ready' | 'pending' | 'failed';
96
+ }>;
97
+ history(input: ContentDocumentInput): Promise<ContentDocumentRevision[]>;
98
+ preview(input: ContentDocumentInput & {
99
+ revisionId: string;
100
+ }): Promise<{
101
+ revision: ContentDocumentRevision;
102
+ markdown: string;
103
+ }>;
104
+ checkpoint(input: ContentDocumentInput & {
105
+ label: string;
106
+ }): Promise<ContentDocumentRevision>;
107
+ propose(input: ContentDocumentInput & ContentTextPatch): Promise<ContentDocumentProposal>;
108
+ proposals(input: ContentDocumentInput): Promise<ContentDocumentProposal[]>;
109
+ decide(input: ContentDocumentInput & {
110
+ proposalId: string;
111
+ accept: boolean;
112
+ }): Promise<ContentDocumentProposal>;
113
+ comments(input: ContentDocumentInput): Promise<ContentDocumentComment[]>;
114
+ comment(input: ContentDocumentInput & {
115
+ body: string;
116
+ blockId: string | null;
117
+ }): Promise<ContentDocumentComment>;
118
+ resolveComment(input: ContentDocumentInput & {
119
+ commentId: string;
120
+ resolved: boolean;
121
+ }): Promise<ContentDocumentComment>;
122
+ restore(input: ContentDocumentInput & {
123
+ revisionId: string;
124
+ expectedSequence: number;
125
+ epoch: number;
126
+ }): Promise<ContentDocumentDescriptor>;
127
+ reconcile(input: ContentDocumentInput & {
128
+ choice: 'file' | 'document';
129
+ expectedHash: string;
130
+ expectedSequence: number;
131
+ epoch: number;
132
+ }): Promise<ContentDocumentDescriptor>;
133
+ setDeleted(input: ContentDocumentInput & {
134
+ deleted: boolean;
135
+ }): Promise<void>;
136
+ /** File moves retain resource identity; source authorization must already reflect the new path. */
137
+ relocate(input: ContentDocumentInput & {
138
+ path: string;
139
+ title: string;
140
+ }): Promise<void>;
141
+ }
142
+ export declare const ContentDocumentsRuntimeCapability: import("../core/runtime-capability").RuntimeCapabilityKey<ContentDocumentsApi>;
@@ -0,0 +1,73 @@
1
+ import { DiscoveryService, Reflector } from '@nestjs/core';
2
+ import type { ContentEditorRegistration, FileContentEditorRegistration } from '@xpert-ai/contracts';
3
+ import { BaseStrategyRegistry } from '../strategy';
4
+ import type { ContentDocumentModel, ContentDocumentScope } from './document';
5
+ import type { ContentResourceReference, ContentSourceInput } from './index';
6
+ /** File codecs expose no cells, blocks or plugin-specific edit operations to the platform. */
7
+ export interface ContentFileEditor {
8
+ readonly descriptor: FileContentEditorRegistration;
9
+ create(): Promise<Buffer>;
10
+ validateFile(buffer: Buffer): Promise<void>;
11
+ }
12
+ export type IContentEditorProvider = ContentDocumentModel | ContentFileEditor;
13
+ export declare function isTextContentEditor(provider: IContentEditorProvider): provider is ContentDocumentModel;
14
+ export declare const ContentEditorProvider: (key: string) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
15
+ export declare class ContentEditorRegistry extends BaseStrategyRegistry<IContentEditorProvider> {
16
+ constructor(discovery: DiscoveryService, reflector: Reflector);
17
+ getTextModel(key: string, organizationId: string): ContentDocumentModel;
18
+ }
19
+ export interface ContentEditorFile {
20
+ editorKey: string;
21
+ projectId: string;
22
+ path: string;
23
+ title: string;
24
+ }
25
+ /** Resource owner supplies current identity/location and owns atomic versions, independent of format. */
26
+ export interface ContentResourceEditor {
27
+ describe(input: ContentSourceInput): Promise<ContentEditorFile>;
28
+ files?: {
29
+ read(input: ContentSourceInput): Promise<{
30
+ buffer: Buffer;
31
+ revision: string;
32
+ }>;
33
+ write(input: ContentSourceInput & {
34
+ buffer: Buffer;
35
+ expectedRevision: string;
36
+ }): Promise<{
37
+ revision: string;
38
+ }>;
39
+ };
40
+ }
41
+ export type ContentEditorInput = ContentDocumentScope & {
42
+ source: ContentResourceReference;
43
+ };
44
+ export interface ContentEditorResolution {
45
+ registration: ContentEditorRegistration;
46
+ file: ContentEditorFile;
47
+ canWrite: boolean;
48
+ viewKey: string;
49
+ }
50
+ /** Trusted scope only. Every operation checks Project, Assistant binding and resource permissions. */
51
+ export interface ContentEditorsApi {
52
+ list(scope: ContentDocumentScope): Promise<ContentEditorRegistration[]>;
53
+ /** Prepare/validate bytes; does not create a resource or grant access to a destination. */
54
+ prepare(scope: ContentDocumentScope & {
55
+ editorKey: string;
56
+ buffer?: Buffer;
57
+ }): Promise<{
58
+ registration: FileContentEditorRegistration;
59
+ buffer: Buffer;
60
+ }>;
61
+ resolve(input: ContentEditorInput): Promise<ContentEditorResolution>;
62
+ read(input: ContentEditorInput): Promise<ContentEditorResolution & {
63
+ buffer: Buffer;
64
+ revision: string;
65
+ }>;
66
+ write(input: ContentEditorInput & {
67
+ buffer: Buffer;
68
+ expectedRevision: string;
69
+ }): Promise<{
70
+ revision: string;
71
+ }>;
72
+ }
73
+ export declare const ContentEditorsRuntimeCapability: import("../core/runtime-capability").RuntimeCapabilityKey<ContentEditorsApi>;
@@ -0,0 +1,91 @@
1
+ import type { ContentReferenceProvider } from './reference';
2
+ import { DiscoveryService, Reflector } from '@nestjs/core';
3
+ import { BaseStrategyRegistry } from '../strategy';
4
+ import type { OrganizationRuntimeActor } from '../runtime/actor';
5
+ export type ContentActor = OrganizationRuntimeActor;
6
+ export interface ContentPrincipal extends ContentActor {
7
+ groupIds: string[];
8
+ }
9
+ export type ContentOperation = 'read' | 'comment' | 'write' | 'manage';
10
+ export interface ContentResourceReference {
11
+ providerKey: string;
12
+ resourceId: string;
13
+ }
14
+ export interface ContentResourceRequest extends ContentResourceReference {
15
+ actor: ContentActor;
16
+ operation: ContentOperation;
17
+ /** Relative immutable file path. Providers must validate its owning item. */
18
+ filePath?: string;
19
+ }
20
+ export interface ContentResourceDescriptor extends ContentResourceReference {
21
+ title: string;
22
+ role: string;
23
+ canWrite: boolean;
24
+ canManage: boolean;
25
+ }
26
+ /** Source hook scope uses the provider's identifier; it is never a platform document id. */
27
+ export type ContentSourceInput = import('./document').ContentDocumentScope & {
28
+ sourceResourceId: string;
29
+ };
30
+ export interface ContentPageProvider {
31
+ pageHierarchy(input: ContentSourceInput): Promise<import('@xpert-ai/contracts').ContentPageHierarchy>;
32
+ /** Retry requestId after unknown outcomes. Return the registered platform document id. */
33
+ createChildPage(input: ContentSourceInput & {
34
+ title: string;
35
+ requestId: string;
36
+ }): Promise<{
37
+ documentId: string;
38
+ }>;
39
+ }
40
+ export interface ContentPublicationObserver {
41
+ /** Retryable projection: compare the supplied head before updating derived data. */
42
+ onDocumentPublished(input: ContentSourceInput & {
43
+ path: string;
44
+ hash: string;
45
+ revisionId: string;
46
+ sequence: number;
47
+ }): Promise<void>;
48
+ }
49
+ export interface ContentLocationProvider {
50
+ validateLocationChange(input: import('./document').ContentLocationChangeInput): Promise<void>;
51
+ onLocationPrepared?(input: import('./document').ContentLocationChangeInput & {
52
+ operationId: string;
53
+ }): Promise<void>;
54
+ onLocationChanged(input: import('./document').ContentLocationChangeInput & {
55
+ operationId: string;
56
+ }): Promise<void>;
57
+ }
58
+ /** Resource authorization is mandatory. Content extensions are explicitly composed, never inferred. */
59
+ export interface IContentResourceProvider {
60
+ readonly title: string;
61
+ authorize(input: ContentResourceRequest & {
62
+ principal: ContentPrincipal;
63
+ }): Promise<ContentResourceDescriptor>;
64
+ readonly editor?: import('./editor').ContentResourceEditor;
65
+ readonly references?: ContentReferenceProvider;
66
+ readonly pages?: ContentPageProvider;
67
+ readonly publication?: ContentPublicationObserver;
68
+ readonly locations?: ContentLocationProvider;
69
+ }
70
+ export declare const CONTENT_RESOURCE_PROVIDER = "XPERT_CONTENT_RESOURCE_PROVIDER";
71
+ export declare const ContentResourceProvider: (key: string) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
72
+ export declare class ContentResourceProviderRegistry extends BaseStrategyRegistry<IContentResourceProvider> {
73
+ constructor(discovery: DiscoveryService, reflector: Reflector);
74
+ }
75
+ export interface ContentIdentitiesApi {
76
+ /** Checks current active organization membership, then resolves current groups. */
77
+ principal(actor: ContentActor): Promise<ContentPrincipal>;
78
+ directory(actor: ContentActor, query: string): Promise<Array<{
79
+ id: string;
80
+ type: 'user' | 'group';
81
+ label: string;
82
+ }>>;
83
+ }
84
+ export interface ContentResourcesApi {
85
+ readonly identities: ContentIdentitiesApi;
86
+ authorize(input: ContentResourceRequest): Promise<ContentResourceDescriptor>;
87
+ }
88
+ export declare const ContentResourcesRuntimeCapability: import("../core/runtime-capability").RuntimeCapabilityKey<ContentResourcesApi>;
89
+ export * from './document';
90
+ export * from './reference';
91
+ export * from './editor';
@@ -0,0 +1,38 @@
1
+ import type { ContentReferenceEntry, ContentReferencePage, ContentReferenceTarget } from '@xpert-ai/contracts';
2
+ import type { ContentSourceInput } from './index';
3
+ import type { ContentDocumentInput } from './document';
4
+ import type { WorkspacePortableFileReference } from '../runtime/capabilities/workspace-files';
5
+ export type ContentReferenceQuery = {
6
+ kind: ContentReferenceTarget['kind'];
7
+ query: string;
8
+ cursor?: string;
9
+ pageSize: number;
10
+ };
11
+ export type ContentReferenceUpload = {
12
+ kind: 'image' | 'file';
13
+ fileName: string;
14
+ mimeType: string;
15
+ buffer: Buffer;
16
+ };
17
+ export type ContentReferenceFile = {
18
+ reference: WorkspacePortableFileReference;
19
+ fileName: string;
20
+ mimeType: string;
21
+ size?: number;
22
+ };
23
+ /** Optional source-provider hooks use the containing document's SOURCE id, not its platform id. */
24
+ export interface ContentReferenceProvider {
25
+ listReferences?(input: ContentSourceInput & ContentReferenceQuery): Promise<ContentReferencePage>;
26
+ uploadReference?(input: ContentSourceInput & ContentReferenceUpload): Promise<ContentReferenceEntry>;
27
+ resolveReference?(input: ContentSourceInput & {
28
+ target: ContentReferenceTarget;
29
+ }): Promise<ContentReferenceFile>;
30
+ }
31
+ export interface ContentReferencesApi {
32
+ list(input: ContentDocumentInput & ContentReferenceQuery): Promise<ContentReferencePage>;
33
+ upload(input: ContentDocumentInput & ContentReferenceUpload): Promise<ContentReferenceEntry>;
34
+ resolve(input: ContentDocumentInput & {
35
+ target: ContentReferenceTarget;
36
+ }): Promise<ContentReferenceFile>;
37
+ }
38
+ export declare const ContentReferencesRuntimeCapability: import("../core/runtime-capability").RuntimeCapabilityKey<ContentReferencesApi>;