@ddlqhd/agent-sdk 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/{chunk-6X7EYQLS.cjs → chunk-JXAJQGV5.cjs} +24 -14
- package/dist/chunk-JXAJQGV5.cjs.map +1 -0
- package/dist/{chunk-Z45DHTDX.cjs → chunk-P2X3AMDK.cjs} +34 -4
- package/dist/chunk-P2X3AMDK.cjs.map +1 -0
- package/dist/{chunk-MEJHTQJM.js → chunk-TKUPLTGJ.js} +31 -5
- package/dist/chunk-TKUPLTGJ.js.map +1 -0
- package/dist/{chunk-EQ5CXH44.js → chunk-UHENMHUS.js} +17 -7
- package/dist/chunk-UHENMHUS.js.map +1 -0
- package/dist/cli/index.cjs +28 -28
- package/dist/cli/index.js +2 -2
- package/dist/{index-Cw3SfEAB.d.ts → index-CnrY1ZA2.d.ts} +25 -2
- package/dist/{index-D2Qntkn_.d.cts → index-DzBt4ewK.d.cts} +25 -2
- package/dist/index.cjs +90 -74
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/models/index.d.cts +1 -1
- package/dist/models/index.d.ts +1 -1
- package/dist/tools/index.cjs +64 -48
- package/dist/tools/index.d.cts +3 -3
- package/dist/tools/index.d.ts +3 -3
- package/dist/tools/index.js +1 -1
- package/dist/{types-CWPAYWzr.d.cts → types-BUwjMwNH.d.cts} +5 -0
- package/dist/{types-CWPAYWzr.d.ts → types-BUwjMwNH.d.ts} +5 -0
- package/package.json +1 -1
- package/dist/chunk-6X7EYQLS.cjs.map +0 -1
- package/dist/chunk-EQ5CXH44.js.map +0 -1
- package/dist/chunk-MEJHTQJM.js.map +0 -1
- package/dist/chunk-Z45DHTDX.cjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createModel, emitSDKLog, mergeMcpStdioEnv } from './chunk-D3UZNLZO.js';
|
|
3
|
-
import { ToolRegistry, createAgentTool, HookManager, getAllBuiltinTools, getEnvironmentInfo, formatEnvironmentSection } from './chunk-
|
|
3
|
+
import { ToolRegistry, createAgentTool, HookManager, getAllBuiltinTools, getEnvironmentInfo, formatEnvironmentSection, SUBAGENT_EXPLORE_DEFAULT_TOOL_NAMES, subagentExploreDefaultsUnavailableMessage, resolveSubagentTypeAppend } from './chunk-TKUPLTGJ.js';
|
|
4
4
|
import { readFileSync, promises, existsSync } from 'fs';
|
|
5
5
|
import { dirname, join, resolve } from 'path';
|
|
6
6
|
import { fileURLToPath } from 'url';
|
|
@@ -3121,12 +3121,20 @@ ${additionalContent}`;
|
|
|
3121
3121
|
defaultAllowedTools: this.config.subagent?.defaultAllowedTools
|
|
3122
3122
|
};
|
|
3123
3123
|
}
|
|
3124
|
-
resolveSubagentTools(request) {
|
|
3124
|
+
resolveSubagentTools(request, subagentType) {
|
|
3125
3125
|
const subagentConfig = this.getSubagentConfig();
|
|
3126
3126
|
const parentTools = this.toolRegistry.getAll();
|
|
3127
3127
|
const byName = new Map(parentTools.map((tool) => [tool.name, tool]));
|
|
3128
|
-
|
|
3128
|
+
let requestedNames = request.allowed_tools ?? subagentConfig.defaultAllowedTools;
|
|
3129
|
+
let usedExploreDefaultNames = false;
|
|
3130
|
+
if (requestedNames === void 0 && subagentType === "explore") {
|
|
3131
|
+
requestedNames = [...SUBAGENT_EXPLORE_DEFAULT_TOOL_NAMES];
|
|
3132
|
+
usedExploreDefaultNames = true;
|
|
3133
|
+
}
|
|
3129
3134
|
let selected = requestedNames ? requestedNames.map((name) => byName.get(name)).filter((tool) => tool !== void 0) : parentTools.filter((tool) => !tool.isDangerous);
|
|
3135
|
+
if (usedExploreDefaultNames && selected.length === 0) {
|
|
3136
|
+
return { error: subagentExploreDefaultsUnavailableMessage() };
|
|
3137
|
+
}
|
|
3130
3138
|
selected = selected.filter((tool) => tool.name !== "Agent");
|
|
3131
3139
|
selected = selected.filter((tool) => tool.name !== "AskUserQuestion");
|
|
3132
3140
|
if (!subagentConfig.allowDangerousTools) {
|
|
@@ -3162,7 +3170,7 @@ ${additionalContent}`;
|
|
|
3162
3170
|
1,
|
|
3163
3171
|
request.max_iterations ?? this.config.maxIterations ?? DEFAULT_MAX_ITERATIONS
|
|
3164
3172
|
);
|
|
3165
|
-
const resolved = this.resolveSubagentTools(request);
|
|
3173
|
+
const resolved = this.resolveSubagentTools(request, normalizedType);
|
|
3166
3174
|
if (!resolved.tools) {
|
|
3167
3175
|
return {
|
|
3168
3176
|
content: resolved.error ?? "Unable to resolve subagent tools",
|
|
@@ -3186,8 +3194,10 @@ ${additionalContent}`;
|
|
|
3186
3194
|
this.activeSubagentRuns += 1;
|
|
3187
3195
|
try {
|
|
3188
3196
|
await child.waitForInit();
|
|
3197
|
+
const typeAppend = resolveSubagentTypeAppend(normalizedType, this.config.subagent);
|
|
3198
|
+
const mergedSystem = [typeAppend, request.system_prompt].filter((s) => typeof s === "string" && s.trim().length > 0).join("\n\n");
|
|
3189
3199
|
const runPromise = child.run(request.prompt, {
|
|
3190
|
-
systemPrompt:
|
|
3200
|
+
systemPrompt: mergedSystem || void 0
|
|
3191
3201
|
});
|
|
3192
3202
|
const timeoutPromise = new Promise((_, reject) => {
|
|
3193
3203
|
const timer = setTimeout(() => {
|
|
@@ -3511,5 +3521,5 @@ function validateMCPConfig(config) {
|
|
|
3511
3521
|
}
|
|
3512
3522
|
|
|
3513
3523
|
export { Agent, DEFAULT_MAX_ITERATIONS, DEFAULT_SYSTEM_PROMPT, JsonlStorage, MCPAdapter, MCPClient, MODEL_STREAM_EVENT_TYPES, MemoryManager, MemoryStorage, PACKAGE_VERSION, SessionManager, SkillLoader, SkillRegistry, StreamChunkProcessor, createAgent, createJsonlStorage, createMCPAdapter, createMCPClient, createMemoryStorage, createSessionManager, createSkillLoader, createSkillRegistry, createStorage, formatMcpToolName, getLatestSessionId, getSessionStoragePath, isMcpPrefixedToolName, isModelStreamEventType, loadMCPConfig, parseSkillMd, validateMCPConfig };
|
|
3514
|
-
//# sourceMappingURL=chunk-
|
|
3515
|
-
//# sourceMappingURL=chunk-
|
|
3524
|
+
//# sourceMappingURL=chunk-UHENMHUS.js.map
|
|
3525
|
+
//# sourceMappingURL=chunk-UHENMHUS.js.map
|