unbrowse 3.1.0 → 3.2.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 (107) hide show
  1. package/dist/cli.js +455 -96
  2. package/dist/index.js +2 -6
  3. package/dist/mcp.js +695 -46
  4. package/dist/server.js +25811 -0
  5. package/package.json +1 -2
  6. package/vendor/kuri/darwin-arm64/kuri +0 -0
  7. package/vendor/kuri/darwin-x64/kuri +0 -0
  8. package/vendor/kuri/linux-arm64/kuri +0 -0
  9. package/vendor/kuri/linux-x64/kuri +0 -0
  10. package/vendor/kuri/manifest.json +7 -10
  11. package/runtime-src/agent-outcome.ts +0 -166
  12. package/runtime-src/analytics-session.ts +0 -55
  13. package/runtime-src/api/browse-index.ts +0 -317
  14. package/runtime-src/api/browse-session.ts +0 -572
  15. package/runtime-src/api/browse-submit-prereqs.ts +0 -48
  16. package/runtime-src/api/browse-submit.ts +0 -1184
  17. package/runtime-src/api/routes.ts +0 -1823
  18. package/runtime-src/auth/browser-cookies.ts +0 -423
  19. package/runtime-src/auth/index.ts +0 -535
  20. package/runtime-src/auth/runtime.ts +0 -116
  21. package/runtime-src/browser/index.ts +0 -659
  22. package/runtime-src/browser/types.ts +0 -41
  23. package/runtime-src/build-info.generated.ts +0 -6
  24. package/runtime-src/capture/index.ts +0 -1794
  25. package/runtime-src/capture/prefetch.ts +0 -95
  26. package/runtime-src/capture/rsc.ts +0 -45
  27. package/runtime-src/cli/shortcuts.ts +0 -273
  28. package/runtime-src/cli.ts +0 -1572
  29. package/runtime-src/client/graph-client.ts +0 -100
  30. package/runtime-src/client/index.ts +0 -1425
  31. package/runtime-src/debug-trace.ts +0 -18
  32. package/runtime-src/domain.ts +0 -38
  33. package/runtime-src/execution/index.ts +0 -3397
  34. package/runtime-src/execution/retry.ts +0 -46
  35. package/runtime-src/execution/robots.ts +0 -167
  36. package/runtime-src/execution/search-forms.ts +0 -188
  37. package/runtime-src/extraction/index.ts +0 -1507
  38. package/runtime-src/foundry/publish-bundle.ts +0 -392
  39. package/runtime-src/graph/agent-augment.ts +0 -315
  40. package/runtime-src/graph/index.ts +0 -1524
  41. package/runtime-src/graph/local-fixtures.ts +0 -393
  42. package/runtime-src/graph/local-harness.ts +0 -646
  43. package/runtime-src/graph/planner.ts +0 -411
  44. package/runtime-src/graph/session.ts +0 -294
  45. package/runtime-src/graph/trace-store.ts +0 -136
  46. package/runtime-src/index.ts +0 -24
  47. package/runtime-src/indexer/index.ts +0 -465
  48. package/runtime-src/intent-match.ts +0 -1515
  49. package/runtime-src/kuri/client.ts +0 -1839
  50. package/runtime-src/logger.ts +0 -30
  51. package/runtime-src/marketplace/index.ts +0 -103
  52. package/runtime-src/mcp.ts +0 -1747
  53. package/runtime-src/orchestrator/browser-agent.ts +0 -374
  54. package/runtime-src/orchestrator/dag-advisor.ts +0 -59
  55. package/runtime-src/orchestrator/dag-feedback.ts +0 -257
  56. package/runtime-src/orchestrator/first-pass-action.ts +0 -403
  57. package/runtime-src/orchestrator/index.ts +0 -4480
  58. package/runtime-src/orchestrator/passive-publish.ts +0 -187
  59. package/runtime-src/orchestrator/timing-economics.ts +0 -80
  60. package/runtime-src/payments/cascade.ts +0 -137
  61. package/runtime-src/payments/index.ts +0 -270
  62. package/runtime-src/payments/lobster-pay.ts +0 -182
  63. package/runtime-src/payments/wallet.ts +0 -98
  64. package/runtime-src/publish/review-context.ts +0 -93
  65. package/runtime-src/publish/sanitize.ts +0 -197
  66. package/runtime-src/publish/schema-review.ts +0 -192
  67. package/runtime-src/publish-admission.ts +0 -388
  68. package/runtime-src/ratelimit/index.ts +0 -23
  69. package/runtime-src/reverse-engineer/bundle-scanner.ts +0 -127
  70. package/runtime-src/reverse-engineer/description-prompt.ts +0 -213
  71. package/runtime-src/reverse-engineer/index.ts +0 -1551
  72. package/runtime-src/router.ts +0 -17
  73. package/runtime-src/routing-telemetry.ts +0 -395
  74. package/runtime-src/runtime/browser-access.ts +0 -11
  75. package/runtime-src/runtime/browser-auth.ts +0 -12
  76. package/runtime-src/runtime/browser-host.ts +0 -48
  77. package/runtime-src/runtime/lifecycle.ts +0 -17
  78. package/runtime-src/runtime/local-server.ts +0 -311
  79. package/runtime-src/runtime/paths.ts +0 -99
  80. package/runtime-src/runtime/setup.ts +0 -251
  81. package/runtime-src/runtime/supervisor.ts +0 -69
  82. package/runtime-src/runtime/update-hints.ts +0 -351
  83. package/runtime-src/server.ts +0 -100
  84. package/runtime-src/session-logs.ts +0 -142
  85. package/runtime-src/settings.ts +0 -221
  86. package/runtime-src/single-binary.ts +0 -143
  87. package/runtime-src/site-policy.ts +0 -54
  88. package/runtime-src/stale-cleanup-runner.ts +0 -144
  89. package/runtime-src/stale-cleanup.ts +0 -133
  90. package/runtime-src/telemetry-attribution.ts +0 -120
  91. package/runtime-src/telemetry.ts +0 -253
  92. package/runtime-src/template-params.ts +0 -141
  93. package/runtime-src/transform/drift.ts +0 -60
  94. package/runtime-src/transform/index.ts +0 -277
  95. package/runtime-src/types/index.ts +0 -1
  96. package/runtime-src/types/skill.ts +0 -912
  97. package/runtime-src/vault/index.ts +0 -196
  98. package/runtime-src/verification/auth-gate.ts +0 -8
  99. package/runtime-src/verification/candidates.ts +0 -27
  100. package/runtime-src/verification/index.ts +0 -120
  101. package/runtime-src/verification/matrix.ts +0 -30
  102. package/runtime-src/version.ts +0 -148
  103. package/runtime-src/workflow/artifact.ts +0 -161
  104. package/runtime-src/workflow/compile.ts +0 -808
  105. package/runtime-src/workflow/publish.ts +0 -225
  106. package/runtime-src/workflow/runtime.ts +0 -213
  107. package/vendor/kuri/win-x64/kuri.exe +0 -0
@@ -1,17 +0,0 @@
1
- import type { EndpointDescriptor } from "./types/index.js";
2
-
3
- export const UNSAFE_ACTION_BLOCK_THRESHOLD = 0.6;
4
-
5
- export function computeUnsafeActionScore(endpoint: EndpointDescriptor): number {
6
- let score = 0;
7
- if (endpoint.idempotency === "unsafe") score += 0.4;
8
- if (endpoint.method === "POST" || endpoint.method === "PUT" || endpoint.method === "DELETE") score += 0.2;
9
- const inferredFromBundle = /inferred from js bundle/i.test(endpoint.description ?? "");
10
- if (inferredFromBundle) score += 0.2;
11
- if (!endpoint.response_schema) score += 0.1;
12
- if (endpoint.verification_status === "failed") score += 0.1;
13
- if (endpoint.reliability_score < 0.3) score += 0.1;
14
- if (endpoint.trigger_url) score -= 0.1;
15
- if (endpoint.verification_status === "verified") score -= 0.15;
16
- return Math.max(0, Math.min(1, score));
17
- }
@@ -1,395 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import { nanoid } from "nanoid";
3
- import type {
4
- ExecutionOptions,
5
- ProjectionOptions,
6
- RoutingCandidateEvent,
7
- RoutingCandidateSnapshot,
8
- RoutingContextBuckets,
9
- RoutingSessionCompletedEvent,
10
- RoutingSessionEvent,
11
- RoutingSessionOutcome,
12
- RoutingStepEvent,
13
- RoutingTelemetryEvent,
14
- RoutingTelemetrySource,
15
- RoutingRunType,
16
- SkillManifest,
17
- } from "./types/index.js";
18
- import { anonymizeUrl, classifyFailure, hashResponseBody, hashValue } from "./telemetry.js";
19
-
20
- const BLOCKED_KEY_PATTERN =
21
- /(cookie|token|auth|secret|password|session|bearer|credential|apikey|response_body|request_body|transcript|email)/i;
22
-
23
- type StateBindings = Record<string, unknown>;
24
-
25
- function stableHash(value: unknown): string {
26
- return createHash("sha256").update(JSON.stringify(value)).digest("hex").slice(0, 24);
27
- }
28
-
29
- function sanitizeScalar(value: unknown): string | number | boolean | null {
30
- if (value == null) return null;
31
- if (typeof value === "string") return hashValue(value);
32
- if (typeof value === "number" || typeof value === "boolean") return value;
33
- return stableHash(value);
34
- }
35
-
36
- function sanitizeObject(input: Record<string, unknown>): Record<string, string | number | boolean | null> {
37
- const out: Record<string, string | number | boolean | null> = {};
38
- for (const [key, value] of Object.entries(input)) {
39
- if (BLOCKED_KEY_PATTERN.test(key)) continue;
40
- out[key] = sanitizeScalar(value);
41
- }
42
- return out;
43
- }
44
-
45
- export function hashRoutingState(bindings: StateBindings = {}): string {
46
- const safeEntries = Object.entries(bindings)
47
- .filter(([key]) => !BLOCKED_KEY_PATTERN.test(key))
48
- .sort(([a], [b]) => a.localeCompare(b))
49
- .map(([key, value]) => [key, sanitizeScalar(value)]);
50
- return stableHash(safeEntries);
51
- }
52
-
53
- export function hashSchemaFingerprint(schema: unknown): string | undefined {
54
- if (!schema || typeof schema !== "object") return undefined;
55
- return stableHash(schema);
56
- }
57
-
58
- export function buildRoutingContextBuckets(
59
- intent: string,
60
- projection?: ProjectionOptions,
61
- options?: ExecutionOptions,
62
- hasPriorHistory = false,
63
- ): RoutingContextBuckets {
64
- const lower = intent.toLowerCase();
65
- const role = /\b(code|repo|pull request|issue|commit|package)\b/.test(lower)
66
- ? "developer"
67
- : /\b(research|paper|literature|study)\b/.test(lower)
68
- ? "researcher"
69
- : /\b(price|stock|trade|portfolio|market)\b/.test(lower)
70
- ? "analyst"
71
- : "general";
72
- const outputPreference = projection?.raw
73
- ? "raw"
74
- : projection?.fields?.length
75
- ? "structured"
76
- : "mixed";
77
- return {
78
- role,
79
- cost_sensitivity: options?.force_capture ? "low" : "medium",
80
- latency_sensitivity: options?.force_capture ? "low" : "high",
81
- output_preference: outputPreference,
82
- task_horizon: /\b(workflow|sequence|multi|then|after|before|across)\b/.test(lower) ? "long" : "short",
83
- has_prior_history: hasPriorHistory,
84
- };
85
- }
86
-
87
- function normalizeDomain(value?: string): string | null {
88
- if (!value) return null;
89
- try {
90
- return new URL(value).hostname.toLowerCase();
91
- } catch {
92
- return value.toLowerCase();
93
- }
94
- }
95
-
96
- function routingSourceFromOrchestratorSource(
97
- source: "marketplace" | "live-capture" | "dom-fallback" | "route-cache" | "browser-action" | "first-pass",
98
- ): RoutingTelemetrySource {
99
- if (source === "dom-fallback") return "live-capture";
100
- if (source === "first-pass") return "browser-action";
101
- return source;
102
- }
103
-
104
- function routeFingerprint(endpoint: Pick<SkillManifest["endpoints"][number], "method" | "url_template">): string {
105
- return stableHash(`${endpoint.method}:${anonymizeUrl(endpoint.url_template)}`);
106
- }
107
-
108
- function operationIdForEndpoint(skill: SkillManifest | undefined, endpointId?: string): string | undefined {
109
- if (!skill?.operation_graph || !endpointId) return undefined;
110
- return skill.operation_graph.operations.find((operation) => operation.endpoint_id === endpointId)?.operation_id;
111
- }
112
-
113
- type CollectorOptions = {
114
- sessionId: string;
115
- startedAt: string;
116
- intent: string;
117
- traceVersion?: string;
118
- anonymizedAgentId?: string;
119
- runType: RoutingRunType;
120
- contextBuckets: RoutingContextBuckets;
121
- normalizedDomains?: string[];
122
- };
123
-
124
- type CandidateRankArgs = {
125
- stepIndex?: number;
126
- source: RoutingTelemetrySource;
127
- stateHashBefore: string;
128
- candidateCount: number;
129
- reachableOperationCount?: number;
130
- availableBindingCount?: number;
131
- missingBindingCount?: number;
132
- selectedEndpointId?: string;
133
- selectedOperationId?: string;
134
- candidates: RoutingCandidateSnapshot[];
135
- };
136
-
137
- type StepArgs = {
138
- stepIndex?: number;
139
- source: RoutingTelemetrySource;
140
- stateHashBefore: string;
141
- stateHashAfter: string;
142
- selectedSkillId?: string;
143
- selectedEndpointId?: string;
144
- selectedOperationId?: string;
145
- reachableOperationCount?: number;
146
- availableBindingCount?: number;
147
- missingBindingCount?: number;
148
- candidateCount: number;
149
- executionLatencyMs?: number;
150
- statusCode?: number;
151
- success?: boolean;
152
- failureReason?: string;
153
- schemaFingerprint?: string;
154
- responseHash?: string;
155
- crossDomainTransition?: boolean;
156
- retryCount?: number;
157
- userOverride?: boolean;
158
- didStepUnlockNextStep?: boolean;
159
- requiredRecovery?: boolean;
160
- };
161
-
162
- export function buildRoutingCandidateSnapshots(
163
- skill: SkillManifest,
164
- ranked: Array<{ endpoint: SkillManifest["endpoints"][number]; score: number }>,
165
- options?: {
166
- reachableEndpointIds?: Set<string>;
167
- selectedEndpointId?: string;
168
- rejectionReasons?: Record<string, string | undefined>;
169
- },
170
- ): RoutingCandidateSnapshot[] {
171
- return ranked.map((candidate, index) => ({
172
- candidate_id: nanoid(),
173
- rank: index + 1,
174
- skill_id: skill.skill_id,
175
- endpoint_id: candidate.endpoint.endpoint_id,
176
- operation_id: operationIdForEndpoint(skill, candidate.endpoint.endpoint_id),
177
- route_fingerprint: routeFingerprint(candidate.endpoint),
178
- score: Math.round(candidate.score * 1000) / 1000,
179
- chosen: candidate.endpoint.endpoint_id === options?.selectedEndpointId,
180
- reachable: options?.reachableEndpointIds
181
- ? options.reachableEndpointIds.has(candidate.endpoint.endpoint_id)
182
- : true,
183
- rejection_reason: options?.rejectionReasons?.[candidate.endpoint.endpoint_id],
184
- feature_snapshot: {
185
- method: candidate.endpoint.method,
186
- has_response_schema: !!candidate.endpoint.response_schema,
187
- dom_extraction: !!candidate.endpoint.dom_extraction,
188
- verification_status: candidate.endpoint.verification_status,
189
- reliability_score: candidate.endpoint.reliability_score,
190
- unsafe_action_score: candidate.endpoint.idempotency === "unsafe" ? 1 : 0,
191
- },
192
- }));
193
- }
194
-
195
- export function createRoutingTelemetryCollector(options: CollectorOptions) {
196
- const events: RoutingTelemetryEvent[] = [];
197
- const normalizedDomains = new Set(options.normalizedDomains?.filter(Boolean) ?? []);
198
- let stepIndex = 0;
199
- let completed = false;
200
-
201
- const sessionStarted: RoutingSessionEvent = {
202
- event_id: nanoid(),
203
- event_type: "routing_session_started",
204
- session_id: options.sessionId,
205
- created_at: options.startedAt,
206
- trace_version: options.traceVersion,
207
- anonymized_agent_id: options.anonymizedAgentId,
208
- top_level_intent: options.intent,
209
- normalized_domains: [...normalizedDomains],
210
- run_type: options.runType,
211
- context_buckets: options.contextBuckets,
212
- };
213
- events.push(sessionStarted);
214
-
215
- function syncDomains() {
216
- sessionStarted.normalized_domains = [...normalizedDomains];
217
- }
218
-
219
- function nextStep(explicit?: number): number {
220
- if (explicit && explicit > stepIndex) stepIndex = explicit;
221
- else if (!explicit) stepIndex += 1;
222
- return explicit ?? stepIndex;
223
- }
224
-
225
- return {
226
- sessionId: options.sessionId,
227
- addDomain(value?: string) {
228
- const domain = normalizeDomain(value);
229
- if (!domain) return;
230
- normalizedDomains.add(domain);
231
- syncDomains();
232
- },
233
- recordCandidates(args: CandidateRankArgs): number {
234
- const index = nextStep(args.stepIndex);
235
- const event: RoutingCandidateEvent = {
236
- event_id: nanoid(),
237
- event_type: "routing_candidates_ranked",
238
- session_id: options.sessionId,
239
- created_at: new Date().toISOString(),
240
- trace_version: options.traceVersion,
241
- anonymized_agent_id: options.anonymizedAgentId,
242
- top_level_intent: options.intent,
243
- normalized_domains: [...normalizedDomains],
244
- run_type: options.runType,
245
- step_id: `${options.sessionId}:${index}`,
246
- step_index: index,
247
- source: args.source,
248
- state_hash_before: args.stateHashBefore,
249
- candidate_count: args.candidateCount,
250
- reachable_operation_count: args.reachableOperationCount,
251
- available_binding_count: args.availableBindingCount,
252
- missing_binding_count: args.missingBindingCount,
253
- selected_endpoint_id: args.selectedEndpointId,
254
- selected_operation_id: args.selectedOperationId,
255
- candidates: args.candidates,
256
- };
257
- events.push(event);
258
- return index;
259
- },
260
- recordStep(args: StepArgs): number {
261
- const index = nextStep(args.stepIndex);
262
- const event: RoutingStepEvent = {
263
- event_id: nanoid(),
264
- event_type: "routing_step_executed",
265
- session_id: options.sessionId,
266
- created_at: new Date().toISOString(),
267
- trace_version: options.traceVersion,
268
- anonymized_agent_id: options.anonymizedAgentId,
269
- top_level_intent: options.intent,
270
- normalized_domains: [...normalizedDomains],
271
- run_type: options.runType,
272
- step_id: `${options.sessionId}:${index}`,
273
- step_index: index,
274
- source: args.source,
275
- state_hash_before: args.stateHashBefore,
276
- state_hash_after: args.stateHashAfter,
277
- selected_skill_id: args.selectedSkillId,
278
- selected_endpoint_id: args.selectedEndpointId,
279
- selected_operation_id: args.selectedOperationId,
280
- reachable_operation_count: args.reachableOperationCount,
281
- available_binding_count: args.availableBindingCount,
282
- missing_binding_count: args.missingBindingCount,
283
- candidate_count: args.candidateCount,
284
- execution_latency_ms: args.executionLatencyMs,
285
- status_code: args.statusCode,
286
- success: args.success,
287
- failure_reason: args.failureReason,
288
- schema_fingerprint: args.schemaFingerprint,
289
- response_hash: args.responseHash,
290
- cross_domain_transition: args.crossDomainTransition ?? false,
291
- retry_count: args.retryCount ?? 0,
292
- user_override: args.userOverride ?? false,
293
- did_step_unlock_next_step: args.didStepUnlockNextStep ?? false,
294
- required_recovery: args.requiredRecovery ?? false,
295
- };
296
- events.push(event);
297
- return index;
298
- },
299
- complete(args: {
300
- outcome: RoutingSessionOutcome;
301
- completedAt: string;
302
- totalApiCalls: number;
303
- retryCount: number;
304
- userOverride: boolean;
305
- requiredRecovery: boolean;
306
- }) {
307
- if (completed) return;
308
- completed = true;
309
- const rankedEvents = events.filter((event) => event.event_type === "routing_candidates_ranked");
310
- const stepEvents = events.filter((event) => event.event_type === "routing_step_executed");
311
- const completedEvent: RoutingSessionCompletedEvent = {
312
- event_id: nanoid(),
313
- event_type: "routing_session_completed",
314
- session_id: options.sessionId,
315
- created_at: args.completedAt,
316
- completed_at: args.completedAt,
317
- trace_version: options.traceVersion,
318
- anonymized_agent_id: options.anonymizedAgentId,
319
- top_level_intent: options.intent,
320
- normalized_domains: [...normalizedDomains],
321
- run_type: options.runType,
322
- final_outcome: args.outcome,
323
- final_success: args.outcome === "success",
324
- total_steps: stepEvents.length,
325
- total_candidates_ranked: rankedEvents.reduce((sum, event) => sum + event.candidate_count, 0),
326
- total_api_calls: args.totalApiCalls,
327
- retry_count: args.retryCount,
328
- user_override: args.userOverride,
329
- required_recovery: args.requiredRecovery,
330
- };
331
- events.push(completedEvent);
332
- },
333
- toBatch(): RoutingTelemetryEvent[] {
334
- return events.map((event) => ({
335
- ...event,
336
- normalized_domains: [...normalizedDomains],
337
- }));
338
- },
339
- };
340
- }
341
-
342
- export function sanitizeRoutingEventBatch(events: RoutingTelemetryEvent[]): RoutingTelemetryEvent[] {
343
- return events.map((event) => {
344
- if (event.event_type === "routing_session_started") {
345
- return {
346
- ...event,
347
- top_level_intent: event.top_level_intent.trim(),
348
- };
349
- }
350
- if (event.event_type === "routing_candidates_ranked") {
351
- return {
352
- ...event,
353
- candidates: event.candidates.map((candidate) => ({
354
- ...candidate,
355
- rejection_reason: candidate.rejection_reason?.slice(0, 120),
356
- feature_snapshot: sanitizeObject(candidate.feature_snapshot) as RoutingCandidateSnapshot["feature_snapshot"],
357
- })),
358
- };
359
- }
360
- if (event.event_type === "routing_step_executed") {
361
- return {
362
- ...event,
363
- failure_reason: event.failure_reason ? classifyFailure(event.failure_reason) : undefined,
364
- };
365
- }
366
- return event;
367
- });
368
- }
369
-
370
- export function deriveRoutingStepArtifacts(args: {
371
- result: unknown;
372
- skill?: SkillManifest;
373
- selectedEndpointId?: string;
374
- source: "marketplace" | "live-capture" | "dom-fallback" | "route-cache" | "browser-action" | "first-pass";
375
- bindingsBefore?: StateBindings;
376
- bindingsAfter?: StateBindings;
377
- }): {
378
- source: RoutingTelemetrySource;
379
- stateHashBefore: string;
380
- stateHashAfter: string;
381
- responseHash?: string;
382
- schemaFingerprint?: string;
383
- selectedOperationId?: string;
384
- } {
385
- return {
386
- source: routingSourceFromOrchestratorSource(args.source),
387
- stateHashBefore: hashRoutingState(args.bindingsBefore),
388
- stateHashAfter: hashRoutingState(args.bindingsAfter ?? args.bindingsBefore),
389
- responseHash: args.result != null ? hashResponseBody(args.result) : undefined,
390
- schemaFingerprint: hashSchemaFingerprint(
391
- args.skill?.endpoints.find((endpoint) => endpoint.endpoint_id === args.selectedEndpointId)?.response_schema,
392
- ),
393
- selectedOperationId: operationIdForEndpoint(args.skill, args.selectedEndpointId),
394
- };
395
- }
@@ -1,11 +0,0 @@
1
- export interface BrowserAccessConfig {
2
- default_path: "unbrowse" | "direct" | "proxy";
3
- fallback_path: "direct" | "proxy";
4
- supported_frameworks: string[];
5
- }
6
-
7
- export const DEFAULT_BROWSER_ACCESS: BrowserAccessConfig = {
8
- default_path: "unbrowse",
9
- fallback_path: "direct",
10
- supported_frameworks: ["openclaw", "mcp", "langchain", "hermes", "elizaos"],
11
- };
@@ -1,12 +0,0 @@
1
- function isFalseyEnv(value: string | undefined): boolean {
2
- if (!value) return false;
3
- const normalized = value.trim().toLowerCase();
4
- return normalized === "0" || normalized === "false" || normalized === "no" || normalized === "off";
5
- }
6
-
7
- /**
8
- * Default on for auth-gated browsing; explicit opt-out for clean-room E2E runs.
9
- */
10
- export function shouldImportBrowserCookies(): boolean {
11
- return !isFalseyEnv(process.env.UNBROWSE_IMPORT_BROWSER_COOKIES);
12
- }
@@ -1,48 +0,0 @@
1
- export type HostEnvironment = "openclaw" | "openai" | "native" | "mcp" | "unknown";
2
-
3
- export interface BrowserPathConfig {
4
- binary_path?: string;
5
- cdp_port?: number;
6
- headless: boolean;
7
- user_data_dir?: string;
8
- }
9
-
10
- /** Detect the host environment from environment variables */
11
- export function detectHostEnvironment(): HostEnvironment {
12
- if (process.env.OPENCLAW_RUNTIME) return "openclaw";
13
- if (process.env.OPENAI_TOOL_RUNTIME) return "openai";
14
- if (process.env.MCP_SERVER_MODE) return "mcp";
15
- if (process.env.UNBROWSE_NATIVE) return "native";
16
- return "unknown";
17
- }
18
-
19
- /** Get browser configuration appropriate for the detected host */
20
- export function getBrowserConfig(env?: HostEnvironment): BrowserPathConfig {
21
- const detected = env ?? detectHostEnvironment();
22
- switch (detected) {
23
- case "openclaw":
24
- return {
25
- binary_path: process.env.OPENCLAW_BROWSER_PATH ?? "/usr/bin/chromium",
26
- headless: true,
27
- user_data_dir: process.env.OPENCLAW_USER_DATA ?? "/tmp/openclaw-chrome",
28
- };
29
- case "openai":
30
- return {
31
- binary_path: process.env.OPENAI_BROWSER_PATH,
32
- headless: true,
33
- cdp_port: parseInt(process.env.OPENAI_CDP_PORT ?? "9222"),
34
- };
35
- case "mcp":
36
- return {
37
- headless: true,
38
- cdp_port: parseInt(process.env.CDP_PORT ?? "0"),
39
- };
40
- case "native":
41
- return {
42
- headless: false,
43
- user_data_dir: process.env.UNBROWSE_USER_DATA,
44
- };
45
- default:
46
- return { headless: false };
47
- }
48
- }
@@ -1,17 +0,0 @@
1
- export type LifecyclePhase = "discover" | "capture" | "resolve" | "execute" | "publish";
2
-
3
- export interface LifecycleEvent {
4
- phase: LifecyclePhase;
5
- skill_id: string;
6
- timestamp: string;
7
- duration_ms: number;
8
- source: "cache" | "marketplace" | "live-capture";
9
- }
10
-
11
- export function attributeLifecycle(events: LifecycleEvent[]): Map<LifecyclePhase, number> {
12
- const totals = new Map<LifecyclePhase, number>();
13
- for (const e of events) {
14
- totals.set(e.phase, (totals.get(e.phase) ?? 0) + e.duration_ms);
15
- }
16
- return totals;
17
- }