@ambasada/village 0.0.0-stage → 0.8.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 CENTYSO (https://centyso.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,57 @@
1
- # Temporary Holding Version
1
+ # @ambasada/village
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The Hack A Ton add-on for Ambasada apps: accept and spend TON in the village, list offerings, run the agent. One
4
+ package: the SDK, the `ambasada village …` CLI commands, the local bank for `ambasada dev`, the template overlay and
5
+ the `ambasada-village` skill. No runtime dependencies.
6
+
7
+ ```sh
8
+ npx ambasada add village # in an Ambasada app
9
+ npm create ambasada@latest my-shop -- --village # a new one
10
+ ```
11
+
12
+ ```ts
13
+ import { village } from "@ambasada/village"; // AMBASADA_API_KEY, AMBASADA_VILLAGE_API_URL (default https://hackaton.ambasada.id)
14
+ export const POST = village.sell("translate", async ({ text, to }) => ({ text: await village.llm(`Translate to ${to}: ${text}`) }));
15
+ ```
16
+
17
+ | | |
18
+ |---|---|
19
+ | `village.sell(offering, handler)` | fetch handler for a paid endpoint: verifies `x-village-receipt` (402 otherwise), answers JSON |
20
+ | `village.verifyReceipt(req, { offering })` | the same check by hand → receipt claims + parsed `input`; fetch `Request` or Node/Express raw body |
21
+ | `village.checkout(input)` / `getCheckout(id)` / `createPaymentLink(…)` | Checkout for people (`POST /v1/checkout/sessions`) |
22
+ | `village.verifyWebhook(req, secret?)` | Standard Webhooks signature (`AMBASADA_WEBHOOK_SECRET`) → `{ id, type, data }` |
23
+ | `village.verifyCheckoutReceipt(token, { session })` | pay.js `village:paid` receipt |
24
+ | `village.buy("company/offering", input, { maxPrice, idempotencyKey, parent })` | Pay through the Gateway |
25
+ | `village.need(name, input, opts)` | buy whatever your agent routed `name` to |
26
+ | `village.llm(prompt)` / `village.llm.chat(req)` | OpenAI-compatible chat, paid in TON |
27
+ | `village.images.generate(req)`, `village.tools.list()` / `.call(id, input)`, `village.files.put(data)` | LLMOK utilities |
28
+ | `village.listings.put(name, def)` / `.list()` | offerings |
29
+ | `village.wallet()`, `village.ledger(since)`, `village.transfer(to, amount)` | money |
30
+ | `village.agent.config/steer/transcript`, `village.market.search(q)` | agent and market (CLI) |
31
+
32
+ `Village extends Ambasada` (`@ambasada/sdk`), so `village.auth`, `village.apps` and `village.store` work too. Errors are
33
+ `VillageError` (the same class as `AmbasadaError`), `ReceiptInvalidError` (402) and `WebhookInvalidError` (400).
34
+ Workers: `createVillage({ env })`. A team key (`sk_live_…`, village app → Developers) works on both hosts; a project
35
+ key from developer.ambasada.dev hosts the app but can't pay or sell.
36
+
37
+ `ambasada.config.ts`: `defineCompany(defineApp({ id, name, product }), { idea, offerings, agent })` (the 0.7
38
+ `defineCompany({ id, name, idea, … })` still works); `offerings.ts`: `export default [offering({ … })]`.
39
+
40
+ ## CLI
41
+
42
+ The package's `"ambasada": { "plugin": "./dist/cli.mjs" }` makes the `ambasada` CLI load it in a project that
43
+ depends on it:
44
+
45
+ ```
46
+ ambasada village wallet | ledger | offerings sync|list | market search "…" | steer "…" | logs --agent
47
+ ambasada village webhook set <url> | test | links create … | dev buy <offering> '{json}'
48
+ ```
49
+
50
+ The 0.7 spellings (`ambasada wallet`, `ambasada dev buy`, `ambasada logs --agent`, …) still work through 1.x, with
51
+ a one-line deprecation. It also puts the bank on `ambasada dev`'s mock (a fake visitor and agent, Checkout, pay.js,
52
+ canned LLM), pushes `agent/` and syncs offerings after `ambasada deploy` / `link`, and adds the overlay
53
+ (templates/village-overlay) on `init --village` / `add village`.
54
+
55
+ `pnpm build` writes `dist/index.js`, `dist/cli.mjs` (overlay and pay.js embedded) and the `.d.ts` files.
56
+
57
+ Built by [CENTYSO](https://centyso.com) for [Ambasada](https://ambasada.id). MIT.