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,277 +0,0 @@
1
- import type { ProjectionOptions, ResponseSchema } from "../types/index.js";
2
-
3
- // --- Entity Index (for normalized/decorator-pattern APIs) ---
4
-
5
- /**
6
- * Build a lookup map from entityUrn → object for APIs that use
7
- * normalized entity references (LinkedIn Voyager, Facebook Graph, etc.).
8
- * Objects reference each other via "*fieldName" keys whose values are URNs.
9
- */
10
- export function buildEntityIndex(items: unknown[]): Map<string, unknown> {
11
- const index = new Map<string, unknown>();
12
- for (const item of items) {
13
- if (item != null && typeof item === "object") {
14
- const urn = (item as Record<string, unknown>).entityUrn;
15
- if (typeof urn === "string") index.set(urn, item);
16
- }
17
- }
18
- return index;
19
- }
20
-
21
- /**
22
- * Auto-detect and build an entity index from a response that contains
23
- * an entityUrn-keyed array (e.g. `included[]`, `data.included[]`).
24
- * Returns null if no suitable array is found.
25
- */
26
- export function detectEntityIndex(data: unknown): Map<string, unknown> | null {
27
- if (data == null || typeof data !== "object") return null;
28
-
29
- // Check common locations for normalized entity arrays
30
- const candidates: unknown[] = [];
31
- const obj = data as Record<string, unknown>;
32
-
33
- // Direct: { included: [...] }
34
- if (Array.isArray(obj.included)) candidates.push(obj.included);
35
- // Nested: { data: { included: [...] } }
36
- if (obj.data && typeof obj.data === "object") {
37
- const d = obj.data as Record<string, unknown>;
38
- if (Array.isArray(d.included)) candidates.push(d.included);
39
- }
40
-
41
- // Check if any candidate has entityUrn-keyed objects
42
- for (const arr of candidates) {
43
- const items = arr as unknown[];
44
- if (items.length < 2) continue;
45
- // Sample first few items to check for entityUrn
46
- const sample = items.slice(0, 5);
47
- const hasUrns = sample.filter(
48
- (i) => i != null && typeof i === "object" && typeof (i as Record<string, unknown>).entityUrn === "string"
49
- ).length;
50
- if (hasUrns >= sample.length * 0.5) {
51
- return buildEntityIndex(items);
52
- }
53
- }
54
- return null;
55
- }
56
-
57
- // --- Field Projection ---
58
-
59
- /**
60
- * Walk a dot-notation path with [] array expansion.
61
- * e.g. "elements[].actor.name" expands across array items.
62
- */
63
- export function resolvePath(obj: unknown, path: string, entityIndex?: Map<string, unknown>): unknown[] {
64
- const parts = path.split(".");
65
- let current: unknown[] = [obj];
66
-
67
- for (const part of parts) {
68
- const next: unknown[] = [];
69
- const isArray = part.endsWith("[]");
70
- const key = isArray ? part.slice(0, -2) : part;
71
-
72
- for (const item of current) {
73
- if (item == null || typeof item !== "object") continue;
74
- const rec = item as Record<string, unknown>;
75
- let val = rec[key];
76
-
77
- // URN reference resolution: if direct lookup fails, check for "*key" reference
78
- if (val === undefined && entityIndex) {
79
- const ref = rec[`*${key}`];
80
- if (typeof ref === "string") {
81
- val = entityIndex.get(ref);
82
- }
83
- }
84
-
85
- if (val === undefined) continue;
86
- if (isArray && Array.isArray(val)) {
87
- next.push(...val);
88
- } else {
89
- next.push(val);
90
- }
91
- }
92
- current = next;
93
- }
94
- return current;
95
- }
96
-
97
- /**
98
- * Select only specified fields, rebuilding nested structure.
99
- */
100
- export function project(data: unknown, fields: string[]): unknown {
101
- if (data == null) return data;
102
- if (Array.isArray(data)) return data.map((item) => project(item, fields));
103
-
104
- const result: Record<string, unknown> = {};
105
- for (const field of fields) {
106
- const resolved = resolvePath(data, field);
107
- if (resolved.length === 0) continue;
108
- setNestedValue(result, field, resolved.length === 1 ? resolved[0] : resolved);
109
- }
110
- return result;
111
- }
112
-
113
- function setNestedValue(obj: Record<string, unknown>, path: string, value: unknown): void {
114
- const parts = path.split(".").map((p) => (p.endsWith("[]") ? p.slice(0, -2) : p));
115
- let current: Record<string, unknown> = obj;
116
- for (let i = 0; i < parts.length - 1; i++) {
117
- if (!(parts[i] in current) || typeof current[parts[i]] !== "object") {
118
- current[parts[i]] = {};
119
- }
120
- current = current[parts[i]] as Record<string, unknown>;
121
- }
122
- current[parts[parts.length - 1]] = value;
123
- }
124
-
125
- /**
126
- * Strip nulls, empty strings, empty arrays, and ephemeral keys.
127
- */
128
- const EPHEMERAL_KEYS = new Set(["trackingId", "$type", "recipeType"]);
129
- const EPHEMERAL_SUFFIXES = ["Urn"];
130
-
131
- function isEphemeral(key: string): boolean {
132
- if (EPHEMERAL_KEYS.has(key)) return true;
133
- return EPHEMERAL_SUFFIXES.some((s) => key.endsWith(s));
134
- }
135
-
136
- export function compact(data: unknown, _opts?: { max_depth?: number }): unknown {
137
- if (data == null) return undefined;
138
- if (Array.isArray(data)) {
139
- const filtered = data.map((item) => compact(item, _opts)).filter((v) => v !== undefined);
140
- return filtered.length > 0 ? filtered : undefined;
141
- }
142
- if (typeof data === "object") {
143
- const result: Record<string, unknown> = {};
144
- for (const [key, val] of Object.entries(data as Record<string, unknown>)) {
145
- if (isEphemeral(key)) continue;
146
- const compacted = compact(val, _opts);
147
- if (compacted !== undefined) result[key] = compacted;
148
- }
149
- return Object.keys(result).length > 0 ? result : undefined;
150
- }
151
- if (typeof data === "string" && data === "") return undefined;
152
- return data;
153
- }
154
-
155
- function truncateDepth(data: unknown, maxDepth: number, currentDepth = 0): unknown {
156
- if (currentDepth >= maxDepth) return typeof data === "object" && data !== null ? "[truncated]" : data;
157
- if (Array.isArray(data)) return data.map((item) => truncateDepth(item, maxDepth, currentDepth + 1));
158
- if (typeof data === "object" && data !== null) {
159
- const result: Record<string, unknown> = {};
160
- for (const [key, val] of Object.entries(data as Record<string, unknown>)) {
161
- result[key] = truncateDepth(val, maxDepth, currentDepth + 1);
162
- }
163
- return result;
164
- }
165
- return data;
166
- }
167
-
168
- /**
169
- * Orchestrate project + compact + max_depth truncation.
170
- */
171
- export function applyProjection(data: unknown, projection: ProjectionOptions): unknown {
172
- let result = data;
173
- if (projection.fields && projection.fields.length > 0) {
174
- result = project(result, projection.fields);
175
- }
176
- if (projection.compact) {
177
- result = compact(result);
178
- }
179
- if (projection.max_depth != null) {
180
- result = truncateDepth(result, projection.max_depth);
181
- }
182
- return result;
183
- }
184
-
185
- // --- Schema Inference ---
186
-
187
- function typeOf(value: unknown): string {
188
- if (value === null) return "null";
189
- if (Array.isArray(value)) return "array";
190
- if (typeof value === "number") return Number.isInteger(value) ? "integer" : "number";
191
- return typeof value; // string, boolean, object
192
- }
193
-
194
- function inferSingle(value: unknown): ResponseSchema {
195
- const t = typeOf(value);
196
- if (t === "null") return { type: "null", inferred_from_samples: 1 };
197
- if (t === "array") {
198
- const arr = value as unknown[];
199
- if (arr.length === 0) return { type: "array", inferred_from_samples: 1 };
200
- const itemSchemas = arr.map(inferSingle);
201
- return { type: "array", items: mergeSchemas(itemSchemas), inferred_from_samples: 1 };
202
- }
203
- if (t === "object") {
204
- const obj = value as Record<string, unknown>;
205
- const properties: Record<string, ResponseSchema> = {};
206
- for (const [key, val] of Object.entries(obj)) {
207
- properties[key] = inferSingle(val);
208
- }
209
- return {
210
- type: "object",
211
- properties,
212
- required: Object.keys(obj),
213
- inferred_from_samples: 1,
214
- };
215
- }
216
- return { type: t, inferred_from_samples: 1 };
217
- }
218
-
219
- function mergeSchemas(schemas: ResponseSchema[]): ResponseSchema {
220
- if (schemas.length === 0) return { type: "object", inferred_from_samples: 0 };
221
- if (schemas.length === 1) return schemas[0];
222
-
223
- const types = new Set(schemas.map((s) => s.type));
224
- if (types.size === 1 && types.has("object")) {
225
- return mergeObjectSchemas(schemas);
226
- }
227
- if (types.size === 1 && types.has("array")) {
228
- const itemSchemas = schemas.filter((s) => s.items).map((s) => s.items!);
229
- return {
230
- type: "array",
231
- items: itemSchemas.length > 0 ? mergeSchemas(itemSchemas) : undefined,
232
- inferred_from_samples: schemas.length,
233
- };
234
- }
235
- if (types.size === 1) {
236
- return { type: schemas[0].type, inferred_from_samples: schemas.length };
237
- }
238
- // Union type
239
- const unique = [...types].map((t) => ({ type: t, inferred_from_samples: schemas.length }));
240
- return { type: unique[0].type, anyOf: unique, inferred_from_samples: schemas.length };
241
- }
242
-
243
- function mergeObjectSchemas(schemas: ResponseSchema[]): ResponseSchema {
244
- const allKeys = new Set<string>();
245
- for (const s of schemas) {
246
- if (s.properties) Object.keys(s.properties).forEach((k) => allKeys.add(k));
247
- }
248
- const properties: Record<string, ResponseSchema> = {};
249
- const required: string[] = [];
250
-
251
- for (const key of allKeys) {
252
- const propSchemas = schemas
253
- .filter((s) => s.properties?.[key])
254
- .map((s) => s.properties![key]);
255
- properties[key] = mergeSchemas(propSchemas);
256
- // Required only if present in ALL samples
257
- if (propSchemas.length === schemas.length) required.push(key);
258
- }
259
-
260
- return {
261
- type: "object",
262
- properties,
263
- required: required.length > 0 ? required : undefined,
264
- inferred_from_samples: schemas.length,
265
- };
266
- }
267
-
268
- /**
269
- * Infer JSON Schema draft-07 subset from 1+ response samples.
270
- */
271
- export function inferSchema(samples: unknown[]): ResponseSchema {
272
- if (samples.length === 0) return { type: "object", inferred_from_samples: 0 };
273
- const schemas = samples.map(inferSingle);
274
- const merged = mergeSchemas(schemas);
275
- merged.inferred_from_samples = samples.length;
276
- return merged;
277
- }
@@ -1 +0,0 @@
1
- export * from "./skill.js";