tr-plugin-meta-harness 0.0.0-stage → 0.5.26

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 (94) hide show
  1. package/DESIGN.md +86 -0
  2. package/README.md +310 -2
  3. package/capability/BRICK.md +59 -0
  4. package/capability/index.mjs +675 -0
  5. package/cli.mjs +524 -0
  6. package/package.json +32 -4
  7. package/plugin.json +1714 -0
  8. package/skills/meta-harness/SKILL.md +75 -0
  9. package/src/adapters/dsh.mjs +446 -0
  10. package/src/adoption.mjs +102 -0
  11. package/src/agent-user.mjs +194 -0
  12. package/src/alerts.mjs +229 -0
  13. package/src/cascade.mjs +185 -0
  14. package/src/chat.mjs +80 -0
  15. package/src/codex-models.mjs +54 -0
  16. package/src/compat-harness.mjs +114 -0
  17. package/src/control.mjs +145 -0
  18. package/src/coordinator.mjs +307 -0
  19. package/src/dispatch-request.mjs +76 -0
  20. package/src/dispatch.mjs +119 -0
  21. package/src/documentation-authority.mjs +57 -0
  22. package/src/documentation.mjs +240 -0
  23. package/src/executor.mjs +161 -0
  24. package/src/gate-adapters/agy.mjs +155 -0
  25. package/src/gate-adapters/claude.mjs +303 -0
  26. package/src/gate-adapters/cline.mjs +111 -0
  27. package/src/gate-adapters/codex.mjs +164 -0
  28. package/src/gate-adapters/cursor.mjs +164 -0
  29. package/src/gate-adapters/devin.mjs +116 -0
  30. package/src/gate-adapters/dsh.mjs +284 -0
  31. package/src/gate-adapters/grok.mjs +112 -0
  32. package/src/gate-adapters/hermes.mjs +217 -0
  33. package/src/gate-adapters/hook-files.mjs +156 -0
  34. package/src/gate-adapters/index.mjs +131 -0
  35. package/src/gate-adapters/openclaw-plugin/gate-client.js +205 -0
  36. package/src/gate-adapters/openclaw-plugin/index.js +25 -0
  37. package/src/gate-adapters/openclaw-plugin/openclaw.plugin.json +9 -0
  38. package/src/gate-adapters/openclaw-plugin/package.json +15 -0
  39. package/src/gate-adapters/openclaw.mjs +288 -0
  40. package/src/gate-adapters/pi.mjs +146 -0
  41. package/src/gate.mjs +18 -0
  42. package/src/harness-updates.mjs +170 -0
  43. package/src/included-usage.mjs +344 -0
  44. package/src/jobs.mjs +135 -0
  45. package/src/json-reply.mjs +22 -0
  46. package/src/learner.mjs +120 -0
  47. package/src/maintenance.mjs +18 -0
  48. package/src/mcp-server.mjs +228 -0
  49. package/src/model-catalog.mjs +195 -0
  50. package/src/model-selection.mjs +67 -0
  51. package/src/paths.mjs +23 -0
  52. package/src/pool.mjs +69 -0
  53. package/src/process-manager.mjs +246 -0
  54. package/src/process-worker.mjs +18 -0
  55. package/src/reasoning.mjs +231 -0
  56. package/src/remote-operation.mjs +76 -0
  57. package/src/review.mjs +241 -0
  58. package/src/reviews.mjs +25 -0
  59. package/src/router-benchmark-corpus.mjs +16 -0
  60. package/src/router-benchmark.mjs +208 -0
  61. package/src/router.mjs +334 -0
  62. package/src/runtime.mjs +58 -0
  63. package/src/session/claude.mjs +358 -0
  64. package/src/session/codex.mjs +501 -0
  65. package/src/session/result.mjs +90 -0
  66. package/src/session/resume.mjs +393 -0
  67. package/src/session/run.mjs +258 -0
  68. package/src/session-jobs.mjs +77 -0
  69. package/src/setup.mjs +38 -0
  70. package/src/ssss-store.mjs +20 -0
  71. package/src/telemetry.mjs +267 -0
  72. package/src/termination.mjs +28 -0
  73. package/src/threads.mjs +150 -0
  74. package/src/tracker.mjs +133 -0
  75. package/src/usage-queue.mjs +137 -0
  76. package/src/verify-ssss.mjs +102 -0
  77. package/src/worker.mjs +1104 -0
  78. package/src/worktree.mjs +244 -0
  79. package/ui/chunks/adapter-docs-freshness.md +16 -0
  80. package/ui/chunks/chat-handoff.md +26 -0
  81. package/ui/chunks/fleet-maintenance.md +21 -0
  82. package/ui/chunks/harness-inventory.md +21 -0
  83. package/ui/chunks/included-access.md +18 -0
  84. package/ui/chunks/included-usage-verification.md +15 -0
  85. package/ui/chunks/independent-review.md +17 -0
  86. package/ui/chunks/managed-execution.md +20 -0
  87. package/ui/chunks/official-documentation.md +18 -0
  88. package/ui/chunks/quota-recovery.md +21 -0
  89. package/ui/chunks/review-routing-decision.md +16 -0
  90. package/ui/chunks/route-work.md +18 -0
  91. package/ui/chunks/routing-evidence.md +18 -0
  92. package/ui/chunks/run-ledger.md +18 -0
  93. package/ui/chunks/session-controls.md +16 -0
  94. package/ui/home.js +198 -0
@@ -0,0 +1,307 @@
1
+ /**
2
+ * Multi-agent coordination.
3
+ * Pipeline: Explorer -> Architect -> Implementer -> Verifier. Writing happens only on a dedicated
4
+ * branch in its own worktree, and the Verifier inspects that exact commit from a different model
5
+ * family. Nothing merges into the operator's branch; the branch is the deliverable.
6
+ */
7
+ import { recordRunReceipt } from './learner.mjs';
8
+ import { classifyTaskComplexity, synthesizeOneWayValve } from '../capability/index.mjs';
9
+ import { notifyAlert } from './alerts.mjs';
10
+ import { dispatchWithReceipt } from './dispatch.mjs';
11
+ import { queueIncludedJob } from './usage-queue.mjs';
12
+ import { resolvePool, localExecutionNode } from './pool.mjs';
13
+ import { createThread, appendThreadTurn, updateThread } from './threads.mjs';
14
+ import { executeCodeReview } from './review.mjs';
15
+ import { isGitRepo, isDirty, headCommit, createWorktree, removeWorktree, commitAll, diffBetween, linkDependencies, deleteBranch } from './worktree.mjs';
16
+ import { lastJsonWith } from './json-reply.mjs';
17
+ import { runQualityGate } from './gate.mjs';
18
+ import { forwardRemoteOperation } from './remote-operation.mjs';
19
+ import { cancellationResult } from './worker.mjs';
20
+ import { sessionOptions } from './session/run.mjs';
21
+ import { createModelValidator, filterPoolByModel } from './model-selection.mjs';
22
+
23
+ const OPEN_THREADS = new Set();
24
+ const MAX_BLUEPRINT = 20000;
25
+ /** Implementation is the long stage: a 15-minute session fallback stopped real implementers mid-change (2026-12-01). */
26
+ export const IMPLEMENTER_TIMEOUT_MS = 3600000;
27
+ export const STAGE_TIMEOUT_MS = 900000;
28
+ export function stageTimeoutMs(role, override) {
29
+ if (override !== undefined) return override;
30
+ return role === 'Implementer' ? IMPLEMENTER_TIMEOUT_MS : STAGE_TIMEOUT_MS;
31
+ }
32
+ /** A stopped pipeline must not leave its thread reading as active. */
33
+ export function failOpenThreads(summary = 'The run was stopped before it finished.') {
34
+ for (const id of OPEN_THREADS) { try { updateThread(id, { status: 'failed', summary }); } catch { /* the thread store reports its own failure */ } }
35
+ OPEN_THREADS.clear();
36
+ }
37
+
38
+ export function assignPipelineRoles(pool = [], options = {}) {
39
+ const sorted = [...pool].sort((a, b) => b.qualityScore - a.qualityScore);
40
+ const findById = id => {
41
+ const harness = sorted.find(h => h.id === id);
42
+ if (!harness) throw new Error(`Selected harness ${id} is not ready for this task`);
43
+ return harness;
44
+ };
45
+ // The session's own harness leads only when it can take work; TR_ACTIVE_HARNESS is advisory.
46
+ const active = process.env.TR_ACTIVE_HARNESS;
47
+ const orchestrator = options.orchestrator ? findById(options.orchestrator) : sorted.find(h => h.id === active) || sorted[0] || null;
48
+ if (!orchestrator) return { orchestrator: null, explorer: null, architect: null, implementer: null, verifier: null, heterogeneousFamilies: false };
49
+
50
+ const byCost = [...pool].sort((a, b) => a.costScore - b.costScore);
51
+ const explorer = options.explorer ? findById(options.explorer) : byCost.find(h => h.id !== orchestrator.id) || orchestrator;
52
+ const architect = options.architect ? findById(options.architect) : orchestrator;
53
+ // A requested model is the Implementer's: only a harness that can run it writes the code.
54
+ const compatible = options.modelCompatible;
55
+ const writers = compatible ? sorted.filter(h => compatible.includes(h.id)) : sorted;
56
+ const implementer = options.implementer ? findById(options.implementer) : writers.find(h => h.id !== explorer.id && h.id !== architect.id) || writers.find(h => h.id !== architect.id) || (compatible ? writers[0] || null : architect);
57
+ if (compatible && implementer && !compatible.includes(implementer.id)) throw new Error(`Selected implementer ${implementer.id} cannot run model ${options.model}`);
58
+ if (!implementer) return { orchestrator, explorer, architect, implementer: null, verifier: null, heterogeneousFamilies: false };
59
+ const verifier = options.verifier ? findById(options.verifier) : sorted.find(h => h.family !== implementer.family) || null;
60
+ return { orchestrator, explorer, architect, implementer, verifier, heterogeneousFamilies: Boolean(verifier) && verifier.family !== implementer.family };
61
+ }
62
+
63
+ /** The agent must state a verdict. Silence or an unreadable answer is not a pass. */
64
+ export function parseVerification(response) {
65
+ const parsed = lastJsonWith(response, 'verdict');
66
+ const verdict = String(parsed?.verdict).toUpperCase();
67
+ if (['PASS', 'FAIL'].includes(verdict)) return { parsed: true, verdict, findings: Array.isArray(parsed.findings) ? parsed.findings : [] };
68
+ return { parsed: false, verdict: 'UNREADABLE', findings: [] };
69
+ }
70
+ export function parseVote(response) {
71
+ const parsed = lastJsonWith(response, 'vote');
72
+ const vote = String(parsed?.vote).toUpperCase();
73
+ return ['APPROVE', 'REJECT'].includes(vote) ? { vote, reason: parsed.reason || null } : { vote: 'ABSTAIN', reason: null };
74
+ }
75
+
76
+ const stageOf = (role, harness, permissions, action, extra = {}) => ({ role, harness: harness?.id || null, harnessName: harness?.name || null, modelFamily: harness?.family || null, permissions, action, status: 'planned', output: null, ...extra });
77
+ const READ = { read: true, write: false };
78
+ const WRITE = { read: true, write: true };
79
+
80
+ function buildStages(roles, withSubagents) {
81
+ const stages = [];
82
+ if (withSubagents) stages.push(stageOf('Explorer', roles.explorer, READ, 'Find the relevant files, symbols and interfaces.', { contextDigest: null }));
83
+ stages.push(stageOf('Architect', roles.architect, READ, 'Produce the blueprint, file list and verification steps.'));
84
+ stages.push(stageOf('Implementer', roles.implementer, WRITE, 'Write the code and tests on a dedicated branch in its own worktree.'));
85
+ stages.push(stageOf('Verifier', roles.verifier, READ, 'Audit the implementation commit from a different model family.', { worktreeIsolated: true, passed: null }));
86
+ return stages;
87
+ }
88
+
89
+ async function runPipeline(task, poolInfo, options) {
90
+ const started = Date.now();
91
+ const pool = poolInfo.ready;
92
+ const roles = assignPipelineRoles(pool, options);
93
+ const cwd = options.cwd || process.cwd();
94
+ const execute = options.execute === true;
95
+ const withSubagents = options.subagents !== false;
96
+ const stages = roles.orchestrator ? buildStages(roles, withSubagents) : [];
97
+ if (options.model !== undefined) for (const item of stages) if (item.role === 'Implementer') item.model = options.model;
98
+ const base = { mode: 'pipeline', task, ...modelFields(options), orchestrator: roles.orchestrator?.id || null, executedLive: execute, excluded: poolInfo.excluded, heterogeneousFamiliesVerified: roles.heterogeneousFamilies, stages };
99
+
100
+ if (!execute) {
101
+ const blockers = [];
102
+ if (!roles.orchestrator) blockers.push('No harness can take work right now.');
103
+ else if (!roles.implementer) blockers.push(`No harness that can take work can run model ${options.model}.`);
104
+ else if (!roles.heterogeneousFamilies) blockers.push('Only one model family is available, so no independent Verifier exists.');
105
+ return { ...base, ok: blockers.length === 0, threadId: null, blockers };
106
+ }
107
+ if (!roles.orchestrator) throw new Error(`No harness can take work right now: ${poolInfo.excluded.map(e => `${e.harness} (${e.reason})`).join(', ') || 'none installed'}`);
108
+ if (!roles.implementer) throw new Error(`No harness that can take work can run model ${options.model}`);
109
+ if (!roles.heterogeneousFamilies && options.allowSameFamily !== true) throw new Error('Refusing to run: only one model family is available, so no independent Verifier exists. Pass --allow-same-family to accept self-review.');
110
+ if (!isGitRepo(cwd)) throw new Error('A pipeline writes on its own branch, so it must run inside a git repository');
111
+
112
+ const verifier = roles.verifier || roles.implementer;
113
+ const complexity = classifyTaskComplexity(task);
114
+ // Validate the repository before creating lifecycle state: an unborn repository has no usable base.
115
+ const baseCommit = headCommit(cwd);
116
+ const warnings = isDirty(cwd) ? ['The working tree has uncommitted changes; the branch starts from the last commit and does not include them.'] : [];
117
+ const thread = createThread({ title: task.slice(0, 80), task, platform: roles.orchestrator.id, model: roles.orchestrator.name, status: 'active' });
118
+ OPEN_THREADS.add(thread.id);
119
+ const branch = options.branch || `meta-harness/${thread.id}`;
120
+ const run = async (stage, harness, prompt, { workdir = cwd, permissions, role = stage.role } = {}) => {
121
+ stage.status = 'running';
122
+ const result = await dispatchWithReceipt({ agent: harness.id, node: 'local', cwd: workdir, contextCwd: cwd, contextTask: task, prompt,
123
+ ...sessionOptions({ ...options, cwd }), timeoutMs: stageTimeoutMs(stage.role, options.timeoutMs), goal: stage.role === 'Implementer' ? options.goal || task.slice(0, 4000) : prompt.slice(0, 4000),
124
+ ...(stage.role === 'Implementer' && options.model !== undefined ? { model: options.model } : {}),
125
+ permissions: permissions || stage.permissions, allowUnknownAuth: options.allowUnknownAuth === true }, { dispatchFn: options.dispatchFn, role, complexityScore: complexity.score });
126
+ stage.status = result.cancelled ? 'cancelled' : result.ok ? 'completed' : result.queued ? 'queued' : 'failed';
127
+ stage.output = result.response || result.error || null;
128
+ for (const key of ['goalCheck', 'structured', 'sessionId', 'progressFile', 'usage']) if (result[key] !== undefined) stage[key] = result[key];
129
+ stage.failureKind = result.ok ? undefined : result.failureKind;
130
+ if (result.queueId) stage.queueId = result.queueId;
131
+ appendThreadTurn(thread.id, { role: role.toLowerCase(), agent: harness.id, content: stage.output || '' });
132
+ return result;
133
+ };
134
+
135
+ let ok = true, commit = null, implementerDir = null, gate = null, wip = false;
136
+ const stage = role => stages.find(item => item.role === role);
137
+ try {
138
+ let digest = '';
139
+ if (withSubagents) {
140
+ const explorer = await run(stage('Explorer'), roles.explorer, `[ROLE: EXPLORER]\nDo not change any file. Find the files, symbols and interfaces relevant to this task:\n${task}`);
141
+ if (!explorer.ok) { ok = false; return finish(); }
142
+ digest = synthesizeOneWayValve(explorer.response, { maxChars: 2000 });
143
+ stage('Explorer').contextDigest = digest;
144
+ }
145
+ const architect = await run(stage('Architect'), roles.architect, `[ROLE: ARCHITECT]\nDo not change any file. Task:\n${task}\n\nExplorer digest:\n${digest || 'None.'}\n\nProduce a concise blueprint, the files to change, and how to verify the result.`);
146
+ if (!architect.ok) { ok = false; return finish(); }
147
+ const blueprint = architect.response.length > MAX_BLUEPRINT ? `${architect.response.slice(0, MAX_BLUEPRINT)}\n[Blueprint shortened to ${MAX_BLUEPRINT} characters.]` : architect.response;
148
+
149
+ implementerDir = createWorktree(cwd, { branch });
150
+ const implementer = await run(stage('Implementer'), roles.implementer, `[ROLE: IMPLEMENTER]\nWork only in this checkout. Implement the task and its tests. Do not commit; the harness commits your changes.\nTask:\n${task}\n\nBlueprint:\n${blueprint}`, { workdir: implementerDir });
151
+ if (!implementer.ok) {
152
+ // A failed stage after real edits (a goal check, a timeout) must not discard them: keep them on the branch.
153
+ ok = false;
154
+ commit = commitAll(implementerDir, `meta-harness: unfinished implementer work (${implementer.failureKind || 'failed'})\n\n${task.slice(0, 200)}`) || null;
155
+ wip = Boolean(commit);
156
+ return finish();
157
+ }
158
+ commit = commitAll(implementerDir, `meta-harness: ${task.slice(0, 60)}\n\nImplementer: ${roles.implementer.id}`);
159
+ if (!commit) commit = baseCommit;
160
+ stage('Implementer').commit = commit;
161
+ updateThread(thread.id, { branch, worktreePath: null });
162
+
163
+ if (options.gate) {
164
+ linkDependencies(cwd, implementerDir);
165
+ gate = await (options.gateFn || runQualityGate)(implementerDir, options.gateOptions);
166
+ if (cancellationResult()) { ok = false; return finish(); }
167
+ if (!gate.passed) { ok = false; stage('Verifier').status = 'skipped'; stage('Verifier').output = `Quality gate did not pass: ${gate.summary}`; return finish(); }
168
+ }
169
+
170
+ const diff = diffBetween(cwd, baseCommit, commit);
171
+ const verifyDir = createWorktree(cwd, { ref: commit, prefix: 'meta-harness-verify-' });
172
+ try {
173
+ const verification = await run(stage('Verifier'), verifier, `[ROLE: INDEPENDENT VERIFIER]\nYou did not write this code. Do not change any file. Run the checks you can and audit commit ${commit} for this task:\n${task}\n\nBlueprint:\n${blueprint}\n\nDiff${diff.length > 30000 ? ' (first 30000 characters; read the rest from this checkout)' : ''}:\n${diff.slice(0, 30000)}\n\nEnd your reply with exactly one JSON object: {"verdict":"PASS"|"FAIL","findings":["..."]}`, { workdir: verifyDir });
174
+ const parsed = verification.ok ? parseVerification(verification.response) : { parsed: false, verdict: 'NOT_RUN', findings: [] };
175
+ Object.assign(stage('Verifier'), { commit, verdict: parsed.verdict, findings: parsed.findings, passed: parsed.verdict === 'PASS' });
176
+ if (parsed.verdict !== 'PASS') { ok = false; return finish(); }
177
+ } finally { removeWorktree(cwd, verifyDir); }
178
+
179
+ if (options.autoReview) {
180
+ const review = await executeCodeReview({ cwd, author: roles.implementer.id, threadId: thread.id, task, target: `${baseCommit}...${commit}`, dispatchFn: options.dispatchFn, reviewer: options.reviewer, allowUnknownAuth: options.allowUnknownAuth === true, availableHarnesses: options.availableHarnesses });
181
+ stages.push({ role: 'Reviewer', harness: review.review?.reviewer || null, status: review.ok ? 'completed' : 'failed', verdict: review.review?.verdict || null, riskScore: review.review?.riskScore ?? null, output: review.review?.summary || review.error || null });
182
+ if (!review.ok || review.review?.verdict !== 'APPROVE') ok = false;
183
+ }
184
+ return finish();
185
+ } catch (error) {
186
+ // An infrastructure failure (git, a refused commit) must still close the thread and report.
187
+ ok = false;
188
+ const current = stages.find(item => ['running', 'planned'].includes(item.status));
189
+ if (current) Object.assign(current, { status: 'failed', failureKind: 'process', output: String(error.message) });
190
+ return finish();
191
+ } finally {
192
+ removeWorktree(cwd, implementerDir);
193
+ if (implementerDir && !wip && (!commit || (!ok && !cancellationResult()))) deleteBranch(cwd, branch);
194
+ }
195
+
196
+ function finish() {
197
+ const cancelled = cancellationResult();
198
+ if (cancelled) {
199
+ ok = false;
200
+ if (implementerDir) commit = commitAll(implementerDir, 'meta-harness: unfinished pipeline from a cancelled job') || commit;
201
+ }
202
+ return (async () => {
203
+ for (const item of stages) if (item.status === 'planned') item.status = 'skipped';
204
+ OPEN_THREADS.delete(thread.id);
205
+ const kept = (ok || cancelled || wip) && commit;
206
+ updateThread(thread.id, { status: ok ? 'completed' : 'failed', branch: kept ? branch : null, commit, baseCommit });
207
+ const alert = cancelled ? null : await notifyAlert({ title: ok ? 'Metaharness: pipeline passed' : 'Metaharness: pipeline failed', message: `${task.slice(0, 80)}${commit ? ` (branch ${branch})` : ''}`, severity: ok ? 'info' : 'warning' });
208
+ const limited = stages.find(item => item.failureKind === 'limit');
209
+ return { ...base, ok, ...cancelled, ...(limited ? { failureKind: 'limit', error: limited.output } : {}), goalCheck: stage('Implementer')?.goalCheck, structured: stage('Implementer')?.structured,
210
+ sessionId: stage('Implementer')?.sessionId, progressFile: stage('Implementer')?.progressFile,
211
+ threadId: thread.id, branch: kept ? branch : null, commit, baseCommit, ...(wip ? { wip: true } : {}), gate, warnings, durationMs: Date.now() - started, alert };
212
+ })();
213
+ }
214
+ }
215
+
216
+ async function runCouncil(task, poolInfo, options) {
217
+ // One seat per model family, strongest first, so the seats can actually disagree.
218
+ const families = new Set();
219
+ const seats = options.harnesses || [...poolInfo.ready].sort((a, b) => b.qualityScore - a.qualityScore).filter(h => !families.has(h.family) && families.add(h.family)).slice(0, 3).map(h => h.id);
220
+ if (options.execute !== true) return { ok: seats.length > 0, mode: 'council', task, ...modelFields(options), executedLive: false, consensus: 'planned', excluded: poolInfo.excluded, votes: seats.map(harness => ({ harness, status: 'planned' })) };
221
+ if (!seats.length) throw new Error('No harness can take work right now');
222
+ const cwd = options.cwd || process.cwd();
223
+ const votes = await Promise.all(seats.map(async harness => {
224
+ const result = await dispatchWithReceipt({ agent: harness, node: 'local', cwd, contextTask: task, ...sessionOptions({ ...options, cwd }), ...(options.model !== undefined ? { model: options.model } : {}), prompt: `[ROLE: COUNCIL MEMBER]\nDo not change any file. Assess this proposal, with its trade-offs and risks:\n${task}\n\nEnd your reply with exactly one JSON object: {"vote":"APPROVE"|"REJECT","reason":"..."}`, permissions: READ, allowUnknownAuth: options.allowUnknownAuth === true }, { dispatchFn: options.dispatchFn, role: 'Council' });
225
+ return { harness, ok: result.ok === true, failureKind: result.failureKind, ...(result.ok ? parseVote(result.response) : { vote: 'ABSTAIN', reason: null, error: result.error }),
226
+ ...(result.queueId ? { queueId: result.queueId } : {}), feedback: result.response || null };
227
+ }));
228
+ const count = vote => votes.filter(item => item.vote === vote).length;
229
+ const majority = votes.length / 2;
230
+ const consensus = count('APPROVE') > majority ? 'approved' : count('REJECT') > majority ? 'rejected' : 'no-consensus';
231
+ const limited = votes.some(item => item.failureKind === 'limit');
232
+ return { ok: !limited && votes.some(item => item.ok), ...(limited ? { failureKind: 'limit' } : {}), ...cancellationResult(), mode: 'council', task, ...modelFields(options), executedLive: true, consensus, excluded: poolInfo.excluded, votes };
233
+ }
234
+
235
+ async function runRace(task, poolInfo, options) {
236
+ const seats = options.candidates || [...poolInfo.ready].sort((a, b) => b.qualityScore - a.qualityScore).slice(0, 2).map(h => h.id);
237
+ if (options.execute !== true) return { ok: seats.length > 1, mode: 'race', task, ...modelFields(options), executedLive: false, excluded: poolInfo.excluded, candidates: seats.map(harness => ({ harness, status: 'planned' })) };
238
+ if (seats.length < 2) throw new Error('A race needs at least two harnesses that can take work');
239
+ if (!options.gate) return { ok: false, mode: 'race', task, executedLive: false, verification: 'unverified', gateApplied: false, error: 'A race requires a deterministic quality gate before any candidate can win.' };
240
+ const cwd = options.cwd || process.cwd();
241
+ if (!isGitRepo(cwd)) throw new Error('A race writes on separate branches, so it must run inside a git repository');
242
+ const id = `race-${Date.now().toString(36)}`;
243
+ const entries = await Promise.all(seats.map(async harness => {
244
+ const branch = `meta-harness/${id}-${harness}`;
245
+ let directory;
246
+ let keep = false;
247
+ try {
248
+ const started = Date.now();
249
+ directory = createWorktree(cwd, { branch });
250
+ const result = await dispatchWithReceipt({ agent: harness, node: 'local', cwd: directory, contextCwd: cwd, contextTask: task, ...sessionOptions({ ...options, cwd }), goal: options.goal || task.slice(0, 4000), ...(options.model !== undefined ? { model: options.model } : {}), prompt: `[ROLE: IMPLEMENTER]\nWork only in this checkout. Implement the task and its tests. Do not commit.\nTask:\n${task}`, permissions: WRITE, allowUnknownAuth: options.allowUnknownAuth === true }, { dispatchFn: options.dispatchFn, role: 'Race' });
251
+ const commit = result.ok || result.cancelled ? commitAll(directory, `meta-harness race: ${task.slice(0, 60)}\n\nAgent: ${harness}`) : null;
252
+ if (result.cancelled) {
253
+ keep = Boolean(commit);
254
+ return { ...result, harness, branch: keep ? branch : null, wip: commit };
255
+ }
256
+ if (result.ok && options.gate) linkDependencies(cwd, directory);
257
+ const gate = result.ok ? await (options.gateFn || runQualityGate)(directory, options.gateOptions) : null;
258
+ if (cancellationResult()) {
259
+ keep = Boolean(commit);
260
+ return { ...cancellationResult(), harness, branch: keep ? branch : null, commit };
261
+ }
262
+ keep = result.ok === true && gate?.passed === true;
263
+ return { harness, branch: keep ? branch : null, commit: keep ? commit : null, ok: keep, gate, goalCheck: result.goalCheck, structured: result.structured, failureKind: result.failureKind, completedAt: Date.now(), durationMs: Date.now() - started, error: result.ok ? keep ? undefined : 'The quality gate failed' : result.error,
264
+ ...(result.queueId ? { queueId: result.queueId } : {}) };
265
+ } catch (error) {
266
+ return { harness, branch: null, commit: null, ok: false, gate: null, durationMs: null, error: String(error.message) };
267
+ } finally {
268
+ removeWorktree(cwd, directory);
269
+ if (!keep) deleteBranch(cwd, branch);
270
+ }
271
+ }));
272
+ const finishers = entries.filter(entry => entry.ok).sort((a, b) => a.completedAt - b.completedAt);
273
+ const limited = entries.some(item => item.failureKind === 'limit');
274
+ return { ok: !limited && finishers.length > 0, ...(limited ? { failureKind: 'limit' } : {}), ...cancellationResult(), mode: 'race', task, ...modelFields(options), executedLive: true, gateApplied: true, verification: !limited && finishers.length ? 'passed' : 'failed', winner: limited ? null : finishers[0]?.harness || null, excluded: poolInfo.excluded, candidates: entries };
275
+ }
276
+
277
+ const modelFields = options => options.model !== undefined ? { model: options.model, modelSelection: options.modelSelection } : {};
278
+
279
+ export async function coordinateTask(taskDescription, options = {}) {
280
+ if (cancellationResult()) return cancellationResult();
281
+ const task = String(taskDescription || '').trim();
282
+ if (!task) throw new Error('Task description is required for coordination');
283
+ const remote = await forwardRemoteOperation('coordinate', task, options);
284
+ if (remote) return remote;
285
+ const mode = options.mode || 'pipeline';
286
+ if (!['pipeline', 'orchestrate', 'council', 'race'].includes(mode)) throw new Error(`Unsupported coordination mode: ${mode}`);
287
+ localExecutionNode(options);
288
+ let poolInfo = await resolvePool(options);
289
+ if (options.model !== undefined) {
290
+ // Council and race seats all run the model, so their pool narrows. A pipeline keeps every harness
291
+ // for its other roles and gives the Implementer role to one that can run the model.
292
+ const filtered = filterPoolByModel(poolInfo, options.model, options.modelValidator || createModelValidator());
293
+ options = { ...options, modelSelection: filtered.selection, modelCompatible: filtered.selection.compatible };
294
+ if (mode === 'council' || mode === 'race') poolInfo = filtered.pool;
295
+ }
296
+ const wall = poolInfo.excluded.find(item => item.failureKind === 'quota');
297
+ const minimum = mode === 'race' || ((mode === 'pipeline' || mode === 'orchestrate') && options.allowSameFamily !== true) ? 2 : 1;
298
+ if (options.execute === true && wall && poolInfo.ready.length < minimum) {
299
+ const blocked = { ok: false, failureKind: 'quota', error: 'Coordination is waiting for included usage.', resetsAt: wall.resetsAt };
300
+ const job = await queueIncludedJob({ agent: wall.harness, cwd: options.cwd || process.cwd(), prompt: task }, blocked,
301
+ { role: 'Coordinate', launchPrevented: true });
302
+ return { ...blocked, mode, executedLive: false, queued: true, queueId: job.id, needsReview: job.needsReview };
303
+ }
304
+ if (mode === 'council') return runCouncil(task, poolInfo, options);
305
+ if (mode === 'race') return runRace(task, poolInfo, options);
306
+ return runPipeline(task, poolInfo, options);
307
+ }
@@ -0,0 +1,76 @@
1
+ import path from 'node:path';
2
+ import { sessionOptions } from './session/run.mjs';
3
+
4
+ const DEFAULT_PERMISSIONS = Object.freeze({ read: true, write: false, send: false, destructive: false });
5
+ export { DEFAULT_PERMISSIONS };
6
+
7
+ export function commandPermissions(value = DEFAULT_PERMISSIONS) {
8
+ if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error('Command permissions must be boolean values');
9
+ for (const key of Object.keys(value)) {
10
+ if (!Object.hasOwn(DEFAULT_PERMISSIONS, key) || typeof value[key] !== 'boolean') throw new Error(`Invalid permission ${key}`);
11
+ }
12
+ return { ...DEFAULT_PERMISSIONS, ...value };
13
+ }
14
+
15
+ const PUBLIC_FIELDS = [
16
+ 'agent', 'cwd', 'prompt', 'permissions', 'node', 'allowUnknownAuth', 'timeoutMs',
17
+ 'model', 'tools', 'settingSources', 'allowedTools',
18
+ 'goal', 'maxTurns', 'maxTokens', 'maxBudgetUsd', 'resultSchema', 'approvalPolicy', 'questionTimeoutMs', 'effort', 'fallbackModel', 'name',
19
+ 'internalReasoning',
20
+ ];
21
+
22
+ /** The plugin host stops a foreground command after 10 minutes; a detached background job is not under that limit. */
23
+ export const FOREGROUND_TIMEOUT_MAX_MS = 540000;
24
+ export const BACKGROUND_TIMEOUT_MAX_MS = 5400000;
25
+
26
+ /**
27
+ * The deadline an attached run may use: the host passes its actual timer in TR_PLUGIN_TIMEOUT_MS
28
+ * (90 minutes for a terminal or background-task call), less a minute to finish and report.
29
+ * Without it, the conservative 9-minute limit applies.
30
+ */
31
+ export function attachedTimeoutMaxMs(env = process.env) {
32
+ const host = Number(env.TR_PLUGIN_TIMEOUT_MS);
33
+ if (!Number.isInteger(host) || host <= 60000) return FOREGROUND_TIMEOUT_MAX_MS;
34
+ return Math.min(BACKGROUND_TIMEOUT_MAX_MS, Math.max(FOREGROUND_TIMEOUT_MAX_MS, host - 60000));
35
+ }
36
+ /** A detached local job is coding work, not a probe: five minutes stopped real jobs mid-implementation. */
37
+ export const BACKGROUND_TIMEOUT_DEFAULT_MS = 3600000;
38
+ export const FOREGROUND_TIMEOUT_DEFAULT_MS = 300000;
39
+
40
+ export function defaultTimeoutMs({ background = false, local = true } = {}) {
41
+ return background && local ? BACKGROUND_TIMEOUT_DEFAULT_MS : FOREGROUND_TIMEOUT_DEFAULT_MS;
42
+ }
43
+
44
+ /** The deadline a resumed or forked job runs under: an explicit override, else the saved job's, else the default. */
45
+ export function continuationTimeoutMs({ override, saved, background = false } = {}) {
46
+ const timeoutMs = override ?? saved ?? defaultTimeoutMs({ background });
47
+ const max = background ? BACKGROUND_TIMEOUT_MAX_MS : attachedTimeoutMaxMs();
48
+ if (!Number.isInteger(timeoutMs) || timeoutMs < 1) throw new Error('--timeout-ms must be a whole number of milliseconds');
49
+ return Math.min(timeoutMs, max);
50
+ }
51
+
52
+ export function validateDispatchRequest(request, { background = false } = {}) {
53
+ if (!request || typeof request !== 'object' || Array.isArray(request)) throw new Error('Dispatch requires a JSON object');
54
+ if (Object.keys(request).some(key => !PUBLIC_FIELDS.includes(key))) throw new Error('Unsupported dispatch field; workspace context and containment are managed by Metaharness');
55
+ if (typeof request.agent !== 'string' || !/^[a-z][a-z0-9-]{0,63}$/.test(request.agent) ||
56
+ typeof request.cwd !== 'string' || !path.isAbsolute(request.cwd) || request.cwd.includes('\0') ||
57
+ typeof request.prompt !== 'string' || !request.prompt.trim() || Buffer.byteLength(request.prompt) > 65536) {
58
+ throw new Error('Dispatch requires an explicit agent, absolute workspace, and bounded nonempty prompt');
59
+ }
60
+ if (request.node !== undefined && (typeof request.node !== 'string' || !request.node.trim() || /[\0\r\n]/.test(request.node))) throw new Error('Invalid dispatch node');
61
+ if (request.allowUnknownAuth !== undefined && typeof request.allowUnknownAuth !== 'boolean') throw new Error('allowUnknownAuth must be a boolean');
62
+ // Only a local job gets the background limit: a remote node runs the attempt as its own foreground dispatch.
63
+ const local = request.node === undefined || request.node === 'local';
64
+ const timeoutMs = request.timeoutMs === undefined ? defaultTimeoutMs({ background, local }) : request.timeoutMs;
65
+ const max = background && local ? BACKGROUND_TIMEOUT_MAX_MS : local ? attachedTimeoutMaxMs() : FOREGROUND_TIMEOUT_MAX_MS;
66
+ if (!Number.isInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > max) {
67
+ throw new Error(`Dispatch timeout must be 1..${FOREGROUND_TIMEOUT_MAX_MS} ms, or up to ${BACKGROUND_TIMEOUT_MAX_MS} ms for a local --background job`);
68
+ }
69
+ return { ...request, ...sessionOptions(request), permissions: commandPermissions(request.permissions), timeoutMs };
70
+ }
71
+
72
+ /** The installed destination starts from its own project context and decides containment itself. */
73
+ export function destinationDispatchRequest(request) {
74
+ const fields = PUBLIC_FIELDS.filter(key => key !== 'node' && request[key] !== undefined);
75
+ return validateDispatchRequest(Object.fromEntries(fields.map(key => [key, request[key]])));
76
+ }
@@ -0,0 +1,119 @@
1
+ /** One path for every agent run: contain it if needed, dispatch it, classify the outcome, write its receipt. */
2
+ import { executeOnNode } from './executor.mjs';
3
+ import { classifyFailure, INCLUDED_BILLING, READ_ONLY_ADAPTERS, cancellationResult } from './worker.mjs';
4
+ import { codexModelRefusal } from './codex-models.mjs';
5
+ import { recordRunReceipt } from './learner.mjs';
6
+ import { isGitRepo, createWorktree, removeWorktree, commitAll, deleteBranch, gitPointerProblem } from './worktree.mjs';
7
+ import { randomUUID } from 'node:crypto';
8
+ import { includedAdmission, openRouterAdmission, readIncludedPolicy } from './included-usage.mjs';
9
+ import { queueIncludedJob } from './usage-queue.mjs';
10
+ import { createModelValidator } from './model-selection.mjs';
11
+ import { enforceVelocityCircuitBreaker } from './alerts.mjs';
12
+
13
+ export async function dispatchWithReceipt(request, { dispatchFn, node = request.node || 'local', role, complexityScore, escalatedFrom,
14
+ record = recordRunReceipt, replay, retryId, manageWrites = false, validateModel, usagePolicy = readIncludedPolicy, admit = includedAdmission, admitOpenRouter = openRouterAdmission } = {}) {
15
+ const started = Date.now();
16
+ if (cancellationResult()) return cancellationResult();
17
+ try { await enforceVelocityCircuitBreaker({ kind: request.internalReasoning ? 'reasoning' : 'dispatch' }); } catch (error) {
18
+ return { ok: false, agent: request.agent, failureKind: 'circuit-breaker', error: error.message, launchPrevented: true, exitCode: null, durationMs: Date.now() - started };
19
+ }
20
+ if (request.agent === 'codex' && request.model === undefined && node === 'local') {
21
+ const refused = codexModelRefusal();
22
+ if (refused) return { ok: false, agent: request.agent, failureKind: 'model', error: refused, launchPrevented: true, exitCode: null, durationMs: Date.now() - started };
23
+ }
24
+ // A model this harness must not or cannot run is refused before launch; it says nothing about the harness, so no receipt.
25
+ if (request.model !== undefined) {
26
+ const check = (validateModel || createModelValidator({ local: node === 'local' }))(request.agent, request.model);
27
+ if (!check.ok) return { ok: false, agent: request.agent, failureKind: 'model', error: check.reason, modelCheck: check, launchPrevented: true, exitCode: null, durationMs: Date.now() - started };
28
+ }
29
+ // A harness that cannot be told not to write does read-only work in a checkout that is thrown away.
30
+ const contain = node === 'local' && request.permissions?.write !== true && !READ_ONLY_ADAPTERS.includes(request.agent) && request.isolated !== true && isGitRepo(request.cwd);
31
+ const ownWrites = manageWrites && node === 'local' && request.permissions?.write === true && isGitRepo(request.cwd);
32
+ let scratch = null, branch = null, result, billingMode = null, launchPrevented = false;
33
+ try {
34
+ let effective = request;
35
+ const policy = await usagePolicy();
36
+ const openRouter = Object.hasOwn(policy.openRouter ?? {}, request.agent);
37
+ const planOnly = request.includedPlanOnly === true;
38
+ if (planOnly && (!policy.enabled || node !== 'local' || openRouter)) {
39
+ result = { ok: false, failureKind: 'billing-policy', error: 'This reasoning task requires a verified local included plan.' };
40
+ launchPrevented = true;
41
+ } else if (policy.enabled && node === 'local') {
42
+ billingMode = openRouter ? 'openrouter' : 'included';
43
+ const admission = openRouter ? await admitOpenRouter(request.agent, policy) : await admit(request.agent, request.cwd, planOnly ? { ...policy, claude: undefined } : policy);
44
+ if (!admission.ok) {
45
+ result = { ...admission, agent: request.agent, exitCode: null };
46
+ launchPrevented = true;
47
+ } else effective = { ...request, [INCLUDED_BILLING]: { key: admission.key, claudePlan: admission.claudePlan, claudeToken: admission.claudeToken, openRouter: admission.openRouter, agy: admission.agy } };
48
+ }
49
+ result = cancellationResult() || result;
50
+ if (!result) {
51
+ if (contain || ownWrites) {
52
+ branch = ownWrites ? `meta-harness/dispatch-${randomUUID()}` : null;
53
+ scratch = createWorktree(request.cwd, { ...(branch ? { branch } : {}), prefix: ownWrites ? 'meta-harness-dispatch-' : 'meta-harness-readonly-' });
54
+ effective = { ...effective, ...(branch ? { branch } : {}), cwd: scratch, contextCwd: request.contextCwd || request.cwd, isolated: true };
55
+ }
56
+ result = dispatchFn ? await dispatchFn(effective) : await executeOnNode(node, { ...effective, operation: 'dispatch' });
57
+ if (cancellationResult()) result = { ...result, ...cancellationResult() };
58
+ if (contain) result = { ...result, readOnly: 'disposable-checkout' };
59
+ }
60
+ } catch (error) {
61
+ const message = String(error?.message || error);
62
+ result = { ok: false, error: message, agent: request.agent, ...(error?.code === 'NOT_READY' ? { failureKind: 'not-ready' } : classifyFailure(message)) };
63
+ } finally {
64
+ if (scratch) {
65
+ let keep = false;
66
+ try {
67
+ if (branch) {
68
+ const commit = commitAll(scratch, result?.cancelled ? 'meta-harness: unfinished cancelled dispatch' : 'meta-harness: dispatch changes');
69
+ if (commit) result = { ...result, branch, ...(result?.ok ? { commit } : { wip: commit }) };
70
+ else if (result?.sessionId) result = { ...result, branch };
71
+ else deleteBranch(request.cwd, branch);
72
+ }
73
+ } catch (error) {
74
+ // A refused commit must leave the checkout available for recovery, without running status there.
75
+ if (!gitPointerProblem(scratch)) throw error;
76
+ keep = true;
77
+ result = { ...result, ok: false, failureKind: 'security', error: String(error.message), branch, keptWorktree: scratch };
78
+ } finally { if (!keep) removeWorktree(request.cwd, scratch); }
79
+ if (!keep && branch && !result?.branch) deleteBranch(request.cwd, branch);
80
+ }
81
+ }
82
+ const durationMs = Date.now() - started;
83
+ if (result.execution?.receiptOwner === 'destination' && result.receiptId) return { ...result, durationMs };
84
+ if (result.execution?.remote && (result.queued || result.launchPrevented)) return { ...result, durationMs };
85
+ if (billingMode === 'included' && result.failureKind === 'quota') {
86
+ if (retryId) result = { ...result, needsReview: !launchPrevented && request.permissions?.write === true };
87
+ // Internal reasoning is an attempt within the caller's durable task.
88
+ else if (!request.internalReasoning) {
89
+ try {
90
+ const job = await queueIncludedJob(request, result, { role, replay, launchPrevented });
91
+ result = { ...result, queued: true, queueId: job.id, needsReview: job.needsReview };
92
+ } catch (error) {
93
+ result = { ...result, queueError: error.message };
94
+ }
95
+ }
96
+ }
97
+ if (launchPrevented) {
98
+ // A launch refused for quota is a quota wall too (A-124): record it, so routing sees the harness as
99
+ // exhausted until its reset and picks another included harness instead of choosing it again.
100
+ if (result.failureKind === 'quota') {
101
+ try { await record({ harness: request.agent, role, task: String(request.contextTask || request.prompt || '').slice(0, 200), success: false,
102
+ failureKind: 'quota', billingMode, error: result.error, resetsAt: result.resetsAt || null }); } catch { /* bookkeeping must not hide the refusal */ }
103
+ }
104
+ return { ...result, launchPrevented, durationMs };
105
+ }
106
+ // A finished run keeps its result: the worktree and any cost are real even when bookkeeping fails.
107
+ let receipt, receiptError;
108
+ try {
109
+ receipt = await record({
110
+ harness: request.agent, role, node, task: request.contextTask || request.prompt, complexityScore,
111
+ billingMode,
112
+ model: result.model ?? null, exitCode: result.exitCode ?? null, finishedReason: result.finishedReason ?? null,
113
+ tools: result.toolResults,
114
+ success: result.ok === true, durationMs, failureKind: result.ok ? null : result.failureKind || 'agent',
115
+ error: result.ok ? null : result.error, resetsAt: result.resetsAt, escalatedFrom,
116
+ });
117
+ } catch (error) { receiptError = String(error?.message || error); }
118
+ return { ...result, durationMs, ...(billingMode ? { billingMode } : {}), ...(receipt?.id ? { receiptId: receipt.id } : {}), ...(receiptError ? { receiptError } : {}) };
119
+ }
@@ -0,0 +1,57 @@
1
+ import os from 'node:os';
2
+ import { hostModule, readPeerMetaHarness } from './executor.mjs';
3
+ import { documentationStatus, ensureDocumentation, maintainDocumentation, readDocumentation, refreshDocumentation, searchDocumentation } from './documentation.mjs';
4
+ import { runProcess } from './worker.mjs';
5
+
6
+ const localCommands = {
7
+ 'docs-status': documentationStatus,
8
+ 'docs-ensure': ensureDocumentation,
9
+ 'docs-refresh': refreshDocumentation,
10
+ 'docs-search': searchDocumentation,
11
+ 'docs-read': readDocumentation,
12
+ maintenance: maintainDocumentation,
13
+ };
14
+
15
+ async function localMeshIdentity(load) {
16
+ // A peer's SSH session on the documentation owner does not have the owner's
17
+ // interactive Keychain. Public-cache reads only need the local mesh identity.
18
+ const { loadPluginModule } = await load('plugin-runtime');
19
+ const { resolveTailscaleBinary, STATUS_TIMEOUT_MS } = await loadPluginModule('mesh', 'tailscale-cli', { projectRoot: os.homedir() });
20
+ const result = await runProcess(resolveTailscaleBinary(), ['status', '--json'], { timeoutMs: STATUS_TIMEOUT_MS });
21
+ if (result.exitCode !== 0) return null;
22
+ const own = JSON.parse(result.stdout)?.Self;
23
+ return own ? { hostname: String(own.DNSName || own.HostName || '').replace(/\.$/, ''), ips: own.TailscaleIPs || [] } : null;
24
+ }
25
+
26
+ async function documentationAuthority(load, localIdentity, authorityOnly) {
27
+ if (!process.env.TR_PACKAGE_ROOT) return null;
28
+ const [{ getPlugin }, { readPluginRecord }] = await Promise.all([load('plugin-loader'), load('plugin-store')]);
29
+ const plugin = getPlugin('meta-harness', os.homedir()) || getPlugin('cli-agents', os.homedir());
30
+ const record = plugin?.valid ? readPluginRecord(plugin) : null;
31
+ const selected = (record?.task_nodes ?? record?.frontmatter?.task_nodes)?.maintenance;
32
+ if (!selected) return null;
33
+ const self = await localIdentity(load);
34
+ if (self?.hostname === selected || self?.ips?.includes(selected)) return { node: { ...self, self: true } };
35
+ if (authorityOnly) throw new Error(`This node cannot verify itself as the documentation authority ${selected}`);
36
+ const mesh = await load('mesh');
37
+ const node = mesh.findMeshNode(selected);
38
+ if (!node) throw new Error(`The configured documentation authority ${selected} is not recorded in the mesh`);
39
+ return { mesh, node };
40
+ }
41
+
42
+ export async function runDocumentationCommand(operation, options = {}, { load = hostModule, localIdentity = localMeshIdentity, peer = readPeerMetaHarness, commands = localCommands, authorityOnly = process.env.TR_METAHARNESS_DOCS_AUTHORITY_ONLY === '1' } = {}) {
43
+ const authority = await documentationAuthority(load, localIdentity, authorityOnly);
44
+ if (!authority) {
45
+ if (authorityOnly) throw new Error('The destination has no configured documentation authority');
46
+ return commands[operation](options);
47
+ }
48
+ const { node, mesh } = authority;
49
+ const sourceNode = node.hostname || node.ip;
50
+ if (node.self) return { ...await commands[operation](options), sourceNode };
51
+ const command = operation === 'maintenance' ? 'docs-ensure' : operation;
52
+ const args = [command];
53
+ for (const key of ['agent', 'url', 'query']) if (options[key] !== undefined) args.push(`--${key}`, options[key]);
54
+ const refreshing = command === 'docs-refresh' || command === 'docs-ensure';
55
+ const output = await peer(node, args, { mesh, timeoutMs: refreshing ? 90_000 : 30_000, env: ['TR_METAHARNESS_DOCS_AUTHORITY_ONLY=1'] });
56
+ return { ...output, sourceNode, remote: true };
57
+ }