import { type AstDocument, type CelSegment } from "@telorun/analyzer"; import type { ReplaceRange } from "../types.js"; export type { ReplaceRange }; export type CompletionCtx = { type: "kind"; /** Set for indented `kind:` lines. The enclosing docKind + the YAML * path to the parent of the `kind:` field (so the value slot's * schema node can be looked up to discover `x-telo-ref` constraints). * Absent for top-level `kind:` — there, no constraint applies. */ docKind?: string; yamlPath?: string[]; /** Full source range of the kind value, so a pick overwrites the whole * existing scalar (e.g. `Sql.Co|nnection` + `Sql.Connection` → no * suffix left behind). */ replaceRange: ReplaceRange; } | { type: "capability"; } | { type: "prop-key"; docKind: string; yamlPath: string[]; /** The same location with sequence indices kept, so a caller can find the * manifest node this slot sits in — what resolving an enclosing call's * reference needs. */ concretePath: string; docIndex: number; existingKeys: Set; } | { /** Cursor sits on the value of an object-form ref's `name:` field * (e.g. `connection: { kind: Sql.Connection, name: |}`). Editor hosts * use `refKind` (from the sibling `kind:` line) to filter the in-doc * resource list to matching candidates. */ type: "ref-name"; docKind: string; /** YAML path to the parent slot (e.g. `["connection"]`). The schema * at this path declares the `x-telo-ref` constraint. */ yamlPath: string[]; /** The kind value of the sibling `kind:` line, if present. */ refKind?: string; prefix: string; replaceRange: ReplaceRange; } | { type: "field-value"; docKind: string; field: string; /** Text from the start of the value to the cursor. */ prefix: string; /** Full source range of the value being completed. */ replaceRange: ReplaceRange; } | { /** Cursor sits on an ordinary field VALUE whose schema declares the values * it may take — `enum` (closed) or `examples` (open). Untargeted on * purpose: every value slot resolves here and the ones declaring neither * simply offer nothing. */ type: "value-suggestions"; docKind: string; /** Path from the document root to the field, so its schema can be found. */ yamlPath: string[]; replaceRange: ReplaceRange; } | { /** Cursor sits inside a CEL body — closed or still open (`!cel "req.|`). * What completes is decided by the scope the analyzer resolves for this * site, so the host must supply a `CelScopeQuery`; without one the * candidate list would be a guess rather than a claim about what * `telo check` accepts, and nothing is offered. */ type: "cel"; docKind?: string; /** Which `---` document the cursor is in, so the host can name the * resource this expression belongs to. */ docIndex: number; /** The site's address with sequence indices kept — what the scope is * resolved at. */ concretePath: string; segment: CelSegment; /** Cursor as a document offset. */ offset: number; }; /** * Resolves an `x-telo-schema-from` annotation to the schema it derives. Supplied * by the caller because the anchor is alias-qualified and only the registry can * resolve it in the declaring kind's module scope. */ export type SchemaFromResolver = (schemaFrom: string) => Record | undefined; /** Navigate a JSON Schema hierarchy following `path`, auto-descending into * array items, peeling `anyOf` / `oneOf` branches, following document-local * `$ref`s and expanding `x-telo-schema-from` slots. When multiple peeled * branches define `properties`, returns a synthetic node whose `properties` is * the union (first-wins on key collision) and whose `required` is the * intersection — enough for propKeyCompletions to surface every key a value at * this slot can legally carry. */ export declare function navigateSchema(schema: Record, path: string[], schemaFrom?: SchemaFromResolver): Record | undefined; /** Walks up and down from `cursorLine` looking for a sibling line at the * exact same indent whose key is `kind`. The value of the first such line * is returned (alias form, e.g. `"Sql.Connection"`). Used by ref-name * completion to discover what kind of resource the user is targeting in an * object-form ref. Walking stops at the first line with a strictly smaller * indent (that's the parent's structural boundary). */ /** Every kind the `x-telo-ref` slot at `yamlPath` accepts, or an empty array * when the path doesn't resolve or declares no constraint. * * All of them, not the first: a slot accepting `Invocable | Runnable` used to * complete only the invocables, because a single-constraint lookup stopped at * the first branch. The analyzer's accessor unions a `kind:` list and the * `anyOf` / `oneOf` branches alike, so completion now offers what the slot * actually takes. */ export declare function lookupRefConstraints(definitionSchema: Record, yamlPath: string[], schemaFrom?: SchemaFromResolver): string[]; /** Derive a `CompletionCtx` from the AST-resolved cursor (Approach B). The * structural resolution lives in `resolveNodeAtPosition`; this only maps a * resolved slot onto the completion the editor should offer. `docs` lets a * host thread its already-parsed AST; without it we parse locally so this * stands alone. */ export declare function detectContext(text: string, line: number, character: number, docs?: AstDocument[]): CompletionCtx | undefined; //# sourceMappingURL=detect-context.d.ts.map