@cuylabs/agent-core 0.8.0 → 0.10.0
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/README.md +33 -17
- package/dist/chunk-2O4MCSQS.js +780 -0
- package/dist/chunk-2TTOLHBT.js +198 -0
- package/dist/chunk-5FMSGQVX.js +281 -0
- package/dist/chunk-5NVVNXPQ.js +288 -0
- package/dist/{chunk-CAA7FHIH.js → chunk-6HZBHFOL.js} +3 -103
- package/dist/chunk-CJI7PVS2.js +58 -0
- package/dist/{chunk-N6HWIEEA.js → chunk-CMYN2RCB.js} +278 -61
- package/dist/chunk-FII65CN7.js +117 -0
- package/dist/{chunk-IVUJDISU.js → chunk-GFTW23FV.js} +5 -14
- package/dist/chunk-I6PKJ7XQ.js +292 -0
- package/dist/{chunk-BDBZ3SLK.js → chunk-ICZ66572.js} +48 -4
- package/dist/chunk-KYLPMBHD.js +316 -0
- package/dist/chunk-MXAP4UG6.js +2956 -0
- package/dist/{chunk-RZITT45F.js → chunk-N3VX7FEE.js} +39 -6
- package/dist/{chunk-YSLSEQ6B.js → chunk-NDZWXCBZ.js} +218 -95
- package/dist/{chunk-P6YF7USR.js → chunk-Q742PSH3.js} +23 -38
- package/dist/chunk-QAL3OMI3.js +943 -0
- package/dist/{chunk-RFEKJKTO.js → chunk-RN6WZEUF.js} +330 -280
- package/dist/{chunk-ZXAKHMWH.js → chunk-ROTGCYDW.js} +22 -84
- package/dist/chunk-SPBFQXOT.js +0 -0
- package/dist/{chunk-LRHOS4ZN.js → chunk-SPILYYDF.js} +3 -2
- package/dist/chunk-SSFBF3US.js +602 -0
- package/dist/chunk-SZ2XBPTW.js +8 -0
- package/dist/chunk-T4UIX5D7.js +115 -0
- package/dist/chunk-TIHPYVAJ.js +102 -0
- package/dist/{chunk-YUUJK53A.js → chunk-TOTDGK3P.js} +1 -1
- package/dist/chunk-V4RFNEET.js +563 -0
- package/dist/chunk-VOUEJSW6.js +0 -0
- package/dist/{chunk-4BDA7DQY.js → chunk-WBPOZ7CL.js} +673 -273
- package/dist/chunk-X4VN4GIJ.js +185 -0
- package/dist/dispatch/index.d.ts +93 -0
- package/dist/dispatch/index.js +37 -0
- package/dist/events/index.d.ts +93 -0
- package/dist/events/index.js +6 -0
- package/dist/{runtime → execution}/index.d.ts +120 -34
- package/dist/{runtime → execution}/index.js +18 -13
- package/dist/index-BCqEGzBj.d.ts +251 -0
- package/dist/index.d.ts +490 -122
- package/dist/index.js +2104 -615
- package/dist/{errors → inference/errors}/index.d.ts +2 -2
- package/dist/{errors → inference/errors}/index.js +1 -1
- package/dist/inference/index.d.ts +16 -23
- package/dist/inference/index.js +45 -16
- package/dist/instance-BqV2D5pc.d.ts +5723 -0
- package/dist/logger/index.d.ts +50 -0
- package/dist/logger/index.js +11 -0
- package/dist/mcp/index.d.ts +5 -9
- package/dist/mcp/index.js +2 -3
- package/dist/middleware/index.d.ts +10 -149
- package/dist/middleware/index.js +11 -3
- package/dist/model-messages-B4nK9D1-.d.ts +13 -0
- package/dist/models/index.d.ts +23 -18
- package/dist/models/index.js +48 -11
- package/dist/models/reasoning/index.d.ts +4 -0
- package/dist/{reasoning → models/reasoning}/index.js +3 -3
- package/dist/plugin/index.d.ts +458 -0
- package/dist/plugin/index.js +32 -0
- package/dist/profiles/index.d.ts +55 -0
- package/dist/profiles/index.js +30 -0
- package/dist/prompt/index.d.ts +8 -12
- package/dist/prompt/index.js +3 -2
- package/dist/safety/index.d.ts +109 -14
- package/dist/safety/index.js +59 -3
- package/dist/sandbox/index.d.ts +81 -0
- package/dist/sandbox/index.js +1 -0
- package/dist/skill/index.d.ts +10 -8
- package/dist/skill/index.js +3 -3
- package/dist/storage/index.d.ts +12 -4
- package/dist/storage/index.js +1 -1
- package/dist/subagents/index.d.ts +177 -0
- package/dist/subagents/index.js +78 -0
- package/dist/team/index.d.ts +544 -0
- package/dist/team/index.js +41 -0
- package/dist/tool/host/index.d.ts +41 -0
- package/dist/tool/host/index.js +10 -0
- package/dist/tool/index.d.ts +125 -21
- package/dist/tool/index.js +20 -13
- package/dist/{types-VQgymC1N.d.ts → types-Bj_J8u_W.d.ts} +44 -64
- package/dist/{types-CHiPh8U2.d.ts → types-C_LCeYNg.d.ts} +7 -7
- package/dist/types-RSCv7nQ4.d.ts +59 -0
- package/package.json +58 -53
- package/dist/builder-UpOWQMW3.d.ts +0 -34
- package/dist/chunk-7MUFEN4K.js +0 -559
- package/dist/chunk-7VKQ4WPB.js +0 -73
- package/dist/chunk-BFM2YHNM.js +0 -222
- package/dist/chunk-DWYX7ASF.js +0 -26
- package/dist/chunk-KUVSERLJ.js +0 -50
- package/dist/chunk-N7P4PN3O.js +0 -84
- package/dist/chunk-SDSBEQXG.js +0 -157
- package/dist/chunk-SQU2AJHO.js +0 -305
- package/dist/chunk-VBWWUHWI.js +0 -724
- package/dist/chunk-VEKUXUVF.js +0 -41
- package/dist/chunk-VNQBHPCT.js +0 -398
- package/dist/chunk-WWYYNWEW.js +0 -259
- package/dist/context/index.d.ts +0 -259
- package/dist/context/index.js +0 -26
- package/dist/events-CE72w8W4.d.ts +0 -149
- package/dist/host/index.d.ts +0 -45
- package/dist/host/index.js +0 -8
- package/dist/index-CWSchSql.d.ts +0 -1058
- package/dist/messages-BYWGn8TY.d.ts +0 -110
- package/dist/presets/index.d.ts +0 -53
- package/dist/presets/index.js +0 -28
- package/dist/reasoning/index.d.ts +0 -116
- package/dist/registry-DwYqsQkX.d.ts +0 -164
- package/dist/runner-e2YRcUoX.d.ts +0 -786
- package/dist/scope/index.d.ts +0 -10
- package/dist/scope/index.js +0 -14
- package/dist/session-manager-B_CWGTsl.d.ts +0 -274
- package/dist/signal/index.d.ts +0 -28
- package/dist/signal/index.js +0 -6
- package/dist/sub-agent/index.d.ts +0 -23
- package/dist/sub-agent/index.js +0 -15
- package/dist/tool-BHbyUAy3.d.ts +0 -150
- package/dist/tool-DLXAR9Ce.d.ts +0 -145
- package/dist/tracker-DClqYqTj.d.ts +0 -96
- package/dist/tracking/index.d.ts +0 -111
- package/dist/tracking/index.js +0 -20
- package/dist/types-BfNpU8NS.d.ts +0 -270
- package/dist/types-BnpEOYV-.d.ts +0 -50
- package/dist/types-CQL-SvTn.d.ts +0 -29
- package/dist/types-CWm-7rvB.d.ts +0 -55
- package/dist/types-KKDrdU9Y.d.ts +0 -325
- package/dist/types-QA4WhEfz.d.ts +0 -138
- package/dist/types-QKHHQLLq.d.ts +0 -336
- package/dist/types-YuWV4ag7.d.ts +0 -72
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// src/logger/logger.ts
|
|
2
|
+
import { createWriteStream, mkdirSync } from "fs";
|
|
3
|
+
import { dirname } from "path";
|
|
4
|
+
var LEVEL_ORDER = {
|
|
5
|
+
debug: 0,
|
|
6
|
+
info: 1,
|
|
7
|
+
warn: 2,
|
|
8
|
+
error: 3
|
|
9
|
+
};
|
|
10
|
+
function noop() {
|
|
11
|
+
}
|
|
12
|
+
var silentLogger = {
|
|
13
|
+
debug: noop,
|
|
14
|
+
info: noop,
|
|
15
|
+
warn: noop,
|
|
16
|
+
error: noop,
|
|
17
|
+
child() {
|
|
18
|
+
return silentLogger;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
function formatMeta(meta) {
|
|
22
|
+
const parts = [];
|
|
23
|
+
for (const [key, value] of Object.entries(meta)) {
|
|
24
|
+
if (value === void 0) continue;
|
|
25
|
+
parts.push(
|
|
26
|
+
typeof value === "string" ? `${key}=${value}` : `${key}=${JSON.stringify(value)}`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
return parts.length > 0 ? ` ${parts.join(" ")}` : "";
|
|
30
|
+
}
|
|
31
|
+
function createLoggerWithPrefix(minLevel, prefix) {
|
|
32
|
+
function shouldLog(level) {
|
|
33
|
+
return LEVEL_ORDER[level] >= minLevel;
|
|
34
|
+
}
|
|
35
|
+
function emit(level, consoleFn, message, meta) {
|
|
36
|
+
if (!shouldLog(level)) return;
|
|
37
|
+
const metaStr = meta ? formatMeta(meta) : "";
|
|
38
|
+
consoleFn(`[${prefix}] ${message}${metaStr}`);
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
debug(message, meta) {
|
|
42
|
+
emit("debug", console.debug, message, meta);
|
|
43
|
+
},
|
|
44
|
+
info(message, meta) {
|
|
45
|
+
emit("info", console.info, message, meta);
|
|
46
|
+
},
|
|
47
|
+
warn(message, meta) {
|
|
48
|
+
emit("warn", console.warn, message, meta);
|
|
49
|
+
},
|
|
50
|
+
error(message, meta) {
|
|
51
|
+
emit("error", console.error, message, meta);
|
|
52
|
+
},
|
|
53
|
+
child(namespace) {
|
|
54
|
+
return createLoggerWithPrefix(minLevel, `${prefix}:${namespace}`);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function createConsoleLogger(options = {}) {
|
|
59
|
+
const envLevel = typeof process !== "undefined" ? process.env.AGENT_LOG_LEVEL : void 0;
|
|
60
|
+
const level = options.level ?? envLevel ?? "warn";
|
|
61
|
+
const prefix = options.prefix ?? "agent-core";
|
|
62
|
+
return createLoggerWithPrefix(LEVEL_ORDER[level], prefix);
|
|
63
|
+
}
|
|
64
|
+
function formatTimestamp() {
|
|
65
|
+
return (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace("Z", "");
|
|
66
|
+
}
|
|
67
|
+
function createFileLoggerWithPrefix(stream, minLevel, prefix) {
|
|
68
|
+
function shouldLog(level) {
|
|
69
|
+
return LEVEL_ORDER[level] >= minLevel;
|
|
70
|
+
}
|
|
71
|
+
function emit(level, message, meta) {
|
|
72
|
+
if (!shouldLog(level)) return;
|
|
73
|
+
const metaStr = meta ? formatMeta(meta) : "";
|
|
74
|
+
stream.write(`${formatTimestamp()} ${level.toUpperCase().padEnd(5)} [${prefix}] ${message}${metaStr}
|
|
75
|
+
`);
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
debug(message, meta) {
|
|
79
|
+
emit("debug", message, meta);
|
|
80
|
+
},
|
|
81
|
+
info(message, meta) {
|
|
82
|
+
emit("info", message, meta);
|
|
83
|
+
},
|
|
84
|
+
warn(message, meta) {
|
|
85
|
+
emit("warn", message, meta);
|
|
86
|
+
},
|
|
87
|
+
error(message, meta) {
|
|
88
|
+
emit("error", message, meta);
|
|
89
|
+
},
|
|
90
|
+
child(namespace) {
|
|
91
|
+
return createFileLoggerWithPrefix(stream, minLevel, `${prefix}:${namespace}`);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function createFileLogger(options) {
|
|
96
|
+
mkdirSync(dirname(options.filePath), { recursive: true });
|
|
97
|
+
const stream = createWriteStream(options.filePath, { flags: "a" });
|
|
98
|
+
stream.on("error", () => {
|
|
99
|
+
});
|
|
100
|
+
const level = options.level ?? "debug";
|
|
101
|
+
const prefix = options.prefix ?? "agent-core";
|
|
102
|
+
const logger = createFileLoggerWithPrefix(stream, LEVEL_ORDER[level], prefix);
|
|
103
|
+
return {
|
|
104
|
+
...logger,
|
|
105
|
+
close() {
|
|
106
|
+
stream.end();
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export {
|
|
112
|
+
silentLogger,
|
|
113
|
+
createConsoleLogger,
|
|
114
|
+
createFileLogger
|
|
115
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// src/profiles/patterns.ts
|
|
2
|
+
function globToRegex(pattern) {
|
|
3
|
+
const escaped = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*").replace(/\?/g, ".");
|
|
4
|
+
return new RegExp(`^${escaped}$`, "i");
|
|
5
|
+
}
|
|
6
|
+
function matchesPatterns(id, patterns) {
|
|
7
|
+
return patterns.some((pattern) => globToRegex(pattern).test(id));
|
|
8
|
+
}
|
|
9
|
+
function filterTools(tools, options) {
|
|
10
|
+
const allowPatterns = options.allow ?? [];
|
|
11
|
+
const denyPatterns = options.deny ?? [];
|
|
12
|
+
return tools.filter((tool) => {
|
|
13
|
+
const matchesAllow = allowPatterns.length === 0 || matchesPatterns(tool.id, allowPatterns);
|
|
14
|
+
if (!matchesAllow) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
const matchesDeny = denyPatterns.length > 0 && matchesPatterns(tool.id, denyPatterns);
|
|
18
|
+
if (matchesDeny && allowPatterns.length === 0) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// src/profiles/apply.ts
|
|
26
|
+
function applyProfile(profile, availableTools, baseSystemPrompt) {
|
|
27
|
+
const tools = filterTools(availableTools, {
|
|
28
|
+
allow: profile.allowTools,
|
|
29
|
+
deny: profile.denyTools
|
|
30
|
+
});
|
|
31
|
+
let systemPrompt = profile.systemPrompt;
|
|
32
|
+
if (systemPrompt && baseSystemPrompt) {
|
|
33
|
+
systemPrompt = systemPrompt.replace("{basePrompt}", baseSystemPrompt);
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
name: profile.name,
|
|
37
|
+
systemPrompt,
|
|
38
|
+
tools: tools.length > 0 ? tools : void 0,
|
|
39
|
+
temperature: profile.temperature,
|
|
40
|
+
maxSteps: profile.maxSteps,
|
|
41
|
+
reasoningLevel: profile.reasoningLevel,
|
|
42
|
+
model: profile.model
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function mergeProfiles(...profiles) {
|
|
46
|
+
if (profiles.length === 0) {
|
|
47
|
+
throw new Error("mergeProfiles requires at least one profile");
|
|
48
|
+
}
|
|
49
|
+
if (profiles.length === 1) {
|
|
50
|
+
return profiles[0];
|
|
51
|
+
}
|
|
52
|
+
const [first, ...rest] = profiles;
|
|
53
|
+
const allAllow = [];
|
|
54
|
+
const allDeny = [];
|
|
55
|
+
for (const profile of profiles) {
|
|
56
|
+
if (profile.allowTools?.length) {
|
|
57
|
+
allAllow.push(profile.allowTools);
|
|
58
|
+
}
|
|
59
|
+
if (profile.denyTools?.length) {
|
|
60
|
+
allDeny.push(...profile.denyTools);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const combinedAllow = allAllow.length > 0 ? allAllow.reduce(
|
|
64
|
+
(left, right) => left.length <= right.length ? left : right
|
|
65
|
+
) : void 0;
|
|
66
|
+
return {
|
|
67
|
+
name: profiles.map((profile) => profile.name).join("+"),
|
|
68
|
+
description: profiles.map((profile) => profile.description).join(" | "),
|
|
69
|
+
allowTools: combinedAllow,
|
|
70
|
+
denyTools: allDeny.length > 0 ? [...new Set(allDeny)] : void 0,
|
|
71
|
+
systemPrompt: rest.reduce(
|
|
72
|
+
(value, profile) => profile.systemPrompt ?? value,
|
|
73
|
+
first.systemPrompt
|
|
74
|
+
),
|
|
75
|
+
temperature: rest.reduce(
|
|
76
|
+
(value, profile) => profile.temperature ?? value,
|
|
77
|
+
first.temperature
|
|
78
|
+
),
|
|
79
|
+
maxSteps: rest.reduce(
|
|
80
|
+
(value, profile) => profile.maxSteps ?? value,
|
|
81
|
+
first.maxSteps
|
|
82
|
+
),
|
|
83
|
+
reasoningLevel: rest.reduce(
|
|
84
|
+
(value, profile) => profile.reasoningLevel ?? value,
|
|
85
|
+
first.reasoningLevel
|
|
86
|
+
),
|
|
87
|
+
model: rest.reduce((value, profile) => profile.model ?? value, first.model)
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function createProfile(options) {
|
|
91
|
+
return {
|
|
92
|
+
description: options.description ?? `Custom profile: ${options.name}`,
|
|
93
|
+
...options
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export {
|
|
98
|
+
filterTools,
|
|
99
|
+
applyProfile,
|
|
100
|
+
mergeProfiles,
|
|
101
|
+
createProfile
|
|
102
|
+
};
|