shopstack 0.1.0 → 0.2.1
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.
- package/README.md +145 -10
- package/SKILL.md +128 -0
- package/bin/shopstack +8 -1
- package/package.json +28 -6
- package/src/cli.js +516 -0
- package/src/client.d.ts +220 -0
- package/src/client.js +486 -0
- package/src/config.d.ts +55 -0
- package/src/config.js +153 -0
- package/scripts/postinstall.js +0 -6
package/README.md
CHANGED
|
@@ -1,25 +1,160 @@
|
|
|
1
1
|
# shopstack
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
When installed, it tells users:
|
|
6
|
-
|
|
7
|
-
> Wow you're fast! Apply for access at https://shopstack.ai
|
|
3
|
+
Dependency-free JavaScript client and CLI for Shopstack's asynchronous checkout API.
|
|
8
4
|
|
|
9
5
|
## Install
|
|
10
6
|
|
|
11
7
|
```bash
|
|
8
|
+
npm install shopstack
|
|
9
|
+
# or
|
|
12
10
|
npm install -g shopstack
|
|
13
11
|
```
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
Node.js 18 or newer is required.
|
|
14
|
+
|
|
15
|
+
The 0.2.1 source candidate defaults to Shopstack's currently deployed public staging API at
|
|
16
|
+
`https://shopstack-staging.shopstack.workers.dev/v1`. Set
|
|
17
|
+
`SHOPSTACK_API_URL` only when targeting a different Shopstack environment.
|
|
18
|
+
|
|
19
|
+
## Verified signup
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
shopstack signup
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The command asks for email and Personal or Developer account type. It starts a
|
|
26
|
+
15-minute signup and waits while you open the verification email. No account or
|
|
27
|
+
API key exists until the link is consumed. The CLI generates and privately
|
|
28
|
+
persists all retry and polling capabilities before the first request, then
|
|
29
|
+
retrieves the first key after verification and stores it in
|
|
30
|
+
`~/.config/shopstack/config.json` with file mode `0600`; it never prints the
|
|
31
|
+
key, recovery capability, or polling capability. If the command is interrupted,
|
|
32
|
+
rerun `shopstack signup`; the matching pending attempt resumes automatically.
|
|
33
|
+
The explicit helper also remains available:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
shopstack signup resume sup_...
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Developer account and users
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
shopstack signup
|
|
43
|
+
shopstack users create --external-id customer-123 --profile customer-123
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The developer key administers users but cannot run their checkouts. Each created
|
|
47
|
+
user receives an independently scoped API key and CLI profile.
|
|
48
|
+
|
|
49
|
+
## MCP
|
|
50
|
+
|
|
51
|
+
Configure any stdio MCP client to run:
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"mcpServers": {
|
|
56
|
+
"shopstack": {
|
|
57
|
+
"command": "npx",
|
|
58
|
+
"args": ["-y", "shopstack-mcp"]
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The MCP server can start and poll verified signup, manage local profiles,
|
|
65
|
+
create developer-owned users, list/connect Link, and create/poll/message/cancel
|
|
66
|
+
checkouts. It exposes status, activity, and the latest bounded mechanical intent
|
|
67
|
+
phase. It deliberately has no card-input or payment-approval tool.
|
|
16
68
|
|
|
17
|
-
|
|
69
|
+
The canonical agent skill ships as `SKILL.md` in this package. After
|
|
70
|
+
publication it is available at
|
|
71
|
+
`https://unpkg.com/shopstack@0.2.1/SKILL.md` with the release-pinned package.
|
|
18
72
|
|
|
19
|
-
|
|
73
|
+
## Connections
|
|
20
74
|
|
|
21
75
|
```bash
|
|
22
|
-
shopstack
|
|
76
|
+
shopstack connect list
|
|
77
|
+
shopstack connect link
|
|
23
78
|
```
|
|
24
79
|
|
|
25
|
-
|
|
80
|
+
Link is currently the only persistent payment provider. Connecting it is
|
|
81
|
+
optional.
|
|
82
|
+
|
|
83
|
+
## Run a checkout
|
|
84
|
+
|
|
85
|
+
Create `checkout.json` using the canonical API body:
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"item_url": "https://merchant.example/product",
|
|
90
|
+
"instructions": "Buy one in blue",
|
|
91
|
+
"customer": {
|
|
92
|
+
"email": "buyer@example.com",
|
|
93
|
+
"name": "Example Buyer",
|
|
94
|
+
"phone": "+12125550100",
|
|
95
|
+
"shipping_address": {
|
|
96
|
+
"line1": "1 Example Street",
|
|
97
|
+
"line2": "Apartment 2",
|
|
98
|
+
"suburb": "Manhattan",
|
|
99
|
+
"city": "New York",
|
|
100
|
+
"region": "NY",
|
|
101
|
+
"postal_code": "10001",
|
|
102
|
+
"country": "US"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"maximum_amount": "75.00",
|
|
106
|
+
"currency": "USD"
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Then run:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
shopstack checkout run --file checkout.json
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
When no provider is selected, the checkout runs normally until the payment
|
|
117
|
+
form, then asks for card details through a no-echo terminal prompt. Card data is
|
|
118
|
+
sent only to the protected payment-details endpoint. The CLI separately shows
|
|
119
|
+
the exact final amount and asks for approval before Shopstack can submit.
|
|
120
|
+
|
|
121
|
+
To use an active Link connection, add `"payment_provider": "link"` to the
|
|
122
|
+
request.
|
|
123
|
+
|
|
124
|
+
Card values are never accepted as command-line flags.
|
|
125
|
+
|
|
126
|
+
## JavaScript client
|
|
127
|
+
|
|
128
|
+
```js
|
|
129
|
+
import { ShopstackClient } from "shopstack";
|
|
130
|
+
|
|
131
|
+
const onboarding = new ShopstackClient();
|
|
132
|
+
const account = await onboarding.signup({
|
|
133
|
+
accountType: "developer",
|
|
134
|
+
email: "developer@example.com",
|
|
135
|
+
onProgress: ({ state }) => console.log(state),
|
|
136
|
+
persistence: secureSignupPersistence,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
const shopstack = new ShopstackClient({
|
|
140
|
+
apiKey: process.env.SHOPSTACK_API_KEY,
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
const result = await shopstack.runCheckout(checkoutRequest, {
|
|
144
|
+
paymentDetails: async () => secureCardSource(),
|
|
145
|
+
approve: async (approval) => askYourUserToApprove(approval),
|
|
146
|
+
message: async (checkout) => askYourUser(checkout.activity),
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
`signup` generates retry state internally and returns the completed account
|
|
151
|
+
identity only after the one-time credential is stored. It never returns the API
|
|
152
|
+
key, recovery key, or polling token. Pass a secure persistence adapter for
|
|
153
|
+
restart recovery and durable credential storage; never use browser storage.
|
|
154
|
+
|
|
155
|
+
`runCheckout` returns at a required input if its corresponding callback is
|
|
156
|
+
omitted. Final payment approval is never inferred from a message or from
|
|
157
|
+
supplying a card.
|
|
158
|
+
|
|
159
|
+
Set `SHOPSTACK_API_URL` to target a different Shopstack API and
|
|
160
|
+
`SHOPSTACK_CONFIG_FILE` to relocate CLI profiles.
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: shopstack-checkout
|
|
3
|
+
description: Use Shopstack to onboard a verified personal account or a developer with independently scoped end users, inspect optional Link connectivity, and run asynchronous online checkouts while displaying status, activity, and mechanical intent. Trigger for buying products, automating checkout, integrating Shopstack into an agent, or managing developer-owned shopping users.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Shopstack Checkout
|
|
7
|
+
|
|
8
|
+
Use Shopstack as the checkout execution layer. Keep account verification, user ownership, protected payment input, and final payment approval at their typed boundaries.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
For the JavaScript client and CLI:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install shopstack
|
|
16
|
+
npm install -g shopstack
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
For MCP clients, configure the local stdio server:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"mcpServers": {
|
|
24
|
+
"shopstack": {
|
|
25
|
+
"command": "npx",
|
|
26
|
+
"args": ["-y", "shopstack-mcp"]
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Never ask the model to print or relay a Shopstack API key. The CLI and MCP server save verified keys in the private local Shopstack profile file.
|
|
33
|
+
|
|
34
|
+
## Choose the account shape
|
|
35
|
+
|
|
36
|
+
- Use a personal account for `Shopstack -> user`.
|
|
37
|
+
- Use a developer account for `Shopstack -> developer -> user1, user2, ...`.
|
|
38
|
+
- A developer management key creates and manages users but cannot run a user's checkout.
|
|
39
|
+
- Every developer-owned user receives an independent user API key and profile.
|
|
40
|
+
|
|
41
|
+
Start verified CLI signup:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
shopstack signup
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The command prompts for email and Personal or Developer account type. The user
|
|
48
|
+
must open the time-limited verification link. No account or API key exists
|
|
49
|
+
before verification. The CLI generates and privately stores its retry and
|
|
50
|
+
polling capabilities before the request, polls signup, saves the verified key
|
|
51
|
+
with mode `0600`, and prints none of those credentials. Rerunning
|
|
52
|
+
`shopstack signup` automatically resumes the matching pending attempt after an
|
|
53
|
+
interruption; `shopstack signup resume SIGNUP_ID` remains an explicit helper.
|
|
54
|
+
|
|
55
|
+
After developer signup, create an end user:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
shopstack users create --external-id customer-123 --profile customer-123
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Use `shopstack profiles list` and `shopstack profiles use NAME` to select a local profile without exposing its key.
|
|
62
|
+
|
|
63
|
+
## Choose payment connectivity
|
|
64
|
+
|
|
65
|
+
Link is currently the only persistent payment provider, and it is optional:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
shopstack connect list
|
|
69
|
+
shopstack connect link
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Include `payment_provider: "link"` only when the active user's Link connection reports checkout-ready. Otherwise omit `payment_provider`. Shopstack will run until card entry and request one protected checkout-scoped card through the SDK or no-echo CLI prompt.
|
|
73
|
+
|
|
74
|
+
Never put card data in MCP arguments, natural-language messages, model output, logs, or ordinary CLI flags.
|
|
75
|
+
|
|
76
|
+
## Create and monitor a checkout
|
|
77
|
+
|
|
78
|
+
Supply the canonical customer schema unchanged:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"item_url": "https://merchant.example/product",
|
|
83
|
+
"instructions": "Buy one in blue",
|
|
84
|
+
"customer": {
|
|
85
|
+
"email": "buyer@example.com",
|
|
86
|
+
"name": "Example Buyer",
|
|
87
|
+
"phone": "+12125550100",
|
|
88
|
+
"shipping_address": {
|
|
89
|
+
"line1": "1 Example Street",
|
|
90
|
+
"line2": "Apartment 2",
|
|
91
|
+
"suburb": "Manhattan",
|
|
92
|
+
"city": "New York",
|
|
93
|
+
"region": "NY",
|
|
94
|
+
"postal_code": "10001",
|
|
95
|
+
"country": "US"
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"maximum_amount": "75.00",
|
|
99
|
+
"currency": "USD"
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Run it with:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
shopstack checkout run --file checkout.json
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Or create with MCP, then call `poll_checkout`. Display these authoritative fields to the user when they change:
|
|
110
|
+
|
|
111
|
+
- `status`: one of exactly `queued`, `started`, `help_required`, `approval_required`, `submitting`, `complete`, `failed`, `cancelled`;
|
|
112
|
+
- `activity`: bounded present-tense display text;
|
|
113
|
+
- `intent.name`, `intent.phase`, and `intent.updated_at`: bounded mechanical action progress with no arguments or reasoning;
|
|
114
|
+
- `required_input`: a typed handoff such as protected payment-card input;
|
|
115
|
+
- `approval`: the exact amount-bound approval request when present.
|
|
116
|
+
|
|
117
|
+
Poll every two seconds for `queued`, `started`, and `submitting`; every five seconds for `help_required` and `approval_required`; stop at `complete`, `failed`, or `cancelled`.
|
|
118
|
+
|
|
119
|
+
## Respond at typed boundaries
|
|
120
|
+
|
|
121
|
+
- Use `GET/POST /v1/checkout/{id}/messages` only for ordinary missing information.
|
|
122
|
+
- Use protected SDK/CLI payment input when `required_input.type` is `payment_card`.
|
|
123
|
+
- Use only the dedicated payment-approval endpoint from a separately scoped trusted backend.
|
|
124
|
+
- MCP and messages cannot approve payment and expose no approval tool.
|
|
125
|
+
- Never infer approval from a user's conversational message.
|
|
126
|
+
- Cancel with the typed cancellation operation if the user withdraws the request.
|
|
127
|
+
|
|
128
|
+
Use the checkout's canonical current representation as state truth. Events are ordered evidence, not a replacement state machine. Preserve idempotency keys on retried mutations.
|
package/bin/shopstack
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { runCli } from "../src/cli.js";
|
|
4
|
+
|
|
5
|
+
try {
|
|
6
|
+
await runCli(process.argv.slice(2));
|
|
7
|
+
} catch (error) {
|
|
8
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
9
|
+
process.exitCode = 1;
|
|
10
|
+
}
|
package/package.json
CHANGED
|
@@ -1,21 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shopstack",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "Shopstack
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Shopstack API client and command-line checkout tools.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./src/client.d.ts",
|
|
9
|
+
"import": "./src/client.js"
|
|
10
|
+
},
|
|
11
|
+
"./config": {
|
|
12
|
+
"types": "./src/config.d.ts",
|
|
13
|
+
"import": "./src/config.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"types": "./src/client.d.ts",
|
|
17
|
+
"files": [
|
|
18
|
+
"SKILL.md",
|
|
19
|
+
"bin",
|
|
20
|
+
"src"
|
|
21
|
+
],
|
|
5
22
|
"bin": {
|
|
6
|
-
"shopstack": "
|
|
23
|
+
"shopstack": "bin/shopstack"
|
|
7
24
|
},
|
|
8
25
|
"scripts": {
|
|
9
|
-
"
|
|
10
|
-
"
|
|
26
|
+
"shopstack": "node ./bin/shopstack",
|
|
27
|
+
"test": "node --test"
|
|
11
28
|
},
|
|
12
29
|
"engines": {
|
|
13
30
|
"node": ">=18"
|
|
14
31
|
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/jimbo132/shopstack-cli.git"
|
|
35
|
+
},
|
|
15
36
|
"license": "MIT",
|
|
16
37
|
"keywords": [
|
|
17
38
|
"shopstack",
|
|
18
39
|
"cli",
|
|
19
|
-
"
|
|
40
|
+
"checkout",
|
|
41
|
+
"payments"
|
|
20
42
|
]
|
|
21
43
|
}
|