@toolpack-sdk/agents 2.1.1 → 2.3.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 +72 -4
- package/dist/{base-agent-DPdK4Pnl.d.cts → base-agent-65162dq7.d.cts} +1 -1
- package/dist/{base-agent-nU8pr4nu.d.ts → base-agent-DzspMyaG.d.ts} +1 -1
- package/dist/capabilities/index.cjs +2 -2
- package/dist/capabilities/index.d.cts +3 -3
- package/dist/capabilities/index.d.ts +3 -3
- package/dist/capabilities/index.js +3 -3
- package/dist/channels/index.cjs +2 -2
- package/dist/channels/index.d.cts +2 -2
- package/dist/channels/index.d.ts +2 -2
- package/dist/channels/index.js +2 -2
- package/dist/eval-report-BUD6NRiP.d.cts +343 -0
- package/dist/eval-report-C6dSvR3Y.d.ts +343 -0
- package/dist/{index-Du6S0eG7.d.cts → index-BxUlu-qG.d.ts} +76 -2
- package/dist/{index-o8Lbzv5N.d.ts → index-DrigwC1A.d.cts} +76 -2
- package/dist/index.cjs +40 -26
- package/dist/index.d.cts +9 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.js +40 -26
- package/dist/{intent-classifier-agent-DxyfJWcm.d.cts → intent-classifier-agent-D0rWtviD.d.cts} +2 -2
- package/dist/{intent-classifier-agent-0JZDlhpk.d.ts → intent-classifier-agent-mmNoAozf.d.ts} +2 -2
- package/dist/interceptors/index.cjs +1 -1
- package/dist/interceptors/index.d.cts +92 -5
- package/dist/interceptors/index.d.ts +92 -5
- package/dist/interceptors/index.js +1 -1
- package/dist/testing/index.cjs +16 -2
- package/dist/testing/index.d.cts +3 -2
- package/dist/testing/index.d.ts +3 -2
- package/dist/testing/index.js +16 -2
- package/dist/{types-TB6yypig.d.cts → types-C3eW-auY.d.cts} +6 -8
- package/dist/{types-TB6yypig.d.ts → types-C3eW-auY.d.ts} +6 -8
- package/package.json +18 -9
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import { B as BaseAgent } from './base-agent-DzspMyaG.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Eval primitives — shared types across EvalDataset, EvalRunner, EvalScorer, and EvalReport.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A single eval case: an input fed to the agent and the expected output used
|
|
8
|
+
* for scoring.
|
|
9
|
+
*/
|
|
10
|
+
interface EvalCase {
|
|
11
|
+
/** Unique identifier for this case. */
|
|
12
|
+
id: string;
|
|
13
|
+
/** The input passed to `agent.invokeAgent()`. */
|
|
14
|
+
input: {
|
|
15
|
+
message: string;
|
|
16
|
+
intent?: string;
|
|
17
|
+
conversationId?: string;
|
|
18
|
+
context?: Record<string, unknown>;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The expected output used by scorers.
|
|
22
|
+
* Exact-match and contains scorers compare `actualOutput` against this.
|
|
23
|
+
* LLM-judge scorers use it as the reference answer.
|
|
24
|
+
*/
|
|
25
|
+
expectedOutput: string;
|
|
26
|
+
/** Optional free-form metadata (e.g. tags, difficulty, source). */
|
|
27
|
+
metadata?: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The actual output produced by running a single eval case against an agent.
|
|
31
|
+
*/
|
|
32
|
+
interface EvalCaseResult {
|
|
33
|
+
/** The eval case that was run. */
|
|
34
|
+
evalCase: EvalCase;
|
|
35
|
+
/** The output produced by the agent. */
|
|
36
|
+
actualOutput: string;
|
|
37
|
+
/** Wall-clock duration in milliseconds. */
|
|
38
|
+
durationMs: number;
|
|
39
|
+
/** Error message if the agent threw, otherwise undefined. */
|
|
40
|
+
error?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The result of running an entire dataset through an agent.
|
|
44
|
+
*/
|
|
45
|
+
interface EvalRun {
|
|
46
|
+
/** Identifier for this run (e.g. "v1.2", "pr-456"). */
|
|
47
|
+
runId: string;
|
|
48
|
+
/** ISO timestamp of when the run started. */
|
|
49
|
+
startedAt: string;
|
|
50
|
+
/** ISO timestamp of when the run completed. */
|
|
51
|
+
completedAt: string;
|
|
52
|
+
/** Total wall-clock duration in milliseconds. */
|
|
53
|
+
totalDurationMs: number;
|
|
54
|
+
/** Per-case results, in dataset order. */
|
|
55
|
+
results: EvalCaseResult[];
|
|
56
|
+
}
|
|
57
|
+
/** The verdict for a single scored case. */
|
|
58
|
+
type EvalVerdict = 'pass' | 'fail';
|
|
59
|
+
/**
|
|
60
|
+
* A scored result — wraps an EvalCaseResult with a pass/fail verdict and
|
|
61
|
+
* an optional explanation.
|
|
62
|
+
*/
|
|
63
|
+
interface EvalScoredResult {
|
|
64
|
+
/** The underlying case result. */
|
|
65
|
+
caseResult: EvalCaseResult;
|
|
66
|
+
/** Pass or fail. */
|
|
67
|
+
verdict: EvalVerdict;
|
|
68
|
+
/**
|
|
69
|
+
* Optional human-readable explanation of the verdict.
|
|
70
|
+
* Populated by LLMJudgeScorer; optional for other scorers.
|
|
71
|
+
*/
|
|
72
|
+
explanation?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* A fully scored run — an EvalRun annotated with per-case verdicts and
|
|
76
|
+
* aggregate pass/fail counts.
|
|
77
|
+
*/
|
|
78
|
+
interface EvalScoredRun {
|
|
79
|
+
/** The original run. */
|
|
80
|
+
run: EvalRun;
|
|
81
|
+
/** Scored results, in run order. */
|
|
82
|
+
scoredResults: EvalScoredResult[];
|
|
83
|
+
/** Number of passing cases. */
|
|
84
|
+
passCount: number;
|
|
85
|
+
/** Number of failing cases. */
|
|
86
|
+
failCount: number;
|
|
87
|
+
/** Pass rate as a fraction between 0 and 1. */
|
|
88
|
+
passRate: number;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A regression entry — a case that passed in the baseline but fails in the
|
|
92
|
+
* candidate.
|
|
93
|
+
*/
|
|
94
|
+
interface EvalRegression {
|
|
95
|
+
caseId: string;
|
|
96
|
+
baselineOutput: string;
|
|
97
|
+
candidateOutput: string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* An improvement entry — a case that failed in the baseline but passes in the
|
|
101
|
+
* candidate.
|
|
102
|
+
*/
|
|
103
|
+
interface EvalImprovement {
|
|
104
|
+
caseId: string;
|
|
105
|
+
baselineOutput: string;
|
|
106
|
+
candidateOutput: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Comparison report between a baseline scored run and a candidate scored run.
|
|
110
|
+
*/
|
|
111
|
+
interface EvalReport {
|
|
112
|
+
baselineRunId: string;
|
|
113
|
+
candidateRunId: string;
|
|
114
|
+
baselinePassRate: number;
|
|
115
|
+
candidatePassRate: number;
|
|
116
|
+
/** Δ pass rate (candidate − baseline). Positive = improvement. */
|
|
117
|
+
delta: number;
|
|
118
|
+
regressions: EvalRegression[];
|
|
119
|
+
improvements: EvalImprovement[];
|
|
120
|
+
/** Cases that passed in both runs. */
|
|
121
|
+
stablePasses: string[];
|
|
122
|
+
/** Cases that failed in both runs. */
|
|
123
|
+
stableFails: string[];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* A collection of eval cases that can be loaded from / saved to JSON.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```ts
|
|
131
|
+
* const dataset = new EvalDataset([
|
|
132
|
+
* {
|
|
133
|
+
* id: 'q1',
|
|
134
|
+
* input: { message: 'What is 2 + 2?' },
|
|
135
|
+
* expectedOutput: '4',
|
|
136
|
+
* },
|
|
137
|
+
* ]);
|
|
138
|
+
*
|
|
139
|
+
* dataset.save('./evals/math.json');
|
|
140
|
+
*
|
|
141
|
+
* const loaded = EvalDataset.load('./evals/math.json');
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
declare class EvalDataset {
|
|
145
|
+
private _cases;
|
|
146
|
+
constructor(cases?: EvalCase[]);
|
|
147
|
+
/** All cases in the dataset. */
|
|
148
|
+
get cases(): EvalCase[];
|
|
149
|
+
/** Number of cases. */
|
|
150
|
+
get size(): number;
|
|
151
|
+
/**
|
|
152
|
+
* Get a case by ID.
|
|
153
|
+
* Returns `undefined` if not found.
|
|
154
|
+
*/
|
|
155
|
+
get(id: string): EvalCase | undefined;
|
|
156
|
+
/**
|
|
157
|
+
* Add one or more cases.
|
|
158
|
+
* Throws if a case with the same ID already exists.
|
|
159
|
+
*/
|
|
160
|
+
add(...cases: EvalCase[]): this;
|
|
161
|
+
/**
|
|
162
|
+
* Remove a case by ID.
|
|
163
|
+
* Returns `true` if removed, `false` if not found.
|
|
164
|
+
*/
|
|
165
|
+
remove(id: string): boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Filter cases by a predicate. Returns a new EvalDataset.
|
|
168
|
+
*/
|
|
169
|
+
filter(predicate: (c: EvalCase) => boolean): EvalDataset;
|
|
170
|
+
/**
|
|
171
|
+
* Serialize to a plain array (suitable for `JSON.stringify`).
|
|
172
|
+
*/
|
|
173
|
+
toJSON(): EvalCase[];
|
|
174
|
+
/**
|
|
175
|
+
* Save cases to a JSON file.
|
|
176
|
+
*
|
|
177
|
+
* @param filePath Absolute or relative path to the output file.
|
|
178
|
+
*/
|
|
179
|
+
save(filePath: string): void;
|
|
180
|
+
/**
|
|
181
|
+
* Load cases from a JSON file.
|
|
182
|
+
* The file must contain a JSON array of `EvalCase` objects.
|
|
183
|
+
*
|
|
184
|
+
* @param filePath Absolute or relative path to the JSON file.
|
|
185
|
+
*/
|
|
186
|
+
static load(filePath: string): EvalDataset;
|
|
187
|
+
/**
|
|
188
|
+
* Create an `EvalDataset` from a plain array (e.g. from a database query).
|
|
189
|
+
*/
|
|
190
|
+
static from(cases: EvalCase[]): EvalDataset;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
interface EvalRunnerOptions {
|
|
194
|
+
/**
|
|
195
|
+
* Identifier for this run — use something meaningful like a version or PR number.
|
|
196
|
+
* Defaults to a timestamp string.
|
|
197
|
+
*/
|
|
198
|
+
runId?: string;
|
|
199
|
+
/**
|
|
200
|
+
* Concurrency limit — how many cases to run in parallel.
|
|
201
|
+
* Defaults to 1 (sequential) to avoid overwhelming the provider.
|
|
202
|
+
*/
|
|
203
|
+
concurrency?: number;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Runs an agent against every case in an `EvalDataset` and collects the
|
|
207
|
+
* results into an `EvalRun`.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```ts
|
|
211
|
+
* const runner = new EvalRunner(agent);
|
|
212
|
+
* const run = await runner.run(dataset, { runId: 'v1.2' });
|
|
213
|
+
*
|
|
214
|
+
* console.log(`${run.results.length} cases run in ${run.totalDurationMs}ms`);
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
declare class EvalRunner {
|
|
218
|
+
private agent;
|
|
219
|
+
constructor(agent: BaseAgent);
|
|
220
|
+
/**
|
|
221
|
+
* Run all cases in the dataset and return an `EvalRun`.
|
|
222
|
+
*/
|
|
223
|
+
run(dataset: EvalDataset, options?: EvalRunnerOptions): Promise<EvalRun>;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* A scorer evaluates each `EvalCaseResult` in a run and produces a
|
|
228
|
+
* pass/fail verdict with an optional explanation.
|
|
229
|
+
*
|
|
230
|
+
* Implement this interface to create custom scoring logic.
|
|
231
|
+
*/
|
|
232
|
+
interface EvalScorer {
|
|
233
|
+
score(run: EvalRun): Promise<EvalScoredRun>;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Passes a case when `actualOutput` exactly equals `expectedOutput`.
|
|
237
|
+
* Optionally case-insensitive and/or trimmed.
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```ts
|
|
241
|
+
* const scorer = new ExactMatchScorer({ trim: true, caseInsensitive: true });
|
|
242
|
+
* const scored = await scorer.score(run);
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
declare class ExactMatchScorer implements EvalScorer {
|
|
246
|
+
private trim;
|
|
247
|
+
private caseInsensitive;
|
|
248
|
+
constructor(options?: {
|
|
249
|
+
trim?: boolean;
|
|
250
|
+
caseInsensitive?: boolean;
|
|
251
|
+
});
|
|
252
|
+
score(run: EvalRun): Promise<EvalScoredRun>;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Passes a case when `actualOutput` contains `expectedOutput` as a substring.
|
|
256
|
+
* Optionally case-insensitive.
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* ```ts
|
|
260
|
+
* const scorer = new ContainsScorer({ caseInsensitive: true });
|
|
261
|
+
* const scored = await scorer.score(run);
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
declare class ContainsScorer implements EvalScorer {
|
|
265
|
+
private caseInsensitive;
|
|
266
|
+
constructor(options?: {
|
|
267
|
+
caseInsensitive?: boolean;
|
|
268
|
+
});
|
|
269
|
+
score(run: EvalRun): Promise<EvalScoredRun>;
|
|
270
|
+
}
|
|
271
|
+
interface LLMJudgeScorerOptions {
|
|
272
|
+
/**
|
|
273
|
+
* Custom judge prompt template.
|
|
274
|
+
* Use `{{question}}`, `{{expected}}`, and `{{actual}}` as placeholders.
|
|
275
|
+
* Must instruct the LLM to respond with only "pass" or "fail" on the first line,
|
|
276
|
+
* optionally followed by an explanation.
|
|
277
|
+
*/
|
|
278
|
+
promptTemplate?: string;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Uses an LLM agent as a judge to score each case.
|
|
282
|
+
* The judge is prompted with the question, expected answer, and actual answer.
|
|
283
|
+
*
|
|
284
|
+
* @example
|
|
285
|
+
* ```ts
|
|
286
|
+
* const judgeAgent = new MyAgent({ toolpack });
|
|
287
|
+
* const scorer = new LLMJudgeScorer(judgeAgent);
|
|
288
|
+
* const scored = await scorer.score(run);
|
|
289
|
+
* ```
|
|
290
|
+
*/
|
|
291
|
+
declare class LLMJudgeScorer implements EvalScorer {
|
|
292
|
+
private judgeAgent;
|
|
293
|
+
private promptTemplate;
|
|
294
|
+
constructor(judgeAgent: BaseAgent, options?: LLMJudgeScorerOptions);
|
|
295
|
+
score(run: EvalRun): Promise<EvalScoredRun>;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Wraps a user-supplied scoring function.
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* ```ts
|
|
302
|
+
* const scorer = new CustomScorer(async (result) => {
|
|
303
|
+
* const pass = result.actualOutput.includes('Paris');
|
|
304
|
+
* return { verdict: pass ? 'pass' : 'fail' };
|
|
305
|
+
* });
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
308
|
+
declare class CustomScorer implements EvalScorer {
|
|
309
|
+
private fn;
|
|
310
|
+
constructor(fn: (result: EvalCaseResult) => Promise<{
|
|
311
|
+
verdict: EvalVerdict;
|
|
312
|
+
explanation?: string;
|
|
313
|
+
}>);
|
|
314
|
+
score(run: EvalRun): Promise<EvalScoredRun>;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Compares two scored runs and produces a regression/improvement report.
|
|
319
|
+
*
|
|
320
|
+
* @example
|
|
321
|
+
* ```ts
|
|
322
|
+
* const report = compareEvalRuns(baselineScoredRun, candidateScoredRun);
|
|
323
|
+
*
|
|
324
|
+
* if (report.regressions.length > 0) {
|
|
325
|
+
* console.error('Regressions detected:', report.regressions);
|
|
326
|
+
* process.exit(1);
|
|
327
|
+
* }
|
|
328
|
+
*
|
|
329
|
+
* console.log(`Pass rate: ${report.baselinePassRate} → ${report.candidatePassRate} (Δ${report.delta > 0 ? '+' : ''}${report.delta.toFixed(2)})`);
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
declare function compareEvalRuns(baseline: EvalScoredRun, candidate: EvalScoredRun): EvalReport;
|
|
333
|
+
/**
|
|
334
|
+
* Format an `EvalReport` as a human-readable summary string.
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* ```ts
|
|
338
|
+
* console.log(formatEvalReport(report));
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
341
|
+
declare function formatEvalReport(report: EvalReport): string;
|
|
342
|
+
|
|
343
|
+
export { ContainsScorer as C, type EvalCase as E, LLMJudgeScorer as L, CustomScorer as a, type EvalCaseResult as b, EvalDataset as c, type EvalImprovement as d, type EvalRegression as e, type EvalReport as f, type EvalRun as g, EvalRunner as h, type EvalRunnerOptions as i, type EvalScoredResult as j, type EvalScoredRun as k, type EvalScorer as l, type EvalVerdict as m, ExactMatchScorer as n, type LLMJudgeScorerOptions as o, compareEvalRuns as p, formatEvalReport as q };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AgentInput, e as AgentOutput } from './types-
|
|
1
|
+
import { A as AgentInput, e as AgentOutput } from './types-C3eW-auY.js';
|
|
2
2
|
import { Participant } from 'toolpack-sdk';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -924,4 +924,78 @@ declare class SMSChannel extends BaseChannel {
|
|
|
924
924
|
stop(): Promise<void>;
|
|
925
925
|
}
|
|
926
926
|
|
|
927
|
-
|
|
927
|
+
interface McpChannelConfig {
|
|
928
|
+
/**
|
|
929
|
+
* Maximum milliseconds to wait for the agent to respond.
|
|
930
|
+
* Default: 120_000 (2 minutes).
|
|
931
|
+
*/
|
|
932
|
+
timeout?: number;
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Channel that connects a Toolpack agent to an MCP server as a tool.
|
|
936
|
+
*
|
|
937
|
+
* Unlike other channels (Slack, Webhook) this channel does not own a server or
|
|
938
|
+
* socket. Instead it exposes a `trigger()` method that the MCP tools/call handler
|
|
939
|
+
* calls directly. The agent runs and sends its output back through `send()`, which
|
|
940
|
+
* resolves the Promise that `trigger()` is waiting on.
|
|
941
|
+
*
|
|
942
|
+
* Usage:
|
|
943
|
+
* ```typescript
|
|
944
|
+
* const ch = new McpChannel();
|
|
945
|
+
* const agent = new PrReviewerAgent({ channels: [ch] });
|
|
946
|
+
* await agent.start();
|
|
947
|
+
*
|
|
948
|
+
* await sdk.startMcpServer({
|
|
949
|
+
* transport: 'stdio',
|
|
950
|
+
* agents: [ch.asAgentDefinition(agent)],
|
|
951
|
+
* });
|
|
952
|
+
* ```
|
|
953
|
+
*
|
|
954
|
+
* ⚠ One McpChannel handles one concurrent call at a time. If two tools/call
|
|
955
|
+
* requests arrive for the same channel simultaneously, the second call's
|
|
956
|
+
* pendingResolve overwrites the first and the first call's result is lost.
|
|
957
|
+
* Create one McpChannel per agent instance and do not share channels.
|
|
958
|
+
*/
|
|
959
|
+
declare class McpChannel extends BaseChannel {
|
|
960
|
+
readonly isTriggerChannel = false;
|
|
961
|
+
private readonly _timeout;
|
|
962
|
+
private _pendingResolve?;
|
|
963
|
+
constructor(config?: McpChannelConfig);
|
|
964
|
+
/**
|
|
965
|
+
* No-op — McpChannel is driven by trigger(), not a background listener.
|
|
966
|
+
*/
|
|
967
|
+
listen(): void;
|
|
968
|
+
/**
|
|
969
|
+
* Resolves the pending trigger() Promise with the agent's output.
|
|
970
|
+
*/
|
|
971
|
+
send(output: AgentOutput): Promise<void>;
|
|
972
|
+
/**
|
|
973
|
+
* Convert raw MCP arguments into AgentInput.
|
|
974
|
+
* If args contains a string 'message' field it is used as the message;
|
|
975
|
+
* otherwise the entire args object is JSON-stringified as the message.
|
|
976
|
+
*/
|
|
977
|
+
normalize(incoming: unknown): AgentInput;
|
|
978
|
+
/**
|
|
979
|
+
* Called by the MCP tools/call handler.
|
|
980
|
+
* Triggers the agent and waits for it to respond via send().
|
|
981
|
+
* Rejects if the agent does not respond within the configured timeout.
|
|
982
|
+
*/
|
|
983
|
+
trigger(args: Record<string, unknown>): Promise<string>;
|
|
984
|
+
/**
|
|
985
|
+
* Produce an McpAgentDefinition suitable for startMcpServer({ agents: [...] }).
|
|
986
|
+
*
|
|
987
|
+
* @param agent Object with name and description (typically a BaseAgent instance).
|
|
988
|
+
* @param inputSchema Optional JSON Schema for the tool's input parameters.
|
|
989
|
+
*/
|
|
990
|
+
asAgentDefinition(agent: {
|
|
991
|
+
name: string;
|
|
992
|
+
description: string;
|
|
993
|
+
}, inputSchema?: Record<string, unknown>): {
|
|
994
|
+
invoke: (args: Record<string, unknown>) => Promise<string>;
|
|
995
|
+
inputSchema?: Record<string, unknown> | undefined;
|
|
996
|
+
name: string;
|
|
997
|
+
description: string;
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
export { BaseChannel as B, type CreateJobOptions as C, DiscordChannel as D, EmailChannel as E, type JobStatus as J, McpChannel as M, SchedulerStore as S, TelegramChannel as T, WebhookChannel as W, type CreateJobResult as a, type DiscordChannelConfig as b, type EmailChannelConfig as c, type McpChannelConfig as d, SMSChannel as e, type SMSChannelConfig as f, ScheduledChannel as g, type ScheduledChannelConfig as h, type ScheduledJob as i, SlackChannel as j, type SlackChannelConfig as k, type TelegramChannelConfig as l, type WebhookChannelConfig as m };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AgentInput, e as AgentOutput } from './types-
|
|
1
|
+
import { A as AgentInput, e as AgentOutput } from './types-C3eW-auY.cjs';
|
|
2
2
|
import { Participant } from 'toolpack-sdk';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -924,4 +924,78 @@ declare class SMSChannel extends BaseChannel {
|
|
|
924
924
|
stop(): Promise<void>;
|
|
925
925
|
}
|
|
926
926
|
|
|
927
|
-
|
|
927
|
+
interface McpChannelConfig {
|
|
928
|
+
/**
|
|
929
|
+
* Maximum milliseconds to wait for the agent to respond.
|
|
930
|
+
* Default: 120_000 (2 minutes).
|
|
931
|
+
*/
|
|
932
|
+
timeout?: number;
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Channel that connects a Toolpack agent to an MCP server as a tool.
|
|
936
|
+
*
|
|
937
|
+
* Unlike other channels (Slack, Webhook) this channel does not own a server or
|
|
938
|
+
* socket. Instead it exposes a `trigger()` method that the MCP tools/call handler
|
|
939
|
+
* calls directly. The agent runs and sends its output back through `send()`, which
|
|
940
|
+
* resolves the Promise that `trigger()` is waiting on.
|
|
941
|
+
*
|
|
942
|
+
* Usage:
|
|
943
|
+
* ```typescript
|
|
944
|
+
* const ch = new McpChannel();
|
|
945
|
+
* const agent = new PrReviewerAgent({ channels: [ch] });
|
|
946
|
+
* await agent.start();
|
|
947
|
+
*
|
|
948
|
+
* await sdk.startMcpServer({
|
|
949
|
+
* transport: 'stdio',
|
|
950
|
+
* agents: [ch.asAgentDefinition(agent)],
|
|
951
|
+
* });
|
|
952
|
+
* ```
|
|
953
|
+
*
|
|
954
|
+
* ⚠ One McpChannel handles one concurrent call at a time. If two tools/call
|
|
955
|
+
* requests arrive for the same channel simultaneously, the second call's
|
|
956
|
+
* pendingResolve overwrites the first and the first call's result is lost.
|
|
957
|
+
* Create one McpChannel per agent instance and do not share channels.
|
|
958
|
+
*/
|
|
959
|
+
declare class McpChannel extends BaseChannel {
|
|
960
|
+
readonly isTriggerChannel = false;
|
|
961
|
+
private readonly _timeout;
|
|
962
|
+
private _pendingResolve?;
|
|
963
|
+
constructor(config?: McpChannelConfig);
|
|
964
|
+
/**
|
|
965
|
+
* No-op — McpChannel is driven by trigger(), not a background listener.
|
|
966
|
+
*/
|
|
967
|
+
listen(): void;
|
|
968
|
+
/**
|
|
969
|
+
* Resolves the pending trigger() Promise with the agent's output.
|
|
970
|
+
*/
|
|
971
|
+
send(output: AgentOutput): Promise<void>;
|
|
972
|
+
/**
|
|
973
|
+
* Convert raw MCP arguments into AgentInput.
|
|
974
|
+
* If args contains a string 'message' field it is used as the message;
|
|
975
|
+
* otherwise the entire args object is JSON-stringified as the message.
|
|
976
|
+
*/
|
|
977
|
+
normalize(incoming: unknown): AgentInput;
|
|
978
|
+
/**
|
|
979
|
+
* Called by the MCP tools/call handler.
|
|
980
|
+
* Triggers the agent and waits for it to respond via send().
|
|
981
|
+
* Rejects if the agent does not respond within the configured timeout.
|
|
982
|
+
*/
|
|
983
|
+
trigger(args: Record<string, unknown>): Promise<string>;
|
|
984
|
+
/**
|
|
985
|
+
* Produce an McpAgentDefinition suitable for startMcpServer({ agents: [...] }).
|
|
986
|
+
*
|
|
987
|
+
* @param agent Object with name and description (typically a BaseAgent instance).
|
|
988
|
+
* @param inputSchema Optional JSON Schema for the tool's input parameters.
|
|
989
|
+
*/
|
|
990
|
+
asAgentDefinition(agent: {
|
|
991
|
+
name: string;
|
|
992
|
+
description: string;
|
|
993
|
+
}, inputSchema?: Record<string, unknown>): {
|
|
994
|
+
invoke: (args: Record<string, unknown>) => Promise<string>;
|
|
995
|
+
inputSchema?: Record<string, unknown> | undefined;
|
|
996
|
+
name: string;
|
|
997
|
+
description: string;
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
export { BaseChannel as B, type CreateJobOptions as C, DiscordChannel as D, EmailChannel as E, type JobStatus as J, McpChannel as M, SchedulerStore as S, TelegramChannel as T, WebhookChannel as W, type CreateJobResult as a, type DiscordChannelConfig as b, type EmailChannelConfig as c, type McpChannelConfig as d, SMSChannel as e, type SMSChannelConfig as f, ScheduledChannel as g, type ScheduledChannelConfig as h, type ScheduledJob as i, SlackChannel as j, type SlackChannelConfig as k, type TelegramChannelConfig as l, type WebhookChannelConfig as m };
|