@amaster.ai/employee-runtime-connector 0.1.1-beta.135 → 0.1.1-beta.136

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.
@@ -21600,14 +21600,36 @@ var BENIGN_EMPTY_STDIN_CLOSE_ERROR_CODES = /* @__PURE__ */ new Set([
21600
21600
  "EPIPE",
21601
21601
  "ERR_STREAM_DESTROYED"
21602
21602
  ]);
21603
- function closeExecutorStdin(stdin, input, onDeliveryError) {
21603
+ function executorStdinDeliveryFallback(input) {
21604
+ if (!input) return null;
21605
+ const error = new Error("executor stdin closed before delivery completed");
21606
+ error.code = "EPIPE";
21607
+ return error;
21608
+ }
21609
+ function deliverExecutorStdin(stream, input, onSettled) {
21604
21610
  const hasInput = Boolean(input);
21605
- stdin.once("error", (error) => {
21606
- if (!hasInput && BENIGN_EMPTY_STDIN_CLOSE_ERROR_CODES.has(error?.code)) return;
21607
- onDeliveryError(error);
21611
+ let settled = false;
21612
+ const settle = (error) => {
21613
+ if (settled) return;
21614
+ settled = true;
21615
+ if (!hasInput && BENIGN_EMPTY_STDIN_CLOSE_ERROR_CODES.has(error?.code)) {
21616
+ onSettled(null);
21617
+ return;
21618
+ }
21619
+ onSettled(error ?? null);
21620
+ };
21621
+ stream.on("error", settle);
21622
+ stream.once("finish", () => settle(null));
21623
+ stream.once("close", () => {
21624
+ if (stream.writableFinished) return;
21625
+ settle(executorStdinDeliveryFallback(input));
21608
21626
  });
21609
- if (hasInput) stdin.end(input);
21610
- else stdin.end();
21627
+ try {
21628
+ if (hasInput) stream.end(input);
21629
+ else stream.end();
21630
+ } catch (error) {
21631
+ settle(error);
21632
+ }
21611
21633
  }
21612
21634
 
21613
21635
  // src/amaster-runtime-daemon/durability.mjs
@@ -28998,7 +29020,7 @@ function createSourceCompletionStopPolicy({
28998
29020
  }
28999
29021
 
29000
29022
  // src/amaster-runtime-daemon.mjs
29001
- var CONNECTOR_VERSION = "0.1.1-beta.135";
29023
+ var CONNECTOR_VERSION = "0.1.1-beta.136";
29002
29024
  var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
29003
29025
  var SOURCE_ACQUISITION_CAPABILITY2 = source_acquisition_compatibility_default.profileVersion;
29004
29026
  var daemonRequire = createRequire(import.meta.url);
@@ -31770,6 +31792,7 @@ function runExecutor(command, args, options) {
31770
31792
  let quiescenceTimer = null;
31771
31793
  let stoppedResidentTimer = null;
31772
31794
  let completionOutputDrainTimer = null;
31795
+ let stdinSettlementTimer = null;
31773
31796
  let stopReason = null;
31774
31797
  let childExited = false;
31775
31798
  let childClosed = false;
@@ -31777,6 +31800,7 @@ function runExecutor(command, args, options) {
31777
31800
  let closeSignal = null;
31778
31801
  let spawnError = null;
31779
31802
  let spawnErrorCode = null;
31803
+ let stdinSettled = false;
31780
31804
  let outputDrainForcedClosed = false;
31781
31805
  let killedWorkspaceResidents = [];
31782
31806
  let stoppedResidentDrainUntil = 0;
@@ -31814,6 +31838,7 @@ function runExecutor(command, args, options) {
31814
31838
  if (quiescenceTimer) clearTimeout(quiescenceTimer);
31815
31839
  if (stoppedResidentTimer) clearTimeout(stoppedResidentTimer);
31816
31840
  if (completionOutputDrainTimer) clearTimeout(completionOutputDrainTimer);
31841
+ if (stdinSettlementTimer) clearTimeout(stdinSettlementTimer);
31817
31842
  sourceCompletionStopPolicy.close();
31818
31843
  options.signal?.removeEventListener?.("abort", abort);
31819
31844
  resolveRun({
@@ -31843,6 +31868,21 @@ function runExecutor(command, args, options) {
31843
31868
  signalExecutorProcess(child, "SIGTERM", processGroupId);
31844
31869
  scheduleStopKill();
31845
31870
  };
31871
+ const settleExecutorStdin = (error) => {
31872
+ if (stdinSettled) return;
31873
+ stdinSettled = true;
31874
+ if (stdinSettlementTimer) {
31875
+ clearTimeout(stdinSettlementTimer);
31876
+ stdinSettlementTimer = null;
31877
+ }
31878
+ if (error) {
31879
+ if (!spawnError) spawnError = `executor_stdin_delivery_failed: ${error.message}`;
31880
+ const stdinErrorCode = sourceAcquisitionSpawnErrno(error.code);
31881
+ if (!spawnErrorCode && stdinErrorCode) spawnErrorCode = stdinErrorCode;
31882
+ requestStop("stdin_delivery_failed");
31883
+ }
31884
+ maybeFinishQuiescent();
31885
+ };
31846
31886
  const sourceCompletionStopPolicy = createSourceCompletionStopPolicy({
31847
31887
  enabled: options.sourceCompletionGuard === true,
31848
31888
  onStop: requestStop
@@ -31886,6 +31926,15 @@ function runExecutor(command, args, options) {
31886
31926
  };
31887
31927
  const maybeFinishQuiescent = () => {
31888
31928
  if (settled || !childExited && !childClosed) return;
31929
+ if (!stdinSettled) {
31930
+ if (!stdinSettlementTimer) {
31931
+ stdinSettlementTimer = setTimeout(() => {
31932
+ stdinSettlementTimer = null;
31933
+ settleExecutorStdin(executorStdinDeliveryFallback(options.stdin));
31934
+ }, 100);
31935
+ }
31936
+ return;
31937
+ }
31889
31938
  if (isExecutorProcessAlive(child, processGroupId) || !childClosed && Date.now() < stoppedResidentDrainUntil || killedWorkspaceResidents.some((resident) => isProcessIdAlive(resident.pid))) {
31890
31939
  requestStop("completion_cleanup");
31891
31940
  if (!quiescenceTimer) {
@@ -32047,12 +32096,7 @@ function runExecutor(command, args, options) {
32047
32096
  closeSignal = signal;
32048
32097
  maybeFinishQuiescent();
32049
32098
  });
32050
- closeExecutorStdin(child.stdin, options.stdin, (error) => {
32051
- if (settled) return;
32052
- spawnError = `executor_stdin_delivery_failed: ${error.message}`;
32053
- spawnErrorCode = sourceAcquisitionSpawnErrno(error.code);
32054
- requestStop("executor_stdin_delivery_failed");
32055
- });
32099
+ deliverExecutorStdin(child.stdin, options.stdin, settleExecutorStdin);
32056
32100
  });
32057
32101
  }
32058
32102
  async function ingestLog(config, command, stream, level, message, payload = {}) {
@@ -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.135";
10
+ const CONNECTOR_VERSION = "0.1.1-beta.136";
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.135",
3
+ "version": "0.1.1-beta.136",
4
4
  "description": "MirrorX runtime connector CLI and daemon",
5
5
  "license": "MIT",
6
6
  "type": "module",