@stdiobus/workers-registry 1.3.7
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/LICENSE +201 -0
- package/README.md +932 -0
- package/out/dist/workers/acp-registry/registry-launcher-client.js +52 -0
- package/out/dist/workers/acp-registry/registry-launcher-client.js.map +7 -0
- package/out/dist/workers/acp-registry/registry-launcher-config.json +31 -0
- package/out/dist/workers/acp-worker/index.js +5 -0
- package/out/dist/workers/acp-worker/index.js.map +7 -0
- package/out/dist/workers/echo-worker/echo-worker-config.json +21 -0
- package/out/dist/workers/echo-worker/echo-worker.js +3 -0
- package/out/dist/workers/echo-worker/echo-worker.js.map +7 -0
- package/out/dist/workers/index.d.ts +15 -0
- package/out/dist/workers/index.js +33 -0
- package/out/dist/workers/mcp-echo-server/index.js +3 -0
- package/out/dist/workers/mcp-echo-server/index.js.map +7 -0
- package/out/dist/workers/mcp-echo-server/mcp-echo-server-config.json +21 -0
- package/out/dist/workers/mcp-to-acp-proxy/proxy.js +3 -0
- package/out/dist/workers/mcp-to-acp-proxy/proxy.js.map +7 -0
- package/out/tsc/workers/acp-worker/src/acp/client-capabilities.d.ts +131 -0
- package/out/tsc/workers/acp-worker/src/acp/content-mapper.d.ts +95 -0
- package/out/tsc/workers/acp-worker/src/acp/index.d.ts +13 -0
- package/out/tsc/workers/acp-worker/src/acp/tools.d.ts +119 -0
- package/out/tsc/workers/acp-worker/src/agent.d.ts +113 -0
- package/out/tsc/workers/acp-worker/src/index.d.ts +1 -0
- package/out/tsc/workers/acp-worker/src/mcp/connection.d.ts +54 -0
- package/out/tsc/workers/acp-worker/src/mcp/index.d.ts +10 -0
- package/out/tsc/workers/acp-worker/src/mcp/manager.d.ts +178 -0
- package/out/tsc/workers/acp-worker/src/mcp/types.d.ts +114 -0
- package/out/tsc/workers/acp-worker/src/mcp-proxy/connection.d.ts +80 -0
- package/out/tsc/workers/acp-worker/src/mcp-proxy/converter.d.ts +156 -0
- package/out/tsc/workers/acp-worker/src/mcp-proxy/index.d.ts +2 -0
- package/out/tsc/workers/acp-worker/src/mcp-proxy/state.d.ts +165 -0
- package/out/tsc/workers/acp-worker/src/mcp-proxy/types.d.ts +163 -0
- package/out/tsc/workers/acp-worker/src/registry-launcher/config/api-keys.d.ts +41 -0
- package/out/tsc/workers/acp-worker/src/registry-launcher/config/config.d.ts +17 -0
- package/out/tsc/workers/acp-worker/src/registry-launcher/config/index.d.ts +10 -0
- package/out/tsc/workers/acp-worker/src/registry-launcher/config/types.d.ts +15 -0
- package/out/tsc/workers/acp-worker/src/registry-launcher/index.d.ts +2 -0
- package/out/tsc/workers/acp-worker/src/registry-launcher/log.d.ts +77 -0
- package/out/tsc/workers/acp-worker/src/registry-launcher/registry/index.d.ts +109 -0
- package/out/tsc/workers/acp-worker/src/registry-launcher/registry/resolver.d.ts +67 -0
- package/out/tsc/workers/acp-worker/src/registry-launcher/registry/types.d.ts +105 -0
- package/out/tsc/workers/acp-worker/src/registry-launcher/router/index.d.ts +8 -0
- package/out/tsc/workers/acp-worker/src/registry-launcher/router/message-router.d.ts +150 -0
- package/out/tsc/workers/acp-worker/src/registry-launcher/runtime/agent-runtime.d.ts +58 -0
- package/out/tsc/workers/acp-worker/src/registry-launcher/runtime/index.d.ts +11 -0
- package/out/tsc/workers/acp-worker/src/registry-launcher/runtime/manager.d.ts +82 -0
- package/out/tsc/workers/acp-worker/src/registry-launcher/runtime/types.d.ts +20 -0
- package/out/tsc/workers/acp-worker/src/registry-launcher/stream/index.d.ts +8 -0
- package/out/tsc/workers/acp-worker/src/registry-launcher/stream/ndjson-handler.d.ts +119 -0
- package/out/tsc/workers/acp-worker/src/registry-launcher/test-utils/index.d.ts +234 -0
- package/out/tsc/workers/acp-worker/src/session/index.d.ts +12 -0
- package/out/tsc/workers/acp-worker/src/session/manager.d.ts +63 -0
- package/out/tsc/workers/acp-worker/src/session/session.d.ts +86 -0
- package/out/tsc/workers/acp-worker/src/session/types.d.ts +33 -0
- package/out/tsc/workers/acp-worker/src/test-utils/test-harness.d.ts +80 -0
- package/out/tsc/workers/mcp-echo-server/mcp-echo-server.d.ts +2 -0
- package/package.json +77 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for the MCP-ACP protocol proxy.
|
|
3
|
+
*
|
|
4
|
+
* This module defines TypeScript interfaces for all state objects and message types
|
|
5
|
+
* used by the proxy to convert between Model Context Protocol (MCP) and Agent Client
|
|
6
|
+
* Protocol (ACP).
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Configuration loaded from environment variables.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const config: ProxyConfig = {
|
|
14
|
+
* acpHost: process.env.ACP_HOST || '127.0.0.1',
|
|
15
|
+
* acpPort: parseInt(process.env.ACP_PORT || '9011', 10),
|
|
16
|
+
* agentId: process.env.AGENT_ID!
|
|
17
|
+
* };
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export interface ProxyConfig {
|
|
21
|
+
/** ACP_HOST environment variable (default: 127.0.0.1) */
|
|
22
|
+
acpHost: string;
|
|
23
|
+
/** ACP_PORT environment variable (default: 9011) */
|
|
24
|
+
acpPort: number;
|
|
25
|
+
/** AGENT_ID environment variable (required) */
|
|
26
|
+
agentId: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Pending request tracking information.
|
|
30
|
+
*
|
|
31
|
+
* Tracks requests that have been sent but not yet received a response.
|
|
32
|
+
* Used for correlating responses with their original requests and handling
|
|
33
|
+
* queued requests (e.g., session/new followed by session/prompt).
|
|
34
|
+
*/
|
|
35
|
+
export interface PendingRequest {
|
|
36
|
+
/** Original MCP or ACP method name */
|
|
37
|
+
method: string;
|
|
38
|
+
/** Original request parameters */
|
|
39
|
+
params?: unknown;
|
|
40
|
+
/** For queued requests: original request ID (session/new -> session/prompt) */
|
|
41
|
+
originalId?: string | number;
|
|
42
|
+
/** For queued prompts: the prompt text to send after session creation */
|
|
43
|
+
promptText?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Session state maintained by the proxy.
|
|
47
|
+
*
|
|
48
|
+
* Manages session identifiers, pending requests, and accumulated text for
|
|
49
|
+
* streaming responses.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const state: SessionState = {
|
|
54
|
+
* proxySessionId: 'proxy-1234567890',
|
|
55
|
+
* acpSessionId: 'session-abc123',
|
|
56
|
+
* pendingRequests: new Map(),
|
|
57
|
+
* accumulatedText: new Map()
|
|
58
|
+
* };
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export interface SessionState {
|
|
62
|
+
/** Session ID for stdio Bus routing (generated by proxy) */
|
|
63
|
+
proxySessionId: string | null;
|
|
64
|
+
/** Session ID from ACP agent (received from session/new response) */
|
|
65
|
+
acpSessionId: string | null;
|
|
66
|
+
/** Map of request ID to pending request information */
|
|
67
|
+
pendingRequests: Map<string | number, PendingRequest>;
|
|
68
|
+
/** Map of request ID to accumulated streaming text */
|
|
69
|
+
accumulatedText: Map<string | number, string>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* MCP JSON-RPC request message.
|
|
73
|
+
*
|
|
74
|
+
* Represents a request from an MCP client (like Kiro IDE) to the proxy.
|
|
75
|
+
* Uses JSON-RPC 2.0 format.
|
|
76
|
+
*/
|
|
77
|
+
export type MCPRequest = {
|
|
78
|
+
/** JSON-RPC version (always '2.0') */
|
|
79
|
+
jsonrpc: '2.0';
|
|
80
|
+
/** Request identifier (string or number) */
|
|
81
|
+
id: string | number;
|
|
82
|
+
/** MCP method name (e.g., 'initialize', 'tools/list', 'tools/call') */
|
|
83
|
+
method: string;
|
|
84
|
+
/** Method-specific parameters */
|
|
85
|
+
params?: unknown;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* MCP JSON-RPC response message.
|
|
89
|
+
*
|
|
90
|
+
* Represents a response from the proxy to an MCP client.
|
|
91
|
+
* Contains either a result or an error, never both.
|
|
92
|
+
*/
|
|
93
|
+
export type MCPResponse = {
|
|
94
|
+
/** JSON-RPC version (always '2.0') */
|
|
95
|
+
jsonrpc: '2.0';
|
|
96
|
+
/** Request identifier matching the original request */
|
|
97
|
+
id: string | number;
|
|
98
|
+
/** Success result (present if no error) */
|
|
99
|
+
result?: unknown;
|
|
100
|
+
/** Error information (present if request failed) */
|
|
101
|
+
error?: {
|
|
102
|
+
/** JSON-RPC error code */
|
|
103
|
+
code: number;
|
|
104
|
+
/** Human-readable error message */
|
|
105
|
+
message: string;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* ACP JSON-RPC request message.
|
|
110
|
+
*
|
|
111
|
+
* Represents a request from the proxy to an ACP agent via stdio Bus.
|
|
112
|
+
* Extends JSON-RPC 2.0 with ACP-specific fields.
|
|
113
|
+
*/
|
|
114
|
+
export type ACPRequest = {
|
|
115
|
+
/** JSON-RPC version (always '2.0') */
|
|
116
|
+
jsonrpc: '2.0';
|
|
117
|
+
/** Request identifier (string or number) */
|
|
118
|
+
id: string | number;
|
|
119
|
+
/** ACP method name (e.g., 'initialize', 'session/new', 'session/prompt') */
|
|
120
|
+
method: string;
|
|
121
|
+
/** Target agent identifier */
|
|
122
|
+
agentId: string;
|
|
123
|
+
/** Session identifier for stdio Bus routing */
|
|
124
|
+
sessionId: string;
|
|
125
|
+
/** Method-specific parameters */
|
|
126
|
+
params?: unknown;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* ACP JSON-RPC response message.
|
|
130
|
+
*
|
|
131
|
+
* Represents a response from an ACP agent to the proxy.
|
|
132
|
+
* Contains either a result or an error, never both.
|
|
133
|
+
*/
|
|
134
|
+
export type ACPResponse = {
|
|
135
|
+
/** JSON-RPC version (always '2.0') */
|
|
136
|
+
jsonrpc: '2.0';
|
|
137
|
+
/** Request identifier matching the original request */
|
|
138
|
+
id: string | number;
|
|
139
|
+
/** Success result (present if no error) */
|
|
140
|
+
result?: unknown;
|
|
141
|
+
/** Error information (present if request failed) */
|
|
142
|
+
error?: {
|
|
143
|
+
/** JSON-RPC error code */
|
|
144
|
+
code: number;
|
|
145
|
+
/** Human-readable error message */
|
|
146
|
+
message: string;
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* ACP JSON-RPC notification message.
|
|
151
|
+
*
|
|
152
|
+
* Represents a notification from an ACP agent to the proxy.
|
|
153
|
+
* Notifications do not have an id field and do not expect a response.
|
|
154
|
+
* Used for streaming updates like agent_message_chunk.
|
|
155
|
+
*/
|
|
156
|
+
export type ACPNotification = {
|
|
157
|
+
/** JSON-RPC version (always '2.0') */
|
|
158
|
+
jsonrpc: '2.0';
|
|
159
|
+
/** Notification method name (e.g., 'session/update') */
|
|
160
|
+
method: string;
|
|
161
|
+
/** Notification-specific parameters */
|
|
162
|
+
params?: unknown;
|
|
163
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API keys structure for a single agent.
|
|
3
|
+
*/
|
|
4
|
+
export interface AgentApiKeys {
|
|
5
|
+
/** API key for the agent */
|
|
6
|
+
apiKey: string;
|
|
7
|
+
/** Environment variables to pass to the agent */
|
|
8
|
+
env: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* API keys file structure.
|
|
12
|
+
*/
|
|
13
|
+
export interface ApiKeysFile {
|
|
14
|
+
/** Map of agent ID to API keys */
|
|
15
|
+
agents: Record<string, AgentApiKeys>;
|
|
16
|
+
/** Version of the API keys file format */
|
|
17
|
+
version: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Load API keys from a JSON file.
|
|
21
|
+
*
|
|
22
|
+
* @param apiKeysPath - Path to the API keys JSON file
|
|
23
|
+
* @returns Loaded API keys or empty object if file is missing/malformed
|
|
24
|
+
*/
|
|
25
|
+
export declare function loadApiKeys(apiKeysPath: string): Record<string, AgentApiKeys>;
|
|
26
|
+
/**
|
|
27
|
+
* Get API key for a specific agent.
|
|
28
|
+
*
|
|
29
|
+
* @param apiKeys - Loaded API keys
|
|
30
|
+
* @param agentId - Agent ID to get key for
|
|
31
|
+
* @returns API key or undefined if not found
|
|
32
|
+
*/
|
|
33
|
+
export declare function getAgentApiKey(apiKeys: Record<string, AgentApiKeys>, agentId: string): string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Get environment variables for a specific agent.
|
|
36
|
+
*
|
|
37
|
+
* @param apiKeys - Loaded API keys
|
|
38
|
+
* @param agentId - Agent ID to get env vars for
|
|
39
|
+
* @returns Environment variables or empty object if not found
|
|
40
|
+
*/
|
|
41
|
+
export declare function getAgentEnv(apiKeys: Record<string, AgentApiKeys>, agentId: string): Record<string, string>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LauncherConfig } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Load configuration from a JSON file.
|
|
4
|
+
*
|
|
5
|
+
* This function:
|
|
6
|
+
* 1. Reads the config file from the specified path
|
|
7
|
+
* 2. Parses it as JSON
|
|
8
|
+
* 3. Validates and applies default values for missing fields
|
|
9
|
+
* 4. Applies environment variable overrides
|
|
10
|
+
*
|
|
11
|
+
* If the config file is missing or malformed, default values are used
|
|
12
|
+
* and a warning is logged to stderr.
|
|
13
|
+
*
|
|
14
|
+
* @param configPath - Path to the JSON config file (optional)
|
|
15
|
+
* @returns Loaded and validated configuration
|
|
16
|
+
*/
|
|
17
|
+
export declare function loadConfig(configPath?: string): LauncherConfig;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config module barrel export.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the public API for configuration loading.
|
|
5
|
+
*
|
|
6
|
+
* @module config
|
|
7
|
+
*/
|
|
8
|
+
export { loadConfig } from './config.js';
|
|
9
|
+
export { DEFAULT_CONFIG, type LauncherConfig } from './types.js';
|
|
10
|
+
export { loadApiKeys, getAgentApiKey, getAgentEnv, type AgentApiKeys, type ApiKeysFile } from './api-keys.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for the Registry Launcher.
|
|
3
|
+
*/
|
|
4
|
+
export interface LauncherConfig {
|
|
5
|
+
/** Registry URL (default: official ACP Registry) */
|
|
6
|
+
registryUrl: string;
|
|
7
|
+
/** Path to API keys JSON file (default: ./api-keys.json) */
|
|
8
|
+
apiKeysPath: string;
|
|
9
|
+
/** Agent shutdown timeout in seconds (default: 5) */
|
|
10
|
+
shutdownTimeoutSec: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Default configuration values.
|
|
14
|
+
*/
|
|
15
|
+
export declare const DEFAULT_CONFIG: LauncherConfig;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logging utilities for the Registry Launcher.
|
|
3
|
+
*
|
|
4
|
+
* Provides structured logging to stderr with ISO 8601 timestamps and severity levels.
|
|
5
|
+
* All logs go to stderr only - stdout is reserved for NDJSON protocol messages.
|
|
6
|
+
*
|
|
7
|
+
* @module log
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Log severity levels.
|
|
11
|
+
*/
|
|
12
|
+
export type LogLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
|
|
13
|
+
/**
|
|
14
|
+
* Log a message to stderr with ISO 8601 timestamp and severity level.
|
|
15
|
+
*
|
|
16
|
+
* @param level - Severity level (DEBUG, INFO, WARN, ERROR)
|
|
17
|
+
* @param message - Log message
|
|
18
|
+
* @param context - Optional context identifier (defaults to 'registry-launcher')
|
|
19
|
+
*/
|
|
20
|
+
export declare function log(level: LogLevel, message: string, context?: string): void;
|
|
21
|
+
/**
|
|
22
|
+
* Log an agent spawn event.
|
|
23
|
+
*
|
|
24
|
+
* @param agentId - The agent identifier
|
|
25
|
+
* @param command - The spawn command
|
|
26
|
+
* @param args - The spawn command arguments
|
|
27
|
+
*/
|
|
28
|
+
export declare function logSpawn(agentId: string, command: string, args: string[]): void;
|
|
29
|
+
/**
|
|
30
|
+
* Log an agent exit event.
|
|
31
|
+
*
|
|
32
|
+
* @param agentId - The agent identifier
|
|
33
|
+
* @param exitCode - The exit code (null if terminated by signal)
|
|
34
|
+
* @param signal - The signal that terminated the process (null if exited normally)
|
|
35
|
+
*/
|
|
36
|
+
export declare function logExit(agentId: string, exitCode: number | null, signal?: string | null): void;
|
|
37
|
+
/**
|
|
38
|
+
* Log a backpressure warning when writing to an agent process fails.
|
|
39
|
+
*
|
|
40
|
+
* @param agentId - The agent identifier
|
|
41
|
+
*/
|
|
42
|
+
export declare function logBackpressure(agentId: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* Log an error when an agent's stdin closes unexpectedly.
|
|
45
|
+
*
|
|
46
|
+
* @param agentId - The agent identifier
|
|
47
|
+
* @param error - The error that occurred
|
|
48
|
+
*/
|
|
49
|
+
export declare function logStdinClosed(agentId: string, error?: Error): void;
|
|
50
|
+
/**
|
|
51
|
+
* Convenience function for logging debug messages.
|
|
52
|
+
*
|
|
53
|
+
* @param message - Debug message
|
|
54
|
+
* @param context - Optional context identifier
|
|
55
|
+
*/
|
|
56
|
+
export declare function logDebug(message: string, context?: string): void;
|
|
57
|
+
/**
|
|
58
|
+
* Convenience function for logging info messages.
|
|
59
|
+
*
|
|
60
|
+
* @param message - Info message
|
|
61
|
+
* @param context - Optional context identifier
|
|
62
|
+
*/
|
|
63
|
+
export declare function logInfo(message: string, context?: string): void;
|
|
64
|
+
/**
|
|
65
|
+
* Convenience function for logging warning messages.
|
|
66
|
+
*
|
|
67
|
+
* @param message - Warning message
|
|
68
|
+
* @param context - Optional context identifier
|
|
69
|
+
*/
|
|
70
|
+
export declare function logWarn(message: string, context?: string): void;
|
|
71
|
+
/**
|
|
72
|
+
* Convenience function for logging error messages.
|
|
73
|
+
*
|
|
74
|
+
* @param message - Error message
|
|
75
|
+
* @param context - Optional context identifier
|
|
76
|
+
*/
|
|
77
|
+
export declare function logError(message: string, context?: string): void;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry Index for the ACP Registry.
|
|
3
|
+
*
|
|
4
|
+
* Handles fetching, parsing, and querying the ACP Registry.
|
|
5
|
+
* Supports configurable registry URL via environment variable.
|
|
6
|
+
*
|
|
7
|
+
* @module registry/index
|
|
8
|
+
*/
|
|
9
|
+
import { Registry, RegistryAgent, SpawnCommand } from './types.js';
|
|
10
|
+
export type { Platform, BinaryDistribution, BinaryTarget, NpxDistribution, UvxDistribution, Distribution, RegistryAgent, Registry, SpawnCommand, } from './types.js';
|
|
11
|
+
export { PlatformNotSupportedError, NoDistributionError, getCurrentPlatform, resolve } from './resolver.js';
|
|
12
|
+
/**
|
|
13
|
+
* Error thrown when registry fetch fails.
|
|
14
|
+
*/
|
|
15
|
+
export declare class RegistryFetchError extends Error {
|
|
16
|
+
readonly cause?: Error | undefined;
|
|
17
|
+
constructor(message: string, cause?: Error | undefined);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Error thrown when registry JSON is malformed.
|
|
21
|
+
*/
|
|
22
|
+
export declare class RegistryParseError extends Error {
|
|
23
|
+
readonly cause?: Error | undefined;
|
|
24
|
+
constructor(message: string, cause?: Error | undefined);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Error thrown when an agent is not found in the registry.
|
|
28
|
+
*/
|
|
29
|
+
export declare class AgentNotFoundError extends Error {
|
|
30
|
+
readonly agentId: string;
|
|
31
|
+
constructor(agentId: string);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Interface for the RegistryIndex.
|
|
35
|
+
*/
|
|
36
|
+
export interface IRegistryIndex {
|
|
37
|
+
/**
|
|
38
|
+
* Fetch and parse the ACP Registry from the configured URL.
|
|
39
|
+
* @throws RegistryFetchError if fetch fails
|
|
40
|
+
* @throws RegistryParseError if JSON is malformed
|
|
41
|
+
*/
|
|
42
|
+
fetch(): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Look up an agent by ID.
|
|
45
|
+
* @returns The agent entry or undefined if not found
|
|
46
|
+
*/
|
|
47
|
+
lookup(agentId: string): RegistryAgent | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Resolve an agent ID to a spawn command.
|
|
50
|
+
* @throws AgentNotFoundError if agent not in registry
|
|
51
|
+
* @throws PlatformNotSupportedError if binary distribution doesn't support current platform
|
|
52
|
+
*/
|
|
53
|
+
resolve(agentId: string): SpawnCommand;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Parse and validate registry JSON data.
|
|
57
|
+
*
|
|
58
|
+
* @param data - Raw JSON data to parse
|
|
59
|
+
* @returns Parsed and validated Registry object
|
|
60
|
+
* @throws RegistryParseError if JSON is malformed or invalid
|
|
61
|
+
*/
|
|
62
|
+
export declare function parseRegistry(data: unknown): Registry;
|
|
63
|
+
/**
|
|
64
|
+
* Registry Index implementation.
|
|
65
|
+
*
|
|
66
|
+
* Fetches, parses, and provides lookup functionality for the ACP Registry.
|
|
67
|
+
*/
|
|
68
|
+
export declare class RegistryIndex implements IRegistryIndex {
|
|
69
|
+
/** Configured registry URL */
|
|
70
|
+
private readonly registryUrl;
|
|
71
|
+
/** Parsed registry data (null until fetch() is called) */
|
|
72
|
+
private registry;
|
|
73
|
+
/** Map of agent ID to agent entry for fast lookup */
|
|
74
|
+
private agentMap;
|
|
75
|
+
/**
|
|
76
|
+
* Create a new RegistryIndex.
|
|
77
|
+
*
|
|
78
|
+
* @param registryUrl - URL to fetch the registry from (can be overridden by ACP_REGISTRY_URL env var)
|
|
79
|
+
*/
|
|
80
|
+
constructor(registryUrl: string);
|
|
81
|
+
/**
|
|
82
|
+
* Fetch and parse the ACP Registry from the configured URL.
|
|
83
|
+
*
|
|
84
|
+
* @throws RegistryFetchError if fetch fails
|
|
85
|
+
* @throws RegistryParseError if JSON is malformed
|
|
86
|
+
*/
|
|
87
|
+
fetch(): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Look up an agent by ID.
|
|
90
|
+
*
|
|
91
|
+
* @param agentId - Agent ID to look up
|
|
92
|
+
* @returns The agent entry or undefined if not found
|
|
93
|
+
*/
|
|
94
|
+
lookup(agentId: string): RegistryAgent | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Resolve an agent ID to a spawn command.
|
|
97
|
+
*
|
|
98
|
+
* @param agentId - Agent ID to resolve
|
|
99
|
+
* @returns Resolved spawn command
|
|
100
|
+
* @throws AgentNotFoundError if agent not in registry
|
|
101
|
+
* @throws PlatformNotSupportedError if binary distribution doesn't support current platform
|
|
102
|
+
*/
|
|
103
|
+
resolve(agentId: string): SpawnCommand;
|
|
104
|
+
/**
|
|
105
|
+
* Get the parsed registry data.
|
|
106
|
+
* @returns The parsed registry or null if not yet fetched
|
|
107
|
+
*/
|
|
108
|
+
getRegistry(): Registry | null;
|
|
109
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Distribution Resolver for the ACP Registry.
|
|
3
|
+
*
|
|
4
|
+
* Resolves distribution metadata to spawn commands based on distribution type.
|
|
5
|
+
* Supports binary (platform-specific), npx (npm), and uvx (Python) distributions.
|
|
6
|
+
*
|
|
7
|
+
* @module registry/resolver
|
|
8
|
+
*/
|
|
9
|
+
import { BinaryDistribution, Distribution, NpxDistribution, Platform, SpawnCommand, UvxDistribution } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Error thrown when the current platform is not supported by a binary distribution.
|
|
12
|
+
*/
|
|
13
|
+
export declare class PlatformNotSupportedError extends Error {
|
|
14
|
+
readonly agentId: string;
|
|
15
|
+
readonly platform: Platform;
|
|
16
|
+
constructor(agentId: string, platform: Platform);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Error thrown when no supported distribution type is available.
|
|
20
|
+
*/
|
|
21
|
+
export declare class NoDistributionError extends Error {
|
|
22
|
+
readonly agentId: string;
|
|
23
|
+
constructor(agentId: string);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get the current platform identifier.
|
|
27
|
+
* Maps Node.js platform/arch to ACP Registry platform format.
|
|
28
|
+
*
|
|
29
|
+
* @returns Platform identifier for the current OS and architecture
|
|
30
|
+
*/
|
|
31
|
+
export declare function getCurrentPlatform(): Platform;
|
|
32
|
+
/**
|
|
33
|
+
* Resolve a binary distribution to a spawn command.
|
|
34
|
+
*
|
|
35
|
+
* @param distribution - Binary distribution to resolve
|
|
36
|
+
* @param agentId - Agent ID for error messages
|
|
37
|
+
* @returns Resolved spawn command
|
|
38
|
+
* @throws PlatformNotSupportedError if current platform is not supported
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolveBinary(distribution: BinaryDistribution, agentId: string): SpawnCommand;
|
|
41
|
+
/**
|
|
42
|
+
* Resolve an npx distribution to a spawn command.
|
|
43
|
+
*
|
|
44
|
+
* @param distribution - NPX distribution to resolve
|
|
45
|
+
* @returns Resolved spawn command
|
|
46
|
+
*/
|
|
47
|
+
export declare function resolveNpx(distribution: NpxDistribution): SpawnCommand;
|
|
48
|
+
/**
|
|
49
|
+
* Resolve a uvx distribution to a spawn command.
|
|
50
|
+
*
|
|
51
|
+
* @param distribution - UVX distribution to resolve
|
|
52
|
+
* @returns Resolved spawn command
|
|
53
|
+
*/
|
|
54
|
+
export declare function resolveUvx(distribution: UvxDistribution): SpawnCommand;
|
|
55
|
+
/**
|
|
56
|
+
* Resolve a distribution to a spawn command.
|
|
57
|
+
*
|
|
58
|
+
* Priority order: npx > uvx > binary
|
|
59
|
+
* (npx/uvx are preferred as they don't require platform-specific handling)
|
|
60
|
+
*
|
|
61
|
+
* @param distribution - Distribution to resolve
|
|
62
|
+
* @param agentId - Agent ID for error messages
|
|
63
|
+
* @returns Resolved spawn command
|
|
64
|
+
* @throws PlatformNotSupportedError if binary distribution doesn't support current platform
|
|
65
|
+
* @throws NoDistributionError if no distribution type is available
|
|
66
|
+
*/
|
|
67
|
+
export declare function resolve(distribution: Distribution, agentId: string): SpawnCommand;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for the ACP Registry.
|
|
3
|
+
*
|
|
4
|
+
* These types match the official ACP Registry schema:
|
|
5
|
+
* https://cdn.agentclientprotocol.com/registry/v1/latest/registry.schema.json
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Platform identifiers for binary distributions.
|
|
9
|
+
* Format: <os>-<arch>
|
|
10
|
+
*/
|
|
11
|
+
export type Platform = 'darwin-aarch64' | 'darwin-x86_64' | 'linux-aarch64' | 'linux-x86_64' | 'windows-aarch64' | 'windows-x86_64';
|
|
12
|
+
/**
|
|
13
|
+
* Binary target metadata for a specific platform.
|
|
14
|
+
*/
|
|
15
|
+
export interface BinaryTarget {
|
|
16
|
+
/** URL to download archive */
|
|
17
|
+
archive: string;
|
|
18
|
+
/** Command to execute after extraction */
|
|
19
|
+
cmd: string;
|
|
20
|
+
/** Optional command-line arguments */
|
|
21
|
+
args?: string[];
|
|
22
|
+
/** Optional environment variables */
|
|
23
|
+
env?: Record<string, string>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Binary distribution - platform-specific executables.
|
|
27
|
+
*/
|
|
28
|
+
export type BinaryDistribution = Partial<Record<Platform, BinaryTarget>>;
|
|
29
|
+
/**
|
|
30
|
+
* NPX distribution - Node packages run via npx.
|
|
31
|
+
*/
|
|
32
|
+
export interface NpxDistribution {
|
|
33
|
+
/** Package name with optional version (e.g., "@scope/pkg@1.0.0") */
|
|
34
|
+
package: string;
|
|
35
|
+
/** Optional command-line arguments */
|
|
36
|
+
args?: string[];
|
|
37
|
+
/** Optional environment variables */
|
|
38
|
+
env?: Record<string, string>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* UVX distribution - Python packages run via uvx.
|
|
42
|
+
*/
|
|
43
|
+
export interface UvxDistribution {
|
|
44
|
+
/** Package name with optional version (e.g., "pkg@latest") */
|
|
45
|
+
package: string;
|
|
46
|
+
/** Optional command-line arguments */
|
|
47
|
+
args?: string[];
|
|
48
|
+
/** Optional environment variables */
|
|
49
|
+
env?: Record<string, string>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Distribution object containing one or more distribution types.
|
|
53
|
+
* An agent may provide multiple distribution methods.
|
|
54
|
+
*/
|
|
55
|
+
export interface Distribution {
|
|
56
|
+
/** Binary distribution (platform-specific executables) */
|
|
57
|
+
binary?: BinaryDistribution;
|
|
58
|
+
/** NPX distribution (Node packages) */
|
|
59
|
+
npx?: NpxDistribution;
|
|
60
|
+
/** UVX distribution (Python packages) */
|
|
61
|
+
uvx?: UvxDistribution;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Agent entry in the ACP Registry.
|
|
65
|
+
*/
|
|
66
|
+
export interface RegistryAgent {
|
|
67
|
+
/** Unique agent identifier */
|
|
68
|
+
id: string;
|
|
69
|
+
/** Human-readable display name */
|
|
70
|
+
name: string;
|
|
71
|
+
/** Semantic version of the agent */
|
|
72
|
+
version: string;
|
|
73
|
+
/** Brief description */
|
|
74
|
+
description?: string;
|
|
75
|
+
/** Source code repository URL */
|
|
76
|
+
repository?: string;
|
|
77
|
+
/** Author/organization names */
|
|
78
|
+
authors?: string[];
|
|
79
|
+
/** SPDX license identifier */
|
|
80
|
+
license?: string;
|
|
81
|
+
/** Icon URL or path */
|
|
82
|
+
icon?: string;
|
|
83
|
+
/** Distribution methods */
|
|
84
|
+
distribution: Distribution;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Parsed ACP Registry structure.
|
|
88
|
+
*/
|
|
89
|
+
export interface Registry {
|
|
90
|
+
/** Registry schema version */
|
|
91
|
+
version: string;
|
|
92
|
+
/** List of registered agents */
|
|
93
|
+
agents: RegistryAgent[];
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Resolved spawn command for an agent.
|
|
97
|
+
*/
|
|
98
|
+
export interface SpawnCommand {
|
|
99
|
+
/** Command to execute */
|
|
100
|
+
command: string;
|
|
101
|
+
/** Command-line arguments */
|
|
102
|
+
args: string[];
|
|
103
|
+
/** Environment variables */
|
|
104
|
+
env?: Record<string, string>;
|
|
105
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Router module barrel export.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the public API for message routing.
|
|
5
|
+
*
|
|
6
|
+
* @module router
|
|
7
|
+
*/
|
|
8
|
+
export { MessageRouter, RoutingErrorCodes, createErrorResponse, extractAgentId, extractId, transformMessage, type ErrorResponse, type WriteCallback, } from './message-router.js';
|