@amaster.ai/employee-runtime-connector 0.1.1-beta.292 → 0.1.1-beta.294

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.
@@ -17764,20 +17764,22 @@ function isWithin(path, root) {
17764
17764
  function makePiRunPathWritable(path, uid, gid, fs = defaultFs) {
17765
17765
  const visit = (entryPath) => {
17766
17766
  const stat = fs.lstatSync(entryPath);
17767
+ const ownedByTarget = stat.uid === uid && stat.gid === gid;
17767
17768
  if (stat.isSymbolicLink()) {
17768
- fs.lchownSync(entryPath, uid, gid);
17769
+ if (!ownedByTarget) fs.lchownSync(entryPath, uid, gid);
17769
17770
  return;
17770
17771
  }
17771
17772
  if (stat.isDirectory()) {
17772
- fs.chmodSync(entryPath, 448);
17773
+ if ((stat.mode & 511) !== 448) fs.chmodSync(entryPath, 448);
17773
17774
  for (const entry of fs.readdirSync(entryPath)) {
17774
17775
  visit(resolve(entryPath, entry));
17775
17776
  }
17776
- fs.chownSync(entryPath, uid, gid);
17777
+ if (!ownedByTarget) fs.chownSync(entryPath, uid, gid);
17777
17778
  return;
17778
17779
  }
17779
- fs.chmodSync(entryPath, 384 | stat.mode & 73);
17780
- fs.chownSync(entryPath, uid, gid);
17780
+ const desiredMode = 384 | stat.mode & 73;
17781
+ if ((stat.mode & 511) !== desiredMode) fs.chmodSync(entryPath, desiredMode);
17782
+ if (!ownedByTarget) fs.chownSync(entryPath, uid, gid);
17781
17783
  };
17782
17784
  visit(resolve(path));
17783
17785
  }
@@ -34342,7 +34344,7 @@ function assertRequiredTaskAttachmentMaterialized(input, materialized) {
34342
34344
  }
34343
34345
 
34344
34346
  // src/amaster-runtime-daemon.mjs
34345
- var CONNECTOR_VERSION = "0.1.1-beta.292";
34347
+ var CONNECTOR_VERSION = "0.1.1-beta.294";
34346
34348
  var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
34347
34349
  var daemonRequire = createRequire(import.meta.url);
34348
34350
  var MAX_CHECKPOINT_BYTES = 20 * 1024 * 1024;
@@ -35027,6 +35029,21 @@ function buildHeartbeatPayload(config, options = {}) {
35027
35029
  function desktopDelegatedRunnerEnabled(config) {
35028
35030
  return config.runnerKind === RUNNER_KIND_DESKTOP_DELEGATED;
35029
35031
  }
35032
+ function piIsolatedChildOwnership(config) {
35033
+ const uid = Number(config.piExecutorUid ?? 0);
35034
+ const gid = Number(config.piExecutorGid ?? uid);
35035
+ if (!Number.isSafeInteger(uid) || uid <= 0 || !Number.isSafeInteger(gid) || gid <= 0) return null;
35036
+ if (desktopDelegatedRunnerEnabled(config)) return null;
35037
+ if (typeof process.getuid !== "function" || process.getuid() !== 0) return null;
35038
+ return { uid, gid };
35039
+ }
35040
+ function handoffPiRunPathsToChild(config, paths) {
35041
+ const ownership = piIsolatedChildOwnership(config);
35042
+ if (!ownership) return;
35043
+ for (const path of paths) {
35044
+ if (typeof path === "string" && path) makePiRunPathWritable(path, ownership.uid, ownership.gid);
35045
+ }
35046
+ }
35030
35047
  function writeLocalRuntimeStatus(config, runtimeStatus) {
35031
35048
  const currentState = readState(process.env);
35032
35049
  writeState(process.env, {
@@ -35734,6 +35751,10 @@ async function syncPiExecutorProviderConfig(config, command, agentDir, providerC
35734
35751
  if (!agentDir) return;
35735
35752
  const { modelsSynced, settingsSynced } = syncAmasterProviderFiles(agentDir, providerConfig);
35736
35753
  if (modelsSynced || settingsSynced) {
35754
+ handoffPiRunPathsToChild(config, [
35755
+ modelsSynced ? join19(agentDir, "models.json") : null,
35756
+ settingsSynced ? join19(agentDir, "settings.json") : null
35757
+ ]);
35737
35758
  await ingestLog(config, command, "system", "info", "Synced AMaster provider config for pi executor", {
35738
35759
  modelsSynced,
35739
35760
  settingsSynced,
@@ -39199,6 +39220,10 @@ async function executeRunCommand(config, command) {
39199
39220
  let completionOwnsManagedMcpProfile = false;
39200
39221
  const trustedPiRuntimeAssertion = commandTrustedPiRuntimeAssertion(command);
39201
39222
  const preparationStages = [];
39223
+ let preparationLogChain = Promise.resolve();
39224
+ const enqueuePreparationLog = (stream, level, message, payload = {}) => {
39225
+ preparationLogChain = preparationLogChain.then(() => ingestLog(config, command, stream, level, message, payload)).catch(() => void 0);
39226
+ };
39202
39227
  const runExecutionStage = (phase, operation) => {
39203
39228
  const startedAtMs = Date.now();
39204
39229
  const recordDuration = () => preparationStages.push({
@@ -39375,7 +39400,7 @@ async function executeRunCommand(config, command) {
39375
39400
  if (executor.kind === "pi") {
39376
39401
  assertManagedPiNonInteractiveInvocation(invocation.args, managedMcpProfile);
39377
39402
  }
39378
- await ingestLog(config, command, "system", "info", desktopDelegatedRunnerEnabled(config) && executor.kind === "pi" ? "Prepared desktop delegated Pi runtime action bridge" : executor.kind === "pi" ? "Prepared isolated Pi managed MCP profile" : `Attested isolated ${executor.kind} managed MCP profile`, {
39403
+ enqueuePreparationLog("system", "info", desktopDelegatedRunnerEnabled(config) && executor.kind === "pi" ? "Prepared desktop delegated Pi runtime action bridge" : executor.kind === "pi" ? "Prepared isolated Pi managed MCP profile" : `Attested isolated ${executor.kind} managed MCP profile`, {
39379
39404
  presentationKind: "managed_mcp_attestation",
39380
39405
  ...managedMcpProfile.attestation
39381
39406
  });
@@ -39500,6 +39525,7 @@ async function executeRunCommand(config, command) {
39500
39525
  mkdirSync10(promptDir, { recursive: true, mode: 448 });
39501
39526
  const promptPath = join19(promptDir, "conversation-system.md");
39502
39527
  writeFileSync12(promptPath, appendedSystemPrompt, { encoding: "utf8", mode: 384, flag: "wx" });
39528
+ handoffPiRunPathsToChild(config, [promptPath]);
39503
39529
  const printIndex = invocation.args.lastIndexOf("-p");
39504
39530
  invocation.args.splice(printIndex < 0 ? invocation.args.length : printIndex, 0, "--append-system-prompt", promptPath);
39505
39531
  }
@@ -39518,24 +39544,18 @@ async function executeRunCommand(config, command) {
39518
39544
  cwd,
39519
39545
  expectedSha256: finalAgentInstructionFiles.get("AGENTS.md")?.sha256
39520
39546
  });
39521
- if (config.piExecutorUid > 0 && !desktopDelegatedRunnerEnabled(config)) {
39522
- piExecutorIdentity = await runExecutionStage("context_attestation", () => preparePiExecutorAccess({
39523
- uid: config.piExecutorUid,
39524
- gid: config.piExecutorGid,
39525
- effectiveUid: typeof process.getuid === "function" ? process.getuid() : null,
39526
- profileRoot: managedMcpProfile.profileRoot,
39527
- workspaceRoot: cwd,
39528
- allowedRoot: config.runtimeWorkspacesRoot
39529
- }));
39530
- }
39547
+ handoffPiRunPathsToChild(config, [
39548
+ ...finalContextExtensions,
39549
+ readString(asRecord(managedMcpProfile.runExitFinalContextAttestation).extensionPath)
39550
+ ]);
39531
39551
  }
39532
39552
  const promptBudgetSummary = contextManifest.budget.totalChars === null ? `${contextManifest.budget.usedChars} characters (unbounded)` : `${contextManifest.budget.usedChars}/${contextManifest.budget.totalChars} characters`;
39533
- await ingestLog(config, command, "system", "info", `Compiled ${contextManifest.mode} prompt using ${promptBudgetSummary}`, {
39553
+ enqueuePreparationLog("system", "info", `Compiled ${contextManifest.mode} prompt using ${promptBudgetSummary}`, {
39534
39554
  presentationKind: "context_manifest",
39535
39555
  contextManifest
39536
39556
  });
39537
39557
  if (contextManifest.continuationPromptContract) {
39538
- await ingestLog(config, command, "system", "info", "Compiled Runtime Action continuation prompt contract", {
39558
+ enqueuePreparationLog("system", "info", "Compiled Runtime Action continuation prompt contract", {
39539
39559
  presentationKind: "runtime_action_continuation_prompt_contract",
39540
39560
  metricName: "mirrorx_runtime_continuation_prompt_generated_total",
39541
39561
  metricValue: 1,
@@ -39544,19 +39564,21 @@ async function executeRunCommand(config, command) {
39544
39564
  });
39545
39565
  }
39546
39566
  if (contextManifest.currentRunContractShadow.status !== "match") {
39547
- await ingestLog(config, command, "system", "warn", "Current Run Contract shadow comparison did not match the legacy runtime inference", {
39567
+ enqueuePreparationLog("system", "warn", "Current Run Contract shadow comparison did not match the legacy runtime inference", {
39548
39568
  presentationKind: "current_run_contract_shadow_audit",
39549
39569
  currentRunContractShadow: contextManifest.currentRunContractShadow
39550
39570
  });
39551
39571
  }
39572
+ await preparationLogChain;
39552
39573
  await ackCommand(config, command, "spawned");
39553
- await ingestLog(config, command, "system", "info", `Starting ${executor.kind} executor`, {
39574
+ enqueuePreparationLog("system", "info", `Starting ${executor.kind} executor`, {
39554
39575
  executorKind: executor.kind,
39555
39576
  cwd,
39556
39577
  args: invocation.args,
39557
39578
  preparationElapsedMs: Math.max(0, Date.now() - preparationStartedAtMs),
39558
39579
  preparationStages
39559
39580
  });
39581
+ await preparationLogChain;
39560
39582
  forgetActiveRunCommand = rememberActiveRunCommand(command, {
39561
39583
  executorKind: executor.kind,
39562
39584
  workspacePath: cwd,
@@ -40214,6 +40236,7 @@ async function executeRunCommand(config, command) {
40214
40236
  }
40215
40237
  return { resultDelivered: Boolean(completion) };
40216
40238
  } finally {
40239
+ await preparationLogChain;
40217
40240
  if (managedMcpProfile && !managedMcpCleanup && !completionOwnsManagedMcpProfile) {
40218
40241
  managedMcpCleanup = cleanupManagedMcpProfile(managedMcpProfile, {
40219
40242
  commandId: command.commandId,
@@ -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.1-beta.292";
10
+ const CONNECTOR_VERSION = "0.1.1-beta.294";
11
11
 
12
12
  const CONFIG_KEY_MAP = new Map([
13
13
  ["server_url", "AMASTER_EMPLOYEE_SERVER_URL"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amaster.ai/employee-runtime-connector",
3
- "version": "0.1.1-beta.292",
3
+ "version": "0.1.1-beta.294",
4
4
  "description": "MirrorX runtime connector CLI and daemon",
5
5
  "license": "MIT",
6
6
  "type": "module",