nowaikit 3.0.0 → 4.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.
- package/LICENSE +10 -10
- package/README.md +8 -6
- package/desktop/renderer/dist/assets/index-D46KUWoj.js +49 -0
- package/desktop/renderer/dist/index.html +5 -5
- package/desktop/serve.cjs +134 -10
- package/dist/a2a/agent-card.d.ts +8 -0
- package/dist/a2a/agent-card.d.ts.map +1 -0
- package/dist/a2a/agent-card.js +82 -0
- package/dist/a2a/agent-card.js.map +1 -0
- package/dist/a2a/index.d.ts +13 -0
- package/dist/a2a/index.d.ts.map +1 -0
- package/dist/a2a/index.js +74 -0
- package/dist/a2a/index.js.map +1 -0
- package/dist/a2a/task-manager.d.ts +20 -0
- package/dist/a2a/task-manager.d.ts.map +1 -0
- package/dist/a2a/task-manager.js +148 -0
- package/dist/a2a/task-manager.js.map +1 -0
- package/dist/a2a/types.d.ts +73 -0
- package/dist/a2a/types.d.ts.map +1 -0
- package/dist/a2a/types.js +6 -0
- package/dist/a2a/types.js.map +1 -0
- package/dist/api/index.d.ts +16 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +106 -0
- package/dist/api/index.js.map +1 -0
- package/dist/cli/config-store.d.ts +31 -0
- package/dist/cli/config-store.d.ts.map +1 -1
- package/dist/cli/config-store.js +44 -1
- package/dist/cli/config-store.js.map +1 -1
- package/dist/cli/index.js +115 -9
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/setup.d.ts.map +1 -1
- package/dist/cli/setup.js +669 -49
- package/dist/cli/setup.js.map +1 -1
- package/dist/cli/shortcuts.d.ts +2 -0
- package/dist/cli/shortcuts.d.ts.map +1 -0
- package/dist/cli/shortcuts.js +122 -0
- package/dist/cli/shortcuts.js.map +1 -0
- package/dist/dashboard/index.d.ts +7 -0
- package/dist/dashboard/index.d.ts.map +1 -0
- package/dist/dashboard/index.js +111 -0
- package/dist/dashboard/index.js.map +1 -0
- package/dist/direct/llm-client.d.ts +1 -1
- package/dist/direct/llm-client.d.ts.map +1 -1
- package/dist/direct/llm-client.js +9 -4
- package/dist/direct/llm-client.js.map +1 -1
- package/dist/prompts/capabilities/build-app.d.ts.map +1 -1
- package/dist/prompts/capabilities/build-app.js +2 -0
- package/dist/prompts/capabilities/build-app.js.map +1 -1
- package/dist/prompts/capabilities/build-atf-suite.d.ts +4 -0
- package/dist/prompts/capabilities/build-atf-suite.d.ts.map +1 -0
- package/dist/prompts/capabilities/build-atf-suite.js +143 -0
- package/dist/prompts/capabilities/build-atf-suite.js.map +1 -0
- package/dist/prompts/capabilities/build-business-rule.d.ts.map +1 -1
- package/dist/prompts/capabilities/build-business-rule.js +2 -0
- package/dist/prompts/capabilities/build-business-rule.js.map +1 -1
- package/dist/prompts/capabilities/build-catalog.d.ts.map +1 -1
- package/dist/prompts/capabilities/build-catalog.js +2 -0
- package/dist/prompts/capabilities/build-catalog.js.map +1 -1
- package/dist/prompts/capabilities/build-client-script.d.ts.map +1 -1
- package/dist/prompts/capabilities/build-client-script.js +2 -0
- package/dist/prompts/capabilities/build-client-script.js.map +1 -1
- package/dist/prompts/capabilities/build-flow.d.ts.map +1 -1
- package/dist/prompts/capabilities/build-flow.js +2 -0
- package/dist/prompts/capabilities/build-flow.js.map +1 -1
- package/dist/prompts/capabilities/build-portal.d.ts.map +1 -1
- package/dist/prompts/capabilities/build-portal.js +2 -0
- package/dist/prompts/capabilities/build-portal.js.map +1 -1
- package/dist/prompts/capabilities/build-rest-api.d.ts.map +1 -1
- package/dist/prompts/capabilities/build-rest-api.js +2 -0
- package/dist/prompts/capabilities/build-rest-api.js.map +1 -1
- package/dist/prompts/capabilities/build-test-plan.d.ts.map +1 -1
- package/dist/prompts/capabilities/build-test-plan.js +2 -0
- package/dist/prompts/capabilities/build-test-plan.js.map +1 -1
- package/dist/prompts/capabilities/build-uib.d.ts.map +1 -1
- package/dist/prompts/capabilities/build-uib.js +2 -0
- package/dist/prompts/capabilities/build-uib.js.map +1 -1
- package/dist/prompts/capabilities/docs-app.d.ts.map +1 -1
- package/dist/prompts/capabilities/docs-app.js +2 -0
- package/dist/prompts/capabilities/docs-app.js.map +1 -1
- package/dist/prompts/capabilities/docs-release.d.ts.map +1 -1
- package/dist/prompts/capabilities/docs-release.js +2 -0
- package/dist/prompts/capabilities/docs-release.js.map +1 -1
- package/dist/prompts/capabilities/docs-runbook.d.ts.map +1 -1
- package/dist/prompts/capabilities/docs-runbook.js +2 -0
- package/dist/prompts/capabilities/docs-runbook.js.map +1 -1
- package/dist/prompts/capabilities/docs-script.d.ts.map +1 -1
- package/dist/prompts/capabilities/docs-script.js +2 -0
- package/dist/prompts/capabilities/docs-script.js.map +1 -1
- package/dist/prompts/capabilities/ops-deploy.d.ts.map +1 -1
- package/dist/prompts/capabilities/ops-deploy.js +2 -0
- package/dist/prompts/capabilities/ops-deploy.js.map +1 -1
- package/dist/prompts/capabilities/ops-risk.d.ts.map +1 -1
- package/dist/prompts/capabilities/ops-risk.js +2 -0
- package/dist/prompts/capabilities/ops-risk.js.map +1 -1
- package/dist/prompts/capabilities/ops-triage.d.ts.map +1 -1
- package/dist/prompts/capabilities/ops-triage.js +2 -0
- package/dist/prompts/capabilities/ops-triage.js.map +1 -1
- package/dist/prompts/capabilities/review-acls.d.ts.map +1 -1
- package/dist/prompts/capabilities/review-acls.js +2 -0
- package/dist/prompts/capabilities/review-acls.js.map +1 -1
- package/dist/prompts/capabilities/review-code.d.ts.map +1 -1
- package/dist/prompts/capabilities/review-code.js +2 -0
- package/dist/prompts/capabilities/review-code.js.map +1 -1
- package/dist/prompts/capabilities/review-flows.d.ts.map +1 -1
- package/dist/prompts/capabilities/review-flows.js +2 -0
- package/dist/prompts/capabilities/review-flows.js.map +1 -1
- package/dist/prompts/capabilities/review-scripts.d.ts.map +1 -1
- package/dist/prompts/capabilities/review-scripts.js +2 -0
- package/dist/prompts/capabilities/review-scripts.js.map +1 -1
- package/dist/prompts/capabilities/scan-automation.d.ts.map +1 -1
- package/dist/prompts/capabilities/scan-automation.js +2 -0
- package/dist/prompts/capabilities/scan-automation.js.map +1 -1
- package/dist/prompts/capabilities/scan-cmdb.d.ts.map +1 -1
- package/dist/prompts/capabilities/scan-cmdb.js +2 -0
- package/dist/prompts/capabilities/scan-cmdb.js.map +1 -1
- package/dist/prompts/capabilities/scan-debt.d.ts.map +1 -1
- package/dist/prompts/capabilities/scan-debt.js +2 -0
- package/dist/prompts/capabilities/scan-debt.js.map +1 -1
- package/dist/prompts/capabilities/scan-health.d.ts.map +1 -1
- package/dist/prompts/capabilities/scan-health.js +2 -0
- package/dist/prompts/capabilities/scan-health.js.map +1 -1
- package/dist/prompts/capabilities/scan-security.d.ts.map +1 -1
- package/dist/prompts/capabilities/scan-security.js +2 -0
- package/dist/prompts/capabilities/scan-security.js.map +1 -1
- package/dist/prompts/capabilities/scan-upgrade.d.ts.map +1 -1
- package/dist/prompts/capabilities/scan-upgrade.js +2 -0
- package/dist/prompts/capabilities/scan-upgrade.js.map +1 -1
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +47 -8
- package/dist/prompts/index.js.map +1 -1
- package/dist/reports/brand.d.ts +79 -0
- package/dist/reports/brand.d.ts.map +1 -0
- package/dist/reports/brand.js +204 -0
- package/dist/reports/brand.js.map +1 -0
- package/dist/reports/charts.d.ts +11 -0
- package/dist/reports/charts.d.ts.map +1 -0
- package/dist/reports/charts.js +91 -0
- package/dist/reports/charts.js.map +1 -0
- package/dist/reports/index.d.ts +13 -0
- package/dist/reports/index.d.ts.map +1 -0
- package/dist/reports/index.js +65 -0
- package/dist/reports/index.js.map +1 -0
- package/dist/reports/parser.d.ts +13 -0
- package/dist/reports/parser.d.ts.map +1 -0
- package/dist/reports/parser.js +202 -0
- package/dist/reports/parser.js.map +1 -0
- package/dist/reports/pdf-generator.d.ts +8 -0
- package/dist/reports/pdf-generator.d.ts.map +1 -0
- package/dist/reports/pdf-generator.js +244 -0
- package/dist/reports/pdf-generator.js.map +1 -0
- package/dist/reports/pptx-generator.d.ts +8 -0
- package/dist/reports/pptx-generator.d.ts.map +1 -0
- package/dist/reports/pptx-generator.js +273 -0
- package/dist/reports/pptx-generator.js.map +1 -0
- package/dist/reports/types.d.ts +60 -0
- package/dist/reports/types.d.ts.map +1 -0
- package/dist/reports/types.js +7 -0
- package/dist/reports/types.js.map +1 -0
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/index.js +10 -0
- package/dist/resources/index.js.map +1 -1
- package/dist/resources/query-syntax.d.ts +6 -0
- package/dist/resources/query-syntax.d.ts.map +1 -0
- package/dist/resources/query-syntax.js +113 -0
- package/dist/resources/query-syntax.js.map +1 -0
- package/dist/sdk/index.d.ts +51 -0
- package/dist/sdk/index.d.ts.map +1 -0
- package/dist/sdk/index.js +55 -0
- package/dist/sdk/index.js.map +1 -0
- package/dist/server.d.ts +2 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +103 -92
- package/dist/server.js.map +1 -1
- package/dist/servicenow/client.js +1 -1
- package/dist/servicenow/client.js.map +1 -1
- package/dist/tools/ai-agents.d.ts +145 -0
- package/dist/tools/ai-agents.d.ts.map +1 -0
- package/dist/tools/ai-agents.js +185 -0
- package/dist/tools/ai-agents.js.map +1 -0
- package/dist/tools/cmdb-reconciliation.d.ts +112 -0
- package/dist/tools/cmdb-reconciliation.d.ts.map +1 -0
- package/dist/tools/cmdb-reconciliation.js +267 -0
- package/dist/tools/cmdb-reconciliation.js.map +1 -0
- package/dist/tools/discovery.d.ts +34 -0
- package/dist/tools/discovery.d.ts.map +1 -0
- package/dist/tools/discovery.js +168 -0
- package/dist/tools/discovery.js.map +1 -0
- package/dist/tools/fluent.d.ts +105 -11
- package/dist/tools/fluent.d.ts.map +1 -1
- package/dist/tools/fluent.js +118 -1
- package/dist/tools/fluent.js.map +1 -1
- package/dist/tools/index.d.ts +840 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +44 -6
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/ml.d.ts +104 -0
- package/dist/tools/ml.d.ts.map +1 -1
- package/dist/tools/ml.js +139 -0
- package/dist/tools/ml.js.map +1 -1
- package/dist/tools/now-assist-skills.d.ts +129 -0
- package/dist/tools/now-assist-skills.d.ts.map +1 -0
- package/dist/tools/now-assist-skills.js +128 -0
- package/dist/tools/now-assist-skills.js.map +1 -0
- package/dist/tools/orchestration.d.ts +132 -0
- package/dist/tools/orchestration.d.ts.map +1 -0
- package/dist/tools/orchestration.js +320 -0
- package/dist/tools/orchestration.js.map +1 -0
- package/dist/tools/reporting.d.ts +127 -1
- package/dist/tools/reporting.d.ts.map +1 -1
- package/dist/tools/reporting.js +64 -0
- package/dist/tools/reporting.js.map +1 -1
- package/dist/tools/schema-cache.d.ts +44 -0
- package/dist/tools/schema-cache.d.ts.map +1 -0
- package/dist/tools/schema-cache.js +127 -0
- package/dist/tools/schema-cache.js.map +1 -0
- package/dist/tools-manifest.json +1250 -25
- package/dist/transport/auth-middleware.d.ts +16 -0
- package/dist/transport/auth-middleware.d.ts.map +1 -0
- package/dist/transport/auth-middleware.js +31 -0
- package/dist/transport/auth-middleware.js.map +1 -0
- package/dist/transport/http-server.d.ts +44 -0
- package/dist/transport/http-server.d.ts.map +1 -0
- package/dist/transport/http-server.js +172 -0
- package/dist/transport/http-server.js.map +1 -0
- package/dist/transport/index.d.ts +19 -0
- package/dist/transport/index.d.ts.map +1 -0
- package/dist/transport/index.js +105 -0
- package/dist/transport/index.js.map +1 -0
- package/dist/utils/permissions.d.ts +2 -0
- package/dist/utils/permissions.d.ts.map +1 -1
- package/dist/utils/permissions.js +8 -0
- package/dist/utils/permissions.js.map +1 -1
- package/package.json +27 -4
- package/desktop/renderer/dist/assets/index-B-6BYnh8.js +0 -49
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { ServiceNowError } from '../utils/errors.js';
|
|
2
|
+
import { requireNowAssist, requireWrite } from '../utils/permissions.js';
|
|
3
|
+
export function getOrchestrationToolDefinitions() {
|
|
4
|
+
return [
|
|
5
|
+
{
|
|
6
|
+
name: 'create_playbook',
|
|
7
|
+
description: 'Create a playbook definition with ordered steps that chain tool calls (requires NOW_ASSIST_ENABLED + WRITE_ENABLED)',
|
|
8
|
+
inputSchema: {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
name: { type: 'string', description: 'Playbook name' },
|
|
12
|
+
description: { type: 'string', description: 'Playbook description' },
|
|
13
|
+
steps: {
|
|
14
|
+
type: 'array',
|
|
15
|
+
description: 'Ordered list of playbook steps',
|
|
16
|
+
items: {
|
|
17
|
+
type: 'object',
|
|
18
|
+
properties: {
|
|
19
|
+
tool_name: { type: 'string', description: 'Name of the tool to invoke' },
|
|
20
|
+
args_template: { type: 'object', description: 'Arguments template — can reference {{context.key}} or {{steps[N].result.key}}' },
|
|
21
|
+
condition: { type: 'string', description: 'Optional JS-like condition expression. Step runs only when truthy.' },
|
|
22
|
+
on_error: { type: 'string', enum: ['stop', 'skip', 'continue'], description: 'Error handling: stop (default), skip this step, or continue to next' },
|
|
23
|
+
},
|
|
24
|
+
required: ['tool_name', 'args_template'],
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
required: ['name', 'description', 'steps'],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'execute_playbook',
|
|
33
|
+
description: 'Execute a playbook step by step, passing results forward through context (requires NOW_ASSIST_ENABLED). Supports dry_run.',
|
|
34
|
+
inputSchema: {
|
|
35
|
+
type: 'object',
|
|
36
|
+
properties: {
|
|
37
|
+
playbook: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
description: 'Playbook object with name, description, and steps array',
|
|
40
|
+
properties: {
|
|
41
|
+
name: { type: 'string' },
|
|
42
|
+
description: { type: 'string' },
|
|
43
|
+
steps: {
|
|
44
|
+
type: 'array',
|
|
45
|
+
items: {
|
|
46
|
+
type: 'object',
|
|
47
|
+
properties: {
|
|
48
|
+
tool_name: { type: 'string' },
|
|
49
|
+
args_template: { type: 'object' },
|
|
50
|
+
condition: { type: 'string' },
|
|
51
|
+
on_error: { type: 'string', enum: ['stop', 'skip', 'continue'] },
|
|
52
|
+
},
|
|
53
|
+
required: ['tool_name', 'args_template'],
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
required: ['steps'],
|
|
58
|
+
},
|
|
59
|
+
context: { type: 'object', description: 'Initial context key-value pairs available to all steps' },
|
|
60
|
+
dry_run: { type: 'boolean', description: 'Preview execution plan without invoking tools (default true)' },
|
|
61
|
+
},
|
|
62
|
+
required: ['playbook'],
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'list_playbooks',
|
|
67
|
+
description: 'List stored playbook definitions from sys_hub_action_type_definition',
|
|
68
|
+
inputSchema: {
|
|
69
|
+
type: 'object',
|
|
70
|
+
properties: {
|
|
71
|
+
limit: { type: 'number', description: 'Max records to return (default 25)' },
|
|
72
|
+
},
|
|
73
|
+
required: [],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
const ORCHESTRATION_TOOL_NAMES = new Set([
|
|
79
|
+
'create_playbook', 'execute_playbook', 'list_playbooks',
|
|
80
|
+
]);
|
|
81
|
+
/**
|
|
82
|
+
* Resolve template references like {{context.foo}} and {{steps[0].result.bar}}
|
|
83
|
+
* in argument values against the current execution state.
|
|
84
|
+
*/
|
|
85
|
+
function resolveTemplate(value, context, stepResults) {
|
|
86
|
+
if (typeof value === 'string') {
|
|
87
|
+
return value.replace(/\{\{(.*?)\}\}/g, (_match, expr) => {
|
|
88
|
+
const trimmed = expr.trim();
|
|
89
|
+
// Handle context.key references
|
|
90
|
+
if (trimmed.startsWith('context.')) {
|
|
91
|
+
const path = trimmed.slice('context.'.length);
|
|
92
|
+
return resolvePathValue(context, path) ?? '';
|
|
93
|
+
}
|
|
94
|
+
// Handle steps[N].result.key references
|
|
95
|
+
const stepMatch = trimmed.match(/^steps\[(\d+)\]\.result\.(.+)$/);
|
|
96
|
+
if (stepMatch) {
|
|
97
|
+
const stepIdx = parseInt(stepMatch[1], 10);
|
|
98
|
+
const path = stepMatch[2];
|
|
99
|
+
const stepResult = stepResults[stepIdx];
|
|
100
|
+
if (stepResult?.result) {
|
|
101
|
+
return resolvePathValue(stepResult.result, path) ?? '';
|
|
102
|
+
}
|
|
103
|
+
return '';
|
|
104
|
+
}
|
|
105
|
+
return '';
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
if (Array.isArray(value)) {
|
|
109
|
+
return value.map(item => resolveTemplate(item, context, stepResults));
|
|
110
|
+
}
|
|
111
|
+
if (value !== null && typeof value === 'object') {
|
|
112
|
+
const resolved = {};
|
|
113
|
+
for (const [k, v] of Object.entries(value)) {
|
|
114
|
+
resolved[k] = resolveTemplate(v, context, stepResults);
|
|
115
|
+
}
|
|
116
|
+
return resolved;
|
|
117
|
+
}
|
|
118
|
+
return value;
|
|
119
|
+
}
|
|
120
|
+
/** Resolve a dot-separated path against an object */
|
|
121
|
+
function resolvePathValue(obj, path) {
|
|
122
|
+
const parts = path.split('.');
|
|
123
|
+
let current = obj;
|
|
124
|
+
for (const part of parts) {
|
|
125
|
+
if (current === null || current === undefined)
|
|
126
|
+
return undefined;
|
|
127
|
+
current = current[part];
|
|
128
|
+
}
|
|
129
|
+
return current;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Evaluate a simple condition string against context and step results.
|
|
133
|
+
* Supports basic expressions like "context.count > 0" or "steps[0].result.success == true".
|
|
134
|
+
*/
|
|
135
|
+
function evaluateCondition(condition, context, stepResults) {
|
|
136
|
+
if (!condition || condition.trim() === '')
|
|
137
|
+
return true;
|
|
138
|
+
// Resolve all template references in the condition first
|
|
139
|
+
const resolved = resolveTemplate(condition, context, stepResults);
|
|
140
|
+
// Simple truthy evaluation after template resolution
|
|
141
|
+
// Support basic comparisons: ==, !=, >, <, >=, <=
|
|
142
|
+
const comparisonMatch = String(resolved).match(/^(.+?)\s*(==|!=|>=|<=|>|<)\s*(.+)$/);
|
|
143
|
+
if (comparisonMatch) {
|
|
144
|
+
const [, leftStr, op, rightStr] = comparisonMatch;
|
|
145
|
+
const left = parseConditionValue(leftStr.trim());
|
|
146
|
+
const right = parseConditionValue(rightStr.trim());
|
|
147
|
+
switch (op) {
|
|
148
|
+
case '==': return left == right;
|
|
149
|
+
case '!=': return left != right;
|
|
150
|
+
case '>': return Number(left) > Number(right);
|
|
151
|
+
case '<': return Number(left) < Number(right);
|
|
152
|
+
case '>=': return Number(left) >= Number(right);
|
|
153
|
+
case '<=': return Number(left) <= Number(right);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
// Default: truthy check on the resolved string
|
|
157
|
+
const val = String(resolved).trim().toLowerCase();
|
|
158
|
+
return val !== '' && val !== 'false' && val !== '0' && val !== 'null' && val !== 'undefined';
|
|
159
|
+
}
|
|
160
|
+
function parseConditionValue(val) {
|
|
161
|
+
if (val === 'true')
|
|
162
|
+
return true;
|
|
163
|
+
if (val === 'false')
|
|
164
|
+
return false;
|
|
165
|
+
if (val === 'null' || val === 'undefined')
|
|
166
|
+
return '';
|
|
167
|
+
// Remove surrounding quotes
|
|
168
|
+
if ((val.startsWith('"') && val.endsWith('"')) || (val.startsWith("'") && val.endsWith("'"))) {
|
|
169
|
+
return val.slice(1, -1);
|
|
170
|
+
}
|
|
171
|
+
const num = Number(val);
|
|
172
|
+
if (!isNaN(num) && val !== '')
|
|
173
|
+
return num;
|
|
174
|
+
return val;
|
|
175
|
+
}
|
|
176
|
+
export async function executeOrchestrationToolCall(client, name, args) {
|
|
177
|
+
if (!ORCHESTRATION_TOOL_NAMES.has(name))
|
|
178
|
+
return null;
|
|
179
|
+
switch (name) {
|
|
180
|
+
case 'create_playbook': {
|
|
181
|
+
requireNowAssist();
|
|
182
|
+
requireWrite();
|
|
183
|
+
if (!args.name)
|
|
184
|
+
throw new ServiceNowError('name is required', 'INVALID_REQUEST');
|
|
185
|
+
if (!args.description)
|
|
186
|
+
throw new ServiceNowError('description is required', 'INVALID_REQUEST');
|
|
187
|
+
if (!args.steps || !Array.isArray(args.steps) || args.steps.length === 0) {
|
|
188
|
+
throw new ServiceNowError('steps must be a non-empty array', 'INVALID_REQUEST');
|
|
189
|
+
}
|
|
190
|
+
// Validate each step has required fields
|
|
191
|
+
for (let i = 0; i < args.steps.length; i++) {
|
|
192
|
+
const step = args.steps[i];
|
|
193
|
+
if (!step.tool_name)
|
|
194
|
+
throw new ServiceNowError(`steps[${i}].tool_name is required`, 'INVALID_REQUEST');
|
|
195
|
+
if (!step.args_template || typeof step.args_template !== 'object') {
|
|
196
|
+
throw new ServiceNowError(`steps[${i}].args_template must be an object`, 'INVALID_REQUEST');
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
// Attempt to store as a record; fall back to returning the definition
|
|
200
|
+
try {
|
|
201
|
+
const record = await client.createRecord('sys_hub_action_type_definition', {
|
|
202
|
+
name: args.name,
|
|
203
|
+
description: args.description,
|
|
204
|
+
definition: JSON.stringify({
|
|
205
|
+
steps: args.steps,
|
|
206
|
+
version: '1.0',
|
|
207
|
+
created_by: 'nowaikit',
|
|
208
|
+
}),
|
|
209
|
+
active: true,
|
|
210
|
+
});
|
|
211
|
+
return { message: 'Playbook created', playbook: record };
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
// Table may not exist — return the definition for manual creation
|
|
215
|
+
return {
|
|
216
|
+
message: 'Playbook definition generated (table sys_hub_action_type_definition may not be available). Use this definition for manual creation.',
|
|
217
|
+
definition: {
|
|
218
|
+
name: args.name,
|
|
219
|
+
description: args.description,
|
|
220
|
+
steps: args.steps,
|
|
221
|
+
version: '1.0',
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
case 'execute_playbook': {
|
|
227
|
+
requireNowAssist();
|
|
228
|
+
if (!args.playbook || !args.playbook.steps || !Array.isArray(args.playbook.steps)) {
|
|
229
|
+
throw new ServiceNowError('playbook with steps array is required', 'INVALID_REQUEST');
|
|
230
|
+
}
|
|
231
|
+
const steps = args.playbook.steps;
|
|
232
|
+
const context = args.context || {};
|
|
233
|
+
const dryRun = args.dry_run !== false;
|
|
234
|
+
const stepResults = [];
|
|
235
|
+
// Dynamically import executeTool for live execution
|
|
236
|
+
let executeTool;
|
|
237
|
+
if (!dryRun) {
|
|
238
|
+
const toolIndex = await import('./index.js');
|
|
239
|
+
executeTool = toolIndex.executeTool;
|
|
240
|
+
}
|
|
241
|
+
for (let i = 0; i < steps.length; i++) {
|
|
242
|
+
const step = steps[i];
|
|
243
|
+
const onError = step.on_error || 'stop';
|
|
244
|
+
// Evaluate condition
|
|
245
|
+
if (step.condition) {
|
|
246
|
+
const conditionMet = evaluateCondition(step.condition, context, stepResults);
|
|
247
|
+
if (!conditionMet) {
|
|
248
|
+
stepResults.push({
|
|
249
|
+
step_index: i,
|
|
250
|
+
tool_name: step.tool_name,
|
|
251
|
+
status: 'skipped',
|
|
252
|
+
result: null,
|
|
253
|
+
error: `Condition not met: ${step.condition}`,
|
|
254
|
+
});
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
// Resolve args template
|
|
259
|
+
const resolvedArgs = resolveTemplate(step.args_template, context, stepResults);
|
|
260
|
+
if (dryRun) {
|
|
261
|
+
stepResults.push({
|
|
262
|
+
step_index: i,
|
|
263
|
+
tool_name: step.tool_name,
|
|
264
|
+
status: 'dry_run',
|
|
265
|
+
result: { resolved_args: resolvedArgs },
|
|
266
|
+
});
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
// Execute the step
|
|
270
|
+
const startTime = Date.now();
|
|
271
|
+
try {
|
|
272
|
+
const result = await executeTool(client, step.tool_name, resolvedArgs);
|
|
273
|
+
stepResults.push({
|
|
274
|
+
step_index: i,
|
|
275
|
+
tool_name: step.tool_name,
|
|
276
|
+
status: 'executed',
|
|
277
|
+
result,
|
|
278
|
+
duration_ms: Date.now() - startTime,
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
catch (err) {
|
|
282
|
+
const errorMsg = err instanceof ServiceNowError ? err.message : String(err);
|
|
283
|
+
stepResults.push({
|
|
284
|
+
step_index: i,
|
|
285
|
+
tool_name: step.tool_name,
|
|
286
|
+
status: 'error',
|
|
287
|
+
error: errorMsg,
|
|
288
|
+
duration_ms: Date.now() - startTime,
|
|
289
|
+
});
|
|
290
|
+
if (onError === 'stop') {
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
// 'skip' and 'continue' both move to the next step
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return {
|
|
297
|
+
playbook_name: args.playbook.name || 'unnamed',
|
|
298
|
+
dry_run: dryRun,
|
|
299
|
+
total_steps: steps.length,
|
|
300
|
+
executed: stepResults.filter(s => s.status === 'executed').length,
|
|
301
|
+
skipped: stepResults.filter(s => s.status === 'skipped').length,
|
|
302
|
+
errors: stepResults.filter(s => s.status === 'error').length,
|
|
303
|
+
steps: stepResults,
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
case 'list_playbooks': {
|
|
307
|
+
const limit = args.limit || 25;
|
|
308
|
+
const resp = await client.queryRecords({
|
|
309
|
+
table: 'sys_hub_action_type_definition',
|
|
310
|
+
query: 'active=true',
|
|
311
|
+
limit,
|
|
312
|
+
fields: 'sys_id,name,description,active,sys_updated_on',
|
|
313
|
+
});
|
|
314
|
+
return { count: resp.count, playbooks: resp.records };
|
|
315
|
+
}
|
|
316
|
+
default:
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
//# sourceMappingURL=orchestration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestration.js","sourceRoot":"","sources":["../../src/tools/orchestration.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,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mD;gBACrD,CAAC;YACH,CAAC;YAED,OAAO;gBACL,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,SAAS;gBAC9C,OAAO,EAAE,MAAM;gBACf,WAAW,EAAE,KAAK,CAAC,MAAM;gBACzB,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,MAAM;gBACjE,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,MAAM;gBAC/D,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC,MAAM;gBAC5D,KAAK,EAAE,WAAW;aACnB,CAAC;QACJ,CAAC;QAED,KAAK,gBAAgB,CAAC,CAAC,CAAC;YACtB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YAE/B,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC;gBACrC,KAAK,EAAE,gCAAgC;gBACvC,KAAK,EAAE,aAAa;gBACpB,KAAK;gBACL,MAAM,EAAE,+CAA+C;aACxD,CAAC,CAAC;YACH,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;QACxD,CAAC;QAED;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Reporting & Analytics tools — ServiceNow Reporting API.
|
|
2
|
+
* Reporting & Analytics tools — ServiceNow Reporting API + branded report generation.
|
|
3
3
|
* All tools are Tier 0 (read-only) unless noted.
|
|
4
4
|
* ServiceNow API: GET /api/now/reporting, /api/now/stats/{table}, /api/now/pa/widget/{sys_id}
|
|
5
5
|
*/
|
|
@@ -53,6 +53,9 @@ export declare function getReportingToolDefinitions(): ({
|
|
|
53
53
|
format?: undefined;
|
|
54
54
|
conditions?: undefined;
|
|
55
55
|
unit?: undefined;
|
|
56
|
+
content?: undefined;
|
|
57
|
+
sections?: undefined;
|
|
58
|
+
capability?: undefined;
|
|
56
59
|
};
|
|
57
60
|
required: never[];
|
|
58
61
|
};
|
|
@@ -99,6 +102,9 @@ export declare function getReportingToolDefinitions(): ({
|
|
|
99
102
|
format?: undefined;
|
|
100
103
|
conditions?: undefined;
|
|
101
104
|
unit?: undefined;
|
|
105
|
+
content?: undefined;
|
|
106
|
+
sections?: undefined;
|
|
107
|
+
capability?: undefined;
|
|
102
108
|
};
|
|
103
109
|
required: string[];
|
|
104
110
|
};
|
|
@@ -157,6 +163,9 @@ export declare function getReportingToolDefinitions(): ({
|
|
|
157
163
|
format?: undefined;
|
|
158
164
|
conditions?: undefined;
|
|
159
165
|
unit?: undefined;
|
|
166
|
+
content?: undefined;
|
|
167
|
+
sections?: undefined;
|
|
168
|
+
capability?: undefined;
|
|
160
169
|
};
|
|
161
170
|
required: string[];
|
|
162
171
|
};
|
|
@@ -215,6 +224,9 @@ export declare function getReportingToolDefinitions(): ({
|
|
|
215
224
|
format?: undefined;
|
|
216
225
|
conditions?: undefined;
|
|
217
226
|
unit?: undefined;
|
|
227
|
+
content?: undefined;
|
|
228
|
+
sections?: undefined;
|
|
229
|
+
capability?: undefined;
|
|
218
230
|
};
|
|
219
231
|
required: string[];
|
|
220
232
|
};
|
|
@@ -264,6 +276,9 @@ export declare function getReportingToolDefinitions(): ({
|
|
|
264
276
|
format?: undefined;
|
|
265
277
|
conditions?: undefined;
|
|
266
278
|
unit?: undefined;
|
|
279
|
+
content?: undefined;
|
|
280
|
+
sections?: undefined;
|
|
281
|
+
capability?: undefined;
|
|
267
282
|
};
|
|
268
283
|
required: string[];
|
|
269
284
|
};
|
|
@@ -319,6 +334,9 @@ export declare function getReportingToolDefinitions(): ({
|
|
|
319
334
|
format?: undefined;
|
|
320
335
|
conditions?: undefined;
|
|
321
336
|
unit?: undefined;
|
|
337
|
+
content?: undefined;
|
|
338
|
+
sections?: undefined;
|
|
339
|
+
capability?: undefined;
|
|
322
340
|
};
|
|
323
341
|
required: string[];
|
|
324
342
|
};
|
|
@@ -368,6 +386,9 @@ export declare function getReportingToolDefinitions(): ({
|
|
|
368
386
|
format?: undefined;
|
|
369
387
|
conditions?: undefined;
|
|
370
388
|
unit?: undefined;
|
|
389
|
+
content?: undefined;
|
|
390
|
+
sections?: undefined;
|
|
391
|
+
capability?: undefined;
|
|
371
392
|
};
|
|
372
393
|
required: never[];
|
|
373
394
|
};
|
|
@@ -420,6 +441,9 @@ export declare function getReportingToolDefinitions(): ({
|
|
|
420
441
|
format?: undefined;
|
|
421
442
|
conditions?: undefined;
|
|
422
443
|
unit?: undefined;
|
|
444
|
+
content?: undefined;
|
|
445
|
+
sections?: undefined;
|
|
446
|
+
capability?: undefined;
|
|
423
447
|
};
|
|
424
448
|
required: never[];
|
|
425
449
|
};
|
|
@@ -481,6 +505,9 @@ export declare function getReportingToolDefinitions(): ({
|
|
|
481
505
|
format?: undefined;
|
|
482
506
|
conditions?: undefined;
|
|
483
507
|
unit?: undefined;
|
|
508
|
+
content?: undefined;
|
|
509
|
+
sections?: undefined;
|
|
510
|
+
capability?: undefined;
|
|
484
511
|
};
|
|
485
512
|
required: string[];
|
|
486
513
|
};
|
|
@@ -530,6 +557,9 @@ export declare function getReportingToolDefinitions(): ({
|
|
|
530
557
|
format?: undefined;
|
|
531
558
|
conditions?: undefined;
|
|
532
559
|
unit?: undefined;
|
|
560
|
+
content?: undefined;
|
|
561
|
+
sections?: undefined;
|
|
562
|
+
capability?: undefined;
|
|
533
563
|
};
|
|
534
564
|
required: string[];
|
|
535
565
|
};
|
|
@@ -576,6 +606,9 @@ export declare function getReportingToolDefinitions(): ({
|
|
|
576
606
|
format?: undefined;
|
|
577
607
|
conditions?: undefined;
|
|
578
608
|
unit?: undefined;
|
|
609
|
+
content?: undefined;
|
|
610
|
+
sections?: undefined;
|
|
611
|
+
capability?: undefined;
|
|
579
612
|
};
|
|
580
613
|
required: string[];
|
|
581
614
|
};
|
|
@@ -643,6 +676,9 @@ export declare function getReportingToolDefinitions(): ({
|
|
|
643
676
|
format?: undefined;
|
|
644
677
|
conditions?: undefined;
|
|
645
678
|
unit?: undefined;
|
|
679
|
+
content?: undefined;
|
|
680
|
+
sections?: undefined;
|
|
681
|
+
capability?: undefined;
|
|
646
682
|
};
|
|
647
683
|
required: string[];
|
|
648
684
|
};
|
|
@@ -695,6 +731,9 @@ export declare function getReportingToolDefinitions(): ({
|
|
|
695
731
|
format?: undefined;
|
|
696
732
|
conditions?: undefined;
|
|
697
733
|
unit?: undefined;
|
|
734
|
+
content?: undefined;
|
|
735
|
+
sections?: undefined;
|
|
736
|
+
capability?: undefined;
|
|
698
737
|
};
|
|
699
738
|
required: never[];
|
|
700
739
|
};
|
|
@@ -727,6 +766,7 @@ export declare function getReportingToolDefinitions(): ({
|
|
|
727
766
|
format: {
|
|
728
767
|
type: string;
|
|
729
768
|
description: string;
|
|
769
|
+
enum?: undefined;
|
|
730
770
|
};
|
|
731
771
|
search?: undefined;
|
|
732
772
|
category?: undefined;
|
|
@@ -756,6 +796,9 @@ export declare function getReportingToolDefinitions(): ({
|
|
|
756
796
|
status?: undefined;
|
|
757
797
|
conditions?: undefined;
|
|
758
798
|
unit?: undefined;
|
|
799
|
+
content?: undefined;
|
|
800
|
+
sections?: undefined;
|
|
801
|
+
capability?: undefined;
|
|
759
802
|
};
|
|
760
803
|
required: string[];
|
|
761
804
|
};
|
|
@@ -817,6 +860,89 @@ export declare function getReportingToolDefinitions(): ({
|
|
|
817
860
|
day_of_week?: undefined;
|
|
818
861
|
day_of_month?: undefined;
|
|
819
862
|
format?: undefined;
|
|
863
|
+
content?: undefined;
|
|
864
|
+
sections?: undefined;
|
|
865
|
+
capability?: undefined;
|
|
866
|
+
};
|
|
867
|
+
required: string[];
|
|
868
|
+
};
|
|
869
|
+
} | {
|
|
870
|
+
name: string;
|
|
871
|
+
description: string;
|
|
872
|
+
inputSchema: {
|
|
873
|
+
type: string;
|
|
874
|
+
properties: {
|
|
875
|
+
content: {
|
|
876
|
+
type: string;
|
|
877
|
+
description: string;
|
|
878
|
+
};
|
|
879
|
+
sections: {
|
|
880
|
+
type: string;
|
|
881
|
+
description: string;
|
|
882
|
+
items: {
|
|
883
|
+
type: string;
|
|
884
|
+
properties: {
|
|
885
|
+
content: {
|
|
886
|
+
type: string;
|
|
887
|
+
description: string;
|
|
888
|
+
};
|
|
889
|
+
title: {
|
|
890
|
+
type: string;
|
|
891
|
+
description: string;
|
|
892
|
+
};
|
|
893
|
+
capability: {
|
|
894
|
+
type: string;
|
|
895
|
+
description: string;
|
|
896
|
+
};
|
|
897
|
+
};
|
|
898
|
+
required: string[];
|
|
899
|
+
};
|
|
900
|
+
};
|
|
901
|
+
format: {
|
|
902
|
+
type: string;
|
|
903
|
+
enum: string[];
|
|
904
|
+
description: string;
|
|
905
|
+
};
|
|
906
|
+
title: {
|
|
907
|
+
type: string;
|
|
908
|
+
description: string;
|
|
909
|
+
};
|
|
910
|
+
capability: {
|
|
911
|
+
type: string;
|
|
912
|
+
description: string;
|
|
913
|
+
};
|
|
914
|
+
search?: undefined;
|
|
915
|
+
category?: undefined;
|
|
916
|
+
limit?: undefined;
|
|
917
|
+
sys_id_or_name?: undefined;
|
|
918
|
+
table?: undefined;
|
|
919
|
+
group_by?: undefined;
|
|
920
|
+
aggregate?: undefined;
|
|
921
|
+
query?: undefined;
|
|
922
|
+
date_field?: undefined;
|
|
923
|
+
periods?: undefined;
|
|
924
|
+
widget_sys_id?: undefined;
|
|
925
|
+
time_range?: undefined;
|
|
926
|
+
fields?: undefined;
|
|
927
|
+
active?: undefined;
|
|
928
|
+
name?: undefined;
|
|
929
|
+
script?: undefined;
|
|
930
|
+
run_type?: undefined;
|
|
931
|
+
run_time?: undefined;
|
|
932
|
+
run_period?: undefined;
|
|
933
|
+
sys_id?: undefined;
|
|
934
|
+
type?: undefined;
|
|
935
|
+
field?: undefined;
|
|
936
|
+
roles?: undefined;
|
|
937
|
+
job_sys_id?: undefined;
|
|
938
|
+
status?: undefined;
|
|
939
|
+
report_id?: undefined;
|
|
940
|
+
frequency?: undefined;
|
|
941
|
+
recipients?: undefined;
|
|
942
|
+
day_of_week?: undefined;
|
|
943
|
+
day_of_month?: undefined;
|
|
944
|
+
conditions?: undefined;
|
|
945
|
+
unit?: undefined;
|
|
820
946
|
};
|
|
821
947
|
required: string[];
|
|
822
948
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporting.d.ts","sourceRoot":"","sources":["../../src/tools/reporting.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAIhE,wBAAgB,2BAA2B
|
|
1
|
+
{"version":3,"file":"reporting.d.ts","sourceRoot":"","sources":["../../src/tools/reporting.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAIhE,wBAAgB,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA0R1C;AAED,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACxB,OAAO,CAAC,GAAG,CAAC,CA0Nd"}
|
package/dist/tools/reporting.js
CHANGED
|
@@ -253,6 +253,33 @@ export function getReportingToolDefinitions() {
|
|
|
253
253
|
required: ['name', 'table', 'aggregate'],
|
|
254
254
|
},
|
|
255
255
|
},
|
|
256
|
+
{
|
|
257
|
+
name: 'generate_report',
|
|
258
|
+
description: 'Generate a branded PDF or PPTX report from capability analysis results. Call this after completing a scan, review, or audit to create a management-ready document with charts, tables, and ServiceNow links. Supports single capability (content) or multiple capabilities (sections) in one combined report.',
|
|
259
|
+
inputSchema: {
|
|
260
|
+
type: 'object',
|
|
261
|
+
properties: {
|
|
262
|
+
content: { type: 'string', description: 'Full markdown analysis to convert into a branded report (for single capability)' },
|
|
263
|
+
sections: {
|
|
264
|
+
type: 'array',
|
|
265
|
+
description: 'Multiple capability analyses to combine into one report. Each section becomes a chapter. Use this instead of content for multi-capability reports.',
|
|
266
|
+
items: {
|
|
267
|
+
type: 'object',
|
|
268
|
+
properties: {
|
|
269
|
+
content: { type: 'string', description: 'Markdown analysis for this capability' },
|
|
270
|
+
title: { type: 'string', description: 'Section title (e.g. "Instance Health Scan")' },
|
|
271
|
+
capability: { type: 'string', description: 'Capability name (e.g. "scan-health")' },
|
|
272
|
+
},
|
|
273
|
+
required: ['content', 'title'],
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
format: { type: 'string', enum: ['pdf', 'pptx'], description: 'Output format: pdf (branded document) or pptx (slide deck)' },
|
|
277
|
+
title: { type: 'string', description: 'Report title (e.g. "Instance Health Scan", "Comprehensive Instance Audit")' },
|
|
278
|
+
capability: { type: 'string', description: 'Capability name that produced the analysis (e.g. "scan-health", "review-code", "combined-audit")' },
|
|
279
|
+
},
|
|
280
|
+
required: ['format', 'title'],
|
|
281
|
+
},
|
|
282
|
+
},
|
|
256
283
|
];
|
|
257
284
|
}
|
|
258
285
|
export async function executeReportingToolCall(client, name, args) {
|
|
@@ -453,6 +480,43 @@ export async function executeReportingToolCall(client, name, args) {
|
|
|
453
480
|
});
|
|
454
481
|
return { ...result, summary: `Created KPI "${args.name}" (${args.aggregate} on ${args.table})` };
|
|
455
482
|
}
|
|
483
|
+
case 'generate_report': {
|
|
484
|
+
if (!args.format || !args.title)
|
|
485
|
+
throw new ServiceNowError('format and title are required', 'INVALID_REQUEST');
|
|
486
|
+
if (!args.content && !args.sections)
|
|
487
|
+
throw new ServiceNowError('Either content (single capability) or sections (multiple capabilities) is required', 'INVALID_REQUEST');
|
|
488
|
+
if (args.format !== 'pdf' && args.format !== 'pptx')
|
|
489
|
+
throw new ServiceNowError('format must be "pdf" or "pptx"', 'INVALID_REQUEST');
|
|
490
|
+
// Combine sections into a single markdown document if multiple capabilities provided
|
|
491
|
+
let combinedContent;
|
|
492
|
+
let capabilityName;
|
|
493
|
+
if (args.sections && Array.isArray(args.sections) && args.sections.length > 0) {
|
|
494
|
+
combinedContent = args.sections
|
|
495
|
+
.map((s) => `\n\n---\n\n# ${s.title}\n\n${s.content}`)
|
|
496
|
+
.join('\n');
|
|
497
|
+
capabilityName = args.capability || (args.sections.length > 1 ? 'combined-audit' : args.sections[0].capability || 'report');
|
|
498
|
+
}
|
|
499
|
+
else {
|
|
500
|
+
combinedContent = args.content;
|
|
501
|
+
capabilityName = args.capability || 'report';
|
|
502
|
+
}
|
|
503
|
+
const { generateReport } = await import('../reports/index.js');
|
|
504
|
+
const reportResult = await generateReport(combinedContent, args.format, {
|
|
505
|
+
title: args.title,
|
|
506
|
+
instanceUrl: client.baseUrl || '',
|
|
507
|
+
instanceName: capabilityName,
|
|
508
|
+
capability: capabilityName,
|
|
509
|
+
});
|
|
510
|
+
const sectionCount = args.sections ? args.sections.length : 1;
|
|
511
|
+
return {
|
|
512
|
+
success: true,
|
|
513
|
+
file_path: reportResult.filePath,
|
|
514
|
+
size_bytes: reportResult.sizeBytes,
|
|
515
|
+
format: args.format,
|
|
516
|
+
sections: sectionCount,
|
|
517
|
+
message: `Report saved to ${reportResult.filePath} (${Math.round(reportResult.sizeBytes / 1024)} KB, ${sectionCount} capability${sectionCount > 1 ? 'ies' : ''})`,
|
|
518
|
+
};
|
|
519
|
+
}
|
|
456
520
|
default:
|
|
457
521
|
return null;
|
|
458
522
|
}
|