oc-browser-relay 1.0.8 → 1.0.11

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.
@@ -22979,6 +22979,32 @@ var WorkspaceService = class {
22979
22979
  };
22980
22980
 
22981
22981
  // shared/template-executor.ts
22982
+ function formatDateLocal(date) {
22983
+ const year = date.getFullYear();
22984
+ const month = String(date.getMonth() + 1).padStart(2, "0");
22985
+ const day = String(date.getDate()).padStart(2, "0");
22986
+ return `${year}-${month}-${day}`;
22987
+ }
22988
+ function buildPreviousAvailableDailyDateRange(now = /* @__PURE__ */ new Date()) {
22989
+ const target = new Date(now);
22990
+ const daysBack = now.getHours() < 6 ? 2 : 1;
22991
+ target.setDate(target.getDate() - daysBack);
22992
+ const date = formatDateLocal(target);
22993
+ return `${date}|${date}`;
22994
+ }
22995
+ function buildEffectiveDailyPeriod(now = /* @__PURE__ */ new Date()) {
22996
+ const daysBack = now.getHours() < 6 ? 2 : 1;
22997
+ const target = new Date(now);
22998
+ target.setDate(target.getDate() - daysBack);
22999
+ const date = formatDateLocal(target);
23000
+ return {
23001
+ effectiveMetricPeriodLabel: daysBack === 2 ? "\u524D\u5929" : "\u6628\u5929",
23002
+ effectiveDateRange: `${date}|${date}`
23003
+ };
23004
+ }
23005
+ function normalizeMetricPeriodLabel(value) {
23006
+ return typeof value === "string" ? value.replace(/\s+/g, "") : "";
23007
+ }
22982
23008
  var TemplateExecutor = class _TemplateExecutor {
22983
23009
  static isPublishItemTemplate(template) {
22984
23010
  return template.platform === "xiaohongshu" && ["publish_note", "save_note_draft"].includes(template.taskType);
@@ -23090,8 +23116,52 @@ var TemplateExecutor = class _TemplateExecutor {
23090
23116
  hydrated[field.name] = field.default;
23091
23117
  }
23092
23118
  }
23119
+ this.applySycmLiveMetricDerivedDefaults(template, data, hydrated);
23093
23120
  return hydrated;
23094
23121
  }
23122
+ applySycmLiveMetricDerivedDefaults(template, rawInput, hydrated) {
23123
+ const isSycmLiveMetricsTemplate = template.siteId === "sycm_taobao" && template.taskType === "browser_action" && (template.optionalFields ?? []).some((field) => field.name === "metricPeriodLabel");
23124
+ if (!isSycmLiveMetricsTemplate) {
23125
+ return;
23126
+ }
23127
+ const normalizedLabel = normalizeMetricPeriodLabel(hydrated.metricPeriodLabel);
23128
+ const hasExplicitDateType = rawInput.requestDateType !== void 0;
23129
+ const hasExplicitDateRange = rawInput.requestDateRange !== void 0;
23130
+ const hasExplicitInvokeDirectly = rawInput.invokeDirectly !== void 0;
23131
+ const isYesterdayLabel = normalizedLabel === "\u6628\u5929";
23132
+ if (!hasExplicitDateType) {
23133
+ switch (normalizedLabel) {
23134
+ case "\u6628\u5929":
23135
+ case "\u65E5":
23136
+ hydrated.requestDateType = "day";
23137
+ break;
23138
+ case "\u5468":
23139
+ hydrated.requestDateType = "week";
23140
+ break;
23141
+ case "\u6708":
23142
+ hydrated.requestDateType = "month";
23143
+ break;
23144
+ case "\u5B9E\u65F6":
23145
+ hydrated.requestDateType = "today";
23146
+ break;
23147
+ default:
23148
+ break;
23149
+ }
23150
+ }
23151
+ if (!hasExplicitDateRange) {
23152
+ hydrated.requestDateRange = isYesterdayLabel ? buildPreviousAvailableDailyDateRange() : "";
23153
+ }
23154
+ if (isYesterdayLabel) {
23155
+ const effectiveDailyPeriod = buildEffectiveDailyPeriod();
23156
+ hydrated.effectiveMetricPeriodLabel = effectiveDailyPeriod.effectiveMetricPeriodLabel;
23157
+ hydrated.effectiveDateRange = effectiveDailyPeriod.effectiveDateRange;
23158
+ if ((/* @__PURE__ */ new Date()).getHours() < 6) {
23159
+ hydrated.invokeDirectly = true;
23160
+ } else if (!hasExplicitInvokeDirectly && hydrated.invokeDirectly === void 0) {
23161
+ hydrated.invokeDirectly = false;
23162
+ }
23163
+ }
23164
+ }
23095
23165
  mergeXiaohongshuTopicsIntoContent(template, data) {
23096
23166
  if (template.platform !== "xiaohongshu" || !["publish_note", "save_note_draft"].includes(template.taskType)) {
23097
23167
  return data;
@@ -18,8 +18,17 @@
18
18
  "value": "/ffa/mshop/homepage/index"
19
19
  },
20
20
  {
21
- "type": "element_visible",
22
- "selector": "label:has(input[type='radio'][value='Real']), label:has(input[type='radio'][value='Day'])"
21
+ "type": "logical_or",
22
+ "conditions": [
23
+ {
24
+ "type": "element_visible",
25
+ "selector": "label:has(input[type='radio'][value='Real']), label:has(input[type='radio'][value='Day'])"
26
+ },
27
+ {
28
+ "type": "element_visible",
29
+ "selector": "div.auxo-select-selector:has(input[role='combobox'][aria-haspopup='listbox'])"
30
+ }
31
+ ]
23
32
  }
24
33
  ]
25
34
  },
@@ -83,6 +92,54 @@
83
92
  "label": "切换首页时间粒度",
84
93
  "kind": "click",
85
94
  "skipPopupGuard": true,
95
+ "dropdownFallback": {
96
+ "panelSelector": ".auxo-select-dropdown:not(.auxo-select-dropdown-hidden)",
97
+ "panelWaitTimeoutMs": 1800,
98
+ "triggerLocators": [
99
+ {
100
+ "kind": "xpath",
101
+ "value": "//div[contains(@class,'auxo-select-selector')][.//span[contains(@class,'auxo-select-selection-item')][contains(normalize-space(.),'实时') or contains(normalize-space(.),'近1天') or contains(normalize-space(.),'近7天') or contains(normalize-space(.),'近30天') or contains(normalize-space(.),'大促')]]",
102
+ "priority": 1
103
+ }
104
+ ],
105
+ "optionLocatorsByValue": {
106
+ "Real": [
107
+ {
108
+ "kind": "xpath",
109
+ "value": "//div[contains(@class,'auxo-select-dropdown') and not(contains(@class,'auxo-select-dropdown-hidden'))]//div[contains(@class,'auxo-select-item-option')][.//div[contains(@class,'auxo-select-item-option-content') and normalize-space()='实时']]",
110
+ "priority": 1
111
+ }
112
+ ],
113
+ "Day": [
114
+ {
115
+ "kind": "xpath",
116
+ "value": "//div[contains(@class,'auxo-select-dropdown') and not(contains(@class,'auxo-select-dropdown-hidden'))]//div[contains(@class,'auxo-select-item-option')][.//div[contains(@class,'auxo-select-item-option-content') and normalize-space()='近1天']]",
117
+ "priority": 1
118
+ }
119
+ ],
120
+ "Week": [
121
+ {
122
+ "kind": "xpath",
123
+ "value": "//div[contains(@class,'auxo-select-dropdown') and not(contains(@class,'auxo-select-dropdown-hidden'))]//div[contains(@class,'auxo-select-item-option')][.//div[contains(@class,'auxo-select-item-option-content') and normalize-space()='近7天']]",
124
+ "priority": 1
125
+ }
126
+ ],
127
+ "Month": [
128
+ {
129
+ "kind": "xpath",
130
+ "value": "//div[contains(@class,'auxo-select-dropdown') and not(contains(@class,'auxo-select-dropdown-hidden'))]//div[contains(@class,'auxo-select-item-option')][.//div[contains(@class,'auxo-select-item-option-content') and normalize-space()='近30天']]",
131
+ "priority": 1
132
+ }
133
+ ],
134
+ "Promotion": [
135
+ {
136
+ "kind": "xpath",
137
+ "value": "//div[contains(@class,'auxo-select-dropdown') and not(contains(@class,'auxo-select-dropdown-hidden'))]//div[contains(@class,'auxo-select-item-option')][.//div[contains(@class,'auxo-select-item-option-content') and normalize-space()='大促']]",
138
+ "priority": 1
139
+ }
140
+ ]
141
+ }
142
+ },
86
143
  "locators": [
87
144
  {
88
145
  "kind": "xpath",
@@ -281,6 +281,9 @@
281
281
  }
282
282
  },
283
283
  "executionPolicy": {
284
+ "popupGuard": {
285
+ "enabled": false
286
+ },
284
287
  "typingPolicy": {
285
288
  "mode": "human_typing",
286
289
  "minKeyDelayMs": 120,
@@ -4,8 +4,7 @@
4
4
  "platform": "douyin",
5
5
  "name": "采集抖店首页经营看板指标",
6
6
  "description": "打开抖店商家后台首页,切换指定时间粒度按钮,捕获首页接口响应并返回结构化经营数据。",
7
- "requiredFields": [
8
- ],
7
+ "requiredFields": [],
9
8
  "optionalFields": [
10
9
  {
11
10
  "name": "pageUrl",
@@ -45,6 +44,9 @@
45
44
  "tool": "trigger_action",
46
45
  "args": {
47
46
  "action": "switch_metric_period",
47
+ "actionInput": {
48
+ "metricPeriodValue": "Day"
49
+ },
48
50
  "locators": [
49
51
  {
50
52
  "kind": "xpath",
@@ -62,6 +64,9 @@
62
64
  "tool": "trigger_action",
63
65
  "args": {
64
66
  "action": "switch_metric_period",
67
+ "actionInput": {
68
+ "metricPeriodValue": "Real"
69
+ },
65
70
  "locators": [
66
71
  {
67
72
  "kind": "xpath",
@@ -79,6 +84,9 @@
79
84
  "tool": "trigger_action",
80
85
  "args": {
81
86
  "action": "switch_metric_period",
87
+ "actionInput": {
88
+ "metricPeriodValue": "Real"
89
+ },
82
90
  "locators": [
83
91
  {
84
92
  "kind": "xpath",
@@ -96,6 +104,9 @@
96
104
  "tool": "trigger_action",
97
105
  "args": {
98
106
  "action": "switch_metric_period",
107
+ "actionInput": {
108
+ "metricPeriodValue": "Real"
109
+ },
99
110
  "locators": [
100
111
  {
101
112
  "kind": "xpath",
@@ -113,6 +124,9 @@
113
124
  "tool": "trigger_action",
114
125
  "args": {
115
126
  "action": "switch_metric_period",
127
+ "actionInput": {
128
+ "metricPeriodValue": "Real"
129
+ },
116
130
  "locators": [
117
131
  {
118
132
  "kind": "xpath",
@@ -129,6 +143,9 @@
129
143
  "tool": "trigger_action",
130
144
  "args": {
131
145
  "action": "switch_metric_period",
146
+ "actionInput": {
147
+ "metricPeriodValue": "{{data.metricPeriodValue}}"
148
+ },
132
149
  "locators": [
133
150
  {
134
151
  "kind": "xpath",
@@ -3,7 +3,7 @@
3
3
  "taskType": "browser_action",
4
4
  "platform": "taobao",
5
5
  "name": "采集生意参谋首页店铺数据",
6
- "description": "打开生意参谋首页,点击“实时 / 日 / 周 / 月”之一,同时采集首页概览与趋势接口。",
6
+ "description": "打开生意参谋首页,点击“昨天 / 实时 / 日 / 周 / 月”之一,同时采集首页概览与趋势接口。",
7
7
  "requiredFields": [],
8
8
  "optionalFields": [
9
9
  {
@@ -15,27 +15,37 @@
15
15
  {
16
16
  "name": "metricPeriodLabel",
17
17
  "type": "string",
18
- "description": "首页时间粒度按钮文本,支持:实时、日、周、月",
19
- "default": "实时"
18
+ "description": "首页时间粒度按钮文本,支持:昨天、实时、日、周、月",
19
+ "default": "昨天"
20
20
  },
21
21
  {
22
22
  "name": "invokeDirectly",
23
23
  "type": "boolean",
24
- "description": "是否跳过页面点击,直接在页面会话内调用接口",
24
+ "description": "是否跳过页面点击,直接在页面会话内调用接口;06:00 前请求“昨天”时会强制走直调以回退到前天",
25
25
  "default": false
26
26
  },
27
27
  {
28
28
  "name": "requestDateType",
29
29
  "type": "string",
30
- "description": "直调接口时使用的 dateType,例如 today/day/week/month",
30
+ "description": "直调接口时使用的 dateType,例如 today/day/week/month;未传时会按 metricPeriodLabel 自动推导",
31
31
  "default": "today"
32
32
  },
33
33
  {
34
34
  "name": "requestDateRange",
35
35
  "type": "string",
36
- "description": "直调接口时使用的 dateRange,格式 YYYY-MM-DD|YYYY-MM-DD;实时可留空",
36
+ "description": "直调接口时使用的 dateRange,格式 YYYY-MM-DD|YYYY-MM-DD;未传时“昨天”会自动补成可用的最近日范围,6 点前回退到前天,实时可留空",
37
37
  "default": ""
38
38
  },
39
+ {
40
+ "name": "effectiveMetricPeriodLabel",
41
+ "type": "string",
42
+ "description": "内部派生的实际生效周期标签;请求“昨天”时,06:00 前会变成“前天”"
43
+ },
44
+ {
45
+ "name": "effectiveDateRange",
46
+ "type": "string",
47
+ "description": "内部派生的实际生效日期范围,格式 YYYY-MM-DD|YYYY-MM-DD"
48
+ },
39
49
  {
40
50
  "name": "returnHostPatterns",
41
51
  "type": "array",
@@ -62,7 +72,7 @@
62
72
  {
63
73
  "nodeId": "s2b",
64
74
  "name": "prepare_realtime_metrics",
65
- "goal": "当目标为实时时,先切换到其他粒度,确保回切实时会触发刷新",
75
+ "goal": "先切换到其他粒度,确保再切回目标粒度时会触发刷新",
66
76
  "when": "equals(payload.invokeDirectly, false)",
67
77
  "tool": "trigger_action",
68
78
  "args": {
@@ -110,7 +120,7 @@
110
120
  {
111
121
  "nodeId": "s4",
112
122
  "name": "collect_live_metrics",
113
- "goal": "整合首页实时概览与趋势接口为统一结构化结果",
123
+ "goal": "整合首页概览与趋势接口为统一结构化结果",
114
124
  "when": "equals(payload.invokeDirectly, false)",
115
125
  "tool": "collect_structured_data",
116
126
  "args": {
@@ -123,12 +133,12 @@
123
133
  {
124
134
  "nodeId": "s3p",
125
135
  "name": "show_live_metrics_direct_activity",
126
- "goal": "在页面顶部展示独立提示,标记当前正在直调实时指标接口",
136
+ "goal": "在页面顶部展示独立提示,标记当前正在直调首页指标接口",
127
137
  "when": "equals(payload.invokeDirectly, true)",
128
138
  "tool": "present_page_activity",
129
139
  "args": {
130
140
  "mode": "start",
131
- "message": "正在分析实时数据",
141
+ "message": "正在分析首页指标数据",
132
142
  "style": "info",
133
143
  "showLabel": false,
134
144
  "profile": "none"
@@ -201,7 +211,7 @@
201
211
  {
202
212
  "nodeId": "s4c",
203
213
  "name": "hide_live_metrics_direct_activity",
204
- "goal": "在实时直调链路结束后关闭页面提示",
214
+ "goal": "在首页指标直调链路结束后关闭页面提示",
205
215
  "when": "equals(payload.invokeDirectly, true)",
206
216
  "tool": "present_page_activity",
207
217
  "args": {