Skip to content

@codesoul-co/hypha-tools / workspace

模块用法

用于声明并实施 Workspace 作用域边界。Workspace 模块公开 3 接口、1 类型。

从包入口导入

ts
import type {
  WorkspaceRuntimeConfig,
  WorkspaceRuntimePort,
  WorkspaceRuntimeRequest,
  WorkspaceFileOperation,
} from '@codesoul-co/hypha-tools';

使用要点

  • 4 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用 import type,运行时不应依赖它们。

公共导出

Symbol种类签名说明
WorkspaceRuntimeConfig接口interface WorkspaceRuntimeConfigWorkspace Runtime Config 接口,共包含 5 个公开字段或方法。
WorkspaceRuntimePort接口interface WorkspaceRuntimePortWorkspace Runtime Port 接口,共包含 3 个公开字段或方法。
WorkspaceRuntimeRequest接口interface WorkspaceRuntimeRequestWorkspace Runtime Request 接口,共包含 8 个公开字段或方法。
WorkspaceFileOperation类型type WorkspaceFileOperation = 'read' | 'write' | 'list' | 'execute'Workspace File Operation 公共类型别名;完整类型表达式见声明。

WorkspaceRuntimeConfig

Workspace Runtime Config 接口,共包含 5 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { WorkspaceRuntimeConfig } from '@codesoul-co/hypha-tools';
  • 源码模块: workspace

声明

text
export interface WorkspaceRuntimeConfig {
    workingDirectory: string;
    readPaths: string[];
    writePaths: string[];
    executePaths: string[];
    execution: {
        enabled: boolean;
        timeoutMs: number;
        maxOutputBytes: number;
    };
}

契约成员

成员种类签名说明
executePaths属性executePaths: string[]公开属性;类型、只读和可选状态以签名列为准。
execution属性execution: { enabled: boolean; timeoutMs: number; maxOutputBytes: number; }公开属性;类型、只读和可选状态以签名列为准。
readPaths属性readPaths: string[]公开属性;类型、只读和可选状态以签名列为准。
workingDirectory属性workingDirectory: string公开属性;类型、只读和可选状态以签名列为准。
writePaths属性writePaths: string[]公开属性;类型、只读和可选状态以签名列为准。

WorkspaceRuntimePort

Workspace Runtime Port 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { WorkspaceRuntimePort } from '@codesoul-co/hypha-tools';
  • 源码模块: workspace

声明

text
export interface WorkspaceRuntimePort {
    execute(request: WorkspaceRuntimeRequest): Promise<unknown>;
    health(): Promise<ProviderHealth>;
    close?(): Promise<void>;
}

契约成员

成员种类签名说明
close方法close?(): Promise<void>公开方法;参数与返回类型以签名列为准。
execute方法execute(request: WorkspaceRuntimeRequest): Promise<unknown>公开方法;参数与返回类型以签名列为准。
health方法health(): Promise<ProviderHealth>公开方法;参数与返回类型以签名列为准。

WorkspaceRuntimeRequest

Workspace Runtime Request 接口,共包含 8 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { WorkspaceRuntimeRequest } from '@codesoul-co/hypha-tools';
  • 源码模块: workspace

声明

text
export interface WorkspaceRuntimeRequest {
    operation: WorkspaceFileOperation;
    path: string;
    content?: string;
    executable?: boolean;
    args?: string[];
    cwd?: string;
    timeoutMs?: number;
    signal?: AbortSignal;
}

契约成员

成员种类签名说明
args属性args?: string[]公开属性;类型、只读和可选状态以签名列为准。
content属性content?: string公开属性;类型、只读和可选状态以签名列为准。
cwd属性cwd?: string公开属性;类型、只读和可选状态以签名列为准。
executable属性executable?: boolean公开属性;类型、只读和可选状态以签名列为准。
operation属性operation: WorkspaceFileOperation公开属性;类型、只读和可选状态以签名列为准。
path属性path: string公开属性;类型、只读和可选状态以签名列为准。
signal属性signal?: AbortSignal公开属性;类型、只读和可选状态以签名列为准。
timeoutMs属性timeoutMs?: number公开属性;类型、只读和可选状态以签名列为准。

WorkspaceFileOperation

Workspace File Operation 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { WorkspaceFileOperation } from '@codesoul-co/hypha-tools';
  • 源码模块: workspace

声明

text
export type WorkspaceFileOperation = 'read' | 'write' | 'list' | 'execute';