@xpert-ai/plugin-sdk 3.28.0 → 3.29.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 (30) hide show
  1. package/data-workbench.cjs.js +0 -679
  2. package/data-workbench.esm.js +1 -676
  3. package/docs/artifact-presentations.md +2 -0
  4. package/docs/artifact-types.md +97 -0
  5. package/docs/data-workbench.md +37 -0
  6. package/index.cjs.js +171 -4
  7. package/index.esm.js +168 -4
  8. package/model-provider.cjs.js +5 -0
  9. package/model-provider.esm.js +5 -1
  10. package/package.json +2 -2
  11. package/src/data-workbench.d.ts +0 -2
  12. package/src/index.d.ts +1 -0
  13. package/src/lib/agent/middleware/capabilities/execution-observability.d.ts +26 -0
  14. package/src/lib/agent/middleware/capabilities/index.d.ts +1 -0
  15. package/src/lib/artifact-type/definition.schema.d.ts +119 -0
  16. package/src/lib/artifact-type/index.d.ts +91 -0
  17. package/src/lib/artifact-type/registry.d.ts +25 -0
  18. package/src/lib/data/datasource/adapter.strategy.d.ts +3 -0
  19. package/src/lib/data/datasource/index.d.ts +0 -2
  20. package/src/lib/data/datasource/strategy.interface.d.ts +5 -1
  21. package/src/lib/data/datasource/types.d.ts +2 -2
  22. package/src/lib/data/datasource/workbench.d.ts +4 -3
  23. package/src/lib/runtime/capabilities/artifact-library.d.ts +52 -0
  24. package/src/lib/runtime/capabilities/artifacts.d.ts +15 -0
  25. package/src/lib/runtime/capabilities/index.d.ts +1 -0
  26. package/src/lib/data/datasource/workbench-adapter.d.ts +0 -51
  27. package/src/lib/data/datasource/workbench-pagination.d.ts +0 -6
  28. package/src/lib/data/datasource/workbench-sql-lexer.d.ts +0 -11
  29. package/src/lib/data/datasource/workbench-sql-syntax.d.ts +0 -3
  30. package/src/lib/data/datasource/workbench-sql.d.ts +0 -20
@@ -198,6 +198,10 @@ const ArtifactsRuntimeCapability = createRuntimeCapability('platform.artifacts',
198
198
  description: 'Create, version, preview, download, share, archive, and delete platform-managed plugin and Agent artifacts.'
199
199
  });
200
200
 
201
+ const ArtifactLibraryRuntimeCapability = createRuntimeCapability('platform.artifact-library', {
202
+ description: 'Add governed Artifact references to a Project content catalog and manage their published links.'
203
+ });
204
+
201
205
  const ArtifactDraftsRuntimeCapability = createRuntimeCapability('platform.artifact-drafts', {
202
206
  description: 'Persist working copies with optimistic concurrency; atomically publish a confirmed revision as an immutable Artifact version.'
203
207
  });
@@ -426,6 +430,7 @@ function normalizeWorkspaceScope(scope) {
426
430
  exports.ActorTokenRuntimeCapability = ActorTokenRuntimeCapability;
427
431
  exports.ActorTokenRuntimeFactoryCapability = ActorTokenRuntimeFactoryCapability;
428
432
  exports.ArtifactDraftsRuntimeCapability = ArtifactDraftsRuntimeCapability;
433
+ exports.ArtifactLibraryRuntimeCapability = ArtifactLibraryRuntimeCapability;
429
434
  exports.ArtifactsRuntimeCapability = ArtifactsRuntimeCapability;
430
435
  exports.AssistantMiddlewareAccessRuntimeCapability = AssistantMiddlewareAccessRuntimeCapability;
431
436
  exports.BaseTool = BaseTool;
@@ -196,6 +196,10 @@ const ArtifactsRuntimeCapability = createRuntimeCapability('platform.artifacts',
196
196
  description: 'Create, version, preview, download, share, archive, and delete platform-managed plugin and Agent artifacts.'
197
197
  });
198
198
 
199
+ const ArtifactLibraryRuntimeCapability = createRuntimeCapability('platform.artifact-library', {
200
+ description: 'Add governed Artifact references to a Project content catalog and manage their published links.'
201
+ });
202
+
199
203
  const ArtifactDraftsRuntimeCapability = createRuntimeCapability('platform.artifact-drafts', {
200
204
  description: 'Persist working copies with optimistic concurrency; atomically publish a confirmed revision as an immutable Artifact version.'
201
205
  });
@@ -421,4 +425,4 @@ function normalizeWorkspaceScope(scope) {
421
425
  } : {});
422
426
  }
423
427
 
424
- 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 };
428
+ 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, ArtifactLibraryRuntimeCapability as d, ArtifactsRuntimeCapability as e, AssistantMiddlewareAccessRuntimeCapability as f, BaseTool as g, BaseToolset as h, McpClientRuntimeCapability as i, ProjectFilesRuntimeCapability as j, ProjectKnowledgeRuntimeCapability as k, ProjectProvisioningRuntimeCapability as l, RestClientRuntimeCapability as m, RuntimeCapabilityProvider as n, SANDBOX_JOB_INVOCATION_PREFIX as o, SANDBOX_JOB_PROGRESS_PREFIX as p, SandboxJobRuntimeError as q, SandboxJobsRuntimeCapability as r, WORKSPACE_FILES_SOURCE as s, isSandboxJobRuntimeError as t, workspaceFileMutationPath as u, workspaceRelativeFilePathSchema as v, workspaceFileMutationMetadata as w };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpert-ai/plugin-sdk",
3
- "version": "3.28.0",
3
+ "version": "3.29.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.28.0",
77
+ "@xpert-ai/contracts": "3.29.0",
78
78
  "express": "^4.22.1",
79
79
  "js-tiktoken": "^1.0.21"
80
80
  },
@@ -1,3 +1 @@
1
1
  export * from './lib/data/datasource/workbench';
2
- export * from './lib/data/datasource/workbench-sql';
3
- export * from './lib/data/datasource/workbench-adapter';
package/src/index.d.ts CHANGED
@@ -27,6 +27,7 @@ export * from './lib/managed-connection/index';
27
27
  export * from './lib/managed-queue/index';
28
28
  export * from './lib/view-extension/index';
29
29
  export * from './lib/artifact-presentation/index';
30
+ export * from './lib/artifact-type/index';
30
31
  export * from './lib/collaboration/index';
31
32
  export * from './lib/content-resource/index';
32
33
  export * from './lib/evolution/index';
@@ -0,0 +1,26 @@
1
+ import type { z } from 'zod/v3';
2
+ import type { ExecutionObservationQueryInput, ExecutionObservationOverview, ExecutionObservationList, ExecutionObservationConversations, ExecutionObservationSummary, ExecutionObservationDetail, ExecutionObservationComparison, ExecutionObservationAnomalies, executionObservationDetailQuerySchema, executionObservationCompareSchema, executionObservationAnomalySchema } from '@xpert-ai/contracts';
3
+ import { type IApiPrincipal } from '@xpert-ai/contracts';
4
+ /** Credential audience check only; the host must still revalidate the human's live admin role and grant. */
5
+ export declare function isExecutionObservationSession(principal: IApiPrincipal | null, xpertId?: string | null): boolean;
6
+ /** Read-only execution analytics. The host binds identity; arguments cannot change its authorization scope. */
7
+ export interface ExecutionObservabilityApi {
8
+ workspaces(input: {
9
+ page: number;
10
+ search?: string;
11
+ }): Promise<{
12
+ items: Array<{
13
+ id: string;
14
+ name: string;
15
+ }>;
16
+ hasMore: boolean;
17
+ }>;
18
+ overview(input: ExecutionObservationQueryInput): Promise<ExecutionObservationOverview>;
19
+ conversations(input: ExecutionObservationQueryInput): Promise<ExecutionObservationConversations>;
20
+ query(input: ExecutionObservationQueryInput): Promise<ExecutionObservationList>;
21
+ summary(input: ExecutionObservationQueryInput): Promise<ExecutionObservationSummary>;
22
+ get(input: z.input<typeof executionObservationDetailQuerySchema>): Promise<ExecutionObservationDetail>;
23
+ compare(input: z.input<typeof executionObservationCompareSchema>): Promise<ExecutionObservationComparison>;
24
+ findAnomalies(input: z.input<typeof executionObservationAnomalySchema>): Promise<ExecutionObservationAnomalies>;
25
+ }
26
+ export declare const ExecutionObservabilityRuntimeCapability: import("../../../core/runtime-capability").RuntimeCapabilityKey<ExecutionObservabilityApi>;
@@ -1,2 +1,3 @@
1
1
  export * from './assistant-task';
2
2
  export * from './file';
3
+ export * from './execution-observability';
@@ -0,0 +1,119 @@
1
+ import { z } from 'zod/v3';
2
+ /** Package exports are a runtime boundary; reject malformed declarations before registration. */
3
+ export declare const artifactTypeDefinitionSchema: z.ZodObject<{
4
+ title: z.ZodOptional<z.ZodObject<{
5
+ en_US: z.ZodString;
6
+ zh_Hans: z.ZodOptional<z.ZodString>;
7
+ zh_Hant: z.ZodOptional<z.ZodString>;
8
+ }, "strict", z.ZodTypeAny, {
9
+ en_US?: string;
10
+ zh_Hans?: string;
11
+ zh_Hant?: string;
12
+ }, {
13
+ en_US?: string;
14
+ zh_Hans?: string;
15
+ zh_Hant?: string;
16
+ }>>;
17
+ kinds: z.ZodArray<z.ZodEnum<["html", "markdown", "pdf", "pptx", "image", "file", "site", "presentation"]>, "many">;
18
+ collection: z.ZodOptional<z.ZodObject<{
19
+ allowCopy: z.ZodBoolean;
20
+ }, "strict", z.ZodTypeAny, {
21
+ allowCopy?: boolean;
22
+ }, {
23
+ allowCopy?: boolean;
24
+ }>>;
25
+ content: z.ZodOptional<z.ZodObject<{
26
+ mimeTypes: z.ZodArray<z.ZodString, "many">;
27
+ maxBytes: z.ZodNumber;
28
+ }, "strict", z.ZodTypeAny, {
29
+ mimeTypes?: string[];
30
+ maxBytes?: number;
31
+ }, {
32
+ mimeTypes?: string[];
33
+ maxBytes?: number;
34
+ }>>;
35
+ sharing: z.ZodOptional<z.ZodObject<{
36
+ accessModes: z.ZodArray<z.ZodEnum<["owner_only", "workspace_all", "organization_all", "custom_principals", "public_link", "signed_preview"]>, "many">;
37
+ versionModes: z.ZodArray<z.ZodEnum<["latest", "version"]>, "many">;
38
+ maxTtlSeconds: z.ZodOptional<z.ZodNumber>;
39
+ allowDownload: z.ZodBoolean;
40
+ mutableLinks: z.ZodBoolean;
41
+ descriptor: z.ZodBoolean;
42
+ shareKey: z.ZodOptional<z.ZodString>;
43
+ }, "strict", z.ZodTypeAny, {
44
+ accessModes?: ("owner_only" | "workspace_all" | "organization_all" | "custom_principals" | "public_link" | "signed_preview")[];
45
+ versionModes?: ("version" | "latest")[];
46
+ maxTtlSeconds?: number;
47
+ allowDownload?: boolean;
48
+ mutableLinks?: boolean;
49
+ descriptor?: boolean;
50
+ shareKey?: string;
51
+ }, {
52
+ accessModes?: ("owner_only" | "workspace_all" | "organization_all" | "custom_principals" | "public_link" | "signed_preview")[];
53
+ versionModes?: ("version" | "latest")[];
54
+ maxTtlSeconds?: number;
55
+ allowDownload?: boolean;
56
+ mutableLinks?: boolean;
57
+ descriptor?: boolean;
58
+ shareKey?: string;
59
+ }>>;
60
+ presentation: z.ZodObject<{
61
+ mode: z.ZodEnum<["file", "snapshot", "authenticated"]>;
62
+ }, "strict", z.ZodTypeAny, {
63
+ mode?: "file" | "authenticated" | "snapshot";
64
+ }, {
65
+ mode?: "file" | "authenticated" | "snapshot";
66
+ }>;
67
+ }, "strict", z.ZodTypeAny, {
68
+ title?: {
69
+ en_US?: string;
70
+ zh_Hans?: string;
71
+ zh_Hant?: string;
72
+ };
73
+ collection?: {
74
+ allowCopy?: boolean;
75
+ };
76
+ content?: {
77
+ mimeTypes?: string[];
78
+ maxBytes?: number;
79
+ };
80
+ presentation?: {
81
+ mode?: "file" | "authenticated" | "snapshot";
82
+ };
83
+ kinds?: ("file" | "image" | "html" | "markdown" | "pdf" | "pptx" | "site" | "presentation")[];
84
+ sharing?: {
85
+ accessModes?: ("owner_only" | "workspace_all" | "organization_all" | "custom_principals" | "public_link" | "signed_preview")[];
86
+ versionModes?: ("version" | "latest")[];
87
+ maxTtlSeconds?: number;
88
+ allowDownload?: boolean;
89
+ mutableLinks?: boolean;
90
+ descriptor?: boolean;
91
+ shareKey?: string;
92
+ };
93
+ }, {
94
+ title?: {
95
+ en_US?: string;
96
+ zh_Hans?: string;
97
+ zh_Hant?: string;
98
+ };
99
+ collection?: {
100
+ allowCopy?: boolean;
101
+ };
102
+ content?: {
103
+ mimeTypes?: string[];
104
+ maxBytes?: number;
105
+ };
106
+ presentation?: {
107
+ mode?: "file" | "authenticated" | "snapshot";
108
+ };
109
+ kinds?: ("file" | "image" | "html" | "markdown" | "pdf" | "pptx" | "site" | "presentation")[];
110
+ sharing?: {
111
+ accessModes?: ("owner_only" | "workspace_all" | "organization_all" | "custom_principals" | "public_link" | "signed_preview")[];
112
+ versionModes?: ("version" | "latest")[];
113
+ maxTtlSeconds?: number;
114
+ allowDownload?: boolean;
115
+ mutableLinks?: boolean;
116
+ descriptor?: boolean;
117
+ shareKey?: string;
118
+ };
119
+ }>;
@@ -0,0 +1,91 @@
1
+ import type { ArtifactAccessMode, ArtifactKind, ArtifactLinkVersionMode, ArtifactTypeReference, I18nObject } from '@xpert-ai/contracts';
2
+ import type { ContentOperation } from '../content-resource';
3
+ import type { ArtifactLinkAccessInput } from '../runtime/capabilities/artifacts';
4
+ export declare const ARTIFACT_TYPE_PROVIDER = "XPERT_ARTIFACT_TYPE_PROVIDER";
5
+ /** The loader supplies plugin identity. A contribution cannot select another plugin's namespace. */
6
+ export declare const ArtifactTypeProvider: (resourceType: string) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
7
+ export type ArtifactTypeSource = ArtifactTypeReference & {
8
+ resourceId: string;
9
+ tenantId?: string | null;
10
+ organizationId?: string | null;
11
+ userId?: string | null;
12
+ workspaceId?: string | null;
13
+ projectId?: string | null;
14
+ xpertId?: string | null;
15
+ };
16
+ export type ArtifactTypeActor = {
17
+ tenantId?: string | null;
18
+ userId?: string | null;
19
+ };
20
+ export type ArtifactTypeLink = {
21
+ accessMode: ArtifactAccessMode;
22
+ versionMode: ArtifactLinkVersionMode;
23
+ expiresAt?: Date | string | null;
24
+ allowDownload?: boolean;
25
+ };
26
+ export interface ArtifactTypeDefinition {
27
+ /** Localized semantic type name shown by libraries independently of the storage/rendering kind. */
28
+ title?: I18nObject;
29
+ kinds: readonly ArtifactKind[];
30
+ /** Copying bytes into another Project changes their lifecycle and sharing boundary. Custom views must opt in. */
31
+ collection?: {
32
+ allowCopy: boolean;
33
+ };
34
+ content?: {
35
+ mimeTypes: readonly string[];
36
+ maxBytes: number;
37
+ };
38
+ sharing?: {
39
+ accessModes: readonly ArtifactAccessMode[];
40
+ versionModes: readonly ArtifactLinkVersionMode[];
41
+ maxTtlSeconds?: number;
42
+ allowDownload: boolean;
43
+ mutableLinks: boolean;
44
+ descriptor: boolean;
45
+ shareKey?: string;
46
+ };
47
+ /** Built-in surfaces are resolved by host composition; plugins use the platform viewer. */
48
+ presentation: {
49
+ mode: 'file';
50
+ } | {
51
+ mode: 'snapshot';
52
+ } | {
53
+ mode: 'authenticated';
54
+ };
55
+ }
56
+ export interface ArtifactSnapshotContext {
57
+ /** This is the export's scope, not an authenticated principal. */
58
+ source: ArtifactTypeSource;
59
+ viewer: {
60
+ kind: 'anonymous';
61
+ } | {
62
+ kind: 'authenticated';
63
+ actor: {
64
+ tenantId: string;
65
+ userId: string;
66
+ };
67
+ };
68
+ content: Buffer;
69
+ }
70
+ /** Snapshot renderers receive only the already-authorized version. They expose no query channel. */
71
+ interface ArtifactSnapshotReader {
72
+ read(context: ArtifactSnapshotContext): Promise<object>;
73
+ }
74
+ export type ArtifactSnapshotProvider = ArtifactSnapshotReader & ({
75
+ kind: 'host';
76
+ } | {
77
+ kind: 'plugin';
78
+ getEntry(): Promise<{
79
+ html: string;
80
+ }>;
81
+ });
82
+ export interface IArtifactTypeProvider {
83
+ readonly definition: ArtifactTypeDefinition;
84
+ authorize(source: ArtifactTypeSource, actor: ArtifactTypeActor, operation: ContentOperation): Promise<void>;
85
+ validateContent(content: Buffer, mimeType: string): Promise<void> | void;
86
+ assertPublication?(source: ArtifactTypeSource, access: ArtifactLinkAccessInput): Promise<void> | void;
87
+ assertLink?(source: ArtifactTypeSource, link: ArtifactTypeLink): Promise<void> | void;
88
+ readonly snapshot?: ArtifactSnapshotProvider;
89
+ }
90
+ export * from './registry';
91
+ export type { ArtifactTypeReference, ArtifactTypeBinding } from '@xpert-ai/contracts';
@@ -0,0 +1,25 @@
1
+ import { DiscoveryService, Reflector } from '@nestjs/core';
2
+ import type { ArtifactTypeBinding, ArtifactTypeReference } from '@xpert-ai/contracts';
3
+ import { BaseStrategyRegistry, type StrategySource } from '../strategy';
4
+ import { type IArtifactTypeProvider } from './index';
5
+ export declare const artifactTypeKey: (type: ArtifactTypeReference) => string;
6
+ export declare const FILE_ARTIFACT_TYPE: ArtifactTypeReference;
7
+ /** Bindings pin registration scope. Removal never falls back to a different installation or plain file. */
8
+ export declare class ArtifactTypeRegistry extends BaseStrategyRegistry<IArtifactTypeProvider> {
9
+ constructor(discovery: DiscoveryService, reflector: Reflector);
10
+ upsert(instance: unknown): void;
11
+ registerBuiltin(type: ArtifactTypeReference, provider: IArtifactTypeProvider): void;
12
+ assertCanRegister(key: string, provider: IArtifactTypeProvider, source: StrategySource): void;
13
+ bind(type: ArtifactTypeReference, scope: {
14
+ tenantId?: string | null;
15
+ organizationId?: string | null;
16
+ }): ArtifactTypeBinding;
17
+ hasType(type: ArtifactTypeReference, scope: {
18
+ tenantId?: string | null;
19
+ organizationId?: string | null;
20
+ }): boolean;
21
+ requireBinding(binding: ArtifactTypeBinding, scope: {
22
+ tenantId?: string | null;
23
+ organizationId?: string | null;
24
+ }): IArtifactTypeProvider;
25
+ }
@@ -9,6 +9,9 @@ export declare abstract class AdapterDataSourceStrategy<TOptions extends Adapter
9
9
  private readonly extraArgs;
10
10
  abstract readonly type: string;
11
11
  abstract readonly name: string;
12
+ readonly workbench?: {
13
+ readonly engine: string;
14
+ };
12
15
  readonly description?: string;
13
16
  private configurationSchemaCache;
14
17
  private runners;
@@ -4,6 +4,4 @@ export * from './strategy.registry';
4
4
  export * from './adapter.strategy';
5
5
  export * from './types';
6
6
  export * from './workbench';
7
- export * from './workbench-sql';
8
- export * from './workbench-adapter';
9
7
  export * from '../analytics';
@@ -1,8 +1,12 @@
1
- import { AdapterBaseOptions, DBQueryRunner, DBQueryRunnerType } from "./types";
1
+ import { AdapterBaseOptions, DBQueryRunner, DBQueryRunnerType } from './types';
2
2
  export interface IDataSourceStrategy<TOptions extends AdapterBaseOptions = AdapterBaseOptions> {
3
3
  readonly type: string;
4
4
  readonly name: string;
5
5
  readonly description?: string;
6
+ /** Explicit opt-in to scoped Workbench execution. Engine IDs are owned by plugins. */
7
+ readonly workbench?: {
8
+ readonly engine: string;
9
+ };
6
10
  /**
7
11
  * Create a query runner for the given data source options.
8
12
  */
@@ -1,6 +1,6 @@
1
1
  import * as _axios from 'axios';
2
2
  import { Readable } from 'stream';
3
- import type { DatabaseWorkbenchAdapter } from './workbench';
3
+ import type { DatabaseLocation, DatabaseWorkbenchAdapter } from './workbench';
4
4
  import { IColumnDef, IDataSourceCapabilityQuery, IDSSchema, IDSTable } from '@xpert-ai/contracts';
5
5
  export type { IColumnDef, IDataSourceCapabilityQuery, IDSSchema, IDSTable } from '@xpert-ai/contracts';
6
6
  /**
@@ -49,7 +49,7 @@ export interface QueryResult<T = unknown> {
49
49
  * - Connect different types of data sources
50
50
  */
51
51
  export interface DBQueryRunner {
52
- getWorkbenchAdapter?(): DatabaseWorkbenchAdapter;
52
+ getWorkbenchAdapter?(location?: DatabaseLocation): DatabaseWorkbenchAdapter;
53
53
  type: string;
54
54
  name: string;
55
55
  syntax: DBSyntaxEnum;
@@ -1,11 +1,12 @@
1
- /** Shared wire contract. Credentials and driver objects never cross this boundary. */
2
- export type DatabaseEngine = 'doris' | 'mysql' | 'postgres';
1
+ /** Stable plugin engine identifier. Credentials and driver objects never cross this wire contract. */
2
+ export type DatabaseEngine = string;
3
3
  export type DatabaseValue = string | number | boolean | null;
4
4
  export type DatabaseObjectKind = 'table' | 'view';
5
5
  export interface DatabaseLocation {
6
+ /** Plugins validate whether a requested database can differ from the saved connection. */
6
7
  database?: string;
7
8
  schema?: string;
8
- /** Doris external catalog; legacy QueryOptions.catalog continues to mean database. */
9
+ /** Optional engine catalog interpreted and validated by the database plugin. */
9
10
  engineCatalog?: string;
10
11
  }
11
12
  export interface DatabaseObjectRef extends DatabaseLocation {
@@ -0,0 +1,52 @@
1
+ import type { ContentDocumentScope } from '../../content-resource';
2
+ import type { ArtifactLinkRecord } from './artifacts';
3
+ import type { ArtifactTypeDescriptor } from '@xpert-ai/contracts';
4
+ export type ArtifactLibraryScope = ContentDocumentScope;
5
+ export interface ArtifactLibraryItem {
6
+ id: string;
7
+ artifactId: string;
8
+ versionId: string;
9
+ title: string;
10
+ type?: ArtifactTypeDescriptor;
11
+ revision: number;
12
+ url: string;
13
+ canManage: boolean;
14
+ versions: Array<{
15
+ id: string;
16
+ number: number;
17
+ title: string;
18
+ }>;
19
+ sharing: {
20
+ accessModes: Array<'organization_all' | 'public_link'>;
21
+ maxDays: number;
22
+ link: ArtifactLinkRecord | null;
23
+ } | null;
24
+ }
25
+ /** Spaces is a consumer; adding a reference never grants source access or publishes a share. */
26
+ export interface ArtifactLibraryApi {
27
+ add(input: ArtifactLibraryScope & {
28
+ artifactId: string;
29
+ versionId: string;
30
+ }): Promise<{
31
+ referenceId: string;
32
+ contentId: string;
33
+ }>;
34
+ open(input: ArtifactLibraryScope & {
35
+ referenceId: string;
36
+ }): Promise<ArtifactLibraryItem>;
37
+ selectVersion(input: ArtifactLibraryScope & {
38
+ referenceId: string;
39
+ versionId: string;
40
+ expectedRevision: number;
41
+ }): Promise<void>;
42
+ share(input: ArtifactLibraryScope & {
43
+ referenceId: string;
44
+ accessMode: 'organization_all' | 'public_link';
45
+ days: number;
46
+ acknowledgePublic?: boolean;
47
+ }): Promise<ArtifactLinkRecord>;
48
+ revoke(input: ArtifactLibraryScope & {
49
+ referenceId: string;
50
+ }): Promise<void>;
51
+ }
52
+ export declare const ArtifactLibraryRuntimeCapability: import("../../core/runtime-capability").RuntimeCapabilityKey<ArtifactLibraryApi>;
@@ -20,6 +20,8 @@ export type ArtifactSourceInput = {
20
20
  };
21
21
  /** Creates or locates an Artifact container without uploading content bytes. */
22
22
  export type CreateArtifactInput = {
23
+ /** Omit for the built-in file type. Custom types must match source's pluginName/resourceType. */
24
+ type?: import('@xpert-ai/contracts').ArtifactTypeReference;
23
25
  /** Optional explicit provider key; authorizes source.resourceId without changing ownership or list visibility. */
24
26
  authorizationProviderKey?: string | null;
25
27
  source: ArtifactSourceInput;
@@ -110,6 +112,7 @@ export type ArtifactVersionRecord = {
110
112
  };
111
113
  /** Durable Artifact container returned to plugins. */
112
114
  export type ArtifactRecord = ArtifactScopeInput & {
115
+ typeBinding?: import('@xpert-ai/contracts').ArtifactTypeBinding | null;
113
116
  /** Additional resource ACL, evaluated against this record's resourceId. */
114
117
  authorizationProviderKey?: string | null;
115
118
  id: string;
@@ -203,6 +206,18 @@ export type UpdateArtifactLinkAccessInput = {
203
206
  };
204
207
  /** Platform runtime capability exposed to plugins for managing generated Artifacts. */
205
208
  export interface ArtifactsApi {
209
+ /** Authorized immutable bytes, with status, digest and type validation. Copying additionally checks the type's export policy. */
210
+ readArtifactVersion(input: {
211
+ artifactId: string;
212
+ artifactVersionId: string;
213
+ purpose: 'view' | 'copy';
214
+ }): Promise<{
215
+ artifact: ArtifactRecord;
216
+ version: ArtifactVersionRecord;
217
+ buffer: Buffer;
218
+ mimeType: string;
219
+ fileName: string;
220
+ }>;
206
221
  createArtifact(input: CreateArtifactInput): Promise<ArtifactRecord>;
207
222
  findArtifactBySource(input: FindArtifactBySourceInput): Promise<ArtifactRecord | null>;
208
223
  createArtifactVersion(input: CreateArtifactVersionInput): Promise<ArtifactVersionRecord>;
@@ -1,5 +1,6 @@
1
1
  export * from './actor-token';
2
2
  export * from './artifacts';
3
+ export * from './artifact-library';
3
4
  export * from './artifact-drafts';
4
5
  export * from './workspace-files';
5
6
  export * from './workspace-storage';
@@ -1,51 +0,0 @@
1
- /**
2
- * Why this exists: existing SQL Workbench plugins share this SDK implementation.
3
- * Validation, quoting, pagination, metadata and transaction SQL couple it to PostgreSQL/MySQL/Doris.
4
- * TODO: move those behaviors into plugin-owned implementations of DatabaseWorkbenchAdapter;
5
- * retain SDK interfaces/result types and dialect-independent execution helpers for reuse.
6
- * Migrate existing callers with equivalent read-only/security tests before removing legacy guards.
7
- * Host authorization/execution limits and generic Dataset/Binding must remain independent of dialects.
8
- */
9
- import type { DatabaseCapabilities, DatabaseEngine, DatabaseImportInput, DatabaseImportReceipt, DatabaseLocation, DatabaseObjectDetail, DatabaseObjectPage, DatabaseObjectRef, DatabaseQueryInput, DatabaseResult, DatabaseValue, DatabaseWorkbenchAdapter } from './workbench';
10
- export interface WorkbenchTransport {
11
- execute(sql: string, parameters: DatabaseValue[], options: {
12
- timeoutMs: number;
13
- maxRows: number;
14
- signal?: AbortSignal;
15
- }): Promise<DatabaseResult>;
16
- close(): Promise<void>;
17
- importRows?(input: DatabaseImportInput, signal?: AbortSignal): Promise<DatabaseImportReceipt>;
18
- }
19
- /**
20
- * One adapter per physical connection. A host session must not share it across users.
21
- * @deprecated Legacy SDK-owned SQL dialects. New plugins should implement DatabaseWorkbenchAdapter
22
- * with plugin-owned dialect behavior. Retained for compatibility with existing plugins.
23
- */
24
- export declare class SqlDatabaseWorkbenchAdapter implements DatabaseWorkbenchAdapter {
25
- readonly engine: DatabaseEngine;
26
- private readonly transport;
27
- private readonly initial;
28
- private version?;
29
- private transactionOpen;
30
- private busy;
31
- private closed;
32
- constructor(engine: DatabaseEngine, transport: WorkbenchTransport, initial?: DatabaseLocation);
33
- private quote;
34
- private ref;
35
- private assertLocation;
36
- private raw;
37
- capabilities(): Promise<DatabaseCapabilities>;
38
- locations(): Promise<DatabaseLocation[]>;
39
- objects(input: DatabaseLocation & {
40
- search?: string;
41
- page?: number;
42
- pageSize?: number;
43
- }): Promise<DatabaseObjectPage>;
44
- describe(object: DatabaseObjectRef): Promise<DatabaseObjectDetail>;
45
- query(input: DatabaseQueryInput, signal?: AbortSignal): Promise<DatabaseResult>;
46
- explain(input: Omit<DatabaseQueryInput, 'mode'>, signal?: AbortSignal): Promise<DatabaseResult>;
47
- transaction(action: 'begin' | 'commit' | 'rollback'): Promise<void>;
48
- importRows(input: DatabaseImportInput, signal?: AbortSignal): Promise<DatabaseImportReceipt>;
49
- cancel(): Promise<void>;
50
- close(): Promise<void>;
51
- }
@@ -1,6 +0,0 @@
1
- import type { DatabaseValue } from './workbench';
2
- /** Apply a page to a MySQL result without turning its (possibly duplicate) output names into table columns. */
3
- export declare function paginateMysqlQuery(sql: string, parameters: DatabaseValue[], limit: number, offset: number): {
4
- sql: string;
5
- parameters: DatabaseValue[];
6
- };
@@ -1,11 +0,0 @@
1
- export interface SqlToken {
2
- text: string;
3
- start: number;
4
- end: number;
5
- kind: 'word' | 'number' | 'symbol' | 'identifier' | 'literal';
6
- }
7
- /** Mask comments and quoted content without changing source offsets. Shared by guards and pagination. */
8
- export declare function lexWorkbenchSql(source: string): {
9
- masked: string;
10
- tokens: SqlToken[];
11
- };
@@ -1,3 +0,0 @@
1
- import type { SqlToken } from './workbench-sql-lexer';
2
- /** Positions where name(...) declares columns or a built-in type, rather than invoking a function. */
3
- export declare function sqlDeclarationPositions(tokens: SqlToken[]): Set<number>;
@@ -1,20 +0,0 @@
1
- export interface SqlStatement {
2
- sql: string;
3
- words: string[];
4
- effect: 'read' | 'write' | 'unsupported';
5
- }
6
- /**
7
- * @deprecated Mixed-dialect Workbench policy. New adapters should own dialect-aware statement
8
- * validation. Existing callers must retain this guard until an equivalent replacement is in place.
9
- */
10
- export declare function splitWorkbenchSql(source: string): SqlStatement[];
11
- /**
12
- * @deprecated Uses the legacy mixed-dialect policy. New adapters should enforce read-only execution
13
- * with dialect-aware validation and database permissions. Keep this guard until safely migrated.
14
- */
15
- export declare function requireReadStatement(sql: string): string;
16
- /**
17
- * @deprecated Built-in engine switch. New adapters should own dialect-specific identifier quoting
18
- * while preserving identifier validation and escaping.
19
- */
20
- export declare function quoteDatabaseIdentifier(name: string, engine: 'doris' | 'mysql' | 'postgres'): string;