@sema-agent/core 1.350.0 → 1.352.0

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.
@@ -679,6 +679,8 @@ export async function prepareTask(spec, deps, sessions, resume, _memorySelector,
679
679
  excludeTools: toolFaceSnapshot.exclude,
680
680
  deferTools: toolFaceSnapshot.defer,
681
681
  promptProfile,
682
+ ...(spec.additionalDirectories !== undefined ? { additionalDirectories: Object.freeze([...spec.additionalDirectories]) } : {}),
683
+ ...(spec.envFacts !== undefined ? { envFacts: { ...spec.envFacts } } : {}),
682
684
  getApiKeyAndHeaders: spec.getApiKeyAndHeaders,
683
685
  parentCwd: taskRootPath,
684
686
  ...(centerAdoption !== undefined ? { centerArtifactDigest: centerAdoption.artifact.artifactDigest } : {}),
@@ -957,7 +959,16 @@ export async function prepareTask(spec, deps, sessions, resume, _memorySelector,
957
959
  }
958
960
  }
959
961
  if (spec.envFacts?.scratchpadDir) {
960
- const c = await executionEnv.canonicalPath(spec.envFacts.scratchpadDir);
962
+ let c = await executionEnv.canonicalPath(spec.envFacts.scratchpadDir);
963
+ if (!c.ok && c.error.code === "not_found") {
964
+ const marker = await executionEnv.joinPath([spec.envFacts.scratchpadDir, ".sema-scratchpad"]);
965
+ const exclusiveCreate = executionEnv.writeFileExclusive?.bind(executionEnv);
966
+ if (marker.ok && exclusiveCreate) {
967
+ const w = await exclusiveCreate(marker.value, "");
968
+ if (w.ok || w.error.code === "already_exists")
969
+ c = await executionEnv.canonicalPath(spec.envFacts.scratchpadDir);
970
+ }
971
+ }
961
972
  if (c.ok)
962
973
  additionalRootsCanonical.push(c.value);
963
974
  }
@@ -1048,6 +1059,7 @@ export async function prepareTask(spec, deps, sessions, resume, _memorySelector,
1048
1059
  ...(internals?.explicitAgentName !== undefined ? { senderName: internals.explicitAgentName } : {}),
1049
1060
  ...(internals?.parentRetainLedger !== undefined ? { siblingRetain: internals.parentRetainLedger } : {}),
1050
1061
  ...(deps.rosterStore !== undefined ? { roster: deps.rosterStore } : {}),
1062
+ ...(deps.onBackgroundChildEvent ? { onBackgroundChildEvent: deps.onBackgroundChildEvent } : {}),
1051
1063
  })));
1052
1064
  if (!(spec.tools ?? []).some((t) => t.name === AGENT_TRANSCRIPT_TOOL_NAME)) {
1053
1065
  tools.push(firstPartyOffload(createAgentTranscriptTool({