mongo.do 0.1.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/LICENSE +21 -0
- package/README.md +454 -0
- package/dist/agentfs/adapters/anthropic.d.ts +176 -0
- package/dist/agentfs/adapters/anthropic.d.ts.map +1 -0
- package/dist/agentfs/adapters/anthropic.js +629 -0
- package/dist/agentfs/adapters/anthropic.js.map +1 -0
- package/dist/agentfs/adapters/index.d.ts +21 -0
- package/dist/agentfs/adapters/index.d.ts.map +1 -0
- package/dist/agentfs/adapters/index.js +23 -0
- package/dist/agentfs/adapters/index.js.map +1 -0
- package/dist/agentfs/adapters/vercel.d.ts +260 -0
- package/dist/agentfs/adapters/vercel.d.ts.map +1 -0
- package/dist/agentfs/adapters/vercel.js +288 -0
- package/dist/agentfs/adapters/vercel.js.map +1 -0
- package/dist/agentfs/glob.d.ts +116 -0
- package/dist/agentfs/glob.d.ts.map +1 -0
- package/dist/agentfs/glob.js +270 -0
- package/dist/agentfs/glob.js.map +1 -0
- package/dist/agentfs/grep.d.ts +83 -0
- package/dist/agentfs/grep.d.ts.map +1 -0
- package/dist/agentfs/grep.js +193 -0
- package/dist/agentfs/grep.js.map +1 -0
- package/dist/agentfs/index.d.ts +22 -0
- package/dist/agentfs/index.d.ts.map +1 -0
- package/dist/agentfs/index.js +18 -0
- package/dist/agentfs/index.js.map +1 -0
- package/dist/agentfs/kv-store.d.ts +128 -0
- package/dist/agentfs/kv-store.d.ts.map +1 -0
- package/dist/agentfs/kv-store.js +227 -0
- package/dist/agentfs/kv-store.js.map +1 -0
- package/dist/agentfs/mondo-agent.d.ts +255 -0
- package/dist/agentfs/mondo-agent.d.ts.map +1 -0
- package/dist/agentfs/mondo-agent.js +879 -0
- package/dist/agentfs/mondo-agent.js.map +1 -0
- package/dist/agentfs/toolcalls.d.ts +130 -0
- package/dist/agentfs/toolcalls.d.ts.map +1 -0
- package/dist/agentfs/toolcalls.js +178 -0
- package/dist/agentfs/toolcalls.js.map +1 -0
- package/dist/agentfs/types.d.ts +171 -0
- package/dist/agentfs/types.d.ts.map +1 -0
- package/dist/agentfs/types.js +7 -0
- package/dist/agentfs/types.js.map +1 -0
- package/dist/agentfs/vfs.d.ts +249 -0
- package/dist/agentfs/vfs.d.ts.map +1 -0
- package/dist/agentfs/vfs.js +469 -0
- package/dist/agentfs/vfs.js.map +1 -0
- package/dist/cli/index.d.ts +15 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +219 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/mcp.d.ts +119 -0
- package/dist/cli/mcp.d.ts.map +1 -0
- package/dist/cli/mcp.js +418 -0
- package/dist/cli/mcp.js.map +1 -0
- package/dist/cli/server.d.ts +179 -0
- package/dist/cli/server.d.ts.map +1 -0
- package/dist/cli/server.js +441 -0
- package/dist/cli/server.js.map +1 -0
- package/dist/client/Collection.d.ts +199 -0
- package/dist/client/Collection.d.ts.map +1 -0
- package/dist/client/Collection.js +256 -0
- package/dist/client/Collection.js.map +1 -0
- package/dist/client/Database.d.ts +68 -0
- package/dist/client/Database.d.ts.map +1 -0
- package/dist/client/Database.js +105 -0
- package/dist/client/Database.js.map +1 -0
- package/dist/client/MongoClient.d.ts +165 -0
- package/dist/client/MongoClient.d.ts.map +1 -0
- package/dist/client/MongoClient.js +307 -0
- package/dist/client/MongoClient.js.map +1 -0
- package/dist/client/aggregation-cursor.d.ts +210 -0
- package/dist/client/aggregation-cursor.d.ts.map +1 -0
- package/dist/client/aggregation-cursor.js +509 -0
- package/dist/client/aggregation-cursor.js.map +1 -0
- package/dist/client/bulk-write.d.ts +216 -0
- package/dist/client/bulk-write.d.ts.map +1 -0
- package/dist/client/bulk-write.js +63 -0
- package/dist/client/bulk-write.js.map +1 -0
- package/dist/client/change-stream.d.ts +245 -0
- package/dist/client/change-stream.d.ts.map +1 -0
- package/dist/client/change-stream.js +429 -0
- package/dist/client/change-stream.js.map +1 -0
- package/dist/client/cursor.d.ts +85 -0
- package/dist/client/cursor.d.ts.map +1 -0
- package/dist/client/cursor.js +156 -0
- package/dist/client/cursor.js.map +1 -0
- package/dist/client/http-cursor.d.ts +233 -0
- package/dist/client/http-cursor.d.ts.map +1 -0
- package/dist/client/http-cursor.js +496 -0
- package/dist/client/http-cursor.js.map +1 -0
- package/dist/client/index.d.ts +18 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +24 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/mongo-client.d.ts +60 -0
- package/dist/client/mongo-client.d.ts.map +1 -0
- package/dist/client/mongo-client.js +190 -0
- package/dist/client/mongo-client.js.map +1 -0
- package/dist/client/mongo-collection.d.ts +359 -0
- package/dist/client/mongo-collection.d.ts.map +1 -0
- package/dist/client/mongo-collection.js +1641 -0
- package/dist/client/mongo-collection.js.map +1 -0
- package/dist/client/mongo-cursor.d.ts +257 -0
- package/dist/client/mongo-cursor.d.ts.map +1 -0
- package/dist/client/mongo-cursor.js +621 -0
- package/dist/client/mongo-cursor.js.map +1 -0
- package/dist/client/mongo-database.d.ts +88 -0
- package/dist/client/mongo-database.d.ts.map +1 -0
- package/dist/client/mongo-database.js +139 -0
- package/dist/client/mongo-database.js.map +1 -0
- package/dist/client/session.d.ts +210 -0
- package/dist/client/session.d.ts.map +1 -0
- package/dist/client/session.js +326 -0
- package/dist/client/session.js.map +1 -0
- package/dist/durable-object/index-manager.d.ts +173 -0
- package/dist/durable-object/index-manager.d.ts.map +1 -0
- package/dist/durable-object/index-manager.js +764 -0
- package/dist/durable-object/index-manager.js.map +1 -0
- package/dist/durable-object/index.d.ts +12 -0
- package/dist/durable-object/index.d.ts.map +1 -0
- package/dist/durable-object/index.js +8 -0
- package/dist/durable-object/index.js.map +1 -0
- package/dist/durable-object/mcp-handler.d.ts +52 -0
- package/dist/durable-object/mcp-handler.d.ts.map +1 -0
- package/dist/durable-object/mcp-handler.js +186 -0
- package/dist/durable-object/mcp-handler.js.map +1 -0
- package/dist/durable-object/migrations.d.ts +40 -0
- package/dist/durable-object/migrations.d.ts.map +1 -0
- package/dist/durable-object/migrations.js +121 -0
- package/dist/durable-object/migrations.js.map +1 -0
- package/dist/durable-object/mondo-database.d.ts +148 -0
- package/dist/durable-object/mondo-database.d.ts.map +1 -0
- package/dist/durable-object/mondo-database.js +621 -0
- package/dist/durable-object/mondo-database.js.map +1 -0
- package/dist/durable-object/schema.d.ts +192 -0
- package/dist/durable-object/schema.d.ts.map +1 -0
- package/dist/durable-object/schema.js +186 -0
- package/dist/durable-object/schema.js.map +1 -0
- package/dist/embedding/document-serializer.d.ts +118 -0
- package/dist/embedding/document-serializer.d.ts.map +1 -0
- package/dist/embedding/document-serializer.js +339 -0
- package/dist/embedding/document-serializer.js.map +1 -0
- package/dist/embedding/embedding-manager.d.ts +136 -0
- package/dist/embedding/embedding-manager.d.ts.map +1 -0
- package/dist/embedding/embedding-manager.js +176 -0
- package/dist/embedding/embedding-manager.js.map +1 -0
- package/dist/embedding/index.d.ts +9 -0
- package/dist/embedding/index.d.ts.map +1 -0
- package/dist/embedding/index.js +9 -0
- package/dist/embedding/index.js.map +1 -0
- package/dist/executor/aggregation-executor.d.ts +93 -0
- package/dist/executor/aggregation-executor.d.ts.map +1 -0
- package/dist/executor/aggregation-executor.js +275 -0
- package/dist/executor/aggregation-executor.js.map +1 -0
- package/dist/executor/function-executor.d.ts +39 -0
- package/dist/executor/function-executor.d.ts.map +1 -0
- package/dist/executor/function-executor.js +168 -0
- package/dist/executor/function-executor.js.map +1 -0
- package/dist/executor/index.d.ts +4 -0
- package/dist/executor/index.d.ts.map +1 -0
- package/dist/executor/index.js +4 -0
- package/dist/executor/index.js.map +1 -0
- package/dist/executor/vector-search-executor.d.ts +71 -0
- package/dist/executor/vector-search-executor.d.ts.map +1 -0
- package/dist/executor/vector-search-executor.js +113 -0
- package/dist/executor/vector-search-executor.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/adapters/anthropic-adapter.d.ts +256 -0
- package/dist/mcp/adapters/anthropic-adapter.d.ts.map +1 -0
- package/dist/mcp/adapters/anthropic-adapter.js +409 -0
- package/dist/mcp/adapters/anthropic-adapter.js.map +1 -0
- package/dist/mcp/adapters/base-adapter.d.ts +164 -0
- package/dist/mcp/adapters/base-adapter.d.ts.map +1 -0
- package/dist/mcp/adapters/base-adapter.js +277 -0
- package/dist/mcp/adapters/base-adapter.js.map +1 -0
- package/dist/mcp/adapters/errors.d.ts +173 -0
- package/dist/mcp/adapters/errors.d.ts.map +1 -0
- package/dist/mcp/adapters/errors.js +305 -0
- package/dist/mcp/adapters/errors.js.map +1 -0
- package/dist/mcp/adapters/index.d.ts +65 -0
- package/dist/mcp/adapters/index.d.ts.map +1 -0
- package/dist/mcp/adapters/index.js +92 -0
- package/dist/mcp/adapters/index.js.map +1 -0
- package/dist/mcp/adapters/streaming.d.ts +200 -0
- package/dist/mcp/adapters/streaming.d.ts.map +1 -0
- package/dist/mcp/adapters/streaming.js +381 -0
- package/dist/mcp/adapters/streaming.js.map +1 -0
- package/dist/mcp/adapters/vercel-adapter.d.ts +321 -0
- package/dist/mcp/adapters/vercel-adapter.d.ts.map +1 -0
- package/dist/mcp/adapters/vercel-adapter.js +487 -0
- package/dist/mcp/adapters/vercel-adapter.js.map +1 -0
- package/dist/mcp/agent.d.ts +192 -0
- package/dist/mcp/agent.d.ts.map +1 -0
- package/dist/mcp/agent.js +338 -0
- package/dist/mcp/agent.js.map +1 -0
- package/dist/mcp/cli.d.ts +71 -0
- package/dist/mcp/cli.d.ts.map +1 -0
- package/dist/mcp/cli.js +218 -0
- package/dist/mcp/cli.js.map +1 -0
- package/dist/mcp/index.d.ts +15 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +20 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/sandbox/database-proxy.d.ts +118 -0
- package/dist/mcp/sandbox/database-proxy.d.ts.map +1 -0
- package/dist/mcp/sandbox/database-proxy.js +154 -0
- package/dist/mcp/sandbox/database-proxy.js.map +1 -0
- package/dist/mcp/sandbox/index.d.ts +8 -0
- package/dist/mcp/sandbox/index.d.ts.map +1 -0
- package/dist/mcp/sandbox/index.js +7 -0
- package/dist/mcp/sandbox/index.js.map +1 -0
- package/dist/mcp/sandbox/miniflare-evaluator.d.ts +72 -0
- package/dist/mcp/sandbox/miniflare-evaluator.d.ts.map +1 -0
- package/dist/mcp/sandbox/miniflare-evaluator.js +379 -0
- package/dist/mcp/sandbox/miniflare-evaluator.js.map +1 -0
- package/dist/mcp/sandbox/template.d.ts +48 -0
- package/dist/mcp/sandbox/template.d.ts.map +1 -0
- package/dist/mcp/sandbox/template.js +147 -0
- package/dist/mcp/sandbox/template.js.map +1 -0
- package/dist/mcp/sandbox/worker-evaluator.d.ts +160 -0
- package/dist/mcp/sandbox/worker-evaluator.d.ts.map +1 -0
- package/dist/mcp/sandbox/worker-evaluator.js +217 -0
- package/dist/mcp/sandbox/worker-evaluator.js.map +1 -0
- package/dist/mcp/server.d.ts +75 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +278 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tool-call-auditor.d.ts +188 -0
- package/dist/mcp/tool-call-auditor.d.ts.map +1 -0
- package/dist/mcp/tool-call-auditor.js +198 -0
- package/dist/mcp/tool-call-auditor.js.map +1 -0
- package/dist/mcp/tools/do.d.ts +51 -0
- package/dist/mcp/tools/do.d.ts.map +1 -0
- package/dist/mcp/tools/do.js +113 -0
- package/dist/mcp/tools/do.js.map +1 -0
- package/dist/mcp/tools/fetch.d.ts +43 -0
- package/dist/mcp/tools/fetch.d.ts.map +1 -0
- package/dist/mcp/tools/fetch.js +127 -0
- package/dist/mcp/tools/fetch.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +9 -0
- package/dist/mcp/tools/index.d.ts.map +1 -0
- package/dist/mcp/tools/index.js +9 -0
- package/dist/mcp/tools/index.js.map +1 -0
- package/dist/mcp/tools/search.d.ts +60 -0
- package/dist/mcp/tools/search.d.ts.map +1 -0
- package/dist/mcp/tools/search.js +278 -0
- package/dist/mcp/tools/search.js.map +1 -0
- package/dist/mcp/transport/http.d.ts +144 -0
- package/dist/mcp/transport/http.d.ts.map +1 -0
- package/dist/mcp/transport/http.js +545 -0
- package/dist/mcp/transport/http.js.map +1 -0
- package/dist/mcp/transport/index.d.ts +10 -0
- package/dist/mcp/transport/index.d.ts.map +1 -0
- package/dist/mcp/transport/index.js +12 -0
- package/dist/mcp/transport/index.js.map +1 -0
- package/dist/mcp/transport/stdio.d.ts +132 -0
- package/dist/mcp/transport/stdio.d.ts.map +1 -0
- package/dist/mcp/transport/stdio.js +466 -0
- package/dist/mcp/transport/stdio.js.map +1 -0
- package/dist/mcp/types.d.ts +476 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +178 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/olap/cdc/cdc-buffer.d.ts +92 -0
- package/dist/olap/cdc/cdc-buffer.d.ts.map +1 -0
- package/dist/olap/cdc/cdc-buffer.js +146 -0
- package/dist/olap/cdc/cdc-buffer.js.map +1 -0
- package/dist/olap/cdc/cdc-emitter.d.ts +118 -0
- package/dist/olap/cdc/cdc-emitter.d.ts.map +1 -0
- package/dist/olap/cdc/cdc-emitter.js +217 -0
- package/dist/olap/cdc/cdc-emitter.js.map +1 -0
- package/dist/olap/cdc/cdc-schema.d.ts +119 -0
- package/dist/olap/cdc/cdc-schema.d.ts.map +1 -0
- package/dist/olap/cdc/cdc-schema.js +253 -0
- package/dist/olap/cdc/cdc-schema.js.map +1 -0
- package/dist/olap/cdc/index.d.ts +10 -0
- package/dist/olap/cdc/index.d.ts.map +1 -0
- package/dist/olap/cdc/index.js +10 -0
- package/dist/olap/cdc/index.js.map +1 -0
- package/dist/olap/clickhouse/iceberg.d.ts +164 -0
- package/dist/olap/clickhouse/iceberg.d.ts.map +1 -0
- package/dist/olap/clickhouse/iceberg.js +138 -0
- package/dist/olap/clickhouse/iceberg.js.map +1 -0
- package/dist/olap/clickhouse/index.d.ts +14 -0
- package/dist/olap/clickhouse/index.d.ts.map +1 -0
- package/dist/olap/clickhouse/index.js +14 -0
- package/dist/olap/clickhouse/index.js.map +1 -0
- package/dist/olap/clickhouse/mapper.d.ts +170 -0
- package/dist/olap/clickhouse/mapper.d.ts.map +1 -0
- package/dist/olap/clickhouse/mapper.js +654 -0
- package/dist/olap/clickhouse/mapper.js.map +1 -0
- package/dist/olap/clickhouse/olap-backend.d.ts +181 -0
- package/dist/olap/clickhouse/olap-backend.d.ts.map +1 -0
- package/dist/olap/clickhouse/olap-backend.js +1083 -0
- package/dist/olap/clickhouse/olap-backend.js.map +1 -0
- package/dist/olap/clickhouse/query-executor.d.ts +163 -0
- package/dist/olap/clickhouse/query-executor.d.ts.map +1 -0
- package/dist/olap/clickhouse/query-executor.js +560 -0
- package/dist/olap/clickhouse/query-executor.js.map +1 -0
- package/dist/olap/clickhouse/query.d.ts +134 -0
- package/dist/olap/clickhouse/query.d.ts.map +1 -0
- package/dist/olap/clickhouse/query.js +512 -0
- package/dist/olap/clickhouse/query.js.map +1 -0
- package/dist/olap/stage/index.d.ts +6 -0
- package/dist/olap/stage/index.d.ts.map +1 -0
- package/dist/olap/stage/index.js +6 -0
- package/dist/olap/stage/index.js.map +1 -0
- package/dist/olap/stage/parser.d.ts +68 -0
- package/dist/olap/stage/parser.d.ts.map +1 -0
- package/dist/olap/stage/parser.js +293 -0
- package/dist/olap/stage/parser.js.map +1 -0
- package/dist/olap/stage/router.d.ts +94 -0
- package/dist/olap/stage/router.d.ts.map +1 -0
- package/dist/olap/stage/router.js +390 -0
- package/dist/olap/stage/router.js.map +1 -0
- package/dist/rpc/endpoint.d.ts +52 -0
- package/dist/rpc/endpoint.d.ts.map +1 -0
- package/dist/rpc/endpoint.js +734 -0
- package/dist/rpc/endpoint.js.map +1 -0
- package/dist/rpc/index.d.ts +34 -0
- package/dist/rpc/index.d.ts.map +1 -0
- package/dist/rpc/index.js +45 -0
- package/dist/rpc/index.js.map +1 -0
- package/dist/rpc/rpc-client.d.ts +275 -0
- package/dist/rpc/rpc-client.d.ts.map +1 -0
- package/dist/rpc/rpc-client.js +735 -0
- package/dist/rpc/rpc-client.js.map +1 -0
- package/dist/rpc/rpc-target.d.ts +220 -0
- package/dist/rpc/rpc-target.d.ts.map +1 -0
- package/dist/rpc/rpc-target.js +500 -0
- package/dist/rpc/rpc-target.js.map +1 -0
- package/dist/rpc/worker-entrypoint.d.ts +159 -0
- package/dist/rpc/worker-entrypoint.d.ts.map +1 -0
- package/dist/rpc/worker-entrypoint.js +212 -0
- package/dist/rpc/worker-entrypoint.js.map +1 -0
- package/dist/server.d.ts +18 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +129 -0
- package/dist/server.js.map +1 -0
- package/dist/studio/components/browser/CollectionItem.d.ts +26 -0
- package/dist/studio/components/browser/CollectionItem.d.ts.map +1 -0
- package/dist/studio/components/browser/CollectionItem.js +143 -0
- package/dist/studio/components/browser/CollectionItem.js.map +1 -0
- package/dist/studio/components/browser/CollectionTree.d.ts +45 -0
- package/dist/studio/components/browser/CollectionTree.d.ts.map +1 -0
- package/dist/studio/components/browser/CollectionTree.js +207 -0
- package/dist/studio/components/browser/CollectionTree.js.map +1 -0
- package/dist/studio/components/browser/ConnectedDatabaseBrowser.d.ts +51 -0
- package/dist/studio/components/browser/ConnectedDatabaseBrowser.d.ts.map +1 -0
- package/dist/studio/components/browser/ConnectedDatabaseBrowser.js +185 -0
- package/dist/studio/components/browser/ConnectedDatabaseBrowser.js.map +1 -0
- package/dist/studio/components/browser/DatabaseBrowser.d.ts +46 -0
- package/dist/studio/components/browser/DatabaseBrowser.d.ts.map +1 -0
- package/dist/studio/components/browser/DatabaseBrowser.js +304 -0
- package/dist/studio/components/browser/DatabaseBrowser.js.map +1 -0
- package/dist/studio/components/browser/__tests__/CollectionItem.test.d.ts +5 -0
- package/dist/studio/components/browser/__tests__/CollectionItem.test.d.ts.map +1 -0
- package/dist/studio/components/browser/__tests__/CollectionItem.test.js +169 -0
- package/dist/studio/components/browser/__tests__/CollectionItem.test.js.map +1 -0
- package/dist/studio/components/browser/__tests__/CollectionTree.test.d.ts +5 -0
- package/dist/studio/components/browser/__tests__/CollectionTree.test.d.ts.map +1 -0
- package/dist/studio/components/browser/__tests__/CollectionTree.test.js +203 -0
- package/dist/studio/components/browser/__tests__/CollectionTree.test.js.map +1 -0
- package/dist/studio/components/browser/__tests__/DatabaseBrowser.e2e.test.d.ts +8 -0
- package/dist/studio/components/browser/__tests__/DatabaseBrowser.e2e.test.d.ts.map +1 -0
- package/dist/studio/components/browser/__tests__/DatabaseBrowser.e2e.test.js +522 -0
- package/dist/studio/components/browser/__tests__/DatabaseBrowser.e2e.test.js.map +1 -0
- package/dist/studio/components/browser/__tests__/DatabaseBrowser.test.d.ts +5 -0
- package/dist/studio/components/browser/__tests__/DatabaseBrowser.test.d.ts.map +1 -0
- package/dist/studio/components/browser/__tests__/DatabaseBrowser.test.js +518 -0
- package/dist/studio/components/browser/__tests__/DatabaseBrowser.test.js.map +1 -0
- package/dist/studio/components/browser/__tests__/setup.d.ts +5 -0
- package/dist/studio/components/browser/__tests__/setup.d.ts.map +1 -0
- package/dist/studio/components/browser/__tests__/setup.js +22 -0
- package/dist/studio/components/browser/__tests__/setup.js.map +1 -0
- package/dist/studio/components/browser/index.d.ts +15 -0
- package/dist/studio/components/browser/index.d.ts.map +1 -0
- package/dist/studio/components/browser/index.js +10 -0
- package/dist/studio/components/browser/index.js.map +1 -0
- package/dist/studio/components/browser/types.d.ts +33 -0
- package/dist/studio/components/browser/types.d.ts.map +1 -0
- package/dist/studio/components/browser/types.js +5 -0
- package/dist/studio/components/browser/types.js.map +1 -0
- package/dist/studio/components/connection/ConnectionForm.d.ts +59 -0
- package/dist/studio/components/connection/ConnectionForm.d.ts.map +1 -0
- package/dist/studio/components/connection/ConnectionForm.js +274 -0
- package/dist/studio/components/connection/ConnectionForm.js.map +1 -0
- package/dist/studio/components/connection/ConnectionList.d.ts +59 -0
- package/dist/studio/components/connection/ConnectionList.d.ts.map +1 -0
- package/dist/studio/components/connection/ConnectionList.js +286 -0
- package/dist/studio/components/connection/ConnectionList.js.map +1 -0
- package/dist/studio/components/connection/ConnectionPanel.d.ts +132 -0
- package/dist/studio/components/connection/ConnectionPanel.d.ts.map +1 -0
- package/dist/studio/components/connection/ConnectionPanel.js +293 -0
- package/dist/studio/components/connection/ConnectionPanel.js.map +1 -0
- package/dist/studio/components/connection/__tests__/ConnectionPanel.test.d.ts +8 -0
- package/dist/studio/components/connection/__tests__/ConnectionPanel.test.d.ts.map +1 -0
- package/dist/studio/components/connection/__tests__/ConnectionPanel.test.js +632 -0
- package/dist/studio/components/connection/__tests__/ConnectionPanel.test.js.map +1 -0
- package/dist/studio/components/connection/__tests__/setup.d.ts +5 -0
- package/dist/studio/components/connection/__tests__/setup.d.ts.map +1 -0
- package/dist/studio/components/connection/__tests__/setup.js +11 -0
- package/dist/studio/components/connection/__tests__/setup.js.map +1 -0
- package/dist/studio/components/connection/index.d.ts +10 -0
- package/dist/studio/components/connection/index.d.ts.map +1 -0
- package/dist/studio/components/connection/index.js +7 -0
- package/dist/studio/components/connection/index.js.map +1 -0
- package/dist/studio/components/crud/DeleteDocumentDialog.d.ts +91 -0
- package/dist/studio/components/crud/DeleteDocumentDialog.d.ts.map +1 -0
- package/dist/studio/components/crud/DeleteDocumentDialog.js +273 -0
- package/dist/studio/components/crud/DeleteDocumentDialog.js.map +1 -0
- package/dist/studio/components/crud/DocumentEditor.d.ts +32 -0
- package/dist/studio/components/crud/DocumentEditor.d.ts.map +1 -0
- package/dist/studio/components/crud/DocumentEditor.js +546 -0
- package/dist/studio/components/crud/DocumentEditor.js.map +1 -0
- package/dist/studio/components/crud/InsertDocumentDialog.d.ts +78 -0
- package/dist/studio/components/crud/InsertDocumentDialog.d.ts.map +1 -0
- package/dist/studio/components/crud/InsertDocumentDialog.js +323 -0
- package/dist/studio/components/crud/InsertDocumentDialog.js.map +1 -0
- package/dist/studio/components/crud/__tests__/DeleteDocumentDialog.test.d.ts +5 -0
- package/dist/studio/components/crud/__tests__/DeleteDocumentDialog.test.d.ts.map +1 -0
- package/dist/studio/components/crud/__tests__/DeleteDocumentDialog.test.js +298 -0
- package/dist/studio/components/crud/__tests__/DeleteDocumentDialog.test.js.map +1 -0
- package/dist/studio/components/crud/__tests__/DocumentEditor.test.d.ts +8 -0
- package/dist/studio/components/crud/__tests__/DocumentEditor.test.d.ts.map +1 -0
- package/dist/studio/components/crud/__tests__/DocumentEditor.test.js +368 -0
- package/dist/studio/components/crud/__tests__/DocumentEditor.test.js.map +1 -0
- package/dist/studio/components/crud/__tests__/InsertDocumentDialog.test.d.ts +2 -0
- package/dist/studio/components/crud/__tests__/InsertDocumentDialog.test.d.ts.map +1 -0
- package/dist/studio/components/crud/__tests__/InsertDocumentDialog.test.js +352 -0
- package/dist/studio/components/crud/__tests__/InsertDocumentDialog.test.js.map +1 -0
- package/dist/studio/components/crud/__tests__/setup.d.ts +5 -0
- package/dist/studio/components/crud/__tests__/setup.d.ts.map +1 -0
- package/dist/studio/components/crud/__tests__/setup.js +22 -0
- package/dist/studio/components/crud/__tests__/setup.js.map +1 -0
- package/dist/studio/components/crud/index.d.ts +12 -0
- package/dist/studio/components/crud/index.d.ts.map +1 -0
- package/dist/studio/components/crud/index.js +11 -0
- package/dist/studio/components/crud/index.js.map +1 -0
- package/dist/studio/hooks/useConnection.d.ts +127 -0
- package/dist/studio/hooks/useConnection.d.ts.map +1 -0
- package/dist/studio/hooks/useConnection.js +414 -0
- package/dist/studio/hooks/useConnection.js.map +1 -0
- package/dist/studio/hooks/useDatabaseBrowser.d.ts +107 -0
- package/dist/studio/hooks/useDatabaseBrowser.d.ts.map +1 -0
- package/dist/studio/hooks/useDatabaseBrowser.js +294 -0
- package/dist/studio/hooks/useDatabaseBrowser.js.map +1 -0
- package/dist/studio/index.d.ts +16 -0
- package/dist/studio/index.d.ts.map +1 -0
- package/dist/studio/index.js +14 -0
- package/dist/studio/index.js.map +1 -0
- package/dist/studio/types/connection.d.ts +266 -0
- package/dist/studio/types/connection.d.ts.map +1 -0
- package/dist/studio/types/connection.js +159 -0
- package/dist/studio/types/connection.js.map +1 -0
- package/dist/studio/vitest.config.d.ts +3 -0
- package/dist/studio/vitest.config.d.ts.map +1 -0
- package/dist/studio/vitest.config.js +33 -0
- package/dist/studio/vitest.config.js.map +1 -0
- package/dist/translator/aggregation-translator.d.ts +51 -0
- package/dist/translator/aggregation-translator.d.ts.map +1 -0
- package/dist/translator/aggregation-translator.js +324 -0
- package/dist/translator/aggregation-translator.js.map +1 -0
- package/dist/translator/dialect.d.ts +131 -0
- package/dist/translator/dialect.d.ts.map +1 -0
- package/dist/translator/dialect.js +276 -0
- package/dist/translator/dialect.js.map +1 -0
- package/dist/translator/geo-translator.d.ts +91 -0
- package/dist/translator/geo-translator.d.ts.map +1 -0
- package/dist/translator/geo-translator.js +587 -0
- package/dist/translator/geo-translator.js.map +1 -0
- package/dist/translator/hybrid-translator.d.ts +70 -0
- package/dist/translator/hybrid-translator.d.ts.map +1 -0
- package/dist/translator/hybrid-translator.js +193 -0
- package/dist/translator/hybrid-translator.js.map +1 -0
- package/dist/translator/index.d.ts +13 -0
- package/dist/translator/index.d.ts.map +1 -0
- package/dist/translator/index.js +11 -0
- package/dist/translator/index.js.map +1 -0
- package/dist/translator/query-translator.d.ts +211 -0
- package/dist/translator/query-translator.d.ts.map +1 -0
- package/dist/translator/query-translator.js +1276 -0
- package/dist/translator/query-translator.js.map +1 -0
- package/dist/translator/search-highlight.d.ts +83 -0
- package/dist/translator/search-highlight.d.ts.map +1 -0
- package/dist/translator/search-highlight.js +83 -0
- package/dist/translator/search-highlight.js.map +1 -0
- package/dist/translator/search-translator.d.ts +155 -0
- package/dist/translator/search-translator.d.ts.map +1 -0
- package/dist/translator/search-translator.js +241 -0
- package/dist/translator/search-translator.js.map +1 -0
- package/dist/translator/stages/add-fields-stage.d.ts +7 -0
- package/dist/translator/stages/add-fields-stage.d.ts.map +1 -0
- package/dist/translator/stages/add-fields-stage.js +72 -0
- package/dist/translator/stages/add-fields-stage.js.map +1 -0
- package/dist/translator/stages/bucket-stage.d.ts +7 -0
- package/dist/translator/stages/bucket-stage.d.ts.map +1 -0
- package/dist/translator/stages/bucket-stage.js +87 -0
- package/dist/translator/stages/bucket-stage.js.map +1 -0
- package/dist/translator/stages/count-stage.d.ts +7 -0
- package/dist/translator/stages/count-stage.d.ts.map +1 -0
- package/dist/translator/stages/count-stage.js +12 -0
- package/dist/translator/stages/count-stage.js.map +1 -0
- package/dist/translator/stages/expression-translator.d.ts +68 -0
- package/dist/translator/stages/expression-translator.d.ts.map +1 -0
- package/dist/translator/stages/expression-translator.js +467 -0
- package/dist/translator/stages/expression-translator.js.map +1 -0
- package/dist/translator/stages/facet-stage.d.ts +13 -0
- package/dist/translator/stages/facet-stage.d.ts.map +1 -0
- package/dist/translator/stages/facet-stage.js +26 -0
- package/dist/translator/stages/facet-stage.js.map +1 -0
- package/dist/translator/stages/fusion-stages.d.ts +118 -0
- package/dist/translator/stages/fusion-stages.d.ts.map +1 -0
- package/dist/translator/stages/fusion-stages.js +201 -0
- package/dist/translator/stages/fusion-stages.js.map +1 -0
- package/dist/translator/stages/group-stage.d.ts +8 -0
- package/dist/translator/stages/group-stage.d.ts.map +1 -0
- package/dist/translator/stages/group-stage.js +123 -0
- package/dist/translator/stages/group-stage.js.map +1 -0
- package/dist/translator/stages/index.d.ts +24 -0
- package/dist/translator/stages/index.d.ts.map +1 -0
- package/dist/translator/stages/index.js +24 -0
- package/dist/translator/stages/index.js.map +1 -0
- package/dist/translator/stages/join-optimizer.d.ts +37 -0
- package/dist/translator/stages/join-optimizer.d.ts.map +1 -0
- package/dist/translator/stages/join-optimizer.js +93 -0
- package/dist/translator/stages/join-optimizer.js.map +1 -0
- package/dist/translator/stages/limit-stage.d.ts +7 -0
- package/dist/translator/stages/limit-stage.d.ts.map +1 -0
- package/dist/translator/stages/limit-stage.js +11 -0
- package/dist/translator/stages/limit-stage.js.map +1 -0
- package/dist/translator/stages/lookup-stage.d.ts +7 -0
- package/dist/translator/stages/lookup-stage.d.ts.map +1 -0
- package/dist/translator/stages/lookup-stage.js +73 -0
- package/dist/translator/stages/lookup-stage.js.map +1 -0
- package/dist/translator/stages/match-stage.d.ts +7 -0
- package/dist/translator/stages/match-stage.d.ts.map +1 -0
- package/dist/translator/stages/match-stage.js +14 -0
- package/dist/translator/stages/match-stage.js.map +1 -0
- package/dist/translator/stages/optimizer.d.ts +15 -0
- package/dist/translator/stages/optimizer.d.ts.map +1 -0
- package/dist/translator/stages/optimizer.js +249 -0
- package/dist/translator/stages/optimizer.js.map +1 -0
- package/dist/translator/stages/parallel-facet.d.ts +47 -0
- package/dist/translator/stages/parallel-facet.d.ts.map +1 -0
- package/dist/translator/stages/parallel-facet.js +57 -0
- package/dist/translator/stages/parallel-facet.js.map +1 -0
- package/dist/translator/stages/project-stage.d.ts +8 -0
- package/dist/translator/stages/project-stage.d.ts.map +1 -0
- package/dist/translator/stages/project-stage.js +145 -0
- package/dist/translator/stages/project-stage.js.map +1 -0
- package/dist/translator/stages/search-stage.d.ts +60 -0
- package/dist/translator/stages/search-stage.d.ts.map +1 -0
- package/dist/translator/stages/search-stage.js +89 -0
- package/dist/translator/stages/search-stage.js.map +1 -0
- package/dist/translator/stages/skip-stage.d.ts +7 -0
- package/dist/translator/stages/skip-stage.d.ts.map +1 -0
- package/dist/translator/stages/skip-stage.js +11 -0
- package/dist/translator/stages/skip-stage.js.map +1 -0
- package/dist/translator/stages/sort-stage.d.ts +7 -0
- package/dist/translator/stages/sort-stage.d.ts.map +1 -0
- package/dist/translator/stages/sort-stage.js +21 -0
- package/dist/translator/stages/sort-stage.js.map +1 -0
- package/dist/translator/stages/types.d.ts +136 -0
- package/dist/translator/stages/types.d.ts.map +1 -0
- package/dist/translator/stages/types.js +5 -0
- package/dist/translator/stages/types.js.map +1 -0
- package/dist/translator/stages/unwind-stage.d.ts +7 -0
- package/dist/translator/stages/unwind-stage.d.ts.map +1 -0
- package/dist/translator/stages/unwind-stage.js +61 -0
- package/dist/translator/stages/unwind-stage.js.map +1 -0
- package/dist/translator/stages/vector-search-stage.d.ts +53 -0
- package/dist/translator/stages/vector-search-stage.d.ts.map +1 -0
- package/dist/translator/stages/vector-search-stage.js +62 -0
- package/dist/translator/stages/vector-search-stage.js.map +1 -0
- package/dist/translator/update-translator.d.ts +148 -0
- package/dist/translator/update-translator.d.ts.map +1 -0
- package/dist/translator/update-translator.js +819 -0
- package/dist/translator/update-translator.js.map +1 -0
- package/dist/translator/vector-translator.d.ts +89 -0
- package/dist/translator/vector-translator.d.ts.map +1 -0
- package/dist/translator/vector-translator.js +106 -0
- package/dist/translator/vector-translator.js.map +1 -0
- package/dist/types/env.d.ts +31 -0
- package/dist/types/env.d.ts.map +1 -0
- package/dist/types/env.js +5 -0
- package/dist/types/env.js.map +1 -0
- package/dist/types/function.d.ts +65 -0
- package/dist/types/function.d.ts.map +1 -0
- package/dist/types/function.js +5 -0
- package/dist/types/function.js.map +1 -0
- package/dist/types/index.d.ts +137 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +13 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/mongodb.d.ts +258 -0
- package/dist/types/mongodb.d.ts.map +1 -0
- package/dist/types/mongodb.js +5 -0
- package/dist/types/mongodb.js.map +1 -0
- package/dist/types/objectid.d.ts +130 -0
- package/dist/types/objectid.d.ts.map +1 -0
- package/dist/types/objectid.js +314 -0
- package/dist/types/objectid.js.map +1 -0
- package/dist/types/rpc.d.ts +313 -0
- package/dist/types/rpc.d.ts.map +1 -0
- package/dist/types/rpc.js +136 -0
- package/dist/types/rpc.js.map +1 -0
- package/dist/types/vectorize.d.ts +136 -0
- package/dist/types/vectorize.d.ts.map +1 -0
- package/dist/types/vectorize.js +8 -0
- package/dist/types/vectorize.js.map +1 -0
- package/dist/utils/sql-safety.d.ts +64 -0
- package/dist/utils/sql-safety.d.ts.map +1 -0
- package/dist/utils/sql-safety.js +112 -0
- package/dist/utils/sql-safety.js.map +1 -0
- package/dist/validation/document-validator.d.ts +195 -0
- package/dist/validation/document-validator.d.ts.map +1 -0
- package/dist/validation/document-validator.js +529 -0
- package/dist/validation/document-validator.js.map +1 -0
- package/dist/vectorize/document-serializer.d.ts +119 -0
- package/dist/vectorize/document-serializer.d.ts.map +1 -0
- package/dist/vectorize/document-serializer.js +320 -0
- package/dist/vectorize/document-serializer.js.map +1 -0
- package/dist/wire/auth/index.d.ts +5 -0
- package/dist/wire/auth/index.d.ts.map +1 -0
- package/dist/wire/auth/index.js +5 -0
- package/dist/wire/auth/index.js.map +1 -0
- package/dist/wire/auth/scram.d.ts +160 -0
- package/dist/wire/auth/scram.d.ts.map +1 -0
- package/dist/wire/auth/scram.js +425 -0
- package/dist/wire/auth/scram.js.map +1 -0
- package/dist/wire/backend/interface.d.ts +168 -0
- package/dist/wire/backend/interface.d.ts.map +1 -0
- package/dist/wire/backend/interface.js +10 -0
- package/dist/wire/backend/interface.js.map +1 -0
- package/dist/wire/backend/local-sqlite.d.ts +89 -0
- package/dist/wire/backend/local-sqlite.d.ts.map +1 -0
- package/dist/wire/backend/local-sqlite.js +1002 -0
- package/dist/wire/backend/local-sqlite.js.map +1 -0
- package/dist/wire/backend/query-router.d.ts +197 -0
- package/dist/wire/backend/query-router.d.ts.map +1 -0
- package/dist/wire/backend/query-router.js +590 -0
- package/dist/wire/backend/query-router.js.map +1 -0
- package/dist/wire/backend/validation.d.ts +26 -0
- package/dist/wire/backend/validation.d.ts.map +1 -0
- package/dist/wire/backend/validation.js +79 -0
- package/dist/wire/backend/validation.js.map +1 -0
- package/dist/wire/backend/workers-proxy.d.ts +95 -0
- package/dist/wire/backend/workers-proxy.d.ts.map +1 -0
- package/dist/wire/backend/workers-proxy.js +429 -0
- package/dist/wire/backend/workers-proxy.js.map +1 -0
- package/dist/wire/commands/admin.d.ts +49 -0
- package/dist/wire/commands/admin.d.ts.map +1 -0
- package/dist/wire/commands/admin.js +272 -0
- package/dist/wire/commands/admin.js.map +1 -0
- package/dist/wire/commands/aggregate.d.ts +15 -0
- package/dist/wire/commands/aggregate.d.ts.map +1 -0
- package/dist/wire/commands/aggregate.js +98 -0
- package/dist/wire/commands/aggregate.js.map +1 -0
- package/dist/wire/commands/auth.d.ts +58 -0
- package/dist/wire/commands/auth.d.ts.map +1 -0
- package/dist/wire/commands/auth.js +158 -0
- package/dist/wire/commands/auth.js.map +1 -0
- package/dist/wire/commands/crud.d.ts +49 -0
- package/dist/wire/commands/crud.d.ts.map +1 -0
- package/dist/wire/commands/crud.js +336 -0
- package/dist/wire/commands/crud.js.map +1 -0
- package/dist/wire/commands/hello.d.ts +35 -0
- package/dist/wire/commands/hello.d.ts.map +1 -0
- package/dist/wire/commands/hello.js +204 -0
- package/dist/wire/commands/hello.js.map +1 -0
- package/dist/wire/commands/index.d.ts +24 -0
- package/dist/wire/commands/index.d.ts.map +1 -0
- package/dist/wire/commands/index.js +145 -0
- package/dist/wire/commands/index.js.map +1 -0
- package/dist/wire/commands/router.d.ts +46 -0
- package/dist/wire/commands/router.d.ts.map +1 -0
- package/dist/wire/commands/router.js +151 -0
- package/dist/wire/commands/router.js.map +1 -0
- package/dist/wire/commands/types.d.ts +51 -0
- package/dist/wire/commands/types.d.ts.map +1 -0
- package/dist/wire/commands/types.js +15 -0
- package/dist/wire/commands/types.js.map +1 -0
- package/dist/wire/index.d.ts +15 -0
- package/dist/wire/index.d.ts.map +1 -0
- package/dist/wire/index.js +19 -0
- package/dist/wire/index.js.map +1 -0
- package/dist/wire/message.d.ts +49 -0
- package/dist/wire/message.d.ts.map +1 -0
- package/dist/wire/message.js +299 -0
- package/dist/wire/message.js.map +1 -0
- package/dist/wire/server.d.ts +145 -0
- package/dist/wire/server.d.ts.map +1 -0
- package/dist/wire/server.js +284 -0
- package/dist/wire/server.js.map +1 -0
- package/dist/wire/types.d.ts +140 -0
- package/dist/wire/types.d.ts.map +1 -0
- package/dist/wire/types.js +64 -0
- package/dist/wire/types.js.map +1 -0
- package/dist/worker.d.ts +17 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +22 -0
- package/dist/worker.js.map +1 -0
- package/package.json +82 -0
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vercel AI SDK Adapter for MCP
|
|
3
|
+
*
|
|
4
|
+
* Adapts MCP server tools to Vercel AI SDK's tool format.
|
|
5
|
+
* Compatible with the Vercel AI SDK's `tool` and `generateText` APIs.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Converts MCP tool definitions to Vercel AI SDK format
|
|
9
|
+
* - Supports both `tool()` and `CoreTool` interfaces
|
|
10
|
+
* - Handles streaming via Vercel's streaming responses
|
|
11
|
+
* - Integrates with `ai` package for Next.js compatibility
|
|
12
|
+
*
|
|
13
|
+
* @see https://sdk.vercel.ai/docs/ai-sdk-core/tools-and-tool-calling
|
|
14
|
+
*/
|
|
15
|
+
import { BaseAdapter } from './base-adapter';
|
|
16
|
+
import { McpError } from './errors';
|
|
17
|
+
import { streamTextContent, } from './streaming';
|
|
18
|
+
import { z } from 'zod';
|
|
19
|
+
// =============================================================================
|
|
20
|
+
// Constants
|
|
21
|
+
// =============================================================================
|
|
22
|
+
const DEFAULT_STREAMING_THRESHOLD = 50 * 1024; // 50KB
|
|
23
|
+
// =============================================================================
|
|
24
|
+
// Vercel Adapter Class
|
|
25
|
+
// =============================================================================
|
|
26
|
+
/**
|
|
27
|
+
* Vercel AI SDK Adapter
|
|
28
|
+
*
|
|
29
|
+
* Converts MCP tools to Vercel AI SDK's CoreTool format and handles
|
|
30
|
+
* tool execution with streaming support.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* import { generateText, tool } from 'ai'
|
|
35
|
+
*
|
|
36
|
+
* const mcpServer = createMcpServer({ dbAccess })
|
|
37
|
+
* const adapter = new VercelAdapter({ server: mcpServer })
|
|
38
|
+
*
|
|
39
|
+
* await adapter.initialize()
|
|
40
|
+
*
|
|
41
|
+
* // Get tools for Vercel AI SDK
|
|
42
|
+
* const tools = await adapter.getTools()
|
|
43
|
+
*
|
|
44
|
+
* // Use with generateText
|
|
45
|
+
* const result = await generateText({
|
|
46
|
+
* model: openai('gpt-4'),
|
|
47
|
+
* tools,
|
|
48
|
+
* prompt: 'Search for documents about AI',
|
|
49
|
+
* })
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export class VercelAdapter extends BaseAdapter {
|
|
53
|
+
streamingThreshold;
|
|
54
|
+
defaultStreaming;
|
|
55
|
+
formatResult;
|
|
56
|
+
toolCache = new Map();
|
|
57
|
+
mcpToolNames = new Map(); // Vercel name -> MCP name
|
|
58
|
+
initialized = false;
|
|
59
|
+
constructor(config) {
|
|
60
|
+
super(config);
|
|
61
|
+
this.streamingThreshold = config.streamingThreshold ?? DEFAULT_STREAMING_THRESHOLD;
|
|
62
|
+
this.defaultStreaming = config.defaultStreaming ?? true;
|
|
63
|
+
this.formatResult = config.formatResult ?? this.defaultResultFormatter.bind(this);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Adapter name for logging
|
|
67
|
+
*/
|
|
68
|
+
get adapterName() {
|
|
69
|
+
return 'vercel';
|
|
70
|
+
}
|
|
71
|
+
// ===========================================================================
|
|
72
|
+
// Lifecycle
|
|
73
|
+
// ===========================================================================
|
|
74
|
+
/**
|
|
75
|
+
* Initialize the adapter
|
|
76
|
+
*
|
|
77
|
+
* Fetches all available tools from the MCP server and converts
|
|
78
|
+
* them to Vercel AI SDK format.
|
|
79
|
+
*/
|
|
80
|
+
async initialize() {
|
|
81
|
+
if (this.initialized) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
this.log('info', 'Initializing Vercel AI SDK adapter');
|
|
85
|
+
try {
|
|
86
|
+
const mcpTools = await this.server.listTools();
|
|
87
|
+
for (const tool of mcpTools) {
|
|
88
|
+
const vercelTool = this.convertTool(tool);
|
|
89
|
+
this.toolCache.set(tool.name, vercelTool);
|
|
90
|
+
this.mcpToolNames.set(tool.name, tool.name);
|
|
91
|
+
this.log('debug', `Registered tool: ${tool.name}`);
|
|
92
|
+
}
|
|
93
|
+
this.initialized = true;
|
|
94
|
+
this.log('info', `Vercel adapter initialized with ${this.toolCache.size} tools`);
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
this.log('error', 'Failed to initialize Vercel adapter', { error });
|
|
98
|
+
throw McpError.fromError(error instanceof Error ? error : new Error(String(error)));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Cleanup adapter resources
|
|
103
|
+
*/
|
|
104
|
+
async cleanup() {
|
|
105
|
+
this.toolCache.clear();
|
|
106
|
+
this.mcpToolNames.clear();
|
|
107
|
+
this.initialized = false;
|
|
108
|
+
this.log('info', 'Vercel adapter cleaned up');
|
|
109
|
+
}
|
|
110
|
+
// ===========================================================================
|
|
111
|
+
// Tool Conversion
|
|
112
|
+
// ===========================================================================
|
|
113
|
+
/**
|
|
114
|
+
* Convert MCP tool definition to Vercel CoreTool format
|
|
115
|
+
*/
|
|
116
|
+
convertTool(mcpTool) {
|
|
117
|
+
const parameters = this.convertToZodSchema(mcpTool.inputSchema);
|
|
118
|
+
const toolName = mcpTool.name;
|
|
119
|
+
return {
|
|
120
|
+
description: mcpTool.description,
|
|
121
|
+
parameters,
|
|
122
|
+
execute: async (params) => {
|
|
123
|
+
const response = await this.callTool(toolName, params);
|
|
124
|
+
return this.formatResult(response);
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Convert JSON Schema to Zod schema
|
|
130
|
+
*
|
|
131
|
+
* Creates a Zod schema that validates the same structure as the
|
|
132
|
+
* original JSON Schema from the MCP tool definition.
|
|
133
|
+
*/
|
|
134
|
+
convertToZodSchema(schema) {
|
|
135
|
+
const shape = {};
|
|
136
|
+
if (schema.properties) {
|
|
137
|
+
for (const [key, prop] of Object.entries(schema.properties)) {
|
|
138
|
+
shape[key] = this.convertPropertyToZod(prop, schema.required?.includes(key) ?? false);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return z.object(shape);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Convert a single JSON Schema property to Zod
|
|
145
|
+
*/
|
|
146
|
+
convertPropertyToZod(prop, required) {
|
|
147
|
+
let zodType;
|
|
148
|
+
switch (prop.type) {
|
|
149
|
+
case 'string':
|
|
150
|
+
zodType = z.string();
|
|
151
|
+
if (prop.description) {
|
|
152
|
+
zodType = zodType.describe(prop.description);
|
|
153
|
+
}
|
|
154
|
+
if ('enum' in prop && prop.enum) {
|
|
155
|
+
zodType = z.enum(prop.enum);
|
|
156
|
+
}
|
|
157
|
+
break;
|
|
158
|
+
case 'number':
|
|
159
|
+
case 'integer':
|
|
160
|
+
zodType = z.number();
|
|
161
|
+
if (prop.description) {
|
|
162
|
+
zodType = zodType.describe(prop.description);
|
|
163
|
+
}
|
|
164
|
+
break;
|
|
165
|
+
case 'boolean':
|
|
166
|
+
zodType = z.boolean();
|
|
167
|
+
if (prop.description) {
|
|
168
|
+
zodType = zodType.describe(prop.description);
|
|
169
|
+
}
|
|
170
|
+
break;
|
|
171
|
+
case 'array':
|
|
172
|
+
if ('items' in prop && prop.items) {
|
|
173
|
+
zodType = z.array(this.convertPropertyToZod(prop.items, true));
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
zodType = z.array(z.unknown());
|
|
177
|
+
}
|
|
178
|
+
if (prop.description) {
|
|
179
|
+
zodType = zodType.describe(prop.description);
|
|
180
|
+
}
|
|
181
|
+
break;
|
|
182
|
+
case 'object':
|
|
183
|
+
if ('properties' in prop && prop.properties) {
|
|
184
|
+
const nestedShape = {};
|
|
185
|
+
for (const [key, value] of Object.entries(prop.properties)) {
|
|
186
|
+
const isRequired = 'required' in prop && prop.required?.includes(key);
|
|
187
|
+
nestedShape[key] = this.convertPropertyToZod(value, isRequired ?? false);
|
|
188
|
+
}
|
|
189
|
+
zodType = z.object(nestedShape);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
zodType = z.record(z.string(), z.unknown());
|
|
193
|
+
}
|
|
194
|
+
if (prop.description) {
|
|
195
|
+
zodType = zodType.describe(prop.description);
|
|
196
|
+
}
|
|
197
|
+
break;
|
|
198
|
+
default:
|
|
199
|
+
zodType = z.unknown();
|
|
200
|
+
}
|
|
201
|
+
return required ? zodType : zodType.optional();
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Default result formatter
|
|
205
|
+
*/
|
|
206
|
+
defaultResultFormatter(response) {
|
|
207
|
+
if (response.isError) {
|
|
208
|
+
return JSON.stringify({ error: this.extractTextContent(response) });
|
|
209
|
+
}
|
|
210
|
+
return this.extractTextContent(response);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Extract text content from MCP response
|
|
214
|
+
*/
|
|
215
|
+
extractTextContent(response) {
|
|
216
|
+
return response.content
|
|
217
|
+
.filter((c) => c.type === 'text')
|
|
218
|
+
.map((c) => c.text)
|
|
219
|
+
.join('\n');
|
|
220
|
+
}
|
|
221
|
+
// ===========================================================================
|
|
222
|
+
// Public API
|
|
223
|
+
// ===========================================================================
|
|
224
|
+
/**
|
|
225
|
+
* Get all tools in Vercel AI SDK format
|
|
226
|
+
*
|
|
227
|
+
* Returns a record of tool definitions suitable for use with
|
|
228
|
+
* the Vercel AI SDK's `generateText` or `streamText` functions.
|
|
229
|
+
*
|
|
230
|
+
* @returns Record of tool name to CoreTool
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* ```typescript
|
|
234
|
+
* import { generateText } from 'ai'
|
|
235
|
+
*
|
|
236
|
+
* const tools = await adapter.getTools()
|
|
237
|
+
*
|
|
238
|
+
* const result = await generateText({
|
|
239
|
+
* model: openai('gpt-4'),
|
|
240
|
+
* tools,
|
|
241
|
+
* prompt: 'Search for users',
|
|
242
|
+
* })
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
async getTools() {
|
|
246
|
+
if (!this.initialized) {
|
|
247
|
+
await this.initialize();
|
|
248
|
+
}
|
|
249
|
+
return Object.fromEntries(this.toolCache);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Get a single tool by name
|
|
253
|
+
*
|
|
254
|
+
* @param name - Tool name
|
|
255
|
+
* @returns CoreTool or undefined
|
|
256
|
+
*/
|
|
257
|
+
async getTool(name) {
|
|
258
|
+
if (!this.initialized) {
|
|
259
|
+
await this.initialize();
|
|
260
|
+
}
|
|
261
|
+
return this.toolCache.get(name);
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Handle a tool call from model response
|
|
265
|
+
*
|
|
266
|
+
* Executes the requested tool and returns a tool result.
|
|
267
|
+
*
|
|
268
|
+
* @param toolCall - Tool call from model
|
|
269
|
+
* @returns Tool result
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* ```typescript
|
|
273
|
+
* for (const toolCall of result.toolCalls) {
|
|
274
|
+
* const toolResult = await adapter.handleToolCall(toolCall)
|
|
275
|
+
* results.push(toolResult)
|
|
276
|
+
* }
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
async handleToolCall(toolCall) {
|
|
280
|
+
const startTime = Date.now();
|
|
281
|
+
this.log('debug', `Handling tool call: ${toolCall.toolName}`, {
|
|
282
|
+
id: toolCall.toolCallId,
|
|
283
|
+
});
|
|
284
|
+
try {
|
|
285
|
+
const response = await this.callTool(toolCall.toolName, toolCall.args);
|
|
286
|
+
return {
|
|
287
|
+
toolCallId: toolCall.toolCallId,
|
|
288
|
+
toolName: toolCall.toolName,
|
|
289
|
+
result: this.formatResult(response),
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
catch (error) {
|
|
293
|
+
const mcpError = McpError.fromError(error instanceof Error ? error : new Error(String(error)));
|
|
294
|
+
this.log('error', `Tool call failed: ${toolCall.toolName}`, {
|
|
295
|
+
id: toolCall.toolCallId,
|
|
296
|
+
error: mcpError.message,
|
|
297
|
+
duration: Date.now() - startTime,
|
|
298
|
+
});
|
|
299
|
+
return {
|
|
300
|
+
toolCallId: toolCall.toolCallId,
|
|
301
|
+
toolName: toolCall.toolName,
|
|
302
|
+
result: JSON.stringify({
|
|
303
|
+
error: mcpError.message,
|
|
304
|
+
code: mcpError.code,
|
|
305
|
+
}),
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Handle multiple tool calls in parallel
|
|
311
|
+
*
|
|
312
|
+
* @param toolCalls - Array of tool calls
|
|
313
|
+
* @param concurrency - Maximum concurrent executions (default: 5)
|
|
314
|
+
* @returns Array of tool results
|
|
315
|
+
*/
|
|
316
|
+
async handleToolCalls(toolCalls, concurrency = 5) {
|
|
317
|
+
const results = [];
|
|
318
|
+
const executing = [];
|
|
319
|
+
for (const toolCall of toolCalls) {
|
|
320
|
+
const promise = this.handleToolCall(toolCall).then((result) => {
|
|
321
|
+
results.push(result);
|
|
322
|
+
});
|
|
323
|
+
executing.push(promise);
|
|
324
|
+
if (executing.length >= concurrency) {
|
|
325
|
+
await Promise.race(executing);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
await Promise.all(executing);
|
|
329
|
+
return results;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Create a streaming tool executor
|
|
333
|
+
*
|
|
334
|
+
* Returns a function that executes a tool and streams the response.
|
|
335
|
+
* Compatible with Vercel AI SDK's streaming patterns.
|
|
336
|
+
*
|
|
337
|
+
* @param toolName - Name of the tool
|
|
338
|
+
* @returns Streaming executor function
|
|
339
|
+
*
|
|
340
|
+
* @example
|
|
341
|
+
* ```typescript
|
|
342
|
+
* const searchStream = adapter.createStreamingExecutor('search')
|
|
343
|
+
*
|
|
344
|
+
* const stream = searchStream({ query: 'AI documents' })
|
|
345
|
+
*
|
|
346
|
+
* for await (const chunk of stream) {
|
|
347
|
+
* process.stdout.write(chunk)
|
|
348
|
+
* }
|
|
349
|
+
* ```
|
|
350
|
+
*/
|
|
351
|
+
createStreamingExecutor(toolName) {
|
|
352
|
+
return (args, options) => {
|
|
353
|
+
return this.executeWithStreaming(toolName, args, options);
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Execute a tool with streaming response
|
|
358
|
+
*
|
|
359
|
+
* @param toolName - Tool name
|
|
360
|
+
* @param args - Tool arguments
|
|
361
|
+
* @param options - Stream options
|
|
362
|
+
* @yields String chunks of the response
|
|
363
|
+
*/
|
|
364
|
+
async *executeWithStreaming(toolName, args, options) {
|
|
365
|
+
const response = await this.callTool(toolName, args);
|
|
366
|
+
const content = this.extractTextContent(response);
|
|
367
|
+
const shouldStream = options?.stream ?? this.defaultStreaming;
|
|
368
|
+
const chunkSize = options?.chunkSize ?? 1024;
|
|
369
|
+
if (!shouldStream || content.length <= this.streamingThreshold) {
|
|
370
|
+
yield content;
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
for await (const chunk of streamTextContent(content, {
|
|
374
|
+
chunkSize,
|
|
375
|
+
...(options?.signal && { signal: options.signal }),
|
|
376
|
+
})) {
|
|
377
|
+
yield chunk.content;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Create a ReadableStream for a tool execution
|
|
382
|
+
*
|
|
383
|
+
* Returns a Web Streams API ReadableStream that can be used
|
|
384
|
+
* with Response objects for HTTP streaming.
|
|
385
|
+
*
|
|
386
|
+
* @param toolName - Tool name
|
|
387
|
+
* @param args - Tool arguments
|
|
388
|
+
* @returns ReadableStream of response chunks
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* ```typescript
|
|
392
|
+
* // In a Next.js API route
|
|
393
|
+
* export async function POST(req: Request) {
|
|
394
|
+
* const { toolName, args } = await req.json()
|
|
395
|
+
* const stream = adapter.createReadableStream(toolName, args)
|
|
396
|
+
* return new Response(stream)
|
|
397
|
+
* }
|
|
398
|
+
* ```
|
|
399
|
+
*/
|
|
400
|
+
createReadableStream(toolName, args) {
|
|
401
|
+
const encoder = new TextEncoder();
|
|
402
|
+
const adapter = this;
|
|
403
|
+
return new ReadableStream({
|
|
404
|
+
async start(controller) {
|
|
405
|
+
try {
|
|
406
|
+
for await (const chunk of adapter.executeWithStreaming(toolName, args)) {
|
|
407
|
+
controller.enqueue(encoder.encode(chunk));
|
|
408
|
+
}
|
|
409
|
+
controller.close();
|
|
410
|
+
}
|
|
411
|
+
catch (error) {
|
|
412
|
+
controller.error(error);
|
|
413
|
+
}
|
|
414
|
+
},
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Create a tool wrapper compatible with Vercel AI SDK's `tool()` helper
|
|
419
|
+
*
|
|
420
|
+
* This creates a tool definition that can be used directly with the
|
|
421
|
+
* `tool()` helper from the `ai` package.
|
|
422
|
+
*
|
|
423
|
+
* @param mcpToolName - MCP tool name
|
|
424
|
+
* @returns Tool configuration object
|
|
425
|
+
*
|
|
426
|
+
* @example
|
|
427
|
+
* ```typescript
|
|
428
|
+
* import { tool } from 'ai'
|
|
429
|
+
*
|
|
430
|
+
* const searchTool = adapter.createToolWrapper('search')
|
|
431
|
+
*
|
|
432
|
+
* // Use with generateText
|
|
433
|
+
* const result = await generateText({
|
|
434
|
+
* model: openai('gpt-4'),
|
|
435
|
+
* tools: { search: searchTool },
|
|
436
|
+
* prompt: 'Find documents',
|
|
437
|
+
* })
|
|
438
|
+
* ```
|
|
439
|
+
*/
|
|
440
|
+
createToolWrapper(mcpToolName) {
|
|
441
|
+
return this.toolCache.get(mcpToolName);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
// =============================================================================
|
|
445
|
+
// Factory Function
|
|
446
|
+
// =============================================================================
|
|
447
|
+
/**
|
|
448
|
+
* Create a Vercel AI SDK adapter for an MCP server
|
|
449
|
+
*
|
|
450
|
+
* @param config - Adapter configuration
|
|
451
|
+
* @returns Configured VercelAdapter instance
|
|
452
|
+
*
|
|
453
|
+
* @example
|
|
454
|
+
* ```typescript
|
|
455
|
+
* const adapter = createVercelAdapter({
|
|
456
|
+
* server: mcpServer,
|
|
457
|
+
* retry: { maxRetries: 3 },
|
|
458
|
+
* streamingThreshold: 10000,
|
|
459
|
+
* })
|
|
460
|
+
*
|
|
461
|
+
* await adapter.initialize()
|
|
462
|
+
* const tools = await adapter.getTools()
|
|
463
|
+
* ```
|
|
464
|
+
*/
|
|
465
|
+
export function createVercelAdapter(config) {
|
|
466
|
+
return new VercelAdapter(config);
|
|
467
|
+
}
|
|
468
|
+
// =============================================================================
|
|
469
|
+
// Utility Functions
|
|
470
|
+
// =============================================================================
|
|
471
|
+
/**
|
|
472
|
+
* Convert Vercel tool results to continuation messages
|
|
473
|
+
*
|
|
474
|
+
* Formats tool results for inclusion in the next model request.
|
|
475
|
+
*
|
|
476
|
+
* @param results - Array of tool results
|
|
477
|
+
* @returns Formatted tool results for API
|
|
478
|
+
*/
|
|
479
|
+
export function formatToolResults(results) {
|
|
480
|
+
return results.map((result) => ({
|
|
481
|
+
type: 'tool-result',
|
|
482
|
+
toolCallId: result.toolCallId,
|
|
483
|
+
toolName: result.toolName,
|
|
484
|
+
result: result.result,
|
|
485
|
+
}));
|
|
486
|
+
}
|
|
487
|
+
//# sourceMappingURL=vercel-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vercel-adapter.js","sourceRoot":"","sources":["../../../src/mcp/adapters/vercel-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,WAAW,EAA0B,MAAM,gBAAgB,CAAA;AAEpE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACnC,OAAO,EACL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search, fetch, do)
|
|
6
|
+
* - AgentFS for file system operations
|
|
7
|
+
* - KV Store for key-value storage
|
|
8
|
+
* - Tool Call Auditing for logging
|
|
9
|
+
* - Code execution via Worker Loader or Miniflare fallback
|
|
10
|
+
*/
|
|
11
|
+
import { type CodeLoader, type McpServerConfig } from './server';
|
|
12
|
+
import { type AgentFSDatabase } from '../agentfs/vfs';
|
|
13
|
+
import { type KVStorageBackend } from '../agentfs/kv-store';
|
|
14
|
+
import { type AuditBackend } from '../agentfs/toolcalls';
|
|
15
|
+
import type { DatabaseAccess, McpToolResponse } from './types';
|
|
16
|
+
/**
|
|
17
|
+
* Execution result from tool or code execution
|
|
18
|
+
*/
|
|
19
|
+
export interface ExecutionResult<T = unknown> {
|
|
20
|
+
success: boolean;
|
|
21
|
+
value?: T;
|
|
22
|
+
error?: string;
|
|
23
|
+
logs?: string[];
|
|
24
|
+
duration?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Search options for the search method
|
|
28
|
+
*/
|
|
29
|
+
export interface SearchOptions {
|
|
30
|
+
collection?: string;
|
|
31
|
+
database?: string;
|
|
32
|
+
limit?: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Search result in OpenAI Deep Research format
|
|
36
|
+
*/
|
|
37
|
+
export interface SearchResult {
|
|
38
|
+
id: string;
|
|
39
|
+
title: string;
|
|
40
|
+
url: string;
|
|
41
|
+
text: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Fetch result with document metadata
|
|
45
|
+
*/
|
|
46
|
+
export interface FetchResult {
|
|
47
|
+
id: string;
|
|
48
|
+
title: string;
|
|
49
|
+
url: string;
|
|
50
|
+
text: string;
|
|
51
|
+
metadata: {
|
|
52
|
+
database: string;
|
|
53
|
+
collection: string;
|
|
54
|
+
_id: string;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* MCP server interface exposed by the agent
|
|
59
|
+
*/
|
|
60
|
+
export interface McpServerLike {
|
|
61
|
+
listTools(): Promise<{
|
|
62
|
+
name: string;
|
|
63
|
+
description: string;
|
|
64
|
+
}[]>;
|
|
65
|
+
callTool(name: string, args: Record<string, unknown>): Promise<McpToolResponse>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* File system interface exposed by the agent
|
|
69
|
+
*/
|
|
70
|
+
export interface FileSystemLike {
|
|
71
|
+
readFile(path: string): Promise<string>;
|
|
72
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
73
|
+
deleteFile(path: string): Promise<boolean>;
|
|
74
|
+
exists(path: string): Promise<boolean>;
|
|
75
|
+
stat(path: string): Promise<{
|
|
76
|
+
type: string;
|
|
77
|
+
size: number;
|
|
78
|
+
} | null>;
|
|
79
|
+
readdir(path: string): Promise<string[]>;
|
|
80
|
+
mkdir(path: string): Promise<void>;
|
|
81
|
+
glob(pattern: string): Promise<string[]>;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Key-Value store interface exposed by the agent
|
|
85
|
+
*/
|
|
86
|
+
export interface KVStoreLike {
|
|
87
|
+
get<T>(key: string): Promise<T | null>;
|
|
88
|
+
set<T>(key: string, value: T): Promise<void>;
|
|
89
|
+
delete(key: string): Promise<boolean>;
|
|
90
|
+
has(key: string): Promise<boolean>;
|
|
91
|
+
keys(prefix?: string): Promise<string[]>;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Audit log interface exposed by the agent
|
|
95
|
+
*/
|
|
96
|
+
export interface AuditLogLike {
|
|
97
|
+
record(tool: string, inputs: unknown, outputs: unknown, durationMs?: number): Promise<string>;
|
|
98
|
+
list(options?: {
|
|
99
|
+
limit?: number;
|
|
100
|
+
offset?: number;
|
|
101
|
+
tool?: string;
|
|
102
|
+
}): Promise<{
|
|
103
|
+
id: string;
|
|
104
|
+
tool: string;
|
|
105
|
+
timestamp: Date;
|
|
106
|
+
}[]>;
|
|
107
|
+
count(): Promise<number>;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Configuration for creating a MonDoAgent
|
|
111
|
+
*/
|
|
112
|
+
export interface MonDoAgentConfig {
|
|
113
|
+
/** Unique agent identifier */
|
|
114
|
+
id?: string;
|
|
115
|
+
/** Database access for MCP tools */
|
|
116
|
+
dbAccess: DatabaseAccess;
|
|
117
|
+
/** Optional code loader for 'do' tool */
|
|
118
|
+
codeLoader?: CodeLoader;
|
|
119
|
+
/** Optional custom filesystem database */
|
|
120
|
+
fsDatabase?: AgentFSDatabase;
|
|
121
|
+
/** Optional custom KV storage backend */
|
|
122
|
+
kvBackend?: KVStorageBackend;
|
|
123
|
+
/** Optional custom audit storage backend */
|
|
124
|
+
auditBackend?: AuditBackend;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* MonDoAgent - AI Agent interface for mongo.do
|
|
128
|
+
*/
|
|
129
|
+
export interface MonDoAgent {
|
|
130
|
+
/** Agent identifier */
|
|
131
|
+
readonly id: string;
|
|
132
|
+
/** Access to MCP server for tool handling */
|
|
133
|
+
readonly mcp: McpServerLike;
|
|
134
|
+
/** Access to virtual filesystem */
|
|
135
|
+
readonly fs: FileSystemLike;
|
|
136
|
+
/** Access to key-value store */
|
|
137
|
+
readonly kv: KVStoreLike;
|
|
138
|
+
/** Access to tool call audit log */
|
|
139
|
+
readonly audit: AuditLogLike;
|
|
140
|
+
/**
|
|
141
|
+
* Execute a tool by name with given arguments
|
|
142
|
+
*/
|
|
143
|
+
execute<T = unknown>(toolName: string, args: Record<string, unknown>): Promise<ExecutionResult<T>>;
|
|
144
|
+
/**
|
|
145
|
+
* Execute code in the secure sandbox
|
|
146
|
+
*/
|
|
147
|
+
do(code: string, description?: string): Promise<ExecutionResult<unknown>>;
|
|
148
|
+
/**
|
|
149
|
+
* Search for documents
|
|
150
|
+
*/
|
|
151
|
+
search(query: string, options?: SearchOptions): Promise<SearchResult[]>;
|
|
152
|
+
/**
|
|
153
|
+
* Fetch a document by ID
|
|
154
|
+
*/
|
|
155
|
+
fetch(id: string): Promise<FetchResult | null>;
|
|
156
|
+
/**
|
|
157
|
+
* Dispose agent resources
|
|
158
|
+
*/
|
|
159
|
+
dispose(): Promise<void>;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Create a new MonDoAgent instance
|
|
163
|
+
*
|
|
164
|
+
* @param config - Agent configuration
|
|
165
|
+
* @returns MonDoAgent instance
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* const agent = createMonDoAgent({
|
|
170
|
+
* dbAccess: myDatabaseAccess,
|
|
171
|
+
* codeLoader: myCodeLoader,
|
|
172
|
+
* });
|
|
173
|
+
*
|
|
174
|
+
* // Execute code
|
|
175
|
+
* const result = await agent.do('return await db.collection("users").count()');
|
|
176
|
+
*
|
|
177
|
+
* // Search documents
|
|
178
|
+
* const results = await agent.search('users with admin role');
|
|
179
|
+
*
|
|
180
|
+
* // Use filesystem
|
|
181
|
+
* await agent.fs.writeFile('/data/output.json', JSON.stringify(data));
|
|
182
|
+
*
|
|
183
|
+
* // Use KV store
|
|
184
|
+
* await agent.kv.set('session-state', { step: 1 });
|
|
185
|
+
*
|
|
186
|
+
* // Clean up
|
|
187
|
+
* await agent.dispose();
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
export declare function createMonDoAgent(config: MonDoAgentConfig): MonDoAgent;
|
|
191
|
+
export type { DatabaseAccess, CodeLoader, McpServerConfig };
|
|
192
|
+
//# sourceMappingURL=agent.d.ts.map
|