@team-agent/installer 0.5.66 → 0.5.68
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 +8 -1
- package/Cargo.toml +1 -1
- package/crates/team-agent/Cargo.toml +1 -0
- package/crates/team-agent/src/cli/adapters.rs +5 -0
- package/crates/team-agent/src/cli/diagnose.rs +82 -0
- package/crates/team-agent/src/cli/emit.rs +3 -3
- package/crates/team-agent/src/cli/grok_slot.rs +299 -0
- package/crates/team-agent/src/cli/leader.rs +21 -7
- package/crates/team-agent/src/cli/leaders.rs +125 -1
- package/crates/team-agent/src/cli/mod.rs +20 -0
- package/crates/team-agent/src/cli/send/presentation.rs +7 -1
- package/crates/team-agent/src/cli/spec.rs +2 -0
- package/crates/team-agent/src/cli/status_port/compact.rs +28 -0
- package/crates/team-agent/src/cli/status_port/snapshot.rs +25 -1
- package/crates/team-agent/src/cli/tests/base.rs +26 -3
- package/crates/team-agent/src/cli/tests/missing_subcommands.rs +129 -19
- package/crates/team-agent/src/cli/tests/shutdown_kill_plan.rs +387 -6
- package/crates/team-agent/src/cli/tests/status_send.rs +79 -10
- package/crates/team-agent/src/communication_mode/mod.rs +6 -4
- package/crates/team-agent/src/compiler.rs +59 -0
- package/crates/team-agent/src/coordinator/backoff.rs +55 -0
- package/crates/team-agent/src/coordinator/conpty_shim.rs +82 -0
- package/crates/team-agent/src/coordinator/health.rs +173 -0
- package/crates/team-agent/src/coordinator/mod.rs +31 -0
- package/crates/team-agent/src/coordinator/orphan.rs +31 -0
- package/crates/team-agent/src/coordinator/runtime_detectors.rs +30 -0
- package/crates/team-agent/src/coordinator/runtime_observation.rs +25 -0
- package/crates/team-agent/src/coordinator/steps/abnormal.rs +59 -0
- package/crates/team-agent/src/coordinator/steps/delivery.rs +10 -0
- package/crates/team-agent/src/coordinator/steps/health_sync.rs +10 -0
- package/crates/team-agent/src/coordinator/steps/mod.rs +22 -0
- package/crates/team-agent/src/coordinator/steps/persist.rs +10 -0
- package/crates/team-agent/src/coordinator/steps/runtime_prompts.rs +10 -0
- package/crates/team-agent/src/coordinator/steps/session_gate.rs +10 -0
- package/crates/team-agent/src/coordinator/tick.rs +133 -22
- package/crates/team-agent/src/coordinator/types.rs +49 -0
- package/crates/team-agent/src/db/message_store.rs +39 -5
- package/crates/team-agent/src/layout/worker_env.rs +20 -3
- package/crates/team-agent/src/layout/worker_window_helpers.rs +2 -0
- package/crates/team-agent/src/leader/provider_attribution.rs +53 -0
- package/crates/team-agent/src/leader/registry.rs +65 -0
- package/crates/team-agent/src/leader/start.rs +920 -63
- package/crates/team-agent/src/lifecycle/display.rs +56 -0
- package/crates/team-agent/src/lifecycle/helpers.rs +57 -0
- package/crates/team-agent/src/lifecycle/launch/add_agent.rs +332 -12
- package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +62 -0
- package/crates/team-agent/src/lifecycle/launch/agent_state.rs +59 -0
- package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +101 -11
- package/crates/team-agent/src/lifecycle/launch/cursor_create_chat.rs +229 -0
- package/crates/team-agent/src/lifecycle/launch/cursor_mcp.rs +332 -0
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +204 -456
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +24 -0
- package/crates/team-agent/src/lifecycle/launch/grok_per_seat.rs +260 -0
- package/crates/team-agent/src/lifecycle/launch/identity.rs +146 -0
- package/crates/team-agent/src/lifecycle/launch/layout.rs +60 -0
- package/crates/team-agent/src/lifecycle/launch/leader_context.rs +112 -0
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +530 -0
- package/crates/team-agent/src/lifecycle/launch/ownership.rs +40 -0
- package/crates/team-agent/src/lifecycle/launch/plan.rs +31 -0
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +66 -0
- package/crates/team-agent/src/lifecycle/launch/quick_start_transport.rs +78 -0
- package/crates/team-agent/src/lifecycle/launch/readiness.rs +85 -38
- package/crates/team-agent/src/lifecycle/launch/role_source.rs +44 -44
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +62 -2
- package/crates/team-agent/src/lifecycle/launch/spec_state.rs +139 -0
- package/crates/team-agent/src/lifecycle/launch/state_projection.rs +109 -0
- package/crates/team-agent/src/lifecycle/launch/worker_env.rs +214 -1
- package/crates/team-agent/src/lifecycle/launch.rs +99 -29
- package/crates/team-agent/src/lifecycle/lock.rs +42 -1
- package/crates/team-agent/src/lifecycle/mod.rs +11 -0
- package/crates/team-agent/src/lifecycle/pane_input_lock.rs +161 -0
- package/crates/team-agent/src/lifecycle/profile_launch.rs +98 -0
- package/crates/team-agent/src/lifecycle/profile_smoke.rs +51 -1
- package/crates/team-agent/src/lifecycle/restart/agent.rs +124 -0
- package/crates/team-agent/src/lifecycle/restart/common.rs +369 -11
- package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +27 -0
- package/crates/team-agent/src/lifecycle/restart/preflight.rs +25 -0
- package/crates/team-agent/src/lifecycle/restart/rebuild.rs +106 -0
- package/crates/team-agent/src/lifecycle/restart/remove.rs +196 -5
- package/crates/team-agent/src/lifecycle/restart/selection.rs +72 -0
- package/crates/team-agent/src/lifecycle/restart/team_state.rs +22 -0
- package/crates/team-agent/src/lifecycle/restart.rs +29 -0
- package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +2 -3
- package/crates/team-agent/src/lifecycle/tests/clone_agent_preserves_source_tools.rs +309 -0
- package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +150 -157
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +2 -2
- package/crates/team-agent/src/lifecycle/tests/core.rs +4 -0
- package/crates/team-agent/src/lifecycle/tests/cursor_mcp_overlay.rs +287 -0
- package/crates/team-agent/src/lifecycle/tests/cursor_require_explicit_model_red.rs +229 -0
- package/crates/team-agent/src/lifecycle/tests/cursor_restart_resume_red.rs +353 -0
- package/crates/team-agent/src/lifecycle/tests/g1_silent_faces.rs +784 -0
- package/crates/team-agent/src/lifecycle/tests/gate_fixtures.rs +562 -0
- package/crates/team-agent/src/lifecycle/tests/grok_effort_argv_red.rs +239 -0
- package/crates/team-agent/src/lifecycle/tests/grok_mcp_overlay_red.rs +498 -0
- package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +250 -0
- package/crates/team-agent/src/lifecycle/tests/grok_restart_resume_red.rs +293 -0
- package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +63 -38
- package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +3 -2
- package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +16 -8
- package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +69 -0
- package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +20 -19
- package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +97 -61
- package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +2 -0
- package/crates/team-agent/src/lifecycle/tests/startup_latency_contract.rs +40 -7
- package/crates/team-agent/src/lifecycle/tests/test_isolation_escape_contract.rs +59 -1
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +69 -26
- package/crates/team-agent/src/lifecycle/tests.rs +23 -13
- package/crates/team-agent/src/lifecycle/types.rs +61 -0
- package/crates/team-agent/src/lifecycle/worker_command_context.rs +85 -11
- package/crates/team-agent/src/mcp_server/tests/scoped.rs +100 -1
- package/crates/team-agent/src/mcp_server/tests.rs +196 -2
- package/crates/team-agent/src/messaging/delivery.rs +405 -40
- package/crates/team-agent/src/messaging/helpers.rs +2 -0
- package/crates/team-agent/src/messaging/leader_receiver.rs +53 -1
- package/crates/team-agent/src/messaging/results.rs +4 -0
- package/crates/team-agent/src/messaging/send.rs +34 -0
- package/crates/team-agent/src/messaging/tests/dup_inject.rs +406 -0
- package/crates/team-agent/src/messaging/tests/e23.rs +9 -0
- package/crates/team-agent/src/messaging/tests/leader_inject_acceptance.rs +66 -0
- package/crates/team-agent/src/messaging/tests/mod.rs +1 -0
- package/crates/team-agent/src/messaging/types.rs +4 -1
- package/crates/team-agent/src/model/enums.rs +14 -5
- package/crates/team-agent/src/model/permissions.rs +3 -0
- package/crates/team-agent/src/os_probe.rs +73 -2
- package/crates/team-agent/src/provider/adapter.rs +231 -4
- package/crates/team-agent/src/provider/adapters/cursor_agent.rs +86 -0
- package/crates/team-agent/src/provider/adapters/grok.rs +157 -0
- package/crates/team-agent/src/provider/adapters/mod.rs +2 -0
- package/crates/team-agent/src/provider/bypass_flags.rs +46 -2
- package/crates/team-agent/src/provider/classify.rs +4 -2
- package/crates/team-agent/src/provider/faults.rs +2 -1
- package/crates/team-agent/src/provider/mod.rs +11 -0
- package/crates/team-agent/src/provider/session/capture.rs +158 -20
- package/crates/team-agent/src/provider/session/context_fork/claude.rs +38 -1
- package/crates/team-agent/src/provider/session/context_fork/codex.rs +72 -1
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +57 -1
- package/crates/team-agent/src/provider/session/context_fork.rs +77 -3
- package/crates/team-agent/src/provider/session/mod.rs +18 -0
- package/crates/team-agent/src/provider/session/resume.rs +57 -0
- package/crates/team-agent/src/provider/session_scan/claude.rs +125 -1
- package/crates/team-agent/src/provider/session_scan/codex.rs +94 -1
- package/crates/team-agent/src/provider/session_scan/common.rs +204 -2
- package/crates/team-agent/src/provider/session_scan/copilot.rs +33 -1
- package/crates/team-agent/src/provider/session_scan/cursor.rs +538 -0
- package/crates/team-agent/src/provider/session_scan/grok.rs +288 -0
- package/crates/team-agent/src/provider/session_scan.rs +8 -0
- package/crates/team-agent/src/provider/submit_now.rs +94 -0
- package/crates/team-agent/src/provider/tests/adapter.rs +304 -0
- package/crates/team-agent/src/provider/types.rs +4 -2
- package/crates/team-agent/src/provider/wire.rs +23 -1
- package/crates/team-agent/src/state/persist.rs +301 -8
- package/crates/team-agent/src/state/repository.rs +5 -0
- package/crates/team-agent/src/tmux_backend/tests.rs +1737 -42
- package/crates/team-agent/src/tmux_backend.rs +1064 -75
- package/crates/team-agent/src/transport/tests/wire.rs +28 -2
- package/crates/team-agent/src/transport.rs +248 -1
- package/npm/install.mjs +129 -73
- package/package.json +4 -4
- package/skills/team-agent/SKILL.md +33 -238
- package/skills/team-agent/command-coverage.json +31 -0
- package/crates/team-agent/src/lifecycle/launch/fork_agent/completion.rs +0 -59
- package/crates/team-agent/src/lifecycle/launch/fork_finalize.rs +0 -488
- package/crates/team-agent/src/lifecycle/launch/fork_pending.rs +0 -109
- package/crates/team-agent/src/lifecycle/launch/fork_state.rs +0 -447
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
//! ---
|
|
2
|
+
//! purpose: grok 席位角色 effort 必须进入 argv;缺字段不发 flag
|
|
3
|
+
//! contract:
|
|
4
|
+
//! provides:
|
|
5
|
+
//! - name: grok-effort-medium-reaches-argv
|
|
6
|
+
//! what: effort: medium ⇒ 相邻 `--effort medium`
|
|
7
|
+
//! - name: grok-effort-absent-omits-flag
|
|
8
|
+
//! what: 角色无 effort 字段 ⇒ argv 中 `--effort` 次数为 0
|
|
9
|
+
//! - name: grok-effort-survives-restart
|
|
10
|
+
//! what: restart 后仍带同一档
|
|
11
|
+
//! - name: grok-effort-no-longer-silently-dropped
|
|
12
|
+
//! what: 已废除「grok effort 被静默丢弃 + effort_unsupported」
|
|
13
|
+
//! boundary: 只钉 Provider::Grok 的 effort 启动契约;不改 claude/codex/cursor
|
|
14
|
+
//! maturity: wired
|
|
15
|
+
//! ---
|
|
16
|
+
|
|
17
|
+
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
|
|
18
|
+
|
|
19
|
+
#[path = "../../../tests/support/hermetic.rs"]
|
|
20
|
+
mod hermetic_guard;
|
|
21
|
+
#[allow(dead_code)]
|
|
22
|
+
fn _hermetic_boundary_marker(_: &hermetic_guard::HermeticTestEnv) {}
|
|
23
|
+
|
|
24
|
+
use std::path::{Path, PathBuf};
|
|
25
|
+
use std::sync::atomic::{AtomicU64, Ordering};
|
|
26
|
+
|
|
27
|
+
use serial_test::serial;
|
|
28
|
+
use team_agent::lifecycle::{quick_start_with_transport_in_workspace, restart_with_transport};
|
|
29
|
+
use team_agent::transport::test_support::OfflineTransport;
|
|
30
|
+
|
|
31
|
+
#[test]
|
|
32
|
+
#[serial(env)]
|
|
33
|
+
fn grok_role_effort_medium_reaches_argv() {
|
|
34
|
+
let (ws, _home, _guard, team) = seed_grok("effort-medium", Some("medium"));
|
|
35
|
+
let transport = OfflineTransport::new();
|
|
36
|
+
quick_start_with_transport_in_workspace(&ws, &team, None, true, Some("grokteam"), &transport)
|
|
37
|
+
.expect("grok role with effort: medium must start");
|
|
38
|
+
let argv = first_spawn_argv(&transport);
|
|
39
|
+
assert!(
|
|
40
|
+
argv_contains_adjacent(&argv, &["--effort", "medium"]),
|
|
41
|
+
"declared effort must appear as adjacent `--effort medium`; argv={argv:?}"
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
#[test]
|
|
46
|
+
#[serial(env)]
|
|
47
|
+
fn grok_role_without_effort_emits_zero_effort_flags() {
|
|
48
|
+
let (ws, _home, _guard, team) = seed_grok("effort-absent", None);
|
|
49
|
+
let transport = OfflineTransport::new();
|
|
50
|
+
quick_start_with_transport_in_workspace(&ws, &team, None, true, Some("grokteam"), &transport)
|
|
51
|
+
.expect("grok role without effort must start");
|
|
52
|
+
let argv = first_spawn_argv(&transport);
|
|
53
|
+
let count = argv.iter().filter(|a| *a == "--effort").count();
|
|
54
|
+
assert_eq!(
|
|
55
|
+
count, 0,
|
|
56
|
+
"absent effort must not invent a default flag; argv={argv:?}"
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
#[test]
|
|
61
|
+
#[serial(env)]
|
|
62
|
+
fn grok_restart_keeps_declared_effort_medium() {
|
|
63
|
+
let (ws, _home, _guard, team) = seed_grok("effort-restart", Some("medium"));
|
|
64
|
+
let first = OfflineTransport::new();
|
|
65
|
+
quick_start_with_transport_in_workspace(&ws, &team, None, true, Some("grokteam"), &first)
|
|
66
|
+
.expect("initial grok start");
|
|
67
|
+
assert!(
|
|
68
|
+
argv_contains_adjacent(&first_spawn_argv(&first), &["--effort", "medium"]),
|
|
69
|
+
"precondition: first start must carry medium; argv={:?}",
|
|
70
|
+
first_spawn_argv(&first)
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
seed_healthy_coordinator(&ws);
|
|
74
|
+
|
|
75
|
+
let restart = OfflineTransport::new();
|
|
76
|
+
restart_with_transport(&ws, true, Some("grokteam"), &restart)
|
|
77
|
+
.expect("restart --allow-fresh must start the grok seat");
|
|
78
|
+
let argv = first_spawn_argv(&restart);
|
|
79
|
+
assert!(
|
|
80
|
+
argv_contains_adjacent(&argv, &["--effort", "medium"]),
|
|
81
|
+
"restart must keep the persisted effort; argv={argv:?}"
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
#[test]
|
|
86
|
+
#[serial(env)]
|
|
87
|
+
fn grok_role_effort_max_is_rejected_at_compile() {
|
|
88
|
+
let (ws, _home, _guard, team) = seed_grok("effort-max", Some("max"));
|
|
89
|
+
let err =
|
|
90
|
+
team_agent::compiler::compile_team(&team).expect_err("grok + effort:max must not compile");
|
|
91
|
+
let text = err.to_string();
|
|
92
|
+
assert!(
|
|
93
|
+
text.contains("max") && (text.contains("claude") || text.contains("only supported")),
|
|
94
|
+
"max must stay claude-only at compile; err={text}"
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
#[test]
|
|
99
|
+
#[serial(env)]
|
|
100
|
+
fn grok_medium_effort_no_longer_emits_unsupported_event() {
|
|
101
|
+
// 已废除的行为:旧实现把 grok 的 effort 静默丢掉并写 provider.effort_unsupported,
|
|
102
|
+
// 此断言证明它确实没了。
|
|
103
|
+
let (ws, _home, _guard, team) = seed_grok("effort-tombstone", Some("medium"));
|
|
104
|
+
let transport = OfflineTransport::new();
|
|
105
|
+
quick_start_with_transport_in_workspace(&ws, &team, None, true, Some("grokteam"), &transport)
|
|
106
|
+
.expect("grok role with effort: medium must start");
|
|
107
|
+
let events = team_agent::event_log::EventLog::new(&ws)
|
|
108
|
+
.tail(0)
|
|
109
|
+
.expect("events");
|
|
110
|
+
let dropped = events.iter().any(|event| {
|
|
111
|
+
event.get("event").and_then(serde_json::Value::as_str)
|
|
112
|
+
== Some("provider.effort_unsupported")
|
|
113
|
+
});
|
|
114
|
+
assert!(
|
|
115
|
+
!dropped,
|
|
116
|
+
"grok medium must not emit provider.effort_unsupported; events={events:?}"
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/// restart 的就绪门要求 `coordinator_health().ok`,而单测里 `start_coordinator`
|
|
121
|
+
/// spawn 的是 `std::env::current_exe()` —— 也就是 libtest 测试二进制本身,它一启动
|
|
122
|
+
/// 就以 `Unrecognized option: 'workspace'` 退出并变成僵尸,`pid_is_running` 的
|
|
123
|
+
/// `ps stat=` 一看到 `Z` 就判 not running。于是就绪门只能靠「抢在死婴被看到之前
|
|
124
|
+
/// 探到它」这个竞态过关,慢机/高负载上必然超时。这里按本仓既有写法(见
|
|
125
|
+
/// `copilot_provider_red.rs` / `restart_build_before_destroy_0540_contract.rs`)
|
|
126
|
+
/// 预先把 pid 文件与 metadata 指向测试进程自己,让 `start_coordinator` 走
|
|
127
|
+
/// `AlreadyRunning` 早返回,竞态被删掉而不是被调宽。
|
|
128
|
+
fn seed_healthy_coordinator(workspace: &Path) {
|
|
129
|
+
let workspace = crate::coordinator::WorkspacePath::new(workspace.to_path_buf());
|
|
130
|
+
let pid = crate::coordinator::Pid::new(std::process::id());
|
|
131
|
+
std::fs::create_dir_all(
|
|
132
|
+
crate::coordinator::coordinator_pid_path(&workspace)
|
|
133
|
+
.parent()
|
|
134
|
+
.unwrap(),
|
|
135
|
+
)
|
|
136
|
+
.unwrap();
|
|
137
|
+
crate::coordinator::write_coordinator_metadata(
|
|
138
|
+
&workspace,
|
|
139
|
+
pid,
|
|
140
|
+
crate::coordinator::MetadataSource::Boot,
|
|
141
|
+
)
|
|
142
|
+
.expect("write coordinator metadata");
|
|
143
|
+
std::fs::write(
|
|
144
|
+
crate::coordinator::coordinator_pid_path(&workspace),
|
|
145
|
+
pid.to_string(),
|
|
146
|
+
)
|
|
147
|
+
.expect("write coordinator pid");
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
fn seed_grok(tag: &str, effort: Option<&str>) -> (PathBuf, PathBuf, HomeGuard, PathBuf) {
|
|
151
|
+
let ws = tmp_dir(tag);
|
|
152
|
+
let home = tmp_dir(&format!("{tag}-home"));
|
|
153
|
+
seed_grok_home(&home, Some(&ws));
|
|
154
|
+
let guard = HomeGuard::set(&home);
|
|
155
|
+
let team = write_grok_role(&ws, effort);
|
|
156
|
+
(ws, home, guard, team)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
fn first_spawn_argv(transport: &OfflineTransport) -> Vec<String> {
|
|
160
|
+
let records = transport.spawn_records();
|
|
161
|
+
assert!(
|
|
162
|
+
!records.is_empty(),
|
|
163
|
+
"expected a worker spawn so argv can be inspected; records={records:?}"
|
|
164
|
+
);
|
|
165
|
+
records[0].1.clone()
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
fn argv_contains_adjacent(hay: &[String], needle: &[&str]) -> bool {
|
|
169
|
+
hay.windows(needle.len())
|
|
170
|
+
.any(|window| window.iter().map(String::as_str).eq(needle.iter().copied()))
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
fn write_grok_role(ws: &Path, effort: Option<&str>) -> PathBuf {
|
|
174
|
+
let team = ws.join("grokteam");
|
|
175
|
+
std::fs::create_dir_all(team.join("agents")).unwrap();
|
|
176
|
+
std::fs::write(
|
|
177
|
+
team.join("TEAM.md"),
|
|
178
|
+
"---\nname: grokteam\nobjective: grok effort argv.\nprovider: grok\ndangerously_skip_permissions: false\n---\n\nTeam.\n",
|
|
179
|
+
)
|
|
180
|
+
.unwrap();
|
|
181
|
+
let effort_line = match effort {
|
|
182
|
+
Some(value) => format!("effort: {value}\n"),
|
|
183
|
+
None => String::new(),
|
|
184
|
+
};
|
|
185
|
+
std::fs::write(
|
|
186
|
+
team.join("agents").join("grok_writer.md"),
|
|
187
|
+
format!(
|
|
188
|
+
"---\nname: grok_writer\nrole: Grok Writer\nprovider: grok\nmodel: grok-4.6\n{effort_line}auth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nWorker.\n"
|
|
189
|
+
),
|
|
190
|
+
)
|
|
191
|
+
.unwrap();
|
|
192
|
+
team
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
fn seed_grok_home(home: &Path, trusted_cwd: Option<&Path>) {
|
|
196
|
+
let grok = home.join(".grok");
|
|
197
|
+
std::fs::create_dir_all(&grok).unwrap();
|
|
198
|
+
std::fs::write(grok.join("auth.json"), r#"{"test":"ok"}"#).unwrap();
|
|
199
|
+
if let Some(cwd) = trusted_cwd {
|
|
200
|
+
std::fs::write(
|
|
201
|
+
grok.join("trusted_folders.toml"),
|
|
202
|
+
format!("[folders.\"{}\"]\ntrusted = true\n", cwd.display()),
|
|
203
|
+
)
|
|
204
|
+
.unwrap();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
struct HomeGuard {
|
|
209
|
+
prev: Option<String>,
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
impl HomeGuard {
|
|
213
|
+
fn set(home: &Path) -> Self {
|
|
214
|
+
let prev = std::env::var("HOME").ok();
|
|
215
|
+
std::env::set_var("HOME", home);
|
|
216
|
+
Self { prev }
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
impl Drop for HomeGuard {
|
|
221
|
+
fn drop(&mut self) {
|
|
222
|
+
match &self.prev {
|
|
223
|
+
Some(value) => std::env::set_var("HOME", value),
|
|
224
|
+
None => std::env::remove_var("HOME"),
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
fn tmp_dir(tag: &str) -> PathBuf {
|
|
230
|
+
static N: AtomicU64 = AtomicU64::new(0);
|
|
231
|
+
let dir = std::env::temp_dir().join(format!(
|
|
232
|
+
"ta-rs-grok-effort-{tag}-{}-{}",
|
|
233
|
+
std::process::id(),
|
|
234
|
+
N.fetch_add(1, Ordering::Relaxed)
|
|
235
|
+
));
|
|
236
|
+
let _ = std::fs::remove_dir_all(&dir);
|
|
237
|
+
std::fs::create_dir_all(&dir).unwrap();
|
|
238
|
+
std::fs::canonicalize(dir).unwrap()
|
|
239
|
+
}
|