@1claw/sdk 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/LICENSE +133 -0
- package/README.md +246 -0
- package/dist/access.d.ts +35 -0
- package/dist/access.d.ts.map +1 -0
- package/dist/access.js +52 -0
- package/dist/access.js.map +1 -0
- package/dist/agents.d.ts +41 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +61 -0
- package/dist/agents.js.map +1 -0
- package/dist/api-keys.d.ts +20 -0
- package/dist/api-keys.d.ts.map +1 -0
- package/dist/api-keys.js +25 -0
- package/dist/api-keys.js.map +1 -0
- package/dist/approvals.d.ts +45 -0
- package/dist/approvals.d.ts.map +1 -0
- package/dist/approvals.js +76 -0
- package/dist/approvals.js.map +1 -0
- package/dist/audit.d.ts +23 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/audit.js +41 -0
- package/dist/audit.js.map +1 -0
- package/dist/auth.d.ts +42 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +79 -0
- package/dist/auth.js.map +1 -0
- package/dist/billing.d.ts +17 -0
- package/dist/billing.d.ts.map +1 -0
- package/dist/billing.js +22 -0
- package/dist/billing.js.map +1 -0
- package/dist/chains.d.ts +25 -0
- package/dist/chains.d.ts.map +1 -0
- package/dist/chains.js +39 -0
- package/dist/chains.js.map +1 -0
- package/dist/client.d.ts +99 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +116 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +56 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +115 -0
- package/dist/errors.js.map +1 -0
- package/dist/http.d.ts +42 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +145 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/handler.d.ts +40 -0
- package/dist/mcp/handler.d.ts.map +1 -0
- package/dist/mcp/handler.js +216 -0
- package/dist/mcp/handler.js.map +1 -0
- package/dist/mcp/index.d.ts +3 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +3 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/tools.d.ts +29 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +236 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/org.d.ts +16 -0
- package/dist/org.d.ts.map +1 -0
- package/dist/org.js +21 -0
- package/dist/org.js.map +1 -0
- package/dist/secrets.d.ts +42 -0
- package/dist/secrets.d.ts.map +1 -0
- package/dist/secrets.js +48 -0
- package/dist/secrets.js.map +1 -0
- package/dist/sharing.d.ts +59 -0
- package/dist/sharing.d.ts.map +1 -0
- package/dist/sharing.js +69 -0
- package/dist/sharing.js.map +1 -0
- package/dist/types.d.ts +446 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/vault.d.ts +18 -0
- package/dist/vault.d.ts.map +1 -0
- package/dist/vault.js +30 -0
- package/dist/vault.js.map +1 -0
- package/dist/x402.d.ts +40 -0
- package/dist/x402.d.ts.map +1 -0
- package/dist/x402.js +129 -0
- package/dist/x402.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool dispatcher — routes incoming tool calls to the appropriate
|
|
3
|
+
* SDK methods and returns structured MCP-compatible results.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { createClient } from "@1claw/sdk";
|
|
8
|
+
* import { McpHandler } from "@1claw/sdk/mcp";
|
|
9
|
+
*
|
|
10
|
+
* const client = createClient({ ... });
|
|
11
|
+
* const handler = new McpHandler(client);
|
|
12
|
+
* const result = await handler.handle("1claw_get_secret", { vault_id: "...", key: "..." });
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export class McpHandler {
|
|
16
|
+
constructor(client) {
|
|
17
|
+
this.client = client;
|
|
18
|
+
this.handlers = new Map([
|
|
19
|
+
["1claw_get_secret", this.getSecret.bind(this)],
|
|
20
|
+
["1claw_set_secret", this.setSecret.bind(this)],
|
|
21
|
+
["1claw_list_secret_keys", this.listSecretKeys.bind(this)],
|
|
22
|
+
["1claw_delete_secret", this.deleteSecret.bind(this)],
|
|
23
|
+
["1claw_list_vaults", this.listVaults.bind(this)],
|
|
24
|
+
["1claw_create_vault", this.createVault.bind(this)],
|
|
25
|
+
["1claw_request_approval", this.requestApproval.bind(this)],
|
|
26
|
+
["1claw_check_approval_status", this.checkApproval.bind(this)],
|
|
27
|
+
["1claw_pay_and_fetch", this.payAndFetch.bind(this)],
|
|
28
|
+
["1claw_share_secret", this.shareSecret.bind(this)],
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
31
|
+
/** Dispatch a tool call by name. Throws if the tool name is unknown. */
|
|
32
|
+
async handle(toolName, args) {
|
|
33
|
+
const handler = this.handlers.get(toolName);
|
|
34
|
+
if (!handler) {
|
|
35
|
+
return {
|
|
36
|
+
content: [{ type: "text", text: `Unknown tool: ${toolName}` }],
|
|
37
|
+
isError: true,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
return await handler(args);
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
45
|
+
return {
|
|
46
|
+
content: [{ type: "text", text: `Error: ${message}` }],
|
|
47
|
+
isError: true,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** Return the set of tool names this handler supports. */
|
|
52
|
+
getToolNames() {
|
|
53
|
+
return Array.from(this.handlers.keys());
|
|
54
|
+
}
|
|
55
|
+
// -----------------------------------------------------------------------
|
|
56
|
+
// Tool implementations
|
|
57
|
+
// -----------------------------------------------------------------------
|
|
58
|
+
async getSecret(args) {
|
|
59
|
+
const vaultId = args.vault_id;
|
|
60
|
+
const key = args.key;
|
|
61
|
+
const reason = args.reason;
|
|
62
|
+
const res = await this.client.secrets.get(vaultId, key, { reason });
|
|
63
|
+
if (res.error) {
|
|
64
|
+
if (res.error.type === "approval_required") {
|
|
65
|
+
return this.text(JSON.stringify({
|
|
66
|
+
status: "pending_approval",
|
|
67
|
+
message: "Human approval is required to access this secret.",
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
return this.error(res.error.message);
|
|
71
|
+
}
|
|
72
|
+
return this.text(JSON.stringify({
|
|
73
|
+
status: "available",
|
|
74
|
+
id: res.data.id,
|
|
75
|
+
path: res.data.path,
|
|
76
|
+
type: res.data.type,
|
|
77
|
+
value: res.data.value,
|
|
78
|
+
version: res.data.version,
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
async setSecret(args) {
|
|
82
|
+
const vaultId = args.vault_id;
|
|
83
|
+
const key = args.key;
|
|
84
|
+
const value = args.value;
|
|
85
|
+
const type = args.type ?? "generic";
|
|
86
|
+
const res = await this.client.secrets.set(vaultId, key, value, {
|
|
87
|
+
type,
|
|
88
|
+
});
|
|
89
|
+
if (res.error)
|
|
90
|
+
return this.error(res.error.message);
|
|
91
|
+
return this.text(JSON.stringify({
|
|
92
|
+
status: "stored",
|
|
93
|
+
id: res.data.id,
|
|
94
|
+
path: res.data.path,
|
|
95
|
+
version: res.data.version,
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
async listSecretKeys(args) {
|
|
99
|
+
const vaultId = args.vault_id;
|
|
100
|
+
const prefix = args.prefix;
|
|
101
|
+
const res = await this.client.secrets.list(vaultId, prefix);
|
|
102
|
+
if (res.error)
|
|
103
|
+
return this.error(res.error.message);
|
|
104
|
+
const keys = res.data.secrets.map((s) => ({
|
|
105
|
+
path: s.path,
|
|
106
|
+
type: s.type,
|
|
107
|
+
version: s.version,
|
|
108
|
+
}));
|
|
109
|
+
return this.text(JSON.stringify({ status: "ok", keys }));
|
|
110
|
+
}
|
|
111
|
+
async deleteSecret(args) {
|
|
112
|
+
const vaultId = args.vault_id;
|
|
113
|
+
const key = args.key;
|
|
114
|
+
const res = await this.client.secrets.delete(vaultId, key);
|
|
115
|
+
if (res.error)
|
|
116
|
+
return this.error(res.error.message);
|
|
117
|
+
return this.text(JSON.stringify({ status: "deleted", path: key }));
|
|
118
|
+
}
|
|
119
|
+
async listVaults(_args) {
|
|
120
|
+
const res = await this.client.vault.list();
|
|
121
|
+
if (res.error)
|
|
122
|
+
return this.error(res.error.message);
|
|
123
|
+
const vaults = res.data.vaults.map((v) => ({
|
|
124
|
+
id: v.id,
|
|
125
|
+
name: v.name,
|
|
126
|
+
description: v.description,
|
|
127
|
+
}));
|
|
128
|
+
return this.text(JSON.stringify({ status: "ok", vaults }));
|
|
129
|
+
}
|
|
130
|
+
async createVault(args) {
|
|
131
|
+
const name = args.name;
|
|
132
|
+
const description = args.description;
|
|
133
|
+
const res = await this.client.vault.create({ name, description });
|
|
134
|
+
if (res.error)
|
|
135
|
+
return this.error(res.error.message);
|
|
136
|
+
return this.text(JSON.stringify({
|
|
137
|
+
status: "created",
|
|
138
|
+
id: res.data.id,
|
|
139
|
+
name: res.data.name,
|
|
140
|
+
}));
|
|
141
|
+
}
|
|
142
|
+
async requestApproval(args) {
|
|
143
|
+
const vaultId = args.vault_id;
|
|
144
|
+
const secretPath = args.secret_path;
|
|
145
|
+
const reason = args.reason;
|
|
146
|
+
const res = await this.client.approvals.request({
|
|
147
|
+
vault_id: vaultId,
|
|
148
|
+
secret_path: secretPath,
|
|
149
|
+
reason,
|
|
150
|
+
});
|
|
151
|
+
if (res.error)
|
|
152
|
+
return this.error(res.error.message);
|
|
153
|
+
return this.text(JSON.stringify({
|
|
154
|
+
status: "pending",
|
|
155
|
+
approval_request_id: res.data.id,
|
|
156
|
+
message: "Approval request submitted. Waiting for human review.",
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
159
|
+
async checkApproval(args) {
|
|
160
|
+
const requestId = args.request_id;
|
|
161
|
+
const res = await this.client.approvals.check(requestId);
|
|
162
|
+
if (res.error)
|
|
163
|
+
return this.error(res.error.message);
|
|
164
|
+
return this.text(JSON.stringify({
|
|
165
|
+
status: res.data.status,
|
|
166
|
+
decided_by: res.data.decided_by,
|
|
167
|
+
decided_at: res.data.decided_at,
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
async payAndFetch(args) {
|
|
171
|
+
const vaultId = args.vault_id;
|
|
172
|
+
const key = args.key;
|
|
173
|
+
const res = await this.client.x402.withPayment(vaultId, key);
|
|
174
|
+
if (res.error)
|
|
175
|
+
return this.error(res.error.message);
|
|
176
|
+
return this.text(JSON.stringify({
|
|
177
|
+
status: "paid_and_fetched",
|
|
178
|
+
id: res.data.id,
|
|
179
|
+
path: res.data.path,
|
|
180
|
+
type: res.data.type,
|
|
181
|
+
value: res.data.value,
|
|
182
|
+
version: res.data.version,
|
|
183
|
+
}));
|
|
184
|
+
}
|
|
185
|
+
async shareSecret(args) {
|
|
186
|
+
const secretId = args.secret_id;
|
|
187
|
+
const email = args.email;
|
|
188
|
+
const expiresAt = args.expires_at;
|
|
189
|
+
const maxAccessCount = args.max_access_count ?? 5;
|
|
190
|
+
const res = await this.client.sharing.create(secretId, {
|
|
191
|
+
recipient_type: "external_email",
|
|
192
|
+
email,
|
|
193
|
+
expires_at: expiresAt,
|
|
194
|
+
max_access_count: maxAccessCount,
|
|
195
|
+
});
|
|
196
|
+
if (res.error)
|
|
197
|
+
return this.error(res.error.message);
|
|
198
|
+
return this.text(JSON.stringify({
|
|
199
|
+
status: "shared",
|
|
200
|
+
share_id: res.data.id,
|
|
201
|
+
recipient_email: email,
|
|
202
|
+
expires_at: res.data.expires_at,
|
|
203
|
+
message: `Secret shared with ${email}. They will see it when they sign up or log in.`,
|
|
204
|
+
}));
|
|
205
|
+
}
|
|
206
|
+
// -----------------------------------------------------------------------
|
|
207
|
+
// Helpers
|
|
208
|
+
// -----------------------------------------------------------------------
|
|
209
|
+
text(text) {
|
|
210
|
+
return { content: [{ type: "text", text }] };
|
|
211
|
+
}
|
|
212
|
+
error(text) {
|
|
213
|
+
return { content: [{ type: "text", text }], isError: true };
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/mcp/handler.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,UAAU;IAGnB,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;QAC9C,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,CAAC;YACpB,CAAC,kBAAkB,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC/C,CAAC,kBAAkB,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC/C,CAAC,wBAAwB,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1D,CAAC,qBAAqB,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrD,CAAC,mBAAmB,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjD,CAAC,oBAAoB,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnD,CAAC,wBAAwB,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC3D,CAAC,6BAA6B,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC9D,CAAC,qBAAqB,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACpD,CAAC,oBAAoB,EAAE,IAAI,CAAC,WAAW,CAAC,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EAAE;YACnD,cAAc,EAAE,gBAAgB;YAChC,KAAK;YACL,UAAU,EAAE,SAAS;YACrB,gBAAgB,EAAE,cAAc;SACnC,CAAC,CAAC;QACH,IAAI,GAAG,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEpD,OAAO,IAAI,CAAC,IAAI,CACZ,IAAI,CAAC,SAAS,CAAC;YACX,MAAM,EAAE,QAAQ;YAChB,QAAQ,EAAE,GAAG,CAAC,IAAK,CAAC,EAAE;YACtB,eAAe,EAAE,KAAK;YACtB,UAAU,EAAE,GAAG,CAAC,IAAK,CAAC,UAAU;YAChC,OAAO,EAAE,sBAAsB,KAAK,iDAAiD;SACxF,CAAC,CACL,CAAC;IACN,CAAC;IAED,0EAA0E;IAC1E,UAAU;IACV,0EAA0E;IAElE,IAAI,CAAC,IAAY;QACrB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IACjD,CAAC;IAEO,KAAK,CAAC,IAAY;QACtB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAChE,CAAC;CACJ"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { McpHandler } from "./handler";
|
|
2
|
+
export { getMcpToolDefinitions, ALL_TOOLS, TOOL_GET_SECRET, TOOL_SET_SECRET, TOOL_LIST_SECRET_KEYS, TOOL_DELETE_SECRET, TOOL_LIST_VAULTS, TOOL_CREATE_VAULT, TOOL_REQUEST_APPROVAL, TOOL_CHECK_APPROVAL, TOOL_PAY_AND_FETCH, TOOL_SHARE_SECRET, } from "./tools";
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EACH,qBAAqB,EACrB,SAAS,EACT,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,GACpB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { McpHandler } from "./handler";
|
|
2
|
+
export { getMcpToolDefinitions, ALL_TOOLS, TOOL_GET_SECRET, TOOL_SET_SECRET, TOOL_LIST_SECRET_KEYS, TOOL_DELETE_SECRET, TOOL_LIST_VAULTS, TOOL_CREATE_VAULT, TOOL_REQUEST_APPROVAL, TOOL_CHECK_APPROVAL, TOOL_PAY_AND_FETCH, TOOL_SHARE_SECRET, } from "./tools";
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EACH,qBAAqB,EACrB,SAAS,EACT,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,GACpB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { McpToolDefinition } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* MCP tool definitions for AI agents (Claude, GPT, etc.) to interact
|
|
4
|
+
* with 1Claw vaults natively via function/tool calling.
|
|
5
|
+
*
|
|
6
|
+
* Usage with Vercel AI SDK:
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { getMcpToolDefinitions } from "@1claw/sdk/mcp";
|
|
9
|
+
* const tools = getMcpToolDefinitions();
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* Each definition includes a JSON Schema `inputSchema` that LLMs use
|
|
13
|
+
* to structure their tool-call arguments.
|
|
14
|
+
*/
|
|
15
|
+
export declare const TOOL_GET_SECRET: McpToolDefinition;
|
|
16
|
+
export declare const TOOL_SET_SECRET: McpToolDefinition;
|
|
17
|
+
export declare const TOOL_LIST_SECRET_KEYS: McpToolDefinition;
|
|
18
|
+
export declare const TOOL_DELETE_SECRET: McpToolDefinition;
|
|
19
|
+
export declare const TOOL_LIST_VAULTS: McpToolDefinition;
|
|
20
|
+
export declare const TOOL_CREATE_VAULT: McpToolDefinition;
|
|
21
|
+
export declare const TOOL_REQUEST_APPROVAL: McpToolDefinition;
|
|
22
|
+
export declare const TOOL_CHECK_APPROVAL: McpToolDefinition;
|
|
23
|
+
export declare const TOOL_PAY_AND_FETCH: McpToolDefinition;
|
|
24
|
+
export declare const TOOL_SHARE_SECRET: McpToolDefinition;
|
|
25
|
+
/** All MCP tool definitions for 1Claw. */
|
|
26
|
+
export declare const ALL_TOOLS: McpToolDefinition[];
|
|
27
|
+
/** Return all MCP tool definitions for use in agent tool registries. */
|
|
28
|
+
export declare function getMcpToolDefinitions(): McpToolDefinition[];
|
|
29
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,eAAe,EAAE,iBAyB7B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,iBA6B7B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,iBAmBnC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,iBAiBhC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,iBAU9B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,iBAiB/B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,iBAuBnC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,iBAejC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,iBAoBhC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,iBAgC/B,CAAC;AAEF,0CAA0C;AAC1C,eAAO,MAAM,SAAS,EAAE,iBAAiB,EAWxC,CAAC;AAEF,wEAAwE;AACxE,wBAAgB,qBAAqB,IAAI,iBAAiB,EAAE,CAE3D"}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool definitions for AI agents (Claude, GPT, etc.) to interact
|
|
3
|
+
* with 1Claw vaults natively via function/tool calling.
|
|
4
|
+
*
|
|
5
|
+
* Usage with Vercel AI SDK:
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { getMcpToolDefinitions } from "@1claw/sdk/mcp";
|
|
8
|
+
* const tools = getMcpToolDefinitions();
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* Each definition includes a JSON Schema `inputSchema` that LLMs use
|
|
12
|
+
* to structure their tool-call arguments.
|
|
13
|
+
*/
|
|
14
|
+
export const TOOL_GET_SECRET = {
|
|
15
|
+
name: "1claw_get_secret",
|
|
16
|
+
description: "Fetch a decrypted secret from a 1Claw vault. " +
|
|
17
|
+
"Returns the secret value if access is granted. " +
|
|
18
|
+
"May return a pending_approval status if human approval is required.",
|
|
19
|
+
inputSchema: {
|
|
20
|
+
type: "object",
|
|
21
|
+
properties: {
|
|
22
|
+
vault_id: {
|
|
23
|
+
type: "string",
|
|
24
|
+
description: "UUID of the vault containing the secret",
|
|
25
|
+
},
|
|
26
|
+
key: {
|
|
27
|
+
type: "string",
|
|
28
|
+
description: "Path/key of the secret within the vault",
|
|
29
|
+
},
|
|
30
|
+
reason: {
|
|
31
|
+
type: "string",
|
|
32
|
+
description: "Why the agent needs this secret (logged for audit)",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
required: ["vault_id", "key"],
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
export const TOOL_SET_SECRET = {
|
|
39
|
+
name: "1claw_set_secret",
|
|
40
|
+
description: "Store or update a secret in a 1Claw vault. " +
|
|
41
|
+
"The value is encrypted at rest using HSM-backed keys.",
|
|
42
|
+
inputSchema: {
|
|
43
|
+
type: "object",
|
|
44
|
+
properties: {
|
|
45
|
+
vault_id: {
|
|
46
|
+
type: "string",
|
|
47
|
+
description: "UUID of the vault to store the secret in",
|
|
48
|
+
},
|
|
49
|
+
key: {
|
|
50
|
+
type: "string",
|
|
51
|
+
description: "Path/key for the secret",
|
|
52
|
+
},
|
|
53
|
+
value: {
|
|
54
|
+
type: "string",
|
|
55
|
+
description: "The secret value to encrypt and store",
|
|
56
|
+
},
|
|
57
|
+
type: {
|
|
58
|
+
type: "string",
|
|
59
|
+
description: "Type hint (e.g. 'api_key', 'password', 'token', 'generic')",
|
|
60
|
+
default: "generic",
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
required: ["vault_id", "key", "value"],
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
export const TOOL_LIST_SECRET_KEYS = {
|
|
67
|
+
name: "1claw_list_secret_keys",
|
|
68
|
+
description: "List all secret keys in a vault WITHOUT revealing their values. " +
|
|
69
|
+
"Returns metadata only: path, type, version, and timestamps.",
|
|
70
|
+
inputSchema: {
|
|
71
|
+
type: "object",
|
|
72
|
+
properties: {
|
|
73
|
+
vault_id: {
|
|
74
|
+
type: "string",
|
|
75
|
+
description: "UUID of the vault to list secrets from",
|
|
76
|
+
},
|
|
77
|
+
prefix: {
|
|
78
|
+
type: "string",
|
|
79
|
+
description: "Optional prefix filter for secret paths",
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
required: ["vault_id"],
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
export const TOOL_DELETE_SECRET = {
|
|
86
|
+
name: "1claw_delete_secret",
|
|
87
|
+
description: "Permanently delete a secret from a 1Claw vault.",
|
|
88
|
+
inputSchema: {
|
|
89
|
+
type: "object",
|
|
90
|
+
properties: {
|
|
91
|
+
vault_id: {
|
|
92
|
+
type: "string",
|
|
93
|
+
description: "UUID of the vault containing the secret",
|
|
94
|
+
},
|
|
95
|
+
key: {
|
|
96
|
+
type: "string",
|
|
97
|
+
description: "Path/key of the secret to delete",
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
required: ["vault_id", "key"],
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
export const TOOL_LIST_VAULTS = {
|
|
104
|
+
name: "1claw_list_vaults",
|
|
105
|
+
description: "List all vaults accessible to the current identity. " +
|
|
106
|
+
"Returns vault names, descriptions, and IDs.",
|
|
107
|
+
inputSchema: {
|
|
108
|
+
type: "object",
|
|
109
|
+
properties: {},
|
|
110
|
+
required: [],
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
export const TOOL_CREATE_VAULT = {
|
|
114
|
+
name: "1claw_create_vault",
|
|
115
|
+
description: "Create a new encrypted vault in 1Claw.",
|
|
116
|
+
inputSchema: {
|
|
117
|
+
type: "object",
|
|
118
|
+
properties: {
|
|
119
|
+
name: {
|
|
120
|
+
type: "string",
|
|
121
|
+
description: "Human-readable vault name",
|
|
122
|
+
},
|
|
123
|
+
description: {
|
|
124
|
+
type: "string",
|
|
125
|
+
description: "Optional vault description",
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
required: ["name"],
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
export const TOOL_REQUEST_APPROVAL = {
|
|
132
|
+
name: "1claw_request_approval",
|
|
133
|
+
description: "Formally request human approval to access a gated secret. " +
|
|
134
|
+
"A notification is sent to the vault owner for review.",
|
|
135
|
+
inputSchema: {
|
|
136
|
+
type: "object",
|
|
137
|
+
properties: {
|
|
138
|
+
vault_id: {
|
|
139
|
+
type: "string",
|
|
140
|
+
description: "UUID of the vault containing the secret",
|
|
141
|
+
},
|
|
142
|
+
secret_path: {
|
|
143
|
+
type: "string",
|
|
144
|
+
description: "Path of the secret requiring approval",
|
|
145
|
+
},
|
|
146
|
+
reason: {
|
|
147
|
+
type: "string",
|
|
148
|
+
description: "Why the agent needs access to this secret",
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
required: ["vault_id", "secret_path"],
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
export const TOOL_CHECK_APPROVAL = {
|
|
155
|
+
name: "1claw_check_approval_status",
|
|
156
|
+
description: "Check the current status of a human approval request. " +
|
|
157
|
+
"Returns 'pending', 'approved', or 'denied'.",
|
|
158
|
+
inputSchema: {
|
|
159
|
+
type: "object",
|
|
160
|
+
properties: {
|
|
161
|
+
request_id: {
|
|
162
|
+
type: "string",
|
|
163
|
+
description: "UUID of the approval request to check",
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
required: ["request_id"],
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
export const TOOL_PAY_AND_FETCH = {
|
|
170
|
+
name: "1claw_pay_and_fetch",
|
|
171
|
+
description: "Pay the x402 micropayment fee and retrieve a secret. " +
|
|
172
|
+
"Use this when the free tier is exhausted and you need " +
|
|
173
|
+
"to pay for API access using USDC on Base.",
|
|
174
|
+
inputSchema: {
|
|
175
|
+
type: "object",
|
|
176
|
+
properties: {
|
|
177
|
+
vault_id: {
|
|
178
|
+
type: "string",
|
|
179
|
+
description: "UUID of the vault containing the secret",
|
|
180
|
+
},
|
|
181
|
+
key: {
|
|
182
|
+
type: "string",
|
|
183
|
+
description: "Path/key of the secret to fetch",
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
required: ["vault_id", "key"],
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
export const TOOL_SHARE_SECRET = {
|
|
190
|
+
name: "1claw_share_secret",
|
|
191
|
+
description: "Share a secret with another person by email. " +
|
|
192
|
+
"The recipient does NOT need a 1Claw account — they will see " +
|
|
193
|
+
"the shared secret when they sign up or log in. " +
|
|
194
|
+
"Use this to grant a human access to a credential.",
|
|
195
|
+
inputSchema: {
|
|
196
|
+
type: "object",
|
|
197
|
+
properties: {
|
|
198
|
+
secret_id: {
|
|
199
|
+
type: "string",
|
|
200
|
+
description: "UUID of the secret entry to share",
|
|
201
|
+
},
|
|
202
|
+
email: {
|
|
203
|
+
type: "string",
|
|
204
|
+
description: "Email address of the recipient",
|
|
205
|
+
},
|
|
206
|
+
expires_at: {
|
|
207
|
+
type: "string",
|
|
208
|
+
description: "ISO-8601 expiry date for the share (e.g. '2025-12-31T00:00:00Z')",
|
|
209
|
+
},
|
|
210
|
+
max_access_count: {
|
|
211
|
+
type: "number",
|
|
212
|
+
description: "Maximum number of times the secret can be accessed (default: 5)",
|
|
213
|
+
default: 5,
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
required: ["secret_id", "email", "expires_at"],
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
/** All MCP tool definitions for 1Claw. */
|
|
220
|
+
export const ALL_TOOLS = [
|
|
221
|
+
TOOL_GET_SECRET,
|
|
222
|
+
TOOL_SET_SECRET,
|
|
223
|
+
TOOL_LIST_SECRET_KEYS,
|
|
224
|
+
TOOL_DELETE_SECRET,
|
|
225
|
+
TOOL_LIST_VAULTS,
|
|
226
|
+
TOOL_CREATE_VAULT,
|
|
227
|
+
TOOL_REQUEST_APPROVAL,
|
|
228
|
+
TOOL_CHECK_APPROVAL,
|
|
229
|
+
TOOL_PAY_AND_FETCH,
|
|
230
|
+
TOOL_SHARE_SECRET,
|
|
231
|
+
];
|
|
232
|
+
/** Return all MCP tool definitions for use in agent tool registries. */
|
|
233
|
+
export function getMcpToolDefinitions() {
|
|
234
|
+
return ALL_TOOLS;
|
|
235
|
+
}
|
|
236
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +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AiB,GAAsB;IAChD,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EACP,+CAA+C;QAC/C,8DAA8D;QAC9D,iDAAiD;QACjD,mDAAmD;IACvD,WAAW,EAAE;QACT,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACR,SAAS,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,mCAAmC;aACnD;YACD,KAAK,EAAE;gBACH,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,gCAAgC;aAChD;YACD,UAAU,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EACP,kEAAkE;aACzE;YACD,gBAAgB,EAAE;gBACd,IAAI,EAAE,QAAQ;gBACd,WAAW,EACP,iEAAiE;gBACrE,OAAO,EAAE,CAAC;aACb;SACJ;QACD,QAAQ,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,YAAY,CAAC;KACjD;CACJ,CAAC;AAEF,0CAA0C;AAC1C,MAAM,CAAC,MAAM,SAAS,GAAwB;IAC1C,eAAe;IACf,eAAe;IACf,qBAAqB;IACrB,kBAAkB;IAClB,gBAAgB;IAChB,iBAAiB;IACjB,qBAAqB;IACrB,mBAAmB;IACnB,kBAAkB;IAClB,iBAAiB;CACpB,CAAC;AAEF,wEAAwE;AACxE,MAAM,UAAU,qBAAqB;IACjC,OAAO,SAAS,CAAC;AACrB,CAAC"}
|
package/dist/org.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HttpClient } from "./http";
|
|
2
|
+
import type { OrgMemberResponse, OrgMemberListResponse, UpdateMemberRoleRequest, OneclawResponse } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Org resource — manage organization membership and roles.
|
|
5
|
+
*/
|
|
6
|
+
export declare class OrgResource {
|
|
7
|
+
private readonly http;
|
|
8
|
+
constructor(http: HttpClient);
|
|
9
|
+
/** List all members of the current organization. */
|
|
10
|
+
listMembers(): Promise<OneclawResponse<OrgMemberListResponse>>;
|
|
11
|
+
/** Update a member's role (owner, admin, or member). */
|
|
12
|
+
updateMemberRole(userId: string, role: UpdateMemberRoleRequest["role"]): Promise<OneclawResponse<OrgMemberResponse>>;
|
|
13
|
+
/** Remove a member from the organization. */
|
|
14
|
+
removeMember(userId: string): Promise<OneclawResponse<void>>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=org.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"org.d.ts","sourceRoot":"","sources":["../src/org.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,EACR,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,eAAe,EAClB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,qBAAa,WAAW;IACR,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,oDAAoD;IAC9C,WAAW,IAAI,OAAO,CAAC,eAAe,CAAC,qBAAqB,CAAC,CAAC;IAOpE,wDAAwD;IAClD,gBAAgB,CAClB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,uBAAuB,CAAC,MAAM,CAAC,GACtC,OAAO,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC;IAQ9C,6CAA6C;IACvC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;CAGrE"}
|
package/dist/org.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Org resource — manage organization membership and roles.
|
|
3
|
+
*/
|
|
4
|
+
export class OrgResource {
|
|
5
|
+
constructor(http) {
|
|
6
|
+
this.http = http;
|
|
7
|
+
}
|
|
8
|
+
/** List all members of the current organization. */
|
|
9
|
+
async listMembers() {
|
|
10
|
+
return this.http.request("GET", "/v1/org/members");
|
|
11
|
+
}
|
|
12
|
+
/** Update a member's role (owner, admin, or member). */
|
|
13
|
+
async updateMemberRole(userId, role) {
|
|
14
|
+
return this.http.request("PATCH", `/v1/org/members/${userId}`, { body: { role } });
|
|
15
|
+
}
|
|
16
|
+
/** Remove a member from the organization. */
|
|
17
|
+
async removeMember(userId) {
|
|
18
|
+
return this.http.request("DELETE", `/v1/org/members/${userId}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=org.js.map
|
package/dist/org.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"org.js","sourceRoot":"","sources":["../src/org.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,OAAO,WAAW;IACpB,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,oDAAoD;IACpD,KAAK,CAAC,WAAW;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACpB,KAAK,EACL,iBAAiB,CACpB,CAAC;IACN,CAAC;IAED,wDAAwD;IACxD,KAAK,CAAC,gBAAgB,CAClB,MAAc,EACd,IAAqC;QAErC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACpB,OAAO,EACP,mBAAmB,MAAM,EAAE,EAC3B,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,CACrB,CAAC;IACN,CAAC;IAED,6CAA6C;IAC7C,KAAK,CAAC,YAAY,CAAC,MAAc;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAO,QAAQ,EAAE,mBAAmB,MAAM,EAAE,CAAC,CAAC;IAC1E,CAAC;CACJ"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { HttpClient } from "./http";
|
|
2
|
+
import type { SecretResponse, SecretMetadataResponse, SecretListResponse, OneclawResponse } from "./types";
|
|
3
|
+
export interface SetSecretOptions {
|
|
4
|
+
type?: string;
|
|
5
|
+
metadata?: Record<string, unknown>;
|
|
6
|
+
expires_at?: string;
|
|
7
|
+
rotation_policy?: Record<string, unknown>;
|
|
8
|
+
max_access_count?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface GetSecretOptions {
|
|
11
|
+
/** Reason for accessing this secret (logged in the audit trail). */
|
|
12
|
+
reason?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Secrets resource — store, retrieve, list, rotate, and delete secrets
|
|
16
|
+
* within a vault.
|
|
17
|
+
*/
|
|
18
|
+
export declare class SecretsResource {
|
|
19
|
+
private readonly http;
|
|
20
|
+
constructor(http: HttpClient);
|
|
21
|
+
/**
|
|
22
|
+
* Store or update a secret at the given path inside a vault.
|
|
23
|
+
* Returns the secret metadata (without the plaintext value).
|
|
24
|
+
*/
|
|
25
|
+
set(vaultId: string, key: string, value: string, options?: SetSecretOptions): Promise<OneclawResponse<SecretMetadataResponse>>;
|
|
26
|
+
/**
|
|
27
|
+
* Retrieve a decrypted secret value.
|
|
28
|
+
* May return a `PaymentRequiredError` (402) or `ApprovalRequiredError`
|
|
29
|
+
* depending on access policies.
|
|
30
|
+
*/
|
|
31
|
+
get(vaultId: string, key: string, _options?: GetSecretOptions): Promise<OneclawResponse<SecretResponse>>;
|
|
32
|
+
/** Delete a secret from a vault. */
|
|
33
|
+
delete(vaultId: string, key: string): Promise<OneclawResponse<void>>;
|
|
34
|
+
/** List secret keys (metadata only, no plaintext values). */
|
|
35
|
+
list(vaultId: string, prefix?: string): Promise<OneclawResponse<SecretListResponse>>;
|
|
36
|
+
/**
|
|
37
|
+
* Rotate a secret by writing a new value at the same path.
|
|
38
|
+
* This increments the version and overwrites the previous value.
|
|
39
|
+
*/
|
|
40
|
+
rotate(vaultId: string, key: string, newValue: string, options?: SetSecretOptions): Promise<OneclawResponse<SecretMetadataResponse>>;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=secrets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../src/secrets.ts"],"names":[],"mappings":"A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