@aiscene/shared 8.0.3 → 8.0.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.
- package/dist/es/agent-tools/agent-behavior-init-args.mjs +44 -0
- package/dist/es/agent-tools/base-tools.mjs +163 -0
- package/dist/es/agent-tools/chrome-path.mjs +50 -0
- package/dist/es/agent-tools/cli-report-session.mjs +78 -0
- package/dist/es/agent-tools/error-formatter.mjs +106 -0
- package/dist/es/agent-tools/index.mjs +9 -0
- package/dist/es/agent-tools/init-arg-utils.mjs +38 -0
- package/dist/es/agent-tools/observation-artifact.mjs +5 -0
- package/dist/es/agent-tools/observation-record.mjs +248 -0
- package/dist/es/agent-tools/tool-defaults.mjs +54 -0
- package/dist/es/agent-tools/tool-generator.mjs +529 -0
- package/dist/es/agent-tools/types.mjs +3 -0
- package/dist/es/agent-tools/user-prompt.mjs +66 -0
- package/dist/es/cli/interrupt.mjs +116 -0
- package/dist/es/cli/record-command.mjs +130 -0
- package/dist/es/cli/screenshot-file.mjs +24 -0
- package/dist/es/cli/verbose-ai-act.mjs +230 -0
- package/dist/es/cli/verbose-screenshot.mjs +134 -0
- package/dist/es/cli/verbose.mjs +404 -0
- package/dist/es/env/parse-model-config.mjs +1 -1
- package/dist/es/env/types.mjs +18 -3
- package/dist/es/img/index.mjs +3 -3
- package/dist/es/img/info.mjs +45 -1
- package/dist/es/img/photon-loader.mjs +4 -0
- package/dist/es/img/transform.mjs +113 -3
- package/dist/es/recorder.mjs +249 -0
- package/dist/lib/agent-tools/agent-behavior-init-args.js +87 -0
- package/dist/lib/agent-tools/base-tools.js +197 -0
- package/dist/lib/agent-tools/chrome-path.js +87 -0
- package/dist/lib/agent-tools/cli-report-session.js +121 -0
- package/dist/lib/agent-tools/error-formatter.js +149 -0
- package/dist/lib/agent-tools/index.js +114 -0
- package/dist/lib/agent-tools/init-arg-utils.js +78 -0
- package/dist/lib/agent-tools/observation-artifact.js +42 -0
- package/dist/lib/agent-tools/observation-record.js +297 -0
- package/dist/lib/agent-tools/tool-defaults.js +97 -0
- package/dist/lib/agent-tools/tool-generator.js +569 -0
- package/dist/lib/agent-tools/types.js +40 -0
- package/dist/lib/agent-tools/user-prompt.js +103 -0
- package/dist/lib/cli/interrupt.js +156 -0
- package/dist/lib/cli/record-command.js +164 -0
- package/dist/lib/cli/screenshot-file.js +58 -0
- package/dist/lib/cli/verbose-ai-act.js +273 -0
- package/dist/lib/cli/verbose-screenshot.js +177 -0
- package/dist/lib/cli/verbose.js +465 -0
- package/dist/lib/env/parse-model-config.js +1 -1
- package/dist/lib/env/types.js +32 -2
- package/dist/lib/img/index.js +29 -5
- package/dist/lib/img/info.js +48 -1
- package/dist/lib/img/photon-loader.js +38 -0
- package/dist/lib/img/transform.js +135 -4
- package/dist/lib/recorder.js +307 -0
- package/dist/types/agent-tools/agent-behavior-init-args.d.ts +17 -0
- package/dist/types/agent-tools/base-tools.d.ts +158 -0
- package/dist/types/agent-tools/chrome-path.d.ts +2 -0
- package/dist/types/agent-tools/cli-report-session.d.ts +12 -0
- package/dist/types/agent-tools/error-formatter.d.ts +30 -0
- package/dist/types/agent-tools/index.d.ts +9 -0
- package/dist/types/agent-tools/init-arg-utils.d.ts +13 -0
- package/dist/types/agent-tools/observation-artifact.d.ts +10 -0
- package/dist/types/agent-tools/observation-record.d.ts +38 -0
- package/dist/types/agent-tools/tool-defaults.d.ts +63 -0
- package/dist/types/agent-tools/tool-generator.d.ts +13 -0
- package/dist/types/agent-tools/types.d.ts +213 -0
- package/dist/types/agent-tools/user-prompt.d.ts +13 -0
- package/dist/types/cli/interrupt.d.ts +49 -0
- package/dist/types/cli/record-command.d.ts +3 -0
- package/dist/types/cli/screenshot-file.d.ts +10 -0
- package/dist/types/cli/verbose-ai-act.d.ts +44 -0
- package/dist/types/cli/verbose-screenshot.d.ts +10 -0
- package/dist/types/cli/verbose.d.ts +40 -0
- package/dist/types/env/types.d.ts +16 -7
- package/dist/types/img/index.d.ts +2 -2
- package/dist/types/img/info.d.ts +2 -0
- package/dist/types/img/photon-loader.d.ts +2 -0
- package/dist/types/img/transform.d.ts +22 -2
- package/dist/types/mcp/types.d.ts +1 -0
- package/dist/types/recorder.d.ts +113 -0
- package/package.json +1 -1
- package/src/agent-tools/agent-behavior-init-args.ts +109 -0
- package/src/agent-tools/base-tools.ts +399 -0
- package/src/agent-tools/chrome-path.ts +74 -0
- package/src/agent-tools/cli-report-session.ts +130 -0
- package/src/agent-tools/error-formatter.ts +177 -0
- package/src/agent-tools/index.ts +9 -0
- package/src/agent-tools/init-arg-utils.ts +105 -0
- package/src/agent-tools/observation-artifact.ts +29 -0
- package/src/agent-tools/observation-record.ts +331 -0
- package/src/agent-tools/tool-defaults.ts +119 -0
- package/src/agent-tools/tool-generator.ts +866 -0
- package/src/agent-tools/types.ts +250 -0
- package/src/agent-tools/user-prompt.ts +102 -0
- package/src/cli/interrupt.ts +207 -0
- package/src/cli/record-command.ts +177 -0
- package/src/cli/screenshot-file.ts +61 -0
- package/src/cli/verbose-ai-act.ts +387 -0
- package/src/cli/verbose-screenshot.ts +269 -0
- package/src/cli/verbose.ts +753 -0
- package/src/env/types.ts +30 -2
- package/src/img/index.ts +12 -0
- package/src/img/info.ts +61 -0
- package/src/img/photon-loader.ts +5 -0
- package/src/img/transform.ts +262 -3
- package/src/mcp/types.ts +2 -0
- package/src/recorder.ts +625 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
promptInputExtraSchema: ()=>promptInputExtraSchema,
|
|
28
|
+
composeUserPrompt: ()=>composeUserPrompt
|
|
29
|
+
});
|
|
30
|
+
const external_zod_namespaceObject = require("zod");
|
|
31
|
+
function normalizeStringList(raw, fieldName) {
|
|
32
|
+
if (null == raw) return [];
|
|
33
|
+
if ('string' == typeof raw) {
|
|
34
|
+
const trimmed = raw.trim();
|
|
35
|
+
return trimmed ? [
|
|
36
|
+
trimmed
|
|
37
|
+
] : [];
|
|
38
|
+
}
|
|
39
|
+
if (Array.isArray(raw)) return raw.map((item, index)=>{
|
|
40
|
+
if ('string' != typeof item) throw new Error(`${fieldName}[${index}]: expected a string.`);
|
|
41
|
+
return item.trim();
|
|
42
|
+
});
|
|
43
|
+
throw new Error(`${fieldName}: expected a string or string array, got ${typeof raw}.`);
|
|
44
|
+
}
|
|
45
|
+
function composeImages(input) {
|
|
46
|
+
const urls = normalizeStringList(input.image, 'image');
|
|
47
|
+
const names = normalizeStringList(input.imageName, 'imageName');
|
|
48
|
+
if (urls.length !== names.length) throw new Error(`image/imageName: expected the same number of --image and --image-name values, got ${urls.length} image(s) and ${names.length} image name(s).`);
|
|
49
|
+
return urls.map((url, index)=>({
|
|
50
|
+
name: names[index],
|
|
51
|
+
url
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
function coerceBoolean(value) {
|
|
55
|
+
if (null == value) return;
|
|
56
|
+
if ('boolean' == typeof value) return value;
|
|
57
|
+
if ('string' == typeof value) {
|
|
58
|
+
const trimmed = value.trim();
|
|
59
|
+
if (!trimmed) return;
|
|
60
|
+
const v = trimmed.toLowerCase();
|
|
61
|
+
if ('true' === v || '1' === v) return true;
|
|
62
|
+
if ('false' === v || '0' === v) return false;
|
|
63
|
+
throw new Error(`convertHttpImage2Base64: expected "true", "false", "1", or "0"; got ${JSON.stringify(value)}.`);
|
|
64
|
+
}
|
|
65
|
+
throw new Error(`convertHttpImage2Base64: expected a boolean, got ${typeof value}.`);
|
|
66
|
+
}
|
|
67
|
+
function composeUserPrompt(input) {
|
|
68
|
+
const images = composeImages({
|
|
69
|
+
image: input.image,
|
|
70
|
+
imageName: input.imageName
|
|
71
|
+
});
|
|
72
|
+
const convertFlag = coerceBoolean(input.convertHttpImage2Base64);
|
|
73
|
+
if (0 === images.length && void 0 === convertFlag) return input.prompt;
|
|
74
|
+
const payload = {
|
|
75
|
+
prompt: input.prompt
|
|
76
|
+
};
|
|
77
|
+
if (images.length > 0) payload.images = images;
|
|
78
|
+
if (void 0 !== convertFlag) payload.convertHttpImage2Base64 = convertFlag;
|
|
79
|
+
return payload;
|
|
80
|
+
}
|
|
81
|
+
const promptInputExtraSchema = {
|
|
82
|
+
image: external_zod_namespaceObject.z.union([
|
|
83
|
+
external_zod_namespaceObject.z.string(),
|
|
84
|
+
external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string())
|
|
85
|
+
]).optional().describe('Reference image URL/path. Repeat --image for multiple images.'),
|
|
86
|
+
imageName: external_zod_namespaceObject.z.union([
|
|
87
|
+
external_zod_namespaceObject.z.string(),
|
|
88
|
+
external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string())
|
|
89
|
+
]).optional().describe('Reference image name. Repeat --image-name; must align with --image order.'),
|
|
90
|
+
convertHttpImage2Base64: external_zod_namespaceObject.z.union([
|
|
91
|
+
external_zod_namespaceObject.z.boolean(),
|
|
92
|
+
external_zod_namespaceObject.z.string()
|
|
93
|
+
]).optional().describe('If true, convert http(s) image URLs to base64 before sending to the model.')
|
|
94
|
+
};
|
|
95
|
+
exports.composeUserPrompt = __webpack_exports__.composeUserPrompt;
|
|
96
|
+
exports.promptInputExtraSchema = __webpack_exports__.promptInputExtraSchema;
|
|
97
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
98
|
+
"composeUserPrompt",
|
|
99
|
+
"promptInputExtraSchema"
|
|
100
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
101
|
+
Object.defineProperty(exports, '__esModule', {
|
|
102
|
+
value: true
|
|
103
|
+
});
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
createCliInterruptWaiter: ()=>createCliInterruptWaiter,
|
|
28
|
+
hasActiveCliInterruptWaiter: ()=>hasActiveCliInterruptWaiter,
|
|
29
|
+
waitForCliInterrupt: ()=>waitForCliInterrupt
|
|
30
|
+
});
|
|
31
|
+
const activeInterruptWaiters = new WeakMap();
|
|
32
|
+
const noop = ()=>{};
|
|
33
|
+
const sigintExitCode = 130;
|
|
34
|
+
function guardTerminalCtrlC(input, onInterrupt) {
|
|
35
|
+
if (!input?.isTTY || !input.setRawMode) return noop;
|
|
36
|
+
const wasRaw = true === input.isRaw;
|
|
37
|
+
const wasFlowing = true === input.readableFlowing;
|
|
38
|
+
const onData = (chunk)=>{
|
|
39
|
+
const includesCtrlC = 'string' == typeof chunk && chunk.includes('\u0003') || chunk instanceof Uint8Array && chunk.includes(3);
|
|
40
|
+
if (includesCtrlC) onInterrupt();
|
|
41
|
+
};
|
|
42
|
+
const dispose = ()=>{
|
|
43
|
+
input.removeListener('data', onData);
|
|
44
|
+
try {
|
|
45
|
+
if (!wasFlowing) input.pause?.();
|
|
46
|
+
} finally{
|
|
47
|
+
if (!wasRaw) input.setRawMode?.(false);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
input.setRawMode(true);
|
|
51
|
+
try {
|
|
52
|
+
input.on('data', onData);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
dispose();
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
return dispose;
|
|
58
|
+
}
|
|
59
|
+
function registerCliInterruptWaiter(source) {
|
|
60
|
+
const key = source;
|
|
61
|
+
activeInterruptWaiters.set(key, (activeInterruptWaiters.get(key) ?? 0) + 1);
|
|
62
|
+
let active = true;
|
|
63
|
+
return ()=>{
|
|
64
|
+
if (!active) return;
|
|
65
|
+
active = false;
|
|
66
|
+
const remaining = (activeInterruptWaiters.get(key) ?? 1) - 1;
|
|
67
|
+
if (remaining > 0) activeInterruptWaiters.set(key, remaining);
|
|
68
|
+
else activeInterruptWaiters.delete(key);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function hasActiveCliInterruptWaiter(source = process) {
|
|
72
|
+
return (activeInterruptWaiters.get(source) ?? 0) > 0;
|
|
73
|
+
}
|
|
74
|
+
function createCliInterruptWaiter(watchdogMs, options = {}) {
|
|
75
|
+
const source = options.source ?? process;
|
|
76
|
+
const input = options.input ?? (source === process ? process.stdin : void 0);
|
|
77
|
+
const forceExit = options.forceExit ?? (source === process ? (exitCode)=>{
|
|
78
|
+
process.exit(exitCode);
|
|
79
|
+
} : void 0);
|
|
80
|
+
const unregisterWaiter = registerCliInterruptWaiter(source);
|
|
81
|
+
let timer;
|
|
82
|
+
let finished = false;
|
|
83
|
+
let disposed = false;
|
|
84
|
+
let disposeInput = noop;
|
|
85
|
+
let resolveResult;
|
|
86
|
+
let rejectResult;
|
|
87
|
+
const result = new Promise((resolve, reject)=>{
|
|
88
|
+
resolveResult = resolve;
|
|
89
|
+
rejectResult = reject;
|
|
90
|
+
});
|
|
91
|
+
const finish = (reason)=>{
|
|
92
|
+
if (finished) return;
|
|
93
|
+
finished = true;
|
|
94
|
+
if (timer) {
|
|
95
|
+
clearTimeout(timer);
|
|
96
|
+
timer = void 0;
|
|
97
|
+
}
|
|
98
|
+
resolveResult(reason);
|
|
99
|
+
};
|
|
100
|
+
const onSigint = ()=>finish('sigint');
|
|
101
|
+
const onSigterm = ()=>finish('sigterm');
|
|
102
|
+
const onSighup = ()=>finish('sighup');
|
|
103
|
+
function dispose() {
|
|
104
|
+
if (disposed) return;
|
|
105
|
+
disposed = true;
|
|
106
|
+
source.removeListener('SIGINT', onSigint);
|
|
107
|
+
source.removeListener('SIGTERM', onSigterm);
|
|
108
|
+
source.removeListener('SIGHUP', onSighup);
|
|
109
|
+
try {
|
|
110
|
+
disposeInput();
|
|
111
|
+
} finally{
|
|
112
|
+
if (timer) {
|
|
113
|
+
clearTimeout(timer);
|
|
114
|
+
timer = void 0;
|
|
115
|
+
}
|
|
116
|
+
unregisterWaiter();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const onTerminalCtrlC = ()=>{
|
|
120
|
+
if (!finished) return void finish('sigint');
|
|
121
|
+
dispose();
|
|
122
|
+
forceExit?.(sigintExitCode);
|
|
123
|
+
};
|
|
124
|
+
try {
|
|
125
|
+
source.on('SIGINT', onSigint);
|
|
126
|
+
source.on('SIGTERM', onSigterm);
|
|
127
|
+
source.on('SIGHUP', onSighup);
|
|
128
|
+
disposeInput = guardTerminalCtrlC(input, onTerminalCtrlC);
|
|
129
|
+
if (watchdogMs > 0) timer = setTimeout(()=>finish('watchdog'), watchdogMs);
|
|
130
|
+
} catch (error) {
|
|
131
|
+
dispose();
|
|
132
|
+
rejectResult(error);
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
result,
|
|
136
|
+
dispose
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function waitForCliInterrupt(watchdogMs, source = process, input = source === process ? process.stdin : void 0) {
|
|
140
|
+
const waiter = createCliInterruptWaiter(watchdogMs, {
|
|
141
|
+
source,
|
|
142
|
+
input
|
|
143
|
+
});
|
|
144
|
+
return waiter.result.finally(waiter.dispose);
|
|
145
|
+
}
|
|
146
|
+
exports.createCliInterruptWaiter = __webpack_exports__.createCliInterruptWaiter;
|
|
147
|
+
exports.hasActiveCliInterruptWaiter = __webpack_exports__.hasActiveCliInterruptWaiter;
|
|
148
|
+
exports.waitForCliInterrupt = __webpack_exports__.waitForCliInterrupt;
|
|
149
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
150
|
+
"createCliInterruptWaiter",
|
|
151
|
+
"hasActiveCliInterruptWaiter",
|
|
152
|
+
"waitForCliInterrupt"
|
|
153
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
154
|
+
Object.defineProperty(exports, '__esModule', {
|
|
155
|
+
value: true
|
|
156
|
+
});
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
createRecordCliCommand: ()=>createRecordCliCommand
|
|
28
|
+
});
|
|
29
|
+
const external_zod_namespaceObject = require("zod");
|
|
30
|
+
const error_formatter_js_namespaceObject = require("../agent-tools/error-formatter.js");
|
|
31
|
+
const observation_artifact_js_namespaceObject = require("../agent-tools/observation-artifact.js");
|
|
32
|
+
const observation_record_js_namespaceObject = require("../agent-tools/observation-record.js");
|
|
33
|
+
const external_interrupt_js_namespaceObject = require("./interrupt.js");
|
|
34
|
+
const external_verbose_js_namespaceObject = require("./verbose.js");
|
|
35
|
+
const recordCliMetadata = {
|
|
36
|
+
positionals: [
|
|
37
|
+
'action'
|
|
38
|
+
],
|
|
39
|
+
options: {
|
|
40
|
+
intervalMs: {
|
|
41
|
+
preferredName: 'interval-ms',
|
|
42
|
+
aliases: [
|
|
43
|
+
'intervalMs'
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
maxFrames: {
|
|
47
|
+
preferredName: 'max-frames',
|
|
48
|
+
aliases: [
|
|
49
|
+
'maxFrames'
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
watchdogMs: {
|
|
53
|
+
preferredName: 'watchdog-ms',
|
|
54
|
+
aliases: [
|
|
55
|
+
'watchdogMs'
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
action: {
|
|
59
|
+
hidden: true
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
function mergeCliMetadata(base, extra) {
|
|
64
|
+
return {
|
|
65
|
+
positionals: base.positionals,
|
|
66
|
+
options: {
|
|
67
|
+
...base.options ?? {},
|
|
68
|
+
...extra?.options ?? {}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function createErrorResult(message) {
|
|
73
|
+
return {
|
|
74
|
+
content: [
|
|
75
|
+
{
|
|
76
|
+
type: 'text',
|
|
77
|
+
text: message
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
isError: true
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function createRecordCliCommand(getAgent, initArgSchema = {}, initArgCliMetadata) {
|
|
84
|
+
return {
|
|
85
|
+
name: 'record',
|
|
86
|
+
description: 'Record the page/screen in the foreground until Ctrl+C or a termination signal, then save the ordered frame window for a later assert command.',
|
|
87
|
+
schema: {
|
|
88
|
+
action: external_zod_namespaceObject.z.literal('start').describe('Start a foreground recording. Press Ctrl+C to finish.'),
|
|
89
|
+
output: external_zod_namespaceObject.z.string().optional().describe('Path for the JSON observation manifest. Frames are stored in an adjacent <name>.frames directory. Defaults to a generated path under midscene_run/output.'),
|
|
90
|
+
intervalMs: external_zod_namespaceObject.z.number().min(200).optional().describe('Sampling interval in milliseconds. Defaults to 1000; minimum 200 (5fps).'),
|
|
91
|
+
maxFrames: external_zod_namespaceObject.z.number().int().min(2).optional().describe('Maximum buffered frames. Defaults to 30; minimum 2.'),
|
|
92
|
+
watchdogMs: external_zod_namespaceObject.z.number().min(0).optional().describe('Safety timeout in milliseconds. Defaults to 300000 (5 minutes); 0 disables it.'),
|
|
93
|
+
...initArgSchema
|
|
94
|
+
},
|
|
95
|
+
cli: mergeCliMetadata(recordCliMetadata, initArgCliMetadata),
|
|
96
|
+
handler: async (args = {})=>{
|
|
97
|
+
if ('start' !== args.action) return createErrorResult('record requires the start operation (for example: record start --output ./observation.json)');
|
|
98
|
+
try {
|
|
99
|
+
const agent = await getAgent(args);
|
|
100
|
+
(0, external_verbose_js_namespaceObject.emitCliVerboseEvent)({
|
|
101
|
+
event: 'agent_ready',
|
|
102
|
+
tool: 'record'
|
|
103
|
+
});
|
|
104
|
+
if (!agent.startObserving) throw new Error('record is not supported because this agent does not provide startObserving');
|
|
105
|
+
const observationArtifacts = (0, observation_artifact_js_namespaceObject.resolveObservationArtifactAdapter)(agent);
|
|
106
|
+
if (!observationArtifacts) throw new Error('record is not supported because this agent does not provide observation artifact persistence');
|
|
107
|
+
const unsubscribeVerbose = (0, external_verbose_js_namespaceObject.attachCliVerboseDumpListener)(agent, {
|
|
108
|
+
toolName: 'record'
|
|
109
|
+
});
|
|
110
|
+
let observer;
|
|
111
|
+
let interruptWaiter;
|
|
112
|
+
try {
|
|
113
|
+
const watchdogMs = args.watchdogMs ?? 300000;
|
|
114
|
+
observer = await agent.startObserving({
|
|
115
|
+
intervalMs: args.intervalMs,
|
|
116
|
+
maxFrames: args.maxFrames,
|
|
117
|
+
watchdogMs
|
|
118
|
+
});
|
|
119
|
+
interruptWaiter = (0, external_interrupt_js_namespaceObject.createCliInterruptWaiter)(watchdogMs);
|
|
120
|
+
(0, external_verbose_js_namespaceObject.emitCliVerboseEvent)({
|
|
121
|
+
event: 'recording_ready',
|
|
122
|
+
tool: 'record',
|
|
123
|
+
watchdogMs
|
|
124
|
+
});
|
|
125
|
+
const stopReason = await interruptWaiter.result;
|
|
126
|
+
(0, external_verbose_js_namespaceObject.emitCliVerboseEvent)({
|
|
127
|
+
event: 'recording_stopping',
|
|
128
|
+
tool: 'record',
|
|
129
|
+
reason: stopReason
|
|
130
|
+
});
|
|
131
|
+
const observation = await observer.stop();
|
|
132
|
+
const record = await observationArtifacts.exportRecord(observation);
|
|
133
|
+
const outputPath = (0, observation_record_js_namespaceObject.writeUIObservationRecord)(record, args.output);
|
|
134
|
+
return {
|
|
135
|
+
content: [
|
|
136
|
+
{
|
|
137
|
+
type: 'text',
|
|
138
|
+
text: `Observation record saved: ${outputPath}`
|
|
139
|
+
}
|
|
140
|
+
]
|
|
141
|
+
};
|
|
142
|
+
} finally{
|
|
143
|
+
try {
|
|
144
|
+
await observer?.dispose?.();
|
|
145
|
+
} finally{
|
|
146
|
+
interruptWaiter?.dispose();
|
|
147
|
+
unsubscribeVerbose();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
} catch (error) {
|
|
151
|
+
const errorMessage = (0, error_formatter_js_namespaceObject.getErrorMessage)(error);
|
|
152
|
+
console.error('Error executing record:', errorMessage);
|
|
153
|
+
return createErrorResult(`Failed to execute record: ${errorMessage}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
exports.createRecordCliCommand = __webpack_exports__.createRecordCliCommand;
|
|
159
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
160
|
+
"createRecordCliCommand"
|
|
161
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
162
|
+
Object.defineProperty(exports, '__esModule', {
|
|
163
|
+
value: true
|
|
164
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
writeCliScreenshotFile: ()=>writeCliScreenshotFile
|
|
28
|
+
});
|
|
29
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
30
|
+
const external_node_os_namespaceObject = require("node:os");
|
|
31
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
32
|
+
function safeScreenshotFilenamePart(value) {
|
|
33
|
+
const text = 'string' == typeof value && value.length > 0 ? value : 'shot';
|
|
34
|
+
return text.replace(/[^a-zA-Z0-9._-]/g, '_') || 'shot';
|
|
35
|
+
}
|
|
36
|
+
function extensionFromImageMetadata(mimeType, extension) {
|
|
37
|
+
if ('jpeg' === extension || 'jpg' === extension) return 'jpeg';
|
|
38
|
+
if ('png' === extension) return 'png';
|
|
39
|
+
return 'image/jpeg' === mimeType ? 'jpeg' : 'png';
|
|
40
|
+
}
|
|
41
|
+
function writeCliScreenshotFile(rawBase64, options = {}) {
|
|
42
|
+
const extension = extensionFromImageMetadata(options.mimeType, options.extension);
|
|
43
|
+
const directory = options.directoryPath ? options.directoryPath : options.directoryName ? (0, external_node_path_namespaceObject.join)((0, external_node_os_namespaceObject.tmpdir)(), options.directoryName) : (0, external_node_os_namespaceObject.tmpdir)();
|
|
44
|
+
if (!(0, external_node_fs_namespaceObject.existsSync)(directory)) (0, external_node_fs_namespaceObject.mkdirSync)(directory, {
|
|
45
|
+
recursive: true
|
|
46
|
+
});
|
|
47
|
+
const filename = void 0 !== options.id ? `${safeScreenshotFilenamePart(options.id)}.${extension}` : `${options.filenamePrefix ?? 'screenshot'}-${Date.now()}.${extension}`;
|
|
48
|
+
const filePath = (0, external_node_path_namespaceObject.join)(directory, filename);
|
|
49
|
+
if (false !== options.overwrite || !(0, external_node_fs_namespaceObject.existsSync)(filePath)) (0, external_node_fs_namespaceObject.writeFileSync)(filePath, Buffer.from(rawBase64, 'base64'));
|
|
50
|
+
return filePath;
|
|
51
|
+
}
|
|
52
|
+
exports.writeCliScreenshotFile = __webpack_exports__.writeCliScreenshotFile;
|
|
53
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
54
|
+
"writeCliScreenshotFile"
|
|
55
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
56
|
+
Object.defineProperty(exports, '__esModule', {
|
|
57
|
+
value: true
|
|
58
|
+
});
|