@essentialai/cogent 1.0.0

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 (85) hide show
  1. package/dist/errors/bridge-error.d.ts +31 -0
  2. package/dist/errors/bridge-error.d.ts.map +1 -0
  3. package/dist/errors/bridge-error.js +45 -0
  4. package/dist/errors/bridge-error.js.map +1 -0
  5. package/dist/errors/codes.d.ts +43 -0
  6. package/dist/errors/codes.d.ts.map +1 -0
  7. package/dist/errors/codes.js +47 -0
  8. package/dist/errors/codes.js.map +1 -0
  9. package/dist/errors/http-status.d.ts +7 -0
  10. package/dist/errors/http-status.d.ts.map +1 -0
  11. package/dist/errors/http-status.js +43 -0
  12. package/dist/errors/http-status.js.map +1 -0
  13. package/dist/errors/index.d.ts +5 -0
  14. package/dist/errors/index.d.ts.map +1 -0
  15. package/dist/errors/index.js +4 -0
  16. package/dist/errors/index.js.map +1 -0
  17. package/dist/file/config.d.ts +17 -0
  18. package/dist/file/config.d.ts.map +1 -0
  19. package/dist/file/config.js +26 -0
  20. package/dist/file/config.js.map +1 -0
  21. package/dist/file/index.d.ts +27 -0
  22. package/dist/file/index.d.ts.map +1 -0
  23. package/dist/file/index.js +24 -0
  24. package/dist/file/index.js.map +1 -0
  25. package/dist/file/state.d.ts +22 -0
  26. package/dist/file/state.d.ts.map +1 -0
  27. package/dist/file/state.js +18 -0
  28. package/dist/file/state.js.map +1 -0
  29. package/dist/helpers/ids.d.ts +19 -0
  30. package/dist/helpers/ids.d.ts.map +1 -0
  31. package/dist/helpers/ids.js +26 -0
  32. package/dist/helpers/ids.js.map +1 -0
  33. package/dist/helpers/index.d.ts +3 -0
  34. package/dist/helpers/index.d.ts.map +1 -0
  35. package/dist/helpers/index.js +3 -0
  36. package/dist/helpers/index.js.map +1 -0
  37. package/dist/helpers/validation.d.ts +21 -0
  38. package/dist/helpers/validation.d.ts.map +1 -0
  39. package/dist/helpers/validation.js +34 -0
  40. package/dist/helpers/validation.js.map +1 -0
  41. package/dist/index.d.ts +6 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +6 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/routes/endpoints.d.ts +41 -0
  46. package/dist/routes/endpoints.d.ts.map +1 -0
  47. package/dist/routes/endpoints.js +77 -0
  48. package/dist/routes/endpoints.js.map +1 -0
  49. package/dist/routes/index.d.ts +2 -0
  50. package/dist/routes/index.d.ts.map +1 -0
  51. package/dist/routes/index.js +2 -0
  52. package/dist/routes/index.js.map +1 -0
  53. package/dist/schemas/api-requests.d.ts +72 -0
  54. package/dist/schemas/api-requests.d.ts.map +1 -0
  55. package/dist/schemas/api-requests.js +72 -0
  56. package/dist/schemas/api-requests.js.map +1 -0
  57. package/dist/schemas/api-responses.d.ts +98 -0
  58. package/dist/schemas/api-responses.d.ts.map +1 -0
  59. package/dist/schemas/api-responses.js +83 -0
  60. package/dist/schemas/api-responses.js.map +1 -0
  61. package/dist/schemas/index.d.ts +3 -0
  62. package/dist/schemas/index.d.ts.map +1 -0
  63. package/dist/schemas/index.js +3 -0
  64. package/dist/schemas/index.js.map +1 -0
  65. package/dist/types/index.d.ts +5 -0
  66. package/dist/types/index.d.ts.map +1 -0
  67. package/dist/types/index.js +5 -0
  68. package/dist/types/index.js.map +1 -0
  69. package/dist/types/message.d.ts +19 -0
  70. package/dist/types/message.d.ts.map +1 -0
  71. package/dist/types/message.js +17 -0
  72. package/dist/types/message.js.map +1 -0
  73. package/dist/types/peer.d.ts +16 -0
  74. package/dist/types/peer.d.ts.map +1 -0
  75. package/dist/types/peer.js +14 -0
  76. package/dist/types/peer.js.map +1 -0
  77. package/dist/types/session.d.ts +14 -0
  78. package/dist/types/session.d.ts.map +1 -0
  79. package/dist/types/session.js +12 -0
  80. package/dist/types/session.js.map +1 -0
  81. package/dist/types/state.d.ts +14 -0
  82. package/dist/types/state.d.ts.map +1 -0
  83. package/dist/types/state.js +12 -0
  84. package/dist/types/state.js.map +1 -0
  85. package/package.json +50 -0
@@ -0,0 +1,31 @@
1
+ import { z } from "zod";
2
+ import type { ErrorCode } from "./codes.js";
3
+ /** Output shape for BridgeErrorSchema -- used for isolatedDeclarations compatibility. */
4
+ export interface BridgeErrorPayload {
5
+ success: false;
6
+ error: string;
7
+ message: string;
8
+ suggestion?: string;
9
+ }
10
+ /**
11
+ * Schema for the serialized BridgeError payload (JSON wire format).
12
+ * Used for API error responses and structured logging.
13
+ */
14
+ export declare const BridgeErrorSchema: z.ZodType<BridgeErrorPayload>;
15
+ /**
16
+ * Domain error class for Cogent Bridge.
17
+ * Evolved from the original BridgeError with added httpStatus and toJSON().
18
+ *
19
+ * - `code`: One of the ErrorCode values (e.g., "PEER_NOT_FOUND")
20
+ * - `suggestion`: Optional human-readable recovery hint
21
+ * - `httpStatus`: Derived from ErrorHttpStatus mapping (fallback 500)
22
+ * - `toJSON()`: Returns structured BridgeErrorPayload for API responses
23
+ */
24
+ export declare class BridgeError extends Error {
25
+ readonly code: ErrorCode;
26
+ readonly suggestion?: string;
27
+ readonly httpStatus: number;
28
+ constructor(code: ErrorCode, message: string, suggestion?: string);
29
+ toJSON(): BridgeErrorPayload;
30
+ }
31
+ //# sourceMappingURL=bridge-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge-error.d.ts","sourceRoot":"","sources":["../../src/errors/bridge-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG5C,yFAAyF;AACzF,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAK1D,CAAC;AAEH;;;;;;;;GAQG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,SAAgB,IAAI,EAAE,SAAS,CAAC;IAChC,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpC,SAAgB,UAAU,EAAE,MAAM,CAAC;gBAEvB,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;IAWjE,MAAM,IAAI,kBAAkB;CAQ7B"}
@@ -0,0 +1,45 @@
1
+ import { z } from "zod";
2
+ import { ErrorHttpStatus } from "./http-status.js";
3
+ /**
4
+ * Schema for the serialized BridgeError payload (JSON wire format).
5
+ * Used for API error responses and structured logging.
6
+ */
7
+ export const BridgeErrorSchema = z.object({
8
+ success: z.literal(false),
9
+ error: z.string(),
10
+ message: z.string(),
11
+ suggestion: z.string().optional(),
12
+ });
13
+ /**
14
+ * Domain error class for Cogent Bridge.
15
+ * Evolved from the original BridgeError with added httpStatus and toJSON().
16
+ *
17
+ * - `code`: One of the ErrorCode values (e.g., "PEER_NOT_FOUND")
18
+ * - `suggestion`: Optional human-readable recovery hint
19
+ * - `httpStatus`: Derived from ErrorHttpStatus mapping (fallback 500)
20
+ * - `toJSON()`: Returns structured BridgeErrorPayload for API responses
21
+ */
22
+ export class BridgeError extends Error {
23
+ code;
24
+ suggestion;
25
+ httpStatus;
26
+ constructor(code, message, suggestion) {
27
+ const fullMessage = suggestion
28
+ ? `${code}: ${message}. ${suggestion}`
29
+ : `${code}: ${message}`;
30
+ super(fullMessage);
31
+ this.name = "BridgeError";
32
+ this.code = code;
33
+ this.suggestion = suggestion;
34
+ this.httpStatus = ErrorHttpStatus[code] ?? 500;
35
+ }
36
+ toJSON() {
37
+ return {
38
+ success: false,
39
+ error: this.code,
40
+ message: this.message,
41
+ suggestion: this.suggestion,
42
+ };
43
+ }
44
+ }
45
+ //# sourceMappingURL=bridge-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge-error.js","sourceRoot":"","sources":["../../src/errors/bridge-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAUnD;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAkC,CAAC,CAAC,MAAM,CAAC;IACvE,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IACzB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAClC,CAAC,CAAC;AAEH;;;;;;;;GAQG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpB,IAAI,CAAY;IAChB,UAAU,CAAU;IACpB,UAAU,CAAS;IAEnC,YAAY,IAAe,EAAE,OAAe,EAAE,UAAmB;QAC/D,MAAM,WAAW,GAAG,UAAU;YAC5B,CAAC,CAAC,GAAG,IAAI,KAAK,OAAO,KAAK,UAAU,EAAE;YACtC,CAAC,CAAC,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC;QAC1B,KAAK,CAAC,WAAW,CAAC,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;IACjD,CAAC;IAED,MAAM;QACJ,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,IAAI,CAAC,IAAI;YAChB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Complete error code taxonomy for Cogent Bridge.
3
+ * Covers all transport layers: file, HTTP, WebSocket, auth, message, and generic.
4
+ *
5
+ * Uses `as const` object (not enum) per modern TypeScript best practices --
6
+ * compatible with erasableSyntaxOnly, tree-shakes well, works as both
7
+ * a value namespace and a type.
8
+ */
9
+ export declare const ErrorCode: {
10
+ readonly CLI_NOT_FOUND: "CLI_NOT_FOUND";
11
+ readonly CLI_TIMEOUT: "CLI_TIMEOUT";
12
+ readonly CLI_EXEC_FAILED: "CLI_EXEC_FAILED";
13
+ readonly STATE_CORRUPT: "STATE_CORRUPT";
14
+ readonly STATE_WRITE_FAILED: "STATE_WRITE_FAILED";
15
+ readonly LOCK_TIMEOUT: "LOCK_TIMEOUT";
16
+ readonly LOCK_STALE: "LOCK_STALE";
17
+ readonly PEER_NOT_FOUND: "PEER_NOT_FOUND";
18
+ readonly INVALID_INPUT: "INVALID_INPUT";
19
+ readonly STARTUP_FAILED: "STARTUP_FAILED";
20
+ readonly DIR_NOT_WRITABLE: "DIR_NOT_WRITABLE";
21
+ readonly SESSION_NOT_FOUND: "SESSION_NOT_FOUND";
22
+ readonly SESSION_FULL: "SESSION_FULL";
23
+ readonly AUTH_INVALID_TOKEN: "AUTH_INVALID_TOKEN";
24
+ readonly AUTH_MISSING_TOKEN: "AUTH_MISSING_TOKEN";
25
+ readonly AUTH_EXPIRED_TOKEN: "AUTH_EXPIRED_TOKEN";
26
+ readonly RATE_LIMITED: "RATE_LIMITED";
27
+ readonly ENDPOINT_NOT_FOUND: "ENDPOINT_NOT_FOUND";
28
+ readonly METHOD_NOT_ALLOWED: "METHOD_NOT_ALLOWED";
29
+ readonly REQUEST_TOO_LARGE: "REQUEST_TOO_LARGE";
30
+ readonly INTERNAL_SERVER_ERROR: "INTERNAL_SERVER_ERROR";
31
+ readonly WS_CONNECTION_FAILED: "WS_CONNECTION_FAILED";
32
+ readonly WS_HANDSHAKE_ERROR: "WS_HANDSHAKE_ERROR";
33
+ readonly WS_MESSAGE_TOO_LARGE: "WS_MESSAGE_TOO_LARGE";
34
+ readonly WS_HEARTBEAT_TIMEOUT: "WS_HEARTBEAT_TIMEOUT";
35
+ readonly WS_INVALID_FRAME: "WS_INVALID_FRAME";
36
+ readonly MESSAGE_DELIVERY_FAILED: "MESSAGE_DELIVERY_FAILED";
37
+ readonly MESSAGE_QUEUE_FULL: "MESSAGE_QUEUE_FULL";
38
+ readonly MESSAGE_TOO_LARGE: "MESSAGE_TOO_LARGE";
39
+ readonly INTERNAL_ERROR: "INTERNAL_ERROR";
40
+ readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
41
+ };
42
+ export type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
43
+ //# sourceMappingURL=codes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codes.d.ts","sourceRoot":"","sources":["../../src/errors/codes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyCZ,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Complete error code taxonomy for Cogent Bridge.
3
+ * Covers all transport layers: file, HTTP, WebSocket, auth, message, and generic.
4
+ *
5
+ * Uses `as const` object (not enum) per modern TypeScript best practices --
6
+ * compatible with erasableSyntaxOnly, tree-shakes well, works as both
7
+ * a value namespace and a type.
8
+ */
9
+ export const ErrorCode = {
10
+ // File transport errors (migrated from existing BridgeErrorCode enum)
11
+ CLI_NOT_FOUND: "CLI_NOT_FOUND",
12
+ CLI_TIMEOUT: "CLI_TIMEOUT",
13
+ CLI_EXEC_FAILED: "CLI_EXEC_FAILED",
14
+ STATE_CORRUPT: "STATE_CORRUPT",
15
+ STATE_WRITE_FAILED: "STATE_WRITE_FAILED",
16
+ LOCK_TIMEOUT: "LOCK_TIMEOUT",
17
+ LOCK_STALE: "LOCK_STALE",
18
+ PEER_NOT_FOUND: "PEER_NOT_FOUND",
19
+ INVALID_INPUT: "INVALID_INPUT",
20
+ STARTUP_FAILED: "STARTUP_FAILED",
21
+ DIR_NOT_WRITABLE: "DIR_NOT_WRITABLE",
22
+ // HTTP / API errors
23
+ SESSION_NOT_FOUND: "SESSION_NOT_FOUND",
24
+ SESSION_FULL: "SESSION_FULL",
25
+ AUTH_INVALID_TOKEN: "AUTH_INVALID_TOKEN",
26
+ AUTH_MISSING_TOKEN: "AUTH_MISSING_TOKEN",
27
+ AUTH_EXPIRED_TOKEN: "AUTH_EXPIRED_TOKEN",
28
+ RATE_LIMITED: "RATE_LIMITED",
29
+ ENDPOINT_NOT_FOUND: "ENDPOINT_NOT_FOUND",
30
+ METHOD_NOT_ALLOWED: "METHOD_NOT_ALLOWED",
31
+ REQUEST_TOO_LARGE: "REQUEST_TOO_LARGE",
32
+ INTERNAL_SERVER_ERROR: "INTERNAL_SERVER_ERROR",
33
+ // WebSocket errors
34
+ WS_CONNECTION_FAILED: "WS_CONNECTION_FAILED",
35
+ WS_HANDSHAKE_ERROR: "WS_HANDSHAKE_ERROR",
36
+ WS_MESSAGE_TOO_LARGE: "WS_MESSAGE_TOO_LARGE",
37
+ WS_HEARTBEAT_TIMEOUT: "WS_HEARTBEAT_TIMEOUT",
38
+ WS_INVALID_FRAME: "WS_INVALID_FRAME",
39
+ // Message errors
40
+ MESSAGE_DELIVERY_FAILED: "MESSAGE_DELIVERY_FAILED",
41
+ MESSAGE_QUEUE_FULL: "MESSAGE_QUEUE_FULL",
42
+ MESSAGE_TOO_LARGE: "MESSAGE_TOO_LARGE",
43
+ // Generic
44
+ INTERNAL_ERROR: "INTERNAL_ERROR",
45
+ UNKNOWN_ERROR: "UNKNOWN_ERROR",
46
+ };
47
+ //# sourceMappingURL=codes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codes.js","sourceRoot":"","sources":["../../src/errors/codes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,sEAAsE;IACtE,aAAa,EAAE,eAAe;IAC9B,WAAW,EAAE,aAAa;IAC1B,eAAe,EAAE,iBAAiB;IAClC,aAAa,EAAE,eAAe;IAC9B,kBAAkB,EAAE,oBAAoB;IACxC,YAAY,EAAE,cAAc;IAC5B,UAAU,EAAE,YAAY;IACxB,cAAc,EAAE,gBAAgB;IAChC,aAAa,EAAE,eAAe;IAC9B,cAAc,EAAE,gBAAgB;IAChC,gBAAgB,EAAE,kBAAkB;IAEpC,oBAAoB;IACpB,iBAAiB,EAAE,mBAAmB;IACtC,YAAY,EAAE,cAAc;IAC5B,kBAAkB,EAAE,oBAAoB;IACxC,kBAAkB,EAAE,oBAAoB;IACxC,kBAAkB,EAAE,oBAAoB;IACxC,YAAY,EAAE,cAAc;IAC5B,kBAAkB,EAAE,oBAAoB;IACxC,kBAAkB,EAAE,oBAAoB;IACxC,iBAAiB,EAAE,mBAAmB;IACtC,qBAAqB,EAAE,uBAAuB;IAE9C,mBAAmB;IACnB,oBAAoB,EAAE,sBAAsB;IAC5C,kBAAkB,EAAE,oBAAoB;IACxC,oBAAoB,EAAE,sBAAsB;IAC5C,oBAAoB,EAAE,sBAAsB;IAC5C,gBAAgB,EAAE,kBAAkB;IAEpC,iBAAiB;IACjB,uBAAuB,EAAE,yBAAyB;IAClD,kBAAkB,EAAE,oBAAoB;IACxC,iBAAiB,EAAE,mBAAmB;IAEtC,UAAU;IACV,cAAc,EAAE,gBAAgB;IAChC,aAAa,EAAE,eAAe;CACtB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { ErrorCode } from "./codes.js";
2
+ /**
3
+ * Maps each ErrorCode to its corresponding HTTP status code.
4
+ * Used by BridgeError to derive httpStatus and by server route handlers.
5
+ */
6
+ export declare const ErrorHttpStatus: Record<ErrorCode, number>;
7
+ //# sourceMappingURL=http-status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-status.d.ts","sourceRoot":"","sources":["../../src/errors/http-status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAyCrD,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Maps each ErrorCode to its corresponding HTTP status code.
3
+ * Used by BridgeError to derive httpStatus and by server route handlers.
4
+ */
5
+ export const ErrorHttpStatus = {
6
+ // File transport errors -> 500 (server-side infrastructure)
7
+ CLI_NOT_FOUND: 500,
8
+ CLI_TIMEOUT: 500,
9
+ CLI_EXEC_FAILED: 500,
10
+ STATE_CORRUPT: 422,
11
+ STATE_WRITE_FAILED: 500,
12
+ LOCK_TIMEOUT: 409,
13
+ LOCK_STALE: 409,
14
+ PEER_NOT_FOUND: 404,
15
+ INVALID_INPUT: 400,
16
+ STARTUP_FAILED: 500,
17
+ DIR_NOT_WRITABLE: 500,
18
+ // HTTP / API errors
19
+ SESSION_NOT_FOUND: 404,
20
+ SESSION_FULL: 429,
21
+ AUTH_INVALID_TOKEN: 401,
22
+ AUTH_MISSING_TOKEN: 401,
23
+ AUTH_EXPIRED_TOKEN: 401,
24
+ RATE_LIMITED: 429,
25
+ ENDPOINT_NOT_FOUND: 404,
26
+ METHOD_NOT_ALLOWED: 405,
27
+ REQUEST_TOO_LARGE: 400,
28
+ INTERNAL_SERVER_ERROR: 500,
29
+ // WebSocket errors
30
+ WS_CONNECTION_FAILED: 500,
31
+ WS_HANDSHAKE_ERROR: 500,
32
+ WS_MESSAGE_TOO_LARGE: 413,
33
+ WS_HEARTBEAT_TIMEOUT: 500,
34
+ WS_INVALID_FRAME: 400,
35
+ // Message errors
36
+ MESSAGE_DELIVERY_FAILED: 500,
37
+ MESSAGE_QUEUE_FULL: 429,
38
+ MESSAGE_TOO_LARGE: 400,
39
+ // Generic
40
+ INTERNAL_ERROR: 500,
41
+ UNKNOWN_ERROR: 500,
42
+ };
43
+ //# sourceMappingURL=http-status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-status.js","sourceRoot":"","sources":["../../src/errors/http-status.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAA8B;IACxD,4DAA4D;IAC5D,aAAa,EAAE,GAAG;IAClB,WAAW,EAAE,GAAG;IAChB,eAAe,EAAE,GAAG;IACpB,aAAa,EAAE,GAAG;IAClB,kBAAkB,EAAE,GAAG;IACvB,YAAY,EAAE,GAAG;IACjB,UAAU,EAAE,GAAG;IACf,cAAc,EAAE,GAAG;IACnB,aAAa,EAAE,GAAG;IAClB,cAAc,EAAE,GAAG;IACnB,gBAAgB,EAAE,GAAG;IAErB,oBAAoB;IACpB,iBAAiB,EAAE,GAAG;IACtB,YAAY,EAAE,GAAG;IACjB,kBAAkB,EAAE,GAAG;IACvB,kBAAkB,EAAE,GAAG;IACvB,kBAAkB,EAAE,GAAG;IACvB,YAAY,EAAE,GAAG;IACjB,kBAAkB,EAAE,GAAG;IACvB,kBAAkB,EAAE,GAAG;IACvB,iBAAiB,EAAE,GAAG;IACtB,qBAAqB,EAAE,GAAG;IAE1B,mBAAmB;IACnB,oBAAoB,EAAE,GAAG;IACzB,kBAAkB,EAAE,GAAG;IACvB,oBAAoB,EAAE,GAAG;IACzB,oBAAoB,EAAE,GAAG;IACzB,gBAAgB,EAAE,GAAG;IAErB,iBAAiB;IACjB,uBAAuB,EAAE,GAAG;IAC5B,kBAAkB,EAAE,GAAG;IACvB,iBAAiB,EAAE,GAAG;IAEtB,UAAU;IACV,cAAc,EAAE,GAAG;IACnB,aAAa,EAAE,GAAG;CACnB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { ErrorCode } from "./codes.js";
2
+ export type { ErrorCode as ErrorCodeType } from "./codes.js";
3
+ export { ErrorHttpStatus } from "./http-status.js";
4
+ export { BridgeError, BridgeErrorSchema, type BridgeErrorPayload } from "./bridge-error.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,YAAY,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { ErrorCode } from "./codes.js";
2
+ export { ErrorHttpStatus } from "./http-status.js";
3
+ export { BridgeError, BridgeErrorSchema } from "./bridge-error.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAA2B,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { z } from "zod";
2
+ /** Configuration for the file-based transport layer. */
3
+ export interface FileConfig {
4
+ COGENT_STATE_PATH: string;
5
+ COGENT_TIMEOUT_MS: number;
6
+ COGENT_CHAR_LIMIT: number;
7
+ COGENT_LOG_LEVEL: "debug" | "info" | "warn" | "error";
8
+ COGENT_CLAUDE_PATH: string;
9
+ COGENT_STALE_TIMEOUT_MS: number;
10
+ }
11
+ /**
12
+ * Schema for file-transport configuration.
13
+ * Migrated from cogent-bridge src/config.ts configSchema.
14
+ * All values have sensible defaults and can be set via environment variables.
15
+ */
16
+ export declare const FileConfigSchema: z.ZodType<FileConfig>;
17
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/file/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,wDAAwD;AACxD,MAAM,WAAW,UAAU;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IACtD,kBAAkB,EAAE,MAAM,CAAC;IAC3B,uBAAuB,EAAE,MAAM,CAAC;CACjC;AAID;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAejD,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { z } from "zod";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ const defaultStatePath = path.join(os.homedir(), ".cogent");
5
+ /**
6
+ * Schema for file-transport configuration.
7
+ * Migrated from cogent-bridge src/config.ts configSchema.
8
+ * All values have sensible defaults and can be set via environment variables.
9
+ */
10
+ export const FileConfigSchema = z.object({
11
+ COGENT_STATE_PATH: z.string().default(defaultStatePath).describe("Directory for bridge state files"),
12
+ COGENT_TIMEOUT_MS: z.coerce.number().int().min(1000).default(120_000).describe("CLI subprocess timeout in ms"),
13
+ COGENT_CHAR_LIMIT: z.coerce.number().int().min(0).default(0).describe("Message truncation limit (0 = no limit)"),
14
+ COGENT_LOG_LEVEL: z
15
+ .enum(["debug", "info", "warn", "error"])
16
+ .default("info")
17
+ .describe("Log verbosity level"),
18
+ COGENT_CLAUDE_PATH: z.string().default("claude").describe("Path to the Claude CLI binary"),
19
+ COGENT_STALE_TIMEOUT_MS: z.coerce
20
+ .number()
21
+ .int()
22
+ .min(0)
23
+ .default(1_800_000)
24
+ .describe("Idle peer timeout in ms (30 min default)"),
25
+ });
26
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/file/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAc7B,MAAM,gBAAgB,GAAW,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;AAEpE;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAA0B,CAAC,CAAC,MAAM,CAAC;IAC9D,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,kCAAkC,CAAC;IACpG,iBAAiB,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,8BAA8B,CAAC;IAC9G,iBAAiB,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,yCAAyC,CAAC;IAChH,gBAAgB,EAAE,CAAC;SAChB,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;SACxC,OAAO,CAAC,MAAM,CAAC;SACf,QAAQ,CAAC,qBAAqB,CAAC;IAClC,kBAAkB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,+BAA+B,CAAC;IAC1F,uBAAuB,EAAE,CAAC,CAAC,MAAM;SAC9B,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,CAAC,CAAC;SACN,OAAO,CAAC,SAAS,CAAC;SAClB,QAAQ,CAAC,0CAA0C,CAAC;CACxD,CAAC,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { z } from "zod";
2
+ /** Result of executing the Claude CLI subprocess. */
3
+ export interface CliExecResult {
4
+ stdout: string;
5
+ stderr: string;
6
+ exitCode: number | null;
7
+ }
8
+ /** Result of sending a message via the file transport. */
9
+ export interface SendMessageResult {
10
+ success: boolean;
11
+ response: string | null;
12
+ error: string | null;
13
+ durationMs: number;
14
+ }
15
+ /**
16
+ * Schema for CLI execution result.
17
+ * Migrated from cogent-bridge src/types.ts CliExecResult interface.
18
+ */
19
+ export declare const CliExecResultSchema: z.ZodType<CliExecResult>;
20
+ /**
21
+ * Schema for message send result via file transport.
22
+ * Migrated from cogent-bridge src/types.ts SendMessageResult interface.
23
+ */
24
+ export declare const SendMessageResultSchema: z.ZodType<SendMessageResult>;
25
+ export { FileBridgeStateSchema, type FileBridgeState, LockInfoSchema, type LockInfo } from "./state.js";
26
+ export { FileConfigSchema, type FileConfig } from "./config.js";
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/file/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,qDAAqD;AACrD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,0DAA0D;AAC1D,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAIvD,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAK/D,CAAC;AAGH,OAAO,EAAE,qBAAqB,EAAE,KAAK,eAAe,EAAE,cAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AACxG,OAAO,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Schema for CLI execution result.
4
+ * Migrated from cogent-bridge src/types.ts CliExecResult interface.
5
+ */
6
+ export const CliExecResultSchema = z.object({
7
+ stdout: z.string().describe("Standard output from the CLI process"),
8
+ stderr: z.string().describe("Standard error from the CLI process"),
9
+ exitCode: z.number().nullable().describe("Process exit code (null if killed by signal)"),
10
+ });
11
+ /**
12
+ * Schema for message send result via file transport.
13
+ * Migrated from cogent-bridge src/types.ts SendMessageResult interface.
14
+ */
15
+ export const SendMessageResultSchema = z.object({
16
+ success: z.boolean().describe("Whether the message was sent successfully"),
17
+ response: z.string().nullable().describe("Response text from the target peer"),
18
+ error: z.string().nullable().describe("Error message if sending failed"),
19
+ durationMs: z.number().describe("Round-trip duration in milliseconds"),
20
+ });
21
+ // Re-export everything from state and config
22
+ export { FileBridgeStateSchema, LockInfoSchema } from "./state.js";
23
+ export { FileConfigSchema } from "./config.js";
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/file/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAmBxB;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAA6B,CAAC,CAAC,MAAM,CAAC;IACpE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sCAAsC,CAAC;IACnE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qCAAqC,CAAC;IAClE,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,8CAA8C,CAAC;CACzF,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAiC,CAAC,CAAC,MAAM,CAAC;IAC5E,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,2CAA2C,CAAC;IAC1E,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;IAC9E,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;IACxE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qCAAqC,CAAC;CACvE,CAAC,CAAC;AAEH,6CAA6C;AAC7C,OAAO,EAAE,qBAAqB,EAAwB,cAAc,EAAiB,MAAM,YAAY,CAAC;AACxG,OAAO,EAAE,gBAAgB,EAAmB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { z } from "zod";
2
+ import type { BridgeState } from "../types/index.js";
3
+ /** Information about a held file lock. */
4
+ export interface LockInfo {
5
+ pid: number;
6
+ acquiredAt: string;
7
+ lockFile: string;
8
+ }
9
+ /**
10
+ * File-transport-specific bridge state.
11
+ * Currently identical to BridgeState -- this alias exists so the file transport
12
+ * has its own type to extend later (e.g., lock metadata, file paths, timestamps).
13
+ */
14
+ export declare const FileBridgeStateSchema: z.ZodType<BridgeState>;
15
+ /** Re-export BridgeState as FileBridgeState for clarity in file-transport context. */
16
+ export type FileBridgeState = BridgeState;
17
+ /**
18
+ * Schema for a held file lock, used for stale lock detection.
19
+ * Represents the JSON content written inside lock files.
20
+ */
21
+ export declare const LockInfoSchema: z.ZodType<LockInfo>;
22
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/file/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD,0CAA0C;AAC1C,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,CAAqB,CAAC;AAE/E,sFAAsF;AACtF,MAAM,MAAM,eAAe,GAAG,WAAW,CAAC;AAE1C;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAI7C,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { z } from "zod";
2
+ import { BridgeStateSchema } from "../types/index.js";
3
+ /**
4
+ * File-transport-specific bridge state.
5
+ * Currently identical to BridgeState -- this alias exists so the file transport
6
+ * has its own type to extend later (e.g., lock metadata, file paths, timestamps).
7
+ */
8
+ export const FileBridgeStateSchema = BridgeStateSchema;
9
+ /**
10
+ * Schema for a held file lock, used for stale lock detection.
11
+ * Represents the JSON content written inside lock files.
12
+ */
13
+ export const LockInfoSchema = z.object({
14
+ pid: z.number().int().describe("Process ID holding the lock"),
15
+ acquiredAt: z.string().datetime().describe("ISO 8601 timestamp when lock was acquired"),
16
+ lockFile: z.string().describe("Path to the lock file"),
17
+ });
18
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/file/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAYtD;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA2B,iBAAiB,CAAC;AAK/E;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAwB,CAAC,CAAC,MAAM,CAAC;IAC1D,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;IAC7D,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,2CAA2C,CAAC;IACvF,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC;CACvD,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Generate a unique session identifier.
3
+ * Currently produces a UUID v4. Centralized here so the format can
4
+ * change later (e.g., prefixed IDs like `sess_xxx`) without affecting callers.
5
+ */
6
+ export declare function generateSessionId(): string;
7
+ /**
8
+ * Generate a unique peer identifier.
9
+ * Currently produces a UUID v4. Centralized here so the format can
10
+ * change later (e.g., prefixed IDs like `peer_xxx`) without affecting callers.
11
+ */
12
+ export declare function generatePeerId(): string;
13
+ /**
14
+ * Generate a unique message identifier.
15
+ * Currently produces a UUID v4. Centralized here so the format can
16
+ * change later (e.g., prefixed IDs like `msg_xxx`) without affecting callers.
17
+ */
18
+ export declare function generateMessageId(): string;
19
+ //# sourceMappingURL=ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../src/helpers/ids.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C"}
@@ -0,0 +1,26 @@
1
+ import crypto from "node:crypto";
2
+ /**
3
+ * Generate a unique session identifier.
4
+ * Currently produces a UUID v4. Centralized here so the format can
5
+ * change later (e.g., prefixed IDs like `sess_xxx`) without affecting callers.
6
+ */
7
+ export function generateSessionId() {
8
+ return crypto.randomUUID();
9
+ }
10
+ /**
11
+ * Generate a unique peer identifier.
12
+ * Currently produces a UUID v4. Centralized here so the format can
13
+ * change later (e.g., prefixed IDs like `peer_xxx`) without affecting callers.
14
+ */
15
+ export function generatePeerId() {
16
+ return crypto.randomUUID();
17
+ }
18
+ /**
19
+ * Generate a unique message identifier.
20
+ * Currently produces a UUID v4. Centralized here so the format can
21
+ * change later (e.g., prefixed IDs like `msg_xxx`) without affecting callers.
22
+ */
23
+ export function generateMessageId() {
24
+ return crypto.randomUUID();
25
+ }
26
+ //# sourceMappingURL=ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ids.js","sourceRoot":"","sources":["../../src/helpers/ids.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC;;;;GAIG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC;AAC7B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC;AAC7B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { generateSessionId, generatePeerId, generateMessageId } from "./ids.js";
2
+ export { isValidUUID, isValidPeerId, isValidSessionId, isValidMessageId } from "./validation.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { generateSessionId, generatePeerId, generateMessageId } from "./ids.js";
2
+ export { isValidUUID, isValidPeerId, isValidSessionId, isValidMessageId } from "./validation.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Check whether a string is a valid UUID v4.
3
+ * Used for validating IDs received from external sources.
4
+ */
5
+ export declare function isValidUUID(value: string): boolean;
6
+ /**
7
+ * Check whether a string is a valid peer ID.
8
+ * Peers use UUID v4 identifiers.
9
+ */
10
+ export declare function isValidPeerId(value: string): boolean;
11
+ /**
12
+ * Check whether a string is a valid session ID.
13
+ * Sessions use UUID v4 identifiers.
14
+ */
15
+ export declare function isValidSessionId(value: string): boolean;
16
+ /**
17
+ * Check whether a string is a valid message ID.
18
+ * Messages use UUID v4 identifiers.
19
+ */
20
+ export declare function isValidMessageId(value: string): boolean;
21
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/helpers/validation.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEvD"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * UUID v4 regex pattern.
3
+ * Matches standard lowercase UUID format: 8-4-4-4-12 hex digits with version 4 indicator.
4
+ */
5
+ const UUID_V4_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
6
+ /**
7
+ * Check whether a string is a valid UUID v4.
8
+ * Used for validating IDs received from external sources.
9
+ */
10
+ export function isValidUUID(value) {
11
+ return UUID_V4_REGEX.test(value);
12
+ }
13
+ /**
14
+ * Check whether a string is a valid peer ID.
15
+ * Peers use UUID v4 identifiers.
16
+ */
17
+ export function isValidPeerId(value) {
18
+ return isValidUUID(value);
19
+ }
20
+ /**
21
+ * Check whether a string is a valid session ID.
22
+ * Sessions use UUID v4 identifiers.
23
+ */
24
+ export function isValidSessionId(value) {
25
+ return isValidUUID(value);
26
+ }
27
+ /**
28
+ * Check whether a string is a valid message ID.
29
+ * Messages use UUID v4 identifiers.
30
+ */
31
+ export function isValidMessageId(value) {
32
+ return isValidUUID(value);
33
+ }
34
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/helpers/validation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,aAAa,GAAW,wEAAwE,CAAC;AAEvG;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,OAAO,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from "./types/index.js";
2
+ export * from "./errors/index.js";
3
+ export * from "./schemas/index.js";
4
+ export * from "./routes/index.js";
5
+ export * from "./helpers/index.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export * from "./types/index.js";
2
+ export * from "./errors/index.js";
3
+ export * from "./schemas/index.js";
4
+ export * from "./routes/index.js";
5
+ export * from "./helpers/index.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}