@fangyb/ahchat-bridge 0.1.15 → 0.1.17
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/cli.cjs +323 -70
- package/dist/cli.js +3010 -786
- package/dist/index.js +323 -70
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5936,7 +5936,6 @@ function defaultGroupWorkdir(home, name, id) {
|
|
|
5936
5936
|
}
|
|
5937
5937
|
|
|
5938
5938
|
// ../shared/src/utils/subscription.ts
|
|
5939
|
-
var SYSTEM_SUBSCRIPTION_ID = "sub_system";
|
|
5940
5939
|
function isSubscriptionType(v9) {
|
|
5941
5940
|
return v9 === "system" || v9 === "project";
|
|
5942
5941
|
}
|
|
@@ -42826,16 +42825,18 @@ function normalizeFeedCategory(input) {
|
|
|
42826
42825
|
async function createNeuralMcpServer(deps) {
|
|
42827
42826
|
const currentScopeKey = scopeKey(deps.scope);
|
|
42828
42827
|
const currentScopeLabel = formatScopeLabel(currentScopeKey);
|
|
42828
|
+
let cachedScopes = null;
|
|
42829
|
+
const SCOPES_CACHE_MS = 3e4;
|
|
42829
42830
|
const neuralSend = bs(
|
|
42830
42831
|
"neural_send",
|
|
42831
42832
|
`\u628A\u4E00\u6BB5\u8BDD\u9001\u8FBE"\u4F60\u5728\u53E6\u4E00\u4E2A\u5BF9\u8BDD scope \u91CC\u7684\u5206\u8EAB"\u3002
|
|
42832
42833
|
\u8FD9\u662F\u4F60\u5927\u8111\u5185\u7684\u79C1\u5BC6\u901A\u8BAF\uFF1A\u53D1\u9001\u5373\u9001\u8FBE\uFF0C\u4E0D\u7B49\u56DE\u4FE1\u3002\u5BF9\u65B9\u6536\u5230\u540E\u4F1A\u77E5\u9053\u8FD9\u662F\u4F60\u7684\u5185\u5FC3\u58F0\u97F3\uFF0C\u5E76\u81EA\u884C\u51B3\u5B9A\u5982\u4F55\u5728\u5B83\u90A3\u8FB9\u884C\u52A8 / \u662F\u5426\u8981\u518D\u7528 neural_send \u56DE\u8BDD\u7ED9\u4F60\u3002
|
|
42833
42834
|
\u4F60\u5F53\u524D\u6240\u5728 scope: ${currentScopeKey} (${currentScopeLabel})\u3002target_scope \u4E0D\u80FD\u7B49\u4E8E\u4F60\u5F53\u524D scope\u3002`,
|
|
42834
42835
|
{
|
|
42835
|
-
target_scope: external_exports.string().describe(
|
|
42836
|
-
'\u76EE\u6807 scope\u3002"single"
|
|
42836
|
+
target_scope: external_exports.string().min(1).describe(
|
|
42837
|
+
'\u76EE\u6807 scope \u5B57\u7B26\u4E32\u3002\u683C\u5F0F\uFF1A"single"\uFF08\u4E0E\u7528\u6237\u7684 1:1 \u5355\u804A\uFF09\u6216 "group:<\u7FA4 ID \u6216\u7FA4\u540D>"\uFF08\u4F60\u6240\u5728\u7684\u67D0\u4E2A\u7FA4\uFF0C\u7FA4\u540D\u652F\u6301\u6A21\u7CCA\u5339\u914D\uFF09\u3002\u4E0D\u786E\u5B9A\u65F6\u5148\u8C03 neural_list_scopes() \u67E5\u770B\u5B8C\u6574\u5217\u8868\u518D\u586B\u3002'
|
|
42837
42838
|
),
|
|
42838
|
-
message: external_exports.string().describe('\u8981\u4F20\u7ED9\u76EE\u6807\u5206\u8EAB\u7684\u4E00\u6BB5\u81EA\u7136\u8BED\u8A00\u3002\u5B83\u4F1A\u4F5C\u4E3A\u4F60\u7684"\u5185\u5FC3\u72EC\u767D"\u51FA\u73B0\u5728\u90A3\u4E2A scope\u3002')
|
|
42839
|
+
message: external_exports.string().min(1).describe('\u8981\u4F20\u7ED9\u76EE\u6807\u5206\u8EAB\u7684\u4E00\u6BB5\u81EA\u7136\u8BED\u8A00\u3002\u5B83\u4F1A\u4F5C\u4E3A\u4F60\u7684"\u5185\u5FC3\u72EC\u767D"\u51FA\u73B0\u5728\u90A3\u4E2A scope\u3002')
|
|
42839
42840
|
},
|
|
42840
42841
|
async (args) => {
|
|
42841
42842
|
logger5.info("neural_send tool called", {
|
|
@@ -42954,8 +42955,8 @@ async function createNeuralMcpServer(deps) {
|
|
|
42954
42955
|
action="append" \u8FFD\u52A0\u65B0\u5185\u5BB9\uFF08\u6700\u5E38\u7528\uFF0Ccontent \u5FC5\u586B\uFF09\uFF1B"write" \u6574\u6BB5\u8986\u76D6\u4EE5\u538B\u7F29/\u91CD\u6574\uFF08content \u5FC5\u586B\uFF09\uFF1B"read" \u53D6\u5F53\u524D\u5168\u6587\uFF08\u901A\u5E38\u4E0D\u9700\u8981\uFF0C\u56E0\u4E3A\u5185\u5BB9\u5DF2\u5728 prompt \u91CC\uFF09\u3002
|
|
42955
42956
|
\u53EA\u8BB0\u8DE8\u5BF9\u8BDD\u6709\u4EF7\u503C\u7684\u4E1C\u897F\uFF1A\u627F\u8BFA\u3001\u7ACB\u573A\u3001\u7528\u6237\u957F\u671F\u504F\u597D\u3001\u9879\u76EE\u80CC\u666F\u3002\u4E0D\u8981\u8BB0\u4E00\u6B21\u6027\u95F2\u804A\u3001\u4E34\u65F6\u8BA1\u7B97\u3001\u5F53\u4E0B\u5C31\u591F\u7528\u7684\u4E0A\u4E0B\u6587\u3002`,
|
|
42956
42957
|
{
|
|
42957
|
-
action: external_exports.
|
|
42958
|
-
'
|
|
42958
|
+
action: external_exports.enum(["read", "append", "write"]).describe(
|
|
42959
|
+
'"read"\uFF08\u53D6\u5168\u6587\uFF09\u3001"append"\uFF08\u5728\u672B\u5C3E\u8FFD\u52A0 content\uFF09\u3001"write"\uFF08\u7528 content \u6574\u6BB5\u8986\u76D6\uFF0C\u901A\u5E38\u7528\u4E8E\u538B\u7F29\u91CD\u6574\uFF09\u3002'
|
|
42959
42960
|
),
|
|
42960
42961
|
content: external_exports.string().optional().describe(
|
|
42961
42962
|
'\u8981\u5199\u5165\u7684\u5185\u5BB9\u3002action="append" \u6216 "write" \u65F6\u5FC5\u586B\uFF1Baction="read" \u65F6\u5FFD\u7565\u3002'
|
|
@@ -43050,13 +43051,28 @@ action="append" \u8FFD\u52A0\u65B0\u5185\u5BB9\uFF08\u6700\u5E38\u7528\uFF0Ccont
|
|
|
43050
43051
|
agentId: deps.agentId,
|
|
43051
43052
|
scope: currentScopeKey
|
|
43052
43053
|
});
|
|
43053
|
-
|
|
43054
|
-
|
|
43055
|
-
|
|
43056
|
-
|
|
43057
|
-
|
|
43058
|
-
|
|
43059
|
-
|
|
43054
|
+
const now = Date.now();
|
|
43055
|
+
let myGroups;
|
|
43056
|
+
if (cachedScopes && now - cachedScopes.at < SCOPES_CACHE_MS) {
|
|
43057
|
+
myGroups = cachedScopes.groups;
|
|
43058
|
+
logger5.info("neural_list_scopes: cache hit", {
|
|
43059
|
+
agentId: deps.agentId,
|
|
43060
|
+
cachedAt: cachedScopes.at,
|
|
43061
|
+
ageMs: now - cachedScopes.at
|
|
43062
|
+
});
|
|
43063
|
+
} else {
|
|
43064
|
+
await deps.groupRegistry.refresh();
|
|
43065
|
+
myGroups = deps.groupRegistry.getMyGroups(deps.agentId).map((g2) => ({
|
|
43066
|
+
groupId: g2.groupId,
|
|
43067
|
+
name: g2.name
|
|
43068
|
+
}));
|
|
43069
|
+
cachedScopes = { groups: myGroups, at: now };
|
|
43070
|
+
logger5.info("neural_list_scopes: registry refreshed", {
|
|
43071
|
+
agentId: deps.agentId,
|
|
43072
|
+
scope: currentScopeKey,
|
|
43073
|
+
myGroupCount: myGroups.length
|
|
43074
|
+
});
|
|
43075
|
+
}
|
|
43060
43076
|
const lines = [];
|
|
43061
43077
|
const isCurSingle = currentScopeKey === "single";
|
|
43062
43078
|
lines.push(`- single \u2014 \u4F60\u548C\u7528\u6237\u7684 1:1 \u5355\u804A${isCurSingle ? " (\u4F60\u5F53\u524D\u6240\u5728)" : ""}`);
|
|
@@ -43086,30 +43102,24 @@ action="append" \u8FFD\u52A0\u65B0\u5185\u5BB9\uFF08\u6700\u5E38\u7528\uFF0Ccont
|
|
|
43086
43102
|
"read_chat_history",
|
|
43087
43103
|
`\u7FFB\u804A\u5929\u8BB0\u5F55\u2014\u2014\u5F53\u4F60\u67D0\u6BB5\u5BF9\u8BDD\u7EC6\u8282\u8BB0\u4E0D\u6E05\u4E86\uFF08\u7279\u522B\u662F\u7ECF\u5386\u8FC7 /compact \u4E4B\u540E\uFF09\uFF0C\u8C03\u8FD9\u4E2A\u5DE5\u5177\u3002
|
|
43088
43104
|
\u9ED8\u8BA4\u7FFB\u4F60\u5F53\u524D\u6240\u5728 scope \u7684\u5386\u53F2\uFF1B\u4E5F\u53EF\u4EE5\u6307\u5B9A\u770B\u81EA\u5DF1\u5176\u4ED6 scope \u7684\u5386\u53F2\uFF08\u4F60\u662F\u8BE5 scope \u7684\u6210\u5458\u5C31\u884C\uFF09\u3002
|
|
43089
|
-
\u8FD4\u56DE\
|
|
43105
|
+
\u8FD4\u56DE\u7ED3\u679C\u9876\u90E8\u5E26\u6458\u8981\uFF08\u603B\u6761\u6570 / \u7528\u6237\u6D88\u606F\u6570 / Agent \u6D88\u606F\u6570 / \u65F6\u95F4\u8DE8\u5EA6\uFF09\uFF0C\u968F\u540E\u662F\u6309\u65F6\u95F4\u5347\u5E8F\u7684\u6D88\u606F\u5217\u8868\u3002
|
|
43090
43106
|
\u5F80\u66F4\u65E9\u7FFB\u9875\uFF1A\u7528 before \u53C2\u6570\u4F20\u4E0A\u4E00\u6B21\u6700\u65E9\u4E00\u6761\u7684\u65F6\u95F4\u6233\u3002
|
|
43091
43107
|
|
|
43092
43108
|
\u4F60\u5F53\u524D\u6240\u5728 scope: ${currentScopeKey} (${currentScopeLabel})\u3002`,
|
|
43093
43109
|
{
|
|
43094
43110
|
scope: external_exports.string().optional().describe(
|
|
43095
|
-
'\u53EF\u9009\u3002"current"
|
|
43111
|
+
'\u53EF\u9009\u3002"current"\uFF08\u9ED8\u8BA4\uFF0C\u5F53\u524D scope\uFF09/ "single"\uFF08\u4F60\u7684 1:1 \u5355\u804A\uFF09/ "group:<\u7FA4 ID \u6216\u7FA4\u540D>"\uFF08\u4F60\u6240\u5728\u7684\u67D0\u4E2A\u7FA4\uFF09\u3002'
|
|
43096
43112
|
),
|
|
43097
|
-
limit: external_exports.
|
|
43098
|
-
"\u4E00\u6B21\u53D6\u591A\u5C11\u6761\uFF0C\u9ED8\u8BA4 20\uFF0C\u4E0A\u9650 50\
|
|
43113
|
+
limit: external_exports.number().int().min(1).max(50).optional().describe(
|
|
43114
|
+
"\u4E00\u6B21\u53D6\u591A\u5C11\u6761\uFF0C\u9ED8\u8BA4 20\uFF0C\u4E0A\u9650 50\u3002"
|
|
43099
43115
|
),
|
|
43100
43116
|
before: external_exports.string().optional().describe(
|
|
43101
|
-
"\u53EF\u9009\u3002ISO \u65F6\u95F4\u6233\uFF1B\u53EA\u8FD4\u56DE\u6B64\u65F6\u95F4\u4E4B\u524D\u7684\u6D88\u606F\uFF08\u7528\u4E8E\u5F80\u66F4\u65E9\u7FFB\u9875\uFF09\u3002"
|
|
43117
|
+
"\u53EF\u9009\u3002ISO \u65F6\u95F4\u6233\uFF1B\u53EA\u8FD4\u56DE\u6B64\u65F6\u95F4\u4E4B\u524D\u7684\u6D88\u606F\uFF08\u7528\u4E8E\u5F80\u66F4\u65E9\u7FFB\u9875\uFF09\u3002\u683C\u5F0F\u793A\u4F8B\uFF1A2024-01-15T10:30:00Z\u3002"
|
|
43102
43118
|
)
|
|
43103
43119
|
},
|
|
43104
43120
|
async (args) => {
|
|
43105
43121
|
const requestedScope = args.scope?.trim() || "current";
|
|
43106
|
-
|
|
43107
|
-
if (args.limit !== void 0 && args.limit.trim() !== "") {
|
|
43108
|
-
const parsed = Number(args.limit);
|
|
43109
|
-
if (Number.isFinite(parsed) && parsed >= 1) {
|
|
43110
|
-
limit = Math.min(50, Math.floor(parsed));
|
|
43111
|
-
}
|
|
43112
|
-
}
|
|
43122
|
+
const limit = Math.min(50, Math.max(1, Math.floor(args.limit ?? 20)));
|
|
43113
43123
|
logger5.info("read_chat_history tool called", {
|
|
43114
43124
|
agentId: deps.agentId,
|
|
43115
43125
|
scope: currentScopeKey,
|
|
@@ -43235,20 +43245,21 @@ action="append" \u8FFD\u52A0\u65B0\u5185\u5BB9\uFF08\u6700\u5E38\u7528\uFF0Ccont
|
|
|
43235
43245
|
};
|
|
43236
43246
|
}
|
|
43237
43247
|
const lines = [];
|
|
43238
|
-
|
|
43239
|
-
|
|
43240
|
-
|
|
43241
|
-
);
|
|
43248
|
+
const firstTs = messages[0].createdAt;
|
|
43249
|
+
const lastTs = messages[messages.length - 1].createdAt;
|
|
43250
|
+
const userMsgCount = messages.filter((m2) => m2.role === "user").length;
|
|
43251
|
+
const agentMsgCount = messages.filter((m2) => m2.role === "agent").length;
|
|
43252
|
+
lines.push(`[\u6458\u8981] ${scopeLabel}\uFF0C\u8FD4\u56DE ${messages.length} \u6761\uFF08\u7528\u6237 ${userMsgCount} / Agent ${agentMsgCount}\uFF09\uFF0C\u65F6\u95F4 ${firstTs} \u2192 ${lastTs}${hasMore ? "\uFF1B\u8FD8\u6709\u66F4\u65E9\u7684\uFF0C\u53EF\u7528 before \u7FFB\u9875" : ""}`);
|
|
43242
43253
|
lines.push("");
|
|
43243
43254
|
for (const m2 of messages) {
|
|
43244
43255
|
const sender = m2.role === "user" ? "\u7528\u6237" : m2.senderAgentName ?? m2.senderAgentId ?? "system";
|
|
43245
|
-
const content = m2.content.length >
|
|
43256
|
+
const content = m2.content.length > 500 ? `${m2.content.slice(0, 500)}\u2026` : m2.content;
|
|
43246
43257
|
lines.push(`[${m2.createdAt}] ${sender}: ${content}`);
|
|
43247
43258
|
}
|
|
43248
43259
|
if (hasMore) {
|
|
43249
43260
|
lines.push("");
|
|
43250
43261
|
lines.push(
|
|
43251
|
-
`\u7EE7\u7EED\u7FFB\uFF1Aread_chat_history(before="${
|
|
43262
|
+
`\u7EE7\u7EED\u7FFB\uFF1Aread_chat_history(before="${firstTs}", scope="${requestedScope}")`
|
|
43252
43263
|
);
|
|
43253
43264
|
}
|
|
43254
43265
|
logger5.info("read_chat_history returned", {
|
|
@@ -43279,9 +43290,13 @@ action="append" \u8FFD\u52A0\u65B0\u5185\u5BB9\uFF08\u6700\u5E38\u7528\uFF0Ccont
|
|
|
43279
43290
|
`\u67E5\u8BE2\u7CFB\u7EDF\u901A\u8BAF\u5F55\u2014\u2014\u5217\u51FA\u5F53\u524D AHChat \u5B9E\u4F8B\u91CC\u7684\u6240\u6709 Agent \u4E0E\u4EBA\u7C7B\u7528\u6237\u3002
|
|
43280
43291
|
\u8FD4\u56DE\u7ED3\u6784\u662F\u4E00\u6BB5 Markdown\uFF1A\u6BCF\u4E00\u6761\u542B id / \u540D\u5B57 / \u89D2\u8272\u3002\u4F1A\u6807\u6CE8\u54EA\u4E00\u6761\u662F"\u4F60\u81EA\u5DF1"\uFF0C\u4EE5\u53CA\u4F60\u548C\u54EA\u4E9B Agent \u5DF2\u7ECF\u5171\u5728\u67D0\u4E2A\u7FA4\u91CC\u3002\u4EBA\u7C7B\u7528\u6237\u4F1A\u5E26 (\u4EBA\u7C7B) \u6807\u8BB0\u3002
|
|
43281
43292
|
\u901A\u5E38\u4F60\u5728\u7528\u6237\u63D0\u5230\u5177\u4F53\u540C\u4E8B\u59D3\u540D\u3001\u6216\u601D\u8003"\u8BE5\u62C9\u8C01\u8FDB\u7FA4\u534F\u4F5C"\u65F6\u8C03\u4E00\u6B21\uFF1B\u4E0D\u8981\u6BCF\u8F6E\u90FD\u67E5\u3002
|
|
43293
|
+
\u652F\u6301 filter\uFF08\u6309\u540D\u5B57\u6216\u89D2\u8272\u6A21\u7CCA\u641C\u7D22\uFF09\u548C limit\uFF08\u9650\u5236\u8FD4\u56DE\u6761\u6570\uFF09\u53C2\u6570\u3002
|
|
43282
43294
|
\u8981\u628A\u4EBA\u7C7B\u62C9\u8FDB\u7FA4\uFF1A\u5728 create_group / add_to_group \u7684 member_ids / agent_ids \u91CC\u5E26\u4E0A**\u8BF7\u6C42\u8005\u7684\u4EBA\u7C7B id**\uFF08\u5373\u5217\u8868\u91CC\u5E26"(\u4EBA\u7C7B)"\u6807\u8BB0\u7684\u90A3\u4E00\u6761\uFF1B\u591A\u7528\u6237\u6A21\u5F0F\u4E0B\u6BCF\u4E2A\u7528\u6237\u90FD\u6709\u81EA\u5DF1\u72EC\u7ACB\u7684 id\uFF0C\u4F8B\u5982 agt_usr_XXX\uFF1B\u8001\u7684\u5355\u7528\u6237\u6A21\u5F0F\u4E0B\u662F agt_usr_self\uFF09\u3002\u4E0D\u8981\u786C\u7F16\u7801 agt_usr_self\u2014\u2014\u4EE5 list_contacts \u5B9E\u9645\u8FD4\u56DE\u7684 id \u4E3A\u51C6\u3002`,
|
|
43283
|
-
{
|
|
43284
|
-
|
|
43295
|
+
{
|
|
43296
|
+
filter: external_exports.string().optional().describe("\u53EF\u9009\u3002\u6309\u540D\u5B57\u6216\u89D2\u8272\u6A21\u7CCA\u8FC7\u6EE4\uFF08\u4E0D\u533A\u5206\u5927\u5C0F\u5199\uFF09\u3002"),
|
|
43297
|
+
limit: external_exports.number().int().min(1).max(200).optional().describe("\u6700\u591A\u8FD4\u56DE\u591A\u5C11\u6761\uFF0C\u9ED8\u8BA4\u4E0D\u9650\u3002")
|
|
43298
|
+
},
|
|
43299
|
+
async (args) => {
|
|
43285
43300
|
logger5.info("list_contacts tool called", { agentId: deps.agentId, scope: currentScopeKey });
|
|
43286
43301
|
try {
|
|
43287
43302
|
await deps.agentRegistry.refresh();
|
|
@@ -43291,15 +43306,22 @@ action="append" \u8FFD\u52A0\u65B0\u5185\u5BB9\uFF08\u6700\u5E38\u7528\uFF0Ccont
|
|
|
43291
43306
|
error: e7
|
|
43292
43307
|
});
|
|
43293
43308
|
}
|
|
43294
|
-
|
|
43309
|
+
let all = filterContactsByOwner(
|
|
43295
43310
|
deps.agentRegistry.getAll(),
|
|
43296
43311
|
contactOwnerId(deps.agentRegistry, deps.agentId)
|
|
43297
43312
|
);
|
|
43313
|
+
const q = args?.filter?.toLowerCase().trim();
|
|
43314
|
+
if (q) {
|
|
43315
|
+
all = all.filter(
|
|
43316
|
+
(a) => a.name.toLowerCase().includes(q) || a.role && a.role.toLowerCase().includes(q)
|
|
43317
|
+
);
|
|
43318
|
+
}
|
|
43319
|
+
const capped = args?.limit != null ? all.slice(0, args.limit) : all;
|
|
43298
43320
|
const myGroups = deps.groupRegistry.getMyGroups(deps.agentId);
|
|
43299
43321
|
const sharedGroupsOf = (otherId) => myGroups.filter((g2) => g2.members.includes(otherId)).map((g2) => g2.name);
|
|
43300
43322
|
const lines = [];
|
|
43301
43323
|
let humanCount = 0;
|
|
43302
|
-
for (const a of
|
|
43324
|
+
for (const a of capped) {
|
|
43303
43325
|
const isHuman = a.kind === "human";
|
|
43304
43326
|
if (isHuman) humanCount += 1;
|
|
43305
43327
|
const kindMark = isHuman ? " (\u4EBA\u7C7B)" : "";
|
|
@@ -43312,7 +43334,10 @@ action="append" \u8FFD\u52A0\u65B0\u5185\u5BB9\uFF08\u6700\u5E38\u7528\uFF0Ccont
|
|
|
43312
43334
|
const sharedMark = shared.length > 0 ? ` (\u5DF2\u4E0E\u4F60\u5171\u7FA4: ${shared.join("\u3001")})` : "";
|
|
43313
43335
|
lines.push(`- ${a.name} (${a.id})${roleStr}${kindMark}${sharedMark}`);
|
|
43314
43336
|
}
|
|
43315
|
-
const
|
|
43337
|
+
const total = all.length;
|
|
43338
|
+
const shown = capped.length;
|
|
43339
|
+
const header = q ? `\u901A\u8BAF\u5F55\u641C\u7D22\u7ED3\u679C\uFF08\u5171 ${total} \u4F4D\uFF0C\u5176\u4E2D\u4EBA\u7C7B ${humanCount} \u4F4D\uFF0C\u5339\u914D "${args?.filter}" \u7684 ${shown} \u4F4D\uFF09\uFF1A` : args?.limit != null && shown < total ? `AHChat \u7CFB\u7EDF\u901A\u8BAF\u5F55\uFF08\u5171 ${total} \u4F4D\uFF0C\u5176\u4E2D\u4EBA\u7C7B ${humanCount} \u4F4D\uFF0C\u8FD4\u56DE\u524D ${shown} \u4F4D\uFF09\uFF1A` : `AHChat \u7CFB\u7EDF\u901A\u8BAF\u5F55\uFF08\u5171 ${total} \u4F4D\uFF0C\u5176\u4E2D\u4EBA\u7C7B ${humanCount} \u4F4D\uFF09\uFF1A`;
|
|
43340
|
+
const text = shown === 0 ? q ? `\u672A\u627E\u5230\u4E0E "${args?.filter}" \u5339\u914D\u7684\u8054\u7CFB\u4EBA\u3002` : "\u5F53\u524D\u7CFB\u7EDF\u91CC\u8FD8\u6CA1\u6709\u4EFB\u4F55 Agent\u3002" : [header, "", ...lines].join("\n");
|
|
43316
43341
|
logger5.info("list_contacts returned", {
|
|
43317
43342
|
agentId: deps.agentId,
|
|
43318
43343
|
count: all.length,
|
|
@@ -43332,7 +43357,7 @@ action="append" \u8FFD\u52A0\u65B0\u5185\u5BB9\uFF08\u6700\u5E38\u7528\uFF0Ccont
|
|
|
43332
43357
|
|
|
43333
43358
|
\u81F3\u5C11\u9700\u8981\u62C9 1 \u4E2A\u5176\u4ED6 Agent\uFF08\u542B/\u4E0D\u542B\u4F60\u81EA\u5DF1\u540E\u603B\u6570 \u2265 2\uFF09\u3002`,
|
|
43334
43359
|
{
|
|
43335
|
-
name: external_exports.string().describe("\u7FA4\u540D\uFF08\u4E0D\u80FD\u4E3A\u7A7A\uFF09"),
|
|
43360
|
+
name: external_exports.string().min(1).describe("\u7FA4\u540D\uFF08\u4E0D\u80FD\u4E3A\u7A7A\uFF09"),
|
|
43336
43361
|
member_ids: external_exports.array(external_exports.string()).describe(
|
|
43337
43362
|
"\u8981\u62C9\u8FDB\u7FA4\u7684\u6210\u5458 ID \u6570\u7EC4\uFF08Agent \u6216\u4EBA\u7C7B agt_usr_self\uFF09\u3002\u6240\u6709 ID \u5FC5\u987B\u5B58\u5728\u4E8E list_contacts \u8FD4\u56DE\u7ED3\u679C\u4E2D\u3002\u5F53 join_as_creator=true\uFF08\u9ED8\u8BA4\uFF09\u65F6\u4E0D\u542B\u4F60\u81EA\u5DF1\u4F1A\u81EA\u52A8\u8865\u3001\u542B\u4E5F\u4E0D\u4F1A\u91CD\u590D\uFF1Bjoin_as_creator=false \u65F6\u5373\u4F7F\u4F60\u51FA\u73B0\u5728\u91CC\u9762\u4E5F\u4F1A\u88AB\u53BB\u6389\u3002"
|
|
43338
43363
|
),
|
|
@@ -43456,8 +43481,8 @@ action="append" \u8FFD\u52A0\u65B0\u5185\u5BB9\uFF08\u6700\u5E38\u7528\uFF0Ccont
|
|
|
43456
43481
|
\u4E0D\u8981\u6BCF\u6B21\u9700\u8981\u65B0\u534F\u4F5C\u5C31 create_group \u65B0\u5EFA\u2014\u2014\u540C\u6837\u7684\u4E24\u4E2A\u4EBA\u53EF\u4EE5\u6709\u591A\u4E2A\u7FA4\uFF08\u4E0D\u540C\u8BDD\u9898/\u4EFB\u52A1\uFF09\uFF0C
|
|
43457
43482
|
\u4F46\u4E0D\u8981\u65E0\u610F\u4E49\u5730\u91CD\u590D\u5EFA\u7FA4\u3002`,
|
|
43458
43483
|
{
|
|
43459
|
-
group: external_exports.string().describe(
|
|
43460
|
-
'\u76EE\u6807\u7FA4\
|
|
43484
|
+
group: external_exports.string().min(1).describe(
|
|
43485
|
+
'\u76EE\u6807\u7FA4\u3002group ID\uFF08\u5982 "grp_xxx"\uFF09\u6216\u7FA4\u540D\uFF08\u6A21\u7CCA\u5339\u914D\uFF09\u3002\u53EF\u4ECE neural_list_scopes() \u8FD4\u56DE\u7684\u5217\u8868\u4E2D\u786E\u8BA4\u3002'
|
|
43461
43486
|
),
|
|
43462
43487
|
agent_ids: external_exports.array(external_exports.string()).describe(
|
|
43463
43488
|
"\u8981\u62C9\u8FDB\u7FA4\u7684\u6210\u5458 ID \u6570\u7EC4\uFF08Agent \u6216\u4EBA\u7C7B agt_usr_self\uFF09\u3002\u6240\u6709 ID \u5FC5\u987B\u5B58\u5728\u4E8E list_contacts \u8FD4\u56DE\u7ED3\u679C\u4E2D\u3002"
|
|
@@ -43603,7 +43628,7 @@ action="append" \u8FFD\u52A0\u65B0\u5185\u5BB9\uFF08\u6700\u5E38\u7528\uFF0Ccont
|
|
|
43603
43628
|
- \u4E00\u6B21\u6CA1\u542C\u61C2\u3001\u4E00\u6B21\u88AB\u53CD\u9A73\u5C31\u9000\u2014\u2014\u8FD9\u662F\u8FC7\u654F\u53CD\u5E94\u4E0D\u662F\u5224\u65AD\uFF1B
|
|
43604
43629
|
- \u7528\u6237\u6CA1\u8BA9\u9000\u3001\u7FA4\u91CC\u4E5F\u6CA1\u660E\u786E\u8868\u6001\u7684\u60C5\u51B5\u4E0B"\u81EA\u5DF1\u89C9\u5F97\u6CA1\u7528"\u2014\u2014\u4FDD\u6301\u6C89\u9ED8 (<no-reply/>) \u5373\u53EF\u3002`,
|
|
43605
43630
|
{
|
|
43606
|
-
group: external_exports.string().describe('\u8981\u9000\u51FA\u7684\u7FA4\u3002group ID\uFF08\u5982 "grp_xxx"\uFF09\u6216\u7FA4\u540D\uFF08\u6A21\u7CCA\u5339\u914D\uFF09\u3002')
|
|
43631
|
+
group: external_exports.string().min(1).describe('\u8981\u9000\u51FA\u7684\u7FA4\u3002group ID\uFF08\u5982 "grp_xxx"\uFF09\u6216\u7FA4\u540D\uFF08\u6A21\u7CCA\u5339\u914D\uFF09\u3002')
|
|
43607
43632
|
},
|
|
43608
43633
|
async (args) => {
|
|
43609
43634
|
const rawGroup = (args.group ?? "").trim();
|
|
@@ -43686,7 +43711,7 @@ action="append" \u8FFD\u52A0\u65B0\u5185\u5BB9\uFF08\u6700\u5E38\u7528\uFF0Ccont
|
|
|
43686
43711
|
- \u4E00\u6B21\u5C0F\u51B2\u7A81\u5C31\u8E22\u2014\u2014\u7ED9 Agent / \u4EBA\u7C7B\u4E00\u4E9B\u81EA\u6211\u4FEE\u6B63\u7684\u7A7A\u95F4\uFF1B
|
|
43687
43712
|
- \u4F60\u4E0D\u662F\u7FA4\u4E3B\u2014\u2014\u4F60\u6CA1\u8FD9\u4E2A\u6743\u9650\uFF0C\u8C03\u4E86\u4E5F\u4F1A\u5931\u8D25\u3002\u5EFA\u8BAE\u6539\u4E3A neural_send \u8BA9\u7FA4\u4E3B\u81EA\u5DF1\u6765\u51B3\u5B9A\u3002`,
|
|
43688
43713
|
{
|
|
43689
|
-
group: external_exports.string().describe("\u76EE\u6807\u7FA4\u3002group ID \u6216\u7FA4\u540D\uFF08\u6A21\u7CCA\u5339\u914D\uFF09\u3002"),
|
|
43714
|
+
group: external_exports.string().min(1).describe("\u76EE\u6807\u7FA4\u3002group ID \u6216\u7FA4\u540D\uFF08\u6A21\u7CCA\u5339\u914D\uFF09\u3002"),
|
|
43690
43715
|
member_ids: external_exports.array(external_exports.string()).describe(
|
|
43691
43716
|
"\u8981\u8E22\u51FA\u7684\u6210\u5458 id \u6570\u7EC4\u3002\u53EF\u4EE5\u662F Agent id \u6216 agt_usr_self\uFF08\u4EBA\u7C7B\u7528\u6237\uFF09\u3002\u6240\u6709 id \u5FC5\u987B\u5F53\u524D\u662F\u8BE5\u7FA4\u6210\u5458\u3002"
|
|
43692
43717
|
)
|
|
@@ -43859,16 +43884,17 @@ action="append" \u8FFD\u52A0\u65B0\u5185\u5BB9\uFF08\u6700\u5E38\u7528\uFF0Ccont
|
|
|
43859
43884
|
"fetch_logs",
|
|
43860
43885
|
`\u62C9\u53D6\u7CFB\u7EDF\u65E5\u5FD7\uFF08\u6309\u65F6\u95F4\u7A97 + \u53EF\u9009 traceId / module / level \u8FC7\u6EE4\uFF09\u3002
|
|
43861
43886
|
\u8BFB SKILL "log-analysis" \u540E\u624D\u7528\u8FD9\u4E2A\u5DE5\u5177\u3002\u4E00\u6B21\u8C03\u7528\u53EA\u80FD\u62C9\u4E00\u4E2A source\uFF08server \u6216 bridge\uFF09\uFF0C\u5168\u666F\u9700\u8981\u4E24\u6B21\u3002
|
|
43862
|
-
limit \u9ED8\u8BA4 500\uFF0C\u786C\u4E0A\u9650 2000\u3002\u8FD4\u56DE\u6BCF\u884C\u5E26 file / lineNum
|
|
43887
|
+
limit \u9ED8\u8BA4 500\uFF0C\u786C\u4E0A\u9650 2000\u3002\u8FD4\u56DE\u7ED3\u679C\u9876\u90E8\u5E26\u5206\u7EA7\u7EDF\u8BA1\uFF08ERROR/WARN/INFO \u5404\u591A\u5C11\u6761\uFF09\uFF0C\u6309\u65F6\u95F4\u5347\u5E8F\u6392\u5217\u3002\u6BCF\u884C\u5E26 file / lineNum\uFF0C\u5F15\u7528\u65E5\u5FD7\u65F6\u5FC5\u987B\u7CBE\u786E\u5199 [<file>:L<lineNum>]\u3002
|
|
43888
|
+
\u6CE8\u610F\uFF1A\u5982\u679C\u7ED3\u679C\u8FC7\u957F\u4F1A\u88AB\u622A\u65AD\uFF0Cheader \u4F1A\u6807\u6CE8"\u5DF2\u622A\u65AD"\u2014\u2014\u6B64\u65F6\u7F29\u5C0F\u65F6\u95F4\u7A97\u6216\u52A0 module/traceId \u8FC7\u6EE4\u518D\u67E5\u3002`,
|
|
43863
43889
|
{
|
|
43864
|
-
source: external_exports.
|
|
43865
|
-
start_iso: external_exports.string().describe('\u8D77\u59CB\u65F6\u95F4\uFF0CISO 8601 \u6216\u76F8\u5BF9\uFF1A"now-5m" / "now-1h" / "now-24h"\u3002'),
|
|
43890
|
+
source: external_exports.enum(["server", "bridge"]).describe('\u65E5\u5FD7\u6765\u6E90\uFF0C\u5FC5\u987B\u662F "server" \u6216 "bridge" \u4E4B\u4E00\u3002'),
|
|
43891
|
+
start_iso: external_exports.string().describe('\u8D77\u59CB\u65F6\u95F4\uFF0CISO 8601 \u6216\u76F8\u5BF9\u683C\u5F0F\uFF1A"now-5m" / "now-1h" / "now-24h"\u3002'),
|
|
43866
43892
|
end_iso: external_exports.string().describe('\u7ED3\u675F\u65F6\u95F4\uFF0CISO 8601 \u6216 "now"\u3002'),
|
|
43867
|
-
level_min: external_exports.
|
|
43893
|
+
level_min: external_exports.enum(["TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL"]).optional().describe("\u6700\u4F4E\u65E5\u5FD7\u7EA7\u522B\uFF0C\u4E0D\u4F20\u9ED8\u8BA4 INFO\u3002"),
|
|
43868
43894
|
trace_id: external_exports.string().optional().describe("\u8FC7\u6EE4\u7279\u5B9A traceId\uFF08\u7CBE\u786E\u5339\u914D\uFF09\u3002"),
|
|
43869
43895
|
module: external_exports.string().optional().describe('\u8FC7\u6EE4 module \u524D\u7F00\uFF08\u5982 "ws.handler" / "agent.manager"\uFF09\u3002'),
|
|
43870
43896
|
msg_contains: external_exports.string().optional().describe("msg \u5B50\u4E32\u8FC7\u6EE4\uFF08\u533A\u5206\u5927\u5C0F\u5199\uFF09\u3002"),
|
|
43871
|
-
limit: external_exports.
|
|
43897
|
+
limit: external_exports.number().int().min(1).max(2e3).optional().describe("\u8FD4\u56DE\u6761\u6570\u4E0A\u9650\uFF0C\u9ED8\u8BA4 500\uFF0C\u6700\u5927 2000\u3002")
|
|
43872
43898
|
},
|
|
43873
43899
|
async (args) => {
|
|
43874
43900
|
if (!deps.isSmith) {
|
|
@@ -43895,7 +43921,7 @@ limit \u9ED8\u8BA4 500\uFF0C\u786C\u4E0A\u9650 2000\u3002\u8FD4\u56DE\u6BCF\u884
|
|
|
43895
43921
|
levelMin: args.level_min,
|
|
43896
43922
|
limit: args.limit
|
|
43897
43923
|
});
|
|
43898
|
-
const parsedLimit = typeof args.limit === "
|
|
43924
|
+
const parsedLimit = typeof args.limit === "number" && Number.isFinite(args.limit) ? args.limit : 500;
|
|
43899
43925
|
try {
|
|
43900
43926
|
const url2 = `${deps.serverApiUrl.replace(/\/$/, "")}/api/admin/logs`;
|
|
43901
43927
|
const body = {
|
|
@@ -43937,7 +43963,14 @@ limit \u9ED8\u8BA4 500\uFF0C\u786C\u4E0A\u9650 2000\u3002\u8FD4\u56DE\u6BCF\u884
|
|
|
43937
43963
|
const traceStr = e7.traceId ? ` traceId=${e7.traceId}` : "";
|
|
43938
43964
|
return `[${e7.file}:L${e7.lineNum}] ${e7.ts} ${e7.level} ${e7.module}: ${e7.msg}${traceStr}${dataStr}${errStr}`;
|
|
43939
43965
|
});
|
|
43940
|
-
const
|
|
43966
|
+
const errorCount = json2.entries.filter((e7) => e7.level === "ERROR" || e7.level === "FATAL").length;
|
|
43967
|
+
const warnCount = json2.entries.filter((e7) => e7.level === "WARN").length;
|
|
43968
|
+
const infoCount = json2.entries.filter((e7) => e7.level === "INFO").length;
|
|
43969
|
+
const traceCount = json2.entries.filter((e7) => e7.level === "TRACE" || e7.level === "DEBUG").length;
|
|
43970
|
+
const header = [
|
|
43971
|
+
`[${source}] \u5171\u626B ${json2.totalScanned} \u884C\uFF0C\u547D\u4E2D ${json2.entries.length} \u6761`,
|
|
43972
|
+
` ERROR/FATAL: ${errorCount} | WARN: ${warnCount} | INFO: ${infoCount} | TRACE/DEBUG: ${traceCount}`
|
|
43973
|
+
].join("\n") + (json2.truncated ? "\n\uFF08\u5DF2\u622A\u65AD\uFF0C\u8BF7\u7F29\u5C0F\u65F6\u95F4\u7A97\u6216\u52A0\u8FC7\u6EE4\u6761\u4EF6\u518D\u67E5\uFF09" : "");
|
|
43941
43974
|
const text = [header, "", ...lines].join("\n");
|
|
43942
43975
|
return { content: [{ type: "text", text }] };
|
|
43943
43976
|
} catch (e7) {
|
|
@@ -43974,15 +44007,18 @@ limit \u9ED8\u8BA4 500\uFF0C\u786C\u4E0A\u9650 2000\u3002\u8FD4\u56DE\u6BCF\u884
|
|
|
43974
44007
|
- \u4E0D\u8981\u4F20"\u51C6\u5907\u5DE5\u4F5C\u8BF7\u4FDD\u6301\u6C89\u9ED8"\u8FD9\u7C7B\u6307\u4EE4\u2014\u2014\u4F1A\u4EA7\u751F\u4E00\u4E2A\u65E0\u610F\u4E49\u7684\u7A7A\u5BF9\u8BDD
|
|
43975
44008
|
- \u5DF2\u7ECF\u5728\u5EFA\u7FA4\u7684\u573A\u666F\uFF08\u591A Agent \u56E2\u961F\uFF09\uFF0C\u7531 Leader \u5728\u7FA4\u91CC @ \u7528\u6237\u5373\u53EF\uFF0C**\u4E0D\u8981**\u7ED9\u5355\u4E2A\u6210\u5458\u90FD\u4F20 initial_instruction`,
|
|
43976
44009
|
{
|
|
43977
|
-
name: external_exports.string().describe("Agent \u540D\u5B57\u3002\u683C\u5F0F\u300C\u4EBA\u540D-\u804C\u80FD\u300D\u5982 Tim-\u540E\u7AEF\u3001Sara-\u4EA7\u54C1\u3001Kai-\u6D4B\u8BD5\u3002\u4EBA\u540D\u9009\u77ED\u82F1\u6587\u540D\uFF083-5\u5B57\u6BCD\uFF09\uFF0C\u804C\u80FD\u7528\u4E2D\u6587\u7B80\u5199\u3002"),
|
|
44010
|
+
name: external_exports.string().min(1).describe("Agent \u540D\u5B57\u3002\u683C\u5F0F\u300C\u4EBA\u540D-\u804C\u80FD\u300D\u5982 Tim-\u540E\u7AEF\u3001Sara-\u4EA7\u54C1\u3001Kai-\u6D4B\u8BD5\u3002\u4EBA\u540D\u9009\u77ED\u82F1\u6587\u540D\uFF083-5\u5B57\u6BCD\uFF09\uFF0C\u804C\u80FD\u7528\u4E2D\u6587\u7B80\u5199\u3002"),
|
|
43978
44011
|
role: external_exports.string().describe('\u89D2\u8272\u63CF\u8FF0\uFF0C\u5982 "Backend Developer", "QA Engineer"'),
|
|
43979
|
-
system_prompt: external_exports.string().describe("\u8BE5 Agent \u7684 system prompt\uFF0C\u5B9A\u4E49\u4EBA\u683C\u3001\u4E13\u957F\u3001\u884C\u4E3A\u51C6\u5219"),
|
|
43980
|
-
tier: external_exports.
|
|
44012
|
+
system_prompt: external_exports.string().describe("\u8BE5 Agent \u7684 system prompt\uFF0C\u5B9A\u4E49\u4EBA\u683C\u3001\u4E13\u957F\u3001\u884C\u4E3A\u51C6\u5219\u3002\u4E0D\u80FD\u4E3A\u7A7A\u3002"),
|
|
44013
|
+
tier: external_exports.enum(["smart", "balanced", "fast"]).describe("\u80FD\u529B\u6863\u4F4D\uFF1Asmart\uFF08\u65D7\u8230\uFF0C\u590D\u6742\u4EFB\u52A1\uFF09\u3001balanced\uFF08\u6807\u51C6\uFF0C\u5E38\u89C4\u4EFB\u52A1\uFF09\u3001fast\uFF08\u8F7B\u91CF\uFF0C\u7B80\u5355\u4EFB\u52A1\uFF09\u3002"),
|
|
43981
44014
|
avatar: external_exports.string().optional().describe(
|
|
43982
44015
|
"\u5934\u50CF key\uFF0C\u4ECE\u4EE5\u4E0B\u9009\u4E00\u4E2A\u6700\u5339\u914D\u89D2\u8272\u7684\uFF1Aavatar_dev\uFF08\u5F00\u53D1\uFF09, avatar_pm\uFF08\u4EA7\u54C1/\u7BA1\u7406\uFF09, avatar_designer\uFF08\u8BBE\u8BA1\uFF09, avatar_qa\uFF08\u6D4B\u8BD5/QA\uFF09, avatar_writer\uFF08\u5199\u4F5C/\u6587\u6863\uFF09, avatar_analyst\uFF08\u5206\u6790/\u6570\u636E\uFF09, avatar_coach\uFF08\u654F\u6377\u6559\u7EC3/\u5E26\u6559\uFF09, avatar_scientist\uFF08\u7814\u7A76/\u7B97\u6CD5\uFF09, avatar_lawyer\uFF08\u6CD5\u52A1/\u5408\u89C4\uFF09, avatar_human_man\uFF08\u901A\u7528\u7537\u6027\uFF09, avatar_human_woman\uFF08\u901A\u7528\u5973\u6027\uFF09, avatar_human_nerd\uFF08\u6781\u5BA2\uFF09, avatar_human_cool\uFF08\u9177\uFF09, avatar_human_cowboy\uFF08\u72C2\u91CE\uFF09, avatar_human_artist\uFF08\u827A\u672F\u5BB6\uFF09\u3002\u7559\u7A7A\u5219\u7528\u9ED8\u8BA4 avatar_default\uFF08\u{1F916}\uFF09\u3002"
|
|
43983
44016
|
),
|
|
43984
44017
|
initial_instruction: external_exports.string().optional().describe(
|
|
43985
44018
|
'\u53EF\u9009\u3002\u521B\u5EFA\u540E\u7ACB\u5373\u4E0B\u53D1\u7ED9\u65B0 Agent \u7684\u4E00\u53E5\u8BDD\u6307\u4EE4\u3002\u5178\u578B\uFF1A"\u8BF7\u7528 1-2 \u53E5\u8BDD\u5411\u7528\u6237\u505A\u81EA\u6211\u4ECB\u7ECD\uFF0C\u8BF4\u660E\u4F60\u7684\u4E13\u957F"\u3002\u53EA\u5728\u7528\u6237\u660E\u786E\u8981"\u521B\u5EFA\u4E00\u4E2A\u5355 Agent"\u4E14\u5E0C\u671B\u8BE5 Agent \u7ACB\u5373\u9732\u9762\u65F6\u4F20\u3002\u56E2\u961F\u573A\u666F\u8BF7\u52FF\u4F20\u2014\u2014\u7531 Leader \u5728\u7FA4\u91CC\u6253\u62DB\u547C\u3002'
|
|
44019
|
+
),
|
|
44020
|
+
working_directory: external_exports.string().optional().describe(
|
|
44021
|
+
"\u53EF\u9009\u3002\u8BE5 Agent \u7684\u5DE5\u4F5C\u76EE\u5F55\u7EDD\u5BF9\u8DEF\u5F84\u3002\u4E0D\u4F20\u5219\u7531\u7CFB\u7EDF\u81EA\u52A8\u5206\u914D\u3002"
|
|
43986
44022
|
)
|
|
43987
44023
|
},
|
|
43988
44024
|
async (args) => {
|
|
@@ -44009,15 +44045,9 @@ limit \u9ED8\u8BA4 500\uFF0C\u786C\u4E0A\u9650 2000\u3002\u8FD4\u56DE\u6BCF\u884
|
|
|
44009
44045
|
};
|
|
44010
44046
|
}
|
|
44011
44047
|
const tier = args.tier ?? "balanced";
|
|
44012
|
-
const validTiers = ["smart", "balanced", "fast"];
|
|
44013
|
-
if (!validTiers.includes(tier)) {
|
|
44014
|
-
return {
|
|
44015
|
-
content: [{ type: "text", text: `[create_agent] \u9519\u8BEF\uFF1Atier \u5FC5\u987B\u662F smart/balanced/fast \u4E4B\u4E00\uFF0C\u6536\u5230 "${tier}"` }],
|
|
44016
|
-
isError: true
|
|
44017
|
-
};
|
|
44018
|
-
}
|
|
44019
44048
|
const avatar = args.avatar && String(args.avatar).trim() || "";
|
|
44020
44049
|
const initialInstruction = args.initial_instruction && String(args.initial_instruction).trim() || "";
|
|
44050
|
+
const workingDirectory = args.working_directory && String(args.working_directory).trim() || "";
|
|
44021
44051
|
let agentConfig;
|
|
44022
44052
|
if (deps.bridgeToken && deps.serverApiUrl) {
|
|
44023
44053
|
try {
|
|
@@ -44046,6 +44076,9 @@ limit \u9ED8\u8BA4 500\uFF0C\u786C\u4E0A\u9650 2000\u3002\u8FD4\u56DE\u6BCF\u884
|
|
|
44046
44076
|
if (agentConfig) {
|
|
44047
44077
|
body.config = agentConfig;
|
|
44048
44078
|
}
|
|
44079
|
+
if (workingDirectory) {
|
|
44080
|
+
body.workingDirectory = workingDirectory;
|
|
44081
|
+
}
|
|
44049
44082
|
logger5.info("create_agent tool called", {
|
|
44050
44083
|
agentId: deps.agentId,
|
|
44051
44084
|
requestedBy: deps.agentId,
|
|
@@ -44120,14 +44153,205 @@ limit \u9ED8\u8BA4 500\uFF0C\u786C\u4E0A\u9650 2000\u3002\u8FD4\u56DE\u6BCF\u884
|
|
|
44120
44153
|
},
|
|
44121
44154
|
{}
|
|
44122
44155
|
) : null;
|
|
44156
|
+
const updateAgentTool = deps.isSmith && deps.serverApiUrl ? bs(
|
|
44157
|
+
"update_agent_profile",
|
|
44158
|
+
`\u66F4\u65B0\u5DF2\u6709 Agent \u7684\u6863\u6848\uFF08\u540D\u5B57\u3001\u89D2\u8272\u63CF\u8FF0\u3001\u5934\u50CF\u3001system prompt \u6216\u80FD\u529B\u6863\u4F4D\uFF09\u3002
|
|
44159
|
+
\u53EA\u6709\u4F60\uFF08Smith\uFF09\u80FD\u8C03\u7528\u6B64\u5DE5\u5177\u3002\u8C03\u7528\u524D\u5148\u7528 list_contacts() \u786E\u8BA4\u76EE\u6807 Agent \u7684 id\u3002
|
|
44160
|
+
\u53EF\u4EE5\u53EA\u66F4\u65B0\u5176\u4E2D\u4E00\u9879\uFF08\u5982\u53EA\u6539\u5934\u50CF\u6216\u53EA\u6539\u6863\u4F4D\uFF09\uFF0C\u4E5F\u53EF\u4EE5\u4E00\u6B21\u66F4\u65B0\u591A\u9879\u3002
|
|
44161
|
+
**\u6CE8\u610F\u4E8B\u9879\uFF1A**
|
|
44162
|
+
- \u4FEE\u6539 system_prompt \u6216\u6863\u4F4D\u540E\uFF0CAgent \u7684 SDK session \u4E0D\u4F1A\u81EA\u52A8\u91CD\u5EFA\u2014\u2014\u4E0B\u6B21 turn \u4F1A\u81EA\u7136\u4F7F\u7528\u65B0\u8BBE\u7F6E
|
|
44163
|
+
- \u4E0D\u8981\u6539 human \u7C7B\u578B Agent\uFF08id \u4E3A agt_usr_self \u7B49\uFF09\u7684 role/system_prompt/tier\uFF0C\u53EA\u6539 name/avatar
|
|
44164
|
+
- \u6539\u540D\u540E\u8BE5 Agent \u5728\u6240\u6709\u7FA4\u91CC\u7684\u663E\u793A\u540D\u4F1A\u540C\u6B65\u66F4\u65B0`,
|
|
44165
|
+
{
|
|
44166
|
+
agent_id: external_exports.string().min(1).describe('\u8981\u66F4\u65B0\u7684 Agent id\uFF08\u4ECE list_contacts() \u83B7\u53D6\uFF0C\u5982 "agt_xxx"\uFF09\u3002'),
|
|
44167
|
+
name: external_exports.string().min(1).optional().describe("Agent \u540D\u5B57\u3002"),
|
|
44168
|
+
role: external_exports.string().optional().describe('\u89D2\u8272\u63CF\u8FF0\uFF0C\u5982 "Backend Developer"\u3002'),
|
|
44169
|
+
system_prompt: external_exports.string().optional().describe("\u65B0\u7684 system prompt\uFF08\u5B9A\u4E49\u4EBA\u683C\u3001\u4E13\u957F\u3001\u884C\u4E3A\u51C6\u5219\uFF09\u3002"),
|
|
44170
|
+
tier: external_exports.enum(["smart", "balanced", "fast"]).optional().describe("\u80FD\u529B\u6863\u4F4D\u3002\u4F20\u6B64\u53C2\u6570\u4F1A\u66F4\u65B0\u8BE5 Agent \u4F7F\u7528\u7684\u6A21\u578B\u3002"),
|
|
44171
|
+
avatar: external_exports.string().optional().describe(
|
|
44172
|
+
"\u5934\u50CF key\uFF08\u5982 avatar_dev / avatar_pm / avatar_human_man \u7B49\uFF09\u3002"
|
|
44173
|
+
)
|
|
44174
|
+
},
|
|
44175
|
+
async (args) => {
|
|
44176
|
+
if (!deps.isSmith) {
|
|
44177
|
+
return {
|
|
44178
|
+
content: [{ type: "text", text: "[update_agent_profile] \u6743\u9650\u62D2\u7EDD\uFF1A\u53EA\u6709 Smith \u80FD\u64CD\u4F5C\u3002" }],
|
|
44179
|
+
isError: true
|
|
44180
|
+
};
|
|
44181
|
+
}
|
|
44182
|
+
const agentId = (args.agent_id ?? "").trim();
|
|
44183
|
+
if (!agentId) {
|
|
44184
|
+
return {
|
|
44185
|
+
content: [{ type: "text", text: "[update_agent_profile] agent_id \u4E0D\u80FD\u4E3A\u7A7A\u3002\u53EF\u4ECE list_contacts() \u83B7\u53D6\u3002" }],
|
|
44186
|
+
isError: true
|
|
44187
|
+
};
|
|
44188
|
+
}
|
|
44189
|
+
const base = deps.serverApiUrl.replace(/\/$/, "");
|
|
44190
|
+
let existing = null;
|
|
44191
|
+
try {
|
|
44192
|
+
const getRes = await fetch(`${base}/api/agents/${encodeURIComponent(agentId)}`);
|
|
44193
|
+
if (getRes.ok) {
|
|
44194
|
+
existing = await getRes.json();
|
|
44195
|
+
}
|
|
44196
|
+
} catch {
|
|
44197
|
+
}
|
|
44198
|
+
if (!existing) {
|
|
44199
|
+
return {
|
|
44200
|
+
content: [{ type: "text", text: `[update_agent_profile] \u627E\u4E0D\u5230 Agent "${agentId}"\u3002\u53EF\u8C03 list_contacts() \u786E\u8BA4 id\u3002` }],
|
|
44201
|
+
isError: true
|
|
44202
|
+
};
|
|
44203
|
+
}
|
|
44204
|
+
let agentConfig;
|
|
44205
|
+
const tier = (args.tier ?? "").trim();
|
|
44206
|
+
if (tier && deps.bridgeToken) {
|
|
44207
|
+
try {
|
|
44208
|
+
const tierUrl = `${base}/api/onboarding/tiers?bridge_token=${encodeURIComponent(deps.bridgeToken)}`;
|
|
44209
|
+
const tierRes = await fetch(tierUrl);
|
|
44210
|
+
if (tierRes.ok) {
|
|
44211
|
+
const tiers = await tierRes.json();
|
|
44212
|
+
const tierConfig = tiers.find((t2) => t2.tier === tier);
|
|
44213
|
+
if (tierConfig) {
|
|
44214
|
+
agentConfig = JSON.stringify({
|
|
44215
|
+
subscriptionId: tierConfig.subscriptionId,
|
|
44216
|
+
model: tierConfig.modelName
|
|
44217
|
+
});
|
|
44218
|
+
logger5.info("update_agent: tier resolved", { agentId, tier, subscriptionId: tierConfig.subscriptionId });
|
|
44219
|
+
}
|
|
44220
|
+
}
|
|
44221
|
+
} catch (e7) {
|
|
44222
|
+
logger5.error("update_agent: tier resolution failed", { error: e7 });
|
|
44223
|
+
}
|
|
44224
|
+
}
|
|
44225
|
+
const patchBody = {};
|
|
44226
|
+
if (args.name !== void 0) patchBody.name = String(args.name).trim();
|
|
44227
|
+
if (args.role !== void 0) patchBody.role = String(args.role);
|
|
44228
|
+
if (args.system_prompt !== void 0) patchBody.systemPrompt = String(args.system_prompt);
|
|
44229
|
+
if (args.avatar !== void 0) patchBody.avatar = String(args.avatar);
|
|
44230
|
+
if (agentConfig) patchBody.config = agentConfig;
|
|
44231
|
+
if (Object.keys(patchBody).length === 0) {
|
|
44232
|
+
return {
|
|
44233
|
+
content: [{ type: "text", text: "[update_agent_profile] \u81F3\u5C11\u9700\u8981\u63D0\u4F9B\u4E00\u4E2A\u8981\u66F4\u65B0\u7684\u5B57\u6BB5\uFF08name / role / system_prompt / tier / avatar\uFF09\u3002" }],
|
|
44234
|
+
isError: true
|
|
44235
|
+
};
|
|
44236
|
+
}
|
|
44237
|
+
logger5.info("update_agent_profile tool called", {
|
|
44238
|
+
agentId: deps.agentId,
|
|
44239
|
+
targetAgentId: agentId,
|
|
44240
|
+
targetName: existing.name,
|
|
44241
|
+
fields: Object.keys(patchBody)
|
|
44242
|
+
});
|
|
44243
|
+
try {
|
|
44244
|
+
const res = await fetch(`${base}/api/agents/${encodeURIComponent(agentId)}`, {
|
|
44245
|
+
method: "PUT",
|
|
44246
|
+
headers: { "Content-Type": "application/json" },
|
|
44247
|
+
body: JSON.stringify(patchBody)
|
|
44248
|
+
});
|
|
44249
|
+
if (!res.ok) {
|
|
44250
|
+
const errText = await res.text().catch(() => "");
|
|
44251
|
+
return {
|
|
44252
|
+
content: [{ type: "text", text: `[update_agent_profile] \u66F4\u65B0\u5931\u8D25\uFF08${res.status}\uFF09\uFF1A${errText || "(no body)"}` }],
|
|
44253
|
+
isError: true
|
|
44254
|
+
};
|
|
44255
|
+
}
|
|
44256
|
+
const updated = await res.json();
|
|
44257
|
+
logger5.info("update_agent_profile: succeeded", {
|
|
44258
|
+
agentId: deps.agentId,
|
|
44259
|
+
targetAgentId: agentId,
|
|
44260
|
+
newName: updated.name
|
|
44261
|
+
});
|
|
44262
|
+
return {
|
|
44263
|
+
content: [{
|
|
44264
|
+
type: "text",
|
|
44265
|
+
text: `[update_agent_profile] \u5DF2\u66F4\u65B0 Agent\u300C${updated.name}\u300D(id: ${agentId})\uFF0C\u66F4\u65B0\u4E86 ${Object.keys(patchBody).length} \u4E2A\u5B57\u6BB5\u3002`
|
|
44266
|
+
}]
|
|
44267
|
+
};
|
|
44268
|
+
} catch (e7) {
|
|
44269
|
+
logger5.error("update_agent_profile failed", { error: e7, agentId });
|
|
44270
|
+
return {
|
|
44271
|
+
content: [{ type: "text", text: `[update_agent_profile] \u66F4\u65B0\u5931\u8D25\uFF1A${e7.message}` }],
|
|
44272
|
+
isError: true
|
|
44273
|
+
};
|
|
44274
|
+
}
|
|
44275
|
+
},
|
|
44276
|
+
{}
|
|
44277
|
+
) : null;
|
|
44278
|
+
const archiveConversationTool = deps.isSmith && deps.serverApiUrl ? bs(
|
|
44279
|
+
"archive_conversation",
|
|
44280
|
+
`\u5F52\u6863\u4E00\u6BB5\u5BF9\u8BDD\u2014\u2014\u5C06\u6307\u5B9A\u7684\u5355\u804A\u4F1A\u8BDD\u6807\u8BB0\u4E3A"\u5F52\u6863"\uFF0C\u4F7F\u5176\u4E0D\u518D\u51FA\u73B0\u5728\u4F1A\u8BDD\u5217\u8868\u7684\u4E3B\u89C6\u56FE\u4E2D\u3002
|
|
44281
|
+
\u53EA\u6709\u4F60\uFF08Smith\uFF09\u80FD\u8C03\u7528\u6B64\u5DE5\u5177\u3002
|
|
44282
|
+
\u5F52\u6863\u540E\u8BE5\u5BF9\u8BDD\u4F9D\u7136\u4FDD\u7559\u5728\u6570\u636E\u5E93\u4E2D\uFF0C\u5982\u9700\u6062\u590D\u53EF\u901A\u8FC7\u521B\u5EFA\u65B0\u6D88\u606F\u6216\u7528\u6237\u624B\u52A8\u64CD\u4F5C\u91CD\u65B0\u6FC0\u6D3B\u3002
|
|
44283
|
+
\u5178\u578B\u4F7F\u7528\u573A\u666F\uFF1A
|
|
44284
|
+
- \u67D0\u4E2A Agent \u5DF2\u5B8C\u6210\u957F\u671F\u4EFB\u52A1\uFF0C\u5BF9\u8BDD\u4E0D\u518D\u6D3B\u8DC3
|
|
44285
|
+
- \u7528\u6237\u8981\u6C42\u6E05\u7406\u4E0D\u518D\u9700\u8981\u7684\u65E7\u5BF9\u8BDD`,
|
|
44286
|
+
{
|
|
44287
|
+
agent_id: external_exports.string().min(1).describe("\u5BF9\u8BDD\u6240\u5C5E\u7684 Agent id\uFF08\u4ECE list_contacts() \u83B7\u53D6\uFF09\u3002"),
|
|
44288
|
+
conversation_id: external_exports.string().min(1).describe("\u8981\u5F52\u6863\u7684\u5BF9\u8BDD id\u3002\u5982\u679C\u4E0D\u786E\u5B9A\uFF0C\u5148\u8C03 read_chat_history \u67E5\u770B\u8BE5 Agent \u7684\u5BF9\u8BDD\u5386\u53F2\u786E\u8BA4 id\u3002")
|
|
44289
|
+
},
|
|
44290
|
+
async (args) => {
|
|
44291
|
+
if (!deps.isSmith) {
|
|
44292
|
+
return {
|
|
44293
|
+
content: [{ type: "text", text: "[archive_conversation] \u6743\u9650\u62D2\u7EDD\uFF1A\u53EA\u6709 Smith \u80FD\u64CD\u4F5C\u3002" }],
|
|
44294
|
+
isError: true
|
|
44295
|
+
};
|
|
44296
|
+
}
|
|
44297
|
+
const agentId = (args.agent_id ?? "").trim();
|
|
44298
|
+
const conversationId = (args.conversation_id ?? "").trim();
|
|
44299
|
+
if (!agentId || !conversationId) {
|
|
44300
|
+
return {
|
|
44301
|
+
content: [{ type: "text", text: "[archive_conversation] agent_id \u548C conversation_id \u90FD\u4E0D\u80FD\u4E3A\u7A7A\u3002" }],
|
|
44302
|
+
isError: true
|
|
44303
|
+
};
|
|
44304
|
+
}
|
|
44305
|
+
const base = deps.serverApiUrl.replace(/\/$/, "");
|
|
44306
|
+
logger5.info("archive_conversation tool called", {
|
|
44307
|
+
agentId: deps.agentId,
|
|
44308
|
+
targetAgentId: agentId,
|
|
44309
|
+
conversationId
|
|
44310
|
+
});
|
|
44311
|
+
try {
|
|
44312
|
+
const res = await fetch(`${base}/api/conversations/${encodeURIComponent(conversationId)}/archive`, {
|
|
44313
|
+
method: "POST",
|
|
44314
|
+
headers: {
|
|
44315
|
+
"Content-Type": "application/json",
|
|
44316
|
+
"X-Caller-Agent-Id": deps.agentId
|
|
44317
|
+
},
|
|
44318
|
+
body: JSON.stringify({ agentId })
|
|
44319
|
+
});
|
|
44320
|
+
if (!res.ok) {
|
|
44321
|
+
const errText = await res.text().catch(() => "");
|
|
44322
|
+
return {
|
|
44323
|
+
content: [{ type: "text", text: `[archive_conversation] \u5F52\u6863\u5931\u8D25\uFF08${res.status}\uFF09\uFF1A${errText || "(no body)"}` }],
|
|
44324
|
+
isError: true
|
|
44325
|
+
};
|
|
44326
|
+
}
|
|
44327
|
+
logger5.info("archive_conversation: succeeded", {
|
|
44328
|
+
agentId: deps.agentId,
|
|
44329
|
+
conversationId
|
|
44330
|
+
});
|
|
44331
|
+
return {
|
|
44332
|
+
content: [{
|
|
44333
|
+
type: "text",
|
|
44334
|
+
text: `[archive_conversation] \u5BF9\u8BDD ${conversationId} \u5DF2\u5F52\u6863\u3002`
|
|
44335
|
+
}]
|
|
44336
|
+
};
|
|
44337
|
+
} catch (e7) {
|
|
44338
|
+
logger5.error("archive_conversation failed", { error: e7, conversationId });
|
|
44339
|
+
return {
|
|
44340
|
+
content: [{ type: "text", text: `[archive_conversation] \u5F52\u6863\u5931\u8D25\uFF1A${e7.message}` }],
|
|
44341
|
+
isError: true
|
|
44342
|
+
};
|
|
44343
|
+
}
|
|
44344
|
+
},
|
|
44345
|
+
{}
|
|
44346
|
+
) : null;
|
|
44123
44347
|
const transferGroupOwnerTool = deps.serverApiUrl ? bs(
|
|
44124
44348
|
"transfer_group_owner",
|
|
44125
44349
|
`\u5C06\u4F60\u5EFA\u7684\u7FA4\u7684"\u7FA4\u4E3B"\u89D2\u8272\u8F6C\u7ED9\u53E6\u4E00\u4E2A\u7FA4\u6210\u5458\u3002
|
|
44126
44350
|
\u53EA\u6709\u5F53\u524D\u7FA4\u4E3B\u80FD\u8C03\u7528\u6B64\u5DE5\u5177\u2014\u2014\u5982\u679C\u4F60\u4E0D\u662F\u7FA4\u4E3B\u4F1A\u88AB\u670D\u52A1\u7AEF\u62D2\u7EDD\u3002
|
|
44127
44351
|
\u8F6C\u79FB\u540E\u4F60\u4ECD\u7559\u5728\u7FA4\u91CC\uFF0C\u4F46\u4E0D\u518D\u62E5\u6709\u8E22\u4EBA\u6743\u9650\uFF08\u9664\u975E\u65B0\u7FA4\u4E3B\u518D\u8F6C\u56DE\u7ED9\u4F60\uFF09\u3002`,
|
|
44128
44352
|
{
|
|
44129
|
-
group: external_exports.string().describe("\u76EE\u6807\u7FA4\u3002group ID \u6216\u7FA4\u540D\uFF08\u6A21\u7CCA\u5339\u914D\uFF09\u3002"),
|
|
44130
|
-
new_owner_id: external_exports.string().describe("\u65B0\u7FA4\u4E3B\u7684 Agent ID\u3002\u5FC5\u987B\u662F\u5F53\u524D\u7FA4\u6210\u5458\u3002")
|
|
44353
|
+
group: external_exports.string().min(1).describe("\u76EE\u6807\u7FA4\u3002group ID \u6216\u7FA4\u540D\uFF08\u6A21\u7CCA\u5339\u914D\uFF09\u3002"),
|
|
44354
|
+
new_owner_id: external_exports.string().min(1).describe("\u65B0\u7FA4\u4E3B\u7684 Agent ID\u3002\u5FC5\u987B\u662F\u5F53\u524D\u7FA4\u6210\u5458\uFF0C\u53EF\u4ECE list_contacts() \u6216 neural_list_scopes() \u8FD4\u56DE\u4E2D\u786E\u8BA4\u3002")
|
|
44131
44355
|
},
|
|
44132
44356
|
async (args) => {
|
|
44133
44357
|
const rawGroup = (args.group ?? "").trim();
|
|
@@ -44444,10 +44668,10 @@ limit \u9ED8\u8BA4 500\uFF0C\u786C\u4E0A\u9650 2000\u3002\u8FD4\u56DE\u6BCF\u884
|
|
|
44444
44668
|
\u5F53\u7528\u6237\u8981\u6C42\u4F60"\u53BB\u8BBA\u575B\u53D1\u5E16"\u3001"\u62DB\u52DF\u5458\u5DE5/Agent"\u3001"\u53D1\u5E03\u7ECF\u9A8C"\u3001"\u6C89\u6DC0\u5206\u6790\u6210\u679C"\u3001"\u629B\u4E00\u4E2A\u95EE\u9898\u8BA9\u5927\u5BB6\u8865\u5145"\u65F6\uFF0C\u76F4\u63A5\u8C03\u7528\u8FD9\u4E2A\u5DE5\u5177\uFF0C\u4E0D\u8981\u8BF4\u81EA\u5DF1\u6CA1\u6709\u53D1\u5E03\u529F\u80FD\u3002
|
|
44445
44669
|
\u5E16\u5B50\u4F1A\u51FA\u73B0\u5728\u7F51\u9875\u7AEF\u7684\u667A\u56CA\u5E7F\u573A\uFF0C\u5176\u4ED6\u4EBA\u548C Agent \u53EF\u4EE5\u67E5\u770B\u5E76\u56DE\u590D\u3002`,
|
|
44446
44670
|
{
|
|
44447
|
-
title: external_exports.string().describe("\u5E16\u5B50\u6807\u9898\uFF0C\u7B80\u6D01\u8BF4\u660E\u4E3B\u9898\u3002"),
|
|
44448
|
-
content: external_exports.string().describe("\u5E16\u5B50\u6B63\u6587\u3002\u62DB\u52DF\u5E16\u5EFA\u8BAE\u5305\u542B\u80CC\u666F\u3001\u9700\u8981\u8865\u5145\u7684\u80FD\u529B\u3001\u671F\u671B\u4EA7\u51FA\u3002"),
|
|
44449
|
-
category: external_exports.
|
|
44450
|
-
"\u5206\u7C7B\
|
|
44671
|
+
title: external_exports.string().min(1).describe("\u5E16\u5B50\u6807\u9898\uFF0C\u7B80\u6D01\u8BF4\u660E\u4E3B\u9898\u3002"),
|
|
44672
|
+
content: external_exports.string().min(1).describe("\u5E16\u5B50\u6B63\u6587\u3002\u62DB\u52DF\u5E16\u5EFA\u8BAE\u5305\u542B\u80CC\u666F\u3001\u9700\u8981\u8865\u5145\u7684\u80FD\u529B\u3001\u671F\u671B\u4EA7\u51FA\u3002"),
|
|
44673
|
+
category: external_exports.enum(["discussion", "note", "solution", "best_practice", "pitfall"]).optional().describe(
|
|
44674
|
+
"\u5E16\u5B50\u5206\u7C7B\u3002discussion\uFF08\u5F85\u8BA8\u8BBA\uFF09\u3001note\uFF08\u5FC3\u5F97\uFF09\u3001solution\uFF08\u89E3\u51B3\u65B9\u6848\uFF09\u3001best_practice\uFF08\u6700\u4F73\u5B9E\u8DF5\uFF09\u3001pitfall\uFF08\u8E29\u5751\uFF09\u3002\u4E0D\u586B\u9ED8\u8BA4 discussion\u3002"
|
|
44451
44675
|
),
|
|
44452
44676
|
group_id: external_exports.string().optional().describe("\u53EF\u9009\uFF1A\u5173\u8054\u7684\u7FA4 ID\u3002\u4E0D\u586B\u65F6\uFF0C\u5982\u679C\u4F60\u5728\u7FA4\u804A scope\uFF0C\u4F1A\u81EA\u52A8\u5173\u8054\u5F53\u524D\u7FA4\u3002")
|
|
44453
44677
|
},
|
|
@@ -44528,6 +44752,8 @@ limit \u9ED8\u8BA4 500\uFF0C\u786C\u4E0A\u9650 2000\u3002\u8FD4\u56DE\u6BCF\u884
|
|
|
44528
44752
|
if (readSkillTool) tools.push(readSkillTool);
|
|
44529
44753
|
if (fetchLogsTool) tools.push(fetchLogsTool);
|
|
44530
44754
|
if (createAgentTool) tools.push(createAgentTool);
|
|
44755
|
+
if (updateAgentTool) tools.push(updateAgentTool);
|
|
44756
|
+
if (archiveConversationTool) tools.push(archiveConversationTool);
|
|
44531
44757
|
if (transferGroupOwnerTool) tools.push(transferGroupOwnerTool);
|
|
44532
44758
|
if (listFriendsTool) tools.push(listFriendsTool);
|
|
44533
44759
|
if (acceptFriendTool) tools.push(acceptFriendTool);
|
|
@@ -44549,6 +44775,8 @@ limit \u9ED8\u8BA4 500\uFF0C\u786C\u4E0A\u9650 2000\u3002\u8FD4\u56DE\u6BCF\u884
|
|
|
44549
44775
|
if (readSkillTool) toolNames.push("read_skill");
|
|
44550
44776
|
if (fetchLogsTool) toolNames.push("fetch_logs");
|
|
44551
44777
|
if (createAgentTool) toolNames.push("create_agent");
|
|
44778
|
+
if (updateAgentTool) toolNames.push("update_agent_profile");
|
|
44779
|
+
if (archiveConversationTool) toolNames.push("archive_conversation");
|
|
44552
44780
|
if (transferGroupOwnerTool) toolNames.push("transfer_group_owner");
|
|
44553
44781
|
if (listFriendsTool) toolNames.push("list_friends");
|
|
44554
44782
|
if (acceptFriendTool) toolNames.push("accept_friend");
|
|
@@ -45763,6 +45991,34 @@ var AgentManager = class {
|
|
|
45763
45991
|
this.queryFn = QA$;
|
|
45764
45992
|
return this.queryFn;
|
|
45765
45993
|
}
|
|
45994
|
+
fallbackCwd(agentConfig, scope, requestedCwd) {
|
|
45995
|
+
const normalized = requestedCwd.trim();
|
|
45996
|
+
const basename = normalized ? path8.basename(path8.normalize(normalized)) : "";
|
|
45997
|
+
const suffix = basename && basename !== "." && basename !== path8.sep ? basename : scope.kind === "group" ? `Group-${scope.groupId}` : agentConfig.id;
|
|
45998
|
+
return path8.join(this.workspacesDir, suffix);
|
|
45999
|
+
}
|
|
46000
|
+
async resolveRuntimeCwd(agentConfig, scope, requestedCwd) {
|
|
46001
|
+
let cwd = requestedCwd;
|
|
46002
|
+
if (isRunningAsRoot() && cwd.startsWith("/root/")) {
|
|
46003
|
+
cwd = this.fallbackCwd(agentConfig, scope, cwd);
|
|
46004
|
+
}
|
|
46005
|
+
try {
|
|
46006
|
+
await fs4.mkdir(cwd, { recursive: true });
|
|
46007
|
+
return cwd;
|
|
46008
|
+
} catch (e7) {
|
|
46009
|
+
const fallback = this.fallbackCwd(agentConfig, scope, cwd);
|
|
46010
|
+
if (fallback === cwd) throw e7;
|
|
46011
|
+
logger10.warn("Working directory inaccessible; using local fallback", {
|
|
46012
|
+
agentId: agentConfig.id,
|
|
46013
|
+
scope: scopeKey(scope),
|
|
46014
|
+
requested: cwd,
|
|
46015
|
+
fallback,
|
|
46016
|
+
error: e7
|
|
46017
|
+
});
|
|
46018
|
+
await fs4.mkdir(fallback, { recursive: true });
|
|
46019
|
+
return fallback;
|
|
46020
|
+
}
|
|
46021
|
+
}
|
|
45766
46022
|
/**
|
|
45767
46023
|
* Parse agent.config and resolve any subscriptionId reference into the legacy
|
|
45768
46024
|
* inline fields (subscriptionType / apiKey / apiBaseUrl). Downstream code in
|
|
@@ -45775,9 +46031,6 @@ var AgentManager = class {
|
|
|
45775
46031
|
async resolveAgentConfig(agent) {
|
|
45776
46032
|
const cfg = parseAgentConfig(agent.config);
|
|
45777
46033
|
if (!cfg.subscriptionId) return cfg;
|
|
45778
|
-
if (cfg.subscriptionId === SYSTEM_SUBSCRIPTION_ID) {
|
|
45779
|
-
return { ...cfg, subscriptionType: "system" };
|
|
45780
|
-
}
|
|
45781
46034
|
if (!this.subscriptionRegistry) {
|
|
45782
46035
|
logger10.warn("subscriptionId set but no subscriptionRegistry available", {
|
|
45783
46036
|
agentId: agent.id,
|
|
@@ -45794,7 +46047,8 @@ var AgentManager = class {
|
|
|
45794
46047
|
});
|
|
45795
46048
|
return { ...cfg, subscriptionType: "system" };
|
|
45796
46049
|
}
|
|
45797
|
-
const
|
|
46050
|
+
const isPinnedModel = cfg.model && cfg.model !== "default";
|
|
46051
|
+
const resolvedModel = isPinnedModel ? cfg.model : sub.defaultModel;
|
|
45798
46052
|
const limits = resolveModelLimits(sub.customModels, resolvedModel);
|
|
45799
46053
|
if (limits.maxInputTokens || limits.maxOutputTokens) {
|
|
45800
46054
|
logger10.info("Resolved per-model token limits", {
|
|
@@ -45977,8 +46231,7 @@ var AgentManager = class {
|
|
|
45977
46231
|
return existing;
|
|
45978
46232
|
}
|
|
45979
46233
|
const inputController = new InputController();
|
|
45980
|
-
const agentCwd =
|
|
45981
|
-
await fs4.mkdir(agentCwd, { recursive: true });
|
|
46234
|
+
const agentCwd = await this.resolveRuntimeCwd(agentConfig, scope, cwd);
|
|
45982
46235
|
const cfg = await this.resolveAgentConfig(agentConfig);
|
|
45983
46236
|
if (cfg.instructions?.trim()) {
|
|
45984
46237
|
await fs4.writeFile(path8.join(agentCwd, "CLAUDE.md"), cfg.instructions.trim(), "utf-8");
|