@sassoftware/sas-score-mcp-serverjs 0.4.1-1 → 0.4.1-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.
@@ -1,81 +1,81 @@
1
- /*
2
- * Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
-
6
- import { z } from 'zod';
7
- import _jobSubmit from '../toolHelpers/_jobSubmit.js';
8
-
9
- function runJob(_appContext) {
10
-
11
- let description = `
12
- run-job — execute a deployed SAS Viya job.
13
-
14
- USE when: run job, execute job, run with parameters
15
- DO NOT USE for: arbitrary SAS code (use run-sas-program), macros (use run-macro), list/find jobs
16
-
17
- PARAMETERS
18
- - name: string — job name (required)
19
- - scenario: string | object — input parameters. Accepts: "x=1, y=2" or {x:1, y:2}
20
-
21
- ROUTING RULES
22
- - "run job xyz" → { name: "xyz" }
23
- - "run job xyz with param1=10, param2=val2" → { name: "xyz", scenario: {param1:10, param2:"val2"} }
24
-
25
- EXAMPLES
26
- - "run job xyz" → { name: "xyz" }
27
- - "run job monthly_etl with month=10, year=2025" → { name: "monthly_etl", scenario: {month:10, year:2025} }
28
-
29
- NEGATIVE EXAMPLES (do not route here)
30
- - "run SAS code" (use run-sas-program)
31
- - "run macro X" (use run-macro)
32
- - "list jobs" (use list-jobs)
33
- - "find job X" (use find-job)
34
-
35
- ERRORS
36
- Returns log output, listings, tables from job. Error if job not found.
37
- `;
38
-
39
- let spec = {
40
- name: 'run-job',
41
- description: description,
42
- inputSchema: z.object({
43
- name: z.string(),
44
- scenario: z.any(),
45
- }),
46
- handler: async (params) => {
47
- let scenario = params.scenario;
48
- let scenarioObj = {};
49
- let count = 0;
50
- //
51
- if (scenario == null) {
52
- scenarioObj = {};
53
- } else if (typeof scenario === 'object') {
54
- scenarioObj = scenario;
55
- } else if (Array.isArray(scenario)) {
56
- scenarioObj = scenario[0];
57
- } else if (typeof scenario === 'string') {
58
- if (scenario.trim() === '') {
59
- scenarioObj = {};
60
- } else {
61
- // console.error('Incoming scenario', scenario);
62
- scenarioObj = scenario.split(',').reduce((acc, pair) => {
63
- let [key, value] = pair.split('=');
64
- acc[key.trim()] = value;
65
- count++;
66
- return acc;
67
- }, {});
68
- }
69
- }
70
- params.type = 'job';
71
- params.scenario = scenarioObj;
72
- // Provide runtime context for auth and server settings
73
- let r = await _jobSubmit(params);
74
- return r;
75
- }
76
- };
77
- return spec;
78
- }
79
-
80
- export default runJob;
81
-
1
+ /*
2
+ * Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ import { z } from 'zod';
7
+ import _jobSubmit from '../toolHelpers/_jobSubmit.js';
8
+
9
+ function runJob(_appContext) {
10
+
11
+ let description = `
12
+ run-job — execute a deployed SAS Viya job.
13
+
14
+ USE when: run job, execute job, run with parameters
15
+ DO NOT USE for: arbitrary SAS code (use run-sas-program), macros (use run-macro), list/find jobs
16
+
17
+ PARAMETERS
18
+ - name: string — job name (required)
19
+ - scenario: string | object — input parameters. Accepts: "x=1, y=2" or {x:1, y:2}
20
+
21
+ ROUTING RULES
22
+ - "run job xyz" → { name: "xyz" }
23
+ - "run job xyz with param1=10, param2=val2" → { name: "xyz", scenario: {param1:10, param2:"val2"} }
24
+
25
+ EXAMPLES
26
+ - "run job xyz" → { name: "xyz" }
27
+ - "run job monthly_etl with month=10, year=2025" → { name: "monthly_etl", scenario: {month:10, year:2025} }
28
+
29
+ NEGATIVE EXAMPLES (do not route here)
30
+ - "run SAS code" (use run-sas-program)
31
+ - "run macro X" (use run-macro)
32
+ - "list jobs" (use list-jobs)
33
+ - "find job X" (use find-job)
34
+
35
+ ERRORS
36
+ Returns log output, listings, tables from job. Error if job not found.
37
+ `;
38
+
39
+ let spec = {
40
+ name: 'run-job',
41
+ description: description,
42
+ inputSchema: z.object({
43
+ name: z.string(),
44
+ scenario: z.string().optional()
45
+ }),
46
+ handler: async (params) => {
47
+ let scenario = params.scenario;
48
+ let scenarioObj = {};
49
+ let count = 0;
50
+ //
51
+ if (scenario == null) {
52
+ scenarioObj = {};
53
+ } else if (typeof scenario === 'object') {
54
+ scenarioObj = scenario;
55
+ } else if (Array.isArray(scenario)) {
56
+ scenarioObj = scenario[0];
57
+ } else if (typeof scenario === 'string') {
58
+ if (scenario.trim() === '') {
59
+ scenarioObj = {};
60
+ } else {
61
+ // console.error('Incoming scenario', scenario);
62
+ scenarioObj = scenario.split(',').reduce((acc, pair) => {
63
+ let [key, value] = pair.split('=');
64
+ acc[key.trim()] = value;
65
+ count++;
66
+ return acc;
67
+ }, {});
68
+ }
69
+ }
70
+ params.type = 'job';
71
+ params.scenario = scenarioObj;
72
+ // Provide runtime context for auth and server settings
73
+ let r = await _jobSubmit(params);
74
+ return r;
75
+ }
76
+ };
77
+ return spec;
78
+ }
79
+
80
+ export default runJob;
81
+
@@ -1,82 +1,82 @@
1
- /*
2
- * Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
-
6
- import { z } from 'zod';
7
- import _jobSubmit from '../toolHelpers/_jobSubmit.js';
8
-
9
- function runJobdef(_appContext) {
10
- // JSON object for LLM/tooling
11
-
12
- let description = `
13
- run-jobdef — execute a SAS Viya job definition.
14
-
15
- USE when: run jobdef, execute jobdef, run with parameters
16
- DO NOT USE for: arbitrary SAS code (use run-sas-program), macros (use run-macro), list/find jobdefs
17
-
18
- PARAMETERS
19
- - name: string — jobdef name (required)
20
- - scenario: string | object — input parameters. Accepts: "x=1, y=2" or {x:1, y:2}
21
-
22
- ROUTING RULES
23
- - "run jobdef xyz" → { name: "xyz" }
24
- - "run jobdef xyz with param1=10, param2=val2" → { name: "xyz", scenario: {param1:10, param2:"val2"} }
25
-
26
- EXAMPLES
27
- - "run jobdef xyz" → { name: "xyz" }
28
- - "run jobdef monthly_report with month=10, year=2025" → { name: "monthly_report", scenario: {month:10, year:2025} }
29
-
30
- NEGATIVE EXAMPLES (do not route here)
31
- - "run SAS code" (use run-sas-program)
32
- - "run macro X" (use run-macro)
33
- - "list jobdefs" (use list-jobdefs)
34
- - "find jobdef X" (use find-jobdef)
35
-
36
- ERRORS
37
- Returns log output, listings, tables from jobdef. Error if jobdef not found.
38
- `;
39
-
40
- let spec = {
41
- name: 'run-jobdef',
42
- description: description,
43
- inputSchema: z.object({
44
- name: z.string(),
45
- scenario: z.any()
46
- }),
47
- handler: async (params) => {
48
- let scenario = params.scenario;
49
- let scenarioObj = {};
50
- let count = 0;
51
- //
52
- if (scenario == null) {
53
- scenarioObj = {};
54
- } else if (typeof scenario === 'object') {
55
- scenarioObj = scenario;
56
- } else if (Array.isArray(scenario)) {
57
- scenarioObj = scenario[0];
58
- } else if (typeof scenario === 'string') {
59
- if (scenario.trim() === '') {
60
- scenarioObj = {};
61
- } else {
62
- // console.error('Incoming scenario', scenario);
63
- scenarioObj = scenario.split(',').reduce((acc, pair) => {
64
- let [key, value] = pair.split('=');
65
- acc[key.trim()] = value;
66
- count++;
67
- return acc;
68
- }, {});
69
- }
70
- }
71
- params.type = 'def';
72
- params.scenario = scenarioObj;
73
- // Provide runtime context for auth and server settings
74
- let r = await _jobSubmit(params);
75
- return r;
76
- }
77
- };
78
- return spec;
79
- }
80
-
81
- export default runJobdef;
82
-
1
+ /*
2
+ * Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ import { z } from 'zod';
7
+ import _jobSubmit from '../toolHelpers/_jobSubmit.js';
8
+
9
+ function runJobdef(_appContext) {
10
+ // JSON object for LLM/tooling
11
+
12
+ let description = `
13
+ run-jobdef — execute a SAS Viya job definition.
14
+
15
+ USE when: run jobdef, execute jobdef, run with parameters
16
+ DO NOT USE for: arbitrary SAS code (use run-sas-program), macros (use run-macro), list/find jobdefs
17
+
18
+ PARAMETERS
19
+ - name: string — jobdef name (required)
20
+ - scenario: string | object — input parameters. Accepts: "x=1, y=2" or {x:1, y:2}
21
+
22
+ ROUTING RULES
23
+ - "run jobdef xyz" → { name: "xyz" }
24
+ - "run jobdef xyz with param1=10, param2=val2" → { name: "xyz", scenario: {param1:10, param2:"val2"} }
25
+
26
+ EXAMPLES
27
+ - "run jobdef xyz" → { name: "xyz" }
28
+ - "run jobdef monthly_report with month=10, year=2025" → { name: "monthly_report", scenario: {month:10, year:2025} }
29
+
30
+ NEGATIVE EXAMPLES (do not route here)
31
+ - "run SAS code" (use run-sas-program)
32
+ - "run macro X" (use run-macro)
33
+ - "list jobdefs" (use list-jobdefs)
34
+ - "find jobdef X" (use find-jobdef)
35
+
36
+ ERRORS
37
+ Returns log output, listings, tables from jobdef. Error if jobdef not found.
38
+ `;
39
+
40
+ let spec = {
41
+ name: 'run-jobdef',
42
+ description: description,
43
+ inputSchema: z.object({
44
+ name: z.string(),
45
+ scenario: z.string().optional()
46
+ }),
47
+ handler: async (params) => {
48
+ let scenario = params.scenario;
49
+ let scenarioObj = {};
50
+ let count = 0;
51
+ //
52
+ if (scenario == null) {
53
+ scenarioObj = {};
54
+ } else if (typeof scenario === 'object') {
55
+ scenarioObj = scenario;
56
+ } else if (Array.isArray(scenario)) {
57
+ scenarioObj = scenario[0];
58
+ } else if (typeof scenario === 'string') {
59
+ if (scenario.trim() === '') {
60
+ scenarioObj = {};
61
+ } else {
62
+ // console.error('Incoming scenario', scenario);
63
+ scenarioObj = scenario.split(',').reduce((acc, pair) => {
64
+ let [key, value] = pair.split('=');
65
+ acc[key.trim()] = value;
66
+ count++;
67
+ return acc;
68
+ }, {});
69
+ }
70
+ }
71
+ params.type = 'def';
72
+ params.scenario = scenarioObj;
73
+ // Provide runtime context for auth and server settings
74
+ let r = await _jobSubmit(params);
75
+ return r;
76
+ }
77
+ };
78
+ return spec;
79
+ }
80
+
81
+ export default runJobdef;
82
+
@@ -1,81 +1,82 @@
1
- /*
2
- * Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
-
6
- import { z } from 'zod';
7
- import _submitCode from '../toolHelpers/_submitCode.js';
8
-
9
-
10
- function runMacro(_appContext) {
11
- let description = `
12
- run-macro — submit and execute a SAS macro on SAS Viya server.
13
-
14
- USE when: run macro, execute macro with parameters
15
- DO NOT USE for: arbitrary SAS code (use run-sas-program), jobs, jobdefs
16
-
17
- PARAMETERS
18
- - macro: string — macro name without "%" (required)
19
- - scenario: string — parameters or setup code (optional). Accepts: "x=1, y=abc" or "%let x=1; %let y=abc;"
20
-
21
- ROUTING RULES
22
- - "run macro abc" → { macro: "abc", scenario: "" }
23
- - "run macro abc with x=1, y=2" → { macro: "abc", scenario: "x=1, y=2" }
24
- - "run macro xyz with %let a=1; %let b=2;" → { macro: "xyz", scenario: "%let a=1; %let b=2;" }
25
-
26
- EXAMPLES
27
- - "run macro abc" → { macro: "abc", scenario: "" }
28
- - "run macro summarize with x=1, y=2" → { macro: "summarize", scenario: "x=1, y=2" }
29
-
30
- NEGATIVE EXAMPLES (do not route here)
31
- - "run SAS code" (use run-sas-program)
32
- - "run job X" (use run-job)
33
- - "run jobdef X" (use run-jobdef)
34
-
35
- ERRORS
36
- Returns log, ods, tables created by macro. Auto-converts "x=1, y=2" to "%let x=1; %let y=2;" format.
37
- `;
38
-
39
- let spec = {
40
- name: 'run-macro',
41
- description: description,
42
-
43
- inputSchema: z.object({
44
- macro: z.string(),
45
- scenario: z.string()
46
- }),
47
- handler: async (params) => {
48
- const scenarioRaw = (params.scenario || '').trim();
49
- let setup = '';
50
- if (scenarioRaw) {
51
- // If the scenario already contains macro syntax, send it through unchanged
52
- const hasMacroSyntax = /%let\b|%[a-zA-Z_]\w*\s*\(|%[a-zA-Z_]\w*\s*;/.test(scenarioRaw) || scenarioRaw.includes('%');
53
- if (hasMacroSyntax) {
54
- setup = scenarioRaw;
55
- } else {
56
- // Convert "x=1,y=abc" -> "%let x=1; %let y=abc;"
57
- setup = scenarioRaw.split(',')
58
- .map(p => p.trim())
59
- .filter(Boolean)
60
- .map(p => {
61
- const [k, ...rest] = p.split('=');
62
- if (!k) return '';
63
- const key = k.trim();
64
- const val = rest.join('=').trim();
65
- return `%let ${key}=${val};`;
66
- })
67
- .filter(Boolean)
68
- .join(' ');
69
- }
70
- }
71
- const src = `${setup} %${params.macro};`;
72
- params.src = src;
73
- let r = await _submitCode(params);
74
- return r;
75
- }
76
- }
77
- return spec;
78
- }
79
-
80
- export default runMacro;
1
+ /*
2
+ * Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ import { z } from 'zod';
7
+ import _submitCode from '../toolHelpers/_submitCode.js';
8
+
9
+
10
+ function runMacro(_appContext) {
11
+ let description = `
12
+ run-macro — submit and execute a SAS macro on SAS Viya server.
13
+
14
+ USE when: run macro, execute macro with parameters
15
+ DO NOT USE for: arbitrary SAS code (use run-sas-program), jobs, jobdefs
16
+
17
+ PARAMETERS
18
+ - macro: string — macro name without "%" (required)
19
+ - scenario: string — parameters or setup code (optional). Accepts: "x=1, y=abc" or "%let x=1; %let y=abc;"
20
+
21
+ ROUTING RULES
22
+ - "run macro abc" → { macro: "abc", scenario: "" }
23
+ - "run macro abc with x=1, y=2" → { macro: "abc", scenario: "x=1, y=2" }
24
+ - "run macro xyz with %let a=1; %let b=2;" → { macro: "xyz", scenario: "%let a=1; %let b=2;" }
25
+
26
+ EXAMPLES
27
+ - "run macro abc" → { macro: "abc", scenario: "" }
28
+ - "run macro summarize with x=1, y=2" → { macro: "summarize", scenario: "x=1, y=2" }
29
+
30
+ NEGATIVE EXAMPLES (do not route here)
31
+ - "run SAS code" (use run-sas-program)
32
+ - "run job X" (use run-job)
33
+ - "run jobdef X" (use run-jobdef)
34
+
35
+ ERRORS
36
+ Returns log, ods, tables created by macro. Auto-converts "x=1, y=2" to "%let x=1; %let y=2;" format.
37
+ `;
38
+
39
+ let spec = {
40
+ name: 'run-macro',
41
+ description: description,
42
+
43
+ inputSchema: z.object({
44
+ macro: z.string(),
45
+ scenario: z.string().optional()
46
+ }),
47
+
48
+ handler: async (params) => {
49
+ const scenarioRaw = (params.scenario || '').trim();
50
+ let setup = '';
51
+ if (scenarioRaw) {
52
+ // If the scenario already contains macro syntax, send it through unchanged
53
+ const hasMacroSyntax = /%let\b|%[a-zA-Z_]\w*\s*\(|%[a-zA-Z_]\w*\s*;/.test(scenarioRaw) || scenarioRaw.includes('%');
54
+ if (hasMacroSyntax) {
55
+ setup = scenarioRaw;
56
+ } else {
57
+ // Convert "x=1,y=abc" -> "%let x=1; %let y=abc;"
58
+ setup = scenarioRaw.split(',')
59
+ .map(p => p.trim())
60
+ .filter(Boolean)
61
+ .map(p => {
62
+ const [k, ...rest] = p.split('=');
63
+ if (!k) return '';
64
+ const key = k.trim();
65
+ const val = rest.join('=').trim();
66
+ return `%let ${key}=${val};`;
67
+ })
68
+ .filter(Boolean)
69
+ .join(' ');
70
+ }
71
+ }
72
+ const src = `${setup} %${params.macro};`;
73
+ params.src = src;
74
+ let r = await _submitCode(params);
75
+ return r;
76
+ }
77
+ }
78
+ return spec;
79
+ }
80
+
81
+ export default runMacro;
81
82
 
@@ -45,15 +45,11 @@ Returns log, ods, tables array, data (if output specified). Error if execution f
45
45
  description: description,
46
46
  inputSchema: z.object({
47
47
  src: z.string(),
48
- scenario: z.any(),
49
- output: z.string(),
50
- folder: z.string(),
51
- limit: z.number()
48
+ scenario: z.string().optional(),
49
+ output: z.string().optional(),
50
+ folder: z.string().optional(),
51
+ limit: z.number().optional()
52
52
  }),
53
- // NOTE: Previously 'required' incorrectly listed 'program' which does not
54
- // exist in the schema. This prevented execution in some orchestrators that
55
- // enforce required parameter presence, causing only descriptions to appear.
56
- // Corrected to 'src'.
57
53
  handler: async (params) => {
58
54
  let {src, folder, scenario, _appContext} = params;
59
55
  // figure out src