@team-agent/installer 0.2.11 → 0.3.0
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/Cargo.lock +744 -0
- package/Cargo.toml +34 -0
- package/crates/team-agent/Cargo.toml +33 -0
- package/crates/team-agent/src/cli/adapters.rs +1343 -0
- package/crates/team-agent/src/cli/diagnose.rs +554 -0
- package/crates/team-agent/src/cli/emit.rs +1077 -0
- package/crates/team-agent/src/cli/helpers.rs +88 -0
- package/crates/team-agent/src/cli/leader.rs +216 -0
- package/crates/team-agent/src/cli/mod.rs +1141 -0
- package/crates/team-agent/src/cli/profile.rs +306 -0
- package/crates/team-agent/src/cli/send.rs +215 -0
- package/crates/team-agent/src/cli/status.rs +179 -0
- package/crates/team-agent/src/cli/status_port.rs +502 -0
- package/crates/team-agent/src/cli/tests/base.rs +616 -0
- package/crates/team-agent/src/cli/tests/compile.rs +96 -0
- package/crates/team-agent/src/cli/tests/divergence.rs +509 -0
- package/crates/team-agent/src/cli/tests/lane_c.rs +333 -0
- package/crates/team-agent/src/cli/tests/leader_watch.rs +395 -0
- package/crates/team-agent/src/cli/tests/main_preserved.rs +675 -0
- package/crates/team-agent/src/cli/tests/missing_subcommands.rs +390 -0
- package/crates/team-agent/src/cli/tests/mod.rs +97 -0
- package/crates/team-agent/src/cli/tests/peer_allow.rs +137 -0
- package/crates/team-agent/src/cli/tests/repair_state_byte_lock.rs +302 -0
- package/crates/team-agent/src/cli/tests/run_delegation.rs +305 -0
- package/crates/team-agent/src/cli/tests/status_send.rs +385 -0
- package/crates/team-agent/src/cli/tests/verb_profile.rs +182 -0
- package/crates/team-agent/src/cli/tests/verb_settle.rs +236 -0
- package/crates/team-agent/src/cli/tests/verb_validate.rs +184 -0
- package/crates/team-agent/src/cli/types.rs +605 -0
- package/crates/team-agent/src/compiler/tests.rs +701 -0
- package/crates/team-agent/src/compiler.rs +489 -0
- package/crates/team-agent/src/coordinator/backoff.rs +153 -0
- package/crates/team-agent/src/coordinator/health.rs +436 -0
- package/crates/team-agent/src/coordinator/mod.rs +80 -0
- package/crates/team-agent/src/coordinator/orphan.rs +179 -0
- package/crates/team-agent/src/coordinator/tests/abnormal.rs +255 -0
- package/crates/team-agent/src/coordinator/tests/basics.rs +262 -0
- package/crates/team-agent/src/coordinator/tests/daemon.rs +323 -0
- package/crates/team-agent/src/coordinator/tests/health_sync.rs +263 -0
- package/crates/team-agent/src/coordinator/tests/main_preserved.rs +136 -0
- package/crates/team-agent/src/coordinator/tests/mod.rs +310 -0
- package/crates/team-agent/src/coordinator/tests/spine.rs +261 -0
- package/crates/team-agent/src/coordinator/tests/takeover.rs +227 -0
- package/crates/team-agent/src/coordinator/tests/tick_core.rs +256 -0
- package/crates/team-agent/src/coordinator/tests/watch.rs +167 -0
- package/crates/team-agent/src/coordinator/tick.rs +2032 -0
- package/crates/team-agent/src/coordinator/types.rs +584 -0
- package/crates/team-agent/src/db/migration.rs +716 -0
- package/crates/team-agent/src/db/mod.rs +23 -0
- package/crates/team-agent/src/db/schema.rs +378 -0
- package/crates/team-agent/src/event_log.rs +375 -0
- package/crates/team-agent/src/fake_worker.rs +253 -0
- package/crates/team-agent/src/leader/helpers.rs +190 -0
- package/crates/team-agent/src/leader/inject.rs +33 -0
- package/crates/team-agent/src/leader/lease.rs +1063 -0
- package/crates/team-agent/src/leader/mod.rs +99 -0
- package/crates/team-agent/src/leader/owner_bind.rs +292 -0
- package/crates/team-agent/src/leader/rediscover/tests.rs +525 -0
- package/crates/team-agent/src/leader/rediscover.rs +1099 -0
- package/crates/team-agent/src/leader/start.rs +273 -0
- package/crates/team-agent/src/leader/takeover.rs +235 -0
- package/crates/team-agent/src/leader/tests/basics.rs +183 -0
- package/crates/team-agent/src/leader/tests/byte_findings.rs +234 -0
- package/crates/team-agent/src/leader/tests/identity.rs +206 -0
- package/crates/team-agent/src/leader/tests/idle.rs +271 -0
- package/crates/team-agent/src/leader/tests/lease_api.rs +225 -0
- package/crates/team-agent/src/leader/tests/lease_claim.rs +253 -0
- package/crates/team-agent/src/leader/tests/mod.rs +125 -0
- package/crates/team-agent/src/leader/tests/rediscover.rs +351 -0
- package/crates/team-agent/src/leader/tests/wake_start_owner.rs +204 -0
- package/crates/team-agent/src/leader/types.rs +487 -0
- package/crates/team-agent/src/lib.rs +85 -0
- package/crates/team-agent/src/lifecycle/display.rs +228 -0
- package/crates/team-agent/src/lifecycle/helpers.rs +112 -0
- package/crates/team-agent/src/lifecycle/launch/plan.rs +227 -0
- package/crates/team-agent/src/lifecycle/launch.rs +1833 -0
- package/crates/team-agent/src/lifecycle/mod.rs +62 -0
- package/crates/team-agent/src/lifecycle/restart/agent.rs +533 -0
- package/crates/team-agent/src/lifecycle/restart/common.rs +517 -0
- package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +41 -0
- package/crates/team-agent/src/lifecycle/restart/rebuild.rs +268 -0
- package/crates/team-agent/src/lifecycle/restart/remove.rs +780 -0
- package/crates/team-agent/src/lifecycle/restart/selection.rs +208 -0
- package/crates/team-agent/src/lifecycle/restart/team_state.rs +242 -0
- package/crates/team-agent/src/lifecycle/restart.rs +76 -0
- package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +455 -0
- package/crates/team-agent/src/lifecycle/tests/core.rs +989 -0
- package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +583 -0
- package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +933 -0
- package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +265 -0
- package/crates/team-agent/src/lifecycle/tests.rs +27 -0
- package/crates/team-agent/src/lifecycle/types.rs +685 -0
- package/crates/team-agent/src/main.rs +41 -0
- package/crates/team-agent/src/mcp_server/helpers.rs +228 -0
- package/crates/team-agent/src/mcp_server/mod.rs +183 -0
- package/crates/team-agent/src/mcp_server/normalize.rs +312 -0
- package/crates/team-agent/src/mcp_server/tests/golden.rs +283 -0
- package/crates/team-agent/src/mcp_server/tests/normalize.rs +244 -0
- package/crates/team-agent/src/mcp_server/tests/scoped.rs +189 -0
- package/crates/team-agent/src/mcp_server/tests/send.rs +222 -0
- package/crates/team-agent/src/mcp_server/tests/tools.rs +158 -0
- package/crates/team-agent/src/mcp_server/tests/wire.rs +159 -0
- package/crates/team-agent/src/mcp_server/tests.rs +38 -0
- package/crates/team-agent/src/mcp_server/tools.rs +603 -0
- package/crates/team-agent/src/mcp_server/types.rs +421 -0
- package/crates/team-agent/src/mcp_server/wire.rs +388 -0
- package/crates/team-agent/src/message_store.rs +767 -0
- package/crates/team-agent/src/messaging/activity.rs +433 -0
- package/crates/team-agent/src/messaging/delivery.rs +542 -0
- package/crates/team-agent/src/messaging/helpers.rs +209 -0
- package/crates/team-agent/src/messaging/leader_receiver.rs +340 -0
- package/crates/team-agent/src/messaging/mod.rs +147 -0
- package/crates/team-agent/src/messaging/peers.rs +32 -0
- package/crates/team-agent/src/messaging/results.rs +537 -0
- package/crates/team-agent/src/messaging/scheduler.rs +344 -0
- package/crates/team-agent/src/messaging/selftest.rs +100 -0
- package/crates/team-agent/src/messaging/send.rs +582 -0
- package/crates/team-agent/src/messaging/tests/basic.rs +357 -0
- package/crates/team-agent/src/messaging/tests/main_preserved.rs +122 -0
- package/crates/team-agent/src/messaging/tests/mod.rs +293 -0
- package/crates/team-agent/src/messaging/tests/runtime.rs +1422 -0
- package/crates/team-agent/src/messaging/tests/spine.rs +437 -0
- package/crates/team-agent/src/messaging/trust.rs +192 -0
- package/crates/team-agent/src/messaging/types.rs +355 -0
- package/crates/team-agent/src/messaging/watchers.rs +591 -0
- package/crates/team-agent/src/model/enums.rs +311 -0
- package/crates/team-agent/src/model/errors.rs +17 -0
- package/crates/team-agent/src/model/ids.rs +155 -0
- package/crates/team-agent/src/model/mod.rs +22 -0
- package/crates/team-agent/src/model/paths.rs +228 -0
- package/crates/team-agent/src/model/permissions.rs +567 -0
- package/crates/team-agent/src/model/routing.rs +340 -0
- package/crates/team-agent/src/model/spec.rs +680 -0
- package/crates/team-agent/src/model/task_graph.rs +380 -0
- package/crates/team-agent/src/model/testdata/fuzz.golden.yaml +43 -0
- package/crates/team-agent/src/model/testdata/fuzz.yaml +43 -0
- package/crates/team-agent/src/model/testdata/spec_invalid_a.yaml +207 -0
- package/crates/team-agent/src/model/testdata/team.spec.golden.yaml +206 -0
- package/crates/team-agent/src/model/testdata/team.spec.yaml +206 -0
- package/crates/team-agent/src/model/yaml/tests.rs +288 -0
- package/crates/team-agent/src/model/yaml.rs +800 -0
- package/crates/team-agent/src/packaging/install.rs +305 -0
- package/crates/team-agent/src/packaging/migrate.rs +30 -0
- package/crates/team-agent/src/packaging/mod.rs +82 -0
- package/crates/team-agent/src/packaging/repair.rs +24 -0
- package/crates/team-agent/src/packaging/tests.rs +829 -0
- package/crates/team-agent/src/packaging/types.rs +369 -0
- package/crates/team-agent/src/provider/adapter.rs +801 -0
- package/crates/team-agent/src/provider/approvals/mod.rs +2 -0
- package/crates/team-agent/src/provider/approvals/parsing.rs +452 -0
- package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +163 -0
- package/crates/team-agent/src/provider/classify.rs +456 -0
- package/crates/team-agent/src/provider/faults.rs +136 -0
- package/crates/team-agent/src/provider/helpers.rs +41 -0
- package/crates/team-agent/src/provider/mod.rs +53 -0
- package/crates/team-agent/src/provider/startup_prompt.rs +423 -0
- package/crates/team-agent/src/provider/tests/adapter.rs +239 -0
- package/crates/team-agent/src/provider/tests/classify.rs +240 -0
- package/crates/team-agent/src/provider/tests/faults.rs +120 -0
- package/crates/team-agent/src/provider/tests/idle.rs +208 -0
- package/crates/team-agent/src/provider/tests/wire.rs +213 -0
- package/crates/team-agent/src/provider/tests.rs +31 -0
- package/crates/team-agent/src/provider/types.rs +424 -0
- package/crates/team-agent/src/state/identity.rs +656 -0
- package/crates/team-agent/src/state/mod.rs +58 -0
- package/crates/team-agent/src/state/owner_gate.rs +423 -0
- package/crates/team-agent/src/state/persist.rs +712 -0
- package/crates/team-agent/src/state/projection.rs +657 -0
- package/crates/team-agent/src/state/selector.rs +105 -0
- package/crates/team-agent/src/state/testdata/state-rich.canonical.json +133 -0
- package/crates/team-agent/src/tmux_backend/tests.rs +586 -0
- package/crates/team-agent/src/tmux_backend.rs +758 -0
- package/crates/team-agent/src/transport/test_support.rs +252 -0
- package/crates/team-agent/src/transport/tests/behavior.rs +327 -0
- package/crates/team-agent/src/transport/tests/mod.rs +199 -0
- package/crates/team-agent/src/transport/tests/wire.rs +527 -0
- package/crates/team-agent/src/transport.rs +774 -0
- package/npm/install.mjs +90 -106
- package/package.json +15 -13
- package/crates/team-agent-core/Cargo.toml +0 -12
- package/crates/team-agent-core/src/lib.rs +0 -332
- package/crates/team-agent-core/src/main.rs +0 -152
- package/pyproject.toml +0 -18
- package/scripts/install.py +0 -88
- package/scripts/run_regression_tests.py +0 -83
- package/src/team_agent/__init__.py +0 -3
- package/src/team_agent/__main__.py +0 -5
- package/src/team_agent/_legacy_pane_discovery.py +0 -186
- package/src/team_agent/abnormal_track.py +0 -253
- package/src/team_agent/approvals/__init__.py +0 -65
- package/src/team_agent/approvals/constants.py +0 -6
- package/src/team_agent/approvals/parsing.py +0 -176
- package/src/team_agent/approvals/runtime_prompts.py +0 -171
- package/src/team_agent/approvals/status.py +0 -176
- package/src/team_agent/cli/__init__.py +0 -137
- package/src/team_agent/cli/commands.py +0 -481
- package/src/team_agent/cli/e2e.py +0 -202
- package/src/team_agent/cli/helpers.py +0 -226
- package/src/team_agent/cli/parser.py +0 -540
- package/src/team_agent/compiler.py +0 -334
- package/src/team_agent/coordinator/__init__.py +0 -53
- package/src/team_agent/coordinator/__main__.py +0 -119
- package/src/team_agent/coordinator/lifecycle.py +0 -411
- package/src/team_agent/coordinator/metadata.py +0 -61
- package/src/team_agent/coordinator/paths.py +0 -17
- package/src/team_agent/diagnose/__init__.py +0 -48
- package/src/team_agent/diagnose/checks.py +0 -101
- package/src/team_agent/diagnose/comms.py +0 -213
- package/src/team_agent/diagnose/health.py +0 -241
- package/src/team_agent/diagnose/orphan_cleanup.py +0 -364
- package/src/team_agent/diagnose/preflight.py +0 -194
- package/src/team_agent/diagnose/quick_start.py +0 -324
- package/src/team_agent/display/__init__.py +0 -92
- package/src/team_agent/display/adaptive.py +0 -511
- package/src/team_agent/display/backend.py +0 -46
- package/src/team_agent/display/close.py +0 -154
- package/src/team_agent/display/ghostty.py +0 -77
- package/src/team_agent/display/rebuild.py +0 -102
- package/src/team_agent/display/tiling.py +0 -156
- package/src/team_agent/display/worker_window.py +0 -114
- package/src/team_agent/display/workspace.py +0 -382
- package/src/team_agent/errors.py +0 -10
- package/src/team_agent/events.py +0 -84
- package/src/team_agent/fake_worker.py +0 -80
- package/src/team_agent/idle_predicate.py +0 -218
- package/src/team_agent/idle_takeover.py +0 -59
- package/src/team_agent/idle_takeover_wiring.py +0 -114
- package/src/team_agent/launch/__init__.py +0 -41
- package/src/team_agent/launch/bootstrap.py +0 -85
- package/src/team_agent/launch/config.py +0 -106
- package/src/team_agent/launch/core.py +0 -301
- package/src/team_agent/launch/requirements.py +0 -57
- package/src/team_agent/leader/__init__.py +0 -926
- package/src/team_agent/leader_binding.py +0 -183
- package/src/team_agent/lifecycle/__init__.py +0 -5
- package/src/team_agent/lifecycle/agents.py +0 -278
- package/src/team_agent/lifecycle/operations.py +0 -411
- package/src/team_agent/lifecycle/paste_buffer_hygiene.py +0 -39
- package/src/team_agent/lifecycle/start.py +0 -363
- package/src/team_agent/mcp_server/__init__.py +0 -42
- package/src/team_agent/mcp_server/__main__.py +0 -7
- package/src/team_agent/mcp_server/contracts.py +0 -148
- package/src/team_agent/mcp_server/normalize.py +0 -257
- package/src/team_agent/mcp_server/server.py +0 -150
- package/src/team_agent/mcp_server/tools.py +0 -352
- package/src/team_agent/message_store/__init__.py +0 -23
- package/src/team_agent/message_store/agent_health.py +0 -113
- package/src/team_agent/message_store/core.py +0 -497
- package/src/team_agent/message_store/leader_notification_log.py +0 -198
- package/src/team_agent/message_store/result_watchers.py +0 -251
- package/src/team_agent/message_store/schema.py +0 -308
- package/src/team_agent/message_store/schema_migration.py +0 -448
- package/src/team_agent/messaging/__init__.py +0 -1
- package/src/team_agent/messaging/activity_detector.py +0 -262
- package/src/team_agent/messaging/delivery.py +0 -504
- package/src/team_agent/messaging/deps.py +0 -247
- package/src/team_agent/messaging/idle_alerts.py +0 -423
- package/src/team_agent/messaging/internal_delivery.py +0 -46
- package/src/team_agent/messaging/leader.py +0 -497
- package/src/team_agent/messaging/leader_api_errors.py +0 -216
- package/src/team_agent/messaging/leader_panes.py +0 -673
- package/src/team_agent/messaging/owner_bypass.py +0 -29
- package/src/team_agent/messaging/result_delivery.py +0 -539
- package/src/team_agent/messaging/results.py +0 -447
- package/src/team_agent/messaging/scheduler.py +0 -450
- package/src/team_agent/messaging/send.py +0 -532
- package/src/team_agent/messaging/session_drift.py +0 -94
- package/src/team_agent/messaging/tmux_io.py +0 -506
- package/src/team_agent/messaging/tmux_prompt.py +0 -338
- package/src/team_agent/messaging/trust_auto_answer.py +0 -52
- package/src/team_agent/orchestrator/__init__.py +0 -376
- package/src/team_agent/orchestrator/plan.py +0 -122
- package/src/team_agent/orchestrator/state.py +0 -128
- package/src/team_agent/paths.py +0 -45
- package/src/team_agent/permissions.py +0 -123
- package/src/team_agent/profiles/__init__.py +0 -82
- package/src/team_agent/profiles/constants.py +0 -19
- package/src/team_agent/profiles/core.py +0 -407
- package/src/team_agent/profiles/helpers.py +0 -69
- package/src/team_agent/profiles/provider_env.py +0 -188
- package/src/team_agent/profiles/smoke.py +0 -201
- package/src/team_agent/provider_cli/__init__.py +0 -43
- package/src/team_agent/provider_cli/adapter.py +0 -172
- package/src/team_agent/provider_cli/base.py +0 -48
- package/src/team_agent/provider_cli/claude.py +0 -503
- package/src/team_agent/provider_cli/codex.py +0 -336
- package/src/team_agent/provider_cli/copilot.py +0 -8
- package/src/team_agent/provider_cli/fake.py +0 -39
- package/src/team_agent/provider_cli/gemini.py +0 -95
- package/src/team_agent/provider_cli/opencode.py +0 -8
- package/src/team_agent/provider_cli/prompt.py +0 -62
- package/src/team_agent/provider_cli/registry.py +0 -18
- package/src/team_agent/provider_cli/unsupported.py +0 -32
- package/src/team_agent/provider_state/README.md +0 -78
- package/src/team_agent/provider_state/__init__.py +0 -91
- package/src/team_agent/provider_state/claude.py +0 -86
- package/src/team_agent/provider_state/codex.py +0 -84
- package/src/team_agent/provider_state/common.py +0 -207
- package/src/team_agent/provider_state/registry.py +0 -118
- package/src/team_agent/providers.py +0 -163
- package/src/team_agent/quality_gates.py +0 -104
- package/src/team_agent/restart/__init__.py +0 -34
- package/src/team_agent/restart/orchestration.py +0 -554
- package/src/team_agent/restart/selection.py +0 -89
- package/src/team_agent/restart/snapshot.py +0 -70
- package/src/team_agent/routing.py +0 -84
- package/src/team_agent/runtime.py +0 -1243
- package/src/team_agent/rust_core.py +0 -327
- package/src/team_agent/sessions/__init__.py +0 -25
- package/src/team_agent/sessions/capture.py +0 -144
- package/src/team_agent/sessions/inventory.py +0 -44
- package/src/team_agent/sessions/resume.py +0 -135
- package/src/team_agent/simple_yaml.py +0 -236
- package/src/team_agent/spec.py +0 -370
- package/src/team_agent/state.py +0 -693
- package/src/team_agent/status/__init__.py +0 -63
- package/src/team_agent/status/approvals.py +0 -52
- package/src/team_agent/status/compact.py +0 -158
- package/src/team_agent/status/constants.py +0 -18
- package/src/team_agent/status/inbox.py +0 -58
- package/src/team_agent/status/peek.py +0 -117
- package/src/team_agent/status/queries.py +0 -199
- package/src/team_agent/task_graph.py +0 -80
- package/src/team_agent/terminal.py +0 -57
- package/src/team_agent/wake.py +0 -58
- package/src/team_agent/watch/__init__.py +0 -145
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from typing import Any
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def _compact_tool_result(result: dict[str, Any]) -> dict[str, Any]:
|
|
7
|
-
if result.get("ok") is False:
|
|
8
|
-
keys = [
|
|
9
|
-
"ok",
|
|
10
|
-
"status",
|
|
11
|
-
"reason",
|
|
12
|
-
"error",
|
|
13
|
-
"message_id",
|
|
14
|
-
"agent_id",
|
|
15
|
-
"new_agent_id",
|
|
16
|
-
"source_agent_id",
|
|
17
|
-
"role_file_sha",
|
|
18
|
-
"session_id",
|
|
19
|
-
"to",
|
|
20
|
-
"targets",
|
|
21
|
-
"delivered_count",
|
|
22
|
-
"failed_count",
|
|
23
|
-
"fallback_path",
|
|
24
|
-
"suggestion",
|
|
25
|
-
]
|
|
26
|
-
compact = {key: result[key] for key in keys if key in result}
|
|
27
|
-
if str(result.get("status") or "").startswith("fanout_"):
|
|
28
|
-
for key in ("deliveries", "recipients"):
|
|
29
|
-
if key in result:
|
|
30
|
-
compact[key] = result[key]
|
|
31
|
-
return compact
|
|
32
|
-
keys = [
|
|
33
|
-
"ok",
|
|
34
|
-
"status",
|
|
35
|
-
"message_id",
|
|
36
|
-
"to",
|
|
37
|
-
"targets",
|
|
38
|
-
"delivered_count",
|
|
39
|
-
"failed_count",
|
|
40
|
-
"submitted",
|
|
41
|
-
"visible",
|
|
42
|
-
"queued",
|
|
43
|
-
"durably_stored",
|
|
44
|
-
"result_id",
|
|
45
|
-
"task_id",
|
|
46
|
-
"agent_id",
|
|
47
|
-
"new_agent_id",
|
|
48
|
-
"source_agent_id",
|
|
49
|
-
"role_file_sha",
|
|
50
|
-
"session_id",
|
|
51
|
-
"leader_notified",
|
|
52
|
-
"notification_message_id",
|
|
53
|
-
"notification_status",
|
|
54
|
-
"notification_channel",
|
|
55
|
-
"notification_event_id",
|
|
56
|
-
]
|
|
57
|
-
compact = {key: result[key] for key in keys if key in result}
|
|
58
|
-
if str(result.get("status") or "").startswith("fanout_"):
|
|
59
|
-
for key in ("deliveries", "recipients"):
|
|
60
|
-
if key in result:
|
|
61
|
-
compact[key] = result[key]
|
|
62
|
-
if "acknowledged_messages" in result:
|
|
63
|
-
compact["acknowledged_count"] = len(result.get("acknowledged_messages") or [])
|
|
64
|
-
return compact or {"ok": True}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
def _normalize_report_envelope(env: dict[str, Any]) -> dict[str, Any]:
|
|
68
|
-
summary = _text(env.get("summary")) or "completed"
|
|
69
|
-
return {
|
|
70
|
-
"schema_version": "result_envelope_v1",
|
|
71
|
-
"task_id": _text(env.get("task_id")) or "manual",
|
|
72
|
-
"agent_id": _text(env.get("agent_id")) or "unknown",
|
|
73
|
-
"status": _normalize_result_status(env.get("status")),
|
|
74
|
-
"summary": summary,
|
|
75
|
-
"changes": _normalize_changes(env.get("changes"), summary),
|
|
76
|
-
"tests": _normalize_tests(env.get("tests")),
|
|
77
|
-
"risks": _normalize_risks(env.get("risks")),
|
|
78
|
-
"artifacts": _normalize_artifacts(env.get("artifacts")),
|
|
79
|
-
"next_actions": _normalize_next_actions(env.get("next_actions")),
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
def _items(value: Any) -> list[Any]:
|
|
84
|
-
if value is None:
|
|
85
|
-
return []
|
|
86
|
-
if isinstance(value, list):
|
|
87
|
-
return value
|
|
88
|
-
return [value]
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
def _text(value: Any) -> str | None:
|
|
92
|
-
if value is None:
|
|
93
|
-
return None
|
|
94
|
-
text = str(value).strip()
|
|
95
|
-
return text or None
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
def _first_text(item: dict[str, Any], *keys: str) -> str | None:
|
|
99
|
-
for key in keys:
|
|
100
|
-
text = _text(item.get(key))
|
|
101
|
-
if text:
|
|
102
|
-
return text
|
|
103
|
-
return None
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
def _normalize_result_status(value: Any) -> str:
|
|
107
|
-
text = (_text(value) or "success").lower().replace("-", "_").replace(" ", "_")
|
|
108
|
-
mapping = {
|
|
109
|
-
"ok": "success",
|
|
110
|
-
"done": "success",
|
|
111
|
-
"complete": "success",
|
|
112
|
-
"completed": "success",
|
|
113
|
-
"passed": "success",
|
|
114
|
-
"pass": "success",
|
|
115
|
-
"blocked": "blocked",
|
|
116
|
-
"block": "blocked",
|
|
117
|
-
"failed": "failed",
|
|
118
|
-
"fail": "failed",
|
|
119
|
-
"error": "failed",
|
|
120
|
-
"partial": "partial",
|
|
121
|
-
"partially_done": "partial",
|
|
122
|
-
}
|
|
123
|
-
return mapping.get(text, text if text in {"success", "blocked", "failed", "partial"} else "success")
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
def _normalize_changes(value: Any, fallback_summary: str) -> list[dict[str, str]]:
|
|
127
|
-
changes: list[dict[str, str]] = []
|
|
128
|
-
for item in _items(value):
|
|
129
|
-
if not isinstance(item, dict):
|
|
130
|
-
continue
|
|
131
|
-
path = _first_text(item, "path", "file", "filepath", "filename")
|
|
132
|
-
if not path:
|
|
133
|
-
continue
|
|
134
|
-
description = _first_text(item, "description", "summary", "detail", "details", "message") or fallback_summary
|
|
135
|
-
changes.append(
|
|
136
|
-
{
|
|
137
|
-
"path": path,
|
|
138
|
-
"kind": _normalize_change_kind(_first_text(item, "kind", "type", "action"), description),
|
|
139
|
-
"description": description,
|
|
140
|
-
}
|
|
141
|
-
)
|
|
142
|
-
return changes
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
def _normalize_change_kind(value: str | None, description: str) -> str:
|
|
146
|
-
text = (value or "").strip().lower().replace("-", "_").replace(" ", "_")
|
|
147
|
-
if text in {"created", "modified", "deleted", "observed"}:
|
|
148
|
-
return text
|
|
149
|
-
mapping = {
|
|
150
|
-
"create": "created",
|
|
151
|
-
"added": "created",
|
|
152
|
-
"add": "created",
|
|
153
|
-
"new": "created",
|
|
154
|
-
"changed": "modified",
|
|
155
|
-
"change": "modified",
|
|
156
|
-
"updated": "modified",
|
|
157
|
-
"update": "modified",
|
|
158
|
-
"edited": "modified",
|
|
159
|
-
"edit": "modified",
|
|
160
|
-
"removed": "deleted",
|
|
161
|
-
"remove": "deleted",
|
|
162
|
-
"delete": "deleted",
|
|
163
|
-
"observe": "observed",
|
|
164
|
-
"observed": "observed",
|
|
165
|
-
"inspected": "observed",
|
|
166
|
-
"inspect": "observed",
|
|
167
|
-
}
|
|
168
|
-
if text in mapping:
|
|
169
|
-
return mapping[text]
|
|
170
|
-
description_text = description.lower()
|
|
171
|
-
if any(word in description_text for word in ["created", "added", "new file"]):
|
|
172
|
-
return "created"
|
|
173
|
-
if any(word in description_text for word in ["deleted", "removed"]):
|
|
174
|
-
return "deleted"
|
|
175
|
-
if any(word in description_text for word in ["observed", "inspected", "verified"]):
|
|
176
|
-
return "observed"
|
|
177
|
-
return "modified"
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
def _normalize_tests(value: Any) -> list[dict[str, str]]:
|
|
181
|
-
tests: list[dict[str, str]] = []
|
|
182
|
-
for item in _items(value):
|
|
183
|
-
if not isinstance(item, dict):
|
|
184
|
-
command = _text(item)
|
|
185
|
-
if command:
|
|
186
|
-
tests.append({"command": command, "status": "not_run"})
|
|
187
|
-
continue
|
|
188
|
-
command = _first_text(item, "command", "cmd", "name", "test")
|
|
189
|
-
if not command:
|
|
190
|
-
continue
|
|
191
|
-
test = {"command": command, "status": _normalize_test_status(item.get("status"))}
|
|
192
|
-
detail = _first_text(item, "detail", "output", "stdout", "stderr", "summary", "message")
|
|
193
|
-
if detail:
|
|
194
|
-
test["detail"] = detail
|
|
195
|
-
tests.append(test)
|
|
196
|
-
return tests
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
def _normalize_test_status(value: Any) -> str:
|
|
200
|
-
text = (_text(value) or "not_run").lower().replace("-", "_").replace(" ", "_")
|
|
201
|
-
mapping = {
|
|
202
|
-
"pass": "passed",
|
|
203
|
-
"ok": "passed",
|
|
204
|
-
"success": "passed",
|
|
205
|
-
"fail": "failed",
|
|
206
|
-
"error": "failed",
|
|
207
|
-
"notrun": "not_run",
|
|
208
|
-
"not_run": "not_run",
|
|
209
|
-
"notrun_yet": "not_run",
|
|
210
|
-
"skip": "skipped",
|
|
211
|
-
}
|
|
212
|
-
return mapping.get(text, text if text in {"passed", "failed", "not_run", "skipped"} else "not_run")
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
def _normalize_risks(value: Any) -> list[dict[str, str]]:
|
|
216
|
-
risks: list[dict[str, str]] = []
|
|
217
|
-
for item in _items(value):
|
|
218
|
-
if not isinstance(item, dict):
|
|
219
|
-
description = _text(item)
|
|
220
|
-
if description:
|
|
221
|
-
risks.append({"severity": "low", "description": description})
|
|
222
|
-
continue
|
|
223
|
-
description = _first_text(item, "description", "summary", "detail", "message")
|
|
224
|
-
if not description:
|
|
225
|
-
continue
|
|
226
|
-
severity = (_first_text(item, "severity", "level") or "low").lower()
|
|
227
|
-
if severity not in {"low", "medium", "high"}:
|
|
228
|
-
severity = "low"
|
|
229
|
-
risks.append({"severity": severity, "description": description})
|
|
230
|
-
return risks
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
def _normalize_artifacts(value: Any) -> list[dict[str, str]]:
|
|
234
|
-
artifacts: list[dict[str, str]] = []
|
|
235
|
-
for item in _items(value):
|
|
236
|
-
if not isinstance(item, dict):
|
|
237
|
-
path = _text(item)
|
|
238
|
-
if path:
|
|
239
|
-
artifacts.append({"path": path, "description": path})
|
|
240
|
-
continue
|
|
241
|
-
path = _first_text(item, "path", "file", "filepath", "filename")
|
|
242
|
-
if not path:
|
|
243
|
-
continue
|
|
244
|
-
artifacts.append({"path": path, "description": _first_text(item, "description", "summary", "detail") or path})
|
|
245
|
-
return artifacts
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
def _normalize_next_actions(value: Any) -> list[dict[str, str]]:
|
|
249
|
-
actions: list[dict[str, str]] = []
|
|
250
|
-
for item in _items(value):
|
|
251
|
-
if isinstance(item, dict):
|
|
252
|
-
description = _first_text(item, "description", "summary", "action", "todo", "message")
|
|
253
|
-
else:
|
|
254
|
-
description = _text(item)
|
|
255
|
-
if description:
|
|
256
|
-
actions.append({"description": description})
|
|
257
|
-
return actions
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import argparse
|
|
4
|
-
import json
|
|
5
|
-
import sys
|
|
6
|
-
from pathlib import Path
|
|
7
|
-
from typing import Any
|
|
8
|
-
|
|
9
|
-
from team_agent.mcp_server.contracts import TOOLS
|
|
10
|
-
from team_agent.mcp_server.tools import TeamOrchestratorTools
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
ARGUMENT_ERROR_TYPES = (TypeError, ValueError, KeyError, AttributeError)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def dispatch(tools: TeamOrchestratorTools, request: dict[str, Any]) -> dict[str, Any]:
|
|
17
|
-
tool = request.get("tool") or request.get("method")
|
|
18
|
-
args = request.get("arguments") or request.get("params") or {}
|
|
19
|
-
if tool == "assign_task":
|
|
20
|
-
return tools.assign_task(**args)
|
|
21
|
-
if tool == "send_message":
|
|
22
|
-
return tools.send_message(**args)
|
|
23
|
-
if tool == "report_result":
|
|
24
|
-
return tools.report_result(**args)
|
|
25
|
-
if tool == "update_state":
|
|
26
|
-
return tools.update_state(**args)
|
|
27
|
-
if tool == "get_team_status":
|
|
28
|
-
return tools.get_team_status()
|
|
29
|
-
if tool == "stop_agent":
|
|
30
|
-
return tools.stop_agent(**args)
|
|
31
|
-
if tool == "reset_agent":
|
|
32
|
-
return tools.reset_agent(**args)
|
|
33
|
-
if tool == "add_agent":
|
|
34
|
-
return tools.add_agent(**args)
|
|
35
|
-
if tool == "fork_agent":
|
|
36
|
-
return tools.fork_agent(**args)
|
|
37
|
-
if tool == "request_human":
|
|
38
|
-
return tools.request_human(**args)
|
|
39
|
-
if tool == "stuck_list":
|
|
40
|
-
return tools.stuck_list()
|
|
41
|
-
if tool == "stuck_cancel":
|
|
42
|
-
return tools.stuck_cancel(**args)
|
|
43
|
-
return _tool_error_result("unknown_tool", f"unknown tool {tool!r}", exc_type="UnknownTool")
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def handle_mcp(tools: TeamOrchestratorTools, request: dict[str, Any]) -> dict[str, Any] | None:
|
|
47
|
-
method = request.get("method")
|
|
48
|
-
msg_id = request.get("id")
|
|
49
|
-
if method and method.startswith("notifications/"):
|
|
50
|
-
return None
|
|
51
|
-
if method == "initialize":
|
|
52
|
-
return {
|
|
53
|
-
"jsonrpc": "2.0",
|
|
54
|
-
"id": msg_id,
|
|
55
|
-
"result": {
|
|
56
|
-
"protocolVersion": request.get("params", {}).get("protocolVersion", "2024-11-05"),
|
|
57
|
-
"capabilities": {"tools": {}},
|
|
58
|
-
"serverInfo": {"name": "team_orchestrator", "version": "0.1.4"},
|
|
59
|
-
},
|
|
60
|
-
}
|
|
61
|
-
if method == "tools/list":
|
|
62
|
-
return {"jsonrpc": "2.0", "id": msg_id, "result": {"tools": TOOLS}}
|
|
63
|
-
if method == "tools/call":
|
|
64
|
-
params = request.get("params", {})
|
|
65
|
-
name = params.get("name")
|
|
66
|
-
arguments = params.get("arguments") or {}
|
|
67
|
-
try:
|
|
68
|
-
result = dispatch(tools, {"tool": name, "arguments": arguments})
|
|
69
|
-
except ARGUMENT_ERROR_TYPES as exc:
|
|
70
|
-
result = _tool_exception_result(exc, "invalid_tool_arguments")
|
|
71
|
-
except Exception as exc:
|
|
72
|
-
result = _tool_exception_result(exc, "internal_runtime_error")
|
|
73
|
-
is_error = result.get("ok") is False
|
|
74
|
-
return {
|
|
75
|
-
"jsonrpc": "2.0",
|
|
76
|
-
"id": msg_id,
|
|
77
|
-
"result": {
|
|
78
|
-
"content": [
|
|
79
|
-
{
|
|
80
|
-
"type": "text",
|
|
81
|
-
"text": json.dumps(result, ensure_ascii=False),
|
|
82
|
-
}
|
|
83
|
-
],
|
|
84
|
-
"isError": is_error,
|
|
85
|
-
},
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
"jsonrpc": "2.0",
|
|
89
|
-
"id": msg_id,
|
|
90
|
-
"error": {"code": -32601, "message": f"unknown method {method!r}"},
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
def _tool_exception_result(exc: Exception, reason: str) -> dict[str, str | bool]:
|
|
95
|
-
return _tool_error_result(reason, _public_exception_message(exc), exc_type=type(exc).__name__)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
def _tool_error_result(reason: str, message: str, exc_type: str) -> dict[str, str | bool]:
|
|
99
|
-
return {
|
|
100
|
-
"ok": False,
|
|
101
|
-
"reason": reason,
|
|
102
|
-
"error_code": reason,
|
|
103
|
-
"exc_type": exc_type,
|
|
104
|
-
"message": message,
|
|
105
|
-
"error": message,
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
def _public_exception_message(exc: Exception) -> str:
|
|
110
|
-
message = str(exc).replace("\n", " ").strip()
|
|
111
|
-
return message[:200] if message else type(exc).__name__
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
def main(argv: list[str] | None = None) -> None:
|
|
115
|
-
parser = argparse.ArgumentParser(description="TeamSpec team_orchestrator MCP stdio server")
|
|
116
|
-
parser.add_argument("--workspace", default=".", help="Workspace containing .team/runtime")
|
|
117
|
-
args = parser.parse_args(argv)
|
|
118
|
-
tools = TeamOrchestratorTools(Path(args.workspace))
|
|
119
|
-
for line in sys.stdin:
|
|
120
|
-
line = line.strip()
|
|
121
|
-
if not line:
|
|
122
|
-
continue
|
|
123
|
-
try:
|
|
124
|
-
request = json.loads(line)
|
|
125
|
-
if request.get("jsonrpc") == "2.0":
|
|
126
|
-
response = handle_mcp(tools, request)
|
|
127
|
-
if response is None:
|
|
128
|
-
continue
|
|
129
|
-
sys.stdout.write(json.dumps(response, ensure_ascii=False) + "\n")
|
|
130
|
-
sys.stdout.flush()
|
|
131
|
-
continue
|
|
132
|
-
result = dispatch(tools, request)
|
|
133
|
-
sys.stdout.write(json.dumps({"ok": result.get("ok", True), "result": result}, ensure_ascii=False) + "\n")
|
|
134
|
-
sys.stdout.flush()
|
|
135
|
-
except Exception as exc: # MCP transports need errors surfaced on stdout.
|
|
136
|
-
if "request" in locals() and isinstance(request, dict) and request.get("jsonrpc") == "2.0":
|
|
137
|
-
sys.stdout.write(
|
|
138
|
-
json.dumps(
|
|
139
|
-
{
|
|
140
|
-
"jsonrpc": "2.0",
|
|
141
|
-
"id": request.get("id"),
|
|
142
|
-
"error": {"code": -32000, "message": str(exc)},
|
|
143
|
-
},
|
|
144
|
-
ensure_ascii=False,
|
|
145
|
-
)
|
|
146
|
-
+ "\n"
|
|
147
|
-
)
|
|
148
|
-
else:
|
|
149
|
-
sys.stdout.write(json.dumps({"ok": False, "error": str(exc)}, ensure_ascii=False) + "\n")
|
|
150
|
-
sys.stdout.flush()
|