@letterblack/lbe-sdk 1.0.0 → 1.0.1

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/README.md CHANGED
@@ -54,8 +54,8 @@ console.log(JSON.parse(output));
54
54
  | `npx lbe execute --input input.json` | Execute one JSON request through WASM |
55
55
  | `cat input.json \| npx lbe execute` | Execute from stdin |
56
56
 
57
- The legacy `lbe-mcp` command is intentionally disabled in this package until
58
- the MCP server is rebuilt as a thin bridge over `execute(input)`.
57
+ `lbe-mcp` starts a thin MCP stdio bridge exposing one tool: `lbe_execute`.
58
+ It contains no governance logic; it only passes JSON into `execute(input)`.
59
59
 
60
60
  ## What ships
61
61
 
@@ -1,3 +1,105 @@
1
1
  #!/usr/bin/env node
2
- process.stderr.write('lbe-mcp is disabled in the WASM-authoritative package until MCP transport is reimplemented as a thin execute() bridge.\n');
3
- process.exit(2);
2
+ import { execute } from './index.js';
3
+
4
+ let buffer = Buffer.alloc(0);
5
+
6
+ function send(payload) {
7
+ const body = Buffer.from(JSON.stringify(payload), 'utf8');
8
+ process.stdout.write(`Content-Length: ${body.length}\r\n\r\n`);
9
+ process.stdout.write(body);
10
+ }
11
+
12
+ function result(id, value) {
13
+ send({ jsonrpc: '2.0', id, result: value });
14
+ }
15
+
16
+ function error(id, code, message) {
17
+ send({ jsonrpc: '2.0', id, error: { code, message } });
18
+ }
19
+
20
+ function handle(message) {
21
+ const { id, method, params } = message;
22
+ if (method === 'initialize') {
23
+ result(id, {
24
+ protocolVersion: params?.protocolVersion || '2024-11-05',
25
+ capabilities: { tools: {} },
26
+ serverInfo: { name: 'lbe', version: '1.0.1' }
27
+ });
28
+ return;
29
+ }
30
+ if (method === 'notifications/initialized') return;
31
+ if (method === 'tools/list') {
32
+ result(id, {
33
+ tools: [{
34
+ name: 'lbe_execute',
35
+ description: 'Execute one canonical LBE JSON request through the local WASM boundary.',
36
+ inputSchema: {
37
+ type: 'object',
38
+ properties: {
39
+ input: {
40
+ type: 'object',
41
+ description: 'LBE execute request object. It will be serialized and passed to execute(input).'
42
+ },
43
+ input_json: {
44
+ type: 'string',
45
+ description: 'Raw JSON string to pass to execute(input). Takes precedence over input.'
46
+ }
47
+ }
48
+ }
49
+ }]
50
+ });
51
+ return;
52
+ }
53
+ if (method === 'tools/call') {
54
+ try {
55
+ if (params?.name !== 'lbe_execute') {
56
+ error(id, -32602, 'Unknown tool');
57
+ return;
58
+ }
59
+ const args = params.arguments || {};
60
+ const input = typeof args.input_json === 'string' ? args.input_json : JSON.stringify(args.input);
61
+ const output = execute(input);
62
+ result(id, {
63
+ content: [{ type: 'text', text: output }],
64
+ structuredContent: JSON.parse(output),
65
+ isError: false
66
+ });
67
+ } catch (err) {
68
+ result(id, {
69
+ content: [{ type: 'text', text: String(err?.message || err) }],
70
+ isError: true
71
+ });
72
+ }
73
+ return;
74
+ }
75
+ if (id !== undefined) error(id, -32601, 'Method not found');
76
+ }
77
+
78
+ function pump() {
79
+ while (true) {
80
+ const headerEnd = buffer.indexOf('\r\n\r\n');
81
+ if (headerEnd < 0) return;
82
+ const header = buffer.slice(0, headerEnd).toString('utf8');
83
+ const match = header.match(/Content-Length:\s*(\d+)/i);
84
+ if (!match) {
85
+ buffer = buffer.slice(headerEnd + 4);
86
+ continue;
87
+ }
88
+ const length = Number(match[1]);
89
+ const bodyStart = headerEnd + 4;
90
+ const bodyEnd = bodyStart + length;
91
+ if (buffer.length < bodyEnd) return;
92
+ const body = buffer.slice(bodyStart, bodyEnd).toString('utf8');
93
+ buffer = buffer.slice(bodyEnd);
94
+ try {
95
+ handle(JSON.parse(body));
96
+ } catch (err) {
97
+ error(null, -32700, String(err?.message || err));
98
+ }
99
+ }
100
+ }
101
+
102
+ process.stdin.on('data', (chunk) => {
103
+ buffer = Buffer.concat([buffer, chunk]);
104
+ pump();
105
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterblack/lbe-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Local-first execution governance SDK for AI agents.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",