snow-flow 10.0.1-dev.440 → 10.0.1-dev.441

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "10.0.1-dev.440",
3
+ "version": "10.0.1-dev.441",
4
4
  "name": "snow-flow",
5
5
  "description": "Snow-Flow - ServiceNow Multi-Agent Development Framework powered by AI",
6
6
  "license": "Elastic-2.0",
@@ -222,6 +222,48 @@ async function addActionViaGraphQL(
222
222
  }
223
223
  if (!actionDefId) return { success: false, error: 'Action definition not found for: ' + actionType, steps };
224
224
 
225
+ // Look up available input fields from sys_hub_action_input
226
+ let actionParams: { element: string; label: string; mandatory: boolean; default_value: string; internal_type: string }[] = [];
227
+ try {
228
+ const resp = await client.get('/api/now/table/sys_hub_action_input', {
229
+ params: {
230
+ sysparm_query: 'model=' + actionDefId,
231
+ sysparm_fields: 'sys_id,element,label,mandatory,default_value,internal_type',
232
+ sysparm_display_value: 'false',
233
+ sysparm_limit: 50
234
+ }
235
+ });
236
+ actionParams = (resp.data.result || []).map((r: any) => ({
237
+ element: r.element,
238
+ label: r.label,
239
+ mandatory: r.mandatory === 'true' || r.mandatory === true,
240
+ default_value: r.default_value || '',
241
+ internal_type: r.internal_type || ''
242
+ }));
243
+ steps.available_inputs = actionParams;
244
+ } catch (_) {}
245
+
246
+ // Match provided inputs to actual field names (fuzzy: "message" → "log_message", "level" → "log_level")
247
+ const resolvedInputs: Record<string, string> = {};
248
+ if (inputs) {
249
+ const paramElements = actionParams.map(p => p.element);
250
+ for (const [key, value] of Object.entries(inputs)) {
251
+ // Exact match first
252
+ if (paramElements.includes(key)) {
253
+ resolvedInputs[key] = value;
254
+ continue;
255
+ }
256
+ // Try to find a param whose element ends with the key or contains it
257
+ const match = actionParams.find(p => p.element.endsWith('_' + key) || p.element === key || p.label.toLowerCase() === key.toLowerCase());
258
+ if (match) {
259
+ resolvedInputs[match.element] = value;
260
+ } else {
261
+ resolvedInputs[key] = value;
262
+ }
263
+ }
264
+ steps.resolved_inputs = resolvedInputs;
265
+ }
266
+
225
267
  const uuid = generateUUID();
226
268
  const actionResponseFields = 'actions { inserts { sysId uiUniqueIdentifier __typename } updates deletes __typename }';
227
269
  try {
@@ -246,8 +288,8 @@ async function addActionViaGraphQL(
246
288
  const actionId = result?.actions?.inserts?.[0]?.sysId;
247
289
  steps.insert = { success: !!actionId, actionId, uuid };
248
290
 
249
- if (actionId && inputs && Object.keys(inputs).length > 0) {
250
- const updateInputs = Object.entries(inputs).map(([name, value]) => ({
291
+ if (actionId && Object.keys(resolvedInputs).length > 0) {
292
+ const updateInputs = Object.entries(resolvedInputs).map(([name, value]) => ({
251
293
  name,
252
294
  value: { schemaless: false, schemalessValue: '', value: String(value) }
253
295
  }));
@@ -256,7 +298,7 @@ async function addActionViaGraphQL(
256
298
  flowId: flowId,
257
299
  actions: { update: [{ uiUniqueIdentifier: uuid, type: 'action', inputs: updateInputs }] }
258
300
  }, actionResponseFields);
259
- steps.value_update = { success: true };
301
+ steps.value_update = { success: true, inputs: updateInputs.map(i => i.name) };
260
302
  } catch (e: any) {
261
303
  steps.value_update = { success: false, error: e.message };
262
304
  }