@kadi.build/core 0.0.1-alpha.2 → 0.0.1-alpha.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 (99) hide show
  1. package/README.md +1122 -216
  2. package/dist/KadiClient.d.ts +303 -0
  3. package/dist/KadiClient.d.ts.map +1 -0
  4. package/dist/KadiClient.js +1162 -0
  5. package/dist/KadiClient.js.map +1 -0
  6. package/dist/errors/error-codes.d.ts +215 -0
  7. package/dist/errors/error-codes.d.ts.map +1 -0
  8. package/dist/errors/error-codes.js +295 -0
  9. package/dist/errors/error-codes.js.map +1 -0
  10. package/dist/index.d.ts +15 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +24 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/loadAbility.d.ts +65 -0
  15. package/dist/loadAbility.d.ts.map +1 -0
  16. package/dist/loadAbility.js +335 -0
  17. package/dist/loadAbility.js.map +1 -0
  18. package/dist/messages/BrokerMessages.d.ts +84 -0
  19. package/dist/messages/BrokerMessages.d.ts.map +1 -0
  20. package/dist/messages/BrokerMessages.js +127 -0
  21. package/dist/messages/BrokerMessages.js.map +1 -0
  22. package/dist/messages/MessageBuilder.d.ts +83 -0
  23. package/dist/messages/MessageBuilder.d.ts.map +1 -0
  24. package/dist/messages/MessageBuilder.js +144 -0
  25. package/dist/messages/MessageBuilder.js.map +1 -0
  26. package/dist/schemas/events.schemas.d.ts +177 -0
  27. package/dist/schemas/events.schemas.d.ts.map +1 -0
  28. package/dist/schemas/events.schemas.js +265 -0
  29. package/dist/schemas/events.schemas.js.map +1 -0
  30. package/dist/schemas/index.d.ts +3 -0
  31. package/dist/schemas/index.d.ts.map +1 -0
  32. package/dist/schemas/index.js +4 -0
  33. package/dist/schemas/index.js.map +1 -0
  34. package/dist/schemas/kadi.schemas.d.ts +70 -0
  35. package/dist/schemas/kadi.schemas.d.ts.map +1 -0
  36. package/dist/schemas/kadi.schemas.js +120 -0
  37. package/dist/schemas/kadi.schemas.js.map +1 -0
  38. package/dist/transports/BrokerTransport.d.ts +96 -0
  39. package/dist/transports/BrokerTransport.d.ts.map +1 -0
  40. package/dist/transports/BrokerTransport.js +145 -0
  41. package/dist/transports/BrokerTransport.js.map +1 -0
  42. package/dist/transports/NativeTransport.d.ts +92 -0
  43. package/dist/transports/NativeTransport.d.ts.map +1 -0
  44. package/dist/transports/NativeTransport.js +221 -0
  45. package/dist/transports/NativeTransport.js.map +1 -0
  46. package/dist/transports/StdioTransport.d.ts +112 -0
  47. package/dist/transports/StdioTransport.d.ts.map +1 -0
  48. package/dist/transports/StdioTransport.js +440 -0
  49. package/dist/transports/StdioTransport.js.map +1 -0
  50. package/dist/transports/Transport.d.ts +93 -0
  51. package/dist/transports/Transport.d.ts.map +1 -0
  52. package/dist/transports/Transport.js +13 -0
  53. package/dist/transports/Transport.js.map +1 -0
  54. package/dist/types/broker.d.ts +31 -0
  55. package/dist/types/broker.d.ts.map +1 -0
  56. package/dist/types/broker.js +6 -0
  57. package/dist/types/broker.js.map +1 -0
  58. package/dist/types/core.d.ts +138 -0
  59. package/dist/types/core.d.ts.map +1 -0
  60. package/dist/types/core.js +26 -0
  61. package/dist/types/core.js.map +1 -0
  62. package/dist/types/events.d.ts +186 -0
  63. package/dist/types/events.d.ts.map +1 -0
  64. package/dist/types/events.js +16 -0
  65. package/dist/types/events.js.map +1 -0
  66. package/dist/types/index.d.ts +9 -0
  67. package/dist/types/index.d.ts.map +1 -0
  68. package/dist/types/index.js +13 -0
  69. package/dist/types/index.js.map +1 -0
  70. package/dist/types/protocol.d.ts +160 -0
  71. package/dist/types/protocol.d.ts.map +1 -0
  72. package/dist/types/protocol.js +5 -0
  73. package/dist/types/protocol.js.map +1 -0
  74. package/dist/utils/agentUtils.d.ts +102 -0
  75. package/dist/utils/agentUtils.d.ts.map +1 -0
  76. package/dist/utils/agentUtils.js +166 -0
  77. package/dist/utils/agentUtils.js.map +1 -0
  78. package/dist/utils/commandUtils.d.ts +45 -0
  79. package/dist/utils/commandUtils.d.ts.map +1 -0
  80. package/dist/utils/commandUtils.js +145 -0
  81. package/dist/utils/commandUtils.js.map +1 -0
  82. package/dist/utils/configUtils.d.ts +55 -0
  83. package/dist/utils/configUtils.d.ts.map +1 -0
  84. package/dist/utils/configUtils.js +100 -0
  85. package/dist/utils/configUtils.js.map +1 -0
  86. package/dist/utils/logger.d.ts +59 -0
  87. package/dist/utils/logger.d.ts.map +1 -0
  88. package/dist/utils/logger.js +122 -0
  89. package/dist/utils/logger.js.map +1 -0
  90. package/dist/utils/pathUtils.d.ts +48 -0
  91. package/dist/utils/pathUtils.d.ts.map +1 -0
  92. package/dist/utils/pathUtils.js +128 -0
  93. package/dist/utils/pathUtils.js.map +1 -0
  94. package/package.json +58 -5
  95. package/agent.json +0 -18
  96. package/broker.js +0 -214
  97. package/index.js +0 -382
  98. package/ipc.js +0 -220
  99. package/ipcInterfaces/pythonAbilityIPC.py +0 -177
@@ -0,0 +1,59 @@
1
+ import { Debugger } from 'debug';
2
+ export interface KadiLogger extends Debugger {
3
+ trace: Debugger;
4
+ error: Debugger;
5
+ lifecycle: Debugger;
6
+ protocol: Debugger;
7
+ transport: Debugger;
8
+ info: Debugger;
9
+ warn: Debugger;
10
+ debug: Debugger;
11
+ }
12
+ export declare const loggers: {
13
+ main: KadiLogger | null;
14
+ ability: KadiLogger | null;
15
+ broker: KadiLogger | null;
16
+ ipc: KadiLogger | null;
17
+ transport: KadiLogger | null;
18
+ rpc: KadiLogger | null;
19
+ };
20
+ /**
21
+ * Creates a namespaced logger with sub-loggers for different concerns
22
+ * @param namespace - The logger namespace (e.g., 'ability', 'broker')
23
+ * @returns A logger instance with specialized sub-loggers
24
+ */
25
+ export declare function createLogger(namespace: string): KadiLogger;
26
+ /**
27
+ * Creates a logger for a specific component within a namespace
28
+ */
29
+ export declare function createComponentLogger(component: string): KadiLogger;
30
+ /**
31
+ * Checks if debug is enabled for a namespace
32
+ */
33
+ export declare function isDebugEnabled(namespace: string): boolean;
34
+ /**
35
+ * Format an object for logging
36
+ */
37
+ export declare function formatObject(obj: any, label?: string): string;
38
+ /**
39
+ * Create a child logger with additional context
40
+ */
41
+ export declare function createChildLogger(parentLogger: KadiLogger, context: string): KadiLogger;
42
+ export declare function isKadiLogger(obj: unknown): obj is KadiLogger;
43
+ declare const _default: {
44
+ loggers: {
45
+ main: KadiLogger | null;
46
+ ability: KadiLogger | null;
47
+ broker: KadiLogger | null;
48
+ ipc: KadiLogger | null;
49
+ transport: KadiLogger | null;
50
+ rpc: KadiLogger | null;
51
+ };
52
+ createLogger: typeof createLogger;
53
+ createComponentLogger: typeof createComponentLogger;
54
+ isDebugEnabled: typeof isDebugEnabled;
55
+ formatObject: typeof formatObject;
56
+ createChildLogger: typeof createChildLogger;
57
+ };
58
+ export default _default;
59
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,OAA0B,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAIpD,MAAM,WAAW,UAAW,SAAQ,QAAQ;IAC1C,KAAK,EAAE,QAAQ,CAAC;IAChB,KAAK,EAAE,QAAQ,CAAC;IAChB,SAAS,EAAE,QAAQ,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,QAAQ,CAAC;IACpB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,QAAQ,CAAC;CACjB;AAMD,eAAO,MAAM,OAAO;UACJ,UAAU,GAAG,IAAI;aACd,UAAU,GAAG,IAAI;YAClB,UAAU,GAAG,IAAI;SACpB,UAAU,GAAG,IAAI;eACX,UAAU,GAAG,IAAI;SACvB,UAAU,GAAG,IAAI;CAC/B,CAAC;AAYF;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAwC1D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAEnE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAazD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,GAAE,MAAW,GAAG,MAAM,CAKjE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,UAAU,EACxB,OAAO,EAAE,MAAM,GACd,UAAU,CAGZ;AAGD,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,UAAU,CAQ5D;;;cAxHe,UAAU,GAAG,IAAI;iBACd,UAAU,GAAG,IAAI;gBAClB,UAAU,GAAG,IAAI;aACpB,UAAU,GAAG,IAAI;mBACX,UAAU,GAAG,IAAI;aACvB,UAAU,GAAG,IAAI;;;;;;;;AAyHhC,wBAOE"}
@@ -0,0 +1,122 @@
1
+ import createDebugLogger from 'debug';
2
+ import chalk from 'chalk';
3
+ // Typed logger storage
4
+ const loggerCache = new Map();
5
+ // Pre-configured loggers for backward compatibility
6
+ export const loggers = {
7
+ main: null,
8
+ ability: null,
9
+ broker: null,
10
+ ipc: null,
11
+ transport: null,
12
+ rpc: null
13
+ };
14
+ // Initialize default loggers
15
+ function initializeDefaultLoggers() {
16
+ loggers.main = createLogger('main');
17
+ loggers.ability = createLogger('ability');
18
+ loggers.broker = createLogger('broker');
19
+ loggers.ipc = createLogger('ipc');
20
+ loggers.transport = createLogger('transport');
21
+ loggers.rpc = createLogger('rpc');
22
+ }
23
+ /**
24
+ * Creates a namespaced logger with sub-loggers for different concerns
25
+ * @param namespace - The logger namespace (e.g., 'ability', 'broker')
26
+ * @returns A logger instance with specialized sub-loggers
27
+ */
28
+ export function createLogger(namespace) {
29
+ // Check cache first
30
+ if (loggerCache.has(namespace)) {
31
+ return loggerCache.get(namespace);
32
+ }
33
+ const baseNamespace = `kadi:${namespace}`;
34
+ const logger = createDebugLogger(baseNamespace);
35
+ // Create typed sub-loggers
36
+ logger.trace = createDebugLogger(`${baseNamespace}:trace`);
37
+ logger.error = createDebugLogger(`${baseNamespace}:error`);
38
+ logger.lifecycle = createDebugLogger(`${baseNamespace}:lifecycle`);
39
+ logger.protocol = createDebugLogger(`${baseNamespace}:protocol`);
40
+ logger.transport = createDebugLogger(`${baseNamespace}:transport`);
41
+ logger.info = createDebugLogger(`${baseNamespace}:info`);
42
+ logger.warn = createDebugLogger(`${baseNamespace}:warn`);
43
+ logger.debug = createDebugLogger(`${baseNamespace}:debug`);
44
+ // Add colored output for different log levels
45
+ const originalError = logger.error;
46
+ logger.error = ((message, ...args) => {
47
+ if (process.stdout.isTTY) {
48
+ originalError(chalk.red(message), ...args);
49
+ }
50
+ else {
51
+ originalError(message, ...args);
52
+ }
53
+ });
54
+ const originalWarn = logger.warn;
55
+ logger.warn = ((message, ...args) => {
56
+ if (process.stdout.isTTY) {
57
+ originalWarn(chalk.yellow(message), ...args);
58
+ }
59
+ else {
60
+ originalWarn(message, ...args);
61
+ }
62
+ });
63
+ loggerCache.set(namespace, logger);
64
+ return logger;
65
+ }
66
+ /**
67
+ * Creates a logger for a specific component within a namespace
68
+ */
69
+ export function createComponentLogger(component) {
70
+ return createLogger(component);
71
+ }
72
+ /**
73
+ * Checks if debug is enabled for a namespace
74
+ */
75
+ export function isDebugEnabled(namespace) {
76
+ const debug = process.env.DEBUG || '';
77
+ // Handle wildcard patterns
78
+ if (debug.includes('*')) {
79
+ const patterns = debug.split(',').map((p) => p.trim());
80
+ return patterns.some((pattern) => {
81
+ const regex = pattern.replace(/\*/g, '.*');
82
+ return new RegExp(`^${regex}$`).test(namespace);
83
+ });
84
+ }
85
+ return debug.includes(namespace);
86
+ }
87
+ /**
88
+ * Format an object for logging
89
+ */
90
+ export function formatObject(obj, label = '') {
91
+ if (label) {
92
+ return `${label}: ${JSON.stringify(obj, null, 2)}`;
93
+ }
94
+ return JSON.stringify(obj, null, 2);
95
+ }
96
+ /**
97
+ * Create a child logger with additional context
98
+ */
99
+ export function createChildLogger(parentLogger, context) {
100
+ const namespace = parentLogger.namespace.replace('kadi:', '');
101
+ return createLogger(`${namespace}:${context}`);
102
+ }
103
+ // Type guard for checking if something is a logger
104
+ export function isKadiLogger(obj) {
105
+ return (obj !== null &&
106
+ typeof obj === 'function' &&
107
+ 'trace' in obj &&
108
+ 'error' in obj &&
109
+ 'lifecycle' in obj);
110
+ }
111
+ // Initialize default loggers on module load
112
+ initializeDefaultLoggers();
113
+ // Default export for backward compatibility
114
+ export default {
115
+ loggers,
116
+ createLogger,
117
+ createComponentLogger,
118
+ isDebugEnabled,
119
+ formatObject,
120
+ createChildLogger
121
+ };
122
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,iBAA+B,MAAM,OAAO,CAAC;AACpD,OAAO,KAAK,MAAM,OAAO,CAAC;AAc1B,uBAAuB;AACvB,MAAM,WAAW,GAAG,IAAI,GAAG,EAAsB,CAAC;AAElD,oDAAoD;AACpD,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI,EAAE,IAAyB;IAC/B,OAAO,EAAE,IAAyB;IAClC,MAAM,EAAE,IAAyB;IACjC,GAAG,EAAE,IAAyB;IAC9B,SAAS,EAAE,IAAyB;IACpC,GAAG,EAAE,IAAyB;CAC/B,CAAC;AAEF,6BAA6B;AAC7B,SAAS,wBAAwB;IAC/B,OAAO,CAAC,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACpC,OAAO,CAAC,OAAO,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1C,OAAO,CAAC,MAAM,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;IACxC,OAAO,CAAC,GAAG,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IAClC,OAAO,CAAC,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 * @returns The directory containing the Kadi executable
7
+ */
8
+ export declare function resolveKadiExecPath(): string;
9
+ /**
10
+ * Safely resolves Kadi installation path
11
+ * @throws {Error} If Kadi installation cannot be found
12
+ */
13
+ export declare function resolveKadiInstallPath(): string;
14
+ export declare const kadiExecDir: string;
15
+ export declare const kadiRootDir: string;
16
+ export declare const kadiAgentPath: string;
17
+ export declare const rootDir: string;
18
+ export declare const abilitiesDir: string;
19
+ export declare const projectAgentPath: string;
20
+ export declare const kadiCoreAgentPath: string;
21
+ export declare const pathUtils: {
22
+ /**
23
+ * Normalizes path for current platform
24
+ */
25
+ readonly normalize: (inputPath: string) => string;
26
+ /**
27
+ * Checks if path is absolute
28
+ */
29
+ readonly isAbsolute: (inputPath: string) => boolean;
30
+ /**
31
+ * Safely joins paths
32
+ */
33
+ readonly join: (...paths: string[]) => string;
34
+ /**
35
+ * Gets directory name from path
36
+ */
37
+ readonly dirname: (inputPath: string) => string;
38
+ /**
39
+ * Gets base name from path
40
+ */
41
+ readonly basename: (inputPath: string, ext?: string) => string;
42
+ /**
43
+ * Resolve a path relative to the project root
44
+ */
45
+ readonly resolveFromRoot: (...segments: string[]) => string;
46
+ };
47
+ export default pathUtils;
48
+ //# sourceMappingURL=pathUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathUtils.d.ts","sourceRoot":"","sources":["../../src/utils/pathUtils.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG;IAAE,OAAO,EAAE,eAAe,CAAA;CAAE,CAAC;AAElE;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAa5C;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CA4C/C;AAaD,eAAO,MAAM,WAAW,QAAwB,CAAC;AACjD,eAAO,MAAM,WAAW,QAA2B,CAAC;AACpD,eAAO,MAAM,aAAa,QAAuC,CAAC;AAElE,eAAO,MAAM,OAAO,QAAgB,CAAC;AACrC,eAAO,MAAM,YAAY,QAAkC,CAAC;AAC5D,eAAO,MAAM,gBAAgB,QAAmC,CAAC;AACjE,eAAO,MAAM,iBAAiB,QAA2C,CAAC;AAG1E,eAAO,MAAM,SAAS;IACpB;;OAEG;oCACkB,MAAM,KAAG,MAAM;IAIpC;;OAEG;qCACmB,MAAM,KAAG,OAAO;IAItC;;OAEG;8BACY,MAAM,EAAE,KAAG,MAAM;IAIhC;;OAEG;kCACgB,MAAM,KAAG,MAAM;IAIlC;;OAEG;mCACiB,MAAM,QAAQ,MAAM,KAAG,MAAM;IAIjD;;OAEG;4CAC0B,MAAM,EAAE,KAAG,MAAM;CAGtC,CAAC;AAEX,eAAe,SAAS,CAAC"}
@@ -0,0 +1,128 @@
1
+ import path from 'node:path';
2
+ import fs from 'node:fs';
3
+ import { execSync } from 'node:child_process';
4
+ import { fileURLToPath } from 'node:url';
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
7
+ /**
8
+ * Resolves the Kadi executable directory path
9
+ * @returns The directory containing the Kadi executable
10
+ */
11
+ export function resolveKadiExecPath() {
12
+ // Try to find kadi using which command
13
+ try {
14
+ const kadiPath = execSync('which kadi', { encoding: 'utf8' }).trim();
15
+ if (kadiPath) {
16
+ return path.dirname(kadiPath);
17
+ }
18
+ }
19
+ catch {
20
+ // which command failed, continue with other methods
21
+ }
22
+ // Fallback to process.execPath
23
+ return path.dirname(process.execPath);
24
+ }
25
+ /**
26
+ * Safely resolves Kadi installation path
27
+ * @throws {Error} If Kadi installation cannot be found
28
+ */
29
+ export function resolveKadiInstallPath() {
30
+ // Try using npm to find the global kadi installation
31
+ try {
32
+ const npmGlobalPath = execSync('npm root -g', { encoding: 'utf8' }).trim();
33
+ const kadiPath = path.join(npmGlobalPath, 'kadi');
34
+ if (fs.existsSync(kadiPath)) {
35
+ return kadiPath;
36
+ }
37
+ }
38
+ catch {
39
+ // npm command failed, continue with other methods
40
+ }
41
+ // Try to find kadi in the path
42
+ try {
43
+ const kadiExecutable = execSync('which kadi', { encoding: 'utf8' }).trim();
44
+ if (kadiExecutable) {
45
+ // Follow symlinks to get real path
46
+ const realPath = fs.realpathSync(kadiExecutable);
47
+ // Go up from bin to find the kadi root
48
+ let currentPath = path.dirname(realPath);
49
+ while (currentPath !== path.dirname(currentPath)) {
50
+ if (fs.existsSync(path.join(currentPath, 'package.json'))) {
51
+ try {
52
+ const pkg = JSON.parse(fs.readFileSync(path.join(currentPath, 'package.json'), 'utf8'));
53
+ if (pkg.name === 'kadi' || pkg.name === '@kadi.build/core') {
54
+ return currentPath;
55
+ }
56
+ }
57
+ catch {
58
+ // Not a valid package.json, continue searching
59
+ }
60
+ }
61
+ currentPath = path.dirname(currentPath);
62
+ }
63
+ }
64
+ }
65
+ catch {
66
+ // which command failed
67
+ }
68
+ // Fallback to current working directory
69
+ return process.cwd();
70
+ }
71
+ /**
72
+ * Type guard to validate a path exists
73
+ */
74
+ function validatePath(pathStr) {
75
+ if (!fs.existsSync(pathStr)) {
76
+ throw new Error(`Path does not exist: ${pathStr}`);
77
+ }
78
+ return pathStr;
79
+ }
80
+ // Export path constants
81
+ export const kadiExecDir = resolveKadiExecPath();
82
+ export const kadiRootDir = resolveKadiInstallPath();
83
+ export const kadiAgentPath = path.join(kadiRootDir, 'agent.json');
84
+ export const rootDir = process.cwd();
85
+ export const abilitiesDir = path.join(rootDir, 'abilities');
86
+ export const projectAgentPath = path.join(rootDir, 'agent.json');
87
+ export const kadiCoreAgentPath = path.join(__dirname, '..', 'agent.json');
88
+ // Platform-specific path utilities
89
+ export const pathUtils = {
90
+ /**
91
+ * Normalizes path for current platform
92
+ */
93
+ normalize(inputPath) {
94
+ return path.normalize(inputPath);
95
+ },
96
+ /**
97
+ * Checks if path is absolute
98
+ */
99
+ isAbsolute(inputPath) {
100
+ return path.isAbsolute(inputPath);
101
+ },
102
+ /**
103
+ * Safely joins paths
104
+ */
105
+ join(...paths) {
106
+ return path.join(...paths);
107
+ },
108
+ /**
109
+ * Gets directory name from path
110
+ */
111
+ dirname(inputPath) {
112
+ return path.dirname(inputPath);
113
+ },
114
+ /**
115
+ * Gets base name from path
116
+ */
117
+ basename(inputPath, ext) {
118
+ return path.basename(inputPath, ext);
119
+ },
120
+ /**
121
+ * Resolve a path relative to the project root
122
+ */
123
+ resolveFromRoot(...segments) {
124
+ return path.resolve(rootDir, ...segments);
125
+ }
126
+ };
127
+ export default pathUtils;
128
+ //# sourceMappingURL=pathUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathUtils.js","sourceRoot":"","sources":["../../src/utils/pathUtils.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAK3C;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IACjC,uCAAuC;IACvC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACrE,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,oDAAoD;IACtD,CAAC;IAED,+BAA+B;IAC/B,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AACxC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB;IACpC,qDAAqD;IACrD,IAAI,CAAC;QACH,MAAM,aAAa,GAAG,QAAQ,CAAC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IACH,IAAI,CAAC,GAAG,KAAe;QACrB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,SAAiB;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,SAAiB,EAAE,GAAY;QACtC,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,eAAe,CAAC,GAAG,QAAkB;QACnC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,QAAQ,CAAC,CAAC;IAC5C,CAAC;CACO,CAAC;AAEX,eAAe,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,12 +1,52 @@
1
1
  {
2
2
  "name": "@kadi.build/core",
3
- "version": "0.0.1-alpha.2",
3
+ "version": "0.0.1-alpha.4",
4
4
  "description": "A module that is a comprehensive toolkit for developers integrating with the KADI infrastructure.",
5
- "main": "index.js",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
6
7
  "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ },
13
+ "./types": {
14
+ "import": "./dist/types/index.js",
15
+ "types": "./dist/types/index.d.ts"
16
+ },
17
+ "./types/protocol": {
18
+ "import": "./dist/types/protocol.js",
19
+ "types": "./dist/types/protocol.d.ts"
20
+ },
21
+ "./types/events": {
22
+ "import": "./dist/types/events.js",
23
+ "types": "./dist/types/events.d.ts"
24
+ },
25
+ "./schemas": {
26
+ "import": "./dist/schemas/index.js",
27
+ "types": "./dist/schemas/index.d.ts"
28
+ },
29
+ "./messages": {
30
+ "import": "./dist/messages/BrokerMessages.js",
31
+ "types": "./dist/messages/BrokerMessages.d.ts"
32
+ }
33
+ },
34
+ "files": [
35
+ "dist",
36
+ "README.md",
37
+ "LICENSE"
38
+ ],
7
39
  "scripts": {
40
+ "clean": "rimraf dist",
41
+ "build": "npm run clean && tsc",
42
+ "build:watch": "tsc --watch",
43
+ "typecheck": "tsc --noEmit",
44
+ "lint": "eslint 'src/**/*.{js,ts}'",
45
+ "lint:fix": "eslint 'src/**/*.{js,ts}' --fix",
8
46
  "format": "prettier --write .",
9
- "test": "echo \"Error: no test specified\" && exit 1"
47
+ "format:check": "prettier --check .",
48
+ "prepublishOnly": "npm run build",
49
+ "prepare": "npm run build"
10
50
  },
11
51
  "author": "Corey Clark",
12
52
  "contributors": [
@@ -17,10 +57,23 @@
17
57
  ],
18
58
  "license": "MIT",
19
59
  "dependencies": {
60
+ "chalk": "^5.5.0",
61
+ "debug": "^4.4.1",
20
62
  "events": "^3.3.0",
21
- "ws": "^8.16.0"
63
+ "ws": "^8.16.0",
64
+ "zod": "^4.1.5"
22
65
  },
23
66
  "devDependencies": {
24
- "prettier": "^3.6.2"
67
+ "@types/debug": "^4.1.12",
68
+ "@types/node": "^20.19.11",
69
+ "@types/ws": "^8.18.1",
70
+ "@typescript-eslint/eslint-plugin": "^7.18.0",
71
+ "@typescript-eslint/parser": "^7.18.0",
72
+ "eslint": "^8.57.1",
73
+ "eslint-config-prettier": "^9.1.2",
74
+ "eslint-plugin-prettier": "^5.5.4",
75
+ "prettier": "^3.6.2",
76
+ "rimraf": "^5.0.10",
77
+ "typescript": "^5.9.2"
25
78
  }
26
79
  }
package/agent.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "name": "kadi-core",
3
- "version": "0.0.1",
4
- "license": "MIT",
5
- "description": "base install ability for kadi",
6
- "repo": "https://gitlab.com/humin-game-lab/agent-abilities/kadi-core.git",
7
- "lib": "https://gitlab.com/humin-game-lab/agent-abilities/kadi-core/-/archive/v0.0.1/kadi-core-v0.0.1.zip",
8
- "abilities": {},
9
-
10
- "scripts": {
11
- "preflight": "echo 'kadi-core v0.0.1 is starting...'",
12
- "setup": "echo 'kadi-core v0.0.1 is ready...'",
13
- "start": "npm install",
14
- "stop": "echo 'kadi-core v0.0.1 is ready...'",
15
- "python": "python3 ./node_modules/kadi-core/ipcInterfaces/pythonAbilityIPC.py",
16
- "rust": "cargo run --bin path/to/rustAbilityIPC"
17
- }
18
- }