/// Alga extension runner component interfaces. /// Inspired by wasmCloud's capability providers, each interface here /// represents a host-provided capability that extensions can import. package alga:extension; /// Shared type definitions --------------------------------------------------- record context-data { request-id: option, tenant-id: string, extension-id: string, install-id: option, version-id: option, } enum secret-error { missing, denied, expired, internal, } record http-header { name: string, value: string, } record http-request { method: string, url: string, headers: list, body: option>, } record http-response { status: u16, headers: list, body: option>, } enum http-error { invalid-url, not-allowed, transport, internal, } enum storage-error { missing, conflict, denied, internal, } record storage-entry { namespace: string, key: string, value: list, revision: option, } enum proxy-error { route-not-found, denied, bad-request, internal, } record user-data { tenant-id: string, client-name: string, user-id: string, user-email: string, user-name: string, user-type: string, } record user-data-v2 { tenant-id: string, client-name: string, user-id: string, user-email: string, user-name: string, user-type: string, client-id: option, additional-fields: list>, } enum user-error { not-available, not-allowed, } enum client-read-error { not-allowed, invalid-input, internal, } record client-summary { client-id: string, client-name: string, client-type: option, is-inactive: bool, default-currency-code: option, account-manager-id: option, account-manager-name: option, billing-email: option, } record clients-list-input { search: option, include-inactive: option, page: option, page-size: option, } record clients-list-result { items: list, total-count: u32, page: u32, page-size: u32, } enum service-item-kind { service, product, } enum service-billing-method { fixed, hourly, usage, } enum service-read-error { not-allowed, invalid-input, internal, } record service-summary { service-id: string, service-name: string, item-kind: service-item-kind, billing-method: service-billing-method, service-type-id: option, service-type-name: option, default-rate: f64, unit-of-measure: string, is-active: bool, sku: option, } record services-list-input { search: option, item-kind: option, is-active: option, billing-method: option, page: option, page-size: option, } record services-list-result { items: list, total-count: u32, page: u32, page-size: u32, } /// Capability provider interfaces ------------------------------------------- /// Access execution context metadata. /// @requires(cap:context.read) interface context { get-context: func() -> context-data; } /// Retrieve install-scoped secrets. /// @requires(cap:secrets.get) interface secrets { get: func(key: string) -> result; list: func() -> list; } /// Perform outbound HTTP requests with host enforced allowlists. /// @requires(cap:http.fetch) interface http { fetch: func(request: http-request) -> result; } /// Work with host-backed key/value storage. /// @requires(cap:storage.kv) interface storage { get: func(namespace: string, key: string) -> result; put: func(entry: storage-entry) -> result; delete: func(namespace: string, key: string) -> result<(), storage-error>; list: func(namespace: string, cursor: option) -> result, storage-error>; } /// Emit structured log messages. /// @requires(cap:log.emit) interface logging { info: func(message: string); warn: func(message: string); error: func(message: string); } /// Invoke host-mediated proxy routes for UI flows. /// @requires(cap:ui.proxy) interface ui-proxy { call: func(route: string, payload: option>) -> result, proxy-error>; } /// Access current user information. /// @requires(cap:user.read) interface user { get-user: func() -> result; } /// Access current user information (v2 adds client-id and additional-fields). /// @requires(cap:user.read) interface user-v2 { get-user: func() -> result; } /// Read tenant-scoped client summaries. /// @requires(cap:client.read) interface clients { list-clients: func(input: clients-list-input) -> result; get-client: func(client-id: string) -> result, client-read-error>; } /// Read tenant-scoped service catalog summaries. /// @requires(cap:service.read) interface services { list-services: func(input: services-list-input) -> result; get-service: func(service-id: string) -> result, service-read-error>; } /// Guest exported HTTP-style handler entrypoint (initial contract). record execute-request { context: context-data, http: http-request, } record execute-response { status: u16, headers: list, body: option>, } /// World describing the Alga extension runtime contract. world runner { import context: interface context; import secrets: interface secrets; import http: interface http; import storage: interface storage; import logging: interface logging; import ui-proxy: interface ui-proxy; import user-v2: interface user-v2; import clients: interface clients; import services: interface services; export handler: func(request: execute-request) -> execute-response; }