greentic_runner_host/
component_api.rs

1pub mod component {
2    wasmtime::component::bindgen!({
3        inline: r#"
4        package greentic:component@0.4.0;
5
6        interface control {
7          should-cancel: func() -> bool;
8          yield-now: func();
9        }
10
11        interface node {
12          type json = string;
13
14          record tenant-ctx {
15            tenant: string,
16            team: option<string>,
17            user: option<string>,
18            trace-id: option<string>,
19            correlation-id: option<string>,
20            deadline-unix-ms: option<u64>,
21            attempt: u32,
22            idempotency-key: option<string>,
23          }
24
25          record exec-ctx {
26            tenant: tenant-ctx,
27            flow-id: string,
28            node-id: option<string>,
29          }
30
31          record node-error {
32            code: string,
33            message: string,
34            retryable: bool,
35            backoff-ms: option<u64>,
36            details: option<json>,
37          }
38
39          variant invoke-result {
40            ok(json),
41            err(node-error),
42          }
43
44          variant stream-event {
45            data(json),
46            progress(u8),
47            done,
48            error(string),
49          }
50
51          enum lifecycle-status { ok }
52
53          get-manifest: func() -> json;
54          on-start: func(ctx: exec-ctx) -> result<lifecycle-status, string>;
55          on-stop: func(ctx: exec-ctx, reason: string) -> result<lifecycle-status, string>;
56          invoke: func(ctx: exec-ctx, op: string, input: json) -> invoke-result;
57          invoke-stream: func(ctx: exec-ctx, op: string, input: json) -> list<stream-event>;
58        }
59
60        world component {
61          import control;
62          export node;
63        }
64        "#,
65        world: "component",
66    });
67}
68
69pub use component::Component;
70pub use component::ComponentPre;
71pub use component::exports::greentic::component::node;
72pub use component::greentic::component::control;