mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-03 07:33:45 +00:00
feat(id): brand PermissionID, PtyID, QuestionID, and ToolID (#17042)
This commit is contained in:
17
packages/opencode/src/tool/schema.ts
Normal file
17
packages/opencode/src/tool/schema.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { Schema } from "effect"
|
||||
import z from "zod"
|
||||
|
||||
import { Identifier } from "@/id/id"
|
||||
import { withStatics } from "@/util/schema"
|
||||
|
||||
const toolIdSchema = Schema.String.pipe(Schema.brand("ToolID"))
|
||||
|
||||
export type ToolID = typeof toolIdSchema.Type
|
||||
|
||||
export const ToolID = toolIdSchema.pipe(
|
||||
withStatics((schema: typeof toolIdSchema) => ({
|
||||
make: (id: string) => schema.makeUnsafe(id),
|
||||
ascending: (id?: string) => schema.makeUnsafe(Identifier.ascending("tool", id)),
|
||||
zod: Identifier.schema("tool").pipe(z.custom<ToolID>()),
|
||||
})),
|
||||
)
|
||||
@@ -7,6 +7,7 @@ import type { Agent } from "../agent/agent"
|
||||
import { Scheduler } from "../scheduler"
|
||||
import { Filesystem } from "../util/filesystem"
|
||||
import { Glob } from "../util/glob"
|
||||
import { ToolID } from "./schema"
|
||||
|
||||
export namespace Truncate {
|
||||
export const MAX_LINES = 2000
|
||||
@@ -90,7 +91,7 @@ export namespace Truncate {
|
||||
const unit = hitBytes ? "bytes" : "lines"
|
||||
const preview = out.join("\n")
|
||||
|
||||
const id = Identifier.ascending("tool")
|
||||
const id = ToolID.ascending()
|
||||
const filepath = path.join(DIR, id)
|
||||
await Filesystem.write(filepath, text)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user