@amaster.ai/employee-runtime-connector 0.1.11 → 0.1.13-beta.0
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.
|
@@ -24,9 +24,15 @@ export const BUILD_SUPPORTED_CAPABILITIES = Object.freeze([
|
|
|
24
24
|
"mirrorx_initialization_completion_v1",
|
|
25
25
|
"native_session_checkpoint_v1",
|
|
26
26
|
"pi_web_public_search_v1",
|
|
27
|
+
"pi_web_public_fetch_v1",
|
|
27
28
|
]);
|
|
28
29
|
|
|
29
30
|
const DYNAMIC_READINESS = Object.freeze({
|
|
31
|
+
pi_web_public_fetch_v1: {
|
|
32
|
+
reasonCode: "pi_web_fetch_extension_unavailable",
|
|
33
|
+
ready: (input) => input.executors.some((executor) => executor.kind === "pi")
|
|
34
|
+
&& input.piWebFetchReady === true,
|
|
35
|
+
},
|
|
30
36
|
pi_web_public_search_v1: {
|
|
31
37
|
reasonCode: "pi_web_search_extension_unavailable",
|
|
32
38
|
ready: (input) => input.executors.some((executor) => executor.kind === "pi")
|
|
@@ -4946,7 +4946,8 @@ var AMASTER_RUNTIME_CONNECTOR_CAPABILITIES = [
|
|
|
4946
4946
|
"mirrorx_initialization_context_v1",
|
|
4947
4947
|
"mirrorx_initialization_completion_v1",
|
|
4948
4948
|
"native_session_checkpoint_v1",
|
|
4949
|
-
"pi_web_public_search_v1"
|
|
4949
|
+
"pi_web_public_search_v1",
|
|
4950
|
+
"pi_web_public_fetch_v1"
|
|
4950
4951
|
];
|
|
4951
4952
|
var RUNTIME_EXECUTION_LANES = ["business", "conversation"];
|
|
4952
4953
|
var runtimeExecutionLaneSchema = external_exports.enum(RUNTIME_EXECUTION_LANES);
|
|
@@ -5462,10 +5463,20 @@ var EXTERNAL_WAIT_REASON_CODES = {
|
|
|
5462
5463
|
externalInputPending: "external_input_pending",
|
|
5463
5464
|
externalApprovalPending: "external_approval_pending",
|
|
5464
5465
|
externalDependencyPending: "external_dependency_pending",
|
|
5466
|
+
externalServiceUnavailable: "external_service_unavailable",
|
|
5465
5467
|
heligeGenerationInProgress: "helige_generation_in_progress",
|
|
5466
5468
|
heligeNewTurnNotObserved: "helige_new_turn_not_observed",
|
|
5467
5469
|
heligeGenerationStatusUnavailable: "helige_generation_status_unavailable"
|
|
5468
5470
|
};
|
|
5471
|
+
var EXTERNAL_WAIT_NEW_WRITE_REASON_CODES = [
|
|
5472
|
+
EXTERNAL_WAIT_REASON_CODES.browserHumanSessionHandoffRequired,
|
|
5473
|
+
EXTERNAL_WAIT_REASON_CODES.externalDependencyPending,
|
|
5474
|
+
EXTERNAL_WAIT_REASON_CODES.externalServiceUnavailable,
|
|
5475
|
+
EXTERNAL_WAIT_REASON_CODES.wikiOperationContextMissing,
|
|
5476
|
+
EXTERNAL_WAIT_REASON_CODES.agentInsufficientBalance,
|
|
5477
|
+
EXTERNAL_WAIT_REASON_CODES.heligeInsufficientBalance,
|
|
5478
|
+
EXTERNAL_WAIT_REASON_CODES.businessDataSourceUnavailable
|
|
5479
|
+
];
|
|
5469
5480
|
var LEGACY_BROWSER_HANDOFF_REASON_CODES = [
|
|
5470
5481
|
EXTERNAL_WAIT_REASON_CODES.browserMfaRequired,
|
|
5471
5482
|
EXTERNAL_WAIT_REASON_CODES.browserCaptchaRequired,
|
|
@@ -9701,6 +9712,32 @@ var createTaskResourceAttachmentRequestSchema = external_exports.object({ attach
|
|
|
9701
9712
|
// ../shared/src/mirrorx-discovery-governance.ts
|
|
9702
9713
|
var sha256Schema6 = external_exports.string().regex(/^sha256:[a-f0-9]{64}$/);
|
|
9703
9714
|
var positiveBoundedInteger = (max) => external_exports.number().int().positive().max(max);
|
|
9715
|
+
var selectMirrorXInternalDiscoveryTargetSchema = external_exports.object({
|
|
9716
|
+
routineId: external_exports.string().uuid(),
|
|
9717
|
+
criterionId: external_exports.string().uuid(),
|
|
9718
|
+
gapId: external_exports.string().uuid(),
|
|
9719
|
+
expectedGapContractId: external_exports.string().uuid(),
|
|
9720
|
+
expectedGapAuthorityRevision: external_exports.number().int().positive()
|
|
9721
|
+
}).strict();
|
|
9722
|
+
var mirrorXInternalDiscoveryTargetSelectionSchema = external_exports.object({
|
|
9723
|
+
id: external_exports.string().uuid(),
|
|
9724
|
+
companyId: external_exports.string().uuid(),
|
|
9725
|
+
routineId: external_exports.string().uuid(),
|
|
9726
|
+
goalId: external_exports.string().uuid(),
|
|
9727
|
+
criterionId: external_exports.string().uuid(),
|
|
9728
|
+
gapId: external_exports.string().uuid(),
|
|
9729
|
+
gapContractId: external_exports.string().uuid(),
|
|
9730
|
+
gapAuthorityRevision: external_exports.number().int().positive(),
|
|
9731
|
+
targetKey: external_exports.string().min(1),
|
|
9732
|
+
sourceSelectorRevision: external_exports.string().min(1),
|
|
9733
|
+
projectionPolicyRevision: external_exports.number().int().positive(),
|
|
9734
|
+
comparePolicyRevision: external_exports.number().int().positive(),
|
|
9735
|
+
freezeSeq: external_exports.string().regex(/^\d+$/),
|
|
9736
|
+
selectionRevision: external_exports.number().int().positive(),
|
|
9737
|
+
status: external_exports.enum(["current", "superseded"]),
|
|
9738
|
+
createdAt: external_exports.string().datetime({ offset: true }),
|
|
9739
|
+
supersededAt: external_exports.string().datetime({ offset: true }).nullable()
|
|
9740
|
+
}).strict();
|
|
9704
9741
|
var mirrorxDiscoveryPromotionModeSchema = external_exports.enum(["shadow", "board_gated"]);
|
|
9705
9742
|
var customerFeedbackSourceBindingV1Schema = external_exports.object({
|
|
9706
9743
|
version: external_exports.literal(1),
|
|
@@ -19179,7 +19216,7 @@ var MIRRORX_DRIVE_AGENT_RULES = [
|
|
|
19179
19216
|
// src/amaster-runtime-daemon.mjs
|
|
19180
19217
|
import { chmodSync as chmodSync8, copyFileSync as copyFileSync2, existsSync as existsSync18, lstatSync as lstatSync15, mkdirSync as mkdirSync13, mkdtempSync as mkdtempSync5, readFileSync as readFileSync20, readdirSync as readdirSync13, realpathSync as realpathSync12, renameSync as renameSync11, rmSync as rmSync12, statSync as statSync12, symlinkSync as symlinkSync2, unlinkSync as unlinkSync3, writeFileSync as writeFileSync14 } from "node:fs";
|
|
19181
19218
|
import { arch as arch4, homedir as homedir7, hostname as hostname2, platform as platform4, tmpdir } from "node:os";
|
|
19182
|
-
import { basename as basename8, delimiter as delimiter3, dirname as
|
|
19219
|
+
import { basename as basename8, delimiter as delimiter3, dirname as dirname13, extname as extname3, isAbsolute as isAbsolute13, join as join25, relative as relative9, resolve as resolve19 } from "node:path";
|
|
19183
19220
|
import { spawn, spawnSync as spawnSync5 } from "node:child_process";
|
|
19184
19221
|
|
|
19185
19222
|
// src/amaster-runtime-daemon/common.mjs
|
|
@@ -29118,11 +29155,17 @@ function piRuntimeWebEvidence(event) {
|
|
|
29118
29155
|
return [];
|
|
29119
29156
|
}
|
|
29120
29157
|
}
|
|
29158
|
+
const directToolEndResult = readString(event?.type) === "tool_execution_end" ? {
|
|
29159
|
+
...asRecord(event?.result),
|
|
29160
|
+
role: "toolResult",
|
|
29161
|
+
toolName: readString(event?.toolName) ?? readString(asRecord(event?.result).toolName),
|
|
29162
|
+
toolCallId: readString(event?.toolCallId) ?? readString(asRecord(event?.result).toolCallId)
|
|
29163
|
+
} : null;
|
|
29121
29164
|
const toolResults = [
|
|
29122
29165
|
event?.message,
|
|
29123
29166
|
...Array.isArray(event?.messages) ? event.messages : [],
|
|
29124
29167
|
...Array.isArray(event?.toolResults) ? event.toolResults : [],
|
|
29125
|
-
...
|
|
29168
|
+
...directToolEndResult ? [directToolEndResult] : []
|
|
29126
29169
|
];
|
|
29127
29170
|
const evidence = [];
|
|
29128
29171
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -32735,9 +32778,14 @@ var BUILD_SUPPORTED_CAPABILITIES = Object.freeze([
|
|
|
32735
32778
|
"mirrorx_initialization_context_v1",
|
|
32736
32779
|
"mirrorx_initialization_completion_v1",
|
|
32737
32780
|
"native_session_checkpoint_v1",
|
|
32738
|
-
"pi_web_public_search_v1"
|
|
32781
|
+
"pi_web_public_search_v1",
|
|
32782
|
+
"pi_web_public_fetch_v1"
|
|
32739
32783
|
]);
|
|
32740
32784
|
var DYNAMIC_READINESS = Object.freeze({
|
|
32785
|
+
pi_web_public_fetch_v1: {
|
|
32786
|
+
reasonCode: "pi_web_fetch_extension_unavailable",
|
|
32787
|
+
ready: (input) => input.executors.some((executor) => executor.kind === "pi") && input.piWebFetchReady === true
|
|
32788
|
+
},
|
|
32741
32789
|
pi_web_public_search_v1: {
|
|
32742
32790
|
reasonCode: "pi_web_search_extension_unavailable",
|
|
32743
32791
|
ready: (input) => input.executors.some((executor) => executor.kind === "pi") && input.piWebSearchReady === true
|
|
@@ -33236,20 +33284,35 @@ function exactRequest(value, challenge) {
|
|
|
33236
33284
|
if (!["username", "password"].includes(value.credentialRole) || !semanticMatches(value.credentialRole, semantic)) return null;
|
|
33237
33285
|
return { ...value, credentialKey: value.credentialKey.trim(), targetOrigin, authenticationOrigin, controlSemantic: semantic };
|
|
33238
33286
|
}
|
|
33239
|
-
function createBrowserCredentialChannel({ consume }) {
|
|
33287
|
+
function createBrowserCredentialChannel({ consume, onFailure }) {
|
|
33240
33288
|
if (typeof consume !== "function") throw new Error("browser_credential_consumer_required");
|
|
33241
33289
|
const challenge = randomBytes2(32).toString("base64url");
|
|
33242
33290
|
const consumedRefs = /* @__PURE__ */ new Set();
|
|
33243
33291
|
const consumedRequests = [];
|
|
33244
33292
|
const authReceipts = [];
|
|
33245
33293
|
let closed = false;
|
|
33294
|
+
let failed = false;
|
|
33246
33295
|
let requestBuffer = Buffer.alloc(0);
|
|
33247
33296
|
let sequence = Promise.resolve();
|
|
33248
33297
|
let responsePipe = null;
|
|
33298
|
+
const failClosed = () => {
|
|
33299
|
+
if (failed) return;
|
|
33300
|
+
failed = true;
|
|
33301
|
+
closed = true;
|
|
33302
|
+
requestBuffer.fill(0);
|
|
33303
|
+
requestBuffer = Buffer.alloc(0);
|
|
33304
|
+
authReceipts.length = 0;
|
|
33305
|
+
try {
|
|
33306
|
+
responsePipe?.end();
|
|
33307
|
+
} catch {
|
|
33308
|
+
}
|
|
33309
|
+
onFailure?.("browser_credential_private_fd_lost");
|
|
33310
|
+
};
|
|
33249
33311
|
const respondError = (reason) => {
|
|
33250
33312
|
if (!closed && responsePipe?.writable) responsePipe.write(encodeBrowserCredentialFrame("E", Buffer.from(reason, "utf8")));
|
|
33251
33313
|
};
|
|
33252
33314
|
const handleReceipt = (frame) => {
|
|
33315
|
+
if (closed) return;
|
|
33253
33316
|
let receipt;
|
|
33254
33317
|
try {
|
|
33255
33318
|
receipt = JSON.parse(frame.payload.toString("utf8"));
|
|
@@ -33280,6 +33343,7 @@ function createBrowserCredentialChannel({ consume }) {
|
|
|
33280
33343
|
if (authReceipts.length === 0) authReceipts.push(Object.freeze({ ...receipt, credentialRoles: [...new Set(receipt.credentialRoles)].sort() }));
|
|
33281
33344
|
};
|
|
33282
33345
|
const handleFrame = async (frame) => {
|
|
33346
|
+
if (closed) return;
|
|
33283
33347
|
if (frame.type === "A") return handleReceipt(frame);
|
|
33284
33348
|
if (frame.type !== "R" || frame.payload.length > MAX_BYTES3) return respondError("browser_credential_request_invalid");
|
|
33285
33349
|
let decoded;
|
|
@@ -33299,6 +33363,10 @@ function createBrowserCredentialChannel({ consume }) {
|
|
|
33299
33363
|
try {
|
|
33300
33364
|
const value = await consume(request);
|
|
33301
33365
|
bytes = Buffer.isBuffer(value) ? value : Buffer.from(value, "utf8");
|
|
33366
|
+
if (closed) {
|
|
33367
|
+
bytes.fill(0);
|
|
33368
|
+
return;
|
|
33369
|
+
}
|
|
33302
33370
|
if (bytes.length === 0 || bytes.length > MAX_BYTES3) throw new Error("browser_credential_value_invalid");
|
|
33303
33371
|
responseFrame = encodeBrowserCredentialFrame("V", bytes);
|
|
33304
33372
|
responsePipe.write(responseFrame, () => {
|
|
@@ -33316,6 +33384,8 @@ function createBrowserCredentialChannel({ consume }) {
|
|
|
33316
33384
|
const requestPipe = child?.stdio?.[BROWSER_CREDENTIAL_REQUEST_FD];
|
|
33317
33385
|
responsePipe = child?.stdio?.[BROWSER_CREDENTIAL_RESPONSE_FD];
|
|
33318
33386
|
if (!requestPipe?.on || !responsePipe?.write) throw new Error("browser_credential_private_fd_unavailable");
|
|
33387
|
+
requestPipe.on("error", failClosed);
|
|
33388
|
+
responsePipe.on("error", failClosed);
|
|
33319
33389
|
responsePipe.write(encodeBrowserCredentialFrame("C", Buffer.from(challenge, "utf8")));
|
|
33320
33390
|
requestPipe.on("data", (chunk) => {
|
|
33321
33391
|
if (closed) return;
|
|
@@ -33342,6 +33412,7 @@ function createBrowserCredentialChannel({ consume }) {
|
|
|
33342
33412
|
},
|
|
33343
33413
|
async receipts() {
|
|
33344
33414
|
await sequence;
|
|
33415
|
+
if (failed) return [];
|
|
33345
33416
|
return authReceipts.map((receipt) => ({ ...receipt, credentialRoles: [...receipt.credentialRoles] }));
|
|
33346
33417
|
},
|
|
33347
33418
|
close() {
|
|
@@ -33357,7 +33428,7 @@ function createBrowserCredentialChannel({ consume }) {
|
|
|
33357
33428
|
import { existsSync as existsSync12, lstatSync as lstatSync9, readFileSync as readFileSync12, readdirSync as readdirSync8, statSync as statSync6 } from "node:fs";
|
|
33358
33429
|
import { createHash as createHash14 } from "node:crypto";
|
|
33359
33430
|
import { homedir as homedir4 } from "node:os";
|
|
33360
|
-
import { isAbsolute as isAbsolute7, join as join16, relative as relative5, resolve as resolve10 } from "node:path";
|
|
33431
|
+
import { dirname as dirname10, isAbsolute as isAbsolute7, join as join16, relative as relative5, resolve as resolve10 } from "node:path";
|
|
33361
33432
|
var CAPABILITY = "browser_credential_auth_transaction_v1";
|
|
33362
33433
|
var CREDENTIAL_BROWSER_TCB = Object.freeze({
|
|
33363
33434
|
package: "chrome-devtools-mcp",
|
|
@@ -33370,26 +33441,34 @@ var CREDENTIAL_BROWSER_PACKAGE_FILES = Object.freeze({
|
|
|
33370
33441
|
"dist/index.js": "7530da9aaa0ee272fa6e10ff80059f42a45aee6fff8d8c7cbce05c2cb24e180c"
|
|
33371
33442
|
});
|
|
33372
33443
|
var CREDENTIAL_AUTH_EXTENSION_SHA256 = "14088f0a7761a2a0884477ac2f300dcf615e4ba78b7753e4aec8078b344ab9b9";
|
|
33444
|
+
var IMAGE_PI_HOME = "/opt/pi-cli-runtime/.pi";
|
|
33445
|
+
var IMAGE_AUTH_EXTENSION_PATH = join16(IMAGE_PI_HOME, "extensions", "browser-credential-auth.mjs");
|
|
33446
|
+
var BROWSER_AUTH_IMAGE_NODE_PATH = join16(IMAGE_PI_HOME, "npm", "node_modules");
|
|
33373
33447
|
var READINESS_CACHE_TTL_MS = 5e3;
|
|
33374
33448
|
var readinessCache = /* @__PURE__ */ new Map();
|
|
33375
|
-
function inspectBrowserCredentialAuthReadiness(env = process.env, expected = {}) {
|
|
33449
|
+
function inspectBrowserCredentialAuthReadiness(env = process.env, expected = {}, options = {}) {
|
|
33376
33450
|
const home = String(env.PI_CODING_AGENT_DIR ?? env.PI_AGENT_HOME ?? join16(homedir4(), ".pi", "agent")).trim();
|
|
33451
|
+
const packageHome = expected.packageHome ?? IMAGE_PI_HOME;
|
|
33452
|
+
const extensionPath = expected.authExtensionPath ?? IMAGE_AUTH_EXTENSION_PATH;
|
|
33453
|
+
const requireImageOwnership = options.requireImageOwnership !== false;
|
|
33454
|
+
const cacheKey = JSON.stringify([home, packageHome, extensionPath, requireImageOwnership]);
|
|
33377
33455
|
const now = Date.now();
|
|
33378
|
-
const cached = readinessCache.get(
|
|
33379
|
-
if (cached && cached.expiresAt > now) return { ...cached.readiness };
|
|
33456
|
+
const cached = readinessCache.get(cacheKey);
|
|
33457
|
+
if (!options.fresh && cached && cached.expiresAt > now) return { ...cached.readiness };
|
|
33380
33458
|
const candidates = [
|
|
33381
|
-
join16(
|
|
33382
|
-
join16(
|
|
33459
|
+
join16(packageHome, "npm", "node_modules", "@amaster.ai", "pi-browser-use", "package.json"),
|
|
33460
|
+
join16(packageHome, "node_modules", "@amaster.ai", "pi-browser-use", "package.json")
|
|
33383
33461
|
];
|
|
33384
33462
|
const packageAttestation = candidates.map((manifestPath) => attestedPackageManifest(manifestPath, {
|
|
33385
33463
|
browserTcb: expected.browserTcb ?? CREDENTIAL_BROWSER_TCB,
|
|
33386
33464
|
packageFiles: expected.packageFiles ?? CREDENTIAL_BROWSER_PACKAGE_FILES,
|
|
33387
33465
|
authExtensionSha256: expected.authExtensionSha256 ?? CREDENTIAL_AUTH_EXTENSION_SHA256
|
|
33388
|
-
})).find(Boolean) ?? null;
|
|
33466
|
+
}, requireImageOwnership)).find(Boolean) ?? null;
|
|
33389
33467
|
const packageAttested = Boolean(packageAttestation);
|
|
33390
33468
|
const authExtensionAttested = attestedAuthExtension(
|
|
33391
|
-
|
|
33392
|
-
packageAttestation ? expected.authExtensionSha256 ?? CREDENTIAL_AUTH_EXTENSION_SHA256 : null
|
|
33469
|
+
extensionPath,
|
|
33470
|
+
packageAttestation ? expected.authExtensionSha256 ?? CREDENTIAL_AUTH_EXTENSION_SHA256 : null,
|
|
33471
|
+
requireImageOwnership
|
|
33393
33472
|
);
|
|
33394
33473
|
const readiness = {
|
|
33395
33474
|
privateChannel: true,
|
|
@@ -33398,29 +33477,48 @@ function inspectBrowserCredentialAuthReadiness(env = process.env, expected = {})
|
|
|
33398
33477
|
atomicTransaction: packageAttested && authExtensionAttested,
|
|
33399
33478
|
trustedProfileInjection: packageAttested
|
|
33400
33479
|
};
|
|
33401
|
-
readinessCache.set(
|
|
33480
|
+
readinessCache.set(cacheKey, { readiness, expiresAt: now + READINESS_CACHE_TTL_MS });
|
|
33402
33481
|
return { ...readiness };
|
|
33403
33482
|
}
|
|
33404
|
-
function
|
|
33483
|
+
function browserCredentialAuthExtensionArgs(authority, env = process.env, expected = {}, options = {}) {
|
|
33484
|
+
if (!authority) return [];
|
|
33485
|
+
const readiness = inspectBrowserCredentialAuthReadiness(env, expected, { ...options, fresh: true });
|
|
33486
|
+
if (!readiness.atomicTransaction || !readiness.sealedGate) {
|
|
33487
|
+
throw new Error("browser_credential_auth_extension_unavailable");
|
|
33488
|
+
}
|
|
33489
|
+
return ["--extension", expected.authExtensionPath ?? IMAGE_AUTH_EXTENSION_PATH];
|
|
33490
|
+
}
|
|
33491
|
+
function attestedAuthExtension(extensionPath, expectedSha256, requireImageOwnership) {
|
|
33405
33492
|
try {
|
|
33406
33493
|
if (typeof expectedSha256 !== "string" || !/^[a-f0-9]{64}$/u.test(expectedSha256)) return false;
|
|
33407
|
-
|
|
33494
|
+
const extensionStat = lstatSync9(extensionPath);
|
|
33495
|
+
if (!extensionStat.isFile() || extensionStat.isSymbolicLink()) return false;
|
|
33496
|
+
if (requireImageOwnership && !immutableImageFile(extensionPath)) return false;
|
|
33408
33497
|
const source = readFileSync12(extensionPath, "utf8");
|
|
33409
33498
|
return createHash14("sha256").update(source, "utf8").digest("hex") === expectedSha256 && source.includes("BrowserCredentialAuthBroker") && source.includes("browser_authenticate") && source.includes("AMASTER_BROWSER_CREDENTIAL_PRIVATE_CHANNEL");
|
|
33410
33499
|
} catch {
|
|
33411
33500
|
return false;
|
|
33412
33501
|
}
|
|
33413
33502
|
}
|
|
33503
|
+
function immutableImageFile(filePath) {
|
|
33504
|
+
const fileStat = lstatSync9(filePath);
|
|
33505
|
+
if (!fileStat.isFile() || fileStat.isSymbolicLink() || fileStat.uid !== 0 || (fileStat.mode & 18) !== 0) return false;
|
|
33506
|
+
for (let directory = dirname10(filePath); directory !== dirname10(directory); directory = dirname10(directory)) {
|
|
33507
|
+
const parentStat = lstatSync9(directory);
|
|
33508
|
+
if (!parentStat.isDirectory() || parentStat.isSymbolicLink() || parentStat.uid !== 0 || (parentStat.mode & 18) !== 0) return false;
|
|
33509
|
+
}
|
|
33510
|
+
return true;
|
|
33511
|
+
}
|
|
33414
33512
|
function fileSha256(path) {
|
|
33415
33513
|
return createHash14("sha256").update(readFileSync12(path)).digest("hex");
|
|
33416
33514
|
}
|
|
33417
|
-
function treeAttestation(root) {
|
|
33515
|
+
function treeAttestation(root, requireImageOwnership) {
|
|
33418
33516
|
const files = [];
|
|
33419
33517
|
const visit = (directory) => {
|
|
33420
33518
|
for (const entry of readdirSync8(directory, { withFileTypes: true })) {
|
|
33421
33519
|
const path = join16(directory, entry.name);
|
|
33422
33520
|
if (entry.isDirectory()) visit(path);
|
|
33423
|
-
else if (entry.isFile() && !lstatSync9(path).isSymbolicLink()) files.push(path);
|
|
33521
|
+
else if (entry.isFile() && !lstatSync9(path).isSymbolicLink() && (!requireImageOwnership || immutableImageFile(path))) files.push(path);
|
|
33424
33522
|
else throw new Error("browser_credential_tcb_tree_invalid");
|
|
33425
33523
|
}
|
|
33426
33524
|
};
|
|
@@ -33434,8 +33532,9 @@ function treeAttestation(root) {
|
|
|
33434
33532
|
}
|
|
33435
33533
|
return digest2.digest("hex");
|
|
33436
33534
|
}
|
|
33437
|
-
function attestedPackageManifest(manifestPath, expected) {
|
|
33535
|
+
function attestedPackageManifest(manifestPath, expected, requireImageOwnership) {
|
|
33438
33536
|
try {
|
|
33537
|
+
if (requireImageOwnership && !immutableImageFile(manifestPath)) return null;
|
|
33439
33538
|
const manifest = JSON.parse(readFileSync12(manifestPath, "utf8"));
|
|
33440
33539
|
if (manifest?.name !== "@amaster.ai/pi-browser-use") return null;
|
|
33441
33540
|
if (!Array.isArray(manifest.mirrorxCapabilities) || !manifest.mirrorxCapabilities.includes(CAPABILITY)) {
|
|
@@ -33448,14 +33547,16 @@ function attestedPackageManifest(manifestPath, expected) {
|
|
|
33448
33547
|
if (Object.entries(expected.packageFiles).some(([relativePath, sha2563]) => {
|
|
33449
33548
|
const path = resolve10(packageDir, relativePath);
|
|
33450
33549
|
const relativePathFromPackage = relative5(packageDir, path);
|
|
33451
|
-
return !relativePathFromPackage || relativePathFromPackage.startsWith("..") || isAbsolute7(relativePathFromPackage) || !statSync6(path).isFile() || fileSha256(path) !== sha2563;
|
|
33550
|
+
return !relativePathFromPackage || relativePathFromPackage.startsWith("..") || isAbsolute7(relativePathFromPackage) || !statSync6(path).isFile() || requireImageOwnership && !immutableImageFile(path) || fileSha256(path) !== sha2563;
|
|
33452
33551
|
})) return null;
|
|
33453
33552
|
const browserPackageDir = resolve10(packageDir, "..", "..", "chrome-devtools-mcp");
|
|
33454
|
-
const
|
|
33455
|
-
if (
|
|
33553
|
+
const browserManifestPath = join16(browserPackageDir, "package.json");
|
|
33554
|
+
if (requireImageOwnership && !immutableImageFile(browserManifestPath)) return null;
|
|
33555
|
+
const browserPackage = JSON.parse(readFileSync12(browserManifestPath, "utf8"));
|
|
33556
|
+
if (browserPackage.name !== expected.browserTcb.package || browserPackage.version !== expected.browserTcb.version || treeAttestation(join16(browserPackageDir, "build"), requireImageOwnership) !== expected.browserTcb.buildTreeSha256) return null;
|
|
33456
33557
|
const entrypoint = resolve10(packageDir, manifest.main);
|
|
33457
33558
|
const relativeEntrypoint = relative5(packageDir, entrypoint);
|
|
33458
|
-
if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || isAbsolute7(relativeEntrypoint) || !existsSync12(entrypoint)) return null;
|
|
33559
|
+
if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || isAbsolute7(relativeEntrypoint) || !existsSync12(entrypoint) || requireImageOwnership && !immutableImageFile(entrypoint)) return null;
|
|
33459
33560
|
return statSync6(entrypoint).isFile() ? {} : null;
|
|
33460
33561
|
} catch {
|
|
33461
33562
|
return null;
|
|
@@ -33493,7 +33594,7 @@ function inspectBrowserCredentialEnvReadiness(env = process.env) {
|
|
|
33493
33594
|
// src/amaster-runtime-daemon/pi-web-search-readiness.mjs
|
|
33494
33595
|
import { lstatSync as lstatSync11, readFileSync as readFileSync14 } from "node:fs";
|
|
33495
33596
|
import { homedir as homedir6 } from "node:os";
|
|
33496
|
-
import { join as join18 } from "node:path";
|
|
33597
|
+
import { isAbsolute as isAbsolute8, join as join18 } from "node:path";
|
|
33497
33598
|
function readRegularJson(path) {
|
|
33498
33599
|
try {
|
|
33499
33600
|
const stat = lstatSync11(path);
|
|
@@ -33504,18 +33605,36 @@ function readRegularJson(path) {
|
|
|
33504
33605
|
return null;
|
|
33505
33606
|
}
|
|
33506
33607
|
}
|
|
33507
|
-
function
|
|
33508
|
-
|
|
33608
|
+
function isRegularFile(path) {
|
|
33609
|
+
try {
|
|
33610
|
+
const stat = lstatSync11(path);
|
|
33611
|
+
return stat.isFile() && !stat.isSymbolicLink();
|
|
33612
|
+
} catch {
|
|
33613
|
+
return false;
|
|
33614
|
+
}
|
|
33615
|
+
}
|
|
33616
|
+
function installedPiWebAccess(env) {
|
|
33617
|
+
const home = String(env["AMASTER-CLI_CODING_AGENT_DIR"] ?? env.PI_CODING_AGENT_DIR ?? env.PI_AGENT_HOME ?? join18(homedir6(), ".pi", "agent")).trim();
|
|
33509
33618
|
const settings = readRegularJson(join18(home, "settings.json"));
|
|
33510
33619
|
const packages = Array.isArray(settings?.packages) ? settings.packages : [];
|
|
33511
|
-
const
|
|
33512
|
-
const providers = settings?.["pi-web-access"]?.providers;
|
|
33513
|
-
if (!configured || !providers || typeof providers !== "object" || Array.isArray(providers) || Object.keys(providers).length === 0) return false;
|
|
33620
|
+
const npmConfigured = packages.some((entry) => typeof entry === "string" && /^npm:@amaster\.ai\/pi-web-access(?:@|$)/u.test(entry));
|
|
33514
33621
|
const manifests = [
|
|
33515
33622
|
join18(home, "npm", "node_modules", "@amaster.ai", "pi-web-access", "package.json"),
|
|
33516
33623
|
join18(home, "node_modules", "@amaster.ai", "pi-web-access", "package.json")
|
|
33517
33624
|
];
|
|
33518
|
-
|
|
33625
|
+
const npmInstalled = npmConfigured && manifests.some((path) => readRegularJson(path)?.name === "@amaster.ai/pi-web-access");
|
|
33626
|
+
const localInstalled = packages.some((entry) => typeof entry === "string" && isAbsolute8(entry) && readRegularJson(join18(entry, "package.json"))?.name === "@amaster.ai/pi-web-access" && readRegularJson(join18(entry, "package.json"))?.pi?.extensions?.includes("./dist/index.js") && isRegularFile(join18(entry, "dist", "index.js")));
|
|
33627
|
+
return { settings, installed: npmInstalled || localInstalled };
|
|
33628
|
+
}
|
|
33629
|
+
function inspectPiWebSearchReadiness(env = process.env) {
|
|
33630
|
+
const { settings, installed } = installedPiWebAccess(env);
|
|
33631
|
+
const providers = settings?.["pi-web-access"]?.providers;
|
|
33632
|
+
return Boolean(installed && providers && typeof providers === "object" && !Array.isArray(providers) && Object.keys(providers).length > 0);
|
|
33633
|
+
}
|
|
33634
|
+
function inspectPiWebFetchReadiness(env = process.env) {
|
|
33635
|
+
const { settings, installed } = installedPiWebAccess(env);
|
|
33636
|
+
const fetch2 = settings?.["pi-web-access"]?.fetch;
|
|
33637
|
+
return Boolean(installed && fetch2?.mode === "direct" && fetch2?.dnsOverHttps === "google");
|
|
33519
33638
|
}
|
|
33520
33639
|
|
|
33521
33640
|
// src/amaster-runtime-daemon/browser-credential-env.mjs
|
|
@@ -33525,6 +33644,7 @@ var BROWSER_CREDENTIAL_ENV_CAPABILITY = "browser_credential_env_read_v1";
|
|
|
33525
33644
|
var BROWSER_CREDENTIAL_PRIVATE_CAPABILITY = "browser_credential_auth_transaction_v1";
|
|
33526
33645
|
var BROWSER_CREDENTIAL_ENV_FILE = "PI_AGENT_BROWSER_CREDENTIAL_ENV_FILE";
|
|
33527
33646
|
var BROWSER_CREDENTIAL_AUTHORITY_ENV = "AMASTER_BROWSER_CREDENTIAL_AUTHORITY_JSON";
|
|
33647
|
+
var BROWSER_SESSION_USER_DATA_DIR_ENV = "AMASTER_BROWSER_SESSION_USER_DATA_DIR";
|
|
33528
33648
|
var BROWSER_CREDENTIAL_USERNAME_KEY = "BROWSER_USERNAME";
|
|
33529
33649
|
var BROWSER_CREDENTIAL_PASSWORD_KEY = "BROWSER_PASSWORD";
|
|
33530
33650
|
function exactOrigin2(value) {
|
|
@@ -33605,6 +33725,15 @@ function browserCredentialPrivateAuthority(command, presentation = browserCreden
|
|
|
33605
33725
|
refs: Object.freeze(refs.map((ref2) => Object.freeze({ ...ref2 })))
|
|
33606
33726
|
});
|
|
33607
33727
|
}
|
|
33728
|
+
function attachTrustedBrowserExecutorEnv(env, { authority = null, userDataDir = null } = {}) {
|
|
33729
|
+
const result2 = { ...env };
|
|
33730
|
+
delete result2[BROWSER_CREDENTIAL_AUTHORITY_ENV];
|
|
33731
|
+
delete result2[BROWSER_SESSION_USER_DATA_DIR_ENV];
|
|
33732
|
+
if (authority && !userDataDir) fail2("browser_credential_authority_profile_required");
|
|
33733
|
+
if (userDataDir) result2[BROWSER_SESSION_USER_DATA_DIR_ENV] = userDataDir;
|
|
33734
|
+
if (authority) result2[BROWSER_CREDENTIAL_AUTHORITY_ENV] = JSON.stringify(authority);
|
|
33735
|
+
return result2;
|
|
33736
|
+
}
|
|
33608
33737
|
function dotenvQuotedValue(value) {
|
|
33609
33738
|
if (value.includes("\0")) fail2("browser_credential_env_value_invalid");
|
|
33610
33739
|
return `"${value.replace(/[\\"\n\r\t$`]/gu, (char) => ({
|
|
@@ -33662,7 +33791,7 @@ async function materializeBrowserCredentialEnv(plan, options) {
|
|
|
33662
33791
|
// src/amaster-runtime-daemon/runtime-artifact-upload.mjs
|
|
33663
33792
|
import { createHash as createHash15 } from "node:crypto";
|
|
33664
33793
|
import { closeSync as closeSync4, constants as constants3, fstatSync as fstatSync4, lstatSync as lstatSync12, openSync as openSync4, readFileSync as readFileSync15, realpathSync as realpathSync10 } from "node:fs";
|
|
33665
|
-
import { isAbsolute as
|
|
33794
|
+
import { isAbsolute as isAbsolute9, relative as relative6, resolve as resolve12 } from "node:path";
|
|
33666
33795
|
var SHA256_PATTERN = /^[a-f0-9]{64}$/;
|
|
33667
33796
|
function requiredString2(value, name) {
|
|
33668
33797
|
if (typeof value !== "string" || !value.trim()) throw new Error(`Runtime Artifact ${name} is required`);
|
|
@@ -33675,7 +33804,7 @@ function ownedRelativePath(value) {
|
|
|
33675
33804
|
}
|
|
33676
33805
|
function pathWithin2(candidate, root) {
|
|
33677
33806
|
const rel = relative6(root, candidate);
|
|
33678
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
33807
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute9(rel);
|
|
33679
33808
|
}
|
|
33680
33809
|
function sameFileSnapshot(left, right) {
|
|
33681
33810
|
return left.dev === right.dev && left.ino === right.ino && left.size === right.size && left.mtimeMs === right.mtimeMs && left.ctimeMs === right.ctimeMs;
|
|
@@ -34041,10 +34170,10 @@ function createRuntimeArtifactIngestQueue({ ingest, onError }) {
|
|
|
34041
34170
|
// src/amaster-runtime-daemon/workspace-guard.mjs
|
|
34042
34171
|
import { createHash as createHash17 } from "node:crypto";
|
|
34043
34172
|
import { existsSync as existsSync13, mkdirSync as mkdirSync11, realpathSync as realpathSync11, statSync as statSync7 } from "node:fs";
|
|
34044
|
-
import { basename as basename6, join as join20, isAbsolute as
|
|
34173
|
+
import { basename as basename6, join as join20, isAbsolute as isAbsolute10, relative as relative7, resolve as resolve13 } from "node:path";
|
|
34045
34174
|
function pathWithin3(candidate, root) {
|
|
34046
34175
|
const rel = relative7(root, candidate);
|
|
34047
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
34176
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute10(rel);
|
|
34048
34177
|
}
|
|
34049
34178
|
function resolveWorkspaceCwd(config, command) {
|
|
34050
34179
|
const payload = asRecord(command.payload);
|
|
@@ -34281,7 +34410,7 @@ import {
|
|
|
34281
34410
|
unlinkSync as unlinkSync2,
|
|
34282
34411
|
writeFileSync as writeFileSync13
|
|
34283
34412
|
} from "node:fs";
|
|
34284
|
-
import { dirname as
|
|
34413
|
+
import { dirname as dirname11, extname, isAbsolute as isAbsolute11, join as join22, parse as parse4, resolve as resolve15, sep as sep4 } from "node:path";
|
|
34285
34414
|
import { fileURLToPath } from "node:url";
|
|
34286
34415
|
var PRESET_TEMPLATE_MANIFEST_FILE = ".mirrorx-preset-templates.json";
|
|
34287
34416
|
var MAX_PRESET_TEMPLATE_FILES = 256;
|
|
@@ -34316,7 +34445,7 @@ function assertCatalogReadableByExecutor(targetDir, fileNames, identity) {
|
|
|
34316
34445
|
if (!stat.isDirectory() || !modeAllows(stat, identity, 64, 8, 1)) {
|
|
34317
34446
|
throw new Error(`preset_template_executor_path_unreadable: ${current}`);
|
|
34318
34447
|
}
|
|
34319
|
-
const parent =
|
|
34448
|
+
const parent = dirname11(current);
|
|
34320
34449
|
if (parent === current) break;
|
|
34321
34450
|
current = parent;
|
|
34322
34451
|
}
|
|
@@ -34337,7 +34466,7 @@ function hasAllowedTemplateExtension(name) {
|
|
|
34337
34466
|
return ALLOWED_TEMPLATE_EXTENSIONS.has(extname(name).toLowerCase());
|
|
34338
34467
|
}
|
|
34339
34468
|
function validTemplateName(value) {
|
|
34340
|
-
return typeof value === "string" && value.length > 0 && value !== "." && value !== ".." && !value.includes("\0") && !value.includes("/") && !value.includes("\\") && !
|
|
34469
|
+
return typeof value === "string" && value.length > 0 && value !== "." && value !== ".." && !value.includes("\0") && !value.includes("/") && !value.includes("\\") && !isAbsolute11(value) && parse4(value).base === value && hasAllowedTemplateExtension(value);
|
|
34341
34470
|
}
|
|
34342
34471
|
function readManifest(manifestPath, { strict }) {
|
|
34343
34472
|
try {
|
|
@@ -34401,14 +34530,14 @@ function materializeBundledPresetTemplates(input) {
|
|
|
34401
34530
|
}
|
|
34402
34531
|
const manifest = readManifest(join22(sourceDir, PRESET_TEMPLATE_MANIFEST_FILE), { strict: true });
|
|
34403
34532
|
const verifiedFiles = verifiedBundleFiles(sourceDir, manifest);
|
|
34404
|
-
mkdirSync12(
|
|
34533
|
+
mkdirSync12(dirname11(targetDir), { recursive: true, mode: 493 });
|
|
34405
34534
|
const targetStat = lstatIfExists(targetDir);
|
|
34406
34535
|
if (targetStat && (!targetStat.isDirectory() || targetStat.isSymbolicLink())) {
|
|
34407
34536
|
throw new Error("preset_template_target_root_unsafe");
|
|
34408
34537
|
}
|
|
34409
34538
|
mkdirSync12(targetDir, { recursive: true, mode: 493 });
|
|
34410
34539
|
const previousManifest = readManifest(join22(targetDir, PRESET_TEMPLATE_MANIFEST_FILE), { strict: false });
|
|
34411
|
-
const stageDir = mkdtempSync4(join22(
|
|
34540
|
+
const stageDir = mkdtempSync4(join22(dirname11(targetDir), ".mirrorx-preset-templates-"));
|
|
34412
34541
|
try {
|
|
34413
34542
|
for (const file of verifiedFiles) {
|
|
34414
34543
|
const stagedPath = join22(stageDir, file.name);
|
|
@@ -34470,7 +34599,7 @@ function materializeRuntimePresetTemplates(input) {
|
|
|
34470
34599
|
|
|
34471
34600
|
// src/amaster-runtime-daemon/runtime-status-summary.mjs
|
|
34472
34601
|
import { existsSync as existsSync16, readdirSync as readdirSync11, statSync as statSync10 } from "node:fs";
|
|
34473
|
-
import { dirname as
|
|
34602
|
+
import { dirname as dirname12, join as join23, resolve as resolve16 } from "node:path";
|
|
34474
34603
|
function runtimeStatusDirectoryEntries(path) {
|
|
34475
34604
|
try {
|
|
34476
34605
|
return readdirSync11(path, { withFileTypes: true });
|
|
@@ -34552,7 +34681,7 @@ function summarizeRuntimeStatusRecentRun(workdir, manifest) {
|
|
|
34552
34681
|
}
|
|
34553
34682
|
function runtimeStatusOutboxDir(config) {
|
|
34554
34683
|
const statePath = config.AMASTER_DAEMON_STATE_FILE ?? config.daemonStateFile;
|
|
34555
|
-
return join23(
|
|
34684
|
+
return join23(dirname12(stateFilePath({
|
|
34556
34685
|
AMASTER_DAEMON_STATE_FILE: statePath
|
|
34557
34686
|
})), "result-outbox");
|
|
34558
34687
|
}
|
|
@@ -34560,7 +34689,7 @@ function runtimeStatusRunCompletionDir(config) {
|
|
|
34560
34689
|
const explicit = config.AMASTER_RUN_COMPLETION_STATE_DIR ?? config.runCompletionStateDir;
|
|
34561
34690
|
if (typeof explicit === "string" && explicit.trim()) return resolve16(explicit);
|
|
34562
34691
|
const statePath = config.AMASTER_DAEMON_STATE_FILE ?? config.daemonStateFile;
|
|
34563
|
-
return join23(
|
|
34692
|
+
return join23(dirname12(stateFilePath({
|
|
34564
34693
|
AMASTER_DAEMON_STATE_FILE: statePath
|
|
34565
34694
|
})), "run-completion-state");
|
|
34566
34695
|
}
|
|
@@ -34961,7 +35090,7 @@ export default function amasterProjectInstructions(pi) {
|
|
|
34961
35090
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
34962
35091
|
import { createHash as createHash19 } from "node:crypto";
|
|
34963
35092
|
import { existsSync as existsSync17, readdirSync as readdirSync12, readFileSync as readFileSync19, statSync as statSync11 } from "node:fs";
|
|
34964
|
-
import { basename as basename7, extname as extname2, isAbsolute as
|
|
35093
|
+
import { basename as basename7, extname as extname2, isAbsolute as isAbsolute12, join as join24, relative as relative8, resolve as resolve18 } from "node:path";
|
|
34965
35094
|
var WORKSPACE_RUNTIME_SERVICES_FILENAME = ".amaster-runtime-services.json";
|
|
34966
35095
|
var ARTIFACT_EXTENSIONS = /* @__PURE__ */ new Map([
|
|
34967
35096
|
[".md", "markdown"],
|
|
@@ -35007,7 +35136,7 @@ var SAFE_RUNTIME_SERVICE_HEALTH_STATUSES = /* @__PURE__ */ new Set(["unknown", "
|
|
|
35007
35136
|
var SAFE_RUNTIME_SERVICE_LIFECYCLES = /* @__PURE__ */ new Set(["shared", "ephemeral"]);
|
|
35008
35137
|
function statusPathWithin(candidate, root) {
|
|
35009
35138
|
const rel = relative8(root, candidate);
|
|
35010
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
35139
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute12(rel);
|
|
35011
35140
|
}
|
|
35012
35141
|
function normalizeRelativePath(root, filePath) {
|
|
35013
35142
|
return relative8(root, filePath).split(/[\\/]+/).join("/");
|
|
@@ -35262,7 +35391,7 @@ function assertRequiredTaskAttachmentMaterialized(input, materialized) {
|
|
|
35262
35391
|
}
|
|
35263
35392
|
|
|
35264
35393
|
// src/amaster-runtime-daemon.mjs
|
|
35265
|
-
var CONNECTOR_VERSION = "0.1.
|
|
35394
|
+
var CONNECTOR_VERSION = "0.1.13-beta.0";
|
|
35266
35395
|
var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
|
|
35267
35396
|
var SUPPORTED_TASK_CONTEXT_VERSIONS = Object.freeze([TASK_CONTEXT_MANIFEST_VERSION, TASK_CONTEXT_V2]);
|
|
35268
35397
|
var daemonRequire = createRequire(import.meta.url);
|
|
@@ -35374,7 +35503,7 @@ function resultOutboxPendingCount(config) {
|
|
|
35374
35503
|
function runCompletionStateDir(config) {
|
|
35375
35504
|
const explicit = readString(process.env.AMASTER_RUN_COMPLETION_STATE_DIR);
|
|
35376
35505
|
if (explicit) return resolve19(expandHomePath(explicit));
|
|
35377
|
-
return join25(
|
|
35506
|
+
return join25(dirname13(stateFilePath(process.env)), "run-completion-state");
|
|
35378
35507
|
}
|
|
35379
35508
|
function runCompletionStateInvalidDir(config) {
|
|
35380
35509
|
return join25(runCompletionStateDir(config), "invalid");
|
|
@@ -35820,7 +35949,8 @@ function runtimeAdvertisedCapabilities(config) {
|
|
|
35820
35949
|
executors: config.executors,
|
|
35821
35950
|
browserCredentialAuth: inspectBrowserCredentialAuthReadiness(),
|
|
35822
35951
|
browserCredentialEnv: inspectBrowserCredentialEnvReadiness(),
|
|
35823
|
-
piWebSearchReady: inspectPiWebSearchReadiness()
|
|
35952
|
+
piWebSearchReady: inspectPiWebSearchReadiness(),
|
|
35953
|
+
piWebFetchReady: inspectPiWebFetchReadiness()
|
|
35824
35954
|
});
|
|
35825
35955
|
}
|
|
35826
35956
|
function buildRegisterPayload(config) {
|
|
@@ -36712,7 +36842,7 @@ function safeAgentInstructionMaterializationTarget(workspace, filePath) {
|
|
|
36712
36842
|
const raw = readString(filePath);
|
|
36713
36843
|
if (!raw || raw.includes("\0")) return null;
|
|
36714
36844
|
const normalized = raw.replace(/\\/g, "/");
|
|
36715
|
-
if (
|
|
36845
|
+
if (isAbsolute13(normalized)) return null;
|
|
36716
36846
|
const segments = normalized.split("/").filter(Boolean);
|
|
36717
36847
|
if (segments.length === 0 || segments.some((segment) => segment === "." || segment === "..")) return null;
|
|
36718
36848
|
const relativePath = segments.join("/");
|
|
@@ -36802,7 +36932,7 @@ async function materializeEffectiveAgentInstructions(config, command, workspace,
|
|
|
36802
36932
|
}
|
|
36803
36933
|
const target = safeAgentInstructionMaterializationTarget(workspace, filePath);
|
|
36804
36934
|
if (!target) throw new Error(`context_envelope_instruction_path_invalid: ${filePath}`);
|
|
36805
|
-
mkdirSync13(
|
|
36935
|
+
mkdirSync13(dirname13(target.targetPath), { recursive: true });
|
|
36806
36936
|
const temporaryPath = `${target.targetPath}.mirrorx-${command.commandId}.tmp`;
|
|
36807
36937
|
try {
|
|
36808
36938
|
writeFileSync14(temporaryPath, content, { encoding: "utf8", mode: 384 });
|
|
@@ -38211,7 +38341,7 @@ function manifestMatchesActiveRuntimeRef(manifest, refs, workdir = null) {
|
|
|
38211
38341
|
function buildOrphanReaperSample(root, workdir, manifest, residents) {
|
|
38212
38342
|
const relativeWorkdir = (() => {
|
|
38213
38343
|
const value = relative9(root, workdir);
|
|
38214
|
-
return value && !value.startsWith("..") && !
|
|
38344
|
+
return value && !value.startsWith("..") && !isAbsolute13(value) ? value : basename8(workdir);
|
|
38215
38345
|
})();
|
|
38216
38346
|
return {
|
|
38217
38347
|
workdir: relativeWorkdir,
|
|
@@ -38324,7 +38454,14 @@ function runExecutor(command, args, options) {
|
|
|
38324
38454
|
const maxOutputBytes = parsePositiveInteger(options.maxOutputBytes, 50 * 1024 * 1024);
|
|
38325
38455
|
const maxRssMb = parsePositiveInteger(options.maxRssMb, 0);
|
|
38326
38456
|
const maxRssBytes = maxRssMb * 1024 * 1024;
|
|
38327
|
-
const browserCredentialChannel = typeof options.browserCredentialConsumer === "function" ? createBrowserCredentialChannel({
|
|
38457
|
+
const browserCredentialChannel = typeof options.browserCredentialConsumer === "function" ? createBrowserCredentialChannel({
|
|
38458
|
+
consume: options.browserCredentialConsumer,
|
|
38459
|
+
onFailure: (reason) => {
|
|
38460
|
+
spawnError = reason;
|
|
38461
|
+
spawnErrorCode = reason;
|
|
38462
|
+
requestStop(reason);
|
|
38463
|
+
}
|
|
38464
|
+
}) : null;
|
|
38328
38465
|
const childEnv = { ...options.env };
|
|
38329
38466
|
delete childEnv.AMASTER_BROWSER_CREDENTIAL_PRIVATE_CHANNEL;
|
|
38330
38467
|
if (browserCredentialChannel) childEnv.AMASTER_BROWSER_CREDENTIAL_PRIVATE_CHANNEL = "1";
|
|
@@ -38592,8 +38729,8 @@ function runExecutor(command, args, options) {
|
|
|
38592
38729
|
child.stdout.once("end", () => stdoutDecoder.end());
|
|
38593
38730
|
child.stderr.once("end", () => stderrDecoder.end());
|
|
38594
38731
|
child.on("error", (err) => {
|
|
38595
|
-
spawnError = err.message;
|
|
38596
|
-
spawnErrorCode = typeof err.code === "string" ? err.code : null;
|
|
38732
|
+
if (!spawnError) spawnError = err.message;
|
|
38733
|
+
if (!spawnErrorCode) spawnErrorCode = typeof err.code === "string" ? err.code : null;
|
|
38597
38734
|
});
|
|
38598
38735
|
child.on("exit", (code, signal) => {
|
|
38599
38736
|
childExited = true;
|
|
@@ -39174,7 +39311,7 @@ async function completeCommand(config, command, status, result2, error) {
|
|
|
39174
39311
|
function resultOutboxDir(config) {
|
|
39175
39312
|
const explicit = readString(process.env.AMASTER_RESULT_OUTBOX_DIR);
|
|
39176
39313
|
if (explicit) return resolve19(expandHomePath(explicit));
|
|
39177
|
-
return join25(
|
|
39314
|
+
return join25(dirname13(stateFilePath(process.env)), "result-outbox");
|
|
39178
39315
|
}
|
|
39179
39316
|
function resultOutboxInvalidDir(config) {
|
|
39180
39317
|
return join25(resultOutboxDir(config), "invalid");
|
|
@@ -39651,7 +39788,7 @@ async function materializeRequiredArtifactInputs(config, command, workspace) {
|
|
|
39651
39788
|
}
|
|
39652
39789
|
usedPaths.add(relativePath);
|
|
39653
39790
|
const targetPath = join25(workspace.cwd, relativePath);
|
|
39654
|
-
mkdirSync13(
|
|
39791
|
+
mkdirSync13(dirname13(targetPath), { recursive: true });
|
|
39655
39792
|
writeFileSync14(targetPath, body);
|
|
39656
39793
|
chmodSync8(targetPath, 292);
|
|
39657
39794
|
materialized.push({
|
|
@@ -39749,7 +39886,7 @@ async function materializeMentionedArtifactFiles(config, command, workspace) {
|
|
|
39749
39886
|
return { materialized, skipped };
|
|
39750
39887
|
}
|
|
39751
39888
|
function issueCheckpointDir(workspace) {
|
|
39752
|
-
return join25(
|
|
39889
|
+
return join25(dirname13(workspace.runDir), "checkpoint");
|
|
39753
39890
|
}
|
|
39754
39891
|
async function clearIssueCheckpoint(config, command, workspace, reason, consumedSource = null) {
|
|
39755
39892
|
const checkpointDir = issueCheckpointDir(workspace);
|
|
@@ -39771,7 +39908,7 @@ async function clearIssueCheckpoint(config, command, workspace, reason, consumed
|
|
|
39771
39908
|
}
|
|
39772
39909
|
function safeCheckpointRelativePath(rawPath) {
|
|
39773
39910
|
const raw = String(rawPath ?? "").trim();
|
|
39774
|
-
if (
|
|
39911
|
+
if (isAbsolute13(raw) || /^[A-Za-z]:[\\/]/.test(raw)) return null;
|
|
39775
39912
|
const normalized = raw.split(/[\\/]+/).filter(Boolean).join("/");
|
|
39776
39913
|
if (!normalized || normalized.startsWith("../") || normalized.split("/").some((segment) => segment.startsWith("."))) return null;
|
|
39777
39914
|
if (normalized.startsWith("input-attachments/") || isRuntimeMetadataArtifactPath(normalized)) return null;
|
|
@@ -39903,8 +40040,8 @@ async function materializeIssueCheckpoint(config, command, workspace) {
|
|
|
39903
40040
|
}
|
|
39904
40041
|
const materialized = [];
|
|
39905
40042
|
for (const { relativePath, source, target, expectedSha256, expectedByteSize } of validated) {
|
|
39906
|
-
mkdirSync13(
|
|
39907
|
-
const targetParent = realpathSync12(
|
|
40043
|
+
mkdirSync13(dirname13(target), { recursive: true });
|
|
40044
|
+
const targetParent = realpathSync12(dirname13(target));
|
|
39908
40045
|
if (!pathWithin3(targetParent, workspaceRoot)) {
|
|
39909
40046
|
throw new Error(`issue checkpoint target escapes its workspace: ${relativePath}`);
|
|
39910
40047
|
}
|
|
@@ -40011,7 +40148,7 @@ async function saveIssueCheckpoint(config, command, workspace, candidates, optio
|
|
|
40011
40148
|
}
|
|
40012
40149
|
const target = resolve19(filesDir, relativePath);
|
|
40013
40150
|
if (!pathWithin3(target, filesDir)) continue;
|
|
40014
|
-
mkdirSync13(
|
|
40151
|
+
mkdirSync13(dirname13(target), { recursive: true });
|
|
40015
40152
|
copyFileSync2(ownedSource, target);
|
|
40016
40153
|
const storedStat = lstatSync15(target);
|
|
40017
40154
|
if (!storedStat.isFile() || storedStat.size !== byteSize) {
|
|
@@ -40265,13 +40402,7 @@ async function executeRunCommand(config, command) {
|
|
|
40265
40402
|
const nativeSessionRequest = asRecord(asRecord(command.payload).nativeSession);
|
|
40266
40403
|
let invocation = null;
|
|
40267
40404
|
let executorEnv = buildExecutorEnv(config, command, workspace);
|
|
40268
|
-
|
|
40269
|
-
if (browserCredentialAuthority) {
|
|
40270
|
-
executorEnv = {
|
|
40271
|
-
...executorEnv,
|
|
40272
|
-
[BROWSER_CREDENTIAL_AUTHORITY_ENV]: JSON.stringify(browserCredentialAuthority)
|
|
40273
|
-
};
|
|
40274
|
-
}
|
|
40405
|
+
let browserSessionUserDataDir = null;
|
|
40275
40406
|
let managedMcpProfile = null;
|
|
40276
40407
|
let managedMcpCleanup = null;
|
|
40277
40408
|
let cleanupManagedMcpProfile = null;
|
|
@@ -40325,10 +40456,7 @@ async function executeRunCommand(config, command) {
|
|
|
40325
40456
|
cleanupBrowserSessionProfile(config, browserSession);
|
|
40326
40457
|
}
|
|
40327
40458
|
const ownedProfile = ensureBrowserSessionProfile(config, browserSession);
|
|
40328
|
-
|
|
40329
|
-
...executorEnv,
|
|
40330
|
-
AMASTER_BROWSER_SESSION_USER_DATA_DIR: ownedProfile.userDataDir
|
|
40331
|
-
};
|
|
40459
|
+
browserSessionUserDataDir = ownedProfile.userDataDir;
|
|
40332
40460
|
}
|
|
40333
40461
|
invocation = buildExecutorInvocation(executor, executionCommand, workspace);
|
|
40334
40462
|
if (taskSessionCheckpointUnavailable) {
|
|
@@ -40391,7 +40519,7 @@ async function executeRunCommand(config, command) {
|
|
|
40391
40519
|
executorCommand: invocation.command,
|
|
40392
40520
|
executorHome: workspace.executorHome,
|
|
40393
40521
|
runDir: workspace.runDir,
|
|
40394
|
-
runtimeCacheRoot: join25(
|
|
40522
|
+
runtimeCacheRoot: join25(dirname13(config.daemonStateFile), "cache"),
|
|
40395
40523
|
cwd,
|
|
40396
40524
|
runtimeAuth: commandRuntimeAuth(command),
|
|
40397
40525
|
nativeSession: asRecord(asRecord(executionCommand.payload).nativeSession),
|
|
@@ -40462,6 +40590,10 @@ async function executeRunCommand(config, command) {
|
|
|
40462
40590
|
if (executor.kind === "pi" && Array.isArray(managedMcpProfile.extensionArgs) && managedMcpProfile.extensionArgs.length > 0) {
|
|
40463
40591
|
invocation.args = [...invocation.args, ...managedMcpProfile.extensionArgs];
|
|
40464
40592
|
}
|
|
40593
|
+
if (executor.kind === "pi" && browserCredentialAuthority) {
|
|
40594
|
+
invocation.args = [...invocation.args, ...browserCredentialAuthExtensionArgs(browserCredentialAuthority, executorEnv)];
|
|
40595
|
+
executorEnv = { ...executorEnv, NODE_PATH: BROWSER_AUTH_IMAGE_NODE_PATH };
|
|
40596
|
+
}
|
|
40465
40597
|
if (executor.kind === "pi") {
|
|
40466
40598
|
assertManagedPiNonInteractiveInvocation(invocation.args, managedMcpProfile);
|
|
40467
40599
|
}
|
|
@@ -40470,6 +40602,10 @@ async function executeRunCommand(config, command) {
|
|
|
40470
40602
|
...managedMcpProfile.attestation
|
|
40471
40603
|
});
|
|
40472
40604
|
}
|
|
40605
|
+
executorEnv = attachTrustedBrowserExecutorEnv(executorEnv, {
|
|
40606
|
+
authority: browserCredentialAuthority,
|
|
40607
|
+
userDataDir: browserSessionUserDataDir
|
|
40608
|
+
});
|
|
40473
40609
|
executorEnv = withAuditCorrelationEnvironment(executorEnv, command);
|
|
40474
40610
|
if (Object.keys(trustedPiRuntimeAssertion).length > 0) {
|
|
40475
40611
|
throw new Error("pi_trusted_runtime_unsupported");
|
package/dist/amaster-runtime.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { homedir, hostname } from "node:os";
|
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
import { BUILD_SUPPORTED_CAPABILITIES } from "./amaster-runtime-daemon/capability-registry.mjs";
|
|
9
9
|
|
|
10
|
-
const CONNECTOR_VERSION = "0.1.
|
|
10
|
+
const CONNECTOR_VERSION = "0.1.13-beta.0";
|
|
11
11
|
|
|
12
12
|
const CONFIG_KEY_MAP = new Map([
|
|
13
13
|
["server_url", "AMASTER_EMPLOYEE_SERVER_URL"],
|