@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
33 lines • 1.6 kB
TypeScript
/**
* `Endpoint` split and the URL secret marking rule (custody design 4.1, row CK5).
*
* A provider `baseUrl` is split into its public parts, which travel as plain config, and its
* secret parts, which are sealed one field each. Secret iff: `userinfo` (always); a path segment
* or query value that is templated (`!command` or a `$VAR` reference, senpi's own template
* syntax); a part the user listed in `secretUrlParts`; or a query value whose NAME is key-ish.
* The key-ish list decides what is sealed, never the source digest.
*/
export type UrlSecretField = "urlUserinfo" | `urlPath:${number}` | `urlQuery:${string}`;
export type MarkableUrlPart = `urlPath:${number}` | `urlQuery:${string}`;
export interface SecretUrlPart {
readonly secret: true;
}
export interface Endpoint {
readonly scheme: "http" | "https";
readonly host: string;
readonly port?: number;
readonly path: readonly (string | SecretUrlPart)[];
readonly query?: Readonly<Record<string, string | SecretUrlPart>>;
readonly userinfo?: true;
}
export type EndpointSplit = {
readonly ok: true;
readonly endpoint: Endpoint;
readonly secrets: ReadonlyMap<UrlSecretField, string>;
} | {
readonly ok: false;
readonly reason: "unparseable" | "scheme" | "fragment" | "duplicate-query" | "valueless-query";
};
export declare function splitEndpoint(baseUrl: string, secretUrlParts?: readonly MarkableUrlPart[]): EndpointSplit;
export declare function composeEndpointUrl(endpoint: Endpoint, secret: (field: UrlSecretField) => string): string;
//# sourceMappingURL=endpoint.d.ts.map