@atlaswork/atlascode 0.1.125 → 0.1.126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/atlasweb-carrier.json +6 -0
- package/dist/cli.js +514 -18
- package/dist/web-session-runtime/atlascode/web/entry.d.ts +2 -0
- package/dist/web-session-runtime/atlascode/web/executionOutlet.d.ts +60 -0
- package/dist/web-session-runtime/atlascode/web/runtimeEntry.d.ts +16 -0
- package/dist/web-session-runtime/index.d.ts +1 -1
- package/dist/web-session-runtime/kernel/execution/executionOutlet.d.ts +60 -0
- package/dist/web-session-runtime/kernel/protocol/webExecutionV0.d.ts +542 -0
- package/dist/web-session-runtime/kernel/state/injection.d.ts +28 -0
- package/dist/web-session-runtime/kernel/state/ports.d.ts +67 -0
- package/dist/web-session-runtime-execution/atlascode/web/contract.d.ts +10 -0
- package/dist/web-session-runtime-execution/atlascode/web/cursorLedger.d.ts +63 -0
- package/dist/web-session-runtime-execution/atlascode/web/entry.d.ts +24 -0
- package/dist/web-session-runtime-execution/atlascode/web/errors.d.ts +16 -0
- package/dist/web-session-runtime-execution/atlascode/web/follow.d.ts +82 -0
- package/dist/web-session-runtime-execution/atlascode/web/limits.d.ts +63 -0
- package/dist/web-session-runtime-execution/atlascode/web/projection.d.ts +69 -0
- package/dist/web-session-runtime-execution/atlascode/web/readonlyRuntime.d.ts +156 -0
- package/dist/web-session-runtime-execution/atlascode/web/runtimeDefault.d.ts +26 -0
- package/dist/web-session-runtime-execution/atlascode/web/sessionStoreAdapter.d.ts +70 -0
- package/dist/web-session-runtime-execution/engine/session/env.d.ts +32 -0
- package/dist/web-session-runtime-execution/engine/session/firstPrompt.d.ts +21 -0
- package/dist/web-session-runtime-execution/engine/session/json.d.ts +27 -0
- package/dist/web-session-runtime-execution/engine/session/load.d.ts +88 -0
- package/dist/web-session-runtime-execution/engine/session/paths.d.ts +25 -0
- package/dist/web-session-runtime-execution/engine/session/predicates.d.ts +55 -0
- package/dist/web-session-runtime-execution/engine/session/readonly.d.ts +29 -0
- package/dist/web-session-runtime-execution/engine/session/scanner.d.ts +26 -0
- package/dist/web-session-runtime-execution/engine/session/search.d.ts +44 -0
- package/dist/web-session-runtime-execution/engine/session/types.d.ts +379 -0
- package/dist/web-session-runtime-execution/index.d.ts +1 -0
- package/dist/web-session-runtime-execution/index.js +8396 -0
- package/dist/web-session-runtime-execution/kernel/execution/executionOutlet.d.ts +60 -0
- package/dist/web-session-runtime-execution/kernel/protocol/webExecutionV0.d.ts +547 -0
- package/dist/web-session-runtime-execution/kernel/protocol/webSessionV0.d.ts +727 -0
- package/dist/web-session-runtime-execution/kernel/state/injection.d.ts +28 -0
- package/dist/web-session-runtime-execution/kernel/state/ports.d.ts +67 -0
- package/dist/web-session-runtime-execution/shared/ProductDefinition.d.ts +47 -0
- package/dist/web-session-runtime-execution/shared/agentRoleTemplates.d.ts +44 -0
- package/dist/web-session-runtime-execution/shared/agentSwarmsEnabled.d.ts +5 -0
- package/dist/web-session-runtime-execution/shared/boundedImageRead.d.ts +31 -0
- package/dist/web-session-runtime-execution/shared/circular-buffer.d.ts +42 -0
- package/dist/web-session-runtime-execution/shared/configDir.d.ts +57 -0
- package/dist/web-session-runtime-execution/shared/constants.d.ts +19 -0
- package/dist/web-session-runtime-execution/shared/debug.d.ts +32 -0
- package/dist/web-session-runtime-execution/shared/env.d.ts +38 -0
- package/dist/web-session-runtime-execution/shared/errors.d.ts +56 -0
- package/dist/web-session-runtime-execution/shared/feature.d.ts +25 -0
- package/dist/web-session-runtime-execution/shared/format.d.ts +11 -0
- package/dist/web-session-runtime-execution/shared/fs-operations.d.ts +116 -0
- package/dist/web-session-runtime-execution/shared/hash.d.ts +13 -0
- package/dist/web-session-runtime-execution/shared/identity.d.ts +23 -0
- package/dist/web-session-runtime-execution/shared/index.d.ts +46 -0
- package/dist/web-session-runtime-execution/shared/lazySchema.d.ts +12 -0
- package/dist/web-session-runtime-execution/shared/log.d.ts +1 -0
- package/dist/web-session-runtime-execution/shared/path.d.ts +22 -0
- package/dist/web-session-runtime-execution/shared/pdfPageImages.d.ts +19 -0
- package/dist/web-session-runtime-execution/shared/pdfReference.d.ts +70 -0
- package/dist/web-session-runtime-execution/shared/permissionDeadline.d.ts +24 -0
- package/dist/web-session-runtime-execution/shared/platform.d.ts +8 -0
- package/dist/web-session-runtime-execution/shared/stringUtils.d.ts +110 -0
- package/dist/web-session-runtime-execution/shared/swarmSchemaFilter.d.ts +23 -0
- package/dist/web-session-runtime-execution/shared/teamFileSchema.d.ts +151 -0
- package/dist/web-session-runtime-execution/shared/teamInboxSchema.d.ts +112 -0
- package/dist/web-session-runtime-execution/shared/teammateContext.d.ts +89 -0
- package/dist/web-session-runtime-execution/shared/tempDir.d.ts +1 -0
- package/dist/web-session-runtime-execution/shared/textEncoding.d.ts +41 -0
- package/dist/web-session-runtime-execution/shared/tokenEstimation.d.ts +36 -0
- package/dist/web-session-runtime-execution/shared/types-session.d.ts +266 -0
- package/dist/web-session-runtime-execution/shared/types.d.ts +190 -0
- package/dist/web-session-runtime-execution/shared/unc.d.ts +5 -0
- package/dist/web-session-runtime-execution/shared/windowsPaths.d.ts +24 -0
- package/package.json +11 -4
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 0.1.106 S3b 切片 1 —— bootstrapState 缝注入槽(lock-face 必答②)。
|
|
3
|
+
*
|
|
4
|
+
* 注入拓扑三 lane(lock-face 必答④,禁只写 tui 桥):
|
|
5
|
+
* ① TUI 车道:src/tui/factory.ts(组合根)注入真实现包装
|
|
6
|
+
* ② headless 车道:src/atlascode/compose.ts(全仓唯一装配点,与既有
|
|
7
|
+
* setBootstrapStatePort 基项同点,保持单源)
|
|
8
|
+
* ③ probe 车道:e2e/生产 lane 探针以缺省 NoopSeam 运行(合法);真状态
|
|
9
|
+
* 消费探针显式注入 stub,未注入路径断言 fail-fast 抛错
|
|
10
|
+
*/
|
|
11
|
+
import type { KernelBootstrapNoopSeam, KernelBootstrapStatePort } from './ports.js';
|
|
12
|
+
export type KernelInjectionSlot = 'bootstrapState' | 'noopSeam' | 'sessionEnv';
|
|
13
|
+
/** 产品组合根单例门 arming(幂等;调用本身非注入)。 */
|
|
14
|
+
export declare function armKernelInjectionGuard(): void;
|
|
15
|
+
/** 守卫认领原语:armed 时槽已消费 = 硬错,未消费则记账;未 armed = no-op。 */
|
|
16
|
+
export declare function claimKernelInjectionSlot(slot: KernelInjectionSlot): void;
|
|
17
|
+
/** armed 态查询(env.ts resetSessionEnv 消费——守卫逻辑仍单文件)。 */
|
|
18
|
+
export declare function isKernelInjectionArmed(): boolean;
|
|
19
|
+
/** 注入真状态端口(组合根启动期恰一次;重复注入 = 覆盖,测试期重注合法)。 */
|
|
20
|
+
export declare function setKernelBootstrapState(port: KernelBootstrapStatePort): void;
|
|
21
|
+
/** 真状态读取门:未注入 = 显式抛错(fail-fast,硬约束 B——真状态禁缺省)。 */
|
|
22
|
+
export declare function getKernelBootstrapState(): KernelBootstrapStatePort;
|
|
23
|
+
/** no-op 缝注入(可选;不注入 = DEFAULT_NOOP_SEAM 空实现,合法)。 */
|
|
24
|
+
export declare function setKernelBootstrapNoopSeam(seam: KernelBootstrapNoopSeam): void;
|
|
25
|
+
/** no-op 缝读取门:缺省空实现合法(与真状态缺省语义相反,逐件写死)。 */
|
|
26
|
+
export declare function getKernelBootstrapNoopSeam(): KernelBootstrapNoopSeam;
|
|
27
|
+
/** 测试隔离辅助:清空注入槽(生产组合根禁用;armed 态 = 硬错,批复条件④)。 */
|
|
28
|
+
export declare function resetKernelBootstrapStateForTests(): void;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 0.1.106 S3b 内核态分层切片 1 —— bootstrapState 端口缝(lock-face 必答②终形)。
|
|
3
|
+
*
|
|
4
|
+
* 三态判形(docs/2026-11-13-01106-s3b-lockface-main.md 必答①,
|
|
5
|
+
* 附件 bs-export-triage.csv 115 行逐件):
|
|
6
|
+
* - 真状态 29 名(28 函数 + InvokedSkillRecord 类型)→ 本文件 KernelBootstrapStatePort
|
|
7
|
+
* - no-op 86 名 → 留 tui 桥原位;唯首车缝消费 4 名入 KernelBootstrapNoopSeam
|
|
8
|
+
* - 分歧 3 名(getAllowedSettingSources / getFlagSettingsPath /
|
|
9
|
+
* setAllowedSettingSources,S3a 护栏锁定)→ 禁入本缝接口
|
|
10
|
+
* (格 2 负断言:缝接口名集 ∩ 分歧名集 = ∅,tests/unit/kernel-state-seam.test.ts)
|
|
11
|
+
*
|
|
12
|
+
* 缺省语义逐件写死(两态相反,工单 §6 硬约束 B):
|
|
13
|
+
* - 真状态(StatePort):未注入 = 显式抛错(fail-fast,injection.ts)
|
|
14
|
+
* - no-op(NoopSeam):未注入 = 缺省空实现,合法(injection.ts DEFAULT_NOOP_SEAM)
|
|
15
|
+
*
|
|
16
|
+
* 本域零 tui import(签名面本地重述,实现留在 src/tui/bootstrapState.ts,
|
|
17
|
+
* tui 桥组合根构造真实现注入——kernel 不感知实现)。
|
|
18
|
+
*/
|
|
19
|
+
/** FX-04 invoked-skill 记录(原 tui/bootstrapState.ts:48 定义,本域收编 +
|
|
20
|
+
* bootstrapState re-export 兜底,消费者零改动)。 */
|
|
21
|
+
export interface InvokedSkillRecord {
|
|
22
|
+
skillName: string;
|
|
23
|
+
skillPath: string;
|
|
24
|
+
content: string;
|
|
25
|
+
invokedAt: number;
|
|
26
|
+
}
|
|
27
|
+
/** 真状态端口:bootstrapState 中引用模块级可变状态的 28 函数。 */
|
|
28
|
+
export interface KernelBootstrapStatePort {
|
|
29
|
+
addInvokedSkill(skillName: string, skillPath: string, content: string, agentId: string | null): void;
|
|
30
|
+
clearInvokedSkillsForAgent(agentId: string | null): void;
|
|
31
|
+
getInvokedSkillsForAgent(agentId: string | null | undefined): Map<string, InvokedSkillRecord>;
|
|
32
|
+
flushInteractionTime(): void;
|
|
33
|
+
getLastInteractionTime(): number;
|
|
34
|
+
updateLastInteractionTime(force?: boolean): void;
|
|
35
|
+
getActiveTimeCounter(): unknown;
|
|
36
|
+
getAgentColorMap(): unknown;
|
|
37
|
+
getLocCounter(): unknown;
|
|
38
|
+
getInitialMainLoopModel(): string | null;
|
|
39
|
+
getMainLoopModelOverride(): string | undefined;
|
|
40
|
+
setMainLoopModelOverride(model: string | undefined): void;
|
|
41
|
+
getIsRemoteMode(): boolean;
|
|
42
|
+
setIsRemoteMode(v: boolean): void;
|
|
43
|
+
getTurnClassifierCount(): number;
|
|
44
|
+
getTurnClassifierDurationMs(): number;
|
|
45
|
+
getTurnHookCount(): number;
|
|
46
|
+
getTurnHookDurationMs(): number;
|
|
47
|
+
getTurnToolCount(): number;
|
|
48
|
+
getTurnToolDurationMs(): number;
|
|
49
|
+
resetTurnClassifierDuration(): void;
|
|
50
|
+
resetTurnHookDuration(): void;
|
|
51
|
+
resetTurnToolDuration(): void;
|
|
52
|
+
addToTurnHookDuration(durationMs: number): void;
|
|
53
|
+
addToTurnClassifierDuration(durationMs: number): void;
|
|
54
|
+
clearSystemPromptSectionState(): void;
|
|
55
|
+
getSystemPromptSectionCache(): unknown;
|
|
56
|
+
setSystemPromptSectionCacheEntry(name: string, value: string | null): void;
|
|
57
|
+
}
|
|
58
|
+
/** no-op 占位缝:首车(切片 2 出口 59 文件)直接消费的 4 名 bootstrapState
|
|
59
|
+
* no-op 占位(bs-export-triage.csv 判形全 no-op)。缺省空实现合法。
|
|
60
|
+
* 切片 2:签名按消费点原形保真(tui stub 为 any 吞参,透传参 = 调用面
|
|
61
|
+
* 零改动;适配器 forward 原函数返回值)。 */
|
|
62
|
+
export interface KernelBootstrapNoopSeam {
|
|
63
|
+
addSlowOperation(description: string, durationMs: number): void;
|
|
64
|
+
waitForScrollIdle(): Promise<void> | void;
|
|
65
|
+
setLastAPIRequest(params: unknown): void;
|
|
66
|
+
setLastAPIRequestMessages(messages: unknown): void;
|
|
67
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ProductDefinition(0.1.98 S1a 硬化波,工单 docs/2026-11-12-p0-wave-0198-s1a-ticket.md
|
|
3
|
+
* lock-face ①④ 批复形):per-product 运行时差异的唯一接口面。
|
|
4
|
+
*
|
|
5
|
+
* 与 IDN-1 构建配方归一边界:品牌串走 identity.ts 构建配方(buildUserAgent 等),
|
|
6
|
+
* 本接口只承载**运行时清单参数**(工具子集 / 配置目录维度〔0.1.99 步 2 激活〕)。
|
|
7
|
+
*
|
|
8
|
+
* ★不参数化清单(lock-face §0 冻结,禁顺手漂移——改动 = row F 回 f4):
|
|
9
|
+
* 1. modelprovider/constants.ts 两 beta 头(SUMMARIZE_CONNECTOR_TEXT_BETA_HEADER /
|
|
10
|
+
* AFK_MODE_BETA_HEADER)——wire 协议常量(WIRE 冻结族),非产品工具面。
|
|
11
|
+
* 2. coordinator localShellTask `MONITOR_TOOL` 门——coordinator 行为门(env 已可关)。
|
|
12
|
+
* 3. tui 域 FEATURE_* env kill-switch 行为门族——TUI 行为门 ≠ 工具子集。
|
|
13
|
+
* 4. 项目级 `.atlas/skills` 约定目录字面(loadSkillsDir)——项目根约定,非
|
|
14
|
+
* ~/.atlas 配置目录,product 无关。
|
|
15
|
+
* 5. 工具 prompt 文案中 `~/.atlas` 用户引导字面——用户可见文案,不入本接口。
|
|
16
|
+
*
|
|
17
|
+
* 解析时序(lock-face ④ 判据 (a)):**解析一次性**——ACTIVE_PRODUCT 模块级冻结,
|
|
18
|
+
* 启动期定谳,消费方(loopDeps/toolRegistry)读引用不重解析;禁 per-call 重解析。
|
|
19
|
+
*/
|
|
20
|
+
export interface ProductDefinition {
|
|
21
|
+
/** 产品 id(注册清单键;当前唯一 'atlascode')。 */
|
|
22
|
+
readonly id: string;
|
|
23
|
+
/**
|
|
24
|
+
* 运行时工具子集(工具名冻结清单;**undefined = 全量装配,atlascode 零变更**)。
|
|
25
|
+
* 消费点 = toolRegistry getAllBaseTools 装配层过滤(Agent/base/ascend 段,
|
|
26
|
+
* mcpTools 动态面不参 subset);过滤与 isEnabled 判别同路(lock-face ④ (c)),
|
|
27
|
+
* 禁旁路 env 直查。defer/ToolSearch 面消费 registry 产物,subset 外工具不可见。
|
|
28
|
+
*/
|
|
29
|
+
readonly toolSubset?: readonly string[];
|
|
30
|
+
/**
|
|
31
|
+
* 配置目录名维度(0.1.99 步 2 激活):部署期产品默认层。
|
|
32
|
+
* env 四层次序(0.1.99 lock-face 必改① 钉死)= ATLAS_CONFIG_DIR(全路径
|
|
33
|
+
* 显式)> ATLAS_CONFIG_DIR_NAME(用户显式)> 本值(部署期默认)> '.atlas'
|
|
34
|
+
* ——显式用户意图恒压部署期产品默认。消费经 shared/configDir provider
|
|
35
|
+
* 槽惰性读(倒置 getter 形,shared 零 import 纯度)。
|
|
36
|
+
*/
|
|
37
|
+
readonly configDirName?: string;
|
|
38
|
+
/**
|
|
39
|
+
* team durable 持久化档部署期缺省回落(0.1.100 W-D-B-1 段 D 批复形
|
|
40
|
+
* @bbe99518):settings teams.persistence 缺席时回落本值,再落 'memory'。
|
|
41
|
+
* **仅缺省回落**——读写点禁 product id 条件旁路(工单 §6 吸收①,§8 分档
|
|
42
|
+
* 门纪律);undefined = 'memory'(现网行为字节级不变)。
|
|
43
|
+
*/
|
|
44
|
+
readonly teamPersistenceDefault?: 'memory' | 'durable';
|
|
45
|
+
}
|
|
46
|
+
/** 活跃产品定义(解析一次性:返回模块级冻结引用,禁调用方重解析/复制)。 */
|
|
47
|
+
export declare function getActiveProductDefinition(): ProductDefinition;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* shared/agentRoleTemplates — 0.1.93 W-D-A(Form A 临时小组,工单
|
|
3
|
+
* docs/2026-11-08-p0-wave-0193-ticket.md;f4 批复 2026-11-08)。
|
|
4
|
+
*
|
|
5
|
+
* 职责两件:
|
|
6
|
+
* 1. renderTeammatePrompt — spawn 触发点(Agent 扩参 name/team_name)的
|
|
7
|
+
* prompt 组装纯函数:把 TeamCreate members 名册(role/goal/backstory
|
|
8
|
+
* 三元组,CrewAI 词汇吸收)+ 任务 prompt 合成为成员首条指令。纯函数
|
|
9
|
+
* 零 I/O、零门依赖 → 落 shared(engine AgentTool 与未来 TUI 预览面
|
|
10
|
+
* 双消费)。
|
|
11
|
+
* 2. named 角色模板注册表(A4 载体)——role 标签 → 模板片段映射;
|
|
12
|
+
* renderTeammatePrompt 消费(命中则注入模板片段)。注册 = 组合根 /
|
|
13
|
+
* 域包显式装配(PRT-2 同型:非模块顶层自注册);缺省零注册 =
|
|
14
|
+
* render 恒等走名册三元组,零行为差。
|
|
15
|
+
*/
|
|
16
|
+
/** named 角色模板(role 标签检索单元;systemPromptFragment = 组装时注入
|
|
17
|
+
* 的固定指令片段)。 */
|
|
18
|
+
export type AgentRoleTemplate = {
|
|
19
|
+
role: string;
|
|
20
|
+
systemPromptFragment?: string;
|
|
21
|
+
};
|
|
22
|
+
/** 组合根 / 域包注册(幂等 last-wins;测试 resetAgentRoleTemplates 复位)。 */
|
|
23
|
+
export declare function registerAgentRoleTemplate(template: AgentRoleTemplate): void;
|
|
24
|
+
/** role 标签检索(未注册 = undefined,render 走名册三元组)。 */
|
|
25
|
+
export declare function getAgentRoleTemplate(role: string): AgentRoleTemplate | undefined;
|
|
26
|
+
/** 测试复位(teardown 用)。 */
|
|
27
|
+
export declare function resetAgentRoleTemplates(): void;
|
|
28
|
+
/** renderTeammatePrompt 输入面(TeamCreate roster 条目 + Agent 任务 prompt)。 */
|
|
29
|
+
export type TeammatePromptParts = {
|
|
30
|
+
/** 成员名(spawn 身份)。 */
|
|
31
|
+
name: string;
|
|
32
|
+
/** 角色标签(命中注册表则注入模板片段)。 */
|
|
33
|
+
role?: string;
|
|
34
|
+
goal?: string;
|
|
35
|
+
backstory?: string;
|
|
36
|
+
/** 任务 prompt(Agent call 透传原文)。 */
|
|
37
|
+
prompt: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* 合成成员首条指令:身份行 + 模板/角色元数据段 + 任务 prompt 原文。
|
|
41
|
+
* 纯函数(无 I/O 无门);roster 字段全可选(缺省只渲染任务 prompt +
|
|
42
|
+
* 身份行 = roster 未建组仍可 spawn 的退化面)。
|
|
43
|
+
*/
|
|
44
|
+
export declare function renderTeammatePrompt(parts: TeammatePromptParts): string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** 图片源读上限:128 MiB(上游 302:>128MB 应拒)。 */
|
|
2
|
+
export declare const MAX_IMAGE_SOURCE_BYTES: number;
|
|
3
|
+
/** 非 regular 文件(FIFO/设备/socket):类型拒绝,读循环/解码器不可达。 */
|
|
4
|
+
export declare class NonRegularFileError extends Error {
|
|
5
|
+
constructor(filePath: string, fileKindDescription: string);
|
|
6
|
+
}
|
|
7
|
+
/** 源超限:fstat 阶段(读取前)或读循环累计超限(增长守卫)拒绝。 */
|
|
8
|
+
export declare class ImageSourceTooLargeError extends Error {
|
|
9
|
+
constructor(filePath: string, sizeBytes: number, maxBytes: number);
|
|
10
|
+
}
|
|
11
|
+
/** 读循环 duck 句柄(fs.promises.FileHandle 满足;测试可注 fake)。 */
|
|
12
|
+
export interface BoundedReadHandle {
|
|
13
|
+
read(buffer: Buffer, offset: number, length: number, position: number | null): Promise<{
|
|
14
|
+
bytesRead: number;
|
|
15
|
+
}>;
|
|
16
|
+
close(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 有界读循环(核心):分块读至 EOF;单次读长 = min(chunk, 剩余预算+1)
|
|
20
|
+
* (增长面不整块过读);累计 > maxBytes 拒;chunk 间查 abort。
|
|
21
|
+
* 句柄 duck 注入面(单测 fake 无盘判别:EOF 恰内容/无穷流累计帽/abort)。
|
|
22
|
+
*/
|
|
23
|
+
export declare function readBoundedFromHandle(handle: BoundedReadHandle, maxBytes: number, signal?: AbortSignal, sourcePath?: string): Promise<Buffer>;
|
|
24
|
+
/**
|
|
25
|
+
* 有界文件读:O_NONBLOCK 打开(FIFO/设备不阻塞等 producer)→ fstat
|
|
26
|
+
* 类型 + 大小双验(读取前)→ 有界读循环 → 恒 close(close 失败不吞读
|
|
27
|
+
* 结果;handle 非空态直接 .catch,无可选链短路面)。
|
|
28
|
+
*/
|
|
29
|
+
export declare function readBoundedFileBytes(filePath: string, maxBytes: number, signal?: AbortSignal): Promise<Buffer>;
|
|
30
|
+
/** 图片源读固定上限面(K5-1 产品入口)。 */
|
|
31
|
+
export declare function readBoundedImageBytes(filePath: string, signal?: AbortSignal): Promise<Buffer>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 定长循环缓冲(C1 叶子下沉,整文件复制自旧仓 utils/CircularBuffer.ts)。
|
|
3
|
+
*
|
|
4
|
+
* 零依赖纯类:维护滚动数据窗口(shell 输出尾窗 / 日志环形缓冲等)。
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A fixed-size circular buffer that automatically evicts the oldest items
|
|
8
|
+
* when the buffer is full. Useful for maintaining a rolling window of data.
|
|
9
|
+
*/
|
|
10
|
+
export declare class CircularBuffer<T> {
|
|
11
|
+
private capacity;
|
|
12
|
+
private buffer;
|
|
13
|
+
private head;
|
|
14
|
+
private size;
|
|
15
|
+
constructor(capacity: number);
|
|
16
|
+
/**
|
|
17
|
+
* Add an item to the buffer. If the buffer is full,
|
|
18
|
+
* the oldest item will be evicted.
|
|
19
|
+
*/
|
|
20
|
+
add(item: T): void;
|
|
21
|
+
/**
|
|
22
|
+
* Add multiple items to the buffer at once.
|
|
23
|
+
*/
|
|
24
|
+
addAll(items: T[]): void;
|
|
25
|
+
/**
|
|
26
|
+
* Get the most recent N items from the buffer.
|
|
27
|
+
* Returns fewer items if the buffer contains less than N items.
|
|
28
|
+
*/
|
|
29
|
+
getRecent(count: number): T[];
|
|
30
|
+
/**
|
|
31
|
+
* Get all items currently in the buffer, in order from oldest to newest.
|
|
32
|
+
*/
|
|
33
|
+
toArray(): T[];
|
|
34
|
+
/**
|
|
35
|
+
* Clear all items from the buffer.
|
|
36
|
+
*/
|
|
37
|
+
clear(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Get the current number of items in the buffer.
|
|
40
|
+
*/
|
|
41
|
+
length(): number;
|
|
42
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 配置目录名(跨域纯叶子,C-Deep 切片 3 T5 下沉)
|
|
3
|
+
*
|
|
4
|
+
* 旧仓来源(a8af45b): src/utils/configDir.ts — getConfigDirName 单一事实源。
|
|
5
|
+
* permissions 域(DANGEROUS_DIRECTORIES / getAtlasTempDir* / isClaudeConfigFile)
|
|
6
|
+
* 与 sandbox 域(createSandboxManager 配置目录 denyWrite 族)共线消费,属跨 ≥2 域
|
|
7
|
+
* 纯叶子 → shared 下沉(L3 四域互不 import,shared 为唯一跨域叶子汇)。
|
|
8
|
+
*
|
|
9
|
+
* 纯叶子:只读 env + provider 槽,无域依赖。
|
|
10
|
+
*
|
|
11
|
+
* 0.1.99 S1a 步 2(工单 docs/2026-11-12-p0-wave-0199-s1a-step2-ticket.md §7
|
|
12
|
+
* lock-face 定谳):product.configDirName 维度激活——依赖方向 = **倒置惰性
|
|
13
|
+
* getter 形**(本文件持 provider 槽 + 组合根 compose.ts 注入,setSettingsPathsProvider
|
|
14
|
+
* 同款先例):shared 保零 import 纯度(禁反向 import ProductDefinition),
|
|
15
|
+
* provider 槽天然兼任 product 层判别格测试注入口。
|
|
16
|
+
*
|
|
17
|
+
* env 四层次序(lock-face 必改① 钉死,显式用户意图恒压部署期产品默认):
|
|
18
|
+
* 1. ATLAS_CONFIG_DIR —— 全路径显式(仅 homedir 锚出口;见下「双出口语义」)。
|
|
19
|
+
* 2. ATLAS_CONFIG_DIR_NAME —— 用户显式目录名。
|
|
20
|
+
* 3. product.configDirName —— 部署期产品默认(provider 槽惰性读,未注入 = 无此层)。
|
|
21
|
+
* 4. '.atlas' —— 缺省(无盘探;陈旧 `~/.claude` 不再把运行时拉回 legacy 目录)。
|
|
22
|
+
*
|
|
23
|
+
* 双出口语义(0.1.99 row F 批复 @f4 §8 b8a55c40,两维不同维禁混用):
|
|
24
|
+
* - `getConfigDirName()` —— **homedir 锚**(用户配置目录):四层全序。L1 全路径
|
|
25
|
+
* 经 `join(homedir(), v)` 绝对段重置后解析为显式目录本身,语义正确。
|
|
26
|
+
* - `getConfigDirNameForProject()` —— **项目根锚 / 名字标签**(repo 内 `.atlas`
|
|
27
|
+
* 点目录、managed 目录子路径、tmp 目录名标签、权限 pattern 串):剥 L1 的三层
|
|
28
|
+
* (NAME > product 默认 > '.atlas')。L1 是「用户配置目录全路径」,对项目点
|
|
29
|
+
* 目录=维度错配(join(repoRoot, 全路径) 绝对段重置 → 项目点目录漂移到用户
|
|
30
|
+
* 配置目录,canon 19 fail 单根因实证);名字标签位进全路径同样破坏匹配。
|
|
31
|
+
* - 恒等判据:ATLAS_CONFIG_DIR 未设时两出口同值(现网行为字节级不变)。
|
|
32
|
+
*/
|
|
33
|
+
/** 产品配置目录名提供器(无参惰性 getter:读活跃 ProductDefinition 当前值)。 */
|
|
34
|
+
export type ConfigDirNameProvider = () => string | undefined;
|
|
35
|
+
/** 组合根注入产品配置目录名提供器(读 activeProduct.configDirName)。 */
|
|
36
|
+
export declare function setConfigDirNameProvider(provider: ConfigDirNameProvider): void;
|
|
37
|
+
/** 测试复位(teardown 用,防跨用例泄漏——mock.module 泄漏同族守)。 */
|
|
38
|
+
export declare function resetConfigDirNameProvider(): void;
|
|
39
|
+
/**
|
|
40
|
+
* 配置目录名(homedir 锚出口)。Clean migration:缺省恒 `.atlas`——无 legacy
|
|
41
|
+
* `~/.claude` 回落,供第二套 agent 平台同机共存而不互相写穿配置目录。
|
|
42
|
+
*
|
|
43
|
+
* 解析序见头注(env 四层:ATLAS_CONFIG_DIR > ATLAS_CONFIG_DIR_NAME >
|
|
44
|
+
* product.configDirName > '.atlas')。消费面 = homedir/XDG 锚(用户配置目录),
|
|
45
|
+
* 逐点分型清册见 docs/2026-11-12-0199-configdir-anchor-enumeration.md。
|
|
46
|
+
*/
|
|
47
|
+
export declare function getConfigDirName(): string;
|
|
48
|
+
/**
|
|
49
|
+
* 配置目录名(项目根锚 / 名字标签出口)。剥 L1(ATLAS_CONFIG_DIR 全路径)的
|
|
50
|
+
* 三层解析:ATLAS_CONFIG_DIR_NAME > product.configDirName > '.atlas'。
|
|
51
|
+
*
|
|
52
|
+
* 消费面 = repo 内 `.atlas` 点目录(skills/worktrees/settings/rules/agent-memory
|
|
53
|
+
* 等 join(root, …))、managed 目录子路径、tmp 目录名标签、权限 pattern 串——
|
|
54
|
+
* 这些位置需要的是「名字」而非「用户配置目录全路径」。恒等判据:L1 未设时
|
|
55
|
+
* 与 getConfigDirName() 同值。
|
|
56
|
+
*/
|
|
57
|
+
export declare function getConfigDirNameForProject(): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 跨域常量叶子(C-Deep 切片 3 T3:task 输出磁盘上限单一事实源)。
|
|
3
|
+
*
|
|
4
|
+
* 旧仓单一事实源分裂两处:utils/task/diskOutput.ts L30-31(
|
|
5
|
+
* MAX_TASK_OUTPUT_BYTES / MAX_TASK_OUTPUT_BYTES_DISPLAY)+
|
|
6
|
+
* utils/ShellCommand.ts L54(SIZE_WATCHDOG_INTERVAL_MS)。上限的两个
|
|
7
|
+
* 消费者在新仓分属两域——task(diskOutput:pipe 模式 DiskTaskOutput
|
|
8
|
+
* 超限只追加截断标记 + 丢 chunk)与 executor(ShellCommand:file 模式
|
|
9
|
+
* 5s 轮询 stat watchdog,超限 kill 后台任务)——L3 四域互不 import,
|
|
10
|
+
* shared 是唯一跨域叶子下沉处 → 上限落此单一事实源。watchdog 轮询
|
|
11
|
+
* 间隔单消费者(executor)→ 留 executor 域内(ShellCommand.ts 模块
|
|
12
|
+
* 常量),不随下沉。
|
|
13
|
+
*
|
|
14
|
+
* 显示串不再单设 DISPLAY 常量:两消费点改用 shared formatFileSize(bytes)
|
|
15
|
+
* 推导(默认 5GB → '5GB',与旧仓 '5GB' 字面一致;自定义上限时随值
|
|
16
|
+
* 缩放,优于旧仓硬编码字面)。
|
|
17
|
+
*/
|
|
18
|
+
/** task 输出磁盘文件上限:5GB。pipe 模式丢弃线 = file 模式 watchdog kill 线。 */
|
|
19
|
+
export declare const MAX_TASK_OUTPUT_BYTES: number;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* debug 日志(charter C-4:本期不加第 9 port,logging port 定案前维持占位)。
|
|
3
|
+
*
|
|
4
|
+
* 单一事实源(C1 统一裁定):C-Deep 填 executor/sandbox stub 时旧仓 Shell.ts
|
|
5
|
+
* 会大量 import logForDebugging——禁止每域各复制一份 no-op(B 波
|
|
6
|
+
* modelprovider/debug.ts 先例已废)。logging port 定案后整文件替换为
|
|
7
|
+
* port 实现(签名不变,调用点零改动)。
|
|
8
|
+
*
|
|
9
|
+
* 0.1.93b 段 R-aux(f4 裁定 2026-11-09,工单 @c22716f6 §3):最小可注入
|
|
10
|
+
* sink 窗(Port 5/Port 1 set/get 双函数 + 模块级持有先例同型)。背景 =
|
|
11
|
+
* 0.1.93 W-D-A e2e 缺口回执:R-①/②/⑤ 判别格依赖的 swarm 域
|
|
12
|
+
* `[inProcessRunner]` debug 行(~30 处)import 自本文件 = 纯 no-op →
|
|
13
|
+
* 任何 lane 零输出,判别格空转;cli/debugSink.ts 完整 sink(--debug-file
|
|
14
|
+
* 落盘 + ISO 时间戳)此前仅绑 cli 域三文件。
|
|
15
|
+
*
|
|
16
|
+
* 缺省零行为变更(锁面②):sink 未注入 = 纯 no-op;仅 cli/debugSink 在
|
|
17
|
+
* 启动期(initDebugSink,--debug/--debug-file/env DEBUG 任一启用的既有
|
|
18
|
+
* 组合入口)注册注入。与 C-4 前向兼容——logging port 定案时整文件替换,
|
|
19
|
+
* set/get 窗口随替换面一并删除(登记:architecture-charter C-4 节扩格批注)。
|
|
20
|
+
*/
|
|
21
|
+
export type DebugLogLevel = 'verbose' | 'debug' | 'info' | 'warn' | 'error';
|
|
22
|
+
export type DebugSink = (message: string, options?: {
|
|
23
|
+
level?: DebugLogLevel;
|
|
24
|
+
}) => void;
|
|
25
|
+
/** 启动期注入(cli/debugSink initDebugSink 唯一生产调用点;测试面可置 null 复位)。 */
|
|
26
|
+
export declare function setDebugSink(sink: DebugSink | null): void;
|
|
27
|
+
/** 当前 sink(诊断/测试断言面;未注入 = null)。 */
|
|
28
|
+
export declare function getDebugSink(): DebugSink | null;
|
|
29
|
+
/** 经注入 sink 转发;未注入 = no-op(缺省零输出零 I/O,锁面②)。 */
|
|
30
|
+
export declare function logForDebugging(message: string, options?: {
|
|
31
|
+
level: DebugLogLevel;
|
|
32
|
+
}): void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* env 解析纯函数(shared 工具,B 波 S1 加)。
|
|
3
|
+
*
|
|
4
|
+
* 四域 config.ts 共用的 env 读取原语。纯函数无副作用(不依赖 debug/log),
|
|
5
|
+
* 旧仓 validateBoundedIntEnvVar 带 logForDebugging 依赖 → 此处剥离为纯函数,
|
|
6
|
+
* 调用方自行决定是否记录(charter L3 域自治:config 层不拉 cross-domain utils)。
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* 解析有界整数 env:缺失/无效 → defaultValue;parsed > upperLimit → cap 到 upperLimit。
|
|
10
|
+
* 语义对齐旧仓 validateBoundedIntEnvVar(剥掉 logForDebugging 依赖,
|
|
11
|
+
* message 字段随之删除——旧仓 message 仅 logForDebugging 消费)。
|
|
12
|
+
*
|
|
13
|
+
* 下界裁定(C1):默认 `min = 0`(0 合法,GLOB_TIMEOUT=0 表"不限时");
|
|
14
|
+
* timeout 类 env 传 `min = 1` 恢复旧仓"0 无效回落默认"语义。
|
|
15
|
+
*
|
|
16
|
+
* @param name env 变量名(仅用于返回 status,不做日志)
|
|
17
|
+
* @param value env 原始值
|
|
18
|
+
* @param defaultValue 缺失/无效时的回落值
|
|
19
|
+
* @param upperLimit 上限(parsed > upperLimit 时 cap)
|
|
20
|
+
* @param min 下界(默认 0;传 1 拒绝 0/负值)
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseBoundedIntEnv(name: string, value: string | undefined, defaultValue: number, upperLimit: number, min?: number): {
|
|
23
|
+
effective: number;
|
|
24
|
+
status: "valid" | "capped" | "invalid";
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* 判断 env 值是否为「真」:`1` / `true` / `yes` / `on`(trim + 大小写不敏感)→ true。
|
|
28
|
+
* 接受 boolean(透传)。语义 = 旧仓 utils/envUtils.ts isEnvTruthy(T3 布尔 env 约定)。
|
|
29
|
+
*
|
|
30
|
+
* C1 统一裁定:本函数是布尔 env 单一事实源——替代 B 波 parseBoolEnv(窄集合)
|
|
31
|
+
* 与 memory/modelprovider 域内本地副本;C1b 消费方全部切到本函数后其余形态删除。
|
|
32
|
+
*/
|
|
33
|
+
export declare function isEnvTruthy(envVar: string | boolean | undefined): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* 判断 env 值是否显式设为「假」:`0` / `false` / `no` / `off`(trim + 大小写不敏感)。
|
|
36
|
+
* undefined → false(未设不算显式假)。语义 = 旧仓 utils/envUtils.ts isEnvDefinedFalsy。
|
|
37
|
+
*/
|
|
38
|
+
export declare function isEnvDefinedFalsy(envVar: string | boolean | undefined): boolean;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 错误处理纯助手(C1 叶子下沉,复制自旧仓 utils/errors.ts 纯函数段)。
|
|
3
|
+
*
|
|
4
|
+
* 零依赖:仅错误对象形状检查,不 import 任何域/错误类(旧仓 error 类族
|
|
5
|
+
* TelemetrySafeError/AxiosErrorKind 等留在各自域,不随叶子下沉)。
|
|
6
|
+
* 消费者:catch 边界归一化 / fs 错误分类 / 工具结果回传模型的短栈提取。
|
|
7
|
+
*/
|
|
8
|
+
export declare function hasExactErrorMessage(error: unknown, message: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Normalize an unknown value into an Error.
|
|
11
|
+
* Use at catch-site boundaries when you need an Error instance.
|
|
12
|
+
*/
|
|
13
|
+
export declare function toError(e: unknown): Error;
|
|
14
|
+
/**
|
|
15
|
+
* Extract a string message from an unknown error-like value.
|
|
16
|
+
* Use when you only need the message (e.g., for logging or display).
|
|
17
|
+
*/
|
|
18
|
+
export declare function errorMessage(e: unknown): string;
|
|
19
|
+
/**
|
|
20
|
+
* Extract the errno code (e.g., 'ENOENT', 'EACCES') from a caught error.
|
|
21
|
+
* Returns undefined if the error has no code or is not an ErrnoException.
|
|
22
|
+
* Replaces the `(e as NodeJS.ErrnoException).code` cast pattern.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getErrnoCode(e: unknown): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* True if the error is ENOENT (file or directory does not exist).
|
|
27
|
+
* Replaces `(e as NodeJS.ErrnoException).code === 'ENOENT'`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isENOENT(e: unknown): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Extract the errno path (the filesystem path that triggered the error)
|
|
32
|
+
* from a caught error. Returns undefined if the error has no path.
|
|
33
|
+
* Replaces the `(e as NodeJS.ErrnoException).path` cast pattern.
|
|
34
|
+
*/
|
|
35
|
+
export declare function getErrnoPath(e: unknown): string | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Extract error message + top N stack frames from an unknown error.
|
|
38
|
+
* Use when the error flows to the model as a tool_result — full stack
|
|
39
|
+
* traces are ~500-2000 chars of mostly-irrelevant internal frames and
|
|
40
|
+
* waste context tokens. Keep the full stack in debug logs instead.
|
|
41
|
+
*/
|
|
42
|
+
export declare function shortErrorStack(e: unknown, maxFrames?: number): string;
|
|
43
|
+
/**
|
|
44
|
+
* True if the error means the path is missing, inaccessible, or
|
|
45
|
+
* structurally unreachable — use in catch blocks after fs operations to
|
|
46
|
+
* distinguish expected "nothing there / no access" from unexpected errors.
|
|
47
|
+
*
|
|
48
|
+
* Covers:
|
|
49
|
+
* ENOENT — path does not exist
|
|
50
|
+
* EACCES — permission denied
|
|
51
|
+
* EPERM — operation not permitted
|
|
52
|
+
* ENOTDIR — a path component is not a directory (e.g. a file named
|
|
53
|
+
* `.claude` exists where a directory is expected)
|
|
54
|
+
* ELOOP — too many symlink levels (circular symlinks)
|
|
55
|
+
*/
|
|
56
|
+
export declare function isFsInaccessible(e: unknown): e is NodeJS.ErrnoException;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* feature(name) — 特性灰度开关(charter d 裁定:普通模块, 非 bun:bundle 内建)
|
|
3
|
+
*
|
|
4
|
+
* 旧仓双形态(127 内建 bun:bundle + 45 F5 shim bunBundle.ts)→ 新仓统一为
|
|
5
|
+
* 本普通模块。解掉旧仓 bun:bundle feature() 测试中恒 false 不可测的坑
|
|
6
|
+
* (charter PRT-1 连带收益)。
|
|
7
|
+
*
|
|
8
|
+
* 机制:
|
|
9
|
+
* - 读 `FEATURE_<NAME>` env(大写), call-time 求值(非构建期常量)
|
|
10
|
+
* - `FEATURE_X=true` → 开; `FEATURE_X=false` → 显式关(压过 ON_BY_DEFAULT)
|
|
11
|
+
* - ON_BY_DEFAULT 集合中的 flag 未设 env 时默认开(生产 bundle 经本模块生效)
|
|
12
|
+
*
|
|
13
|
+
* 测试:直接 `process.env['FEATURE_X'] = 'true'` / `delete` 控制, 无需 preload。
|
|
14
|
+
*
|
|
15
|
+
* 域级 flag 不在此(扩展点机制 = DomainPackage.featureGate 声明式, charter PRT-1)。
|
|
16
|
+
* 远程实验配置(growthbook)走 Port 8 FeatureConfigPort, 不在此。
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* 特性灰度开关。call-time 读 env, 非构建期常量。
|
|
20
|
+
* @param name flag 名(大写, 如 "ASCEND_TOOLS")
|
|
21
|
+
* @returns true = 该特性当前开启
|
|
22
|
+
*/
|
|
23
|
+
export declare function feature(name: string): boolean;
|
|
24
|
+
/** 导出 ON_BY_DEFAULT 供测试断言(只读副本, 不导出可变引用) */
|
|
25
|
+
export declare const FEATURE_ON_BY_DEFAULT: readonly string[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 字节大小格式化(C1 叶子下沉,复制自旧仓 utils/format.ts 的 formatFileSize)。
|
|
3
|
+
*
|
|
4
|
+
* 纯函数无 intl 依赖。旧仓消费者:modelprovider(PDF 尺寸回传)/
|
|
5
|
+
* memory(readFileInRange 超限提示)/ shell(输出统计)——跨 ≥2 域,归 shared。
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Formats a byte count to a human-readable string (KB, MB, GB).
|
|
9
|
+
* @example formatFileSize(1536) → "1.5KB"
|
|
10
|
+
*/
|
|
11
|
+
export declare function formatFileSize(sizeInBytes: number): string;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 文件系统抽象(C1 下沉,跨 ≥2 域:memory FileSystemMemoryStore +
|
|
3
|
+
* C-Deep executor Shell.ts 移植(旧仓 utils/fsOperations.ts 消费方含 Shell.ts/debug.ts 等 10+ 文件))。
|
|
4
|
+
*
|
|
5
|
+
* 从 memory/fsOperations.ts 的 B 波裁剪版上移:最小集(旧仓 60+ 方法全量 YAGNI)。
|
|
6
|
+
* C-Deep 时 executor 若需更多原语(writeFile/appendFile/rm…)→ 接口**加法式**扩展,
|
|
7
|
+
* 不另开第二份抽象(防腐:fs 抽象单一事实源在 shared)。
|
|
8
|
+
*
|
|
9
|
+
* slowOperations 计时 / errors.getErrnoCode 依赖已断开。
|
|
10
|
+
* mkdir 的 EEXIST 容错保留(Bun/Windows 只读目录位误判,旧仓 issue 30924)。
|
|
11
|
+
*/
|
|
12
|
+
import * as fs from 'fs';
|
|
13
|
+
import { type FileHandle } from 'fs/promises';
|
|
14
|
+
/**
|
|
15
|
+
* 最小 FS 操作集(跨域共享,C-Deep 按需加法扩展)。
|
|
16
|
+
*
|
|
17
|
+
* C-Deep 切片 1 加法(executor Shell.ts 消费;防腐口径不变:fs 抽象单一
|
|
18
|
+
* 事实源在 shared,executor 不直连 node:fs):
|
|
19
|
+
* - mkdir 加 mode 参数(沙箱临时目录 0o700;recursive + EEXIST 容错语义不变)
|
|
20
|
+
* - realpathSync(setCwd 符号链接解析 + cwd 消失恢复,旧仓 fsOperations 同名原语)
|
|
21
|
+
* - open(file 模式 spawn fd:O_WRONLY|O_CREAT|O_APPEND|O_NOFOLLOW)
|
|
22
|
+
* - unlinkSync(cwd 跟踪临时文件清理,ENOENT 容错在调用方)
|
|
23
|
+
*
|
|
24
|
+
* E-3 S-3b 加法(engine/config settings 加载/写回消费;旧仓 settings.ts 经
|
|
25
|
+
* getFsImplementation 走 sync 面,单测 mock 注入无真实磁盘):
|
|
26
|
+
* - readdirSync(withFileTypes,managed-settings.d drop-in 枚举)
|
|
27
|
+
* - writeFileSync(settings 写回,UTF-8 字符串;旧仓 writeFileSyncAndFlush 的
|
|
28
|
+
* fsync 段为 durability 优化,新仓裁剪——settings 非 durability 敏感数据)
|
|
29
|
+
* - mkdirSync(写回前建目录,recursive + EEXIST 容错,同 async mkdir 语义)
|
|
30
|
+
*
|
|
31
|
+
* E-4 S-4c1 加法(engine/permissions 规则磁盘加载/写回消费):
|
|
32
|
+
* - lstatSync(safeResolvePath 特殊文件守卫)
|
|
33
|
+
* - safeResolvePath 助手(接口外纯函数,旧仓 utils/fsOperations.ts:138 逐字)
|
|
34
|
+
*
|
|
35
|
+
* §8.55 S-C1 加法(engine/tools/files 依赖闭包层消费,旧仓
|
|
36
|
+
* utils/fsOperations.ts NodeFsOperations 同名原语逐字,slowLogging 裁):
|
|
37
|
+
* - readFileBytes(fs.readFile 无 encoding → Buffer;FileRead 图像支
|
|
38
|
+
* 消费;readFile 强制 encoding 成员不复用)
|
|
39
|
+
* - readSync(openSync + readSync(fd) + closeSync 逐字,非 Node 22
|
|
40
|
+
* fs.readSync(path, opts) 新 API;detectLineEndings 4KB 采样)
|
|
41
|
+
* - isDirEmptySync(readdirSync withFileTypes length===0 逐字)
|
|
42
|
+
* - readlinkSync / renameSync(writeFileSyncAndFlush_DEPRECATED 原子写
|
|
43
|
+
* 面符号链接保留 + 原子 rename)
|
|
44
|
+
*
|
|
45
|
+
* 存量 setFsImplementation 测试 stub(9 文件字面实现)不补新成员:
|
|
46
|
+
* tests/ 不在 tsconfig include(tsc 0 基线实证)+ 各 stub 消费面
|
|
47
|
+
* 零调用新成员(运行时安全)——E-4 lstatSync 加法同款裁定先例。
|
|
48
|
+
*
|
|
49
|
+
* 0.1.84 V3-5 K5-3 加法(readFileSyncWithMetadata 全量字节无损判别消费):
|
|
50
|
+
* - readFileBytesSync(fs.readFileSync 无 encoding → Buffer;readFileBytes
|
|
51
|
+
* 的同步 twin,readFileSync 强制 encoding 成员不复用——同款先例;命名对齐
|
|
52
|
+
* TUI 本地 twin 既有同名成员,fileRead 双体逐字同构)
|
|
53
|
+
* 例外登记:sc1-fs/notebook-se2 两 stub 消费面非零(驱动
|
|
54
|
+
* readFileSyncWithMetadata 链),已补成员;其余 stub 维持零消费。
|
|
55
|
+
*/
|
|
56
|
+
export type FsOperations = {
|
|
57
|
+
cwd(): string;
|
|
58
|
+
existsSync(path: string): boolean;
|
|
59
|
+
stat(path: string): Promise<fs.Stats>;
|
|
60
|
+
readdir(path: string, options?: {
|
|
61
|
+
recursive?: boolean;
|
|
62
|
+
}): Promise<fs.Dirent[]>;
|
|
63
|
+
mkdir(path: string, options?: {
|
|
64
|
+
mode?: number;
|
|
65
|
+
}): Promise<void>;
|
|
66
|
+
readFile(path: string, options: {
|
|
67
|
+
encoding: BufferEncoding;
|
|
68
|
+
}): Promise<string>;
|
|
69
|
+
readFileSync(path: string, options: {
|
|
70
|
+
encoding: BufferEncoding;
|
|
71
|
+
}): string;
|
|
72
|
+
readFileBytesSync(path: string): Buffer;
|
|
73
|
+
statSync(path: string): fs.Stats;
|
|
74
|
+
realpathSync(path: string): string;
|
|
75
|
+
open(path: string, flags: number): Promise<FileHandle>;
|
|
76
|
+
unlinkSync(path: string): void;
|
|
77
|
+
readdirSync(path: string): fs.Dirent[];
|
|
78
|
+
writeFileSync(path: string, data: string): void;
|
|
79
|
+
mkdirSync(path: string): void;
|
|
80
|
+
lstatSync(path: string): fs.Stats;
|
|
81
|
+
readFileBytes(path: string): Promise<Buffer>;
|
|
82
|
+
readSync(path: string, options: {
|
|
83
|
+
length: number;
|
|
84
|
+
}): {
|
|
85
|
+
buffer: Buffer;
|
|
86
|
+
bytesRead: number;
|
|
87
|
+
};
|
|
88
|
+
isDirEmptySync(path: string): boolean;
|
|
89
|
+
readlinkSync(path: string): string;
|
|
90
|
+
renameSync(oldPath: string, newPath: string): void;
|
|
91
|
+
};
|
|
92
|
+
export declare const NodeFsOperations: FsOperations;
|
|
93
|
+
/** 覆盖 FS 实现(测试注入)。 */
|
|
94
|
+
export declare function setFsImplementation(implementation: FsOperations): void;
|
|
95
|
+
/** 当前活跃 FS 实现。 */
|
|
96
|
+
export declare function getFsImplementation(): FsOperations;
|
|
97
|
+
/** 重置为 Node 默认实现。 */
|
|
98
|
+
export declare function setOriginalFsImplementation(): void;
|
|
99
|
+
/**
|
|
100
|
+
* 安全解析路径(E-4 S-4c1 加法,旧仓 utils/fsOperations.ts:138 逐字):
|
|
101
|
+
* realpath 解析 + 符号链接判定,失败回落原路径(不抛)。
|
|
102
|
+
*
|
|
103
|
+
* 语义(旧仓逐字):
|
|
104
|
+
* - UNC 路径(// 或 \\ 开头)在任何 fs 访问前阻塞(Windows DNS/SMB 防网络请求)
|
|
105
|
+
* - 特殊文件(FIFO/socket/字符/块设备)不 realpath(realpathSync 会阻塞等写入者)
|
|
106
|
+
* - 文件不存在 / 符号链接断裂 / EACCES / ELOOP → 回落原路径(允许文件创建场景)
|
|
107
|
+
* - isCanonical = realpath 成功(全路径分量符号链接已解,调用方可跳过再解析)
|
|
108
|
+
*
|
|
109
|
+
* 消费点:engine/permissions permissionRulesLoader lenient reader +
|
|
110
|
+
* permissionSetup isSymlinkTo(H6 实挂)。
|
|
111
|
+
*/
|
|
112
|
+
export declare function safeResolvePath(fs: FsOperations, filePath: string): {
|
|
113
|
+
resolvedPath: string;
|
|
114
|
+
isSymlink: boolean;
|
|
115
|
+
isCanonical: boolean;
|
|
116
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* djb2 字符串哈希(跨域纯叶子,C-Deep 切片 3 T5 下沉)
|
|
3
|
+
*
|
|
4
|
+
* 旧仓来源(a8af45b): src/utils/hash.ts — djb2Hash 单一事实源。
|
|
5
|
+
* sanitizePath 的 Node 兜底分支消费(Bun.hash 不可用时),跨域纯叶子 →
|
|
6
|
+
* shared 下沉。
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* djb2 字符串哈希——快速非加密哈希,返回有符号 32 位 int。跨运行时确定性
|
|
10
|
+
* (区别于 Bun.hash 的 wyhash)。Bun.hash 不可用或需盘上稳定输出(如须
|
|
11
|
+
* 跨运行时升级存活的缓存目录名)时作兜底。
|
|
12
|
+
*/
|
|
13
|
+
export declare function djb2Hash(str: string): number;
|