@purseragents/ai-sdk 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Purser
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,50 @@
1
- # Temporary Holding Version
1
+ # Purser for the Vercel AI SDK
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
+ A bank account for your AI agent. The owner sets the rules, a firewall checks every payment, and the agent gets its own
4
+ account as tools. Made by [Purser](https://purseragents.fun).
5
+
6
+ ```sh
7
+ npm install ai @purseragents/ai-sdk
8
+ ```
9
+
10
+ ```ts
11
+ import { generateText, stepCountIs } from "ai";
12
+ import { purserTools } from "@purseragents/ai-sdk";
13
+
14
+ const { text } = await generateText({
15
+ model, // any AI SDK model
16
+ tools: purserTools({ apiKey: process.env.PURSER_API_KEY }),
17
+ stopWhen: stepCountIs(5),
18
+ prompt: "Pay the data vendor 2.50 USDG for today's report.",
19
+ });
20
+ ```
21
+
22
+ `purserTools()` returns a ToolSet with eight tools: `purser_account`, `purser_rules`, `purser_check_payment`,
23
+ `purser_pay`, `purser_receipts`, `purser_paid_fetch`, `purser_pay_invoice` and `purser_profit`. It works with
24
+ `generateText`, `streamText` and agents.
25
+
26
+ Options:
27
+
28
+ - `readOnly: true` leaves out the three tools that move money.
29
+ - `only: ["purser_account", "purser_pay"]` keeps just the tools you name.
30
+ - `needsApproval: true` asks your app before a tool that moves money runs, with the AI SDK's tool approval. The owner's
31
+ rules and approvals in Purser apply either way.
32
+ - `baseUrl` points at your own engine, such as test mode on `http://localhost:8787`.
33
+
34
+ A payment the rules or the firewall refuse comes back to the model as "Blocked." with the reasons and "Nothing was
35
+ paid", never as an error, so the agent can tell the user what happened.
36
+
37
+ ## Getting a key
38
+
39
+ The owner opens an account for the agent on [purseragents.fun](https://purseragents.fun), sets its rules (limits per
40
+ payment, per day and per week, allowed payees, approvals) and creates an agent key for that one account. The key can
41
+ only do what the rules allow, and the owner can freeze the account or revoke the key at any time.
42
+
43
+ ## Try it locally
44
+
45
+ Clone [PurserAgents/purser](https://github.com/PurserAgents/purser) and run `cd engine && npm run testmode`. It starts
46
+ a local chain with test money and prints an engine URL and agent keys; pass them as `baseUrl` and `apiKey`.
47
+
48
+ ## License
49
+
50
+ MIT
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @purseragents/ai-sdk: give an agent built with the Vercel AI SDK its own Purser account.
3
+ *
4
+ * import { generateText } from "ai";
5
+ * import { purserTools } from "@purseragents/ai-sdk";
6
+ *
7
+ * const { text } = await generateText({
8
+ * model,
9
+ * tools: purserTools({ apiKey: process.env.PURSER_API_KEY }),
10
+ * prompt: "Pay the data vendor 2.50 USDG for today's report.",
11
+ * });
12
+ *
13
+ * Every payment goes through the owner's rules and Purser's firewall first. A blocked payment comes back to the
14
+ * model as a plain answer with the reasons ("Blocked. ... Nothing was paid."), never as a thrown error.
15
+ */
16
+ import { type ToolSet } from "ai";
17
+ import { Purser } from "@purseragents/sdk";
18
+ export interface PurserAiSdkOptions {
19
+ /** The agent's API key (prs_...). Default: process.env.PURSER_API_KEY */
20
+ apiKey?: string;
21
+ /** The Purser engine. Default: process.env.PURSER_ENGINE_URL, then https://purseragents.fun */
22
+ baseUrl?: string;
23
+ /** A Purser client you made yourself, instead of apiKey and baseUrl. */
24
+ client?: Purser;
25
+ /** Only these tools, by name (for example ["purser_account", "purser_pay"]). */
26
+ only?: string[];
27
+ /** Leave out every tool that can move money. */
28
+ readOnly?: boolean;
29
+ /**
30
+ * Ask a human before a tool that moves money runs (the AI SDK's tool approval). Purser's own rules and owner
31
+ * approvals apply either way; this adds a check in your app. Default: false.
32
+ */
33
+ needsApproval?: boolean;
34
+ fetch?: typeof fetch;
35
+ }
36
+ /** Purser's tools as an AI SDK ToolSet, keyed by name: purser_account, purser_pay, purser_check_payment and the rest. */
37
+ export declare function purserTools(options?: PurserAiSdkOptions): ToolSet;
38
+ export { Purser, PURSER_DEFAULT_URL } from "@purseragents/sdk";
package/dist/index.js ADDED
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @purseragents/ai-sdk: give an agent built with the Vercel AI SDK its own Purser account.
3
+ *
4
+ * import { generateText } from "ai";
5
+ * import { purserTools } from "@purseragents/ai-sdk";
6
+ *
7
+ * const { text } = await generateText({
8
+ * model,
9
+ * tools: purserTools({ apiKey: process.env.PURSER_API_KEY }),
10
+ * prompt: "Pay the data vendor 2.50 USDG for today's report.",
11
+ * });
12
+ *
13
+ * Every payment goes through the owner's rules and Purser's firewall first. A blocked payment comes back to the
14
+ * model as a plain answer with the reasons ("Blocked. ... Nothing was paid."), never as a thrown error.
15
+ */
16
+ import { jsonSchema, tool } from "ai";
17
+ import { purserFromSettings, purserTools as coreTools, runPurserTool } from "@purseragents/sdk";
18
+ const env = (k) => (typeof process !== "undefined" ? process.env?.[k] : undefined);
19
+ function client(o) {
20
+ return o.client ?? purserFromSettings({ apiKey: o.apiKey ?? env("PURSER_API_KEY"), baseUrl: o.baseUrl ?? env("PURSER_ENGINE_URL"), fetch: o.fetch });
21
+ }
22
+ function wrap(t, needsApproval) {
23
+ return tool({
24
+ title: t.title,
25
+ description: t.description,
26
+ inputSchema: jsonSchema(t.parameters),
27
+ ...(needsApproval && t.movesMoney ? { needsApproval: true } : {}),
28
+ execute: async (input) => runPurserTool(t, input),
29
+ });
30
+ }
31
+ /** Purser's tools as an AI SDK ToolSet, keyed by name: purser_account, purser_pay, purser_check_payment and the rest. */
32
+ export function purserTools(options = {}) {
33
+ const set = {};
34
+ for (const t of coreTools(client(options), { only: options.only, readOnly: options.readOnly }))
35
+ set[t.name] = wrap(t, !!options.needsApproval);
36
+ return set;
37
+ }
38
+ export { Purser, PURSER_DEFAULT_URL } from "@purseragents/sdk";
package/package.json CHANGED
@@ -1,6 +1,41 @@
1
1
  {
2
2
  "name": "@purseragents/ai-sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Purser for the Vercel AI SDK: give your agent its own bank account, with the owner's rules and a firewall in front of every payment.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "keywords": [
20
+ "ai",
21
+ "ai-sdk",
22
+ "vercel",
23
+ "tools",
24
+ "agent",
25
+ "payments",
26
+ "purser",
27
+ "x402"
28
+ ],
29
+ "homepage": "https://purseragents.fun/developers",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/PurserAgents/purser.git",
33
+ "directory": "packages/ai-sdk"
34
+ },
35
+ "peerDependencies": {
36
+ "ai": ">=6.0.0"
37
+ },
38
+ "dependencies": {
39
+ "@purseragents/sdk": "^0.1.0"
40
+ }
41
+ }