@brud/protocol 0.0.0-stage → 0.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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Akkhar-Labs
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,56 @@
1
- # Temporary Holding Version
1
+ # @brud/protocol
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The message types, method names and error codes that the BrudOS daemon and its clients use to talk to each other.
4
+
5
+ ## What is BrudOS?
6
+
7
+ BrudOS is a small kernel you embed in a program to build software out of independent pieces, called **participants**, that do not have to trust each other. The kernel gives every participant an identity, lets each participant decide who may call its APIs, and enforces that on every call.
8
+
9
+ The kernel has no abilities of its own: it does not read files, use the network or run commands. That makes it a good base for plugin systems and AI-agent runtimes, where you need to know exactly who was allowed to do what.
10
+
11
+ > **Status: beta (0.0.x).** The core works and is tested, but APIs may still change before 1.0.
12
+
13
+ ## Which package do I need?
14
+
15
+ BrudOS is published as four packages. Install only what you need.
16
+
17
+ | Package | Use it to | Install |
18
+ |---|---|---|
19
+ | [`@brud/kernel`](https://www.npmjs.com/package/@brud/kernel) | The engine. Embed it in your program to run participants. | `npm install @brud/kernel` |
20
+ | [`@brud/sdk`](https://www.npmjs.com/package/@brud/sdk) | Write and test participants (plugins, services, agent tools). | `npm install @brud/sdk @brud/kernel` |
21
+ | [`@brud/daemon`](https://www.npmjs.com/package/@brud/daemon) | Run kernels as a local background process that editors, agents and scripts connect to. | `npm install @brud/daemon` |
22
+ | **`@brud/protocol`** (this package) | The message types the daemon and its clients share. Installed with the daemon; you only need it directly to write your own client. | `npm install @brud/protocol` |
23
+
24
+ New to BrudOS? Start with the [introduction](https://github.com/rahatarch/brud/tree/main/docs-next/01-introduction/what-is-brudos.md) and the [getting-started guide](https://github.com/rahatarch/brud/tree/main/docs-next/02-getting-started).
25
+
26
+ ## Do I need this?
27
+
28
+ Usually not. If you run the daemon or connect to it with [`@brud/daemon`](https://www.npmjs.com/package/@brud/daemon), this package is installed for you. Install it directly only if you are writing your own daemon client and want the TypeScript types.
29
+
30
+ ## Install
31
+
32
+ ```bash
33
+ npm install @brud/protocol
34
+ ```
35
+
36
+ Requires Node.js 22 or newer. It has no runtime dependencies and ships CommonJS with TypeScript declarations.
37
+
38
+ ## What it exports
39
+
40
+ - Method name constants such as `KERNEL_BOOT`, `KERNEL_ROUTE` and `REQUEST_CANCEL`, with typed parameters and results.
41
+ - `RPC_ERROR_CODES` and the error types.
42
+ - `DAEMON_PROTOCOL_VERSION` (currently `1.0.0`, the version of the wire protocol, which is separate from this package's version).
43
+
44
+ ```ts
45
+ import { KERNEL_BOOT, type KernelBootParams } from '@brud/protocol';
46
+ ```
47
+
48
+ The messages are JSON-RPC 2.0 sent over a Noise-encrypted local channel.
49
+
50
+ ## Documentation
51
+
52
+ [Protocol reference](https://github.com/rahatarch/brud/tree/main/docs-next/05-daemon/protocol-reference.md) · [Report an issue](https://github.com/rahatarch/brud/issues)
53
+
54
+ ## License
55
+
56
+ [Apache-2.0](LICENSE)
@@ -0,0 +1,62 @@
1
+ export declare const RPC_ERROR_CODES: {
2
+ readonly PARSE_ERROR: -32700;
3
+ readonly INVALID_REQUEST: -32600;
4
+ readonly METHOD_NOT_FOUND: -32601;
5
+ readonly INVALID_PARAMS: -32602;
6
+ readonly INTERNAL_ERROR: -32603;
7
+ readonly AUTH_FAILED: -32001;
8
+ readonly HANDSHAKE_REQUIRED: -32002;
9
+ readonly WORKSPACE_MISMATCH: -32003;
10
+ readonly PROTOCOL_VERSION_MISMATCH: -32004;
11
+ readonly ALREADY_HANDSHAKEN: -32005;
12
+ readonly PATH_VIOLATION: -32010;
13
+ readonly READ_ONLY_VIOLATION: -32011;
14
+ readonly NOT_IMPLEMENTED: -32012;
15
+ readonly FILE_NOT_FOUND: -32013;
16
+ readonly STORAGE_ERROR: -32014;
17
+ readonly LIFECYCLE_STATE: -32015;
18
+ readonly ACCESS_DENIED: -32016;
19
+ readonly RESOURCE_EXHAUSTED: -32017;
20
+ readonly REQUEST_TIMEOUT: -32018;
21
+ };
22
+ export type RpcErrorCode = (typeof RPC_ERROR_CODES)[keyof typeof RPC_ERROR_CODES];
23
+ export declare const PARSE_ERROR: -32700;
24
+ export declare const INVALID_REQUEST: -32600;
25
+ export declare const METHOD_NOT_FOUND: -32601;
26
+ export declare const INVALID_PARAMS: -32602;
27
+ export declare const INTERNAL_ERROR: -32603;
28
+ export declare const AUTH_FAILED: -32001;
29
+ export declare const HANDSHAKE_REQUIRED: -32002;
30
+ export declare const WORKSPACE_MISMATCH: -32003;
31
+ export declare const PROTOCOL_VERSION_MISMATCH: -32004;
32
+ export declare const ALREADY_HANDSHAKEN: -32005;
33
+ export declare const PATH_VIOLATION: -32010;
34
+ export declare const READ_ONLY_VIOLATION: -32011;
35
+ export declare const NOT_IMPLEMENTED: -32012;
36
+ export declare const FILE_NOT_FOUND: -32013;
37
+ export declare const STORAGE_ERROR: -32014;
38
+ export declare const LIFECYCLE_STATE: -32015;
39
+ export declare const ACCESS_DENIED: -32016;
40
+ export declare const RESOURCE_EXHAUSTED: -32017;
41
+ export declare const REQUEST_TIMEOUT: -32018;
42
+ export interface RpcErrorDetails {
43
+ readonly errorCode?: string;
44
+ readonly rule?: string;
45
+ readonly path?: string;
46
+ readonly root?: string;
47
+ readonly reason?: string;
48
+ readonly operation?: string;
49
+ readonly expected?: string;
50
+ readonly actual?: string;
51
+ readonly syscall?: string;
52
+ readonly method?: string;
53
+ /** Request field that was invalid. */
54
+ readonly field?: string;
55
+ /** Kernel instance the error refers to. */
56
+ readonly instanceId?: string;
57
+ }
58
+ export interface RpcErrorData {
59
+ readonly code: RpcErrorCode;
60
+ readonly message: string;
61
+ readonly data?: RpcErrorDetails;
62
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.REQUEST_TIMEOUT = exports.RESOURCE_EXHAUSTED = exports.ACCESS_DENIED = exports.LIFECYCLE_STATE = exports.STORAGE_ERROR = exports.FILE_NOT_FOUND = exports.NOT_IMPLEMENTED = exports.READ_ONLY_VIOLATION = exports.PATH_VIOLATION = exports.ALREADY_HANDSHAKEN = exports.PROTOCOL_VERSION_MISMATCH = exports.WORKSPACE_MISMATCH = exports.HANDSHAKE_REQUIRED = exports.AUTH_FAILED = exports.INTERNAL_ERROR = exports.INVALID_PARAMS = exports.METHOD_NOT_FOUND = exports.INVALID_REQUEST = exports.PARSE_ERROR = exports.RPC_ERROR_CODES = void 0;
4
+ exports.RPC_ERROR_CODES = {
5
+ PARSE_ERROR: -32700,
6
+ INVALID_REQUEST: -32600,
7
+ METHOD_NOT_FOUND: -32601,
8
+ INVALID_PARAMS: -32602,
9
+ INTERNAL_ERROR: -32603,
10
+ AUTH_FAILED: -32001,
11
+ HANDSHAKE_REQUIRED: -32002,
12
+ WORKSPACE_MISMATCH: -32003,
13
+ PROTOCOL_VERSION_MISMATCH: -32004,
14
+ ALREADY_HANDSHAKEN: -32005,
15
+ PATH_VIOLATION: -32010,
16
+ READ_ONLY_VIOLATION: -32011,
17
+ NOT_IMPLEMENTED: -32012,
18
+ FILE_NOT_FOUND: -32013,
19
+ STORAGE_ERROR: -32014,
20
+ LIFECYCLE_STATE: -32015,
21
+ ACCESS_DENIED: -32016,
22
+ RESOURCE_EXHAUSTED: -32017,
23
+ REQUEST_TIMEOUT: -32018,
24
+ };
25
+ exports.PARSE_ERROR = exports.RPC_ERROR_CODES.PARSE_ERROR;
26
+ exports.INVALID_REQUEST = exports.RPC_ERROR_CODES.INVALID_REQUEST;
27
+ exports.METHOD_NOT_FOUND = exports.RPC_ERROR_CODES.METHOD_NOT_FOUND;
28
+ exports.INVALID_PARAMS = exports.RPC_ERROR_CODES.INVALID_PARAMS;
29
+ exports.INTERNAL_ERROR = exports.RPC_ERROR_CODES.INTERNAL_ERROR;
30
+ exports.AUTH_FAILED = exports.RPC_ERROR_CODES.AUTH_FAILED;
31
+ exports.HANDSHAKE_REQUIRED = exports.RPC_ERROR_CODES.HANDSHAKE_REQUIRED;
32
+ exports.WORKSPACE_MISMATCH = exports.RPC_ERROR_CODES.WORKSPACE_MISMATCH;
33
+ exports.PROTOCOL_VERSION_MISMATCH = exports.RPC_ERROR_CODES.PROTOCOL_VERSION_MISMATCH;
34
+ exports.ALREADY_HANDSHAKEN = exports.RPC_ERROR_CODES.ALREADY_HANDSHAKEN;
35
+ exports.PATH_VIOLATION = exports.RPC_ERROR_CODES.PATH_VIOLATION;
36
+ exports.READ_ONLY_VIOLATION = exports.RPC_ERROR_CODES.READ_ONLY_VIOLATION;
37
+ exports.NOT_IMPLEMENTED = exports.RPC_ERROR_CODES.NOT_IMPLEMENTED;
38
+ exports.FILE_NOT_FOUND = exports.RPC_ERROR_CODES.FILE_NOT_FOUND;
39
+ exports.STORAGE_ERROR = exports.RPC_ERROR_CODES.STORAGE_ERROR;
40
+ exports.LIFECYCLE_STATE = exports.RPC_ERROR_CODES.LIFECYCLE_STATE;
41
+ exports.ACCESS_DENIED = exports.RPC_ERROR_CODES.ACCESS_DENIED;
42
+ exports.RESOURCE_EXHAUSTED = exports.RPC_ERROR_CODES.RESOURCE_EXHAUSTED;
43
+ exports.REQUEST_TIMEOUT = exports.RPC_ERROR_CODES.REQUEST_TIMEOUT;
@@ -0,0 +1,33 @@
1
+ import type { RpcErrorData } from './errors.js';
2
+ export type JsonRpcVersion = '2.0';
3
+ export type JsonRpcId = string | number | null;
4
+ export interface RpcRequest<TParams = unknown> {
5
+ readonly jsonrpc: JsonRpcVersion;
6
+ readonly id: JsonRpcId;
7
+ readonly method: string;
8
+ readonly params?: TParams;
9
+ }
10
+ export interface RpcNotification<TParams = unknown> {
11
+ readonly jsonrpc: JsonRpcVersion;
12
+ readonly method: string;
13
+ readonly params?: TParams;
14
+ }
15
+ export interface RpcSuccessResponse<TResult = unknown> {
16
+ readonly jsonrpc: JsonRpcVersion;
17
+ readonly id: JsonRpcId;
18
+ readonly result: TResult;
19
+ }
20
+ export interface RpcErrorResponse {
21
+ readonly jsonrpc: JsonRpcVersion;
22
+ readonly id: JsonRpcId;
23
+ readonly error: RpcErrorData;
24
+ }
25
+ export type RpcResponse<TResult = unknown> = RpcSuccessResponse<TResult> | RpcErrorResponse;
26
+ export type RpcMessage = RpcRequest | RpcNotification | RpcSuccessResponse | RpcErrorResponse;
27
+ export declare function isRpcErrorData(value: unknown): value is RpcErrorData;
28
+ export declare function isRpcRequest(value: unknown): value is RpcRequest;
29
+ export declare function isRpcNotification(value: unknown): value is RpcNotification;
30
+ export declare function isRpcSuccessResponse(value: unknown): value is RpcSuccessResponse;
31
+ export declare function isRpcErrorResponse(value: unknown): value is RpcErrorResponse;
32
+ export declare function isRpcResponse(value: unknown): value is RpcResponse;
33
+ export declare function isRpcMessage(value: unknown): value is RpcMessage;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isRpcErrorData = isRpcErrorData;
4
+ exports.isRpcRequest = isRpcRequest;
5
+ exports.isRpcNotification = isRpcNotification;
6
+ exports.isRpcSuccessResponse = isRpcSuccessResponse;
7
+ exports.isRpcErrorResponse = isRpcErrorResponse;
8
+ exports.isRpcResponse = isRpcResponse;
9
+ exports.isRpcMessage = isRpcMessage;
10
+ function isRecord(value) {
11
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
12
+ }
13
+ function isJsonRpcId(value) {
14
+ return value === null || typeof value === 'string' || typeof value === 'number';
15
+ }
16
+ function isRpcErrorData(value) {
17
+ return isRecord(value)
18
+ && typeof value.code === 'number'
19
+ && Number.isInteger(value.code)
20
+ && typeof value.message === 'string';
21
+ }
22
+ function isRpcRequest(value) {
23
+ return isRecord(value)
24
+ && value.jsonrpc === '2.0'
25
+ && typeof value.method === 'string'
26
+ && 'id' in value
27
+ && isJsonRpcId(value.id);
28
+ }
29
+ function isRpcNotification(value) {
30
+ return isRecord(value)
31
+ && value.jsonrpc === '2.0'
32
+ && typeof value.method === 'string'
33
+ && !('id' in value);
34
+ }
35
+ function isRpcSuccessResponse(value) {
36
+ return isRecord(value)
37
+ && value.jsonrpc === '2.0'
38
+ && 'id' in value
39
+ && isJsonRpcId(value.id)
40
+ && 'result' in value
41
+ && !('error' in value);
42
+ }
43
+ function isRpcErrorResponse(value) {
44
+ return isRecord(value)
45
+ && value.jsonrpc === '2.0'
46
+ && 'id' in value
47
+ && isJsonRpcId(value.id)
48
+ && 'error' in value
49
+ && isRpcErrorData(value.error);
50
+ }
51
+ function isRpcResponse(value) {
52
+ return isRpcSuccessResponse(value) || isRpcErrorResponse(value);
53
+ }
54
+ function isRpcMessage(value) {
55
+ return isRpcRequest(value) || isRpcNotification(value) || isRpcResponse(value);
56
+ }
@@ -0,0 +1,4 @@
1
+ export * from './version.js';
2
+ export * from './errors.js';
3
+ export * from './methods.js';
4
+ export * from './framing.js';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./version.js"), exports);
18
+ __exportStar(require("./errors.js"), exports);
19
+ __exportStar(require("./methods.js"), exports);
20
+ __exportStar(require("./framing.js"), exports);
@@ -0,0 +1,237 @@
1
+ import type { JsonRpcId } from './framing.js';
2
+ import type { DaemonProtocolVersion } from './version.js';
3
+ export declare const DAEMON_CONNECT = "daemon.connect";
4
+ export declare const DAEMON_PING = "daemon.ping";
5
+ export declare const DAEMON_INFO = "daemon.info";
6
+ /** Kernel-instance methods: the daemon is a neutral host for kernels. */
7
+ export declare const KERNEL_REQUIREMENTS = "kernel.requirements";
8
+ export declare const KERNEL_BOOT = "kernel.boot";
9
+ export declare const KERNEL_ATTACH = "kernel.attach";
10
+ export declare const KERNEL_LIST = "kernel.list";
11
+ export declare const KERNEL_STATUS = "kernel.status";
12
+ export declare const KERNEL_DISPOSE = "kernel.dispose";
13
+ export declare const KERNEL_KINDS = "kernel.kinds";
14
+ export declare const KERNEL_ROUTE = "kernel.route";
15
+ export declare const REQUEST_CANCEL = "request.cancel";
16
+ export declare const REQUEST_CANCELLED = "request.cancelled";
17
+ export declare const REQUEST_METHODS: readonly ["request.cancel"];
18
+ export type RequestMethod = (typeof REQUEST_METHODS)[number];
19
+ export declare const DAEMON_METHODS: readonly ["daemon.connect", "daemon.ping", "daemon.info"];
20
+ export type DaemonMethod = (typeof DAEMON_METHODS)[number];
21
+ export declare const KERNEL_METHODS: readonly ["kernel.requirements", "kernel.boot", "kernel.attach", "kernel.list", "kernel.status", "kernel.dispose", "kernel.kinds", "kernel.route"];
22
+ export type KernelMethod = (typeof KERNEL_METHODS)[number];
23
+ export interface DaemonClientIdentity {
24
+ readonly name: string;
25
+ readonly version: string;
26
+ }
27
+ /**
28
+ * Caller capability tier presented during `daemon.connect`.
29
+ *
30
+ * `ui` identifies a human-facing client (for example the editor UI) and `ai`
31
+ * identifies an autonomous caller. Each maps to host-session capabilities in
32
+ * the operator's daemon config.
33
+ */
34
+ export type DaemonCallerTier = 'ui' | 'ai';
35
+ /**
36
+ * Post-handshake connect parameters.
37
+ *
38
+ * Authentication, the caller principal, and the daemon home are fixed by
39
+ * the authenticated Noise session before this request is accepted. They are
40
+ * deliberately absent from this payload: a caller cannot re-assert or override
41
+ * its tier here.
42
+ */
43
+ export interface DaemonConnectParams {
44
+ readonly protocolVersion: string;
45
+ /** Client identity supplied by the authenticated client. */
46
+ readonly clientInfo?: DaemonClientIdentity;
47
+ /** Legacy client identity field retained for wire compatibility. */
48
+ readonly client?: DaemonClientIdentity;
49
+ readonly capabilities?: readonly string[];
50
+ }
51
+ export interface DaemonServerIdentity {
52
+ readonly name: string;
53
+ readonly version: string;
54
+ readonly pid: number;
55
+ }
56
+ export interface DaemonCapabilities {
57
+ readonly protocolVersion: DaemonProtocolVersion;
58
+ /** Methods this daemon serves. */
59
+ readonly methods: readonly string[];
60
+ }
61
+ export interface DaemonHandshakeResult {
62
+ readonly connectionId: string;
63
+ readonly protocolVersion: DaemonProtocolVersion;
64
+ /** Validated caller tier recorded on the daemon session. */
65
+ readonly tier: DaemonCallerTier;
66
+ readonly capabilities: DaemonCapabilities;
67
+ readonly server: DaemonServerIdentity;
68
+ }
69
+ /** Lifecycle state of a daemon-hosted kernel instance. */
70
+ export type KernelInstanceState = 'booting' | 'running' | 'shutting-down' | 'disposed';
71
+ /** One startup field a composition requires, as declared by a participant. */
72
+ export interface KernelRequirementField {
73
+ readonly name: string;
74
+ readonly type: string;
75
+ readonly required: boolean;
76
+ readonly description?: string;
77
+ /** Participant (module) that declared the field. */
78
+ readonly service: string;
79
+ /** Whether a client may set it (operator allowlist). */
80
+ readonly clientSettable: boolean;
81
+ }
82
+ export interface KernelRequirementsResult {
83
+ readonly fields: readonly KernelRequirementField[];
84
+ }
85
+ export interface KernelBootParams {
86
+ /** Startup options; only fields the operator allows clients to set. */
87
+ readonly options?: Readonly<Record<string, unknown>>;
88
+ }
89
+ export interface KernelInstanceParams {
90
+ readonly instanceId: string;
91
+ }
92
+ export interface KernelInstanceDescriptor {
93
+ readonly instanceId: string;
94
+ readonly state: KernelInstanceState;
95
+ readonly clientCount: number;
96
+ readonly lastUsedAt: string;
97
+ }
98
+ export interface KernelBootResult {
99
+ readonly instance: KernelInstanceDescriptor;
100
+ /** True when an existing kernel with identical options was reused. */
101
+ readonly reused: boolean;
102
+ /**
103
+ * Participants the kernel left out because required startup fields were
104
+ * missing. The kernel prunes them instead of refusing the boot (it refuses
105
+ * only for hardcore services or participants others depend on).
106
+ */
107
+ readonly pruned: readonly {
108
+ readonly participants: readonly string[];
109
+ readonly path: string;
110
+ readonly missingFields: readonly string[];
111
+ }[];
112
+ }
113
+ export interface KernelListResult {
114
+ /** Instances this connection is attached to. */
115
+ readonly instances: readonly KernelInstanceDescriptor[];
116
+ }
117
+ export interface KernelStatusResult {
118
+ readonly instance: KernelInstanceDescriptor | null;
119
+ }
120
+ export interface KernelDisposeResult {
121
+ readonly disposed: boolean;
122
+ }
123
+ /** Public description of one operation of a kind. */
124
+ export interface KernelKindOperation {
125
+ readonly description?: string;
126
+ readonly input?: Readonly<Record<string, unknown>>;
127
+ }
128
+ export interface KernelKindInfo {
129
+ readonly kind: string;
130
+ readonly description?: string;
131
+ readonly operations?: Readonly<Record<string, KernelKindOperation>>;
132
+ }
133
+ export interface KernelKindsResult {
134
+ readonly kinds: readonly KernelKindInfo[];
135
+ }
136
+ export interface KernelRouteParams extends KernelInstanceParams {
137
+ /** Brud syntax text. */
138
+ readonly text: string;
139
+ readonly stopOnFailure?: boolean;
140
+ readonly dryRun?: boolean;
141
+ readonly maxOperations?: number;
142
+ }
143
+ /** The Router's route result, as JSON. */
144
+ export type KernelRouteResult = Readonly<Record<string, unknown>>;
145
+ export interface DaemonPingParams {
146
+ readonly nonce?: string;
147
+ }
148
+ export interface DaemonPingResult {
149
+ readonly connectionId: string;
150
+ readonly timestamp: number;
151
+ readonly nonce?: string;
152
+ }
153
+ export type DaemonEmptyParams = Record<string, never>;
154
+ export interface DaemonInfoResult {
155
+ readonly connectionId: string;
156
+ readonly name: string;
157
+ readonly version: string;
158
+ readonly protocolVersion: DaemonProtocolVersion;
159
+ readonly pid: number;
160
+ readonly uptimeMs: number;
161
+ }
162
+ export interface RequestCancelParams {
163
+ /** Id of the in-flight request the caller is abandoning. */
164
+ readonly id: JsonRpcId;
165
+ }
166
+ /**
167
+ * Outcome the daemon observed for a cancellation.
168
+ *
169
+ * - `cancelled`: the signal was delivered and the operation settled as
170
+ * `aborted`, so the work stopped.
171
+ * - `not-abortable`: the signal was delivered but the operation completed
172
+ * normally; it does not honor cancellation.
173
+ * - `aborting`: the signal was delivered but the operation had not settled
174
+ * within the acknowledgement grace window.
175
+ * - `not-found`: no matching request was in flight (already finished).
176
+ * - `invalid`: the cancellation frame did not name a valid request id.
177
+ */
178
+ export type RequestCancelStatus = 'cancelled' | 'not-abortable' | 'aborting' | 'not-found' | 'invalid';
179
+ export interface RequestCancelledParams {
180
+ /** Id of the request the cancellation referred to. */
181
+ readonly id: JsonRpcId;
182
+ readonly status: RequestCancelStatus;
183
+ readonly message?: string;
184
+ }
185
+ export interface DaemonMethodMap {
186
+ readonly 'daemon.connect': {
187
+ readonly params: DaemonConnectParams;
188
+ readonly result: DaemonHandshakeResult;
189
+ };
190
+ readonly 'daemon.ping': {
191
+ readonly params: DaemonPingParams;
192
+ readonly result: DaemonPingResult;
193
+ };
194
+ readonly 'daemon.info': {
195
+ readonly params: DaemonEmptyParams;
196
+ readonly result: DaemonInfoResult;
197
+ };
198
+ readonly 'kernel.requirements': {
199
+ readonly params: DaemonEmptyParams;
200
+ readonly result: KernelRequirementsResult;
201
+ };
202
+ readonly 'kernel.boot': {
203
+ readonly params: KernelBootParams;
204
+ readonly result: KernelBootResult;
205
+ };
206
+ readonly 'kernel.attach': {
207
+ readonly params: KernelInstanceParams;
208
+ readonly result: KernelStatusResult;
209
+ };
210
+ readonly 'kernel.list': {
211
+ readonly params: DaemonEmptyParams;
212
+ readonly result: KernelListResult;
213
+ };
214
+ readonly 'kernel.status': {
215
+ readonly params: KernelInstanceParams;
216
+ readonly result: KernelStatusResult;
217
+ };
218
+ readonly 'kernel.dispose': {
219
+ readonly params: KernelInstanceParams;
220
+ readonly result: KernelDisposeResult;
221
+ };
222
+ readonly 'kernel.kinds': {
223
+ readonly params: KernelInstanceParams;
224
+ readonly result: KernelKindsResult;
225
+ };
226
+ readonly 'kernel.route': {
227
+ readonly params: KernelRouteParams;
228
+ readonly result: KernelRouteResult;
229
+ };
230
+ readonly 'request.cancel': {
231
+ readonly params: RequestCancelParams;
232
+ readonly result: RequestCancelledParams;
233
+ };
234
+ }
235
+ export type DaemonRequestMethod = keyof DaemonMethodMap;
236
+ export type DaemonMethodParams<TMethod extends DaemonRequestMethod> = DaemonMethodMap[TMethod]['params'];
237
+ export type DaemonMethodResult<TMethod extends DaemonRequestMethod> = DaemonMethodMap[TMethod]['result'];
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KERNEL_METHODS = exports.DAEMON_METHODS = exports.REQUEST_METHODS = exports.REQUEST_CANCELLED = exports.REQUEST_CANCEL = exports.KERNEL_ROUTE = exports.KERNEL_KINDS = exports.KERNEL_DISPOSE = exports.KERNEL_STATUS = exports.KERNEL_LIST = exports.KERNEL_ATTACH = exports.KERNEL_BOOT = exports.KERNEL_REQUIREMENTS = exports.DAEMON_INFO = exports.DAEMON_PING = exports.DAEMON_CONNECT = void 0;
4
+ exports.DAEMON_CONNECT = 'daemon.connect';
5
+ exports.DAEMON_PING = 'daemon.ping';
6
+ exports.DAEMON_INFO = 'daemon.info';
7
+ /** Kernel-instance methods: the daemon is a neutral host for kernels. */
8
+ exports.KERNEL_REQUIREMENTS = 'kernel.requirements';
9
+ exports.KERNEL_BOOT = 'kernel.boot';
10
+ exports.KERNEL_ATTACH = 'kernel.attach';
11
+ exports.KERNEL_LIST = 'kernel.list';
12
+ exports.KERNEL_STATUS = 'kernel.status';
13
+ exports.KERNEL_DISPOSE = 'kernel.dispose';
14
+ exports.KERNEL_KINDS = 'kernel.kinds';
15
+ exports.KERNEL_ROUTE = 'kernel.route';
16
+ exports.REQUEST_CANCEL = 'request.cancel';
17
+ exports.REQUEST_CANCELLED = 'request.cancelled';
18
+ exports.REQUEST_METHODS = [exports.REQUEST_CANCEL];
19
+ exports.DAEMON_METHODS = [exports.DAEMON_CONNECT, exports.DAEMON_PING, exports.DAEMON_INFO];
20
+ exports.KERNEL_METHODS = [
21
+ exports.KERNEL_REQUIREMENTS,
22
+ exports.KERNEL_BOOT,
23
+ exports.KERNEL_ATTACH,
24
+ exports.KERNEL_LIST,
25
+ exports.KERNEL_STATUS,
26
+ exports.KERNEL_DISPOSE,
27
+ exports.KERNEL_KINDS,
28
+ exports.KERNEL_ROUTE,
29
+ ];
@@ -0,0 +1,2 @@
1
+ export declare const DAEMON_PROTOCOL_VERSION: "1.0.0";
2
+ export type DaemonProtocolVersion = typeof DAEMON_PROTOCOL_VERSION;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DAEMON_PROTOCOL_VERSION = void 0;
4
+ exports.DAEMON_PROTOCOL_VERSION = '1.0.0';
@@ -0,0 +1,2 @@
1
+ export * from './messages';
2
+ export * from './daemon/index.js';
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./messages"), exports);
18
+ __exportStar(require("./daemon/index.js"), exports);
@@ -0,0 +1,260 @@
1
+ export declare const WEBVIEW_COMMANDS: readonly ["applyPatch", "previewPatch", "previewNextFile", "previewPrevFile", "previewAllFiles", "executeCurrentFile", "executeAllFiles", "rejectPreview", "doneDiffPreview", "closeDiffPreview", "hidePreviewNavigation", "showPreviewNavigation", "updatePreviewHeader", "openMainWindow", "extractStructure", "ready", "getHistory", "getRevertHistory", "revertSession", "revertOperations", "deleteSingleSession", "wipeHistory", "softDeleteSession", "restoreSession", "restoreAllSessions", "getTrashedSessions", "permanentDelete", "getSessionSnapshots", "openUnifiedResults", "openPromptLibrary", "openGetStarted", "previewNoChanges", "getSettings", "saveSettings", "getToolList", "getPrompts", "savePrompt", "deletePrompt", "getPromptVersions", "revertPrompt", "killProcess", "copyPrompt", "getActiveProcessIds"];
2
+ export type WebviewCommand = typeof WEBVIEW_COMMANDS[number];
3
+ export type ExtensionCommand = 'success' | 'error' | 'updatePreviewHeader' | 'showPreviewNavigation' | 'hidePreviewNavigation' | 'structureResult' | 'codebaseMetadataResult' | 'historyResult' | 'revertResult' | 'revertOperationsResult' | 'revertHistoryResult' | 'sessionDeleted' | 'historyWiped' | 'trashedSessionsResult' | 'sessionRestored' | 'allSessionsRestored' | 'searchFilesResult' | 'readResult' | 'diffPreviewResult' | 'filePatched' | 'sessionSnapshotsResult' | 'previewNoChanges' | 'settingsResult' | 'settingsSaved' | 'toolListResult' | 'promptsResult' | 'promptSaved' | 'promptDeleted' | 'promptVersionsResult' | 'promptReverted' | 'terminalChunk' | 'executionState' | 'activeProcessIds' | 'unifiedResults' | 'noPreviewableOps' | 'executeSuccess';
4
+ export interface PromptVersionPayload {
5
+ version: number;
6
+ content: string;
7
+ timestamp: string;
8
+ message?: string;
9
+ }
10
+ export interface PromptPayload {
11
+ id: string;
12
+ title: string;
13
+ description: string;
14
+ tags: string[];
15
+ createdAt: string;
16
+ updatedAt: string;
17
+ currentVersion: number;
18
+ scope: 'global' | 'workspace';
19
+ versions: PromptVersionPayload[];
20
+ }
21
+ export interface BrudSettingsPayload {
22
+ workspaceBoundaryEnabled?: boolean;
23
+ commandValidationEnabled?: boolean;
24
+ toolAllowList?: Record<string, boolean>;
25
+ readConcurrency?: number;
26
+ readMaxBatchFiles?: number;
27
+ readMaxAggregateBytes?: number;
28
+ }
29
+ export interface WebviewMessage {
30
+ command: WebviewCommand;
31
+ text?: string;
32
+ sessionId?: string;
33
+ targetState?: 'pre' | 'post';
34
+ operationIds?: string[];
35
+ triggeredBy?: 'user' | 'system';
36
+ permanentDelete?: boolean;
37
+ fileIndex?: number;
38
+ settings?: BrudSettingsPayload;
39
+ promptId?: string;
40
+ promptData?: PromptPayload;
41
+ promptScope?: 'global' | 'workspace';
42
+ version?: number;
43
+ processId?: string;
44
+ enabled?: boolean;
45
+ }
46
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
47
+ export declare function isWebviewCommand(value: unknown): value is WebviewCommand;
48
+ export declare function isWebviewMessage(value: unknown): value is WebviewMessage;
49
+ export interface ReportSection {
50
+ type: 'summary' | 'table' | 'details' | 'button' | 'copyButton' | 'text';
51
+ title?: string;
52
+ content?: string;
53
+ items?: Array<{
54
+ label: string;
55
+ value: string;
56
+ status?: 'success' | 'failed' | 'aborted' | 'interrupted';
57
+ }>;
58
+ buttonText?: string;
59
+ buttonAction?: WebviewCommand;
60
+ copyText?: string;
61
+ }
62
+ export interface UnifiedOperationResult {
63
+ toolKind: string;
64
+ data: unknown;
65
+ }
66
+ export interface UnifiedSessionResults {
67
+ operations: UnifiedOperationResult[];
68
+ }
69
+ export interface ExtensionMessage {
70
+ command: ExtensionCommand;
71
+ message?: string;
72
+ fileName?: string;
73
+ fileIndex?: number;
74
+ totalFiles?: number;
75
+ structure?: StructureResult;
76
+ structures?: StructureResult[];
77
+ codebaseMetadata?: CodebaseMetadataResult;
78
+ history?: HistorySessionResult[];
79
+ revertResult?: RevertSessionResult;
80
+ revertOperationsResult?: RevertSessionResult;
81
+ revertHistory?: RevertHistoryData[];
82
+ deletedCount?: number;
83
+ restoredCount?: number;
84
+ trashedSessions?: HistorySessionResult[];
85
+ searchResults?: SearchFilesResult;
86
+ readResult?: ReadResultData;
87
+ diffPreviewData?: DiffPreviewData;
88
+ snapshotData?: SessionSnapshotsResult | null;
89
+ structured?: ReportSection[];
90
+ settings?: BrudSettingsPayload;
91
+ source?: string;
92
+ warnings?: string[];
93
+ tools?: Array<{
94
+ kind: string;
95
+ name: string;
96
+ description: string;
97
+ }>;
98
+ prompts?: PromptPayload[];
99
+ prompt?: PromptPayload;
100
+ versions?: PromptVersionPayload[];
101
+ savedPromptId?: string;
102
+ errorMessage?: string;
103
+ processId?: string;
104
+ chunk?: string;
105
+ chunkIndex?: number;
106
+ streamDone?: boolean;
107
+ streamStatus?: 'success' | 'failed' | 'interrupted';
108
+ executing?: boolean;
109
+ results?: UnifiedSessionResults;
110
+ detail?: string;
111
+ processIds?: string[];
112
+ }
113
+ export interface HistorySessionResult {
114
+ sessionId: string;
115
+ timestamp: string;
116
+ originalPrompt: string;
117
+ status: 'success' | 'failure' | 'interrupted';
118
+ operationCount: number;
119
+ operationTypes: string[];
120
+ operations: OperationResult[];
121
+ filesAffected: string[];
122
+ metadataUsed: Record<string, unknown>;
123
+ terminalCommands: string[];
124
+ revertCommands: string[];
125
+ sessionTitle?: string;
126
+ sessionDescription?: string;
127
+ isDeleted?: boolean;
128
+ deletedAt?: string;
129
+ expiresAt?: string;
130
+ deletedBy?: 'user' | 'system';
131
+ deleteReason?: 'manual_delete' | 'manual_wipe' | 'retention_cleanup';
132
+ renewedAt?: string;
133
+ softDeleteHistory?: SoftDeleteEventResult[];
134
+ }
135
+ export interface SoftDeleteEventResult {
136
+ action: 'soft_delete' | 'restore';
137
+ at: string;
138
+ by: 'user' | 'system';
139
+ reason?: 'manual_delete' | 'manual_wipe' | 'retention_cleanup';
140
+ }
141
+ export interface PreviewHeaderData {
142
+ fileName: string;
143
+ fileIndex: number;
144
+ totalFiles: number;
145
+ }
146
+ export interface OperationResult {
147
+ operationId: string;
148
+ operationIndex: number;
149
+ kind: string;
150
+ status: 'success' | 'aborted' | 'failed' | 'interrupted';
151
+ message: string;
152
+ code?: string;
153
+ details?: string;
154
+ path: string;
155
+ to?: string;
156
+ title?: string;
157
+ description?: string;
158
+ fileResults?: {
159
+ modified: string[];
160
+ skipped: string[];
161
+ failed: string[];
162
+ fileErrors?: Array<{
163
+ path: string;
164
+ code?: string;
165
+ details?: string;
166
+ }>;
167
+ };
168
+ data?: {
169
+ command: string;
170
+ output: string;
171
+ exitCode: number | null;
172
+ duration: number;
173
+ success: boolean;
174
+ } | Array<{
175
+ command: string;
176
+ output: string;
177
+ exitCode: number | null;
178
+ duration: number;
179
+ success: boolean;
180
+ }>;
181
+ }
182
+ export interface ExecutionResult {
183
+ success: boolean;
184
+ message: string;
185
+ errors: string[];
186
+ operationResults: OperationResult[];
187
+ }
188
+ export interface StructureResult {
189
+ json: string;
190
+ directoryPath: string;
191
+ depth: number;
192
+ fileCount: number;
193
+ directoryCount: number;
194
+ }
195
+ export interface CodebaseMetadataResult {
196
+ root: string;
197
+ totalFiles: number;
198
+ totalFolders: number;
199
+ mostDenseFolder: string;
200
+ mostDenseCount: number;
201
+ }
202
+ export interface SearchFilesResult {
203
+ results: Array<{
204
+ path: string;
205
+ name: string;
206
+ extension: string;
207
+ directory: string;
208
+ size: number;
209
+ }>;
210
+ totalMatches: number;
211
+ truncated: boolean;
212
+ }
213
+ export interface DiffFileEntry {
214
+ filePath: string;
215
+ originalContent: string;
216
+ modifiedContent: string;
217
+ languageId?: string;
218
+ }
219
+ export interface DiffPreviewData {
220
+ files: DiffFileEntry[];
221
+ currentIndex: number;
222
+ }
223
+ export interface ReadFileEntry {
224
+ path: string;
225
+ content: string;
226
+ size: number;
227
+ isImported?: boolean;
228
+ importedFrom?: string;
229
+ startLine?: number;
230
+ endLine?: number;
231
+ totalLines?: number;
232
+ }
233
+ export interface ReadResultData {
234
+ files: ReadFileEntry[];
235
+ totalFiles: number;
236
+ totalSize: number;
237
+ }
238
+ export interface RevertSessionResult {
239
+ success: boolean;
240
+ message: string;
241
+ errors: string[];
242
+ }
243
+ export interface RevertHistoryData {
244
+ revertId: string;
245
+ timestamp: string;
246
+ targetState: 'pre' | 'post';
247
+ revertedOperationIds: string[];
248
+ status: 'success' | 'failed';
249
+ errorMessage?: string;
250
+ }
251
+ export interface SnapshotDataResult {
252
+ sessionId: string;
253
+ snapshotType: 'pre' | 'post';
254
+ files: Record<string, string>;
255
+ diffFromPrevious: string;
256
+ }
257
+ export interface SessionSnapshotsResult {
258
+ pre: SnapshotDataResult;
259
+ post: SnapshotDataResult;
260
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WEBVIEW_COMMANDS = void 0;
4
+ exports.isRecord = isRecord;
5
+ exports.isWebviewCommand = isWebviewCommand;
6
+ exports.isWebviewMessage = isWebviewMessage;
7
+ exports.WEBVIEW_COMMANDS = [
8
+ 'applyPatch',
9
+ 'previewPatch',
10
+ 'previewNextFile',
11
+ 'previewPrevFile',
12
+ 'previewAllFiles',
13
+ 'executeCurrentFile',
14
+ 'executeAllFiles',
15
+ 'rejectPreview',
16
+ 'doneDiffPreview',
17
+ 'closeDiffPreview',
18
+ 'hidePreviewNavigation',
19
+ 'showPreviewNavigation',
20
+ 'updatePreviewHeader',
21
+ 'openMainWindow',
22
+ 'extractStructure',
23
+ 'ready',
24
+ 'getHistory',
25
+ 'getRevertHistory',
26
+ 'revertSession',
27
+ 'revertOperations',
28
+ 'deleteSingleSession',
29
+ 'wipeHistory',
30
+ 'softDeleteSession',
31
+ 'restoreSession',
32
+ 'restoreAllSessions',
33
+ 'getTrashedSessions',
34
+ 'permanentDelete',
35
+ 'getSessionSnapshots',
36
+ 'openUnifiedResults',
37
+ 'openPromptLibrary',
38
+ 'openGetStarted',
39
+ 'previewNoChanges',
40
+ 'getSettings',
41
+ 'saveSettings',
42
+ 'getToolList',
43
+ 'getPrompts',
44
+ 'savePrompt',
45
+ 'deletePrompt',
46
+ 'getPromptVersions',
47
+ 'revertPrompt',
48
+ 'killProcess',
49
+ 'copyPrompt',
50
+ 'getActiveProcessIds',
51
+ ];
52
+ function isRecord(value) {
53
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
54
+ }
55
+ function isWebviewCommand(value) {
56
+ return typeof value === 'string' && exports.WEBVIEW_COMMANDS.includes(value);
57
+ }
58
+ function isWebviewMessage(value) {
59
+ return isRecord(value) && isWebviewCommand(value.command);
60
+ }
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@brud/protocol",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "default": "./dist/index.js"
10
+ },
11
+ "./package.json": "./package.json"
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "!dist/**/__tests__",
16
+ "!dist/**/__verification__",
17
+ "!dist/**/*.map"
18
+ ],
19
+ "engines": {
20
+ "node": ">=22"
21
+ },
22
+ "scripts": {
23
+ "build": "tsc"
24
+ },
25
+ "dependencies": {},
26
+ "description": "Wire types and error codes for the BrudOS daemon protocol (JSON-RPC over a Noise-secured local channel).",
27
+ "license": "Apache-2.0",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/rahatarch/brud.git",
31
+ "directory": "packages/protocol"
32
+ },
33
+ "homepage": "https://github.com/rahatarch/brud/tree/main/docs-next",
34
+ "bugs": {
35
+ "url": "https://github.com/rahatarch/brud/issues"
36
+ },
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
40
+ "keywords": [
41
+ "brud",
42
+ "brudos",
43
+ "kernel",
44
+ "participants"
45
+ ]
46
+ }