@amaster.ai/employee-runtime-connector 0.1.1-beta.59 → 0.1.1-beta.60

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.
@@ -1895,6 +1895,7 @@ function reconcileManagedCodexMcpProfiles(rootPath, options = {}) {
1895
1895
  import { createHash as createHash3 } from "node:crypto";
1896
1896
  import {
1897
1897
  chmodSync as chmodSync3,
1898
+ chownSync as chownSync2,
1898
1899
  copyFileSync,
1899
1900
  existsSync as existsSync3,
1900
1901
  lstatSync as lstatSync3,
@@ -2505,6 +2506,25 @@ function stablePiDirectCatalogSetHash(entries) {
2505
2506
  const normalized = entries.map((entry) => ({ name: entry.name, exposedName: entry.exposedName, schemaHash: entry.schemaHash, riskLevel: entry.riskLevel })).sort((left, right) => left.name.localeCompare(right.name));
2506
2507
  return createHash2("sha256").update(stablePiJson(normalized)).digest("hex");
2507
2508
  }
2509
+ function normalizePiManagedMcpCacheForSemanticHash(value) {
2510
+ const parsed = Buffer.isBuffer(value) || typeof value === "string" ? JSON.parse(value.toString("utf8")) : JSON.parse(JSON.stringify(value));
2511
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
2512
+ throw new Error("managed MCP cache root is invalid");
2513
+ }
2514
+ if (!parsed.servers || typeof parsed.servers !== "object" || Array.isArray(parsed.servers)) {
2515
+ throw new Error("managed MCP cache servers are invalid");
2516
+ }
2517
+ for (const entry of Object.values(parsed.servers)) {
2518
+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
2519
+ delete entry.cachedAt;
2520
+ if (Array.isArray(entry.prompts) && entry.prompts.length === 0) delete entry.prompts;
2521
+ }
2522
+ return parsed;
2523
+ }
2524
+ function stablePiManagedMcpCacheSemanticHash(value) {
2525
+ const parsed = normalizePiManagedMcpCacheForSemanticHash(value);
2526
+ return createHash2("sha256").update(stablePiJson(parsed)).digest("hex");
2527
+ }
2508
2528
  function managedPiEffectiveToolsAttestorExtensionSource() {
2509
2529
  return String.raw`import { createHash } from "node:crypto";
2510
2530
  import { readFileSync, writeFileSync } from "node:fs";
@@ -2531,10 +2551,17 @@ function sha256(value) {
2531
2551
  return createHash("sha256").update(value).digest("hex");
2532
2552
  }
2533
2553
 
2554
+ ${normalizePiManagedMcpCacheForSemanticHash.toString()}
2555
+
2534
2556
  function schemaHash(value) {
2535
2557
  return sha256(stableJson(record(value)));
2536
2558
  }
2537
2559
 
2560
+ function cacheSemanticHash(value) {
2561
+ const parsed = normalizePiManagedMcpCacheForSemanticHash(value);
2562
+ return sha256(stableJson(parsed));
2563
+ }
2564
+
2538
2565
  function toolSetHash(entries) {
2539
2566
  return sha256(stableJson(entries
2540
2567
  .map((entry) => ({ name: entry.name, schemaHash: entry.schemaHash }))
@@ -2591,8 +2618,22 @@ export default function amasterEffectiveToolsAttestor(pi) {
2591
2618
  if (sourceDigest !== manifest.attestorSourceSha256) throw new Error("attestor source digest mismatch");
2592
2619
  const configDigest = sha256(readFileSync(configPath));
2593
2620
  if (configDigest !== manifest.configSha256) throw new Error("managed MCP config digest mismatch");
2594
- const cacheDigest = sha256(readFileSync(cachePath));
2595
- if (cacheDigest !== manifest.cacheSha256) throw new Error("managed MCP cache digest mismatch");
2621
+ const cacheBytes = readFileSync(cachePath);
2622
+ const cacheDigest = sha256(cacheBytes);
2623
+ let cacheSemanticMatches = false;
2624
+ if (cacheDigest !== manifest.cacheSha256) {
2625
+ try {
2626
+ cacheSemanticMatches = cacheSemanticHash(cacheBytes) === manifest.cacheSemanticHash;
2627
+ } catch {
2628
+ cacheSemanticMatches = false;
2629
+ }
2630
+ }
2631
+ const cacheAttestation = cacheDigest === manifest.cacheSha256
2632
+ ? "exact"
2633
+ : cacheSemanticMatches
2634
+ ? "semantic"
2635
+ : null;
2636
+ if (!cacheAttestation) throw new Error("managed MCP cache digest mismatch");
2596
2637
 
2597
2638
  const expectedEntries = Array.isArray(manifest.entries) ? manifest.entries : [];
2598
2639
  if (expectedEntries.length === 0) throw new Error("effective tool manifest is empty");
@@ -2659,6 +2700,7 @@ export default function amasterEffectiveToolsAttestor(pi) {
2659
2700
  attestorSourceSha256: sourceDigest,
2660
2701
  configSha256: configDigest,
2661
2702
  cacheSha256: cacheDigest,
2703
+ cacheAttestation,
2662
2704
  strictInputValidatorSelfTest: true,
2663
2705
  modelInvocationStarted: false,
2664
2706
  attestedAt: new Date().toISOString(),
@@ -2713,6 +2755,8 @@ function applyManagedPiToolAllowlist(args, profile) {
2713
2755
  }
2714
2756
  function createManagedPiMcpProfileApi(options = {}) {
2715
2757
  const spawnSyncImpl = typeof options.spawnSync === "function" ? options.spawnSync : spawnSync2;
2758
+ const chownSyncImpl = typeof options.chownSync === "function" ? options.chownSync : chownSync2;
2759
+ const ownershipStatSyncImpl = typeof options.ownershipStatSync === "function" ? options.ownershipStatSync : statSync2;
2716
2760
  const nowImpl = typeof options.now === "function" ? options.now : Date.now;
2717
2761
  const SUPPORTED_SCHEMA_VERSION2 = "amaster.governed-mcp.v1";
2718
2762
  const SUPPORTED_SERVER_NAME2 = "amaster";
@@ -3562,9 +3606,11 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
3562
3606
  if (result3.error) {
3563
3607
  const code = typeof result3.error.code === "string" ? result3.error.code : "UNKNOWN";
3564
3608
  const receiptDiagnostic = inspectEffectiveToolsProbeReceipt(input.receiptPath);
3565
- throw new Error(
3609
+ const error = new Error(
3566
3610
  `pi_managed_mcp_effective_tools_failed: probe error=${code} elapsedMs=${elapsedMs} timeoutMs=${PI_EFFECTIVE_TOOLS_ATTESTATION_TIMEOUT_MS} receiptPhase=${receiptDiagnostic.phase}`
3567
3611
  );
3612
+ if (code === "ETIMEDOUT") error.code = "pi_managed_mcp_probe_timeout";
3613
+ throw error;
3568
3614
  }
3569
3615
  if (result3.status !== 0) {
3570
3616
  const receiptDiagnostic = inspectEffectiveToolsProbeReceipt(input.receiptPath);
@@ -3734,7 +3780,8 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
3734
3780
  proxyMode: "forbidden",
3735
3781
  attestorSourceSha256,
3736
3782
  configSha256: sha2562(readFileSync3(configPath)),
3737
- cacheSha256
3783
+ cacheSha256,
3784
+ cacheSemanticHash: stablePiManagedMcpCacheSemanticHash(readFileSync3(cachePath))
3738
3785
  };
3739
3786
  writePrivateFile2(manifestPath, `${JSON.stringify(manifest, null, 2)}
3740
3787
  `);
@@ -3743,6 +3790,7 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
3743
3790
  manifestPath,
3744
3791
  receiptPath,
3745
3792
  cacheSha256,
3793
+ cacheContentsBase64: Buffer.from(readFileSync3(cachePath)).toString("base64"),
3746
3794
  configPath,
3747
3795
  configSha256: sha2562(readFileSync3(configPath)),
3748
3796
  attestorSourceSha256,
@@ -3796,6 +3844,7 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
3796
3844
  directAttestationInput,
3797
3845
  spawnIdentity
3798
3846
  ) : {};
3847
+ const runExitClosureCacheOwnership = directAttestationInput ? ownershipStatSyncImpl(directAttestationInput.cachePath) : null;
3799
3848
  const attestationFacts = {
3800
3849
  connectorVersion: nonEmpty2(input.connectorVersion, "connectorVersion"),
3801
3850
  executorKind: "pi",
@@ -3829,6 +3878,22 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
3829
3878
  skillArgs,
3830
3879
  spawnIdentity,
3831
3880
  workspaceMcpConfigPath,
3881
+ ...directAttestationInput ? {
3882
+ runExitClosureBaseline: {
3883
+ schemaVersion: "amaster.pi-run-exit-closure-baseline.v1",
3884
+ owner,
3885
+ profileRoot,
3886
+ cachePath: directAttestationInput.cachePath,
3887
+ cacheSha256: directAttestationInput.cacheSha256,
3888
+ cacheContentsBase64: directAttestationInput.cacheContentsBase64,
3889
+ cacheOwnership: runExitClosureCacheOwnership ? { uid: runExitClosureCacheOwnership.uid, gid: runExitClosureCacheOwnership.gid } : null,
3890
+ manifestPath: directAttestationInput.manifestPath,
3891
+ manifestSha256: sha2562(readFileSync3(directAttestationInput.manifestPath)),
3892
+ configPath: directAttestationInput.configPath,
3893
+ configSha256: directAttestationInput.configSha256,
3894
+ receiptPath: directAttestationInput.receiptPath
3895
+ }
3896
+ } : {},
3832
3897
  // Only narrowed specialized catalogs (diagnosis/source-acquisition) pin
3833
3898
  // the run to the governed tool set. The full catalog is additive: an
3834
3899
  // ordinary run keeps Pi's native tools plus the direct governed tools.
@@ -3853,6 +3918,97 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
3853
3918
  throw error;
3854
3919
  }
3855
3920
  }
3921
+ function restoreManagedPiRunExitClosureBaseline2(input, expectedOwner) {
3922
+ if (!input) return { status: "not_required" };
3923
+ const baseline = record6(input);
3924
+ if (baseline.schemaVersion !== "amaster.pi-run-exit-closure-baseline.v1") {
3925
+ throw new Error("pi_run_exit_closure_baseline_invalid: unsupported schema version");
3926
+ }
3927
+ const owner = record6(baseline.owner);
3928
+ if (owner.commandId !== expectedOwner?.commandId || owner.runId !== expectedOwner?.runId) {
3929
+ throw new Error("pi_run_exit_closure_baseline_owner_mismatch");
3930
+ }
3931
+ const profileRoot = resolve3(nonEmpty2(baseline.profileRoot, "runExitClosureBaseline.profileRoot"));
3932
+ const cachePath = resolve3(nonEmpty2(baseline.cachePath, "runExitClosureBaseline.cachePath"));
3933
+ const manifestPath = resolve3(nonEmpty2(baseline.manifestPath, "runExitClosureBaseline.manifestPath"));
3934
+ const configPath = resolve3(nonEmpty2(baseline.configPath, "runExitClosureBaseline.configPath"));
3935
+ const receiptPath = resolve3(nonEmpty2(baseline.receiptPath, "runExitClosureBaseline.receiptPath"));
3936
+ for (const path of [cachePath, manifestPath, receiptPath]) {
3937
+ if (!within2(path, profileRoot)) throw new Error("pi_run_exit_closure_baseline_path_mismatch");
3938
+ }
3939
+ for (const path of [cachePath, manifestPath, configPath, receiptPath]) {
3940
+ if (existsSync3(path)) {
3941
+ const stat = lstatSync3(path);
3942
+ if (!stat.isFile() || stat.isSymbolicLink()) {
3943
+ throw new Error(`pi_run_exit_closure_baseline_unsafe: ${path}`);
3944
+ }
3945
+ }
3946
+ }
3947
+ const cacheContentsBase64 = nonEmpty2(
3948
+ baseline.cacheContentsBase64,
3949
+ "runExitClosureBaseline.cacheContentsBase64"
3950
+ );
3951
+ const cacheContents = Buffer.from(cacheContentsBase64, "base64");
3952
+ const cacheSha256 = nonEmpty2(baseline.cacheSha256, "runExitClosureBaseline.cacheSha256");
3953
+ if (sha2562(cacheContents) !== cacheSha256) {
3954
+ throw new Error("pi_run_exit_closure_baseline_cache_digest_mismatch");
3955
+ }
3956
+ const baselineCacheOwnership = record6(baseline.cacheOwnership);
3957
+ const cacheOwnership = Number.isSafeInteger(baselineCacheOwnership.uid) && baselineCacheOwnership.uid >= 0 && Number.isSafeInteger(baselineCacheOwnership.gid) && baselineCacheOwnership.gid >= 0 ? { uid: baselineCacheOwnership.uid, gid: baselineCacheOwnership.gid } : existsSync3(cachePath) ? ownershipStatSyncImpl(cachePath) : null;
3958
+ if (!cacheOwnership) {
3959
+ throw new Error("pi_run_exit_closure_baseline_cache_owner_missing");
3960
+ }
3961
+ if (sha2562(readFileSync3(manifestPath)) !== nonEmpty2(baseline.manifestSha256, "runExitClosureBaseline.manifestSha256")) {
3962
+ throw new Error("pi_run_exit_closure_baseline_manifest_drift");
3963
+ }
3964
+ if (sha2562(readFileSync3(configPath)) !== nonEmpty2(baseline.configSha256, "runExitClosureBaseline.configSha256")) {
3965
+ throw new Error("pi_run_exit_closure_baseline_config_drift");
3966
+ }
3967
+ if (existsSync3(receiptPath)) rmSync2(receiptPath);
3968
+ writeOwnedFileAtomic(cachePath, cacheContents);
3969
+ const replacedCacheStat = ownershipStatSyncImpl(cachePath);
3970
+ if (replacedCacheStat.uid !== cacheOwnership.uid || replacedCacheStat.gid !== cacheOwnership.gid) {
3971
+ chownSyncImpl(cachePath, cacheOwnership.uid, cacheOwnership.gid);
3972
+ }
3973
+ if (sha2562(readFileSync3(cachePath)) !== cacheSha256) {
3974
+ throw new Error("pi_run_exit_closure_baseline_restore_failed");
3975
+ }
3976
+ const restoredCacheStat = ownershipStatSyncImpl(cachePath);
3977
+ if (restoredCacheStat.uid !== cacheOwnership.uid || restoredCacheStat.gid !== cacheOwnership.gid) {
3978
+ throw new Error("pi_run_exit_closure_baseline_owner_restore_failed");
3979
+ }
3980
+ return { status: "restored", cacheSha256 };
3981
+ }
3982
+ function inspectManagedPiRunExitClosureAttestation2(input, expectedOwner) {
3983
+ if (!input) return { status: "not_required" };
3984
+ const baseline = record6(input);
3985
+ const owner = record6(baseline.owner);
3986
+ if (owner.commandId !== expectedOwner?.commandId || owner.runId !== expectedOwner?.runId) {
3987
+ throw new Error("pi_run_exit_closure_baseline_owner_mismatch");
3988
+ }
3989
+ const profileRoot = resolve3(nonEmpty2(baseline.profileRoot, "runExitClosureBaseline.profileRoot"));
3990
+ const receiptPath = resolve3(nonEmpty2(baseline.receiptPath, "runExitClosureBaseline.receiptPath"));
3991
+ if (!within2(receiptPath, profileRoot)) throw new Error("pi_run_exit_closure_baseline_path_mismatch");
3992
+ if (!existsSync3(receiptPath)) return { status: "missing" };
3993
+ const stat = lstatSync3(receiptPath);
3994
+ if (!stat.isFile() || stat.isSymbolicLink()) {
3995
+ throw new Error(`pi_run_exit_closure_baseline_unsafe: ${receiptPath}`);
3996
+ }
3997
+ try {
3998
+ const receipt = record6(JSON.parse(readFileSync3(receiptPath, "utf8")));
3999
+ return {
4000
+ status: nonEmpty2(receipt.status, "effectiveToolsReceipt.status"),
4001
+ ...typeof receipt.mode === "string" ? { mode: receipt.mode } : {},
4002
+ ...typeof receipt.error === "string" ? { error: receipt.error.slice(0, 1e3) } : {},
4003
+ ...typeof receipt.cacheSha256 === "string" ? { cacheSha256: receipt.cacheSha256 } : {}
4004
+ };
4005
+ } catch (error) {
4006
+ return {
4007
+ status: "invalid",
4008
+ error: (error instanceof Error ? error.message : String(error)).slice(0, 1e3)
4009
+ };
4010
+ }
4011
+ }
3856
4012
  function prepareDelegatedPiMcpProfile2(input) {
3857
4013
  assertInvocationIsolation2(input);
3858
4014
  const { gateway, gatewayUrl, sessionToken, headers, runId, mcpToolMode, directCatalog } = validateAuthority2(input);
@@ -4157,11 +4313,13 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
4157
4313
  failures
4158
4314
  };
4159
4315
  }
4160
- return { prepareManagedPiMcpProfile: prepareManagedPiMcpProfile2, prepareDelegatedPiMcpProfile: prepareDelegatedPiMcpProfile2, preserveManagedPiSessionRollout: preserveManagedPiSessionRollout2, cleanupManagedPiMcpProfile: cleanupManagedPiMcpProfile2, cleanupDelegatedPiMcpProfile: cleanupDelegatedPiMcpProfile2, reconcileManagedPiMcpProfiles: reconcileManagedPiMcpProfiles2 };
4316
+ return { prepareManagedPiMcpProfile: prepareManagedPiMcpProfile2, prepareDelegatedPiMcpProfile: prepareDelegatedPiMcpProfile2, inspectManagedPiRunExitClosureAttestation: inspectManagedPiRunExitClosureAttestation2, restoreManagedPiRunExitClosureBaseline: restoreManagedPiRunExitClosureBaseline2, preserveManagedPiSessionRollout: preserveManagedPiSessionRollout2, cleanupManagedPiMcpProfile: cleanupManagedPiMcpProfile2, cleanupDelegatedPiMcpProfile: cleanupDelegatedPiMcpProfile2, reconcileManagedPiMcpProfiles: reconcileManagedPiMcpProfiles2 };
4161
4317
  }
4162
4318
  var piManagedMcpProfileApi = createManagedPiMcpProfileApi();
4163
4319
  var prepareManagedPiMcpProfile = piManagedMcpProfileApi.prepareManagedPiMcpProfile;
4164
4320
  var prepareDelegatedPiMcpProfile = piManagedMcpProfileApi.prepareDelegatedPiMcpProfile;
4321
+ var inspectManagedPiRunExitClosureAttestation = piManagedMcpProfileApi.inspectManagedPiRunExitClosureAttestation;
4322
+ var restoreManagedPiRunExitClosureBaseline = piManagedMcpProfileApi.restoreManagedPiRunExitClosureBaseline;
4165
4323
  var preserveManagedPiSessionRollout = piManagedMcpProfileApi.preserveManagedPiSessionRollout;
4166
4324
  var cleanupManagedPiMcpProfile = piManagedMcpProfileApi.cleanupManagedPiMcpProfile;
4167
4325
  var cleanupDelegatedPiMcpProfile = piManagedMcpProfileApi.cleanupDelegatedPiMcpProfile;
@@ -5818,6 +5976,7 @@ function runtimeAuthorizationText(context, mode, { suppressOrdinaryCompletionCon
5818
5976
  ].join(" ") : "";
5819
5977
  const businessOutcomeTerminalContract = !suppressOrdinaryCompletionContract && businessOutcome.mode === "required" ? [
5820
5978
  delivery.mode === "required" ? "When every acceptance criterion is satisfied and the exact current Delivery Manifest is ready, record the final execution disposition with update_parent status in_progress and a concise evidence summary, then end the run successfully without creating a final review interaction." : "When every acceptance criterion is satisfied, record the final execution disposition with update_parent status in_progress and a concise evidence summary, then end the run successfully without creating a final review interaction.",
5979
+ "The exact runtime_action_in_progress_server_owned rejection is the expected fail-before-effect receipt for this Server-owned handoff. After receiving it, do not retry update_parent with done or another status; end the run successfully so the Server terminal reconciler can take over.",
5821
5980
  evidenceAutoAcceptance ? delivery.mode === "required" ? "Only after the run and command succeed does the Server validate the exact current Delivery Manifest and terminal Outcome evidence, auto-accept the Outcome, and finalize the issue as done atomically. This evidence-auto path does not create a Board review; report the actual Server-owned terminal disposition without implying a handoff." : "Only after the run and command succeed does the Server validate the terminal Outcome evidence, auto-accept the Outcome, and finalize the issue as done atomically. This evidence-auto path does not create a Board review; report the actual Server-owned terminal disposition without implying a handoff." : delivery.mode === "required" ? "Only after the run and command succeed does the Server bind the exact current Delivery Manifest and terminal Outcome evidence, create the formal Board review before generic continuation handoff is evaluated, and move the issue to in_review. Board acceptance then finalizes the issue as done atomically." : "Only after the run and command succeed does the Server bind the terminal Outcome evidence, create the formal Board review before generic continuation handoff is evaluated, and move the issue to in_review. Board acceptance then finalizes the issue as done atomically."
5822
5981
  ].join(" ") : "";
5823
5982
  const organizationCapabilityAllowed = asRecord(envelope.organizationCapability).allowed === true;
@@ -9226,12 +9385,12 @@ import { existsSync as existsSync7, mkdirSync as mkdirSync6, realpathSync as rea
9226
9385
  import { basename as basename4, join as join8, isAbsolute as isAbsolute4, relative as relative4, resolve as resolve5 } from "node:path";
9227
9386
 
9228
9387
  // src/amaster-runtime-daemon/workspace-manifest.mjs
9229
- import { chownSync as chownSync2, existsSync as existsSync6, readFileSync as readFileSync8, renameSync as renameSync5, rmSync as rmSync4, statSync as statSync3, writeFileSync as writeFileSync6 } from "node:fs";
9388
+ import { chownSync as chownSync3, existsSync as existsSync6, readFileSync as readFileSync8, renameSync as renameSync5, rmSync as rmSync4, statSync as statSync3, writeFileSync as writeFileSync6 } from "node:fs";
9230
9389
  import { basename as basename3, dirname as dirname5, join as join7 } from "node:path";
9231
9390
  var WORKSPACE_MANIFEST_FILENAME = ".amaster-runtime.json";
9232
9391
  function syncManifestDirOwnership(manifestPath, deps = {}) {
9233
9392
  const stat = deps.statSync ?? statSync3;
9234
- const chown = deps.chownSync ?? chownSync2;
9393
+ const chown = deps.chownSync ?? chownSync3;
9235
9394
  const geteuid = deps.geteuid ?? (typeof process.geteuid === "function" ? process.geteuid.bind(process) : () => null);
9236
9395
  try {
9237
9396
  if (geteuid() !== 0) return false;
@@ -10238,7 +10397,7 @@ var source_acquisition_compatibility_default = {
10238
10397
  };
10239
10398
 
10240
10399
  // src/amaster-runtime-daemon.mjs
10241
- var CONNECTOR_VERSION = "0.1.1-beta.59";
10400
+ var CONNECTOR_VERSION = "0.1.1-beta.60";
10242
10401
  var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
10243
10402
  var SOURCE_ACQUISITION_CAPABILITY = source_acquisition_compatibility_default.profileVersion;
10244
10403
  var SOURCE_ACQUISITION_PROFILE_VERSION = source_acquisition_compatibility_default.profileVersion;
@@ -13422,10 +13581,15 @@ async function executeRunExitClosureTurn(config, inputState, options = {}) {
13422
13581
  protectedValues
13423
13582
  );
13424
13583
  try {
13584
+ const managedMcpClosureBaseline = executorKind === "pi" ? restoreManagedPiRunExitClosureBaseline(
13585
+ executionConfig.runExitClosureBaseline,
13586
+ { commandId: state.commandId, runId: commandRunId(command) }
13587
+ ) : { status: "not_required" };
13425
13588
  await ingestLog(config, command, "system", "info", "Starting bounded run-exit disposition closure turn", {
13426
13589
  presentationKind: "run_exit_disposition_closure",
13427
13590
  commandId: state.commandId,
13428
- closureAttempt: 1
13591
+ closureAttempt: 1,
13592
+ managedMcpClosureBaselineStatus: managedMcpClosureBaseline.status
13429
13593
  });
13430
13594
  let execution;
13431
13595
  try {
@@ -13473,8 +13637,14 @@ async function executeRunExitClosureTurn(config, inputState, options = {}) {
13473
13637
  allowMissingAssistantOutput: false
13474
13638
  }) : null;
13475
13639
  const parsedError = hasOutputFlood ? "Run-exit closure output exceeded the configured limit" : hasMemoryLimit ? "Run-exit closure exceeded the configured memory limit" : execution.timedOut ? "Run-exit closure timed out" : execution.spawnError ?? piInvalidOutputError ?? parsedForValidation.errorMessage ?? ((execution.exitCode ?? 0) === 0 || cleanupDisposition ? null : `Run-exit closure exited with code ${execution.exitCode ?? "unknown"}`);
13476
- const succeeded = execution.cancelled !== true && !hasOutputFlood && !hasMemoryLimit && (execution.exitCode === 0 || completionOutputStopped || Boolean(cleanupDisposition)) && !execution.timedOut && !execution.spawnError && !parsedError;
13477
- await ingestLog(config, command, "system", succeeded ? "info" : "error", succeeded ? "Run-exit disposition closure turn completed" : `Run-exit disposition closure turn failed: ${parsedError}`, {
13640
+ const effectiveToolsAttestation = executorKind === "pi" ? inspectManagedPiRunExitClosureAttestation(
13641
+ executionConfig.runExitClosureBaseline,
13642
+ { commandId: state.commandId, runId: commandRunId(command) }
13643
+ ) : { status: "not_required" };
13644
+ const effectiveToolsError = executorKind === "pi" && executionConfig.runExitClosureBaseline && effectiveToolsAttestation.status !== "attested" ? `Run-exit closure effective-tools attestation ${effectiveToolsAttestation.status}` : null;
13645
+ const closureError = parsedError ?? effectiveToolsError;
13646
+ const succeeded = execution.cancelled !== true && !hasOutputFlood && !hasMemoryLimit && (execution.exitCode === 0 || completionOutputStopped || Boolean(cleanupDisposition)) && !execution.timedOut && !execution.spawnError && !closureError;
13647
+ await ingestLog(config, command, "system", succeeded ? "info" : "error", succeeded ? "Run-exit disposition closure turn completed" : `Run-exit disposition closure turn failed: ${closureError}`, {
13478
13648
  presentationKind: "run_exit_disposition_closure",
13479
13649
  closureAttempt: 1,
13480
13650
  succeeded,
@@ -13483,7 +13653,7 @@ async function executeRunExitClosureTurn(config, inputState, options = {}) {
13483
13653
  });
13484
13654
  return {
13485
13655
  succeeded,
13486
- error: parsedError,
13656
+ error: closureError,
13487
13657
  usage: asRecord(parsed.usage),
13488
13658
  audit: {
13489
13659
  schemaVersion: "run-exit-disposition-closure-v1",
@@ -13495,12 +13665,13 @@ async function executeRunExitClosureTurn(config, inputState, options = {}) {
13495
13665
  summary: truncateText(readString(parsed.summary) ?? "", 2e3),
13496
13666
  outputTelemetry,
13497
13667
  cleanupDisposition,
13668
+ effectiveToolsAttestation,
13498
13669
  toolResults: mcpToolResults.slice(0, 10).map((result3) => ({
13499
13670
  status: readString(result3.status),
13500
13671
  toolName: readString(result3.toolName) ?? readString(result3.name) ?? readString(asRecord(result3.runtimeAction).toolName),
13501
13672
  invocationId: readString(result3.invocationId)
13502
13673
  })),
13503
- ...parsedError ? { error: truncateText(parsedError, 1e3) } : {}
13674
+ ...closureError ? { error: truncateText(closureError, 1e3) } : {}
13504
13675
  }
13505
13676
  };
13506
13677
  } finally {
@@ -15481,7 +15652,8 @@ async function executeRunCommand(config, command) {
15481
15652
  maxOutputBytes: config.executorMaxOutputBytes,
15482
15653
  maxRssMb: config.executorMaxRssMb,
15483
15654
  ...piExecutorIdentity ? { spawnIdentity: piExecutorIdentity } : {},
15484
- ...sourceProfile ? { sourceProfileInput: sourceProfile.input } : {}
15655
+ ...sourceProfile ? { sourceProfileInput: sourceProfile.input } : {},
15656
+ ...managedMcpProfile?.runExitClosureBaseline ? { runExitClosureBaseline: managedMcpProfile.runExitClosureBaseline } : {}
15485
15657
  }
15486
15658
  },
15487
15659
  completionRequest: {
@@ -6,7 +6,7 @@ import { basename, dirname, join, resolve } from "node:path";
6
6
  import { homedir, hostname } from "node:os";
7
7
  import { fileURLToPath } from "node:url";
8
8
 
9
- const CONNECTOR_VERSION = "0.1.1-beta.59";
9
+ const CONNECTOR_VERSION = "0.1.1-beta.60";
10
10
 
11
11
  const CAPABILITIES = [
12
12
  "remote_registration",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amaster.ai/employee-runtime-connector",
3
- "version": "0.1.1-beta.59",
3
+ "version": "0.1.1-beta.60",
4
4
  "description": "MirrorX runtime connector CLI and daemon",
5
5
  "license": "MIT",
6
6
  "type": "module",