@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,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session State Management
|
|
3
|
+
*
|
|
4
|
+
* This module manages ACP session state including session creation,
|
|
5
|
+
* lookup, and cleanup. Each session maintains its own MCP connections
|
|
6
|
+
* and conversation history.
|
|
7
|
+
*
|
|
8
|
+
* @module session
|
|
9
|
+
*/
|
|
10
|
+
export { SessionManager } from './manager.js';
|
|
11
|
+
export { Session } from './session.js';
|
|
12
|
+
export type { SessionState, HistoryEntry } from './types.js';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Manager
|
|
3
|
+
*
|
|
4
|
+
* Manages the lifecycle of ACP sessions.
|
|
5
|
+
*
|
|
6
|
+
* @module session/manager
|
|
7
|
+
*/
|
|
8
|
+
import { type MCPManagerFactory, Session } from './session.js';
|
|
9
|
+
import type { MCPServerConfig } from '../mcp/types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Manages ACP sessions.
|
|
12
|
+
*/
|
|
13
|
+
export declare class SessionManager {
|
|
14
|
+
private sessions;
|
|
15
|
+
private mcpManagerFactory?;
|
|
16
|
+
/**
|
|
17
|
+
* Create a new SessionManager.
|
|
18
|
+
*
|
|
19
|
+
* @param mcpManagerFactory - Optional factory for creating MCPManager instances (used in tests)
|
|
20
|
+
*/
|
|
21
|
+
constructor(mcpManagerFactory?: MCPManagerFactory);
|
|
22
|
+
/**
|
|
23
|
+
* Create a new session.
|
|
24
|
+
*/
|
|
25
|
+
createSession(cwd: string, mcpServers?: MCPServerConfig[]): Promise<Session>;
|
|
26
|
+
/**
|
|
27
|
+
* Get a session by ID.
|
|
28
|
+
*/
|
|
29
|
+
getSession(id: string): Session | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Cancel a session.
|
|
32
|
+
*/
|
|
33
|
+
cancelSession(id: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Close and remove a session.
|
|
36
|
+
*/
|
|
37
|
+
closeSession(id: string): Promise<boolean>;
|
|
38
|
+
/**
|
|
39
|
+
* Close all sessions.
|
|
40
|
+
*/
|
|
41
|
+
closeAll(): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Get all sessions.
|
|
44
|
+
*
|
|
45
|
+
* @returns Array of all sessions
|
|
46
|
+
*/
|
|
47
|
+
getAllSessions(): Session[];
|
|
48
|
+
/**
|
|
49
|
+
* Remove a session from the manager without closing it.
|
|
50
|
+
*
|
|
51
|
+
* @param id - Session ID to remove
|
|
52
|
+
* @returns true if session was removed, false if not found
|
|
53
|
+
*/
|
|
54
|
+
removeSession(id: string): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Generate a unique session ID using crypto.randomUUID().
|
|
57
|
+
*
|
|
58
|
+
* Generate unique sessionId using UUID
|
|
59
|
+
*
|
|
60
|
+
* @returns A unique UUID string for the session
|
|
61
|
+
*/
|
|
62
|
+
private generateSessionId;
|
|
63
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session
|
|
3
|
+
*
|
|
4
|
+
* Represents a single ACP session with its state and MCP connections.
|
|
5
|
+
* Stores sessionId, cwd, MCP connections, and cancellation flag.
|
|
6
|
+
*
|
|
7
|
+
* @module session/session
|
|
8
|
+
*/
|
|
9
|
+
import type { HistoryEntry, SessionState } from './types.js';
|
|
10
|
+
import { MCPManager } from '../mcp/index.js';
|
|
11
|
+
/**
|
|
12
|
+
* Factory function type for creating MCPManager instances.
|
|
13
|
+
* Used for dependency injection in tests.
|
|
14
|
+
*/
|
|
15
|
+
export type MCPManagerFactory = () => MCPManager;
|
|
16
|
+
/**
|
|
17
|
+
* Represents an ACP session.
|
|
18
|
+
*
|
|
19
|
+
* The Session class manages:
|
|
20
|
+
* - Session identification (sessionId per requirements)
|
|
21
|
+
* - Working directory context (cwd)
|
|
22
|
+
* - MCP server connections via MCPManager
|
|
23
|
+
* - Cancellation state for aborting operations
|
|
24
|
+
* - Conversation history
|
|
25
|
+
*/
|
|
26
|
+
export declare class Session {
|
|
27
|
+
/** Unique session identifier (SessionId type per requirements) */
|
|
28
|
+
readonly id: string;
|
|
29
|
+
/** Current working directory for the session */
|
|
30
|
+
readonly cwd: string;
|
|
31
|
+
/** Manager for MCP server connections */
|
|
32
|
+
readonly mcpManager: MCPManager;
|
|
33
|
+
/** Cancellation flag for aborting pending operations */
|
|
34
|
+
private cancelled;
|
|
35
|
+
/** Timestamp when the session was created */
|
|
36
|
+
private createdAt;
|
|
37
|
+
/** Conversation history for the session */
|
|
38
|
+
private history;
|
|
39
|
+
/**
|
|
40
|
+
* Create a new Session.
|
|
41
|
+
*
|
|
42
|
+
* @param id - Unique session identifier
|
|
43
|
+
* @param cwd - Current working directory for the session
|
|
44
|
+
* @param mcpManagerFactory - Optional factory for creating MCPManager (used in tests)
|
|
45
|
+
*/
|
|
46
|
+
constructor(id: string, cwd: string, mcpManagerFactory?: MCPManagerFactory);
|
|
47
|
+
/**
|
|
48
|
+
* Check if the session has been cancelled.
|
|
49
|
+
*
|
|
50
|
+
* @returns true if the session has been cancelled
|
|
51
|
+
*/
|
|
52
|
+
isCancelled(): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Cancel the session.
|
|
55
|
+
* Sets the cancellation flag and aborts pending MCP operations.
|
|
56
|
+
*/
|
|
57
|
+
cancel(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Add an entry to the conversation history.
|
|
60
|
+
*
|
|
61
|
+
* @param role - Role of the message sender ('user' or 'agent')
|
|
62
|
+
* @param content - Content of the message
|
|
63
|
+
*/
|
|
64
|
+
addHistoryEntry(role: 'user' | 'agent', content: string): void;
|
|
65
|
+
/**
|
|
66
|
+
* Get the conversation history.
|
|
67
|
+
*
|
|
68
|
+
* @returns Array of history entries
|
|
69
|
+
*/
|
|
70
|
+
getHistory(): HistoryEntry[];
|
|
71
|
+
/**
|
|
72
|
+
* Clear the conversation history.
|
|
73
|
+
*/
|
|
74
|
+
clearHistory(): void;
|
|
75
|
+
/**
|
|
76
|
+
* Get the session state.
|
|
77
|
+
*
|
|
78
|
+
* @returns Current session state including id, cwd, cancelled flag, and history
|
|
79
|
+
*/
|
|
80
|
+
getState(): SessionState;
|
|
81
|
+
/**
|
|
82
|
+
* Close the session and cleanup resources.
|
|
83
|
+
* Closes all MCP server connections.
|
|
84
|
+
*/
|
|
85
|
+
close(): Promise<void>;
|
|
86
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for session state management.
|
|
5
|
+
*
|
|
6
|
+
* @module session/types
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Represents a history entry in a session.
|
|
10
|
+
*/
|
|
11
|
+
export interface HistoryEntry {
|
|
12
|
+
/** Role of the message sender */
|
|
13
|
+
role: 'user' | 'agent';
|
|
14
|
+
/** Content of the message */
|
|
15
|
+
content: string;
|
|
16
|
+
/** Timestamp of the message */
|
|
17
|
+
timestamp: Date;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Represents the state of an ACP session.
|
|
21
|
+
*/
|
|
22
|
+
export interface SessionState {
|
|
23
|
+
/** Unique session identifier (SessionId type per requirements) */
|
|
24
|
+
id: string;
|
|
25
|
+
/** Current working directory for the session */
|
|
26
|
+
cwd: string;
|
|
27
|
+
/** Whether the session has been cancelled */
|
|
28
|
+
cancelled: boolean;
|
|
29
|
+
/** When the session was created */
|
|
30
|
+
createdAt: Date;
|
|
31
|
+
/** Conversation history for the session */
|
|
32
|
+
history: HistoryEntry[];
|
|
33
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Integration Test Harness
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities for testing full ACP/MCP protocol flows.
|
|
5
|
+
* Creates mock MCP servers and ACP clients for integration testing.
|
|
6
|
+
*
|
|
7
|
+
* @module tests/integration/test-harness
|
|
8
|
+
*/
|
|
9
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
10
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
11
|
+
/**
|
|
12
|
+
* Mock MCP server for testing.
|
|
13
|
+
* Provides configurable tools and resources.
|
|
14
|
+
*/
|
|
15
|
+
export interface MockMCPServer {
|
|
16
|
+
server: Server;
|
|
17
|
+
transport: [unknown, unknown];
|
|
18
|
+
tools: MockTool[];
|
|
19
|
+
resources: MockResource[];
|
|
20
|
+
close: () => Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Mock tool definition.
|
|
24
|
+
*/
|
|
25
|
+
export interface MockTool {
|
|
26
|
+
name: string;
|
|
27
|
+
description: string;
|
|
28
|
+
inputSchema: Record<string, unknown>;
|
|
29
|
+
handler: (args: Record<string, unknown>) => Promise<{
|
|
30
|
+
content: Array<{
|
|
31
|
+
type: string;
|
|
32
|
+
text?: string;
|
|
33
|
+
}>;
|
|
34
|
+
isError?: boolean;
|
|
35
|
+
}>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Mock resource definition.
|
|
39
|
+
*/
|
|
40
|
+
export interface MockResource {
|
|
41
|
+
uri: string;
|
|
42
|
+
name: string;
|
|
43
|
+
description?: string;
|
|
44
|
+
mimeType?: string;
|
|
45
|
+
content: string | {
|
|
46
|
+
blob: string;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Create a mock MCP server with configurable tools and resources.
|
|
51
|
+
*
|
|
52
|
+
* @param name - Server name
|
|
53
|
+
* @param tools - Array of mock tools
|
|
54
|
+
* @param resources - Array of mock resources
|
|
55
|
+
* @returns Mock MCP server instance
|
|
56
|
+
*/
|
|
57
|
+
export declare function createMockMCPServer(name: string, tools?: MockTool[], resources?: MockResource[]): Promise<MockMCPServer>;
|
|
58
|
+
/**
|
|
59
|
+
* Create an MCP client connected to a mock server.
|
|
60
|
+
*
|
|
61
|
+
* @param mockServer - The mock server to connect to
|
|
62
|
+
* @returns Connected MCP client
|
|
63
|
+
*/
|
|
64
|
+
export declare function createMCPClientForMockServer(mockServer: MockMCPServer): Promise<Client>;
|
|
65
|
+
/**
|
|
66
|
+
* Default echo tool for testing.
|
|
67
|
+
*/
|
|
68
|
+
export declare const echoTool: MockTool;
|
|
69
|
+
/**
|
|
70
|
+
* Default error tool for testing error handling.
|
|
71
|
+
*/
|
|
72
|
+
export declare const errorTool: MockTool;
|
|
73
|
+
/**
|
|
74
|
+
* Default greeting resource for testing.
|
|
75
|
+
*/
|
|
76
|
+
export declare const greetingResource: MockResource;
|
|
77
|
+
/**
|
|
78
|
+
* Default config resource for testing.
|
|
79
|
+
*/
|
|
80
|
+
export declare const configResource: MockResource;
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stdiobus/workers-registry",
|
|
3
|
+
"version": "1.3.7",
|
|
4
|
+
"description": "Worker implementations for stdio Bus kernel - ACP, MCP, and protocol bridges",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./out/dist/workers/acp-worker/index.js",
|
|
7
|
+
"types": "./out/tsc/workers/acp-worker/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./out/dist/workers/acp-worker/index.js",
|
|
11
|
+
"types": "./out/tsc/workers/acp-worker/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./workers/acp-worker": {
|
|
14
|
+
"import": "./out/dist/workers/acp-worker/index.js",
|
|
15
|
+
"types": "./out/tsc/workers/acp-worker/index.d.ts"
|
|
16
|
+
},
|
|
17
|
+
"./workers/echo-worker": "./out/dist/workers/echo-worker/echo-worker.js",
|
|
18
|
+
"./workers/mcp-echo-server": {
|
|
19
|
+
"import": "./out/dist/workers/mcp-echo-server/index.js",
|
|
20
|
+
"types": "./out/tsc/workers/mcp-echo-server/index.d.ts"
|
|
21
|
+
},
|
|
22
|
+
"./workers/mcp-to-acp-proxy": "./out/dist/workers/mcp-to-acp-proxy/proxy.js",
|
|
23
|
+
"./workers": "./out/dist/workers/index.js",
|
|
24
|
+
"./package.json": "./package.json"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"out/",
|
|
28
|
+
"README.md",
|
|
29
|
+
"LICENSE"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "node scripts/build.js",
|
|
33
|
+
"build:workers": "node scripts/build.js",
|
|
34
|
+
"clean": "rm -rf out",
|
|
35
|
+
"prepublishOnly": "npm run build",
|
|
36
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
37
|
+
"test:unit": "node --experimental-vm-modules node_modules/jest/bin/jest.js tests/unit",
|
|
38
|
+
"test:property": "node --experimental-vm-modules node_modules/jest/bin/jest.js tests/property",
|
|
39
|
+
"test:integration": "node --experimental-vm-modules node_modules/jest/bin/jest.js tests/integration",
|
|
40
|
+
"sync-acp": "node scripts/sync-acp.js"
|
|
41
|
+
},
|
|
42
|
+
"keywords": [
|
|
43
|
+
"acp",
|
|
44
|
+
"mcp",
|
|
45
|
+
"agent",
|
|
46
|
+
"transport",
|
|
47
|
+
"json-rpc",
|
|
48
|
+
"stdio-bus",
|
|
49
|
+
"worker",
|
|
50
|
+
"protocol"
|
|
51
|
+
],
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "https://github.com/stdiobus/workers-registry.git"
|
|
55
|
+
},
|
|
56
|
+
"bugs": {
|
|
57
|
+
"url": "https://github.com/stdiobus/workers-registry/issues"
|
|
58
|
+
},
|
|
59
|
+
"homepage": "https://github.com/stdiobus/workers-registry#readme",
|
|
60
|
+
"license": "Apache-2.0",
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=20.0.0"
|
|
63
|
+
},
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"@agentclientprotocol/sdk": "^0.14.1",
|
|
66
|
+
"@modelcontextprotocol/sdk": "^1.27.1"
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@types/jest": "^29.5.0",
|
|
70
|
+
"@types/node": "^20.0.0",
|
|
71
|
+
"esbuild": "^0.20.0",
|
|
72
|
+
"fast-check": "^3.22.0",
|
|
73
|
+
"jest": "^29.7.0",
|
|
74
|
+
"ts-jest": "^29.1.0",
|
|
75
|
+
"typescript": "^5.0.0"
|
|
76
|
+
}
|
|
77
|
+
}
|