@atlasharness/atlascode 0.1.35 → 0.1.36

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.
Files changed (2) hide show
  1. package/dist/cli.js +32 -9
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -68325,7 +68325,7 @@ function unregisterPermissionCallback(requestId) {
68325
68325
  function processMailboxPermissionResponse(params) {
68326
68326
  const callback = pendingCallbacks.get(params.requestId);
68327
68327
  if (!callback) {
68328
- logForDebugging(`[SwarmPermissionPoller] No callback registered for mailbox response ${params.requestId}`);
68328
+ logForDebugging(`[SwarmPermissionPoller] approval response dropped (no pending callback, decided:unavailable) request_id=${params.requestId} decision=${params.decision}`, { level: "warn" });
68329
68329
  return false;
68330
68330
  }
68331
68331
  logForDebugging(`[SwarmPermissionPoller] Processing mailbox response for request ${params.requestId}: ${params.decision}`);
@@ -69576,6 +69576,14 @@ var init_permissionSync = __esm(() => {
69576
69576
 
69577
69577
  // src/swarm/inProcessRunner.ts
69578
69578
  import { randomUUID as randomUUID10 } from "node:crypto";
69579
+ function resolveMailboxPermissionDeadlineMs() {
69580
+ const raw = process.env.ATLAS_PERM_MAILBOX_DEADLINE_MS;
69581
+ const parsed = raw !== undefined ? Number.parseInt(raw, 10) : NaN;
69582
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : PERMISSION_MAILBOX_DEADLINE_MS;
69583
+ }
69584
+ function approvalUnavailableReason(deadlineMs) {
69585
+ return `approval unavailable: the approver (leader) did not respond within ` + `${deadlineMs}ms, so this tool use was denied (fail-closed) — the permission ` + `request was not granted and the tool did NOT run. Try a different approach that ` + `does not require approval, or retry once the approver is available.`;
69586
+ }
69579
69587
  function buildTeammateToolPermissionContext(narrow) {
69580
69588
  return {
69581
69589
  mode: narrow.mode,
@@ -69655,7 +69663,7 @@ function createAssistantAPIErrorMessage(content) {
69655
69663
  message: { role: "assistant", content: [{ type: "text", text: content }] }
69656
69664
  };
69657
69665
  }
69658
- function createInProcessPermissionGate(identity, abortController, tools, getAppState, buildTpc) {
69666
+ function createInProcessPermissionGate(identity, abortController, tools, getAppState, buildTpc, deadlineMs) {
69659
69667
  const effectiveBuildTpc = buildTpc ?? (() => buildTeammateToolPermissionContext(getAppState().toolPermissionContext));
69660
69668
  return async (tool, input) => {
69661
69669
  const toolUseKey = `inproc-${randomUUID10()}`;
@@ -69772,6 +69780,14 @@ function createInProcessPermissionGate(identity, abortController, tools, getAppS
69772
69780
  workerColor: identity.color,
69773
69781
  teamName: identity.teamName
69774
69782
  });
69783
+ let settled = false;
69784
+ const settle = (verdict) => {
69785
+ if (settled)
69786
+ return;
69787
+ settled = true;
69788
+ resolve(verdict);
69789
+ };
69790
+ const effDeadlineMs = deadlineMs ?? resolveMailboxPermissionDeadlineMs();
69775
69791
  registerPermissionCallback({
69776
69792
  requestId: request.id,
69777
69793
  toolUseId: toolUseKey,
@@ -69779,7 +69795,7 @@ function createInProcessPermissionGate(identity, abortController, tools, getAppS
69779
69795
  cleanup();
69780
69796
  persistPermissionUpdates(permissionUpdates);
69781
69797
  const finalInput = updatedInput && Object.keys(updatedInput).length > 0 ? updatedInput : input ?? {};
69782
- resolve({
69798
+ settle({
69783
69799
  allowed: true,
69784
69800
  updatedInput: finalInput
69785
69801
  });
@@ -69787,14 +69803,14 @@ function createInProcessPermissionGate(identity, abortController, tools, getAppS
69787
69803
  onReject(feedback) {
69788
69804
  cleanup();
69789
69805
  const message = feedback ? `${SUBAGENT_REJECT_MESSAGE_WITH_REASON_PREFIX}${feedback}` : SUBAGENT_REJECT_MESSAGE;
69790
- resolve({ allowed: false, ask: true, reason: message });
69806
+ settle({ allowed: false, ask: true, reason: message });
69791
69807
  }
69792
69808
  });
69793
69809
  sendPermissionRequestViaMailbox(request);
69794
- const pollInterval = setInterval(async (abortController, cleanup, resolve, identity, request) => {
69810
+ const pollInterval = setInterval(async (abortController, cleanup, settle, identity, request) => {
69795
69811
  if (abortController.signal.aborted) {
69796
69812
  cleanup();
69797
- resolve({
69813
+ settle({
69798
69814
  allowed: false,
69799
69815
  ask: true,
69800
69816
  reason: SUBAGENT_REJECT_MESSAGE
@@ -69826,16 +69842,23 @@ function createInProcessPermissionGate(identity, abortController, tools, getAppS
69826
69842
  }
69827
69843
  }
69828
69844
  }
69829
- }, PERMISSION_POLL_INTERVAL_MS, abortController, cleanup, resolve, identity, request);
69845
+ }, PERMISSION_POLL_INTERVAL_MS, abortController, cleanup, settle, identity, request);
69846
+ pollInterval.unref();
69847
+ const deadlineTimer = setTimeout(() => {
69848
+ cleanup();
69849
+ settle({ allowed: false, reason: approvalUnavailableReason(effDeadlineMs) });
69850
+ }, effDeadlineMs);
69851
+ deadlineTimer.unref();
69830
69852
  const onAbortListener = () => {
69831
69853
  cleanup();
69832
- resolve({ allowed: false, ask: true, reason: SUBAGENT_REJECT_MESSAGE });
69854
+ settle({ allowed: false, ask: true, reason: SUBAGENT_REJECT_MESSAGE });
69833
69855
  };
69834
69856
  abortController.signal.addEventListener("abort", onAbortListener, {
69835
69857
  once: true
69836
69858
  });
69837
69859
  function cleanup() {
69838
69860
  clearInterval(pollInterval);
69861
+ clearTimeout(deadlineTimer);
69839
69862
  unregisterPermissionCallback(request.id);
69840
69863
  abortController.signal.removeEventListener("abort", onAbortListener);
69841
69864
  }
@@ -70263,7 +70286,7 @@ function startInProcessTeammate(args) {
70263
70286
  logForDebugging(`[inProcessRunner] Unhandled error in ${agentId}: ${error}`);
70264
70287
  });
70265
70288
  }
70266
- var PERMISSION_POLL_INTERVAL_MS = 500, TEAMMATE_MESSAGE_TAG2 = "teammate-message", SUBAGENT_REJECT_MESSAGE = "Permission for this tool use was denied. The tool use was rejected (eg. if it was a file edit, the new_string was NOT written to the file). Try a different approach or report the limitation to complete your task.", SUBAGENT_REJECT_MESSAGE_WITH_REASON_PREFIX = `Permission for this tool use was denied. The tool use was rejected (eg. if it was a file edit, the new_string was NOT written to the file). The user said:
70289
+ var PERMISSION_POLL_INTERVAL_MS = 500, PERMISSION_MAILBOX_DEADLINE_MS = 30000, TEAMMATE_MESSAGE_TAG2 = "teammate-message", SUBAGENT_REJECT_MESSAGE = "Permission for this tool use was denied. The tool use was rejected (eg. if it was a file edit, the new_string was NOT written to the file). Try a different approach or report the limitation to complete your task.", SUBAGENT_REJECT_MESSAGE_WITH_REASON_PREFIX = `Permission for this tool use was denied. The tool use was rejected (eg. if it was a file edit, the new_string was NOT written to the file). The user said:
70267
70290
  `, sleep5 = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
70268
70291
  var init_inProcessRunner = __esm(() => {
70269
70292
  init_shared();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlasharness/atlascode",
3
- "version": "0.1.35",
3
+ "version": "0.1.36",
4
4
  "description": "AtlasCode — Coding Agent for the domestic computing ecosystem (Ascend NPU + domestic LLM backends)",
5
5
  "bin": {
6
6
  "atlas": "dist/cli.js",