@sema-agent/core 7.57.0 → 7.58.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 +385 -0
- package/dist/agents/subagent-steps.js +2 -4
- package/dist/brain/route-adjudicator.js +2 -1
- package/dist/core/a2a.d.ts +2 -1
- package/dist/core/a2a.js +23 -10
- package/dist/core/allow-entry.d.ts +2 -1
- package/dist/core/allow-entry.js +2 -1
- package/dist/core/ask-origin.d.ts +21 -2
- package/dist/core/ask-origin.js +5 -1
- package/dist/core/auto-compaction.d.ts +4 -0
- package/dist/core/auto-compaction.js +1 -1
- package/dist/core/auto-mode-directive.d.ts +29 -5
- package/dist/core/auto-mode-directive.js +38 -8
- package/dist/core/checkpoint-requirements.d.ts +7 -1
- package/dist/core/checkpoint-requirements.js +2 -0
- package/dist/core/checkpoint-store.d.ts +27 -11
- package/dist/core/checkpoint-store.js +13 -3
- package/dist/core/engine-notice.d.ts +1 -1
- package/dist/core/fs-write-gate-policy.d.ts +4 -2
- package/dist/core/fs-write-gate-policy.js +7 -3
- package/dist/core/gate-fold.js +6 -3
- package/dist/core/gate-lanes.js +11 -2
- package/dist/core/git-worktree-env.d.ts +53 -11
- package/dist/core/git-worktree-env.js +96 -12
- package/dist/core/hooks.d.ts +4 -1
- package/dist/core/hooks.js +12 -5
- package/dist/core/human-input-projection.d.ts +1 -0
- package/dist/core/human-input-projection.js +3 -0
- package/dist/core/locked-config.d.ts +15 -1
- package/dist/core/locked-config.js +38 -2
- package/dist/core/mcp-call-meta.d.ts +66 -0
- package/dist/core/mcp-call-meta.js +103 -0
- package/dist/core/mcp-connection-pool.d.ts +3 -1
- package/dist/core/mcp-connection-pool.js +3 -1
- package/dist/core/mcp-failure.d.ts +7 -1
- package/dist/core/mcp-failure.js +10 -0
- package/dist/core/mcp-probe.d.ts +4 -0
- package/dist/core/mcp-probe.js +1 -1
- package/dist/core/mcp-server-link.d.ts +5 -2
- package/dist/core/mcp-server-spec.d.ts +46 -18
- package/dist/core/mcp-server-spec.js +1 -18
- package/dist/core/mcp.d.ts +6 -14
- package/dist/core/mcp.js +77 -37
- package/dist/core/memory-engine/scope-contract.d.ts +45 -4
- package/dist/core/memory-engine/scope-contract.js +80 -11
- package/dist/core/mode-policy.d.ts +8 -5
- package/dist/core/mode-policy.js +5 -4
- package/dist/core/mods/host.js +1 -1
- package/dist/core/mods/kernel/dispatch.d.ts +3 -0
- package/dist/core/mods/kernel/dispatch.js +10 -8
- package/dist/core/mods/kernel/events.d.ts +5 -1
- package/dist/core/mods/kernel/events.js +1 -1
- package/dist/core/mods/kernel/registration.d.ts +5 -1
- package/dist/core/mods/kernel/site-rules.d.ts +3 -0
- package/dist/core/mods/kernel/site-rules.js +10 -0
- package/dist/core/mods/package.d.ts +23 -0
- package/dist/core/mods/package.js +118 -0
- package/dist/core/mods/stations.d.ts +2 -2
- package/dist/core/mods/stations.js +1 -1
- package/dist/core/mods/tool-call.d.ts +5 -1
- package/dist/core/mods/tool-call.js +12 -3
- package/dist/core/path-guard-rows.d.ts +20 -0
- package/dist/core/path-guard-rows.js +11 -0
- package/dist/core/peer-seat.d.ts +186 -0
- package/dist/core/peer-seat.js +307 -0
- package/dist/core/present-plan-tool.d.ts +10 -1
- package/dist/core/present-plan-tool.js +46 -2
- package/dist/core/protocol-http-auth.d.ts +40 -29
- package/dist/core/protocol-http-auth.js +30 -32
- package/dist/core/redaction-marks.d.ts +16 -0
- package/dist/core/redaction-marks.js +16 -0
- package/dist/core/redaction-passes.js +8 -9
- package/dist/core/retention.d.ts +41 -15
- package/dist/core/retention.js +59 -12
- package/dist/core/rewrite-rejudge.d.ts +37 -0
- package/dist/core/rewrite-rejudge.js +40 -0
- package/dist/core/run-origin.d.ts +40 -0
- package/dist/core/run-origin.js +37 -0
- package/dist/core/runner/advertised-writable-dirs.d.ts +57 -38
- package/dist/core/runner/advertised-writable-dirs.js +126 -0
- package/dist/core/runner/compaction-restate.d.ts +15 -6
- package/dist/core/runner/compaction-restate.js +28 -2
- package/dist/core/runner/contracts.d.ts +13 -5
- package/dist/core/runner/gate-exit.d.ts +18 -4
- package/dist/core/runner/gate-exit.js +5 -1
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +2 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +1 -1
- package/dist/core/runner/prepare-config-doors.d.ts +8 -5
- package/dist/core/runner/prepare-config-doors.js +12 -10
- package/dist/core/runner/prepare-delegation-surface.d.ts +4 -0
- package/dist/core/runner/prepare-delegation-surface.js +15 -18
- package/dist/core/runner/prepare-gate-stations.js +1 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +7 -3
- package/dist/core/runner/prepare-hands-readface.js +4 -1
- package/dist/core/runner/prepare-memory.d.ts +3 -0
- package/dist/core/runner/prepare-memory.js +19 -23
- package/dist/core/runner/prepare-policy-chain.d.ts +4 -4
- package/dist/core/runner/prepare-policy-chain.js +2 -2
- package/dist/core/runner/prepare-protocol-tools.d.ts +4 -2
- package/dist/core/runner/prepare-protocol-tools.js +3 -3
- package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
- package/dist/core/runner/prepare-suspend-saga.js +2 -1
- package/dist/core/runner/prepare-task.js +25 -12
- package/dist/core/runner/prepare-wiring-manifest.d.ts +1 -0
- package/dist/core/runner/prepare-wiring-manifest.js +2 -2
- package/dist/core/runner/prepare-workspace-restore.d.ts +3 -0
- package/dist/core/runner/prepare-workspace-restore.js +4 -4
- package/dist/core/runner/resume-admission.js +1 -1
- package/dist/core/runner/resume-checkpoint-screen.js +2 -0
- package/dist/core/runner/run-harness-handlers.d.ts +3 -4
- package/dist/core/runner/run-harness-handlers.js +1 -8
- package/dist/core/runner/run-identity-wiring.js +1 -0
- package/dist/core/runner/run-leg.js +5 -1
- package/dist/core/runner/run-notification-lane.js +3 -0
- package/dist/core/runner/terminal-account.js +3 -3
- package/dist/core/runner/tool-end-body.js +1 -0
- package/dist/core/runner/tool-occurrence.d.ts +4 -1
- package/dist/core/runner/tool-occurrence.js +2 -1
- package/dist/core/runner/write-protection-station.d.ts +8 -2
- package/dist/core/runner/write-protection-station.js +2 -0
- package/dist/core/runner-deps.d.ts +2 -2
- package/dist/core/sensitive-path-policy.js +6 -7
- package/dist/core/session-log-transfer.d.ts +24 -0
- package/dist/core/session-log-transfer.js +166 -0
- package/dist/core/session-store.d.ts +84 -19
- package/dist/core/session-store.js +162 -24
- package/dist/core/session.d.ts +92 -1
- package/dist/core/shell-read-silence.js +1 -0
- package/dist/core/steer-replay.d.ts +4 -2
- package/dist/core/steer-replay.js +2 -1
- package/dist/core/store-contracts/checkpoint-store-contract.js +17 -0
- package/dist/core/store-contracts/session-repo-contract.js +112 -5
- package/dist/core/store-contracts/session-store-contract.d.ts +4 -1
- package/dist/core/store-contracts/session-store-contract.js +236 -2
- package/dist/core/task-event.d.ts +68 -8
- package/dist/core/task-registry-shared.d.ts +2 -1
- package/dist/core/task-spec.d.ts +37 -0
- package/dist/core/task-stream.d.ts +2 -1
- package/dist/core/terminal-cause.d.ts +1 -1
- package/dist/core/tool-catalog-entries.js +1 -0
- package/dist/core/tool-result-store.d.ts +17 -10
- package/dist/core/tool-result-store.js +3 -1
- package/dist/core/types.d.ts +1 -1
- package/dist/core/untrusted-egress.d.ts +0 -2
- package/dist/core/untrusted-egress.js +10 -14
- package/dist/core/wiring-manifest.d.ts +12 -3
- package/dist/core/wiring-manifest.js +4 -3
- package/dist/core/workspace-snapshot.d.ts +44 -0
- package/dist/core/workspace-snapshot.js +34 -0
- package/dist/core/write-protect.d.ts +43 -3
- package/dist/core/write-protect.js +43 -16
- package/dist/engine/execution-env/node-execution-env.js +15 -11
- package/dist/engine/execution-env/symlink-chain.d.ts +7 -5
- package/dist/engine/harness/agent-harness.d.ts +5 -0
- package/dist/engine/harness/agent-harness.js +2 -0
- package/dist/engine/harness/types.d.ts +48 -7
- package/dist/engine/harness/types.js +5 -1
- package/dist/engine/llm/types.d.ts +12 -3
- package/dist/engine/llm/types.js +1 -1
- package/dist/engine/session/import-validate.js +3 -0
- package/dist/engine/session/memory-repo.d.ts +17 -9
- package/dist/engine/session/memory-repo.js +44 -34
- package/dist/engine/session/repo-utils.d.ts +22 -4
- package/dist/engine/session/repo-utils.js +49 -1
- package/dist/engine/session/storage-base.d.ts +10 -1
- package/dist/engine/session/storage-base.js +7 -1
- package/dist/index.d.ts +13 -6
- package/dist/index.js +10 -4
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +2 -2
- package/dist/internal/harness.js +2 -2
- package/dist/stores/file/index.d.ts +4 -1
- package/dist/stores/file/index.js +4 -1
- package/dist/stores/file/session-store.d.ts +15 -8
- package/dist/stores/file/session-store.js +28 -13
- package/dist/tools/fs/fs-write.d.ts +6 -3
- package/dist/tools/fs/fs-write.js +8 -7
- package/dist/tools/fs/index.d.ts +3 -0
- package/dist/tools/fs/index.js +1 -1
- package/dist/tools/fs/safety.js +40 -8
- package/dist/tools/fs/search.js +6 -24
- package/dist/tools/fs/shell-read-check.d.ts +8 -1
- package/dist/tools/fs/shell-read-check.js +59 -15
- package/dist/tools/fs/shell-read-establish.js +2 -1
- package/dist/tools/fs/shell-read-identity.js +1 -1
- package/dist/tools/fs/shell-read-judge.d.ts +10 -1
- package/dist/tools/worktree.d.ts +42 -15
- package/dist/tools/worktree.js +60 -32
- package/package.json +4 -2
- package/test/export-surface.snapshot.json +63 -1
- package/wire-changes/core-stores-sql@7.58.0.json +29 -0
- package/wire-changes/core@7.58.0.json +2188 -0
- package/wire-changes/mods-kernel@7.58.0.json +81 -0
- package/wire-changes/primitives@7.58.0.json +29 -0
- package/dist/primitives/credential-ref.d.ts +0 -89
- package/dist/primitives/credential-ref.js +0 -125
- package/dist/primitives/index.d.ts +0 -2
- package/dist/primitives/index.js +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ export { runCascade, type CascadeRung, type CascadeConfig, type CascadeAttempt,
|
|
|
61
61
|
export { pgQuery, mysqlQuery, sqliteQuery } from "./tools/sql-adapters.js";
|
|
62
62
|
export { materializeMcpTools, MCP_PREFIX, type MaterializedMcp, type McpServerStatus, type McpRefreshResult, type McpReconnectResult } from "./core/mcp.js";
|
|
63
63
|
export { mcpStartupTimeoutMs } from "./core/mcp.js";
|
|
64
|
+
export { judgeSessionMetaKey, MCP_SESSION_META_KEY_MAX_CHARS, type SessionMetaKeyReading } from "./core/mcp-call-meta.js";
|
|
64
65
|
export { McpConnectionPool } from "./core/mcp-connection-pool.js";
|
|
65
66
|
export { probeMcpServers, type McpProbeResult } from "./core/mcp-probe.js";
|
|
66
67
|
export { judgeMcpNames, describeMcpNameConflict, type McpNameConflict, type McpNameSetServer, type McpNameVerdict } from "./core/mcp-name-judge.js";
|
|
@@ -87,12 +88,12 @@ export { createSessionRulePolicy } from "./core/runner/session-rule-policy.js";
|
|
|
87
88
|
export { LOCKED_KEY_REGISTRY, resolveLockedKeys, type LockedKey, type LockedConfig } from "./core/locked-config.js";
|
|
88
89
|
export { BUILTIN_COMPLIANCE_DENIES, COMPLIANCE_CAPABILITIES, WEB_FETCH_TOOL_NAME, complianceCallDenial, resolveComplianceDenies, type ComplianceCapability, type CompliancePosture, type ComplianceProfile, } from "./core/compliance.js";
|
|
89
90
|
export { admitMemoryScopes, foldAdmissionFreeze, type OwnOrgAdmissionVerdict, type MemoryAdmissionInput, type MemoryAdmissionOutcome, type MemoryAdmissionVerdict, type MemoryScopeAdmission, type MemoryScopeOrigin, type MemoryScopeRequest, } from "./core/memory-admission.js";
|
|
90
|
-
export { assertRetentionCapability, RETENTION_CASCADE_DOMAINS, RETENTION_CASCADE_EXEMPT, type ManagedRetentionCapability, type RetentionDeclaration, type RetentionDeclaring, type RetentionPolicy, type RetentionReceipt, } from "./core/retention.js";
|
|
91
|
+
export { assertRetentionCapability, readRetentionDeclaration, RETENTION_CASCADE_DOMAINS, RETENTION_CASCADE_EXEMPT, type ManagedRetentionCapability, type RetentionDeclaration, type RetentionDeclaring, type RetentionPolicy, type RetentionReceipt, } from "./core/retention.js";
|
|
91
92
|
export { GOVERNANCE_CODES, governanceRetryClass, TOOL_DECLARATION_CODES, type GovernanceCode, type GovernanceRetryClass, type ToolDeclarationCode } from "./core/governance-codes.js";
|
|
92
93
|
export { NOTICE_AUDIENCE, noticeAudienceOf, ENGINE_NOTICE_CODES, NOTICE_MINTER, type EngineNoticeCode, type NoticeAudience, type NoticeMinter } from "./core/governance-codes.js";
|
|
93
94
|
export { TtlSessionStore, type TtlSessionStoreOptions, type EvictPolicy } from "./core/session-store.js";
|
|
94
95
|
export { reconcileInterruptedSession, findOrphanToolCalls, type OrphanToolCall, type ReconcileReport, } from "./core/session-reconcile.js";
|
|
95
|
-
export { StoredSession, InMemorySessionRepo, InMemorySessionStorage, BaseSessionStorage, leafIdAfterEntry, validateEntriesForImport, StreamingImportValidator, boundedTail, SessionError, isSessionConflict, hasSessionFork, uuidv7, readSessionListQuery, SESSION_LIST_LIMITS, type Session, type SessionStore, type AcquiredSession, type SessionStoreSummary, type SessionListQuery, type SessionListQueryReading, type SessionStorage, type SessionRepo, type SessionRow, type SessionMetadata, type SessionTreeEntry, type SessionWriteOptions, type SessionPlacement, type SessionPlacementRecord, type PlacedSessionRow, type SessionHead, } from "./core/session.js";
|
|
96
|
+
export { StoredSession, InMemorySessionRepo, InMemorySessionStorage, BaseSessionStorage, leafIdAfterEntry, validateEntriesForImport, StreamingImportValidator, boundedTail, SessionError, isSessionConflict, hasSessionFork, uuidv7, readSessionListQuery, SESSION_LIST_LIMITS, type Session, type SessionStore, type AcquiredSession, type SessionStoreSummary, type SessionListQuery, type SessionListQueryReading, type SessionStorage, type SessionRepo, type SessionRow, type SessionMetadata, type SessionTreeEntry, type SessionWriteOptions, type SessionPlacement, type SessionPlacementRecord, type PlacedSessionRow, type SessionHead, type SessionLogTransfer, type SessionLogExportOptions, type SessionLogReplace, type SessionLogCommit, type SessionLogCommitView, type SessionStoreHooks, type SessionRowExpectation, type SessionRowRead, type SessionLogMark, } from "./core/session.js";
|
|
96
97
|
export { warmResume } from "./core/warm-resume.js";
|
|
97
98
|
export { StubExecutionEnv } from "./core/stub-env.js";
|
|
98
99
|
export { NodeExecutionEnv, FileError, ExecutionError } from "./internal/harness.js";
|
|
@@ -188,13 +189,14 @@ export { type ToolCallIdentity } from "./core/fs-write-gate-policy.js";
|
|
|
188
189
|
export { type RuleFaceView, catalogRuleFaceView } from "./core/permission-rules.js";
|
|
189
190
|
export { DURABLE_HISTORY_NAMES } from "./engine/compaction/utils.js";
|
|
190
191
|
export { describeStaticWiring, deriveWiringManifest, deriveAskEffective, resolveDeclaredDurability, resolveSubagentTranscriptTier, type SubagentTranscriptTier, resolveAskSeamForm, resolveQuestionSeam, countElicitOptIns, AUTO_MODE_ARM_REASONS, type AutoModeArmReason, type AutoModeArmFact, type WiringManifest, type WiringManifestMcpEntry, LSP_LANES, type LspLane, type WiringFacts, type WiringLegKind, type AskSeamForm, APPROVAL_REACH, type ApprovalReach, isApprovalReach, type AskEffective, type QuestionChannelState, type SeamProvenance, type ParkLaneReason, type ManifestDurability, type StaticWiringDeps, type StaticWiringSpec, } from "./core/wiring-manifest.js";
|
|
192
|
+
export { RUN_ORIGINS, type RunOrigin, isRunOrigin } from "./core/run-origin.js";
|
|
191
193
|
export { probeParkRoundTrip, durableParkGapOf, durableParkGapFor, PARK_SELFCHECK_SCOPE_PREFIX, type ParkSelfCheckResult, type ParkProbeFinding, type ParkProbeFindingCode, } from "./core/park-selfcheck.js";
|
|
192
194
|
export { type StoreDurability } from "./core/checkpoint-store.js";
|
|
193
195
|
export { type StoreFidelity } from "./core/checkpoint-store.js";
|
|
194
196
|
export { projectHumanInput, buildHumanInputEvent, type HumanInputSource, type HumanInputFrame, type HumanInputEvent, type HumanInputDelivery, } from "./core/human-input-projection.js";
|
|
195
197
|
export { USER_ATTACHMENT_SEAT, USER_ATTACHMENT_KINDS, USER_ATTACHMENT_SUPPLIES, USER_ATTACHMENT_OUTCOMES, USER_ATTACHMENTS_MAX, USER_ATTACHMENT_LABEL_MAX, type UserAttachmentDeclaration, } from "./core/user-attachment.js";
|
|
196
198
|
export type { HumanInputAttachment } from "./core/types.js";
|
|
197
|
-
export { TaskRegistry, defaultTaskRegistry, createTaskOutputTool, createTaskStopTool, type SemaTaskType, type SemaTaskStatus, type SemaTaskHandle, type ParkedClaimTicket, type TaskAccess, type UnifiedTaskOutput, type TaskRetrievalStatus, type StopSource, type RegisterMonitorInput, type MonitorTimers, MONITOR_BATCH_WINDOW_MS, MONITOR_DEFAULT_TIMEOUT_MS, MONITOR_MAX_TIMEOUT_MS, MONITOR_MAX_BATCHES_PER_MINUTE, canAccessWorkflowRun, DURABLE_AGENT_HANDLE_RE, engineAgentName, type BackgroundShellHardKillReceipt, } from "./core/task-registry.js";
|
|
199
|
+
export { TaskRegistry, defaultTaskRegistry, createTaskOutputTool, createTaskStopTool, type SemaTaskType, type SemaTaskStatus, type SemaTaskHandle, type ParkedClaimTicket, type TaskAccess, type UnifiedTaskOutput, type TaskRetrievalStatus, type StopSource, type RegisterMonitorInput, type MonitorTimers, MONITOR_BATCH_WINDOW_MS, MONITOR_DEFAULT_TIMEOUT_MS, MONITOR_MAX_TIMEOUT_MS, MONITOR_MAX_BATCHES_PER_MINUTE, canAccessWorkflowRun, DURABLE_AGENT_HANDLE_RE, engineAgentName, chosenAgentName, type BackgroundShellHardKillReceipt, } from "./core/task-registry.js";
|
|
198
200
|
export { InMemoryMailboxStore, type MailboxStore, type MailboxMessage, type MailboxLease, MailboxStoreError, type MailboxStoreErrorCode, MAILBOX_TOMBSTONED_RECIPIENT_CODE, type MailboxAppendMessage, type MailboxPeerMeta, type MailboxPeerFromMode, type MailboxPeerRecordKind, type MailboxPeerNoticeMeta, type MailboxPeerNoticeState, MAILBOX_PEER_NOTICE_STATES, MAILBOX_PEER_FROM_MODES, MAILBOX_PEER_RECORD_KINDS, MAILBOX_INVALID_PEER_META_CODE, MAILBOX_CROSS_PROCESS_UNSAFE_CODE, readMailboxPeerMeta, mailboxCrossProcessMountVerdict, type MailboxCrossProcessVerdict, type MailboxAckResult, type MailboxDecision, type MailboxDecisionOutcome, MAILBOX_DECISIONS, MAILBOX_INVALID_DECISION_MOVE_CODE, isMailboxDecision, isMailboxDecisionFinal, isMailboxDecisionDeliverable, mailboxDecisionEdgeAllowed, assertMailboxDecisionMove, moveMailboxDecision, readStoredMailboxDecision, } from "./core/mailbox-store.js";
|
|
199
201
|
export { FileMailboxStore, type FileMailboxStoreOptions } from "./stores/file/mailbox-store.js";
|
|
200
202
|
export { createFileTaskListStore } from "./stores/file/task-list-store.js";
|
|
@@ -283,7 +285,8 @@ export type { ClassicEventMap, ClassicEventName, ObservedAnswer, EngineModRegist
|
|
|
283
285
|
export { KERNEL_CONTRACT_VERSION, MOD_TIERS, MOD_SEATS, MOD_EVENT_SIDES, MOD_EVENT_TABLE, MODS_INVALID_CODE, MODS_REGISTRATION_REFUSED_CODE, type ModTier, type ModRegistrationTier, type ModSeat, type ModEventSide, type ModEventName, type ModEventRow, type ModStation, type ModRegistration, type ModUses, type On, type ModHandler, type ModHandlerOptions, type ModNext, type ModOrigin, type ModTraceEntry, type ModCaughtError, type ModDollarBase, type ModEventPayload, type ModMatcher, type ModAdmissionRecord, } from "./core/mods/kernel/index.js";
|
|
284
286
|
export type { EngineDollar, ModelCompleteBlock, ToolCallAnswer } from "./core/mods/dollar.js";
|
|
285
287
|
export { admitModChain } from "./core/mods/stations.js";
|
|
286
|
-
export {
|
|
288
|
+
export { loadModPackage, type ModPackageHost, type ModPackageRegistration } from "./core/mods/package.js";
|
|
289
|
+
export { CREDENTIAL_REF_KINDS, CREDENTIAL_REF_TRUST, CREDENTIAL_REF_TEXT_MAX, CREDENTIAL_REF_MAP_MAX, CREDENTIAL_REF_PROBLEM_REASONS, readCredentialRef, type CredentialRef, type CredentialRefKind, type CredentialRefRequestAdmission, type CredentialRefProblem, type CredentialRefProblemReason, type CredentialRefReading, } from "@sema-agent/primitives";
|
|
287
290
|
export { InMemoryMemoryStore, composeMemoryBlock, composeLayeredMemoryBlock, normalizeMemorySpec, type NormalizedMemorySpec, type MemorySpecInput, supportsConsolidation, supportsPeriodicConsolidation, firstSentence, expandLexicalTerms, lexicalSearchMatch, type Embedder, classifyPromotable, enforcePromotableWriteGate, guardedMemoryStore, MemoryGateError, MemoryProjectionError, detectSecret, enforceSecretWriteGate, enforceStructuredNoteSecretGate, type UtilityGate, type MemoryStore, type MemoryVectorMode, type ScoredMemory, type MemoryNoteHeader, type MemoryNoteRecord, type MemoryNoteType, type StructuredNoteInput, MEMORY_PROJECT_KEY_ABSENT_REASONS, type MemoryProjectKeyAbsentReason, type MemoryProjectKey, } from "./core/memory.js";
|
|
288
291
|
export { MemoryEngine, FileMemoryEngineBackend, memoryBackendContract, assertMemoryBackendSearchEquivalence, type MemoryBackendContractHooks, buildMemoryInstruction, writableRootOf, truncateIndex, scanEntryFiles, deriveRepoKey, deriveRepoMemoryDir, deriveControlPlaneDir, deriveRepoControlPlaneDir, resolveMemoryEngineRoot, scopeDirName, ControlPlaneCorruptError, parseEntryFile, serializeEntryFile, computeEntryRev, entryFromFile, MEMORY_ORIGIN_CAUSES, committedOriginOf, originEquals, consolidationExposedFrontmatter, ambiguousOriginRepresentation, type OriginClearanceRow, type OriginClearanceEvent, type OriginClearanceShadow, committedDistilledOf, distilledEquals, type MemoryEntryDistilled, type MemoryEntryDistilledInput, CONSOLIDATION_DEFAULTS, ConsolidationRefusedError, MEMORY_SEARCH_SUPERSEDED_TAG, consolidationTypeEligible, deriveSupersededSet, memorySupersededNote, readIntentCredentials, supersessionFuseCeiling, deriveShadowedSet, memoryConsolidationRecommendedNotice, memoryConsolidationCommittedNotice, memoryConsolidationConflictNotice, memoryConsolidationIncompleteNotice, memoryConsolidationRefusedNotice, memoryConsolidationWithheldNotice, type ConsolidationGateRead, type ConsolidationGateRow, type ConsolidationIntent, type ConsolidationIntentCredentialRow, type ConsolidationLeaseSeat, type ConsolidationProductProposal, type ConsolidationProposal, type ConsolidationWriteGate, type MemoryConsolidationOptions, type ConsolidationCommitReceipt, type ConsolidationReconcileReport, type ConsolidationResolveReceipt, type ConsolidationPlanSummary, type ConsolidationPlanFoldEvidence, type SessionMemoryStatus, DISTILLER_DEFAULT_MAX_INPUTS_PER_PRODUCT, LLM_DISTILLER_CONTRACT, LLM_DISTILLER_CONTRACT_DL2, LLM_DISTILLER_CONTRACT_DL3, LLM_DISTILLER_CONTRACTS, MEMORY_DISTILLER_CONTRACT_V1, contractGroupingDiff, driveConsolidationToFixpoint, isAliasModelId, llmPlanDistiller, mintExposurePartitionedPlan, mintLlmConsolidationPlan, MEMORY_DISTILLER_PURITY_CONTRACT_V1, detectCleanArmVerbatimLeak, type CleanArmLeakFinding, type CleanArmLeakVerdict, type MemoryDistillerPurityContract, openAiCompatChatSeat, parseJsonAnswer, planParseRepairs, sanitizeLlmGroups, scheduleUnderFuse, type ConsolidationDistillFn, type ConsolidationDriveCycleRow, type ConsolidationDriveEngine, type ConsolidationDriveResult, type ConsolidationFoldState, type DistillerCandidate, type DistillerChatAnswer, type DistillerChatFn, type DistillerChatRequest, type FuseSchedule, type LlmConsolidationPlan, type LlmConsolidationPlanArm, type LlmConsolidationPlanProduct, type LlmDistillerContract, type MintLlmConsolidationPlanResult, type PlanParseRepairs, type SanitizedLlmGroups, CONSOLIDATION_DRIVER_PLANS_DIR, CONSOLIDATION_DRIVER_RUNS_FILE, CONSOLIDATION_RUN_STOP_REASONS, CONSOLIDATION_WRITE_REFUSED_CODE, archiveDistillerPlan, readConsolidationDriverRun, runMemoryConsolidationDriver, type ConsolidationDriverEngine, type ConsolidationDriverRunRow, type ConsolidationRunReceipt, type ConsolidationRunStopReason, type ConsolidationWriteJudge, type ConsolidationWriteTarget, type RunMemoryConsolidationOptions, isInstructionEntry, type MemoryEntryOrigin, type MemoryOriginCause, MEMORY_INSTRUCTION_TEMPLATE, MEMORY_RECALL_DISCIPLINE, MEMORY_PREFERENCE_DISCIPLINE, MEMORY_READONLY_NOTICE, MEMORY_CAPTURE_OPTOUT_NOTICE, memoryCaptureOptedOutNotice, memoryCaptureOptOutUnpersistedNotice, SESSION_CAPTURE_OPTOUT_DIR, markSessionCaptureOptOut, readSessionCaptureOptOut, listSessionCaptureOptOut, fileSessionCaptureRecordStore, type SessionCaptureOptOutRecord, type SessionCaptureOptOutMarkOutcome, type SessionCaptureRecordStore, 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_INDEX_TOOL_NAME, MEMORY_ENGINE_TOOL_NAMES, type MemorySearchDetails, type MemorySearchHit, type CleanMemorySearchHit, type ExposedMemorySearchHit, MEMORY_EXPOSURE_BANNER, MEMORY_EXPOSURE_HANDLE_TAG, memoryExposureIndexRow, type MemoryGetDetails, type MemoryIndexDetails, type MemoryIndexRow, type CleanMemoryIndexRow, type ExposedMemoryIndexRow, 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 MemoryScopeEnumeration, 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, isOrgScopeKey, 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";
|
|
289
292
|
export { createConsolidationWriteJudge, deliverWriteRefusal, type ConsolidationWriteJudgeInput } from "./core/runner/memory-consolidation-write-judge.js";
|
|
@@ -368,10 +371,11 @@ export { FileBackgroundAgentStore, type FileBackgroundAgentStoreOptions } from "
|
|
|
368
371
|
export { A2A_TASK_STATES, type A2ATaskState, type A2ATaskStateReversal, type A2ATaskStateReversalFaithful, type A2ATaskStateReversalLossy, toA2ATaskState, fromA2ATaskState, } from "./core/a2a-task-state.js";
|
|
369
372
|
export { type WorkflowJournalStore, type WorkflowJournalEntry, InMemoryWorkflowJournalStore, callKeyOrdinal, JOURNAL_OVERSIZE_ERROR_CODE, WorkflowJournalOversizeError, assertJournalEntryFits, readWorkflowJournalEntry, type WorkflowJournalEntryReading, WorkflowJournalIncompatibleError, JOURNAL_INCOMPATIBLE_ERROR_CODE, } from "./core/workflow-journal-store.js";
|
|
370
373
|
export { untrustedEgressForHuman, redactHostLeaks, redactSecrets, boundedRedactedSummary } from "./core/untrusted-egress.js";
|
|
374
|
+
export { REDACTION_MARK } from "./core/redaction-marks.js";
|
|
371
375
|
export type { Egress, EgressTier } from "./core/untrusted-egress.js";
|
|
372
376
|
export type { RedactionFinding, RedactionReport, RedactionConfidence, RedactionSource, SummarizableFinding, } from "./core/untrusted-egress.js";
|
|
373
377
|
export { summarizeRedactions } from "./core/untrusted-egress.js";
|
|
374
|
-
export { headerOwnershipCollision } from "./core/protocol-http-auth.js";
|
|
378
|
+
export { headerOwnershipCollision, MCP_ASSERTION_HEADER } from "./core/protocol-http-auth.js";
|
|
375
379
|
export type { ProtocolHttpAuth } from "./core/protocol-http-auth.js";
|
|
376
380
|
export { MemoryRosterStore, FileRosterStore, type RosterStore, type RosterEntry, type RosterAccess, type RosterGcOptions } from "./agents/roster-store.js";
|
|
377
381
|
export { CONFIG_CATALOG_VERSION, describeConfigCatalog, resolveEffectiveConfig, type ConfigKnob, type ConfigOverrideDeclaration, type ConfigProvenance, type EffectiveConfigField, } from "./config/catalog.js";
|
|
@@ -430,7 +434,7 @@ export { ROUTE_ADJUDICATION_CONFORMANCE_CORPUS, type RouteAdjudicationVector } f
|
|
|
430
434
|
export { type BrainTimeoutConfig } from "./brain/timeout.js";
|
|
431
435
|
export { createAssistantMessageEventStream } from "./internal/llm.js";
|
|
432
436
|
export type { AssistantMessage, AssistantMessageEvent, CompleteSimpleFn, Context, DocumentContent, ImageContent, Message, StopReason, StreamFn, TextContent, ThinkingContent, ToolCall, ToolDescriptionVariant, ToolResultMessage, Usage, UserMessage, UserMessageAttachment, UserAttachmentKind, UserAttachmentObservation, UserAttachmentOutcome, UserAttachmentSupply, } from "./internal/llm.js";
|
|
433
|
-
export type { AgentDefinition, BeforeWriteHook, BeforeWriteRequest, BeforeWriteResult, TrackFileEditHook, TrackEditRequest, TrackEditResult, FileEditedHook, FileEditedNotice, HandsBandOptions, Brain, BrainStatus, BrainStatusPhase, BrainRetryErrClass, ImageInput, UserAttachment, McpElicitRequest, McpElicitResponse, McpServerSpec, A2aServerSpec, OnElicit, Model, ModelRef, ProjectMemoryLoad, RunnerDeps, ResumePreflightInfo, ResumePreflightVerdict, EngineNotice, RuntimeCaps, BackgroundChildEvent, DelegationLifecycleEvent, SkillSpec, TaskEvent, ExtensionRequester, TaskEventIdentity, ToolActivity, TaskLimits, StaleToolResultOffloadOptions, TaskResult, TerminalCause, PausedCause, EffectiveMemoryScopes, RemoteEnvFailureNote, TaskSpec, ShellGateDoctrine, TaskStatus, TaskStream, CompactOutcome, ThinkingLevel, ToolExecuteContext, ToolReturn, ToolSpec, ToolInputVerdict, ToolInputValidationContext, ReversibilityVerdict, ReadRootGrantCandidate, ToolEffect, ToolContentOrigin, WorkflowGovernanceBaseline, DelegationTaskType, } from "./core/types.js";
|
|
437
|
+
export type { AgentDefinition, BeforeWriteHook, BeforeWriteRequest, BeforeWriteResult, TrackFileEditHook, TrackEditRequest, TrackEditResult, FileEditedHook, FileEditedNotice, HandsBandOptions, Brain, BrainStatus, BrainStatusPhase, BrainRetryErrClass, ImageInput, UserAttachment, McpElicitRequest, McpElicitResponse, McpServerSpec, A2aServerSpec, OnElicit, Model, ModelRef, ProjectMemoryLoad, RunnerDeps, ResumePreflightInfo, ResumePreflightVerdict, EngineNotice, RuntimeCaps, BackgroundChildEvent, DelegationLifecycleEvent, SkillSpec, TaskEvent, ExtensionRequester, RewriteAuthor, ToolInputRewrite, TaskEventIdentity, ToolActivity, TaskLimits, StaleToolResultOffloadOptions, TaskResult, TerminalCause, PausedCause, EffectiveMemoryScopes, RemoteEnvFailureNote, TaskSpec, ShellGateDoctrine, TaskStatus, TaskStream, CompactOutcome, ThinkingLevel, ToolExecuteContext, ToolReturn, ToolSpec, ToolInputVerdict, ToolInputValidationContext, ReversibilityVerdict, ReadRootGrantCandidate, ToolEffect, ToolContentOrigin, WorkflowGovernanceBaseline, DelegationTaskType, } from "./core/types.js";
|
|
434
438
|
export { Type } from "typebox";
|
|
435
439
|
export type { TSchema, Static } from "typebox";
|
|
436
440
|
export { explainPromptAssembly, describeCatalog, type CatalogDescription, type ExplainInput } from "./prompt-assembly/explain.js";
|
|
@@ -440,6 +444,7 @@ export { RULE_OFFERS_ABSENCES, type RuleOffersAbsence } from "./core/ask-origin.
|
|
|
440
444
|
export { BOUND_GRANT_ABSENCES, type BoundGrantAbsence } from "./core/skill-grant-binding.js";
|
|
441
445
|
export { DISPOSABLE_PROMPT_SECTIONS, type DisposablePromptSection, type PromptSectionEntry, type PromptSectionAuthor, type McpInstructionsEntry } from "./core/prompt-section-seat.js";
|
|
442
446
|
export type { McpRevocationLedger, McpMountIdentity } from "./core/mcp-server-spec.js";
|
|
447
|
+
export type { PeerSeat, PeerQuestion, PeerAnswer, PeerSeatTarget, PeerAskCause } from "./core/peer-seat.js";
|
|
443
448
|
export { readToolAxes, readMcpToolAxes } from "./core/mcp-server-spec.js";
|
|
444
449
|
export type { ToolAxesRead, ToolAxesSurface } from "./core/mcp-server-spec.js";
|
|
445
450
|
export { receiveDeclaration, DECLARATION_PATH_RULES } from "./core/mcp-server-spec.js";
|
|
@@ -455,4 +460,6 @@ export { checkpointRevOf, checkpointOccMatches, checkpointHolderMatches, type Ho
|
|
|
455
460
|
export { CARD_FACET_OVERRIDES } from "./core/pause-registry.js";
|
|
456
461
|
export { readRuleOffers, RULE_OFFER_SHAPE_PROBLEMS, type RuleOfferShapeProblem, type RuleOfferRead, type RuleOfferDropped, type RuleOffersReading } from "./core/rule-offer-read.js";
|
|
457
462
|
export { compareOccupants } from "./engine/session/repo-utils.js";
|
|
463
|
+
export { sessionRowMatches } from "./engine/session/repo-utils.js";
|
|
464
|
+
export { sessionLogMarkOf } from "./engine/session/storage-base.js";
|
|
458
465
|
export { CHECKPOINT_LIST_LIMITS, readCheckpointOverdueQuery, readCheckpointSessionQuery, readCheckpointDeleteGuard, checkpointDeadlinePassed, deleteGuardAdmits, selectOverduePage, selectSessionPage, type CheckpointFacet, type CheckpointPage, type CheckpointOverdueQuery, type CheckpointOverdueCursor, type CheckpointOverdueQueryReading, type CheckpointSessionQuery, type CheckpointSessionCursor, type CheckpointSessionQueryReading, type CheckpointRowRead, type CheckpointDeleteGuard, } from "./core/checkpoint-queries.js";
|
package/dist/index.js
CHANGED
|
@@ -47,6 +47,7 @@ export { runCascade, } from "./agents/cascade.js";
|
|
|
47
47
|
export { pgQuery, mysqlQuery, sqliteQuery } from "./tools/sql-adapters.js";
|
|
48
48
|
export { materializeMcpTools, MCP_PREFIX } from "./core/mcp.js";
|
|
49
49
|
export { mcpStartupTimeoutMs } from "./core/mcp.js";
|
|
50
|
+
export { judgeSessionMetaKey, MCP_SESSION_META_KEY_MAX_CHARS } from "./core/mcp-call-meta.js";
|
|
50
51
|
export { McpConnectionPool } from "./core/mcp-connection-pool.js";
|
|
51
52
|
export { probeMcpServers } from "./core/mcp-probe.js";
|
|
52
53
|
export { judgeMcpNames, describeMcpNameConflict } from "./core/mcp-name-judge.js";
|
|
@@ -73,7 +74,7 @@ export { createSessionRulePolicy } from "./core/runner/session-rule-policy.js";
|
|
|
73
74
|
export { LOCKED_KEY_REGISTRY, resolveLockedKeys } from "./core/locked-config.js";
|
|
74
75
|
export { BUILTIN_COMPLIANCE_DENIES, COMPLIANCE_CAPABILITIES, WEB_FETCH_TOOL_NAME, complianceCallDenial, resolveComplianceDenies, } from "./core/compliance.js";
|
|
75
76
|
export { admitMemoryScopes, foldAdmissionFreeze, } from "./core/memory-admission.js";
|
|
76
|
-
export { assertRetentionCapability, RETENTION_CASCADE_DOMAINS, RETENTION_CASCADE_EXEMPT, } from "./core/retention.js";
|
|
77
|
+
export { assertRetentionCapability, readRetentionDeclaration, RETENTION_CASCADE_DOMAINS, RETENTION_CASCADE_EXEMPT, } from "./core/retention.js";
|
|
77
78
|
export { GOVERNANCE_CODES, governanceRetryClass, TOOL_DECLARATION_CODES } from "./core/governance-codes.js";
|
|
78
79
|
export { NOTICE_AUDIENCE, noticeAudienceOf, ENGINE_NOTICE_CODES, NOTICE_MINTER } from "./core/governance-codes.js";
|
|
79
80
|
export { TtlSessionStore } from "./core/session-store.js";
|
|
@@ -153,12 +154,13 @@ export {} from "./core/fs-write-gate-policy.js";
|
|
|
153
154
|
export { catalogRuleFaceView } from "./core/permission-rules.js";
|
|
154
155
|
export { DURABLE_HISTORY_NAMES } from "./engine/compaction/utils.js";
|
|
155
156
|
export { describeStaticWiring, deriveWiringManifest, deriveAskEffective, resolveDeclaredDurability, resolveSubagentTranscriptTier, resolveAskSeamForm, resolveQuestionSeam, countElicitOptIns, AUTO_MODE_ARM_REASONS, LSP_LANES, APPROVAL_REACH, isApprovalReach, } from "./core/wiring-manifest.js";
|
|
157
|
+
export { RUN_ORIGINS, isRunOrigin } from "./core/run-origin.js";
|
|
156
158
|
export { probeParkRoundTrip, durableParkGapOf, durableParkGapFor, PARK_SELFCHECK_SCOPE_PREFIX, } from "./core/park-selfcheck.js";
|
|
157
159
|
export {} from "./core/checkpoint-store.js";
|
|
158
160
|
export {} from "./core/checkpoint-store.js";
|
|
159
161
|
export { projectHumanInput, buildHumanInputEvent, } from "./core/human-input-projection.js";
|
|
160
162
|
export { USER_ATTACHMENT_SEAT, USER_ATTACHMENT_KINDS, USER_ATTACHMENT_SUPPLIES, USER_ATTACHMENT_OUTCOMES, USER_ATTACHMENTS_MAX, USER_ATTACHMENT_LABEL_MAX, } from "./core/user-attachment.js";
|
|
161
|
-
export { TaskRegistry, defaultTaskRegistry, createTaskOutputTool, createTaskStopTool, MONITOR_BATCH_WINDOW_MS, MONITOR_DEFAULT_TIMEOUT_MS, MONITOR_MAX_TIMEOUT_MS, MONITOR_MAX_BATCHES_PER_MINUTE, canAccessWorkflowRun, DURABLE_AGENT_HANDLE_RE, engineAgentName, } from "./core/task-registry.js";
|
|
163
|
+
export { TaskRegistry, defaultTaskRegistry, createTaskOutputTool, createTaskStopTool, MONITOR_BATCH_WINDOW_MS, MONITOR_DEFAULT_TIMEOUT_MS, MONITOR_MAX_TIMEOUT_MS, MONITOR_MAX_BATCHES_PER_MINUTE, canAccessWorkflowRun, DURABLE_AGENT_HANDLE_RE, engineAgentName, chosenAgentName, } from "./core/task-registry.js";
|
|
162
164
|
export { InMemoryMailboxStore, MailboxStoreError, MAILBOX_TOMBSTONED_RECIPIENT_CODE, MAILBOX_PEER_NOTICE_STATES, MAILBOX_PEER_FROM_MODES, MAILBOX_PEER_RECORD_KINDS, MAILBOX_INVALID_PEER_META_CODE, MAILBOX_CROSS_PROCESS_UNSAFE_CODE, readMailboxPeerMeta, mailboxCrossProcessMountVerdict, MAILBOX_DECISIONS, MAILBOX_INVALID_DECISION_MOVE_CODE, isMailboxDecision, isMailboxDecisionFinal, isMailboxDecisionDeliverable, mailboxDecisionEdgeAllowed, assertMailboxDecisionMove, moveMailboxDecision, readStoredMailboxDecision, } from "./core/mailbox-store.js";
|
|
163
165
|
export { FileMailboxStore } from "./stores/file/mailbox-store.js";
|
|
164
166
|
export { createFileTaskListStore } from "./stores/file/task-list-store.js";
|
|
@@ -217,7 +219,8 @@ export { adoptLocalDataRoot, ackAdoptionConfig, witnessAdoptionConfig, listAdopt
|
|
|
217
219
|
export { formatHookFeedback, runToolGate, createHookEnvCapabilities, createPreToolUseConstraintPolicy, normalizePersistedRuleHit, } from "./core/hooks.js";
|
|
218
220
|
export { KERNEL_CONTRACT_VERSION, MOD_TIERS, MOD_SEATS, MOD_EVENT_SIDES, MOD_EVENT_TABLE, MODS_INVALID_CODE, MODS_REGISTRATION_REFUSED_CODE, } from "./core/mods/kernel/index.js";
|
|
219
221
|
export { admitModChain } from "./core/mods/stations.js";
|
|
220
|
-
export {
|
|
222
|
+
export { loadModPackage } from "./core/mods/package.js";
|
|
223
|
+
export { CREDENTIAL_REF_KINDS, CREDENTIAL_REF_TRUST, CREDENTIAL_REF_TEXT_MAX, CREDENTIAL_REF_MAP_MAX, CREDENTIAL_REF_PROBLEM_REASONS, readCredentialRef, } from "@sema-agent/primitives";
|
|
221
224
|
export { InMemoryMemoryStore, composeMemoryBlock, composeLayeredMemoryBlock, normalizeMemorySpec, supportsConsolidation, supportsPeriodicConsolidation, firstSentence, expandLexicalTerms, lexicalSearchMatch, classifyPromotable, enforcePromotableWriteGate, guardedMemoryStore, MemoryGateError, MemoryProjectionError, detectSecret, enforceSecretWriteGate, enforceStructuredNoteSecretGate, MEMORY_PROJECT_KEY_ABSENT_REASONS, } from "./core/memory.js";
|
|
222
225
|
export { MemoryEngine, FileMemoryEngineBackend, memoryBackendContract, assertMemoryBackendSearchEquivalence, buildMemoryInstruction, writableRootOf, truncateIndex, scanEntryFiles, deriveRepoKey, deriveRepoMemoryDir, deriveControlPlaneDir, deriveRepoControlPlaneDir, resolveMemoryEngineRoot, scopeDirName, ControlPlaneCorruptError, parseEntryFile, serializeEntryFile, computeEntryRev, entryFromFile, MEMORY_ORIGIN_CAUSES, committedOriginOf, originEquals, consolidationExposedFrontmatter, ambiguousOriginRepresentation, committedDistilledOf, distilledEquals, CONSOLIDATION_DEFAULTS, ConsolidationRefusedError, MEMORY_SEARCH_SUPERSEDED_TAG, consolidationTypeEligible, deriveSupersededSet, memorySupersededNote, readIntentCredentials, supersessionFuseCeiling, deriveShadowedSet, memoryConsolidationRecommendedNotice, memoryConsolidationCommittedNotice, memoryConsolidationConflictNotice, memoryConsolidationIncompleteNotice, memoryConsolidationRefusedNotice, memoryConsolidationWithheldNotice, DISTILLER_DEFAULT_MAX_INPUTS_PER_PRODUCT, LLM_DISTILLER_CONTRACT, LLM_DISTILLER_CONTRACT_DL2, LLM_DISTILLER_CONTRACT_DL3, LLM_DISTILLER_CONTRACTS, MEMORY_DISTILLER_CONTRACT_V1, contractGroupingDiff, driveConsolidationToFixpoint, isAliasModelId, llmPlanDistiller, mintExposurePartitionedPlan, mintLlmConsolidationPlan, MEMORY_DISTILLER_PURITY_CONTRACT_V1, detectCleanArmVerbatimLeak, openAiCompatChatSeat, parseJsonAnswer, planParseRepairs, sanitizeLlmGroups, scheduleUnderFuse, CONSOLIDATION_DRIVER_PLANS_DIR, CONSOLIDATION_DRIVER_RUNS_FILE, CONSOLIDATION_RUN_STOP_REASONS, CONSOLIDATION_WRITE_REFUSED_CODE, archiveDistillerPlan, readConsolidationDriverRun, runMemoryConsolidationDriver, isInstructionEntry, MEMORY_INSTRUCTION_TEMPLATE, MEMORY_RECALL_DISCIPLINE, MEMORY_PREFERENCE_DISCIPLINE, MEMORY_READONLY_NOTICE, MEMORY_CAPTURE_OPTOUT_NOTICE, memoryCaptureOptedOutNotice, memoryCaptureOptOutUnpersistedNotice, SESSION_CAPTURE_OPTOUT_DIR, markSessionCaptureOptOut, readSessionCaptureOptOut, listSessionCaptureOptOut, fileSessionCaptureRecordStore, 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_INDEX_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, isOrgScopeKey, 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";
|
|
223
226
|
export { createConsolidationWriteJudge, deliverWriteRefusal } from "./core/runner/memory-consolidation-write-judge.js";
|
|
@@ -297,8 +300,9 @@ export { FileBackgroundAgentStore } from "./stores/file/background-agent-store.j
|
|
|
297
300
|
export { A2A_TASK_STATES, toA2ATaskState, fromA2ATaskState, } from "./core/a2a-task-state.js";
|
|
298
301
|
export { InMemoryWorkflowJournalStore, callKeyOrdinal, JOURNAL_OVERSIZE_ERROR_CODE, WorkflowJournalOversizeError, assertJournalEntryFits, readWorkflowJournalEntry, WorkflowJournalIncompatibleError, JOURNAL_INCOMPATIBLE_ERROR_CODE, } from "./core/workflow-journal-store.js";
|
|
299
302
|
export { untrustedEgressForHuman, redactHostLeaks, redactSecrets, boundedRedactedSummary } from "./core/untrusted-egress.js";
|
|
303
|
+
export { REDACTION_MARK } from "./core/redaction-marks.js";
|
|
300
304
|
export { summarizeRedactions } from "./core/untrusted-egress.js";
|
|
301
|
-
export { headerOwnershipCollision } from "./core/protocol-http-auth.js";
|
|
305
|
+
export { headerOwnershipCollision, MCP_ASSERTION_HEADER } from "./core/protocol-http-auth.js";
|
|
302
306
|
export { MemoryRosterStore, FileRosterStore } from "./agents/roster-store.js";
|
|
303
307
|
export { CONFIG_CATALOG_VERSION, describeConfigCatalog, resolveEffectiveConfig, } from "./config/catalog.js";
|
|
304
308
|
export { normalizeAgentName } from "./core/task-registry.js";
|
|
@@ -372,4 +376,6 @@ export { checkpointRevOf, checkpointOccMatches, checkpointHolderMatches } from "
|
|
|
372
376
|
export { CARD_FACET_OVERRIDES } from "./core/pause-registry.js";
|
|
373
377
|
export { readRuleOffers, RULE_OFFER_SHAPE_PROBLEMS } from "./core/rule-offer-read.js";
|
|
374
378
|
export { compareOccupants } from "./engine/session/repo-utils.js";
|
|
379
|
+
export { sessionRowMatches } from "./engine/session/repo-utils.js";
|
|
380
|
+
export { sessionLogMarkOf } from "./engine/session/storage-base.js";
|
|
375
381
|
export { CHECKPOINT_LIST_LIMITS, readCheckpointOverdueQuery, readCheckpointSessionQuery, readCheckpointDeleteGuard, checkpointDeadlinePassed, deleteGuardAdmits, selectOverduePage, selectSessionPage, } from "./core/checkpoint-queries.js";
|
|
@@ -14,4 +14,4 @@ export type { SessionWriteOptions, CompactionEntry } from "../engine/harness/typ
|
|
|
14
14
|
export type { ActiveWorktreeSession, WorkspaceState } from "../engine/harness/types.js";
|
|
15
15
|
export type { GitAnnouncementKind, GitAnnouncementState } from "../engine/harness/types.js";
|
|
16
16
|
export type { SessionForkOptions } from "../engine/harness/types.js";
|
|
17
|
-
export type { SessionPlacementRecord, SessionCreateOptions, SessionHead, SessionRow } from "../engine/harness/types.js";
|
|
17
|
+
export type { SessionPlacementRecord, SessionCreateOptions, SessionHead, SessionRow, SessionRowExpectation, SessionRowRead, SessionLogMark } from "../engine/harness/types.js";
|
|
@@ -17,9 +17,9 @@ export { DEFAULT_CHARS_PER_TOKEN, DEFAULT_CLAMP_TOLERANCE, DEFAULT_COMPACTION_SE
|
|
|
17
17
|
export { SKILL_RETENTION_PER_SKILL_MAX_CHARS, SKILL_RETENTION_TOTAL_MAX_CHARS, SKILL_RETENTION_TRUNCATION_MARKER, formatFileOperations, formatPersistedOutputRefs, readCompactionActiveTools, readRetainedInvokedSkills, renderInvokedSkillsRetention, } from "../engine/compaction/utils.js";
|
|
18
18
|
export { NodeExecutionEnv } from "../engine/execution-env/node-execution-env.js";
|
|
19
19
|
export { StoredSession, buildSessionContext } from "../engine/session/session.js";
|
|
20
|
-
export { assertForkTarget, compareOccupants, forkRowCells, frozenRow, getEntriesToFork, importRowCells, incarnationCell, ownerCell, readIncarnationCell, readOwnerCell } from "../engine/session/repo-utils.js";
|
|
20
|
+
export { assertForkTarget, compareOccupants, forkRowCells, frozenRow, getEntriesToFork, importRowCells, incarnationCell, ownerCell, readIncarnationCell, readOwnerCell, rowExpectationMissed, sessionRowMatches } from "../engine/session/repo-utils.js";
|
|
21
21
|
export { validateEntriesForImport, StreamingImportValidator } from "../engine/session/import-validate.js";
|
|
22
|
-
export { BaseSessionStorage, leafIdAfterEntry } from "../engine/session/storage-base.js";
|
|
22
|
+
export { BaseSessionStorage, leafIdAfterEntry, resolveLeafId, sessionLogMarkOf } from "../engine/session/storage-base.js";
|
|
23
23
|
export { InMemorySessionStorage } from "../engine/session/memory-storage.js";
|
|
24
24
|
export { InMemorySessionRepo } from "../engine/session/memory-repo.js";
|
|
25
25
|
export { uuidv7 } from "../engine/session/uuid.js";
|
package/dist/internal/harness.js
CHANGED
|
@@ -5,9 +5,9 @@ export { DEFAULT_CHARS_PER_TOKEN, DEFAULT_CLAMP_TOLERANCE, DEFAULT_COMPACTION_SE
|
|
|
5
5
|
export { SKILL_RETENTION_PER_SKILL_MAX_CHARS, SKILL_RETENTION_TOTAL_MAX_CHARS, SKILL_RETENTION_TRUNCATION_MARKER, formatFileOperations, formatPersistedOutputRefs, readCompactionActiveTools, readRetainedInvokedSkills, renderInvokedSkillsRetention, } from "../engine/compaction/utils.js";
|
|
6
6
|
export { NodeExecutionEnv } from "../engine/execution-env/node-execution-env.js";
|
|
7
7
|
export { StoredSession, buildSessionContext } from "../engine/session/session.js";
|
|
8
|
-
export { assertForkTarget, compareOccupants, forkRowCells, frozenRow, getEntriesToFork, importRowCells, incarnationCell, ownerCell, readIncarnationCell, readOwnerCell } from "../engine/session/repo-utils.js";
|
|
8
|
+
export { assertForkTarget, compareOccupants, forkRowCells, frozenRow, getEntriesToFork, importRowCells, incarnationCell, ownerCell, readIncarnationCell, readOwnerCell, rowExpectationMissed, sessionRowMatches } from "../engine/session/repo-utils.js";
|
|
9
9
|
export { validateEntriesForImport, StreamingImportValidator } from "../engine/session/import-validate.js";
|
|
10
|
-
export { BaseSessionStorage, leafIdAfterEntry } from "../engine/session/storage-base.js";
|
|
10
|
+
export { BaseSessionStorage, leafIdAfterEntry, resolveLeafId, sessionLogMarkOf } from "../engine/session/storage-base.js";
|
|
11
11
|
export { InMemorySessionStorage } from "../engine/session/memory-storage.js";
|
|
12
12
|
export { InMemorySessionRepo } from "../engine/session/memory-repo.js";
|
|
13
13
|
export { uuidv7 } from "../engine/session/uuid.js";
|
|
@@ -2,7 +2,7 @@ import { type MemoryStore, type UtilityGate } from "../../core/memory.js";
|
|
|
2
2
|
import type { CheckpointStore } from "../../core/checkpoint-store.js";
|
|
3
3
|
import type { ToolResultStore } from "../../core/tool-result-store.js";
|
|
4
4
|
import { type EvictPolicy } from "../../core/session-store.js";
|
|
5
|
-
import type { SessionStore } from "../../core/session.js";
|
|
5
|
+
import type { SessionStore, SessionStoreHooks } from "../../core/session.js";
|
|
6
6
|
import { type FileCheckpointStoreOptions } from "./checkpoint-store.js";
|
|
7
7
|
import { type FileSessionPolicyStoreOptions } from "./session-policy-store.js";
|
|
8
8
|
import { type FileFileHistoryStoreOptions } from "./file-history-store.js";
|
|
@@ -107,6 +107,9 @@ export interface FileStorageBackendOptions {
|
|
|
107
107
|
* `principal` when the read was keyed by one. One sink for one failure grammar — a host does not register three.
|
|
108
108
|
*/
|
|
109
109
|
onCorruptRead?: (info: FileStorageCorruptReadInfo) => void;
|
|
110
|
+
/** The deployment's hooks on the session store's row deletions ({@link SessionStoreHooks}) — the File lane has no foreign keys, so a
|
|
111
|
+
* deployment's own records keyed by session id are cleaned here, before each row the session store deletes. */
|
|
112
|
+
sessions?: SessionStoreHooks;
|
|
110
113
|
}
|
|
111
114
|
/**
|
|
112
115
|
* The payload of {@link FileStorageBackendOptions.onCorruptRead} — the widest shape any store this
|
|
@@ -51,6 +51,9 @@ export class FileStorageBackend {
|
|
|
51
51
|
fileSessions;
|
|
52
52
|
fileWorkflowJournal;
|
|
53
53
|
constructor(opts = {}) {
|
|
54
|
+
if ("retention" in opts) {
|
|
55
|
+
throw Object.assign(new Error(`FileStorageBackend runs no retention executor, so its options take no \`retention\` word: its stores declare "none".`), { code: "config.retention_capability" });
|
|
56
|
+
}
|
|
54
57
|
this.root = resolveDataRoot(opts.root);
|
|
55
58
|
assertAdoptionBootGate(this.root, "FileStorageBackend");
|
|
56
59
|
this.lock = new BootLock(join(this.root, "LOCK"));
|
|
@@ -60,7 +63,7 @@ export class FileStorageBackend {
|
|
|
60
63
|
const corruptRead = opts.onCorruptRead !== undefined ? { onCorruptRead: opts.onCorruptRead } : undefined;
|
|
61
64
|
const repo = new FileSessionRepo(this.root, corruptRead);
|
|
62
65
|
this.fileSessions = repo;
|
|
63
|
-
this.ttl = new TtlSessionStore({ repo, evict: opts.evict ?? "forget", durability: "durable", placements: { subagent: { durability: "durable" } } });
|
|
66
|
+
this.ttl = new TtlSessionStore({ repo, evict: opts.evict ?? "forget", durability: "durable", placements: { subagent: { durability: "durable" } }, ...(opts.sessions !== undefined ? { hooks: opts.sessions } : {}) });
|
|
64
67
|
this.sessionStore = this.ttl;
|
|
65
68
|
const sessionHeadOf = this.ttl.headOf;
|
|
66
69
|
this.fileCheckpoints = new FileCheckpointStore(this.root, { ...opts.checkpoint, ...corruptRead, ...(sessionHeadOf !== undefined ? { sessionHeadOf } : {}) });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Session, SessionCreateOptions, SessionForkOptions, SessionHead, SessionMetadata, SessionPlacementRecord, SessionRepo, SessionRow, SessionTreeEntry } from "../../internal/harness.js";
|
|
1
|
+
import type { Session, SessionCreateOptions, SessionForkOptions, SessionHead, SessionMetadata, SessionPlacementRecord, SessionRepo, SessionRow, SessionRowExpectation, SessionRowRead, SessionTreeEntry } from "../../internal/harness.js";
|
|
2
2
|
import type { PlacedSessionRow } from "../../core/session.js";
|
|
3
3
|
import { type CorruptReadInfo } from "./corrupt-read-sink.js";
|
|
4
4
|
export interface FileSessionRepoOptions {
|
|
@@ -60,6 +60,13 @@ export declare class FileSessionRepo implements SessionRepo {
|
|
|
60
60
|
* head does not see. A leaf entry naming an id the log does not hold is not checked here (a replay refuses that log on open).
|
|
61
61
|
*/
|
|
62
62
|
headOf(sessionId: string): Promise<SessionHead | undefined>;
|
|
63
|
+
/** {@link headOf}'s one read, synchronously — what a conditional delete judges its expectation against in the step that removes the row. */
|
|
64
|
+
private headNow;
|
|
65
|
+
/** The row in one read of its file (one inode): the header's cells, the head they and the replayed log give, and the log. */
|
|
66
|
+
readRow(sessionId: string): Promise<SessionRowRead | undefined>;
|
|
67
|
+
/** {@link readRow}'s one read, synchronously — what a conditional import judges its expectation against in the step that writes. A
|
|
68
|
+
* file whose header cannot be read rejects (`corrupt_session`): it is a row whose cells nobody can name. */
|
|
69
|
+
private rowNow;
|
|
63
70
|
/**
|
|
64
71
|
* The row's {@link SessionRow} — its header cells and the newest write it holds, the log's modification time (every write to a row
|
|
65
72
|
* is an append to its log; the placed listing's age reads the same time) — in one read of the header, never a replay of the log.
|
|
@@ -111,24 +118,24 @@ export declare class FileSessionRepo implements SessionRepo {
|
|
|
111
118
|
olderThanMs?: number;
|
|
112
119
|
scope?: string;
|
|
113
120
|
}): Promise<PlacedSessionRow[]>;
|
|
114
|
-
/** The row as it stands before a file-replacing write: `undefined` ⇔ there is no row (no file); a row
|
|
115
|
-
* whose header cannot be read rejects (it exists, and nobody can name its cells). */
|
|
116
|
-
private priorHeader;
|
|
117
121
|
/** Cheap placement probe for one id (the TtlSessionStore's cold-cache release consults it so the
|
|
118
122
|
* placed real-deletion obligation holds after a restart). `undefined` = missing file OR unplaced; a row that cannot be read rejects. */
|
|
119
123
|
placementOf(sessionId: string): Promise<SessionPlacementRecord | undefined>;
|
|
120
|
-
delete(metadata: SessionMetadata): Promise<void>;
|
|
124
|
+
delete(metadata: SessionMetadata, expect?: SessionRowExpectation): Promise<void>;
|
|
121
125
|
fork(sourceMetadata: SessionMetadata, options?: SessionForkOptions & SessionCreateOptions): Promise<Session>;
|
|
122
126
|
/** 2c session-sync (the FILE half): the FULL oldest-first log for export. The file backend
|
|
123
127
|
* has NO F3 floor — `read` returns EVERY persisted entry (`id`/`parentId` verbatim) — so this is the complete
|
|
124
128
|
* log, BYPASSing any bounded tail (matches `InMemorySessionRepo.exportEntries`). Missing file → not_found. */
|
|
125
129
|
exportEntries(sessionId: string): Promise<SessionTreeEntry[]>;
|
|
126
130
|
/** 2c session-sync: import a verbatim log into `sessionId`. The single fail-closed invariant gate runs
|
|
127
|
-
* FIRST ({@link validateEntriesForImport}); a new row's header records `owner`, an existing row's is laid down again whole
|
|
131
|
+
* FIRST ({@link validateEntriesForImport}); a new row's header records `owner`, an existing row's is laid down again whole and must already
|
|
132
|
+
* be `owner`'s (`importRowCells`), and the row must be the one `options.expect` names (`sessionRowMatches`) — the row read, both
|
|
133
|
+
* judgements and the write with no await between; the head answered is the one the write lays down. Writes the WHOLE file
|
|
128
134
|
* (meta + entries) atomically via tmp→fsync→rename — the rename is the commit point, so a crash leaves either nothing or an
|
|
129
|
-
* orphan temp, never a partially-imported session (mirrors `fork`).
|
|
135
|
+
* orphan temp, never a partially-imported session (mirrors `fork`). The importer's existing session is REPLACED (the
|
|
130
136
|
* orchestrator's importSession owns the already-exists policy, same as InMemory's overwrite). */
|
|
131
137
|
importEntries(sessionId: string, owner: string | undefined, entries: SessionTreeEntry[], options?: {
|
|
132
138
|
preserveActorAssertions?: boolean;
|
|
133
|
-
|
|
139
|
+
expect?: SessionRowExpectation;
|
|
140
|
+
}): Promise<SessionHead>;
|
|
134
141
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { closeSync, existsSync, fstatSync, openSync, readdirSync, rmSync, utimesSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { BaseSessionStorage, StoredSession, SessionError, assertForkTarget, compareOccupants, forkRowCells, frozenRow, getEntriesToFork, importRowCells, incarnationCell, leafIdAfterEntry, ownerCell, readIncarnationCell, readOwnerCell, uuidv7, validateEntriesForImport, } from "../../internal/harness.js";
|
|
3
|
+
import { BaseSessionStorage, StoredSession, SessionError, assertForkTarget, compareOccupants, forkRowCells, frozenRow, getEntriesToFork, importRowCells, incarnationCell, leafIdAfterEntry, ownerCell, readIncarnationCell, readOwnerCell, resolveLeafId, rowExpectationMissed, sessionLogMarkOf, sessionRowMatches, uuidv7, validateEntriesForImport, } from "../../internal/harness.js";
|
|
4
4
|
import { canonicalStoreKey, AppendLog, atomicWriteFile, ensureDir, firstJsonlRecord, lastJsonlRecord, readJsonlRecords, sanitizePathComponent, writeThenLink } from "./fs-atomic.js";
|
|
5
5
|
import { guardCorruptSink } from "./corrupt-read-sink.js";
|
|
6
6
|
import { assertAdoptionBootGate } from "./adoption/marker.js";
|
|
@@ -125,11 +125,30 @@ export class FileSessionRepo {
|
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
async headOf(sessionId) {
|
|
128
|
+
return this.headNow(sessionId);
|
|
129
|
+
}
|
|
130
|
+
headNow(sessionId) {
|
|
128
131
|
return this.atRow(sessionId, (fd, size, meta) => {
|
|
129
132
|
const last = lastJsonlRecord(fd, size, (r) => r.kind === "entry", SESSION_LINE_JUDGE);
|
|
130
133
|
return { owner: meta.owner ?? null, incarnation: meta.incarnation, leafId: last === undefined ? null : leafIdAfterEntry(last.entry) };
|
|
131
134
|
});
|
|
132
135
|
}
|
|
136
|
+
async readRow(sessionId) {
|
|
137
|
+
return this.rowNow(sessionId);
|
|
138
|
+
}
|
|
139
|
+
rowNow(sessionId) {
|
|
140
|
+
let read;
|
|
141
|
+
try {
|
|
142
|
+
read = this.read(sessionId);
|
|
143
|
+
}
|
|
144
|
+
catch (err) {
|
|
145
|
+
if (err instanceof SessionError && err.code === "not_found")
|
|
146
|
+
return undefined;
|
|
147
|
+
throw err;
|
|
148
|
+
}
|
|
149
|
+
const { meta, entries } = read;
|
|
150
|
+
return { metadata: meta, head: { owner: meta.owner ?? null, incarnation: meta.incarnation, leafId: resolveLeafId(entries) }, entries };
|
|
151
|
+
}
|
|
133
152
|
rowOf(sessionId) {
|
|
134
153
|
return this.atRow(sessionId, (_fd, _size, meta, mtimeMs) => ({ ...meta, lastActiveAt: Math.trunc(mtimeMs) }));
|
|
135
154
|
}
|
|
@@ -270,16 +289,6 @@ export class FileSessionRepo {
|
|
|
270
289
|
}
|
|
271
290
|
return out;
|
|
272
291
|
}
|
|
273
|
-
priorHeader(id) {
|
|
274
|
-
try {
|
|
275
|
-
return this.read(id).meta;
|
|
276
|
-
}
|
|
277
|
-
catch (err) {
|
|
278
|
-
if (err instanceof SessionError && err.code === "not_found")
|
|
279
|
-
return undefined;
|
|
280
|
-
throw err;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
292
|
async placementOf(sessionId) {
|
|
284
293
|
try {
|
|
285
294
|
return this.read(sessionId).meta.placement;
|
|
@@ -290,7 +299,9 @@ export class FileSessionRepo {
|
|
|
290
299
|
throw err;
|
|
291
300
|
}
|
|
292
301
|
}
|
|
293
|
-
async delete(metadata) {
|
|
302
|
+
async delete(metadata, expect) {
|
|
303
|
+
if (expect !== undefined && !sessionRowMatches(expect, this.headNow(metadata.id), () => sessionLogMarkOf(this.read(metadata.id).entries)))
|
|
304
|
+
throw rowExpectationMissed(metadata.id, "delete");
|
|
294
305
|
evictSharedSessionStorage(canonicalStoreKey(this.pathFor(metadata.id)));
|
|
295
306
|
try {
|
|
296
307
|
rmSync(this.pathFor(metadata.id), { force: true });
|
|
@@ -320,12 +331,16 @@ export class FileSessionRepo {
|
|
|
320
331
|
}
|
|
321
332
|
async importEntries(sessionId, owner, entries, options) {
|
|
322
333
|
const validated = validateEntriesForImport(entries, options);
|
|
323
|
-
const
|
|
334
|
+
const prior = this.rowNow(sessionId);
|
|
335
|
+
if (!sessionRowMatches(options?.expect, prior?.metadata, () => sessionLogMarkOf(prior.entries)))
|
|
336
|
+
throw rowExpectationMissed(sessionId, "import");
|
|
337
|
+
const meta = importRowCells(sessionId, owner, prior?.metadata, new Date().toISOString());
|
|
324
338
|
evictSharedSessionStorage(canonicalStoreKey(this.pathFor(sessionId)));
|
|
325
339
|
const lines = [JSON.stringify({ kind: "meta", ...meta })];
|
|
326
340
|
for (const entry of validated) {
|
|
327
341
|
lines.push(JSON.stringify({ kind: "entry", entry }));
|
|
328
342
|
}
|
|
329
343
|
atomicWriteFile(this.tmpDir, this.pathFor(sessionId), `${lines.join("\n")}\n`);
|
|
344
|
+
return { owner: meta.owner ?? null, incarnation: meta.incarnation, leafId: resolveLeafId(validated) };
|
|
330
345
|
}
|
|
331
346
|
}
|
|
@@ -14,8 +14,11 @@ import { type CwdRef } from "./fs-shared.js";
|
|
|
14
14
|
* Absent hook ⇒ byte-identical behavior.
|
|
15
15
|
*/
|
|
16
16
|
export type { BeforeWriteRequest, BeforeWriteResult, BeforeWriteHook, TrackEditRequest, TrackEditResult, TrackFileEditHook } from "../../core/types.js";
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
/** A write tool's primary containment root: fixed, or a getter over the leg's live write location (read once per call, so an
|
|
18
|
+
* EnterWorktree switch moves where the next write may land). Canonical in both forms. */
|
|
19
|
+
export type WriteRootSeat = string | (() => string);
|
|
20
|
+
export declare function createEditFileTool(env: ExecutionEnv, state: ReadFileState, rootCanonical: WriteRootSeat, cwdRef?: CwdRef, additionalRoots?: readonly string[], beforeWrite?: BeforeWriteHook, trackEdit?: TrackFileEditHook, onEdited?: FileEditedHook, writeFace?: () => ContainmentFace, writeDeny?: WriteDenyMatcher): AgentTool;
|
|
21
|
+
export declare function createWriteFileTool(env: ExecutionEnv, state: ReadFileState, rootCanonical: WriteRootSeat, cwdRef?: CwdRef, additionalRoots?: readonly string[], beforeWrite?: BeforeWriteHook, trackEdit?: TrackFileEditHook, onEdited?: FileEditedHook, writeFace?: () => ContainmentFace, writeDeny?: WriteDenyMatcher): AgentTool;
|
|
19
22
|
/**
|
|
20
23
|
* design v1.163 — NotebookEdit: replace/insert/delete a single cell in a .ipynb. CC-parity tool over the SAME hand-band
|
|
21
24
|
* safety skeleton as Edit/Write (resolveKey containment → requireRead read-before-edit → checkStale content-hash
|
|
@@ -23,4 +26,4 @@ export declare function createWriteFileTool(env: ExecutionEnv, state: ReadFileSt
|
|
|
23
26
|
* .ipynb as the cell projection but records read state (hash/totalLines) in the RAW notebook-text
|
|
24
27
|
* coordinate — that raw-coordinate read record is what this tool's freshness check depends on.
|
|
25
28
|
*/
|
|
26
|
-
export declare function createNotebookEditTool(env: ExecutionEnv, state: ReadFileState, rootCanonical:
|
|
29
|
+
export declare function createNotebookEditTool(env: ExecutionEnv, state: ReadFileState, rootCanonical: WriteRootSeat, cwdRef?: CwdRef, additionalRoots?: readonly string[], beforeWrite?: BeforeWriteHook, trackEdit?: TrackFileEditHook, onEdited?: FileEditedHook, writeFace?: () => ContainmentFace, writeDeny?: WriteDenyMatcher): AgentTool;
|
|
@@ -89,6 +89,7 @@ async function gateToolWrite(hook, tool, path, key, content) {
|
|
|
89
89
|
return `Error (${tool}): write rejected by the write gate (${res.code}): ${clipHookText(res.reason)}`;
|
|
90
90
|
return undefined;
|
|
91
91
|
}
|
|
92
|
+
const rootOf = (seat) => (typeof seat === "function" ? seat() : seat);
|
|
92
93
|
export function createEditFileTool(env, state, rootCanonical, cwdRef, additionalRoots, beforeWrite, trackEdit, onEdited, writeFace, writeDeny) {
|
|
93
94
|
return defineTool({
|
|
94
95
|
name: "Edit",
|
|
@@ -114,7 +115,7 @@ export function createEditFileTool(env, state, rootCanonical, cwdRef, additional
|
|
|
114
115
|
const path = fileArgPath(args);
|
|
115
116
|
if (path === undefined)
|
|
116
117
|
return { ok: true };
|
|
117
|
-
const r = await resolveKey(env, rootCanonical, path, ctx.signal, cwdRef?.current, additionalRoots, undefined, seatForCall(writeDeny, ctx.toolCallId), writeFace?.());
|
|
118
|
+
const r = await resolveKey(env, rootOf(rootCanonical), path, ctx.signal, cwdRef?.current, additionalRoots, undefined, seatForCall(writeDeny, ctx.toolCallId), writeFace?.());
|
|
118
119
|
if (!r.ok)
|
|
119
120
|
return { ok: true };
|
|
120
121
|
if (a.old_string === a.new_string)
|
|
@@ -152,7 +153,7 @@ export function createEditFileTool(env, state, rootCanonical, cwdRef, additional
|
|
|
152
153
|
const path = fileArgPath(args);
|
|
153
154
|
if (path === undefined)
|
|
154
155
|
return errorResult(`Error (Edit): file_path is required.`);
|
|
155
|
-
const r = await resolveKey(env, rootCanonical, path, ctx.signal, cwdRef?.current, additionalRoots, undefined, seatForCall(writeDeny, ctx.toolCallId), writeFace?.());
|
|
156
|
+
const r = await resolveKey(env, rootOf(rootCanonical), path, ctx.signal, cwdRef?.current, additionalRoots, undefined, seatForCall(writeDeny, ctx.toolCallId), writeFace?.());
|
|
156
157
|
if (!r.ok)
|
|
157
158
|
return errorResult(violationText("Edit", r.violation), violationDetails(r.violation));
|
|
158
159
|
if (!batch && a.old_string === a.new_string) {
|
|
@@ -190,7 +191,7 @@ export function createEditFileTool(env, state, rootCanonical, cwdRef, additional
|
|
|
190
191
|
details: { type: "create", filePath: path, content: created },
|
|
191
192
|
};
|
|
192
193
|
}
|
|
193
|
-
return errorResult(`Error (Edit): ${await enoentMessage(env, r.key, cwdRef?.current ?? rootCanonical, ctx.signal)}`);
|
|
194
|
+
return errorResult(`Error (Edit): ${await enoentMessage(env, r.key, cwdRef?.current ?? rootOf(rootCanonical), ctx.signal)}`);
|
|
194
195
|
}
|
|
195
196
|
const editInfo = await env.fileInfo(r.key, ctx.signal);
|
|
196
197
|
if (editInfo.ok && editInfo.value.size > MAX_EDIT_BYTES) {
|
|
@@ -346,7 +347,7 @@ export function createWriteFileTool(env, state, rootCanonical, cwdRef, additiona
|
|
|
346
347
|
return { ok: true };
|
|
347
348
|
if (ipynbRedirect("Write", path))
|
|
348
349
|
return { ok: true };
|
|
349
|
-
const r = await resolveKey(env, rootCanonical, path, ctx.signal, cwdRef?.current, additionalRoots, undefined, seatForCall(writeDeny, ctx.toolCallId), writeFace?.());
|
|
350
|
+
const r = await resolveKey(env, rootOf(rootCanonical), path, ctx.signal, cwdRef?.current, additionalRoots, undefined, seatForCall(writeDeny, ctx.toolCallId), writeFace?.());
|
|
350
351
|
if (!r.ok)
|
|
351
352
|
return { ok: true };
|
|
352
353
|
const exists = await env.exists(r.key, ctx.signal);
|
|
@@ -365,7 +366,7 @@ export function createWriteFileTool(env, state, rootCanonical, cwdRef, additiona
|
|
|
365
366
|
const ipynb = ipynbRedirect("Write", path);
|
|
366
367
|
if (ipynb)
|
|
367
368
|
return errorResult(ipynb);
|
|
368
|
-
const r = await resolveKey(env, rootCanonical, path, ctx.signal, cwdRef?.current, additionalRoots, undefined, seatForCall(writeDeny, ctx.toolCallId), writeFace?.());
|
|
369
|
+
const r = await resolveKey(env, rootOf(rootCanonical), path, ctx.signal, cwdRef?.current, additionalRoots, undefined, seatForCall(writeDeny, ctx.toolCallId), writeFace?.());
|
|
369
370
|
if (!r.ok)
|
|
370
371
|
return errorResult(violationText("Write", r.violation), violationDetails(r.violation));
|
|
371
372
|
const exists = await env.exists(r.key, ctx.signal);
|
|
@@ -462,7 +463,7 @@ export function createNotebookEditTool(env, state, rootCanonical, cwdRef, additi
|
|
|
462
463
|
return { ok: false, code: "invalid", message: NOTEBOOK_CELL_TYPE_REQUIRED_MESSAGE };
|
|
463
464
|
if (mode !== "insert" && !a.cell_id)
|
|
464
465
|
return { ok: false, code: "invalid", message: NOTEBOOK_CELL_ID_REQUIRED_MESSAGE };
|
|
465
|
-
const r = await resolveKey(env, rootCanonical, a.notebook_path, ctx.signal, cwdRef?.current, additionalRoots, undefined, seatForCall(writeDeny, ctx.toolCallId), writeFace?.());
|
|
466
|
+
const r = await resolveKey(env, rootOf(rootCanonical), a.notebook_path, ctx.signal, cwdRef?.current, additionalRoots, undefined, seatForCall(writeDeny, ctx.toolCallId), writeFace?.());
|
|
466
467
|
if (!r.ok)
|
|
467
468
|
return { ok: true };
|
|
468
469
|
const notRead = requireRead(state, r.key);
|
|
@@ -482,7 +483,7 @@ export function createNotebookEditTool(env, state, rootCanonical, cwdRef, additi
|
|
|
482
483
|
return errorResult(NOTEBOOK_CELL_TYPE_REQUIRED_MESSAGE);
|
|
483
484
|
if (mode !== "insert" && !cell_id)
|
|
484
485
|
return errorResult(NOTEBOOK_CELL_ID_REQUIRED_MESSAGE);
|
|
485
|
-
const r = await resolveKey(env, rootCanonical, notebook_path, ctx.signal, cwdRef?.current, additionalRoots, undefined, seatForCall(writeDeny, ctx.toolCallId), writeFace?.());
|
|
486
|
+
const r = await resolveKey(env, rootOf(rootCanonical), notebook_path, ctx.signal, cwdRef?.current, additionalRoots, undefined, seatForCall(writeDeny, ctx.toolCallId), writeFace?.());
|
|
486
487
|
if (!r.ok)
|
|
487
488
|
return errorResult(violationText("NotebookEdit", r.violation), violationDetails(r.violation));
|
|
488
489
|
const notRead = requireRead(state, r.key);
|
package/dist/tools/fs/index.d.ts
CHANGED
|
@@ -26,6 +26,9 @@ export interface HandsToolkitOptions {
|
|
|
26
26
|
* `bash_readonly` IS constrained by them (that face refuses a read outside the roots), so widening
|
|
27
27
|
* here widens what the read-only band may read. */
|
|
28
28
|
additionalRoots?: readonly string[];
|
|
29
|
+
/** The WRITE tools' primary root (edit_file / write_file / notebook_edit), read per call: the leg's write location, which
|
|
30
|
+
* moves with an EnterWorktree switch while the read tools keep `rootCanonical`. Absent ⇒ `rootCanonical` (one root). */
|
|
31
|
+
writeRoot?: () => string;
|
|
29
32
|
/** The read-boundary whitelist: extra allowed containment roots for the READ faces only —
|
|
30
33
|
* read_file/grep/glob/repo_map and `bash_readonly` admit them; edit_file/write_file/notebook_edit
|
|
31
34
|
* and the full `bash`'s disclosure roots deliberately do NOT (widening reads must never silently
|
package/dist/tools/fs/index.js
CHANGED
|
@@ -81,7 +81,7 @@ export function createHandsToolkit(env, readFileState, rootCanonical, opts = {})
|
|
|
81
81
|
afterPlacement(createReadFileTool(env, readFileState, rootCanonical, readCwd, readFaceRoots, opts.readImageDownsampler, opts.pdfModelCapabilities, bgOutputReadExemption, readDeny, readFace, opts.reminderMark, opts.reminderDisclosureCounts, reader)),
|
|
82
82
|
];
|
|
83
83
|
if (handsWriteHalfMounts({ readOnly })) {
|
|
84
|
-
tools.push(createEditFileTool(env, readFileState, rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny), createWriteFileTool(env, readFileState, rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny), createNotebookEditTool(env, readFileState, rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny));
|
|
84
|
+
tools.push(createEditFileTool(env, readFileState, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny), createWriteFileTool(env, readFileState, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny), createNotebookEditTool(env, readFileState, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny));
|
|
85
85
|
}
|
|
86
86
|
tools.push(afterPlacement(createGrepTool(env, rootCanonical, readFaceRoots, readDeny, readFace, cwdRef, readAdmission)), afterPlacement(createGlobTool(env, rootCanonical, readFaceRoots, readDeny, readFace, cwdRef, readAdmission)), afterPlacement(createRepoMapTool(env, rootCanonical, readFaceRoots, readDeny, readFace, cwdRef, readAdmission)));
|
|
87
87
|
if (includeShell) {
|