@open-wa/cli 5.0.0-alpha.8 → 5.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/LICENSE.md +2 -2
- package/README.md +1 -1
- package/dist/bin.cjs +7 -7
- package/dist/bin.d.cts +1 -1
- package/dist/{event-projection-store-BM9eOQXx.cjs → event-projection-store-DRXPBnNc.cjs} +23 -15
- package/dist/index.cjs +1 -2
- package/dist/index.d.cts +13 -13
- package/dist/index.d.cts.map +1 -1
- package/package.json +17 -11
- package/.open-wa/chrome-executable-path.json +0 -4
- package/.turbo/turbo-build.log +0 -16
- package/CHANGELOG.md +0 -79
- package/src/__tests__/cli-termination.test.ts +0 -50
- package/src/__tests__/event-projection-store.test.ts +0 -64
- package/src/__tests__/interactive-session.test.ts +0 -84
- package/src/__tests__/interactive-terminal.test.ts +0 -80
- package/src/__tests__/output-broker.test.ts +0 -66
- package/src/__tests__/output-mode.test.ts +0 -68
- package/src/__tests__/shutdown-controller.test.ts +0 -73
- package/src/bin.ts +0 -115
- package/src/config/cli-flags-schema.ts +0 -53
- package/src/index.ts +0 -7
- package/src/presenter/interactive-terminal.ts +0 -178
- package/src/runtime/cli-termination.ts +0 -66
- package/src/runtime/interactive-session.ts +0 -64
- package/src/runtime/output-broker.ts +0 -193
- package/src/runtime/output-mode.ts +0 -73
- package/src/runtime/shutdown-controller.ts +0 -86
- package/src/state/event-projection-store.ts +0 -166
- package/src/tunnel-client.ts +0 -169
- package/tsconfig.json +0 -23
- package/tsdown.config.ts +0 -8
package/LICENSE.md
CHANGED
|
@@ -55,9 +55,9 @@ Licensor hereby grants permission by this license ("License"), free of charge,
|
|
|
55
55
|
4. Compliance with Human Rights Laws and Human Rights Principles:
|
|
56
56
|
|
|
57
57
|
a. **Human Rights Laws**. The Software shall not be used by any person or entity for any systems, activities, or other uses that violate any applicable laws, regulations, or rules that protect human, civil, labor, privacy, political, environmental, security, economic, due process, or similar rights (the "Human Rights Laws"). Where the Human Rights Laws of more than one jurisdiction are applicable to the use of the Software, the Human Rights Laws that are most protective of the individuals or groups harmed shall apply.
|
|
58
|
-
|
|
58
|
+
|
|
59
59
|
b. **Human Rights Principles**. Licensee is advised to consult the articles of the United Nations Universal Declaration of Human Rights (https://www.un.org/en/universal-declaration-human-rights/) and the United Nations Global Compact (https://www.unglobalcompact.org/ what-is-gc/mission/principles) that define recognized principles of international human rights (the "Human Rights Principles"). It is Licensor's express intent that all use of the Software be consistent with Human Rights Principles. If Licensor receives notification or otherwise learns of an alleged violation of any Human Rights Principles relating to Licensee's use of the Software, Licensor may in its discretion and without obligation (i) (a) notify Licensee of such allegation and (b) allow Licensee 90 days from notification under (i)(a) to investigate and respond to Licensor regarding the allegation and (ii) (a) after the earlier of 90 days from notification under (i)(a), or Licensee's response under (i)(b), notify Licensee of License termination and (b) allow Licensee an additional 90 days from notification under (ii)(a) to cease use of the Software.
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
c. **Indemnity**. Licensee shall hold harmless and indemnify Licensor against all losses, damages, liabilities, deficiencies, claims, actions, judgments, settlements, interest, awards, penalties, fines, costs, or expenses of whatever kind, including Licensor's reasonable attorneys' fees, arising out of or relating to Licensee's non-compliance with this License or use of the Software in violation of Human Rights Laws or Human Rights Principles.
|
|
62
62
|
|
|
63
63
|
5. Enforceability: If any portion or provision of this License is determined to be invalid, illegal, or unenforceable by a court of competent jurisdiction, then such invalidity, illegality, or unenforceability shall not affect any other term or provision of this License or invalidate or render unenforceable such term or provision in any other jurisdiction. Upon a determination that any term or provision is invalid, illegal, or unenforceable, to the extent permitted by applicable law, the court may modify this License to affect the original intent of the parties as closely as possible. The section headings are for convenience only and are not intended to affect the construction or interpretation of this License. Any rule of construction to the effect that ambiguities are to be resolved against the drafting party shall not apply in interpreting this License. The language in this License shall be interpreted as to its fair meaning and not strictly for or against any party.
|
package/README.md
CHANGED
|
@@ -28,4 +28,4 @@ See the [CLI reference](https://openwa.dev/reference/cli) on our docs site.
|
|
|
28
28
|
|
|
29
29
|
## License
|
|
30
30
|
|
|
31
|
-
[H-DNH
|
|
31
|
+
[H-DNH 1.1](https://github.com/open-wa/wa-automate-nodejs/blob/master/LICENSE.md) — Hippocratic + Do Not Harm
|
package/dist/bin.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
2
|
//#region \0rolldown/runtime.js
|
|
4
3
|
var __create = Object.create;
|
|
5
4
|
var __defProp = Object.defineProperty;
|
|
@@ -17,19 +16,20 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
16
|
}
|
|
18
17
|
return to;
|
|
19
18
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
21
20
|
value: mod,
|
|
22
21
|
enumerable: true
|
|
23
22
|
}) : target, mod));
|
|
24
23
|
//#endregion
|
|
25
|
-
const require_event_projection_store = require("./event-projection-store-
|
|
24
|
+
const require_event_projection_store = require("./event-projection-store-DRXPBnNc.cjs");
|
|
26
25
|
let _open_wa_wa_automate = require("@open-wa/wa-automate");
|
|
27
26
|
let ws = require("ws");
|
|
28
|
-
ws = __toESM(ws);
|
|
27
|
+
ws = __toESM(ws, 1);
|
|
29
28
|
let qrcode = require("qrcode");
|
|
30
|
-
qrcode = __toESM(qrcode);
|
|
29
|
+
qrcode = __toESM(qrcode, 1);
|
|
31
30
|
//#region src/tunnel-client.ts
|
|
32
31
|
var TunnelClient = class {
|
|
32
|
+
options;
|
|
33
33
|
ws = null;
|
|
34
34
|
reconnectTimeout = null;
|
|
35
35
|
isDestroyed = false;
|
|
@@ -55,7 +55,8 @@ var TunnelClient = class {
|
|
|
55
55
|
if (this.isDestroyed) return;
|
|
56
56
|
let urlStr = this.options.proxyHost;
|
|
57
57
|
if (urlStr.startsWith("http")) urlStr = urlStr.replace(/^http/, "ws");
|
|
58
|
-
|
|
58
|
+
const connectUrl = `${urlStr}/sessions/${encodeURIComponent(this.options.sessionId)}/upstream?token=${encodeURIComponent(this.options.proxyToken)}`;
|
|
59
|
+
this.ws = new ws.default(connectUrl);
|
|
59
60
|
this.ws.on("open", () => {
|
|
60
61
|
this.log("info", `[TunnelClient] Connected upstream for session ${this.options.sessionId}`);
|
|
61
62
|
});
|
|
@@ -395,4 +396,3 @@ async function main() {
|
|
|
395
396
|
}
|
|
396
397
|
main();
|
|
397
398
|
//#endregion
|
|
398
|
-
exports.__toESM = __toESM;
|
package/dist/bin.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
require("./bin.cjs");
|
|
2
1
|
let zod = require("zod");
|
|
3
2
|
//#region src/config/cli-flags-schema.ts
|
|
4
3
|
const OutputModeOverrideSchema = zod.z.enum(["interactive", "plain"]);
|
|
@@ -86,20 +85,8 @@ var OutputBroker = class {
|
|
|
86
85
|
this.forward("error", "console", stringifyArgs(args), () => this.originalConsole?.error(...args));
|
|
87
86
|
};
|
|
88
87
|
if (this.interceptStreams) {
|
|
89
|
-
process.stdout.write = (
|
|
90
|
-
|
|
91
|
-
this.forward("info", "stdout", message, () => this.originalWrites?.stdout(chunk, encoding, callback));
|
|
92
|
-
if (this.interactive && !this.passthrough) if (typeof encoding === "function") encoding(void 0);
|
|
93
|
-
else callback?.(void 0);
|
|
94
|
-
return true;
|
|
95
|
-
});
|
|
96
|
-
process.stderr.write = ((chunk, encoding, callback) => {
|
|
97
|
-
const message = Buffer.isBuffer(chunk) ? chunk.toString("utf8") : String(chunk);
|
|
98
|
-
this.forward("error", "stderr", message, () => this.originalWrites?.stderr(chunk, encoding, callback));
|
|
99
|
-
if (this.interactive && !this.passthrough) if (typeof encoding === "function") encoding(void 0);
|
|
100
|
-
else callback?.(void 0);
|
|
101
|
-
return true;
|
|
102
|
-
});
|
|
88
|
+
process.stdout.write = this.createStreamInterceptor("info", "stdout", this.originalWrites.stdout);
|
|
89
|
+
process.stderr.write = this.createStreamInterceptor("error", "stderr", this.originalWrites.stderr);
|
|
103
90
|
}
|
|
104
91
|
}
|
|
105
92
|
dispose() {
|
|
@@ -133,6 +120,22 @@ var OutputBroker = class {
|
|
|
133
120
|
write(level, message, source = "runtime") {
|
|
134
121
|
this.forward(level, source, message);
|
|
135
122
|
}
|
|
123
|
+
createStreamInterceptor(level, source, originalWrite) {
|
|
124
|
+
const broker = this;
|
|
125
|
+
function write(chunk, encoding, callback) {
|
|
126
|
+
const message = Buffer.isBuffer(chunk) ? chunk.toString("utf8") : String(chunk);
|
|
127
|
+
broker.forward(level, source, message, () => {
|
|
128
|
+
if (typeof encoding === "function") originalWrite(chunk, encoding);
|
|
129
|
+
else originalWrite(chunk, encoding, callback);
|
|
130
|
+
});
|
|
131
|
+
if (broker.interactive && !broker.passthrough) {
|
|
132
|
+
if (typeof encoding === "function") encoding(void 0);
|
|
133
|
+
else callback?.(void 0);
|
|
134
|
+
}
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
return write;
|
|
138
|
+
}
|
|
136
139
|
forward(level, source, message, passthroughWriter) {
|
|
137
140
|
const entry = {
|
|
138
141
|
level,
|
|
@@ -183,6 +186,11 @@ async function performGracefulShutdown(state, signal) {
|
|
|
183
186
|
} catch (error) {
|
|
184
187
|
errors.push(normalizeError(error, "client.stop failed"));
|
|
185
188
|
}
|
|
189
|
+
if (runtime) try {
|
|
190
|
+
runtime.dispose();
|
|
191
|
+
} catch (error) {
|
|
192
|
+
errors.push(normalizeError(error, "runtime.dispose failed"));
|
|
193
|
+
}
|
|
186
194
|
store?.projectStatus({
|
|
187
195
|
phase: "shutdown.complete",
|
|
188
196
|
detail: `Shutdown completed after ${signal}`
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_event_projection_store = require("./event-projection-store-
|
|
3
|
-
require("./bin.cjs");
|
|
2
|
+
const require_event_projection_store = require("./event-projection-store-DRXPBnNc.cjs");
|
|
4
3
|
let _open_wa_wa_automate = require("@open-wa/wa-automate");
|
|
5
4
|
exports.CliShutdownError = require_event_projection_store.CliShutdownError;
|
|
6
5
|
exports.EventProjectionStore = require_event_projection_store.EventProjectionStore;
|
package/dist/index.d.cts
CHANGED
|
@@ -2,7 +2,6 @@ import { CliQrPayload, CliRuntimeResult, CliStatusUpdate, parseCliArgs, runCli a
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { HyperEmitter } from "@open-wa/hyperemitter";
|
|
4
4
|
import { OpenWAEventMap } from "@open-wa/core";
|
|
5
|
-
|
|
6
5
|
//#region src/config/cli-flags-schema.d.ts
|
|
7
6
|
declare const CliLocalFlagsSchema: z.ZodObject<{
|
|
8
7
|
outputMode: z.ZodOptional<z.ZodEnum<{
|
|
@@ -15,7 +14,7 @@ interface ParsedCliLocalFlags {
|
|
|
15
14
|
flags: CliLocalFlags;
|
|
16
15
|
forwardedArgs: string[];
|
|
17
16
|
}
|
|
18
|
-
declare function parseCliLocalFlags(argv: string[]): ParsedCliLocalFlags;
|
|
17
|
+
export declare function parseCliLocalFlags(argv: string[]): ParsedCliLocalFlags;
|
|
19
18
|
//#endregion
|
|
20
19
|
//#region src/runtime/output-broker.d.ts
|
|
21
20
|
type BrokerLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
@@ -33,7 +32,7 @@ interface OutputBrokerOptions {
|
|
|
33
32
|
interceptStreams?: boolean;
|
|
34
33
|
}
|
|
35
34
|
type Subscriber = (entry: BrokerEntry) => void;
|
|
36
|
-
declare class OutputBroker {
|
|
35
|
+
export declare class OutputBroker {
|
|
37
36
|
private readonly interactive;
|
|
38
37
|
private readonly maxEntries;
|
|
39
38
|
private readonly passthrough;
|
|
@@ -51,9 +50,10 @@ declare class OutputBroker {
|
|
|
51
50
|
writeRawStdout(message: string): void;
|
|
52
51
|
writeRawStderr(message: string): void;
|
|
53
52
|
write(level: BrokerLevel, message: string, source?: BrokerSource): void;
|
|
53
|
+
private createStreamInterceptor;
|
|
54
54
|
private forward;
|
|
55
55
|
}
|
|
56
|
-
declare function createOutputBroker(options: OutputBrokerOptions): OutputBroker;
|
|
56
|
+
export declare function createOutputBroker(options: OutputBrokerOptions): OutputBroker;
|
|
57
57
|
//#endregion
|
|
58
58
|
//#region src/state/event-projection-store.d.ts
|
|
59
59
|
interface ProjectionSnapshot {
|
|
@@ -72,7 +72,7 @@ interface EventProjectionStoreOptions {
|
|
|
72
72
|
eventDebounceMs?: number;
|
|
73
73
|
}
|
|
74
74
|
type ProjectionListener = (snapshot: ProjectionSnapshot) => void;
|
|
75
|
-
declare class EventProjectionStore {
|
|
75
|
+
export declare class EventProjectionStore {
|
|
76
76
|
private readonly maxLogs;
|
|
77
77
|
private readonly eventDebounceMs;
|
|
78
78
|
private readonly listeners;
|
|
@@ -90,7 +90,7 @@ declare class EventProjectionStore {
|
|
|
90
90
|
private scheduleFlush;
|
|
91
91
|
private emit;
|
|
92
92
|
}
|
|
93
|
-
declare function createEventProjectionStore(options?: EventProjectionStoreOptions): EventProjectionStore;
|
|
93
|
+
export declare function createEventProjectionStore(options?: EventProjectionStoreOptions): EventProjectionStore;
|
|
94
94
|
//#endregion
|
|
95
95
|
//#region src/runtime/cli-termination.d.ts
|
|
96
96
|
interface ShutdownRuntimeState {
|
|
@@ -100,11 +100,11 @@ interface ShutdownRuntimeState {
|
|
|
100
100
|
};
|
|
101
101
|
store?: EventProjectionStore;
|
|
102
102
|
}
|
|
103
|
-
declare class CliShutdownError extends AggregateError {
|
|
103
|
+
export declare class CliShutdownError extends AggregateError {
|
|
104
104
|
constructor(errors: Error[], signal: NodeJS.Signals);
|
|
105
105
|
}
|
|
106
|
-
declare function performGracefulShutdown(state: ShutdownRuntimeState, signal: NodeJS.Signals): Promise<void>;
|
|
107
|
-
declare function writeVisibleFatalError(message: string, writeRawStderr: (message: string) => void): void;
|
|
106
|
+
export declare function performGracefulShutdown(state: ShutdownRuntimeState, signal: NodeJS.Signals): Promise<void>;
|
|
107
|
+
export declare function writeVisibleFatalError(message: string, writeRawStderr: (message: string) => void): void;
|
|
108
108
|
//#endregion
|
|
109
109
|
//#region src/runtime/output-mode.d.ts
|
|
110
110
|
type OutputModeKind = 'interactive' | 'plain';
|
|
@@ -120,7 +120,7 @@ interface DetectOutputModeOptions {
|
|
|
120
120
|
stdout?: Pick<NodeJS.WriteStream, 'isTTY'>;
|
|
121
121
|
stderr?: Pick<NodeJS.WriteStream, 'isTTY'>;
|
|
122
122
|
}
|
|
123
|
-
declare function detectOutputMode(options?: DetectOutputModeOptions): OutputModeContract;
|
|
123
|
+
export declare function detectOutputMode(options?: DetectOutputModeOptions): OutputModeContract;
|
|
124
124
|
//#endregion
|
|
125
125
|
//#region src/runtime/shutdown-controller.d.ts
|
|
126
126
|
interface ShutdownControllerOptions {
|
|
@@ -129,7 +129,7 @@ interface ShutdownControllerOptions {
|
|
|
129
129
|
cleanup?: () => void | Promise<void>;
|
|
130
130
|
exit?: (code: number) => never | void;
|
|
131
131
|
}
|
|
132
|
-
declare class ShutdownController {
|
|
132
|
+
export declare class ShutdownController {
|
|
133
133
|
private readonly timeoutMs;
|
|
134
134
|
private readonly gracefulShutdown;
|
|
135
135
|
private readonly cleanup?;
|
|
@@ -144,7 +144,7 @@ declare class ShutdownController {
|
|
|
144
144
|
handleSignal(signal: NodeJS.Signals): Promise<void>;
|
|
145
145
|
private runCleanup;
|
|
146
146
|
}
|
|
147
|
-
declare function createShutdownController(options: ShutdownControllerOptions): ShutdownController;
|
|
147
|
+
export declare function createShutdownController(options: ShutdownControllerOptions): ShutdownController;
|
|
148
148
|
//#endregion
|
|
149
|
-
export {
|
|
149
|
+
export { main, parseCliArgs, start };
|
|
150
150
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/config/cli-flags-schema.ts","../src/runtime/output-broker.ts","../src/state/event-projection-store.ts","../src/runtime/cli-termination.ts","../src/runtime/output-mode.ts","../src/runtime/shutdown-controller.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/config/cli-flags-schema.ts","../src/runtime/output-broker.ts","../src/state/event-projection-store.ts","../src/runtime/cli-termination.ts","../src/runtime/output-mode.ts","../src/runtime/shutdown-controller.ts"],"mappings":";;;;;cAIa,qBAAmB,EAAA;;;;;GAE9B,EAAA,KAAA;KAEU,gBAAgB,EAAE,aAAa;UAE1B;EACf,OAAO;EACP;;wBAGc,mBAAmB,iBAAiB;;;KCfxC;KACA;UAEK;EACf,OAAO;EACP;EACA,QAAQ;EACR;;UAGe;EACf;EACA;EACA;EACA;;KAGG,cAAc,OAAO;qBA4Bb;mBACM;mBACA;mBACA;mBACA;mBACA;mBACA;UACT;UACA;UAKA;EAKR,YAAY,SAAS;EAOrB;EAgCA;EAmBA,UAAU,UAAU;EAOpB,cAAc;EAId,eAAe;EAIf,eAAe;EAIf,MAAM,OAAO,aAAa,iBAAiB,SAAQ;UAI3C;UAiCA;;wBAuBM,mBAAmB,SAAS,sBAAsB;;;UCnMjD;EACf;EACA;EACA;EACA,KAAK;EACL,YAAY;EACZ;EACA;EACA;EACA;;UAGe;EACf;EACA;;KAGG,sBAAsB,UAAU;qBAGxB;mBACM;mBACA;mBACA;mBACA;UAOT;UACA;UACA;EAER,YAAY,UAAS;EAKrB,UAAU,UAAU;EAQpB,eAAe;EAOf,WAAW,OAAO;EAQlB,cAAc,QAAQ;EAatB,UAAU,SAAS;EAOnB,cAAc,SAAS,aAAa;UAmD5B;UAgBA;;wBAQM,2BAA2B,UAAS,8BAAmC;;;UChKtE;EACf,UAAU;EACV;IACE;;EAEF,QAAQ;;qBAGG,yBAAyB;EACpC,YAAY,QAAQ,SAAS,QAAQ,OAAO;;wBAcxB,wBAAwB,OAAO,sBAAsB,QAAQ,OAAO,UAAU;wBA6CpF,uBAAuB,iBAAiB,iBAAiB;;;KCrE7D;UAEK;EACf,MAAM;EACN;EACA;;UAae;EACf,QAAQ;EACR,MAAM,OAAO;EACb,QAAQ,KAAK,OAAO;EACpB,SAAS,KAAK,OAAO;EACrB,SAAS,KAAK,OAAO;;wBAGP,iBAAiB,UAAS,0BAA+B;;;UC5BxD;EACf;EACA,mBAAmB,QAAQ,OAAO,YAAY;EAC9C,uBAAuB;EACvB,QAAQ;;qBAGG;mBACM;mBACA;mBACA;mBACA;UACT;UACA;UACA;mBACS;EAEjB,YAAY,SAAS;EAOrB,QAAQ,UAAS,OAAO;EAgBxB;EAQM,aAAa,QAAQ,OAAO,UAAU;UAyB9B;;wBAUA,yBAAyB,SAAS,4BAA4B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-wa/cli",
|
|
3
|
-
"version": "5.0.0
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "CLI for @open-wa WhatsApp automation - Easy API mode",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.cjs",
|
|
@@ -18,20 +18,22 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"
|
|
21
|
+
"@open-wa/core": "5.0.0",
|
|
22
|
+
"@open-wa/hyperemitter": "5.0.0",
|
|
23
|
+
"@open-wa/wa-automate": "5.0.0",
|
|
24
|
+
"ink": "^7.1.1",
|
|
22
25
|
"qrcode": "^1.5.4",
|
|
23
|
-
"react": "^
|
|
24
|
-
"ws": "^8.
|
|
25
|
-
"zod": "^4.
|
|
26
|
-
"@open-wa/core": "5.0.0-alpha.8",
|
|
27
|
-
"@open-wa/wa-automate": "5.0.0-alpha.8"
|
|
26
|
+
"react": "^19.3.0",
|
|
27
|
+
"ws": "^8.22.0",
|
|
28
|
+
"zod": "^4.6.5"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
|
-
"@types/node": "^
|
|
31
|
-
"@types/
|
|
31
|
+
"@types/node": "^26.6.3",
|
|
32
|
+
"@types/qrcode": "^1.5.6",
|
|
33
|
+
"@types/react": "^19.3.0",
|
|
32
34
|
"@types/ws": "^8.18.1",
|
|
33
|
-
"typescript": "^
|
|
34
|
-
"vitest": "
|
|
35
|
+
"typescript": "^7.0.2",
|
|
36
|
+
"vitest": "5.0.2"
|
|
35
37
|
},
|
|
36
38
|
"publishConfig": {
|
|
37
39
|
"access": "public"
|
|
@@ -41,6 +43,10 @@
|
|
|
41
43
|
"type": "git",
|
|
42
44
|
"url": "https://github.com/open-wa/wa-automate-nodejs.git"
|
|
43
45
|
},
|
|
46
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
47
|
+
"files": [
|
|
48
|
+
"dist"
|
|
49
|
+
],
|
|
44
50
|
"scripts": {
|
|
45
51
|
"build": "tsdown src/index.ts src/bin.ts --format cjs",
|
|
46
52
|
"dev": "tsdown src/index.ts src/bin.ts --format cjs --watch",
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
$ tsdown src/index.ts src/bin.ts --format cjs
|
|
2
|
-
[34mℹ[39m [34mtsdown v0.21.7[39m powered by [38;2;255;126;23mrolldown v1.0.0-rc.12[39m
|
|
3
|
-
[34mℹ[39m config file: [4m/home/runner/work/wa-automate-nodejs/wa-automate-nodejs/packages/cli/tsdown.config.ts[24m
|
|
4
|
-
[34mℹ[39m entry: [34msrc/index.ts, src/bin.ts[39m
|
|
5
|
-
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
6
|
-
[34mℹ[39m Build start
|
|
7
|
-
[34mℹ[39m Granting execute permission to [4mdist/bin.cjs[24m
|
|
8
|
-
[34mℹ[39m [2mdist/[22m[1mbin.cjs[22m [2m12.64 kB[22m [2m│ gzip: 3.94 kB[22m
|
|
9
|
-
[34mℹ[39m [2mdist/[22m[1mindex.cjs[22m [2m 1.54 kB[22m [2m│ gzip: 0.44 kB[22m
|
|
10
|
-
[34mℹ[39m [2mdist/[22mevent-projection-store-BM9eOQXx.cjs [2m13.64 kB[22m [2m│ gzip: 3.39 kB[22m
|
|
11
|
-
[34mℹ[39m 3 files, total: 27.82 kB
|
|
12
|
-
[34mℹ[39m [2mdist/[22mindex.d.cts.map [2m2.84 kB[22m [2m│ gzip: 0.95 kB[22m
|
|
13
|
-
[34mℹ[39m [2mdist/[22m[32m[1mindex.d.cts[22m[39m [2m5.40 kB[22m [2m│ gzip: 1.69 kB[22m
|
|
14
|
-
[34mℹ[39m [2mdist/[22m[32m[1mbin.d.cts[22m[39m [2m0.01 kB[22m [2m│ gzip: 0.03 kB[22m
|
|
15
|
-
[34mℹ[39m 3 files, total: 8.25 kB
|
|
16
|
-
[32m✔[39m Build complete in [32m4347ms[39m
|
package/CHANGELOG.md
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
# @open-wa/cli
|
|
2
|
-
|
|
3
|
-
## 5.0.0-alpha.8
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- Updated dependencies [[`6a55aef`](https://github.com/open-wa/wa-automate-nodejs/commit/6a55aef602b347bfffc8550e448585e7776baf18)]:
|
|
8
|
-
- @open-wa/core@5.0.0-alpha.8
|
|
9
|
-
- @open-wa/wa-automate@5.0.0-alpha.8
|
|
10
|
-
|
|
11
|
-
## 5.0.0-alpha.7
|
|
12
|
-
|
|
13
|
-
### Patch Changes
|
|
14
|
-
|
|
15
|
-
- Updated dependencies []:
|
|
16
|
-
- @open-wa/core@5.0.0-alpha.7
|
|
17
|
-
- @open-wa/wa-automate@5.0.0-alpha.7
|
|
18
|
-
|
|
19
|
-
## 5.0.0-alpha.6
|
|
20
|
-
|
|
21
|
-
### Patch Changes
|
|
22
|
-
|
|
23
|
-
- Updated dependencies []:
|
|
24
|
-
- @open-wa/wa-automate@5.0.0-alpha.6
|
|
25
|
-
- @open-wa/core@5.0.0-alpha.6
|
|
26
|
-
|
|
27
|
-
## 5.0.0-alpha.5
|
|
28
|
-
|
|
29
|
-
### Patch Changes
|
|
30
|
-
|
|
31
|
-
- Updated dependencies []:
|
|
32
|
-
- @open-wa/wa-automate@5.0.0-alpha.5
|
|
33
|
-
- @open-wa/core@5.0.0-alpha.5
|
|
34
|
-
|
|
35
|
-
## 5.0.0-alpha.4
|
|
36
|
-
|
|
37
|
-
### Patch Changes
|
|
38
|
-
|
|
39
|
-
- Updated dependencies []:
|
|
40
|
-
- @open-wa/wa-automate@5.0.0-alpha.4
|
|
41
|
-
- @open-wa/core@5.0.0-alpha.4
|
|
42
|
-
|
|
43
|
-
## 5.0.0-alpha.3
|
|
44
|
-
|
|
45
|
-
### Patch Changes
|
|
46
|
-
|
|
47
|
-
- Updated dependencies []:
|
|
48
|
-
- @open-wa/core@5.0.0-alpha.3
|
|
49
|
-
- @open-wa/wa-automate@5.0.0-alpha.3
|
|
50
|
-
|
|
51
|
-
## 5.0.0-alpha.2
|
|
52
|
-
|
|
53
|
-
### Patch Changes
|
|
54
|
-
|
|
55
|
-
- Updated dependencies []:
|
|
56
|
-
- @open-wa/core@5.0.0-alpha.2
|
|
57
|
-
- @open-wa/wa-automate@5.0.0-alpha.2
|
|
58
|
-
|
|
59
|
-
## 6.0.0-alpha.2
|
|
60
|
-
|
|
61
|
-
### Minor Changes
|
|
62
|
-
|
|
63
|
-
- Dry run minor bump
|
|
64
|
-
|
|
65
|
-
### Patch Changes
|
|
66
|
-
|
|
67
|
-
- Updated dependencies []:
|
|
68
|
-
- @open-wa/core@6.0.0-alpha.2
|
|
69
|
-
- @open-wa/wa-automate@6.0.0-alpha.2
|
|
70
|
-
|
|
71
|
-
## 5.0.1-alpha.2
|
|
72
|
-
|
|
73
|
-
### Patch Changes
|
|
74
|
-
|
|
75
|
-
- Dry run patch bump
|
|
76
|
-
|
|
77
|
-
- Updated dependencies []:
|
|
78
|
-
- @open-wa/core@5.0.1-alpha.2
|
|
79
|
-
- @open-wa/wa-automate@5.0.1-alpha.2
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
-
import { CliShutdownError, performGracefulShutdown, writeVisibleFatalError } from '../runtime/cli-termination';
|
|
3
|
-
|
|
4
|
-
describe('CLI termination helpers', () => {
|
|
5
|
-
it('attempts all teardown steps even when one rejects', async () => {
|
|
6
|
-
const order: string[] = [];
|
|
7
|
-
const store = {
|
|
8
|
-
projectStatus: vi.fn((update: { phase: string }) => {
|
|
9
|
-
order.push(`status:${update.phase}`);
|
|
10
|
-
}),
|
|
11
|
-
};
|
|
12
|
-
const runtime = {
|
|
13
|
-
server: {
|
|
14
|
-
stop: vi.fn(async () => {
|
|
15
|
-
order.push('server.stop');
|
|
16
|
-
throw new Error('server breach');
|
|
17
|
-
}),
|
|
18
|
-
},
|
|
19
|
-
client: {
|
|
20
|
-
stop: vi.fn(async () => {
|
|
21
|
-
order.push('client.stop');
|
|
22
|
-
}),
|
|
23
|
-
},
|
|
24
|
-
} as any;
|
|
25
|
-
const tunnelClient = {
|
|
26
|
-
disconnect: vi.fn(() => {
|
|
27
|
-
order.push('tunnel.disconnect');
|
|
28
|
-
}),
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const result = performGracefulShutdown({ runtime, tunnelClient, store: store as any }, 'SIGTERM');
|
|
32
|
-
|
|
33
|
-
await expect(result).rejects.toBeInstanceOf(CliShutdownError);
|
|
34
|
-
expect(order).toEqual([
|
|
35
|
-
'status:shutdown.starting',
|
|
36
|
-
'server.stop',
|
|
37
|
-
'tunnel.disconnect',
|
|
38
|
-
'client.stop',
|
|
39
|
-
'status:shutdown.complete',
|
|
40
|
-
]);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('writes fatal errors directly to raw stderr for visibility', () => {
|
|
44
|
-
const writeRawStderr = vi.fn();
|
|
45
|
-
|
|
46
|
-
writeVisibleFatalError('reactor offline', writeRawStderr);
|
|
47
|
-
|
|
48
|
-
expect(writeRawStderr).toHaveBeenCalledWith('\nFatal error: reactor offline\n');
|
|
49
|
-
});
|
|
50
|
-
});
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
-
import { createEventProjectionStore } from '../state/event-projection-store';
|
|
3
|
-
|
|
4
|
-
class FakeEmitter {
|
|
5
|
-
private handlers = new Map<string, Set<(payload: unknown) => void>>();
|
|
6
|
-
|
|
7
|
-
on(event: string, handler: (payload: unknown) => void) {
|
|
8
|
-
const handlers = this.handlers.get(event) ?? new Set();
|
|
9
|
-
handlers.add(handler);
|
|
10
|
-
this.handlers.set(event, handlers);
|
|
11
|
-
return this;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
off(event: string, handler: (payload: unknown) => void) {
|
|
15
|
-
this.handlers.get(event)?.delete(handler);
|
|
16
|
-
return this;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
emit(event: string, payload: unknown) {
|
|
20
|
-
for (const handler of this.handlers.get(event) ?? []) {
|
|
21
|
-
handler(payload);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
listenerCount(event: string): number {
|
|
26
|
-
return this.handlers.get(event)?.size ?? 0;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
describe('EventProjectionStore', () => {
|
|
31
|
-
it('retains only a bounded number of log entries', () => {
|
|
32
|
-
const store = createEventProjectionStore({ maxLogs: 2 });
|
|
33
|
-
|
|
34
|
-
store.projectLog({ level: 'info', message: 'one', source: 'runtime', timestamp: 1 });
|
|
35
|
-
store.projectLog({ level: 'info', message: 'two', source: 'runtime', timestamp: 2 });
|
|
36
|
-
store.projectLog({ level: 'info', message: 'three', source: 'runtime', timestamp: 3 });
|
|
37
|
-
|
|
38
|
-
expect(store.getSnapshot().recentLogs.map((entry) => entry.message)).toEqual(['two', 'three']);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('coalesces bursty runtime events before exposing them to the snapshot', async () => {
|
|
42
|
-
vi.useFakeTimers();
|
|
43
|
-
const store = createEventProjectionStore({ eventDebounceMs: 100 });
|
|
44
|
-
const emitter = new FakeEmitter();
|
|
45
|
-
const detach = store.attachEmitter(emitter as any);
|
|
46
|
-
|
|
47
|
-
emitter.emit('message.received', {});
|
|
48
|
-
emitter.emit('message.received', {});
|
|
49
|
-
emitter.emit('ack.changed', {});
|
|
50
|
-
|
|
51
|
-
expect(store.getSnapshot().messageCount).toBe(0);
|
|
52
|
-
expect(store.getSnapshot().ackCount).toBe(0);
|
|
53
|
-
|
|
54
|
-
await vi.advanceTimersByTimeAsync(100);
|
|
55
|
-
|
|
56
|
-
expect(store.getSnapshot().messageCount).toBe(2);
|
|
57
|
-
expect(store.getSnapshot().ackCount).toBe(1);
|
|
58
|
-
|
|
59
|
-
detach();
|
|
60
|
-
expect(emitter.listenerCount('message.received')).toBe(0);
|
|
61
|
-
expect(emitter.listenerCount('ack.changed')).toBe(0);
|
|
62
|
-
vi.useRealTimers();
|
|
63
|
-
});
|
|
64
|
-
});
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
-
|
|
3
|
-
describe('createInteractiveCliSession', () => {
|
|
4
|
-
it('uses a broker configuration that leaves stdio streams untouched for Ink', async () => {
|
|
5
|
-
const install = vi.fn();
|
|
6
|
-
const dispose = vi.fn();
|
|
7
|
-
const subscribe = vi.fn(() => vi.fn());
|
|
8
|
-
const write = vi.fn();
|
|
9
|
-
|
|
10
|
-
const createOutputBroker = vi.fn(() => ({
|
|
11
|
-
install,
|
|
12
|
-
dispose,
|
|
13
|
-
subscribe,
|
|
14
|
-
write,
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
|
-
vi.doMock('../runtime/output-broker', async () => {
|
|
18
|
-
const actual = await vi.importActual<typeof import('../runtime/output-broker')>('../runtime/output-broker');
|
|
19
|
-
return {
|
|
20
|
-
...actual,
|
|
21
|
-
createOutputBroker,
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
vi.doMock('../presenter/interactive-terminal', () => ({
|
|
25
|
-
InteractiveTerminalPresenter: class MockInteractiveTerminalPresenter {
|
|
26
|
-
async start() {}
|
|
27
|
-
stop() {}
|
|
28
|
-
},
|
|
29
|
-
}));
|
|
30
|
-
|
|
31
|
-
const module = await import('../runtime/interactive-session');
|
|
32
|
-
const session = await module.createInteractiveCliSession();
|
|
33
|
-
|
|
34
|
-
expect(createOutputBroker).toHaveBeenCalledWith(
|
|
35
|
-
expect.objectContaining({
|
|
36
|
-
interactive: true,
|
|
37
|
-
interceptStreams: false,
|
|
38
|
-
})
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
session.cleanup();
|
|
42
|
-
vi.resetModules();
|
|
43
|
-
vi.doUnmock('../runtime/output-broker');
|
|
44
|
-
vi.doUnmock('../presenter/interactive-terminal');
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('awaits presenter startup before resolving the interactive session', async () => {
|
|
48
|
-
let resolveStart: (() => void) | undefined;
|
|
49
|
-
const start = vi.fn(
|
|
50
|
-
() =>
|
|
51
|
-
new Promise<void>((resolve) => {
|
|
52
|
-
resolveStart = resolve;
|
|
53
|
-
})
|
|
54
|
-
);
|
|
55
|
-
const stop = vi.fn();
|
|
56
|
-
|
|
57
|
-
vi.doMock('../presenter/interactive-terminal', () => ({
|
|
58
|
-
InteractiveTerminalPresenter: class MockInteractiveTerminalPresenter {
|
|
59
|
-
start = start;
|
|
60
|
-
stop = stop;
|
|
61
|
-
},
|
|
62
|
-
}));
|
|
63
|
-
|
|
64
|
-
const module = await import('../runtime/interactive-session');
|
|
65
|
-
let resolved = false;
|
|
66
|
-
const sessionPromise = module.createInteractiveCliSession().then((session) => {
|
|
67
|
-
resolved = true;
|
|
68
|
-
return session;
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
await Promise.resolve();
|
|
72
|
-
|
|
73
|
-
expect(start).toHaveBeenCalledTimes(1);
|
|
74
|
-
expect(resolved).toBe(false);
|
|
75
|
-
|
|
76
|
-
resolveStart?.();
|
|
77
|
-
const session = await sessionPromise;
|
|
78
|
-
|
|
79
|
-
expect(resolved).toBe(true);
|
|
80
|
-
session.cleanup();
|
|
81
|
-
vi.resetModules();
|
|
82
|
-
vi.doUnmock('../presenter/interactive-terminal');
|
|
83
|
-
});
|
|
84
|
-
});
|