# Building a Component

Create a tool in the component wizard, declare its typed ports, and let Perceivo check the script against them.

- Page: https://perceivo.ai/university/orch-05-building-a-component
- JSON: https://perceivo.ai/registry/film/orch-05-building-a-component.json
- Kind: film
- Revision: 3 (published 2026-10-18, produced 2026-10-15)
- Previous revision 1 (published 2026-10-07): https://perceivo.ai/registry/film/orch-05-building-a-component/r1.json
- Previous revision 2 (published 2026-10-11): https://perceivo.ai/registry/film/orch-05-building-a-component/r2.json
- SDK version: none

## Validation

- SDK: not applicable (UI walkthrough; no component or orchestration is offered for download)
- Platform: not applicable (UI walkthrough; no component or orchestration is offered for download)

## Transcript

[0:00] Introduction to Orchestrations, Episode 5: Building a Component
[0:06] Welcome back to our Introduction to Orchestrations series.
[0:09] Last time, we covered the component types, and the rules for connecting them.
[0:15] Now we'll build one: a small tool, with a typed contract that Perceivo checks before it can ever break a run.
[0:23] Every component in your organization lives here.
[0:26] You can import one from a file, or create one from scratch.
[0:30] Let's create one.
[0:32] The wizard has five steps: general details, ports, the script, who can use it, and validation.
[0:40] We'll give our tool a name, and a description our team will understand at a glance.
[0:45] We covered the component types last time.
[0:48] We're creating a tool.
[0:50] And we'll accept the default appearance.
[0:53] Ports are contracts.
[0:54] They guarantee what inputs a component accepts, and what outputs it provides.
[0:59] They're what makes components safe to snap together.
[1:04] A tool takes exactly one input port.
[1:06] We'll call it input.
[1:08] The request specifies what the tool expects to receive from its caller.
[1:12] The sender has to pass what your script requires, or your script will likely fail.
[1:17] That's why you declare the port in your manifest, to announce to the world what you will accept, and what you will return as a response.
[1:25] Perceivo validates those ports at the time the connection is made.
[1:29] But it also validates that your script implements what the manifest says, when you create the component.
[1:35] To illustrate how that works, we added a string field called text, to the request.
[1:41] And for the response, we promise to return an integer called word count.
[1:46] By the way, if you'd rather not use the form, all of this can be defined in a manifest.
[1:52] In this view, your ports are in a YAML format.
[1:56] If you develop locally, or use a coding agent, this is the form you are more likely to see these definitions in.
[2:03] But some people like the graphic interface, so we provide both options.
[2:09] With the interface defined, it's time for the business logic.
[2:13] The wizard can generate a starting script for the type.
[2:16] We'll replace the scaffold with our business logic.
[2:20] Notice the key parts.
[2:22] This wrapper means it extends the Tool class.
[2:25] It has a run function.
[2:27] That is required.
[2:28] It reads text, the field our port declared, and it returns response data.
[2:35] Every asset you create in Perceivo has its own permissions.
[2:39] Roles is where you assign them, to groups, users, and service accounts.
[2:45] Validation runs automatically when you reach the last step.
[2:49] It reads the script, and checks it against the manifest.
[2:53] And it caught something.
[2:55] The script returns a field called result, which our port never declared.
[3:00] And it never returns the word count the port promised.
[3:04] If the script and the contract disagree, you find out here, not halfway through a run.
[3:10] So we go back and fix it.
[3:11] We read the text from the request, count the words, and return the count.
[3:17] Notice the names: text and word count, exactly as the port declared them.
[3:22] Now the script and the contract agree.
[3:25] Validation passes, and we create the component.
[3:29] And here it is, listed with our other assets in the palette.
[3:33] Wherever you wire it in, the canvas checks that connection against this same contract.
[3:38] Everything the wizard just did, your coding agent can do with the SDK.
[3:43] It scaffolds the component, validates it, runs it locally, and exports a package you can import with the Perceivo API.
[3:52] And this structure works for your agent.
[3:55] No boilerplate cluttering its context.
[3:57] Less to hold in its head.
[3:59] It spends its attention on the problem, not the plumbing, and it performs more reliably.
[4:06] So: define the contract, write the script, and let validation prove they agree.
[4:12] That's a component you can rely on.
[4:15] Everything in this series is open source, with example components and every example that follows in the Perceivo SDK repository.
[4:25] Next time, we reuse work: whole orchestrations inside other orchestrations, and templates.
[4:32] See you there.
