@kadi.build/core 0.0.1-alpha.3 → 0.0.1-alpha.5

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 (128) hide show
  1. package/README.md +754 -606
  2. package/dist/KadiClient.d.ts +440 -0
  3. package/dist/KadiClient.d.ts.map +1 -0
  4. package/dist/KadiClient.js +1518 -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 +106 -0
  15. package/dist/loadAbility.d.ts.map +1 -0
  16. package/dist/loadAbility.js +376 -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 +125 -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 +106 -0
  39. package/dist/transports/BrokerTransport.d.ts.map +1 -0
  40. package/dist/transports/BrokerTransport.js +177 -0
  41. package/dist/transports/BrokerTransport.js.map +1 -0
  42. package/dist/transports/NativeTransport.d.ts +82 -0
  43. package/dist/transports/NativeTransport.d.ts.map +1 -0
  44. package/dist/transports/NativeTransport.js +263 -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 +445 -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 +139 -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 +187 -0
  75. package/dist/utils/agentUtils.d.ts.map +1 -0
  76. package/dist/utils/agentUtils.js +185 -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 +56 -5
  95. package/agent.json +0 -18
  96. package/examples/example-abilities/echo-js/README.md +0 -131
  97. package/examples/example-abilities/echo-js/agent.json +0 -63
  98. package/examples/example-abilities/echo-js/package.json +0 -24
  99. package/examples/example-abilities/echo-js/service.js +0 -43
  100. package/examples/example-abilities/hash-go/agent.json +0 -53
  101. package/examples/example-abilities/hash-go/cmd/hash_ability/main.go +0 -340
  102. package/examples/example-abilities/hash-go/go.mod +0 -3
  103. package/examples/example-agent/abilities/echo-js/0.0.1/README.md +0 -131
  104. package/examples/example-agent/abilities/echo-js/0.0.1/agent.json +0 -63
  105. package/examples/example-agent/abilities/echo-js/0.0.1/package-lock.json +0 -93
  106. package/examples/example-agent/abilities/echo-js/0.0.1/package.json +0 -24
  107. package/examples/example-agent/abilities/echo-js/0.0.1/service.js +0 -41
  108. package/examples/example-agent/abilities/hash-go/0.0.1/agent.json +0 -53
  109. package/examples/example-agent/abilities/hash-go/0.0.1/bin/hash_ability +0 -0
  110. package/examples/example-agent/abilities/hash-go/0.0.1/cmd/hash_ability/main.go +0 -340
  111. package/examples/example-agent/abilities/hash-go/0.0.1/go.mod +0 -3
  112. package/examples/example-agent/agent.json +0 -39
  113. package/examples/example-agent/index.js +0 -102
  114. package/examples/example-agent/package-lock.json +0 -93
  115. package/examples/example-agent/package.json +0 -17
  116. package/src/KadiAbility.js +0 -478
  117. package/src/index.js +0 -65
  118. package/src/loadAbility.js +0 -1086
  119. package/src/servers/BaseRpcServer.js +0 -404
  120. package/src/servers/BrokerRpcServer.js +0 -776
  121. package/src/servers/StdioRpcServer.js +0 -360
  122. package/src/transport/BrokerMessageBuilder.js +0 -377
  123. package/src/transport/IpcMessageBuilder.js +0 -1229
  124. package/src/utils/agentUtils.js +0 -137
  125. package/src/utils/commandUtils.js +0 -64
  126. package/src/utils/configUtils.js +0 -72
  127. package/src/utils/logger.js +0 -161
  128. package/src/utils/pathUtils.js +0 -86
@@ -0,0 +1,187 @@
1
+ export interface AbilityJSON {
2
+ name: string;
3
+ version: string;
4
+ description?: string;
5
+ main?: string;
6
+ command?: string;
7
+ [key: string]: any;
8
+ }
9
+ export interface ProjectJSON {
10
+ name: string;
11
+ version: string;
12
+ abilities?: Array<{
13
+ name: string;
14
+ version: string;
15
+ }>;
16
+ [key: string]: any;
17
+ }
18
+ export interface AgentJSON {
19
+ name: string;
20
+ version: string;
21
+ kind?: string;
22
+ license?: string;
23
+ description?: string;
24
+ repo?: string;
25
+ lib?: string;
26
+ brokers?: {
27
+ [brokerName: string]: string;
28
+ };
29
+ defaultBroker?: string;
30
+ abilities?: {
31
+ [abilityName: string]: string;
32
+ };
33
+ scripts?: {
34
+ [scriptName: string]: string;
35
+ };
36
+ build?: {
37
+ [buildName: string]: {
38
+ image?: string;
39
+ engine?: string;
40
+ platform?: string;
41
+ baseImage?: string;
42
+ cli?: boolean;
43
+ keepBuildDir?: boolean;
44
+ buildManifest?: string;
45
+ dryRun?: boolean;
46
+ [key: string]: any;
47
+ };
48
+ };
49
+ deploy?: {
50
+ [deployName: string]: {
51
+ target?: string;
52
+ image?: string;
53
+ engine?: string;
54
+ network?: string;
55
+ cert?: string;
56
+ verbose?: boolean;
57
+ showCommands?: boolean;
58
+ ports?: Array<{
59
+ port: number;
60
+ as: number;
61
+ to: string[];
62
+ }>;
63
+ services?: {
64
+ [serviceName: string]: {
65
+ image?: string;
66
+ expose?: Array<{
67
+ port: number;
68
+ as: number;
69
+ to: Array<{
70
+ global?: boolean;
71
+ [key: string]: any;
72
+ }>;
73
+ }>;
74
+ resources?: {
75
+ cpu?: number;
76
+ memory?: string;
77
+ storage?: string;
78
+ };
79
+ pricing?: {
80
+ amount?: string;
81
+ denom?: string;
82
+ };
83
+ [key: string]: any;
84
+ };
85
+ };
86
+ placement?: {
87
+ attributes?: {
88
+ [key: string]: any;
89
+ };
90
+ [key: string]: any;
91
+ };
92
+ [key: string]: any;
93
+ };
94
+ };
95
+ [key: string]: any;
96
+ }
97
+ export interface KadiJSON {
98
+ brokers?: Array<{
99
+ name: string;
100
+ url: string;
101
+ default?: boolean;
102
+ }>;
103
+ api?: string;
104
+ [key: string]: any;
105
+ }
106
+ /**
107
+ * Get ability configuration JSON
108
+ */
109
+ export declare function getAbilityJSON(abilityName: string, abilityVersion: string): AbilityJSON | null;
110
+ /**
111
+ * Get path to ability's agent.json file
112
+ */
113
+ export declare function getAbilityJSONPath(abilityName: string, abilityVersion: string): string;
114
+ /**
115
+ * Get the abilities directory path
116
+ */
117
+ export declare function getAbilitiesDir(): string;
118
+ /**
119
+ * Get agent configuration JSON (replaces getProjectJSON with proper typing)
120
+ */
121
+ export declare function getAgentJSON(): AgentJSON | null;
122
+ /**
123
+ * Get project configuration JSON (deprecated - use getAgentJSON instead)
124
+ * @deprecated Use getAgentJSON for better typing
125
+ */
126
+ export declare function getProjectJSON(): ProjectJSON | null;
127
+ /**
128
+ * Get path to project's agent.json file
129
+ */
130
+ export declare function getProjectJSONPath(): string;
131
+ /**
132
+ * Get Kadi core configuration JSON
133
+ */
134
+ export declare function getKadiCoreJSON(): KadiJSON | null;
135
+ /**
136
+ * Get path to Kadi core's agent.json file
137
+ */
138
+ export declare function getKadiCoreJSONPath(): string;
139
+ /**
140
+ * Get main Kadi configuration JSON
141
+ */
142
+ export declare function getKadiJSON(): KadiJSON | null;
143
+ /**
144
+ * Get path to main Kadi agent.json file
145
+ */
146
+ export declare function getKadiJSONPath(): string;
147
+ /**
148
+ * Get Kadi executable path
149
+ */
150
+ export declare function getKadiExecPath(): string;
151
+ /**
152
+ * Get Kadi installation path
153
+ */
154
+ export declare function getKadiInstallPath(): string;
155
+ /**
156
+ * Get ability version from abilities array
157
+ * @param abilities - Array of ability configurations
158
+ * @param name - Name of the ability to find
159
+ * @returns The ability version or 'latest' if not found
160
+ */
161
+ export declare function getAbilityVersionFromArray(abilities: Array<{
162
+ name: string;
163
+ version: string;
164
+ }>, name: string): string;
165
+ export declare const KADI_API_URL: string | undefined;
166
+ export declare const SEARCH_API_URL: string | undefined;
167
+ export declare const GET_API_URL: string | undefined;
168
+ declare const _default: {
169
+ getAbilityJSON: typeof getAbilityJSON;
170
+ getAbilityJSONPath: typeof getAbilityJSONPath;
171
+ getAbilitiesDir: typeof getAbilitiesDir;
172
+ getAgentJSON: typeof getAgentJSON;
173
+ getProjectJSON: typeof getProjectJSON;
174
+ getProjectJSONPath: typeof getProjectJSONPath;
175
+ getKadiCoreJSON: typeof getKadiCoreJSON;
176
+ getKadiCoreJSONPath: typeof getKadiCoreJSONPath;
177
+ getKadiJSON: typeof getKadiJSON;
178
+ getKadiJSONPath: typeof getKadiJSONPath;
179
+ getKadiExecPath: typeof getKadiExecPath;
180
+ getKadiInstallPath: typeof getKadiInstallPath;
181
+ getAbilityVersionFromArray: typeof getAbilityVersionFromArray;
182
+ KADI_API_URL: string | undefined;
183
+ SEARCH_API_URL: string | undefined;
184
+ GET_API_URL: string | undefined;
185
+ };
186
+ export default _default;
187
+ //# sourceMappingURL=agentUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentUtils.d.ts","sourceRoot":"","sources":["../../src/utils/agentUtils.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO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AI,CAc7C;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,EACnD,IAAI,EAAE,MAAM,GACX,MAAM,CAqBR;AAID,eAAO,MAAM,YAAY,oBAAe,CAAC;AACzC,eAAO,MAAM,cAAc,oBAEd,CAAC;AACd,eAAO,MAAM,WAAW,oBAAmD,CAAC;;;;;;;;;;;;;;;;;;;AAG5E,wBAiBE"}
@@ -0,0 +1,185 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { kadiAgentPath, kadiExecDir, kadiRootDir, abilitiesDir, projectAgentPath, kadiCoreAgentPath } from './pathUtils.js';
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
7
+ /**
8
+ * Get ability configuration JSON
9
+ */
10
+ export function getAbilityJSON(abilityName, abilityVersion) {
11
+ const abilityJSONPath = getAbilityJSONPath(abilityName, abilityVersion);
12
+ if (!fs.existsSync(abilityJSONPath)) {
13
+ return null;
14
+ }
15
+ try {
16
+ const content = fs.readFileSync(abilityJSONPath, 'utf-8');
17
+ return JSON.parse(content);
18
+ }
19
+ catch (error) {
20
+ console.error(`Failed to read ability JSON at ${abilityJSONPath}:`, error);
21
+ return null;
22
+ }
23
+ }
24
+ /**
25
+ * Get path to ability's agent.json file
26
+ */
27
+ export function getAbilityJSONPath(abilityName, abilityVersion) {
28
+ return path.join(abilitiesDir, abilityName, abilityVersion, 'agent.json');
29
+ }
30
+ /**
31
+ * Get the abilities directory path
32
+ */
33
+ export function getAbilitiesDir() {
34
+ return abilitiesDir;
35
+ }
36
+ /**
37
+ * Get agent configuration JSON (replaces getProjectJSON with proper typing)
38
+ */
39
+ export function getAgentJSON() {
40
+ const agentJSONPath = getProjectJSONPath(); // Still uses same path
41
+ if (!fs.existsSync(agentJSONPath)) {
42
+ return null;
43
+ }
44
+ try {
45
+ const content = fs.readFileSync(agentJSONPath, 'utf-8');
46
+ return JSON.parse(content);
47
+ }
48
+ catch (error) {
49
+ console.error(`Failed to read agent JSON at ${agentJSONPath}:`, error);
50
+ return null;
51
+ }
52
+ }
53
+ /**
54
+ * Get project configuration JSON (deprecated - use getAgentJSON instead)
55
+ * @deprecated Use getAgentJSON for better typing
56
+ */
57
+ export function getProjectJSON() {
58
+ const projectJSONPath = getProjectJSONPath();
59
+ if (!fs.existsSync(projectJSONPath)) {
60
+ return null;
61
+ }
62
+ try {
63
+ const content = fs.readFileSync(projectJSONPath, 'utf-8');
64
+ return JSON.parse(content);
65
+ }
66
+ catch (error) {
67
+ console.error(`Failed to read project JSON at ${projectJSONPath}:`, error);
68
+ return null;
69
+ }
70
+ }
71
+ /**
72
+ * Get path to project's agent.json file
73
+ */
74
+ export function getProjectJSONPath() {
75
+ return projectAgentPath;
76
+ }
77
+ /**
78
+ * Get Kadi core configuration JSON
79
+ */
80
+ export function getKadiCoreJSON() {
81
+ const kadiCoreJSONPath = getKadiCoreJSONPath();
82
+ if (!fs.existsSync(kadiCoreJSONPath)) {
83
+ return null;
84
+ }
85
+ try {
86
+ const content = fs.readFileSync(kadiCoreJSONPath, 'utf-8');
87
+ return JSON.parse(content);
88
+ }
89
+ catch (error) {
90
+ console.error(`Failed to read Kadi core JSON at ${kadiCoreJSONPath}:`, error);
91
+ return null;
92
+ }
93
+ }
94
+ /**
95
+ * Get path to Kadi core's agent.json file
96
+ */
97
+ export function getKadiCoreJSONPath() {
98
+ return kadiCoreAgentPath;
99
+ }
100
+ /**
101
+ * Get main Kadi configuration JSON
102
+ */
103
+ export function getKadiJSON() {
104
+ const kadiJSONPath = getKadiJSONPath();
105
+ if (!fs.existsSync(kadiJSONPath)) {
106
+ return null;
107
+ }
108
+ try {
109
+ const content = fs.readFileSync(kadiJSONPath, 'utf-8');
110
+ return JSON.parse(content);
111
+ }
112
+ catch (error) {
113
+ console.error(`Failed to read Kadi JSON at ${kadiJSONPath}:`, error);
114
+ return null;
115
+ }
116
+ }
117
+ /**
118
+ * Get path to main Kadi agent.json file
119
+ */
120
+ export function getKadiJSONPath() {
121
+ return kadiAgentPath;
122
+ }
123
+ /**
124
+ * Get Kadi executable path
125
+ */
126
+ export function getKadiExecPath() {
127
+ return kadiExecDir;
128
+ }
129
+ /**
130
+ * Get Kadi installation path
131
+ */
132
+ export function getKadiInstallPath() {
133
+ return kadiRootDir;
134
+ }
135
+ /**
136
+ * Get ability version from abilities array
137
+ * @param abilities - Array of ability configurations
138
+ * @param name - Name of the ability to find
139
+ * @returns The ability version or 'latest' if not found
140
+ */
141
+ export function getAbilityVersionFromArray(abilities, name) {
142
+ const ability = abilities.find((a) => a.name === name);
143
+ if (ability) {
144
+ return ability.version;
145
+ }
146
+ // Check if ability exists in abilities directory with a default version
147
+ const abilityDir = path.join(abilitiesDir, name);
148
+ if (fs.existsSync(abilityDir)) {
149
+ const versions = fs
150
+ .readdirSync(abilityDir)
151
+ .filter((dir) => fs.statSync(path.join(abilityDir, dir)).isDirectory());
152
+ if (versions.length > 0) {
153
+ // Return the latest version (simple string comparison)
154
+ return versions.sort().reverse()[0];
155
+ }
156
+ }
157
+ return 'latest';
158
+ }
159
+ // Initialize Kadi configuration and export API URLs
160
+ const kadijson = getKadiJSON() || {};
161
+ export const KADI_API_URL = kadijson.api;
162
+ export const SEARCH_API_URL = kadijson.api
163
+ ? `${kadijson.api}/search`
164
+ : undefined;
165
+ export const GET_API_URL = kadijson.api ? `${kadijson.api}/get` : undefined;
166
+ // Export default for backward compatibility
167
+ export default {
168
+ getAbilityJSON,
169
+ getAbilityJSONPath,
170
+ getAbilitiesDir,
171
+ getAgentJSON,
172
+ getProjectJSON,
173
+ getProjectJSONPath,
174
+ getKadiCoreJSON,
175
+ getKadiCoreJSONPath,
176
+ getKadiJSON,
177
+ getKadiJSONPath,
178
+ getKadiExecPath,
179
+ getKadiInstallPath,
180
+ getAbilityVersionFromArray,
181
+ KADI_API_URL,
182
+ SEARCH_API_URL,
183
+ GET_API_URL
184
+ };
185
+ //# sourceMappingURL=agentUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentUtils.js","sourceRoot":"","sources":["../../src/utils/agentUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,aAAa,EACb,WAAW,EACX,WAAW,EAEX,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AAExB,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAuG3C;;GAEG;AACH,MAAM,UAAU,cAAc,CAC5B,WAAmB,EACnB,cAAsB;IAEtB,MAAM,eAAe,GAAG,kBAAkB,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;IAExE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAgB,CAAC;IAC5C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,kCAAkC,eAAe,GAAG,EAAE,KAAK,CAAC,CAAC;QAC3E,OAAO,IA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AAQ,CAAC,GAAG,SAAS;IAC1B,CAAC,CAAC,SAAS,CAAC;AACd,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AAE5E,4CAA4C;AAC5C,eAAe;IACb,cAAc;IACd,kBAAkB;IAClB,eAAe;IACf,YAAY;IACZ,cAAc;IACd,kBAAkB;IAClB,eAAe;IACf,mBAAmB;IACnB,WAAW;IACX,eAAe;IACf,eAAe;IACf,kBAAkB;IAClB,0BAA0B;IAC1B,YAAY;IACZ,cAAc;IACd,WAAW;CACZ,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { ExecOptions, ChildProcess } from 'node:child_process';
2
+ import { Readable } from 'node:stream';
3
+ export interface CommandResult {
4
+ stdout: string;
5
+ stderr: string;
6
+ code: number;
7
+ }
8
+ export interface StreamingCommand {
9
+ stdout: Readable | null;
10
+ stderr: Readable | null;
11
+ kill: () => boolean;
12
+ promise: Promise<CommandResult>;
13
+ process: ChildProcess;
14
+ }
15
+ /**
16
+ * Execute a command and return the complete output
17
+ * Use this for commands with bounded output
18
+ * @param name - The name of the ability or context
19
+ * @param version - The version of the ability
20
+ * @param command - The command to execute
21
+ */
22
+ export declare function runExecCommand(name: string, version: string, command: string): Promise<CommandResult>;
23
+ /**
24
+ * Spawn a command for streaming output
25
+ * Use this for long-running commands or large outputs
26
+ * @param name - The name of the ability or context
27
+ * @param version - The version of the ability
28
+ * @param command - The command to execute
29
+ */
30
+ export declare function runSpawnCommand(name: string, version: string, command: string): Promise<StreamingCommand>;
31
+ /**
32
+ * Generic command execution with options
33
+ * @param command - The command to execute
34
+ * @param options - Execution options
35
+ */
36
+ export declare function runCommand(command: string, options?: ExecOptions): Promise<CommandResult>;
37
+ /**
38
+ * Run command with timeout
39
+ */
40
+ export declare function runCommandWithTimeout(command: string, timeoutMs: number, options?: ExecOptions): Promise<CommandResult>;
41
+ /**
42
+ * Check if a command exists in PATH
43
+ */
44
+ export declare function commandExists(command: string): Promise<boolean>;
45
+ //# sourceMappingURL=commandUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commandUtils.d.ts","sourceRoot":"","sources":["../../src/utils/commandUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,WAAW,EAEX,YAAY,EACb,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAOvC,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAC;IACxB,IAAI,EAAE,MAAM,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IAChC,OAAO,EAAE,YAAY,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,aAAa,CAAC,CAqBxB;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,gBAAgB,CAAC,CAgD3B;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,aAAa,CAAC,CAoBxB;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,aAAa,CAAC,CAkBxB;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAUrE"}
@@ -0,0 +1,145 @@
1
+ import { exec, spawn } from 'node:child_process';
2
+ import { promisify } from 'node:util';
3
+ import path from 'node:path';
4
+ import { rootDir } from './pathUtils.js';
5
+ const execAsync = promisify(exec);
6
+ /**
7
+ * Execute a command and return the complete output
8
+ * Use this for commands with bounded output
9
+ * @param name - The name of the ability or context
10
+ * @param version - The version of the ability
11
+ * @param command - The command to execute
12
+ */
13
+ export async function runExecCommand(name, version, command) {
14
+ const abilityPath = path.join(rootDir, 'abilities', name, version);
15
+ return new Promise((resolve, reject) => {
16
+ exec(command, { cwd: abilityPath }, (error, stdout, stderr) => {
17
+ if (error) {
18
+ // Even on error, we want to return the output
19
+ resolve({
20
+ stdout: stdout?.toString() || '',
21
+ stderr: stderr?.toString() || error.message,
22
+ code: error.code || 1
23
+ });
24
+ }
25
+ else {
26
+ resolve({
27
+ stdout: stdout?.toString() || '',
28
+ stderr: stderr?.toString() || '',
29
+ code: 0
30
+ });
31
+ }
32
+ });
33
+ });
34
+ }
35
+ /**
36
+ * Spawn a command for streaming output
37
+ * Use this for long-running commands or large outputs
38
+ * @param name - The name of the ability or context
39
+ * @param version - The version of the ability
40
+ * @param command - The command to execute
41
+ */
42
+ export async function runSpawnCommand(name, version, command) {
43
+ const abilityPath = path.join(rootDir, 'abilities', name, version);
44
+ return new Promise((resolve, reject) => {
45
+ const [cmd, ...args] = command.split(' ');
46
+ const child = spawn(cmd, args, {
47
+ cwd: abilityPath,
48
+ shell: true
49
+ });
50
+ // Create promise for final result
51
+ const promise = new Promise((resolveResult) => {
52
+ let stdout = '';
53
+ let stderr = '';
54
+ child.stdout?.on('data', (chunk) => {
55
+ stdout += chunk.toString();
56
+ });
57
+ child.stderr?.on('data', (chunk) => {
58
+ stderr += chunk.toString();
59
+ });
60
+ child.on('error', (error) => {
61
+ resolveResult({
62
+ stdout,
63
+ stderr: stderr || error.message,
64
+ code: 1
65
+ });
66
+ });
67
+ child.on('exit', (code) => {
68
+ resolveResult({
69
+ stdout,
70
+ stderr,
71
+ code: code || 0
72
+ });
73
+ });
74
+ });
75
+ resolve({
76
+ stdout: child.stdout,
77
+ stderr: child.stderr,
78
+ kill: () => child.kill(),
79
+ promise,
80
+ process: child
81
+ });
82
+ });
83
+ }
84
+ /**
85
+ * Generic command execution with options
86
+ * @param command - The command to execute
87
+ * @param options - Execution options
88
+ */
89
+ export async function runCommand(command, options = {}) {
90
+ try {
91
+ const { stdout, stderr } = await execAsync(command, {
92
+ encoding: 'utf8',
93
+ ...options
94
+ });
95
+ return {
96
+ stdout: stdout.toString(),
97
+ stderr: stderr.toString(),
98
+ code: 0
99
+ };
100
+ }
101
+ catch (error) {
102
+ // Exec error includes stdout/stderr even on failure
103
+ return {
104
+ stdout: error.stdout?.toString() || '',
105
+ stderr: error.stderr?.toString() || error.message,
106
+ code: error.code || 1
107
+ };
108
+ }
109
+ }
110
+ /**
111
+ * Run command with timeout
112
+ */
113
+ export async function runCommandWithTimeout(command, timeoutMs, options = {}) {
114
+ const controller = new AbortController();
115
+ const timeout = setTimeout(() => controller.abort(), timeoutMs);
116
+ try {
117
+ const result = await runCommand(command, {
118
+ ...options,
119
+ signal: controller.signal
120
+ });
121
+ clearTimeout(timeout);
122
+ return result;
123
+ }
124
+ catch (error) {
125
+ clearTimeout(timeout);
126
+ if (error.code === 'ABORT_ERR') {
127
+ throw new Error(`Command timed out after ${timeoutMs}ms`);
128
+ }
129
+ throw error;
130
+ }
131
+ }
132
+ /**
133
+ * Check if a command exists in PATH
134
+ */
135
+ export async function commandExists(command) {
136
+ const checkCommand = process.platform === 'win32' ? `where ${command}` : `which ${command}`;
137
+ try {
138
+ const result = await runCommand(checkCommand);
139
+ return result.code === 0;
140
+ }
141
+ catch {
142
+ return false;
143
+ }
144
+ }
145
+ //# sourceMappingURL=commandUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commandUtils.js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E,EAAE,SAAS,CAAC,CAAC;IAEhE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,EAAE;YACvC,GAAG,OAAO;YACV,MAAM,EAAE,UAAU,CAAC,MAAa;SACjC,CAAC,CAAC;QACH,YAAY,CAAC,OAAO,CAAC,CAAC;QACtB,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,YAAY,CAAC,OAAO,CAAC,CAAC;QACtB,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,2BAA2B,SAAS,IAAI,CAAC,CAAC;QAC5D,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAe;IACjD,MAAM,YAAY,GAChB,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS,OAAO,EAAE,CAAC;IAEzE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,YAAY,CAAC,CAAC;QAC9C,OAAO,MAAM,CAAC,IAAI,KAAK,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
@@ -0,0 +1,55 @@
1
+ export interface BrokerConfig {
2
+ [key: string]: string;
3
+ }
4
+ export interface AbilityInfo {
5
+ name: string;
6
+ version: string;
7
+ [key: string]: any;
8
+ }
9
+ export declare const KADI_BROKERS: BrokerConfig;
10
+ export declare const KADI_BROKER_URL: string | undefined;
11
+ /**
12
+ * Get broker URL by name
13
+ */
14
+ export declare function getBrokerUrl(brokerName: string): string | undefined;
15
+ /**
16
+ * Get all broker names
17
+ */
18
+ export declare function getBrokerNames(): string[];
19
+ /**
20
+ * Get the default broker name
21
+ */
22
+ export declare function getDefaultBrokerName(): string | undefined;
23
+ /**
24
+ * Set the active broker
25
+ * @throws {Error} If broker name is not found
26
+ */
27
+ export declare function setActiveBroker(brokerName: string): void;
28
+ /**
29
+ * Get the active broker name
30
+ */
31
+ export declare function getActiveBrokerName(): string | undefined;
32
+ /**
33
+ * Get the active broker URL
34
+ */
35
+ export declare function getActiveBrokerUrl(): string | undefined;
36
+ /**
37
+ * Find ability version by name
38
+ * @param abilities - Array of ability configurations
39
+ * @param name - Name of the ability to find
40
+ * @returns The ability configuration or undefined
41
+ */
42
+ export declare function findAbilityVersionByName(abilities: AbilityInfo[], name: string): AbilityInfo | undefined;
43
+ declare const _default: {
44
+ KADI_BROKERS: BrokerConfig;
45
+ KADI_BROKER_URL: string | undefined;
46
+ getBrokerUrl: typeof getBrokerUrl;
47
+ getBrokerNames: typeof getBrokerNames;
48
+ getDefaultBrokerName: typeof getDefaultBrokerName;
49
+ setActiveBroker: typeof setActiveBroker;
50
+ getActiveBrokerName: typeof getActiveBrokerName;
51
+ getActiveBrokerUrl: typeof getActiveBrokerUrl;
52
+ findAbilityVersionByName: typeof findAbilityVersionByName;
53
+ };
54
+ export default _default;
55
+ //# sourceMappingURL=configUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configUtils.d.ts","sourceRoot":"","sources":["../../src/utils/configUtils.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,YAAY;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAoBD,eAAO,MAAM,YAAY,cAAU,CAAC;AAgBpC,eAAO,MAAM,eAAe,oBAEf,CAAC;AAKd;;GAEG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEnE;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,EAAE,CAEzC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,GAAG,SAAS,CAEzD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAKxD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,GAAG,SAAS,CAExD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,SAAS,CAEvD;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,WAAW,EAAE,EACxB,IAAI,EAAE,MAAM,GACX,WAAW,GAAG,SAAS,CAEzB;;;;;;;;;;;;AAGD,wBAUE"}