-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Begin Migration to Standard Schema #221
base: main
Are you sure you want to change the base?
Begin Migration to Standard Schema #221
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not associated with the project, just stumbled across this so leaving some driveby comments!
// @ts-ignore | ||
const field = prompt.argsSchema.shape[request.params.argument.name]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a problem. The below line assumes that prompt.argsSchema
is a zod type. Shouldn't this rely on the json-schema somehow (though it's a bit more complicated, it looks like Completable
is an extension of zod that's internal.
At least it should be
// @ts-ignore | |
const field = prompt.argsSchema.shape[request.params.argument.name]; | |
const field = (prompt.argsSchema as ZodObject<ZodRawShape>)?.shape?.[request.params.argument.name]; |
And I guess standardised completable support could come later. Similar for the one below.
this._registeredPrompts[name] = { | ||
description, | ||
argsSchema: argsSchema === undefined ? undefined : z.object(argsSchema), | ||
argsSchema, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this could be non-breaking by doing
argsSchema, | |
argsSchema: argsSchema === undefined | |
? undefined | |
: argsSchema?.['~standard'] | |
? argsSchema | |
: z.object(argsSchema), |
And resurrecting PromptArgsRawShape
as ts union type input
Resolves #164
The aim of this PR is to utilize the
StandardSchemaV1
interface instead ofZodType
. This will allow for usage of other runtime type libraries, including Arktype, Effect Schema, Valibot and Typebox.Important note about this PR: in places that previously accepted a record of types, we must now supply a single object type of the given vendor.
This is important because we don't know how to turn a record containing unknown standard types into an object type of that same vendor (with which we derive the JSON schema). This is unfortunately a breaking change.
TODO:
Completable
utility (@jspahrsummers what is the recommended path forward here?)toJSONSchema
calls using aWeakMap
keyed by the runtime type.