refactor(core): simplify location filesystem (#31545)
This commit is contained in:
parent
0777cf1ccf
commit
132ef57272
73 changed files with 1048 additions and 1416 deletions
|
|
@ -1,8 +1,7 @@
|
|||
import {
|
||||
ToolOutput as LLMToolOutput,
|
||||
ToolOutput,
|
||||
type LLMEvent,
|
||||
type ProviderMetadata,
|
||||
type ToolOutput as LLMToolOutputType,
|
||||
type ToolResultValue,
|
||||
type Usage,
|
||||
} from "@opencode-ai/llm"
|
||||
|
|
@ -45,13 +44,13 @@ const message = (value: unknown) => {
|
|||
}
|
||||
}
|
||||
|
||||
type ToolOutput =
|
||||
| { readonly structured: Record<string, unknown>; readonly content: LLMToolOutputType["content"] }
|
||||
type SettledOutput =
|
||||
| { readonly structured: Record<string, unknown>; readonly content: ToolOutput["content"] }
|
||||
| { readonly error: { readonly type: "unknown"; readonly message: string } }
|
||||
|
||||
const settledOutput = (value: LLMToolOutputType | undefined, result: ToolResultValue): ToolOutput => {
|
||||
const settledOutput = (value: ToolOutput | undefined, result: ToolResultValue): SettledOutput => {
|
||||
if (result.type === "error") return { error: { type: "unknown", message: message(result.value) } }
|
||||
const settled = value ?? LLMToolOutput.fromResultValue(result)
|
||||
const settled = value ?? ToolOutput.fromResultValue(result)
|
||||
if (!settled) throw new Error(`Unsupported tool result: ${message(result)}`)
|
||||
return { structured: record(settled.structured), content: settled.content }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,9 +38,8 @@ const toolCall = (tool: SessionMessage.AssistantTool, providerMetadata: Provider
|
|||
|
||||
const toolResult = (tool: SessionMessage.AssistantTool, providerMetadata: ProviderMetadata | undefined) => {
|
||||
if (tool.state.status === "completed") {
|
||||
// TODO: Materialize remote URL and managed file sources before provider-history lowering.
|
||||
// ToolOutput.toResultValue intentionally rejects unmaterialized sources rather than
|
||||
// guessing whether a provider can fetch them or leaking host-local resource paths.
|
||||
// TODO: Materialize remote and managed URIs before provider-history lowering.
|
||||
// ToolOutput.toResultValue rejects unresolved URIs rather than treating them as media bytes.
|
||||
const result =
|
||||
tool.provider?.executed === true && tool.state.result !== undefined
|
||||
? tool.state.result
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue