open-mcp-app 0.0.11 → 0.0.13
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/dist/core/index.d.ts +14 -1
- package/dist/core/index.js +61 -10
- package/dist/core/index.js.map +1 -1
- package/dist/react/index.js +61 -10
- package/dist/react/index.js.map +1 -1
- package/dist/server/index.d.ts +29 -408
- package/dist/server/index.js +29 -451
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -13377,7 +13377,7 @@ var StreamableHTTPServerTransport = class {
|
|
|
13377
13377
|
|
|
13378
13378
|
// src/server/app.ts
|
|
13379
13379
|
import express from "express";
|
|
13380
|
-
import { z as
|
|
13380
|
+
import { z as z2 } from "zod";
|
|
13381
13381
|
|
|
13382
13382
|
// src/server/types.ts
|
|
13383
13383
|
var MIME_TYPES = {
|
|
@@ -13617,153 +13617,15 @@ var WebSocketManager = class {
|
|
|
13617
13617
|
};
|
|
13618
13618
|
|
|
13619
13619
|
// src/server/storageRpc.ts
|
|
13620
|
-
import { z as z2 } from "zod";
|
|
13621
|
-
var STORAGE_METHODS = {
|
|
13622
|
-
KV_GET: "creature/storage/kv/get",
|
|
13623
|
-
KV_SET: "creature/storage/kv/set",
|
|
13624
|
-
KV_DELETE: "creature/storage/kv/delete",
|
|
13625
|
-
KV_LIST: "creature/storage/kv/list",
|
|
13626
|
-
KV_LIST_WITH_VALUES: "creature/storage/kv/listWithValues",
|
|
13627
|
-
KV_SEARCH: "creature/storage/kv/search",
|
|
13628
|
-
VECTOR_UPSERT: "creature/storage/vector/upsert",
|
|
13629
|
-
VECTOR_SEARCH: "creature/storage/vector/search",
|
|
13630
|
-
VECTOR_DELETE: "creature/storage/vector/delete",
|
|
13631
|
-
BLOB_PUT: "creature/storage/blob/put",
|
|
13632
|
-
BLOB_GET: "creature/storage/blob/get",
|
|
13633
|
-
BLOB_DELETE: "creature/storage/blob/delete",
|
|
13634
|
-
BLOB_LIST: "creature/storage/blob/list"
|
|
13635
|
-
};
|
|
13636
13620
|
var currentServer = null;
|
|
13637
|
-
var setCurrentServer = (
|
|
13621
|
+
var setCurrentServer = ({
|
|
13622
|
+
server
|
|
13623
|
+
}) => {
|
|
13638
13624
|
currentServer = server;
|
|
13639
13625
|
};
|
|
13640
13626
|
var getCurrentServer = () => {
|
|
13641
13627
|
return currentServer;
|
|
13642
13628
|
};
|
|
13643
|
-
var isStorageRpcAvailable = () => {
|
|
13644
|
-
const isCreature = !!process.env.CREATURE_PROJECT_ID;
|
|
13645
|
-
return isCreature && currentServer !== null;
|
|
13646
|
-
};
|
|
13647
|
-
var GenericResultSchema = z2.record(z2.unknown());
|
|
13648
|
-
var sendStorageRequest = async (method, params) => {
|
|
13649
|
-
if (!currentServer) {
|
|
13650
|
-
throw new Error(
|
|
13651
|
-
"Storage RPC not available: no server connection. Make sure you're calling this from within a tool handler."
|
|
13652
|
-
);
|
|
13653
|
-
}
|
|
13654
|
-
try {
|
|
13655
|
-
const server = currentServer.server;
|
|
13656
|
-
const result = await server.request(
|
|
13657
|
-
{ method, params },
|
|
13658
|
-
GenericResultSchema
|
|
13659
|
-
);
|
|
13660
|
-
return result;
|
|
13661
|
-
} catch (error) {
|
|
13662
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
13663
|
-
throw new Error(`Storage RPC failed (${method}): ${message}`);
|
|
13664
|
-
}
|
|
13665
|
-
};
|
|
13666
|
-
var rpcKvGet = async (key) => {
|
|
13667
|
-
const result = await sendStorageRequest(
|
|
13668
|
-
STORAGE_METHODS.KV_GET,
|
|
13669
|
-
{ key }
|
|
13670
|
-
);
|
|
13671
|
-
return result.value;
|
|
13672
|
-
};
|
|
13673
|
-
var rpcKvSet = async (key, value) => {
|
|
13674
|
-
const result = await sendStorageRequest(
|
|
13675
|
-
STORAGE_METHODS.KV_SET,
|
|
13676
|
-
{ key, value }
|
|
13677
|
-
);
|
|
13678
|
-
return result.success;
|
|
13679
|
-
};
|
|
13680
|
-
var rpcKvDelete = async (key) => {
|
|
13681
|
-
const result = await sendStorageRequest(
|
|
13682
|
-
STORAGE_METHODS.KV_DELETE,
|
|
13683
|
-
{ key }
|
|
13684
|
-
);
|
|
13685
|
-
return result.deleted;
|
|
13686
|
-
};
|
|
13687
|
-
var rpcKvList = async (prefix) => {
|
|
13688
|
-
const result = await sendStorageRequest(
|
|
13689
|
-
STORAGE_METHODS.KV_LIST,
|
|
13690
|
-
{ prefix }
|
|
13691
|
-
);
|
|
13692
|
-
return result.keys;
|
|
13693
|
-
};
|
|
13694
|
-
var rpcKvListWithValues = async (prefix) => {
|
|
13695
|
-
const result = await sendStorageRequest(
|
|
13696
|
-
STORAGE_METHODS.KV_LIST_WITH_VALUES,
|
|
13697
|
-
{ prefix }
|
|
13698
|
-
);
|
|
13699
|
-
return result.entries;
|
|
13700
|
-
};
|
|
13701
|
-
var rpcKvSearch = async (query, options) => {
|
|
13702
|
-
const result = await sendStorageRequest(
|
|
13703
|
-
STORAGE_METHODS.KV_SEARCH,
|
|
13704
|
-
{ query, prefix: options?.prefix, limit: options?.limit }
|
|
13705
|
-
);
|
|
13706
|
-
return result.matches;
|
|
13707
|
-
};
|
|
13708
|
-
var rpcVectorUpsert = async (key, text, metadata) => {
|
|
13709
|
-
const result = await sendStorageRequest(
|
|
13710
|
-
STORAGE_METHODS.VECTOR_UPSERT,
|
|
13711
|
-
{ key, text, metadata }
|
|
13712
|
-
);
|
|
13713
|
-
return result.success;
|
|
13714
|
-
};
|
|
13715
|
-
var rpcVectorSearch = async (query, options) => {
|
|
13716
|
-
const result = await sendStorageRequest(
|
|
13717
|
-
STORAGE_METHODS.VECTOR_SEARCH,
|
|
13718
|
-
{ query, prefix: options?.prefix, limit: options?.limit }
|
|
13719
|
-
);
|
|
13720
|
-
return result.matches;
|
|
13721
|
-
};
|
|
13722
|
-
var rpcVectorDelete = async (key) => {
|
|
13723
|
-
const result = await sendStorageRequest(
|
|
13724
|
-
STORAGE_METHODS.VECTOR_DELETE,
|
|
13725
|
-
{ key }
|
|
13726
|
-
);
|
|
13727
|
-
return result.deleted;
|
|
13728
|
-
};
|
|
13729
|
-
var rpcBlobPut = async (name, data, mimeType) => {
|
|
13730
|
-
const result = await sendStorageRequest(
|
|
13731
|
-
STORAGE_METHODS.BLOB_PUT,
|
|
13732
|
-
{
|
|
13733
|
-
name,
|
|
13734
|
-
data: Buffer.from(data).toString("base64"),
|
|
13735
|
-
mimeType
|
|
13736
|
-
}
|
|
13737
|
-
);
|
|
13738
|
-
return result;
|
|
13739
|
-
};
|
|
13740
|
-
var rpcBlobGet = async (name) => {
|
|
13741
|
-
const result = await sendStorageRequest(
|
|
13742
|
-
STORAGE_METHODS.BLOB_GET,
|
|
13743
|
-
{ name }
|
|
13744
|
-
);
|
|
13745
|
-
if (result.data === null) {
|
|
13746
|
-
return null;
|
|
13747
|
-
}
|
|
13748
|
-
return {
|
|
13749
|
-
data: Buffer.from(result.data, "base64"),
|
|
13750
|
-
mimeType: result.mimeType
|
|
13751
|
-
};
|
|
13752
|
-
};
|
|
13753
|
-
var rpcBlobDelete = async (name) => {
|
|
13754
|
-
const result = await sendStorageRequest(
|
|
13755
|
-
STORAGE_METHODS.BLOB_DELETE,
|
|
13756
|
-
{ name }
|
|
13757
|
-
);
|
|
13758
|
-
return result.deleted;
|
|
13759
|
-
};
|
|
13760
|
-
var rpcBlobList = async (prefix) => {
|
|
13761
|
-
const result = await sendStorageRequest(
|
|
13762
|
-
STORAGE_METHODS.BLOB_LIST,
|
|
13763
|
-
{ prefix }
|
|
13764
|
-
);
|
|
13765
|
-
return result.names;
|
|
13766
|
-
};
|
|
13767
13629
|
|
|
13768
13630
|
// src/server/app.ts
|
|
13769
13631
|
function createHttpLogSink(endpoint, sourceName) {
|
|
@@ -14123,8 +13985,9 @@ var App = class {
|
|
|
14123
13985
|
const toolMeta = this.buildToolMeta(config);
|
|
14124
13986
|
tools.push({
|
|
14125
13987
|
name,
|
|
14126
|
-
description: this.buildToolDescription(config, config.input ||
|
|
13988
|
+
description: this.buildToolDescription(config, config.input || z2.object({})),
|
|
14127
13989
|
inputSchema: config.input ? this.zodToJsonSchema(config.input) : { type: "object" },
|
|
13990
|
+
...config.annotations && { annotations: config.annotations },
|
|
14128
13991
|
...Object.keys(toolMeta).length > 0 && { _meta: toolMeta }
|
|
14129
13992
|
});
|
|
14130
13993
|
}
|
|
@@ -14155,7 +14018,7 @@ var App = class {
|
|
|
14155
14018
|
websocketUrl: void 0
|
|
14156
14019
|
};
|
|
14157
14020
|
const result = await handler(input, context);
|
|
14158
|
-
return { jsonrpc: "2.0", result: this.formatToolResult(result, instanceId), id };
|
|
14021
|
+
return { jsonrpc: "2.0", result: this.formatToolResult(result, instanceId, void 0, toolName), id };
|
|
14159
14022
|
}
|
|
14160
14023
|
if (method === "resources/list") {
|
|
14161
14024
|
const resources = [];
|
|
@@ -14313,17 +14176,19 @@ var App = class {
|
|
|
14313
14176
|
createExpressApp() {
|
|
14314
14177
|
const app = express();
|
|
14315
14178
|
app.use(express.json({ limit: "50mb" }));
|
|
14316
|
-
|
|
14317
|
-
|
|
14318
|
-
|
|
14319
|
-
|
|
14320
|
-
|
|
14321
|
-
|
|
14322
|
-
|
|
14323
|
-
|
|
14324
|
-
|
|
14325
|
-
|
|
14326
|
-
|
|
14179
|
+
if (this.config.cors !== false) {
|
|
14180
|
+
app.use((req, res, next) => {
|
|
14181
|
+
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
14182
|
+
res.setHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS");
|
|
14183
|
+
res.setHeader("Access-Control-Allow-Headers", "Content-Type, Accept, Mcp-Session-Id");
|
|
14184
|
+
res.setHeader("Access-Control-Expose-Headers", "Mcp-Session-Id");
|
|
14185
|
+
if (req.method === "OPTIONS") {
|
|
14186
|
+
res.status(204).end();
|
|
14187
|
+
return;
|
|
14188
|
+
}
|
|
14189
|
+
next();
|
|
14190
|
+
});
|
|
14191
|
+
}
|
|
14327
14192
|
if (this.config.middleware) {
|
|
14328
14193
|
this.config.middleware(app);
|
|
14329
14194
|
}
|
|
@@ -14371,7 +14236,7 @@ var App = class {
|
|
|
14371
14236
|
const server = this.createMcpServer();
|
|
14372
14237
|
await server.connect(transport);
|
|
14373
14238
|
this.serverByTransport.set(transport, server);
|
|
14374
|
-
setCurrentServer(server);
|
|
14239
|
+
setCurrentServer({ server });
|
|
14375
14240
|
await transport.handleRequest(req, res, req.body);
|
|
14376
14241
|
return;
|
|
14377
14242
|
} else {
|
|
@@ -14547,7 +14412,7 @@ var App = class {
|
|
|
14547
14412
|
registerTools(server) {
|
|
14548
14413
|
for (const [name, { config, handler }] of this.tools) {
|
|
14549
14414
|
const toolMeta = this.buildToolMeta(config);
|
|
14550
|
-
const baseSchema = config.input ||
|
|
14415
|
+
const baseSchema = config.input || z2.object({});
|
|
14551
14416
|
const inputSchema = "passthrough" in baseSchema && typeof baseSchema.passthrough === "function" ? baseSchema.passthrough() : baseSchema;
|
|
14552
14417
|
const description = this.buildToolDescription(config, baseSchema);
|
|
14553
14418
|
const hasUi = !!config.ui;
|
|
@@ -14556,6 +14421,7 @@ var App = class {
|
|
|
14556
14421
|
{
|
|
14557
14422
|
description,
|
|
14558
14423
|
inputSchema,
|
|
14424
|
+
...config.annotations && { annotations: config.annotations },
|
|
14559
14425
|
...Object.keys(toolMeta).length > 0 && { _meta: toolMeta }
|
|
14560
14426
|
},
|
|
14561
14427
|
async (args) => {
|
|
@@ -14616,7 +14482,7 @@ var App = class {
|
|
|
14616
14482
|
if (this.config.logToolCalls) {
|
|
14617
14483
|
this.sendLog("info", `Tool result: ${name} (${durationMs}ms)`, { event: "tool_result", tool: name, durationMs });
|
|
14618
14484
|
}
|
|
14619
|
-
return this.formatToolResult(result, instanceId, websocketUrl);
|
|
14485
|
+
return this.formatToolResult(result, instanceId, websocketUrl, name);
|
|
14620
14486
|
} catch (error) {
|
|
14621
14487
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
14622
14488
|
const durationMs = Date.now() - startMs;
|
|
@@ -14660,9 +14526,6 @@ var App = class {
|
|
|
14660
14526
|
if (config.experimental?.defaultDisplayMode) {
|
|
14661
14527
|
experimental.defaultDisplayMode = config.experimental.defaultDisplayMode;
|
|
14662
14528
|
}
|
|
14663
|
-
if (config.experimental?.openInBackground !== void 0) {
|
|
14664
|
-
experimental.openInBackground = config.experimental.openInBackground;
|
|
14665
|
-
}
|
|
14666
14529
|
toolMeta.ui = {
|
|
14667
14530
|
resourceUri: config.ui,
|
|
14668
14531
|
visibility,
|
|
@@ -14702,14 +14565,15 @@ var App = class {
|
|
|
14702
14565
|
*
|
|
14703
14566
|
* SDK manages instanceId and websocketUrl automatically.
|
|
14704
14567
|
*/
|
|
14705
|
-
formatToolResult(result, instanceId, websocketUrl) {
|
|
14568
|
+
formatToolResult(result, instanceId, websocketUrl, toolName) {
|
|
14706
14569
|
const text = result.text || JSON.stringify(result.data || {});
|
|
14707
14570
|
const structuredContent = {
|
|
14708
14571
|
...result.data,
|
|
14709
14572
|
...result.title && { title: result.title },
|
|
14710
14573
|
...result.inlineHeight && { inlineHeight: result.inlineHeight },
|
|
14711
14574
|
...instanceId && { instanceId },
|
|
14712
|
-
...websocketUrl && { websocketUrl }
|
|
14575
|
+
...websocketUrl && { websocketUrl },
|
|
14576
|
+
...toolName && { _toolName: toolName }
|
|
14713
14577
|
};
|
|
14714
14578
|
const meta = {};
|
|
14715
14579
|
if (instanceId) {
|
|
@@ -14869,7 +14733,7 @@ function wrapServer(server) {
|
|
|
14869
14733
|
import fs2 from "fs";
|
|
14870
14734
|
import fsPromises from "fs/promises";
|
|
14871
14735
|
import path3 from "path";
|
|
14872
|
-
import { z as
|
|
14736
|
+
import { z as z3 } from "zod";
|
|
14873
14737
|
var getStorageDir = () => {
|
|
14874
14738
|
const dir = process.env.CREATURE_MCP_STORAGE_DIR;
|
|
14875
14739
|
return dir && dir.length > 0 ? dir : null;
|
|
@@ -14967,235 +14831,6 @@ function experimental_rmdirSync(relativePath) {
|
|
|
14967
14831
|
const safePath = resolveSafePath(relativePath);
|
|
14968
14832
|
fs2.rmSync(safePath, { recursive: true, force: true });
|
|
14969
14833
|
}
|
|
14970
|
-
var MAX_KEY_LENGTH = 256;
|
|
14971
|
-
var MAX_VECTOR_TEXT_LENGTH = 2e4;
|
|
14972
|
-
var sanitizeKey = (key) => {
|
|
14973
|
-
if (!key || key.length === 0) {
|
|
14974
|
-
throw new Error("Key cannot be empty");
|
|
14975
|
-
}
|
|
14976
|
-
if (key.length > MAX_KEY_LENGTH) {
|
|
14977
|
-
throw new Error(`Key exceeds maximum length of ${MAX_KEY_LENGTH}`);
|
|
14978
|
-
}
|
|
14979
|
-
if (key.includes("..")) {
|
|
14980
|
-
throw new Error("Key cannot contain '..'");
|
|
14981
|
-
}
|
|
14982
|
-
if (path3.isAbsolute(key)) {
|
|
14983
|
-
throw new Error("Key cannot be an absolute path");
|
|
14984
|
-
}
|
|
14985
|
-
if (!/^[a-zA-Z0-9_\-./:]+$/.test(key)) {
|
|
14986
|
-
throw new Error("Key contains invalid characters");
|
|
14987
|
-
}
|
|
14988
|
-
return key;
|
|
14989
|
-
};
|
|
14990
|
-
function experimental_kvIsAvailable() {
|
|
14991
|
-
return isStorageRpcAvailable() || getStorageDir() !== null;
|
|
14992
|
-
}
|
|
14993
|
-
async function experimental_kvGet(key) {
|
|
14994
|
-
const sanitizedKey = sanitizeKey(key);
|
|
14995
|
-
if (isStorageRpcAvailable()) {
|
|
14996
|
-
try {
|
|
14997
|
-
return await rpcKvGet(sanitizedKey);
|
|
14998
|
-
} catch (error) {
|
|
14999
|
-
console.error("[KV] RPC error in kvGet:", error);
|
|
15000
|
-
return null;
|
|
15001
|
-
}
|
|
15002
|
-
}
|
|
15003
|
-
return null;
|
|
15004
|
-
}
|
|
15005
|
-
function experimental_kvGetSync(key) {
|
|
15006
|
-
console.warn("[KV] experimental_kvGetSync is deprecated. Use experimental_kvGet for cross-platform support.");
|
|
15007
|
-
return null;
|
|
15008
|
-
}
|
|
15009
|
-
async function experimental_kvSet(key, value) {
|
|
15010
|
-
const sanitizedKey = sanitizeKey(key);
|
|
15011
|
-
if (isStorageRpcAvailable()) {
|
|
15012
|
-
try {
|
|
15013
|
-
return await rpcKvSet(sanitizedKey, value);
|
|
15014
|
-
} catch (error) {
|
|
15015
|
-
console.error("[KV] RPC error in kvSet:", error);
|
|
15016
|
-
return false;
|
|
15017
|
-
}
|
|
15018
|
-
}
|
|
15019
|
-
return false;
|
|
15020
|
-
}
|
|
15021
|
-
function experimental_kvSetSync(key, value) {
|
|
15022
|
-
console.warn("[KV] experimental_kvSetSync is deprecated. Use experimental_kvSet for cross-platform support.");
|
|
15023
|
-
return false;
|
|
15024
|
-
}
|
|
15025
|
-
async function experimental_kvDelete(key) {
|
|
15026
|
-
const sanitizedKey = sanitizeKey(key);
|
|
15027
|
-
if (isStorageRpcAvailable()) {
|
|
15028
|
-
try {
|
|
15029
|
-
return await rpcKvDelete(sanitizedKey);
|
|
15030
|
-
} catch (error) {
|
|
15031
|
-
console.error("[KV] RPC error in kvDelete:", error);
|
|
15032
|
-
return false;
|
|
15033
|
-
}
|
|
15034
|
-
}
|
|
15035
|
-
return false;
|
|
15036
|
-
}
|
|
15037
|
-
function experimental_kvDeleteSync(key) {
|
|
15038
|
-
console.warn("[KV] experimental_kvDeleteSync is deprecated. Use experimental_kvDelete for cross-platform support.");
|
|
15039
|
-
return false;
|
|
15040
|
-
}
|
|
15041
|
-
async function experimental_kvList(prefix) {
|
|
15042
|
-
const sanitizedPrefix = prefix ? sanitizeKey(prefix) : void 0;
|
|
15043
|
-
if (isStorageRpcAvailable()) {
|
|
15044
|
-
try {
|
|
15045
|
-
return await rpcKvList(sanitizedPrefix);
|
|
15046
|
-
} catch (error) {
|
|
15047
|
-
console.error("[KV] RPC error in kvList:", error);
|
|
15048
|
-
return null;
|
|
15049
|
-
}
|
|
15050
|
-
}
|
|
15051
|
-
return null;
|
|
15052
|
-
}
|
|
15053
|
-
async function experimental_kvListWithValues(prefix) {
|
|
15054
|
-
const sanitizedPrefix = prefix ? sanitizeKey(prefix) : void 0;
|
|
15055
|
-
if (isStorageRpcAvailable()) {
|
|
15056
|
-
try {
|
|
15057
|
-
return await rpcKvListWithValues(sanitizedPrefix);
|
|
15058
|
-
} catch (error) {
|
|
15059
|
-
console.error("[KV] RPC error in kvListWithValues:", error);
|
|
15060
|
-
return null;
|
|
15061
|
-
}
|
|
15062
|
-
}
|
|
15063
|
-
return null;
|
|
15064
|
-
}
|
|
15065
|
-
function experimental_kvListSync(prefix) {
|
|
15066
|
-
console.warn("[KV] experimental_kvListSync is deprecated. Use experimental_kvList for cross-platform support.");
|
|
15067
|
-
return null;
|
|
15068
|
-
}
|
|
15069
|
-
async function experimental_kvSearch(query, options) {
|
|
15070
|
-
if (!query || query.trim().length === 0) {
|
|
15071
|
-
throw new Error("Search query cannot be empty");
|
|
15072
|
-
}
|
|
15073
|
-
const sanitizedPrefix = options?.prefix ? sanitizeKey(options.prefix) : void 0;
|
|
15074
|
-
if (isStorageRpcAvailable()) {
|
|
15075
|
-
try {
|
|
15076
|
-
return await rpcKvSearch(query, {
|
|
15077
|
-
prefix: sanitizedPrefix,
|
|
15078
|
-
limit: options?.limit
|
|
15079
|
-
});
|
|
15080
|
-
} catch (error) {
|
|
15081
|
-
console.error("[KV] RPC error in kvSearch:", error);
|
|
15082
|
-
return null;
|
|
15083
|
-
}
|
|
15084
|
-
}
|
|
15085
|
-
return null;
|
|
15086
|
-
}
|
|
15087
|
-
function experimental_vectorIsAvailable() {
|
|
15088
|
-
return isStorageRpcAvailable();
|
|
15089
|
-
}
|
|
15090
|
-
async function experimental_vectorUpsert(key, text, metadata) {
|
|
15091
|
-
const sanitizedKey = sanitizeKey(key);
|
|
15092
|
-
const trimmed = text.trim();
|
|
15093
|
-
if (!trimmed) {
|
|
15094
|
-
throw new Error("Text cannot be empty");
|
|
15095
|
-
}
|
|
15096
|
-
if (trimmed.length > MAX_VECTOR_TEXT_LENGTH) {
|
|
15097
|
-
throw new Error(`Text exceeds maximum length of ${MAX_VECTOR_TEXT_LENGTH}`);
|
|
15098
|
-
}
|
|
15099
|
-
if (!isStorageRpcAvailable()) {
|
|
15100
|
-
return false;
|
|
15101
|
-
}
|
|
15102
|
-
return rpcVectorUpsert(sanitizedKey, trimmed, metadata);
|
|
15103
|
-
}
|
|
15104
|
-
async function experimental_vectorSearch(query, options) {
|
|
15105
|
-
const trimmed = query.trim();
|
|
15106
|
-
if (!trimmed) {
|
|
15107
|
-
throw new Error("Search query cannot be empty");
|
|
15108
|
-
}
|
|
15109
|
-
if (trimmed.length > MAX_VECTOR_TEXT_LENGTH) {
|
|
15110
|
-
throw new Error(`Text exceeds maximum length of ${MAX_VECTOR_TEXT_LENGTH}`);
|
|
15111
|
-
}
|
|
15112
|
-
const sanitizedPrefix = options?.prefix ? sanitizeKey(options.prefix) : void 0;
|
|
15113
|
-
if (!isStorageRpcAvailable()) {
|
|
15114
|
-
return null;
|
|
15115
|
-
}
|
|
15116
|
-
return rpcVectorSearch(trimmed, {
|
|
15117
|
-
prefix: sanitizedPrefix,
|
|
15118
|
-
limit: options?.limit
|
|
15119
|
-
});
|
|
15120
|
-
}
|
|
15121
|
-
async function experimental_vectorDelete(key) {
|
|
15122
|
-
const sanitizedKey = sanitizeKey(key);
|
|
15123
|
-
if (!isStorageRpcAvailable()) {
|
|
15124
|
-
return false;
|
|
15125
|
-
}
|
|
15126
|
-
return rpcVectorDelete(sanitizedKey);
|
|
15127
|
-
}
|
|
15128
|
-
var MAX_BLOB_SIZE = 10 * 1024 * 1024;
|
|
15129
|
-
function experimental_blobIsAvailable() {
|
|
15130
|
-
return isStorageRpcAvailable() || getStorageDir() !== null;
|
|
15131
|
-
}
|
|
15132
|
-
async function experimental_blobPut(name, data, mimeType) {
|
|
15133
|
-
const sanitizedName = sanitizeKey(name);
|
|
15134
|
-
if (data.length > MAX_BLOB_SIZE) {
|
|
15135
|
-
throw new Error(`Blob exceeds maximum size of ${MAX_BLOB_SIZE} bytes`);
|
|
15136
|
-
}
|
|
15137
|
-
if (isStorageRpcAvailable()) {
|
|
15138
|
-
try {
|
|
15139
|
-
return await rpcBlobPut(sanitizedName, data, mimeType);
|
|
15140
|
-
} catch (error) {
|
|
15141
|
-
console.error("[Blob] RPC error in blobPut:", error);
|
|
15142
|
-
return null;
|
|
15143
|
-
}
|
|
15144
|
-
}
|
|
15145
|
-
return null;
|
|
15146
|
-
}
|
|
15147
|
-
function experimental_blobPutSync(name, data, mimeType) {
|
|
15148
|
-
console.warn("[Blob] experimental_blobPutSync is deprecated. Use experimental_blobPut for cross-platform support.");
|
|
15149
|
-
return null;
|
|
15150
|
-
}
|
|
15151
|
-
async function experimental_blobGet(name) {
|
|
15152
|
-
const sanitizedName = sanitizeKey(name);
|
|
15153
|
-
if (isStorageRpcAvailable()) {
|
|
15154
|
-
try {
|
|
15155
|
-
return await rpcBlobGet(sanitizedName);
|
|
15156
|
-
} catch (error) {
|
|
15157
|
-
console.error("[Blob] RPC error in blobGet:", error);
|
|
15158
|
-
return null;
|
|
15159
|
-
}
|
|
15160
|
-
}
|
|
15161
|
-
return null;
|
|
15162
|
-
}
|
|
15163
|
-
function experimental_blobGetSync(name) {
|
|
15164
|
-
console.warn("[Blob] experimental_blobGetSync is deprecated. Use experimental_blobGet for cross-platform support.");
|
|
15165
|
-
return null;
|
|
15166
|
-
}
|
|
15167
|
-
async function experimental_blobDelete(name) {
|
|
15168
|
-
const sanitizedName = sanitizeKey(name);
|
|
15169
|
-
if (isStorageRpcAvailable()) {
|
|
15170
|
-
try {
|
|
15171
|
-
return await rpcBlobDelete(sanitizedName);
|
|
15172
|
-
} catch (error) {
|
|
15173
|
-
console.error("[Blob] RPC error in blobDelete:", error);
|
|
15174
|
-
return false;
|
|
15175
|
-
}
|
|
15176
|
-
}
|
|
15177
|
-
return false;
|
|
15178
|
-
}
|
|
15179
|
-
function experimental_blobDeleteSync(name) {
|
|
15180
|
-
console.warn("[Blob] experimental_blobDeleteSync is deprecated. Use experimental_blobDelete for cross-platform support.");
|
|
15181
|
-
return false;
|
|
15182
|
-
}
|
|
15183
|
-
async function experimental_blobList(prefix) {
|
|
15184
|
-
const sanitizedPrefix = prefix ? sanitizeKey(prefix) : void 0;
|
|
15185
|
-
if (isStorageRpcAvailable()) {
|
|
15186
|
-
try {
|
|
15187
|
-
return await rpcBlobList(sanitizedPrefix);
|
|
15188
|
-
} catch (error) {
|
|
15189
|
-
console.error("[Blob] RPC error in blobList:", error);
|
|
15190
|
-
return null;
|
|
15191
|
-
}
|
|
15192
|
-
}
|
|
15193
|
-
return null;
|
|
15194
|
-
}
|
|
15195
|
-
function experimental_blobListSync(prefix) {
|
|
15196
|
-
console.warn("[Blob] experimental_blobListSync is deprecated. Use experimental_blobList for cross-platform support.");
|
|
15197
|
-
return null;
|
|
15198
|
-
}
|
|
15199
14834
|
async function experimental_sampleMessage(params) {
|
|
15200
14835
|
const server = getCurrentServer();
|
|
15201
14836
|
if (!server) {
|
|
@@ -15203,7 +14838,7 @@ async function experimental_sampleMessage(params) {
|
|
|
15203
14838
|
}
|
|
15204
14839
|
const rawResult = await server.server.request(
|
|
15205
14840
|
{ method: "sampling/createMessage", params },
|
|
15206
|
-
|
|
14841
|
+
z3.record(z3.unknown())
|
|
15207
14842
|
);
|
|
15208
14843
|
const result = rawResult;
|
|
15209
14844
|
const content = result.content;
|
|
@@ -15248,40 +14883,6 @@ var exp = {
|
|
|
15248
14883
|
mkdirSync: experimental_mkdirSync,
|
|
15249
14884
|
readdirSync: experimental_readdirSync,
|
|
15250
14885
|
rmdirSync: experimental_rmdirSync,
|
|
15251
|
-
// KV Store
|
|
15252
|
-
kvIsAvailable: experimental_kvIsAvailable,
|
|
15253
|
-
kvGet: experimental_kvGet,
|
|
15254
|
-
kvSet: experimental_kvSet,
|
|
15255
|
-
kvDelete: experimental_kvDelete,
|
|
15256
|
-
kvList: experimental_kvList,
|
|
15257
|
-
kvListWithValues: experimental_kvListWithValues,
|
|
15258
|
-
kvSearch: experimental_kvSearch,
|
|
15259
|
-
vectorIsAvailable: experimental_vectorIsAvailable,
|
|
15260
|
-
vectorUpsert: experimental_vectorUpsert,
|
|
15261
|
-
vectorSearch: experimental_vectorSearch,
|
|
15262
|
-
vectorDelete: experimental_vectorDelete,
|
|
15263
|
-
/** @deprecated Use kvGet instead */
|
|
15264
|
-
kvGetSync: experimental_kvGetSync,
|
|
15265
|
-
/** @deprecated Use kvSet instead */
|
|
15266
|
-
kvSetSync: experimental_kvSetSync,
|
|
15267
|
-
/** @deprecated Use kvDelete instead */
|
|
15268
|
-
kvDeleteSync: experimental_kvDeleteSync,
|
|
15269
|
-
/** @deprecated Use kvList instead */
|
|
15270
|
-
kvListSync: experimental_kvListSync,
|
|
15271
|
-
// Blob Store
|
|
15272
|
-
blobIsAvailable: experimental_blobIsAvailable,
|
|
15273
|
-
blobPut: experimental_blobPut,
|
|
15274
|
-
blobGet: experimental_blobGet,
|
|
15275
|
-
blobDelete: experimental_blobDelete,
|
|
15276
|
-
blobList: experimental_blobList,
|
|
15277
|
-
/** @deprecated Use blobPut instead */
|
|
15278
|
-
blobPutSync: experimental_blobPutSync,
|
|
15279
|
-
/** @deprecated Use blobGet instead */
|
|
15280
|
-
blobGetSync: experimental_blobGetSync,
|
|
15281
|
-
/** @deprecated Use blobDelete instead */
|
|
15282
|
-
blobDeleteSync: experimental_blobDeleteSync,
|
|
15283
|
-
/** @deprecated Use blobList instead */
|
|
15284
|
-
blobListSync: experimental_blobListSync,
|
|
15285
14886
|
sampleMessage: experimental_sampleMessage
|
|
15286
14887
|
};
|
|
15287
14888
|
export {
|
|
@@ -15289,15 +14890,6 @@ export {
|
|
|
15289
14890
|
MIME_TYPES,
|
|
15290
14891
|
createApp,
|
|
15291
14892
|
exp,
|
|
15292
|
-
experimental_blobDelete,
|
|
15293
|
-
experimental_blobDeleteSync,
|
|
15294
|
-
experimental_blobGet,
|
|
15295
|
-
experimental_blobGetSync,
|
|
15296
|
-
experimental_blobIsAvailable,
|
|
15297
|
-
experimental_blobList,
|
|
15298
|
-
experimental_blobListSync,
|
|
15299
|
-
experimental_blobPut,
|
|
15300
|
-
experimental_blobPutSync,
|
|
15301
14893
|
experimental_deleteFile,
|
|
15302
14894
|
experimental_deleteFileSync,
|
|
15303
14895
|
experimental_exists,
|
|
@@ -15305,16 +14897,6 @@ export {
|
|
|
15305
14897
|
experimental_getProjectId,
|
|
15306
14898
|
experimental_getServerName,
|
|
15307
14899
|
experimental_getWritableDirectory,
|
|
15308
|
-
experimental_kvDelete,
|
|
15309
|
-
experimental_kvDeleteSync,
|
|
15310
|
-
experimental_kvGet,
|
|
15311
|
-
experimental_kvGetSync,
|
|
15312
|
-
experimental_kvIsAvailable,
|
|
15313
|
-
experimental_kvList,
|
|
15314
|
-
experimental_kvListSync,
|
|
15315
|
-
experimental_kvSearch,
|
|
15316
|
-
experimental_kvSet,
|
|
15317
|
-
experimental_kvSetSync,
|
|
15318
14900
|
experimental_mkdir,
|
|
15319
14901
|
experimental_mkdirSync,
|
|
15320
14902
|
experimental_readFile,
|
|
@@ -15324,10 +14906,6 @@ export {
|
|
|
15324
14906
|
experimental_rmdir,
|
|
15325
14907
|
experimental_rmdirSync,
|
|
15326
14908
|
experimental_sampleMessage,
|
|
15327
|
-
experimental_vectorDelete,
|
|
15328
|
-
experimental_vectorIsAvailable,
|
|
15329
|
-
experimental_vectorSearch,
|
|
15330
|
-
experimental_vectorUpsert,
|
|
15331
14909
|
experimental_writeFile,
|
|
15332
14910
|
experimental_writeFileSync,
|
|
15333
14911
|
htmlLoader,
|