-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnomad_cli.py
More file actions
3159 lines (2953 loc) · 152 KB
/
nomad_cli.py
File metadata and controls
3159 lines (2953 loc) · 152 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import argparse
import json
import sys
from typing import Any, Dict, Iterable, Optional
from nomad_autopilot import NomadAutopilot
from codex_peer_agent import CodexPeerAgent
from cryptogrift_guard_agent import CryptoGriftGuardAgent
from nomad_swarm_spawner import NomadSwarmSpawner
from workflow import NomadAgent
from self_development import SelfDevelopmentJournal
def _runtime_gradient_context(base_url: str) -> Dict[str, Any]:
from nomad_machine_economy import machine_economy_snapshot
from nomad_operational_release import operational_release_snapshot
from nomad_recruitment_gradient import build_recruitment_gradient
base = (base_url or "").strip()
agent = NomadAgent()
summary = agent.swarm_registry.public_manifest(base_url=base)
worker_fleet = summary.get("transition_worker_fleet") if isinstance(summary.get("transition_worker_fleet"), dict) else {}
if not worker_fleet:
worker_fleet = agent.swarm_registry.worker_fleet_contract(base_url=base)
economy = machine_economy_snapshot()
release = operational_release_snapshot(base_url=base, worker_fleet=worker_fleet, economy=economy)
gradient = build_recruitment_gradient(
base_url=base,
worker_fleet=worker_fleet,
machine_economy=economy,
operational_release=release,
)
return {
"base_url": base,
"summary": summary,
"worker_fleet": worker_fleet,
"economy": economy,
"operational_release": release,
"recruitment_gradient": gradient,
}
def _contract_conformance_for_runtime_context(ctx: Dict[str, Any]) -> Dict[str, Any]:
from nomad_contract_conformance import build_contract_conformance_snapshot
from nomad_machine_product_surface import build_machine_product_surface
from nomad_openapi import build_openapi_document
from nomad_runtime_capsule import build_runtime_capsule
base = str(ctx.get("base_url") or "")
gradient = ctx.get("recruitment_gradient") if isinstance(ctx.get("recruitment_gradient"), dict) else {}
capsule = build_runtime_capsule(base_url=base, recruitment_gradient=gradient)
product = build_machine_product_surface(
base_url=base,
recruitment_gradient=gradient,
runtime_capsule=capsule,
worker_fleet=ctx.get("worker_fleet") if isinstance(ctx.get("worker_fleet"), dict) else {},
machine_economy=ctx.get("economy") if isinstance(ctx.get("economy"), dict) else {},
operational_release=ctx.get("operational_release") if isinstance(ctx.get("operational_release"), dict) else {},
swarm_summary=ctx.get("summary") if isinstance(ctx.get("summary"), dict) else {},
)
return build_contract_conformance_snapshot(
base_url=base,
machine_product_surface=product,
openapi_document=build_openapi_document(base_url=base),
)
def _compact_text(result: Dict[str, Any]) -> str:
mode = result.get("mode", "result")
if mode == "self_audit":
lines = [f"Nomad self audit: {result.get('profile', {}).get('label', 'unknown profile')}"]
for row in result.get("current_stack") or []:
current = row.get("current") or {}
recommended = row.get("recommended") or {}
status = "aligned" if row.get("aligned") else "upgrade"
lines.append(
f"{row.get('category')}: {current.get('name', 'not set')} -> "
f"{recommended.get('name', 'unknown')} [{status}]"
)
upgrades = result.get("upgrades") or []
if upgrades:
lines.append("Next improvements")
lines.extend(f"- {item['category']}: switch to {item['recommended']}" for item in upgrades)
if result.get("analysis"):
lines.append(result["analysis"])
return "\n".join(lines)
if mode == "nomad_system_status":
os_info = result.get("os") or {}
resources = result.get("resources") or {}
compute_lanes = result.get("compute_lanes") or {}
tasks = result.get("tasks") or {}
outbound = result.get("outbound") or {}
autopilot = result.get("autopilot") or {}
autonomous = result.get("autonomous_development") or {}
mutual_aid = result.get("mutual_aid") or {}
top_truth_pattern = mutual_aid.get("top_truth_pattern") or {}
top_high_value_patterns = (mutual_aid.get("top_high_value_patterns") or [])[:3]
lines = [
"Nomad system status",
f"Uptime: {result.get('uptime', 'unknown')}",
f"Platform: {os_info.get('platform', 'unknown')}",
f"CPU: {resources.get('cpu_count', 0)} cores",
f"RAM: {resources.get('memory_gb', 0):.2f} GB",
"",
"Autopilot:",
f" Status: {'[ACTIVE]' if autopilot.get('active') else '[INACTIVE]'}",
]
if autopilot.get("active"):
lines.append(f" Last Run: {autopilot.get('last_run', 'N/A')}")
lines.append(f" Objective: {autopilot.get('objective', 'N/A')}")
lines.extend([
"",
"Autonomous Development:",
f" Actions: {autonomous.get('action_count', 0)}",
f" Latest: {autonomous.get('latest_title', '') or 'none'}",
"",
"Mutual-Aid:",
f" Score: {mutual_aid.get('mutual_aid_score', 0)}",
f" Swarm Assist: {mutual_aid.get('swarm_assist_score', 0)}",
f" Modules: {mutual_aid.get('module_count', 0)}",
f" Ledger: {mutual_aid.get('truth_ledger_count', 0)}",
f" Inbox: {mutual_aid.get('swarm_inbox_count', 0)}",
f" Paid Packs: {mutual_aid.get('paid_pack_count', 0)}",
"",
"Compute Lanes:",
f" Local Ollama: {'[ACTIVE]' if compute_lanes.get('local', {}).get('ollama') else '[INACTIVE]'}",
f" Local llama.cpp: {'[ACTIVE]' if compute_lanes.get('local', {}).get('llama_cpp') else '[INACTIVE]'}",
f" GitHub Models: {'[ACTIVE]' if compute_lanes.get('hosted', {}).get('github_models') else '[INACTIVE]'}",
f" Hugging Face: {'[ACTIVE]' if compute_lanes.get('hosted', {}).get('huggingface') else '[INACTIVE]'}",
f" xAI Grok: {'[ACTIVE]' if compute_lanes.get('hosted', {}).get('xai_grok') else '[INACTIVE]'}",
f" OpenRouter: {'[ACTIVE]' if compute_lanes.get('hosted', {}).get('openrouter') else '[INACTIVE]'}",
f" Modal: {'[ACTIVE]' if (compute_lanes.get('hosted', {}).get('modal') if isinstance(compute_lanes.get('hosted', {}).get('modal'), bool) else (compute_lanes.get('hosted', {}).get('modal') or {}).get('available')) else '[INACTIVE]'}",
f" Lambda Labs: {'[ACTIVE]' if compute_lanes.get('hosted', {}).get('lambda_labs') else '[INACTIVE]'}",
f" RunPod: {'[ACTIVE]' if compute_lanes.get('hosted', {}).get('runpod') else '[INACTIVE]'}",
"",
"Tasks:",
f" Total: {tasks.get('total', 0)}",
f" Paid/Pending: {tasks.get('paid', 0)}",
f" Awaiting Payment: {tasks.get('awaiting_payment', 0)}",
f" Completed: {tasks.get('completed', 0)}",
"",
"Outbound:",
f" Contacts: {(outbound.get('contacts') or {}).get('total', 0)}",
f" Awaiting Reply: {(outbound.get('contacts') or {}).get('awaiting_reply', 0)}",
f" Follow-up Ready: {(outbound.get('contacts') or {}).get('followup_ready', 0)}",
])
if top_truth_pattern:
lines.extend([
"",
"Top Truth Pattern:",
(
f" {top_truth_pattern.get('title', '')} "
f"[{top_truth_pattern.get('pain_type', 'unknown')}] "
f"repeat={top_truth_pattern.get('repeat_count', 0)} "
f"truth={top_truth_pattern.get('truth_score', 0)}"
),
])
if top_high_value_patterns:
lines.extend([
"",
"Top High-Value Patterns:",
])
for item in top_high_value_patterns:
lines.append(
f" {item.get('title', '')} [{item.get('pain_type', 'unknown')}] "
f"hits={item.get('occurrence_count', 0)} "
f"truth={item.get('avg_truth_score', 0)} "
f"reuse={item.get('avg_reuse_value', 0)}"
)
if result.get("analysis"):
lines.append("")
lines.append(result["analysis"])
return "\n".join(lines)
if mode == "nomad_machine_economy":
viability = result.get("machine_viability") or {}
flows = result.get("resource_flows") or {}
tasks = flows.get("service_tasks") or {}
products = flows.get("products") or {}
patterns = flows.get("patterns") or {}
modules = flows.get("modules") or {}
lines = [
"Nomad machine economy",
f"Tier: {viability.get('tier', 'unknown')} score={viability.get('carrying_score', 0)}",
f"Tasks: total={tasks.get('total', 0)} awaiting_payment={tasks.get('awaiting_payment', 0)} unpaid_delivered={tasks.get('unpaid_delivered', 0)}",
f"Products: total={products.get('total', 0)} machine_sellable={products.get('machine_sellable', 0)} exchange_ready={products.get('machine_exchange_ready', 0)}",
f"Patterns: groups={patterns.get('pattern_groups', 0)} high_value={patterns.get('high_value_patterns', 0)} top_count={patterns.get('top_pattern_count', 0)}",
f"Modules: total={modules.get('module_count', 0)} overmint_pressure={modules.get('overmint_pressure', 0)}",
]
actions = result.get("next_actions") or []
if actions:
lines.append("Next actions:")
for item in actions[:4]:
lines.append(f"- {item.get('action', '')}: {item.get('reason', '')}")
if result.get("analysis"):
lines.append(result["analysis"])
return "\n".join(lines)
if mode == "nomad_nonhuman_agent_science" or result.get("schema") == "nomad.nonhuman_agent_science.v1":
claims = result.get("research_claims") or []
lanes = result.get("implementation_lanes") or []
lines = [
"Nomad nonhuman agent science",
f"Claims: {len(claims)}",
f"Lanes: {len(lanes)}",
f"Stance: {result.get('stance', '')}",
]
if claims:
lines.append("Research pressure:")
for item in claims[:5]:
lines.append(f"- {item.get('id', '')}: {item.get('nomad_primitive', '')}")
if lanes:
lines.append("Implementation lanes:")
for lane in lanes[:5]:
lines.append(f"- {lane.get('id', '')}: {lane.get('status', '')}")
return "\n".join(lines)
if result.get("schema") == "nomad.operational_release.v1":
gates = result.get("release_gates") or []
lines = [
"Nomad operational release",
f"Tier: {result.get('release_tier', 'unknown')} capacity={result.get('release_capacity', 0)}",
f"Recommended worker objective: {result.get('recommended_worker_objective', '')}",
]
if gates:
lines.append("Release gates:")
for item in gates[:6]:
lines.append(
f"- {item.get('id', '')}: {item.get('status', '')} score={item.get('score', 0)}"
)
return "\n".join(lines)
if result.get("schema") == "nomad.local_growth_kernel.v1":
pop = result.get("population") or {}
decision = result.get("decision") or {}
worker_execution = result.get("worker_execution") or {}
post_decision = worker_execution.get("post_execution_decision") or {}
evidence = worker_execution.get("fresh_evidence") or {}
fleet = result.get("worker_fleet") or {}
history = result.get("local_worker_history") or {}
top = (pop.get("top_variants") or [{}])[0]
top_fit = top.get("fitness") if isinstance(top, dict) else {}
lines = [
"Nomad local growth kernel",
f"Decision: {decision.get('action', '')} [{decision.get('reason', '')}]",
f"Objective: {decision.get('objective', '')}",
f"Workers: active={fleet.get('active_worker_count', 0)} known={fleet.get('known_worker_count', 0)} leases={fleet.get('active_lease_count', 0)}",
f"Local worker history: runs={history.get('total_runs', 0)} last={history.get('last_objective', '')}",
f"Archive: {pop.get('archive_size_before', 0)} -> {pop.get('archive_size_after', 0)} candidates={pop.get('candidate_count', 0)} diversity={pop.get('population_diversity', 0)}",
f"Top variant: {top.get('variant_id', '') if isinstance(top, dict) else ''} frontier={top_fit.get('frontier_score', 0) if isinstance(top_fit, dict) else 0}",
]
if worker_execution.get("requested"):
lines.append(
f"Worker pulse: events={evidence.get('event_count', 0)} ok={evidence.get('ok_count', 0)}"
)
if post_decision:
lines.append(
f"Post-pulse: {post_decision.get('action', '')} objective={post_decision.get('objective', '')}"
)
lines.append(result.get("analysis", ""))
return "\n".join(
[
line for line in lines if line
]
)
if result.get("schema") == "nomad.recruitment_gradient.v1":
state = result.get("state_vector") or {}
rows = result.get("gradient") or []
budget = result.get("runtime_budget") or {}
lines = [
"Nomad recruitment gradient",
f"Field strength: {state.get('field_strength', 0)}",
f"Wanted runtimes: {budget.get('wanted_new_runtimes_now', 0)}",
]
if rows:
lines.append("Top routes:")
for item in rows[:5]:
lines.append(
f"- {item.get('objective', '')}: weight={item.get('routing_weight', 0)} deficit={item.get('deficit', 0)}"
)
return "\n".join(lines)
if result.get("schema") == "nomad.protocol_bytecode.v1":
vector = result.get("current_vector") or {}
programs = result.get("programs") or []
lines = [
"Nomad protocol bytecode",
f"Digest: {result.get('bytecode_digest', '')}",
f"Top objective: {vector.get('top_objective', '')}",
f"Workers: {vector.get('active_workers', 0)}",
f"Programs: {', '.join(str(item.get('id', '')) for item in programs[:4] if isinstance(item, dict))}",
]
return "\n".join([line for line in lines if line])
if result.get("schema") == "nomad.counterfactual_lease_replay.v1":
selected = result.get("selected_shadow_lease") or {}
leases = result.get("counterfactual_leases") or []
lines = [
"Nomad counterfactual replay",
f"Digest: {result.get('replay_digest', '')}",
f"Selected: {selected.get('objective', '')} score={selected.get('counterfactual_score', 0)}",
]
if leases:
lines.append("Shadow leases:")
for item in leases[:5]:
lines.append(
f"- {item.get('objective', '')}: score={item.get('counterfactual_score', 0)} proof={item.get('predicted_proof_yield_per_minute', 0)}"
)
return "\n".join(lines)
if result.get("schema") == "nomad.runtime_capsule.v1":
hint = result.get("routing_hint") or {}
return "\n".join(
[
"Nomad runtime capsule",
f"Capsule: {result.get('capsule_digest', '')}",
f"Gradient: {result.get('gradient_hash', '')}",
f"Top objective: {hint.get('top_objective', '')}",
f"Field strength: {hint.get('field_strength', 0)}",
]
)
if result.get("schema") == "nomad.openclaw_bridge_contract.v1":
adapter = result.get("adapter") or {}
return "\n".join(
[
"Nomad OpenClaw bridge",
f"Adapter: {adapter.get('download', '')}",
f"Command: {adapter.get('command', '')}",
]
)
if mode == "nomad_autopilot":
service = result.get("service") or {}
outreach = result.get("outreach") or {}
outbound_tracking = result.get("outbound_tracking") or {}
lead_conversion = result.get("lead_conversion") or {}
product_factory = result.get("product_factory") or {}
reply_conversion = result.get("reply_conversion") or {}
autonomous_development = result.get("autonomous_development") or {}
campaign = outreach.get("campaign") or {}
stats = campaign.get("stats") or {}
conversion_stats = lead_conversion.get("stats") or {}
autonomous_action = autonomous_development.get("action") or {}
lines = [
"Nomad autopilot",
f"Objective: {result.get('objective', '')}",
f"Worked paid tasks: {len(service.get('worked_task_ids') or [])}",
f"Draft-ready tasks: {len(service.get('draft_ready_task_ids') or [])}",
f"Awaiting payment: {len(service.get('awaiting_payment_task_ids') or [])}",
f"Stale invalid tasks dropped: {len(service.get('stale_invalid_task_ids') or [])}",
f"Payment follow-ups sent: {len((result.get('payment_followup_send') or {}).get('sent_contact_ids') or [])}",
f"Lead conversions: {sum(int(value) for value in conversion_stats.values()) if conversion_stats else 0}",
f"Products built: {product_factory.get('product_count', 0)}",
f"A2A replies converted: {len(reply_conversion.get('created_task_ids') or [])}",
f"Outreach queued: {stats.get('queued', 0)}",
f"Outreach sent: {stats.get('sent', 0)}",
f"Tracked outbound threads: {(outbound_tracking.get('contacts') or {}).get('total', 0)}",
(
f"Autonomous dev: {autonomous_action.get('title')}"
if autonomous_action
else f"Autonomous dev: skipped ({autonomous_development.get('reason', 'none')})"
),
]
quota = result.get("daily_quota") or {}
if quota:
lines.append(
"Daily A2A quota: "
f"prepared {quota.get('prepared_count', 0)}/{quota.get('target', 0)}, "
f"sent {quota.get('sent_count', 0)}/{quota.get('target', 0)}"
)
if outbound_tracking.get("next_best_action"):
lines.append(f"Next outbound action: {outbound_tracking.get('next_best_action')}")
if result.get("analysis"):
lines.append(result["analysis"])
proof = result.get("autonomy_proof") or {}
if proof:
lines.append(
"Autonomy proof: "
f"{proof.get('status', 'unknown')} "
f"(useful={bool(proof.get('cycle_was_useful'))}, "
f"artifact={proof.get('useful_artifact_created', '') or 'none'}, "
f"unlock={proof.get('next_required_unlock', '') or 'none'})"
)
return "\n".join(lines)
if mode == "nomad_mission_control":
top = result.get("top_blocker") or {}
paid = result.get("paid_job_focus") or {}
next_action = result.get("next_action") or {}
compute = result.get("compute_policy") or {}
unlocks = result.get("human_unlocks") or []
tasks = result.get("agent_tasks") or []
lines = [
"Nomad mission control",
f"Top blocker: {top.get('summary', 'unknown')}",
f"Next: {next_action.get('summary', top.get('next_action', ''))}",
f"Paid focus: {paid.get('target_offer', '')} [{paid.get('status', '')}]",
f"Compute: max {compute.get('max_active_agents_per_blocker', 2)} specialist(s) per blocker, {compute.get('default_mode', 'local_first')}",
]
if unlocks:
unlock = unlocks[0]
lines.append(f"Human unlock: {unlock.get('title', '')} -> {unlock.get('expected_reply', '')}")
if tasks:
task = tasks[0]
lines.append(f"First agent task: {task.get('id', '')} ({task.get('role', '')})")
if result.get("analysis"):
lines.append(result["analysis"])
return "\n".join(line for line in lines if line)
if mode == "nomad_lead_workbench":
self_help = result.get("self_help") or {}
lines = [
"Nomad lead workbench",
f"Queue: {result.get('queue_count', 0)}",
f"Worked: {result.get('worked_count', 0)}",
f"Top action: {self_help.get('top_next_action', '')}",
f"Executable without human: {self_help.get('executable_without_human_count', 0)}",
f"Human-blocked: {self_help.get('human_blocked_count', 0)}",
]
for item in (result.get("queue") or [])[:3]:
lines.append(
f"- {item.get('kind')}: {item.get('title', '')} "
f"[{item.get('safe_next_action', '')}]"
)
if result.get("analysis"):
lines.append(result["analysis"])
return "\n".join(line for line in lines if line)
if mode == "codex_peer_agent":
receipt = result.get("join_receipt") or {}
development = result.get("development_response") or {}
lead = result.get("lead_workbench") or {}
mission = result.get("mission") or {}
lines = [
"CodexPeerAgent",
f"Transport: {result.get('transport', '')}",
f"Join receipt: {receipt.get('receipt_id', '') or 'none'} accepted={receipt.get('accepted', False)}",
f"Development: {development.get('solution_title', '') or development.get('pain_type', '')}",
f"Worked leads: {lead.get('worked_count', 0)} / queue {lead.get('queue_count', 0)}",
f"Top lead action: {lead.get('top_next_action', '')}",
f"Top blocker: {mission.get('top_blocker', '')}",
f"Next: {mission.get('next_action', '')}",
]
if result.get("analysis"):
lines.append(result["analysis"])
return "\n".join(line for line in lines if line)
if mode == "codex_peer_worker":
lines = [
"CodexPeerWorker",
f"Transport: {result.get('transport', '')} http_only={result.get('http_only', False)}",
f"Cycles: {result.get('cycles_completed', 0)} / requested {result.get('cycles_requested', 0)}",
f"Worked leads: {result.get('worked_leads', 0)} / queue {result.get('latest_queue_count', 0)}",
f"Prospect agents: {result.get('latest_prospect_agents', 0)}",
f"Queued invites: {result.get('latest_queued_agent_invites', 0)}",
f"Agent to attract: {result.get('latest_agent_to_attract', '')}",
f"Top action: {result.get('latest_top_action', '')}",
f"Top blocker: {result.get('latest_top_blocker', '')}",
f"Next: {result.get('latest_next_action', '')}",
]
if result.get("analysis"):
lines.append(result["analysis"])
return "\n".join(line for line in lines if line)
if mode == "nomad_service_e2e":
task = result.get("task") or {}
payment = task.get("payment") if isinstance(task.get("payment"), dict) else {}
lifecycle = result.get("lifecycle") or []
lines = [
"Nomad service E2E",
f"Task: {task.get('task_id', 'preview')}",
f"Status: {task.get('status', 'preview')}",
f"Service type: {task.get('service_type', 'custom')}",
f"Budget: {payment.get('amount_native', task.get('budget_native', 0))} {payment.get('native_symbol', '')}".strip(),
f"Next: {result.get('next_best_action', '')}",
]
if lifecycle:
current = next(
(
step
for step in lifecycle
if step.get("status") in {"ready", "in_progress"}
),
lifecycle[-1],
)
lines.append(f"Current stage: {current.get('stage', 'unknown')} [{current.get('status', 'unknown')}]")
if result.get("analysis"):
lines.append(result["analysis"])
return "\n".join(line for line in lines if line)
if mode == "nomad_outbound_tracking":
contacts = result.get("contacts") or {}
campaigns = result.get("campaigns") or {}
tasks = result.get("tasks") or {}
autonomous = result.get("autonomous_tracking") or {}
lines = [
"Nomad outbound tracking",
f"Contacts: {contacts.get('total', 0)}",
f"Awaiting reply: {contacts.get('awaiting_reply', 0)}",
f"Follow-up ready: {contacts.get('followup_ready', 0)}",
f"Campaigns: {campaigns.get('total', 0)}",
f"Awaiting payment tasks: {len(tasks.get('awaiting_payment') or [])}",
f"Autonomous follow-ups: payments={autonomous.get('payment_followup_log_count', 0)}, agents={autonomous.get('agent_followup_log_count', 0)}",
f"Next: {result.get('next_best_action', '')}",
]
if result.get("analysis"):
lines.append(result["analysis"])
return "\n".join(line for line in lines if line)
if mode == "autopilot_idle":
decision = result.get("decision") or {}
lines = [
"Nomad autopilot idle",
f"Reason: {decision.get('reason', 'waiting')}",
f"Next check: {result.get('next_check_seconds', decision.get('next_check_seconds', 0))} seconds",
]
active_lanes = decision.get("active_compute_lanes") or []
if active_lanes:
lines.append(f"Active compute: {', '.join(active_lanes)}")
if result.get("analysis"):
lines.append(result["analysis"])
return "\n".join(lines)
if mode == "nomad_addon_scan":
stats = result.get("stats") or {}
lines = [
"Nomad addons",
f"Source: {result.get('source_dir', '')}",
f"Discovered: {stats.get('discovered', 0)}",
f"Safe active adapters: {stats.get('active_safe_adapter', 0)}",
f"Needs review: {stats.get('needs_human_review', 0)}",
]
for addon in (result.get("addons") or [])[:5]:
lines.append(
f"- {addon.get('name')} [{addon.get('status')}] "
f"source={addon.get('manifest_path')}"
)
quantum = result.get("quantum_tokens") or {}
best_unlock = quantum.get("best_next_quantum_unlock") or {}
if best_unlock:
lines.append(
f"Best quantum unlock: {best_unlock.get('provider')} via {best_unlock.get('telegram_command')}"
)
if result.get("secret_warnings"):
lines.append("Secret warning: plaintext token-like values found in Nomadds; rotate/remove them.")
if result.get("analysis"):
lines.append(result["analysis"])
return "\n".join(lines)
if mode == "nomad_quantum_tokens":
selected = result.get("selected_strategy") or {}
lines = [
"Nomad quantum tokens",
f"Objective: {result.get('objective', '')}",
f"Selected: {selected.get('title', selected.get('strategy_id', 'none'))}",
f"Tokens: {len(result.get('tokens') or [])}",
result.get("claim_boundary", ""),
]
backend = result.get("selected_backend") or (result.get("backend_plan") or {}).get("selected_backend") or {}
if backend:
lines.append(
f"Backend: {backend.get('provider', backend.get('backend_id', 'unknown'))} "
f"[{backend.get('status', 'unknown')}]"
)
local_simulation = result.get("local_quantum_simulation") or (result.get("backend_plan") or {}).get("local_simulation") or {}
if local_simulation.get("counts"):
lines.append(f"Local simulation counts: {local_simulation['counts']}")
hpc = result.get("proposal_backed_hpc") or []
if hpc:
first_hpc = hpc[0]
lines.append(
f"HPC path: {first_hpc.get('provider')} [{first_hpc.get('status')}]"
)
for token in (result.get("tokens") or [])[:3]:
lines.append(f"- {token.get('qtoken_id')}: {token.get('title')} score={token.get('score')}")
best_unlock = result.get("best_next_quantum_unlock") or {}
if best_unlock:
lines.append(
f"Best quantum unlock: {best_unlock.get('provider')} via {best_unlock.get('telegram_command')}"
)
if result.get("human_unlocks"):
lines.append("Human unlock available for real quantum provider execution.")
if result.get("analysis"):
lines.append(result["analysis"])
return "\n".join(line for line in lines if line)
if mode == "codebuddy_scout":
status = result.get("status") or {}
runner = result.get("review_runner") or {}
lines = [
"Nomad CodeBuddy scout",
f"Role: {result.get('recommended_role', 'self_development_reviewer')}",
f"Enabled: {status.get('enabled', False)}",
f"Automation ready: {status.get('automation_ready', False)}",
f"CLI available: {status.get('cli_available', False)}",
f"Route: {status.get('route', 'unknown')}",
f"Runner: {runner.get('command', '')}",
status.get("next_action", ""),
]
if result.get("analysis"):
lines.append(result["analysis"])
return "\n".join(line for line in lines if line)
if mode == "codebuddy_review":
data_release = result.get("data_release") or {}
lines = [
"Nomad CodeBuddy review",
f"OK: {result.get('ok', False)}",
f"Issue: {result.get('issue') or 'none'}",
f"Data release approved: {data_release.get('approved', False)}",
f"Diff chars: {data_release.get('diff_char_count', 0)}",
result.get("message", ""),
]
if result.get("review"):
lines.append("Review")
lines.append(str(result["review"]))
elif data_release.get("files"):
lines.append(f"Files: {', '.join(data_release['files'][:8])}")
if result.get("analysis"):
lines.append(result["analysis"])
return "\n".join(line for line in lines if line)
if mode == "render_scout":
status = result.get("status") or {}
verification = status.get("verification") or {}
selected = result.get("selected_service") or {}
lines = [
"Nomad Render scout",
f"API key configured: {status.get('api_key_configured', False)}",
f"Deploy enabled: {status.get('deploy_enabled', False)}",
f"Desired domain: {status.get('desired_domain', '')}",
f"Verification OK: {verification.get('ok', False)}",
f"Service count: {verification.get('service_count', 0)}",
f"Selected service: {selected.get('name') or selected.get('id') or 'none'}",
status.get("next_action", ""),
]
if result.get("analysis"):
lines.append(result["analysis"])
return "\n".join(line for line in lines if line)
if mode == "modal_scout":
status = result.get("status") or {}
deployment = result.get("deployment") or {}
lines = [
"Nomad Modal scout",
f"Configured: {status.get('configured', False)}",
f"Reachable: {status.get('reachable', False)}",
f"App name: {deployment.get('app_name', '')}",
f"Secret name: {deployment.get('secret_name', '')}",
f"GitHub branch: {deployment.get('github_branch', '')}",
f"Render public URL: {deployment.get('public_api_url', '')}",
]
deploy_commands = deployment.get("deploy_commands") or []
if deploy_commands:
lines.append(f"Next step: {deploy_commands[0]}")
if result.get("analysis"):
lines.append(result["analysis"])
return "\n".join(line for line in lines if line)
if mode == "agent_collaboration":
charter = result.get("charter") or {}
permission = charter.get("permission") or {}
lines = [
"Nomad agent collaboration",
f"Enabled: {charter.get('enabled', False)}",
f"Public home: {charter.get('public_home', '')}",
f"Ask help: {permission.get('ask_other_agents_for_help', False)}",
f"Accept help: {permission.get('accept_help_from_other_agents', False)}",
f"Learn from replies: {permission.get('learn_from_public_agent_replies', False)}",
]
if result.get("analysis"):
lines.append(result["analysis"])
return "\n".join(line for line in lines if line)
if mode in {"nomad_mutual_aid", "nomad_mutual_aid_status"}:
plan = result.get("evolution_plan") or result.get("latest_evolution_plan") or {}
lines = [
"Nomad Mutual-Aid",
f"Score: {result.get('mutual_aid_score', 0)}",
f"Truth density total: {result.get('truth_density_total', 0)}",
f"Modules: {result.get('module_count', 0)}",
f"Ledger entries: {result.get('truth_ledger_count', 0)}",
f"Paid packs: {result.get('paid_pack_count', 0)}",
]
if plan:
lines.append(
f"Latest plan: {plan.get('filename', '') or plan.get('module_id', '')} "
f"[{'applied' if plan.get('applied') else 'planned'}]"
)
if result.get("analysis"):
lines.append(result["analysis"])
return "\n".join(line for line in lines if line)
if mode == "nomad_truth_density_ledger":
stats = result.get("stats") or {}
return "\n".join(
[
"Nomad Truth-Density Ledger",
f"Entries: {result.get('entry_count', 0)}",
f"Average truth score: {stats.get('avg_truth_score', 0)}",
f"Average reuse value: {stats.get('avg_reuse_value', 0)}",
result.get("analysis", ""),
]
)
if mode == "nomad_swarm_inbox":
stats = result.get("stats") or {}
return "\n".join(
[
"Nomad Swarm Inbox",
f"Total: {stats.get('total', 0)}",
f"Verified pending review: {stats.get('verified_pending_review', 0)}",
f"Rejected: {stats.get('rejected', 0)}",
result.get("analysis", ""),
]
)
if mode == "nomad_swarm_development_signals":
return "\n".join(
[
"Nomad Swarm Development Signals",
f"Signals: {result.get('signal_count', 0)}",
result.get("analysis", ""),
]
)
if mode == "nomad_high_value_patterns":
return "\n".join(
[
"Nomad High-Value Patterns",
f"Patterns: {result.get('pattern_count', 0)}",
f"Minimum repeats: {result.get('min_repeat_count', 0)}",
result.get("analysis", ""),
]
)
if mode == "nomad_mutual_aid_module_compression":
return "\n".join(
[
"Nomad Mutual-Aid Module Compression",
f"Dry run: {result.get('dry_run', False)}",
f"Legacy groups: {result.get('legacy_group_count', 0)}",
f"Legacy modules: {result.get('legacy_module_count', 0)}",
f"Canonical created: {result.get('canonical_created_count', 0)}",
f"Active modules after: {result.get('active_module_count_after', 0)}",
result.get("analysis", ""),
]
)
if mode == "nomad_agent_engagements":
stats = result.get("stats") or {}
roles = stats.get("roles") or {}
return "\n".join(
[
"Nomad Agent Engagements",
f"Entries: {result.get('entry_count', 0)}",
f"Roles: {', '.join(f'{key}={value}' for key, value in sorted(roles.items())) or 'none'}",
result.get("analysis", ""),
]
)
if mode == "nomad_agent_engagement_summary":
roles = result.get("roles") or {}
outcomes = result.get("outcomes") or {}
return "\n".join(
[
"Nomad Agent Engagement Summary",
f"Entries: {result.get('entry_count', 0)}",
f"Roles: {', '.join(f'{key}={value}' for key, value in sorted(roles.items())) or 'none'}",
f"Outcomes: {', '.join(f'{key}={value}' for key, value in sorted(outcomes.items())) or 'none'}",
result.get("analysis", ""),
]
)
if mode == "nomad_agent_attractor":
top_offer = result.get("top_offer") or {}
return "\n".join(
[
"Nomad Agent Attractor",
f"Focus: {result.get('focus_service_type', 'custom')}",
f"Roles sought: {', '.join(result.get('target_roles') or []) or 'none'}",
f"Top offer: {top_offer.get('headline', '') or 'none'}",
f"Attractor: {(result.get('entrypoints') or {}).get('agent_attractor', '')}",
result.get("analysis", ""),
]
)
if mode == "nomad_swarm_attractor":
blockers = result.get("current_blockers") or {}
mix = result.get("worker_mix") or []
first = mix[0] if mix else {}
budget = result.get("replication_budget") or {}
return "\n".join(
[
"Nomad Swarm Attractor",
f"Metabolism pressure: {result.get('metabolism_pressure', 0)}",
f"Release: {blockers.get('release_tier', '')} capacity={blockers.get('release_capacity', 0)}",
f"Carrying: {blockers.get('tier', '')} score={blockers.get('carrying_score', 0)}",
f"Top deficit: {first.get('objective', 'none')} ({first.get('deficit', 0)})",
f"Wanted workers: {budget.get('wanted_new_workers_now', 0)}",
(result.get("agent_recruitment_packet") or {}).get("run_loop_command", ""),
]
)
if mode == "nomad_swarm_network":
active_lead = result.get("active_lead") or {}
approval = result.get("approval_state") or {}
return "\n".join(
[
"Nomad Swarm Network",
f"Lead: {active_lead.get('title') or active_lead.get('url') or 'none'}",
f"Focus: {result.get('focus_service_type', '')}",
f"Roles: {', '.join(result.get('target_roles') or []) or 'none'}",
f"Public reply allowed: {approval.get('public_reply_allowed_now', False)}",
f"Next: {result.get('next_best_action', '')}",
]
)
if mode == "nomad_swarm_coordination":
return "\n".join(
[
"Nomad Swarm Coordination",
f"Focus: {result.get('focus_pain_type', '')}",
f"Connected agents: {result.get('connected_agents', 0)}",
f"Next: {result.get('next_best_action', '')}",
f"Help lanes: {len(result.get('help_lanes') or [])}",
]
)
if mode == "nomad_swarm_accumulation":
return "\n".join(
[
"Nomad Swarm Accumulation",
f"Known agents: {result.get('known_agents', 0)}",
f"Joined agents: {result.get('joined_agents', 0)}",
f"Prospects: {result.get('prospect_agents', 0)}",
f"Next: {result.get('next_best_action', '')}",
]
)
if mode == "nomad_mutual_aid_packs":
return "\n".join(
[
"Nomad Mutual-Aid Paid Packs",
f"Packs: {result.get('pack_count', 0)}",
result.get("analysis", ""),
]
)
if mode == "codex_task":
return str(result.get("text") or result.get("analysis") or "")
if mode == "nomad_operator_desk":
lines = ["Nomad operator desk (human unlocks)"]
primary = result.get("primary_action") or {}
if primary:
lines.append(f"PRIMARY: {primary.get('title', '')} [{primary.get('source', '')}]")
block = primary.get("copy_paste_block") or ""
if block:
lines.append(block)
else:
lines.append("No unlock items queued.")
hint = result.get("copy_cli_hint") or ""
if hint:
lines.append(hint)
jo = (result.get("journal_excerpt") or {}).get("next_objective") or ""
if jo:
lines.append(f"Journal next objective: {jo}")
return "\n".join(line for line in lines if line)
if mode == "nomad_operator_verify":
lines = [
"Nomad operator verify bundle",
f"base_url: {result.get('base_url', '')}",
f"all_ok: {result.get('all_ok')}",
]
for row in result.get("checks") or []:
status = "OK" if row.get("ok") else "FAIL"
code = row.get("status_code", "")
err = row.get("error") or ""
lines.append(f" {row.get('name')}: {status} {code} {err}".strip())
return "\n".join(lines)
if mode == "nomad_operator_metrics":
return "\n".join(
[
"Nomad operator metrics",
f"verify_ok_streak: {result.get('verify_ok_streak', 0)}",
f"last_verify_all_ok: {result.get('last_verify_all_ok')}",
f"self_dev_cycles: {result.get('self_development_cycle_count', 0)}",
f"verify_pass_rate_last_n: {result.get('verify_pass_rate_last_n')}",
f"cycles_logged_in_tail: {result.get('self_improvement_events_in_tail', 0)}",
]
)
if mode == "nomad_operator_daily":
v = result.get("verify") or {}
lines = [
"Nomad operator daily bundle",
f"verify all_ok: {v.get('all_ok')}",
f"base_url: {v.get('base_url', '')}",
]
for row in v.get("checks") or []:
mark = "OK" if row.get("ok") else "FAIL"
lines.append(f" {row.get('name')}: {mark}")
ni = result.get("next_iteration") or {}
for hint in ni.get("hints") or []:
lines.append(f"Next: {hint}")
return "\n".join(lines)
if mode == "nomad_operator_sprint":
lines = [
"Nomad operator sprint (next actions)",
f"public_base_url: {result.get('public_base_url', '')}",
f"compute_lane_count: {result.get('compute_lane_count', 0)}",
]
for risk in result.get("insomnia_risks") or []:
lines.append(f"risk[{risk.get('severity', 'n/a')}]: {risk.get('risk', '')}")
for row in result.get("actions") or []:
lines.append(
f" [{row.get('kind', '')} p={row.get('priority', '')}] "
f"{row.get('title', '')}: {row.get('cli', '')}".strip()
)
return "\n".join(line for line in lines if line)
if mode == "nomad_operator_growth_start":
lines = [
"Nomad growth-start (daily + first leads)",
f"overall_ok: {result.get('ok')}",
f"verify all_ok: {(result.get('daily') or {}).get('verify', {}).get('all_ok')}",
f"lead_query: {result.get('lead_query', '')}",
]
lc = (result.get("leads") or {}) if isinstance(result.get("leads"), dict) else {}
if lc:
lines.append(f"leads mode: {lc.get('mode', '')} addressable: {lc.get('addressable_count', '')}")
sw = result.get("swarm_accumulation") or {}
if sw and not sw.get("skipped"):
lines.append(
f"swarm: +{len(sw.get('new_prospect_ids') or [])} prospects "
f"(queue {sw.get('prospect_agents', '')})"
)
for step in result.get("next_steps") or []:
lines.append(f" -> {step}")
return "\n".join(lines)
if mode == "nomad_operator_autonomy_step":
lines = [
"Nomad autonomy-step (growth + lead scout + swarm feed + focused /cycle)",
f"overall_ok: {result.get('ok')}",
f"lead_query: {result.get('lead_query', '')}",
]
for row in result.get("steps") or []:
mark = "OK" if row.get("ok") else "FAIL"
extra = ""
if row.get("step") == "swarm_accumulation" and row.get("new_prospects") is not None:
extra = f" (+{row.get('new_prospects')} prospects)"
lines.append(f" {row.get('step', '')}: {mark}{extra}")
cyc = result.get("cycle") or {}
if isinstance(cyc, dict) and cyc.get("self_development"):
sd = cyc["self_development"]
if sd.get("next_objective"):
lines.append(f"Next objective: {sd.get('next_objective')}")
for hint in result.get("next_steps") or []:
lines.append(f" -> {hint}")
return "\n".join(lines)
if mode == "nomad_operator_iteration_report":
tr = result.get("trends") or {}
lines = [
"Nomad operator iteration report",
f"verify pass rate (last 10): {tr.get('verify_pass_rate_last_10')}",
f"verify pass rate (last 30): {tr.get('verify_pass_rate_last_30')}",
f"self-improvement cycles logged: {tr.get('self_improvement_cycles_logged', 0)}",
f"daily bundles logged: {tr.get('operator_daily_runs', 0)}",
]
for rec in result.get("recommendations") or []:
lines.append(f"Recommend: {rec}")
return "\n".join(lines)
if mode == "nomad_agent_reputation":
totals = result.get("totals") or {}
signals = result.get("signals") or {}
return "\n".join(
[
"Nomad agent reputation",
f"tasks: {totals.get('tasks', 0)}",
f"awaiting_payment: {totals.get('awaiting_payment', 0)}",
f"paid: {totals.get('paid', 0)}",
f"delivered: {totals.get('delivered', 0)}",
f"boundary_reliability: {signals.get('boundary_reliability', 0)}",
]
)
if mode == "nomad_unhuman_hub":
profile = result.get("unhuman_profile") or {}
lines = [