@kaleidorg/mind 0.0.1 → 0.2.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.
- package/dist/capabilities.d.ts +34 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +34 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/context/budget.d.ts +29 -0
- package/dist/context/budget.d.ts.map +1 -0
- package/dist/context/budget.js +36 -0
- package/dist/context/budget.js.map +1 -0
- package/dist/context/builder.d.ts +39 -0
- package/dist/context/builder.d.ts.map +1 -0
- package/dist/context/builder.js +77 -0
- package/dist/context/builder.js.map +1 -0
- package/dist/engine.d.ts +9 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +18 -2
- package/dist/engine.js.map +1 -1
- package/dist/fastpath/fastpath.d.ts +38 -0
- package/dist/fastpath/fastpath.d.ts.map +1 -0
- package/dist/fastpath/fastpath.js +52 -0
- package/dist/fastpath/fastpath.js.map +1 -0
- package/dist/funnel.d.ts +111 -0
- package/dist/funnel.d.ts.map +1 -0
- package/dist/funnel.js +175 -0
- package/dist/funnel.js.map +1 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -1
- package/dist/knowledge/bitcoin-copilot.d.ts +11 -0
- package/dist/knowledge/bitcoin-copilot.d.ts.map +1 -0
- package/dist/knowledge/bitcoin-copilot.js +155 -0
- package/dist/knowledge/bitcoin-copilot.js.map +1 -0
- package/dist/knowledge/merchants.d.ts +24 -0
- package/dist/knowledge/merchants.d.ts.map +1 -0
- package/dist/knowledge/merchants.js +34 -0
- package/dist/knowledge/merchants.js.map +1 -0
- package/dist/knowledge/wallet.d.ts +34 -0
- package/dist/knowledge/wallet.d.ts.map +1 -0
- package/dist/knowledge/wallet.js +63 -0
- package/dist/knowledge/wallet.js.map +1 -0
- package/dist/memory/store.d.ts +34 -0
- package/dist/memory/store.d.ts.map +1 -0
- package/dist/memory/store.js +103 -0
- package/dist/memory/store.js.map +1 -0
- package/dist/memory/tool.d.ts +9 -0
- package/dist/memory/tool.d.ts.map +1 -0
- package/dist/memory/tool.js +70 -0
- package/dist/memory/tool.js.map +1 -0
- package/dist/memory/types.d.ts +56 -0
- package/dist/memory/types.d.ts.map +1 -0
- package/dist/memory/types.js +14 -0
- package/dist/memory/types.js.map +1 -0
- package/dist/rag/retriever.d.ts +30 -0
- package/dist/rag/retriever.d.ts.map +1 -0
- package/dist/rag/retriever.js +72 -0
- package/dist/rag/retriever.js.map +1 -0
- package/dist/rag/tool.d.ts +15 -0
- package/dist/rag/tool.d.ts.map +1 -0
- package/dist/rag/tool.js +42 -0
- package/dist/rag/tool.js.map +1 -0
- package/dist/rag/types.d.ts +44 -0
- package/dist/rag/types.d.ts.map +1 -0
- package/dist/rag/types.js +11 -0
- package/dist/rag/types.js.map +1 -0
- package/dist/rag/vector-store.d.ts +23 -0
- package/dist/rag/vector-store.d.ts.map +1 -0
- package/dist/rag/vector-store.js +72 -0
- package/dist/rag/vector-store.js.map +1 -0
- package/dist/recipe/asset-send.d.ts +15 -0
- package/dist/recipe/asset-send.d.ts.map +1 -0
- package/dist/recipe/asset-send.js +83 -0
- package/dist/recipe/asset-send.js.map +1 -0
- package/dist/recipe/payments.d.ts +15 -0
- package/dist/recipe/payments.d.ts.map +1 -0
- package/dist/recipe/payments.js +119 -0
- package/dist/recipe/payments.js.map +1 -0
- package/dist/recipe/receive.d.ts +14 -0
- package/dist/recipe/receive.d.ts.map +1 -0
- package/dist/recipe/receive.js +109 -0
- package/dist/recipe/receive.js.map +1 -0
- package/dist/recipe/runner.d.ts +42 -0
- package/dist/recipe/runner.d.ts.map +1 -0
- package/dist/recipe/runner.js +94 -0
- package/dist/recipe/runner.js.map +1 -0
- package/dist/recipe/swap.d.ts +16 -0
- package/dist/recipe/swap.d.ts.map +1 -0
- package/dist/recipe/swap.js +73 -0
- package/dist/recipe/swap.js.map +1 -0
- package/dist/recipe/types.d.ts +71 -0
- package/dist/recipe/types.d.ts.map +1 -0
- package/dist/recipe/types.js +13 -0
- package/dist/recipe/types.js.map +1 -0
- package/dist/skills/bundle.d.ts +30 -0
- package/dist/skills/bundle.d.ts.map +1 -0
- package/dist/skills/bundle.js +24 -0
- package/dist/skills/bundle.js.map +1 -0
- package/dist/skills/loader.d.ts +33 -0
- package/dist/skills/loader.d.ts.map +1 -0
- package/dist/skills/loader.js +59 -0
- package/dist/skills/loader.js.map +1 -0
- package/dist/skills/reference-source.d.ts +18 -0
- package/dist/skills/reference-source.d.ts.map +1 -0
- package/dist/skills/reference-source.js +53 -0
- package/dist/skills/reference-source.js.map +1 -0
- package/dist/skills/registry.d.ts +41 -0
- package/dist/skills/registry.d.ts.map +1 -0
- package/dist/skills/registry.js +167 -0
- package/dist/skills/registry.js.map +1 -0
- package/dist/skills/types.d.ts +53 -0
- package/dist/skills/types.d.ts.map +1 -0
- package/dist/skills/types.js +18 -0
- package/dist/skills/types.js.map +1 -0
- package/dist/tools/cli.d.ts +43 -0
- package/dist/tools/cli.d.ts.map +1 -0
- package/dist/tools/cli.js +61 -0
- package/dist/tools/cli.js.map +1 -0
- package/dist/tools/l402.d.ts +47 -0
- package/dist/tools/l402.d.ts.map +1 -0
- package/dist/tools/l402.js +84 -0
- package/dist/tools/l402.js.map +1 -0
- package/dist/tools/mcp.d.ts +3 -2
- package/dist/tools/mcp.d.ts.map +1 -1
- package/dist/tools/mcp.js +3 -2
- package/dist/tools/mcp.js.map +1 -1
- package/dist/wallet/contract.d.ts +57 -0
- package/dist/wallet/contract.d.ts.map +1 -0
- package/dist/wallet/contract.js +113 -0
- package/dist/wallet/contract.js.map +1 -0
- package/package.json +16 -5
- package/scripts/bundle-skills.mjs +84 -0
- package/skills/README.md +74 -0
- package/skills/bitrefill/SKILL.md +66 -0
- package/skills/bitrefill/references/api.md +99 -0
- package/skills/bitrefill/references/browse.md +71 -0
- package/skills/bitrefill/references/capability-matrix.md +115 -0
- package/skills/bitrefill/references/cli-headless-auth.md +133 -0
- package/skills/bitrefill/references/cli.md +237 -0
- package/skills/bitrefill/references/host-openclaw.md +167 -0
- package/skills/bitrefill/references/mcp.md +150 -0
- package/skills/bitrefill/references/safeguards.md +138 -0
- package/skills/bitrefill/references/troubleshooting.md +182 -0
- package/skills/kaleido-trading/SKILL.md +31 -0
- package/skills/kaleido-wallet/SKILL.md +28 -0
- package/src/capabilities.ts +67 -0
- package/src/context/budget.ts +46 -0
- package/src/context/builder.ts +100 -0
- package/src/context/context.test.ts +83 -0
- package/src/engine.test.ts +204 -0
- package/src/engine.ts +27 -2
- package/src/fastpath/fastpath.test.ts +34 -0
- package/src/fastpath/fastpath.ts +70 -0
- package/src/funnel.test.ts +207 -0
- package/src/funnel.ts +260 -0
- package/src/index.ts +102 -0
- package/src/knowledge/bitcoin-copilot.ts +177 -0
- package/src/knowledge/knowledge.test.ts +63 -0
- package/src/knowledge/merchants.ts +49 -0
- package/src/knowledge/wallet.ts +84 -0
- package/src/memory/memory.test.ts +85 -0
- package/src/memory/store.ts +129 -0
- package/src/memory/tool.ts +76 -0
- package/src/memory/types.ts +63 -0
- package/src/rag/rag.test.ts +85 -0
- package/src/rag/retriever.ts +94 -0
- package/src/rag/tool.ts +55 -0
- package/src/rag/types.ts +49 -0
- package/src/rag/vector-store.ts +78 -0
- package/src/recipe/asset-send.ts +79 -0
- package/src/recipe/payments.ts +116 -0
- package/src/recipe/receive.ts +98 -0
- package/src/recipe/recipe.test.ts +193 -0
- package/src/recipe/runner.ts +122 -0
- package/src/recipe/swap.ts +74 -0
- package/src/recipe/types.ts +76 -0
- package/src/skills/bundle.ts +42 -0
- package/src/skills/loader.ts +63 -0
- package/src/skills/reference-source.ts +60 -0
- package/src/skills/registry.ts +183 -0
- package/src/skills/skills.test.ts +191 -0
- package/src/skills/types.ts +55 -0
- package/src/tools/cli.test.ts +53 -0
- package/src/tools/cli.ts +98 -0
- package/src/tools/l402.test.ts +113 -0
- package/src/tools/l402.ts +122 -0
- package/src/tools/mcp.ts +3 -2
- package/src/wallet/contract.test.ts +89 -0
- package/src/wallet/contract.ts +157 -0
- package/dist/providers/qvac.d.ts +0 -89
- package/dist/providers/qvac.d.ts.map +0 -1
- package/dist/providers/qvac.js +0 -150
- package/dist/providers/qvac.js.map +0 -1
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical multi-L2 wallet tool contract — the single source of truth for
|
|
3
|
+
* KaleidoMind's wallet tools (names + JSON schemas + spend flags).
|
|
4
|
+
*
|
|
5
|
+
* Every surface implements THESE EXACT tools, only the transport differs:
|
|
6
|
+
* - mobile → in-process handlers over the WDK adapters (`bindWalletTools`)
|
|
7
|
+
* - desktop → kaleido-mcp (tools namespaced per layer) + a `kaleido` CLI
|
|
8
|
+
* - eval → stub handlers
|
|
9
|
+
*
|
|
10
|
+
* Because the schemas are identical everywhere, skills are portable and the
|
|
11
|
+
* model comparison is honest. Tools are namespaced per layer (`spark_*`,
|
|
12
|
+
* `rln_*`, `arkade_*`, `liquid_*`); cross-cutting router/helpers are unprefixed.
|
|
13
|
+
*
|
|
14
|
+
* Spend tools (move funds) carry `spend: true` → `requiresConfirmation: true`,
|
|
15
|
+
* so the Engine always pauses for the host's confirm gate before executing.
|
|
16
|
+
*
|
|
17
|
+
* Pure data — no deps, RN-safe.
|
|
18
|
+
*/
|
|
19
|
+
import { InProcessToolSource } from '../tools/in-process.js';
|
|
20
|
+
function t(layer, name, description, properties = {}, required = [], spend = false) {
|
|
21
|
+
return {
|
|
22
|
+
layer,
|
|
23
|
+
name,
|
|
24
|
+
description,
|
|
25
|
+
spend,
|
|
26
|
+
requiresConfirmation: spend,
|
|
27
|
+
parameters: { type: 'object', properties, required },
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const sats = { type: 'number', description: 'Amount in satoshis' };
|
|
31
|
+
const asset = { type: 'string', description: "Asset ticker, e.g. 'USDT', 'XAUT', 'BTC'" };
|
|
32
|
+
/** The full contract. Keep descriptions terse — small models read every word. */
|
|
33
|
+
export const WALLET_TOOLS = [
|
|
34
|
+
// ── Spark ──────────────────────────────────────────────────────────────
|
|
35
|
+
t('spark', 'spark_get_balance', 'Get the Spark wallet BTC balance.'),
|
|
36
|
+
t('spark', 'spark_get_address', 'Get a Spark deposit address to receive BTC.'),
|
|
37
|
+
t('spark', 'spark_create_invoice', 'Create a Spark Lightning invoice to receive BTC.', { amount_sats: sats }),
|
|
38
|
+
t('spark', 'spark_send', 'Send BTC from Spark to an address or invoice.', { amount_sats: sats, to: { type: 'string', description: 'Address or invoice' } }, ['amount_sats', 'to'], true),
|
|
39
|
+
// ── RLN / RGB ──────────────────────────────────────────────────────────
|
|
40
|
+
t('rln', 'rln_get_balances', 'Get RLN node balances (BTC + RGB assets).'),
|
|
41
|
+
t('rln', 'rln_get_node_info', 'Get RLN node status and sync state.'),
|
|
42
|
+
t('rln', 'rln_list_channels', 'List the RLN node Lightning channels.'),
|
|
43
|
+
t('rln', 'rln_create_ln_invoice', 'Create a Lightning (BTC) invoice on the RLN node.', { amount_sats: sats }),
|
|
44
|
+
t('rln', 'rln_create_rgb_invoice', 'Create an RGB asset invoice to receive an asset (e.g. USDT).', { asset, amount: { type: 'number', description: 'Asset amount' } }, ['asset', 'amount']),
|
|
45
|
+
t('rln', 'rln_pay_invoice', 'Pay a Lightning invoice from the RLN node.', { invoice: { type: 'string' } }, ['invoice'], true),
|
|
46
|
+
t('rln', 'rln_send_asset', 'Send an RGB asset (e.g. USDT) to a recipient.', { asset, amount: { type: 'number' }, to: { type: 'string' } }, ['asset', 'amount', 'to'], true),
|
|
47
|
+
// ── Arkade ─────────────────────────────────────────────────────────────
|
|
48
|
+
t('arkade', 'arkade_get_balance', 'Get the Arkade wallet balance.'),
|
|
49
|
+
t('arkade', 'arkade_get_address', 'Get an Arkade address to receive funds.'),
|
|
50
|
+
t('arkade', 'arkade_send', 'Send BTC from Arkade to a recipient.', { amount_sats: sats, to: { type: 'string' } }, ['amount_sats', 'to'], true),
|
|
51
|
+
// ── Liquid (later) ─────────────────────────────────────────────────────
|
|
52
|
+
t('liquid', 'liquid_get_balance', 'Get the Liquid wallet balance (L-BTC + assets).'),
|
|
53
|
+
t('liquid', 'liquid_create_invoice', 'Create a Liquid invoice/address to receive (L-BTC or L-USDt).', { asset, amount: { type: 'number' } }),
|
|
54
|
+
t('liquid', 'liquid_send', 'Send a Liquid asset (L-BTC or L-USDt) to a recipient.', { asset, amount: { type: 'number' }, to: { type: 'string' } }, ['asset', 'amount', 'to'], true),
|
|
55
|
+
// ── Core: router + helpers ─────────────────────────────────────────────
|
|
56
|
+
t('core', 'get_balances', 'Get balances across all layers (or one layer).', { layer: { type: 'string', enum: ['spark', 'rln', 'arkade', 'liquid'], description: 'Optional: a single layer' } }),
|
|
57
|
+
t('core', 'resolve_contact', 'Resolve a contact name to a Lightning address / Nostr / preferred rail.', { name: { type: 'string', description: 'Contact name, e.g. "bob"' } }, ['name']),
|
|
58
|
+
t('core', 'get_price', 'Get the current price of an asset, optionally in a fiat currency.', { asset, fiat: { type: 'string', description: "Fiat code, e.g. 'EUR', 'USD'" } }),
|
|
59
|
+
t('core', 'fiat_to_sats', 'Convert a fiat amount to satoshis at the current rate.', { amount: { type: 'number' }, currency: { type: 'string', description: "Fiat code, e.g. 'EUR'" } }, ['amount', 'currency']),
|
|
60
|
+
t('core', 'get_swap_quote', 'Quote a swap between two assets.', { from_asset: asset, to_asset: asset, amount: { type: 'number' } }, ['from_asset', 'to_asset', 'amount']),
|
|
61
|
+
t('core', 'execute_swap', 'Execute a previously quoted swap.', { quote_id: { type: 'string' }, from_asset: asset, to_asset: asset, amount: { type: 'number' } }, [], true),
|
|
62
|
+
// The high-level entry a skill prefers — picks the rail for the asset, or uses `layer`.
|
|
63
|
+
t('core', 'send_payment', 'Send a payment, automatically choosing the best layer for the asset (or use `layer`).', { asset, amount_sats: sats, to: { type: 'string', description: 'Contact, address, or invoice' }, layer: { type: 'string', enum: ['spark', 'rln', 'arkade', 'liquid'] } }, ['to'], true),
|
|
64
|
+
// High-level receive — picks the right invoice/address tool for the asset/layer.
|
|
65
|
+
t('core', 'create_invoice', 'Create an invoice or address to receive funds, choosing the rail for the asset (or use `layer`). Omit amount for an any-amount invoice.', { asset, amount: { type: 'number', description: 'Amount (sats for BTC, asset units otherwise) — optional' }, layer: { type: 'string', enum: ['spark', 'rln', 'arkade', 'liquid'] } }),
|
|
66
|
+
];
|
|
67
|
+
// ── Selectors ───────────────────────────────────────────────────────────────
|
|
68
|
+
export const WALLET_LAYERS = ['spark', 'rln', 'arkade', 'liquid', 'core'];
|
|
69
|
+
/** Names of all spend (fund-moving) tools — these are confirmation-gated. */
|
|
70
|
+
export const SPEND_TOOLS = new Set(WALLET_TOOLS.filter((x) => x.spend).map((x) => x.name));
|
|
71
|
+
export function isSpendTool(name) {
|
|
72
|
+
return SPEND_TOOLS.has(name);
|
|
73
|
+
}
|
|
74
|
+
export function getWalletTool(name) {
|
|
75
|
+
return WALLET_TOOLS.find((x) => x.name === name);
|
|
76
|
+
}
|
|
77
|
+
/** Pick the contract tools for the given layers (core helpers included by default). */
|
|
78
|
+
export function walletTools(opts = {}) {
|
|
79
|
+
const layers = new Set(opts.layers ?? ['spark', 'rln', 'arkade', 'liquid']);
|
|
80
|
+
if (opts.includeCore !== false)
|
|
81
|
+
layers.add('core');
|
|
82
|
+
return WALLET_TOOLS.filter((x) => layers.has(x.layer));
|
|
83
|
+
}
|
|
84
|
+
/** Strip to plain ToolDefs (drop the layer/spend metadata). */
|
|
85
|
+
export function toToolDefs(tools) {
|
|
86
|
+
return tools.map(({ name, description, parameters, requiresConfirmation }) => ({ name, description, parameters, requiresConfirmation }));
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Bind contract tools to in-process handlers → an InProcessToolSource. The
|
|
90
|
+
* mobile (and eval) binding: pass a map of `{ toolName: handler }` and you get a
|
|
91
|
+
* ToolSource implementing the canonical schemas with spend flags preserved.
|
|
92
|
+
*/
|
|
93
|
+
export function bindWalletTools(handlers, opts = {}) {
|
|
94
|
+
const tools = walletTools(opts);
|
|
95
|
+
const bound = [];
|
|
96
|
+
for (const def of tools) {
|
|
97
|
+
const handler = handlers[def.name];
|
|
98
|
+
if (!handler) {
|
|
99
|
+
if (opts.allowMissing)
|
|
100
|
+
continue;
|
|
101
|
+
throw new Error(`bindWalletTools: no handler for "${def.name}"`);
|
|
102
|
+
}
|
|
103
|
+
bound.push({
|
|
104
|
+
name: def.name,
|
|
105
|
+
description: def.description,
|
|
106
|
+
parameters: def.parameters,
|
|
107
|
+
requiresConfirmation: def.requiresConfirmation,
|
|
108
|
+
handler,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return new InProcessToolSource(opts.id ?? 'wallet', bound);
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/wallet/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAc7D,SAAS,CAAC,CACR,KAAkB,EAClB,IAAY,EACZ,WAAmB,EACnB,aAAoB,EAAE,EACtB,WAAqB,EAAE,EACvB,KAAK,GAAG,KAAK;IAEb,OAAO;QACL,KAAK;QACL,IAAI;QACJ,WAAW;QACX,KAAK;QACL,oBAAoB,EAAE,KAAK;QAC3B,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE;KACrD,CAAC;AACJ,CAAC;AAED,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,oBAAoB,EAAW,CAAC;AAC5E,MAAM,KAAK,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,0CAA0C,EAAW,CAAC;AAEnG,iFAAiF;AACjF,MAAM,CAAC,MAAM,YAAY,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
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaleidorg/mind",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Local-first reasoning + function-calling engine for KaleidoSwap. QVAC-powered.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -16,21 +16,31 @@
|
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
17
|
"exports": {
|
|
18
18
|
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
19
20
|
"import": "./dist/index.js",
|
|
20
|
-
"
|
|
21
|
+
"default": "./dist/index.js"
|
|
21
22
|
},
|
|
22
23
|
"./mcp": {
|
|
24
|
+
"types": "./dist/tools/mcp.d.ts",
|
|
23
25
|
"import": "./dist/tools/mcp.js",
|
|
24
|
-
"
|
|
26
|
+
"default": "./dist/tools/mcp.js"
|
|
27
|
+
},
|
|
28
|
+
"./skills": {
|
|
29
|
+
"types": "./dist/skills/loader.d.ts",
|
|
30
|
+
"import": "./dist/skills/loader.js",
|
|
31
|
+
"default": "./dist/skills/loader.js"
|
|
25
32
|
},
|
|
26
33
|
"./logger": {
|
|
34
|
+
"types": "./dist/logger.d.ts",
|
|
27
35
|
"import": "./dist/logger.js",
|
|
28
|
-
"
|
|
36
|
+
"default": "./dist/logger.js"
|
|
29
37
|
}
|
|
30
38
|
},
|
|
31
39
|
"files": [
|
|
32
40
|
"dist",
|
|
33
41
|
"src",
|
|
42
|
+
"skills",
|
|
43
|
+
"scripts",
|
|
34
44
|
"README.md",
|
|
35
45
|
"LICENSE"
|
|
36
46
|
],
|
|
@@ -38,7 +48,8 @@
|
|
|
38
48
|
"build": "tsc",
|
|
39
49
|
"typecheck": "tsc --noEmit",
|
|
40
50
|
"test": "vitest run",
|
|
41
|
-
"lint": "eslint src"
|
|
51
|
+
"lint": "eslint src",
|
|
52
|
+
"bundle-skills": "node scripts/bundle-skills.mjs"
|
|
42
53
|
},
|
|
43
54
|
"devDependencies": {
|
|
44
55
|
"vitest": "^1.6.0"
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* bundle-skills — serialise one or more skill directories into a SkillBundle
|
|
4
|
+
* JSON file, so hosts without a filesystem (React Native) can load the same
|
|
5
|
+
* SKILL.md skills the Node fs loader reads.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* node bundle-skills.mjs --out <file.json> <skills-dir> [<more-dirs>...]
|
|
9
|
+
*
|
|
10
|
+
* Example (mobile: ship the packaged bitrefill skill + the app's own skills):
|
|
11
|
+
* node bundle-skills.mjs --out ./skills.bundle.json \
|
|
12
|
+
* node_modules/@kaleidorg/mind/skills/bitrefill ./skills
|
|
13
|
+
*
|
|
14
|
+
* Each positional arg may be either a single skill folder (contains SKILL.md)
|
|
15
|
+
* or a parent folder of skill folders. References under <skill>/references/*.md
|
|
16
|
+
* are inlined. The output matches the `SkillBundle` type in src/skills/bundle.ts.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { readdirSync, readFileSync, existsSync, writeFileSync, statSync } from 'node:fs';
|
|
20
|
+
import { join, basename } from 'node:path';
|
|
21
|
+
|
|
22
|
+
function parseArgs(argv) {
|
|
23
|
+
const dirs = [];
|
|
24
|
+
let out = null;
|
|
25
|
+
for (let i = 0; i < argv.length; i++) {
|
|
26
|
+
if (argv[i] === '--out') out = argv[++i];
|
|
27
|
+
else dirs.push(argv[i]);
|
|
28
|
+
}
|
|
29
|
+
if (!out || dirs.length === 0) {
|
|
30
|
+
console.error('usage: bundle-skills.mjs --out <file.json> <skills-dir> [<more-dirs>...]');
|
|
31
|
+
process.exit(2);
|
|
32
|
+
}
|
|
33
|
+
return { out, dirs };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function readSkillFolder(dir) {
|
|
37
|
+
const md = join(dir, 'SKILL.md');
|
|
38
|
+
if (!existsSync(md)) return null;
|
|
39
|
+
const refDir = join(dir, 'references');
|
|
40
|
+
const references = existsSync(refDir)
|
|
41
|
+
? readdirSync(refDir)
|
|
42
|
+
.filter((f) => f.endsWith('.md'))
|
|
43
|
+
.sort()
|
|
44
|
+
.map((name) => ({ name, content: readFileSync(join(refDir, name), 'utf8') }))
|
|
45
|
+
: [];
|
|
46
|
+
return {
|
|
47
|
+
dir: basename(dir),
|
|
48
|
+
markdown: readFileSync(md, 'utf8'),
|
|
49
|
+
...(references.length ? { references } : {}),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Expand a path into skill folders: itself if it has a SKILL.md, else its children. */
|
|
54
|
+
function collectSkillDirs(path) {
|
|
55
|
+
if (!existsSync(path)) {
|
|
56
|
+
console.error(`bundle-skills: path not found: ${path}`);
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
if (existsSync(join(path, 'SKILL.md'))) return [path];
|
|
60
|
+
return readdirSync(path)
|
|
61
|
+
.map((e) => join(path, e))
|
|
62
|
+
.filter((p) => statSync(p).isDirectory() && existsSync(join(p, 'SKILL.md')))
|
|
63
|
+
.sort();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const { out, dirs } = parseArgs(process.argv.slice(2));
|
|
67
|
+
const seen = new Set();
|
|
68
|
+
const skills = [];
|
|
69
|
+
for (const arg of dirs) {
|
|
70
|
+
for (const skillDir of collectSkillDirs(arg)) {
|
|
71
|
+
const s = readSkillFolder(skillDir);
|
|
72
|
+
if (!s) continue;
|
|
73
|
+
if (seen.has(s.dir)) {
|
|
74
|
+
console.error(`bundle-skills: duplicate skill folder "${s.dir}" — skipping ${skillDir}`);
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
seen.add(s.dir);
|
|
78
|
+
skills.push(s);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const bundle = { version: 1, skills };
|
|
83
|
+
writeFileSync(out, JSON.stringify(bundle, null, 2));
|
|
84
|
+
console.error(`bundle-skills: wrote ${skills.length} skill(s) → ${out} [${skills.map((s) => s.dir).join(', ')}]`);
|
package/skills/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Skills
|
|
2
|
+
|
|
3
|
+
Claude-style **Agent Skills** the KaleidoMind brain (QVAC) loads at runtime.
|
|
4
|
+
Skills are the top layer of tool use: entering one injects a focused playbook
|
|
5
|
+
into the system prompt and (optionally) scopes the model to a subset of tools —
|
|
6
|
+
*progressive disclosure*, so a small local model never sees every tool or
|
|
7
|
+
instruction at once.
|
|
8
|
+
|
|
9
|
+
Each subfolder is a skill: a `SKILL.md` (YAML frontmatter + playbook) plus
|
|
10
|
+
optional `references/*.md` files loaded on demand. The format is the Anthropic
|
|
11
|
+
Agent Skills spec, so skills published for Claude (e.g. `bitrefill/agents`) run
|
|
12
|
+
the QVAC brain unchanged.
|
|
13
|
+
|
|
14
|
+
## Frontmatter
|
|
15
|
+
|
|
16
|
+
```yaml
|
|
17
|
+
---
|
|
18
|
+
name: my-skill # required — stable id
|
|
19
|
+
description: When to use this… # required — selection signal (embed triggers here)
|
|
20
|
+
tools: tool_a, tool_b # optional — scope the model to these tools
|
|
21
|
+
triggers: foo, bar # optional — keywords that boost selection
|
|
22
|
+
metadata: # optional — anything else (author, version, …)
|
|
23
|
+
author: kaleidoswap
|
|
24
|
+
---
|
|
25
|
+
# Playbook
|
|
26
|
+
Markdown instructions injected into the system prompt when this skill is active.
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Loading (same skills, every surface)
|
|
30
|
+
|
|
31
|
+
**Node** (desktop sidecar, kaleidoagent) — read folders from disk:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { loadSkillsDir, packagedSkillsDir } from '@kaleidorg/mind/skills';
|
|
35
|
+
import { SkillRegistry, createSkillReferenceToolSource } from '@kaleidorg/mind';
|
|
36
|
+
|
|
37
|
+
const skills = loadSkillsDir(packagedSkillsDir()); // these shipped skills
|
|
38
|
+
const registry = new SkillRegistry(skills);
|
|
39
|
+
const refSource = createSkillReferenceToolSource(registry); // read_skill_reference
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**React Native** (rate) — no filesystem, so bundle the folders to JSON at build
|
|
43
|
+
time and rehydrate:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
node node_modules/@kaleidorg/mind/scripts/bundle-skills.mjs \
|
|
47
|
+
--out skills.bundle.json ./skills
|
|
48
|
+
```
|
|
49
|
+
```ts
|
|
50
|
+
import { SkillRegistry, skillsFromBundle } from '@kaleidorg/mind';
|
|
51
|
+
import bundle from './skills.bundle.json';
|
|
52
|
+
const registry = new SkillRegistry(skillsFromBundle(bundle));
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Then per query: `const skill = registry.select(query)` →
|
|
56
|
+
`registry.compose(systemPrompt, skill)` → pass `{ system, allowedTools }` to
|
|
57
|
+
`engine.runAgentic(...)`.
|
|
58
|
+
|
|
59
|
+
## Adding a skill
|
|
60
|
+
|
|
61
|
+
1. Create `skills/<name>/SKILL.md` (and `references/*.md` if needed).
|
|
62
|
+
2. Node hosts pick it up automatically. For mobile, re-run the bundler.
|
|
63
|
+
3. That's it — no code changes. The selector routes to it by description/triggers.
|
|
64
|
+
|
|
65
|
+
## Shipped skills
|
|
66
|
+
|
|
67
|
+
- **bitrefill/** — official Bitrefill agent skill (gift cards, mobile top-ups,
|
|
68
|
+
eSIMs; pay in crypto / Lightning / USDC-x402 / balance). Capability-routes to
|
|
69
|
+
the best channel; preferred purchase path is the Bitrefill remote MCP at
|
|
70
|
+
`https://api.bitrefill.com/mcp` (needs `BITREFILL_API_KEY` — anonymous = 401).
|
|
71
|
+
Source: https://github.com/bitrefill/agents (MIT). Update with
|
|
72
|
+
`npx skills add bitrefill/agents` or re-vendor the folder.
|
|
73
|
+
- **kaleido-wallet/** — balances, receive, pay, channels over `kaleido-mcp`.
|
|
74
|
+
- **kaleido-trading/** — prices, quotes, atomic swaps, LSP channels.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bitrefill
|
|
3
|
+
description: "Buy or browse Bitrefill — 1,500+ gift cards, mobile top-ups, and eSIMs across 180+ countries, payable in crypto, Lightning, USDC via x402, or pre-funded account balance. Routes the host agent to its highest-fidelity channel (residential browser, MCP server, npm CLI, or REST API) based on detected runtime capabilities, with a dedicated OpenClaw integration guide for chat-channel scenarios. Triggers when the user mentions Bitrefill, gift cards, mobile top-up, eSIM data plan, refilling a phone, or asks to pay or check out with crypto, Lightning, USDC, or x402."
|
|
4
|
+
compatibility: "Detects host capabilities at runtime. Paths require: browse — residential-IP browser; MCP — MCP-capable client + Bitrefill OAuth/API key; CLI — Node.js >=18 + shell + npm + @bitrefill/cli >=0.3.0 (headless login/verify via magic link); API — outbound HTTP + Bitrefill API key (Personal) or API ID/Secret (Business/Affiliate). OpenClaw host gets a dedicated guide."
|
|
5
|
+
metadata:
|
|
6
|
+
author: bitrefill
|
|
7
|
+
version: "2.1.5"
|
|
8
|
+
homepage: "https://www.bitrefill.com"
|
|
9
|
+
docs: "https://docs.bitrefill.com"
|
|
10
|
+
repository: "https://github.com/bitrefill/cli"
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Bitrefill
|
|
14
|
+
|
|
15
|
+
Bitrefill sells digital goods (gift cards, mobile top-ups, eSIMs) across 180+ countries and 1,500+ brands. Pay with crypto, Lightning, USDC via x402, or pre-funded account balance. Codes deliver instantly after payment confirms.
|
|
16
|
+
|
|
17
|
+
This skill **routes by capability, not by use case**. Same intent ("buy a Steam card") plays out differently across hosts. Pick a path below based on what your runtime can do.
|
|
18
|
+
|
|
19
|
+
## Pick a path
|
|
20
|
+
|
|
21
|
+
Walk these checks **in order**. First match wins.
|
|
22
|
+
|
|
23
|
+
1. **Inside OpenClaw?** Check for `~/.openclaw/openclaw.json`, `~/.openclaw/skills/`, or `openclaw` on PATH. If yes → read [host-openclaw.md](references/host-openclaw.md) first. **Default purchase path: guest CLI via `exec`** (no auth). Sign in for `balance`/cashback. OpenClaw also supports MCP, API, Browse, chat-channel scenarios (Telegram, cron, mobile camera).
|
|
24
|
+
|
|
25
|
+
2. **Browse-only intent (no purchase)?** If the user only wants to explore, compare prices, or learn how products work:
|
|
26
|
+
- Have a residential-IP browser (ChatGPT Atlas, Cursor browser tool, Claude/Playwright Chrome extension, OpenClaw on user host)? → [browse.md](references/browse.md).
|
|
27
|
+
- Datacenter egress only (ChatGPT web/Agent, Gemini consumer, Jules)? `www.bitrefill.com` returns **403 Cloudflare** to datacenter IPs. Use [mcp.md](references/mcp.md) `search-products` / `product-details` instead — they return the same catalog without scraping.
|
|
28
|
+
|
|
29
|
+
3. **MCP supported?** Bitrefill ships a remote HTTP/SSE MCP at `https://api.bitrefill.com/mcp`. Works on Claude.ai (Pro+), Cowork, Claude Desktop, Claude Code, ChatGPT (Plus+), Atlas, Codex CLI, Gemini CLI, Cursor, OpenCode, OpenClaw. **Highest-fidelity purchase channel — typed tool calls, OAuth or API key, no shell needed.** → [mcp.md](references/mcp.md).
|
|
30
|
+
|
|
31
|
+
4. **Shell + `npm install` available?** CLI ≥ 0.3.0: **guest checkout first** (no auth — `buy-products --email` + crypto). Sign in for `balance`, cashback, order history. → [cli.md](references/cli.md). Headless sign-in → [cli-headless-auth.md](references/cli-headless-auth.md).
|
|
32
|
+
|
|
33
|
+
5. **Outbound HTTP from agent loop?** Anywhere shell exists, plus Claude Code `WebFetch`. Last resort — verbose, no typed validation. → [api.md](references/api.md).
|
|
34
|
+
|
|
35
|
+
6. **None of the above** (e.g. Gemini consumer free tier): give the user a `bitrefill.com` link and stop.
|
|
36
|
+
|
|
37
|
+
Don't know which host you're in? Read [capability-matrix.md](references/capability-matrix.md) — per-client cheat sheet maps every leading agent product to its viable paths.
|
|
38
|
+
|
|
39
|
+
## Top spending safeguards (read full list before any purchase)
|
|
40
|
+
|
|
41
|
+
This skill enables **real-money transactions**. Codes deliver instantly and digital goods are non-refundable per EU consumer rights.
|
|
42
|
+
|
|
43
|
+
- **Confirm before buying.** Present product, denomination, price, payment method. Wait for explicit user approval. Autonomous purchasing only when user opts in for the current session.
|
|
44
|
+
- **Treat codes as cash.** Never paste in group chats or public channels. Prefer in-memory storage over plain-text logs. Advise user to redeem ASAP.
|
|
45
|
+
- **Use a dedicated, low-balance account.** Never give the agent access to high-balance accounts or crypto wallet seeds. This skill is **not a wallet**.
|
|
46
|
+
- **Log every purchase.** `invoice_id`, product, amount, payment method.
|
|
47
|
+
|
|
48
|
+
Full safeguards + per-host hardening (OpenClaw exec-approvals, Cursor auto-approve, Codex sandbox, Claude Code allowlist) → [safeguards.md](references/safeguards.md).
|
|
49
|
+
|
|
50
|
+
## References
|
|
51
|
+
|
|
52
|
+
| File | Use when |
|
|
53
|
+
|------|----------|
|
|
54
|
+
| [browse.md](references/browse.md) | Agent has residential-IP browser; user wants to explore |
|
|
55
|
+
| [mcp.md](references/mcp.md) | MCP-capable host; preferred purchase path |
|
|
56
|
+
| [cli.md](references/cli.md) | Shell + npm; guest checkout or signed-in CLI ≥ 0.3.0 |
|
|
57
|
+
| [cli-headless-auth.md](references/cli-headless-auth.md) | AgentMail or equivalent inbox + magic-link auth for headless agents |
|
|
58
|
+
| [api.md](references/api.md) | HTTP-only runtime; Personal / Business / Affiliate REST tiers |
|
|
59
|
+
| [host-openclaw.md](references/host-openclaw.md) | OpenClaw Gateway — guest CLI via `exec` preferred |
|
|
60
|
+
| [capability-matrix.md](references/capability-matrix.md) | Per-client viable paths cheat sheet |
|
|
61
|
+
| [safeguards.md](references/safeguards.md) | Spending policy + per-host hardening |
|
|
62
|
+
| [troubleshooting.md](references/troubleshooting.md) | Common errors across all paths |
|
|
63
|
+
|
|
64
|
+
## Source of truth
|
|
65
|
+
|
|
66
|
+
Skill summarizes and routes. For exhaustive enums (countries, payment methods, full endpoint list), follow link-outs to <https://docs.bitrefill.com>.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Path: REST API
|
|
2
|
+
|
|
3
|
+
Use when: outbound HTTP available but no MCP and no shell. Last resort — verbose, no typed validation. Examples below use `curl` but any HTTP client works.
|
|
4
|
+
|
|
5
|
+
Base URL: `https://api.bitrefill.com/v2`
|
|
6
|
+
|
|
7
|
+
## Three tiers
|
|
8
|
+
|
|
9
|
+
| Tier | Auth | Use case |
|
|
10
|
+
|------|------|----------|
|
|
11
|
+
| Personal | Bearer token | Personal projects, agent automation |
|
|
12
|
+
| Business | Basic auth (`API_ID:API_SECRET`) | Platforms, resellers, BRGC batches, deposits, test products |
|
|
13
|
+
| Affiliate | Basic auth | Same as Business + commission tracking, results filtered by `referrer_id` |
|
|
14
|
+
|
|
15
|
+
## Personal API (agent default)
|
|
16
|
+
|
|
17
|
+
Get key: <https://www.bitrefill.com/account/developers>.
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
export BITREFILL_API_KEY=YOUR_API_KEY
|
|
21
|
+
H="Authorization: Bearer $BITREFILL_API_KEY"
|
|
22
|
+
|
|
23
|
+
# 1. Ping
|
|
24
|
+
curl -H "$H" https://api.bitrefill.com/v2/ping
|
|
25
|
+
# → {"data":{"message":"pong"}}
|
|
26
|
+
|
|
27
|
+
# 2. Balance
|
|
28
|
+
curl -H "$H" https://api.bitrefill.com/v2/accounts/balance
|
|
29
|
+
|
|
30
|
+
# 3. Search
|
|
31
|
+
curl -H "$H" "https://api.bitrefill.com/v2/products/search?q=amazon"
|
|
32
|
+
|
|
33
|
+
# 4. Product details
|
|
34
|
+
curl -H "$H" https://api.bitrefill.com/v2/products/amazon-us
|
|
35
|
+
|
|
36
|
+
# 5. Buy (balance, instant)
|
|
37
|
+
curl -X POST -H "$H" -H "Content-Type: application/json" \
|
|
38
|
+
-d '{
|
|
39
|
+
"products": [{"product_id":"amazon-us","package_id":"amazon-us<&>50","quantity":1}],
|
|
40
|
+
"payment_method": "balance",
|
|
41
|
+
"auto_pay": true
|
|
42
|
+
}' \
|
|
43
|
+
https://api.bitrefill.com/v2/invoices
|
|
44
|
+
|
|
45
|
+
# 6. Order / redemption
|
|
46
|
+
curl -H "$H" https://api.bitrefill.com/v2/orders/{order_id}
|
|
47
|
+
# → data.redemption_info.code, .link, .pin, .instructions
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
For crypto: omit `auto_pay`, set `payment_method: "bitcoin"|"lightning"|"usdc_base"|...`, include `refund_address` for crypto methods, then poll `GET /invoices/{id}` until `status: "complete"`.
|
|
51
|
+
|
|
52
|
+
## Business API
|
|
53
|
+
|
|
54
|
+
Apply: <https://www.bitrefill.com/integrate>.
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
TOKEN=$(printf "%s:%s" "$BITREFILL_API_ID" "$BITREFILL_API_SECRET" | base64)
|
|
58
|
+
H="Authorization: Basic $TOKEN"
|
|
59
|
+
|
|
60
|
+
curl -H "$H" https://api.bitrefill.com/v2/ping
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Adds: BRGC (Bitrefill Reusable Gift Card) batches, account deposits via crypto, full product catalog including test products. Same endpoints + `POST /brgc-batches`, `POST /accounts/deposit`.
|
|
64
|
+
|
|
65
|
+
## Affiliate API
|
|
66
|
+
|
|
67
|
+
Apply: <https://www.bitrefill.com/affiliate>. Same auth as Business. Adds `GET /commissions` with `after`/`before` date filters. Order/invoice queries return data filtered by `referrer_id` instead of `user_id`.
|
|
68
|
+
|
|
69
|
+
## Key endpoints
|
|
70
|
+
|
|
71
|
+
- `GET /ping` — health check (1 req / 3 s)
|
|
72
|
+
- `GET /accounts/balance` — current balance
|
|
73
|
+
- `GET /products` — paginated catalog (cache locally, refresh daily; 1000 product req/hr quota shared with search)
|
|
74
|
+
- `GET /products/search?q=...` — keyword search
|
|
75
|
+
- `GET /products/{id}` — product details with `packages` array
|
|
76
|
+
- `POST /invoices` — create invoice (max 20 products)
|
|
77
|
+
- `POST /invoices/{id}/pay` — pay unpaid balance invoice
|
|
78
|
+
- `GET /invoices/{id}` — status
|
|
79
|
+
- `GET /orders/{id}` — redemption info
|
|
80
|
+
- `POST /esims` — create eSIM invoice (or top-up existing via `esim_id`)
|
|
81
|
+
- `GET /esims` / `GET /esims/{id}` — list / get user eSIMs
|
|
82
|
+
|
|
83
|
+
Webhooks: `webhook_url` field on invoice creation → notification when delivered.
|
|
84
|
+
|
|
85
|
+
## Test products
|
|
86
|
+
|
|
87
|
+
Business/Affiliate only. No money charged. Examples: `test-gift-card-code`, etc. Full list: <https://docs.bitrefill.com/docs/test-products>.
|
|
88
|
+
|
|
89
|
+
## Rate limits
|
|
90
|
+
|
|
91
|
+
Most endpoints 60 req / 10 min. `/products` and `/products/search` 60 req/min + 1000 product req/hr quota. `/ping` 1 req / 3 s. Full table: <https://docs.bitrefill.com/docs/rate-limits>.
|
|
92
|
+
|
|
93
|
+
## Source of truth
|
|
94
|
+
|
|
95
|
+
- <https://docs.bitrefill.com/docs/api-overview> — tier comparison + auth
|
|
96
|
+
- <https://docs.bitrefill.com/docs/quickstart-2> — 6-step purchase flow
|
|
97
|
+
- <https://docs.bitrefill.com/reference> — full endpoint catalog
|
|
98
|
+
- <https://docs.bitrefill.com/docs/error-codes> — error codes
|
|
99
|
+
- <https://docs.bitrefill.com/docs/webhooks> — webhook payload spec
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Path: Browse the Website
|
|
2
|
+
|
|
3
|
+
Use when: user wants to **explore** Bitrefill (compare prices, learn product types, check denominations, see country availability) AND your runtime has a **residential-IP browser**. Browse-only by default — for purchases prefer [mcp.md](mcp.md).
|
|
4
|
+
|
|
5
|
+
## Hard requirement: residential IP
|
|
6
|
+
|
|
7
|
+
`www.bitrefill.com` sits behind Cloudflare. **Datacenter egress = 403.** Do NOT use Firecrawl, raw `fetch`, `curl`, or any scraping API.
|
|
8
|
+
|
|
9
|
+
Viable runtimes:
|
|
10
|
+
|
|
11
|
+
- **ChatGPT Atlas** — built-in residential Chromium.
|
|
12
|
+
- **Cursor** — built-in browser tool runs from user's machine.
|
|
13
|
+
- **Claude Code / Desktop / Cowork + Claude-for-Chrome** extension drives local Chrome.
|
|
14
|
+
- **Any host + Playwright/Chrome MCP** running on user's machine.
|
|
15
|
+
- **OpenClaw Gateway on user's host** — `browser` tool uses host IP. (See [host-openclaw.md](host-openclaw.md).)
|
|
16
|
+
|
|
17
|
+
Not viable: ChatGPT web/Agent (OpenAI datacenter), Gemini consumer (Google datacenter), Jules (Google VM), any cloud sandbox without residential proxy.
|
|
18
|
+
|
|
19
|
+
## URL patterns
|
|
20
|
+
|
|
21
|
+
First path segment = **country** (Alpha-2 lowercase). Second = **language**.
|
|
22
|
+
|
|
23
|
+
- Gift cards listing: `https://www.bitrefill.com/{country}/{lang}/gift-cards/`
|
|
24
|
+
- Gift card category: `https://www.bitrefill.com/{country}/{lang}/gift-cards/{category-slug}/` (e.g. `/us/en/gift-cards/food/`)
|
|
25
|
+
- Gift card product: `https://www.bitrefill.com/{country}/{lang}/gift-cards/{product-slug}/`
|
|
26
|
+
- Direct search: `https://www.bitrefill.com/{country}/{lang}/gift-cards/?q={query}` (covers gift cards + top-ups + eSIMs; in-country prioritized)
|
|
27
|
+
- Mobile top-ups: `https://www.bitrefill.com/refill/`
|
|
28
|
+
- eSIMs (locale): `https://www.bitrefill.com/{country}/{lang}/esims/`
|
|
29
|
+
- eSIMs (browse all destinations): `https://www.bitrefill.com/esim/all-destinations`
|
|
30
|
+
- Single eSIM: `https://www.bitrefill.com/{country}/{lang}/esims/bitrefill-esim-{destination-slug}/` (e.g. `bitrefill-esim-japan`, `bitrefill-esim-global`)
|
|
31
|
+
- Auth (no locale prefix): `/login`, `/signup`
|
|
32
|
+
|
|
33
|
+
## Country in URL vs geolock
|
|
34
|
+
|
|
35
|
+
- **URL country** filters which inventory is **listed**.
|
|
36
|
+
- **Geolock** is enforced at **IP level** at checkout. A product may appear in listing but be unpurchasable if user's IP is outside allowed region.
|
|
37
|
+
|
|
38
|
+
Match URL country to recipient's country to surface usable cards.
|
|
39
|
+
|
|
40
|
+
## Listing filters & sort (gift cards)
|
|
41
|
+
|
|
42
|
+
Query params on any gift-card listing (`/{country}/{lang}/gift-cards/[category/]`):
|
|
43
|
+
|
|
44
|
+
- `redemptionMethod` — `online` | `instore`
|
|
45
|
+
- `minRating` — `2` | `3` | `4` | `5`
|
|
46
|
+
- `minRewards` — `1`–`10` (cashback %)
|
|
47
|
+
- `s` — sort: `2` = A–Z, `3` = recently added, `4` = cashback. Default = popularity.
|
|
48
|
+
|
|
49
|
+
Example: `https://www.bitrefill.com/us/en/gift-cards/food/?minRating=5&minRewards=4&redemptionMethod=instore`
|
|
50
|
+
|
|
51
|
+
## Categories (popular slugs)
|
|
52
|
+
|
|
53
|
+
`top-products`, `retail`, `apparel`, `electronics`, `food`, `restaurants`, `food-delivery`, `streaming`, `games`, `travel`, `flights`, `accommodation`, `entertainment`, `gasoline`, `vpn`, `multi-brand`, `digital-wallet`, `groceries`, `pharmacy`, `experiences`, `gifts`. Full list: <https://docs.bitrefill.com/docs/Products>.
|
|
54
|
+
|
|
55
|
+
## Suggested flow
|
|
56
|
+
|
|
57
|
+
1. Clarify product type (gift card / top-up / eSIM) + country (+ carrier for top-ups).
|
|
58
|
+
2. Send user to direct search URL or category path.
|
|
59
|
+
3. For top-ups: country → carrier → amount.
|
|
60
|
+
4. For eSIMs: destination → data + duration.
|
|
61
|
+
5. Remind user to check denomination matches recipient's needs and that geolock applies at checkout.
|
|
62
|
+
|
|
63
|
+
## Purchase from the browser?
|
|
64
|
+
|
|
65
|
+
Possible but slow and risky. Anti-bot may block agent on brand redemption sites. Prefer [mcp.md](mcp.md) or [cli.md](cli.md) for purchases. If browser checkout is the only option, follow [safeguards.md](safeguards.md) — confirm with user, log invoice ID, treat redemption code as cash.
|
|
66
|
+
|
|
67
|
+
## Source of truth
|
|
68
|
+
|
|
69
|
+
- <https://www.bitrefill.com>
|
|
70
|
+
- <https://help.bitrefill.com>
|
|
71
|
+
- <https://docs.bitrefill.com/docs/Products>
|