@reclaimprotocol/agent 0.1.1-dev.1 → 0.1.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/README.md +1 -1
- package/lib/cdp/capture-engine.d.ts +66 -0
- package/lib/cdp/capture-engine.js +153 -0
- package/lib/cdp/capture.d.ts +9 -20
- package/lib/cdp/capture.js +14 -138
- package/lib/cdp/index.d.ts +3 -0
- package/lib/cdp/index.js +6 -0
- package/lib/config/store.d.ts +7 -6
- package/lib/config/store.js +2 -2
- package/lib/index.d.ts +2 -2
- package/lib/index.js +1 -1
- package/lib/mcp/api/operations.gen.d.ts +101 -45
- package/lib/mcp/api/operations.gen.js +996 -126
- package/lib/mcp/api/to-zod.d.ts +24 -0
- package/lib/mcp/api/to-zod.js +94 -0
- package/lib/mcp/api/tools.js +1 -1
- package/lib/mcp/credentials/authenticate.d.ts +3 -0
- package/lib/mcp/{tools/credentials → credentials}/authenticate.js +3 -3
- package/lib/mcp/credentials/build.d.ts +5 -0
- package/lib/mcp/credentials/build.js +18 -0
- package/lib/mcp/{tools/credentials → credentials}/cache.d.ts +9 -9
- package/lib/mcp/{tools/credentials → credentials}/cache.js +36 -19
- package/lib/mcp/credentials/import.d.ts +2 -0
- package/lib/mcp/{tools/credentials → credentials}/import.js +2 -2
- package/lib/mcp/credentials/issue.d.ts +2 -0
- package/lib/mcp/{tools/credentials → credentials}/issue.js +4 -4
- package/lib/mcp/credentials/keypair.d.ts +17 -0
- package/lib/mcp/credentials/keypair.js +48 -0
- package/lib/mcp/credentials/link.d.ts +3 -0
- package/lib/mcp/credentials/link.js +107 -0
- package/lib/mcp/{tools/credentials → credentials}/list-cached.d.ts +1 -1
- package/lib/mcp/{tools/credentials → credentials}/list-cached.js +5 -5
- package/lib/mcp/credentials/owner-key.d.ts +23 -0
- package/lib/mcp/credentials/owner-key.js +58 -0
- package/lib/mcp/credentials/paths.d.ts +12 -0
- package/lib/mcp/credentials/paths.js +35 -0
- package/lib/mcp/credentials/poll.d.ts +27 -0
- package/lib/mcp/credentials/poll.js +61 -0
- package/lib/mcp/{tools/credentials → credentials}/resolve-owner-key.d.ts +1 -1
- package/lib/mcp/{tools/credentials → credentials}/resolve-owner-key.js +2 -2
- package/lib/mcp/credentials/session-cache.d.ts +14 -0
- package/lib/mcp/credentials/session-cache.js +42 -0
- package/lib/mcp/{tools/credentials → credentials}/status.d.ts +1 -1
- package/lib/mcp/credentials/status.js +76 -0
- package/lib/mcp/instructions.d.ts +1 -0
- package/lib/mcp/instructions.js +11 -0
- package/lib/mcp/register.d.ts +38 -0
- package/lib/mcp/register.js +80 -0
- package/lib/mcp/server.d.ts +2 -2
- package/lib/mcp/server.js +3 -3
- package/lib/mcp/start.js +10 -4
- package/lib/mcp/tools/agent/build.js +2 -15
- package/lib/mcp/tools/agent/index.d.ts +2 -0
- package/lib/mcp/tools/agent/index.js +3 -0
- package/lib/mcp/tools/agent/proof.js +1 -6
- package/lib/mcp/tools/agent/propose.js +13 -2
- package/lib/mcp/tools/agent/publish.js +10 -2
- package/lib/mcp/tools/agent/replay.js +0 -5
- package/lib/mcp/tools/analyze.d.ts +3 -0
- package/lib/mcp/tools/analyze.js +26 -0
- package/lib/mcp/tools/attach.d.ts +11 -0
- package/lib/mcp/tools/attach.js +72 -0
- package/lib/mcp/tools/authenticate/authenticate.js +107 -0
- package/lib/mcp/tools/authenticate/build.d.ts +15 -0
- package/lib/mcp/tools/authenticate/build.js +28 -0
- package/lib/mcp/tools/authenticate/decrypt-key.d.ts +32 -0
- package/lib/mcp/tools/authenticate/decrypt-key.js +49 -0
- package/lib/mcp/tools/authenticate/eth-key.d.ts +38 -0
- package/lib/mcp/tools/authenticate/eth-key.js +130 -0
- package/lib/mcp/tools/authenticate/import.js +57 -0
- package/lib/mcp/tools/authenticate/index.d.ts +2 -0
- package/lib/mcp/tools/authenticate/index.js +4 -0
- package/lib/mcp/tools/authenticate/issue.js +42 -0
- package/lib/mcp/tools/authenticate/resolve-owner-key.d.ts +13 -0
- package/lib/mcp/tools/authenticate/resolve-owner-key.js +53 -0
- package/lib/mcp/tools/capture.d.ts +10 -0
- package/lib/mcp/tools/capture.js +142 -0
- package/lib/mcp/tools/eval.d.ts +5 -0
- package/lib/mcp/tools/eval.js +127 -0
- package/lib/mcp/tools/find.d.ts +3 -0
- package/lib/mcp/tools/find.js +60 -0
- package/lib/mcp/tools/index.d.ts +3 -0
- package/lib/mcp/tools/index.js +6 -0
- package/lib/mcp/tools/owner-key.d.ts +2 -0
- package/lib/mcp/tools/owner-key.js +63 -0
- package/lib/mcp/tools/proof.d.ts +3 -0
- package/lib/mcp/tools/proof.js +214 -0
- package/lib/mcp/tools/propose.d.ts +9 -0
- package/lib/mcp/tools/propose.js +75 -0
- package/lib/mcp/tools/publish.d.ts +3 -0
- package/lib/mcp/tools/publish.js +59 -0
- package/lib/mcp/tools/replay.d.ts +3 -0
- package/lib/mcp/tools/replay.js +46 -0
- package/lib/mcp/tools/session.d.ts +10 -0
- package/lib/mcp/tools/session.js +29 -0
- package/lib/mcp/tools/verification/build.d.ts +12 -0
- package/lib/mcp/tools/verification/build.js +14 -0
- package/lib/mcp/tools/verification/diagnose.d.ts +11 -0
- package/lib/mcp/tools/verification/diagnose.js +132 -0
- package/lib/mcp/tools/verification/index.d.ts +1 -0
- package/lib/mcp/tools/verification/index.js +2 -0
- package/lib/mcp/tools/verification/result.d.ts +12 -0
- package/lib/mcp/tools/verification/result.js +126 -0
- package/lib/mcp/verifications/build.d.ts +5 -0
- package/lib/mcp/verifications/build.js +14 -0
- package/lib/mcp/verifications/create.d.ts +3 -0
- package/lib/mcp/verifications/create.js +57 -0
- package/lib/mcp/verifications/find.d.ts +3 -0
- package/lib/mcp/verifications/find.js +37 -0
- package/lib/mcp/verifications/get.d.ts +3 -0
- package/lib/mcp/verifications/get.js +26 -0
- package/lib/mcp/verifications/update.d.ts +3 -0
- package/lib/mcp/verifications/update.js +78 -0
- package/lib/old/client.d.ts +3 -0
- package/lib/old/instructions.d.ts +0 -6
- package/lib/old/instructions.js +6 -24
- package/lib/old/to-register.d.ts +3 -0
- package/lib/old/to-register.js +35 -7
- package/lib/old/tools/publish.js +13 -1
- package/lib/proof/attestor.d.ts +33 -1
- package/lib/proof/attestor.js +65 -63
- package/lib/proof/index.d.ts +5 -0
- package/lib/proof/index.js +6 -0
- package/lib/proof/proof-core.d.ts +35 -0
- package/lib/proof/proof-core.js +73 -0
- package/lib/provider/index.d.ts +5 -0
- package/lib/provider/index.js +9 -0
- package/lib/provider/to-version.d.ts +9 -12
- package/lib/provider/to-version.js +38 -4
- package/lib/provider/verification-checks.d.ts +12 -0
- package/lib/provider/verification-checks.js +30 -0
- package/lib/routes.gen.d.ts +271 -0
- package/lib/routes.gen.js +73 -0
- package/lib/types/openapi.gen.d.ts +3967 -0
- package/lib/types/openapi.gen.js +5 -0
- package/package.json +16 -7
- package/skill/SKILL.md +35 -14
- package/skill/builder-mode.md +9 -0
- package/skill/old-mode.md +13 -0
- package/src/cdp/capture-engine.ts +256 -0
- package/src/cdp/capture.ts +25 -185
- package/src/cdp/index.ts +6 -0
- package/src/config/store.ts +7 -6
- package/src/index.ts +2 -4
- package/src/mcp/api/operations.gen.ts +1023 -121
- package/src/mcp/api/to-zod.ts +115 -0
- package/src/mcp/api/tools.ts +9 -3
- package/src/mcp/instructions.ts +15 -0
- package/src/mcp/server.ts +5 -4
- package/src/mcp/start.ts +14 -4
- package/src/mcp/tools/agent/build.ts +2 -18
- package/src/mcp/tools/agent/index.ts +4 -0
- package/src/mcp/tools/agent/proof.ts +1 -7
- package/src/mcp/tools/agent/propose.ts +13 -2
- package/src/mcp/tools/agent/publish.ts +10 -2
- package/src/mcp/tools/agent/replay.ts +0 -5
- package/src/mcp/tools/{credentials → authenticate}/authenticate.ts +9 -8
- package/src/mcp/tools/authenticate/build.ts +32 -0
- package/src/mcp/tools/authenticate/decrypt-key.ts +64 -0
- package/src/mcp/tools/authenticate/eth-key.ts +182 -0
- package/src/mcp/tools/authenticate/import.ts +73 -0
- package/src/mcp/tools/authenticate/index.ts +4 -0
- package/src/mcp/tools/authenticate/issue.ts +50 -0
- package/src/mcp/tools/authenticate/resolve-owner-key.ts +60 -0
- package/src/mcp/tools/index.ts +6 -0
- package/src/mcp/tools/verification/build.ts +16 -0
- package/src/mcp/tools/verification/index.ts +2 -0
- package/src/mcp/tools/verification/result.ts +155 -0
- package/src/old/client.ts +3 -0
- package/src/old/instructions.ts +10 -25
- package/src/old/to-register.ts +62 -27
- package/src/old/tools/publish.ts +17 -1
- package/src/proof/attestor.ts +112 -71
- package/src/proof/index.ts +21 -0
- package/src/proof/proof-core.ts +109 -0
- package/src/provider/index.ts +20 -0
- package/src/provider/to-version.ts +52 -11
- package/src/provider/verification-checks.ts +36 -0
- package/lib/mcp/tools/credentials/build.d.ts +0 -16
- package/lib/mcp/tools/credentials/build.js +0 -33
- package/lib/mcp/tools/credentials/status.js +0 -62
- package/src/mcp/tools/credentials/build.ts +0 -37
- package/src/mcp/tools/credentials/cache.ts +0 -161
- package/src/mcp/tools/credentials/env-file.ts +0 -101
- package/src/mcp/tools/credentials/import.ts +0 -72
- package/src/mcp/tools/credentials/issue.ts +0 -107
- package/src/mcp/tools/credentials/list-cached.ts +0 -66
- package/src/mcp/tools/credentials/register.ts +0 -49
- package/src/mcp/tools/credentials/resolve-owner-key.ts +0 -78
- package/src/mcp/tools/credentials/status.ts +0 -82
- package/src/types/openapi.ts +0 -7
- /package/lib/mcp/{tools/credentials → credentials}/env-file.d.ts +0 -0
- /package/lib/mcp/{tools/credentials → credentials}/env-file.js +0 -0
- /package/lib/mcp/{tools/credentials → credentials}/register.d.ts +0 -0
- /package/lib/mcp/{tools/credentials → credentials}/register.js +0 -0
- /package/lib/mcp/tools/{credentials → authenticate}/authenticate.d.ts +0 -0
- /package/lib/mcp/tools/{credentials → authenticate}/import.d.ts +0 -0
- /package/lib/mcp/tools/{credentials → authenticate}/issue.d.ts +0 -0
- /package/lib/mcp/tools/{credentials → authenticate}/session-cache.d.ts +0 -0
- /package/lib/mcp/tools/{credentials → authenticate}/session-cache.js +0 -0
- /package/src/mcp/tools/{credentials → authenticate}/session-cache.ts +0 -0
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { generateKeypair } from '@reclaimprotocol/client'
|
|
2
|
-
import { findProjectRoot } from '../../../paths.ts'
|
|
3
|
-
import { defineTool, type RegisteredTool } from '../../server.ts'
|
|
4
|
-
import { findCredentialFromCachedBy } from './cache.ts'
|
|
5
|
-
import { persistCredentialLocally } from './register.ts'
|
|
6
|
-
|
|
7
|
-
export function issueTool(): RegisteredTool {
|
|
8
|
-
return defineTool<{
|
|
9
|
-
reuseCachedAppPk?: string
|
|
10
|
-
label?: string
|
|
11
|
-
projectDir?: string
|
|
12
|
-
writeEnv?: boolean
|
|
13
|
-
}>(
|
|
14
|
-
{
|
|
15
|
-
name: 'issue_credentials',
|
|
16
|
-
description:
|
|
17
|
-
'Mint a fresh anonymous Reclaim app key-pair (or reuse ' +
|
|
18
|
-
'a cached one via `reuseCachedAppPk`) and cache it locally. ' +
|
|
19
|
-
'By default also writes RECLAIM_PRIVATE_KEY to the project ' +
|
|
20
|
-
'.env (mode 0600) and appends .env to .gitignore; pass ' +
|
|
21
|
-
'`writeEnv: false` to keep it in the local cache (memory) ' +
|
|
22
|
-
'only and leave .env untouched. ALWAYS ask the dev whether ' +
|
|
23
|
-
'to save to .env before writing it. The key-pair is ' +
|
|
24
|
-
'generated locally and is NOT registered with the server — ' +
|
|
25
|
-
'anonymous credentials operate in SANDBOX mode entirely ' +
|
|
26
|
-
'client-side. PREFER REUSE over generating a new credential ' +
|
|
27
|
-
'unless the user explicitly asks for a new app identity. To ' +
|
|
28
|
-
'use a credential for verification in production, link it to ' +
|
|
29
|
-
'an organization (via link_credential) and add billing.',
|
|
30
|
-
inputSchema: {
|
|
31
|
-
type: 'object',
|
|
32
|
-
properties: {
|
|
33
|
-
reuseCachedAppPk: {
|
|
34
|
-
type: 'string',
|
|
35
|
-
pattern: '^0x[0-9a-fA-F]{40}$',
|
|
36
|
-
description:
|
|
37
|
-
'Lowercase ETH address of a cached credential ' +
|
|
38
|
-
'to reuse instead of minting a new one.',
|
|
39
|
-
},
|
|
40
|
-
label: {
|
|
41
|
-
type: 'string',
|
|
42
|
-
minLength: 1,
|
|
43
|
-
maxLength: 100,
|
|
44
|
-
description: 'Human label stored in the local cache.',
|
|
45
|
-
},
|
|
46
|
-
projectDir: {
|
|
47
|
-
type: 'string',
|
|
48
|
-
description:
|
|
49
|
-
'Project directory to write .env into. Defaults ' +
|
|
50
|
-
'to the closest ancestor of cwd containing ' +
|
|
51
|
-
'.git or package.json.',
|
|
52
|
-
},
|
|
53
|
-
writeEnv: {
|
|
54
|
-
type: 'boolean',
|
|
55
|
-
description:
|
|
56
|
-
'Write RECLAIM_PRIVATE_KEY to the project .env ' +
|
|
57
|
-
'(default true). Set false to cache the credential ' +
|
|
58
|
-
'in memory only, without touching .env.',
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
async(args) => {
|
|
64
|
-
const projectDir = findProjectRoot(args.projectDir || process.cwd())
|
|
65
|
-
let keypair: { address: string, privateKey: string } | undefined
|
|
66
|
-
let reused = false
|
|
67
|
-
|
|
68
|
-
if(args.reuseCachedAppPk) {
|
|
69
|
-
const cached = findCredentialFromCachedBy(args.reuseCachedAppPk)
|
|
70
|
-
if(!cached) {
|
|
71
|
-
throw new Error(
|
|
72
|
-
`No cached credential for ${args.reuseCachedAppPk}. ` +
|
|
73
|
-
'Call list_cached_credentials first.',
|
|
74
|
-
)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
keypair = {
|
|
78
|
-
address: cached.address,
|
|
79
|
-
privateKey: cached.privateKey,
|
|
80
|
-
}
|
|
81
|
-
reused = true
|
|
82
|
-
} else {
|
|
83
|
-
keypair = generateKeypair()
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const writeEnv = args.writeEnv ?? true
|
|
87
|
-
const persisted = persistCredentialLocally(
|
|
88
|
-
keypair,
|
|
89
|
-
args.label,
|
|
90
|
-
projectDir,
|
|
91
|
-
writeEnv,
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
return {
|
|
95
|
-
reused,
|
|
96
|
-
...persisted,
|
|
97
|
-
note: writeEnv
|
|
98
|
-
? 'Private key written to .env (and the local cache); it is ' +
|
|
99
|
-
'NOT in this response on purpose. The credential is ' +
|
|
100
|
-
'local-only (SANDBOX); link it to an org for production.'
|
|
101
|
-
: 'Private key cached in memory only (.env untouched). Sign ' +
|
|
102
|
-
'proofs with it by passing run_proof({ ownerAddress }). The ' +
|
|
103
|
-
'credential is local-only (SANDBOX).',
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
)
|
|
107
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { findProjectRoot } from '../../../paths.ts'
|
|
2
|
-
import { defineTool, type RegisteredTool } from '../../server.ts'
|
|
3
|
-
import { readCredentialsFromCache, suggestCredentialForDir } from './cache.ts'
|
|
4
|
-
|
|
5
|
-
export function listCachedTool(): RegisteredTool {
|
|
6
|
-
return defineTool<Record<string, never>>(
|
|
7
|
-
{
|
|
8
|
-
name: 'list_cached_credentials',
|
|
9
|
-
description:
|
|
10
|
-
'List Reclaim app credentials (ETH key-pairs) cached ' +
|
|
11
|
-
'locally in ~/.reclaim/config.json. Returns one ' +
|
|
12
|
-
'row per credential with address, optional label and ' +
|
|
13
|
-
'orgId, createdAt, createdIn (where it was first created), ' +
|
|
14
|
-
'and the project directories that have used it. Private keys ' +
|
|
15
|
-
'are stripped. The response also reports `currentDir` and ' +
|
|
16
|
-
'flags the best credential for it (`suggested`, plus ' +
|
|
17
|
-
'`suggestedAddress`/`suggestionReason`) — prefer reusing that ' +
|
|
18
|
-
'one over minting a new credential. When the cache is empty a ' +
|
|
19
|
-
'`suggestion` string explains how to create one.',
|
|
20
|
-
inputSchema: {
|
|
21
|
-
type: 'object',
|
|
22
|
-
properties: {},
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
async() => {
|
|
26
|
-
const doc = readCredentialsFromCache()
|
|
27
|
-
const currentDir = findProjectRoot(process.cwd())
|
|
28
|
-
const suggestion = suggestCredentialForDir(currentDir, doc.credentials)
|
|
29
|
-
const suggestedAddress = suggestion?.credential.address
|
|
30
|
-
|
|
31
|
-
const items = doc.credentials.map((c) => ({
|
|
32
|
-
address: c.address,
|
|
33
|
-
label: c.label,
|
|
34
|
-
orgId: c.orgId,
|
|
35
|
-
createdAt: c.createdAt,
|
|
36
|
-
createdIn: c.createdIn,
|
|
37
|
-
projectDirs: c.projectDirs,
|
|
38
|
-
matchesCurrentDir:
|
|
39
|
-
c.createdIn === currentDir || c.projectDirs.includes(currentDir),
|
|
40
|
-
suggested: c.address === suggestedAddress,
|
|
41
|
-
}))
|
|
42
|
-
|
|
43
|
-
// Promote the single suggested row to the top; stable sort keeps
|
|
44
|
-
// the rest in insertion (newest-first) order.
|
|
45
|
-
items.sort((a, b) => Number(b.suggested) - Number(a.suggested))
|
|
46
|
-
|
|
47
|
-
if(items.length === 0) {
|
|
48
|
-
return {
|
|
49
|
-
items,
|
|
50
|
-
currentDir,
|
|
51
|
-
suggestion:
|
|
52
|
-
'No cached credentials. Call issue_credentials to mint a new ' +
|
|
53
|
-
'app key-pair, or import_credentials if you already hold a ' +
|
|
54
|
-
'private key. Do not invent credentials.',
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return {
|
|
59
|
-
items,
|
|
60
|
-
currentDir,
|
|
61
|
-
suggestedAddress,
|
|
62
|
-
suggestionReason: suggestion?.reason,
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
)
|
|
66
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { EthKeypair } from '@reclaimprotocol/client'
|
|
2
|
-
import { type CachedCredential, upsertCredential } from './cache.ts'
|
|
3
|
-
import { type EnvWriteResult, writeAppCredentialsToEnv } from './env-file.ts'
|
|
4
|
-
|
|
5
|
-
/** Shape returned by `persistCredentialLocally` — the fields both
|
|
6
|
-
* `issue_credentials` and `import_credentials` expose in their MCP
|
|
7
|
-
* responses. The env-file fields are present only when the credential
|
|
8
|
-
* was persisted to `.env` (`writeEnv: true`); a memory-only credential
|
|
9
|
-
* lives in the cache and omits them. */
|
|
10
|
-
export type PersistedCredential = Pick<
|
|
11
|
-
CachedCredential,
|
|
12
|
-
'address' | 'label'
|
|
13
|
-
> &
|
|
14
|
-
Partial<EnvWriteResult> & { wroteEnv: boolean }
|
|
15
|
-
|
|
16
|
-
/** Local persistence step shared by `issue_credentials` and
|
|
17
|
-
* `import_credentials`. Always upserts the credentials cache; when
|
|
18
|
-
* `writeEnv` is true (default) it also writes `RECLAIM_PRIVATE_KEY` to
|
|
19
|
-
* the project `.env` (0600) and appends `.env` to `.gitignore`. Pass
|
|
20
|
-
* `writeEnv: false` to keep the credential in the cache (memory) only,
|
|
21
|
-
* without touching the project's `.env`. */
|
|
22
|
-
export function persistCredentialLocally(
|
|
23
|
-
keypair: EthKeypair,
|
|
24
|
-
label: string | undefined,
|
|
25
|
-
projectDir: string,
|
|
26
|
-
writeEnv = true,
|
|
27
|
-
): PersistedCredential {
|
|
28
|
-
const cached = upsertCredential({
|
|
29
|
-
address: keypair.address,
|
|
30
|
-
privateKey: keypair.privateKey,
|
|
31
|
-
label,
|
|
32
|
-
createdAt: new Date().toISOString(),
|
|
33
|
-
createdIn: projectDir,
|
|
34
|
-
projectDirs: [projectDir],
|
|
35
|
-
})
|
|
36
|
-
if(!writeEnv) {
|
|
37
|
-
return { address: cached.address, label: cached.label, wroteEnv: false }
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const env = writeAppCredentialsToEnv(projectDir, keypair.privateKey)
|
|
41
|
-
return {
|
|
42
|
-
address: cached.address,
|
|
43
|
-
label: cached.label,
|
|
44
|
-
wroteEnv: true,
|
|
45
|
-
envPath: env.envPath,
|
|
46
|
-
gitignorePath: env.gitignorePath,
|
|
47
|
-
gitignoreAppended: env.gitignoreAppended,
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { deriveFromPrivateKey } from '@reclaimprotocol/client'
|
|
2
|
-
import { findProjectRoot } from '../../../paths.ts'
|
|
3
|
-
import { defineTool, type RegisteredTool } from '../../server.ts'
|
|
4
|
-
import { suggestCredentialForDir } from './cache.ts'
|
|
5
|
-
import { readPrivateKeyFromEnvFile } from './env-file.ts'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Decide which app credential `run_proof` should sign with, BEFORE
|
|
9
|
-
* calling it. `run_proof` requires an `ownerAddress` and does no
|
|
10
|
-
* resolution of its own — this is the single place that "checks memory,
|
|
11
|
-
* env, etc and offers options".
|
|
12
|
-
*
|
|
13
|
-
* Checks, in order: `RECLAIM_PRIVATE_KEY` in the MCP env → the project
|
|
14
|
-
* `.env` → the best cached credential for this directory. Never returns
|
|
15
|
-
* the private key — only the address to pass through as `ownerAddress`.
|
|
16
|
-
*/
|
|
17
|
-
export function resolveOwnerKeyTool(): RegisteredTool {
|
|
18
|
-
return defineTool<Record<string, never>>(
|
|
19
|
-
{
|
|
20
|
-
name: 'resolve_owner_key',
|
|
21
|
-
description:
|
|
22
|
-
'Resolve which app credential run_proof should sign with — ' +
|
|
23
|
-
'call this BEFORE run_proof. Checks, in order: ' +
|
|
24
|
-
'RECLAIM_PRIVATE_KEY in the MCP env, RECLAIM_PRIVATE_KEY in the ' +
|
|
25
|
-
'project .env, then the best cached credential for this ' +
|
|
26
|
-
'directory. Returns { ready: true, address, source } when one ' +
|
|
27
|
-
'is available — pass `address` to run_proof as `ownerAddress`. ' +
|
|
28
|
-
'Returns { ready: false } when none exists: then ask the dev to ' +
|
|
29
|
-
'provide a private key (import_credentials) or create one ' +
|
|
30
|
-
'(issue_credentials) — optionally with writeEnv:false to keep ' +
|
|
31
|
-
'it in the local cache (memory) only — and call resolve_owner_key ' +
|
|
32
|
-
'again. Never exposes the private key.',
|
|
33
|
-
inputSchema: { type: 'object', properties: {} },
|
|
34
|
-
},
|
|
35
|
-
async() => {
|
|
36
|
-
const dir = findProjectRoot(process.cwd())
|
|
37
|
-
|
|
38
|
-
const envKey = process.env.RECLAIM_PRIVATE_KEY
|
|
39
|
-
if(envKey) {
|
|
40
|
-
return {
|
|
41
|
-
ready: true,
|
|
42
|
-
address: deriveFromPrivateKey(envKey).address,
|
|
43
|
-
source: 'env',
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const dotenvKey = readPrivateKeyFromEnvFile(dir)
|
|
48
|
-
if(dotenvKey) {
|
|
49
|
-
return {
|
|
50
|
-
ready: true,
|
|
51
|
-
address: deriveFromPrivateKey(dotenvKey).address,
|
|
52
|
-
source: 'dotenv',
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const suggestion = suggestCredentialForDir(dir)
|
|
57
|
-
if(suggestion) {
|
|
58
|
-
return {
|
|
59
|
-
ready: true,
|
|
60
|
-
address: suggestion.credential.address,
|
|
61
|
-
source: 'cache',
|
|
62
|
-
reason: suggestion.reason,
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return {
|
|
67
|
-
ready: false,
|
|
68
|
-
message:
|
|
69
|
-
'No app credential available (no RECLAIM_PRIVATE_KEY in env ' +
|
|
70
|
-
'or .env, and the cache is empty). Ask the dev to provide ' +
|
|
71
|
-
'their private key via import_credentials, or create one via ' +
|
|
72
|
-
'issue_credentials (pass writeEnv:false to keep it out of ' +
|
|
73
|
-
'.env). Then call resolve_owner_key again and pass its ' +
|
|
74
|
-
'address to run_proof as ownerAddress.',
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
)
|
|
78
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
deriveFromPrivateKey,
|
|
3
|
-
type ReclaimClient,
|
|
4
|
-
} from '@reclaimprotocol/client'
|
|
5
|
-
import assert from 'node:assert'
|
|
6
|
-
import { findProjectRoot } from '../../../paths.ts'
|
|
7
|
-
import { defineTool, type RegisteredTool } from '../../server.ts'
|
|
8
|
-
import { suggestCredentialForDir } from './cache.ts'
|
|
9
|
-
|
|
10
|
-
export function statusTool(client: ReclaimClient): RegisteredTool {
|
|
11
|
-
return defineTool<{ address?: string }>(
|
|
12
|
-
{
|
|
13
|
-
name: 'reclaim_status',
|
|
14
|
-
description:
|
|
15
|
-
'Report the live mode (SANDBOX | PRODUCTION | REVOKED) ' +
|
|
16
|
-
'of a Reclaim app credential. Pass `address` — or omit it ' +
|
|
17
|
-
'to derive the address from RECLAIM_PRIVATE_KEY, falling ' +
|
|
18
|
-
'back to the best cached credential for this directory. ' +
|
|
19
|
-
'Useful to confirm a credential is linked to an org ' +
|
|
20
|
-
'with billing before running a production flow.',
|
|
21
|
-
inputSchema: {
|
|
22
|
-
type: 'object',
|
|
23
|
-
properties: {
|
|
24
|
-
address: {
|
|
25
|
-
type: 'string',
|
|
26
|
-
pattern: '^0x[0-9a-fA-F]{40}$',
|
|
27
|
-
description:
|
|
28
|
-
'Lowercase ETH address. Defaults to the address ' +
|
|
29
|
-
'derived from RECLAIM_PRIVATE_KEY, then the cached ' +
|
|
30
|
-
'credential suggested for the current directory.',
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
async(args) => {
|
|
36
|
-
let address = args.address?.toLowerCase()
|
|
37
|
-
if(!address && process.env.RECLAIM_PRIVATE_KEY) {
|
|
38
|
-
address = deriveFromPrivateKey(process.env.RECLAIM_PRIVATE_KEY).address
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if(!address) {
|
|
42
|
-
address = suggestCredentialForDir(findProjectRoot(process.cwd()))
|
|
43
|
-
?.credential.address
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
assert(
|
|
47
|
-
address,
|
|
48
|
-
new Error(
|
|
49
|
-
'No address given, RECLAIM_PRIVATE_KEY is not set, and the ' +
|
|
50
|
-
'cache is empty. Run issue_credentials or import_credentials ' +
|
|
51
|
-
'first.',
|
|
52
|
-
)
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
const credResult = await client
|
|
56
|
-
.call('GetCredentialByAddress', { params: { address } })
|
|
57
|
-
const cred = credResult.data
|
|
58
|
-
|
|
59
|
-
// A registered credential always carries an `id`; its absence means
|
|
60
|
-
// the server had no row for this address — a local-only credential.
|
|
61
|
-
const localOnly = !cred.id
|
|
62
|
-
|
|
63
|
-
return {
|
|
64
|
-
address: cred.address,
|
|
65
|
-
mode: cred.mode,
|
|
66
|
-
orgId: cred.orgId,
|
|
67
|
-
label: cred.label,
|
|
68
|
-
revokedAt: cred.revokedAt,
|
|
69
|
-
lastUsedAt: cred.lastUsedAt,
|
|
70
|
-
...(localOnly ? {
|
|
71
|
-
note:
|
|
72
|
-
'Local-only credential — not registered with the server. '
|
|
73
|
-
+ 'It operates in SANDBOX, which is all you need to publish '
|
|
74
|
-
+ 'a verification (only an auth token is required — no '
|
|
75
|
-
+ 'credential link). Linking it to an org with billing (via '
|
|
76
|
-
+ 'link_credential) is only needed for the upcoming feature '
|
|
77
|
-
+ 'that runs verifications for your own app’s users.',
|
|
78
|
-
} : {}),
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
)
|
|
82
|
-
}
|
package/src/types/openapi.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { components } from '@reclaimprotocol/client'
|
|
2
|
-
|
|
3
|
-
export type CredentialAttachSession =
|
|
4
|
-
components['schemas']['CredentialAttachSession']
|
|
5
|
-
export type CreateProviderVersionRequest =
|
|
6
|
-
components['schemas']['CreateProviderVersionRequest']
|
|
7
|
-
export type ProviderVersionRef = components['schemas']['ProviderVersionRef']
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|