@xpert-ai/plugin-sdk 3.29.0 → 3.30.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.
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod/v3';
2
2
  /** Package exports are a runtime boundary; reject malformed declarations before registration. */
3
- export declare const artifactTypeDefinitionSchema: z.ZodObject<{
3
+ export declare const artifactTypeDefinitionSchema: z.ZodEffects<z.ZodObject<{
4
4
  title: z.ZodOptional<z.ZodObject<{
5
5
  en_US: z.ZodString;
6
6
  zh_Hans: z.ZodOptional<z.ZodString>;
@@ -22,6 +22,13 @@ export declare const artifactTypeDefinitionSchema: z.ZodObject<{
22
22
  }, {
23
23
  allowCopy?: boolean;
24
24
  }>>;
25
+ versioning: z.ZodOptional<z.ZodObject<{
26
+ mode: z.ZodLiteral<"draft-only">;
27
+ }, "strict", z.ZodTypeAny, {
28
+ mode?: "draft-only";
29
+ }, {
30
+ mode?: "draft-only";
31
+ }>>;
25
32
  content: z.ZodOptional<z.ZodObject<{
26
33
  mimeTypes: z.ZodArray<z.ZodString, "many">;
27
34
  maxBytes: z.ZodNumber;
@@ -33,6 +40,7 @@ export declare const artifactTypeDefinitionSchema: z.ZodObject<{
33
40
  maxBytes?: number;
34
41
  }>>;
35
42
  sharing: z.ZodOptional<z.ZodObject<{
43
+ projectAccess: z.ZodOptional<z.ZodLiteral<"link-audience">>;
36
44
  accessModes: z.ZodArray<z.ZodEnum<["owner_only", "workspace_all", "organization_all", "custom_principals", "public_link", "signed_preview"]>, "many">;
37
45
  versionModes: z.ZodArray<z.ZodEnum<["latest", "version"]>, "many">;
38
46
  maxTtlSeconds: z.ZodOptional<z.ZodNumber>;
@@ -41,6 +49,7 @@ export declare const artifactTypeDefinitionSchema: z.ZodObject<{
41
49
  descriptor: z.ZodBoolean;
42
50
  shareKey: z.ZodOptional<z.ZodString>;
43
51
  }, "strict", z.ZodTypeAny, {
52
+ projectAccess?: "link-audience";
44
53
  accessModes?: ("owner_only" | "workspace_all" | "organization_all" | "custom_principals" | "public_link" | "signed_preview")[];
45
54
  versionModes?: ("version" | "latest")[];
46
55
  maxTtlSeconds?: number;
@@ -49,6 +58,7 @@ export declare const artifactTypeDefinitionSchema: z.ZodObject<{
49
58
  descriptor?: boolean;
50
59
  shareKey?: string;
51
60
  }, {
61
+ projectAccess?: "link-audience";
52
62
  accessModes?: ("owner_only" | "workspace_all" | "organization_all" | "custom_principals" | "public_link" | "signed_preview")[];
53
63
  versionModes?: ("version" | "latest")[];
54
64
  maxTtlSeconds?: number;
@@ -81,7 +91,71 @@ export declare const artifactTypeDefinitionSchema: z.ZodObject<{
81
91
  mode?: "file" | "authenticated" | "snapshot";
82
92
  };
83
93
  kinds?: ("file" | "image" | "html" | "markdown" | "pdf" | "pptx" | "site" | "presentation")[];
94
+ versioning?: {
95
+ mode?: "draft-only";
96
+ };
97
+ sharing?: {
98
+ projectAccess?: "link-audience";
99
+ accessModes?: ("owner_only" | "workspace_all" | "organization_all" | "custom_principals" | "public_link" | "signed_preview")[];
100
+ versionModes?: ("version" | "latest")[];
101
+ maxTtlSeconds?: number;
102
+ allowDownload?: boolean;
103
+ mutableLinks?: boolean;
104
+ descriptor?: boolean;
105
+ shareKey?: string;
106
+ };
107
+ }, {
108
+ title?: {
109
+ en_US?: string;
110
+ zh_Hans?: string;
111
+ zh_Hant?: string;
112
+ };
113
+ collection?: {
114
+ allowCopy?: boolean;
115
+ };
116
+ content?: {
117
+ mimeTypes?: string[];
118
+ maxBytes?: number;
119
+ };
120
+ presentation?: {
121
+ mode?: "file" | "authenticated" | "snapshot";
122
+ };
123
+ kinds?: ("file" | "image" | "html" | "markdown" | "pdf" | "pptx" | "site" | "presentation")[];
124
+ versioning?: {
125
+ mode?: "draft-only";
126
+ };
84
127
  sharing?: {
128
+ projectAccess?: "link-audience";
129
+ accessModes?: ("owner_only" | "workspace_all" | "organization_all" | "custom_principals" | "public_link" | "signed_preview")[];
130
+ versionModes?: ("version" | "latest")[];
131
+ maxTtlSeconds?: number;
132
+ allowDownload?: boolean;
133
+ mutableLinks?: boolean;
134
+ descriptor?: boolean;
135
+ shareKey?: string;
136
+ };
137
+ }>, {
138
+ title?: {
139
+ en_US?: string;
140
+ zh_Hans?: string;
141
+ zh_Hant?: string;
142
+ };
143
+ collection?: {
144
+ allowCopy?: boolean;
145
+ };
146
+ content?: {
147
+ mimeTypes?: string[];
148
+ maxBytes?: number;
149
+ };
150
+ presentation?: {
151
+ mode?: "file" | "authenticated" | "snapshot";
152
+ };
153
+ kinds?: ("file" | "image" | "html" | "markdown" | "pdf" | "pptx" | "site" | "presentation")[];
154
+ versioning?: {
155
+ mode?: "draft-only";
156
+ };
157
+ sharing?: {
158
+ projectAccess?: "link-audience";
85
159
  accessModes?: ("owner_only" | "workspace_all" | "organization_all" | "custom_principals" | "public_link" | "signed_preview")[];
86
160
  versionModes?: ("version" | "latest")[];
87
161
  maxTtlSeconds?: number;
@@ -107,7 +181,11 @@ export declare const artifactTypeDefinitionSchema: z.ZodObject<{
107
181
  mode?: "file" | "authenticated" | "snapshot";
108
182
  };
109
183
  kinds?: ("file" | "image" | "html" | "markdown" | "pdf" | "pptx" | "site" | "presentation")[];
184
+ versioning?: {
185
+ mode?: "draft-only";
186
+ };
110
187
  sharing?: {
188
+ projectAccess?: "link-audience";
111
189
  accessModes?: ("owner_only" | "workspace_all" | "organization_all" | "custom_principals" | "public_link" | "signed_preview")[];
112
190
  versionModes?: ("version" | "latest")[];
113
191
  maxTtlSeconds?: number;
@@ -35,7 +35,13 @@ export interface ArtifactTypeDefinition {
35
35
  mimeTypes: readonly string[];
36
36
  maxBytes: number;
37
37
  };
38
+ /** A managed application owns publication; generic version uploads cannot bypass its draft workflow. */
39
+ versioning?: {
40
+ mode: 'draft-only';
41
+ };
38
42
  sharing?: {
43
+ /** Opt in to authenticated Project shares beyond membership; source ACL and data policy still apply. */
44
+ projectAccess?: 'link-audience';
39
45
  accessModes: readonly ArtifactAccessMode[];
40
46
  versionModes: readonly ArtifactLinkVersionMode[];
41
47
  maxTtlSeconds?: number;
@@ -82,7 +88,13 @@ export type ArtifactSnapshotProvider = ArtifactSnapshotReader & ({
82
88
  export interface IArtifactTypeProvider {
83
89
  readonly definition: ArtifactTypeDefinition;
84
90
  authorize(source: ArtifactTypeSource, actor: ArtifactTypeActor, operation: ContentOperation): Promise<void>;
91
+ /** Additional policy for working drafts; published reads keep their ordinary source policy. */
92
+ authorizeDraft?(source: ArtifactTypeSource, actor: ArtifactTypeActor, operation: ContentOperation): Promise<void>;
93
+ /** Enforce domain review/dependency policy immediately before committing the verified draft. */
94
+ assertDraftPublication?(source: ArtifactTypeSource, actor: ArtifactTypeActor, draft: import('../runtime/capabilities/artifact-drafts').ArtifactDraftRecord): Promise<void>;
85
95
  validateContent(content: Buffer, mimeType: string): Promise<void> | void;
96
+ /** Opt-in adoption of legacy file bindings; validate provenance as well as every saved payload. */
97
+ validateLegacyContent?(source: ArtifactTypeSource, content: Buffer, mimeType: string): Promise<void> | void;
86
98
  assertPublication?(source: ArtifactTypeSource, access: ArtifactLinkAccessInput): Promise<void> | void;
87
99
  assertLink?(source: ArtifactTypeSource, link: ArtifactTypeLink): Promise<void> | void;
88
100
  readonly snapshot?: ArtifactSnapshotProvider;
@@ -1,3 +1,4 @@
1
+ import type { IntegrationUsage, IntegrationUsageScope } from '@xpert-ai/contracts';
1
2
  import type { IIntegration, IPagination } from '@xpert-ai/contracts';
2
3
  import type { PluginWebhookCredentialResult } from '../webhook';
3
4
  /**
@@ -68,6 +69,8 @@ export declare const INTEGRATION_PERMISSION_SERVICE_TOKEN = "XPERT_PLUGIN_INTEGR
68
69
  * Read-only integration permission service exposed to plugins.
69
70
  */
70
71
  export interface IntegrationPermissionService {
72
+ /** Scope must come from a host-authorized request/execution or a persisted binding, never tool input. */
73
+ readForUsage?(id: string, usage: IntegrationUsage, scope: IntegrationUsageScope): Promise<IIntegration | null>;
71
74
  /** Read plugin configuration in its host-bound scope; system plugins use the Default tenant. */
72
75
  readConfiguration?(id: string): Promise<IIntegration | null>;
73
76
  /** Exact lookup for a connector whose actor and persisted scope have been authorized by the host. */
@@ -0,0 +1,11 @@
1
+ import type { WorkspacePortableFileReference, WorkspaceFileBuffer } from './workspace-files';
2
+ /** Content owned by an Artifact, isolated from generic Project/Assistant file access. */
3
+ export interface ArtifactContentApi {
4
+ write(input: {
5
+ artifactId: string;
6
+ buffer: Buffer;
7
+ }): Promise<WorkspacePortableFileReference>;
8
+ /** Reauthorizes a published version or the working draft owning these exact bytes. */
9
+ read(reference: WorkspacePortableFileReference): Promise<WorkspaceFileBuffer>;
10
+ }
11
+ export declare const ArtifactContentRuntimeCapability: import("../../core/runtime-capability").RuntimeCapabilityKey<ArtifactContentApi>;
@@ -2,6 +2,7 @@ export * from './actor-token';
2
2
  export * from './artifacts';
3
3
  export * from './artifact-library';
4
4
  export * from './artifact-drafts';
5
+ export * from './artifact-content';
5
6
  export * from './workspace-files';
6
7
  export * from './workspace-storage';
7
8
  export * from './sandbox-jobs';
@@ -17,6 +17,8 @@ export interface WorkspaceStorage {
17
17
  * Native plugins are trusted server code; this handle is not a sandbox for malicious plugin code. */
18
18
  export interface WorkspaceAppDataOptions {
19
19
  pluginName: string;
20
+ /** Explicit Project application state; membership is rechecked on every operation. */
21
+ projectId?: string;
20
22
  /** Opt in for personal data; shared Assistant workspaces otherwise remain supported. */
21
23
  requireUserIsolation?: boolean;
22
24
  }
@@ -1,6 +1,8 @@
1
1
  import { z } from 'zod/v3';
2
2
  /** Portable Agent input; filesystem containment and authorization remain with the host. */
3
3
  export declare const workspaceRelativeFilePathSchema: z.ZodEffects<z.ZodString, string, string>;
4
+ /** Directory discovery also accepts the workspace root and a trailing directory slash. */
5
+ export declare const workspaceRelativeDirectoryPathSchema: z.ZodPipeline<z.ZodEffects<z.ZodString, string, string>, z.ZodUnion<[z.ZodLiteral<".">, z.ZodEffects<z.ZodString, string, string>]>>;
4
6
  /** Host-owned metadata lets plugins observe file intent without guessing tool names. */
5
7
  export declare const workspaceFileMutationMetadata: {
6
8
  readonly workspaceFileOperation: {
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Node.js command template for recursive directory listing with depth control.
3
+ */
4
+ export declare function buildListDirCommand(dirPath: string, displayPath: string, offset: number, limit: number, depth: number): string;
@@ -69,7 +69,7 @@ export type SandboxRuntimeResources = {
69
69
  };
70
70
  /** Network access that a Provider must enforce for the Runtime instance. */
71
71
  export type SandboxRuntimeNetworkPolicy = {
72
- mode: 'none' | 'internal-only';
72
+ mode: 'none' | 'internal-only' | 'unrestricted';
73
73
  allowedHosts?: string[];
74
74
  };
75
75
  /** Mandatory process and filesystem hardening for a Runtime instance. */
@@ -58,7 +58,7 @@ export declare abstract class BaseSandbox implements SandboxBackendProtocol {
58
58
  * @param offset - 1-indexed entry number to start from (default: 1)
59
59
  * @param limit - Maximum number of entries to return (default: 25)
60
60
  * @param depth - Maximum depth to traverse (default: 2)
61
- * @returns Human-readable directory tree with indentation
61
+ * @returns Directory tree whose entries are relative to the sandbox working directory
62
62
  */
63
63
  listDir(dirPath: string, offset?: number, limit?: number, depth?: number): Promise<string>;
64
64
  /**
@@ -77,7 +77,7 @@ export declare abstract class BaseSandbox implements SandboxBackendProtocol {
77
77
  */
78
78
  grepRaw(pattern: string, path?: string, include?: string | null): Promise<GrepMatch[] | string>;
79
79
  /**
80
- * Search file contents for a regex pattern, returning human-readable output.
80
+ * Search file contents for a regex pattern, returning workspace-relative path labels.
81
81
  */
82
82
  grep(pattern: string, path?: string, include?: string | null): Promise<string>;
83
83
  /**
@@ -85,7 +85,7 @@ export declare abstract class BaseSandbox implements SandboxBackendProtocol {
85
85
  */
86
86
  globInfo(pattern: string, path?: string): Promise<FileInfo[]>;
87
87
  /**
88
- * Find files matching a glob pattern, returning human-readable output.
88
+ * Find files matching a glob pattern, returning workspace-relative paths.
89
89
  */
90
90
  glob(pattern: string, path?: string): Promise<string>;
91
91
  /**
@@ -0,0 +1,2 @@
1
+ /** Format tool-owned paths only; file contents and backend filesystem authorization stay unchanged. */
2
+ export declare function workspaceRelativeDisplayPath(workingDirectory: string, filePath: string): string;
@@ -6,6 +6,11 @@ export type TWorkflowTriggerBootstrapConfig = {
6
6
  };
7
7
  export type TWorkflowTriggerParams<T> = {
8
8
  xpertId: string;
9
+ /** Host-owned Assistant scope; never taken from trigger configuration. */
10
+ scope?: {
11
+ tenantId: string;
12
+ organizationId: string | null;
13
+ };
9
14
  agentKey?: string;
10
15
  node?: TXpertTeamNode;
11
16
  config: T;
@@ -1,66 +0,0 @@
1
- # Workspace file tools
2
-
3
- Use the platform `SandboxFile` middleware to read, write, append and edit HTML,
4
- Python, JavaScript and other text files. Domain plugins should consume the files
5
- through `WorkspaceFilesRuntimeCapability` instead of adding duplicate writers.
6
- The Assistant must enable the sandbox feature and include the file middleware;
7
- these helpers do not enable tools or grant file access.
8
-
9
- ## Agent arguments
10
-
11
- File paths are relative to the Assistant's file workspace, for example
12
- `dashboards/sales.html` or `scripts/sales.py`. The SDK exports
13
- `workspaceRelativeFilePathSchema` for the same portable input contract:
14
-
15
- - At most 1024 characters, with non-empty `/`-separated segments.
16
- - No absolute paths, Windows drive prefixes, backslashes, control characters,
17
- `.`/`..` segments or whitespace at either edge of a segment.
18
- - Unicode names and spaces inside a segment are supported.
19
-
20
- Write and append accept `{ file_path, content }`, with `content` as one string
21
- (including an empty string). Arrays, `html` aliases and extra fields are rejected.
22
- Edit uses `old_string`, `new_string` and optional `replace_all`; multi-edit takes
23
- `edits` containing `oldString`, `newString` and optional `replaceAll`. Unknown keys
24
- are rejected inside each edit as well as at the top level.
25
-
26
- This is a file-path contract. Directory listing and search retain their own
27
- schemas, including support for the workspace root. Input validation does not
28
- replace host authorization, filesystem containment or symlink protection.
29
-
30
- ## Observing file mutation intent
31
-
32
- The four mutating platform tools declare host-owned metadata:
33
-
34
- ```ts
35
- metadata: workspaceFileMutationMetadata
36
- // { workspaceFileOperation: { type: 'mutation', pathArgument: 'file_path' } }
37
- ```
38
-
39
- A plugin can call `workspaceFileMutationPath(tool.metadata, toolCall.args)` to
40
- obtain the validated relative path. Other tool implementations may declare their
41
- own `pathArgument`. Missing or malformed metadata, non-mutation operations and
42
- invalid paths return `undefined`; consumers must not infer mutation behavior
43
- from tool names, labels or file extensions.
44
-
45
- Metadata describes an attempted operation, not its success. A plugin may mark an
46
- already registered document as potentially changed before execution, but must
47
- inspect the tool result and actual file content before accepting a save. Writing
48
- a file does not save an Artifact draft or publish a version. Artifact saves need
49
- their own successful, revision-bearing receipt. Business rules for selecting
50
- files, validating dashboards, saving drafts and publishing remain in plugins.
51
-
52
- ## Runtime path mapping
53
-
54
- Plugins exchange relative paths, never container or server absolute paths. After
55
- sandbox acquisition, the invocation handler uses the acquired provider's workspace
56
- mapper when it differs from the requested provider, including when the host
57
- chooses a default provider. Graph compilation and runtime workspace paths use this
58
- mapped work area; server-side file access retains the Volume path and scope.
59
- This does not add default-provider selection to hosts that require an explicit
60
- provider, or change workspace authorization and sandbox lifecycle ownership.
61
-
62
- ## Recovering failed file edits
63
-
64
- `sandbox_write_file` creates a new file; it does not overwrite an existing editing copy. Read an existing file and use exact-text edit tools. Structured mutation results containing an error provide a portable `recovery.read` tool call and recovery guidance without converting the error into success.
65
-
66
- `BaseSandbox.multiEdit` persists operations sequentially, stops at the first error, and does not roll back earlier successful edits. Its optional `MultiEditResult.progress` reports `mode: "sequential"`, `appliedEdits`, and a one-based `failedEdit` on failure. Other backends may omit progress; consumers must not infer rollback or applied counts when it is absent. Transport exceptions propagate. Always reread current contents after a failed batch and apply only remaining changes.