lmcode-js skill
Use lmcode-js to embed the DSLB v6 bytecode verifier, 226-signature standard catalog, and REST/CLI controller into Node.js 22+ and 24+ applications.
Purpose
Run schema-bound lmcode DSLB v6 bytecode in pure JavaScript with lossless 64-bit BigInt math, raw byte buffers, REST/CLI dispatch, and LMCODE_RETURN framing.
When to use it
Use lmcode-js when building a Node.js host tool, CLI, or test runner that executes compiled .dslb v6 programs without native addons.
Install
Import @lmctl-ai/lmcode-js and @lmctl-ai/lmcode-js/rest in Node.js 22 or 24 LTS with zero external npm runtime dependencies.
Commands
npm run verify:pins
npm test
npm run mutation
npm run conformance
npm run conformance:rest
npm run sample-suite
Inputs and outputs
- Input: Buffer or Uint8Array DSLB v6 bytecode, exact schema JSON bytes, and optional LMCODE_INVOCATION_FILE manifest.
- Output: mutated JS host objects in Context, HTTP/1.1 traffic on stdout via RestController, or a terminal LMCODE_RETURN frame.
- Types: integers default to BigInt (or safe Number with { ints: 'number' }); strings default to UTF-8 (or Buffer with { rawStrings: true }).
Safety rules
- Enable { rawStrings: true } on callbacks that must preserve invalid UTF-8 bytes or interior NUL bytes as Node Buffer instances.
- Keep default BigInt mode for callbacks that handle full signed 64-bit integer ranges outside Number.MAX_SAFE_INTEGER.
- Pass { dry: previewCallback } options only for side-effect-free preview callbacks during dry invocations.
Worked examples
import { Context, Program, createRegistry } from '@lmctl-ai/lmcode-js';
const registry = createRegistry();
registry.context('greeter', 'Greeter');
registry.method('method Greeter.say(string) -> void', (greeter, text) => {
greeter.messages.push(text);
});
const program = Program.load(bytecode, schemaBytes, registry);
const context = new Context({ greeter: { messages: [] } });
program.run(context);
Errors and exit codes
| Code | Phase | Exit | Condition |
|---|---|---|---|
| LOAD_BAD_BYTECODE | load | 3 | Malformed DSLB v6 header, bad magic or version, truncated section, invalid opcode, or stack depth violation |
| LOAD_BAD_SCHEMA | load | 3 | Host schema JSON fails dsl.schema 2 validation or declares an invalid result contract |
| LOAD_SCHEMA_MISMATCH | load | 3 | 32-byte SHA-256 schema hash in DSLB v6 header does not match exact host schema bytes |
| LOAD_UNBOUND | load | 3 | Bytecode imports a context, function, or method signature not registered in the host Registry |
| RUN_ERROR | run | 3 | VM division or remainder by zero, or loop-free operand stack underflow |
| RUN_HOST | run | 3 | Host callback failure, invalid encoding, expired collection handle, or REST route validation failure |
| APP_FAIL | app | 4 | Post-run application domain validation failure or output stream write failure |
How to verify
npm run check