refactor: clean up code formatting and update package dependencies

- Removed unnecessary blank lines and improved formatting for better readability in index.ts and converters.ts.
- Updated package-lock.json to downgrade several dependencies for compatibility, including @protobufjs/eventemitter, @protobufjs/fetch, and others.
- Enhanced error message in core.ts to clarify configuration options for the Command Code API key.
- Added a test to ensure the correct handling of environment variable values in test-stream.ts.
This commit is contained in:
wh.huajieyu
2026-05-28 06:23:28 -04:00
parent c2497ed098
commit e78875f532
6 changed files with 67 additions and 37 deletions
+15 -4
View File
@@ -39,7 +39,11 @@ export function numberValue(value: unknown): number | undefined {
}
function defaultAuthPaths(home: string): string[] {
return [join(home, ".commandcode", "auth.json"), join(home, ".omp", "agent", "auth.json"), join(home, ".pi", "agent", "auth.json")]
return [
join(home, ".commandcode", "auth.json"),
join(home, ".omp", "agent", "auth.json"),
join(home, ".pi", "agent", "auth.json"),
]
}
function apiKeyFromCredentialRecord(value: unknown): string | undefined {
@@ -288,7 +292,11 @@ export function mapFinishReason(reason: unknown): StopReason {
function promptPartToText(value: unknown, depth = 0): string {
if (depth > 10) return ""
if (typeof value === "string") return value
if (Array.isArray(value)) return value.map((v) => promptPartToText(v, depth + 1)).filter(Boolean).join("\n")
if (Array.isArray(value))
return value
.map((v) => promptPartToText(v, depth + 1))
.filter(Boolean)
.join("\n")
if (!isRecord(value)) return ""
const text = stringValue(value.text)
if (text) return text
@@ -300,7 +308,10 @@ function promptPartToText(value: unknown, depth = 0): string {
export function systemPromptToText(value: unknown): string {
if (value === undefined || value === null) return ""
if (typeof value === "string") return value
if (Array.isArray(value)) return value.map((v) => promptPartToText(v, 0)).filter(Boolean).join("\n\n")
if (Array.isArray(value))
return value
.map((v) => promptPartToText(v, 0))
.filter(Boolean)
.join("\n\n")
return promptPartToText(value, 0)
}