@team-agent/installer 0.5.123 → 0.5.124
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/intent/runtime.rs +25 -1
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +61 -0
- package/crates/team-agent/src/cli/models.rs +54 -10
- package/crates/team-agent/src/contract_runtime/backend.rs +8 -0
- package/crates/team-agent/src/contract_runtime/discovery.rs +46 -56
- package/crates/team-agent/src/contract_runtime/registry.rs +41 -3
- package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +19 -101
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +5 -6
- package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +1 -3
- package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +4 -16
- package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +1 -3
- package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +84 -53
- package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +19 -1
- package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +21 -0
- package/crates/team-agent/src/messaging/delivery.rs +5 -3
- package/crates/team-agent/src/provider/adapters/pi.rs +4 -4
- package/crates/team-agent/src/provider/session_scan/pi.rs +32 -19
- package/crates/team-agent/src/provider/tests/command_helpers.rs +2 -2
- package/npm/install.mjs +40 -3
- package/package.json +4 -4
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//! contract:
|
|
4
4
|
//! provides:
|
|
5
5
|
//! - name: scan_session_store
|
|
6
|
-
//! what: 只读每个 JSONL 的首个完整 header
|
|
6
|
+
//! what: 只读每个 JSONL 的首个完整 header;有预期 id 时按 id/cwd/spawned_at,否则按 cwd/spawned_at 读取 Pi 自己的 id
|
|
7
7
|
//! - name: validate_exact_backing
|
|
8
8
|
//! what: restart 前重验 exact path 的 id/cwd header
|
|
9
9
|
//! boundary:
|
|
@@ -49,13 +49,8 @@ fn read_header(path: &Path) -> Option<PiSessionHeader> {
|
|
|
49
49
|
(header.record_type == "session" && header.version == 3).then_some(header)
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
fn
|
|
53
|
-
|
|
54
|
-
expected_session_id: &SessionId,
|
|
55
|
-
spawn_cwd: &Path,
|
|
56
|
-
spawned_at: Option<&str>,
|
|
57
|
-
) -> bool {
|
|
58
|
-
if header.id != expected_session_id.as_str() || !paths_equal(&header.cwd, spawn_cwd) {
|
|
52
|
+
fn header_matches_spawn(header: &PiSessionHeader, spawn_cwd: &Path, spawned_at: Option<&str>) -> bool {
|
|
53
|
+
if !paths_equal(&header.cwd, spawn_cwd) {
|
|
59
54
|
return false;
|
|
60
55
|
}
|
|
61
56
|
let Ok(header_timestamp) = chrono::DateTime::parse_from_rfc3339(&header.timestamp) else {
|
|
@@ -70,6 +65,16 @@ fn header_matches(
|
|
|
70
65
|
header_timestamp >= spawned_at
|
|
71
66
|
}
|
|
72
67
|
|
|
68
|
+
fn header_matches(
|
|
69
|
+
header: &PiSessionHeader,
|
|
70
|
+
expected_session_id: &SessionId,
|
|
71
|
+
spawn_cwd: &Path,
|
|
72
|
+
spawned_at: Option<&str>,
|
|
73
|
+
) -> bool {
|
|
74
|
+
header.id == expected_session_id.as_str()
|
|
75
|
+
&& header_matches_spawn(header, spawn_cwd, spawned_at)
|
|
76
|
+
}
|
|
77
|
+
|
|
73
78
|
fn collect_jsonl(root: &Path, out: &mut Vec<PathBuf>) -> Result<(), ProviderError> {
|
|
74
79
|
let entries = std::fs::read_dir(root)
|
|
75
80
|
.map_err(|error| ProviderError::Io(format!("{}: {error}", root.display())))?;
|
|
@@ -125,15 +130,14 @@ pub(crate) fn validate_exact_backing(
|
|
|
125
130
|
|
|
126
131
|
/// ---
|
|
127
132
|
/// purpose: 仅在 recorded seat root 内递归捕获 Pi session header 候选
|
|
128
|
-
/// returns:
|
|
133
|
+
/// returns: 有预期 id 时按 id/cwd/timestamp 匹配;否则读取 Pi header 自己的 id,并按 cwd/timestamp 匹配
|
|
129
134
|
/// errors: root 内目录枚举失败时返回 ProviderError
|
|
130
135
|
/// ---
|
|
131
136
|
pub(super) fn scan_session_store(
|
|
132
137
|
context: &CaptureSessionContext,
|
|
133
138
|
) -> Result<Vec<CapturedSessionCandidate>, ProviderError> {
|
|
134
|
-
let (Some(root), Some(
|
|
139
|
+
let (Some(root), Some(spawned_at)) = (
|
|
135
140
|
context.provider_projects_root.as_deref(),
|
|
136
|
-
context.expected_session_id.as_ref(),
|
|
137
141
|
context.spawned_at.as_deref(),
|
|
138
142
|
) else {
|
|
139
143
|
return Ok(Vec::new());
|
|
@@ -149,15 +153,24 @@ pub(super) fn scan_session_store(
|
|
|
149
153
|
.into_iter()
|
|
150
154
|
.filter_map(|path| {
|
|
151
155
|
let header = read_header(&path)?;
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
156
|
+
let session_id = if let Some(expected_session_id) = context.expected_session_id.as_ref() {
|
|
157
|
+
if !header_matches(
|
|
158
|
+
&header,
|
|
159
|
+
expected_session_id,
|
|
160
|
+
&context.spawn_cwd,
|
|
161
|
+
Some(spawned_at),
|
|
162
|
+
) {
|
|
163
|
+
return None;
|
|
164
|
+
}
|
|
165
|
+
expected_session_id.clone()
|
|
166
|
+
} else if header_matches_spawn(&header, &context.spawn_cwd, Some(spawned_at)) {
|
|
167
|
+
SessionId::new(header.id)
|
|
168
|
+
} else {
|
|
169
|
+
return None;
|
|
170
|
+
};
|
|
171
|
+
Some(CapturedSessionCandidate {
|
|
159
172
|
captured: CapturedSession {
|
|
160
|
-
session_id: Some(
|
|
173
|
+
session_id: Some(session_id),
|
|
161
174
|
rollout_path: Some(RolloutPath::new(path)),
|
|
162
175
|
captured_via: CaptureVia::FsWatch,
|
|
163
176
|
attribution_confidence: Confidence::High,
|
|
@@ -36,8 +36,8 @@ fn command_helpers_keep_provider_argv_bytes_and_order() {
|
|
|
36
36
|
extension: std::path::Path::new("extension.ts"), model: Some("vendor/model"),
|
|
37
37
|
effort: Some(ProviderEffort::XHigh), system_prompt: raw,
|
|
38
38
|
session_dir: Some(std::path::Path::new("sessions")),
|
|
39
|
-
session: pi::PiSessionSelector::Fresh
|
|
40
|
-
}).expect("pi"), ["pi", "-e", "extension.ts", "--model", "vendor/model", "--thinking", "xhigh", "--append-system-prompt", raw, "--session-dir", "sessions", "--
|
|
39
|
+
session: pi::PiSessionSelector::Fresh, agent_id: "worker",
|
|
40
|
+
}).expect("pi"), ["pi", "-e", "extension.ts", "--model", "vendor/model", "--thinking", "xhigh", "--append-system-prompt", raw, "--session-dir", "sessions", "--name", "worker"]);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
#[test]
|
package/npm/install.mjs
CHANGED
|
@@ -168,7 +168,12 @@ function install(argv) {
|
|
|
168
168
|
if (pathCheck.status === "ready") {
|
|
169
169
|
console.log("Ready in this terminal. Run: team-agent --help");
|
|
170
170
|
} else {
|
|
171
|
-
console.log(
|
|
171
|
+
console.log(pathActivationGuidance({
|
|
172
|
+
binDir,
|
|
173
|
+
teamAgent,
|
|
174
|
+
rc: installTarget.rc,
|
|
175
|
+
shell: path.basename(process.env.SHELL || ""),
|
|
176
|
+
}));
|
|
172
177
|
}
|
|
173
178
|
}
|
|
174
179
|
|
|
@@ -561,7 +566,9 @@ function ensureBinDirOnShellRc(binDir, options = {}) {
|
|
|
561
566
|
|
|
562
567
|
function shellRcTargets(shell, home) {
|
|
563
568
|
if (shell === "zsh") {
|
|
564
|
-
|
|
569
|
+
// Login shells, including ssh and macOS Terminal, read .zprofile and do
|
|
570
|
+
// not read .zshrc unless they are also interactive. Write both.
|
|
571
|
+
return { files: [path.join(home, ".zprofile"), path.join(home, ".zshrc")], style: "posix" };
|
|
565
572
|
}
|
|
566
573
|
if (shell === "bash") {
|
|
567
574
|
return { files: [path.join(home, ".bashrc"), path.join(home, ".bash_profile")], style: "posix" };
|
|
@@ -571,13 +578,43 @@ function shellRcTargets(shell, home) {
|
|
|
571
578
|
}
|
|
572
579
|
if (!shell || shell === "sh") {
|
|
573
580
|
return {
|
|
574
|
-
files:
|
|
581
|
+
files: process.platform === "darwin"
|
|
582
|
+
? [path.join(home, ".zprofile"), path.join(home, ".zshrc")]
|
|
583
|
+
: [path.join(home, ".profile")],
|
|
575
584
|
style: "posix",
|
|
576
585
|
};
|
|
577
586
|
}
|
|
578
587
|
return null;
|
|
579
588
|
}
|
|
580
589
|
|
|
590
|
+
export function pathActivationGuidance(options = {}) {
|
|
591
|
+
const binDir = options.binDir;
|
|
592
|
+
const teamAgent = options.teamAgent;
|
|
593
|
+
const rc = options.rc || { files: [], skipped: [] };
|
|
594
|
+
const refresh = options.shell === "zsh" ? "rehash" : "hash -r";
|
|
595
|
+
const lines = [
|
|
596
|
+
"This shell cannot see team-agent yet. A child installer cannot change the shell that launched it.",
|
|
597
|
+
"Run this in the current shell:",
|
|
598
|
+
` export PATH="${binDir}:$PATH"`,
|
|
599
|
+
` ${refresh}`,
|
|
600
|
+
" team-agent --help",
|
|
601
|
+
"Or run the installed command directly:",
|
|
602
|
+
` ${teamAgent} --help`,
|
|
603
|
+
];
|
|
604
|
+
const written = rc.files || [];
|
|
605
|
+
const skipped = rc.skipped || [];
|
|
606
|
+
if (written.length > 0) {
|
|
607
|
+
lines.push(`New shells read: ${written.join(", ")}`);
|
|
608
|
+
} else if (skipped.length > 0) {
|
|
609
|
+
lines.push(`Shell startup already contains the PATH entry: ${skipped.join(", ")}`);
|
|
610
|
+
} else if (rc.unsupported) {
|
|
611
|
+
lines.push("This shell has no supported startup file. Keep the export above.");
|
|
612
|
+
} else {
|
|
613
|
+
lines.push("Could not update a shell startup file. Keep the export above.");
|
|
614
|
+
}
|
|
615
|
+
return lines.join("\n");
|
|
616
|
+
}
|
|
617
|
+
|
|
581
618
|
function installedBinDir(runtimeRoot, opts) {
|
|
582
619
|
const manifest = readInstallManifest(runtimeRoot);
|
|
583
620
|
if (typeof manifest?.binDir === "string" && manifest.binDir) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@team-agent/installer",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.124",
|
|
4
4
|
"description": "npx installer for Team Agent",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codex",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"team-agent-installer": "npm/install.mjs"
|
|
21
21
|
},
|
|
22
22
|
"optionalDependencies": {
|
|
23
|
-
"@team-agent/cli-darwin-arm64": "0.5.
|
|
24
|
-
"@team-agent/cli-darwin-x64": "0.5.
|
|
25
|
-
"@team-agent/cli-linux-x64": "0.5.
|
|
23
|
+
"@team-agent/cli-darwin-arm64": "0.5.124",
|
|
24
|
+
"@team-agent/cli-darwin-x64": "0.5.124",
|
|
25
|
+
"@team-agent/cli-linux-x64": "0.5.124"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"postinstall": "node npm/bincheck.mjs",
|