hammer-ai 0.2.11 → 0.2.12
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/index.d.ts +16 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2259,6 +2259,13 @@ interface SubAgentToolOptions {
|
|
|
2259
2259
|
maxSteps?: number;
|
|
2260
2260
|
/** Temperature for LLM calls. Defaults to LLMClient's built-in default (0.2). */
|
|
2261
2261
|
temperature?: number;
|
|
2262
|
+
/**
|
|
2263
|
+
* Whether `execute()` awaits the sub-agent loop before returning.
|
|
2264
|
+
* - `true` (default): the parent agent blocks until the sub-agent finishes.
|
|
2265
|
+
* - `false`: the loop is fired in the background and `execute()` returns
|
|
2266
|
+
* immediately. Override `onSubAgentDispatched()` to track the promise.
|
|
2267
|
+
*/
|
|
2268
|
+
blocking?: boolean;
|
|
2262
2269
|
}
|
|
2263
2270
|
/**
|
|
2264
2271
|
* A Tool that runs its own contained agentic loop.
|
|
@@ -2295,6 +2302,15 @@ declare abstract class SubAgentTool extends Tool {
|
|
|
2295
2302
|
* Override when `getSchema()` adds parameters beyond `task`.
|
|
2296
2303
|
*/
|
|
2297
2304
|
protected buildSubAgentTask(params: Record<string, any>): string;
|
|
2305
|
+
/**
|
|
2306
|
+
* Called when `blocking` is `false`, right after the sub-agent loop is
|
|
2307
|
+
* dispatched in the background. Override to track the promise (e.g. for
|
|
2308
|
+
* pending-generation registries) and return a custom immediate result.
|
|
2309
|
+
*
|
|
2310
|
+
* @param params The raw parameters passed to `execute()`.
|
|
2311
|
+
* @param promise Settles when the background sub-agent loop completes.
|
|
2312
|
+
*/
|
|
2313
|
+
protected onSubAgentDispatched(_params: Record<string, any>, _promise: Promise<void>): ToolResult;
|
|
2298
2314
|
execute(params: Record<string, any>): Promise<ToolResult>;
|
|
2299
2315
|
protected runSubAgentLoop(task: string): Promise<ToolResult>;
|
|
2300
2316
|
}
|
package/dist/index.js
CHANGED
|
@@ -7195,10 +7195,28 @@ var SubAgentTool = class extends Tool {
|
|
|
7195
7195
|
buildSubAgentTask(params) {
|
|
7196
7196
|
return typeof params.task === "string" ? params.task.trim() : "";
|
|
7197
7197
|
}
|
|
7198
|
+
// ---- non-blocking hook ------------------------------------------------
|
|
7199
|
+
/**
|
|
7200
|
+
* Called when `blocking` is `false`, right after the sub-agent loop is
|
|
7201
|
+
* dispatched in the background. Override to track the promise (e.g. for
|
|
7202
|
+
* pending-generation registries) and return a custom immediate result.
|
|
7203
|
+
*
|
|
7204
|
+
* @param params The raw parameters passed to `execute()`.
|
|
7205
|
+
* @param promise Settles when the background sub-agent loop completes.
|
|
7206
|
+
*/
|
|
7207
|
+
onSubAgentDispatched(_params, _promise) {
|
|
7208
|
+
return { success: true, pending: true, message: "Sub-agent started in background." };
|
|
7209
|
+
}
|
|
7198
7210
|
// ---- execute ---------------------------------------------------------
|
|
7199
7211
|
async execute(params) {
|
|
7200
7212
|
const task = this.buildSubAgentTask(params);
|
|
7201
7213
|
if (!task) return { success: false, error: "task is required" };
|
|
7214
|
+
if (this.subAgentOptions.blocking === false) {
|
|
7215
|
+
const promise = this.runSubAgentLoop(task).then(() => {
|
|
7216
|
+
}).catch(() => {
|
|
7217
|
+
});
|
|
7218
|
+
return this.onSubAgentDispatched(params, promise);
|
|
7219
|
+
}
|
|
7202
7220
|
return this.runSubAgentLoop(task);
|
|
7203
7221
|
}
|
|
7204
7222
|
// ---- core loop -------------------------------------------------------
|