@toolpack-sdk/agents 2.3.0 → 2.4.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 +175 -0
- package/dist/{base-agent-65162dq7.d.cts → base-agent-C4fYjHPu.d.ts} +13 -1
- package/dist/{base-agent-DzspMyaG.d.ts → base-agent-Dqca3WLY.d.cts} +13 -1
- package/dist/capabilities/index.cjs +27 -9
- package/dist/capabilities/index.d.cts +3 -3
- package/dist/capabilities/index.d.ts +3 -3
- package/dist/capabilities/index.js +27 -9
- package/dist/channels/index.d.cts +2 -2
- package/dist/channels/index.d.ts +2 -2
- package/dist/{eval-report-C6dSvR3Y.d.ts → eval-report-CO98LRUC.d.ts} +1 -1
- package/dist/{eval-report-BUD6NRiP.d.cts → eval-report-DV-wNcjW.d.cts} +1 -1
- package/dist/{index-BxUlu-qG.d.ts → index-C0OlSL3f.d.ts} +1 -1
- package/dist/{index-DrigwC1A.d.cts → index-Cg5gWiPj.d.cts} +1 -1
- package/dist/index.cjs +45 -27
- package/dist/index.d.cts +111 -9
- package/dist/index.d.ts +111 -9
- package/dist/index.js +45 -27
- package/dist/{intent-classifier-agent-mmNoAozf.d.ts → intent-classifier-agent-ACQSotfT.d.ts} +2 -2
- package/dist/{intent-classifier-agent-D0rWtviD.d.cts → intent-classifier-agent-CPKmOVJx.d.cts} +2 -2
- package/dist/interceptors/index.d.cts +4 -4
- package/dist/interceptors/index.d.ts +4 -4
- package/dist/testing/index.d.cts +3 -3
- package/dist/testing/index.d.ts +3 -3
- package/dist/{types-C3eW-auY.d.cts → types-C3EZvpe0.d.cts} +57 -1
- package/dist/{types-C3eW-auY.d.ts → types-C3EZvpe0.d.ts} +57 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,19 +1,36 @@
|
|
|
1
|
-
import { A as AgentInput, a as AgentResult,
|
|
2
|
-
export { b as AgentDelegationConfig,
|
|
3
|
-
import { B as BaseAgent, A as AgentMindConfig } from './base-agent-
|
|
4
|
-
export { a as AgentEvents, C as ConfidenceLevel, G as GoalPriority, b as GoalStatus, M as MindBelief, c as MindEntry, d as MindEntryType, e as MindGoal, f as MindRecallResult, g as MindReflection, h as MindTtlDefaults } from './base-agent-
|
|
1
|
+
import { B as BaseAgentOptions, A as AgentInput, a as AgentResult, d as IAgentRegistry, f as AgentOutput, g as AgentInstance, C as ChannelInterface, P as PendingAsk } from './types-C3EZvpe0.cjs';
|
|
2
|
+
export { b as AgentDelegationConfig, e as AgentRunOptions, c as AgentSpawnConfig, h as AgentSpawnTemplate, I as Interceptor, i as InterceptorChainConfig, j as InterceptorContext, k as InterceptorResult, N as NextFunction, S as SKIP_SENTINEL, W as WorkflowStep, l as isSkipSentinel, s as skip } from './types-C3EZvpe0.cjs';
|
|
3
|
+
import { B as BaseAgent, A as AgentMindConfig } from './base-agent-Dqca3WLY.cjs';
|
|
4
|
+
export { a as AgentEvents, C as ConfidenceLevel, G as GoalPriority, b as GoalStatus, M as MindBelief, c as MindEntry, d as MindEntryType, e as MindGoal, f as MindRecallResult, g as MindReflection, h as MindTtlDefaults } from './base-agent-Dqca3WLY.cjs';
|
|
5
5
|
import { ModeConfig, ConversationStore, AssemblerOptions, AssembledPrompt, RequestToolDefinition, ToolProject } from 'toolpack-sdk';
|
|
6
6
|
export { AssembledPrompt, AssemblerOptions, ConversationScope, ConversationStore, GetOptions, InMemoryConversationStore, InMemoryConversationStoreConfig, Participant, PromptMessage, ConversationSearchOptions as SearchOptions, StoredMessage } from 'toolpack-sdk';
|
|
7
|
-
import { S as SchedulerStore } from './index-
|
|
8
|
-
export { B as BaseChannel, C as CreateJobOptions, a as CreateJobResult, D as DiscordChannel, b as DiscordChannelConfig, E as EmailChannel, c as EmailChannelConfig, J as JobStatus, M as McpChannel, d as McpChannelConfig, e as SMSChannel, f as SMSChannelConfig, g as ScheduledChannel, h as ScheduledChannelConfig, i as ScheduledJob, j as SlackChannel, k as SlackChannelConfig, T as TelegramChannel, l as TelegramChannelConfig, W as WebhookChannel, m as WebhookChannelConfig } from './index-
|
|
9
|
-
export { I as IntentClassification, a as IntentClassifierAgent, b as IntentClassifierInput } from './intent-classifier-agent-
|
|
7
|
+
import { S as SchedulerStore } from './index-Cg5gWiPj.cjs';
|
|
8
|
+
export { B as BaseChannel, C as CreateJobOptions, a as CreateJobResult, D as DiscordChannel, b as DiscordChannelConfig, E as EmailChannel, c as EmailChannelConfig, J as JobStatus, M as McpChannel, d as McpChannelConfig, e as SMSChannel, f as SMSChannelConfig, g as ScheduledChannel, h as ScheduledChannelConfig, i as ScheduledJob, j as SlackChannel, k as SlackChannelConfig, T as TelegramChannel, l as TelegramChannelConfig, W as WebhookChannel, m as WebhookChannelConfig } from './index-Cg5gWiPj.cjs';
|
|
9
|
+
export { I as IntentClassification, a as IntentClassifierAgent, b as IntentClassifierInput } from './intent-classifier-agent-CPKmOVJx.cjs';
|
|
10
10
|
import { SummarizerAgent } from './capabilities/index.cjs';
|
|
11
11
|
export { HistoryTurn, SummarizerInput, SummarizerOutput } from './capabilities/index.cjs';
|
|
12
12
|
export { AddressCheckConfig, AddressCheckResult, CaptureHistoryConfig, ComposedChain, DepthExceededError, DepthGuardConfig, EventDedupConfig, IntentClassifierInterceptorConfig, InvocationDepthExceededError, NoiseFilterConfig, OTelSpan, OTelSpanOptions, OTelSpanStatus, OTelSpanStatusCode, OTelTracer, OTelTracerConfig, OTelTracerProvider, ParticipantResolverConfig, RateLimitConfig, SelfFilterConfig, TracerConfig, composeChain, createAddressCheckInterceptor, createCaptureInterceptor, createDepthGuardInterceptor, createEventDedupInterceptor, createIntentClassifierInterceptor, createNoiseFilterInterceptor, createOTelTracerInterceptor, createParticipantResolverInterceptor, createRateLimitInterceptor, createSelfFilterInterceptor, createTracerInterceptor, executeChain } from './interceptors/index.cjs';
|
|
13
|
-
export { C as ContainsScorer, a as CustomScorer, E as EvalCase, b as EvalCaseResult, c as EvalDataset, d as EvalImprovement, e as EvalRegression, f as EvalReport, g as EvalRun, h as EvalRunner, i as EvalRunnerOptions, j as EvalScoredResult, k as EvalScoredRun, l as EvalScorer, m as EvalVerdict, n as ExactMatchScorer, L as LLMJudgeScorer, o as LLMJudgeScorerOptions, p as compareEvalRuns, q as formatEvalReport } from './eval-report-
|
|
13
|
+
export { C as ContainsScorer, a as CustomScorer, E as EvalCase, b as EvalCaseResult, c as EvalDataset, d as EvalImprovement, e as EvalRegression, f as EvalReport, g as EvalRun, h as EvalRunner, i as EvalRunnerOptions, j as EvalScoredResult, k as EvalScoredRun, l as EvalScorer, m as EvalVerdict, n as ExactMatchScorer, L as LLMJudgeScorer, o as LLMJudgeScorerOptions, p as compareEvalRuns, q as formatEvalReport } from './eval-report-DV-wNcjW.cjs';
|
|
14
14
|
import 'events';
|
|
15
15
|
import '@toolpack-sdk/knowledge';
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Lightweight concrete agent for one-off tasks.
|
|
19
|
+
*
|
|
20
|
+
* Typically instantiated internally by the `spawn_agent` tool. Can also be
|
|
21
|
+
* constructed directly for testing or advanced orchestration. The mode (and
|
|
22
|
+
* its system prompt) is supplied at construction time by the caller.
|
|
23
|
+
*
|
|
24
|
+
* No channels, no interceptors, no registry entry.
|
|
25
|
+
*/
|
|
26
|
+
declare class EphemeralAgent extends BaseAgent {
|
|
27
|
+
name: string;
|
|
28
|
+
description: string;
|
|
29
|
+
mode: ModeConfig | string;
|
|
30
|
+
constructor(name: string, description: string, mode: ModeConfig | string, options: BaseAgentOptions);
|
|
31
|
+
invokeAgent(input: AgentInput): Promise<AgentResult>;
|
|
32
|
+
}
|
|
33
|
+
|
|
17
34
|
/**
|
|
18
35
|
* Transport interface for agent-to-agent communication.
|
|
19
36
|
* Enables pluggable transport mechanisms (local, JSON-RPC, etc.)
|
|
@@ -54,6 +71,10 @@ declare class AgentRegistry implements IAgentRegistry {
|
|
|
54
71
|
_transport: AgentTransport;
|
|
55
72
|
/** In-memory store for pending human-in-the-loop questions. Stored as Map<conversationId, PendingAsk[]> */
|
|
56
73
|
private pendingAsks;
|
|
74
|
+
private _started;
|
|
75
|
+
private _restarting;
|
|
76
|
+
private _restartScheduled;
|
|
77
|
+
private _deadlineTimer?;
|
|
57
78
|
/**
|
|
58
79
|
* @param agents Agent instances to coordinate. Each agent's `channels` and
|
|
59
80
|
* `interceptors` are configured on the agent itself.
|
|
@@ -71,6 +92,30 @@ declare class AgentRegistry implements IAgentRegistry {
|
|
|
71
92
|
* 4. Calls `agent.start()` which binds message handlers and begins listening.
|
|
72
93
|
*/
|
|
73
94
|
start(): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Add an agent to the registry. If the registry is already started the agent
|
|
97
|
+
* is fully wired and started immediately; otherwise it is deferred until start().
|
|
98
|
+
*/
|
|
99
|
+
addAgent(agent: BaseAgent): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Remove an agent by name. Stops the agent and unregisters its channels.
|
|
102
|
+
* No-op when the name is not found.
|
|
103
|
+
*/
|
|
104
|
+
removeAgent(name: string): Promise<void>;
|
|
105
|
+
/** Returns true when all registered agents have no in-progress conversations. */
|
|
106
|
+
isAllIdle(): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Schedule a graceful restart once all agents are idle, or force one after
|
|
109
|
+
* maxWaitMinutes (default 30). Idempotent — subsequent calls are ignored.
|
|
110
|
+
*
|
|
111
|
+
* Uses process.exit(0) so a process manager (PM2, systemd) can restart with
|
|
112
|
+
* the updated dist/ and .env. Override _exit() in tests to prevent that.
|
|
113
|
+
*/
|
|
114
|
+
scheduleRestart(options?: {
|
|
115
|
+
maxWaitMinutes?: number;
|
|
116
|
+
}): void;
|
|
117
|
+
_executeRestart(): Promise<void>;
|
|
118
|
+
protected _exit(code: number): void;
|
|
74
119
|
/**
|
|
75
120
|
* Send output to a named channel.
|
|
76
121
|
*/
|
|
@@ -111,6 +156,63 @@ declare class AgentError extends Error {
|
|
|
111
156
|
constructor(message: string);
|
|
112
157
|
}
|
|
113
158
|
|
|
159
|
+
type WatchFn = (path: string, options: {
|
|
160
|
+
recursive?: boolean;
|
|
161
|
+
}, listener: (event: string, filename: string | null) => void) => {
|
|
162
|
+
close(): void;
|
|
163
|
+
};
|
|
164
|
+
type SpawnFn = (cmd: string, args: string[], options: {
|
|
165
|
+
cwd?: string;
|
|
166
|
+
stdio?: unknown;
|
|
167
|
+
}) => {
|
|
168
|
+
stderr: {
|
|
169
|
+
on(event: string, listener: (data: Buffer) => void): void;
|
|
170
|
+
} | null;
|
|
171
|
+
on(event: string, listener: (arg: unknown) => void): void;
|
|
172
|
+
};
|
|
173
|
+
interface HotReloadWatcherOptions {
|
|
174
|
+
/** Directories or files to watch. */
|
|
175
|
+
watchPaths: string[];
|
|
176
|
+
/** Working directory for tsc --build (defaults to process.cwd()). */
|
|
177
|
+
cwd?: string;
|
|
178
|
+
/**
|
|
179
|
+
* How long to wait after the last file change before compiling (default: 30 000 ms).
|
|
180
|
+
* Set higher when developers routinely edit many files across several minutes.
|
|
181
|
+
* The timer resets on every new change, so compile only fires after a period of silence.
|
|
182
|
+
*/
|
|
183
|
+
debounceMs?: number;
|
|
184
|
+
/** Called after a successful compile or after an .env file change. */
|
|
185
|
+
onRestartNeeded: () => void;
|
|
186
|
+
/** Called when tsc --build exits non-zero. Restart is NOT triggered. */
|
|
187
|
+
onCompileError?: (stderr: string) => void;
|
|
188
|
+
/** Inject a custom spawn function (for testing). */
|
|
189
|
+
spawnFn?: SpawnFn;
|
|
190
|
+
/** Inject a custom watch function (for testing). */
|
|
191
|
+
watchFn?: WatchFn;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Watches source files and .env files for changes. On a TypeScript change it
|
|
195
|
+
* runs tsc --build and, on success, calls onRestartNeeded. On an .env change
|
|
196
|
+
* it calls onRestartNeeded directly. Multiple rapid changes within debounceMs
|
|
197
|
+
* are collapsed into a single compile/notify.
|
|
198
|
+
*/
|
|
199
|
+
declare class HotReloadWatcher {
|
|
200
|
+
private readonly cwd;
|
|
201
|
+
private readonly debounceMs;
|
|
202
|
+
private readonly onRestartNeeded;
|
|
203
|
+
private readonly onCompileError?;
|
|
204
|
+
private readonly spawnFn;
|
|
205
|
+
private readonly watchFn;
|
|
206
|
+
private readonly watchPaths;
|
|
207
|
+
private watchers;
|
|
208
|
+
private debounceTimer?;
|
|
209
|
+
constructor(options: HotReloadWatcherOptions);
|
|
210
|
+
start(): void;
|
|
211
|
+
stop(): void;
|
|
212
|
+
private _handleFileChange;
|
|
213
|
+
private _runCompile;
|
|
214
|
+
}
|
|
215
|
+
|
|
114
216
|
declare class ResearchAgent extends BaseAgent {
|
|
115
217
|
name: string;
|
|
116
218
|
description: string;
|
|
@@ -395,4 +497,4 @@ declare class AgentMind {
|
|
|
395
497
|
*/
|
|
396
498
|
declare function createSchedulerTools(store: SchedulerStore): ToolProject;
|
|
397
499
|
|
|
398
|
-
export { AgentError, AgentInput, AgentInstance, AgentJsonRpcServer, AgentMind, AgentMindConfig, AgentOutput, AgentRegistry, type AgentRegistryTransportOptions, AgentResult, type AgentTransport, BaseAgent, BaseAgentOptions, BrowserAgent, ChannelInterface, CodingAgent, type ConversationSearchTool, type ConversationSearchToolConfig, DataAgent, IAgentRegistry, JsonRpcTransport, LocalTransport, type RunContext as MindRunContext, PendingAsk, ResearchAgent, SchedulerStore, SummarizerAgent, assemblePrompt, createConversationSearchTool, createSchedulerTools };
|
|
500
|
+
export { AgentError, AgentInput, AgentInstance, AgentJsonRpcServer, AgentMind, AgentMindConfig, AgentOutput, AgentRegistry, type AgentRegistryTransportOptions, AgentResult, type AgentTransport, BaseAgent, BaseAgentOptions, BrowserAgent, ChannelInterface, CodingAgent, type ConversationSearchTool, type ConversationSearchToolConfig, DataAgent, EphemeralAgent, HotReloadWatcher, type HotReloadWatcherOptions, IAgentRegistry, JsonRpcTransport, LocalTransport, type RunContext as MindRunContext, PendingAsk, ResearchAgent, SchedulerStore, type SpawnFn, SummarizerAgent, type WatchFn, assemblePrompt, createConversationSearchTool, createSchedulerTools };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,36 @@
|
|
|
1
|
-
import { A as AgentInput, a as AgentResult,
|
|
2
|
-
export { b as AgentDelegationConfig,
|
|
3
|
-
import { B as BaseAgent, A as AgentMindConfig } from './base-agent-
|
|
4
|
-
export { a as AgentEvents, C as ConfidenceLevel, G as GoalPriority, b as GoalStatus, M as MindBelief, c as MindEntry, d as MindEntryType, e as MindGoal, f as MindRecallResult, g as MindReflection, h as MindTtlDefaults } from './base-agent-
|
|
1
|
+
import { B as BaseAgentOptions, A as AgentInput, a as AgentResult, d as IAgentRegistry, f as AgentOutput, g as AgentInstance, C as ChannelInterface, P as PendingAsk } from './types-C3EZvpe0.js';
|
|
2
|
+
export { b as AgentDelegationConfig, e as AgentRunOptions, c as AgentSpawnConfig, h as AgentSpawnTemplate, I as Interceptor, i as InterceptorChainConfig, j as InterceptorContext, k as InterceptorResult, N as NextFunction, S as SKIP_SENTINEL, W as WorkflowStep, l as isSkipSentinel, s as skip } from './types-C3EZvpe0.js';
|
|
3
|
+
import { B as BaseAgent, A as AgentMindConfig } from './base-agent-C4fYjHPu.js';
|
|
4
|
+
export { a as AgentEvents, C as ConfidenceLevel, G as GoalPriority, b as GoalStatus, M as MindBelief, c as MindEntry, d as MindEntryType, e as MindGoal, f as MindRecallResult, g as MindReflection, h as MindTtlDefaults } from './base-agent-C4fYjHPu.js';
|
|
5
5
|
import { ModeConfig, ConversationStore, AssemblerOptions, AssembledPrompt, RequestToolDefinition, ToolProject } from 'toolpack-sdk';
|
|
6
6
|
export { AssembledPrompt, AssemblerOptions, ConversationScope, ConversationStore, GetOptions, InMemoryConversationStore, InMemoryConversationStoreConfig, Participant, PromptMessage, ConversationSearchOptions as SearchOptions, StoredMessage } from 'toolpack-sdk';
|
|
7
|
-
import { S as SchedulerStore } from './index-
|
|
8
|
-
export { B as BaseChannel, C as CreateJobOptions, a as CreateJobResult, D as DiscordChannel, b as DiscordChannelConfig, E as EmailChannel, c as EmailChannelConfig, J as JobStatus, M as McpChannel, d as McpChannelConfig, e as SMSChannel, f as SMSChannelConfig, g as ScheduledChannel, h as ScheduledChannelConfig, i as ScheduledJob, j as SlackChannel, k as SlackChannelConfig, T as TelegramChannel, l as TelegramChannelConfig, W as WebhookChannel, m as WebhookChannelConfig } from './index-
|
|
9
|
-
export { I as IntentClassification, a as IntentClassifierAgent, b as IntentClassifierInput } from './intent-classifier-agent-
|
|
7
|
+
import { S as SchedulerStore } from './index-C0OlSL3f.js';
|
|
8
|
+
export { B as BaseChannel, C as CreateJobOptions, a as CreateJobResult, D as DiscordChannel, b as DiscordChannelConfig, E as EmailChannel, c as EmailChannelConfig, J as JobStatus, M as McpChannel, d as McpChannelConfig, e as SMSChannel, f as SMSChannelConfig, g as ScheduledChannel, h as ScheduledChannelConfig, i as ScheduledJob, j as SlackChannel, k as SlackChannelConfig, T as TelegramChannel, l as TelegramChannelConfig, W as WebhookChannel, m as WebhookChannelConfig } from './index-C0OlSL3f.js';
|
|
9
|
+
export { I as IntentClassification, a as IntentClassifierAgent, b as IntentClassifierInput } from './intent-classifier-agent-ACQSotfT.js';
|
|
10
10
|
import { SummarizerAgent } from './capabilities/index.js';
|
|
11
11
|
export { HistoryTurn, SummarizerInput, SummarizerOutput } from './capabilities/index.js';
|
|
12
12
|
export { AddressCheckConfig, AddressCheckResult, CaptureHistoryConfig, ComposedChain, DepthExceededError, DepthGuardConfig, EventDedupConfig, IntentClassifierInterceptorConfig, InvocationDepthExceededError, NoiseFilterConfig, OTelSpan, OTelSpanOptions, OTelSpanStatus, OTelSpanStatusCode, OTelTracer, OTelTracerConfig, OTelTracerProvider, ParticipantResolverConfig, RateLimitConfig, SelfFilterConfig, TracerConfig, composeChain, createAddressCheckInterceptor, createCaptureInterceptor, createDepthGuardInterceptor, createEventDedupInterceptor, createIntentClassifierInterceptor, createNoiseFilterInterceptor, createOTelTracerInterceptor, createParticipantResolverInterceptor, createRateLimitInterceptor, createSelfFilterInterceptor, createTracerInterceptor, executeChain } from './interceptors/index.js';
|
|
13
|
-
export { C as ContainsScorer, a as CustomScorer, E as EvalCase, b as EvalCaseResult, c as EvalDataset, d as EvalImprovement, e as EvalRegression, f as EvalReport, g as EvalRun, h as EvalRunner, i as EvalRunnerOptions, j as EvalScoredResult, k as EvalScoredRun, l as EvalScorer, m as EvalVerdict, n as ExactMatchScorer, L as LLMJudgeScorer, o as LLMJudgeScorerOptions, p as compareEvalRuns, q as formatEvalReport } from './eval-report-
|
|
13
|
+
export { C as ContainsScorer, a as CustomScorer, E as EvalCase, b as EvalCaseResult, c as EvalDataset, d as EvalImprovement, e as EvalRegression, f as EvalReport, g as EvalRun, h as EvalRunner, i as EvalRunnerOptions, j as EvalScoredResult, k as EvalScoredRun, l as EvalScorer, m as EvalVerdict, n as ExactMatchScorer, L as LLMJudgeScorer, o as LLMJudgeScorerOptions, p as compareEvalRuns, q as formatEvalReport } from './eval-report-CO98LRUC.js';
|
|
14
14
|
import 'events';
|
|
15
15
|
import '@toolpack-sdk/knowledge';
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Lightweight concrete agent for one-off tasks.
|
|
19
|
+
*
|
|
20
|
+
* Typically instantiated internally by the `spawn_agent` tool. Can also be
|
|
21
|
+
* constructed directly for testing or advanced orchestration. The mode (and
|
|
22
|
+
* its system prompt) is supplied at construction time by the caller.
|
|
23
|
+
*
|
|
24
|
+
* No channels, no interceptors, no registry entry.
|
|
25
|
+
*/
|
|
26
|
+
declare class EphemeralAgent extends BaseAgent {
|
|
27
|
+
name: string;
|
|
28
|
+
description: string;
|
|
29
|
+
mode: ModeConfig | string;
|
|
30
|
+
constructor(name: string, description: string, mode: ModeConfig | string, options: BaseAgentOptions);
|
|
31
|
+
invokeAgent(input: AgentInput): Promise<AgentResult>;
|
|
32
|
+
}
|
|
33
|
+
|
|
17
34
|
/**
|
|
18
35
|
* Transport interface for agent-to-agent communication.
|
|
19
36
|
* Enables pluggable transport mechanisms (local, JSON-RPC, etc.)
|
|
@@ -54,6 +71,10 @@ declare class AgentRegistry implements IAgentRegistry {
|
|
|
54
71
|
_transport: AgentTransport;
|
|
55
72
|
/** In-memory store for pending human-in-the-loop questions. Stored as Map<conversationId, PendingAsk[]> */
|
|
56
73
|
private pendingAsks;
|
|
74
|
+
private _started;
|
|
75
|
+
private _restarting;
|
|
76
|
+
private _restartScheduled;
|
|
77
|
+
private _deadlineTimer?;
|
|
57
78
|
/**
|
|
58
79
|
* @param agents Agent instances to coordinate. Each agent's `channels` and
|
|
59
80
|
* `interceptors` are configured on the agent itself.
|
|
@@ -71,6 +92,30 @@ declare class AgentRegistry implements IAgentRegistry {
|
|
|
71
92
|
* 4. Calls `agent.start()` which binds message handlers and begins listening.
|
|
72
93
|
*/
|
|
73
94
|
start(): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Add an agent to the registry. If the registry is already started the agent
|
|
97
|
+
* is fully wired and started immediately; otherwise it is deferred until start().
|
|
98
|
+
*/
|
|
99
|
+
addAgent(agent: BaseAgent): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Remove an agent by name. Stops the agent and unregisters its channels.
|
|
102
|
+
* No-op when the name is not found.
|
|
103
|
+
*/
|
|
104
|
+
removeAgent(name: string): Promise<void>;
|
|
105
|
+
/** Returns true when all registered agents have no in-progress conversations. */
|
|
106
|
+
isAllIdle(): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Schedule a graceful restart once all agents are idle, or force one after
|
|
109
|
+
* maxWaitMinutes (default 30). Idempotent — subsequent calls are ignored.
|
|
110
|
+
*
|
|
111
|
+
* Uses process.exit(0) so a process manager (PM2, systemd) can restart with
|
|
112
|
+
* the updated dist/ and .env. Override _exit() in tests to prevent that.
|
|
113
|
+
*/
|
|
114
|
+
scheduleRestart(options?: {
|
|
115
|
+
maxWaitMinutes?: number;
|
|
116
|
+
}): void;
|
|
117
|
+
_executeRestart(): Promise<void>;
|
|
118
|
+
protected _exit(code: number): void;
|
|
74
119
|
/**
|
|
75
120
|
* Send output to a named channel.
|
|
76
121
|
*/
|
|
@@ -111,6 +156,63 @@ declare class AgentError extends Error {
|
|
|
111
156
|
constructor(message: string);
|
|
112
157
|
}
|
|
113
158
|
|
|
159
|
+
type WatchFn = (path: string, options: {
|
|
160
|
+
recursive?: boolean;
|
|
161
|
+
}, listener: (event: string, filename: string | null) => void) => {
|
|
162
|
+
close(): void;
|
|
163
|
+
};
|
|
164
|
+
type SpawnFn = (cmd: string, args: string[], options: {
|
|
165
|
+
cwd?: string;
|
|
166
|
+
stdio?: unknown;
|
|
167
|
+
}) => {
|
|
168
|
+
stderr: {
|
|
169
|
+
on(event: string, listener: (data: Buffer) => void): void;
|
|
170
|
+
} | null;
|
|
171
|
+
on(event: string, listener: (arg: unknown) => void): void;
|
|
172
|
+
};
|
|
173
|
+
interface HotReloadWatcherOptions {
|
|
174
|
+
/** Directories or files to watch. */
|
|
175
|
+
watchPaths: string[];
|
|
176
|
+
/** Working directory for tsc --build (defaults to process.cwd()). */
|
|
177
|
+
cwd?: string;
|
|
178
|
+
/**
|
|
179
|
+
* How long to wait after the last file change before compiling (default: 30 000 ms).
|
|
180
|
+
* Set higher when developers routinely edit many files across several minutes.
|
|
181
|
+
* The timer resets on every new change, so compile only fires after a period of silence.
|
|
182
|
+
*/
|
|
183
|
+
debounceMs?: number;
|
|
184
|
+
/** Called after a successful compile or after an .env file change. */
|
|
185
|
+
onRestartNeeded: () => void;
|
|
186
|
+
/** Called when tsc --build exits non-zero. Restart is NOT triggered. */
|
|
187
|
+
onCompileError?: (stderr: string) => void;
|
|
188
|
+
/** Inject a custom spawn function (for testing). */
|
|
189
|
+
spawnFn?: SpawnFn;
|
|
190
|
+
/** Inject a custom watch function (for testing). */
|
|
191
|
+
watchFn?: WatchFn;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Watches source files and .env files for changes. On a TypeScript change it
|
|
195
|
+
* runs tsc --build and, on success, calls onRestartNeeded. On an .env change
|
|
196
|
+
* it calls onRestartNeeded directly. Multiple rapid changes within debounceMs
|
|
197
|
+
* are collapsed into a single compile/notify.
|
|
198
|
+
*/
|
|
199
|
+
declare class HotReloadWatcher {
|
|
200
|
+
private readonly cwd;
|
|
201
|
+
private readonly debounceMs;
|
|
202
|
+
private readonly onRestartNeeded;
|
|
203
|
+
private readonly onCompileError?;
|
|
204
|
+
private readonly spawnFn;
|
|
205
|
+
private readonly watchFn;
|
|
206
|
+
private readonly watchPaths;
|
|
207
|
+
private watchers;
|
|
208
|
+
private debounceTimer?;
|
|
209
|
+
constructor(options: HotReloadWatcherOptions);
|
|
210
|
+
start(): void;
|
|
211
|
+
stop(): void;
|
|
212
|
+
private _handleFileChange;
|
|
213
|
+
private _runCompile;
|
|
214
|
+
}
|
|
215
|
+
|
|
114
216
|
declare class ResearchAgent extends BaseAgent {
|
|
115
217
|
name: string;
|
|
116
218
|
description: string;
|
|
@@ -395,4 +497,4 @@ declare class AgentMind {
|
|
|
395
497
|
*/
|
|
396
498
|
declare function createSchedulerTools(store: SchedulerStore): ToolProject;
|
|
397
499
|
|
|
398
|
-
export { AgentError, AgentInput, AgentInstance, AgentJsonRpcServer, AgentMind, AgentMindConfig, AgentOutput, AgentRegistry, type AgentRegistryTransportOptions, AgentResult, type AgentTransport, BaseAgent, BaseAgentOptions, BrowserAgent, ChannelInterface, CodingAgent, type ConversationSearchTool, type ConversationSearchToolConfig, DataAgent, IAgentRegistry, JsonRpcTransport, LocalTransport, type RunContext as MindRunContext, PendingAsk, ResearchAgent, SchedulerStore, SummarizerAgent, assemblePrompt, createConversationSearchTool, createSchedulerTools };
|
|
500
|
+
export { AgentError, AgentInput, AgentInstance, AgentJsonRpcServer, AgentMind, AgentMindConfig, AgentOutput, AgentRegistry, type AgentRegistryTransportOptions, AgentResult, type AgentTransport, BaseAgent, BaseAgentOptions, BrowserAgent, ChannelInterface, CodingAgent, type ConversationSearchTool, type ConversationSearchToolConfig, DataAgent, EphemeralAgent, HotReloadWatcher, type HotReloadWatcherOptions, IAgentRegistry, JsonRpcTransport, LocalTransport, type RunContext as MindRunContext, PendingAsk, ResearchAgent, SchedulerStore, type SpawnFn, SummarizerAgent, type WatchFn, assemblePrompt, createConversationSearchTool, createSchedulerTools };
|