@axiom-lattice/protocols 2.1.48 → 2.1.50

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,131 @@
1
+ /**
2
+ * CollectionStoreProtocol
3
+ *
4
+ * Collection store protocol definitions for the Axiom Lattice framework.
5
+ * Provides standardized interfaces for collection management across all implementations.
6
+ */
7
+
8
+ /**
9
+ * Collection field type definition
10
+ */
11
+ export type CollectionFieldType = 'string' | 'number' | 'enum';
12
+
13
+ /**
14
+ * Collection field definition
15
+ */
16
+ export interface CollectionField {
17
+ /** Field key name, written to metadata[key] */
18
+ key: string;
19
+ /** Field data type */
20
+ type: CollectionFieldType;
21
+ /** Valid values for enum type */
22
+ enumValues?: string[];
23
+ /** Whether the field is required on entry creation */
24
+ required?: boolean;
25
+ }
26
+
27
+ /**
28
+ * Collection schema definition
29
+ */
30
+ export interface CollectionSchema {
31
+ /** Custom field definitions */
32
+ fields: CollectionField[];
33
+ }
34
+
35
+ /**
36
+ * Collection type definition
37
+ */
38
+ export interface Collection {
39
+ /** Collection unique identifier */
40
+ id: string;
41
+ /** Collection name (unique per tenant, corresponds to vector table name) */
42
+ name: string;
43
+ /** Tenant identifier */
44
+ tenantId: string;
45
+ /** Human-readable display name */
46
+ label: string;
47
+ /** Embedding model key (registered in EmbeddingsLatticeManager) */
48
+ embeddingKey: string;
49
+ /** Custom field schema */
50
+ schema: CollectionSchema;
51
+ /** Creation timestamp */
52
+ createdAt: Date;
53
+ /** Last update timestamp */
54
+ updatedAt: Date;
55
+ }
56
+
57
+ /**
58
+ * Create collection request type
59
+ */
60
+ export interface CreateCollectionRequest {
61
+ /** Collection name (required) */
62
+ name: string;
63
+ /** Human-readable display name (required) */
64
+ label: string;
65
+ /** Embedding model key (required) */
66
+ embeddingKey: string;
67
+ /** Custom field schema (optional) */
68
+ schema?: CollectionSchema;
69
+ }
70
+
71
+ /**
72
+ * Update collection request type
73
+ */
74
+ export interface UpdateCollectionRequest {
75
+ /** Human-readable display name */
76
+ label?: string;
77
+ /** Embedding model key */
78
+ embeddingKey?: string;
79
+ /** Custom field schema */
80
+ schema?: CollectionSchema;
81
+ }
82
+
83
+ /**
84
+ * CollectionStore interface
85
+ * Provides CRUD operations for collection metadata
86
+ */
87
+ export interface CollectionStore {
88
+ /**
89
+ * Get all collections for a tenant
90
+ * @param tenantId Tenant identifier
91
+ * @returns Array of all collections for the tenant
92
+ */
93
+ getAllCollections(tenantId: string): Promise<Collection[]>;
94
+
95
+ /**
96
+ * Get collection by name
97
+ * @param tenantId Tenant identifier
98
+ * @param name Collection name
99
+ * @returns Collection if found, null otherwise
100
+ */
101
+ getCollectionByName(tenantId: string, name: string): Promise<Collection | null>;
102
+
103
+ /**
104
+ * Create a new collection
105
+ * @param tenantId Tenant identifier
106
+ * @param data Collection creation data
107
+ * @returns Created collection
108
+ */
109
+ createCollection(tenantId: string, data: CreateCollectionRequest): Promise<Collection>;
110
+
111
+ /**
112
+ * Update an existing collection
113
+ * @param tenantId Tenant identifier
114
+ * @param name Collection name
115
+ * @param updates Partial updates
116
+ * @returns Updated collection if found, null otherwise
117
+ */
118
+ updateCollection(
119
+ tenantId: string,
120
+ name: string,
121
+ updates: UpdateCollectionRequest
122
+ ): Promise<Collection | null>;
123
+
124
+ /**
125
+ * Delete a collection by name
126
+ * @param tenantId Tenant identifier
127
+ * @param name Collection name
128
+ * @returns true if deleted, false otherwise
129
+ */
130
+ deleteCollection(tenantId: string, name: string): Promise<boolean>;
131
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * ConnectionStore Protocol
3
+ *
4
+ * Generic store for external service connections (databases, APIs, etc.).
5
+ * Provides tenant-scoped CRUD operations keyed by a unique business key.
6
+ * The key is scoped to (tenant_id, type) — same tenant, same plugin type
7
+ * can't use duplicate keys, but different types can share keys (ERP "prod" != CRM "prod").
8
+ */
9
+
10
+ export interface ConnectionEntry {
11
+ id: string;
12
+ tenantId: string;
13
+ type: string;
14
+ key: string;
15
+ name: string;
16
+ description?: string;
17
+ config: Record<string, unknown>;
18
+ createdAt: string;
19
+ updatedAt: string;
20
+ }
21
+
22
+ export interface ConnectionStore {
23
+ listByType(tenantId: string, type: string): Promise<ConnectionEntry[]>;
24
+ getByKey(tenantId: string, type: string, key: string): Promise<ConnectionEntry | null>;
25
+ create(entry: Omit<ConnectionEntry, "id" | "createdAt" | "updatedAt">): Promise<ConnectionEntry>;
26
+ update(tenantId: string, type: string, key: string, updates: Partial<ConnectionEntry>): Promise<ConnectionEntry | null>;
27
+ delete(tenantId: string, type: string, key: string): Promise<boolean>;
28
+ }
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Plugin Connection 字段 schema(驱动前端表单渲染)
3
+ */
4
+ export interface PluginConnectionFieldSchema {
5
+ /** 字段 key */
6
+ key: string;
7
+ /** 字段类型 */
8
+ type: "string" | "number" | "boolean" | "password";
9
+ /** UI 标签 */
10
+ title: string;
11
+ /** 前端 widget 类型 */
12
+ widget?: "input" | "password" | "select" | "numberInput";
13
+ /** 是否必填 */
14
+ required?: boolean;
15
+ /** 默认值 */
16
+ default?: unknown;
17
+ /** 如果是 select widget,可选值列表 */
18
+ enumValues?: string[];
19
+ /** 帮助文本 */
20
+ helpText?: string;
21
+ }
22
+
23
+ /**
24
+ * 连接测试结果
25
+ */
26
+ export interface PluginConnectionTestResult {
27
+ ok: boolean;
28
+ message: string;
29
+ /** 可选的附加诊断信息 */
30
+ details?: Record<string, unknown>;
31
+ }
32
+
33
+ /**
34
+ * 资源发现条目
35
+ */
36
+ export interface PluginDiscoveredResource {
37
+ id: string;
38
+ name: string;
39
+ /** 可选的归组 */
40
+ group?: string;
41
+ /** 可选描述 */
42
+ description?: string;
43
+ }
44
+
45
+ /**
46
+ * 插件连接定义(全部可选,存在即生效)
47
+ *
48
+ * - fields: 前端渲染表单字段
49
+ * - test: 连通测试 → API 推导 hasTest
50
+ * - discover: 资源发现 → API 推导 hasDiscover
51
+ * - resourceLabel: 资源面板标题
52
+ */
53
+ export interface PluginConnection {
54
+ /** 连接表单字段 */
55
+ fields: PluginConnectionFieldSchema[];
56
+ /** 连通测试回调(存在即声明 hasTest: true) */
57
+ test?: (config: Record<string, unknown>) => Promise<PluginConnectionTestResult>;
58
+ /** 资源发现回调(存在即声明 hasDiscover: true) */
59
+ discover?: (config: Record<string, unknown>) => Promise<PluginDiscoveredResource[]>;
60
+ /** 资源发现面板标题 */
61
+ resourceLabel?: string;
62
+ }
63
+
64
+ /**
65
+ * 工具元信息(用于前端 allowedTools 筛选)
66
+ */
67
+ export interface PluginToolMeta {
68
+ name: string;
69
+ description: string;
70
+ }
71
+
72
+ /**
73
+ * 插件元数据(开发者声明)
74
+ *
75
+ * connectionSchema 不在此类型中——由 serializePluginMeta 自动推导后注入 PluginMetaOutput。
76
+ */
77
+ export interface PluginMeta {
78
+ /** 插件唯一标识,如 "erp" */
79
+ type: string;
80
+ /** 显示名称 */
81
+ name: string;
82
+ /** 描述 */
83
+ description: string;
84
+ /** 版本号,为包管理预留 */
85
+ version?: string;
86
+ /** 安装来源,如 "npm:my-plugin@1.2.0" */
87
+ source?: string;
88
+ /** 图标名称(可选,前端渲染用) */
89
+ icon?: string;
90
+ /** 工具清单(可选,middleware 能自动提取时不需要写) */
91
+ tools?: PluginToolMeta[];
92
+ /** 中间件配置 schema(用于 agent 配置面板) */
93
+ configSchema?: Record<string, unknown>;
94
+ /** 默认配置 */
95
+ defaultConfig?: Record<string, unknown>;
96
+ }
97
+
98
+ /**
99
+ * 插件元数据输出(API 返回格式)
100
+ *
101
+ * 在 PluginMeta 基础上增加了由 serializePluginMeta 自动推导的 connectionSchema。
102
+ */
103
+ export interface PluginMetaOutput extends PluginMeta {
104
+ /** 连接 schema(由 API 端点从 connection 方法存在性自动注入) */
105
+ connectionSchema?: {
106
+ fields: PluginConnectionFieldSchema[];
107
+ hasTest: boolean;
108
+ hasDiscover: boolean;
109
+ resourceLabel?: string;
110
+ };
111
+ }
112
+
113
+ /**
114
+ * 中间件工厂(泛型,不依赖 langchain)
115
+ */
116
+ export type PluginMiddlewareFactory<T = unknown> = (
117
+ config: Record<string, unknown>,
118
+ ) => T | Promise<T>;
119
+
120
+ /**
121
+ * Plugin 基类接口
122
+ *
123
+ * 一个对象 = 一个完整的插件定义。
124
+ * meta + connection + middleware 全在一个类里内聚。
125
+ *
126
+ * @example
127
+ * ```ts
128
+ * const erpPlugin: Plugin = {
129
+ * meta: { type: "erp", name: "ERP", description: "SAP B1" },
130
+ * connection: {
131
+ * fields: [{ key: "baseUrl", type: "string", title: "SAP URL" }],
132
+ * test: async (config) => ({ ok: true, message: "ok" }),
133
+ * },
134
+ * middleware: (config) => createMiddleware({ ... }),
135
+ * };
136
+ * ```
137
+ */
138
+ export interface Plugin {
139
+ /** 插件元数据 */
140
+ meta: PluginMeta;
141
+ /** 连接能力(可选,没有则不暴露连接管理) */
142
+ connection?: PluginConnection;
143
+ /** 中间件工厂(可选,没有则不注册任何工具) */
144
+ middleware?: PluginMiddlewareFactory;
145
+ }
@@ -18,7 +18,7 @@ export interface ResourceResolver {
18
18
  }
19
19
 
20
20
  /** Visibility level for resource shares. */
21
- export type ShareVisibility = "public" | "password";
21
+ export type ShareVisibility = "public" | "password" | "internal";
22
22
 
23
23
  /** Persisted record of a resource share within a project. */
24
24
  export interface ShareRecord {
@@ -0,0 +1,59 @@
1
+ /**
2
+ * VectorStoreProviderProtocol
3
+ *
4
+ * Provides a pluggable factory for creating VectorStore instances.
5
+ * Each provider key maps to a backend (memory, pgvector, chroma, etc.).
6
+ * Follows the same singleton registry pattern as EmbeddingsLatticeManager.
7
+ */
8
+
9
+ import { VectorStore } from "@langchain/core/vectorstores";
10
+ import type { DocumentInterface } from "@langchain/core/documents";
11
+
12
+ /**
13
+ * Parameters for creating a VectorStore instance.
14
+ */
15
+ export interface VectorStoreCreateParams {
16
+ /** Table/collection name for the vector store */
17
+ tableName: string;
18
+ /** Embedding model key to use for embedding operations */
19
+ embeddingKey: string;
20
+ /** Provider-specific configuration */
21
+ config?: Record<string, unknown>;
22
+ }
23
+
24
+ /**
25
+ * VectorStoreProvider interface.
26
+ * Implementations create VectorStore instances for a specific backend.
27
+ */
28
+ export interface VectorStoreProvider {
29
+ /**
30
+ * Create a new VectorStore instance.
31
+ * @param params Creation parameters including table name and embedding key
32
+ * @returns A LangChain VectorStore instance
33
+ */
34
+ create(params: VectorStoreCreateParams): Promise<VectorStore>;
35
+
36
+ /**
37
+ * Dispose a VectorStore instance (optional cleanup).
38
+ * @param name The table/collection name
39
+ */
40
+ dispose?(name: string): Promise<void>;
41
+
42
+ /**
43
+ * Get the number of entries in a vector store (optional).
44
+ * @param tableName The table/collection name
45
+ */
46
+ getEntryCount?(tableName: string): Promise<number>;
47
+
48
+ /**
49
+ * List all entries in a vector store (optional).
50
+ * @param tableName The table/collection name
51
+ */
52
+ listEntries?(tableName: string): Promise<DocumentInterface[]>;
53
+
54
+ /**
55
+ * Drop/delete the underlying storage for a vector store (optional).
56
+ * @param tableName The table/collection name
57
+ */
58
+ dropTable?(tableName: string): Promise<void>;
59
+ }
package/src/index.ts CHANGED
@@ -24,6 +24,7 @@ export * from "./McpLatticeProtocol";
24
24
  export * from "./WorkspaceStoreProtocol";
25
25
  export * from "./TenantStoreProtocol";
26
26
  export * from "./DatabaseConfigStoreProtocol";
27
+ export * from "./ConnectionStoreProtocol";
27
28
  export * from "./ChannelInstallationStoreProtocol";
28
29
  export * from "./MetricsServerConfigStoreProtocol";
29
30
  export * from "./McpServerConfigStoreProtocol";
@@ -31,6 +32,8 @@ export * from "./UserStoreProtocol";
31
32
  export * from "./UserTenantLinkProtocol";
32
33
  export * from "./WorkflowTrackingStoreProtocol";
33
34
  export * from "./BindingProtocol";
35
+ export * from "./CollectionStoreProtocol";
36
+ export * from "./VectorStoreProviderProtocol";
34
37
  export * from "./MenuProtocol";
35
38
  export * from "./EvalStoreProtocol";
36
39
  export * from "./TaskStoreProtocol";
@@ -47,5 +50,18 @@ export * from "./InternalDSL";
47
50
 
48
51
  export * from "./SandboxResourceProtocol";
49
52
 
53
+ // Plugin system
54
+ export type {
55
+ Plugin,
56
+ PluginMeta,
57
+ PluginMetaOutput,
58
+ PluginConnection,
59
+ PluginConnectionFieldSchema,
60
+ PluginConnectionTestResult,
61
+ PluginDiscoveredResource,
62
+ PluginToolMeta,
63
+ PluginMiddlewareFactory,
64
+ } from "./PluginProtocol";
65
+
50
66
  // 导出通用类型
51
67
  export * from "./types";