@atlaswork/atlascode 0.1.124 → 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.
Files changed (76) hide show
  1. package/dist/atlasweb-carrier.json +6 -0
  2. package/dist/cli.js +514 -18
  3. package/dist/web-session-runtime/atlascode/web/entry.d.ts +2 -0
  4. package/dist/web-session-runtime/atlascode/web/executionOutlet.d.ts +60 -0
  5. package/dist/web-session-runtime/atlascode/web/limits.d.ts +5 -0
  6. package/dist/web-session-runtime/atlascode/web/runtimeEntry.d.ts +16 -0
  7. package/dist/web-session-runtime/atlascode/web/sessionStoreAdapter.d.ts +12 -0
  8. package/dist/web-session-runtime/index.d.ts +1 -1
  9. package/dist/web-session-runtime/index.js +104 -3
  10. package/dist/web-session-runtime/kernel/execution/executionOutlet.d.ts +60 -0
  11. package/dist/web-session-runtime/kernel/protocol/webExecutionV0.d.ts +542 -0
  12. package/dist/web-session-runtime/kernel/state/injection.d.ts +28 -0
  13. package/dist/web-session-runtime/kernel/state/ports.d.ts +67 -0
  14. package/dist/web-session-runtime-execution/atlascode/web/contract.d.ts +10 -0
  15. package/dist/web-session-runtime-execution/atlascode/web/cursorLedger.d.ts +63 -0
  16. package/dist/web-session-runtime-execution/atlascode/web/entry.d.ts +24 -0
  17. package/dist/web-session-runtime-execution/atlascode/web/errors.d.ts +16 -0
  18. package/dist/web-session-runtime-execution/atlascode/web/follow.d.ts +82 -0
  19. package/dist/web-session-runtime-execution/atlascode/web/limits.d.ts +63 -0
  20. package/dist/web-session-runtime-execution/atlascode/web/projection.d.ts +69 -0
  21. package/dist/web-session-runtime-execution/atlascode/web/readonlyRuntime.d.ts +156 -0
  22. package/dist/web-session-runtime-execution/atlascode/web/runtimeDefault.d.ts +26 -0
  23. package/dist/web-session-runtime-execution/atlascode/web/sessionStoreAdapter.d.ts +70 -0
  24. package/dist/web-session-runtime-execution/engine/session/env.d.ts +32 -0
  25. package/dist/web-session-runtime-execution/engine/session/firstPrompt.d.ts +21 -0
  26. package/dist/web-session-runtime-execution/engine/session/json.d.ts +27 -0
  27. package/dist/web-session-runtime-execution/engine/session/load.d.ts +88 -0
  28. package/dist/web-session-runtime-execution/engine/session/paths.d.ts +25 -0
  29. package/dist/web-session-runtime-execution/engine/session/predicates.d.ts +55 -0
  30. package/dist/web-session-runtime-execution/engine/session/readonly.d.ts +29 -0
  31. package/dist/web-session-runtime-execution/engine/session/scanner.d.ts +26 -0
  32. package/dist/web-session-runtime-execution/engine/session/search.d.ts +44 -0
  33. package/dist/web-session-runtime-execution/engine/session/types.d.ts +379 -0
  34. package/dist/web-session-runtime-execution/index.d.ts +1 -0
  35. package/dist/web-session-runtime-execution/index.js +8396 -0
  36. package/dist/web-session-runtime-execution/kernel/execution/executionOutlet.d.ts +60 -0
  37. package/dist/web-session-runtime-execution/kernel/protocol/webExecutionV0.d.ts +547 -0
  38. package/dist/web-session-runtime-execution/kernel/protocol/webSessionV0.d.ts +727 -0
  39. package/dist/web-session-runtime-execution/kernel/state/injection.d.ts +28 -0
  40. package/dist/web-session-runtime-execution/kernel/state/ports.d.ts +67 -0
  41. package/dist/web-session-runtime-execution/shared/ProductDefinition.d.ts +47 -0
  42. package/dist/web-session-runtime-execution/shared/agentRoleTemplates.d.ts +44 -0
  43. package/dist/web-session-runtime-execution/shared/agentSwarmsEnabled.d.ts +5 -0
  44. package/dist/web-session-runtime-execution/shared/boundedImageRead.d.ts +31 -0
  45. package/dist/web-session-runtime-execution/shared/circular-buffer.d.ts +42 -0
  46. package/dist/web-session-runtime-execution/shared/configDir.d.ts +57 -0
  47. package/dist/web-session-runtime-execution/shared/constants.d.ts +19 -0
  48. package/dist/web-session-runtime-execution/shared/debug.d.ts +32 -0
  49. package/dist/web-session-runtime-execution/shared/env.d.ts +38 -0
  50. package/dist/web-session-runtime-execution/shared/errors.d.ts +56 -0
  51. package/dist/web-session-runtime-execution/shared/feature.d.ts +25 -0
  52. package/dist/web-session-runtime-execution/shared/format.d.ts +11 -0
  53. package/dist/web-session-runtime-execution/shared/fs-operations.d.ts +116 -0
  54. package/dist/web-session-runtime-execution/shared/hash.d.ts +13 -0
  55. package/dist/web-session-runtime-execution/shared/identity.d.ts +23 -0
  56. package/dist/web-session-runtime-execution/shared/index.d.ts +46 -0
  57. package/dist/web-session-runtime-execution/shared/lazySchema.d.ts +12 -0
  58. package/dist/web-session-runtime-execution/shared/log.d.ts +1 -0
  59. package/dist/web-session-runtime-execution/shared/path.d.ts +22 -0
  60. package/dist/web-session-runtime-execution/shared/pdfPageImages.d.ts +19 -0
  61. package/dist/web-session-runtime-execution/shared/pdfReference.d.ts +70 -0
  62. package/dist/web-session-runtime-execution/shared/permissionDeadline.d.ts +24 -0
  63. package/dist/web-session-runtime-execution/shared/platform.d.ts +8 -0
  64. package/dist/web-session-runtime-execution/shared/stringUtils.d.ts +110 -0
  65. package/dist/web-session-runtime-execution/shared/swarmSchemaFilter.d.ts +23 -0
  66. package/dist/web-session-runtime-execution/shared/teamFileSchema.d.ts +151 -0
  67. package/dist/web-session-runtime-execution/shared/teamInboxSchema.d.ts +112 -0
  68. package/dist/web-session-runtime-execution/shared/teammateContext.d.ts +89 -0
  69. package/dist/web-session-runtime-execution/shared/tempDir.d.ts +1 -0
  70. package/dist/web-session-runtime-execution/shared/textEncoding.d.ts +41 -0
  71. package/dist/web-session-runtime-execution/shared/tokenEstimation.d.ts +36 -0
  72. package/dist/web-session-runtime-execution/shared/types-session.d.ts +266 -0
  73. package/dist/web-session-runtime-execution/shared/types.d.ts +190 -0
  74. package/dist/web-session-runtime-execution/shared/unc.d.ts +5 -0
  75. package/dist/web-session-runtime-execution/shared/windowsPaths.d.ts +24 -0
  76. package/package.json +11 -4
@@ -0,0 +1,23 @@
1
+ export declare const PRODUCT_NAME = "AtlasCode";
2
+ export declare const PACKAGE_NAME = "@atlasharness/atlascode";
3
+ export declare const REPOSITORY_URL = "https://github.com/vincentlau2046/AtlasCode";
4
+ /**
5
+ * 仓库 slug(owner/repo 形,0.1.98 S1a 焊点① 派生自 REPOSITORY_URL 单一事实源
6
+ * ——coordinatorMode 提示词示例产品串注入消费;禁 engine 域字面回归,判据 =
7
+ * literal-inventory 域级 grep)。
8
+ */
9
+ export declare const REPOSITORY_SLUG: string;
10
+ /**
11
+ * 品牌身份扩常量(BR-1,spec §6.2)——identity 单一事实源落地:
12
+ * 家族共享名 / 对外品牌名 / 反馈通道 / 强调色相配方。
13
+ */
14
+ export declare const PRODUCT_FAMILY = "Atlas";
15
+ export declare const PRODUCT_BRAND = "AtlasCode";
16
+ export declare const FEEDBACK_CHANNEL = "https://github.com/vincentlau2046/AtlasCode/issues";
17
+ export declare const ACCENT_HUE = "compute";
18
+ export declare function getVersion(): string;
19
+ /** LLM 出站 User-Agent 品牌串(与 tui/utils/http.ts `AtlasCode/<v> (repo)` 语义对齐,无字面 `+`)。 */
20
+ export declare function buildUserAgent(): string;
21
+ /** WebFetch UA 共用 builder(tui `getWebFetchUserAgent` ④ 与 engine `WEB_FETCH_USER_AGENT` ⑤ 同一出处,零分叉)。
22
+ * 'Atlas-User' = 家族级 WebFetch agent 名(robots.txt 匹配串,Branded House 共享面,§10.3 spec §12)。 */
23
+ export declare function buildWebFetchUserAgent(): string;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * shared 模块唯一公共出口(STR-1 门面规则)。
3
+ *
4
+ * 外部模块只许 `import { ... } from "../shared.js"`(或 "src/shared"),
5
+ * 不许 reach 内部文件(entry-point lint 拦截)。
6
+ *
7
+ * re-export: feature(A 波已实现)/ types / types-session /
8
+ * identity / sanitizeToolName / tokenEstimation(随各文件 B/C 波落地)
9
+ */
10
+ export { feature, FEATURE_ON_BY_DEFAULT } from "./feature.js";
11
+ export { PRODUCT_NAME, PACKAGE_NAME, REPOSITORY_URL, REPOSITORY_SLUG, // 0.1.98 S1a 焊点①(owner/repo 派生,coordinatorMode 提示词消费)
12
+ PRODUCT_FAMILY, PRODUCT_BRAND, FEEDBACK_CHANNEL, ACCENT_HUE, getVersion, buildUserAgent, buildWebFetchUserAgent, } from "./identity.js";
13
+ export { parseBoundedIntEnv, isEnvTruthy, isEnvDefinedFalsy } from "./env.js";
14
+ export { escapeRegExp, capitalize, plural, firstLineOf, countCharInString, normalizeFullWidthDigits, normalizeFullWidthSpace, safeJoinLines, EndTruncatingAccumulator, truncateToLines, } from "./stringUtils.js";
15
+ export { CircularBuffer } from "./circular-buffer.js";
16
+ export { hasExactErrorMessage, toError, errorMessage, getErrnoCode, isENOENT, getErrnoPath, shortErrorStack, isFsInaccessible, } from "./errors.js";
17
+ export { formatFileSize } from "./format.js";
18
+ export { MAX_IMAGE_SOURCE_BYTES, NonRegularFileError, ImageSourceTooLargeError, readBoundedFileBytes, readBoundedFromHandle, readBoundedImageBytes, type BoundedReadHandle, } from "./boundedImageRead.js";
19
+ export { PDF_PAGE_IMAGE_MAX_BYTES, readPDFPageImages, type PDFPageImageBlock, } from "./pdfPageImages.js";
20
+ export { decodeTextLosslessly, hasUtf16LeBom, UndecodableTextError, type DecodedText, } from "./textEncoding.js";
21
+ export { MAX_TASK_OUTPUT_BYTES } from "./constants.js";
22
+ export { getConfigDirName, getConfigDirNameForProject, setConfigDirNameProvider, resetConfigDirNameProvider, type ConfigDirNameProvider, } from "./configDir.js";
23
+ export { TEAM_FILE_SCHEMA_VERSION, STALE_LOCK_MS, LOCK_RETRY_MAX, teamFileV2Schema, parseTeamFileV2, getLeadInstanceId, resetLeadInstanceId, getTeamsDirShared, getTeamFilePathShared, decideStaleLock, writeTeamFileV2Atomic, readTeamFileV2, sweepTmpOrphans, type TeamPersistenceMode, type TeamAllowedPath, type TeamRosterEntry, type TeamMemberV2, type TeamFileV2, type TeamFileLegacyExtras, type TeamFile, type ParsedTeamFileV2, } from "./teamFileSchema.js";
24
+ export { INBOX_SCHEMA_VERSION, MAX_INBOX_MESSAGES, inboxMessageSchema, inboxEnvelopeSchema, readInboxFile, writeInboxFileAtomic, isInboxSourceAllowed, inboxFullWarning, type InboxMessageSource, type SharedInboxMessage, type InboxEnvelope, type ReadInboxResult, } from "./teamInboxSchema.js";
25
+ export { getAtlasTempDirName } from "./tempDir.js";
26
+ export { getPlatform, SUPPORTED_PLATFORMS, type Platform, } from "./platform.js";
27
+ export { expandPath, containsPathTraversal, sanitizePath, MAX_SANITIZED_LENGTH, } from "./path.js";
28
+ export { containsVulnerableUncPath } from "./unc.js";
29
+ export { djb2Hash } from "./hash.js";
30
+ export { lazySchema } from "./lazySchema.js";
31
+ export { logForDebugging, type DebugLogLevel } from "./debug.js";
32
+ export { setDebugSink, getDebugSink, type DebugSink } from "./debug.js";
33
+ export { logError } from "./log.js";
34
+ export { windowsPathToPosixPath, posixPathToWindowsPath, } from "./windowsPaths.js";
35
+ export { NodeFsOperations, setFsImplementation, getFsImplementation, setOriginalFsImplementation, safeResolvePath, type FsOperations, } from "./fs-operations.js";
36
+ export { roughTokenCountEstimation, bytesPerTokenForFileType, roughTokenCountEstimationForFileType, } from "./tokenEstimation.js";
37
+ export type * from "./types.js";
38
+ export { EFFORT_LEVELS, asSystemPrompt } from "./types.js";
39
+ export type * from "./types-session.js";
40
+ export { resolveMailboxPermissionDeadlineMs, approvalUnavailableReason, } from "./permissionDeadline.js";
41
+ export { collectPDFReferenceAttachmentsForCompact, formatPDFReferenceForModel, FullPDFReadUnsupportedError, projectPDFReferenceForRecord, type PDFReferenceMetadata, } from "./pdfReference.js";
42
+ export { isAgentSwarmsEnabled } from "./agentSwarmsEnabled.js";
43
+ export { SWARM_FIELDS_BY_TOOL, filterSwarmFieldsFromSchema, } from "./swarmSchemaFilter.js";
44
+ export { type AgentRoleTemplate, registerAgentRoleTemplate, getAgentRoleTemplate, resetAgentRoleTemplates, type TeammatePromptParts, renderTeammatePrompt, } from "./agentRoleTemplates.js";
45
+ export { type TeammateContext, getTeammateContext, runWithTeammateContext, isInProcessTeammate, createTeammateContext, } from "./teammateContext.js";
46
+ export { getActiveProductDefinition, type ProductDefinition, } from "./ProductDefinition.js";
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 懒加载 schema 工厂(跨域纯叶子,C-Deep 切片 3 T5 下沉)
3
+ *
4
+ * 旧仓来源(a8af45b): src/utils/lazySchema.ts — 零依赖 memoize 工厂。
5
+ * permissions 域 PermissionRule.ts(zod schema 延迟到首调构造,避免模块 init
6
+ * 期构建)消费;跨域纯叶子 → shared 下沉。
7
+ */
8
+ /**
9
+ * 返回一个 memoize 工厂函数:首调时才构造值,之后恒返回缓存。
10
+ * 用于把 Zod schema 构造从模块 init 期推迟到首次访问。
11
+ */
12
+ export declare function lazySchema<T>(factory: () => T): () => T;
@@ -0,0 +1 @@
1
+ export declare function logError(error: unknown): void;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * 展开可能含 tilde(~)记法的路径为绝对路径。
3
+ * 恒返回当前平台原生格式。
4
+ *
5
+ * @param path - 待展开路径(~/、~、绝对、相对)
6
+ * @param baseDir - 相对路径解析基准(调用域注入的 cwd;shared 叶子不隐式取 cwd)
7
+ *
8
+ * @throws 路径含 null 字节或参数类型非法
9
+ */
10
+ export declare function expandPath(path: string, baseDir: string): string;
11
+ /**
12
+ * 检查路径是否含目录穿越模式(上跳父目录)。
13
+ *
14
+ * @returns 含 `../`、`..\` 或以 `..` 结尾时为 true
15
+ */
16
+ export declare function containsPathTraversal(path: string): boolean;
17
+ export declare const MAX_SANITIZED_LENGTH = 200;
18
+ /**
19
+ * 把字符串转成安全的目录/文件名:非字母数字替换为连字符。
20
+ * 超长(> MAX_SANITIZED_LENGTH)截断 + 追加哈希后缀保唯一。
21
+ */
22
+ export declare function sanitizePath(name: string): string;
@@ -0,0 +1,19 @@
1
+ /** 页图字节上限:单图与单次 Read 累计同帽 128 MiB。 */
2
+ export declare const PDF_PAGE_IMAGE_MAX_BYTES: number;
3
+ /** 页图块形:原始 JPEG base64(pdftoppm -jpeg 输出恒 image/jpeg)。 */
4
+ export type PDFPageImageBlock = {
5
+ type: 'image';
6
+ source: {
7
+ type: 'base64';
8
+ media_type: 'image/jpeg';
9
+ data: string;
10
+ };
11
+ };
12
+ export declare function readPDFPageImages(outputDir: string, opts?: {
13
+ maxBytesPerImage?: number;
14
+ maxTotalBytes?: number;
15
+ signal?: AbortSignal;
16
+ }): Promise<{
17
+ blocks: PDFPageImageBlock[];
18
+ totalBytes: number;
19
+ }>;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * @PDF 引用 → provider 投影叶子(0.1.85 Task A / C85-A)。
3
+ *
4
+ * 纯函数、零文件 I/O、零 settings/React/原生依赖——被两面消费:
5
+ * - modelprovider/params.ts toOpenAIMessages(现役请求链:attachment 型
6
+ * pdf_reference 消息在此投影为 user 文本,修复 084 Gap A——此前
7
+ * attachment 型整体落空被丢,f4 新鲜探针证真实 pdf_reference 投影为 [])
8
+ * - tui/utils/messages.ts normalizeAttachmentForAPI pdf_reference 支
9
+ * (TUI 车道既有消费,本波起调用同一叶子,双面文本恒等)
10
+ *
11
+ * 文本 = 0.1.84 K5-8 通用引用提示四要素(工单 §1-A:实际绝对 filename 必在
12
+ * 正文;小/大/null 页数提示真实;无 too-large 虚报、无「无 pages 必失败」、
13
+ * 不声称已读、模型无关)。FILE_READ_TOOL_NAME 两侧均为 'Read'
14
+ * (engine/tools/toolNames.ts + tui prompt.ts),叶子不依赖任一面。
15
+ */
16
+ /** pdf_reference 引用 metadata(产点:tui/utils/attachments.ts
17
+ * PDFReferenceAttachment 同形五字段;D 波持久化白名单同此投影)。 */
18
+ export type PDFReferenceMetadata = {
19
+ type: 'pdf_reference';
20
+ filename: string;
21
+ /** pdfinfo 页数;pdfinfo 不可用 → null(页数未知,不以 size 估算冒充) */
22
+ pageCount: number | null;
23
+ fileSize: number;
24
+ /** Path relative to CWD at creation time, for stable display */
25
+ displayPath: string;
26
+ };
27
+ /**
28
+ * full-PDF 原生 document 读不支持(0.1.85-B/C,工单 §1-B/§1-C):provider
29
+ * 无 document 块映射且过不了补充合法化门(text/image 允许面)——双体
30
+ * FileReadTool 无 pages 读 PDF 整支显式错误。附件/压缩消费面以此判定
31
+ * 回落引用车道(compact → compact_file_reference;at-mention 本就经
32
+ * tryGetPDFReference 分流),不静默丢附件、不虚报已读。message 与 Task B
33
+ * 显式指引文案一致('current provider' + 'pages parameter')。
34
+ */
35
+ export declare class FullPDFReadUnsupportedError extends Error {
36
+ constructor(message: string);
37
+ }
38
+ export declare function formatPDFReferenceForModel(reference: PDFReferenceMetadata): string;
39
+ /**
40
+ * D 波(0.1.85-D,工单 §1-D「恢复/压缩仍保引用」)落盘白名单投影:任意
41
+ * attachment 值 → 五字段 PDFReferenceMetadata | null。双 record 车道
42
+ * (engine session/record.ts + tui utils/sessionStorage.ts)落盘前的唯一
43
+ * 通道——**不 spread 原对象**:恶意/意外额外字段(base64/Buffer/content
44
+ * 等正文形字段)一律剥除不落盘;五字段缺一或类型不符 → null(不落盘,
45
+ * 不放宽)。引用≠正文:落盘的只有文件位置与页数/大小元数据,零 PDF
46
+ * bytes;resume 后 params attachment 支(Task A)据此投影四要素必读文本,
47
+ * 模型按本次权限重读(文件替换→新内容;删除/deny→Read 显式失败,无旧
48
+ * 页图假答面)。
49
+ */
50
+ export declare function projectPDFReferenceForRecord(att: unknown): PDFReferenceMetadata | null;
51
+ /**
52
+ * R-085-1(0.1.86 H,工单 §H「修法 A」):从压缩输入消息收集 @PDF 引用
53
+ * 附件(projectPDFReferenceForRecord 五字段白名单投影——与落盘同源,恶意
54
+ * 额外字段剥除;按 filename 去重防重复膨胀,后值覆盖 = 更近的引用获胜)。
55
+ * 压缩吃掉全部历史附件后,post-compact 重建引用(不重建正文),模型按
56
+ * 本次权限 Read(文件替换→新内容;删除/deny→显式失败,无旧页图假答面)。
57
+ *
58
+ * 0.1.85-D 起源 = TUI contextBodies/compact(reactiveCompact 消费面);
59
+ * R-085-1 迁入 shared 单一事实源:ENGINE compactConversation(富体 manual
60
+ * /compact + auto-compact rich,裁剪 headless)同样在 compact 时重建为
61
+ * 边界后 attachment 记录(buildPostCompactMessages attachments 槽位),
62
+ * JSONL 边界后落盘 → resume 边界截断(sessionStoragePortable in-stream
63
+ * truncate)不再消灭唯一投影来源 → params attachment 支(C85-A)投影。
64
+ * 参数取结构最小形(type/attachment 可选读),TUI/engine 双 Message 并存
65
+ * 面均天然可传入。
66
+ */
67
+ export declare function collectPDFReferenceAttachmentsForCompact(messages: readonly {
68
+ type?: unknown;
69
+ attachment?: unknown;
70
+ }[]): PDFReferenceMetadata[];
@@ -0,0 +1,24 @@
1
+ /**
2
+ * P1 mailbox 审批兜底 deadline 策略(0.1.37 ⑧ 收敛:shared 单一事实源)。
3
+ *
4
+ * 0.1.36 切片① 原定义在 src/swarm/inProcessRunner.ts(engine 面)。0.1.37 ⑧ 封
5
+ * TUI pane-worker 用户面(swarmWorkerHandler worker 侧 promise)时,boundaries
6
+ * 规则 tui↛swarm(eslint.config.mjs tui allow 面不含 swarm)→ 两面(swarm
7
+ * engine + tui)共同收敛到 shared 叶子经门面消费:env 名 + 缺省值 + fail-closed
8
+ * 措辞单一事实源,两消费面不漂移。
9
+ *
10
+ * 消费面:
11
+ * - engine:src/swarm/inProcessRunner.ts(mailbox 回退支 gate,0.1.36 切片①)
12
+ * - tui:src/tui/hooks/toolPermission/handlers/swarmWorkerHandler.ts(worker
13
+ * 侧 promise 第 4 终态,0.1.37 ⑧)
14
+ */
15
+ /** P1:mailbox 兜底 deadline 解析(env 覆盖 + 缺省回落;纯面 = 判别单测可测)。 */
16
+ export declare function resolveMailboxPermissionDeadlineMs(): number;
17
+ /**
18
+ * P1:timeout 终态 fail-closed deny 的模型可见 reason(unavailable 语义,**deny**
19
+ * 措辞——超时场景恰是「无人可确认」,非 "confirmation required";带 deadline Nms
20
+ * 可审计)。engine 面经 toolExecution ask:false 支渲染 `permission denied: <reason>`
21
+ * (is_error tool_result,模型可见、回合继续);TUI 面经 buildReject 拼
22
+ * SUBAGENT 前缀送回 worker agent(A2 语义:不 abort,回合继续)。
23
+ */
24
+ export declare function approvalUnavailableReason(deadlineMs: number): string;
@@ -0,0 +1,8 @@
1
+ export type Platform = 'macos' | 'windows' | 'wsl' | 'linux' | 'unknown';
2
+ /** 国内目标支持的宿主平台(wsl 归 Linux 族)。 */
3
+ export declare const SUPPORTED_PLATFORMS: Platform[];
4
+ /**
5
+ * 探测宿主平台(模块级 memoize——平台一次定形)。
6
+ * linux 下再读 /proc/version 判 WSL(Microsoft 标记),判不出回落 linux。
7
+ */
8
+ export declare const getPlatform: () => Platform;
@@ -0,0 +1,110 @@
1
+ /**
2
+ * 字符串工具纯函数(C1 叶子下沉,整文件复制自旧仓 utils/stringUtils.ts)。
3
+ *
4
+ * 零依赖纯函数:无 import,不碰 fs/env/debug,任何域可经 shared 门面消费。
5
+ * 旧仓消费者:shell(output 截断)/ diff 渲染(shebang 首行)/ CJK IME 归一化等。
6
+ */
7
+ /**
8
+ * Escapes special regex characters in a string so it can be used as a literal
9
+ * pattern in a RegExp constructor.
10
+ */
11
+ export declare function escapeRegExp(str: string): string;
12
+ /**
13
+ * Uppercases the first character of a string, leaving the rest unchanged.
14
+ * Unlike lodash `capitalize`, this does NOT lowercase the remaining characters.
15
+ *
16
+ * @example capitalize('fooBar') → 'FooBar'
17
+ * @example capitalize('hello world') → 'Hello world'
18
+ */
19
+ export declare function capitalize(str: string): string;
20
+ /**
21
+ * Returns the singular or plural form of a word based on count.
22
+ * Replaces the inline `word${n === 1 ? '' : 's'}` idiom.
23
+ *
24
+ * @example plural(1, 'file') → 'file'
25
+ * @example plural(3, 'file') → 'files'
26
+ * @example plural(2, 'entry', 'entries') → 'entries'
27
+ */
28
+ export declare function plural(n: number, word: string, pluralWord?: string): string;
29
+ /**
30
+ * Returns the first line of a string without allocating a split array.
31
+ * Used for shebang detection in diff rendering.
32
+ */
33
+ export declare function firstLineOf(s: string): string;
34
+ /**
35
+ * Counts occurrences of `char` in `str` using indexOf jumps instead of
36
+ * per-character iteration. Structurally typed so Buffer works too
37
+ * (Buffer.indexOf accepts string needles).
38
+ */
39
+ export declare function countCharInString(str: {
40
+ indexOf(search: string, start?: number): number;
41
+ }, char: string, start?: number): number;
42
+ /**
43
+ * Normalize full-width (zenkaku) digits to half-width digits.
44
+ * Useful for accepting input from Japanese/CJK IMEs.
45
+ */
46
+ export declare function normalizeFullWidthDigits(input: string): string;
47
+ /**
48
+ * Normalize full-width (zenkaku) space to half-width space.
49
+ * Useful for accepting input from Japanese/CJK IMEs (U+3000 → U+0020).
50
+ */
51
+ export declare function normalizeFullWidthSpace(input: string): string;
52
+ /**
53
+ * Safely joins an array of strings with a delimiter, truncating if the result exceeds maxSize.
54
+ *
55
+ * @param lines Array of strings to join
56
+ * @param delimiter Delimiter to use between strings (default: ',')
57
+ * @param maxSize Maximum size of the resulting string
58
+ * @returns The joined string, truncated if necessary
59
+ */
60
+ export declare function safeJoinLines(lines: string[], delimiter?: string, maxSize?: number): string;
61
+ /**
62
+ * A string accumulator that safely handles large outputs by truncating from the end
63
+ * when a size limit is exceeded. This prevents RangeError crashes while preserving
64
+ * the beginning of the output.
65
+ */
66
+ export declare class EndTruncatingAccumulator {
67
+ private readonly maxSize;
68
+ private content;
69
+ private isTruncated;
70
+ private totalBytesReceived;
71
+ /**
72
+ * Creates a new EndTruncatingAccumulator
73
+ * @param maxSize Maximum size in characters before truncation occurs
74
+ */
75
+ constructor(maxSize?: number);
76
+ /**
77
+ * Appends data to the accumulator. If the total size exceeds maxSize,
78
+ * the end is truncated to maintain the size limit.
79
+ * @param data The string data to append
80
+ */
81
+ append(data: string | Buffer): void;
82
+ /**
83
+ * Returns the accumulated string, with truncation marker if truncated
84
+ */
85
+ toString(): string;
86
+ /**
87
+ * Clears all accumulated data
88
+ */
89
+ clear(): void;
90
+ /**
91
+ * Returns the current size of accumulated data
92
+ */
93
+ get length(): number;
94
+ /**
95
+ * Returns whether truncation has occurred
96
+ */
97
+ get truncated(): boolean;
98
+ /**
99
+ * Returns total bytes received (before truncation)
100
+ */
101
+ get totalBytes(): number;
102
+ }
103
+ /**
104
+ * Truncates text to a maximum number of lines, adding an ellipsis if truncated.
105
+ *
106
+ * @param text The text to truncate
107
+ * @param maxLines Maximum number of lines to keep
108
+ * @returns The truncated text with ellipsis if truncated
109
+ */
110
+ export declare function truncateToLines(text: string, maxLines: number): string;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * shared/swarmSchemaFilter — swarm 扩参字段 wire 投影过滤面(0.1.93 W-D-A,
3
+ * f4 批复五(c):过滤面落 engine 单源 = shared 底层,modelprovider/params.ts
4
+ * (print + TUI 双车道 wire 投影)与 tui/utils/api.ts 同消费)。
5
+ *
6
+ * 上游契约实锤(0.1.93 插桩 F2 + 本仓 tui/utils/api.ts SWARM_FIELDS_BY_TOOL
7
+ * 对偶逐字):Agent 扩 name/team_name/mode;ExitPlanMode 扩
8
+ * launchSwarm/teammateCount。门 OFF 时两车道 wire schema 均剥除(判据④
9
+ * 「门 OFF 缺省不可见」载体);门 ON 原样保留。
10
+ *
11
+ * 纯函数面(无 engine 依赖——engine 工具名常量不可 import 进 shared,表键
12
+ * = 字面量与 tui/engine 两侧常量值逐字同源:'Agent' / 'ExitPlanMode')。
13
+ */
14
+ /** 表键 = AGENT_TOOL_NAME / EXIT_PLAN_MODE_V2_TOOL_NAME 常量值(tui 与
15
+ * engine 两侧单一事实源同值;LEGACY_AGENT_TOOL_NAME 'Task' 沿 tui 表先例
16
+ * 不入——旧名工具面随 legacy alias 面,不在本波扩参域)。 */
17
+ export declare const SWARM_FIELDS_BY_TOOL: Record<string, string[]>;
18
+ /**
19
+ * Filters swarm-related fields from a tool's input schema when swarms are
20
+ * not enabled. Called at wire projection sites (params.ts / tui api.ts).
21
+ * 非 swarm 表工具原样返回(零拷贝)。
22
+ */
23
+ export declare function filterSwarmFieldsFromSchema(toolName: string, schema: Record<string, unknown> | undefined | null, swarmEnabled: boolean): Record<string, unknown> | undefined | null;
@@ -0,0 +1,151 @@
1
+ import { z } from 'zod';
2
+ import type { PermissionMode } from './types-session.js';
3
+ /** schema 版本(v2 = 本波定形;v1 = 0.1.36 旧 TeamFile 无版本字段,弃置)。 */
4
+ export declare const TEAM_FILE_SCHEMA_VERSION = 2;
5
+ /** durable 档取值(settings teams.persistence;缺省 'memory')。 */
6
+ export type TeamPersistenceMode = 'memory' | 'durable';
7
+ /** 0.1.36 TeamAllowedPath 收编(tui 副本逐字段)。 */
8
+ export type TeamAllowedPath = {
9
+ path: string;
10
+ toolName: string;
11
+ addedBy: string;
12
+ addedAt: number;
13
+ };
14
+ /** Form A 角色化成员名册条目(自 engine/tools/team/teamServices.ts 单源收编;
15
+ * 原地 re-export 保持消费面不变)。 */
16
+ export type TeamRosterEntry = {
17
+ name: string;
18
+ role?: string;
19
+ goal?: string;
20
+ backstory?: string;
21
+ };
22
+ /** v2 成员条目 = TeamServicesFile member 面 + 0.1.36 全量字段收编。 */
23
+ export type TeamMemberV2 = {
24
+ agentId: string;
25
+ name: string;
26
+ agentType?: string;
27
+ model?: string;
28
+ prompt?: string;
29
+ color?: string;
30
+ planModeRequired?: boolean;
31
+ joinedAt: number;
32
+ tmuxPaneId: string;
33
+ cwd: string;
34
+ worktreePath?: string;
35
+ sessionId?: string;
36
+ subscriptions: string[];
37
+ backendType?: string;
38
+ isActive?: boolean;
39
+ mode?: PermissionMode;
40
+ };
41
+ /** 0.1.36 遗产全量字段(hiddenPaneIds/teamAllowedPaths,tmux 车道消费面)
42
+ * 收编为 v2 可选成员——弃置定谳针对无版本文件拒读,不丢在场字段。 */
43
+ export type TeamFileLegacyExtras = {
44
+ hiddenPaneIds?: string[];
45
+ teamAllowedPaths?: TeamAllowedPath[];
46
+ };
47
+ /** v2 team file(durable 支写形)。 */
48
+ export type TeamFileV2 = {
49
+ schemaVersion: 2;
50
+ name: string;
51
+ description?: string;
52
+ createdAt: number;
53
+ leadAgentId: string;
54
+ leadSessionId?: string;
55
+ /** 0.1.93 W-D-A 裁除回填位(teamCreateTool Form A 注记 260 行)。 */
56
+ leadModel?: string;
57
+ /** v2 恒 'durable'(写入即 durable 支)。 */
58
+ persistence: 'durable';
59
+ /** 七条(b) 二次验证锚:boot 级 lead 进程 instance id(getLeadInstanceId)。 */
60
+ leadInstanceId: string;
61
+ roster?: TeamRosterEntry[];
62
+ members: TeamMemberV2[];
63
+ } & TeamFileLegacyExtras;
64
+ /** 0.1.36 遗产形(无 schemaVersion)= v2 剥持久面字段(弃置定谳:禁新增
65
+ * 消费点,tmux 车道现网行为维持;本别名 = 双副本收敛单源锚)。 */
66
+ export type TeamFile = Omit<TeamFileV2, 'schemaVersion' | 'persistence' | 'leadInstanceId' | 'roster'>;
67
+ export declare const teamFileV2Schema: z.ZodObject<{
68
+ schemaVersion: z.ZodLiteral<2>;
69
+ name: z.ZodString;
70
+ description: z.ZodOptional<z.ZodString>;
71
+ createdAt: z.ZodNumber;
72
+ leadAgentId: z.ZodString;
73
+ leadSessionId: z.ZodOptional<z.ZodString>;
74
+ leadModel: z.ZodOptional<z.ZodString>;
75
+ persistence: z.ZodLiteral<"durable">;
76
+ leadInstanceId: z.ZodString;
77
+ roster: z.ZodOptional<z.ZodArray<z.ZodObject<{
78
+ name: z.ZodString;
79
+ role: z.ZodOptional<z.ZodString>;
80
+ goal: z.ZodOptional<z.ZodString>;
81
+ backstory: z.ZodOptional<z.ZodString>;
82
+ }, z.core.$strip>>>;
83
+ members: z.ZodArray<z.ZodObject<{
84
+ agentId: z.ZodString;
85
+ name: z.ZodString;
86
+ agentType: z.ZodOptional<z.ZodString>;
87
+ model: z.ZodOptional<z.ZodString>;
88
+ prompt: z.ZodOptional<z.ZodString>;
89
+ color: z.ZodOptional<z.ZodString>;
90
+ planModeRequired: z.ZodOptional<z.ZodBoolean>;
91
+ joinedAt: z.ZodNumber;
92
+ tmuxPaneId: z.ZodString;
93
+ cwd: z.ZodString;
94
+ worktreePath: z.ZodOptional<z.ZodString>;
95
+ sessionId: z.ZodOptional<z.ZodString>;
96
+ subscriptions: z.ZodArray<z.ZodString>;
97
+ backendType: z.ZodOptional<z.ZodString>;
98
+ isActive: z.ZodOptional<z.ZodBoolean>;
99
+ mode: z.ZodOptional<z.ZodString>;
100
+ }, z.core.$strip>>;
101
+ hiddenPaneIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
102
+ teamAllowedPaths: z.ZodOptional<z.ZodArray<z.ZodObject<{
103
+ path: z.ZodString;
104
+ toolName: z.ZodString;
105
+ addedBy: z.ZodString;
106
+ addedAt: z.ZodNumber;
107
+ }, z.core.$strip>>>;
108
+ }, z.core.$strip>;
109
+ export type ParsedTeamFileV2 = {
110
+ ok: true;
111
+ file: TeamFileV2;
112
+ } | {
113
+ ok: false;
114
+ error: string;
115
+ };
116
+ /** v2 回读解析(七条(a) 白名单校验 + 演进拒读 fail-visible)。
117
+ * 错误面含测得 schemaVersion(或 'missing')与迁移指引——禁静默降级半解析。 */
118
+ export declare function parseTeamFileV2(content: string): ParsedTeamFileV2;
119
+ /** lead 进程 instance id(boot 级模块缓存;测试可 resetLeadInstanceId 复位)。 */
120
+ export declare function getLeadInstanceId(): string;
121
+ /** 测试复位(teardown 用)。 */
122
+ export declare function resetLeadInstanceId(): void;
123
+ export declare function getTeamsDirShared(): string;
124
+ /** stale lock 夺锁双门参数(lock-face §2 必答定形):mtime 年龄与 PID 存活
125
+ * 双条件与;有界重试后 fail-visible 不夺锁;夺锁成功记告警禁静默。 */
126
+ export declare const STALE_LOCK_MS = 10000;
127
+ export declare const LOCK_RETRY_MAX = 3;
128
+ /** team file 路径(与 swarm/tui 两车道 getTeamFilePath 同语义)。 */
129
+ export declare function getTeamFilePathShared(teamName: string): string;
130
+ type StaleLockDecision = {
131
+ action: 'acquire';
132
+ } | {
133
+ action: 'steal';
134
+ warning: string;
135
+ } | {
136
+ action: 'fail';
137
+ error: string;
138
+ };
139
+ /** stale lock 夺锁双门判(lock-face §2):mtime > STALE_LOCK_MS **且**
140
+ * lock PID 不存活才夺;单条件不满足 = 未 stale。双门全 stale → 夺锁
141
+ * (warning fail-visible 文案可判读,禁 log-only 静默形)。 */
142
+ export declare function decideStaleLock(lockMtimeMs: number, lockPid: number | undefined, nowMs?: number): StaleLockDecision;
143
+ /** durable 原子写(tmp+rename;写中 kill reader 见旧全量态零 partial)。
144
+ * 调用方须已在 durable 支内(OFF 支不可达 = F1 standing 判据)。 */
145
+ export declare function writeTeamFileV2Atomic(teamName: string, file: TeamFileV2): Promise<void>;
146
+ /** durable 回读(七条(a) parseTeamFileV2 白名单校验;foreign = fail-visible
147
+ * 错误面,禁半解析)。文件不存在 = null(调用方回落现网 Form A 行为)。 */
148
+ export declare function readTeamFileV2(teamName: string): Promise<TeamFileV2 | null>;
149
+ /** tmp 孤儿清扫(读路径发现 tmp 残留 → fail-visible 告警 + 清扫,禁静默)。 */
150
+ export declare function sweepTmpOrphans(teamName: string): Promise<string[]>;
151
+ export {};
@@ -0,0 +1,112 @@
1
+ /**
2
+ * team inbox schema 单源(0.1.100 W-D-B-1 S4,lock-face §4 D-④)。
3
+ *
4
+ * 载体 = 文件面基座(`~/.atlas/teams/<t>/inboxes/<a>.json`,mailbox 内存
5
+ * store 定位 = 缓存/队列层,非第二事实源)。本模块 = inbox 文件信封
6
+ * (消息数组 + schemaVersion + 满载上界常量)+ 读写原子原语(tmp+rename
7
+ * 同 §2 / teamFileSchema.writeTeamFileV2Atomic 先形)单点。
8
+ *
9
+ * 双车道同源约束(§9 格 8):engine `messaging/mailbox.ts` 与 tui
10
+ * `utils/teammateMailbox.ts`(tmux 车道)双双改消费本模块——禁第三副本。
11
+ *
12
+ * 信封演进(§9 格 5 域):本波起写面为 envelope
13
+ * `{ schemaVersion: 1, messages: [...] }`;读面兼容 pre-envelope 裸数组
14
+ * (升级路径 in-flight team 不可 brick——读面刻意识别旧形并按信封语义
15
+ * 回填,属显式 legacy 识别,非半解析;异 schemaVersion / 非法记录 →
16
+ * fail-visible 拒读禁半解析)。
17
+ *
18
+ * 七条(d):消息记录 `source` 字段白名单('lead' | 'teammate',缺省 =
19
+ * legacy 无来源)+ 消费前置校验助手 isInboxSourceAllowed(方向性白名单:
20
+ * 指令形协议消息只认 lead 来源、汇报形只认 teammate 来源;legacy 缺省
21
+ * 放行 = 不伪造判别面)。
22
+ *
23
+ * 七条(e):MAX_INBOX_MESSAGES 满载拒收上界(写入面拒收 + fail-visible
24
+ * 告警,禁静默丢最旧——工单 §6 必改 2(e))。
25
+ */
26
+ import { z } from 'zod';
27
+ export declare const INBOX_SCHEMA_VERSION = 1;
28
+ /** 满载拒收上界(七条(e):拒收 fail-visible,禁静默丢最旧)。 */
29
+ export declare const MAX_INBOX_MESSAGES = 200;
30
+ /** 消息来源白名单(七条(d):信封消息 source 字段仅此二值)。 */
31
+ export type InboxMessageSource = 'lead' | 'teammate';
32
+ /**
33
+ * inbox 消息记录(两车道 TeammateMessage 的共享形)。未知字段在 schema
34
+ * 层剥除(七条(a):落盘文件 = 不可信输入,白名单校验)。
35
+ */
36
+ export type SharedInboxMessage = {
37
+ from: string;
38
+ text: string;
39
+ timestamp: string;
40
+ read: boolean;
41
+ color?: string;
42
+ summary?: string;
43
+ /** 来源白名单标注(七条(d));legacy 记录无此字段。 */
44
+ source?: InboxMessageSource;
45
+ };
46
+ /**
47
+ * 记录 schema(白名单 + 未知字段剥除;zod strip 缺省行为)。
48
+ * timestamp 容忍缺省(default ''):写面存在不携带 timestamp 的调用形
49
+ * (waitForNextPromptOrShutdown H 判据格实伤 2026-11-12;pre-S4 裸读面
50
+ * 无校验故容忍),必填判 = legacy in-flight 记录整体拒读 brick。
51
+ */
52
+ export declare const inboxMessageSchema: z.ZodObject<{
53
+ from: z.ZodString;
54
+ text: z.ZodString;
55
+ timestamp: z.ZodDefault<z.ZodString>;
56
+ read: z.ZodBoolean;
57
+ color: z.ZodOptional<z.ZodString>;
58
+ summary: z.ZodOptional<z.ZodString>;
59
+ source: z.ZodOptional<z.ZodEnum<{
60
+ lead: "lead";
61
+ teammate: "teammate";
62
+ }>>;
63
+ }, z.core.$strip>;
64
+ /** inbox 文件信封(schemaVersion + 消息数组)。 */
65
+ export declare const inboxEnvelopeSchema: z.ZodObject<{
66
+ schemaVersion: z.ZodLiteral<1>;
67
+ messages: z.ZodArray<z.ZodObject<{
68
+ from: z.ZodString;
69
+ text: z.ZodString;
70
+ timestamp: z.ZodDefault<z.ZodString>;
71
+ read: z.ZodBoolean;
72
+ color: z.ZodOptional<z.ZodString>;
73
+ summary: z.ZodOptional<z.ZodString>;
74
+ source: z.ZodOptional<z.ZodEnum<{
75
+ lead: "lead";
76
+ teammate: "teammate";
77
+ }>>;
78
+ }, z.core.$strip>>;
79
+ }, z.core.$strip>;
80
+ export type InboxEnvelope = z.infer<typeof inboxEnvelopeSchema>;
81
+ /** 读原语结果(fail-visible 面:error 文案可判读,禁静默半解析)。 */
82
+ export type ReadInboxResult = {
83
+ ok: true;
84
+ messages: SharedInboxMessage[];
85
+ } | {
86
+ ok: false;
87
+ error: string;
88
+ };
89
+ /**
90
+ * 读 inbox 文件(fail-visible 拒读形):
91
+ * - ENOENT → 空信箱(现网行为逐字);
92
+ * - envelope 且 schemaVersion === 1 → 白名单校验回填;
93
+ * - envelope 且异 schemaVersion → 拒读(禁半解析,§9 格 5 域);
94
+ * - pre-envelope 裸数组 → 显式 legacy 识别(逐记录白名单校验剥未知字段;
95
+ * 任一记录非法 → 整体拒读,禁半解析);
96
+ * - 其余(非 JSON / 非数组非信封 / 记录非法)→ 拒读 + 可判读 error。
97
+ */
98
+ export declare function readInboxFile(filePath: string): Promise<ReadInboxResult>;
99
+ /**
100
+ * 写 inbox 文件(原子原语 tmp+rename:写中 kill reader 见旧全量态零
101
+ * partial;ack 持久化 F7 回归防 = mark-read 走本原语,写中 kill 不撕
102
+ * ack 态)。目录由调用方保证(两车道 ensureInboxDir 先行)。
103
+ */
104
+ export declare function writeInboxFileAtomic(filePath: string, messages: SharedInboxMessage[]): Promise<void>;
105
+ /**
106
+ * 消费前置校验(七条(d)):方向性来源白名单。legacy 记录(source 缺省)
107
+ * 放行 = 不伪造判别面;显式白名单外来源 → 拒收该协议消息(fail-visible,
108
+ * 由调用方日志呈面)。用于 permission/shutdown 类协议消息消费点。
109
+ */
110
+ export declare function isInboxSourceAllowed(message: Pick<SharedInboxMessage, 'source'>, allowed: ReadonlyArray<InboxMessageSource>): boolean;
111
+ /** 满载拒收 fail-visible 文案(含当前长度/上界,§4)。 */
112
+ export declare function inboxFullWarning(recipient: string, length: number): string;