a3s 0.10.5

a3s — A3S coding agent CLI; `a3s code` launches the interactive TUI
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
use std::ffi::OsString;
use std::path::PathBuf;

use a3s::components::ComponentId;
use clap::{Args, Parser, Subcommand, ValueEnum};

mod code;
pub(crate) use code::*;
mod admin;
pub(crate) use admin::*;

#[derive(Debug, Parser)]
#[command(
    name = "a3s",
    version,
    about = "A3S agent platform CLI",
    propagate_version = true,
    disable_help_subcommand = true
)]
pub(crate) struct Cli {
    /// Run as if A3S was started in this directory.
    #[arg(short = 'C', long, global = true, value_name = "PATH")]
    pub directory: Option<PathBuf>,

    /// Use one explicit A3S ACL configuration file.
    #[arg(long, global = true, value_name = "PATH")]
    pub config: Option<PathBuf>,

    /// Select human, JSON, or JSONL output for root-owned commands.
    #[arg(long, global = true, value_enum, default_value_t = OutputMode::Human)]
    pub output: OutputMode,

    /// Shorthand for --output json.
    #[arg(long, global = true, conflicts_with = "output")]
    pub json: bool,

    /// Suppress nonessential human output.
    #[arg(short, long, global = true, conflicts_with = "verbose")]
    pub quiet: bool,

    /// Increase diagnostic detail; repeat for more detail.
    #[arg(short, long, global = true, action = clap::ArgAction::Count)]
    pub verbose: u8,

    /// Control terminal color.
    #[arg(long, global = true, value_enum, default_value_t = ColorMode::Auto)]
    pub color: ColorMode,

    /// Disable progress bars and spinners.
    #[arg(long, global = true)]
    pub no_progress: bool,

    /// Disable network access and first-use downloads.
    #[arg(long, global = true)]
    pub offline: bool,

    /// Never prompt for input.
    #[arg(long, global = true)]
    pub non_interactive: bool,

    #[command(subcommand)]
    pub command: Option<RootCommand>,
}

impl Cli {
    pub(crate) fn output_mode(&self) -> OutputMode {
        if self.json {
            OutputMode::Json
        } else {
            self.output
        }
    }
}

#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, ValueEnum)]
pub(crate) enum OutputMode {
    #[default]
    Human,
    Json,
    Jsonl,
}

#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, ValueEnum)]
pub(crate) enum ColorMode {
    #[default]
    Auto,
    Always,
    Never,
}

#[derive(Debug, Subcommand)]
pub(crate) enum RootCommand {
    /// Launch or automate the A3S coding agent.
    Code(CodeArgs),
    /// Run the local A3S Web application and API.
    Web(WebArgs),
    /// Monitor agents, containers, sessions, and events.
    Top(TopArgs),
    /// Run the registered A3S Box product.
    Box(ProxyArgs),
    /// Manage a multi-service application with A3S Box.
    Compose(ProxyArgs),
    /// Create and start the current Compose application.
    Up(ProxyArgs),
    /// Stop and remove the current Compose application.
    Down(ProxyArgs),
    /// List services in the current Compose application.
    Ps(ProxyArgs),
    /// View logs from the current Compose application.
    Logs(ProxyArgs),
    /// Run the registered A3S Bench product.
    Bench(ProxyArgs),
    /// Run the registered A3S Search product.
    Search(ProxyArgs),
    /// Use Browser, Office, or an installed A3S Use extension.
    Use(ProxyArgs),
    /// Manage account authentication.
    Auth(AuthArgs),
    /// Discover and select runtime models.
    Model(ModelArgs),
    /// Inspect and edit A3S ACL configuration.
    Config(ConfigArgs),
    /// List registered components and discovered external tools.
    List(ListArgs),
    /// Show component status, sources, and available versions.
    Info(InfoArgs),
    /// Install or repair registered components.
    Install(InstallArgs),
    /// List or apply component upgrades.
    Upgrade(UpgradeArgs),
    /// Remove only component-owned files.
    Uninstall(UninstallArgs),
    /// Run read-only installation and health diagnostics.
    Doctor(DoctorArgs),
    /// Manage trusted component registries.
    Registry(RegistryArgs),
    /// Inspect or remove recreatable cache data.
    Cache(CacheArgs),
    /// Manage the A3S executable itself.
    #[command(name = "self")]
    Self_(SelfArgs),
    /// Print A3S version information.
    Version,
    /// Generate shell completion source.
    Completion(CompletionArgs),
    /// Show help for a command path.
    Help(HelpArgs),
    /// Compatibility route for the former overloaded update command.
    #[command(name = "update", hide = true)]
    LegacyUpdate(PassthroughArgs),
}

#[derive(Clone, Debug, Args)]
#[command(trailing_var_arg = true, disable_help_flag = true)]
pub(crate) struct PassthroughArgs {
    #[arg(allow_hyphen_values = true)]
    pub args: Vec<OsString>,
}

#[derive(Clone, Debug, Args)]
#[command(
    trailing_var_arg = true,
    disable_help_flag = true,
    disable_version_flag = true
)]
pub(crate) struct ProxyArgs {
    #[arg(allow_hyphen_values = true)]
    pub args: Vec<OsString>,
}

#[derive(Clone, Debug, Args)]
pub(crate) struct WebArgs {
    #[command(subcommand)]
    pub command: Option<WebCommand>,

    #[command(flatten)]
    pub shortcut: WebStartArgs,
}

#[derive(Clone, Debug, Subcommand)]
pub(crate) enum WebCommand {
    /// Start A3S Web in the foreground or as a managed instance.
    Start(WebStartArgs),
    /// Stop the managed instance for the effective workspace.
    Stop(WebTargetArgs),
    /// Inspect the managed instance for the effective workspace.
    Status(WebTargetArgs),
    /// Read or follow the managed instance log.
    Logs(WebLogsArgs),
    /// Open the managed instance in the default browser.
    Open(WebTargetArgs),
}

#[derive(Clone, Debug, Default, Args)]
pub(crate) struct WebStartArgs {
    /// Run as a managed background instance.
    #[arg(short = 'd', long = "detach")]
    pub detach: bool,

    /// Gracefully replace a verified A3S Web instance; never stop an unrelated process.
    #[arg(long)]
    pub replace: bool,

    /// Listen host. Defaults to A3S_CODE_WEB_HOST or 127.0.0.1.
    #[arg(long, value_name = "HOST")]
    pub host: Option<String>,

    /// Listen port. Use 0 to select an available port.
    #[arg(long, value_name = "PORT")]
    pub port: Option<u16>,

    /// Deprecated workspace spelling; use global --directory/-C.
    #[arg(short = 'w', long = "workspace", value_name = "PATH", hide = true)]
    pub legacy_workspace: Option<PathBuf>,

    /// Directory containing built Web assets.
    #[arg(long, value_name = "PATH")]
    pub web_dir: Option<PathBuf>,

    /// Serve only the API without Web assets.
    #[arg(long)]
    pub api_only: bool,
}

#[derive(Clone, Debug, Default, Args)]
pub(crate) struct WebTargetArgs {
    /// Deprecated workspace spelling; use global --directory/-C.
    #[arg(short = 'w', long = "workspace", value_name = "PATH", hide = true)]
    pub legacy_workspace: Option<PathBuf>,
}

#[derive(Clone, Debug, Args)]
pub(crate) struct WebLogsArgs {
    #[command(flatten)]
    pub target: WebTargetArgs,

    /// Continue printing appended log data until interrupted.
    #[arg(short, long)]
    pub follow: bool,

    /// Number of existing lines to print before following.
    #[arg(short = 'n', long, default_value_t = 100)]
    pub lines: usize,
}

#[derive(Clone, Debug, Default, Args)]
pub(crate) struct TopArgs {
    /// Focus one container by name or ID.
    #[arg(long, value_name = "CONTAINER", conflicts_with = "legacy_container")]
    pub container: Option<String>,

    /// Select the initial monitor view.
    #[arg(long, value_enum, conflicts_with = "legacy_view")]
    pub view: Option<TopView>,

    /// Select the container runtime connector.
    #[arg(long, value_enum)]
    pub connector: Option<TopConnector>,

    /// Show only active containers.
    #[arg(short = 'a', long, alias = "active-only", conflicts_with = "all")]
    pub active: bool,

    /// Include stopped containers.
    #[arg(long, conflicts_with = "active")]
    pub all: bool,

    /// Filter visible rows.
    #[arg(short, long, value_name = "TEXT")]
    pub filter: Option<String>,

    /// Select the sort field.
    #[arg(short, long, value_enum)]
    pub sort: Option<TopSort>,

    /// Reverse the selected sort order.
    #[arg(short, long)]
    pub reverse: bool,

    /// Filter by risk level.
    #[arg(long, value_enum)]
    pub risk: Option<TopRisk>,

    /// Filter observer events by kind.
    #[arg(long, value_enum)]
    pub kind: Option<TopEventKind>,

    /// Emit repeated machine snapshots.
    #[arg(long)]
    pub watch: bool,

    /// Snapshot or refresh interval, for example 1500ms or 2s.
    #[arg(long, value_name = "DURATION")]
    pub interval: Option<String>,

    /// Stop after this many machine snapshots.
    #[arg(long, value_name = "COUNT", requires = "watch")]
    pub count: Option<usize>,

    /// Restore the compact column set.
    #[arg(long, alias = "compact-columns")]
    pub compact: bool,

    /// Hide table headers.
    #[arg(long)]
    pub no_header: bool,

    /// Invert terminal colors.
    #[arg(short, long)]
    pub invert: bool,

    /// Deprecated positional container shorthand. A duration after --watch is
    /// interpreted as the former combined watch grammar.
    #[arg(value_name = "LEGACY_CONTAINER", hide = true)]
    pub legacy_container: Option<String>,

    #[arg(long, hide = true, group = "legacy_view")]
    pub agents: bool,
    #[arg(long = "sessions", hide = true, group = "legacy_view")]
    pub view_sessions: bool,
    #[arg(long = "containers", hide = true, group = "legacy_view")]
    pub view_containers: bool,
    #[arg(long = "processes", hide = true, group = "legacy_view")]
    pub view_processes: bool,
    #[arg(long = "events", hide = true, group = "legacy_view")]
    pub view_events: bool,
}

#[derive(Clone, Copy, Debug, Eq, PartialEq, ValueEnum)]
pub(crate) enum TopView {
    Agents,
    Sessions,
    Containers,
    Processes,
    Events,
}

#[derive(Clone, Copy, Debug, Eq, PartialEq, ValueEnum)]
pub(crate) enum TopConnector {
    #[value(name = "a3s-box")]
    A3sBox,
    Docker,
    Runc,
}

#[derive(Clone, Copy, Debug, Eq, PartialEq, ValueEnum)]
pub(crate) enum TopSort {
    Cpu,
    Mem,
    Net,
    Block,
    Pids,
    State,
    Id,
    Uptime,
    Name,
    Tokens,
}

#[derive(Clone, Copy, Debug, Eq, PartialEq, ValueEnum)]
pub(crate) enum TopRisk {
    All,
    Medium,
    High,
}

#[derive(Clone, Copy, Debug, Eq, PartialEq, ValueEnum)]
pub(crate) enum TopEventKind {
    All,
    Tool,
    Security,
    File,
    Egress,
    Llm,
    Other,
}

#[derive(Debug, Args)]
#[command(subcommand_required = true, arg_required_else_help = true)]
pub(crate) struct AuthArgs {
    #[command(subcommand)]
    pub command: AuthCommand,
}

#[derive(Debug, Subcommand)]
pub(crate) enum AuthCommand {
    /// List managed and discovered account providers.
    List,
    /// Show account and credential status.
    Status(AuthProviderArgs),
    /// Sign in through OAuth or protected token input.
    Login(AuthLoginArgs),
    /// Remove the stored managed session.
    Logout(AuthProviderArgs),
}

#[derive(Clone, Debug, Default, Args)]
pub(crate) struct AuthProviderArgs {
    /// Authentication provider. The initial managed provider is os.
    #[arg(value_name = "PROVIDER", default_value = "os", value_parser = ["os"])]
    pub provider: String,
}

#[derive(Clone, Debug, Default, Args)]
pub(crate) struct AuthLoginArgs {
    /// Authentication provider. Values other than os are treated as unsafe
    /// legacy positional input and are never echoed.
    #[arg(value_name = "PROVIDER")]
    pub provider_or_legacy: Option<OsString>,

    /// Read an existing bearer token from standard input.
    #[arg(long, conflicts_with = "token_file")]
    pub token_stdin: bool,

    /// Read an existing bearer token from a protected file.
    #[arg(long, value_name = "PATH", conflicts_with = "token_stdin")]
    pub token_file: Option<PathBuf>,

    /// Captures unsafe legacy positional credentials so they can be rejected
    /// without Clap reflecting their values in an error message.
    #[arg(value_name = "LEGACY_TOKEN", hide = true)]
    pub legacy_values: Vec<OsString>,
}

#[derive(Debug, Args)]
#[command(subcommand_required = true, arg_required_else_help = true)]
pub(crate) struct ModelArgs {
    #[command(subcommand)]
    pub command: ModelCommand,
}

#[derive(Debug, Subcommand)]
pub(crate) enum ModelCommand {
    /// List configured and compatible account-backed models.
    List,
    /// Show the effective default model.
    Current,
    /// Select and persist a validated default model.
    Use(ModelUseArgs),
    /// Remove the selected default model from one config layer.
    Reset(ModelScopeArgs),
}

#[derive(Clone, Debug, Args)]
pub(crate) struct ModelUseArgs {
    /// Source-qualified model ID, for example openai/gpt-5.
    #[arg(value_name = "PROVIDER/MODEL")]
    pub model: String,

    #[command(flatten)]
    pub target: ModelScopeArgs,
}

#[derive(Clone, Debug, Args)]
pub(crate) struct ModelScopeArgs {
    /// ACL layer to update when --config is not present.
    #[arg(long, value_enum, default_value_t = ConfigScope::User)]
    pub scope: ConfigScope,
}

#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, ValueEnum)]
pub(crate) enum ConfigScope {
    Workspace,
    #[default]
    User,
}

#[derive(Clone, Debug, Args)]
pub(crate) struct ConfigScopeArgs {
    /// ACL layer to use when --config is not present.
    #[arg(long, value_enum, default_value_t = ConfigScope::User)]
    pub scope: ConfigScope,
}

#[derive(Debug, Args)]
#[command(subcommand_required = true, arg_required_else_help = true)]
pub(crate) struct ConfigArgs {
    #[command(subcommand)]
    pub command: ConfigCommand,
}

#[derive(Debug, Subcommand)]
pub(crate) enum ConfigCommand {
    /// Print the active ACL config path.
    Path,
    /// Print A3S config, data, state, cache, and asset paths.
    Paths,
    /// Print an effective redacted configuration summary.
    Show,
    /// Create a starter A3S ACL configuration.
    Init(ConfigInitArgs),
    /// Open an ACL configuration in VISUAL or EDITOR.
    Edit(ConfigScopeArgs),
    /// Parse and validate an ACL configuration.
    Validate(ConfigValidateArgs),
}

#[derive(Clone, Debug, Args)]
pub(crate) struct ConfigInitArgs {
    /// ACL layer to create when --config is not present.
    #[arg(long, value_enum, default_value_t = ConfigScope::User)]
    pub scope: ConfigScope,
    /// Replace an existing config with the starter template.
    #[arg(long)]
    pub force: bool,
}

#[derive(Clone, Debug, Default, Args)]
pub(crate) struct ConfigValidateArgs {
    /// Config path. Defaults to the active config.
    #[arg(value_name = "PATH")]
    pub path: Option<PathBuf>,
}

#[derive(Clone, Debug, Default, Args)]
pub(crate) struct ListArgs {
    /// Show only installed or otherwise present components.
    #[arg(long, conflicts_with = "available")]
    pub installed: bool,
    /// Show only missing components that can be installed.
    #[arg(long, conflicts_with = "installed")]
    pub available: bool,
    /// Query release sources and show available upgrades.
    #[arg(long)]
    pub updates: bool,
    /// Filter by component kind.
    #[arg(long, value_enum)]
    pub kind: Option<ComponentKindArg>,
}

#[derive(Clone, Debug, Default, Args)]
#[command(disable_version_flag = true)]
pub(crate) struct InstallArgs {
    /// Registered component IDs.
    #[arg(value_name = "COMPONENT")]
    pub components: Vec<ComponentId>,
    /// Install one exact component version.
    #[arg(long, value_name = "VERSION")]
    pub version: Option<String>,
    /// Select a supported source.
    #[arg(long, value_name = "SOURCE")]
    pub source: Option<String>,
    /// Select a release channel.
    #[arg(long, value_enum, default_value_t = ReleaseChannelArg::Stable)]
    pub channel: ReleaseChannelArg,
    /// Select user or system ownership scope.
    #[arg(long, value_enum, default_value_t = InstallScopeArg::User)]
    pub scope: InstallScopeArg,
    /// Install an explicit local package.
    #[arg(long = "from", value_name = "PATH")]
    pub package: Option<PathBuf>,
    /// Repair or reinstall using current provenance.
    #[arg(long)]
    pub force: bool,
    /// Permit an explicit provenance or scope migration.
    #[arg(long)]
    pub migrate: bool,
    /// Resolve and print the operation plan without mutation.
    #[arg(long)]
    pub dry_run: bool,
    /// Apply only if the newly resolved plan matches this reviewed SHA-256 digest.
    #[arg(
        long,
        value_name = "SHA256",
        conflicts_with = "dry_run",
        value_parser = parse_plan_digest
    )]
    pub plan_digest: Option<String>,
    /// Explicitly trust an unsigned local development package.
    #[arg(long)]
    pub allow_unsigned: bool,
    /// Accept the operation plan without prompting.
    #[arg(long)]
    pub yes: bool,
}

#[derive(Clone, Debug, Default, Args)]
pub(crate) struct UpgradeArgs {
    /// Managed component IDs. With no IDs, only list available upgrades.
    #[arg(value_name = "COMPONENT", conflicts_with = "all")]
    pub components: Vec<ComponentId>,
    /// Upgrade every eligible managed component.
    #[arg(long)]
    pub all: bool,
    /// Accept the operation plan without prompting.
    #[arg(long)]
    pub yes: bool,
    /// Resolve and print the operation plan without mutation.
    #[arg(long)]
    pub dry_run: bool,
    /// Apply only if the newly resolved plan matches this reviewed SHA-256 digest.
    #[arg(
        long,
        value_name = "SHA256",
        conflicts_with = "dry_run",
        value_parser = parse_plan_digest
    )]
    pub plan_digest: Option<String>,
}

#[derive(Clone, Debug, Default, Args)]
pub(crate) struct UninstallArgs {
    /// Registered component IDs.
    #[arg(value_name = "COMPONENT", required = true)]
    pub components: Vec<ComponentId>,
    /// Remove managed children before their parent.
    #[arg(long)]
    pub cascade: bool,
    /// Also remove component-owned cache and runtime state.
    #[arg(long)]
    pub purge: bool,
    /// Accept the operation plan without prompting.
    #[arg(long)]
    pub yes: bool,
    /// Resolve and print the operation plan without mutation.
    #[arg(long)]
    pub dry_run: bool,
    /// Apply only if the newly resolved plan matches this reviewed SHA-256 digest.
    #[arg(
        long,
        value_name = "SHA256",
        conflicts_with = "dry_run",
        value_parser = parse_plan_digest
    )]
    pub plan_digest: Option<String>,
}

fn parse_plan_digest(value: &str) -> Result<String, String> {
    if value.len() != 64
        || !value
            .bytes()
            .all(|byte| byte.is_ascii_hexdigit() && !byte.is_ascii_uppercase())
    {
        return Err("expected exactly 64 lowercase hexadecimal characters".to_string());
    }
    Ok(value.to_string())
}

#[derive(Debug, Args)]
#[command(subcommand_required = true, arg_required_else_help = true)]
pub(crate) struct SelfArgs {
    #[command(subcommand)]
    pub command: SelfCommand,
}

#[derive(Debug, Subcommand)]
pub(crate) enum SelfCommand {
    /// Check for and install a newer A3S CLI release.
    Update(SelfUpdateArgs),
}

#[derive(Clone, Debug, Default, Args)]
pub(crate) struct SelfUpdateArgs {
    /// Check availability without modifying the installation.
    #[arg(long)]
    pub check: bool,
    /// Resolve and print the update without applying it.
    #[arg(long)]
    pub dry_run: bool,
    /// Accept the update plan without prompting.
    #[arg(long)]
    pub yes: bool,
}