Skip to content

@codesoul-co/hypha-adapters-local / local-process-policy

模块用法

用于实施 Policy 与治理检查。Local process policy 模块公开 1 类、2 接口。

从包入口导入

ts
import {
  LocalProcessPolicyResolver,
} from '@codesoul-co/hypha-adapters-local';

import type {
  LocalProcessPolicyResolverOptions,
  ResolvedLocalProcessPolicy,
} from '@codesoul-co/hypha-adapters-local';

使用要点

  • 2 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用 import type,运行时不应依赖它们。
  • 1 个类提供可实例化的运行时实现;构造参数与公开方法在各自条目中完整列出。

公共导出

Symbol种类签名说明
LocalProcessPolicyResolvernew LocalProcessPolicyResolver(options: LocalProcessPolicyResolverOptions): LocalProcessPolicyResolverResolves untrusted command input into an explicit, host-local execution policy.
LocalProcessPolicyResolverOptions接口interface LocalProcessPolicyResolverOptionsLocal Process Policy Resolver Options 接口,共包含 14 个公开字段或方法。
ResolvedLocalProcessPolicy接口interface ResolvedLocalProcessPolicyResolved Local Process Policy 接口,共包含 9 个公开字段或方法。

LocalProcessPolicyResolver

Resolves untrusted command input into an explicit, host-local execution policy.

  • 种类: 类
  • 导入: import { LocalProcessPolicyResolver } from '@codesoul-co/hypha-adapters-local';
  • 源码模块: local-process-policy

声明

text
export declare class LocalProcessPolicyResolver {
    readonly workspaceRoot: string;
    constructor(options: LocalProcessPolicyResolverOptions);
    validateEnvironment(environment: ExecutionEnvironmentSpec): void;
    resolve(environment: ExecutionEnvironmentSpec, request: CommandExecutionRequest): Promise<ResolvedLocalProcessPolicy>;
    assertExecutionSurfaceUnchanged(policy: ResolvedLocalProcessPolicy): Promise<void>;
    assertSurfaceAvailable(): Promise<void>;
}

公开成员

成员种类签名说明
assertExecutionSurfaceUnchanged方法assertExecutionSurfaceUnchanged(policy: ResolvedLocalProcessPolicy): Promise<void>公开方法;参数与返回类型以签名列为准。
assertSurfaceAvailable方法assertSurfaceAvailable(): Promise<void>公开方法;参数与返回类型以签名列为准。
constructor构造函数(options: LocalProcessPolicyResolverOptions): LocalProcessPolicyResolver创建该类的实例。
resolve方法resolve(environment: ExecutionEnvironmentSpec, request: CommandExecutionRequest): Promise<ResolvedLocalProcessPolicy>公开方法;参数与返回类型以签名列为准。
validateEnvironment方法validateEnvironment(environment: ExecutionEnvironmentSpec): void公开方法;参数与返回类型以签名列为准。
workspaceRoot属性readonly workspaceRoot: string公开属性;类型、只读和可选状态以签名列为准。

LocalProcessPolicyResolverOptions

Local Process Policy Resolver Options 接口,共包含 14 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { LocalProcessPolicyResolverOptions } from '@codesoul-co/hypha-adapters-local';
  • 源码模块: local-process-policy

声明

text
export interface LocalProcessPolicyResolverOptions {
    workspaceRoot: string;
    executables: Record<string, string>;
    baseEnvironment?: Record<string, string>;
    inheritEnvironment?: string[];
    maxExecutionTimeoutMs?: number;
    maxStdoutBytes?: number;
    maxStderrBytes?: number;
    maxCombinedOutputBytes?: number;
    maxArgumentCount?: number;
    maxArgumentBytes?: number;
    maxTotalArgumentBytes?: number;
    maxEnvironmentVariables?: number;
    maxEnvironmentValueBytes?: number;
    maxTotalEnvironmentBytes?: number;
}

契约成员

成员种类签名说明
baseEnvironment属性baseEnvironment?: Record<string, string>公开属性;类型、只读和可选状态以签名列为准。
executables属性executables: Record<string, string>公开属性;类型、只读和可选状态以签名列为准。
inheritEnvironment属性inheritEnvironment?: string[]公开属性;类型、只读和可选状态以签名列为准。
maxArgumentBytes属性maxArgumentBytes?: number公开属性;类型、只读和可选状态以签名列为准。
maxArgumentCount属性maxArgumentCount?: number公开属性;类型、只读和可选状态以签名列为准。
maxCombinedOutputBytes属性maxCombinedOutputBytes?: number公开属性;类型、只读和可选状态以签名列为准。
maxEnvironmentValueBytes属性maxEnvironmentValueBytes?: number公开属性;类型、只读和可选状态以签名列为准。
maxEnvironmentVariables属性maxEnvironmentVariables?: number公开属性;类型、只读和可选状态以签名列为准。
maxExecutionTimeoutMs属性maxExecutionTimeoutMs?: number公开属性;类型、只读和可选状态以签名列为准。
maxStderrBytes属性maxStderrBytes?: number公开属性;类型、只读和可选状态以签名列为准。
maxStdoutBytes属性maxStdoutBytes?: number公开属性;类型、只读和可选状态以签名列为准。
maxTotalArgumentBytes属性maxTotalArgumentBytes?: number公开属性;类型、只读和可选状态以签名列为准。
maxTotalEnvironmentBytes属性maxTotalEnvironmentBytes?: number公开属性;类型、只读和可选状态以签名列为准。
workspaceRoot属性workspaceRoot: string公开属性;类型、只读和可选状态以签名列为准。

ResolvedLocalProcessPolicy

Resolved Local Process Policy 接口,共包含 9 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ResolvedLocalProcessPolicy } from '@codesoul-co/hypha-adapters-local';
  • 源码模块: local-process-policy

声明

text
export interface ResolvedLocalProcessPolicy {
    executable: string;
    args: readonly string[];
    cwd: string;
    environment: NodeJS.ProcessEnv;
    timeoutMs: number;
    idleTimeoutMs?: number;
    maxStdoutBytes: number;
    maxStderrBytes: number;
    maxCombinedOutputBytes: number;
}

契约成员

成员种类签名说明
args属性args: readonly string[]公开属性;类型、只读和可选状态以签名列为准。
cwd属性cwd: string公开属性;类型、只读和可选状态以签名列为准。
environment属性environment: NodeJS.ProcessEnv公开属性;类型、只读和可选状态以签名列为准。
executable属性executable: string公开属性;类型、只读和可选状态以签名列为准。
idleTimeoutMs属性idleTimeoutMs?: number公开属性;类型、只读和可选状态以签名列为准。
maxCombinedOutputBytes属性maxCombinedOutputBytes: number公开属性;类型、只读和可选状态以签名列为准。
maxStderrBytes属性maxStderrBytes: number公开属性;类型、只读和可选状态以签名列为准。
maxStdoutBytes属性maxStdoutBytes: number公开属性;类型、只读和可选状态以签名列为准。
timeoutMs属性timeoutMs: number公开属性;类型、只读和可选状态以签名列为准。