@xpert-ai/plugin-sdk 3.23.1 → 3.26.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 (44) hide show
  1. package/docs/README.md +8 -0
  2. package/docs/analytics.md +42 -0
  3. package/docs/artifact-presentations.md +43 -0
  4. package/docs/mcp-client.md +63 -0
  5. package/docs/provider-credential-validation.md +34 -0
  6. package/docs/rest-client.md +24 -0
  7. package/docs/workspace-file-tools.md +6 -0
  8. package/index.cjs.js +471 -89
  9. package/index.esm.js +448 -92
  10. package/model-provider.cjs.js +10 -0
  11. package/model-provider.esm.js +9 -1
  12. package/package.json +2 -2
  13. package/src/index.d.ts +2 -0
  14. package/src/lib/agent/handoff/agent-runtime-message.contract.d.ts +76 -76
  15. package/src/lib/agent/middleware/capabilities/assistant-task.d.ts +36 -1
  16. package/src/lib/agent/runtime/dispatch.d.ts +284 -284
  17. package/src/lib/agent/runtime/index.d.ts +1 -0
  18. package/src/lib/agent/runtime/pipeline-scope.d.ts +110 -0
  19. package/src/lib/agent/runtime/types.d.ts +4 -2
  20. package/src/lib/ai-model/ai-model-provider.interface.d.ts +3 -1
  21. package/src/lib/ai-model/utils/limits.d.ts +4 -2
  22. package/src/lib/artifact-presentation/index.d.ts +35 -0
  23. package/src/lib/data/analytics/analytics-payload.d.ts +3 -0
  24. package/src/lib/data/analytics/index.d.ts +1 -0
  25. package/src/lib/data/datasource/types.d.ts +1 -1
  26. package/src/lib/project-pipeline/adapters.d.ts +87 -0
  27. package/src/lib/project-pipeline/capability.d.ts +100 -0
  28. package/src/lib/project-pipeline/index.d.ts +5 -0
  29. package/src/lib/project-pipeline/projection.d.ts +71 -0
  30. package/src/lib/project-pipeline/registry.d.ts +509 -0
  31. package/src/lib/project-pipeline/runtime-registry.d.ts +45 -0
  32. package/src/lib/project-pipeline/scoped-registry.d.ts +10 -0
  33. package/src/lib/project-task/index.d.ts +6 -0
  34. package/src/lib/project-type/index.d.ts +17 -1
  35. package/src/lib/rag/types.d.ts +1 -1
  36. package/src/lib/runtime/capabilities/artifacts.d.ts +2 -0
  37. package/src/lib/runtime/capabilities/index.d.ts +2 -0
  38. package/src/lib/runtime/capabilities/mcp-client-runtime.d.ts +41 -0
  39. package/src/lib/runtime/capabilities/rest-client-runtime.d.ts +34 -0
  40. package/src/lib/sandbox/file-edits.d.ts +4 -0
  41. package/src/lib/sandbox/protocol.d.ts +7 -1
  42. package/src/lib/sandbox/sandbox.d.ts +2 -8
  43. package/src/lib/tool-provider/adapters.d.ts +1 -1
  44. package/src/lib/tool-provider/types.d.ts +2 -0
@@ -265,6 +265,14 @@ const ToolImagesRuntimeCapability = createRuntimeCapability('platform.tool-image
265
265
  description: 'Save scoped immutable tool images and materialize verified pixels for one model request.'
266
266
  });
267
267
 
268
+ const McpClientRuntimeCapability = createRuntimeCapability('platform.mcp.client', {
269
+ description: 'Governed MCP client access using existing connections and viewer credentials; read-only tools initially.'
270
+ });
271
+
272
+ const RestClientRuntimeCapability = createRuntimeCapability('platform.rest.client', {
273
+ description: 'Governed JSON access through saved OpenAPI connections and platform-managed authentication.'
274
+ });
275
+
268
276
  /** Portable Agent input; filesystem containment and authorization remain with the host. */ const workspaceRelativeFilePathSchema = v3.z.string().min(1).max(1024).refine((value)=>!/[\\\x00-\x1f\x7f]/.test(value) && !/^[A-Za-z]:/.test(value) && value.split('/').every((part)=>part.length > 0 && part === part.trim() && part !== '.' && part !== '..'), 'Use a workspace-relative file path with non-empty segments; no absolute paths, traversal or surrounding whitespace.');
269
277
  /** Host-owned metadata lets plugins observe file intent without guessing tool names. */ const workspaceFileMutationMetadata = {
270
278
  workspaceFileOperation: {
@@ -407,10 +415,12 @@ exports.BaseTool = BaseTool;
407
415
  exports.BaseToolset = BaseToolset;
408
416
  exports.BuiltinToolset = BuiltinToolset;
409
417
  exports.DefaultRuntimeCapabilityRegistry = DefaultRuntimeCapabilityRegistry;
418
+ exports.McpClientRuntimeCapability = McpClientRuntimeCapability;
410
419
  exports.ModelProviderBuiltinToolset = ModelProviderBuiltinToolset;
411
420
  exports.ProjectAccessRuntimeCapability = ProjectAccessRuntimeCapability;
412
421
  exports.ProjectProvisioningRuntimeCapability = ProjectProvisioningRuntimeCapability;
413
422
  exports.RUNTIME_CAPABILITY_PROVIDER = RUNTIME_CAPABILITY_PROVIDER;
423
+ exports.RestClientRuntimeCapability = RestClientRuntimeCapability;
414
424
  exports.RuntimeCapabilityProvider = RuntimeCapabilityProvider;
415
425
  exports.SANDBOX_JOB_ERROR_CODES = SANDBOX_JOB_ERROR_CODES;
416
426
  exports.SANDBOX_JOB_INVOCATION_PREFIX = SANDBOX_JOB_INVOCATION_PREFIX;
@@ -263,6 +263,14 @@ const ToolImagesRuntimeCapability = createRuntimeCapability('platform.tool-image
263
263
  description: 'Save scoped immutable tool images and materialize verified pixels for one model request.'
264
264
  });
265
265
 
266
+ const McpClientRuntimeCapability = createRuntimeCapability('platform.mcp.client', {
267
+ description: 'Governed MCP client access using existing connections and viewer credentials; read-only tools initially.'
268
+ });
269
+
270
+ const RestClientRuntimeCapability = createRuntimeCapability('platform.rest.client', {
271
+ description: 'Governed JSON access through saved OpenAPI connections and platform-managed authentication.'
272
+ });
273
+
266
274
  /** Portable Agent input; filesystem containment and authorization remain with the host. */ const workspaceRelativeFilePathSchema = z.string().min(1).max(1024).refine((value)=>!/[\\\x00-\x1f\x7f]/.test(value) && !/^[A-Za-z]:/.test(value) && value.split('/').every((part)=>part.length > 0 && part === part.trim() && part !== '.' && part !== '..'), 'Use a workspace-relative file path with non-empty segments; no absolute paths, traversal or surrounding whitespace.');
267
275
  /** Host-owned metadata lets plugins observe file intent without guessing tool names. */ const workspaceFileMutationMetadata = {
268
276
  workspaceFileOperation: {
@@ -397,4 +405,4 @@ function normalizeWorkspaceScope(scope) {
397
405
  } : {});
398
406
  }
399
407
 
400
- 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, BaseTool as e, BaseToolset as f, ProjectProvisioningRuntimeCapability as g, RuntimeCapabilityProvider as h, SANDBOX_JOB_INVOCATION_PREFIX as i, SANDBOX_JOB_PROGRESS_PREFIX as j, SandboxJobRuntimeError as k, SandboxJobsRuntimeCapability as l, WORKSPACE_FILES_SOURCE as m, isSandboxJobRuntimeError as n, workspaceFileMutationPath as o, workspaceRelativeFilePathSchema as p, workspaceFileMutationMetadata as w };
408
+ 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, BaseTool as e, BaseToolset as f, McpClientRuntimeCapability as g, ProjectProvisioningRuntimeCapability as h, RestClientRuntimeCapability as i, RuntimeCapabilityProvider as j, SANDBOX_JOB_INVOCATION_PREFIX as k, SANDBOX_JOB_PROGRESS_PREFIX as l, SandboxJobRuntimeError as m, SandboxJobsRuntimeCapability as n, WORKSPACE_FILES_SOURCE as o, isSandboxJobRuntimeError as p, workspaceFileMutationPath as q, workspaceRelativeFilePathSchema as r, workspaceFileMutationMetadata as w };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpert-ai/plugin-sdk",
3
- "version": "3.23.1",
3
+ "version": "3.26.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.23.0",
77
+ "@xpert-ai/contracts": "3.26.0",
78
78
  "express": "^4.22.1",
79
79
  "js-tiktoken": "^1.0.21"
80
80
  },
package/src/index.d.ts CHANGED
@@ -26,10 +26,12 @@ export * from './lib/sandbox/index';
26
26
  export * from './lib/managed-connection/index';
27
27
  export * from './lib/managed-queue/index';
28
28
  export * from './lib/view-extension/index';
29
+ export * from './lib/artifact-presentation/index';
29
30
  export * from './lib/collaboration/index';
30
31
  export * from './lib/evolution/index';
31
32
  export * from './lib/mcp/index';
32
33
  export * from './lib/tool-provider/index';
33
34
  export * from './lib/project-type/index';
34
35
  export * from './lib/project-task/index';
36
+ export * from './lib/project-pipeline';
35
37
  export * from './lib/agent-plugin/import-default-agent-plugins.command';
@@ -14,38 +14,38 @@ export declare const agentRuntimeEventSchema: z.ZodDiscriminatedUnion<"kind", [z
14
14
  completed: z.ZodNumber;
15
15
  total: z.ZodNumber;
16
16
  }, "strict", z.ZodTypeAny, {
17
- completed?: number;
18
- total?: number;
17
+ completed: number;
18
+ total: number;
19
19
  }, {
20
- completed?: number;
21
- total?: number;
20
+ completed: number;
21
+ total: number;
22
22
  }>, {
23
- completed?: number;
24
- total?: number;
23
+ completed: number;
24
+ total: number;
25
25
  }, {
26
- completed?: number;
27
- total?: number;
26
+ completed: number;
27
+ total: number;
28
28
  }>>;
29
29
  }, "strict", z.ZodTypeAny, {
30
- source?: "executor" | "host";
31
- startedAt?: string;
32
- summary?: string;
30
+ source: "executor" | "host";
31
+ observedAt: string;
32
+ startedAt?: string | undefined;
33
+ summary?: string | undefined;
34
+ phase?: string | undefined;
33
35
  steps?: {
34
- completed?: number;
35
- total?: number;
36
- };
37
- observedAt?: string;
38
- phase?: string;
36
+ completed: number;
37
+ total: number;
38
+ } | undefined;
39
39
  }, {
40
- source?: "executor" | "host";
41
- startedAt?: string;
42
- summary?: string;
40
+ source: "executor" | "host";
41
+ observedAt: string;
42
+ startedAt?: string | undefined;
43
+ summary?: string | undefined;
44
+ phase?: string | undefined;
43
45
  steps?: {
44
- completed?: number;
45
- total?: number;
46
- };
47
- observedAt?: string;
48
- phase?: string;
46
+ completed: number;
47
+ total: number;
48
+ } | undefined;
49
49
  }>;
50
50
  version: z.ZodLiteral<1>;
51
51
  invocationId: z.ZodString;
@@ -56,32 +56,32 @@ export declare const agentRuntimeEventSchema: z.ZodDiscriminatedUnion<"kind", [z
56
56
  projectTaskId: z.ZodString;
57
57
  taskExecutionId: z.ZodString;
58
58
  }, "strict", z.ZodTypeAny, {
59
- projectId?: string;
60
- projectTaskId?: string;
61
- taskExecutionId?: string;
59
+ projectId: string;
60
+ projectTaskId: string;
61
+ taskExecutionId: string;
62
62
  }, {
63
- projectId?: string;
64
- projectTaskId?: string;
65
- taskExecutionId?: string;
63
+ projectId: string;
64
+ projectTaskId: string;
65
+ taskExecutionId: string;
66
66
  }>>;
67
67
  }, "strict", z.ZodTypeAny, {
68
68
  version?: 1;
69
69
  kind?: "progress";
70
70
  progress?: {
71
- source?: "executor" | "host";
72
- startedAt?: string;
73
- summary?: string;
71
+ source: "executor" | "host";
72
+ observedAt: string;
73
+ startedAt?: string | undefined;
74
+ summary?: string | undefined;
75
+ phase?: string | undefined;
74
76
  steps?: {
75
- completed?: number;
76
- total?: number;
77
- };
78
- observedAt?: string;
79
- phase?: string;
77
+ completed: number;
78
+ total: number;
79
+ } | undefined;
80
80
  };
81
81
  projectTask?: {
82
- projectId?: string;
83
- projectTaskId?: string;
84
- taskExecutionId?: string;
82
+ projectId: string;
83
+ projectTaskId: string;
84
+ taskExecutionId: string;
85
85
  };
86
86
  invocationId?: string;
87
87
  revision?: number;
@@ -89,20 +89,20 @@ export declare const agentRuntimeEventSchema: z.ZodDiscriminatedUnion<"kind", [z
89
89
  version?: 1;
90
90
  kind?: "progress";
91
91
  progress?: {
92
- source?: "executor" | "host";
93
- startedAt?: string;
94
- summary?: string;
92
+ source: "executor" | "host";
93
+ observedAt: string;
94
+ startedAt?: string | undefined;
95
+ summary?: string | undefined;
96
+ phase?: string | undefined;
95
97
  steps?: {
96
- completed?: number;
97
- total?: number;
98
- };
99
- observedAt?: string;
100
- phase?: string;
98
+ completed: number;
99
+ total: number;
100
+ } | undefined;
101
101
  };
102
102
  projectTask?: {
103
- projectId?: string;
104
- projectTaskId?: string;
105
- taskExecutionId?: string;
103
+ projectId: string;
104
+ projectTaskId: string;
105
+ taskExecutionId: string;
106
106
  };
107
107
  invocationId?: string;
108
108
  revision?: number;
@@ -118,22 +118,22 @@ export declare const agentRuntimeEventSchema: z.ZodDiscriminatedUnion<"kind", [z
118
118
  projectTaskId: z.ZodString;
119
119
  taskExecutionId: z.ZodString;
120
120
  }, "strict", z.ZodTypeAny, {
121
- projectId?: string;
122
- projectTaskId?: string;
123
- taskExecutionId?: string;
121
+ projectId: string;
122
+ projectTaskId: string;
123
+ taskExecutionId: string;
124
124
  }, {
125
- projectId?: string;
126
- projectTaskId?: string;
127
- taskExecutionId?: string;
125
+ projectId: string;
126
+ projectTaskId: string;
127
+ taskExecutionId: string;
128
128
  }>>;
129
129
  }, "strict", z.ZodTypeAny, {
130
130
  status?: "failed" | "succeeded" | "cancelled";
131
131
  version?: 1;
132
132
  kind?: "result";
133
133
  projectTask?: {
134
- projectId?: string;
135
- projectTaskId?: string;
136
- taskExecutionId?: string;
134
+ projectId: string;
135
+ projectTaskId: string;
136
+ taskExecutionId: string;
137
137
  };
138
138
  invocationId?: string;
139
139
  revision?: number;
@@ -142,9 +142,9 @@ export declare const agentRuntimeEventSchema: z.ZodDiscriminatedUnion<"kind", [z
142
142
  version?: 1;
143
143
  kind?: "result";
144
144
  projectTask?: {
145
- projectId?: string;
146
- projectTaskId?: string;
147
- taskExecutionId?: string;
145
+ projectId: string;
146
+ projectTaskId: string;
147
+ taskExecutionId: string;
148
148
  };
149
149
  invocationId?: string;
150
150
  revision?: number;
@@ -160,21 +160,21 @@ export declare const agentRuntimeEventSchema: z.ZodDiscriminatedUnion<"kind", [z
160
160
  projectTaskId: z.ZodString;
161
161
  taskExecutionId: z.ZodString;
162
162
  }, "strict", z.ZodTypeAny, {
163
- projectId?: string;
164
- projectTaskId?: string;
165
- taskExecutionId?: string;
163
+ projectId: string;
164
+ projectTaskId: string;
165
+ taskExecutionId: string;
166
166
  }, {
167
- projectId?: string;
168
- projectTaskId?: string;
169
- taskExecutionId?: string;
167
+ projectId: string;
168
+ projectTaskId: string;
169
+ taskExecutionId: string;
170
170
  }>>;
171
171
  }, "strict", z.ZodTypeAny, {
172
172
  version?: 1;
173
173
  kind?: "input_request";
174
174
  projectTask?: {
175
- projectId?: string;
176
- projectTaskId?: string;
177
- taskExecutionId?: string;
175
+ projectId: string;
176
+ projectTaskId: string;
177
+ taskExecutionId: string;
178
178
  };
179
179
  invocationId?: string;
180
180
  revision?: number;
@@ -183,9 +183,9 @@ export declare const agentRuntimeEventSchema: z.ZodDiscriminatedUnion<"kind", [z
183
183
  version?: 1;
184
184
  kind?: "input_request";
185
185
  projectTask?: {
186
- projectId?: string;
187
- projectTaskId?: string;
188
- taskExecutionId?: string;
186
+ projectId: string;
187
+ projectTaskId: string;
188
+ taskExecutionId: string;
189
189
  };
190
190
  invocationId?: string;
191
191
  revision?: number;
@@ -1,4 +1,4 @@
1
- import type { JSONValue, TAvatar } from '@xpert-ai/contracts';
1
+ import type { JSONValue, TAvatar, ProjectPipelineNativeSource } from '@xpert-ai/contracts';
2
2
  /** Task lifecycle snapshot. interrupted means paused; unknown does not confirm failure. */
3
3
  export type AgentMiddlewareAssistantTaskStatus = 'queued' | 'running' | 'succeeded' | 'failed' | 'interrupted' | 'unknown';
4
4
  /** Existing platform file reference; access remains subject to host authorization. */
@@ -28,6 +28,30 @@ export type AgentMiddlewareExternalAssistantExpectation = {
28
28
  templateKey: string;
29
29
  agentKey: string;
30
30
  };
31
+ export type AgentMiddlewarePublishedAgentTarget = {
32
+ requesterXpertId: string;
33
+ expectation: AgentMiddlewareExternalAssistantExpectation;
34
+ };
35
+ export type AgentMiddlewareResolvedAgent = {
36
+ xpertId: string;
37
+ workspaceId: string;
38
+ agentKey: string;
39
+ };
40
+ /** Safe capabilities of the exact accessible published Assistant; no draft or prompt content. */
41
+ export type AgentMiddlewarePublishedContext = {
42
+ primaryAgentKey: string | null;
43
+ publishedVersion: string;
44
+ templateSource: {
45
+ pluginName?: string;
46
+ templateKey: string;
47
+ } | null;
48
+ features: string[];
49
+ availableAgents: Array<{
50
+ key: string;
51
+ title?: string;
52
+ role?: string;
53
+ }>;
54
+ };
31
55
  /** Resolve the executor from the requester's required, direct published external-Assistant connections. */
32
56
  export type AgentMiddlewareAssistantTaskTarget = {
33
57
  kind: 'external_assistant';
@@ -93,6 +117,8 @@ export type AgentMiddlewareCorrelatedExecution = {
93
117
  export type AgentMiddlewareAssistantTaskInput = {
94
118
  /** Current/requesting Assistant ID; must match target.requesterXpertId when target is supplied. */
95
119
  xpertId: string;
120
+ /** Fail before dispatch if the accessible published executor changed after the caller prepared its intent. */
121
+ expectedPublishedVersion?: string;
96
122
  /** Selects the base/Primary model; child Agents retain authored models. */
97
123
  modelId?: string;
98
124
  /** Entry Agent for the current Assistant; external targets use their resolved primary Agent. */
@@ -102,6 +128,8 @@ export type AgentMiddlewareAssistantTaskInput = {
102
128
  conversationId?: string | null;
103
129
  executionId?: string | null;
104
130
  projectId?: string | null;
131
+ /** Optional Pipeline dispatch provenance. Host revalidates the lease and pins exact native identities before dispatch. */
132
+ pipelineSource?: ProjectPipelineNativeSource;
105
133
  taskId?: string;
106
134
  /** Per-run idempotency key. Otherwise correlation.operationId or executionId is used; taskId alone is insufficient. */
107
135
  clientMessageId?: string;
@@ -143,6 +171,11 @@ export type AgentMiddlewareAssistantTaskCancelResult = {
143
171
  };
144
172
  /** Host Assistant Task API. Feature-detect optional methods before calling them. */
145
173
  export interface AgentMiddlewareAssistantTaskApi {
174
+ getPublishedContext?(xpertId: string): Promise<AgentMiddlewarePublishedContext>;
175
+ /** Resolve an Agent entrypoint in an accessible published Assistant in the requester's workspace. Ambiguous matches are rejected. */
176
+ resolvePublishedAgent?(input: AgentMiddlewarePublishedAgentTarget): Promise<AgentMiddlewareResolvedAgent>;
177
+ /** Delegate a trusted plugin operation to the resolved resource with live access checks; preserve the original credential audience. */
178
+ withPublishedAgent?<T>(input: AgentMiddlewarePublishedAgentTarget, operation: (target: AgentMiddlewareResolvedAgent) => Promise<T>): Promise<T>;
146
179
  /**
147
180
  * Verify that a running native delegate is the requester's bound external role.
148
181
  *
@@ -174,6 +207,8 @@ export interface AgentMiddlewareAssistantTaskApi {
174
207
  getModels?(xpertId: string): Promise<import('@xpert-ai/contracts').TAssistantModelsResponse>;
175
208
  /** Submit once and retain the receipt; use getTaskStatus to follow asynchronous progress. */
176
209
  startTask(input: AgentMiddlewareAssistantTaskInput): Promise<AgentMiddlewareAssistantTaskResult>;
210
+ /** Pin a Pipeline task before persisting deferred work. Save the returned input unchanged; this does not start execution. */
211
+ preparePipelineTask?(input: AgentMiddlewareAssistantTaskInput): Promise<AgentMiddlewareAssistantTaskInput>;
177
212
  /** List safe binding descriptors without deployed Assistant instance IDs. */
178
213
  listExternalAssistantBindings?(input: AgentMiddlewareListExternalAssistantBindingsInput): Promise<AgentMiddlewareExternalAssistantBinding[]>;
179
214
  /** Read executions owned by the requester and its currently bound external Assistants. */