Enhance provider system with dynamic package resolution and improved logging

- Add npm registry lookup for AI SDK packages with fallback support
- Enhance error logging with cause information
- Add timing deltas to log output for performance monitoring

🤖 Generated with [opencode](https://opencode.ai)

Co-Authored-By: opencode <noreply@opencode.ai>
This commit is contained in:
Dax Raad
2025-06-14 14:32:45 -04:00
parent 0239761f31
commit 574d494c3c
5 changed files with 56 additions and 6 deletions

View File

@@ -29,7 +29,10 @@ export abstract class NamedError extends Error {
) {
super(name, options)
this.name = name
log.error(name, this.data)
log.error(name, {
...this.data,
cause: options?.cause?.toString(),
})
}
static isInstance(input: any): input is InstanceType<typeof result> {

View File

@@ -45,6 +45,7 @@ export namespace Log {
)
}
let last = Date.now()
export function create(tags?: Record<string, any>) {
tags = tags || {}
@@ -56,9 +57,13 @@ export namespace Log {
.filter(([_, value]) => value !== undefined && value !== null)
.map(([key, value]) => `${key}=${value}`)
.join(" ")
const next = new Date()
const diff = next.getTime() - last
last = next.getTime()
return (
[new Date().toISOString(), prefix, message].filter(Boolean).join(" ") +
"\n"
[next.toISOString().split(".")[0], "+" + diff + "ms", prefix, message]
.filter(Boolean)
.join(" ") + "\n"
)
}
const result = {