CLI¶
xcore_agent.cli — the Typer application. See CLI reference
for the human-readable command guide.
xcore_agent.cli
¶
Command-line entry point for xcore-agent.
app = typer.Typer(add_completion=False, help='xcore-agent — deploys .xdeploy artifacts.')
module-attribute
¶
console = Console()
module-attribute
¶
SupervisorKind
¶
Bases: str, Enum
Source code in xcore_agent/cli.py
MarketplaceKind
¶
validate(install_yaml: Path = typer.Argument(..., help='Path to install.yaml'), manifest_json: Path = typer.Option(None, help='Optional path to manifest.json to validate alongside it')) -> None
¶
Validate an install.yaml (and optionally manifest.json) — local only, no network.
Source code in xcore_agent/cli.py
init_plan(project_id: str = typer.Argument(..., help="project_id to stamp in the plan — must equal the plugin's marketplace slug for `deploy-marketplace`/`watch-marketplace`"), plugin: list[str] = typer.Option(..., help='Plugin id to install (repeatable) — one install_plugin step per id, in the order given'), extension: list[str] = typer.Option([], help='Extension id to install (repeatable) — one install_extension step per id, for a shared non-plugin service under extensions/<id> (see manifest.ExtensionRef). Separate id namespace from --plugin: a plugin and an extension may share an id.'), version: str = typer.Option('0.1.0', help='Version to stamp in the plan'), output: Path = typer.Option(Path('deployment/install.yaml'), help='Where to write the generated install.yaml'), env_template: list[str] = typer.Option([], help='PLUGIN=RELATIVE_PATH adding a write_env step for that plugin (repeatable), e.g. demo=plugins/demo/.env.template'), snapshot: bool = typer.Option(True, help='Take a rollback snapshot before each install_plugin/install_extension step'), healthcheck: bool = typer.Option(True, help='Append a healthcheck step after start'), healthcheck_timeout: str = typer.Option('30s', help="Healthcheck timeout, e.g. '30s' or '2m'"), healthcheck_retries: int = typer.Option(3, help='Healthcheck retry count'), force: bool = typer.Option(False, help='Overwrite --output if it already exists')) -> None
¶
Generate a starter install.yaml for a project: one install_plugin step
per --plugin (in order given), one install_extension step per --extension,
an optional write_env step per --env-template, a start step depending on
all of them, and an optional trailing healthcheck. The result is
validated through InstallPlan before being written, so it is guaranteed
loadable by validate/deploy/deploy-marketplace as-is — a starting
point to hand-edit from, not a substitute for reviewing what actually
gets deployed.
Source code in xcore_agent/cli.py
build(source_root: Path = typer.Argument(..., help='Project source tree: plugins/, integration.yaml, deployment/install.yaml'), project_id: str = typer.Option(...), project_name: str = typer.Option(...), version: str = typer.Option(..., help='Version to stamp on this artifact, e.g. 1.0.0'), output: Path = typer.Option(..., help='Output path for the encrypted .xdeploy artifact'), signing_key_file: Path = typer.Option(None, help='Path to a raw 32-byte Ed25519 private key. A throwaway key is generated (and NOT saved) if omitted — fine for local testing, not for anything an agent needs to trust across builds.')) -> None
¶
Build, encrypt, and sign a .xdeploy artifact from a project source tree.
Source code in xcore_agent/cli.py
publish(source_root: Path = typer.Argument(..., help='Project source tree: plugins/, integration.yaml, deployment/install.yaml'), project_id: str = typer.Option(..., envvar='XCORE_PROJECT_ID'), project_name: str = typer.Option(...), version: str = typer.Option(..., help='Version to stamp on this artifact, e.g. 1.0.0'), xdevkey: str = typer.Option(..., envvar='XCORE_XDEVKEY'), hub_url: str = typer.Option('https://hub.xcorehub.dev', envvar='XCORE_HUB_URL'), output: Path = typer.Option(None, help='Also write the sealed .xdeploy artifact here (optional — it stays on Hub either way, this is just a local copy for your own records)'), signing_key_file: Path = typer.Option(None, help="Path to a raw 32-byte Ed25519 private key. A throwaway key is generated (and NOT saved) if omitted — fine for a one-off publish, but a `watch`er needs the SAME trusted key across every version of a project it's told to follow, so reuse one across builds if you intend to keep publishing updates to this project_id.")) -> None
¶
Build, encrypt, sign, and upload a .xdeploy artifact to XCore Hub in
one step. build alone only produces a local file and prints the DEK to
your terminal with instructions to "hand this to the Hub" — nothing in
xcore-agent actually did that upload before this command existed. The
DEK never touches disk here: it stays in memory between build and
publish, exactly like deploy/watch never persist one either.
Source code in xcore_agent/cli.py
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 | |
deploy(project_id: str = typer.Option(..., envvar='XCORE_PROJECT_ID'), version: str = typer.Option(..., help='Version to deploy, e.g. 1.0.0'), xdevkey: str = typer.Option(..., envvar='XCORE_XDEVKEY'), deployment_credential: str = typer.Option(..., envvar='XCORE_DEPLOYMENT_KEY'), hub_url: str = typer.Option('https://hub.xcorehub.dev', envvar='XCORE_HUB_URL'), project_root: Path = typer.Option(..., help='Target install directory, e.g. /etc/xcore/projects/my-erp'), signer_public_key: Path = typer.Option(..., help="Path to the Hub's Ed25519 public key (raw 32 bytes)"), git_token: list[str] = typer.Option([], help="HOST=TOKEN for a private git host a source-based plugin may need to authenticate against (repeatable) — only used for a plugin/extension whose 'source:' is a git fallback (see PluginSource), not a marketplace slug. Public repos and SSH URLs need none of this."), marketplace_url: str = typer.Option('https://marketplace.xcorehub.dev', envvar='XCORE_MARKETPLACE_URL', help="Marketplace root (no /app/... segment), used to resolve any plugin/extension whose 'source:' is a marketplace slug — see `deploy-marketplace --help` for the shape of this URL. Irrelevant if every plugin in this project is either embedded or git-sourced."), marketplace_api_key: str = typer.Option(None, envvar='XCORE_MARKETPLACE_API_KEY', help="xdevkeys API key (xdk_...), required only if some plugin/extension in this project has a marketplace-slug 'source:' (the default xcli records for anything installed via `xcli plugin install`)."), marketplace_signing_secret: str = typer.Option(None, envvar='XCORE_MARKETPLACE_SIGNING_SECRET', help='HMAC signing secret verifying marketplace-sourced plugins/extensions (see `deploy-marketplace --help`) — required alongside --marketplace-api-key whenever this project has one.'), provisioners_config: Path = typer.Option(None, help="YAML file mapping plugin id -> {command, env, timeout} for the 'provision' action — see agent/provisioners.py. Omit if no plugin in this project uses 'provision'."), notifiers_config: Path = typer.Option(None, help="YAML file mapping event -> {command, env, timeout} for the 'notify' action — see agent/notifiers.py. Omit if no step in this project's install.yaml uses 'notify'."), plugin_secret_key: str = typer.Option(None, envvar='XCORE_PLUGIN_SECRET', help="This host's own `plugins.secret_key` (root integration.yaml, e.g. ${PLUGIN_SECRET}/${SECRET_KEY} depending on the project's env naming) — signs every installed `execution_mode: trusted` plugin with plugin.sig so this host's strict_trusted check (xcore.kernel.security.signature) can load it. Host-local, never embedded in the artifact — same as --signing-secret is NOT this. Omit if this host doesn't run strict_trusted: true, or has no trusted-mode plugins.")) -> None
¶
Deploy a project version fetched from XCore Hub.
Requires a live Hub API — not available yet (see agent.hub_client.HttpHubClient) — so this command currently fails at the authenticate step by design.
Source code in xcore_agent/cli.py
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 | |
deploy_marketplace(slug: str = typer.Argument(..., help='Plugin or extension slug on the marketplace'), version: str = typer.Option('latest', help="Version to deploy, or 'latest'"), kind: MarketplaceKind = typer.Option(MarketplaceKind.plugin), api_key: str = typer.Option(..., envvar='XCORE_API_KEY', help='xdevkeys API key (xdk_...)'), signing_secret: str = typer.Option(..., envvar='XCORE_SIGNING_SECRET', help="The publisher's HMAC signing secret (from xdevkeys) — obtained out-of-band, e.g. from the plugin's developer. Unlike Ed25519, this is a *shared* secret: whoever holds it can also forge a signature, so treat its source as part of your trust decision, not the signature check alone."), hub_url: str = typer.Option('https://marketplace.xcorehub.dev', envvar='XCORE_HUB_URL', help="Hub root, WITHOUT a plugin segment — MarketplaceClient appends the right /app/<plugin> mount itself (marketplace, xservices, or xdeployments depending on the request; see marketplace_client.py's module docstring). e.g. https://marketplace.xcorehub.dev, or http://localhost:8000 for a local Hub."), project_root: Path = typer.Option(..., help='Target install directory, e.g. /etc/xcore/projects/my-erp'), host_id: str = typer.Option(None, envvar='XCORE_HOST_ID', help="Identifier for this target reported alongside deployment status (GET /deployments/{kind}/{slug}/hosts on the marketplace) — defaults to this machine's hostname."), install_plan: Path = typer.Option(..., help='Local install.yaml — the real Marketplace ships plain plugin source, not a deployment plan, so this is supplied by the operator (same trust boundary as --provisioners-config), never fetched from the Hub.'), provisioners_config: Path = typer.Option(None, help="YAML file mapping plugin id -> {command, env, timeout} for the 'provision' action — see agent/provisioners.py."), notifiers_config: Path = typer.Option(None, help="YAML file mapping event -> {command, env, timeout} for the 'notify' action — see agent/notifiers.py."), plugin_secret_key: str = typer.Option(None, envvar='XCORE_PLUGIN_SECRET', help="This host's own `plugins.secret_key` (root integration.yaml) — signs the installed plugin with plugin.sig if it declares `execution_mode: trusted`, so this host's strict_trusted check can load it. No effect for kind=service (no plugin.yaml/execution_mode there). See `deploy --help` for the same option's full explanation.")) -> None
¶
Deploy a single plugin or extension fetched from the real xcore-team/marketplace
(X-API-Key auth, HMAC-SHA256-signed plain ZIP) — see agent/marketplace_client.py
for how this differs from deploy's .xdeploy/DEK/Ed25519 contract.
Source code in xcore_agent/cli.py
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 | |
watch_marketplace(slug: str = typer.Argument(..., help='Plugin or extension slug on the marketplace'), kind: MarketplaceKind = typer.Option(MarketplaceKind.plugin), api_key: str = typer.Option(..., envvar='XCORE_API_KEY', help='xdevkeys API key (xdk_...)'), signing_secret: str = typer.Option(..., envvar='XCORE_SIGNING_SECRET', help="The publisher's HMAC signing secret (from xdevkeys) — see `deploy-marketplace` --signing-secret for the trust-model caveat."), hub_url: str = typer.Option('https://marketplace.xcorehub.dev', envvar='XCORE_HUB_URL', help="Hub root, WITHOUT a plugin segment — MarketplaceClient appends the right /app/<plugin> mount itself (marketplace, xservices, or xdeployments depending on the request; see marketplace_client.py's module docstring). e.g. https://marketplace.xcorehub.dev, or http://localhost:8000 for a local Hub."), project_root: Path = typer.Option(..., help='Target install directory, e.g. /etc/xcore/projects/my-erp'), host_id: str = typer.Option(None, envvar='XCORE_HOST_ID', help="Identifier for this target reported alongside deployment status — defaults to this machine's hostname."), install_plan: Path = typer.Option(..., help='Local install.yaml — supplied by the operator, never fetched from the Hub (same as `deploy-marketplace` --install-plan).'), interval: int = typer.Option(60, help='Seconds between Marketplace checks'), once: bool = typer.Option(False, help='Check once and exit instead of looping forever'), keep_snapshots: int = typer.Option(3, help='Rollback snapshots to keep for this plugin'), supervisor: SupervisorKind = typer.Option(SupervisorKind.none, help='How to restart the plugin after a redeploy and GC pass'), systemd_user_scope: bool = typer.Option(True, help='Use `systemctl --user` vs system-wide'), k8s_namespace: str = typer.Option('default', help='Namespace for --supervisor kubernetes'), k8s_kubeconfig: str = typer.Option(None, help="Path to a kubeconfig file for --supervisor kubernetes (defaults to kubectl's own)"), k8s_context: str = typer.Option(None, help="kubeconfig context for --supervisor kubernetes (defaults to kubectl's current)"), provisioners_config: Path = typer.Option(None, help="YAML file mapping plugin id -> {command, env, timeout} for the 'provision' action — see agent/provisioners.py."), notifiers_config: Path = typer.Option(None, help="YAML file mapping event -> {command, env, timeout} for the 'notify' action — see agent/notifiers.py.")) -> None
¶
Poll the real xcore-team/marketplace for a new version of one plugin
or extension and redeploy automatically when it appears — the CI/CD loop
for the Marketplace flow (X-API-Key auth, HMAC-signed plain ZIP; see
agent/marketplace_client.py). Runs garbage collection after every
successful redeploy, same as watch.
Source code in xcore_agent/cli.py
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 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 | |
watch(project_id: str = typer.Option(..., envvar='XCORE_PROJECT_ID'), xdevkey: str = typer.Option(..., envvar='XCORE_XDEVKEY'), deployment_credential: str = typer.Option(..., envvar='XCORE_DEPLOYMENT_KEY'), hub_url: str = typer.Option('https://hub.xcorehub.dev', envvar='XCORE_HUB_URL'), project_root: Path = typer.Option(...), signer_public_key: Path = typer.Option(..., help="Path to the Hub's Ed25519 public key (raw 32 bytes)"), interval: int = typer.Option(60, help='Seconds between Hub checks'), once: bool = typer.Option(False, help='Check once and exit instead of looping forever'), keep_snapshots: int = typer.Option(3, help='Rollback snapshots to keep per plugin'), supervisor: SupervisorKind = typer.Option(SupervisorKind.none, help='How to restart plugins after a redeploy and GC pass'), systemd_user_scope: bool = typer.Option(True, help='Use `systemctl --user` vs system-wide'), k8s_namespace: str = typer.Option('default', help='Namespace for --supervisor kubernetes'), k8s_kubeconfig: str = typer.Option(None, help="Path to a kubeconfig file for --supervisor kubernetes (defaults to kubectl's own)"), k8s_context: str = typer.Option(None, help="kubeconfig context for --supervisor kubernetes (defaults to kubectl's current)"), git_token: list[str] = typer.Option([], help="HOST=TOKEN for a private git host a source-based plugin may need to authenticate against (repeatable) — only used for a plugin/extension whose 'source:' is a git fallback (see PluginSource), not a marketplace slug. Public repos and SSH URLs need none of this."), marketplace_url: str = typer.Option('https://marketplace.xcorehub.dev', envvar='XCORE_MARKETPLACE_URL', help="Marketplace root (no /app/... segment), used to resolve any plugin/extension whose 'source:' is a marketplace slug. Irrelevant if every plugin in this project is either embedded or git-sourced."), marketplace_api_key: str = typer.Option(None, envvar='XCORE_MARKETPLACE_API_KEY', help="xdevkeys API key (xdk_...), required only if some plugin/extension in this project has a marketplace-slug 'source:' (the default xcli records for anything installed via `xcli plugin install`)."), marketplace_signing_secret: str = typer.Option(None, envvar='XCORE_MARKETPLACE_SIGNING_SECRET', help='HMAC signing secret verifying marketplace-sourced plugins/extensions — required alongside --marketplace-api-key whenever this project has one.'), provisioners_config: Path = typer.Option(None, help="YAML file mapping plugin id -> {command, env, timeout} for the 'provision' action — see agent/provisioners.py."), notifiers_config: Path = typer.Option(None, help="YAML file mapping event -> {command, env, timeout} for the 'notify' action — see agent/notifiers.py.")) -> None
¶
Poll XCore Hub for a new version/tag and redeploy automatically when one appears — the CI/CD loop. Runs garbage collection (stale rollback snapshots + cached downloads) after every successful redeploy. Requires a live Hub API — not available yet (see agent.hub_client.HttpHubClient).
Source code in xcore_agent/cli.py
708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 | |
gc(project_root: Path = typer.Option(...), cache_root: Path = typer.Option(None, help='Cache root to prune (e.g. ~/.cache/xcore-agent/<project-id>)'), keep_version: list[str] = typer.Option([], help='Version(s) to keep in the cache — repeat for multiple'), keep_snapshots: int = typer.Option(3, help='Rollback snapshots to keep per plugin'), force_restart: bool = typer.Option(False, help='Restart every installed plugin after cleanup'), supervisor: SupervisorKind = typer.Option(SupervisorKind.systemd, help='Which supervisor to use when --force-restart is set'), systemd_user_scope: bool = typer.Option(True, help='Use `systemctl --user` vs system-wide'), k8s_namespace: str = typer.Option('default', help='Namespace for --supervisor kubernetes'), k8s_kubeconfig: str = typer.Option(None, help="Path to a kubeconfig file for --supervisor kubernetes (defaults to kubectl's own)"), k8s_context: str = typer.Option(None, help="kubeconfig context for --supervisor kubernetes (defaults to kubectl's current)")) -> None
¶
Purge stale rollback snapshots and cached artifact downloads, and optionally force every plugin to restart afterward so no running process keeps serving state that was just reclaimed on disk.
Source code in xcore_agent/cli.py
resolve_sources_cmd(project_root: Path = typer.Argument(..., help='Project root containing deployment/install.yaml and its plugins/extensions'), install_plan: Path = typer.Option(None, help='Override path to install.yaml (default: <project_root>/deployment/install.yaml)'), marketplace_url: str = typer.Option('https://marketplace.xcorehub.dev', envvar='XCORE_MARKETPLACE_URL', help='Marketplace root, used for any step whose source: is a marketplace slug.'), marketplace_api_key: str = typer.Option(None, envvar='XCORE_MARKETPLACE_API_KEY', help='xdevkeys API key (xdk_...), required only if some step has a marketplace-slug source:.'), marketplace_signing_secret: str = typer.Option(None, envvar='XCORE_MARKETPLACE_SIGNING_SECRET', help='HMAC signing secret verifying marketplace-sourced steps — required alongside --marketplace-api-key whenever this project has one.'), git_token: list[str] = typer.Option([], help='HOST=TOKEN for a private git host a source-based step may need to authenticate against (repeatable). Public repos and SSH URLs need none of this.'), cache_root: Path = typer.Option(None, help='Resolver cache directory (default: ~/.cache/xcore-agent/resolve-sources).')) -> None
¶
Resolve every source: declared in a project's own install.yaml
directly onto its plugins/extensions directories, in place — no
.xdeploy artifact, no Hub, no signature/hash pin involved. For a
project resolving its OWN declared sources against itself: typically a
container image reconstructing its marketplace-sourced plugins at boot
(docker-entrypoint.sh), before the app underneath ever loads them —
see agent.pipeline.DeploymentRunner._resolve_plugins for the
artifact-verifying equivalent of this used by deploy/watch.
Source code in xcore_agent/cli.py
909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 | |
watch_sources_cmd(project_root: Path = typer.Argument(..., help='Project root containing deployment/install.yaml and its plugins/extensions'), marketplace_api_key: str = typer.Option(..., envvar='XCORE_MARKETPLACE_API_KEY'), marketplace_signing_secret: str = typer.Option(..., envvar='XCORE_MARKETPLACE_SIGNING_SECRET'), marketplace_url: str = typer.Option('https://marketplace.xcorehub.dev', envvar='XCORE_MARKETPLACE_URL', help='Marketplace root, used for every step whose source: is a marketplace slug.'), install_plan: Path = typer.Option(None, help='Override path to install.yaml (default: <project_root>/deployment/install.yaml)'), interval: int = typer.Option(300, help='Seconds between marketplace checks'), once: bool = typer.Option(False, help='Check once and exit instead of looping forever'), exit_on_update: bool = typer.Option(False, help='Exit (code 0) right after applying at least one update instead of continuing to poll — for a process supervisor that restarts the whole process to pick up the newly-written files (this command never restarts anything itself). Ignored with --once, which always exits after its single check.'), cache_root: Path = typer.Option(None, help='Resolver cache directory (default: ~/.cache/xcore-agent/watch-sources).')) -> None
¶
Poll the marketplace for every source: declared in a project's own
install.yaml and re-resolve (in place) whichever ones have a newer
published version — the multi-source counterpart to watch-marketplace
for a project that DEPENDS ON several independent marketplace plugins/
extensions rather than BEING one itself (watch-marketplace replays
install.yaml's entire plan through a single fetched artifact, which
breaks the moment more than one step declares its own source: — see
watch_sources.py's module docstring). Like resolve-sources, this
never touches install.yaml's own steps (no start/healthcheck, no
InstallDriver) and never restarts anything — see --exit-on-update for
the intended way to let a supervisor do that.
Source code in xcore_agent/cli.py
988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 | |