@team-agent/installer 0.5.127 → 0.5.128
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 +1 -1
- package/Cargo.toml +1 -1
- package/README.md +11 -0
- package/crates/team-agent/src/cli/adapters.rs +3 -13
- package/crates/team-agent/src/cli/arguments.rs +4 -0
- package/crates/team-agent/src/cli/diagnose.rs +68 -22
- package/crates/team-agent/src/cli/emit.rs +58 -26
- package/crates/team-agent/src/cli/intent/runtime.rs +32 -5
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +102 -11
- package/crates/team-agent/src/cli/intent/tests.rs +10 -12
- package/crates/team-agent/src/cli/intent.rs +1 -1
- package/crates/team-agent/src/cli/mod.rs +25 -8
- package/crates/team-agent/src/cli/models.rs +764 -7
- package/crates/team-agent/src/cli/schedule.rs +175 -0
- package/crates/team-agent/src/cli/send/persist.rs +0 -36
- package/crates/team-agent/src/cli/send/presentation.rs +1 -1
- package/crates/team-agent/src/cli/send.rs +108 -110
- package/crates/team-agent/src/cli/spec.rs +6 -0
- package/crates/team-agent/src/cli/status_port/brief.rs +5 -67
- package/crates/team-agent/src/cli/tests/leader_watch.rs +12 -62
- package/crates/team-agent/src/cli/tests/mod.rs +1 -1
- package/crates/team-agent/src/cli/tests/named_address.rs +11 -10
- package/crates/team-agent/src/cli/tests/run_delegation.rs +9 -6
- package/crates/team-agent/src/cli/tests/status_send.rs +68 -271
- package/crates/team-agent/src/compiler/tests.rs +3 -18
- package/crates/team-agent/src/compiler.rs +205 -6
- package/crates/team-agent/src/contract_runtime/backend.rs +145 -11
- package/crates/team-agent/src/contract_runtime/commands.rs +7 -7
- package/crates/team-agent/src/contract_runtime/config.rs +26 -16
- package/crates/team-agent/src/contract_runtime/config_tests.rs +24 -4
- package/crates/team-agent/src/contract_runtime/discovery.rs +12 -1
- package/crates/team-agent/src/contract_runtime/fork.rs +3 -10
- package/crates/team-agent/src/contract_runtime/framework.rs +28 -11
- package/crates/team-agent/src/contract_runtime/mcp.rs +19 -24
- package/crates/team-agent/src/contract_runtime/prompt.rs +2 -2
- package/crates/team-agent/src/contract_runtime/registry.rs +56 -92
- package/crates/team-agent/src/coordinator/steps/abnormal.rs +11 -11
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +16 -54
- package/crates/team-agent/src/coordinator/tests/health_sync.rs +42 -0
- package/crates/team-agent/src/coordinator/tick.rs +1 -89
- package/crates/team-agent/src/db/message_store.rs +7 -65
- package/crates/team-agent/src/direct_delivery.rs +368 -0
- package/crates/team-agent/src/inbox_store.rs +169 -0
- package/crates/team-agent/src/leader/registry.rs +5 -0
- package/crates/team-agent/src/leader/start.rs +2 -1
- package/crates/team-agent/src/leader/tests/lease_api.rs +2 -2
- package/crates/team-agent/src/leader/tests/prompt_contract.rs +1 -0
- package/crates/team-agent/src/lib.rs +2 -0
- package/crates/team-agent/src/lifecycle/launch/add_agent.rs +33 -0
- package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +206 -1
- package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +28 -2
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +38 -13
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +87 -6
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +9 -1
- package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +351 -81
- package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +3 -4
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +24 -0
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +36 -13
- package/crates/team-agent/src/lifecycle/launch.rs +24 -1
- package/crates/team-agent/src/lifecycle/profile_launch.rs +321 -11
- package/crates/team-agent/src/lifecycle/restart/agent.rs +1 -0
- package/crates/team-agent/src/lifecycle/restart/avatar.rs +1798 -0
- package/crates/team-agent/src/lifecycle/restart/claude_fork.rs +163 -0
- package/crates/team-agent/src/lifecycle/restart/common.rs +345 -35
- package/crates/team-agent/src/lifecycle/restart/selection.rs +5 -5
- package/crates/team-agent/src/lifecycle/restart.rs +4 -0
- package/crates/team-agent/src/lifecycle/role_config.rs +39 -14
- package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +325 -0
- package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +320 -8
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +236 -13
- package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +378 -4
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +5 -4
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +7 -11
- package/crates/team-agent/src/lifecycle/tests/core.rs +47 -18
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_native_mcp_host.mjs +2 -1
- package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +14 -14
- package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +60 -20
- package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +28 -26
- package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +6 -6
- package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +18 -6
- package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +70 -52
- package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +210 -0
- package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +157 -4
- package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +526 -10
- package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +1419 -0
- package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +68 -1
- package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +34 -12
- package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +94 -2
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +10 -11
- package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +2 -2
- package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +254 -2
- package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +4 -4
- package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +5 -6
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +16 -7
- package/crates/team-agent/src/lifecycle/tests.rs +3 -0
- package/crates/team-agent/src/lifecycle/types.rs +18 -2
- package/crates/team-agent/src/lifecycle/worker_command_context.rs +43 -50
- package/crates/team-agent/src/mcp_server/readiness.rs +130 -149
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +98 -119
- package/crates/team-agent/src/mcp_server/tests/scoped.rs +21 -31
- package/crates/team-agent/src/mcp_server/tests/send.rs +72 -107
- package/crates/team-agent/src/mcp_server/tests/tools.rs +10 -12
- package/crates/team-agent/src/mcp_server/tools.rs +70 -196
- package/crates/team-agent/src/messaging/delivery.rs +160 -218
- package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +5 -5
- package/crates/team-agent/src/messaging/helpers.rs +1 -19
- package/crates/team-agent/src/messaging/mod.rs +1 -0
- package/crates/team-agent/src/messaging/reminders.rs +316 -0
- package/crates/team-agent/src/messaging/scheduler.rs +7 -1
- package/crates/team-agent/src/messaging/tests/dup_inject.rs +191 -85
- package/crates/team-agent/src/messaging/tests/runtime.rs +4 -110
- package/crates/team-agent/src/messaging/tests/spine.rs +40 -24
- package/crates/team-agent/src/messaging/types.rs +1 -0
- package/crates/team-agent/src/provider/adapter.rs +303 -51
- package/crates/team-agent/src/provider/adapters/claude.rs +78 -0
- package/crates/team-agent/src/provider/adapters/claude_fork.rs +131 -0
- package/crates/team-agent/src/provider/adapters/mod.rs +7 -5
- package/crates/team-agent/src/provider/adapters/pi.rs +106 -0
- package/crates/team-agent/src/provider/classify.rs +1 -66
- package/crates/team-agent/src/provider/model_catalog.rs +201 -13
- package/crates/team-agent/src/provider/session/capture.rs +106 -6
- package/crates/team-agent/src/provider/session/context_fork/claude.rs +123 -0
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +4 -0
- package/crates/team-agent/src/provider/session/context_fork.rs +150 -18
- package/crates/team-agent/src/provider/session_scan/claude.rs +523 -0
- package/crates/team-agent/src/provider/session_scan/common.rs +44 -8
- package/crates/team-agent/src/provider/session_scan/pi.rs +34 -1
- package/crates/team-agent/src/provider/session_scan.rs +16 -6
- package/crates/team-agent/src/provider/tests/adapter.rs +104 -17
- package/crates/team-agent/src/provider/tests/classify.rs +0 -53
- package/crates/team-agent/src/provider/tests/command_helpers.rs +12 -3
- package/crates/team-agent/src/provider/tests/idle.rs +37 -0
- package/crates/team-agent/src/provider/wire.rs +22 -34
- package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +1 -1
- package/crates/team-agent/src/state/persist.rs +6 -6
- package/crates/team-agent/src/state/projection.rs +1 -1
- package/crates/team-agent/src/state/repository/tests.rs +2 -2
- package/crates/team-agent/src/test_support/models_timeout_fixture.rs +144 -0
- package/crates/team-agent/src/tmux_backend/tests.rs +0 -151
- package/crates/team-agent/src/tmux_backend.rs +5 -40
- package/package.json +4 -4
- package/skills/team-agent/SKILL.md +5 -7
- package/skills/team-agent/command-coverage.json +1 -1
- package/skills/team-agent/docs/reference/team-agent-operator.md +3 -3
- package/skills/team-agent/references/team-agent-operator.md +3 -3
|
@@ -41,7 +41,7 @@ const TEAM_MD: &str =
|
|
|
41
41
|
|
|
42
42
|
const FAKE_ROLE: &str = "---\nname: faker\nrole: Fake Worker\nprovider: fake\nmodel: fake\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nFake worker.\n";
|
|
43
43
|
|
|
44
|
-
const
|
|
44
|
+
const CLAUDE_ROLE: &str = "---\nname: clauder\nrole: Claude Worker\nprovider: claude\nmodel: claude-sonnet-4-6\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nClaude worker.\n";
|
|
45
45
|
|
|
46
46
|
#[test]
|
|
47
47
|
#[serial(env)]
|
|
@@ -50,7 +50,7 @@ fn worker_mcp_owner_team_scope_must_match_runtime_team_key_not_spec_name() {
|
|
|
50
50
|
let team = mixed_provider_team_dir(&hermetic, "mcp-owner-scope");
|
|
51
51
|
super::launch_spawn::seed_healthy_coordinator(team.parent().unwrap());
|
|
52
52
|
let transport = RecordingTransport::new()
|
|
53
|
-
.with_windows(vec![WindowName::new("
|
|
53
|
+
.with_windows(vec![WindowName::new("clauder"), WindowName::new("faker")]);
|
|
54
54
|
let launch = ready_launch(
|
|
55
55
|
quick_start_with_transport(&team, None, true, None, &transport)
|
|
56
56
|
.expect("quick-start should reach worker spawn path"),
|
|
@@ -194,8 +194,7 @@ fn running_worker_state_must_only_be_written_for_windows_that_exist_after_launch
|
|
|
194
194
|
let spec_path = team.join("team.spec.yaml");
|
|
195
195
|
std::fs::write(&spec_path, team_agent::model::yaml::dumps(&spec)).expect("write spec");
|
|
196
196
|
|
|
197
|
-
// Simulates the Mac mini final capture: the
|
|
198
|
-
// (originally Claude, here Copilot) window does not.
|
|
197
|
+
// Simulates the Mac mini final capture: the fake worker's window exists, the claude window does not.
|
|
199
198
|
// launch_with_transport currently never verifies the post-spawn window set before persisting
|
|
200
199
|
// `status=running`, so this fixture pins the state/physical invariant directly.
|
|
201
200
|
let transport = RecordingTransport::new().with_windows(vec![WindowName::new("faker")]);
|
|
@@ -743,8 +742,8 @@ fn mixed_provider_team_dir(hermetic: &HermeticTestEnv, tag: &str) -> PathBuf {
|
|
|
743
742
|
let team = hermetic.workspace(tag).join("teamdir");
|
|
744
743
|
std::fs::create_dir_all(team.join("agents")).expect("create agents dir");
|
|
745
744
|
std::fs::write(team.join("TEAM.md"), TEAM_MD).expect("write TEAM.md");
|
|
746
|
-
std::fs::write(team.join("agents").join("
|
|
747
|
-
.expect("write
|
|
745
|
+
std::fs::write(team.join("agents").join("clauder.md"), CLAUDE_ROLE)
|
|
746
|
+
.expect("write clauder role");
|
|
748
747
|
std::fs::write(team.join("agents").join("faker.md"), FAKE_ROLE).expect("write faker role");
|
|
749
748
|
team
|
|
750
749
|
}
|
|
@@ -167,8 +167,8 @@ fn worker_spawn_scrubs_cross_provider_process_identity_but_keeps_config_env() {
|
|
|
167
167
|
("NODE_EXTRA_CA_CERTS", "/canary/ca.pem"),
|
|
168
168
|
]);
|
|
169
169
|
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
let launch_team =
|
|
171
|
+
compiled_team_dir_for_provider("cross-launch", &[("worker_a", "Launch Worker")], "claude");
|
|
172
172
|
let launch_transport = RecordingTransport::new().with_session_present(false);
|
|
173
173
|
launch_with_transport(
|
|
174
174
|
&launch_team.join("team.spec.yaml"),
|
|
@@ -179,16 +179,25 @@ fn worker_spawn_scrubs_cross_provider_process_identity_but_keeps_config_env() {
|
|
|
179
179
|
)
|
|
180
180
|
.expect("launch fixture should spawn worker");
|
|
181
181
|
|
|
182
|
-
let restart_team =
|
|
183
|
-
|
|
182
|
+
let restart_team = compiled_team_dir_for_provider(
|
|
183
|
+
"cross-restart",
|
|
184
|
+
&[("worker_a", "Restart Worker")],
|
|
185
|
+
"claude",
|
|
186
|
+
);
|
|
187
|
+
seed_restart_state_as(&restart_team, "worker_a", "claude");
|
|
184
188
|
let restart_transport = RecordingTransport::new().with_session_present(false);
|
|
185
189
|
restart_with_transport(&restart_team, true, None, &restart_transport)
|
|
186
190
|
.expect("restart fixture should spawn worker");
|
|
187
191
|
|
|
188
|
-
let add_team =
|
|
189
|
-
|
|
192
|
+
let add_team =
|
|
193
|
+
compiled_team_dir_for_provider("cross-add", &[("worker_a", "Existing Worker")], "claude");
|
|
194
|
+
seed_running_add_agent_state_as(&add_team, "worker_a", "claude");
|
|
190
195
|
let role_file = add_team.parent().unwrap().join("worker_b.md");
|
|
191
|
-
std::fs::write(
|
|
196
|
+
std::fs::write(
|
|
197
|
+
&role_file,
|
|
198
|
+
role_doc_for_provider("worker_b", "Added Worker", "claude"),
|
|
199
|
+
)
|
|
200
|
+
.unwrap();
|
|
192
201
|
let add_transport = RecordingTransport::new().with_session_present(true);
|
|
193
202
|
add_agent_with_transport(
|
|
194
203
|
&add_team,
|
|
@@ -50,6 +50,7 @@ mod agent_ops;
|
|
|
50
50
|
mod b0_legacy_snapshot_nonauthority_contract;
|
|
51
51
|
mod b0_reader_hideone_audit_contract;
|
|
52
52
|
mod behavioral_diff_264_red;
|
|
53
|
+
mod claude_compatible_config_red;
|
|
53
54
|
mod claude_profile_launch_red;
|
|
54
55
|
mod cli_argv_routing_red;
|
|
55
56
|
mod clone_agent_preserves_source_tools;
|
|
@@ -72,8 +73,10 @@ mod phase_b_contracts;
|
|
|
72
73
|
mod phase_golden;
|
|
73
74
|
mod pi_catalog_red;
|
|
74
75
|
mod pi_command_red;
|
|
76
|
+
mod pi_compiler_red;
|
|
75
77
|
mod pi_dual_entry_red;
|
|
76
78
|
mod pi_executable_mcp_red;
|
|
79
|
+
mod pi_fork_session_inheritance_red;
|
|
77
80
|
mod pi_lifecycle_doctor_red;
|
|
78
81
|
mod pi_native_mcp_capability_red;
|
|
79
82
|
mod pi_session_delivery_red;
|
|
@@ -393,6 +393,14 @@ pub enum LifecycleError {
|
|
|
393
393
|
/// 编译 spec / role doc 失败(`compile_team`/`compile_role_doc_agent`)。
|
|
394
394
|
#[error("spec compile failed: {0}")]
|
|
395
395
|
Compile(String),
|
|
396
|
+
/// Pi model/schema admission failed before lifecycle reservation or writes.
|
|
397
|
+
#[error("pi model preflight failed: {requested}")]
|
|
398
|
+
PiModelPreflight {
|
|
399
|
+
requested: String,
|
|
400
|
+
candidates: Vec<String>,
|
|
401
|
+
action: String,
|
|
402
|
+
not_ready: bool,
|
|
403
|
+
},
|
|
396
404
|
/// provider 命令构造 / resume 不可用(`ResumeUnavailable`)。
|
|
397
405
|
#[error("provider error: {0}")]
|
|
398
406
|
Provider(String),
|
|
@@ -607,8 +615,8 @@ pub struct AddAgentReport {
|
|
|
607
615
|
pub role_file: PathBuf,
|
|
608
616
|
}
|
|
609
617
|
|
|
610
|
-
/// `fork_agent(...)` 结果。
|
|
611
|
-
///
|
|
618
|
+
/// `fork_agent(...)` 结果。Pi 的 snapshot fork 附带可审计的 source/target backing 细节;
|
|
619
|
+
/// 已支持的其他 provider 保持既有报告字段。
|
|
612
620
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
613
621
|
pub struct ForkAgentReport {
|
|
614
622
|
pub source_agent_id: AgentId,
|
|
@@ -616,6 +624,14 @@ pub struct ForkAgentReport {
|
|
|
616
624
|
pub env: AgentActionEnvelope,
|
|
617
625
|
pub session_id: Option<SessionId>,
|
|
618
626
|
pub backing_state: ForkBackingState,
|
|
627
|
+
pub pi_fork: Option<PiForkDetails>,
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
631
|
+
pub struct PiForkDetails {
|
|
632
|
+
pub source_session_id: SessionId,
|
|
633
|
+
pub session_id: SessionId,
|
|
634
|
+
pub backing_path: RolloutPath,
|
|
619
635
|
}
|
|
620
636
|
|
|
621
637
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
//! - name: WorkerCommandAgent
|
|
6
6
|
//! what: 从 YAML 或 JSON 读出的单 agent 命令上下文
|
|
7
7
|
//! - name: compile_worker_system_prompt
|
|
8
|
-
//! what: 按身份、runtime
|
|
8
|
+
//! what: 按身份、runtime 契约、通信模式、角色正文拼系统提示词
|
|
9
9
|
//! depends:
|
|
10
10
|
//! - crate::communication_mode
|
|
11
11
|
//! boundary:
|
|
@@ -29,10 +29,9 @@ All communication must go through Team Agent MCP tools.
|
|
|
29
29
|
|
|
30
30
|
- Teammate: {send_message}(to='<agent_id>', content='...')
|
|
31
31
|
- Broadcast: {send_message}(to='*', content='...')
|
|
32
|
-
- Complete: {report_result}(summary='...') — call exactly once
|
|
33
32
|
- Optional roster/status: {get_team_status} — use only when useful; it is not a communication or completion prerequisite.
|
|
34
33
|
|
|
35
|
-
|
|
34
|
+
Use {send_message} exclusively for findings, progress, questions, and completion updates. Lifecycle management remains on the separately authorized operator CLI.
|
|
36
35
|
|
|
37
36
|
## Rules:
|
|
38
37
|
|
|
@@ -40,23 +39,12 @@ Only these three Team Agent MCP tools are available. Lifecycle management remain
|
|
|
40
39
|
- Do not reply to pure ACKs, greetings, or unchanged status notices (such as "paused" or "waiting"); after reporting a blocker once or completing a task, remain silent until a new actionable instruction arrives.
|
|
41
40
|
- On 500/529/rate limits, retry only after 1-2 minutes."#;
|
|
42
41
|
|
|
43
|
-
// 0.4.11 trimmed: the runtime contract section above already covers
|
|
44
|
-
// send_message signatures and report_result exactly-once. The output
|
|
45
|
-
// contract now only carries the RESULT-ENVELOPE-SPECIFIC delivery
|
|
46
|
-
// semantics (leader-attach dependence + fallback status) that the
|
|
47
|
-
// generic runtime section deliberately leaves out.
|
|
48
|
-
const RESULT_ENVELOPE_OUTPUT_CONTRACT: &str =
|
|
49
|
-
"Final completion must call {report_result} exactly once with a short summary \
|
|
50
|
-
and optional status/changes/tests; the MCP runtime injects the result into the attached leader pane. \
|
|
51
|
-
If no leader is attached, the tool returns a fallback/failed result instead of completion.";
|
|
52
|
-
|
|
53
42
|
pub(crate) struct WorkerCommandAgent {
|
|
54
43
|
id: Option<String>,
|
|
55
44
|
provider: Provider,
|
|
56
45
|
role: Option<String>,
|
|
57
46
|
system_prompt_inline: Option<String>,
|
|
58
47
|
system_prompt_file: Option<String>,
|
|
59
|
-
output_contract_format: Option<String>,
|
|
60
48
|
communication_mode: CommunicationMode,
|
|
61
49
|
/// Missing `dangerously_skip_permissions` defaults to false; only explicit true enables bypass.
|
|
62
50
|
dangerously_skip_permissions: bool,
|
|
@@ -100,11 +88,6 @@ impl WorkerCommandAgent {
|
|
|
100
88
|
.filter(|value| value.is_truthy())
|
|
101
89
|
.and_then(crate::model::yaml::Value::as_str)
|
|
102
90
|
.map(str::to_string),
|
|
103
|
-
output_contract_format: agent
|
|
104
|
-
.get("output_contract")
|
|
105
|
-
.and_then(|contract| contract.get("format"))
|
|
106
|
-
.and_then(crate::model::yaml::Value::as_str)
|
|
107
|
-
.map(str::to_string),
|
|
108
91
|
communication_mode: communication_mode(
|
|
109
92
|
agent
|
|
110
93
|
.get("communication_mode")
|
|
@@ -154,11 +137,6 @@ impl WorkerCommandAgent {
|
|
|
154
137
|
.and_then(serde_json::Value::as_str)
|
|
155
138
|
.filter(|value| !value.is_empty())
|
|
156
139
|
.map(str::to_string),
|
|
157
|
-
output_contract_format: agent
|
|
158
|
-
.get("output_contract")
|
|
159
|
-
.and_then(|contract| contract.get("format"))
|
|
160
|
-
.and_then(serde_json::Value::as_str)
|
|
161
|
-
.map(str::to_string),
|
|
162
140
|
communication_mode: communication_mode(
|
|
163
141
|
agent
|
|
164
142
|
.get("communication_mode")
|
|
@@ -189,19 +167,14 @@ pub(crate) fn compile_worker_system_prompt(
|
|
|
189
167
|
"{}()",
|
|
190
168
|
mcp_tool_name(agent.provider, "team_orchestrator", "get_team_status")
|
|
191
169
|
);
|
|
192
|
-
let
|
|
193
|
-
let runtime_contract =
|
|
194
|
-
runtime_contract_section(&send_message, &report_result, &get_team_status);
|
|
170
|
+
let runtime_contract = runtime_contract_section(&send_message, &get_team_status);
|
|
195
171
|
let communication_contract = agent.communication_mode.runtime_contract(&send_message);
|
|
196
|
-
let
|
|
172
|
+
let chunks = [
|
|
197
173
|
identity_section(agent),
|
|
198
174
|
runtime_contract,
|
|
199
175
|
communication_contract,
|
|
200
176
|
role_body(agent)?,
|
|
201
177
|
];
|
|
202
|
-
if let Some(contract) = output_contract(agent, &report_result) {
|
|
203
|
-
chunks.push(contract);
|
|
204
|
-
}
|
|
205
178
|
Ok(chunks
|
|
206
179
|
.into_iter()
|
|
207
180
|
.filter(|chunk| !chunk.is_empty())
|
|
@@ -234,14 +207,9 @@ fn mcp_tool_name(provider: Provider, server: &str, tool: &str) -> String {
|
|
|
234
207
|
}
|
|
235
208
|
}
|
|
236
209
|
|
|
237
|
-
pub(crate) fn runtime_contract_section(
|
|
238
|
-
send_message: &str,
|
|
239
|
-
report_result: &str,
|
|
240
|
-
get_team_status: &str,
|
|
241
|
-
) -> String {
|
|
210
|
+
pub(crate) fn runtime_contract_section(send_message: &str, get_team_status: &str) -> String {
|
|
242
211
|
RUNTIME_CONTRACT_SECTION
|
|
243
212
|
.replace("{send_message}", send_message)
|
|
244
|
-
.replace("{report_result}", report_result)
|
|
245
213
|
.replace("{get_team_status}", get_team_status)
|
|
246
214
|
}
|
|
247
215
|
|
|
@@ -281,11 +249,6 @@ fn role_body(agent: &WorkerCommandAgent) -> Result<String, LifecycleError> {
|
|
|
281
249
|
Ok(chunks.join("\n\n"))
|
|
282
250
|
}
|
|
283
251
|
|
|
284
|
-
fn output_contract(agent: &WorkerCommandAgent, report_result: &str) -> Option<String> {
|
|
285
|
-
(agent.output_contract_format.as_deref() == Some("result_envelope_v1"))
|
|
286
|
-
.then(|| RESULT_ENVELOPE_OUTPUT_CONTRACT.replace("{report_result}", report_result))
|
|
287
|
-
}
|
|
288
|
-
|
|
289
252
|
#[cfg(test)]
|
|
290
253
|
mod tests {
|
|
291
254
|
use super::*;
|
|
@@ -293,7 +256,7 @@ mod tests {
|
|
|
293
256
|
#[test]
|
|
294
257
|
fn system_prompt_uses_identity_then_runtime_contract_python_order() {
|
|
295
258
|
// #264 D6: Python truth source (prompt.py:39, live ps confirmed) builds
|
|
296
|
-
// chunks = [identity, TEAMMATE_SYSTEM_PROMPT, role_body
|
|
259
|
+
// chunks = [identity, TEAMMATE_SYSTEM_PROMPT, role_body].
|
|
297
260
|
// The previous assertion locked the inverted contract-first order with no
|
|
298
261
|
// Python evidence; this is the corrected golden.
|
|
299
262
|
// 0.3.5 union (copilot v2 C-1 / B2 MUST-4 行为层守): identity 必须 FIRST —
|
|
@@ -305,7 +268,6 @@ mod tests {
|
|
|
305
268
|
role: Some("Runtime Developer".to_string()),
|
|
306
269
|
system_prompt_inline: Some("Implement the assigned slice.".to_string()),
|
|
307
270
|
system_prompt_file: None,
|
|
308
|
-
output_contract_format: Some("result_envelope_v1".to_string()),
|
|
309
271
|
communication_mode: CommunicationMode::default(),
|
|
310
272
|
dangerously_skip_permissions: false,
|
|
311
273
|
};
|
|
@@ -320,18 +282,45 @@ mod tests {
|
|
|
320
282
|
.find(RUNTIME_CONTRACT_SECTION.lines().next().unwrap_or(""))
|
|
321
283
|
.unwrap();
|
|
322
284
|
let role = prompt.find("Implement the assigned slice.").unwrap();
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
.unwrap();
|
|
326
|
-
assert!(identity < runtime && runtime < role && role < output);
|
|
285
|
+
assert!(identity < runtime && runtime < role);
|
|
286
|
+
assert!(!prompt.contains("report_result"));
|
|
327
287
|
let slowdown_phrase = format!("500/{}", 500 + 29);
|
|
328
288
|
assert!(prompt.contains(&slowdown_phrase));
|
|
329
289
|
assert!(prompt.contains("Runtime Developer"));
|
|
330
290
|
}
|
|
331
291
|
|
|
292
|
+
#[test]
|
|
293
|
+
fn output_contract_metadata_does_not_add_completion_instructions() {
|
|
294
|
+
let json = serde_json::json!({
|
|
295
|
+
"id": "worker",
|
|
296
|
+
"output_contract": { "format": "result_envelope_v1" },
|
|
297
|
+
});
|
|
298
|
+
let yaml = crate::model::yaml::loads(
|
|
299
|
+
"id: worker\noutput_contract:\n format: result_envelope_v1\n",
|
|
300
|
+
)
|
|
301
|
+
.unwrap();
|
|
302
|
+
for agent in [
|
|
303
|
+
WorkerCommandAgent::from_json(&json, None, Provider::Codex).unwrap(),
|
|
304
|
+
WorkerCommandAgent::from_yaml(&yaml, None, Provider::Codex).unwrap(),
|
|
305
|
+
] {
|
|
306
|
+
let prompt = compile_worker_system_prompt(&agent).unwrap();
|
|
307
|
+
assert!(!prompt.contains("report_result"));
|
|
308
|
+
assert!(prompt.contains("send_message"));
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
332
312
|
#[test]
|
|
333
313
|
fn all_provider_mode_prompts_share_silence_contract_without_unconditional_replies() {
|
|
334
|
-
for provider in [
|
|
314
|
+
for provider in [
|
|
315
|
+
Provider::Claude,
|
|
316
|
+
Provider::ClaudeCode,
|
|
317
|
+
Provider::Codex,
|
|
318
|
+
Provider::Copilot,
|
|
319
|
+
Provider::GeminiCli,
|
|
320
|
+
Provider::Grok,
|
|
321
|
+
Provider::Pi,
|
|
322
|
+
Provider::Fake,
|
|
323
|
+
] {
|
|
335
324
|
for mode in CommunicationMode::ALL.iter().copied() {
|
|
336
325
|
let agent = WorkerCommandAgent {
|
|
337
326
|
id: Some("worker".to_string()),
|
|
@@ -339,11 +328,15 @@ mod tests {
|
|
|
339
328
|
role: Some("developer".to_string()),
|
|
340
329
|
system_prompt_inline: Some("worker body".to_string()),
|
|
341
330
|
system_prompt_file: None,
|
|
342
|
-
output_contract_format: Some("result_envelope_v1".to_string()),
|
|
343
331
|
communication_mode: mode,
|
|
344
332
|
dangerously_skip_permissions: false,
|
|
345
333
|
};
|
|
346
334
|
let prompt = compile_worker_system_prompt(&agent).unwrap();
|
|
335
|
+
assert!(!prompt.contains("report_result"));
|
|
336
|
+
let send = mcp_tool_name(provider, "team_orchestrator", "send_message");
|
|
337
|
+
assert!(prompt.contains(&format!(
|
|
338
|
+
"Use {send} exclusively for findings, progress, questions, and completion updates."
|
|
339
|
+
)));
|
|
347
340
|
assert!(prompt.contains(
|
|
348
341
|
"Do not reply to pure ACKs, greetings, or unchanged status notices (such as \"paused\" or \"waiting\"); after reporting a blocker once or completing a task, remain silent until a new actionable instruction arrives."
|
|
349
342
|
));
|