agentlife 1.5.0 → 1.5.2

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/index.js +50 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2070,6 +2070,42 @@ function visionSurfaceCount(state) {
2070
2070
  n++;
2071
2071
  return n;
2072
2072
  }
2073
+ async function anySpecialistHasBaseline(state, runtime) {
2074
+ const cfg = runtime.config.loadConfig();
2075
+ const list = cfg?.agents?.list ?? [];
2076
+ for (const agent of list) {
2077
+ const id = agent?.id;
2078
+ if (!id || PROVISIONED_IDS.has(id))
2079
+ continue;
2080
+ const workspace = agent.workspace || "";
2081
+ if (!workspace)
2082
+ continue;
2083
+ try {
2084
+ const content = await fs3.readFile(path4.join(workspace, "memory", "baseline.md"), "utf-8");
2085
+ if (content.trim().length > 0)
2086
+ return true;
2087
+ } catch {}
2088
+ }
2089
+ return false;
2090
+ }
2091
+ function specialistHasAnySurface(state, specialistId) {
2092
+ if (!state.surfaceDb)
2093
+ return false;
2094
+ for (const id of state.surfaceDb.keys()) {
2095
+ if (state.surfaceDb.getAgentId(id) === specialistId)
2096
+ return true;
2097
+ }
2098
+ return false;
2099
+ }
2100
+ function specialistIdFromSessionKey(sessionKey) {
2101
+ if (!sessionKey)
2102
+ return null;
2103
+ const parts = sessionKey.split(":");
2104
+ if (parts.length < 2 || parts[0] !== "agent")
2105
+ return null;
2106
+ const id = parts[1];
2107
+ return id && id.length > 0 ? id : null;
2108
+ }
2073
2109
  async function sendSystemMessage(state, agentId, message, idempotencyKey, log) {
2074
2110
  if (!state.runCommand) {
2075
2111
  log(`[cold-start] sendSystemMessage ${idempotencyKey}: skipped — runCommand not available`);
@@ -2113,6 +2149,9 @@ async function computeStartingPhase(state, runtime) {
2113
2149
  if (specialists.length === 0) {
2114
2150
  return { phase: "BLANK", details: "no specialists" };
2115
2151
  }
2152
+ if (await anySpecialistHasBaseline(state, runtime)) {
2153
+ return { phase: "SYNTHESIZING", details: "baseline.md present" };
2154
+ }
2116
2155
  const { total } = await specialistMemoryTotal(state, runtime);
2117
2156
  if (total < VISION_MIN_MEMORY_CHARS) {
2118
2157
  return { phase: "AWAITING_BASELINE", details: `totalChars=${total} below ${VISION_MIN_MEMORY_CHARS}` };
@@ -2149,6 +2188,9 @@ async function transition(state, runtime, log, trigger) {
2149
2188
  case "memoryWritten": {
2150
2189
  if (cur.phase !== "AWAITING_BASELINE")
2151
2190
  return cur;
2191
+ if (await anySpecialistHasBaseline(state, runtime)) {
2192
+ return enterPhase(state, runtime, log, "SYNTHESIZING");
2193
+ }
2152
2194
  const { total } = await specialistMemoryTotal(state, runtime);
2153
2195
  if (total >= VISION_MIN_MEMORY_CHARS) {
2154
2196
  return enterPhase(state, runtime, log, "SYNTHESIZING");
@@ -2176,6 +2218,14 @@ async function transition(state, runtime, log, trigger) {
2176
2218
  return cur;
2177
2219
  }
2178
2220
  if (cur.phase === "AWAITING_BASELINE") {
2221
+ if (await anySpecialistHasBaseline(state, runtime)) {
2222
+ return enterPhase(state, runtime, log, "SYNTHESIZING");
2223
+ }
2224
+ const specialistId = specialistIdFromSessionKey(cur.actionSessionKey);
2225
+ if (specialistId && !specialistHasAnySurface(state, specialistId)) {
2226
+ log(`[cold-start] ${specialistId} replied in AWAITING_BASELINE with no surface ` + `attributed and no baseline.md written — [system:start] contract violation`);
2227
+ return enterFailed(state, log, "agent_produced_no_surface");
2228
+ }
2179
2229
  return cur;
2180
2230
  }
2181
2231
  return cur;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentlife",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "bun build index.ts --outfile dist/index.js --target node --external openclaw/plugin-sdk",