تخطَّ إلى المحتوى

Components

A Greentic component is a portable WebAssembly component that implements Greentic’s component ABI and runs inside the Greentic runtime. Components are the executable building blocks called from flows: they render templates, call APIs, transform data, create Adaptive Cards, route work, and encapsulate custom business logic.

Components are:

  • Sandboxed - Runtime access is controlled through declared capabilities.
  • Portable - Built as WASI Preview 2 components.
  • Composable - Called from .ygtc flows and reusable across packs.
  • Schema-driven - Inputs, config, operations, and setup questions are described in generated metadata.
  • Agent-friendly - Coding agents can use the wizard schema and replay answers instead of hand-editing manifests and bindings.

The component docs are ordered by the surfaces most teams touch first:

Templates

Render deterministic Handlebars text from flow payloads and message envelopes.

Adaptive Cards

Store card JSON in packs, render and validate it, then deliver native or transformed UI through messaging extensions.

QA

Define setup, update, remove, and validation questions for components and extensions.

After those, the section covers existing components and tools such as fast2flow, cards2pack, flow2flow, component-llm-openai, and component-script-rhai.

Use the top-level launcher when the component is part of an application or extension pack:

Terminal window
gtc wizard --schema
gtc wizard --answers pack-with-component.answers.json

gtc wizard delegates to the pack wizard, and the pack wizard can delegate component creation through component_wizard_answers. This keeps the pack manifest, component files, flows, doctor checks, and build steps aligned.

Use the component wizard directly when you are working in a component project:

Terminal window
greentic-component wizard --schema
greentic-component wizard --answers component-create-answers.json

The current direct create answer shape is:

component-create-answers.json
{
"wizard_id": "greentic-component.wizard.run",
"schema_id": "greentic-component.wizard.run",
"schema_version": "1.0.0",
"answers": {
"mode": "create",
"fields": {
"component_name": "research-analyst",
"output_dir": "./components/research-analyst",
"advanced_setup": true,
"abi_version": "0.6.0",
"operation_names": "answer,score_sources",
"filesystem_mode": "none",
"http_client": true,
"http_server": false,
"messaging_inbound": true,
"messaging_outbound": true,
"events_inbound": false,
"events_outbound": false,
"secrets_enabled": true,
"secret_keys": "openai_api_key",
"secret_format": "text",
"state_read": true,
"state_write": true,
"state_delete": false,
"telemetry_scope": "node",
"config_fields": "model:string,temperature:number"
}
},
"locks": {}
}

Do not copy this blindly for future versions. Ask the agent or developer workflow to run greentic-component wizard --schema first and fill the current schema.

greentic-component wizard supports these modes:

ModePurpose
createScaffold a component project.
add-operationAdd a new user operation to an existing component.
update-operationRename or update operation metadata.
build-testRun build/test-oriented wizard steps.
doctorRun validation-oriented wizard steps.

Use validate for a no-side-effect plan and apply for execution:

Terminal window
greentic-component wizard validate --answers component-create-answers.json
greentic-component wizard apply --answers component-create-answers.json

The CLI also supports --emit-answers for capturing a reusable AnswerDocument.

The current Rust template generates a component project with Greentic conventions:

research-analyst/
├── Cargo.toml
├── component.manifest.json
├── Makefile
├── assets/
│ └── i18n/
│ ├── en.json
│ └── locales.json
├── schemas/
│ └── component.schema.json
├── src/
│ ├── i18n.rs
│ ├── i18n_bundle.rs
│ ├── lib.rs
│ └── qa.rs
└── tests/
└── conformance.rs

The generated files cover:

  • component operation scaffolding
  • component.manifest.json
  • ABI version metadata, currently 0.6.0 by default
  • config schema fields
  • host and WASI capability declarations
  • secret requirements
  • telemetry scope
  • QA specs and answer application hooks
  • i18n bundles and i18n key checks
  • build, test, and doctor wiring

Capabilities describe what the component may ask the runtime to provide. Declare only what the component actually needs:

CapabilityUse it when
HTTP clientThe component calls external APIs.
Messaging inbound/outboundThe component reads or emits channel message envelopes.
Events inbound/outboundThe component receives or emits event envelopes.
State read/write/deleteThe component stores session, tenant, or workflow state.
SecretsThe component needs runtime secrets such as API keys.
FilesystemThe component reads from or writes to a permitted filesystem mount.
TelemetryThe component emits spans/logs under tenant, pack, or node scope.
PageWhat it is for
TemplatesHandlebars text rendering with payload and msg context.
Adaptive CardsCard assets, rendering, validation, transformation, and complex card flows.
QAComponent setup/update/remove questions and answer validation.
fast2flowIntent routing and flow dispatch.
cards2packConvert Adaptive Card directories into pack assets and flows.
flow2flowFlow-to-flow routing patterns.
LLM OpenAILLM call patterns for OpenAI-compatible models.
Script RhaiLightweight script-style logic in flows.

From a wizard-generated component:

Terminal window
make wasm
greentic-component doctor ./dist/research-analyst__0_6_0.wasm

You can also call the component CLI directly:

Terminal window
greentic-component build --manifest ./component.manifest.json
greentic-component test \
--wasm ./dist/research-analyst__0_6_0.wasm \
--op answer \
--input ./tests/fixtures/answer.json
  1. Start with gtc wizard --schema or greentic-component wizard --schema.
  2. Replay answers with --answers so the work is reproducible.
  3. Keep operations small and explicit.
  4. Declare only the capabilities the component needs.
  5. Put setup questions and validation in QA, not in prose instructions.
  6. Use i18n keys for user-facing setup text.
  7. Run build, tests, and doctor before packaging.