@phren/cli
Version:
Knowledge layer for AI agents - CLI, MCP server, and data layer
45 lines (44 loc) • 2.53 kB
TypeScript
import { type GitHost } from "./git-hosts.js";
/**
* The gitboy path's credentials. The Hook's stored `gba_` agent token is the
* only one a keyed dispatch may use: a credential helper in the worktree's own
* config answers git, and the agent environment carries the same token for the
* API. The token never enters argv, a remote URL or a log.
*/
/** Variables a keyed worker may inherit from the Hook's own environment. */
export declare const KEYED_ENV_ALLOW: readonly ["HOME", "USER", "LOGNAME", "PATH", "SHELL", "TERM", "LANG", "LC_ALL", "TMPDIR"];
/**
* The exact environment for a keyed worker: a small allowlist plus the values
* this Hook owns. Nothing else from process.env is copied, so no caller or
* Hook token reaches the harness.
*/
export declare function keyedExplicitEnv(base?: NodeJS.ProcessEnv, extra?: Record<string, string>): Record<string, string>;
/** The credential-free HTTPS remote for a gitboy host, or a refusal when owner/repo cannot be derived. */
export declare function credentialFreeRemote(host: Pick<GitHost, "domain" | "webUrl">): string;
/** Write the agent token to an exact private file path. */
export declare function writeAgentTokenFileAt(file: string, token: string): Promise<string>;
/** Remove a token file this Hook wrote; only the expected file name is ever touched. */
export declare function removeAgentTokenFile(file: string | undefined): Promise<void>;
export interface KeyedGitboy {
env: Record<string, string>;
tokenFile: string;
}
export interface KeyedGitboyOptions {
/** The exact token file path (the clone's git dir). */
tokenFile: string;
/** The managed global config the clone and the agent use. */
gitConfigFile?: string;
}
/**
* A keyed dispatch in a gitboy checkout uses this computer's stored agent token
* and fails closed when there is none. The token goes to a 0600 file; the agent
* gets only GITBOY_TOKEN_FILE (and, for a clone, its managed GIT_CONFIG_GLOBAL).
*/
export declare function prepareKeyedGitboy(cwd: string, options: KeyedGitboyOptions): Promise<KeyedGitboy | undefined>;
/** A git credential request for a host with a stored gitboy token, answered for `get` only. */
export declare function gitCredentialAnswer(request: string): Promise<{
username: string;
password: string;
} | undefined>;
/** The `phren bridge git-credential` helper: get answers, store and erase do nothing. */
export declare function gitCredentialCommand(operation: string | undefined, request: string): Promise<string | undefined>;