@uxnan/shared 0.0.1-alpha.20260627

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 (68) hide show
  1. package/README.md +96 -0
  2. package/dist/src/agents/agent-adapter.d.ts +78 -0
  3. package/dist/src/agents/agent-adapter.js +2 -0
  4. package/dist/src/agents/agent-adapter.js.map +1 -0
  5. package/dist/src/agents/agent-capabilities.d.ts +106 -0
  6. package/dist/src/agents/agent-capabilities.js +7 -0
  7. package/dist/src/agents/agent-capabilities.js.map +1 -0
  8. package/dist/src/agents/agent-config.d.ts +17 -0
  9. package/dist/src/agents/agent-config.js +2 -0
  10. package/dist/src/agents/agent-config.js.map +1 -0
  11. package/dist/src/constants.d.ts +30 -0
  12. package/dist/src/constants.js +31 -0
  13. package/dist/src/constants.js.map +1 -0
  14. package/dist/src/e2ee/envelope.d.ts +17 -0
  15. package/dist/src/e2ee/envelope.js +7 -0
  16. package/dist/src/e2ee/envelope.js.map +1 -0
  17. package/dist/src/e2ee/handshake.d.ts +82 -0
  18. package/dist/src/e2ee/handshake.js +14 -0
  19. package/dist/src/e2ee/handshake.js.map +1 -0
  20. package/dist/src/e2ee/pairing-payload.d.ts +44 -0
  21. package/dist/src/e2ee/pairing-payload.js +82 -0
  22. package/dist/src/e2ee/pairing-payload.js.map +1 -0
  23. package/dist/src/index.d.ts +25 -0
  24. package/dist/src/index.js +32 -0
  25. package/dist/src/index.js.map +1 -0
  26. package/dist/src/jsonrpc/envelope.d.ts +39 -0
  27. package/dist/src/jsonrpc/envelope.js +36 -0
  28. package/dist/src/jsonrpc/envelope.js.map +1 -0
  29. package/dist/src/jsonrpc/errors.d.ts +43 -0
  30. package/dist/src/jsonrpc/errors.js +73 -0
  31. package/dist/src/jsonrpc/errors.js.map +1 -0
  32. package/dist/src/jsonrpc/method-registry.d.ts +7 -0
  33. package/dist/src/jsonrpc/method-registry.js +79 -0
  34. package/dist/src/jsonrpc/method-registry.js.map +1 -0
  35. package/dist/src/jsonrpc/methods.d.ts +526 -0
  36. package/dist/src/jsonrpc/methods.js +2 -0
  37. package/dist/src/jsonrpc/methods.js.map +1 -0
  38. package/dist/src/jsonrpc/notifications.d.ts +85 -0
  39. package/dist/src/jsonrpc/notifications.js +19 -0
  40. package/dist/src/jsonrpc/notifications.js.map +1 -0
  41. package/dist/src/models/approval.d.ts +37 -0
  42. package/dist/src/models/approval.js +12 -0
  43. package/dist/src/models/approval.js.map +1 -0
  44. package/dist/src/models/git.d.ts +191 -0
  45. package/dist/src/models/git.js +8 -0
  46. package/dist/src/models/git.js.map +1 -0
  47. package/dist/src/models/project.d.ts +22 -0
  48. package/dist/src/models/project.js +5 -0
  49. package/dist/src/models/project.js.map +1 -0
  50. package/dist/src/models/session.d.ts +28 -0
  51. package/dist/src/models/session.js +7 -0
  52. package/dist/src/models/session.js.map +1 -0
  53. package/dist/src/models/thread.d.ts +104 -0
  54. package/dist/src/models/thread.js +8 -0
  55. package/dist/src/models/thread.js.map +1 -0
  56. package/dist/src/models/workspace.d.ts +133 -0
  57. package/dist/src/models/workspace.js +7 -0
  58. package/dist/src/models/workspace.js.map +1 -0
  59. package/dist/src/notifications/push-payload.d.ts +23 -0
  60. package/dist/src/notifications/push-payload.js +7 -0
  61. package/dist/src/notifications/push-payload.js.map +1 -0
  62. package/dist/src/validators/json-schema/schemas.d.ts +13 -0
  63. package/dist/src/validators/json-schema/schemas.js +82 -0
  64. package/dist/src/validators/json-schema/schemas.js.map +1 -0
  65. package/dist/src/validators/validate.d.ts +20 -0
  66. package/dist/src/validators/validate.js +46 -0
  67. package/dist/src/validators/validate.js.map +1 -0
  68. package/package.json +36 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pairing-payload.js","sourceRoot":"","sources":["../../../src/e2ee/pairing-payload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAsCzE,M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CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,cAAc,CAAC,EAAU,EAAE,GAAW;IACpD,IAAI,OAAgB,CAAC;IACrB,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAChE,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC;IACjD,CAAC;IACD,OAAO,sBAAsB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AAC9C,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC9C,OAAO,GAAG,GAAG,kBAAkB,CAAC;AAClC,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @uxnan/shared — JSON-RPC and E2EE contracts shared across the Uxnan
3
+ * ecosystem (bridge, relay, and the mobile app's manually-synced Dart types).
4
+ */
5
+ export * from './constants.js';
6
+ export * from './jsonrpc/envelope.js';
7
+ export * from './jsonrpc/errors.js';
8
+ export * from './jsonrpc/methods.js';
9
+ export * from './jsonrpc/method-registry.js';
10
+ export * from './jsonrpc/notifications.js';
11
+ export * from './e2ee/handshake.js';
12
+ export * from './e2ee/envelope.js';
13
+ export * from './e2ee/pairing-payload.js';
14
+ export * from './agents/agent-capabilities.js';
15
+ export * from './agents/agent-config.js';
16
+ export * from './agents/agent-adapter.js';
17
+ export * from './notifications/push-payload.js';
18
+ export * from './models/thread.js';
19
+ export * from './models/git.js';
20
+ export * from './models/workspace.js';
21
+ export * from './models/project.js';
22
+ export * from './models/session.js';
23
+ export * from './models/approval.js';
24
+ export * from './validators/validate.js';
25
+ export * from './validators/json-schema/schemas.js';
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @uxnan/shared — JSON-RPC and E2EE contracts shared across the Uxnan
3
+ * ecosystem (bridge, relay, and the mobile app's manually-synced Dart types).
4
+ */
5
+ export * from './constants.js';
6
+ // JSON-RPC
7
+ export * from './jsonrpc/envelope.js';
8
+ export * from './jsonrpc/errors.js';
9
+ export * from './jsonrpc/methods.js';
10
+ export * from './jsonrpc/method-registry.js';
11
+ export * from './jsonrpc/notifications.js';
12
+ // E2EE
13
+ export * from './e2ee/handshake.js';
14
+ export * from './e2ee/envelope.js';
15
+ export * from './e2ee/pairing-payload.js';
16
+ // Agents
17
+ export * from './agents/agent-capabilities.js';
18
+ export * from './agents/agent-config.js';
19
+ export * from './agents/agent-adapter.js';
20
+ // Notifications
21
+ export * from './notifications/push-payload.js';
22
+ // Models
23
+ export * from './models/thread.js';
24
+ export * from './models/git.js';
25
+ export * from './models/workspace.js';
26
+ export * from './models/project.js';
27
+ export * from './models/session.js';
28
+ export * from './models/approval.js';
29
+ // Validators
30
+ export * from './validators/validate.js';
31
+ export * from './validators/json-schema/schemas.js';
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,gBAAgB,CAAC;AAE/B,WAAW;AACX,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAE3C,OAAO;AACP,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAE1C,SAAS;AACT,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAE1C,gBAAgB;AAChB,cAAc,iCAAiC,CAAC;AAEhD,SAAS;AACT,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AAErC,aAAa;AACb,cAAc,0BAA0B,CAAC;AACzC,cAAc,qCAAqC,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * JSON-RPC 2.0 message envelope types and constructors.
3
+ *
4
+ * Source: architecture/02b-contracts-and-requirements.md (envelope format).
5
+ */
6
+ import { JSONRPC_VERSION } from '../constants.js';
7
+ import type { JsonRpcErrorObject } from './errors.js';
8
+ export type JsonRpcId = string | number;
9
+ export interface JsonRpcRequest<P = unknown> {
10
+ jsonrpc: typeof JSONRPC_VERSION;
11
+ id: JsonRpcId;
12
+ method: string;
13
+ params?: P;
14
+ }
15
+ export interface JsonRpcNotification<P = unknown> {
16
+ jsonrpc: typeof JSONRPC_VERSION;
17
+ method: string;
18
+ params?: P;
19
+ }
20
+ export interface JsonRpcSuccessResponse<R = unknown> {
21
+ jsonrpc: typeof JSONRPC_VERSION;
22
+ id: JsonRpcId;
23
+ result: R;
24
+ }
25
+ export interface JsonRpcErrorResponse {
26
+ jsonrpc: typeof JSONRPC_VERSION;
27
+ /** `null` when the request id could not be determined (e.g. parse error). */
28
+ id: JsonRpcId | null;
29
+ error: JsonRpcErrorObject;
30
+ }
31
+ export type JsonRpcResponse<R = unknown> = JsonRpcSuccessResponse<R> | JsonRpcErrorResponse;
32
+ export type JsonRpcMessage = JsonRpcRequest | JsonRpcNotification | JsonRpcResponse;
33
+ export declare function makeRequest<P>(id: JsonRpcId, method: string, params?: P): JsonRpcRequest<P>;
34
+ export declare function makeNotification<P>(method: string, params?: P): JsonRpcNotification<P>;
35
+ export declare function makeResponse<R>(id: JsonRpcId, result: R): JsonRpcSuccessResponse<R>;
36
+ export declare function makeErrorResponse(id: JsonRpcId | null, error: JsonRpcErrorObject): JsonRpcErrorResponse;
37
+ export declare function isJsonRpcRequest(msg: JsonRpcMessage): msg is JsonRpcRequest;
38
+ export declare function isJsonRpcNotification(msg: JsonRpcMessage): msg is JsonRpcNotification;
39
+ export declare function isJsonRpcResponse(msg: JsonRpcMessage): msg is JsonRpcResponse;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * JSON-RPC 2.0 message envelope types and constructors.
3
+ *
4
+ * Source: architecture/02b-contracts-and-requirements.md (envelope format).
5
+ */
6
+ import { JSONRPC_VERSION } from '../constants.js';
7
+ export function makeRequest(id, method, params) {
8
+ const msg = { jsonrpc: JSONRPC_VERSION, id, method };
9
+ if (params !== undefined) {
10
+ msg.params = params;
11
+ }
12
+ return msg;
13
+ }
14
+ export function makeNotification(method, params) {
15
+ const msg = { jsonrpc: JSONRPC_VERSION, method };
16
+ if (params !== undefined) {
17
+ msg.params = params;
18
+ }
19
+ return msg;
20
+ }
21
+ export function makeResponse(id, result) {
22
+ return { jsonrpc: JSONRPC_VERSION, id, result };
23
+ }
24
+ export function makeErrorResponse(id, error) {
25
+ return { jsonrpc: JSONRPC_VERSION, id, error };
26
+ }
27
+ export function isJsonRpcRequest(msg) {
28
+ return 'method' in msg && 'id' in msg && msg.id !== undefined;
29
+ }
30
+ export function isJsonRpcNotification(msg) {
31
+ return 'method' in msg && !('id' in msg);
32
+ }
33
+ export function isJsonRpcResponse(msg) {
34
+ return 'result' in msg || 'error' in msg;
35
+ }
36
+ //# sourceMappingURL=envelope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"envelope.js","sourceRoot":"","sources":["../../../src/jsonrpc/envelope.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAmClD,MAAM,UAAU,WAAW,CAAI,EAAa,EAAE,MAAc,EAAE,MAAU;IACtE,MAAM,GAAG,GAAsB,EAAE,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;IACxE,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAI,MAAc,EAAE,MAAU;IAC5D,MAAM,GAAG,GAA2B,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC;IACzE,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,YAAY,CAAI,EAAa,EAAE,MAAS;IACtD,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,EAAoB,EACpB,KAAyB;IAEzB,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,GAAmB;IAClD,OAAO,QAAQ,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,IAAI,GAAG,CAAC,EAAE,KAAK,SAAS,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,GAAmB;IACvD,OAAO,QAAQ,IAAI,GAAG,IAAI,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,GAAmB;IACnD,OAAO,QAAQ,IAAI,GAAG,IAAI,OAAO,IAAI,GAAG,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * JSON-RPC 2.0 error codes used across the Uxnan ecosystem.
3
+ *
4
+ * Standard codes (-32700..-32603) plus Uxnan-specific codes (-32000..-32008).
5
+ * Source: architecture/02b-contracts-and-requirements.md.
6
+ */
7
+ export declare const JsonRpcErrorCode: {
8
+ readonly ParseError: -32700;
9
+ readonly InvalidRequest: -32600;
10
+ readonly MethodNotFound: -32601;
11
+ readonly InvalidParams: -32602;
12
+ readonly InternalError: -32603;
13
+ readonly BridgeError: -32000;
14
+ readonly AuthenticationRequired: -32001;
15
+ readonly AgentNotRunning: -32002;
16
+ readonly GitOperationFailed: -32003;
17
+ readonly WorkspaceAccessDenied: -32004;
18
+ readonly BridgeVersionIncompatible: -32005;
19
+ readonly SessionExpired: -32006;
20
+ readonly ConfirmationRequired: -32007;
21
+ readonly ResourceNotFound: -32008;
22
+ };
23
+ export type JsonRpcErrorCode = (typeof JsonRpcErrorCode)[keyof typeof JsonRpcErrorCode];
24
+ /** Human-readable default messages for each error code. */
25
+ export declare const JSON_RPC_ERROR_MESSAGES: Record<JsonRpcErrorCode, string>;
26
+ /** Shape of the `error` member of a JSON-RPC error response. */
27
+ export interface JsonRpcErrorObject {
28
+ code: number;
29
+ message: string;
30
+ data?: unknown;
31
+ }
32
+ /**
33
+ * Error carrying a JSON-RPC error code, so handlers can throw a typed error
34
+ * that the transport layer maps to a JSON-RPC error response.
35
+ */
36
+ export declare class RpcError extends Error {
37
+ readonly code: number;
38
+ readonly data?: unknown;
39
+ constructor(code: number, message?: string, data?: unknown);
40
+ toErrorObject(): JsonRpcErrorObject;
41
+ static methodNotFound(method: string): RpcError;
42
+ static invalidParams(detail?: string, data?: unknown): RpcError;
43
+ }
@@ -0,0 +1,73 @@
1
+ /**
2
+ * JSON-RPC 2.0 error codes used across the Uxnan ecosystem.
3
+ *
4
+ * Standard codes (-32700..-32603) plus Uxnan-specific codes (-32000..-32008).
5
+ * Source: architecture/02b-contracts-and-requirements.md.
6
+ */
7
+ export const JsonRpcErrorCode = {
8
+ // Standard JSON-RPC 2.0
9
+ ParseError: -32700,
10
+ InvalidRequest: -32600,
11
+ MethodNotFound: -32601,
12
+ InvalidParams: -32602,
13
+ InternalError: -32603,
14
+ // Uxnan-specific
15
+ BridgeError: -32000,
16
+ AuthenticationRequired: -32001,
17
+ AgentNotRunning: -32002,
18
+ GitOperationFailed: -32003,
19
+ WorkspaceAccessDenied: -32004,
20
+ BridgeVersionIncompatible: -32005,
21
+ SessionExpired: -32006,
22
+ ConfirmationRequired: -32007,
23
+ ResourceNotFound: -32008,
24
+ };
25
+ /** Human-readable default messages for each error code. */
26
+ export const JSON_RPC_ERROR_MESSAGES = {
27
+ [JsonRpcErrorCode.ParseError]: 'Parse error',
28
+ [JsonRpcErrorCode.InvalidRequest]: 'Invalid request',
29
+ [JsonRpcErrorCode.MethodNotFound]: 'Method not found',
30
+ [JsonRpcErrorCode.InvalidParams]: 'Invalid params',
31
+ [JsonRpcErrorCode.InternalError]: 'Internal error',
32
+ [JsonRpcErrorCode.BridgeError]: 'Bridge error',
33
+ [JsonRpcErrorCode.AuthenticationRequired]: 'Authentication required',
34
+ [JsonRpcErrorCode.AgentNotRunning]: 'Agent not running',
35
+ [JsonRpcErrorCode.GitOperationFailed]: 'Git operation failed',
36
+ [JsonRpcErrorCode.WorkspaceAccessDenied]: 'Workspace access denied',
37
+ [JsonRpcErrorCode.BridgeVersionIncompatible]: 'Bridge version incompatible',
38
+ [JsonRpcErrorCode.SessionExpired]: 'Session expired',
39
+ [JsonRpcErrorCode.ConfirmationRequired]: 'Confirmation required',
40
+ [JsonRpcErrorCode.ResourceNotFound]: 'Resource not found',
41
+ };
42
+ /**
43
+ * Error carrying a JSON-RPC error code, so handlers can throw a typed error
44
+ * that the transport layer maps to a JSON-RPC error response.
45
+ */
46
+ export class RpcError extends Error {
47
+ code;
48
+ data;
49
+ constructor(code, message, data) {
50
+ const resolved = message ?? JSON_RPC_ERROR_MESSAGES[code] ?? 'Bridge error';
51
+ super(resolved);
52
+ this.name = 'RpcError';
53
+ this.code = code;
54
+ if (data !== undefined) {
55
+ this.data = data;
56
+ }
57
+ }
58
+ toErrorObject() {
59
+ const obj = { code: this.code, message: this.message };
60
+ if (this.data !== undefined) {
61
+ obj.data = this.data;
62
+ }
63
+ return obj;
64
+ }
65
+ static methodNotFound(method) {
66
+ return new RpcError(JsonRpcErrorCode.MethodNotFound, `Method not found: ${method}`);
67
+ }
68
+ static invalidParams(detail, data) {
69
+ const message = detail ? `Invalid params: ${detail}` : 'Invalid params';
70
+ return new RpcError(JsonRpcErrorCode.InvalidParams, message, data);
71
+ }
72
+ }
73
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/jsonrpc/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,wBAAwB;IACxB,UAAU,EAAE,CAAC,KAAK;IAClB,cAAc,EAAE,CAAC,KAAK;IACtB,cAAc,EAAE,CAAC,KAAK;IACtB,aAAa,EAAE,CAAC,KAAK;IACrB,aAAa,EAAE,CAAC,KAAK;IACrB,iBAAiB;IACjB,WAAW,EAAE,CAAC,KAAK;IACnB,sBAAsB,EAAE,CAAC,KAAK;IAC9B,eAAe,EAAE,CAAC,KAAK;IACvB,kBAAkB,EAAE,CAAC,KAAK;IAC1B,qBAAqB,EAAE,CAAC,KAAK;IAC7B,yBAAyB,EAAE,CAAC,KAAK;IACjC,cAAc,EAAE,CAAC,KAAK;IACtB,oBAAoB,EAAE,CAAC,KAAK;IAC5B,gBAAgB,EAAE,CAAC,KAAK;CAChB,CAAC;AAIX,2DAA2D;AAC3D,MAAM,CAAC,MAAM,uBAAuB,GAAqC;IACvE,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE,aAAa;IAC5C,CAAC,gBAAgB,CAAC,cAAc,CAAC,EAAE,iBAAiB;IACpD,CAAC,gBAAgB,CAAC,cAAc,CAAC,EAAE,kBAAkB;IACrD,CAAC,gBAAgB,CAAC,aAAa,CAAC,EAAE,gBAAgB;IAClD,CAAC,gBAAgB,CAAC,aAAa,CAAC,EAAE,gBAAgB;IAClD,CAAC,gBAAgB,CAAC,WAAW,CAAC,EAAE,cAAc;IAC9C,CAAC,gBAAgB,CAAC,sBAAsB,CAAC,EAAE,yBAAyB;IACpE,CAAC,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CAAC;IAED,MAAM,CAAC,aAAa,CAAC,MAAe,EAAE,IAAc;QAClD,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,mBAAmB,MAAM,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC;QACxE,OAAO,IAAI,QAAQ,CAAC,gBAAgB,CAAC,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACrE,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Runtime list of valid JSON-RPC method names, kept in lock-step with the
3
+ * compile-time {@link JsonRpcMethodRegistry} via the assertion below.
4
+ */
5
+ import type { JsonRpcMethodName } from './methods.js';
6
+ export declare const METHOD_NAMES: readonly ["thread/list", "thread/read", "thread/start", "thread/resume", "thread/fork", "thread/setModel", "thread/rename", "thread/setAccessMode", "thread/archive", "thread/unarchive", "thread/delete", "turn/list", "turn/read", "turn/send", "turn/cancel", "git/status", "git/diff", "git/commit", "git/push", "git/pull", "git/checkout", "git/createBranch", "git/createWorktree", "git/stage", "git/unstage", "git/discard", "git/createPr", "git/undoCommit", "git/branches", "git/switchBranch", "git/revert", "git/deleteBranch", "git/removeWorktree", "git/log", "git/commitShow", "workspace/readFile", "workspace/readImage", "workspace/list", "workspace/browseDirs", "workspace/checkpoint", "workspace/diffCheckpoint", "workspace/applyCheckpoint", "workspace/applyPatch", "workspace/exists", "project/list", "project/resolve", "agent/list", "agent/models", "auth/status", "auth/login", "auth/logout", "notifications/register", "notifications/update", "notifications/unregister", "bridge/status", "bridge/generatePairingQr", "bridge/connectedPhones", "bridge/disconnectPhone", "bridge/trustedDevices", "bridge/removeTrustedDevice"];
7
+ export declare function isKnownMethod(method: string): method is JsonRpcMethodName;
@@ -0,0 +1,79 @@
1
+ export const METHOD_NAMES = [
2
+ // Threads & turns
3
+ 'thread/list',
4
+ 'thread/read',
5
+ 'thread/start',
6
+ 'thread/resume',
7
+ 'thread/fork',
8
+ 'thread/setModel',
9
+ 'thread/rename',
10
+ 'thread/setAccessMode',
11
+ 'thread/archive',
12
+ 'thread/unarchive',
13
+ 'thread/delete',
14
+ 'turn/list',
15
+ 'turn/read',
16
+ 'turn/send',
17
+ 'turn/cancel',
18
+ // Git
19
+ 'git/status',
20
+ 'git/diff',
21
+ 'git/commit',
22
+ 'git/push',
23
+ 'git/pull',
24
+ 'git/checkout',
25
+ 'git/createBranch',
26
+ 'git/createWorktree',
27
+ 'git/stage',
28
+ 'git/unstage',
29
+ 'git/discard',
30
+ 'git/createPr',
31
+ 'git/undoCommit',
32
+ 'git/branches',
33
+ 'git/switchBranch',
34
+ 'git/revert',
35
+ 'git/deleteBranch',
36
+ 'git/removeWorktree',
37
+ 'git/log',
38
+ 'git/commitShow',
39
+ // Workspace
40
+ 'workspace/readFile',
41
+ 'workspace/readImage',
42
+ 'workspace/list',
43
+ 'workspace/browseDirs',
44
+ 'workspace/checkpoint',
45
+ 'workspace/diffCheckpoint',
46
+ 'workspace/applyCheckpoint',
47
+ 'workspace/applyPatch',
48
+ 'workspace/exists',
49
+ // Projects
50
+ 'project/list',
51
+ 'project/resolve',
52
+ // Agents
53
+ 'agent/list',
54
+ 'agent/models',
55
+ // Auth
56
+ 'auth/status',
57
+ 'auth/login',
58
+ 'auth/logout',
59
+ // Notifications (push)
60
+ 'notifications/register',
61
+ 'notifications/update',
62
+ 'notifications/unregister',
63
+ // Bridge control
64
+ 'bridge/status',
65
+ 'bridge/generatePairingQr',
66
+ 'bridge/connectedPhones',
67
+ 'bridge/disconnectPhone',
68
+ 'bridge/trustedDevices',
69
+ 'bridge/removeTrustedDevice',
70
+ ];
71
+ const _assertNamesAreMethods = true;
72
+ const _assertMethodsAreNames = true;
73
+ void _assertNamesAreMethods;
74
+ void _assertMethodsAreNames;
75
+ const METHOD_NAME_SET = new Set(METHOD_NAMES);
76
+ export function isKnownMethod(method) {
77
+ return METHOD_NAME_SET.has(method);
78
+ }
79
+ //# sourceMappingURL=method-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"method-registry.js","sourceRoot":"","sources":["../../../src/jsonrpc/method-registry.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,kBAAkB;IAClB,aAAa;IACb,aAAa;IACb,cAAc;IACd,eAAe;IACf,aAAa;IACb,iBAAiB;IACjB,eAAe;IACf,sBAAsB;IACtB,gBAAgB;IAChB,kBAAkB;IAClB,eAAe;IACf,WAAW;IACX,WAAW;IACX,WAAW;IACX,aAAa;IACb,MAAM;IACN,YAAY;IACZ,UAAU;IACV,YAAY;IACZ,UAAU;IACV,UAAU;IACV,cAAc;IACd,kBAAkB;IAClB,oBAAoB;IACpB,WAAW;IACX,aAAa;IACb,aAAa;IACb,cAAc;IACd,gBAAgB;IAChB,cAAc;IACd,kBAAkB;IAClB,YAAY;IACZ,kBAAkB;IAClB,oBAAoB;IACpB,SAAS;IACT,gBAAgB;IAChB,YAAY;IACZ,oBAAoB;IACpB,qBAAqB;IACrB,gBAAgB;IAChB,sBAAsB;IACtB,sBAAsB;IACtB,0BAA0B;IAC1B,2BAA2B;IAC3B,sBAAsB;IACtB,kBAAkB;IAClB,WAAW;IACX,cAAc;IACd,iBAAiB;IACjB,SAAS;IACT,YAAY;IACZ,cAAc;IACd,OAAO;IACP,aAAa;IACb,YAAY;IACZ,aAAa;IACb,uBAAuB;IACvB,wBAAwB;IACxB,sBAAsB;IACtB,0BAA0B;IAC1B,iBAAiB;IACjB,eAAe;IACf,0BAA0B;IAC1B,wBAAwB;IACxB,wBAAwB;IACxB,uBAAuB;IACvB,4BAA4B;CACpB,CAAC;AAQX,MAAM,sBAAsB,GAAqB,IAAI,CAAC;AACtD,MAAM,sBAAsB,GAAqB,IAAI,CAAC;AACtD,KAAK,sBAAsB,CAAC;AAC5B,KAAK,sBAAsB,CAAC;AAE5B,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;AAEnE,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,OAAO,eAAe,CAAC,G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