Skip to main content

terminal_commander_ipc/
lib.rs

1// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
2// Copyright 2026 The Terminal Commander Authors
3
4//! Terminal Commander shared IPC crate (TC37).
5//!
6//! Houses the wire protocol, the length-prefixed JSON framing, and the
7//! cross-platform `DaemonClient` transport that every IPC client (MCP
8//! adapter, admin CLI) and the daemon server share. Splitting these out
9//! of the daemon keeps the dependency arrow pointing at a small,
10//! protocol-only crate: `core <- ipc <- {daemon, mcp, cli}`.
11//!
12//! Platform support for the client transport:
13//! - Linux / WSL2 / macOS / BSD: live via tokio `UnixStream` (see
14//!   [`client`]).
15//! - Windows native: live via tokio named pipe `ClientOptions` (see
16//!   [`pipe_client`]).
17//!
18//! The server side (dispatch, peer identity, `IpcServer` / `PipeServer`)
19//! stays in the daemon crate; this crate is wire types + framing +
20//! client transport only.
21//!
22//! Source-status: live (TC37).
23
24pub mod protocol;
25
26pub mod framing;
27
28#[cfg(unix)]
29pub mod client;
30
31#[cfg(windows)]
32pub mod pipe_client;
33
34pub use protocol::{
35    AccessRoute, AuditRowWire, AuditSinceParams, AuditSinceResponse, BucketEventsSinceParams,
36    BucketEventsSinceResponse, BucketSummaryParams, BucketSummaryResponse, BucketWaitParams,
37    BucketWaitResponse, BulkDeactivateOutcome, BulkOutcomeKind, CommandOutputTailParams,
38    CommandOutputTailResponse, CommandReceipt, CommandStartParams, CommandStartResponse,
39    CommandStatusParams, CommandStatusResponse, CommandStopParams, CommandStopResponse,
40    ContextUnavailableReason, DEFAULT_AUDIT_READ_LIMIT, DEFAULT_BUCKET_READ_LIMIT,
41    DEFAULT_BUCKET_WAIT_MS, DEFAULT_CONTEXT_AFTER, DEFAULT_CONTEXT_BEFORE, DEFAULT_FILE_READ_BYTES,
42    DEFAULT_FILE_READ_LINES, DEFAULT_FILE_SEARCH_MATCHES, DEFAULT_FILE_SEARCH_SNIPPET_BYTES,
43    DEFAULT_PULL_TIMEOUT_MS, DEFAULT_REGISTRY_SEARCH_LIMIT, DiscoverResponse, EventContextParams,
44    EventContextResponse, FileLine, FileReadWindowParams, FileReadWindowResponse, FileSearchMatch,
45    FileSearchParams, FileSearchResponse, FileWatchListEntry, FileWatchListResponse,
46    FileWatchStartParams, FileWatchStartResponse, FileWatchStopParams, FileWatchStopResponse,
47    FileWriteParams, FileWriteResponse, HostEnvironment, IpcContextFrame, IpcError, IpcErrorCode,
48    IpcRequest, IpcResponse, IpcResult, ListLimitParams, Liveness, MAX_AUDIT_READ_LIMIT,
49    MAX_BUCKET_READ_LIMIT, MAX_BUCKET_WAIT_MS, MAX_BUCKETS_PER_SUBSCRIPTION, MAX_COMMAND_ENV_ITEMS,
50    MAX_COMMAND_GRACE_MS, MAX_COMMAND_INLINE_RULES, MAX_CONTEXT_BYTES, MAX_CONTEXT_FRAMES,
51    MAX_FILE_READ_BYTES, MAX_FILE_READ_LINES, MAX_FILE_SEARCH_MATCHES, MAX_FILE_SEARCH_SCAN_BYTES,
52    MAX_FILE_SEARCH_SNIPPET_BYTES, MAX_FILE_WRITE_BYTES, MAX_FRAME_BYTES, MAX_LIST_LIMIT,
53    MAX_PTY_ARGV_ITEMS, MAX_PTY_STDIN_BYTES, MAX_PULL_EVENTS, MAX_PULL_TIMEOUT_MS,
54    MAX_REGISTRY_SEARCH_LIMIT, MAX_REGISTRY_TEST_SAMPLE_BYTES, MAX_REGISTRY_TEST_SAMPLES,
55    MAX_REQUEST_BYTES, MAX_RESPONSE_BYTES, MAX_SESSION_ENV_ITEMS, MAX_SESSION_LINE_BYTES,
56    MAX_SUBSCRIPTIONS, MAX_SUGGEST_PROPOSED_RULES, MAX_SUGGEST_SAMPLE_BYTES, MAX_SUGGEST_SAMPLES,
57    MAX_TAIL_BYTES, MAX_TAIL_LINES, OutcomeTrust, PackAvailableHint, PolicyCapsView,
58    PolicyStatusResponse, ProbeKind, ProbeListEntry, ProbeListResponse, ProbeStatusParams,
59    ProbeStatusResponse, ProgramProbe, PtyCommandListEntry, PtyCommandListResponse,
60    PtyCommandStartParams, PtyCommandStartResponse, PtyCommandStopParams, PtyCommandStopResponse,
61    PtyCommandWriteStdinParams, PtyCommandWriteStdinResponse, RegistryActivateParams,
62    RegistryActivateResponse, RegistryActiveEntry, RegistryDeactivateBulkParams,
63    RegistryDeactivateBulkResponse, RegistryDeactivateParams, RegistryDeactivateResponse,
64    RegistryGetParams, RegistryGetResponse, RegistryImportFailure, RegistryImportPackParams,
65    RegistryImportPackResponse, RegistryListActiveResponse, RegistrySearchHit,
66    RegistrySearchParams, RegistrySearchResponse, RegistrySuggestFromSamplesParams,
67    RegistrySuggestFromSamplesResponse, RegistryTestMatch, RegistryTestParams,
68    RegistryTestResponse, RegistryTestSample, RegistryUpsertParams, RegistryUpsertResponse,
69    RequestEnvelope, ResponseEnvelope, RuntimeActiveRule, RuntimeBucketSummary,
70    RuntimeStateResponse, SelfCheckResponse, SessionState, SeverityHistogram, ShellExecParams,
71    ShellSessionExecParams, ShellSessionExecResponse, ShellSessionListEntry,
72    ShellSessionListResponse, ShellSessionStartParams, ShellSessionStartResponse,
73    ShellSessionStatusParams, ShellSessionStatusResponse, ShellSessionStopParams,
74    ShellSessionStopResponse, SourceLiveness, SubscriptionCloseParams, SubscriptionCloseResponse,
75    SubscriptionEvent, SubscriptionListParams, SubscriptionListResponse, SubscriptionOpenParams,
76    SubscriptionOpenResponse, SubscriptionPredicate, SubscriptionPullParams,
77    SubscriptionPullResponse, SubscriptionSourceSel, SubscriptionSummary, TerminalProbe,
78    WorkspaceSnapshotApplyParams, WorkspaceSnapshotApplyResponse, WorkspaceSnapshotCreateParams,
79    WorkspaceSnapshotCreateResponse, WslProbe, decode_payload, encode_frame,
80};
81
82pub use framing::{ReadOutcome, read_frame, read_request, read_request_classified, write_response};
83
84#[cfg(unix)]
85pub use client::DaemonClient;
86
87#[cfg(windows)]
88pub use pipe_client::DaemonClient;