@toolpack-sdk/agents 2.1.0 → 2.2.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.
@@ -924,4 +924,78 @@ declare class SMSChannel extends BaseChannel {
924
924
  stop(): Promise<void>;
925
925
  }
926
926
 
927
- export { BaseChannel as B, type CreateJobOptions as C, DiscordChannel as D, EmailChannel as E, type JobStatus as J, SchedulerStore as S, TelegramChannel as T, WebhookChannel as W, type CreateJobResult as a, type DiscordChannelConfig as b, type EmailChannelConfig as c, SMSChannel as d, type SMSChannelConfig as e, ScheduledChannel as f, type ScheduledChannelConfig as g, type ScheduledJob as h, SlackChannel as i, type SlackChannelConfig as j, type TelegramChannelConfig as k, type WebhookChannelConfig as l };
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 };
@@ -924,4 +924,78 @@ declare class SMSChannel extends BaseChannel {
924
924
  stop(): Promise<void>;
925
925
  }
926
926
 
927
- export { BaseChannel as B, type CreateJobOptions as C, DiscordChannel as D, EmailChannel as E, type JobStatus as J, SchedulerStore as S, TelegramChannel as T, WebhookChannel as W, type CreateJobResult as a, type DiscordChannelConfig as b, type EmailChannelConfig as c, SMSChannel as d, type SMSChannelConfig as e, ScheduledChannel as f, type ScheduledChannelConfig as g, type ScheduledJob as h, SlackChannel as i, type SlackChannelConfig as j, type TelegramChannelConfig as k, type WebhookChannelConfig as l };
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 };