@xpert-ai/plugin-sdk 3.37.0 → 3.38.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.
- package/artifact-document.cjs.js +1 -1
- package/artifact-document.esm.js +1 -1
- package/docs/README.md +87 -0
- package/docs/artifact-documents.md +1 -1
- package/index.cjs.js +345 -102
- package/index.esm.js +338 -104
- package/model-provider.cjs.js +3 -0
- package/model-provider.esm.js +3 -1
- package/package.json +2 -2
- package/src/index.d.ts +1 -0
- package/src/lib/artifact-document/host.d.ts +2 -0
- package/src/lib/core/index.d.ts +2 -0
- package/src/lib/core/named-provider.registry.d.ts +9 -0
- package/src/lib/core/provider-registration.d.ts +9 -0
- package/src/lib/project-pipeline/adapters.d.ts +3 -2
- package/src/lib/rag/capability/knowledgebase-documents.d.ts +9 -0
- package/src/lib/runtime/capabilities/conversation.d.ts +8 -0
- package/src/lib/runtime/capabilities/index.d.ts +1 -0
- package/src/lib/sandbox/file-edit-command.d.ts +2 -1
- package/src/lib/sandbox/file-edits.d.ts +1 -0
- package/src/lib/sandbox/protocol.d.ts +7 -1
- package/src/lib/strategy.d.ts +8 -2
- package/src/lib/widgets/index.d.ts +2 -0
- package/src/lib/widgets/message-widget-provider/index.d.ts +3 -0
- package/src/lib/widgets/message-widget-provider/provider.decorator.d.ts +2 -0
- package/src/lib/widgets/message-widget-provider/provider.registry.d.ts +7 -0
- package/src/lib/widgets/message-widget-provider/types.d.ts +16 -0
- package/src/lib/widgets/widget-action/action.decorator.d.ts +2 -0
- package/src/lib/widgets/widget-action/action.registry.d.ts +8 -0
- package/src/lib/widgets/widget-action/index.d.ts +3 -0
- package/src/lib/widgets/widget-action/types.d.ts +19 -0
package/src/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './lib/plugin-metadata';
|
|
|
4
4
|
export * from './lib/artifact-namespace';
|
|
5
5
|
export * from './lib/resource-card';
|
|
6
6
|
export * from './lib/resource-card-provider';
|
|
7
|
+
export * from './lib/widgets';
|
|
7
8
|
export * from './lib/types';
|
|
8
9
|
export * from './lib/logger';
|
|
9
10
|
export * from './lib/integration/index';
|
|
@@ -10,6 +10,8 @@ export interface ArtifactDocumentHostOptions<T> {
|
|
|
10
10
|
dependencies?: ArtifactDocumentDependencyAsset[];
|
|
11
11
|
/** Trusted resource policy; unrestricted mode permits networking. Omit to block external resources. */
|
|
12
12
|
networkPolicy?: ArtifactDocumentNetworkPolicy;
|
|
13
|
+
/** Allow this document to initiate file downloads. Only a trusted host may opt in. */
|
|
14
|
+
allowDownloads?: boolean;
|
|
13
15
|
/** Public binding IDs and presentation defaults for this document generation. */
|
|
14
16
|
context: ArtifactDocumentContext;
|
|
15
17
|
/** Resolve against saved Bindings on the server with the current user's access; never execute a query definition from HTML. */
|
package/src/lib/core/index.d.ts
CHANGED
|
@@ -10,3 +10,5 @@ export * from './types';
|
|
|
10
10
|
export * from './strategy-bus';
|
|
11
11
|
export * from './webhook';
|
|
12
12
|
export * from './runtime-capability';
|
|
13
|
+
export * from './named-provider.registry';
|
|
14
|
+
export { assertPluginRegistrationOwner, definePluginRegistration, readPluginProviderRegistrations, type PluginProviderRegistration } from './provider-registration';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseStrategyRegistry, type StrategySource } from '../strategy';
|
|
2
|
+
/** Opt-in registry for validated, owner-qualified providers that cannot replace a different live instance. */
|
|
3
|
+
export declare abstract class NamedProviderRegistry<T extends object> extends BaseStrategyRegistry<T> {
|
|
4
|
+
private readonly providerLogger;
|
|
5
|
+
protected abstract isProvider(instance: object): instance is T;
|
|
6
|
+
upsert(instance: unknown): void;
|
|
7
|
+
assertCanRegister(name: string, instance: T, source: StrategySource): void;
|
|
8
|
+
protected onRegistrationError(error: unknown): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** A name is unique within its registration category and installation scope. */
|
|
2
|
+
export interface PluginProviderRegistration {
|
|
3
|
+
kind: string;
|
|
4
|
+
key: string;
|
|
5
|
+
}
|
|
6
|
+
/** Declares a plugin-owned strategy category with a stable metadata key across SDK copies. */
|
|
7
|
+
export declare function definePluginRegistration(metadataKey: string, kind?: string): (name: string) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
8
|
+
export declare function assertPluginRegistrationOwner(name: string, pluginName?: string): void;
|
|
9
|
+
export declare function readPluginProviderRegistrations(target: object, pluginName: string): PluginProviderRegistration[];
|
|
@@ -67,8 +67,9 @@ export interface ProjectPipelineAssistantContext extends ProjectPipelineOperatio
|
|
|
67
67
|
export interface ProjectPipelineAssistantOperation {
|
|
68
68
|
/** Bounded domain prompt/context only; no actor, Project, model or executor overrides. */
|
|
69
69
|
prepare(context: ProjectPipelineAssistantContext): Promise<ProjectPipelineAssistantInput>;
|
|
70
|
-
/**
|
|
71
|
-
|
|
70
|
+
/** Called after native execution and delegated result delivery settle. Return null only when the
|
|
71
|
+
* assigned assistant definitively ended without the required outputs. Throw on an uncertain read. */
|
|
72
|
+
collect(context: ProjectPipelineAssistantContext): Promise<Record<string, ProjectPipelineEvidenceRef> | null>;
|
|
72
73
|
}
|
|
73
74
|
export interface ProjectPipelineRuntimeContext extends ProjectPipelineOperationContext {
|
|
74
75
|
executor: {
|
|
@@ -58,6 +58,10 @@ export type KnowledgebaseDocumentRecord = {
|
|
|
58
58
|
};
|
|
59
59
|
export type KnowledgebaseListDocumentsInput = {
|
|
60
60
|
knowledgebaseId: string;
|
|
61
|
+
/** Exact source fingerprint; null selects legacy documents without a fingerprint. */
|
|
62
|
+
sourceHash?: string | null;
|
|
63
|
+
/** Exact original byte size, optionally narrowing a legacy fingerprint lookup. */
|
|
64
|
+
size?: number;
|
|
61
65
|
page?: number;
|
|
62
66
|
pageSize?: number;
|
|
63
67
|
search?: string;
|
|
@@ -77,6 +81,11 @@ export type KnowledgebaseListDocumentsResult = {
|
|
|
77
81
|
total: number;
|
|
78
82
|
page: number;
|
|
79
83
|
pageSize: number;
|
|
84
|
+
/** Echo validated exact filters so clients never mistake an older host's unfiltered result for a match. */
|
|
85
|
+
appliedFilters?: {
|
|
86
|
+
sourceHash?: string | null;
|
|
87
|
+
size?: number;
|
|
88
|
+
};
|
|
80
89
|
};
|
|
81
90
|
export type KnowledgebaseCreateFolderInput = {
|
|
82
91
|
knowledgebaseId: string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IMessageWidgetProvider, MessageWidgetReference } from '../../widgets/message-widget-provider/types';
|
|
2
|
+
export interface ConversationRuntimeApi {
|
|
3
|
+
/** Binds a provider-owned Widget to an assistant reply in the current thread. */
|
|
4
|
+
publishWidget(issuer: IMessageWidgetProvider, widget: Pick<MessageWidgetReference, 'provider' | 'widgetId'> & {
|
|
5
|
+
messageId?: string;
|
|
6
|
+
}): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare const ConversationRuntimeCapability: import("../../core/runtime-capability").RuntimeCapabilityKey<ConversationRuntimeApi>;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { EditOperation } from './protocol';
|
|
2
2
|
export declare function buildEditCommand(filePath: string, oldString: string, newString: string, replaceAll: boolean): string;
|
|
3
|
+
export declare function buildBatchEditCommand(filePath: string, edits: EditOperation[]): string;
|
|
@@ -2,3 +2,4 @@ import type { EditOperation, EditResult, ExecuteResponse, MaybePromise, MultiEdi
|
|
|
2
2
|
export declare function editCommandResult(filePath: string, result: ExecuteResponse): EditResult;
|
|
3
3
|
/** Stops on failure; never promises rollback or silently reapplies completed edits. */
|
|
4
4
|
export declare function sequentialFileEdits(filePath: string, edits: EditOperation[], apply: (edit: EditOperation) => MaybePromise<EditResult>): Promise<MultiEditResult>;
|
|
5
|
+
export declare function groupedFileEdits(path: string, edits: EditOperation[], execute: (command: string) => MaybePromise<ExecuteResponse>): Promise<MultiEditResult>;
|
|
@@ -151,11 +151,17 @@ export interface MultiEditResult {
|
|
|
151
151
|
filesUpdate?: Record<string, FileData> | null;
|
|
152
152
|
/** Results from each individual edit operation */
|
|
153
153
|
results?: EditResult[];
|
|
154
|
-
/**
|
|
154
|
+
/** Indices are one-based. appliedEdits counts only the confirmed prefix. */
|
|
155
155
|
progress?: {
|
|
156
156
|
mode: 'sequential';
|
|
157
157
|
appliedEdits: number;
|
|
158
|
+
/** An edit was confirmed to have failed (for example, its old text did not match). */
|
|
158
159
|
failedEdit?: number;
|
|
160
|
+
/** Inclusive range of the submitted batch with unknown persistence. Later edits were not sent. */
|
|
161
|
+
unconfirmedEdits?: {
|
|
162
|
+
from: number;
|
|
163
|
+
to: number;
|
|
164
|
+
};
|
|
159
165
|
};
|
|
160
166
|
/** Metadata for the multi-edit operation, attached to the ToolMessage */
|
|
161
167
|
metadata?: Record<string, unknown>;
|
package/src/lib/strategy.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OnModuleInit, type Type } from '@nestjs/common';
|
|
1
|
+
import { OnModuleInit, type OnModuleDestroy, type Type } from '@nestjs/common';
|
|
2
2
|
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
3
3
|
import { StrategyBus } from './core/strategy-bus';
|
|
4
4
|
export type StrategySource = {
|
|
@@ -10,17 +10,21 @@ export type StrategySource = {
|
|
|
10
10
|
pluginVersion?: string;
|
|
11
11
|
scopeKey: string;
|
|
12
12
|
};
|
|
13
|
-
export declare class BaseStrategyRegistry<S> implements OnModuleInit {
|
|
13
|
+
export declare class BaseStrategyRegistry<S> implements OnModuleInit, OnModuleDestroy {
|
|
14
14
|
protected readonly strategyKey: string;
|
|
15
15
|
protected discoveryService: DiscoveryService;
|
|
16
16
|
protected reflector: Reflector;
|
|
17
17
|
private readonly logger;
|
|
18
|
+
private strategySubscription?;
|
|
18
19
|
protected readonly bus: StrategyBus;
|
|
19
20
|
protected strategies: Map<string, Map<string, S>>;
|
|
20
21
|
protected pluginStrategies: Map<string, Set<string>>;
|
|
21
22
|
private readonly explicitSources;
|
|
22
23
|
constructor(strategyKey: string, discoveryService: DiscoveryService, reflector: Reflector);
|
|
23
24
|
onModuleInit(): void;
|
|
25
|
+
onModuleDestroy(): void;
|
|
26
|
+
/** Policy for rejected registrations delivered by the lifecycle bus. */
|
|
27
|
+
protected onRegistrationError(error: unknown): void;
|
|
24
28
|
upsert(instance: unknown): void;
|
|
25
29
|
/** Registers a host-generated adapter without mutating shared class metadata. */
|
|
26
30
|
register(type: string, instance: S, source: StrategySource): S;
|
|
@@ -40,6 +44,8 @@ export declare class BaseStrategyRegistry<S> implements OnModuleInit {
|
|
|
40
44
|
protected resolveOrganization(organizationId?: string): string;
|
|
41
45
|
protected resolveGlobalFallbackOrganization(): string;
|
|
42
46
|
protected resolveStrategyScopeKeys(organizationId?: string): string[];
|
|
47
|
+
/** Resolves a registered name in the effective scope, without requiring a match. */
|
|
48
|
+
findByName(type: string, organizationId?: string): S | undefined;
|
|
43
49
|
/**
|
|
44
50
|
* Get strategy by type from the given organization including global strategies as fallback.
|
|
45
51
|
*
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const MESSAGE_WIDGET_PROVIDER = "XPERT_MESSAGE_WIDGET_PROVIDER";
|
|
2
|
+
export declare const MessageWidgetProvider: (name: string) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
2
|
+
import { NamedProviderRegistry } from '../../core/named-provider.registry';
|
|
3
|
+
import type { IMessageWidgetProvider } from './types';
|
|
4
|
+
export declare class MessageWidgetProviderRegistry extends NamedProviderRegistry<IMessageWidgetProvider> {
|
|
5
|
+
constructor(discovery: DiscoveryService, reflector: Reflector);
|
|
6
|
+
protected isProvider(instance: object): instance is IMessageWidgetProvider;
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { TMessageContentWidget } from '@xpert-ai/contracts';
|
|
2
|
+
export interface MessageWidgetReference {
|
|
3
|
+
threadId: string;
|
|
4
|
+
messageId: string;
|
|
5
|
+
widgetId: string;
|
|
6
|
+
provider: string;
|
|
7
|
+
}
|
|
8
|
+
export interface IMessageWidgetProvider {
|
|
9
|
+
/** Explicit opt-in to producing audience-safe content for restricted runtime sessions. */
|
|
10
|
+
readonly visibleInRestrictedSessions?: boolean;
|
|
11
|
+
/** Only currently authorized cards may be returned. Omitted references remain hidden. */
|
|
12
|
+
resolve(references: readonly MessageWidgetReference[]): Promise<Array<{
|
|
13
|
+
messageId: string;
|
|
14
|
+
widget: TMessageContentWidget;
|
|
15
|
+
}>>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const WIDGET_ACTION_PROVIDER = "XPERT_WIDGET_ACTION_PROVIDER";
|
|
2
|
+
export declare const WidgetActionProvider: (name: string) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
2
|
+
import { NamedProviderRegistry } from '../../core/named-provider.registry';
|
|
3
|
+
import type { IWidgetActionHandler, IWidgetActionProvider } from './types';
|
|
4
|
+
export declare class WidgetActionProviderRegistry extends NamedProviderRegistry<IWidgetActionProvider> {
|
|
5
|
+
constructor(discovery: DiscoveryService, reflector: Reflector);
|
|
6
|
+
protected isProvider(instance: object): instance is IWidgetActionProvider;
|
|
7
|
+
resolve(action: string): IWidgetActionHandler | undefined;
|
|
8
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface WidgetActionContext {
|
|
2
|
+
threadId: string;
|
|
3
|
+
messageId: string;
|
|
4
|
+
widgetId: string;
|
|
5
|
+
/** Untrusted form values supplied by the caller. */
|
|
6
|
+
fields: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
export interface IWidgetActionHandler {
|
|
9
|
+
/** Receipt-backed widgets require the handler to verify the authoritative offer before performing any mutation. */
|
|
10
|
+
readonly widgetSource?: 'message' | 'receipt';
|
|
11
|
+
/** The handler enforces business permissions and validates the submitted fields. */
|
|
12
|
+
execute(context: WidgetActionContext): Promise<{
|
|
13
|
+
refresh?: 'thread';
|
|
14
|
+
}>;
|
|
15
|
+
}
|
|
16
|
+
export interface IWidgetActionProvider {
|
|
17
|
+
/** Local names contain only letters, digits, underscores or hyphens and are scoped to this provider. */
|
|
18
|
+
readonly actions: Readonly<Record<string, IWidgetActionHandler>>;
|
|
19
|
+
}
|