0agent 1.0.15 → 1.0.17

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.
package/bin/0agent.js CHANGED
@@ -94,6 +94,10 @@ switch (cmd) {
94
94
  await runServe(args.slice(1));
95
95
  break;
96
96
 
97
+ case 'watch':
98
+ await runWatch();
99
+ break;
100
+
97
101
  default:
98
102
  showHelp();
99
103
  break;
@@ -447,12 +451,12 @@ async function streamSession(sessionId) {
447
451
  break;
448
452
  case 'session.completed': {
449
453
  if (streaming) { process.stdout.write('\n'); streaming = false; }
450
- // Show files written + commands run
451
454
  const r = event.result ?? {};
452
455
  if (r.files_written?.length) console.log(`\n \x1b[32m✓\x1b[0m Files: ${r.files_written.join(', ')}`);
453
456
  if (r.commands_run?.length) console.log(` \x1b[32m✓\x1b[0m Commands run: ${r.commands_run.length}`);
454
457
  if (r.tokens_used) console.log(` \x1b[2m${r.tokens_used} tokens · ${r.model}\x1b[0m`);
455
458
  console.log('\n \x1b[32m✓ Done\x1b[0m\n');
459
+ await showResultPreview(r); // confirm server/file actually exists
456
460
  ws.close();
457
461
  resolve();
458
462
  break;
@@ -496,6 +500,7 @@ async function pollSession(sessionId) {
496
500
  console.log('\n ✓ Done\n');
497
501
  const out = s.result?.output ?? s.result;
498
502
  if (out && typeof out === 'string') console.log(` ${out}\n`);
503
+ await showResultPreview(s.result ?? {});
499
504
  return;
500
505
  }
501
506
  if (s.status === 'failed') {
@@ -804,6 +809,177 @@ async function waitForTunnelUrl(proc, pattern, timeout) {
804
809
  });
805
810
  }
806
811
 
812
+ // ─── Result preview — confirms the agent's work actually ran ────────────────
813
+
814
+ async function showResultPreview(result) {
815
+ if (!result) return;
816
+ const files = result.files_written ?? [];
817
+ const cmds = result.commands_run ?? [];
818
+ const out = result.output ?? '';
819
+
820
+ // 1. Server check — if a port was mentioned, verify HTTP response
821
+ const allText = [...cmds, out].join(' ');
822
+ const portMatch = allText.match(/(?:localhost:|port\s*[=:]?\s*)(\d{4,5})/i);
823
+ if (portMatch) {
824
+ const port = parseInt(portMatch[1], 10);
825
+ await sleep(1200); // give server a moment to bind
826
+ try {
827
+ const res = await fetch(`http://localhost:${port}/`, { signal: AbortSignal.timeout(2500) });
828
+ const body = await res.text();
829
+ const preview = body.replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' ').trim().slice(0, 120);
830
+ console.log(` \x1b[32m⬡ Confirmed live:\x1b[0m http://localhost:${port} (HTTP ${res.status})`);
831
+ if (preview) console.log(` \x1b[2m${preview}\x1b[0m`);
832
+ } catch {
833
+ // Server not up yet — non-fatal, ExecutionVerifier already handled this
834
+ }
835
+ }
836
+
837
+ // 2. File preview — show first few lines of the most significant created file
838
+ if (files.length > 0) {
839
+ const mainFile = files.find(f => /\.(html|jsx?|tsx?|py|rs|go|md|css|json)$/.test(f)) ?? files[0];
840
+ try {
841
+ const { readFileSync } = await import('node:fs');
842
+ const { resolve: res } = await import('node:path');
843
+ const fullPath = res(process.env['ZEROAGENT_CWD'] ?? process.cwd(), mainFile);
844
+ const content = readFileSync(fullPath, 'utf8');
845
+ const lines = content.split('\n').slice(0, 6).join('\n');
846
+ console.log(`\n \x1b[2m── ${mainFile} ─────────────────────────────────\x1b[0m`);
847
+ console.log(` \x1b[2m${lines}\x1b[0m`);
848
+ if (content.split('\n').length > 6) console.log(` \x1b[2m...\x1b[0m`);
849
+ } catch {}
850
+ }
851
+
852
+ console.log();
853
+ }
854
+
855
+ // ─── Watch mode — ambient intelligence ──────────────────────────────────────
856
+
857
+ async function runWatch() {
858
+ // Ensure daemon is running (auto-starts if needed)
859
+ await requireDaemon();
860
+
861
+ const { basename } = await import('node:path');
862
+ const cwdName = basename(process.cwd());
863
+
864
+ // Header
865
+ console.log(`\n \x1b[1m0agent\x1b[0m watching \x1b[36m${cwdName}\x1b[0m`);
866
+ console.log(` ${'─'.repeat(42)}`);
867
+
868
+ // Show current graph state
869
+ try {
870
+ const h = await fetch(`${BASE_URL}/api/health`).then(r => r.json()).catch(() => null);
871
+ if (h) {
872
+ console.log(` Graph: ${h.graph_nodes ?? 0} nodes · ${h.graph_edges ?? 0} edges`);
873
+ console.log(` Uptime: ${Math.round((h.uptime_ms ?? 0) / 60000)}m · Sandbox: ${h.sandbox_backend ?? '—'}`);
874
+ }
875
+ } catch {}
876
+
877
+ // Show any unseen insights immediately
878
+ try {
879
+ const insights = await fetch(`${BASE_URL}/api/insights?seen=false`).then(r => r.json()).catch(() => []);
880
+ if (Array.isArray(insights) && insights.length > 0) {
881
+ console.log(`\n \x1b[33m${insights.length} unseen insight${insights.length > 1 ? 's' : ''}:\x1b[0m`);
882
+ for (const ins of insights.slice(0, 3)) {
883
+ const icon = ins.type === 'test_failure' ? '\x1b[31m●\x1b[0m' : ins.type === 'git_anomaly' ? '\x1b[33m⚡\x1b[0m' : '\x1b[36m◆\x1b[0m';
884
+ console.log(` ${icon} ${ins.summary}`);
885
+ if (ins.suggested_action) console.log(` \x1b[2m→ ${ins.suggested_action}\x1b[0m`);
886
+ }
887
+ } else {
888
+ console.log(`\n Watching for insights...`);
889
+ }
890
+ } catch {}
891
+
892
+ console.log(`\n \x1b[2mPress Enter to run suggested action · q to quit\x1b[0m\n`);
893
+
894
+ // Connect WebSocket for live events
895
+ const WS = await importWS();
896
+ let lastSuggestion = null;
897
+ let ws;
898
+
899
+ const connect = () => {
900
+ ws = new WS(`ws://localhost:4200/ws`);
901
+
902
+ ws.on('open', () => {
903
+ ws.send(JSON.stringify({ type: 'subscribe', topics: ['sessions', 'graph', 'insights', 'stats'] }));
904
+ });
905
+
906
+ ws.on('message', (data) => {
907
+ try {
908
+ const event = JSON.parse(data.toString());
909
+ const ts = new Date().toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit' });
910
+
911
+ switch (event.type) {
912
+ case 'agent.insight': {
913
+ const ins = event.insight ?? {};
914
+ const icon = ins.type === 'test_failure' ? '\x1b[31m● test\x1b[0m'
915
+ : ins.type === 'git_anomaly' ? '\x1b[33m⚡ git\x1b[0m'
916
+ : '\x1b[36m◆ insight\x1b[0m';
917
+ console.log(` [${ts}] ${icon} ${ins.summary}`);
918
+ if (ins.suggested_action) {
919
+ console.log(` \x1b[36m→ ${ins.suggested_action}\x1b[0m`);
920
+ lastSuggestion = ins.suggested_action;
921
+ }
922
+ break;
923
+ }
924
+ case 'session.completed':
925
+ console.log(` [${ts}] \x1b[32m✓\x1b[0m Session completed`);
926
+ break;
927
+ case 'session.failed':
928
+ console.log(` [${ts}] \x1b[31m✗\x1b[0m Session failed: ${event.error}`);
929
+ break;
930
+ case 'graph.weight_updated':
931
+ // Subtle learning indicator — one dot per weight change
932
+ process.stdout.write('\x1b[2m·\x1b[0m');
933
+ break;
934
+ case 'team.synced':
935
+ console.log(` [${ts}] \x1b[35m⬡\x1b[0m Team synced (↑${event.deltas_pushed ?? 0} ↓${event.deltas_pulled ?? 0})`);
936
+ break;
937
+ }
938
+ } catch {}
939
+ });
940
+
941
+ ws.on('error', () => {});
942
+ ws.on('close', () => {
943
+ setTimeout(connect, 3000); // reconnect on daemon restart
944
+ });
945
+ };
946
+
947
+ connect();
948
+
949
+ // Keyboard handling — Enter = act, q = quit
950
+ if (process.stdin.isTTY) {
951
+ process.stdin.setRawMode(true);
952
+ process.stdin.resume();
953
+ process.stdin.setEncoding('utf8');
954
+ process.stdin.on('data', async (key) => {
955
+ if (key === '\u0003' || key === 'q') { // Ctrl+C or q
956
+ process.stdout.write('\n');
957
+ ws?.close();
958
+ process.stdin.setRawMode(false);
959
+ process.exit(0);
960
+ }
961
+ if (key === '\r' && lastSuggestion) {
962
+ // Extract executable part from suggestion
963
+ const cmd = lastSuggestion.match(/(?:0agent\s+)?(\/?[\w-]+(?:\s+"[^"]*")?)/);
964
+ if (cmd) {
965
+ process.stdout.write('\n');
966
+ const parts = cmd[1].trim().split(/\s+/);
967
+ if (parts[0].startsWith('/')) {
968
+ await runSkill(parts[0].slice(1), parts.slice(1));
969
+ } else if (parts[0] === 'run' || !['start','stop','init','chat'].includes(parts[0])) {
970
+ await runTask(parts[0] === 'run' ? parts.slice(1) : parts);
971
+ }
972
+ lastSuggestion = null;
973
+ }
974
+ }
975
+ });
976
+ } else {
977
+ // Non-interactive: just watch, no keyboard
978
+ process.on('SIGINT', () => { ws?.close(); process.exit(0); });
979
+ await new Promise(() => {}); // run forever
980
+ }
981
+ }
982
+
807
983
  function showHelp() {
808
984
  console.log(`
809
985
  0agent — An agent that learns.
@@ -838,6 +1014,10 @@ function showHelp() {
838
1014
  0agent /build --task next
839
1015
  0agent /qa --url https://staging.myapp.com
840
1016
  0agent serve --tunnel # then share the URL + 0agent team join <CODE>
1017
+ 0agent watch # ambient mode — live insights, press Enter to act
1018
+
1019
+ Auto-start:
1020
+ The daemon auto-starts on first 0agent run. No need for 0agent start.
841
1021
  `);
842
1022
  }
843
1023
 
@@ -853,10 +1033,46 @@ async function isDaemonRunning() {
853
1033
  }
854
1034
 
855
1035
  async function requireDaemon() {
856
- if (!(await isDaemonRunning())) {
857
- console.log('\n Daemon is not running. Start it with: 0agent start\n');
1036
+ if (await isDaemonRunning()) return;
1037
+
1038
+ // Auto-start if config exists — no manual `0agent start` needed
1039
+ if (!existsSync(CONFIG_PATH)) {
1040
+ console.log('\n Not initialised. Run: 0agent init\n');
858
1041
  process.exit(1);
859
1042
  }
1043
+
1044
+ process.stdout.write(' Starting daemon');
1045
+ await _startDaemonBackground();
1046
+
1047
+ for (let i = 0; i < 24; i++) {
1048
+ await sleep(500);
1049
+ process.stdout.write('.');
1050
+ if (await isDaemonRunning()) {
1051
+ process.stdout.write(' ✓\n\n');
1052
+ return;
1053
+ }
1054
+ }
1055
+ process.stdout.write(' ✗\n');
1056
+ console.log(' Daemon failed to start. Check: 0agent logs\n');
1057
+ process.exit(1);
1058
+ }
1059
+
1060
+ // Internal: spawn daemon process without printing the full startup banner
1061
+ async function _startDaemonBackground() {
1062
+ const { resolve: res, dirname: dn, existsSync: ex } = await import('node:path').then(m => m);
1063
+ const pkgRoot = res(dn(new URL(import.meta.url).pathname), '..');
1064
+ const bundled = res(pkgRoot, 'dist', 'daemon.mjs');
1065
+ const devPath = res(pkgRoot, 'packages', 'daemon', 'dist', 'start.js');
1066
+ const script = ex(bundled) ? bundled : devPath;
1067
+ if (!ex(script)) return;
1068
+
1069
+ mkdirSync(resolve(AGENT_DIR, 'logs'), { recursive: true });
1070
+ const child = spawn(process.execPath, [script], {
1071
+ detached: true,
1072
+ stdio: 'ignore',
1073
+ env: { ...process.env, ZEROAGENT_CONFIG: CONFIG_PATH },
1074
+ });
1075
+ child.unref();
860
1076
  }
861
1077
 
862
1078
  async function importWS() {
package/dist/daemon.mjs CHANGED
@@ -989,9 +989,24 @@ var init_TraceStore = __esm({
989
989
  });
990
990
 
991
991
  // packages/core/src/storage/WeightEventLog.ts
992
+ var WeightEventLog;
992
993
  var init_WeightEventLog = __esm({
993
994
  "packages/core/src/storage/WeightEventLog.ts"() {
994
995
  "use strict";
996
+ WeightEventLog = class {
997
+ constructor(adapter) {
998
+ this.adapter = adapter;
999
+ }
1000
+ append(event) {
1001
+ this.adapter.insertWeightEvent(event);
1002
+ }
1003
+ getByEdge(edgeId) {
1004
+ return this.adapter.getWeightEvents(edgeId);
1005
+ }
1006
+ getByTrace(traceId) {
1007
+ return this.adapter.getWeightEventsByTrace(traceId);
1008
+ }
1009
+ };
995
1010
  }
996
1011
  });
997
1012
 
@@ -1426,9 +1441,58 @@ var init_ArchivalMemory = __esm({
1426
1441
  });
1427
1442
 
1428
1443
  // packages/core/src/concurrency/EdgeWeightUpdater.ts
1444
+ var EdgeWeightUpdater;
1429
1445
  var init_EdgeWeightUpdater = __esm({
1430
1446
  "packages/core/src/concurrency/EdgeWeightUpdater.ts"() {
1431
1447
  "use strict";
1448
+ EdgeWeightUpdater = class {
1449
+ constructor(adapter, weightLog) {
1450
+ this.adapter = adapter;
1451
+ this.weightLog = weightLog;
1452
+ }
1453
+ /**
1454
+ * Update edge weight with optimistic concurrency control.
1455
+ * Retries up to 3 times with exponential backoff (1ms, 2ms, 4ms).
1456
+ * On 3rd failure: LWW (last-write-wins) fallback.
1457
+ */
1458
+ async update(edgeId, expectedWeight, newWeight, reason, traceId) {
1459
+ const delays = [1, 2, 4];
1460
+ let currentExpected = expectedWeight;
1461
+ for (let attempt = 0; attempt <= 2; attempt++) {
1462
+ const success = this.adapter.updateEdgeWeight(edgeId, newWeight, currentExpected);
1463
+ if (success) {
1464
+ this.logEvent(edgeId, currentExpected, newWeight, reason, traceId);
1465
+ return true;
1466
+ }
1467
+ const edge = this.adapter.getEdge(edgeId);
1468
+ if (!edge) return false;
1469
+ currentExpected = edge.weight;
1470
+ if (attempt < 2) {
1471
+ await this.sleep(delays[attempt]);
1472
+ }
1473
+ }
1474
+ console.warn(`OCC conflict on edge ${edgeId} after 3 retries \u2014 LWW fallback`);
1475
+ this.adapter.forceUpdateEdgeWeight(edgeId, newWeight);
1476
+ this.logEvent(edgeId, currentExpected, newWeight, `${reason}:lww_fallback`, traceId);
1477
+ return true;
1478
+ }
1479
+ logEvent(edgeId, oldWeight, newWeight, reason, traceId) {
1480
+ const event = {
1481
+ id: crypto.randomUUID(),
1482
+ edge_id: edgeId,
1483
+ old_weight: oldWeight,
1484
+ new_weight: newWeight,
1485
+ delta: newWeight - oldWeight,
1486
+ reason,
1487
+ trace_id: traceId ?? null,
1488
+ created_at: Date.now()
1489
+ };
1490
+ this.weightLog.append(event);
1491
+ }
1492
+ sleep(ms) {
1493
+ return new Promise((resolve11) => setTimeout(resolve11, ms));
1494
+ }
1495
+ };
1432
1496
  }
1433
1497
  });
1434
1498
 
@@ -3166,6 +3230,9 @@ ${issues}`);
3166
3230
  return result.data;
3167
3231
  }
3168
3232
 
3233
+ // packages/daemon/src/SessionManager.ts
3234
+ init_src();
3235
+
3169
3236
  // packages/daemon/src/EntityScopedContext.ts
3170
3237
  init_src();
3171
3238
  var EntityScopedContextLoader = class {
@@ -3501,6 +3568,61 @@ var ProjectScanner = class {
3501
3568
  }
3502
3569
  };
3503
3570
 
3571
+ // packages/daemon/src/ConversationStore.ts
3572
+ var CREATE_TABLE = `
3573
+ CREATE TABLE IF NOT EXISTS conversations (
3574
+ id TEXT PRIMARY KEY,
3575
+ session_id TEXT NOT NULL,
3576
+ user_entity_id TEXT NOT NULL,
3577
+ role TEXT NOT NULL,
3578
+ content TEXT NOT NULL,
3579
+ created_at INTEGER NOT NULL
3580
+ );
3581
+ CREATE INDEX IF NOT EXISTS idx_conv_user ON conversations(user_entity_id, created_at);
3582
+ `;
3583
+ var ConversationStore = class {
3584
+ constructor(adapter) {
3585
+ this.adapter = adapter;
3586
+ }
3587
+ initialised = false;
3588
+ init() {
3589
+ if (this.initialised) return;
3590
+ this.adapter.db.exec(CREATE_TABLE);
3591
+ this.initialised = true;
3592
+ }
3593
+ append(msg) {
3594
+ this.init();
3595
+ const db = this.adapter.db;
3596
+ db.prepare(
3597
+ `INSERT INTO conversations (id, session_id, user_entity_id, role, content, created_at)
3598
+ VALUES (?, ?, ?, ?, ?, ?)`
3599
+ ).run(msg.id, msg.session_id, msg.user_entity_id, msg.role, msg.content, msg.created_at);
3600
+ }
3601
+ getHistory(userEntityId, limit = 20) {
3602
+ this.init();
3603
+ const db = this.adapter.db;
3604
+ const rows = db.prepare(
3605
+ `SELECT * FROM conversations WHERE user_entity_id = ?
3606
+ ORDER BY created_at DESC LIMIT ?`
3607
+ ).all(userEntityId, limit);
3608
+ return rows.reverse();
3609
+ }
3610
+ /**
3611
+ * Build conversation history as LLM messages for context injection.
3612
+ */
3613
+ buildContextMessages(userEntityId, limit = 10) {
3614
+ return this.getHistory(userEntityId, limit).map((m) => ({
3615
+ role: m.role,
3616
+ content: m.content
3617
+ }));
3618
+ }
3619
+ clearHistory(userEntityId) {
3620
+ this.init();
3621
+ const db = this.adapter.db;
3622
+ db.prepare(`DELETE FROM conversations WHERE user_entity_id = ?`).run(userEntityId);
3623
+ }
3624
+ };
3625
+
3504
3626
  // packages/daemon/src/SessionManager.ts
3505
3627
  var SessionManager = class {
3506
3628
  sessions = /* @__PURE__ */ new Map();
@@ -3511,6 +3633,8 @@ var SessionManager = class {
3511
3633
  cwd;
3512
3634
  identity;
3513
3635
  projectContext;
3636
+ conversationStore;
3637
+ weightUpdater;
3514
3638
  anthropicFetcher = new AnthropicSkillFetcher();
3515
3639
  constructor(deps = {}) {
3516
3640
  this.inferenceEngine = deps.inferenceEngine;
@@ -3520,6 +3644,12 @@ var SessionManager = class {
3520
3644
  this.cwd = deps.cwd ?? process.cwd();
3521
3645
  this.identity = deps.identity;
3522
3646
  this.projectContext = deps.projectContext;
3647
+ if (deps.adapter) {
3648
+ this.conversationStore = new ConversationStore(deps.adapter);
3649
+ this.conversationStore.init();
3650
+ const wLog = new WeightEventLog(deps.adapter);
3651
+ this.weightUpdater = new EdgeWeightUpdater(deps.adapter, wLog);
3652
+ }
3523
3653
  }
3524
3654
  /**
3525
3655
  * Create a new session with status 'pending'.
@@ -3707,9 +3837,22 @@ var SessionManager = class {
3707
3837
  );
3708
3838
  const identityContext = this.identity ? `You are talking to ${this.identity.name} (device: ${this.identity.device_id}, timezone: ${this.identity.timezone}).` : void 0;
3709
3839
  const projectCtx = this.projectContext ? ProjectScanner.buildContextPrompt(this.projectContext) : void 0;
3840
+ const userEntityId = enrichedReq.entity_id ?? this.identity?.entity_node_id;
3841
+ let conversationHistory;
3842
+ if (this.conversationStore && userEntityId) {
3843
+ const history = this.conversationStore.buildContextMessages(userEntityId, 8);
3844
+ if (history.length > 0) {
3845
+ const historyStr = history.map((m) => `${m.role === "user" ? "User" : "Agent"}: ${m.content.slice(0, 400)}`).join("\n");
3846
+ conversationHistory = `CONVERSATION HISTORY (use this for context on follow-up requests):
3847
+ ${historyStr}
3848
+
3849
+ Current task:`;
3850
+ }
3851
+ }
3710
3852
  const systemContext = [
3711
3853
  identityContext,
3712
3854
  projectCtx,
3855
+ conversationHistory,
3713
3856
  anthropicContext,
3714
3857
  enrichedReq.context?.system_context ? String(enrichedReq.context.system_context) : void 0
3715
3858
  ].filter(Boolean).join("\n\n") || void 0;
@@ -3726,6 +3869,49 @@ var SessionManager = class {
3726
3869
  } catch {
3727
3870
  agentResult = await executor.execute(enrichedReq.task, systemContext);
3728
3871
  }
3872
+ if (this.conversationStore && userEntityId) {
3873
+ const sessionId = session.id;
3874
+ const now = Date.now();
3875
+ this.conversationStore.append({
3876
+ id: crypto.randomUUID(),
3877
+ session_id: sessionId,
3878
+ user_entity_id: userEntityId,
3879
+ role: "user",
3880
+ content: enrichedReq.task,
3881
+ created_at: now
3882
+ });
3883
+ this.conversationStore.append({
3884
+ id: crypto.randomUUID(),
3885
+ session_id: sessionId,
3886
+ user_entity_id: userEntityId,
3887
+ role: "assistant",
3888
+ content: agentResult.output.slice(0, 1e3),
3889
+ // cap stored output length
3890
+ created_at: now + 1
3891
+ });
3892
+ }
3893
+ const selectedEdgeId = session.plan?.selected_edge?.edge_id;
3894
+ if (selectedEdgeId && this.weightUpdater && this.graph) {
3895
+ const outcomeSignal = this.computeOutcomeSignal(agentResult);
3896
+ if (outcomeSignal !== 0) {
3897
+ const edge = this.graph.getEdge(selectedEdgeId);
3898
+ if (edge && !edge.locked) {
3899
+ const newWeight = Math.max(0, Math.min(
3900
+ 1,
3901
+ edge.weight + outcomeSignal * 0.1
3902
+ // learning rate 0.1
3903
+ ));
3904
+ await this.weightUpdater.update(
3905
+ edge.id,
3906
+ edge.weight,
3907
+ newWeight,
3908
+ outcomeSignal > 0 ? "task_outcome_positive" : "task_outcome_negative",
3909
+ session.id
3910
+ );
3911
+ this.emit({ type: "graph.weight_updated", edge_id: edge.id, old_weight: edge.weight, new_weight: newWeight });
3912
+ }
3913
+ }
3914
+ }
3729
3915
  if (agentResult.files_written.length > 0) {
3730
3916
  this.addStep(session.id, `Files written: ${agentResult.files_written.join(", ")}`);
3731
3917
  }
@@ -3774,6 +3960,23 @@ var SessionManager = class {
3774
3960
  this.eventBus.emit(event);
3775
3961
  }
3776
3962
  }
3963
+ /**
3964
+ * Convert a task result into a weight signal for the knowledge graph.
3965
+ *
3966
+ * Signal scale: -0.3 (failed after retries) to +0.3 (verified success first try).
3967
+ * Neutral (0) when no verification was possible — don't penalise unverifiable tasks.
3968
+ */
3969
+ computeOutcomeSignal(result) {
3970
+ const healAttempts = result["heal_attempts"];
3971
+ if (!healAttempts || healAttempts.length === 0) return 0;
3972
+ const last = healAttempts[healAttempts.length - 1];
3973
+ const verification = last?.["verification"];
3974
+ if (!verification || verification["method"] === "none") return 0;
3975
+ const success = verification["success"] === true;
3976
+ const healed = result["healed"] === true;
3977
+ if (success) return healed ? 0.1 : 0.3;
3978
+ return -0.2;
3979
+ }
3777
3980
  };
3778
3981
 
3779
3982
  // packages/daemon/src/WebSocketEvents.ts
@@ -5013,7 +5216,9 @@ var ZeroAgentDaemon = class {
5013
5216
  llm: llmExecutor,
5014
5217
  cwd,
5015
5218
  identity: identity ?? void 0,
5016
- projectContext: projectContext ?? void 0
5219
+ projectContext: projectContext ?? void 0,
5220
+ adapter: this.adapter
5221
+ // enables ConversationStore + weight feedback
5017
5222
  });
5018
5223
  const teamSync = identity && teams.length > 0 ? new TeamSync(teamManager, this.adapter, identity.entity_node_id) : null;
5019
5224
  let proactiveSurface = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "0agent",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "description": "A persistent, learning AI agent that runs on your machine. An agent that learns.",
5
5
  "private": false,
6
6
  "license": "Apache-2.0",