openzoo 0.50.45 → 0.50.46

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.
@@ -1264,15 +1264,63 @@ function mintLocalAgent(parsed = {}) {
1264
1264
  seedBriefOnCanvas(agent);
1265
1265
  return agent;
1266
1266
  }
1267
- function seedBriefOnCanvas(agent) {
1267
+
1268
+ function entryKickText(e) {
1269
+ if (!e || typeof e !== 'object') return '';
1270
+ if (e.kind === 'send-message') return String(e.message?.content || '');
1271
+ return String(e.content || '');
1272
+ }
1273
+
1274
+ const briefKicked = new Set();
1275
+ function needsJobKick(agent) {
1268
1276
  if (!agent?.id || !String(agent.brief || '').trim()) return false;
1269
- const t = agentTranscript(agent.id);
1270
- if ((t.entries || []).length) return false;
1271
- const nonce = `oz-brief-${agent.id}`;
1272
- fanoutLine(agent.id, 'user', `[brief]\n${agent.brief}`, { clientNonce: nonce, requestId: nonce });
1273
- fanoutLine(agent.id, 'assistant', `Understood. I am ${agent.name}. Working from this brief.`, { clientNonce: nonce, requestId: nonce });
1277
+ if (briefKicked.has(agent.id)) return false;
1278
+ const entries = agentTranscript(agent.id).entries || [];
1279
+ if (!entries.length) return true;
1280
+ if (entries.length > 4) return false;
1281
+ const blob = entries.map(entryKickText).join('\n');
1282
+ if (/\[brief\]/i.test(blob) && entries.length <= 3) {
1283
+ if (/Working from this brief/i.test(blob)) return true;
1284
+ if (entries.length === 1) return true;
1285
+ }
1286
+ return false;
1287
+ }
1288
+
1289
+ function kickBriefedAgent(agent, log = () => {}) {
1290
+ if (!needsJobKick(agent)) return false;
1291
+ briefKicked.add(agent.id);
1292
+ const nonce = `oz-kick-${agent.id}`;
1293
+ log(`cursor-backend: brief-kick start ${agent.id} ${JSON.stringify(agent.name)}`);
1294
+ setImmediate(async () => {
1295
+ try {
1296
+ const z = await zooComplete(
1297
+ 'Your brief is in this thread. Start that job now. Use tools. Do real work. Do not wait for another human message. Do not only say understood.',
1298
+ log,
1299
+ agent.id,
1300
+ {},
1301
+ );
1302
+ const line = fanoutLine(agent.id, 'assistant', z.text, { clientNonce: nonce, requestId: nonce });
1303
+ ssePush('transcript', { ...gatewayEntry(line), agentId: agent.id });
1304
+ bumpAgent(agent.id, { preview: z.text, notify: true });
1305
+ log(`cursor-backend: brief-kick done ${agent.id} seq=${line.seq}`);
1306
+ } catch (e) {
1307
+ briefKicked.delete(agent.id);
1308
+ log(`cursor-backend: brief-kick failed ${agent.id}: ${e.message}`);
1309
+ }
1310
+ });
1274
1311
  return true;
1275
1312
  }
1313
+
1314
+ function seedBriefOnCanvas(agent, log) {
1315
+ if (!agent?.id || !String(agent.brief || '').trim()) return false;
1316
+ const t = agentTranscript(agent.id);
1317
+ if (!(t.entries || []).length) {
1318
+ const nonce = `oz-brief-${agent.id}`;
1319
+ const userLine = fanoutLine(agent.id, 'user', `[brief]\n${agent.brief}`, { clientNonce: nonce, requestId: nonce });
1320
+ ssePush('transcript', { ...gatewayEntry(userLine), agentId: agent.id });
1321
+ }
1322
+ return kickBriefedAgent(agent, log || ((m) => console.error(m)));
1323
+ }
1276
1324
  function groupMemberIds(agentId) {
1277
1325
  const a = (cachedAgentList() || []).find((x) => x.id === agentId);
1278
1326
  if (!a?.isGroup) return [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openzoo",
3
- "version": "0.50.45",
3
+ "version": "0.50.46",
4
4
  "description": "Local x402-paying proxy + MCP server for openzoo.fun — point any OpenAI-compatible harness (Cursor, Claude Code, aider, SDKs) at localhost and it pays per call from a local burner wallet. Solana and Base rails live; Robinhood experimental.",
5
5
  "license": "MIT",
6
6
  "type": "module",