agent-relay 7.0.0 → 7.0.1
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/index.cjs +620 -407
- package/dist/src/cli/bootstrap.d.ts.map +1 -1
- package/dist/src/cli/bootstrap.js +2 -0
- package/dist/src/cli/bootstrap.js.map +1 -1
- package/dist/src/cli/commands/log.d.ts +9 -0
- package/dist/src/cli/commands/log.d.ts.map +1 -0
- package/dist/src/cli/commands/log.js +153 -0
- package/dist/src/cli/commands/log.js.map +1 -0
- package/package.json +13 -10
package/dist/index.cjs
CHANGED
|
@@ -3181,7 +3181,7 @@ var require_stream = __commonJS({
|
|
|
3181
3181
|
};
|
|
3182
3182
|
duplex._final = function(callback) {
|
|
3183
3183
|
if (ws2.readyState === ws2.CONNECTING) {
|
|
3184
|
-
ws2.once("open", function
|
|
3184
|
+
ws2.once("open", function open3() {
|
|
3185
3185
|
duplex._final(callback);
|
|
3186
3186
|
});
|
|
3187
3187
|
return;
|
|
@@ -3202,7 +3202,7 @@ var require_stream = __commonJS({
|
|
|
3202
3202
|
};
|
|
3203
3203
|
duplex._write = function(chunk, encoding, callback) {
|
|
3204
3204
|
if (ws2.readyState === ws2.CONNECTING) {
|
|
3205
|
-
ws2.once("open", function
|
|
3205
|
+
ws2.once("open", function open3() {
|
|
3206
3206
|
duplex._write(chunk, encoding, callback);
|
|
3207
3207
|
});
|
|
3208
3208
|
return;
|
|
@@ -5133,18 +5133,18 @@ var require_source = __commonJS({
|
|
|
5133
5133
|
}
|
|
5134
5134
|
}
|
|
5135
5135
|
});
|
|
5136
|
-
var createStyler = (
|
|
5136
|
+
var createStyler = (open3, close, parent) => {
|
|
5137
5137
|
let openAll;
|
|
5138
5138
|
let closeAll;
|
|
5139
5139
|
if (parent === void 0) {
|
|
5140
|
-
openAll =
|
|
5140
|
+
openAll = open3;
|
|
5141
5141
|
closeAll = close;
|
|
5142
5142
|
} else {
|
|
5143
|
-
openAll = parent.openAll +
|
|
5143
|
+
openAll = parent.openAll + open3;
|
|
5144
5144
|
closeAll = close + parent.closeAll;
|
|
5145
5145
|
}
|
|
5146
5146
|
return {
|
|
5147
|
-
open:
|
|
5147
|
+
open: open3,
|
|
5148
5148
|
close,
|
|
5149
5149
|
openAll,
|
|
5150
5150
|
closeAll,
|
|
@@ -13358,7 +13358,7 @@ var require_rfdc = __commonJS({
|
|
|
13358
13358
|
});
|
|
13359
13359
|
|
|
13360
13360
|
// node_modules/environment/index.js
|
|
13361
|
-
var isBrowser, isNode, isBun, isDeno, isElectron, isJsDom, isWebWorker, isDedicatedWorker, isSharedWorker, isServiceWorker,
|
|
13361
|
+
var isBrowser, isNode, isBun, isDeno, isElectron, isJsDom, isWebWorker, isDedicatedWorker, isSharedWorker, isServiceWorker, platform2, isMacOs, isWindows, isLinux, isIos, isAndroid;
|
|
13362
13362
|
var init_environment = __esm({
|
|
13363
13363
|
"node_modules/environment/index.js"() {
|
|
13364
13364
|
isBrowser = globalThis.window?.document !== void 0;
|
|
@@ -13371,12 +13371,12 @@ var init_environment = __esm({
|
|
|
13371
13371
|
isDedicatedWorker = typeof DedicatedWorkerGlobalScope !== "undefined" && globalThis instanceof DedicatedWorkerGlobalScope;
|
|
13372
13372
|
isSharedWorker = typeof SharedWorkerGlobalScope !== "undefined" && globalThis instanceof SharedWorkerGlobalScope;
|
|
13373
13373
|
isServiceWorker = typeof ServiceWorkerGlobalScope !== "undefined" && globalThis instanceof ServiceWorkerGlobalScope;
|
|
13374
|
-
|
|
13375
|
-
isMacOs =
|
|
13376
|
-
isWindows =
|
|
13377
|
-
isLinux =
|
|
13378
|
-
isIos =
|
|
13379
|
-
isAndroid =
|
|
13374
|
+
platform2 = globalThis.navigator?.userAgentData?.platform;
|
|
13375
|
+
isMacOs = platform2 === "macOS" || globalThis.navigator?.platform === "MacIntel" || globalThis.navigator?.userAgent?.includes(" Mac ") === true || globalThis.process?.platform === "darwin";
|
|
13376
|
+
isWindows = platform2 === "Windows" || globalThis.navigator?.platform === "Win32" || globalThis.process?.platform === "win32";
|
|
13377
|
+
isLinux = platform2 === "Linux" || globalThis.navigator?.platform?.startsWith("Linux") === true || globalThis.navigator?.userAgent?.includes(" Linux ") === true || globalThis.process?.platform === "linux";
|
|
13378
|
+
isIos = platform2 === "iOS" || globalThis.navigator?.platform === "MacIntel" && globalThis.navigator?.maxTouchPoints > 1 || /iPad|iPhone|iPod/.test(globalThis.navigator?.platform);
|
|
13379
|
+
isAndroid = platform2 === "Android" || globalThis.navigator?.platform === "Android" || globalThis.navigator?.userAgent?.includes(" Android ") === true || globalThis.process?.platform === "android";
|
|
13380
13380
|
}
|
|
13381
13381
|
});
|
|
13382
13382
|
|
|
@@ -13421,11 +13421,11 @@ __export(base_exports, {
|
|
|
13421
13421
|
setCwd: () => setCwd,
|
|
13422
13422
|
synchronizedOutput: () => synchronizedOutput
|
|
13423
13423
|
});
|
|
13424
|
-
var import_node_process,
|
|
13424
|
+
var import_node_process, import_node_os14, ESC, OSC, BEL, SEP, isTerminalApp, isWindows2, isTmux, cwdFunction, wrapOsc, cursorTo, cursorMove, cursorUp, cursorDown, cursorForward, cursorBackward, cursorLeft, cursorSavePosition, cursorRestorePosition, cursorGetPosition, cursorNextLine, cursorPrevLine, cursorHide, cursorShow, eraseLines, eraseEndLine, eraseStartLine, eraseLine, eraseDown, eraseUp, eraseScreen, scrollUp, scrollDown, clearScreen, clearViewport, isOldWindows, clearTerminal, enterAlternativeScreen, exitAlternativeScreen, beginSynchronizedOutput, endSynchronizedOutput, synchronizedOutput, beep, link, image, iTerm, ConEmu, setCwd;
|
|
13425
13425
|
var init_base = __esm({
|
|
13426
13426
|
"node_modules/ansi-escapes/base.js"() {
|
|
13427
13427
|
import_node_process = __toESM(require("node:process"), 1);
|
|
13428
|
-
|
|
13428
|
+
import_node_os14 = __toESM(require("node:os"), 1);
|
|
13429
13429
|
init_environment();
|
|
13430
13430
|
ESC = "\x1B[";
|
|
13431
13431
|
OSC = "\x1B]";
|
|
@@ -13505,7 +13505,7 @@ var init_base = __esm({
|
|
|
13505
13505
|
if (isBrowser || !isWindows2) {
|
|
13506
13506
|
return false;
|
|
13507
13507
|
}
|
|
13508
|
-
const parts =
|
|
13508
|
+
const parts = import_node_os14.default.release().split(".");
|
|
13509
13509
|
const major = Number(parts[0]);
|
|
13510
13510
|
const build = Number(parts[2] ?? 0);
|
|
13511
13511
|
if (major < 10) {
|
|
@@ -31566,12 +31566,12 @@ var require_form_data = __commonJS({
|
|
|
31566
31566
|
if (value.end != void 0 && value.end != Infinity && value.start != void 0) {
|
|
31567
31567
|
callback(null, value.end + 1 - (value.start ? value.start : 0));
|
|
31568
31568
|
} else {
|
|
31569
|
-
fs15.stat(value.path, function(err,
|
|
31569
|
+
fs15.stat(value.path, function(err, stat3) {
|
|
31570
31570
|
if (err) {
|
|
31571
31571
|
callback(err);
|
|
31572
31572
|
return;
|
|
31573
31573
|
}
|
|
31574
|
-
var fileSize =
|
|
31574
|
+
var fileSize = stat3.size - (value.start ? value.start : 0);
|
|
31575
31575
|
callback(null, fileSize);
|
|
31576
31576
|
});
|
|
31577
31577
|
}
|
|
@@ -34615,14 +34615,14 @@ var require_axios = __commonJS({
|
|
|
34615
34615
|
navigator: _navigator,
|
|
34616
34616
|
origin
|
|
34617
34617
|
});
|
|
34618
|
-
var
|
|
34618
|
+
var platform3 = {
|
|
34619
34619
|
...utils,
|
|
34620
34620
|
...platform$1
|
|
34621
34621
|
};
|
|
34622
34622
|
function toURLEncodedForm(data, options) {
|
|
34623
|
-
return toFormData(data, new
|
|
34623
|
+
return toFormData(data, new platform3.classes.URLSearchParams(), {
|
|
34624
34624
|
visitor: function(value, key, path29, helpers) {
|
|
34625
|
-
if (
|
|
34625
|
+
if (platform3.isNode && utils$1.isBuffer(value)) {
|
|
34626
34626
|
this.append(key, value.toString("base64"));
|
|
34627
34627
|
return false;
|
|
34628
34628
|
}
|
|
@@ -34773,8 +34773,8 @@ var require_axios = __commonJS({
|
|
|
34773
34773
|
maxContentLength: -1,
|
|
34774
34774
|
maxBodyLength: -1,
|
|
34775
34775
|
env: {
|
|
34776
|
-
FormData:
|
|
34777
|
-
Blob:
|
|
34776
|
+
FormData: platform3.classes.FormData,
|
|
34777
|
+
Blob: platform3.classes.Blob
|
|
34778
34778
|
},
|
|
34779
34779
|
validateStatus: function validateStatus(status) {
|
|
34780
34780
|
return status >= 200 && status < 300;
|
|
@@ -34915,7 +34915,7 @@ var require_axios = __commonJS({
|
|
|
34915
34915
|
}
|
|
34916
34916
|
var DATA_URL_PATTERN = /^([^,;]+\/[^,;]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
|
|
34917
34917
|
function fromDataURI(uri, asBlob, options) {
|
|
34918
|
-
const _Blob = options && options.Blob ||
|
|
34918
|
+
const _Blob = options && options.Blob || platform3.classes.Blob;
|
|
34919
34919
|
const protocol = parseProtocol(uri);
|
|
34920
34920
|
if (asBlob === void 0 && _Blob) {
|
|
34921
34921
|
asBlob = true;
|
|
@@ -35074,7 +35074,7 @@ var require_axios = __commonJS({
|
|
|
35074
35074
|
yield blob;
|
|
35075
35075
|
}
|
|
35076
35076
|
};
|
|
35077
|
-
var BOUNDARY_ALPHABET =
|
|
35077
|
+
var BOUNDARY_ALPHABET = platform3.ALPHABET.ALPHA_DIGIT + "-_";
|
|
35078
35078
|
var textEncoder = typeof TextEncoder === "function" ? new TextEncoder() : new util2.TextEncoder();
|
|
35079
35079
|
var CRLF = "\r\n";
|
|
35080
35080
|
var CRLF_BYTES = textEncoder.encode(CRLF);
|
|
@@ -35122,7 +35122,7 @@ var require_axios = __commonJS({
|
|
|
35122
35122
|
const {
|
|
35123
35123
|
tag = "form-data-boundary",
|
|
35124
35124
|
size = 25,
|
|
35125
|
-
boundary = tag + "-" +
|
|
35125
|
+
boundary = tag + "-" + platform3.generateString(size, BOUNDARY_ALPHABET)
|
|
35126
35126
|
} = options || {};
|
|
35127
35127
|
if (!utils$1.isFormData(form)) {
|
|
35128
35128
|
throw TypeError("FormData instance required");
|
|
@@ -35522,7 +35522,7 @@ var require_axios = __commonJS({
|
|
|
35522
35522
|
cache.set(key, agent);
|
|
35523
35523
|
return agent;
|
|
35524
35524
|
}
|
|
35525
|
-
var supportedProtocols =
|
|
35525
|
+
var supportedProtocols = platform3.protocols.map((protocol) => {
|
|
35526
35526
|
return protocol + ":";
|
|
35527
35527
|
});
|
|
35528
35528
|
var decodeURIComponentSafe = (value) => {
|
|
@@ -35883,7 +35883,7 @@ var require_axios = __commonJS({
|
|
|
35883
35883
|
}
|
|
35884
35884
|
});
|
|
35885
35885
|
const fullPath = buildFullPath(config2.baseURL, config2.url, config2.allowAbsoluteUrls);
|
|
35886
|
-
const parsed = new URL(fullPath,
|
|
35886
|
+
const parsed = new URL(fullPath, platform3.hasBrowserEnv ? platform3.origin : void 0);
|
|
35887
35887
|
const protocol = parsed.protocol || supportedProtocols[0];
|
|
35888
35888
|
if (protocol === "data:") {
|
|
35889
35889
|
if (config2.maxContentLength > -1) {
|
|
@@ -36284,11 +36284,11 @@ var require_axios = __commonJS({
|
|
|
36284
36284
|
}
|
|
36285
36285
|
});
|
|
36286
36286
|
};
|
|
36287
|
-
var isURLSameOrigin =
|
|
36288
|
-
url3 = new URL(url3,
|
|
36287
|
+
var isURLSameOrigin = platform3.hasStandardBrowserEnv ? /* @__PURE__ */ ((origin2, isMSIE) => (url3) => {
|
|
36288
|
+
url3 = new URL(url3, platform3.origin);
|
|
36289
36289
|
return origin2.protocol === url3.protocol && origin2.host === url3.host && (isMSIE || origin2.port === url3.port);
|
|
36290
|
-
})(new URL(
|
|
36291
|
-
var cookies =
|
|
36290
|
+
})(new URL(platform3.origin), platform3.navigator && /(msie|trident)/i.test(platform3.navigator.userAgent)) : () => true;
|
|
36291
|
+
var cookies = platform3.hasStandardBrowserEnv ? (
|
|
36292
36292
|
// Standard browser envs support document.cookie
|
|
36293
36293
|
{
|
|
36294
36294
|
write(name, value, expires, path29, domain2, secure, sameSite) {
|
|
@@ -36468,13 +36468,13 @@ var require_axios = __commonJS({
|
|
|
36468
36468
|
headers.set("Authorization", "Basic " + btoa((auth.username || "") + ":" + (auth.password ? encodeUTF8(auth.password) : "")));
|
|
36469
36469
|
}
|
|
36470
36470
|
if (utils$1.isFormData(data)) {
|
|
36471
|
-
if (
|
|
36471
|
+
if (platform3.hasStandardBrowserEnv || platform3.hasStandardBrowserWebWorkerEnv) {
|
|
36472
36472
|
headers.setContentType(void 0);
|
|
36473
36473
|
} else if (utils$1.isFunction(data.getHeaders)) {
|
|
36474
36474
|
setFormDataHeaders(headers, data.getHeaders(), own2("formDataHeaderPolicy"));
|
|
36475
36475
|
}
|
|
36476
36476
|
}
|
|
36477
|
-
if (
|
|
36477
|
+
if (platform3.hasStandardBrowserEnv) {
|
|
36478
36478
|
if (utils$1.isFunction(withXSRFToken)) {
|
|
36479
36479
|
withXSRFToken = withXSRFToken(newConfig);
|
|
36480
36480
|
}
|
|
@@ -36610,7 +36610,7 @@ var require_axios = __commonJS({
|
|
|
36610
36610
|
}
|
|
36611
36611
|
}
|
|
36612
36612
|
const protocol = parseProtocol(_config.url);
|
|
36613
|
-
if (protocol && !
|
|
36613
|
+
if (protocol && !platform3.protocols.includes(protocol)) {
|
|
36614
36614
|
reject(new AxiosError("Unsupported protocol " + protocol + ":", AxiosError.ERR_BAD_REQUEST, config2));
|
|
36615
36615
|
return;
|
|
36616
36616
|
}
|
|
@@ -36773,7 +36773,7 @@ var require_axios = __commonJS({
|
|
|
36773
36773
|
const encodeText = isFetchSupported && (typeof TextEncoder2 === "function" ? /* @__PURE__ */ ((encoder) => (str) => encoder.encode(str))(new TextEncoder2()) : async (str) => new Uint8Array(await new Request(str).arrayBuffer()));
|
|
36774
36774
|
const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
|
|
36775
36775
|
let duplexAccessed = false;
|
|
36776
|
-
const request = new Request(
|
|
36776
|
+
const request = new Request(platform3.origin, {
|
|
36777
36777
|
body: new ReadableStream2(),
|
|
36778
36778
|
method: "POST",
|
|
36779
36779
|
get duplex() {
|
|
@@ -36810,7 +36810,7 @@ var require_axios = __commonJS({
|
|
|
36810
36810
|
return body.size;
|
|
36811
36811
|
}
|
|
36812
36812
|
if (utils$1.isSpecCompliantForm(body)) {
|
|
36813
|
-
const _request = new Request(
|
|
36813
|
+
const _request = new Request(platform3.origin, {
|
|
36814
36814
|
method: "POST",
|
|
36815
36815
|
body
|
|
36816
36816
|
});
|
|
@@ -43561,6 +43561,7 @@ __export(index_exports, {
|
|
|
43561
43561
|
checkOutputContains: () => checkOutputContains,
|
|
43562
43562
|
cleanLines: () => cleanLines,
|
|
43563
43563
|
clearBinaryCache: () => clearBinaryCache,
|
|
43564
|
+
clearBrokerLogs: () => clearBrokerLogs,
|
|
43564
43565
|
clearResolveCache: () => clearResolveCache,
|
|
43565
43566
|
collectCliSession: () => collectCliSession,
|
|
43566
43567
|
collectOutput: () => collectOutput,
|
|
@@ -43614,6 +43615,7 @@ __export(index_exports, {
|
|
|
43614
43615
|
generateUniqueAgentName: () => generateUniqueAgentName,
|
|
43615
43616
|
getAgentName: () => getAgentName,
|
|
43616
43617
|
getBaseCli: () => getBaseCli,
|
|
43618
|
+
getBrokerLogDir: () => getBrokerLogDir,
|
|
43617
43619
|
getCachedRelayPtyPath: () => getCachedRelayPtyPath,
|
|
43618
43620
|
getCliDefinition: () => getCliDefinition,
|
|
43619
43621
|
getCliRegistry: () => getCliRegistry,
|
|
@@ -43657,6 +43659,7 @@ __export(index_exports, {
|
|
|
43657
43659
|
isTrajectoryTrackingAvailable: () => isTrajectoryTrackingAvailable,
|
|
43658
43660
|
isValidAgentName: () => isValidAgentName,
|
|
43659
43661
|
isWorktreeStep: () => isWorktreeStep,
|
|
43662
|
+
listBrokerLogs: () => listBrokerLogs,
|
|
43660
43663
|
listLoggedAgents: () => listLoggedAgents,
|
|
43661
43664
|
listPersonas: () => listPersonas,
|
|
43662
43665
|
listWorkflowSchedules: () => listWorkflowSchedules,
|
|
@@ -43672,6 +43675,7 @@ __export(index_exports, {
|
|
|
43672
43675
|
parseTsxStderr: () => parseTsxStderr,
|
|
43673
43676
|
parseVoteCommand: () => parseVoteCommand,
|
|
43674
43677
|
printUpdateNotification: () => printUpdateNotification,
|
|
43678
|
+
pruneBrokerLogs: () => pruneBrokerLogs,
|
|
43675
43679
|
readInbox: () => readInbox,
|
|
43676
43680
|
resetPatternMetrics: () => resetPatternMetrics,
|
|
43677
43681
|
resolveAllCustomSteps: () => resolveAllCustomSteps,
|
|
@@ -43704,6 +43708,7 @@ __export(index_exports, {
|
|
|
43704
43708
|
stripAnsi: () => stripAnsi,
|
|
43705
43709
|
stripAnsiFast: () => stripAnsiFast,
|
|
43706
43710
|
stripInjectedTaskEcho: () => stripInjectedTaskEcho,
|
|
43711
|
+
tailBrokerLog: () => tailBrokerLog,
|
|
43707
43712
|
toReleaseResult: () => toReleaseResult,
|
|
43708
43713
|
toSpawnResult: () => toSpawnResult,
|
|
43709
43714
|
trackPatternPerformance: () => trackPatternPerformance,
|
|
@@ -44235,8 +44240,8 @@ var import_node_child_process = require("node:child_process");
|
|
|
44235
44240
|
var import_node_module = require("node:module");
|
|
44236
44241
|
var import_node_url = require("node:url");
|
|
44237
44242
|
var BROKER_NAME = "agent-relay-broker";
|
|
44238
|
-
function getOptionalDepPackageName(
|
|
44239
|
-
return `@agent-relay/broker-${
|
|
44243
|
+
function getOptionalDepPackageName(platform3 = process.platform, arch = process.arch) {
|
|
44244
|
+
return `@agent-relay/broker-${platform3}-${arch}`;
|
|
44240
44245
|
}
|
|
44241
44246
|
function addUniquePath(paths, candidate) {
|
|
44242
44247
|
if (!candidate || paths.includes(candidate)) {
|
|
@@ -44426,10 +44431,18 @@ function formatBrokerNotFoundError() {
|
|
|
44426
44431
|
|
|
44427
44432
|
// packages/sdk/dist/event-bus.js
|
|
44428
44433
|
var EventBus = class {
|
|
44434
|
+
// Stored type uses `unknown` for `R` so a single Set can hold handlers
|
|
44435
|
+
// from any overload — the dispatcher casts back when it cares about a
|
|
44436
|
+
// non-void return value (see `runBeforeSpawn` in `client.ts`).
|
|
44429
44437
|
handlers = /* @__PURE__ */ new Map();
|
|
44430
44438
|
/**
|
|
44431
44439
|
* Register a handler for `event`. Returns an unsubscribe function that
|
|
44432
44440
|
* removes the handler when called.
|
|
44441
|
+
*
|
|
44442
|
+
* The `R` generic is inferred from the handler return type; callers
|
|
44443
|
+
* that don't care about the return get the default `void` shape, while
|
|
44444
|
+
* events like `beforeAgentSpawn` can pass handlers that return a
|
|
44445
|
+
* `SpawnPatch`.
|
|
44433
44446
|
*/
|
|
44434
44447
|
addListener(event, handler) {
|
|
44435
44448
|
let set2 = this.handlers.get(event);
|
|
@@ -44569,6 +44582,8 @@ var AgentRelayClient = class _AgentRelayClient {
|
|
|
44569
44582
|
child = null;
|
|
44570
44583
|
/** Lease renewal timer (only for spawned brokers). */
|
|
44571
44584
|
leaseTimer = null;
|
|
44585
|
+
brokerExitInfo = null;
|
|
44586
|
+
brokerExitListeners = /* @__PURE__ */ new Set();
|
|
44572
44587
|
workspaceKey;
|
|
44573
44588
|
/** Resolved broker URL — captured so call-site lifecycle contexts can surface it. */
|
|
44574
44589
|
baseUrl;
|
|
@@ -44584,16 +44599,9 @@ var AgentRelayClient = class _AgentRelayClient {
|
|
|
44584
44599
|
requestTimeoutMs: options.requestTimeoutMs
|
|
44585
44600
|
});
|
|
44586
44601
|
}
|
|
44587
|
-
/**
|
|
44588
|
-
* Register a listener on the client's event bus. Returns an unsubscribe
|
|
44589
|
-
* function. Equivalent to `client.eventBus.addListener(...)` but mirrors
|
|
44590
|
-
* the `AgentRelay` facade API so direct-client callers don't need to
|
|
44591
|
-
* reach through `.eventBus`.
|
|
44592
|
-
*/
|
|
44593
44602
|
addListener(event, handler) {
|
|
44594
44603
|
return this.eventBus.addListener(event, handler);
|
|
44595
44604
|
}
|
|
44596
|
-
/** Remove a previously-registered listener. */
|
|
44597
44605
|
removeListener(event, handler) {
|
|
44598
44606
|
this.eventBus.removeListener(event, handler);
|
|
44599
44607
|
}
|
|
@@ -44714,6 +44722,7 @@ var AgentRelayClient = class _AgentRelayClient {
|
|
|
44714
44722
|
...options?.eventBus ? { eventBus: options.eventBus } : {}
|
|
44715
44723
|
});
|
|
44716
44724
|
client.child = child;
|
|
44725
|
+
client.installManagedBrokerExitHandler(child, stderrLines);
|
|
44717
44726
|
const brokerExited = new Promise((_2, reject) => {
|
|
44718
44727
|
child.once("exit", (code) => {
|
|
44719
44728
|
reject(new Error(formatBrokerStartupError(`Broker process exited with code ${code} during initial handshake`, child, { binaryPath, args, cwd, stdoutLines, stderrLines })));
|
|
@@ -44734,18 +44743,13 @@ var AgentRelayClient = class _AgentRelayClient {
|
|
|
44734
44743
|
await new Promise((resolve4) => setTimeout(resolve4, 1e3));
|
|
44735
44744
|
}
|
|
44736
44745
|
}
|
|
44737
|
-
client.
|
|
44738
|
-
|
|
44739
|
-
client.
|
|
44740
|
-
|
|
44741
|
-
|
|
44742
|
-
|
|
44743
|
-
|
|
44744
|
-
if (client.leaseTimer) {
|
|
44745
|
-
clearInterval(client.leaseTimer);
|
|
44746
|
-
client.leaseTimer = null;
|
|
44747
|
-
}
|
|
44748
|
-
});
|
|
44746
|
+
if (!client.brokerExitInfo) {
|
|
44747
|
+
client.connectEvents();
|
|
44748
|
+
client.leaseTimer = setInterval(() => {
|
|
44749
|
+
client.renewLease().catch(() => {
|
|
44750
|
+
});
|
|
44751
|
+
}, 6e4);
|
|
44752
|
+
}
|
|
44749
44753
|
return client;
|
|
44750
44754
|
}
|
|
44751
44755
|
/** PID of the managed broker process, if spawned locally. */
|
|
@@ -44771,6 +44775,33 @@ var AgentRelayClient = class _AgentRelayClient {
|
|
|
44771
44775
|
onEvent(listener) {
|
|
44772
44776
|
return this.transport.onEvent(listener);
|
|
44773
44777
|
}
|
|
44778
|
+
/**
|
|
44779
|
+
* Subscribe to managed broker child-process exit.
|
|
44780
|
+
*
|
|
44781
|
+
* Clients created with `new AgentRelayClient(...)` or `connect()` do not own a
|
|
44782
|
+
* broker child process, so this is a no-op for them.
|
|
44783
|
+
*/
|
|
44784
|
+
onBrokerExit(listener) {
|
|
44785
|
+
if (!this.child && !this.brokerExitInfo) {
|
|
44786
|
+
return () => {
|
|
44787
|
+
};
|
|
44788
|
+
}
|
|
44789
|
+
this.brokerExitListeners.add(listener);
|
|
44790
|
+
if (this.brokerExitInfo) {
|
|
44791
|
+
const info = cloneBrokerExitInfo(this.brokerExitInfo);
|
|
44792
|
+
queueMicrotask(() => {
|
|
44793
|
+
if (this.brokerExitListeners.has(listener)) {
|
|
44794
|
+
try {
|
|
44795
|
+
listener(info);
|
|
44796
|
+
} catch {
|
|
44797
|
+
}
|
|
44798
|
+
}
|
|
44799
|
+
});
|
|
44800
|
+
}
|
|
44801
|
+
return () => {
|
|
44802
|
+
this.brokerExitListeners.delete(listener);
|
|
44803
|
+
};
|
|
44804
|
+
}
|
|
44774
44805
|
queryEvents(filter) {
|
|
44775
44806
|
return this.transport.queryEvents(filter);
|
|
44776
44807
|
}
|
|
@@ -45087,6 +45118,40 @@ var AgentRelayClient = class _AgentRelayClient {
|
|
|
45087
45118
|
async getConfig() {
|
|
45088
45119
|
return this.transport.request("/api/config");
|
|
45089
45120
|
}
|
|
45121
|
+
notifyBrokerExit(info) {
|
|
45122
|
+
if (this.brokerExitInfo)
|
|
45123
|
+
return;
|
|
45124
|
+
this.brokerExitInfo = cloneBrokerExitInfo(info);
|
|
45125
|
+
for (const listener of this.brokerExitListeners) {
|
|
45126
|
+
try {
|
|
45127
|
+
listener(cloneBrokerExitInfo(info));
|
|
45128
|
+
} catch {
|
|
45129
|
+
}
|
|
45130
|
+
}
|
|
45131
|
+
}
|
|
45132
|
+
installManagedBrokerExitHandler(child, stderrLines) {
|
|
45133
|
+
const handleExit = (code, signal) => {
|
|
45134
|
+
this.notifyBrokerExit({
|
|
45135
|
+
code,
|
|
45136
|
+
signal,
|
|
45137
|
+
pid: child.pid,
|
|
45138
|
+
recentStderr: [...stderrLines]
|
|
45139
|
+
});
|
|
45140
|
+
this.disconnectEvents();
|
|
45141
|
+
if (this.leaseTimer) {
|
|
45142
|
+
clearInterval(this.leaseTimer);
|
|
45143
|
+
this.leaseTimer = null;
|
|
45144
|
+
}
|
|
45145
|
+
if (this.child === child) {
|
|
45146
|
+
this.child = null;
|
|
45147
|
+
}
|
|
45148
|
+
};
|
|
45149
|
+
if (child.exitCode !== null || child.signalCode !== null) {
|
|
45150
|
+
handleExit(child.exitCode, child.signalCode);
|
|
45151
|
+
return;
|
|
45152
|
+
}
|
|
45153
|
+
child.once("exit", handleExit);
|
|
45154
|
+
}
|
|
45090
45155
|
};
|
|
45091
45156
|
async function waitForApiUrl(child, timeoutMs, debug) {
|
|
45092
45157
|
const { createInterface: createInterface2 } = await import("node:readline");
|
|
@@ -45150,6 +45215,12 @@ function pushBufferedLine(lines, line) {
|
|
|
45150
45215
|
lines.splice(0, lines.length - 40);
|
|
45151
45216
|
}
|
|
45152
45217
|
}
|
|
45218
|
+
function cloneBrokerExitInfo(info) {
|
|
45219
|
+
return {
|
|
45220
|
+
...info,
|
|
45221
|
+
recentStderr: [...info.recentStderr]
|
|
45222
|
+
};
|
|
45223
|
+
}
|
|
45153
45224
|
function formatBrokerStartupError(message, child, debug) {
|
|
45154
45225
|
const details = [
|
|
45155
45226
|
`pid=${child.pid ?? "unknown"}`,
|
|
@@ -70714,27 +70785,9 @@ var AgentRelay = class {
|
|
|
70714
70785
|
* the same events.
|
|
70715
70786
|
*/
|
|
70716
70787
|
bus = new EventBus();
|
|
70717
|
-
// ── Listener registration ───────────────────────────────────────────────
|
|
70718
|
-
/**
|
|
70719
|
-
* Register a listener for a relay lifecycle event. Returns an
|
|
70720
|
-
* unsubscribe function.
|
|
70721
|
-
*
|
|
70722
|
-
* Example:
|
|
70723
|
-
* ```ts
|
|
70724
|
-
* const off = relay.addListener('agentSpawned', (agent) => console.log(agent.name));
|
|
70725
|
-
* // later:
|
|
70726
|
-
* off();
|
|
70727
|
-
* ```
|
|
70728
|
-
*
|
|
70729
|
-
* Replaces the pre-2.x single-callback `on*` fields. Multiple listeners
|
|
70730
|
-
* can register for the same event; they fire sequentially in
|
|
70731
|
-
* registration order. Async handlers are awaited. Handler exceptions
|
|
70732
|
-
* are caught and logged; one bad listener never blocks the others.
|
|
70733
|
-
*/
|
|
70734
70788
|
addListener(event, handler) {
|
|
70735
70789
|
return this.bus.addListener(event, handler);
|
|
70736
70790
|
}
|
|
70737
|
-
/** Remove a previously-registered listener. Idempotent. */
|
|
70738
70791
|
removeListener(event, handler) {
|
|
70739
70792
|
this.bus.removeListener(event, handler);
|
|
70740
70793
|
}
|
|
@@ -72051,6 +72104,161 @@ var AgentRelay = class {
|
|
|
72051
72104
|
}
|
|
72052
72105
|
};
|
|
72053
72106
|
|
|
72107
|
+
// packages/sdk/dist/broker-logs.js
|
|
72108
|
+
var import_node_os4 = require("node:os");
|
|
72109
|
+
var import_node_path8 = require("node:path");
|
|
72110
|
+
var import_promises2 = require("node:fs/promises");
|
|
72111
|
+
var LOG_NAME_PATTERN = /^(?<brokerId>.+)\.log(?:\.(?<date>\d{4}-\d{2}-\d{2}))?$/;
|
|
72112
|
+
function getBrokerLogDir() {
|
|
72113
|
+
const home = (0, import_node_os4.homedir)();
|
|
72114
|
+
switch ((0, import_node_os4.platform)()) {
|
|
72115
|
+
case "darwin":
|
|
72116
|
+
return (0, import_node_path8.join)(home, "Library", "Logs", "agent-relay");
|
|
72117
|
+
case "win32": {
|
|
72118
|
+
const localAppData = process.env.LOCALAPPDATA ?? (0, import_node_path8.join)(home, "AppData", "Local");
|
|
72119
|
+
return (0, import_node_path8.join)(localAppData, "agent-relay", "Logs");
|
|
72120
|
+
}
|
|
72121
|
+
default: {
|
|
72122
|
+
const stateHome = process.env.XDG_STATE_HOME && process.env.XDG_STATE_HOME.length > 0 ? process.env.XDG_STATE_HOME : (0, import_node_path8.join)(home, ".local", "state");
|
|
72123
|
+
return (0, import_node_path8.join)(stateHome, "agent-relay", "logs");
|
|
72124
|
+
}
|
|
72125
|
+
}
|
|
72126
|
+
}
|
|
72127
|
+
async function listBrokerLogs(dir) {
|
|
72128
|
+
const logDir = dir ?? getBrokerLogDir();
|
|
72129
|
+
let entries;
|
|
72130
|
+
try {
|
|
72131
|
+
entries = await (0, import_promises2.readdir)(logDir);
|
|
72132
|
+
} catch (err) {
|
|
72133
|
+
if (err.code === "ENOENT")
|
|
72134
|
+
return [];
|
|
72135
|
+
throw err;
|
|
72136
|
+
}
|
|
72137
|
+
const files = [];
|
|
72138
|
+
for (const name of entries) {
|
|
72139
|
+
const match = LOG_NAME_PATTERN.exec(name);
|
|
72140
|
+
if (!match || !match.groups)
|
|
72141
|
+
continue;
|
|
72142
|
+
const fullPath = (0, import_node_path8.join)(logDir, name);
|
|
72143
|
+
let info;
|
|
72144
|
+
try {
|
|
72145
|
+
info = await (0, import_promises2.stat)(fullPath);
|
|
72146
|
+
} catch {
|
|
72147
|
+
continue;
|
|
72148
|
+
}
|
|
72149
|
+
if (!info.isFile())
|
|
72150
|
+
continue;
|
|
72151
|
+
files.push({
|
|
72152
|
+
path: fullPath,
|
|
72153
|
+
name,
|
|
72154
|
+
brokerId: match.groups.brokerId,
|
|
72155
|
+
date: match.groups.date ?? null,
|
|
72156
|
+
size: info.size,
|
|
72157
|
+
mtime: info.mtime
|
|
72158
|
+
});
|
|
72159
|
+
}
|
|
72160
|
+
files.sort((a, b2) => b2.mtime.getTime() - a.mtime.getTime());
|
|
72161
|
+
return files;
|
|
72162
|
+
}
|
|
72163
|
+
async function tailBrokerLog(brokerId, options = {}) {
|
|
72164
|
+
const lines = options.lines ?? 200;
|
|
72165
|
+
const files = (await listBrokerLogs(options.dir)).filter((f2) => f2.brokerId === brokerId);
|
|
72166
|
+
if (files.length === 0)
|
|
72167
|
+
return null;
|
|
72168
|
+
const target = files[0];
|
|
72169
|
+
return { path: target.path, content: await tailFile2(target.path, lines) };
|
|
72170
|
+
}
|
|
72171
|
+
async function pruneBrokerLogs(options = {}) {
|
|
72172
|
+
const keepDays = options.keepDays ?? 7;
|
|
72173
|
+
const cutoff = Date.now() - keepDays * 24 * 60 * 60 * 1e3;
|
|
72174
|
+
const files = await listBrokerLogs(options.dir);
|
|
72175
|
+
const removed = [];
|
|
72176
|
+
const kept = [];
|
|
72177
|
+
for (const file2 of files) {
|
|
72178
|
+
if (options.brokerId && file2.brokerId !== options.brokerId) {
|
|
72179
|
+
kept.push(file2);
|
|
72180
|
+
continue;
|
|
72181
|
+
}
|
|
72182
|
+
if (file2.date === null) {
|
|
72183
|
+
kept.push(file2);
|
|
72184
|
+
continue;
|
|
72185
|
+
}
|
|
72186
|
+
if (file2.mtime.getTime() >= cutoff) {
|
|
72187
|
+
kept.push(file2);
|
|
72188
|
+
continue;
|
|
72189
|
+
}
|
|
72190
|
+
if (!options.dryRun) {
|
|
72191
|
+
try {
|
|
72192
|
+
await (0, import_promises2.unlink)(file2.path);
|
|
72193
|
+
} catch (err) {
|
|
72194
|
+
if (err.code !== "ENOENT")
|
|
72195
|
+
throw err;
|
|
72196
|
+
}
|
|
72197
|
+
}
|
|
72198
|
+
removed.push(file2);
|
|
72199
|
+
}
|
|
72200
|
+
return { removed, kept };
|
|
72201
|
+
}
|
|
72202
|
+
async function clearBrokerLogs(options = {}) {
|
|
72203
|
+
const files = await listBrokerLogs(options.dir);
|
|
72204
|
+
const target = options.brokerId ? files.filter((f2) => f2.brokerId === options.brokerId) : files;
|
|
72205
|
+
if (options.dryRun)
|
|
72206
|
+
return target;
|
|
72207
|
+
for (const file2 of target) {
|
|
72208
|
+
try {
|
|
72209
|
+
await (0, import_promises2.unlink)(file2.path);
|
|
72210
|
+
} catch (err) {
|
|
72211
|
+
if (err.code !== "ENOENT")
|
|
72212
|
+
throw err;
|
|
72213
|
+
}
|
|
72214
|
+
}
|
|
72215
|
+
return target;
|
|
72216
|
+
}
|
|
72217
|
+
async function tailFile2(filePath, lines) {
|
|
72218
|
+
const CHUNK = 8192;
|
|
72219
|
+
let fh;
|
|
72220
|
+
try {
|
|
72221
|
+
fh = await (0, import_promises2.open)(filePath, "r");
|
|
72222
|
+
const { size } = await fh.stat();
|
|
72223
|
+
if (size === 0)
|
|
72224
|
+
return "";
|
|
72225
|
+
if (size <= CHUNK) {
|
|
72226
|
+
const buf = Buffer.alloc(size);
|
|
72227
|
+
await fh.read(buf, 0, size, 0);
|
|
72228
|
+
return tailLines(buf.toString("utf-8"), lines);
|
|
72229
|
+
}
|
|
72230
|
+
const chunks = [];
|
|
72231
|
+
let position = size;
|
|
72232
|
+
let newlines = 0;
|
|
72233
|
+
while (position > 0 && newlines <= lines) {
|
|
72234
|
+
const readSize = Math.min(CHUNK, position);
|
|
72235
|
+
position -= readSize;
|
|
72236
|
+
const buf = Buffer.alloc(readSize);
|
|
72237
|
+
await fh.read(buf, 0, readSize, position);
|
|
72238
|
+
chunks.unshift(buf);
|
|
72239
|
+
newlines += countNewlines(buf);
|
|
72240
|
+
}
|
|
72241
|
+
const combined = Buffer.concat(chunks).toString("utf-8");
|
|
72242
|
+
return tailLines(combined, lines);
|
|
72243
|
+
} finally {
|
|
72244
|
+
if (fh)
|
|
72245
|
+
await fh.close();
|
|
72246
|
+
}
|
|
72247
|
+
}
|
|
72248
|
+
function tailLines(text, count) {
|
|
72249
|
+
const split = text.split("\n");
|
|
72250
|
+
if (split.length > 0 && split[split.length - 1] === "")
|
|
72251
|
+
split.pop();
|
|
72252
|
+
return split.slice(-count).join("\n");
|
|
72253
|
+
}
|
|
72254
|
+
function countNewlines(buf) {
|
|
72255
|
+
let n = 0;
|
|
72256
|
+
for (const byte of buf)
|
|
72257
|
+
if (byte === 10)
|
|
72258
|
+
n++;
|
|
72259
|
+
return n;
|
|
72260
|
+
}
|
|
72261
|
+
|
|
72054
72262
|
// packages/sdk/dist/consensus.js
|
|
72055
72263
|
var import_node_crypto3 = require("node:crypto");
|
|
72056
72264
|
var import_node_events = require("node:events");
|
|
@@ -72905,9 +73113,9 @@ function isRestrictedAgent(agent) {
|
|
|
72905
73113
|
var import_node_child_process8 = require("node:child_process");
|
|
72906
73114
|
var import_node_crypto8 = require("node:crypto");
|
|
72907
73115
|
var import_node_fs21 = require("node:fs");
|
|
72908
|
-
var
|
|
72909
|
-
var
|
|
72910
|
-
var
|
|
73116
|
+
var import_promises9 = require("node:fs/promises");
|
|
73117
|
+
var import_node_os10 = require("node:os");
|
|
73118
|
+
var import_node_path30 = __toESM(require("node:path"), 1);
|
|
72911
73119
|
var import_chalk = __toESM(require_source(), 1);
|
|
72912
73120
|
var import_ignore2 = __toESM(require_ignore(), 1);
|
|
72913
73121
|
var import_yaml2 = __toESM(require_dist(), 1);
|
|
@@ -73108,10 +73316,10 @@ async function spawnFromEnv(options = {}) {
|
|
|
73108
73316
|
|
|
73109
73317
|
// packages/sdk/dist/cli-resolver.js
|
|
73110
73318
|
var import_node_child_process4 = require("node:child_process");
|
|
73111
|
-
var
|
|
73319
|
+
var import_promises3 = require("node:fs/promises");
|
|
73112
73320
|
var import_node_fs5 = require("node:fs");
|
|
73113
|
-
var
|
|
73114
|
-
var
|
|
73321
|
+
var import_node_path9 = require("node:path");
|
|
73322
|
+
var import_node_os5 = require("node:os");
|
|
73115
73323
|
var import_node_util2 = require("node:util");
|
|
73116
73324
|
var execFileAsync = (0, import_node_util2.promisify)(import_node_child_process4.execFile);
|
|
73117
73325
|
var resolveCache = /* @__PURE__ */ new Map();
|
|
@@ -73120,7 +73328,7 @@ function clearResolveCache() {
|
|
|
73120
73328
|
}
|
|
73121
73329
|
function expandHome2(p2) {
|
|
73122
73330
|
if (p2.startsWith("~/")) {
|
|
73123
|
-
return (0,
|
|
73331
|
+
return (0, import_node_path9.join)((0, import_node_os5.homedir)(), p2.slice(2));
|
|
73124
73332
|
}
|
|
73125
73333
|
return p2;
|
|
73126
73334
|
}
|
|
@@ -73149,9 +73357,9 @@ async function resolveCli(cli) {
|
|
|
73149
73357
|
if (seen.has(expanded))
|
|
73150
73358
|
continue;
|
|
73151
73359
|
seen.add(expanded);
|
|
73152
|
-
const candidate = (0,
|
|
73360
|
+
const candidate = (0, import_node_path9.join)(expanded, binary);
|
|
73153
73361
|
try {
|
|
73154
|
-
await (0,
|
|
73362
|
+
await (0, import_promises3.access)(candidate, import_promises3.constants.X_OK);
|
|
73155
73363
|
const result = { binary, path: candidate };
|
|
73156
73364
|
resolveCache.set(cli, result);
|
|
73157
73365
|
return result;
|
|
@@ -73188,7 +73396,7 @@ function resolveCliSync(cli) {
|
|
|
73188
73396
|
if (seen.has(expanded))
|
|
73189
73397
|
continue;
|
|
73190
73398
|
seen.add(expanded);
|
|
73191
|
-
const candidate = (0,
|
|
73399
|
+
const candidate = (0, import_node_path9.join)(expanded, binary);
|
|
73192
73400
|
try {
|
|
73193
73401
|
(0, import_node_fs5.accessSync)(candidate, import_node_fs5.constants.X_OK);
|
|
73194
73402
|
const result = { binary, path: candidate };
|
|
@@ -73295,11 +73503,11 @@ function isProxyEnabled(agentDef, swarmConfig) {
|
|
|
73295
73503
|
|
|
73296
73504
|
// packages/sdk/dist/workflows/custom-steps.js
|
|
73297
73505
|
var import_node_fs6 = require("node:fs");
|
|
73298
|
-
var
|
|
73506
|
+
var import_node_path10 = __toESM(require("node:path"), 1);
|
|
73299
73507
|
var import_yaml = __toESM(require_dist(), 1);
|
|
73300
73508
|
var CUSTOM_STEPS_FILE = ".relay/steps.yaml";
|
|
73301
73509
|
function loadCustomSteps(cwd) {
|
|
73302
|
-
const stepsPath =
|
|
73510
|
+
const stepsPath = import_node_path10.default.join(cwd, CUSTOM_STEPS_FILE);
|
|
73303
73511
|
const steps = /* @__PURE__ */ new Map();
|
|
73304
73512
|
if (!(0, import_node_fs6.existsSync)(stepsPath)) {
|
|
73305
73513
|
return steps;
|
|
@@ -73555,20 +73763,20 @@ function resolveAllCustomSteps(steps, customSteps) {
|
|
|
73555
73763
|
return steps.map((step) => resolveCustomStep(step, customSteps));
|
|
73556
73764
|
}
|
|
73557
73765
|
function customStepsFileExists(cwd) {
|
|
73558
|
-
return (0, import_node_fs6.existsSync)(
|
|
73766
|
+
return (0, import_node_fs6.existsSync)(import_node_path10.default.join(cwd, CUSTOM_STEPS_FILE));
|
|
73559
73767
|
}
|
|
73560
73768
|
function getCustomStepsPath(cwd) {
|
|
73561
|
-
return
|
|
73769
|
+
return import_node_path10.default.join(cwd, CUSTOM_STEPS_FILE);
|
|
73562
73770
|
}
|
|
73563
73771
|
|
|
73564
73772
|
// packages/sdk/dist/provisioner/index.js
|
|
73565
73773
|
var import_node_fs16 = require("node:fs");
|
|
73566
|
-
var
|
|
73774
|
+
var import_node_path24 = __toESM(require("node:path"), 1);
|
|
73567
73775
|
|
|
73568
73776
|
// packages/sdk/dist/provisioner/audit.js
|
|
73569
|
-
var
|
|
73570
|
-
var
|
|
73571
|
-
var DEFAULT_PERMISSION_AUDIT_RELATIVE_PATH =
|
|
73777
|
+
var import_promises4 = require("node:fs/promises");
|
|
73778
|
+
var import_node_path11 = __toESM(require("node:path"), 1);
|
|
73779
|
+
var DEFAULT_PERMISSION_AUDIT_RELATIVE_PATH = import_node_path11.default.join(".agent-relay", "permission-audit.json");
|
|
73572
73780
|
function isPlainObject4(value) {
|
|
73573
73781
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
73574
73782
|
}
|
|
@@ -73591,7 +73799,7 @@ function sanitizeJsonValue(value, key) {
|
|
|
73591
73799
|
return String(value);
|
|
73592
73800
|
}
|
|
73593
73801
|
function getDefaultPermissionAuditPath(projectDir) {
|
|
73594
|
-
return
|
|
73802
|
+
return import_node_path11.default.resolve(projectDir, DEFAULT_PERMISSION_AUDIT_RELATIVE_PATH);
|
|
73595
73803
|
}
|
|
73596
73804
|
var PermissionAuditLog = class {
|
|
73597
73805
|
entries = [];
|
|
@@ -73616,8 +73824,8 @@ var PermissionAuditLog = class {
|
|
|
73616
73824
|
};
|
|
73617
73825
|
}
|
|
73618
73826
|
async writeTo(filePath) {
|
|
73619
|
-
await (0,
|
|
73620
|
-
await (0,
|
|
73827
|
+
await (0, import_promises4.mkdir)(import_node_path11.default.dirname(filePath), { recursive: true });
|
|
73828
|
+
await (0, import_promises4.writeFile)(filePath, `${JSON.stringify(this.toJSON(), null, 2)}
|
|
73621
73829
|
`, "utf8");
|
|
73622
73830
|
}
|
|
73623
73831
|
summary() {
|
|
@@ -73638,7 +73846,7 @@ var PermissionAuditLog = class {
|
|
|
73638
73846
|
// packages/sdk/dist/provisioner/compiler.js
|
|
73639
73847
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
73640
73848
|
var import_node_fs7 = require("node:fs");
|
|
73641
|
-
var
|
|
73849
|
+
var import_node_path12 = __toESM(require("node:path"), 1);
|
|
73642
73850
|
var SKIPPED_DIRS = /* @__PURE__ */ new Set([".git", ".relay", "node_modules"]);
|
|
73643
73851
|
function cleanPatterns(content) {
|
|
73644
73852
|
return content.split(/\r?\n/u).map((line) => line.trim()).filter((line) => line !== "" && !line.startsWith("#"));
|
|
@@ -73681,15 +73889,15 @@ function createMatcher(patterns) {
|
|
|
73681
73889
|
return matcher;
|
|
73682
73890
|
}
|
|
73683
73891
|
function loadDotfileRules(projectDir, agentName) {
|
|
73684
|
-
const resolvedProjectDir =
|
|
73892
|
+
const resolvedProjectDir = import_node_path12.default.resolve(projectDir);
|
|
73685
73893
|
return {
|
|
73686
73894
|
deny: unique([
|
|
73687
|
-
...readPatternFile(
|
|
73688
|
-
...readPatternFile(
|
|
73895
|
+
...readPatternFile(import_node_path12.default.join(resolvedProjectDir, ".agentignore")),
|
|
73896
|
+
...readPatternFile(import_node_path12.default.join(resolvedProjectDir, `.${agentName}.agentignore`))
|
|
73689
73897
|
]),
|
|
73690
73898
|
readonly: unique([
|
|
73691
|
-
...readPatternFile(
|
|
73692
|
-
...readPatternFile(
|
|
73899
|
+
...readPatternFile(import_node_path12.default.join(resolvedProjectDir, ".agentreadonly")),
|
|
73900
|
+
...readPatternFile(import_node_path12.default.join(resolvedProjectDir, `.${agentName}.agentreadonly`))
|
|
73693
73901
|
])
|
|
73694
73902
|
};
|
|
73695
73903
|
}
|
|
@@ -73704,9 +73912,9 @@ function resolveScopedWorkdirPatterns(projectDir, workdir) {
|
|
|
73704
73912
|
if (!workdir) {
|
|
73705
73913
|
return void 0;
|
|
73706
73914
|
}
|
|
73707
|
-
const resolvedProjectDir =
|
|
73708
|
-
const resolvedWorkdir =
|
|
73709
|
-
const relativeWorkdir = normalizeRelativePath(
|
|
73915
|
+
const resolvedProjectDir = import_node_path12.default.resolve(projectDir);
|
|
73916
|
+
const resolvedWorkdir = import_node_path12.default.resolve(resolvedProjectDir, workdir);
|
|
73917
|
+
const relativeWorkdir = normalizeRelativePath(import_node_path12.default.relative(resolvedProjectDir, resolvedWorkdir));
|
|
73710
73918
|
if (relativeWorkdir === "" || relativeWorkdir === ".") {
|
|
73711
73919
|
return void 0;
|
|
73712
73920
|
}
|
|
@@ -73724,8 +73932,8 @@ function walkProjectFiles(projectDir, currentDir = projectDir, files = []) {
|
|
|
73724
73932
|
if (entry.isDirectory() && SKIPPED_DIRS.has(entry.name)) {
|
|
73725
73933
|
continue;
|
|
73726
73934
|
}
|
|
73727
|
-
const fullPath =
|
|
73728
|
-
const relativePath = normalizeRelativePath(
|
|
73935
|
+
const fullPath = import_node_path12.default.join(currentDir, entry.name);
|
|
73936
|
+
const relativePath = normalizeRelativePath(import_node_path12.default.relative(projectDir, fullPath));
|
|
73729
73937
|
if (entry.isDirectory()) {
|
|
73730
73938
|
walkProjectFiles(projectDir, fullPath, files);
|
|
73731
73939
|
continue;
|
|
@@ -73769,7 +73977,7 @@ function buildSources(dotfileRules, preset, presetRules, fileRules, rawScopes, i
|
|
|
73769
73977
|
function buildAcl(agentName, readonlyPaths, readwritePaths, deniedPaths) {
|
|
73770
73978
|
const aclMap = /* @__PURE__ */ new Map();
|
|
73771
73979
|
const addRule = (relativePath, rule) => {
|
|
73772
|
-
const aclDir = normalizeAclDir(
|
|
73980
|
+
const aclDir = normalizeAclDir(import_node_path12.default.posix.dirname(normalizeRelativePath(relativePath)));
|
|
73773
73981
|
const rules = aclMap.get(aclDir) ?? /* @__PURE__ */ new Set();
|
|
73774
73982
|
rules.add(rule);
|
|
73775
73983
|
aclMap.set(aclDir, rules);
|
|
@@ -73783,13 +73991,13 @@ function buildAcl(agentName, readonlyPaths, readwritePaths, deniedPaths) {
|
|
|
73783
73991
|
}
|
|
73784
73992
|
const deniedDirs = /* @__PURE__ */ new Map();
|
|
73785
73993
|
for (const relativePath of deniedPaths) {
|
|
73786
|
-
const aclDir = normalizeAclDir(
|
|
73994
|
+
const aclDir = normalizeAclDir(import_node_path12.default.posix.dirname(normalizeRelativePath(relativePath)));
|
|
73787
73995
|
const summary = deniedDirs.get(aclDir) ?? { denied: 0, allowed: 0 };
|
|
73788
73996
|
summary.denied += 1;
|
|
73789
73997
|
deniedDirs.set(aclDir, summary);
|
|
73790
73998
|
}
|
|
73791
73999
|
for (const relativePath of [...readonlyPaths, ...readwritePaths]) {
|
|
73792
|
-
const aclDir = normalizeAclDir(
|
|
74000
|
+
const aclDir = normalizeAclDir(import_node_path12.default.posix.dirname(normalizeRelativePath(relativePath)));
|
|
73793
74001
|
const summary = deniedDirs.get(aclDir) ?? { denied: 0, allowed: 0 };
|
|
73794
74002
|
summary.allowed += 1;
|
|
73795
74003
|
deniedDirs.set(aclDir, summary);
|
|
@@ -73839,7 +74047,7 @@ function compileAgentPermissions(input) {
|
|
|
73839
74047
|
const permissions = input.permissions ?? {};
|
|
73840
74048
|
const effectiveAccess = permissions.access ?? "readwrite";
|
|
73841
74049
|
const inherited = effectiveAccess !== "full" && permissions.inherit !== false;
|
|
73842
|
-
const projectDir =
|
|
74050
|
+
const projectDir = import_node_path12.default.resolve(input.projectDir);
|
|
73843
74051
|
const scopedInput = input;
|
|
73844
74052
|
const dotfileRules = inherited ? loadDotfileRules(projectDir, input.agentName) : { deny: [], readonly: [] };
|
|
73845
74053
|
const presetRules = expandPreset(effectiveAccess, {
|
|
@@ -73943,16 +74151,16 @@ function mergePermissionSources(dotfileScopes, yamlScopes, rawScopes) {
|
|
|
73943
74151
|
var import_node_child_process5 = require("node:child_process");
|
|
73944
74152
|
var import_node_crypto4 = require("node:crypto");
|
|
73945
74153
|
var import_node_fs8 = require("node:fs");
|
|
73946
|
-
var
|
|
74154
|
+
var import_promises5 = require("node:fs/promises");
|
|
73947
74155
|
var import_node_https = __toESM(require("node:https"), 1);
|
|
73948
|
-
var
|
|
73949
|
-
var
|
|
74156
|
+
var import_node_os6 = __toESM(require("node:os"), 1);
|
|
74157
|
+
var import_node_path13 = __toESM(require("node:path"), 1);
|
|
73950
74158
|
var RELAYFILE_VERSION = "0.1.6";
|
|
73951
74159
|
var RELEASE_BASE_URL = "https://github.com/AgentWorkforce/relayfile/releases/download";
|
|
73952
74160
|
var CHECKSUMS_FILE = "checksums.txt";
|
|
73953
|
-
var CACHE_DIR =
|
|
73954
|
-
var CACHE_PATH =
|
|
73955
|
-
var VERSION_PATH =
|
|
74161
|
+
var CACHE_DIR = import_node_path13.default.join(import_node_os6.default.homedir(), ".agent-relay", "bin");
|
|
74162
|
+
var CACHE_PATH = import_node_path13.default.join(CACHE_DIR, "relayfile-mount");
|
|
74163
|
+
var VERSION_PATH = import_node_path13.default.join(CACHE_DIR, "relayfile-mount.version");
|
|
73956
74164
|
var SUPPORTED_TARGETS = ["darwin-arm64", "darwin-amd64", "linux-arm64", "linux-amd64"].join(", ");
|
|
73957
74165
|
var PLATFORM_ARCH_MAP = {
|
|
73958
74166
|
"darwin:arm64": "darwin-arm64",
|
|
@@ -73964,9 +74172,9 @@ function ensureCacheDir() {
|
|
|
73964
74172
|
(0, import_node_fs8.mkdirSync)(CACHE_DIR, { recursive: true });
|
|
73965
74173
|
}
|
|
73966
74174
|
function getRelayfileTarget() {
|
|
73967
|
-
const target = PLATFORM_ARCH_MAP[`${
|
|
74175
|
+
const target = PLATFORM_ARCH_MAP[`${import_node_os6.default.platform()}:${import_node_os6.default.arch()}`];
|
|
73968
74176
|
if (!target) {
|
|
73969
|
-
throw new Error(`Unsupported platform for relayfile-mount: ${
|
|
74177
|
+
throw new Error(`Unsupported platform for relayfile-mount: ${import_node_os6.default.platform()}-${import_node_os6.default.arch()}. Supported targets: ${SUPPORTED_TARGETS}.`);
|
|
73970
74178
|
}
|
|
73971
74179
|
return target;
|
|
73972
74180
|
}
|
|
@@ -74079,7 +74287,7 @@ function getExpectedChecksum(checksumContent, binaryName) {
|
|
|
74079
74287
|
if (!match) {
|
|
74080
74288
|
continue;
|
|
74081
74289
|
}
|
|
74082
|
-
const entryName =
|
|
74290
|
+
const entryName = import_node_path13.default.basename(match[2].trim());
|
|
74083
74291
|
if (entryName === binaryName) {
|
|
74084
74292
|
return match[1].toLowerCase();
|
|
74085
74293
|
}
|
|
@@ -74096,7 +74304,7 @@ async function verifyChecksum(filePath, binaryName) {
|
|
|
74096
74304
|
}
|
|
74097
74305
|
}
|
|
74098
74306
|
function resignBinaryForMacOS(binaryPath) {
|
|
74099
|
-
if (
|
|
74307
|
+
if (import_node_os6.default.platform() !== "darwin") {
|
|
74100
74308
|
return;
|
|
74101
74309
|
}
|
|
74102
74310
|
try {
|
|
@@ -74109,7 +74317,7 @@ async function ensureRelayfileMountBinary(binaryPath) {
|
|
|
74109
74317
|
return binaryPath;
|
|
74110
74318
|
}
|
|
74111
74319
|
if (process.env.RELAYFILE_ROOT) {
|
|
74112
|
-
return
|
|
74320
|
+
return import_node_path13.default.join(process.env.RELAYFILE_ROOT, "bin", "relayfile-mount");
|
|
74113
74321
|
}
|
|
74114
74322
|
const target = getRelayfileTarget();
|
|
74115
74323
|
const binaryName = `relayfile-mount-${target}`;
|
|
@@ -74121,7 +74329,7 @@ async function ensureRelayfileMountBinary(binaryPath) {
|
|
|
74121
74329
|
}
|
|
74122
74330
|
return CACHE_PATH;
|
|
74123
74331
|
}
|
|
74124
|
-
const tempPath =
|
|
74332
|
+
const tempPath = import_node_path13.default.join(CACHE_DIR, `relayfile-mount.${process.pid}.${Date.now()}.download`);
|
|
74125
74333
|
try {
|
|
74126
74334
|
await downloadBinary(downloadUrl, tempPath);
|
|
74127
74335
|
await verifyChecksum(tempPath, binaryName);
|
|
@@ -74193,7 +74401,7 @@ async function ensureRelayfileMount(config2) {
|
|
|
74193
74401
|
if (!(0, import_node_fs8.existsSync)(binaryPath)) {
|
|
74194
74402
|
throw new Error(`missing relayfile mount binary: ${binaryPath}`);
|
|
74195
74403
|
}
|
|
74196
|
-
const mountPoint = config2.mountPoint ?? await (0,
|
|
74404
|
+
const mountPoint = config2.mountPoint ?? await (0, import_promises5.mkdtemp)(import_node_path13.default.join(import_node_os6.default.tmpdir(), `relayfile-mount-${config2.workspace}-`));
|
|
74197
74405
|
(0, import_node_fs8.mkdirSync)(mountPoint, { recursive: true });
|
|
74198
74406
|
const mountBaseArgs = [
|
|
74199
74407
|
"--base-url",
|
|
@@ -74237,12 +74445,12 @@ async function ensureRelayfileMount(config2) {
|
|
|
74237
74445
|
if (mountProc) {
|
|
74238
74446
|
await stopMountProcess(mountProc).catch(() => void 0);
|
|
74239
74447
|
}
|
|
74240
|
-
await (0,
|
|
74448
|
+
await (0, import_promises5.rm)(mountPoint, { recursive: true, force: true }).catch(() => void 0);
|
|
74241
74449
|
const message = error51 instanceof Error ? error51.message : String(error51);
|
|
74242
74450
|
throw new Error(`${startupPhase} failed for ${config2.workspace}: ${message}`);
|
|
74243
74451
|
}
|
|
74244
74452
|
if (!mountProc || typeof mountProc.pid !== "number") {
|
|
74245
|
-
await (0,
|
|
74453
|
+
await (0, import_promises5.rm)(mountPoint, { recursive: true, force: true }).catch(() => void 0);
|
|
74246
74454
|
throw new Error(`mount process startup failed for ${config2.workspace}: missing process id`);
|
|
74247
74455
|
}
|
|
74248
74456
|
let stopped = false;
|
|
@@ -74255,7 +74463,7 @@ async function ensureRelayfileMount(config2) {
|
|
|
74255
74463
|
}
|
|
74256
74464
|
stopped = true;
|
|
74257
74465
|
await stopMountProcess(mountProc).catch(() => void 0);
|
|
74258
|
-
await (0,
|
|
74466
|
+
await (0, import_promises5.rm)(mountPoint, { recursive: true, force: true }).catch(() => void 0);
|
|
74259
74467
|
}
|
|
74260
74468
|
};
|
|
74261
74469
|
}
|
|
@@ -75101,7 +75309,7 @@ var debugEnabled2 = (() => {
|
|
|
75101
75309
|
|
|
75102
75310
|
// packages/sdk/dist/provisioner/seeder.js
|
|
75103
75311
|
var import_node_fs15 = __toESM(require("node:fs"), 1);
|
|
75104
|
-
var
|
|
75312
|
+
var import_node_path23 = __toESM(require("node:path"), 1);
|
|
75105
75313
|
|
|
75106
75314
|
// node_modules/tar/dist/esm/index.min.js
|
|
75107
75315
|
var import_events = __toESM(require("events"), 1);
|
|
@@ -75109,7 +75317,7 @@ var import_fs = __toESM(require("fs"), 1);
|
|
|
75109
75317
|
var import_node_events2 = require("node:events");
|
|
75110
75318
|
var import_node_stream = __toESM(require("node:stream"), 1);
|
|
75111
75319
|
var import_node_string_decoder = require("node:string_decoder");
|
|
75112
|
-
var
|
|
75320
|
+
var import_node_path14 = __toESM(require("node:path"), 1);
|
|
75113
75321
|
var import_node_fs9 = __toESM(require("node:fs"), 1);
|
|
75114
75322
|
var import_path = require("path");
|
|
75115
75323
|
var import_events2 = require("events");
|
|
@@ -75117,27 +75325,27 @@ var import_assert = __toESM(require("assert"), 1);
|
|
|
75117
75325
|
var import_buffer = require("buffer");
|
|
75118
75326
|
var vs = __toESM(require("zlib"), 1);
|
|
75119
75327
|
var import_zlib = __toESM(require("zlib"), 1);
|
|
75120
|
-
var import_node_path14 = require("node:path");
|
|
75121
75328
|
var import_node_path15 = require("node:path");
|
|
75329
|
+
var import_node_path16 = require("node:path");
|
|
75122
75330
|
var import_fs2 = __toESM(require("fs"), 1);
|
|
75123
75331
|
var import_fs3 = __toESM(require("fs"), 1);
|
|
75124
75332
|
var import_path2 = __toESM(require("path"), 1);
|
|
75125
|
-
var
|
|
75333
|
+
var import_node_path17 = require("node:path");
|
|
75126
75334
|
var import_path3 = __toESM(require("path"), 1);
|
|
75127
75335
|
var import_node_fs10 = __toESM(require("node:fs"), 1);
|
|
75128
75336
|
var import_node_assert = __toESM(require("node:assert"), 1);
|
|
75129
75337
|
var import_node_crypto5 = require("node:crypto");
|
|
75130
75338
|
var import_node_fs11 = __toESM(require("node:fs"), 1);
|
|
75131
|
-
var
|
|
75339
|
+
var import_node_path18 = __toESM(require("node:path"), 1);
|
|
75132
75340
|
var import_fs4 = __toESM(require("fs"), 1);
|
|
75133
75341
|
var import_node_fs12 = __toESM(require("node:fs"), 1);
|
|
75134
|
-
var import_node_path18 = __toESM(require("node:path"), 1);
|
|
75135
|
-
var import_node_fs13 = __toESM(require("node:fs"), 1);
|
|
75136
|
-
var import_promises5 = __toESM(require("node:fs/promises"), 1);
|
|
75137
75342
|
var import_node_path19 = __toESM(require("node:path"), 1);
|
|
75138
|
-
var
|
|
75343
|
+
var import_node_fs13 = __toESM(require("node:fs"), 1);
|
|
75344
|
+
var import_promises6 = __toESM(require("node:fs/promises"), 1);
|
|
75345
|
+
var import_node_path20 = __toESM(require("node:path"), 1);
|
|
75346
|
+
var import_node_path21 = require("node:path");
|
|
75139
75347
|
var import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
75140
|
-
var
|
|
75348
|
+
var import_node_path22 = __toESM(require("node:path"), 1);
|
|
75141
75349
|
var vr = Object.defineProperty;
|
|
75142
75350
|
var Mr = (s3, t) => {
|
|
75143
75351
|
for (var e in t) vr(s3, e, { get: t[e], enumerable: true });
|
|
@@ -76030,12 +76238,12 @@ var k = class {
|
|
|
76030
76238
|
}
|
|
76031
76239
|
};
|
|
76032
76240
|
var ln = (s3, t) => {
|
|
76033
|
-
let i = s3, r = "", n, o =
|
|
76241
|
+
let i = s3, r = "", n, o = import_node_path15.posix.parse(s3).root || ".";
|
|
76034
76242
|
if (Buffer.byteLength(i) < 100) n = [i, r, false];
|
|
76035
76243
|
else {
|
|
76036
|
-
r =
|
|
76244
|
+
r = import_node_path15.posix.dirname(i), i = import_node_path15.posix.basename(i);
|
|
76037
76245
|
do
|
|
76038
|
-
Buffer.byteLength(i) <= 100 && Buffer.byteLength(r) <= t ? n = [i, r, false] : Buffer.byteLength(i) > 100 && Buffer.byteLength(r) <= t ? n = [i.slice(0, 99), r, true] : (i =
|
|
76246
|
+
Buffer.byteLength(i) <= 100 && Buffer.byteLength(r) <= t ? n = [i, r, false] : Buffer.byteLength(i) > 100 && Buffer.byteLength(r) <= t ? n = [i.slice(0, 99), r, true] : (i = import_node_path15.posix.join(import_node_path15.posix.basename(r), i), r = import_node_path15.posix.dirname(r));
|
|
76039
76247
|
while (r !== o && n === void 0);
|
|
76040
76248
|
n || (n = [s3.slice(0, 99), "", true]);
|
|
76041
76249
|
}
|
|
@@ -76081,7 +76289,7 @@ var ct = class s {
|
|
|
76081
76289
|
if (t === "") return Buffer.allocUnsafe(0);
|
|
76082
76290
|
let e = Buffer.byteLength(t), i = 512 * Math.ceil(1 + e / 512), r = Buffer.allocUnsafe(i);
|
|
76083
76291
|
for (let n = 0; n < 512; n++) r[n] = 0;
|
|
76084
|
-
new k({ path: ("PaxHeader/" + (0,
|
|
76292
|
+
new k({ path: ("PaxHeader/" + (0, import_node_path16.basename)(this.path ?? "")).slice(0, 99), mode: this.mode || 420, uid: this.uid, gid: this.gid, size: e, mtime: this.mtime, type: this.global ? "GlobalExtendedHeader" : "ExtendedHeader", linkpath: "", uname: this.uname || "", gname: this.gname || "", devmaj: 0, devmin: 0, atime: this.atime, ctime: this.ctime }).encode(r), r.write(t, 512, e, "utf8");
|
|
76085
76293
|
for (let n = e + 512; n < r.length; n++) r[n] = 0;
|
|
76086
76294
|
return r;
|
|
76087
76295
|
}
|
|
@@ -76493,7 +76701,7 @@ var Ct = K(An, In, (s3) => new st(s3), (s3) => new st(s3), (s3, t) => {
|
|
|
76493
76701
|
t?.length && $i(s3, t), s3.noResume || Dn(s3);
|
|
76494
76702
|
});
|
|
76495
76703
|
var Xi = (s3, t, e) => (s3 &= 4095, e && (s3 = (s3 | 384) & -19), t && (s3 & 256 && (s3 |= 64), s3 & 32 && (s3 |= 8), s3 & 4 && (s3 |= 1)), s3);
|
|
76496
|
-
var { isAbsolute: kn, parse: Ks } =
|
|
76704
|
+
var { isAbsolute: kn, parse: Ks } = import_node_path17.win32;
|
|
76497
76705
|
var ce = (s3) => {
|
|
76498
76706
|
let t = "", e = Ks(s3);
|
|
76499
76707
|
for (; kn(s3) || e.root; ) {
|
|
@@ -77202,11 +77410,11 @@ var Wn = (s3, t) => {
|
|
|
77202
77410
|
};
|
|
77203
77411
|
var hr = (s3, t) => {
|
|
77204
77412
|
t.forEach((e) => {
|
|
77205
|
-
e.charAt(0) === "@" ? Ct({ file:
|
|
77413
|
+
e.charAt(0) === "@" ? Ct({ file: import_node_path14.default.resolve(s3.cwd, e.slice(1)), sync: true, noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
|
|
77206
77414
|
}), s3.end();
|
|
77207
77415
|
};
|
|
77208
77416
|
var ar = async (s3, t) => {
|
|
77209
|
-
for (let e of t) e.charAt(0) === "@" ? await Ct({ file:
|
|
77417
|
+
for (let e of t) e.charAt(0) === "@" ? await Ct({ file: import_node_path14.default.resolve(String(s3.cwd), e.slice(1)), noResume: true, onReadEntry: (i) => {
|
|
77210
77418
|
s3.add(i);
|
|
77211
77419
|
} }) : s3.add(e);
|
|
77212
77420
|
s3.end();
|
|
@@ -77244,13 +77452,13 @@ var pi = (s3, t, e, i) => {
|
|
|
77244
77452
|
});
|
|
77245
77453
|
};
|
|
77246
77454
|
var qn = (s3, t, e, i, r) => {
|
|
77247
|
-
if (t.isDirectory()) us(
|
|
77455
|
+
if (t.isDirectory()) us(import_node_path19.default.resolve(s3, t.name), e, i, (n) => {
|
|
77248
77456
|
if (n) return r(n);
|
|
77249
|
-
let o =
|
|
77457
|
+
let o = import_node_path19.default.resolve(s3, t.name);
|
|
77250
77458
|
pi(o, e, i, r);
|
|
77251
77459
|
});
|
|
77252
77460
|
else {
|
|
77253
|
-
let n =
|
|
77461
|
+
let n = import_node_path19.default.resolve(s3, t.name);
|
|
77254
77462
|
pi(n, e, i, r);
|
|
77255
77463
|
}
|
|
77256
77464
|
};
|
|
@@ -77271,7 +77479,7 @@ var us = (s3, t, e, i) => {
|
|
|
77271
77479
|
});
|
|
77272
77480
|
};
|
|
77273
77481
|
var Qn = (s3, t, e, i) => {
|
|
77274
|
-
t.isDirectory() && ms(
|
|
77482
|
+
t.isDirectory() && ms(import_node_path19.default.resolve(s3, t.name), e, i), ds(import_node_path19.default.resolve(s3, t.name), e, i);
|
|
77275
77483
|
};
|
|
77276
77484
|
var ms = (s3, t, e) => {
|
|
77277
77485
|
let i;
|
|
@@ -77320,13 +77528,13 @@ var wr = (s3, t, e) => {
|
|
|
77320
77528
|
E ? e(E) : x && a ? us(x, o, h, (Le) => S(Le)) : n ? import_node_fs13.default.chmod(s3, r, e) : e();
|
|
77321
77529
|
};
|
|
77322
77530
|
if (s3 === d) return jn(s3, S);
|
|
77323
|
-
if (l) return
|
|
77324
|
-
let N = f(
|
|
77531
|
+
if (l) return import_promises6.default.mkdir(s3, { mode: r, recursive: true }).then((E) => S(null, E ?? void 0), S);
|
|
77532
|
+
let N = f(import_node_path20.default.relative(d, s3)).split("/");
|
|
77325
77533
|
ps(d, N, r, c, d, void 0, S);
|
|
77326
77534
|
};
|
|
77327
77535
|
var ps = (s3, t, e, i, r, n, o) => {
|
|
77328
77536
|
if (t.length === 0) return o(null, n);
|
|
77329
|
-
let h = t.shift(), a = f(
|
|
77537
|
+
let h = t.shift(), a = f(import_node_path20.default.resolve(s3 + "/" + h));
|
|
77330
77538
|
import_node_fs13.default.mkdir(a, e, Sr(a, t, e, i, r, n, o));
|
|
77331
77539
|
};
|
|
77332
77540
|
var Sr = (s3, t, e, i, r, n, o) => (h) => {
|
|
@@ -77360,9 +77568,9 @@ var yr = (s3, t) => {
|
|
|
77360
77568
|
};
|
|
77361
77569
|
if (s3 === c) return to(c), d();
|
|
77362
77570
|
if (a) return d(import_node_fs13.default.mkdirSync(s3, { mode: i, recursive: true }) ?? void 0);
|
|
77363
|
-
let T = f(
|
|
77571
|
+
let T = f(import_node_path20.default.relative(c, s3)).split("/"), N;
|
|
77364
77572
|
for (let E = T.shift(), x = c; E && (x += "/" + E); E = T.shift()) {
|
|
77365
|
-
x = f(
|
|
77573
|
+
x = f(import_node_path20.default.resolve(x));
|
|
77366
77574
|
try {
|
|
77367
77575
|
import_node_fs13.default.mkdirSync(x, i), N = N || x;
|
|
77368
77576
|
} catch {
|
|
@@ -77391,14 +77599,14 @@ var eo = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
|
|
|
77391
77599
|
var io = eo === "win32";
|
|
77392
77600
|
var so = (s3) => s3.split("/").slice(0, -1).reduce((e, i) => {
|
|
77393
77601
|
let r = e.at(-1);
|
|
77394
|
-
return r !== void 0 && (i = (0,
|
|
77602
|
+
return r !== void 0 && (i = (0, import_node_path21.join)(r, i)), e.push(i || "/"), e;
|
|
77395
77603
|
}, []);
|
|
77396
77604
|
var Si = class {
|
|
77397
77605
|
#t = /* @__PURE__ */ new Map();
|
|
77398
77606
|
#i = /* @__PURE__ */ new Map();
|
|
77399
77607
|
#s = /* @__PURE__ */ new Set();
|
|
77400
77608
|
reserve(t, e) {
|
|
77401
|
-
t = io ? ["win32 parallelization disabled"] : t.map((r) => mt((0,
|
|
77609
|
+
t = io ? ["win32 parallelization disabled"] : t.map((r) => mt((0, import_node_path21.join)(gr(r))));
|
|
77402
77610
|
let i = new Set(t.map((r) => so(r)).reduce((r, n) => r.concat(n)));
|
|
77403
77611
|
this.#i.set(e, { dirs: i, paths: t });
|
|
77404
77612
|
for (let r of t) {
|
|
@@ -77538,7 +77746,7 @@ var qt = class extends st {
|
|
|
77538
77746
|
if (t.preserveOwner) throw new TypeError("cannot preserve owner in archive and also set owner explicitly");
|
|
77539
77747
|
this.uid = t.uid, this.gid = t.gid, this.setOwner = true;
|
|
77540
77748
|
} else this.uid = void 0, this.gid = void 0, this.setOwner = false;
|
|
77541
|
-
this.preserveOwner = t.preserveOwner === void 0 && typeof t.uid != "number" ? !!(process.getuid && process.getuid() === 0) : !!t.preserveOwner, this.processUid = (this.preserveOwner || this.setOwner) && process.getuid ? process.getuid() : void 0, this.processGid = (this.preserveOwner || this.setOwner) && process.getgid ? process.getgid() : void 0, this.maxDepth = typeof t.maxDepth == "number" ? t.maxDepth : oo, this.forceChown = t.forceChown === true, this.win32 = !!t.win32 || Te, this.newer = !!t.newer, this.keep = !!t.keep, this.noMtime = !!t.noMtime, this.preservePaths = !!t.preservePaths, this.unlink = !!t.unlink, this.cwd = f(
|
|
77749
|
+
this.preserveOwner = t.preserveOwner === void 0 && typeof t.uid != "number" ? !!(process.getuid && process.getuid() === 0) : !!t.preserveOwner, this.processUid = (this.preserveOwner || this.setOwner) && process.getuid ? process.getuid() : void 0, this.processGid = (this.preserveOwner || this.setOwner) && process.getgid ? process.getgid() : void 0, this.maxDepth = typeof t.maxDepth == "number" ? t.maxDepth : oo, this.forceChown = t.forceChown === true, this.win32 = !!t.win32 || Te, this.newer = !!t.newer, this.keep = !!t.keep, this.noMtime = !!t.noMtime, this.preservePaths = !!t.preservePaths, this.unlink = !!t.unlink, this.cwd = f(import_node_path18.default.resolve(t.cwd || process.cwd())), this.strip = Number(t.strip) || 0, this.processUmask = this.chmod ? typeof t.processUmask == "number" ? t.processUmask : _r() : 0, this.umask = typeof t.umask == "number" ? t.umask : this.processUmask, this.dmode = t.dmode || 511 & ~this.umask, this.fmode = t.fmode || 438 & ~this.umask, this.on("entry", (e) => this[Or](e));
|
|
77542
77750
|
}
|
|
77543
77751
|
warn(t, e, i = {}) {
|
|
77544
77752
|
return (t === "TAR_BAD_ARCHIVE" || t === "TAR_ABORT") && (i.recoverable = false), super.warn(t, e, i);
|
|
@@ -77552,7 +77760,7 @@ var qt = class extends st {
|
|
|
77552
77760
|
let [n, o] = ce(i), h = o.replaceAll(/\\/g, "/").split("/");
|
|
77553
77761
|
if (h.includes("..") || Te && /^[a-z]:\.\.$/i.test(h[0] ?? "")) {
|
|
77554
77762
|
if (e === "path" || r === "Link") return this.warn("TAR_ENTRY_ERROR", `${e} contains '..'`, { entry: t, [e]: i }), false;
|
|
77555
|
-
let a =
|
|
77763
|
+
let a = import_node_path18.default.posix.dirname(t.path), l = import_node_path18.default.posix.normalize(import_node_path18.default.posix.join(a, h.join("/")));
|
|
77556
77764
|
if (l.startsWith("../") || l === "..") return this.warn("TAR_ENTRY_ERROR", `${e} escapes extraction directory`, { entry: t, [e]: i }), false;
|
|
77557
77765
|
}
|
|
77558
77766
|
return n && (t[e] = String(o), this.warn("TAR_ENTRY_INFO", `stripping ${n} from absolute ${e}`, { entry: t, [e]: i })), true;
|
|
@@ -77570,12 +77778,12 @@ var qt = class extends st {
|
|
|
77570
77778
|
}
|
|
77571
77779
|
if (isFinite(this.maxDepth) && i.length > this.maxDepth) return this.warn("TAR_ENTRY_ERROR", "path excessively deep", { entry: t, path: e, depth: i.length, maxDepth: this.maxDepth }), false;
|
|
77572
77780
|
if (!this[ws](t, "path") || !this[ws](t, "linkpath")) return false;
|
|
77573
|
-
if (t.absolute =
|
|
77781
|
+
if (t.absolute = import_node_path18.default.isAbsolute(t.path) ? f(import_node_path18.default.resolve(t.path)) : f(import_node_path18.default.resolve(this.cwd, t.path)), !this.preservePaths && typeof t.absolute == "string" && t.absolute.indexOf(this.cwd + "/") !== 0 && t.absolute !== this.cwd) return this.warn("TAR_ENTRY_ERROR", "path escaped extraction target", { entry: t, path: f(t.path), resolvedPath: t.absolute, cwd: this.cwd }), false;
|
|
77574
77782
|
if (t.absolute === this.cwd && t.type !== "Directory" && t.type !== "GNUDumpDir") return false;
|
|
77575
77783
|
if (this.win32) {
|
|
77576
|
-
let { root: r } =
|
|
77784
|
+
let { root: r } = import_node_path18.default.win32.parse(String(t.absolute));
|
|
77577
77785
|
t.absolute = r + Qi(String(t.absolute).slice(r.length));
|
|
77578
|
-
let { root: n } =
|
|
77786
|
+
let { root: n } = import_node_path18.default.win32.parse(t.path);
|
|
77579
77787
|
t.path = n + Qi(t.path.slice(n.length));
|
|
77580
77788
|
}
|
|
77581
77789
|
return true;
|
|
@@ -77663,13 +77871,13 @@ var qt = class extends st {
|
|
|
77663
77871
|
t.unsupported = true, this.warn("TAR_ENTRY_UNSUPPORTED", `unsupported entry type: ${t.type}`, { entry: t }), t.resume();
|
|
77664
77872
|
}
|
|
77665
77873
|
[xr](t, e) {
|
|
77666
|
-
let i = f(
|
|
77874
|
+
let i = f(import_node_path18.default.relative(this.cwd, import_node_path18.default.resolve(import_node_path18.default.dirname(String(t.absolute)), String(t.linkpath)))).split("/");
|
|
77667
77875
|
this[Re](t, this.cwd, i, () => this[Ri](t, String(t.linkpath), "symlink", e), (r) => {
|
|
77668
77876
|
this[O](r, t), e();
|
|
77669
77877
|
});
|
|
77670
77878
|
}
|
|
77671
77879
|
[Lr](t, e) {
|
|
77672
|
-
let i = f(
|
|
77880
|
+
let i = f(import_node_path18.default.resolve(this.cwd, String(t.linkpath))), r = f(String(t.linkpath)).split("/");
|
|
77673
77881
|
this[Re](t, this.cwd, r, () => this[Ri](t, i, "link", e), (n) => {
|
|
77674
77882
|
this[O](n, t), e();
|
|
77675
77883
|
});
|
|
@@ -77677,10 +77885,10 @@ var qt = class extends st {
|
|
|
77677
77885
|
[Re](t, e, i, r, n) {
|
|
77678
77886
|
let o = i.shift();
|
|
77679
77887
|
if (this.preservePaths || o === void 0) return r();
|
|
77680
|
-
let h =
|
|
77888
|
+
let h = import_node_path18.default.resolve(e, o);
|
|
77681
77889
|
import_node_fs11.default.lstat(h, (a, l) => {
|
|
77682
77890
|
if (a) return r();
|
|
77683
|
-
if (l?.isSymbolicLink()) return n(new St(h,
|
|
77891
|
+
if (l?.isSymbolicLink()) return n(new St(h, import_node_path18.default.resolve(h, i.join("/"))));
|
|
77684
77892
|
this[Re](t, h, i, r, n);
|
|
77685
77893
|
});
|
|
77686
77894
|
}
|
|
@@ -77714,7 +77922,7 @@ var qt = class extends st {
|
|
|
77714
77922
|
});
|
|
77715
77923
|
}, n = () => {
|
|
77716
77924
|
if (t.absolute !== this.cwd) {
|
|
77717
|
-
let h = f(
|
|
77925
|
+
let h = f(import_node_path18.default.dirname(String(t.absolute)));
|
|
77718
77926
|
if (h !== this.cwd) return this[yt](h, this.dmode, (a) => {
|
|
77719
77927
|
if (a) {
|
|
77720
77928
|
this[O](a, t), i();
|
|
@@ -77789,7 +77997,7 @@ var xe = class extends qt {
|
|
|
77789
77997
|
this[Oe] = true;
|
|
77790
77998
|
}
|
|
77791
77999
|
if (t.absolute !== this.cwd) {
|
|
77792
|
-
let n = f(
|
|
78000
|
+
let n = f(import_node_path18.default.dirname(String(t.absolute)));
|
|
77793
78001
|
if (n !== this.cwd) {
|
|
77794
78002
|
let o = this[yt](n, this.dmode);
|
|
77795
78003
|
if (o) return this[O](o, t);
|
|
@@ -77889,10 +78097,10 @@ var xe = class extends qt {
|
|
|
77889
78097
|
if (this.preservePaths || i.length === 0) return r();
|
|
77890
78098
|
let o = e;
|
|
77891
78099
|
for (let h of i) {
|
|
77892
|
-
o =
|
|
78100
|
+
o = import_node_path18.default.resolve(o, h);
|
|
77893
78101
|
let [a, l] = ye(() => import_node_fs11.default.lstatSync(o));
|
|
77894
78102
|
if (a) return r();
|
|
77895
|
-
if (l.isSymbolicLink()) return n(new St(o,
|
|
78103
|
+
if (l.isSymbolicLink()) return n(new St(o, import_node_path18.default.resolve(e, i.join("/"))));
|
|
77896
78104
|
}
|
|
77897
78105
|
r();
|
|
77898
78106
|
}
|
|
@@ -77996,11 +78204,11 @@ var po = (s3, t) => {
|
|
|
77996
78204
|
};
|
|
77997
78205
|
var Eo = (s3, t) => {
|
|
77998
78206
|
t.forEach((e) => {
|
|
77999
|
-
e.charAt(0) === "@" ? Ct({ file:
|
|
78207
|
+
e.charAt(0) === "@" ? Ct({ file: import_node_path22.default.resolve(s3.cwd, e.slice(1)), sync: true, noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
|
|
78000
78208
|
}), s3.end();
|
|
78001
78209
|
};
|
|
78002
78210
|
var wo = async (s3, t) => {
|
|
78003
|
-
for (let e of t) e.charAt(0) === "@" ? await Ct({ file:
|
|
78211
|
+
for (let e of t) e.charAt(0) === "@" ? await Ct({ file: import_node_path22.default.resolve(String(s3.cwd), e.slice(1)), noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
|
|
78004
78212
|
s3.end();
|
|
78005
78213
|
};
|
|
78006
78214
|
var vt = K(uo, po, () => {
|
|
@@ -78077,7 +78285,7 @@ function isUtf8(raw) {
|
|
|
78077
78285
|
}
|
|
78078
78286
|
}
|
|
78079
78287
|
function buildSeedFilePayload(filePath, rootDir) {
|
|
78080
|
-
const relative3 =
|
|
78288
|
+
const relative3 = import_node_path23.default.relative(rootDir, filePath).split(import_node_path23.default.sep).join("/");
|
|
78081
78289
|
const raw = import_node_fs15.default.readFileSync(filePath);
|
|
78082
78290
|
if (isUtf8(raw)) {
|
|
78083
78291
|
return { path: `/${relative3}`, content: raw.toString("utf8"), encoding: "utf-8" };
|
|
@@ -78085,7 +78293,7 @@ function buildSeedFilePayload(filePath, rootDir) {
|
|
|
78085
78293
|
return { path: `/${relative3}`, content: raw.toString("base64"), encoding: "base64" };
|
|
78086
78294
|
}
|
|
78087
78295
|
function collectSeedPaths(rootDir, currentRelative, excludeDirs, output) {
|
|
78088
|
-
const absoluteDir =
|
|
78296
|
+
const absoluteDir = import_node_path23.default.join(rootDir, currentRelative);
|
|
78089
78297
|
const entries = import_node_fs15.default.readdirSync(absoluteDir, { withFileTypes: true });
|
|
78090
78298
|
for (const entry of entries) {
|
|
78091
78299
|
if (excludeDirs.has(entry.name)) {
|
|
@@ -78095,7 +78303,7 @@ function collectSeedPaths(rootDir, currentRelative, excludeDirs, output) {
|
|
|
78095
78303
|
continue;
|
|
78096
78304
|
}
|
|
78097
78305
|
const nextRelative = currentRelative ? `${currentRelative}/${entry.name}` : entry.name;
|
|
78098
|
-
const absolutePath =
|
|
78306
|
+
const absolutePath = import_node_path23.default.join(rootDir, nextRelative);
|
|
78099
78307
|
if (excludeDirs.has(nextRelative)) {
|
|
78100
78308
|
continue;
|
|
78101
78309
|
}
|
|
@@ -78110,15 +78318,15 @@ function collectSeedPaths(rootDir, currentRelative, excludeDirs, output) {
|
|
|
78110
78318
|
if (entry.isSymbolicLink()) {
|
|
78111
78319
|
try {
|
|
78112
78320
|
const resolved = import_node_fs15.default.realpathSync(absolutePath);
|
|
78113
|
-
if (!resolved.startsWith(rootDir +
|
|
78321
|
+
if (!resolved.startsWith(rootDir + import_node_path23.default.sep) && resolved !== rootDir) {
|
|
78114
78322
|
continue;
|
|
78115
78323
|
}
|
|
78116
|
-
const
|
|
78117
|
-
if (
|
|
78324
|
+
const stat3 = import_node_fs15.default.statSync(resolved);
|
|
78325
|
+
if (stat3.isDirectory()) {
|
|
78118
78326
|
collectSeedPaths(rootDir, nextRelative, excludeDirs, output);
|
|
78119
78327
|
continue;
|
|
78120
78328
|
}
|
|
78121
|
-
if (
|
|
78329
|
+
if (stat3.isFile()) {
|
|
78122
78330
|
output.push(absolutePath);
|
|
78123
78331
|
}
|
|
78124
78332
|
} catch {
|
|
@@ -78246,7 +78454,7 @@ async function seedAclRules(baseUrl, token, workspaceId, aclRules) {
|
|
|
78246
78454
|
}
|
|
78247
78455
|
async function seedWorkspace(baseUrl, token, workspaceId, projectDir, excludeDirs) {
|
|
78248
78456
|
const workspace = normalizeWorkspaceId2(workspaceId);
|
|
78249
|
-
const rootDir =
|
|
78457
|
+
const rootDir = import_node_path23.default.resolve(projectDir);
|
|
78250
78458
|
const excludes = normalizeExcludeDirs([...DEFAULT_EXCLUDED_DIRS, ...excludeDirs]);
|
|
78251
78459
|
const seedPaths = [];
|
|
78252
78460
|
collectSeedPaths(rootDir, "", excludes, seedPaths);
|
|
@@ -78419,7 +78627,7 @@ function buildSummary(compilations) {
|
|
|
78419
78627
|
function buildAgentResult(projectDir, name, token, compiled, mountPoint) {
|
|
78420
78628
|
return {
|
|
78421
78629
|
name,
|
|
78422
|
-
tokenPath:
|
|
78630
|
+
tokenPath: import_node_path24.default.resolve(projectDir, ".relay", "tokens", `${name}.jwt`),
|
|
78423
78631
|
token,
|
|
78424
78632
|
scopes: [...compiled.scopes],
|
|
78425
78633
|
compiled,
|
|
@@ -78478,7 +78686,7 @@ async function provisionWorkflowAgents(config2) {
|
|
|
78478
78686
|
action: "mint",
|
|
78479
78687
|
details: {
|
|
78480
78688
|
workspace: config2.workspace,
|
|
78481
|
-
jwtPath:
|
|
78689
|
+
jwtPath: import_node_path24.default.resolve(config2.projectDir, ".relay", "tokens", `${agent.name}.jwt`),
|
|
78482
78690
|
scopeCount: compiled.scopes.length,
|
|
78483
78691
|
scopes: [...compiled.scopes],
|
|
78484
78692
|
ttlSeconds: config2.tokenTtlSeconds ?? null
|
|
@@ -78556,7 +78764,7 @@ async function provisionWorkflowAgents(config2) {
|
|
|
78556
78764
|
});
|
|
78557
78765
|
}
|
|
78558
78766
|
if (!config2.skipMount) {
|
|
78559
|
-
const mountRoot =
|
|
78767
|
+
const mountRoot = import_node_path24.default.resolve(config2.mountBaseDir ?? import_node_path24.default.join(config2.projectDir, ".relay"));
|
|
78560
78768
|
try {
|
|
78561
78769
|
for (const agent of agents) {
|
|
78562
78770
|
const token = tokens.get(agent.name);
|
|
@@ -78569,7 +78777,7 @@ async function provisionWorkflowAgents(config2) {
|
|
|
78569
78777
|
relayfileUrl: config2.relayfileBaseUrl,
|
|
78570
78778
|
workspace: config2.workspace,
|
|
78571
78779
|
token,
|
|
78572
|
-
mountPoint:
|
|
78780
|
+
mountPoint: import_node_path24.default.join(mountRoot, `workspace-${sanitizePathComponent(config2.workspace)}-${sanitizePathComponent(agent.name)}`)
|
|
78573
78781
|
});
|
|
78574
78782
|
mounts.set(agent.name, mountHandle);
|
|
78575
78783
|
agentResults[agent.name] = buildAgentResult(config2.projectDir, agent.name, token, compiled, mountHandle.mountPoint);
|
|
@@ -78624,13 +78832,13 @@ async function provisionWorkflowAgents(config2) {
|
|
|
78624
78832
|
|
|
78625
78833
|
// packages/sdk/dist/workflows/collectors/claude.js
|
|
78626
78834
|
var import_node_fs17 = require("node:fs");
|
|
78627
|
-
var
|
|
78628
|
-
var
|
|
78629
|
-
var
|
|
78835
|
+
var import_promises7 = require("node:fs/promises");
|
|
78836
|
+
var import_node_os7 = require("node:os");
|
|
78837
|
+
var import_node_path25 = __toESM(require("node:path"), 1);
|
|
78630
78838
|
var import_node_readline = require("node:readline");
|
|
78631
|
-
var CLAUDE_HOME =
|
|
78632
|
-
var HISTORY_PATH =
|
|
78633
|
-
var PROJECTS_PATH =
|
|
78839
|
+
var CLAUDE_HOME = import_node_path25.default.join((0, import_node_os7.homedir)(), ".claude");
|
|
78840
|
+
var HISTORY_PATH = import_node_path25.default.join(CLAUDE_HOME, "history.jsonl");
|
|
78841
|
+
var PROJECTS_PATH = import_node_path25.default.join(CLAUDE_HOME, "projects");
|
|
78634
78842
|
var HISTORY_LOOKBACK_MS = 5e3;
|
|
78635
78843
|
var ClaudeCodeCollector = class {
|
|
78636
78844
|
canCollect() {
|
|
@@ -78641,7 +78849,7 @@ var ClaudeCodeCollector = class {
|
|
|
78641
78849
|
if (!historyEntry) {
|
|
78642
78850
|
return null;
|
|
78643
78851
|
}
|
|
78644
|
-
const sessionPath =
|
|
78852
|
+
const sessionPath = import_node_path25.default.join(PROJECTS_PATH, encodeProjectPath(historyEntry.project), `${historyEntry.sessionId}.jsonl`);
|
|
78645
78853
|
if (!await isReadableFileAsync(sessionPath)) {
|
|
78646
78854
|
return null;
|
|
78647
78855
|
}
|
|
@@ -78926,7 +79134,7 @@ function isReadableDirectory(dirPath) {
|
|
|
78926
79134
|
}
|
|
78927
79135
|
async function isReadableFileAsync(filePath) {
|
|
78928
79136
|
try {
|
|
78929
|
-
await (0,
|
|
79137
|
+
await (0, import_promises7.access)(filePath);
|
|
78930
79138
|
return true;
|
|
78931
79139
|
} catch {
|
|
78932
79140
|
return false;
|
|
@@ -78935,13 +79143,13 @@ async function isReadableFileAsync(filePath) {
|
|
|
78935
79143
|
|
|
78936
79144
|
// packages/sdk/dist/workflows/collectors/codex.js
|
|
78937
79145
|
var import_node_fs18 = __toESM(require("node:fs"), 1);
|
|
78938
|
-
var
|
|
78939
|
-
var
|
|
79146
|
+
var import_node_os8 = __toESM(require("node:os"), 1);
|
|
79147
|
+
var import_node_path26 = __toESM(require("node:path"), 1);
|
|
78940
79148
|
var import_node_module2 = require("node:module");
|
|
78941
79149
|
var require2 = (0, import_node_module2.createRequire)(import_meta_url);
|
|
78942
|
-
var CODEX_HOME =
|
|
78943
|
-
var DEFAULT_HISTORY_PATH =
|
|
78944
|
-
var DEFAULT_STATE_PATH =
|
|
79150
|
+
var CODEX_HOME = import_node_path26.default.join(import_node_os8.default.homedir(), ".codex");
|
|
79151
|
+
var DEFAULT_HISTORY_PATH = import_node_path26.default.join(CODEX_HOME, "history.jsonl");
|
|
79152
|
+
var DEFAULT_STATE_PATH = import_node_path26.default.join(CODEX_HOME, "state_5.sqlite");
|
|
78945
79153
|
function loadBetterSqlite3() {
|
|
78946
79154
|
try {
|
|
78947
79155
|
return require2("better-sqlite3");
|
|
@@ -79175,11 +79383,11 @@ var CodexCollector = class {
|
|
|
79175
79383
|
|
|
79176
79384
|
// packages/sdk/dist/workflows/collectors/opencode.js
|
|
79177
79385
|
var import_node_fs19 = __toESM(require("node:fs"), 1);
|
|
79178
|
-
var
|
|
79179
|
-
var
|
|
79386
|
+
var import_node_os9 = __toESM(require("node:os"), 1);
|
|
79387
|
+
var import_node_path27 = __toESM(require("node:path"), 1);
|
|
79180
79388
|
var import_node_module3 = require("node:module");
|
|
79181
79389
|
var require3 = (0, import_node_module3.createRequire)(import_meta_url);
|
|
79182
|
-
var OPENCODE_DB_PATH =
|
|
79390
|
+
var OPENCODE_DB_PATH = import_node_path27.default.join(import_node_os9.default.homedir(), ".local", "share", "opencode", "opencode.db");
|
|
79183
79391
|
var MATCH_WINDOW_GRACE_MS = 5e3;
|
|
79184
79392
|
var ERROR_LINE_PATTERN = /^(Error|error:|Command failed|FAIL)\b/;
|
|
79185
79393
|
function loadDatabaseConstructor() {
|
|
@@ -79920,7 +80128,7 @@ var import_node_child_process7 = require("node:child_process");
|
|
|
79920
80128
|
// packages/sdk/dist/workflows/verification.js
|
|
79921
80129
|
var import_node_child_process6 = require("node:child_process");
|
|
79922
80130
|
var import_node_fs20 = require("node:fs");
|
|
79923
|
-
var
|
|
80131
|
+
var import_node_path28 = __toESM(require("node:path"), 1);
|
|
79924
80132
|
var WorkflowCompletionError = class extends Error {
|
|
79925
80133
|
completionReason;
|
|
79926
80134
|
constructor(message, completionReason) {
|
|
@@ -80112,9 +80320,9 @@ function checkCustom(value, output, cwd = process.cwd()) {
|
|
|
80112
80320
|
}
|
|
80113
80321
|
}
|
|
80114
80322
|
function checkFileExists(filePath, cwd = process.cwd()) {
|
|
80115
|
-
const normalizedCwd =
|
|
80116
|
-
const resolved =
|
|
80117
|
-
if (!
|
|
80323
|
+
const normalizedCwd = import_node_path28.default.resolve(cwd);
|
|
80324
|
+
const resolved = import_node_path28.default.isAbsolute(filePath) ? import_node_path28.default.resolve(filePath) : import_node_path28.default.resolve(normalizedCwd, filePath);
|
|
80325
|
+
if (!import_node_path28.default.isAbsolute(filePath) && !resolved.startsWith(normalizedCwd + import_node_path28.default.sep) && resolved !== normalizedCwd) {
|
|
80118
80326
|
return false;
|
|
80119
80327
|
}
|
|
80120
80328
|
return (0, import_node_fs20.existsSync)(resolved);
|
|
@@ -80947,14 +81155,14 @@ function delay(ms2) {
|
|
|
80947
81155
|
}
|
|
80948
81156
|
|
|
80949
81157
|
// packages/sdk/dist/workflows/trajectory.js
|
|
80950
|
-
var
|
|
81158
|
+
var import_node_path29 = require("node:path");
|
|
80951
81159
|
|
|
80952
81160
|
// node_modules/agent-trajectories/dist/chunk-WMJRBQB4.js
|
|
80953
81161
|
var import_module = require("module");
|
|
80954
81162
|
var import_crypto = require("crypto");
|
|
80955
81163
|
var import_crypto2 = require("crypto");
|
|
80956
81164
|
var import_fs5 = require("fs");
|
|
80957
|
-
var
|
|
81165
|
+
var import_promises8 = require("fs/promises");
|
|
80958
81166
|
var import_path4 = require("path");
|
|
80959
81167
|
var ALPHABET = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
80960
81168
|
var ID_LENGTH = 12;
|
|
@@ -81551,9 +81759,9 @@ var FileStorage = class {
|
|
|
81551
81759
|
* Initialize storage directories
|
|
81552
81760
|
*/
|
|
81553
81761
|
async initialize() {
|
|
81554
|
-
await (0,
|
|
81555
|
-
await (0,
|
|
81556
|
-
await (0,
|
|
81762
|
+
await (0, import_promises8.mkdir)(this.trajectoriesDir, { recursive: true });
|
|
81763
|
+
await (0, import_promises8.mkdir)(this.activeDir, { recursive: true });
|
|
81764
|
+
await (0, import_promises8.mkdir)(this.completedDir, { recursive: true });
|
|
81557
81765
|
if (!(0, import_fs5.existsSync)(this.indexPath)) {
|
|
81558
81766
|
await withIndexLock(this.indexPath, async () => {
|
|
81559
81767
|
if (!(0, import_fs5.existsSync)(this.indexPath)) {
|
|
@@ -81592,7 +81800,7 @@ var FileStorage = class {
|
|
|
81592
81800
|
const before = Object.keys(index.trajectories).length;
|
|
81593
81801
|
const discovered = [];
|
|
81594
81802
|
try {
|
|
81595
|
-
const activeFiles = await (0,
|
|
81803
|
+
const activeFiles = await (0, import_promises8.readdir)(this.activeDir);
|
|
81596
81804
|
for (const file2 of activeFiles) {
|
|
81597
81805
|
if (!file2.endsWith(".json")) continue;
|
|
81598
81806
|
discovered.push((0, import_path4.join)(this.activeDir, file2));
|
|
@@ -81678,13 +81886,13 @@ var FileStorage = class {
|
|
|
81678
81886
|
if (candidates.length === 0) {
|
|
81679
81887
|
return { moved: [], targetDir };
|
|
81680
81888
|
}
|
|
81681
|
-
await (0,
|
|
81889
|
+
await (0, import_promises8.mkdir)(targetDir, { recursive: true });
|
|
81682
81890
|
const moved = [];
|
|
81683
81891
|
for (const failure of candidates) {
|
|
81684
81892
|
const dest = await this.resolveQuarantineDest(failure.path, targetDir);
|
|
81685
81893
|
try {
|
|
81686
|
-
await (0,
|
|
81687
|
-
await (0,
|
|
81894
|
+
await (0, import_promises8.mkdir)((0, import_path4.dirname)(dest), { recursive: true });
|
|
81895
|
+
await (0, import_promises8.rename)(failure.path, dest);
|
|
81688
81896
|
moved.push(failure);
|
|
81689
81897
|
} catch (error51) {
|
|
81690
81898
|
console.warn(
|
|
@@ -81726,7 +81934,7 @@ var FileStorage = class {
|
|
|
81726
81934
|
async walkJsonFilesInto(dir, out) {
|
|
81727
81935
|
let entries;
|
|
81728
81936
|
try {
|
|
81729
|
-
entries = await (0,
|
|
81937
|
+
entries = await (0, import_promises8.readdir)(dir, { withFileTypes: true });
|
|
81730
81938
|
} catch (error51) {
|
|
81731
81939
|
if (error51.code === "ENOENT") return;
|
|
81732
81940
|
throw error51;
|
|
@@ -81766,19 +81974,19 @@ var FileStorage = class {
|
|
|
81766
81974
|
this.completedDir,
|
|
81767
81975
|
`${date5.getFullYear()}-${String(date5.getMonth() + 1).padStart(2, "0")}`
|
|
81768
81976
|
);
|
|
81769
|
-
await (0,
|
|
81977
|
+
await (0, import_promises8.mkdir)(monthDir, { recursive: true });
|
|
81770
81978
|
filePath = (0, import_path4.join)(monthDir, `${trajectory2.id}.json`);
|
|
81771
81979
|
const activePath = (0, import_path4.join)(this.activeDir, `${trajectory2.id}.json`);
|
|
81772
81980
|
if ((0, import_fs5.existsSync)(activePath)) {
|
|
81773
|
-
await (0,
|
|
81981
|
+
await (0, import_promises8.unlink)(activePath);
|
|
81774
81982
|
}
|
|
81775
81983
|
const mdPath = (0, import_path4.join)(monthDir, `${trajectory2.id}.md`);
|
|
81776
81984
|
const markdown = exportToMarkdown(trajectory2);
|
|
81777
|
-
await (0,
|
|
81985
|
+
await (0, import_promises8.writeFile)(mdPath, markdown, "utf-8");
|
|
81778
81986
|
} else {
|
|
81779
81987
|
filePath = (0, import_path4.join)(this.activeDir, `${trajectory2.id}.json`);
|
|
81780
81988
|
}
|
|
81781
|
-
await (0,
|
|
81989
|
+
await (0, import_promises8.writeFile)(filePath, JSON.stringify(trajectory2, null, 2), "utf-8");
|
|
81782
81990
|
await this.updateIndex(trajectory2, filePath);
|
|
81783
81991
|
}
|
|
81784
81992
|
/**
|
|
@@ -81799,7 +82007,7 @@ var FileStorage = class {
|
|
|
81799
82007
|
if ((0, import_fs5.existsSync)(flatPath)) {
|
|
81800
82008
|
return this.readTrajectoryOrNull(flatPath);
|
|
81801
82009
|
}
|
|
81802
|
-
const months = await (0,
|
|
82010
|
+
const months = await (0, import_promises8.readdir)(this.completedDir);
|
|
81803
82011
|
for (const month of months) {
|
|
81804
82012
|
const filePath = (0, import_path4.join)(this.completedDir, month, `${id}.json`);
|
|
81805
82013
|
if ((0, import_fs5.existsSync)(filePath)) {
|
|
@@ -81818,7 +82026,7 @@ var FileStorage = class {
|
|
|
81818
82026
|
*/
|
|
81819
82027
|
async getActive() {
|
|
81820
82028
|
try {
|
|
81821
|
-
const files = await (0,
|
|
82029
|
+
const files = await (0, import_promises8.readdir)(this.activeDir);
|
|
81822
82030
|
const jsonFiles = files.filter((f2) => f2.endsWith(".json"));
|
|
81823
82031
|
if (jsonFiles.length === 0) {
|
|
81824
82032
|
return null;
|
|
@@ -81903,16 +82111,16 @@ var FileStorage = class {
|
|
|
81903
82111
|
async delete(id) {
|
|
81904
82112
|
const activePath = (0, import_path4.join)(this.activeDir, `${id}.json`);
|
|
81905
82113
|
if ((0, import_fs5.existsSync)(activePath)) {
|
|
81906
|
-
await (0,
|
|
82114
|
+
await (0, import_promises8.unlink)(activePath);
|
|
81907
82115
|
}
|
|
81908
82116
|
await withIndexLock(this.indexPath, async () => {
|
|
81909
82117
|
const index = await this.loadIndex();
|
|
81910
82118
|
const entry = index.trajectories[id];
|
|
81911
82119
|
if (entry?.path && (0, import_fs5.existsSync)(entry.path)) {
|
|
81912
|
-
await (0,
|
|
82120
|
+
await (0, import_promises8.unlink)(entry.path);
|
|
81913
82121
|
const mdPath = entry.path.replace(".json", ".md");
|
|
81914
82122
|
if ((0, import_fs5.existsSync)(mdPath)) {
|
|
81915
|
-
await (0,
|
|
82123
|
+
await (0, import_promises8.unlink)(mdPath);
|
|
81916
82124
|
}
|
|
81917
82125
|
}
|
|
81918
82126
|
delete index.trajectories[id];
|
|
@@ -81965,7 +82173,7 @@ var FileStorage = class {
|
|
|
81965
82173
|
async readTrajectoryFile(path28) {
|
|
81966
82174
|
let content;
|
|
81967
82175
|
try {
|
|
81968
|
-
content = await (0,
|
|
82176
|
+
content = await (0, import_promises8.readFile)(path28, "utf-8");
|
|
81969
82177
|
} catch (error51) {
|
|
81970
82178
|
return { ok: false, reason: "io_error", path: path28, error: error51 };
|
|
81971
82179
|
}
|
|
@@ -82011,7 +82219,7 @@ var FileStorage = class {
|
|
|
82011
82219
|
async loadIndex() {
|
|
82012
82220
|
let content;
|
|
82013
82221
|
try {
|
|
82014
|
-
content = await (0,
|
|
82222
|
+
content = await (0, import_promises8.readFile)(this.indexPath, "utf-8");
|
|
82015
82223
|
} catch (error51) {
|
|
82016
82224
|
if (error51.code !== "ENOENT") {
|
|
82017
82225
|
console.error(
|
|
@@ -82054,8 +82262,8 @@ var FileStorage = class {
|
|
|
82054
82262
|
async saveIndex(index) {
|
|
82055
82263
|
index.lastUpdated = (/* @__PURE__ */ new Date()).toISOString();
|
|
82056
82264
|
const tmpPath = `${this.indexPath}.${process.pid}.${(0, import_crypto2.randomUUID)()}.tmp`;
|
|
82057
|
-
await (0,
|
|
82058
|
-
await (0,
|
|
82265
|
+
await (0, import_promises8.writeFile)(tmpPath, JSON.stringify(index, null, 2), "utf-8");
|
|
82266
|
+
await (0, import_promises8.rename)(tmpPath, this.indexPath);
|
|
82059
82267
|
}
|
|
82060
82268
|
async updateIndex(trajectory2, filePath) {
|
|
82061
82269
|
await withIndexLock(this.indexPath, async () => {
|
|
@@ -82179,8 +82387,8 @@ var WorkflowTrajectory = class {
|
|
|
82179
82387
|
this.reflectOnConverge = cfg.reflectOnConverge !== false;
|
|
82180
82388
|
this.autoDecisions = cfg.autoDecisions !== false;
|
|
82181
82389
|
this.runId = runId;
|
|
82182
|
-
const dataDir = process.env.TRAJECTORIES_DATA_DIR ?? (0,
|
|
82183
|
-
this.storageBaseDir = process.env.TRAJECTORIES_DATA_DIR ? (0,
|
|
82390
|
+
const dataDir = process.env.TRAJECTORIES_DATA_DIR ?? (0, import_node_path29.join)(cwd, ".trajectories");
|
|
82391
|
+
this.storageBaseDir = process.env.TRAJECTORIES_DATA_DIR ? (0, import_node_path29.dirname)(dataDir) : cwd;
|
|
82184
82392
|
}
|
|
82185
82393
|
async start(workflowName, stepCount, trackInfo, description, pattern) {
|
|
82186
82394
|
if (!this.enabled)
|
|
@@ -82639,8 +82847,8 @@ var WorkflowRunner = class _WorkflowRunner {
|
|
|
82639
82847
|
this.workspaceId = options.workspaceId ?? "local";
|
|
82640
82848
|
this.relayOptions = options.relay ?? {};
|
|
82641
82849
|
this.cwd = options.cwd ?? process.cwd();
|
|
82642
|
-
this.summaryDir = options.summaryDir ??
|
|
82643
|
-
this.workersPath =
|
|
82850
|
+
this.summaryDir = options.summaryDir ?? import_node_path30.default.join(this.cwd, ".relay", "summaries");
|
|
82851
|
+
this.workersPath = import_node_path30.default.join(this.cwd, ".agent-relay", "team", "workers.json");
|
|
82644
82852
|
this.executor = options.executor;
|
|
82645
82853
|
this.processBackend = options.processBackend;
|
|
82646
82854
|
this.envSecrets = options.envSecrets;
|
|
@@ -82678,7 +82886,7 @@ var WorkflowRunner = class _WorkflowRunner {
|
|
|
82678
82886
|
}
|
|
82679
82887
|
seenNames.add(pd.name);
|
|
82680
82888
|
const expanded = _WorkflowRunner.resolveEnvVars(pd.path);
|
|
82681
|
-
const abs =
|
|
82889
|
+
const abs = import_node_path30.default.resolve(baseCwd, expanded);
|
|
82682
82890
|
resolved.set(pd.name, abs);
|
|
82683
82891
|
const isRequired = pd.required !== false;
|
|
82684
82892
|
if (!(0, import_node_fs21.existsSync)(abs)) {
|
|
@@ -83010,7 +83218,7 @@ var WorkflowRunner = class _WorkflowRunner {
|
|
|
83010
83218
|
return resolved;
|
|
83011
83219
|
}
|
|
83012
83220
|
if (agent.cwd) {
|
|
83013
|
-
return
|
|
83221
|
+
return import_node_path30.default.resolve(this.cwd, agent.cwd);
|
|
83014
83222
|
}
|
|
83015
83223
|
return this.cwd;
|
|
83016
83224
|
}
|
|
@@ -83029,7 +83237,7 @@ var WorkflowRunner = class _WorkflowRunner {
|
|
|
83029
83237
|
}
|
|
83030
83238
|
resolveEffectiveCwd(step, agentDef) {
|
|
83031
83239
|
if (step.cwd) {
|
|
83032
|
-
return
|
|
83240
|
+
return import_node_path30.default.resolve(this.cwd, step.cwd);
|
|
83033
83241
|
}
|
|
83034
83242
|
return this.resolveStepWorkdir(step) ?? (agentDef ? this.resolveAgentCwd(agentDef) : this.cwd);
|
|
83035
83243
|
}
|
|
@@ -83038,14 +83246,14 @@ var WorkflowRunner = class _WorkflowRunner {
|
|
|
83038
83246
|
if (!mount) {
|
|
83039
83247
|
return cwd;
|
|
83040
83248
|
}
|
|
83041
|
-
const relative3 =
|
|
83249
|
+
const relative3 = import_node_path30.default.relative(this.cwd, cwd);
|
|
83042
83250
|
if (relative3 === "") {
|
|
83043
83251
|
return mount.mountPoint;
|
|
83044
83252
|
}
|
|
83045
|
-
if (relative3 === ".." || relative3.startsWith(`..${
|
|
83253
|
+
if (relative3 === ".." || relative3.startsWith(`..${import_node_path30.default.sep}`)) {
|
|
83046
83254
|
return cwd;
|
|
83047
83255
|
}
|
|
83048
|
-
return
|
|
83256
|
+
return import_node_path30.default.resolve(mount.mountPoint, relative3);
|
|
83049
83257
|
}
|
|
83050
83258
|
resolveExecutionCwd(step, agentDef) {
|
|
83051
83259
|
const cwd = this.resolveEffectiveCwd(step, agentDef);
|
|
@@ -83350,7 +83558,7 @@ ${next}` : next;
|
|
|
83350
83558
|
}
|
|
83351
83559
|
uniqueEvidenceRoots(roots) {
|
|
83352
83560
|
return [
|
|
83353
|
-
...new Set(roots.filter((root) => Boolean(root)).map((root) =>
|
|
83561
|
+
...new Set(roots.filter((root) => Boolean(root)).map((root) => import_node_path30.default.resolve(root)))
|
|
83354
83562
|
];
|
|
83355
83563
|
}
|
|
83356
83564
|
captureFileSnapshot(root) {
|
|
@@ -83368,7 +83576,7 @@ ${next}` : next;
|
|
|
83368
83576
|
if (entry.isDirectory() && _WorkflowRunner.EVIDENCE_IGNORED_DIRS.has(entry.name)) {
|
|
83369
83577
|
continue;
|
|
83370
83578
|
}
|
|
83371
|
-
const fullPath =
|
|
83579
|
+
const fullPath = import_node_path30.default.join(currentPath, entry.name);
|
|
83372
83580
|
if (entry.isDirectory()) {
|
|
83373
83581
|
visit(fullPath);
|
|
83374
83582
|
continue;
|
|
@@ -83420,9 +83628,9 @@ ${next}` : next;
|
|
|
83420
83628
|
return changes.sort((a, b2) => a.path.localeCompare(b2.path));
|
|
83421
83629
|
}
|
|
83422
83630
|
normalizeEvidencePath(filePath) {
|
|
83423
|
-
const relative3 =
|
|
83631
|
+
const relative3 = import_node_path30.default.relative(this.cwd, filePath);
|
|
83424
83632
|
if (!relative3 || relative3 === "")
|
|
83425
|
-
return
|
|
83633
|
+
return import_node_path30.default.basename(filePath);
|
|
83426
83634
|
return relative3.startsWith("..") ? filePath : relative3;
|
|
83427
83635
|
}
|
|
83428
83636
|
buildStepCompletionDecision(stepName, completionReason) {
|
|
@@ -83808,8 +84016,8 @@ ${next}` : next;
|
|
|
83808
84016
|
// ── Parsing & validation ────────────────────────────────────────────────
|
|
83809
84017
|
/** Parse a relay.yaml file from disk. */
|
|
83810
84018
|
async parseYamlFile(filePath) {
|
|
83811
|
-
const absPath =
|
|
83812
|
-
const raw = await (0,
|
|
84019
|
+
const absPath = import_node_path30.default.resolve(this.cwd, filePath);
|
|
84020
|
+
const raw = await (0, import_promises9.readFile)(absPath, "utf-8");
|
|
83813
84021
|
return this.parseYamlString(raw, absPath);
|
|
83814
84022
|
}
|
|
83815
84023
|
/** Parse a relay.yaml string. */
|
|
@@ -84008,14 +84216,14 @@ ${err.suggestion}`);
|
|
|
84008
84216
|
}
|
|
84009
84217
|
for (const agent of resolved.agents) {
|
|
84010
84218
|
if (agent.cwd) {
|
|
84011
|
-
const resolvedCwd =
|
|
84219
|
+
const resolvedCwd = import_node_path30.default.resolve(this.cwd, agent.cwd);
|
|
84012
84220
|
if (!(0, import_node_fs21.existsSync)(resolvedCwd)) {
|
|
84013
84221
|
warnings.push(`Agent "${agent.name}" cwd "${agent.cwd}" resolves to "${resolvedCwd}" which does not exist`);
|
|
84014
84222
|
}
|
|
84015
84223
|
}
|
|
84016
84224
|
if (agent.additionalPaths) {
|
|
84017
84225
|
for (const ap of agent.additionalPaths) {
|
|
84018
|
-
const resolvedPath =
|
|
84226
|
+
const resolvedPath = import_node_path30.default.resolve(this.cwd, ap);
|
|
84019
84227
|
if (!(0, import_node_fs21.existsSync)(resolvedPath)) {
|
|
84020
84228
|
warnings.push(`Agent "${agent.name}" additionalPath "${ap}" resolves to "${resolvedPath}" which does not exist`);
|
|
84021
84229
|
}
|
|
@@ -84590,7 +84798,7 @@ ${err.suggestion}`);
|
|
|
84590
84798
|
}
|
|
84591
84799
|
}
|
|
84592
84800
|
this.log("Starting broker...");
|
|
84593
|
-
const brokerBaseName =
|
|
84801
|
+
const brokerBaseName = import_node_path30.default.basename(this.cwd) || "workflow";
|
|
84594
84802
|
const brokerName = `${brokerBaseName}-${runId.slice(0, 8)}`;
|
|
84595
84803
|
this.relay = new AgentRelay({
|
|
84596
84804
|
...this.relayOptions,
|
|
@@ -84612,7 +84820,7 @@ ${err.suggestion}`);
|
|
|
84612
84820
|
if (/Read\(/.test(stripped)) {
|
|
84613
84821
|
const m2 = stripped.match(/Read\(\s*~?([^\s)"']{8,})/);
|
|
84614
84822
|
if (m2) {
|
|
84615
|
-
const base =
|
|
84823
|
+
const base = import_node_path30.default.basename(m2[1]);
|
|
84616
84824
|
activity = base.length >= 3 ? `Reading ${base}` : "Reading file...";
|
|
84617
84825
|
} else {
|
|
84618
84826
|
activity = "Reading file...";
|
|
@@ -84620,7 +84828,7 @@ ${err.suggestion}`);
|
|
|
84620
84828
|
} else if (/Edit\(/.test(stripped)) {
|
|
84621
84829
|
const m2 = stripped.match(/Edit\(\s*~?([^\s)"']{8,})/);
|
|
84622
84830
|
if (m2) {
|
|
84623
|
-
const base =
|
|
84831
|
+
const base = import_node_path30.default.basename(m2[1]);
|
|
84624
84832
|
activity = base.length >= 3 ? `Editing ${base}` : "Editing file...";
|
|
84625
84833
|
} else {
|
|
84626
84834
|
activity = "Editing file...";
|
|
@@ -85461,14 +85669,14 @@ Repair only what is needed for this step to produce the required artifact or evi
|
|
|
85461
85669
|
const stepOutputContext = this.buildStepOutputContext(stepStates, runId);
|
|
85462
85670
|
const branch = this.interpolateStepTask(step.branch ?? "", stepOutputContext);
|
|
85463
85671
|
const baseBranch = step.baseBranch ? this.interpolateStepTask(step.baseBranch, stepOutputContext) : "HEAD";
|
|
85464
|
-
const worktreePath = step.path ? this.interpolateStepTask(step.path, stepOutputContext) :
|
|
85672
|
+
const worktreePath = step.path ? this.interpolateStepTask(step.path, stepOutputContext) : import_node_path30.default.join(".worktrees", step.name);
|
|
85465
85673
|
const createBranch2 = step.createBranch !== false;
|
|
85466
85674
|
const stepCwd = this.resolveStepWorkdir(step) ?? this.cwd;
|
|
85467
85675
|
this.beginStepEvidence(step.name, [stepCwd], state.row.startedAt);
|
|
85468
85676
|
if (!branch) {
|
|
85469
85677
|
throw new Error('Worktree step missing required "branch" field');
|
|
85470
85678
|
}
|
|
85471
|
-
const absoluteWorktreePath =
|
|
85679
|
+
const absoluteWorktreePath = import_node_path30.default.resolve(stepCwd, worktreePath);
|
|
85472
85680
|
let branchExists = false;
|
|
85473
85681
|
await new Promise((resolve4) => {
|
|
85474
85682
|
const checkChild = (0, import_node_child_process8.spawn)("git", ["rev-parse", "--verify", "--quiet", branch], {
|
|
@@ -86551,8 +86759,8 @@ WORKER COMPLETION CONTRACT:
|
|
|
86551
86759
|
promptTaskText: taskText
|
|
86552
86760
|
};
|
|
86553
86761
|
}
|
|
86554
|
-
const taskTmpDir = (0, import_node_fs21.mkdtempSync)(
|
|
86555
|
-
const taskTmpFile =
|
|
86762
|
+
const taskTmpDir = (0, import_node_fs21.mkdtempSync)(import_node_path30.default.join((0, import_node_os10.tmpdir)(), "relay-pty-task-"));
|
|
86763
|
+
const taskTmpFile = import_node_path30.default.join(taskTmpDir, `${agentName}-${Date.now()}.txt`);
|
|
86556
86764
|
(0, import_node_fs21.writeFileSync)(taskTmpFile, taskText, { encoding: "utf8", mode: 384, flag: "wx" });
|
|
86557
86765
|
const promptTaskText = `TASK_FILE:${taskTmpFile}
|
|
86558
86766
|
Read that file completely before taking any action.
|
|
@@ -86958,7 +87166,7 @@ DO NOT:
|
|
|
86958
87166
|
- Output only status messages without the actual deliverable content`;
|
|
86959
87167
|
const { cmd, args } = _WorkflowRunner.buildNonInteractiveCommand(agentDef.cli, taskWithDeliverable, modelArgs);
|
|
86960
87168
|
const logsDir = this.getWorkerLogsDir();
|
|
86961
|
-
const logPath =
|
|
87169
|
+
const logPath = import_node_path30.default.join(logsDir, `${agentName}.log`);
|
|
86962
87170
|
const logStream = (0, import_node_fs21.createWriteStream)(logPath, { flags: "a" });
|
|
86963
87171
|
this.registerWorker(agentName, agentDef.cli, step.task ?? "", void 0, false);
|
|
86964
87172
|
let stopHeartbeat;
|
|
@@ -87126,7 +87334,7 @@ DO NOT:
|
|
|
87126
87334
|
const preparedTask = this.prepareInteractiveSpawnTask(agentName, taskWithExit);
|
|
87127
87335
|
this.ptyOutputBuffers.set(agentName, []);
|
|
87128
87336
|
const logsDir = this.getWorkerLogsDir();
|
|
87129
|
-
const logStream = (0, import_node_fs21.createWriteStream)(
|
|
87337
|
+
const logStream = (0, import_node_fs21.createWriteStream)(import_node_path30.default.join(logsDir, `${agentName}.log`), { flags: "a" });
|
|
87130
87338
|
this.ptyLogStreams.set(agentName, logStream);
|
|
87131
87339
|
this.ptyListeners.set(agentName, (chunk) => {
|
|
87132
87340
|
const stripped = _WorkflowRunner.stripAnsi(chunk);
|
|
@@ -87176,8 +87384,8 @@ DO NOT:
|
|
|
87176
87384
|
const oldName = agentName;
|
|
87177
87385
|
this.ptyOutputBuffers.set(agent.name, this.ptyOutputBuffers.get(oldName) ?? []);
|
|
87178
87386
|
this.ptyOutputBuffers.delete(oldName);
|
|
87179
|
-
const oldLogPath =
|
|
87180
|
-
const newLogPath =
|
|
87387
|
+
const oldLogPath = import_node_path30.default.join(logsDir, `${oldName}.log`);
|
|
87388
|
+
const newLogPath = import_node_path30.default.join(logsDir, `${agent.name}.log`);
|
|
87181
87389
|
const oldLogStream = this.ptyLogStreams.get(oldName);
|
|
87182
87390
|
if (oldLogStream) {
|
|
87183
87391
|
oldLogStream.end();
|
|
@@ -87287,15 +87495,15 @@ DO NOT:
|
|
|
87287
87495
|
this.supervisedRuntimeAgents.delete(agentName);
|
|
87288
87496
|
this.runtimeStepAgents.delete(agentName);
|
|
87289
87497
|
if (preparedTask.taskTmpFile) {
|
|
87290
|
-
await (0,
|
|
87498
|
+
await (0, import_promises9.unlink)(preparedTask.taskTmpFile).catch(() => void 0);
|
|
87291
87499
|
}
|
|
87292
87500
|
}
|
|
87293
87501
|
let output;
|
|
87294
87502
|
if (ptyChunks.length > 0) {
|
|
87295
87503
|
output = ptyChunks.join("");
|
|
87296
87504
|
} else {
|
|
87297
|
-
const summaryPath =
|
|
87298
|
-
output = (0, import_node_fs21.existsSync)(summaryPath) ? await (0,
|
|
87505
|
+
const summaryPath = import_node_path30.default.join(this.summaryDir, `${step.name}.md`);
|
|
87506
|
+
output = (0, import_node_fs21.existsSync)(summaryPath) ? await (0, import_promises9.readFile)(summaryPath, "utf-8") : exitResult === "timeout" ? "Agent completed (released after idle timeout)" : exitResult === "released" ? "Agent completed (idle \u2014 treated as done)" : `Agent exited (${exitResult})`;
|
|
87299
87507
|
}
|
|
87300
87508
|
if (ptyChunks.length === 0) {
|
|
87301
87509
|
this.captureStepTerminalEvidence(evidenceStepName, { stdout: output, combined: output }, { exitCode: agent?.exitCode, exitSignal: agent?.exitSignal }, {
|
|
@@ -87747,7 +87955,7 @@ DO NOT:
|
|
|
87747
87955
|
}
|
|
87748
87956
|
}
|
|
87749
87957
|
const outputDir = this.getStepOutputDir(runId);
|
|
87750
|
-
const logsDir =
|
|
87958
|
+
const logsDir = import_node_path30.default.join(this.cwd, ".agent-relay", "team", "worker-logs");
|
|
87751
87959
|
console.log("");
|
|
87752
87960
|
console.log(` Run ID: ${runId}`);
|
|
87753
87961
|
console.log(` Step output: ${outputDir}`);
|
|
@@ -87833,7 +88041,7 @@ ${excerpt}` : "";
|
|
|
87833
88041
|
if (!target)
|
|
87834
88042
|
return;
|
|
87835
88043
|
try {
|
|
87836
|
-
(0, import_node_fs21.mkdirSync)(
|
|
88044
|
+
(0, import_node_fs21.mkdirSync)(import_node_path30.default.dirname(target), { recursive: true });
|
|
87837
88045
|
(0, import_node_fs21.writeFileSync)(target, runId + "\n", "utf8");
|
|
87838
88046
|
} catch {
|
|
87839
88047
|
}
|
|
@@ -87870,16 +88078,16 @@ ${excerpt}` : "";
|
|
|
87870
88078
|
/** Directory for persisted step outputs: .agent-relay/step-outputs/{runId}/ */
|
|
87871
88079
|
getStepOutputDir(runId) {
|
|
87872
88080
|
this.validateRunId(runId);
|
|
87873
|
-
return
|
|
88081
|
+
return import_node_path30.default.join(this.cwd, ".agent-relay", "step-outputs", runId);
|
|
87874
88082
|
}
|
|
87875
88083
|
/** Persist step output to disk and post full output as a channel message. */
|
|
87876
88084
|
async persistStepOutput(runId, stepName, output) {
|
|
87877
|
-
const outputPath =
|
|
88085
|
+
const outputPath = import_node_path30.default.join(this.getStepOutputDir(runId), `${stepName}.md`);
|
|
87878
88086
|
try {
|
|
87879
88087
|
const dir = this.getStepOutputDir(runId);
|
|
87880
88088
|
(0, import_node_fs21.mkdirSync)(dir, { recursive: true });
|
|
87881
88089
|
const cleaned = _WorkflowRunner.stripAnsi(output);
|
|
87882
|
-
await (0,
|
|
88090
|
+
await (0, import_promises9.writeFile)(outputPath, cleaned);
|
|
87883
88091
|
} catch {
|
|
87884
88092
|
}
|
|
87885
88093
|
this.recordStepToolSideEffect(stepName, {
|
|
@@ -87904,32 +88112,32 @@ ${preview}
|
|
|
87904
88112
|
\`\`\``, { stepName });
|
|
87905
88113
|
}
|
|
87906
88114
|
async persistAgentReport(runId, stepName, report) {
|
|
87907
|
-
const reportPath =
|
|
88115
|
+
const reportPath = import_node_path30.default.join(this.getStepOutputDir(runId), `${stepName}.report.json`);
|
|
87908
88116
|
try {
|
|
87909
88117
|
(0, import_node_fs21.mkdirSync)(this.getStepOutputDir(runId), { recursive: true });
|
|
87910
|
-
await (0,
|
|
88118
|
+
await (0, import_promises9.writeFile)(reportPath, JSON.stringify(report, null, 2), "utf8");
|
|
87911
88119
|
} catch {
|
|
87912
88120
|
}
|
|
87913
88121
|
}
|
|
87914
88122
|
/** Scan .agent-relay/step-outputs/ for the most recent run directory containing the needed steps. */
|
|
87915
88123
|
findMostRecentRunWithSteps(stepNames) {
|
|
87916
88124
|
try {
|
|
87917
|
-
const baseDir =
|
|
88125
|
+
const baseDir = import_node_path30.default.join(this.cwd, ".agent-relay", "step-outputs");
|
|
87918
88126
|
if (!(0, import_node_fs21.existsSync)(baseDir))
|
|
87919
88127
|
return void 0;
|
|
87920
88128
|
const entries = (0, import_node_fs21.readdirSync)(baseDir);
|
|
87921
88129
|
let best;
|
|
87922
88130
|
for (const entry of entries) {
|
|
87923
|
-
const dirPath =
|
|
88131
|
+
const dirPath = import_node_path30.default.join(baseDir, entry);
|
|
87924
88132
|
try {
|
|
87925
|
-
const
|
|
87926
|
-
if (!
|
|
88133
|
+
const stat3 = (0, import_node_fs21.statSync)(dirPath);
|
|
88134
|
+
if (!stat3.isDirectory())
|
|
87927
88135
|
continue;
|
|
87928
|
-
const hasAny = [...stepNames].some((name) => (0, import_node_fs21.existsSync)(
|
|
88136
|
+
const hasAny = [...stepNames].some((name) => (0, import_node_fs21.existsSync)(import_node_path30.default.join(dirPath, `${name}.md`)));
|
|
87929
88137
|
if (!hasAny)
|
|
87930
88138
|
continue;
|
|
87931
|
-
if (!best ||
|
|
87932
|
-
best = { name: entry, mtime:
|
|
88139
|
+
if (!best || stat3.mtimeMs > best.mtime) {
|
|
88140
|
+
best = { name: entry, mtime: stat3.mtimeMs };
|
|
87933
88141
|
}
|
|
87934
88142
|
} catch {
|
|
87935
88143
|
continue;
|
|
@@ -87943,7 +88151,7 @@ ${preview}
|
|
|
87943
88151
|
/** Load persisted step output from disk. */
|
|
87944
88152
|
loadStepOutput(runId, stepName) {
|
|
87945
88153
|
try {
|
|
87946
|
-
const filePath =
|
|
88154
|
+
const filePath = import_node_path30.default.join(this.getStepOutputDir(runId), `${stepName}.md`);
|
|
87947
88155
|
if (!(0, import_node_fs21.existsSync)(filePath))
|
|
87948
88156
|
return void 0;
|
|
87949
88157
|
return (0, import_node_fs21.readFileSync)(filePath, "utf-8");
|
|
@@ -87972,7 +88180,7 @@ ${preview}
|
|
|
87972
88180
|
return null;
|
|
87973
88181
|
let resumeConfig = config2 ?? this.currentConfig;
|
|
87974
88182
|
if (!resumeConfig) {
|
|
87975
|
-
const yamlPath =
|
|
88183
|
+
const yamlPath = import_node_path30.default.join(this.cwd, "relay.yaml");
|
|
87976
88184
|
if ((0, import_node_fs21.existsSync)(yamlPath)) {
|
|
87977
88185
|
try {
|
|
87978
88186
|
const raw = (0, import_node_fs21.readFileSync)(yamlPath, "utf-8");
|
|
@@ -88001,8 +88209,8 @@ ${preview}
|
|
|
88001
88209
|
let earliestMtime = Date.now();
|
|
88002
88210
|
for (const stepName of cachedStepNames) {
|
|
88003
88211
|
try {
|
|
88004
|
-
const mdPath =
|
|
88005
|
-
const reportPath =
|
|
88212
|
+
const mdPath = import_node_path30.default.join(stepOutputDir, `${stepName}.md`);
|
|
88213
|
+
const reportPath = import_node_path30.default.join(stepOutputDir, `${stepName}.report.json`);
|
|
88006
88214
|
const mdStat = (0, import_node_fs21.existsSync)(mdPath) ? (0, import_node_fs21.statSync)(mdPath) : null;
|
|
88007
88215
|
const reportStat = (0, import_node_fs21.existsSync)(reportPath) ? (0, import_node_fs21.statSync)(reportPath) : null;
|
|
88008
88216
|
const mtime = Math.max(mdStat?.mtimeMs ?? 0, reportStat?.mtimeMs ?? 0);
|
|
@@ -88056,7 +88264,7 @@ ${preview}
|
|
|
88056
88264
|
}
|
|
88057
88265
|
/** Get or create the worker logs directory (.agent-relay/team/worker-logs) */
|
|
88058
88266
|
getWorkerLogsDir() {
|
|
88059
|
-
const logsDir =
|
|
88267
|
+
const logsDir = import_node_path30.default.join(this.cwd, ".agent-relay", "team", "worker-logs");
|
|
88060
88268
|
(0, import_node_fs21.mkdirSync)(logsDir, { recursive: true });
|
|
88061
88269
|
return logsDir;
|
|
88062
88270
|
}
|
|
@@ -88068,12 +88276,12 @@ ${preview}
|
|
|
88068
88276
|
spawnedAt: Date.now(),
|
|
88069
88277
|
pid,
|
|
88070
88278
|
interactive,
|
|
88071
|
-
logFile:
|
|
88279
|
+
logFile: import_node_path30.default.join(this.getWorkerLogsDir(), `${agentName}.log`)
|
|
88072
88280
|
};
|
|
88073
88281
|
this.activeWorkers.set(agentName, workerEntry);
|
|
88074
88282
|
this.workersFileLock = this.workersFileLock.then(() => {
|
|
88075
88283
|
try {
|
|
88076
|
-
(0, import_node_fs21.mkdirSync)(
|
|
88284
|
+
(0, import_node_fs21.mkdirSync)(import_node_path30.default.dirname(this.workersPath), { recursive: true });
|
|
88077
88285
|
const existing = this.readWorkers().filter((w2) => w2.name !== agentName);
|
|
88078
88286
|
existing.push({ name: agentName, ...workerEntry });
|
|
88079
88287
|
this.writeWorkers(existing);
|
|
@@ -88110,8 +88318,8 @@ ${preview}
|
|
|
88110
88318
|
|
|
88111
88319
|
// packages/sdk/dist/workflows/file-db.js
|
|
88112
88320
|
var import_node_fs22 = require("node:fs");
|
|
88113
|
-
var
|
|
88114
|
-
var
|
|
88321
|
+
var import_node_os11 = __toESM(require("node:os"), 1);
|
|
88322
|
+
var import_node_path31 = __toESM(require("node:path"), 1);
|
|
88115
88323
|
var JsonFileWorkflowDb = class _JsonFileWorkflowDb {
|
|
88116
88324
|
filePath;
|
|
88117
88325
|
/** Whether persistence is active. False = in-memory-only mode. */
|
|
@@ -88127,7 +88335,7 @@ var JsonFileWorkflowDb = class _JsonFileWorkflowDb {
|
|
|
88127
88335
|
constructor(filePathOrOptions) {
|
|
88128
88336
|
const options = typeof filePathOrOptions === "string" ? { filePath: filePathOrOptions } : filePathOrOptions;
|
|
88129
88337
|
this.onWriteFailure = options.onWriteFailure;
|
|
88130
|
-
const requestedPath = options.filePath ??
|
|
88338
|
+
const requestedPath = options.filePath ?? import_node_path31.default.join(".agent-relay", "workflow-runs.jsonl");
|
|
88131
88339
|
const homeFallback = options.homeFallback ?? false;
|
|
88132
88340
|
const { resolvedPath, writable } = _JsonFileWorkflowDb.resolveStoragePath(requestedPath, homeFallback);
|
|
88133
88341
|
this.filePath = resolvedPath;
|
|
@@ -88144,7 +88352,7 @@ var JsonFileWorkflowDb = class _JsonFileWorkflowDb {
|
|
|
88144
88352
|
}
|
|
88145
88353
|
hasStepOutputs(runId) {
|
|
88146
88354
|
try {
|
|
88147
|
-
const dir =
|
|
88355
|
+
const dir = import_node_path31.default.join(import_node_path31.default.dirname(this.filePath), "step-outputs", runId);
|
|
88148
88356
|
return (0, import_node_fs22.existsSync)(dir) && (0, import_node_fs22.readdirSync)(dir).length > 0;
|
|
88149
88357
|
} catch {
|
|
88150
88358
|
return false;
|
|
@@ -88154,16 +88362,16 @@ var JsonFileWorkflowDb = class _JsonFileWorkflowDb {
|
|
|
88154
88362
|
static resolveStoragePath(requestedPath, homeFallback) {
|
|
88155
88363
|
const candidates = [requestedPath];
|
|
88156
88364
|
if (homeFallback) {
|
|
88157
|
-
const base =
|
|
88158
|
-
candidates.push(
|
|
88365
|
+
const base = import_node_path31.default.basename(requestedPath) || "workflow-runs.jsonl";
|
|
88366
|
+
candidates.push(import_node_path31.default.join(import_node_os11.default.homedir(), ".agent-relay", `workflow-runs-${base}`));
|
|
88159
88367
|
}
|
|
88160
88368
|
for (let i = 0; i < candidates.length; i++) {
|
|
88161
88369
|
const candidate = candidates[i];
|
|
88162
88370
|
const isLastCandidate = i === candidates.length - 1;
|
|
88163
88371
|
try {
|
|
88164
|
-
(0, import_node_fs22.mkdirSync)(
|
|
88372
|
+
(0, import_node_fs22.mkdirSync)(import_node_path31.default.dirname(candidate), { recursive: true });
|
|
88165
88373
|
if (!isLastCandidate) {
|
|
88166
|
-
(0, import_node_fs22.accessSync)(
|
|
88374
|
+
(0, import_node_fs22.accessSync)(import_node_path31.default.dirname(candidate), import_node_fs22.constants.W_OK);
|
|
88167
88375
|
if ((0, import_node_fs22.existsSync)(candidate)) {
|
|
88168
88376
|
(0, import_node_fs22.accessSync)(candidate, import_node_fs22.constants.W_OK);
|
|
88169
88377
|
}
|
|
@@ -88452,17 +88660,17 @@ async function runWorkflow(yamlPath, options = {}) {
|
|
|
88452
88660
|
}
|
|
88453
88661
|
|
|
88454
88662
|
// packages/cloud/src/auth.ts
|
|
88455
|
-
var
|
|
88663
|
+
var import_promises10 = __toESM(require("node:fs/promises"), 1);
|
|
88456
88664
|
var import_node_http = __toESM(require("node:http"), 1);
|
|
88457
|
-
var
|
|
88458
|
-
var
|
|
88665
|
+
var import_node_os13 = __toESM(require("node:os"), 1);
|
|
88666
|
+
var import_node_path33 = __toESM(require("node:path"), 1);
|
|
88459
88667
|
var import_node_child_process9 = require("node:child_process");
|
|
88460
88668
|
|
|
88461
88669
|
// packages/cloud/src/types.ts
|
|
88462
|
-
var
|
|
88463
|
-
var
|
|
88670
|
+
var import_node_os12 = __toESM(require("node:os"), 1);
|
|
88671
|
+
var import_node_path32 = __toESM(require("node:path"), 1);
|
|
88464
88672
|
var REFRESH_WINDOW_MS = 6e4;
|
|
88465
|
-
var AUTH_FILE_PATH =
|
|
88673
|
+
var AUTH_FILE_PATH = import_node_path32.default.join(import_node_os12.default.homedir(), ".agent-relay", "cloud-auth.json");
|
|
88466
88674
|
function defaultApiUrl() {
|
|
88467
88675
|
return process.env.CLOUD_API_URL?.trim() || "https://agentrelay.com/cloud";
|
|
88468
88676
|
}
|
|
@@ -88530,7 +88738,7 @@ async function readStoredAuth(env = process.env) {
|
|
|
88530
88738
|
return envAuth;
|
|
88531
88739
|
}
|
|
88532
88740
|
try {
|
|
88533
|
-
const file2 = await
|
|
88741
|
+
const file2 = await import_promises10.default.readFile(AUTH_FILE_PATH, "utf8");
|
|
88534
88742
|
const parsed = JSON.parse(file2);
|
|
88535
88743
|
return isValidStoredAuth(parsed) ? parsed : null;
|
|
88536
88744
|
} catch {
|
|
@@ -88538,11 +88746,11 @@ async function readStoredAuth(env = process.env) {
|
|
|
88538
88746
|
}
|
|
88539
88747
|
}
|
|
88540
88748
|
async function writeStoredAuth(auth) {
|
|
88541
|
-
await
|
|
88749
|
+
await import_promises10.default.mkdir(import_node_path33.default.dirname(AUTH_FILE_PATH), {
|
|
88542
88750
|
recursive: true,
|
|
88543
88751
|
mode: 448
|
|
88544
88752
|
});
|
|
88545
|
-
await
|
|
88753
|
+
await import_promises10.default.writeFile(AUTH_FILE_PATH, `${JSON.stringify(auth, null, 2)}
|
|
88546
88754
|
`, {
|
|
88547
88755
|
encoding: "utf8",
|
|
88548
88756
|
mode: 384
|
|
@@ -88556,11 +88764,11 @@ function shouldRefresh(accessTokenExpiresAt) {
|
|
|
88556
88764
|
return expiresAt - Date.now() <= REFRESH_WINDOW_MS;
|
|
88557
88765
|
}
|
|
88558
88766
|
function openBrowser(url2) {
|
|
88559
|
-
const
|
|
88560
|
-
if (
|
|
88767
|
+
const platform3 = import_node_os13.default.platform();
|
|
88768
|
+
if (platform3 === "darwin") {
|
|
88561
88769
|
return (0, import_node_child_process9.spawn)("open", [url2], { stdio: "ignore", detached: true });
|
|
88562
88770
|
}
|
|
88563
|
-
if (
|
|
88771
|
+
if (platform3 === "win32") {
|
|
88564
88772
|
return (0, import_node_child_process9.spawn)("cmd", ["/c", "start", "", url2], { stdio: "ignore", detached: true });
|
|
88565
88773
|
}
|
|
88566
88774
|
return (0, import_node_child_process9.spawn)("xdg-open", [url2], { stdio: "ignore", detached: true });
|
|
@@ -88757,8 +88965,8 @@ async function authorizedApiFetch(auth, requestPath, init) {
|
|
|
88757
88965
|
}
|
|
88758
88966
|
|
|
88759
88967
|
// packages/cloud/src/workflows.ts
|
|
88760
|
-
var
|
|
88761
|
-
var
|
|
88968
|
+
var import_promises11 = __toESM(require("node:fs/promises"), 1);
|
|
88969
|
+
var import_node_path34 = __toESM(require("node:path"), 1);
|
|
88762
88970
|
var import_ignore3 = __toESM(require_ignore(), 1);
|
|
88763
88971
|
function validateYamlWorkflow(content) {
|
|
88764
88972
|
const hasField = (field) => new RegExp(`^${field}\\s*:`, "m").test(content);
|
|
@@ -88818,7 +89026,7 @@ ${message}`);
|
|
|
88818
89026
|
}
|
|
88819
89027
|
}
|
|
88820
89028
|
function inferWorkflowFileType(filePath) {
|
|
88821
|
-
const ext =
|
|
89029
|
+
const ext = import_node_path34.default.extname(filePath).toLowerCase();
|
|
88822
89030
|
switch (ext) {
|
|
88823
89031
|
case ".yaml":
|
|
88824
89032
|
case ".yml":
|
|
@@ -88834,9 +89042,9 @@ function inferWorkflowFileType(filePath) {
|
|
|
88834
89042
|
}
|
|
88835
89043
|
}
|
|
88836
89044
|
async function resolveWorkflowInput(workflowArg, explicitFileType) {
|
|
88837
|
-
const looksLikeFile =
|
|
89045
|
+
const looksLikeFile = import_node_path34.default.isAbsolute(workflowArg) || workflowArg.includes(import_node_path34.default.sep) || inferWorkflowFileType(workflowArg) !== null;
|
|
88838
89046
|
try {
|
|
88839
|
-
const workflow2 = await
|
|
89047
|
+
const workflow2 = await import_promises11.default.readFile(workflowArg, "utf-8");
|
|
88840
89048
|
const fileType = explicitFileType ?? inferWorkflowFileType(workflowArg);
|
|
88841
89049
|
if (!fileType) {
|
|
88842
89050
|
throw new Error(`Could not infer workflow type from ${workflowArg}. Use --file-type.`);
|
|
@@ -88875,7 +89083,7 @@ async function scheduleWorkflow(workflowArg, options = {}) {
|
|
|
88875
89083
|
validateYamlWorkflow(input.workflow);
|
|
88876
89084
|
}
|
|
88877
89085
|
const requestBody = {
|
|
88878
|
-
name: options.name?.trim() ||
|
|
89086
|
+
name: options.name?.trim() || import_node_path34.default.basename(workflowArg),
|
|
88879
89087
|
schedule_type: hasCron ? "cron" : "once",
|
|
88880
89088
|
timezone: options.timezone?.trim() || "UTC",
|
|
88881
89089
|
workflowRequest: {
|
|
@@ -88976,7 +89184,7 @@ function isMissingFileError(error51) {
|
|
|
88976
89184
|
var DEBUG = process.env.AGENT_RELAY_DEBUG_SSH === "1";
|
|
88977
89185
|
|
|
88978
89186
|
// packages/sdk/dist/workflows/builder.js
|
|
88979
|
-
var
|
|
89187
|
+
var import_node_path35 = __toESM(require("node:path"), 1);
|
|
88980
89188
|
var import_yaml3 = __toESM(require_dist(), 1);
|
|
88981
89189
|
|
|
88982
89190
|
// packages/sdk/dist/workflows/cloud-runner.js
|
|
@@ -89335,7 +89543,7 @@ var WorkflowBuilder = class {
|
|
|
89335
89543
|
async run(options = {}) {
|
|
89336
89544
|
const config2 = this.toConfig();
|
|
89337
89545
|
const runnerCwd = options.cwd ?? process.cwd();
|
|
89338
|
-
const dbPath =
|
|
89546
|
+
const dbPath = import_node_path35.default.join(runnerCwd, ".agent-relay", "workflow-runs.jsonl");
|
|
89339
89547
|
const db = new JsonFileWorkflowDb(dbPath);
|
|
89340
89548
|
const runner = new WorkflowRunner({
|
|
89341
89549
|
cwd: options.cwd,
|
|
@@ -90253,7 +90461,7 @@ var StateStore = class extends import_node_events5.EventEmitter {
|
|
|
90253
90461
|
|
|
90254
90462
|
// packages/sdk/dist/workflows/templates.js
|
|
90255
90463
|
var import_node_fs23 = require("node:fs");
|
|
90256
|
-
var
|
|
90464
|
+
var import_node_path36 = __toESM(require("node:path"), 1);
|
|
90257
90465
|
var import_node_url2 = require("node:url");
|
|
90258
90466
|
var import_yaml4 = __toESM(require_dist(), 1);
|
|
90259
90467
|
var YAML_EXTENSIONS = [".yaml", ".yml"];
|
|
@@ -90278,7 +90486,7 @@ var TemplateRegistry = class {
|
|
|
90278
90486
|
fetcher;
|
|
90279
90487
|
constructor(options = {}) {
|
|
90280
90488
|
this.builtInTemplatesDir = this.resolveBuiltInTemplatesDir(options.builtInTemplatesDir);
|
|
90281
|
-
this.customTemplatesDir = options.customTemplatesDir ?
|
|
90489
|
+
this.customTemplatesDir = options.customTemplatesDir ? import_node_path36.default.resolve(options.customTemplatesDir) : import_node_path36.default.resolve(options.workspaceDir ?? process.cwd(), ".relay/workflows");
|
|
90282
90490
|
this.fetcher = options.fetcher ?? fetch;
|
|
90283
90491
|
}
|
|
90284
90492
|
listBuiltInTemplates() {
|
|
@@ -90352,12 +90560,12 @@ var TemplateRegistry = class {
|
|
|
90352
90560
|
if (!templateName) {
|
|
90353
90561
|
throw new Error('Template name is required. Provide name explicitly or include a string "name" field.');
|
|
90354
90562
|
}
|
|
90355
|
-
if (templateName.includes("/") || templateName.includes("\\") || templateName.includes("..") ||
|
|
90563
|
+
if (templateName.includes("/") || templateName.includes("\\") || templateName.includes("..") || import_node_path36.default.isAbsolute(templateName)) {
|
|
90356
90564
|
throw new Error(`Invalid template name: "${templateName}" contains path separators or traversal sequences`);
|
|
90357
90565
|
}
|
|
90358
90566
|
this.validateRelayConfig(parsed, url2);
|
|
90359
90567
|
await import_node_fs23.promises.mkdir(this.customTemplatesDir, { recursive: true });
|
|
90360
|
-
const targetPath =
|
|
90568
|
+
const targetPath = import_node_path36.default.join(this.customTemplatesDir, `${templateName}.yaml`);
|
|
90361
90569
|
await import_node_fs23.promises.writeFile(targetPath, (0, import_yaml4.stringify)(parsed), "utf-8");
|
|
90362
90570
|
return targetPath;
|
|
90363
90571
|
}
|
|
@@ -90379,12 +90587,12 @@ var TemplateRegistry = class {
|
|
|
90379
90587
|
}
|
|
90380
90588
|
resolveBuiltInTemplatesDir(explicitDir) {
|
|
90381
90589
|
if (explicitDir) {
|
|
90382
|
-
return
|
|
90590
|
+
return import_node_path36.default.resolve(explicitDir);
|
|
90383
90591
|
}
|
|
90384
|
-
const currentDir =
|
|
90592
|
+
const currentDir = import_node_path36.default.dirname((0, import_node_url2.fileURLToPath)(import_meta_url));
|
|
90385
90593
|
const candidates = [
|
|
90386
|
-
|
|
90387
|
-
|
|
90594
|
+
import_node_path36.default.resolve(currentDir, "builtin-templates"),
|
|
90595
|
+
import_node_path36.default.resolve(currentDir, "../workflows/builtin-templates")
|
|
90388
90596
|
];
|
|
90389
90597
|
for (const candidate of candidates) {
|
|
90390
90598
|
if ((0, import_node_fs23.existsSync)(candidate)) {
|
|
@@ -90407,10 +90615,10 @@ var TemplateRegistry = class {
|
|
|
90407
90615
|
}
|
|
90408
90616
|
async findTemplatePath(directory, templateName) {
|
|
90409
90617
|
for (const ext of YAML_EXTENSIONS) {
|
|
90410
|
-
const candidate =
|
|
90618
|
+
const candidate = import_node_path36.default.join(directory, `${templateName}${ext}`);
|
|
90411
90619
|
try {
|
|
90412
|
-
const
|
|
90413
|
-
if (
|
|
90620
|
+
const stat3 = await import_node_fs23.promises.stat(candidate);
|
|
90621
|
+
if (stat3.isFile()) {
|
|
90414
90622
|
return candidate;
|
|
90415
90623
|
}
|
|
90416
90624
|
} catch {
|
|
@@ -90755,7 +90963,7 @@ function pythonVerifyCommand() {
|
|
|
90755
90963
|
|
|
90756
90964
|
// packages/sdk/dist/workflows/run-script.js
|
|
90757
90965
|
var import_node_fs24 = __toESM(require("node:fs"), 1);
|
|
90758
|
-
var
|
|
90966
|
+
var import_node_path37 = __toESM(require("node:path"), 1);
|
|
90759
90967
|
var import_node_child_process10 = require("node:child_process");
|
|
90760
90968
|
function diag(msg) {
|
|
90761
90969
|
try {
|
|
@@ -90770,12 +90978,12 @@ function diag(msg) {
|
|
|
90770
90978
|
}
|
|
90771
90979
|
}
|
|
90772
90980
|
function findLocalSdkWorkspace(startDir) {
|
|
90773
|
-
let current =
|
|
90774
|
-
const root =
|
|
90981
|
+
let current = import_node_path37.default.resolve(startDir);
|
|
90982
|
+
const root = import_node_path37.default.parse(current).root;
|
|
90775
90983
|
while (true) {
|
|
90776
|
-
const packageJsonPath =
|
|
90777
|
-
const sdkDir =
|
|
90778
|
-
const sdkPackageJsonPath =
|
|
90984
|
+
const packageJsonPath = import_node_path37.default.join(current, "package.json");
|
|
90985
|
+
const sdkDir = import_node_path37.default.join(current, "packages", "sdk");
|
|
90986
|
+
const sdkPackageJsonPath = import_node_path37.default.join(sdkDir, "package.json");
|
|
90779
90987
|
try {
|
|
90780
90988
|
if (import_node_fs24.default.existsSync(packageJsonPath) && import_node_fs24.default.existsSync(sdkPackageJsonPath)) {
|
|
90781
90989
|
const pkg = JSON.parse(import_node_fs24.default.readFileSync(packageJsonPath, "utf8"));
|
|
@@ -90788,14 +90996,14 @@ function findLocalSdkWorkspace(startDir) {
|
|
|
90788
90996
|
}
|
|
90789
90997
|
if (current === root)
|
|
90790
90998
|
return null;
|
|
90791
|
-
current =
|
|
90999
|
+
current = import_node_path37.default.dirname(current);
|
|
90792
91000
|
}
|
|
90793
91001
|
}
|
|
90794
91002
|
function ensureLocalSdkWorkflowRuntime(startDir, execRunner = import_node_child_process10.execFileSync) {
|
|
90795
91003
|
const workspace = findLocalSdkWorkspace(startDir);
|
|
90796
91004
|
if (!workspace)
|
|
90797
91005
|
return;
|
|
90798
|
-
const workflowsEntry =
|
|
91006
|
+
const workflowsEntry = import_node_path37.default.join(workspace.sdkDir, "dist", "workflows", "index.js");
|
|
90799
91007
|
if (import_node_fs24.default.existsSync(workflowsEntry))
|
|
90800
91008
|
return;
|
|
90801
91009
|
console.log("[agent-relay] Detected local @agent-relay/sdk workspace without built workflows runtime; building SDK workflow dependencies...");
|
|
@@ -90858,8 +91066,8 @@ function resolveLocalTypeScriptImport(fromFile, specifier) {
|
|
|
90858
91066
|
if (!specifier.startsWith(".") && !specifier.startsWith("/")) {
|
|
90859
91067
|
return null;
|
|
90860
91068
|
}
|
|
90861
|
-
const basePath = specifier.startsWith("/") ?
|
|
90862
|
-
const ext =
|
|
91069
|
+
const basePath = specifier.startsWith("/") ? import_node_path37.default.resolve(specifier) : import_node_path37.default.resolve(import_node_path37.default.dirname(fromFile), specifier);
|
|
91070
|
+
const ext = import_node_path37.default.extname(basePath);
|
|
90863
91071
|
const candidates = ext === ".js" || ext === ".mjs" || ext === ".cjs" ? [
|
|
90864
91072
|
`${basePath.slice(0, -ext.length)}.ts`,
|
|
90865
91073
|
`${basePath.slice(0, -ext.length)}.tsx`,
|
|
@@ -90871,10 +91079,10 @@ function resolveLocalTypeScriptImport(fromFile, specifier) {
|
|
|
90871
91079
|
`${basePath}.tsx`,
|
|
90872
91080
|
`${basePath}.mts`,
|
|
90873
91081
|
`${basePath}.cts`,
|
|
90874
|
-
|
|
90875
|
-
|
|
90876
|
-
|
|
90877
|
-
|
|
91082
|
+
import_node_path37.default.join(basePath, "index.ts"),
|
|
91083
|
+
import_node_path37.default.join(basePath, "index.tsx"),
|
|
91084
|
+
import_node_path37.default.join(basePath, "index.mts"),
|
|
91085
|
+
import_node_path37.default.join(basePath, "index.cts")
|
|
90878
91086
|
];
|
|
90879
91087
|
for (const candidate of candidates) {
|
|
90880
91088
|
if (/\.(?:ts|tsx|mts|cts)$/.test(candidate) && import_node_fs24.default.existsSync(candidate)) {
|
|
@@ -90895,7 +91103,7 @@ function findStaticLocalTypeScriptImports(filePath, source) {
|
|
|
90895
91103
|
return imports;
|
|
90896
91104
|
}
|
|
90897
91105
|
function shouldSkipNodeStripTypesPreflight(filePath, seen = /* @__PURE__ */ new Set(), isEntry = true) {
|
|
90898
|
-
const resolvedPath =
|
|
91106
|
+
const resolvedPath = import_node_path37.default.resolve(filePath);
|
|
90899
91107
|
if (seen.has(resolvedPath)) {
|
|
90900
91108
|
return false;
|
|
90901
91109
|
}
|
|
@@ -91024,14 +91232,14 @@ async function spawnRunnerWithStderrCapture(command, args, env) {
|
|
|
91024
91232
|
}
|
|
91025
91233
|
async function runScriptWorkflow(filePath, options = {}) {
|
|
91026
91234
|
diag(`runScriptWorkflow: resolving ${filePath}`);
|
|
91027
|
-
const resolved =
|
|
91235
|
+
const resolved = import_node_path37.default.resolve(filePath);
|
|
91028
91236
|
if (!import_node_fs24.default.existsSync(resolved)) {
|
|
91029
91237
|
throw new Error(`File not found: ${resolved}`);
|
|
91030
91238
|
}
|
|
91031
|
-
const ext =
|
|
91032
|
-
const runIdFile =
|
|
91239
|
+
const ext = import_node_path37.default.extname(resolved).toLowerCase();
|
|
91240
|
+
const runIdFile = import_node_path37.default.join(process.cwd(), ".agent-relay", `script-run-id-${process.pid}-${Date.now()}.txt`);
|
|
91033
91241
|
try {
|
|
91034
|
-
import_node_fs24.default.mkdirSync(
|
|
91242
|
+
import_node_fs24.default.mkdirSync(import_node_path37.default.dirname(runIdFile), { recursive: true });
|
|
91035
91243
|
} catch {
|
|
91036
91244
|
}
|
|
91037
91245
|
const childEnv = { ...process.env, AGENT_RELAY_RUN_ID_FILE: runIdFile };
|
|
@@ -91069,7 +91277,7 @@ Run ID: ${runId}`;
|
|
|
91069
91277
|
};
|
|
91070
91278
|
if (ext === ".ts" || ext === ".tsx") {
|
|
91071
91279
|
diag("runScriptWorkflow: ensureLocalSdkWorkflowRuntime start");
|
|
91072
|
-
ensureLocalSdkWorkflowRuntime(
|
|
91280
|
+
ensureLocalSdkWorkflowRuntime(import_node_path37.default.dirname(resolved));
|
|
91073
91281
|
diag("runScriptWorkflow: ensureLocalSdkWorkflowRuntime done");
|
|
91074
91282
|
const wrapRunnerError = (runner, result) => {
|
|
91075
91283
|
const parsed = parseTsxStderr(result.stderr);
|
|
@@ -92495,7 +92703,7 @@ function isValidAgentName(name) {
|
|
|
92495
92703
|
|
|
92496
92704
|
// packages/utils/dist/logger.js
|
|
92497
92705
|
var import_node_fs25 = __toESM(require("node:fs"), 1);
|
|
92498
|
-
var
|
|
92706
|
+
var import_node_path38 = __toESM(require("node:path"), 1);
|
|
92499
92707
|
function getLogFile() {
|
|
92500
92708
|
return process.env.AGENT_RELAY_LOG_FILE;
|
|
92501
92709
|
}
|
|
@@ -92513,7 +92721,7 @@ var LEVEL_PRIORITY = {
|
|
|
92513
92721
|
};
|
|
92514
92722
|
var createdLogDirs = /* @__PURE__ */ new Set();
|
|
92515
92723
|
function ensureLogDir(logFile) {
|
|
92516
|
-
const logDir =
|
|
92724
|
+
const logDir = import_node_path38.default.dirname(logFile);
|
|
92517
92725
|
if (!createdLogDirs.has(logDir) && !import_node_fs25.default.existsSync(logDir)) {
|
|
92518
92726
|
import_node_fs25.default.mkdirSync(logDir, { recursive: true });
|
|
92519
92727
|
createdLogDirs.add(logDir);
|
|
@@ -92959,16 +93167,16 @@ function getRepoFullNameFromPath(workingDirectory) {
|
|
|
92959
93167
|
|
|
92960
93168
|
// packages/utils/dist/update-checker.js
|
|
92961
93169
|
var import_node_fs27 = __toESM(require("node:fs"), 1);
|
|
92962
|
-
var
|
|
93170
|
+
var import_node_path39 = __toESM(require("node:path"), 1);
|
|
92963
93171
|
var import_node_https2 = __toESM(require("node:https"), 1);
|
|
92964
|
-
var
|
|
93172
|
+
var import_node_os15 = __toESM(require("node:os"), 1);
|
|
92965
93173
|
var import_compare_versions = __toESM(require_umd(), 1);
|
|
92966
93174
|
var PACKAGE_NAME = "agent-relay";
|
|
92967
93175
|
var CHECK_INTERVAL_MS = 60 * 60 * 1e3;
|
|
92968
93176
|
var NPM_REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
|
|
92969
93177
|
function getCachePath() {
|
|
92970
|
-
const cacheDir =
|
|
92971
|
-
return
|
|
93178
|
+
const cacheDir = import_node_path39.default.join(import_node_os15.default.homedir(), ".agent-relay");
|
|
93179
|
+
return import_node_path39.default.join(cacheDir, "update-cache.json");
|
|
92972
93180
|
}
|
|
92973
93181
|
function readCache() {
|
|
92974
93182
|
try {
|
|
@@ -92984,7 +93192,7 @@ function readCache() {
|
|
|
92984
93192
|
function writeCache(cache) {
|
|
92985
93193
|
try {
|
|
92986
93194
|
const cachePath = getCachePath();
|
|
92987
|
-
const cacheDir =
|
|
93195
|
+
const cacheDir = import_node_path39.default.dirname(cachePath);
|
|
92988
93196
|
if (!import_node_fs27.default.existsSync(cacheDir)) {
|
|
92989
93197
|
import_node_fs27.default.mkdirSync(cacheDir, { recursive: true });
|
|
92990
93198
|
}
|
|
@@ -93268,8 +93476,8 @@ function validateModelForCli(cli, model) {
|
|
|
93268
93476
|
|
|
93269
93477
|
// packages/utils/dist/relay-pty-path.js
|
|
93270
93478
|
var import_node_fs28 = __toESM(require("node:fs"), 1);
|
|
93271
|
-
var
|
|
93272
|
-
var
|
|
93479
|
+
var import_node_os16 = __toESM(require("node:os"), 1);
|
|
93480
|
+
var import_node_path40 = __toESM(require("node:path"), 1);
|
|
93273
93481
|
var SUPPORTED_PLATFORMS = {
|
|
93274
93482
|
darwin: {
|
|
93275
93483
|
arm64: "relay-pty-darwin-arm64",
|
|
@@ -93281,14 +93489,14 @@ var SUPPORTED_PLATFORMS = {
|
|
|
93281
93489
|
}
|
|
93282
93490
|
};
|
|
93283
93491
|
function getPlatformBinaryName() {
|
|
93284
|
-
const
|
|
93285
|
-
const arch =
|
|
93286
|
-
return SUPPORTED_PLATFORMS[
|
|
93492
|
+
const platform3 = import_node_os16.default.platform();
|
|
93493
|
+
const arch = import_node_os16.default.arch();
|
|
93494
|
+
return SUPPORTED_PLATFORMS[platform3]?.[arch] ?? null;
|
|
93287
93495
|
}
|
|
93288
93496
|
function isPlatformSupported() {
|
|
93289
|
-
const
|
|
93290
|
-
const arch =
|
|
93291
|
-
return SUPPORTED_PLATFORMS[
|
|
93497
|
+
const platform3 = import_node_os16.default.platform();
|
|
93498
|
+
const arch = import_node_os16.default.arch();
|
|
93499
|
+
return SUPPORTED_PLATFORMS[platform3]?.[arch] !== void 0;
|
|
93292
93500
|
}
|
|
93293
93501
|
function getSupportedPlatforms() {
|
|
93294
93502
|
const platforms = [];
|
|
@@ -93317,19 +93525,19 @@ function findRelayPtyBinary(callerDirname) {
|
|
|
93317
93525
|
const scopedMatch = normalizedCaller.match(/^(.+?\/node_modules)\/@agent-relay\//);
|
|
93318
93526
|
const directMatch = normalizedCaller.match(/^(.+?\/node_modules\/agent-relay)/);
|
|
93319
93527
|
if (scopedMatch) {
|
|
93320
|
-
packageRoots.push(
|
|
93528
|
+
packageRoots.push(import_node_path40.default.join(scopedMatch[1], "agent-relay"));
|
|
93321
93529
|
}
|
|
93322
93530
|
if (directMatch) {
|
|
93323
93531
|
packageRoots.push(directMatch[1]);
|
|
93324
93532
|
}
|
|
93325
93533
|
const home = process.env.HOME || process.env.USERPROFILE || "";
|
|
93326
93534
|
if (home) {
|
|
93327
|
-
const npxCacheBase =
|
|
93535
|
+
const npxCacheBase = import_node_path40.default.join(home, ".npm", "_npx");
|
|
93328
93536
|
if (import_node_fs28.default.existsSync(npxCacheBase)) {
|
|
93329
93537
|
try {
|
|
93330
93538
|
const entries = import_node_fs28.default.readdirSync(npxCacheBase);
|
|
93331
93539
|
for (const entry of entries) {
|
|
93332
|
-
const npxPackage =
|
|
93540
|
+
const npxPackage = import_node_path40.default.join(npxCacheBase, entry, "node_modules", "agent-relay");
|
|
93333
93541
|
if (import_node_fs28.default.existsSync(npxPackage)) {
|
|
93334
93542
|
packageRoots.push(npxPackage);
|
|
93335
93543
|
}
|
|
@@ -93338,42 +93546,42 @@ function findRelayPtyBinary(callerDirname) {
|
|
|
93338
93546
|
}
|
|
93339
93547
|
}
|
|
93340
93548
|
}
|
|
93341
|
-
packageRoots.push(
|
|
93549
|
+
packageRoots.push(import_node_path40.default.join(process.cwd(), "node_modules", "agent-relay"));
|
|
93342
93550
|
if (home) {
|
|
93343
|
-
packageRoots.push(
|
|
93344
|
-
packageRoots.push(
|
|
93345
|
-
packageRoots.push(
|
|
93346
|
-
packageRoots.push(
|
|
93347
|
-
packageRoots.push(
|
|
93348
|
-
packageRoots.push(
|
|
93349
|
-
packageRoots.push(
|
|
93350
|
-
packageRoots.push(
|
|
93351
|
-
}
|
|
93352
|
-
const bashInstallerDir = process.env.AGENT_RELAY_INSTALL_DIR ?
|
|
93353
|
-
const bashInstallerBinDir = process.env.AGENT_RELAY_BIN_DIR || (home ?
|
|
93354
|
-
const nodePrefix =
|
|
93355
|
-
packageRoots.push(
|
|
93551
|
+
packageRoots.push(import_node_path40.default.join(home, ".nvm", "versions", "node", process.version, "lib", "node_modules", "agent-relay"));
|
|
93552
|
+
packageRoots.push(import_node_path40.default.join(home, ".volta", "tools", "image", "packages", "agent-relay", "lib", "node_modules", "agent-relay"));
|
|
93553
|
+
packageRoots.push(import_node_path40.default.join(home, ".fnm", "node-versions", process.version, "installation", "lib", "node_modules", "agent-relay"));
|
|
93554
|
+
packageRoots.push(import_node_path40.default.join(home, "n", "lib", "node_modules", "agent-relay"));
|
|
93555
|
+
packageRoots.push(import_node_path40.default.join(home, ".asdf", "installs", "nodejs", process.version.replace("v", ""), "lib", "node_modules", "agent-relay"));
|
|
93556
|
+
packageRoots.push(import_node_path40.default.join(home, ".local", "share", "pnpm", "global", "node_modules", "agent-relay"));
|
|
93557
|
+
packageRoots.push(import_node_path40.default.join(home, ".config", "yarn", "global", "node_modules", "agent-relay"));
|
|
93558
|
+
packageRoots.push(import_node_path40.default.join(home, ".yarn", "global", "node_modules", "agent-relay"));
|
|
93559
|
+
}
|
|
93560
|
+
const bashInstallerDir = process.env.AGENT_RELAY_INSTALL_DIR ? import_node_path40.default.join(process.env.AGENT_RELAY_INSTALL_DIR, "bin") : home ? import_node_path40.default.join(home, ".agent-relay", "bin") : null;
|
|
93561
|
+
const bashInstallerBinDir = process.env.AGENT_RELAY_BIN_DIR || (home ? import_node_path40.default.join(home, ".local", "bin") : null);
|
|
93562
|
+
const nodePrefix = import_node_path40.default.resolve(import_node_path40.default.dirname(process.execPath), "..");
|
|
93563
|
+
packageRoots.push(import_node_path40.default.join(nodePrefix, "lib", "node_modules", "agent-relay"));
|
|
93356
93564
|
packageRoots.push("/usr/local/lib/node_modules/agent-relay");
|
|
93357
93565
|
packageRoots.push("/opt/homebrew/lib/node_modules/agent-relay");
|
|
93358
93566
|
packageRoots.push("/usr/lib/node_modules/agent-relay");
|
|
93359
93567
|
const candidates = [];
|
|
93360
93568
|
for (const root of packageRoots) {
|
|
93361
93569
|
if (platformBinary) {
|
|
93362
|
-
candidates.push(
|
|
93570
|
+
candidates.push(import_node_path40.default.join(root, "bin", platformBinary));
|
|
93363
93571
|
}
|
|
93364
|
-
candidates.push(
|
|
93572
|
+
candidates.push(import_node_path40.default.join(root, "bin", "relay-pty"));
|
|
93365
93573
|
}
|
|
93366
93574
|
if (bashInstallerDir) {
|
|
93367
93575
|
if (platformBinary) {
|
|
93368
|
-
candidates.push(
|
|
93576
|
+
candidates.push(import_node_path40.default.join(bashInstallerDir, platformBinary));
|
|
93369
93577
|
}
|
|
93370
|
-
candidates.push(
|
|
93578
|
+
candidates.push(import_node_path40.default.join(bashInstallerDir, "relay-pty"));
|
|
93371
93579
|
}
|
|
93372
93580
|
if (bashInstallerBinDir) {
|
|
93373
93581
|
if (platformBinary) {
|
|
93374
|
-
candidates.push(
|
|
93582
|
+
candidates.push(import_node_path40.default.join(bashInstallerBinDir, platformBinary));
|
|
93375
93583
|
}
|
|
93376
|
-
candidates.push(
|
|
93584
|
+
candidates.push(import_node_path40.default.join(bashInstallerBinDir, "relay-pty"));
|
|
93377
93585
|
}
|
|
93378
93586
|
candidates.push("/app/bin/relay-pty");
|
|
93379
93587
|
candidates.push("/usr/local/bin/relay-pty");
|
|
@@ -93404,11 +93612,11 @@ function isPlatformCompatibleBinary(filePath) {
|
|
|
93404
93612
|
return false;
|
|
93405
93613
|
}
|
|
93406
93614
|
const magic = header.readUInt32BE(0);
|
|
93407
|
-
const
|
|
93408
|
-
if (
|
|
93615
|
+
const platform3 = import_node_os16.default.platform();
|
|
93616
|
+
if (platform3 === "darwin") {
|
|
93409
93617
|
return isMachOBinary(magic);
|
|
93410
93618
|
}
|
|
93411
|
-
if (
|
|
93619
|
+
if (platform3 === "linux") {
|
|
93412
93620
|
return magic === 2135247942;
|
|
93413
93621
|
}
|
|
93414
93622
|
return true;
|
|
@@ -94037,52 +94245,52 @@ var import_node_child_process15 = require("node:child_process");
|
|
|
94037
94245
|
|
|
94038
94246
|
// packages/config/dist/project-namespace.js
|
|
94039
94247
|
var import_node_crypto16 = __toESM(require("node:crypto"), 1);
|
|
94040
|
-
var
|
|
94248
|
+
var import_node_path41 = __toESM(require("node:path"), 1);
|
|
94041
94249
|
var import_node_fs29 = __toESM(require("node:fs"), 1);
|
|
94042
|
-
var
|
|
94250
|
+
var import_node_os17 = __toESM(require("node:os"), 1);
|
|
94043
94251
|
function getGlobalBaseDir2() {
|
|
94044
94252
|
if (process.env.AGENT_RELAY_DATA_DIR) {
|
|
94045
94253
|
return process.env.AGENT_RELAY_DATA_DIR;
|
|
94046
94254
|
}
|
|
94047
94255
|
const xdgDataHome = process.env.XDG_DATA_HOME;
|
|
94048
94256
|
if (xdgDataHome) {
|
|
94049
|
-
return
|
|
94257
|
+
return import_node_path41.default.join(xdgDataHome, "agent-relay");
|
|
94050
94258
|
}
|
|
94051
|
-
return
|
|
94259
|
+
return import_node_path41.default.join(import_node_os17.default.homedir(), ".agent-relay");
|
|
94052
94260
|
}
|
|
94053
94261
|
var GLOBAL_BASE_DIR2 = getGlobalBaseDir2();
|
|
94054
94262
|
var PROJECT_DATA_DIR = ".agent-relay";
|
|
94055
94263
|
function hashPath(projectPath) {
|
|
94056
|
-
const normalized =
|
|
94264
|
+
const normalized = import_node_path41.default.resolve(projectPath);
|
|
94057
94265
|
const hash2 = import_node_crypto16.default.createHash("sha256").update(normalized).digest("hex");
|
|
94058
94266
|
return hash2.substring(0, 12);
|
|
94059
94267
|
}
|
|
94060
94268
|
function findProjectRoot(startDir = process.cwd()) {
|
|
94061
94269
|
if (process.env.AGENT_RELAY_PROJECT) {
|
|
94062
|
-
return
|
|
94270
|
+
return import_node_path41.default.resolve(process.env.AGENT_RELAY_PROJECT);
|
|
94063
94271
|
}
|
|
94064
|
-
let current =
|
|
94065
|
-
const root =
|
|
94272
|
+
let current = import_node_path41.default.resolve(startDir);
|
|
94273
|
+
const root = import_node_path41.default.parse(current).root;
|
|
94066
94274
|
const markers = [".git", "package.json", "Cargo.toml", "go.mod", "pyproject.toml", ".agent-relay"];
|
|
94067
94275
|
while (current !== root) {
|
|
94068
94276
|
for (const marker of markers) {
|
|
94069
|
-
if (import_node_fs29.default.existsSync(
|
|
94277
|
+
if (import_node_fs29.default.existsSync(import_node_path41.default.join(current, marker))) {
|
|
94070
94278
|
return current;
|
|
94071
94279
|
}
|
|
94072
94280
|
}
|
|
94073
|
-
current =
|
|
94281
|
+
current = import_node_path41.default.dirname(current);
|
|
94074
94282
|
}
|
|
94075
|
-
return
|
|
94283
|
+
return import_node_path41.default.resolve(startDir);
|
|
94076
94284
|
}
|
|
94077
94285
|
function getProjectPaths2(projectRoot) {
|
|
94078
94286
|
const root = projectRoot ?? findProjectRoot();
|
|
94079
94287
|
const projectId = hashPath(root);
|
|
94080
|
-
const dataDir =
|
|
94288
|
+
const dataDir = import_node_path41.default.join(root, PROJECT_DATA_DIR);
|
|
94081
94289
|
return {
|
|
94082
94290
|
dataDir,
|
|
94083
|
-
teamDir:
|
|
94084
|
-
dbPath:
|
|
94085
|
-
socketPath:
|
|
94291
|
+
teamDir: import_node_path41.default.join(dataDir, "team"),
|
|
94292
|
+
dbPath: import_node_path41.default.join(dataDir, "messages.sqlite"),
|
|
94293
|
+
socketPath: import_node_path41.default.join(dataDir, "relay.sock"),
|
|
94086
94294
|
projectRoot: root,
|
|
94087
94295
|
projectId
|
|
94088
94296
|
};
|
|
@@ -94090,22 +94298,22 @@ function getProjectPaths2(projectRoot) {
|
|
|
94090
94298
|
|
|
94091
94299
|
// packages/config/dist/trajectory-config.js
|
|
94092
94300
|
var import_node_fs30 = require("node:fs");
|
|
94093
|
-
var
|
|
94094
|
-
var
|
|
94301
|
+
var import_node_path42 = require("node:path");
|
|
94302
|
+
var import_node_os18 = require("node:os");
|
|
94095
94303
|
var import_node_crypto17 = require("node:crypto");
|
|
94096
94304
|
function getAgentRelayConfigDir() {
|
|
94097
|
-
return process.env.AGENT_RELAY_CONFIG_DIR ?? (0,
|
|
94305
|
+
return process.env.AGENT_RELAY_CONFIG_DIR ?? (0, import_node_path42.join)((0, import_node_os18.homedir)(), ".config", "agent-relay");
|
|
94098
94306
|
}
|
|
94099
94307
|
var configCache = null;
|
|
94100
94308
|
function getRelayConfigPath(_projectRoot) {
|
|
94101
|
-
return (0,
|
|
94309
|
+
return (0, import_node_path42.join)(getAgentRelayConfigDir(), "relay.json");
|
|
94102
94310
|
}
|
|
94103
94311
|
function readRelayConfig(projectRoot) {
|
|
94104
94312
|
const configPath = getRelayConfigPath(projectRoot);
|
|
94105
94313
|
if (configCache && configCache.path === configPath) {
|
|
94106
94314
|
try {
|
|
94107
|
-
const
|
|
94108
|
-
if (
|
|
94315
|
+
const stat3 = (0, import_node_fs30.statSync)(configPath);
|
|
94316
|
+
if (stat3.mtimeMs === configCache.mtime) {
|
|
94109
94317
|
return configCache.config;
|
|
94110
94318
|
}
|
|
94111
94319
|
} catch {
|
|
@@ -94118,8 +94326,8 @@ function readRelayConfig(projectRoot) {
|
|
|
94118
94326
|
const content = (0, import_node_fs30.readFileSync)(configPath, "utf-8");
|
|
94119
94327
|
const config2 = JSON.parse(content);
|
|
94120
94328
|
try {
|
|
94121
|
-
const
|
|
94122
|
-
configCache = { path: configPath, config: config2, mtime:
|
|
94329
|
+
const stat3 = (0, import_node_fs30.statSync)(configPath);
|
|
94330
|
+
configCache = { path: configPath, config: config2, mtime: stat3.mtimeMs };
|
|
94123
94331
|
} catch {
|
|
94124
94332
|
}
|
|
94125
94333
|
return config2;
|
|
@@ -94138,12 +94346,12 @@ function getProjectHash(projectRoot) {
|
|
|
94138
94346
|
}
|
|
94139
94347
|
function getUserTrajectoriesDir(projectRoot) {
|
|
94140
94348
|
const projectHash = getProjectHash(projectRoot);
|
|
94141
|
-
const configDir = process.env.XDG_CONFIG_HOME || (0,
|
|
94142
|
-
return (0,
|
|
94349
|
+
const configDir = process.env.XDG_CONFIG_HOME || (0, import_node_path42.join)((0, import_node_os18.homedir)(), ".config");
|
|
94350
|
+
return (0, import_node_path42.join)(configDir, "agent-relay", "trajectories", projectHash);
|
|
94143
94351
|
}
|
|
94144
94352
|
function getRepoTrajectoriesDir(projectRoot) {
|
|
94145
94353
|
const root = projectRoot ?? getProjectPaths2().projectRoot;
|
|
94146
|
-
return (0,
|
|
94354
|
+
return (0, import_node_path42.join)(root, ".trajectories");
|
|
94147
94355
|
}
|
|
94148
94356
|
function getPrimaryTrajectoriesDir(projectRoot) {
|
|
94149
94357
|
if (shouldStoreInRepo(projectRoot)) {
|
|
@@ -94784,7 +94992,7 @@ var HookEmitter = class {
|
|
|
94784
94992
|
|
|
94785
94993
|
// packages/hooks/dist/inbox-check/utils.js
|
|
94786
94994
|
var import_node_fs31 = require("node:fs");
|
|
94787
|
-
var
|
|
94995
|
+
var import_node_path43 = require("node:path");
|
|
94788
94996
|
var DEFAULT_INBOX_DIR = "/tmp/agent-relay";
|
|
94789
94997
|
function getAgentName() {
|
|
94790
94998
|
return process.env.AGENT_RELAY_NAME;
|
|
@@ -94794,7 +95002,7 @@ function getInboxPath(config2) {
|
|
|
94794
95002
|
if (!agentName) {
|
|
94795
95003
|
throw new Error("Agent name not configured. Set AGENT_RELAY_NAME env var.");
|
|
94796
95004
|
}
|
|
94797
|
-
return (0,
|
|
95005
|
+
return (0, import_node_path43.join)(config2.inboxDir, agentName, "inbox.md");
|
|
94798
95006
|
}
|
|
94799
95007
|
function inboxExists(inboxPath) {
|
|
94800
95008
|
return (0, import_node_fs31.existsSync)(inboxPath);
|
|
@@ -94948,6 +95156,7 @@ init_dist2();
|
|
|
94948
95156
|
checkOutputContains,
|
|
94949
95157
|
cleanLines,
|
|
94950
95158
|
clearBinaryCache,
|
|
95159
|
+
clearBrokerLogs,
|
|
94951
95160
|
clearResolveCache,
|
|
94952
95161
|
collectCliSession,
|
|
94953
95162
|
collectOutput,
|
|
@@ -95001,6 +95210,7 @@ init_dist2();
|
|
|
95001
95210
|
generateUniqueAgentName,
|
|
95002
95211
|
getAgentName,
|
|
95003
95212
|
getBaseCli,
|
|
95213
|
+
getBrokerLogDir,
|
|
95004
95214
|
getCachedRelayPtyPath,
|
|
95005
95215
|
getCliDefinition,
|
|
95006
95216
|
getCliRegistry,
|
|
@@ -95044,6 +95254,7 @@ init_dist2();
|
|
|
95044
95254
|
isTrajectoryTrackingAvailable,
|
|
95045
95255
|
isValidAgentName,
|
|
95046
95256
|
isWorktreeStep,
|
|
95257
|
+
listBrokerLogs,
|
|
95047
95258
|
listLoggedAgents,
|
|
95048
95259
|
listPersonas,
|
|
95049
95260
|
listWorkflowSchedules,
|
|
@@ -95059,6 +95270,7 @@ init_dist2();
|
|
|
95059
95270
|
parseTsxStderr,
|
|
95060
95271
|
parseVoteCommand,
|
|
95061
95272
|
printUpdateNotification,
|
|
95273
|
+
pruneBrokerLogs,
|
|
95062
95274
|
readInbox,
|
|
95063
95275
|
resetPatternMetrics,
|
|
95064
95276
|
resolveAllCustomSteps,
|
|
@@ -95091,6 +95303,7 @@ init_dist2();
|
|
|
95091
95303
|
stripAnsi,
|
|
95092
95304
|
stripAnsiFast,
|
|
95093
95305
|
stripInjectedTaskEcho,
|
|
95306
|
+
tailBrokerLog,
|
|
95094
95307
|
toReleaseResult,
|
|
95095
95308
|
toSpawnResult,
|
|
95096
95309
|
trackPatternPerformance,
|