unbrowse 3.1.0-experiments.995f8bb → 3.1.0-experiments.9cbcb13

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 (105) hide show
  1. package/dist/cli.js +79 -33
  2. package/dist/index.js +2 -6
  3. package/dist/mcp.js +73 -22
  4. package/dist/server.js +25994 -0
  5. package/package.json +1 -2
  6. package/vendor/kuri/manifest.json +1 -1
  7. package/runtime-src/agent-outcome.ts +0 -166
  8. package/runtime-src/analytics-session.ts +0 -55
  9. package/runtime-src/api/browse-index.ts +0 -343
  10. package/runtime-src/api/browse-session.ts +0 -572
  11. package/runtime-src/api/browse-submit-prereqs.ts +0 -48
  12. package/runtime-src/api/browse-submit.ts +0 -1184
  13. package/runtime-src/api/routes.ts +0 -1833
  14. package/runtime-src/auth/browser-cookies.ts +0 -423
  15. package/runtime-src/auth/index.ts +0 -535
  16. package/runtime-src/auth/runtime.ts +0 -116
  17. package/runtime-src/browser/index.ts +0 -659
  18. package/runtime-src/browser/types.ts +0 -41
  19. package/runtime-src/build-info.generated.ts +0 -6
  20. package/runtime-src/capture/index.ts +0 -1929
  21. package/runtime-src/capture/prefetch.ts +0 -95
  22. package/runtime-src/capture/rsc.ts +0 -45
  23. package/runtime-src/cli/shortcuts.ts +0 -273
  24. package/runtime-src/cli.ts +0 -1734
  25. package/runtime-src/client/graph-client.ts +0 -100
  26. package/runtime-src/client/index.ts +0 -1425
  27. package/runtime-src/debug-trace.ts +0 -18
  28. package/runtime-src/domain.ts +0 -38
  29. package/runtime-src/execution/index.ts +0 -3407
  30. package/runtime-src/execution/retry.ts +0 -46
  31. package/runtime-src/execution/robots.ts +0 -167
  32. package/runtime-src/execution/search-forms.ts +0 -188
  33. package/runtime-src/execution/token-resolver.ts +0 -135
  34. package/runtime-src/extraction/index.ts +0 -1507
  35. package/runtime-src/foundry/publish-bundle.ts +0 -392
  36. package/runtime-src/graph/agent-augment.ts +0 -315
  37. package/runtime-src/graph/index.ts +0 -1532
  38. package/runtime-src/graph/local-fixtures.ts +0 -393
  39. package/runtime-src/graph/local-harness.ts +0 -646
  40. package/runtime-src/graph/planner.ts +0 -411
  41. package/runtime-src/graph/session.ts +0 -294
  42. package/runtime-src/graph/trace-store.ts +0 -136
  43. package/runtime-src/impact-log.ts +0 -227
  44. package/runtime-src/index.ts +0 -24
  45. package/runtime-src/indexer/index.ts +0 -465
  46. package/runtime-src/intent-match.ts +0 -1515
  47. package/runtime-src/kuri/client.ts +0 -1839
  48. package/runtime-src/logger.ts +0 -30
  49. package/runtime-src/marketplace/index.ts +0 -111
  50. package/runtime-src/mcp.ts +0 -1911
  51. package/runtime-src/orchestrator/browser-agent.ts +0 -374
  52. package/runtime-src/orchestrator/dag-advisor.ts +0 -59
  53. package/runtime-src/orchestrator/dag-feedback.ts +0 -257
  54. package/runtime-src/orchestrator/first-pass-action.ts +0 -403
  55. package/runtime-src/orchestrator/index.ts +0 -4480
  56. package/runtime-src/orchestrator/passive-publish.ts +0 -187
  57. package/runtime-src/orchestrator/timing-economics.ts +0 -80
  58. package/runtime-src/payments/cascade.ts +0 -137
  59. package/runtime-src/payments/index.ts +0 -270
  60. package/runtime-src/payments/lobster-pay.ts +0 -182
  61. package/runtime-src/payments/wallet.ts +0 -98
  62. package/runtime-src/publish/review-context.ts +0 -93
  63. package/runtime-src/publish/sanitize.ts +0 -197
  64. package/runtime-src/publish/schema-review.ts +0 -192
  65. package/runtime-src/publish-admission.ts +0 -388
  66. package/runtime-src/ratelimit/index.ts +0 -23
  67. package/runtime-src/reverse-engineer/bundle-scanner.ts +0 -127
  68. package/runtime-src/reverse-engineer/description-prompt.ts +0 -213
  69. package/runtime-src/reverse-engineer/index.ts +0 -1551
  70. package/runtime-src/reverse-engineer/token-sources.ts +0 -379
  71. package/runtime-src/router.ts +0 -17
  72. package/runtime-src/routing-telemetry.ts +0 -395
  73. package/runtime-src/runtime/browser-access.ts +0 -11
  74. package/runtime-src/runtime/browser-auth.ts +0 -12
  75. package/runtime-src/runtime/browser-host.ts +0 -48
  76. package/runtime-src/runtime/lifecycle.ts +0 -17
  77. package/runtime-src/runtime/local-server.ts +0 -311
  78. package/runtime-src/runtime/paths.ts +0 -99
  79. package/runtime-src/runtime/setup.ts +0 -251
  80. package/runtime-src/runtime/supervisor.ts +0 -69
  81. package/runtime-src/runtime/update-hints.ts +0 -351
  82. package/runtime-src/server.ts +0 -100
  83. package/runtime-src/session-logs.ts +0 -142
  84. package/runtime-src/settings.ts +0 -221
  85. package/runtime-src/single-binary.ts +0 -143
  86. package/runtime-src/site-policy.ts +0 -54
  87. package/runtime-src/stale-cleanup-runner.ts +0 -144
  88. package/runtime-src/stale-cleanup.ts +0 -133
  89. package/runtime-src/telemetry-attribution.ts +0 -120
  90. package/runtime-src/telemetry.ts +0 -253
  91. package/runtime-src/template-params.ts +0 -141
  92. package/runtime-src/transform/drift.ts +0 -60
  93. package/runtime-src/transform/index.ts +0 -277
  94. package/runtime-src/types/index.ts +0 -1
  95. package/runtime-src/types/skill.ts +0 -931
  96. package/runtime-src/vault/index.ts +0 -196
  97. package/runtime-src/verification/auth-gate.ts +0 -8
  98. package/runtime-src/verification/candidates.ts +0 -27
  99. package/runtime-src/verification/index.ts +0 -120
  100. package/runtime-src/verification/matrix.ts +0 -30
  101. package/runtime-src/version.ts +0 -148
  102. package/runtime-src/workflow/artifact.ts +0 -161
  103. package/runtime-src/workflow/compile.ts +0 -808
  104. package/runtime-src/workflow/publish.ts +0 -225
  105. package/runtime-src/workflow/runtime.ts +0 -213
@@ -1,95 +0,0 @@
1
- /**
2
- * Graph-based prefetch for the resolve path.
3
- *
4
- * After resolving an endpoint, traverse parent_child edges to find related
5
- * GET endpoints and prefetch them so the agent gets list + detail in one call.
6
- */
7
- import type { SkillManifest, SkillOperationGraph, SkillOperationNode, SkillOperationEdge } from "../types/index.js";
8
- import { getOperationPrefetchTargets } from "../graph/index.js";
9
- import { executeSkill } from "../execution/index.js";
10
-
11
- export const PREFETCH_MAX = 3;
12
- export const PREFETCH_TIMEOUT_MS = 2000;
13
-
14
- export interface PrefetchTarget {
15
- operation: SkillOperationNode;
16
- edge: SkillOperationEdge;
17
- reason: string;
18
- }
19
-
20
- export interface PrefetchResult {
21
- operation_id: string;
22
- endpoint_id: string;
23
- method: string;
24
- action_kind: string;
25
- resource_kind: string;
26
- description_out?: string;
27
- data: unknown;
28
- success: boolean;
29
- duration_ms: number;
30
- }
31
-
32
- /**
33
- * Find operations worth prefetching given a resolved operation.
34
- * Traverses outgoing parent_child edges. Only returns GET endpoints
35
- * whose bindings are satisfiable.
36
- */
37
- export function getPrefetchTargets(
38
- graph: SkillOperationGraph,
39
- resolvedOperationId: string,
40
- knownBindings: Record<string, unknown>,
41
- ): PrefetchTarget[] {
42
- return getOperationPrefetchTargets(graph, resolvedOperationId, knownBindings, PREFETCH_MAX);
43
- }
44
-
45
- /**
46
- * Execute prefetch targets in parallel with timeout. Failures are non-fatal.
47
- */
48
- export async function executePrefetch(
49
- skill: SkillManifest,
50
- targets: PrefetchTarget[],
51
- baseParams: Record<string, unknown>,
52
- ): Promise<PrefetchResult[]> {
53
- if (targets.length === 0) return [];
54
-
55
- const results = await Promise.allSettled(
56
- targets.map(async (target): Promise<PrefetchResult> => {
57
- const t0 = Date.now();
58
- try {
59
- const execResult = await Promise.race([
60
- executeSkill(skill, { ...baseParams, endpoint_id: target.operation.endpoint_id }),
61
- new Promise<never>((_, reject) => setTimeout(() => reject(new Error("prefetch_timeout")), PREFETCH_TIMEOUT_MS)),
62
- ]);
63
- return {
64
- operation_id: target.operation.operation_id,
65
- endpoint_id: target.operation.endpoint_id,
66
- method: target.operation.method,
67
- action_kind: target.operation.action_kind,
68
- resource_kind: target.operation.resource_kind,
69
- description_out: target.operation.description_out,
70
- data: execResult.result,
71
- success: execResult.trace.success ?? false,
72
- duration_ms: Date.now() - t0,
73
- };
74
- } catch {
75
- return {
76
- operation_id: target.operation.operation_id,
77
- endpoint_id: target.operation.endpoint_id,
78
- method: target.operation.method,
79
- action_kind: target.operation.action_kind,
80
- resource_kind: target.operation.resource_kind,
81
- description_out: target.operation.description_out,
82
- data: null,
83
- success: false,
84
- duration_ms: Date.now() - t0,
85
- };
86
- }
87
- }),
88
- );
89
-
90
- return results.map(r => r.status === "fulfilled" ? r.value : {
91
- operation_id: "unknown", endpoint_id: "unknown", method: "GET",
92
- action_kind: "unknown", resource_kind: "unknown",
93
- data: null, success: false, duration_ms: 0,
94
- });
95
- }
@@ -1,45 +0,0 @@
1
- /**
2
- * React Server Components wire format detection and parsing.
3
- * RSC payloads use newline-delimited format: "0:[\"$\",\"div\",null,{}]"
4
- */
5
-
6
- /** Detect if a response body is an RSC wire format payload */
7
- export function isRscPayload(body: string): boolean {
8
- if (!body || body.length < 3) return false;
9
- const lines = body.split("\n").filter((l) => l.trim().length > 0);
10
- if (lines.length === 0) return false;
11
- const rscLines = lines.filter((l) => /^\d+:/.test(l));
12
- return rscLines.length / lines.length >= 0.5;
13
- }
14
-
15
- /** Parse RSC wire format into individual chunks */
16
- export function parseRscPayload(
17
- body: string,
18
- ): Array<{ id: string; data: unknown }> {
19
- const results: Array<{ id: string; data: unknown }> = [];
20
- const lines = body.split("\n").filter((l) => l.trim().length > 0);
21
- for (const line of lines) {
22
- const colonIdx = line.indexOf(":");
23
- if (colonIdx <= 0) continue;
24
- const id = line.slice(0, colonIdx);
25
- if (!/^\d+$/.test(id)) continue;
26
- const rest = line.slice(colonIdx + 1);
27
- try {
28
- results.push({ id, data: JSON.parse(rest) });
29
- } catch {
30
- results.push({ id, data: rest });
31
- }
32
- }
33
- return results;
34
- }
35
-
36
- /** Extract URLs embedded in RSC payload for endpoint discovery */
37
- export function extractRscDataEndpoints(body: string): string[] {
38
- const urls: string[] = [];
39
- const urlPattern = /https?:\/\/[^\s"'\\)]+/g;
40
- let match;
41
- while ((match = urlPattern.exec(body)) !== null) {
42
- urls.push(match[0]);
43
- }
44
- return [...new Set(urls)];
45
- }
@@ -1,273 +0,0 @@
1
- /**
2
- * Domain/task shortcut registry.
3
- *
4
- * Each site pack defines:
5
- * - aliases for CLI matching
6
- * - canonical domain and login URL
7
- * - task matchers with intent, URL, and dependency metadata
8
- *
9
- * The shortcut system compiles `unbrowse <site> <task>` into the existing
10
- * resolve/login API without requiring backend changes.
11
- */
12
-
13
- export interface TaskDef {
14
- /** User-facing task names (first is canonical) */
15
- match: string[];
16
- /** What this task does — maps to resolve --intent */
17
- intent: string;
18
- /** Target URL for the task */
19
- url: string;
20
- /** Tasks/states that must complete before this one */
21
- requires: string[];
22
- /** Tasks that become available after this one succeeds */
23
- enables: string[];
24
- /** Tasks safe to run concurrently with this one (post-dependencies) */
25
- parallel_with: string[];
26
- /** Whether this task is safe to run concurrently (default true for reads) */
27
- parallel_safe: boolean;
28
- /** Whether this task needs authentication */
29
- needs_auth: boolean;
30
- /** Short description for help output */
31
- description: string;
32
- }
33
-
34
- export interface SitePack {
35
- /** Primary site name */
36
- site: string;
37
- /** Alternative names */
38
- aliases: string[];
39
- /** Canonical domain */
40
- domain: string;
41
- /** Login URL for auth flow */
42
- login_url: string;
43
- /** Available tasks */
44
- tasks: TaskDef[];
45
- /** Short site description */
46
- description: string;
47
- }
48
-
49
- // ---------------------------------------------------------------------------
50
- // Site packs
51
- // ---------------------------------------------------------------------------
52
-
53
- const linkedin: SitePack = {
54
- site: "linkedin",
55
- aliases: ["linkedin", "li"],
56
- domain: "www.linkedin.com",
57
- login_url: "https://www.linkedin.com/login",
58
- description: "LinkedIn — professional network",
59
- tasks: [
60
- {
61
- match: ["login"],
62
- intent: "login",
63
- url: "https://www.linkedin.com/login",
64
- requires: [],
65
- enables: ["feed", "notifications", "messages"],
66
- parallel_with: [],
67
- parallel_safe: false,
68
- needs_auth: false,
69
- description: "Authenticate with LinkedIn",
70
- },
71
- {
72
- match: ["feed"],
73
- intent: "get feed posts",
74
- url: "https://www.linkedin.com/feed/",
75
- requires: ["login"],
76
- enables: [],
77
- parallel_with: ["notifications", "messages"],
78
- parallel_safe: true,
79
- needs_auth: true,
80
- description: "Fetch your LinkedIn feed",
81
- },
82
- {
83
- match: ["notifications", "notifs"],
84
- intent: "get notifications",
85
- url: "https://www.linkedin.com/notifications/",
86
- requires: ["login"],
87
- enables: [],
88
- parallel_with: ["feed", "messages"],
89
- parallel_safe: true,
90
- needs_auth: true,
91
- description: "Fetch your notifications",
92
- },
93
- {
94
- match: ["messages", "msgs"],
95
- intent: "get messages",
96
- url: "https://www.linkedin.com/messaging/",
97
- requires: ["login"],
98
- enables: [],
99
- parallel_with: ["feed", "notifications"],
100
- parallel_safe: true,
101
- needs_auth: true,
102
- description: "Fetch your messages",
103
- },
104
- ],
105
- };
106
-
107
- const github: SitePack = {
108
- site: "github",
109
- aliases: ["github", "gh"],
110
- domain: "github.com",
111
- login_url: "https://github.com/login",
112
- description: "GitHub — code hosting",
113
- tasks: [
114
- {
115
- match: ["login"],
116
- intent: "login",
117
- url: "https://github.com/login",
118
- requires: [],
119
- enables: ["trending", "notifications", "repos"],
120
- parallel_with: [],
121
- parallel_safe: false,
122
- needs_auth: false,
123
- description: "Authenticate with GitHub",
124
- },
125
- {
126
- match: ["trending"],
127
- intent: "get trending repositories",
128
- url: "https://github.com/trending",
129
- requires: [],
130
- enables: [],
131
- parallel_with: ["notifications", "repos"],
132
- parallel_safe: true,
133
- needs_auth: false,
134
- description: "Fetch trending repositories (no auth needed)",
135
- },
136
- {
137
- match: ["notifications", "notifs"],
138
- intent: "get notifications",
139
- url: "https://github.com/notifications",
140
- requires: ["login"],
141
- enables: [],
142
- parallel_with: ["trending", "repos"],
143
- parallel_safe: true,
144
- needs_auth: true,
145
- description: "Fetch your notifications",
146
- },
147
- {
148
- match: ["repos"],
149
- intent: "get repositories",
150
- url: "https://github.com",
151
- requires: ["login"],
152
- enables: [],
153
- parallel_with: ["trending", "notifications"],
154
- parallel_safe: true,
155
- needs_auth: true,
156
- description: "Fetch your repositories",
157
- },
158
- ],
159
- };
160
-
161
- // ---------------------------------------------------------------------------
162
- // Registry
163
- // ---------------------------------------------------------------------------
164
-
165
- const SITE_PACKS: SitePack[] = [linkedin, github];
166
-
167
- /** Look up a site pack by name or alias. */
168
- export function findSitePack(name: string): SitePack | undefined {
169
- const lower = name.toLowerCase();
170
- return SITE_PACKS.find((p) => p.aliases.includes(lower));
171
- }
172
-
173
- /** Look up a task within a site pack. */
174
- export function findTask(pack: SitePack, taskName: string): TaskDef | undefined {
175
- const lower = taskName.toLowerCase();
176
- return pack.tasks.find((t) => t.match.includes(lower));
177
- }
178
-
179
- /** Get all registered site packs. */
180
- export function allSitePacks(): readonly SitePack[] {
181
- return SITE_PACKS;
182
- }
183
-
184
- // ---------------------------------------------------------------------------
185
- // Dependency graph helpers
186
- // ---------------------------------------------------------------------------
187
-
188
- /** Build dependency graph for a site's tasks. */
189
- export function buildDepsGraph(pack: SitePack): Record<string, { requires: string[]; enables: string[]; parallel_with: string[] }> {
190
- const graph: Record<string, { requires: string[]; enables: string[]; parallel_with: string[] }> = {};
191
- for (const task of pack.tasks) {
192
- graph[task.match[0]] = {
193
- requires: task.requires,
194
- enables: task.enables,
195
- parallel_with: task.parallel_with,
196
- };
197
- }
198
- return graph;
199
- }
200
-
201
- /** Generate an execution plan (waves) for a set of tasks. */
202
- export function planExecution(pack: SitePack, taskNames: string[]): { wave: number; commands: string[]; reason: string }[] {
203
- const waves: { wave: number; commands: string[]; reason: string }[] = [];
204
- const resolved = new Set<string>();
205
- const remaining = new Set(taskNames.map((n) => n.toLowerCase()));
206
-
207
- // Collect all prerequisites
208
- const allPrereqs = new Set<string>();
209
- for (const name of remaining) {
210
- const task = findTask(pack, name);
211
- if (task) {
212
- for (const req of task.requires) {
213
- if (!remaining.has(req)) allPrereqs.add(req);
214
- }
215
- }
216
- }
217
-
218
- // Wave 0: prerequisites not in the requested set
219
- if (allPrereqs.size > 0) {
220
- waves.push({
221
- wave: 1,
222
- commands: [...allPrereqs].map((t) => `unbrowse ${pack.site} ${t}`),
223
- reason: "prerequisite",
224
- });
225
- for (const p of allPrereqs) resolved.add(p);
226
- }
227
-
228
- // Wave N: group remaining tasks by whether all deps are resolved
229
- let waveNum = waves.length + 1;
230
- while (remaining.size > 0) {
231
- const ready: string[] = [];
232
- for (const name of remaining) {
233
- const task = findTask(pack, name);
234
- if (!task) { remaining.delete(name); continue; }
235
- const depsOk = task.requires.every((r) => resolved.has(r));
236
- if (depsOk) ready.push(name);
237
- }
238
- if (ready.length === 0) {
239
- // Circular or unresolvable — push everything remaining
240
- waves.push({
241
- wave: waveNum,
242
- commands: [...remaining].map((t) => `unbrowse ${pack.site} ${t}`),
243
- reason: "unresolvable dependencies",
244
- });
245
- break;
246
- }
247
- waves.push({
248
- wave: waveNum,
249
- commands: ready.map((t) => `unbrowse ${pack.site} ${t}`),
250
- reason: ready.length > 1 ? "independent after prerequisites" : "sequential",
251
- });
252
- for (const r of ready) { resolved.add(r); remaining.delete(r); }
253
- waveNum++;
254
- }
255
-
256
- return waves;
257
- }
258
-
259
- /** Build _deps metadata for a command's JSON output. */
260
- export function buildDepsMetadata(pack: SitePack, taskName: string): {
261
- requires: string[];
262
- enables: string[];
263
- parallel_safe: boolean;
264
- session_id?: string;
265
- } {
266
- const task = findTask(pack, taskName);
267
- if (!task) return { requires: [], enables: [], parallel_safe: true };
268
- return {
269
- requires: task.requires,
270
- enables: task.enables,
271
- parallel_safe: task.parallel_safe,
272
- };
273
- }