oc-browser-relay 1.0.10 → 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;
@@ -24367,7 +24437,7 @@ var STEP_DISPATCH_INTERVAL_MS = Number(process.env.STEP_DISPATCH_INTERVAL_MS) ||
24367
24437
  var RUNTIME_ONLINE_GRACE_MS = 1e4;
24368
24438
  var RUNTIME_PRESENCE_TTL_MS = 5 * 60 * 1e3;
24369
24439
  var COMPLETED_TASK_TTL_MS = Number(process.env.COMPLETED_TASK_TTL_MS) || 60 * 60 * 1e3;
24370
- var STEP_WATCHDOG_FALLBACK_TIMEOUT_MS = 12e4;
24440
+ var STEP_WATCHDOG_FALLBACK_TIMEOUT_MS = 6e4;
24371
24441
  var STEP_WATCHDOG_DEFAULT_TIMEOUTS = {
24372
24442
  upload_assets: 18e4,
24373
24443
  fill_field: 12e4,
@@ -32,7 +32,7 @@
32
32
  }
33
33
  ]
34
34
  },
35
- "waitTimeoutMs": 30000
35
+ "waitTimeoutMs": 15000
36
36
  },
37
37
  "reusePolicy": {
38
38
  "enabled": true,
@@ -60,7 +60,7 @@
60
60
  "waitForUrlMatch": [
61
61
  "https://fxg.jinritemai.com/ffa/mshop/homepage/index*"
62
62
  ],
63
- "waitTimeoutMs": 30000,
63
+ "waitTimeoutMs": 15000,
64
64
  "settleDelayMs": 600
65
65
  }
66
66
  ]
@@ -92,10 +92,9 @@
92
92
  "label": "切换首页时间粒度",
93
93
  "kind": "click",
94
94
  "skipPopupGuard": true,
95
- "locatorWaitTimeoutMs": 5000,
96
95
  "dropdownFallback": {
97
96
  "panelSelector": ".auxo-select-dropdown:not(.auxo-select-dropdown-hidden)",
98
- "panelWaitTimeoutMs": 5000,
97
+ "panelWaitTimeoutMs": 1800,
99
98
  "triggerLocators": [
100
99
  {
101
100
  "kind": "xpath",
@@ -165,12 +164,12 @@
165
164
  },
166
165
  "capturePlans": {
167
166
  "homepage_metrics": {
168
- "sourceId": "homepage_metrics",
169
- "captureNetwork": {
170
- "timeoutMs": 600000,
171
- "startPhase": "before_action",
172
- "actionScope": "step"
173
- }
167
+ "sourceId": "homepage_metrics",
168
+ "captureNetwork": {
169
+ "timeoutMs": 15000,
170
+ "startPhase": "before_action",
171
+ "actionScope": "step"
172
+ }
174
173
  }
175
174
  },
176
175
  "crawlerHints": {
@@ -190,7 +189,7 @@
190
189
  "homepage_metrics_capture": {
191
190
  "adapterId": "douyin_fxg_homepage_capture",
192
191
  "sourceId": "homepage_metrics_capture",
193
- "timeoutMs": 600000,
192
+ "timeoutMs": 30000,
194
193
  "observationSources": [
195
194
  {
196
195
  "sourceId": "homepage_metrics_capture",
@@ -57,13 +57,6 @@
57
57
  "actionId": "open_comments",
58
58
  "label": "打开评论面板",
59
59
  "kind": "click",
60
- "scrollSearchFallback": {
61
- "maxScrollAttempts": 4,
62
- "scrollDeltaPx": 720,
63
- "settleDelayMs": 250,
64
- "initialLocateTimeoutMs": 3000,
65
- "retryLocateTimeoutMs": 3000
66
- },
67
60
  "locators": [
68
61
  {
69
62
  "kind": "css",
@@ -93,13 +86,6 @@
93
86
  "actionId": "open_ask_answers",
94
87
  "label": "打开问大家面板",
95
88
  "kind": "click",
96
- "scrollSearchFallback": {
97
- "maxScrollAttempts": 4,
98
- "scrollDeltaPx": 720,
99
- "settleDelayMs": 250,
100
- "initialLocateTimeoutMs": 3000,
101
- "retryLocateTimeoutMs": 3000
102
- },
103
89
  "locators": [
104
90
  {
105
91
  "kind": "css",
@@ -23,7 +23,7 @@
23
23
  { "kind": "xpath", "value": "//div[.//div[normalize-space(text())='发布视频'] and .//div[contains(normalize-space(.), '推荐mp4、webm')]]", "priority": 2 },
24
24
  { "kind": "css", "value": "a[href*='/content/upload']", "priority": 3 }
25
25
  ],
26
- "readyTimeoutMs": 30000
26
+ "readyTimeoutMs": 8000
27
27
  }
28
28
  }
29
29
  }
@@ -37,9 +37,9 @@
37
37
  { "kind": "text", "value": "上传图文", "priority": 2 }
38
38
  ],
39
39
  "hoverDelayMs": 300,
40
- "menuWaitTimeoutMs": 10000,
40
+ "menuWaitTimeoutMs": 2500,
41
41
  "settleDelayMs": 1200,
42
- "readyTimeoutMs": 30000
42
+ "readyTimeoutMs": 8000
43
43
  }
44
44
  }
45
45
  }
@@ -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": {