@artos-commerce/ucp-cli 0.1.0

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.
Files changed (56) hide show
  1. package/README.md +177 -0
  2. package/dist/agent.d.ts +35 -0
  3. package/dist/agent.js +46 -0
  4. package/dist/agent.js.map +1 -0
  5. package/dist/args.d.ts +20 -0
  6. package/dist/args.js +58 -0
  7. package/dist/args.js.map +1 -0
  8. package/dist/cli.d.ts +7 -0
  9. package/dist/cli.js +250 -0
  10. package/dist/cli.js.map +1 -0
  11. package/dist/commands/account.d.ts +19 -0
  12. package/dist/commands/account.js +31 -0
  13. package/dist/commands/account.js.map +1 -0
  14. package/dist/commands/cart.d.ts +17 -0
  15. package/dist/commands/cart.js +51 -0
  16. package/dist/commands/cart.js.map +1 -0
  17. package/dist/commands/catalog-search.d.ts +22 -0
  18. package/dist/commands/catalog-search.js +27 -0
  19. package/dist/commands/catalog-search.js.map +1 -0
  20. package/dist/commands/checkout.d.ts +20 -0
  21. package/dist/commands/checkout.js +52 -0
  22. package/dist/commands/checkout.js.map +1 -0
  23. package/dist/commands/discover.d.ts +13 -0
  24. package/dist/commands/discover.js +27 -0
  25. package/dist/commands/discover.js.map +1 -0
  26. package/dist/commands/init.d.ts +16 -0
  27. package/dist/commands/init.js +222 -0
  28. package/dist/commands/init.js.map +1 -0
  29. package/dist/commands/profile-init.d.ts +22 -0
  30. package/dist/commands/profile-init.js +34 -0
  31. package/dist/commands/profile-init.js.map +1 -0
  32. package/dist/commands/purchase.d.ts +22 -0
  33. package/dist/commands/purchase.js +29 -0
  34. package/dist/commands/purchase.js.map +1 -0
  35. package/dist/config.d.ts +28 -0
  36. package/dist/config.js +22 -0
  37. package/dist/config.js.map +1 -0
  38. package/dist/conformance.d.ts +35 -0
  39. package/dist/conformance.js +240 -0
  40. package/dist/conformance.js.map +1 -0
  41. package/dist/doctor.d.ts +23 -0
  42. package/dist/doctor.js +123 -0
  43. package/dist/doctor.js.map +1 -0
  44. package/dist/index.d.ts +2 -0
  45. package/dist/index.js +25 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/io.d.ts +24 -0
  48. package/dist/io.js +2 -0
  49. package/dist/io.js.map +1 -0
  50. package/dist/output.d.ts +38 -0
  51. package/dist/output.js +131 -0
  52. package/dist/output.js.map +1 -0
  53. package/dist/profile.d.ts +38 -0
  54. package/dist/profile.js +43 -0
  55. package/dist/profile.js.map +1 -0
  56. package/package.json +63 -0
package/README.md ADDED
@@ -0,0 +1,177 @@
1
+ # @artos-commerce/ucp-cli
2
+
3
+ Command-line tools for building **agents on Artos** (the Universal Commerce
4
+ Protocol). Scaffold an agent UCP profile, run connectivity diagnostics, inspect a
5
+ store's UCP profile, search the cross-store catalog, and drive a full
6
+ cart → checkout → purchase flow (plus buyer-account tools) — without hand-rolling
7
+ the UCP transport, headers, or signing.
8
+
9
+ It is the **Build track** companion to
10
+ [`@artos-commerce/ucp-client`](https://www.npmjs.com/package/@artos-commerce/ucp-client):
11
+ the CLI uses the SDK under the hood. If you only want an agent (Claude, Cursor)
12
+ to shop, use the hosted **Connect** bridge instead — see the
13
+ [Artos agent docs](https://docs.artos.sh/agents).
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ npm install -g @artos-commerce/ucp-cli
19
+ # or run ad hoc:
20
+ npx @artos-commerce/ucp-cli --help
21
+ ```
22
+
23
+ Requires **Node 20+**. The crypto settlement rail's `@mysten/sui` is **not**
24
+ needed for any CLI command.
25
+
26
+ ## Configuration
27
+
28
+ Every command resolves its connection from flags first, then the environment,
29
+ then defaults:
30
+
31
+ | Setting | Flag | Env | Default |
32
+ | --- | --- | --- | --- |
33
+ | Artos API base URL | `--api` | `ARTOS_BASE_URL` | `https://api.artos.sh` |
34
+ | Platform API key | `--key` | `UCP_PLATFORM_API_KEY` | _(none — anonymous)_ |
35
+ | Agent profile URL | `--profile` | `PLATFORM_PROFILE_URL` | _(none)_ |
36
+
37
+ Catalog discovery is anonymous, so `catalog search` and `discover` work with no
38
+ key. **Cart, checkout, and purchase** need a real platform key
39
+ (`UCP_PLATFORM_API_KEY`). **`purchase confirm`** additionally needs your agent
40
+ signing key (`AGENT_PRIVATE_JWK` + `AGENT_KID`) so it can mint the AP2 mandate,
41
+ and **`account`** (and any buyer-bound call) needs a buyer OAuth bearer
42
+ (`ARTOS_BUYER_BEARER`). The CLI settles the **card / $0** rails; for crypto
43
+ settlement, use the SDK directly.
44
+
45
+ ## Commands
46
+
47
+ ### `artos init [name]`
48
+
49
+ Scaffolds a runnable **Build-track** starter project: `package.json`,
50
+ `tsconfig.json`, `.env.example`, and a `src/index.ts` wired with `UcpClient`,
51
+ `createCheckoutHandlers`, `createAccountHandlers`, and `OAuthClient` (a
52
+ search → checkout demo plus account-tool and buyer-OAuth examples). Refuses to
53
+ overwrite a directory that already has a `package.json`.
54
+
55
+ ```bash
56
+ artos init my-agent # → ./my-agent
57
+ artos init my-agent --out /path/to/dir
58
+ cd my-agent && npm install && cp .env.example .env && npm start
59
+ ```
60
+
61
+ ### `artos profile init`
62
+
63
+ Generates an EC P-256 signing keypair and a UCP profile document.
64
+
65
+ ```bash
66
+ artos profile init --out ./agent-profile --url https://your-app.example/.well-known/ucp
67
+ ```
68
+
69
+ Writes `ucp.json` (host it publicly at the `--url`) and `private-jwk.json`
70
+ (**secret** — load as `AGENT_PRIVATE_JWK`, never commit). Prints the env vars to
71
+ export.
72
+
73
+ ### `artos doctor`
74
+
75
+ Checks your connection to Artos: platform key, the API's UCP discovery profile,
76
+ the OAuth Authorization Server metadata, and (when configured) your published
77
+ agent profile. Exits non-zero on any failure.
78
+
79
+ ```bash
80
+ artos doctor
81
+ artos doctor --api https://api.dev.artos.sh --profile https://your-app.example/.well-known/ucp
82
+ ```
83
+
84
+ ### `artos conformance [--store <slug>]`
85
+
86
+ Runs a battery of live UCP conformance checks against a deployment: the platform
87
+ discovery profile and its declared UCP version, the OAuth metadata (endpoints,
88
+ PKCE `S256`, `offline_access` / `purchase:complete` scopes), the cross-store
89
+ catalog search, the buyer-bound `401` + `WWW-Authenticate` relay contract, and —
90
+ when a store is given — that the store publishes signing keys for AP2
91
+ verification. Exits non-zero if any required check fails (warnings don't fail the
92
+ run), so it drops straight into CI. Add `--json` for a machine-readable report.
93
+
94
+ ```bash
95
+ artos conformance --api https://api.dev.artos.sh --key "$UCP_PLATFORM_API_KEY"
96
+ artos conformance --store acme --json
97
+ ```
98
+
99
+ ### `artos discover --store <slug>`
100
+
101
+ Fetches a store's UCP profile and prints its protocol version, signing keys,
102
+ payment handlers, and capabilities.
103
+
104
+ ```bash
105
+ artos discover --store about-you
106
+ artos discover --store about-you --json
107
+ ```
108
+
109
+ ### `artos catalog search <query>`
110
+
111
+ Searches the cross-store catalog with the correct UCP headers. `--max` is in
112
+ major units (dollars) and is converted to minor units for you.
113
+
114
+ ```bash
115
+ artos catalog search "running shoes" --max 150 --currency USD
116
+ artos catalog search shoes --json
117
+ ```
118
+
119
+ ### `artos cart <create|view|update>`
120
+
121
+ Manages a store cart. `--item` is repeatable and takes a variant id with an
122
+ optional `:quantity` (default 1).
123
+
124
+ ```bash
125
+ artos cart create --store about-you --item <variantId>:2 --item <variantId>
126
+ artos cart view --store about-you --id <cartId>
127
+ artos cart update --store about-you --id <cartId> --item <variantId>:3
128
+ ```
129
+
130
+ ### `artos checkout <create|view|update>`
131
+
132
+ Manages a store checkout. Build it from a cart (`--cart`) or line items
133
+ (`--item`), and set nested fields with `--set` (dotted keys nest, e.g.
134
+ `--set shipping_address.country=US`).
135
+
136
+ ```bash
137
+ artos checkout create --store about-you --cart <cartId> --set shipping_address.country=US
138
+ artos checkout view --store about-you --id <checkoutId>
139
+ artos checkout update --store about-you --id <checkoutId> --set buyer.email=you@example.com
140
+ ```
141
+
142
+ ### `artos purchase confirm`
143
+
144
+ Re-prices the checkout, verifies the store's signed terms, mints the AP2
145
+ mandate, and places the order on the **card / $0** rail. Needs
146
+ `AGENT_PRIVATE_JWK` + `AGENT_KID`. Exit codes: `0` placed, `2` action required
147
+ (escalation / pick a rail with `--pay`), `1` error.
148
+
149
+ ```bash
150
+ artos purchase confirm --store about-you --id <checkoutId> --pay sh.artos.card
151
+ artos purchase confirm --store about-you --id <checkoutId> --coupon # apply best coupon
152
+ ```
153
+
154
+ ### `artos account <list|call> [tool]`
155
+
156
+ Lists or calls buyer-account tools (`get_buyer_context`, `list_my_orders`, …).
157
+ Buyer-bound, so it needs `ARTOS_BUYER_BEARER`.
158
+
159
+ ```bash
160
+ artos account list
161
+ artos account call list_my_orders --args '{"limit":5}'
162
+ artos account call get_buyer_context --set verbose=true
163
+ ```
164
+
165
+ ## Development
166
+
167
+ ```bash
168
+ npm install
169
+ npm run check # lint + typecheck + test:coverage + build
170
+ ```
171
+
172
+ See [AGENTS.md](AGENTS.md) for the conventions (the `Io` seam, sui-free SDK
173
+ subpaths, the testing bar) every change must follow.
174
+
175
+ ## License
176
+
177
+ MIT
@@ -0,0 +1,35 @@
1
+ import { UcpClient } from '@artos-commerce/ucp-client/ucp';
2
+ import type { UcpResponse } from '@artos-commerce/ucp-client/ucp';
3
+ import { Ap2Signer } from '@artos-commerce/ucp-client/ap2';
4
+ import { type CheckoutOutcome, type ConfirmPurchaseInput } from '@artos-commerce/ucp-client/checkout';
5
+ import type { CliConfig } from './config.js';
6
+ import type { Io } from './io.js';
7
+ /** Buyer bearer env var (server-side OAuth token for buyer-bound calls). */
8
+ export declare function buyerToken(env: NodeJS.ProcessEnv): string | undefined;
9
+ /**
10
+ * Builds the AP2 signer. With `AGENT_PRIVATE_JWK` set it uses the real key (whose
11
+ * public half must be in the published profile, so minted mandates verify);
12
+ * otherwise it generates an ephemeral key so read/write cart + checkout commands
13
+ * (which never mint a verifiable mandate) still work without agent credentials.
14
+ */
15
+ export declare function buildSigner(env: NodeJS.ProcessEnv): Promise<Ap2Signer>;
16
+ /** The store-tool call surface cart/checkout commands operate over. */
17
+ export interface StoreCaller {
18
+ call: (slug: string, name: string, args: Record<string, unknown>, opts?: {
19
+ idempotent?: boolean;
20
+ auth?: 'platform' | 'buyer';
21
+ }) => Promise<UcpResponse>;
22
+ }
23
+ /** Adapts a {@link UcpClient} to the {@link StoreCaller} seam. */
24
+ export declare function storeCaller(client: UcpClient): StoreCaller;
25
+ /** The buyer-account tool surface the `account` command operates over. */
26
+ export interface AccountCaller {
27
+ listAccountTools: UcpClient['listAccountTools'];
28
+ callAccountTool: UcpClient['callAccountTool'];
29
+ }
30
+ /** Constructs a UCP client carrying the (optional) buyer bearer. */
31
+ export declare function buildClient(cfg: CliConfig, io: Io): UcpClient;
32
+ /** A bound `confirmPurchase` function (the only place that needs the signer). */
33
+ export type ConfirmFn = (input: ConfirmPurchaseInput) => Promise<CheckoutOutcome>;
34
+ /** Wires the checkout handlers and returns its `confirmPurchase`. Card/$0 only. */
35
+ export declare function buildConfirm(cfg: CliConfig, io: Io): Promise<ConfirmFn>;
package/dist/agent.js ADDED
@@ -0,0 +1,46 @@
1
+ import { webcrypto } from 'node:crypto';
2
+ import { UcpClient } from '@artos-commerce/ucp-client/ucp';
3
+ import { Ap2Signer } from '@artos-commerce/ucp-client/ap2';
4
+ import { createCheckoutHandlers, } from '@artos-commerce/ucp-client/checkout';
5
+ /** Buyer bearer env var (server-side OAuth token for buyer-bound calls). */
6
+ export function buyerToken(env) {
7
+ return env.ARTOS_BUYER_BEARER?.trim() || undefined;
8
+ }
9
+ /**
10
+ * Builds the AP2 signer. With `AGENT_PRIVATE_JWK` set it uses the real key (whose
11
+ * public half must be in the published profile, so minted mandates verify);
12
+ * otherwise it generates an ephemeral key so read/write cart + checkout commands
13
+ * (which never mint a verifiable mandate) still work without agent credentials.
14
+ */
15
+ export async function buildSigner(env) {
16
+ const raw = env.AGENT_PRIVATE_JWK?.trim();
17
+ if (raw) {
18
+ const jwk = JSON.parse(raw);
19
+ return new Ap2Signer(jwk, env.AGENT_KID?.trim() || jwk.kid || '');
20
+ }
21
+ const pair = await webcrypto.subtle.generateKey({ name: 'ECDSA', namedCurve: 'P-256' }, true, ['sign', 'verify']);
22
+ const jwk = (await webcrypto.subtle.exportKey('jwk', pair.privateKey));
23
+ return new Ap2Signer(jwk, 'ephemeral');
24
+ }
25
+ /** Adapts a {@link UcpClient} to the {@link StoreCaller} seam. */
26
+ export function storeCaller(client) {
27
+ return {
28
+ call: (slug, name, args, opts) => client.callStoreTool(slug, name, args, opts),
29
+ };
30
+ }
31
+ /** Constructs a UCP client carrying the (optional) buyer bearer. */
32
+ export function buildClient(cfg, io) {
33
+ return new UcpClient({
34
+ artosBaseUrl: cfg.artosBaseUrl,
35
+ platformApiKey: cfg.platformApiKey,
36
+ platformProfileUrl: cfg.platformProfileUrl,
37
+ }, { fetch: io.fetch, buyerToken: buyerToken(io.env) });
38
+ }
39
+ /** Wires the checkout handlers and returns its `confirmPurchase`. Card/$0 only. */
40
+ export async function buildConfirm(cfg, io) {
41
+ const client = buildClient(cfg, io);
42
+ const signer = await buildSigner(io.env);
43
+ const handlers = createCheckoutHandlers({ client, signer });
44
+ return (input) => handlers.confirmPurchase(input);
45
+ }
46
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EACL,sBAAsB,GAGvB,MAAM,qCAAqC,CAAC;AAI7C,4EAA4E;AAC5E,MAAM,UAAU,UAAU,CAAC,GAAsB;IAC/C,OAAO,GAAG,CAAC,kBAAkB,EAAE,IAAI,EAAE,IAAI,SAAS,CAAC;AACrD,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAsB;IACtD,MAAM,GAAG,GAAG,GAAG,CAAC,iBAAiB,EAAE,IAAI,EAAE,CAAC;IAC1C,IAAI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Y,CAAC,GAAc,EAAE,EAAM;IACvD,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACpC,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACzC,MAAM,QAAQ,GAAG,sBAAsB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC5D,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;AACpD,CAAC"}
package/dist/args.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ import type { CheckoutLineItem } from '@artos-commerce/ucp-client/checkout';
2
+ /**
3
+ * Parses repeated `--item` values into UCP line items. Each value is a variant
4
+ * id with an optional `:quantity` suffix (default 1), e.g. `v123` or `v123:2`.
5
+ */
6
+ export declare function parseItems(values: string[]): CheckoutLineItem[];
7
+ /** UCP line-item wire shape (`{ item: { id }, quantity }`). */
8
+ export declare function lineItems(items: CheckoutLineItem[]): Array<{
9
+ item: {
10
+ id: string;
11
+ };
12
+ quantity: number;
13
+ }>;
14
+ /**
15
+ * Parses repeated `--set key=value` pairs into a (possibly nested) object. Dotted
16
+ * keys build nested objects, e.g. `shipping_address.country=US` →
17
+ * `{ shipping_address: { country: 'US' } }`. `true`/`false` become booleans;
18
+ * everything else stays a string.
19
+ */
20
+ export declare function parseSet(pairs: string[]): Record<string, unknown>;
package/dist/args.js ADDED
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Parses repeated `--item` values into UCP line items. Each value is a variant
3
+ * id with an optional `:quantity` suffix (default 1), e.g. `v123` or `v123:2`.
4
+ */
5
+ export function parseItems(values) {
6
+ return values.map((raw) => {
7
+ const [id, qty] = raw.split(':');
8
+ const quantity = qty ? Number(qty) : 1;
9
+ if (!id || Number.isNaN(quantity) || quantity <= 0) {
10
+ throw new Error(`Invalid --item "${raw}" (expected "<variantId>" or "<variantId>:<qty>").`);
11
+ }
12
+ return { id, quantity };
13
+ });
14
+ }
15
+ /** UCP line-item wire shape (`{ item: { id }, quantity }`). */
16
+ export function lineItems(items) {
17
+ return items.map((i) => ({ item: { id: i.id }, quantity: i.quantity ?? 1 }));
18
+ }
19
+ /**
20
+ * Coerces a `--set` value to a boolean for the literals `true`/`false`, leaving
21
+ * everything else a string. Numbers are intentionally NOT coerced — fields like
22
+ * `postal_code=94016` / `02134` must stay strings (and lose no leading zeros).
23
+ */
24
+ function coerce(value) {
25
+ if (value === 'true')
26
+ return true;
27
+ if (value === 'false')
28
+ return false;
29
+ return value;
30
+ }
31
+ /**
32
+ * Parses repeated `--set key=value` pairs into a (possibly nested) object. Dotted
33
+ * keys build nested objects, e.g. `shipping_address.country=US` →
34
+ * `{ shipping_address: { country: 'US' } }`. `true`/`false` become booleans;
35
+ * everything else stays a string.
36
+ */
37
+ export function parseSet(pairs) {
38
+ const out = {};
39
+ for (const pair of pairs) {
40
+ const eq = pair.indexOf('=');
41
+ if (eq <= 0) {
42
+ throw new Error(`Invalid --set "${pair}" (expected "key=value").`);
43
+ }
44
+ const path = pair.slice(0, eq).split('.');
45
+ const value = coerce(pair.slice(eq + 1));
46
+ let node = out;
47
+ for (let i = 0; i < path.length - 1; i++) {
48
+ const key = path[i];
49
+ if (typeof node[key] !== 'object' || node[key] === null) {
50
+ node[key] = {};
51
+ }
52
+ node = node[key];
53
+ }
54
+ node[path[path.length - 1]] = value;
55
+ }
56
+ return out;
57
+ }
58
+ //# sourceMappingURL=args.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,MAAgB;IACzC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QACxB,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACjC,MAAM,QAAQ,G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C,CAAC;QAC1C,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;QACzC,IAAI,IAAI,GAAG,GAAG,CAAC;QACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YACzC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACpB,IAAI,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,QAAQ,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;gBACxD,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;YACjB,CAAC;YACD,IAAI,GAAG,IAAI,CAAC,GAAG,CAA4B,CAAC;QAC9C,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;IACtC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import type { Io } from './io.js';
2
+ export declare const HELP = "artos \u2014 CLI for building agents on Artos (UCP)\n\nUsage:\n artos <command> [subcommand] [options]\n\nCommands:\n init [name] Scaffold a Build-track agent starter project\n profile init Generate an agent UCP profile + signing keypair\n doctor Check connectivity: API, OAuth, agent profile\n conformance [--store <slug>] Run live UCP conformance checks\n discover --store <slug> Inspect a store's UCP profile\n catalog search <query> Search the cross-store catalog\n cart <create|view|update> Manage a store cart\n checkout <create|view|update> Manage a store checkout\n purchase confirm Re-price, sign the mandate, and place the order\n account <list|call> [tool] List or call buyer-account tools\n\nGlobal options:\n --api <url> Artos API base URL (env ARTOS_BASE_URL)\n --key <key> Platform API key (env UCP_PLATFORM_API_KEY)\n --profile <url> Agent profile URL (env PLATFORM_PROFILE_URL)\n --json Machine-readable JSON output\n -h, --help Show this help\n\nCommand options:\n init [name] --out <dir>\n profile init --out <dir> --url <profileUrl> --kid <kid>\n catalog search --max <price> --currency <code>\n cart / checkout --store <slug> --id <id> --cart <cartId>\n --item <variantId[:qty]> (repeatable)\n --set <key=value> (repeatable; dotted keys nest)\n purchase confirm --store <slug> --id <checkoutId> --pay <handlerId>\n --mandate <uuid> --coupon | --no-coupon\n account call <tool> --set <key=value> --args <json>\n\nAuth env: AGENT_PRIVATE_JWK + AGENT_KID (mandate signing, purchase),\n ARTOS_BUYER_BEARER (buyer-bound calls: account, crypto).\n";
3
+ /**
4
+ * Parses argv and dispatches to a command, returning the process exit code.
5
+ * All side effects flow through {@link Io}, so this is fully unit-testable.
6
+ */
7
+ export declare function run(argv: string[], io: Io): Promise<number>;
package/dist/cli.js ADDED
@@ -0,0 +1,250 @@
1
+ import { parseArgs } from 'node:util';
2
+ import { join } from 'node:path';
3
+ import { resolveConfig } from './config.js';
4
+ import { runDoctor, formatReport } from './doctor.js';
5
+ import { runConformance, formatConformance } from './conformance.js';
6
+ import { generateAgentProfile } from './profile.js';
7
+ import { parseItems, parseSet } from './args.js';
8
+ import { buildClient, buildConfirm, buyerToken, storeCaller } from './agent.js';
9
+ import { catalogSearch } from './commands/catalog-search.js';
10
+ import { discover } from './commands/discover.js';
11
+ import { profileInit } from './commands/profile-init.js';
12
+ import { initProject } from './commands/init.js';
13
+ import { cart } from './commands/cart.js';
14
+ import { checkout } from './commands/checkout.js';
15
+ import { purchaseConfirm } from './commands/purchase.js';
16
+ import { account } from './commands/account.js';
17
+ export const HELP = `artos — CLI for building agents on Artos (UCP)
18
+
19
+ Usage:
20
+ artos <command> [subcommand] [options]
21
+
22
+ Commands:
23
+ init [name] Scaffold a Build-track agent starter project
24
+ profile init Generate an agent UCP profile + signing keypair
25
+ doctor Check connectivity: API, OAuth, agent profile
26
+ conformance [--store <slug>] Run live UCP conformance checks
27
+ discover --store <slug> Inspect a store's UCP profile
28
+ catalog search <query> Search the cross-store catalog
29
+ cart <create|view|update> Manage a store cart
30
+ checkout <create|view|update> Manage a store checkout
31
+ purchase confirm Re-price, sign the mandate, and place the order
32
+ account <list|call> [tool] List or call buyer-account tools
33
+
34
+ Global options:
35
+ --api <url> Artos API base URL (env ARTOS_BASE_URL)
36
+ --key <key> Platform API key (env UCP_PLATFORM_API_KEY)
37
+ --profile <url> Agent profile URL (env PLATFORM_PROFILE_URL)
38
+ --json Machine-readable JSON output
39
+ -h, --help Show this help
40
+
41
+ Command options:
42
+ init [name] --out <dir>
43
+ profile init --out <dir> --url <profileUrl> --kid <kid>
44
+ catalog search --max <price> --currency <code>
45
+ cart / checkout --store <slug> --id <id> --cart <cartId>
46
+ --item <variantId[:qty]> (repeatable)
47
+ --set <key=value> (repeatable; dotted keys nest)
48
+ purchase confirm --store <slug> --id <checkoutId> --pay <handlerId>
49
+ --mandate <uuid> --coupon | --no-coupon
50
+ account call <tool> --set <key=value> --args <json>
51
+
52
+ Auth env: AGENT_PRIVATE_JWK + AGENT_KID (mandate signing, purchase),
53
+ ARTOS_BUYER_BEARER (buyer-bound calls: account, crypto).
54
+ `;
55
+ /** Builds a JSON GET helper that throws on a non-2xx response. */
56
+ function makeFetchJson(fetchFn) {
57
+ return async (url) => {
58
+ const res = await fetchFn(url, { headers: { accept: 'application/json' } });
59
+ if (!res.ok)
60
+ throw new Error(`HTTP ${res.status}`);
61
+ return (await res.json());
62
+ };
63
+ }
64
+ /** Tri-state coupon flag from `--coupon` / `--no-coupon`. */
65
+ function couponChoice(values) {
66
+ if (values.coupon === true)
67
+ return true;
68
+ if (values['no-coupon'] === true)
69
+ return false;
70
+ return undefined;
71
+ }
72
+ /**
73
+ * Parses argv and dispatches to a command, returning the process exit code.
74
+ * All side effects flow through {@link Io}, so this is fully unit-testable.
75
+ */
76
+ export async function run(argv, io) {
77
+ let values;
78
+ let positionals;
79
+ try {
80
+ const parsed = parseArgs({
81
+ args: argv,
82
+ allowPositionals: true,
83
+ options: {
84
+ api: { type: 'string' },
85
+ key: { type: 'string' },
86
+ profile: { type: 'string' },
87
+ out: { type: 'string' },
88
+ url: { type: 'string' },
89
+ kid: { type: 'string' },
90
+ store: { type: 'string' },
91
+ max: { type: 'string' },
92
+ currency: { type: 'string' },
93
+ id: { type: 'string' },
94
+ cart: { type: 'string' },
95
+ pay: { type: 'string' },
96
+ mandate: { type: 'string' },
97
+ args: { type: 'string' },
98
+ item: { type: 'string', multiple: true },
99
+ set: { type: 'string', multiple: true },
100
+ coupon: { type: 'boolean' },
101
+ 'no-coupon': { type: 'boolean' },
102
+ json: { type: 'boolean' },
103
+ help: { type: 'boolean', short: 'h' },
104
+ },
105
+ });
106
+ values = parsed.values;
107
+ positionals = parsed.positionals;
108
+ }
109
+ catch (err) {
110
+ io.error(err.message);
111
+ io.error(HELP);
112
+ return 1;
113
+ }
114
+ if (values.help || positionals.length === 0) {
115
+ io.write(HELP);
116
+ return 0;
117
+ }
118
+ const flags = {
119
+ api: values.api,
120
+ key: values.key,
121
+ profile: values.profile,
122
+ };
123
+ const cfg = resolveConfig(io.env, flags);
124
+ const [command, sub, ...rest] = positionals;
125
+ const json = values.json === true;
126
+ const store = values.store ?? '';
127
+ const id = values.id;
128
+ const itemVals = values.item ?? [];
129
+ const setVals = values.set ?? [];
130
+ try {
131
+ switch (command) {
132
+ case 'doctor': {
133
+ const report = await runDoctor({ cfg, fetch: io.fetch });
134
+ io.write(formatReport(report));
135
+ return report.ok ? 0 : 1;
136
+ }
137
+ case 'conformance': {
138
+ const report = await runConformance({
139
+ cfg,
140
+ fetch: io.fetch,
141
+ search: () => buildClient(cfg, io).globalSearch({
142
+ query: 'test',
143
+ pagination: { limit: 1 },
144
+ }),
145
+ }, { store: store || undefined });
146
+ io.write(json ? JSON.stringify(report, null, 2) : formatConformance(report));
147
+ return report.ok ? 0 : 1;
148
+ }
149
+ case 'discover': {
150
+ return await discover({ fetchJson: makeFetchJson(io.fetch), baseUrl: cfg.artosBaseUrl, io }, { store, json });
151
+ }
152
+ case 'catalog': {
153
+ if (sub !== 'search') {
154
+ io.error(`Unknown catalog subcommand: ${sub ?? '(none)'} (try "search")`);
155
+ return 1;
156
+ }
157
+ const max = values.max != null ? Number(values.max) : undefined;
158
+ if (max != null && Number.isNaN(max)) {
159
+ io.error('--max must be a number (major units, e.g. 150).');
160
+ return 1;
161
+ }
162
+ return await catalogSearch({ client: buildClient(cfg, io), io }, {
163
+ query: rest.join(' '),
164
+ max,
165
+ currency: values.currency,
166
+ json,
167
+ });
168
+ }
169
+ case 'init': {
170
+ const name = sub ?? 'artos-agent-starter';
171
+ const outDir = values.out ?? join(io.cwd, name);
172
+ return initProject({ io }, { name, outDir });
173
+ }
174
+ case 'profile': {
175
+ if (sub !== 'init') {
176
+ io.error(`Unknown profile subcommand: ${sub ?? '(none)'} (try "init")`);
177
+ return 1;
178
+ }
179
+ const outDir = values.out ??
180
+ join(io.cwd, 'artos-agent-profile');
181
+ const url = values.url ??
182
+ 'https://your-app.example/.well-known/ucp';
183
+ return await profileInit({
184
+ generate: generateAgentProfile,
185
+ mkdir: io.mkdir,
186
+ writeFile: io.writeFile,
187
+ io,
188
+ }, { outDir, url, kid: values.kid });
189
+ }
190
+ case 'cart': {
191
+ return await cart({ store: storeCaller(buildClient(cfg, io)), io }, {
192
+ action: (sub ?? 'view'),
193
+ store,
194
+ id,
195
+ items: parseItems(itemVals),
196
+ json,
197
+ });
198
+ }
199
+ case 'checkout': {
200
+ return await checkout({ store: storeCaller(buildClient(cfg, io)), io }, {
201
+ action: (sub ?? 'view'),
202
+ store,
203
+ id,
204
+ cartId: values.cart,
205
+ items: parseItems(itemVals),
206
+ set: parseSet(setVals),
207
+ json,
208
+ });
209
+ }
210
+ case 'purchase': {
211
+ if (sub !== 'confirm') {
212
+ io.error(`Unknown purchase subcommand: ${sub ?? '(none)'} (try "confirm")`);
213
+ return 1;
214
+ }
215
+ const confirm = await buildConfirm(cfg, io);
216
+ return await purchaseConfirm({ confirm, io }, {
217
+ store,
218
+ id: id ?? '',
219
+ pay: values.pay,
220
+ mandate: values.mandate,
221
+ applyCoupon: couponChoice(values),
222
+ json,
223
+ });
224
+ }
225
+ case 'account': {
226
+ const action = sub === 'call' ? 'call' : 'list';
227
+ let toolArgs = {};
228
+ if (values.args) {
229
+ toolArgs = JSON.parse(values.args);
230
+ }
231
+ if (setVals.length)
232
+ toolArgs = { ...toolArgs, ...parseSet(setVals) };
233
+ return await account({
234
+ account: buildClient(cfg, io),
235
+ hasBuyer: Boolean(buyerToken(io.env)),
236
+ io,
237
+ }, { action, tool: rest[0], toolArgs, json });
238
+ }
239
+ default:
240
+ io.error(`Unknown command: ${command}`);
241
+ io.write(HELP);
242
+ return 1;
243
+ }
244
+ }
245
+ catch (err) {
246
+ io.error(`artos: ${err.message}`);
247
+ return 1;
248
+ }
249
+ }
250
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAoB,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,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'../io.js';
3
+ export type AccountAction = 'list' | 'call';
4
+ export interface AccountArgs {
5
+ action: AccountAction;
6
+ /** Tool name for `account call <tool>`. */
7
+ tool?: string;
8
+ /** Arguments object for `account call` (from `--set`/`--args`). */
9
+ toolArgs?: Record<string, unknown>;
10
+ json?: boolean;
11
+ }
12
+ export interface AccountDeps {
13
+ account: AccountCaller;
14
+ /** Whether a buyer bearer is configured (account tools are buyer-bound). */
15
+ hasBuyer: boolean;
16
+ io: Pick<Io, 'write' | 'error'>;
17
+ }
18
+ /** Lists or calls buyer-account tools (require ARTOS_BUYER_BEARER). */
19
+ export declare function account(deps: AccountDeps, args: AccountArgs): Promise<number>;