@team-agent/installer 0.5.122 → 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 +8 -1
- package/Cargo.toml +1 -1
- package/crates/team-agent/src/cli/diagnose.rs +176 -10
- package/crates/team-agent/src/cli/intent/runtime.rs +103 -43
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +198 -0
- package/crates/team-agent/src/cli/intent/tests.rs +37 -0
- package/crates/team-agent/src/cli/intent.rs +22 -0
- package/crates/team-agent/src/cli/models.rs +54 -10
- package/crates/team-agent/src/contract_runtime/backend.rs +498 -2
- package/crates/team-agent/src/contract_runtime/commands.rs +38 -24
- package/crates/team-agent/src/contract_runtime/discovery.rs +46 -56
- package/crates/team-agent/src/contract_runtime/forward.rs +59 -0
- package/crates/team-agent/src/contract_runtime/framework.rs +23 -17
- 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/launch/quick_start.rs +6 -17
- package/crates/team-agent/src/lifecycle/launch/quick_start_transport.rs +26 -19
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +19 -2
- package/crates/team-agent/src/lifecycle/restart/rebuild.rs +95 -31
- package/crates/team-agent/src/lifecycle/restart.rs +1 -0
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +5 -6
- package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +7 -5
- 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/crates/team-agent/src/provider/wire.rs +2 -1
- package/npm/install.mjs +56 -99
- package/package.json +4 -4
|
@@ -5,7 +5,6 @@ use std::path::Path;
|
|
|
5
5
|
use serde_json::{json, Value};
|
|
6
6
|
use team_agent_contract::contract::types::SeatId;
|
|
7
7
|
use team_agent_contract::orchestration::store::{Outcome, SeatStatus};
|
|
8
|
-
use team_agent_contract::host::process::{sample_process, ProcessState};
|
|
9
8
|
|
|
10
9
|
use crate::cli::CliError;
|
|
11
10
|
use crate::lifecycle::lock::{acquire_agent_lifecycle_lock, LifecycleLockRequest};
|
|
@@ -21,7 +20,7 @@ fn error(error: impl std::fmt::Display) -> CliError {
|
|
|
21
20
|
|
|
22
21
|
/// None delegates only a non-contract selection. Once selected, any identity,
|
|
23
22
|
/// ownership, state or physical error stays on this route and cannot fall back.
|
|
24
|
-
fn with_agent(
|
|
23
|
+
pub(super) fn with_agent(
|
|
25
24
|
workspace: &Path,
|
|
26
25
|
team: Option<&str>,
|
|
27
26
|
agent: &str,
|
|
@@ -51,10 +50,7 @@ fn with_agent(
|
|
|
51
50
|
apply(&latest, &SeatId::new(agent).map_err(error)?).map(Some)
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
fn
|
|
55
|
-
publish_at(&selected.run_workspace, &selected.team_key, id, clear_stop)
|
|
56
|
-
}
|
|
57
|
-
fn publish_at(workspace: &Path, team: &str, id: &SeatId, clear_stop: bool) -> Result<Value, CliError> {
|
|
53
|
+
pub(super) fn publish_at(workspace: &Path, team: &str, id: &SeatId, clear_stop: bool) -> Result<Value, CliError> {
|
|
58
54
|
let projected = framework::project_seat(workspace, team, id.as_str()).map_err(error)?;
|
|
59
55
|
StateRepository::new(workspace).commit(
|
|
60
56
|
StateWriteIntent::StartAgent { team_key: team, agent_id: id.as_str() },
|
|
@@ -70,6 +66,9 @@ fn publish_at(workspace: &Path, team: &str, id: &SeatId, clear_stop: bool) -> Re
|
|
|
70
66
|
}
|
|
71
67
|
},
|
|
72
68
|
).map_err(error)?;
|
|
69
|
+
// Fresh, explicit resume and team restart share this one publication path.
|
|
70
|
+
// Only the exact live receipt may claim a session it actually created.
|
|
71
|
+
backend::bind_workspace_session(workspace, team, id).map_err(error)?;
|
|
73
72
|
Ok(projected)
|
|
74
73
|
}
|
|
75
74
|
|
|
@@ -121,34 +120,32 @@ pub fn start_agent(
|
|
|
121
120
|
return Ok(json!({"ok":false,"agent_id":agent,"status":"paused","reason":"agent_paused"}));
|
|
122
121
|
}
|
|
123
122
|
let unstarted = framework::is_paused_unstarted(row);
|
|
124
|
-
|
|
123
|
+
if unstarted {
|
|
125
124
|
// Full pure team admission precedes native allocation or role writes.
|
|
126
125
|
backend::preflight(&config).map_err(error)?;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
if seat.status != SeatStatus::Stopped && seat.physical.as_ref().is_some_and(|target| sample_process(&target.process) == ProcessState::Alive) {
|
|
135
|
-
return Err(error("native seat is already running; use stop-agent first"));
|
|
136
|
-
}
|
|
137
|
-
Some(backend::prepare_resume(&selected.run_workspace, &selected.team_key, id, Some(role)).map_err(error)?)
|
|
126
|
+
} else if backend::preflight_start_role(&selected.run_workspace, &selected.team_key, role).map_err(error)? {
|
|
127
|
+
backend::preflight(&config).map_err(error)?;
|
|
128
|
+
}
|
|
129
|
+
let before = if unstarted { None } else {
|
|
130
|
+
Backend::open_readonly(&selected.run_workspace, &selected.team_key).map_err(error)?
|
|
131
|
+
.store.creation_receipt(id, None).map_err(error)?
|
|
138
132
|
};
|
|
139
133
|
crate::lifecycle::role_config::commit_contract_role(&source, &previous, &next).map_err(error)?;
|
|
140
|
-
let receipt =
|
|
141
|
-
Some(prepared) => backend::resume(prepared).map_err(error)?,
|
|
142
|
-
None => backend::start(&selected.run_workspace, &selected.team_key, role, &config.members).map_err(error)?.1,
|
|
143
|
-
};
|
|
134
|
+
let receipt = backend::start(&selected.run_workspace, &selected.team_key, role, &config.members).map_err(error)?.1;
|
|
144
135
|
// An uncertain operation never rolls the authoritative native store back
|
|
145
136
|
// to the old generation. The receipt remains available for recovery.
|
|
146
|
-
let projection = checked_projection(&receipt, ||
|
|
137
|
+
let projection = checked_projection(&receipt, || publish_at(&selected.run_workspace, &selected.team_key, id, true))?;
|
|
147
138
|
let coordinator = crate::coordinator::start_coordinator_with_team(
|
|
148
139
|
&crate::coordinator::WorkspacePath::new(selected.run_workspace.clone()), Some(&selected.team_key),
|
|
149
140
|
).map_err(error)?;
|
|
150
141
|
Ok(json!({"ok":coordinator.ok,"agent_id":agent,"status":"running","runtime":"contract",
|
|
151
|
-
"start_mode":
|
|
142
|
+
"start_mode":match before {
|
|
143
|
+
None => "fresh",
|
|
144
|
+
Some(ref original) if original.outcome == Outcome::Compensated => "fresh",
|
|
145
|
+
Some(ref original) if original.id == receipt.id && original.outcome != Outcome::Committed => "receipt_completed",
|
|
146
|
+
Some(ref original) if original.id == receipt.id => "reused",
|
|
147
|
+
Some(_) => "resumed",
|
|
148
|
+
}, "operation":receipt.id,
|
|
152
149
|
"session_id":projection.get("session_id"),"generation":projection.get("generation"),
|
|
153
150
|
"coordinator":crate::lifecycle::coordinator_start_summary_value(
|
|
154
151
|
&crate::lifecycle::CoordinatorStartSummary::from_start_report(&coordinator))}))
|
|
@@ -259,6 +256,23 @@ pub fn stop_agent(
|
|
|
259
256
|
|
|
260
257
|
#[cfg(test)]
|
|
261
258
|
mod tests {
|
|
259
|
+
// Assembly guard, not a substitute for the real shared-session restart/
|
|
260
|
+
// shutdown RED→GREEN journey. All start callers must use this common path.
|
|
261
|
+
#[test]
|
|
262
|
+
fn shared_owner_claim_follows_common_projection_commit_including_team_restart() {
|
|
263
|
+
let source = include_str!("commands.rs");
|
|
264
|
+
let body = source.split_once("pub(super) fn publish_at").unwrap().1
|
|
265
|
+
.split_once("fn check_record").unwrap().0;
|
|
266
|
+
let persisted = body.find("StateRepository::new(workspace).commit").unwrap();
|
|
267
|
+
let claimed = body.find("backend::bind_workspace_session(workspace, team, id)").unwrap();
|
|
268
|
+
let returned = body.find("Ok(projected)").unwrap();
|
|
269
|
+
assert!(persisted < claimed && claimed < returned);
|
|
270
|
+
let restart = source.split_once("pub(crate) fn restart_prepared").unwrap().1
|
|
271
|
+
.split_once("pub fn restart(").unwrap().0;
|
|
272
|
+
assert!(restart.contains("publish_at(workspace, team, &id, false)"));
|
|
273
|
+
assert!(!include_str!("framework.rs").contains("backend::bind_workspace_session"));
|
|
274
|
+
}
|
|
275
|
+
|
|
262
276
|
use super::*;
|
|
263
277
|
use team_agent_contract::contract::{delivery::DeliveryEffect, session::CwdIdentity, types::*};
|
|
264
278
|
use team_agent_contract::orchestration::store::{OperationRecord, Phase, SeatRecord, TransactionKind};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
use std::path::{Path, PathBuf};
|
|
3
3
|
|
|
4
4
|
use team_agent_contract::contract::{hooks::*, plan::CatalogObservation, types::*};
|
|
5
|
-
use team_agent_contract::host::{command::RealCommandRunner, process::resolve_cwd};
|
|
5
|
+
use team_agent_contract::host::{command::{PublicCommand, RealCommandRunner}, process::resolve_cwd};
|
|
6
6
|
use team_agent_contract::kiro::native as kiro;
|
|
7
7
|
use team_agent_contract::providers::cursor::native as cursor;
|
|
8
8
|
use team_agent_contract::providers::grok_build::native as grok;
|
|
@@ -31,12 +31,16 @@ pub enum DiscoveryError {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
pub struct Discovery {
|
|
34
|
+
/// The provider's public command exactly as the user's shell resolves it.
|
|
35
|
+
pub command: PublicCommand,
|
|
34
36
|
pub engine: PathBuf,
|
|
35
37
|
pub native: NativeIdentity,
|
|
36
38
|
pub catalog: CatalogObservation,
|
|
37
39
|
pub runtime: Option<NativeRuntime>,
|
|
38
40
|
}
|
|
39
41
|
|
|
42
|
+
/// Canonical tool path for framework infrastructure such as tmux. Providers
|
|
43
|
+
/// never use this: they launch their public command through [`public_command`].
|
|
40
44
|
pub fn executable(name: &'static str) -> Result<PathBuf, DiscoveryError> {
|
|
41
45
|
let path = std::env::var_os("PATH").ok_or(DiscoveryError::Executable(name))?;
|
|
42
46
|
for directory in std::env::split_paths(&path) {
|
|
@@ -52,6 +56,13 @@ pub fn executable(name: &'static str) -> Result<PathBuf, DiscoveryError> {
|
|
|
52
56
|
Err(DiscoveryError::Executable(name))
|
|
53
57
|
}
|
|
54
58
|
|
|
59
|
+
/// The first `name` on this process's PATH, kept as found so user wrappers and
|
|
60
|
+
/// vendor symlinks stay in the route. No install directory is ever guessed.
|
|
61
|
+
pub fn public_command(name: &'static str) -> Result<PublicCommand, DiscoveryError> {
|
|
62
|
+
let path = std::env::var_os("PATH").ok_or(DiscoveryError::Executable(name))?;
|
|
63
|
+
PublicCommand::resolve(name, &path).map_err(|_| DiscoveryError::Executable(name))
|
|
64
|
+
}
|
|
65
|
+
|
|
55
66
|
pub fn discover(provider: &ProviderId, workspace: &Path) -> Result<Discovery, DiscoveryError> {
|
|
56
67
|
let selected = registry::provider(provider.as_str()).map_err(DiscoveryError::Contract)?;
|
|
57
68
|
let descriptor = selected.descriptor();
|
|
@@ -59,43 +70,23 @@ pub fn discover(provider: &ProviderId, workspace: &Path) -> Result<Discovery, Di
|
|
|
59
70
|
deadline: std::time::Duration::from_secs(30),
|
|
60
71
|
max_output_bytes: 1024 * 1024,
|
|
61
72
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
};
|
|
69
|
-
let (engine, native) = match selected {
|
|
70
|
-
NativeProvider::Kiro => {
|
|
71
|
-
let home = std::env::var_os("HOME")
|
|
72
|
-
.map(PathBuf::from)
|
|
73
|
-
.ok_or(DiscoveryError::Executable("HOME for native installation lookup"))?;
|
|
74
|
-
let engine = kiro::resolve_helper(&launcher, &home)?;
|
|
75
|
-
let native = kiro::probe_engine(&engine, &mut RealCommandRunner::default(), bounds)?;
|
|
76
|
-
(engine, native)
|
|
77
|
-
}
|
|
78
|
-
NativeProvider::Cursor => {
|
|
79
|
-
let engine = cursor::resolve_launcher(&launcher)?;
|
|
80
|
-
let native = cursor::probe_launcher(&engine, &mut RealCommandRunner::default(), bounds)?;
|
|
81
|
-
(engine, native)
|
|
82
|
-
}
|
|
83
|
-
NativeProvider::GrokBuild => {
|
|
84
|
-
let engine = grok::resolve_launcher(&launcher)?;
|
|
85
|
-
let native = grok::probe_launcher(&engine, &mut RealCommandRunner::default(), bounds)?;
|
|
86
|
-
(engine, native)
|
|
87
|
-
}
|
|
73
|
+
// Every metadata probe runs the PATH-selected entry, wrappers included.
|
|
74
|
+
let command = public_command(descriptor.identity.binary)?;
|
|
75
|
+
let native = match selected {
|
|
76
|
+
NativeProvider::Kiro => kiro::probe_launcher(&command, &mut RealCommandRunner::default(), bounds)?,
|
|
77
|
+
NativeProvider::Cursor => cursor::probe_launcher(&command, &mut RealCommandRunner::default(), bounds)?,
|
|
78
|
+
NativeProvider::GrokBuild => grok::probe_launcher(&command, &mut RealCommandRunner::default(), bounds)?,
|
|
88
79
|
};
|
|
89
80
|
let request = CatalogRequest {
|
|
90
81
|
provider: ProviderId::new(descriptor.identity.id).map_err(DiscoveryError::Contract)?,
|
|
91
82
|
native: native.clone(),
|
|
92
|
-
executable:
|
|
83
|
+
executable: command.entry.clone(),
|
|
93
84
|
cwd: resolve_cwd(workspace)?,
|
|
94
85
|
source: descriptor.model.catalog.require("native catalog source").map_err(DiscoveryError::Contract)?.clone(),
|
|
95
86
|
bounds,
|
|
96
87
|
};
|
|
97
|
-
// H1 does not use these pointers or execute an MCP server.
|
|
98
|
-
//
|
|
88
|
+
// H1 does not use these pointers or execute an MCP server. The launcher
|
|
89
|
+
// fingerprint authorizes only metadata reads, never worker launch.
|
|
99
90
|
let adapter = selected.adapter(
|
|
100
91
|
std::env::current_exe()?.canonicalize()?,
|
|
101
92
|
Vec::new(),
|
|
@@ -120,38 +111,31 @@ pub fn discover(provider: &ProviderId, workspace: &Path) -> Result<Discovery, Di
|
|
|
120
111
|
catalog_hook.discover(&request, &mut host)
|
|
121
112
|
}
|
|
122
113
|
}.map_err(DiscoveryError::Catalog)?;
|
|
123
|
-
let result = Discovery { engine, native, catalog, runtime: None };
|
|
114
|
+
let result = Discovery { engine: command.entry.clone(), command, native, catalog, runtime: None };
|
|
124
115
|
validate_catalog(provider, &result).map_err(DiscoveryError::Contract)?;
|
|
125
116
|
Ok(result)
|
|
126
117
|
}
|
|
127
118
|
|
|
128
|
-
/// Runtime discovery is separate from public catalog metadata.
|
|
129
|
-
/// bridges
|
|
119
|
+
/// Runtime discovery is separate from public catalog metadata. Each provider
|
|
120
|
+
/// bridges its catalog to the native image its public command route execs into.
|
|
130
121
|
pub(super) fn discover_runtime(provider: &ProviderId, workspace: &Path) -> Result<Discovery, DiscoveryError> {
|
|
131
122
|
let mut discovery = discover(provider, workspace)?;
|
|
132
123
|
let selected = registry::provider(provider.as_str()).map_err(DiscoveryError::Contract)?;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
discovery.engine = runtime.engine.clone();
|
|
149
|
-
discovery.native = runtime.native.clone();
|
|
150
|
-
discovery.runtime = Some(NativeRuntime::GrokBuild(runtime));
|
|
151
|
-
}
|
|
152
|
-
NativeProvider::Kiro => unreachable!(),
|
|
153
|
-
}
|
|
154
|
-
}
|
|
124
|
+
let bounds = ReadBounds { deadline: std::time::Duration::from_secs(30), max_output_bytes: 1024 * 1024 };
|
|
125
|
+
let home = || std::env::var_os("HOME").map(PathBuf::from)
|
|
126
|
+
.ok_or(DiscoveryError::Executable("HOME for native subscription"));
|
|
127
|
+
let runtime = match selected {
|
|
128
|
+
NativeProvider::Kiro => NativeRuntime::Kiro(
|
|
129
|
+
kiro::probe_runtime(&discovery.command, &mut RealCommandRunner::default(), bounds)?),
|
|
130
|
+
NativeProvider::Cursor => NativeRuntime::Cursor(
|
|
131
|
+
cursor::probe_runtime(&discovery.command, &home()?, &mut RealCommandRunner::default(), bounds)?),
|
|
132
|
+
NativeProvider::GrokBuild => NativeRuntime::GrokBuild(
|
|
133
|
+
grok::probe_runtime(&discovery.command, &home()?, &mut RealCommandRunner::default(), bounds)?),
|
|
134
|
+
};
|
|
135
|
+
discovery.catalog = runtime.bind_catalog(&discovery.catalog).map_err(DiscoveryError::Contract)?;
|
|
136
|
+
discovery.engine = runtime.engine().clone();
|
|
137
|
+
discovery.native = runtime.native().clone();
|
|
138
|
+
discovery.runtime = Some(runtime);
|
|
155
139
|
Ok(discovery)
|
|
156
140
|
}
|
|
157
141
|
|
|
@@ -245,6 +229,10 @@ mod tests {
|
|
|
245
229
|
use crate::cli::{CmdOutput, ExitCode, ModelsArgs};
|
|
246
230
|
use team_agent_contract::contract::plan::ModelRecord;
|
|
247
231
|
|
|
232
|
+
fn controlled_command(name: &str) -> PublicCommand {
|
|
233
|
+
PublicCommand { name: name.into(), search_path: "/controlled".into(), entry: format!("/controlled/{name}").into() }
|
|
234
|
+
}
|
|
235
|
+
|
|
248
236
|
#[test]
|
|
249
237
|
fn native_catalog_projection_preserves_ids_without_claiming_auth_or_effort() {
|
|
250
238
|
let native = NativeIdentity {
|
|
@@ -255,8 +243,9 @@ mod tests {
|
|
|
255
243
|
executable_sha256: Digest([1; 32]),
|
|
256
244
|
};
|
|
257
245
|
let discovery = Discovery {
|
|
246
|
+
command: controlled_command("kiro-cli"),
|
|
258
247
|
runtime: None,
|
|
259
|
-
engine: "/controlled/kiro-cli
|
|
248
|
+
engine: "/controlled/kiro-cli".into(),
|
|
260
249
|
native: native.clone(),
|
|
261
250
|
catalog: CatalogObservation {
|
|
262
251
|
provider: ProviderId::new("kiro").unwrap(),
|
|
@@ -319,6 +308,7 @@ mod tests {
|
|
|
319
308
|
executable_sha256: Digest([2; 32]),
|
|
320
309
|
};
|
|
321
310
|
Discovery {
|
|
311
|
+
command: controlled_command("cursor-agent"),
|
|
322
312
|
runtime: None,
|
|
323
313
|
engine: "/controlled/cursor-agent".into(),
|
|
324
314
|
native: native.clone(),
|
|
@@ -208,10 +208,69 @@ pub fn drain(
|
|
|
208
208
|
Ok(completed)
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
/// Explicit operator egress only: reuse committed native receipts, never run a
|
|
212
|
+
/// coordinator tick, provider admission, input delivery, or candidate migration.
|
|
213
|
+
/// The original runtime binding remains authoritative even when this helper was
|
|
214
|
+
/// built from a newer revision. Pending forwards retain their exact source IDs.
|
|
215
|
+
pub fn drain_scoped_pending_egress(
|
|
216
|
+
workspace: &std::path::Path,
|
|
217
|
+
team: &str,
|
|
218
|
+
expected_scope: &str,
|
|
219
|
+
apply: bool,
|
|
220
|
+
) -> Result<Value, String> {
|
|
221
|
+
if !workspace.is_absolute() || team.is_empty() || team.trim() != team {
|
|
222
|
+
return Err("egress requires an absolute workspace and exact explicit team".into());
|
|
223
|
+
}
|
|
224
|
+
ScopeId::new(expected_scope).map_err(|error| error.to_string())?;
|
|
225
|
+
let selected = crate::state::selector::resolve_active_team_readonly(
|
|
226
|
+
workspace, Some(team), crate::state::selector::SelectorMode::RuntimeOnly,
|
|
227
|
+
).map_err(|error| error.to_string())?;
|
|
228
|
+
crate::lifecycle::launch::ensure_owner_allowed_for_state(&selected.state, None)
|
|
229
|
+
.map_err(|error| error.to_string())?;
|
|
230
|
+
let original = super::backend::Backend::open_readonly(&selected.run_workspace, &selected.team_key)
|
|
231
|
+
.map_err(|error| error.to_string())?;
|
|
232
|
+
if original.binding.scope.as_str() != expected_scope || original.binding.team != team {
|
|
233
|
+
return Err("egress scope/binding mismatch".into());
|
|
234
|
+
}
|
|
235
|
+
let binding = serde_json::to_value(&original.binding).map_err(|error| error.to_string())?;
|
|
236
|
+
let before: Vec<_> = original.store.pending_forwards(32).map_err(|error| error.to_string())?
|
|
237
|
+
.into_iter().map(|intent| intent.id).collect();
|
|
238
|
+
drop(original);
|
|
239
|
+
let processed = if apply {
|
|
240
|
+
let mut backend = super::backend::Backend::open(&selected.run_workspace, &selected.team_key)
|
|
241
|
+
.map_err(|error| error.to_string())?;
|
|
242
|
+
if serde_json::to_value(&backend.binding).map_err(|error| error.to_string())? != binding {
|
|
243
|
+
return Err("egress binding changed before claim".into());
|
|
244
|
+
}
|
|
245
|
+
drain(&backend.binding.framework(), &mut backend.store, 32).map_err(|error| error.to_string())?
|
|
246
|
+
} else { 0 };
|
|
247
|
+
let after = super::backend::Backend::open_readonly(&selected.run_workspace, &selected.team_key)
|
|
248
|
+
.map_err(|error| error.to_string())?;
|
|
249
|
+
if serde_json::to_value(&after.binding).map_err(|error| error.to_string())? != binding {
|
|
250
|
+
return Err("egress binding changed during forwarding".into());
|
|
251
|
+
}
|
|
252
|
+
let pending: Vec<_> = after.store.pending_forwards(32).map_err(|error| error.to_string())?
|
|
253
|
+
.into_iter().map(|intent| intent.id).collect();
|
|
254
|
+
Ok(json!({"scope":expected_scope,"team":team,"apply":apply,"processed":processed,
|
|
255
|
+
"pending_before":before,"pending_after":pending,"binding_unchanged":true,
|
|
256
|
+
"native_input":"not_invoked","coordinator_lifecycle":"not_invoked",
|
|
257
|
+
"leader_consumption":"requires actual natural receipt"}))
|
|
258
|
+
}
|
|
259
|
+
|
|
211
260
|
#[cfg(test)]
|
|
212
261
|
mod tests {
|
|
213
262
|
use super::*;
|
|
214
263
|
#[test]
|
|
264
|
+
fn egress_operator_refuses_implicit_workspace_team_and_invalid_scope_before_io() {
|
|
265
|
+
for (workspace, team, scope) in [
|
|
266
|
+
("relative", "team", "scope"), ("/", "", "scope"),
|
|
267
|
+
("/", " team", "scope"), ("/", "team", ""), ("/", "team", "bad/scope"),
|
|
268
|
+
] {
|
|
269
|
+
assert!(drain_scoped_pending_egress(std::path::Path::new(workspace), team, scope, false).is_err());
|
|
270
|
+
assert!(drain_scoped_pending_egress(std::path::Path::new(workspace), team, scope, true).is_err());
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
#[test]
|
|
215
274
|
fn compact_native_result_becomes_the_existing_framework_business_schema() {
|
|
216
275
|
let compact = json!({"schema_version":1,"agent_id":"worker","task_id":"msg-bound","status":"completed","summary":"5535"});
|
|
217
276
|
let result = framework_result("result-fixed", "worker", &compact).unwrap();
|
|
@@ -127,23 +127,29 @@ pub fn start_role(
|
|
|
127
127
|
team: &str,
|
|
128
128
|
id: &str,
|
|
129
129
|
) -> Result<(), crate::lifecycle::LifecycleError> {
|
|
130
|
-
let
|
|
131
|
-
|
|
132
|
-
.
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
.
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
.
|
|
139
|
-
|
|
140
|
-
backend::start(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
"native startup {:?}: {}",
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
130
|
+
let result = super::commands::with_agent(workspace, Some(team), id, "start-role", |selected, seat| {
|
|
131
|
+
let error = |error: String| crate::cli::CliError::Runtime(error);
|
|
132
|
+
if directory.canonicalize()? != selected.team_dir.canonicalize()? {
|
|
133
|
+
return Err(error("native role source changed while acquiring lifecycle ownership".into()));
|
|
134
|
+
}
|
|
135
|
+
let config = team_config(&selected.run_workspace, &selected.team_dir, &selected.team_key)
|
|
136
|
+
.map_err(|e| error(e.to_string()))?
|
|
137
|
+
.ok_or_else(|| error("contract role no longer configured".into()))?;
|
|
138
|
+
let role = config.roles.iter().find(|role| &role.id == seat)
|
|
139
|
+
.ok_or_else(|| error("contract role not found".into()))?;
|
|
140
|
+
let (_, record) = backend::start(&selected.run_workspace, &selected.team_key, role, &config.members)
|
|
141
|
+
.map_err(|e| error(e.to_string()))?;
|
|
142
|
+
if record.outcome != Outcome::Committed {
|
|
143
|
+
return Err(error(format!("native startup seat={id} operation={:?} phase={:?} outcome={:?}: {}",
|
|
144
|
+
record.id, record.phase, record.outcome, record.failure.unwrap_or_default())));
|
|
145
|
+
}
|
|
146
|
+
// Preserve each committed seat before a later discovery/spawn can fail.
|
|
147
|
+
// A whole-batch error must never hide this generation's physical effects.
|
|
148
|
+
let projected = super::commands::publish_at(&selected.run_workspace, &selected.team_key, seat, true)?;
|
|
149
|
+
Ok(projected)
|
|
150
|
+
}).map_err(|e| crate::lifecycle::LifecycleError::Provider(e.to_string()))?;
|
|
151
|
+
if result.is_none() {
|
|
152
|
+
return Err(crate::lifecycle::LifecycleError::Provider("native startup scope/seat is not addressable; no legacy fallback".into()));
|
|
147
153
|
}
|
|
148
154
|
Ok(())
|
|
149
155
|
}
|
|
@@ -6,8 +6,8 @@ use team_agent_contract::contract::{
|
|
|
6
6
|
descriptor::{PromptCarrier, ProviderDescriptor, ToolNaming},
|
|
7
7
|
types::InstanceIdentity,
|
|
8
8
|
hooks::{PlanHook, ProviderHooks},
|
|
9
|
-
plan::{LaunchPlan, ResolvedLaunch},
|
|
10
|
-
types::{ContractError, Support},
|
|
9
|
+
plan::{CatalogObservation, LaunchEntrypoint, LaunchPlan, ResolvedLaunch},
|
|
10
|
+
types::{ContractError, NativeIdentity, Support},
|
|
11
11
|
};
|
|
12
12
|
use team_agent_contract::kiro::{self, KiroAdapter, KIRO_DESCRIPTOR};
|
|
13
13
|
use team_agent_contract::providers::cursor::{self, CursorAdapter, CURSOR_DESCRIPTOR};
|
|
@@ -19,12 +19,49 @@ use team_agent_contract::runtime::{
|
|
|
19
19
|
|
|
20
20
|
const DESCRIPTORS: &[&ProviderDescriptor] = &[&KIRO_DESCRIPTOR, &CURSOR_DESCRIPTOR, &GROK_BUILD_DESCRIPTOR];
|
|
21
21
|
|
|
22
|
+
/// One provider's public command route: the PATH-selected entry the pane execs
|
|
23
|
+
/// by bare name and the native image that route must exec into.
|
|
22
24
|
#[derive(Clone)]
|
|
23
25
|
pub enum NativeRuntime {
|
|
26
|
+
Kiro(kiro::native::RuntimeInstallation),
|
|
24
27
|
Cursor(cursor::native::RuntimeInstallation),
|
|
25
28
|
GrokBuild(grok_build::native::RuntimeInstallation),
|
|
26
29
|
}
|
|
27
30
|
|
|
31
|
+
impl NativeRuntime {
|
|
32
|
+
pub fn launcher(&self) -> LaunchEntrypoint {
|
|
33
|
+
match self {
|
|
34
|
+
Self::Kiro(runtime) => runtime.launcher(),
|
|
35
|
+
Self::Cursor(runtime) => runtime.launcher(),
|
|
36
|
+
Self::GrokBuild(runtime) => runtime.launcher(),
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
pub fn engine(&self) -> &PathBuf {
|
|
41
|
+
match self {
|
|
42
|
+
Self::Kiro(runtime) => &runtime.engine,
|
|
43
|
+
Self::Cursor(runtime) => &runtime.engine,
|
|
44
|
+
Self::GrokBuild(runtime) => &runtime.engine,
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
pub fn native(&self) -> &NativeIdentity {
|
|
49
|
+
match self {
|
|
50
|
+
Self::Kiro(runtime) => &runtime.native,
|
|
51
|
+
Self::Cursor(runtime) => &runtime.native,
|
|
52
|
+
Self::GrokBuild(runtime) => &runtime.native,
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
pub fn bind_catalog(&self, catalog: &CatalogObservation) -> Result<CatalogObservation, ContractError> {
|
|
57
|
+
match self {
|
|
58
|
+
Self::Kiro(runtime) => runtime.bind_catalog(catalog),
|
|
59
|
+
Self::Cursor(runtime) => runtime.bind_catalog(catalog),
|
|
60
|
+
Self::GrokBuild(runtime) => runtime.bind_catalog(catalog),
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
28
65
|
/// Leaf selection stays here; the framework, lifecycle and outbox remain shared.
|
|
29
66
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
30
67
|
pub(super) enum NativeProvider {
|
|
@@ -143,7 +180,8 @@ impl NativeAdapter {
|
|
|
143
180
|
runtime: Option<NativeRuntime>,
|
|
144
181
|
) -> Result<Self, ContractError> {
|
|
145
182
|
match self {
|
|
146
|
-
|
|
183
|
+
// Kiro plans from the framework-resolved launch paths alone.
|
|
184
|
+
Self::Kiro(adapter) if matches!(runtime, None | Some(NativeRuntime::Kiro(_))) => Ok(Self::Kiro(adapter)),
|
|
147
185
|
Self::Kiro(_) => Err(ContractError::Mismatch("native runtime provider")),
|
|
148
186
|
Self::Cursor(adapter) => {
|
|
149
187
|
let adapter = adapter.with_project(project)?;
|