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.
- package/README.md +66 -13
- package/bin/agent.mjs +133 -7
- package/package.json +1 -1
- package/runtime/README.md +205 -13
- package/runtime/agent +31 -5
- package/runtime/agents/README.md +18 -0
- package/runtime/agents/contribution-reviewer/AGENTS.md +8 -0
- package/runtime/agents/contribution-reviewer/README.md +8 -0
- package/runtime/agents/contribution-reviewer/agent.yaml +40 -0
- package/runtime/agents/contribution-reviewer/capabilities/plan-contribution-pr/capability.yaml +27 -0
- package/runtime/agents/contribution-reviewer/capabilities/plan-contribution-pr/decision-rules.md +5 -0
- package/runtime/agents/contribution-reviewer/capabilities/plan-contribution-pr/workflow.md +6 -0
- package/runtime/agents/contribution-reviewer/capabilities/review-contribution/capability.yaml +25 -0
- package/runtime/agents/contribution-reviewer/capabilities/review-contribution/decision-rules.md +5 -0
- package/runtime/agents/contribution-reviewer/capabilities/review-contribution/workflow.md +5 -0
- package/runtime/agents/contribution-reviewer/capabilities/validate-local-contribution/capability.yaml +26 -0
- package/runtime/agents/contribution-reviewer/capabilities/validate-local-contribution/decision-rules.md +5 -0
- package/runtime/agents/contribution-reviewer/capabilities/validate-local-contribution/workflow.md +6 -0
- package/runtime/agents/contribution-reviewer/infra/README.md +6 -0
- package/runtime/agents/contribution-reviewer/knowledge/context.md +8 -0
- package/runtime/agents/contribution-reviewer/knowledge/system.md +8 -0
- package/runtime/agents/contribution-reviewer/templates/README.md +3 -0
- package/runtime/agents/knowledge-author/AGENTS.md +7 -0
- package/runtime/agents/knowledge-author/README.md +7 -0
- package/runtime/agents/knowledge-author/agent.yaml +37 -0
- package/runtime/agents/knowledge-author/capabilities/create-knowledge-snapshot/capability.yaml +30 -0
- package/runtime/agents/knowledge-author/capabilities/create-knowledge-snapshot/decision-rules.md +6 -0
- package/runtime/agents/knowledge-author/capabilities/create-knowledge-snapshot/workflow.md +7 -0
- package/runtime/agents/knowledge-author/infra/.gitkeep +1 -0
- package/runtime/agents/knowledge-author/knowledge/context.md +4 -0
- package/runtime/agents/knowledge-author/knowledge/system.md +4 -0
- package/runtime/agents/knowledge-author/templates/.gitkeep +1 -0
- package/runtime/agents/knowledge-curator/AGENTS.md +7 -0
- package/runtime/agents/knowledge-curator/README.md +6 -0
- package/runtime/agents/knowledge-curator/agent.yaml +37 -0
- package/runtime/agents/knowledge-curator/capabilities/curate-knowledge-base/capability.yaml +29 -0
- package/runtime/agents/knowledge-curator/capabilities/curate-knowledge-base/decision-rules.md +6 -0
- package/runtime/agents/knowledge-curator/capabilities/curate-knowledge-base/workflow.md +7 -0
- package/runtime/agents/knowledge-curator/infra/.gitkeep +1 -0
- package/runtime/agents/knowledge-curator/knowledge/context.md +4 -0
- package/runtime/agents/knowledge-curator/knowledge/system.md +4 -0
- package/runtime/agents/knowledge-curator/templates/.gitkeep +1 -0
- package/runtime/agents/knowledge-infra-builder/AGENTS.md +8 -0
- package/runtime/agents/knowledge-infra-builder/README.md +8 -0
- package/runtime/agents/knowledge-infra-builder/agent.yaml +38 -0
- package/runtime/agents/knowledge-infra-builder/capabilities/create-knowledge-base/capability.yaml +30 -0
- package/runtime/agents/knowledge-infra-builder/capabilities/create-knowledge-base/decision-rules.md +6 -0
- package/runtime/agents/knowledge-infra-builder/capabilities/create-knowledge-base/workflow.md +7 -0
- package/runtime/agents/knowledge-infra-builder/infra/.gitkeep +1 -0
- package/runtime/agents/knowledge-infra-builder/knowledge/context.md +4 -0
- package/runtime/agents/knowledge-infra-builder/knowledge/system.md +4 -0
- package/runtime/agents/knowledge-infra-builder/templates/.gitkeep +1 -0
- package/runtime/agents/knowledge-owner/AGENTS.md +7 -0
- package/runtime/agents/knowledge-owner/README.md +6 -0
- package/runtime/agents/knowledge-owner/agent.yaml +37 -0
- package/runtime/agents/knowledge-owner/capabilities/publish-knowledge-snapshot/capability.yaml +28 -0
- package/runtime/agents/knowledge-owner/capabilities/publish-knowledge-snapshot/decision-rules.md +6 -0
- package/runtime/agents/knowledge-owner/capabilities/publish-knowledge-snapshot/workflow.md +7 -0
- package/runtime/agents/knowledge-owner/infra/.gitkeep +1 -0
- package/runtime/agents/knowledge-owner/knowledge/context.md +4 -0
- package/runtime/agents/knowledge-owner/knowledge/system.md +4 -0
- package/runtime/agents/knowledge-owner/templates/.gitkeep +1 -0
- package/runtime/agents/knowledge-reviewer/AGENTS.md +7 -0
- package/runtime/agents/knowledge-reviewer/README.md +7 -0
- package/runtime/agents/knowledge-reviewer/agent.yaml +36 -0
- package/runtime/agents/knowledge-reviewer/capabilities/review-knowledge-snapshot/capability.yaml +26 -0
- package/runtime/agents/knowledge-reviewer/capabilities/review-knowledge-snapshot/decision-rules.md +6 -0
- package/runtime/agents/knowledge-reviewer/capabilities/review-knowledge-snapshot/workflow.md +7 -0
- package/runtime/agents/knowledge-reviewer/infra/.gitkeep +1 -0
- package/runtime/agents/knowledge-reviewer/knowledge/context.md +4 -0
- package/runtime/agents/knowledge-reviewer/knowledge/system.md +4 -0
- package/runtime/agents/knowledge-reviewer/templates/.gitkeep +1 -0
- package/runtime/agents/local-memory-manager/AGENTS.md +5 -0
- package/runtime/agents/local-memory-manager/README.md +7 -0
- package/runtime/agents/local-memory-manager/agent.yaml +38 -0
- package/runtime/agents/local-memory-manager/capabilities/curate-local-memory/capability.yaml +19 -0
- package/runtime/agents/local-memory-manager/capabilities/curate-local-memory/decision-rules.md +5 -0
- package/runtime/agents/local-memory-manager/capabilities/curate-local-memory/workflow.md +6 -0
- package/runtime/agents/local-memory-manager/capabilities/inspect-local-memory/capability.yaml +19 -0
- package/runtime/agents/local-memory-manager/capabilities/inspect-local-memory/decision-rules.md +5 -0
- package/runtime/agents/local-memory-manager/capabilities/inspect-local-memory/workflow.md +5 -0
- package/runtime/agents/local-memory-manager/infra/.gitkeep +1 -0
- package/runtime/agents/local-memory-manager/knowledge/context.md +4 -0
- package/runtime/agents/local-memory-manager/knowledge/system.md +4 -0
- package/runtime/agents/local-memory-manager/templates/.gitkeep +1 -0
- package/runtime/agents/memory-sync-manager/AGENTS.md +7 -0
- package/runtime/agents/memory-sync-manager/README.md +7 -0
- package/runtime/agents/memory-sync-manager/agent.yaml +37 -0
- package/runtime/agents/memory-sync-manager/capabilities/plan-memory-backup/capability.yaml +29 -0
- package/runtime/agents/memory-sync-manager/capabilities/plan-memory-backup/decision-rules.md +6 -0
- package/runtime/agents/memory-sync-manager/capabilities/plan-memory-backup/workflow.md +7 -0
- package/runtime/agents/memory-sync-manager/infra/.gitkeep +1 -0
- package/runtime/agents/memory-sync-manager/knowledge/context.md +4 -0
- package/runtime/agents/memory-sync-manager/knowledge/system.md +4 -0
- package/runtime/agents/memory-sync-manager/templates/.gitkeep +1 -0
- package/runtime/agents/shared-memory-curator/AGENTS.md +5 -0
- package/runtime/agents/shared-memory-curator/README.md +6 -0
- package/runtime/agents/shared-memory-curator/agent.yaml +38 -0
- package/runtime/agents/shared-memory-curator/capabilities/create-shared-memory/capability.yaml +19 -0
- package/runtime/agents/shared-memory-curator/capabilities/create-shared-memory/decision-rules.md +5 -0
- package/runtime/agents/shared-memory-curator/capabilities/create-shared-memory/workflow.md +5 -0
- package/runtime/agents/shared-memory-curator/capabilities/publish-shared-submission/capability.yaml +19 -0
- package/runtime/agents/shared-memory-curator/capabilities/publish-shared-submission/decision-rules.md +5 -0
- package/runtime/agents/shared-memory-curator/capabilities/publish-shared-submission/workflow.md +5 -0
- package/runtime/agents/shared-memory-curator/capabilities/review-shared-submission/capability.yaml +19 -0
- package/runtime/agents/shared-memory-curator/capabilities/review-shared-submission/decision-rules.md +5 -0
- package/runtime/agents/shared-memory-curator/capabilities/review-shared-submission/workflow.md +5 -0
- package/runtime/agents/shared-memory-curator/infra/.gitkeep +1 -0
- package/runtime/agents/shared-memory-curator/knowledge/context.md +5 -0
- package/runtime/agents/shared-memory-curator/knowledge/system.md +4 -0
- package/runtime/agents/shared-memory-curator/templates/.gitkeep +1 -0
- package/runtime/cli/README.md +47 -8
- package/runtime/cli/aikit/__init__.py +1 -1
- package/runtime/cli/aikit/agent_registry.py +4 -2
- package/runtime/cli/aikit/agentic_commands.py +158 -0
- package/runtime/cli/aikit/app_home.py +2 -0
- package/runtime/cli/aikit/audit.py +16 -6
- package/runtime/cli/aikit/catalog.py +278 -8
- package/runtime/cli/aikit/cli_dispatch.py +489 -13
- package/runtime/cli/aikit/cli_parser.py +146 -8
- package/runtime/cli/aikit/contribution.py +132 -2
- package/runtime/cli/aikit/doctor_runtime.py +85 -0
- package/runtime/cli/aikit/embedded_mini_brain.py +351 -0
- package/runtime/cli/aikit/eval.py +356 -10
- package/runtime/cli/aikit/human_output.py +310 -4
- package/runtime/cli/aikit/interactive_wizard.py +146 -0
- package/runtime/cli/aikit/knowledge_base.py +1067 -0
- package/runtime/cli/aikit/llm.py +40 -6
- package/runtime/cli/aikit/local_artifacts.py +444 -0
- package/runtime/cli/aikit/local_llm.py +176 -0
- package/runtime/cli/aikit/local_llm_operator.py +15 -5
- package/runtime/cli/aikit/main.py +15 -0
- package/runtime/cli/aikit/mcp_manifest.py +798 -0
- package/runtime/cli/aikit/mcp_tools.py +643 -5
- package/runtime/cli/aikit/memory.py +405 -0
- package/runtime/cli/aikit/mini_brain.py +56 -25
- package/runtime/cli/aikit/model_router.py +42 -9
- package/runtime/cli/aikit/natural_prompt_runtime.py +194 -2
- package/runtime/cli/aikit/ollama.py +64 -15
- package/runtime/cli/aikit/onboarding.py +551 -0
- package/runtime/cli/aikit/output.py +67 -0
- package/runtime/cli/aikit/prompt_injection.py +12 -1
- package/runtime/cli/aikit/review_gate.py +14 -2
- package/runtime/cli/aikit/roadmap_cli.py +1 -1
- package/runtime/cli/aikit/secrets.py +3 -2
- package/runtime/cli/aikit/setup_wizard_payload.py +3 -0
- package/runtime/cli/aikit/shared_memory.py +415 -0
- package/runtime/cli/aikit/specialist_readiness.py +152 -0
- package/runtime/cli/aikit/tasks.py +104 -1
- package/runtime/cli/aikit/team.py +380 -0
- package/runtime/cli/aikit/toolchain.py +7 -2
- package/runtime/cli/aikit/workflows.py +115 -14
- package/runtime/models/qwen2.5-0.5b-instruct/manifest.json +30 -0
- package/runtime/providers/knowledge-github.yaml +40 -0
- package/runtime/providers/knowledge-google-drive.yaml +32 -0
- package/runtime/providers/knowledge-local.yaml +26 -0
- package/runtime/providers/knowledge-notion.yaml +32 -0
- package/runtime/providers/knowledge-obsidian.yaml +24 -0
- package/runtime/providers/knowledge-onedrive.yaml +36 -0
- package/runtime/providers/knowledge-s3.yaml +45 -0
- package/runtime/providers/knowledge-sharepoint.yaml +39 -0
- package/runtime/providers/knowledge-supabase.yaml +43 -0
- package/runtime/providers/knowledge-vector.yaml +39 -0
- package/runtime/requirements.txt +6 -0
- package/runtime/scripts/docker-cli-qa.sh +453 -0
- package/runtime/scripts/release-catalog-snapshot.json +55 -4
- package/runtime/scripts/release-gate.py +54 -13
- package/runtime/tooling/toolchain.yaml +92 -0
- package/runtime/vendor/skills/napkin/napkin.md +21 -7
- package/runtime/workflows/azure-card-analysis/README.md +3 -0
- package/runtime/workflows/azure-card-analysis/workflow.yaml +30 -0
- package/runtime/workflows/daily-pr-review/README.md +3 -0
- package/runtime/workflows/daily-pr-review/workflow.yaml +31 -0
- package/runtime/workflows/incident-analysis/README.md +3 -0
- package/runtime/workflows/incident-analysis/workflow.yaml +33 -0
- package/runtime/workflows/release-prep/README.md +3 -0
- package/runtime/workflows/release-prep/workflow.yaml +30 -0
package/runtime/agents/shared-memory-curator/capabilities/review-shared-submission/capability.yaml
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
id: shared-memory-curator.review-shared-submission
|
|
2
|
+
kind: capability
|
|
3
|
+
name: Review shared submission
|
|
4
|
+
version: 0.3.0
|
|
5
|
+
status: draft
|
|
6
|
+
purpose: Revisar envio pendente de memoria compartilhada.
|
|
7
|
+
entrypoint:
|
|
8
|
+
workflow: workflow.md
|
|
9
|
+
write_policy: read_only
|
|
10
|
+
inputs:
|
|
11
|
+
type: object
|
|
12
|
+
outputs:
|
|
13
|
+
type: object
|
|
14
|
+
routing:
|
|
15
|
+
anchors:
|
|
16
|
+
- revisar envio memoria
|
|
17
|
+
- shared-memory review
|
|
18
|
+
intents:
|
|
19
|
+
- memory.shared.review
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Placeholder for shared-memory-curator infrastructure adapters.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Placeholder for shared-memory-curator templates.
|
package/runtime/cli/README.md
CHANGED
|
@@ -199,11 +199,45 @@ O comando retorna erro apenas para problemas estruturais do runtime, como raiz
|
|
|
199
199
|
inexistente. Provider opcional ausente, LLM sem chave ou CLI de host nao
|
|
200
200
|
instalada aparecem no bloco de diagnostico e podem ser resolvidos sob demanda.
|
|
201
201
|
|
|
202
|
+
## Onboarding
|
|
203
|
+
|
|
204
|
+
Executar apenas `agent` inicia o status/wizard local. Para planejar setup sem
|
|
205
|
+
executar instalacoes externas:
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
agent onboard minimal
|
|
209
|
+
agent onboard complete
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
`minimal` cobre identidade, coordenador LLM opcional, mini-cerebro local
|
|
213
|
+
instalavel sob demanda e memoria local. `complete` inclui tambem toolchain, providers/sources,
|
|
214
|
+
catalogo de agentes, automacoes locais, tarefas, notificacoes, knowledge e
|
|
215
|
+
memoria compartilhada. Instalacoes externas continuam exigindo opt-in.
|
|
216
|
+
|
|
217
|
+
Backups locais de memoria e personalidade sao gerenciados por:
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
agent memory backup create --title "Antes da migracao"
|
|
221
|
+
export AGENT_DEVKIT_BACKUP_PASSPHRASE="frase longa"
|
|
222
|
+
agent memory backup create --title "Antes da migracao" --encrypted --passphrase-env AGENT_DEVKIT_BACKUP_PASSPHRASE
|
|
223
|
+
agent memory backup list
|
|
224
|
+
agent memory backup restore <backup-id> --yes
|
|
225
|
+
agent memory backup restore --file ./backup.adkmb --passphrase-env AGENT_DEVKIT_BACKUP_PASSPHRASE --yes
|
|
226
|
+
agent memory backup delete <backup-id> --yes
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
O backup criptografado gera um pacote portatil `.adkmb` e remove a copia local
|
|
230
|
+
em claro dentro da pasta do backup. Esse fluxo nao executa upload remoto. Sync
|
|
231
|
+
remoto continua exigindo provider, criptografia e opt-in explicito.
|
|
232
|
+
|
|
202
233
|
## Backends LLM
|
|
203
234
|
|
|
204
|
-
O modo `agent "<prompt>"`
|
|
235
|
+
O modo `agent "<prompt>"` consegue conversar e orientar setup com o mini cerebro
|
|
236
|
+
local depois que ele for instalado com opt-in. Para coordenacao/revisao mais forte, o Agent DevKit suporta estas
|
|
205
237
|
familias de backend:
|
|
206
238
|
|
|
239
|
+
- Mini cerebro local instalavel (`embedded-mini-brain`) para onboarding, setup e
|
|
240
|
+
conversa simples sem autenticacao externa.
|
|
207
241
|
- CLIs oficiais autenticadas fora do Agent DevKit (`codex-cli` e
|
|
208
242
|
`claude-code`).
|
|
209
243
|
- APIs configuradas por referencia a variavel de ambiente (`openai`,
|
|
@@ -290,21 +324,26 @@ agent llm doctor openrouter
|
|
|
290
324
|
### Ollama local
|
|
291
325
|
|
|
292
326
|
```bash
|
|
327
|
+
agent setup mini-brain --yes
|
|
328
|
+
agent local-llm doctor
|
|
293
329
|
agent ollama status
|
|
294
330
|
agent ollama models
|
|
295
|
-
agent ollama pull
|
|
296
|
-
agent ollama pull
|
|
331
|
+
agent ollama pull qwen3:0.6b --dry-run
|
|
332
|
+
agent ollama pull qwen3:0.6b --yes
|
|
297
333
|
ollama serve
|
|
298
|
-
agent llm configure ollama --base-url http://localhost:11434/v1 --model
|
|
334
|
+
agent llm configure ollama --base-url http://localhost:11434/v1 --model qwen3:0.6b --set-default
|
|
299
335
|
agent llm doctor ollama
|
|
300
336
|
```
|
|
301
337
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
338
|
+
O mini cerebro embarcado e a base inicial para conversa/setup sem dependencia
|
|
339
|
+
externa. Ollama e tratado como executor operacional local opcional. Codex e
|
|
340
|
+
Claude continuam como coordenadores/revisores preferenciais para decisao,
|
|
341
|
+
especificacao, codigo, documentos, automacoes e fechamento de entrega.
|
|
305
342
|
|
|
306
343
|
Backends suportados no MVP:
|
|
307
344
|
|
|
345
|
+
- `embedded-mini-brain`: mini cerebro local embarcado para bootstrap e tarefas
|
|
346
|
+
simples.
|
|
308
347
|
- `openai`: API OpenAI ou endpoint OpenAI-compatible.
|
|
309
348
|
- `anthropic`: API Anthropic.
|
|
310
349
|
- `openrouter`: API OpenRouter.
|
|
@@ -319,7 +358,7 @@ agent llm list
|
|
|
319
358
|
agent llm configure openai --api-key-env OPENAI_API_KEY --set-default
|
|
320
359
|
agent llm configure anthropic --api-key-env ANTHROPIC_API_KEY --set-default
|
|
321
360
|
agent llm configure openrouter --api-key-env OPENROUTER_API_KEY --set-default
|
|
322
|
-
agent llm configure ollama --base-url http://localhost:11434/v1 --model
|
|
361
|
+
agent llm configure ollama --base-url http://localhost:11434/v1 --model qwen3:0.6b --set-default
|
|
323
362
|
agent llm configure codex-cli --set-default
|
|
324
363
|
agent llm configure claude-code --set-default
|
|
325
364
|
agent llm set-default codex-cli
|
|
@@ -5,8 +5,6 @@ from __future__ import annotations
|
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
from typing import Any
|
|
7
7
|
|
|
8
|
-
import yaml
|
|
9
|
-
|
|
10
8
|
from cli.aikit.write_policy import normalize_write_policy, write_policy_public_fields
|
|
11
9
|
|
|
12
10
|
|
|
@@ -96,6 +94,10 @@ def find_capability(registry: dict[str, Any], agent_id: str, capability_id: str)
|
|
|
96
94
|
|
|
97
95
|
|
|
98
96
|
def read_yaml(path: Path) -> dict[str, Any]:
|
|
97
|
+
try:
|
|
98
|
+
import yaml # type: ignore
|
|
99
|
+
except ImportError as exc:
|
|
100
|
+
raise RuntimeError("PyYAML is required to read Agent DevKit manifests. Install requirements.txt.") from exc
|
|
99
101
|
data = yaml.safe_load(path.read_text(encoding="utf-8")) or {}
|
|
100
102
|
return data if isinstance(data, dict) else {}
|
|
101
103
|
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"""Explicit agentic planning and orchestration CLI commands."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from cli.aikit.core.requests import AgentPromptRequest
|
|
9
|
+
from cli.aikit.errors import DevKitError
|
|
10
|
+
from cli.aikit.natural_prompt_runtime import run_agent_prompt_request
|
|
11
|
+
from cli.aikit.orchestrator import build_execution_plan
|
|
12
|
+
from cli.aikit.runtime_paths import ROOT
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def agentic_plan(root: Path, prompt_parts: list[str] | tuple[str, ...] | None) -> dict[str, Any]:
|
|
16
|
+
prompt = normalize_prompt(prompt_parts, command="plan")
|
|
17
|
+
plan = build_execution_plan(root, prompt, dry_run=True)
|
|
18
|
+
return {
|
|
19
|
+
"kind": "agentic-plan",
|
|
20
|
+
"status": plan.get("status") or "planned",
|
|
21
|
+
"ok": True,
|
|
22
|
+
"dry_run": True,
|
|
23
|
+
"prompt_received": True,
|
|
24
|
+
"prompt_length": len(prompt),
|
|
25
|
+
"summary": plan_summary(plan),
|
|
26
|
+
"execution_plan": plan,
|
|
27
|
+
"orchestration_trace": plan.get("trace", []),
|
|
28
|
+
"response": "Plano agentico gerado sem executar LLM, automacoes ou escritas externas.",
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def agentic_execute(
|
|
33
|
+
prompt_parts: list[str] | tuple[str, ...] | None,
|
|
34
|
+
*,
|
|
35
|
+
llm: str | None = None,
|
|
36
|
+
dry_run: bool = False,
|
|
37
|
+
session_id: str | None = None,
|
|
38
|
+
new_session: bool = False,
|
|
39
|
+
no_llm_fallback: bool = False,
|
|
40
|
+
prog_name: str = "agent",
|
|
41
|
+
project: str | None = None,
|
|
42
|
+
mode: str = "execute",
|
|
43
|
+
) -> dict[str, Any]:
|
|
44
|
+
prompt = normalize_prompt(prompt_parts, command=mode)
|
|
45
|
+
if dry_run:
|
|
46
|
+
payload = agentic_plan(ROOT, [prompt])
|
|
47
|
+
payload["command_mode"] = mode
|
|
48
|
+
return payload
|
|
49
|
+
result = run_agent_prompt_request(
|
|
50
|
+
AgentPromptRequest(
|
|
51
|
+
prompt=prompt,
|
|
52
|
+
llm=llm,
|
|
53
|
+
dry_run=False,
|
|
54
|
+
session_id=session_id,
|
|
55
|
+
new_session=new_session,
|
|
56
|
+
no_llm_fallback=no_llm_fallback,
|
|
57
|
+
prog_name=prog_name,
|
|
58
|
+
project=project,
|
|
59
|
+
)
|
|
60
|
+
)
|
|
61
|
+
return attach_agentic_metadata(result, prompt=prompt, mode=mode)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def normalize_prompt(prompt_parts: list[str] | tuple[str, ...] | None, *, command: str) -> str:
|
|
65
|
+
prompt = " ".join(str(part) for part in (prompt_parts or [])).strip()
|
|
66
|
+
if not prompt:
|
|
67
|
+
raise DevKitError(f"agent {command} requires a natural-language prompt")
|
|
68
|
+
return prompt
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def plan_summary(plan: dict[str, Any]) -> dict[str, Any]:
|
|
72
|
+
specialist_tasks = [task for task in plan.get("specialist_tasks") or [] if isinstance(task, dict)]
|
|
73
|
+
configuration_tasks = [task for task in plan.get("configuration_tasks") or [] if isinstance(task, dict)]
|
|
74
|
+
review_task = plan.get("review_task") if isinstance(plan.get("review_task"), dict) else {}
|
|
75
|
+
model_plan = plan.get("model_plan") if isinstance(plan.get("model_plan"), dict) else {}
|
|
76
|
+
routing_decision = plan.get("routing_decision") if isinstance(plan.get("routing_decision"), dict) else {}
|
|
77
|
+
autonomy = plan.get("autonomy_contract") if isinstance(plan.get("autonomy_contract"), dict) else {}
|
|
78
|
+
needs_input = (
|
|
79
|
+
plan.get("status") == "needs-input"
|
|
80
|
+
or bool(configuration_tasks)
|
|
81
|
+
or model_plan.get("strategy") == "human"
|
|
82
|
+
or autonomy.get("requires_human") is True
|
|
83
|
+
or autonomy.get("status") == "needs-input"
|
|
84
|
+
)
|
|
85
|
+
return {
|
|
86
|
+
"routing_status": routing_decision.get("status"),
|
|
87
|
+
"selected_agent_id": routing_decision.get("selected_agent_id"),
|
|
88
|
+
"selected_capability_id": routing_decision.get("selected_capability_id"),
|
|
89
|
+
"model_strategy": model_plan.get("strategy"),
|
|
90
|
+
"local_llm_selected": model_plan.get("local_llm_selected"),
|
|
91
|
+
"specialist_tasks": len(specialist_tasks),
|
|
92
|
+
"configuration_tasks": len(configuration_tasks),
|
|
93
|
+
"review_required": bool(review_task.get("required") or review_task.get("status") in {"pending", "required"}),
|
|
94
|
+
"collaboration_enabled": bool(plan.get("collaboration_enabled")),
|
|
95
|
+
"controller_enabled": bool(plan.get("controller_enabled")),
|
|
96
|
+
"needs_input": needs_input,
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def attach_agentic_metadata(result: dict[str, Any], *, prompt: str, mode: str) -> dict[str, Any]:
|
|
101
|
+
plan = result.get("execution_plan") if isinstance(result.get("execution_plan"), dict) else None
|
|
102
|
+
if plan is None:
|
|
103
|
+
plan = local_shortcut_execution_plan(prompt=prompt, result=result, mode=mode)
|
|
104
|
+
result["execution_plan"] = plan
|
|
105
|
+
result.setdefault("orchestration_trace", plan.get("trace", []))
|
|
106
|
+
result["agentic_summary"] = plan_summary(plan)
|
|
107
|
+
result["command_mode"] = mode
|
|
108
|
+
result["agentic_command"] = mode
|
|
109
|
+
return result
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def local_shortcut_execution_plan(*, prompt: str, result: dict[str, Any], mode: str) -> dict[str, Any]:
|
|
113
|
+
status = str(result.get("status") or "ok")
|
|
114
|
+
local_mode = str(result.get("mode") or result.get("action") or "local-shortcut")
|
|
115
|
+
ok = result.get("ok") is not False and status not in {"blocked", "failed", "needs-input", "needs-review"}
|
|
116
|
+
return {
|
|
117
|
+
"schema_version": "ai-devkit.agentic-plan/v1",
|
|
118
|
+
"status": "completed" if ok else status,
|
|
119
|
+
"prompt": prompt,
|
|
120
|
+
"dry_run": False,
|
|
121
|
+
"command_mode": mode,
|
|
122
|
+
"routing_decision": {
|
|
123
|
+
"status": "selected",
|
|
124
|
+
"selected_agent_id": "agent-devkit",
|
|
125
|
+
"selected_capability_id": local_mode,
|
|
126
|
+
"method": "local-shortcut",
|
|
127
|
+
"confidence": 1.0,
|
|
128
|
+
},
|
|
129
|
+
"model_plan": {
|
|
130
|
+
"strategy": "deterministic-local",
|
|
131
|
+
"local_llm_selected": False,
|
|
132
|
+
"local_llm_recommended": False,
|
|
133
|
+
"fallback": None,
|
|
134
|
+
},
|
|
135
|
+
"specialist_tasks": [],
|
|
136
|
+
"configuration_tasks": [],
|
|
137
|
+
"review_task": {
|
|
138
|
+
"agent_id": "execution-reviewer",
|
|
139
|
+
"capability_id": "review-final-output",
|
|
140
|
+
"status": "not-required",
|
|
141
|
+
"required": False,
|
|
142
|
+
},
|
|
143
|
+
"review_gate": {
|
|
144
|
+
"required": False,
|
|
145
|
+
"status": "not-required",
|
|
146
|
+
"reason": "local deterministic shortcut",
|
|
147
|
+
},
|
|
148
|
+
"collaboration_enabled": False,
|
|
149
|
+
"controller_enabled": False,
|
|
150
|
+
"trace": [
|
|
151
|
+
{
|
|
152
|
+
"agent_id": "task-orchestrator",
|
|
153
|
+
"action": "local-shortcut",
|
|
154
|
+
"mode": local_mode,
|
|
155
|
+
"status": status,
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
}
|
|
@@ -58,7 +58,7 @@ def record_audit(
|
|
|
58
58
|
execution_id = f"exec_{now_utc().strftime('%Y%m%d%H%M%S')}_{uuid.uuid4().hex[:8]}"
|
|
59
59
|
prompt = extract_prompt(args)
|
|
60
60
|
try:
|
|
61
|
-
safe_result = redact_value(result or {})
|
|
61
|
+
safe_result = redact_value(result or {}, redact_access_keys=True)
|
|
62
62
|
safe_prompt = redact_secrets(prompt) if prompt else None
|
|
63
63
|
safe_error = redact_secrets(error) if error else None
|
|
64
64
|
except Exception as exc: # noqa: BLE001 - never write an unredacted audit fallback.
|
|
@@ -227,25 +227,35 @@ def find_audit_json(execution_id: str) -> Path:
|
|
|
227
227
|
return matches[0]
|
|
228
228
|
|
|
229
229
|
|
|
230
|
-
def redact_value(value: Any) -> Any:
|
|
230
|
+
def redact_value(value: Any, *, redact_access_keys: bool = False, parent_key: str | None = None) -> Any:
|
|
231
231
|
if isinstance(value, str):
|
|
232
232
|
return redact_secrets(value)
|
|
233
233
|
if isinstance(value, list):
|
|
234
|
-
return [redact_value(item) for item in value]
|
|
234
|
+
return [redact_value(item, redact_access_keys=redact_access_keys, parent_key=parent_key) for item in value]
|
|
235
235
|
if isinstance(value, tuple):
|
|
236
|
-
return [redact_value(item) for item in value]
|
|
236
|
+
return [redact_value(item, redact_access_keys=redact_access_keys, parent_key=parent_key) for item in value]
|
|
237
237
|
if isinstance(value, dict):
|
|
238
238
|
redacted: dict[str, Any] = {}
|
|
239
239
|
for key, item in value.items():
|
|
240
240
|
key_text = str(key)
|
|
241
|
-
if secret_key(key_text):
|
|
241
|
+
if secret_key(key_text) or access_key(key_text, parent_key=parent_key, enabled=redact_access_keys):
|
|
242
242
|
redacted[key_text] = "[REDACTED_SECRET]"
|
|
243
243
|
else:
|
|
244
|
-
redacted[key_text] = redact_value(item)
|
|
244
|
+
redacted[key_text] = redact_value(item, redact_access_keys=redact_access_keys, parent_key=key_text)
|
|
245
245
|
return redacted
|
|
246
246
|
return value
|
|
247
247
|
|
|
248
248
|
|
|
249
|
+
def access_key(key: str, *, parent_key: str | None, enabled: bool) -> bool:
|
|
250
|
+
if not enabled:
|
|
251
|
+
return False
|
|
252
|
+
normalized = key.lower().replace("-", "_")
|
|
253
|
+
if normalized in {"owner_key", "contributor_key", "shared_key"}:
|
|
254
|
+
return True
|
|
255
|
+
parent = (parent_key or "").lower().replace("-", "_")
|
|
256
|
+
return normalized == "key" and parent in {"owner_access", "contributor_access", "shared_access"}
|
|
257
|
+
|
|
258
|
+
|
|
249
259
|
def secret_key(key: str) -> bool:
|
|
250
260
|
normalized = key.lower().replace("-", "_")
|
|
251
261
|
if normalized in {"token_estimate", "tokens", "prompt_tokens", "completion_tokens", "total_tokens"}:
|