@xpert-ai/plugin-sdk 3.27.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 (60) hide show
  1. package/collaboration-client.cjs.js +31 -5
  2. package/collaboration-client.esm.js +31 -5
  3. package/data-workbench.cjs.js +0 -679
  4. package/data-workbench.esm.js +1 -676
  5. package/docs/artifact-presentations.md +2 -0
  6. package/docs/artifact-types.md +97 -0
  7. package/docs/data-workbench.md +37 -0
  8. package/index.cjs.js +481 -49
  9. package/index.esm.js +469 -49
  10. package/model-provider.cjs.js +7 -1
  11. package/model-provider.esm.js +7 -2
  12. package/package.json +2 -2
  13. package/src/data-workbench.d.ts +0 -2
  14. package/src/index.d.ts +2 -0
  15. package/src/lib/agent/handoff/types.d.ts +5 -0
  16. package/src/lib/agent/middleware/capabilities/assistant-task.d.ts +6 -1
  17. package/src/lib/agent/middleware/capabilities/execution-observability.d.ts +26 -0
  18. package/src/lib/agent/middleware/capabilities/index.d.ts +1 -0
  19. package/src/lib/agent/runtime/capability.d.ts +4 -0
  20. package/src/lib/agent/runtime/cli-model-profile.d.ts +1 -1
  21. package/src/lib/agent/runtime/execution-runner.d.ts +11 -0
  22. package/src/lib/agent/runtime/index.d.ts +2 -0
  23. package/src/lib/agent/runtime/managed.d.ts +94 -0
  24. package/src/lib/agent/runtime/process-supervisor.d.ts +1 -0
  25. package/src/lib/agent/runtime/strategy.d.ts +14 -0
  26. package/src/lib/agent/runtime/types.d.ts +30 -1
  27. package/src/lib/ai-model/native-model.d.ts +5 -1
  28. package/src/lib/artifact-type/definition.schema.d.ts +119 -0
  29. package/src/lib/artifact-type/index.d.ts +91 -0
  30. package/src/lib/artifact-type/registry.d.ts +25 -0
  31. package/src/lib/assistant-capability/index.d.ts +1 -0
  32. package/src/lib/assistant-capability/middleware.d.ts +10 -0
  33. package/src/lib/collaboration/types.d.ts +5 -0
  34. package/src/lib/content-resource/catalog.d.ts +88 -0
  35. package/src/lib/content-resource/editor-compatibility.d.ts +3 -0
  36. package/src/lib/content-resource/editor.d.ts +35 -3
  37. package/src/lib/content-resource/index.d.ts +3 -0
  38. package/src/lib/data/datasource/adapter.strategy.d.ts +3 -0
  39. package/src/lib/data/datasource/index.d.ts +0 -2
  40. package/src/lib/data/datasource/strategy.interface.d.ts +5 -1
  41. package/src/lib/data/datasource/types.d.ts +2 -2
  42. package/src/lib/data/datasource/workbench.d.ts +4 -3
  43. package/src/lib/execution-control/context.d.ts +7 -0
  44. package/src/lib/execution-control/index.d.ts +2 -0
  45. package/src/lib/managed-queue/index.d.ts +12 -0
  46. package/src/lib/runtime/capabilities/artifact-drafts.d.ts +10 -1
  47. package/src/lib/runtime/capabilities/artifact-library.d.ts +52 -0
  48. package/src/lib/runtime/capabilities/artifacts.d.ts +15 -0
  49. package/src/lib/runtime/capabilities/index.d.ts +1 -0
  50. package/src/lib/runtime/capabilities/mcp-client-runtime.d.ts +2 -0
  51. package/src/lib/runtime/capabilities/sandbox-jobs.d.ts +12 -3
  52. package/src/lib/sandbox/file-edit-command.d.ts +2 -0
  53. package/src/lib/sandbox/file-edit-diff.d.ts +1 -0
  54. package/src/lib/sandbox/protocol.d.ts +13 -1
  55. package/src/lib/sandbox/runtime-provider.d.ts +12 -0
  56. package/src/lib/data/datasource/workbench-adapter.d.ts +0 -51
  57. package/src/lib/data/datasource/workbench-pagination.d.ts +0 -6
  58. package/src/lib/data/datasource/workbench-sql-lexer.d.ts +0 -11
  59. package/src/lib/data/datasource/workbench-sql-syntax.d.ts +0 -3
  60. package/src/lib/data/datasource/workbench-sql.d.ts +0 -20
@@ -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
+ }
@@ -1,6 +1,7 @@
1
1
  import { DiscoveryService, Reflector } from '@nestjs/core';
2
2
  import type { I18nObject, LanguagesEnum, ModelFeature, TXpertTeamDraft, TXpertTemplate } from '@xpert-ai/contracts';
3
3
  import { BaseStrategyRegistry } from '../strategy';
4
+ export { applyAssistantMiddleware, hasAssistantMiddleware } from './middleware';
4
5
  export interface AssistantCapabilityContext {
5
6
  template: TXpertTemplate;
6
7
  draft: TXpertTeamDraft;
@@ -0,0 +1,10 @@
1
+ import { type TXpertTeamDraft } from '@xpert-ai/contracts';
2
+ export declare function hasAssistantMiddleware(draft: TXpertTeamDraft, provider: string): boolean;
3
+ /** Compose only the draft graph. The platform records the contribution for safe removal.
4
+ * No Project, permission, external resource or implicit replacement is created here. */
5
+ export declare function applyAssistantMiddleware(draft: TXpertTeamDraft, input: {
6
+ provider: string;
7
+ key: string;
8
+ title: string;
9
+ instructions: string;
10
+ }): void;
@@ -147,6 +147,11 @@ export interface CollaborationApi {
147
147
  archiveDocument(input: GetCollaborationDocumentInput & {
148
148
  expectedSequence?: number;
149
149
  }): Promise<CollaborationDocumentRecord>;
150
+ /** Reopen an archived document after the provider's current manage authorization.
151
+ * State and sequence are retained; this cannot resurrect a deleted document. */
152
+ restoreDocument(input: GetCollaborationDocumentInput & {
153
+ expectedSequence?: number;
154
+ }): Promise<CollaborationDocumentRecord>;
150
155
  /** Soft-delete the platform document and notify its provider. */
151
156
  deleteDocument(input: GetCollaborationDocumentInput): Promise<CollaborationDocumentRecord>;
152
157
  }
@@ -0,0 +1,88 @@
1
+ import type { ContentCatalogItem, ContentResourceSnapshot, ContentTypeImplementation, ContentSearchProjection } from '@xpert-ai/contracts';
2
+ import type { ContentDocumentScope } from './document';
3
+ import type { ContentResourceReference, ContentSourceInput } from './index';
4
+ export type ContentResourceMutation = {
5
+ action: 'rename';
6
+ title: string;
7
+ } | {
8
+ action: 'move';
9
+ rootPath: string;
10
+ } | {
11
+ action: 'trash' | 'restore';
12
+ } | {
13
+ action: 'duplicate';
14
+ requestId: string;
15
+ title: string;
16
+ };
17
+ /** Plugins retain their native model and ACL. Discovery is scoped and paginated, never a grant. */
18
+ export interface ContentCatalogProvider {
19
+ readonly types: ContentTypeImplementation[];
20
+ discover(scope: ContentDocumentScope & {
21
+ cursor?: string;
22
+ }): Promise<{
23
+ resourceIds: string[];
24
+ nextCursor?: string;
25
+ }>;
26
+ describe(input: ContentSourceInput): Promise<ContentResourceSnapshot>;
27
+ /** Optional safe text extractor. Must read the requested revision or reject a concurrent change. */
28
+ extract?(input: ContentSourceInput & {
29
+ expectedRevision: string;
30
+ }): Promise<ContentSearchProjection>;
31
+ create(input: ContentDocumentScope & {
32
+ implementationKey: string;
33
+ requestId: string;
34
+ title: string;
35
+ templateId?: string;
36
+ }): Promise<ContentResourceReference>;
37
+ /** Idempotent repair of derived files only; must never overwrite newer native content. */
38
+ reconcile?(input: ContentSourceInput): Promise<void>;
39
+ /** Optional project-local derived index consumer. Called by durable reconciliation,
40
+ * including tombstones; must revalidate revision and never change the resource. */
41
+ onResourceReconciled?(input: ContentDocumentScope & {
42
+ item: ContentCatalogItem;
43
+ }): Promise<void>;
44
+ mutate?(input: ContentSourceInput & {
45
+ expectedRevision: string;
46
+ change: ContentResourceMutation;
47
+ }): Promise<ContentResourceReference>;
48
+ }
49
+ export interface ContentCatalogApi {
50
+ types(scope: ContentDocumentScope): Promise<Array<ContentTypeImplementation & {
51
+ providerKey: string;
52
+ }>>;
53
+ /** Reconciles registered providers before listing. The caller may continue with the returned cursor. */
54
+ list(scope: ContentDocumentScope & {
55
+ excludedProviderKeys?: string[];
56
+ contentIds?: string[];
57
+ typeId?: string;
58
+ search?: string;
59
+ deleted?: boolean;
60
+ offset?: number;
61
+ limit?: number;
62
+ }): Promise<{
63
+ items: ContentCatalogItem[];
64
+ hasMore: boolean;
65
+ }>;
66
+ register(input: ContentDocumentScope & {
67
+ source: ContentResourceReference;
68
+ }): Promise<ContentCatalogItem>;
69
+ get(input: ContentDocumentScope & {
70
+ contentId: string;
71
+ }): Promise<ContentCatalogItem>;
72
+ projectText(input: ContentDocumentScope & {
73
+ contentId: string;
74
+ expectedRevision: string;
75
+ }): Promise<ContentSearchProjection | null>;
76
+ create(input: ContentDocumentScope & {
77
+ providerKey: string;
78
+ implementationKey: string;
79
+ requestId: string;
80
+ title: string;
81
+ templateId?: string;
82
+ }): Promise<ContentCatalogItem>;
83
+ mutate(input: ContentDocumentScope & {
84
+ contentId: string;
85
+ expectedRevision: string;
86
+ change: ContentResourceMutation;
87
+ }): Promise<ContentCatalogItem>;
88
+ }
@@ -0,0 +1,3 @@
1
+ import type { ContentModelIdentity, ResourceContentEditorRegistration } from '@xpert-ai/contracts';
2
+ /** Matching semantic type alone never grants a writer access to an incompatible native model. */
3
+ export declare function supportsContentModel(editor: ResourceContentEditorRegistration, model: ContentModelIdentity, access: 'view' | 'edit'): boolean;
@@ -1,16 +1,22 @@
1
1
  import { DiscoveryService, Reflector } from '@nestjs/core';
2
- import type { ContentEditorRegistration, FileContentEditorRegistration } from '@xpert-ai/contracts';
2
+ import type { ContentEditorRegistration, FileContentEditorRegistration, ResourceContentEditorRegistration } from '@xpert-ai/contracts';
3
3
  import { BaseStrategyRegistry } from '../strategy';
4
4
  import type { ContentDocumentModel, ContentDocumentScope } from './document';
5
5
  import type { ContentResourceReference, ContentSourceInput } from './index';
6
+ export { supportsContentModel } from './editor-compatibility';
6
7
  /** File codecs expose no cells, blocks or plugin-specific edit operations to the platform. */
7
8
  export interface ContentFileEditor {
8
9
  readonly descriptor: FileContentEditorRegistration;
9
10
  create(): Promise<Buffer>;
10
11
  validateFile(buffer: Buffer): Promise<void>;
11
12
  }
12
- export type IContentEditorProvider = ContentDocumentModel | ContentFileEditor;
13
+ export interface ContentResourceEditorImplementation {
14
+ readonly descriptor: ResourceContentEditorRegistration;
15
+ }
16
+ export type IContentEditorProvider = ContentDocumentModel | ContentFileEditor | ContentResourceEditorImplementation;
13
17
  export declare function isTextContentEditor(provider: IContentEditorProvider): provider is ContentDocumentModel;
18
+ export declare function isFileContentEditor(provider: IContentEditorProvider): provider is ContentFileEditor;
19
+ export declare function isResourceContentEditor(provider: IContentEditorProvider): provider is ContentResourceEditorImplementation;
14
20
  export declare const ContentEditorProvider: (key: string) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
15
21
  export declare class ContentEditorRegistry extends BaseStrategyRegistry<IContentEditorProvider> {
16
22
  constructor(discovery: DiscoveryService, reflector: Reflector);
@@ -40,15 +46,41 @@ export interface ContentResourceEditor {
40
46
  }
41
47
  export type ContentEditorInput = ContentDocumentScope & {
42
48
  source: ContentResourceReference;
49
+ editorKey?: string;
43
50
  };
51
+ export type ContentEditorPreferenceScope = 'resource' | 'project' | 'organization';
52
+ export interface ContentEditorPreferenceState {
53
+ scope: ContentEditorPreferenceScope;
54
+ editorKey: string | null;
55
+ revision: number;
56
+ canSet: boolean;
57
+ }
44
58
  export interface ContentEditorResolution {
45
59
  registration: ContentEditorRegistration;
46
- file: ContentEditorFile;
60
+ file?: ContentEditorFile;
61
+ resource?: import('@xpert-ai/contracts').ContentCatalogItem;
47
62
  canWrite: boolean;
48
63
  viewKey: string;
64
+ selectionId?: string;
65
+ parameters?: {
66
+ contentProvider: string;
67
+ contentId?: string;
68
+ contentTitle?: string;
69
+ contentEditor?: string;
70
+ };
71
+ editors?: ResourceContentEditorRegistration[];
49
72
  }
50
73
  /** Trusted scope only. Every operation checks Project, Assistant binding and resource permissions. */
51
74
  export interface ContentEditorsApi {
75
+ preferences(input: ContentDocumentScope & {
76
+ contentId: string;
77
+ }): Promise<ContentEditorPreferenceState[]>;
78
+ setPreference(input: ContentDocumentScope & {
79
+ contentId: string;
80
+ scope: ContentEditorPreferenceScope;
81
+ editorKey: string | null;
82
+ expectedRevision: number;
83
+ }): Promise<ContentEditorPreferenceState>;
52
84
  list(scope: ContentDocumentScope): Promise<ContentEditorRegistration[]>;
53
85
  /** Prepare/validate bytes; does not create a resource or grant access to a destination. */
54
86
  prepare(scope: ContentDocumentScope & {
@@ -66,6 +66,7 @@ export interface IContentResourceProvider {
66
66
  readonly pages?: ContentPageProvider;
67
67
  readonly publication?: ContentPublicationObserver;
68
68
  readonly locations?: ContentLocationProvider;
69
+ readonly catalog?: import('./catalog').ContentCatalogProvider;
69
70
  }
70
71
  export declare const CONTENT_RESOURCE_PROVIDER = "XPERT_CONTENT_RESOURCE_PROVIDER";
71
72
  export declare const ContentResourceProvider: (key: string) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -84,8 +85,10 @@ export interface ContentIdentitiesApi {
84
85
  export interface ContentResourcesApi {
85
86
  readonly identities: ContentIdentitiesApi;
86
87
  authorize(input: ContentResourceRequest): Promise<ContentResourceDescriptor>;
88
+ readonly catalog: import('./catalog').ContentCatalogApi;
87
89
  }
88
90
  export declare const ContentResourcesRuntimeCapability: import("../core/runtime-capability").RuntimeCapabilityKey<ContentResourcesApi>;
89
91
  export * from './document';
90
92
  export * from './reference';
91
93
  export * from './editor';
94
+ export * from './catalog';
@@ -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,7 @@
1
+ import type { TaskControlRef, TaskControlIntent } from '@xpert-ai/contracts';
2
+ /** A handler may check control at a safe boundary; abort alone is not an exit receipt. */
3
+ export interface TaskControlContext {
4
+ reference: TaskControlRef;
5
+ signal: AbortSignal;
6
+ desired(): Promise<TaskControlIntent>;
7
+ }
@@ -0,0 +1,2 @@
1
+ export type { TaskControlRef, TaskControlPolicy, TaskControlIntent, TaskControlKind, TaskControlState } from '@xpert-ai/contracts';
2
+ export * from './context';
@@ -1,7 +1,10 @@
1
+ import type { TaskControlContext, TaskControlPolicy } from '../execution-control';
1
2
  export declare const MANAGED_QUEUE_SERVICE_TOKEN = "XPERT_MANAGED_QUEUE_SERVICE";
2
3
  export declare const MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN = "XPERT_MANAGED_QUEUE_HANDLER_REGISTRY";
3
4
  export declare const PLUGIN_JOB_PROCESSOR_METADATA = "XPERT_PLUGIN_JOB_PROCESSOR_METADATA";
4
5
  export type PluginJobProcessorOptions = {
6
+ /** Explicit handler compatibility contract for controlled jobs; not a package version. */
7
+ controlContract?: string;
5
8
  pluginName: string;
6
9
  queueName?: string;
7
10
  queue?: string;
@@ -10,6 +13,7 @@ export type PluginJobProcessorOptions = {
10
13
  concurrency?: number;
11
14
  };
12
15
  export type PluginJobProcessorMetadata = {
16
+ controlContract?: string;
13
17
  pluginName: string;
14
18
  queueName: string;
15
19
  jobName: string;
@@ -42,6 +46,12 @@ export type ManagedQueueRedis = {
42
46
  eval(script: string, numKeys: number, ...args: Array<string | number>): Promise<unknown>;
43
47
  };
44
48
  export type ManagedQueueEnqueueInput<TPayload = unknown> = {
49
+ /** Trusted producer lifecycle policy; omission inherits an active host control scope. */
50
+ /** Explicitly enroll work in the current host task context; omitted retains the existing independent queue lifecycle. */
51
+ controlPolicy?: TaskControlPolicy;
52
+ /** Required when enrolling a new controlled job. Must match the registered handler. */
53
+ controlContract?: string;
54
+ drainOnPause?: boolean;
45
55
  pluginName: string;
46
56
  queueName: string;
47
57
  jobName: string;
@@ -84,6 +94,7 @@ export type ManagedQueueJob<TPayload = unknown> = {
84
94
  updateData(data: TPayload): Promise<void>;
85
95
  };
86
96
  export type ManagedQueueJobContext = {
97
+ control?: TaskControlContext;
87
98
  pluginName: string;
88
99
  queueName: string;
89
100
  jobName: string;
@@ -107,6 +118,7 @@ export interface ManagedQueueJobProcessor<TPayload = unknown> {
107
118
  handle(job: ManagedQueueJob<TPayload>, context: ManagedQueueJobContext): Promise<void> | void;
108
119
  }
109
120
  export type ManagedQueueHandlerRegistration<TPayload = unknown> = {
121
+ controlContract?: string;
110
122
  pluginName: string;
111
123
  queueName: string;
112
124
  jobName: string;
@@ -21,7 +21,16 @@ export type PublishArtifactDraftInput = {
21
21
  };
22
22
  export interface ArtifactDraftsApi {
23
23
  list(artifactIds: string[]): Promise<ArtifactDraftRecord[]>;
24
- get(artifactId: string): Promise<ArtifactDraftRecord | null>;
24
+ /** Catalog/recycle-bin reads only; ordinary editors must leave includeArchived unset. */
25
+ get(artifactId: string, options?: {
26
+ includeArchived?: boolean;
27
+ }): Promise<ArtifactDraftRecord | null>;
28
+ /** Manager-only CAS lifecycle; recycling revokes all links, restoring never reactivates them. */
29
+ setRecycled(input: {
30
+ artifactId: string;
31
+ expectedRevision: number;
32
+ recycled: boolean;
33
+ }): Promise<ArtifactDraftRecord>;
25
34
  save(input: SaveArtifactDraftInput): Promise<ArtifactDraftRecord>;
26
35
  /** Trusted application action only; never expose this operation as an Agent tool. */
27
36
  publish(input: PublishArtifactDraftInput): Promise<ArtifactVersionRecord>;
@@ -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';
@@ -23,6 +23,8 @@ export interface McpClientToolResult {
23
23
  text: string[];
24
24
  }
25
25
  export interface McpClientToolCall {
26
+ /** Stable host call identity; required inside a controlled execution to prevent replay. */
27
+ operationKey?: string;
26
28
  toolName: string;
27
29
  contractHash: string;
28
30
  arguments: Record<string, JSONValue>;
@@ -1,10 +1,12 @@
1
+ import type { SandboxJobRetryReference } from '@xpert-ai/contracts';
1
2
  import type { JSONValue } from '@xpert-ai/contracts';
2
3
  import type { WorkspaceFileScope, WorkspacePortableFileReference } from './workspace-files';
4
+ import type { TaskControlPolicy } from '../../execution-control';
3
5
  /** Stable machine-readable failures emitted by the Sandbox Jobs capability. */
4
- export declare const SANDBOX_JOB_ERROR_CODES: readonly ["SANDBOX_ACTION_UNAVAILABLE", "SANDBOX_ACTION_INVALID", "SANDBOX_PROFILE_UNAVAILABLE", "SANDBOX_RUNTIME_UNAVAILABLE", "SANDBOX_VERSION_MISMATCH", "SANDBOX_CAPACITY_UNAVAILABLE", "SANDBOX_START_FAILED", "SANDBOX_DEPENDENCY_MISSING", "EXPORT_CONVERSION_FAILED", "EXPORT_TEXT_EXTRACTION_FAILED", "SANDBOX_INVOCATION_FAILED", "BROWSER_LAUNCH_FAILED", "EXPORT_TIMEOUT", "EXPORT_OOM", "EXPORT_MEDIA_FAILED", "EXPORT_INPUT_INVALID", "EXPORT_OUTPUT_INVALID", "SANDBOX_CANCELLED"];
6
+ export declare const SANDBOX_JOB_ERROR_CODES: readonly ["SANDBOX_ACTION_UNAVAILABLE", "SANDBOX_ACTION_INVALID", "SANDBOX_PROFILE_UNAVAILABLE", "SANDBOX_RUNTIME_UNAVAILABLE", "SANDBOX_VERSION_MISMATCH", "SANDBOX_CAPACITY_UNAVAILABLE", "SANDBOX_START_FAILED", "SANDBOX_DEPENDENCY_MISSING", "EXPORT_CONVERSION_FAILED", "EXPORT_TEXT_EXTRACTION_FAILED", "SANDBOX_INVOCATION_FAILED", "BROWSER_LAUNCH_FAILED", "EXPORT_TIMEOUT", "EXPORT_OOM", "EXPORT_MEDIA_FAILED", "EXPORT_INPUT_INVALID", "EXPORT_OUTPUT_INVALID", "SANDBOX_CANCELLED", "SANDBOX_CONTROL_UNCONFIRMED"];
5
7
  export type SandboxJobErrorCode = (typeof SANDBOX_JOB_ERROR_CODES)[number];
6
8
  /** Persisted lifecycle states for a generic isolated background execution. */
7
- export type SandboxJobStatus = 'waiting' | 'starting' | 'running' | 'succeeded' | 'failed' | 'cancelled' | 'lost';
9
+ export type SandboxJobStatus = 'waiting' | 'starting' | 'running' | 'settling' | 'cancelling' | 'unknown' | 'succeeded' | 'failed' | 'cancelled' | 'lost';
8
10
  /** Line prefix used by trusted Actions to report structured, provider-neutral progress. */
9
11
  export declare const SANDBOX_JOB_PROGRESS_PREFIX = "XPERT_SANDBOX_PROGRESS ";
10
12
  /** Latest structured progress reported by a Sandbox Action or Core lifecycle stage. */
@@ -68,6 +70,8 @@ export type SandboxJobRunInput = {
68
70
  actionVersion: string;
69
71
  /** Stable tenant-scoped key combining business identity and immutable input checksum. */
70
72
  idempotencyKey: string;
73
+ /** A new call identity that explicitly retries a settled original generation. */
74
+ retryOf?: SandboxJobRetryReference;
71
75
  scope: SandboxJobScope;
72
76
  /** Small structured request; file bytes must be supplied through `files`. */
73
77
  payload: JSONValue;
@@ -89,6 +93,9 @@ export type SandboxJobOutput = {
89
93
  };
90
94
  /** Provider-neutral persisted view of a Sandbox Job and its runtime evidence. */
91
95
  export type SandboxJobSnapshot = {
96
+ /** Business result and physical completion are independent facts. */
97
+ controlState?: 'pending' | 'settled' | 'unknown';
98
+ generation?: string;
92
99
  id: string;
93
100
  runtimeProfile: string;
94
101
  sandboxRuntimeVersion: string;
@@ -137,6 +144,8 @@ export type SandboxJobInvocation = {
137
144
  };
138
145
  /** Live execution controls; kept separate from the persisted, JSON-only RunInput. */
139
146
  export type SandboxJobRunOptions = {
147
+ /** Trusted host ownership; independent/shared work must not inherit caller termination. */
148
+ controlPolicy?: TaskControlPolicy;
140
149
  /** Cancels an owned attempt; on reattachment, cancels only this caller's wait. */
141
150
  signal?: AbortSignal;
142
151
  invocation?: SandboxJobInvocation;
@@ -176,7 +185,7 @@ export type SandboxJobActionHealth = {
176
185
  export interface SandboxJobsApi {
177
186
  /** Starts, reattaches, or reuses a successful execution by tenant-scoped idempotency key. */
178
187
  run(input: SandboxJobRunInput, options?: SandboxJobRunOptions): Promise<SandboxJobRunResult>;
179
- /** Cancels the logical Job and terminates its active Runtime when one exists. */
188
+ /** Persists stop intent; terminal status is returned only after actual execution and host settlement. */
180
189
  cancel(input: {
181
190
  jobId: string;
182
191
  }): Promise<SandboxJobSnapshot>;
@@ -0,0 +1,2 @@
1
+ /** Compare actual file contents inside the sandbox; reporting must never prevent an edit. */
2
+ export declare function buildEditCommand(filePath: string, oldString: string, newString: string, replaceAll: boolean): string;
@@ -0,0 +1 @@
1
+ export declare const FILE_EDIT_DIFF_SCRIPT: string;