@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.cjs
CHANGED
|
@@ -1491,6 +1491,7 @@ __export(index_exports, {
|
|
|
1491
1491
|
createMemoryVaultSearchTool: () => createMemoryVaultSearchTool,
|
|
1492
1492
|
createMemoryVaultTool: () => createMemoryVaultTool,
|
|
1493
1493
|
createMessageSourceResolver: () => createMessageSourceResolver,
|
|
1494
|
+
createNotionProxyTools: () => createNotionProxyTools,
|
|
1494
1495
|
createNotionTools: () => createNotionTools,
|
|
1495
1496
|
createPlatformCursorStore: () => createPlatformCursorStore,
|
|
1496
1497
|
createRecallTool: () => createRecallTool,
|
|
@@ -5533,6 +5534,36 @@ init_clientConfig();
|
|
|
5533
5534
|
// src/lib/chat/toolLoop.ts
|
|
5534
5535
|
init_clientConfig();
|
|
5535
5536
|
init_redactor();
|
|
5537
|
+
|
|
5538
|
+
// src/lib/storage/mcpImages.ts
|
|
5539
|
+
var IMAGE_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
5540
|
+
"AnumaMediaMCP-anuma_create_image",
|
|
5541
|
+
"anuma_create_image",
|
|
5542
|
+
// Deprecated anuma-image-mcp tools, retained so images in already-stored
|
|
5543
|
+
// conversations still re-materialize on replay.
|
|
5544
|
+
"AnumaImageMCP-generate_cloud_image",
|
|
5545
|
+
"AnumaImageMCP-edit_cloud_image",
|
|
5546
|
+
"generate_cloud_image",
|
|
5547
|
+
"edit_cloud_image"
|
|
5548
|
+
]);
|
|
5549
|
+
function toolOutputForModel(name, output) {
|
|
5550
|
+
if (!name || !IMAGE_TOOL_NAMES.has(name)) return output;
|
|
5551
|
+
try {
|
|
5552
|
+
const {
|
|
5553
|
+
imageUrl: _imageUrl,
|
|
5554
|
+
url: _url,
|
|
5555
|
+
output_images: _outputImages,
|
|
5556
|
+
...rest
|
|
5557
|
+
} = JSON.parse(output);
|
|
5558
|
+
return JSON.stringify(rest);
|
|
5559
|
+
} catch {
|
|
5560
|
+
return output;
|
|
5561
|
+
}
|
|
5562
|
+
}
|
|
5563
|
+
var VIDEO_EXTENSIONS = ["mp4", "webm", "mov"];
|
|
5564
|
+
var VIDEO_EXTENSION_RE = new RegExp(`\\.(${VIDEO_EXTENSIONS.join("|")})(?:[?#]|$)`, "i");
|
|
5565
|
+
|
|
5566
|
+
// src/lib/chat/toolLoop.ts
|
|
5536
5567
|
init_endpointOverride();
|
|
5537
5568
|
|
|
5538
5569
|
// src/lib/chat/runHooks.ts
|
|
@@ -7666,6 +7697,40 @@ function extractLastUserText(messages) {
|
|
|
7666
7697
|
function isToolErrorResult(result) {
|
|
7667
7698
|
return result !== null && typeof result === "object" && "error" in result && typeof result.error === "string";
|
|
7668
7699
|
}
|
|
7700
|
+
function serverToolCallMessages(events, messages, skipIds) {
|
|
7701
|
+
const seen = new Set(skipIds);
|
|
7702
|
+
for (const m of messages) {
|
|
7703
|
+
if (m.tool_call_id) seen.add(m.tool_call_id);
|
|
7704
|
+
for (const tc of m.tool_calls ?? []) if (tc.id) seen.add(tc.id);
|
|
7705
|
+
}
|
|
7706
|
+
const executed = [];
|
|
7707
|
+
for (const event of events ?? []) {
|
|
7708
|
+
if (!event.id || event.output === void 0 || event.output === null || seen.has(event.id)) {
|
|
7709
|
+
continue;
|
|
7710
|
+
}
|
|
7711
|
+
seen.add(event.id);
|
|
7712
|
+
executed.push(event);
|
|
7713
|
+
}
|
|
7714
|
+
if (executed.length === 0) return [];
|
|
7715
|
+
return [
|
|
7716
|
+
{
|
|
7717
|
+
role: "assistant",
|
|
7718
|
+
content: void 0,
|
|
7719
|
+
tool_calls: executed.map((event) => ({
|
|
7720
|
+
id: event.id,
|
|
7721
|
+
type: "function",
|
|
7722
|
+
function: { name: event.name, arguments: event.arguments }
|
|
7723
|
+
}))
|
|
7724
|
+
},
|
|
7725
|
+
...executed.map(
|
|
7726
|
+
(event) => ({
|
|
7727
|
+
role: "tool",
|
|
7728
|
+
tool_call_id: event.id,
|
|
7729
|
+
content: [{ type: "text", text: toolOutputForModel(event.name, event.output ?? "") }]
|
|
7730
|
+
})
|
|
7731
|
+
)
|
|
7732
|
+
];
|
|
7733
|
+
}
|
|
7669
7734
|
function getToolName(tool) {
|
|
7670
7735
|
const func = tool.function;
|
|
7671
7736
|
const nestedName = func?.name;
|
|
@@ -8435,7 +8500,14 @@ Executing tool: ${toolInfo}
|
|
|
8435
8500
|
}
|
|
8436
8501
|
}))
|
|
8437
8502
|
};
|
|
8438
|
-
const toolResultMessages = [
|
|
8503
|
+
const toolResultMessages = [
|
|
8504
|
+
...serverToolCallMessages(
|
|
8505
|
+
currentAccumulator.toolCallEvents,
|
|
8506
|
+
currentMessages,
|
|
8507
|
+
new Set(toolCallsToExecute.map((tc) => tc.id))
|
|
8508
|
+
),
|
|
8509
|
+
assistantMessage
|
|
8510
|
+
];
|
|
8439
8511
|
for (const execResult of continueResults) {
|
|
8440
8512
|
const resultContent = execResult.error ? `Error: ${execResult.error}` : safeJsonStringify(execResult.result);
|
|
8441
8513
|
toolResultMessages.push({
|
|
@@ -10630,20 +10702,6 @@ function generateMediaId() {
|
|
|
10630
10702
|
// src/lib/db/media/operations.ts
|
|
10631
10703
|
var import_watermelondb7 = require("@nozbe/watermelondb");
|
|
10632
10704
|
|
|
10633
|
-
// src/lib/storage/mcpImages.ts
|
|
10634
|
-
var IMAGE_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
10635
|
-
"AnumaMediaMCP-anuma_create_image",
|
|
10636
|
-
"anuma_create_image",
|
|
10637
|
-
// Deprecated anuma-image-mcp tools, retained so images in already-stored
|
|
10638
|
-
// conversations still re-materialize on replay.
|
|
10639
|
-
"AnumaImageMCP-generate_cloud_image",
|
|
10640
|
-
"AnumaImageMCP-edit_cloud_image",
|
|
10641
|
-
"generate_cloud_image",
|
|
10642
|
-
"edit_cloud_image"
|
|
10643
|
-
]);
|
|
10644
|
-
var VIDEO_EXTENSIONS = ["mp4", "webm", "mov"];
|
|
10645
|
-
var VIDEO_EXTENSION_RE = new RegExp(`\\.(${VIDEO_EXTENSIONS.join("|")})(?:[?#]|$)`, "i");
|
|
10646
|
-
|
|
10647
10705
|
// src/lib/storage/opfs.ts
|
|
10648
10706
|
function isOPFSSupported() {
|
|
10649
10707
|
return typeof navigator !== "undefined" && "storage" in navigator && "getDirectory" in navigator.storage;
|
|
@@ -21189,24 +21247,10 @@ function storedToLlmapiMessage(stored) {
|
|
|
21189
21247
|
});
|
|
21190
21248
|
for (const event of stored.toolCallEvents) {
|
|
21191
21249
|
if (event.id && event.output !== void 0 && event.output !== null) {
|
|
21192
|
-
let toolOutput = event.output;
|
|
21193
|
-
if (event.name && IMAGE_TOOL_NAMES.has(event.name)) {
|
|
21194
|
-
try {
|
|
21195
|
-
const parsed = JSON.parse(toolOutput);
|
|
21196
|
-
const {
|
|
21197
|
-
imageUrl: _imageUrl,
|
|
21198
|
-
url: _url,
|
|
21199
|
-
output_images: _outputImages,
|
|
21200
|
-
...rest
|
|
21201
|
-
} = parsed;
|
|
21202
|
-
toolOutput = JSON.stringify(rest);
|
|
21203
|
-
} catch {
|
|
21204
|
-
}
|
|
21205
|
-
}
|
|
21206
21250
|
messages.push({
|
|
21207
21251
|
role: "tool",
|
|
21208
21252
|
tool_call_id: event.id,
|
|
21209
|
-
content: [{ type: "text", text:
|
|
21253
|
+
content: [{ type: "text", text: toolOutputForModel(event.name, event.output) }]
|
|
21210
21254
|
});
|
|
21211
21255
|
}
|
|
21212
21256
|
}
|
|
@@ -24848,6 +24892,19 @@ async function refreshNotionAccessToken(params) {
|
|
|
24848
24892
|
return result;
|
|
24849
24893
|
}
|
|
24850
24894
|
|
|
24895
|
+
// src/lib/connectors/errors.ts
|
|
24896
|
+
function buildConnectorErrorResult(code, provider, connectUrl, extras) {
|
|
24897
|
+
const payload = {
|
|
24898
|
+
__anuma_connector_error_v1: true,
|
|
24899
|
+
code,
|
|
24900
|
+
provider,
|
|
24901
|
+
connect_url: connectUrl,
|
|
24902
|
+
missing_scopes: extras?.missingScopes,
|
|
24903
|
+
required: extras?.required
|
|
24904
|
+
};
|
|
24905
|
+
return JSON.stringify(payload);
|
|
24906
|
+
}
|
|
24907
|
+
|
|
24851
24908
|
// src/tools/notion.ts
|
|
24852
24909
|
var MCP_HTTP_ENDPOINT = "https://mcp.notion.com/mcp";
|
|
24853
24910
|
var MAX_CONTENT_LENGTH2 = 5e4;
|
|
@@ -25020,8 +25077,83 @@ async function callMCPTool(accessToken, toolName, args) {
|
|
|
25020
25077
|
}
|
|
25021
25078
|
return truncateToolResult(jsonRpcResponse.result);
|
|
25022
25079
|
}
|
|
25023
|
-
|
|
25080
|
+
var NOTION_PROVIDER = "notion";
|
|
25081
|
+
function directRunner(getAccessToken, requestNotionAccess) {
|
|
25082
|
+
return async (toolName, args) => {
|
|
25083
|
+
let token = getAccessToken();
|
|
25084
|
+
if (!token) {
|
|
25085
|
+
token = await requestNotionAccess();
|
|
25086
|
+
}
|
|
25087
|
+
return callMCPTool(token, toolName, args);
|
|
25088
|
+
};
|
|
25089
|
+
}
|
|
25090
|
+
function readField(json4, key) {
|
|
25091
|
+
return typeof json4 === "object" && json4 !== null ? json4[key] : void 0;
|
|
25092
|
+
}
|
|
25093
|
+
function readString(json4, key) {
|
|
25094
|
+
const value = readField(json4, key);
|
|
25095
|
+
return typeof value === "string" ? value : void 0;
|
|
25096
|
+
}
|
|
25097
|
+
function notionConnectorError(status, json4) {
|
|
25098
|
+
const code = readField(json4, "code");
|
|
25099
|
+
if (status === 503) {
|
|
25100
|
+
return code === "upstream_unavailable" ? buildConnectorErrorResult("upstream_unavailable", NOTION_PROVIDER) : null;
|
|
25101
|
+
}
|
|
25102
|
+
if (status !== 401 && status !== 403 && status !== 412) return null;
|
|
25103
|
+
switch (code) {
|
|
25104
|
+
case "scope_not_covered": {
|
|
25105
|
+
const missingScopes = readField(json4, "missing_scopes");
|
|
25106
|
+
return buildConnectorErrorResult(
|
|
25107
|
+
"scope_not_covered",
|
|
25108
|
+
NOTION_PROVIDER,
|
|
25109
|
+
readString(json4, "connect_url"),
|
|
25110
|
+
Array.isArray(missingScopes) ? { missingScopes } : void 0
|
|
25111
|
+
);
|
|
25112
|
+
}
|
|
25113
|
+
case "insufficient_scope":
|
|
25114
|
+
return buildConnectorErrorResult("insufficient_scope", NOTION_PROVIDER, void 0, {
|
|
25115
|
+
required: readString(json4, "required")
|
|
25116
|
+
});
|
|
25117
|
+
case "upstream_unavailable":
|
|
25118
|
+
return buildConnectorErrorResult("upstream_unavailable", NOTION_PROVIDER);
|
|
25119
|
+
default:
|
|
25120
|
+
return buildConnectorErrorResult(
|
|
25121
|
+
"connector_not_connected",
|
|
25122
|
+
NOTION_PROVIDER,
|
|
25123
|
+
readString(json4, "connect_url")
|
|
25124
|
+
);
|
|
25125
|
+
}
|
|
25126
|
+
}
|
|
25127
|
+
function proxyRunner(callMcp) {
|
|
25128
|
+
return async (toolName, args) => {
|
|
25129
|
+
const { status, json: json4 } = await callMcp(toolName, args);
|
|
25130
|
+
if (status >= 200 && status < 300) {
|
|
25131
|
+
const result = readField(json4, "result");
|
|
25132
|
+
if (result === void 0) {
|
|
25133
|
+
throw new Error(`Notion returned no result (${status})`);
|
|
25134
|
+
}
|
|
25135
|
+
return truncateToolResult(result);
|
|
25136
|
+
}
|
|
25137
|
+
const connectorError = notionConnectorError(status, json4);
|
|
25138
|
+
if (connectorError) return connectorError;
|
|
25139
|
+
const message = readField(json4, "error");
|
|
25140
|
+
throw new Error(`${typeof message === "string" ? message : JSON.stringify(json4)} (${status})`);
|
|
25141
|
+
};
|
|
25142
|
+
}
|
|
25143
|
+
function withNotionExecutor(run, errorPrefix, tool) {
|
|
25024
25144
|
return {
|
|
25145
|
+
...tool,
|
|
25146
|
+
executor: async (args) => {
|
|
25147
|
+
try {
|
|
25148
|
+
return await run(tool.function.name, args);
|
|
25149
|
+
} catch (error) {
|
|
25150
|
+
return `${errorPrefix}: ${error instanceof Error ? error.message : String(error)}`;
|
|
25151
|
+
}
|
|
25152
|
+
}
|
|
25153
|
+
};
|
|
25154
|
+
}
|
|
25155
|
+
function notionSearchTool(run) {
|
|
25156
|
+
return withNotionExecutor(run, "Error searching Notion", {
|
|
25025
25157
|
type: "function",
|
|
25026
25158
|
function: {
|
|
25027
25159
|
name: "notion-search",
|
|
@@ -25062,22 +25194,11 @@ function createNotionSearchTool(getAccessToken, requestNotionAccess) {
|
|
|
25062
25194
|
},
|
|
25063
25195
|
required: ["query"]
|
|
25064
25196
|
}
|
|
25065
|
-
},
|
|
25066
|
-
executor: async (args) => {
|
|
25067
|
-
let token = getAccessToken();
|
|
25068
|
-
if (!token) {
|
|
25069
|
-
token = await requestNotionAccess();
|
|
25070
|
-
}
|
|
25071
|
-
try {
|
|
25072
|
-
return await callMCPTool(token, "notion-search", args);
|
|
25073
|
-
} catch (error) {
|
|
25074
|
-
return `Error searching Notion: ${error instanceof Error ? error.message : String(error)}`;
|
|
25075
|
-
}
|
|
25076
25197
|
}
|
|
25077
|
-
};
|
|
25198
|
+
});
|
|
25078
25199
|
}
|
|
25079
|
-
function
|
|
25080
|
-
return {
|
|
25200
|
+
function notionFetchTool(run) {
|
|
25201
|
+
return withNotionExecutor(run, "Error fetching Notion page", {
|
|
25081
25202
|
type: "function",
|
|
25082
25203
|
function: {
|
|
25083
25204
|
name: "notion-fetch",
|
|
@@ -25100,22 +25221,11 @@ function createNotionFetchTool(getAccessToken, requestNotionAccess) {
|
|
|
25100
25221
|
},
|
|
25101
25222
|
required: ["id"]
|
|
25102
25223
|
}
|
|
25103
|
-
},
|
|
25104
|
-
executor: async (args) => {
|
|
25105
|
-
let token = getAccessToken();
|
|
25106
|
-
if (!token) {
|
|
25107
|
-
token = await requestNotionAccess();
|
|
25108
|
-
}
|
|
25109
|
-
try {
|
|
25110
|
-
return await callMCPTool(token, "notion-fetch", args);
|
|
25111
|
-
} catch (error) {
|
|
25112
|
-
return `Error fetching Notion page: ${error instanceof Error ? error.message : String(error)}`;
|
|
25113
|
-
}
|
|
25114
25224
|
}
|
|
25115
|
-
};
|
|
25225
|
+
});
|
|
25116
25226
|
}
|
|
25117
|
-
function
|
|
25118
|
-
return {
|
|
25227
|
+
function notionCreatePagesTool(run) {
|
|
25228
|
+
return withNotionExecutor(run, "Error creating Notion page", {
|
|
25119
25229
|
type: "function",
|
|
25120
25230
|
function: {
|
|
25121
25231
|
name: "notion-create-pages",
|
|
@@ -25148,22 +25258,11 @@ function createNotionCreatePagesTool(getAccessToken, requestNotionAccess) {
|
|
|
25148
25258
|
},
|
|
25149
25259
|
required: ["pages"]
|
|
25150
25260
|
}
|
|
25151
|
-
},
|
|
25152
|
-
executor: async (args) => {
|
|
25153
|
-
let token = getAccessToken();
|
|
25154
|
-
if (!token) {
|
|
25155
|
-
token = await requestNotionAccess();
|
|
25156
|
-
}
|
|
25157
|
-
try {
|
|
25158
|
-
return await callMCPTool(token, "notion-create-pages", args);
|
|
25159
|
-
} catch (error) {
|
|
25160
|
-
return `Error creating Notion page: ${error instanceof Error ? error.message : String(error)}`;
|
|
25161
|
-
}
|
|
25162
25261
|
}
|
|
25163
|
-
};
|
|
25262
|
+
});
|
|
25164
25263
|
}
|
|
25165
|
-
function
|
|
25166
|
-
return {
|
|
25264
|
+
function notionUpdatePageTool(run) {
|
|
25265
|
+
return withNotionExecutor(run, "Error updating Notion page", {
|
|
25167
25266
|
type: "function",
|
|
25168
25267
|
function: {
|
|
25169
25268
|
name: "notion-update-page",
|
|
@@ -25211,22 +25310,11 @@ function createNotionUpdatePageTool(getAccessToken, requestNotionAccess) {
|
|
|
25211
25310
|
},
|
|
25212
25311
|
required: ["data"]
|
|
25213
25312
|
}
|
|
25214
|
-
},
|
|
25215
|
-
executor: async (args) => {
|
|
25216
|
-
let token = getAccessToken();
|
|
25217
|
-
if (!token) {
|
|
25218
|
-
token = await requestNotionAccess();
|
|
25219
|
-
}
|
|
25220
|
-
try {
|
|
25221
|
-
return await callMCPTool(token, "notion-update-page", args);
|
|
25222
|
-
} catch (error) {
|
|
25223
|
-
return `Error updating Notion page: ${error instanceof Error ? error.message : String(error)}`;
|
|
25224
|
-
}
|
|
25225
25313
|
}
|
|
25226
|
-
};
|
|
25314
|
+
});
|
|
25227
25315
|
}
|
|
25228
|
-
function
|
|
25229
|
-
return {
|
|
25316
|
+
function notionMovePagesTool(run) {
|
|
25317
|
+
return withNotionExecutor(run, "Error moving Notion pages", {
|
|
25230
25318
|
type: "function",
|
|
25231
25319
|
function: {
|
|
25232
25320
|
name: "notion-move-pages",
|
|
@@ -25246,22 +25334,11 @@ function createNotionMovePagesTool(getAccessToken, requestNotionAccess) {
|
|
|
25246
25334
|
},
|
|
25247
25335
|
required: ["page_or_database_ids", "new_parent"]
|
|
25248
25336
|
}
|
|
25249
|
-
},
|
|
25250
|
-
executor: async (args) => {
|
|
25251
|
-
let token = getAccessToken();
|
|
25252
|
-
if (!token) {
|
|
25253
|
-
token = await requestNotionAccess();
|
|
25254
|
-
}
|
|
25255
|
-
try {
|
|
25256
|
-
return await callMCPTool(token, "notion-move-pages", args);
|
|
25257
|
-
} catch (error) {
|
|
25258
|
-
return `Error moving Notion pages: ${error instanceof Error ? error.message : String(error)}`;
|
|
25259
|
-
}
|
|
25260
25337
|
}
|
|
25261
|
-
};
|
|
25338
|
+
});
|
|
25262
25339
|
}
|
|
25263
|
-
function
|
|
25264
|
-
return {
|
|
25340
|
+
function notionDuplicatePageTool(run) {
|
|
25341
|
+
return withNotionExecutor(run, "Error duplicating Notion page", {
|
|
25265
25342
|
type: "function",
|
|
25266
25343
|
function: {
|
|
25267
25344
|
name: "notion-duplicate-page",
|
|
@@ -25276,22 +25353,11 @@ function createNotionDuplicatePageTool(getAccessToken, requestNotionAccess) {
|
|
|
25276
25353
|
},
|
|
25277
25354
|
required: ["page_id"]
|
|
25278
25355
|
}
|
|
25279
|
-
},
|
|
25280
|
-
executor: async (args) => {
|
|
25281
|
-
let token = getAccessToken();
|
|
25282
|
-
if (!token) {
|
|
25283
|
-
token = await requestNotionAccess();
|
|
25284
|
-
}
|
|
25285
|
-
try {
|
|
25286
|
-
return await callMCPTool(token, "notion-duplicate-page", args);
|
|
25287
|
-
} catch (error) {
|
|
25288
|
-
return `Error duplicating Notion page: ${error instanceof Error ? error.message : String(error)}`;
|
|
25289
|
-
}
|
|
25290
25356
|
}
|
|
25291
|
-
};
|
|
25357
|
+
});
|
|
25292
25358
|
}
|
|
25293
|
-
function
|
|
25294
|
-
return {
|
|
25359
|
+
function notionCreateDatabaseTool(run) {
|
|
25360
|
+
return withNotionExecutor(run, "Error creating Notion database", {
|
|
25295
25361
|
type: "function",
|
|
25296
25362
|
function: {
|
|
25297
25363
|
name: "notion-create-database",
|
|
@@ -25320,22 +25386,11 @@ function createNotionCreateDatabaseTool(getAccessToken, requestNotionAccess) {
|
|
|
25320
25386
|
},
|
|
25321
25387
|
required: ["properties"]
|
|
25322
25388
|
}
|
|
25323
|
-
},
|
|
25324
|
-
executor: async (args) => {
|
|
25325
|
-
let token = getAccessToken();
|
|
25326
|
-
if (!token) {
|
|
25327
|
-
token = await requestNotionAccess();
|
|
25328
|
-
}
|
|
25329
|
-
try {
|
|
25330
|
-
return await callMCPTool(token, "notion-create-database", args);
|
|
25331
|
-
} catch (error) {
|
|
25332
|
-
return `Error creating Notion database: ${error instanceof Error ? error.message : String(error)}`;
|
|
25333
|
-
}
|
|
25334
25389
|
}
|
|
25335
|
-
};
|
|
25390
|
+
});
|
|
25336
25391
|
}
|
|
25337
|
-
function
|
|
25338
|
-
return {
|
|
25392
|
+
function notionUpdateDataSourceTool(run) {
|
|
25393
|
+
return withNotionExecutor(run, "Error updating Notion data source", {
|
|
25339
25394
|
type: "function",
|
|
25340
25395
|
function: {
|
|
25341
25396
|
name: "notion-update-data-source",
|
|
@@ -25372,22 +25427,11 @@ function createNotionUpdateDataSourceTool(getAccessToken, requestNotionAccess) {
|
|
|
25372
25427
|
},
|
|
25373
25428
|
required: ["data_source_id"]
|
|
25374
25429
|
}
|
|
25375
|
-
},
|
|
25376
|
-
executor: async (args) => {
|
|
25377
|
-
let token = getAccessToken();
|
|
25378
|
-
if (!token) {
|
|
25379
|
-
token = await requestNotionAccess();
|
|
25380
|
-
}
|
|
25381
|
-
try {
|
|
25382
|
-
return await callMCPTool(token, "notion-update-data-source", args);
|
|
25383
|
-
} catch (error) {
|
|
25384
|
-
return `Error updating Notion data source: ${error instanceof Error ? error.message : String(error)}`;
|
|
25385
|
-
}
|
|
25386
25430
|
}
|
|
25387
|
-
};
|
|
25431
|
+
});
|
|
25388
25432
|
}
|
|
25389
|
-
function
|
|
25390
|
-
return {
|
|
25433
|
+
function notionCreateCommentTool(run) {
|
|
25434
|
+
return withNotionExecutor(run, "Error creating Notion comment", {
|
|
25391
25435
|
type: "function",
|
|
25392
25436
|
function: {
|
|
25393
25437
|
name: "notion-create-comment",
|
|
@@ -25427,22 +25471,11 @@ function createNotionCreateCommentTool(getAccessToken, requestNotionAccess) {
|
|
|
25427
25471
|
},
|
|
25428
25472
|
required: ["page_id", "rich_text"]
|
|
25429
25473
|
}
|
|
25430
|
-
},
|
|
25431
|
-
executor: async (args) => {
|
|
25432
|
-
let token = getAccessToken();
|
|
25433
|
-
if (!token) {
|
|
25434
|
-
token = await requestNotionAccess();
|
|
25435
|
-
}
|
|
25436
|
-
try {
|
|
25437
|
-
return await callMCPTool(token, "notion-create-comment", args);
|
|
25438
|
-
} catch (error) {
|
|
25439
|
-
return `Error creating Notion comment: ${error instanceof Error ? error.message : String(error)}`;
|
|
25440
|
-
}
|
|
25441
25474
|
}
|
|
25442
|
-
};
|
|
25475
|
+
});
|
|
25443
25476
|
}
|
|
25444
|
-
function
|
|
25445
|
-
return {
|
|
25477
|
+
function notionGetCommentsTool(run) {
|
|
25478
|
+
return withNotionExecutor(run, "Error retrieving Notion comments", {
|
|
25446
25479
|
type: "function",
|
|
25447
25480
|
function: {
|
|
25448
25481
|
name: "notion-get-comments",
|
|
@@ -25469,22 +25502,11 @@ function createNotionGetCommentsTool(getAccessToken, requestNotionAccess) {
|
|
|
25469
25502
|
},
|
|
25470
25503
|
required: ["page_id"]
|
|
25471
25504
|
}
|
|
25472
|
-
},
|
|
25473
|
-
executor: async (args) => {
|
|
25474
|
-
let token = getAccessToken();
|
|
25475
|
-
if (!token) {
|
|
25476
|
-
token = await requestNotionAccess();
|
|
25477
|
-
}
|
|
25478
|
-
try {
|
|
25479
|
-
return await callMCPTool(token, "notion-get-comments", args);
|
|
25480
|
-
} catch (error) {
|
|
25481
|
-
return `Error retrieving Notion comments: ${error instanceof Error ? error.message : String(error)}`;
|
|
25482
|
-
}
|
|
25483
25505
|
}
|
|
25484
|
-
};
|
|
25506
|
+
});
|
|
25485
25507
|
}
|
|
25486
|
-
function
|
|
25487
|
-
return {
|
|
25508
|
+
function notionGetUsersTool(run) {
|
|
25509
|
+
return withNotionExecutor(run, "Error listing Notion users", {
|
|
25488
25510
|
type: "function",
|
|
25489
25511
|
function: {
|
|
25490
25512
|
name: "notion-get-users",
|
|
@@ -25510,22 +25532,11 @@ function createNotionGetUsersTool(getAccessToken, requestNotionAccess) {
|
|
|
25510
25532
|
}
|
|
25511
25533
|
}
|
|
25512
25534
|
}
|
|
25513
|
-
},
|
|
25514
|
-
executor: async (args) => {
|
|
25515
|
-
let token = getAccessToken();
|
|
25516
|
-
if (!token) {
|
|
25517
|
-
token = await requestNotionAccess();
|
|
25518
|
-
}
|
|
25519
|
-
try {
|
|
25520
|
-
return await callMCPTool(token, "notion-get-users", args);
|
|
25521
|
-
} catch (error) {
|
|
25522
|
-
return `Error listing Notion users: ${error instanceof Error ? error.message : String(error)}`;
|
|
25523
|
-
}
|
|
25524
25535
|
}
|
|
25525
|
-
};
|
|
25536
|
+
});
|
|
25526
25537
|
}
|
|
25527
|
-
function
|
|
25528
|
-
return {
|
|
25538
|
+
function notionGetTeamsTool(run) {
|
|
25539
|
+
return withNotionExecutor(run, "Error retrieving Notion teams", {
|
|
25529
25540
|
type: "function",
|
|
25530
25541
|
function: {
|
|
25531
25542
|
name: "notion-get-teams",
|
|
@@ -25539,40 +25550,35 @@ function createNotionGetTeamsTool(getAccessToken, requestNotionAccess) {
|
|
|
25539
25550
|
}
|
|
25540
25551
|
}
|
|
25541
25552
|
}
|
|
25542
|
-
},
|
|
25543
|
-
executor: async (args) => {
|
|
25544
|
-
let token = getAccessToken();
|
|
25545
|
-
if (!token) {
|
|
25546
|
-
token = await requestNotionAccess();
|
|
25547
|
-
}
|
|
25548
|
-
try {
|
|
25549
|
-
return await callMCPTool(token, "notion-get-teams", args);
|
|
25550
|
-
} catch (error) {
|
|
25551
|
-
return `Error retrieving Notion teams: ${error instanceof Error ? error.message : String(error)}`;
|
|
25552
|
-
}
|
|
25553
25553
|
}
|
|
25554
|
-
};
|
|
25554
|
+
});
|
|
25555
25555
|
}
|
|
25556
|
+
var NOTION_TOOLS = [
|
|
25557
|
+
// Search
|
|
25558
|
+
notionSearchTool,
|
|
25559
|
+
// Pages
|
|
25560
|
+
notionFetchTool,
|
|
25561
|
+
notionCreatePagesTool,
|
|
25562
|
+
notionUpdatePageTool,
|
|
25563
|
+
notionMovePagesTool,
|
|
25564
|
+
notionDuplicatePageTool,
|
|
25565
|
+
// Data Sources (Databases)
|
|
25566
|
+
notionCreateDatabaseTool,
|
|
25567
|
+
notionUpdateDataSourceTool,
|
|
25568
|
+
// Comments
|
|
25569
|
+
notionCreateCommentTool,
|
|
25570
|
+
notionGetCommentsTool,
|
|
25571
|
+
// Users & Teams
|
|
25572
|
+
notionGetUsersTool,
|
|
25573
|
+
notionGetTeamsTool
|
|
25574
|
+
];
|
|
25556
25575
|
function createNotionTools(getAccessToken, requestNotionAccess) {
|
|
25557
|
-
|
|
25558
|
-
|
|
25559
|
-
|
|
25560
|
-
|
|
25561
|
-
|
|
25562
|
-
|
|
25563
|
-
createNotionUpdatePageTool(getAccessToken, requestNotionAccess),
|
|
25564
|
-
createNotionMovePagesTool(getAccessToken, requestNotionAccess),
|
|
25565
|
-
createNotionDuplicatePageTool(getAccessToken, requestNotionAccess),
|
|
25566
|
-
// Data Sources (Databases)
|
|
25567
|
-
createNotionCreateDatabaseTool(getAccessToken, requestNotionAccess),
|
|
25568
|
-
createNotionUpdateDataSourceTool(getAccessToken, requestNotionAccess),
|
|
25569
|
-
// Comments
|
|
25570
|
-
createNotionCreateCommentTool(getAccessToken, requestNotionAccess),
|
|
25571
|
-
createNotionGetCommentsTool(getAccessToken, requestNotionAccess),
|
|
25572
|
-
// Users & Teams
|
|
25573
|
-
createNotionGetUsersTool(getAccessToken, requestNotionAccess),
|
|
25574
|
-
createNotionGetTeamsTool(getAccessToken, requestNotionAccess)
|
|
25575
|
-
];
|
|
25576
|
+
const run = directRunner(getAccessToken, requestNotionAccess);
|
|
25577
|
+
return NOTION_TOOLS.map((tool) => tool(run));
|
|
25578
|
+
}
|
|
25579
|
+
function createNotionProxyTools(callMcp) {
|
|
25580
|
+
const run = proxyRunner(callMcp);
|
|
25581
|
+
return NOTION_TOOLS.map((tool) => tool(run));
|
|
25576
25582
|
}
|
|
25577
25583
|
// Annotate the CommonJS export names for ESM import in node:
|
|
25578
25584
|
0 && (module.exports = {
|
|
@@ -25668,6 +25674,7 @@ function createNotionTools(getAccessToken, requestNotionAccess) {
|
|
|
25668
25674
|
createMemoryVaultSearchTool,
|
|
25669
25675
|
createMemoryVaultTool,
|
|
25670
25676
|
createMessageSourceResolver,
|
|
25677
|
+
createNotionProxyTools,
|
|
25671
25678
|
createNotionTools,
|
|
25672
25679
|
createPlatformCursorStore,
|
|
25673
25680
|
createRecallTool,
|