@ancha-labs/cli 0.4.34 → 0.4.35
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/lib/ancha.mjs +6236 -3976
- package/lib/assets/docs/apps.md +4 -0
- package/lib/assets/docs/scenes.md +49 -0
- package/lib/assets/harbor/companion.mjs +4937 -2896
- package/lib/assets/ui/app.js +1 -1
- package/lib/mcp-entry.mjs +199 -82
- package/lib/worker.mjs +5291 -3133
- package/lib/world-server.mjs +4911 -2870
- package/package.json +1 -1
package/lib/assets/docs/apps.md
CHANGED
|
@@ -56,6 +56,8 @@ agent:
|
|
|
56
56
|
|
|
57
57
|
Stripe, Shopify and Clerk webhooks go to an events URL that names `{{service}}`, as here; Stripe and Shopify also deliver to endpoints the app registers through their own API, and Clerk to endpoints added with `clerk.subscribe_webhook`.
|
|
58
58
|
|
|
59
|
+
Stripe webhook endpoints created with `connect: true` receive connected-account events such as `account.updated`, `capability.updated` and `payout.*`, with the account ID in the event's top-level `account` field. Other Stripe endpoints receive platform events, including destination-charge payments, refunds and disputes. Each registered endpoint signs with its own secret. The world's Stripe events URL receives both account and platform events, signed with `STRIPE_WEBHOOK_SECRET`; during a trial, matching registered endpoints take precedence over that URL.
|
|
60
|
+
|
|
59
61
|
Create a Checkout Session with a seeded price, then open its `url` and choose **Pay** or **Decline**. Set `seed.stripe.livemode: false` for these test-card buttons. A successful payment redirects to `success_url`, replacing `{CHECKOUT_SESSION_ID}`, and delivers `checkout.session.completed` alongside the payment and subscription events.
|
|
60
62
|
|
|
61
63
|
A scene can complete the latest open session for an email:
|
|
@@ -71,6 +73,8 @@ world_rules:
|
|
|
71
73
|
|
|
72
74
|
The harness can call the same `stripe.complete_checkout` action with `session` to select an exact session. Use `pm_card_chargeDeclined` to exercise failed payment. Subscriptions, trials and renewals follow the world clock. Change the customer's default payment method with `stripe.set_default_card` (`customer_email` or `customer`, and `card`) to test a failed renewal, recovery or cancellation.
|
|
73
75
|
|
|
76
|
+
Create an account link through `POST /v1/account_links` and open its `url` for the hosted Connect onboarding page. Express and Custom accounts use `type: account_onboarding`; Custom accounts also use `account_update`. Links are single use and expire after 5 minutes on the world clock: an expired or previously visited link redirects to `refresh_url`, where the app can create a fresh link. Submit the page's test identity and bank choice to collect requirements and begin capability review, then return to `return_url`. Leaving through the return link also reaches `return_url`; read the account's requirements and capabilities to determine its state.
|
|
77
|
+
|
|
74
78
|
## Clerk sign-in
|
|
75
79
|
|
|
76
80
|
Run `ancha connect clerk --lang ts` for the SDK configuration. The app receives `CLERK_API_URL`, `CLERK_SECRET_KEY`, `CLERK_PUBLISHABLE_KEY`, `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY`, `CLERK_JWT_KEY` and `CLERK_WEBHOOK_SIGNING_SECRET`. `CLERK_FRONTEND_API_URL`, `CLERK_PROXY_URL` and `NEXT_PUBLIC_CLERK_PROXY_URL` name the same Frontend API. Pass `apiUrl`, `publishableKey`, `jwtKey` and `proxyUrl` to `createClerkClient`; keep the app's `authenticateRequest` and organization checks. `CLERK_JWT_KEY` is the PEM public key for networkless verification. Session tokens last 60 seconds and are dated on the app's own clock: the world's when the app runs with `agent.clock: node`, real time otherwise.
|
|
@@ -230,6 +230,55 @@ checks:
|
|
|
230
230
|
state: { clerk.memberships: { organization: ridgeway-robotics, email: erin.walsh@ridgeway-robotics.example, role: "org:admin", count: 1 } }
|
|
231
231
|
```
|
|
232
232
|
|
|
233
|
+
## Stripe Connect accounts, transfers and payouts
|
|
234
|
+
|
|
235
|
+
Seed Express or Custom sellers in `connected_accounts` with `onboarding: complete`, `incomplete` or `restricted`, a test `bank`, a payout schedule and an optional `balance` in minor units. Account refs work as `$seller_ready` or `$account.seller_ready`. Configure settlement, payout arrival, verification review and the dispute fee under `connect`; the values below are the defaults:
|
|
236
|
+
|
|
237
|
+
```yaml
|
|
238
|
+
seed:
|
|
239
|
+
stripe:
|
|
240
|
+
livemode: false
|
|
241
|
+
account: { name: Market, currency: usd }
|
|
242
|
+
connected_accounts:
|
|
243
|
+
- { ref: seller_ready, type: express, name: Alex Reed, email: alex@market.example, onboarding: complete, bank: success, payouts: manual }
|
|
244
|
+
- { ref: seller_new, type: express, name: Sam Park, email: sam@market.example, onboarding: incomplete, payouts: manual }
|
|
245
|
+
payments:
|
|
246
|
+
- { ref: buyer_payment, amount: 10000, created: -1h }
|
|
247
|
+
connect:
|
|
248
|
+
settlement: { available_after: 2d, payout_arrival: 1d }
|
|
249
|
+
verification: { review: 0s }
|
|
250
|
+
disputes: { fee: 1500 }
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Use `Stripe-Account` (the SDK's `stripeAccount` request option) to select a connected account for balance, balance transaction, payout, event, account and external-account list requests. Card-payment funds move from pending to available after `connect.settlement.available_after` on the world clock; transfers with `source_transaction` share the source charge's availability time. Test banks `no_account`, `account_closed`, `insufficient_funds`, `debit_not_authorized` and `invalid_currency` produce the matching payout failure, return the funds and mark the bank errored; replacing it with `bank: success` enables payouts again.
|
|
254
|
+
|
|
255
|
+
Check account eligibility, transfer and fee totals, payout status and the seller's remaining balance:
|
|
256
|
+
|
|
257
|
+
```yaml
|
|
258
|
+
checks:
|
|
259
|
+
- { id: seller_onboarded, state: { stripe.accounts: { account: $seller_new, charges_enabled: true, payouts_enabled: true, requirements_due: false, count: 1 } } }
|
|
260
|
+
- { id: seller_transfer, state: { stripe.transfers: { destination: $seller_ready, count: 1, amount: 10000, after_start: true } } }
|
|
261
|
+
- { id: platform_fee, state: { stripe.application_fees: { account: $seller_ready, count: 1, amount: 1000, after_start: true } } }
|
|
262
|
+
- { id: seller_paid, state: { stripe.payouts: { account: $seller_ready, status: paid, count: 1, amount: 1000, after_start: true } } }
|
|
263
|
+
- { id: seller_balance, state: { stripe.account_balance: { account: $seller_ready, available: 8000, pending: 0 } } }
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
`stripe.accounts` matches every supplied field, including `email`, `details_submitted`, `capabilities`, `disabled_reason` and `requirements_due`; `count` is exact, otherwise at least one account must match. Transfers and application fees accept a `charge` filter and compare exact counts and summed minor-unit amounts; use `amount_reversed` for transfers and `amount_refunded` for fees. Transfers also accept `transfer_group`. Payouts accept `failure_code`; their `account` selects the owner. `after_start: true` selects transfers, fees or payouts created at or after the attempt starts. `stripe.account_balance` compares `available`, `pending` or both; omitting `account` selects the platform balance.
|
|
267
|
+
|
|
268
|
+
Script onboarding, new requirements, bank replacement and dispute outcomes on the same world clock:
|
|
269
|
+
|
|
270
|
+
```yaml
|
|
271
|
+
world_rules:
|
|
272
|
+
actors:
|
|
273
|
+
- { at: 5s, stripe.complete_onboarding: { account: $seller_new, bank: success } }
|
|
274
|
+
- { at: 1h, stripe.require: { account: $seller_ready, requirements: [individual.verification.document], capabilities: [transfers], deadline: 2h } }
|
|
275
|
+
- { at: 2h, stripe.update_bank: { account: $seller_ready, bank: success } }
|
|
276
|
+
- { at: 3h, stripe.dispute: { payment_intent: $buyer_payment, reason: fraudulent, amount: 10000 } }
|
|
277
|
+
- { at: 4h, stripe.close_dispute: { payment_intent: $buyer_payment, outcome: won } }
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
The three account actions select by `account` or `email`. `stripe.complete_onboarding` collects requirements, sets `details_submitted` and reviews the requested capabilities after `connect.verification.review`. `stripe.require` makes the named capabilities inactive at its deadline, or immediately when no deadline is given; meeting the requirements cancels that deadline. `stripe.update_bank` replaces the payout bank. `stripe.dispute` selects by `charge`, `payment_intent` or the latest succeeded charge for `customer_email`, debiting the platform for the disputed amount plus `connect.disputes.fee`. `stripe.close_dispute` selects by `dispute` or the same payment selectors; `won` reinstates the disputed amount and `lost` closes the dispute. `ancha twins seed stripe --json` includes all five checks and actions.
|
|
281
|
+
|
|
233
282
|
## Zendesk ticket checks
|
|
234
283
|
|
|
235
284
|
Use `zendesk.ticket` to check one ticket by numeric `id` or exact `subject`. All supplied conditions apply to that ticket. A subject identifies exactly one ticket; use its `id` when subjects repeat.
|