@midscene/shared 1.9.2-beta-20260608084200.0 → 1.9.2
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.
|
@@ -5,7 +5,7 @@ import { assert } from "../utils.mjs";
|
|
|
5
5
|
import { maskConfig, parseJson } from "./helper.mjs";
|
|
6
6
|
import { initDebugConfig } from "./init-debug.mjs";
|
|
7
7
|
const MODEL_CONFIG_DOC_URL = 'https://midscenejs.com/model-common-config.html';
|
|
8
|
-
const getCurrentVersion = ()=>"1.9.2
|
|
8
|
+
const getCurrentVersion = ()=>"1.9.2";
|
|
9
9
|
const getInvalidModelFamilyMessage = (modelFamily)=>`Invalid MIDSCENE_MODEL_FAMILY value: ${modelFamily}. Current version v${getCurrentVersion()} accepts the following model families: ${MODEL_FAMILY_VALUES.join(', ')}. You can also visit ${MODEL_CONFIG_DOC_URL} for the latest configuration information.`;
|
|
10
10
|
const KEYS_MAP = {
|
|
11
11
|
insight: INSIGHT_MODEL_CONFIG_KEYS,
|
|
@@ -421,12 +421,14 @@ function generateCommonTools(getAgent, initArgSchema = {}, initArgCliMetadata, t
|
|
|
421
421
|
description: 'Assert a natural language statement against the current page/screen.',
|
|
422
422
|
schema: {
|
|
423
423
|
prompt: z.string().describe('Natural language assertion to verify, e.g. "there is a login button visible"'),
|
|
424
|
+
message: z.string().optional().describe('Custom error message to throw when the assertion fails, e.g. "the login button should be visible".'),
|
|
424
425
|
...promptInputExtraSchema,
|
|
425
426
|
...initArgSchema
|
|
426
427
|
},
|
|
427
428
|
cli: mergeToolCliMetadata(void 0, initArgCliMetadata),
|
|
428
429
|
handler: async (args = {})=>{
|
|
429
430
|
const prompt = args.prompt;
|
|
431
|
+
const message = args.message;
|
|
430
432
|
try {
|
|
431
433
|
const agent = await getAgent(args);
|
|
432
434
|
if (!agent.aiAssert) return createErrorResult('assert is not supported by this agent');
|
|
@@ -436,7 +438,7 @@ function generateCommonTools(getAgent, initArgSchema = {}, initArgCliMetadata, t
|
|
|
436
438
|
imageName: args.imageName,
|
|
437
439
|
convertHttpImage2Base64: args.convertHttpImage2Base64
|
|
438
440
|
});
|
|
439
|
-
await agent.aiAssert(userPrompt);
|
|
441
|
+
await agent.aiAssert(userPrompt, message);
|
|
440
442
|
return {
|
|
441
443
|
content: [
|
|
442
444
|
{
|
|
@@ -37,7 +37,7 @@ const external_utils_js_namespaceObject = require("../utils.js");
|
|
|
37
37
|
const external_helper_js_namespaceObject = require("./helper.js");
|
|
38
38
|
const external_init_debug_js_namespaceObject = require("./init-debug.js");
|
|
39
39
|
const MODEL_CONFIG_DOC_URL = 'https://midscenejs.com/model-common-config.html';
|
|
40
|
-
const getCurrentVersion = ()=>"1.9.2
|
|
40
|
+
const getCurrentVersion = ()=>"1.9.2";
|
|
41
41
|
const getInvalidModelFamilyMessage = (modelFamily)=>`Invalid MIDSCENE_MODEL_FAMILY value: ${modelFamily}. Current version v${getCurrentVersion()} accepts the following model families: ${external_types_js_namespaceObject.MODEL_FAMILY_VALUES.join(', ')}. You can also visit ${MODEL_CONFIG_DOC_URL} for the latest configuration information.`;
|
|
42
42
|
const KEYS_MAP = {
|
|
43
43
|
insight: external_constants_js_namespaceObject.INSIGHT_MODEL_CONFIG_KEYS,
|
|
@@ -451,12 +451,14 @@ function generateCommonTools(getAgent, initArgSchema = {}, initArgCliMetadata, t
|
|
|
451
451
|
description: 'Assert a natural language statement against the current page/screen.',
|
|
452
452
|
schema: {
|
|
453
453
|
prompt: external_zod_namespaceObject.z.string().describe('Natural language assertion to verify, e.g. "there is a login button visible"'),
|
|
454
|
+
message: external_zod_namespaceObject.z.string().optional().describe('Custom error message to throw when the assertion fails, e.g. "the login button should be visible".'),
|
|
454
455
|
...external_user_prompt_js_namespaceObject.promptInputExtraSchema,
|
|
455
456
|
...initArgSchema
|
|
456
457
|
},
|
|
457
458
|
cli: mergeToolCliMetadata(void 0, initArgCliMetadata),
|
|
458
459
|
handler: async (args = {})=>{
|
|
459
460
|
const prompt = args.prompt;
|
|
461
|
+
const message = args.message;
|
|
460
462
|
try {
|
|
461
463
|
const agent = await getAgent(args);
|
|
462
464
|
if (!agent.aiAssert) return createErrorResult('assert is not supported by this agent');
|
|
@@ -466,7 +468,7 @@ function generateCommonTools(getAgent, initArgSchema = {}, initArgCliMetadata, t
|
|
|
466
468
|
imageName: args.imageName,
|
|
467
469
|
convertHttpImage2Base64: args.convertHttpImage2Base64
|
|
468
470
|
});
|
|
469
|
-
await agent.aiAssert(userPrompt);
|
|
471
|
+
await agent.aiAssert(userPrompt, message);
|
|
470
472
|
return {
|
|
471
473
|
content: [
|
|
472
474
|
{
|
package/package.json
CHANGED
|
@@ -718,6 +718,12 @@ export function generateCommonTools(
|
|
|
718
718
|
.describe(
|
|
719
719
|
'Natural language assertion to verify, e.g. "there is a login button visible"',
|
|
720
720
|
),
|
|
721
|
+
message: z
|
|
722
|
+
.string()
|
|
723
|
+
.optional()
|
|
724
|
+
.describe(
|
|
725
|
+
'Custom error message to throw when the assertion fails, e.g. "the login button should be visible".',
|
|
726
|
+
),
|
|
721
727
|
...promptInputExtraSchema,
|
|
722
728
|
...initArgSchema,
|
|
723
729
|
},
|
|
@@ -726,6 +732,7 @@ export function generateCommonTools(
|
|
|
726
732
|
args: Record<string, unknown> = {},
|
|
727
733
|
): Promise<ToolResult> => {
|
|
728
734
|
const prompt = args.prompt as string;
|
|
735
|
+
const message = args.message as string | undefined;
|
|
729
736
|
try {
|
|
730
737
|
const agent = await getAgent(args);
|
|
731
738
|
if (!agent.aiAssert) {
|
|
@@ -737,7 +744,7 @@ export function generateCommonTools(
|
|
|
737
744
|
imageName: args.imageName,
|
|
738
745
|
convertHttpImage2Base64: args.convertHttpImage2Base64,
|
|
739
746
|
});
|
|
740
|
-
await agent.aiAssert(userPrompt);
|
|
747
|
+
await agent.aiAssert(userPrompt, message);
|
|
741
748
|
return {
|
|
742
749
|
content: [{ type: 'text', text: 'Assertion passed.' }],
|
|
743
750
|
};
|