diff --git a/ts/examples/memoryProviders/package.json b/ts/examples/memoryProviders/package.json index 1003aed51..f674572f6 100644 --- a/ts/examples/memoryProviders/package.json +++ b/ts/examples/memoryProviders/package.json @@ -21,7 +21,7 @@ "clean": "rimraf --glob dist *.tsbuildinfo *.done.build.log", "prettier": "prettier --check . --ignore-path ../../.prettierignore", "prettier:fix": "prettier --write . --ignore-path ../../.prettierignore", - "test": "npm run test", + "test": "npm run test:local", "test:local": "node --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=\".*\\.spec\\.js\"", "test:local:debug": "node --inspect-brk --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=\".*\\.spec\\.js\"", "tsc": "tsc -b" diff --git a/ts/packages/actionSchema/package.json b/ts/packages/actionSchema/package.json index 4e69bae13..b8a95852f 100644 --- a/ts/packages/actionSchema/package.json +++ b/ts/packages/actionSchema/package.json @@ -23,7 +23,7 @@ "clean": "rimraf --glob dist *.tsbuildinfo *.done.build.log", "prettier": "prettier --check . --ignore-path ../../.prettierignore", "prettier:fix": "prettier --write . --ignore-path ../../prettierignore", - "test": "npm run test", + "test": "npm run test:local", "test:local": "node --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=\".*\\.spec\\.js\"", "test:local:debug": "node --inspect-brk --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=\".*\\.spec\\.js\"", "tsc": "tsc -b" diff --git a/ts/packages/actionSchema/src/validate.ts b/ts/packages/actionSchema/src/validate.ts index 8a3689279..4095268f0 100644 --- a/ts/packages/actionSchema/src/validate.ts +++ b/ts/packages/actionSchema/src/validate.ts @@ -147,7 +147,7 @@ function validateObject( ignoreExtraneous?.includes(actualField) !== true ) { const fullName = name ? `${name}.${actualField}` : actualField; - throw new Error(`Extraneous property ${fullName}`); + throw new Error(`Extraneous property '${fullName}'`); } } } diff --git a/ts/packages/agents/test/src/handler.ts b/ts/packages/agents/test/src/handler.ts index b6922374f..0f22fe2fc 100644 --- a/ts/packages/agents/test/src/handler.ts +++ b/ts/packages/agents/test/src/handler.ts @@ -52,7 +52,9 @@ async function executeAction( case "add": const { a, b } = action.parameters; return createActionResult(`The sum of ${a} and ${b} is ${a + b}`); + case "random": + return createActionResult(`Random number: ${Math.random()}`); default: - throw new Error(`Unknown action: ${action.actionName}`); + throw new Error(`Unknown action: ${(action as any).actionName}`); } } diff --git a/ts/packages/agents/test/src/schema.ts b/ts/packages/agents/test/src/schema.ts index 5334936f9..43e03250e 100644 --- a/ts/packages/agents/test/src/schema.ts +++ b/ts/packages/agents/test/src/schema.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -export type TestActions = AddAction; +export type TestActions = AddAction | RandomNumberAction; type AddAction = { actionName: "add"; parameters: { @@ -9,3 +9,7 @@ type AddAction = { b: number; }; }; + +type RandomNumberAction = { + actionName: "random"; +}; diff --git a/ts/packages/aiclient/package.json b/ts/packages/aiclient/package.json index 89b631e15..6a05955e7 100644 --- a/ts/packages/aiclient/package.json +++ b/ts/packages/aiclient/package.json @@ -22,7 +22,7 @@ "clean": "rimraf --glob dist *.tsbuildinfo *.done.build.log", "prettier": "prettier --check . --ignore-path ../../.prettierignore", "prettier:fix": "prettier --write . --ignore-path ../../prettierignore", - "test": "npm run test", + "test": "npm run test:local", "test:local": "node --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=\".*\\.spec\\.js\"", "test:local:debug": "node --inspect-brk --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=\".*\\.spec\\.js\"", "tsc": "tsc -b" diff --git a/ts/packages/api/package.json b/ts/packages/api/package.json index 13ba834cf..a373ca2bb 100644 --- a/ts/packages/api/package.json +++ b/ts/packages/api/package.json @@ -18,7 +18,7 @@ "prettier": "prettier --check . --ignore-path ../../.prettierignore", "prettier:fix": "prettier --write . --ignore-path ../../.prettierignore", "start": "node ./dist/index.js", - "test": "npm run test", + "test": "npm run test:local", "test:local": "node --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=\".*\\.spec\\.js\"", "test:local:debug": "node --inspect-brk --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=\".*\\.spec\\.js\"", "tsc": "tsc -b" diff --git a/ts/packages/cache/package.json b/ts/packages/cache/package.json index c23c6673e..12b016b68 100644 --- a/ts/packages/cache/package.json +++ b/ts/packages/cache/package.json @@ -22,7 +22,7 @@ "clean": "rimraf --glob dist *.tsbuildinfo *.done.build.log", "prettier": "prettier --check . --ignore-path ../../.prettierignore", "prettier:fix": "prettier --write . --ignore-path ../../.prettierignore", - "test": "npm run test", + "test": "npm run test:local", "test:local": "node --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=\".*\\.spec\\.js\"", "test:local:debug": "node --inspect-brk --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=\".*\\.spec\\.js\"", "tsc": "tsc -b" diff --git a/ts/packages/commonUtils/package.json b/ts/packages/commonUtils/package.json index 3247505c3..c9ad4cc7a 100644 --- a/ts/packages/commonUtils/package.json +++ b/ts/packages/commonUtils/package.json @@ -23,7 +23,7 @@ "clean": "rimraf --glob dist *.tsbuildinfo *.done.build.log", "prettier": "prettier --check . --ignore-path ../../.prettierignore", "prettier:fix": "prettier --write . --ignore-path ../../.prettierignore", - "test": "npm run test", + "test": "npm run test:local", "test:local": "node --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=\".*\\.spec\\.js\"", "test:local:debug": "node --inspect-brk --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=\".*\\.spec\\.js\"", "tsc": "tsc -b" diff --git a/ts/packages/dispatcher/package.json b/ts/packages/dispatcher/package.json index fd2c088b8..00c6c0aa7 100644 --- a/ts/packages/dispatcher/package.json +++ b/ts/packages/dispatcher/package.json @@ -27,7 +27,7 @@ "clean": "rimraf --glob dist *.tsbuildinfo *.done.build.log", "prettier": "prettier --check . --ignore-path ../../.prettierignore", "prettier:fix": "prettier --write . --ignore-path ../../.prettierignore", - "test": "npm run test", + "test": "npm run test:local", "test:local": "node --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=\".*\\.spec\\.js\"", "test:local:debug": "node --inspect-brk --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=\".*\\.spec\\.js\"", "tsc": "tsc -b" diff --git a/ts/packages/dispatcher/src/context/system/systemAgent.ts b/ts/packages/dispatcher/src/context/system/systemAgent.ts index 9bacc615c..65d171c2e 100644 --- a/ts/packages/dispatcher/src/context/system/systemAgent.ts +++ b/ts/packages/dispatcher/src/context/system/systemAgent.ts @@ -226,9 +226,12 @@ class ActionCommandHandler implements CommandHandler { const action: AppAction = { translatorName, actionName, - parameters: params.flags.parameters, }; + if (params.flags.parameters !== undefined) { + action.parameters = params.flags.parameters; + } + validateAction(actionSchema, action, true); return executeActions( diff --git a/ts/packages/dispatcher/test/provider.spec.ts b/ts/packages/dispatcher/test/provider.spec.ts index d57880581..13aeb8c5e 100644 --- a/ts/packages/dispatcher/test/provider.spec.ts +++ b/ts/packages/dispatcher/test/provider.spec.ts @@ -60,6 +60,12 @@ describe("dispatcher", () => { expect(output[1].message).toBe("The sum of 1 and 2 is 3"); }); + it("action command no parameters", async () => { + await dispatcher.processCommand("@action test random"); + + expect(output).toHaveLength(2); + expect(output[1].message).toMatch(/Random number: [0-9.]+/); + }); const errorCommands = [ { name: "Empty Command", diff --git a/ts/packages/knowledgeProcessor/package.json b/ts/packages/knowledgeProcessor/package.json index e4052e50c..9e5bc25b4 100644 --- a/ts/packages/knowledgeProcessor/package.json +++ b/ts/packages/knowledgeProcessor/package.json @@ -21,7 +21,7 @@ "clean": "rimraf --glob dist *.tsbuildinfo *.done.build.log", "prettier": "prettier --check . --ignore-path ../../.prettierignore", "prettier:fix": "prettier --write . --ignore-path ../../.prettierignore", - "test": "npm run test", + "test": "npm run test:local", "test:local": "node --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=\".*\\.spec\\.js\"", "test:local:debug": "node --inspect-brk --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=\".*\\.spec\\.js\"", "tsc": "tsc -b" diff --git a/ts/packages/telemetry/package.json b/ts/packages/telemetry/package.json index 7a13dd891..3e3abdd9c 100644 --- a/ts/packages/telemetry/package.json +++ b/ts/packages/telemetry/package.json @@ -20,7 +20,7 @@ "clean": "rimraf --glob dist *.tsbuildinfo *.done.build.log", "prettier": "prettier --check . --ignore-path ../../.prettierignore", "prettier:fix": "prettier --write . --ignore-path ../../.prettierignore", - "test": "npm run test", + "test": "npm run test:local", "test:local": "node --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=\".*\\.spec\\.js\"", "test:local:debug": "node --inspect-brk --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=\".*\\.spec\\.js\"", "tsc": "tsc -b" diff --git a/ts/packages/typeagent/package.json b/ts/packages/typeagent/package.json index 0ce0f1653..7c9f06c54 100644 --- a/ts/packages/typeagent/package.json +++ b/ts/packages/typeagent/package.json @@ -22,7 +22,7 @@ "clean": "rimraf --glob dist *.tsbuildinfo *.done.build.log", "prettier": "prettier --check . --ignore-path ../../.prettierignore", "prettier:fix": "prettier --write . --ignore-path ../../prettierignore", - "test": "npm run test", + "test": "npm run test:local", "test:local": "node --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=\".*\\.spec\\.js\"", "test:local:debug": "node --inspect-brk --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=\".*\\.spec\\.js\"", "tsc": "tsc -b"