@mastra/core
Version:
63 lines (62 loc) • 2.28 kB
JavaScript
const require_signal_provider = require("./signal-provider-xZOwL9Eb.cjs");
const require_task_state_processor = require("./task-state-processor-BB7omHO3.cjs");
//#region src/signals/task-signal-provider.ts
/**
* Bundles the built-in task tools and the {@link TaskStateProcessor} behind a
* single agent registration.
*
* The task list is held in the thread-scoped `tasks` storage domain (the
* TaskStore) and projected onto the agent state-signal lane by
* `TaskStateProcessor`. Wiring task tracking by hand means registering all four
* task tools **and** the processor, and keeping them in sync — forget the
* processor and the tools work for a single turn but silently lose the list
* across turns. This provider wires both together so that cannot happen.
*
* Task tracking requires a memory-backed thread (`threadId` + `resourceId`) and
* a Mastra `storage` instance (the `tasks` domain is always wired in-memory by
* default). Without memory the tools no-op and report that task tracking
* requires agent memory.
*
* @example
* ```ts
* import { Agent } from '@mastra/core/agent';
* import { TaskSignalProvider } from '@mastra/core/signals';
*
* const agent = new Agent({
* name: 'coder',
* instructions: '...',
* model,
* memory,
* signals: [new TaskSignalProvider()],
* });
* ```
*
* The Agent automatically merges the tools into its toolset and registers the
* processor on its input-processor chain (which propagates the Mastra instance
* so the processor can resolve the TaskStore).
*
* @experimental Agent signals are experimental and may change in a future release.
*/
var TaskSignalProvider = class extends require_signal_provider.SignalProvider {
id = "task-signals";
#processor = new require_task_state_processor.TaskStateProcessor();
getInputProcessors() {
return [this.#processor];
}
getTools() {
return {
task_write: require_task_state_processor.taskWriteTool,
task_update: require_task_state_processor.taskUpdateTool,
task_complete: require_task_state_processor.taskCompleteTool,
task_check: require_task_state_processor.taskCheckTool
};
}
};
//#endregion
Object.defineProperty(exports, "TaskSignalProvider", {
enumerable: true,
get: function() {
return TaskSignalProvider;
}
});
//# sourceMappingURL=signals-DGZ0mRcR.cjs.map