@openvcs/sdk 0.2.2 → 0.2.4

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.
Files changed (51) hide show
  1. package/README.md +76 -7
  2. package/lib/build.d.ts +28 -0
  3. package/lib/build.js +188 -0
  4. package/lib/cli.js +21 -2
  5. package/lib/dist.d.ts +4 -7
  6. package/lib/dist.js +67 -113
  7. package/lib/init.d.ts +2 -0
  8. package/lib/init.js +13 -8
  9. package/lib/runtime/contracts.d.ts +45 -0
  10. package/lib/runtime/contracts.js +4 -0
  11. package/lib/runtime/dispatcher.d.ts +16 -0
  12. package/lib/runtime/dispatcher.js +133 -0
  13. package/lib/runtime/errors.d.ts +5 -0
  14. package/lib/runtime/errors.js +26 -0
  15. package/lib/runtime/host.d.ts +10 -0
  16. package/lib/runtime/host.js +48 -0
  17. package/lib/runtime/index.d.ts +9 -0
  18. package/lib/runtime/index.js +166 -0
  19. package/lib/runtime/transport.d.ts +14 -0
  20. package/lib/runtime/transport.js +72 -0
  21. package/lib/types/host.d.ts +57 -0
  22. package/lib/types/host.js +4 -0
  23. package/lib/types/index.d.ts +4 -0
  24. package/lib/types/index.js +22 -0
  25. package/lib/types/plugin.d.ts +56 -0
  26. package/lib/types/plugin.js +4 -0
  27. package/lib/types/protocol.d.ts +77 -0
  28. package/lib/types/protocol.js +13 -0
  29. package/lib/types/vcs.d.ts +459 -0
  30. package/lib/types/vcs.js +4 -0
  31. package/package.json +16 -3
  32. package/src/lib/build.ts +229 -0
  33. package/src/lib/cli.ts +21 -2
  34. package/src/lib/dist.ts +76 -128
  35. package/src/lib/init.ts +13 -8
  36. package/src/lib/runtime/contracts.ts +52 -0
  37. package/src/lib/runtime/dispatcher.ts +185 -0
  38. package/src/lib/runtime/errors.ts +27 -0
  39. package/src/lib/runtime/host.ts +72 -0
  40. package/src/lib/runtime/index.ts +201 -0
  41. package/src/lib/runtime/transport.ts +93 -0
  42. package/src/lib/types/host.ts +71 -0
  43. package/src/lib/types/index.ts +7 -0
  44. package/src/lib/types/plugin.ts +110 -0
  45. package/src/lib/types/protocol.ts +97 -0
  46. package/src/lib/types/vcs.ts +579 -0
  47. package/test/build.test.js +95 -0
  48. package/test/cli.test.js +37 -0
  49. package/test/dist.test.js +239 -15
  50. package/test/init.test.js +25 -0
  51. package/test/runtime.test.js +118 -0
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ // Copyright © 2025-2026 OpenVCS Contributors
3
+ // SPDX-License-Identifier: GPL-3.0-or-later
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.createHost = exports.pluginError = exports.isPluginFailure = exports.createDefaultPluginDelegates = void 0;
6
+ exports.createPluginRuntime = createPluginRuntime;
7
+ exports.startPluginRuntime = startPluginRuntime;
8
+ const dispatcher_1 = require("./dispatcher");
9
+ const host_1 = require("./host");
10
+ const transport_1 = require("./transport");
11
+ var dispatcher_2 = require("./dispatcher");
12
+ Object.defineProperty(exports, "createDefaultPluginDelegates", { enumerable: true, get: function () { return dispatcher_2.createDefaultPluginDelegates; } });
13
+ var errors_1 = require("./errors");
14
+ Object.defineProperty(exports, "isPluginFailure", { enumerable: true, get: function () { return errors_1.isPluginFailure; } });
15
+ Object.defineProperty(exports, "pluginError", { enumerable: true, get: function () { return errors_1.pluginError; } });
16
+ var host_2 = require("./host");
17
+ Object.defineProperty(exports, "createHost", { enumerable: true, get: function () { return host_2.createHost; } });
18
+ /** Creates a reusable stdio JSON-RPC runtime for OpenVCS Node plugins. */
19
+ function createPluginRuntime(options = {}) {
20
+ let buffer = Buffer.alloc(0);
21
+ let processing = Promise.resolve();
22
+ let started = false;
23
+ let currentTransport = null;
24
+ let chunkLock = Promise.resolve();
25
+ const runtime = {
26
+ start(transport = defaultTransport()) {
27
+ if (started) {
28
+ return;
29
+ }
30
+ started = true;
31
+ currentTransport = transport;
32
+ transport.stdin.on('data', (chunk) => {
33
+ runtime.consumeChunk(chunk);
34
+ });
35
+ transport.stdin.on('error', () => {
36
+ process.exit(1);
37
+ });
38
+ options.onStart?.();
39
+ },
40
+ stop() {
41
+ if (!started) {
42
+ return;
43
+ }
44
+ started = false;
45
+ processing = processing
46
+ .catch(async (error) => {
47
+ const errorMessage = error instanceof Error ? error.message : String(error);
48
+ console.error(`[runtime] shutdown error: ${errorMessage}`);
49
+ const err = error instanceof Error ? error : new Error(errorMessage);
50
+ await options.onShutdown?.(err);
51
+ })
52
+ .then(async () => {
53
+ await options.onShutdown?.();
54
+ });
55
+ currentTransport = null;
56
+ },
57
+ consumeChunk(chunk) {
58
+ if (!started) {
59
+ return;
60
+ }
61
+ const lock = chunkLock.then(() => {
62
+ buffer = Buffer.concat([buffer, normalizeChunk(chunk)]);
63
+ const parsed = (0, transport_1.parseFramedMessages)(buffer);
64
+ buffer = parsed.remainder;
65
+ for (const request of parsed.messages) {
66
+ processing = processing
67
+ .then(async () => {
68
+ await runtime.dispatchRequest(request);
69
+ })
70
+ .catch((error) => {
71
+ const message = error instanceof Error ? error.message : String(error || 'unknown plugin processing error');
72
+ const host = createRuntimeHost(currentTransport, options.logTarget);
73
+ host.error(message);
74
+ });
75
+ }
76
+ });
77
+ chunkLock = lock;
78
+ },
79
+ async dispatchRequest(request) {
80
+ const id = request.id;
81
+ const host = createRuntimeHost(currentTransport, options.logTarget);
82
+ const method = asTrimmedString(request.method);
83
+ const validationErrors = [];
84
+ if (!method)
85
+ validationErrors.push('missing method');
86
+ if (typeof id !== 'number' && typeof id !== 'string')
87
+ validationErrors.push(`invalid id type: ${typeof id}`);
88
+ if (validationErrors.length > 0) {
89
+ host.error(`invalid request: ${validationErrors.join(', ')}`);
90
+ return;
91
+ }
92
+ const dispatcher = (0, dispatcher_1.createRuntimeDispatcher)(options, host, {
93
+ async sendResult(requestId, result) {
94
+ await sendMessage(currentTransport, {
95
+ jsonrpc: '2.0',
96
+ id: requestId,
97
+ result,
98
+ });
99
+ },
100
+ async sendError(requestId, code, message, data) {
101
+ await sendMessage(currentTransport, {
102
+ jsonrpc: '2.0',
103
+ id: requestId,
104
+ error: {
105
+ code,
106
+ message,
107
+ ...(data == null ? {} : { data }),
108
+ },
109
+ });
110
+ },
111
+ });
112
+ const methodName = method;
113
+ const params = asRecord(request.params) ?? {};
114
+ const requestId = id;
115
+ await dispatcher(requestId, methodName, params);
116
+ },
117
+ };
118
+ return runtime;
119
+ }
120
+ /** Starts a previously created plugin runtime on process stdio. */
121
+ function startPluginRuntime(runtime, transport) {
122
+ runtime.start(transport);
123
+ }
124
+ /** Returns the default stdio transport used by the runtime. */
125
+ function defaultTransport() {
126
+ return {
127
+ stdin: process.stdin,
128
+ stdout: process.stdout,
129
+ };
130
+ }
131
+ /** Sends one JSON-RPC response or notification through the active transport. */
132
+ async function sendMessage(transport, value) {
133
+ await (0, transport_1.writeFramedMessage)((transport ?? defaultTransport()).stdout, value);
134
+ }
135
+ /** Builds the host helper for the currently active transport. */
136
+ function createRuntimeHost(transport, logTarget) {
137
+ return (0, host_1.createHost)(async (method, params) => {
138
+ await sendMessage(transport, {
139
+ jsonrpc: '2.0',
140
+ method,
141
+ params,
142
+ });
143
+ }, { logTarget });
144
+ }
145
+ /** Type guard that returns true if the value is a valid RequestParams object. */
146
+ function isRequestParams(value) {
147
+ if (value == null || typeof value !== 'object' || Array.isArray(value)) {
148
+ return false;
149
+ }
150
+ return true;
151
+ }
152
+ /** Coerces unknown request method values into trimmed strings. Returns null for non-strings. */
153
+ function asTrimmedString(value) {
154
+ return typeof value === 'string' ? value.trim() : null;
155
+ }
156
+ /** Coerces unknown params to a Record, returning null for invalid input. */
157
+ function asRecord(value) {
158
+ if (isRequestParams(value)) {
159
+ return value;
160
+ }
161
+ return null;
162
+ }
163
+ /** Normalizes incoming data chunks to UTF-8 buffers. */
164
+ function normalizeChunk(chunk) {
165
+ return Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk, 'utf8');
166
+ }
@@ -0,0 +1,14 @@
1
+ import type { JsonRpcRequest } from '../types';
2
+ /** Describes the parsed result of draining one buffered transport chunk. */
3
+ export interface FramedMessageParseResult {
4
+ /** Stores the decoded requests found in the current buffer. */
5
+ messages: JsonRpcRequest[];
6
+ /** Stores any remaining incomplete bytes. */
7
+ remainder: Buffer;
8
+ }
9
+ /** Serializes one JSON-RPC payload into an LSP-style framed stdio message. */
10
+ export declare function serializeFramedMessage(value: unknown): Buffer;
11
+ /** Writes one JSON-RPC payload to the supplied stdout-like stream. */
12
+ export declare function writeFramedMessage(writer: NodeJS.WritableStream, value: unknown): Promise<void>;
13
+ /** Parses all complete framed JSON-RPC requests currently present in a buffer. */
14
+ export declare function parseFramedMessages(buffer: Buffer): FramedMessageParseResult;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ // Copyright © 2025-2026 OpenVCS Contributors
3
+ // SPDX-License-Identifier: GPL-3.0-or-later
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.serializeFramedMessage = serializeFramedMessage;
6
+ exports.writeFramedMessage = writeFramedMessage;
7
+ exports.parseFramedMessages = parseFramedMessages;
8
+ /** Serializes one JSON-RPC payload into an LSP-style framed stdio message. */
9
+ function serializeFramedMessage(value) {
10
+ const payload = Buffer.from(JSON.stringify(value), 'utf8');
11
+ const header = Buffer.from(`Content-Length: ${payload.length}\r\n\r\n`, 'utf8');
12
+ return Buffer.concat([header, payload]);
13
+ }
14
+ /** Writes one JSON-RPC payload to the supplied stdout-like stream. */
15
+ async function writeFramedMessage(writer, value) {
16
+ try {
17
+ const serialized = serializeFramedMessage(value);
18
+ const canContinue = writer.write(serialized);
19
+ if (!canContinue) {
20
+ await new Promise((resolve) => writer.once('drain', resolve));
21
+ }
22
+ }
23
+ catch (error) {
24
+ console.error(`[transport] failed to write framed message: ${error instanceof Error ? error.message : String(error)}`);
25
+ }
26
+ }
27
+ /** Parses all complete framed JSON-RPC requests currently present in a buffer. */
28
+ function parseFramedMessages(buffer) {
29
+ const messages = [];
30
+ let remainder = buffer;
31
+ while (true) {
32
+ const marker = remainder.indexOf('\r\n\r\n');
33
+ if (marker < 0) {
34
+ return { messages, remainder };
35
+ }
36
+ const header = remainder.subarray(0, marker).toString('utf8');
37
+ const contentLength = readContentLength(header);
38
+ if (contentLength == null) {
39
+ remainder = remainder.subarray(marker + 4);
40
+ continue;
41
+ }
42
+ const totalLength = marker + 4 + contentLength;
43
+ if (remainder.length < totalLength) {
44
+ return { messages, remainder };
45
+ }
46
+ const payload = remainder.subarray(marker + 4, totalLength).toString('utf8');
47
+ remainder = remainder.subarray(totalLength);
48
+ try {
49
+ messages.push(JSON.parse(payload));
50
+ }
51
+ catch {
52
+ continue;
53
+ }
54
+ }
55
+ }
56
+ /** Reads one `Content-Length` header value from a framed message header block. */
57
+ function readContentLength(header) {
58
+ const headerLines = header.split(/\r?\n/g);
59
+ for (const line of headerLines) {
60
+ const separatorIndex = line.indexOf(':');
61
+ if (separatorIndex < 0) {
62
+ continue;
63
+ }
64
+ const name = line.slice(0, separatorIndex).trim().toLowerCase();
65
+ if (name !== 'content-length') {
66
+ continue;
67
+ }
68
+ const rawValue = Number(line.slice(separatorIndex + 1).trim());
69
+ return Number.isFinite(rawValue) && rawValue >= 0 ? rawValue : null;
70
+ }
71
+ return null;
72
+ }
@@ -0,0 +1,57 @@
1
+ import type { JsonRpcId } from './protocol';
2
+ /** Enumerates the log levels accepted by the host log notification. */
3
+ export type HostLogLevel = 'error' | 'info';
4
+ /** Describes one `host.log` notification payload. */
5
+ export interface HostLogParams {
6
+ /** Stores the emitted log severity. */
7
+ level: HostLogLevel;
8
+ /** Stores the plugin log target name. */
9
+ target: string;
10
+ /** Stores the log message text. */
11
+ message: string;
12
+ }
13
+ /** Describes one `host.ui_notify` notification payload. */
14
+ export interface HostUiNotifyParams {
15
+ /** Stores the message shown by the host UI. */
16
+ message: string;
17
+ /** Stores an optional severity or category understood by the host. */
18
+ level?: string;
19
+ }
20
+ /** Describes one `host.status_set` notification payload. */
21
+ export interface HostStatusSetParams {
22
+ /** Stores the status text shown by the host. */
23
+ text: string;
24
+ }
25
+ /** Describes one `host.event_emit` notification payload. */
26
+ export interface HostEventEmitParams {
27
+ /** Stores the plugin-defined event name. */
28
+ name: string;
29
+ /** Stores the event payload forwarded to the host. */
30
+ payload?: Record<string, unknown>;
31
+ }
32
+ /** Describes one `vcs.event` notification payload. */
33
+ export interface VcsEventParams {
34
+ /** Stores the repository session id associated with the event. */
35
+ session_id: string;
36
+ /** Stores the originating request id when one exists. */
37
+ request_id: JsonRpcId | null;
38
+ /** Stores the event payload. */
39
+ event: Record<string, unknown>;
40
+ }
41
+ /** Describes the host helper API available inside delegate handlers. */
42
+ export interface PluginHost {
43
+ /** Emits a `host.log` notification. */
44
+ log(level: HostLogLevel, message: string): void;
45
+ /** Emits an informational `host.log` notification. */
46
+ info(message: string): void;
47
+ /** Emits an error `host.log` notification. */
48
+ error(message: string): void;
49
+ /** Emits a `host.ui_notify` notification. */
50
+ uiNotify(params: HostUiNotifyParams): void;
51
+ /** Emits a `host.status_set` notification. */
52
+ statusSet(params: HostStatusSetParams): void;
53
+ /** Emits a `host.event_emit` notification. */
54
+ emitEvent(params: HostEventEmitParams): void;
55
+ /** Emits a `vcs.event` notification. */
56
+ emitVcsEvent(sessionId: string, requestId: JsonRpcId | null, event: Record<string, unknown>): void;
57
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ // Copyright © 2025-2026 OpenVCS Contributors
3
+ // SPDX-License-Identifier: GPL-3.0-or-later
4
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ export * from './host';
2
+ export * from './plugin';
3
+ export * from './protocol';
4
+ export * from './vcs';
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ // Copyright © 2025-2026 OpenVCS Contributors
3
+ // SPDX-License-Identifier: GPL-3.0-or-later
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ __exportStar(require("./host"), exports);
20
+ __exportStar(require("./plugin"), exports);
21
+ __exportStar(require("./protocol"), exports);
22
+ __exportStar(require("./vcs"), exports);
@@ -0,0 +1,56 @@
1
+ import type { RequestParams, RpcMethodHandler } from './protocol';
2
+ /** Describes the capability flags reported during plugin initialization. */
3
+ export interface PluginImplements {
4
+ /** Indicates whether the plugin responds to `plugin.*` methods. */
5
+ plugin: boolean;
6
+ /** Indicates whether the plugin responds to `vcs.*` methods. */
7
+ vcs: boolean;
8
+ }
9
+ /** Describes the handshake payload returned from `plugin.initialize`. */
10
+ export interface PluginInitializeResult {
11
+ /** Stores the SDK protocol version mirrored from the host. */
12
+ protocol_version: number;
13
+ /** Stores the feature groups implemented by the plugin. */
14
+ implements: PluginImplements;
15
+ }
16
+ /** Describes one optional override returned by a custom initialize handler. */
17
+ export type PluginInitializeOverride = Partial<PluginInitializeResult>;
18
+ /** Describes one plugin-contributed menu definition. */
19
+ export type PluginMenuDefinition = Record<string, unknown>;
20
+ /** Describes one plugin settings value payload. */
21
+ export type PluginSettingsValue = Record<string, unknown>;
22
+ /** Describes the params shape for plugin action handling. */
23
+ export interface PluginHandleActionParams extends RequestParams {
24
+ /** Stores the action id selected by the user. */
25
+ action_id?: string;
26
+ }
27
+ /** Describes the params shape for plugin settings callbacks. */
28
+ export interface PluginSettingsValuesParams extends RequestParams {
29
+ /** Stores the list of values supplied by the host. */
30
+ values?: unknown[];
31
+ }
32
+ /** Enumerates all host `plugin.*` method names. */
33
+ export type PluginMethodName = 'plugin.initialize' | 'plugin.init' | 'plugin.deinit' | 'plugin.get_menus' | 'plugin.handle_action' | 'plugin.settings.defaults' | 'plugin.settings.on_load' | 'plugin.settings.on_apply' | 'plugin.settings.on_save' | 'plugin.settings.on_reset';
34
+ /** Describes the delegate map supported by the SDK runtime for `plugin.*`. */
35
+ export interface PluginDelegates<TContext = unknown> {
36
+ /** Overrides the default handshake payload returned by `plugin.initialize`. */
37
+ 'plugin.initialize'?: RpcMethodHandler<RequestParams, PluginInitializeOverride, TContext>;
38
+ /** Handles plugin startup work. */
39
+ 'plugin.init'?: RpcMethodHandler<RequestParams, null, TContext>;
40
+ /** Handles plugin shutdown work. */
41
+ 'plugin.deinit'?: RpcMethodHandler<RequestParams, null, TContext>;
42
+ /** Returns plugin-contributed menus. */
43
+ 'plugin.get_menus'?: RpcMethodHandler<RequestParams, PluginMenuDefinition[], TContext>;
44
+ /** Handles a contributed plugin action. */
45
+ 'plugin.handle_action'?: RpcMethodHandler<PluginHandleActionParams, null, TContext>;
46
+ /** Returns the default settings values for the plugin. */
47
+ 'plugin.settings.defaults'?: RpcMethodHandler<RequestParams, PluginSettingsValue[], TContext>;
48
+ /** Transforms settings values when they are loaded. */
49
+ 'plugin.settings.on_load'?: RpcMethodHandler<PluginSettingsValuesParams, unknown[], TContext>;
50
+ /** Applies settings values to the running plugin. */
51
+ 'plugin.settings.on_apply'?: RpcMethodHandler<PluginSettingsValuesParams, null, TContext>;
52
+ /** Transforms settings values before they are saved. */
53
+ 'plugin.settings.on_save'?: RpcMethodHandler<PluginSettingsValuesParams, unknown[], TContext>;
54
+ /** Resets plugin settings state. */
55
+ 'plugin.settings.on_reset'?: RpcMethodHandler<PluginSettingsValuesParams, null, TContext>;
56
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ // Copyright © 2025-2026 OpenVCS Contributors
3
+ // SPDX-License-Identifier: GPL-3.0-or-later
4
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,77 @@
1
+ /** Stores the protocol version mirrored from the backend host contract. */
2
+ export declare const PROTOCOL_VERSION = 1;
3
+ /** Stores the reserved JSON-RPC error code used for plugin failures. */
4
+ export declare const PLUGIN_FAILURE_CODE = -32001;
5
+ /** Stores the reserved JSON-RPC error code used for uncaught plugin errors. */
6
+ export declare const PLUGIN_INTERNAL_ERROR_CODE = -32002;
7
+ /** Stores the reserved JSON-RPC error code used for protocol version mismatches. */
8
+ export declare const PROTOCOL_VERSION_MISMATCH_CODE = -32003;
9
+ /** Represents a JSON-RPC request identifier. */
10
+ export type JsonRpcId = number | string;
11
+ /** Represents an untyped JSON-RPC parameter object. */
12
+ export type RequestParams = Record<string, unknown>;
13
+ /** Describes one JSON-RPC error payload. */
14
+ export interface JsonRpcError {
15
+ /** Stores the machine-readable error code. */
16
+ code: number;
17
+ /** Stores the human-readable error message. */
18
+ message: string;
19
+ /** Stores optional structured error details. */
20
+ data?: unknown;
21
+ }
22
+ /** Describes one JSON-RPC request received from the host. */
23
+ export interface JsonRpcRequest {
24
+ /** Stores the JSON-RPC protocol marker when present. */
25
+ jsonrpc?: string;
26
+ /** Stores the request identifier used to match responses. */
27
+ id?: JsonRpcId;
28
+ /** Stores the requested method name. */
29
+ method?: unknown;
30
+ /** Stores the untyped parameter payload. */
31
+ params?: unknown;
32
+ }
33
+ /** Describes one JSON-RPC notification emitted without an id. */
34
+ export interface JsonRpcNotification {
35
+ /** Stores the JSON-RPC protocol marker. */
36
+ jsonrpc: '2.0';
37
+ /** Stores the notification method name. */
38
+ method: string;
39
+ /** Stores the notification payload. */
40
+ params?: unknown;
41
+ }
42
+ /** Describes one JSON-RPC success response. */
43
+ export interface JsonRpcSuccessResponse<TResult = unknown> {
44
+ /** Stores the JSON-RPC protocol marker. */
45
+ jsonrpc: '2.0';
46
+ /** Stores the request identifier being answered. */
47
+ id: JsonRpcId;
48
+ /** Stores the successful result payload. */
49
+ result: TResult;
50
+ }
51
+ /** Describes one JSON-RPC error response. */
52
+ export interface JsonRpcErrorResponse {
53
+ /** Stores the JSON-RPC protocol marker. */
54
+ jsonrpc: '2.0';
55
+ /** Stores the request identifier being answered. */
56
+ id: JsonRpcId;
57
+ /** Stores the structured error payload. */
58
+ error: JsonRpcError;
59
+ }
60
+ /** Describes one plugin-specific failure payload surfaced to the host. */
61
+ export interface PluginFailure {
62
+ /** Stores the reserved JSON-RPC error code for plugin failures. */
63
+ code: typeof PLUGIN_FAILURE_CODE;
64
+ /** Stores the top-level failure message. */
65
+ message: string;
66
+ /** Stores nested plugin-specific failure details. */
67
+ data: PluginFailureData;
68
+ }
69
+ /** Describes the structured data embedded in a plugin failure. */
70
+ export interface PluginFailureData {
71
+ /** Stores the stable plugin-specific error code. */
72
+ code: string;
73
+ /** Stores the user-facing failure message. */
74
+ message: string;
75
+ }
76
+ /** Describes one method handler used by the SDK delegate runtime. */
77
+ export type RpcMethodHandler<TParams extends RequestParams = RequestParams, TResult = unknown, TContext = unknown> = (params: TParams, context: TContext) => TResult | Promise<TResult>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ // Copyright © 2025-2026 OpenVCS Contributors
3
+ // SPDX-License-Identifier: GPL-3.0-or-later
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.PROTOCOL_VERSION_MISMATCH_CODE = exports.PLUGIN_INTERNAL_ERROR_CODE = exports.PLUGIN_FAILURE_CODE = exports.PROTOCOL_VERSION = void 0;
6
+ /** Stores the protocol version mirrored from the backend host contract. */
7
+ exports.PROTOCOL_VERSION = 1;
8
+ /** Stores the reserved JSON-RPC error code used for plugin failures. */
9
+ exports.PLUGIN_FAILURE_CODE = -32001;
10
+ /** Stores the reserved JSON-RPC error code used for uncaught plugin errors. */
11
+ exports.PLUGIN_INTERNAL_ERROR_CODE = -32002;
12
+ /** Stores the reserved JSON-RPC error code used for protocol version mismatches. */
13
+ exports.PROTOCOL_VERSION_MISMATCH_CODE = -32003;