browser-use 0.2.0 → 0.4.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 (259) hide show
  1. package/README.md +295 -686
  2. package/dist/actor/element.d.ts +19 -0
  3. package/dist/actor/element.js +46 -0
  4. package/dist/actor/index.d.ts +4 -0
  5. package/dist/actor/index.js +4 -0
  6. package/dist/actor/mouse.d.ts +19 -0
  7. package/dist/actor/mouse.js +39 -0
  8. package/dist/actor/page.d.ts +29 -0
  9. package/dist/actor/page.js +88 -0
  10. package/dist/actor/utils.d.ts +4 -0
  11. package/dist/actor/utils.js +35 -0
  12. package/dist/agent/cloud-events.d.ts +18 -0
  13. package/dist/agent/cloud-events.js +65 -2
  14. package/dist/agent/gif.d.ts +1 -0
  15. package/dist/agent/gif.js +24 -2
  16. package/dist/agent/judge.d.ts +17 -0
  17. package/dist/agent/judge.js +197 -0
  18. package/dist/agent/message-manager/service.d.ts +12 -4
  19. package/dist/agent/message-manager/service.js +205 -39
  20. package/dist/agent/message-manager/utils.js +0 -1
  21. package/dist/agent/message-manager/views.d.ts +4 -0
  22. package/dist/agent/message-manager/views.js +11 -7
  23. package/dist/agent/prompts.d.ts +24 -3
  24. package/dist/agent/prompts.js +274 -59
  25. package/dist/agent/service.d.ts +103 -41
  26. package/dist/agent/service.js +2336 -472
  27. package/dist/agent/variable-detector.d.ts +12 -0
  28. package/dist/agent/variable-detector.js +211 -0
  29. package/dist/agent/views.d.ts +237 -18
  30. package/dist/agent/views.js +446 -33
  31. package/dist/browser/cloud/cloud.d.ts +20 -0
  32. package/dist/browser/cloud/cloud.js +129 -0
  33. package/dist/browser/cloud/index.d.ts +2 -0
  34. package/dist/browser/cloud/index.js +2 -0
  35. package/dist/browser/cloud/views.d.ts +41 -0
  36. package/dist/browser/cloud/views.js +35 -0
  37. package/dist/browser/events.d.ts +345 -0
  38. package/dist/browser/events.js +566 -0
  39. package/dist/browser/extensions.js +17 -17
  40. package/dist/browser/index.d.ts +4 -0
  41. package/dist/browser/index.js +4 -0
  42. package/dist/browser/profile.d.ts +10 -4
  43. package/dist/browser/profile.js +79 -12
  44. package/dist/browser/session-manager.d.ts +85 -0
  45. package/dist/browser/session-manager.js +208 -0
  46. package/dist/browser/session.d.ts +105 -9
  47. package/dist/browser/session.js +1166 -95
  48. package/dist/browser/types.d.ts +153 -156
  49. package/dist/browser/views.d.ts +39 -0
  50. package/dist/browser/views.js +32 -0
  51. package/dist/browser/watchdogs/aboutblank-watchdog.d.ts +12 -0
  52. package/dist/browser/watchdogs/aboutblank-watchdog.js +131 -0
  53. package/dist/browser/watchdogs/base.d.ts +21 -0
  54. package/dist/browser/watchdogs/base.js +81 -0
  55. package/dist/browser/watchdogs/cdp-session-watchdog.d.ts +14 -0
  56. package/dist/browser/watchdogs/cdp-session-watchdog.js +177 -0
  57. package/dist/browser/watchdogs/crash-watchdog.d.ts +38 -0
  58. package/dist/browser/watchdogs/crash-watchdog.js +296 -0
  59. package/dist/browser/watchdogs/default-action-watchdog.d.ts +49 -0
  60. package/dist/browser/watchdogs/default-action-watchdog.js +212 -0
  61. package/dist/browser/watchdogs/dom-watchdog.d.ts +8 -0
  62. package/dist/browser/watchdogs/dom-watchdog.js +31 -0
  63. package/dist/browser/watchdogs/downloads-watchdog.d.ts +77 -0
  64. package/dist/browser/watchdogs/downloads-watchdog.js +409 -0
  65. package/dist/browser/watchdogs/har-recording-watchdog.d.ts +19 -0
  66. package/dist/browser/watchdogs/har-recording-watchdog.js +317 -0
  67. package/dist/browser/watchdogs/index.d.ts +15 -0
  68. package/dist/browser/watchdogs/index.js +15 -0
  69. package/dist/browser/watchdogs/local-browser-watchdog.d.ts +10 -0
  70. package/dist/browser/watchdogs/local-browser-watchdog.js +32 -0
  71. package/dist/browser/watchdogs/permissions-watchdog.d.ts +8 -0
  72. package/dist/browser/watchdogs/permissions-watchdog.js +73 -0
  73. package/dist/browser/watchdogs/popups-watchdog.d.ts +13 -0
  74. package/dist/browser/watchdogs/popups-watchdog.js +77 -0
  75. package/dist/browser/watchdogs/recording-watchdog.d.ts +27 -0
  76. package/dist/browser/watchdogs/recording-watchdog.js +249 -0
  77. package/dist/browser/watchdogs/screenshot-watchdog.d.ts +6 -0
  78. package/dist/browser/watchdogs/screenshot-watchdog.js +13 -0
  79. package/dist/browser/watchdogs/security-watchdog.d.ts +10 -0
  80. package/dist/browser/watchdogs/security-watchdog.js +84 -0
  81. package/dist/browser/watchdogs/storage-state-watchdog.d.ts +24 -0
  82. package/dist/browser/watchdogs/storage-state-watchdog.js +288 -0
  83. package/dist/cli.d.ts +7 -2
  84. package/dist/cli.js +182 -25
  85. package/dist/code-use/formatting.d.ts +3 -0
  86. package/dist/code-use/formatting.js +18 -0
  87. package/dist/code-use/index.d.ts +6 -0
  88. package/dist/code-use/index.js +6 -0
  89. package/dist/code-use/namespace.d.ts +5 -0
  90. package/dist/code-use/namespace.js +81 -0
  91. package/dist/code-use/notebook-export.d.ts +3 -0
  92. package/dist/code-use/notebook-export.js +56 -0
  93. package/dist/code-use/service.d.ts +24 -0
  94. package/dist/code-use/service.js +104 -0
  95. package/dist/code-use/utils.d.ts +4 -0
  96. package/dist/code-use/utils.js +98 -0
  97. package/dist/code-use/views.d.ts +108 -0
  98. package/dist/code-use/views.js +165 -0
  99. package/dist/config.d.ts +15 -0
  100. package/dist/config.js +109 -7
  101. package/dist/controller/registry/service.d.ts +10 -1
  102. package/dist/controller/registry/service.js +266 -10
  103. package/dist/controller/registry/views.d.ts +4 -1
  104. package/dist/controller/registry/views.js +25 -2
  105. package/dist/controller/service.d.ts +10 -1
  106. package/dist/controller/service.js +1814 -268
  107. package/dist/controller/views.d.ts +78 -155
  108. package/dist/controller/views.js +61 -12
  109. package/dist/dom/history-tree-processor/service.d.ts +5 -0
  110. package/dist/dom/history-tree-processor/service.js +169 -14
  111. package/dist/dom/history-tree-processor/view.d.ts +7 -1
  112. package/dist/dom/history-tree-processor/view.js +10 -1
  113. package/dist/dom/markdown-extractor.d.ts +37 -0
  114. package/dist/dom/markdown-extractor.js +345 -0
  115. package/dist/dom/service.d.ts +3 -1
  116. package/dist/dom/service.js +76 -0
  117. package/dist/dom/views.d.ts +1 -0
  118. package/dist/dom/views.js +45 -0
  119. package/dist/event-bus.d.ts +107 -7
  120. package/dist/event-bus.js +313 -10
  121. package/dist/exceptions.d.ts +0 -3
  122. package/dist/exceptions.js +0 -7
  123. package/dist/filesystem/file-system.d.ts +18 -0
  124. package/dist/filesystem/file-system.js +503 -42
  125. package/dist/index.d.ts +7 -0
  126. package/dist/index.js +6 -0
  127. package/dist/integrations/gmail/actions.d.ts +3 -3
  128. package/dist/integrations/gmail/actions.js +4 -4
  129. package/dist/llm/anthropic/chat.d.ts +18 -1
  130. package/dist/llm/anthropic/chat.js +123 -55
  131. package/dist/llm/anthropic/serializer.d.ts +2 -0
  132. package/dist/llm/anthropic/serializer.js +81 -9
  133. package/dist/llm/aws/chat-anthropic.d.ts +17 -0
  134. package/dist/llm/aws/chat-anthropic.js +126 -26
  135. package/dist/llm/aws/chat-bedrock.d.ts +28 -1
  136. package/dist/llm/aws/chat-bedrock.js +161 -34
  137. package/dist/llm/aws/serializer.d.ts +13 -1
  138. package/dist/llm/aws/serializer.js +56 -17
  139. package/dist/llm/azure/chat.d.ts +53 -2
  140. package/dist/llm/azure/chat.js +366 -54
  141. package/dist/llm/base.d.ts +2 -0
  142. package/dist/llm/browser-use/chat.d.ts +40 -0
  143. package/dist/llm/browser-use/chat.js +305 -0
  144. package/dist/llm/browser-use/index.d.ts +1 -0
  145. package/dist/llm/browser-use/index.js +1 -0
  146. package/dist/llm/cerebras/chat.d.ts +39 -0
  147. package/dist/llm/cerebras/chat.js +178 -0
  148. package/dist/llm/cerebras/index.d.ts +2 -0
  149. package/dist/llm/cerebras/index.js +2 -0
  150. package/dist/llm/cerebras/serializer.d.ts +7 -0
  151. package/dist/llm/cerebras/serializer.js +82 -0
  152. package/dist/llm/deepseek/chat.d.ts +19 -2
  153. package/dist/llm/deepseek/chat.js +138 -25
  154. package/dist/llm/google/chat.d.ts +46 -2
  155. package/dist/llm/google/chat.js +267 -64
  156. package/dist/llm/google/serializer.d.ts +9 -1
  157. package/dist/llm/google/serializer.js +141 -34
  158. package/dist/llm/groq/chat.d.ts +21 -2
  159. package/dist/llm/groq/chat.js +125 -26
  160. package/dist/llm/groq/parser.js +3 -1
  161. package/dist/llm/mistral/chat.d.ts +43 -0
  162. package/dist/llm/mistral/chat.js +154 -0
  163. package/dist/llm/mistral/index.d.ts +2 -0
  164. package/dist/llm/mistral/index.js +2 -0
  165. package/dist/llm/mistral/schema.d.ts +8 -0
  166. package/dist/llm/mistral/schema.js +27 -0
  167. package/dist/llm/models.d.ts +2 -0
  168. package/dist/llm/models.js +317 -0
  169. package/dist/llm/ollama/chat.d.ts +13 -1
  170. package/dist/llm/ollama/chat.js +110 -19
  171. package/dist/llm/ollama/serializer.d.ts +1 -0
  172. package/dist/llm/ollama/serializer.js +34 -12
  173. package/dist/llm/openai/chat.d.ts +16 -0
  174. package/dist/llm/openai/chat.js +94 -44
  175. package/dist/llm/openai/like.d.ts +5 -3
  176. package/dist/llm/openai/like.js +7 -3
  177. package/dist/llm/openai/responses-serializer.d.ts +18 -0
  178. package/dist/llm/openai/responses-serializer.js +72 -0
  179. package/dist/llm/openrouter/chat.d.ts +28 -2
  180. package/dist/llm/openrouter/chat.js +115 -29
  181. package/dist/llm/schema.d.ts +11 -1
  182. package/dist/llm/schema.js +109 -4
  183. package/dist/llm/vercel/chat.d.ts +50 -0
  184. package/dist/llm/vercel/chat.js +276 -0
  185. package/dist/llm/vercel/index.d.ts +1 -0
  186. package/dist/llm/vercel/index.js +1 -0
  187. package/dist/llm/vercel/serializer.d.ts +5 -0
  188. package/dist/llm/vercel/serializer.js +7 -0
  189. package/dist/llm/views.d.ts +2 -1
  190. package/dist/llm/views.js +3 -1
  191. package/dist/logging-config.d.ts +2 -0
  192. package/dist/logging-config.js +82 -29
  193. package/dist/mcp/client.d.ts +10 -5
  194. package/dist/mcp/client.js +14 -9
  195. package/dist/mcp/controller.d.ts +42 -3
  196. package/dist/mcp/controller.js +56 -31
  197. package/dist/mcp/server.d.ts +15 -0
  198. package/dist/mcp/server.js +261 -52
  199. package/dist/observability.js +10 -4
  200. package/dist/sandbox/index.d.ts +2 -0
  201. package/dist/sandbox/index.js +2 -0
  202. package/dist/sandbox/sandbox.d.ts +19 -0
  203. package/dist/sandbox/sandbox.js +140 -0
  204. package/dist/sandbox/views.d.ts +67 -0
  205. package/dist/sandbox/views.js +121 -0
  206. package/dist/skill-cli/index.d.ts +3 -0
  207. package/dist/skill-cli/index.js +3 -0
  208. package/dist/skill-cli/protocol.d.ts +30 -0
  209. package/dist/skill-cli/protocol.js +48 -0
  210. package/dist/skill-cli/server.d.ts +11 -0
  211. package/dist/skill-cli/server.js +85 -0
  212. package/dist/skill-cli/sessions.d.ts +24 -0
  213. package/dist/skill-cli/sessions.js +47 -0
  214. package/dist/skills/index.d.ts +3 -0
  215. package/dist/skills/index.js +3 -0
  216. package/dist/skills/service.d.ts +27 -0
  217. package/dist/skills/service.js +266 -0
  218. package/dist/skills/utils.d.ts +6 -0
  219. package/dist/skills/utils.js +53 -0
  220. package/dist/skills/views.d.ts +40 -0
  221. package/dist/skills/views.js +10 -0
  222. package/dist/sync/auth.js +8 -3
  223. package/dist/sync/service.d.ts +6 -6
  224. package/dist/sync/service.js +54 -89
  225. package/dist/telemetry/views.d.ts +20 -6
  226. package/dist/telemetry/views.js +23 -5
  227. package/dist/tokens/custom-pricing.d.ts +2 -0
  228. package/dist/tokens/custom-pricing.js +22 -0
  229. package/dist/tokens/index.d.ts +2 -0
  230. package/dist/tokens/index.js +2 -0
  231. package/dist/tokens/mappings.d.ts +1 -0
  232. package/dist/tokens/mappings.js +3 -0
  233. package/dist/tokens/service.js +27 -8
  234. package/dist/tools/extraction/index.d.ts +2 -0
  235. package/dist/tools/extraction/index.js +2 -0
  236. package/dist/tools/extraction/schema-utils.d.ts +6 -0
  237. package/dist/tools/extraction/schema-utils.js +237 -0
  238. package/dist/tools/extraction/views.d.ts +7 -0
  239. package/dist/tools/index.d.ts +5 -0
  240. package/dist/tools/index.js +5 -0
  241. package/dist/tools/registry/index.d.ts +2 -0
  242. package/dist/tools/registry/index.js +2 -0
  243. package/dist/tools/registry/service.d.ts +1 -0
  244. package/dist/tools/registry/service.js +1 -0
  245. package/dist/tools/registry/views.d.ts +1 -0
  246. package/dist/tools/registry/views.js +1 -0
  247. package/dist/tools/service.d.ts +2 -0
  248. package/dist/tools/service.js +1 -0
  249. package/dist/tools/utils.d.ts +2 -0
  250. package/dist/tools/utils.js +57 -0
  251. package/dist/tools/views.d.ts +1 -0
  252. package/dist/tools/views.js +1 -0
  253. package/dist/utils.d.ts +10 -1
  254. package/dist/utils.js +70 -3
  255. package/package.json +116 -49
  256. package/dist/dom/playground/process-dom.js +0 -5
  257. package/dist/dom/playground/test-accessibility.d.ts +0 -44
  258. package/dist/dom/playground/test-accessibility.js +0 -111
  259. /package/dist/{dom/playground/process-dom.d.ts → tools/extraction/views.js} +0 -0
@@ -0,0 +1,12 @@
1
+ import type { AgentHistoryList, DetectedVariable } from './views.js';
2
+ import type { DOMHistoryElement } from '../dom/history-tree-processor/view.js';
3
+ export declare const detect_variables_in_history: (history: AgentHistoryList | {
4
+ history: any[];
5
+ }) => Record<string, DetectedVariable>;
6
+ export declare const substitute_in_dict: (data: Record<string, unknown>, replacements: Record<string, string>) => number;
7
+ export declare const _private_for_tests: {
8
+ detectFromAttributes: (attributes: Record<string, string>) => [string, string | null] | null;
9
+ detectFromValuePattern: (value: string) => [string, string | null] | null;
10
+ detectVariableType: (value: string, element: DOMHistoryElement | null) => [string, string | null] | null;
11
+ ensureUniqueName: (baseName: string, existing: Record<string, DetectedVariable>) => string;
12
+ };
@@ -0,0 +1,211 @@
1
+ import { DetectedVariable as DetectedVariableModel } from './views.js';
2
+ const ACTION_FIELDS_TO_CHECK = ['text', 'query'];
3
+ const getActionPayload = (action) => {
4
+ if (action && typeof action.model_dump === 'function') {
5
+ return action.model_dump();
6
+ }
7
+ if (action && typeof action === 'object' && !Array.isArray(action)) {
8
+ return action;
9
+ }
10
+ return {};
11
+ };
12
+ const ensureUniqueName = (baseName, existing) => {
13
+ if (!(baseName in existing)) {
14
+ return baseName;
15
+ }
16
+ let counter = 2;
17
+ while (`${baseName}_${counter}` in existing) {
18
+ counter += 1;
19
+ }
20
+ return `${baseName}_${counter}`;
21
+ };
22
+ const detectFromAttributes = (attributes) => {
23
+ const inputType = String(attributes.type ?? '').toLowerCase();
24
+ if (inputType === 'email')
25
+ return ['email', 'email'];
26
+ if (inputType === 'tel')
27
+ return ['phone', 'phone'];
28
+ if (inputType === 'date')
29
+ return ['date', 'date'];
30
+ if (inputType === 'number')
31
+ return ['number', 'number'];
32
+ if (inputType === 'url')
33
+ return ['url', 'url'];
34
+ const semanticFields = [
35
+ attributes.id ?? '',
36
+ attributes.name ?? '',
37
+ attributes.placeholder ?? '',
38
+ attributes['aria-label'] ?? '',
39
+ ];
40
+ const combined = semanticFields.join(' ').toLowerCase();
41
+ if (['address', 'street', 'addr'].some((needle) => combined.includes(needle))) {
42
+ if (combined.includes('billing'))
43
+ return ['billing_address', null];
44
+ if (combined.includes('shipping'))
45
+ return ['shipping_address', null];
46
+ return ['address', null];
47
+ }
48
+ if (['comment', 'note', 'message', 'description'].some((needle) => combined.includes(needle))) {
49
+ return ['comment', null];
50
+ }
51
+ if (combined.includes('email') || combined.includes('e-mail')) {
52
+ return ['email', 'email'];
53
+ }
54
+ if (['phone', 'tel', 'mobile', 'cell'].some((needle) => combined.includes(needle))) {
55
+ return ['phone', 'phone'];
56
+ }
57
+ if (combined.includes('first') && combined.includes('name')) {
58
+ return ['first_name', null];
59
+ }
60
+ if (combined.includes('last') && combined.includes('name')) {
61
+ return ['last_name', null];
62
+ }
63
+ if (combined.includes('full') && combined.includes('name')) {
64
+ return ['full_name', null];
65
+ }
66
+ if (combined.includes('name')) {
67
+ return ['name', null];
68
+ }
69
+ if (['date', 'dob', 'birth'].some((needle) => combined.includes(needle))) {
70
+ return ['date', 'date'];
71
+ }
72
+ if (combined.includes('city'))
73
+ return ['city', null];
74
+ if (combined.includes('state') || combined.includes('province')) {
75
+ return ['state', null];
76
+ }
77
+ if (combined.includes('country'))
78
+ return ['country', null];
79
+ if (['zip', 'postal', 'postcode'].some((needle) => combined.includes(needle))) {
80
+ return ['zip_code', 'postal_code'];
81
+ }
82
+ if (combined.includes('company') || combined.includes('organization')) {
83
+ return ['company', null];
84
+ }
85
+ return null;
86
+ };
87
+ const detectFromValuePattern = (value) => {
88
+ if (/^[\w.-]+@[\w.-]+\.\w+$/.test(value)) {
89
+ return ['email', 'email'];
90
+ }
91
+ if (/^[\d\s\-()+]+$/.test(value)) {
92
+ const digitsOnly = value.replace(/[\s\-()+]/g, '');
93
+ if (digitsOnly.length >= 10) {
94
+ return ['phone', 'phone'];
95
+ }
96
+ }
97
+ if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
98
+ return ['date', 'date'];
99
+ }
100
+ const stripped = value.replace(/[\s-]/g, '');
101
+ if (value.length >= 2 &&
102
+ value.length <= 30 &&
103
+ value[0] === value[0].toUpperCase() &&
104
+ /^[A-Za-z]+$/.test(stripped)) {
105
+ const words = value.trim().split(/\s+/);
106
+ if (words.length === 1)
107
+ return ['first_name', null];
108
+ if (words.length === 2)
109
+ return ['full_name', null];
110
+ return ['name', null];
111
+ }
112
+ if (/^\d{1,9}$/.test(value)) {
113
+ return ['number', 'number'];
114
+ }
115
+ return null;
116
+ };
117
+ const detectVariableType = (value, element) => {
118
+ const attrs = element?.attributes;
119
+ if (attrs && typeof attrs === 'object') {
120
+ const normalizedAttrs = Object.fromEntries(Object.entries(attrs).map(([key, attrValue]) => [key, String(attrValue)]));
121
+ const attrMatch = detectFromAttributes(normalizedAttrs);
122
+ if (attrMatch) {
123
+ return attrMatch;
124
+ }
125
+ }
126
+ return detectFromValuePattern(value);
127
+ };
128
+ const detectInAction = (actionPayload, element, detected, detectedValues) => {
129
+ for (const params of Object.values(actionPayload)) {
130
+ if (!params || typeof params !== 'object' || Array.isArray(params)) {
131
+ continue;
132
+ }
133
+ for (const field of ACTION_FIELDS_TO_CHECK) {
134
+ const value = params[field];
135
+ if (typeof value !== 'string' || !value.trim()) {
136
+ continue;
137
+ }
138
+ if (detectedValues.has(value)) {
139
+ continue;
140
+ }
141
+ const variableInfo = detectVariableType(value, element);
142
+ if (!variableInfo) {
143
+ continue;
144
+ }
145
+ const [baseName, format] = variableInfo;
146
+ const uniqueName = ensureUniqueName(baseName, detected);
147
+ detected[uniqueName] = new DetectedVariableModel(uniqueName, value, 'string', format);
148
+ detectedValues.add(value);
149
+ }
150
+ }
151
+ };
152
+ export const detect_variables_in_history = (history) => {
153
+ const detected = {};
154
+ const detectedValues = new Set();
155
+ const historyItems = Array.isArray(history?.history)
156
+ ? history.history
157
+ : [];
158
+ for (const historyItem of historyItems) {
159
+ const actions = historyItem?.model_output?.action;
160
+ if (!Array.isArray(actions)) {
161
+ continue;
162
+ }
163
+ const interactedElements = Array.isArray(historyItem?.state?.interacted_element)
164
+ ? historyItem.state.interacted_element
165
+ : [];
166
+ for (let actionIndex = 0; actionIndex < actions.length; actionIndex += 1) {
167
+ const actionPayload = getActionPayload(actions[actionIndex]);
168
+ const element = interactedElements[actionIndex] ?? null;
169
+ detectInAction(actionPayload, element, detected, detectedValues);
170
+ }
171
+ }
172
+ return detected;
173
+ };
174
+ export const substitute_in_dict = (data, replacements) => {
175
+ let count = 0;
176
+ for (const [key, value] of Object.entries(data)) {
177
+ if (typeof value === 'string') {
178
+ if (value in replacements) {
179
+ data[key] = replacements[value];
180
+ count += 1;
181
+ }
182
+ continue;
183
+ }
184
+ if (value && typeof value === 'object' && !Array.isArray(value)) {
185
+ count += substitute_in_dict(value, replacements);
186
+ continue;
187
+ }
188
+ if (Array.isArray(value)) {
189
+ for (let index = 0; index < value.length; index += 1) {
190
+ const item = value[index];
191
+ if (typeof item === 'string') {
192
+ if (item in replacements) {
193
+ value[index] = replacements[item];
194
+ count += 1;
195
+ }
196
+ continue;
197
+ }
198
+ if (item && typeof item === 'object' && !Array.isArray(item)) {
199
+ count += substitute_in_dict(item, replacements);
200
+ }
201
+ }
202
+ }
203
+ }
204
+ return count;
205
+ };
206
+ export const _private_for_tests = {
207
+ detectFromAttributes,
208
+ detectFromValuePattern,
209
+ detectVariableType,
210
+ ensureUniqueName,
211
+ };