Skip to content

Commit 7817262

Browse files
authored
chore: clean up types and registry validation (#3436)
* clean up types and registry validation * dont check in lock files
1 parent a5d7e9b commit 7817262

File tree

6 files changed

+30
-18
lines changed

6 files changed

+30
-18
lines changed

Diff for: .gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,6 @@ packages/*/dist/*
9797
**/dist/**
9898

9999
**/.docusaurus/**
100-
**/docs/build/**
100+
**/docs/build/**
101+
102+
**lock**

Diff for: bun.lockb

-1.31 MB
Binary file not shown.

Diff for: package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
"typedoc": "0.26.11",
3434
"typescript": "5.6.3",
3535
"vite": "5.4.12",
36-
"vitest": "3.0.5"
36+
"vitest": "3.0.5",
37+
"@types/bun": "latest"
3738
},
3839
"bun": {
3940
"overrides": {
@@ -63,5 +64,7 @@
6364
"packageManager": "[email protected]",
6465
"workspaces": [
6566
"packages/*"
66-
]
67-
}
67+
],
68+
"module": "index.ts",
69+
"type": "module"
70+
}

Diff for: packages/cli/src/commands/init.ts

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ async function setupEnvironment(targetDir: string, database: string) {
3737
}
3838

3939
async function selectPlugins() {
40-
const registry = await getRegistryIndex()
4140

4241
const clients = await listPluginsByType("client")
4342
const plugins = await listPluginsByType("plugin")

Diff for: packages/cli/src/utils/registry/index.ts

+20-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { registrySchema, type Registry, getPluginType } from "@/src/utils/regist
22
import { HttpsProxyAgent } from "https-proxy-agent"
33
import fetch from "node-fetch"
44
import { REGISTRY_URL } from "./constants"
5-
5+
import { z } from "zod"
66
const agent = process.env.https_proxy
77
? new HttpsProxyAgent(process.env.https_proxy)
88
: undefined
@@ -11,11 +11,20 @@ export async function getRegistryIndex(): Promise<Registry> {
1111
try {
1212
console.log("REGISTRY_URL", REGISTRY_URL)
1313
const response = await fetch(REGISTRY_URL, { agent })
14-
console.log("repsonse", response);
15-
const result = await response.json()
16-
console.log("result", result)
17-
return registrySchema.parse(result)
18-
} catch (error: any) {
14+
// Get the response body as text first
15+
const text = await response.text()
16+
17+
let registry: Registry
18+
try {
19+
// validate if the response is a valid registry
20+
registry = registrySchema.parse(JSON.parse(text))
21+
} catch {
22+
console.error("Invalid JSON response received from registry:", text)
23+
throw new Error("Registry response is not valid JSON")
24+
}
25+
26+
return registry
27+
} catch (error) {
1928
throw new Error(`Failed to fetch plugins from registry: ${error.message}`)
2029
}
2130
}
@@ -24,17 +33,16 @@ export async function getPluginRepository(pluginName: string): Promise<string |
2433
try {
2534
const registry = await getRegistryIndex()
2635
return registry[pluginName] || null
27-
} catch (error: any) {
36+
} catch (error) {
2837
throw new Error(`Failed to get plugin repository: ${error.message}`)
2938
}
3039
}
3140

3241
export async function listPluginsByType(type: "adapter" | "client" | "plugin"): Promise<string[]> {
3342
try {
3443
const registry = await getRegistryIndex()
35-
console.log(registry)
36-
return Object.keys(registry).filter(name => name.includes(type + "-"))
37-
} catch (error: any) {
44+
return Object.keys(registry).filter(name => name.includes(`${type}-`))
45+
} catch (error) {
3846
throw new Error(`Failed to list plugins: ${error.message}`)
3947
}
4048
}
@@ -44,8 +52,8 @@ export async function getAvailableDatabases(): Promise<string[]> {
4452
// const adapters = await listPluginsByType("adapter")
4553
// console.log(adapters)
4654
// return adapters.map(name => name.replace("@elizaos/adapter-", ""))
47-
return ["sqlite"]
48-
} catch (error: any) {
55+
return ["sqlite", "drizzle"]
56+
} catch (error) {
4957
throw new Error(`Failed to get available databases: ${error.message}`)
5058
}
5159
}

Diff for: packages/client/src/components/audio-recorder.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type Record = {
2727

2828
let recorder: MediaRecorder;
2929
let recordingChunks: BlobPart[] = [];
30-
let timerTimeout: NodeJS.Timeout;
30+
let timerTimeout: ReturnType<typeof setTimeout>;
3131

3232
// Utility function to pad a number with leading zeros
3333
const padWithLeadingZeros = (num: number, length: number): string => {

0 commit comments

Comments
 (0)