L'appairage ne survivait pas au redémarrage et son code, permanent, était imprimé sur la sortie standard. Un appareil appairé devient une entité persistante, nommée et révocable, derrière un code désormais éphémère. - B1 : port DeviceSessionStore et adapter FsDeviceSessionStore, entités de domaine (PairedDevice, DeviceId, SessionTokenHash, DeviceName). Les tokens sont hachés en SHA-256 et comparés en temps constant (subtle) : le store ne peut pas rejouer une session qu'il a servie. Cookie Max-Age 400 j à renouvellement glissant, lastSeenAtMs throttlé. - B2 : code éphémère en mémoire, TTL 10 min et usage unique, toute génération invalidant la précédente. POST /api/pairing-code authentifiée, flag --new-code. Le code est retiré du boot et l'eprintln! qui l'imprimait est supprimé. - B3 : endpoints devices (list/rename/revoke/revoke-all/logout), event DeviceRevoked et ActiveConnectionRegistry par device_id, fermant sans délai les WebSockets d'un appareil révoqué. - B4 : port PairAttemptLimiter et adapter mémoire, rate-limit par origine et global sur horloge injectée, donc testable sans attente réelle. La normalisation du code passe côté serveur : elle absorbe la dette #76, que la seule normalisation frontend de #75 ne faisait que masquer. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
187 lines
10 KiB
Rust
187 lines
10 KiB
Rust
//! # IdeA — Application layer
|
|
//!
|
|
//! Orchestrates **use cases** by talking **only to the domain ports** (traits),
|
|
//! never to concrete adapters (ARCHITECTURE §1.1, §6). Every use case is a
|
|
//! struct carrying its ports as `Arc<dyn Port>` and exposing
|
|
//! `execute(input) -> Result<output, AppError>`.
|
|
//!
|
|
//! This crate depends on `domain` only. The composition root (`app-tauri`) is
|
|
//! the single place that constructs concrete adapters and injects them here.
|
|
|
|
#![forbid(unsafe_code)]
|
|
#![warn(missing_docs)]
|
|
|
|
pub mod agent;
|
|
pub mod background;
|
|
pub mod conversation;
|
|
pub mod device;
|
|
pub mod diag;
|
|
pub mod embedder;
|
|
pub mod error;
|
|
pub mod git;
|
|
pub mod health;
|
|
pub mod issues;
|
|
pub mod layout;
|
|
pub mod memory;
|
|
pub mod model_server;
|
|
pub mod orchestrator;
|
|
pub mod permission;
|
|
pub mod project;
|
|
pub mod remote;
|
|
pub mod skill;
|
|
pub mod sprints;
|
|
pub mod template;
|
|
pub mod terminal;
|
|
pub mod ticket_assistant;
|
|
pub mod window;
|
|
pub mod workstate;
|
|
|
|
pub use agent::{
|
|
drain_reply_stream_with_readiness, drain_with_readiness,
|
|
drain_with_readiness_and_announcements, drain_with_readiness_outcome, reference_profile_id,
|
|
reference_profiles, selectable_reference_profiles, send_blocking, AgentResumer,
|
|
AnnouncementPublisher, ChangeAgentProfile, ChangeAgentProfileInput, ChangeAgentProfileOutput,
|
|
CloneOpenCodeProfileFromSeed, CloneOpenCodeProfileFromSeedInput,
|
|
CloneOpenCodeProfileFromSeedOutput, ConfigureProfiles, ConfigureProfilesInput,
|
|
ConfigureProfilesOutput, CreateAgentFromScratch, CreateAgentInput, CreateAgentOutput,
|
|
DeleteAgent, DeleteAgentInput, DeleteProfile, DeleteProfileInput, DetectProfiles,
|
|
DetectProfilesInput, DetectProfilesOutput, FirstRunState, FirstRunStateOutput, HandoffProvider,
|
|
InjectedLiveRow, InspectConversation, InspectConversationInput, InspectConversationOutput,
|
|
LaunchAgent, LaunchAgentInput, LaunchAgentOutput, ListAgents, ListAgentsInput,
|
|
ListAgentsOutput, ListProfiles, ListProfilesOutput, ListResumableAgents,
|
|
ListResumableAgentsInput, ListResumableAgentsOutput, LiveStateLeanProvider, McpRuntime,
|
|
PermissionProjectorRegistry, ProfileAvailability, ProviderSessionProvider, ReadAgentContext,
|
|
ReadAgentContextInput, ReadAgentContextOutput, ReferenceProfiles, ReferenceProfilesOutput,
|
|
ResumableAgent, SaveProfile, SaveProfileInput, SaveProfileOutput, SessionLimitService,
|
|
StructuredRoutingMode, StructuredSessionDescriptor, TurnOutcome, UpdateAgentContext,
|
|
UpdateAgentContextInput, AGENT_MEMORY_RECALL_BUDGET, CODEX_SUBMIT_DELAY_MS,
|
|
LIVE_STATE_INJECT_MAX, RESUME_PROMPT,
|
|
};
|
|
pub use background::{
|
|
BackgroundCommandArchive, CancelBackgroundTask, CancelBackgroundTaskOutput,
|
|
RetryBackgroundTask, SpawnBackgroundCommand, SpawnBackgroundCommandInput,
|
|
SpawnBackgroundCommandOutput,
|
|
};
|
|
pub use conversation::{
|
|
ConversationArchiveProvider, ReadConversationPage, ReadConversationPageInput, RecordTurn,
|
|
RotateConversationLog, RotateConversationLogInput, TurnPage, TurnSource, TurnView,
|
|
};
|
|
pub use device::{
|
|
normalize_pairing_code, pairing_codes_equal, AuthenticateSession, AuthenticateSessionInput,
|
|
DeviceView, ListDevices, ListDevicesInput, ListDevicesOutput, PairAttemptDecision,
|
|
PairAttemptLimiter, PairDevice, PairDeviceInput, PairDeviceOutput, RateLimitKey, RenameDevice,
|
|
RenameDeviceInput, RevokeAllDevices, RevokeDevice, RevokeDeviceInput, TouchDevice,
|
|
TouchDeviceInput, TouchDeviceOutput,
|
|
};
|
|
pub use embedder::{
|
|
CheckEmbedderSuggestion, CheckEmbedderSuggestionInput, CheckEmbedderSuggestionOutput,
|
|
DeleteEmbedderProfile, DeleteEmbedderProfileInput, DescribeEmbedderEngines, DismissChoice,
|
|
DismissEmbedderSuggestion, DismissEmbedderSuggestionInput, EmbedderEnginesView,
|
|
ListEmbedderProfiles, ListEmbedderProfilesOutput, OnnxModelView, SaveEmbedderProfile,
|
|
SaveEmbedderProfileInput, SaveEmbedderProfileOutput, SuggestedThisSession,
|
|
};
|
|
pub use error::AppError;
|
|
pub use git::{
|
|
GitBranches, GitBranchesInput, GitBranchesOutput, GitCheckout, GitCheckoutInput, GitCommit,
|
|
GitCommitInput, GitCommitOutput, GitGraph, GitGraphInput, GitGraphOutput, GitInit,
|
|
GitInitInput, GitLog, GitLogInput, GitLogOutput, GitStage, GitStagePathInput, GitStatus,
|
|
GitStatusInput, GitStatusOutput, GitUnstage,
|
|
};
|
|
pub use health::{HealthInput, HealthReport, HealthUseCase};
|
|
pub use issues::{
|
|
AssignIssueAgent, AssignIssueAgentInput, AssignIssueAgentOutput, CreateIssue, CreateIssueInput,
|
|
CreateIssueOutput, DeleteIssue, DeleteIssueInput, DeleteIssueOutput, LinkIssues,
|
|
LinkIssuesInput, LinkIssuesOutput, ListIssues, ListIssuesInput, ListIssuesOutput, ReadIssue,
|
|
ReadIssueCarnet, ReadIssueCarnetInput, ReadIssueCarnetOutput, ReadIssueInput, ReadIssueOutput,
|
|
UnlinkIssues, UnlinkIssuesInput, UpdateIssue, UpdateIssueCarnet, UpdateIssueCarnetInput,
|
|
UpdateIssueCarnetOutput, UpdateIssueInput, UpdateIssueOutput,
|
|
};
|
|
pub use layout::{
|
|
CreateLayout, CreateLayoutInput, CreateLayoutOutput, DeleteLayout, DeleteLayoutInput,
|
|
DeleteLayoutOutput, LayoutInfo, LayoutKind, LayoutOperation, LayoutsDoc, ListLayouts,
|
|
ListLayoutsInput, ListLayoutsOutput, LoadLayout, LoadLayoutInput, LoadLayoutOutput,
|
|
MutateLayout, MutateLayoutInput, MutateLayoutOutput, NamedLayout, ReconcileLayouts,
|
|
ReconcileLayoutsInput, ReconcileLayoutsOutput, RenameLayout, RenameLayoutInput,
|
|
SetActiveLayout, SetActiveLayoutInput, SetActiveLayoutOutput, SnapshotRunningAgents,
|
|
SnapshotRunningAgentsInput, SnapshotRunningAgentsOutput, LAYOUTS_FILE,
|
|
};
|
|
pub use memory::{
|
|
CreateMemory, CreateMemoryInput, CreateMemoryOutput, DeleteMemory, DeleteMemoryInput,
|
|
GetMemory, GetMemoryInput, GetMemoryOutput, HarvestMemoryFromTurn, ListMemories,
|
|
ListMemoriesInput, ListMemoriesOutput, MemoryHarvestOutcome, ReadMemoryIndex,
|
|
ReadMemoryIndexInput, ReadMemoryIndexOutput, RecallMemory, RecallMemoryInput,
|
|
RecallMemoryOutput, ResolveMemoryLinks, ResolveMemoryLinksInput, ResolveMemoryLinksOutput,
|
|
UpdateMemory, UpdateMemoryInput, UpdateMemoryOutput,
|
|
};
|
|
pub use model_server::{
|
|
model_server_error_code, DeleteModelServer, DeleteModelServerInput, EnsureLocalModelServer,
|
|
EnsureLocalModelServerInput, EnsureLocalModelServerOutput, ListModelServers,
|
|
ListModelServersOutput, ReadinessPolicy as ModelServerReadinessPolicy, SaveModelServer,
|
|
SaveModelServerInput, SaveModelServerOutput,
|
|
};
|
|
pub use orchestrator::{
|
|
resolve_rendezvous_ceiling, resolve_rendezvous_window, run_inactivity_watchdog,
|
|
AgentWakeService, AskLivenessProbe, ContextGuardUseCases, LiveStateProvider,
|
|
LiveStateReadProvider, McpRuntimeProvider, OrchestratorOutcome, OrchestratorService,
|
|
ProposeContext, ReadContext, ReadMemory, RecordTurnProvider, WakeSessionProvider,
|
|
WatchdogOutcome, WriteMemory, DEFAULT_RENDEZVOUS_CEILING, DEFAULT_RENDEZVOUS_WINDOW,
|
|
};
|
|
pub use permission::{
|
|
GetProjectPermissions, GetProjectPermissionsInput, GetProjectPermissionsOutput,
|
|
ResolveAgentPermissions, ResolveAgentPermissionsInput, ResolveAgentPermissionsOutput,
|
|
UpdateAgentPermissions, UpdateAgentPermissionsInput, UpdateProjectPermissions,
|
|
UpdateProjectPermissionsInput,
|
|
};
|
|
pub use project::{
|
|
CloseProject, CloseProjectInput, CloseProjectOutput, CloseTab, CloseTabInput, CreateProject,
|
|
CreateProjectInput, CreateProjectOutput, ListProjects, ListProjectsOutput, OpenProject,
|
|
OpenProjectInput, OpenProjectOutput, ProjectMeta, ReadProjectContext, ReadProjectContextInput,
|
|
ReadProjectContextOutput, UpdateProjectContext, UpdateProjectContextInput,
|
|
PROJECT_CONTEXT_FILE,
|
|
};
|
|
pub use remote::{ConnectRemote, ConnectRemoteInput, ConnectRemoteOutput};
|
|
pub use skill::{
|
|
AssignSkillToAgent, AssignSkillToAgentInput, CreateSkill, CreateSkillInput, CreateSkillOutput,
|
|
DeleteSkill, DeleteSkillInput, ListSkills, ListSkillsInput, ListSkillsOutput, ReadSkill,
|
|
ReadSkillInput, UnassignSkillFromAgent, UnassignSkillFromAgentInput, UpdateSkill,
|
|
UpdateSkillInput, UpdateSkillOutput,
|
|
};
|
|
pub use sprints::{
|
|
normalized_reorder, AssignTicketToSprint, AssignTicketToSprintInput,
|
|
AssignTicketToSprintOutput, CreateSprint, CreateSprintInput, CreateSprintOutput, DeleteSprint,
|
|
DeleteSprintInput, ListSprints, ListSprintsInput, ListSprintsOutput, RenameSprint,
|
|
RenameSprintInput, ReorderSprints, ReorderSprintsInput, ReorderSprintsOutput, SprintListEntry,
|
|
SprintOutput, UnassignTicketFromSprint, UnassignTicketFromSprintInput,
|
|
};
|
|
pub use template::{
|
|
AgentDrift, CreateAgentFromTemplate, CreateAgentFromTemplateInput,
|
|
CreateAgentFromTemplateOutput, CreateTemplate, CreateTemplateInput, CreateTemplateOutput,
|
|
DeleteTemplate, DeleteTemplateInput, DetectAgentDrift, DetectAgentDriftInput,
|
|
DetectAgentDriftOutput, ListTemplates, ListTemplatesOutput, SyncAgentWithTemplate,
|
|
SyncAgentWithTemplateInput, SyncAgentWithTemplateOutput, UpdateTemplate, UpdateTemplateInput,
|
|
UpdateTemplateOutput,
|
|
};
|
|
pub use terminal::{
|
|
CloseTerminal, CloseTerminalInput, CloseTerminalOutput, LiveAgentRegistry, LiveSessionKind,
|
|
LiveSessionSnapshot, LiveSessions, OpenTerminal, OpenTerminalInput, OpenTerminalOutput,
|
|
ResizeTerminal, ResizeTerminalInput, StructuredSessions, TerminalSessions, WriteToTerminal,
|
|
WriteToTerminalInput,
|
|
};
|
|
pub use ticket_assistant::{
|
|
CloseTicketAssistant, CloseTicketAssistantInput, OpenTicketAssistant, OpenTicketAssistantInput,
|
|
OpenTicketAssistantOutput,
|
|
};
|
|
pub use window::{
|
|
MoveTabToNewWindow, MoveTabToNewWindowInput, MoveTabToNewWindowOutput, RestoreOpenWindows,
|
|
RestoreOpenWindowsOutput, SnapshotOpenWindows, SnapshotOpenWindowsInput,
|
|
};
|
|
pub use workstate::{
|
|
AgentBackgroundTaskState, AgentTicketState, AgentWorkState, AttachLiveAgent,
|
|
AttachLiveAgentInput, AttachLiveAgentOutput, BackgroundTaskKindLabel, ConversationLogProvider,
|
|
ConversationPreviewStatus, ConversationTurnWorkPreview, ConversationWorkSummary,
|
|
GetLiveStateLean, GetProjectWorkState, GetProjectWorkStateInput, LeanLiveEntry, LeanLiveState,
|
|
LiveWorkSession, ProjectWorkState, ReconcileLiveState, ReconcileLiveStateInput, StopLiveAgent,
|
|
StopLiveAgentInput, StopLiveAgentOutput, TicketWorkSource, TicketWorkStatus, UpdateLiveState,
|
|
UpdateLiveStateInput, LIVE_STATE_MAX_ENTRIES, LIVE_STATE_TTL_MS,
|
|
};
|