@acpfx/node-sdk 0.2.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/package.json +10 -0
- package/src/index.ts +53 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# @acpfx/node-sdk
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- d757640: Initial release: type-safe contracts, Rust orchestrator, manifest-driven event filtering
|
|
8
|
+
|
|
9
|
+
- Rust schema crate as canonical event type source of truth with codegen to TypeScript + Zod
|
|
10
|
+
- Node manifests (manifest.yaml) declaring consumes/emits contracts
|
|
11
|
+
- Orchestrator event filtering: nodes only receive declared events
|
|
12
|
+
- Rust orchestrator with ratatui TUI (--ui flag)
|
|
13
|
+
- node-sdk with structured logging helpers
|
|
14
|
+
- CI/CD with GitHub Actions and changesets
|
|
15
|
+
- Platform-specific npm packages for Rust binaries (esbuild-style distribution)
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [d757640]
|
|
20
|
+
- @acpfx/core@0.2.0
|
package/package.json
ADDED
package/src/index.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node SDK — shared helpers for acpfx TS nodes.
|
|
3
|
+
*
|
|
4
|
+
* Provides emit(), log(), onEvent(), and handleManifestFlag().
|
|
5
|
+
* log() emits structured log events on stdout (not stderr).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { createInterface, type Interface } from "node:readline";
|
|
9
|
+
/**
|
|
10
|
+
* Re-export handleManifestFlag from core — handles the --manifest flag.
|
|
11
|
+
* If --manifest is in process.argv, prints the manifest as JSON and exits.
|
|
12
|
+
*/
|
|
13
|
+
export { handleManifestFlag } from "@acpfx/core";
|
|
14
|
+
|
|
15
|
+
const NODE_NAME = process.env.ACPFX_NODE_NAME ?? "unknown";
|
|
16
|
+
|
|
17
|
+
/** Emit an NDJSON event on stdout. */
|
|
18
|
+
export function emit(event: Record<string, unknown>): void {
|
|
19
|
+
process.stdout.write(JSON.stringify(event) + "\n");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Emit a structured log event on stdout. */
|
|
23
|
+
export function log(level: "info" | "warn" | "error" | "debug", message: string): void {
|
|
24
|
+
emit({ type: "log", level, component: NODE_NAME, message });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Convenience: log.info / log.warn / log.error / log.debug */
|
|
28
|
+
log.info = (message: string): void => log("info", message);
|
|
29
|
+
log.warn = (message: string): void => log("warn", message);
|
|
30
|
+
log.error = (message: string): void => log("error", message);
|
|
31
|
+
log.debug = (message: string): void => log("debug", message);
|
|
32
|
+
|
|
33
|
+
export type EventHandler = (event: Record<string, unknown>) => void;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Listen for NDJSON events on stdin. Returns the readline interface
|
|
37
|
+
* for attaching close handlers.
|
|
38
|
+
*/
|
|
39
|
+
export function onEvent(handler: EventHandler): Interface {
|
|
40
|
+
const rl = createInterface({ input: process.stdin });
|
|
41
|
+
|
|
42
|
+
rl.on("line", (line) => {
|
|
43
|
+
if (!line.trim()) return;
|
|
44
|
+
try {
|
|
45
|
+
const event = JSON.parse(line);
|
|
46
|
+
handler(event);
|
|
47
|
+
} catch {
|
|
48
|
+
// ignore malformed JSON
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return rl;
|
|
53
|
+
}
|