@midscene/core 0.28.12-beta-20250923080328.0 → 0.28.12-beta-20250923091649.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.
Files changed (32) hide show
  1. package/dist/es/agent/agent.mjs +1 -1
  2. package/dist/es/agent/agent.mjs.map +1 -1
  3. package/dist/es/agent/tasks.mjs +140 -19
  4. package/dist/es/agent/tasks.mjs.map +1 -1
  5. package/dist/es/agent/utils.mjs +1 -1
  6. package/dist/es/ai-model/index.mjs +1 -2
  7. package/dist/es/ai-model/llm-planning.mjs +3 -23
  8. package/dist/es/ai-model/llm-planning.mjs.map +1 -1
  9. package/dist/es/ai-model/ui-tars-planning.mjs +6 -26
  10. package/dist/es/ai-model/ui-tars-planning.mjs.map +1 -1
  11. package/dist/es/utils.mjs +2 -2
  12. package/dist/lib/agent/agent.js +1 -1
  13. package/dist/lib/agent/agent.js.map +1 -1
  14. package/dist/lib/agent/tasks.js +139 -18
  15. package/dist/lib/agent/tasks.js.map +1 -1
  16. package/dist/lib/agent/utils.js +1 -1
  17. package/dist/lib/ai-model/index.js +2 -6
  18. package/dist/lib/ai-model/llm-planning.js +3 -23
  19. package/dist/lib/ai-model/llm-planning.js.map +1 -1
  20. package/dist/lib/ai-model/ui-tars-planning.js +6 -26
  21. package/dist/lib/ai-model/ui-tars-planning.js.map +1 -1
  22. package/dist/lib/utils.js +2 -2
  23. package/dist/types/agent/tasks.d.ts +17 -3
  24. package/dist/types/ai-model/index.d.ts +0 -1
  25. package/dist/types/ai-model/llm-planning.d.ts +0 -2
  26. package/dist/types/ai-model/ui-tars-planning.d.ts +18 -6
  27. package/package.json +3 -3
  28. package/dist/es/ai-model/conversation-history.mjs +0 -58
  29. package/dist/es/ai-model/conversation-history.mjs.map +0 -1
  30. package/dist/lib/ai-model/conversation-history.js +0 -92
  31. package/dist/lib/ai-model/conversation-history.js.map +0 -1
  32. package/dist/types/ai-model/conversation-history.d.ts +0 -18
@@ -1,3 +1,4 @@
1
+ import { type ChatCompletionMessageParam } from '../ai-model';
1
2
  import type { AbstractInterface } from '../device';
2
3
  import { type DetailedLocateParam, type ExecutionTaskApply, type ExecutionTaskProgressOptions, Executor, type Insight, type InsightExtractOption, type InsightExtractParam, type MidsceneYamlFlowItem, type PlanningAction, type PlanningActionParamWaitFor, type PlanningLocateParam, type TMultimodalPrompt, type TUserPrompt } from '../index';
3
4
  import { type IModelConfig } from '@midscene/shared/env';
@@ -12,7 +13,7 @@ export declare class TaskExecutor {
12
13
  interface: AbstractInterface;
13
14
  insight: Insight;
14
15
  taskCache?: TaskCache;
15
- private conversationHistory;
16
+ conversationHistory: ChatCompletionMessageParam[];
16
17
  onTaskStartCallback?: ExecutionTaskProgressOptions['onTaskStart'];
17
18
  replanningCycleLimit?: number;
18
19
  get page(): AbstractInterface;
@@ -31,15 +32,28 @@ export declare class TaskExecutor {
31
32
  loadYamlFlowAsPlanning(userInstruction: string, yamlString: string): Promise<{
32
33
  executor: Executor;
33
34
  }>;
34
- private createPlanningTask;
35
+ private planningTaskFromPrompt;
36
+ private planningTaskToGoal;
35
37
  runPlans(title: string, plans: PlanningAction[], modelConfig: IModelConfig): Promise<ExecutionResult>;
36
- private getReplanningCycleLimit;
37
38
  action(userPrompt: string, modelConfig: IModelConfig, actionContext?: string): Promise<ExecutionResult<{
38
39
  yamlFlow?: MidsceneYamlFlowItem[];
39
40
  } | undefined>>;
41
+ actionToGoal(userPrompt: string, modelConfig: IModelConfig): Promise<ExecutionResult<{
42
+ yamlFlow?: MidsceneYamlFlowItem[];
43
+ } | undefined>>;
40
44
  private createTypeQueryTask;
41
45
  createTypeQueryExecution<T>(type: 'Query' | 'Boolean' | 'Number' | 'String' | 'Assert', demand: InsightExtractParam, modelConfig: IModelConfig, opt?: InsightExtractOption, multimodalPrompt?: TMultimodalPrompt): Promise<ExecutionResult<T>>;
42
46
  assert(assertion: TUserPrompt, modelConfig: IModelConfig, opt?: InsightExtractOption): Promise<ExecutionResult<boolean>>;
47
+ /**
48
+ * Append a message to the conversation history
49
+ * For user messages with images:
50
+ * - Keep max 4 user image messages in history
51
+ * - Remove oldest user image message when limit reached
52
+ * For assistant messages:
53
+ * - Simply append to history
54
+ * @param conversationHistory Message to append
55
+ */
56
+ private appendConversationHistory;
43
57
  private appendErrorPlan;
44
58
  waitFor(assertion: TUserPrompt, opt: PlanningActionParamWaitFor, modelConfig: IModelConfig): Promise<ExecutionResult<void>>;
45
59
  }
@@ -8,6 +8,5 @@ export { AiLocateElement, AiExtractElementInfo, AiLocateSection, } from './inspe
8
8
  export { plan } from './llm-planning';
9
9
  export { adaptBboxToRect } from './common';
10
10
  export { vlmPlanning, resizeImageForUiTars } from './ui-tars-planning';
11
- export { ConversationHistory, type ConversationHistoryOptions, } from './conversation-history';
12
11
  export { AIActionType, type AIArgs } from './common';
13
12
  export { getMidsceneLocationSchema, type MidsceneLocationResultType, PointSchema, SizeSchema, RectSchema, TMultimodalPromptSchema, TUserPromptSchema, type TMultimodalPrompt, type TUserPrompt, findAllMidsceneLocatorField, dumpActionParam, loadActionParam, } from './common';
@@ -1,6 +1,5 @@
1
1
  import type { DeviceAction, InterfaceType, PlanningAIResponse, UIContext } from '../types';
2
2
  import type { IModelConfig } from '@midscene/shared/env';
3
- import type { ConversationHistory } from './conversation-history';
4
3
  export declare function plan(userInstruction: string, opts: {
5
4
  context: UIContext;
6
5
  interfaceType: InterfaceType;
@@ -8,5 +7,4 @@ export declare function plan(userInstruction: string, opts: {
8
7
  log?: string;
9
8
  actionContext?: string;
10
9
  modelConfig: IModelConfig;
11
- conversationHistory?: ConversationHistory;
12
10
  }): Promise<PlanningAIResponse>;
@@ -1,12 +1,24 @@
1
- import type { PlanningAIResponse, Size, UIContext } from '../types';
1
+ import type { AIUsageInfo, MidsceneYamlFlowItem, PlanningAction, Size } from '../types';
2
2
  import { type IModelConfig, UITarsModelVersion } from '@midscene/shared/env';
3
- import type { ConversationHistory } from './conversation-history';
3
+ import { actionParser } from '@ui-tars/action-parser';
4
+ import type { ChatCompletionMessageParam } from 'openai/resources/index';
4
5
  type ActionType = 'click' | 'drag' | 'type' | 'hotkey' | 'finished' | 'scroll' | 'wait';
5
- export declare function vlmPlanning(userInstruction: string, options: {
6
- conversationHistory: ConversationHistory;
7
- context: UIContext;
6
+ export declare function vlmPlanning(options: {
7
+ userInstruction: string;
8
+ conversationHistory: ChatCompletionMessageParam[];
9
+ size: {
10
+ width: number;
11
+ height: number;
12
+ };
8
13
  modelConfig: IModelConfig;
9
- }): Promise<PlanningAIResponse>;
14
+ }): Promise<{
15
+ actions: PlanningAction<any>[];
16
+ actionsFromModel: ReturnType<typeof actionParser>['parsed'];
17
+ action_summary: string;
18
+ yamlFlow?: MidsceneYamlFlowItem[];
19
+ usage?: AIUsageInfo;
20
+ rawResponse?: string;
21
+ }>;
10
22
  interface BaseAction {
11
23
  action_type: ActionType;
12
24
  action_inputs: Record<string, any>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@midscene/core",
3
3
  "description": "Automate browser actions, extract data, and perform assertions using AI. It offers JavaScript SDK, Chrome extension, and support for scripting in YAML. See https://midscenejs.com/ for details.",
4
- "version": "0.28.12-beta-20250923080328.0",
4
+ "version": "0.28.12-beta-20250923091649.0",
5
5
  "repository": "https://github.com/web-infra-dev/midscene",
6
6
  "homepage": "https://midscenejs.com/",
7
7
  "main": "./dist/lib/index.js",
@@ -87,8 +87,8 @@
87
87
  "zod": "3.24.3",
88
88
  "semver": "7.5.2",
89
89
  "js-yaml": "4.1.0",
90
- "@midscene/recorder": "0.28.12-beta-20250923080328.0",
91
- "@midscene/shared": "0.28.12-beta-20250923080328.0"
90
+ "@midscene/recorder": "0.28.12-beta-20250923091649.0",
91
+ "@midscene/shared": "0.28.12-beta-20250923091649.0"
92
92
  },
93
93
  "devDependencies": {
94
94
  "@microsoft/api-extractor": "^7.52.10",
@@ -1,58 +0,0 @@
1
- function _define_property(obj, key, value) {
2
- if (key in obj) Object.defineProperty(obj, key, {
3
- value: value,
4
- enumerable: true,
5
- configurable: true,
6
- writable: true
7
- });
8
- else obj[key] = value;
9
- return obj;
10
- }
11
- var _computedKey;
12
- _computedKey = Symbol.iterator;
13
- let _computedKey1 = _computedKey;
14
- class ConversationHistory {
15
- append(message) {
16
- if ('user' === message.role) this.pruneOldestUserMessageIfNecessary();
17
- this.messages.push(message);
18
- }
19
- seed(messages) {
20
- this.reset();
21
- messages.forEach((message)=>{
22
- this.append(message);
23
- });
24
- }
25
- reset() {
26
- this.messages.length = 0;
27
- }
28
- snapshot() {
29
- return [
30
- ...this.messages
31
- ];
32
- }
33
- get length() {
34
- return this.messages.length;
35
- }
36
- [_computedKey1]() {
37
- return this.messages[Symbol.iterator]();
38
- }
39
- toJSON() {
40
- return this.snapshot();
41
- }
42
- pruneOldestUserMessageIfNecessary() {
43
- const userMessages = this.messages.filter((item)=>'user' === item.role);
44
- if (userMessages.length < this.maxUserImageMessages) return;
45
- const firstUserMessageIndex = this.messages.findIndex((item)=>'user' === item.role);
46
- if (firstUserMessageIndex >= 0) this.messages.splice(firstUserMessageIndex, 1);
47
- }
48
- constructor(options){
49
- var _options_initialMessages;
50
- _define_property(this, "maxUserImageMessages", void 0);
51
- _define_property(this, "messages", []);
52
- this.maxUserImageMessages = (null == options ? void 0 : options.maxUserImageMessages) ?? 4;
53
- if (null == options ? void 0 : null == (_options_initialMessages = options.initialMessages) ? void 0 : _options_initialMessages.length) this.seed(options.initialMessages);
54
- }
55
- }
56
- export { ConversationHistory };
57
-
58
- //# sourceMappingURL=conversation-history.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ai-model/conversation-history.mjs","sources":["webpack://@midscene/core/./src/ai-model/conversation-history.ts"],"sourcesContent":["import type { ChatCompletionMessageParam } from 'openai/resources/index';\n\nexport interface ConversationHistoryOptions {\n maxUserImageMessages?: number;\n initialMessages?: ChatCompletionMessageParam[];\n}\n\nexport class ConversationHistory {\n private readonly maxUserImageMessages: number;\n private readonly messages: ChatCompletionMessageParam[] = [];\n\n constructor(options?: ConversationHistoryOptions) {\n this.maxUserImageMessages = options?.maxUserImageMessages ?? 4;\n if (options?.initialMessages?.length) {\n this.seed(options.initialMessages);\n }\n }\n\n append(message: ChatCompletionMessageParam) {\n if (message.role === 'user') {\n this.pruneOldestUserMessageIfNecessary();\n }\n\n this.messages.push(message);\n }\n\n seed(messages: ChatCompletionMessageParam[]) {\n this.reset();\n messages.forEach((message) => {\n this.append(message);\n });\n }\n\n reset() {\n this.messages.length = 0;\n }\n\n snapshot(): ChatCompletionMessageParam[] {\n return [...this.messages];\n }\n\n get length(): number {\n return this.messages.length;\n }\n\n [Symbol.iterator](): IterableIterator<ChatCompletionMessageParam> {\n return this.messages[Symbol.iterator]();\n }\n\n toJSON(): ChatCompletionMessageParam[] {\n return this.snapshot();\n }\n\n private pruneOldestUserMessageIfNecessary() {\n const userMessages = this.messages.filter((item) => item.role === 'user');\n if (userMessages.length < this.maxUserImageMessages) {\n return;\n }\n\n const firstUserMessageIndex = this.messages.findIndex(\n (item) => item.role === 'user',\n );\n\n if (firstUserMessageIndex >= 0) {\n this.messages.splice(firstUserMessageIndex, 1);\n }\n }\n}\n"],"names":["Symbol","ConversationHistory","message","messages","userMessages","item","firstUserMessageIndex","options","_options_initialMessages"],"mappings":";;;;;;;;;;;eA6CGA,OAAO,QAAQ;;AAtCX,MAAMC;IAWX,OAAOC,OAAmC,EAAE;QAC1C,IAAIA,AAAiB,WAAjBA,QAAQ,IAAI,EACd,IAAI,CAAC,iCAAiC;QAGxC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAACA;IACrB;IAEA,KAAKC,QAAsC,EAAE;QAC3C,IAAI,CAAC,KAAK;QACVA,SAAS,OAAO,CAAC,CAACD;YAChB,IAAI,CAAC,MAAM,CAACA;QACd;IACF;IAEA,QAAQ;QACN,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG;IACzB;IAEA,WAAyC;QACvC,OAAO;eAAI,IAAI,CAAC,QAAQ;SAAC;IAC3B;IAEA,IAAI,SAAiB;QACnB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM;IAC7B;IAEA,CAAC,cAAD,GAAkE;QAChE,OAAO,IAAI,CAAC,QAAQ,CAACF,OAAO,QAAQ,CAAC;IACvC;IAEA,SAAuC;QACrC,OAAO,IAAI,CAAC,QAAQ;IACtB;IAEQ,oCAAoC;QAC1C,MAAMI,eAAe,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAACC,OAASA,AAAc,WAAdA,KAAK,IAAI;QAC7D,IAAID,aAAa,MAAM,GAAG,IAAI,CAAC,oBAAoB,EACjD;QAGF,MAAME,wBAAwB,IAAI,CAAC,QAAQ,CAAC,SAAS,CACnD,CAACD,OAASA,AAAc,WAAdA,KAAK,IAAI;QAGrB,IAAIC,yBAAyB,GAC3B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAACA,uBAAuB;IAEhD;IAvDA,YAAYC,OAAoC,CAAE;YAE5CC;QALN,uBAAiB,wBAAjB;QACA,uBAAiB,YAAyC,EAAE;QAG1D,IAAI,CAAC,oBAAoB,GAAGD,AAAAA,CAAAA,QAAAA,UAAAA,KAAAA,IAAAA,QAAS,oBAAoB,AAAD,KAAK;QAC7D,IAAIC,QAAAA,UAAAA,KAAAA,IAAAA,QAAAA,CAAAA,2BAAAA,QAAS,eAAe,AAAD,IAAvBA,KAAAA,IAAAA,yBAA0B,MAAM,EAClC,IAAI,CAAC,IAAI,CAACD,QAAQ,eAAe;IAErC;AAmDF"}
@@ -1,92 +0,0 @@
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
- ConversationHistory: ()=>ConversationHistory
28
- });
29
- function _define_property(obj, key, value) {
30
- if (key in obj) Object.defineProperty(obj, key, {
31
- value: value,
32
- enumerable: true,
33
- configurable: true,
34
- writable: true
35
- });
36
- else obj[key] = value;
37
- return obj;
38
- }
39
- var _computedKey;
40
- _computedKey = Symbol.iterator;
41
- let _computedKey1 = _computedKey;
42
- class ConversationHistory {
43
- append(message) {
44
- if ('user' === message.role) this.pruneOldestUserMessageIfNecessary();
45
- this.messages.push(message);
46
- }
47
- seed(messages) {
48
- this.reset();
49
- messages.forEach((message)=>{
50
- this.append(message);
51
- });
52
- }
53
- reset() {
54
- this.messages.length = 0;
55
- }
56
- snapshot() {
57
- return [
58
- ...this.messages
59
- ];
60
- }
61
- get length() {
62
- return this.messages.length;
63
- }
64
- [_computedKey1]() {
65
- return this.messages[Symbol.iterator]();
66
- }
67
- toJSON() {
68
- return this.snapshot();
69
- }
70
- pruneOldestUserMessageIfNecessary() {
71
- const userMessages = this.messages.filter((item)=>'user' === item.role);
72
- if (userMessages.length < this.maxUserImageMessages) return;
73
- const firstUserMessageIndex = this.messages.findIndex((item)=>'user' === item.role);
74
- if (firstUserMessageIndex >= 0) this.messages.splice(firstUserMessageIndex, 1);
75
- }
76
- constructor(options){
77
- var _options_initialMessages;
78
- _define_property(this, "maxUserImageMessages", void 0);
79
- _define_property(this, "messages", []);
80
- this.maxUserImageMessages = (null == options ? void 0 : options.maxUserImageMessages) ?? 4;
81
- if (null == options ? void 0 : null == (_options_initialMessages = options.initialMessages) ? void 0 : _options_initialMessages.length) this.seed(options.initialMessages);
82
- }
83
- }
84
- exports.ConversationHistory = __webpack_exports__.ConversationHistory;
85
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
86
- "ConversationHistory"
87
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
88
- Object.defineProperty(exports, '__esModule', {
89
- value: true
90
- });
91
-
92
- //# sourceMappingURL=conversation-history.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ai-model/conversation-history.js","sources":["webpack://@midscene/core/webpack/runtime/define_property_getters","webpack://@midscene/core/webpack/runtime/has_own_property","webpack://@midscene/core/webpack/runtime/make_namespace_object","webpack://@midscene/core/./src/ai-model/conversation-history.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 { ChatCompletionMessageParam } from 'openai/resources/index';\n\nexport interface ConversationHistoryOptions {\n maxUserImageMessages?: number;\n initialMessages?: ChatCompletionMessageParam[];\n}\n\nexport class ConversationHistory {\n private readonly maxUserImageMessages: number;\n private readonly messages: ChatCompletionMessageParam[] = [];\n\n constructor(options?: ConversationHistoryOptions) {\n this.maxUserImageMessages = options?.maxUserImageMessages ?? 4;\n if (options?.initialMessages?.length) {\n this.seed(options.initialMessages);\n }\n }\n\n append(message: ChatCompletionMessageParam) {\n if (message.role === 'user') {\n this.pruneOldestUserMessageIfNecessary();\n }\n\n this.messages.push(message);\n }\n\n seed(messages: ChatCompletionMessageParam[]) {\n this.reset();\n messages.forEach((message) => {\n this.append(message);\n });\n }\n\n reset() {\n this.messages.length = 0;\n }\n\n snapshot(): ChatCompletionMessageParam[] {\n return [...this.messages];\n }\n\n get length(): number {\n return this.messages.length;\n }\n\n [Symbol.iterator](): IterableIterator<ChatCompletionMessageParam> {\n return this.messages[Symbol.iterator]();\n }\n\n toJSON(): ChatCompletionMessageParam[] {\n return this.snapshot();\n }\n\n private pruneOldestUserMessageIfNecessary() {\n const userMessages = this.messages.filter((item) => item.role === 'user');\n if (userMessages.length < this.maxUserImageMessages) {\n return;\n }\n\n const firstUserMessageIndex = this.messages.findIndex(\n (item) => item.role === 'user',\n );\n\n if (firstUserMessageIndex >= 0) {\n this.messages.splice(firstUserMessageIndex, 1);\n }\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","ConversationHistory","message","messages","userMessages","item","firstUserMessageIndex","options","_options_initialMessages"],"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;;;;;;;;;;;;;;;;;;eCuCGG,OAAO,QAAQ;;AAtCX,MAAMC;IAWX,OAAOC,OAAmC,EAAE;QAC1C,IAAIA,AAAiB,WAAjBA,QAAQ,IAAI,EACd,IAAI,CAAC,iCAAiC;QAGxC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAACA;IACrB;IAEA,KAAKC,QAAsC,EAAE;QAC3C,IAAI,CAAC,KAAK;QACVA,SAAS,OAAO,CAAC,CAACD;YAChB,IAAI,CAAC,MAAM,CAACA;QACd;IACF;IAEA,QAAQ;QACN,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG;IACzB;IAEA,WAAyC;QACvC,OAAO;eAAI,IAAI,CAAC,QAAQ;SAAC;IAC3B;IAEA,IAAI,SAAiB;QACnB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM;IAC7B;IAEA,CAAC,cAAD,GAAkE;QAChE,OAAO,IAAI,CAAC,QAAQ,CAACF,OAAO,QAAQ,CAAC;IACvC;IAEA,SAAuC;QACrC,OAAO,IAAI,CAAC,QAAQ;IACtB;IAEQ,oCAAoC;QAC1C,MAAMI,eAAe,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAACC,OAASA,AAAc,WAAdA,KAAK,IAAI;QAC7D,IAAID,aAAa,MAAM,GAAG,IAAI,CAAC,oBAAoB,EACjD;QAGF,MAAME,wBAAwB,IAAI,CAAC,QAAQ,CAAC,SAAS,CACnD,CAACD,OAASA,AAAc,WAAdA,KAAK,IAAI;QAGrB,IAAIC,yBAAyB,GAC3B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAACA,uBAAuB;IAEhD;IAvDA,YAAYC,OAAoC,CAAE;YAE5CC;QALN,uBAAiB,wBAAjB;QACA,uBAAiB,YAAyC,EAAE;QAG1D,IAAI,CAAC,oBAAoB,GAAGD,AAAAA,CAAAA,QAAAA,UAAAA,KAAAA,IAAAA,QAAS,oBAAoB,AAAD,KAAK;QAC7D,IAAIC,QAAAA,UAAAA,KAAAA,IAAAA,QAAAA,CAAAA,2BAAAA,QAAS,eAAe,AAAD,IAAvBA,KAAAA,IAAAA,yBAA0B,MAAM,EAClC,IAAI,CAAC,IAAI,CAACD,QAAQ,eAAe;IAErC;AAmDF"}
@@ -1,18 +0,0 @@
1
- import type { ChatCompletionMessageParam } from 'openai/resources/index';
2
- export interface ConversationHistoryOptions {
3
- maxUserImageMessages?: number;
4
- initialMessages?: ChatCompletionMessageParam[];
5
- }
6
- export declare class ConversationHistory {
7
- private readonly maxUserImageMessages;
8
- private readonly messages;
9
- constructor(options?: ConversationHistoryOptions);
10
- append(message: ChatCompletionMessageParam): void;
11
- seed(messages: ChatCompletionMessageParam[]): void;
12
- reset(): void;
13
- snapshot(): ChatCompletionMessageParam[];
14
- get length(): number;
15
- [Symbol.iterator](): IterableIterator<ChatCompletionMessageParam>;
16
- toJSON(): ChatCompletionMessageParam[];
17
- private pruneOldestUserMessageIfNecessary;
18
- }