@essentialai/cogent-bridge 1.3.5 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/LICENSE +187 -12
- package/README.md +16 -2
- package/dist/services/auto-relay.d.ts +20 -1
- package/dist/services/auto-relay.d.ts.map +1 -1
- package/dist/services/auto-relay.js +58 -4
- package/dist/services/auto-relay.js.map +1 -1
- package/dist/tools/send-message.d.ts.map +1 -1
- package/dist/tools/send-message.js +46 -15
- package/dist/tools/send-message.js.map +1 -1
- package/package.json +6 -4
- package/server.json +3 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [2.0.0] - 2026-02-25
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- Cloud mode: connect to cogent.tools relay server for cross-machine communication
|
|
7
|
+
- HttpBackend for REST API integration with cloud relay
|
|
8
|
+
- WebSocket client for real-time message push with reconnection
|
|
9
|
+
- Session create/join tools for cloud session management
|
|
10
|
+
- Auto-relay: send-message blocks until response arrives in cloud mode
|
|
11
|
+
- Label-based session joining with auto-generated human-readable labels
|
|
12
|
+
- Interactive setup wizard (`cogent-bridge init`)
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
- Transport abstraction: StorageBackend interface with FileBackend (local) and HttpBackend (cloud)
|
|
16
|
+
- License changed from ISC to Apache 2.0
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
- Cloud message delivery reliability via auto-relay service
|
|
20
|
+
- Session isolation between concurrent cloud sessions
|
package/LICENSE
CHANGED
|
@@ -1,15 +1,190 @@
|
|
|
1
|
-
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
-
copyright notice and this permission notice appear in all copies.
|
|
7
|
+
1. Definitions.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding any notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2025-2026 Essential AI Solutions Ltd.
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# @essentialai/cogent-bridge
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@essentialai/cogent-bridge)
|
|
4
|
+
[](https://www.npmjs.com/package/@essentialai/cogent-bridge)
|
|
5
|
+
[](https://www.npmjs.com/package/@essentialai/cogent-bridge)
|
|
6
|
+
|
|
7
|
+
MCP server for inter-Claude-Code session communication. Two Claude Code instances can exchange messages while staying fully isolated in their own repositories -- locally via shared files or across machines via [cogent.tools](https://cogent.tools) cloud relay.
|
|
4
8
|
|
|
5
9
|
## Quick Start
|
|
6
10
|
|
|
@@ -306,6 +310,16 @@ src/
|
|
|
306
310
|
| `npm run test:watch` | `vitest` | Run tests in watch mode |
|
|
307
311
|
| `npm run test:coverage` | `vitest run --coverage` | Run tests with coverage report |
|
|
308
312
|
|
|
313
|
+
## Related Packages
|
|
314
|
+
|
|
315
|
+
- [@essentialai/cogent](https://www.npmjs.com/package/@essentialai/cogent) -- Shared types, Zod schemas, and error codes
|
|
316
|
+
- [@essentialai/cogent-server](https://www.npmjs.com/package/@essentialai/cogent-server) -- Cloud relay server
|
|
317
|
+
|
|
318
|
+
## Links
|
|
319
|
+
|
|
320
|
+
- [cogent.tools](https://cogent.tools) -- Public cloud relay server
|
|
321
|
+
- [GitHub](https://github.com/eaisdevelopment/cogent)
|
|
322
|
+
|
|
309
323
|
## License
|
|
310
324
|
|
|
311
|
-
|
|
325
|
+
Apache-2.0
|
|
@@ -6,6 +6,7 @@ export declare class AutoRelayService {
|
|
|
6
6
|
private processing;
|
|
7
7
|
private queue;
|
|
8
8
|
private expectingResponseFrom;
|
|
9
|
+
private responseWaiters;
|
|
9
10
|
/**
|
|
10
11
|
* Set the local peer info. Called from register-peer tool after
|
|
11
12
|
* successful registration so we know which session to inject into.
|
|
@@ -19,9 +20,27 @@ export declare class AutoRelayService {
|
|
|
19
20
|
*/
|
|
20
21
|
expectResponse(fromPeerId: string): void;
|
|
21
22
|
/**
|
|
22
|
-
*
|
|
23
|
+
* Wait for a response from a peer. Returns a Promise that resolves with
|
|
24
|
+
* the response message content when the target peer responds.
|
|
25
|
+
*
|
|
26
|
+
* This is the key mechanism that makes cloud mode behave like local mode:
|
|
27
|
+
* send-message calls this before sending, then awaits the Promise.
|
|
28
|
+
* When the response arrives via WS, the Promise resolves with the actual
|
|
29
|
+
* response text, which send-message returns as the tool result.
|
|
30
|
+
*
|
|
31
|
+
* On timeout, the Promise rejects but the expectation is kept in
|
|
32
|
+
* expectingResponseFrom so late responses still get inject-only treatment
|
|
33
|
+
* (preventing infinite auto-relay loops).
|
|
34
|
+
*/
|
|
35
|
+
waitForResponse(fromPeerId: string, timeoutMs: number): Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Clear the expectation for a peer and cancel any pending waiter.
|
|
23
38
|
*/
|
|
24
39
|
clearExpectation(fromPeerId: string): void;
|
|
40
|
+
/**
|
|
41
|
+
* Cancel a pending response waiter for a peer.
|
|
42
|
+
*/
|
|
43
|
+
private _cancelWaiter;
|
|
25
44
|
/**
|
|
26
45
|
* Process an incoming cloud message by invoking local execClaude()
|
|
27
46
|
* and relaying the response back to the sender.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-relay.d.ts","sourceRoot":"","sources":["../../src/services/auto-relay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAqD5C,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,cAAc,CAAuB;IAC7C,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,qBAAqB,CAA0B;
|
|
1
|
+
{"version":3,"file":"auto-relay.d.ts","sourceRoot":"","sources":["../../src/services/auto-relay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAqD5C,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,cAAc,CAAuB;IAC7C,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,qBAAqB,CAA0B;IACvD,OAAO,CAAC,eAAe,CAGR;IAEf;;;OAGG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;IAOlE;;;;;OAKG;IACH,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAKxC;;;;;;;;;;;;OAYG;IACH,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAiBvE;;OAEG;IACH,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAK1C;;OAEG;IACH,OAAO,CAAC,aAAa;IAQrB;;;;;;;;;;OAUG;IACG,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAsEvD;;OAEG;YACW,eAAe;IA2D7B;;;OAGG;YACW,WAAW;IAgCzB;;OAEG;IACH,IAAI,IAAI,IAAI;CAeb;AAED,0DAA0D;AAC1D,eAAO,MAAM,SAAS,kBAAyB,CAAC"}
|
|
@@ -42,6 +42,7 @@ export class AutoRelayService {
|
|
|
42
42
|
processing = false;
|
|
43
43
|
queue = [];
|
|
44
44
|
expectingResponseFrom = new Set();
|
|
45
|
+
responseWaiters = new Map();
|
|
45
46
|
/**
|
|
46
47
|
* Set the local peer info. Called from register-peer tool after
|
|
47
48
|
* successful registration so we know which session to inject into.
|
|
@@ -63,10 +64,48 @@ export class AutoRelayService {
|
|
|
63
64
|
logger.debug(`Auto-relay: expecting response from ${fromPeerId} (will inject-only)`);
|
|
64
65
|
}
|
|
65
66
|
/**
|
|
66
|
-
*
|
|
67
|
+
* Wait for a response from a peer. Returns a Promise that resolves with
|
|
68
|
+
* the response message content when the target peer responds.
|
|
69
|
+
*
|
|
70
|
+
* This is the key mechanism that makes cloud mode behave like local mode:
|
|
71
|
+
* send-message calls this before sending, then awaits the Promise.
|
|
72
|
+
* When the response arrives via WS, the Promise resolves with the actual
|
|
73
|
+
* response text, which send-message returns as the tool result.
|
|
74
|
+
*
|
|
75
|
+
* On timeout, the Promise rejects but the expectation is kept in
|
|
76
|
+
* expectingResponseFrom so late responses still get inject-only treatment
|
|
77
|
+
* (preventing infinite auto-relay loops).
|
|
78
|
+
*/
|
|
79
|
+
waitForResponse(fromPeerId, timeoutMs) {
|
|
80
|
+
return new Promise((resolve, reject) => {
|
|
81
|
+
// Clean up any existing waiter for this peer
|
|
82
|
+
this._cancelWaiter(fromPeerId);
|
|
83
|
+
const timer = setTimeout(() => {
|
|
84
|
+
this.responseWaiters.delete(fromPeerId);
|
|
85
|
+
// Keep expectingResponseFrom so late responses get inject-only treatment
|
|
86
|
+
reject(new Error(`Response timeout from ${fromPeerId} after ${timeoutMs}ms`));
|
|
87
|
+
}, timeoutMs);
|
|
88
|
+
this.responseWaiters.set(fromPeerId, { resolve, timer });
|
|
89
|
+
this.expectingResponseFrom.add(fromPeerId);
|
|
90
|
+
logger.debug(`Auto-relay: waiting for response from ${fromPeerId} (timeout: ${timeoutMs}ms)`);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Clear the expectation for a peer and cancel any pending waiter.
|
|
67
95
|
*/
|
|
68
96
|
clearExpectation(fromPeerId) {
|
|
69
97
|
this.expectingResponseFrom.delete(fromPeerId);
|
|
98
|
+
this._cancelWaiter(fromPeerId);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Cancel a pending response waiter for a peer.
|
|
102
|
+
*/
|
|
103
|
+
_cancelWaiter(fromPeerId) {
|
|
104
|
+
const existing = this.responseWaiters.get(fromPeerId);
|
|
105
|
+
if (existing) {
|
|
106
|
+
clearTimeout(existing.timer);
|
|
107
|
+
this.responseWaiters.delete(fromPeerId);
|
|
108
|
+
}
|
|
70
109
|
}
|
|
71
110
|
/**
|
|
72
111
|
* Process an incoming cloud message by invoking local execClaude()
|
|
@@ -98,11 +137,21 @@ export class AutoRelayService {
|
|
|
98
137
|
return;
|
|
99
138
|
}
|
|
100
139
|
// Guard: we sent this peer an explicit message and are expecting their response.
|
|
101
|
-
//
|
|
102
|
-
//
|
|
140
|
+
// If there's an active waiter (send-message is blocking), resolve it with
|
|
141
|
+
// the response content. Otherwise fall back to inject-only mode.
|
|
103
142
|
if (this.expectingResponseFrom.has(msg.fromPeerId)) {
|
|
104
143
|
this.expectingResponseFrom.delete(msg.fromPeerId);
|
|
105
|
-
|
|
144
|
+
// Check if send-message is actively waiting for this response
|
|
145
|
+
const waiter = this.responseWaiters.get(msg.fromPeerId);
|
|
146
|
+
if (waiter) {
|
|
147
|
+
clearTimeout(waiter.timer);
|
|
148
|
+
this.responseWaiters.delete(msg.fromPeerId);
|
|
149
|
+
waiter.resolve(msg.message);
|
|
150
|
+
logger.info(`Auto-relay: response from ${msg.fromPeerId} delivered to waiting send-message`);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
// No active waiter (timed out or used expectResponse directly)
|
|
154
|
+
logger.info(`Auto-relay: inject-only response from ${msg.fromPeerId} (no active waiter)`);
|
|
106
155
|
await this._injectOnly(msg);
|
|
107
156
|
return;
|
|
108
157
|
}
|
|
@@ -220,6 +269,11 @@ export class AutoRelayService {
|
|
|
220
269
|
* Stop the auto-relay service: clear queue and reset state.
|
|
221
270
|
*/
|
|
222
271
|
stop() {
|
|
272
|
+
// Cancel all pending response waiters
|
|
273
|
+
for (const [, waiter] of this.responseWaiters) {
|
|
274
|
+
clearTimeout(waiter.timer);
|
|
275
|
+
}
|
|
276
|
+
this.responseWaiters.clear();
|
|
223
277
|
this.queue = [];
|
|
224
278
|
this.localPeerId = null;
|
|
225
279
|
this.localSessionId = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-relay.js","sourceRoot":"","sources":["../../src/services/auto-relay.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;;;GAGG;AACH,SAAS,kBAAkB,CACzB,SAAiB,EACjB,UAAkB,EAClB,OAAe;IAEf,OAAO,CACL,+BAA+B,SAAS,KAAK,UAAU,QAAQ;QAC/D,GAAG,OAAO,MAAM;QAChB,OAAO;QACP,uFAAuF,SAAS,IAAI;QACpG,4EAA4E,CAC7E,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH;;;GAGG;AACH,SAAS,uBAAuB,CAC9B,SAAiB,EACjB,UAAkB,EAClB,OAAe;IAEf,OAAO,CACL,iCAAiC,SAAS,KAAK,UAAU,QAAQ;QACjE,GAAG,OAAO,MAAM;QAChB,OAAO;QACP,uFAAuF;QACvF,8DAA8D,CAC/D,CAAC;AACJ,CAAC;AAED,MAAM,OAAO,gBAAgB;IACnB,WAAW,GAAkB,IAAI,CAAC;IAClC,cAAc,GAAkB,IAAI,CAAC;IACrC,QAAQ,GAAkB,IAAI,CAAC;IAC/B,UAAU,GAAY,KAAK,CAAC;IAC5B,KAAK,GAAoB,EAAE,CAAC;IAC5B,qBAAqB,GAAgB,IAAI,GAAG,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"auto-relay.js","sourceRoot":"","sources":["../../src/services/auto-relay.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;;;GAGG;AACH,SAAS,kBAAk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AAM,CAAC,EAAE,MAAM,CAAC,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YAC9C,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;QAE7B,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;QACnC,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACrC,CAAC;CACF;AAED,0DAA0D;AAC1D,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,gBAAgB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-message.d.ts","sourceRoot":"","sources":["../../src/tools/send-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAoBpE,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"send-message.d.ts","sourceRoot":"","sources":["../../src/tools/send-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAoBpE,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAyL/D"}
|
|
@@ -81,31 +81,62 @@ export function registerSendMessageTool(server) {
|
|
|
81
81
|
logger.error("Failed to update lastSeenAt for target", { error: e });
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
//
|
|
85
|
-
//
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
84
|
+
// Cloud mode: wait for the actual response from the target peer.
|
|
85
|
+
// This makes cloud mode behave like local mode -- the tool blocks
|
|
86
|
+
// until the response arrives (or times out), then returns it.
|
|
87
|
+
if (isCloud && success) {
|
|
88
|
+
// Set up response waiter BEFORE sending to avoid race condition
|
|
89
|
+
const responsePromise = autoRelay.waitForResponse(toPeerId, config.COGENT_TIMEOUT_MS);
|
|
90
|
+
// Send message via cloud relay
|
|
91
|
+
try {
|
|
92
|
+
await backend.recordMessage({
|
|
93
|
+
fromPeerId,
|
|
94
|
+
toPeerId,
|
|
95
|
+
message,
|
|
96
|
+
response: null,
|
|
97
|
+
durationMs,
|
|
98
|
+
success: true,
|
|
99
|
+
error: null,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
catch (recordErr) {
|
|
103
|
+
autoRelay.clearExpectation(toPeerId);
|
|
104
|
+
throw recordErr;
|
|
105
|
+
}
|
|
106
|
+
// Wait for the response from the target peer's auto-relay
|
|
107
|
+
try {
|
|
108
|
+
const cloudResponse = await responsePromise;
|
|
109
|
+
return successResult({
|
|
110
|
+
success: true,
|
|
111
|
+
response: cloudResponse,
|
|
112
|
+
error: null,
|
|
113
|
+
durationMs: Date.now() - startMs,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return successResult({
|
|
118
|
+
success: true,
|
|
119
|
+
response: `Message delivered to ${to.label} (${toPeerId}) via cloud relay ` +
|
|
120
|
+
`but response timed out after ${Math.round(config.COGENT_TIMEOUT_MS / 1000)}s. ` +
|
|
121
|
+
`Check cogent_get_history for their reply.`,
|
|
122
|
+
error: null,
|
|
123
|
+
durationMs: Date.now() - startMs,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// Local mode: record with synchronous response from execClaude
|
|
91
128
|
await backend.recordMessage({
|
|
92
129
|
fromPeerId,
|
|
93
130
|
toPeerId,
|
|
94
131
|
message,
|
|
95
|
-
response:
|
|
132
|
+
response: success ? result.stdout : null,
|
|
96
133
|
durationMs,
|
|
97
134
|
success,
|
|
98
135
|
error: success ? null : result.stderr,
|
|
99
136
|
});
|
|
100
|
-
// In cloud mode, tell auto-relay to expect the response from this peer.
|
|
101
|
-
// When it arrives via WS, it will be injected into our session but NOT
|
|
102
|
-
// relayed back, preventing the infinite auto-relay loop.
|
|
103
|
-
if (isCloud && success) {
|
|
104
|
-
autoRelay.expectResponse(toPeerId);
|
|
105
|
-
}
|
|
106
137
|
return successResult({
|
|
107
138
|
success,
|
|
108
|
-
response:
|
|
139
|
+
response: success ? result.stdout : null,
|
|
109
140
|
error: success ? null : result.stderr,
|
|
110
141
|
durationMs,
|
|
111
142
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-message.js","sourceRoot":"","sources":["../../src/tools/send-message.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEhC,SAAS,mBAAmB,CAAC,SAAiB,EAAE,UAAkB,EAAE,OAAe;IACjF,OAAO,CACL,+BAA+B,SAAS,KAAK,UAAU,QAAQ;QAC/D,GAAG,OAAO,MAAM;QAChB,OAAO;QACP,uFAAuF,SAAS,IAAI;QACpG,4EAA4E,CAC7E,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,MAAiB;IACvD,MAAM,CAAC,YAAY,CACjB,qBAAqB,EACrB;QACE,KAAK,EAAE,sBAAsB;QAC7B,WAAW,E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C;gBAED,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;YACpD,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@essentialai/cogent-bridge",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "MCP server for inter-Claude-Code session communication bridge",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"dist",
|
|
13
13
|
"README.md",
|
|
14
14
|
"LICENSE",
|
|
15
|
+
"CHANGELOG.md",
|
|
15
16
|
"server.json"
|
|
16
17
|
],
|
|
17
18
|
"scripts": {
|
|
@@ -21,8 +22,9 @@
|
|
|
21
22
|
"clean": "rm -rf dist",
|
|
22
23
|
"test": "node node_modules/vitest/vitest.mjs run",
|
|
23
24
|
"test:watch": "node node_modules/vitest/vitest.mjs",
|
|
25
|
+
"test:unit": "node node_modules/vitest/vitest.mjs run --exclude 'src/e2e/**'",
|
|
24
26
|
"test:coverage": "node node_modules/vitest/vitest.mjs run --coverage",
|
|
25
|
-
"prepublishOnly": "npm run build && npm test"
|
|
27
|
+
"prepublishOnly": "npm run build && npm run test:unit"
|
|
26
28
|
},
|
|
27
29
|
"keywords": [
|
|
28
30
|
"mcp",
|
|
@@ -46,7 +48,7 @@
|
|
|
46
48
|
"url": "https://github.com/eaisdevelopment/cogent/issues"
|
|
47
49
|
},
|
|
48
50
|
"author": "Pavlo Sidelov <pavlo@essentialai.uk>",
|
|
49
|
-
"license": "
|
|
51
|
+
"license": "Apache-2.0",
|
|
50
52
|
"mcpName": "io.github.eaisdevelopment/cogent",
|
|
51
53
|
"publishConfig": {
|
|
52
54
|
"access": "public"
|
|
@@ -55,7 +57,7 @@
|
|
|
55
57
|
"node": ">=18"
|
|
56
58
|
},
|
|
57
59
|
"dependencies": {
|
|
58
|
-
"@essentialai/cogent": "^
|
|
60
|
+
"@essentialai/cogent": "^2.0.0",
|
|
59
61
|
"@modelcontextprotocol/sdk": "^1.6.1",
|
|
60
62
|
"ws": "^8.19.0",
|
|
61
63
|
"zod": "^3.23.8"
|
package/server.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "io.github.eaisdevelopment/cogent",
|
|
4
4
|
"title": "Cogent Bridge from Essential AI Solutions (essentialai.uk)",
|
|
5
5
|
"description": "MCP bridge for inter-session communication between Claude Code instances",
|
|
6
|
-
"version": "
|
|
6
|
+
"version": "2.0.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"url": "https://github.com/eaisdevelopment/cogent",
|
|
9
9
|
"source": "github"
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
{
|
|
13
13
|
"registryType": "npm",
|
|
14
14
|
"identifier": "@essentialai/cogent-bridge",
|
|
15
|
-
"version": "
|
|
15
|
+
"version": "2.0.0",
|
|
16
16
|
"runtimeHint": "npx",
|
|
17
17
|
"transport": {
|
|
18
18
|
"type": "stdio"
|
|
@@ -57,4 +57,4 @@
|
|
|
57
57
|
]
|
|
58
58
|
}
|
|
59
59
|
]
|
|
60
|
-
}
|
|
60
|
+
}
|