@bastani/atomic 0.8.30-alpha.2 → 0.8.30-alpha.3

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 (34) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/dist/builtin/cursor/package.json +2 -2
  3. package/dist/builtin/intercom/package.json +1 -1
  4. package/dist/builtin/mcp/package.json +1 -1
  5. package/dist/builtin/subagents/package.json +1 -1
  6. package/dist/builtin/web-access/package.json +1 -1
  7. package/dist/builtin/workflows/CHANGELOG.md +1 -0
  8. package/dist/builtin/workflows/README.md +1 -1
  9. package/dist/builtin/workflows/package.json +1 -1
  10. package/dist/builtin/workflows/src/runs/foreground/executor.ts +19 -10
  11. package/dist/core/anthropic-thinking-guard.d.ts +15 -0
  12. package/dist/core/anthropic-thinking-guard.d.ts.map +1 -0
  13. package/dist/core/anthropic-thinking-guard.js +205 -0
  14. package/dist/core/anthropic-thinking-guard.js.map +1 -0
  15. package/dist/core/compaction/compaction.d.ts +8 -2
  16. package/dist/core/compaction/compaction.d.ts.map +1 -1
  17. package/dist/core/compaction/compaction.js +19 -3
  18. package/dist/core/compaction/compaction.js.map +1 -1
  19. package/dist/core/compaction/context-compaction.d.ts.map +1 -1
  20. package/dist/core/compaction/context-compaction.js +30 -3
  21. package/dist/core/compaction/context-compaction.js.map +1 -1
  22. package/dist/core/sdk.d.ts.map +1 -1
  23. package/dist/core/sdk.js +15 -3
  24. package/dist/core/sdk.js.map +1 -1
  25. package/dist/core/session-manager.d.ts.map +1 -1
  26. package/dist/core/session-manager.js +22 -28
  27. package/dist/core/session-manager.js.map +1 -1
  28. package/dist/modes/interactive/components/context-compaction-summary-message.d.ts.map +1 -1
  29. package/dist/modes/interactive/components/context-compaction-summary-message.js +2 -2
  30. package/dist/modes/interactive/components/context-compaction-summary-message.js.map +1 -1
  31. package/docs/compaction.md +2 -0
  32. package/docs/session-format.md +1 -1
  33. package/docs/workflows.md +2 -0
  34. package/package.json +2 -2
@@ -150,7 +150,7 @@ What Survives:
150
150
  - User instructions: The original task and any clarifications.
151
151
 
152
152
  Conditionally Deleted:
153
- - Old Reasoning decisions: If there is nothing else to remove and the target reduction is not met, you can remove reasoning steps, EXCEPT do not delete any content block from the latest assistant message when that message contains thinking or redacted_thinking blocks.
153
+ - Old Reasoning decisions: If there is nothing else to remove and the target reduction is not met, you can remove entire stale assistant entries, EXCEPT do not delete individual content blocks from any retained assistant message that contains thinking or redacted_thinking blocks. Thinking-bearing assistant messages are all-or-nothing for replay safety.
154
154
 
155
155
  <output_format>
156
156
  Call the context_delete tool one or more times with deletion targets in this shape:
@@ -525,7 +525,7 @@ function formatProtectedToolDependencyError(transcript, blockedTarget, context)
525
525
  function isProtectedContextDeletionErrorMessage(message) {
526
526
  return (/\bprotected\b/i.test(message) ||
527
527
  /Cannot delete (?:recent context entry|content block .* because entry .* is one of the last)/u.test(message) ||
528
- /latest assistant message|thinking\/redacted_thinking block in the latest assistant message/u.test(message));
528
+ /latest assistant message|thinking\/redacted_thinking block in (?:the latest|a retained) assistant message/u.test(message));
529
529
  }
530
530
  function assertNoRecentContextDeletionTargets(transcript, targets) {
531
531
  const recentEntryIds = getRecentContextEntryIds(transcript);
@@ -543,6 +543,19 @@ function latestAssistantEntry(transcript, deletedEntryIds = new Set()) {
543
543
  }
544
544
  return undefined;
545
545
  }
546
+ function findAssistantThinkingContentBlockDeletionViolation(transcript, targets) {
547
+ const deletedEntryIds = getDeletedEntryIds(targets);
548
+ for (const target of targets) {
549
+ if (target.kind !== "content_block")
550
+ continue;
551
+ if (deletedEntryIds.has(target.entryId))
552
+ continue;
553
+ const entry = findTranscriptEntry(transcript, target.entryId);
554
+ if (entry && assistantEntryHasThinkingContentBlock(entry))
555
+ return target;
556
+ }
557
+ return undefined;
558
+ }
546
559
  function findLatestAssistantThinkingDeletionViolation(transcript, targets) {
547
560
  const deletedEntryIds = getDeletedEntryIds(targets);
548
561
  const latestRetainedAssistant = latestAssistantEntry(transcript, deletedEntryIds);
@@ -565,6 +578,12 @@ function findLatestAssistantThinkingDeletionViolation(transcript, targets) {
565
578
  }
566
579
  return undefined;
567
580
  }
581
+ function assertNoAssistantThinkingContentBlockDeletionTargets(transcript, targets) {
582
+ const violation = findAssistantThinkingContentBlockDeletionViolation(transcript, targets);
583
+ if (!violation)
584
+ return;
585
+ throw new Error(`Cannot delete content block ${violation.entryId}:${violation.blockIndex} because a thinking/redacted_thinking block in a retained assistant message must remain unmodified; retained assistant messages containing thinking/redacted_thinking content blocks are all-or-nothing`);
586
+ }
568
587
  function assertNoLatestAssistantThinkingDeletionTargets(transcript, targets) {
569
588
  const violation = findLatestAssistantThinkingDeletionViolation(transcript, targets);
570
589
  if (!violation)
@@ -630,6 +649,11 @@ function canonicalizeEntryTargets(transcript, targets, entry) {
630
649
  return deleteEntryTarget(targets, entry.entryId);
631
650
  }
632
651
  function addToolCallDeletion(transcript, targets, entry, callId) {
652
+ if (assistantEntryHasThinkingContentBlock(entry)) {
653
+ if (!canDeleteTarget(transcript, { kind: "entry", entryId: entry.entryId }))
654
+ return false;
655
+ return deleteEntryTarget(targets, entry.entryId);
656
+ }
633
657
  let changed = false;
634
658
  for (const blockIndex of toolCallBlockIndexes(entry, callId)) {
635
659
  const target = { kind: "content_block", entryId: entry.entryId, blockIndex };
@@ -700,7 +724,9 @@ function reconcileToolDependencies(transcript, initialTargets) {
700
724
  continue;
701
725
  recordChange(deleteEntryTarget(targets, result.entryId));
702
726
  const callEntryTarget = { kind: "entry", entryId: callEntry.entryId };
703
- const callBlockTarget = firstToolCallBlockTarget(callEntry, callId) ?? callEntryTarget;
727
+ const callBlockTarget = assistantEntryHasThinkingContentBlock(callEntry)
728
+ ? callEntryTarget
729
+ : firstToolCallBlockTarget(callEntry, callId) ?? callEntryTarget;
704
730
  if (!canDeleteTarget(transcript, callBlockTarget)) {
705
731
  if (isRecentTarget(transcript, callBlockTarget)) {
706
732
  throw new Error(formatRecentContextDeletionError(transcript, callBlockTarget));
@@ -884,6 +910,7 @@ export function validateContextDeletionRequest(request, transcript) {
884
910
  // Tool reconciliation can add targets after the per-request checks above, so
885
911
  // these post-reconcile assertions remain authoritative.
886
912
  assertNoRecentContextDeletionTargets(transcript, reconciledTargets);
913
+ assertNoAssistantThinkingContentBlockDeletionTargets(transcript, reconciledTargets);
887
914
  assertNoLatestAssistantThinkingDeletionTargets(transcript, reconciledTargets);
888
915
  const reconciledDeletedEntryIds = getDeletedEntryIds(reconciledTargets);
889
916
  for (const target of reconciledTargets) {