@bnbagent/studio-cli 0.0.13 → 0.0.14-alpha.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 +201 -0
- package/README.md +8 -0
- package/dist/_agentcoreName-DZDWEYD3.js +0 -0
- package/dist/bag.js +3556 -1565
- package/dist/{chunk-H4X2OOLA.js → chunk-QVYWAJEK.js} +228 -72
- package/dist/chunk-U7IDQ3K5.js +0 -0
- package/dist/{deployCli-22NMZ4G7.js → deployCli-F3AOM5UO.js} +1 -2
- package/package.json +12 -13
- package/recipes/agent/code/{{PKG}}/deliveryPolicy.ts.tmpl +43 -0
- package/recipes/agent/code/{{PKG}}/readToolCatalog.ts.tmpl +102 -0
- package/recipes/agent/code/{{PKG}}/signing.ts.tmpl +7 -2
- package/recipes/agent/recipe.toml +4 -3
- package/recipes/runtimes/agentcore/code/{{PKG}}/dualMain.ts.tmpl +6 -2
- package/recipes/runtimes/agentcore/code/{{PKG}}/mcpMain.ts.tmpl +173 -134
- package/recipes/runtimes/agentcore/code/{{PKG}}/model.ts.tmpl +7 -0
- package/recipes/runtimes/agentcore/code/{{PKG}}/sellerCore.ts.tmpl +31 -46
- package/recipes/runtimes/agentcore/code/{{PKG}}/tools.ts.tmpl +19 -48
- package/recipes/runtimes/agentcore/code/{{PKG}}/unifiedMain.ts.tmpl +2 -1
- package/recipes/runtimes/azure-foundry/code/{{PKG}}/mcpMain.ts.tmpl +173 -134
- package/recipes/runtimes/azure-foundry/code/{{PKG}}/model.ts.tmpl +7 -0
- package/recipes/runtimes/azure-foundry/code/{{PKG}}/sellerCore.ts.tmpl +31 -46
- package/recipes/runtimes/azure-foundry/code/{{PKG}}/tools.ts.tmpl +19 -48
- package/recipes/runtimes/azure-foundry/code/{{PKG}}/unifiedMain.ts.tmpl +2 -1
- package/recipes/wallet/recipe.toml +3 -2
- package/skills/bnbagent-studio.md +12 -1
- package/skills/references/bnbagent-studio-operating.md +1 -0
- package/skills/references/bnbagent-studio-scaffolding-agent.md +11 -34
- package/skills/references/bnbagent-studio-selling-via-b402.md +3 -3
- package/skills/references/bnbagent-studio-using-altana-wallet.md +6 -1
- package/skills/references/bnbagent-studio-using-twak-wallet.md +24 -76
- package/dist/_twak-4XF4H5PL.js +0 -25
- package/dist/chunk-RO726HJG.js +0 -175
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** Shared delivery ceilings for asynchronous A2A and synchronous MCP paths. */
|
|
2
|
+
export function envSeconds(name: string, dflt: number): number {
|
|
3
|
+
const value = Number(process.env[name] || dflt);
|
|
4
|
+
return Number.isFinite(value) && value > 0 ? value : dflt;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const deliveryTimeoutSeconds = () =>
|
|
8
|
+
envSeconds("NOTIFY_DELIVERY_TIMEOUT_SECONDS", 600);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Smallest remaining submit window a funded job must still have before we
|
|
12
|
+
* accept it. NOTIFY_DELIVERY_TIMEOUT_SECONDS is a ceiling, not a typical
|
|
13
|
+
* duration, so it is capped by NOTIFY_MIN_SUBMIT_WINDOW_SECONDS (default 300s):
|
|
14
|
+
* otherwise a long timeout would permanently reject every job whose buyer
|
|
15
|
+
* chose a short but valid deadline (e.g. `--deadline-min 10`).
|
|
16
|
+
*/
|
|
17
|
+
export const minimumDeliveryWindowSeconds = () =>
|
|
18
|
+
Math.min(
|
|
19
|
+
deliveryTimeoutSeconds() + 60,
|
|
20
|
+
envSeconds("NOTIFY_MIN_SUBMIT_WINDOW_SECONDS", 300),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export class DeliveryTimeoutError extends Error {}
|
|
24
|
+
|
|
25
|
+
/** Bound an entire delivery attempt and abort cancellable work on timeout. */
|
|
26
|
+
export async function withTimeout<T>(
|
|
27
|
+
work: Promise<T>,
|
|
28
|
+
seconds: number,
|
|
29
|
+
controller?: AbortController,
|
|
30
|
+
): Promise<T> {
|
|
31
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
32
|
+
const deadline = new Promise<never>((_, reject) => {
|
|
33
|
+
timer = setTimeout(() => {
|
|
34
|
+
controller?.abort();
|
|
35
|
+
reject(new DeliveryTimeoutError(`timed out after ${seconds}s`));
|
|
36
|
+
}, seconds * 1000);
|
|
37
|
+
});
|
|
38
|
+
try {
|
|
39
|
+
return await Promise.race([work, deadline]);
|
|
40
|
+
} finally {
|
|
41
|
+
clearTimeout(timer);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/** Shared descriptions and Zod input shapes for AI SDK and MCP read tools. */
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
const network = z
|
|
5
|
+
.string()
|
|
6
|
+
.optional()
|
|
7
|
+
.describe("studio network name (defaults to the project's [network].default)");
|
|
8
|
+
const optionalAddress = z
|
|
9
|
+
.string()
|
|
10
|
+
.optional()
|
|
11
|
+
.describe("0x address; omit for own wallet");
|
|
12
|
+
|
|
13
|
+
export const READ_TOOL_CATALOG = {
|
|
14
|
+
wallet_info: {
|
|
15
|
+
description:
|
|
16
|
+
"Describe the agent's active wallet (address, kind, key location).",
|
|
17
|
+
inputSchema: {},
|
|
18
|
+
},
|
|
19
|
+
wallet_list: {
|
|
20
|
+
description: "List all local wallet addresses.",
|
|
21
|
+
inputSchema: {},
|
|
22
|
+
},
|
|
23
|
+
wallet_address: {
|
|
24
|
+
description: "Read the active wallet address.",
|
|
25
|
+
inputSchema: {},
|
|
26
|
+
},
|
|
27
|
+
balance_native: {
|
|
28
|
+
description:
|
|
29
|
+
"Native BNB balance of an address (defaults to the agent's own wallet).",
|
|
30
|
+
inputSchema: { address: optionalAddress, network },
|
|
31
|
+
},
|
|
32
|
+
balance_u: {
|
|
33
|
+
description:
|
|
34
|
+
"$U payment-token balance of an address (defaults to the agent's own wallet).",
|
|
35
|
+
inputSchema: { address: optionalAddress, network },
|
|
36
|
+
},
|
|
37
|
+
network_info: {
|
|
38
|
+
description: "Chain id, RPC, and token information for a Studio network.",
|
|
39
|
+
inputSchema: { network },
|
|
40
|
+
},
|
|
41
|
+
tx_status: {
|
|
42
|
+
description: "Status and receipt summary of a transaction hash.",
|
|
43
|
+
inputSchema: {
|
|
44
|
+
tx_hash: z.string().describe("0x transaction hash"),
|
|
45
|
+
network,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
block_info: {
|
|
49
|
+
description: "Read a block header summary.",
|
|
50
|
+
inputSchema: { block: z.string().optional(), network },
|
|
51
|
+
},
|
|
52
|
+
contract_call_view: {
|
|
53
|
+
description: "Call a read-only contract function by signature.",
|
|
54
|
+
inputSchema: {
|
|
55
|
+
address: z.string(),
|
|
56
|
+
function_signature: z.string(),
|
|
57
|
+
args: z.array(z.unknown()).optional(),
|
|
58
|
+
output_types: z.array(z.string()).optional(),
|
|
59
|
+
network,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
pieverse_usage: {
|
|
63
|
+
description: "Pieverse LLM usage and credit summary for the last N days.",
|
|
64
|
+
inputSchema: { days: z.number().int().optional() },
|
|
65
|
+
},
|
|
66
|
+
agent_info: {
|
|
67
|
+
description: "ERC-8004 identity record for an agent id.",
|
|
68
|
+
inputSchema: {
|
|
69
|
+
agent_id: z.number().int().describe("ERC-8004 agent id"),
|
|
70
|
+
network,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
agent_by_address: {
|
|
74
|
+
description: "Look up an ERC-8004 registration by wallet address.",
|
|
75
|
+
inputSchema: {
|
|
76
|
+
address: z.string().describe("0x wallet address"),
|
|
77
|
+
network,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
job_status: {
|
|
81
|
+
description:
|
|
82
|
+
"Read-only ERC-8183 job detail including the event-resolved deliverable URL.",
|
|
83
|
+
inputSchema: {
|
|
84
|
+
job_id: z.number().int().describe("on-chain job id"),
|
|
85
|
+
network,
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
job_list: {
|
|
89
|
+
description: "List recent ERC-8183 jobs, optionally only this agent's.",
|
|
90
|
+
inputSchema: {
|
|
91
|
+
limit: z.number().int().optional(),
|
|
92
|
+
mine: z.boolean().optional().describe("only jobs assigned to this agent"),
|
|
93
|
+
network,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
job_count: {
|
|
97
|
+
description: "Read the network-wide in-flight ERC-8183 job count.",
|
|
98
|
+
inputSchema: { network },
|
|
99
|
+
},
|
|
100
|
+
} as const;
|
|
101
|
+
|
|
102
|
+
export type ReadToolName = keyof typeof READ_TOOL_CATALOG;
|
|
@@ -250,8 +250,13 @@ export async function signQuote(
|
|
|
250
250
|
* distinguishes a job to skip-forever (record + tell the client) from a
|
|
251
251
|
* transient retry.
|
|
252
252
|
*/
|
|
253
|
-
export async function verifySignedJob(
|
|
254
|
-
|
|
253
|
+
export async function verifySignedJob(
|
|
254
|
+
jobId: number,
|
|
255
|
+
minimumRemainingSeconds = 0,
|
|
256
|
+
): Promise<Verdict> {
|
|
257
|
+
return verifySignedJobCore(jobId, getWallet().address, {
|
|
258
|
+
minimumRemainingSeconds,
|
|
259
|
+
});
|
|
255
260
|
}
|
|
256
261
|
|
|
257
262
|
/**
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
[recipe]
|
|
2
2
|
name = "agent"
|
|
3
|
-
description = "Agent — protocol-neutral signing entrypoints
|
|
4
|
-
status = "
|
|
3
|
+
description = "Agent — protocol-neutral signing entrypoints, shared delivery policy, and read-tool catalog. The Agent is the SOLE key-holder/signer; signing glue remains fixed code that the LLM never calls. Runtime choice (AgentCore / Azure Foundry) lives in `runtimes/<runtime>/` (decision D9: no separate frameworks recipe in the TS line)."
|
|
4
|
+
status = "protocol-shared"
|
|
5
5
|
|
|
6
6
|
[dependencies]
|
|
7
7
|
node = [
|
|
8
|
-
#
|
|
8
|
+
# Shared templates import @bnbagent/studio-runtime (erc8183 + wallet +
|
|
9
9
|
# config + networks subpaths) and the @bnbagent/sdk protocol layer
|
|
10
10
|
# (NegotiationHandler / JobDescription) — protocol-level glue, framework-
|
|
11
11
|
# neutral. The agent project's serving deps (@a2a-js/sdk / MCP SDK / ai)
|
|
12
12
|
# come from the runtimes/<R>/ recipe selected at `bag init` time.
|
|
13
13
|
"@bnbagent/studio-runtime",
|
|
14
14
|
"@bnbagent/sdk@0.5.5",
|
|
15
|
+
"zod@^3.25.0",
|
|
15
16
|
]
|
|
16
17
|
|
|
17
18
|
[env]
|
|
@@ -209,7 +209,8 @@ export function buildRunWork(): RunWork {
|
|
|
209
209
|
|
|
210
210
|
function hasErc8183Rail(cfg: TomlTable): boolean {
|
|
211
211
|
const payments = asTable(cfg.payments);
|
|
212
|
-
|
|
212
|
+
const rail = asTable(payments?.erc8183);
|
|
213
|
+
return rail !== null && rail.enabled !== false;
|
|
213
214
|
}
|
|
214
215
|
|
|
215
216
|
function asTable(value: unknown): TomlTable | null {
|
|
@@ -364,7 +365,10 @@ export async function buildDualApp(): Promise<{
|
|
|
364
365
|
delete transports[t.sessionId];
|
|
365
366
|
}
|
|
366
367
|
};
|
|
367
|
-
await buildMcpServer({
|
|
368
|
+
await buildMcpServer({
|
|
369
|
+
commerceSkills: rails.erc8183,
|
|
370
|
+
runWork,
|
|
371
|
+
}).connect(t);
|
|
368
372
|
transport = t;
|
|
369
373
|
}
|
|
370
374
|
await transport.handleRequest(req, res, req.body);
|