@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,324 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import json
|
|
4
|
-
import shutil
|
|
5
|
-
import time
|
|
6
|
-
from pathlib import Path
|
|
7
|
-
from typing import Any
|
|
8
|
-
|
|
9
|
-
from team_agent.diagnose.preflight import ensure_profiles_for_roles, preflight
|
|
10
|
-
from team_agent.events import EventLog
|
|
11
|
-
from team_agent.message_store import MessageStore
|
|
12
|
-
from team_agent.paths import logs_dir, team_workspace
|
|
13
|
-
from team_agent.spec import load_spec
|
|
14
|
-
from team_agent.state import load_runtime_state, save_runtime_state, write_team_state
|
|
15
|
-
from team_agent.task_graph import TASK_STATUSES
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def quick_start(
|
|
19
|
-
agents_dir: Path,
|
|
20
|
-
name: str | None = None,
|
|
21
|
-
yes: bool = False,
|
|
22
|
-
fresh: bool = False,
|
|
23
|
-
team_id: str | None = None,
|
|
24
|
-
) -> dict[str, Any]:
|
|
25
|
-
from team_agent.runtime import (
|
|
26
|
-
RuntimeError,
|
|
27
|
-
_compile_team_dir_spec,
|
|
28
|
-
_quick_start_existing_context,
|
|
29
|
-
ensure_workspace_dirs,
|
|
30
|
-
launch,
|
|
31
|
-
start_coordinator,
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
team_dir = prepare_quick_start_team(agents_dir.resolve(), Path.cwd().resolve(), name, team_id=team_id)
|
|
35
|
-
workspace = team_workspace(team_dir)
|
|
36
|
-
ensure_workspace_dirs(workspace)
|
|
37
|
-
ensure_profiles_for_roles(team_dir)
|
|
38
|
-
compiled = _compile_team_dir_spec(team_dir, workspace)
|
|
39
|
-
spec_path = team_dir / "team.spec.yaml"
|
|
40
|
-
existing = _quick_start_existing_context(workspace, compiled["spec"]["runtime"]["session_name"])
|
|
41
|
-
if existing and not fresh:
|
|
42
|
-
return {
|
|
43
|
-
"ok": False,
|
|
44
|
-
"step": "existing_runtime_state",
|
|
45
|
-
"summary": (
|
|
46
|
-
"quick-start would start fresh workers from role docs for an existing team. "
|
|
47
|
-
"Use restart to continue the previous worker context, or pass --fresh to intentionally start new workers."
|
|
48
|
-
),
|
|
49
|
-
"team": existing.get("team_name"),
|
|
50
|
-
"session_name": existing.get("session_name"),
|
|
51
|
-
"state_path": existing.get("state_path"),
|
|
52
|
-
"next_actions": [
|
|
53
|
-
f"team-agent restart {workspace} --team {existing.get('session_name')}",
|
|
54
|
-
f"team-agent quick-start {team_dir} --fresh",
|
|
55
|
-
],
|
|
56
|
-
}
|
|
57
|
-
preflight_result = preflight(team_dir)
|
|
58
|
-
if not preflight_result.get("ok"):
|
|
59
|
-
return {
|
|
60
|
-
"ok": False,
|
|
61
|
-
"step": "preflight",
|
|
62
|
-
"summary": preflight_result.get("summary"),
|
|
63
|
-
"details_log": preflight_result.get("details_log"),
|
|
64
|
-
"blockers": preflight_result.get("blockers", []),
|
|
65
|
-
"next_actions": preflight_result.get("next_actions", []),
|
|
66
|
-
"checks": preflight_result.get("checks", []),
|
|
67
|
-
}
|
|
68
|
-
dangerous = bool(compiled["spec"].get("runtime", {}).get("dangerous_auto_approve"))
|
|
69
|
-
if dangerous and not yes:
|
|
70
|
-
raise RuntimeError("quick-start requires --yes when dangerous_auto_approve is true")
|
|
71
|
-
launched = launch(spec_path, auto_approve=True, skip_profile_smoke=True)
|
|
72
|
-
from team_agent.leader import autobind_leader_receiver_from_env
|
|
73
|
-
leader_provider = str(compiled["spec"].get("leader", {}).get("provider") or "codex")
|
|
74
|
-
autobind_leader_receiver_from_env(workspace, leader_provider, source="quick_start")
|
|
75
|
-
coordinator = start_coordinator(workspace)
|
|
76
|
-
ready = wait_ready(workspace, timeout=120)
|
|
77
|
-
summary = (
|
|
78
|
-
f"team {compiled['spec']['team']['name']} ready: "
|
|
79
|
-
f"{len(launched.get('agents', []))} agent"
|
|
80
|
-
f"{'' if len(launched.get('agents', [])) == 1 else 's'} "
|
|
81
|
-
f"in session {launched.get('session_name')} (coordinator pid {coordinator.get('pid')})"
|
|
82
|
-
)
|
|
83
|
-
ready_signal = (
|
|
84
|
-
"quick-start completed; workers are ready. "
|
|
85
|
-
"Do not wait, sleep, or poll status after this success line unless diagnosing a failure."
|
|
86
|
-
)
|
|
87
|
-
details_log = logs_dir(workspace) / f"quick-start-{int(time.time())}.json"
|
|
88
|
-
details_log.write_text(
|
|
89
|
-
json.dumps(
|
|
90
|
-
{
|
|
91
|
-
"team_dir": str(team_dir),
|
|
92
|
-
"preflight": preflight_result,
|
|
93
|
-
"compile": compiled,
|
|
94
|
-
"launch": launched,
|
|
95
|
-
"ready": ready,
|
|
96
|
-
"coordinator": coordinator,
|
|
97
|
-
},
|
|
98
|
-
indent=2,
|
|
99
|
-
ensure_ascii=False,
|
|
100
|
-
),
|
|
101
|
-
encoding="utf-8",
|
|
102
|
-
)
|
|
103
|
-
return {
|
|
104
|
-
"ok": bool(launched.get("ok") and ready.get("ok") and coordinator.get("ok")),
|
|
105
|
-
"summary": summary,
|
|
106
|
-
"ready_signal": ready_signal,
|
|
107
|
-
"next_actions": ["Dispatch work with team-agent send, or return control to the user."],
|
|
108
|
-
"team_dir": str(team_dir),
|
|
109
|
-
"spec": str(spec_path),
|
|
110
|
-
"session_name": launched.get("session_name"),
|
|
111
|
-
"coordinator": coordinator,
|
|
112
|
-
"details_log": str(details_log),
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
def prepare_quick_start_team(agents_dir: Path, workspace: Path, name: str | None, team_id: str | None = None) -> Path:
|
|
117
|
-
from team_agent.runtime import RuntimeError, _safe_snapshot_name
|
|
118
|
-
|
|
119
|
-
if (agents_dir / "TEAM.md").exists() and (agents_dir / "agents").is_dir():
|
|
120
|
-
return agents_dir
|
|
121
|
-
team_source = agents_dir / "TEAM.md"
|
|
122
|
-
role_docs = [path for path in sorted(agents_dir.glob("*.md")) if path.name != "TEAM.md"] if agents_dir.is_dir() else []
|
|
123
|
-
if not role_docs:
|
|
124
|
-
raise RuntimeError(f"{agents_dir}: 该目录缺角色定义文件 — 先用 'team-agent quick-start <roles-dir>' 从 role .md 创建一个新 team")
|
|
125
|
-
team_dir = workspace / ".team" / (_safe_snapshot_name(team_id) if team_id else "current")
|
|
126
|
-
target_agents = team_dir / "agents"
|
|
127
|
-
target_profiles = team_dir / "profiles"
|
|
128
|
-
target_agents.mkdir(parents=True, exist_ok=True)
|
|
129
|
-
target_profiles.mkdir(parents=True, exist_ok=True)
|
|
130
|
-
for role_doc in role_docs:
|
|
131
|
-
shutil.copy2(role_doc, target_agents / role_doc.name)
|
|
132
|
-
team_doc = team_dir / "TEAM.md"
|
|
133
|
-
if team_source.exists():
|
|
134
|
-
shutil.copy2(team_source, team_doc)
|
|
135
|
-
if name:
|
|
136
|
-
EventLog(workspace).write("quick_start.name_ignored_existing_team_doc", name=name, team_doc=str(team_doc))
|
|
137
|
-
elif not team_doc.exists():
|
|
138
|
-
team_name = name or agents_dir.name.replace(" ", "-") or "team-agent-team"
|
|
139
|
-
team_doc.write_text(
|
|
140
|
-
f"---\nname: {team_name}\nobjective: Quick-start Team Agent team.\n---\n\nQuick-start team.\n",
|
|
141
|
-
encoding="utf-8",
|
|
142
|
-
)
|
|
143
|
-
elif name:
|
|
144
|
-
# Keep the existing body; name override is only for fresh TEAM.md to avoid hand-editing user docs.
|
|
145
|
-
EventLog(workspace).write("quick_start.name_ignored_existing_team_doc", name=name, team_doc=str(team_doc))
|
|
146
|
-
return team_dir
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
def wait_ready(workspace: Path, timeout: int = 120) -> dict[str, Any]:
|
|
150
|
-
from team_agent.runtime import status
|
|
151
|
-
|
|
152
|
-
start_time = time.monotonic()
|
|
153
|
-
last: dict[str, Any] = {}
|
|
154
|
-
trust_answered = False
|
|
155
|
-
while time.monotonic() - start_time <= timeout:
|
|
156
|
-
last = status(workspace, as_json=True)
|
|
157
|
-
agents = last.get("agents", {})
|
|
158
|
-
if agents and any(agent.get("status") == "awaiting_trust_prompt" for agent in agents.values()):
|
|
159
|
-
if _auto_answer_ready_wait_trust_prompt(workspace, last):
|
|
160
|
-
trust_answered = True
|
|
161
|
-
time.sleep(0.5)
|
|
162
|
-
last = status(workspace, as_json=True)
|
|
163
|
-
agents = last.get("agents", {})
|
|
164
|
-
if agents and all(agent.get("tmux_window_present") and agent.get("status") in {"running", "busy"} for agent in agents.values()):
|
|
165
|
-
break
|
|
166
|
-
continue
|
|
167
|
-
break
|
|
168
|
-
if agents and all(agent.get("tmux_window_present") and agent.get("status") in {"running", "busy"} for agent in agents.values()):
|
|
169
|
-
break
|
|
170
|
-
time.sleep(1.0)
|
|
171
|
-
readiness = {
|
|
172
|
-
"process_started": bool(last.get("tmux_session_present")),
|
|
173
|
-
"cli_prompt_ready": all(agent.get("status") in {"running", "busy"} for agent in last.get("agents", {}).values()) if last.get("agents") else False,
|
|
174
|
-
"mcp_ready": all(Path(agent.get("mcp_config", "")).exists() for agent in last.get("agents", {}).values()) if last.get("agents") else False,
|
|
175
|
-
"task_prompt_delivered": bool(MessageStore(workspace).message_counts()),
|
|
176
|
-
}
|
|
177
|
-
if trust_answered and readiness["process_started"] and readiness["mcp_ready"]:
|
|
178
|
-
readiness["cli_prompt_ready"] = True
|
|
179
|
-
ok = readiness["process_started"] and readiness["cli_prompt_ready"] and readiness["mcp_ready"]
|
|
180
|
-
awaiting_trust = any(agent.get("status") == "awaiting_trust_prompt" for agent in last.get("agents", {}).values()) if last.get("agents") else False
|
|
181
|
-
if awaiting_trust and not trust_answered and _auto_answer_ready_wait_trust_prompt(workspace, last):
|
|
182
|
-
trust_answered = True
|
|
183
|
-
if readiness["process_started"] and readiness["mcp_ready"]:
|
|
184
|
-
readiness["cli_prompt_ready"] = True
|
|
185
|
-
ok = True
|
|
186
|
-
details_log = logs_dir(workspace) / f"wait-ready-{int(time.time())}.json"
|
|
187
|
-
details_log.write_text(json.dumps({"readiness": readiness, "status": last}, indent=2, ensure_ascii=False), encoding="utf-8")
|
|
188
|
-
if awaiting_trust and not trust_answered:
|
|
189
|
-
pending = {
|
|
190
|
-
"ok": False,
|
|
191
|
-
"status": "pending",
|
|
192
|
-
"reason": "awaiting_trust_prompt",
|
|
193
|
-
"summary": "workers pending: awaiting_trust_prompt",
|
|
194
|
-
"next_actions": ["Answer the Codex workspace trust prompt in the worker pane."],
|
|
195
|
-
"details_log": str(details_log),
|
|
196
|
-
"readiness": readiness,
|
|
197
|
-
}
|
|
198
|
-
return pending
|
|
199
|
-
return {
|
|
200
|
-
"ok": ok,
|
|
201
|
-
"summary": "workers ready" if ok else "workers not fully ready before timeout",
|
|
202
|
-
"next_actions": ["Dispatch a task with team-agent send."] if ok else ["Run team-agent diagnose --json."],
|
|
203
|
-
"details_log": str(details_log),
|
|
204
|
-
"readiness": readiness,
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
def _auto_answer_ready_wait_trust_prompt(workspace: Path, status_result: dict[str, Any]) -> bool:
|
|
209
|
-
from team_agent.messaging.leader_panes import attempt_trust_auto_answer
|
|
210
|
-
from team_agent.runtime import run_cmd
|
|
211
|
-
|
|
212
|
-
state = load_runtime_state(workspace)
|
|
213
|
-
session_name = status_result.get("session_name") or state.get("session_name")
|
|
214
|
-
event_log = EventLog(workspace)
|
|
215
|
-
state["workspace_root"] = str(workspace)
|
|
216
|
-
state["trust_auto_answer_stage"] = "quick_start_ready_wait"
|
|
217
|
-
answered = False
|
|
218
|
-
for agent_id, agent in (status_result.get("agents") or {}).items():
|
|
219
|
-
if not isinstance(agent, dict) or agent.get("status") != "awaiting_trust_prompt":
|
|
220
|
-
continue
|
|
221
|
-
state_agent = state.get("agents", {}).get(agent_id, {}) if isinstance(state.get("agents"), dict) else {}
|
|
222
|
-
display = agent.get("display") if isinstance(agent.get("display"), dict) else {}
|
|
223
|
-
state_display = state_agent.get("display") if isinstance(state_agent.get("display"), dict) else {}
|
|
224
|
-
pane_id = (
|
|
225
|
-
agent.get("pane_id")
|
|
226
|
-
or display.get("pane_id")
|
|
227
|
-
or agent.get("target")
|
|
228
|
-
or agent.get("tmux_target")
|
|
229
|
-
or state_agent.get("pane_id")
|
|
230
|
-
or state_display.get("pane_id")
|
|
231
|
-
or state_agent.get("target")
|
|
232
|
-
or state_agent.get("tmux_target")
|
|
233
|
-
or status_result.get("pane_id")
|
|
234
|
-
or status_result.get("target")
|
|
235
|
-
or status_result.get("tmux_target")
|
|
236
|
-
)
|
|
237
|
-
window = agent.get("window") or state_agent.get("window") or agent_id
|
|
238
|
-
agent_session = session_name or agent.get("session_name") or state_agent.get("session_name")
|
|
239
|
-
if pane_id:
|
|
240
|
-
target = str(pane_id)
|
|
241
|
-
elif agent_session:
|
|
242
|
-
target = f"{agent_session}:{window}"
|
|
243
|
-
else:
|
|
244
|
-
target = str(window)
|
|
245
|
-
if not str(target).startswith("%"):
|
|
246
|
-
panes = run_cmd(["tmux", "list-panes", "-a", "-F", "#{pane_id}\t#{window_name}"], timeout=5)
|
|
247
|
-
if panes.returncode == 0:
|
|
248
|
-
for line in panes.stdout.splitlines():
|
|
249
|
-
pane_id_text, _, window_name = line.partition("\t")
|
|
250
|
-
if window_name == window and pane_id_text:
|
|
251
|
-
target = pane_id_text
|
|
252
|
-
break
|
|
253
|
-
pane = run_cmd(["tmux", "display-message", "-p", "-t", target, "#{pane_id}"], timeout=5)
|
|
254
|
-
if pane.returncode == 0 and pane.stdout.strip():
|
|
255
|
-
target = pane.stdout.strip()
|
|
256
|
-
capture_tail = str(agent.get("pane_capture_tail") or agent.get("capture_tail") or "")
|
|
257
|
-
if not capture_tail:
|
|
258
|
-
capture = run_cmd(["tmux", "capture-pane", "-p", "-t", target], timeout=5)
|
|
259
|
-
if capture.returncode != 0:
|
|
260
|
-
event_log.write("quick_start.trust_auto_answer_capture_failed", agent_id=agent_id, target=target, error=capture.stderr.strip())
|
|
261
|
-
continue
|
|
262
|
-
capture_tail = capture.stdout
|
|
263
|
-
result = attempt_trust_auto_answer(workspace, target, capture_tail, event_log, state=state)
|
|
264
|
-
event_log.write("quick_start.trust_auto_answer_attempted", agent_id=agent_id, target=target, **result)
|
|
265
|
-
answered = answered or bool(result.get("answered"))
|
|
266
|
-
return answered
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
def settle(workspace: Path) -> dict[str, Any]:
|
|
270
|
-
from team_agent.runtime import collect, status
|
|
271
|
-
|
|
272
|
-
collected = collect(workspace)
|
|
273
|
-
current = status(workspace, as_json=True)
|
|
274
|
-
details_log = logs_dir(workspace) / f"settle-{int(time.time())}.json"
|
|
275
|
-
details_log.write_text(json.dumps({"collect": collected, "status": current}, indent=2, ensure_ascii=False), encoding="utf-8")
|
|
276
|
-
return {
|
|
277
|
-
"ok": collected.get("ok", False),
|
|
278
|
-
"summary": f"collected {len(collected.get('collected', []))} result(s)",
|
|
279
|
-
"next_actions": ["Review team_state.md and decide whether to continue or shutdown."],
|
|
280
|
-
"details_log": str(details_log),
|
|
281
|
-
"collect": collected,
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
def repair_state(
|
|
286
|
-
workspace: Path,
|
|
287
|
-
task_id: str,
|
|
288
|
-
assignee: str | None = None,
|
|
289
|
-
status_value: str | None = None,
|
|
290
|
-
summary: str | None = None,
|
|
291
|
-
) -> dict[str, Any]:
|
|
292
|
-
from team_agent.runtime import RuntimeError, _find_task, _leader_id
|
|
293
|
-
|
|
294
|
-
state = load_runtime_state(workspace)
|
|
295
|
-
spec_path = Path(state.get("spec_path", workspace / "team.spec.yaml"))
|
|
296
|
-
spec = load_spec(spec_path)
|
|
297
|
-
task = _find_task(state.get("tasks", []), task_id)
|
|
298
|
-
if assignee is not None:
|
|
299
|
-
valid_agents = {agent["id"] for agent in spec.get("agents", [])}
|
|
300
|
-
valid_agents.add(_leader_id(state, spec))
|
|
301
|
-
if assignee not in valid_agents:
|
|
302
|
-
raise RuntimeError(f"unknown agent id for repair: {assignee}")
|
|
303
|
-
if status_value is not None and status_value not in TASK_STATUSES:
|
|
304
|
-
raise RuntimeError(f"unknown task status for repair: {status_value}")
|
|
305
|
-
before = {
|
|
306
|
-
"assignee": task.get("assignee"),
|
|
307
|
-
"status": task.get("status"),
|
|
308
|
-
"last_result_summary": task.get("last_result_summary"),
|
|
309
|
-
}
|
|
310
|
-
if assignee is not None:
|
|
311
|
-
task["assignee"] = assignee
|
|
312
|
-
if status_value is not None:
|
|
313
|
-
task["status"] = status_value
|
|
314
|
-
if summary is not None:
|
|
315
|
-
task["last_result_summary"] = summary
|
|
316
|
-
after = {
|
|
317
|
-
"assignee": task.get("assignee"),
|
|
318
|
-
"status": task.get("status"),
|
|
319
|
-
"last_result_summary": task.get("last_result_summary"),
|
|
320
|
-
}
|
|
321
|
-
save_runtime_state(workspace, state)
|
|
322
|
-
state_path = write_team_state(workspace, spec, state)
|
|
323
|
-
EventLog(workspace).write("repair_state.task", task_id=task_id, before=before, after=after)
|
|
324
|
-
return {"ok": True, "task_id": task_id, "before": before, "after": after, "state_file": str(state_path)}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from team_agent.display.adaptive import (
|
|
4
|
-
ADAPTIVE_BLOCK_REASONS,
|
|
5
|
-
adaptive_blocked,
|
|
6
|
-
close_adaptive_display,
|
|
7
|
-
close_adaptive_windows,
|
|
8
|
-
open_adaptive_display,
|
|
9
|
-
prepare_adaptive_windows,
|
|
10
|
-
probe_display_capabilities,
|
|
11
|
-
)
|
|
12
|
-
from team_agent.display.backend import (
|
|
13
|
-
ADAPTIVE_DISPLAY_BACKEND,
|
|
14
|
-
DISPLAY_BACKENDS_WITH_WORKER_VIEWS,
|
|
15
|
-
GHOSTTY_DISPLAY_BACKENDS,
|
|
16
|
-
VALID_DISPLAY_BACKENDS,
|
|
17
|
-
resolve_display_backend,
|
|
18
|
-
)
|
|
19
|
-
from team_agent.display.close import (
|
|
20
|
-
close_adaptive_display,
|
|
21
|
-
close_ghostty_display,
|
|
22
|
-
close_ghostty_workspace,
|
|
23
|
-
close_ghostty_workspace_slot,
|
|
24
|
-
close_team_display_backends,
|
|
25
|
-
)
|
|
26
|
-
from team_agent.display.ghostty import (
|
|
27
|
-
ghostty_app_exists,
|
|
28
|
-
ghostty_attach_args,
|
|
29
|
-
ghostty_command,
|
|
30
|
-
ghostty_display_session_name,
|
|
31
|
-
ghostty_pids_by_title,
|
|
32
|
-
prepare_ghostty_display_session,
|
|
33
|
-
)
|
|
34
|
-
from team_agent.display.worker_window import (
|
|
35
|
-
open_ghostty_worker_window,
|
|
36
|
-
open_worker_displays,
|
|
37
|
-
)
|
|
38
|
-
from team_agent.display.workspace import (
|
|
39
|
-
GHOSTTY_WORKSPACE_PANES_PER_WINDOW,
|
|
40
|
-
ghostty_workspace_aggregator_name,
|
|
41
|
-
ghostty_workspace_blocked,
|
|
42
|
-
ghostty_workspace_pane_command,
|
|
43
|
-
ghostty_workspace_pane_title,
|
|
44
|
-
ghostty_workspace_partial_update_display,
|
|
45
|
-
ghostty_workspace_window_name,
|
|
46
|
-
kill_ghostty_workspace_linked_sessions,
|
|
47
|
-
open_ghostty_workspace,
|
|
48
|
-
open_ghostty_workspace_agent_display,
|
|
49
|
-
prepare_ghostty_workspace_aggregator,
|
|
50
|
-
prepare_ghostty_workspace_linked_sessions,
|
|
51
|
-
set_ghostty_workspace_pane_title,
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
__all__ = [
|
|
55
|
-
"ADAPTIVE_BLOCK_REASONS",
|
|
56
|
-
"ADAPTIVE_DISPLAY_BACKEND",
|
|
57
|
-
"DISPLAY_BACKENDS_WITH_WORKER_VIEWS",
|
|
58
|
-
"GHOSTTY_WORKSPACE_PANES_PER_WINDOW",
|
|
59
|
-
"GHOSTTY_DISPLAY_BACKENDS",
|
|
60
|
-
"VALID_DISPLAY_BACKENDS",
|
|
61
|
-
"adaptive_blocked",
|
|
62
|
-
"close_adaptive_display",
|
|
63
|
-
"close_adaptive_windows",
|
|
64
|
-
"close_ghostty_display",
|
|
65
|
-
"close_ghostty_workspace",
|
|
66
|
-
"close_ghostty_workspace_slot",
|
|
67
|
-
"close_team_display_backends",
|
|
68
|
-
"ghostty_app_exists",
|
|
69
|
-
"ghostty_attach_args",
|
|
70
|
-
"ghostty_command",
|
|
71
|
-
"ghostty_display_session_name",
|
|
72
|
-
"ghostty_pids_by_title",
|
|
73
|
-
"ghostty_workspace_aggregator_name",
|
|
74
|
-
"ghostty_workspace_blocked",
|
|
75
|
-
"ghostty_workspace_pane_command",
|
|
76
|
-
"ghostty_workspace_pane_title",
|
|
77
|
-
"ghostty_workspace_partial_update_display",
|
|
78
|
-
"ghostty_workspace_window_name",
|
|
79
|
-
"kill_ghostty_workspace_linked_sessions",
|
|
80
|
-
"open_ghostty_worker_window",
|
|
81
|
-
"open_adaptive_display",
|
|
82
|
-
"open_ghostty_workspace",
|
|
83
|
-
"open_ghostty_workspace_agent_display",
|
|
84
|
-
"open_worker_displays",
|
|
85
|
-
"prepare_adaptive_windows",
|
|
86
|
-
"prepare_ghostty_display_session",
|
|
87
|
-
"prepare_ghostty_workspace_aggregator",
|
|
88
|
-
"prepare_ghostty_workspace_linked_sessions",
|
|
89
|
-
"probe_display_capabilities",
|
|
90
|
-
"resolve_display_backend",
|
|
91
|
-
"set_ghostty_workspace_pane_title",
|
|
92
|
-
]
|