@byted-las/contextlake-openclaw 1.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.
Files changed (82) hide show
  1. package/README.md +64 -0
  2. package/bin/contextlake-openclaw.js +5 -0
  3. package/dist/index.d.ts +113 -0
  4. package/dist/index.js +73 -0
  5. package/dist/src/client/lancedb.d.ts +30 -0
  6. package/dist/src/client/lancedb.js +113 -0
  7. package/dist/src/client/tos.d.ts +19 -0
  8. package/dist/src/client/tos.js +81 -0
  9. package/dist/src/commands/cli.d.ts +6 -0
  10. package/dist/src/commands/cli.js +78 -0
  11. package/dist/src/commands/index.d.ts +1 -0
  12. package/dist/src/commands/index.js +139 -0
  13. package/dist/src/commands/slashcmd.d.ts +14 -0
  14. package/dist/src/commands/slashcmd.js +91 -0
  15. package/dist/src/commands/tools.d.ts +219 -0
  16. package/dist/src/commands/tools.js +286 -0
  17. package/dist/src/lib/actions/ingest.d.ts +8 -0
  18. package/dist/src/lib/actions/ingest.js +123 -0
  19. package/dist/src/lib/actions/manage.d.ts +15 -0
  20. package/dist/src/lib/actions/manage.js +91 -0
  21. package/dist/src/lib/actions/retrieve.d.ts +8 -0
  22. package/dist/src/lib/actions/retrieve.js +73 -0
  23. package/dist/src/processor/loader.d.ts +7 -0
  24. package/dist/src/processor/loader.js +83 -0
  25. package/dist/src/service/embedding/factory.d.ts +2 -0
  26. package/dist/src/service/embedding/factory.js +16 -0
  27. package/dist/src/service/embedding/interface.d.ts +18 -0
  28. package/dist/src/service/embedding/interface.js +2 -0
  29. package/dist/src/service/embedding/local.d.ts +14 -0
  30. package/dist/src/service/embedding/local.js +104 -0
  31. package/dist/src/service/embedding/remote.d.ts +9 -0
  32. package/dist/src/service/embedding/remote.js +42 -0
  33. package/dist/src/service/metadata/factory.d.ts +13 -0
  34. package/dist/src/service/metadata/factory.js +48 -0
  35. package/dist/src/service/metadata/interface.d.ts +17 -0
  36. package/dist/src/service/metadata/interface.js +2 -0
  37. package/dist/src/service/metadata/local.d.ts +13 -0
  38. package/dist/src/service/metadata/local.js +49 -0
  39. package/dist/src/service/storage/factory.d.ts +2 -0
  40. package/dist/src/service/storage/factory.js +19 -0
  41. package/dist/src/service/storage/interface.d.ts +32 -0
  42. package/dist/src/service/storage/interface.js +2 -0
  43. package/dist/src/service/storage/local.d.ts +9 -0
  44. package/dist/src/service/storage/local.js +72 -0
  45. package/dist/src/skills/las-data-profiler/index.d.ts +26 -0
  46. package/dist/src/skills/las-data-profiler/index.js +231 -0
  47. package/dist/src/skills/las-data-profiler/register.d.ts +1 -0
  48. package/dist/src/skills/las-data-profiler/register.js +19 -0
  49. package/dist/src/utils/config.d.ts +1 -0
  50. package/dist/src/utils/config.js +16 -0
  51. package/index.ts +78 -0
  52. package/openclaw.plugin.json +57 -0
  53. package/package.json +52 -0
  54. package/src/client/lancedb.ts +102 -0
  55. package/src/client/tos.ts +100 -0
  56. package/src/commands/cli.ts +77 -0
  57. package/src/commands/index.ts +156 -0
  58. package/src/commands/slashcmd.ts +95 -0
  59. package/src/commands/tools.ts +286 -0
  60. package/src/lib/actions/ingest.ts +103 -0
  61. package/src/lib/actions/manage.ts +107 -0
  62. package/src/lib/actions/retrieve.ts +90 -0
  63. package/src/processor/loader.ts +58 -0
  64. package/src/service/embedding/factory.ts +13 -0
  65. package/src/service/embedding/interface.ts +21 -0
  66. package/src/service/embedding/local.ts +118 -0
  67. package/src/service/embedding/remote.ts +45 -0
  68. package/src/service/metadata/factory.ts +52 -0
  69. package/src/service/metadata/interface.ts +19 -0
  70. package/src/service/metadata/local.ts +60 -0
  71. package/src/service/storage/factory.ts +16 -0
  72. package/src/service/storage/interface.ts +36 -0
  73. package/src/service/storage/local.ts +42 -0
  74. package/src/skills/contextlake-delete/SKILL.md +36 -0
  75. package/src/skills/contextlake-ingest/SKILL.md +40 -0
  76. package/src/skills/contextlake-list/SKILL.md +22 -0
  77. package/src/skills/contextlake-retrieve/SKILL.md +37 -0
  78. package/src/skills/las-data-profiler/SKILL.md +174 -0
  79. package/src/skills/las-data-profiler/index.ts +254 -0
  80. package/src/skills/las-data-profiler/register.ts +19 -0
  81. package/src/skills/las-data-profiler/s3_catalog.py +608 -0
  82. package/src/utils/config.ts +13 -0
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # ContextLake OpenClaw Plugin
2
+
3
+ A powerful, serverless-first Knowledge Base / Knowledge Lake (知识库/知识湖) plugin for the OpenClaw Agent framework.
4
+
5
+ This plugin allows OpenClaw agents to natively understand, index, and retrieve local and remote documents (PDF, Word, Markdown, Text) using vector similarity search. It features a pluggable architecture supporting both completely offline operations (via LanceDB and local GGUF models) and cloud-based operations.
6
+
7
+ ## Features
8
+
9
+ - **Multi-modal Document Ingestion**: Automatically extracts text from PDF, DOCX, TXT, and MD files.
10
+ - **Agentic Tools**: Exposes `contextlake-ingest`, `contextlake-retrieve`, `contextlake-list`, and `contextlake-delete` skills directly to the LLM.
11
+ - **Slash Commands**: Quick chat actions (`/contextlake-search`, `/contextlake-ingest`) for fast human-in-the-loop operations.
12
+ - **CLI Management**: Full command-line interface for bulk operations and CI/CD integration.
13
+ - **Local-First & Pluggable**:
14
+ - Uses `LanceDB` for local embedded vector storage.
15
+ - Uses `node-llama-cpp` for offline, private embedding generation (`bge-small-zh` by default).
16
+ - Can be easily configured to use remote embedding APIs (like OpenAI or Doubao ARK) or remote storage (TOS).
17
+
18
+ ## Installation
19
+
20
+ Assuming you are in an OpenClaw environment:
21
+
22
+ ```bash
23
+ npm install
24
+ npm run build
25
+ ```
26
+
27
+ Then register the plugin in your OpenClaw configuration:
28
+
29
+ ```json
30
+ {
31
+ "plugins": [
32
+ {
33
+ "package": "contextlake-openclaw",
34
+ "config": {
35
+ "metadata_storage": {
36
+ "type": "local",
37
+ "lancedb_uri": "./data/contextlake"
38
+ },
39
+ "file_storage": {
40
+ "type": "local",
41
+ "local_base_dir": "./data/files"
42
+ }
43
+ }
44
+ }
45
+ ]
46
+ }
47
+ ```
48
+
49
+ ## Agent Tools (Skills)
50
+
51
+ The LLM agent automatically has access to the following tools:
52
+
53
+ 1. **`contextlake-ingest`**: Uploads and indexes files.
54
+ 2. **`contextlake-retrieve`**: Performs vector search on the indexed documents based on a query.
55
+ 3. **`contextlake-list`**: Lists all currently indexed documents.
56
+ 4. **`contextlake-delete`**: Removes documents by ID or filter.
57
+
58
+ You can simply talk to the agent:
59
+ > "帮我把这个 `manual.pdf` 注入到知识库中。"
60
+ > "在知识湖中检索关于架构设计的文档。"
61
+
62
+ ## Development
63
+
64
+ For detailed architecture and internal workflows, please refer to [AGENTS.md](./AGENTS.md).
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ // 临时执行脚本,如果是生产环境可能需要直接执行 dist 下的 js 文件
4
+ require('ts-node').register();
5
+ require('../scripts/cli.ts');
@@ -0,0 +1,113 @@
1
+ declare const plugin: {
2
+ id: string;
3
+ name: string;
4
+ version: string;
5
+ description: string;
6
+ configSchema: {
7
+ type: string;
8
+ properties: {
9
+ metadata_storage: {
10
+ type: string;
11
+ properties: {
12
+ type: {
13
+ type: string;
14
+ enum: string[];
15
+ default: string;
16
+ };
17
+ lancedb_uri: {
18
+ type: string;
19
+ default: string;
20
+ };
21
+ remote_api_endpoint: {
22
+ type: string;
23
+ };
24
+ remote_api_key: {
25
+ type: string;
26
+ };
27
+ embedding: {
28
+ type: string;
29
+ properties: {
30
+ provider: {
31
+ type: string;
32
+ enum: string[];
33
+ default: string;
34
+ };
35
+ model_name: {
36
+ type: string;
37
+ default: string;
38
+ };
39
+ api_key: {
40
+ type: string;
41
+ };
42
+ api_base: {
43
+ type: string;
44
+ };
45
+ };
46
+ default: {
47
+ provider: string;
48
+ model_name: string;
49
+ };
50
+ };
51
+ };
52
+ default: {
53
+ type: string;
54
+ lancedb_uri: string;
55
+ };
56
+ };
57
+ file_storage: {
58
+ type: string;
59
+ properties: {
60
+ type: {
61
+ type: string;
62
+ enum: string[];
63
+ default: string;
64
+ };
65
+ local_base_dir: {
66
+ type: string;
67
+ default: string;
68
+ };
69
+ tos: {
70
+ type: string;
71
+ properties: {
72
+ access_key: {
73
+ type: string;
74
+ };
75
+ secret_key: {
76
+ type: string;
77
+ };
78
+ region: {
79
+ type: string;
80
+ };
81
+ path: {
82
+ type: string;
83
+ description: string;
84
+ };
85
+ endpoint: {
86
+ type: string;
87
+ };
88
+ sts_token: {
89
+ type: string;
90
+ };
91
+ };
92
+ };
93
+ };
94
+ default: {
95
+ type: string;
96
+ local_base_dir: string;
97
+ };
98
+ };
99
+ storage_policy: {
100
+ type: string;
101
+ properties: {
102
+ max_inline_size_kb: {
103
+ type: string;
104
+ default: number;
105
+ description: string;
106
+ };
107
+ };
108
+ };
109
+ };
110
+ };
111
+ register(ctx: any): void;
112
+ };
113
+ export default plugin;
package/dist/index.js ADDED
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const commands_1 = require("./src/commands");
4
+ const plugin = {
5
+ id: 'contextlake-openclaw',
6
+ name: 'ContextLake',
7
+ version: '1.1.0',
8
+ description: 'A lightweight knowledge base plugin for OpenClaw using LanceDB and TOS, with data profiling support',
9
+ configSchema: {
10
+ type: 'object',
11
+ properties: {
12
+ metadata_storage: {
13
+ type: 'object',
14
+ properties: {
15
+ type: { type: 'string', enum: ['local', 'remote'], default: 'local' },
16
+ lancedb_uri: { type: 'string', default: './data/contextlake' },
17
+ remote_api_endpoint: { type: 'string' },
18
+ remote_api_key: { type: 'string' },
19
+ embedding: {
20
+ type: 'object',
21
+ properties: {
22
+ provider: { type: 'string', enum: ['local', 'remote', 'openai'], default: 'local' },
23
+ model_name: { type: 'string', default: 'hf:CompendiumLabs/bge-small-zh-v1.5-gguf/bge-small-zh-v1.5-f16.gguf' },
24
+ api_key: { type: 'string' },
25
+ api_base: { type: 'string' }
26
+ },
27
+ default: { provider: 'local', model_name: 'hf:CompendiumLabs/bge-small-zh-v1.5-gguf/bge-small-zh-v1.5-f16.gguf' }
28
+ }
29
+ },
30
+ default: { type: 'local', lancedb_uri: './data/contextlake' }
31
+ },
32
+ file_storage: {
33
+ type: 'object',
34
+ properties: {
35
+ type: { type: 'string', enum: ['local', 'tos'], default: 'local' },
36
+ local_base_dir: { type: 'string', default: './data/files' },
37
+ tos: {
38
+ type: 'object',
39
+ properties: {
40
+ access_key: { type: 'string' },
41
+ secret_key: { type: 'string' },
42
+ region: { type: 'string' },
43
+ path: { type: 'string', description: 'TOS path in format tos://bucket/base_path/' },
44
+ endpoint: { type: 'string' },
45
+ sts_token: { type: 'string' }
46
+ }
47
+ }
48
+ },
49
+ default: { type: 'local', local_base_dir: './data/files' }
50
+ },
51
+ storage_policy: {
52
+ type: 'object',
53
+ properties: {
54
+ max_inline_size_kb: { type: 'number', default: 1024, description: 'Files smaller than this size (in KB) will be stored directly in LanceDB' }
55
+ }
56
+ }
57
+ }
58
+ },
59
+ register(ctx) {
60
+ const logger = ctx.logger || {
61
+ info: (msg, ...args) => console.log(msg, ...args),
62
+ warn: (msg, ...args) => console.warn(msg, ...args),
63
+ error: (msg, ...args) => console.error(msg, ...args),
64
+ debug: (msg, ...args) => console.debug(msg, ...args),
65
+ };
66
+ // Add logging
67
+ logger.info(`[${new Date().toISOString()}] [ContextLake] Plugin register started`);
68
+ // Delegate all registrations to commands/index.ts
69
+ (0, commands_1.registerAll)(ctx, logger);
70
+ logger.info(`[${new Date().toISOString()}] [ContextLake] Plugin register completed`);
71
+ }
72
+ };
73
+ exports.default = plugin;
@@ -0,0 +1,30 @@
1
+ import * as lancedb from '@lancedb/lancedb';
2
+ import { EmbeddingProvider } from '../service/embedding/interface';
3
+ export interface LanceDBConfig {
4
+ uri: string;
5
+ }
6
+ export interface DocumentSchema {
7
+ id: string;
8
+ vector: number[];
9
+ text: string;
10
+ source: string;
11
+ file_type: string;
12
+ storage_type: string;
13
+ url: string;
14
+ metadata: string;
15
+ created_at: number;
16
+ binary_data?: Buffer;
17
+ }
18
+ export declare class ContextLakeLanceDBClient {
19
+ private db;
20
+ private table;
21
+ private config;
22
+ private embeddingProvider;
23
+ constructor(config: LanceDBConfig, embeddingProvider: EmbeddingProvider);
24
+ connect(): Promise<void>;
25
+ getTable(tableName?: string, dim?: number): Promise<lancedb.Table>;
26
+ addAssets(docs: DocumentSchema[]): Promise<void>;
27
+ search(query: string, limit?: number, filter?: string): Promise<any[]>;
28
+ delete(filter: string): Promise<void>;
29
+ list(limit?: number, filter?: string): Promise<any[]>;
30
+ }
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.ContextLakeLanceDBClient = void 0;
37
+ const lancedb = __importStar(require("@lancedb/lancedb"));
38
+ class ContextLakeLanceDBClient {
39
+ db = null;
40
+ table = null;
41
+ config;
42
+ embeddingProvider;
43
+ constructor(config, embeddingProvider) {
44
+ this.config = config;
45
+ this.embeddingProvider = embeddingProvider;
46
+ }
47
+ async connect() {
48
+ if (!this.db) {
49
+ this.db = await lancedb.connect(this.config.uri);
50
+ }
51
+ }
52
+ async getTable(tableName = 'documents', dim = 0) {
53
+ if (this.table)
54
+ return this.table;
55
+ await this.connect();
56
+ const tableNames = await this.db.tableNames();
57
+ if (tableNames.includes(tableName)) {
58
+ this.table = await this.db.openTable(tableName);
59
+ }
60
+ else {
61
+ if (dim <= 0) {
62
+ // Fallback: use embedding provider to infer dimension only if needed
63
+ const dummyVec = await this.embeddingProvider.generateEmbedding("init");
64
+ dim = dummyVec.length;
65
+ }
66
+ // @ts-ignore
67
+ this.table = await this.db.createTable(tableName, [
68
+ {
69
+ id: 'schema_init',
70
+ vector: Array(dim).fill(0),
71
+ text: '',
72
+ source: '',
73
+ file_type: '',
74
+ storage_type: '',
75
+ url: '',
76
+ metadata: '{}',
77
+ created_at: 0,
78
+ binary_data: Buffer.from('')
79
+ }
80
+ ]);
81
+ await this.table.delete('id = "schema_init"');
82
+ }
83
+ return this.table;
84
+ }
85
+ async addAssets(docs) {
86
+ const table = await this.getTable();
87
+ // @ts-ignore
88
+ await table.add(docs);
89
+ }
90
+ async search(query, limit = 5, filter) {
91
+ const vector = await this.embeddingProvider.generateEmbedding(query);
92
+ const table = await this.getTable();
93
+ // @ts-ignore
94
+ let search = table.vectorSearch(vector).limit(limit);
95
+ if (filter) {
96
+ search = search.where(filter);
97
+ }
98
+ return await search.toArray();
99
+ }
100
+ async delete(filter) {
101
+ const table = await this.getTable();
102
+ await table.delete(filter);
103
+ }
104
+ async list(limit = 100, filter) {
105
+ const table = await this.getTable();
106
+ let query = table.query().limit(limit);
107
+ if (filter) {
108
+ query = query.where(filter);
109
+ }
110
+ return await query.toArray();
111
+ }
112
+ }
113
+ exports.ContextLakeLanceDBClient = ContextLakeLanceDBClient;
@@ -0,0 +1,19 @@
1
+ import { StorageProvider } from '../service/storage/interface';
2
+ export interface TosConfig {
3
+ access_key?: string;
4
+ secret_key?: string;
5
+ region: string;
6
+ endpoint?: string;
7
+ path: string;
8
+ sts_token?: string;
9
+ }
10
+ export declare class ContextLakeTosClient implements StorageProvider {
11
+ private client;
12
+ private bucket;
13
+ private basePath;
14
+ constructor(config: TosConfig);
15
+ private parseTosUrl;
16
+ uploadFile(fileName: string, buffer: Buffer): Promise<string>;
17
+ downloadFile(key: string): Promise<Buffer>;
18
+ deleteFile(key: string): Promise<void>;
19
+ }
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContextLakeTosClient = void 0;
4
+ const tos_sdk_1 = require("@volcengine/tos-sdk");
5
+ class ContextLakeTosClient {
6
+ client;
7
+ bucket;
8
+ basePath;
9
+ constructor(config) {
10
+ const tosConfig = {
11
+ accessKeyId: config.access_key,
12
+ accessKeySecret: config.secret_key,
13
+ region: config.region,
14
+ endpoint: config.endpoint,
15
+ securityToken: config.sts_token,
16
+ };
17
+ this.client = new tos_sdk_1.TosClient(tosConfig);
18
+ if (!config.path) {
19
+ throw new Error('TOS configuration requires "path" (e.g. tos://bucket/path/)');
20
+ }
21
+ if (!config.path.startsWith('tos://')) {
22
+ throw new Error('TOS path must start with tos://');
23
+ }
24
+ const parts = config.path.substring(6).split('/');
25
+ this.bucket = parts[0];
26
+ this.basePath = parts.slice(1).join('/');
27
+ if (this.basePath && !this.basePath.endsWith('/')) {
28
+ this.basePath += '/';
29
+ }
30
+ }
31
+ parseTosUrl(key) {
32
+ if (key.startsWith('tos://')) {
33
+ const pathParts = key.split('/').slice(3);
34
+ return pathParts.join('/');
35
+ }
36
+ return key;
37
+ }
38
+ async uploadFile(fileName, buffer) {
39
+ const key = `${this.basePath}${fileName}`;
40
+ await this.client.putObject({
41
+ bucket: this.bucket,
42
+ key,
43
+ body: buffer,
44
+ });
45
+ return `tos://${this.bucket}/${key}`;
46
+ }
47
+ async downloadFile(key) {
48
+ const actualKey = this.parseTosUrl(key);
49
+ const result = await this.client.getObject({
50
+ bucket: this.bucket,
51
+ key: actualKey,
52
+ });
53
+ // Check if result.data is a stream or buffer
54
+ if (Buffer.isBuffer(result.data)) {
55
+ return result.data;
56
+ }
57
+ // Read stream to buffer
58
+ // @ts-ignore
59
+ const stream = result.data.content || result.data;
60
+ if (stream && stream.toArray) {
61
+ // Optimized path for some stream implementations (like node-fetch/minipass)
62
+ return Buffer.concat(await stream.toArray());
63
+ }
64
+ if (stream && stream[Symbol.asyncIterator]) {
65
+ const chunks = [];
66
+ for await (const chunk of stream) {
67
+ chunks.push(Buffer.from(chunk));
68
+ }
69
+ return Buffer.concat(chunks);
70
+ }
71
+ return Buffer.from(result.data);
72
+ }
73
+ async deleteFile(key) {
74
+ const actualKey = this.parseTosUrl(key);
75
+ await this.client.deleteObject({
76
+ bucket: this.bucket,
77
+ key: actualKey,
78
+ });
79
+ }
80
+ }
81
+ exports.ContextLakeTosClient = ContextLakeTosClient;
@@ -0,0 +1,6 @@
1
+ export declare function getCliCommands(pluginConfig: any, logger: any): {
2
+ ingestAction: (files: any, options: any) => Promise<void>;
3
+ searchAction: (query: any, options: any) => Promise<void>;
4
+ listAction: (options: any) => Promise<void>;
5
+ deleteAction: (options: any) => Promise<void>;
6
+ };
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCliCommands = getCliCommands;
4
+ const ingest_1 = require("../lib/actions/ingest");
5
+ const retrieve_1 = require("../lib/actions/retrieve");
6
+ const manage_1 = require("../lib/actions/manage");
7
+ function getCliCommands(pluginConfig, logger) {
8
+ return {
9
+ ingestAction: async (files, options) => {
10
+ logger.info(`[${new Date().toISOString()}] [ContextLake] CLI ingest started`, { files, options });
11
+ try {
12
+ const metadata = options.metadata ? JSON.parse(options.metadata) : {};
13
+ const result = await (0, ingest_1.ingestAssets)({
14
+ files,
15
+ metadata,
16
+ chunkSize: parseInt(options.chunkSize),
17
+ overlap: parseInt(options.overlap)
18
+ }, pluginConfig, logger);
19
+ // eslint-disable-next-line no-console
20
+ console.log(JSON.stringify(result, null, 2));
21
+ logger.info(`[${new Date().toISOString()}] [ContextLake] CLI ingest success`);
22
+ }
23
+ catch (e) {
24
+ console.error('Error:', e.message);
25
+ logger.error(`[${new Date().toISOString()}] [ContextLake] CLI ingest failed`, { error: e.message, stack: e.stack });
26
+ }
27
+ },
28
+ searchAction: async (query, options) => {
29
+ logger.info(`[${new Date().toISOString()}] [ContextLake] CLI search started`, { query, options });
30
+ try {
31
+ const result = await (0, retrieve_1.retrieveAssets)({
32
+ query,
33
+ top_k: parseInt(options.topK),
34
+ filter: options.filter,
35
+ include_binary: options.binary
36
+ }, pluginConfig, logger);
37
+ // eslint-disable-next-line no-console
38
+ console.log(JSON.stringify(result, null, 2));
39
+ logger.info(`[${new Date().toISOString()}] [ContextLake] CLI search success`);
40
+ }
41
+ catch (e) {
42
+ console.error('Error:', e.message);
43
+ logger.error(`[${new Date().toISOString()}] [ContextLake] CLI search failed`, { error: e.message, stack: e.stack });
44
+ }
45
+ },
46
+ listAction: async (options) => {
47
+ logger.info(`[${new Date().toISOString()}] [ContextLake] CLI list started`, { options });
48
+ try {
49
+ const result = await (0, manage_1.listAssets)({
50
+ limit: parseInt(options.limit)
51
+ }, pluginConfig, logger);
52
+ // eslint-disable-next-line no-console
53
+ console.log(JSON.stringify(result, null, 2));
54
+ logger.info(`[${new Date().toISOString()}] [ContextLake] CLI list success`);
55
+ }
56
+ catch (e) {
57
+ console.error('Error:', e.message);
58
+ logger.error(`[${new Date().toISOString()}] [ContextLake] CLI list failed`, { error: e.message, stack: e.stack });
59
+ }
60
+ },
61
+ deleteAction: async (options) => {
62
+ logger.info(`[${new Date().toISOString()}] [ContextLake] CLI delete started`, { options });
63
+ try {
64
+ const result = await (0, manage_1.deleteAssets)({
65
+ file_ids: options.ids,
66
+ filter: options.filter
67
+ }, pluginConfig, logger);
68
+ // eslint-disable-next-line no-console
69
+ console.log(JSON.stringify(result, null, 2));
70
+ logger.info(`[${new Date().toISOString()}] [ContextLake] CLI delete success`);
71
+ }
72
+ catch (e) {
73
+ console.error('Error:', e.message);
74
+ logger.error(`[${new Date().toISOString()}] [ContextLake] CLI delete failed`, { error: e.message, stack: e.stack });
75
+ }
76
+ }
77
+ };
78
+ }
@@ -0,0 +1 @@
1
+ export declare function registerAll(ctx: any, logger: any): void;