dustbureau 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 +21 -0
- package/README.md +204 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/vault.d.ts +45 -0
- package/dist/vault.d.ts.map +1 -0
- package/dist/vault.js +96 -0
- package/dist/vault.js.map +1 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dust Bureau contributors
|
|
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
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# dustbureau — TypeScript / JavaScript SDK
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/dustbureau)
|
|
4
|
+
[](https://nodejs.org/)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](https://www.typescriptlang.org/tsconfig#strict)
|
|
7
|
+
[](https://eslint.org/)
|
|
8
|
+
[](#)
|
|
9
|
+
[](#)
|
|
10
|
+
|
|
11
|
+
Production-ready TypeScript client for the [Dust Bureau Agent Vault](https://dustbureau.network).
|
|
12
|
+
|
|
13
|
+
Use it from inside an AI agent (LangChain.js, Vercel AI SDK, Mastra, custom) to call external APIs **without ever holding the credentials yourself**. The Vault keeps the keys; the agent gets the response.
|
|
14
|
+
|
|
15
|
+
**Zero runtime dependencies** — uses native `fetch`. Works in modern Node (≥20) and in browsers.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
From npm:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install dustbureau
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or pin the major:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install dustbureau@^0.1.0
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
From source (for contributors):
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
git clone https://github.com/DreaminOdin/dust-bureau
|
|
37
|
+
cd dust-bureau/sdk/typescript
|
|
38
|
+
npm install
|
|
39
|
+
npm run build
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Quickstart
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { AgentVault } from "dustbureau";
|
|
48
|
+
|
|
49
|
+
const vault = new AgentVault({
|
|
50
|
+
url: "http://localhost:3000",
|
|
51
|
+
credential: "cred_abc123", // get this from the Vault admin dashboard
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Call OpenAI — the API key never leaves the Vault.
|
|
55
|
+
const result = await vault.call<{ choices: Array<{ message: { content: string } }> }>(
|
|
56
|
+
"openai",
|
|
57
|
+
"chat.completions",
|
|
58
|
+
{ model: "gpt-4o-mini", messages: [{ role: "user", content: "Hello" }] },
|
|
59
|
+
);
|
|
60
|
+
console.log(result.choices[0].message.content);
|
|
61
|
+
|
|
62
|
+
// Audit-log proof id for this call (on-chain reference once anchored)
|
|
63
|
+
console.log(vault.lastProof()); // → "a3f9...7c2d"
|
|
64
|
+
|
|
65
|
+
// Spending stats for budget controls
|
|
66
|
+
console.log(await vault.budget("openai")); // → { today: 3, month: 47, total: 100 }
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Async jobs (MIP-003 / Masumi-compatible)
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
// Fire-and-forget — returns immediately with a jobId
|
|
73
|
+
const jobId = await vault.startJob("openai", "chat.completions", {
|
|
74
|
+
model: "gpt-4o-mini",
|
|
75
|
+
messages: [...],
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Poll manually
|
|
79
|
+
const status = await vault.jobStatus(jobId);
|
|
80
|
+
// → { jobId, status: "running" | "completed" | "failed", result?, error? }
|
|
81
|
+
|
|
82
|
+
// Or block until done (with a timeout)
|
|
83
|
+
const result = await vault.waitForJob<MyResultType>(jobId, {
|
|
84
|
+
pollInterval: 500,
|
|
85
|
+
timeout: 30_000,
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## LangChain.js integration
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
import { tool } from "@langchain/core/tools";
|
|
93
|
+
import { AgentVault } from "dustbureau";
|
|
94
|
+
import { z } from "zod";
|
|
95
|
+
|
|
96
|
+
const vault = new AgentVault({ url: "http://localhost:3000", credential: "cred_abc123" });
|
|
97
|
+
|
|
98
|
+
const callOpenAI = tool(
|
|
99
|
+
async ({ prompt }: { prompt: string }) => {
|
|
100
|
+
const result = await vault.call("openai", "chat.completions", {
|
|
101
|
+
model: "gpt-4o-mini",
|
|
102
|
+
messages: [{ role: "user", content: prompt }],
|
|
103
|
+
});
|
|
104
|
+
return (result as { choices: Array<{ message: { content: string } }> })
|
|
105
|
+
.choices[0].message.content;
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: "call_openai",
|
|
109
|
+
description: "Call OpenAI through the Dust Bureau Vault.",
|
|
110
|
+
schema: z.object({ prompt: z.string() }),
|
|
111
|
+
},
|
|
112
|
+
);
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Vercel AI SDK integration
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import { tool } from "ai";
|
|
119
|
+
import { AgentVault } from "dustbureau";
|
|
120
|
+
import { z } from "zod";
|
|
121
|
+
|
|
122
|
+
const vault = new AgentVault({ url: "http://localhost:3000", credential: "cred_abc123" });
|
|
123
|
+
|
|
124
|
+
const searchTool = tool({
|
|
125
|
+
description: "Search the web via Vault",
|
|
126
|
+
parameters: z.object({ query: z.string() }),
|
|
127
|
+
execute: async ({ query }) => vault.call("serper", "search", { q: query }),
|
|
128
|
+
});
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## API reference
|
|
134
|
+
|
|
135
|
+
| Method | Purpose |
|
|
136
|
+
|---|---|
|
|
137
|
+
| `vault.call<T>(service, method, params)` | Execute an API call via the Vault. Returns the raw service result (typed via the generic). |
|
|
138
|
+
| `vault.budget(service?)` | Return spending stats. With a service argument: `SpendingStats`; without: `Record<string, SpendingStats>`. |
|
|
139
|
+
| `vault.lastProof()` | Audit-log proof id for the most recent call (or `null`). |
|
|
140
|
+
| `vault.auditLog(limit = 20)` | Return the last `limit` audit entries for this credential. |
|
|
141
|
+
| `vault.startJob(service, method, params)` | Start an async job (MIP-003-compatible). Returns the `jobId`. |
|
|
142
|
+
| `vault.jobStatus<T>(jobId)` | Poll the status of a running job; returns `JobStatus<T>`. |
|
|
143
|
+
| `vault.waitForJob<T>(jobId, { pollInterval?, timeout? })` | Block until a job completes; throws `VaultError` on failure or timeout. |
|
|
144
|
+
|
|
145
|
+
All methods throw `VaultError` on Vault-side errors (HTTP failure, missing service, budget exhausted, etc.).
|
|
146
|
+
|
|
147
|
+
### Authentication
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
// Credential token — agent scope, can only call /call
|
|
151
|
+
const vault = new AgentVault({ url, credential: "cred_..." });
|
|
152
|
+
|
|
153
|
+
// Master key — admin scope, full Vault access
|
|
154
|
+
const vault = new AgentVault({ url, masterKey: "..." });
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
The key is sent as `X-Vault-Key` on every request.
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Status
|
|
162
|
+
|
|
163
|
+
**Production-ready as of v0.1.0.**
|
|
164
|
+
|
|
165
|
+
- Implementation: zero-dependency, native `fetch`
|
|
166
|
+
- Tests: 23 passing via Vitest, **100 % line + function coverage**, 94.87 % branch coverage
|
|
167
|
+
- Type-checked: `tsc --strict` clean (`noUnusedLocals`, `noUnusedParameters`, `noImplicitReturns` all on)
|
|
168
|
+
- Lint: ESLint flat-config + `@typescript-eslint` clean
|
|
169
|
+
- Format: Prettier-enforced
|
|
170
|
+
- Supported runtime: Node ≥ 20, modern browsers (anything with global `fetch`)
|
|
171
|
+
- Published on npm as [`dustbureau`](https://www.npmjs.com/package/dustbureau)
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Development
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
cd sdk/typescript
|
|
179
|
+
npm install
|
|
180
|
+
|
|
181
|
+
npm run lint # ESLint (--fix to auto-correct)
|
|
182
|
+
npm run format # Prettier rewrite
|
|
183
|
+
npm run typecheck # tsc --noEmit
|
|
184
|
+
npm run test # Vitest
|
|
185
|
+
npm run test:coverage # Vitest + v8 coverage report
|
|
186
|
+
npm run build # Emit dist/
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
CI runs the same gauntlet on Node 20/22 across Linux + Windows + macOS — see [`.github/workflows/typescript.yml`](../../.github/workflows/typescript.yml).
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## License
|
|
194
|
+
|
|
195
|
+
MIT — see [LICENSE](LICENSE).
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## Related
|
|
200
|
+
|
|
201
|
+
- **Python SDK:** [`dustbureau` on PyPI](https://pypi.org/project/dustbureau/) — sibling source in [`sdk/python/`](../python/)
|
|
202
|
+
- **Vault server:** [`dust-bureau-vault`](../../dust-bureau-vault/)
|
|
203
|
+
- **MCP server:** [`mcp/`](../../mcp/) for Claude Code integration
|
|
204
|
+
- **Anchor protocol** (Midnight) and **Enterprise edition** ship in separate repositories from Phase 1a.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACjD,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VaultError = exports.AgentVault = void 0;
|
|
4
|
+
var vault_1 = require("./vault");
|
|
5
|
+
Object.defineProperty(exports, "AgentVault", { enumerable: true, get: function () { return vault_1.AgentVault; } });
|
|
6
|
+
Object.defineProperty(exports, "VaultError", { enumerable: true, get: function () { return vault_1.VaultError; } });
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iCAAiD;AAAxC,mGAAA,UAAU,OAAA;AAAE,mGAAA,UAAU,OAAA"}
|
package/dist/vault.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export declare class VaultError extends Error {
|
|
2
|
+
constructor(message: string);
|
|
3
|
+
}
|
|
4
|
+
export interface VaultConfig {
|
|
5
|
+
url?: string;
|
|
6
|
+
credential?: string;
|
|
7
|
+
masterKey?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface CallResult<T = unknown> {
|
|
10
|
+
result: T;
|
|
11
|
+
proofId: string | null;
|
|
12
|
+
}
|
|
13
|
+
export interface JobStatus<T = unknown> {
|
|
14
|
+
jobId: string;
|
|
15
|
+
status: "running" | "completed" | "failed";
|
|
16
|
+
result?: T;
|
|
17
|
+
error?: string;
|
|
18
|
+
createdAt: string;
|
|
19
|
+
completedAt?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface SpendingStats {
|
|
22
|
+
today: number;
|
|
23
|
+
month: number;
|
|
24
|
+
total: number;
|
|
25
|
+
}
|
|
26
|
+
export declare class AgentVault {
|
|
27
|
+
private readonly url;
|
|
28
|
+
private readonly key;
|
|
29
|
+
private _lastProofId;
|
|
30
|
+
constructor(config: VaultConfig);
|
|
31
|
+
call<T = unknown>(service: string, method: string, params: Record<string, unknown>): Promise<T>;
|
|
32
|
+
budget(service?: string): Promise<Record<string, SpendingStats> | SpendingStats>;
|
|
33
|
+
lastProof(): string | null;
|
|
34
|
+
auditLog(limit?: number): Promise<unknown[]>;
|
|
35
|
+
startJob(service: string, method: string, params: Record<string, unknown>): Promise<string>;
|
|
36
|
+
jobStatus<T = unknown>(jobId: string): Promise<JobStatus<T>>;
|
|
37
|
+
waitForJob<T = unknown>(jobId: string, { pollInterval, timeout }?: {
|
|
38
|
+
pollInterval?: number;
|
|
39
|
+
timeout?: number;
|
|
40
|
+
}): Promise<T>;
|
|
41
|
+
private post;
|
|
42
|
+
private get;
|
|
43
|
+
private request;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=vault.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault.d.ts","sourceRoot":"","sources":["../src/vault.ts"],"names":[],"mappings":"AAAA,qBAAa,UAAW,SAAQ,KAAK;gBACvB,OAAO,EAAE,MAAM;CAI5B;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,UAAU,CAAC,CAAC,GAAG,OAAO;IACrC,MAAM,EAAE,CAAC,CAAC;IACV,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,MAAM,WAAW,SAAS,CAAC,CAAC,GAAG,OAAO;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;IAC3C,MAAM,CAAC,EAAE,CAAC,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,YAAY,CAAuB;gBAE/B,MAAM,EAAE,WAAW;IAUzB,IAAI,CAAC,CAAC,GAAG,OAAO,EACpB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,CAAC,CAAC;IAQP,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,aAAa,CAAC;IAStF,SAAS,IAAI,MAAM,GAAG,IAAI;IAIpB,QAAQ,CAAC,KAAK,SAAK,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAOxC,QAAQ,CACZ,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,MAAM,CAAC;IAKZ,SAAS,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAY5D,UAAU,CAAC,CAAC,GAAG,OAAO,EAC1B,KAAK,EAAE,MAAM,EACb,EAAE,YAAkB,EAAE,OAAgB,EAAE,GAAE;QAAE,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAO,GACzF,OAAO,CAAC,CAAC,CAAC;YAcC,IAAI;YAOJ,GAAG;YAIH,OAAO;CAkBtB"}
|
package/dist/vault.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AgentVault = exports.VaultError = void 0;
|
|
4
|
+
class VaultError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "VaultError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.VaultError = VaultError;
|
|
11
|
+
class AgentVault {
|
|
12
|
+
constructor(config) {
|
|
13
|
+
this._lastProofId = null;
|
|
14
|
+
if (!config.credential && !config.masterKey) {
|
|
15
|
+
throw new VaultError("Provide either 'credential' or 'masterKey'");
|
|
16
|
+
}
|
|
17
|
+
this.url = (config.url ?? "http://localhost:3000").replace(/\/$/, "");
|
|
18
|
+
this.key = (config.credential ?? config.masterKey);
|
|
19
|
+
}
|
|
20
|
+
// ── Core: proxy a service call ───────────────────────────────────────────
|
|
21
|
+
async call(service, method, params) {
|
|
22
|
+
const data = await this.post("/call", { service, method, params });
|
|
23
|
+
this._lastProofId = typeof data.proof_id === "string" ? data.proof_id : null;
|
|
24
|
+
return data.result;
|
|
25
|
+
}
|
|
26
|
+
// ── Budget info ──────────────────────────────────────────────────────────
|
|
27
|
+
async budget(service) {
|
|
28
|
+
const data = await this.get("/budget/spending");
|
|
29
|
+
const spending = data.spending ?? {};
|
|
30
|
+
if (service)
|
|
31
|
+
return spending[service] ?? {};
|
|
32
|
+
return spending;
|
|
33
|
+
}
|
|
34
|
+
// ── Audit / proof ────────────────────────────────────────────────────────
|
|
35
|
+
lastProof() {
|
|
36
|
+
return this._lastProofId;
|
|
37
|
+
}
|
|
38
|
+
async auditLog(limit = 20) {
|
|
39
|
+
const data = await this.get(`/audit?limit=${limit}`);
|
|
40
|
+
return data.entries ?? [];
|
|
41
|
+
}
|
|
42
|
+
// ── Masumi MIP-003: async job interface ──────────────────────────────────
|
|
43
|
+
async startJob(service, method, params) {
|
|
44
|
+
const data = await this.post("/masumi/start_job", { service, method, params });
|
|
45
|
+
return data.job_id;
|
|
46
|
+
}
|
|
47
|
+
async jobStatus(jobId) {
|
|
48
|
+
const data = await this.get(`/masumi/status?job_id=${encodeURIComponent(jobId)}`);
|
|
49
|
+
return {
|
|
50
|
+
jobId: data.job_id,
|
|
51
|
+
status: data.status,
|
|
52
|
+
result: data.result,
|
|
53
|
+
error: data.error,
|
|
54
|
+
createdAt: data.created_at,
|
|
55
|
+
completedAt: data.completed_at,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
async waitForJob(jobId, { pollInterval = 500, timeout = 60000 } = {}) {
|
|
59
|
+
const deadline = Date.now() + timeout;
|
|
60
|
+
while (Date.now() < deadline) {
|
|
61
|
+
const status = await this.jobStatus(jobId);
|
|
62
|
+
if (status.status === "completed")
|
|
63
|
+
return status.result;
|
|
64
|
+
if (status.status === "failed")
|
|
65
|
+
throw new VaultError(`Job failed: ${status.error ?? "unknown"}`);
|
|
66
|
+
await sleep(pollInterval);
|
|
67
|
+
}
|
|
68
|
+
throw new VaultError(`Job ${jobId} timed out after ${timeout}ms`);
|
|
69
|
+
}
|
|
70
|
+
// ── Internal helpers ─────────────────────────────────────────────────────
|
|
71
|
+
async post(path, body) {
|
|
72
|
+
return this.request("POST", path, body);
|
|
73
|
+
}
|
|
74
|
+
async get(path) {
|
|
75
|
+
return this.request("GET", path);
|
|
76
|
+
}
|
|
77
|
+
async request(method, path, body) {
|
|
78
|
+
const res = await fetch(this.url + path, {
|
|
79
|
+
method,
|
|
80
|
+
headers: {
|
|
81
|
+
"Content-Type": "application/json",
|
|
82
|
+
"X-Vault-Key": this.key,
|
|
83
|
+
},
|
|
84
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
85
|
+
});
|
|
86
|
+
const data = (await res.json());
|
|
87
|
+
if (!data.ok)
|
|
88
|
+
throw new VaultError(data.error ?? `HTTP ${res.status}`);
|
|
89
|
+
return data;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.AgentVault = AgentVault;
|
|
93
|
+
function sleep(ms) {
|
|
94
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=vault.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault.js","sourceRoot":"","sources":["../src/vault.ts"],"names":[],"mappings":";;;AAAA,MAAa,UAAW,SAAQ,KAAK;IACnC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AALD,gCAKC;AA4BD,MAAa,UAAU;IAKrB,YAAY,MAAmB;QAFvB,iBAAY,GAAkB,IAAI,CAAC;QAGzC,IAAI,CAAC,MAAM,CAA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
|
+
{
|
|
2
|
+
"name": "dustbureau",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript/JavaScript SDK for the Dust Bureau Agent Vault — call external APIs through a vault that holds the credentials, with on-chain-anchorable audit trail.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Dust Bureau contributors <ivo@dustbureau.network>",
|
|
7
|
+
"homepage": "https://github.com/DreaminOdin/dust-bureau#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/DreaminOdin/dust-bureau.git",
|
|
11
|
+
"directory": "sdk/typescript"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/DreaminOdin/dust-bureau/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"vault",
|
|
18
|
+
"ai-agents",
|
|
19
|
+
"credentials",
|
|
20
|
+
"secrets-management",
|
|
21
|
+
"compliance",
|
|
22
|
+
"audit",
|
|
23
|
+
"cardano",
|
|
24
|
+
"midnight",
|
|
25
|
+
"masumi",
|
|
26
|
+
"mip-003"
|
|
27
|
+
],
|
|
28
|
+
"main": "dist/index.js",
|
|
29
|
+
"types": "dist/index.d.ts",
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE"
|
|
34
|
+
],
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=20"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsc",
|
|
43
|
+
"dev": "tsc --watch",
|
|
44
|
+
"test": "vitest run",
|
|
45
|
+
"test:watch": "vitest",
|
|
46
|
+
"test:coverage": "vitest run --coverage",
|
|
47
|
+
"lint": "eslint src tests",
|
|
48
|
+
"lint:fix": "eslint src tests --fix",
|
|
49
|
+
"format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
50
|
+
"format:check": "prettier --check \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
51
|
+
"typecheck": "tsc --noEmit",
|
|
52
|
+
"prepublishOnly": "npm run lint && npm run typecheck && npm run test && npm run build"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^20.14.0",
|
|
57
|
+
"@typescript-eslint/eslint-plugin": "^8.18.0",
|
|
58
|
+
"@typescript-eslint/parser": "^8.18.0",
|
|
59
|
+
"@vitest/coverage-v8": "^2.1.0",
|
|
60
|
+
"@eslint/js": "^9.16.0",
|
|
61
|
+
"eslint": "^9.16.0",
|
|
62
|
+
"prettier": "^3.4.0",
|
|
63
|
+
"typescript": "^5.4.5",
|
|
64
|
+
"vitest": "^2.1.0"
|
|
65
|
+
}
|
|
66
|
+
}
|