@illuma-ai/agents 1.3.2 → 1.4.0-alpha.1
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/cjs/graphs/Graph.cjs +3 -18
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/llm/openai/index.cjs +3 -0
- package/dist/cjs/llm/openai/index.cjs.map +1 -1
- package/dist/cjs/main.cjs +56 -0
- package/dist/cjs/main.cjs.map +1 -1
- package/dist/cjs/providers/a2a/A2ACapabilityProvider.cjs +288 -0
- package/dist/cjs/providers/a2a/A2ACapabilityProvider.cjs.map +1 -0
- package/dist/cjs/providers/a2a/client.cjs +92 -0
- package/dist/cjs/providers/a2a/client.cjs.map +1 -0
- package/dist/cjs/providers/a2a/config.cjs +38 -0
- package/dist/cjs/providers/a2a/config.cjs.map +1 -0
- package/dist/cjs/providers/capabilityNaming.cjs +43 -0
- package/dist/cjs/providers/capabilityNaming.cjs.map +1 -0
- package/dist/cjs/providers/mcp/MCPCapabilityProvider.cjs +244 -0
- package/dist/cjs/providers/mcp/MCPCapabilityProvider.cjs.map +1 -0
- package/dist/cjs/providers/mcp/config.cjs +42 -0
- package/dist/cjs/providers/mcp/config.cjs.map +1 -0
- package/dist/cjs/providers/mcp/transport.cjs +65 -0
- package/dist/cjs/providers/mcp/transport.cjs.map +1 -0
- package/dist/cjs/providers/tools-server/ToolsServerCapabilityProvider.cjs +121 -0
- package/dist/cjs/providers/tools-server/ToolsServerCapabilityProvider.cjs.map +1 -0
- package/dist/cjs/providers/types.cjs +51 -0
- package/dist/cjs/providers/types.cjs.map +1 -0
- package/dist/cjs/tools/ToolNode.cjs +3 -0
- package/dist/cjs/tools/ToolNode.cjs.map +1 -1
- package/dist/cjs/tools/proxyTool.cjs +100 -0
- package/dist/cjs/tools/proxyTool.cjs.map +1 -0
- package/dist/cjs/utils/credentials.cjs +142 -0
- package/dist/cjs/utils/credentials.cjs.map +1 -0
- package/dist/cjs/utils/httpClient.cjs +74 -0
- package/dist/cjs/utils/httpClient.cjs.map +1 -0
- package/dist/cjs/utils/toolManifest.cjs +100 -0
- package/dist/cjs/utils/toolManifest.cjs.map +1 -0
- package/dist/esm/graphs/Graph.mjs +3 -18
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/llm/openai/index.mjs +3 -0
- package/dist/esm/llm/openai/index.mjs.map +1 -1
- package/dist/esm/main.mjs +13 -0
- package/dist/esm/main.mjs.map +1 -1
- package/dist/esm/providers/a2a/A2ACapabilityProvider.mjs +281 -0
- package/dist/esm/providers/a2a/A2ACapabilityProvider.mjs.map +1 -0
- package/dist/esm/providers/a2a/client.mjs +88 -0
- package/dist/esm/providers/a2a/client.mjs.map +1 -0
- package/dist/esm/providers/a2a/config.mjs +35 -0
- package/dist/esm/providers/a2a/config.mjs.map +1 -0
- package/dist/esm/providers/capabilityNaming.mjs +39 -0
- package/dist/esm/providers/capabilityNaming.mjs.map +1 -0
- package/dist/esm/providers/mcp/MCPCapabilityProvider.mjs +240 -0
- package/dist/esm/providers/mcp/MCPCapabilityProvider.mjs.map +1 -0
- package/dist/esm/providers/mcp/config.mjs +39 -0
- package/dist/esm/providers/mcp/config.mjs.map +1 -0
- package/dist/esm/providers/mcp/transport.mjs +63 -0
- package/dist/esm/providers/mcp/transport.mjs.map +1 -0
- package/dist/esm/providers/tools-server/ToolsServerCapabilityProvider.mjs +119 -0
- package/dist/esm/providers/tools-server/ToolsServerCapabilityProvider.mjs.map +1 -0
- package/dist/esm/providers/types.mjs +51 -0
- package/dist/esm/providers/types.mjs.map +1 -0
- package/dist/esm/tools/ToolNode.mjs +3 -0
- package/dist/esm/tools/ToolNode.mjs.map +1 -1
- package/dist/esm/tools/proxyTool.mjs +98 -0
- package/dist/esm/tools/proxyTool.mjs.map +1 -0
- package/dist/esm/utils/credentials.mjs +135 -0
- package/dist/esm/utils/credentials.mjs.map +1 -0
- package/dist/esm/utils/httpClient.mjs +70 -0
- package/dist/esm/utils/httpClient.mjs.map +1 -0
- package/dist/esm/utils/toolManifest.mjs +96 -0
- package/dist/esm/utils/toolManifest.mjs.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/providers/a2a/A2ACapabilityProvider.d.ts +89 -0
- package/dist/types/providers/a2a/client.d.ts +47 -0
- package/dist/types/providers/a2a/config.d.ts +18 -0
- package/dist/types/providers/a2a/index.d.ts +6 -0
- package/dist/types/providers/a2a/types.d.ts +173 -0
- package/dist/types/providers/capabilityNaming.d.ts +25 -0
- package/dist/types/providers/index.d.ts +12 -0
- package/dist/types/providers/mcp/MCPCapabilityProvider.d.ts +54 -0
- package/dist/types/providers/mcp/config.d.ts +20 -0
- package/dist/types/providers/mcp/index.d.ts +5 -0
- package/dist/types/providers/mcp/transport.d.ts +18 -0
- package/dist/types/providers/mcp/types.d.ts +112 -0
- package/dist/types/providers/tools-server/ToolsServerCapabilityProvider.d.ts +45 -0
- package/dist/types/providers/tools-server/index.d.ts +1 -0
- package/dist/types/providers/types.d.ts +170 -0
- package/dist/types/tools/proxyTool.d.ts +55 -0
- package/dist/types/utils/credentials.d.ts +77 -0
- package/dist/types/utils/httpClient.d.ts +46 -0
- package/dist/types/utils/index.d.ts +3 -0
- package/dist/types/utils/toolManifest.d.ts +49 -0
- package/package.json +16 -1
- package/src/graphs/Graph.ts +0 -23
- package/src/index.ts +4 -0
- package/src/providers/__tests__/ToolsServerCapabilityProvider.integration.spec.ts +79 -0
- package/src/providers/__tests__/ToolsServerCapabilityProvider.test.ts +206 -0
- package/src/providers/__tests__/types.test.ts +64 -0
- package/src/providers/a2a/A2ACapabilityProvider.ts +384 -0
- package/src/providers/a2a/__tests__/A2ACapabilityProvider.integration.spec.ts +345 -0
- package/src/providers/a2a/__tests__/A2ACapabilityProvider.test.ts +460 -0
- package/src/providers/a2a/client.ts +115 -0
- package/src/providers/a2a/config.ts +40 -0
- package/src/providers/a2a/index.ts +29 -0
- package/src/providers/a2a/types.ts +191 -0
- package/src/providers/capabilityNaming.ts +42 -0
- package/src/providers/index.ts +68 -0
- package/src/providers/mcp/MCPCapabilityProvider.ts +345 -0
- package/src/providers/mcp/__tests__/MCPCapabilityProvider.integration.spec.ts +386 -0
- package/src/providers/mcp/__tests__/MCPCapabilityProvider.test.ts +371 -0
- package/src/providers/mcp/config.ts +45 -0
- package/src/providers/mcp/index.ts +21 -0
- package/src/providers/mcp/transport.ts +76 -0
- package/src/providers/mcp/types.ts +139 -0
- package/src/providers/tools-server/ToolsServerCapabilityProvider.ts +220 -0
- package/src/providers/tools-server/index.ts +1 -0
- package/src/providers/types.ts +187 -0
- package/src/tools/proxyTool.ts +146 -0
- package/src/utils/__tests__/credentials.test.ts +130 -0
- package/src/utils/__tests__/httpClient.test.ts +75 -0
- package/src/utils/__tests__/toolManifest.test.ts +116 -0
- package/src/utils/credentials.ts +157 -0
- package/src/utils/httpClient.ts +92 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/toolManifest.ts +109 -0
- package/src/agents/AgentContext.js.map +0 -1
- package/src/agents/AgentContext.test.js.map +0 -1
- package/src/agents/__tests__/AgentContext.test.js.map +0 -1
- package/src/agents/__tests__/resolveStructuredOutputMode.test.js.map +0 -1
- package/src/common/enum.js.map +0 -1
- package/src/common/index.js.map +0 -1
- package/src/events.js.map +0 -1
- package/src/graphs/Graph.js.map +0 -1
- package/src/graphs/MultiAgentGraph.js.map +0 -1
- package/src/graphs/__tests__/structured-output.integration.test.js.map +0 -1
- package/src/graphs/__tests__/structured-output.test.js.map +0 -1
- package/src/graphs/contextManagement.e2e.test.js.map +0 -1
- package/src/graphs/contextManagement.test.js.map +0 -1
- package/src/graphs/handoffValidation.test.js.map +0 -1
- package/src/graphs/index.js.map +0 -1
- package/src/index.js.map +0 -1
- package/src/instrumentation.js.map +0 -1
- package/src/llm/anthropic/index.js.map +0 -1
- package/src/llm/anthropic/types.js.map +0 -1
- package/src/llm/anthropic/utils/message_inputs.js.map +0 -1
- package/src/llm/anthropic/utils/message_outputs.js.map +0 -1
- package/src/llm/anthropic/utils/output_parsers.js.map +0 -1
- package/src/llm/anthropic/utils/tools.js.map +0 -1
- package/src/llm/bedrock/__tests__/bedrock-caching.test.js.map +0 -1
- package/src/llm/bedrock/index.js.map +0 -1
- package/src/llm/bedrock/types.js.map +0 -1
- package/src/llm/bedrock/utils/index.js.map +0 -1
- package/src/llm/bedrock/utils/message_inputs.js.map +0 -1
- package/src/llm/bedrock/utils/message_outputs.js.map +0 -1
- package/src/llm/fake.js.map +0 -1
- package/src/llm/google/index.js.map +0 -1
- package/src/llm/google/types.js.map +0 -1
- package/src/llm/google/utils/common.js.map +0 -1
- package/src/llm/google/utils/tools.js.map +0 -1
- package/src/llm/google/utils/zod_to_genai_parameters.js.map +0 -1
- package/src/llm/openai/index.js.map +0 -1
- package/src/llm/openai/types.js.map +0 -1
- package/src/llm/openai/utils/index.js.map +0 -1
- package/src/llm/openai/utils/isReasoningModel.test.js.map +0 -1
- package/src/llm/openrouter/index.js.map +0 -1
- package/src/llm/openrouter/reasoning.test.js.map +0 -1
- package/src/llm/providers.js.map +0 -1
- package/src/llm/text.js.map +0 -1
- package/src/llm/vertexai/index.js.map +0 -1
- package/src/messages/__tests__/tools.test.js.map +0 -1
- package/src/messages/cache.js.map +0 -1
- package/src/messages/cache.test.js.map +0 -1
- package/src/messages/content.js.map +0 -1
- package/src/messages/content.test.js.map +0 -1
- package/src/messages/core.js.map +0 -1
- package/src/messages/ensureThinkingBlock.test.js.map +0 -1
- package/src/messages/format.js.map +0 -1
- package/src/messages/formatAgentMessages.test.js.map +0 -1
- package/src/messages/formatAgentMessages.tools.test.js.map +0 -1
- package/src/messages/formatMessage.test.js.map +0 -1
- package/src/messages/ids.js.map +0 -1
- package/src/messages/index.js.map +0 -1
- package/src/messages/labelContentByAgent.test.js.map +0 -1
- package/src/messages/prune.js.map +0 -1
- package/src/messages/reducer.js.map +0 -1
- package/src/messages/shiftIndexTokenCountMap.test.js.map +0 -1
- package/src/messages/summarize.js.map +0 -1
- package/src/messages/summarize.test.js.map +0 -1
- package/src/messages/tools.js.map +0 -1
- package/src/mockStream.js.map +0 -1
- package/src/prompts/collab.js.map +0 -1
- package/src/prompts/index.js.map +0 -1
- package/src/prompts/taskmanager.js.map +0 -1
- package/src/run.js.map +0 -1
- package/src/schemas/index.js.map +0 -1
- package/src/schemas/schema-preparation.test.js.map +0 -1
- package/src/schemas/validate.js.map +0 -1
- package/src/schemas/validate.test.js.map +0 -1
- package/src/scripts/abort.js.map +0 -1
- package/src/scripts/ant_web_search.js.map +0 -1
- package/src/scripts/ant_web_search_edge_case.js.map +0 -1
- package/src/scripts/ant_web_search_error_edge_case.js.map +0 -1
- package/src/scripts/args.js.map +0 -1
- package/src/scripts/bedrock-cache-debug.js.map +0 -1
- package/src/scripts/bedrock-content-aggregation-test.js.map +0 -1
- package/src/scripts/bedrock-merge-test.js.map +0 -1
- package/src/scripts/bedrock-parallel-tools-test.js.map +0 -1
- package/src/scripts/caching.js.map +0 -1
- package/src/scripts/cli.js.map +0 -1
- package/src/scripts/cli2.js.map +0 -1
- package/src/scripts/cli3.js.map +0 -1
- package/src/scripts/cli4.js.map +0 -1
- package/src/scripts/cli5.js.map +0 -1
- package/src/scripts/code_exec.js.map +0 -1
- package/src/scripts/code_exec_files.js.map +0 -1
- package/src/scripts/code_exec_multi_session.js.map +0 -1
- package/src/scripts/code_exec_ptc.js.map +0 -1
- package/src/scripts/code_exec_session.js.map +0 -1
- package/src/scripts/code_exec_simple.js.map +0 -1
- package/src/scripts/content.js.map +0 -1
- package/src/scripts/empty_input.js.map +0 -1
- package/src/scripts/handoff-test.js.map +0 -1
- package/src/scripts/image.js.map +0 -1
- package/src/scripts/memory.js.map +0 -1
- package/src/scripts/multi-agent-chain.js.map +0 -1
- package/src/scripts/multi-agent-conditional.js.map +0 -1
- package/src/scripts/multi-agent-document-review-chain.js.map +0 -1
- package/src/scripts/multi-agent-hybrid-flow.js.map +0 -1
- package/src/scripts/multi-agent-parallel-start.js.map +0 -1
- package/src/scripts/multi-agent-parallel.js.map +0 -1
- package/src/scripts/multi-agent-sequence.js.map +0 -1
- package/src/scripts/multi-agent-supervisor.js.map +0 -1
- package/src/scripts/multi-agent-test.js.map +0 -1
- package/src/scripts/parallel-asymmetric-tools-test.js.map +0 -1
- package/src/scripts/parallel-full-metadata-test.js.map +0 -1
- package/src/scripts/parallel-tools-test.js.map +0 -1
- package/src/scripts/programmatic_exec.js.map +0 -1
- package/src/scripts/programmatic_exec_agent.js.map +0 -1
- package/src/scripts/search.js.map +0 -1
- package/src/scripts/sequential-full-metadata-test.js.map +0 -1
- package/src/scripts/simple.js.map +0 -1
- package/src/scripts/single-agent-metadata-test.js.map +0 -1
- package/src/scripts/stream.js.map +0 -1
- package/src/scripts/test-custom-prompt-key.js.map +0 -1
- package/src/scripts/test-handoff-input.js.map +0 -1
- package/src/scripts/test-handoff-preamble.js.map +0 -1
- package/src/scripts/test-handoff-steering.js.map +0 -1
- package/src/scripts/test-multi-agent-list-handoff.js.map +0 -1
- package/src/scripts/test-parallel-agent-labeling.js.map +0 -1
- package/src/scripts/test-parallel-handoffs.js.map +0 -1
- package/src/scripts/test-thinking-handoff-bedrock.js.map +0 -1
- package/src/scripts/test-thinking-handoff.js.map +0 -1
- package/src/scripts/test-thinking-to-thinking-handoff-bedrock.js.map +0 -1
- package/src/scripts/test-tool-before-handoff-role-order.js.map +0 -1
- package/src/scripts/test-tools-before-handoff.js.map +0 -1
- package/src/scripts/test_code_api.js.map +0 -1
- package/src/scripts/thinking-bedrock.js.map +0 -1
- package/src/scripts/thinking-vertexai.js.map +0 -1
- package/src/scripts/thinking.js.map +0 -1
- package/src/scripts/tool_search.js.map +0 -1
- package/src/scripts/tools.js.map +0 -1
- package/src/specs/agent-handoffs-bedrock.integration.test.js.map +0 -1
- package/src/specs/agent-handoffs.test.js.map +0 -1
- package/src/specs/anthropic.simple.test.js.map +0 -1
- package/src/specs/azure.simple.test.js.map +0 -1
- package/src/specs/cache.simple.test.js.map +0 -1
- package/src/specs/custom-event-await.test.js.map +0 -1
- package/src/specs/deepseek.simple.test.js.map +0 -1
- package/src/specs/emergency-prune.test.js.map +0 -1
- package/src/specs/moonshot.simple.test.js.map +0 -1
- package/src/specs/observability.integration.test.js.map +0 -1
- package/src/specs/openai.simple.test.js.map +0 -1
- package/src/specs/openrouter.simple.test.js.map +0 -1
- package/src/specs/prune.test.js.map +0 -1
- package/src/specs/reasoning.test.js.map +0 -1
- package/src/specs/spec.utils.js.map +0 -1
- package/src/specs/thinking-handoff.test.js.map +0 -1
- package/src/specs/thinking-prune.test.js.map +0 -1
- package/src/specs/token-distribution-edge-case.test.js.map +0 -1
- package/src/specs/token-memoization.test.js.map +0 -1
- package/src/specs/tokens.test.js.map +0 -1
- package/src/specs/tool-error.test.js.map +0 -1
- package/src/splitStream.js.map +0 -1
- package/src/splitStream.test.js.map +0 -1
- package/src/stream.js.map +0 -1
- package/src/stream.test.js.map +0 -1
- package/src/test/mockTools.js.map +0 -1
- package/src/tools/BrowserTools.js.map +0 -1
- package/src/tools/Calculator.js.map +0 -1
- package/src/tools/Calculator.test.js.map +0 -1
- package/src/tools/CodeExecutor.js.map +0 -1
- package/src/tools/ProgrammaticToolCalling.js.map +0 -1
- package/src/tools/StreamingToolCallBuffer.js.map +0 -1
- package/src/tools/ToolNode.js.map +0 -1
- package/src/tools/ToolSearch.js.map +0 -1
- package/src/tools/__tests__/BrowserTools.test.js.map +0 -1
- package/src/tools/__tests__/ProgrammaticToolCalling.integration.test.js.map +0 -1
- package/src/tools/__tests__/ProgrammaticToolCalling.test.js.map +0 -1
- package/src/tools/__tests__/StreamingToolCallBuffer.test.js.map +0 -1
- package/src/tools/__tests__/ToolApproval.test.js.map +0 -1
- package/src/tools/__tests__/ToolNode.recovery.test.js.map +0 -1
- package/src/tools/__tests__/ToolNode.session.test.js.map +0 -1
- package/src/tools/__tests__/ToolSearch.integration.test.js.map +0 -1
- package/src/tools/__tests__/ToolSearch.test.js.map +0 -1
- package/src/tools/__tests__/handlers.test.js.map +0 -1
- package/src/tools/__tests__/truncation-recovery.integration.test.js.map +0 -1
- package/src/tools/handlers.js.map +0 -1
- package/src/tools/schema.js.map +0 -1
- package/src/tools/search/anthropic.js.map +0 -1
- package/src/tools/search/content.js.map +0 -1
- package/src/tools/search/content.test.js.map +0 -1
- package/src/tools/search/firecrawl.js.map +0 -1
- package/src/tools/search/format.js.map +0 -1
- package/src/tools/search/highlights.js.map +0 -1
- package/src/tools/search/index.js.map +0 -1
- package/src/tools/search/jina-reranker.test.js.map +0 -1
- package/src/tools/search/rerankers.js.map +0 -1
- package/src/tools/search/schema.js.map +0 -1
- package/src/tools/search/search.js.map +0 -1
- package/src/tools/search/serper-scraper.js.map +0 -1
- package/src/tools/search/test.js.map +0 -1
- package/src/tools/search/tool.js.map +0 -1
- package/src/tools/search/types.js.map +0 -1
- package/src/tools/search/utils.js.map +0 -1
- package/src/types/graph.js.map +0 -1
- package/src/types/graph.test.js.map +0 -1
- package/src/types/index.js.map +0 -1
- package/src/types/llm.js.map +0 -1
- package/src/types/messages.js.map +0 -1
- package/src/types/run.js.map +0 -1
- package/src/types/stream.js.map +0 -1
- package/src/types/tools.js.map +0 -1
- package/src/utils/contextAnalytics.js.map +0 -1
- package/src/utils/contextAnalytics.test.js.map +0 -1
- package/src/utils/events.js.map +0 -1
- package/src/utils/graph.js.map +0 -1
- package/src/utils/handlers.js.map +0 -1
- package/src/utils/index.js.map +0 -1
- package/src/utils/llm.js.map +0 -1
- package/src/utils/llmConfig.js.map +0 -1
- package/src/utils/logging.js.map +0 -1
- package/src/utils/misc.js.map +0 -1
- package/src/utils/run.js.map +0 -1
- package/src/utils/schema.js.map +0 -1
- package/src/utils/title.js.map +0 -1
- package/src/utils/tokens.js.map +0 -1
- package/src/utils/toonFormat.js.map +0 -1
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the A2A capability provider.
|
|
3
|
+
*
|
|
4
|
+
* A2A (Agent-to-Agent) is a public HTTP + JSON-RPC 2.0 protocol for
|
|
5
|
+
* invoking one agent from another. When an agent has been served over
|
|
6
|
+
* A2A (e.g., via `ranger agents serve` or any compliant runtime), a
|
|
7
|
+
* caller agent can use `A2ACapabilityProvider` to:
|
|
8
|
+
* - discover the remote agent's skills via `GET /.well-known/agent.json`
|
|
9
|
+
* - invoke it by POSTing JSON-RPC `tasks/send` to its base URL
|
|
10
|
+
*
|
|
11
|
+
* The types here mirror the public A2A protocol shape at the subset
|
|
12
|
+
* needed for client-side integration.
|
|
13
|
+
*/
|
|
14
|
+
/** Capabilities advertised on the remote agent's agent card. */
|
|
15
|
+
export interface A2ACardCapabilities {
|
|
16
|
+
/** True when the agent supports SSE streaming via `tasks/sendSubscribe`. */
|
|
17
|
+
streaming: boolean;
|
|
18
|
+
pushNotifications?: boolean;
|
|
19
|
+
stateTransitionHistory?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** A single skill exposed by a remote agent on its agent card. */
|
|
22
|
+
export interface A2ASkill {
|
|
23
|
+
/** Stable skill identifier. */
|
|
24
|
+
id: string;
|
|
25
|
+
/** Human-readable name. */
|
|
26
|
+
name: string;
|
|
27
|
+
/** Description of what the skill does. */
|
|
28
|
+
description: string;
|
|
29
|
+
/** Optional tags (e.g., "search", "analysis"). */
|
|
30
|
+
tags?: string[];
|
|
31
|
+
/** Optional example inputs. */
|
|
32
|
+
examples?: string[];
|
|
33
|
+
}
|
|
34
|
+
/** Shape served at `GET /.well-known/agent.json`. */
|
|
35
|
+
export interface A2AAgentCard {
|
|
36
|
+
name: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
/** Base URL clients should POST task requests to. */
|
|
39
|
+
url: string;
|
|
40
|
+
/** Card version — independent of the underlying model/agent version. */
|
|
41
|
+
version: string;
|
|
42
|
+
capabilities: A2ACardCapabilities;
|
|
43
|
+
defaultInputModes?: string[];
|
|
44
|
+
defaultOutputModes?: string[];
|
|
45
|
+
skills: A2ASkill[];
|
|
46
|
+
provider?: {
|
|
47
|
+
organization: string;
|
|
48
|
+
url?: string;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** Spec describing one remote A2A-served agent the provider should connect to. */
|
|
52
|
+
export interface A2ARemoteSpec {
|
|
53
|
+
/**
|
|
54
|
+
* Base URL of the remote A2A endpoint. The provider will fetch the
|
|
55
|
+
* card from `<url>/.well-known/agent.json` and POST task requests to
|
|
56
|
+
* `<url>/` (JSON-RPC root).
|
|
57
|
+
*/
|
|
58
|
+
url: string;
|
|
59
|
+
/**
|
|
60
|
+
* Optional static headers to include on every request. Auth headers
|
|
61
|
+
* should be provided via the `getAuthHeaders` callback instead, so
|
|
62
|
+
* token refresh doesn't require rebuilding the provider.
|
|
63
|
+
*/
|
|
64
|
+
headers?: Record<string, string>;
|
|
65
|
+
/**
|
|
66
|
+
* When true, expose the remote agent as a single coarse-grained
|
|
67
|
+
* Capability (one per remote, named after the agent). When false
|
|
68
|
+
* (default), expose one Capability per skill advertised on the card.
|
|
69
|
+
*/
|
|
70
|
+
flattenAsSingleTool?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Optional override of the agent card URL. Defaults to
|
|
73
|
+
* `<url>/.well-known/agent.json`.
|
|
74
|
+
*/
|
|
75
|
+
cardPath?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Optional override of the JSON-RPC endpoint path. Defaults to `/`.
|
|
78
|
+
*/
|
|
79
|
+
rpcPath?: string;
|
|
80
|
+
}
|
|
81
|
+
/** Configuration for the A2A capability provider. */
|
|
82
|
+
export interface A2AProviderConfig {
|
|
83
|
+
/**
|
|
84
|
+
* Map of remoteName → spec. Remote names are stable identifiers used
|
|
85
|
+
* as the capability name prefix and as keys for `getAuthHeaders`.
|
|
86
|
+
*/
|
|
87
|
+
remotes: Record<string, A2ARemoteSpec>;
|
|
88
|
+
/**
|
|
89
|
+
* Optional callback to resolve auth headers for a given remote at
|
|
90
|
+
* connect-time. Returns a header map merged over `spec.headers`.
|
|
91
|
+
*
|
|
92
|
+
* The library never stores tokens — the host owns auth lifecycle and
|
|
93
|
+
* provides resolved values here.
|
|
94
|
+
*/
|
|
95
|
+
getAuthHeaders?: (remoteName: string) => Promise<Record<string, string> | undefined> | Record<string, string> | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Identity announced to remotes on every request via `user-agent` /
|
|
98
|
+
* provider headers. Defaults to env vars (`A2A_CLIENT_NAME` /
|
|
99
|
+
* `A2A_CLIENT_VERSION`) or a library fallback.
|
|
100
|
+
*/
|
|
101
|
+
clientInfo?: {
|
|
102
|
+
name: string;
|
|
103
|
+
version: string;
|
|
104
|
+
};
|
|
105
|
+
/** HTTP request timeout in ms. Defaults to 30_000. */
|
|
106
|
+
timeoutMs?: number;
|
|
107
|
+
/** Optional logger. Defaults to a console-based one. */
|
|
108
|
+
logger?: A2ALogger;
|
|
109
|
+
}
|
|
110
|
+
/** Minimal logger interface — matches pino-style signatures. */
|
|
111
|
+
export interface A2ALogger {
|
|
112
|
+
debug: (...args: unknown[]) => void;
|
|
113
|
+
info: (...args: unknown[]) => void;
|
|
114
|
+
warn: (...args: unknown[]) => void;
|
|
115
|
+
error: (...args: unknown[]) => void;
|
|
116
|
+
}
|
|
117
|
+
export interface JsonRpcRequest<P = unknown> {
|
|
118
|
+
jsonrpc: '2.0';
|
|
119
|
+
id: string | number | null;
|
|
120
|
+
method: string;
|
|
121
|
+
params?: P;
|
|
122
|
+
}
|
|
123
|
+
export interface JsonRpcSuccess<R = unknown> {
|
|
124
|
+
jsonrpc: '2.0';
|
|
125
|
+
id: string | number | null;
|
|
126
|
+
result: R;
|
|
127
|
+
}
|
|
128
|
+
export interface JsonRpcErrorResponse {
|
|
129
|
+
jsonrpc: '2.0';
|
|
130
|
+
id: string | number | null;
|
|
131
|
+
error: {
|
|
132
|
+
code: number;
|
|
133
|
+
message: string;
|
|
134
|
+
data?: unknown;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
export type JsonRpcResponse<R = unknown> = JsonRpcSuccess<R> | JsonRpcErrorResponse;
|
|
138
|
+
export interface A2AMessage {
|
|
139
|
+
role: 'user' | 'agent';
|
|
140
|
+
parts: Array<{
|
|
141
|
+
type: 'text';
|
|
142
|
+
text: string;
|
|
143
|
+
}>;
|
|
144
|
+
}
|
|
145
|
+
export interface A2ATaskParams {
|
|
146
|
+
/** Caller-assigned task id — echoed back by the server. */
|
|
147
|
+
id: string;
|
|
148
|
+
/** Optional session id for multi-turn continuity. */
|
|
149
|
+
sessionId?: string;
|
|
150
|
+
/** The message to deliver to the remote agent. */
|
|
151
|
+
message: A2AMessage;
|
|
152
|
+
}
|
|
153
|
+
export type A2ATaskState = 'submitted' | 'working' | 'input-required' | 'completed' | 'failed' | 'canceled';
|
|
154
|
+
export interface A2ATaskStatus {
|
|
155
|
+
state: A2ATaskState;
|
|
156
|
+
timestamp: string;
|
|
157
|
+
}
|
|
158
|
+
export interface A2ATask {
|
|
159
|
+
id: string;
|
|
160
|
+
sessionId?: string;
|
|
161
|
+
status: A2ATaskStatus;
|
|
162
|
+
/** Final agent response — populated when status is `completed`. */
|
|
163
|
+
artifacts?: Array<{
|
|
164
|
+
parts: Array<{
|
|
165
|
+
type: 'text';
|
|
166
|
+
text: string;
|
|
167
|
+
}>;
|
|
168
|
+
}>;
|
|
169
|
+
error?: {
|
|
170
|
+
code: number;
|
|
171
|
+
message: string;
|
|
172
|
+
};
|
|
173
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared capability-name encoding used by source-specific providers
|
|
3
|
+
* (MCP, A2A, and future providers that expose multi-level namespaces).
|
|
4
|
+
*
|
|
5
|
+
* A capability name encodes `<sourceName>__<itemName>` where:
|
|
6
|
+
* - `sourceName` is the provider-level identifier (MCP server name,
|
|
7
|
+
* A2A remote name, etc.)
|
|
8
|
+
* - `itemName` is the per-source sub-unit (MCP tool name, A2A skill id)
|
|
9
|
+
*
|
|
10
|
+
* Centralizing the separator + parsing here keeps both providers in lockstep
|
|
11
|
+
* and prevents collisions when re-exported from the provider barrel.
|
|
12
|
+
*/
|
|
13
|
+
/** Separator between source and item in an encoded capability name. */
|
|
14
|
+
export declare const CAPABILITY_NAME_SEPARATOR = "__";
|
|
15
|
+
/** Compose a capability name. If `itemName` is omitted, returns just `sourceName`. */
|
|
16
|
+
export declare function formatCapabilityName(sourceName: string, itemName?: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Parse a capability name into its components. Returns `null` when `name`
|
|
19
|
+
* is empty. When the name has no separator, `itemName` is undefined
|
|
20
|
+
* (the caller can treat that as a whole-source invocation).
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseCapabilityName(name: string): {
|
|
23
|
+
sourceName: string;
|
|
24
|
+
itemName?: string;
|
|
25
|
+
} | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capability provider abstraction.
|
|
3
|
+
*
|
|
4
|
+
* See docs/architecture-capability-layer.md for the full design rationale.
|
|
5
|
+
*/
|
|
6
|
+
export * from './types';
|
|
7
|
+
export * from './capabilityNaming';
|
|
8
|
+
export * from './tools-server';
|
|
9
|
+
export { MCPCapabilityProvider, flattenToolCallResponse, createTransport, mcpConsoleLogger, getMCPEnvDefaults, } from './mcp';
|
|
10
|
+
export type { MCPLogger, MCPProviderConfig, MCPServerSpec, MCPTransportKind, StdioSpec, SSESpec, StreamableHTTPSpec, WebSocketSpec, MCPToolDescriptor, MCPToolCallResult, MCPStructuredTool, } from './mcp';
|
|
11
|
+
export { A2ACapabilityProvider, A2AClient, extractTaskText, generateRpcId, skillToCapability, coerceInputToA2AMessage, MESSAGE_INPUT_SCHEMA, a2aConsoleLogger, getA2AEnvDefaults, } from './a2a';
|
|
12
|
+
export type { A2AAgentCard, A2ACardCapabilities, A2AClientOptions, A2ALogger, A2AMessage, A2AProviderConfig, A2ARemoteSpec, A2ASkill, A2ATask, A2ATaskParams, A2ATaskState, A2ATaskStatus, JsonRpcRequest, JsonRpcResponse, JsonRpcSuccess, JsonRpcErrorResponse, } from './a2a';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCPCapabilityProvider — connects to MCP servers via the official MCP SDK
|
|
3
|
+
* and exposes their tools as `Capability` / `StructuredToolInterface`.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors the pattern of `ToolsServerCapabilityProvider`: thin adapter,
|
|
6
|
+
* protocol-specific transport, stateless as far as tokens/OAuth are
|
|
7
|
+
* concerned (all auth is host-resolved and forwarded via `getAuthHeaders`).
|
|
8
|
+
*
|
|
9
|
+
* What the host supplies:
|
|
10
|
+
* - `servers`: unified spec map (normalized from whatever source:
|
|
11
|
+
* programmatic, YAML, DB, marketplace catalog).
|
|
12
|
+
* - `getAuthHeaders?`: per-server header resolver. Called at connect
|
|
13
|
+
* time. OAuth orchestration / token refresh happens in the host.
|
|
14
|
+
*
|
|
15
|
+
* What the library does:
|
|
16
|
+
* - Picks the right SDK transport per spec.
|
|
17
|
+
* - Connects, calls `listTools()`, wraps each tool as a `Capability`.
|
|
18
|
+
* - `createRunnables()` returns `StructuredTool`s that invoke the
|
|
19
|
+
* server's tools on demand, streaming the string result back to the
|
|
20
|
+
* agent.
|
|
21
|
+
* - Caches open connections per-instance so repeated `fetchManifest` /
|
|
22
|
+
* `createRunnables` calls reuse them.
|
|
23
|
+
*/
|
|
24
|
+
import { type StructuredToolInterface } from '@langchain/core/tools';
|
|
25
|
+
import { type Capability, type CapabilityFilter, type CapabilityProvider, type CredentialMap } from '@/providers/types';
|
|
26
|
+
import { CAPABILITY_NAME_SEPARATOR, formatCapabilityName } from '@/providers/capabilityNaming';
|
|
27
|
+
import type { MCPProviderConfig, MCPToolCallResult } from './types';
|
|
28
|
+
export declare class MCPCapabilityProvider implements CapabilityProvider {
|
|
29
|
+
readonly providerId: string;
|
|
30
|
+
private readonly config;
|
|
31
|
+
private readonly logger;
|
|
32
|
+
private readonly connections;
|
|
33
|
+
constructor(config: MCPProviderConfig);
|
|
34
|
+
fetchManifest(filter?: CapabilityFilter): Promise<Capability[]>;
|
|
35
|
+
createRunnables(capabilities: Capability[], _credentials: CredentialMap): Promise<StructuredToolInterface[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Disconnect all open MCP client connections. Callers should invoke this
|
|
38
|
+
* on shutdown to release transports and child processes (for stdio).
|
|
39
|
+
*/
|
|
40
|
+
close(): Promise<void>;
|
|
41
|
+
private ensureConnection;
|
|
42
|
+
private resolveAuthHeaders;
|
|
43
|
+
private toolToCapability;
|
|
44
|
+
private capabilityMatchesFilter;
|
|
45
|
+
private buildProxyTool;
|
|
46
|
+
}
|
|
47
|
+
export { CAPABILITY_NAME_SEPARATOR, formatCapabilityName };
|
|
48
|
+
/**
|
|
49
|
+
* Flatten the MCP SDK's callTool response into a plain text + error flag.
|
|
50
|
+
* Concatenates any `text`-type content parts; non-text parts are
|
|
51
|
+
* JSON-stringified so the LLM sees something rather than silently
|
|
52
|
+
* dropping output.
|
|
53
|
+
*/
|
|
54
|
+
export declare function flattenToolCallResponse(response: unknown): MCPToolCallResult;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment-driven configuration defaults for the MCP capability provider.
|
|
3
|
+
*
|
|
4
|
+
* Hosts can override any of these via the provider config object. Env vars
|
|
5
|
+
* exist so deployments can brand or tune the library without code changes.
|
|
6
|
+
*/
|
|
7
|
+
import type { MCPLogger } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* Read env values with fallbacks. Kept as a function (not a constant) so
|
|
10
|
+
* tests and hosts that mutate process.env after import get the current
|
|
11
|
+
* value on each call.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getMCPEnvDefaults(): {
|
|
14
|
+
clientName: string;
|
|
15
|
+
clientVersion: string;
|
|
16
|
+
connectTimeoutMs: number;
|
|
17
|
+
requestTimeoutMs: number;
|
|
18
|
+
};
|
|
19
|
+
/** Console-routed default logger. */
|
|
20
|
+
export declare const consoleLogger: MCPLogger;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { MCPCapabilityProvider } from './MCPCapabilityProvider';
|
|
2
|
+
export { CAPABILITY_NAME_SEPARATOR, formatCapabilityName, flattenToolCallResponse, } from './MCPCapabilityProvider';
|
|
3
|
+
export { createTransport } from './transport';
|
|
4
|
+
export { consoleLogger as mcpConsoleLogger, getMCPEnvDefaults } from './config';
|
|
5
|
+
export type { MCPLogger, MCPProviderConfig, MCPServerSpec, MCPTransportKind, StdioSpec, SSESpec, StreamableHTTPSpec, WebSocketSpec, MCPToolDescriptor, MCPToolCallResult, MCPStructuredTool, } from './types';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport factory — turns an `MCPServerSpec` into a configured
|
|
3
|
+
* MCP SDK transport. One switch statement per kind.
|
|
4
|
+
*
|
|
5
|
+
* Each transport is constructed with the merged header map (spec headers
|
|
6
|
+
* plus any `getAuthHeaders`-resolved additions) for HTTP-based kinds.
|
|
7
|
+
* Stdio uses `env` + `command` + `args` directly.
|
|
8
|
+
*/
|
|
9
|
+
import type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
|
|
10
|
+
import type { MCPServerSpec } from './types';
|
|
11
|
+
/**
|
|
12
|
+
* Build a Transport from a spec + resolved auth headers.
|
|
13
|
+
*
|
|
14
|
+
* @param spec - the server spec (one of stdio / sse / streamable-http / websocket)
|
|
15
|
+
* @param authHeaders - headers merged over `spec.headers` at connect time
|
|
16
|
+
* @returns a configured Transport ready to be passed to `Client.connect()`
|
|
17
|
+
*/
|
|
18
|
+
export declare function createTransport(spec: MCPServerSpec, authHeaders?: Record<string, string>): Transport;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the MCP capability provider.
|
|
3
|
+
*
|
|
4
|
+
* Design notes:
|
|
5
|
+
* - `MCPServerSpec` is a unified, minimal shape describing an MCP server
|
|
6
|
+
* the library can connect to. All config sources (programmatic,
|
|
7
|
+
* YAML-derived, marketplace-derived) normalize to this before reaching
|
|
8
|
+
* the provider.
|
|
9
|
+
* - Auth headers are provided per-request via `getAuthHeaders` on the
|
|
10
|
+
* provider config. The library never orchestrates OAuth — the host
|
|
11
|
+
* resolves tokens however it sees fit and forwards the headers map.
|
|
12
|
+
*/
|
|
13
|
+
import type { StructuredToolInterface } from '@langchain/core/tools';
|
|
14
|
+
/** Transport kinds supported by the MCP SDK. */
|
|
15
|
+
export type MCPTransportKind = 'stdio' | 'sse' | 'streamable-http' | 'websocket';
|
|
16
|
+
/** Stdio-transport spec — spawn a local subprocess. */
|
|
17
|
+
export interface StdioSpec {
|
|
18
|
+
type: 'stdio';
|
|
19
|
+
command: string;
|
|
20
|
+
args?: string[];
|
|
21
|
+
env?: Record<string, string>;
|
|
22
|
+
/** Working directory for the spawned process. */
|
|
23
|
+
cwd?: string;
|
|
24
|
+
}
|
|
25
|
+
/** SSE-transport spec (legacy EventSource-based transport). */
|
|
26
|
+
export interface SSESpec {
|
|
27
|
+
type: 'sse';
|
|
28
|
+
url: string;
|
|
29
|
+
/** Static headers (e.g., API key). Forwarded on each HTTP request. */
|
|
30
|
+
headers?: Record<string, string>;
|
|
31
|
+
}
|
|
32
|
+
/** Streamable HTTP spec (the modern MCP HTTP transport). */
|
|
33
|
+
export interface StreamableHTTPSpec {
|
|
34
|
+
type: 'streamable-http';
|
|
35
|
+
url: string;
|
|
36
|
+
headers?: Record<string, string>;
|
|
37
|
+
}
|
|
38
|
+
/** WebSocket transport spec. */
|
|
39
|
+
export interface WebSocketSpec {
|
|
40
|
+
type: 'websocket';
|
|
41
|
+
url: string;
|
|
42
|
+
headers?: Record<string, string>;
|
|
43
|
+
}
|
|
44
|
+
/** Discriminated union of all supported transports. */
|
|
45
|
+
export type MCPServerSpec = StdioSpec | SSESpec | StreamableHTTPSpec | WebSocketSpec;
|
|
46
|
+
/** Configuration for the MCP capability provider. */
|
|
47
|
+
export interface MCPProviderConfig {
|
|
48
|
+
/**
|
|
49
|
+
* Map of serverName → spec. Server names are stable identifiers used
|
|
50
|
+
* downstream as the capability name prefix and as keys for
|
|
51
|
+
* `getAuthHeaders` lookups.
|
|
52
|
+
*
|
|
53
|
+
* The host is responsible for normalizing configs from multiple sources
|
|
54
|
+
* (local database, YAML, marketplace catalog) into this unified shape.
|
|
55
|
+
*/
|
|
56
|
+
servers: Record<string, MCPServerSpec>;
|
|
57
|
+
/**
|
|
58
|
+
* Optional callback to resolve auth headers for a given server at
|
|
59
|
+
* connect-time. Returns a header map (e.g., `{ Authorization: "Bearer ..." }`)
|
|
60
|
+
* that is merged into the spec's base headers.
|
|
61
|
+
*
|
|
62
|
+
* The library never stores tokens or orchestrates OAuth — the host
|
|
63
|
+
* owns that layer and surfaces the resolved value here.
|
|
64
|
+
*/
|
|
65
|
+
getAuthHeaders?: (serverName: string) => Promise<Record<string, string> | undefined> | Record<string, string> | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Client identity sent to MCP servers on handshake. Defaults to
|
|
68
|
+
* env vars (`MCP_CLIENT_NAME` / `MCP_CLIENT_VERSION`) or a library
|
|
69
|
+
* fallback if not set. Hosts typically override with their app identity.
|
|
70
|
+
*/
|
|
71
|
+
clientInfo?: {
|
|
72
|
+
name: string;
|
|
73
|
+
version: string;
|
|
74
|
+
};
|
|
75
|
+
/** Connection timeout in ms. Defaults to 30_000. */
|
|
76
|
+
connectTimeoutMs?: number;
|
|
77
|
+
/** Tool-list / tool-call timeout in ms. Defaults to 30_000. */
|
|
78
|
+
requestTimeoutMs?: number;
|
|
79
|
+
/**
|
|
80
|
+
* Optional logger. When omitted, falls back to a console-based default.
|
|
81
|
+
* Implementations are expected to match the `MCPLogger` minimal shape.
|
|
82
|
+
*/
|
|
83
|
+
logger?: MCPLogger;
|
|
84
|
+
}
|
|
85
|
+
/** Minimal logger interface — matches pino-style signatures. */
|
|
86
|
+
export interface MCPLogger {
|
|
87
|
+
debug: (...args: unknown[]) => void;
|
|
88
|
+
info: (...args: unknown[]) => void;
|
|
89
|
+
warn: (...args: unknown[]) => void;
|
|
90
|
+
error: (...args: unknown[]) => void;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Shape returned by the MCP SDK's `listTools()`. Keeping our own narrow
|
|
94
|
+
* alias so we don't leak the full SDK types through the provider's public
|
|
95
|
+
* surface.
|
|
96
|
+
*/
|
|
97
|
+
export interface MCPToolDescriptor {
|
|
98
|
+
name: string;
|
|
99
|
+
description?: string;
|
|
100
|
+
inputSchema?: unknown;
|
|
101
|
+
}
|
|
102
|
+
/** Result of a tool invocation, flattened from the SDK response. */
|
|
103
|
+
export interface MCPToolCallResult {
|
|
104
|
+
/** Plain-text content joined from the MCP response's content array. */
|
|
105
|
+
text: string;
|
|
106
|
+
/** Raw content array from the SDK response, for advanced consumers. */
|
|
107
|
+
rawContent: unknown;
|
|
108
|
+
/** True when the MCP server flagged the result as an error. */
|
|
109
|
+
isError: boolean;
|
|
110
|
+
}
|
|
111
|
+
/** What the provider returns from createRunnables (re-exported for clarity). */
|
|
112
|
+
export type MCPStructuredTool = StructuredToolInterface;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ToolsServerCapabilityProvider — capabilities sourced from a tools-server
|
|
3
|
+
* HTTP endpoint.
|
|
4
|
+
*
|
|
5
|
+
* Fetches the manifest via GET /manifest, builds proxy StructuredTools via
|
|
6
|
+
* POST /execute/:tool. Manifest is cached (TTL-configurable) so repeated
|
|
7
|
+
* init cycles don't refetch.
|
|
8
|
+
*
|
|
9
|
+
* See docs/architecture-capability-layer.md for the design rationale.
|
|
10
|
+
*/
|
|
11
|
+
import type { AxiosInstance } from 'axios';
|
|
12
|
+
import type { StructuredToolInterface } from '@langchain/core/tools';
|
|
13
|
+
import { type Capability, type CapabilityFilter, type CapabilityProvider, type CredentialMap } from '@/providers/types';
|
|
14
|
+
/** Configuration for ToolsServerCapabilityProvider. */
|
|
15
|
+
export interface ToolsServerConfig {
|
|
16
|
+
/** Tools-server base URL (e.g., https://tools.illuma.ai or http://localhost:3500). */
|
|
17
|
+
baseUrl: string;
|
|
18
|
+
/** API key sent as x-api-key header on all requests. Required. */
|
|
19
|
+
apiKey: string;
|
|
20
|
+
/** Optional override for manifest path. Defaults to `/manifest`. */
|
|
21
|
+
manifestPath?: string;
|
|
22
|
+
/** Optional override for execute path template. Defaults to `/execute/:name`. */
|
|
23
|
+
executePath?: string;
|
|
24
|
+
/** Request timeout in ms. Defaults to 30_000. */
|
|
25
|
+
timeoutMs?: number;
|
|
26
|
+
/** Manifest cache TTL in ms. 0 disables. Defaults to 60_000 (1 min). */
|
|
27
|
+
manifestTtlMs?: number;
|
|
28
|
+
/** Optional pre-built axios instance (for testing). */
|
|
29
|
+
client?: AxiosInstance;
|
|
30
|
+
/** Optional proxy override (defaults to process.env.PROXY). */
|
|
31
|
+
proxy?: string | null;
|
|
32
|
+
}
|
|
33
|
+
export declare class ToolsServerCapabilityProvider implements CapabilityProvider {
|
|
34
|
+
private readonly config;
|
|
35
|
+
readonly providerId: string;
|
|
36
|
+
private readonly client;
|
|
37
|
+
private readonly manifestPath;
|
|
38
|
+
private readonly executePath;
|
|
39
|
+
private readonly cache;
|
|
40
|
+
constructor(config: ToolsServerConfig);
|
|
41
|
+
fetchManifest(filter?: CapabilityFilter): Promise<Capability[]>;
|
|
42
|
+
createRunnables(capabilities: Capability[], credentials: CredentialMap): Promise<StructuredToolInterface[]>;
|
|
43
|
+
/** Force a manifest refresh on next fetchManifest call. */
|
|
44
|
+
invalidateCache(): void;
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ToolsServerCapabilityProvider';
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CapabilityProvider types — the abstraction that lets agents consume tools,
|
|
3
|
+
* skills, and MCP-backed capabilities through a single interface regardless
|
|
4
|
+
* of where they come from.
|
|
5
|
+
*
|
|
6
|
+
* Design principles:
|
|
7
|
+
* 1. Source-agnostic — providers are distinguished by WHERE they come from
|
|
8
|
+
* (tools-server, skill store, MCP server), not by the backend service
|
|
9
|
+
* any individual tool calls.
|
|
10
|
+
* 2. Credential-agnostic — providers receive a flat credentialMap from the
|
|
11
|
+
* host; they don't know about user settings, databases, OAuth flows.
|
|
12
|
+
* 3. Extension-ready — the shape reserves slots for upcoming patterns
|
|
13
|
+
* (skills injectedMessages, ToolCall.auth/expires_at, skill sessions)
|
|
14
|
+
* so when those land we don't refactor the core.
|
|
15
|
+
*/
|
|
16
|
+
import type { StructuredToolInterface } from '@langchain/core/tools';
|
|
17
|
+
/**
|
|
18
|
+
* Kind of capability. Today only TOOL is implemented; SKILL and MCP are
|
|
19
|
+
* reserved — SkillCapabilityProvider + MCPCapabilityProvider will populate
|
|
20
|
+
* them in later phases. Keeping the enum from day one prevents a breaking
|
|
21
|
+
* change when those ship.
|
|
22
|
+
*/
|
|
23
|
+
export declare enum CapabilityKind {
|
|
24
|
+
TOOL = "tool",
|
|
25
|
+
SKILL = "skill",
|
|
26
|
+
MCP = "mcp",
|
|
27
|
+
/**
|
|
28
|
+
* Remote agent reachable over the A2A (Agent-to-Agent) protocol.
|
|
29
|
+
* The library's `A2ACapabilityProvider` is a client for this kind —
|
|
30
|
+
* invoking an A2A capability sends a JSON-RPC `tasks/send` to the
|
|
31
|
+
* remote agent's endpoint.
|
|
32
|
+
*/
|
|
33
|
+
A2A = "a2a"
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Where an auth credential comes from. Used by hosts to decide whether to
|
|
37
|
+
* forward the credential per-request or let the capability provider resolve
|
|
38
|
+
* it from its own environment.
|
|
39
|
+
*/
|
|
40
|
+
export declare enum AuthSource {
|
|
41
|
+
/** Resolved by the capability provider itself from its environment. Host never sends. */
|
|
42
|
+
SERVER = "server",
|
|
43
|
+
/** User-configured value stored in the host's credential store. Host forwards per-request. */
|
|
44
|
+
USER = "user",
|
|
45
|
+
/** Active OAuth/session token. Host forwards per-request from active session. */
|
|
46
|
+
FORWARDED = "forwarded"
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* One entry in a capability's auth config. Describes a single credential
|
|
50
|
+
* the capability needs. The `source` field tells the host how to resolve
|
|
51
|
+
* the value; the `prod`/`admin`/`hide` flags control UI visibility.
|
|
52
|
+
*/
|
|
53
|
+
export interface AuthConfigEntry {
|
|
54
|
+
/** Environment-variable-style name (e.g., "OPENAI_API_KEY"). Stable identifier. */
|
|
55
|
+
authField: string;
|
|
56
|
+
/** Human-readable label for UI. */
|
|
57
|
+
label?: string;
|
|
58
|
+
/** Optional description of how to obtain the credential. */
|
|
59
|
+
description?: string;
|
|
60
|
+
/** Where the value comes from. Defaults to USER if unspecified. */
|
|
61
|
+
source?: AuthSource;
|
|
62
|
+
/** True if the credential is required for the capability to function. */
|
|
63
|
+
required?: boolean;
|
|
64
|
+
/** Platform-managed in production — never prompt user. */
|
|
65
|
+
prod?: boolean;
|
|
66
|
+
/** Only admins can configure. */
|
|
67
|
+
admin?: boolean;
|
|
68
|
+
/** Never show in any UI (used when source === SERVER). */
|
|
69
|
+
hide?: boolean;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Arbitrary metadata attached to a capability. Extension point.
|
|
73
|
+
*
|
|
74
|
+
* Fields prefixed with "Reserved for" are not populated today but exist in
|
|
75
|
+
* the type so upstream patterns (skills, auth expiration, sessions) can
|
|
76
|
+
* drop in without a schema migration.
|
|
77
|
+
*/
|
|
78
|
+
export interface CapabilityMetadata {
|
|
79
|
+
/** Icon URL or path relative to the provider's static asset root. */
|
|
80
|
+
icon?: string;
|
|
81
|
+
/** Category for UI grouping (e.g., "search", "image", "finance"). */
|
|
82
|
+
category?: string;
|
|
83
|
+
/** Free-form tags for filtering / search. */
|
|
84
|
+
tags?: string[];
|
|
85
|
+
/** Reserved for upstream `fix/auth-events` — auth mode declared by tool. */
|
|
86
|
+
auth?: string;
|
|
87
|
+
/** Reserved for upstream `fix/auth-events` — Unix timestamp for token expiration. */
|
|
88
|
+
expires_at?: number;
|
|
89
|
+
/** Reserved for upstream skills — capability returns injected messages on execute. */
|
|
90
|
+
injectedMessages?: boolean;
|
|
91
|
+
/** Reserved for upstream skills — capability consumes ToolSessionMap state. */
|
|
92
|
+
sessionAware?: boolean;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* A single capability — a tool, skill, or MCP-backed operation that an agent
|
|
96
|
+
* can invoke. The shape mirrors common plugin-manifest conventions so the
|
|
97
|
+
* same entry can round-trip between an upstream catalog and a host registry.
|
|
98
|
+
*/
|
|
99
|
+
export interface Capability {
|
|
100
|
+
/** What kind of capability this is. Controls how it's invoked downstream. */
|
|
101
|
+
kind: CapabilityKind;
|
|
102
|
+
/**
|
|
103
|
+
* Stable unique identifier. For tools this is the pluginKey
|
|
104
|
+
* (e.g., "dalle", "wikipedia"). For skills this is the skill's `name`.
|
|
105
|
+
* Used everywhere the capability is referenced.
|
|
106
|
+
*/
|
|
107
|
+
name: string;
|
|
108
|
+
/** Human-readable description for the LLM and UI. */
|
|
109
|
+
description: string;
|
|
110
|
+
/**
|
|
111
|
+
* Input schema as JSON Schema. For tools this comes from the Zod schema
|
|
112
|
+
* passed through `zodToJsonSchema`. Optional for capabilities with no
|
|
113
|
+
* input (e.g., parameter-less skills).
|
|
114
|
+
*/
|
|
115
|
+
schema?: unknown;
|
|
116
|
+
/** Credential requirements. */
|
|
117
|
+
authConfig: AuthConfigEntry[];
|
|
118
|
+
/** Extension metadata. See CapabilityMetadata. */
|
|
119
|
+
metadata: CapabilityMetadata;
|
|
120
|
+
}
|
|
121
|
+
/** Filter for fetchManifest. All fields optional; missing = no filter. */
|
|
122
|
+
export interface CapabilityFilter {
|
|
123
|
+
kind?: CapabilityKind;
|
|
124
|
+
tags?: string[];
|
|
125
|
+
/** Restrict to capabilities whose `name` is in this list. */
|
|
126
|
+
names?: string[];
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* A flat credential map: authField → value.
|
|
130
|
+
*
|
|
131
|
+
* The host is responsible for resolving values (from env vars, user
|
|
132
|
+
* settings, OAuth sessions, etc.) before passing to the provider. The
|
|
133
|
+
* provider does not inspect the origin — it just forwards to the tool.
|
|
134
|
+
*/
|
|
135
|
+
export type CredentialMap = Record<string, string>;
|
|
136
|
+
/**
|
|
137
|
+
* The core interface. All concrete providers implement this.
|
|
138
|
+
*
|
|
139
|
+
* Providers are identified by `providerId` for logging/debug. They fetch
|
|
140
|
+
* their own manifest and build LangChain-compatible runnables from it.
|
|
141
|
+
*
|
|
142
|
+
* Lifetime: a provider may be instantiated once at startup (e.g., tools-
|
|
143
|
+
* server pointing at a stable URL) or per-user (e.g., MCP with per-user
|
|
144
|
+
* OAuth). The interface is agnostic.
|
|
145
|
+
*/
|
|
146
|
+
export interface CapabilityProvider {
|
|
147
|
+
/** Stable identifier for this provider instance (e.g., "tools-server:https://..."). */
|
|
148
|
+
readonly providerId: string;
|
|
149
|
+
/**
|
|
150
|
+
* Return the list of capabilities this provider exposes.
|
|
151
|
+
*
|
|
152
|
+
* Implementations may cache the manifest — the contract is that the
|
|
153
|
+
* returned list reflects the provider's current view of available
|
|
154
|
+
* capabilities.
|
|
155
|
+
*
|
|
156
|
+
* @param filter optional filter to scope the result
|
|
157
|
+
*/
|
|
158
|
+
fetchManifest(filter?: CapabilityFilter): Promise<Capability[]>;
|
|
159
|
+
/**
|
|
160
|
+
* Build LangChain StructuredTools from a set of capabilities using the
|
|
161
|
+
* caller-supplied credentials.
|
|
162
|
+
*
|
|
163
|
+
* Called at agent init. The returned tools are bound to the LLM and
|
|
164
|
+
* invoked during the graph's tool-calling loop.
|
|
165
|
+
*
|
|
166
|
+
* @param capabilities the subset of capabilities the agent wants to use
|
|
167
|
+
* @param credentials credential values keyed by authField
|
|
168
|
+
*/
|
|
169
|
+
createRunnables(capabilities: Capability[], credentials: CredentialMap): Promise<StructuredToolInterface[]>;
|
|
170
|
+
}
|