@team-agent/installer 0.2.10 → 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 -83
- package/src/team_agent/coordinator/lifecycle.py +0 -363
- 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 -200
- package/src/team_agent/idle_takeover.py +0 -59
- package/src/team_agent/idle_takeover_wiring.py +0 -111
- 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 -254
- package/src/team_agent/messaging/delivery.py +0 -473
- 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 -457
- 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 -86
- 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 -1239
- 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 -143
- 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 -602
- 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
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
//! status/data enums + data structs + 有界重试常量 (§19 必变:散字符串态 → 穷尽 enum;
|
|
2
|
+
//! §3 ad-hoc dict → typed 边界)。
|
|
3
|
+
|
|
4
|
+
use serde::{Deserialize, Serialize};
|
|
5
|
+
|
|
6
|
+
use crate::model::enums::Provider;
|
|
7
|
+
use crate::model::ids::{LeaderSessionUuid, OwnerEpoch, TaskId, TeamKey};
|
|
8
|
+
use crate::transport::PaneId;
|
|
9
|
+
|
|
10
|
+
use super::helpers::MessageStatusShadow;
|
|
11
|
+
|
|
12
|
+
// ===========================================================================
|
|
13
|
+
// ENUMS (§19 必变:散字符串态 → 穷尽 enum,serde rename 到精确 Python 字符串)
|
|
14
|
+
// ===========================================================================
|
|
15
|
+
|
|
16
|
+
/// 投递层结果态 (**≠** `messages.status` 行态;card §41)。Python 把两套词表混在同一
|
|
17
|
+
/// dict 里漂移;Rust 拆开:本 enum 是「投递动作的结果」,行态另由 step 7 `MessageStatus` 表达。
|
|
18
|
+
/// 值取自 `delivery.py:181,259,307`、`send.py:261,299,418,489`、`leader.py:230,428`。
|
|
19
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
20
|
+
#[serde(rename_all = "snake_case")]
|
|
21
|
+
pub enum DeliveryStatus {
|
|
22
|
+
Delivered,
|
|
23
|
+
Failed,
|
|
24
|
+
/// busy → 延后不丢 (card §131:不 mark failed,留队列)。
|
|
25
|
+
Queued,
|
|
26
|
+
Blocked,
|
|
27
|
+
Refused,
|
|
28
|
+
RetryScheduled,
|
|
29
|
+
TrustAutoAnswerExhausted,
|
|
30
|
+
AlreadyDelivered,
|
|
31
|
+
/// leader fallback inbox 审计:`ok=True` 但**非真投递成功** (bug-52,card §129)。
|
|
32
|
+
/// 上游必须能区分,绝不当 `Submitted`。
|
|
33
|
+
FallbackLog,
|
|
34
|
+
BroadcastDelivered,
|
|
35
|
+
BroadcastPartial,
|
|
36
|
+
FanoutDelivered,
|
|
37
|
+
FanoutPartial,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/// 投递/发件拒绝原因 (card §42)。Python 散裸字符串靠 `==` 比对易拼错;Rust 穷尽 enum。
|
|
41
|
+
/// 值散落 `send.py`/`delivery.py`/`leader.py`/`session_drift.py`/`owner_gate`。
|
|
42
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
43
|
+
#[serde(rename_all = "snake_case")]
|
|
44
|
+
pub enum DeliveryRefusal {
|
|
45
|
+
TargetNotInTeam,
|
|
46
|
+
HumanConfirmationRequired,
|
|
47
|
+
MissingPermissions,
|
|
48
|
+
RecipientBusy,
|
|
49
|
+
UnknownRecipient,
|
|
50
|
+
TmuxTargetMissing,
|
|
51
|
+
MessageAlreadyClaimed,
|
|
52
|
+
LeaderNotAttached,
|
|
53
|
+
NoCallerPane,
|
|
54
|
+
TeamOwnerMismatch,
|
|
55
|
+
Ambiguous,
|
|
56
|
+
RecipientPaneInNonInputMode,
|
|
57
|
+
SessionDrift,
|
|
58
|
+
/// Caller supplied a `--message-id` that already exists in the store
|
|
59
|
+
/// (CR-015/054 caller-key dedup; identical idempotent re-send is rejected, not duplicated).
|
|
60
|
+
Duplicate,
|
|
61
|
+
/// Send without a resolvable target/assignee (CR-061/N27): the prompt text
|
|
62
|
+
/// is content, not a target. Distinct from `TargetNotInTeam` (where caller
|
|
63
|
+
/// did pick a target but it's unknown).
|
|
64
|
+
RoutingAmbiguous,
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/// 注入失败阶段 (审计用;`delivery.py:309` injection.stage)。card §43。
|
|
68
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
69
|
+
#[serde(rename_all = "snake_case")]
|
|
70
|
+
pub enum DeliveryStage {
|
|
71
|
+
TrustAutoAnswerDismissalWait,
|
|
72
|
+
Inject,
|
|
73
|
+
Submit,
|
|
74
|
+
VisibleCheck,
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/// scheduled_events.kind (step 7 定义,本步**穷尽消费**;card §44)。
|
|
78
|
+
/// `_fire_due_scheduled_events` 的 `else` 返回 `unknown scheduled event kind`
|
|
79
|
+
/// (`scheduler.py:100`) —— Rust 穷尽 match 让漏 kind 编不过,**无运行时 fallback**。
|
|
80
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
81
|
+
#[serde(rename_all = "snake_case")]
|
|
82
|
+
pub enum ScheduledKind {
|
|
83
|
+
Send,
|
|
84
|
+
HealthPing,
|
|
85
|
+
TrustRetry,
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/// classifier 产物 status (card §48;消费 step 8 classifier)。
|
|
89
|
+
/// **致命铁律 (bug-071/077/085)**:`Uncertain` (= agent_health 的 Unknown) 在 ping /
|
|
90
|
+
/// take-over predicate 里**显式 block**,绝不 fallthrough 成 idle。穷尽 match,**无 `_ => Idle`**。
|
|
91
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
92
|
+
#[serde(rename_all = "snake_case")]
|
|
93
|
+
pub enum ActivityStatus {
|
|
94
|
+
Working,
|
|
95
|
+
Idle,
|
|
96
|
+
Stuck,
|
|
97
|
+
Uncertain,
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
impl ActivityStatus {
|
|
101
|
+
/// take-over / ping predicate 闸门:仅非-`Uncertain` 且为 `Idle` 才放行。
|
|
102
|
+
/// `Uncertain`/`Working`/`Stuck` 全 block (穷尽,无兜底)。
|
|
103
|
+
pub fn allows_idle_takeover(self) -> bool {
|
|
104
|
+
match self {
|
|
105
|
+
ActivityStatus::Idle => true,
|
|
106
|
+
ActivityStatus::Working | ActivityStatus::Stuck | ActivityStatus::Uncertain => false,
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/// 告警类型 (card §49;`scheduler.py:38` `_ALERT_TYPES`)。`stuck_cancel` 还接 `all` (展开全集)。
|
|
112
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
113
|
+
#[serde(rename_all = "snake_case")]
|
|
114
|
+
pub enum AlertType {
|
|
115
|
+
Stuck,
|
|
116
|
+
IdleFallback,
|
|
117
|
+
CrossWorkerDeadlock,
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
impl AlertType {
|
|
121
|
+
/// `stuck_cancel(alert_type="all")` → `sorted(_ALERT_TYPES)` 全集 (`scheduler.py:269`)。
|
|
122
|
+
pub fn all() -> [AlertType; 3] {
|
|
123
|
+
[AlertType::CrossWorkerDeadlock, AlertType::IdleFallback, AlertType::Stuck]
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/// selftest check 状态 (card §47;`diagnose/comms.py`)。§19 必变 enum。
|
|
128
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
129
|
+
#[serde(rename_all = "snake_case")]
|
|
130
|
+
pub enum CheckStatus {
|
|
131
|
+
Pass,
|
|
132
|
+
Fail,
|
|
133
|
+
Deferred,
|
|
134
|
+
NotImplemented,
|
|
135
|
+
NotChallenged,
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/// selftest check 验证项 (`verifies` 字段;`diagnose/comms.py:149`)。
|
|
139
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
140
|
+
#[serde(rename_all = "snake_case")]
|
|
141
|
+
pub enum CheckKind {
|
|
142
|
+
ReceiverBinding,
|
|
143
|
+
ContractSuite,
|
|
144
|
+
/// 机械门 (§84/MUST-NOT-13):`{anthropic,openai,httpx} == 0`。
|
|
145
|
+
NoProviderSdkCalls,
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/// leader_receiver.mode (card §51;`leader.py:103,166`)。§3/§41 必 enum。
|
|
149
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
150
|
+
#[serde(rename_all = "snake_case")]
|
|
151
|
+
pub enum ReceiverMode {
|
|
152
|
+
DirectTmux,
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// ===========================================================================
|
|
156
|
+
// PaneWidth fail-safe (bug-064/082;`delivery.py:20-51` `_tmux_pane_width`)
|
|
157
|
+
// ===========================================================================
|
|
158
|
+
|
|
159
|
+
/// `_tmux_pane_width` 的 typed 结果 (card §124 / `delivery.py:20-51`)。**fail-safe 铁律**:
|
|
160
|
+
/// 查询失败时**绝不**返回默认宽度 —— matcher 退回精确相等,右边缘截断的 prompt 绝不靠猜测
|
|
161
|
+
/// 自动应答。故 `Failed` 携带 reason 但**不**携带任何 fallback 宽度。
|
|
162
|
+
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
163
|
+
pub enum PaneWidthQuery {
|
|
164
|
+
Ok { pane_width: u32 },
|
|
165
|
+
/// 失败原因 (`tmux_query_failed:<exc>`/`tmux_query_nonzero`/`empty_output`/
|
|
166
|
+
/// `unparseable_output`/`non_positive_width`)。**无默认宽度** (fail-safe)。
|
|
167
|
+
Failed { error: String },
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// ===========================================================================
|
|
171
|
+
// STRUCTS (§3/§19 必变:ad-hoc dict → typed 边界)
|
|
172
|
+
// ===========================================================================
|
|
173
|
+
|
|
174
|
+
/// 投递结果 (card §40;`delivery.py:180`/`send.py:347` 的 ad-hoc dict 的 typed 版)。
|
|
175
|
+
/// 每个 caller 自己拼/读 dict key,漂移高危 → §3 typed:`status` 必 enum。
|
|
176
|
+
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
177
|
+
pub struct DeliveryOutcome {
|
|
178
|
+
pub ok: bool,
|
|
179
|
+
/// 投递层结果态 (≠ 行态)。
|
|
180
|
+
pub status: DeliveryStatus,
|
|
181
|
+
/// step 7 `messages.status` 行态原文 (shadow;leader 集成时收口为 step 7 enum)。
|
|
182
|
+
pub message_status: MessageStatusShadow,
|
|
183
|
+
pub message_id: Option<String>,
|
|
184
|
+
/// 注入可见性验证 (transport InjectReport 的投影)。
|
|
185
|
+
pub verification: Option<String>,
|
|
186
|
+
pub stage: Option<DeliveryStage>,
|
|
187
|
+
pub reason: Option<DeliveryRefusal>,
|
|
188
|
+
/// fallback / broadcast / fanout 等通道标注 (`channel` 字段)。
|
|
189
|
+
pub channel: Option<String>,
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/// trust retry payload (card §45;`delivery.py:273` scheduled_events.payload_json 的 typed 视图)。
|
|
193
|
+
/// `attempt` 是 u8 有界 (≤ [`TRUST_RETRY_MAX_ATTEMPTS`])。
|
|
194
|
+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
195
|
+
pub struct TrustRetryPayload {
|
|
196
|
+
pub message_id: String,
|
|
197
|
+
pub attempt: u8,
|
|
198
|
+
pub max_attempts: u8,
|
|
199
|
+
/// 首投目标 pane (`first_target`)。
|
|
200
|
+
pub first_target: PaneId,
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/// send retry payload (card §46;`results.py:251`/`scheduler.py:134`)。report_result 排队给
|
|
204
|
+
/// leader 的 send 事件 payload;`max_attempts` = [`SEND_RETRY_MAX_ATTEMPTS`]。
|
|
205
|
+
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] // 无 Eq:含 f64 timeout
|
|
206
|
+
pub struct SendEventPayload {
|
|
207
|
+
pub content: String,
|
|
208
|
+
pub task_id: Option<TaskId>,
|
|
209
|
+
pub sender: String,
|
|
210
|
+
pub requires_ack: bool,
|
|
211
|
+
pub wait_visible: bool,
|
|
212
|
+
pub timeout: f64,
|
|
213
|
+
pub max_attempts: u8,
|
|
214
|
+
pub attempt: u8,
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/// selftest 单 check (card §47;`diagnose/comms.py:119`)。
|
|
218
|
+
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
219
|
+
pub struct SelftestCheck {
|
|
220
|
+
pub status: CheckStatus,
|
|
221
|
+
pub verifies: CheckKind,
|
|
222
|
+
/// 证据 (proof/calls 等;leader 集成时按 CheckKind 收口具体形状)。
|
|
223
|
+
pub evidence: CheckEvidence,
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/// selftest check 证据 (`proof`/`calls`/`mismatches` 的 typed union)。
|
|
227
|
+
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
228
|
+
pub enum CheckEvidence {
|
|
229
|
+
/// `no_provider_sdk_calls` 的机械证据 (§84):三 SDK 调用计数。
|
|
230
|
+
ProviderSdkCalls(ProviderSdkCalls),
|
|
231
|
+
/// binding 一致性比对结果 (mismatch 列表)。
|
|
232
|
+
Binding { mismatches: Vec<String> },
|
|
233
|
+
/// contract_suite deferred 占位。
|
|
234
|
+
Deferred { reason: String },
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/// **机械门** (§84/MUST-NOT-13;`diagnose/comms.py:142`):selftest 路径 provider SDK 调用
|
|
238
|
+
/// 计数,断言 `{anthropic,openai,httpx} == 0`。
|
|
239
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
|
|
240
|
+
pub struct ProviderSdkCalls {
|
|
241
|
+
pub anthropic: u32,
|
|
242
|
+
pub openai: u32,
|
|
243
|
+
pub httpx: u32,
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
impl ProviderSdkCalls {
|
|
247
|
+
/// `any(calls.values())` 取反:三者全 0 才 pass。
|
|
248
|
+
pub fn is_zero(self) -> bool {
|
|
249
|
+
self.anthropic == 0 && self.openai == 0 && self.httpx == 0
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/// comms selftest 顶层结果 (`run_comms_selftest` 返回;`diagnose/comms.py:40`)。
|
|
254
|
+
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
255
|
+
pub struct SelftestReport {
|
|
256
|
+
pub ok: bool,
|
|
257
|
+
pub status: CheckStatus,
|
|
258
|
+
pub run_id: String,
|
|
259
|
+
/// `scope = "binding_consistency"`。
|
|
260
|
+
pub scope: String,
|
|
261
|
+
pub boundary: String,
|
|
262
|
+
pub receiver_binding: SelftestCheck,
|
|
263
|
+
pub contract_suite: SelftestCheck,
|
|
264
|
+
pub provider_sdk_calls: SelftestCheck,
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/// idle 行为评估结果 (`evaluate_idle_behavior` 返回;`diagnose/comms.py:87`)。
|
|
268
|
+
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
269
|
+
pub struct IdleEvaluation {
|
|
270
|
+
pub ok: bool,
|
|
271
|
+
pub agent_id: String,
|
|
272
|
+
pub claimed_status: String,
|
|
273
|
+
pub token: String,
|
|
274
|
+
pub status: CheckStatus,
|
|
275
|
+
pub execution_ack: String,
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/// 抑制快照 (card §50;`scheduler.py:383` `_agent_alert_snapshot`)。清除判据靠 snapshot diff。
|
|
279
|
+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
280
|
+
pub struct AlertSnapshot {
|
|
281
|
+
pub assigned_task_ids: Vec<TaskId>,
|
|
282
|
+
pub delivered_message_ids: Vec<String>,
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/// 告警抑制条目 (card §50;`scheduler.py:287`)。
|
|
286
|
+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
287
|
+
pub struct AlertSuppression {
|
|
288
|
+
pub suppressed_at: String,
|
|
289
|
+
pub suppressed_by: String,
|
|
290
|
+
pub snapshot: AlertSnapshot,
|
|
291
|
+
pub manual_acknowledge: Option<bool>,
|
|
292
|
+
pub expires_at: Option<String>,
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/// leader_receiver binding (card §51;step 5/10 主拥,本步消费/校验;`leader.py:103,166`)。
|
|
296
|
+
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
297
|
+
pub struct LeaderReceiver {
|
|
298
|
+
pub mode: ReceiverMode,
|
|
299
|
+
pub pane_id: PaneId,
|
|
300
|
+
pub provider: Provider,
|
|
301
|
+
pub leader_session_uuid: Option<LeaderSessionUuid>,
|
|
302
|
+
pub owner_epoch: OwnerEpoch,
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/// leader_notification_log dedup key (card §52;`leader_notification_log.py:30`)。
|
|
306
|
+
/// **陷阱**:dedup key = `(result_id, owner_team_id, owner_epoch)`,**不含**
|
|
307
|
+
/// `leader_session_uuid` (它退化为 nullable audit)。
|
|
308
|
+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
309
|
+
pub struct LeaderNotificationKey {
|
|
310
|
+
pub result_id: String,
|
|
311
|
+
pub owner_team_id: TeamKey,
|
|
312
|
+
pub owner_epoch: OwnerEpoch,
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/// classifier 产物 (card §48;`activity_detector.py:107` 的 `{status,confidence,rationale}`)。
|
|
316
|
+
#[derive(Debug, Clone, PartialEq)]
|
|
317
|
+
pub struct AgentActivity {
|
|
318
|
+
pub status: ActivityStatus,
|
|
319
|
+
pub confidence: f64,
|
|
320
|
+
pub rationale: String,
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/// result watcher 通知记录 (card §53;`result_delivery.py` deliver/dedupe 返回的逐 watcher 结果)。
|
|
324
|
+
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
|
325
|
+
pub struct WatcherNotice {
|
|
326
|
+
pub watcher_id: String,
|
|
327
|
+
pub result_id: Option<String>,
|
|
328
|
+
pub ok: bool,
|
|
329
|
+
#[serde(skip_serializing_if = "Option::is_none")]
|
|
330
|
+
pub status: Option<String>,
|
|
331
|
+
/// dedupe / 投递 / 失败的 message_id (存活语义:requeue 不得清空,Gap 32)。
|
|
332
|
+
pub notified_message_id: Option<String>,
|
|
333
|
+
#[serde(skip_serializing_if = "Option::is_none")]
|
|
334
|
+
pub primary_watcher_id: Option<String>,
|
|
335
|
+
#[serde(skip_serializing_if = "Option::is_none")]
|
|
336
|
+
pub prior_state: Option<String>,
|
|
337
|
+
pub error: Option<String>,
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// ===========================================================================
|
|
341
|
+
// BOUNDED CONSTANTS (有界重试;穷尽计数器锁死,绝不死循环;card §125)
|
|
342
|
+
// ===========================================================================
|
|
343
|
+
|
|
344
|
+
/// `_TRUST_RETRY_MAX_ATTEMPTS = 4` (`delivery.py:61`)。第 4 次终态发
|
|
345
|
+
/// `leader_panes.trust_auto_answer_exhausted`,不死循环。
|
|
346
|
+
pub const TRUST_RETRY_MAX_ATTEMPTS: u8 = 4;
|
|
347
|
+
|
|
348
|
+
/// `_TRUST_RETRY_BACKOFF_SECONDS = {2:5, 3:15, 4:30}` (`delivery.py:60`)。
|
|
349
|
+
pub const TRUST_RETRY_BACKOFF_SECONDS: &[(u8, u32)] = &[(2, 5), (3, 15), (4, 30)];
|
|
350
|
+
|
|
351
|
+
/// send 重试 `max_attempts = 3` (`scheduler.py:134`/`results.py:251`)。
|
|
352
|
+
pub const SEND_RETRY_MAX_ATTEMPTS: u8 = 3;
|
|
353
|
+
|
|
354
|
+
/// result watcher 投递有界重试 max 5 (`result_delivery.py` notify max 5)。
|
|
355
|
+
pub const RESULT_DELIVERY_MAX_ATTEMPTS: u8 = 5;
|