@amaster.ai/employee-runtime-connector 0.1.12 → 0.1.13-beta.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.
|
@@ -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",
|
|
@@ -33367,29 +33438,38 @@ var CREDENTIAL_BROWSER_TCB = Object.freeze({
|
|
|
33367
33438
|
});
|
|
33368
33439
|
var CREDENTIAL_BROWSER_PACKAGE_FILES = Object.freeze({
|
|
33369
33440
|
"dist/config.js": "ed61ba70f3c2445db22fac31c432c86df2d9b3674bd36b34cce6f7a981f3926f",
|
|
33370
|
-
"dist/index.js": "
|
|
33441
|
+
"dist/index.js": "e94fdec799848fc45942cc59868dfd12dd27597025f757eded3e1d7e3a8e0fb9"
|
|
33371
33442
|
});
|
|
33372
|
-
var CREDENTIAL_AUTH_EXTENSION_SHA256 = "
|
|
33443
|
+
var CREDENTIAL_AUTH_EXTENSION_SHA256 = "c57dba1e1856bab8e44b55b5725dac2bcee7751522a1b87e0eef0144ad114cd7";
|
|
33444
|
+
var CREDENTIAL_BROWSER_PACKAGE_VERSION = "0.1.2-beta.80";
|
|
33445
|
+
var IMAGE_PI_HOME = "/opt/pi-cli-runtime/.pi";
|
|
33446
|
+
var IMAGE_AUTH_EXTENSION_PATH = join16(IMAGE_PI_HOME, "extensions", "browser-credential-auth.mjs");
|
|
33447
|
+
var BROWSER_AUTH_IMAGE_NODE_PATH = join16(IMAGE_PI_HOME, "npm", "node_modules");
|
|
33373
33448
|
var READINESS_CACHE_TTL_MS = 5e3;
|
|
33374
33449
|
var readinessCache = /* @__PURE__ */ new Map();
|
|
33375
|
-
function inspectBrowserCredentialAuthReadiness(env = process.env, expected = {}) {
|
|
33450
|
+
function inspectBrowserCredentialAuthReadiness(env = process.env, expected = {}, options = {}) {
|
|
33376
33451
|
const home = String(env.PI_CODING_AGENT_DIR ?? env.PI_AGENT_HOME ?? join16(homedir4(), ".pi", "agent")).trim();
|
|
33452
|
+
const packageHome = expected.packageHome ?? IMAGE_PI_HOME;
|
|
33453
|
+
const extensionPath = expected.authExtensionPath ?? IMAGE_AUTH_EXTENSION_PATH;
|
|
33454
|
+
const requireImageOwnership = options.requireImageOwnership !== false;
|
|
33455
|
+
const cacheKey = JSON.stringify([home, packageHome, extensionPath, requireImageOwnership]);
|
|
33377
33456
|
const now = Date.now();
|
|
33378
|
-
const cached = readinessCache.get(
|
|
33379
|
-
if (cached && cached.expiresAt > now) return { ...cached.readiness };
|
|
33457
|
+
const cached = readinessCache.get(cacheKey);
|
|
33458
|
+
if (!options.fresh && cached && cached.expiresAt > now) return { ...cached.readiness };
|
|
33380
33459
|
const candidates = [
|
|
33381
|
-
join16(
|
|
33382
|
-
join16(
|
|
33460
|
+
join16(packageHome, "npm", "node_modules", "@amaster.ai", "pi-browser-use", "package.json"),
|
|
33461
|
+
join16(packageHome, "node_modules", "@amaster.ai", "pi-browser-use", "package.json")
|
|
33383
33462
|
];
|
|
33384
33463
|
const packageAttestation = candidates.map((manifestPath) => attestedPackageManifest(manifestPath, {
|
|
33385
33464
|
browserTcb: expected.browserTcb ?? CREDENTIAL_BROWSER_TCB,
|
|
33386
33465
|
packageFiles: expected.packageFiles ?? CREDENTIAL_BROWSER_PACKAGE_FILES,
|
|
33387
33466
|
authExtensionSha256: expected.authExtensionSha256 ?? CREDENTIAL_AUTH_EXTENSION_SHA256
|
|
33388
|
-
})).find(Boolean) ?? null;
|
|
33467
|
+
}, requireImageOwnership)).find(Boolean) ?? null;
|
|
33389
33468
|
const packageAttested = Boolean(packageAttestation);
|
|
33390
33469
|
const authExtensionAttested = attestedAuthExtension(
|
|
33391
|
-
|
|
33392
|
-
packageAttestation ? expected.authExtensionSha256 ?? CREDENTIAL_AUTH_EXTENSION_SHA256 : null
|
|
33470
|
+
extensionPath,
|
|
33471
|
+
packageAttestation ? expected.authExtensionSha256 ?? CREDENTIAL_AUTH_EXTENSION_SHA256 : null,
|
|
33472
|
+
requireImageOwnership
|
|
33393
33473
|
);
|
|
33394
33474
|
const readiness = {
|
|
33395
33475
|
privateChannel: true,
|
|
@@ -33398,29 +33478,48 @@ function inspectBrowserCredentialAuthReadiness(env = process.env, expected = {})
|
|
|
33398
33478
|
atomicTransaction: packageAttested && authExtensionAttested,
|
|
33399
33479
|
trustedProfileInjection: packageAttested
|
|
33400
33480
|
};
|
|
33401
|
-
readinessCache.set(
|
|
33481
|
+
readinessCache.set(cacheKey, { readiness, expiresAt: now + READINESS_CACHE_TTL_MS });
|
|
33402
33482
|
return { ...readiness };
|
|
33403
33483
|
}
|
|
33404
|
-
function
|
|
33484
|
+
function browserCredentialAuthExtensionArgs(authority, env = process.env, expected = {}, options = {}) {
|
|
33485
|
+
if (!authority) return [];
|
|
33486
|
+
const readiness = inspectBrowserCredentialAuthReadiness(env, expected, { ...options, fresh: true });
|
|
33487
|
+
if (!readiness.atomicTransaction || !readiness.sealedGate) {
|
|
33488
|
+
throw new Error("browser_credential_auth_extension_unavailable");
|
|
33489
|
+
}
|
|
33490
|
+
return ["--extension", expected.authExtensionPath ?? IMAGE_AUTH_EXTENSION_PATH];
|
|
33491
|
+
}
|
|
33492
|
+
function attestedAuthExtension(extensionPath, expectedSha256, requireImageOwnership) {
|
|
33405
33493
|
try {
|
|
33406
33494
|
if (typeof expectedSha256 !== "string" || !/^[a-f0-9]{64}$/u.test(expectedSha256)) return false;
|
|
33407
|
-
|
|
33495
|
+
const extensionStat = lstatSync9(extensionPath);
|
|
33496
|
+
if (!extensionStat.isFile() || extensionStat.isSymbolicLink()) return false;
|
|
33497
|
+
if (requireImageOwnership && !immutableImageFile(extensionPath)) return false;
|
|
33408
33498
|
const source = readFileSync12(extensionPath, "utf8");
|
|
33409
33499
|
return createHash14("sha256").update(source, "utf8").digest("hex") === expectedSha256 && source.includes("BrowserCredentialAuthBroker") && source.includes("browser_authenticate") && source.includes("AMASTER_BROWSER_CREDENTIAL_PRIVATE_CHANNEL");
|
|
33410
33500
|
} catch {
|
|
33411
33501
|
return false;
|
|
33412
33502
|
}
|
|
33413
33503
|
}
|
|
33504
|
+
function immutableImageFile(filePath) {
|
|
33505
|
+
const fileStat = lstatSync9(filePath);
|
|
33506
|
+
if (!fileStat.isFile() || fileStat.isSymbolicLink() || fileStat.uid !== 0 || (fileStat.mode & 18) !== 0) return false;
|
|
33507
|
+
for (let directory = dirname10(filePath); directory !== dirname10(directory); directory = dirname10(directory)) {
|
|
33508
|
+
const parentStat = lstatSync9(directory);
|
|
33509
|
+
if (!parentStat.isDirectory() || parentStat.isSymbolicLink() || parentStat.uid !== 0 || (parentStat.mode & 18) !== 0) return false;
|
|
33510
|
+
}
|
|
33511
|
+
return true;
|
|
33512
|
+
}
|
|
33414
33513
|
function fileSha256(path) {
|
|
33415
33514
|
return createHash14("sha256").update(readFileSync12(path)).digest("hex");
|
|
33416
33515
|
}
|
|
33417
|
-
function treeAttestation(root) {
|
|
33516
|
+
function treeAttestation(root, requireImageOwnership) {
|
|
33418
33517
|
const files = [];
|
|
33419
33518
|
const visit = (directory) => {
|
|
33420
33519
|
for (const entry of readdirSync8(directory, { withFileTypes: true })) {
|
|
33421
33520
|
const path = join16(directory, entry.name);
|
|
33422
33521
|
if (entry.isDirectory()) visit(path);
|
|
33423
|
-
else if (entry.isFile() && !lstatSync9(path).isSymbolicLink()) files.push(path);
|
|
33522
|
+
else if (entry.isFile() && !lstatSync9(path).isSymbolicLink() && (!requireImageOwnership || immutableImageFile(path))) files.push(path);
|
|
33424
33523
|
else throw new Error("browser_credential_tcb_tree_invalid");
|
|
33425
33524
|
}
|
|
33426
33525
|
};
|
|
@@ -33434,11 +33533,12 @@ function treeAttestation(root) {
|
|
|
33434
33533
|
}
|
|
33435
33534
|
return digest2.digest("hex");
|
|
33436
33535
|
}
|
|
33437
|
-
function attestedPackageManifest(manifestPath, expected) {
|
|
33536
|
+
function attestedPackageManifest(manifestPath, expected, requireImageOwnership) {
|
|
33438
33537
|
try {
|
|
33538
|
+
if (requireImageOwnership && !immutableImageFile(manifestPath)) return null;
|
|
33439
33539
|
const manifest = JSON.parse(readFileSync12(manifestPath, "utf8"));
|
|
33440
|
-
if (manifest?.name !== "@amaster.ai/pi-browser-use") return null;
|
|
33441
|
-
if (!Array.isArray(manifest.mirrorxCapabilities) ||
|
|
33540
|
+
if (manifest?.name !== "@amaster.ai/pi-browser-use" || manifest.version !== CREDENTIAL_BROWSER_PACKAGE_VERSION) return null;
|
|
33541
|
+
if (!Array.isArray(manifest.mirrorxCapabilities) || manifest.mirrorxCapabilities.length !== 1 || manifest.mirrorxCapabilities[0] !== CAPABILITY) {
|
|
33442
33542
|
return null;
|
|
33443
33543
|
}
|
|
33444
33544
|
if (!sameCredentialBrowserTcb(manifest.mirrorxCredentialBrowserTcb, expected.browserTcb)) return null;
|
|
@@ -33448,14 +33548,16 @@ function attestedPackageManifest(manifestPath, expected) {
|
|
|
33448
33548
|
if (Object.entries(expected.packageFiles).some(([relativePath, sha2563]) => {
|
|
33449
33549
|
const path = resolve10(packageDir, relativePath);
|
|
33450
33550
|
const relativePathFromPackage = relative5(packageDir, path);
|
|
33451
|
-
return !relativePathFromPackage || relativePathFromPackage.startsWith("..") || isAbsolute7(relativePathFromPackage) || !statSync6(path).isFile() || fileSha256(path) !== sha2563;
|
|
33551
|
+
return !relativePathFromPackage || relativePathFromPackage.startsWith("..") || isAbsolute7(relativePathFromPackage) || !statSync6(path).isFile() || requireImageOwnership && !immutableImageFile(path) || fileSha256(path) !== sha2563;
|
|
33452
33552
|
})) return null;
|
|
33453
33553
|
const browserPackageDir = resolve10(packageDir, "..", "..", "chrome-devtools-mcp");
|
|
33454
|
-
const
|
|
33455
|
-
if (
|
|
33554
|
+
const browserManifestPath = join16(browserPackageDir, "package.json");
|
|
33555
|
+
if (requireImageOwnership && !immutableImageFile(browserManifestPath)) return null;
|
|
33556
|
+
const browserPackage = JSON.parse(readFileSync12(browserManifestPath, "utf8"));
|
|
33557
|
+
if (browserPackage.name !== expected.browserTcb.package || browserPackage.version !== expected.browserTcb.version || treeAttestation(join16(browserPackageDir, "build"), requireImageOwnership) !== expected.browserTcb.buildTreeSha256) return null;
|
|
33456
33558
|
const entrypoint = resolve10(packageDir, manifest.main);
|
|
33457
33559
|
const relativeEntrypoint = relative5(packageDir, entrypoint);
|
|
33458
|
-
if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || isAbsolute7(relativeEntrypoint) || !existsSync12(entrypoint)) return null;
|
|
33560
|
+
if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || isAbsolute7(relativeEntrypoint) || !existsSync12(entrypoint) || requireImageOwnership && !immutableImageFile(entrypoint)) return null;
|
|
33459
33561
|
return statSync6(entrypoint).isFile() ? {} : null;
|
|
33460
33562
|
} catch {
|
|
33461
33563
|
return null;
|
|
@@ -33493,7 +33595,7 @@ function inspectBrowserCredentialEnvReadiness(env = process.env) {
|
|
|
33493
33595
|
// src/amaster-runtime-daemon/pi-web-search-readiness.mjs
|
|
33494
33596
|
import { lstatSync as lstatSync11, readFileSync as readFileSync14 } from "node:fs";
|
|
33495
33597
|
import { homedir as homedir6 } from "node:os";
|
|
33496
|
-
import { join as join18 } from "node:path";
|
|
33598
|
+
import { isAbsolute as isAbsolute8, join as join18 } from "node:path";
|
|
33497
33599
|
function readRegularJson(path) {
|
|
33498
33600
|
try {
|
|
33499
33601
|
const stat = lstatSync11(path);
|
|
@@ -33504,18 +33606,36 @@ function readRegularJson(path) {
|
|
|
33504
33606
|
return null;
|
|
33505
33607
|
}
|
|
33506
33608
|
}
|
|
33507
|
-
function
|
|
33508
|
-
|
|
33609
|
+
function isRegularFile(path) {
|
|
33610
|
+
try {
|
|
33611
|
+
const stat = lstatSync11(path);
|
|
33612
|
+
return stat.isFile() && !stat.isSymbolicLink();
|
|
33613
|
+
} catch {
|
|
33614
|
+
return false;
|
|
33615
|
+
}
|
|
33616
|
+
}
|
|
33617
|
+
function installedPiWebAccess(env) {
|
|
33618
|
+
const home = String(env["AMASTER-CLI_CODING_AGENT_DIR"] ?? env.PI_CODING_AGENT_DIR ?? env.PI_AGENT_HOME ?? join18(homedir6(), ".pi", "agent")).trim();
|
|
33509
33619
|
const settings = readRegularJson(join18(home, "settings.json"));
|
|
33510
33620
|
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;
|
|
33621
|
+
const npmConfigured = packages.some((entry) => typeof entry === "string" && /^npm:@amaster\.ai\/pi-web-access(?:@|$)/u.test(entry));
|
|
33514
33622
|
const manifests = [
|
|
33515
33623
|
join18(home, "npm", "node_modules", "@amaster.ai", "pi-web-access", "package.json"),
|
|
33516
33624
|
join18(home, "node_modules", "@amaster.ai", "pi-web-access", "package.json")
|
|
33517
33625
|
];
|
|
33518
|
-
|
|
33626
|
+
const npmInstalled = npmConfigured && manifests.some((path) => readRegularJson(path)?.name === "@amaster.ai/pi-web-access");
|
|
33627
|
+
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")));
|
|
33628
|
+
return { settings, installed: npmInstalled || localInstalled };
|
|
33629
|
+
}
|
|
33630
|
+
function inspectPiWebSearchReadiness(env = process.env) {
|
|
33631
|
+
const { settings, installed } = installedPiWebAccess(env);
|
|
33632
|
+
const providers = settings?.["pi-web-access"]?.providers;
|
|
33633
|
+
return Boolean(installed && providers && typeof providers === "object" && !Array.isArray(providers) && Object.keys(providers).length > 0);
|
|
33634
|
+
}
|
|
33635
|
+
function inspectPiWebFetchReadiness(env = process.env) {
|
|
33636
|
+
const { settings, installed } = installedPiWebAccess(env);
|
|
33637
|
+
const fetch2 = settings?.["pi-web-access"]?.fetch;
|
|
33638
|
+
return Boolean(installed && fetch2?.mode === "direct" && fetch2?.dnsOverHttps === "google");
|
|
33519
33639
|
}
|
|
33520
33640
|
|
|
33521
33641
|
// src/amaster-runtime-daemon/browser-credential-env.mjs
|
|
@@ -33672,7 +33792,7 @@ async function materializeBrowserCredentialEnv(plan, options) {
|
|
|
33672
33792
|
// src/amaster-runtime-daemon/runtime-artifact-upload.mjs
|
|
33673
33793
|
import { createHash as createHash15 } from "node:crypto";
|
|
33674
33794
|
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";
|
|
33675
|
-
import { isAbsolute as
|
|
33795
|
+
import { isAbsolute as isAbsolute9, relative as relative6, resolve as resolve12 } from "node:path";
|
|
33676
33796
|
var SHA256_PATTERN = /^[a-f0-9]{64}$/;
|
|
33677
33797
|
function requiredString2(value, name) {
|
|
33678
33798
|
if (typeof value !== "string" || !value.trim()) throw new Error(`Runtime Artifact ${name} is required`);
|
|
@@ -33685,7 +33805,7 @@ function ownedRelativePath(value) {
|
|
|
33685
33805
|
}
|
|
33686
33806
|
function pathWithin2(candidate, root) {
|
|
33687
33807
|
const rel = relative6(root, candidate);
|
|
33688
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
33808
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute9(rel);
|
|
33689
33809
|
}
|
|
33690
33810
|
function sameFileSnapshot(left, right) {
|
|
33691
33811
|
return left.dev === right.dev && left.ino === right.ino && left.size === right.size && left.mtimeMs === right.mtimeMs && left.ctimeMs === right.ctimeMs;
|
|
@@ -34051,10 +34171,10 @@ function createRuntimeArtifactIngestQueue({ ingest, onError }) {
|
|
|
34051
34171
|
// src/amaster-runtime-daemon/workspace-guard.mjs
|
|
34052
34172
|
import { createHash as createHash17 } from "node:crypto";
|
|
34053
34173
|
import { existsSync as existsSync13, mkdirSync as mkdirSync11, realpathSync as realpathSync11, statSync as statSync7 } from "node:fs";
|
|
34054
|
-
import { basename as basename6, join as join20, isAbsolute as
|
|
34174
|
+
import { basename as basename6, join as join20, isAbsolute as isAbsolute10, relative as relative7, resolve as resolve13 } from "node:path";
|
|
34055
34175
|
function pathWithin3(candidate, root) {
|
|
34056
34176
|
const rel = relative7(root, candidate);
|
|
34057
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
34177
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute10(rel);
|
|
34058
34178
|
}
|
|
34059
34179
|
function resolveWorkspaceCwd(config, command) {
|
|
34060
34180
|
const payload = asRecord(command.payload);
|
|
@@ -34291,7 +34411,7 @@ import {
|
|
|
34291
34411
|
unlinkSync as unlinkSync2,
|
|
34292
34412
|
writeFileSync as writeFileSync13
|
|
34293
34413
|
} from "node:fs";
|
|
34294
|
-
import { dirname as
|
|
34414
|
+
import { dirname as dirname11, extname, isAbsolute as isAbsolute11, join as join22, parse as parse4, resolve as resolve15, sep as sep4 } from "node:path";
|
|
34295
34415
|
import { fileURLToPath } from "node:url";
|
|
34296
34416
|
var PRESET_TEMPLATE_MANIFEST_FILE = ".mirrorx-preset-templates.json";
|
|
34297
34417
|
var MAX_PRESET_TEMPLATE_FILES = 256;
|
|
@@ -34326,7 +34446,7 @@ function assertCatalogReadableByExecutor(targetDir, fileNames, identity) {
|
|
|
34326
34446
|
if (!stat.isDirectory() || !modeAllows(stat, identity, 64, 8, 1)) {
|
|
34327
34447
|
throw new Error(`preset_template_executor_path_unreadable: ${current}`);
|
|
34328
34448
|
}
|
|
34329
|
-
const parent =
|
|
34449
|
+
const parent = dirname11(current);
|
|
34330
34450
|
if (parent === current) break;
|
|
34331
34451
|
current = parent;
|
|
34332
34452
|
}
|
|
@@ -34347,7 +34467,7 @@ function hasAllowedTemplateExtension(name) {
|
|
|
34347
34467
|
return ALLOWED_TEMPLATE_EXTENSIONS.has(extname(name).toLowerCase());
|
|
34348
34468
|
}
|
|
34349
34469
|
function validTemplateName(value) {
|
|
34350
|
-
return typeof value === "string" && value.length > 0 && value !== "." && value !== ".." && !value.includes("\0") && !value.includes("/") && !value.includes("\\") && !
|
|
34470
|
+
return typeof value === "string" && value.length > 0 && value !== "." && value !== ".." && !value.includes("\0") && !value.includes("/") && !value.includes("\\") && !isAbsolute11(value) && parse4(value).base === value && hasAllowedTemplateExtension(value);
|
|
34351
34471
|
}
|
|
34352
34472
|
function readManifest(manifestPath, { strict }) {
|
|
34353
34473
|
try {
|
|
@@ -34411,14 +34531,14 @@ function materializeBundledPresetTemplates(input) {
|
|
|
34411
34531
|
}
|
|
34412
34532
|
const manifest = readManifest(join22(sourceDir, PRESET_TEMPLATE_MANIFEST_FILE), { strict: true });
|
|
34413
34533
|
const verifiedFiles = verifiedBundleFiles(sourceDir, manifest);
|
|
34414
|
-
mkdirSync12(
|
|
34534
|
+
mkdirSync12(dirname11(targetDir), { recursive: true, mode: 493 });
|
|
34415
34535
|
const targetStat = lstatIfExists(targetDir);
|
|
34416
34536
|
if (targetStat && (!targetStat.isDirectory() || targetStat.isSymbolicLink())) {
|
|
34417
34537
|
throw new Error("preset_template_target_root_unsafe");
|
|
34418
34538
|
}
|
|
34419
34539
|
mkdirSync12(targetDir, { recursive: true, mode: 493 });
|
|
34420
34540
|
const previousManifest = readManifest(join22(targetDir, PRESET_TEMPLATE_MANIFEST_FILE), { strict: false });
|
|
34421
|
-
const stageDir = mkdtempSync4(join22(
|
|
34541
|
+
const stageDir = mkdtempSync4(join22(dirname11(targetDir), ".mirrorx-preset-templates-"));
|
|
34422
34542
|
try {
|
|
34423
34543
|
for (const file of verifiedFiles) {
|
|
34424
34544
|
const stagedPath = join22(stageDir, file.name);
|
|
@@ -34480,7 +34600,7 @@ function materializeRuntimePresetTemplates(input) {
|
|
|
34480
34600
|
|
|
34481
34601
|
// src/amaster-runtime-daemon/runtime-status-summary.mjs
|
|
34482
34602
|
import { existsSync as existsSync16, readdirSync as readdirSync11, statSync as statSync10 } from "node:fs";
|
|
34483
|
-
import { dirname as
|
|
34603
|
+
import { dirname as dirname12, join as join23, resolve as resolve16 } from "node:path";
|
|
34484
34604
|
function runtimeStatusDirectoryEntries(path) {
|
|
34485
34605
|
try {
|
|
34486
34606
|
return readdirSync11(path, { withFileTypes: true });
|
|
@@ -34562,7 +34682,7 @@ function summarizeRuntimeStatusRecentRun(workdir, manifest) {
|
|
|
34562
34682
|
}
|
|
34563
34683
|
function runtimeStatusOutboxDir(config) {
|
|
34564
34684
|
const statePath = config.AMASTER_DAEMON_STATE_FILE ?? config.daemonStateFile;
|
|
34565
|
-
return join23(
|
|
34685
|
+
return join23(dirname12(stateFilePath({
|
|
34566
34686
|
AMASTER_DAEMON_STATE_FILE: statePath
|
|
34567
34687
|
})), "result-outbox");
|
|
34568
34688
|
}
|
|
@@ -34570,7 +34690,7 @@ function runtimeStatusRunCompletionDir(config) {
|
|
|
34570
34690
|
const explicit = config.AMASTER_RUN_COMPLETION_STATE_DIR ?? config.runCompletionStateDir;
|
|
34571
34691
|
if (typeof explicit === "string" && explicit.trim()) return resolve16(explicit);
|
|
34572
34692
|
const statePath = config.AMASTER_DAEMON_STATE_FILE ?? config.daemonStateFile;
|
|
34573
|
-
return join23(
|
|
34693
|
+
return join23(dirname12(stateFilePath({
|
|
34574
34694
|
AMASTER_DAEMON_STATE_FILE: statePath
|
|
34575
34695
|
})), "run-completion-state");
|
|
34576
34696
|
}
|
|
@@ -34971,7 +35091,7 @@ export default function amasterProjectInstructions(pi) {
|
|
|
34971
35091
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
34972
35092
|
import { createHash as createHash19 } from "node:crypto";
|
|
34973
35093
|
import { existsSync as existsSync17, readdirSync as readdirSync12, readFileSync as readFileSync19, statSync as statSync11 } from "node:fs";
|
|
34974
|
-
import { basename as basename7, extname as extname2, isAbsolute as
|
|
35094
|
+
import { basename as basename7, extname as extname2, isAbsolute as isAbsolute12, join as join24, relative as relative8, resolve as resolve18 } from "node:path";
|
|
34975
35095
|
var WORKSPACE_RUNTIME_SERVICES_FILENAME = ".amaster-runtime-services.json";
|
|
34976
35096
|
var ARTIFACT_EXTENSIONS = /* @__PURE__ */ new Map([
|
|
34977
35097
|
[".md", "markdown"],
|
|
@@ -35017,7 +35137,7 @@ var SAFE_RUNTIME_SERVICE_HEALTH_STATUSES = /* @__PURE__ */ new Set(["unknown", "
|
|
|
35017
35137
|
var SAFE_RUNTIME_SERVICE_LIFECYCLES = /* @__PURE__ */ new Set(["shared", "ephemeral"]);
|
|
35018
35138
|
function statusPathWithin(candidate, root) {
|
|
35019
35139
|
const rel = relative8(root, candidate);
|
|
35020
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
35140
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute12(rel);
|
|
35021
35141
|
}
|
|
35022
35142
|
function normalizeRelativePath(root, filePath) {
|
|
35023
35143
|
return relative8(root, filePath).split(/[\\/]+/).join("/");
|
|
@@ -35272,7 +35392,7 @@ function assertRequiredTaskAttachmentMaterialized(input, materialized) {
|
|
|
35272
35392
|
}
|
|
35273
35393
|
|
|
35274
35394
|
// src/amaster-runtime-daemon.mjs
|
|
35275
|
-
var CONNECTOR_VERSION = "0.1.
|
|
35395
|
+
var CONNECTOR_VERSION = "0.1.13-beta.1";
|
|
35276
35396
|
var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
|
|
35277
35397
|
var SUPPORTED_TASK_CONTEXT_VERSIONS = Object.freeze([TASK_CONTEXT_MANIFEST_VERSION, TASK_CONTEXT_V2]);
|
|
35278
35398
|
var daemonRequire = createRequire(import.meta.url);
|
|
@@ -35384,7 +35504,7 @@ function resultOutboxPendingCount(config) {
|
|
|
35384
35504
|
function runCompletionStateDir(config) {
|
|
35385
35505
|
const explicit = readString(process.env.AMASTER_RUN_COMPLETION_STATE_DIR);
|
|
35386
35506
|
if (explicit) return resolve19(expandHomePath(explicit));
|
|
35387
|
-
return join25(
|
|
35507
|
+
return join25(dirname13(stateFilePath(process.env)), "run-completion-state");
|
|
35388
35508
|
}
|
|
35389
35509
|
function runCompletionStateInvalidDir(config) {
|
|
35390
35510
|
return join25(runCompletionStateDir(config), "invalid");
|
|
@@ -35830,7 +35950,8 @@ function runtimeAdvertisedCapabilities(config) {
|
|
|
35830
35950
|
executors: config.executors,
|
|
35831
35951
|
browserCredentialAuth: inspectBrowserCredentialAuthReadiness(),
|
|
35832
35952
|
browserCredentialEnv: inspectBrowserCredentialEnvReadiness(),
|
|
35833
|
-
piWebSearchReady: inspectPiWebSearchReadiness()
|
|
35953
|
+
piWebSearchReady: inspectPiWebSearchReadiness(),
|
|
35954
|
+
piWebFetchReady: inspectPiWebFetchReadiness()
|
|
35834
35955
|
});
|
|
35835
35956
|
}
|
|
35836
35957
|
function buildRegisterPayload(config) {
|
|
@@ -36722,7 +36843,7 @@ function safeAgentInstructionMaterializationTarget(workspace, filePath) {
|
|
|
36722
36843
|
const raw = readString(filePath);
|
|
36723
36844
|
if (!raw || raw.includes("\0")) return null;
|
|
36724
36845
|
const normalized = raw.replace(/\\/g, "/");
|
|
36725
|
-
if (
|
|
36846
|
+
if (isAbsolute13(normalized)) return null;
|
|
36726
36847
|
const segments = normalized.split("/").filter(Boolean);
|
|
36727
36848
|
if (segments.length === 0 || segments.some((segment) => segment === "." || segment === "..")) return null;
|
|
36728
36849
|
const relativePath = segments.join("/");
|
|
@@ -36812,7 +36933,7 @@ async function materializeEffectiveAgentInstructions(config, command, workspace,
|
|
|
36812
36933
|
}
|
|
36813
36934
|
const target = safeAgentInstructionMaterializationTarget(workspace, filePath);
|
|
36814
36935
|
if (!target) throw new Error(`context_envelope_instruction_path_invalid: ${filePath}`);
|
|
36815
|
-
mkdirSync13(
|
|
36936
|
+
mkdirSync13(dirname13(target.targetPath), { recursive: true });
|
|
36816
36937
|
const temporaryPath = `${target.targetPath}.mirrorx-${command.commandId}.tmp`;
|
|
36817
36938
|
try {
|
|
36818
36939
|
writeFileSync14(temporaryPath, content, { encoding: "utf8", mode: 384 });
|
|
@@ -38221,7 +38342,7 @@ function manifestMatchesActiveRuntimeRef(manifest, refs, workdir = null) {
|
|
|
38221
38342
|
function buildOrphanReaperSample(root, workdir, manifest, residents) {
|
|
38222
38343
|
const relativeWorkdir = (() => {
|
|
38223
38344
|
const value = relative9(root, workdir);
|
|
38224
|
-
return value && !value.startsWith("..") && !
|
|
38345
|
+
return value && !value.startsWith("..") && !isAbsolute13(value) ? value : basename8(workdir);
|
|
38225
38346
|
})();
|
|
38226
38347
|
return {
|
|
38227
38348
|
workdir: relativeWorkdir,
|
|
@@ -38334,7 +38455,14 @@ function runExecutor(command, args, options) {
|
|
|
38334
38455
|
const maxOutputBytes = parsePositiveInteger(options.maxOutputBytes, 50 * 1024 * 1024);
|
|
38335
38456
|
const maxRssMb = parsePositiveInteger(options.maxRssMb, 0);
|
|
38336
38457
|
const maxRssBytes = maxRssMb * 1024 * 1024;
|
|
38337
|
-
const browserCredentialChannel = typeof options.browserCredentialConsumer === "function" ? createBrowserCredentialChannel({
|
|
38458
|
+
const browserCredentialChannel = typeof options.browserCredentialConsumer === "function" ? createBrowserCredentialChannel({
|
|
38459
|
+
consume: options.browserCredentialConsumer,
|
|
38460
|
+
onFailure: (reason) => {
|
|
38461
|
+
spawnError = reason;
|
|
38462
|
+
spawnErrorCode = reason;
|
|
38463
|
+
requestStop(reason);
|
|
38464
|
+
}
|
|
38465
|
+
}) : null;
|
|
38338
38466
|
const childEnv = { ...options.env };
|
|
38339
38467
|
delete childEnv.AMASTER_BROWSER_CREDENTIAL_PRIVATE_CHANNEL;
|
|
38340
38468
|
if (browserCredentialChannel) childEnv.AMASTER_BROWSER_CREDENTIAL_PRIVATE_CHANNEL = "1";
|
|
@@ -38602,8 +38730,8 @@ function runExecutor(command, args, options) {
|
|
|
38602
38730
|
child.stdout.once("end", () => stdoutDecoder.end());
|
|
38603
38731
|
child.stderr.once("end", () => stderrDecoder.end());
|
|
38604
38732
|
child.on("error", (err) => {
|
|
38605
|
-
spawnError = err.message;
|
|
38606
|
-
spawnErrorCode = typeof err.code === "string" ? err.code : null;
|
|
38733
|
+
if (!spawnError) spawnError = err.message;
|
|
38734
|
+
if (!spawnErrorCode) spawnErrorCode = typeof err.code === "string" ? err.code : null;
|
|
38607
38735
|
});
|
|
38608
38736
|
child.on("exit", (code, signal) => {
|
|
38609
38737
|
childExited = true;
|
|
@@ -39184,7 +39312,7 @@ async function completeCommand(config, command, status, result2, error) {
|
|
|
39184
39312
|
function resultOutboxDir(config) {
|
|
39185
39313
|
const explicit = readString(process.env.AMASTER_RESULT_OUTBOX_DIR);
|
|
39186
39314
|
if (explicit) return resolve19(expandHomePath(explicit));
|
|
39187
|
-
return join25(
|
|
39315
|
+
return join25(dirname13(stateFilePath(process.env)), "result-outbox");
|
|
39188
39316
|
}
|
|
39189
39317
|
function resultOutboxInvalidDir(config) {
|
|
39190
39318
|
return join25(resultOutboxDir(config), "invalid");
|
|
@@ -39661,7 +39789,7 @@ async function materializeRequiredArtifactInputs(config, command, workspace) {
|
|
|
39661
39789
|
}
|
|
39662
39790
|
usedPaths.add(relativePath);
|
|
39663
39791
|
const targetPath = join25(workspace.cwd, relativePath);
|
|
39664
|
-
mkdirSync13(
|
|
39792
|
+
mkdirSync13(dirname13(targetPath), { recursive: true });
|
|
39665
39793
|
writeFileSync14(targetPath, body);
|
|
39666
39794
|
chmodSync8(targetPath, 292);
|
|
39667
39795
|
materialized.push({
|
|
@@ -39759,7 +39887,7 @@ async function materializeMentionedArtifactFiles(config, command, workspace) {
|
|
|
39759
39887
|
return { materialized, skipped };
|
|
39760
39888
|
}
|
|
39761
39889
|
function issueCheckpointDir(workspace) {
|
|
39762
|
-
return join25(
|
|
39890
|
+
return join25(dirname13(workspace.runDir), "checkpoint");
|
|
39763
39891
|
}
|
|
39764
39892
|
async function clearIssueCheckpoint(config, command, workspace, reason, consumedSource = null) {
|
|
39765
39893
|
const checkpointDir = issueCheckpointDir(workspace);
|
|
@@ -39781,7 +39909,7 @@ async function clearIssueCheckpoint(config, command, workspace, reason, consumed
|
|
|
39781
39909
|
}
|
|
39782
39910
|
function safeCheckpointRelativePath(rawPath) {
|
|
39783
39911
|
const raw = String(rawPath ?? "").trim();
|
|
39784
|
-
if (
|
|
39912
|
+
if (isAbsolute13(raw) || /^[A-Za-z]:[\\/]/.test(raw)) return null;
|
|
39785
39913
|
const normalized = raw.split(/[\\/]+/).filter(Boolean).join("/");
|
|
39786
39914
|
if (!normalized || normalized.startsWith("../") || normalized.split("/").some((segment) => segment.startsWith("."))) return null;
|
|
39787
39915
|
if (normalized.startsWith("input-attachments/") || isRuntimeMetadataArtifactPath(normalized)) return null;
|
|
@@ -39913,8 +40041,8 @@ async function materializeIssueCheckpoint(config, command, workspace) {
|
|
|
39913
40041
|
}
|
|
39914
40042
|
const materialized = [];
|
|
39915
40043
|
for (const { relativePath, source, target, expectedSha256, expectedByteSize } of validated) {
|
|
39916
|
-
mkdirSync13(
|
|
39917
|
-
const targetParent = realpathSync12(
|
|
40044
|
+
mkdirSync13(dirname13(target), { recursive: true });
|
|
40045
|
+
const targetParent = realpathSync12(dirname13(target));
|
|
39918
40046
|
if (!pathWithin3(targetParent, workspaceRoot)) {
|
|
39919
40047
|
throw new Error(`issue checkpoint target escapes its workspace: ${relativePath}`);
|
|
39920
40048
|
}
|
|
@@ -40021,7 +40149,7 @@ async function saveIssueCheckpoint(config, command, workspace, candidates, optio
|
|
|
40021
40149
|
}
|
|
40022
40150
|
const target = resolve19(filesDir, relativePath);
|
|
40023
40151
|
if (!pathWithin3(target, filesDir)) continue;
|
|
40024
|
-
mkdirSync13(
|
|
40152
|
+
mkdirSync13(dirname13(target), { recursive: true });
|
|
40025
40153
|
copyFileSync2(ownedSource, target);
|
|
40026
40154
|
const storedStat = lstatSync15(target);
|
|
40027
40155
|
if (!storedStat.isFile() || storedStat.size !== byteSize) {
|
|
@@ -40392,7 +40520,7 @@ async function executeRunCommand(config, command) {
|
|
|
40392
40520
|
executorCommand: invocation.command,
|
|
40393
40521
|
executorHome: workspace.executorHome,
|
|
40394
40522
|
runDir: workspace.runDir,
|
|
40395
|
-
runtimeCacheRoot: join25(
|
|
40523
|
+
runtimeCacheRoot: join25(dirname13(config.daemonStateFile), "cache"),
|
|
40396
40524
|
cwd,
|
|
40397
40525
|
runtimeAuth: commandRuntimeAuth(command),
|
|
40398
40526
|
nativeSession: asRecord(asRecord(executionCommand.payload).nativeSession),
|
|
@@ -40463,6 +40591,10 @@ async function executeRunCommand(config, command) {
|
|
|
40463
40591
|
if (executor.kind === "pi" && Array.isArray(managedMcpProfile.extensionArgs) && managedMcpProfile.extensionArgs.length > 0) {
|
|
40464
40592
|
invocation.args = [...invocation.args, ...managedMcpProfile.extensionArgs];
|
|
40465
40593
|
}
|
|
40594
|
+
if (executor.kind === "pi" && browserCredentialAuthority) {
|
|
40595
|
+
invocation.args = [...invocation.args, ...browserCredentialAuthExtensionArgs(browserCredentialAuthority, executorEnv)];
|
|
40596
|
+
executorEnv = { ...executorEnv, NODE_PATH: BROWSER_AUTH_IMAGE_NODE_PATH };
|
|
40597
|
+
}
|
|
40466
40598
|
if (executor.kind === "pi") {
|
|
40467
40599
|
assertManagedPiNonInteractiveInvocation(invocation.args, managedMcpProfile);
|
|
40468
40600
|
}
|
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.1";
|
|
11
11
|
|
|
12
12
|
const CONFIG_KEY_MAP = new Map([
|
|
13
13
|
["server_url", "AMASTER_EMPLOYEE_SERVER_URL"],
|