@agent-receipts/sdk 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 +108 -0
- package/dist/index.d.mts +28 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +87 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +67 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Webaes
|
|
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,108 @@
|
|
|
1
|
+
# @agent-receipts/sdk
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for [Agent Receipts](https://github.com/webaesbyamin/agent-receipts). Track, verify, and manage signed receipts for AI agent actions. Everything runs locally.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @agent-receipts/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { AgentReceipts } from '@agent-receipts/sdk'
|
|
15
|
+
|
|
16
|
+
const ar = new AgentReceipts()
|
|
17
|
+
|
|
18
|
+
const receipt = await ar.track({
|
|
19
|
+
action: 'generate_report',
|
|
20
|
+
input: { query: 'Q4 revenue' },
|
|
21
|
+
output: { total: 142000 },
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
console.log(receipt.receipt_id) // rcpt_8f3k2j4n...
|
|
25
|
+
console.log(receipt.signature) // ed25519 hex signature
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## API
|
|
29
|
+
|
|
30
|
+
### `new AgentReceipts(config?)`
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
const ar = new AgentReceipts({
|
|
34
|
+
dataDir: '~/.agent-receipts', // optional, defaults to ~/.agent-receipts
|
|
35
|
+
})
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### `ar.track(params)` — Track a completed action
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
const receipt = await ar.track({
|
|
42
|
+
action: 'analyze_data',
|
|
43
|
+
input: { dataset: 'sales_2024' },
|
|
44
|
+
output: { summary: 'Revenue up 12%' },
|
|
45
|
+
agent_id: 'analyst-v2',
|
|
46
|
+
chain_id: 'chain_abc', // optional, auto-generated if omitted
|
|
47
|
+
parent_receipt_id: 'rcpt_prev', // optional, links to parent receipt
|
|
48
|
+
})
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### `ar.emit(params)` — Alias for track
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
const receipt = await ar.emit({ action: 'my_action', input: 'data' })
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### `ar.start(params)` — Start a pending receipt
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
const receipt = await ar.start({
|
|
61
|
+
action: 'long_running_task',
|
|
62
|
+
input: { job_id: '12345' },
|
|
63
|
+
})
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### `ar.complete(receiptId, params)` — Complete a pending receipt
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
const completed = await ar.complete(receipt.receipt_id, {
|
|
70
|
+
output: { result: 'done' },
|
|
71
|
+
status: 'completed',
|
|
72
|
+
})
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### `ar.verify(receiptId)` — Verify a receipt signature
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
const { verified, receipt } = await ar.verify('rcpt_8f3k2j4n')
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### `ar.get(receiptId)` — Get a receipt by ID
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
const receipt = await ar.get('rcpt_8f3k2j4n')
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### `ar.list(filter?)` — List receipts
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
const result = await ar.list({ agent_id: 'my-agent', status: 'completed' })
|
|
91
|
+
// result.data: ActionReceipt[]
|
|
92
|
+
// result.pagination: { page, pageSize, total }
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### `ar.getPublicKey()` — Get the signing public key
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
const publicKey = await ar.getPublicKey()
|
|
99
|
+
// 64-char hex string (Ed25519 public key)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Examples
|
|
103
|
+
|
|
104
|
+
See the [examples](https://github.com/webaesbyamin/agent-receipts/tree/main/examples) directory for complete usage patterns including chained receipts and multi-step pipelines.
|
|
105
|
+
|
|
106
|
+
## License
|
|
107
|
+
|
|
108
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { TrackParams, CreateParams, CompleteParams, ReceiptFilter, PaginatedResult } from '@agent-receipts/mcp-server';
|
|
2
|
+
export { CompleteParams, CreateParams, PaginatedResult, ReceiptFilter, TrackParams, hashData } from '@agent-receipts/mcp-server';
|
|
3
|
+
import { ActionReceipt } from '@agent-receipts/schema';
|
|
4
|
+
|
|
5
|
+
interface AgentReceiptsConfig {
|
|
6
|
+
dataDir?: string;
|
|
7
|
+
}
|
|
8
|
+
declare class AgentReceipts {
|
|
9
|
+
private engine;
|
|
10
|
+
private dataDir;
|
|
11
|
+
private initialized;
|
|
12
|
+
constructor(config?: AgentReceiptsConfig);
|
|
13
|
+
private ensureInitialized;
|
|
14
|
+
track(params: TrackParams): Promise<ActionReceipt>;
|
|
15
|
+
/** Alias for track */
|
|
16
|
+
emit(params: TrackParams): Promise<ActionReceipt>;
|
|
17
|
+
start(params: CreateParams): Promise<ActionReceipt>;
|
|
18
|
+
complete(receiptId: string, params: CompleteParams): Promise<ActionReceipt>;
|
|
19
|
+
verify(receiptId: string): Promise<{
|
|
20
|
+
verified: boolean;
|
|
21
|
+
receipt: ActionReceipt;
|
|
22
|
+
}>;
|
|
23
|
+
get(receiptId: string): Promise<ActionReceipt | null>;
|
|
24
|
+
list(filter?: ReceiptFilter): Promise<PaginatedResult<ActionReceipt>>;
|
|
25
|
+
getPublicKey(): Promise<string>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { AgentReceipts, type AgentReceiptsConfig };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { TrackParams, CreateParams, CompleteParams, ReceiptFilter, PaginatedResult } from '@agent-receipts/mcp-server';
|
|
2
|
+
export { CompleteParams, CreateParams, PaginatedResult, ReceiptFilter, TrackParams, hashData } from '@agent-receipts/mcp-server';
|
|
3
|
+
import { ActionReceipt } from '@agent-receipts/schema';
|
|
4
|
+
|
|
5
|
+
interface AgentReceiptsConfig {
|
|
6
|
+
dataDir?: string;
|
|
7
|
+
}
|
|
8
|
+
declare class AgentReceipts {
|
|
9
|
+
private engine;
|
|
10
|
+
private dataDir;
|
|
11
|
+
private initialized;
|
|
12
|
+
constructor(config?: AgentReceiptsConfig);
|
|
13
|
+
private ensureInitialized;
|
|
14
|
+
track(params: TrackParams): Promise<ActionReceipt>;
|
|
15
|
+
/** Alias for track */
|
|
16
|
+
emit(params: TrackParams): Promise<ActionReceipt>;
|
|
17
|
+
start(params: CreateParams): Promise<ActionReceipt>;
|
|
18
|
+
complete(receiptId: string, params: CompleteParams): Promise<ActionReceipt>;
|
|
19
|
+
verify(receiptId: string): Promise<{
|
|
20
|
+
verified: boolean;
|
|
21
|
+
receipt: ActionReceipt;
|
|
22
|
+
}>;
|
|
23
|
+
get(receiptId: string): Promise<ActionReceipt | null>;
|
|
24
|
+
list(filter?: ReceiptFilter): Promise<PaginatedResult<ActionReceipt>>;
|
|
25
|
+
getPublicKey(): Promise<string>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { AgentReceipts, type AgentReceiptsConfig };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
AgentReceipts: () => AgentReceipts,
|
|
24
|
+
hashData: () => import_mcp_server.hashData
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
var import_mcp_server = require("@agent-receipts/mcp-server");
|
|
28
|
+
var AgentReceipts = class {
|
|
29
|
+
engine = null;
|
|
30
|
+
dataDir;
|
|
31
|
+
initialized = false;
|
|
32
|
+
constructor(config) {
|
|
33
|
+
this.dataDir = config?.dataDir ?? import_mcp_server.ConfigManager.getDefaultDataDir();
|
|
34
|
+
}
|
|
35
|
+
async ensureInitialized() {
|
|
36
|
+
if (this.engine && this.initialized) {
|
|
37
|
+
return this.engine;
|
|
38
|
+
}
|
|
39
|
+
const store = new import_mcp_server.ReceiptStore(this.dataDir);
|
|
40
|
+
await store.init();
|
|
41
|
+
const keyManager = new import_mcp_server.KeyManager(this.dataDir);
|
|
42
|
+
await keyManager.init();
|
|
43
|
+
const configManager = new import_mcp_server.ConfigManager(this.dataDir);
|
|
44
|
+
await configManager.init();
|
|
45
|
+
this.engine = new import_mcp_server.ReceiptEngine(store, keyManager, configManager);
|
|
46
|
+
this.initialized = true;
|
|
47
|
+
return this.engine;
|
|
48
|
+
}
|
|
49
|
+
async track(params) {
|
|
50
|
+
const engine = await this.ensureInitialized();
|
|
51
|
+
return engine.track(params);
|
|
52
|
+
}
|
|
53
|
+
/** Alias for track */
|
|
54
|
+
async emit(params) {
|
|
55
|
+
return this.track(params);
|
|
56
|
+
}
|
|
57
|
+
async start(params) {
|
|
58
|
+
const engine = await this.ensureInitialized();
|
|
59
|
+
return engine.create({ ...params, status: "pending" });
|
|
60
|
+
}
|
|
61
|
+
async complete(receiptId, params) {
|
|
62
|
+
const engine = await this.ensureInitialized();
|
|
63
|
+
return engine.complete(receiptId, params);
|
|
64
|
+
}
|
|
65
|
+
async verify(receiptId) {
|
|
66
|
+
const engine = await this.ensureInitialized();
|
|
67
|
+
return engine.verify(receiptId);
|
|
68
|
+
}
|
|
69
|
+
async get(receiptId) {
|
|
70
|
+
const engine = await this.ensureInitialized();
|
|
71
|
+
return engine.get(receiptId);
|
|
72
|
+
}
|
|
73
|
+
async list(filter) {
|
|
74
|
+
const engine = await this.ensureInitialized();
|
|
75
|
+
return engine.list(filter);
|
|
76
|
+
}
|
|
77
|
+
async getPublicKey() {
|
|
78
|
+
const engine = await this.ensureInitialized();
|
|
79
|
+
return engine.getPublicKey();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
83
|
+
0 && (module.exports = {
|
|
84
|
+
AgentReceipts,
|
|
85
|
+
hashData
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n ReceiptStore,\n KeyManager,\n ConfigManager,\n ReceiptEngine,\n hashData,\n} from '@agent-receipts/mcp-server'\nimport type {\n TrackParams,\n CreateParams,\n CompleteParams,\n ReceiptFilter,\n PaginatedResult,\n} from '@agent-receipts/mcp-server'\nimport type { ActionReceipt } from '@agent-receipts/schema'\n\nexport interface AgentReceiptsConfig {\n dataDir?: string\n}\n\nexport class AgentReceipts {\n private engine: ReceiptEngine | null = null\n private dataDir: string\n private initialized = false\n\n constructor(config?: AgentReceiptsConfig) {\n this.dataDir = config?.dataDir ?? ConfigManager.getDefaultDataDir()\n }\n\n private async ensureInitialized(): Promise<ReceiptEngine> {\n if (this.engine && this.initialized) {\n return this.engine\n }\n\n const store = new ReceiptStore(this.dataDir)\n await store.init()\n\n const keyManager = new KeyManager(this.dataDir)\n await keyManager.init()\n\n const configManager = new ConfigManager(this.dataDir)\n await configManager.init()\n\n this.engine = new ReceiptEngine(store, keyManager, configManager)\n this.initialized = true\n return this.engine\n }\n\n async track(params: TrackParams): Promise<ActionReceipt> {\n const engine = await this.ensureInitialized()\n return engine.track(params)\n }\n\n /** Alias for track */\n async emit(params: TrackParams): Promise<ActionReceipt> {\n return this.track(params)\n }\n\n async start(params: CreateParams): Promise<ActionReceipt> {\n const engine = await this.ensureInitialized()\n return engine.create({ ...params, status: 'pending' })\n }\n\n async complete(receiptId: string, params: CompleteParams): Promise<ActionReceipt> {\n const engine = await this.ensureInitialized()\n return engine.complete(receiptId, params)\n }\n\n async verify(receiptId: string): Promise<{ verified: boolean; receipt: ActionReceipt }> {\n const engine = await this.ensureInitialized()\n return engine.verify(receiptId)\n }\n\n async get(receiptId: string): Promise<ActionReceipt | null> {\n const engine = await this.ensureInitialized()\n return engine.get(receiptId)\n }\n\n async list(filter?: ReceiptFilter): Promise<PaginatedResult<ActionReceipt>> {\n const engine = await this.ensureInitialized()\n return engine.list(filter)\n }\n\n async getPublicKey(): Promise<string> {\n const engine = await this.ensureInitialized()\n return engine.getPublicKey()\n }\n}\n\nexport { hashData }\nexport type { TrackParams, CreateParams, CompleteParams, ReceiptFilter, PaginatedResult }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAMO;AAcA,IAAM,gBAAN,MAAoB;AAAA,EACjB,SAA+B;AAAA,EAC/B;AAAA,EACA,cAAc;AAAA,EAEtB,YAAY,QAA8B;AACxC,SAAK,UAAU,QAAQ,WAAW,gCAAc,kBAAkB;AAAA,EACpE;AAAA,EAEA,MAAc,oBAA4C;AACxD,QAAI,KAAK,UAAU,KAAK,aAAa;AACnC,aAAO,KAAK;AAAA,IACd;AAEA,UAAM,QAAQ,IAAI,+BAAa,KAAK,OAAO;AAC3C,UAAM,MAAM,KAAK;AAEjB,UAAM,aAAa,IAAI,6BAAW,KAAK,OAAO;AAC9C,UAAM,WAAW,KAAK;AAEtB,UAAM,gBAAgB,IAAI,gCAAc,KAAK,OAAO;AACpD,UAAM,cAAc,KAAK;AAEzB,SAAK,SAAS,IAAI,gCAAc,OAAO,YAAY,aAAa;AAChE,SAAK,cAAc;AACnB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAM,MAAM,QAA6C;AACvD,UAAM,SAAS,MAAM,KAAK,kBAAkB;AAC5C,WAAO,OAAO,MAAM,MAAM;AAAA,EAC5B;AAAA;AAAA,EAGA,MAAM,KAAK,QAA6C;AACtD,WAAO,KAAK,MAAM,MAAM;AAAA,EAC1B;AAAA,EAEA,MAAM,MAAM,QAA8C;AACxD,UAAM,SAAS,MAAM,KAAK,kBAAkB;AAC5C,WAAO,OAAO,OAAO,EAAE,GAAG,QAAQ,QAAQ,UAAU,CAAC;AAAA,EACvD;AAAA,EAEA,MAAM,SAAS,WAAmB,QAAgD;AAChF,UAAM,SAAS,MAAM,KAAK,kBAAkB;AAC5C,WAAO,OAAO,SAAS,WAAW,MAAM;AAAA,EAC1C;AAAA,EAEA,MAAM,OAAO,WAA2E;AACtF,UAAM,SAAS,MAAM,KAAK,kBAAkB;AAC5C,WAAO,OAAO,OAAO,SAAS;AAAA,EAChC;AAAA,EAEA,MAAM,IAAI,WAAkD;AAC1D,UAAM,SAAS,MAAM,KAAK,kBAAkB;AAC5C,WAAO,OAAO,IAAI,SAAS;AAAA,EAC7B;AAAA,EAEA,MAAM,KAAK,QAAiE;AAC1E,UAAM,SAAS,MAAM,KAAK,kBAAkB;AAC5C,WAAO,OAAO,KAAK,MAAM;AAAA,EAC3B;AAAA,EAEA,MAAM,eAAgC;AACpC,UAAM,SAAS,MAAM,KAAK,kBAAkB;AAC5C,WAAO,OAAO,aAAa;AAAA,EAC7B;AACF;","names":[]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import {
|
|
3
|
+
ReceiptStore,
|
|
4
|
+
KeyManager,
|
|
5
|
+
ConfigManager,
|
|
6
|
+
ReceiptEngine,
|
|
7
|
+
hashData
|
|
8
|
+
} from "@agent-receipts/mcp-server";
|
|
9
|
+
var AgentReceipts = class {
|
|
10
|
+
engine = null;
|
|
11
|
+
dataDir;
|
|
12
|
+
initialized = false;
|
|
13
|
+
constructor(config) {
|
|
14
|
+
this.dataDir = config?.dataDir ?? ConfigManager.getDefaultDataDir();
|
|
15
|
+
}
|
|
16
|
+
async ensureInitialized() {
|
|
17
|
+
if (this.engine && this.initialized) {
|
|
18
|
+
return this.engine;
|
|
19
|
+
}
|
|
20
|
+
const store = new ReceiptStore(this.dataDir);
|
|
21
|
+
await store.init();
|
|
22
|
+
const keyManager = new KeyManager(this.dataDir);
|
|
23
|
+
await keyManager.init();
|
|
24
|
+
const configManager = new ConfigManager(this.dataDir);
|
|
25
|
+
await configManager.init();
|
|
26
|
+
this.engine = new ReceiptEngine(store, keyManager, configManager);
|
|
27
|
+
this.initialized = true;
|
|
28
|
+
return this.engine;
|
|
29
|
+
}
|
|
30
|
+
async track(params) {
|
|
31
|
+
const engine = await this.ensureInitialized();
|
|
32
|
+
return engine.track(params);
|
|
33
|
+
}
|
|
34
|
+
/** Alias for track */
|
|
35
|
+
async emit(params) {
|
|
36
|
+
return this.track(params);
|
|
37
|
+
}
|
|
38
|
+
async start(params) {
|
|
39
|
+
const engine = await this.ensureInitialized();
|
|
40
|
+
return engine.create({ ...params, status: "pending" });
|
|
41
|
+
}
|
|
42
|
+
async complete(receiptId, params) {
|
|
43
|
+
const engine = await this.ensureInitialized();
|
|
44
|
+
return engine.complete(receiptId, params);
|
|
45
|
+
}
|
|
46
|
+
async verify(receiptId) {
|
|
47
|
+
const engine = await this.ensureInitialized();
|
|
48
|
+
return engine.verify(receiptId);
|
|
49
|
+
}
|
|
50
|
+
async get(receiptId) {
|
|
51
|
+
const engine = await this.ensureInitialized();
|
|
52
|
+
return engine.get(receiptId);
|
|
53
|
+
}
|
|
54
|
+
async list(filter) {
|
|
55
|
+
const engine = await this.ensureInitialized();
|
|
56
|
+
return engine.list(filter);
|
|
57
|
+
}
|
|
58
|
+
async getPublicKey() {
|
|
59
|
+
const engine = await this.ensureInitialized();
|
|
60
|
+
return engine.getPublicKey();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
export {
|
|
64
|
+
AgentReceipts,
|
|
65
|
+
hashData
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n ReceiptStore,\n KeyManager,\n ConfigManager,\n ReceiptEngine,\n hashData,\n} from '@agent-receipts/mcp-server'\nimport type {\n TrackParams,\n CreateParams,\n CompleteParams,\n ReceiptFilter,\n PaginatedResult,\n} from '@agent-receipts/mcp-server'\nimport type { ActionReceipt } from '@agent-receipts/schema'\n\nexport interface AgentReceiptsConfig {\n dataDir?: string\n}\n\nexport class AgentReceipts {\n private engine: ReceiptEngine | null = null\n private dataDir: string\n private initialized = false\n\n constructor(config?: AgentReceiptsConfig) {\n this.dataDir = config?.dataDir ?? ConfigManager.getDefaultDataDir()\n }\n\n private async ensureInitialized(): Promise<ReceiptEngine> {\n if (this.engine && this.initialized) {\n return this.engine\n }\n\n const store = new ReceiptStore(this.dataDir)\n await store.init()\n\n const keyManager = new KeyManager(this.dataDir)\n await keyManager.init()\n\n const configManager = new ConfigManager(this.dataDir)\n await configManager.init()\n\n this.engine = new ReceiptEngine(store, keyManager, configManager)\n this.initialized = true\n return this.engine\n }\n\n async track(params: TrackParams): Promise<ActionReceipt> {\n const engine = await this.ensureInitialized()\n return engine.track(params)\n }\n\n /** Alias for track */\n async emit(params: TrackParams): Promise<ActionReceipt> {\n return this.track(params)\n }\n\n async start(params: CreateParams): Promise<ActionReceipt> {\n const engine = await this.ensureInitialized()\n return engine.create({ ...params, status: 'pending' })\n }\n\n async complete(receiptId: string, params: CompleteParams): Promise<ActionReceipt> {\n const engine = await this.ensureInitialized()\n return engine.complete(receiptId, params)\n }\n\n async verify(receiptId: string): Promise<{ verified: boolean; receipt: ActionReceipt }> {\n const engine = await this.ensureInitialized()\n return engine.verify(receiptId)\n }\n\n async get(receiptId: string): Promise<ActionReceipt | null> {\n const engine = await this.ensureInitialized()\n return engine.get(receiptId)\n }\n\n async list(filter?: ReceiptFilter): Promise<PaginatedResult<ActionReceipt>> {\n const engine = await this.ensureInitialized()\n return engine.list(filter)\n }\n\n async getPublicKey(): Promise<string> {\n const engine = await this.ensureInitialized()\n return engine.getPublicKey()\n }\n}\n\nexport { hashData }\nexport type { TrackParams, CreateParams, CompleteParams, ReceiptFilter, PaginatedResult }\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAcA,IAAM,gBAAN,MAAoB;AAAA,EACjB,SAA+B;AAAA,EAC/B;AAAA,EACA,cAAc;AAAA,EAEtB,YAAY,QAA8B;AACxC,SAAK,UAAU,QAAQ,WAAW,cAAc,kBAAkB;AAAA,EACpE;AAAA,EAEA,MAAc,oBAA4C;AACxD,QAAI,KAAK,UAAU,KAAK,aAAa;AACnC,aAAO,KAAK;AAAA,IACd;AAEA,UAAM,QAAQ,IAAI,aAAa,KAAK,OAAO;AAC3C,UAAM,MAAM,KAAK;AAEjB,UAAM,aAAa,IAAI,WAAW,KAAK,OAAO;AAC9C,UAAM,WAAW,KAAK;AAEtB,UAAM,gBAAgB,IAAI,cAAc,KAAK,OAAO;AACpD,UAAM,cAAc,KAAK;AAEzB,SAAK,SAAS,IAAI,cAAc,OAAO,YAAY,aAAa;AAChE,SAAK,cAAc;AACnB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAM,MAAM,QAA6C;AACvD,UAAM,SAAS,MAAM,KAAK,kBAAkB;AAC5C,WAAO,OAAO,MAAM,MAAM;AAAA,EAC5B;AAAA;AAAA,EAGA,MAAM,KAAK,QAA6C;AACtD,WAAO,KAAK,MAAM,MAAM;AAAA,EAC1B;AAAA,EAEA,MAAM,MAAM,QAA8C;AACxD,UAAM,SAAS,MAAM,KAAK,kBAAkB;AAC5C,WAAO,OAAO,OAAO,EAAE,GAAG,QAAQ,QAAQ,UAAU,CAAC;AAAA,EACvD;AAAA,EAEA,MAAM,SAAS,WAAmB,QAAgD;AAChF,UAAM,SAAS,MAAM,KAAK,kBAAkB;AAC5C,WAAO,OAAO,SAAS,WAAW,MAAM;AAAA,EAC1C;AAAA,EAEA,MAAM,OAAO,WAA2E;AACtF,UAAM,SAAS,MAAM,KAAK,kBAAkB;AAC5C,WAAO,OAAO,OAAO,SAAS;AAAA,EAChC;AAAA,EAEA,MAAM,IAAI,WAAkD;AAC1D,UAAM,SAAS,MAAM,KAAK,kBAAkB;AAC5C,WAAO,OAAO,IAAI,SAAS;AAAA,EAC7B;AAAA,EAEA,MAAM,KAAK,QAAiE;AAC1E,UAAM,SAAS,MAAM,KAAK,kBAAkB;AAC5C,WAAO,OAAO,KAAK,MAAM;AAAA,EAC3B;AAAA,EAEA,MAAM,eAAgC;AACpC,UAAM,SAAS,MAAM,KAAK,kBAAkB;AAC5C,WAAO,OAAO,aAAa;AAAA,EAC7B;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agent-receipts/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript SDK for Agent Receipts — local-first action tracking",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Amin <amin@webaes.co> (https://webaes.co)",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/webaesbyamin/agent-receipts",
|
|
10
|
+
"directory": "packages/sdk"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/webaesbyamin/agent-receipts#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/webaesbyamin/agent-receipts/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"agent-receipts",
|
|
18
|
+
"sdk",
|
|
19
|
+
"ai-agents",
|
|
20
|
+
"action-tracking",
|
|
21
|
+
"receipts",
|
|
22
|
+
"verification",
|
|
23
|
+
"typescript"
|
|
24
|
+
],
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=20.0.0"
|
|
27
|
+
},
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"module": "./dist/index.mjs",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"import": "./dist/index.mjs",
|
|
35
|
+
"require": "./dist/index.js"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist"
|
|
40
|
+
],
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@agent-receipts/schema": "0.1.0",
|
|
43
|
+
"@agent-receipts/mcp-server": "0.1.0",
|
|
44
|
+
"@agent-receipts/crypto": "0.1.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/node": "^20.0.0",
|
|
48
|
+
"tsup": "^8.2.0",
|
|
49
|
+
"typescript": "^5.4.0",
|
|
50
|
+
"vitest": "^2.1.0"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsup",
|
|
54
|
+
"dev": "tsup --watch",
|
|
55
|
+
"test": "vitest run",
|
|
56
|
+
"typecheck": "tsc --noEmit"
|
|
57
|
+
}
|
|
58
|
+
}
|