@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,63 @@
1
+ /**
2
+ * AtlasWeb S0-R cursor/result snapshot 账本(工单 §4.3 / 呈批书 §7.5)。
3
+ *
4
+ * opaque 随机 token ↔ 实例内绑定 {product, scope, session, baselineId,
5
+ * generation, revision, expiry}。伪造/未知 → 'unknown'(调用方按
6
+ * resetRequired+新 baseline 或 closed 处置);跨域 → 'mismatch'
7
+ * (scopeDenied);过期 → 'expired'(resetRequired+新 baseline)。
8
+ * LRU 淘汰序:未 pin(无活跃 subscription 绑定)先淘;全 pinned 淘最旧
9
+ * pinned 并回调 onActiveEvict(显式 resetRequired,禁静默失效)。
10
+ */
11
+ export type CursorVerifyResult = {
12
+ ok: true;
13
+ binding: CursorBinding;
14
+ } | {
15
+ ok: false;
16
+ why: 'unknown' | 'expired' | 'mismatch';
17
+ message: string;
18
+ };
19
+ export interface CursorBinding {
20
+ /**
21
+ * token 内部版本化(S0-R5 呈批书 §3 @6e772c02):opaque token 不变,
22
+ * payload 结构版本字段在册(v1 = 首个携字节锚的版本;升级 wire 不
23
+ * breaking——消费侧只持 opaque token)。
24
+ */
25
+ v: 1;
26
+ productId: string;
27
+ scopeId: string;
28
+ sessionId: string;
29
+ baselineId: string;
30
+ generation: string;
31
+ revision: number;
32
+ /**
33
+ * S0-R5 加性字节锚(§12-3 机制钉):resume 续接的读取起点(完整记录
34
+ * 边界或含 pendingPartial 的 EOF)与文件身份锚。加性面,既有五字段
35
+ * 不动。
36
+ */
37
+ byteOffset: number;
38
+ ino: number;
39
+ }
40
+ export declare class CursorLedger {
41
+ private readonly capacity;
42
+ private readonly ttlMs;
43
+ private readonly maxPayloadBytes;
44
+ private readonly onActiveEvict?;
45
+ private readonly entries;
46
+ private readonly payloadBytes;
47
+ constructor(capacity: number, ttlMs: number, maxPayloadBytes: number, onActiveEvict?: ((token: string, binding: CursorBinding) => void) | undefined);
48
+ issue(binding: CursorBinding, payloadBytes?: number): string;
49
+ /** 活跃 subscription 绑定 pin(LRU 淘序:未 pin 先淘)。 */
50
+ pin(token: string): void;
51
+ unpin(token: string): void;
52
+ refreshExpiry(token: string): void;
53
+ verify(token: string, who: {
54
+ productId: string;
55
+ scopeId: string;
56
+ sessionId: string;
57
+ }): CursorVerifyResult;
58
+ totalPayloadBytes(): number;
59
+ size(): number;
60
+ private evictForInsert;
61
+ }
62
+ /** 语义化构造:账本实例共用 invalidRequest 拒面(容量/TTL 由 limits 校验)。 */
63
+ export declare function assertLedgerConfig(capacity: number, ttlMs: number): void;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * AtlasWeb S0-R web 出口(工单 §4.5)+ B0 执行出口面(S2)。
3
+ *
4
+ * 纯 re-export 面:零副作用(禁入口导入就跑 CLI)、零 TUI/private TSX
5
+ * 泄漏(加载图审计);声明只依赖 contract 公开类型(经 ./contract 相对
6
+ * shim)。
7
+ * S4 落地细化附注:`./web-session-runtime` pack 构建入口已分离至
8
+ * runtimeEntry.ts(pack 合同「零 zod 依赖」× 本文件执行出口面 zod 闭包,
9
+ * 两锚定形消解 = pack entry 分离;本文件面 = runtime 面 + 执行出口面)。
10
+ * S0-R2 形 A(lock-face @25cb7454 §1/§2,f4 批复工单 §7 @351c74c4):本出口
11
+ * 扩具名导出 `createDefaultReadonlySessionRuntime`(engine 真体随 bundle,
12
+ * pack 格重形 = engine/session 只读闭包允许);注入缝
13
+ * (createReadonlySessionRuntime options.engine)保留不动(预答不变量)。
14
+ * 内部面不入出口:atlasWebSessionEngine / buildConversationChain /
15
+ * TranscriptMessage(d.ts 泄漏面钉②)。
16
+ */
17
+ export { createReadonlySessionRuntime, type ReadonlySessionRuntime, type ReadonlySessionRuntimeOptions, type ReadonlySessionEngine, type ReadonlySessionScopes, type ReadonlySessionLimits, type ResolvedLimits, type ListSessionsRequest, type ListSessionsResult, type ReplaySessionRequest, type ReplaySessionResult, type FollowSessionRequest, type FollowSubscription, type SearchSessionsRequest, type SearchSessionsResult, } from './readonlyRuntime.js';
18
+ export { createDefaultReadonlySessionRuntime, type AtlasWebSessionRuntimeOptions, } from './runtimeDefault.js';
19
+ export type { FollowHandle } from './follow.js';
20
+ export type { SessionStoreAdapter, SessionStoreScopes, SessionFileEntry, TranscriptStat, TranscriptTail, } from './sessionStoreAdapter.js';
21
+ export type { NeutralProjection, NeutralProjectionMessage, NeutralBlock, ProjectionSourceMessage, ProjectionEngineDeps, ProjectionLoad, } from './projection.js';
22
+ export { WebSessionError, type WebSessionErrorCode } from './errors.js';
23
+ export { createExecutionOutlet, type ExecutionOutlet, type ExecutionOutletOptions, type ExecutionDispatchResult, type WebExecutionProbeResult, } from '../../kernel/execution/executionOutlet.js';
24
+ export { EXECUTION_SCHEMA_VERSION, EXECUTION_PROTOCOL_VERSION, EXECUTION_CAPABILITY_DISABLED_CODE, WebExecutionCommandSchema, WebExecutionEventSchema, WebExecutionErrorSchema, ExecutionBindSchema, type ExecutionBind, type ExecutionReplay, type WebExecutionCommand, type WebExecutionEvent, type WebExecutionError, } from '../../kernel/protocol/webExecutionV0.js';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * AtlasWeb S0-R(0.1.116 候)web 域错误单源。
3
+ *
4
+ * 工单 docs/2026-11-15-atlasweb-s0-upstream-delivery-ticket.md §4.1 /
5
+ * 呈批书 docs/2026-11-15-s0-ur-lockface-brief.md §7.3-§7.5(f4 批复
6
+ * @f1f1099d)。code 域 = contract 错误联合 10 codes
7
+ * (src/kernel/protocol/webSessionV0.ts WebSessionErrorSchema)。
8
+ * ioUnavailable 独占 retryable(契约钉死,其余 code 不携该字段)。
9
+ */
10
+ export type WebSessionErrorCode = 'unsupportedSchema' | 'invalidRequest' | 'scopeDenied' | 'notFound' | 'corruptData' | 'ioUnavailable' | 'cursorExpired' | 'resourceLimit' | 'cancelled' | 'closed';
11
+ export declare class WebSessionError extends Error {
12
+ readonly code: WebSessionErrorCode;
13
+ /** 仅 ioUnavailable 语义位(契约:其余 code 不投影该字段)。 */
14
+ readonly retryable?: boolean;
15
+ constructor(code: WebSessionErrorCode, message: string, retryable?: boolean);
16
+ }
@@ -0,0 +1,82 @@
1
+ /**
2
+ * AtlasWeb S0-R follow 订阅机(工单 §4.3 一致性/恢复 + 呈批书 §7.5
3
+ * 采样序/cursor/lease/终态优先序,f4 批复 @f1f1099d + §5.7 @98c51bd6
4
+ * 终态形态钉死:closed 恒为唯一 terminal 事件 kind——error 终态路径 =
5
+ * error{code} → closed 成对送达,终态后零数据事件)。
6
+ *
7
+ * 采样序(§4.3 先采样后 baseline,一致 snapshot):baseline 前后双采样
8
+ * 三元组全等方采纳(ino/size/mtime),不夏现有界重试(3 次)→
9
+ * ioUnavailable retryable。半行不当完整记录等下一采样;非法完整行
10
+ * corruptData 不无限等待。增量尾读 = 上次 offset 起步只解析新增字节;
11
+ * 稳定文件 repeat poll 走 O(1) stat 通道(零 read/零 parse/零事件)。
12
+ * 不连续(truncate/replace/compact,ino 变或 size < offset)→
13
+ * resetRequired + 新 generation/baseline,旧消息不再采纳。
14
+ * S0-R5 重采样兜底(呈批书 §2 @6e772c02,f4 §13 批复):同 inode
15
+ * size > offset 的 rewrite 漏过单向守卫 → 旧 offset 尾读 unparseable
16
+ * complete record 时不再硬终流,先做单次身份重采样复核(成本上界
17
+ * ≤ maxTranscriptBytes,禁循环)→ 3-way 分类:prefix 异 →
18
+ * resetRequired + 新 baseline;全量可解析且 prefix 同(瞬态撕裂/半行
19
+ * 竞态)→ 静默自愈零终态;仍 unparseable → corruptData 真损坏
20
+ * (终态收窄至此)。
21
+ * S0-R5 resumeCursor 续接(呈批书 §3):verify ok → 内部 parse
22
+ * [0, byteOffset) 重建投影态(不发 baseline 事件——零重放)→
23
+ * offset/ino 锚定进既有轮询(断连窗 append 从文件本身恢复);verify
24
+ * 三因(unknown/expired/mismatch)统一 → resetRequired 显式分态 +
25
+ * 新 baseline(分因 message 透传,禁静默 fresh);resume 起点过 ②
26
+ * 同一判定面(offset 越界/ino 错配 → resetRequired 同形)。
27
+ *
28
+ * 终态恰一(优先序 §7.5):closed(4) > error(cancelled)(3) > 其余
29
+ * error(2),高可覆低(替换队内未消费终态对);resetRequired 非终态。
30
+ * close() 加盟 worker 停止(有界 2s);订阅槽释放恰一次(worker 实停
31
+ * 才释放,杜绝 close 竞态下槽位早释的限额绕过)。
32
+ */
33
+ import type { WebSessionEvent } from './contract.js';
34
+ import type { CursorLedger } from './cursorLedger.js';
35
+ import type { SessionStoreAdapter } from './sessionStoreAdapter.js';
36
+ import { type ProjectionEngineDeps, type ProjectionSourceMessage } from './projection.js';
37
+ /** 投影消息源结构面(engine TranscriptMessage 的结构超集镜像,pack 域零引擎导入)。 */
38
+ export type FollowSourceMessage = ProjectionSourceMessage;
39
+ export interface FollowLimits {
40
+ pollingIntervalMs: number;
41
+ idleLeaseMs: number;
42
+ pendingEvents: number;
43
+ pendingBytes: number;
44
+ maxProjectionBytes: number;
45
+ maxRecordBytes: number;
46
+ /** S0-R5:重采样/续接全量读的字节上界(钉 3 成本界;超界 resourceLimit)。 */
47
+ maxTranscriptBytes: number;
48
+ }
49
+ export interface FollowDeps {
50
+ adapter: SessionStoreAdapter;
51
+ productId: string;
52
+ scopeId: string;
53
+ sessionId: string;
54
+ subscriptionId: string;
55
+ requestId?: string;
56
+ /**
57
+ * S0-R5 ③:opaque resume cursor(账本 token)。在场 → verify 续接支
58
+ * (零 baseline 事件);缺席 → 既有 fresh baseline。协议形
59
+ * webSessionV0 FollowSessionRequestSchema.resumeCursor optional。
60
+ */
61
+ resumeCursor?: string;
62
+ limits: FollowLimits;
63
+ signal?: AbortSignal;
64
+ ledger: CursorLedger;
65
+ /** 引擎 loader 全量基线面(显式 filePath;呈批书 §7.3 钉死形,注入缝)。 */
66
+ loadFull: (filePath: string) => Promise<{
67
+ messages: Map<string, ProjectionSourceMessage>;
68
+ leafUuids: Set<string>;
69
+ }>;
70
+ /** 经 adapter 校验链的显式路径解析(scope 授权 + containment)。 */
71
+ resolvePath: (scopeId: string, sessionId: string) => Promise<string>;
72
+ /** CLI 同规则链重建注入缝(projection 头注镜像义务)。 */
73
+ buildConversationChain: ProjectionEngineDeps['buildConversationChain'];
74
+ /** 订阅槽释放回调(worker 实停时恰一次)。 */
75
+ onRelease: () => void;
76
+ }
77
+ export interface FollowHandle {
78
+ [Symbol.asyncIterator](): AsyncIterator<WebSessionEvent>;
79
+ renewLease(): Promise<boolean>;
80
+ close(): Promise<void>;
81
+ }
82
+ export declare function createFollowSubscription(deps: FollowDeps): FollowHandle;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * AtlasWeb S0-R web 域单一资源常量表(工单 §4.4 冻结值;呈批书 §7.4
3
+ * "常量单源 src/atlascode/web/limits.ts")。
4
+ *
5
+ * 每参数 DEFAULT 可配(不得越 HARD 硬上限,host 不可调高);R-1 先落
6
+ * runtime/adapter 首车需要的界,R-2 补齐全表(pending/lease/cursor 族)。
7
+ */
8
+ export declare const MIB: number;
9
+ export declare const DEFAULT_MAX_TRANSCRIPT_BYTES: number;
10
+ export declare const HARD_MAX_TRANSCRIPT_BYTES: number;
11
+ export declare const DEFAULT_MAX_SCAN_SESSIONS = 4096;
12
+ export declare const HARD_MAX_SCAN_SESSIONS = 16384;
13
+ export declare const DEFAULT_MAX_SCOPES_PER_RUNTIME = 32;
14
+ export declare const HARD_MAX_SCOPES_PER_RUNTIME = 128;
15
+ export declare const DEFAULT_PAGE_SIZE = 50;
16
+ export declare const HARD_MAX_PAGE_SIZE = 200;
17
+ export declare const SEARCH_QUERY_MIN_CODE_POINTS = 1;
18
+ export declare const SEARCH_QUERY_MAX_CODE_POINTS = 256;
19
+ export declare const DEFAULT_MAX_RECORD_BYTES: number;
20
+ export declare const HARD_MAX_RECORD_BYTES: number;
21
+ export declare const DEFAULT_MAX_PARSE_RECORDS = 100000;
22
+ export declare const HARD_MAX_PARSE_RECORDS = 500000;
23
+ export declare const DEFAULT_MAX_PROJECTION_BYTES: number;
24
+ export declare const HARD_MAX_PROJECTION_BYTES: number;
25
+ export declare const TITLE_HEAD_BYTES: number;
26
+ /** wire 契约 title ≤512 code points(SessionSummarySchema)——钳制上限。 */
27
+ export declare const TITLE_MAX_CODE_POINTS = 512;
28
+ /** 首条 user 消息派生标题的展示截断点(≤契约 512)。 */
29
+ export declare const TITLE_USER_MESSAGE_CODE_POINTS = 120;
30
+ export declare const DEFAULT_MAX_SUBSCRIPTIONS = 16;
31
+ export declare const HARD_MAX_SUBSCRIPTIONS = 64;
32
+ export declare const DEFAULT_MAX_CONCURRENT_READS = 4;
33
+ export declare const HARD_MAX_CONCURRENT_READS = 16;
34
+ export declare const DEFAULT_MAX_PENDING_EVENTS = 8;
35
+ export declare const HARD_MAX_PENDING_EVENTS = 32;
36
+ export declare const DEFAULT_MAX_PENDING_BYTES: number;
37
+ export declare const HARD_MAX_PENDING_BYTES: number;
38
+ export declare const DEFAULT_POLLING_INTERVAL_MS = 1000;
39
+ export declare const HARD_MIN_POLLING_INTERVAL_MS = 100;
40
+ export declare const HARD_MAX_POLLING_INTERVAL_MS = 60000;
41
+ export declare const DEFAULT_REQUEST_DEADLINE_MS = 10000;
42
+ export declare const HARD_MIN_REQUEST_DEADLINE_MS = 1;
43
+ export declare const HARD_MAX_REQUEST_DEADLINE_MS = 60000;
44
+ export declare const DEFAULT_IDLE_LEASE_MS = 120000;
45
+ export declare const HARD_MIN_IDLE_LEASE_MS = 1000;
46
+ export declare const HARD_MAX_IDLE_LEASE_MS = 600000;
47
+ export declare const DEFAULT_CURSOR_TTL_MS = 600000;
48
+ export declare const HARD_MIN_CURSOR_TTL_MS = 1000;
49
+ export declare const HARD_MAX_CURSOR_TTL_MS = 3600000;
50
+ export declare const DEFAULT_CLOSE_DEADLINE_MS = 2000;
51
+ export declare const HARD_MIN_CLOSE_DEADLINE_MS = 1;
52
+ export declare const HARD_MAX_CLOSE_DEADLINE_MS = 10000;
53
+ export declare const DEFAULT_LEDGER_CAPACITY = 128;
54
+ export declare const HARD_MAX_LEDGER_CAPACITY = 1024;
55
+ export declare const DEFAULT_LEDGER_PAYLOAD_BYTES: number;
56
+ export declare const HARD_MAX_LEDGER_PAYLOAD_BYTES: number;
57
+ export declare const READ_CHUNK_SIZE: number;
58
+ export declare const PARSE_BATCH_SIZE = 256;
59
+ /**
60
+ * 有界整数校验(工单 §4.4:禁 NaN/Infinity/小数/负值;>硬上限拒)。
61
+ * value === undefined → 缺省值;不合法 → invalidRequest。
62
+ */
63
+ export declare function validateBoundedInt(name: string, value: number | undefined, defaultValue: number, hardMax: number, hardMin?: number): number;
@@ -0,0 +1,69 @@
1
+ /**
2
+ * AtlasWeb S0-R Code→中立投影(工单 §4.1 projection.ts;呈批书 §7.3
3
+ * persisted-effective-conversation 显式定义 / 必改 6 Code-neutral 词汇审计)。
4
+ *
5
+ * 输入 = loadTranscriptFull 的只读加载结果(经注入缝,本域零 engine 导入
6
+ * ——§4.5 pack 加载图审计面);输出 = contract ProjectionSchema 形
7
+ * (text/activity 两块型,无任何内部词汇)。leaf 选取 = terminal leaf 中
8
+ * timestamp 最新者(CLI 同域规则),链路 = 注入的 buildConversationChain
9
+ * (CLI 同规则 load.ts 镜像,引擎适配边界做类型焊接,见 runtimeDefault.ts);
10
+ * compact 边界行 / session 级元数据行不投影。
11
+ */
12
+ /** 投影消息源结构面(磁盘 JSONL 行的窄结构镜像;pack 域公开类型)。 */
13
+ export interface ProjectionSourceMessage {
14
+ uuid: string;
15
+ parentUuid: string | null;
16
+ type: string;
17
+ timestamp?: string | null;
18
+ message?: {
19
+ content?: unknown;
20
+ };
21
+ }
22
+ /** 注入缝:CLI 同规则链重建(load.ts buildConversationChain 镜像义务)。 */
23
+ export interface ProjectionEngineDeps {
24
+ buildConversationChain: (messages: Map<string, ProjectionSourceMessage>, leaf: ProjectionSourceMessage) => ProjectionSourceMessage[];
25
+ }
26
+ /** 投影块(contract BlockSchema 子面;label ≤256 / text 无界走 resourceLimit)。 */
27
+ export type NeutralBlock = {
28
+ kind: 'text';
29
+ text: string;
30
+ } | {
31
+ kind: 'activity';
32
+ label: string;
33
+ status?: string;
34
+ };
35
+ export interface NeutralProjectionMessage {
36
+ id: string;
37
+ role: 'user' | 'assistant' | 'system';
38
+ createdAt: string | null;
39
+ blocks: NeutralBlock[];
40
+ }
41
+ export interface NeutralProjection {
42
+ sessionId: string;
43
+ productId: string;
44
+ scopeId: string;
45
+ semantics: 'persisted-effective-conversation';
46
+ messages: NeutralProjectionMessage[];
47
+ truncated: false;
48
+ }
49
+ export interface ProjectionLoad {
50
+ messages: Map<string, ProjectionSourceMessage>;
51
+ leafUuids: Set<string>;
52
+ }
53
+ /** 事件/projection 序列化字节单一口径(replay 与 follow 共享,防兄弟路漂移)。 */
54
+ export declare function serializedProjectionBytes(p: unknown): number;
55
+ /**
56
+ * terminal leaf 集计算(load.ts:1187-1226 同规则镜像:terminal → 最近
57
+ * user/assistant 祖先;增量尾读路径复用。f4 §5.7 登记:镜像同步义务,
58
+ * 漂移守卫 = 必改5a fixture 对表 standing)。leafUuids 选 timestamp 最新者。
59
+ */
60
+ export declare function computeLeafUuids(messages: Map<string, ProjectionSourceMessage>): Set<string>;
61
+ /**
62
+ * terminal leaf 集中选 timestamp 最新者(并列取插入序末位),注入的
63
+ * CLI 同规则链重建;空载入 → 空投影。
64
+ */
65
+ export declare function projectConversation(load: ProjectionLoad, meta: {
66
+ sessionId: string;
67
+ productId: string;
68
+ scopeId: string;
69
+ }, engine: ProjectionEngineDeps): NeutralProjection;
@@ -0,0 +1,156 @@
1
+ /**
2
+ * AtlasWeb S0-R 窄只读 session runtime factory(工单 §4.2 生命周期面 /
3
+ * 呈批书 §7.3 scopeId 钉死)。
4
+ *
5
+ * R-1 首车:factory + 生命周期(start/close/epoch/不可重启)+ listSessions
6
+ * (adapter 注入缝,隔离反例先红后绿)。R-2:replaySession/followSession
7
+ * (follow 订阅机 src/atlascode/web/follow.ts)+ limits 全表解析 + 订阅槽/
8
+ * 并发读计数 + cursor ledger。search/poll 恢复与 ./web-session-runtime 出口
9
+ * = R-3。
10
+ *
11
+ * 纪律(工单 §4.2):创建/import 零应用配置探测/零写盘/零 timer;start 才
12
+ * 验授权配置;未 start 调用拒 closed('not started');close 幂等可 await;
13
+ * close 后不可 restart(重建新实例换 epoch);实例状态全自持(cache/
14
+ * revision/issued cursors/subscriptions/timers 实例字段,零全局槽)。
15
+ */
16
+ import type { WebSessionProjection } from './contract.js';
17
+ import { type FollowHandle } from './follow.js';
18
+ import { type ProjectionEngineDeps, type ProjectionSourceMessage } from './projection.js';
19
+ import type { SessionStoreAdapter } from './sessionStoreAdapter.js';
20
+ export type ReadonlySessionScopes = ReadonlyArray<{
21
+ scopeId: string;
22
+ storageDir: string;
23
+ }>;
24
+ export interface ReadonlySessionLimits {
25
+ maxTranscriptBytes?: number;
26
+ maxScanSessions?: number;
27
+ pageSize?: number;
28
+ maxRecordBytes?: number;
29
+ maxParseRecords?: number;
30
+ maxProjectionBytes?: number;
31
+ maxSubscriptions?: number;
32
+ maxConcurrentReads?: number;
33
+ maxPendingEvents?: number;
34
+ maxPendingBytes?: number;
35
+ pollingIntervalMs?: number;
36
+ requestDeadlineMs?: number;
37
+ idleLeaseMs?: number;
38
+ cursorTtlMs?: number;
39
+ closeDeadlineMs?: number;
40
+ ledgerCapacity?: number;
41
+ ledgerPayloadBytes?: number;
42
+ }
43
+ /**
44
+ * engine 注入缝(R-3:本域零 'src/engine' 直接导入——§4.5 pack 加载图
45
+ * 审计面)。CLI 真体经 src/atlascode/web/runtimeDefault.ts cast 焊接
46
+ * (引擎适配边界,不进 pack 图);测试注入 fake。
47
+ */
48
+ export interface ReadonlySessionEngine {
49
+ /** 呈批书 §7.3 钉死复用形:loadTranscriptFull(precompactSkip force-full)。S0-R3 加性 maxBytes(工单 §8-2;undefined = 不设界)。S0-R4 加性 expectIno(工单 §11-1 F1 授权身份锚;undefined = 不锚定)。 */
50
+ loadTranscriptFull: (filePath: string, opts?: {
51
+ maxBytes?: number;
52
+ expectIno?: number;
53
+ }) => Promise<{
54
+ messages: Map<string, ProjectionSourceMessage>;
55
+ leafUuids: Set<string>;
56
+ }>;
57
+ /** CLI 同规则链重建(projection 头注镜像义务)。 */
58
+ buildConversationChain: ProjectionEngineDeps['buildConversationChain'];
59
+ }
60
+ export interface ReadonlySessionRuntimeOptions {
61
+ /** 静态产品标识(ProductDefinition 单源,'atlascode')。 */
62
+ productId: string;
63
+ /** 授权 scopes(scopeId ↔ storageDir 显式映射;不可缺省)。 */
64
+ scopes: ReadonlySessionScopes;
65
+ /** engine 注入(loader + 链重建);CLI 真体见 runtimeDefault.ts。 */
66
+ engine: ReadonlySessionEngine;
67
+ /** 只读 storage adapter;缺省 = Node fs adapter(host 可注入 fake)。 */
68
+ adapter?: SessionStoreAdapter;
69
+ limits?: ReadonlySessionLimits;
70
+ }
71
+ export interface ListSessionsRequest {
72
+ scopeId: string;
73
+ }
74
+ export interface ListSessionsResult {
75
+ sessions: Array<{
76
+ sessionId: string;
77
+ title: string | null;
78
+ createdAt: string | null;
79
+ updatedAt: string;
80
+ messageCount: number | null;
81
+ productId: string;
82
+ scopeId: string;
83
+ }>;
84
+ }
85
+ export interface ReplaySessionRequest {
86
+ scopeId: string;
87
+ sessionId: string;
88
+ }
89
+ export interface ReplaySessionResult {
90
+ of: 'replaySession';
91
+ projection: WebSessionProjection;
92
+ }
93
+ export interface FollowSessionRequest {
94
+ scopeId: string;
95
+ sessionId: string;
96
+ requestId?: string;
97
+ /**
98
+ * S0-R5 ③(呈批书 §3 @6e772c02,f4 §13 批复):opaque resume cursor
99
+ * (账本 token)。在场 → 续接支(零 baseline 事件,断连窗 append 从
100
+ * 文件本身恢复);verify 三因(unknown/expired/mismatch)→ resetRequired
101
+ * 显式分态。协议形 webSessionV0 FollowSessionRequestSchema.resumeCursor
102
+ * optional(本域信任上层已验,运行面 opaque string)。
103
+ */
104
+ resumeCursor?: string;
105
+ }
106
+ /** S0-R4 件 A(工单 §3/呈批书 L1,f4 §10 @7ecf0fa4 批复):query 界(1-256 code points)= 契约面钉死(webSessionV0),runtime 信任上层已验。 */
107
+ export interface SearchSessionsRequest {
108
+ scopeId: string;
109
+ query: string;
110
+ pageSize?: number;
111
+ /** opaque offset cursor(会话列表序内偏移编码;不跨进程有效、mtime 漂移容忍=越界空页)。 */
112
+ pageToken?: string;
113
+ }
114
+ export interface SearchSessionsResult {
115
+ results: Array<{
116
+ sessionId: string;
117
+ messageId: string;
118
+ /** ≤512 Unicode code points(契约 SearchResultSchema);命中起点起切片。 */
119
+ snippet: string;
120
+ }>;
121
+ nextPageToken?: string;
122
+ }
123
+ export type FollowSubscription = FollowHandle;
124
+ /** §4.4 全表解析值(start 时经 validateBoundedInt 钉死,host 不可越硬上限)。 */
125
+ export interface ResolvedLimits {
126
+ maxTranscriptBytes: number;
127
+ maxScanSessions: number;
128
+ pageSize: number;
129
+ maxRecordBytes: number;
130
+ maxParseRecords: number;
131
+ maxProjectionBytes: number;
132
+ maxSubscriptions: number;
133
+ maxConcurrentReads: number;
134
+ maxPendingEvents: number;
135
+ maxPendingBytes: number;
136
+ pollingIntervalMs: number;
137
+ requestDeadlineMs: number;
138
+ idleLeaseMs: number;
139
+ cursorTtlMs: number;
140
+ closeDeadlineMs: number;
141
+ ledgerCapacity: number;
142
+ ledgerPayloadBytes: number;
143
+ }
144
+ export interface ReadonlySessionRuntime {
145
+ /** 实例纪元(重建新实例换 epoch;close 后旧 epoch 永不复用)。 */
146
+ readonly epoch: string;
147
+ readonly limits: ResolvedLimits;
148
+ start(): Promise<void>;
149
+ listSessions(req: ListSessionsRequest, signal?: AbortSignal): Promise<ListSessionsResult>;
150
+ replaySession(req: ReplaySessionRequest, signal?: AbortSignal): Promise<ReplaySessionResult>;
151
+ followSession(req: FollowSessionRequest, signal?: AbortSignal): Promise<FollowSubscription>;
152
+ /** S0-R4 件 A 第四面:会话级搜索(AbortSignal A 形,'cancelled' 零 partial payload)。 */
153
+ searchSessions(req: SearchSessionsRequest, signal?: AbortSignal): Promise<SearchSessionsResult>;
154
+ close(): Promise<void>;
155
+ }
156
+ export declare function createReadonlySessionRuntime(options: ReadonlySessionRuntimeOptions): ReadonlySessionRuntime;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * AtlasWeb S0-R2 默认 runtime 装配(形 A:engine 真体随 bundle)。
3
+ *
4
+ * S0-R2(lock-face @25cb7454 §1/§3-4,f4 批复工单 §7 @351c74c4):本文件
5
+ * **入 pack 加载图**(pack 格重形:engine/session 只读闭包允许)——import
6
+ * 自 `src/engine` 全门面窄化为只读子门面 `src/engine/session/readonly`
7
+ * (S0-R f4 批复 @f1f1099d 专用面;载体图 = readonly + load 族纯函数 +
8
+ * 域内依赖,query/loopDeps/pipeline/tools 全纵切出图)。本文件是
9
+ * 'src/engine' 与 web 只读域之间的唯一焊接点:注入 engine 真体
10
+ * (loadTranscriptFull force-full + load.ts buildConversationChain),并在
11
+ * 边界做结构类型 cast(engine TranscriptMessage → 投影源结构面)。相对
12
+ * import(非 'src/' alias):tsconfig.web-session-runtime 无 paths 映射 +
13
+ * d.ts 面只认相对 specifier(rewrite 脚本钉死形)。
14
+ */
15
+ import { type ReadonlySessionRuntime, type ReadonlySessionRuntimeOptions } from './readonlyRuntime.js';
16
+ /** 默认装配 options(engine 必填缝已由本模块填死)。 */
17
+ export type AtlasWebSessionRuntimeOptions = Omit<ReadonlySessionRuntimeOptions, 'engine'>;
18
+ /** 引擎真体(cast 焊接:engine 类型 → 投影源结构面,边界一次完成)。 */
19
+ export declare function atlasWebSessionEngine(): ReadonlySessionRuntimeOptions['engine'];
20
+ /**
21
+ * 默认装配 factory(形 A 出口名,工单 §2/§6-3):createReadonlySessionRuntime
22
+ * + engine 注入。注入缝(options.engine)保留不动(预答不变量,工单 §6-2)——
23
+ * 本 factory 仅把 engine 成员填死后委托注入缝。旧名 createAtlasWebSessionRuntime
24
+ * 改名(grep 实证零调用点,零别名)。
25
+ */
26
+ export declare function createDefaultReadonlySessionRuntime(options: AtlasWebSessionRuntimeOptions): ReadonlySessionRuntime;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * AtlasWeb S0-R 受授权真实读取 adapter(工单 §4.1/§4.2;呈批书 §7.4
3
+ * 同 fd 校验读取链,f4 批复 @f1f1099d 必改 2 扩项)。
4
+ *
5
+ * 安全读链(禁 path 两段式):授权根 containment(realpath 规范化)→
6
+ * lstat 末段拒 symlink/非 regular → O_NOFOLLOW open → fstat S_ISREG 白名单
7
+ * → ino 对比收 TOCTOU 窗 → size 对资源界 → 同一 fd 流式读(chunk ≤64KiB,
8
+ * 每 chunk 边界查 AbortSignal)→ 读毕 fstat 复核 ino/size。
9
+ * 非法 ID(含 `..`/路径形)→ invalidRequest;未知 scope → scopeDenied;
10
+ * 文件不存在 → notFound;权限/非 regular → ioUnavailable{retryable:false};
11
+ * 读取中身份变化 → ioUnavailable{retryable:true};超界 → resourceLimit。
12
+ * 零写面;不默认回落 HOME;scopeId ↔ storageDir 显式映射。
13
+ */
14
+ export type SessionStoreScopes = ReadonlyArray<{
15
+ scopeId: string;
16
+ storageDir: string;
17
+ }>;
18
+ export interface SessionFileEntry {
19
+ sessionId: string;
20
+ filePath: string;
21
+ sizeBytes: number;
22
+ updatedAt: string;
23
+ createdAt: string | null;
24
+ }
25
+ export interface TranscriptStat {
26
+ sizeBytes: number;
27
+ mtimeMs: number;
28
+ ino: number;
29
+ }
30
+ export interface TranscriptTail {
31
+ /** offset 起的新增字节(增量尾读,零重解析判据的读取面)。 */
32
+ bytes: Uint8Array;
33
+ sizeBytes: number;
34
+ ino: number;
35
+ }
36
+ /** 有界头读结果(G-D):bytes.length ≤ maxBytes;sizeBytes = 文件全尺寸。 */
37
+ export interface TranscriptHead {
38
+ bytes: Uint8Array;
39
+ sizeBytes: number;
40
+ ino: number;
41
+ }
42
+ export interface SessionStoreAdapter {
43
+ start(): Promise<void>;
44
+ listSessionFiles(scopeId: string): Promise<SessionFileEntry[]>;
45
+ readTranscript(scopeId: string, sessionId: string, signal?: AbortSignal): Promise<Uint8Array>;
46
+ /** O(1) 采样通道(mtime+size+ino 三元组守卫;未存在 → null)。 */
47
+ statTranscript(scopeId: string, sessionId: string): Promise<TranscriptStat | null>;
48
+ /** 增量尾读:offset 起步只取新增字节(§7.5 零重解析判据)。 */
49
+ readTranscriptTail(scopeId: string, sessionId: string, offset: number, signal?: AbortSignal): Promise<TranscriptTail>;
50
+ /**
51
+ * 有界头读(G-D,2026-11-20):[0, maxBytes) 窗读取(list 面 title
52
+ * 提取源)。可选缝——缺省 adapter 不实现时 runtime 诚实降级 title
53
+ * null;Node fs 默认载体实有。同一安全读链(openValidated + 读毕复核)。
54
+ */
55
+ readTranscriptHead?(scopeId: string, sessionId: string, maxBytes: number, signal?: AbortSignal): Promise<TranscriptHead>;
56
+ /**
57
+ * 显式路径解析(baseline loadFull 的 filePath 源;呈批书 §7.3 scopeId ↔
58
+ * storageDir 显式映射):经同一校验链后返回文件路径。
59
+ */
60
+ resolveTranscriptPath(scopeId: string, sessionId: string): Promise<string>;
61
+ close(): Promise<void>;
62
+ }
63
+ export interface NodeFsSessionStoreAdapterOptions {
64
+ productId: string;
65
+ scopes: SessionStoreScopes;
66
+ limits?: {
67
+ maxTranscriptBytes?: number;
68
+ };
69
+ }
70
+ export declare function createNodeFsSessionStoreAdapter(options: NodeFsSessionStoreAdapterOptions): SessionStoreAdapter;
@@ -0,0 +1,32 @@
1
+ export type SessionEnv = {
2
+ /** 当前 session id(旧 bootstrap getSessionId)。 */
3
+ getSessionId(): string;
4
+ /** 切换 session(/resume/--continue;单参——projectDir 原子对随 d1 裁)。 */
5
+ switchSession(id: string): void;
6
+ /** 进程启动 cwd(旧 bootstrap getOriginalCwd;不可变语义)。 */
7
+ getOriginalCwd(): string;
8
+ /** transcript 项目根目录(`<configHome>/projects`,bootstrap defaultTranscriptDir 先例)。 */
9
+ getProjectsDir(): string;
10
+ /** 进程退出清理钩子注册(旧 utils/cleanupRegistry;缺省 no-op 收集,壳侧接线执行面)。 */
11
+ registerCleanup(handler: () => Promise<void>): void;
12
+ /**
13
+ * 活态 cwd(S-E3 A12,§8.52):旧仓 getCwd() 活态语义(ALS 覆盖层 ??
14
+ * cwdState,Bash cd 持久化 / --resume workDir / agent worktree 刷新)。域缺省
15
+ * = process.cwd() 活读(无 bootstrap 约束下旧活态语义最近等价,自包含不破);
16
+ * 组合根经 bootstrap pwd()(ALS 覆盖 ?? getCwdState)注真值。消费点 =
17
+ * project.ts insertMessageChain cwd 戳(A-1 审视值 delta 可选扩已落)。
18
+ */
19
+ getCwd(): string;
20
+ };
21
+ /**
22
+ * 组合根注真 bootstrap 值(E-wave-end compose.ts 接线;测试覆写
23
+ * getProjectsDir → tmpdir 真盘面)。Partial 合并:未注成员沿用缺省。
24
+ */
25
+ export declare function setSessionEnv(partial: Partial<SessionEnv>): void;
26
+ export declare function getSessionEnv(): SessionEnv;
27
+ /**
28
+ * 测试复位(恢复域缺省,丢弃组合根/测试注入的 Partial 合并;单进程连跑跨文件
29
+ * 泄漏守卫——setSessionEnv 为 Partial 合并进程内不可逆,本导出 = teardown 出口;
30
+ * 合并走 spread 新对象,defaultEnv 本体不被写,复位安全)。
31
+ */
32
+ export declare function resetSessionEnv(): void;
@@ -0,0 +1,21 @@
1
+ import type { Message, TranscriptMessage } from './types.js';
2
+ /** 旧 constants/xml.ts 逐字。 */
3
+ export declare const COMMAND_NAME_TAG = "command-name";
4
+ type BuiltinCommandNamesSource = () => Set<string>;
5
+ /**
6
+ * 内建命令名集合注入窗(S-C4 注入口回填,§8.71.1.4):CLI 域
7
+ * cli/commands.ts registerBuiltinCommandNames() 注入 engine/skill 域
8
+ * builtInCommandNames 读面(调用一次即持久;缺省空 Set = 未注入态行为)。
9
+ */
10
+ export declare function setBuiltinCommandNamesSource(src: BuiltinCommandNamesSource): void;
11
+ /** 测试复位面(缺省空 Set 态)。 */
12
+ export declare function resetBuiltinCommandNamesSourceForTesting(): void;
13
+ declare function extractFirstPrompt(transcript: TranscriptMessage[]): string;
14
+ /**
15
+ * Gets the last user message that was processed (i.e., before any non-user
16
+ * message appears). Used to determine if a session has valid user
17
+ * interaction.(旧 L1757 逐字)
18
+ */
19
+ export declare function getFirstMeaningfulUserMessageTextContent<T extends Message>(transcript: T[]): string | undefined;
20
+ /** 旧 L1736 逐字(convertToLogOption 消费;load 读面经本文件导入)。 */
21
+ export { extractFirstPrompt };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * session 域 — JSONL 解析/序列化域内小工具(E-7 S-7d d1,§8.49 详案 item 6
3
+ * 「域内小工具 parseJSONL / jsonParse / jsonStringify」独立小文件承载)
4
+ *
5
+ * 旧仓来源:src/utils/json.ts parseJSONL 族(L94-215 逐字)+ src/utils/
6
+ * slowOperations.ts jsonParse/jsonStringify(语义逐字,**计时面裁**——旧
7
+ * slowLogging 包裹归 telemetry 已删的 879 点同族,纯 JSON.parse/stringify
8
+ * 语义保留)。
9
+ *
10
+ * 裁面登记(审视 B-1,E-7 d1 独立审视 NIT):旧 readJSONLFile(json.ts
11
+ * L201,100MB 尾读)未随迁——全仓唯一消费者 = stats.ts:177(CLI 会话
12
+ * 统计面,d1 域外),归 CLI stats 波。
13
+ */
14
+ /**
15
+ * Parses JSONL data from a string or Buffer, skipping malformed lines.
16
+ * Uses Bun.JSONL.parseChunk when available for better performance,
17
+ * falls back to indexOf-based scanning otherwise.
18
+ */
19
+ export declare function parseJSONL<T>(data: string | Buffer): T[];
20
+ /**
21
+ * 旧 slowOperations.jsonParse 语义逐字(计时包裹裁):V8 de-opts JSON.parse
22
+ * when a second argument is passed, even if undefined — branch explicitly so
23
+ * the common (no-reviver) path stays on the fast path.
24
+ */
25
+ export declare const jsonParse: typeof JSON.parse;
26
+ /** 旧 slowOperations.jsonStringify 语义逐字(计时包裹裁)。 */
27
+ export declare function jsonStringify(data: unknown, space?: number): string;