@team-agent/installer 0.5.42 → 0.5.44
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/crates/team-agent/src/cli/adapters.rs +129 -54
- package/crates/team-agent/src/cli/diagnose.rs +1 -2
- package/crates/team-agent/src/cli/emit.rs +1 -7
- package/crates/team-agent/src/cli/helpers.rs +3 -1
- package/crates/team-agent/src/cli/leader.rs +2 -1
- package/crates/team-agent/src/cli/mod.rs +126 -16
- package/crates/team-agent/src/cli/named_address.rs +14 -5
- package/crates/team-agent/src/cli/profile.rs +19 -7
- package/crates/team-agent/src/cli/send.rs +9 -3
- package/crates/team-agent/src/cli/status.rs +8 -30
- package/crates/team-agent/src/cli/status_port.rs +1341 -1272
- package/crates/team-agent/src/cli/tests/base.rs +738 -660
- package/crates/team-agent/src/cli/tests/compile.rs +45 -18
- package/crates/team-agent/src/cli/tests/divergence.rs +462 -444
- package/crates/team-agent/src/cli/tests/lane_c.rs +365 -282
- package/crates/team-agent/src/cli/tests/leader_watch.rs +356 -329
- package/crates/team-agent/src/cli/tests/main_preserved.rs +672 -564
- package/crates/team-agent/src/cli/tests/missing_subcommands.rs +284 -224
- package/crates/team-agent/src/cli/tests/mod.rs +17 -7
- package/crates/team-agent/src/cli/tests/named_address.rs +8 -2
- package/crates/team-agent/src/cli/tests/peer_allow.rs +10 -2
- package/crates/team-agent/src/cli/tests/run_delegation.rs +314 -273
- package/crates/team-agent/src/cli/tests/shutdown_kill_plan.rs +26 -15
- package/crates/team-agent/src/cli/tests/status_send.rs +707 -629
- package/crates/team-agent/src/cli/tests/verb_install_skill.rs +20 -4
- package/crates/team-agent/src/cli/tests/verb_profile.rs +46 -17
- package/crates/team-agent/src/cli/tests/verb_validate.rs +15 -3
- package/crates/team-agent/src/codex_app_server.rs +2 -5
- package/crates/team-agent/src/compiler/tests.rs +139 -33
- package/crates/team-agent/src/compiler.rs +55 -22
- package/crates/team-agent/src/conpty/backend.rs +23 -33
- package/crates/team-agent/src/coordinator/backoff.rs +2 -7
- package/crates/team-agent/src/coordinator/conpty_shim.rs +55 -67
- package/crates/team-agent/src/coordinator/health.rs +46 -31
- package/crates/team-agent/src/coordinator/mod.rs +3 -3
- package/crates/team-agent/src/coordinator/orphan.rs +22 -10
- package/crates/team-agent/src/coordinator/steps/abnormal.rs +51 -56
- package/crates/team-agent/src/coordinator/tests/abnormal.rs +55 -19
- package/crates/team-agent/src/coordinator/tests/basics.rs +179 -41
- package/crates/team-agent/src/coordinator/tests/daemon.rs +53 -13
- package/crates/team-agent/src/coordinator/tests/health_sync.rs +78 -19
- package/crates/team-agent/src/coordinator/tests/main_preserved.rs +61 -11
- package/crates/team-agent/src/coordinator/tests/mod.rs +33 -39
- package/crates/team-agent/src/coordinator/tests/spine.rs +52 -12
- package/crates/team-agent/src/coordinator/tests/takeover.rs +73 -15
- package/crates/team-agent/src/coordinator/tests/tick_core.rs +50 -15
- package/crates/team-agent/src/coordinator/tests/watch.rs +74 -20
- package/crates/team-agent/src/db/message_store.rs +138 -30
- package/crates/team-agent/src/db/migration.rs +249 -61
- package/crates/team-agent/src/db/schema.rs +303 -82
- package/crates/team-agent/src/diagnose/comms.rs +9 -2
- package/crates/team-agent/src/diagnose/mod.rs +1 -3
- package/crates/team-agent/src/diagnose/orphans.rs +79 -61
- package/crates/team-agent/src/event_log.rs +70 -16
- package/crates/team-agent/src/layout/manager.rs +15 -4
- package/crates/team-agent/src/layout/mod.rs +4 -4
- package/crates/team-agent/src/layout/overlay.rs +10 -3
- package/crates/team-agent/src/layout/placement.rs +5 -1
- package/crates/team-agent/src/layout/recovery.rs +4 -2
- package/crates/team-agent/src/layout/runtime_sessions.rs +7 -7
- package/crates/team-agent/src/layout/sessions.rs +17 -9
- package/crates/team-agent/src/layout/tmux_endpoint.rs +1 -1
- package/crates/team-agent/src/layout/worker_env.rs +87 -19
- package/crates/team-agent/src/leader/helpers.rs +7 -1
- package/crates/team-agent/src/leader/lease.rs +199 -89
- package/crates/team-agent/src/leader/owner_bind.rs +55 -22
- package/crates/team-agent/src/leader/provider_attribution.rs +25 -6
- package/crates/team-agent/src/leader/rediscover/tests.rs +88 -24
- package/crates/team-agent/src/leader/rediscover.rs +74 -25
- package/crates/team-agent/src/leader/registry.rs +1 -1
- package/crates/team-agent/src/leader/start.rs +75 -54
- package/crates/team-agent/src/leader/takeover.rs +46 -11
- package/crates/team-agent/src/leader/tests/basics.rs +320 -167
- package/crates/team-agent/src/leader/tests/byte_findings.rs +361 -219
- package/crates/team-agent/src/leader/tests/identity.rs +428 -356
- package/crates/team-agent/src/leader/tests/idle.rs +285 -254
- package/crates/team-agent/src/leader/tests/lease_api.rs +338 -274
- package/crates/team-agent/src/leader/tests/lease_claim.rs +643 -593
- package/crates/team-agent/src/leader/tests/mod.rs +115 -99
- package/crates/team-agent/src/leader/tests/rediscover.rs +74 -22
- package/crates/team-agent/src/leader/tests/wake_start_owner.rs +237 -211
- package/crates/team-agent/src/lib.rs +4 -4
- package/crates/team-agent/src/lifecycle/display.rs +7 -3
- package/crates/team-agent/src/lifecycle/launch.rs +55 -15
- package/crates/team-agent/src/lifecycle/mod.rs +9 -1
- package/crates/team-agent/src/lifecycle/profile_launch.rs +77 -34
- package/crates/team-agent/src/lifecycle/profile_smoke.rs +3 -1
- package/crates/team-agent/src/lifecycle/restart/agent.rs +1 -6
- package/crates/team-agent/src/lifecycle/restart/common.rs +6 -2
- package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +1 -4
- package/crates/team-agent/src/lifecycle/restart/preflight.rs +6 -5
- package/crates/team-agent/src/lifecycle/restart/rebuild.rs +26 -22
- package/crates/team-agent/src/lifecycle/restart/remove.rs +45 -35
- package/crates/team-agent/src/lifecycle/restart/team_state.rs +63 -17
- package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +251 -84
- package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +198 -48
- package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +2 -1
- package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +152 -32
- package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +1 -5
- package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +3 -0
- package/crates/team-agent/src/lifecycle/tests.rs +2 -2
- package/crates/team-agent/src/main.rs +4 -4
- package/crates/team-agent/src/mcp_server/lifecycle_tools/agent_ops.rs +47 -20
- package/crates/team-agent/src/mcp_server/mod.rs +11 -2
- package/crates/team-agent/src/mcp_server/types.rs +14 -3
- package/crates/team-agent/src/mcp_server/wire.rs +230 -68
- package/crates/team-agent/src/messaging/delivery.rs +20 -18
- package/crates/team-agent/src/messaging/helpers.rs +25 -4
- package/crates/team-agent/src/messaging/leader_receiver.rs +4 -5
- package/crates/team-agent/src/messaging/mod.rs +2 -3
- package/crates/team-agent/src/messaging/selftest.rs +46 -26
- package/crates/team-agent/src/messaging/tests/main_preserved.rs +47 -12
- package/crates/team-agent/src/messaging/tests/runtime.rs +57 -22
- package/crates/team-agent/src/messaging/tests/spine.rs +154 -40
- package/crates/team-agent/src/messaging/tests/wave2.rs +31 -32
- package/crates/team-agent/src/messaging/trust.rs +25 -2
- package/crates/team-agent/src/messaging/watchers.rs +37 -9
- package/crates/team-agent/src/model/enums.rs +65 -16
- package/crates/team-agent/src/model/ids.rs +12 -3
- package/crates/team-agent/src/model/paths.rs +28 -7
- package/crates/team-agent/src/model/permissions.rs +176 -33
- package/crates/team-agent/src/model/routing.rs +66 -20
- package/crates/team-agent/src/model/spec.rs +365 -69
- package/crates/team-agent/src/model/task_graph.rs +36 -9
- package/crates/team-agent/src/model/yaml/tests.rs +24 -6
- package/crates/team-agent/src/model/yaml.rs +7 -6
- package/crates/team-agent/src/packaging/install.rs +23 -9
- package/crates/team-agent/src/packaging/migrate.rs +5 -7
- package/crates/team-agent/src/packaging/mod.rs +9 -1
- package/crates/team-agent/src/packaging/repair.rs +13 -6
- package/crates/team-agent/src/packaging/tests.rs +63 -16
- package/crates/team-agent/src/packaging/types.rs +22 -7
- package/crates/team-agent/src/platform/argv.rs +4 -1
- package/crates/team-agent/src/platform/file_lock.rs +22 -8
- package/crates/team-agent/src/platform/process.rs +54 -24
- package/crates/team-agent/src/provider/adapters/claude.rs +1 -3
- package/crates/team-agent/src/provider/approvals/parsing.rs +134 -26
- package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +13 -3
- package/crates/team-agent/src/provider/classify.rs +127 -42
- package/crates/team-agent/src/provider/faults.rs +17 -5
- package/crates/team-agent/src/provider/helpers.rs +6 -5
- package/crates/team-agent/src/provider/startup_prompt.rs +75 -27
- package/crates/team-agent/src/state/persist.rs +28 -0
- package/crates/team-agent/src/state/repository.rs +8 -3
- package/crates/team-agent/src/tmux_backend/tests.rs +1637 -1398
- package/crates/team-agent/src/tmux_backend.rs +80 -44
- package/crates/team-agent/src/topology.rs +40 -20
- package/crates/team-agent/src/transport/test_support.rs +20 -23
- package/crates/team-agent/src/transport/tests/behavior.rs +292 -293
- package/crates/team-agent/src/transport/tests/mod.rs +178 -187
- package/crates/team-agent/src/transport/tests/wire.rs +561 -525
- package/crates/team-agent/src/transport.rs +12 -17
- package/crates/team-agent/src/transport_factory.rs +29 -14
- package/package.json +4 -4
|
@@ -27,8 +27,7 @@ static WHEN_EQ: LazyLock<Option<Regex>> =
|
|
|
27
27
|
LazyLock::new(|| Regex::new(r#"^task\.(type|risk)\s*==\s*['"]([^'"]+)['"]\z"#).ok());
|
|
28
28
|
static WHEN_FILES: LazyLock<Option<Regex>> =
|
|
29
29
|
LazyLock::new(|| Regex::new(r"^task\.files\s+matches\s+\[(.*)\]\z").ok());
|
|
30
|
-
static QUOTED: LazyLock<Option<Regex>> =
|
|
31
|
-
LazyLock::new(|| Regex::new(r#"['"]([^'"]+)['"]"#).ok());
|
|
30
|
+
static QUOTED: LazyLock<Option<Regex>> = LazyLock::new(|| Regex::new(r#"['"]([^'"]+)['"]"#).ok());
|
|
32
31
|
|
|
33
32
|
/// `routing.route_task(spec, task)`。
|
|
34
33
|
pub fn route_task(spec: &Yaml, task: &Yaml) -> RouteResult {
|
|
@@ -41,11 +40,18 @@ pub fn route_task(spec: &Yaml, task: &Yaml) -> RouteResult {
|
|
|
41
40
|
// valid_agents = {leader_id} ∪ {agent.id}
|
|
42
41
|
let agents: &[Yaml] = spec.get("agents").and_then(Yaml::as_list).unwrap_or(&[]);
|
|
43
42
|
let valid = |id: &str| {
|
|
44
|
-
id == leader_id
|
|
43
|
+
id == leader_id
|
|
44
|
+
|| agents
|
|
45
|
+
.iter()
|
|
46
|
+
.any(|a| a.get("id").and_then(Yaml::as_str) == Some(id))
|
|
45
47
|
};
|
|
46
48
|
|
|
47
49
|
// explicit assignee(truthy)。
|
|
48
|
-
if let Some(explicit) = task
|
|
50
|
+
if let Some(explicit) = task
|
|
51
|
+
.get("assignee")
|
|
52
|
+
.and_then(Yaml::as_str)
|
|
53
|
+
.filter(|s| !s.is_empty())
|
|
54
|
+
{
|
|
49
55
|
if valid(explicit) {
|
|
50
56
|
return RouteResult {
|
|
51
57
|
agent_id: AgentId::from(explicit),
|
|
@@ -70,7 +76,10 @@ pub fn route_task(spec: &Yaml, task: &Yaml) -> RouteResult {
|
|
|
70
76
|
|
|
71
77
|
for rule in rules {
|
|
72
78
|
if rule_matches(rule, task) {
|
|
73
|
-
let id = rule
|
|
79
|
+
let id = rule
|
|
80
|
+
.get("assign_to")
|
|
81
|
+
.and_then(Yaml::as_str)
|
|
82
|
+
.unwrap_or(leader_id);
|
|
74
83
|
let rule_id = rule.get("id").and_then(Yaml::as_str).unwrap_or("<unnamed>");
|
|
75
84
|
return RouteResult {
|
|
76
85
|
agent_id: AgentId::from(id),
|
|
@@ -98,7 +107,10 @@ fn rule_matches(rule: &Yaml, task: &Yaml) -> bool {
|
|
|
98
107
|
}
|
|
99
108
|
if let Some(when) = rule.get("when").filter(|w| w.is_truthy()) {
|
|
100
109
|
// Python str(when):when 通常是字符串;非字符串退化为其 Debug(极少见)。
|
|
101
|
-
let expr = when
|
|
110
|
+
let expr = when
|
|
111
|
+
.as_str()
|
|
112
|
+
.map(str::to_string)
|
|
113
|
+
.unwrap_or_else(|| format!("{when:?}"));
|
|
102
114
|
if !when_match(&expr, task) {
|
|
103
115
|
return false;
|
|
104
116
|
}
|
|
@@ -136,7 +148,10 @@ fn structured_match(m: &Yaml, task: &Yaml) -> bool {
|
|
|
136
148
|
}
|
|
137
149
|
}
|
|
138
150
|
if let Some(files_pat) = m.get("files") {
|
|
139
|
-
let patterns: Vec<&str> = as_list(files_pat)
|
|
151
|
+
let patterns: Vec<&str> = as_list(files_pat)
|
|
152
|
+
.iter()
|
|
153
|
+
.filter_map(|v| v.as_str())
|
|
154
|
+
.collect();
|
|
140
155
|
let files: Vec<&str> = task
|
|
141
156
|
.get("files")
|
|
142
157
|
.and_then(Yaml::as_list)
|
|
@@ -156,7 +171,10 @@ fn when_match(expr: &str, task: &Yaml) -> bool {
|
|
|
156
171
|
if let Some(re) = WHEN_TYPE_IN.as_ref() {
|
|
157
172
|
if let Some(c) = re.captures(expr) {
|
|
158
173
|
let values = quoted_values(c.get(1).map_or("", |m| m.as_str()));
|
|
159
|
-
return task
|
|
174
|
+
return task
|
|
175
|
+
.get("type")
|
|
176
|
+
.and_then(Yaml::as_str)
|
|
177
|
+
.is_some_and(|t| values.iter().any(|v| v == t));
|
|
160
178
|
}
|
|
161
179
|
}
|
|
162
180
|
if let Some(re) = WHEN_EQ.as_ref() {
|
|
@@ -234,7 +252,8 @@ fn fnmatch_translate(pat: &str) -> String {
|
|
|
234
252
|
if j >= n {
|
|
235
253
|
body.push_str("\\[");
|
|
236
254
|
} else {
|
|
237
|
-
let mut stuff: String =
|
|
255
|
+
let mut stuff: String =
|
|
256
|
+
chars[i..j].iter().collect::<String>().replace('\\', "\\\\");
|
|
238
257
|
i = j + 1;
|
|
239
258
|
if let Some(rest) = stuff.strip_prefix('!') {
|
|
240
259
|
stuff = format!("^{rest}");
|
|
@@ -254,7 +273,11 @@ fn fnmatch_translate(pat: &str) -> String {
|
|
|
254
273
|
|
|
255
274
|
/// Python `repr()` of a str(简化:identifier 类用单引号,含单引号无双引号用双引号)。
|
|
256
275
|
fn py_repr_str(s: &str) -> String {
|
|
257
|
-
let quote = if s.contains('\'') && !s.contains('"') {
|
|
276
|
+
let quote = if s.contains('\'') && !s.contains('"') {
|
|
277
|
+
'"'
|
|
278
|
+
} else {
|
|
279
|
+
'\''
|
|
280
|
+
};
|
|
258
281
|
let mut out = String::new();
|
|
259
282
|
out.push(quote);
|
|
260
283
|
for c in s.chars() {
|
|
@@ -289,12 +312,32 @@ mod tests {
|
|
|
289
312
|
fn route_task_matches_python_golden() {
|
|
290
313
|
let s = spec();
|
|
291
314
|
let cases: &[(&str, &str, &str)] = &[
|
|
292
|
-
(
|
|
293
|
-
|
|
294
|
-
|
|
315
|
+
(
|
|
316
|
+
r#"{"type":"implementation"}"#,
|
|
317
|
+
"codex_implementer",
|
|
318
|
+
"matched routing rule implementation-to-codex",
|
|
319
|
+
),
|
|
320
|
+
(
|
|
321
|
+
r#"{"type":"research"}"#,
|
|
322
|
+
"codex_researcher",
|
|
323
|
+
"matched routing rule research-to-codex",
|
|
324
|
+
),
|
|
325
|
+
(
|
|
326
|
+
r#"{"type":"review"}"#,
|
|
327
|
+
"codex_reviewer",
|
|
328
|
+
"matched routing rule review-to-codex",
|
|
329
|
+
),
|
|
295
330
|
(r#"{"type":"unknown"}"#, "leader", "no routing rule matched"),
|
|
296
|
-
(
|
|
297
|
-
|
|
331
|
+
(
|
|
332
|
+
r#"{"assignee":"codex_implementer","type":"x"}"#,
|
|
333
|
+
"codex_implementer",
|
|
334
|
+
"explicit assignee on task",
|
|
335
|
+
),
|
|
336
|
+
(
|
|
337
|
+
r#"{"assignee":"ghost","type":"x"}"#,
|
|
338
|
+
"leader",
|
|
339
|
+
"unknown explicit assignee 'ghost'",
|
|
340
|
+
),
|
|
298
341
|
(r#"{}"#, "leader", "no routing rule matched"),
|
|
299
342
|
];
|
|
300
343
|
for (t, want_id, want_reason) in cases {
|
|
@@ -318,7 +361,8 @@ mod tests {
|
|
|
318
361
|
#[test]
|
|
319
362
|
fn structured_match_and_files() {
|
|
320
363
|
// 构造带 match dict 的规则,验 type/files。
|
|
321
|
-
let rule =
|
|
364
|
+
let rule =
|
|
365
|
+
task(r#"{"id":"r1","assign_to":"w","priority":1,"match":{"files":["src/*.rs"]}}"#);
|
|
322
366
|
assert!(rule_matches(&rule, &task(r#"{"files":["src/main.rs"]}"#)));
|
|
323
367
|
assert!(!rule_matches(&rule, &task(r#"{"files":["docs/x.md"]}"#)));
|
|
324
368
|
}
|
|
@@ -328,10 +372,12 @@ mod tests {
|
|
|
328
372
|
// Backlog control bug: compiler emits one route per agent with match.assignee.
|
|
329
373
|
// match.assignee must be a real predicate; otherwise every route is unconditional and
|
|
330
374
|
// tasks funnel into the first/highest-priority rule.
|
|
331
|
-
let alpha_rule =
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
375
|
+
let alpha_rule = task(
|
|
376
|
+
r#"{"id":"route-alpha","match":{"assignee":["alpha"]},"assign_to":"alpha","priority":10}"#,
|
|
377
|
+
);
|
|
378
|
+
let bravo_rule = task(
|
|
379
|
+
r#"{"id":"route-bravo","match":{"assignee":["bravo"]},"assign_to":"bravo","priority":10}"#,
|
|
380
|
+
);
|
|
335
381
|
let bravo_task = task(r#"{"id":"t1","assignee":"bravo"}"#);
|
|
336
382
|
|
|
337
383
|
assert!(!rule_matches(&alpha_rule, &bravo_task));
|