@stdiobus/workers-registry 1.4.14 → 1.5.0-beta.2

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.
Files changed (129) hide show
  1. package/README.md +181 -21
  2. package/out/dist/workers-registry/acp-registry/index.js +128 -2
  3. package/out/dist/workers-registry/acp-registry/index.js.map +4 -4
  4. package/out/dist/workers-registry/acp-worker/index.js +1 -3
  5. package/out/dist/workers-registry/acp-worker/index.js.map +4 -4
  6. package/out/dist/workers-registry/index.d.ts +1 -0
  7. package/out/dist/workers-registry/index.js +6 -0
  8. package/out/dist/workers-registry/openai-agent/index.js +1 -1
  9. package/out/dist/workers-registry/openai-agent/index.js.map +2 -2
  10. package/out/dist/workers-registry/registry-launcher/index.js +131 -0
  11. package/out/dist/workers-registry/registry-launcher/index.js.map +7 -0
  12. package/out/tsc/workers-registry/acp-worker/src/index.d.ts +0 -10
  13. package/out/tsc/workers-registry/registry-launcher/src/auth/auth-manager.d.ts +392 -0
  14. package/out/tsc/workers-registry/registry-launcher/src/auth/cli/cli.property.test.d.ts +22 -0
  15. package/out/tsc/workers-registry/registry-launcher/src/auth/cli/index.d.ts +9 -0
  16. package/out/tsc/workers-registry/registry-launcher/src/auth/cli/login-command.d.ts +32 -0
  17. package/out/tsc/workers-registry/registry-launcher/src/auth/cli/logout-command.d.ts +25 -0
  18. package/out/tsc/workers-registry/registry-launcher/src/auth/cli/setup-command.d.ts +25 -0
  19. package/out/tsc/workers-registry/registry-launcher/src/auth/cli/status-command.d.ts +21 -0
  20. package/out/tsc/workers-registry/registry-launcher/src/auth/errors.d.ts +190 -0
  21. package/out/tsc/workers-registry/registry-launcher/src/auth/flows/agent-auth-flow.d.ts +146 -0
  22. package/out/tsc/workers-registry/registry-launcher/src/auth/flows/callback-server.d.ts +131 -0
  23. package/out/tsc/workers-registry/registry-launcher/src/auth/flows/callback-server.test.d.ts +1 -0
  24. package/out/tsc/workers-registry/registry-launcher/src/auth/flows/index.d.ts +11 -0
  25. package/out/tsc/workers-registry/registry-launcher/src/auth/flows/terminal-auth-flow.d.ts +252 -0
  26. package/out/tsc/workers-registry/registry-launcher/src/auth/flows/terminal-auth-flow.test.d.ts +1 -0
  27. package/out/tsc/workers-registry/registry-launcher/src/auth/index.d.ts +33 -0
  28. package/out/tsc/workers-registry/registry-launcher/src/auth/integration.test.d.ts +1 -0
  29. package/out/tsc/workers-registry/registry-launcher/src/auth/model-credentials/anthropic-api-key.d.ts +154 -0
  30. package/out/tsc/workers-registry/registry-launcher/src/auth/model-credentials/index.d.ts +20 -0
  31. package/out/tsc/workers-registry/registry-launcher/src/auth/model-credentials/model-credentials.test.d.ts +1 -0
  32. package/out/tsc/workers-registry/registry-launcher/src/auth/model-credentials/openai-api-key.d.ts +182 -0
  33. package/out/tsc/workers-registry/registry-launcher/src/auth/model-credentials/types.d.ts +186 -0
  34. package/out/tsc/workers-registry/registry-launcher/src/auth/pkce.d.ts +61 -0
  35. package/out/tsc/workers-registry/registry-launcher/src/auth/pkce.property.test.d.ts +1 -0
  36. package/out/tsc/workers-registry/registry-launcher/src/auth/pkce.test.d.ts +1 -0
  37. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/base-provider.d.ts +138 -0
  38. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/base-provider.test.d.ts +1 -0
  39. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/cognito-provider.d.ts +44 -0
  40. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/concrete-providers.test.d.ts +1 -0
  41. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/entra-provider.d.ts +54 -0
  42. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/github-provider.d.ts +19 -0
  43. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/google-provider.d.ts +19 -0
  44. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/index.d.ts +107 -0
  45. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/index.test.d.ts +1 -0
  46. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/oidc-provider.d.ts +413 -0
  47. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/oidc-provider.property.test.d.ts +1 -0
  48. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/oidc-provider.test.d.ts +1 -0
  49. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/providers.property.test.d.ts +1 -0
  50. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/types.d.ts +28 -0
  51. package/out/tsc/workers-registry/registry-launcher/src/auth/session.d.ts +251 -0
  52. package/out/tsc/workers-registry/registry-launcher/src/auth/session.property.test.d.ts +1 -0
  53. package/out/tsc/workers-registry/registry-launcher/src/auth/session.test.d.ts +1 -0
  54. package/out/tsc/workers-registry/registry-launcher/src/auth/state.d.ts +26 -0
  55. package/out/tsc/workers-registry/registry-launcher/src/auth/state.property.test.d.ts +1 -0
  56. package/out/tsc/workers-registry/registry-launcher/src/auth/state.test.d.ts +1 -0
  57. package/out/tsc/workers-registry/registry-launcher/src/auth/storage/credential-store.d.ts +98 -0
  58. package/out/tsc/workers-registry/registry-launcher/src/auth/storage/credential-store.test.d.ts +1 -0
  59. package/out/tsc/workers-registry/registry-launcher/src/auth/storage/encrypted-file-backend.d.ts +101 -0
  60. package/out/tsc/workers-registry/registry-launcher/src/auth/storage/encrypted-file-backend.test.d.ts +1 -0
  61. package/out/tsc/workers-registry/registry-launcher/src/auth/storage/index.d.ts +12 -0
  62. package/out/tsc/workers-registry/registry-launcher/src/auth/storage/keychain-backend.d.ts +80 -0
  63. package/out/tsc/workers-registry/registry-launcher/src/auth/storage/keychain-backend.test.d.ts +1 -0
  64. package/out/tsc/workers-registry/registry-launcher/src/auth/storage/memory-backend.d.ts +54 -0
  65. package/out/tsc/workers-registry/registry-launcher/src/auth/storage/storage.property.test.d.ts +1 -0
  66. package/out/tsc/workers-registry/registry-launcher/src/auth/storage/types.d.ts +44 -0
  67. package/out/tsc/workers-registry/registry-launcher/src/auth/token-manager.d.ts +171 -0
  68. package/out/tsc/workers-registry/registry-launcher/src/auth/token-manager.property.test.d.ts +1 -0
  69. package/out/tsc/workers-registry/registry-launcher/src/auth/token-manager.test.d.ts +1 -0
  70. package/out/tsc/workers-registry/registry-launcher/src/auth/types.d.ts +369 -0
  71. package/out/tsc/workers-registry/registry-launcher/src/auth/types.test.d.ts +1 -0
  72. package/out/tsc/workers-registry/registry-launcher/src/config/config.property.test.d.ts +1 -0
  73. package/out/tsc/workers-registry/registry-launcher/src/config/config.test.d.ts +1 -0
  74. package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/registry/index.d.ts +51 -2
  75. package/out/tsc/workers-registry/registry-launcher/src/registry/index.property.test.d.ts +1 -0
  76. package/out/tsc/workers-registry/registry-launcher/src/registry/index.test.d.ts +1 -0
  77. package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/registry/types.d.ts +24 -0
  78. package/out/tsc/workers-registry/registry-launcher/src/router/message-router.d.ts +770 -0
  79. package/out/tsc/workers-registry/registry-launcher/src/router/message-router.property.test.d.ts +1 -0
  80. package/out/tsc/workers-registry/registry-launcher/src/router/message-router.test.d.ts +1 -0
  81. package/out/tsc/workers-registry/registry-launcher/src/runtime/manager.property.test.d.ts +1 -0
  82. package/out/tsc/workers-registry/registry-launcher/src/runtime/manager.test.d.ts +1 -0
  83. package/out/tsc/workers-registry/registry-launcher/src/stream/ndjson-handler.property.test.d.ts +1 -0
  84. package/out/tsc/workers-registry/registry-launcher/src/stream/ndjson-handler.test.d.ts +1 -0
  85. package/out/tsc/workers-registry/registry-launcher/tests/e2e/auth-flow.e2e.test.d.ts +1 -0
  86. package/out/tsc/workers-registry/registry-launcher/tests/e2e/auth-required-flow.e2e.test.d.ts +1 -0
  87. package/out/tsc/workers-registry/registry-launcher/tests/e2e/helpers/api-keys.d.ts +32 -0
  88. package/out/tsc/workers-registry/registry-launcher/tests/e2e/helpers/index.d.ts +17 -0
  89. package/out/tsc/workers-registry/registry-launcher/tests/e2e/helpers/launcher-harness.d.ts +101 -0
  90. package/out/tsc/workers-registry/registry-launcher/tests/e2e/helpers/registry-server.d.ts +46 -0
  91. package/out/tsc/workers-registry/registry-launcher/tests/e2e/production-agent-auth.e2e.test.d.ts +1 -0
  92. package/out/tsc/workers-registry/registry-launcher/tests/e2e/production-api-keys.e2e.test.d.ts +1 -0
  93. package/out/tsc/workers-registry/registry-launcher/tests/e2e/production-auth-required.e2e.test.d.ts +1 -0
  94. package/out/tsc/workers-registry/registry-launcher/tests/e2e/production-cli.e2e.test.d.ts +1 -0
  95. package/out/tsc/workers-registry/registry-launcher/tests/e2e/production-concurrent.e2e.test.d.ts +1 -0
  96. package/out/tsc/workers-registry/registry-launcher/tests/e2e/production-lifecycle.e2e.test.d.ts +1 -0
  97. package/out/tsc/workers-registry/registry-launcher/tests/e2e/production-terminal-auth.e2e.test.d.ts +1 -0
  98. package/out/tsc/workers-registry/registry-launcher/tests/integration/agent-auth.integration.test.d.ts +9 -0
  99. package/out/tsc/workers-registry/registry-launcher/tests/integration/registry-launcher.test.d.ts +1 -0
  100. package/out/tsc/workers-registry/registry-launcher/tests/integration/terminal-auth.integration.test.d.ts +12 -0
  101. package/package.json +16 -11
  102. package/out/tsc/workers-registry/acp-worker/src/registry-launcher/router/message-router.d.ts +0 -199
  103. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher/config/config.property.test.d.ts → registry-launcher/src/auth/auth-manager.property.test.d.ts} +0 -0
  104. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher/config/config.test.d.ts → registry-launcher/src/auth/auth-manager.test.d.ts} +0 -0
  105. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher/registry/index.property.test.d.ts → registry-launcher/src/auth/cli/cli.test.d.ts} +0 -0
  106. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher/registry/index.test.d.ts → registry-launcher/src/auth/cli/login-command.test.d.ts} +0 -0
  107. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher/router/message-router.property.test.d.ts → registry-launcher/src/auth/cli/provider-config.test.d.ts} +0 -0
  108. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher/router/message-router.test.d.ts → registry-launcher/src/auth/cli/setup-command.test.d.ts} +0 -0
  109. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher/runtime/manager.property.test.d.ts → registry-launcher/src/auth/cli/status-command.test.d.ts} +0 -0
  110. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher/runtime/manager.test.d.ts → registry-launcher/src/auth/errors.property.test.d.ts} +0 -0
  111. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher/stream/ndjson-handler.property.test.d.ts → registry-launcher/src/auth/errors.test.d.ts} +0 -0
  112. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher/stream/ndjson-handler.test.d.ts → registry-launcher/src/auth/flows/agent-auth-flow.test.d.ts} +0 -0
  113. /package/out/tsc/workers-registry/{acp-worker/tests/integration/registry-launcher.test.d.ts → registry-launcher/src/auth/flows/callback-server.property.test.d.ts} +0 -0
  114. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/config/api-keys.d.ts +0 -0
  115. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/config/config.d.ts +0 -0
  116. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/config/index.d.ts +0 -0
  117. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/config/types.d.ts +0 -0
  118. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/index.d.ts +0 -0
  119. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/log.d.ts +0 -0
  120. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/log.test.d.ts +0 -0
  121. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/registry/resolver.d.ts +0 -0
  122. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/router/index.d.ts +0 -0
  123. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/runtime/agent-runtime.d.ts +0 -0
  124. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/runtime/index.d.ts +0 -0
  125. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/runtime/manager.d.ts +0 -0
  126. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/runtime/types.d.ts +0 -0
  127. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/stream/index.d.ts +0 -0
  128. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/stream/ndjson-handler.d.ts +0 -0
  129. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/test-utils/index.d.ts +0 -0
@@ -0,0 +1,32 @@
1
+ /** Configuration for a single agent's API key entry. */
2
+ export interface AgentApiKeyConfig {
3
+ /** API key value */
4
+ apiKey?: string;
5
+ /** Environment variables to inject into the agent process */
6
+ env?: Record<string, string>;
7
+ }
8
+ /**
9
+ * Helper for creating and managing temporary api-keys.json files.
10
+ *
11
+ * Tracks all created temp directories for cleanup.
12
+ */
13
+ export declare class ApiKeysHelper {
14
+ private tempDirs;
15
+ /**
16
+ * Create a temporary api-keys.json file with the given agent configs.
17
+ *
18
+ * @param agents - Map of agent ID to API key configuration.
19
+ * @returns Absolute path to the created api-keys.json file.
20
+ */
21
+ createApiKeysFile(agents: Record<string, AgentApiKeyConfig>): string;
22
+ /**
23
+ * Create an empty api-keys.json (no agents configured).
24
+ *
25
+ * @returns Absolute path to the created api-keys.json file.
26
+ */
27
+ createEmptyApiKeysFile(): string;
28
+ /**
29
+ * Clean up all temporary files and directories created by this helper.
30
+ */
31
+ cleanup(): void;
32
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * E2E test helper infrastructure.
3
+ *
4
+ * Provides helpers for spawning the production launcher binary,
5
+ * serving mock registries, and managing temporary api-keys files.
6
+ *
7
+ * IMPORTANT: These helpers work ONLY with the production binary (dist/).
8
+ * No imports from src/ are allowed.
9
+ *
10
+ * @module tests/e2e/helpers
11
+ */
12
+ export { LauncherHarness } from './launcher-harness';
13
+ export type { LauncherOptions } from './launcher-harness';
14
+ export { MockRegistryServer } from './registry-server';
15
+ export type { MockAgent } from './registry-server';
16
+ export { ApiKeysHelper } from './api-keys';
17
+ export type { AgentApiKeyConfig } from './api-keys';
@@ -0,0 +1,101 @@
1
+ /** Options for starting the launcher process. */
2
+ export interface LauncherOptions {
3
+ /** Environment variables to pass to the launcher */
4
+ env?: Record<string, string>;
5
+ /** Path to api-keys.json file */
6
+ apiKeysPath?: string;
7
+ /** URL for the mock registry server */
8
+ registryUrl?: string;
9
+ /** Additional CLI args */
10
+ args?: string[];
11
+ /** Timeout for launcher ready in ms (default: 15000) */
12
+ readyTimeoutMs?: number;
13
+ }
14
+ /**
15
+ * Test harness for the production Registry Launcher binary.
16
+ *
17
+ * Manages spawning, communication, and cleanup of the launcher process
18
+ * for E2E testing.
19
+ */
20
+ export declare class LauncherHarness {
21
+ private process;
22
+ private stderrBuffer;
23
+ private stdoutBuffer;
24
+ private responses;
25
+ private responseListeners;
26
+ private stderrListeners;
27
+ /** Path to the production launcher binary. */
28
+ private readonly launcherPath;
29
+ constructor();
30
+ /**
31
+ * Spawn the launcher process and wait for "Registry Launcher ready" in stderr.
32
+ *
33
+ * @param opts - Launcher options (env vars, registry URL, api keys path, etc.)
34
+ * @throws Error if the launcher fails to start or doesn't become ready within timeout.
35
+ */
36
+ start(opts?: LauncherOptions): Promise<void>;
37
+ /**
38
+ * Send an NDJSON message to the launcher's stdin.
39
+ *
40
+ * @param msg - Object to serialize as JSON and write to stdin.
41
+ * @throws Error if the launcher is not running.
42
+ */
43
+ sendMessage(msg: object): void;
44
+ /**
45
+ * Wait for a response with a matching `id` from stdout.
46
+ *
47
+ * Checks already-received responses first, then listens for new ones.
48
+ *
49
+ * @param id - The JSON-RPC request id to match.
50
+ * @param timeoutMs - Maximum time to wait in ms (default: 10000).
51
+ * @returns The parsed response object.
52
+ * @throws Error on timeout or if the launcher exits unexpectedly.
53
+ */
54
+ waitForResponse(id: string | number, timeoutMs?: number): Promise<object>;
55
+ /**
56
+ * Wait for a pattern to appear in stderr output.
57
+ *
58
+ * Checks already-collected stderr first, then listens for new data.
59
+ *
60
+ * @param pattern - String or RegExp to match against stderr.
61
+ * @param timeoutMs - Maximum time to wait in ms (default: 10000).
62
+ * @returns The matching stderr line or chunk.
63
+ * @throws Error on timeout.
64
+ */
65
+ waitForStderr(pattern: string | RegExp, timeoutMs?: number): Promise<string>;
66
+ /**
67
+ * Collect all responses from stdout for a given period.
68
+ *
69
+ * @param timeoutMs - Duration to collect responses in ms.
70
+ * @returns Array of all parsed response objects received during the period.
71
+ */
72
+ collectAllResponses(timeoutMs: number): Promise<object[]>;
73
+ /**
74
+ * Send SIGTERM and wait for process exit, then cleanup.
75
+ *
76
+ * @returns Object with the exit code (null if force-killed).
77
+ */
78
+ stop(): Promise<{
79
+ exitCode: number | null;
80
+ }>;
81
+ /**
82
+ * Get all stderr output collected so far.
83
+ *
84
+ * @returns The full stderr buffer as a string.
85
+ */
86
+ getStderr(): string;
87
+ /**
88
+ * Check if the launcher process is running.
89
+ *
90
+ * @returns true if the process is alive.
91
+ */
92
+ isRunning(): boolean;
93
+ /** Parse complete NDJSON lines from the stdout buffer. */
94
+ private parseStdoutLines;
95
+ /** Find an already-received response by id. */
96
+ private findResponse;
97
+ /** Check if a response object has a matching id. */
98
+ private matchesId;
99
+ /** Check if text matches a string or RegExp pattern. */
100
+ private matchesPattern;
101
+ }
@@ -0,0 +1,46 @@
1
+ /** Agent definition for the mock registry. */
2
+ export interface MockAgent {
3
+ /** Unique agent identifier */
4
+ id: string;
5
+ /** Human-readable agent name */
6
+ name: string;
7
+ /** Agent version */
8
+ version?: string;
9
+ /** Agent description */
10
+ description?: string;
11
+ /** Command to run the agent (e.g., 'node') */
12
+ cmd: string;
13
+ /** Arguments for the command (e.g., path to agent script) */
14
+ args: string[];
15
+ }
16
+ /**
17
+ * Mock HTTP server that serves an ACP registry JSON.
18
+ *
19
+ * Binds to 127.0.0.1 on a random port and serves the registry
20
+ * at any request path.
21
+ */
22
+ export declare class MockRegistryServer {
23
+ private server;
24
+ private port;
25
+ /**
26
+ * Start the HTTP server on a random port, serving the registry JSON.
27
+ *
28
+ * @param agents - Array of mock agent definitions to include in the registry.
29
+ * @returns The full URL to the registry JSON (e.g., `http://127.0.0.1:12345/registry.json`).
30
+ */
31
+ start(agents: MockAgent[]): Promise<string>;
32
+ /**
33
+ * Stop the server and release resources.
34
+ */
35
+ stop(): Promise<void>;
36
+ /**
37
+ * Get the URL of the mock registry.
38
+ *
39
+ * @returns URL in format `http://127.0.0.1:{port}/registry.json`.
40
+ */
41
+ getUrl(): string;
42
+ /**
43
+ * Build a valid ACP registry JSON from the provided agents.
44
+ */
45
+ private buildRegistryJson;
46
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * E2E tests for Agent Auth flow.
3
+ *
4
+ * Tests the complete Agent Auth flow:
5
+ * - initialize → AUTH_REQUIRED → authenticate → session/new success
6
+ *
7
+ * Uses mock-agent-auth.mjs which simulates an agent that requires Agent Auth.
8
+ */
9
+ export {};
@@ -0,0 +1,12 @@
1
+ /**
2
+ * E2E tests for Terminal Auth flow.
3
+ *
4
+ * Tests the complete Terminal Auth flow:
5
+ * - initialize → AUTH_REQUIRED → spawn with args → session/new success
6
+ *
7
+ * Uses mock-agent-terminal.mjs which simulates an agent that requires Terminal Auth.
8
+ *
9
+ * Note: These tests require TTY environment to run Terminal Auth.
10
+ * In CI/non-TTY environments, Terminal Auth should fail gracefully.
11
+ */
12
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdiobus/workers-registry",
3
- "version": "1.4.14",
3
+ "version": "1.5.0-beta.2",
4
4
  "description": "Worker implementations for stdio Bus kernel - ACP, MCP, and protocol bridges",
5
5
  "type": "module",
6
6
  "main": "./out/dist/workers-registry/acp-registry/index.js",
@@ -22,17 +22,21 @@
22
22
  "import": "./out/dist/workers-registry/acp-worker/agent.js",
23
23
  "types": "./out/tsc/workers-registry/acp-worker/src/agent.d.ts"
24
24
  },
25
- "./workers/acp-worker/registry": {
26
- "import": "./out/dist/workers-registry/acp-worker/registry-launcher/registry/index.js",
27
- "types": "./out/tsc/workers-registry/acp-worker/src/registry-launcher/registry/index.d.ts"
25
+ "./workers/registry-launcher": {
26
+ "import": "./out/dist/workers-registry/registry-launcher/index.js",
27
+ "types": "./out/tsc/workers-registry/registry-launcher/src/index.d.ts"
28
28
  },
29
- "./workers/acp-worker/runtime": {
30
- "import": "./out/dist/workers-registry/acp-worker/registry-launcher/runtime/manager.js",
31
- "types": "./out/tsc/workers-registry/acp-worker/src/registry-launcher/runtime/manager.d.ts"
29
+ "./workers/registry-launcher/registry": {
30
+ "import": "./out/dist/workers-registry/registry-launcher/registry/index.js",
31
+ "types": "./out/tsc/workers-registry/registry-launcher/src/registry/index.d.ts"
32
32
  },
33
- "./workers/acp-worker/config": {
34
- "import": "./out/dist/workers-registry/acp-worker/registry-launcher/config/config.js",
35
- "types": "./out/tsc/workers-registry/acp-worker/src/registry-launcher/config/config.d.ts"
33
+ "./workers/registry-launcher/runtime": {
34
+ "import": "./out/dist/workers-registry/registry-launcher/runtime/manager.js",
35
+ "types": "./out/tsc/workers-registry/registry-launcher/src/runtime/manager.d.ts"
36
+ },
37
+ "./workers/registry-launcher/config": {
38
+ "import": "./out/dist/workers-registry/registry-launcher/config/config.js",
39
+ "types": "./out/tsc/workers-registry/registry-launcher/src/config/config.d.ts"
36
40
  },
37
41
  "./workers/acp-worker/mcp": {
38
42
  "import": "./out/dist/workers-registry/acp-worker/mcp/manager.js",
@@ -98,6 +102,7 @@
98
102
  "@modelcontextprotocol/sdk": "^1.27.1"
99
103
  },
100
104
  "devDependencies": {
105
+ "@stdiobus/node": "^0.1.0",
101
106
  "@types/jest": "^29.5.0",
102
107
  "@types/node": "^20.0.0",
103
108
  "esbuild": "^0.20.0",
@@ -107,4 +112,4 @@
107
112
  "tsc-alias": "^1.8.16",
108
113
  "typescript": "^5.0.0"
109
114
  }
110
- }
115
+ }
@@ -1,199 +0,0 @@
1
- /**
2
- * Message Router for the Registry Launcher.
3
- *
4
- * Routes incoming JSON-RPC messages to the appropriate agent based on agentId.
5
- * Handles agentId extraction, message transformation, and error response generation.
6
- *
7
- * @module router/message-router
8
- */
9
- import type { IRegistryIndex } from '../registry/index.js';
10
- import type { AgentRuntimeManager } from '../runtime/manager.js';
11
- /**
12
- * JSON-RPC error codes for routing errors.
13
- */
14
- export declare const RoutingErrorCodes: {
15
- /** Missing agentId in request */
16
- readonly MISSING_AGENT_ID: -32600;
17
- /** Agent not found in registry */
18
- readonly AGENT_NOT_FOUND: -32001;
19
- /** Platform not supported for binary distribution */
20
- readonly PLATFORM_NOT_SUPPORTED: -32002;
21
- /** Agent spawn failed */
22
- readonly SPAWN_FAILED: -32003;
23
- };
24
- /**
25
- * JSON-RPC error response structure.
26
- */
27
- export interface ErrorResponse {
28
- jsonrpc: '2.0';
29
- id: string | number | null;
30
- error: {
31
- code: number;
32
- message: string;
33
- data?: unknown;
34
- };
35
- }
36
- /**
37
- * Callback type for writing responses to stdout.
38
- */
39
- export type WriteCallback = (message: object) => boolean;
40
- /**
41
- * Create a JSON-RPC error response.
42
- *
43
- * @param id - Request ID (null for notifications or unknown)
44
- * @param code - Error code
45
- * @param message - Error message
46
- * @param data - Optional additional error data
47
- * @returns Error response object
48
- */
49
- export declare function createErrorResponse(id: string | number | null, code: number, message: string, data?: unknown): ErrorResponse;
50
- /**
51
- * Extract the agentId field from a message.
52
- *
53
- * @param message - The message object to extract from
54
- * @returns The agentId string or undefined if not present
55
- */
56
- export declare function extractAgentId(message: object): string | undefined;
57
- /**
58
- * Extract the JSON-RPC id field from a message.
59
- *
60
- * @param message - The message object to extract from
61
- * @returns The id (string, number, or null)
62
- */
63
- export declare function extractId(message: object): string | number | null;
64
- /**
65
- * Transform a message for forwarding to an agent.
66
- *
67
- * Removes the agentId field while preserving all other fields.
68
- *
69
- * @param message - The original message
70
- * @returns A new message object without the agentId field
71
- */
72
- export declare function transformMessage(message: object): object;
73
- /**
74
- * Message Router implementation.
75
- *
76
- * Routes incoming JSON-RPC messages to the appropriate agent based on agentId.
77
- * Handles message transformation, error generation, and request correlation.
78
- */
79
- export declare class MessageRouter {
80
- /** Registry index for agent lookup and resolution */
81
- private readonly registry;
82
- /** Runtime manager for agent process lifecycle */
83
- private readonly runtimeManager;
84
- /** Callback for writing responses to stdout */
85
- private readonly writeCallback;
86
- /** API keys for agent authentication */
87
- private readonly apiKeys;
88
- /** Map of request ID to pending request info for correlation */
89
- private readonly pendingRequests;
90
- /** Map of agent ID to authentication state */
91
- private readonly authState;
92
- /** Map of agent sessionId to client sessionId for notification routing */
93
- private readonly sessionIdMap;
94
- /**
95
- * Create a new MessageRouter.
96
- *
97
- * @param registry - Registry index for agent lookup
98
- * @param runtimeManager - Runtime manager for agent processes
99
- * @param writeCallback - Callback for writing responses to stdout
100
- * @param apiKeys - API keys for agent authentication (optional)
101
- */
102
- constructor(registry: IRegistryIndex, runtimeManager: AgentRuntimeManager, writeCallback: WriteCallback, apiKeys?: Record<string, any>);
103
- /**
104
- * Inject mcpServers from registry into session/new request params.
105
- *
106
- * If the agent has mcpServers configured in the registry, they are merged
107
- * with any mcpServers already present in the request params.
108
- * Registry servers are added first, then request servers (request takes precedence for duplicates).
109
- *
110
- * @param message - The transformed message (without agentId)
111
- * @param agentId - The agent ID to look up in registry
112
- * @returns Message with mcpServers injected into params
113
- */
114
- private injectMcpServers;
115
- /**
116
- * Route an incoming message to the appropriate agent.
117
- *
118
- * Extracts agentId, resolves spawn command, and forwards message.
119
- *
120
- * @param message - The incoming JSON-RPC message
121
- * @returns Error response if routing fails, undefined on success
122
- */
123
- route(message: object): Promise<ErrorResponse | undefined>;
124
- /**
125
- * Handle a response from an agent process.
126
- *
127
- * Intercepts initialize responses to trigger automatic authentication.
128
- * Handles agent-to-client requests (like session/request_permission) by
129
- * auto-responding when they cannot be forwarded to the client.
130
- * Tracks sessionId mapping for proper notification routing.
131
- * Forwards all responses to stdout.
132
- *
133
- * @param agentId - The agent that sent the response
134
- * @param response - The response object from the agent
135
- */
136
- handleAgentResponse(agentId: string, response: object): void;
137
- /**
138
- * Handle a request from an agent to the client.
139
- *
140
- * Agent-to-client requests (JSON-RPC messages with both `id` and `method`)
141
- * require a response. Since the Registry Launcher is headless and cannot
142
- * forward these to a human, we auto-respond to keep the agent unblocked.
143
- *
144
- * Known methods:
145
- * - session/request_permission: Auto-approve with the first "allow" option
146
- *
147
- * Unknown methods get a generic success response so the agent continues.
148
- *
149
- * @param agentId - The agent that sent the request
150
- * @param id - The JSON-RPC request id
151
- * @param method - The JSON-RPC method name
152
- * @param msg - The full message object
153
- */
154
- private handleAgentRequest;
155
- /**
156
- * Build an auto-approve result for session/request_permission.
157
- *
158
- * Picks the first "allow" option from the request, preferring
159
- * allow_always > allow_once > first option as fallback.
160
- *
161
- * @param msg - The request_permission message
162
- * @returns The result object for the response
163
- */
164
- private buildPermissionResponse;
165
- /**
166
- * Send a JSON-RPC message directly to an agent process.
167
- *
168
- * @param agentId - The agent to send to
169
- * @param message - The message to send
170
- */
171
- private sendToAgent;
172
- /**
173
- * Attempt automatic authentication for an agent.
174
- *
175
- * Selects the best authentication method and sends authenticate request.
176
- *
177
- * @param agentId - The agent to authenticate
178
- * @param authMethods - Available authentication methods from initialize response
179
- */
180
- private attemptAuthentication;
181
- /**
182
- * Get the number of pending requests.
183
- *
184
- * @returns The count of pending requests
185
- */
186
- get pendingCount(): number;
187
- /**
188
- * Check if a request ID is pending.
189
- *
190
- * @param id - The request ID to check
191
- * @returns true if the request is pending, false otherwise
192
- */
193
- isPending(id: string | number): boolean;
194
- /**
195
- * Clear all pending requests.
196
- * Useful for cleanup during shutdown.
197
- */
198
- clearPending(): void;
199
- }