agent-devkit 0.2.0 → 0.3.1

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 (177) hide show
  1. package/README.md +66 -13
  2. package/bin/agent.mjs +133 -7
  3. package/package.json +1 -1
  4. package/runtime/README.md +205 -13
  5. package/runtime/agent +31 -5
  6. package/runtime/agents/README.md +18 -0
  7. package/runtime/agents/contribution-reviewer/AGENTS.md +8 -0
  8. package/runtime/agents/contribution-reviewer/README.md +8 -0
  9. package/runtime/agents/contribution-reviewer/agent.yaml +40 -0
  10. package/runtime/agents/contribution-reviewer/capabilities/plan-contribution-pr/capability.yaml +27 -0
  11. package/runtime/agents/contribution-reviewer/capabilities/plan-contribution-pr/decision-rules.md +5 -0
  12. package/runtime/agents/contribution-reviewer/capabilities/plan-contribution-pr/workflow.md +6 -0
  13. package/runtime/agents/contribution-reviewer/capabilities/review-contribution/capability.yaml +25 -0
  14. package/runtime/agents/contribution-reviewer/capabilities/review-contribution/decision-rules.md +5 -0
  15. package/runtime/agents/contribution-reviewer/capabilities/review-contribution/workflow.md +5 -0
  16. package/runtime/agents/contribution-reviewer/capabilities/validate-local-contribution/capability.yaml +26 -0
  17. package/runtime/agents/contribution-reviewer/capabilities/validate-local-contribution/decision-rules.md +5 -0
  18. package/runtime/agents/contribution-reviewer/capabilities/validate-local-contribution/workflow.md +6 -0
  19. package/runtime/agents/contribution-reviewer/infra/README.md +6 -0
  20. package/runtime/agents/contribution-reviewer/knowledge/context.md +8 -0
  21. package/runtime/agents/contribution-reviewer/knowledge/system.md +8 -0
  22. package/runtime/agents/contribution-reviewer/templates/README.md +3 -0
  23. package/runtime/agents/knowledge-author/AGENTS.md +7 -0
  24. package/runtime/agents/knowledge-author/README.md +7 -0
  25. package/runtime/agents/knowledge-author/agent.yaml +37 -0
  26. package/runtime/agents/knowledge-author/capabilities/create-knowledge-snapshot/capability.yaml +30 -0
  27. package/runtime/agents/knowledge-author/capabilities/create-knowledge-snapshot/decision-rules.md +6 -0
  28. package/runtime/agents/knowledge-author/capabilities/create-knowledge-snapshot/workflow.md +7 -0
  29. package/runtime/agents/knowledge-author/infra/.gitkeep +1 -0
  30. package/runtime/agents/knowledge-author/knowledge/context.md +4 -0
  31. package/runtime/agents/knowledge-author/knowledge/system.md +4 -0
  32. package/runtime/agents/knowledge-author/templates/.gitkeep +1 -0
  33. package/runtime/agents/knowledge-curator/AGENTS.md +7 -0
  34. package/runtime/agents/knowledge-curator/README.md +6 -0
  35. package/runtime/agents/knowledge-curator/agent.yaml +37 -0
  36. package/runtime/agents/knowledge-curator/capabilities/curate-knowledge-base/capability.yaml +29 -0
  37. package/runtime/agents/knowledge-curator/capabilities/curate-knowledge-base/decision-rules.md +6 -0
  38. package/runtime/agents/knowledge-curator/capabilities/curate-knowledge-base/workflow.md +7 -0
  39. package/runtime/agents/knowledge-curator/infra/.gitkeep +1 -0
  40. package/runtime/agents/knowledge-curator/knowledge/context.md +4 -0
  41. package/runtime/agents/knowledge-curator/knowledge/system.md +4 -0
  42. package/runtime/agents/knowledge-curator/templates/.gitkeep +1 -0
  43. package/runtime/agents/knowledge-infra-builder/AGENTS.md +8 -0
  44. package/runtime/agents/knowledge-infra-builder/README.md +8 -0
  45. package/runtime/agents/knowledge-infra-builder/agent.yaml +38 -0
  46. package/runtime/agents/knowledge-infra-builder/capabilities/create-knowledge-base/capability.yaml +30 -0
  47. package/runtime/agents/knowledge-infra-builder/capabilities/create-knowledge-base/decision-rules.md +6 -0
  48. package/runtime/agents/knowledge-infra-builder/capabilities/create-knowledge-base/workflow.md +7 -0
  49. package/runtime/agents/knowledge-infra-builder/infra/.gitkeep +1 -0
  50. package/runtime/agents/knowledge-infra-builder/knowledge/context.md +4 -0
  51. package/runtime/agents/knowledge-infra-builder/knowledge/system.md +4 -0
  52. package/runtime/agents/knowledge-infra-builder/templates/.gitkeep +1 -0
  53. package/runtime/agents/knowledge-owner/AGENTS.md +7 -0
  54. package/runtime/agents/knowledge-owner/README.md +6 -0
  55. package/runtime/agents/knowledge-owner/agent.yaml +37 -0
  56. package/runtime/agents/knowledge-owner/capabilities/publish-knowledge-snapshot/capability.yaml +28 -0
  57. package/runtime/agents/knowledge-owner/capabilities/publish-knowledge-snapshot/decision-rules.md +6 -0
  58. package/runtime/agents/knowledge-owner/capabilities/publish-knowledge-snapshot/workflow.md +7 -0
  59. package/runtime/agents/knowledge-owner/infra/.gitkeep +1 -0
  60. package/runtime/agents/knowledge-owner/knowledge/context.md +4 -0
  61. package/runtime/agents/knowledge-owner/knowledge/system.md +4 -0
  62. package/runtime/agents/knowledge-owner/templates/.gitkeep +1 -0
  63. package/runtime/agents/knowledge-reviewer/AGENTS.md +7 -0
  64. package/runtime/agents/knowledge-reviewer/README.md +7 -0
  65. package/runtime/agents/knowledge-reviewer/agent.yaml +36 -0
  66. package/runtime/agents/knowledge-reviewer/capabilities/review-knowledge-snapshot/capability.yaml +26 -0
  67. package/runtime/agents/knowledge-reviewer/capabilities/review-knowledge-snapshot/decision-rules.md +6 -0
  68. package/runtime/agents/knowledge-reviewer/capabilities/review-knowledge-snapshot/workflow.md +7 -0
  69. package/runtime/agents/knowledge-reviewer/infra/.gitkeep +1 -0
  70. package/runtime/agents/knowledge-reviewer/knowledge/context.md +4 -0
  71. package/runtime/agents/knowledge-reviewer/knowledge/system.md +4 -0
  72. package/runtime/agents/knowledge-reviewer/templates/.gitkeep +1 -0
  73. package/runtime/agents/local-memory-manager/AGENTS.md +5 -0
  74. package/runtime/agents/local-memory-manager/README.md +7 -0
  75. package/runtime/agents/local-memory-manager/agent.yaml +38 -0
  76. package/runtime/agents/local-memory-manager/capabilities/curate-local-memory/capability.yaml +19 -0
  77. package/runtime/agents/local-memory-manager/capabilities/curate-local-memory/decision-rules.md +5 -0
  78. package/runtime/agents/local-memory-manager/capabilities/curate-local-memory/workflow.md +6 -0
  79. package/runtime/agents/local-memory-manager/capabilities/inspect-local-memory/capability.yaml +19 -0
  80. package/runtime/agents/local-memory-manager/capabilities/inspect-local-memory/decision-rules.md +5 -0
  81. package/runtime/agents/local-memory-manager/capabilities/inspect-local-memory/workflow.md +5 -0
  82. package/runtime/agents/local-memory-manager/infra/.gitkeep +1 -0
  83. package/runtime/agents/local-memory-manager/knowledge/context.md +4 -0
  84. package/runtime/agents/local-memory-manager/knowledge/system.md +4 -0
  85. package/runtime/agents/local-memory-manager/templates/.gitkeep +1 -0
  86. package/runtime/agents/memory-sync-manager/AGENTS.md +7 -0
  87. package/runtime/agents/memory-sync-manager/README.md +7 -0
  88. package/runtime/agents/memory-sync-manager/agent.yaml +37 -0
  89. package/runtime/agents/memory-sync-manager/capabilities/plan-memory-backup/capability.yaml +29 -0
  90. package/runtime/agents/memory-sync-manager/capabilities/plan-memory-backup/decision-rules.md +6 -0
  91. package/runtime/agents/memory-sync-manager/capabilities/plan-memory-backup/workflow.md +7 -0
  92. package/runtime/agents/memory-sync-manager/infra/.gitkeep +1 -0
  93. package/runtime/agents/memory-sync-manager/knowledge/context.md +4 -0
  94. package/runtime/agents/memory-sync-manager/knowledge/system.md +4 -0
  95. package/runtime/agents/memory-sync-manager/templates/.gitkeep +1 -0
  96. package/runtime/agents/shared-memory-curator/AGENTS.md +5 -0
  97. package/runtime/agents/shared-memory-curator/README.md +6 -0
  98. package/runtime/agents/shared-memory-curator/agent.yaml +38 -0
  99. package/runtime/agents/shared-memory-curator/capabilities/create-shared-memory/capability.yaml +19 -0
  100. package/runtime/agents/shared-memory-curator/capabilities/create-shared-memory/decision-rules.md +5 -0
  101. package/runtime/agents/shared-memory-curator/capabilities/create-shared-memory/workflow.md +5 -0
  102. package/runtime/agents/shared-memory-curator/capabilities/publish-shared-submission/capability.yaml +19 -0
  103. package/runtime/agents/shared-memory-curator/capabilities/publish-shared-submission/decision-rules.md +5 -0
  104. package/runtime/agents/shared-memory-curator/capabilities/publish-shared-submission/workflow.md +5 -0
  105. package/runtime/agents/shared-memory-curator/capabilities/review-shared-submission/capability.yaml +19 -0
  106. package/runtime/agents/shared-memory-curator/capabilities/review-shared-submission/decision-rules.md +5 -0
  107. package/runtime/agents/shared-memory-curator/capabilities/review-shared-submission/workflow.md +5 -0
  108. package/runtime/agents/shared-memory-curator/infra/.gitkeep +1 -0
  109. package/runtime/agents/shared-memory-curator/knowledge/context.md +5 -0
  110. package/runtime/agents/shared-memory-curator/knowledge/system.md +4 -0
  111. package/runtime/agents/shared-memory-curator/templates/.gitkeep +1 -0
  112. package/runtime/cli/README.md +47 -8
  113. package/runtime/cli/aikit/__init__.py +1 -1
  114. package/runtime/cli/aikit/agent_registry.py +4 -2
  115. package/runtime/cli/aikit/agentic_commands.py +158 -0
  116. package/runtime/cli/aikit/app_home.py +2 -0
  117. package/runtime/cli/aikit/audit.py +16 -6
  118. package/runtime/cli/aikit/catalog.py +278 -8
  119. package/runtime/cli/aikit/cli_dispatch.py +489 -13
  120. package/runtime/cli/aikit/cli_parser.py +146 -8
  121. package/runtime/cli/aikit/contribution.py +132 -2
  122. package/runtime/cli/aikit/doctor_runtime.py +85 -0
  123. package/runtime/cli/aikit/embedded_mini_brain.py +351 -0
  124. package/runtime/cli/aikit/eval.py +356 -10
  125. package/runtime/cli/aikit/human_output.py +310 -4
  126. package/runtime/cli/aikit/interactive_wizard.py +146 -0
  127. package/runtime/cli/aikit/knowledge_base.py +1067 -0
  128. package/runtime/cli/aikit/llm.py +40 -6
  129. package/runtime/cli/aikit/local_artifacts.py +444 -0
  130. package/runtime/cli/aikit/local_llm.py +176 -0
  131. package/runtime/cli/aikit/local_llm_operator.py +15 -5
  132. package/runtime/cli/aikit/main.py +15 -0
  133. package/runtime/cli/aikit/mcp_manifest.py +798 -0
  134. package/runtime/cli/aikit/mcp_tools.py +643 -5
  135. package/runtime/cli/aikit/memory.py +405 -0
  136. package/runtime/cli/aikit/mini_brain.py +56 -25
  137. package/runtime/cli/aikit/model_router.py +42 -9
  138. package/runtime/cli/aikit/natural_prompt_runtime.py +194 -2
  139. package/runtime/cli/aikit/ollama.py +64 -15
  140. package/runtime/cli/aikit/onboarding.py +551 -0
  141. package/runtime/cli/aikit/output.py +67 -0
  142. package/runtime/cli/aikit/prompt_injection.py +12 -1
  143. package/runtime/cli/aikit/review_gate.py +14 -2
  144. package/runtime/cli/aikit/roadmap_cli.py +1 -1
  145. package/runtime/cli/aikit/secrets.py +3 -2
  146. package/runtime/cli/aikit/setup_wizard_payload.py +3 -0
  147. package/runtime/cli/aikit/shared_memory.py +415 -0
  148. package/runtime/cli/aikit/specialist_readiness.py +152 -0
  149. package/runtime/cli/aikit/tasks.py +104 -1
  150. package/runtime/cli/aikit/team.py +380 -0
  151. package/runtime/cli/aikit/toolchain.py +7 -2
  152. package/runtime/cli/aikit/workflows.py +115 -14
  153. package/runtime/models/qwen2.5-0.5b-instruct/manifest.json +30 -0
  154. package/runtime/providers/knowledge-github.yaml +40 -0
  155. package/runtime/providers/knowledge-google-drive.yaml +32 -0
  156. package/runtime/providers/knowledge-local.yaml +26 -0
  157. package/runtime/providers/knowledge-notion.yaml +32 -0
  158. package/runtime/providers/knowledge-obsidian.yaml +24 -0
  159. package/runtime/providers/knowledge-onedrive.yaml +36 -0
  160. package/runtime/providers/knowledge-s3.yaml +45 -0
  161. package/runtime/providers/knowledge-sharepoint.yaml +39 -0
  162. package/runtime/providers/knowledge-supabase.yaml +43 -0
  163. package/runtime/providers/knowledge-vector.yaml +39 -0
  164. package/runtime/requirements.txt +6 -0
  165. package/runtime/scripts/docker-cli-qa.sh +453 -0
  166. package/runtime/scripts/release-catalog-snapshot.json +55 -4
  167. package/runtime/scripts/release-gate.py +54 -13
  168. package/runtime/tooling/toolchain.yaml +92 -0
  169. package/runtime/vendor/skills/napkin/napkin.md +21 -7
  170. package/runtime/workflows/azure-card-analysis/README.md +3 -0
  171. package/runtime/workflows/azure-card-analysis/workflow.yaml +30 -0
  172. package/runtime/workflows/daily-pr-review/README.md +3 -0
  173. package/runtime/workflows/daily-pr-review/workflow.yaml +31 -0
  174. package/runtime/workflows/incident-analysis/README.md +3 -0
  175. package/runtime/workflows/incident-analysis/workflow.yaml +33 -0
  176. package/runtime/workflows/release-prep/README.md +3 -0
  177. package/runtime/workflows/release-prep/workflow.yaml +30 -0
@@ -0,0 +1,176 @@
1
+ """Canonical local-LLM CLI surface over Ollama and mini-brain policy."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import shutil
6
+ import subprocess
7
+ from typing import Any
8
+
9
+ from cli.aikit.embedded_mini_brain import EMBEDDED_BACKEND_ID, EMBEDDED_MODEL_ID, embedded_mini_brain_status
10
+ from cli.aikit.mini_brain import DEFAULT_OLLAMA_MODEL, mini_brain_contract
11
+ from cli.aikit.model_router import build_model_plan
12
+ from cli.aikit.ollama import ollama_models, ollama_pull, ollama_status
13
+
14
+
15
+ LOCAL_LLM_SCHEMA_VERSION = "agent-devkit.local-llm/v1"
16
+ LOCAL_WORKERS = (
17
+ ("local-classifier", "intent classification and routing hints"),
18
+ ("local-summarizer", "short summaries and extraction"),
19
+ ("local-coder", "mechanical code drafts with coordinator review"),
20
+ ("local-log-analyzer", "log clustering and evidence extraction"),
21
+ ("local-sql-helper", "SQL draft assistance with review required"),
22
+ )
23
+
24
+
25
+ def local_llm_list() -> dict[str, Any]:
26
+ status = ollama_status()
27
+ contract = mini_brain_contract(ollama_payload=status)
28
+ return {
29
+ "kind": "local-llm",
30
+ "schema_version": LOCAL_LLM_SCHEMA_VERSION,
31
+ "status": "ok",
32
+ "provider": EMBEDDED_BACKEND_ID,
33
+ "optional_providers": ["ollama"],
34
+ "embedded": embedded_mini_brain_status(),
35
+ "mini_brain": contract,
36
+ "workers": [{"id": worker_id, "purpose": purpose} for worker_id, purpose in LOCAL_WORKERS],
37
+ "models": {
38
+ "status": status.get("status"),
39
+ "count": status.get("model_count", 0),
40
+ },
41
+ }
42
+
43
+
44
+ def local_llm_doctor() -> dict[str, Any]:
45
+ status = ollama_status()
46
+ contract = mini_brain_contract(ollama_payload=status)
47
+ model_plan = build_model_plan("resuma estes logs operacionais")
48
+ ok = contract.get("available") is True
49
+ return {
50
+ "kind": "local-llm-doctor",
51
+ "schema_version": LOCAL_LLM_SCHEMA_VERSION,
52
+ "status": "ok" if ok else "partial",
53
+ "provider": EMBEDDED_BACKEND_ID,
54
+ "optional_providers": ["ollama"],
55
+ "embedded": embedded_mini_brain_status(),
56
+ "ollama": status,
57
+ "mini_brain": contract,
58
+ "model_plan": {
59
+ "strategy": model_plan.get("strategy"),
60
+ "local_llm_recommended": model_plan.get("local_llm_recommended"),
61
+ "local_llm_selected": model_plan.get("local_llm_selected"),
62
+ "local_llm_role": model_plan.get("local_llm_role"),
63
+ "forbidden_actions": model_plan.get("forbidden_actions") or [],
64
+ },
65
+ "next_steps": local_llm_next_steps(status=status, mini_brain=contract),
66
+ }
67
+
68
+
69
+ def local_llm_models() -> dict[str, Any]:
70
+ payload = ollama_models()
71
+ embedded = embedded_mini_brain_status()
72
+ payload["kind"] = "local-llm-models"
73
+ payload["schema_version"] = LOCAL_LLM_SCHEMA_VERSION
74
+ payload["provider"] = EMBEDDED_BACKEND_ID
75
+ payload["embedded"] = {
76
+ "status": embedded.get("status"),
77
+ "provider": EMBEDDED_BACKEND_ID,
78
+ "model": EMBEDDED_MODEL_ID,
79
+ "installed": embedded.get("model_file_valid") is True,
80
+ "available": embedded.get("available") is True,
81
+ "install_command": embedded.get("install_command"),
82
+ }
83
+ payload["optional_provider"] = "ollama"
84
+ return payload
85
+
86
+
87
+ def local_llm_install(model: str | None, *, dry_run: bool = False, yes: bool = False) -> dict[str, Any]:
88
+ model = model or DEFAULT_OLLAMA_MODEL
89
+ payload = ollama_pull(model, dry_run=dry_run, yes=yes)
90
+ payload["kind"] = "local-llm-install"
91
+ payload["schema_version"] = LOCAL_LLM_SCHEMA_VERSION
92
+ payload["provider"] = "ollama"
93
+ return payload
94
+
95
+
96
+ def local_llm_remove(model: str | None, *, dry_run: bool = False, yes: bool = False) -> dict[str, Any]:
97
+ model = model or DEFAULT_OLLAMA_MODEL
98
+ command = ["ollama", "rm", model]
99
+ binary = shutil.which("ollama")
100
+ if dry_run or not yes:
101
+ needs_confirmation = not dry_run and not yes
102
+ return {
103
+ "kind": "local-llm-remove",
104
+ "schema_version": LOCAL_LLM_SCHEMA_VERSION,
105
+ "status": "planned" if dry_run else "needs-confirmation",
106
+ "ok": bool(dry_run),
107
+ "exit_code": 2 if needs_confirmation else 0,
108
+ "provider": "ollama",
109
+ "model": model,
110
+ "binary": binary,
111
+ "command": command,
112
+ "dry_run": dry_run,
113
+ "yes": yes,
114
+ "message": "Use --yes to remove the local model." if not dry_run and not yes else "Dry-run only.",
115
+ }
116
+ if not binary:
117
+ return {
118
+ "kind": "local-llm-remove",
119
+ "schema_version": LOCAL_LLM_SCHEMA_VERSION,
120
+ "status": "missing",
121
+ "ok": False,
122
+ "provider": "ollama",
123
+ "model": model,
124
+ "command": command,
125
+ "message": "Ollama binary not found in PATH.",
126
+ "exit_code": 2,
127
+ }
128
+ process = subprocess.run(command, check=False, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=120)
129
+ return {
130
+ "kind": "local-llm-remove",
131
+ "schema_version": LOCAL_LLM_SCHEMA_VERSION,
132
+ "status": "ok" if process.returncode == 0 else "failed",
133
+ "ok": process.returncode == 0,
134
+ "provider": "ollama",
135
+ "model": model,
136
+ "binary": binary,
137
+ "command": command,
138
+ "exit_code": process.returncode,
139
+ "stdout": process.stdout[-4000:],
140
+ "stderr": process.stderr[-4000:],
141
+ }
142
+
143
+
144
+ def local_llm_benchmark(model: str | None = None) -> dict[str, Any]:
145
+ model = model or DEFAULT_OLLAMA_MODEL
146
+ status = ollama_status()
147
+ installed = {item.get("name") for item in status.get("models") or [] if isinstance(item, dict)}
148
+ available = status.get("status") == "ok" and model in installed
149
+ return {
150
+ "kind": "local-llm-benchmark",
151
+ "schema_version": LOCAL_LLM_SCHEMA_VERSION,
152
+ "status": "ready" if available else "planned",
153
+ "ok": available,
154
+ "provider": "ollama",
155
+ "model": model,
156
+ "checks": [
157
+ {"id": "ollama-binary", "status": "passed" if status.get("status") == "ok" else "failed"},
158
+ {"id": "model-installed", "status": "passed" if model in installed else "planned"},
159
+ {"id": "policy", "status": "passed", "message": "Benchmark is read-only and does not approve final work."},
160
+ ],
161
+ "next_steps": [] if available else [f"agent local-llm install {model} --yes"],
162
+ }
163
+
164
+
165
+ def local_llm_next_steps(*, status: dict[str, Any], mini_brain: dict[str, Any]) -> list[str]:
166
+ steps: list[str] = []
167
+ if status.get("status") != "ok":
168
+ install_plan = status.get("install_plan") if isinstance(status.get("install_plan"), dict) else {}
169
+ command = install_plan.get("command")
170
+ if command:
171
+ steps.append(f"Install Ollama: {command}")
172
+ if not mini_brain.get("enabled"):
173
+ steps.append("agent setup mini-brain --yes")
174
+ if status.get("model_count", 0) < 1:
175
+ steps.append(f"agent local-llm install {DEFAULT_OLLAMA_MODEL} --yes")
176
+ return steps
@@ -24,7 +24,7 @@ FORBIDDEN_DELEGATION_MARKERS = (
24
24
 
25
25
 
26
26
  def maybe_delegate_local_llm(prompt: str, model_plan: dict[str, Any]) -> dict[str, Any]:
27
- """Execute a bounded operational task with Ollama when the model plan selected it."""
27
+ """Execute a bounded operational task with the selected local worker."""
28
28
  delegation = model_plan.get("delegation") if isinstance(model_plan.get("delegation"), dict) else {}
29
29
  if model_plan.get("strategy") != "mini-brain":
30
30
  return skipped(
@@ -38,6 +38,12 @@ def maybe_delegate_local_llm(prompt: str, model_plan: dict[str, Any]) -> dict[st
38
38
  "High-risk tasks cannot be delegated to local LLM workers.",
39
39
  model_plan=model_plan,
40
40
  )
41
+ if model_plan.get("local_llm_role") != "operational-worker":
42
+ return skipped(
43
+ "not-operational-worker",
44
+ "The embedded mini-brain is acting as the bootstrap coordinator, not as a delegated worker.",
45
+ model_plan=model_plan,
46
+ )
41
47
  if int(model_plan.get("max_llm_calls") or 0) <= 0:
42
48
  return skipped(
43
49
  "llm-budget-not-available",
@@ -50,9 +56,10 @@ def maybe_delegate_local_llm(prompt: str, model_plan: dict[str, Any]) -> dict[st
50
56
  if any(marker in lowered for marker in FORBIDDEN_DELEGATION_MARKERS):
51
57
  return skipped("forbidden", "Prompt contains an action that local LLM workers cannot execute.", model_plan=model_plan)
52
58
  delegated_prompt = build_delegated_prompt(prompt, model_plan)
59
+ provider = str(model_plan.get("local_llm_provider") or "ollama")
53
60
  result = invoke_agent_prompt(
54
61
  delegated_prompt,
55
- "ollama",
62
+ provider,
56
63
  public_name="Local LLM Operator",
57
64
  allow_fallback=False,
58
65
  )
@@ -64,7 +71,7 @@ def maybe_delegate_local_llm(prompt: str, model_plan: dict[str, Any]) -> dict[st
64
71
  "status": "ok" if result.get("ok") else result.get("status", "failed"),
65
72
  "ok": bool(result.get("ok")),
66
73
  "llm_backend": result.get("llm_backend"),
67
- "model_provider": "ollama",
74
+ "model_provider": provider,
68
75
  "mini_brain": summarize_mini_brain(model_plan.get("mini_brain")),
69
76
  "strategy": model_plan.get("strategy"),
70
77
  "risk": model_plan.get("risk"),
@@ -108,7 +115,7 @@ def enrich_prompt_with_local_result(prompt: str, local_execution: dict[str, Any]
108
115
  [
109
116
  prompt,
110
117
  "",
111
- "Contexto operacional produzido pelo local-llm-operator/Ollama:",
118
+ f"Contexto operacional produzido pelo local-llm-operator/{local_execution.get('model_provider') or local_execution.get('llm_backend') or 'local'}:",
112
119
  str(local_execution["response"]),
113
120
  "",
114
121
  "Use esse contexto apenas como apoio. A decisao, resposta final e revisao continuam sob responsabilidade do coordenador.",
@@ -131,7 +138,10 @@ def skipped(reason: str, message: str, *, model_plan: dict[str, Any]) -> dict[st
131
138
  "strategy": model_plan.get("strategy"),
132
139
  "risk": model_plan.get("risk"),
133
140
  "confidence": model_plan.get("confidence"),
134
- "requires_review": bool(model_plan.get("local_llm_recommended") or model_plan.get("local_llm_selected")),
141
+ "requires_review": bool(
142
+ model_plan.get("local_llm_role") == "operational-worker"
143
+ and (model_plan.get("local_llm_recommended") or model_plan.get("local_llm_selected"))
144
+ ),
135
145
  }
136
146
 
137
147
 
@@ -4,7 +4,9 @@
4
4
  from __future__ import annotations
5
5
 
6
6
  import json
7
+ import os
7
8
  import sys
9
+ import traceback
8
10
 
9
11
  from cli.aikit.cli_dispatch import dispatch, format_audit_warning, is_audit_warning, maybe_record_cli_audit
10
12
  from cli.aikit.cli_parser import DETERMINISTIC_COMMANDS, LLM_COMMANDS, build_parser
@@ -26,6 +28,19 @@ def main(argv: list[str] | None = None, *, prog: str | None = None) -> int:
26
28
  print(format_audit_warning(audit_result), file=sys.stderr)
27
29
  print(f"error: {exc}", file=sys.stderr)
28
30
  return 1
31
+ except Exception as exc: # noqa: BLE001 - CLI boundary must not leak tracebacks by default.
32
+ if os.environ.get("AI_DEVKIT_DEBUG") == "1":
33
+ traceback.print_exc(file=sys.stderr)
34
+ else:
35
+ print(
36
+ f"error: internal error: {type(exc).__name__}. "
37
+ "Run with AI_DEVKIT_DEBUG=1 for traceback.",
38
+ file=sys.stderr,
39
+ )
40
+ audit_result = maybe_record_cli_audit(args, result=None, error=f"{type(exc).__name__}: {exc}")
41
+ if is_audit_warning(audit_result):
42
+ print(format_audit_warning(audit_result), file=sys.stderr)
43
+ return 1
29
44
 
30
45
  if result is None:
31
46
  return 0