@sema-agent/core 7.65.0 → 7.66.1
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 +269 -0
- package/dist/agents/delegation-registry-seat.d.ts +15 -0
- package/dist/agents/delegation-registry-seat.js +13 -0
- package/dist/agents/org-delivery-gate.d.ts +8 -1
- package/dist/agents/org-delivery-gate.js +9 -3
- package/dist/agents/peer-session-drain.d.ts +51 -12
- package/dist/agents/peer-session-drain.js +44 -31
- package/dist/agents/read-inbox-tool.d.ts +6 -2
- package/dist/agents/read-inbox-tool.js +18 -5
- package/dist/agents/subagent.d.ts +3 -1
- package/dist/agents/subagent.js +79 -75
- package/dist/brain/reasoning.d.ts +2 -0
- package/dist/brain/reasoning.js +1 -0
- package/dist/core/allow-entry.d.ts +9 -0
- package/dist/core/allow-entry.js +7 -1
- package/dist/core/ask-origin.d.ts +23 -3
- package/dist/core/ask-origin.js +11 -1
- package/dist/core/engine-notice.d.ts +3 -3
- package/dist/core/governance-codes.js +1 -0
- package/dist/core/human-input-projection.d.ts +9 -0
- package/dist/core/human-input-projection.js +13 -0
- package/dist/core/input-author.d.ts +66 -6
- package/dist/core/input-author.js +21 -3
- package/dist/core/memory-engine/consolidation.d.ts +23 -9
- package/dist/core/memory-engine/consolidation.js +30 -5
- package/dist/core/memory-engine/control-plane-adoption.d.ts +11 -10
- package/dist/core/memory-engine/control-plane-adoption.js +54 -29
- package/dist/core/memory-engine/delegation-settlement.d.ts +18 -12
- package/dist/core/memory-engine/delegation-settlement.js +36 -26
- package/dist/core/memory-engine/engine.d.ts +17 -6
- package/dist/core/memory-engine/engine.js +78 -35
- package/dist/core/memory-engine/file-backend.d.ts +4 -1
- package/dist/core/memory-engine/file-backend.js +5 -1
- package/dist/core/memory-engine/index.d.ts +2 -2
- package/dist/core/memory-engine/index.js +2 -2
- package/dist/core/memory-engine/layout.d.ts +57 -36
- package/dist/core/memory-engine/layout.js +109 -134
- package/dist/core/memory-engine/memory-backend-contract.js +7 -7
- package/dist/core/memory-engine/memory-deployment.d.ts +3 -2
- package/dist/core/memory-engine/memory-deployment.js +6 -3
- package/dist/core/memory-engine/origin-clearance.d.ts +43 -15
- package/dist/core/memory-engine/origin-clearance.js +143 -55
- package/dist/core/model-receipt.d.ts +2 -1
- package/dist/core/model-receipt.js +5 -0
- package/dist/core/mods/dollar.d.ts +12 -0
- package/dist/core/mods/kernel/dispatch.d.ts +3 -1
- package/dist/core/mods/kernel/dispatch.js +5 -2
- package/dist/core/mods/kernel/events.d.ts +3 -1
- package/dist/core/mods/kernel/events.js +2 -2
- package/dist/core/mods/prompt-submit.d.ts +4 -0
- package/dist/core/mods/prompt-submit.js +24 -0
- package/dist/core/mods/stations.d.ts +23 -4
- package/dist/core/mods/stations.js +14 -7
- package/dist/core/retired-host-table-account.d.ts +19 -0
- package/dist/core/retired-host-table-account.js +28 -0
- package/dist/core/retired-tool-name-account.d.ts +60 -0
- package/dist/core/retired-tool-name-account.js +32 -0
- package/dist/core/roles.d.ts +3 -1
- package/dist/core/roles.js +5 -2
- package/dist/core/runner/compact-session.js +2 -1
- package/dist/core/runner/contracts.d.ts +1 -1
- package/dist/core/runner/gate-exit.js +9 -2
- package/dist/core/runner/memory-consolidation-driver.js +2 -2
- package/dist/core/runner/prepare-config-doors.js +1 -1
- package/dist/core/runner/prepare-delegation-surface.d.ts +1 -1
- package/dist/core/runner/prepare-delegation-surface.js +5 -3
- package/dist/core/runner/prepare-inherited-gate.js +2 -0
- package/dist/core/runner/prepare-memory.js +26 -5
- package/dist/core/runner/prepare-park-ask.d.ts +2 -0
- package/dist/core/runner/prepare-park-ask.js +3 -1
- package/dist/core/runner/prepare-policy-chain.js +2 -1
- package/dist/core/runner/prepare-project-context.js +2 -2
- package/dist/core/runner/prepare-question-face.d.ts +2 -2
- package/dist/core/runner/prepare-task.d.ts +5 -1
- package/dist/core/runner/prepare-task.js +5 -4
- package/dist/core/runner/prepare-wiring-manifest.js +5 -4
- package/dist/core/runner/prompt-suggestions.js +1 -1
- package/dist/core/runner/run-identity-wiring.js +2 -2
- package/dist/core/runner/run-leg.js +3 -3
- package/dist/core/runner/run-notification-lane.d.ts +3 -0
- package/dist/core/runner/run-notification-lane.js +2 -2
- package/dist/core/runner/runtask.js +6 -3
- package/dist/core/runner/steer-admission.d.ts +11 -2
- package/dist/core/runner/stream-steer-verb.d.ts +5 -2
- package/dist/core/runner/stream-steer-verb.js +67 -14
- package/dist/core/runner/sub-agent-deny-lists.d.ts +8 -27
- package/dist/core/runner/sub-agent-deny-lists.js +22 -33
- package/dist/core/runner-deps.d.ts +4 -4
- package/dist/core/shell-run-candidates.js +3 -3
- package/dist/core/side-query.js +1 -1
- package/dist/core/skill-grant.d.ts +7 -0
- package/dist/core/skill-grant.js +14 -5
- package/dist/core/task-event.d.ts +14 -0
- package/dist/core/tool-policy.js +2 -3
- package/dist/core/tool-spec.d.ts +13 -3
- package/dist/core/user-attachment.d.ts +5 -1
- package/dist/core/user-attachment.js +11 -5
- package/dist/engine/harness/agent-harness.d.ts +19 -11
- package/dist/engine/harness/agent-harness.js +7 -4
- package/dist/engine/llm/types.d.ts +22 -10
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -1
- package/dist/shell/lex.d.ts +50 -15
- package/dist/shell/lex.js +43 -9
- package/dist/tools/fs/fs-bash.js +3 -3
- package/dist/tools/fs/removal-targets.d.ts +8 -2
- package/dist/tools/fs/removal-targets.js +31 -4
- package/dist/tools/fs/shell-read-argv.js +7 -1
- package/dist/tools/fs/shell-read-bindings.d.ts +21 -5
- package/dist/tools/fs/shell-read-bindings.js +130 -44
- package/dist/tools/fs/shell-read-plan.js +95 -29
- package/dist/tools/fs/shell-read-sourced.d.ts +25 -0
- package/dist/tools/fs/shell-read-sourced.js +119 -0
- package/dist/tools/fs/shell-read-word.d.ts +2 -2
- package/dist/tools/fs/shell-read-word.js +4 -5
- package/dist/tools/fs/shell-read-workdir.d.ts +19 -3
- package/dist/tools/fs/shell-read-workdir.js +60 -15
- package/dist/tools/fs/shell-reentry-text.d.ts +10 -2
- package/dist/tools/fs/shell-reentry-text.js +11 -4
- package/package.json +2 -2
- package/test/export-surface.snapshot.json +13 -7
- package/wire-changes/core-stores-sql@7.66.0.json +30 -0
- package/wire-changes/core-stores-sql@7.66.1.json +30 -0
- package/wire-changes/core@7.66.0.json +1218 -0
- package/wire-changes/core@7.66.1.json +46 -0
- package/wire-changes/mods-kernel@7.66.0.json +65 -0
- package/wire-changes/mods-kernel@7.66.1.json +30 -0
- package/wire-changes/primitives@7.66.0.json +30 -0
- package/wire-changes/primitives@7.66.1.json +30 -0
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export { formatToolError, formatZodValidationError, formatValidationPath, trunca
|
|
|
25
25
|
export type { WorkerErrorClass } from "./core/tool-errors.js";
|
|
26
26
|
export { webFetchToolSpec, htmlToText, type WebFetchConfig, createWebSearchTool, type WebSearchConfig, createSearxngSearchBackend, probeSearchBackend, type SearxngBackendOptions, createWebFetchSummarizer, WEBFETCH_SUMMARY_MAX_CONTENT, WEBFETCH_SUMMARY_GUIDELINES, } from "./tools/web.js";
|
|
27
27
|
export { compileHostFloor, type HostFloor, type HostFloorDeclaration, type HostFloorPosture, type HostFloorReach } from "./core/host-floor.js";
|
|
28
|
+
export { hostOfUrl, HOST_UNREADABLE_SENTENCE, type HostReading, type HostUnreadableReason } from "./core/host-target.js";
|
|
28
29
|
export { createTodoWriteTool } from "./tools/todo.js";
|
|
29
30
|
export { ARTIFACT_ACTIONS, ARTIFACT_PLANES, ARTIFACT_COMMIT_CERTAINTIES, ARTIFACT_COMMIT_THROW_OUTCOME, ARTIFACT_PUBLISH_CONTEXTS, ARTIFACT_LIST_SCOPES, ARTIFACT_PLANE_CONTENT_ORIGIN, ARTIFACT_ACTION_HOST_METHOD, ARTIFACT_ACTION_CONCURRENCY_SAFE, ARTIFACT_HOST_FAILURE_CODES, ARTIFACT_FAILURE_RESULT_CODE, ARTIFACT_HOST_ERROR_CODE, readArtifactHostCapabilities, type ArtifactAction, type ArtifactPlane, type ArtifactCommitCertainty, type ArtifactPublishContext, type ArtifactListScope, type ArtifactHostFailureCode, type ArtifactResultCode, type ArtifactHost, type ArtifactHostCapabilities, type ArtifactHostCapabilitiesVerdict, type ArtifactCallContext, type ArtifactFileContent, type ArtifactPublishRequest, type ArtifactPublishOutcome, type ArtifactConflictSnapshot, type ArtifactListOutcome, type ArtifactReadOutcome, type ArtifactFilesOutcome, type ArtifactFileOutcome, type ArtifactRef, type ArtifactListRow, } from "./core/artifact-host.js";
|
|
30
31
|
export { createArtifactTool, artifactAttemptId, normalizePublishedPath, mediaTypeOf, type ArtifactToolOptions, type ArtifactLocalRead } from "./tools/artifact/artifact-tool.js";
|
|
@@ -174,6 +175,7 @@ export { createSensitivePathPolicy, RECOMMENDED_SENSITIVE_PATTERNS } from "./cor
|
|
|
174
175
|
export { createFsWriteGatePolicy, WRITE_EXEMPT_DIR_COVERS_ROOT_CODE, type FsWriteGatePolicyOptions } from "./core/fs-write-gate-policy.js";
|
|
175
176
|
export { RETIRED_TOOL_NAMES } from "./core/tool-name-aliases.js";
|
|
176
177
|
export { judgeRuleToolName, RULE_TOOL_NAME_VERDICTS, type RuleToolNameVerdict } from "./core/tool-name-aliases.js";
|
|
178
|
+
export { retiredToolNameAccount } from "./core/retired-host-table-account.js";
|
|
177
179
|
export { DEFAULT_SUBAGENT_TOOL_NAME } from "./agents/subagent.js";
|
|
178
180
|
export { renderTaskNotificationXml, RESUPPLIED_FRAME_PREAMBLE, taskNotificationDedupKey, isDelegatedAgentTerminal, isTerminalTaskNotification, TASK_NOTIFICATION_TERMINAL_STATUSES, // the terminal words that predicate reads, as a value: a host's own terminal check reads these, never a second list
|
|
179
181
|
type TaskNotificationTerminalStatus, SystemInjectionQueue, type TaskNotificationPayload, type TaskNotificationStatus, type ExternalNotificationInput, type SystemInjection, type SystemInjectionPriority, type NotificationInjectionOutcome, // the injector's outcome words (`parked_durably` = the session's durable box took the frame)
|
|
@@ -297,7 +299,7 @@ export { adoptLocalDataRoot, ackAdoptionConfig, witnessAdoptionConfig, listAdopt
|
|
|
297
299
|
export { formatHookFeedback, runToolGate, createHookEnvCapabilities, type PersistedRuleHit, type PersistedRuleHitRule, type PersistedRuleUnreadable, type PersistedRuleCoverage, type PersistedRuleAnswer, normalizePersistedRuleHit, type HookInvocationIdentity, type ClassicEventBase, type PreToolUseEvent, type PostToolUseEvent, type PostToolUseFailureEvent, type PostToolBatchEvent, type UserPromptSubmitEvent, type SubagentStartEvent, type StopEvent, type StopFailureEvent, type SessionStartEvent, type SessionEndEvent, type PreCompactEvent, type PostCompactEvent, type StopHookResult, type HookEnvCapabilities, type HookToolOutput, type PreToolUseResult, type PostToolUseResult, type UserPromptSubmitResult, type SubagentStartResult, type HookToolFailure, type PostToolUseFailureResult, type PostToolBatchCall, type PostToolBatchResult, type PreCompactContext, type PreCompactResult, type PostCompactContext, type PermissionDeniedPayload, } from "./core/hooks.js";
|
|
298
300
|
export type { ClassicEventMap, ClassicEventName, ObservedAnswer, EngineModRegistration } from "./core/mods/classic-events.js";
|
|
299
301
|
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";
|
|
300
|
-
export type { AgentSpawnAnswer, EngineDollar, ModelCompleteBlock, SessionAppendAnswer, SessionCompactAnswer, SessionSendAnswer, SessionUsage, SessionVersion, ToolCallAnswer } from "./core/mods/dollar.js";
|
|
302
|
+
export type { AgentSpawnAnswer, EngineDollar, ModelCompleteBlock, PromptSubmitAnswer, SessionAppendAnswer, SessionCompactAnswer, SessionSendAnswer, SessionUsage, SessionVersion, ToolCallAnswer } from "./core/mods/dollar.js";
|
|
301
303
|
export type { ContextOccupancy } from "./core/mods/lifecycle-stations.js";
|
|
302
304
|
export { admitModChain, promptScreenDeclaredBy } from "./core/mods/stations.js";
|
|
303
305
|
export { SESSION_APPEND_DOORS, SESSION_APPEND_ORIGIN_KINDS, type SessionAppendDoor, type SessionAppendOrigin } from "./core/mods/session-append.js";
|
|
@@ -306,7 +308,7 @@ export { SESSION_SEND_ORIGIN_KINDS, type SessionSendOrigin } from "./core/mods/s
|
|
|
306
308
|
export { loadModPackage, type ModPackageHost, type ModPackageRegistration } from "./core/mods/package.js";
|
|
307
309
|
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";
|
|
308
310
|
export { composeMemoryBlock, composeLayeredMemoryBlock, normalizeMemorySpec, type NormalizedMemorySpec, type MemorySpecInput, firstSentence, detectSecret, MEMORY_PROJECT_KEY_ABSENT_REASONS, type MemoryProjectKeyAbsentReason, type MemoryProjectKey, } from "./core/memory.js";
|
|
309
|
-
export { MemoryEngine, FileMemoryEngineBackend, readMemoryLedgerForm, memoryBackendContract, assertMemoryBackendSearchEquivalence, type MemoryBackendContractHooks, memoryGovernanceStoreContract, type MemoryGovernanceStoreContractHooks, 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, supersessionFuseCeiling, DELETION_FUSE_FLOOR, fileGovernanceStore, memoryGovernanceDurability, type MemoryGovernanceDurability, 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_RUN_STOP_REASONS, CONSOLIDATION_WRITE_REFUSED_CODE, 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,
|
|
311
|
+
export { MemoryEngine, FileMemoryEngineBackend, readMemoryLedgerForm, memoryBackendContract, assertMemoryBackendSearchEquivalence, type MemoryBackendContractHooks, memoryGovernanceStoreContract, type MemoryGovernanceStoreContractHooks, 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, supersessionFuseCeiling, DELETION_FUSE_FLOOR, fileGovernanceStore, memoryGovernanceDurability, type MemoryGovernanceDurability, 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_RUN_STOP_REASONS, CONSOLIDATION_WRITE_REFUSED_CODE, 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, 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 ErasureCarrierAnswer, type ErasureCarrierClass, type ErasureCountAnswer, type ErasureSelect, type ErasedBinding, type MemoryErasureAttestation, computeMemoryBundleHash, type MemoryExportBundle, type MemoryImportReport, type MemoryExportSnapshot, type MemoryBundleImportPlan, type BundleChallengeRow, type BundleLineageRow, type BundlePollutedSession, type MemoryBackend, type MemoryGovernanceStore, MEMORY_GOVERNANCE_DOC_NAMES, type MemoryGovernanceDocName, MEMORY_CONTROL_OBJECT_KINDS, type MemoryControlObjectKind, adoptReplicaControlPlane, replicaControlPlaneStrays, type ControlPlaneAdoptionReport, type ReplicaControlPlaneStrays, type MemoryGovernanceDocs, type ConsolidationTx, 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, formatUserLocalScope, formatOrgScope, formatProjScope, formatUserProjScope, isPersonalScope, isReplicableScope, 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, memorySyncStoreOf, carriesCredential, type MemorySyncTransport, type MemorySyncRequestBody, type MemorySyncResponseBody, type MemorySyncClientConflict, type SyncMemoryScopeOptions, type MemorySyncClientResult, memorySyncReportOf, memoryTravelGapOf, type MemorySyncLayerReport, type MemorySyncRoundReport, } from "./core/memory-engine/index.js";
|
|
310
312
|
export { createConsolidationWriteJudge, deliverWriteRefusal, type ConsolidationWriteJudgeInput } from "./core/runner/memory-consolidation-write-judge.js";
|
|
311
313
|
export { STORE_FORM_REFUSAL_CODES, TARGET_OUTSIDE_STORE, SCOPE_HOME_NOT_DIRECTORY, CONTROL_PLANE_LINKS_UNSUPPORTED, SCOPE_HOME_FORMS, type StoreFormRefusalCode, type StoreFormRefusalDetail, type StoreFormRefusal, type ScopeHomeForm } from "./core/memory-engine/layout.js";
|
|
312
314
|
export { resolveMemoryScopeStore, type MemoryScopeStore, type MemoryScopeStoreInput } from "./core/memory-engine/dual-root.js";
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ export { REPORT_FINDINGS_TOOL_NAME } from "./core/runner/synthetic-tools.js";
|
|
|
11
11
|
export { formatToolError, formatZodValidationError, formatValidationPath, truncateError, errorClassOf } from "./core/tool-errors.js";
|
|
12
12
|
export { webFetchToolSpec, htmlToText, createWebSearchTool, createSearxngSearchBackend, probeSearchBackend, createWebFetchSummarizer, WEBFETCH_SUMMARY_MAX_CONTENT, WEBFETCH_SUMMARY_GUIDELINES, } from "./tools/web.js";
|
|
13
13
|
export { compileHostFloor } from "./core/host-floor.js";
|
|
14
|
+
export { hostOfUrl, HOST_UNREADABLE_SENTENCE } from "./core/host-target.js";
|
|
14
15
|
export { createTodoWriteTool } from "./tools/todo.js";
|
|
15
16
|
export { ARTIFACT_ACTIONS, ARTIFACT_PLANES, ARTIFACT_COMMIT_CERTAINTIES, ARTIFACT_COMMIT_THROW_OUTCOME, ARTIFACT_PUBLISH_CONTEXTS, ARTIFACT_LIST_SCOPES, ARTIFACT_PLANE_CONTENT_ORIGIN, ARTIFACT_ACTION_HOST_METHOD, ARTIFACT_ACTION_CONCURRENCY_SAFE, ARTIFACT_HOST_FAILURE_CODES, ARTIFACT_FAILURE_RESULT_CODE, ARTIFACT_HOST_ERROR_CODE, readArtifactHostCapabilities, } from "./core/artifact-host.js";
|
|
16
17
|
export { createArtifactTool, artifactAttemptId, normalizePublishedPath, mediaTypeOf } from "./tools/artifact/artifact-tool.js";
|
|
@@ -138,6 +139,7 @@ export { createSensitivePathPolicy, RECOMMENDED_SENSITIVE_PATTERNS } from "./cor
|
|
|
138
139
|
export { createFsWriteGatePolicy, WRITE_EXEMPT_DIR_COVERS_ROOT_CODE } from "./core/fs-write-gate-policy.js";
|
|
139
140
|
export { RETIRED_TOOL_NAMES } from "./core/tool-name-aliases.js";
|
|
140
141
|
export { judgeRuleToolName, RULE_TOOL_NAME_VERDICTS } from "./core/tool-name-aliases.js";
|
|
142
|
+
export { retiredToolNameAccount } from "./core/retired-host-table-account.js";
|
|
141
143
|
export { DEFAULT_SUBAGENT_TOOL_NAME } from "./agents/subagent.js";
|
|
142
144
|
export { renderTaskNotificationXml, RESUPPLIED_FRAME_PREAMBLE, taskNotificationDedupKey, isDelegatedAgentTerminal, isTerminalTaskNotification, TASK_NOTIFICATION_TERMINAL_STATUSES, SystemInjectionQueue, NOTIFICATION_INJECTION_OUTCOMES, isNotificationInjectionOutcome, SYSTEM_INJECTION_PRIORITIES, isSystemInjectionPriority, steerPriorityOf, injectionLaneOf, AGENT_MESSAGE_TAG, renderAgentMessageFrame, HANDBACK_STATES, COMPACTION_KINDS, DISCARDED_DELIVERY_PATHS, handbackStateOf, terminalFrameFacets, } from "./core/task-notification.js";
|
|
143
145
|
export { TOOL_FAMILIES, TOOL_MOUNT_TAGS, TOOL_APPROVAL_CARDS, TOOL_PATH_ACCESSES, TOOL_PATH_BASES, TOOL_PATH_ABSENCES, TOOL_WIRE_NAME_MAX_CHARS, TOOL_CONTRACT_MAX_CHARS, TOOL_CARD_ID_MAX_CHARS, TOOL_KEY_MAX_CHARS, TOOL_KEYS_MAX, RENDER_HINT_MAX_CHARS, RENDER_HINT_ACTIVITY_MAX_CHARS, RENDER_HINT_MAX_LIST, pathTargetSlotOnly, } from "./core/tool-face.js";
|
|
@@ -234,7 +236,7 @@ export { SESSION_SEND_ORIGIN_KINDS } from "./core/mods/session-send.js";
|
|
|
234
236
|
export { loadModPackage } from "./core/mods/package.js";
|
|
235
237
|
export { CREDENTIAL_REF_KINDS, CREDENTIAL_REF_TRUST, CREDENTIAL_REF_TEXT_MAX, CREDENTIAL_REF_MAP_MAX, CREDENTIAL_REF_PROBLEM_REASONS, readCredentialRef, } from "@sema-agent/primitives";
|
|
236
238
|
export { composeMemoryBlock, composeLayeredMemoryBlock, normalizeMemorySpec, firstSentence, detectSecret, MEMORY_PROJECT_KEY_ABSENT_REASONS, } from "./core/memory.js";
|
|
237
|
-
export { MemoryEngine, FileMemoryEngineBackend, readMemoryLedgerForm, memoryBackendContract, assertMemoryBackendSearchEquivalence, memoryGovernanceStoreContract, 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, supersessionFuseCeiling, DELETION_FUSE_FLOOR, fileGovernanceStore, memoryGovernanceDurability, 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_RUN_STOP_REASONS, CONSOLIDATION_WRITE_REFUSED_CODE, runMemoryConsolidationDriver, isInstructionEntry, MEMORY_INSTRUCTION_TEMPLATE, MEMORY_RECALL_DISCIPLINE, MEMORY_PREFERENCE_DISCIPLINE, MEMORY_READONLY_NOTICE, MEMORY_CAPTURE_OPTOUT_NOTICE, memoryCaptureOptedOutNotice, memoryCaptureOptOutUnpersistedNotice, SESSION_CAPTURE_OPTOUT_DIR,
|
|
239
|
+
export { MemoryEngine, FileMemoryEngineBackend, readMemoryLedgerForm, memoryBackendContract, assertMemoryBackendSearchEquivalence, memoryGovernanceStoreContract, 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, supersessionFuseCeiling, DELETION_FUSE_FLOOR, fileGovernanceStore, memoryGovernanceDurability, 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_RUN_STOP_REASONS, CONSOLIDATION_WRITE_REFUSED_CODE, runMemoryConsolidationDriver, isInstructionEntry, MEMORY_INSTRUCTION_TEMPLATE, MEMORY_RECALL_DISCIPLINE, MEMORY_PREFERENCE_DISCIPLINE, MEMORY_READONLY_NOTICE, MEMORY_CAPTURE_OPTOUT_NOTICE, memoryCaptureOptedOutNotice, memoryCaptureOptOutUnpersistedNotice, SESSION_CAPTURE_OPTOUT_DIR, 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, MEMORY_GOVERNANCE_DOC_NAMES, MEMORY_CONTROL_OBJECT_KINDS, adoptReplicaControlPlane, replicaControlPlaneStrays, SCOPE_SEGMENT_MAX_ENCODED, PROJECT_MARKER_PATH, encodeScopeSegment, decodeScopeSegment, parseScopeKey, formatUserScope, formatUserLocalScope, formatOrgScope, formatProjScope, formatUserProjScope, isPersonalScope, isReplicableScope, 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, memorySyncStoreOf, carriesCredential, memorySyncReportOf, memoryTravelGapOf, } from "./core/memory-engine/index.js";
|
|
238
240
|
export { createConsolidationWriteJudge, deliverWriteRefusal } from "./core/runner/memory-consolidation-write-judge.js";
|
|
239
241
|
export { STORE_FORM_REFUSAL_CODES, TARGET_OUTSIDE_STORE, SCOPE_HOME_NOT_DIRECTORY, CONTROL_PLANE_LINKS_UNSUPPORTED, SCOPE_HOME_FORMS } from "./core/memory-engine/layout.js";
|
|
240
242
|
export { resolveMemoryScopeStore } from "./core/memory-engine/dual-root.js";
|
package/dist/shell/lex.d.ts
CHANGED
|
@@ -132,6 +132,17 @@ export interface AssignmentFact {
|
|
|
132
132
|
readonly form: "scalar" | "compound";
|
|
133
133
|
/** `op === "="` with no subscript and a scalar value: the whole name is settled by this word's text. */
|
|
134
134
|
readonly settlesWholeName: boolean;
|
|
135
|
+
/** Only on a compound value whose every element this lexer read as a word: each element, in order
|
|
136
|
+
* ({@link CompoundElement}). Absent on a compound value it did not read element by element (its `compound_array_value`
|
|
137
|
+
* stands for the whole value). */
|
|
138
|
+
readonly elements?: readonly CompoundElement[];
|
|
139
|
+
}
|
|
140
|
+
/** One element of a compound value `NAME=(…)`: the element as the list's own word (what bash word-expands, its patterns
|
|
141
|
+
* included), and the scalar assignment bash performs for it — `NAME[k]=v` for a keyed element (`[k]=v`, `[k]+=v`), the
|
|
142
|
+
* subscript the shell evaluates; `NAME=v` for any other element. */
|
|
143
|
+
export interface CompoundElement {
|
|
144
|
+
readonly word: LexedWord;
|
|
145
|
+
readonly stored: LexedWord;
|
|
135
146
|
}
|
|
136
147
|
/** An argv word. `raw` is what the SHELL sees (quotes, escapes and substitution text retained); `folded` is what
|
|
137
148
|
* the PROGRAM receives after quote removal, with every substitution replaced by {@link SUBSTITUTION_PLACEHOLDER},
|
|
@@ -165,6 +176,10 @@ export interface LexedRedirect {
|
|
|
165
176
|
/** `<>` opens its target for reading AND writing (creating it), on descriptor 0 unless one is written. */
|
|
166
177
|
readonly op: "<" | ">" | ">>" | "<<<" | "<>" | "&>" | "&>>" | ">&" | "<&";
|
|
167
178
|
readonly fd?: number;
|
|
179
|
+
/** The word right before the operator is a bare `{NAME}` (`{fd}>file`, `{fd}<<EOF`): bash ≥ 4.1 opens a descriptor it picks
|
|
180
|
+
* (never 0) and stores its number in NAME — no argument; bash 3.2 reads `{NAME}` as an argument and the redirection on its
|
|
181
|
+
* default descriptor. The word stays a word token; every reader takes both readings ({@link namesRedirectDescriptor}). */
|
|
182
|
+
readonly allocated?: true;
|
|
168
183
|
readonly target?: LexedWord;
|
|
169
184
|
readonly dup?: string;
|
|
170
185
|
}
|
|
@@ -175,6 +190,10 @@ export interface LexedHeredoc {
|
|
|
175
190
|
readonly delimiter: string;
|
|
176
191
|
readonly quoted: boolean;
|
|
177
192
|
readonly body: string;
|
|
193
|
+
/** The descriptor the body is opened on when the operator carried one (`3<<EOF`); absent = standard input. */
|
|
194
|
+
readonly fd?: number;
|
|
195
|
+
/** `{NAME}<<EOF`: a descriptor bash ≥ 4.1 allocates, standard input to bash 3.2 ({@link LexedRedirect.allocated}). */
|
|
196
|
+
readonly allocated?: true;
|
|
178
197
|
}
|
|
179
198
|
/** A subshell parenthesis, standing alone: structure, not a word. */
|
|
180
199
|
export interface LexedGroup {
|
|
@@ -204,6 +223,14 @@ export interface LexedSegment {
|
|
|
204
223
|
/** The bodies among {@link substitutions} of a function or value substitution (`${ list; }`, `${| list; }`): their list
|
|
205
224
|
* runs in the CURRENT shell, so what it assigns or where it moves outlives the word. Absent when there is none. */
|
|
206
225
|
readonly currentShell?: readonly string[];
|
|
226
|
+
/** The segment stands where a `source` of a file this text wrote stood (#3400): it is the written literal's text, not
|
|
227
|
+
* the text as the shell will read it — whether it runs is not proven (the write may have failed or gone to a device,
|
|
228
|
+
* the printer may be shadowed), so what it binds or where it moves is one more candidate, never a certainty (#3557). */
|
|
229
|
+
readonly spliced?: true;
|
|
230
|
+
/** The `source` segment itself, kept after the segments its written literal was spliced into (#3557): never spliced
|
|
231
|
+
* again. The inserted segments are only {@link spliced} — a `source` among them of a file the inserted text itself
|
|
232
|
+
* wrote splices on the next pass (a guard on `spliced` would hide `. ./inner.sh` inside the spliced text). */
|
|
233
|
+
readonly sourced?: true;
|
|
207
234
|
}
|
|
208
235
|
export interface LexedCommand {
|
|
209
236
|
readonly segments: readonly LexedSegment[];
|
|
@@ -293,18 +320,14 @@ export declare function parameterArithmeticTexts(body: string): {
|
|
|
293
320
|
* its text (`${x:-${a[i]}}`); a parameter, brace or glob text carrying a substitution opener runs what it opens.
|
|
294
321
|
*/
|
|
295
322
|
export declare function expansionHidesRun(e: WordExpansion): boolean;
|
|
296
|
-
/**
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
* auto-background share until the value is read element by element. */
|
|
305
|
-
export declare function compoundValueHidesRun(w: {
|
|
306
|
-
readonly assignment?: AssignmentFact;
|
|
307
|
-
}): boolean;
|
|
323
|
+
/**
|
|
324
|
+
* The words an assignment word stores, each the ONE assignment bash performs: the word itself, or — a compound value
|
|
325
|
+
* `NAME=(…)` the lexer read element by element — each element's scalar assignment ({@link CompoundElement.stored}:
|
|
326
|
+
* `NAME[k]=v` / `NAME=v`); a compound value it did not read that way is the word itself, its `compound_array_value`
|
|
327
|
+
* standing. Every reader of what a word's value runs or cannot be read reads these, so an element is judged exactly as
|
|
328
|
+
* the scalar assignment of the same text (`A=(${P@P})` as `A=${P@P}`, `A=([x]=1)` as `A[x]=1`, `A=("$@")` as `A="$@"`).
|
|
329
|
+
*/
|
|
330
|
+
export declare function assignedWords(w: LexedWord): readonly LexedWord[];
|
|
308
331
|
/** Does the parameter body (`P@P`, `a[i]@P`) carry a transformation that EVALUATES the value — `${P@P}` expands P's value
|
|
309
332
|
* as a prompt string, its parameter, command and arithmetic expansions run (measured on 5.3) — rather than respelling it? */
|
|
310
333
|
export declare function transformEvaluates(body: string): boolean;
|
|
@@ -319,9 +342,21 @@ export declare function parameterRereadsValue(body: string): boolean;
|
|
|
319
342
|
/** Is the arithmetic text (an arithmetic command's interior) provably free of a variable — the same reading
|
|
320
343
|
* {@link expansionHidesRun} gives an arithmetic expansion? */
|
|
321
344
|
export declare function arithmeticTextIsPlain(text: string): boolean;
|
|
322
|
-
/** Does
|
|
323
|
-
*
|
|
324
|
-
|
|
345
|
+
/** Does an assignment word's subscript (`A[x]=v`, an element `[x]=v` read as {@link assignedWords} does) hide a run? An
|
|
346
|
+
* indexed array's subscript is arithmetic bash evaluates as the assignment runs: anything but digits and operators may
|
|
347
|
+
* evaluate a value the text does not show (`x='b[$(…)0]'; A[x]=1`). The deny lanes and auto-background ask it alike. */
|
|
348
|
+
export declare function subscriptHidesRun(w: LexedWord): boolean;
|
|
349
|
+
/** Does a word run a program its text does not show — an expansion that may ({@link expansionHidesRun}: a substitution, a
|
|
350
|
+
* parameter whose evaluation may), an assignment subscript ({@link subscriptHidesRun}) — read on the words an assignment
|
|
351
|
+
* stores ({@link assignedWords}); a compound value the lexer did not read element by element may run anything. The deny
|
|
352
|
+
* lanes' one reading of a word. */
|
|
353
|
+
export declare function wordHidesRun(w: LexedWord): boolean;
|
|
354
|
+
/** Does the word standing right before the token `next` name the descriptor `next` opens (`{fd}>file`, `{fd}<<EOF`) — to bash
|
|
355
|
+
* ≥ 4.1, which allocates it; to bash 3.2 the word is an argument ({@link LexedRedirect.allocated}, the lexer's one reading). */
|
|
356
|
+
export declare function namesRedirectDescriptor(next: LexedToken | undefined): boolean;
|
|
357
|
+
/** The words of a segment that name the descriptor of the redirection after them ({@link namesRedirectDescriptor}): what bash
|
|
358
|
+
* ≥ 4.1's reading of the argv drops (bash 3.2 keeps them as arguments). */
|
|
359
|
+
export declare function descriptorNameWords(segment: LexedSegment): ReadonlySet<LexedWord>;
|
|
325
360
|
/** The text a word's pieces hand the program when every piece is literal; `undefined` when one is an expansion or
|
|
326
361
|
* unresolved. */
|
|
327
362
|
export declare function literalTextOf(pieces: readonly WordPiece[]): string | undefined;
|
package/dist/shell/lex.js
CHANGED
|
@@ -750,8 +750,27 @@ export function expansionHidesRun(e) {
|
|
|
750
750
|
return !PLAIN_ARITHMETIC.test(body);
|
|
751
751
|
return SUBSTITUTION_OPENER.test(body) || (e.kind === "parameter" && (bodyEvaluatesText(body) || parameterRereadsValue(body))) || nestedBodyEvaluatesText(body);
|
|
752
752
|
}
|
|
753
|
-
export function
|
|
754
|
-
|
|
753
|
+
export function assignedWords(w) {
|
|
754
|
+
const elements = w.assignment?.form === "compound" ? w.assignment.elements : undefined;
|
|
755
|
+
return elements !== undefined ? elements.map((e) => e.stored) : [w];
|
|
756
|
+
}
|
|
757
|
+
function compoundElementsOf(name, words) {
|
|
758
|
+
if (words.some((w) => w.assignment?.form === "compound"))
|
|
759
|
+
return undefined;
|
|
760
|
+
const out = [];
|
|
761
|
+
for (const word of words) {
|
|
762
|
+
const keyed = word.raw.startsWith("[") ? scalarAssignmentOf(`${name}${word.raw}`) : undefined;
|
|
763
|
+
const stored = keyed?.assignment?.subscript !== undefined ? keyed : scalarAssignmentOf(`${name}=${word.raw}`);
|
|
764
|
+
if (stored === undefined || (stored !== keyed && stored.assignment?.subscript !== undefined))
|
|
765
|
+
return undefined;
|
|
766
|
+
out.push({ word, stored });
|
|
767
|
+
}
|
|
768
|
+
return out;
|
|
769
|
+
}
|
|
770
|
+
function scalarAssignmentOf(text) {
|
|
771
|
+
const lexed = lexShell(text);
|
|
772
|
+
const argv = "parseFailure" in lexed || lexed.segments.length !== 1 ? undefined : argvOf(lexed.segments[0]);
|
|
773
|
+
return argv?.length === 1 && argv[0].assignment?.form === "scalar" ? argv[0] : undefined;
|
|
755
774
|
}
|
|
756
775
|
export function transformEvaluates(body) {
|
|
757
776
|
const transform = TRANSFORM_FORM.exec(body)?.[1];
|
|
@@ -764,8 +783,17 @@ export function parameterRereadsValue(body) {
|
|
|
764
783
|
export function arithmeticTextIsPlain(text) {
|
|
765
784
|
return PLAIN_ARITHMETIC.test(text.replace(/\\\n/g, ""));
|
|
766
785
|
}
|
|
767
|
-
export function
|
|
768
|
-
return
|
|
786
|
+
export function subscriptHidesRun(w) {
|
|
787
|
+
return w.assignment?.subscript !== undefined && !arithmeticTextIsPlain(w.assignment.subscript.raw);
|
|
788
|
+
}
|
|
789
|
+
export function wordHidesRun(w) {
|
|
790
|
+
return assignedWords(w).some((e) => e.assignment?.form === "compound" || e.expansions.some((p) => p.expansion !== undefined && expansionHidesRun(p.expansion)) || subscriptHidesRun(e));
|
|
791
|
+
}
|
|
792
|
+
export function namesRedirectDescriptor(next) {
|
|
793
|
+
return (next?.kind === "redirect" || next?.kind === "heredoc") && next.allocated === true;
|
|
794
|
+
}
|
|
795
|
+
export function descriptorNameWords(segment) {
|
|
796
|
+
return new Set(segment.tokens.flatMap((t, i) => (t.kind === "word" && namesRedirectDescriptor(segment.tokens[i + 1]) ? [t] : [])));
|
|
769
797
|
}
|
|
770
798
|
export function literalTextOf(pieces) {
|
|
771
799
|
return pieces.every((q) => q.literal !== undefined) ? pieces.map((q) => q.literal).join("") : undefined;
|
|
@@ -805,6 +833,7 @@ class WordBuilder {
|
|
|
805
833
|
marks = [];
|
|
806
834
|
subscript;
|
|
807
835
|
compound = false;
|
|
836
|
+
elementWords;
|
|
808
837
|
widenedClasses = [];
|
|
809
838
|
begin(src) { if (!this.started)
|
|
810
839
|
this.at = src; }
|
|
@@ -1127,6 +1156,7 @@ class WordBuilder {
|
|
|
1127
1156
|
expansions: valuePieces.filter((p) => p.expansion !== undefined),
|
|
1128
1157
|
...(this.compound ? { unresolved: "compound_array_value" } : {}),
|
|
1129
1158
|
};
|
|
1159
|
+
const elements = this.compound && this.elementWords !== undefined ? compoundElementsOf(name, this.elementWords) : undefined;
|
|
1130
1160
|
let subscript;
|
|
1131
1161
|
if (sub !== undefined) {
|
|
1132
1162
|
const rawFrom = this.rawOfFolded[sub.from] + 1;
|
|
@@ -1142,6 +1172,7 @@ class WordBuilder {
|
|
|
1142
1172
|
bare,
|
|
1143
1173
|
form: this.compound ? "compound" : "scalar",
|
|
1144
1174
|
settlesWholeName: !appends && sub === undefined && !this.compound,
|
|
1175
|
+
...(elements !== undefined ? { elements } : {}),
|
|
1145
1176
|
};
|
|
1146
1177
|
}
|
|
1147
1178
|
isAssignmentHead() {
|
|
@@ -1247,10 +1278,11 @@ function scanText(source, connectorsAreText, segments, level, list) {
|
|
|
1247
1278
|
w = new WordBuilder();
|
|
1248
1279
|
if (pendingHeredoc !== undefined) {
|
|
1249
1280
|
const header = heredocHeaderOf(word, pendingHeredoc.dash);
|
|
1281
|
+
const { fd: heredocFd, allocated } = pendingHeredoc;
|
|
1250
1282
|
pendingHeredoc = undefined;
|
|
1251
1283
|
if (header === undefined)
|
|
1252
1284
|
return fail("heredoc_delimiter_expands", at);
|
|
1253
|
-
const token = { kind: "heredoc", delimiter: header.delimiter, quoted: header.quoted, body: "" };
|
|
1285
|
+
const token = { kind: "heredoc", delimiter: header.delimiter, quoted: header.quoted, body: "", ...(heredocFd !== undefined ? { fd: heredocFd } : {}), ...(allocated === true ? { allocated } : {}) };
|
|
1254
1286
|
current().tokens.push(token);
|
|
1255
1287
|
pendingHeredocs.push({ ...header, token });
|
|
1256
1288
|
if (acceptable) {
|
|
@@ -1262,10 +1294,10 @@ function scanText(source, connectorsAreText, segments, level, list) {
|
|
|
1262
1294
|
return undefined;
|
|
1263
1295
|
}
|
|
1264
1296
|
if (pendingRedirect !== undefined) {
|
|
1265
|
-
const { op, fd } = pendingRedirect;
|
|
1297
|
+
const { op, fd, allocated } = pendingRedirect;
|
|
1266
1298
|
pendingRedirect = undefined;
|
|
1267
1299
|
const target = { ...word, atCommandPosition: false };
|
|
1268
|
-
const written = fd !== undefined ? { fd } : {};
|
|
1300
|
+
const written = fd !== undefined ? { fd } : allocated === true ? { allocated } : {};
|
|
1269
1301
|
if ((op === ">&" || op === "<&") && word.raw === word.folded && /^(?:\d+-?|-)$/.test(word.folded))
|
|
1270
1302
|
current().tokens.push({ kind: "redirect", op, ...written, dup: word.folded });
|
|
1271
1303
|
else
|
|
@@ -1552,6 +1584,7 @@ function scanText(source, connectorsAreText, segments, level, list) {
|
|
|
1552
1584
|
w.mark("compound_array_value", w.raw.length);
|
|
1553
1585
|
w.opaque(text, text, undefined, i, end, undefined);
|
|
1554
1586
|
w.compound = true;
|
|
1587
|
+
w.elementWords = inner.command.segments.every((sg) => sg.tokens.every((t) => t.kind === "word")) ? inner.command.segments.flatMap(argvOf) : undefined;
|
|
1555
1588
|
current().substitutions.push(...inner.command.substitutions);
|
|
1556
1589
|
const runsHere = inner.command.segments.flatMap((s) => s.currentShell ?? []);
|
|
1557
1590
|
if (runsHere.length > 0)
|
|
@@ -1605,6 +1638,7 @@ function scanText(source, connectorsAreText, segments, level, list) {
|
|
|
1605
1638
|
}
|
|
1606
1639
|
if (arithParens === 0 && (ch === "<" || ch === ">" || (ch === "&" && source[n1] === ">"))) {
|
|
1607
1640
|
let fd;
|
|
1641
|
+
const allocated = ch !== "&" && w.started && w.raw === w.folded && /^\{[A-Za-z_][A-Za-z0-9_]*\}$/.test(w.raw);
|
|
1608
1642
|
if (ch !== "&" && w.started && w.raw === w.folded && /^\d+$/.test(w.raw)) {
|
|
1609
1643
|
fd = Number(w.raw);
|
|
1610
1644
|
w = new WordBuilder();
|
|
@@ -1614,7 +1648,7 @@ function scanText(source, connectorsAreText, segments, level, list) {
|
|
|
1614
1648
|
if (r !== undefined)
|
|
1615
1649
|
return r;
|
|
1616
1650
|
}
|
|
1617
|
-
const written = fd !== undefined ? { fd } : {};
|
|
1651
|
+
const written = fd !== undefined ? { fd } : allocated ? { allocated: true } : {};
|
|
1618
1652
|
const n2 = next(n1);
|
|
1619
1653
|
if (ch === "&") {
|
|
1620
1654
|
if (source[n2] === ">") {
|
|
@@ -1634,7 +1668,7 @@ function scanText(source, connectorsAreText, segments, level, list) {
|
|
|
1634
1668
|
continue;
|
|
1635
1669
|
}
|
|
1636
1670
|
const dash = source[n2] === "-";
|
|
1637
|
-
pendingHeredoc = { dash };
|
|
1671
|
+
pendingHeredoc = { dash, ...written };
|
|
1638
1672
|
i = dash ? n2 : n1;
|
|
1639
1673
|
continue;
|
|
1640
1674
|
}
|
package/dist/tools/fs/fs-bash.js
CHANGED
|
@@ -17,7 +17,7 @@ import { resolveBashTimeoutCaps, bashTimeoutCapsSec, bashTimeoutArgRefusal, bash
|
|
|
17
17
|
import { bashClassifyDefaultAllow, BASH_READONLY_DEFAULT_ALLOW, classifyBoundedReadonlyPollLoopDetailed, classifyCompoundReadonlyDetailed, parseLeadingCommandName } from "./bash-readonly-classifier.js";
|
|
18
18
|
import { readOnlyShellVerdict } from "../../core/read-only-shell.js";
|
|
19
19
|
import { toolFace } from "../../core/tool-catalog-entries.js";
|
|
20
|
-
import { argvOf,
|
|
20
|
+
import { argvOf, assignedWords, expansionHidesRun, expansionsInHeredocBody, lexShell, subscriptHidesRun } from "../../shell/lex.js";
|
|
21
21
|
import { arithmeticAssignedNames } from "./shell-read-bindings.js";
|
|
22
22
|
import { thrownText } from "../../core/thrown-value.js";
|
|
23
23
|
import { patternKillRefusal } from "./pattern-kill-guard.js";
|
|
@@ -163,8 +163,8 @@ export function canAutoBackground(command, depth = 0) {
|
|
|
163
163
|
return false;
|
|
164
164
|
const segments = lexed.segments;
|
|
165
165
|
const hidden = (e) => e !== undefined && e.kind !== "command" && e.kind !== "process" && e.kind !== "arithmetic" && expansionHidesRun(e);
|
|
166
|
-
const words = segments.flatMap((s) => s.tokens.flatMap((t) => (t.kind === "word" ?
|
|
167
|
-
if (words.some((w) => w.unresolved === "parameter_text" ||
|
|
166
|
+
const words = segments.flatMap((s) => s.tokens.flatMap((t) => (t.kind === "word" ? assignedWords(t) : t.kind === "redirect" && t.target !== undefined ? [t.target] : [])));
|
|
167
|
+
if (words.some((w) => w.unresolved === "parameter_text" || w.assignment?.form === "compound" || subscriptHidesRun(w) || w.expansions.some((p) => hidden(p.expansion))))
|
|
168
168
|
return false;
|
|
169
169
|
const heredocs = segments.flatMap((s) => s.tokens.flatMap((t) => (t.kind === "heredoc" && !t.quoted ? [expansionsInHeredocBody(t.body)] : [])));
|
|
170
170
|
if (heredocs.some((b) => b === undefined || b.some((x) => x.unresolved !== undefined || hidden(x.expansion))))
|
|
@@ -9,10 +9,16 @@ export type ShellRemovalCommand = (typeof SHELL_REMOVAL_COMMANDS)[number];
|
|
|
9
9
|
/** What makes a removal target dangerous, in the order a card names it. */
|
|
10
10
|
export type DangerousRemovalKind = "filesystem_root" | "home" | "workspace" | "top_level" | "mounted_drive";
|
|
11
11
|
/** The protected locations a removal is judged against. `homes`: the environment's declared home and every other spelling
|
|
12
|
-
* of it (its canonical one); `workspace`: the task root, the working
|
|
12
|
+
* of it (its canonical one); `workspace`: the task root, the additional working directories — and, judged at one removal
|
|
13
|
+
* ({@link removalSeatAt}), the working directory; `startedIn`: the directory the command starts in, the removal's working
|
|
14
|
+
* directory wherever the plan does not prove the removal's shell left it (absent: `workspace` holds every one);
|
|
15
|
+
* `departures`: the plan's working-directory bases PROVEN to stand outside `startedIn` ({@link departuresOf}), by removal
|
|
16
|
+
* key (absent or empty: no base is). */
|
|
13
17
|
export interface RemovalSeat {
|
|
14
18
|
readonly homes: readonly string[];
|
|
15
19
|
readonly workspace: readonly string[];
|
|
20
|
+
readonly startedIn?: string;
|
|
21
|
+
readonly departures?: ReadonlySet<string>;
|
|
16
22
|
}
|
|
17
23
|
/** One dangerous removal a command makes: the removal program, the operand as written, the target as established. */
|
|
18
24
|
export interface DangerousRemoval {
|
|
@@ -87,7 +93,7 @@ export declare const KNOWN_SAFE_ROOTS: readonly string[];
|
|
|
87
93
|
* ({@link runtimeScriptOf}), or one nobody read ({@link unreadPlan}, {@link programUnread}) — is an unreadable text of its
|
|
88
94
|
* own. The read-face copy of an operand is not judged: it follows a link the removal does not follow.
|
|
89
95
|
*/
|
|
90
|
-
export declare function removalFindingsOf(established: EstablishedPlan, seat: RemovalSeat, safeRoots?: readonly string[], enclosingRelocated?: boolean): RemovalFinding[];
|
|
96
|
+
export declare function removalFindingsOf(established: EstablishedPlan, seat: RemovalSeat, safeRoots?: readonly string[], enclosingRelocated?: boolean, apart?: boolean): RemovalFinding[];
|
|
91
97
|
/** Does the removal program refuse this operand by its own first step — its last path component is `.` or `..`, trailing
|
|
92
98
|
* separators stripped (POSIX `rm` step 1, which GNU, BSD and BusyBox `rm` keep; `rmdir(2)` fails on such a component
|
|
93
99
|
* too)? It removes nothing there, wherever the name lands. The name is the one the program RECEIVES: a pattern's match
|
|
@@ -10,6 +10,30 @@ import { declaresOption, implementationsOf, programRow, rowRefusesArgv, runsShel
|
|
|
10
10
|
import { inlineUntrusted } from "../../core/untrusted-text.js";
|
|
11
11
|
export const SHELL_REMOVAL_COMMANDS = Object.freeze(["rm", "rmdir"]);
|
|
12
12
|
const REMOVAL_COMMAND_SET = new Set(SHELL_REMOVAL_COMMANDS);
|
|
13
|
+
function removalSeatAt(seat, plan, segment, apart) {
|
|
14
|
+
const started = seat.startedIn;
|
|
15
|
+
const left = started !== undefined && !apart && segment.bases !== "unmodelled" && segment.bases.length > 0 && segment.bases.every((b) => seat.departures?.has(removalKey(b)) === true) && !plan.shape.backgrounded;
|
|
16
|
+
return { homes: seat.homes, workspace: [...seat.workspace, ...(left || started === undefined ? [] : [started])] };
|
|
17
|
+
}
|
|
18
|
+
function standsWithin(path, dir) {
|
|
19
|
+
const k = removalKey(path);
|
|
20
|
+
const d = removalKey(dir);
|
|
21
|
+
return k === d || k.startsWith(d.endsWith("/") ? d : `${d}/`);
|
|
22
|
+
}
|
|
23
|
+
async function departuresOf(plan, startedIn, env, signal) {
|
|
24
|
+
const start = await resolvedOrUndefined(env.canonicalPath(startedIn, signal), signal);
|
|
25
|
+
const out = new Set();
|
|
26
|
+
if (start === undefined || !start.ok)
|
|
27
|
+
return out;
|
|
28
|
+
for (const base of new Set(plan.segments.flatMap((s) => (s.bases === "unmodelled" ? [] : s.bases)))) {
|
|
29
|
+
if (standsWithin(base, startedIn) || standsWithin(base, start.value))
|
|
30
|
+
continue;
|
|
31
|
+
const canonical = await resolvedOrUndefined(env.canonicalPath(base, signal), signal);
|
|
32
|
+
if (canonical !== undefined && canonical.ok && !standsWithin(canonical.value, start.value))
|
|
33
|
+
out.add(removalKey(base));
|
|
34
|
+
}
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
13
37
|
function removalKey(path) {
|
|
14
38
|
let k = normalizeAbsPathLexically(path.normalize("NFC")).replace(/\\/g, "/").toLowerCase();
|
|
15
39
|
k = k.replace(/(?:\/+\*+)+\/*$/, "");
|
|
@@ -89,7 +113,7 @@ function selectsOptions(row, args, shellChooses, ...wanted) {
|
|
|
89
113
|
return wanted.every((has) => selected.some(has) || (shellChooses && declaresOption(view, has)));
|
|
90
114
|
});
|
|
91
115
|
}
|
|
92
|
-
export function removalFindingsOf(established, seat, safeRoots = KNOWN_SAFE_ROOTS, enclosingRelocated = false) {
|
|
116
|
+
export function removalFindingsOf(established, seat, safeRoots = KNOWN_SAFE_ROOTS, enclosingRelocated = false, apart = false) {
|
|
93
117
|
if (unreadPlan(established.plan))
|
|
94
118
|
return [{ guard: "unverifiable_shell_text", program: "bash", text: established.plan.unreadable, source: "unread" }];
|
|
95
119
|
const out = [];
|
|
@@ -114,7 +138,7 @@ export function removalFindingsOf(established, seat, safeRoots = KNOWN_SAFE_ROOT
|
|
|
114
138
|
continue;
|
|
115
139
|
if (refusedByRemoval(read))
|
|
116
140
|
continue;
|
|
117
|
-
const kind = removalKindOf(read, seat, rm);
|
|
141
|
+
const kind = removalKindOf(read, removalSeatAt(seat, established.plan, segment, apart), rm);
|
|
118
142
|
if (kind !== undefined) {
|
|
119
143
|
const untracked = read.candidate.bases === "unmodelled" ? established.plan.segments.find((s) => s.bases === "unmodelled")?.text.trim() : undefined;
|
|
120
144
|
out.push({ guard: "dangerous_delete", kind, program: removal.program, operand: read.candidate.raw, target: read.target ?? read.candidate.floorSpelled ?? read.candidate.spelled, ...(untracked !== undefined ? { untrackedFrom: untracked } : {}) });
|
|
@@ -141,7 +165,7 @@ export function removalFindingsOf(established, seat, safeRoots = KNOWN_SAFE_ROOT
|
|
|
141
165
|
}
|
|
142
166
|
const sub = established.nested.get(nested);
|
|
143
167
|
if (sub !== undefined)
|
|
144
|
-
out.push(...removalFindingsOf(sub, seat, safeRoots, handedRelocated));
|
|
168
|
+
out.push(...removalFindingsOf(sub, seat, safeRoots, handedRelocated, true));
|
|
145
169
|
}
|
|
146
170
|
}
|
|
147
171
|
return out;
|
|
@@ -238,9 +262,12 @@ export function removalReadingOf(command, req, seat, safeRoots = KNOWN_SAFE_ROOT
|
|
|
238
262
|
async judge(signal) {
|
|
239
263
|
const env = seat?.env;
|
|
240
264
|
const resolved = env !== undefined && homeDir !== undefined ? await resolvedOrUndefined(env.canonicalPath(homeDir, signal), signal) : undefined;
|
|
265
|
+
const departures = env !== undefined && req.cwd !== undefined ? await departuresOf(plan, req.cwd, env, signal) : undefined;
|
|
241
266
|
const removalSeat = {
|
|
242
267
|
homes: [...(homeDir !== undefined ? [homeDir] : []), ...(resolved !== undefined && resolved.ok ? [resolved.value] : [])],
|
|
243
|
-
workspace: [...(req.root !== undefined ? [req.root] : []), ...(
|
|
268
|
+
workspace: [...(req.root !== undefined ? [req.root] : []), ...(seat?.additionalRoots?.() ?? [])],
|
|
269
|
+
...(req.cwd !== undefined ? { startedIn: req.cwd } : {}),
|
|
270
|
+
...(departures !== undefined ? { departures } : {}),
|
|
244
271
|
};
|
|
245
272
|
const lexical = removalFindingsOf(establishShellReadsLexically(plan, boundary), removalSeat, safeRoots);
|
|
246
273
|
if (lexical.some((f) => f.guard === "dangerous_delete") || env === undefined || roots.length === 0)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { literalTildeSpelling } from "../../shell/lex.js";
|
|
1
|
+
import { assignedWords, literalTildeSpelling } from "../../shell/lex.js";
|
|
2
2
|
import { expandsOf, globMark, partPattern, readOfText, receivedWordOf, rewritten, spellingOf } from "./shell-read-word.js";
|
|
3
3
|
import { arithmeticSubstitutions, bindsArrayElement, judgedSpellingOf, wordValues } from "./shell-read-bindings.js";
|
|
4
4
|
import { argvProgramOf, attachedOptionPayloads, isPathShapedToken } from "./bash-readonly-classifier.js";
|
|
@@ -546,6 +546,12 @@ export function subscriptOnly(word) {
|
|
|
546
546
|
return at < 0 ? "" : word.slice(at);
|
|
547
547
|
}
|
|
548
548
|
export function assignmentArithmetic(w, integer, ctx, asWritten = false) {
|
|
549
|
+
const stored = assignedWords(w);
|
|
550
|
+
if (stored[0] !== w) {
|
|
551
|
+
for (const e of stored)
|
|
552
|
+
assignmentArithmetic(e, integer, ctx, asWritten);
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
549
555
|
const a = w.assignment;
|
|
550
556
|
if (a === undefined) {
|
|
551
557
|
if (!asWritten)
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
import { type LexedRedirect, type LexedSegment, type LexedToken, type LexedWord } from "../../shell/lex.js";
|
|
30
30
|
import { readProgramPosition } from "./bash-program-position.js";
|
|
31
31
|
import { type DeclaredAttribute } from "./program-read-model.js";
|
|
32
|
+
import { type StdinText } from "./shell-reentry-text.js";
|
|
32
33
|
import { type BuiltinState } from "./shell-read-builtins.js";
|
|
33
34
|
/** A value a name may hold — the text the program receives ({@link spelled}: what a shell re-parsing it reads), literal
|
|
34
35
|
* throughout, or a PATTERN whose matches are the values (a `for` list word the shell globs before the loop binds it;
|
|
@@ -64,6 +65,9 @@ export interface FloorValue {
|
|
|
64
65
|
readonly glob?: true;
|
|
65
66
|
/** A pattern's spelling as a reader judges the names it matches, where it is not `spelled` ({@link judgedSpellingOf}). */
|
|
66
67
|
readonly pattern?: string;
|
|
68
|
+
/** A value a binding that may not have run left an unknown name (#3536, {@link BindingTable.floorOf}): it yields to the
|
|
69
|
+
* floor reader's bound before any other ({@link wordFloorValues}). */
|
|
70
|
+
readonly held?: true;
|
|
67
71
|
}
|
|
68
72
|
/** A pattern value's names as a reader judges them, where that is not its spelling: its runs, a class the judge widens
|
|
69
73
|
* as `?` (the lexer's `WordExpansion.pattern.judged`), a leading `~` the literal tilde it is. */
|
|
@@ -140,7 +144,8 @@ export declare function inheritedFunctionsOf(segments: readonly {
|
|
|
140
144
|
export declare function inheritedExportedFunctions(names: ReadonlyMap<string, InheritedBody>): InheritedFunctions;
|
|
141
145
|
/** One binding a segment makes: a name and what it now holds (`unknown` = made unknown). `prefix`: a binding that may or
|
|
142
146
|
* may not take effect (a prefix assignment to a special builtin, which may or may not outlive its command; an `unset` of a
|
|
143
|
-
* function, which a read-only function refuses). `loopVar`: a `for` loop's variable
|
|
147
|
+
* function, which a read-only function refuses). `loopVar`: a `for` loop's variable — or the name a loop head's `read` binds
|
|
148
|
+
* from a literal input (#3401) — held through its body. */
|
|
144
149
|
export interface Binding {
|
|
145
150
|
readonly name: string;
|
|
146
151
|
readonly state: NameState;
|
|
@@ -242,7 +247,7 @@ export declare function loopListHeadAt(argv: readonly LexedWord[]): number | und
|
|
|
242
247
|
* more value its names may hold). `availability`: whether the builtin of a name runs by it where the segment stands
|
|
243
248
|
* ({@link BuiltinState}) — `disabled`: the word finds no command and binds nothing, `maybe`: as a function that may stand.
|
|
244
249
|
*/
|
|
245
|
-
export declare function bindingEffectOf(segment: LexedSegment, argv: readonly LexedWord[], shape: SegmentShape, readValue: ValueReader, shadow?: "named" | "maybe", availability?: (builtin: string) => BuiltinState): BindingEffect;
|
|
250
|
+
export declare function bindingEffectOf(segment: LexedSegment, argv: readonly LexedWord[], shape: SegmentShape, readValue: ValueReader, shadow?: "named" | "maybe", availability?: (builtin: string) => BuiltinState, fed?: readonly StdinText[], fedByLoop?: boolean): BindingEffect;
|
|
246
251
|
/** Does this assignment store ARRAY ELEMENTS — a compound value `(…)`, or a subscripted name `a[k]=v`? Bash never exports
|
|
247
252
|
* an array (an element assigned to an exported scalar makes it an array, gone from every child's environment): what it
|
|
248
253
|
* stores reaches a program only through a word that reads an element — the element floor it leaves here ({@link
|
|
@@ -433,6 +438,12 @@ export declare class BindingThread {
|
|
|
433
438
|
/** The names any of the text's function bodies binds — what a call to one of them may change — or `all` where a body
|
|
434
439
|
* may bind any name. A name the body keeps `local` ({@link leavesBody}) stays in it. */
|
|
435
440
|
functionBound(): ReadonlySet<string> | "all";
|
|
441
|
+
/** Of {@link functionBound}, the names a call MAY leave as they were: the body binds them where the binding may not have run
|
|
442
|
+
* — a `prefix` (a builtin that may not run as the builtin, a declaration behind a launcher) or a segment of SPLICED text
|
|
443
|
+
* (#3557: the sourced literal may never have run, so neither did the definition). A call kills these as one more value the
|
|
444
|
+
* name may hold (detached), never as a certainty — the value before the call stays the deny floor (#3536's law; #3566).
|
|
445
|
+
* A name the body ALSO binds certainly is not here: that binding makes the call's kill certain. */
|
|
446
|
+
functionMaybeBound(): ReadonlySet<string>;
|
|
436
447
|
/** The function body a binding segment `at` makes belongs to, where the name can outlive it: the body it stands in — a
|
|
437
448
|
* plain `local NAME` is the body's own and never leaves it (an optioned declaration, `declare -g` / `local -p`, reads no
|
|
438
449
|
* scope, so it can). What a reader in ANOTHER body loses ({@link unreadableBy}); a call to the body changes it unless a
|
|
@@ -469,14 +480,15 @@ export declare class BindingThread {
|
|
|
469
480
|
/** Does the block that holds a binding's words stay open (no closing word, no switch of branch) through `j`? */
|
|
470
481
|
private heldThrough;
|
|
471
482
|
/** Apply segment `at`'s effect. `andRun`: the segment was reached through `&&` / `||`. `loopEnd`: for a loop variable,
|
|
472
|
-
* the index of the loop's end.
|
|
473
|
-
|
|
483
|
+
* the index of the loop's end. `spliced`: the segment is a sourced literal's text standing in for its `source` (#3557):
|
|
484
|
+
* it may not have run, so every binding it makes is {@link Entry.detached} — one more value, never a certainty. */
|
|
485
|
+
apply(at: number, effect: BindingEffect, andRun: boolean, loopEnd?: number, spliced?: boolean): void;
|
|
474
486
|
/** Does a reader at segment `j` lose the name `u` makes unreadable: past a name reference it may run after, or in a
|
|
475
487
|
* function body other than the one that binds it? */
|
|
476
488
|
private lostAt;
|
|
477
489
|
/** Make these names unknown from segment `at` on (a loop body that binds them may have run before any of its beats; a
|
|
478
490
|
* call runs a body that binds them). */
|
|
479
|
-
kill(at: number, names: Iterable<string> | "all"): void;
|
|
491
|
+
kill(at: number, names: Iterable<string> | "all", spliced?: boolean): void;
|
|
480
492
|
/** The table a reader at segment `j` sees; `andRunStart` = the first segment of `j`'s `&&` run; `where` = what the
|
|
481
493
|
* working-directory thread says `PWD` / `OLDPWD` hold there (absent: it does not say — both unknown). */
|
|
482
494
|
tableAt(j: number, andRunStart: number, where?: WorkingDirectoryState): BindingTable;
|
|
@@ -506,3 +518,7 @@ export declare function arithmeticSubstitutions(text: string, table: BindingTabl
|
|
|
506
518
|
}): string[];
|
|
507
519
|
/** The text of every `[…]` subscript in an arithmetic text (nested brackets balanced; an unclosed one runs to the end). */
|
|
508
520
|
export declare function subscriptsOf(text: string): string[];
|
|
521
|
+
/** The substitution bodies a subscript's text carries, its quotes removed first (the evaluator sees the text without
|
|
522
|
+
* them; `keepQuotes` = the shell expands the text as it stands); a text the lexer refuses is returned whole (a body
|
|
523
|
+
* nothing could read is still re-entered). */
|
|
524
|
+
export declare function substitutionBodies(subscript: string, keepQuotes?: boolean): string[];
|