maritime-cli 1.6.1 → 1.7.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/AGENTS.md +24 -24
- package/dist/api.js +6 -1
- package/dist/commands/blueprint.js +4 -4
- package/dist/commands/chat.js +9 -2
- package/dist/commands/create.js +8 -13
- package/dist/commands/deploy.js +49 -17
- package/dist/commands/env.js +4 -4
- package/dist/commands/exec.js +4 -1
- package/dist/commands/guide.js +4 -4
- package/dist/commands/history.js +1 -1
- package/dist/commands/info.js +0 -1
- package/dist/commands/init.js +1 -6
- package/dist/commands/keys.js +3 -3
- package/dist/commands/list.js +0 -2
- package/dist/commands/login.js +12 -7
- package/dist/commands/logs.js +29 -20
- package/dist/commands/message.js +2 -2
- package/dist/commands/open.js +2 -1
- package/dist/commands/scale.js +5 -3
- package/dist/commands/signup.js +4 -2
- package/dist/commands/status.js +0 -1
- package/dist/commands/whoami.js +3 -2
- package/dist/context.d.ts +2 -4
- package/dist/context.js +2 -2
- package/dist/index.js +65 -23
- package/dist/interactive.js +2 -3
- package/dist/output.d.ts +19 -2
- package/dist/output.js +30 -3
- package/dist/prompt.js +4 -0
- package/dist/resolve.d.ts +0 -1
- package/dist/version-check.d.ts +12 -2
- package/dist/version-check.js +30 -8
- package/dist/websocket.d.ts +9 -0
- package/dist/websocket.js +42 -8
- package/package.json +2 -2
package/dist/websocket.d.ts
CHANGED
|
@@ -9,5 +9,14 @@ export interface WsOptions {
|
|
|
9
9
|
/**
|
|
10
10
|
* Connect to a Maritime WebSocket endpoint with auth token.
|
|
11
11
|
* Returns a cleanup function that closes the connection.
|
|
12
|
+
*
|
|
13
|
+
* Teardown rules (Windows-safe: no handle may outlive the command):
|
|
14
|
+
* - a pending reconnect timer is cleared on cleanup;
|
|
15
|
+
* - CONNECTING sockets are terminated, not orphaned;
|
|
16
|
+
* - a server close with code 1000 is final (the deploy-status endpoint
|
|
17
|
+
* closes with 1000 on terminal status): reconnecting would just replay
|
|
18
|
+
* the terminal frame and burn the backoff;
|
|
19
|
+
* - the SIGINT listener is removed as soon as the connection is done,
|
|
20
|
+
* whether via cleanup() or the server ending the stream.
|
|
12
21
|
*/
|
|
13
22
|
export declare function connectWs(path: string, opts: WsOptions): () => void;
|
package/dist/websocket.js
CHANGED
|
@@ -4,6 +4,15 @@ import { getApiUrl, requireAuth } from './api.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Connect to a Maritime WebSocket endpoint with auth token.
|
|
6
6
|
* Returns a cleanup function that closes the connection.
|
|
7
|
+
*
|
|
8
|
+
* Teardown rules (Windows-safe: no handle may outlive the command):
|
|
9
|
+
* - a pending reconnect timer is cleared on cleanup;
|
|
10
|
+
* - CONNECTING sockets are terminated, not orphaned;
|
|
11
|
+
* - a server close with code 1000 is final (the deploy-status endpoint
|
|
12
|
+
* closes with 1000 on terminal status): reconnecting would just replay
|
|
13
|
+
* the terminal frame and burn the backoff;
|
|
14
|
+
* - the SIGINT listener is removed as soon as the connection is done,
|
|
15
|
+
* whether via cleanup() or the server ending the stream.
|
|
7
16
|
*/
|
|
8
17
|
export function connectWs(path, opts) {
|
|
9
18
|
const token = requireAuth();
|
|
@@ -13,23 +22,32 @@ export function connectWs(path, opts) {
|
|
|
13
22
|
const maxReconnects = opts.maxReconnects ?? 2;
|
|
14
23
|
let reconnects = 0;
|
|
15
24
|
let closed = false;
|
|
25
|
+
let finished = false;
|
|
26
|
+
let reconnectTimer;
|
|
16
27
|
let ws;
|
|
28
|
+
function finish() {
|
|
29
|
+
if (finished)
|
|
30
|
+
return;
|
|
31
|
+
finished = true;
|
|
32
|
+
process.removeListener('SIGINT', sigHandler);
|
|
33
|
+
opts.onClose?.();
|
|
34
|
+
}
|
|
17
35
|
function connect() {
|
|
18
36
|
ws = new WebSocket(url);
|
|
19
37
|
ws.on('message', (raw) => {
|
|
20
38
|
opts.onMessage(raw.toString());
|
|
21
39
|
});
|
|
22
|
-
ws.on('close', () => {
|
|
23
|
-
if (closed) {
|
|
24
|
-
|
|
40
|
+
ws.on('close', (code) => {
|
|
41
|
+
if (closed || code === 1000) {
|
|
42
|
+
finish();
|
|
25
43
|
return;
|
|
26
44
|
}
|
|
27
45
|
if (reconnects < maxReconnects) {
|
|
28
46
|
reconnects++;
|
|
29
|
-
setTimeout(connect, 1000 * reconnects);
|
|
47
|
+
reconnectTimer = setTimeout(connect, 1000 * reconnects);
|
|
30
48
|
}
|
|
31
49
|
else {
|
|
32
|
-
|
|
50
|
+
finish();
|
|
33
51
|
}
|
|
34
52
|
});
|
|
35
53
|
ws.on('error', (err) => {
|
|
@@ -46,9 +64,25 @@ export function connectWs(path, opts) {
|
|
|
46
64
|
process.on('SIGINT', sigHandler);
|
|
47
65
|
function cleanup() {
|
|
48
66
|
closed = true;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
67
|
+
if (reconnectTimer) {
|
|
68
|
+
clearTimeout(reconnectTimer);
|
|
69
|
+
reconnectTimer = undefined;
|
|
70
|
+
// No socket is open when a reconnect was pending; end the stream now.
|
|
71
|
+
finish();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (ws) {
|
|
75
|
+
if (ws.readyState === WebSocket.OPEN) {
|
|
76
|
+
ws.close();
|
|
77
|
+
}
|
|
78
|
+
else if (ws.readyState === WebSocket.CONNECTING) {
|
|
79
|
+
// close() during the handshake leaves the socket to finish
|
|
80
|
+
// connecting in the background; terminate() drops it now.
|
|
81
|
+
ws.terminate();
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
finish();
|
|
85
|
+
}
|
|
52
86
|
}
|
|
53
87
|
}
|
|
54
88
|
return cleanup;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "maritime-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Maritime CLI - Deploy and talk to AI agents from your terminal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"AGENTS.md"
|
|
25
25
|
],
|
|
26
26
|
"engines": {
|
|
27
|
-
"node": ">=
|
|
27
|
+
"node": ">=20.12"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build": "tsc && chmod +x dist/index.js",
|