@ai-setting/roy-agent-core 1.7.53 → 1.7.56
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/config/index.js +7 -7
- package/dist/env/agent/agent-component.d.ts +30 -0
- package/dist/env/agent/index.js +13 -12
- package/dist/env/commands/index.js +7 -7
- package/dist/env/context/index.js +3 -3
- package/dist/env/debug/index.js +7 -7
- package/dist/env/environment.d.ts +7 -0
- package/dist/env/error-reply.d.ts +184 -0
- package/dist/env/event-source/event-source-handlers.d.ts +9 -23
- package/dist/env/event-source/index.js +17 -17
- package/dist/env/hook/index.js +5 -5
- package/dist/env/index.js +41 -40
- package/dist/env/llm/adapter-ai-sdk.d.ts +6 -0
- package/dist/env/llm/adapter-pi-ai.d.ts +152 -2
- package/dist/env/llm/adapter.d.ts +21 -1
- package/dist/env/llm/index.js +10 -10
- package/dist/env/llm/invoke.d.ts +74 -2
- package/dist/env/llm/llm.d.ts +38 -0
- package/dist/env/llm/outbound-defense.d.ts +140 -0
- package/dist/env/llm/reasoning-defense.d.ts +104 -0
- package/dist/env/llm/types.d.ts +26 -0
- package/dist/env/log-trace/decorator.d.ts +46 -3
- package/dist/env/log-trace/index.d.ts +1 -0
- package/dist/env/log-trace/index.js +33 -7
- package/dist/env/log-trace/trace-filters.d.ts +127 -0
- package/dist/env/mcp/index.js +7 -7
- package/dist/env/memory/index.js +7 -7
- package/dist/env/plugin/index.js +7 -7
- package/dist/env/prompt/index.js +8 -8
- package/dist/env/prompt/prompts-index.d.ts +1 -1
- package/dist/env/session/index.js +11 -10
- package/dist/env/session/session-component.d.ts +4 -0
- package/dist/env/session/storage/index.js +5 -3
- package/dist/env/skill/index.js +7 -7
- package/dist/env/task/backend/index.js +0 -2
- package/dist/env/task/backend/types.d.ts +0 -11
- package/dist/env/task/delegate/index.js +8 -8
- package/dist/env/task/index.js +13 -13
- package/dist/env/task/plugins/card-chat-routing.d.ts +42 -89
- package/dist/env/task/plugins/index.js +10 -10
- package/dist/env/task/plugins/lark-card-patch-notifier.d.ts +0 -51
- package/dist/env/task/plugins/lark-cli-task-notify-plugin.d.ts +14 -31
- package/dist/env/task/plugins/per-task-group-chat-plugin.d.ts +4 -4
- package/dist/env/task/storage/index.js +2 -2
- package/dist/env/task/tools/index.js +3 -3
- package/dist/env/tool/built-in/index.js +3 -3
- package/dist/env/tool/index.js +9 -9
- package/dist/env/workflow/engine/engine.d.ts +65 -0
- package/dist/env/workflow/engine/index.js +12 -12
- package/dist/env/workflow/hooks/index.js +7 -7
- package/dist/env/workflow/index.js +23 -22
- package/dist/env/workflow/nodes/index.js +2 -2
- package/dist/env/workflow/nodes/tool-node.d.ts +6 -0
- package/dist/env/workflow/plugins/index.js +8 -8
- package/dist/env/workflow/service/index.js +2 -2
- package/dist/env/workflow/storage/index.js +3 -3
- package/dist/env/workflow/tools/index.js +15 -14
- package/dist/env/workflow/tools/workflow-validate-tool.d.ts +11 -2
- package/dist/env/workflow/types/run.d.ts +19 -0
- package/dist/env/workflow/utils/agent-session-metadata.d.ts +13 -0
- package/dist/env/workflow/utils/index.js +5 -5
- package/dist/env/workflow/utils/redact-command-secrets.d.ts +70 -0
- package/dist/env/workflow/utils/shell-dialect-lint.d.ts +75 -0
- package/dist/env/workflow/utils/validate-workflow-definition.d.ts +22 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +82 -56
- package/dist/shared/@ai-setting/{roy-agent-core-k25gv86p.js → roy-agent-core-0b3fdnn3.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-vvxb9522.js → roy-agent-core-0bmk44ye.js} +71 -10
- package/dist/shared/@ai-setting/{roy-agent-core-k8b440n3.js → roy-agent-core-16t0zfbk.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-4z3rq5gw.js → roy-agent-core-1pnfkspm.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-na73mym1.js → roy-agent-core-202v00x4.js} +213 -2
- package/dist/shared/@ai-setting/{roy-agent-core-ph5qbqcx.js → roy-agent-core-2044fbsd.js} +471 -134
- package/dist/shared/@ai-setting/{roy-agent-core-fs36xgcs.js → roy-agent-core-3dkzqqsd.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-qm9jda8p.js → roy-agent-core-3kz6934b.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-tjg71zqp.js → roy-agent-core-3mc6vmvj.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-tdbv7ff4.js → roy-agent-core-40xzbjtm.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-athdr2m0.js → roy-agent-core-4zy2v3br.js} +10 -2
- package/dist/shared/@ai-setting/{roy-agent-core-t37wbysj.js → roy-agent-core-5gw6w424.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-978b6wfx.js → roy-agent-core-5psjwd08.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-7evvpfwc.js → roy-agent-core-5rxs0ra3.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-gdsqp6j8.js → roy-agent-core-6masakz4.js} +45 -0
- package/dist/shared/@ai-setting/{roy-agent-core-stnddvx9.js → roy-agent-core-6qgq7h1g.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-6167phd4.js → roy-agent-core-833t16n1.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-2k4xffaa.js → roy-agent-core-8cgtwytv.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-rx16h2m1.js → roy-agent-core-97eyghsp.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-fvs48d38.js → roy-agent-core-98aa9r0x.js} +12 -7
- package/dist/shared/@ai-setting/{roy-agent-core-3tv1q6f2.js → roy-agent-core-9nv586rw.js} +57 -19
- package/dist/shared/@ai-setting/roy-agent-core-b599jgyd.js +578 -0
- package/dist/shared/@ai-setting/{roy-agent-core-yd21n6c7.js → roy-agent-core-bwzy00t2.js} +12 -5
- package/dist/shared/@ai-setting/{roy-agent-core-dwx9hjwx.js → roy-agent-core-c6at31ra.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-1cv9j4dg.js → roy-agent-core-d14h726p.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-4sx6sdb2.js → roy-agent-core-d4jpn06f.js} +22 -9
- package/dist/shared/@ai-setting/{roy-agent-core-39xejr39.js → roy-agent-core-e0wbq0qq.js} +7 -7
- package/dist/shared/@ai-setting/{roy-agent-core-vrsxhw9e.js → roy-agent-core-e677am8e.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-hch2geta.js → roy-agent-core-ezsyyjxw.js} +21 -190
- package/dist/shared/@ai-setting/{roy-agent-core-ne2t1pay.js → roy-agent-core-f8sp1txg.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-ak4dc3kg.js → roy-agent-core-gn8f4rhs.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-qcspfszy.js → roy-agent-core-gngjkw3b.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-9jzysq50.js → roy-agent-core-heft3j4c.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-5apmk4qw.js → roy-agent-core-jszgaevt.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-nde5gzta.js → roy-agent-core-m8n0dffe.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-x8n1r7h4.js → roy-agent-core-n3b7ztms.js} +189 -8
- package/dist/shared/@ai-setting/{roy-agent-core-4vpk40ss.js → roy-agent-core-nhk0dsxr.js} +13 -13
- package/dist/shared/@ai-setting/{roy-agent-core-j8e92gj8.js → roy-agent-core-nntphgww.js} +1 -60
- package/dist/shared/@ai-setting/{roy-agent-core-8s9jd2qy.js → roy-agent-core-nra8vfrs.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-pk1b3kvf.js → roy-agent-core-ns3pbyz4.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-7g03zkkb.js → roy-agent-core-pemxr5n4.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-skzjs973.js → roy-agent-core-pjxa78mp.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-p8ak03s0.js → roy-agent-core-q7zksbw0.js} +117 -315
- package/dist/shared/@ai-setting/{roy-agent-core-zd3ddm4k.js → roy-agent-core-qjjf4tjb.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-qamktze3.js → roy-agent-core-qyqnmz8c.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-9csa89jx.js → roy-agent-core-r9qe0ghe.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-h93v6p6y.js → roy-agent-core-tc7gw38m.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-35s1w7tc.js → roy-agent-core-v2188rnk.js} +157 -85
- package/dist/shared/@ai-setting/{roy-agent-core-p2r27era.js → roy-agent-core-vmg30n5x.js} +8 -8
- package/dist/shared/@ai-setting/{roy-agent-core-rnwr39b0.js → roy-agent-core-w7hnjhvx.js} +5 -3
- package/dist/shared/@ai-setting/{roy-agent-core-dv714bqh.js → roy-agent-core-wafk25ff.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-brwzs8wf.js → roy-agent-core-xcq04fq0.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-2gay3sjt.js → roy-agent-core-yg247mk4.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-zy3hqfwg.js → roy-agent-core-yv9x4wmg.js} +631 -35
- package/dist/shared/@ai-setting/{roy-agent-core-yhsssn86.js → roy-agent-core-zmeka63k.js} +1 -1
- package/dist/test-utils/child-process-mock.d.ts +73 -0
- package/package.json +2 -2
- package/dist/shared/@ai-setting/roy-agent-core-dsevjbck.js +0 -245
|
@@ -1,12 +1,163 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TracedAs,
|
|
3
3
|
init_decorator
|
|
4
|
-
} from "./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-b599jgyd.js";
|
|
5
5
|
import {
|
|
6
6
|
__esm,
|
|
7
7
|
__legacyDecorateClassTS
|
|
8
8
|
} from "./roy-agent-core-fs0mn2jk.js";
|
|
9
9
|
|
|
10
|
+
// src/env/workflow/utils/redact-command-secrets.ts
|
|
11
|
+
function replaceTrailing(match, raw) {
|
|
12
|
+
if (raw.length === 0)
|
|
13
|
+
return match;
|
|
14
|
+
const idx = match.lastIndexOf(raw);
|
|
15
|
+
if (idx < 0)
|
|
16
|
+
return match;
|
|
17
|
+
return match.slice(0, idx) + MASK;
|
|
18
|
+
}
|
|
19
|
+
function looksLikeCredentialCommand(command) {
|
|
20
|
+
return PASSWORD_FLAG_TOOL_RE.test(command);
|
|
21
|
+
}
|
|
22
|
+
function looksLikeShortATool(command) {
|
|
23
|
+
return SHORT_A_TOOL_RE.test(command);
|
|
24
|
+
}
|
|
25
|
+
function looksLikePasswordValue(value) {
|
|
26
|
+
if (value.length === 0)
|
|
27
|
+
return false;
|
|
28
|
+
if (PATH_LIKE_RE.test(value))
|
|
29
|
+
return false;
|
|
30
|
+
if (NUMERIC_RE.test(value))
|
|
31
|
+
return false;
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
function redactCommandSecrets(command) {
|
|
35
|
+
if (!command)
|
|
36
|
+
return command;
|
|
37
|
+
let out = command;
|
|
38
|
+
out = out.replace(AUTH_SCHEME_RE, (match, prefix, scheme, value) => isMasked(value) ? match : `${prefix}${scheme} ${MASK}`);
|
|
39
|
+
out = out.replace(URL_USERINFO_RE, (match, head, value, at) => isMasked(value) ? match : `${head}${MASK}${at}`);
|
|
40
|
+
out = out.replace(URL_QUERY_RE, (match, amp, name, eq, value) => {
|
|
41
|
+
if (!SENSITIVE_QUERY_KEY_RE.test(name))
|
|
42
|
+
return match;
|
|
43
|
+
if (isMasked(value))
|
|
44
|
+
return match;
|
|
45
|
+
return `${amp}${name}${eq}${MASK}`;
|
|
46
|
+
});
|
|
47
|
+
out = out.replace(SHORT_U_RE, (match, lead, flag, user, pass) => {
|
|
48
|
+
if (isMasked(pass))
|
|
49
|
+
return match;
|
|
50
|
+
const name = user.slice(0, -1);
|
|
51
|
+
if (UID_GID_RE.test(name) && UID_GID_RE.test(pass))
|
|
52
|
+
return match;
|
|
53
|
+
if (name === pass)
|
|
54
|
+
return match;
|
|
55
|
+
return `${lead}${flag}${user}${MASK}`;
|
|
56
|
+
});
|
|
57
|
+
out = out.replace(LONG_USER_RE, (match, lead, flag, user, pass) => {
|
|
58
|
+
if (isMasked(pass))
|
|
59
|
+
return match;
|
|
60
|
+
const name = user.slice(0, -1);
|
|
61
|
+
if (UID_GID_RE.test(name) && UID_GID_RE.test(pass))
|
|
62
|
+
return match;
|
|
63
|
+
if (name === pass)
|
|
64
|
+
return match;
|
|
65
|
+
return `${lead}${flag}${user}${MASK}`;
|
|
66
|
+
});
|
|
67
|
+
if (looksLikeCredentialCommand(command)) {
|
|
68
|
+
const maskPassword = (match, lead, flag, dq, sq, bare) => {
|
|
69
|
+
const value = dq ?? sq ?? bare ?? "";
|
|
70
|
+
if (isMasked(value) || !looksLikePasswordValue(value))
|
|
71
|
+
return match;
|
|
72
|
+
if (dq !== undefined)
|
|
73
|
+
return `${lead}${flag}"${MASK}"`;
|
|
74
|
+
if (sq !== undefined)
|
|
75
|
+
return `${lead}${flag}'${MASK}'`;
|
|
76
|
+
return lead + flag + MASK;
|
|
77
|
+
};
|
|
78
|
+
out = out.replace(SHORT_P_SPACED_RE, maskPassword);
|
|
79
|
+
out = out.replace(SHORT_P_ATTACHED_RE, maskPassword);
|
|
80
|
+
}
|
|
81
|
+
out = out.replace(AUTH_FAILURE_CRED_RE, (match, head, user, pass) => isMasked(pass) ? match : `${head}${user}:${MASK}`);
|
|
82
|
+
out = out.replace(AWS_SET_SECRET_RE, (match, key, value) => isMasked(value) ? match : `${key} ${MASK}`);
|
|
83
|
+
if (looksLikeShortATool(command)) {
|
|
84
|
+
out = out.replace(SHORT_A_SECRET_RE, (match, lead, flag, value) => isMasked(value) || !looksLikePasswordValue(value) ? match : `${lead}${flag}${MASK}`);
|
|
85
|
+
out = out.replace(SHORT_A_ATTACHED_RE, (match, lead, flag, value) => isMasked(value) || !looksLikePasswordValue(value) ? match : `${lead}${flag}${MASK}`);
|
|
86
|
+
}
|
|
87
|
+
out = out.replace(ASSIGNMENT_RE, (match, key, dq, sq, bare) => {
|
|
88
|
+
if (!SENSITIVE_KEY_RE.test(key))
|
|
89
|
+
return match;
|
|
90
|
+
const value = dq ?? sq ?? bare ?? "";
|
|
91
|
+
if (value === MASK)
|
|
92
|
+
return match;
|
|
93
|
+
const isAuthHeaderKey = /^(?:proxy-)?authorization$/i.test(key);
|
|
94
|
+
if (isAuthHeaderKey && AUTH_SCHEME_WORD_RE.test(value))
|
|
95
|
+
return match;
|
|
96
|
+
const raw = dq !== undefined ? `"${value}"` : sq !== undefined ? `'${value}'` : value;
|
|
97
|
+
return replaceTrailing(match, raw);
|
|
98
|
+
});
|
|
99
|
+
out = out.replace(FLAG_RE, (match, lead, flag, _sep, dq, sq, bare) => {
|
|
100
|
+
if (!SENSITIVE_KEY_RE.test(flag))
|
|
101
|
+
return match;
|
|
102
|
+
const value = dq ?? sq ?? bare ?? "";
|
|
103
|
+
if (value === MASK)
|
|
104
|
+
return match;
|
|
105
|
+
const raw = dq !== undefined ? `"${value}"` : sq !== undefined ? `'${value}'` : value;
|
|
106
|
+
return replaceTrailing(match, raw);
|
|
107
|
+
});
|
|
108
|
+
return out;
|
|
109
|
+
}
|
|
110
|
+
function summarizeCommand(command, maxLen = 120) {
|
|
111
|
+
if (!command)
|
|
112
|
+
return "";
|
|
113
|
+
const collapsed = command.replace(/\s+/g, " ").trim();
|
|
114
|
+
if (collapsed.length <= maxLen)
|
|
115
|
+
return collapsed;
|
|
116
|
+
return `${collapsed.slice(0, maxLen)}…`;
|
|
117
|
+
}
|
|
118
|
+
var MASK = "[REDACTED]", SENSITIVE_KEY_RE, BARE_VALUE = `[^\\s;&|]+[^\\s;&|"'<>()]|[^\\s;&|]`, ASSIGNMENT_RE, FLAG_RE, AUTH_SCHEME_RE, SENSITIVE_QUERY_KEY_RE, URL_QUERY_RE, URL_USERINFO_RE, AUTH_FAILURE_CRED_RE, SHORT_U_RE, LONG_USER_RE, UID_GID_RE, SHORT_P_SPACED_RE, SHORT_P_ATTACHED_RE, isMasked = (value) => (value ?? "").trim() === MASK, AUTH_SCHEME_WORD_RE, PASSWORD_FLAG_TOOL_RE, SHORT_A_TOOL_RE, SHORT_A_SECRET_RE, SHORT_A_ATTACHED_RE, AWS_SET_SECRET_RE, PATH_LIKE_RE, NUMERIC_RE;
|
|
119
|
+
var init_redact_command_secrets = __esm(() => {
|
|
120
|
+
SENSITIVE_KEY_RE = /(?:pass(?:word|wd|phrase)?|token|secret|api[_-]?key|apikey|credential|authorization|private[_-]?key)/i;
|
|
121
|
+
ASSIGNMENT_RE = new RegExp(`(?<![A-Za-z0-9_.-])([A-Za-z0-9_][A-Za-z0-9_.-]*)\\s*[=:]\\s*(?:"([^"]*)"|'([^']*)'|(${BARE_VALUE}))`, "g");
|
|
122
|
+
FLAG_RE = new RegExp(`(^|[\\s])(--?[A-Za-z0-9][A-Za-z0-9_.-]*)(=\\s*|\\s+)(?:"([^"]*)"|'([^']*)'|(${BARE_VALUE}))`, "g");
|
|
123
|
+
AUTH_SCHEME_RE = new RegExp(`((?:Proxy-)?Authorization["']?\\s*[:=]\\s*["']?\\s*)(Bearer|Basic|Token|Digest)\\s+(${BARE_VALUE}|\\[REDACTED\\])`, "gi");
|
|
124
|
+
SENSITIVE_QUERY_KEY_RE = new RegExp([
|
|
125
|
+
"^pass(?:word|wd)?$",
|
|
126
|
+
"^pwd$",
|
|
127
|
+
"^token$",
|
|
128
|
+
"^access[_-]?token$",
|
|
129
|
+
"^refresh[_-]?token$",
|
|
130
|
+
"^id[_-]?token$",
|
|
131
|
+
"^secret$",
|
|
132
|
+
"^client[_-]?secret$",
|
|
133
|
+
"^api[_-]?key$",
|
|
134
|
+
"^apikey$",
|
|
135
|
+
"^credential$",
|
|
136
|
+
"^credentials$",
|
|
137
|
+
"^sig$",
|
|
138
|
+
"^signature$",
|
|
139
|
+
"^auth$",
|
|
140
|
+
"^authorization$",
|
|
141
|
+
"^private[_-]?key$"
|
|
142
|
+
].join("|"), "i");
|
|
143
|
+
URL_QUERY_RE = /([?&])([A-Za-z_][A-Za-z0-9_.-]*)(=)([^&#\s"']+)/g;
|
|
144
|
+
URL_USERINFO_RE = /(\/\/[^/\s:@]+:)([^/\s"']+)(@)/g;
|
|
145
|
+
AUTH_FAILURE_CRED_RE = /(\b(?:auth(?:entication|orization)?|login|credentials?|password|passwd|token)\b[^\n:]{0,40}?[\s"'])([A-Za-z0-9_.-]{1,64}):([^\s;&|"'<>]{3,})/gi;
|
|
146
|
+
SHORT_U_RE = /(^|\s)(-u\s+)([^:\s]+:)([^\s;&|"']+)/g;
|
|
147
|
+
LONG_USER_RE = /(^|\s)(--user(?:=|\s+))([^:\s]+:)([^\s;&|"']+)/g;
|
|
148
|
+
UID_GID_RE = /^\d+$/;
|
|
149
|
+
SHORT_P_SPACED_RE = new RegExp(`(^|\\s)(-p\\s+)(?:"([^"]*)"|'([^']*)'|(${BARE_VALUE}))`, "g");
|
|
150
|
+
SHORT_P_ATTACHED_RE = new RegExp(`(^|\\s)(-p)(?:"([^"]*)"|'([^']*)'|(${BARE_VALUE}))`, "g");
|
|
151
|
+
AUTH_SCHEME_WORD_RE = /^(?:bearer|basic|token|digest|negotiate|ntlm)$/i;
|
|
152
|
+
PASSWORD_FLAG_TOOL_RE = /(?<![\w/.-])(?:docker\s+login|helm\s+(?:registry\s+)?login|mysql|mysqldump|mariadb|sshpass)\b/i;
|
|
153
|
+
SHORT_A_TOOL_RE = /(?<![\w/.-])redis-cli\b/i;
|
|
154
|
+
SHORT_A_SECRET_RE = new RegExp(`(^|\\s)(-a\\s+)(?!-)(${BARE_VALUE})`, "g");
|
|
155
|
+
SHORT_A_ATTACHED_RE = new RegExp(`(^|\\s)(-a)(${BARE_VALUE})`, "g");
|
|
156
|
+
AWS_SET_SECRET_RE = new RegExp(`\\b((?:aws[_-])?(?:secret[_-]?access[_-]?key|session[_-]?token))\\s+(?!set\\b)([^=\\s;&|][^\\s;&|]*[^\\s;&|"'<>()]|[^=\\s;&|])`, "gi");
|
|
157
|
+
PATH_LIKE_RE = /^(?:\/|\.\/|\.\.\/|~\/)/;
|
|
158
|
+
NUMERIC_RE = /^\d+$/;
|
|
159
|
+
});
|
|
160
|
+
|
|
10
161
|
// src/env/workflow/nodes/tool-node.ts
|
|
11
162
|
function isPositiveNumber(v) {
|
|
12
163
|
return typeof v === "number" && Number.isFinite(v) && v > 0;
|
|
@@ -23,9 +174,39 @@ function getToolTimeoutMs(input, config) {
|
|
|
23
174
|
}
|
|
24
175
|
return DEFAULT_TOOL_TIMEOUT_MS;
|
|
25
176
|
}
|
|
26
|
-
|
|
177
|
+
function redactTail(text, tailChars) {
|
|
178
|
+
const window = text.length > tailChars + REDACT_TAIL_SLACK ? text.slice(-(tailChars + REDACT_TAIL_SLACK)) : text;
|
|
179
|
+
return redactCommandSecrets(window).trim().slice(-tailChars).trim();
|
|
180
|
+
}
|
|
181
|
+
function redactErrorForOutput(err) {
|
|
182
|
+
const message = redactCommandSecrets(err.message);
|
|
183
|
+
const stack = typeof err.stack === "string" ? redactCommandSecrets(err.stack) : undefined;
|
|
184
|
+
if (message === err.message && stack === err.stack)
|
|
185
|
+
return err;
|
|
186
|
+
const clone = new Error(message, { cause: err });
|
|
187
|
+
clone.name = err.name;
|
|
188
|
+
if (stack)
|
|
189
|
+
clone.stack = stack;
|
|
190
|
+
return clone;
|
|
191
|
+
}
|
|
192
|
+
function buildExitCodeError(exitCode, md, toolInput) {
|
|
193
|
+
const parts = [`Tool exited with code ${exitCode}`];
|
|
194
|
+
const rawCommand = toolInput && typeof toolInput === "object" ? toolInput.command ?? toolInput.cmd : undefined;
|
|
195
|
+
if (typeof rawCommand === "string" && rawCommand.trim().length > 0) {
|
|
196
|
+
const safe = summarizeCommand(redactCommandSecrets(rawCommand));
|
|
197
|
+
if (safe.length > 0) {
|
|
198
|
+
parts.push(`command: ${safe}`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const stdout = typeof md.stdout === "string" ? md.stdout : "";
|
|
202
|
+
const stdoutTail = redactTail(stdout, 300);
|
|
203
|
+
parts.push(stdoutTail.length > 0 ? `stdout tail: ${stdoutTail}` : "(no stdout)");
|
|
204
|
+
return parts.join(" | ");
|
|
205
|
+
}
|
|
206
|
+
var DEFAULT_TOOL_TIMEOUT_MS = 60000, REDACT_TAIL_SLACK = 4096, ToolNode;
|
|
27
207
|
var init_tool_node = __esm(() => {
|
|
28
208
|
init_decorator();
|
|
209
|
+
init_redact_command_secrets();
|
|
29
210
|
ToolNode = class ToolNode {
|
|
30
211
|
definition;
|
|
31
212
|
toolRegistry;
|
|
@@ -125,7 +306,7 @@ var init_tool_node = __esm(() => {
|
|
|
125
306
|
}
|
|
126
307
|
}
|
|
127
308
|
const extractedOutput = this.extractFromWrapper(output);
|
|
128
|
-
const wrapperError = this.extractErrorFromWrapper(output);
|
|
309
|
+
const wrapperError = this.extractErrorFromWrapper(output, input);
|
|
129
310
|
return {
|
|
130
311
|
output: extractedOutput,
|
|
131
312
|
error: wrapperError,
|
|
@@ -134,7 +315,7 @@ var init_tool_node = __esm(() => {
|
|
|
134
315
|
} catch (error) {
|
|
135
316
|
return {
|
|
136
317
|
output: undefined,
|
|
137
|
-
error: error instanceof Error ? error : new Error(String(error)),
|
|
318
|
+
error: error instanceof Error ? redactErrorForOutput(error) : new Error(redactCommandSecrets(String(error))),
|
|
138
319
|
durationMs: Date.now() - startTime
|
|
139
320
|
};
|
|
140
321
|
}
|
|
@@ -159,7 +340,7 @@ var init_tool_node = __esm(() => {
|
|
|
159
340
|
}
|
|
160
341
|
return result;
|
|
161
342
|
}
|
|
162
|
-
extractErrorFromWrapper(value) {
|
|
343
|
+
extractErrorFromWrapper(value, toolInput) {
|
|
163
344
|
if (value === null || value === undefined) {
|
|
164
345
|
return;
|
|
165
346
|
}
|
|
@@ -172,10 +353,10 @@ var init_tool_node = __esm(() => {
|
|
|
172
353
|
}
|
|
173
354
|
const err = obj.error;
|
|
174
355
|
if (typeof err === "string" && err.length > 0) {
|
|
175
|
-
return err;
|
|
356
|
+
return redactCommandSecrets(err);
|
|
176
357
|
}
|
|
177
358
|
if (err instanceof Error) {
|
|
178
|
-
return err;
|
|
359
|
+
return redactErrorForOutput(err);
|
|
179
360
|
}
|
|
180
361
|
const md = obj.metadata;
|
|
181
362
|
if (md) {
|
|
@@ -185,7 +366,7 @@ var init_tool_node = __esm(() => {
|
|
|
185
366
|
}
|
|
186
367
|
if (typeof md.exit_code === "number" && md.exit_code !== 0) {
|
|
187
368
|
const stderr = typeof md.stderr === "string" ? md.stderr : "";
|
|
188
|
-
return stderr.length > 0 ? stderr :
|
|
369
|
+
return stderr.length > 0 ? redactCommandSecrets(stderr) : buildExitCodeError(md.exit_code, md, toolInput);
|
|
189
370
|
}
|
|
190
371
|
}
|
|
191
372
|
return `Tool execution failed (success=false, no error message)`;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
exports_node_registry_helper,
|
|
3
3
|
init_node_registry_helper
|
|
4
|
-
} from "./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-e677am8e.js";
|
|
5
5
|
import {
|
|
6
6
|
askUserTool,
|
|
7
7
|
createRunWorkflowTool,
|
|
@@ -13,18 +13,18 @@ import {
|
|
|
13
13
|
createWorkflowSearchTool,
|
|
14
14
|
createWorkflowTagListTool,
|
|
15
15
|
createWorkflowValidateTool
|
|
16
|
-
} from "./roy-agent-core-
|
|
16
|
+
} from "./roy-agent-core-0bmk44ye.js";
|
|
17
17
|
import {
|
|
18
18
|
WorkflowService
|
|
19
|
-
} from "./roy-agent-core-
|
|
19
|
+
} from "./roy-agent-core-5rxs0ra3.js";
|
|
20
20
|
import {
|
|
21
21
|
WorkflowEngine,
|
|
22
22
|
exports_engine,
|
|
23
23
|
init_engine
|
|
24
|
-
} from "./roy-agent-core-
|
|
24
|
+
} from "./roy-agent-core-v2188rnk.js";
|
|
25
25
|
import {
|
|
26
26
|
BaseComponent
|
|
27
|
-
} from "./roy-agent-core-
|
|
27
|
+
} from "./roy-agent-core-40xzbjtm.js";
|
|
28
28
|
import {
|
|
29
29
|
createLogger,
|
|
30
30
|
init_logger
|
|
@@ -104,7 +104,7 @@ class WorkflowComponent extends BaseComponent {
|
|
|
104
104
|
return;
|
|
105
105
|
try {
|
|
106
106
|
const { NodeRegistry } = await import("../../env/workflow/engine/index.js");
|
|
107
|
-
const { registerDecoratorNodeType: registerDecoratorNodeType2 } = await import("./roy-agent-core-
|
|
107
|
+
const { registerDecoratorNodeType: registerDecoratorNodeType2 } = await import("./roy-agent-core-heft3j4c.js");
|
|
108
108
|
this.nodeRegistry = new NodeRegistry;
|
|
109
109
|
registerDecoratorNodeType2(this.nodeRegistry);
|
|
110
110
|
this.decoratorsRegistered = true;
|
|
@@ -134,14 +134,14 @@ class WorkflowComponent extends BaseComponent {
|
|
|
134
134
|
}
|
|
135
135
|
async runWorkflow(definition, input, options) {
|
|
136
136
|
const { NodeRegistry } = await import("../../env/workflow/engine/index.js");
|
|
137
|
-
const { registerDecoratorNodeType: registerDecoratorNodeType2 } = await import("./roy-agent-core-
|
|
137
|
+
const { registerDecoratorNodeType: registerDecoratorNodeType2 } = await import("./roy-agent-core-heft3j4c.js");
|
|
138
138
|
const toolComponent = this.toolComponent || this._workflowEnv?.getComponent("tool");
|
|
139
139
|
const skillComponent = this._workflowEnv?.getComponent("skill");
|
|
140
140
|
let agentRunner = this.agentRunner;
|
|
141
141
|
if (!agentRunner && this._workflowEnv) {
|
|
142
142
|
const agentComponent = this._workflowEnv.getComponent("agent");
|
|
143
143
|
if (agentComponent) {
|
|
144
|
-
const { AgentComponentAdapter } = await import("./roy-agent-core-
|
|
144
|
+
const { AgentComponentAdapter } = await import("./roy-agent-core-pjxa78mp.js");
|
|
145
145
|
agentRunner = new AgentComponentAdapter(agentComponent, {}, this.sessionComponent);
|
|
146
146
|
}
|
|
147
147
|
}
|
|
@@ -163,7 +163,7 @@ class WorkflowComponent extends BaseComponent {
|
|
|
163
163
|
if (this.workflowService) {
|
|
164
164
|
this.workflowService = null;
|
|
165
165
|
try {
|
|
166
|
-
const { closeDatabase } = await import("./roy-agent-core-
|
|
166
|
+
const { closeDatabase } = await import("./roy-agent-core-8cgtwytv.js");
|
|
167
167
|
closeDatabase();
|
|
168
168
|
componentLogger.info("[WorkflowComponent] SQLite database closed");
|
|
169
169
|
} catch (error) {
|
|
@@ -241,9 +241,9 @@ class WorkflowComponent extends BaseComponent {
|
|
|
241
241
|
}
|
|
242
242
|
async initSqliteService() {
|
|
243
243
|
try {
|
|
244
|
-
const { getDatabase, initializeTables } = await import("./roy-agent-core-
|
|
245
|
-
const { WorkflowRepository } = await import("./roy-agent-core-
|
|
246
|
-
const { TagRepository } = await import("./roy-agent-core-
|
|
244
|
+
const { getDatabase, initializeTables } = await import("./roy-agent-core-8cgtwytv.js");
|
|
245
|
+
const { WorkflowRepository } = await import("./roy-agent-core-d14h726p.js");
|
|
246
|
+
const { TagRepository } = await import("./roy-agent-core-f8sp1txg.js");
|
|
247
247
|
const db = getDatabase();
|
|
248
248
|
initializeTables();
|
|
249
249
|
const workflowRepository = new WorkflowRepository(db);
|
|
@@ -309,7 +309,7 @@ class WorkflowComponent extends BaseComponent {
|
|
|
309
309
|
this.workflowService = null;
|
|
310
310
|
this.nodeRegistry = null;
|
|
311
311
|
try {
|
|
312
|
-
const { closeDatabase } = await import("./roy-agent-core-
|
|
312
|
+
const { closeDatabase } = await import("./roy-agent-core-8cgtwytv.js");
|
|
313
313
|
closeDatabase();
|
|
314
314
|
} catch {}
|
|
315
315
|
this._status = "stopped";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TracedAs,
|
|
3
3
|
init_decorator
|
|
4
|
-
} from "./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-b599jgyd.js";
|
|
5
5
|
import {
|
|
6
6
|
createLogger,
|
|
7
7
|
init_logger
|
|
@@ -287,34 +287,6 @@ function buildChatAppLink(chatId, base = DEFAULT_APP_LINK_BASE) {
|
|
|
287
287
|
return `${base}/client/chat/open?openChatId=${chatId}`;
|
|
288
288
|
}
|
|
289
289
|
var DEFAULT_APP_LINK_BASE = "https://applink.feishu.cn";
|
|
290
|
-
function buildRedirectCard(opts) {
|
|
291
|
-
const taskLabel = opts.taskId !== undefined ? `#${opts.taskId}` : "本任务";
|
|
292
|
-
const title = opts.taskTitle ? ` ${sanitizeInlineText(opts.taskTitle, 120)}` : "";
|
|
293
|
-
const link = buildChatAppLink(opts.targetChatId);
|
|
294
|
-
const groupName = opts.targetChatName ? sanitizeInlineText(opts.targetChatName, 60) : "专属群";
|
|
295
|
-
return {
|
|
296
|
-
schema: "2.0",
|
|
297
|
-
header: {
|
|
298
|
-
title: { tag: "plain_text", content: "\uD83D\uDCC2 任务卡片已改投专属群" },
|
|
299
|
-
subtitle: { tag: "plain_text", content: "这里不是本任务的群,进展请看专属群" },
|
|
300
|
-
template: "grey"
|
|
301
|
-
},
|
|
302
|
-
body: {
|
|
303
|
-
elements: [
|
|
304
|
-
{
|
|
305
|
-
tag: "markdown",
|
|
306
|
-
content: [
|
|
307
|
-
`- **任务**:${taskLabel}${title}`,
|
|
308
|
-
`- **专属群**:[${groupName}](${link})`,
|
|
309
|
-
`- **群 ID**:\`${opts.targetChatId}\`(搜群名也能进)`,
|
|
310
|
-
opts.reason ? `- **原因**:${sanitizeInlineText(opts.reason, 280)}` : ""
|
|
311
|
-
].filter(Boolean).join(`
|
|
312
|
-
`)
|
|
313
|
-
}
|
|
314
|
-
]
|
|
315
|
-
}
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
290
|
var WORKFLOW_STATUS_LABEL = {
|
|
319
291
|
running: "\uD83D\uDD04 运行中",
|
|
320
292
|
completed: "✅ 已完成",
|
|
@@ -449,7 +421,6 @@ class LarkCardPatchNotifier {
|
|
|
449
421
|
mutexes = new Map;
|
|
450
422
|
states = new Map;
|
|
451
423
|
workflowStates = new Map;
|
|
452
|
-
redirectsSent = new Set;
|
|
453
424
|
constructor(options = {}) {
|
|
454
425
|
this.options = {
|
|
455
426
|
pinOnStart: true,
|
|
@@ -505,36 +476,6 @@ class LarkCardPatchNotifier {
|
|
|
505
476
|
}
|
|
506
477
|
return { messageId, pinned, pinError };
|
|
507
478
|
}
|
|
508
|
-
async sendRedirectNotice(opts) {
|
|
509
|
-
const redirectKey = opts.taskId !== undefined ? `${opts.taskId}:${opts.targetChatId}` : undefined;
|
|
510
|
-
if (redirectKey) {
|
|
511
|
-
if (this.redirectsSent.has(redirectKey)) {
|
|
512
|
-
logger.debug(`sendRedirectNotice: 已发过改投卡片(${redirectKey})→ 跳过重复发送`);
|
|
513
|
-
return false;
|
|
514
|
-
}
|
|
515
|
-
this.redirectsSent.add(redirectKey);
|
|
516
|
-
}
|
|
517
|
-
const card = buildRedirectCard({
|
|
518
|
-
taskId: opts.taskId,
|
|
519
|
-
taskTitle: opts.taskTitle,
|
|
520
|
-
targetChatId: opts.targetChatId,
|
|
521
|
-
targetChatName: opts.targetChatName,
|
|
522
|
-
reason: opts.reason
|
|
523
|
-
});
|
|
524
|
-
try {
|
|
525
|
-
await this.runLarkCli(this.buildSendCardArgs({
|
|
526
|
-
chatId: opts.chatId,
|
|
527
|
-
profile: opts.profile,
|
|
528
|
-
card
|
|
529
|
-
}), "send-redirect");
|
|
530
|
-
return true;
|
|
531
|
-
} catch (err) {
|
|
532
|
-
if (redirectKey)
|
|
533
|
-
this.redirectsSent.delete(redirectKey);
|
|
534
|
-
logger.warn(`sendRedirectNotice failed (non-fatal) for chat ${opts.chatId}: ${err.message}`);
|
|
535
|
-
return false;
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
479
|
async updateTask(opts) {
|
|
539
480
|
await this.mutexFor(opts.messageId).run(async () => {
|
|
540
481
|
const state = this.states.get(opts.messageId) ?? {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentComponentAdapter,
|
|
3
3
|
init_agent_component_adapter
|
|
4
|
-
} from "./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-833t16n1.js";
|
|
5
5
|
import"./roy-agent-core-1db4vpc6.js";
|
|
6
6
|
import"./roy-agent-core-ze068vc9.js";
|
|
7
7
|
import"./roy-agent-core-e25xkv53.js";
|
|
8
|
-
import"./roy-agent-core-
|
|
9
|
-
import"./roy-agent-core-
|
|
10
|
-
import"./roy-agent-core-
|
|
11
|
-
import"./roy-agent-core-
|
|
8
|
+
import"./roy-agent-core-1pnfkspm.js";
|
|
9
|
+
import"./roy-agent-core-16t0zfbk.js";
|
|
10
|
+
import"./roy-agent-core-jszgaevt.js";
|
|
11
|
+
import"./roy-agent-core-b599jgyd.js";
|
|
12
12
|
import"./roy-agent-core-8seq65bp.js";
|
|
13
13
|
import"./roy-agent-core-jnszp0jq.js";
|
|
14
14
|
import"./roy-agent-core-fs0mn2jk.js";
|