@exla/rudder 4.0.0-alpha.3 → 4.0.0-alpha.7
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/brain.d.ts +7 -5
- package/dist/brain.js +32 -22
- package/dist/brain.js.map +1 -1
- package/dist/claude-sdk-protocol.d.ts +125 -0
- package/dist/claude-sdk-protocol.js +491 -0
- package/dist/claude-sdk-protocol.js.map +1 -0
- package/dist/claude-sdk.d.ts +28 -0
- package/dist/claude-sdk.js +425 -0
- package/dist/claude-sdk.js.map +1 -0
- package/dist/context-audit.js +1 -1
- package/dist/context-audit.js.map +1 -1
- package/dist/daemon.js +3 -0
- package/dist/daemon.js.map +1 -1
- package/dist/engine-authority.d.ts +5 -0
- package/dist/engine-authority.js +34 -0
- package/dist/engine-authority.js.map +1 -0
- package/dist/engine.d.ts +33 -0
- package/dist/engine.js +154 -0
- package/dist/engine.js.map +1 -0
- package/dist/fabric-local.d.ts +50 -0
- package/dist/fabric-local.js +339 -0
- package/dist/fabric-local.js.map +1 -0
- package/dist/fabric-remote.d.ts +92 -0
- package/dist/fabric-remote.js +402 -0
- package/dist/fabric-remote.js.map +1 -0
- package/dist/main.js +27 -1
- package/dist/main.js.map +1 -1
- package/dist/native/darwin-arm64/rudder-native +0 -0
- package/dist/native/darwin-x64/rudder-native +0 -0
- package/dist/native/linux-x64/rudder-native +0 -0
- package/dist/planner.js +1 -1
- package/dist/planner.js.map +1 -1
- package/dist/run-manager.js +11 -1
- package/dist/run-manager.js.map +1 -1
- package/dist/scheduler.js +3 -0
- package/dist/scheduler.js.map +1 -1
- package/dist/surfaces.d.ts +1 -1
- package/dist/surfaces.js +6 -7
- package/dist/surfaces.js.map +1 -1
- package/dist/types.d.ts +3 -0
- package/package.json +2 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export type FabricObjectKind = "blob" | "directory" | "source_root" | "environment_root" | "checkpoint" | "action_key" | "action_result";
|
|
2
|
+
export interface FabricObjectRef {
|
|
3
|
+
kind: FabricObjectKind;
|
|
4
|
+
algorithm: "sha256";
|
|
5
|
+
digest: string;
|
|
6
|
+
size_bytes: number;
|
|
7
|
+
}
|
|
8
|
+
export interface FabricLease {
|
|
9
|
+
format_version: 1;
|
|
10
|
+
lease_id: string;
|
|
11
|
+
expires_at_ms: number;
|
|
12
|
+
}
|
|
13
|
+
export interface FabricRootReceipt {
|
|
14
|
+
format_version: 1;
|
|
15
|
+
root_id: string;
|
|
16
|
+
root: FabricObjectRef;
|
|
17
|
+
durability: "replicated";
|
|
18
|
+
published_at_ms: number;
|
|
19
|
+
object_count: number;
|
|
20
|
+
total_bytes: number;
|
|
21
|
+
}
|
|
22
|
+
export interface FabricTransferSource {
|
|
23
|
+
pin(root: FabricObjectRef): Promise<string>;
|
|
24
|
+
unpin(ownedPinId: string): Promise<void>;
|
|
25
|
+
closure(root: FabricObjectRef): Promise<FabricObjectRef[]>;
|
|
26
|
+
read(reference: FabricObjectRef): Promise<Uint8Array>;
|
|
27
|
+
}
|
|
28
|
+
export interface FabricTransferResult {
|
|
29
|
+
receipt: FabricRootReceipt;
|
|
30
|
+
uploaded_objects: number;
|
|
31
|
+
uploaded_bytes: number;
|
|
32
|
+
cleanup_warning?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface FabricLocalReceipt {
|
|
35
|
+
format_version: 1;
|
|
36
|
+
root: FabricObjectRef;
|
|
37
|
+
pin: string;
|
|
38
|
+
generation: number;
|
|
39
|
+
durability: "local";
|
|
40
|
+
}
|
|
41
|
+
export interface FabricTransferTarget {
|
|
42
|
+
beginStaging(ttlMs: number): Promise<FabricLease>;
|
|
43
|
+
renewStaging(leaseId: string, ttlMs: number): Promise<FabricLease>;
|
|
44
|
+
/** Must verify raw checksum, canonical typed schema, and the live lease. */
|
|
45
|
+
receive(leaseId: string, object: FabricObjectRef, bytes: Uint8Array): Promise<FabricObjectRef[]>;
|
|
46
|
+
/** Verify/sync the full reachable closure and atomically retain its root. */
|
|
47
|
+
publish(leaseId: string, pin: string, root: FabricObjectRef): Promise<FabricLocalReceipt>;
|
|
48
|
+
abandonStaging(leaseId: string): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
export interface FabricDownloadResult {
|
|
51
|
+
receipt: FabricRootReceipt;
|
|
52
|
+
local: FabricLocalReceipt;
|
|
53
|
+
downloaded_objects: number;
|
|
54
|
+
downloaded_bytes: number;
|
|
55
|
+
}
|
|
56
|
+
export declare class FabricRemoteError extends Error {
|
|
57
|
+
readonly code: string;
|
|
58
|
+
readonly status?: number | undefined;
|
|
59
|
+
constructor(code: string, message: string, status?: number | undefined);
|
|
60
|
+
}
|
|
61
|
+
export declare function validateFabricReference(value: unknown): FabricObjectRef;
|
|
62
|
+
export declare function verifyFabricObject(reference: FabricObjectRef, bytes: Uint8Array): void;
|
|
63
|
+
export declare class FabricRemoteClient {
|
|
64
|
+
private readonly options;
|
|
65
|
+
private readonly base;
|
|
66
|
+
private readonly concurrency;
|
|
67
|
+
private readonly requestTimeoutMs;
|
|
68
|
+
private readonly leaseTtlMs;
|
|
69
|
+
private readonly buffered;
|
|
70
|
+
constructor(options: {
|
|
71
|
+
/** Full authenticated endpoint base, ending /api/rudder/fabric. */
|
|
72
|
+
baseUrl: string;
|
|
73
|
+
authHeaders: () => Record<string, string> | Promise<Record<string, string>>;
|
|
74
|
+
fetch?: typeof globalThis.fetch;
|
|
75
|
+
concurrency?: number;
|
|
76
|
+
requestTimeoutMs?: number;
|
|
77
|
+
leaseTtlMs?: number;
|
|
78
|
+
});
|
|
79
|
+
private request;
|
|
80
|
+
private json;
|
|
81
|
+
beginStaging(): Promise<FabricLease>;
|
|
82
|
+
renewStaging(leaseId: string): Promise<FabricLease>;
|
|
83
|
+
missing(objects: FabricObjectRef[]): Promise<FabricObjectRef[]>;
|
|
84
|
+
putObject(leaseId: string, reference: FabricObjectRef, bytes: Uint8Array): Promise<void>;
|
|
85
|
+
getObject(reference: FabricObjectRef): Promise<Buffer>;
|
|
86
|
+
publishRoot(root: string, leaseId: string, object: FabricObjectRef): Promise<FabricRootReceipt>;
|
|
87
|
+
getRoot(root: string): Promise<FabricRootReceipt>;
|
|
88
|
+
uploadRoot(root: string, object: FabricObjectRef, source: FabricTransferSource): Promise<FabricTransferResult>;
|
|
89
|
+
downloadRoot(root: string, target: FabricTransferTarget, pin: string): Promise<FabricDownloadResult>;
|
|
90
|
+
}
|
|
91
|
+
/** Lazy loading keeps the native transport out of ordinary remote-client use. */
|
|
92
|
+
export declare function runFabricTransferCommand(args: string[], options?: import("./fabric-local.js").FabricTransferCommandOptions): Promise<void>;
|
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
/** Authenticated bounded CAS transfer. The source adapter must pin the root
|
|
2
|
+
* durably and return a NEW owned pin identifier, never a caller's existing pin.
|
|
3
|
+
* This client does not mount filesystems or run an agent during transfer.
|
|
4
|
+
*/
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
6
|
+
export class FabricRemoteError extends Error {
|
|
7
|
+
code;
|
|
8
|
+
status;
|
|
9
|
+
constructor(code, message, status) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.code = code;
|
|
12
|
+
this.status = status;
|
|
13
|
+
this.name = "FabricRemoteError";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const fail = (code, message) => { throw new FabricRemoteError(code, message); };
|
|
17
|
+
const kinds = new Set(["blob", "directory", "source_root", "environment_root", "checkpoint", "action_key", "action_result"]);
|
|
18
|
+
const identity = (object) => `${object.kind}:${object.digest}:${object.size_bytes}`;
|
|
19
|
+
export function validateFabricReference(value) {
|
|
20
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
21
|
+
fail("invalid_reference", "Invalid object reference");
|
|
22
|
+
const object = value;
|
|
23
|
+
if (Object.keys(object).length !== 4 || typeof object.kind !== "string" || !kinds.has(object.kind) || object.algorithm !== "sha256" || typeof object.digest !== "string" || !/^[a-f0-9]{64}$/.test(object.digest) || !Number.isSafeInteger(object.size_bytes) || Number(object.size_bytes) < 0 || Number(object.size_bytes) > 256 * 1024 * 1024 || (object.kind !== "blob" && Number(object.size_bytes) > 4 * 1024 * 1024))
|
|
24
|
+
fail("invalid_reference", "Invalid typed SHA-256 object reference");
|
|
25
|
+
return { kind: object.kind, algorithm: "sha256", digest: object.digest, size_bytes: object.size_bytes };
|
|
26
|
+
}
|
|
27
|
+
export function verifyFabricObject(reference, bytes) {
|
|
28
|
+
validateFabricReference(reference);
|
|
29
|
+
if (bytes.byteLength !== reference.size_bytes || createHash("sha256").update(bytes).digest("hex") !== reference.digest)
|
|
30
|
+
fail("checksum_mismatch", "Transferred object failed checksum verification");
|
|
31
|
+
}
|
|
32
|
+
function rootId(value) { if (typeof value !== "string" || !/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(value))
|
|
33
|
+
fail("invalid_root_id", "Invalid root publication identifier"); return value; }
|
|
34
|
+
function lease(value) {
|
|
35
|
+
const item = value;
|
|
36
|
+
if (!item || Object.keys(item).length !== 3 || item.format_version !== 1 || typeof item.lease_id !== "string" || !/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/.test(item.lease_id) || !Number.isSafeInteger(item.expires_at_ms) || item.expires_at_ms <= 0)
|
|
37
|
+
fail("invalid_response", "Server returned an invalid staging lease");
|
|
38
|
+
return item;
|
|
39
|
+
}
|
|
40
|
+
function receipt(value, expectedId, expectedRoot) {
|
|
41
|
+
const item = value;
|
|
42
|
+
if (!item || Object.keys(item).length !== 7 || item.format_version !== 1 || item.root_id !== expectedId || item.durability !== "replicated" || !Number.isSafeInteger(item.published_at_ms) || item.published_at_ms < 0 || !Number.isSafeInteger(item.object_count) || item.object_count < 1 || item.object_count > 100_000 || !Number.isSafeInteger(item.total_bytes) || item.total_bytes < 0 || item.total_bytes > 4 * 1024 ** 3)
|
|
43
|
+
fail("invalid_response", "Server returned an invalid publication receipt");
|
|
44
|
+
const root = validateFabricReference(item.root);
|
|
45
|
+
if (expectedRoot && identity(root) !== identity(expectedRoot))
|
|
46
|
+
fail("invalid_response", "Publication receipt refers to another root");
|
|
47
|
+
return { ...item, root };
|
|
48
|
+
}
|
|
49
|
+
/** A single client cannot hold several large objects at once, even when the
|
|
50
|
+
* caller raises small-object concurrency. FIFO admission prevents starvation. */
|
|
51
|
+
class ByteBudget {
|
|
52
|
+
available = 256 * 1024 * 1024;
|
|
53
|
+
queue = [];
|
|
54
|
+
acquire(bytes) {
|
|
55
|
+
return new Promise((resolve) => { this.queue.push({ bytes: Math.max(1, bytes), resolve }); this.drain(); });
|
|
56
|
+
}
|
|
57
|
+
drain() {
|
|
58
|
+
while (this.queue.length && this.queue[0].bytes <= this.available) {
|
|
59
|
+
const item = this.queue.shift();
|
|
60
|
+
this.available -= item.bytes;
|
|
61
|
+
let released = false;
|
|
62
|
+
item.resolve(() => { if (!released) {
|
|
63
|
+
released = true;
|
|
64
|
+
this.available += item.bytes;
|
|
65
|
+
this.drain();
|
|
66
|
+
} });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export class FabricRemoteClient {
|
|
71
|
+
options;
|
|
72
|
+
base;
|
|
73
|
+
concurrency;
|
|
74
|
+
requestTimeoutMs;
|
|
75
|
+
leaseTtlMs;
|
|
76
|
+
buffered = new ByteBudget();
|
|
77
|
+
constructor(options) {
|
|
78
|
+
this.options = options;
|
|
79
|
+
this.base = new URL(options.baseUrl.endsWith("/") ? options.baseUrl : `${options.baseUrl}/`);
|
|
80
|
+
if (!["http:", "https:"].includes(this.base.protocol) || this.base.username || this.base.password || this.base.search || this.base.hash)
|
|
81
|
+
fail("invalid_endpoint", "Invalid fabric endpoint");
|
|
82
|
+
this.concurrency = options.concurrency ?? 1;
|
|
83
|
+
this.requestTimeoutMs = options.requestTimeoutMs ?? 120_000;
|
|
84
|
+
this.leaseTtlMs = options.leaseTtlMs ?? 300_000;
|
|
85
|
+
if (!Number.isInteger(this.concurrency) || this.concurrency < 1 || this.concurrency > 8 || !Number.isInteger(this.requestTimeoutMs) || this.requestTimeoutMs < 1 || this.requestTimeoutMs > 120_000 || !Number.isInteger(this.leaseTtlMs) || this.leaseTtlMs < 1000 || this.leaseTtlMs > 3_600_000)
|
|
86
|
+
fail("invalid_limits", "Invalid transfer concurrency or deadline");
|
|
87
|
+
}
|
|
88
|
+
async request(path, method, body, binary, headers = {}, maxResponseBytes = 2 * 1024 * 1024) {
|
|
89
|
+
const controller = new AbortController();
|
|
90
|
+
let timer;
|
|
91
|
+
const work = (async () => {
|
|
92
|
+
const authHeaders = await this.options.authHeaders();
|
|
93
|
+
if (controller.signal.aborted)
|
|
94
|
+
fail("request_timeout", "Fabric request exceeded its deadline");
|
|
95
|
+
const response = await (this.options.fetch ?? globalThis.fetch)(new URL(path, this.base), {
|
|
96
|
+
method, redirect: "error", signal: controller.signal,
|
|
97
|
+
headers: { ...authHeaders, ...(body !== undefined ? { "Content-Type": "application/json" } : binary ? { "Content-Type": "application/octet-stream" } : {}), ...headers },
|
|
98
|
+
body: binary ? Buffer.isBuffer(binary) ? binary : Buffer.from(binary.buffer, binary.byteOffset, binary.byteLength) : body !== undefined ? JSON.stringify(body) : undefined,
|
|
99
|
+
});
|
|
100
|
+
if (!response.ok) {
|
|
101
|
+
await response.body?.cancel().catch(() => { });
|
|
102
|
+
// Never echo response bodies, auth headers, bucket keys or request data.
|
|
103
|
+
throw new FabricRemoteError("remote_rejected", `Fabric request failed (HTTP ${response.status})`, response.status);
|
|
104
|
+
}
|
|
105
|
+
const length = response.headers.get("content-length");
|
|
106
|
+
if (length !== null && (!/^\d+$/.test(length) || Number(length) > maxResponseBytes)) {
|
|
107
|
+
await response.body?.cancel().catch(() => { });
|
|
108
|
+
fail("too_large", "Fabric response exceeds byte limit");
|
|
109
|
+
}
|
|
110
|
+
if (!response.body)
|
|
111
|
+
return Buffer.alloc(0);
|
|
112
|
+
const reader = response.body.getReader();
|
|
113
|
+
const chunks = [];
|
|
114
|
+
// Known lengths use one bounded destination; retaining chunks and then
|
|
115
|
+
// concatenating would briefly double a 200 MiB compiler response.
|
|
116
|
+
const destination = length === null ? undefined : Buffer.allocUnsafe(Number(length));
|
|
117
|
+
let bytes = 0;
|
|
118
|
+
try {
|
|
119
|
+
while (true) {
|
|
120
|
+
const part = await reader.read();
|
|
121
|
+
if (part.done)
|
|
122
|
+
break;
|
|
123
|
+
const start = bytes;
|
|
124
|
+
bytes += part.value.byteLength;
|
|
125
|
+
if (bytes > maxResponseBytes || (destination && bytes > destination.length))
|
|
126
|
+
fail("too_large", "Fabric response exceeds byte limit");
|
|
127
|
+
if (destination)
|
|
128
|
+
destination.set(part.value, start);
|
|
129
|
+
else
|
|
130
|
+
chunks.push(Buffer.from(part.value));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
await reader.cancel().catch(() => { });
|
|
135
|
+
}
|
|
136
|
+
return destination ? destination.subarray(0, bytes) : Buffer.concat(chunks);
|
|
137
|
+
})();
|
|
138
|
+
try {
|
|
139
|
+
return await Promise.race([work, new Promise((_, reject) => { timer = setTimeout(() => { controller.abort(); reject(new FabricRemoteError("request_timeout", "Fabric request exceeded its deadline")); }, this.requestTimeoutMs); })]);
|
|
140
|
+
}
|
|
141
|
+
catch (failure) {
|
|
142
|
+
if (failure instanceof FabricRemoteError)
|
|
143
|
+
throw failure;
|
|
144
|
+
throw new FabricRemoteError("request_failed", "Fabric request failed");
|
|
145
|
+
}
|
|
146
|
+
finally {
|
|
147
|
+
if (timer)
|
|
148
|
+
clearTimeout(timer);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
async json(path, method, body) {
|
|
152
|
+
const bytes = await this.request(path, method, body);
|
|
153
|
+
try {
|
|
154
|
+
return JSON.parse(bytes.toString("utf8"));
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
return fail("invalid_response", "Fabric returned invalid JSON");
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
async beginStaging() { return lease(await this.json("staging", "POST", { format_version: 1, ttl_ms: this.leaseTtlMs })); }
|
|
161
|
+
async renewStaging(leaseId) {
|
|
162
|
+
lease({ format_version: 1, lease_id: leaseId, expires_at_ms: 1 });
|
|
163
|
+
return lease(await this.json(`staging/${leaseId}/renew`, "POST", { format_version: 1, ttl_ms: this.leaseTtlMs }));
|
|
164
|
+
}
|
|
165
|
+
async missing(objects) {
|
|
166
|
+
if (objects.length > 256)
|
|
167
|
+
fail("too_large", "Missing-object request exceeds batch limit");
|
|
168
|
+
objects.forEach(validateFabricReference);
|
|
169
|
+
const reply = await this.json("missing", "POST", { format_version: 1, objects });
|
|
170
|
+
if (!reply || reply.format_version !== 1 || !Array.isArray(reply.missing) || reply.missing.length > objects.length)
|
|
171
|
+
fail("invalid_response", "Invalid missing-object response");
|
|
172
|
+
const allowed = new Set(objects.map(identity));
|
|
173
|
+
const seen = new Set();
|
|
174
|
+
return reply.missing.map((value) => { const reference = validateFabricReference(value); const key = identity(reference); if (!allowed.has(key) || seen.has(key))
|
|
175
|
+
fail("invalid_response", "Server requested an undeclared or duplicate object"); seen.add(key); return reference; });
|
|
176
|
+
}
|
|
177
|
+
async putObject(leaseId, reference, bytes) {
|
|
178
|
+
verifyFabricObject(reference, bytes);
|
|
179
|
+
lease({ format_version: 1, lease_id: leaseId, expires_at_ms: 1 });
|
|
180
|
+
await this.request(`objects/${reference.kind}/${reference.digest}/${reference.size_bytes}`, "PUT", undefined, bytes, { "X-Rudder-Staging-Lease": leaseId });
|
|
181
|
+
}
|
|
182
|
+
async getObject(reference) {
|
|
183
|
+
validateFabricReference(reference);
|
|
184
|
+
const bytes = await this.request(`objects/${reference.kind}/${reference.digest}/${reference.size_bytes}`, "GET", undefined, undefined, {}, reference.size_bytes);
|
|
185
|
+
verifyFabricObject(reference, bytes);
|
|
186
|
+
return bytes;
|
|
187
|
+
}
|
|
188
|
+
async publishRoot(root, leaseId, object) {
|
|
189
|
+
rootId(root);
|
|
190
|
+
validateFabricReference(object);
|
|
191
|
+
lease({ format_version: 1, lease_id: leaseId, expires_at_ms: 1 });
|
|
192
|
+
return receipt(await this.json(`roots/${encodeURIComponent(root)}`, "POST", { format_version: 1, lease_id: leaseId, root: object }), root, object);
|
|
193
|
+
}
|
|
194
|
+
async getRoot(root) {
|
|
195
|
+
rootId(root);
|
|
196
|
+
return receipt(await this.json(`roots/${encodeURIComponent(root)}`, "GET"), root);
|
|
197
|
+
}
|
|
198
|
+
async uploadRoot(root, object, source) {
|
|
199
|
+
rootId(root);
|
|
200
|
+
validateFabricReference(object);
|
|
201
|
+
let ownedPin;
|
|
202
|
+
try {
|
|
203
|
+
ownedPin = await source.pin(object);
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
return fail("source_failed", "Could not pin the local transfer source");
|
|
207
|
+
}
|
|
208
|
+
if (typeof ownedPin !== "string" || !ownedPin.trim())
|
|
209
|
+
fail("invalid_source", "Source did not return an owned retention pin");
|
|
210
|
+
let result;
|
|
211
|
+
let failure;
|
|
212
|
+
try {
|
|
213
|
+
const inventory = await source.closure(object);
|
|
214
|
+
if (!Array.isArray(inventory) || inventory.length > 100_000)
|
|
215
|
+
fail("too_large", "Source inventory exceeds object limit");
|
|
216
|
+
const unique = new Map();
|
|
217
|
+
let total = 0;
|
|
218
|
+
for (const value of inventory) {
|
|
219
|
+
const reference = validateFabricReference(value);
|
|
220
|
+
if (!unique.has(identity(reference))) {
|
|
221
|
+
unique.set(identity(reference), reference);
|
|
222
|
+
total += reference.size_bytes;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (!unique.has(identity(object)) || total > 4 * 1024 ** 3)
|
|
226
|
+
fail("invalid_source", "Source inventory is incomplete or exceeds byte limit");
|
|
227
|
+
let staging = await this.beginStaging();
|
|
228
|
+
let renewal;
|
|
229
|
+
const ensureLease = async (force = false) => {
|
|
230
|
+
if (!force && staging.expires_at_ms > Date.now() + Math.max(70_000, this.leaseTtlMs / 3))
|
|
231
|
+
return;
|
|
232
|
+
renewal ??= this.renewStaging(staging.lease_id).then((updated) => { if (updated.lease_id !== staging.lease_id)
|
|
233
|
+
fail("invalid_response", "Lease renewal changed identity"); staging = updated; }).finally(() => { renewal = undefined; });
|
|
234
|
+
await renewal;
|
|
235
|
+
};
|
|
236
|
+
let uploaded = 0, uploadedBytes = 0;
|
|
237
|
+
const all = [...unique.values()];
|
|
238
|
+
for (let start = 0; start < all.length; start += 256) {
|
|
239
|
+
await ensureLease();
|
|
240
|
+
const missing = await this.missing(all.slice(start, start + 256));
|
|
241
|
+
let cursor = 0;
|
|
242
|
+
let workerFailure;
|
|
243
|
+
// Wait for EVERY worker before releasing the source pin on failure.
|
|
244
|
+
await Promise.all(Array.from({ length: Math.min(this.concurrency, missing.length) }, async () => {
|
|
245
|
+
while (cursor < missing.length && !workerFailure) {
|
|
246
|
+
const reference = missing[cursor++];
|
|
247
|
+
const release = await this.buffered.acquire(reference.size_bytes);
|
|
248
|
+
try {
|
|
249
|
+
await ensureLease();
|
|
250
|
+
const bytes = await source.read(reference);
|
|
251
|
+
verifyFabricObject(reference, bytes);
|
|
252
|
+
await ensureLease();
|
|
253
|
+
await this.putObject(staging.lease_id, reference, bytes);
|
|
254
|
+
uploaded++;
|
|
255
|
+
uploadedBytes += bytes.byteLength;
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
workerFailure = error;
|
|
259
|
+
}
|
|
260
|
+
finally {
|
|
261
|
+
release();
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}));
|
|
265
|
+
if (workerFailure)
|
|
266
|
+
throw workerFailure;
|
|
267
|
+
}
|
|
268
|
+
await ensureLease(true);
|
|
269
|
+
result = { receipt: await this.publishRoot(root, staging.lease_id, object), uploaded_objects: uploaded, uploaded_bytes: uploadedBytes };
|
|
270
|
+
}
|
|
271
|
+
catch (error) {
|
|
272
|
+
failure = error instanceof FabricRemoteError ? error : new FabricRemoteError("source_failed", "Pinned source transfer failed");
|
|
273
|
+
}
|
|
274
|
+
finally {
|
|
275
|
+
try {
|
|
276
|
+
await source.unpin(ownedPin);
|
|
277
|
+
}
|
|
278
|
+
catch {
|
|
279
|
+
if (result)
|
|
280
|
+
result.cleanup_warning = "Remote publication committed; its temporary local retention pin needs cleanup";
|
|
281
|
+
else
|
|
282
|
+
failure ??= new FabricRemoteError("source_cleanup_failed", "Temporary local retention pin needs cleanup");
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (failure)
|
|
286
|
+
throw failure;
|
|
287
|
+
return result;
|
|
288
|
+
}
|
|
289
|
+
async downloadRoot(root, target, pin) {
|
|
290
|
+
rootId(root);
|
|
291
|
+
if (typeof pin !== "string" || !pin.trim() || pin.length > 512 || /[\x00-\x1f\x7f]/.test(pin))
|
|
292
|
+
fail("invalid_pin", "A local retention pin is required");
|
|
293
|
+
const published = await this.getRoot(root);
|
|
294
|
+
let staging;
|
|
295
|
+
let committed = false;
|
|
296
|
+
try {
|
|
297
|
+
staging = lease(await target.beginStaging(this.leaseTtlMs));
|
|
298
|
+
let renewal;
|
|
299
|
+
const ensureLease = async (force = false) => {
|
|
300
|
+
if (!force && staging.expires_at_ms > Date.now() + Math.max(this.requestTimeoutMs + 5000, this.leaseTtlMs / 3))
|
|
301
|
+
return;
|
|
302
|
+
renewal ??= target.renewStaging(staging.lease_id, this.leaseTtlMs).then((value) => {
|
|
303
|
+
const updated = lease(value);
|
|
304
|
+
if (updated.lease_id !== staging.lease_id)
|
|
305
|
+
fail("invalid_target", "Local renewal changed lease identity");
|
|
306
|
+
staging = updated;
|
|
307
|
+
}).finally(() => { renewal = undefined; });
|
|
308
|
+
await renewal;
|
|
309
|
+
};
|
|
310
|
+
const queue = [];
|
|
311
|
+
const seen = new Set();
|
|
312
|
+
let total = 0, edges = 0, cursor = 0;
|
|
313
|
+
const add = (value, depth) => {
|
|
314
|
+
const object = validateFabricReference(value);
|
|
315
|
+
if (depth > 1024)
|
|
316
|
+
fail("too_large", "Downloaded closure exceeds depth limit");
|
|
317
|
+
if (seen.has(identity(object)))
|
|
318
|
+
return;
|
|
319
|
+
total += object.size_bytes;
|
|
320
|
+
seen.add(identity(object));
|
|
321
|
+
if (seen.size > 100_000 || total > 4 * 1024 ** 3)
|
|
322
|
+
fail("too_large", "Downloaded closure exceeds transfer limits");
|
|
323
|
+
queue.push({ object, depth });
|
|
324
|
+
};
|
|
325
|
+
add(published.root, 0);
|
|
326
|
+
let workerFailure;
|
|
327
|
+
let active = 0;
|
|
328
|
+
const waiting = new Set();
|
|
329
|
+
const wake = () => { for (const resolve of waiting)
|
|
330
|
+
resolve(); waiting.clear(); };
|
|
331
|
+
await Promise.all(Array.from({ length: this.concurrency }, async () => {
|
|
332
|
+
while (!workerFailure) {
|
|
333
|
+
if (cursor === queue.length) {
|
|
334
|
+
// An in-flight metadata object can still reveal more work. Keep
|
|
335
|
+
// idle workers available until the entire discovered graph drains.
|
|
336
|
+
if (!active)
|
|
337
|
+
return;
|
|
338
|
+
await new Promise((resolve) => { waiting.add(resolve); });
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
const { object, depth } = queue[cursor++];
|
|
342
|
+
active++;
|
|
343
|
+
let release;
|
|
344
|
+
try {
|
|
345
|
+
release = await this.buffered.acquire(object.size_bytes);
|
|
346
|
+
if (workerFailure)
|
|
347
|
+
continue;
|
|
348
|
+
await ensureLease();
|
|
349
|
+
if (workerFailure)
|
|
350
|
+
continue;
|
|
351
|
+
const bytes = await this.getObject(object);
|
|
352
|
+
await ensureLease();
|
|
353
|
+
const children = await target.receive(staging.lease_id, object, bytes);
|
|
354
|
+
if (!Array.isArray(children))
|
|
355
|
+
fail("invalid_target", "Local target returned invalid metadata references");
|
|
356
|
+
edges += children.length;
|
|
357
|
+
if (edges > 500_000 || (object.kind === "blob" && children.length))
|
|
358
|
+
fail("invalid_target", "Local target returned invalid metadata edges");
|
|
359
|
+
for (const child of children)
|
|
360
|
+
add(child, depth + 1);
|
|
361
|
+
}
|
|
362
|
+
catch (error) {
|
|
363
|
+
workerFailure ??= { error };
|
|
364
|
+
}
|
|
365
|
+
finally {
|
|
366
|
+
release?.();
|
|
367
|
+
active--;
|
|
368
|
+
wake();
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}));
|
|
372
|
+
if (workerFailure)
|
|
373
|
+
throw workerFailure.error;
|
|
374
|
+
if (seen.size !== published.object_count || total !== published.total_bytes)
|
|
375
|
+
fail("invalid_response", "Published closure inventory differs from verified downloaded objects");
|
|
376
|
+
await ensureLease(true);
|
|
377
|
+
const local = await target.publish(staging.lease_id, pin, published.root);
|
|
378
|
+
if (!local || local.format_version !== 1 || local.durability !== "local" || local.pin !== pin || identity(validateFabricReference(local.root)) !== identity(published.root) || !Number.isSafeInteger(local.generation) || local.generation < 1)
|
|
379
|
+
fail("invalid_target", "Local target returned invalid retention evidence");
|
|
380
|
+
committed = true;
|
|
381
|
+
return { receipt: published, local, downloaded_objects: seen.size, downloaded_bytes: total };
|
|
382
|
+
}
|
|
383
|
+
catch (failure) {
|
|
384
|
+
if (failure instanceof FabricRemoteError)
|
|
385
|
+
throw failure;
|
|
386
|
+
throw new FabricRemoteError("target_failed", "Local download did not confirm complete durable publication");
|
|
387
|
+
}
|
|
388
|
+
finally {
|
|
389
|
+
if (staging && !committed) {
|
|
390
|
+
try {
|
|
391
|
+
await target.abandonStaging(staging.lease_id);
|
|
392
|
+
}
|
|
393
|
+
catch { /* No durable success is returned; its bounded staging lease may need cleanup. */ }
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
/** Lazy loading keeps the native transport out of ordinary remote-client use. */
|
|
399
|
+
export async function runFabricTransferCommand(args, options = {}) {
|
|
400
|
+
return (await import("./fabric-local.js")).runFabricTransferCommand(args, options);
|
|
401
|
+
}
|
|
402
|
+
//# sourceMappingURL=fabric-remote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fabric-remote.js","sourceRoot":"","sources":["../src/fabric-remote.ts"],"names":[],"mappings":"AAAA;;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AC,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAAC,CAAC;gBAAC,MAAM,CAAC,CAAC,iFAAiF,CAAC,CAAC;YAAC,CAAC;QACnL,CAAC;IACH,CAAC;CACF;AAED,iFAAiF;AACjF,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,IAAc,EAAE,UAAoE,EAAE;IACnI,OAAO,CAAC,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,wBAAwB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACrF,CAAC"}
|
package/dist/main.js
CHANGED
|
@@ -23,12 +23,25 @@ import { buildFanoutDag, gateDecision, planTask, scaffoldPlan } from "./planner.
|
|
|
23
23
|
import { backfillLlmTaskSummaries, listRuns, loadConfig, popUndoEntry, projectStateDir, registerProject, runsDir } from "./state.js";
|
|
24
24
|
import { discoverModelOptions } from "./models.js";
|
|
25
25
|
import { resolveNativeBinaryPath } from "./native-binary.js";
|
|
26
|
+
import { ensureEngineRunning, persistentProjectEngineRequested, runEngineCommand } from "./engine.js";
|
|
26
27
|
import { cleanupRuns, deleteRun, listProjectRuns, mergeRun, printLogs, startRun, statusRuns, stopRun, syncRun, watchRun, workerRun, } from "./run-manager.js";
|
|
27
28
|
import { appendCompletionNote, appendDecision, appendSharedContext, parseCompletionNoteArg, SHARED_CONTEXT_FILE, syncSharedContextToWorkspaces, writeCompletionNoteFile } from "./surfaces.js";
|
|
28
29
|
import { commandExists, isTty, MissingToolError, newRunId, runCommand } from "./util.js";
|
|
29
30
|
import { autoUpdateAndRerunIfNeeded, getUpdateAvailable } from "./version-check.js";
|
|
30
31
|
import { printReport } from "./report.js";
|
|
31
32
|
export async function main() {
|
|
33
|
+
// The SDK renderer owns its provider argv and stdio/control protocol. Route
|
|
34
|
+
// before general flag parsing so provider options never become Rudder tasks.
|
|
35
|
+
if (process.argv[2] === "__claude-sdk") {
|
|
36
|
+
const { runClaudeSdkBridge } = await import("./claude-sdk.js");
|
|
37
|
+
await runClaudeSdkBridge(process.argv.slice(3));
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (process.argv[2] === "engine" && process.argv[3] === "api" && ["upload", "download"].includes(process.argv[4] ?? "")) {
|
|
41
|
+
const { runFabricTransferCommand } = await import("./fabric-remote.js");
|
|
42
|
+
await runFabricTransferCommand(process.argv.slice(4));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
32
45
|
const parsed = parseArgs(process.argv.slice(2));
|
|
33
46
|
if (shouldAutoUpdateForCommand(parsed.command) && await autoUpdateAndRerunIfNeeded(process.argv.slice(2))) {
|
|
34
47
|
return;
|
|
@@ -95,6 +108,9 @@ export async function main() {
|
|
|
95
108
|
return;
|
|
96
109
|
}
|
|
97
110
|
switch (parsed.command) {
|
|
111
|
+
case "engine":
|
|
112
|
+
await runEngineCommand(parsed.args[0], parsed.flags.repo ?? findRepoRoot(), parsed.flags.json);
|
|
113
|
+
return;
|
|
98
114
|
case "tmux":
|
|
99
115
|
throw new Error("The tmux dashboard has been removed. Run `rudder` or `rudder dashboard` to open the native dashboard.");
|
|
100
116
|
case "attach": {
|
|
@@ -453,7 +469,7 @@ export function isInternalCommand(command) {
|
|
|
453
469
|
return Boolean(command?.startsWith("__"));
|
|
454
470
|
}
|
|
455
471
|
// Commands that never touch a repository, so they never wait on a jj download.
|
|
456
|
-
const JJ_FREE_COMMANDS = new Set(["__event", "__route-task", "telemetry", "feedback", "login", "logout", "help"]);
|
|
472
|
+
const JJ_FREE_COMMANDS = new Set(["__event", "__route-task", "engine", "telemetry", "feedback", "login", "logout", "help"]);
|
|
457
473
|
function shouldAutoUpdateForCommand(command) {
|
|
458
474
|
if (command?.startsWith("__")) {
|
|
459
475
|
return false;
|
|
@@ -760,6 +776,15 @@ async function maybeOnboard() {
|
|
|
760
776
|
}
|
|
761
777
|
async function openDashboard(parsed) {
|
|
762
778
|
await refreshModelCache();
|
|
779
|
+
if (await attachSocketLive()) {
|
|
780
|
+
await runNativeCommand(["attach", "--dashboard"]);
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
if (persistentProjectEngineRequested(findRepoRoot())) {
|
|
784
|
+
await ensureEngineRunning(findRepoRoot());
|
|
785
|
+
await runNativeCommand(["attach", "--dashboard"]);
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
763
788
|
if (await runNativeDashboard()) {
|
|
764
789
|
return;
|
|
765
790
|
}
|
|
@@ -1269,6 +1294,7 @@ Usage:
|
|
|
1269
1294
|
rudder Open native dashboard with real agent panes
|
|
1270
1295
|
rudder restart Clear local session and open dashboard
|
|
1271
1296
|
rudder attach [agent] Mirror one live agent pane of the running dashboard in this terminal
|
|
1297
|
+
rudder engine [start|status|shutdown] Control the persistent project engine
|
|
1272
1298
|
rudder "task"
|
|
1273
1299
|
rudder run [options] "task"
|
|
1274
1300
|
rudder claude [options] "task"
|