@midscene/core 1.15.5 → 1.16.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/dist/es/agent/agent.mjs +13 -12
- package/dist/es/agent/agent.mjs.map +1 -1
- package/dist/es/agent/insight.mjs +3 -3
- package/dist/es/agent/insight.mjs.map +1 -1
- package/dist/es/agent/task-builder.mjs +14 -8
- package/dist/es/agent/task-builder.mjs.map +1 -1
- package/dist/es/agent/tasks.mjs +18 -13
- package/dist/es/agent/tasks.mjs.map +1 -1
- package/dist/es/agent/utils.mjs +1 -1
- package/dist/es/ai-model/connectivity/run-connectivity-test.mjs +25 -4
- package/dist/es/ai-model/connectivity/run-connectivity-test.mjs.map +1 -1
- package/dist/es/ai-model/model-adapter/insight.mjs +1 -0
- package/dist/es/ai-model/model-adapter/insight.mjs.map +1 -1
- package/dist/es/ai-model/model-adapter/resolve.mjs +2 -0
- package/dist/es/ai-model/model-adapter/resolve.mjs.map +1 -1
- package/dist/es/ai-model/models/gpt.mjs +3 -3
- package/dist/es/ai-model/models/gpt.mjs.map +1 -1
- package/dist/es/ai-model/models/jev/adapter.mjs +135 -0
- package/dist/es/ai-model/models/jev/adapter.mjs.map +1 -0
- package/dist/es/ai-model/models/jev/image.mjs +48 -0
- package/dist/es/ai-model/models/jev/image.mjs.map +1 -0
- package/dist/es/ai-model/models/jev/planning.mjs +168 -0
- package/dist/es/ai-model/models/jev/planning.mjs.map +1 -0
- package/dist/es/ai-model/models/registry.mjs +2 -0
- package/dist/es/ai-model/models/registry.mjs.map +1 -1
- package/dist/es/ai-model/models/task-routing.mjs +28 -0
- package/dist/es/ai-model/models/task-routing.mjs.map +1 -0
- package/dist/es/ai-model/models/utils/intent.mjs +1 -1
- package/dist/es/ai-model/models/utils/intent.mjs.map +1 -1
- package/dist/es/ai-model/service-caller/call-ai.mjs +15 -2
- package/dist/es/ai-model/service-caller/call-ai.mjs.map +1 -1
- package/dist/es/ai-model/service-caller/openai/call-openai.mjs +1 -2
- package/dist/es/ai-model/service-caller/openai/call-openai.mjs.map +1 -1
- package/dist/es/ai-model/service-caller/system-one.mjs +163 -0
- package/dist/es/ai-model/service-caller/system-one.mjs.map +1 -0
- package/dist/es/ai-model/shared/model-locate-result/errors.mjs +6 -2
- package/dist/es/ai-model/shared/model-locate-result/errors.mjs.map +1 -1
- package/dist/es/ai-model/workflows/insight/boolean.mjs +20 -0
- package/dist/es/ai-model/workflows/insight/boolean.mjs.map +1 -0
- package/dist/es/ai-model/workflows/insight/extraction.mjs +2 -0
- package/dist/es/ai-model/workflows/insight/extraction.mjs.map +1 -1
- package/dist/es/report-html-template.mjs +1 -1
- package/dist/es/service/index.mjs +2 -2
- package/dist/es/service/index.mjs.map +1 -1
- package/dist/es/types.mjs.map +1 -1
- package/dist/es/utils.mjs +1 -1
- package/dist/lib/agent/agent.js +15 -14
- package/dist/lib/agent/agent.js.map +1 -1
- package/dist/lib/agent/insight.js +3 -3
- package/dist/lib/agent/insight.js.map +1 -1
- package/dist/lib/agent/task-builder.js +14 -8
- package/dist/lib/agent/task-builder.js.map +1 -1
- package/dist/lib/agent/tasks.js +18 -13
- package/dist/lib/agent/tasks.js.map +1 -1
- package/dist/lib/agent/utils.js +1 -1
- package/dist/lib/ai-model/connectivity/run-connectivity-test.js +25 -4
- package/dist/lib/ai-model/connectivity/run-connectivity-test.js.map +1 -1
- package/dist/lib/ai-model/model-adapter/insight.js +1 -0
- package/dist/lib/ai-model/model-adapter/insight.js.map +1 -1
- package/dist/lib/ai-model/model-adapter/resolve.js +2 -0
- package/dist/lib/ai-model/model-adapter/resolve.js.map +1 -1
- package/dist/lib/ai-model/models/gpt.js +3 -3
- package/dist/lib/ai-model/models/gpt.js.map +1 -1
- package/dist/lib/ai-model/models/jev/adapter.js +169 -0
- package/dist/lib/ai-model/models/jev/adapter.js.map +1 -0
- package/dist/lib/ai-model/models/jev/image.js +85 -0
- package/dist/lib/ai-model/models/jev/image.js.map +1 -0
- package/dist/lib/ai-model/models/jev/planning.js +202 -0
- package/dist/lib/ai-model/models/jev/planning.js.map +1 -0
- package/dist/lib/ai-model/models/registry.js +2 -0
- package/dist/lib/ai-model/models/registry.js.map +1 -1
- package/dist/lib/ai-model/models/task-routing.js +62 -0
- package/dist/lib/ai-model/models/task-routing.js.map +1 -0
- package/dist/lib/ai-model/models/utils/intent.js +1 -1
- package/dist/lib/ai-model/models/utils/intent.js.map +1 -1
- package/dist/lib/ai-model/service-caller/call-ai.js +15 -2
- package/dist/lib/ai-model/service-caller/call-ai.js.map +1 -1
- package/dist/lib/ai-model/service-caller/openai/call-openai.js +1 -2
- package/dist/lib/ai-model/service-caller/openai/call-openai.js.map +1 -1
- package/dist/lib/ai-model/service-caller/system-one.js +206 -0
- package/dist/lib/ai-model/service-caller/system-one.js.map +1 -0
- package/dist/lib/ai-model/shared/model-locate-result/errors.js +8 -4
- package/dist/lib/ai-model/shared/model-locate-result/errors.js.map +1 -1
- package/dist/lib/ai-model/workflows/insight/boolean.js +54 -0
- package/dist/lib/ai-model/workflows/insight/boolean.js.map +1 -0
- package/dist/lib/ai-model/workflows/insight/extraction.js +2 -0
- package/dist/lib/ai-model/workflows/insight/extraction.js.map +1 -1
- package/dist/lib/report-html-template.js +1 -1
- package/dist/lib/service/index.js +1 -1
- package/dist/lib/service/index.js.map +1 -1
- package/dist/lib/types.js.map +1 -1
- package/dist/lib/utils.js +1 -1
- package/dist/types/agent/agent.d.ts.map +1 -1
- package/dist/types/agent/insight.d.ts +2 -1
- package/dist/types/agent/insight.d.ts.map +1 -1
- package/dist/types/agent/task-builder.d.ts +4 -2
- package/dist/types/agent/task-builder.d.ts.map +1 -1
- package/dist/types/agent/tasks.d.ts +5 -3
- package/dist/types/agent/tasks.d.ts.map +1 -1
- package/dist/types/agent/test-runner-nodes.d.ts +1 -1
- package/dist/types/ai-model/connectivity/run-connectivity-test.d.ts +1 -0
- package/dist/types/ai-model/connectivity/run-connectivity-test.d.ts.map +1 -1
- package/dist/types/ai-model/model-adapter/insight-protocol.d.ts +3 -0
- package/dist/types/ai-model/model-adapter/insight-protocol.d.ts.map +1 -1
- package/dist/types/ai-model/model-adapter/insight.d.ts.map +1 -1
- package/dist/types/ai-model/model-adapter/resolve.d.ts +1 -0
- package/dist/types/ai-model/model-adapter/resolve.d.ts.map +1 -1
- package/dist/types/ai-model/model-adapter/types.d.ts +9 -0
- package/dist/types/ai-model/model-adapter/types.d.ts.map +1 -1
- package/dist/types/ai-model/models/jev/adapter.d.ts +23 -0
- package/dist/types/ai-model/models/jev/adapter.d.ts.map +1 -0
- package/dist/types/ai-model/models/jev/image.d.ts +24 -0
- package/dist/types/ai-model/models/jev/image.d.ts.map +1 -0
- package/dist/types/ai-model/models/jev/planning.d.ts +3 -0
- package/dist/types/ai-model/models/jev/planning.d.ts.map +1 -0
- package/dist/types/ai-model/models/registry.d.ts +18 -0
- package/dist/types/ai-model/models/registry.d.ts.map +1 -1
- package/dist/types/ai-model/models/task-routing.d.ts +6 -0
- package/dist/types/ai-model/models/task-routing.d.ts.map +1 -0
- package/dist/types/ai-model/service-caller/call-ai.d.ts.map +1 -1
- package/dist/types/ai-model/service-caller/openai/call-openai.d.ts.map +1 -1
- package/dist/types/ai-model/service-caller/system-one.d.ts +216 -0
- package/dist/types/ai-model/service-caller/system-one.d.ts.map +1 -0
- package/dist/types/ai-model/service-caller/types.d.ts +2 -0
- package/dist/types/ai-model/service-caller/types.d.ts.map +1 -1
- package/dist/types/ai-model/shared/model-locate-result/errors.d.ts +1 -1
- package/dist/types/ai-model/shared/model-locate-result/errors.d.ts.map +1 -1
- package/dist/types/ai-model/workflows/insight/boolean.d.ts +15 -0
- package/dist/types/ai-model/workflows/insight/boolean.d.ts.map +1 -0
- package/dist/types/ai-model/workflows/insight/extraction.d.ts +6 -5
- package/dist/types/ai-model/workflows/insight/extraction.d.ts.map +1 -1
- package/dist/types/ai-model/workflows/planning/types.d.ts +2 -0
- package/dist/types/ai-model/workflows/planning/types.d.ts.map +1 -1
- package/dist/types/device/index.d.ts +7 -7
- package/dist/types/types.d.ts +8 -1
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
resolveModelForTask: ()=>resolveModelForTask
|
|
28
|
+
});
|
|
29
|
+
const logger_namespaceObject = require("@midscene/shared/logger");
|
|
30
|
+
const external_registry_js_namespaceObject = require("./registry.js");
|
|
31
|
+
function resolveModelForTask(configs, intent, task) {
|
|
32
|
+
const requested = (0, external_registry_js_namespaceObject.getModelRuntime)(configs.getModelConfig(intent));
|
|
33
|
+
if (!requested.adapter.supportedTasks || requested.adapter.supportedTasks.includes(task)) return requested;
|
|
34
|
+
const config = configs.getModelConfig('default');
|
|
35
|
+
const runtime = (0, external_registry_js_namespaceObject.getModelRuntime)({
|
|
36
|
+
...config,
|
|
37
|
+
intent
|
|
38
|
+
});
|
|
39
|
+
if (runtime.adapter.supportedTasks && !runtime.adapter.supportedTasks.includes(task)) throw new Error(`The default model cannot perform ${task}. Configure a general-purpose default model.`);
|
|
40
|
+
const reason = `${requested.config.modelFamily} does not support ${task}; using the default model`;
|
|
41
|
+
(0, logger_namespaceObject.getDebug)('ai:model-routing', {
|
|
42
|
+
console: true
|
|
43
|
+
})(reason);
|
|
44
|
+
return {
|
|
45
|
+
...runtime,
|
|
46
|
+
modelRouting: {
|
|
47
|
+
requestedModel: requested.config.modelName,
|
|
48
|
+
requestedSlot: requested.config.slot,
|
|
49
|
+
task,
|
|
50
|
+
reason
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
exports.resolveModelForTask = __webpack_exports__.resolveModelForTask;
|
|
55
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
56
|
+
"resolveModelForTask"
|
|
57
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
58
|
+
Object.defineProperty(exports, '__esModule', {
|
|
59
|
+
value: true
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=task-routing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-model/models/task-routing.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/models/task-routing.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { IModelConfig, TIntent } from '@midscene/shared/env';\nimport { getDebug } from '@midscene/shared/logger';\nimport type { ModelRuntime, ModelTask } from '../model-adapter/types';\nimport { getModelRuntime } from './registry';\n\nexport function resolveModelForTask(\n configs: { getModelConfig(intent: TIntent): IModelConfig },\n intent: TIntent,\n task: ModelTask,\n): ModelRuntime {\n const requested = getModelRuntime(configs.getModelConfig(intent));\n if (\n !requested.adapter.supportedTasks ||\n requested.adapter.supportedTasks.includes(task)\n ) {\n return requested;\n }\n const config = configs.getModelConfig('default');\n const runtime = getModelRuntime({ ...config, intent });\n if (\n runtime.adapter.supportedTasks &&\n !runtime.adapter.supportedTasks.includes(task)\n ) {\n throw new Error(\n `The default model cannot perform ${task}. Configure a general-purpose default model.`,\n );\n }\n const reason = `${requested.config.modelFamily} does not support ${task}; using the default model`;\n getDebug('ai:model-routing', { console: true })(reason);\n return {\n ...runtime,\n modelRouting: {\n requestedModel: requested.config.modelName,\n requestedSlot: requested.config.slot,\n task,\n reason,\n },\n };\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","resolveModelForTask","configs","intent","task","requested","getModelRuntime","config","runtime","Error","reason","getDebug"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;ACDO,SAASI,oBACdC,OAA0D,EAC1DC,MAAe,EACfC,IAAe;IAEf,MAAMC,YAAYC,AAAAA,IAAAA,qCAAAA,eAAAA,AAAAA,EAAgBJ,QAAQ,cAAc,CAACC;IACzD,IACE,CAACE,UAAU,OAAO,CAAC,cAAc,IACjCA,UAAU,OAAO,CAAC,cAAc,CAAC,QAAQ,CAACD,OAE1C,OAAOC;IAET,MAAME,SAASL,QAAQ,cAAc,CAAC;IACtC,MAAMM,UAAUF,AAAAA,IAAAA,qCAAAA,eAAAA,AAAAA,EAAgB;QAAE,GAAGC,MAAM;QAAEJ;IAAO;IACpD,IACEK,QAAQ,OAAO,CAAC,cAAc,IAC9B,CAACA,QAAQ,OAAO,CAAC,cAAc,CAAC,QAAQ,CAACJ,OAEzC,MAAM,IAAIK,MACR,CAAC,iCAAiC,EAAEL,KAAK,4CAA4C,CAAC;IAG1F,MAAMM,SAAS,GAAGL,UAAU,MAAM,CAAC,WAAW,CAAC,kBAAkB,EAAED,KAAK,yBAAyB,CAAC;IAClGO,IAAAA,uBAAAA,QAAAA,AAAAA,EAAS,oBAAoB;QAAE,SAAS;IAAK,GAAGD;IAChD,OAAO;QACL,GAAGF,OAAO;QACV,cAAc;YACZ,gBAAgBH,UAAU,MAAM,CAAC,SAAS;YAC1C,eAAeA,UAAU,MAAM,CAAC,IAAI;YACpCD;YACAM;QACF;IACF;AACF"}
|
|
@@ -27,7 +27,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
27
27
|
isLocateIntent: ()=>isLocateIntent
|
|
28
28
|
});
|
|
29
29
|
function isLocateIntent(intent) {
|
|
30
|
-
return '
|
|
30
|
+
return 'locate' === intent;
|
|
31
31
|
}
|
|
32
32
|
exports.isLocateIntent = __webpack_exports__.isLocateIntent;
|
|
33
33
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-model/models/utils/intent.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/models/utils/intent.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { TIntent } from '@midscene/shared/env';\n\nexport function isLocateIntent(intent?: TIntent): boolean {\n return intent === '
|
|
1
|
+
{"version":3,"file":"ai-model/models/utils/intent.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/models/utils/intent.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { TIntent } from '@midscene/shared/env';\n\nexport function isLocateIntent(intent?: TIntent): boolean {\n return intent === 'locate';\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","isLocateIntent","intent"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;ACJO,SAASI,eAAeC,MAAgB;IAC7C,OAAOA,AAAW,aAAXA;AACT"}
|
|
@@ -35,6 +35,7 @@ const call_openai_js_namespaceObject = require("./openai/call-openai.js");
|
|
|
35
35
|
const chat_completion_js_namespaceObject = require("./openai/chat-completion/chat-completion.js");
|
|
36
36
|
const responses_js_namespaceObject = require("./openai/responses/responses.js");
|
|
37
37
|
const external_request_timeout_js_namespaceObject = require("./request-timeout.js");
|
|
38
|
+
const external_system_one_js_namespaceObject = require("./system-one.js");
|
|
38
39
|
const external_utils_js_namespaceObject = require("./utils.js");
|
|
39
40
|
function _define_property(obj, key, value) {
|
|
40
41
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
@@ -55,6 +56,13 @@ async function callAI(messages, modelRuntime, options) {
|
|
|
55
56
|
const internalCallId = (0, external_utils_js_namespaceObject.nextInternalCallId)();
|
|
56
57
|
const { config: modelConfig } = modelRuntime;
|
|
57
58
|
const prepare = async ()=>{
|
|
59
|
+
if (options?.systemOneRequest) {
|
|
60
|
+
(0, utils_namespaceObject.assert)('jev' === modelConfig.modelFamily, 'System One requests require the Jev model family');
|
|
61
|
+
return {
|
|
62
|
+
protocol: 'system-one',
|
|
63
|
+
input: await (0, external_system_one_js_namespaceObject.prepareSystemOne)(modelConfig, options.systemOneRequest)
|
|
64
|
+
};
|
|
65
|
+
}
|
|
58
66
|
const input = {
|
|
59
67
|
messages,
|
|
60
68
|
modelRuntime,
|
|
@@ -85,7 +93,7 @@ async function callAI(messages, modelRuntime, options) {
|
|
|
85
93
|
prepared
|
|
86
94
|
});
|
|
87
95
|
const { rawUsage, timeCost, totalTimeCost, retryCount, requestId, responseModelName, ...response } = result;
|
|
88
|
-
const
|
|
96
|
+
const rawUsageInfo = (0, external_utils_js_namespaceObject.buildUsageInfo)({
|
|
89
97
|
apiProtocol: prepared.protocol,
|
|
90
98
|
stream: response.isStreamed,
|
|
91
99
|
usageData: rawUsage,
|
|
@@ -99,6 +107,10 @@ async function callAI(messages, modelRuntime, options) {
|
|
|
99
107
|
slot: modelConfig.slot,
|
|
100
108
|
internalCallId
|
|
101
109
|
});
|
|
110
|
+
const usage = rawUsageInfo ? {
|
|
111
|
+
...rawUsageInfo,
|
|
112
|
+
modelRouting: modelRuntime.modelRouting
|
|
113
|
+
} : void 0;
|
|
102
114
|
const debugProfileStats = (0, logger_namespaceObject.getDebug)('ai:profile:stats');
|
|
103
115
|
const debugProfileDetail = (0, logger_namespaceObject.getDebug)('ai:profile:detail');
|
|
104
116
|
debugProfileStats(`model, ${modelConfig.modelName}, mode, ${modelConfig.modelFamily || 'default'}, streaming, ${response.isStreamed}, prompt-tokens, ${usage?.prompt_tokens ?? ''}, completion-tokens, ${usage?.completion_tokens ?? ''}, total-tokens, ${usage?.total_tokens ?? ''}, cached-input, ${usage?.cached_input ?? ''}, cost-ms, ${timeCost ?? ''}, requestId, ${requestId ?? ''}, slot, ${modelConfig.slot}, configured-temperature, ${modelConfig.temperature ?? ''}`);
|
|
@@ -164,6 +176,7 @@ async function callModelOnce({ messages, modelRuntime, options, executionId, int
|
|
|
164
176
|
slot: modelConfig.slot,
|
|
165
177
|
intent: modelConfig.intent,
|
|
166
178
|
modelFamily: modelConfig.modelFamily,
|
|
179
|
+
modelRouting: modelRuntime.modelRouting,
|
|
167
180
|
...event,
|
|
168
181
|
attempt
|
|
169
182
|
});
|
|
@@ -189,7 +202,7 @@ async function callModelOnce({ messages, modelRuntime, options, executionId, int
|
|
|
189
202
|
} : options
|
|
190
203
|
};
|
|
191
204
|
try {
|
|
192
|
-
return await (0, external_request_timeout_js_namespaceObject.runWithAbortSignal)(requestSignal, ()=>'codex' === prepared.protocol ? (0, call_codex_js_namespaceObject.callCodex)(context, prepared.input) : (0, call_openai_js_namespaceObject.callOpenAI)(context, prepared));
|
|
205
|
+
return await (0, external_request_timeout_js_namespaceObject.runWithAbortSignal)(requestSignal, ()=>'system-one' === prepared.protocol ? (0, external_system_one_js_namespaceObject.callSystemOne)(context, prepared.input) : 'codex' === prepared.protocol ? (0, call_codex_js_namespaceObject.callCodex)(context, prepared.input) : (0, call_openai_js_namespaceObject.callOpenAI)(context, prepared));
|
|
193
206
|
} catch (error) {
|
|
194
207
|
options?.abortSignal?.throwIfAborted();
|
|
195
208
|
const lastError = (0, external_utils_js_namespaceObject.toError)(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-model/service-caller/call-ai.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/service-caller/call-ai.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { getDebug } from '@midscene/shared/logger';\nimport { assert, uuid } from '@midscene/shared/utils';\nimport type { ModelRuntime } from '../models';\nimport { callCodex, prepareCodexCall } from './codex/call-codex';\nimport { isCodexAppServerProvider } from './codex/codex-app-server';\nimport {\n isModelCallRecordingEnabled,\n recordModelCallEvent,\n} from './model-call-recorder';\nimport { type PreparedOpenAIInput, callOpenAI } from './openai/call-openai';\nimport { prepareChatCompletion } from './openai/chat-completion/chat-completion';\nimport { prepareResponses } from './openai/responses/responses';\nimport {\n buildRequestAbortSignal,\n resolveEffectiveTimeoutMs,\n runWithAbortSignal,\n waitForRetry,\n} from './request-timeout';\nimport type { ModelCallMessages } from './types';\nimport type {\n AICallResult,\n CallAIOptions,\n ModelCallContext,\n ModelCallResult,\n} from './types';\nimport {\n appendAIRequestFailureSummary,\n buildUsageInfo,\n nextInternalCallId,\n normalizeRetryCount,\n toError,\n} from './utils';\n\nconst DEFAULT_MODEL_PROTOCOL = 'openai-chat';\n\nexport async function callAI(\n messages: ModelCallMessages,\n modelRuntime: ModelRuntime,\n options?: CallAIOptions,\n): Promise<AICallResult> {\n options?.abortSignal?.throwIfAborted();\n const isStreaming = options?.stream === true;\n if (isStreaming) {\n // Explicit streaming is currently used only by recorder code generation.\n // Streaming can also be aggregated without onChunk, but then the caller\n // cannot consume incremental output, which is the purpose of this option.\n // Environment-enabled streaming supports that aggregation-only use case.\n // Once onChunk delivers a chunk, later errors are not retried to avoid\n // delivering duplicate content. Errors before the first chunk can retry.\n assert(\n typeof options?.onChunk === 'function',\n 'onChunk is required when stream: true is explicitly specified',\n );\n }\n\n // Low-level callers without a TaskRunner still need a stable ID for the\n // lifetime of this model call (including its network retries).\n const executionId = modelRuntime.executionId ?? `unscoped-${uuid()}`;\n\n // Stable internal ID for this call, used by the agent to deduplicate usage\n // across the onUsage callback and the task-dump-based collectUsageMetrics()\n // path when the provider does not return a request_id.\n const internalCallId = nextInternalCallId();\n\n const { config: modelConfig } = modelRuntime;\n\n const prepare = async (): Promise<PreparedModelInput> => {\n const input = { messages, modelRuntime, options };\n if (isCodexAppServerProvider(modelConfig.openaiBaseURL)) {\n return { protocol: 'codex', input: prepareCodexCall(input) };\n }\n const protocol = modelConfig.protocol ?? DEFAULT_MODEL_PROTOCOL;\n\n assert(\n modelRuntime.adapter.supportedProtocols.includes(protocol),\n `Model adapter \"${modelConfig.modelFamily ?? 'default'}\" does not support protocol \"${protocol}\"`,\n );\n if (protocol === 'openai-responses') {\n return { protocol: 'responses', input: await prepareResponses(input) };\n }\n return {\n protocol: 'chat-completion',\n input: await prepareChatCompletion(input),\n };\n };\n\n const prepared = options?.abortSignal\n ? await runWithAbortSignal(options.abortSignal, prepare)\n : await prepare();\n\n const result = await callModelWithRetry({\n messages,\n modelRuntime,\n options,\n executionId,\n internalCallId,\n prepared,\n });\n\n const {\n rawUsage,\n timeCost,\n totalTimeCost,\n retryCount,\n requestId,\n responseModelName,\n ...response\n } = result;\n\n const usage = buildUsageInfo({\n apiProtocol: prepared.protocol,\n stream: response.isStreamed,\n usageData: rawUsage,\n timeCost,\n totalTimeCost,\n retryCount,\n requestId,\n responseModelName,\n modelName: modelConfig.modelName,\n modelDescription: modelConfig.modelDescription,\n slot: modelConfig.slot,\n internalCallId,\n });\n\n const debugProfileStats = getDebug('ai:profile:stats');\n const debugProfileDetail = getDebug('ai:profile:detail');\n debugProfileStats(\n `model, ${modelConfig.modelName}, mode, ${modelConfig.modelFamily || 'default'}, streaming, ${response.isStreamed}, prompt-tokens, ${usage?.prompt_tokens ?? ''}, completion-tokens, ${usage?.completion_tokens ?? ''}, total-tokens, ${usage?.total_tokens ?? ''}, cached-input, ${usage?.cached_input ?? ''}, cost-ms, ${timeCost ?? ''}, requestId, ${requestId ?? ''}, slot, ${modelConfig.slot}, configured-temperature, ${modelConfig.temperature ?? ''}`,\n );\n debugProfileDetail(`model usage detail: ${JSON.stringify(usage)}`);\n\n if (usage && modelRuntime.onUsage) {\n modelRuntime.onUsage(usage);\n }\n return { ...response, usage };\n}\n\ntype PreparedModelInput =\n | { protocol: 'codex'; input: ReturnType<typeof prepareCodexCall> }\n | PreparedOpenAIInput;\n\ntype ModelCallInput = {\n messages: ModelCallMessages;\n modelRuntime: ModelRuntime;\n options?: CallAIOptions;\n executionId: string;\n internalCallId: string;\n prepared: PreparedModelInput;\n};\n\n/** Carries the original failure across the retry boundary without replaying output. */\nclass NonRetryableModelCallError extends Error {\n readonly cause: Error;\n\n constructor(cause: Error) {\n super(cause.message, { cause });\n this.cause = cause;\n }\n}\n\nasync function callModelWithRetry(\n input: ModelCallInput,\n): Promise<ModelCallResult & { totalTimeCost: number; retryCount: number }> {\n const startTime = Date.now();\n const {\n modelRuntime: { config },\n options,\n } = input;\n const maxAttempts = normalizeRetryCount(config.retryCount) + 1;\n const retryInterval = config.retryInterval ?? 2000;\n const attemptErrors: Array<{ attempt: number; error: unknown }> = [];\n\n for (let attempt = 1; ; attempt++) {\n options?.abortSignal?.throwIfAborted();\n try {\n const result = await callModelOnce(input, attempt);\n return {\n ...result,\n totalTimeCost: Date.now() - startTime,\n retryCount: attempt - 1,\n };\n } catch (error) {\n options?.abortSignal?.throwIfAborted();\n if (error instanceof NonRetryableModelCallError) {\n throw error.cause;\n }\n const lastError = toError(error);\n attemptErrors.push({ attempt, error: lastError });\n if (attempt === maxAttempts) {\n throw appendAIRequestFailureSummary(\n lastError,\n attemptErrors,\n maxAttempts,\n );\n }\n getDebug('ai:call', { console: true })(\n `AI call failed (attempt ${attempt}/${maxAttempts}), retrying in ${retryInterval}ms... Error: ${lastError.message}`,\n );\n }\n await waitForRetry(retryInterval, options?.abortSignal);\n }\n}\n\nasync function callModelOnce(\n {\n messages,\n modelRuntime,\n options,\n executionId,\n internalCallId,\n prepared,\n }: ModelCallInput,\n attempt: number,\n): Promise<ModelCallResult> {\n const { config: modelConfig } = modelRuntime;\n const recordingEnabled = isModelCallRecordingEnabled();\n const recordEvent =\n recordingEnabled || modelRuntime.onRequest\n ? (event: Record<string, unknown>) => {\n if (event.type === 'request') {\n const request = event.request as { url?: string } | undefined;\n modelRuntime.onRequest?.(request?.url);\n }\n if (!recordingEnabled) return;\n void recordModelCallEvent({\n executionId,\n callId: internalCallId,\n semanticRetryAttempt: options?.semanticRetryAttempt,\n slot: modelConfig.slot,\n intent: modelConfig.intent,\n modelFamily: modelConfig.modelFamily,\n ...event,\n attempt,\n });\n }\n : undefined;\n const effectiveTimeoutMs = resolveEffectiveTimeoutMs(modelConfig.timeout);\n const { signal: requestSignal, cleanup } = buildRequestAbortSignal(\n effectiveTimeoutMs,\n options?.abortSignal,\n );\n let deliveredChunk = false;\n const onChunk = options?.onChunk;\n const context: ModelCallContext = {\n messages,\n modelRuntime,\n executionId,\n recordEvent,\n requestSignal,\n effectiveTimeoutMs,\n options: onChunk\n ? {\n ...options,\n onChunk: (chunk) => {\n requestSignal.throwIfAborted();\n deliveredChunk = true;\n onChunk(chunk);\n },\n }\n : options,\n };\n try {\n return await runWithAbortSignal(requestSignal, () =>\n prepared.protocol === 'codex'\n ? callCodex(context, prepared.input)\n : callOpenAI(context, prepared),\n );\n } catch (error) {\n options?.abortSignal?.throwIfAborted();\n const lastError = toError(error);\n if (deliveredChunk) {\n throw new NonRetryableModelCallError(lastError);\n }\n throw lastError;\n } finally {\n cleanup();\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","DEFAULT_MODEL_PROTOCOL","callAI","messages","modelRuntime","options","isStreaming","assert","executionId","uuid","internalCallId","nextInternalCallId","modelConfig","prepare","input","isCodexAppServerProvider","prepareCodexCall","protocol","prepareResponses","prepareChatCompletion","prepared","runWithAbortSignal","result","callModelWithRetry","rawUsage","timeCost","totalTimeCost","retryCount","requestId","responseModelName","response","usage","buildUsageInfo","debugProfileStats","getDebug","debugProfileDetail","JSON","NonRetryableModelCallError","Error","cause","startTime","Date","config","maxAttempts","normalizeRetryCount","retryInterval","attemptErrors","attempt","callModelOnce","error","lastError","toError","appendAIRequestFailureSummary","waitForRetry","recordingEnabled","isModelCallRecordingEnabled","recordEvent","event","request","recordModelCallEvent","undefined","effectiveTimeoutMs","resolveEffectiveTimeoutMs","requestSignal","cleanup","buildRequestAbortSignal","deliveredChunk","onChunk","context","chunk","callCodex","callOpenAI"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;;;;;;;;;;;;;;;AC2BA,MAAMI,yBAAyB;AAExB,eAAeC,OACpBC,QAA2B,EAC3BC,YAA0B,EAC1BC,OAAuB;IAEvBA,SAAS,aAAa;IACtB,MAAMC,cAAcD,SAAS,WAAW;IACxC,IAAIC,aAOFC,AAAAA,IAAAA,sBAAAA,MAAAA,AAAAA,EACE,AAA4B,cAA5B,OAAOF,SAAS,SAChB;IAMJ,MAAMG,cAAcJ,aAAa,WAAW,IAAI,CAAC,SAAS,EAAEK,AAAAA,IAAAA,sBAAAA,IAAAA,AAAAA,KAAQ;IAKpE,MAAMC,iBAAiBC,AAAAA,IAAAA,kCAAAA,kBAAAA,AAAAA;IAEvB,MAAM,EAAE,QA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QAAQE;YACR,sBAAsBL,SAAS;YAC/B,MAAMO,YAAY,IAAI;YACtB,QAAQA,YAAY,MAAM;YAC1B,aAAaA,YAAY,WAAW;YACpC,GAAG6C,KAAK;YACRV;QACF;IACF,IACAa;IACN,MAAMC,qBAAqBC,AAAAA,IAAAA,4CAAAA,yBAAAA,AAAAA,EAA0BlD,YAAY,OAAO;IACxE,MAAM,EAAE,QAAQmD,aAAa,EAAEC,OAAO,EAAE,GAAGC,AAAAA,IAAAA,4CAAAA,uBAAAA,AAAAA,EACzCJ,oBACAxD,SAAS;IAEX,IAAI6D,iBAAiB;IACrB,MAAMC,UAAU9D,SAAS;IACzB,MAAM+D,UAA4B;QAChCjE;QACAC;QACAI;QACAgD;QACAO;QACAF;QACA,SAASM,UACL;YACE,GAAG9D,OAAO;YACV,SAAS,CAACgE;gBACRN,cAAc,cAAc;gBAC5BG,iBAAiB;gBACjBC,QAAQE;YACV;QACF,IACAhE;IACN;IACA,IAAI;QACF,OAAO,MAAMgB,AAAAA,IAAAA,4CAAAA,kBAAAA,AAAAA,EAAmB0C,eAAe,IAC7C3C,AAAsB,YAAtBA,SAAS,QAAQ,GACbkD,AAAAA,IAAAA,8BAAAA,SAAAA,AAAAA,EAAUF,SAAShD,SAAS,KAAK,IACjCmD,AAAAA,IAAAA,+BAAAA,UAAAA,AAAAA,EAAWH,SAAShD;IAE5B,EAAE,OAAO6B,OAAO;QACd5C,SAAS,aAAa;QACtB,MAAM6C,YAAYC,AAAAA,IAAAA,kCAAAA,OAAAA,AAAAA,EAAQF;QAC1B,IAAIiB,gBACF,MAAM,IAAI7B,2BAA2Ba;QAEvC,MAAMA;IACR,SAAU;QACRc;IACF;AACF"}
|
|
1
|
+
{"version":3,"file":"ai-model/service-caller/call-ai.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/service-caller/call-ai.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { getDebug } from '@midscene/shared/logger';\nimport { assert, uuid } from '@midscene/shared/utils';\nimport type { ModelRuntime } from '../models';\nimport { callCodex, prepareCodexCall } from './codex/call-codex';\nimport { isCodexAppServerProvider } from './codex/codex-app-server';\nimport {\n isModelCallRecordingEnabled,\n recordModelCallEvent,\n} from './model-call-recorder';\nimport { type PreparedOpenAIInput, callOpenAI } from './openai/call-openai';\nimport { prepareChatCompletion } from './openai/chat-completion/chat-completion';\nimport { prepareResponses } from './openai/responses/responses';\nimport {\n buildRequestAbortSignal,\n resolveEffectiveTimeoutMs,\n runWithAbortSignal,\n waitForRetry,\n} from './request-timeout';\nimport { callSystemOne, prepareSystemOne } from './system-one';\nimport type { ModelCallMessages } from './types';\nimport type {\n AICallResult,\n CallAIOptions,\n ModelCallContext,\n ModelCallResult,\n} from './types';\nimport {\n appendAIRequestFailureSummary,\n buildUsageInfo,\n nextInternalCallId,\n normalizeRetryCount,\n toError,\n} from './utils';\n\nconst DEFAULT_MODEL_PROTOCOL = 'openai-chat';\n\nexport async function callAI(\n messages: ModelCallMessages,\n modelRuntime: ModelRuntime,\n options?: CallAIOptions,\n): Promise<AICallResult> {\n options?.abortSignal?.throwIfAborted();\n const isStreaming = options?.stream === true;\n if (isStreaming) {\n // Explicit streaming is currently used only by recorder code generation.\n // Streaming can also be aggregated without onChunk, but then the caller\n // cannot consume incremental output, which is the purpose of this option.\n // Environment-enabled streaming supports that aggregation-only use case.\n // Once onChunk delivers a chunk, later errors are not retried to avoid\n // delivering duplicate content. Errors before the first chunk can retry.\n assert(\n typeof options?.onChunk === 'function',\n 'onChunk is required when stream: true is explicitly specified',\n );\n }\n\n // Low-level callers without a TaskRunner still need a stable ID for the\n // lifetime of this model call (including its network retries).\n const executionId = modelRuntime.executionId ?? `unscoped-${uuid()}`;\n\n // Stable internal ID for this call, used by the agent to deduplicate usage\n // across the onUsage callback and the task-dump-based collectUsageMetrics()\n // path when the provider does not return a request_id.\n const internalCallId = nextInternalCallId();\n\n const { config: modelConfig } = modelRuntime;\n\n const prepare = async (): Promise<PreparedModelInput> => {\n if (options?.systemOneRequest) {\n assert(\n modelConfig.modelFamily === 'jev',\n 'System One requests require the Jev model family',\n );\n return {\n protocol: 'system-one',\n input: await prepareSystemOne(modelConfig, options.systemOneRequest),\n };\n }\n const input = { messages, modelRuntime, options };\n if (isCodexAppServerProvider(modelConfig.openaiBaseURL)) {\n return { protocol: 'codex', input: prepareCodexCall(input) };\n }\n const protocol = modelConfig.protocol ?? DEFAULT_MODEL_PROTOCOL;\n\n assert(\n modelRuntime.adapter.supportedProtocols.includes(protocol),\n `Model adapter \"${modelConfig.modelFamily ?? 'default'}\" does not support protocol \"${protocol}\"`,\n );\n if (protocol === 'openai-responses') {\n return { protocol: 'responses', input: await prepareResponses(input) };\n }\n return {\n protocol: 'chat-completion',\n input: await prepareChatCompletion(input),\n };\n };\n\n const prepared = options?.abortSignal\n ? await runWithAbortSignal(options.abortSignal, prepare)\n : await prepare();\n\n const result = await callModelWithRetry({\n messages,\n modelRuntime,\n options,\n executionId,\n internalCallId,\n prepared,\n });\n\n const {\n rawUsage,\n timeCost,\n totalTimeCost,\n retryCount,\n requestId,\n responseModelName,\n ...response\n } = result;\n\n const rawUsageInfo = buildUsageInfo({\n apiProtocol: prepared.protocol,\n stream: response.isStreamed,\n usageData: rawUsage,\n timeCost,\n totalTimeCost,\n retryCount,\n requestId,\n responseModelName,\n modelName: modelConfig.modelName,\n modelDescription: modelConfig.modelDescription,\n slot: modelConfig.slot,\n internalCallId,\n });\n\n const usage = rawUsageInfo\n ? { ...rawUsageInfo, modelRouting: modelRuntime.modelRouting }\n : undefined;\n\n const debugProfileStats = getDebug('ai:profile:stats');\n const debugProfileDetail = getDebug('ai:profile:detail');\n debugProfileStats(\n `model, ${modelConfig.modelName}, mode, ${modelConfig.modelFamily || 'default'}, streaming, ${response.isStreamed}, prompt-tokens, ${usage?.prompt_tokens ?? ''}, completion-tokens, ${usage?.completion_tokens ?? ''}, total-tokens, ${usage?.total_tokens ?? ''}, cached-input, ${usage?.cached_input ?? ''}, cost-ms, ${timeCost ?? ''}, requestId, ${requestId ?? ''}, slot, ${modelConfig.slot}, configured-temperature, ${modelConfig.temperature ?? ''}`,\n );\n debugProfileDetail(`model usage detail: ${JSON.stringify(usage)}`);\n\n if (usage && modelRuntime.onUsage) {\n modelRuntime.onUsage(usage);\n }\n return { ...response, usage };\n}\n\ntype PreparedModelInput =\n | {\n protocol: 'system-one';\n input: Awaited<ReturnType<typeof prepareSystemOne>>;\n }\n | { protocol: 'codex'; input: ReturnType<typeof prepareCodexCall> }\n | PreparedOpenAIInput;\n\ntype ModelCallInput = {\n messages: ModelCallMessages;\n modelRuntime: ModelRuntime;\n options?: CallAIOptions;\n executionId: string;\n internalCallId: string;\n prepared: PreparedModelInput;\n};\n\n/** Carries the original failure across the retry boundary without replaying output. */\nclass NonRetryableModelCallError extends Error {\n readonly cause: Error;\n\n constructor(cause: Error) {\n super(cause.message, { cause });\n this.cause = cause;\n }\n}\n\nasync function callModelWithRetry(\n input: ModelCallInput,\n): Promise<ModelCallResult & { totalTimeCost: number; retryCount: number }> {\n const startTime = Date.now();\n const {\n modelRuntime: { config },\n options,\n } = input;\n const maxAttempts = normalizeRetryCount(config.retryCount) + 1;\n const retryInterval = config.retryInterval ?? 2000;\n const attemptErrors: Array<{ attempt: number; error: unknown }> = [];\n\n for (let attempt = 1; ; attempt++) {\n options?.abortSignal?.throwIfAborted();\n try {\n const result = await callModelOnce(input, attempt);\n return {\n ...result,\n totalTimeCost: Date.now() - startTime,\n retryCount: attempt - 1,\n };\n } catch (error) {\n options?.abortSignal?.throwIfAborted();\n if (error instanceof NonRetryableModelCallError) {\n throw error.cause;\n }\n const lastError = toError(error);\n attemptErrors.push({ attempt, error: lastError });\n if (attempt === maxAttempts) {\n throw appendAIRequestFailureSummary(\n lastError,\n attemptErrors,\n maxAttempts,\n );\n }\n getDebug('ai:call', { console: true })(\n `AI call failed (attempt ${attempt}/${maxAttempts}), retrying in ${retryInterval}ms... Error: ${lastError.message}`,\n );\n }\n await waitForRetry(retryInterval, options?.abortSignal);\n }\n}\n\nasync function callModelOnce(\n {\n messages,\n modelRuntime,\n options,\n executionId,\n internalCallId,\n prepared,\n }: ModelCallInput,\n attempt: number,\n): Promise<ModelCallResult> {\n const { config: modelConfig } = modelRuntime;\n const recordingEnabled = isModelCallRecordingEnabled();\n const recordEvent =\n recordingEnabled || modelRuntime.onRequest\n ? (event: Record<string, unknown>) => {\n if (event.type === 'request') {\n const request = event.request as { url?: string } | undefined;\n modelRuntime.onRequest?.(request?.url);\n }\n if (!recordingEnabled) return;\n void recordModelCallEvent({\n executionId,\n callId: internalCallId,\n semanticRetryAttempt: options?.semanticRetryAttempt,\n slot: modelConfig.slot,\n intent: modelConfig.intent,\n modelFamily: modelConfig.modelFamily,\n modelRouting: modelRuntime.modelRouting,\n ...event,\n attempt,\n });\n }\n : undefined;\n const effectiveTimeoutMs = resolveEffectiveTimeoutMs(modelConfig.timeout);\n const { signal: requestSignal, cleanup } = buildRequestAbortSignal(\n effectiveTimeoutMs,\n options?.abortSignal,\n );\n let deliveredChunk = false;\n const onChunk = options?.onChunk;\n const context: ModelCallContext = {\n messages,\n modelRuntime,\n executionId,\n recordEvent,\n requestSignal,\n effectiveTimeoutMs,\n options: onChunk\n ? {\n ...options,\n onChunk: (chunk) => {\n requestSignal.throwIfAborted();\n deliveredChunk = true;\n onChunk(chunk);\n },\n }\n : options,\n };\n try {\n return await runWithAbortSignal(requestSignal, () =>\n prepared.protocol === 'system-one'\n ? callSystemOne(context, prepared.input)\n : prepared.protocol === 'codex'\n ? callCodex(context, prepared.input)\n : callOpenAI(context, prepared),\n );\n } catch (error) {\n options?.abortSignal?.throwIfAborted();\n const lastError = toError(error);\n if (deliveredChunk) {\n throw new NonRetryableModelCallError(lastError);\n }\n throw lastError;\n } finally {\n cleanup();\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","DEFAULT_MODEL_PROTOCOL","callAI","messages","modelRuntime","options","isStreaming","assert","executionId","uuid","internalCallId","nextInternalCallId","modelConfig","prepare","prepareSystemOne","input","isCodexAppServerProvider","prepareCodexCall","protocol","prepareResponses","prepareChatCompletion","prepared","runWithAbortSignal","result","callModelWithRetry","rawUsage","timeCost","totalTimeCost","retryCount","requestId","responseModelName","response","rawUsageInfo","buildUsageInfo","usage","undefined","debugProfileStats","getDebug","debugProfileDetail","JSON","NonRetryableModelCallError","Error","cause","startTime","Date","config","maxAttempts","normalizeRetryCount","retryInterval","attemptErrors","attempt","callModelOnce","error","lastError","toError","appendAIRequestFailureSummary","waitForRetry","recordingEnabled","isModelCallRecordingEnabled","recordEvent","event","request","recordModelCallEvent","effectiveTimeoutMs","resolveEffectiveTimeoutMs","requestSignal","cleanup","buildRequestAbortSignal","deliveredChunk","onChunk","context","chunk","callSystemOne","callCodex","callOpenAI"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,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EAAE,QAAQqD,aAAa,EAAEC,OAAO,EAAE,GAAGC,AAAAA,IAAAA,4CAAAA,uBAAAA,AAAAA,EACzCJ,oBACA1D,SAAS;IAEX,IAAI+D,iBAAiB;IACrB,MAAMC,UAAUhE,SAAS;IACzB,MAAMiE,UAA4B;QAChCnE;QACAC;QACAI;QACAmD;QACAM;QACAF;QACA,SAASM,UACL;YACE,GAAGhE,OAAO;YACV,SAAS,CAACkE;gBACRN,cAAc,cAAc;gBAC5BG,iBAAiB;gBACjBC,QAAQE;YACV;QACF,IACAlE;IACN;IACA,IAAI;QACF,OAAO,MAAMiB,AAAAA,IAAAA,4CAAAA,kBAAAA,AAAAA,EAAmB2C,eAAe,IAC7C5C,AAAsB,iBAAtBA,SAAS,QAAQ,GACbmD,AAAAA,IAAAA,uCAAAA,aAAAA,AAAAA,EAAcF,SAASjD,SAAS,KAAK,IACrCA,AAAsB,YAAtBA,SAAS,QAAQ,GACfoD,AAAAA,IAAAA,8BAAAA,SAAAA,AAAAA,EAAUH,SAASjD,SAAS,KAAK,IACjCqD,AAAAA,IAAAA,+BAAAA,UAAAA,AAAAA,EAAWJ,SAASjD;IAE9B,EAAE,OAAO+B,OAAO;QACd/C,SAAS,aAAa;QACtB,MAAMgD,YAAYC,AAAAA,IAAAA,kCAAAA,OAAAA,AAAAA,EAAQF;QAC1B,IAAIgB,gBACF,MAAM,IAAI5B,2BAA2Ba;QAEvC,MAAMA;IACR,SAAU;QACRa;IACF;AACF"}
|
|
@@ -26,7 +26,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
callOpenAI: ()=>callOpenAI
|
|
28
28
|
});
|
|
29
|
-
const env_namespaceObject = require("@midscene/shared/env");
|
|
30
29
|
const logger_namespaceObject = require("@midscene/shared/logger");
|
|
31
30
|
const external_utils_js_namespaceObject = require("../utils.js");
|
|
32
31
|
const chat_completion_js_namespaceObject = require("./chat-completion/chat-completion.js");
|
|
@@ -36,7 +35,7 @@ const responses_js_namespaceObject = require("./responses/responses.js");
|
|
|
36
35
|
async function callOpenAI({ modelRuntime, options, executionId, recordEvent, requestSignal, effectiveTimeoutMs }, prepared) {
|
|
37
36
|
const { config: modelConfig } = modelRuntime;
|
|
38
37
|
const { modelName } = modelConfig;
|
|
39
|
-
const isStreaming = options?.stream ?? 'stream' ===
|
|
38
|
+
const isStreaming = options?.stream ?? 'stream' === modelConfig.streamMode;
|
|
40
39
|
const { openai, openAIRequestContext } = await (0, external_openai_client_js_namespaceObject.createClient)({
|
|
41
40
|
modelConfig,
|
|
42
41
|
proxyAgent: prepared.input.proxyAgent,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-model/service-caller/openai/call-openai.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/service-caller/openai/call-openai.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import {
|
|
1
|
+
{"version":3,"file":"ai-model/service-caller/openai/call-openai.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/service-caller/openai/call-openai.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { getDebug } from '@midscene/shared/logger';\nimport type { ModelCallContext, ModelCallResult } from '../types';\nimport { AIResponseParseError } from '../utils';\nimport {\n callChatCompletion,\n type prepareChatCompletion,\n} from './chat-completion/chat-completion';\nimport { createClient } from './openai-client';\nimport { formatOpenAIAPIErrorDetails } from './openai-request-context';\nimport { callResponses, type prepareResponses } from './responses/responses';\n\nexport type PreparedOpenAIInput =\n | {\n protocol: 'chat-completion';\n input: Awaited<ReturnType<typeof prepareChatCompletion>>;\n }\n | {\n protocol: 'responses';\n input: Awaited<ReturnType<typeof prepareResponses>>;\n };\n\nexport async function callOpenAI(\n {\n modelRuntime,\n options,\n executionId,\n recordEvent,\n requestSignal,\n effectiveTimeoutMs,\n }: ModelCallContext,\n prepared: PreparedOpenAIInput,\n): Promise<ModelCallResult> {\n const { config: modelConfig } = modelRuntime;\n const { modelName } = modelConfig;\n const isStreaming = options?.stream ?? modelConfig.streamMode === 'stream';\n const { openai, openAIRequestContext } = await createClient({\n modelConfig,\n proxyAgent: prepared.input.proxyAgent,\n effectiveTimeoutMs,\n executionId,\n recordEvent,\n });\n const debugCall = getDebug('ai:call');\n debugCall(\n `sending ${isStreaming ? 'streaming ' : ''}request to ${modelName}`,\n );\n const requestOptions = {\n requestSignal,\n openAIRequestContext,\n onChunk: options?.onChunk ?? (() => undefined),\n recordEvent,\n };\n try {\n const startTime = Date.now();\n const response =\n prepared.protocol === 'responses'\n ? await callResponses(\n {\n ...requestOptions,\n responses: openai.responses,\n requestBodyParams: prepared.input.requestParams,\n },\n isStreaming,\n )\n : await callChatCompletion(\n {\n ...requestOptions,\n completion: openai.chat.completions,\n requestBodyParams: prepared.input.requestParams,\n extractContentAndReasoning:\n prepared.input.extractContentAndReasoning,\n useReasoningAsContentFallback:\n prepared.input.useReasoningAsContentFallback,\n },\n isStreaming,\n );\n const { reasoningContent, ...result } = response;\n requestSignal.throwIfAborted();\n const timeCost = Date.now() - startTime;\n debugCall(`response reasoning content: ${reasoningContent}`);\n debugCall(`response content: ${result.content}`);\n recordEvent?.({\n type: 'response',\n http: openAIRequestContext.httpResponse,\n final: {\n content: result.content,\n reasoningContent,\n usage: result.rawUsage,\n requestId: result.requestId,\n timeCost,\n responseModelName: result.responseModelName,\n },\n });\n return {\n ...result,\n reasoning_content: reasoningContent,\n isStreamed: isStreaming,\n timeCost,\n };\n } catch (error: any) {\n // Fetch already records non-2xx responses. Preserve successful HTTP\n // responses too when SDK parsing or completion validation fails.\n if (openAIRequestContext.httpResponse?.ok) {\n recordEvent?.({\n type: 'error',\n ...openAIRequestContext.httpResponse,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n getDebug('ai:call', { console: true })('call AI error', error);\n if (error instanceof AIResponseParseError) {\n throw error;\n }\n throw new Error(\n `failed to call ${isStreaming ? 'streaming ' : ''}AI model service (${modelName}): ${error.message}${formatOpenAIAPIErrorDetails(error, openAIRequestContext)}\\nTrouble shooting: https://midscenejs.com/model-provider.html`,\n { cause: error },\n );\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","callOpenAI","modelRuntime","options","executionId","recordEvent","requestSignal","effectiveTimeoutMs","prepared","modelConfig","modelName","isStreaming","openai","openAIRequestContext","createClient","debugCall","getDebug","requestOptions","undefined","startTime","Date","response","callResponses","callChatCompletion","reasoningContent","result","timeCost","error","Error","String","AIResponseParseError","formatOpenAIAPIErrorDetails"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAA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,AAAAA,IAAAA,mDAAAA,2BAAAA,AAAAA,EAA4BJ,OAAOd,sBAAsB,8DAA8D,CAAC,EAC7N;YAAE,OAAOc;QAAM;IAEnB;AACF"}
|
|
@@ -0,0 +1,206 @@
|
|
|
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
|
+
systemOneResponseSchema: ()=>systemOneResponseSchema,
|
|
28
|
+
systemOneAnswerSchema: ()=>systemOneAnswerSchema,
|
|
29
|
+
prepareSystemOne: ()=>prepareSystemOne,
|
|
30
|
+
callSystemOne: ()=>callSystemOne
|
|
31
|
+
});
|
|
32
|
+
const utils_namespaceObject = require("@midscene/shared/utils");
|
|
33
|
+
const external_zod_namespaceObject = require("zod");
|
|
34
|
+
const index_js_namespaceObject = require("./proxy/index.js");
|
|
35
|
+
const probability = external_zod_namespaceObject.z.number().min(0).max(1);
|
|
36
|
+
const systemOneAnswerSchema = external_zod_namespaceObject.z.discriminatedUnion('type', [
|
|
37
|
+
external_zod_namespaceObject.z.object({
|
|
38
|
+
type: external_zod_namespaceObject.z.literal('noul'),
|
|
39
|
+
noul: probability
|
|
40
|
+
}),
|
|
41
|
+
external_zod_namespaceObject.z.object({
|
|
42
|
+
type: external_zod_namespaceObject.z.literal('choice'),
|
|
43
|
+
choice: external_zod_namespaceObject.z.string()
|
|
44
|
+
}),
|
|
45
|
+
external_zod_namespaceObject.z.object({
|
|
46
|
+
type: external_zod_namespaceObject.z.literal('box'),
|
|
47
|
+
box: external_zod_namespaceObject.z.object({
|
|
48
|
+
left: probability,
|
|
49
|
+
right: probability,
|
|
50
|
+
top: probability,
|
|
51
|
+
bottom: probability
|
|
52
|
+
}).refine((box)=>box.left < box.right && box.top < box.bottom, 'Invalid box edges')
|
|
53
|
+
})
|
|
54
|
+
]);
|
|
55
|
+
const systemOneResponseSchema = external_zod_namespaceObject.z.object({
|
|
56
|
+
model: external_zod_namespaceObject.z.string().optional(),
|
|
57
|
+
answers: external_zod_namespaceObject.z.record(systemOneAnswerSchema),
|
|
58
|
+
usage: external_zod_namespaceObject.z.object({
|
|
59
|
+
input_tokens: external_zod_namespaceObject.z.number().nonnegative().nullable().optional(),
|
|
60
|
+
output_tokens: external_zod_namespaceObject.z.number().nonnegative().nullable().optional()
|
|
61
|
+
}).optional()
|
|
62
|
+
});
|
|
63
|
+
async function prepareSystemOne(config, request) {
|
|
64
|
+
(0, utils_namespaceObject.assert)(config.openaiBaseURL, 'Jev requires MIDSCENE_*_MODEL_BASE_URL');
|
|
65
|
+
(0, utils_namespaceObject.assert)(config.openaiApiKey, 'Jev requires MIDSCENE_*_MODEL_API_KEY');
|
|
66
|
+
(0, utils_namespaceObject.assert)(!config.protocol || 'openai-chat' === config.protocol, 'Jev uses System One, not the Responses API');
|
|
67
|
+
const base = config.openaiBaseURL.replace(/\/+$/, '');
|
|
68
|
+
const url = `${base}${base.endsWith('/v1') ? '' : '/v1'}/systemone`;
|
|
69
|
+
const isOpenRouter = 'openrouter.ai' === new URL(base).hostname;
|
|
70
|
+
const assets = {};
|
|
71
|
+
const imageState = Object.fromEntries(Object.entries(request.images ?? {}).map(([name, dataURL])=>{
|
|
72
|
+
if (isOpenRouter) return [
|
|
73
|
+
name,
|
|
74
|
+
{
|
|
75
|
+
type: 'image_url',
|
|
76
|
+
image_url: {
|
|
77
|
+
url: dataURL
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
];
|
|
81
|
+
const reference = (0, utils_namespaceObject.uuid)();
|
|
82
|
+
const match = /^data:image\/(png|jpeg);base64,(.+)$/.exec(dataURL);
|
|
83
|
+
(0, utils_namespaceObject.assert)(match, 'System One images must be prepared PNG or JPEG data URLs');
|
|
84
|
+
assets[reference] = {
|
|
85
|
+
type: 'image',
|
|
86
|
+
format: 'png' === match[1] ? 'png' : 'jpg',
|
|
87
|
+
data_base64: match[2]
|
|
88
|
+
};
|
|
89
|
+
return [
|
|
90
|
+
name,
|
|
91
|
+
reference
|
|
92
|
+
];
|
|
93
|
+
}));
|
|
94
|
+
const body = {
|
|
95
|
+
...config.extraBody,
|
|
96
|
+
model: config.modelName,
|
|
97
|
+
state: {
|
|
98
|
+
...request.state,
|
|
99
|
+
...imageState
|
|
100
|
+
},
|
|
101
|
+
questions: request.questions,
|
|
102
|
+
...!isOpenRouter && Object.keys(assets).length ? {
|
|
103
|
+
assets
|
|
104
|
+
} : {}
|
|
105
|
+
};
|
|
106
|
+
const serializedBody = JSON.stringify(body);
|
|
107
|
+
(0, utils_namespaceObject.assert)(new TextEncoder().encode(serializedBody).length <= 33554432, 'Jev request exceeds the 32 MiB body limit');
|
|
108
|
+
return {
|
|
109
|
+
url,
|
|
110
|
+
body: serializedBody,
|
|
111
|
+
questions: request.questions,
|
|
112
|
+
headers: {
|
|
113
|
+
...config.openaiExtraConfig?.defaultHeaders,
|
|
114
|
+
Authorization: `Bearer ${config.openaiApiKey}`,
|
|
115
|
+
'Content-Type': 'application/json',
|
|
116
|
+
'TypeSafe-Danger-Zone-Images': 'true'
|
|
117
|
+
},
|
|
118
|
+
dispatcher: await (0, index_js_namespaceObject.createProxyAgentIfNeeded)({
|
|
119
|
+
socksProxy: config.socksProxy,
|
|
120
|
+
httpProxy: config.httpProxy
|
|
121
|
+
})
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
async function callSystemOne(context, prepared) {
|
|
125
|
+
(0, utils_namespaceObject.assert)(!context.options?.stream, 'Jev does not support streaming output');
|
|
126
|
+
const start = Date.now();
|
|
127
|
+
context.recordEvent?.({
|
|
128
|
+
type: 'request',
|
|
129
|
+
request: {
|
|
130
|
+
url: prepared.url,
|
|
131
|
+
method: 'POST',
|
|
132
|
+
body: prepared.body
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
try {
|
|
136
|
+
const response = await fetch(prepared.url, {
|
|
137
|
+
method: 'POST',
|
|
138
|
+
headers: prepared.headers,
|
|
139
|
+
body: prepared.body,
|
|
140
|
+
signal: context.requestSignal,
|
|
141
|
+
...prepared.dispatcher ? {
|
|
142
|
+
dispatcher: prepared.dispatcher
|
|
143
|
+
} : {}
|
|
144
|
+
});
|
|
145
|
+
const body = await response.text();
|
|
146
|
+
const http = {
|
|
147
|
+
status: response.status,
|
|
148
|
+
ok: response.ok,
|
|
149
|
+
body
|
|
150
|
+
};
|
|
151
|
+
if (!response.ok) {
|
|
152
|
+
context.recordEvent?.({
|
|
153
|
+
type: 'error',
|
|
154
|
+
http
|
|
155
|
+
});
|
|
156
|
+
throw new Error(`Jev request failed (${response.status}): ${body.slice(0, 4000)}`);
|
|
157
|
+
}
|
|
158
|
+
const result = systemOneResponseSchema.parse(JSON.parse(body));
|
|
159
|
+
for (const [name, question] of Object.entries(prepared.questions))(0, utils_namespaceObject.assert)(result.answers[name]?.type === question.type, `Missing or invalid Jev answer: ${name}`);
|
|
160
|
+
for (const [name, question] of Object.entries(prepared.questions)){
|
|
161
|
+
const answer = result.answers[name];
|
|
162
|
+
if ('choice' === question.type && 'choice' === answer.type) (0, utils_namespaceObject.assert)(Object.hasOwn(question.criteria, answer.choice), `Invalid Jev choice: ${name}`);
|
|
163
|
+
}
|
|
164
|
+
const input = result.usage?.input_tokens;
|
|
165
|
+
const output = result.usage?.output_tokens;
|
|
166
|
+
const final = {
|
|
167
|
+
content: body,
|
|
168
|
+
isStreamed: false,
|
|
169
|
+
rawUsage: null != input && null != output ? {
|
|
170
|
+
prompt_tokens: input,
|
|
171
|
+
completion_tokens: output,
|
|
172
|
+
total_tokens: input + output
|
|
173
|
+
} : void 0,
|
|
174
|
+
timeCost: Date.now() - start,
|
|
175
|
+
requestId: response.headers.get('x-request-id'),
|
|
176
|
+
responseModelName: result.model
|
|
177
|
+
};
|
|
178
|
+
context.recordEvent?.({
|
|
179
|
+
type: 'response',
|
|
180
|
+
http,
|
|
181
|
+
final
|
|
182
|
+
});
|
|
183
|
+
return final;
|
|
184
|
+
} catch (error) {
|
|
185
|
+
context.recordEvent?.({
|
|
186
|
+
type: 'error',
|
|
187
|
+
error: error instanceof Error ? error.message : String(error)
|
|
188
|
+
});
|
|
189
|
+
throw error;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
exports.callSystemOne = __webpack_exports__.callSystemOne;
|
|
193
|
+
exports.prepareSystemOne = __webpack_exports__.prepareSystemOne;
|
|
194
|
+
exports.systemOneAnswerSchema = __webpack_exports__.systemOneAnswerSchema;
|
|
195
|
+
exports.systemOneResponseSchema = __webpack_exports__.systemOneResponseSchema;
|
|
196
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
197
|
+
"callSystemOne",
|
|
198
|
+
"prepareSystemOne",
|
|
199
|
+
"systemOneAnswerSchema",
|
|
200
|
+
"systemOneResponseSchema"
|
|
201
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
202
|
+
Object.defineProperty(exports, '__esModule', {
|
|
203
|
+
value: true
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
//# sourceMappingURL=system-one.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-model/service-caller/system-one.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/service-caller/system-one.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { IModelConfig } from '@midscene/shared/env';\nimport { assert, uuid } from '@midscene/shared/utils';\nimport { z } from 'zod';\nimport { createProxyAgentIfNeeded } from './proxy';\nimport type { ModelCallContext, ModelCallResult } from './types';\n\nexport interface SystemOneRequest {\n state: Record<string, unknown>;\n images?: Record<string, string>;\n questions: Record<\n string,\n | { type: 'noul' | 'box'; instructions: unknown }\n | {\n type: 'choice';\n instructions: unknown;\n criteria: Record<string, string>;\n }\n >;\n}\n\nconst probability = z.number().min(0).max(1);\nexport const systemOneAnswerSchema = z.discriminatedUnion('type', [\n z.object({ type: z.literal('noul'), noul: probability }),\n z.object({ type: z.literal('choice'), choice: z.string() }),\n z.object({\n type: z.literal('box'),\n box: z\n .object({\n left: probability,\n right: probability,\n top: probability,\n bottom: probability,\n })\n .refine(\n (box) => box.left < box.right && box.top < box.bottom,\n 'Invalid box edges',\n ),\n }),\n]);\nexport const systemOneResponseSchema = z.object({\n model: z.string().optional(),\n answers: z.record(systemOneAnswerSchema),\n usage: z\n .object({\n input_tokens: z.number().nonnegative().nullable().optional(),\n output_tokens: z.number().nonnegative().nullable().optional(),\n })\n .optional(),\n});\n\nexport async function prepareSystemOne(\n config: IModelConfig,\n request: SystemOneRequest,\n) {\n assert(config.openaiBaseURL, 'Jev requires MIDSCENE_*_MODEL_BASE_URL');\n assert(config.openaiApiKey, 'Jev requires MIDSCENE_*_MODEL_API_KEY');\n assert(\n !config.protocol || config.protocol === 'openai-chat',\n 'Jev uses System One, not the Responses API',\n );\n const base = config.openaiBaseURL.replace(/\\/+$/, '');\n const url = `${base}${base.endsWith('/v1') ? '' : '/v1'}/systemone`;\n const isOpenRouter = new URL(base).hostname === 'openrouter.ai';\n const assets: Record<string, unknown> = {};\n const imageState = Object.fromEntries(\n Object.entries(request.images ?? {}).map(([name, dataURL]) => {\n if (isOpenRouter) {\n return [name, { type: 'image_url', image_url: { url: dataURL } }];\n }\n const reference = uuid();\n const match = /^data:image\\/(png|jpeg);base64,(.+)$/.exec(dataURL);\n assert(match, 'System One images must be prepared PNG or JPEG data URLs');\n assets[reference] = {\n type: 'image',\n format: match[1] === 'png' ? 'png' : 'jpg',\n data_base64: match[2],\n };\n return [name, reference];\n }),\n );\n const body = {\n ...config.extraBody,\n model: config.modelName,\n state: { ...request.state, ...imageState },\n questions: request.questions,\n ...(!isOpenRouter && Object.keys(assets).length ? { assets } : {}),\n };\n const serializedBody = JSON.stringify(body);\n assert(\n new TextEncoder().encode(serializedBody).length <= 32 * 1024 * 1024,\n 'Jev request exceeds the 32 MiB body limit',\n );\n return {\n url,\n body: serializedBody,\n questions: request.questions,\n headers: {\n ...(config.openaiExtraConfig?.defaultHeaders as\n | Record<string, string>\n | undefined),\n Authorization: `Bearer ${config.openaiApiKey}`,\n 'Content-Type': 'application/json',\n 'TypeSafe-Danger-Zone-Images': 'true',\n },\n dispatcher: await createProxyAgentIfNeeded({\n socksProxy: config.socksProxy,\n httpProxy: config.httpProxy,\n }),\n };\n}\n\nexport async function callSystemOne(\n context: ModelCallContext,\n prepared: Awaited<ReturnType<typeof prepareSystemOne>>,\n): Promise<ModelCallResult> {\n assert(!context.options?.stream, 'Jev does not support streaming output');\n const start = Date.now();\n context.recordEvent?.({\n type: 'request',\n request: { url: prepared.url, method: 'POST', body: prepared.body },\n });\n try {\n const response = await fetch(prepared.url, {\n method: 'POST',\n headers: prepared.headers,\n body: prepared.body,\n signal: context.requestSignal,\n ...(prepared.dispatcher ? { dispatcher: prepared.dispatcher } : {}),\n });\n const body = await response.text();\n const http = { status: response.status, ok: response.ok, body };\n if (!response.ok) {\n context.recordEvent?.({ type: 'error', http });\n throw new Error(\n `Jev request failed (${response.status}): ${body.slice(0, 4000)}`,\n );\n }\n const result = systemOneResponseSchema.parse(JSON.parse(body));\n for (const [name, question] of Object.entries(prepared.questions)) {\n assert(\n result.answers[name]?.type === question.type,\n `Missing or invalid Jev answer: ${name}`,\n );\n }\n for (const [name, question] of Object.entries(prepared.questions)) {\n const answer = result.answers[name];\n if (question.type === 'choice' && answer.type === 'choice') {\n assert(\n Object.hasOwn(question.criteria, answer.choice),\n `Invalid Jev choice: ${name}`,\n );\n }\n }\n const input = result.usage?.input_tokens;\n const output = result.usage?.output_tokens;\n const final: ModelCallResult = {\n content: body,\n isStreamed: false,\n rawUsage:\n input != null && output != null\n ? {\n prompt_tokens: input,\n completion_tokens: output,\n total_tokens: input + output,\n }\n : undefined,\n timeCost: Date.now() - start,\n requestId: response.headers.get('x-request-id'),\n responseModelName: result.model,\n };\n context.recordEvent?.({ type: 'response', http, final });\n return final;\n } catch (error) {\n context.recordEvent?.({\n type: 'error',\n error: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","probability","z","systemOneAnswerSchema","box","systemOneResponseSchema","prepareSystemOne","config","request","assert","base","url","isOpenRouter","URL","assets","imageState","name","dataURL","reference","uuid","match","body","serializedBody","JSON","TextEncoder","createProxyAgentIfNeeded","callSystemOne","context","prepared","start","Date","response","fetch","http","Error","result","question","answer","input","output","final","undefined","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C,CAAC,oBAAoB,EAAErB,MAAM;QAGnC;QACA,MAAMsB,QAAQH,OAAO,KAAK,EAAE;QAC5B,MAAMI,SAASJ,OAAO,KAAK,EAAE;QAC7B,MAAMK,QAAyB;YAC7B,SAASnB;YACT,YAAY;YACZ,UACEiB,AAAS,QAATA,SAAiBC,AAAU,QAAVA,SACb;gBACE,eAAeD;gBACf,mBAAmBC;gBACnB,cAAcD,QAAQC;YACxB,IACAE;YACN,UAAUX,KAAK,GAAG,KAAKD;YACvB,WAAWE,SAAS,OAAO,CAAC,GAAG,CAAC;YAChC,mBAAmBI,OAAO,KAAK;QACjC;QACAR,QAAQ,WAAW,GAAG;YAAE,MAAM;YAAYM;YAAMO;QAAM;QACtD,OAAOA;IACT,EAAE,OAAOE,OAAO;QACdf,QAAQ,WAAW,GAAG;YACpB,MAAM;YACN,OAAOe,iBAAiBR,QAAQQ,MAAM,OAAO,GAAGC,OAAOD;QACzD;QACA,MAAMA;IACR;AACF"}
|
|
@@ -24,19 +24,23 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
|
|
27
|
+
modelFamilyRequiredForLocateMessage: ()=>modelFamilyRequiredForLocateMessage,
|
|
28
28
|
planningModelFamilyRequiredForLocateMessage: ()=>planningModelFamilyRequiredForLocateMessage
|
|
29
29
|
});
|
|
30
30
|
const modelConfigDocUrl = 'https://midscenejs.com/model-config';
|
|
31
|
-
|
|
31
|
+
function modelFamilyRequiredForLocateMessage(slot) {
|
|
32
|
+
const role = 'locate' === slot ? 'Locate' : 'Default';
|
|
33
|
+
const configKey = 'locate' === slot ? 'MIDSCENE_LOCATE_MODEL_FAMILY' : 'MIDSCENE_MODEL_FAMILY';
|
|
34
|
+
return `${role} model family is required for locate. Configure ${configKey} so Midscene can parse locate coordinates correctly. ${modelConfigDocUrl}`;
|
|
35
|
+
}
|
|
32
36
|
function planningModelFamilyRequiredForLocateMessage(slot) {
|
|
33
37
|
if ('planning' === slot) return `Planning model family is required because aiAct is asking the planning model to return locate coordinates. Configure MIDSCENE_PLANNING_MODEL_FAMILY for the planning model, or remove the separate planning model config and configure MIDSCENE_MODEL_FAMILY on the default model. ${modelConfigDocUrl}`;
|
|
34
38
|
return `Default model family is required because aiAct is asking the default model to return locate coordinates during planning. Configure MIDSCENE_MODEL_FAMILY so Midscene can parse planning locate coordinates correctly. ${modelConfigDocUrl}`;
|
|
35
39
|
}
|
|
36
|
-
exports.
|
|
40
|
+
exports.modelFamilyRequiredForLocateMessage = __webpack_exports__.modelFamilyRequiredForLocateMessage;
|
|
37
41
|
exports.planningModelFamilyRequiredForLocateMessage = __webpack_exports__.planningModelFamilyRequiredForLocateMessage;
|
|
38
42
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
39
|
-
"
|
|
43
|
+
"modelFamilyRequiredForLocateMessage",
|
|
40
44
|
"planningModelFamilyRequiredForLocateMessage"
|
|
41
45
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
42
46
|
Object.defineProperty(exports, '__esModule', {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-model/shared/model-locate-result/errors.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/shared/model-locate-result/errors.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const modelConfigDocUrl = 'https://midscenejs.com/model-config';\n\nexport const
|
|
1
|
+
{"version":3,"file":"ai-model/shared/model-locate-result/errors.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/shared/model-locate-result/errors.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const modelConfigDocUrl = 'https://midscenejs.com/model-config';\n\nexport function modelFamilyRequiredForLocateMessage(slot?: string) {\n const role = slot === 'locate' ? 'Locate' : 'Default';\n const configKey =\n slot === 'locate'\n ? 'MIDSCENE_LOCATE_MODEL_FAMILY'\n : 'MIDSCENE_MODEL_FAMILY';\n return `${role} model family is required for locate. Configure ${configKey} so Midscene can parse locate coordinates correctly. ${modelConfigDocUrl}`;\n}\n\nexport function planningModelFamilyRequiredForLocateMessage(slot?: string) {\n if (slot === 'planning') {\n return `Planning model family is required because aiAct is asking the planning model to return locate coordinates. Configure MIDSCENE_PLANNING_MODEL_FAMILY for the planning model, or remove the separate planning model config and configure MIDSCENE_MODEL_FAMILY on the default model. ${modelConfigDocUrl}`;\n }\n\n return `Default model family is required because aiAct is asking the default model to return locate coordinates during planning. Configure MIDSCENE_MODEL_FAMILY so Midscene can parse planning locate coordinates correctly. ${modelConfigDocUrl}`;\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","modelConfigDocUrl","modelFamilyRequiredForLocateMessage","slot","role","configKey","planningModelFamilyRequiredForLocateMessage"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;ACNA,MAAMI,oBAAoB;AAEnB,SAASC,oCAAoCC,IAAa;IAC/D,MAAMC,OAAOD,AAAS,aAATA,OAAoB,WAAW;IAC5C,MAAME,YACJF,AAAS,aAATA,OACI,iCACA;IACN,OAAO,GAAGC,KAAK,gDAAgD,EAAEC,UAAU,qDAAqD,EAAEJ,mBAAmB;AACvJ;AAEO,SAASK,4CAA4CH,IAAa;IACvE,IAAIA,AAAS,eAATA,MACF,OAAO,CAAC,mRAAmR,EAAEF,mBAAmB;IAGlT,OAAO,CAAC,sNAAsN,EAAEA,mBAAmB;AACrP"}
|