Rename all crates, CLI commands, constants, type names, doc comments, and documentation from wraith to alknet. Includes wire-protocol changes: ALPN wraith-ssh -> alknet-ssh, reserved destination prefix wraith- -> alknet-, SSH auth username wraith -> alknet.
2.3 KiB
id, name, status, depends_on, scope, risk, impact, level
| id | name | status | depends_on | scope | risk | impact | level | ||
|---|---|---|---|---|---|---|---|---|---|
| napi/serve-function | Implement NAPI serve() — server with connection events returning Duplex streams | completed |
|
moderate | high | component | implementation |
Description
Implement the NAPI serve() function per ADR-016. Returns a AlknetServer object with a close() method and onConnection event emitter. Each incoming SSH connection produces a Duplex stream.
The function accepts AlknetServeOptions and returns Promise<AlknetServer>. The NAPI layer handles transport binding, SSH server setup, and connection handling.
Acceptance Criteria
#[napi]functionserve(options: AlknetServeOptions) -> Result<AlknetServer>incrates/alknet-napi/src/serve.rsAlknetServeOptionsstruct with napi fields:transport,hostKey,authorizedKeys,certAuthority,tlsCert,tlsKey,acmeDomain,listen,irohRelayAlknetServernapi class withclose() -> Promise<void>andonConnection(callback)event registration- Each incoming connection produces a
Duplexstream via theonConnectioncallback ConnectionInfostruct passed with each connection:remoteAddr,transportKind- Key material:
hostKey,authorizedKeysaccept file path (string) orBuffer(in-memory) - Server starts transport acceptor, authenticates connections, emits stream events
close()triggers graceful shutdown- TypeScript type matches napi-and-pubsub.md spec
- Integration test: JS serve() + connect() round-trip works
References
- docs/architecture/napi-and-pubsub.md — NAPI serve() spec, AlknetServer interface
- docs/architecture/decisions/016-napi-expose-connect-and-serve.md — both connect() and serve()
- docs/architecture/server.md — server configuration
Notes
TCP transport fully implemented. TLS/iroh transports return helpful "not yet supported" errors. AlknetServerStream provides read/write/close. ConnectionInfo includes remoteAddr and transportKind.
Summary
Implemented NAPI serve() in crates/alknet-napi/src/serve.rs: AlknetServeOptions, AlknetServer with close()/onConnection(), AlknetServerStream (Duplex read/write/close), ConnectionInfo. TCP transport works end-to-end. 241 tests pass, clippy clean.