lua-cli 2.5.5 → 2.5.7

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.
@@ -11,7 +11,8 @@ export default class ProductInstance {
11
11
  * @returns Proxied instance that allows direct access to product properties
12
12
  */
13
13
  constructor(api, product) {
14
- this.data = product;
14
+ // Ensure data is always an object, never null or undefined
15
+ this.data = product && typeof product === 'object' ? product : {};
15
16
  // Make productAPI non-enumerable so it doesn't show up in console.log
16
17
  Object.defineProperty(this, 'productAPI', {
17
18
  value: api,
@@ -26,8 +27,8 @@ export default class ProductInstance {
26
27
  if (prop in target) {
27
28
  return Reflect.get(target, prop, receiver);
28
29
  }
29
- // Otherwise, try to get it from the data object
30
- if (typeof prop === 'string' && prop in target.data) {
30
+ // Otherwise, try to get it from the data object (with null check)
31
+ if (typeof prop === 'string' && target.data && typeof target.data === 'object' && prop in target.data) {
31
32
  return target.data[prop];
32
33
  }
33
34
  return undefined;
@@ -40,19 +41,29 @@ export default class ProductInstance {
40
41
  }
41
42
  // All other properties get set on the data object
42
43
  if (typeof prop === 'string') {
44
+ // Initialize data object if it doesn't exist
45
+ if (!target.data || typeof target.data !== 'object') {
46
+ target.data = {};
47
+ }
43
48
  target.data[prop] = value;
44
49
  return true;
45
50
  }
46
51
  return false;
47
52
  },
48
53
  has(target, prop) {
49
- // Check if property exists on instance or in data
50
- return prop in target || (typeof prop === 'string' && prop in target.data);
54
+ // Check if property exists on instance or in data (with null check)
55
+ if (prop in target) {
56
+ return true;
57
+ }
58
+ if (typeof prop === 'string' && target.data && typeof target.data === 'object') {
59
+ return prop in target.data;
60
+ }
61
+ return false;
51
62
  },
52
63
  ownKeys(target) {
53
- // Return both instance keys and data keys
64
+ // Return both instance keys and data keys (with null check)
54
65
  const instanceKeys = Reflect.ownKeys(target);
55
- const dataKeys = Object.keys(target.data);
66
+ const dataKeys = target.data && typeof target.data === 'object' ? Object.keys(target.data) : [];
56
67
  return [...new Set([...instanceKeys, ...dataKeys])];
57
68
  },
58
69
  getOwnPropertyDescriptor(target, prop) {
@@ -61,8 +72,8 @@ export default class ProductInstance {
61
72
  if (instanceDesc) {
62
73
  return instanceDesc;
63
74
  }
64
- // Then check if it's a data property
65
- if (typeof prop === 'string' && prop in target.data) {
75
+ // Then check if it's a data property (with null check)
76
+ if (typeof prop === 'string' && target.data && typeof target.data === 'object' && prop in target.data) {
66
77
  return {
67
78
  configurable: true,
68
79
  enumerable: true,
@@ -11,8 +11,12 @@ export default class ProductPaginationInstance {
11
11
  * @param results - The paginated product results from the API
12
12
  */
13
13
  constructor(api, results) {
14
- this.products = results.data?.map(product => new ProductInstance(api, product)) || [];
15
- this.pagination = results.pagination || {
14
+ // Ensure products array is always initialized, with null checks
15
+ const productsData = results?.data;
16
+ this.products = (Array.isArray(productsData) ? productsData : [])
17
+ .map(product => new ProductInstance(api, product));
18
+ // Ensure pagination is always initialized with safe defaults
19
+ this.pagination = results?.pagination || {
16
20
  currentPage: 1,
17
21
  totalPages: 1,
18
22
  totalCount: 0,
@@ -11,7 +11,10 @@ export default class ProductSearchInstance {
11
11
  * @param results - The product search results from the API
12
12
  */
13
13
  constructor(api, results) {
14
- this.products = results.data?.map(product => new ProductInstance(api, product)) || [];
14
+ // Ensure products array is always initialized, with null checks
15
+ const productsData = results?.data;
16
+ this.products = (Array.isArray(productsData) ? productsData : [])
17
+ .map(product => new ProductInstance(api, product));
15
18
  // Make productAPI non-enumerable so it doesn't show up in console.log
16
19
  Object.defineProperty(this, 'productAPI', {
17
20
  value: api,
@@ -11,7 +11,8 @@ export default class UserDataInstance {
11
11
  * @returns Proxied instance that allows direct access to data properties
12
12
  */
13
13
  constructor(api, data) {
14
- this.data = data;
14
+ // Ensure data is always an object, never null or undefined
15
+ this.data = data && typeof data === 'object' ? data : {};
15
16
  // Make userAPI non-enumerable so it doesn't show up in console.log
16
17
  Object.defineProperty(this, 'userAPI', {
17
18
  value: api,
@@ -26,8 +27,8 @@ export default class UserDataInstance {
26
27
  if (prop in target) {
27
28
  return Reflect.get(target, prop, receiver);
28
29
  }
29
- // Otherwise, try to get it from the data object
30
- if (typeof prop === 'string' && prop in target.data) {
30
+ // Otherwise, try to get it from the data object (with null check)
31
+ if (typeof prop === 'string' && target.data && typeof target.data === 'object' && prop in target.data) {
31
32
  return target.data[prop];
32
33
  }
33
34
  return undefined;
@@ -40,19 +41,29 @@ export default class UserDataInstance {
40
41
  }
41
42
  // All other properties get set on the data object
42
43
  if (typeof prop === 'string') {
44
+ // Initialize data object if it doesn't exist
45
+ if (!target.data || typeof target.data !== 'object') {
46
+ target.data = {};
47
+ }
43
48
  target.data[prop] = value;
44
49
  return true;
45
50
  }
46
51
  return false;
47
52
  },
48
53
  has(target, prop) {
49
- // Check if property exists on instance or in data
50
- return prop in target || (typeof prop === 'string' && prop in target.data);
54
+ // Check if property exists on instance or in data (with null check)
55
+ if (prop in target) {
56
+ return true;
57
+ }
58
+ if (typeof prop === 'string' && target.data && typeof target.data === 'object') {
59
+ return prop in target.data;
60
+ }
61
+ return false;
51
62
  },
52
63
  ownKeys(target) {
53
- // Return both instance keys and data keys
64
+ // Return both instance keys and data keys (with null check)
54
65
  const instanceKeys = Reflect.ownKeys(target);
55
- const dataKeys = Object.keys(target.data);
66
+ const dataKeys = target.data && typeof target.data === 'object' ? Object.keys(target.data) : [];
56
67
  return [...new Set([...instanceKeys, ...dataKeys])];
57
68
  },
58
69
  getOwnPropertyDescriptor(target, prop) {
@@ -61,8 +72,8 @@ export default class UserDataInstance {
61
72
  if (instanceDesc) {
62
73
  return instanceDesc;
63
74
  }
64
- // Then check if it's a data property
65
- if (typeof prop === 'string' && prop in target.data) {
75
+ // Then check if it's a data property (with null check)
76
+ if (typeof prop === 'string' && target.data && typeof target.data === 'object' && prop in target.data) {
66
77
  return {
67
78
  configurable: true,
68
79
  enumerable: true,
@@ -2,4 +2,8 @@ export declare function copyTemplateFiles(templateDir: string, targetDir: string
2
2
  export declare function createSkillYaml(agentId: string, orgId: string, skillName?: string, skillId?: string, persona?: string, welcomeMessage?: string): void;
3
3
  export declare function readSkillYaml(): any;
4
4
  export declare function readSkillConfig(): any;
5
+ /**
6
+ * Update only the agent information in an existing YAML file
7
+ */
8
+ export declare function updateYamlAgent(agentId: string, orgId: string, persona?: string, welcomeMessage?: string): void;
5
9
  export declare function updateSkillYamlPersona(persona: string, welcomeMessage?: string): void;
@@ -78,6 +78,33 @@ export function readSkillConfig() {
78
78
  // Read YAML config file
79
79
  return readSkillYaml();
80
80
  }
81
+ /**
82
+ * Update only the agent information in an existing YAML file
83
+ */
84
+ export function updateYamlAgent(agentId, orgId, persona, welcomeMessage) {
85
+ const yamlPath = path.join(process.cwd(), 'lua.skill.yaml');
86
+ if (!fs.existsSync(yamlPath)) {
87
+ throw new Error('lua.skill.yaml not found');
88
+ }
89
+ const config = readSkillYaml();
90
+ // Update agent information
91
+ config.agent = config.agent || {};
92
+ config.agent.agentId = agentId;
93
+ config.agent.orgId = orgId;
94
+ if (persona) {
95
+ config.agent.persona = persona;
96
+ }
97
+ if (welcomeMessage) {
98
+ config.agent.welcomeMessage = welcomeMessage;
99
+ }
100
+ // Write back to file
101
+ const yamlContent = dump(config, {
102
+ indent: 2,
103
+ lineWidth: -1,
104
+ noRefs: true
105
+ });
106
+ fs.writeFileSync(yamlPath, yamlContent);
107
+ }
81
108
  export function updateSkillYamlPersona(persona, welcomeMessage) {
82
109
  const yamlPath = path.join(process.cwd(), 'lua.skill.yaml');
83
110
  if (!fs.existsSync(yamlPath)) {
@@ -32,3 +32,16 @@ export declare function selectBaseAgentType(agentTypes: AgentType[]): AgentType;
32
32
  * @throws Error if agent creation fails
33
33
  */
34
34
  export declare function createNewAgent(apiKey: string, agentType: AgentType, businessConfig: BusinessConfig, metadata: Record<string, any>, features: Record<string, boolean>): Promise<AgentCreationResult>;
35
+ /**
36
+ * Fetches detailed agent information for an existing agent.
37
+ * Used when selecting an existing agent during init.
38
+ *
39
+ * @param apiKey - User's API key
40
+ * @param agentId - Agent ID to fetch
41
+ * @returns Agent details including persona and welcome message
42
+ * @throws Error if fetch fails
43
+ */
44
+ export declare function fetchExistingAgentDetails(apiKey: string, agentId: string): Promise<{
45
+ persona?: string;
46
+ welcomeMessage?: string;
47
+ }>;
@@ -127,3 +127,16 @@ async function fetchAgentDetails(agentApi, agentId) {
127
127
  welcomeMessage: agentDetailsResult.data.welcomeMessage
128
128
  };
129
129
  }
130
+ /**
131
+ * Fetches detailed agent information for an existing agent.
132
+ * Used when selecting an existing agent during init.
133
+ *
134
+ * @param apiKey - User's API key
135
+ * @param agentId - Agent ID to fetch
136
+ * @returns Agent details including persona and welcome message
137
+ * @throws Error if fetch fails
138
+ */
139
+ export async function fetchExistingAgentDetails(apiKey, agentId) {
140
+ const agentApi = new AgentApi(BASE_URLS.API, apiKey);
141
+ return fetchAgentDetails(agentApi, agentId);
142
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lua-cli",
3
- "version": "2.5.5",
3
+ "version": "2.5.7",
4
4
  "description": "Command-line interface for Lua AI platform - develop, test, and deploy LuaSkills with custom tools",
5
5
  "readmeFilename": "README.md",
6
6
  "main": "dist/api-exports.js",
@@ -19,7 +19,7 @@
19
19
  "axios": "^1.6.0",
20
20
  "inquirer": "^12.9.6",
21
21
  "js-yaml": "^4.1.0",
22
- "lua-cli": "^2.5.5",
22
+ "lua-cli": "^2.5.6",
23
23
  "openai": "^5.23.0",
24
24
  "uuid": "^13.0.0",
25
25
  "zod": "^3.24.1"