@openvcs/sdk 0.2.3 → 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 (40) hide show
  1. package/README.md +30 -1
  2. package/lib/init.d.ts +2 -0
  3. package/lib/init.js +6 -3
  4. package/lib/runtime/contracts.d.ts +45 -0
  5. package/lib/runtime/contracts.js +4 -0
  6. package/lib/runtime/dispatcher.d.ts +16 -0
  7. package/lib/runtime/dispatcher.js +133 -0
  8. package/lib/runtime/errors.d.ts +5 -0
  9. package/lib/runtime/errors.js +26 -0
  10. package/lib/runtime/host.d.ts +10 -0
  11. package/lib/runtime/host.js +48 -0
  12. package/lib/runtime/index.d.ts +9 -0
  13. package/lib/runtime/index.js +166 -0
  14. package/lib/runtime/transport.d.ts +14 -0
  15. package/lib/runtime/transport.js +72 -0
  16. package/lib/types/host.d.ts +57 -0
  17. package/lib/types/host.js +4 -0
  18. package/lib/types/index.d.ts +4 -0
  19. package/lib/types/index.js +22 -0
  20. package/lib/types/plugin.d.ts +56 -0
  21. package/lib/types/plugin.js +4 -0
  22. package/lib/types/protocol.d.ts +77 -0
  23. package/lib/types/protocol.js +13 -0
  24. package/lib/types/vcs.d.ts +459 -0
  25. package/lib/types/vcs.js +4 -0
  26. package/package.json +14 -1
  27. package/src/lib/init.ts +6 -3
  28. package/src/lib/runtime/contracts.ts +52 -0
  29. package/src/lib/runtime/dispatcher.ts +185 -0
  30. package/src/lib/runtime/errors.ts +27 -0
  31. package/src/lib/runtime/host.ts +72 -0
  32. package/src/lib/runtime/index.ts +201 -0
  33. package/src/lib/runtime/transport.ts +93 -0
  34. package/src/lib/types/host.ts +71 -0
  35. package/src/lib/types/index.ts +7 -0
  36. package/src/lib/types/plugin.ts +110 -0
  37. package/src/lib/types/protocol.ts +97 -0
  38. package/src/lib/types/vcs.ts +579 -0
  39. package/test/init.test.js +25 -0
  40. package/test/runtime.test.js +118 -0
@@ -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;