fix(core): expose filesystem failures
This commit is contained in:
parent
82d9cab48d
commit
e8d632834c
5 changed files with 76 additions and 21 deletions
|
|
@ -1,9 +1,25 @@
|
|||
import type { FileSystemEntry } from "@opencode-ai/sdk/v2/types"
|
||||
import type { Effect } from "effect"
|
||||
import type { PlatformError } from "effect/PlatformError"
|
||||
|
||||
export type FileSystemError =
|
||||
| PlatformError
|
||||
| {
|
||||
readonly _tag: "FileSystemError"
|
||||
readonly method: string
|
||||
readonly cause?: unknown
|
||||
}
|
||||
| {
|
||||
readonly _tag: "FileSystem.PathError"
|
||||
readonly path: string
|
||||
readonly reason: "lexical_escape" | "symlink_escape" | "not_file" | "not_directory"
|
||||
}
|
||||
|
||||
export interface FileSystem {
|
||||
read(input: { readonly path: string }): Effect.Effect<{ readonly content: Uint8Array; readonly mime: string }>
|
||||
list(input?: { readonly path?: string }): Effect.Effect<FileSystemEntry[]>
|
||||
read(input: {
|
||||
readonly path: string
|
||||
}): Effect.Effect<{ readonly content: Uint8Array; readonly mime: string }, FileSystemError>
|
||||
list(input?: { readonly path?: string }): Effect.Effect<FileSystemEntry[], FileSystemError>
|
||||
find(input: {
|
||||
readonly query: string
|
||||
readonly type?: "file" | "directory"
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ export type { AISDK, AISDKHooks } from "./aisdk.js"
|
|||
export type { Catalog, CatalogDraft, CatalogProviderRecord } from "./catalog.js"
|
||||
export type { Command, CommandDraft } from "./command.js"
|
||||
export type { Event, EventMap } from "./event.js"
|
||||
export type { FileSystem } from "./filesystem.js"
|
||||
export type { FileSystem, FileSystemError } from "./filesystem.js"
|
||||
export type { Integration, IntegrationDraft, IntegrationMethod, IntegrationMethodRegistration } from "./integration.js"
|
||||
export type { Location } from "./location.js"
|
||||
export type { Npm } from "./npm.js"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue