@theokit/sdk 4.15.4 → 4.16.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/agent.d.ts +13 -0
- package/dist/compaction.cjs.map +1 -1
- package/dist/compaction.d.cts +10 -2
- package/dist/compaction.d.ts +10 -2
- package/dist/compaction.js.map +1 -1
- package/dist/cron.cjs +13096 -12294
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.d.cts +1 -1
- package/dist/cron.d.ts +1 -1
- package/dist/cron.js +13099 -12297
- package/dist/cron.js.map +1 -1
- package/dist/eval.cjs +13149 -12347
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +13152 -12350
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +15231 -14462
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +69 -2
- package/dist/index.d.ts +69 -2
- package/dist/index.js +15234 -14465
- package/dist/index.js.map +1 -1
- package/dist/internal/runtime/compression/compression-summarizer.d.ts +1 -0
- package/dist/internal/session/agent-session-store.d.ts +9 -0
- package/dist/internal/session/compact-session.d.ts +78 -0
- package/package.json +1 -1
- package/dist/{cron-DY0uC1ng.d.ts → cron-B_vVYc-_.d.ts} +92 -92
- package/dist/{cron-ElTj1cSH.d.cts → cron-Dj8FAU5V.d.cts} +92 -92
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,66 @@
|
|
|
1
1
|
import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot, E as ErrorMetadata } from './errors-gE8612p9.cjs';
|
|
2
2
|
export { A as AgentDisposedError, c as AgentRunError, d as AgentRunErrorCode, e as AuthenticationError, f as BudgetExceedEvent, g as BudgetExceededError, h as BudgetLimit, i as BudgetMode, j as BudgetScope, k as BudgetThresholdEvent, l as BudgetWindow, C as ConfigurationError, m as ErrorCode, I as IntegrationNotConnectedError, n as InvalidTaskIdError, M as MemoryAdapterError, o as MemoryAdapterErrorCode, N as NetworkError, R as RateLimitError, p as TaskNotFoundError, U as UnknownAgentError, q as UnsupportedBudgetOperationError, r as UnsupportedRunOperationError, s as UnsupportedTaskOperationError, t as isTransientError } from './errors-gE8612p9.cjs';
|
|
3
|
-
import { A as AgentOptions, L as LocalOptions, P as ProviderRoutingSettings, S as SystemPromptResolver, C as CloudOptions, M as MemorySettings, a as AgentDefinition, b as ContextSettings, c as PluginsSettings, d as SkillsSettings, e as SDKAgent, f as ListAgentsOptions, g as ListResult, h as SDKAgentInfo, G as GetAgentOptions, i as ListRunsOptions, j as GetRunOptions, k as AgentOperationOptions, l as Plugin$1, m as ProviderProfile, I as InlineSkill, B as BudgetTracker, n as MemoryProvider, o as MemoryId, p as PreToolCallDecision, q as StepResult, r as SDKProvider } from './cron-
|
|
4
|
-
export { s as ActiveMemoryPassArgs, t as ActiveMemoryPassResult, u as AgentMemory, v as BudgetCheck, w as BudgetTotal, x as BudgetUsageEvent, y as CloudEnv, z as CloudRepo, D as ContextBudget, E as ContextManagerKind, F as ContextSnapshot, H as ContextSource, J as ContextSourceStatus, K as CreateSkillSpec, N as Cron, O as CronCreateOptions, Q as CronGetOptions, R as CronJob, T as CronJobStatus, U as CronListOptions, V as CronOperationOptions, W as CronRunOptions, X as CronRuntime, Y as CronSchedulerStatus, Z as CronStartOptions, _ as GoalEvent, $ as GoalOptions, a0 as GoalResult, a1 as HookName, a2 as InvalidateCacheOptions, a3 as MemoryAdapter, a4 as MemoryAdapterCapabilities, a5 as MemoryContext, a6 as MemoryFact, a7 as MemoryProviderHandle, a8 as MemoryProviderInitOptions, a9 as MemoryRevision, aa as MemoryToolSchema, ab as MemoryTurnMessage, ac as PersonalityPreset, ad as PluginContext, ae as PostAssistantReplyContext, af as PreToolCallContext, ag as PreUserSendContext, ah as PreUserSendResult, ai as ProviderCapability, aj as ProviderRoute, ak as ProviderTransform, al as ProviderTransformContext, am as RecordSessionSummaryArgs, an as ResolvedProviderRoute, ao as RunUntilIterator, ap as SDKAgentPlugins, aq as SDKAgentSkillDetail, ar as SDKAgentSkills, as as SDKArtifact, at as SDKContextManager, au as SDKPluginMetadata, av as SDKProvidersManager, aw as SessionRecord, ax as SessionStore, ay as SettingSource, az as Skill, aA as SkillsResolver, aB as SkillsResolverContext, aC as SystemPromptContext, aD as SystemPromptMemoryFact, aE as SystemPromptSkillRef, aF as TelemetrySettings } from './cron-
|
|
3
|
+
import { A as AgentOptions, L as LocalOptions, P as ProviderRoutingSettings, S as SystemPromptResolver, C as CloudOptions, M as MemorySettings, a as AgentDefinition, b as ContextSettings, c as PluginsSettings, d as SkillsSettings, e as SDKAgent, f as ListAgentsOptions, g as ListResult, h as SDKAgentInfo, G as GetAgentOptions, i as ListRunsOptions, j as GetRunOptions, k as AgentOperationOptions, l as Plugin$1, m as ProviderProfile, I as InlineSkill, B as BudgetTracker, n as MemoryProvider, o as MemoryId, p as PreToolCallDecision, q as StepResult, r as SDKProvider } from './cron-Dj8FAU5V.cjs';
|
|
4
|
+
export { s as ActiveMemoryPassArgs, t as ActiveMemoryPassResult, u as AgentMemory, v as BudgetCheck, w as BudgetTotal, x as BudgetUsageEvent, y as CloudEnv, z as CloudRepo, D as ContextBudget, E as ContextManagerKind, F as ContextSnapshot, H as ContextSource, J as ContextSourceStatus, K as CreateSkillSpec, N as Cron, O as CronCreateOptions, Q as CronGetOptions, R as CronJob, T as CronJobStatus, U as CronListOptions, V as CronOperationOptions, W as CronRunOptions, X as CronRuntime, Y as CronSchedulerStatus, Z as CronStartOptions, _ as GoalEvent, $ as GoalOptions, a0 as GoalResult, a1 as HookName, a2 as InvalidateCacheOptions, a3 as MemoryAdapter, a4 as MemoryAdapterCapabilities, a5 as MemoryContext, a6 as MemoryFact, a7 as MemoryProviderHandle, a8 as MemoryProviderInitOptions, a9 as MemoryRevision, aa as MemoryToolSchema, ab as MemoryTurnMessage, ac as PersonalityPreset, ad as PluginContext, ae as PostAssistantReplyContext, af as PreToolCallContext, ag as PreUserSendContext, ah as PreUserSendResult, ai as ProviderCapability, aj as ProviderRoute, ak as ProviderTransform, al as ProviderTransformContext, am as RecordSessionSummaryArgs, an as ResolvedProviderRoute, ao as RunUntilIterator, ap as SDKAgentPlugins, aq as SDKAgentSkillDetail, ar as SDKAgentSkills, as as SDKArtifact, at as SDKContextManager, au as SDKPluginMetadata, av as SDKProvidersManager, aw as SessionRecord, ax as SessionStore, ay as SettingSource, az as Skill, aA as SkillsResolver, aB as SkillsResolverContext, aC as SystemPromptContext, aD as SystemPromptMemoryFact, aE as SystemPromptSkillRef, aF as TelemetrySettings } from './cron-Dj8FAU5V.cjs';
|
|
5
5
|
import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, P as Processor, T as ToolResultContentBlock, c as PermissionMode, d as PermissionEngine, e as RunEventSink, S as SDKMessage } from './run-DFM1H2jW.cjs';
|
|
6
6
|
export { A as AgentConversationTurn, f as AssistantMessage, g as CompletionCheck, h as CompletionCheckResult, i as ConversationStep, j as ConversationTurn, k as CostBreakdown, l as CostSource, m as CostStatus, D as DoomLoopThresholds, G as GenerateOptions, n as GenerateRunResult, I as ImageBlock, o as InputProcessorContext, p as InteractionUpdate, q as McpAuthConfig, r as McpHttpServerConfig, s as McpOAuthConfig, t as McpStdioServerConfig, u as MessageOrigin, v as ModelParameterValue, O as OutputProcessorContext, w as PartialToolCallUpdate, x as PermissionAction, y as PermissionEngineOptions, z as PermissionRule, B as ProcessorControls, E as ProcessorTripwire, F as ProcessorViolation, H as RunCompactBoundaryEvent, J as RunCompletionCheckEvent, K as RunErrorDetail, L as RunEvent, N as RunGitInfo, Q as RunOperation, U as RunPermissionDeniedEvent, V as RunRateLimitEvent, W as RunStatus, X as RunTaskCompletedEvent, Y as RunTaskStartedEvent, Z as RunTaskUpdatedEvent, _ as RunToCompletionOptions, $ as RunToCompletionResult, a0 as RunToolProgressEvent, a1 as RunTripwireEvent, a2 as SDKAssistantMessage, a3 as SDKImage, a4 as SDKImageDimension, a5 as SDKObjectDelta, a6 as SDKRequestMessage, a7 as SDKStatusMessage, a8 as SDKSystemMessage, a9 as SDKTaskMessage, aa as SDKThinkingMessage, ab as SDKToolUseMessage, ac as SDKUserMessage, ad as SDKUserMessageEvent, ae as SendOptions, af as ShellCommand, ag as ShellConversationTurn, ah as ShellOutput, ai as ShellOutputDeltaUpdate, aj as StepCompletedUpdate, ak as StepStartedUpdate, al as StreamToCompletionResult, am as SummaryCompletedUpdate, an as SummaryStartedUpdate, ao as SummaryUpdate, ap as TextBlock, aq as TextDeltaUpdate, ar as ThinkingCompletedUpdate, as as ThinkingDeltaUpdate, at as ThinkingMessage, au as TokenDeltaUpdate, av as TokenUsage, aw as ToolCall, ax as ToolCallCompletedUpdate, ay as ToolCallStartedUpdate, az as ToolContextMessage, aA as ToolResult, aB as ToolResultGuardOptions, aC as ToolUseBlock, aD as TurnEndedUpdate, aE as UserMessage, aF as UserMessageAppendedUpdate, aG as applyMode, aH as emitRunEvent } from './run-DFM1H2jW.cjs';
|
|
7
7
|
import * as zod from 'zod';
|
|
8
8
|
import { ZodType, z } from 'zod';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Public compaction / context-management helpers (M2-1, extended V3-3).
|
|
12
|
+
*
|
|
13
|
+
* Promotes the SDK's compaction capability to a public surface so consumers can
|
|
14
|
+
* compact a transcript, mark/filter conversation checkpoints, and detect
|
|
15
|
+
* context-overflow — without reaching into `internal/`.
|
|
16
|
+
*
|
|
17
|
+
* Two recent-window modes (V3-3):
|
|
18
|
+
* - `keepRecent` (turn-count, default) — keeps the last N turns verbatim and
|
|
19
|
+
* always preserves leading system PROMPTS; reuses the internal
|
|
20
|
+
* `selectCompressionWindow` (no second algorithm).
|
|
21
|
+
* - `keepTokens` (token-budget) — keeps the trailing turns whose accumulated
|
|
22
|
+
* `estimateTokens` fits the budget (theocode `splitTranscript` semantics). In
|
|
23
|
+
* this mode leading system prompts are NOT special-cased (D6).
|
|
24
|
+
*
|
|
25
|
+
* Summarization is delegated to a caller-supplied callback (which receives the
|
|
26
|
+
* older window + the summary template). With `failSafe`, a thrown summarizer
|
|
27
|
+
* returns the ORIGINAL transcript + a structured warn (compaction is an
|
|
28
|
+
* optimization, never a cause of data loss); without it, the error propagates.
|
|
29
|
+
*
|
|
30
|
+
* Public from the `@theokit/sdk/compaction` sub-path.
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* Minimal message shape for compaction/compression input. THE canonical public origin (leaf type —
|
|
34
|
+
* rollup-plugin-dts cannot re-export types from internal modules into entry bundles; M42 lesson).
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
interface CompressibleMessage {
|
|
39
|
+
role: "user" | "assistant" | "system";
|
|
40
|
+
content: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* M50 (agent-builder) — session-transcript compaction, Codex-faithful.
|
|
45
|
+
*
|
|
46
|
+
* Mirrors the vendored Codex mechanism (`codex-rs/core/src/compact.rs`):
|
|
47
|
+
* - the replacement history = recent USER messages verbatim (newest→oldest under a token budget;
|
|
48
|
+
* prior summaries filtered by marker) + ONE summary message with a textual marker prefix,
|
|
49
|
+
* injected as `role:"user"` (`build_compacted_history`, compact.rs:589-663);
|
|
50
|
+
* - persistence is APPEND-ONLY: a `compact_boundary` record becomes the new DAG root and the
|
|
51
|
+
* replacement messages are chained onto it — resume replays boundary→replacement→suffix
|
|
52
|
+
* (equivalent of `CompactedItem.replacement_history`, rollout is never truncated);
|
|
53
|
+
* - a failing summarizer leaves the transcript UNTOUCHED (typed error; no partial state).
|
|
54
|
+
*
|
|
55
|
+
* The summarizer is dependency-injected: tests pass a deterministic fake; the public
|
|
56
|
+
* `Agent.compact` wires the ADR-D440 compression summarizer (its first real caller).
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
interface CompactResult {
|
|
60
|
+
preTokens: number;
|
|
61
|
+
postTokens: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
10
64
|
/**
|
|
11
65
|
* Public types for `Agent.batch` (ADRs D134-D140).
|
|
12
66
|
*
|
|
@@ -583,6 +637,19 @@ declare class Agent {
|
|
|
583
637
|
* @public
|
|
584
638
|
*/
|
|
585
639
|
static rename(agentId: string, name: string, _options?: AgentOperationOptions): Promise<void>;
|
|
640
|
+
/**
|
|
641
|
+
* M50 — compact a LOCAL agent's persisted session transcript (Codex `/compact` parity): the
|
|
642
|
+
* history is summarized (recent user messages preserved verbatim + one marker'd summary) and an
|
|
643
|
+
* append-only `compact_boundary` + replacement chain is written — resume replays only the
|
|
644
|
+
* replacement + later turns. The summarizer defaults to the compression subsystem's aux-LLM
|
|
645
|
+
* (its first real caller); tests/consumers may inject their own.
|
|
646
|
+
*
|
|
647
|
+
* @public
|
|
648
|
+
*/
|
|
649
|
+
static compact(agentId: string, options?: {
|
|
650
|
+
trigger?: "manual" | "auto";
|
|
651
|
+
summarize?: (messages: readonly CompressibleMessage[]) => Promise<string>;
|
|
652
|
+
}): Promise<CompactResult>;
|
|
586
653
|
/**
|
|
587
654
|
* Permanently delete a cloud agent.
|
|
588
655
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,66 @@
|
|
|
1
1
|
import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot, E as ErrorMetadata } from './errors-CG2RpeW-.js';
|
|
2
2
|
export { A as AgentDisposedError, c as AgentRunError, d as AgentRunErrorCode, e as AuthenticationError, f as BudgetExceedEvent, g as BudgetExceededError, h as BudgetLimit, i as BudgetMode, j as BudgetScope, k as BudgetThresholdEvent, l as BudgetWindow, C as ConfigurationError, m as ErrorCode, I as IntegrationNotConnectedError, n as InvalidTaskIdError, M as MemoryAdapterError, o as MemoryAdapterErrorCode, N as NetworkError, R as RateLimitError, p as TaskNotFoundError, U as UnknownAgentError, q as UnsupportedBudgetOperationError, r as UnsupportedRunOperationError, s as UnsupportedTaskOperationError, t as isTransientError } from './errors-CG2RpeW-.js';
|
|
3
|
-
import { A as AgentOptions, L as LocalOptions, P as ProviderRoutingSettings, S as SystemPromptResolver, C as CloudOptions, M as MemorySettings, a as AgentDefinition, b as ContextSettings, c as PluginsSettings, d as SkillsSettings, e as SDKAgent, f as ListAgentsOptions, g as ListResult, h as SDKAgentInfo, G as GetAgentOptions, i as ListRunsOptions, j as GetRunOptions, k as AgentOperationOptions, l as Plugin$1, m as ProviderProfile, I as InlineSkill, B as BudgetTracker, n as MemoryProvider, o as MemoryId, p as PreToolCallDecision, q as StepResult, r as SDKProvider } from './cron-
|
|
4
|
-
export { s as ActiveMemoryPassArgs, t as ActiveMemoryPassResult, u as AgentMemory, v as BudgetCheck, w as BudgetTotal, x as BudgetUsageEvent, y as CloudEnv, z as CloudRepo, D as ContextBudget, E as ContextManagerKind, F as ContextSnapshot, H as ContextSource, J as ContextSourceStatus, K as CreateSkillSpec, N as Cron, O as CronCreateOptions, Q as CronGetOptions, R as CronJob, T as CronJobStatus, U as CronListOptions, V as CronOperationOptions, W as CronRunOptions, X as CronRuntime, Y as CronSchedulerStatus, Z as CronStartOptions, _ as GoalEvent, $ as GoalOptions, a0 as GoalResult, a1 as HookName, a2 as InvalidateCacheOptions, a3 as MemoryAdapter, a4 as MemoryAdapterCapabilities, a5 as MemoryContext, a6 as MemoryFact, a7 as MemoryProviderHandle, a8 as MemoryProviderInitOptions, a9 as MemoryRevision, aa as MemoryToolSchema, ab as MemoryTurnMessage, ac as PersonalityPreset, ad as PluginContext, ae as PostAssistantReplyContext, af as PreToolCallContext, ag as PreUserSendContext, ah as PreUserSendResult, ai as ProviderCapability, aj as ProviderRoute, ak as ProviderTransform, al as ProviderTransformContext, am as RecordSessionSummaryArgs, an as ResolvedProviderRoute, ao as RunUntilIterator, ap as SDKAgentPlugins, aq as SDKAgentSkillDetail, ar as SDKAgentSkills, as as SDKArtifact, at as SDKContextManager, au as SDKPluginMetadata, av as SDKProvidersManager, aw as SessionRecord, ax as SessionStore, ay as SettingSource, az as Skill, aA as SkillsResolver, aB as SkillsResolverContext, aC as SystemPromptContext, aD as SystemPromptMemoryFact, aE as SystemPromptSkillRef, aF as TelemetrySettings } from './cron-
|
|
3
|
+
import { A as AgentOptions, L as LocalOptions, P as ProviderRoutingSettings, S as SystemPromptResolver, C as CloudOptions, M as MemorySettings, a as AgentDefinition, b as ContextSettings, c as PluginsSettings, d as SkillsSettings, e as SDKAgent, f as ListAgentsOptions, g as ListResult, h as SDKAgentInfo, G as GetAgentOptions, i as ListRunsOptions, j as GetRunOptions, k as AgentOperationOptions, l as Plugin$1, m as ProviderProfile, I as InlineSkill, B as BudgetTracker, n as MemoryProvider, o as MemoryId, p as PreToolCallDecision, q as StepResult, r as SDKProvider } from './cron-B_vVYc-_.js';
|
|
4
|
+
export { s as ActiveMemoryPassArgs, t as ActiveMemoryPassResult, u as AgentMemory, v as BudgetCheck, w as BudgetTotal, x as BudgetUsageEvent, y as CloudEnv, z as CloudRepo, D as ContextBudget, E as ContextManagerKind, F as ContextSnapshot, H as ContextSource, J as ContextSourceStatus, K as CreateSkillSpec, N as Cron, O as CronCreateOptions, Q as CronGetOptions, R as CronJob, T as CronJobStatus, U as CronListOptions, V as CronOperationOptions, W as CronRunOptions, X as CronRuntime, Y as CronSchedulerStatus, Z as CronStartOptions, _ as GoalEvent, $ as GoalOptions, a0 as GoalResult, a1 as HookName, a2 as InvalidateCacheOptions, a3 as MemoryAdapter, a4 as MemoryAdapterCapabilities, a5 as MemoryContext, a6 as MemoryFact, a7 as MemoryProviderHandle, a8 as MemoryProviderInitOptions, a9 as MemoryRevision, aa as MemoryToolSchema, ab as MemoryTurnMessage, ac as PersonalityPreset, ad as PluginContext, ae as PostAssistantReplyContext, af as PreToolCallContext, ag as PreUserSendContext, ah as PreUserSendResult, ai as ProviderCapability, aj as ProviderRoute, ak as ProviderTransform, al as ProviderTransformContext, am as RecordSessionSummaryArgs, an as ResolvedProviderRoute, ao as RunUntilIterator, ap as SDKAgentPlugins, aq as SDKAgentSkillDetail, ar as SDKAgentSkills, as as SDKArtifact, at as SDKContextManager, au as SDKPluginMetadata, av as SDKProvidersManager, aw as SessionRecord, ax as SessionStore, ay as SettingSource, az as Skill, aA as SkillsResolver, aB as SkillsResolverContext, aC as SystemPromptContext, aD as SystemPromptMemoryFact, aE as SystemPromptSkillRef, aF as TelemetrySettings } from './cron-B_vVYc-_.js';
|
|
5
5
|
import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, P as Processor, T as ToolResultContentBlock, c as PermissionMode, d as PermissionEngine, e as RunEventSink, S as SDKMessage } from './run-DFM1H2jW.js';
|
|
6
6
|
export { A as AgentConversationTurn, f as AssistantMessage, g as CompletionCheck, h as CompletionCheckResult, i as ConversationStep, j as ConversationTurn, k as CostBreakdown, l as CostSource, m as CostStatus, D as DoomLoopThresholds, G as GenerateOptions, n as GenerateRunResult, I as ImageBlock, o as InputProcessorContext, p as InteractionUpdate, q as McpAuthConfig, r as McpHttpServerConfig, s as McpOAuthConfig, t as McpStdioServerConfig, u as MessageOrigin, v as ModelParameterValue, O as OutputProcessorContext, w as PartialToolCallUpdate, x as PermissionAction, y as PermissionEngineOptions, z as PermissionRule, B as ProcessorControls, E as ProcessorTripwire, F as ProcessorViolation, H as RunCompactBoundaryEvent, J as RunCompletionCheckEvent, K as RunErrorDetail, L as RunEvent, N as RunGitInfo, Q as RunOperation, U as RunPermissionDeniedEvent, V as RunRateLimitEvent, W as RunStatus, X as RunTaskCompletedEvent, Y as RunTaskStartedEvent, Z as RunTaskUpdatedEvent, _ as RunToCompletionOptions, $ as RunToCompletionResult, a0 as RunToolProgressEvent, a1 as RunTripwireEvent, a2 as SDKAssistantMessage, a3 as SDKImage, a4 as SDKImageDimension, a5 as SDKObjectDelta, a6 as SDKRequestMessage, a7 as SDKStatusMessage, a8 as SDKSystemMessage, a9 as SDKTaskMessage, aa as SDKThinkingMessage, ab as SDKToolUseMessage, ac as SDKUserMessage, ad as SDKUserMessageEvent, ae as SendOptions, af as ShellCommand, ag as ShellConversationTurn, ah as ShellOutput, ai as ShellOutputDeltaUpdate, aj as StepCompletedUpdate, ak as StepStartedUpdate, al as StreamToCompletionResult, am as SummaryCompletedUpdate, an as SummaryStartedUpdate, ao as SummaryUpdate, ap as TextBlock, aq as TextDeltaUpdate, ar as ThinkingCompletedUpdate, as as ThinkingDeltaUpdate, at as ThinkingMessage, au as TokenDeltaUpdate, av as TokenUsage, aw as ToolCall, ax as ToolCallCompletedUpdate, ay as ToolCallStartedUpdate, az as ToolContextMessage, aA as ToolResult, aB as ToolResultGuardOptions, aC as ToolUseBlock, aD as TurnEndedUpdate, aE as UserMessage, aF as UserMessageAppendedUpdate, aG as applyMode, aH as emitRunEvent } from './run-DFM1H2jW.js';
|
|
7
7
|
import * as zod from 'zod';
|
|
8
8
|
import { ZodType, z } from 'zod';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Public compaction / context-management helpers (M2-1, extended V3-3).
|
|
12
|
+
*
|
|
13
|
+
* Promotes the SDK's compaction capability to a public surface so consumers can
|
|
14
|
+
* compact a transcript, mark/filter conversation checkpoints, and detect
|
|
15
|
+
* context-overflow — without reaching into `internal/`.
|
|
16
|
+
*
|
|
17
|
+
* Two recent-window modes (V3-3):
|
|
18
|
+
* - `keepRecent` (turn-count, default) — keeps the last N turns verbatim and
|
|
19
|
+
* always preserves leading system PROMPTS; reuses the internal
|
|
20
|
+
* `selectCompressionWindow` (no second algorithm).
|
|
21
|
+
* - `keepTokens` (token-budget) — keeps the trailing turns whose accumulated
|
|
22
|
+
* `estimateTokens` fits the budget (theocode `splitTranscript` semantics). In
|
|
23
|
+
* this mode leading system prompts are NOT special-cased (D6).
|
|
24
|
+
*
|
|
25
|
+
* Summarization is delegated to a caller-supplied callback (which receives the
|
|
26
|
+
* older window + the summary template). With `failSafe`, a thrown summarizer
|
|
27
|
+
* returns the ORIGINAL transcript + a structured warn (compaction is an
|
|
28
|
+
* optimization, never a cause of data loss); without it, the error propagates.
|
|
29
|
+
*
|
|
30
|
+
* Public from the `@theokit/sdk/compaction` sub-path.
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* Minimal message shape for compaction/compression input. THE canonical public origin (leaf type —
|
|
34
|
+
* rollup-plugin-dts cannot re-export types from internal modules into entry bundles; M42 lesson).
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
interface CompressibleMessage {
|
|
39
|
+
role: "user" | "assistant" | "system";
|
|
40
|
+
content: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* M50 (agent-builder) — session-transcript compaction, Codex-faithful.
|
|
45
|
+
*
|
|
46
|
+
* Mirrors the vendored Codex mechanism (`codex-rs/core/src/compact.rs`):
|
|
47
|
+
* - the replacement history = recent USER messages verbatim (newest→oldest under a token budget;
|
|
48
|
+
* prior summaries filtered by marker) + ONE summary message with a textual marker prefix,
|
|
49
|
+
* injected as `role:"user"` (`build_compacted_history`, compact.rs:589-663);
|
|
50
|
+
* - persistence is APPEND-ONLY: a `compact_boundary` record becomes the new DAG root and the
|
|
51
|
+
* replacement messages are chained onto it — resume replays boundary→replacement→suffix
|
|
52
|
+
* (equivalent of `CompactedItem.replacement_history`, rollout is never truncated);
|
|
53
|
+
* - a failing summarizer leaves the transcript UNTOUCHED (typed error; no partial state).
|
|
54
|
+
*
|
|
55
|
+
* The summarizer is dependency-injected: tests pass a deterministic fake; the public
|
|
56
|
+
* `Agent.compact` wires the ADR-D440 compression summarizer (its first real caller).
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
interface CompactResult {
|
|
60
|
+
preTokens: number;
|
|
61
|
+
postTokens: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
10
64
|
/**
|
|
11
65
|
* Public types for `Agent.batch` (ADRs D134-D140).
|
|
12
66
|
*
|
|
@@ -583,6 +637,19 @@ declare class Agent {
|
|
|
583
637
|
* @public
|
|
584
638
|
*/
|
|
585
639
|
static rename(agentId: string, name: string, _options?: AgentOperationOptions): Promise<void>;
|
|
640
|
+
/**
|
|
641
|
+
* M50 — compact a LOCAL agent's persisted session transcript (Codex `/compact` parity): the
|
|
642
|
+
* history is summarized (recent user messages preserved verbatim + one marker'd summary) and an
|
|
643
|
+
* append-only `compact_boundary` + replacement chain is written — resume replays only the
|
|
644
|
+
* replacement + later turns. The summarizer defaults to the compression subsystem's aux-LLM
|
|
645
|
+
* (its first real caller); tests/consumers may inject their own.
|
|
646
|
+
*
|
|
647
|
+
* @public
|
|
648
|
+
*/
|
|
649
|
+
static compact(agentId: string, options?: {
|
|
650
|
+
trigger?: "manual" | "auto";
|
|
651
|
+
summarize?: (messages: readonly CompressibleMessage[]) => Promise<string>;
|
|
652
|
+
}): Promise<CompactResult>;
|
|
586
653
|
/**
|
|
587
654
|
* Permanently delete a cloud agent.
|
|
588
655
|
*
|