@xpert-ai/plugin-sdk 3.9.8 → 4.0.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.
@@ -0,0 +1,22 @@
1
+ export type RuntimeCapabilityKey<T> = {
2
+ readonly id: string;
3
+ readonly description?: string;
4
+ readonly __type?: T;
5
+ };
6
+ export declare function createRuntimeCapability<T>(id: string, options?: {
7
+ description?: string;
8
+ }): RuntimeCapabilityKey<T>;
9
+ export interface AgentMiddlewareRuntimeCapabilityRegistry {
10
+ has<T>(key: RuntimeCapabilityKey<T> | string): boolean;
11
+ get<T>(key: RuntimeCapabilityKey<T> | string): T | undefined;
12
+ require<T>(key: RuntimeCapabilityKey<T> | string): T;
13
+ }
14
+ export declare const XPERT_RUNTIME_CAPABILITIES_TOKEN = "XPERT_RUNTIME_CAPABILITIES";
15
+ export declare class DefaultAgentMiddlewareRuntimeCapabilityRegistry implements AgentMiddlewareRuntimeCapabilityRegistry {
16
+ private readonly capabilities;
17
+ constructor(entries?: Array<[RuntimeCapabilityKey<unknown> | string, unknown]>);
18
+ register<T>(key: RuntimeCapabilityKey<T> | string, implementation: T): this;
19
+ has<T>(key: RuntimeCapabilityKey<T> | string): boolean;
20
+ get<T>(key: RuntimeCapabilityKey<T> | string): T | undefined;
21
+ require<T>(key: RuntimeCapabilityKey<T> | string): T;
22
+ }
@@ -1,11 +1,14 @@
1
1
  import { Embeddings } from '@langchain/core/embeddings';
2
2
  import { BaseLanguageModel } from '@langchain/core/language_models/base';
3
3
  import { BaseChatModel } from '@langchain/core/language_models/chat_models';
4
- import type { Runtime as LangGraphRuntime } from "@langchain/langgraph";
5
- import type { BaseMessage } from "@langchain/core/messages";
6
- import { ICopilotModel, ILLMUsage, IXpertAgentExecution, JSONValue, TSandboxConfigurable } from "@xpert-ai/contracts";
4
+ import type { Runtime as LangGraphRuntime } from '@langchain/langgraph';
5
+ import type { BaseMessage } from '@langchain/core/messages';
6
+ import { ICopilotModel, ILLMUsage, IXpertAgentExecution, JSONValue, TSandboxConfigurable } from '@xpert-ai/contracts';
7
7
  import { Subscriber } from 'rxjs';
8
8
  import { IRerank } from '../../ai-model/types';
9
+ import type { AgentMiddlewareRuntimeCapabilityRegistry } from './runtime-capability';
10
+ export * from './runtime-capability';
11
+ export * from './capabilities';
9
12
  /**
10
13
  * Type for the agent's built-in state properties.
11
14
  */
@@ -54,7 +57,7 @@ export type WithMaybeContext<TContext> = undefined extends TContext ? {
54
57
  /**
55
58
  * Runtime information available to middleware (readonly).
56
59
  */
57
- export type Runtime<TContext = unknown> = Partial<Omit<LangGraphRuntime<TContext>, "context" | "configurable">> & WithMaybeContext<TContext> & {
60
+ export type Runtime<TContext = unknown> = Partial<Omit<LangGraphRuntime<TContext>, 'context' | 'configurable'>> & WithMaybeContext<TContext> & {
58
61
  configurable?: {
59
62
  thread_id?: string;
60
63
  sandbox?: TSandboxConfigurable | null;
@@ -75,8 +78,26 @@ export type AgentMiddlewareWrapWorkflowNodeExecutionParams = {
75
78
  subscriber?: Subscriber<MessageEvent>;
76
79
  catchError?: (error: Error) => Promise<void>;
77
80
  };
81
+ export type AgentMiddlewareEventStatus = 'running' | 'success' | 'fail';
82
+ export type AgentMiddlewareEvent = {
83
+ type?: 'middleware_event';
84
+ middlewareName?: string;
85
+ middlewareKey?: string;
86
+ title?: string;
87
+ message?: string;
88
+ status?: AgentMiddlewareEventStatus;
89
+ phase?: string;
90
+ executionId?: string;
91
+ threadId?: string;
92
+ created_date?: string;
93
+ end_date?: string;
94
+ error?: unknown;
95
+ data?: unknown;
96
+ [key: string]: unknown;
97
+ };
78
98
  export interface AgentMiddlewareRuntimeApi {
79
99
  createModelClient<T = AgentMiddlewareModelClient>(copilotModel: ICopilotModel, options: AgentMiddlewareCreateModelClientOptions): Promise<T>;
80
100
  wrapWorkflowNodeExecution<T>(run: (execution: Partial<IXpertAgentExecution>) => Promise<AgentMiddlewareWrapWorkflowNodeExecutionResult<T>>, params: AgentMiddlewareWrapWorkflowNodeExecutionParams): Promise<T>;
101
+ emitMiddlewareEvent?(event: AgentMiddlewareEvent): Promise<void> | void;
102
+ capabilities?: AgentMiddlewareRuntimeCapabilityRegistry;
81
103
  }
82
- export {};
@@ -1,11 +1,12 @@
1
1
  import { IWFNMiddleware, TAgentMiddlewareMeta, TXpertFeatures } from '@xpert-ai/contracts';
2
- import { StructuredToolInterface } from "@langchain/core/tools";
2
+ import { StructuredToolInterface } from '@langchain/core/tools';
3
3
  import { RunnableToolLike } from '@langchain/core/runnables';
4
4
  import { AgentMiddleware } from './types';
5
5
  import { PromiseOrValue } from '../../types';
6
6
  import { AgentMiddlewareRuntimeApi } from './runtime';
7
7
  export interface IAgentMiddlewareContext {
8
8
  tenantId: string;
9
+ organizationId?: string | null;
9
10
  userId: string;
10
11
  workspaceId?: string;
11
12
  projectId?: string;
@@ -1,4 +1,4 @@
1
- import { JsonSchemaObjectType, PluginMeta } from '@xpert-ai/contracts';
1
+ import { IconDefinition, JsonSchemaObjectType, PluginMeta, PluginTargetApp, PluginTargetAppMeta, TAvatar, XpertTypeEnum } from '@xpert-ai/contracts';
2
2
  import type { DynamicModule, INestApplicationContext } from '@nestjs/common';
3
3
  import { ModuleRef } from '@nestjs/core';
4
4
  import type { ZodSchema } from 'zod';
@@ -36,11 +36,43 @@ export interface PluginConfigSpec<T extends object = any> {
36
36
  export interface XpertPlugin<TConfig extends object = any> extends PluginLifecycle, PluginHealth {
37
37
  meta: PluginMeta;
38
38
  config?: PluginConfigSpec<TConfig>;
39
+ /**
40
+ * Xpert DSL templates contributed by this plugin. The platform namespaces
41
+ * template ids as `${pluginName}:${key}` when exposing them through the
42
+ * xpert-template API.
43
+ */
44
+ templates?: XpertTemplateContribution[] | XpertTemplateProvider;
39
45
  /** Declares the required system-level permissions for this plugin. */
40
46
  permissions?: Permissions;
41
47
  /** Returns the DynamicModule to be mounted to the main application (can be set as global) */
42
48
  register(ctx: PluginContext<TConfig>): DynamicModule;
43
49
  }
50
+ export interface XpertTemplateContribution {
51
+ key: string;
52
+ id?: string;
53
+ name?: string;
54
+ title?: string;
55
+ description?: string;
56
+ category?: string;
57
+ copyright?: string | null;
58
+ privacyPolicy?: string | null;
59
+ avatar?: TAvatar;
60
+ icon?: IconDefinition;
61
+ type?: XpertTypeEnum | 'project';
62
+ targetApps?: PluginTargetApp[];
63
+ targetAppMeta?: PluginTargetAppMeta | null;
64
+ dslContent?: string;
65
+ export_data?: string;
66
+ order?: number;
67
+ default?: boolean;
68
+ startPrompts?: string[];
69
+ releaseNotes?: string;
70
+ xpertName?: string;
71
+ [key: string]: unknown;
72
+ }
73
+ export interface XpertTemplateProvider {
74
+ listTemplates(ctx: PluginContext): PromiseOrValue<XpertTemplateContribution[]>;
75
+ }
44
76
  export interface PluginContext<TConfig extends object = any> {
45
77
  module: ModuleRef;
46
78
  app?: INestApplicationContext;
@@ -1,4 +1,5 @@
1
1
  export * from './provider.decorator';
2
2
  export * from './provider.interface';
3
3
  export * from './provider.registry';
4
+ export * from './remote-component-html';
4
5
  export * from './tokens';
@@ -1,7 +1,16 @@
1
- import { XpertExtensionViewManifest, XpertResolvedViewHostContext, XpertViewActionRequest, XpertViewActionResult, XpertViewDataResult, XpertViewQuery } from '@xpert-ai/contracts';
1
+ import { XpertExtensionViewManifest, XpertRemoteComponentEntry, XpertRemoteComponentViewSchema, XpertResolvedViewHostContext, XpertViewActionRequest, XpertViewActionResult, XpertViewDataResult, XpertViewParameterOptionsQuery, XpertViewParameterOptionsResult, XpertViewQuery } from '@xpert-ai/contracts';
2
+ export interface XpertViewFileActionFile {
3
+ buffer: Buffer;
4
+ originalname?: string;
5
+ mimetype?: string;
6
+ size?: number;
7
+ }
2
8
  export interface IXpertViewExtensionProvider {
3
9
  supports(context: XpertResolvedViewHostContext): Promise<boolean> | boolean;
4
10
  getViewManifests(context: XpertResolvedViewHostContext, slot: string): Promise<XpertExtensionViewManifest[]> | XpertExtensionViewManifest[];
5
11
  getViewData(context: XpertResolvedViewHostContext, viewKey: string, query: XpertViewQuery): Promise<XpertViewDataResult> | XpertViewDataResult;
6
12
  executeViewAction?(context: XpertResolvedViewHostContext, viewKey: string, actionKey: string, request: XpertViewActionRequest): Promise<XpertViewActionResult> | XpertViewActionResult;
13
+ executeViewFileAction?(context: XpertResolvedViewHostContext, viewKey: string, actionKey: string, request: XpertViewActionRequest, file: XpertViewFileActionFile): Promise<XpertViewActionResult> | XpertViewActionResult;
14
+ getViewParameterOptions?(context: XpertResolvedViewHostContext, viewKey: string, parameterKey: string, query: XpertViewParameterOptionsQuery): Promise<XpertViewParameterOptionsResult> | XpertViewParameterOptionsResult;
15
+ getRemoteComponentEntry?(context: XpertResolvedViewHostContext, viewKey: string, component: XpertRemoteComponentViewSchema['component']): Promise<XpertRemoteComponentEntry> | XpertRemoteComponentEntry;
7
16
  }
@@ -0,0 +1,9 @@
1
+ export interface RenderRemoteReactIframeHtmlOptions {
2
+ title: string;
3
+ reactUmd: string;
4
+ reactDomUmd: string;
5
+ appScript: string;
6
+ appCss?: string;
7
+ lang?: string;
8
+ }
9
+ export declare function renderRemoteReactIframeHtml(options: RenderRemoteReactIframeHtmlOptions): string;