@xpert-ai/plugin-sdk 3.26.2 → 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 (41) 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 +15 -0
  10. package/model-provider.esm.js +13 -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 +16 -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/workspace-files.d.ts +2 -0
  41. package/src/lib/view-extension/middleware-runtime.d.ts +2 -3
@@ -1,7 +1,3 @@
1
- /** Invariants: comments/literals are lexed, never stripped with a keyword regex.
2
- * This guard is defense in depth; the database principal remains an authority boundary.
3
- * Unrecognized statements fail closed. Driver multi-statements stay disabled.
4
- */
5
1
  export interface SqlStatement {
6
2
  sql: string;
7
3
  words: string[];
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Plugin metadata may be parsed in a provider constructor, before registry discovery.
3
+ * Preserve Nest injection metadata while isolating validation failures from external plugins.
4
+ * Failed contributions never become executable templates; built-in and non-validation errors still throw.
5
+ */
6
+ import { z } from 'zod/v3';
7
+ export type PipelineContributionIssue = {
8
+ path: (string | number)[];
9
+ code: string;
10
+ };
11
+ export declare class UnavailablePipelineContribution {
12
+ readonly metatype: Function;
13
+ readonly issues: PipelineContributionIssue[];
14
+ constructor(metatype: Function, issues: PipelineContributionIssue[]);
15
+ }
16
+ export declare function pipelineContributionIssues(error: z.ZodError): PipelineContributionIssue[];
17
+ export declare function isolatePipelineContribution<T extends Function>(target: T): T;
@@ -2,13 +2,28 @@ import { DiscoveryService, Reflector } from '@nestjs/core';
2
2
  import { type ProjectPipelineContribution, type ProjectPipelineJsonValue } from '@xpert-ai/contracts';
3
3
  import { BaseStrategyRegistry, type StrategySource } from '../strategy';
4
4
  import type { ProjectAccessActor } from '../runtime/capabilities/project-access';
5
+ import { type PipelineContributionIssue } from './contribution-failure';
5
6
  export { projectPipelineContributionSchema, type ProjectPipelineContribution } from '@xpert-ai/contracts';
6
7
  export declare const PROJECT_PIPELINE_CONTRIBUTION = "PROJECT_PIPELINE_CONTRIBUTION";
7
- export declare const ProjectPipelineContributor: (key: string) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
8
+ export declare const ProjectPipelineContributor: (key: string) => ClassDecorator;
9
+ export interface ProjectPipelineContributionFailure {
10
+ key: string;
11
+ source: Extract<StrategySource, {
12
+ kind: 'plugin';
13
+ }>;
14
+ code: 'PIPELINE_CONTRIBUTION_INVALID';
15
+ issues: PipelineContributionIssue[];
16
+ }
8
17
  export declare class ProjectPipelineContributionRegistry extends BaseStrategyRegistry<ProjectPipelineContribution> {
9
18
  private readonly parsedContributions;
19
+ private readonly failures;
20
+ private readonly failureLogger;
10
21
  constructor(discovery: DiscoveryService, reflector: Reflector);
11
22
  upsert(instance: unknown): void;
23
+ getRegistrationFailures(): ProjectPipelineContributionFailure[];
24
+ remove(scopeKey: string, pluginName: string): void;
25
+ private failureIdentity;
26
+ private rejectContribution;
12
27
  register(key: string, contribution: ProjectPipelineContribution, source: StrategySource): {
13
28
  key: string;
14
29
  configurations: {
@@ -0,0 +1,10 @@
1
+ /** Trusted execution identity supplied by the host or a persisted job, never by client payloads. */
2
+ export interface RuntimeActor {
3
+ tenantId: string;
4
+ userId: string;
5
+ organizationId?: string | null;
6
+ }
7
+ /** Organization-bound operations require an explicit organization, including background executions. */
8
+ export interface OrganizationRuntimeActor extends RuntimeActor {
9
+ organizationId: string;
10
+ }
@@ -5,6 +5,7 @@ export type { ArtifactAccessMode, ArtifactKind, ArtifactLinkDisposition, Artifac
5
5
  export type ArtifactScopeInput = {
6
6
  tenantId?: string | null;
7
7
  organizationId?: string | null;
8
+ /** Omit to use the runtime user. Explicit null on creation shares ownership with projectId; the caller remains the actor. */
8
9
  userId?: string | null;
9
10
  workspaceId?: string | null;
10
11
  projectId?: string | null;
@@ -19,6 +20,8 @@ export type ArtifactSourceInput = {
19
20
  };
20
21
  /** Creates or locates an Artifact container without uploading content bytes. */
21
22
  export type CreateArtifactInput = {
23
+ /** Optional explicit provider key; authorizes source.resourceId without changing ownership or list visibility. */
24
+ authorizationProviderKey?: string | null;
22
25
  source: ArtifactSourceInput;
23
26
  kind?: ArtifactKind | null;
24
27
  title?: string | null;
@@ -107,6 +110,8 @@ export type ArtifactVersionRecord = {
107
110
  };
108
111
  /** Durable Artifact container returned to plugins. */
109
112
  export type ArtifactRecord = ArtifactScopeInput & {
113
+ /** Additional resource ACL, evaluated against this record's resourceId. */
114
+ authorizationProviderKey?: string | null;
110
115
  id: string;
111
116
  pluginName: string;
112
117
  resourceType: string;
@@ -0,0 +1,28 @@
1
+ import type { OrganizationRuntimeActor } from '../actor';
2
+ /** Match a specific connected middleware, not another provider advertising the same feature. */
3
+ export interface AssistantMiddlewareRequirement {
4
+ provider: string;
5
+ requiredFeature: string;
6
+ }
7
+ /** Chosen by trusted server context, never by tool arguments or iframe payloads. */
8
+ export type AssistantMiddlewareAccessScope = {
9
+ type: 'assistant';
10
+ } | {
11
+ type: 'project';
12
+ projectId: string;
13
+ };
14
+ export interface AssistantMiddlewareAccessApi {
15
+ /** Authorize an Assistant capability entry on every invocation, without caching grants.
16
+ * Standalone access uses the Assistant catalog policy; Project use requires current
17
+ * membership and an Assistant binding instead. Both require active organization membership.
18
+ * View providers needing configuration/runtime should use ViewMiddlewareRuntimeCapability.
19
+ * This does not grant file/resource operations. Resource ACLs and collaboration delivery
20
+ * retain their own checks and must not depend on this middleware feature remaining installed.
21
+ */
22
+ assertAccess(input: AssistantMiddlewareRequirement & {
23
+ actor: OrganizationRuntimeActor;
24
+ assistantId: string;
25
+ scope: AssistantMiddlewareAccessScope;
26
+ }): Promise<void>;
27
+ }
28
+ export declare const AssistantMiddlewareAccessRuntimeCapability: import("../../core/runtime-capability").RuntimeCapabilityKey<AssistantMiddlewareAccessApi>;
@@ -6,6 +6,10 @@ export * from './workspace-storage';
6
6
  export * from './sandbox-jobs';
7
7
  export * from './project-provisioning';
8
8
  export * from './project-access';
9
+ export * from './project-files';
9
10
  export * from './tool-images';
11
+ export * from './assistant-middleware-access';
12
+ export * from '../actor';
13
+ export * from './project-knowledge';
10
14
  export * from './mcp-client-runtime';
11
15
  export * from './rest-client-runtime';
@@ -1,19 +1,16 @@
1
1
  import type { XpertProjectClassification } from '@xpert-ai/contracts';
2
- /** Trusted server actor. View providers derive this from host context; jobs persist that actor. */
3
- export interface ProjectAccessActor {
4
- tenantId: string;
5
- organizationId?: string | null;
6
- userId: string;
7
- }
2
+ import type { RuntimeActor } from '../actor';
3
+ export type ProjectAccessActor = RuntimeActor;
8
4
  export interface ProjectHumanAccess extends XpertProjectClassification {
9
5
  projectId: string;
6
+ name?: string;
10
7
  role: 'owner' | 'manager' | 'editor' | 'member';
11
8
  canManage: boolean;
12
9
  archived: boolean;
13
10
  /** Explicit Project bindings, for plugins that choose to use assignment as business policy. */
14
11
  assistantIds?: string[];
15
12
  }
16
- /** Human membership only. Assistant assignment and business authorization remain plugin-owned. */
13
+ /** Project membership and explicit Assistant bindings. Feature activation remains Assistant-owned. */
17
14
  export interface ProjectAccessApi {
18
15
  listReadable(input: {
19
16
  actor: ProjectAccessActor;
@@ -27,5 +24,11 @@ export interface ProjectAccessApi {
27
24
  actor: ProjectAccessActor;
28
25
  projectId: string;
29
26
  }): Promise<ProjectHumanAccess>;
27
+ /** Validate an explicit Assistant connection, including published/root identity normalization. */
28
+ assertAssistant(input: {
29
+ actor: ProjectAccessActor;
30
+ projectId: string;
31
+ assistantId: string;
32
+ }): Promise<ProjectHumanAccess>;
30
33
  }
31
34
  export declare const ProjectAccessRuntimeCapability: import("../../core/runtime-capability").RuntimeCapabilityKey<ProjectAccessApi>;
@@ -0,0 +1,40 @@
1
+ import type { ProjectAccessActor } from './project-access';
2
+ export type ProjectFileScope = {
3
+ actor: ProjectAccessActor;
4
+ projectId: string;
5
+ };
6
+ export type ProjectFileEntry = {
7
+ path: string;
8
+ kind: 'file' | 'directory';
9
+ size: number;
10
+ updatedAt: string;
11
+ };
12
+ export interface ProjectFilesApi {
13
+ list(input: ProjectFileScope & {
14
+ path?: string;
15
+ depth?: number;
16
+ }): Promise<ProjectFileEntry[]>;
17
+ read(input: ProjectFileScope & {
18
+ path: string;
19
+ }): Promise<{
20
+ buffer: Buffer;
21
+ sha256: string;
22
+ }>;
23
+ /** null means create-only. A hash mismatch preserves the current file and rejects. */
24
+ write(input: ProjectFileScope & {
25
+ path: string;
26
+ buffer: Buffer;
27
+ expectedHash: string | null;
28
+ }): Promise<{
29
+ sha256: string;
30
+ }>;
31
+ mkdir(input: ProjectFileScope & {
32
+ path: string;
33
+ }): Promise<void>;
34
+ /** Destination must not exist. Governed Project instructions and skills cannot be moved. */
35
+ move(input: ProjectFileScope & {
36
+ path: string;
37
+ destination: string;
38
+ }): Promise<void>;
39
+ }
40
+ export declare const ProjectFilesRuntimeCapability: import("../../core/runtime-capability").RuntimeCapabilityKey<ProjectFilesApi>;
@@ -0,0 +1,14 @@
1
+ import type { OrganizationRuntimeActor } from '../actor';
2
+ export interface ProjectKnowledgeApi {
3
+ /** One built-in library per Project. Uses current Project ACL, independent of a Space or Assistant.
4
+ * Provisioning calls the existing knowledge service; its request/job context must match actor.
5
+ */
6
+ ensureBinding(input: {
7
+ actor: OrganizationRuntimeActor;
8
+ projectId: string;
9
+ title: string;
10
+ }): Promise<{
11
+ knowledgebaseId: string;
12
+ }>;
13
+ }
14
+ export declare const ProjectKnowledgeRuntimeCapability: import("../../core/runtime-capability").RuntimeCapabilityKey<ProjectKnowledgeApi>;
@@ -7,6 +7,10 @@ export type ProjectExternalAssistantExpectation = {
7
7
  templateKey: string;
8
8
  agentKey: string;
9
9
  };
10
+ /** A requested portable role resolved to an authorized Assistant; not proof of Project membership. */
11
+ export type ProjectAssistantBinding = ProjectExternalAssistantExpectation & {
12
+ xpertId: string;
13
+ };
10
14
  /** Stable identity and desired state for an idempotently provisioned Chat Project. */
11
15
  export type ProjectEnsureInput = {
12
16
  /** Registered application type. Omission preserves legacy unclassified callers. */
@@ -33,6 +37,8 @@ export type ProjectEnsureResult = {
33
37
  workspaceId?: string;
34
38
  /** Persisted Assistant members; ensure never restores removed members or adds new graph dependencies to an existing Project. */
35
39
  xpertIds: string[];
40
+ /** Bindings for the requested role expectations, not all members. Check xpertIds before assigning an executor. */
41
+ assistantBindings: ProjectAssistantBinding[];
36
42
  /** Whether this call inserted the Project or reconciled an existing one. */
37
43
  operation: 'created' | 'updated';
38
44
  };
@@ -5,6 +5,8 @@ export type WorkspaceFileCatalog = 'projects' | 'users' | 'knowledges' | 'skills
5
5
  export declare const WORKSPACE_FILES_SOURCE: "platform.workspace.files";
6
6
  /**
7
7
  * Scope fields used to resolve a workspace Volume.
8
+ * Project types (including Spaces) share the projects catalog and projectId;
9
+ * plugin resource IDs belong to content-resource metadata, not storage scope.
8
10
  *
9
11
  * Explicit APIs can provide catalog plus the matching id directly. Runtime-aware
10
12
  * APIs usually receive these fields from the current Agent execution context.
@@ -1,10 +1,9 @@
1
1
  import type { IWFNMiddleware, XpertResolvedViewHostContext } from '@xpert-ai/contracts';
2
2
  import type { IAgentMiddlewareContext } from '../agent/middleware/strategy.interface';
3
+ import type { AssistantMiddlewareRequirement } from '../runtime/capabilities/assistant-middleware-access';
3
4
  /** Server-only input: use the authorized context received by a View provider, never iframe input. */
4
- export interface ViewMiddlewareRuntimeInput {
5
+ export interface ViewMiddlewareRuntimeInput extends AssistantMiddlewareRequirement {
5
6
  context: XpertResolvedViewHostContext;
6
- provider: string;
7
- requiredFeature: string;
8
7
  /** Authoring requires the same draft access policy as the Agent View host. Defaults to published. */
9
8
  isDraft?: boolean;
10
9
  }