@atlaswork/atlascode 0.1.125 → 0.1.127

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 (75) hide show
  1. package/dist/atlasweb-carrier.json +6 -0
  2. package/dist/cli.js +530 -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/runtimeEntry.d.ts +16 -0
  6. package/dist/web-session-runtime/index.d.ts +1 -1
  7. package/dist/web-session-runtime/kernel/execution/executionOutlet.d.ts +60 -0
  8. package/dist/web-session-runtime/kernel/protocol/webExecutionV0.d.ts +542 -0
  9. package/dist/web-session-runtime/kernel/state/injection.d.ts +28 -0
  10. package/dist/web-session-runtime/kernel/state/ports.d.ts +67 -0
  11. package/dist/web-session-runtime-execution/atlascode/web/contract.d.ts +10 -0
  12. package/dist/web-session-runtime-execution/atlascode/web/cursorLedger.d.ts +63 -0
  13. package/dist/web-session-runtime-execution/atlascode/web/entry.d.ts +26 -0
  14. package/dist/web-session-runtime-execution/atlascode/web/errors.d.ts +16 -0
  15. package/dist/web-session-runtime-execution/atlascode/web/follow.d.ts +82 -0
  16. package/dist/web-session-runtime-execution/atlascode/web/limits.d.ts +63 -0
  17. package/dist/web-session-runtime-execution/atlascode/web/projection.d.ts +69 -0
  18. package/dist/web-session-runtime-execution/atlascode/web/readonlyRuntime.d.ts +156 -0
  19. package/dist/web-session-runtime-execution/atlascode/web/runtimeDefault.d.ts +26 -0
  20. package/dist/web-session-runtime-execution/atlascode/web/sessionStoreAdapter.d.ts +70 -0
  21. package/dist/web-session-runtime-execution/engine/session/env.d.ts +32 -0
  22. package/dist/web-session-runtime-execution/engine/session/firstPrompt.d.ts +21 -0
  23. package/dist/web-session-runtime-execution/engine/session/json.d.ts +27 -0
  24. package/dist/web-session-runtime-execution/engine/session/load.d.ts +88 -0
  25. package/dist/web-session-runtime-execution/engine/session/paths.d.ts +25 -0
  26. package/dist/web-session-runtime-execution/engine/session/predicates.d.ts +55 -0
  27. package/dist/web-session-runtime-execution/engine/session/readonly.d.ts +29 -0
  28. package/dist/web-session-runtime-execution/engine/session/scanner.d.ts +26 -0
  29. package/dist/web-session-runtime-execution/engine/session/search.d.ts +44 -0
  30. package/dist/web-session-runtime-execution/engine/session/types.d.ts +379 -0
  31. package/dist/web-session-runtime-execution/index.d.ts +1 -0
  32. package/dist/web-session-runtime-execution/index.js +8681 -0
  33. package/dist/web-session-runtime-execution/kernel/execution/executionComposition.d.ts +18 -0
  34. package/dist/web-session-runtime-execution/kernel/execution/executionKernel.d.ts +77 -0
  35. package/dist/web-session-runtime-execution/kernel/execution/executionOutlet.d.ts +60 -0
  36. package/dist/web-session-runtime-execution/kernel/protocol/webExecutionV0.d.ts +547 -0
  37. package/dist/web-session-runtime-execution/kernel/protocol/webSessionV0.d.ts +727 -0
  38. package/dist/web-session-runtime-execution/kernel/state/injection.d.ts +28 -0
  39. package/dist/web-session-runtime-execution/kernel/state/ports.d.ts +67 -0
  40. package/dist/web-session-runtime-execution/shared/ProductDefinition.d.ts +47 -0
  41. package/dist/web-session-runtime-execution/shared/agentRoleTemplates.d.ts +44 -0
  42. package/dist/web-session-runtime-execution/shared/agentSwarmsEnabled.d.ts +5 -0
  43. package/dist/web-session-runtime-execution/shared/boundedImageRead.d.ts +31 -0
  44. package/dist/web-session-runtime-execution/shared/circular-buffer.d.ts +42 -0
  45. package/dist/web-session-runtime-execution/shared/configDir.d.ts +57 -0
  46. package/dist/web-session-runtime-execution/shared/constants.d.ts +19 -0
  47. package/dist/web-session-runtime-execution/shared/debug.d.ts +32 -0
  48. package/dist/web-session-runtime-execution/shared/env.d.ts +38 -0
  49. package/dist/web-session-runtime-execution/shared/errors.d.ts +56 -0
  50. package/dist/web-session-runtime-execution/shared/feature.d.ts +25 -0
  51. package/dist/web-session-runtime-execution/shared/format.d.ts +11 -0
  52. package/dist/web-session-runtime-execution/shared/fs-operations.d.ts +116 -0
  53. package/dist/web-session-runtime-execution/shared/hash.d.ts +13 -0
  54. package/dist/web-session-runtime-execution/shared/identity.d.ts +23 -0
  55. package/dist/web-session-runtime-execution/shared/index.d.ts +46 -0
  56. package/dist/web-session-runtime-execution/shared/lazySchema.d.ts +12 -0
  57. package/dist/web-session-runtime-execution/shared/log.d.ts +1 -0
  58. package/dist/web-session-runtime-execution/shared/path.d.ts +22 -0
  59. package/dist/web-session-runtime-execution/shared/pdfPageImages.d.ts +19 -0
  60. package/dist/web-session-runtime-execution/shared/pdfReference.d.ts +70 -0
  61. package/dist/web-session-runtime-execution/shared/permissionDeadline.d.ts +24 -0
  62. package/dist/web-session-runtime-execution/shared/platform.d.ts +8 -0
  63. package/dist/web-session-runtime-execution/shared/stringUtils.d.ts +110 -0
  64. package/dist/web-session-runtime-execution/shared/swarmSchemaFilter.d.ts +23 -0
  65. package/dist/web-session-runtime-execution/shared/teamFileSchema.d.ts +151 -0
  66. package/dist/web-session-runtime-execution/shared/teamInboxSchema.d.ts +112 -0
  67. package/dist/web-session-runtime-execution/shared/teammateContext.d.ts +89 -0
  68. package/dist/web-session-runtime-execution/shared/tempDir.d.ts +1 -0
  69. package/dist/web-session-runtime-execution/shared/textEncoding.d.ts +41 -0
  70. package/dist/web-session-runtime-execution/shared/tokenEstimation.d.ts +36 -0
  71. package/dist/web-session-runtime-execution/shared/types-session.d.ts +266 -0
  72. package/dist/web-session-runtime-execution/shared/types.d.ts +190 -0
  73. package/dist/web-session-runtime-execution/shared/unc.d.ts +5 -0
  74. package/dist/web-session-runtime-execution/shared/windowsPaths.d.ts +24 -0
  75. package/package.json +10 -3
@@ -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,10 @@
1
+ /**
2
+ * AtlasWeb S0-R contract 类型闭包 shim(R-3)。
3
+ *
4
+ * 本域对 contract 公开类型的唯一类型入口:**相对路径**引用(而非
5
+ * 'src/...' 别名),使 tsc emitDeclarationOnly 产出的 d.ts 在 pack
6
+ * (dist/web-session-runtime)内相对可解析、零仓库内 specifier 泄漏
7
+ * (§4.5 加载图审计面:声明只依赖 contract 公开类型)。运行时零开销
8
+ * (纯 type re-export)。
9
+ */
10
+ export type { WebSessionEvent, WebSessionProjection, } from '../../kernel/protocol/webSessionV0.js';
@@ -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,26 @@
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 { createExecutionComposition, type ExecutionComposition, type ExecutionCompositionOptions, } from '../../kernel/execution/executionComposition.js';
25
+ export type { ExecutionTurnRunner, ExecutionTurnRunnerDeps, ExecutionTurnOutcome, ExecutionApprovalDecision, } from '../../kernel/execution/executionKernel.js';
26
+ 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;