*/ public function schema(JsonSchema $schema): array { return []; } /** * Define the output schema for this tool's results. * * @return array */ public function outputSchema(JsonSchema $schema): array { return []; } /** * @return array */ public function toMethodCall(): array { return ['name' => $this->name()]; } /** * Get the tool's array representation. * * @return array{ * name: string, * title?: string|null, * description?: string|null, * inputSchema?: array, * outputSchema?: array, * annotations?: array|object, * _meta?: array * } */ public function toArray(): array { $annotations = $this->annotations(); $schema = JsonSchemaFactory::object( $this->schema(...), )->toArray(); $outputSchema = JsonSchemaFactory::object( $this->outputSchema(...), )->toArray(); $schema['properties'] ??= (object) []; $result = [ 'name' => $this->name(), 'title' => $this->title(), 'description' => $this->description(), 'inputSchema' => $schema, 'annotations' => $annotations === [] ? (object) [] : $annotations, ]; if (isset($outputSchema['properties'])) { $result['outputSchema'] = $outputSchema; } $rendersApp = $this->resolveAttribute(RendersApp::class); if ($rendersApp !== null) { /** @var AppResource $appResource */ $appResource = Container::getInstance()->make($rendersApp->resource); $this->setMeta('ui', [ 'resourceUri' => $appResource->uri(), 'visibility' => array_map(fn (Visibility $visiblity) => $visiblity->value, $rendersApp->visibility), ]); } // @phpstan-ignore return.type return $this->mergeMeta($result); } /** * @return array */ protected function allowedAnnotations(): array { return [ ToolAnnotation::class, ]; } }