@drisp/cli 0.4.4 → 0.4.5
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/athena-gateway.js +195 -160
- package/dist/{chunk-6TJHAUNB.js → chunk-M44KEGM7.js} +15 -3
- package/dist/{chunk-JAPBSL7D.js → chunk-PJUDHH4R.js} +275 -148
- package/dist/cli.js +112 -4
- package/dist/dashboard-daemon.js +1 -1
- package/package.json +1 -1
|
@@ -11664,7 +11664,6 @@ var DEFAULT_RECONNECT_DELAYS_MS = [250, 1e3, 2e3, 5e3, 15e3];
|
|
|
11664
11664
|
var DEFAULT_HEARTBEAT_MS2 = 3e4;
|
|
11665
11665
|
var DEFAULT_WATCHDOG_MS = 9e4;
|
|
11666
11666
|
var DEFAULT_MAX_QUEUE_SIZE = 5e3;
|
|
11667
|
-
var TERMINAL_KINDS = /* @__PURE__ */ new Set(["completion", "error"]);
|
|
11668
11667
|
function createRunStreamClient(opts) {
|
|
11669
11668
|
const log = opts.log ?? (() => {
|
|
11670
11669
|
});
|
|
@@ -11889,9 +11888,8 @@ function createRunStreamClient(opts) {
|
|
|
11889
11888
|
});
|
|
11890
11889
|
},
|
|
11891
11890
|
sendEvent(input) {
|
|
11892
|
-
const seq = nextSeq++;
|
|
11893
11891
|
const frame = {
|
|
11894
|
-
seq
|
|
11892
|
+
seq: nextSeq++,
|
|
11895
11893
|
ts: input.ts,
|
|
11896
11894
|
kind: input.kind,
|
|
11897
11895
|
payload: input.payload ?? null
|
|
@@ -11914,9 +11912,6 @@ function createRunStreamClient(opts) {
|
|
|
11914
11912
|
);
|
|
11915
11913
|
}
|
|
11916
11914
|
}
|
|
11917
|
-
if (TERMINAL_KINDS.has(frame.kind)) {
|
|
11918
|
-
}
|
|
11919
|
-
return seq;
|
|
11920
11915
|
},
|
|
11921
11916
|
whenTerminated() {
|
|
11922
11917
|
if (serverTerminated) return Promise.resolve();
|
|
@@ -12078,104 +12073,106 @@ async function executeRemoteAssignment({
|
|
|
12078
12073
|
});
|
|
12079
12074
|
};
|
|
12080
12075
|
send("progress", { message: "assignment received" });
|
|
12081
|
-
const closeRunStream = async (reason) => {
|
|
12082
|
-
if (!runStream) return;
|
|
12083
|
-
const drainTimeout = new Promise((resolve) => {
|
|
12084
|
-
const t = setTimeout(() => resolve(), 1e4);
|
|
12085
|
-
t.unref?.();
|
|
12086
|
-
});
|
|
12087
|
-
await Promise.race([runStream.whenTerminated(), drainTimeout]);
|
|
12088
|
-
await runStream.close(reason);
|
|
12089
|
-
runStream = null;
|
|
12090
|
-
};
|
|
12091
|
-
if (!spec) {
|
|
12092
|
-
send("error", {
|
|
12093
|
-
message: "remote assignment missing prompt"
|
|
12094
|
-
});
|
|
12095
|
-
await closeRunStream("done");
|
|
12096
|
-
return;
|
|
12097
|
-
}
|
|
12098
|
-
const projectDir = spec.projectDir ?? fallbackProjectDir;
|
|
12099
|
-
let runtimeConfig;
|
|
12100
12076
|
try {
|
|
12101
|
-
|
|
12102
|
-
|
|
12103
|
-
|
|
12104
|
-
|
|
12105
|
-
|
|
12106
|
-
|
|
12107
|
-
|
|
12108
|
-
|
|
12109
|
-
|
|
12110
|
-
|
|
12111
|
-
|
|
12112
|
-
|
|
12113
|
-
|
|
12114
|
-
|
|
12115
|
-
|
|
12116
|
-
|
|
12117
|
-
|
|
12118
|
-
|
|
12119
|
-
|
|
12120
|
-
|
|
12121
|
-
|
|
12122
|
-
|
|
12123
|
-
|
|
12124
|
-
|
|
12125
|
-
|
|
12126
|
-
|
|
12127
|
-
|
|
12128
|
-
|
|
12129
|
-
|
|
12130
|
-
|
|
12131
|
-
|
|
12077
|
+
if (!spec) {
|
|
12078
|
+
send("error", { message: "remote assignment missing prompt" });
|
|
12079
|
+
return;
|
|
12080
|
+
}
|
|
12081
|
+
const projectDir = spec.projectDir ?? fallbackProjectDir;
|
|
12082
|
+
let runtimeConfig;
|
|
12083
|
+
try {
|
|
12084
|
+
runtimeConfig = bootstrapRuntimeConfigFn({
|
|
12085
|
+
projectDir,
|
|
12086
|
+
showSetup: false,
|
|
12087
|
+
isolationPreset: "minimal",
|
|
12088
|
+
workflowOverride: workflowNameFromRef(spec.workflow?.ref)
|
|
12089
|
+
});
|
|
12090
|
+
} catch (err) {
|
|
12091
|
+
send("error", {
|
|
12092
|
+
message: err instanceof Error ? err.message : String(err)
|
|
12093
|
+
});
|
|
12094
|
+
return;
|
|
12095
|
+
}
|
|
12096
|
+
for (const warning of runtimeConfig.warnings) {
|
|
12097
|
+
send("warning", { message: warning });
|
|
12098
|
+
}
|
|
12099
|
+
let buffered = "";
|
|
12100
|
+
const stdout = {
|
|
12101
|
+
write(chunk) {
|
|
12102
|
+
buffered += chunk;
|
|
12103
|
+
let newline = buffered.indexOf("\n");
|
|
12104
|
+
while (newline >= 0) {
|
|
12105
|
+
const line = buffered.slice(0, newline).trim();
|
|
12106
|
+
buffered = buffered.slice(newline + 1);
|
|
12107
|
+
if (line.length > 0) {
|
|
12108
|
+
try {
|
|
12109
|
+
const event = JSON.parse(line);
|
|
12110
|
+
const data = event.data;
|
|
12111
|
+
if (event.type === "exec.completed" && data?.success === false) {
|
|
12112
|
+
deferredFailedCompletion = event;
|
|
12113
|
+
continue;
|
|
12114
|
+
}
|
|
12115
|
+
send(eventKind(event), eventPayload(event), now());
|
|
12116
|
+
} catch (err) {
|
|
12117
|
+
send("progress", { line });
|
|
12118
|
+
log(
|
|
12119
|
+
"warn",
|
|
12120
|
+
`remote run emitted malformed JSONL: ${err instanceof Error ? err.message : String(err)}`
|
|
12121
|
+
);
|
|
12132
12122
|
}
|
|
12133
|
-
send(eventKind(event), eventPayload(event), now());
|
|
12134
|
-
} catch (err) {
|
|
12135
|
-
send("progress", { line });
|
|
12136
|
-
log(
|
|
12137
|
-
"warn",
|
|
12138
|
-
`remote run emitted malformed JSONL: ${err instanceof Error ? err.message : String(err)}`
|
|
12139
|
-
);
|
|
12140
12123
|
}
|
|
12124
|
+
newline = buffered.indexOf("\n");
|
|
12141
12125
|
}
|
|
12142
|
-
|
|
12126
|
+
return true;
|
|
12143
12127
|
}
|
|
12144
|
-
|
|
12145
|
-
|
|
12146
|
-
|
|
12147
|
-
|
|
12148
|
-
|
|
12149
|
-
|
|
12150
|
-
|
|
12151
|
-
|
|
12152
|
-
|
|
12153
|
-
|
|
12154
|
-
|
|
12155
|
-
|
|
12156
|
-
|
|
12157
|
-
|
|
12158
|
-
|
|
12159
|
-
|
|
12160
|
-
|
|
12161
|
-
|
|
12162
|
-
|
|
12163
|
-
|
|
12164
|
-
|
|
12165
|
-
|
|
12166
|
-
|
|
12167
|
-
|
|
12168
|
-
|
|
12169
|
-
|
|
12170
|
-
|
|
12171
|
-
|
|
12172
|
-
|
|
12173
|
-
|
|
12174
|
-
|
|
12175
|
-
|
|
12176
|
-
|
|
12177
|
-
|
|
12178
|
-
|
|
12128
|
+
};
|
|
12129
|
+
const stderr = {
|
|
12130
|
+
write(chunk) {
|
|
12131
|
+
const text = chunk.trim();
|
|
12132
|
+
if (text.length > 0) send("stderr", { text });
|
|
12133
|
+
return true;
|
|
12134
|
+
}
|
|
12135
|
+
};
|
|
12136
|
+
try {
|
|
12137
|
+
await withEnv(spec.env, async () => {
|
|
12138
|
+
const result = await runExecFn({
|
|
12139
|
+
prompt: spec.prompt,
|
|
12140
|
+
projectDir,
|
|
12141
|
+
harness: runtimeConfig.harness,
|
|
12142
|
+
athenaSessionId: spec.sessionId ?? `athena-${frame.runId}`,
|
|
12143
|
+
isolationConfig: runtimeConfig.isolationConfig,
|
|
12144
|
+
pluginMcpConfig: runtimeConfig.pluginMcpConfig,
|
|
12145
|
+
workflow: runtimeConfig.workflow,
|
|
12146
|
+
workflowPlan: runtimeConfig.workflowPlan,
|
|
12147
|
+
json: true,
|
|
12148
|
+
verbose: false,
|
|
12149
|
+
ephemeral: false,
|
|
12150
|
+
timeoutMs: spec.timeoutSec ? spec.timeoutSec * 1e3 : void 0,
|
|
12151
|
+
signal: abortSignal,
|
|
12152
|
+
stdout,
|
|
12153
|
+
stderr
|
|
12154
|
+
});
|
|
12155
|
+
if (deferredFailedCompletion) {
|
|
12156
|
+
const data = typeof deferredFailedCompletion.data === "object" && deferredFailedCompletion.data !== null ? deferredFailedCompletion.data : {};
|
|
12157
|
+
send(
|
|
12158
|
+
"error",
|
|
12159
|
+
{
|
|
12160
|
+
...data,
|
|
12161
|
+
success: result.success,
|
|
12162
|
+
exitCode: result.exitCode,
|
|
12163
|
+
athenaSessionId: result.athenaSessionId,
|
|
12164
|
+
adapterSessionId: result.adapterSessionId,
|
|
12165
|
+
finalMessage: result.finalMessage,
|
|
12166
|
+
tokens: result.tokens,
|
|
12167
|
+
durationMs: result.durationMs,
|
|
12168
|
+
message: result.failure?.message ?? eventPayload(deferredFailedCompletion).message ?? "remote execution failed"
|
|
12169
|
+
},
|
|
12170
|
+
typeof deferredFailedCompletion.ts === "number" ? deferredFailedCompletion.ts : now()
|
|
12171
|
+
);
|
|
12172
|
+
return;
|
|
12173
|
+
}
|
|
12174
|
+
if (result.failure && result.failure.message !== lastTerminalFailureMessage) {
|
|
12175
|
+
send("error", {
|
|
12179
12176
|
success: result.success,
|
|
12180
12177
|
exitCode: result.exitCode,
|
|
12181
12178
|
athenaSessionId: result.athenaSessionId,
|
|
@@ -12183,33 +12180,139 @@ async function executeRemoteAssignment({
|
|
|
12183
12180
|
finalMessage: result.finalMessage,
|
|
12184
12181
|
tokens: result.tokens,
|
|
12185
12182
|
durationMs: result.durationMs,
|
|
12186
|
-
message: result.failure
|
|
12187
|
-
}
|
|
12188
|
-
|
|
12189
|
-
|
|
12190
|
-
|
|
12191
|
-
|
|
12192
|
-
|
|
12193
|
-
|
|
12194
|
-
|
|
12195
|
-
|
|
12196
|
-
|
|
12197
|
-
|
|
12198
|
-
|
|
12199
|
-
|
|
12200
|
-
|
|
12201
|
-
|
|
12202
|
-
|
|
12203
|
-
|
|
12204
|
-
|
|
12183
|
+
message: result.failure.message
|
|
12184
|
+
});
|
|
12185
|
+
}
|
|
12186
|
+
});
|
|
12187
|
+
} catch (err) {
|
|
12188
|
+
send("error", {
|
|
12189
|
+
message: err instanceof Error ? err.message : String(err)
|
|
12190
|
+
});
|
|
12191
|
+
}
|
|
12192
|
+
} finally {
|
|
12193
|
+
if (runStream) {
|
|
12194
|
+
const drainTimeout = new Promise((resolve) => {
|
|
12195
|
+
const t = setTimeout(() => resolve(), 1e4);
|
|
12196
|
+
t.unref?.();
|
|
12197
|
+
});
|
|
12198
|
+
await Promise.race([runStream.whenTerminated(), drainTimeout]);
|
|
12199
|
+
await runStream.close("done");
|
|
12200
|
+
}
|
|
12201
|
+
}
|
|
12202
|
+
}
|
|
12203
|
+
|
|
12204
|
+
// src/infra/config/attachmentMirror.ts
|
|
12205
|
+
import crypto3 from "crypto";
|
|
12206
|
+
import fs20 from "fs";
|
|
12207
|
+
import os11 from "os";
|
|
12208
|
+
import path18 from "path";
|
|
12209
|
+
function attachmentMirrorPath(env = process.env) {
|
|
12210
|
+
const home = env["HOME"] ?? os11.homedir();
|
|
12211
|
+
return path18.join(home, ".config", "athena", "attachments.json");
|
|
12212
|
+
}
|
|
12213
|
+
function readAttachmentMirror(env = process.env) {
|
|
12214
|
+
const file = attachmentMirrorPath(env);
|
|
12215
|
+
let raw;
|
|
12216
|
+
try {
|
|
12217
|
+
raw = fs20.readFileSync(file, "utf-8");
|
|
12205
12218
|
} catch (err) {
|
|
12206
|
-
|
|
12207
|
-
|
|
12208
|
-
|
|
12219
|
+
if (err.code === "ENOENT") return null;
|
|
12220
|
+
throw err;
|
|
12221
|
+
}
|
|
12222
|
+
let parsed;
|
|
12223
|
+
try {
|
|
12224
|
+
parsed = JSON.parse(raw);
|
|
12225
|
+
} catch (err) {
|
|
12226
|
+
throw new Error(
|
|
12227
|
+
`attachment mirror ${file} is invalid JSON: ${err instanceof Error ? err.message : String(err)}`
|
|
12228
|
+
);
|
|
12229
|
+
}
|
|
12230
|
+
try {
|
|
12231
|
+
return parseAttachmentMirror(parsed);
|
|
12232
|
+
} catch (err) {
|
|
12233
|
+
throw new Error(
|
|
12234
|
+
`attachment mirror ${file} is invalid: ${err instanceof Error ? err.message : String(err)}`
|
|
12235
|
+
);
|
|
12236
|
+
}
|
|
12237
|
+
}
|
|
12238
|
+
function writeAttachmentMirror(mirror, env = process.env) {
|
|
12239
|
+
const validated = parseAttachmentMirror(mirror);
|
|
12240
|
+
const file = attachmentMirrorPath(env);
|
|
12241
|
+
const dir = path18.dirname(file);
|
|
12242
|
+
fs20.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
12243
|
+
const tmp = `${file}.${process.pid}.${crypto3.randomBytes(4).toString("hex")}.tmp`;
|
|
12244
|
+
const fd = fs20.openSync(tmp, "w", 384);
|
|
12245
|
+
try {
|
|
12246
|
+
fs20.writeSync(fd, JSON.stringify(validated, null, 2) + "\n");
|
|
12247
|
+
fs20.fsyncSync(fd);
|
|
12209
12248
|
} finally {
|
|
12210
|
-
|
|
12249
|
+
fs20.closeSync(fd);
|
|
12250
|
+
}
|
|
12251
|
+
try {
|
|
12252
|
+
fs20.renameSync(tmp, file);
|
|
12253
|
+
} catch (err) {
|
|
12254
|
+
try {
|
|
12255
|
+
fs20.unlinkSync(tmp);
|
|
12256
|
+
} catch {
|
|
12257
|
+
}
|
|
12258
|
+
throw err;
|
|
12259
|
+
}
|
|
12260
|
+
if (process.platform !== "win32") {
|
|
12261
|
+
try {
|
|
12262
|
+
fs20.chmodSync(dir, 448);
|
|
12263
|
+
fs20.chmodSync(file, 384);
|
|
12264
|
+
} catch {
|
|
12265
|
+
}
|
|
12211
12266
|
}
|
|
12212
12267
|
}
|
|
12268
|
+
function removeAttachmentMirror(env = process.env) {
|
|
12269
|
+
const file = attachmentMirrorPath(env);
|
|
12270
|
+
try {
|
|
12271
|
+
fs20.unlinkSync(file);
|
|
12272
|
+
} catch (err) {
|
|
12273
|
+
if (err.code !== "ENOENT") throw err;
|
|
12274
|
+
}
|
|
12275
|
+
}
|
|
12276
|
+
function parseAttachmentMirror(raw) {
|
|
12277
|
+
if (typeof raw !== "object" || raw === null) {
|
|
12278
|
+
throw new Error("root must be an object");
|
|
12279
|
+
}
|
|
12280
|
+
const obj = raw;
|
|
12281
|
+
if (typeof obj["instanceId"] !== "string" || obj["instanceId"].length === 0) {
|
|
12282
|
+
throw new Error("instanceId must be a non-empty string");
|
|
12283
|
+
}
|
|
12284
|
+
if (typeof obj["fetchedAt"] !== "number") {
|
|
12285
|
+
throw new Error("fetchedAt must be a number");
|
|
12286
|
+
}
|
|
12287
|
+
if (!Array.isArray(obj["attachments"])) {
|
|
12288
|
+
throw new Error("attachments must be an array");
|
|
12289
|
+
}
|
|
12290
|
+
const attachments = obj["attachments"].map((entry, idx) => {
|
|
12291
|
+
if (typeof entry !== "object" || entry === null) {
|
|
12292
|
+
throw new Error(`attachments[${idx}] must be an object`);
|
|
12293
|
+
}
|
|
12294
|
+
const e = entry;
|
|
12295
|
+
if (typeof e["runnerId"] !== "string" || e["runnerId"].length === 0) {
|
|
12296
|
+
throw new Error(
|
|
12297
|
+
`attachments[${idx}].runnerId must be a non-empty string`
|
|
12298
|
+
);
|
|
12299
|
+
}
|
|
12300
|
+
const out = { runnerId: e["runnerId"] };
|
|
12301
|
+
if (typeof e["name"] === "string") out.name = e["name"];
|
|
12302
|
+
if (typeof e["executionTarget"] === "string") {
|
|
12303
|
+
out.executionTarget = e["executionTarget"];
|
|
12304
|
+
}
|
|
12305
|
+
if (typeof e["remoteInstanceId"] === "string") {
|
|
12306
|
+
out.remoteInstanceId = e["remoteInstanceId"];
|
|
12307
|
+
}
|
|
12308
|
+
return out;
|
|
12309
|
+
});
|
|
12310
|
+
return {
|
|
12311
|
+
instanceId: obj["instanceId"],
|
|
12312
|
+
fetchedAt: obj["fetchedAt"],
|
|
12313
|
+
attachments
|
|
12314
|
+
};
|
|
12315
|
+
}
|
|
12213
12316
|
|
|
12214
12317
|
// src/app/dashboard/runtimeDaemon.ts
|
|
12215
12318
|
var DEFAULT_RECONNECT_DELAYS_MS2 = [1e3, 2e3, 5e3, 1e4, 3e4];
|
|
@@ -12246,6 +12349,7 @@ async function runDashboardRuntimeDaemon(options = {}) {
|
|
|
12246
12349
|
const refreshCooldownMs = options.refreshCooldownMs ?? DEFAULT_REFRESH_COOLDOWN_MS;
|
|
12247
12350
|
const runHistoryLimit = options.runHistoryLimit ?? DEFAULT_RUN_HISTORY_LIMIT;
|
|
12248
12351
|
const now = options.now ?? (() => Date.now());
|
|
12352
|
+
const writeMirror = options.writeMirror ?? writeAttachmentMirror;
|
|
12249
12353
|
const startedAt = now();
|
|
12250
12354
|
let stopped = false;
|
|
12251
12355
|
let reconnectAttempt = 0;
|
|
@@ -12379,6 +12483,26 @@ async function runDashboardRuntimeDaemon(options = {}) {
|
|
|
12379
12483
|
});
|
|
12380
12484
|
next.onFrame((frame) => {
|
|
12381
12485
|
lastFrameAt = now();
|
|
12486
|
+
if (frame.type === "attachments.changed") {
|
|
12487
|
+
try {
|
|
12488
|
+
writeMirror({
|
|
12489
|
+
instanceId: token.instanceId,
|
|
12490
|
+
fetchedAt: now(),
|
|
12491
|
+
attachments: frame.attachments.map((a) => ({
|
|
12492
|
+
runnerId: a.runnerId,
|
|
12493
|
+
...a.name !== void 0 ? { name: a.name } : {},
|
|
12494
|
+
...a.executionTarget !== void 0 ? { executionTarget: a.executionTarget } : {},
|
|
12495
|
+
...a.remoteInstanceId !== void 0 ? { remoteInstanceId: a.remoteInstanceId } : {}
|
|
12496
|
+
}))
|
|
12497
|
+
});
|
|
12498
|
+
} catch (err) {
|
|
12499
|
+
log(
|
|
12500
|
+
"warn",
|
|
12501
|
+
`runtime daemon: failed to write attachment mirror: ${err instanceof Error ? err.message : String(err)}`
|
|
12502
|
+
);
|
|
12503
|
+
}
|
|
12504
|
+
return;
|
|
12505
|
+
}
|
|
12382
12506
|
if (frame.type === "cancel") {
|
|
12383
12507
|
const entry = active.get(frame.runId);
|
|
12384
12508
|
if (entry) {
|
|
@@ -12503,27 +12627,27 @@ async function runDashboardRuntimeDaemon(options = {}) {
|
|
|
12503
12627
|
}
|
|
12504
12628
|
|
|
12505
12629
|
// src/infra/daemon/stateDir.ts
|
|
12506
|
-
import
|
|
12507
|
-
import
|
|
12508
|
-
import
|
|
12630
|
+
import fs21 from "fs";
|
|
12631
|
+
import os12 from "os";
|
|
12632
|
+
import path19 from "path";
|
|
12509
12633
|
function daemonStatePaths(env = process.env) {
|
|
12510
12634
|
const xdg = env["XDG_STATE_HOME"];
|
|
12511
|
-
const home = env["HOME"] ??
|
|
12512
|
-
const base = xdg && xdg.length > 0 ? xdg :
|
|
12513
|
-
const dir =
|
|
12635
|
+
const home = env["HOME"] ?? os12.homedir();
|
|
12636
|
+
const base = xdg && xdg.length > 0 ? xdg : path19.join(home, ".local", "state");
|
|
12637
|
+
const dir = path19.join(base, "drisp");
|
|
12514
12638
|
return {
|
|
12515
12639
|
dir,
|
|
12516
|
-
pidPath:
|
|
12517
|
-
logPath:
|
|
12518
|
-
socketPath:
|
|
12640
|
+
pidPath: path19.join(dir, "dashboard-daemon.pid"),
|
|
12641
|
+
logPath: path19.join(dir, "dashboard-daemon.log"),
|
|
12642
|
+
socketPath: path19.join(dir, "dashboard-daemon.sock")
|
|
12519
12643
|
};
|
|
12520
12644
|
}
|
|
12521
12645
|
function ensureDaemonStateDir(env = process.env) {
|
|
12522
12646
|
const paths = daemonStatePaths(env);
|
|
12523
|
-
|
|
12647
|
+
fs21.mkdirSync(paths.dir, { recursive: true, mode: 448 });
|
|
12524
12648
|
if (process.platform !== "win32") {
|
|
12525
12649
|
try {
|
|
12526
|
-
|
|
12650
|
+
fs21.chmodSync(paths.dir, 448);
|
|
12527
12651
|
} catch {
|
|
12528
12652
|
}
|
|
12529
12653
|
}
|
|
@@ -12531,18 +12655,18 @@ function ensureDaemonStateDir(env = process.env) {
|
|
|
12531
12655
|
}
|
|
12532
12656
|
|
|
12533
12657
|
// src/infra/daemon/pidLock.ts
|
|
12534
|
-
import
|
|
12658
|
+
import fs22 from "fs";
|
|
12535
12659
|
function acquirePidLock(pidPath) {
|
|
12536
12660
|
const ownPid = process.pid;
|
|
12537
12661
|
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
12538
12662
|
try {
|
|
12539
|
-
const fd =
|
|
12663
|
+
const fd = fs22.openSync(pidPath, "wx", 384);
|
|
12540
12664
|
try {
|
|
12541
|
-
|
|
12665
|
+
fs22.writeSync(fd, `${ownPid}
|
|
12542
12666
|
`);
|
|
12543
|
-
|
|
12667
|
+
fs22.fsyncSync(fd);
|
|
12544
12668
|
} finally {
|
|
12545
|
-
|
|
12669
|
+
fs22.closeSync(fd);
|
|
12546
12670
|
}
|
|
12547
12671
|
return makeHandle(pidPath, ownPid);
|
|
12548
12672
|
} catch (err) {
|
|
@@ -12556,7 +12680,7 @@ function acquirePidLock(pidPath) {
|
|
|
12556
12680
|
}
|
|
12557
12681
|
if (existing.state === "stale") {
|
|
12558
12682
|
try {
|
|
12559
|
-
|
|
12683
|
+
fs22.unlinkSync(pidPath);
|
|
12560
12684
|
} catch (err) {
|
|
12561
12685
|
if (err.code !== "ENOENT") throw err;
|
|
12562
12686
|
}
|
|
@@ -12570,7 +12694,7 @@ function acquirePidLock(pidPath) {
|
|
|
12570
12694
|
function readPidLock(pidPath) {
|
|
12571
12695
|
let raw;
|
|
12572
12696
|
try {
|
|
12573
|
-
raw =
|
|
12697
|
+
raw = fs22.readFileSync(pidPath, "utf-8");
|
|
12574
12698
|
} catch (err) {
|
|
12575
12699
|
if (err.code === "ENOENT") {
|
|
12576
12700
|
return { state: "absent" };
|
|
@@ -12594,9 +12718,9 @@ function makeHandle(pidPath, pid) {
|
|
|
12594
12718
|
if (released) return;
|
|
12595
12719
|
released = true;
|
|
12596
12720
|
try {
|
|
12597
|
-
const raw =
|
|
12721
|
+
const raw = fs22.readFileSync(pidPath, "utf-8").trim();
|
|
12598
12722
|
if (raw === String(pid)) {
|
|
12599
|
-
|
|
12723
|
+
fs22.unlinkSync(pidPath);
|
|
12600
12724
|
}
|
|
12601
12725
|
} catch (err) {
|
|
12602
12726
|
if (err.code !== "ENOENT") {
|
|
@@ -12622,7 +12746,7 @@ function isProcessAlive(pid) {
|
|
|
12622
12746
|
}
|
|
12623
12747
|
|
|
12624
12748
|
// src/infra/daemon/udsIpc.ts
|
|
12625
|
-
import
|
|
12749
|
+
import fs23 from "fs";
|
|
12626
12750
|
import net2 from "net";
|
|
12627
12751
|
|
|
12628
12752
|
// src/infra/daemon/udsFrameCodec.ts
|
|
@@ -12667,7 +12791,7 @@ async function startUdsServer(socketPath, handler, log) {
|
|
|
12667
12791
|
});
|
|
12668
12792
|
if (process.platform !== "win32") {
|
|
12669
12793
|
try {
|
|
12670
|
-
|
|
12794
|
+
fs23.chmodSync(socketPath, 384);
|
|
12671
12795
|
} catch {
|
|
12672
12796
|
}
|
|
12673
12797
|
}
|
|
@@ -12677,7 +12801,7 @@ async function startUdsServer(socketPath, handler, log) {
|
|
|
12677
12801
|
server.close(() => resolve());
|
|
12678
12802
|
});
|
|
12679
12803
|
try {
|
|
12680
|
-
|
|
12804
|
+
fs23.unlinkSync(socketPath);
|
|
12681
12805
|
} catch (err) {
|
|
12682
12806
|
if (err.code !== "ENOENT") {
|
|
12683
12807
|
}
|
|
@@ -12795,7 +12919,7 @@ async function sendUdsRequest(socketPath, request, options = {}) {
|
|
|
12795
12919
|
async function unlinkStaleSocket(socketPath) {
|
|
12796
12920
|
let stat;
|
|
12797
12921
|
try {
|
|
12798
|
-
stat =
|
|
12922
|
+
stat = fs23.statSync(socketPath);
|
|
12799
12923
|
} catch (err) {
|
|
12800
12924
|
if (err.code === "ENOENT") return;
|
|
12801
12925
|
throw err;
|
|
@@ -12822,7 +12946,7 @@ async function unlinkStaleSocket(socketPath) {
|
|
|
12822
12946
|
`uds path ${socketPath} is in use by another process; aborting`
|
|
12823
12947
|
);
|
|
12824
12948
|
}
|
|
12825
|
-
|
|
12949
|
+
fs23.unlinkSync(socketPath);
|
|
12826
12950
|
}
|
|
12827
12951
|
|
|
12828
12952
|
export {
|
|
@@ -12887,6 +13011,9 @@ export {
|
|
|
12887
13011
|
bootstrapRuntimeConfig,
|
|
12888
13012
|
EXEC_EXIT_CODE,
|
|
12889
13013
|
runExec,
|
|
13014
|
+
readAttachmentMirror,
|
|
13015
|
+
writeAttachmentMirror,
|
|
13016
|
+
removeAttachmentMirror,
|
|
12890
13017
|
runDashboardRuntimeDaemon,
|
|
12891
13018
|
daemonStatePaths,
|
|
12892
13019
|
ensureDaemonStateDir,
|
|
@@ -12895,4 +13022,4 @@ export {
|
|
|
12895
13022
|
startUdsServer,
|
|
12896
13023
|
sendUdsRequest
|
|
12897
13024
|
};
|
|
12898
|
-
//# sourceMappingURL=chunk-
|
|
13025
|
+
//# sourceMappingURL=chunk-PJUDHH4R.js.map
|