@xpert-ai/plugin-sdk 3.23.0 → 3.25.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 (88) hide show
  1. package/_object_without_properties_loose.cjs.js +16 -0
  2. package/_object_without_properties_loose.esm.js +14 -0
  3. package/analytics-result.cjs.js +212 -0
  4. package/analytics-result.esm.js +201 -0
  5. package/analytics.cjs.default.js +1 -0
  6. package/analytics.cjs.js +17 -0
  7. package/analytics.cjs.mjs +2 -0
  8. package/analytics.d.ts +1 -0
  9. package/analytics.esm.js +2 -0
  10. package/artifact-document.cjs.default.js +1 -0
  11. package/artifact-document.cjs.js +581 -0
  12. package/artifact-document.cjs.mjs +2 -0
  13. package/artifact-document.d.ts +1 -0
  14. package/artifact-document.esm.js +563 -0
  15. package/data-workbench.cjs.js +23 -6
  16. package/data-workbench.esm.js +23 -6
  17. package/docs/README.md +8 -0
  18. package/docs/analytics.md +108 -0
  19. package/docs/artifact-documents.md +74 -0
  20. package/docs/artifact-drafts.md +24 -0
  21. package/docs/artifact-presentations.md +43 -0
  22. package/docs/json-encoded-schema.md +19 -0
  23. package/docs/mcp-client.md +63 -0
  24. package/docs/provider-credential-validation.md +34 -0
  25. package/docs/rest-client.md +24 -0
  26. package/docs/workspace-dataset-pipelines.md +120 -0
  27. package/docs/workspace-file-tools.md +66 -0
  28. package/index.cjs.js +555 -108
  29. package/index.esm.js +573 -172
  30. package/model-provider-toolset.cjs.js +1 -1
  31. package/model-provider-toolset.esm.js +1 -1
  32. package/model-provider.cjs.js +47 -1
  33. package/model-provider.esm.js +41 -2
  34. package/package.json +14 -2
  35. package/src/analytics.d.ts +3 -0
  36. package/src/artifact-document.d.ts +5 -0
  37. package/src/index.d.ts +2 -0
  38. package/src/lib/agent/handoff/agent-runtime-message.contract.d.ts +80 -80
  39. package/src/lib/agent/middleware/capabilities/assistant-task.d.ts +36 -1
  40. package/src/lib/agent/runtime/dispatch.d.ts +284 -284
  41. package/src/lib/agent/runtime/index.d.ts +1 -0
  42. package/src/lib/agent/runtime/pipeline-scope.d.ts +110 -0
  43. package/src/lib/agent/runtime/types.d.ts +4 -2
  44. package/src/lib/ai-model/ai-model-provider.interface.d.ts +3 -1
  45. package/src/lib/ai-model/utils/limits.d.ts +4 -2
  46. package/src/lib/artifact-document/dependencies.d.ts +101 -0
  47. package/src/lib/artifact-document/host.d.ts +30 -0
  48. package/src/lib/artifact-document/protocol.d.ts +60 -0
  49. package/src/lib/artifact-document/runtime.d.ts +4 -0
  50. package/src/lib/artifact-document/sha256.d.ts +2 -0
  51. package/src/lib/artifact-presentation/index.d.ts +35 -0
  52. package/src/lib/core/index.d.ts +1 -0
  53. package/src/lib/core/json-encoded-schema.d.ts +15 -0
  54. package/src/lib/data/analytics/analytics-payload.d.ts +3 -0
  55. package/src/lib/data/analytics/analytics-provider.d.ts +74 -0
  56. package/src/lib/data/analytics/analytics-result.d.ts +4 -0
  57. package/src/lib/data/analytics/analytics.registry.d.ts +10 -0
  58. package/src/lib/data/analytics/analytics.schema.d.ts +206 -0
  59. package/src/lib/data/analytics/index.d.ts +5 -0
  60. package/src/lib/data/datasource/index.d.ts +1 -0
  61. package/src/lib/data/datasource/types.d.ts +1 -1
  62. package/src/lib/data/datasource/workbench-adapter.d.ts +11 -1
  63. package/src/lib/data/datasource/workbench-sql.d.ts +12 -0
  64. package/src/lib/project-pipeline/adapters.d.ts +87 -0
  65. package/src/lib/project-pipeline/capability.d.ts +100 -0
  66. package/src/lib/project-pipeline/index.d.ts +5 -0
  67. package/src/lib/project-pipeline/projection.d.ts +71 -0
  68. package/src/lib/project-pipeline/registry.d.ts +509 -0
  69. package/src/lib/project-pipeline/runtime-registry.d.ts +45 -0
  70. package/src/lib/project-pipeline/scoped-registry.d.ts +10 -0
  71. package/src/lib/project-task/index.d.ts +6 -0
  72. package/src/lib/project-type/index.d.ts +17 -1
  73. package/src/lib/rag/types.d.ts +1 -1
  74. package/src/lib/runtime/capabilities/artifact-drafts.d.ts +29 -0
  75. package/src/lib/runtime/capabilities/artifacts.d.ts +12 -0
  76. package/src/lib/runtime/capabilities/index.d.ts +3 -0
  77. package/src/lib/runtime/capabilities/mcp-client-runtime.d.ts +41 -0
  78. package/src/lib/runtime/capabilities/rest-client-runtime.d.ts +34 -0
  79. package/src/lib/runtime/capabilities/sandbox-jobs.d.ts +36 -2
  80. package/src/lib/runtime/index.d.ts +2 -0
  81. package/src/lib/runtime/mutation-evidence.d.ts +7 -0
  82. package/src/lib/runtime/workspace-file-tools.d.ts +11 -0
  83. package/src/lib/sandbox/file-edits.d.ts +4 -0
  84. package/src/lib/sandbox/protocol.d.ts +7 -1
  85. package/src/lib/sandbox/runtime-provider.d.ts +4 -0
  86. package/src/lib/sandbox/sandbox.d.ts +2 -8
  87. package/src/lib/tool-provider/adapters.d.ts +1 -1
  88. package/src/lib/tool-provider/types.d.ts +2 -0
@@ -46,6 +46,12 @@ export type CreateArtifactVersionInput = ArtifactVersionInput & {
46
46
  /** Idempotently creates or reuses one immutable Artifact content version. */
47
47
  export type EnsureArtifactVersionInput = CreateArtifactVersionInput & {
48
48
  idempotencyKey: string;
49
+ /**
50
+ * Compare-and-set guard when promoting a version to current; ignored when setCurrent is false.
51
+ * null requires no current version; omission preserves legacy behavior. Retrying the current
52
+ * immutable version is allowed, while a stale save targeting a different version returns a conflict.
53
+ */
54
+ expectedCurrentVersionId?: string | null;
49
55
  };
50
56
  /** Access policy requested for an Artifact link. */
51
57
  export type ArtifactLinkAccessInput = {
@@ -125,6 +131,8 @@ export type ArtifactLinkRecord = ArtifactScopeInput & {
125
131
  versionMode: ArtifactLinkVersionMode;
126
132
  slug: string;
127
133
  publicUrl: string;
134
+ /** Authenticated standalone presentation page; requires a registered presentation provider. */
135
+ presentationUrl?: string;
128
136
  accessMode: ArtifactAccessMode;
129
137
  status: ArtifactLinkStatus;
130
138
  customPrincipals?: string[] | null;
@@ -143,9 +151,13 @@ export type ArtifactLinkRecord = ArtifactScopeInput & {
143
151
  };
144
152
  /** Filter used when listing Artifacts visible to the current plugin/runtime scope. */
145
153
  export type ListArtifactsInput = {
154
+ /** Include current-version metadata in one batch, without reading Workspace file bytes. */
155
+ includeCurrentVersion?: boolean;
146
156
  pluginName?: string | null;
147
157
  resourceType?: string | null;
148
158
  resourceId?: string | null;
159
+ /** Literal resource ID prefix, never a pattern; narrows results without granting access. */
160
+ resourceIdPrefix?: string | null;
149
161
  status?: ArtifactStatus | 'all' | null;
150
162
  page?: number | null;
151
163
  pageSize?: number | null;
@@ -1,8 +1,11 @@
1
1
  export * from './actor-token';
2
2
  export * from './artifacts';
3
+ export * from './artifact-drafts';
3
4
  export * from './workspace-files';
4
5
  export * from './workspace-storage';
5
6
  export * from './sandbox-jobs';
6
7
  export * from './project-provisioning';
7
8
  export * from './project-access';
8
9
  export * from './tool-images';
10
+ export * from './mcp-client-runtime';
11
+ export * from './rest-client-runtime';
@@ -0,0 +1,41 @@
1
+ import type { JSONValue } from '@xpert-ai/contracts';
2
+ import type { RuntimeIdentityScope } from '../runtime-scope';
3
+ /** References an existing platform connection. No URLs, credentials or connection overrides. */
4
+ export interface McpClientScope {
5
+ actor: Required<Pick<RuntimeIdentityScope, 'tenantId' | 'organizationId' | 'userId'>>;
6
+ workspaceId: string;
7
+ toolsetId: string;
8
+ serverName: string;
9
+ signal: AbortSignal;
10
+ deadlineAt: number;
11
+ }
12
+ export interface McpClientToolDescriptor {
13
+ name: string;
14
+ description?: string;
15
+ inputSchema: Record<string, JSONValue>;
16
+ outputSchema?: Record<string, JSONValue>;
17
+ /** Pins input/output schemas and behavior hints, not authorization or server implementation. */
18
+ contractHash: string;
19
+ }
20
+ export interface McpClientToolResult {
21
+ structuredContent?: Record<string, JSONValue>;
22
+ /** Plain text blocks only. Consumers must explicitly opt into a text JSON result contract. */
23
+ text: string[];
24
+ }
25
+ export interface McpClientToolCall {
26
+ toolName: string;
27
+ contractHash: string;
28
+ arguments: Record<string, JSONValue>;
29
+ }
30
+ /** The host currently permits read-only tools only; requests cannot relax this policy. */
31
+ export interface McpClientToolsApi {
32
+ /** Lists enabled, model-visible tools advertising read-only behavior for the current viewer. */
33
+ list(scope: McpClientScope): Promise<McpClientToolDescriptor[]>;
34
+ /** Callers must additionally restrict tools to their own approved operation catalog. */
35
+ call(scope: McpClientScope, request: McpClientToolCall): Promise<McpClientToolResult>;
36
+ }
37
+ /** Governed access to existing platform MCP connections. Only implemented capabilities are exposed. */
38
+ export interface McpClientRuntimeApi {
39
+ readonly tools: McpClientToolsApi;
40
+ }
41
+ export declare const McpClientRuntimeCapability: import("../../core/runtime-capability").RuntimeCapabilityKey<McpClientRuntimeApi>;
@@ -0,0 +1,34 @@
1
+ import type { JSONValue } from '@xpert-ai/contracts';
2
+ import type { RuntimeIdentityScope } from '../runtime-scope';
3
+ /** References a saved OpenAPI toolset; transport addresses and credentials stay in the host. */
4
+ export interface RestClientScope {
5
+ actor: Required<Pick<RuntimeIdentityScope, 'tenantId' | 'organizationId' | 'userId'>>;
6
+ workspaceId: string;
7
+ toolsetId: string;
8
+ signal: AbortSignal;
9
+ deadlineAt: number;
10
+ }
11
+ export interface RestOperationDescriptor {
12
+ operationId: string;
13
+ description?: string;
14
+ method: 'GET' | 'POST';
15
+ inputSchema: Record<string, JSONValue>;
16
+ /** Pins endpoint, parameter serialization and read-only declaration, not access grants. */
17
+ contractHash: string;
18
+ }
19
+ export interface RestOperationCall {
20
+ operationId: string;
21
+ contractHash: string;
22
+ arguments: Record<string, JSONValue>;
23
+ }
24
+ export interface RestClientRuntimeApi {
25
+ readonly operations: {
26
+ /** Enabled GET operations and POST operations explicitly declared x-xpert-read-only. */
27
+ list(scope: RestClientScope): Promise<RestOperationDescriptor[]>;
28
+ call(scope: RestClientScope, request: RestOperationCall): Promise<{
29
+ body: JSONValue;
30
+ sourceFetchedAt: string;
31
+ }>;
32
+ };
33
+ }
34
+ export declare const RestClientRuntimeCapability: import("../../core/runtime-capability").RuntimeCapabilityKey<RestClientRuntimeApi>;
@@ -1,7 +1,7 @@
1
1
  import type { JSONValue } from '@xpert-ai/contracts';
2
2
  import type { WorkspaceFileScope, WorkspacePortableFileReference } from './workspace-files';
3
3
  /** 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", "BROWSER_LAUNCH_FAILED", "EXPORT_TIMEOUT", "EXPORT_OOM", "EXPORT_MEDIA_FAILED", "EXPORT_INPUT_INVALID", "EXPORT_OUTPUT_INVALID", "SANDBOX_CANCELLED"];
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_INVOCATION_FAILED", "BROWSER_LAUNCH_FAILED", "EXPORT_TIMEOUT", "EXPORT_OOM", "EXPORT_MEDIA_FAILED", "EXPORT_INPUT_INVALID", "EXPORT_OUTPUT_INVALID", "SANDBOX_CANCELLED"];
5
5
  export type SandboxJobErrorCode = (typeof SANDBOX_JOB_ERROR_CODES)[number];
6
6
  /** Persisted lifecycle states for a generic isolated background execution. */
7
7
  export type SandboxJobStatus = 'waiting' | 'starting' | 'running' | 'succeeded' | 'failed' | 'cancelled' | 'lost';
@@ -114,6 +114,40 @@ export type SandboxJobSnapshot = {
114
114
  startedAt?: Date | string | null;
115
115
  finishedAt?: Date | string | null;
116
116
  };
117
+ /**
118
+ * Host callbacks available only for one execution attempt. This configuration is never
119
+ * serialized into a Job or exposed to the script. An attached caller cannot replace it.
120
+ */
121
+ export type SandboxJobInvocation = {
122
+ /** Exact operation names the script may request; names carry no built-in business meaning. */
123
+ operations: readonly string[];
124
+ /** Positive integer request limit, including queued requests; Core caps it at 32. */
125
+ maxCalls: number;
126
+ /** Positive integer budget for UTF-8 request lines and response JSON combined; capped at 8 MB. */
127
+ maxBytes: number;
128
+ /**
129
+ * Runs in the initiating host context. The plugin validates the operation payload and
130
+ * rechecks resource access; the operation allowlist is not business authorization.
131
+ * Honor signal to stop child work. Return only data permitted to enter the script workspace.
132
+ */
133
+ handle(operation: string, payload: JSONValue, context: {
134
+ jobId: string;
135
+ signal: AbortSignal;
136
+ }): Promise<JSONValue>;
137
+ };
138
+ /** Live execution controls; kept separate from the persisted, JSON-only RunInput. */
139
+ export type SandboxJobRunOptions = {
140
+ /** Cancels an owned attempt; on reattachment, cancels only this caller's wait. */
141
+ signal?: AbortSignal;
142
+ invocation?: SandboxJobInvocation;
143
+ };
144
+ /**
145
+ * Stdout frame: prefix + JSON { id, operation, payload } + newline.
146
+ * Core writes { id, value } to <workspaceRoot>/invocations/<id>.json after validation.
147
+ * IDs are unique per attempt and restricted to 1–64 ASCII letters, digits, '_' or '-'.
148
+ * The bridge has no network endpoint and gives the script no host credentials.
149
+ */
150
+ export declare const SANDBOX_JOB_INVOCATION_PREFIX = "XPERT_SANDBOX_INVOKE ";
117
151
  /** Successful `run()` result; failed executions reject with SandboxJobRuntimeError. */
118
152
  export type SandboxJobRunResult = SandboxJobSnapshot & {
119
153
  status: 'succeeded';
@@ -141,7 +175,7 @@ export type SandboxJobActionHealth = {
141
175
  */
142
176
  export interface SandboxJobsApi {
143
177
  /** Starts, reattaches, or reuses a successful execution by tenant-scoped idempotency key. */
144
- run(input: SandboxJobRunInput): Promise<SandboxJobRunResult>;
178
+ run(input: SandboxJobRunInput, options?: SandboxJobRunOptions): Promise<SandboxJobRunResult>;
145
179
  /** Cancels the logical Job and terminates its active Runtime when one exists. */
146
180
  cancel(input: {
147
181
  jobId: string;
@@ -1,3 +1,5 @@
1
1
  export * from './runtime-capability';
2
2
  export * from './runtime-scope';
3
3
  export * from './capabilities';
4
+ export * from './mutation-evidence';
5
+ export * from './workspace-file-tools';
@@ -0,0 +1,7 @@
1
+ /** Run-scoped evidence for multi-tool writes. A file write is not a domain commit. */
2
+ export declare function createMutationEvidence<T>(): {
3
+ begin(): number;
4
+ accept(token: number, value: T): void;
5
+ readonly pending: boolean;
6
+ readonly receipt: T;
7
+ };
@@ -0,0 +1,11 @@
1
+ import { z } from 'zod/v3';
2
+ /** Portable Agent input; filesystem containment and authorization remain with the host. */
3
+ export declare const workspaceRelativeFilePathSchema: z.ZodEffects<z.ZodString, string, string>;
4
+ /** Host-owned metadata lets plugins observe file intent without guessing tool names. */
5
+ export declare const workspaceFileMutationMetadata: {
6
+ readonly workspaceFileOperation: {
7
+ readonly type: "mutation";
8
+ readonly pathArgument: "file_path";
9
+ };
10
+ };
11
+ export declare function workspaceFileMutationPath(metadata: unknown, args: Record<string, unknown>): string | undefined;
@@ -0,0 +1,4 @@
1
+ import type { EditOperation, EditResult, ExecuteResponse, MaybePromise, MultiEditResult } from './protocol';
2
+ export declare function editCommandResult(filePath: string, result: ExecuteResponse): EditResult;
3
+ /** Stops on failure; never promises rollback or silently reapplies completed edits. */
4
+ export declare function sequentialFileEdits(filePath: string, edits: EditOperation[], apply: (edit: EditOperation) => MaybePromise<EditResult>): Promise<MultiEditResult>;
@@ -139,6 +139,12 @@ export interface MultiEditResult {
139
139
  filesUpdate?: Record<string, FileData> | null;
140
140
  /** Results from each individual edit operation */
141
141
  results?: EditResult[];
142
+ /** Present when the backend reports sequential persistence. Indices are one-based. */
143
+ progress?: {
144
+ mode: 'sequential';
145
+ appliedEdits: number;
146
+ failedEdit?: number;
147
+ };
142
148
  /** Metadata for the multi-edit operation, attached to the ToolMessage */
143
149
  metadata?: Record<string, unknown>;
144
150
  }
@@ -290,7 +296,7 @@ export interface BackendProtocol extends IBackendProtocol {
290
296
  /**
291
297
  * Perform multiple sequential edits on a single file.
292
298
  * All edits are applied sequentially, with each edit operating on the result of the previous edit.
293
- * All edits must succeed for the operation to succeed (atomic).
299
+ * Earlier successful edits may persist when a later edit fails. Inspect progress and reread before retrying.
294
300
  *
295
301
  * @param filePath - Absolute file path
296
302
  * @param edits - Array of edit operations to perform sequentially
@@ -76,6 +76,8 @@ export type SandboxRuntimeSecurity = {
76
76
  readOnlyRootFilesystem: boolean;
77
77
  noNewPrivileges: boolean;
78
78
  dropCapabilities: 'all';
79
+ /** Mount job inputs/actions read-only; outputs must live on a bounded ephemeral filesystem. */
80
+ readOnlyWorkspace?: boolean;
79
81
  };
80
82
  /** Isolation guarantees a Provider advertises before it can be selected. */
81
83
  export type SandboxRuntimeProviderCapabilities = {
@@ -86,6 +88,8 @@ export type SandboxRuntimeProviderCapabilities = {
86
88
  readOnlyRootFilesystem: boolean;
87
89
  /** Supports Job-scoped, read-only, seekable Workspace file mappings. */
88
90
  readOnlyFileMounts?: boolean;
91
+ /** Enforces read-only job inputs and bounded ephemeral outputs. */
92
+ readOnlyWorkspace?: boolean;
89
93
  };
90
94
  /** Minimum Provider guarantees required by a Runtime Definition. */
91
95
  export type SandboxRuntimeRequirements = SandboxRuntimeProviderCapabilities;
@@ -97,14 +97,8 @@ export declare abstract class BaseSandbox implements SandboxBackendProtocol {
97
97
  * Append content to a file. Creates the file if it doesn't exist.
98
98
  */
99
99
  append(filePath: string, content: string): Promise<WriteResult>;
100
- /**
101
- * Edit a file by replacing string occurrences.
102
- */
100
+ /** Edit a file by replacing string occurrences. */
103
101
  edit(filePath: string, oldString: string, newString: string, replaceAll?: boolean): Promise<EditResult>;
104
- /**
105
- * Perform multiple sequential edits on a single file.
106
- * All edits are applied sequentially, with each edit operating on the result of the previous edit.
107
- * All edits must succeed for the operation to succeed (atomic).
108
- */
102
+ /** Earlier successful edits remain persisted if a later edit fails. */
109
103
  multiEdit(filePath: string, edits: EditOperation[]): Promise<MultiEditResult>;
110
104
  }
@@ -13,7 +13,7 @@ export declare class DecoratedToolsetStrategy implements IToolsetStrategy<IXpert
13
13
  readonly descriptor: XpertToolProviderDescriptor;
14
14
  readonly meta: IToolsetStrategy<IXpertToolset>['meta'];
15
15
  constructor(instance: XpertToolProviderInstance, pluginName?: string, pluginVersion?: string);
16
- validateConfig(): Promise<void>;
16
+ validateConfig(config?: unknown): Promise<void>;
17
17
  create(toolset: IXpertToolset, params?: TBuiltinToolsetParams): Promise<BuiltinToolset>;
18
18
  createTools(): DynamicStructuredTool<ZodSchema>[];
19
19
  }
@@ -97,6 +97,8 @@ export interface XpertBusinessToolContext {
97
97
  }
98
98
  export type XpertDecoratedToolMethod<TInputSchema extends ZodTypeAny = ZodTypeAny, TOutputSchema extends ZodTypeAny = ZodTypeAny> = (input: ZodInfer<TInputSchema>, context: XpertBusinessToolContext) => PromiseOrValue<ZodInfer<TOutputSchema> | XpertToolResult<ZodInfer<TOutputSchema>> | XpertPreparedToolResult>;
99
99
  export interface XpertToolProviderInstance {
100
+ /** Validate connection values before saving. Reject invalid input without exposing credentials in errors. */
101
+ validateConfig?(config: unknown): PromiseOrValue<void>;
100
102
  /** Compatibility hook for legacy providers; prefer resource and prompt method decorators. */
101
103
  getMcpExtensions?(): Pick<McpCapabilityDefinitions, 'resources' | 'resourceTemplates' | 'prompts'>;
102
104
  getMiddlewareExtensions?(provider: string, options: unknown, context: IAgentMiddlewareContext): PromiseOrValue<Omit<AgentMiddleware, 'name' | 'tools'>>;