Presentation
What the ways to present a toolkit to a model share, such as ToolSearch and CodeMode: each
takes the toolkit a host assembled, which is the model’s to use, and gives another, whose tools
the model calls to reach the first. A tool of the presented toolkit runs as it does when a model
calls it directly, so what it checks, what it fails with, and whether it needs approval stay as
they are.
Since v0.1.0
Constructors
Section titled “Constructors”failure
Section titled “failure”What the model reads of a failure that no tool gave, such as a name that is no tool’s. It is not worth trying again.
Signature
declare const failure: (code: string, message: string) => ToolSource.FailureSince v0.1.0
A toolkit of the tools of both, whose names are the tools’ own, which run as they do in the
toolkit they come from. A name that both have is first’s.
Example (The host’s own tools beside a workspace’s sources)
import { Assembly, Presentation } from "@amends-dev/toolkit"import { Effect, Schema } from "effect"import { Tool, Toolkit } from "effect/ai"
const Remember = Tool.make("remember", { description: "Keeps a note for later turns", parameters: Schema.Struct({ note: Schema.String }), success: Schema.Void})const Own = Toolkit.make(Remember)
declare const members: ReadonlyArray<Assembly.Member>
const program = Effect.gen(function* () { const own = yield* Own.pipe(Effect.provide(Own.toLayer({ remember: () => Effect.void }))) const assembled = yield* Assembly.toolkit(members, () => "allow") // `remember` runs as the host wrote it, and `github__create_issue` as its source does. return Presentation.merge(own, assembled)})Signature
declare const merge: <First extends Record<string, Tool.Any>, Second extends Record<string, Tool.Any>>( first: Toolkit.WithHandler<First>, second: Toolkit.WithHandler<Second>) => Toolkit.WithHandler<Toolkit.MergeRecords<First | Second>>Since v0.1.0
restrict
Section titled “restrict”A toolkit of the tools of presented that names names, which run as they do in presented. It
is typed as presented is, since its tools are among presented’s.
Signature
declare const restrict: <Tools extends Record<string, Tool.Any>>( presented: Toolkit.WithHandler<Tools>, names: ReadonlySet<string>) => Toolkit.WithHandler<Tools>Since v0.1.0
Getters
Section titled “Getters”inputSchemaOf
Section titled “inputSchemaOf”The tool’s parameters, as a JSON Schema with an object root, as a model is shown them. A tool whose parameters are not an object is shown an object with no properties.
Signature
declare const inputSchemaOf: (tool: Tool.Any) => Schema.JsonObjectSince v0.1.0
Predicates
Section titled “Predicates”hasTool
Section titled “hasTool”Whether presented has a tool named name, with the name as the type of one.
Signature
declare const hasTool: <Tools extends Record<string, Tool.Any>>( presented: Toolkit.WithHandler<Tools>, name: string) => name is Extract<keyof Tools, string>Since v0.1.0
Running
Section titled “Running”Runs the tool of presented named name with input, and returns its result as JSON. What the
tool fails with, as its handler or its parameters, fails as a Failure, a result the model reads.
Signature
declare const call: <Tools extends Record<string, Tool.Any>>( presented: Toolkit.WithHandler<Tools>, name: Extract<keyof Tools, string>, input: Schema.JsonObject) => Effect.Effect<Schema.Json, ToolSource.Failure, Tool.HandlerServices<Tools[Extract<keyof Tools, string>]>>Since v0.1.0