openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
177 lines • 8.34 kB
TypeScript
import { C as DeviceBootstrapProfile, S as PairedDeviceApprovalKind, T as PAIRING_SETUP_BOOTSTRAP_PROFILE, b as DevicePairingPendingRequest, g as resolveGatewayPort, r as OpenClawPluginApi, t as definePluginEntry, v as listDevicePairing, w as DeviceBootstrapProfileInput, x as PairedDevice, y as DeviceBootstrapTokenRecord } from "../../plugin-entry-BJ7nwfgz.js";
import "../../types.openclaw-BMUxPS96.js";
import "../../types-ja65ErE-.js";
import { Command } from "commander";
import "@openclaw/fs-safe/temp";
//#region src/infra/device-pairing-approval.d.ts
/** Paired-device access metadata refreshed when an existing device reconnects. */
type DevicePairingAccessMetadata = Pick<PairedDevice, "displayName" | "remoteIp" | "lastSeenAtMs" | "lastSeenReason">;
/** Authorization failure categories for owner approval and bootstrap approval flows. */
type DevicePairingForbiddenReason = "caller-scopes-required" | "caller-missing-scope" | "scope-outside-requested-roles" | "approval-policy-changed" | "bootstrap-role-not-allowed" | "bootstrap-scope-not-allowed";
/** Structured forbidden result with the missing/disallowed role or scope when known. */
type DevicePairingForbiddenResult = {
status: "forbidden";
reason: DevicePairingForbiddenReason;
scope?: string;
role?: string;
};
/** Pairing approval outcome: approved, forbidden with reason, or request not found. */
type ApproveDevicePairingResult = {
status: "approved";
requestId: string;
device: PairedDevice;
/** Existing connected node transports must be retired before success is returned. */
nodePairingGenerationChanged?: true;
} | DevicePairingForbiddenResult | null;
type DevicePairingApprovalOptions = {
callerScopes?: readonly string[];
accessMetadata?: DevicePairingAccessMetadata;
approvedVia?: Extract<PairedDeviceApprovalKind, "owner" | "silent" | "trusted-cidr" | "trusted-proxy" | "ssh-verified">;
/** Revalidate automatic approval against current policy after all pairing-lock awaits. */
isApprovalCurrent?: (state: {
pending: Readonly<DevicePairingPendingRequest>;
existing: Readonly<PairedDevice> | undefined;
}) => boolean;
/**
* Replace pending scopes for a new operator device, or a trusted-proxy
* same-key upgrade. The live role set is rechecked under the pairing lock.
*/
autoApproveNewDeviceScopes?: readonly string[];
};
/** Approve a pending request with optional caller-scope checks for operator grants. */
export declare function approveDevicePairing(requestId: string, baseDir?: string): Promise<ApproveDevicePairingResult>;
export declare function approveDevicePairing(requestId: string, options: DevicePairingApprovalOptions, baseDir?: string): Promise<ApproveDevicePairingResult>;
//#endregion
//#region src/infra/device-bootstrap.d.ts
type DeviceBootstrapTokenIssueParams = {
baseDir?: string;
profile?: DeviceBootstrapProfileInput;
roles?: readonly string[];
scopes?: readonly string[];
};
/** Issue a short-lived generic bootstrap token with a bounded role/scope handoff profile. */
export declare function issueDeviceBootstrapToken(params?: DeviceBootstrapTokenIssueParams): Promise<{
token: string;
expiresAtMs: number;
}>;
/** Remove every outstanding bootstrap token from the pairing state file. */
export declare function clearDeviceBootstrapTokens(params?: {
baseDir?: string;
}): Promise<{
removed: number;
}>;
/** Revoke one bootstrap token and return its record for best-effort restore flows. */
export declare function revokeDeviceBootstrapToken(params: {
token: string;
baseDir?: string;
}): Promise<{
removed: boolean;
record?: DeviceBootstrapTokenRecord;
}>;
//#endregion
//#region src/shared/tailscale-status.d.ts
type TailscaleStatusCommandResult = {
code: number | null;
stdout: string;
};
type TailscaleStatusCommandRunner = (argv: string[], opts: {
timeoutMs: number;
}) => Promise<TailscaleStatusCommandResult>;
/** Runs known Tailscale status commands and returns the first DNS name or tailnet IP found. */
export declare function resolveTailnetHostWithRunner(runCommandWithTimeout?: TailscaleStatusCommandRunner): Promise<string | null>;
/** Finds persistent HTTPS Serve routes whose root proxy targets this gateway port. */
export declare function resolveTailscaleServeGatewayUrlsWithRunner(gatewayPort: number, runCommandWithTimeout?: TailscaleStatusCommandRunner): Promise<string[]>;
//#endregion
//#region src/shared/gateway-bind-url.d.ts
type GatewayBindUrlResult = {
url: string;
source: "gateway.bind=custom" | "gateway.bind=tailnet" | "gateway.bind=lan";
} | {
error: string;
} | null;
/** Resolves the externally advertised gateway URL for non-loopback bind modes. */
export declare function resolveGatewayBindUrl(params: {
bind?: string;
customBindHost?: string;
scheme: "ws" | "wss";
port: number;
pickTailnetHost: () => string | null;
pickLanHost: () => string | null;
}): GatewayBindUrlResult;
//#endregion
//#region src/plugin-sdk/gateway-runtime.d.ts
export declare function resolveAdvertisedLanHost(): Promise<string | null>;
//#endregion
//#region src/plugin-sdk/run-command.d.ts
/** Captured process result returned by plugin command execution helpers. */
type PluginCommandRunResult = {
/** Process exit code, with `1` used when the command failed before spawning or did not report one. */
code: number;
/** Captured standard output as UTF-8 text. */
stdout: string;
/** Captured standard error, normalized to include timeout or thrown-error messages. */
stderr: string;
};
/** Options for commands that are launched on behalf of a plugin runtime. */
type PluginCommandRunOptions = {
/** Executable and arguments, with the command name in the first slot. */
argv: string[];
/** Hard execution limit in milliseconds before the command is terminated. */
timeoutMs: number;
/** Working directory for the child process. Defaults to the current process directory. */
cwd?: string;
/** Environment passed to the child process. Defaults to the current process environment. */
env?: NodeJS.ProcessEnv;
};
/** Run a plugin-managed command with timeout handling and normalized stdout/stderr results. */
export declare function runPluginCommandWithTimeout(options: PluginCommandRunOptions): Promise<PluginCommandRunResult>;
//#endregion
//#region src/infra/tmp-openclaw-dir.d.ts
type SecureDirStat = {
isDirectory(): boolean;
isSymbolicLink(): boolean;
mode?: number;
uid?: number;
};
/** Injectable filesystem/platform hooks for resolving the preferred temp root in tests. */
type ResolvePreferredOpenClawTmpDirOptions = {
accessSync?: (path: string, mode?: number) => void;
chmodSync?: (path: string, mode: number) => void;
getuid?: () => number | undefined;
lstatSync?: (path: string) => SecureDirStat;
mkdirSync?: (path: string, opts: {
recursive: boolean;
mode?: number;
}) => void;
platform?: NodeJS.Platform;
preferredDir?: string;
tmpdir?: () => string;
warn?: (message: string) => void;
};
/** Resolves a safe OpenClaw temp root, falling back to user-scoped os.tmpdir paths when needed. */
export declare function resolvePreferredOpenClawTmpDir(options?: ResolvePreferredOpenClawTmpDirOptions): string;
//#endregion
//#region src/media/qr-image.d.ts
type QrPngRenderOptions = {
scale?: number;
marginModules?: number;
};
/** Temp-file write options kept to filename segments so callers cannot choose parent paths. */
type QrPngTempFileOptions = QrPngRenderOptions & {
tmpRoot: string;
dirPrefix: string;
fileName?: string;
};
type QrPngTempFile = {
filePath: string;
dirPath: string;
mediaLocalRoots: string[];
};
/** Renders QR text as raw PNG base64 after validating bounded renderer options. */
export declare function renderQrPngBase64(input: string, opts?: QrPngRenderOptions): Promise<string>;
/** Renders QR text as a PNG data URL. */
export declare function renderQrPngDataUrl(input: string, opts?: QrPngRenderOptions): Promise<string>;
/** Writes QR PNG output into a scoped temp directory and returns that directory as a media root. */
export declare function writeQrPngTempFile(input: string, opts: QrPngTempFileOptions): Promise<QrPngTempFile>;
//#endregion
export { type DeviceBootstrapProfile, type OpenClawPluginApi, PAIRING_SETUP_BOOTSTRAP_PROFILE, definePluginEntry, listDevicePairing, resolveGatewayPort };