@sema-agent/core 5.54.0 → 5.56.0
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.
- package/CHANGELOG.md +160 -0
- package/dist/agents/cumulative-stats.d.ts +26 -0
- package/dist/agents/cumulative-stats.js +56 -0
- package/dist/agents/observer.d.ts +11 -7
- package/dist/agents/observer.js +2 -4
- package/dist/agents/send-message-tool.js +48 -2
- package/dist/agents/subagent.js +250 -89
- package/dist/agents/verify.d.ts +27 -3
- package/dist/agents/verify.js +7 -2
- package/dist/core/auto-compaction.d.ts +17 -4
- package/dist/core/auto-compaction.js +3 -0
- package/dist/core/context-edit.d.ts +55 -6
- package/dist/core/context-edit.js +12 -1
- package/dist/core/governance-codes.js +14 -0
- package/dist/core/hooks.d.ts +293 -11
- package/dist/core/hooks.js +159 -12
- package/dist/core/human-input-projection.d.ts +20 -2
- package/dist/core/human-input-projection.js +9 -0
- package/dist/core/lsp-diagnostics.d.ts +19 -17
- package/dist/core/lsp-diagnostics.js +11 -5
- package/dist/core/mcp.d.ts +46 -0
- package/dist/core/mcp.js +132 -6
- package/dist/core/memory-engine/consolidation.d.ts +378 -0
- package/dist/core/memory-engine/consolidation.js +342 -0
- package/dist/core/memory-engine/dual-root.js +3 -0
- package/dist/core/memory-engine/engine.d.ts +237 -4
- package/dist/core/memory-engine/engine.js +1111 -4
- package/dist/core/memory-engine/export-bundle.js +9 -0
- package/dist/core/memory-engine/file-backend.js +27 -1
- package/dist/core/memory-engine/frontmatter.d.ts +20 -1
- package/dist/core/memory-engine/frontmatter.js +111 -0
- package/dist/core/memory-engine/index.d.ts +4 -2
- package/dist/core/memory-engine/index.js +3 -1
- package/dist/core/memory-engine/memory-backend-contract.js +131 -0
- package/dist/core/memory-engine/sync-client.js +26 -0
- package/dist/core/memory-engine/tools.d.ts +9 -0
- package/dist/core/memory-engine/tools.js +57 -13
- package/dist/core/memory-engine/types.d.ts +99 -0
- package/dist/core/memory-recall.js +4 -3
- package/dist/core/memory.d.ts +33 -3
- package/dist/core/memory.js +6 -4
- package/dist/core/permission-rules.d.ts +30 -0
- package/dist/core/permission-rules.js +71 -8
- package/dist/core/reminder-disclosure.d.ts +29 -4
- package/dist/core/reminder-disclosure.js +60 -12
- package/dist/core/runner/prepare-memory.js +7 -2
- package/dist/core/runner/prepare-task.d.ts +39 -1
- package/dist/core/runner/prepare-task.js +63 -35
- package/dist/core/runner/runtask.d.ts +8 -1
- package/dist/core/runner/runtask.js +170 -31
- package/dist/core/runner/session-rule-policy.js +5 -3
- package/dist/core/runner/synthetic-tools.js +4 -2
- package/dist/core/runner/turn-attachments.d.ts +16 -6
- package/dist/core/runner/turn-attachments.js +34 -20
- package/dist/core/session-reconcile.d.ts +32 -0
- package/dist/core/session-reconcile.js +15 -0
- package/dist/core/task-notification.d.ts +34 -7
- package/dist/core/task-notification.js +11 -1
- package/dist/core/task-registry-agent.d.ts +20 -3
- package/dist/core/task-registry-agent.js +31 -2
- package/dist/core/tool-policy.d.ts +23 -0
- package/dist/core/tool-policy.js +29 -13
- package/dist/core/types.d.ts +126 -17
- package/dist/core/untrusted-egress.js +12 -2
- package/dist/core/untrusted-text.d.ts +189 -3
- package/dist/core/untrusted-text.js +424 -6
- package/dist/engine/compaction/compaction.d.ts +77 -7
- package/dist/engine/compaction/compaction.js +98 -9
- package/dist/engine/compaction/utils.d.ts +4 -0
- package/dist/engine/compaction/utils.js +6 -0
- package/dist/engine/harness/agent-harness.d.ts +84 -0
- package/dist/engine/harness/agent-harness.js +88 -12
- package/dist/engine/harness/messages.d.ts +4 -2
- package/dist/engine/harness/messages.js +7 -2
- package/dist/engine/harness/types.d.ts +11 -5
- package/dist/engine/loop/types.d.ts +14 -0
- package/dist/engine/session/import-validate.js +10 -0
- package/dist/engine/session/session.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/orchestration/run-spec.js +8 -1
- package/dist/prompts/default.d.ts +22 -6
- package/dist/tools/fs/index.d.ts +3 -1
- package/package.json +1 -1
- package/test/export-surface.snapshot.json +28 -1
|
@@ -183,6 +183,16 @@ export class StreamingImportValidator {
|
|
|
183
183
|
if (elided !== undefined && !(typeof elided === "number" && Number.isSafeInteger(elided) && elided >= 0)) {
|
|
184
184
|
throw new SessionError("invalid_session", `compaction "${e.id}" carries a structurally invalid elidedMessages count (non-negative integer)`);
|
|
185
185
|
}
|
|
186
|
+
const uncovered = e.details?.unsummarizedMessages;
|
|
187
|
+
if (uncovered !== undefined) {
|
|
188
|
+
if (!(typeof uncovered === "number" && Number.isSafeInteger(uncovered) && uncovered >= 0)) {
|
|
189
|
+
throw new SessionError("invalid_session", `compaction "${e.id}" carries a structurally invalid unsummarizedMessages count (non-negative integer)`);
|
|
190
|
+
}
|
|
191
|
+
if (uncovered > 0 && !(typeof elided === "number" && elided >= uncovered)) {
|
|
192
|
+
throw new SessionError("invalid_session", `compaction "${e.id}" carries unsummarizedMessages ${uncovered} without an elidedMessages count at least that ` +
|
|
193
|
+
`large (uncovered messages are a subset of the folded ones)`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
186
196
|
const refs = e.details?.persistedOutputRefs;
|
|
187
197
|
if (refs !== undefined) {
|
|
188
198
|
if (!Array.isArray(refs) || refs.length > PERSISTED_OUTPUT_REFS_MAX_ENTRIES) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { asAgentMessage, createCompactionSummaryMessage, createCustomMessage, } from "../harness/messages.js";
|
|
2
2
|
import { SessionError, isValidModelChange, normalizeAnnouncedListing, normalizeCompactionStateCarrier, normalizeGitAnnouncement, normalizeReminderMark, normalizeWorkspaceState } from "../harness/types.js";
|
|
3
3
|
import { normalizePromptEpoch } from "../../prompt-assembly/epoch.js";
|
|
4
|
-
import { budgetInvokedSkillsRetention, readElidedMessages, readRetainedInvokedSkills, renderInvokedSkillsRetention, } from "../compaction/utils.js";
|
|
4
|
+
import { budgetInvokedSkillsRetention, readElidedMessages, readRetainedInvokedSkills, readUnsummarizedMessages, renderInvokedSkillsRetention, } from "../compaction/utils.js";
|
|
5
5
|
const RETENTION_CLAMP_DEFAULT_CHARS_PER_TOKEN = 4;
|
|
6
6
|
const RETENTION_CLAMP_WINDOW_FRACTION = 0.5;
|
|
7
7
|
export function buildSessionContext(pathEntries, opts) {
|
|
@@ -67,7 +67,7 @@ export function buildSessionContext(pathEntries, opts) {
|
|
|
67
67
|
retainedSkills = budgetInvokedSkillsRetention(retainedSkills, budgetChars);
|
|
68
68
|
}
|
|
69
69
|
const retainedSkillsBlock = renderInvokedSkillsRetention(retainedSkills);
|
|
70
|
-
messages.push(asAgentMessage(createCompactionSummaryMessage(compaction.summary + retainedSkillsBlock, compaction.tokensBefore, compaction.timestamp, readElidedMessages(compaction.details))));
|
|
70
|
+
messages.push(asAgentMessage(createCompactionSummaryMessage(compaction.summary + retainedSkillsBlock, compaction.tokensBefore, compaction.timestamp, readElidedMessages(compaction.details), readUnsummarizedMessages(compaction.details))));
|
|
71
71
|
const compactionIdx = pathEntries.findIndex((e) => e.type === "compaction" && e.id === compaction.id);
|
|
72
72
|
let foundFirstKept = false;
|
|
73
73
|
for (let i = 0; i < compactionIdx; i++) {
|
package/dist/index.d.ts
CHANGED
|
@@ -168,7 +168,7 @@ export { AdoptionError, assertAdoptionBootGate, readRootAdoptionFile, writeRootA
|
|
|
168
168
|
export { adoptLocalDataRoot, ackAdoptionConfig, witnessAdoptionConfig, listAdoptionQuarantine, readAdoptionStatus, type AdoptionStatus, type AdoptLocalDataRootOptions, type AdoptLocalDataRootResult, type AdoptionCarriageLeg, type AdoptionCarriageLegContext, type AdoptionConfigWitnessReceipt, } from "./stores/file/adoption/adopt.js";
|
|
169
169
|
export { formatHookFeedback, runToolGate, createHookEnvCapabilities, createPreToolUseConstraintPolicy, type PersistedRuleHit, type PersistedRuleUnreadable, type PersistedRuleAnswer, normalizePersistedRuleHit, type Hooks, type HookToolContext, type HookInvocationIdentity, type UserPromptSubmitContext, type PostToolBatchContext, type HookEnvCapabilities, type HookToolOutput, type PreToolUseResult, type PostToolUseResult, type UserPromptSubmitResult, type HookToolFailure, type PostToolUseFailureResult, type PostToolBatchCall, type PostToolBatchResult, type PreCompactContext, type PreCompactResult, type PostCompactContext, type StopFailureContext, type PermissionDeniedPayload, type PermissionDeniedSource, } from "./core/hooks.js";
|
|
170
170
|
export { InMemoryMemoryStore, composeMemoryBlock, composeLayeredMemoryBlock, normalizeMemorySpec, type NormalizedMemorySpec, type MemorySpecInput, supportsConsolidation, supportsPeriodicConsolidation, firstSentence, expandLexicalTerms, lexicalSearchMatch, type Embedder, classifyPromotable, enforcePromotableWriteGate, guardedMemoryStore, MemoryGateError, detectSecret, enforceSecretWriteGate, enforceStructuredNoteSecretGate, type UtilityGate, type MemoryStore, type MemoryVectorMode, type ScoredMemory, type MemoryNoteHeader, type MemoryNoteRecord, type MemoryNoteType, type StructuredNoteInput, } from "./core/memory.js";
|
|
171
|
-
export { MemoryEngine, FileMemoryEngineBackend, memoryBackendContract, assertMemoryBackendSearchEquivalence, type MemoryBackendContractHooks, buildMemoryInstruction, truncateIndex, scanEntryFiles, deriveRepoKey, deriveRepoMemoryDir, deriveControlPlaneDir, deriveRepoControlPlaneDir, resolveMemoryEngineRoot, scopeDirName, ControlPlaneCorruptError, parseEntryFile, serializeEntryFile, computeEntryRev, entryFromFile, MEMORY_ORIGIN_CAUSES, committedOriginOf, originEquals, ambiguousOriginRepresentation, isInstructionEntry, type MemoryEntryOrigin, type MemoryOriginCause, MEMORY_INSTRUCTION_TEMPLATE, MEMORY_RECALL_DISCIPLINE, MEMORY_PREFERENCE_DISCIPLINE, MEMORY_READONLY_NOTICE, readV2HeaderHints, type V2HeaderHints, LINEAGE_FILE, CHALLENGES_FILE, CHALLENGED_HISTORY_FILE, CHALLENGE_LEDGER_MAX_EVENTS, rebuildStrictControlPlaneLedger, type ControlPlaneRebuildReceipt, type StrictControlPlaneLedger, type ChallengeAssignment, type ChallengeEvent, type ChallengedHistoryRow, type LineagePendingTxn, type LineagePromotion, MEMORY_INDEX_FILENAME, MEMORY_INDEX_MAX_LINES, MEMORY_INDEX_MAX_BYTES, MEMORY_SEARCH_TOOL_NAME, MEMORY_GET_TOOL_NAME, MEMORY_ENGINE_TOOL_NAMES, type MemorySearchDetails, type MemorySearchHit, type CleanMemorySearchHit, type ExposedMemorySearchHit, MEMORY_EXPOSURE_BANNER, MEMORY_EXPOSURE_HANDLE_TAG, memoryExposureIndexRow, type MemoryGetDetails, STUB_ARCHIVED_LINE, DEFAULT_MAX_MEMORY_FILES, DEFAULT_MAX_ENTRY_DEPTH, DEFAULT_HARVEST_DEADLINE_MS, DEFAULT_HARVEST_FILE_BUDGET, MASS_DELETION_FUSE_RATIO, scanMemoryWrite, scanMemoryFileName, scanRemediation, MEMORY_FILENAME_SEGMENT_RE, renderAnnouncements, enqueueMemoryAnnouncement, drainMemoryAnnouncements, peekMemoryAnnouncements, bumpScanFuse, scanFuseCount, clearScanFuse, ANNOUNCEMENTS_FILE, MEMORY_ANNOUNCEMENTS_MAX, SCAN_FUSE_FILE, SCAN_FUSE_THRESHOLD, type MemoryAnnouncement, type ScanFinding, type MemoryEngineOptions, type MemoryInjection, type EntryProvenanceAccount, type TransferEvidence, type CommittedBinding, type CommittedEntrySnapshot, type CommittedScopeSnapshots, type EntryCustodyReport, erasureSelectHash, type EraseMemoryEntriesInput, type ErasureSelect, type ErasedBinding, type MemoryErasureAttestation, computeMemoryBundleHash, type MemoryExportBundle, type MemoryImportReport, type MemoryExportSnapshot, type MemoryBundleImportPlan, type BundleChallengeRow, type BundleLineageRow, type BundlePollutedSession, type MemoryBackend, type MemoryEntry, type MemoryEntryFrontmatter, type MemoryEntryHeader, type ScoredMemoryEntry, type NotePatch, type PatchReport, type MaterializedFile, type MemorySessionHandle, type HarvestReport, type HarvestRejection, type HarvestRejectionCode, type ParsedEntryFile, type ScannedEntryFile, SCOPE_SEGMENT_MAX_ENCODED, PROJECT_MARKER_PATH, encodeScopeSegment, decodeScopeSegment, parseScopeKey, formatUserScope, formatOrgScope, formatProjScope, formatUserProjScope, isPersonalScope, assertScopeContractPlacement, formatProjectMarker, parseProjectMarker, resolveProjectId, PROJECT_ID_REGEX, type ParsedScopeKey, migrateScope, type MigrateScopeReport, materializeEntriesToFiles, harvestFilesToPatches, projectionsToWriteBack, screenInboundEntries, REMOTE_HARVEST_PER_FILE_BYTES, REMOTE_MASS_DELETION_FUSE_RATIO, type RemoteMemoryFile, type RemoteMemoryBaseline, type RemoteMaterialization, type RemoteHarvestResult, type InboundEntryFinding, deriveProjectMemoryDir, deriveProjectControlDir, recordProjectIdHint, lookupProjectIdHint, PROJECT_ID_HINTS_FILE, reconcileMemoryEntries, nextSyncBaseline, mergeRecallHits, type MemorySyncCursor, type MemorySyncConflict, type MemorySyncPlan, type RecallSource, syncMemoryScope, type MemorySyncTransport, type MemorySyncRequestBody, type MemorySyncResponseBody, type MemorySyncClientConflict, type SyncMemoryScopeOptions, type MemorySyncClientResult, } from "./core/memory-engine/index.js";
|
|
171
|
+
export { MemoryEngine, FileMemoryEngineBackend, memoryBackendContract, assertMemoryBackendSearchEquivalence, type MemoryBackendContractHooks, buildMemoryInstruction, truncateIndex, scanEntryFiles, deriveRepoKey, deriveRepoMemoryDir, deriveControlPlaneDir, deriveRepoControlPlaneDir, resolveMemoryEngineRoot, scopeDirName, ControlPlaneCorruptError, parseEntryFile, serializeEntryFile, computeEntryRev, entryFromFile, MEMORY_ORIGIN_CAUSES, committedOriginOf, originEquals, ambiguousOriginRepresentation, committedDistilledOf, distilledEquals, type MemoryEntryDistilled, type MemoryEntryDistilledInput, CONSOLIDATION_DEFAULTS, ConsolidationRefusedError, MEMORY_SEARCH_SUPERSEDED_TAG, consolidationTypeEligible, deriveSupersededSet, memorySupersededNote, readIntentCredentials, supersessionFuseCeiling, memoryConsolidationRecommendedNotice, memoryConsolidationCommittedNotice, memoryConsolidationConflictNotice, memoryConsolidationRefusedNotice, type ConsolidationGateRow, type ConsolidationIntent, type ConsolidationIntentCredentialRow, type ConsolidationLeaseSeat, type ConsolidationProductProposal, type ConsolidationProposal, type MemoryConsolidationOptions, type ConsolidationCommitReceipt, type ConsolidationReconcileReport, type ConsolidationResolveReceipt, type ConsolidationPlanSummary, isInstructionEntry, type MemoryEntryOrigin, type MemoryOriginCause, MEMORY_INSTRUCTION_TEMPLATE, MEMORY_RECALL_DISCIPLINE, MEMORY_PREFERENCE_DISCIPLINE, MEMORY_READONLY_NOTICE, readV2HeaderHints, type V2HeaderHints, LINEAGE_FILE, CHALLENGES_FILE, CHALLENGED_HISTORY_FILE, CHALLENGE_LEDGER_MAX_EVENTS, rebuildStrictControlPlaneLedger, type ControlPlaneRebuildReceipt, type StrictControlPlaneLedger, type ChallengeAssignment, type ChallengeEvent, type ChallengedHistoryRow, type LineagePendingTxn, type LineagePromotion, MEMORY_INDEX_FILENAME, MEMORY_INDEX_MAX_LINES, MEMORY_INDEX_MAX_BYTES, MEMORY_SEARCH_TOOL_NAME, MEMORY_GET_TOOL_NAME, MEMORY_ENGINE_TOOL_NAMES, type MemorySearchDetails, type MemorySearchHit, type CleanMemorySearchHit, type ExposedMemorySearchHit, MEMORY_EXPOSURE_BANNER, MEMORY_EXPOSURE_HANDLE_TAG, memoryExposureIndexRow, type MemoryGetDetails, STUB_ARCHIVED_LINE, DEFAULT_MAX_MEMORY_FILES, DEFAULT_MAX_ENTRY_DEPTH, DEFAULT_HARVEST_DEADLINE_MS, DEFAULT_HARVEST_FILE_BUDGET, MASS_DELETION_FUSE_RATIO, scanMemoryWrite, scanMemoryFileName, scanRemediation, MEMORY_FILENAME_SEGMENT_RE, renderAnnouncements, enqueueMemoryAnnouncement, drainMemoryAnnouncements, peekMemoryAnnouncements, bumpScanFuse, scanFuseCount, clearScanFuse, ANNOUNCEMENTS_FILE, MEMORY_ANNOUNCEMENTS_MAX, SCAN_FUSE_FILE, SCAN_FUSE_THRESHOLD, type MemoryAnnouncement, type ScanFinding, type MemoryEngineOptions, type MemoryInjection, type EntryProvenanceAccount, type TransferEvidence, type CommittedBinding, type CommittedEntrySnapshot, type CommittedScopeSnapshots, type EntryCustodyReport, erasureSelectHash, type EraseMemoryEntriesInput, type ErasureSelect, type ErasedBinding, type MemoryErasureAttestation, computeMemoryBundleHash, type MemoryExportBundle, type MemoryImportReport, type MemoryExportSnapshot, type MemoryBundleImportPlan, type BundleChallengeRow, type BundleLineageRow, type BundlePollutedSession, type MemoryBackend, type MemoryEntry, type MemoryEntryFrontmatter, type MemoryEntryHeader, type ScoredMemoryEntry, type NotePatch, type PatchReport, type MaterializedFile, type MemorySessionHandle, type HarvestReport, type HarvestRejection, type HarvestRejectionCode, type ParsedEntryFile, type ScannedEntryFile, SCOPE_SEGMENT_MAX_ENCODED, PROJECT_MARKER_PATH, encodeScopeSegment, decodeScopeSegment, parseScopeKey, formatUserScope, formatOrgScope, formatProjScope, formatUserProjScope, isPersonalScope, assertScopeContractPlacement, formatProjectMarker, parseProjectMarker, resolveProjectId, PROJECT_ID_REGEX, type ParsedScopeKey, migrateScope, type MigrateScopeReport, materializeEntriesToFiles, harvestFilesToPatches, projectionsToWriteBack, screenInboundEntries, REMOTE_HARVEST_PER_FILE_BYTES, REMOTE_MASS_DELETION_FUSE_RATIO, type RemoteMemoryFile, type RemoteMemoryBaseline, type RemoteMaterialization, type RemoteHarvestResult, type InboundEntryFinding, deriveProjectMemoryDir, deriveProjectControlDir, recordProjectIdHint, lookupProjectIdHint, PROJECT_ID_HINTS_FILE, reconcileMemoryEntries, nextSyncBaseline, mergeRecallHits, type MemorySyncCursor, type MemorySyncConflict, type MemorySyncPlan, type RecallSource, syncMemoryScope, type MemorySyncTransport, type MemorySyncRequestBody, type MemorySyncResponseBody, type MemorySyncClientConflict, type SyncMemoryScopeOptions, type MemorySyncClientResult, } from "./core/memory-engine/index.js";
|
|
172
172
|
export { SHARED_MEMORY_READ_CAP_BYTES, SHARED_MEMORY_LIST_PAGE_SIZE, SharedMemoryStoreError, type SharedMemoryStoreProvider, type SharedMemoryStoreReader, type SharedMemoryPagedList, type SharedMemoryStoreInfo, type SharedMemoryDocumentEntry, type SharedMemorySnapshot, type SharedMemoryRequestContext, type MemoryListDetails, type MemoryReadDetails, } from "./core/shared-memory/types.js";
|
|
173
173
|
export { sharedMemoryStoreContract, type SharedMemoryFixture, type SharedMemoryStoreContractHooks, } from "./core/shared-memory/contract.js";
|
|
174
174
|
export { termSet, jaccardDistance, cosineDistance } from "./core/memory-vector.js";
|
package/dist/index.js
CHANGED
|
@@ -130,7 +130,7 @@ export { AdoptionError, assertAdoptionBootGate, readRootAdoptionFile, writeRootA
|
|
|
130
130
|
export { adoptLocalDataRoot, ackAdoptionConfig, witnessAdoptionConfig, listAdoptionQuarantine, readAdoptionStatus, } from "./stores/file/adoption/adopt.js";
|
|
131
131
|
export { formatHookFeedback, runToolGate, createHookEnvCapabilities, createPreToolUseConstraintPolicy, normalizePersistedRuleHit, } from "./core/hooks.js";
|
|
132
132
|
export { InMemoryMemoryStore, composeMemoryBlock, composeLayeredMemoryBlock, normalizeMemorySpec, supportsConsolidation, supportsPeriodicConsolidation, firstSentence, expandLexicalTerms, lexicalSearchMatch, classifyPromotable, enforcePromotableWriteGate, guardedMemoryStore, MemoryGateError, detectSecret, enforceSecretWriteGate, enforceStructuredNoteSecretGate, } from "./core/memory.js";
|
|
133
|
-
export { MemoryEngine, FileMemoryEngineBackend, memoryBackendContract, assertMemoryBackendSearchEquivalence, buildMemoryInstruction, truncateIndex, scanEntryFiles, deriveRepoKey, deriveRepoMemoryDir, deriveControlPlaneDir, deriveRepoControlPlaneDir, resolveMemoryEngineRoot, scopeDirName, ControlPlaneCorruptError, parseEntryFile, serializeEntryFile, computeEntryRev, entryFromFile, MEMORY_ORIGIN_CAUSES, committedOriginOf, originEquals, ambiguousOriginRepresentation, isInstructionEntry, MEMORY_INSTRUCTION_TEMPLATE, MEMORY_RECALL_DISCIPLINE, MEMORY_PREFERENCE_DISCIPLINE, MEMORY_READONLY_NOTICE, readV2HeaderHints, LINEAGE_FILE, CHALLENGES_FILE, CHALLENGED_HISTORY_FILE, CHALLENGE_LEDGER_MAX_EVENTS, rebuildStrictControlPlaneLedger, MEMORY_INDEX_FILENAME, MEMORY_INDEX_MAX_LINES, MEMORY_INDEX_MAX_BYTES, MEMORY_SEARCH_TOOL_NAME, MEMORY_GET_TOOL_NAME, MEMORY_ENGINE_TOOL_NAMES, MEMORY_EXPOSURE_BANNER, MEMORY_EXPOSURE_HANDLE_TAG, memoryExposureIndexRow, STUB_ARCHIVED_LINE, DEFAULT_MAX_MEMORY_FILES, DEFAULT_MAX_ENTRY_DEPTH, DEFAULT_HARVEST_DEADLINE_MS, DEFAULT_HARVEST_FILE_BUDGET, MASS_DELETION_FUSE_RATIO, scanMemoryWrite, scanMemoryFileName, scanRemediation, MEMORY_FILENAME_SEGMENT_RE, renderAnnouncements, enqueueMemoryAnnouncement, drainMemoryAnnouncements, peekMemoryAnnouncements, bumpScanFuse, scanFuseCount, clearScanFuse, ANNOUNCEMENTS_FILE, MEMORY_ANNOUNCEMENTS_MAX, SCAN_FUSE_FILE, SCAN_FUSE_THRESHOLD, erasureSelectHash, computeMemoryBundleHash, SCOPE_SEGMENT_MAX_ENCODED, PROJECT_MARKER_PATH, encodeScopeSegment, decodeScopeSegment, parseScopeKey, formatUserScope, formatOrgScope, formatProjScope, formatUserProjScope, isPersonalScope, assertScopeContractPlacement, formatProjectMarker, parseProjectMarker, resolveProjectId, PROJECT_ID_REGEX, migrateScope, materializeEntriesToFiles, harvestFilesToPatches, projectionsToWriteBack, screenInboundEntries, REMOTE_HARVEST_PER_FILE_BYTES, REMOTE_MASS_DELETION_FUSE_RATIO, deriveProjectMemoryDir, deriveProjectControlDir, recordProjectIdHint, lookupProjectIdHint, PROJECT_ID_HINTS_FILE, reconcileMemoryEntries, nextSyncBaseline, mergeRecallHits, syncMemoryScope, } from "./core/memory-engine/index.js";
|
|
133
|
+
export { MemoryEngine, FileMemoryEngineBackend, memoryBackendContract, assertMemoryBackendSearchEquivalence, buildMemoryInstruction, truncateIndex, scanEntryFiles, deriveRepoKey, deriveRepoMemoryDir, deriveControlPlaneDir, deriveRepoControlPlaneDir, resolveMemoryEngineRoot, scopeDirName, ControlPlaneCorruptError, parseEntryFile, serializeEntryFile, computeEntryRev, entryFromFile, MEMORY_ORIGIN_CAUSES, committedOriginOf, originEquals, ambiguousOriginRepresentation, committedDistilledOf, distilledEquals, CONSOLIDATION_DEFAULTS, ConsolidationRefusedError, MEMORY_SEARCH_SUPERSEDED_TAG, consolidationTypeEligible, deriveSupersededSet, memorySupersededNote, readIntentCredentials, supersessionFuseCeiling, memoryConsolidationRecommendedNotice, memoryConsolidationCommittedNotice, memoryConsolidationConflictNotice, memoryConsolidationRefusedNotice, isInstructionEntry, MEMORY_INSTRUCTION_TEMPLATE, MEMORY_RECALL_DISCIPLINE, MEMORY_PREFERENCE_DISCIPLINE, MEMORY_READONLY_NOTICE, readV2HeaderHints, LINEAGE_FILE, CHALLENGES_FILE, CHALLENGED_HISTORY_FILE, CHALLENGE_LEDGER_MAX_EVENTS, rebuildStrictControlPlaneLedger, MEMORY_INDEX_FILENAME, MEMORY_INDEX_MAX_LINES, MEMORY_INDEX_MAX_BYTES, MEMORY_SEARCH_TOOL_NAME, MEMORY_GET_TOOL_NAME, MEMORY_ENGINE_TOOL_NAMES, MEMORY_EXPOSURE_BANNER, MEMORY_EXPOSURE_HANDLE_TAG, memoryExposureIndexRow, STUB_ARCHIVED_LINE, DEFAULT_MAX_MEMORY_FILES, DEFAULT_MAX_ENTRY_DEPTH, DEFAULT_HARVEST_DEADLINE_MS, DEFAULT_HARVEST_FILE_BUDGET, MASS_DELETION_FUSE_RATIO, scanMemoryWrite, scanMemoryFileName, scanRemediation, MEMORY_FILENAME_SEGMENT_RE, renderAnnouncements, enqueueMemoryAnnouncement, drainMemoryAnnouncements, peekMemoryAnnouncements, bumpScanFuse, scanFuseCount, clearScanFuse, ANNOUNCEMENTS_FILE, MEMORY_ANNOUNCEMENTS_MAX, SCAN_FUSE_FILE, SCAN_FUSE_THRESHOLD, erasureSelectHash, computeMemoryBundleHash, SCOPE_SEGMENT_MAX_ENCODED, PROJECT_MARKER_PATH, encodeScopeSegment, decodeScopeSegment, parseScopeKey, formatUserScope, formatOrgScope, formatProjScope, formatUserProjScope, isPersonalScope, assertScopeContractPlacement, formatProjectMarker, parseProjectMarker, resolveProjectId, PROJECT_ID_REGEX, migrateScope, materializeEntriesToFiles, harvestFilesToPatches, projectionsToWriteBack, screenInboundEntries, REMOTE_HARVEST_PER_FILE_BYTES, REMOTE_MASS_DELETION_FUSE_RATIO, deriveProjectMemoryDir, deriveProjectControlDir, recordProjectIdHint, lookupProjectIdHint, PROJECT_ID_HINTS_FILE, reconcileMemoryEntries, nextSyncBaseline, mergeRecallHits, syncMemoryScope, } from "./core/memory-engine/index.js";
|
|
134
134
|
export { SHARED_MEMORY_READ_CAP_BYTES, SHARED_MEMORY_LIST_PAGE_SIZE, SharedMemoryStoreError, } from "./core/shared-memory/types.js";
|
|
135
135
|
export { sharedMemoryStoreContract, } from "./core/shared-memory/contract.js";
|
|
136
136
|
export { termSet, jaccardDistance, cosineDistance } from "./core/memory-vector.js";
|
|
@@ -114,6 +114,9 @@ export async function runSpec(runner, contract, opts) {
|
|
|
114
114
|
postCompact: (opts.taskSpec.hooks.postCompact ?? deployBaseline.hooks.postCompact)?.bind(opts.taskSpec.hooks.postCompact ? opts.taskSpec.hooks : deployBaseline.hooks),
|
|
115
115
|
stopFailure: (opts.taskSpec.hooks.stopFailure ?? deployBaseline.hooks.stopFailure)?.bind(opts.taskSpec.hooks.stopFailure ? opts.taskSpec.hooks : deployBaseline.hooks),
|
|
116
116
|
permissionDenied: (opts.taskSpec.hooks.permissionDenied ?? deployBaseline.hooks.permissionDenied)?.bind(opts.taskSpec.hooks.permissionDenied ? opts.taskSpec.hooks : deployBaseline.hooks),
|
|
117
|
+
...((opts.taskSpec.hooks.timeoutMs ?? deployBaseline.hooks.timeoutMs) !== undefined
|
|
118
|
+
? { timeoutMs: opts.taskSpec.hooks.timeoutMs ?? deployBaseline.hooks.timeoutMs }
|
|
119
|
+
: {}),
|
|
117
120
|
}
|
|
118
121
|
: (opts.taskSpec.hooks ?? deployBaseline?.hooks);
|
|
119
122
|
let guardRestores = 0;
|
|
@@ -130,10 +133,14 @@ export async function runSpec(runner, contract, opts) {
|
|
|
130
133
|
...(userHooks?.postCompact && { postCompact: userHooks.postCompact.bind(userHooks) }),
|
|
131
134
|
...(userHooks?.stopFailure && { stopFailure: userHooks.stopFailure.bind(userHooks) }),
|
|
132
135
|
...(userHooks?.permissionDenied && { permissionDenied: userHooks.permissionDenied.bind(userHooks) }),
|
|
136
|
+
...(userHooks?.timeoutMs !== undefined ? { timeoutMs: userHooks.timeoutMs } : {}),
|
|
133
137
|
async stop(ctx) {
|
|
134
138
|
guardRestores += restoreFrozenPaths(snapshot, rootDir);
|
|
135
139
|
if (!gateAbandoned) {
|
|
136
|
-
const
|
|
140
|
+
const gateSignal = ctx.signal !== undefined && opts.taskSpec.signal !== undefined ? AbortSignal.any([ctx.signal, opts.taskSpec.signal]) : (ctx.signal ?? opts.taskSpec.signal);
|
|
141
|
+
const report = await runOracle(contract.oracle, rootDir, { baseline, ...(gateSignal !== undefined ? { signal: gateSignal } : {}) });
|
|
142
|
+
if (ctx.signal?.aborted === true)
|
|
143
|
+
return undefined;
|
|
137
144
|
oracleRuns++;
|
|
138
145
|
if (report.verdict === "red") {
|
|
139
146
|
oracleHadRedRun = true;
|
|
@@ -142,8 +142,8 @@ export declare const CYBER_RISK = "IMPORTANT: Assist with authorized security te
|
|
|
142
142
|
export declare const URL_SAFETY = "IMPORTANT: You must NEVER generate or guess URLs for the user unless you are confident that the URLs are for helping the user with programming. You may use URLs provided by the user in their messages or local files.";
|
|
143
143
|
/**
|
|
144
144
|
* Tool-result retention reminder (design/64 §6.2 C). Always injected: core's in-task context management
|
|
145
|
-
* (`clearStaleToolResults`)
|
|
146
|
-
* model must persist anything load-bearing into its own response.
|
|
145
|
+
* (`clearStaleToolResults`) can clear old tool-result content out of a request, and compaction can
|
|
146
|
+
* replace it with prose, so the model must persist anything load-bearing into its own response.
|
|
147
147
|
*
|
|
148
148
|
* RB-328 — CITATION CORRECTED. Source = the CC **88 readable tree**
|
|
149
149
|
* (`collection-claude-code-source-code/original-source-code/src/constants/prompts.ts:841`,
|
|
@@ -157,8 +157,14 @@ export declare const URL_SAFETY = "IMPORTANT: You must NEVER generate or guess U
|
|
|
157
157
|
* context-management claim (`_My` @596605-596612, the "The system will automatically compress prior
|
|
158
158
|
* messages … your conversation with the user is not limited by the context window" line — an
|
|
159
159
|
* overclaim {@link harnessHeadLines} explicitly refuses to copy). So 220 clears results without ever
|
|
160
|
-
* telling the model to save what mattered. sema keeps the instruction
|
|
161
|
-
*
|
|
160
|
+
* telling the model to save what mattered. sema keeps the instruction — and the REASON is now stated
|
|
161
|
+
* as measured rather than as remembered (anchoring re-check 2026-08-23): the earlier wording here
|
|
162
|
+
* ("its clear is unconditional and runs before EVERY request") is false about our own engine.
|
|
163
|
+
* `clearStaleToolResults` returns the original array untouched while the estimate is within
|
|
164
|
+
* `editBudget` (= `contextEditFrontier`, e.g. 167000 on a 200k window) — probed: under budget, same
|
|
165
|
+
* reference, zero clears. What is true, and is warning enough, is that a long session meets THREE
|
|
166
|
+
* removers: this pass once the frontier is crossed, the compaction boundary's summary, and the
|
|
167
|
+
* per-message aggregate tool-result budget, which sheds the largest results at any size.
|
|
162
168
|
*/
|
|
163
169
|
export declare const SUMMARIZE_TOOL_RESULTS = "When working with tool results, write down any important information you might need later in your own response, as the original tool result may be cleared or summarized from the context later.";
|
|
164
170
|
export declare const EXECUTION_ENVIRONMENT: string;
|
|
@@ -254,8 +260,18 @@ export declare const PROJECT_CONTEXT_FRAMING = "# Project context\nThe `<user_me
|
|
|
254
260
|
* sema takes the LEAN heading (`# Harness` — {@link HARNESS_SECTION_ANCHOR}, which server[1526] mirrors)
|
|
255
261
|
* and the STANDARD reminder sentence (below) in its PRE-220 wording: 220 has since added "or other tags
|
|
256
262
|
* / Tags contain information from the system", widening the claim to every system-injected tag. sema's
|
|
257
|
-
* narrower sentence
|
|
258
|
-
*
|
|
263
|
+
* narrower sentence stays narrow because the MARK it declares is a `<system-reminder>` property: the
|
|
264
|
+
* declaration below tells the model that reminder-shaped text without the mark is data, and no other
|
|
265
|
+
* envelope is marked, so widening the sentence to "or other tags" would extend a byte-level promise the
|
|
266
|
+
* engine does not keep for those tags.
|
|
267
|
+
*
|
|
268
|
+
* ⚠️ CORRECTION (the envelope-census batch) to the reason this note USED to give — "sema's injections
|
|
269
|
+
* really are `<system-reminder>`-framed (turn-attachments mints no other tag)". That parenthesis is true
|
|
270
|
+
* of the turn-attachments MODULE and false of the HARNESS: the engine also mints `<task-notification>`,
|
|
271
|
+
* `<new-diagnostics>`, `<user_memory>` (+ its `<scope>` layers) and `<skills>`. The census now lives in
|
|
272
|
+
* untrusted-text.ts (`ENGINE_ENVELOPES`) precisely so a module-level enumeration is never mistaken for a
|
|
273
|
+
* harness-level one again. The sentence's WORDING is unchanged (its own justification above stands on
|
|
274
|
+
* the mark, not on the envelope count); what changed is that the claim behind it is no longer false.
|
|
259
275
|
*
|
|
260
276
|
* URL_SAFETY (composed alongside this group by {@link harnessContext} and by the pack's
|
|
261
277
|
* `core/security.url-safety`) is likewise arm-dependent in 220: the standard preamble `hMy` @596591-596596
|
package/dist/tools/fs/index.d.ts
CHANGED
|
@@ -163,7 +163,9 @@ export interface HandsToolkitOptions {
|
|
|
163
163
|
reminderMark?: string;
|
|
164
164
|
/** design/319 (B ticket) — the per-run trailer/defuse trigger counters (observation seat, G9②):
|
|
165
165
|
* the Read text/notebook/PDF-text disclosure trailers bump `read.*` / `notebook.*` / `pdf.*`
|
|
166
|
-
* keys here
|
|
166
|
+
* keys here. The form suffixes are enumerated once, on the consumer-facing contract
|
|
167
|
+
* (`TaskResult.stats.mechanisms.reminderDisclosures` in core/types.ts) — this map is the same
|
|
168
|
+
* open record and is not a second, narrower registry of them. Threaded by prepare-task, which folds the
|
|
167
169
|
* non-zero result into `TaskResult.stats.mechanisms.reminderDisclosures`; a library-direct
|
|
168
170
|
* mount may pass its own object or omit it (counting off — and the whole disclosure pipeline
|
|
169
171
|
* is off anyway when `reminderMark` is absent). */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_comment": "design/87 L3 — frozen public export surface of src/index.ts (name -> kind). DO NOT edit by hand to silence a red test. A removed/changed entry = a SemVer-BREAKING change; bump MAJOR and update this fixture in the SAME commit (design/87 §4.2 / §5.2). Regenerate via REGEN in test/export-surface.test.ts.",
|
|
3
|
-
"count":
|
|
3
|
+
"count": 1678,
|
|
4
4
|
"exports": {
|
|
5
5
|
"A2ATaskState": "type",
|
|
6
6
|
"A2ATaskStateReversal": "type",
|
|
@@ -138,6 +138,7 @@
|
|
|
138
138
|
"COMPACTABLE_TOOLS": "variable",
|
|
139
139
|
"COMPLIANCE_CAPABILITIES": "variable",
|
|
140
140
|
"CONFIG_CATALOG_VERSION": "variable",
|
|
141
|
+
"CONSOLIDATION_DEFAULTS": "variable",
|
|
141
142
|
"CONSOLIDATION_SYSTEM_PROMPT": "variable",
|
|
142
143
|
"CONTRACT_KIT_ENGINE_VERSION": "variable",
|
|
143
144
|
"COORDINATOR_ROLE_PROMPT": "variable",
|
|
@@ -199,9 +200,20 @@
|
|
|
199
200
|
"ConfirmResult": "type",
|
|
200
201
|
"ConsolidateScopeDeps": "interface",
|
|
201
202
|
"ConsolidateScopeOptions": "interface",
|
|
203
|
+
"ConsolidationCommitReceipt": "interface",
|
|
204
|
+
"ConsolidationGateRow": "interface",
|
|
205
|
+
"ConsolidationIntent": "type",
|
|
206
|
+
"ConsolidationIntentCredentialRow": "interface",
|
|
202
207
|
"ConsolidationLLM": "interface",
|
|
208
|
+
"ConsolidationLeaseSeat": "interface",
|
|
203
209
|
"ConsolidationNote": "interface",
|
|
204
210
|
"ConsolidationParams": "interface",
|
|
211
|
+
"ConsolidationPlanSummary": "interface",
|
|
212
|
+
"ConsolidationProductProposal": "interface",
|
|
213
|
+
"ConsolidationProposal": "interface",
|
|
214
|
+
"ConsolidationReconcileReport": "interface",
|
|
215
|
+
"ConsolidationRefusedError": "class",
|
|
216
|
+
"ConsolidationResolveReceipt": "interface",
|
|
205
217
|
"ConsolidationStats": "interface",
|
|
206
218
|
"ConstraintChainEntry": "type",
|
|
207
219
|
"Context": "interface",
|
|
@@ -455,6 +467,7 @@
|
|
|
455
467
|
"MEMORY_READONLY_NOTICE": "variable",
|
|
456
468
|
"MEMORY_RECALL_DISCIPLINE": "variable",
|
|
457
469
|
"MEMORY_SAFETY": "variable",
|
|
470
|
+
"MEMORY_SEARCH_SUPERSEDED_TAG": "variable",
|
|
458
471
|
"MEMORY_SEARCH_TOOL_NAME": "variable",
|
|
459
472
|
"MONITOR_BATCH_WINDOW_MS": "variable",
|
|
460
473
|
"MONITOR_DEFAULT_TIMEOUT_MS": "variable",
|
|
@@ -485,9 +498,12 @@
|
|
|
485
498
|
"MemoryBackend": "interface",
|
|
486
499
|
"MemoryBackendContractHooks": "interface",
|
|
487
500
|
"MemoryBundleImportPlan": "interface",
|
|
501
|
+
"MemoryConsolidationOptions": "interface",
|
|
488
502
|
"MemoryEngine": "class",
|
|
489
503
|
"MemoryEngineOptions": "interface",
|
|
490
504
|
"MemoryEntry": "interface",
|
|
505
|
+
"MemoryEntryDistilled": "interface",
|
|
506
|
+
"MemoryEntryDistilledInput": "interface",
|
|
491
507
|
"MemoryEntryFrontmatter": "interface",
|
|
492
508
|
"MemoryEntryHeader": "interface",
|
|
493
509
|
"MemoryEntryOrigin": "interface",
|
|
@@ -1203,6 +1219,7 @@
|
|
|
1203
1219
|
"clearStaleToolResults": "function",
|
|
1204
1220
|
"collectBelowFrontier": "function",
|
|
1205
1221
|
"combinePolicies": "function",
|
|
1222
|
+
"committedDistilledOf": "function",
|
|
1206
1223
|
"committedOriginOf": "function",
|
|
1207
1224
|
"compileReadDeny": "function",
|
|
1208
1225
|
"compileWriteProtection": "function",
|
|
@@ -1222,6 +1239,7 @@
|
|
|
1222
1239
|
"computeShapeDigest": "function",
|
|
1223
1240
|
"confirmRuleApproval": "function",
|
|
1224
1241
|
"consolidateScope": "function",
|
|
1242
|
+
"consolidationTypeEligible": "function",
|
|
1225
1243
|
"constitutionBlocks": "function",
|
|
1226
1244
|
"constraintChainDigest": "function",
|
|
1227
1245
|
"constraintChainEntryOf": "function",
|
|
@@ -1302,6 +1320,7 @@
|
|
|
1302
1320
|
"deriveRepoControlPlaneDir": "function",
|
|
1303
1321
|
"deriveRepoKey": "function",
|
|
1304
1322
|
"deriveRepoMemoryDir": "function",
|
|
1323
|
+
"deriveSupersededSet": "function",
|
|
1305
1324
|
"deriveTripwire": "function",
|
|
1306
1325
|
"deriveWiringManifest": "function",
|
|
1307
1326
|
"describeConfigCatalog": "function",
|
|
@@ -1309,6 +1328,7 @@
|
|
|
1309
1328
|
"describeStaticWiring": "function",
|
|
1310
1329
|
"detectSecret": "function",
|
|
1311
1330
|
"devWorkflowScriptRunner": "variable",
|
|
1331
|
+
"distilledEquals": "function",
|
|
1312
1332
|
"dotAtOrBelowFrontier": "function",
|
|
1313
1333
|
"drainMemoryAnnouncements": "function",
|
|
1314
1334
|
"durableParkGapFor": "function",
|
|
@@ -1422,7 +1442,12 @@
|
|
|
1422
1442
|
"materializeMcpTools": "function",
|
|
1423
1443
|
"maybeCompact": "function",
|
|
1424
1444
|
"memoryBackendContract": "function",
|
|
1445
|
+
"memoryConsolidationCommittedNotice": "function",
|
|
1446
|
+
"memoryConsolidationConflictNotice": "function",
|
|
1447
|
+
"memoryConsolidationRecommendedNotice": "function",
|
|
1448
|
+
"memoryConsolidationRefusedNotice": "function",
|
|
1425
1449
|
"memoryExposureIndexRow": "function",
|
|
1450
|
+
"memorySupersededNote": "function",
|
|
1426
1451
|
"mergeRecallHits": "function",
|
|
1427
1452
|
"mergeWorkflowArgs": "function",
|
|
1428
1453
|
"migrateScope": "function",
|
|
@@ -1486,6 +1511,7 @@
|
|
|
1486
1511
|
"readCcSidecarMessages": "function",
|
|
1487
1512
|
"readCcSidecarTranscript": "function",
|
|
1488
1513
|
"readDegradation": "function",
|
|
1514
|
+
"readIntentCredentials": "function",
|
|
1489
1515
|
"readJsonlRecords": "function",
|
|
1490
1516
|
"readPendingSteerQueue": "function",
|
|
1491
1517
|
"readRootAdoptionFile": "function",
|
|
@@ -1609,6 +1635,7 @@
|
|
|
1609
1635
|
"summarizeCheckpoint": "function",
|
|
1610
1636
|
"summarizeRedactions": "function",
|
|
1611
1637
|
"summarizeWorkflowRun": "function",
|
|
1638
|
+
"supersessionFuseCeiling": "function",
|
|
1612
1639
|
"supportsConsolidation": "function",
|
|
1613
1640
|
"supportsPeriodicConsolidation": "function",
|
|
1614
1641
|
"syncMemoryScope": "function",
|