/** * Helper that promotes the actions of an umbrella `Action` to virtual * top-level Actions. Each virtual action is named `_` * and delegates to the parent's handler with the discriminator value injected * into the parameters before dispatch. * * The parent umbrella stays registered alongside its virtuals so the planner * can still pick the umbrella directly with custom params. The helper also * records the virtuals on `parent.subActions`, so retrieval can index their * names/examples under the parent instead of ranking every virtual as an * unrelated top-level action. */ import type { Action, ActionExample, ActionParameter } from "../types/components.js"; export interface SubactionPromotionOverrides { /** Complete authored parameters for this operation, before discriminator * pinning. The parent and other operations keep their original contracts. */ parameters?: readonly ActionParameter[]; /** Operation-specific description for the virtual. The umbrella * description is not repeated in it; planner tool rendering states it once * per exposed family. */ description?: string; /** * Set the virtual action's compressed description — the short one-line * blurb the planner sees in tier-A / tier-B summaries. When unset, the * virtual has none and consumers fall back to its composed per-subaction * `description`; the parent's keyword-stuffed `descriptionCompressed` is * never inherited (duplicating it across every virtual floods the * planner's tool payload). */ descriptionCompressed?: string; /** Add similes specific to this virtual subaction. */ similes?: readonly string[]; /** Filter / replace examples used for the virtual. */ examples?: ActionExample[][]; } export interface PromoteSubactionsOptions { /** * Per-subaction overrides keyed by the subaction value (lowercased * canonical form, e.g. `list`, `create`). */ overrides?: Record; /** * Optional name prefix override. Defaults to `parent.name`. Use this if * the virtual `_` would collide with an existing top-level * action — e.g. pass `"LIFEOPS_MESSAGE"` if `MESSAGE_SEND` already exists * elsewhere. */ namePrefix?: string; /** * When true, the parent's `examples` are passed straight through to each * virtual instead of being filtered. Useful for umbrellas whose examples * already exercise multiple subactions. */ shareParentExamples?: boolean; } /** * The family context a promoted virtual's own description deliberately omits. * A virtual's `description` carries only its operation-specific text; the * umbrella description is stated once per tool list by planner tool rendering * (and composed back by canonical alias contracts) instead of once per virtual. */ export declare function promotedSubactionDescription(action: Action): { parent: string; parentDescription: string; subaction: string; operationDescription?: string; } | undefined; /** The pre-split composed text `${parentDescription} — ${blurb}` for a virtual. */ export declare function composedPromotedSubactionDescription(action: Action): string | undefined; /** * The umbrella parent's `routingHint` for a promoted virtual, carried on the * symbol promotion marker rather than on the virtual itself so tool * rendering (which prepends `routingHint` to each tool's description) never * duplicates it across every virtual. The planner's routing-hints block reads * it through this accessor and dedupes by parent, so a promoted family like * TRIGGER_* contributes exactly one hint line when any virtual is exposed. */ export declare function promotedParentRoutingHint(action: Action): { parent: string; hint: string; } | undefined; /** Returns the registered umbrella identity for a generated dispatch alias. */ export declare function promotedSubactionParent(action: Action): string | undefined; /** * The discriminator an umbrella call needs to run as one of its promoted * children without the sub-planner: the single-value enum that * `pinDiscriminatorForVirtual` left on the child's copy of the parent's * discriminator parameter. `undefined` unless `childName` is declared in * `parent.subActions` and resolves through the admitted `lookup` to a generated action of this parent * carrying such a pin, so a name that is not a promoted child of this umbrella * can never bypass sub-planner routing. */ export declare function pinnedDiscriminatorForPromotedChild(parent: Action, childName: string, lookup: (name: string) => Action | undefined): { child: string; discriminator: string; value: string; } | undefined; /** Reads the discriminator enum from action, subaction, op, operation, or verb. Returns an empty array when none is declared. */ export declare function listSubactionsFromParameters(parameters: readonly ActionParameter[] | undefined): readonly string[]; /** * Description a promoted virtual writes on its pinned discriminator. Exported * so the umbrella's alias-contract renderer (planned-tool.ts) can recognise * the pin and carry it as `pins[name] = value` instead of the full override. */ export declare function pinnedDiscriminatorDescription(subaction: string): string; /** * Promote each subaction of an umbrella action to a virtual top-level Action. * * Returns `[parent,...virtuals]`. The parent stays at index 0 so callers can * safely spread the result into a plugin's `actions: [...]` array. The parent * is annotated with the virtual names as `subActions`; virtual actions inject * the parent's structural discriminator into `options.parameters` before * delegating to the parent's handler. * * Calling this function twice on the same parent is idempotent: the second * call returns a freshly-built but structurally identical set of virtuals. */ export declare function promoteSubactionsToActions(parent: Action, options?: PromoteSubactionsOptions): readonly Action[]; /** * Returns true if the given action was produced by * {@link promoteSubactionsToActions}. Used by tests and tooling. */ export declare function isPromotedSubactionVirtual(action: Action): boolean;