@atlaswork/atlascode 0.1.126 → 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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "product": "atlascode",
3
- "version": "0.1.126",
3
+ "version": "0.1.127",
4
4
  "runtimeSha256": "7e7e6f389f7a429be6b06d40237b8e06f311bb8175c30ffd8787a09ac72257d2",
5
- "executionSha256": "79f9c7d42cb7b671a93abd0cf1e639657dcd25ab4dec63ccbb2ac6d634ba891d"
5
+ "executionSha256": "95dac0da045eb6dcd9290814a78141f5f09f9d18713d3f589f1f26e3315cda53"
6
6
  }
package/dist/cli.js CHANGED
@@ -95966,6 +95966,7 @@ function createExecutionKernel(options) {
95966
95966
  const approvalTimeoutMs = options.approvalTimeoutMs ?? EXECUTION_APPROVAL_TIMEOUT_MS;
95967
95967
  const maxTextBytes = options.maxTextBytes ?? EXECUTION_MAX_TEXT_BYTES;
95968
95968
  const followBufferLimit = options.followBufferLimit ?? EXECUTION_FOLLOW_BUFFER_LIMIT;
95969
+ const maxDeltaBytes = EXECUTION_MAX_DELTA_BYTES;
95969
95970
  const streams = new Map;
95970
95971
  const approvals = new Map;
95971
95972
  const subscribers = new Set;
@@ -96062,6 +96063,7 @@ function createExecutionKernel(options) {
96062
96063
  return;
96063
96064
  const turn = st.queue.shift();
96064
96065
  turn.state = "running";
96066
+ turnStates.set(turn.turnId, "running");
96065
96067
  turn.controller = new AbortController;
96066
96068
  st.running = turn;
96067
96069
  emit(st, { workspaceId: ws, sessionId: s, turnId: turn.turnId }, "turn.started", {});
@@ -96072,6 +96074,15 @@ function createExecutionKernel(options) {
96072
96074
  bind: { workspaceId: ws, sessionId: s, turnId: turn.turnId },
96073
96075
  text: turn.text,
96074
96076
  signal: turn.controller.signal,
96077
+ emitDelta: (text) => {
96078
+ if (turn.state !== "running" || turn.controller?.signal.aborted)
96079
+ return;
96080
+ if (Buffer.byteLength(text, "utf8") > maxDeltaBytes) {
96081
+ settleTurn(st, turn, "failed", `turn.delta 超 ${maxDeltaBytes} 字节上限(合同 §8)`);
96082
+ return;
96083
+ }
96084
+ emit(st, { workspaceId: ws, sessionId: s, turnId: turn.turnId }, "turn.delta", { text });
96085
+ },
96075
96086
  requestApproval: () => {
96076
96087
  const approvalId = `appr-${++approvalCounter}`;
96077
96088
  return new Promise((resolve) => {
@@ -96109,6 +96120,9 @@ function createExecutionKernel(options) {
96109
96120
  const handleCommand = async (command) => {
96110
96121
  const ws = command.bind.workspaceId;
96111
96122
  const s = command.bind.sessionId;
96123
+ if (ws.includes("\x00") || s.includes("\x00")) {
96124
+ return err("invalidBind", "workspaceId/sessionId 不得含 NUL 分隔符(流键碰撞面)");
96125
+ }
96112
96126
  if (command.type === "turn.submit") {
96113
96127
  const st = streamOfTracked(ws, s);
96114
96128
  const recorded = st.idempotency.get(command.payload.submitId);
@@ -96168,8 +96182,8 @@ function createExecutionKernel(options) {
96168
96182
  const a = approvals.get(command.payload.approvalId);
96169
96183
  if (!a)
96170
96184
  return err("notFound", `待批操作不存在或已结算:${command.payload.approvalId}`);
96171
- if (command.bind.turnId !== a.turnId) {
96172
- return err("approvalBindMismatch", `decide bind.turnId 与审批归属 turn 不一致(合同 §5)`);
96185
+ if (command.bind.turnId !== a.turnId || command.bind.workspaceId !== a.workspaceId || command.bind.sessionId !== a.sessionId) {
96186
+ return err("approvalBindMismatch", `decide bind 三元组与审批归属不一致(合同 §5)`);
96173
96187
  }
96174
96188
  if (a.settled || now() - a.requestedAt >= approvalTimeoutMs) {
96175
96189
  if (!a.settled)
@@ -96205,18 +96219,20 @@ function createExecutionKernel(options) {
96205
96219
  }
96206
96220
  };
96207
96221
  }
96208
- var EXECUTION_QUEUE_DEPTH = 16, EXECUTION_APPROVAL_TIMEOUT_MS = 300000, EXECUTION_MAX_TEXT_BYTES, EXECUTION_FOLLOW_BUFFER_LIMIT = 1e4, streamKey = (ws, s) => `${ws}\x00${s}`;
96222
+ var EXECUTION_QUEUE_DEPTH = 16, EXECUTION_APPROVAL_TIMEOUT_MS = 300000, EXECUTION_MAX_TEXT_BYTES, EXECUTION_FOLLOW_BUFFER_LIMIT = 1e4, EXECUTION_MAX_DELTA_BYTES, streamKey = (ws, s) => `${ws}\x00${s}`;
96209
96223
  var init_executionKernel = __esm(() => {
96210
96224
  EXECUTION_MAX_TEXT_BYTES = 2 * 1024 * 1024;
96225
+ EXECUTION_MAX_DELTA_BYTES = 256 * 1024;
96211
96226
  });
96212
96227
 
96213
96228
  // src/kernel/execution/executionComposition.ts
96214
- function createExecutionComposition() {
96229
+ function createExecutionComposition(options = {}) {
96215
96230
  const kernel = createExecutionKernel({
96216
- runTurn: async () => {
96231
+ runTurn: options.runTurn ?? (async () => {
96217
96232
  throw new Error("执行能力 runTurn 真体未接线(B0 执行出口波 S4 落地细化附注:引擎深缝候后续切片;能力开关 fail-closed off 时不可达)");
96218
- },
96219
- actorId: () => "atlas-local-ambient"
96233
+ }),
96234
+ actorId: options.actorId ?? (() => "atlas-local-ambient"),
96235
+ ...options.now !== undefined ? { now: options.now } : {}
96220
96236
  });
96221
96237
  const outlet = createExecutionOutlet({
96222
96238
  isExecutionEnabled: () => process.env.ATLAS_WEB_EXECUTION_ENABLED === "1",
@@ -21,4 +21,6 @@ export type { SessionStoreAdapter, SessionStoreScopes, SessionFileEntry, Transcr
21
21
  export type { NeutralProjection, NeutralProjectionMessage, NeutralBlock, ProjectionSourceMessage, ProjectionEngineDeps, ProjectionLoad, } from './projection.js';
22
22
  export { WebSessionError, type WebSessionErrorCode } from './errors.js';
23
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';
24
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';
@@ -8381,6 +8381,290 @@ function createExecutionOutlet(options) {
8381
8381
  }
8382
8382
  };
8383
8383
  }
8384
+ // src/kernel/execution/executionKernel.ts
8385
+ var EXECUTION_QUEUE_DEPTH = 16;
8386
+ var EXECUTION_APPROVAL_TIMEOUT_MS = 300000;
8387
+ var EXECUTION_MAX_TEXT_BYTES = 2 * 1024 * 1024;
8388
+ var EXECUTION_FOLLOW_BUFFER_LIMIT = 1e4;
8389
+ var EXECUTION_MAX_DELTA_BYTES = 256 * 1024;
8390
+ var streamKey = (ws, s) => `${ws}\x00${s}`;
8391
+ function createExecutionKernel(options) {
8392
+ const now = options.now ?? (() => Date.now());
8393
+ const actorId = options.actorId ?? (() => "kernel");
8394
+ const queueDepth = options.queueDepth ?? EXECUTION_QUEUE_DEPTH;
8395
+ const approvalTimeoutMs = options.approvalTimeoutMs ?? EXECUTION_APPROVAL_TIMEOUT_MS;
8396
+ const maxTextBytes = options.maxTextBytes ?? EXECUTION_MAX_TEXT_BYTES;
8397
+ const followBufferLimit = options.followBufferLimit ?? EXECUTION_FOLLOW_BUFFER_LIMIT;
8398
+ const maxDeltaBytes = EXECUTION_MAX_DELTA_BYTES;
8399
+ const streams = new Map;
8400
+ const approvals = new Map;
8401
+ const subscribers = new Set;
8402
+ const turnStates = new Map;
8403
+ let turnCounter = 0;
8404
+ let approvalCounter = 0;
8405
+ const streamOf = (ws, s) => {
8406
+ const key = streamKey(ws, s);
8407
+ let st = streams.get(key);
8408
+ if (!st) {
8409
+ st = {
8410
+ cursor: 0,
8411
+ buffer: [],
8412
+ overflowed: false,
8413
+ queue: [],
8414
+ running: undefined,
8415
+ turns: new Map,
8416
+ idempotency: new Map
8417
+ };
8418
+ streams.set(key, st);
8419
+ }
8420
+ return st;
8421
+ };
8422
+ const err = (code, message, retryable = false) => ({
8423
+ code,
8424
+ message,
8425
+ retryable
8426
+ });
8427
+ const emit = (st, bind, type, payload) => {
8428
+ st.cursor += 1;
8429
+ if (st.buffer.length >= followBufferLimit) {
8430
+ st.overflowed = true;
8431
+ st.buffer.shift();
8432
+ }
8433
+ const event = {
8434
+ v: 0,
8435
+ id: crypto.randomUUID(),
8436
+ ts: now(),
8437
+ type,
8438
+ bind,
8439
+ cursor: String(st.cursor).padStart(16, "0"),
8440
+ payload
8441
+ };
8442
+ st.buffer.push(event);
8443
+ for (const cb of subscribers)
8444
+ cb(event);
8445
+ return event;
8446
+ };
8447
+ const settleApproval = (a, decision) => {
8448
+ if (a.settled)
8449
+ return;
8450
+ a.settled = true;
8451
+ if (a.timer)
8452
+ clearTimeout(a.timer);
8453
+ approvals.delete(a.approvalId);
8454
+ const st = streamOf(a.workspaceId, a.sessionId);
8455
+ const event = emit(st, { workspaceId: a.workspaceId, sessionId: a.sessionId, turnId: a.turnId }, "approval.settled", { approvalId: a.approvalId, decision, actorId: actorId(), timestamp: now() });
8456
+ a.resolve(decision);
8457
+ return event;
8458
+ };
8459
+ const settleTurn = (st, turn, terminal, failedMessage) => {
8460
+ if (turn.state === "completed" || turn.state === "failed" || turn.state === "cancelled") {
8461
+ return;
8462
+ }
8463
+ turn.state = terminal;
8464
+ turnStates.set(turn.turnId, terminal);
8465
+ if (terminal === "cancelled") {
8466
+ for (const a of [...approvals.values()]) {
8467
+ if (a.turnId === turn.turnId && !a.settled)
8468
+ settleApproval(a, "voidedByCancel");
8469
+ }
8470
+ }
8471
+ st.running = st.running?.turnId === turn.turnId ? undefined : st.running;
8472
+ const event = emit(st, { workspaceId: streamWs(st), sessionId: streamSess(st), turnId: turn.turnId }, `turn.${terminal}`, terminal === "failed" ? { message: failedMessage ?? "turn failed" } : {});
8473
+ pump(streamWs(st), streamSess(st));
8474
+ return event;
8475
+ };
8476
+ const wsByStream = new Map;
8477
+ const sessByStream = new Map;
8478
+ const streamWs = (st) => wsByStream.get(st) ?? "";
8479
+ const streamSess = (st) => sessByStream.get(st) ?? "";
8480
+ const origStreamOf = streamOf;
8481
+ const streamOfTracked = (ws, s) => {
8482
+ const st = origStreamOf(ws, s);
8483
+ if (!wsByStream.has(st)) {
8484
+ wsByStream.set(st, ws);
8485
+ sessByStream.set(st, s);
8486
+ }
8487
+ return st;
8488
+ };
8489
+ const pump = (ws, s) => {
8490
+ const st = streamOfTracked(ws, s);
8491
+ if (st.running || st.queue.length === 0)
8492
+ return;
8493
+ const turn = st.queue.shift();
8494
+ turn.state = "running";
8495
+ turnStates.set(turn.turnId, "running");
8496
+ turn.controller = new AbortController;
8497
+ st.running = turn;
8498
+ emit(st, { workspaceId: ws, sessionId: s, turnId: turn.turnId }, "turn.started", {});
8499
+ (async () => {
8500
+ let outcome;
8501
+ try {
8502
+ outcome = await options.runTurn({
8503
+ bind: { workspaceId: ws, sessionId: s, turnId: turn.turnId },
8504
+ text: turn.text,
8505
+ signal: turn.controller.signal,
8506
+ emitDelta: (text) => {
8507
+ if (turn.state !== "running" || turn.controller?.signal.aborted)
8508
+ return;
8509
+ if (Buffer.byteLength(text, "utf8") > maxDeltaBytes) {
8510
+ settleTurn(st, turn, "failed", `turn.delta 超 ${maxDeltaBytes} 字节上限(合同 §8)`);
8511
+ return;
8512
+ }
8513
+ emit(st, { workspaceId: ws, sessionId: s, turnId: turn.turnId }, "turn.delta", { text });
8514
+ },
8515
+ requestApproval: () => {
8516
+ const approvalId = `appr-${++approvalCounter}`;
8517
+ return new Promise((resolve) => {
8518
+ const approval = {
8519
+ approvalId,
8520
+ turnId: turn.turnId,
8521
+ workspaceId: ws,
8522
+ sessionId: s,
8523
+ requestedAt: now(),
8524
+ settled: false,
8525
+ timer: undefined,
8526
+ resolve
8527
+ };
8528
+ approvals.set(approvalId, approval);
8529
+ emit(st, { workspaceId: ws, sessionId: s, turnId: turn.turnId }, "approval.requested", { approvalId });
8530
+ approval.timer = setTimeout(() => {
8531
+ settleApproval(approval, "expired");
8532
+ }, approvalTimeoutMs);
8533
+ approval.timer.unref?.();
8534
+ });
8535
+ }
8536
+ });
8537
+ } catch (e) {
8538
+ outcome = "failed";
8539
+ settleTurn(st, turn, "failed", e instanceof Error ? e.message : String(e));
8540
+ return;
8541
+ }
8542
+ if (outcome === "failed") {
8543
+ settleTurn(st, turn, "failed");
8544
+ } else {
8545
+ settleTurn(st, turn, outcome);
8546
+ }
8547
+ })();
8548
+ };
8549
+ const handleCommand = async (command) => {
8550
+ const ws = command.bind.workspaceId;
8551
+ const s = command.bind.sessionId;
8552
+ if (ws.includes("\x00") || s.includes("\x00")) {
8553
+ return err("invalidBind", "workspaceId/sessionId 不得含 NUL 分隔符(流键碰撞面)");
8554
+ }
8555
+ if (command.type === "turn.submit") {
8556
+ const st = streamOfTracked(ws, s);
8557
+ const recorded = st.idempotency.get(command.payload.submitId);
8558
+ if (recorded)
8559
+ return recorded;
8560
+ if (Buffer.byteLength(command.payload.text, "utf8") > maxTextBytes) {
8561
+ const rejection = err("resourceLimit", `turn.submit 超过 ${maxTextBytes} 字节上限(合同 §8)`);
8562
+ st.idempotency.set(command.payload.submitId, rejection);
8563
+ return rejection;
8564
+ }
8565
+ if (st.queue.length + (st.running ? 1 : 0) >= queueDepth) {
8566
+ const rejection = err("queueFull", `会话队列已满(深度 ${queueDepth},合同 §8)`, true);
8567
+ st.idempotency.set(command.payload.submitId, rejection);
8568
+ return rejection;
8569
+ }
8570
+ const turn = {
8571
+ turnId: `turn-${++turnCounter}`,
8572
+ submitId: command.payload.submitId,
8573
+ text: command.payload.text,
8574
+ state: "queued"
8575
+ };
8576
+ st.turns.set(turn.turnId, turn);
8577
+ turnStates.set(turn.turnId, "queued");
8578
+ st.queue.push(turn);
8579
+ const accepted = emit(st, { workspaceId: ws, sessionId: s, turnId: turn.turnId }, "turn.accepted", { submitId: command.payload.submitId });
8580
+ st.idempotency.set(command.payload.submitId, accepted);
8581
+ pump(ws, s);
8582
+ return accepted;
8583
+ }
8584
+ if (command.type === "turn.cancel" || command.type === "queue.remove") {
8585
+ const st = streamOfTracked(ws, s);
8586
+ const turn = st.turns.get(command.payload.targetTurnId);
8587
+ if (!turn)
8588
+ return err("notFound", `目标回合不存在:${command.payload.targetTurnId}`);
8589
+ if (turn.state === "queued") {
8590
+ st.queue = st.queue.filter((t) => t.turnId !== turn.turnId);
8591
+ turn.state = "cancelled";
8592
+ turnStates.set(turn.turnId, "cancelled");
8593
+ return emit(st, { workspaceId: ws, sessionId: s, turnId: turn.turnId }, "turn.cancelled", {});
8594
+ }
8595
+ if (turn.state === "running") {
8596
+ turn.controller?.abort();
8597
+ turn.state = "cancelled";
8598
+ turnStates.set(turn.turnId, "cancelled");
8599
+ const event = emit(st, { workspaceId: ws, sessionId: s, turnId: turn.turnId }, "turn.cancelled", {});
8600
+ for (const a of [...approvals.values()]) {
8601
+ if (a.turnId === turn.turnId && !a.settled)
8602
+ settleApproval(a, "voidedByCancel");
8603
+ }
8604
+ st.running = st.running?.turnId === turn.turnId ? undefined : st.running;
8605
+ pump(ws, s);
8606
+ return event;
8607
+ }
8608
+ return err("alreadySettled", `回合已终态(${turn.state}),边界错误不改状态(合同 §4)`);
8609
+ }
8610
+ if (command.type === "approval.decide") {
8611
+ const a = approvals.get(command.payload.approvalId);
8612
+ if (!a)
8613
+ return err("notFound", `待批操作不存在或已结算:${command.payload.approvalId}`);
8614
+ if (command.bind.turnId !== a.turnId || command.bind.workspaceId !== a.workspaceId || command.bind.sessionId !== a.sessionId) {
8615
+ return err("approvalBindMismatch", `decide bind 三元组与审批归属不一致(合同 §5)`);
8616
+ }
8617
+ if (a.settled || now() - a.requestedAt >= approvalTimeoutMs) {
8618
+ if (!a.settled)
8619
+ settleApproval(a, "expired");
8620
+ return err("alreadySettled", "待批操作已结算(过期/已决),边界错误(合同 §5)");
8621
+ }
8622
+ return settleApproval(a, command.payload.decision);
8623
+ }
8624
+ return err("notImplemented", "follow.resume 于 S4 切片落地(合同 §6)");
8625
+ };
8626
+ return {
8627
+ handleCommand,
8628
+ replaySince: (workspaceId, sessionId, cursor) => {
8629
+ const st = streams.get(streamKey(workspaceId, sessionId));
8630
+ const headCursor = String(st?.cursor ?? 0).padStart(16, "0");
8631
+ if (!st || !cursor)
8632
+ return { kind: "baseline", events: [], headCursor };
8633
+ if (st.overflowed)
8634
+ return { kind: "expired", events: [], headCursor };
8635
+ const idx = st.buffer.findIndex((e) => e.cursor === cursor);
8636
+ if (idx < 0)
8637
+ return { kind: "expired", events: [], headCursor };
8638
+ return { kind: "delta", events: st.buffer.slice(idx + 1), headCursor };
8639
+ },
8640
+ onEvent: (cb) => {
8641
+ subscribers.add(cb);
8642
+ return () => subscribers.delete(cb);
8643
+ },
8644
+ turnStates,
8645
+ bufferState: (workspaceId, sessionId) => {
8646
+ const st = streams.get(streamKey(workspaceId, sessionId));
8647
+ return st ? { overflowed: st.overflowed, kept: st.buffer.length } : { overflowed: false, kept: 0 };
8648
+ }
8649
+ };
8650
+ }
8651
+
8652
+ // src/kernel/execution/executionComposition.ts
8653
+ function createExecutionComposition(options = {}) {
8654
+ const kernel = createExecutionKernel({
8655
+ runTurn: options.runTurn ?? (async () => {
8656
+ throw new Error("执行能力 runTurn 真体未接线(B0 执行出口波 S4 落地细化附注:引擎深缝候后续切片;能力开关 fail-closed off 时不可达)");
8657
+ }),
8658
+ actorId: options.actorId ?? (() => "atlas-local-ambient"),
8659
+ ...options.now !== undefined ? { now: options.now } : {}
8660
+ });
8661
+ const outlet = createExecutionOutlet({
8662
+ isExecutionEnabled: () => process.env.ATLAS_WEB_EXECUTION_ENABLED === "1",
8663
+ dispatchCommand: (command) => kernel.handleCommand(command),
8664
+ resumeExecution: (bind, cursor) => kernel.replaySince(bind.workspaceId, bind.sessionId, cursor)
8665
+ });
8666
+ return { kernel, outlet };
8667
+ }
8384
8668
  export {
8385
8669
  EXECUTION_CAPABILITY_DISABLED_CODE,
8386
8670
  EXECUTION_PROTOCOL_VERSION,
@@ -8391,6 +8675,7 @@ export {
8391
8675
  WebExecutionEventSchema,
8392
8676
  WebSessionError,
8393
8677
  createDefaultReadonlySessionRuntime,
8678
+ createExecutionComposition,
8394
8679
  createExecutionOutlet,
8395
8680
  createReadonlySessionRuntime
8396
8681
  };
@@ -0,0 +1,18 @@
1
+ import { type ExecutionTurnRunner } from './executionKernel.js';
2
+ /**
3
+ * B1 前置件形 2(f4 附条件采认 @2026-11-21):注入形转正。
4
+ * - 零参默认行为零变更(CLI 双车道回归腿):runTurn 占位 fail-closed 抛错
5
+ * + actorId ambient——CLI 车道自身不服务 web 执行,占位语义保留。
6
+ * - host 侧(AtlasWeb upstream.ts,单接触点)经注入面传 runTurn 真体 +
7
+ * actorId 真源(已认证连接身份)。
8
+ */
9
+ export type ExecutionCompositionOptions = {
10
+ runTurn?: ExecutionTurnRunner;
11
+ actorId?: () => string;
12
+ now?: () => number;
13
+ };
14
+ export declare function createExecutionComposition(options?: ExecutionCompositionOptions): {
15
+ kernel: import("./executionKernel.js").ExecutionKernel;
16
+ outlet: import("./executionOutlet.js").ExecutionOutlet;
17
+ };
18
+ export type ExecutionComposition = ReturnType<typeof createExecutionComposition>;
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Kernel 执行域 —— B0 执行出口波 S3(呈批书 §2 S3 + f4 批复 @a62925c0)。
3
+ * 合同 docs/superpowers/specs/2026-11-20-first-wave-execution-contract.md
4
+ * §3(提交幂等)/§4(状态机与真取消)/§5(审批决策证据)/§2(bind/cursor)/
5
+ * §8(上限:队列 16 / 300s / 2 MiB / 10 000 / 并发 1)。
6
+ *
7
+ * 职责边界:
8
+ * - 上游执法唯一点:幂等键 (workspaceId, sessionId, submitId) 结算重放、
9
+ * 有界 FIFO 队列、并发 1、真取消(queued 不启动 / running 引擎真中止)、
10
+ * 待批 300s 超时 → expired、decide 归属绑定(bind.turnId ≡ 审批归属 turn)、
11
+ * follow 事件缓冲溢出 → 错误边界标记(S4 游标重同步消费)。
12
+ * - 事件流:cursor 每 (workspaceId, sessionId) 流单调递增(唯一排序权威);
13
+ * 事件恒携权威 bind 三元组(E2:结算只认三元组精确匹配的对偶面)。
14
+ * - 引擎缝:options.runTurn 注入(组合根 S4 接线);kernel 不 import 引擎面
15
+ * (加载图惰性同 executionOutlet 纪律)。
16
+ * - follow.resume 命令面 = S4(本切片返回 notImplemented 边界错误)。
17
+ * - 审计读门(turnStates / bufferState)公开为测试与运维只读面。
18
+ */
19
+ import type { ExecutionReplay, WebExecutionCommand, WebExecutionError, WebExecutionEvent } from '../protocol/webExecutionV0.js';
20
+ export declare const EXECUTION_QUEUE_DEPTH = 16;
21
+ export declare const EXECUTION_APPROVAL_TIMEOUT_MS = 300000;
22
+ export declare const EXECUTION_MAX_TEXT_BYTES: number;
23
+ export declare const EXECUTION_FOLLOW_BUFFER_LIMIT = 10000;
24
+ /** 单 delta 块字节上限(合同 §8,f4 归属裁定 @2f8a716:kernel 入口执法,禁静默截断)。 */
25
+ export declare const EXECUTION_MAX_DELTA_BYTES: number;
26
+ export type ExecutionTurnOutcome = 'completed' | 'failed' | 'cancelled';
27
+ export type ExecutionApprovalDecision = 'approved' | 'denied' | 'expired' | 'voidedByCancel';
28
+ export type ExecutionTurnRunnerDeps = {
29
+ bind: {
30
+ workspaceId: string;
31
+ sessionId: string;
32
+ turnId: string;
33
+ };
34
+ text: string;
35
+ signal: AbortSignal;
36
+ /** 注册待批操作:resolve 于 decide / 300s expired / turn 取消(voidedByCancel)。 */
37
+ requestApproval: () => Promise<ExecutionApprovalDecision>;
38
+ /**
39
+ * 回合流增量发射(B1 前置件形 1,f4 附条件采认 @2026-11-21):经 kernel
40
+ * 既有 emit 权威落 `turn.delta`(cursor 单调/bind 三元组/缓冲上限同执法,
41
+ * 零新执法面)。text = 回合流内容,不进审批证据记录(合同 §5 不含正文)。
42
+ */
43
+ emitDelta: (text: string) => void;
44
+ };
45
+ export type ExecutionTurnRunner = (deps: ExecutionTurnRunnerDeps) => Promise<ExecutionTurnOutcome>;
46
+ export type ExecutionKernelOptions = {
47
+ runTurn: ExecutionTurnRunner;
48
+ /** 服务端时钟(§5:timestamp 由服务端产生;测试注入)。 */
49
+ now?: () => number;
50
+ /** 服务端解析的连接身份(§5:actorId 客户端自报不得覆盖;组合根注入)。 */
51
+ actorId?: () => string;
52
+ queueDepth?: number;
53
+ approvalTimeoutMs?: number;
54
+ maxTextBytes?: number;
55
+ followBufferLimit?: number;
56
+ };
57
+ export type ExecutionKernelHandleResult = WebExecutionEvent | WebExecutionError;
58
+ type TurnState = 'queued' | 'running' | 'completed' | 'failed' | 'cancelled';
59
+ /**
60
+ * §6 follow 恢复原语(S4)——结果型 ExecutionReplay 归协议文件
61
+ * (webExecutionV0),本域只执语义。
62
+ */
63
+ export type ExecutionKernel = {
64
+ handleCommand: (command: WebExecutionCommand) => Promise<ExecutionKernelHandleResult>;
65
+ /** §6 恢复原语:follow.resume 的 kernel 侧真体(增量恰一次/过期基线替换)。 */
66
+ replaySince: (workspaceId: string, sessionId: string, cursor?: string) => ExecutionReplay;
67
+ onEvent: (cb: (e: WebExecutionEvent) => void) => () => void;
68
+ /** 审计读门:turnId → 状态(queued/running/终态恰一个)。 */
69
+ turnStates: Map<string, TurnState>;
70
+ /** 审计读门:follow 缓冲态(overflowed = 错误边界标记,S4 游标重同步消费)。 */
71
+ bufferState: (workspaceId: string, sessionId: string) => {
72
+ overflowed: boolean;
73
+ kept: number;
74
+ };
75
+ };
76
+ export declare function createExecutionKernel(options: ExecutionKernelOptions): ExecutionKernel;
77
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaswork/atlascode",
3
- "version": "0.1.126",
3
+ "version": "0.1.127",
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": {
@@ -122,4 +122,4 @@
122
122
  "typescript": "^5.9.3",
123
123
  "typescript-eslint": "^8"
124
124
  }
125
- }
125
+ }