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.
- package/dist/cli.js +79 -33
- package/dist/index.js +2 -6
- package/dist/mcp.js +73 -22
- package/dist/server.js +25994 -0
- package/package.json +1 -2
- package/vendor/kuri/manifest.json +1 -1
- package/runtime-src/agent-outcome.ts +0 -166
- package/runtime-src/analytics-session.ts +0 -55
- package/runtime-src/api/browse-index.ts +0 -343
- package/runtime-src/api/browse-session.ts +0 -572
- package/runtime-src/api/browse-submit-prereqs.ts +0 -48
- package/runtime-src/api/browse-submit.ts +0 -1184
- package/runtime-src/api/routes.ts +0 -1833
- package/runtime-src/auth/browser-cookies.ts +0 -423
- package/runtime-src/auth/index.ts +0 -535
- package/runtime-src/auth/runtime.ts +0 -116
- package/runtime-src/browser/index.ts +0 -659
- package/runtime-src/browser/types.ts +0 -41
- package/runtime-src/build-info.generated.ts +0 -6
- package/runtime-src/capture/index.ts +0 -1929
- package/runtime-src/capture/prefetch.ts +0 -95
- package/runtime-src/capture/rsc.ts +0 -45
- package/runtime-src/cli/shortcuts.ts +0 -273
- package/runtime-src/cli.ts +0 -1734
- package/runtime-src/client/graph-client.ts +0 -100
- package/runtime-src/client/index.ts +0 -1425
- package/runtime-src/debug-trace.ts +0 -18
- package/runtime-src/domain.ts +0 -38
- package/runtime-src/execution/index.ts +0 -3407
- package/runtime-src/execution/retry.ts +0 -46
- package/runtime-src/execution/robots.ts +0 -167
- package/runtime-src/execution/search-forms.ts +0 -188
- package/runtime-src/execution/token-resolver.ts +0 -135
- package/runtime-src/extraction/index.ts +0 -1507
- package/runtime-src/foundry/publish-bundle.ts +0 -392
- package/runtime-src/graph/agent-augment.ts +0 -315
- package/runtime-src/graph/index.ts +0 -1532
- package/runtime-src/graph/local-fixtures.ts +0 -393
- package/runtime-src/graph/local-harness.ts +0 -646
- package/runtime-src/graph/planner.ts +0 -411
- package/runtime-src/graph/session.ts +0 -294
- package/runtime-src/graph/trace-store.ts +0 -136
- package/runtime-src/impact-log.ts +0 -227
- package/runtime-src/index.ts +0 -24
- package/runtime-src/indexer/index.ts +0 -465
- package/runtime-src/intent-match.ts +0 -1515
- package/runtime-src/kuri/client.ts +0 -1839
- package/runtime-src/logger.ts +0 -30
- package/runtime-src/marketplace/index.ts +0 -111
- package/runtime-src/mcp.ts +0 -1911
- package/runtime-src/orchestrator/browser-agent.ts +0 -374
- package/runtime-src/orchestrator/dag-advisor.ts +0 -59
- package/runtime-src/orchestrator/dag-feedback.ts +0 -257
- package/runtime-src/orchestrator/first-pass-action.ts +0 -403
- package/runtime-src/orchestrator/index.ts +0 -4480
- package/runtime-src/orchestrator/passive-publish.ts +0 -187
- package/runtime-src/orchestrator/timing-economics.ts +0 -80
- package/runtime-src/payments/cascade.ts +0 -137
- package/runtime-src/payments/index.ts +0 -270
- package/runtime-src/payments/lobster-pay.ts +0 -182
- package/runtime-src/payments/wallet.ts +0 -98
- package/runtime-src/publish/review-context.ts +0 -93
- package/runtime-src/publish/sanitize.ts +0 -197
- package/runtime-src/publish/schema-review.ts +0 -192
- package/runtime-src/publish-admission.ts +0 -388
- package/runtime-src/ratelimit/index.ts +0 -23
- package/runtime-src/reverse-engineer/bundle-scanner.ts +0 -127
- package/runtime-src/reverse-engineer/description-prompt.ts +0 -213
- package/runtime-src/reverse-engineer/index.ts +0 -1551
- package/runtime-src/reverse-engineer/token-sources.ts +0 -379
- package/runtime-src/router.ts +0 -17
- package/runtime-src/routing-telemetry.ts +0 -395
- package/runtime-src/runtime/browser-access.ts +0 -11
- package/runtime-src/runtime/browser-auth.ts +0 -12
- package/runtime-src/runtime/browser-host.ts +0 -48
- package/runtime-src/runtime/lifecycle.ts +0 -17
- package/runtime-src/runtime/local-server.ts +0 -311
- package/runtime-src/runtime/paths.ts +0 -99
- package/runtime-src/runtime/setup.ts +0 -251
- package/runtime-src/runtime/supervisor.ts +0 -69
- package/runtime-src/runtime/update-hints.ts +0 -351
- package/runtime-src/server.ts +0 -100
- package/runtime-src/session-logs.ts +0 -142
- package/runtime-src/settings.ts +0 -221
- package/runtime-src/single-binary.ts +0 -143
- package/runtime-src/site-policy.ts +0 -54
- package/runtime-src/stale-cleanup-runner.ts +0 -144
- package/runtime-src/stale-cleanup.ts +0 -133
- package/runtime-src/telemetry-attribution.ts +0 -120
- package/runtime-src/telemetry.ts +0 -253
- package/runtime-src/template-params.ts +0 -141
- package/runtime-src/transform/drift.ts +0 -60
- package/runtime-src/transform/index.ts +0 -277
- package/runtime-src/types/index.ts +0 -1
- package/runtime-src/types/skill.ts +0 -931
- package/runtime-src/vault/index.ts +0 -196
- package/runtime-src/verification/auth-gate.ts +0 -8
- package/runtime-src/verification/candidates.ts +0 -27
- package/runtime-src/verification/index.ts +0 -120
- package/runtime-src/verification/matrix.ts +0 -30
- package/runtime-src/version.ts +0 -148
- package/runtime-src/workflow/artifact.ts +0 -161
- package/runtime-src/workflow/compile.ts +0 -808
- package/runtime-src/workflow/publish.ts +0 -225
- 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
|
-
}
|