@canonmsg/agent-sdk 12.2.0 → 12.2.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.
|
@@ -11269,12 +11269,31 @@ function isProcessAlive(pid) {
|
|
|
11269
11269
|
}
|
|
11270
11270
|
}
|
|
11271
11271
|
__name(isProcessAlive, "isProcessAlive");
|
|
11272
|
+
function processIdentity(pid) {
|
|
11273
|
+
if (process.platform !== "linux") return void 0;
|
|
11274
|
+
try {
|
|
11275
|
+
const bootId = readFileSync2("/proc/sys/kernel/random/boot_id", "utf8").trim();
|
|
11276
|
+
const stat3 = readFileSync2(`/proc/${pid}/stat`, "utf8");
|
|
11277
|
+
const startTicks = stat3.slice(stat3.lastIndexOf(")") + 2).split(/\s+/)[19];
|
|
11278
|
+
if (!/^[a-f0-9-]{36}$/.test(bootId) || !startTicks || !/^\d+$/.test(startTicks)) return void 0;
|
|
11279
|
+
return { bootId, startTicks };
|
|
11280
|
+
} catch {
|
|
11281
|
+
return void 0;
|
|
11282
|
+
}
|
|
11283
|
+
}
|
|
11284
|
+
__name(processIdentity, "processIdentity");
|
|
11285
|
+
function sameProcess(owner) {
|
|
11286
|
+
if (!owner.processIdentity) return true;
|
|
11287
|
+
const current = processIdentity(owner.pid);
|
|
11288
|
+
return !current || current.bootId === owner.processIdentity.bootId && current.startTicks === owner.processIdentity.startTicks;
|
|
11289
|
+
}
|
|
11290
|
+
__name(sameProcess, "sameProcess");
|
|
11272
11291
|
function isProfileLocked(profile, home) {
|
|
11273
11292
|
const lockPath = join5(canonPaths(home).locks, `${profile}.lock`);
|
|
11274
11293
|
try {
|
|
11275
11294
|
const lock = parseLock(readFileSync2(lockPath, "utf-8"));
|
|
11276
11295
|
const pid = lock?.pid;
|
|
11277
|
-
if (pid && isProcessAlive(pid)) return { locked: true, pid };
|
|
11296
|
+
if (pid && isProcessAlive(pid) && sameProcess(lock)) return { locked: true, pid };
|
|
11278
11297
|
} catch {
|
|
11279
11298
|
}
|
|
11280
11299
|
return { locked: false };
|
|
@@ -11285,7 +11304,8 @@ function parseLock(raw) {
|
|
|
11285
11304
|
if (!trimmed) return null;
|
|
11286
11305
|
try {
|
|
11287
11306
|
const data = JSON.parse(trimmed);
|
|
11288
|
-
|
|
11307
|
+
if (data.processIdentity !== void 0 && (!data.processIdentity || typeof data.processIdentity.bootId !== "string" || !/^[a-f0-9-]{36}$/.test(data.processIdentity.bootId) || typeof data.processIdentity.startTicks !== "string" || !/^\d+$/.test(data.processIdentity.startTicks))) return null;
|
|
11308
|
+
return typeof data.pid === "number" ? { pid: data.pid, token: typeof data.token === "string" ? data.token : void 0, processIdentity: data.processIdentity } : null;
|
|
11289
11309
|
} catch {
|
|
11290
11310
|
return null;
|
|
11291
11311
|
}
|
|
@@ -11299,7 +11319,8 @@ function acquireLock(profile, home) {
|
|
|
11299
11319
|
const payload = JSON.stringify({
|
|
11300
11320
|
pid: process.pid,
|
|
11301
11321
|
token,
|
|
11302
|
-
acquiredAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
11322
|
+
acquiredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11323
|
+
processIdentity: processIdentity(process.pid)
|
|
11303
11324
|
});
|
|
11304
11325
|
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
11305
11326
|
try {
|
|
@@ -11331,7 +11352,7 @@ function acquireLock(profile, home) {
|
|
|
11331
11352
|
}
|
|
11332
11353
|
try {
|
|
11333
11354
|
process.kill(owner.pid, 0);
|
|
11334
|
-
throw new Error(`Agent "${profile}" is in use by another session (PID ${owner.pid})`);
|
|
11355
|
+
if (sameProcess(owner)) throw new Error(`Agent "${profile}" is in use by another session (PID ${owner.pid})`);
|
|
11335
11356
|
} catch (probeError) {
|
|
11336
11357
|
if (probeError.code !== "ESRCH") throw probeError;
|
|
11337
11358
|
}
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
sendMessageWithRetryChunked,
|
|
30
30
|
splitTextByUtf8Bytes,
|
|
31
31
|
verifyCanonRuntimeConnection
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-FCG2Z57F.js";
|
|
33
33
|
import {
|
|
34
34
|
CONNECTOR_RELAY_ANSWER_WITHIN_MS,
|
|
35
35
|
CONNECTOR_RELAY_INSTALLATION_PATTERN,
|
|
@@ -992,21 +992,33 @@ __name(connectorDriver, "connectorDriver");
|
|
|
992
992
|
|
|
993
993
|
// src/runner/home.ts
|
|
994
994
|
import { randomBytes } from "node:crypto";
|
|
995
|
-
import { closeSync, constants as constants2, fstatSync, fsyncSync, linkSync, mkdirSync, openSync, readSync, renameSync, rmSync, writeSync } from "node:fs";
|
|
995
|
+
import { closeSync, constants as constants2, fstatSync, fsyncSync, linkSync, mkdirSync, openSync, readSync, renameSync, rmSync, writeFileSync, writeSync } from "node:fs";
|
|
996
996
|
import { lstat, mkdir, realpath as realpath2 } from "node:fs/promises";
|
|
997
997
|
import { dirname as dirname3 } from "node:path";
|
|
998
998
|
var runnerLockName = /* @__PURE__ */ __name((environmentId, agentId) => `runner-${environmentId}-${agentId}`.replace(/[^\w.-]/g, "_"), "runnerLockName");
|
|
999
999
|
function writeDurable(file, text3) {
|
|
1000
|
-
|
|
1000
|
+
const directory = dirname3(file);
|
|
1001
|
+
const created = mkdirSync(directory, { recursive: true, mode: 448 });
|
|
1001
1002
|
const temporary = `${file}.${process.pid}.tmp`;
|
|
1002
1003
|
const fd = openSync(temporary, "w", 384);
|
|
1003
1004
|
try {
|
|
1004
|
-
|
|
1005
|
+
writeFileSync(fd, text3);
|
|
1005
1006
|
fsyncSync(fd);
|
|
1006
1007
|
} finally {
|
|
1007
1008
|
closeSync(fd);
|
|
1008
1009
|
}
|
|
1009
1010
|
renameSync(temporary, file);
|
|
1011
|
+
if (process.platform === "win32") return;
|
|
1012
|
+
const last = created ? dirname3(created) : directory;
|
|
1013
|
+
for (let path = directory; ; path = dirname3(path)) {
|
|
1014
|
+
const dir = openSync(path, "r");
|
|
1015
|
+
try {
|
|
1016
|
+
fsyncSync(dir);
|
|
1017
|
+
} finally {
|
|
1018
|
+
closeSync(dir);
|
|
1019
|
+
}
|
|
1020
|
+
if (path === last) break;
|
|
1021
|
+
}
|
|
1010
1022
|
}
|
|
1011
1023
|
__name(writeDurable, "writeDurable");
|
|
1012
1024
|
function privateKey(file, bytes = 32) {
|
package/dist/cli.js
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
runnerLockName,
|
|
23
23
|
startRelayChannel,
|
|
24
24
|
writeRelayCredential
|
|
25
|
-
} from "./chunks/chunk-
|
|
25
|
+
} from "./chunks/chunk-LFTYXZUY.js";
|
|
26
26
|
import {
|
|
27
27
|
CanonApiError,
|
|
28
28
|
CanonClient,
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
resolveCanonRuntimeConnection,
|
|
34
34
|
runCli,
|
|
35
35
|
verifyCanonRuntimeConnection
|
|
36
|
-
} from "./chunks/chunk-
|
|
36
|
+
} from "./chunks/chunk-FCG2Z57F.js";
|
|
37
37
|
import {
|
|
38
38
|
__name,
|
|
39
39
|
isCanonClientVersion
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
runMlsDevSetup,
|
|
19
19
|
runtimeDescriptor,
|
|
20
20
|
startRelayChannel
|
|
21
|
-
} from "./chunks/chunk-
|
|
21
|
+
} from "./chunks/chunk-LFTYXZUY.js";
|
|
22
22
|
import {
|
|
23
23
|
CanonApiError,
|
|
24
24
|
DEFAULT_ANTHROPIC_REQUEST_HEADROOM_BYTES,
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
toAnthropicImageBlock,
|
|
44
44
|
toAnthropicImageBlocksWithinBudget,
|
|
45
45
|
uploadMediaFile
|
|
46
|
-
} from "./chunks/chunk-
|
|
46
|
+
} from "./chunks/chunk-FCG2Z57F.js";
|
|
47
47
|
import "./chunks/chunk-J63YVAKA.js";
|
|
48
48
|
export {
|
|
49
49
|
CanonApiError,
|
package/dist/media.js
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
toAnthropicImageBlock,
|
|
19
19
|
toAnthropicImageBlocksWithinBudget,
|
|
20
20
|
uploadMediaFile
|
|
21
|
-
} from "./chunks/chunk-
|
|
21
|
+
} from "./chunks/chunk-FCG2Z57F.js";
|
|
22
22
|
import "./chunks/chunk-J63YVAKA.js";
|
|
23
23
|
export {
|
|
24
24
|
DEFAULT_ANTHROPIC_REQUEST_HEADROOM_BYTES,
|