@xpert-ai/plugin-sdk 3.18.5 → 3.18.7
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/CHANGELOG.md +35 -0
- package/README.md +44 -0
- package/data-workbench.cjs.default.js +1 -0
- package/data-workbench.cjs.js +669 -0
- package/data-workbench.cjs.mjs +2 -0
- package/data-workbench.d.ts +1 -0
- package/data-workbench.esm.js +663 -0
- package/index.cjs.js +3118 -33
- package/index.esm.js +3109 -39
- package/model-provider.cjs.js +9 -0
- package/model-provider.esm.js +8 -2
- package/package.json +33 -27
- package/src/data-workbench.d.ts +3 -0
- package/src/lib/core/runtime-capability.d.ts +4 -0
- package/src/lib/core/strategy-bus.d.ts +3 -0
- package/src/lib/data/datasource/index.d.ts +3 -0
- package/src/lib/data/datasource/types.d.ts +2 -0
- package/src/lib/data/datasource/workbench-adapter.d.ts +39 -0
- package/src/lib/data/datasource/workbench-pagination.d.ts +6 -0
- package/src/lib/data/datasource/workbench-sql-lexer.d.ts +11 -0
- package/src/lib/data/datasource/workbench-sql-syntax.d.ts +3 -0
- package/src/lib/data/datasource/workbench-sql.d.ts +12 -0
- package/src/lib/data/datasource/workbench.d.ts +133 -0
- package/src/lib/rag/analyzer/index.d.ts +3 -0
- package/src/lib/rag/analyzer/strategy.decorator.d.ts +2 -0
- package/src/lib/rag/analyzer/strategy.interface.d.ts +11 -0
- package/src/lib/rag/analyzer/strategy.registry.d.ts +8 -0
- package/src/lib/rag/index.d.ts +1 -0
- package/src/lib/runtime/capabilities/index.d.ts +1 -0
- package/src/lib/runtime/capabilities/knowledge-graph.d.ts +59 -0
- package/src/lib/tool-provider/component.d.ts +2 -0
- package/src/lib/tool-provider/decorators.d.ts +1 -1
- package/src/lib/tool-provider/index.d.ts +3 -0
- package/src/lib/tool-provider/mcp-methods.d.ts +39 -0
- package/src/lib/tool-provider/provider-methods.d.ts +5 -0
- package/src/lib/tool-provider/tool-result.d.ts +1 -1
- package/src/lib/tool-provider/types.d.ts +12 -1
package/model-provider.cjs.js
CHANGED
|
@@ -154,6 +154,8 @@ function createRuntimeCapability(id, options = {}) {
|
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
156
|
const XPERT_RUNTIME_CAPABILITIES_TOKEN = 'XPERT_RUNTIME_CAPABILITIES';
|
|
157
|
+
/** Metadata key under which RuntimeCapabilityProviderExplorer discovers capability providers. */ const RUNTIME_CAPABILITY_PROVIDER = 'XPERT_RUNTIME_CAPABILITY_PROVIDER';
|
|
158
|
+
/** Tags a Nest provider as the platform implementation of a runtime capability. */ const RuntimeCapabilityProvider = (capability)=>common.SetMetadata(RUNTIME_CAPABILITY_PROVIDER, capability);
|
|
157
159
|
class DefaultRuntimeCapabilityRegistry {
|
|
158
160
|
register(key, implementation) {
|
|
159
161
|
this.capabilities.set(runtimeCapabilityId(key), implementation);
|
|
@@ -192,6 +194,10 @@ const KnowledgebaseProvisioningRuntimeCapability = createRuntimeCapability('plat
|
|
|
192
194
|
description: 'Idempotently provision managed platform knowledgebases and connect them to an Agent.'
|
|
193
195
|
});
|
|
194
196
|
|
|
197
|
+
const KnowledgeGraphRuntimeCapability = createRuntimeCapability('platform.knowledge-graph', {
|
|
198
|
+
description: 'Publish, inspect, and retract source-owned structured knowledge graphs without model extraction.'
|
|
199
|
+
});
|
|
200
|
+
|
|
195
201
|
const KnowledgebaseDocumentsRuntimeCapability = createRuntimeCapability('platform.knowledgebase.documents', {
|
|
196
202
|
description: 'Upload, import, create, process, reprocess, inspect, and delete persistent knowledgebase documents.'
|
|
197
203
|
});
|
|
@@ -389,12 +395,15 @@ exports.BuiltinToolset = BuiltinToolset;
|
|
|
389
395
|
exports.DefaultRuntimeCapabilityRegistry = DefaultRuntimeCapabilityRegistry;
|
|
390
396
|
exports.KnowledgeDocumentVisualAssetsRuntimeCapability = KnowledgeDocumentVisualAssetsRuntimeCapability;
|
|
391
397
|
exports.KnowledgeDocumentVisualAssetsRuntimeFactoryCapability = KnowledgeDocumentVisualAssetsRuntimeFactoryCapability;
|
|
398
|
+
exports.KnowledgeGraphRuntimeCapability = KnowledgeGraphRuntimeCapability;
|
|
392
399
|
exports.KnowledgebaseDocumentsRuntimeCapability = KnowledgebaseDocumentsRuntimeCapability;
|
|
393
400
|
exports.KnowledgebaseProvisioningRuntimeCapability = KnowledgebaseProvisioningRuntimeCapability;
|
|
394
401
|
exports.KnowledgebaseRuntimeCapability = KnowledgebaseRuntimeCapability;
|
|
395
402
|
exports.ModelProviderBuiltinToolset = ModelProviderBuiltinToolset;
|
|
396
403
|
exports.ProjectAccessRuntimeCapability = ProjectAccessRuntimeCapability;
|
|
397
404
|
exports.ProjectProvisioningRuntimeCapability = ProjectProvisioningRuntimeCapability;
|
|
405
|
+
exports.RUNTIME_CAPABILITY_PROVIDER = RUNTIME_CAPABILITY_PROVIDER;
|
|
406
|
+
exports.RuntimeCapabilityProvider = RuntimeCapabilityProvider;
|
|
398
407
|
exports.SANDBOX_JOB_ERROR_CODES = SANDBOX_JOB_ERROR_CODES;
|
|
399
408
|
exports.SANDBOX_JOB_PROGRESS_PREFIX = SANDBOX_JOB_PROGRESS_PREFIX;
|
|
400
409
|
exports.SandboxJobRuntimeError = SandboxJobRuntimeError;
|
package/model-provider.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ as _extends } from './_extends.esm.js';
|
|
2
2
|
import { AiModelTypeEnum } from '@xpert-ai/contracts';
|
|
3
|
-
import { Logger } from '@nestjs/common';
|
|
3
|
+
import { Logger, SetMetadata } from '@nestjs/common';
|
|
4
4
|
import { BaseToolkit, StructuredTool } from '@langchain/core/tools';
|
|
5
5
|
import { z } from 'zod/v3';
|
|
6
6
|
|
|
@@ -152,6 +152,8 @@ function createRuntimeCapability(id, options = {}) {
|
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
154
|
const XPERT_RUNTIME_CAPABILITIES_TOKEN = 'XPERT_RUNTIME_CAPABILITIES';
|
|
155
|
+
/** Metadata key under which RuntimeCapabilityProviderExplorer discovers capability providers. */ const RUNTIME_CAPABILITY_PROVIDER = 'XPERT_RUNTIME_CAPABILITY_PROVIDER';
|
|
156
|
+
/** Tags a Nest provider as the platform implementation of a runtime capability. */ const RuntimeCapabilityProvider = (capability)=>SetMetadata(RUNTIME_CAPABILITY_PROVIDER, capability);
|
|
155
157
|
class DefaultRuntimeCapabilityRegistry {
|
|
156
158
|
register(key, implementation) {
|
|
157
159
|
this.capabilities.set(runtimeCapabilityId(key), implementation);
|
|
@@ -190,6 +192,10 @@ const KnowledgebaseProvisioningRuntimeCapability = createRuntimeCapability('plat
|
|
|
190
192
|
description: 'Idempotently provision managed platform knowledgebases and connect them to an Agent.'
|
|
191
193
|
});
|
|
192
194
|
|
|
195
|
+
const KnowledgeGraphRuntimeCapability = createRuntimeCapability('platform.knowledge-graph', {
|
|
196
|
+
description: 'Publish, inspect, and retract source-owned structured knowledge graphs without model extraction.'
|
|
197
|
+
});
|
|
198
|
+
|
|
193
199
|
const KnowledgebaseDocumentsRuntimeCapability = createRuntimeCapability('platform.knowledgebase.documents', {
|
|
194
200
|
description: 'Upload, import, create, process, reprocess, inspect, and delete persistent knowledgebase documents.'
|
|
195
201
|
});
|
|
@@ -378,4 +384,4 @@ function normalizeWorkspaceScope(scope) {
|
|
|
378
384
|
} : {});
|
|
379
385
|
}
|
|
380
386
|
|
|
381
|
-
export { ActorTokenRuntimeCapability as A, BuiltinToolset as B, DefaultRuntimeCapabilityRegistry as D, KnowledgeDocumentVisualAssetsRuntimeCapability as K, ModelProviderBuiltinToolset as M, ProjectAccessRuntimeCapability as P, SANDBOX_JOB_ERROR_CODES as S,
|
|
387
|
+
export { ActorTokenRuntimeCapability as A, BuiltinToolset as B, DefaultRuntimeCapabilityRegistry as D, KnowledgeDocumentVisualAssetsRuntimeCapability as K, ModelProviderBuiltinToolset as M, ProjectAccessRuntimeCapability as P, RUNTIME_CAPABILITY_PROVIDER as R, SANDBOX_JOB_ERROR_CODES as S, WorkspaceFilesRuntimeCapability as W, XPERT_RUNTIME_CAPABILITIES_TOKEN as X, ActorTokenRuntimeFactoryCapability as a, ArtifactsRuntimeCapability as b, createRuntimeCapability as c, BaseTool as d, BaseToolset as e, KnowledgeDocumentVisualAssetsRuntimeFactoryCapability as f, KnowledgeGraphRuntimeCapability as g, KnowledgebaseDocumentsRuntimeCapability as h, KnowledgebaseProvisioningRuntimeCapability as i, KnowledgebaseRuntimeCapability as j, ProjectProvisioningRuntimeCapability as k, RuntimeCapabilityProvider as l, SANDBOX_JOB_PROGRESS_PREFIX as m, SandboxJobRuntimeError as n, SandboxJobsRuntimeCapability as o, WORKSPACE_FILES_SOURCE as p, isSandboxJobRuntimeError as q };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpert-ai/plugin-sdk",
|
|
3
|
-
"version": "3.18.
|
|
3
|
+
"version": "3.18.7",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,32 +11,6 @@
|
|
|
11
11
|
},
|
|
12
12
|
"main": "./index.cjs.js",
|
|
13
13
|
"module": "./index.esm.js",
|
|
14
|
-
"publishConfig": {
|
|
15
|
-
"access": "public",
|
|
16
|
-
"directory": "dist"
|
|
17
|
-
},
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"@langchain/openai": "0.6.9",
|
|
20
|
-
"@xpert-ai/contracts": "3.18.5",
|
|
21
|
-
"express": "^4.22.1",
|
|
22
|
-
"js-tiktoken": "^1.0.21"
|
|
23
|
-
},
|
|
24
|
-
"peerDependencies": {
|
|
25
|
-
"@langchain/core": "*",
|
|
26
|
-
"@nestjs/common": "*",
|
|
27
|
-
"@nestjs/core": "*",
|
|
28
|
-
"@nestjs/cqrs": "*",
|
|
29
|
-
"ajv": "*",
|
|
30
|
-
"i18next": "*",
|
|
31
|
-
"i18next-fs-backend": "*",
|
|
32
|
-
"json-schema": "*",
|
|
33
|
-
"jsonwebtoken": "*",
|
|
34
|
-
"lodash-es": "*",
|
|
35
|
-
"passport-jwt": "*",
|
|
36
|
-
"rxjs": "*",
|
|
37
|
-
"yaml": "*",
|
|
38
|
-
"zod": "^3.25.0 || ^4.0.0"
|
|
39
|
-
},
|
|
40
14
|
"exports": {
|
|
41
15
|
"./package.json": "./package.json",
|
|
42
16
|
".": {
|
|
@@ -45,6 +19,12 @@
|
|
|
45
19
|
"import": "./index.cjs.mjs",
|
|
46
20
|
"default": "./index.cjs.js"
|
|
47
21
|
},
|
|
22
|
+
"./data-workbench": {
|
|
23
|
+
"module": "./data-workbench.esm.js",
|
|
24
|
+
"types": "./data-workbench.d.ts",
|
|
25
|
+
"import": "./data-workbench.cjs.mjs",
|
|
26
|
+
"default": "./data-workbench.cjs.js"
|
|
27
|
+
},
|
|
48
28
|
"./collaboration-client": {
|
|
49
29
|
"module": "./collaboration-client.esm.js",
|
|
50
30
|
"types": "./collaboration-client.d.ts",
|
|
@@ -70,5 +50,31 @@
|
|
|
70
50
|
"default": "./model-provider-http-client.cjs.js"
|
|
71
51
|
}
|
|
72
52
|
},
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public",
|
|
55
|
+
"directory": "dist"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@langchain/openai": "0.6.9",
|
|
59
|
+
"@xpert-ai/contracts": "3.18.6",
|
|
60
|
+
"express": "^4.22.1",
|
|
61
|
+
"js-tiktoken": "^1.0.21"
|
|
62
|
+
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"@langchain/core": "*",
|
|
65
|
+
"@nestjs/common": "*",
|
|
66
|
+
"@nestjs/core": "*",
|
|
67
|
+
"@nestjs/cqrs": "*",
|
|
68
|
+
"ajv": "*",
|
|
69
|
+
"i18next": "*",
|
|
70
|
+
"i18next-fs-backend": "*",
|
|
71
|
+
"json-schema": "*",
|
|
72
|
+
"jsonwebtoken": "*",
|
|
73
|
+
"lodash-es": "*",
|
|
74
|
+
"passport-jwt": "*",
|
|
75
|
+
"rxjs": "*",
|
|
76
|
+
"yaml": "*",
|
|
77
|
+
"zod": "^3.25.0 || ^4.0.0"
|
|
78
|
+
},
|
|
73
79
|
"types": "./index.d.ts"
|
|
74
80
|
}
|
|
@@ -15,6 +15,10 @@ export interface RuntimeCapabilityRegistry {
|
|
|
15
15
|
/** Read-only capability view accepted by plugin-side consumers. */
|
|
16
16
|
export type RuntimeCapabilityResolver = Pick<RuntimeCapabilityRegistry, 'get'>;
|
|
17
17
|
export declare const XPERT_RUNTIME_CAPABILITIES_TOKEN = "XPERT_RUNTIME_CAPABILITIES";
|
|
18
|
+
/** Metadata key under which RuntimeCapabilityProviderExplorer discovers capability providers. */
|
|
19
|
+
export declare const RUNTIME_CAPABILITY_PROVIDER = "XPERT_RUNTIME_CAPABILITY_PROVIDER";
|
|
20
|
+
/** Tags a Nest provider as the platform implementation of a runtime capability. */
|
|
21
|
+
export declare const RuntimeCapabilityProvider: <T>(capability: RuntimeCapabilityKey<T>) => import("@nestjs/common").CustomDecorator<string>;
|
|
18
22
|
export declare class DefaultRuntimeCapabilityRegistry implements RuntimeCapabilityRegistry {
|
|
19
23
|
private readonly parent?;
|
|
20
24
|
private readonly capabilities;
|
|
@@ -11,6 +11,9 @@ export type StrategyBusEvent<S = any> = {
|
|
|
11
11
|
cause?: 'refresh' | 'uninstall';
|
|
12
12
|
};
|
|
13
13
|
export declare class StrategyBus {
|
|
14
|
+
private readonly removalGuards;
|
|
15
|
+
registerRemovalGuard(guard: (scopeKey: string, pluginNames: readonly string[]) => Promise<void>): () => void;
|
|
16
|
+
assertCanRemove(scopeKey: string, pluginNames: readonly string[]): Promise<void>;
|
|
14
17
|
private readonly subject;
|
|
15
18
|
readonly events$: import("rxjs").Observable<StrategyBusEvent<any>>;
|
|
16
19
|
upsert<S>(strategyType: string, entry: StrategyEntry<S>): void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as _axios from 'axios';
|
|
2
2
|
import { Readable } from 'stream';
|
|
3
|
+
import type { DatabaseWorkbenchAdapter } from './workbench';
|
|
3
4
|
import { IColumnDef, IDataSourceCapabilityQuery, IDSSchema, IDSTable } from '@xpert-ai/contracts';
|
|
4
5
|
export { IColumnDef, IDataSourceCapabilityQuery, IDSSchema, IDSTable } from '@xpert-ai/contracts';
|
|
5
6
|
/**
|
|
@@ -48,6 +49,7 @@ export interface QueryResult<T = unknown> {
|
|
|
48
49
|
* - Connect different types of data sources
|
|
49
50
|
*/
|
|
50
51
|
export interface DBQueryRunner {
|
|
52
|
+
getWorkbenchAdapter?(): DatabaseWorkbenchAdapter;
|
|
51
53
|
type: string;
|
|
52
54
|
name: string;
|
|
53
55
|
syntax: DBSyntaxEnum;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { DatabaseCapabilities, DatabaseEngine, DatabaseImportInput, DatabaseImportReceipt, DatabaseLocation, DatabaseObjectDetail, DatabaseObjectPage, DatabaseObjectRef, DatabaseQueryInput, DatabaseResult, DatabaseValue, DatabaseWorkbenchAdapter } from './workbench';
|
|
2
|
+
export interface WorkbenchTransport {
|
|
3
|
+
execute(sql: string, parameters: DatabaseValue[], options: {
|
|
4
|
+
timeoutMs: number;
|
|
5
|
+
maxRows: number;
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
}): Promise<DatabaseResult>;
|
|
8
|
+
close(): Promise<void>;
|
|
9
|
+
importRows?(input: DatabaseImportInput, signal?: AbortSignal): Promise<DatabaseImportReceipt>;
|
|
10
|
+
}
|
|
11
|
+
/** One adapter per physical connection. A host session must not share it across users. */
|
|
12
|
+
export declare class SqlDatabaseWorkbenchAdapter implements DatabaseWorkbenchAdapter {
|
|
13
|
+
readonly engine: DatabaseEngine;
|
|
14
|
+
private readonly transport;
|
|
15
|
+
private readonly initial;
|
|
16
|
+
private version?;
|
|
17
|
+
private transactionOpen;
|
|
18
|
+
private busy;
|
|
19
|
+
private closed;
|
|
20
|
+
constructor(engine: DatabaseEngine, transport: WorkbenchTransport, initial?: DatabaseLocation);
|
|
21
|
+
private quote;
|
|
22
|
+
private ref;
|
|
23
|
+
private assertLocation;
|
|
24
|
+
private raw;
|
|
25
|
+
capabilities(): Promise<DatabaseCapabilities>;
|
|
26
|
+
locations(): Promise<DatabaseLocation[]>;
|
|
27
|
+
objects(input: DatabaseLocation & {
|
|
28
|
+
search?: string;
|
|
29
|
+
page?: number;
|
|
30
|
+
pageSize?: number;
|
|
31
|
+
}): Promise<DatabaseObjectPage>;
|
|
32
|
+
describe(object: DatabaseObjectRef): Promise<DatabaseObjectDetail>;
|
|
33
|
+
query(input: DatabaseQueryInput, signal?: AbortSignal): Promise<DatabaseResult>;
|
|
34
|
+
explain(input: Omit<DatabaseQueryInput, 'mode'>, signal?: AbortSignal): Promise<DatabaseResult>;
|
|
35
|
+
transaction(action: 'begin' | 'commit' | 'rollback'): Promise<void>;
|
|
36
|
+
importRows(input: DatabaseImportInput, signal?: AbortSignal): Promise<DatabaseImportReceipt>;
|
|
37
|
+
cancel(): Promise<void>;
|
|
38
|
+
close(): Promise<void>;
|
|
39
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DatabaseValue } from './workbench';
|
|
2
|
+
/** Apply a page to a MySQL result without turning its (possibly duplicate) output names into table columns. */
|
|
3
|
+
export declare function paginateMysqlQuery(sql: string, parameters: DatabaseValue[], limit: number, offset: number): {
|
|
4
|
+
sql: string;
|
|
5
|
+
parameters: DatabaseValue[];
|
|
6
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface SqlToken {
|
|
2
|
+
text: string;
|
|
3
|
+
start: number;
|
|
4
|
+
end: number;
|
|
5
|
+
kind: 'word' | 'number' | 'symbol' | 'identifier' | 'literal';
|
|
6
|
+
}
|
|
7
|
+
/** Mask comments and quoted content without changing source offsets. Shared by guards and pagination. */
|
|
8
|
+
export declare function lexWorkbenchSql(source: string): {
|
|
9
|
+
masked: string;
|
|
10
|
+
tokens: SqlToken[];
|
|
11
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Invariants: comments/literals are lexed, never stripped with a keyword regex.
|
|
2
|
+
* This guard is defense in depth; the database principal remains an authority boundary.
|
|
3
|
+
* Unrecognized statements fail closed. Driver multi-statements stay disabled.
|
|
4
|
+
*/
|
|
5
|
+
export interface SqlStatement {
|
|
6
|
+
sql: string;
|
|
7
|
+
words: string[];
|
|
8
|
+
effect: 'read' | 'write' | 'unsupported';
|
|
9
|
+
}
|
|
10
|
+
export declare function splitWorkbenchSql(source: string): SqlStatement[];
|
|
11
|
+
export declare function requireReadStatement(sql: string): string;
|
|
12
|
+
export declare function quoteDatabaseIdentifier(name: string, engine: 'doris' | 'mysql' | 'postgres'): string;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/** Shared wire contract. Credentials and driver objects never cross this boundary. */
|
|
2
|
+
export type DatabaseEngine = 'doris' | 'mysql' | 'postgres';
|
|
3
|
+
export type DatabaseValue = string | number | boolean | null;
|
|
4
|
+
export type DatabaseObjectKind = 'table' | 'view';
|
|
5
|
+
export interface DatabaseLocation {
|
|
6
|
+
database?: string;
|
|
7
|
+
schema?: string;
|
|
8
|
+
/** Doris external catalog; legacy QueryOptions.catalog continues to mean database. */
|
|
9
|
+
engineCatalog?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface DatabaseObjectRef extends DatabaseLocation {
|
|
12
|
+
name: string;
|
|
13
|
+
kind: DatabaseObjectKind;
|
|
14
|
+
}
|
|
15
|
+
export interface DatabaseColumn {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
dataType: string;
|
|
19
|
+
nullable?: boolean;
|
|
20
|
+
ordinal?: number;
|
|
21
|
+
defaultValue?: string | null;
|
|
22
|
+
comment?: string;
|
|
23
|
+
sourceColumn?: string;
|
|
24
|
+
sourceTable?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface DatabaseKey {
|
|
27
|
+
name: string;
|
|
28
|
+
kind: 'primary' | 'unique' | 'index' | 'foreign';
|
|
29
|
+
columns: string[];
|
|
30
|
+
referencedTable?: DatabaseObjectRef;
|
|
31
|
+
referencedColumns?: string[];
|
|
32
|
+
}
|
|
33
|
+
export interface DatabaseObjectDetail {
|
|
34
|
+
object: DatabaseObjectRef;
|
|
35
|
+
columns: DatabaseColumn[];
|
|
36
|
+
keys: DatabaseKey[];
|
|
37
|
+
definition: string;
|
|
38
|
+
model?: 'unique' | 'duplicate' | 'aggregate';
|
|
39
|
+
editable: boolean;
|
|
40
|
+
diagnostics: string[];
|
|
41
|
+
}
|
|
42
|
+
export interface DatabaseCapabilities {
|
|
43
|
+
engine: DatabaseEngine;
|
|
44
|
+
version: string;
|
|
45
|
+
query: boolean;
|
|
46
|
+
explain: boolean;
|
|
47
|
+
transactions: boolean;
|
|
48
|
+
cancel: boolean;
|
|
49
|
+
import: boolean;
|
|
50
|
+
writes: boolean;
|
|
51
|
+
nativeReadOnly: boolean;
|
|
52
|
+
objectKinds: DatabaseObjectKind[];
|
|
53
|
+
diagnostics: string[];
|
|
54
|
+
}
|
|
55
|
+
export interface DatabaseResult {
|
|
56
|
+
columns: DatabaseColumn[];
|
|
57
|
+
rows: DatabaseValue[][];
|
|
58
|
+
affectedRows?: number;
|
|
59
|
+
durationMs: number;
|
|
60
|
+
hasMore: boolean;
|
|
61
|
+
truncated: boolean;
|
|
62
|
+
/** Driver-derived state, never inferred from HTTP success. */
|
|
63
|
+
outcome: 'succeeded' | 'pending' | 'unknown';
|
|
64
|
+
diagnostics: string[];
|
|
65
|
+
}
|
|
66
|
+
export interface DatabaseQueryInput extends DatabaseLocation {
|
|
67
|
+
sql: string;
|
|
68
|
+
parameters?: DatabaseValue[];
|
|
69
|
+
mode: 'read' | 'write';
|
|
70
|
+
limit?: number;
|
|
71
|
+
offset?: number;
|
|
72
|
+
timeoutMs?: number;
|
|
73
|
+
}
|
|
74
|
+
export interface DatabaseImportInput extends DatabaseLocation {
|
|
75
|
+
table: string;
|
|
76
|
+
columns: string[];
|
|
77
|
+
rows: DatabaseValue[][];
|
|
78
|
+
operationId: string;
|
|
79
|
+
}
|
|
80
|
+
export interface DatabaseImportReceipt {
|
|
81
|
+
outcome: 'succeeded' | 'pending' | 'unknown';
|
|
82
|
+
loadedRows?: number;
|
|
83
|
+
filteredRows?: number;
|
|
84
|
+
label: string;
|
|
85
|
+
diagnostics: string[];
|
|
86
|
+
}
|
|
87
|
+
export interface DatabaseObjectPage {
|
|
88
|
+
items: DatabaseObjectRef[];
|
|
89
|
+
page: number;
|
|
90
|
+
pageSize: number;
|
|
91
|
+
hasMore: boolean;
|
|
92
|
+
}
|
|
93
|
+
export interface DatabaseWorkbenchAdapter {
|
|
94
|
+
readonly engine: DatabaseEngine;
|
|
95
|
+
capabilities(): Promise<DatabaseCapabilities>;
|
|
96
|
+
locations(): Promise<DatabaseLocation[]>;
|
|
97
|
+
objects(input: DatabaseLocation & {
|
|
98
|
+
search?: string;
|
|
99
|
+
page?: number;
|
|
100
|
+
pageSize?: number;
|
|
101
|
+
}): Promise<DatabaseObjectPage>;
|
|
102
|
+
describe(object: DatabaseObjectRef): Promise<DatabaseObjectDetail>;
|
|
103
|
+
query(input: DatabaseQueryInput, signal?: AbortSignal): Promise<DatabaseResult>;
|
|
104
|
+
explain(input: Omit<DatabaseQueryInput, 'mode'>, signal?: AbortSignal): Promise<DatabaseResult>;
|
|
105
|
+
transaction(action: 'begin' | 'commit' | 'rollback'): Promise<void>;
|
|
106
|
+
cancel(): Promise<void>;
|
|
107
|
+
importRows(input: DatabaseImportInput, signal?: AbortSignal): Promise<DatabaseImportReceipt>;
|
|
108
|
+
close(): Promise<void>;
|
|
109
|
+
}
|
|
110
|
+
export interface DataSourceActor {
|
|
111
|
+
tenantId: string;
|
|
112
|
+
organizationId: string;
|
|
113
|
+
userId: string;
|
|
114
|
+
}
|
|
115
|
+
export interface DataSourceSummary {
|
|
116
|
+
id: string;
|
|
117
|
+
name: string;
|
|
118
|
+
engine: DatabaseEngine;
|
|
119
|
+
}
|
|
120
|
+
export interface DataSourceWorkbenchScope {
|
|
121
|
+
location?: DatabaseLocation;
|
|
122
|
+
actor: DataSourceActor;
|
|
123
|
+
dataSourceId: string;
|
|
124
|
+
}
|
|
125
|
+
export interface DataSourceRuntimeApi {
|
|
126
|
+
list(actor: DataSourceActor): Promise<DataSourceSummary[]>;
|
|
127
|
+
open(input: DataSourceWorkbenchScope): Promise<DatabaseWorkbenchAdapter>;
|
|
128
|
+
}
|
|
129
|
+
export declare const DataSourceRuntimeCapability: Readonly<{
|
|
130
|
+
id: "platform.datasource.workbench";
|
|
131
|
+
description: "Scoped database workbench access; credentials remain host-owned.";
|
|
132
|
+
__type: DataSourceRuntimeApi | undefined;
|
|
133
|
+
}>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const KEYWORD_ANALYZER_STRATEGY = "KEYWORD_ANALYZER_STRATEGY";
|
|
2
|
+
export declare const KeywordAnalyzerStrategy: (provider: string) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface IKeywordAnalyzerStrategy {
|
|
2
|
+
readonly meta: {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
languages: string[];
|
|
6
|
+
/** Change whenever index/query compatibility changes, including dictionary updates. */
|
|
7
|
+
revision: string;
|
|
8
|
+
};
|
|
9
|
+
/** Return ordered lexemes. The host encodes them as data, never as SQL or tsquery syntax. */
|
|
10
|
+
analyze(text: string, purpose: 'index' | 'query'): Promise<readonly string[]>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
2
|
+
import { BaseStrategyRegistry, StrategySource } from '../../strategy';
|
|
3
|
+
import { IKeywordAnalyzerStrategy } from './strategy.interface';
|
|
4
|
+
export declare class KeywordAnalyzerRegistry extends BaseStrategyRegistry<IKeywordAnalyzerStrategy> {
|
|
5
|
+
constructor(discoveryService: DiscoveryService, reflector: Reflector);
|
|
6
|
+
/** Resolve a pinned source without allowing a higher-priority scope to shadow it. */
|
|
7
|
+
getBySource(provider: string, source: StrategySource, organizationId?: string): IKeywordAnalyzerStrategy | undefined;
|
|
8
|
+
}
|
package/src/lib/rag/index.d.ts
CHANGED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { JSONValue } from '@xpert-ai/contracts';
|
|
2
|
+
export type KnowledgeGraphPublicationOwner = {
|
|
3
|
+
knowledgebaseId: string;
|
|
4
|
+
documentId: string;
|
|
5
|
+
xpertId: string;
|
|
6
|
+
agentKey: string;
|
|
7
|
+
};
|
|
8
|
+
export type KnowledgeGraphPublishedEntity = {
|
|
9
|
+
/** Local reference within this publication. */
|
|
10
|
+
id: string;
|
|
11
|
+
/** Stable, issuer-scoped business identity. Occurrences must include assembly/revision scope. */
|
|
12
|
+
namespace: string;
|
|
13
|
+
nodeKey: string;
|
|
14
|
+
type: string;
|
|
15
|
+
name: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
properties?: Record<string, JSONValue>;
|
|
18
|
+
chunkIds: string[];
|
|
19
|
+
};
|
|
20
|
+
export type KnowledgeGraphPublishedRelation = {
|
|
21
|
+
source: string;
|
|
22
|
+
target: string;
|
|
23
|
+
type: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
properties?: Record<string, JSONValue>;
|
|
26
|
+
chunkIds: string[];
|
|
27
|
+
};
|
|
28
|
+
export type KnowledgeGraphPublishInput = KnowledgeGraphPublicationOwner & {
|
|
29
|
+
publicationKey: string;
|
|
30
|
+
sourceVersion: string;
|
|
31
|
+
/** Complete source chunk manifest; publication rejects concurrent or incomplete writes. */
|
|
32
|
+
chunkIds: string[];
|
|
33
|
+
entities: KnowledgeGraphPublishedEntity[];
|
|
34
|
+
relations: KnowledgeGraphPublishedRelation[];
|
|
35
|
+
};
|
|
36
|
+
export type KnowledgeGraphPublicationResult = {
|
|
37
|
+
documentId: string;
|
|
38
|
+
publicationId: string;
|
|
39
|
+
publicationKey: string;
|
|
40
|
+
sourceVersion: string;
|
|
41
|
+
contentHash: string;
|
|
42
|
+
status: 'queued' | 'running' | 'success' | 'failed' | 'cancelled';
|
|
43
|
+
entityCount: number;
|
|
44
|
+
relationCount: number;
|
|
45
|
+
unchanged: boolean;
|
|
46
|
+
error?: string | null;
|
|
47
|
+
};
|
|
48
|
+
export interface KnowledgeGraphApi {
|
|
49
|
+
/** Atomically accepts a complete, validated snapshot. Indexing is durable and retryable. */
|
|
50
|
+
publish(input: KnowledgeGraphPublishInput): Promise<KnowledgeGraphPublicationResult>;
|
|
51
|
+
status(input: KnowledgeGraphPublicationOwner): Promise<KnowledgeGraphPublicationResult | null>;
|
|
52
|
+
/** Publishes an empty replacement; leaves source chunks and other publishers intact. */
|
|
53
|
+
retract(input: KnowledgeGraphPublicationOwner & {
|
|
54
|
+
publicationKey: string;
|
|
55
|
+
sourceVersion: string;
|
|
56
|
+
chunkIds: string[];
|
|
57
|
+
}): Promise<KnowledgeGraphPublicationResult>;
|
|
58
|
+
}
|
|
59
|
+
export declare const KnowledgeGraphRuntimeCapability: import("../../core/runtime-capability").RuntimeCapabilityKey<KnowledgeGraphApi>;
|
|
@@ -2,7 +2,7 @@ import type { XpertToolOptions, XpertToolProviderOptions } from './types';
|
|
|
2
2
|
export declare const XPERT_TOOL_PROVIDER = "XPERT_TOOL_PROVIDER";
|
|
3
3
|
export declare const XPERT_TOOL_PROVIDER_METADATA = "XPERT_TOOL_PROVIDER_METADATA";
|
|
4
4
|
export declare const XPERT_TOOL_METHOD_METADATA = "XPERT_TOOL_METHOD_METADATA";
|
|
5
|
-
/** Marks one injectable business service as a
|
|
5
|
+
/** Marks one injectable business service as a shared Tool, Resource and Prompt provider. */
|
|
6
6
|
export declare const XpertToolProvider: (options: XpertToolProviderOptions) => ClassDecorator;
|
|
7
7
|
/** Exposes one business method through an Agent Middleware, native MCP, or both. */
|
|
8
8
|
export declare const XpertTool: (options: XpertToolOptions) => MethodDecorator;
|
|
@@ -6,3 +6,6 @@ export * from './adapters';
|
|
|
6
6
|
export * from './coordinator';
|
|
7
7
|
export { XPERT_TOOL_RESULT_FORMAT_VERSION } from './tool-result';
|
|
8
8
|
export { prepareToolResult, type XpertPreparedToolResult, type XpertOutputDiagnostic } from './prepared-result';
|
|
9
|
+
export { runtimeToolProviderComponent } from './component';
|
|
10
|
+
export { XpertResource, XpertResourceTemplate, XpertPrompt, resolveXpertMcpExtensions } from './mcp-methods';
|
|
11
|
+
export type { XpertResourceOptions, XpertResourceTemplateOptions, XpertPromptOptions, XpertDecoratedMcpDescriptor } from './mcp-methods';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { McpResourceDefinition } from '../mcp/resource';
|
|
2
|
+
import type { McpResourceTemplateDefinition } from '../mcp/resource-template';
|
|
3
|
+
import type { McpPromptDefinition } from '../mcp/prompt';
|
|
4
|
+
import type { XpertToolProviderDescriptor } from './types';
|
|
5
|
+
export type XpertResourceOptions = Omit<McpResourceDefinition, 'read'>;
|
|
6
|
+
export type XpertResourceTemplateOptions = Omit<McpResourceTemplateDefinition, 'read' | 'complete'> & {
|
|
7
|
+
/** Optional instance method implementing McpCompletionHandler. */
|
|
8
|
+
completionMethod?: string;
|
|
9
|
+
};
|
|
10
|
+
export type XpertPromptOptions = Omit<McpPromptDefinition, 'get' | 'complete'> & {
|
|
11
|
+
completionMethod?: string;
|
|
12
|
+
};
|
|
13
|
+
type McpMethod = {
|
|
14
|
+
kind: 'resource';
|
|
15
|
+
options: Readonly<XpertResourceOptions>;
|
|
16
|
+
} | {
|
|
17
|
+
kind: 'resource-template';
|
|
18
|
+
options: Readonly<XpertResourceTemplateOptions>;
|
|
19
|
+
} | {
|
|
20
|
+
kind: 'prompt';
|
|
21
|
+
options: Readonly<XpertPromptOptions>;
|
|
22
|
+
};
|
|
23
|
+
export type XpertDecoratedMcpDescriptor = McpMethod & {
|
|
24
|
+
methodName: string;
|
|
25
|
+
};
|
|
26
|
+
/** The decorated method receives ResourceReadContext and returns McpResourceReadResult. */
|
|
27
|
+
export declare const XpertResource: (options: XpertResourceOptions) => MethodDecorator;
|
|
28
|
+
/** The decorated method receives URI arguments and ResourceReadContext. */
|
|
29
|
+
export declare const XpertResourceTemplate: (options: XpertResourceTemplateOptions) => MethodDecorator;
|
|
30
|
+
/** The decorated method receives prompt arguments and ToolExecutionContext. */
|
|
31
|
+
export declare const XpertPrompt: (options: XpertPromptOptions) => MethodDecorator;
|
|
32
|
+
export declare function describeXpertMcpMethods(instance: object): readonly XpertDecoratedMcpDescriptor[];
|
|
33
|
+
/** One catalog for runtime publication and fingerprinting; legacy declarations remain supported. */
|
|
34
|
+
export declare function resolveXpertMcpExtensions(instance: object, descriptor?: XpertToolProviderDescriptor): {
|
|
35
|
+
resources: McpResourceDefinition[];
|
|
36
|
+
resourceTemplates: McpResourceTemplateDefinition[];
|
|
37
|
+
prompts: McpPromptDefinition[];
|
|
38
|
+
};
|
|
39
|
+
export {};
|
|
@@ -2,7 +2,7 @@ import type { ZodTypeAny } from 'zod/v3';
|
|
|
2
2
|
import type { XpertToolContent, XpertToolResult } from '../toolset/tool-result';
|
|
3
3
|
export declare const XPERT_TOOL_RESULT_FORMAT_VERSION = 1;
|
|
4
4
|
/** Validate the envelope separately so binary content never enters the business DTO. */
|
|
5
|
-
export declare function parseDecoratedToolResult(value: unknown, outputSchema
|
|
5
|
+
export declare function parseDecoratedToolResult(value: unknown, outputSchema?: ZodTypeAny): Promise<XpertToolResult>;
|
|
6
6
|
export declare function agentContent(content: XpertToolContent[] | undefined): ({
|
|
7
7
|
type: string;
|
|
8
8
|
image_url: {
|