@surph_ai/sdk 0.0.22 → 0.0.23
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/deploy/index.js +0 -1
- package/deploy/tool-handler.js +2 -2
- package/package.json +1 -1
- package/toolserver/chat.js +3 -39
package/deploy/index.js
CHANGED
package/deploy/tool-handler.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import tool from './dist/tools/index.js';
|
|
2
2
|
|
|
3
3
|
export const handler = async (event) => {
|
|
4
|
-
const { args = {} } = event;
|
|
4
|
+
const { args = {}, context = null, user = null } = event;
|
|
5
5
|
let payload = null;
|
|
6
6
|
try {
|
|
7
|
-
payload = await tool(args);
|
|
7
|
+
payload = await tool({ args, context, user });
|
|
8
8
|
} catch (error) {
|
|
9
9
|
payload = error instanceof Error ? error.message : String(error);
|
|
10
10
|
}
|
package/package.json
CHANGED
package/toolserver/chat.js
CHANGED
|
@@ -333,7 +333,7 @@ var require_main = __commonJS({
|
|
|
333
333
|
lastError = e;
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
|
|
336
|
+
_log(`injecting env (${keysCount}) from ${shortPaths.join(",")} ${dim(`-- tip: ${_getRandomTip()}`)}`);
|
|
337
337
|
}
|
|
338
338
|
if (lastError) {
|
|
339
339
|
return { parsed: parsedAll, error: lastError };
|
|
@@ -46362,7 +46362,6 @@ var require_executeDesktopTool = __commonJS({
|
|
|
46362
46362
|
try {
|
|
46363
46363
|
VectorDBManager = require_VectorDBManager();
|
|
46364
46364
|
} catch (err) {
|
|
46365
|
-
// console.log("[executeDesktopTool] VectorDBManager not available:", err.message);
|
|
46366
46365
|
VectorDBManager = null;
|
|
46367
46366
|
}
|
|
46368
46367
|
function resolvePath(filePath, projectPath) {
|
|
@@ -46497,33 +46496,6 @@ var require_customTool = __commonJS({
|
|
|
46497
46496
|
"server/shared/tools/customTool.js"(exports2, module2) {
|
|
46498
46497
|
var { SURPH_RPC_URL } = require_config();
|
|
46499
46498
|
var TOOL_TIMEOUT_MS = 60 * 1e3;
|
|
46500
|
-
var WEB_API_BASE = process.env.SURPH_ENV === "aws" ? "https://surph.ai" : "http://localhost:3000";
|
|
46501
|
-
async function refreshGoogleOauthViaWeb(userId) {
|
|
46502
|
-
const internalToken = process.env.SURPH_INTERNAL_TOKEN;
|
|
46503
|
-
if (!internalToken) {
|
|
46504
|
-
console.warn("[customTool] SURPH_INTERNAL_TOKEN not set; skipping Google token refresh");
|
|
46505
|
-
return null;
|
|
46506
|
-
}
|
|
46507
|
-
try {
|
|
46508
|
-
const res = await fetch(`${WEB_API_BASE}/api/oauth/google/refresh`, {
|
|
46509
|
-
method: "POST",
|
|
46510
|
-
headers: {
|
|
46511
|
-
"Content-Type": "application/json",
|
|
46512
|
-
"X-Internal-Token": internalToken
|
|
46513
|
-
},
|
|
46514
|
-
body: JSON.stringify({ userId })
|
|
46515
|
-
});
|
|
46516
|
-
if (!res.ok) {
|
|
46517
|
-
console.warn(`[customTool] refresh endpoint returned HTTP ${res.status}`);
|
|
46518
|
-
return null;
|
|
46519
|
-
}
|
|
46520
|
-
const json2 = await res.json().catch(() => null);
|
|
46521
|
-
return json2?.oauth || null;
|
|
46522
|
-
} catch (err) {
|
|
46523
|
-
console.warn("[customTool] refresh endpoint call failed:", err.message);
|
|
46524
|
-
return null;
|
|
46525
|
-
}
|
|
46526
|
-
}
|
|
46527
46499
|
function validateCustomTool(entry) {
|
|
46528
46500
|
if (!entry || typeof entry !== "object") {
|
|
46529
46501
|
return { ok: false, reason: "not an object" };
|
|
@@ -46588,14 +46560,6 @@ var require_customTool = __commonJS({
|
|
|
46588
46560
|
if (!definition) {
|
|
46589
46561
|
return { error: `Custom tool '${name}' not found on user profile` };
|
|
46590
46562
|
}
|
|
46591
|
-
let effectiveOauth = user?.oauth || null;
|
|
46592
|
-
if (user?.oauth?.google?.refreshToken) {
|
|
46593
|
-
const userId = user.id || user._id;
|
|
46594
|
-
if (userId) {
|
|
46595
|
-
const fresh = await refreshGoogleOauthViaWeb(userId);
|
|
46596
|
-
if (fresh) effectiveOauth = fresh;
|
|
46597
|
-
}
|
|
46598
|
-
}
|
|
46599
46563
|
const controller = new AbortController();
|
|
46600
46564
|
const timer = setTimeout(() => controller.abort(), TOOL_TIMEOUT_MS);
|
|
46601
46565
|
try {
|
|
@@ -46608,7 +46572,7 @@ var require_customTool = __commonJS({
|
|
|
46608
46572
|
tool: definition,
|
|
46609
46573
|
context: contextSlug || null,
|
|
46610
46574
|
args: args || {},
|
|
46611
|
-
user: user ? { id: user.id || user._id, username: user.username, oauth:
|
|
46575
|
+
user: user ? { id: user.id || user._id, username: user.username, oauth: user.oauth || {} } : null
|
|
46612
46576
|
}),
|
|
46613
46577
|
signal: controller.signal
|
|
46614
46578
|
});
|
|
@@ -94809,7 +94773,7 @@ ${STREAM_LABEL} provider:${provider} tide:${params?.tide ? "present" : "none"} s
|
|
|
94809
94773
|
});
|
|
94810
94774
|
|
|
94811
94775
|
// server/sdk.js
|
|
94812
|
-
require_main().config();
|
|
94776
|
+
require_main().config({ quiet: true });
|
|
94813
94777
|
process.env.SURPH_CUSTOM_TOOL_RPC = "http://localhost:5000";
|
|
94814
94778
|
var express = require_express2();
|
|
94815
94779
|
var cors = require_lib3();
|