@reclaimprotocol/agent 0.1.11 → 0.1.12
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/lib/old/client.d.ts +31 -0
- package/lib/old/client.js +33 -0
- package/lib/old/tools/build.js +12 -0
- package/lib/old/tools/check-app-status.d.ts +8 -0
- package/lib/old/tools/check-app-status.js +27 -0
- package/lib/old/tools/issue-app-credentials.d.ts +11 -0
- package/lib/old/tools/issue-app-credentials.js +35 -0
- package/lib/old/tools/js-sdk-integration-guide.d.ts +2 -0
- package/lib/old/tools/js-sdk-integration-guide.js +141 -0
- package/lib/old/tools/link-app.d.ts +10 -0
- package/lib/old/tools/link-app.js +72 -0
- package/lib/old/tools/publish.js +26 -6
- package/lib/old/tools/scaffold-demo-server.d.ts +2 -0
- package/lib/old/tools/scaffold-demo-server.js +242 -0
- package/lib/old/tools/verify-sdk-setup.d.ts +9 -0
- package/lib/old/tools/verify-sdk-setup.js +128 -0
- package/package.json +2 -1
- package/src/old/client.ts +60 -0
- package/src/old/tools/build.ts +12 -0
- package/src/old/tools/check-app-status.ts +33 -0
- package/src/old/tools/issue-app-credentials.ts +42 -0
- package/src/old/tools/js-sdk-integration-guide.ts +147 -0
- package/src/old/tools/link-app.ts +88 -0
- package/src/old/tools/publish.ts +30 -6
- package/src/old/tools/scaffold-demo-server.ts +265 -0
- package/src/old/tools/verify-sdk-setup.ts +158 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
2
|
+
import { join } from 'node:path'
|
|
3
|
+
import { defineTool, type RegisteredTool } from '../../mcp/server.ts'
|
|
4
|
+
import { findProjectRoot } from '../../paths.ts'
|
|
5
|
+
import type { ReclaimOldClient } from '../client.ts'
|
|
6
|
+
|
|
7
|
+
interface Check {
|
|
8
|
+
name: string
|
|
9
|
+
ok: boolean
|
|
10
|
+
detail: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function readEnvFile(dir: string): Record<string, string> {
|
|
14
|
+
const path = join(dir, '.env')
|
|
15
|
+
if(!existsSync(path)) {
|
|
16
|
+
return {}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const out: Record<string, string> = {}
|
|
20
|
+
for(const line of readFileSync(path, 'utf8').split('\n')) {
|
|
21
|
+
const m = line.match(/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*?)\s*$/)
|
|
22
|
+
if(m) {
|
|
23
|
+
out[m[1]] = m[2].replace(/^['"]|['"]$/g, '')
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return out
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Health-check a project's @reclaimprotocol/js-sdk setup: SDK installed,
|
|
32
|
+
* RECLAIM_APP_ID/RECLAIM_APP_SECRET present (env or .env), and (if an appId
|
|
33
|
+
* is found) whether that app is actually linked/has quota, via the real
|
|
34
|
+
* check_app_status endpoint — not just static file checks.
|
|
35
|
+
*/
|
|
36
|
+
export function verifySdkSetupTool(client: ReclaimOldClient): RegisteredTool {
|
|
37
|
+
return defineTool<{ projectDir?: string }>(
|
|
38
|
+
{
|
|
39
|
+
name: 'verify_reclaim_sdk_setup',
|
|
40
|
+
description:
|
|
41
|
+
'Health-check a project\'s @reclaimprotocol/js-sdk integration: SDK ' +
|
|
42
|
+
'installed, RECLAIM_APP_ID/RECLAIM_APP_SECRET present, and (if an ' +
|
|
43
|
+
'appId is found) whether that app is actually linked and has quota ' +
|
|
44
|
+
'left, by calling the real status endpoint.',
|
|
45
|
+
inputSchema: {
|
|
46
|
+
type: 'object',
|
|
47
|
+
properties: {
|
|
48
|
+
projectDir: {
|
|
49
|
+
type: 'string',
|
|
50
|
+
description: 'Project directory (default: detected project root).',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
async({ projectDir }) => {
|
|
56
|
+
const dir = projectDir ?? findProjectRoot(process.cwd())
|
|
57
|
+
const checks: Check[] = []
|
|
58
|
+
|
|
59
|
+
const pkgPath = join(dir, 'package.json')
|
|
60
|
+
let sdkInPkg = false
|
|
61
|
+
if(existsSync(pkgPath)) {
|
|
62
|
+
try {
|
|
63
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'))
|
|
64
|
+
sdkInPkg = Boolean(
|
|
65
|
+
pkg.dependencies?.['@reclaimprotocol/js-sdk'] ||
|
|
66
|
+
pkg.devDependencies?.['@reclaimprotocol/js-sdk'],
|
|
67
|
+
)
|
|
68
|
+
} catch{
|
|
69
|
+
// malformed package.json — fall through, reported below
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const sdkInstalled = existsSync(
|
|
74
|
+
join(dir, 'node_modules', '@reclaimprotocol', 'js-sdk'),
|
|
75
|
+
)
|
|
76
|
+
checks.push({
|
|
77
|
+
name: 'sdk_dependency',
|
|
78
|
+
ok: sdkInPkg,
|
|
79
|
+
detail: sdkInPkg
|
|
80
|
+
? '@reclaimprotocol/js-sdk is listed in package.json'
|
|
81
|
+
: '@reclaimprotocol/js-sdk is NOT in package.json — run ' +
|
|
82
|
+
'`npm install @reclaimprotocol/js-sdk`.',
|
|
83
|
+
})
|
|
84
|
+
checks.push({
|
|
85
|
+
name: 'sdk_installed',
|
|
86
|
+
ok: sdkInstalled,
|
|
87
|
+
detail: sdkInstalled
|
|
88
|
+
? '@reclaimprotocol/js-sdk found in node_modules'
|
|
89
|
+
: 'Not found in node_modules — run your package manager\'s ' +
|
|
90
|
+
'install command.',
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
const env = { ...readEnvFile(dir), ...process.env }
|
|
94
|
+
const appId = env.RECLAIM_APP_ID
|
|
95
|
+
const appSecret = env.RECLAIM_APP_SECRET
|
|
96
|
+
checks.push({
|
|
97
|
+
name: 'app_id',
|
|
98
|
+
ok: Boolean(appId),
|
|
99
|
+
detail: appId
|
|
100
|
+
? `RECLAIM_APP_ID set (${appId})`
|
|
101
|
+
: 'RECLAIM_APP_ID missing (env or .env) — run ' +
|
|
102
|
+
'issue_app_credentials or link_app_to_account.',
|
|
103
|
+
})
|
|
104
|
+
checks.push({
|
|
105
|
+
name: 'app_secret',
|
|
106
|
+
ok: Boolean(appSecret),
|
|
107
|
+
detail: appSecret
|
|
108
|
+
? 'RECLAIM_APP_SECRET set'
|
|
109
|
+
: 'RECLAIM_APP_SECRET missing (env or .env).',
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
// Informational only — PUBLIC_URL is only needed for the async
|
|
113
|
+
// webhook callback, not the frontend-only flow, so a missing value
|
|
114
|
+
// doesn't fail the overall check.
|
|
115
|
+
const publicUrl = env.PUBLIC_URL
|
|
116
|
+
checks.push({
|
|
117
|
+
name: 'public_url',
|
|
118
|
+
ok: true,
|
|
119
|
+
detail: publicUrl
|
|
120
|
+
? `PUBLIC_URL set (${publicUrl}) — used as the webhook callback ` +
|
|
121
|
+
'base for setAppCallbackUrl.'
|
|
122
|
+
: 'PUBLIC_URL not set — fine if you only read the proof from the ' +
|
|
123
|
+
'frontend flow, but the async webhook callback needs a ' +
|
|
124
|
+
'publicly-reachable URL (e.g. from `ngrok http <port>`) or it ' +
|
|
125
|
+
'will never fire.',
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
if(appId) {
|
|
129
|
+
try {
|
|
130
|
+
const status = await client.getApplicationStatus(appId) as {
|
|
131
|
+
isLinked?: boolean
|
|
132
|
+
sandboxMode?: boolean
|
|
133
|
+
available?: boolean
|
|
134
|
+
}
|
|
135
|
+
const linked = status?.isLinked === true
|
|
136
|
+
checks.push({
|
|
137
|
+
name: 'app_status',
|
|
138
|
+
ok: status?.available !== false,
|
|
139
|
+
detail:
|
|
140
|
+
`isLinked=${linked}, sandboxMode=${status?.sandboxMode}, ` +
|
|
141
|
+
`available=${status?.available}` +
|
|
142
|
+
(linked ? '' : ' — run link_app_to_account to lift the sandbox limit.'),
|
|
143
|
+
})
|
|
144
|
+
} catch(err) {
|
|
145
|
+
checks.push({
|
|
146
|
+
name: 'app_status',
|
|
147
|
+
ok: false,
|
|
148
|
+
detail: `Could not reach status endpoint: ${
|
|
149
|
+
err instanceof Error ? err.message : String(err)
|
|
150
|
+
}`,
|
|
151
|
+
})
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return { projectDir: dir, checks, ok: checks.every((c) => c.ok) }
|
|
156
|
+
},
|
|
157
|
+
)
|
|
158
|
+
}
|