@atlaswork/atlascode 0.1.130 → 0.1.132

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "product": "atlascode",
3
- "version": "0.1.130",
4
- "runtimeSha256": "5710d05618ccfc396ca914195625655e81b279041c587a9d7e190a7ff85be80c",
5
- "executionSha256": "0fd96bfadfdc26128b8852ef1b94a3018a099a223a5f256f5ef47a576e6ffe6b"
3
+ "version": "0.1.132",
4
+ "runtimeSha256": "9bbb766ae76e5a73f1155a83bd6eda493644fb228b9308e0f45938fb49f43451",
5
+ "executionSha256": "b14e2ea5946c9e086d65d2debe0de98b0afec83228d887958bcb16a6e867710d"
6
6
  }
@@ -31,7 +31,7 @@
31
31
  * 才释放,杜绝 close 竞态下槽位早释的限额绕过)。
32
32
  */
33
33
  import type { WebSessionEvent } from './contract.js';
34
- import type { CursorLedger } from './cursorLedger.js';
34
+ import type { CursorLedger, CursorBinding } from './cursorLedger.js';
35
35
  import type { SessionStoreAdapter } from './sessionStoreAdapter.js';
36
36
  import { type ProjectionEngineDeps, type ProjectionSourceMessage } from './projection.js';
37
37
  /** 投影消息源结构面(engine TranscriptMessage 的结构超集镜像,pack 域零引擎导入)。 */
@@ -62,6 +62,16 @@ export interface FollowDeps {
62
62
  limits: FollowLimits;
63
63
  signal?: AbortSignal;
64
64
  ledger: CursorLedger;
65
+ /**
66
+ * W-FC-1 修形 2(工单 docs/2026-11-28-wfc1-ledger-evict-ticket.md §3 格 2):
67
+ * 活跃 cursor 被账本压力淘汰的 sink 注册/注销面(runtime 持注册表,
68
+ * ledger onActiveEvict 分发后即删)。issue 成功后注册、setTerminal 兜底
69
+ * 注销。inline 类型——零新 export(红线:零新 wire 形/export)。
70
+ */
71
+ evictRouter: {
72
+ register: (token: string, sink: (token: string, binding: CursorBinding) => void) => void;
73
+ unregister: (token: string) => void;
74
+ };
65
75
  /** 引擎 loader 全量基线面(显式 filePath;呈批书 §7.3 钉死形,注入缝)。 */
66
76
  loadFull: (filePath: string) => Promise<{
67
77
  messages: Map<string, ProjectionSourceMessage>;
@@ -1160,6 +1160,9 @@ class CursorLedger {
1160
1160
  this.onActiveEvict = onActiveEvict;
1161
1161
  }
1162
1162
  issue(binding, payloadBytes = 0) {
1163
+ if (payloadBytes > this.maxPayloadBytes) {
1164
+ throw new WebSessionError("resourceLimit", `ledger payload exceeds cap (${payloadBytes} > ${this.maxPayloadBytes} bytes)`);
1165
+ }
1163
1166
  this.evictForInsert(payloadBytes);
1164
1167
  const token = randomUUID();
1165
1168
  this.entries.set(token, {
@@ -1495,10 +1498,20 @@ function createFollowSubscription(deps) {
1495
1498
  terminalRank = rank;
1496
1499
  running = false;
1497
1500
  disarmLease();
1498
- for (const t of issuedTokens)
1501
+ for (const t of issuedTokens) {
1499
1502
  ledger.unpin(t);
1503
+ deps.evictRouter.unregister(t);
1504
+ }
1500
1505
  notify();
1501
1506
  }
1507
+ function handleActiveEvict(token, binding) {
1508
+ queueData({
1509
+ ...envelope(deps),
1510
+ kind: "resetRequired",
1511
+ generation: binding.generation,
1512
+ reason: "active cursor evicted (ledger pressure)"
1513
+ });
1514
+ }
1502
1515
  function queueData(ev) {
1503
1516
  if (terminalEvent || finished)
1504
1517
  return;
@@ -1600,19 +1613,29 @@ function createFollowSubscription(deps) {
1600
1613
  setTerminal(errorEvent("resourceLimit", `projection exceeds limit (${bytes} bytes)`));
1601
1614
  return false;
1602
1615
  }
1603
- const cursor = ledger.issue({
1604
- v: 1,
1605
- productId: deps.productId,
1606
- scopeId: deps.scopeId,
1607
- sessionId: deps.sessionId,
1608
- baselineId,
1609
- generation,
1610
- revision,
1611
- byteOffset: offset,
1612
- ino: anchorIno
1613
- }, bytes);
1616
+ let cursor;
1617
+ try {
1618
+ cursor = ledger.issue({
1619
+ v: 1,
1620
+ productId: deps.productId,
1621
+ scopeId: deps.scopeId,
1622
+ sessionId: deps.sessionId,
1623
+ baselineId,
1624
+ generation,
1625
+ revision,
1626
+ byteOffset: offset,
1627
+ ino: anchorIno
1628
+ }, bytes);
1629
+ } catch (e) {
1630
+ if (e instanceof WebSessionError && e.code === "resourceLimit") {
1631
+ setTerminal(errorEvent("resourceLimit", e.message));
1632
+ return false;
1633
+ }
1634
+ throw e;
1635
+ }
1614
1636
  ledger.pin(cursor);
1615
1637
  issuedTokens.push(cursor);
1638
+ deps.evictRouter.register(cursor, handleActiveEvict);
1616
1639
  queueData({
1617
1640
  ...envelope(deps),
1618
1641
  kind: "baseline",
@@ -1715,19 +1738,29 @@ function createFollowSubscription(deps) {
1715
1738
  return;
1716
1739
  }
1717
1740
  revision++;
1718
- const cursor = ledger.issue({
1719
- v: 1,
1720
- productId: deps.productId,
1721
- scopeId: deps.scopeId,
1722
- sessionId: deps.sessionId,
1723
- baselineId,
1724
- generation,
1725
- revision,
1726
- byteOffset: offset,
1727
- ino: anchorIno
1728
- }, bytes);
1741
+ let cursor;
1742
+ try {
1743
+ cursor = ledger.issue({
1744
+ v: 1,
1745
+ productId: deps.productId,
1746
+ scopeId: deps.scopeId,
1747
+ sessionId: deps.sessionId,
1748
+ baselineId,
1749
+ generation,
1750
+ revision,
1751
+ byteOffset: offset,
1752
+ ino: anchorIno
1753
+ }, bytes);
1754
+ } catch (e) {
1755
+ if (e instanceof WebSessionError && e.code === "resourceLimit") {
1756
+ setTerminal(errorEvent("resourceLimit", e.message));
1757
+ return;
1758
+ }
1759
+ throw e;
1760
+ }
1729
1761
  ledger.pin(cursor);
1730
1762
  issuedTokens.push(cursor);
1763
+ deps.evictRouter.register(cursor, handleActiveEvict);
1731
1764
  queueData({
1732
1765
  ...envelope(deps),
1733
1766
  kind: "replacement",
@@ -2689,7 +2722,12 @@ function createReadonlySessionRuntime(options) {
2689
2722
  let state = "idle";
2690
2723
  const subscriptions = new Set;
2691
2724
  let activeReads = 0;
2692
- const cursorLedger = new CursorLedger(L.ledgerCapacity, L.cursorTtlMs, L.ledgerPayloadBytes);
2725
+ const evictSinks = new Map;
2726
+ const cursorLedger = new CursorLedger(L.ledgerCapacity, L.cursorTtlMs, L.ledgerPayloadBytes, (token, binding) => {
2727
+ const sink = evictSinks.get(token);
2728
+ evictSinks.delete(token);
2729
+ sink?.(token, binding);
2730
+ });
2693
2731
  function assertStarted(operation) {
2694
2732
  if (state === "idle") {
2695
2733
  throw new WebSessionError("closed", "not started");
@@ -2955,6 +2993,14 @@ function createReadonlySessionRuntime(options) {
2955
2993
  },
2956
2994
  signal,
2957
2995
  ledger: cursorLedger,
2996
+ evictRouter: {
2997
+ register: (token, sink) => {
2998
+ evictSinks.set(token, sink);
2999
+ },
3000
+ unregister: (token) => {
3001
+ evictSinks.delete(token);
3002
+ }
3003
+ },
2958
3004
  loadFull: options.engine.loadTranscriptFull,
2959
3005
  buildConversationChain: options.engine.buildConversationChain,
2960
3006
  resolvePath,
@@ -31,7 +31,7 @@
31
31
  * 才释放,杜绝 close 竞态下槽位早释的限额绕过)。
32
32
  */
33
33
  import type { WebSessionEvent } from './contract.js';
34
- import type { CursorLedger } from './cursorLedger.js';
34
+ import type { CursorLedger, CursorBinding } from './cursorLedger.js';
35
35
  import type { SessionStoreAdapter } from './sessionStoreAdapter.js';
36
36
  import { type ProjectionEngineDeps, type ProjectionSourceMessage } from './projection.js';
37
37
  /** 投影消息源结构面(engine TranscriptMessage 的结构超集镜像,pack 域零引擎导入)。 */
@@ -62,6 +62,16 @@ export interface FollowDeps {
62
62
  limits: FollowLimits;
63
63
  signal?: AbortSignal;
64
64
  ledger: CursorLedger;
65
+ /**
66
+ * W-FC-1 修形 2(工单 docs/2026-11-28-wfc1-ledger-evict-ticket.md §3 格 2):
67
+ * 活跃 cursor 被账本压力淘汰的 sink 注册/注销面(runtime 持注册表,
68
+ * ledger onActiveEvict 分发后即删)。issue 成功后注册、setTerminal 兜底
69
+ * 注销。inline 类型——零新 export(红线:零新 wire 形/export)。
70
+ */
71
+ evictRouter: {
72
+ register: (token: string, sink: (token: string, binding: CursorBinding) => void) => void;
73
+ unregister: (token: string) => void;
74
+ };
65
75
  /** 引擎 loader 全量基线面(显式 filePath;呈批书 §7.3 钉死形,注入缝)。 */
66
76
  loadFull: (filePath: string) => Promise<{
67
77
  messages: Map<string, ProjectionSourceMessage>;
@@ -1160,6 +1160,9 @@ class CursorLedger {
1160
1160
  this.onActiveEvict = onActiveEvict;
1161
1161
  }
1162
1162
  issue(binding, payloadBytes = 0) {
1163
+ if (payloadBytes > this.maxPayloadBytes) {
1164
+ throw new WebSessionError("resourceLimit", `ledger payload exceeds cap (${payloadBytes} > ${this.maxPayloadBytes} bytes)`);
1165
+ }
1163
1166
  this.evictForInsert(payloadBytes);
1164
1167
  const token = randomUUID();
1165
1168
  this.entries.set(token, {
@@ -1495,10 +1498,20 @@ function createFollowSubscription(deps) {
1495
1498
  terminalRank = rank;
1496
1499
  running = false;
1497
1500
  disarmLease();
1498
- for (const t of issuedTokens)
1501
+ for (const t of issuedTokens) {
1499
1502
  ledger.unpin(t);
1503
+ deps.evictRouter.unregister(t);
1504
+ }
1500
1505
  notify();
1501
1506
  }
1507
+ function handleActiveEvict(token, binding) {
1508
+ queueData({
1509
+ ...envelope(deps),
1510
+ kind: "resetRequired",
1511
+ generation: binding.generation,
1512
+ reason: "active cursor evicted (ledger pressure)"
1513
+ });
1514
+ }
1502
1515
  function queueData(ev) {
1503
1516
  if (terminalEvent || finished)
1504
1517
  return;
@@ -1600,19 +1613,29 @@ function createFollowSubscription(deps) {
1600
1613
  setTerminal(errorEvent("resourceLimit", `projection exceeds limit (${bytes} bytes)`));
1601
1614
  return false;
1602
1615
  }
1603
- const cursor = ledger.issue({
1604
- v: 1,
1605
- productId: deps.productId,
1606
- scopeId: deps.scopeId,
1607
- sessionId: deps.sessionId,
1608
- baselineId,
1609
- generation,
1610
- revision,
1611
- byteOffset: offset,
1612
- ino: anchorIno
1613
- }, bytes);
1616
+ let cursor;
1617
+ try {
1618
+ cursor = ledger.issue({
1619
+ v: 1,
1620
+ productId: deps.productId,
1621
+ scopeId: deps.scopeId,
1622
+ sessionId: deps.sessionId,
1623
+ baselineId,
1624
+ generation,
1625
+ revision,
1626
+ byteOffset: offset,
1627
+ ino: anchorIno
1628
+ }, bytes);
1629
+ } catch (e) {
1630
+ if (e instanceof WebSessionError && e.code === "resourceLimit") {
1631
+ setTerminal(errorEvent("resourceLimit", e.message));
1632
+ return false;
1633
+ }
1634
+ throw e;
1635
+ }
1614
1636
  ledger.pin(cursor);
1615
1637
  issuedTokens.push(cursor);
1638
+ deps.evictRouter.register(cursor, handleActiveEvict);
1616
1639
  queueData({
1617
1640
  ...envelope(deps),
1618
1641
  kind: "baseline",
@@ -1715,19 +1738,29 @@ function createFollowSubscription(deps) {
1715
1738
  return;
1716
1739
  }
1717
1740
  revision++;
1718
- const cursor = ledger.issue({
1719
- v: 1,
1720
- productId: deps.productId,
1721
- scopeId: deps.scopeId,
1722
- sessionId: deps.sessionId,
1723
- baselineId,
1724
- generation,
1725
- revision,
1726
- byteOffset: offset,
1727
- ino: anchorIno
1728
- }, bytes);
1741
+ let cursor;
1742
+ try {
1743
+ cursor = ledger.issue({
1744
+ v: 1,
1745
+ productId: deps.productId,
1746
+ scopeId: deps.scopeId,
1747
+ sessionId: deps.sessionId,
1748
+ baselineId,
1749
+ generation,
1750
+ revision,
1751
+ byteOffset: offset,
1752
+ ino: anchorIno
1753
+ }, bytes);
1754
+ } catch (e) {
1755
+ if (e instanceof WebSessionError && e.code === "resourceLimit") {
1756
+ setTerminal(errorEvent("resourceLimit", e.message));
1757
+ return;
1758
+ }
1759
+ throw e;
1760
+ }
1729
1761
  ledger.pin(cursor);
1730
1762
  issuedTokens.push(cursor);
1763
+ deps.evictRouter.register(cursor, handleActiveEvict);
1731
1764
  queueData({
1732
1765
  ...envelope(deps),
1733
1766
  kind: "replacement",
@@ -2689,7 +2722,12 @@ function createReadonlySessionRuntime(options) {
2689
2722
  let state = "idle";
2690
2723
  const subscriptions = new Set;
2691
2724
  let activeReads = 0;
2692
- const cursorLedger = new CursorLedger(L.ledgerCapacity, L.cursorTtlMs, L.ledgerPayloadBytes);
2725
+ const evictSinks = new Map;
2726
+ const cursorLedger = new CursorLedger(L.ledgerCapacity, L.cursorTtlMs, L.ledgerPayloadBytes, (token, binding) => {
2727
+ const sink = evictSinks.get(token);
2728
+ evictSinks.delete(token);
2729
+ sink?.(token, binding);
2730
+ });
2693
2731
  function assertStarted(operation) {
2694
2732
  if (state === "idle") {
2695
2733
  throw new WebSessionError("closed", "not started");
@@ -2955,6 +2993,14 @@ function createReadonlySessionRuntime(options) {
2955
2993
  },
2956
2994
  signal,
2957
2995
  ledger: cursorLedger,
2996
+ evictRouter: {
2997
+ register: (token, sink) => {
2998
+ evictSinks.set(token, sink);
2999
+ },
3000
+ unregister: (token) => {
3001
+ evictSinks.delete(token);
3002
+ }
3003
+ },
2958
3004
  loadFull: options.engine.loadTranscriptFull,
2959
3005
  buildConversationChain: options.engine.buildConversationChain,
2960
3006
  resolvePath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaswork/atlascode",
3
- "version": "0.1.130",
3
+ "version": "0.1.132",
4
4
  "description": "AtlasCode — Coding Agent for the domestic computing ecosystem (Ascend NPU + domestic LLM backends)",
5
5
  "homepage": "https://www.atlaswork.cn/",
6
6
  "bin": {
@@ -47,7 +47,8 @@
47
47
  "build:web-session-runtime": "bun build src/atlascode/web/runtimeEntry.ts --outfile dist/web-session-runtime/index.js --target node --external zod && tsc -p tsconfig.web-session-runtime.json && printf 'export * from \"./atlascode/web/runtimeEntry.js\"\\n' > dist/web-session-runtime/index.d.ts && bun scripts/rewrite-web-session-runtime-dts.ts",
48
48
  "build:web-session-runtime-execution": "bun build src/atlascode/web/entry.ts --outfile dist/web-session-runtime-execution/index.js --target node && tsc -p tsconfig.web-session-runtime-execution.json && printf 'export * from \"./atlascode/web/entry.js\"\\n' > dist/web-session-runtime-execution/index.d.ts && bun scripts/rewrite-web-session-runtime-dts.ts dist/web-session-runtime-execution",
49
49
  "build:atlasweb-carrier": "bun scripts/emit-atlasweb-carrier.ts",
50
- "prepublishOnly": "bun run build && bun run build:web-contract && bun run build:web-session-runtime && bun run build:web-session-runtime-execution && bun run build:atlasweb-carrier"
50
+ "prepublishOnly": "bun run build && bun run build:web-contract && bun run build:web-session-runtime && bun run build:web-session-runtime-execution && bun run build:atlasweb-carrier",
51
+ "prepack": "bun run build:atlasweb-carrier"
51
52
  },
52
53
  "dependencies": {
53
54
  "@alcalzone/ansi-tokenize": "^0.3.0",