@theokit/sdk 4.49.0 → 4.50.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 +6 -0
- package/dist/index.cjs +56 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +82 -1
- package/dist/index.d.ts +82 -1
- package/dist/index.js +55 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2019,6 +2019,87 @@ type MutableEnv = Record<string, string | undefined>;
|
|
|
2019
2019
|
*/
|
|
2020
2020
|
declare function loadProjectEnv(env?: MutableEnv, load?: (() => void) | undefined): void;
|
|
2021
2021
|
|
|
2022
|
+
/**
|
|
2023
|
+
* Decide which session artifacts may be deleted — and never delete them.
|
|
2024
|
+
*
|
|
2025
|
+
* This package creates session artifacts (transcripts, locks, temp files) and cleans up only what is
|
|
2026
|
+
* in flight in the operation doing the cleaning: a lock it just released, a `.tmp` from a failed
|
|
2027
|
+
* atomic write. Nothing collects the rest, so every consumer either writes its own collector or lets
|
|
2028
|
+
* the directory grow without bound — and a hand-rolled collector on the path that deletes a user's
|
|
2029
|
+
* transcript is the worst place for each product to learn the same lessons separately.
|
|
2030
|
+
*
|
|
2031
|
+
* ## Planning is not deleting, deliberately
|
|
2032
|
+
*
|
|
2033
|
+
* A function that decided AND deleted could not be tested without a filesystem, and the case that
|
|
2034
|
+
* matters most — "we could not establish whether this session is live" — would have to be simulated
|
|
2035
|
+
* rather than asserted. Here the decision is pure: the plan IS the dry run, and executing it is a
|
|
2036
|
+
* separate act on a value someone can read first. That separation is the dry-run guarantee, rather
|
|
2037
|
+
* than a flag that has to be remembered.
|
|
2038
|
+
*
|
|
2039
|
+
* ## The tri-state
|
|
2040
|
+
*
|
|
2041
|
+
* `keep`, `reap`, `undetermined`. An artifact whose liveness could not be established is never
|
|
2042
|
+
* reaped and never quietly counted as dead. Collapsing "could not determine" into "not there" is how
|
|
2043
|
+
* a collector deletes a session running on another machine, or behind a mount that answered slowly.
|
|
2044
|
+
* The third bucket costs a branch and buys the only guarantee worth having on this path.
|
|
2045
|
+
*
|
|
2046
|
+
* @public
|
|
2047
|
+
*/
|
|
2048
|
+
|
|
2049
|
+
/** Raised when a retention policy cannot be honoured as written. @public */
|
|
2050
|
+
declare class RetentionPolicyError extends TheokitAgentError {
|
|
2051
|
+
readonly name = "RetentionPolicyError";
|
|
2052
|
+
}
|
|
2053
|
+
/** @public */
|
|
2054
|
+
interface ReapableArtifact {
|
|
2055
|
+
readonly id: string;
|
|
2056
|
+
/** Epoch milliseconds. Compared against an injected `nowMs`, never against a read clock. */
|
|
2057
|
+
readonly lastModifiedMs: number;
|
|
2058
|
+
/**
|
|
2059
|
+
* Whether a writer still holds this artifact. `"unknown"` when the caller could not establish it —
|
|
2060
|
+
* a stale lock behind a slow mount, a PID on another host — and it is honoured as a third answer
|
|
2061
|
+
* rather than folded into `false`.
|
|
2062
|
+
*/
|
|
2063
|
+
readonly live: boolean | "unknown";
|
|
2064
|
+
}
|
|
2065
|
+
/** @public */
|
|
2066
|
+
interface RetentionPolicy {
|
|
2067
|
+
/** Artifacts strictly older than this are candidates. The boundary itself is kept. */
|
|
2068
|
+
readonly maxAgeMs: number;
|
|
2069
|
+
/**
|
|
2070
|
+
* A FLOOR on how many artifacts survive: "you will always have your last N sessions". When
|
|
2071
|
+
* liveness and the retention window already spare N or more, this changes nothing; when they
|
|
2072
|
+
* spare fewer, the newest of the remainder are spared until the count reaches N.
|
|
2073
|
+
*
|
|
2074
|
+
* Undetermined artifacts do NOT count toward the floor. Their liveness was never established, so
|
|
2075
|
+
* counting them would let a transient mount failure satisfy the floor with artifacts nobody
|
|
2076
|
+
* confirmed exist as sessions — and quietly delete the ones that do.
|
|
2077
|
+
*/
|
|
2078
|
+
readonly keepLast: number;
|
|
2079
|
+
}
|
|
2080
|
+
/** Why an artifact survived. @public */
|
|
2081
|
+
type KeepReason = "live" | "within-retention" | "keep-last";
|
|
2082
|
+
/** @public */
|
|
2083
|
+
interface KeptArtifact extends ReapableArtifact {
|
|
2084
|
+
readonly reason: KeepReason;
|
|
2085
|
+
}
|
|
2086
|
+
/** @public */
|
|
2087
|
+
interface ReapPlan {
|
|
2088
|
+
/** Safe to delete. Everything here was decided, not defaulted. */
|
|
2089
|
+
readonly reap: readonly ReapableArtifact[];
|
|
2090
|
+
readonly keep: readonly KeptArtifact[];
|
|
2091
|
+
/** Liveness could not be established. Never deleted, never counted as kept. */
|
|
2092
|
+
readonly undetermined: readonly ReapableArtifact[];
|
|
2093
|
+
}
|
|
2094
|
+
/** @public */
|
|
2095
|
+
interface ReapPlanInput {
|
|
2096
|
+
readonly artifacts: readonly ReapableArtifact[];
|
|
2097
|
+
readonly retention: RetentionPolicy;
|
|
2098
|
+
/** Injected so the plan is reproducible and testable; this module never reads a clock. */
|
|
2099
|
+
readonly nowMs: number;
|
|
2100
|
+
}
|
|
2101
|
+
declare function planReaping(input: ReapPlanInput): ReapPlan;
|
|
2102
|
+
|
|
2022
2103
|
/** The internal JSON-Schema shape the synthetic `output` tool consumes. */
|
|
2023
2104
|
type NormalizedJsonSchema = Record<string, unknown>;
|
|
2024
2105
|
/**
|
|
@@ -2892,4 +2973,4 @@ interface WiringRecordInput<K extends string> {
|
|
|
2892
2973
|
*/
|
|
2893
2974
|
declare function recordWiring<K extends string>(input: WiringRecordInput<K>): Readonly<Record<K, WiredEntity>>;
|
|
2894
2975
|
|
|
2895
|
-
export { Agent, AgentBuilder, AgentDefinition, AgentDescription, AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, type CounterBudgetTrackerOptions, CustomTool, type DeclaredLayer, type DeepPartial, type DefineProviderOptions, type DefineToolSpec, type DiagnosticsSink, type DreamingSweepOptions, type DreamingSweepResult, type EnvOptOut, type EnvReachabilityAudit, type EnvReachabilityInput, ErrorMetadata, EventBus, type EvictReason, GOAL_CONTINUATION_MARKER, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, GoalEvent, type GoalLoopAgent, GoalOptions, GoalResult, InlineSkill, JobQueue, type JobQueueOptions, JudgeCredentialError, JudgeResult, LayerOrderError, type LayerValues, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, NoopMemoryProvider, type NormalizedJsonSchema, PermissionEngine, type PermissionGate, type PermissionGateContext, type PermissionGateDecision, PermissionMode, PermissionPlugin, type PermissionPluginOptions, Plugin, PluginsSettings, PreToolCallDecision, Processor, Provider, ProviderProfile, ProviderRoutingSettings, Run, RunEventSink, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, SOVEREIGN_ENV_KEYS, Security, type SecurityFloorInput, type SessionMessage, type SessionMessagePart, type SessionScope, type ShareGptMessage, type ShareGptTrajectory, SkillReadTool, SkillsSettings, type SovereignEnvKey, Squad, type SquadOptions, type SquadRun, StreamObjectError, type StreamObjectEvent, type StreamObjectOptions, SystemPromptResolver, TASK_RESERVED_PREFIXES, Task, type TaskCancelResult, type TaskConfigureOptions, type TaskEvent, type TaskFilter, type TaskHandle, type TaskKind, type TaskState, type TaskStoreOptions, type TaskSubmitOptions, type TaskWorkContext, type TaskWorkFn, Theokit, TheokitAgentError, type TheokitRequestOptions, TokenLimiter, type TokenLimiterOptions, Tool, ToolError, ToolResultContentBlock, type TrustLevel, type TrustPosture, type TrustPostureInput, type TrustSource, UngatedCapabilityError, UnicodeNormalizer, type UnicodeNormalizerOptions, UsageAccumulator, type WiredEntity, type WiringRecordInput, applySecurityFloor, auditEnvReachability, chargeAndCheckThresholds, computeCost, createCounterBudgetTracker, estimateTokens, extractRawId, foldLayers, getPricingEntry, inferApiMode, isValidTaskId, loadProjectEnv, migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, preflightCheck, recordWiring, resolveTrustPosture, runGoalLoop, scopedConversationId, sessionScopePrefix, setDiagnosticsSink, toShareGptTrajectory, verifyLayerOrdering, withCwdMutex };
|
|
2976
|
+
export { Agent, AgentBuilder, AgentDefinition, AgentDescription, AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, type CounterBudgetTrackerOptions, CustomTool, type DeclaredLayer, type DeepPartial, type DefineProviderOptions, type DefineToolSpec, type DiagnosticsSink, type DreamingSweepOptions, type DreamingSweepResult, type EnvOptOut, type EnvReachabilityAudit, type EnvReachabilityInput, ErrorMetadata, EventBus, type EvictReason, GOAL_CONTINUATION_MARKER, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, GoalEvent, type GoalLoopAgent, GoalOptions, GoalResult, InlineSkill, JobQueue, type JobQueueOptions, JudgeCredentialError, JudgeResult, type KeepReason, type KeptArtifact, LayerOrderError, type LayerValues, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, NoopMemoryProvider, type NormalizedJsonSchema, PermissionEngine, type PermissionGate, type PermissionGateContext, type PermissionGateDecision, PermissionMode, PermissionPlugin, type PermissionPluginOptions, Plugin, PluginsSettings, PreToolCallDecision, Processor, Provider, ProviderProfile, ProviderRoutingSettings, type ReapPlan, type ReapPlanInput, type ReapableArtifact, type RetentionPolicy, RetentionPolicyError, Run, RunEventSink, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, SOVEREIGN_ENV_KEYS, Security, type SecurityFloorInput, type SessionMessage, type SessionMessagePart, type SessionScope, type ShareGptMessage, type ShareGptTrajectory, SkillReadTool, SkillsSettings, type SovereignEnvKey, Squad, type SquadOptions, type SquadRun, StreamObjectError, type StreamObjectEvent, type StreamObjectOptions, SystemPromptResolver, TASK_RESERVED_PREFIXES, Task, type TaskCancelResult, type TaskConfigureOptions, type TaskEvent, type TaskFilter, type TaskHandle, type TaskKind, type TaskState, type TaskStoreOptions, type TaskSubmitOptions, type TaskWorkContext, type TaskWorkFn, Theokit, TheokitAgentError, type TheokitRequestOptions, TokenLimiter, type TokenLimiterOptions, Tool, ToolError, ToolResultContentBlock, type TrustLevel, type TrustPosture, type TrustPostureInput, type TrustSource, UngatedCapabilityError, UnicodeNormalizer, type UnicodeNormalizerOptions, UsageAccumulator, type WiredEntity, type WiringRecordInput, applySecurityFloor, auditEnvReachability, chargeAndCheckThresholds, computeCost, createCounterBudgetTracker, estimateTokens, extractRawId, foldLayers, getPricingEntry, inferApiMode, isValidTaskId, loadProjectEnv, migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, planReaping, preflightCheck, recordWiring, resolveTrustPosture, runGoalLoop, scopedConversationId, sessionScopePrefix, setDiagnosticsSink, toShareGptTrajectory, verifyLayerOrdering, withCwdMutex };
|
package/dist/index.d.ts
CHANGED
|
@@ -2019,6 +2019,87 @@ type MutableEnv = Record<string, string | undefined>;
|
|
|
2019
2019
|
*/
|
|
2020
2020
|
declare function loadProjectEnv(env?: MutableEnv, load?: (() => void) | undefined): void;
|
|
2021
2021
|
|
|
2022
|
+
/**
|
|
2023
|
+
* Decide which session artifacts may be deleted — and never delete them.
|
|
2024
|
+
*
|
|
2025
|
+
* This package creates session artifacts (transcripts, locks, temp files) and cleans up only what is
|
|
2026
|
+
* in flight in the operation doing the cleaning: a lock it just released, a `.tmp` from a failed
|
|
2027
|
+
* atomic write. Nothing collects the rest, so every consumer either writes its own collector or lets
|
|
2028
|
+
* the directory grow without bound — and a hand-rolled collector on the path that deletes a user's
|
|
2029
|
+
* transcript is the worst place for each product to learn the same lessons separately.
|
|
2030
|
+
*
|
|
2031
|
+
* ## Planning is not deleting, deliberately
|
|
2032
|
+
*
|
|
2033
|
+
* A function that decided AND deleted could not be tested without a filesystem, and the case that
|
|
2034
|
+
* matters most — "we could not establish whether this session is live" — would have to be simulated
|
|
2035
|
+
* rather than asserted. Here the decision is pure: the plan IS the dry run, and executing it is a
|
|
2036
|
+
* separate act on a value someone can read first. That separation is the dry-run guarantee, rather
|
|
2037
|
+
* than a flag that has to be remembered.
|
|
2038
|
+
*
|
|
2039
|
+
* ## The tri-state
|
|
2040
|
+
*
|
|
2041
|
+
* `keep`, `reap`, `undetermined`. An artifact whose liveness could not be established is never
|
|
2042
|
+
* reaped and never quietly counted as dead. Collapsing "could not determine" into "not there" is how
|
|
2043
|
+
* a collector deletes a session running on another machine, or behind a mount that answered slowly.
|
|
2044
|
+
* The third bucket costs a branch and buys the only guarantee worth having on this path.
|
|
2045
|
+
*
|
|
2046
|
+
* @public
|
|
2047
|
+
*/
|
|
2048
|
+
|
|
2049
|
+
/** Raised when a retention policy cannot be honoured as written. @public */
|
|
2050
|
+
declare class RetentionPolicyError extends TheokitAgentError {
|
|
2051
|
+
readonly name = "RetentionPolicyError";
|
|
2052
|
+
}
|
|
2053
|
+
/** @public */
|
|
2054
|
+
interface ReapableArtifact {
|
|
2055
|
+
readonly id: string;
|
|
2056
|
+
/** Epoch milliseconds. Compared against an injected `nowMs`, never against a read clock. */
|
|
2057
|
+
readonly lastModifiedMs: number;
|
|
2058
|
+
/**
|
|
2059
|
+
* Whether a writer still holds this artifact. `"unknown"` when the caller could not establish it —
|
|
2060
|
+
* a stale lock behind a slow mount, a PID on another host — and it is honoured as a third answer
|
|
2061
|
+
* rather than folded into `false`.
|
|
2062
|
+
*/
|
|
2063
|
+
readonly live: boolean | "unknown";
|
|
2064
|
+
}
|
|
2065
|
+
/** @public */
|
|
2066
|
+
interface RetentionPolicy {
|
|
2067
|
+
/** Artifacts strictly older than this are candidates. The boundary itself is kept. */
|
|
2068
|
+
readonly maxAgeMs: number;
|
|
2069
|
+
/**
|
|
2070
|
+
* A FLOOR on how many artifacts survive: "you will always have your last N sessions". When
|
|
2071
|
+
* liveness and the retention window already spare N or more, this changes nothing; when they
|
|
2072
|
+
* spare fewer, the newest of the remainder are spared until the count reaches N.
|
|
2073
|
+
*
|
|
2074
|
+
* Undetermined artifacts do NOT count toward the floor. Their liveness was never established, so
|
|
2075
|
+
* counting them would let a transient mount failure satisfy the floor with artifacts nobody
|
|
2076
|
+
* confirmed exist as sessions — and quietly delete the ones that do.
|
|
2077
|
+
*/
|
|
2078
|
+
readonly keepLast: number;
|
|
2079
|
+
}
|
|
2080
|
+
/** Why an artifact survived. @public */
|
|
2081
|
+
type KeepReason = "live" | "within-retention" | "keep-last";
|
|
2082
|
+
/** @public */
|
|
2083
|
+
interface KeptArtifact extends ReapableArtifact {
|
|
2084
|
+
readonly reason: KeepReason;
|
|
2085
|
+
}
|
|
2086
|
+
/** @public */
|
|
2087
|
+
interface ReapPlan {
|
|
2088
|
+
/** Safe to delete. Everything here was decided, not defaulted. */
|
|
2089
|
+
readonly reap: readonly ReapableArtifact[];
|
|
2090
|
+
readonly keep: readonly KeptArtifact[];
|
|
2091
|
+
/** Liveness could not be established. Never deleted, never counted as kept. */
|
|
2092
|
+
readonly undetermined: readonly ReapableArtifact[];
|
|
2093
|
+
}
|
|
2094
|
+
/** @public */
|
|
2095
|
+
interface ReapPlanInput {
|
|
2096
|
+
readonly artifacts: readonly ReapableArtifact[];
|
|
2097
|
+
readonly retention: RetentionPolicy;
|
|
2098
|
+
/** Injected so the plan is reproducible and testable; this module never reads a clock. */
|
|
2099
|
+
readonly nowMs: number;
|
|
2100
|
+
}
|
|
2101
|
+
declare function planReaping(input: ReapPlanInput): ReapPlan;
|
|
2102
|
+
|
|
2022
2103
|
/** The internal JSON-Schema shape the synthetic `output` tool consumes. */
|
|
2023
2104
|
type NormalizedJsonSchema = Record<string, unknown>;
|
|
2024
2105
|
/**
|
|
@@ -2892,4 +2973,4 @@ interface WiringRecordInput<K extends string> {
|
|
|
2892
2973
|
*/
|
|
2893
2974
|
declare function recordWiring<K extends string>(input: WiringRecordInput<K>): Readonly<Record<K, WiredEntity>>;
|
|
2894
2975
|
|
|
2895
|
-
export { Agent, AgentBuilder, AgentDefinition, AgentDescription, AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, type CounterBudgetTrackerOptions, CustomTool, type DeclaredLayer, type DeepPartial, type DefineProviderOptions, type DefineToolSpec, type DiagnosticsSink, type DreamingSweepOptions, type DreamingSweepResult, type EnvOptOut, type EnvReachabilityAudit, type EnvReachabilityInput, ErrorMetadata, EventBus, type EvictReason, GOAL_CONTINUATION_MARKER, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, GoalEvent, type GoalLoopAgent, GoalOptions, GoalResult, InlineSkill, JobQueue, type JobQueueOptions, JudgeCredentialError, JudgeResult, LayerOrderError, type LayerValues, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, NoopMemoryProvider, type NormalizedJsonSchema, PermissionEngine, type PermissionGate, type PermissionGateContext, type PermissionGateDecision, PermissionMode, PermissionPlugin, type PermissionPluginOptions, Plugin, PluginsSettings, PreToolCallDecision, Processor, Provider, ProviderProfile, ProviderRoutingSettings, Run, RunEventSink, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, SOVEREIGN_ENV_KEYS, Security, type SecurityFloorInput, type SessionMessage, type SessionMessagePart, type SessionScope, type ShareGptMessage, type ShareGptTrajectory, SkillReadTool, SkillsSettings, type SovereignEnvKey, Squad, type SquadOptions, type SquadRun, StreamObjectError, type StreamObjectEvent, type StreamObjectOptions, SystemPromptResolver, TASK_RESERVED_PREFIXES, Task, type TaskCancelResult, type TaskConfigureOptions, type TaskEvent, type TaskFilter, type TaskHandle, type TaskKind, type TaskState, type TaskStoreOptions, type TaskSubmitOptions, type TaskWorkContext, type TaskWorkFn, Theokit, TheokitAgentError, type TheokitRequestOptions, TokenLimiter, type TokenLimiterOptions, Tool, ToolError, ToolResultContentBlock, type TrustLevel, type TrustPosture, type TrustPostureInput, type TrustSource, UngatedCapabilityError, UnicodeNormalizer, type UnicodeNormalizerOptions, UsageAccumulator, type WiredEntity, type WiringRecordInput, applySecurityFloor, auditEnvReachability, chargeAndCheckThresholds, computeCost, createCounterBudgetTracker, estimateTokens, extractRawId, foldLayers, getPricingEntry, inferApiMode, isValidTaskId, loadProjectEnv, migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, preflightCheck, recordWiring, resolveTrustPosture, runGoalLoop, scopedConversationId, sessionScopePrefix, setDiagnosticsSink, toShareGptTrajectory, verifyLayerOrdering, withCwdMutex };
|
|
2976
|
+
export { Agent, AgentBuilder, AgentDefinition, AgentDescription, AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, type CounterBudgetTrackerOptions, CustomTool, type DeclaredLayer, type DeepPartial, type DefineProviderOptions, type DefineToolSpec, type DiagnosticsSink, type DreamingSweepOptions, type DreamingSweepResult, type EnvOptOut, type EnvReachabilityAudit, type EnvReachabilityInput, ErrorMetadata, EventBus, type EvictReason, GOAL_CONTINUATION_MARKER, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, GoalEvent, type GoalLoopAgent, GoalOptions, GoalResult, InlineSkill, JobQueue, type JobQueueOptions, JudgeCredentialError, JudgeResult, type KeepReason, type KeptArtifact, LayerOrderError, type LayerValues, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, NoopMemoryProvider, type NormalizedJsonSchema, PermissionEngine, type PermissionGate, type PermissionGateContext, type PermissionGateDecision, PermissionMode, PermissionPlugin, type PermissionPluginOptions, Plugin, PluginsSettings, PreToolCallDecision, Processor, Provider, ProviderProfile, ProviderRoutingSettings, type ReapPlan, type ReapPlanInput, type ReapableArtifact, type RetentionPolicy, RetentionPolicyError, Run, RunEventSink, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, SOVEREIGN_ENV_KEYS, Security, type SecurityFloorInput, type SessionMessage, type SessionMessagePart, type SessionScope, type ShareGptMessage, type ShareGptTrajectory, SkillReadTool, SkillsSettings, type SovereignEnvKey, Squad, type SquadOptions, type SquadRun, StreamObjectError, type StreamObjectEvent, type StreamObjectOptions, SystemPromptResolver, TASK_RESERVED_PREFIXES, Task, type TaskCancelResult, type TaskConfigureOptions, type TaskEvent, type TaskFilter, type TaskHandle, type TaskKind, type TaskState, type TaskStoreOptions, type TaskSubmitOptions, type TaskWorkContext, type TaskWorkFn, Theokit, TheokitAgentError, type TheokitRequestOptions, TokenLimiter, type TokenLimiterOptions, Tool, ToolError, ToolResultContentBlock, type TrustLevel, type TrustPosture, type TrustPostureInput, type TrustSource, UngatedCapabilityError, UnicodeNormalizer, type UnicodeNormalizerOptions, UsageAccumulator, type WiredEntity, type WiringRecordInput, applySecurityFloor, auditEnvReachability, chargeAndCheckThresholds, computeCost, createCounterBudgetTracker, estimateTokens, extractRawId, foldLayers, getPricingEntry, inferApiMode, isValidTaskId, loadProjectEnv, migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, planReaping, preflightCheck, recordWiring, resolveTrustPosture, runGoalLoop, scopedConversationId, sessionScopePrefix, setDiagnosticsSink, toShareGptTrajectory, verifyLayerOrdering, withCwdMutex };
|
package/dist/index.js
CHANGED
|
@@ -1574,6 +1574,60 @@ function loadProjectEnv(env = process.env, load = typeof process.loadEnvFile ===
|
|
|
1574
1574
|
}
|
|
1575
1575
|
}
|
|
1576
1576
|
|
|
1577
|
+
// src/reap-plan.ts
|
|
1578
|
+
var RetentionPolicyError = class extends TheokitAgentError {
|
|
1579
|
+
name = "RetentionPolicyError";
|
|
1580
|
+
};
|
|
1581
|
+
function assertPolicy(retention) {
|
|
1582
|
+
const { maxAgeMs, keepLast } = retention;
|
|
1583
|
+
if (!Number.isFinite(maxAgeMs) || maxAgeMs < 0) {
|
|
1584
|
+
throw new RetentionPolicyError(
|
|
1585
|
+
`retention.maxAgeMs must be a non-negative number of milliseconds, got ${String(maxAgeMs)}`
|
|
1586
|
+
);
|
|
1587
|
+
}
|
|
1588
|
+
if (!Number.isInteger(keepLast) || keepLast < 0) {
|
|
1589
|
+
throw new RetentionPolicyError(
|
|
1590
|
+
`retention.keepLast must be a non-negative integer, got ${String(keepLast)}`
|
|
1591
|
+
);
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
function classifyByOwnReason(input) {
|
|
1595
|
+
const keep = [];
|
|
1596
|
+
const atRisk = [];
|
|
1597
|
+
for (const artifact of input.artifacts) {
|
|
1598
|
+
if (artifact.live === "unknown") continue;
|
|
1599
|
+
if (artifact.live === true) {
|
|
1600
|
+
keep.push({ ...artifact, reason: "live" });
|
|
1601
|
+
continue;
|
|
1602
|
+
}
|
|
1603
|
+
if (input.nowMs - artifact.lastModifiedMs <= input.retention.maxAgeMs) {
|
|
1604
|
+
keep.push({ ...artifact, reason: "within-retention" });
|
|
1605
|
+
continue;
|
|
1606
|
+
}
|
|
1607
|
+
atRisk.push(artifact);
|
|
1608
|
+
}
|
|
1609
|
+
return { keep, atRisk };
|
|
1610
|
+
}
|
|
1611
|
+
function applyFloor(kept, atRisk, keepLast) {
|
|
1612
|
+
const shortfall = Math.max(0, keepLast - kept.length);
|
|
1613
|
+
const newestFirst = [...atRisk].sort((a, b) => b.lastModifiedMs - a.lastModifiedMs);
|
|
1614
|
+
const spared = new Set(newestFirst.slice(0, shortfall).map((a) => a.id));
|
|
1615
|
+
const rescued = [];
|
|
1616
|
+
const reap = [];
|
|
1617
|
+
for (const artifact of atRisk) {
|
|
1618
|
+
if (spared.has(artifact.id)) rescued.push({ ...artifact, reason: "keep-last" });
|
|
1619
|
+
else reap.push(artifact);
|
|
1620
|
+
}
|
|
1621
|
+
return { rescued, reap };
|
|
1622
|
+
}
|
|
1623
|
+
function planReaping(input) {
|
|
1624
|
+
assertPolicy(input.retention);
|
|
1625
|
+
const undetermined = input.artifacts.filter((a) => a.live === "unknown");
|
|
1626
|
+
const { keep, atRisk } = classifyByOwnReason(input);
|
|
1627
|
+
const { rescued, reap } = applyFloor(keep, atRisk, input.retention.keepLast);
|
|
1628
|
+
return { reap, keep: [...keep, ...rescued], undetermined };
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1577
1631
|
// src/schema-normalizer.ts
|
|
1578
1632
|
function isJsonSchemaObject(s) {
|
|
1579
1633
|
if (typeof s !== "object" || s === null) return false;
|
|
@@ -2234,6 +2288,6 @@ function recordWiring(input) {
|
|
|
2234
2288
|
return record;
|
|
2235
2289
|
}
|
|
2236
2290
|
|
|
2237
|
-
export { AgentFactory, Budget, EventBus, JobQueue, LayerOrderError, Memory, NoopMemoryProvider, PermissionEngine, PermissionPlugin, Plugin, Provider, SOVEREIGN_ENV_KEYS, Security, Skill, SkillReadTool, Squad, Task, Theokit, TokenLimiter, UngatedCapabilityError, UnicodeNormalizer, applyMode, applySecurityFloor, auditEnvReachability, chargeAndCheckThresholds, createCounterBudgetTracker, estimateTokens, extractRawId, foldLayers, inferApiMode, loadProjectEnv, migrateSqliteToLance2 as migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, preflightCheck, recordWiring, resolveTrustPosture, runGoalLoop, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, verifyLayerOrdering };
|
|
2291
|
+
export { AgentFactory, Budget, EventBus, JobQueue, LayerOrderError, Memory, NoopMemoryProvider, PermissionEngine, PermissionPlugin, Plugin, Provider, RetentionPolicyError, SOVEREIGN_ENV_KEYS, Security, Skill, SkillReadTool, Squad, Task, Theokit, TokenLimiter, UngatedCapabilityError, UnicodeNormalizer, applyMode, applySecurityFloor, auditEnvReachability, chargeAndCheckThresholds, createCounterBudgetTracker, estimateTokens, extractRawId, foldLayers, inferApiMode, loadProjectEnv, migrateSqliteToLance2 as migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, planReaping, preflightCheck, recordWiring, resolveTrustPosture, runGoalLoop, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, verifyLayerOrdering };
|
|
2238
2292
|
//# sourceMappingURL=index.js.map
|
|
2239
2293
|
//# sourceMappingURL=index.js.map
|