@anuma/sdk 6.26.2 → 6.27.1
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/expo/index.cjs +223 -216
- package/dist/expo/index.d.mts +29 -1
- package/dist/expo/index.d.ts +29 -1
- package/dist/expo/index.mjs +220 -216
- package/dist/react/index.cjs +153 -110
- package/dist/react/index.mjs +151 -110
- package/dist/server/index.cjs +66 -1
- package/dist/server/index.mjs +66 -1
- package/dist/tools/index.cjs +1191 -1204
- package/dist/tools/index.d.mts +27 -47
- package/dist/tools/index.d.ts +27 -47
- package/dist/tools/index.mjs +1190 -1204
- package/package.json +1 -1
package/dist/expo/index.mjs
CHANGED
|
@@ -3937,6 +3937,34 @@ function createWebSearchPreProcessor(options = {}) {
|
|
|
3937
3937
|
};
|
|
3938
3938
|
}
|
|
3939
3939
|
|
|
3940
|
+
// src/lib/storage/mcpImages.ts
|
|
3941
|
+
var IMAGE_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
3942
|
+
"AnumaMediaMCP-anuma_create_image",
|
|
3943
|
+
"anuma_create_image",
|
|
3944
|
+
// Deprecated anuma-image-mcp tools, retained so images in already-stored
|
|
3945
|
+
// conversations still re-materialize on replay.
|
|
3946
|
+
"AnumaImageMCP-generate_cloud_image",
|
|
3947
|
+
"AnumaImageMCP-edit_cloud_image",
|
|
3948
|
+
"generate_cloud_image",
|
|
3949
|
+
"edit_cloud_image"
|
|
3950
|
+
]);
|
|
3951
|
+
function toolOutputForModel(name, output) {
|
|
3952
|
+
if (!name || !IMAGE_TOOL_NAMES.has(name)) return output;
|
|
3953
|
+
try {
|
|
3954
|
+
const {
|
|
3955
|
+
imageUrl: _imageUrl,
|
|
3956
|
+
url: _url,
|
|
3957
|
+
output_images: _outputImages,
|
|
3958
|
+
...rest
|
|
3959
|
+
} = JSON.parse(output);
|
|
3960
|
+
return JSON.stringify(rest);
|
|
3961
|
+
} catch {
|
|
3962
|
+
return output;
|
|
3963
|
+
}
|
|
3964
|
+
}
|
|
3965
|
+
var VIDEO_EXTENSIONS = ["mp4", "webm", "mov"];
|
|
3966
|
+
var VIDEO_EXTENSION_RE = new RegExp(`\\.(${VIDEO_EXTENSIONS.join("|")})(?:[?#]|$)`, "i");
|
|
3967
|
+
|
|
3940
3968
|
// src/lib/chat/runHooks.ts
|
|
3941
3969
|
function composeHooks(hooks) {
|
|
3942
3970
|
const handlers = hooks.filter((h) => h !== void 0 && h !== null);
|
|
@@ -6067,6 +6095,40 @@ function extractLastUserText(messages) {
|
|
|
6067
6095
|
function isToolErrorResult(result) {
|
|
6068
6096
|
return result !== null && typeof result === "object" && "error" in result && typeof result.error === "string";
|
|
6069
6097
|
}
|
|
6098
|
+
function serverToolCallMessages(events, messages, skipIds) {
|
|
6099
|
+
const seen = new Set(skipIds);
|
|
6100
|
+
for (const m of messages) {
|
|
6101
|
+
if (m.tool_call_id) seen.add(m.tool_call_id);
|
|
6102
|
+
for (const tc of m.tool_calls ?? []) if (tc.id) seen.add(tc.id);
|
|
6103
|
+
}
|
|
6104
|
+
const executed = [];
|
|
6105
|
+
for (const event of events ?? []) {
|
|
6106
|
+
if (!event.id || event.output === void 0 || event.output === null || seen.has(event.id)) {
|
|
6107
|
+
continue;
|
|
6108
|
+
}
|
|
6109
|
+
seen.add(event.id);
|
|
6110
|
+
executed.push(event);
|
|
6111
|
+
}
|
|
6112
|
+
if (executed.length === 0) return [];
|
|
6113
|
+
return [
|
|
6114
|
+
{
|
|
6115
|
+
role: "assistant",
|
|
6116
|
+
content: void 0,
|
|
6117
|
+
tool_calls: executed.map((event) => ({
|
|
6118
|
+
id: event.id,
|
|
6119
|
+
type: "function",
|
|
6120
|
+
function: { name: event.name, arguments: event.arguments }
|
|
6121
|
+
}))
|
|
6122
|
+
},
|
|
6123
|
+
...executed.map(
|
|
6124
|
+
(event) => ({
|
|
6125
|
+
role: "tool",
|
|
6126
|
+
tool_call_id: event.id,
|
|
6127
|
+
content: [{ type: "text", text: toolOutputForModel(event.name, event.output ?? "") }]
|
|
6128
|
+
})
|
|
6129
|
+
)
|
|
6130
|
+
];
|
|
6131
|
+
}
|
|
6070
6132
|
function getToolName(tool) {
|
|
6071
6133
|
const func = tool.function;
|
|
6072
6134
|
const nestedName = func?.name;
|
|
@@ -6836,7 +6898,14 @@ Executing tool: ${toolInfo}
|
|
|
6836
6898
|
}
|
|
6837
6899
|
}))
|
|
6838
6900
|
};
|
|
6839
|
-
const toolResultMessages = [
|
|
6901
|
+
const toolResultMessages = [
|
|
6902
|
+
...serverToolCallMessages(
|
|
6903
|
+
currentAccumulator.toolCallEvents,
|
|
6904
|
+
currentMessages,
|
|
6905
|
+
new Set(toolCallsToExecute.map((tc) => tc.id))
|
|
6906
|
+
),
|
|
6907
|
+
assistantMessage
|
|
6908
|
+
];
|
|
6840
6909
|
for (const execResult of continueResults) {
|
|
6841
6910
|
const resultContent = execResult.error ? `Error: ${execResult.error}` : safeJsonStringify(execResult.result);
|
|
6842
6911
|
toolResultMessages.push({
|
|
@@ -9019,20 +9088,6 @@ function generateMediaId() {
|
|
|
9019
9088
|
// src/lib/db/media/operations.ts
|
|
9020
9089
|
import { Q as Q3 } from "@nozbe/watermelondb";
|
|
9021
9090
|
|
|
9022
|
-
// src/lib/storage/mcpImages.ts
|
|
9023
|
-
var IMAGE_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
9024
|
-
"AnumaMediaMCP-anuma_create_image",
|
|
9025
|
-
"anuma_create_image",
|
|
9026
|
-
// Deprecated anuma-image-mcp tools, retained so images in already-stored
|
|
9027
|
-
// conversations still re-materialize on replay.
|
|
9028
|
-
"AnumaImageMCP-generate_cloud_image",
|
|
9029
|
-
"AnumaImageMCP-edit_cloud_image",
|
|
9030
|
-
"generate_cloud_image",
|
|
9031
|
-
"edit_cloud_image"
|
|
9032
|
-
]);
|
|
9033
|
-
var VIDEO_EXTENSIONS = ["mp4", "webm", "mov"];
|
|
9034
|
-
var VIDEO_EXTENSION_RE = new RegExp(`\\.(${VIDEO_EXTENSIONS.join("|")})(?:[?#]|$)`, "i");
|
|
9035
|
-
|
|
9036
9091
|
// src/lib/storage/opfs.ts
|
|
9037
9092
|
function isOPFSSupported() {
|
|
9038
9093
|
return typeof navigator !== "undefined" && "storage" in navigator && "getDirectory" in navigator.storage;
|
|
@@ -19522,24 +19577,10 @@ function storedToLlmapiMessage(stored) {
|
|
|
19522
19577
|
});
|
|
19523
19578
|
for (const event of stored.toolCallEvents) {
|
|
19524
19579
|
if (event.id && event.output !== void 0 && event.output !== null) {
|
|
19525
|
-
let toolOutput = event.output;
|
|
19526
|
-
if (event.name && IMAGE_TOOL_NAMES.has(event.name)) {
|
|
19527
|
-
try {
|
|
19528
|
-
const parsed = JSON.parse(toolOutput);
|
|
19529
|
-
const {
|
|
19530
|
-
imageUrl: _imageUrl,
|
|
19531
|
-
url: _url,
|
|
19532
|
-
output_images: _outputImages,
|
|
19533
|
-
...rest
|
|
19534
|
-
} = parsed;
|
|
19535
|
-
toolOutput = JSON.stringify(rest);
|
|
19536
|
-
} catch {
|
|
19537
|
-
}
|
|
19538
|
-
}
|
|
19539
19580
|
messages.push({
|
|
19540
19581
|
role: "tool",
|
|
19541
19582
|
tool_call_id: event.id,
|
|
19542
|
-
content: [{ type: "text", text:
|
|
19583
|
+
content: [{ type: "text", text: toolOutputForModel(event.name, event.output) }]
|
|
19543
19584
|
});
|
|
19544
19585
|
}
|
|
19545
19586
|
}
|
|
@@ -23178,6 +23219,19 @@ async function refreshNotionAccessToken(params) {
|
|
|
23178
23219
|
return result;
|
|
23179
23220
|
}
|
|
23180
23221
|
|
|
23222
|
+
// src/lib/connectors/errors.ts
|
|
23223
|
+
function buildConnectorErrorResult(code, provider, connectUrl, extras) {
|
|
23224
|
+
const payload = {
|
|
23225
|
+
__anuma_connector_error_v1: true,
|
|
23226
|
+
code,
|
|
23227
|
+
provider,
|
|
23228
|
+
connect_url: connectUrl,
|
|
23229
|
+
missing_scopes: extras?.missingScopes,
|
|
23230
|
+
required: extras?.required
|
|
23231
|
+
};
|
|
23232
|
+
return JSON.stringify(payload);
|
|
23233
|
+
}
|
|
23234
|
+
|
|
23181
23235
|
// src/tools/notion.ts
|
|
23182
23236
|
var MCP_HTTP_ENDPOINT = "https://mcp.notion.com/mcp";
|
|
23183
23237
|
var MAX_CONTENT_LENGTH2 = 5e4;
|
|
@@ -23350,8 +23404,83 @@ async function callMCPTool(accessToken, toolName, args) {
|
|
|
23350
23404
|
}
|
|
23351
23405
|
return truncateToolResult(jsonRpcResponse.result);
|
|
23352
23406
|
}
|
|
23353
|
-
|
|
23407
|
+
var NOTION_PROVIDER = "notion";
|
|
23408
|
+
function directRunner(getAccessToken, requestNotionAccess) {
|
|
23409
|
+
return async (toolName, args) => {
|
|
23410
|
+
let token = getAccessToken();
|
|
23411
|
+
if (!token) {
|
|
23412
|
+
token = await requestNotionAccess();
|
|
23413
|
+
}
|
|
23414
|
+
return callMCPTool(token, toolName, args);
|
|
23415
|
+
};
|
|
23416
|
+
}
|
|
23417
|
+
function readField(json4, key) {
|
|
23418
|
+
return typeof json4 === "object" && json4 !== null ? json4[key] : void 0;
|
|
23419
|
+
}
|
|
23420
|
+
function readString(json4, key) {
|
|
23421
|
+
const value = readField(json4, key);
|
|
23422
|
+
return typeof value === "string" ? value : void 0;
|
|
23423
|
+
}
|
|
23424
|
+
function notionConnectorError(status, json4) {
|
|
23425
|
+
const code = readField(json4, "code");
|
|
23426
|
+
if (status === 503) {
|
|
23427
|
+
return code === "upstream_unavailable" ? buildConnectorErrorResult("upstream_unavailable", NOTION_PROVIDER) : null;
|
|
23428
|
+
}
|
|
23429
|
+
if (status !== 401 && status !== 403 && status !== 412) return null;
|
|
23430
|
+
switch (code) {
|
|
23431
|
+
case "scope_not_covered": {
|
|
23432
|
+
const missingScopes = readField(json4, "missing_scopes");
|
|
23433
|
+
return buildConnectorErrorResult(
|
|
23434
|
+
"scope_not_covered",
|
|
23435
|
+
NOTION_PROVIDER,
|
|
23436
|
+
readString(json4, "connect_url"),
|
|
23437
|
+
Array.isArray(missingScopes) ? { missingScopes } : void 0
|
|
23438
|
+
);
|
|
23439
|
+
}
|
|
23440
|
+
case "insufficient_scope":
|
|
23441
|
+
return buildConnectorErrorResult("insufficient_scope", NOTION_PROVIDER, void 0, {
|
|
23442
|
+
required: readString(json4, "required")
|
|
23443
|
+
});
|
|
23444
|
+
case "upstream_unavailable":
|
|
23445
|
+
return buildConnectorErrorResult("upstream_unavailable", NOTION_PROVIDER);
|
|
23446
|
+
default:
|
|
23447
|
+
return buildConnectorErrorResult(
|
|
23448
|
+
"connector_not_connected",
|
|
23449
|
+
NOTION_PROVIDER,
|
|
23450
|
+
readString(json4, "connect_url")
|
|
23451
|
+
);
|
|
23452
|
+
}
|
|
23453
|
+
}
|
|
23454
|
+
function proxyRunner(callMcp) {
|
|
23455
|
+
return async (toolName, args) => {
|
|
23456
|
+
const { status, json: json4 } = await callMcp(toolName, args);
|
|
23457
|
+
if (status >= 200 && status < 300) {
|
|
23458
|
+
const result = readField(json4, "result");
|
|
23459
|
+
if (result === void 0) {
|
|
23460
|
+
throw new Error(`Notion returned no result (${status})`);
|
|
23461
|
+
}
|
|
23462
|
+
return truncateToolResult(result);
|
|
23463
|
+
}
|
|
23464
|
+
const connectorError = notionConnectorError(status, json4);
|
|
23465
|
+
if (connectorError) return connectorError;
|
|
23466
|
+
const message = readField(json4, "error");
|
|
23467
|
+
throw new Error(`${typeof message === "string" ? message : JSON.stringify(json4)} (${status})`);
|
|
23468
|
+
};
|
|
23469
|
+
}
|
|
23470
|
+
function withNotionExecutor(run, errorPrefix, tool) {
|
|
23354
23471
|
return {
|
|
23472
|
+
...tool,
|
|
23473
|
+
executor: async (args) => {
|
|
23474
|
+
try {
|
|
23475
|
+
return await run(tool.function.name, args);
|
|
23476
|
+
} catch (error) {
|
|
23477
|
+
return `${errorPrefix}: ${error instanceof Error ? error.message : String(error)}`;
|
|
23478
|
+
}
|
|
23479
|
+
}
|
|
23480
|
+
};
|
|
23481
|
+
}
|
|
23482
|
+
function notionSearchTool(run) {
|
|
23483
|
+
return withNotionExecutor(run, "Error searching Notion", {
|
|
23355
23484
|
type: "function",
|
|
23356
23485
|
function: {
|
|
23357
23486
|
name: "notion-search",
|
|
@@ -23392,22 +23521,11 @@ function createNotionSearchTool(getAccessToken, requestNotionAccess) {
|
|
|
23392
23521
|
},
|
|
23393
23522
|
required: ["query"]
|
|
23394
23523
|
}
|
|
23395
|
-
},
|
|
23396
|
-
executor: async (args) => {
|
|
23397
|
-
let token = getAccessToken();
|
|
23398
|
-
if (!token) {
|
|
23399
|
-
token = await requestNotionAccess();
|
|
23400
|
-
}
|
|
23401
|
-
try {
|
|
23402
|
-
return await callMCPTool(token, "notion-search", args);
|
|
23403
|
-
} catch (error) {
|
|
23404
|
-
return `Error searching Notion: ${error instanceof Error ? error.message : String(error)}`;
|
|
23405
|
-
}
|
|
23406
23524
|
}
|
|
23407
|
-
};
|
|
23525
|
+
});
|
|
23408
23526
|
}
|
|
23409
|
-
function
|
|
23410
|
-
return {
|
|
23527
|
+
function notionFetchTool(run) {
|
|
23528
|
+
return withNotionExecutor(run, "Error fetching Notion page", {
|
|
23411
23529
|
type: "function",
|
|
23412
23530
|
function: {
|
|
23413
23531
|
name: "notion-fetch",
|
|
@@ -23430,22 +23548,11 @@ function createNotionFetchTool(getAccessToken, requestNotionAccess) {
|
|
|
23430
23548
|
},
|
|
23431
23549
|
required: ["id"]
|
|
23432
23550
|
}
|
|
23433
|
-
},
|
|
23434
|
-
executor: async (args) => {
|
|
23435
|
-
let token = getAccessToken();
|
|
23436
|
-
if (!token) {
|
|
23437
|
-
token = await requestNotionAccess();
|
|
23438
|
-
}
|
|
23439
|
-
try {
|
|
23440
|
-
return await callMCPTool(token, "notion-fetch", args);
|
|
23441
|
-
} catch (error) {
|
|
23442
|
-
return `Error fetching Notion page: ${error instanceof Error ? error.message : String(error)}`;
|
|
23443
|
-
}
|
|
23444
23551
|
}
|
|
23445
|
-
};
|
|
23552
|
+
});
|
|
23446
23553
|
}
|
|
23447
|
-
function
|
|
23448
|
-
return {
|
|
23554
|
+
function notionCreatePagesTool(run) {
|
|
23555
|
+
return withNotionExecutor(run, "Error creating Notion page", {
|
|
23449
23556
|
type: "function",
|
|
23450
23557
|
function: {
|
|
23451
23558
|
name: "notion-create-pages",
|
|
@@ -23478,22 +23585,11 @@ function createNotionCreatePagesTool(getAccessToken, requestNotionAccess) {
|
|
|
23478
23585
|
},
|
|
23479
23586
|
required: ["pages"]
|
|
23480
23587
|
}
|
|
23481
|
-
},
|
|
23482
|
-
executor: async (args) => {
|
|
23483
|
-
let token = getAccessToken();
|
|
23484
|
-
if (!token) {
|
|
23485
|
-
token = await requestNotionAccess();
|
|
23486
|
-
}
|
|
23487
|
-
try {
|
|
23488
|
-
return await callMCPTool(token, "notion-create-pages", args);
|
|
23489
|
-
} catch (error) {
|
|
23490
|
-
return `Error creating Notion page: ${error instanceof Error ? error.message : String(error)}`;
|
|
23491
|
-
}
|
|
23492
23588
|
}
|
|
23493
|
-
};
|
|
23589
|
+
});
|
|
23494
23590
|
}
|
|
23495
|
-
function
|
|
23496
|
-
return {
|
|
23591
|
+
function notionUpdatePageTool(run) {
|
|
23592
|
+
return withNotionExecutor(run, "Error updating Notion page", {
|
|
23497
23593
|
type: "function",
|
|
23498
23594
|
function: {
|
|
23499
23595
|
name: "notion-update-page",
|
|
@@ -23541,22 +23637,11 @@ function createNotionUpdatePageTool(getAccessToken, requestNotionAccess) {
|
|
|
23541
23637
|
},
|
|
23542
23638
|
required: ["data"]
|
|
23543
23639
|
}
|
|
23544
|
-
},
|
|
23545
|
-
executor: async (args) => {
|
|
23546
|
-
let token = getAccessToken();
|
|
23547
|
-
if (!token) {
|
|
23548
|
-
token = await requestNotionAccess();
|
|
23549
|
-
}
|
|
23550
|
-
try {
|
|
23551
|
-
return await callMCPTool(token, "notion-update-page", args);
|
|
23552
|
-
} catch (error) {
|
|
23553
|
-
return `Error updating Notion page: ${error instanceof Error ? error.message : String(error)}`;
|
|
23554
|
-
}
|
|
23555
23640
|
}
|
|
23556
|
-
};
|
|
23641
|
+
});
|
|
23557
23642
|
}
|
|
23558
|
-
function
|
|
23559
|
-
return {
|
|
23643
|
+
function notionMovePagesTool(run) {
|
|
23644
|
+
return withNotionExecutor(run, "Error moving Notion pages", {
|
|
23560
23645
|
type: "function",
|
|
23561
23646
|
function: {
|
|
23562
23647
|
name: "notion-move-pages",
|
|
@@ -23576,22 +23661,11 @@ function createNotionMovePagesTool(getAccessToken, requestNotionAccess) {
|
|
|
23576
23661
|
},
|
|
23577
23662
|
required: ["page_or_database_ids", "new_parent"]
|
|
23578
23663
|
}
|
|
23579
|
-
},
|
|
23580
|
-
executor: async (args) => {
|
|
23581
|
-
let token = getAccessToken();
|
|
23582
|
-
if (!token) {
|
|
23583
|
-
token = await requestNotionAccess();
|
|
23584
|
-
}
|
|
23585
|
-
try {
|
|
23586
|
-
return await callMCPTool(token, "notion-move-pages", args);
|
|
23587
|
-
} catch (error) {
|
|
23588
|
-
return `Error moving Notion pages: ${error instanceof Error ? error.message : String(error)}`;
|
|
23589
|
-
}
|
|
23590
23664
|
}
|
|
23591
|
-
};
|
|
23665
|
+
});
|
|
23592
23666
|
}
|
|
23593
|
-
function
|
|
23594
|
-
return {
|
|
23667
|
+
function notionDuplicatePageTool(run) {
|
|
23668
|
+
return withNotionExecutor(run, "Error duplicating Notion page", {
|
|
23595
23669
|
type: "function",
|
|
23596
23670
|
function: {
|
|
23597
23671
|
name: "notion-duplicate-page",
|
|
@@ -23606,22 +23680,11 @@ function createNotionDuplicatePageTool(getAccessToken, requestNotionAccess) {
|
|
|
23606
23680
|
},
|
|
23607
23681
|
required: ["page_id"]
|
|
23608
23682
|
}
|
|
23609
|
-
},
|
|
23610
|
-
executor: async (args) => {
|
|
23611
|
-
let token = getAccessToken();
|
|
23612
|
-
if (!token) {
|
|
23613
|
-
token = await requestNotionAccess();
|
|
23614
|
-
}
|
|
23615
|
-
try {
|
|
23616
|
-
return await callMCPTool(token, "notion-duplicate-page", args);
|
|
23617
|
-
} catch (error) {
|
|
23618
|
-
return `Error duplicating Notion page: ${error instanceof Error ? error.message : String(error)}`;
|
|
23619
|
-
}
|
|
23620
23683
|
}
|
|
23621
|
-
};
|
|
23684
|
+
});
|
|
23622
23685
|
}
|
|
23623
|
-
function
|
|
23624
|
-
return {
|
|
23686
|
+
function notionCreateDatabaseTool(run) {
|
|
23687
|
+
return withNotionExecutor(run, "Error creating Notion database", {
|
|
23625
23688
|
type: "function",
|
|
23626
23689
|
function: {
|
|
23627
23690
|
name: "notion-create-database",
|
|
@@ -23650,22 +23713,11 @@ function createNotionCreateDatabaseTool(getAccessToken, requestNotionAccess) {
|
|
|
23650
23713
|
},
|
|
23651
23714
|
required: ["properties"]
|
|
23652
23715
|
}
|
|
23653
|
-
},
|
|
23654
|
-
executor: async (args) => {
|
|
23655
|
-
let token = getAccessToken();
|
|
23656
|
-
if (!token) {
|
|
23657
|
-
token = await requestNotionAccess();
|
|
23658
|
-
}
|
|
23659
|
-
try {
|
|
23660
|
-
return await callMCPTool(token, "notion-create-database", args);
|
|
23661
|
-
} catch (error) {
|
|
23662
|
-
return `Error creating Notion database: ${error instanceof Error ? error.message : String(error)}`;
|
|
23663
|
-
}
|
|
23664
23716
|
}
|
|
23665
|
-
};
|
|
23717
|
+
});
|
|
23666
23718
|
}
|
|
23667
|
-
function
|
|
23668
|
-
return {
|
|
23719
|
+
function notionUpdateDataSourceTool(run) {
|
|
23720
|
+
return withNotionExecutor(run, "Error updating Notion data source", {
|
|
23669
23721
|
type: "function",
|
|
23670
23722
|
function: {
|
|
23671
23723
|
name: "notion-update-data-source",
|
|
@@ -23702,22 +23754,11 @@ function createNotionUpdateDataSourceTool(getAccessToken, requestNotionAccess) {
|
|
|
23702
23754
|
},
|
|
23703
23755
|
required: ["data_source_id"]
|
|
23704
23756
|
}
|
|
23705
|
-
},
|
|
23706
|
-
executor: async (args) => {
|
|
23707
|
-
let token = getAccessToken();
|
|
23708
|
-
if (!token) {
|
|
23709
|
-
token = await requestNotionAccess();
|
|
23710
|
-
}
|
|
23711
|
-
try {
|
|
23712
|
-
return await callMCPTool(token, "notion-update-data-source", args);
|
|
23713
|
-
} catch (error) {
|
|
23714
|
-
return `Error updating Notion data source: ${error instanceof Error ? error.message : String(error)}`;
|
|
23715
|
-
}
|
|
23716
23757
|
}
|
|
23717
|
-
};
|
|
23758
|
+
});
|
|
23718
23759
|
}
|
|
23719
|
-
function
|
|
23720
|
-
return {
|
|
23760
|
+
function notionCreateCommentTool(run) {
|
|
23761
|
+
return withNotionExecutor(run, "Error creating Notion comment", {
|
|
23721
23762
|
type: "function",
|
|
23722
23763
|
function: {
|
|
23723
23764
|
name: "notion-create-comment",
|
|
@@ -23757,22 +23798,11 @@ function createNotionCreateCommentTool(getAccessToken, requestNotionAccess) {
|
|
|
23757
23798
|
},
|
|
23758
23799
|
required: ["page_id", "rich_text"]
|
|
23759
23800
|
}
|
|
23760
|
-
},
|
|
23761
|
-
executor: async (args) => {
|
|
23762
|
-
let token = getAccessToken();
|
|
23763
|
-
if (!token) {
|
|
23764
|
-
token = await requestNotionAccess();
|
|
23765
|
-
}
|
|
23766
|
-
try {
|
|
23767
|
-
return await callMCPTool(token, "notion-create-comment", args);
|
|
23768
|
-
} catch (error) {
|
|
23769
|
-
return `Error creating Notion comment: ${error instanceof Error ? error.message : String(error)}`;
|
|
23770
|
-
}
|
|
23771
23801
|
}
|
|
23772
|
-
};
|
|
23802
|
+
});
|
|
23773
23803
|
}
|
|
23774
|
-
function
|
|
23775
|
-
return {
|
|
23804
|
+
function notionGetCommentsTool(run) {
|
|
23805
|
+
return withNotionExecutor(run, "Error retrieving Notion comments", {
|
|
23776
23806
|
type: "function",
|
|
23777
23807
|
function: {
|
|
23778
23808
|
name: "notion-get-comments",
|
|
@@ -23799,22 +23829,11 @@ function createNotionGetCommentsTool(getAccessToken, requestNotionAccess) {
|
|
|
23799
23829
|
},
|
|
23800
23830
|
required: ["page_id"]
|
|
23801
23831
|
}
|
|
23802
|
-
},
|
|
23803
|
-
executor: async (args) => {
|
|
23804
|
-
let token = getAccessToken();
|
|
23805
|
-
if (!token) {
|
|
23806
|
-
token = await requestNotionAccess();
|
|
23807
|
-
}
|
|
23808
|
-
try {
|
|
23809
|
-
return await callMCPTool(token, "notion-get-comments", args);
|
|
23810
|
-
} catch (error) {
|
|
23811
|
-
return `Error retrieving Notion comments: ${error instanceof Error ? error.message : String(error)}`;
|
|
23812
|
-
}
|
|
23813
23832
|
}
|
|
23814
|
-
};
|
|
23833
|
+
});
|
|
23815
23834
|
}
|
|
23816
|
-
function
|
|
23817
|
-
return {
|
|
23835
|
+
function notionGetUsersTool(run) {
|
|
23836
|
+
return withNotionExecutor(run, "Error listing Notion users", {
|
|
23818
23837
|
type: "function",
|
|
23819
23838
|
function: {
|
|
23820
23839
|
name: "notion-get-users",
|
|
@@ -23840,22 +23859,11 @@ function createNotionGetUsersTool(getAccessToken, requestNotionAccess) {
|
|
|
23840
23859
|
}
|
|
23841
23860
|
}
|
|
23842
23861
|
}
|
|
23843
|
-
},
|
|
23844
|
-
executor: async (args) => {
|
|
23845
|
-
let token = getAccessToken();
|
|
23846
|
-
if (!token) {
|
|
23847
|
-
token = await requestNotionAccess();
|
|
23848
|
-
}
|
|
23849
|
-
try {
|
|
23850
|
-
return await callMCPTool(token, "notion-get-users", args);
|
|
23851
|
-
} catch (error) {
|
|
23852
|
-
return `Error listing Notion users: ${error instanceof Error ? error.message : String(error)}`;
|
|
23853
|
-
}
|
|
23854
23862
|
}
|
|
23855
|
-
};
|
|
23863
|
+
});
|
|
23856
23864
|
}
|
|
23857
|
-
function
|
|
23858
|
-
return {
|
|
23865
|
+
function notionGetTeamsTool(run) {
|
|
23866
|
+
return withNotionExecutor(run, "Error retrieving Notion teams", {
|
|
23859
23867
|
type: "function",
|
|
23860
23868
|
function: {
|
|
23861
23869
|
name: "notion-get-teams",
|
|
@@ -23869,40 +23877,35 @@ function createNotionGetTeamsTool(getAccessToken, requestNotionAccess) {
|
|
|
23869
23877
|
}
|
|
23870
23878
|
}
|
|
23871
23879
|
}
|
|
23872
|
-
},
|
|
23873
|
-
executor: async (args) => {
|
|
23874
|
-
let token = getAccessToken();
|
|
23875
|
-
if (!token) {
|
|
23876
|
-
token = await requestNotionAccess();
|
|
23877
|
-
}
|
|
23878
|
-
try {
|
|
23879
|
-
return await callMCPTool(token, "notion-get-teams", args);
|
|
23880
|
-
} catch (error) {
|
|
23881
|
-
return `Error retrieving Notion teams: ${error instanceof Error ? error.message : String(error)}`;
|
|
23882
|
-
}
|
|
23883
23880
|
}
|
|
23884
|
-
};
|
|
23881
|
+
});
|
|
23885
23882
|
}
|
|
23883
|
+
var NOTION_TOOLS = [
|
|
23884
|
+
// Search
|
|
23885
|
+
notionSearchTool,
|
|
23886
|
+
// Pages
|
|
23887
|
+
notionFetchTool,
|
|
23888
|
+
notionCreatePagesTool,
|
|
23889
|
+
notionUpdatePageTool,
|
|
23890
|
+
notionMovePagesTool,
|
|
23891
|
+
notionDuplicatePageTool,
|
|
23892
|
+
// Data Sources (Databases)
|
|
23893
|
+
notionCreateDatabaseTool,
|
|
23894
|
+
notionUpdateDataSourceTool,
|
|
23895
|
+
// Comments
|
|
23896
|
+
notionCreateCommentTool,
|
|
23897
|
+
notionGetCommentsTool,
|
|
23898
|
+
// Users & Teams
|
|
23899
|
+
notionGetUsersTool,
|
|
23900
|
+
notionGetTeamsTool
|
|
23901
|
+
];
|
|
23886
23902
|
function createNotionTools(getAccessToken, requestNotionAccess) {
|
|
23887
|
-
|
|
23888
|
-
|
|
23889
|
-
|
|
23890
|
-
|
|
23891
|
-
|
|
23892
|
-
|
|
23893
|
-
createNotionUpdatePageTool(getAccessToken, requestNotionAccess),
|
|
23894
|
-
createNotionMovePagesTool(getAccessToken, requestNotionAccess),
|
|
23895
|
-
createNotionDuplicatePageTool(getAccessToken, requestNotionAccess),
|
|
23896
|
-
// Data Sources (Databases)
|
|
23897
|
-
createNotionCreateDatabaseTool(getAccessToken, requestNotionAccess),
|
|
23898
|
-
createNotionUpdateDataSourceTool(getAccessToken, requestNotionAccess),
|
|
23899
|
-
// Comments
|
|
23900
|
-
createNotionCreateCommentTool(getAccessToken, requestNotionAccess),
|
|
23901
|
-
createNotionGetCommentsTool(getAccessToken, requestNotionAccess),
|
|
23902
|
-
// Users & Teams
|
|
23903
|
-
createNotionGetUsersTool(getAccessToken, requestNotionAccess),
|
|
23904
|
-
createNotionGetTeamsTool(getAccessToken, requestNotionAccess)
|
|
23905
|
-
];
|
|
23903
|
+
const run = directRunner(getAccessToken, requestNotionAccess);
|
|
23904
|
+
return NOTION_TOOLS.map((tool) => tool(run));
|
|
23905
|
+
}
|
|
23906
|
+
function createNotionProxyTools(callMcp) {
|
|
23907
|
+
const run = proxyRunner(callMcp);
|
|
23908
|
+
return NOTION_TOOLS.map((tool) => tool(run));
|
|
23906
23909
|
}
|
|
23907
23910
|
export {
|
|
23908
23911
|
CHUNKS_DISCARDED_ORIGIN,
|
|
@@ -23997,6 +24000,7 @@ export {
|
|
|
23997
24000
|
createMemoryVaultSearchTool,
|
|
23998
24001
|
createMemoryVaultTool,
|
|
23999
24002
|
createMessageSourceResolver,
|
|
24003
|
+
createNotionProxyTools,
|
|
24000
24004
|
createNotionTools,
|
|
24001
24005
|
createPlatformCursorStore,
|
|
24002
24006
|
createRecallTool,
|