@theokit/sdk 2.25.0 → 2.26.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 +29 -0
- package/dist/a2a/index.cjs +208 -4
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +208 -4
- package/dist/a2a/index.js.map +1 -1
- package/dist/{cron-B44D-678.d.ts → cron-BR1NCSk1.d.cts} +11 -1
- package/dist/{cron-qI-dbG7c.d.cts → cron-DgEQCJ2i.d.ts} +11 -1
- package/dist/cron.cjs +187 -4
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.d.cts +2 -2
- package/dist/cron.d.ts +2 -2
- package/dist/cron.js +187 -4
- package/dist/cron.js.map +1 -1
- package/dist/{errors-DRS-kqOK.d.ts → errors-CbY3pxY7.d.ts} +1 -1
- package/dist/{errors-DIKBXffg.d.cts → errors-DLMNb4Ka.d.cts} +1 -1
- package/dist/errors.d.cts +2 -2
- package/dist/eval.cjs +187 -4
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +187 -4
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +234 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +56 -7
- package/dist/index.d.ts +56 -7
- package/dist/index.js +232 -7
- package/dist/index.js.map +1 -1
- package/dist/internal/runtime/processors/run-processors.d.ts +10 -0
- package/dist/internal/runtime/processors/tripwire-run.d.ts +16 -0
- package/dist/internal/runtime/processors/wrap-output-run.d.ts +18 -0
- package/dist/{run-Cr0C6cOM.d.cts → run-CdWiihyU.d.cts} +109 -2
- package/dist/{run-Cr0C6cOM.d.ts → run-CdWiihyU.d.ts} +109 -2
- package/dist/types/agent.d.ts +10 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/processors.d.ts +84 -0
- package/dist/types/run-events.d.ts +11 -1
- package/dist/types/run.d.ts +12 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot, E as ErrorMetadata } from './errors-
|
|
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-
|
|
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 ProviderProfile, m as Plugin, I as InlineSkill, n as ConversationStorageAdapter, o as StoredMessage, p as SessionMeta, q as SessionMetaPatch, B as BudgetTracker, r as MemoryProvider, s as MemoryId, t as PreToolCallDecision, u as SDKProvider } from './cron-
|
|
4
|
-
export { v as ActiveMemoryPassArgs, w as ActiveMemoryPassResult, x as AgentMemory, y as BudgetCheck, z as BudgetTotal, D as BudgetUsageEvent, E as CloudEnv, F as CloudRepo, H as ContextBudget, J as ContextManagerKind, K as ContextSnapshot, N as ContextSource, O as ContextSourceStatus, Q as CreateSkillSpec, R as Cron, T as CronCreateOptions, U as CronGetOptions, V as CronJob, W as CronJobStatus, X as CronListOptions, Y as CronOperationOptions, Z as CronRunOptions, _ as CronRuntime, $ as CronSchedulerStatus, a0 as CronStartOptions, a1 as GoalEvent, a2 as GoalOptions, a3 as GoalResult, a4 as HookName, a5 as InvalidateCacheOptions, a6 as MemoryAdapter, a7 as MemoryAdapterCapabilities, a8 as MemoryContext, a9 as MemoryFact, aa as MemoryProviderHandle, ab as MemoryProviderInitOptions, ac as MemoryRevision, ad as MemoryToolSchema, ae as MemoryTurnMessage, af as PersonalityPreset, ag as PluginContext, ah as PostAssistantReplyContext, ai as PreToolCallContext, aj as PreUserSendContext, ak as PreUserSendResult, al as ProviderCapability, am as ProviderRoute, an as RecordSessionSummaryArgs, ao as ResolvedProviderRoute, ap as RunUntilIterator, aq as SDKAgentPlugins, ar as SDKAgentSkillDetail, as as SDKAgentSkills, at as SDKArtifact, au as SDKContextManager, av as SDKPluginMetadata, aw as SDKProvidersManager, ax as SettingSource, ay as SkillsResolver, az as SkillsResolverContext, aA as SystemPromptContext, aB as SystemPromptMemoryFact, aC as SystemPromptSkillRef, aD as TelemetrySettings, aE as createSkill, aF as definePlugin } from './cron-
|
|
5
|
-
import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, T as ToolResultContentBlock, S as SDKMessage, c as MessageOrigin } from './run-
|
|
6
|
-
export { A as AgentConversationTurn, d as AssistantMessage, e as ConversationStep, f as ConversationTurn, g as CostBreakdown, h as CostSource, i as CostStatus, D as DoomLoopThresholds, G as GenerateOptions, j as GenerateRunResult, I as ImageBlock, k as
|
|
1
|
+
import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot, E as ErrorMetadata } from './errors-DLMNb4Ka.cjs';
|
|
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-DLMNb4Ka.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 ProviderProfile, m as Plugin, I as InlineSkill, n as ConversationStorageAdapter, o as StoredMessage, p as SessionMeta, q as SessionMetaPatch, B as BudgetTracker, r as MemoryProvider, s as MemoryId, t as PreToolCallDecision, u as SDKProvider } from './cron-BR1NCSk1.cjs';
|
|
4
|
+
export { v as ActiveMemoryPassArgs, w as ActiveMemoryPassResult, x as AgentMemory, y as BudgetCheck, z as BudgetTotal, D as BudgetUsageEvent, E as CloudEnv, F as CloudRepo, H as ContextBudget, J as ContextManagerKind, K as ContextSnapshot, N as ContextSource, O as ContextSourceStatus, Q as CreateSkillSpec, R as Cron, T as CronCreateOptions, U as CronGetOptions, V as CronJob, W as CronJobStatus, X as CronListOptions, Y as CronOperationOptions, Z as CronRunOptions, _ as CronRuntime, $ as CronSchedulerStatus, a0 as CronStartOptions, a1 as GoalEvent, a2 as GoalOptions, a3 as GoalResult, a4 as HookName, a5 as InvalidateCacheOptions, a6 as MemoryAdapter, a7 as MemoryAdapterCapabilities, a8 as MemoryContext, a9 as MemoryFact, aa as MemoryProviderHandle, ab as MemoryProviderInitOptions, ac as MemoryRevision, ad as MemoryToolSchema, ae as MemoryTurnMessage, af as PersonalityPreset, ag as PluginContext, ah as PostAssistantReplyContext, ai as PreToolCallContext, aj as PreUserSendContext, ak as PreUserSendResult, al as ProviderCapability, am as ProviderRoute, an as RecordSessionSummaryArgs, ao as ResolvedProviderRoute, ap as RunUntilIterator, aq as SDKAgentPlugins, ar as SDKAgentSkillDetail, as as SDKAgentSkills, at as SDKArtifact, au as SDKContextManager, av as SDKPluginMetadata, aw as SDKProvidersManager, ax as SettingSource, ay as SkillsResolver, az as SkillsResolverContext, aA as SystemPromptContext, aB as SystemPromptMemoryFact, aC as SystemPromptSkillRef, aD as TelemetrySettings, aE as createSkill, aF as definePlugin } from './cron-BR1NCSk1.cjs';
|
|
5
|
+
import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, P as Processor, T as ToolResultContentBlock, S as SDKMessage, c as MessageOrigin } from './run-CdWiihyU.cjs';
|
|
6
|
+
export { A as AgentConversationTurn, d as AssistantMessage, e as ConversationStep, f as ConversationTurn, g as CostBreakdown, h as CostSource, i as CostStatus, D as DoomLoopThresholds, G as GenerateOptions, j as GenerateRunResult, I as ImageBlock, k as InputProcessorContext, l as InteractionUpdate, m as McpAuthConfig, n as McpHttpServerConfig, o as McpOAuthConfig, p as McpStdioServerConfig, q as ModelParameterValue, O as OutputProcessorContext, r as PartialToolCallUpdate, s as ProcessorControls, t as ProcessorTripwire, u as ProcessorViolation, v as RunCompactBoundaryEvent, w as RunErrorDetail, x as RunEvent, y as RunEventSink, z as RunGitInfo, B as RunOperation, E as RunPermissionDeniedEvent, F as RunRateLimitEvent, H as RunStatus, J as RunTaskCompletedEvent, K as RunTaskStartedEvent, L as RunTaskUpdatedEvent, N as RunToCompletionOptions, Q as RunToCompletionResult, U as RunToolProgressEvent, V as RunTripwireEvent, W as SDKAssistantMessage, X as SDKImage, Y as SDKImageDimension, Z as SDKObjectDelta, _ as SDKRequestMessage, $ as SDKStatusMessage, a0 as SDKSystemMessage, a1 as SDKTaskMessage, a2 as SDKThinkingMessage, a3 as SDKToolUseMessage, a4 as SDKUserMessage, a5 as SDKUserMessageEvent, a6 as SendOptions, a7 as ShellCommand, a8 as ShellConversationTurn, a9 as ShellOutput, aa as ShellOutputDeltaUpdate, ab as StepCompletedUpdate, ac as StepStartedUpdate, ad as StreamToCompletionResult, ae as SummaryCompletedUpdate, af as SummaryStartedUpdate, ag as SummaryUpdate, ah as TextBlock, ai as TextDeltaUpdate, aj as ThinkingCompletedUpdate, ak as ThinkingDeltaUpdate, al as ThinkingMessage, am as TokenDeltaUpdate, an as TokenUsage, ao as ToolCall, ap as ToolCallCompletedUpdate, aq as ToolCallStartedUpdate, ar as ToolContextMessage, as as ToolResult, at as ToolResultGuardOptions, au as ToolUseBlock, av as TurnEndedUpdate, aw as UserMessage, ax as UserMessageAppendedUpdate, ay as emitRunEvent } from './run-CdWiihyU.cjs';
|
|
7
7
|
import * as zod from 'zod';
|
|
8
8
|
import { ZodType, z } from 'zod';
|
|
9
9
|
|
|
@@ -842,6 +842,55 @@ declare class Budget {
|
|
|
842
842
|
static snapshot(): readonly BudgetSnapshot[];
|
|
843
843
|
}
|
|
844
844
|
|
|
845
|
+
/**
|
|
846
|
+
* SE25 — deterministic, no-LLM guardrail processors built on the SE24
|
|
847
|
+
* {@link Processor} seam. Cheap and churn-free (no provider/model deltas), so
|
|
848
|
+
* they are safe to own in-core — unlike the LLM-classifier processors, which are
|
|
849
|
+
* delegated (see the guardrails ADR). All are OPT-IN: add them to
|
|
850
|
+
* `AgentOptions.inputProcessors` / `outputProcessors`.
|
|
851
|
+
*
|
|
852
|
+
* @public
|
|
853
|
+
*/
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* Approximate token count from string length. This is an ESTIMATE
|
|
857
|
+
* (≈ UTF-16-code-units / 4, NOT Unicode code points, NOT an exact per-model
|
|
858
|
+
* tokenizer count) — good enough for a coarse cap, and dependency-free.
|
|
859
|
+
*/
|
|
860
|
+
declare function estimateTokens(text: string): number;
|
|
861
|
+
/** Options for {@link createUnicodeNormalizer}. @public */
|
|
862
|
+
interface UnicodeNormalizerOptions {
|
|
863
|
+
/** Remove C0 + C1 control chars + DEL (keeps tab / newline / carriage-return). Default `false`. */
|
|
864
|
+
stripControlChars?: boolean;
|
|
865
|
+
/** Collapse runs of intra-line whitespace to one space, 3+ blank lines to one, and trim. Default `false`. Uses legacy `\s`; Unicode-only whitespace (U+00A0 NBSP, U+FEFF BOM, U+2000–U+200A) is NOT collapsed. */
|
|
866
|
+
collapseWhitespace?: boolean;
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* SE25 — an input processor that normalizes user text: Unicode NFC (so
|
|
870
|
+
* canonically-equivalent sequences compare equal) plus optional control-char
|
|
871
|
+
* stripping and whitespace collapsing. Pure + deterministic; no LLM. Mirrors
|
|
872
|
+
* Mastra's `UnicodeNormalizer`.
|
|
873
|
+
*
|
|
874
|
+
* @public
|
|
875
|
+
*/
|
|
876
|
+
declare function createUnicodeNormalizer(opts?: UnicodeNormalizerOptions): Processor;
|
|
877
|
+
/** Options for {@link createTokenLimiter}. @public */
|
|
878
|
+
interface TokenLimiterOptions {
|
|
879
|
+
/** Positive integer token budget (estimate — see {@link estimateTokens}). */
|
|
880
|
+
limit: number;
|
|
881
|
+
/** Over the limit: `"truncate"` (default, cut to fit) or `"block"` (abort with a tripwire). */
|
|
882
|
+
strategy?: "truncate" | "block";
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* SE25 — a processor that caps text to a token budget. Placed in
|
|
886
|
+
* `inputProcessors` it limits the prompt; in `outputProcessors` it limits the
|
|
887
|
+
* response. Uses a char-based estimate (no tokenizer dep). `truncate` cuts to
|
|
888
|
+
* fit; `block` aborts (tripwire). Mirrors Mastra's `TokenLimiterProcessor`.
|
|
889
|
+
*
|
|
890
|
+
* @public
|
|
891
|
+
*/
|
|
892
|
+
declare function createTokenLimiter(opts: TokenLimiterOptions): Processor;
|
|
893
|
+
|
|
845
894
|
/**
|
|
846
895
|
* Options for {@link defineProvider}.
|
|
847
896
|
*
|
|
@@ -2520,4 +2569,4 @@ declare function toShareGptTrajectory(result: BatchResult, options?: {
|
|
|
2520
2569
|
model?: string;
|
|
2521
2570
|
}): ShareGptTrajectory | null;
|
|
2522
2571
|
|
|
2523
|
-
export { Agent, AgentBuilder, AgentDefinition, type AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, ConversationStorageAdapter, type CounterBudgetTrackerOptions, CustomTool, type DeepPartial, type DefineProviderOptions, type DefineToolSpec, type DreamingSweepOptions, type DreamingSweepResult, ErrorMetadata, EventBus, type EvictReason, FileSystemConversationStorage, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, InMemoryConversationStorage, InlineSkill, JobQueue, type JobQueueOptions, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryId, MemoryProvider, MemorySettings, MessageOrigin, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, type NormalizedJsonSchema, type PermissionAction, PermissionEngine, type PermissionEngineOptions, type PermissionGate, type PermissionGateContext, type PermissionGateDecision, type PermissionMode, type PermissionPluginOptions, type PermissionRule, Plugin, PluginsSettings, PreToolCallDecision, ProviderProfile, ProviderRoutingSettings, type ReplayHistoryOptions, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type SessionCapabilityResult, type SessionListOptions, type SessionManager, SessionMeta, SessionMetaPatch, type SessionScope, type SessionSummary, type ShareGptMessage, type ShareGptTrajectory, SkillsSettings, type Squad, type SquadOptions, type SquadRun, StoredMessage, 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, ToolError, ToolResultContentBlock, UsageAccumulator, applyMode, buildReplayHistory, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createPermissionPlugin, createSessionManager, createSquad, defineProvider, defineSkillReadTool, defineTool, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, preflightCheck, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, withCwdMutex };
|
|
2572
|
+
export { Agent, AgentBuilder, AgentDefinition, type AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, ConversationStorageAdapter, type CounterBudgetTrackerOptions, CustomTool, type DeepPartial, type DefineProviderOptions, type DefineToolSpec, type DreamingSweepOptions, type DreamingSweepResult, ErrorMetadata, EventBus, type EvictReason, FileSystemConversationStorage, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, InMemoryConversationStorage, InlineSkill, JobQueue, type JobQueueOptions, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryId, MemoryProvider, MemorySettings, MessageOrigin, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, type NormalizedJsonSchema, type PermissionAction, PermissionEngine, type PermissionEngineOptions, type PermissionGate, type PermissionGateContext, type PermissionGateDecision, type PermissionMode, type PermissionPluginOptions, type PermissionRule, Plugin, PluginsSettings, PreToolCallDecision, Processor, ProviderProfile, ProviderRoutingSettings, type ReplayHistoryOptions, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type SessionCapabilityResult, type SessionListOptions, type SessionManager, SessionMeta, SessionMetaPatch, type SessionScope, type SessionSummary, type ShareGptMessage, type ShareGptTrajectory, SkillsSettings, type Squad, type SquadOptions, type SquadRun, StoredMessage, 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, type TokenLimiterOptions, ToolError, ToolResultContentBlock, type UnicodeNormalizerOptions, UsageAccumulator, applyMode, buildReplayHistory, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createPermissionPlugin, createSessionManager, createSquad, createTokenLimiter, createUnicodeNormalizer, defineProvider, defineSkillReadTool, defineTool, estimateTokens, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, preflightCheck, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, withCwdMutex };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot, E as ErrorMetadata } from './errors-
|
|
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-
|
|
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 ProviderProfile, m as Plugin, I as InlineSkill, n as ConversationStorageAdapter, o as StoredMessage, p as SessionMeta, q as SessionMetaPatch, B as BudgetTracker, r as MemoryProvider, s as MemoryId, t as PreToolCallDecision, u as SDKProvider } from './cron-
|
|
4
|
-
export { v as ActiveMemoryPassArgs, w as ActiveMemoryPassResult, x as AgentMemory, y as BudgetCheck, z as BudgetTotal, D as BudgetUsageEvent, E as CloudEnv, F as CloudRepo, H as ContextBudget, J as ContextManagerKind, K as ContextSnapshot, N as ContextSource, O as ContextSourceStatus, Q as CreateSkillSpec, R as Cron, T as CronCreateOptions, U as CronGetOptions, V as CronJob, W as CronJobStatus, X as CronListOptions, Y as CronOperationOptions, Z as CronRunOptions, _ as CronRuntime, $ as CronSchedulerStatus, a0 as CronStartOptions, a1 as GoalEvent, a2 as GoalOptions, a3 as GoalResult, a4 as HookName, a5 as InvalidateCacheOptions, a6 as MemoryAdapter, a7 as MemoryAdapterCapabilities, a8 as MemoryContext, a9 as MemoryFact, aa as MemoryProviderHandle, ab as MemoryProviderInitOptions, ac as MemoryRevision, ad as MemoryToolSchema, ae as MemoryTurnMessage, af as PersonalityPreset, ag as PluginContext, ah as PostAssistantReplyContext, ai as PreToolCallContext, aj as PreUserSendContext, ak as PreUserSendResult, al as ProviderCapability, am as ProviderRoute, an as RecordSessionSummaryArgs, ao as ResolvedProviderRoute, ap as RunUntilIterator, aq as SDKAgentPlugins, ar as SDKAgentSkillDetail, as as SDKAgentSkills, at as SDKArtifact, au as SDKContextManager, av as SDKPluginMetadata, aw as SDKProvidersManager, ax as SettingSource, ay as SkillsResolver, az as SkillsResolverContext, aA as SystemPromptContext, aB as SystemPromptMemoryFact, aC as SystemPromptSkillRef, aD as TelemetrySettings, aE as createSkill, aF as definePlugin } from './cron-
|
|
5
|
-
import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, T as ToolResultContentBlock, S as SDKMessage, c as MessageOrigin } from './run-
|
|
6
|
-
export { A as AgentConversationTurn, d as AssistantMessage, e as ConversationStep, f as ConversationTurn, g as CostBreakdown, h as CostSource, i as CostStatus, D as DoomLoopThresholds, G as GenerateOptions, j as GenerateRunResult, I as ImageBlock, k as
|
|
1
|
+
import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot, E as ErrorMetadata } from './errors-CbY3pxY7.js';
|
|
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-CbY3pxY7.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 ProviderProfile, m as Plugin, I as InlineSkill, n as ConversationStorageAdapter, o as StoredMessage, p as SessionMeta, q as SessionMetaPatch, B as BudgetTracker, r as MemoryProvider, s as MemoryId, t as PreToolCallDecision, u as SDKProvider } from './cron-DgEQCJ2i.js';
|
|
4
|
+
export { v as ActiveMemoryPassArgs, w as ActiveMemoryPassResult, x as AgentMemory, y as BudgetCheck, z as BudgetTotal, D as BudgetUsageEvent, E as CloudEnv, F as CloudRepo, H as ContextBudget, J as ContextManagerKind, K as ContextSnapshot, N as ContextSource, O as ContextSourceStatus, Q as CreateSkillSpec, R as Cron, T as CronCreateOptions, U as CronGetOptions, V as CronJob, W as CronJobStatus, X as CronListOptions, Y as CronOperationOptions, Z as CronRunOptions, _ as CronRuntime, $ as CronSchedulerStatus, a0 as CronStartOptions, a1 as GoalEvent, a2 as GoalOptions, a3 as GoalResult, a4 as HookName, a5 as InvalidateCacheOptions, a6 as MemoryAdapter, a7 as MemoryAdapterCapabilities, a8 as MemoryContext, a9 as MemoryFact, aa as MemoryProviderHandle, ab as MemoryProviderInitOptions, ac as MemoryRevision, ad as MemoryToolSchema, ae as MemoryTurnMessage, af as PersonalityPreset, ag as PluginContext, ah as PostAssistantReplyContext, ai as PreToolCallContext, aj as PreUserSendContext, ak as PreUserSendResult, al as ProviderCapability, am as ProviderRoute, an as RecordSessionSummaryArgs, ao as ResolvedProviderRoute, ap as RunUntilIterator, aq as SDKAgentPlugins, ar as SDKAgentSkillDetail, as as SDKAgentSkills, at as SDKArtifact, au as SDKContextManager, av as SDKPluginMetadata, aw as SDKProvidersManager, ax as SettingSource, ay as SkillsResolver, az as SkillsResolverContext, aA as SystemPromptContext, aB as SystemPromptMemoryFact, aC as SystemPromptSkillRef, aD as TelemetrySettings, aE as createSkill, aF as definePlugin } from './cron-DgEQCJ2i.js';
|
|
5
|
+
import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, P as Processor, T as ToolResultContentBlock, S as SDKMessage, c as MessageOrigin } from './run-CdWiihyU.js';
|
|
6
|
+
export { A as AgentConversationTurn, d as AssistantMessage, e as ConversationStep, f as ConversationTurn, g as CostBreakdown, h as CostSource, i as CostStatus, D as DoomLoopThresholds, G as GenerateOptions, j as GenerateRunResult, I as ImageBlock, k as InputProcessorContext, l as InteractionUpdate, m as McpAuthConfig, n as McpHttpServerConfig, o as McpOAuthConfig, p as McpStdioServerConfig, q as ModelParameterValue, O as OutputProcessorContext, r as PartialToolCallUpdate, s as ProcessorControls, t as ProcessorTripwire, u as ProcessorViolation, v as RunCompactBoundaryEvent, w as RunErrorDetail, x as RunEvent, y as RunEventSink, z as RunGitInfo, B as RunOperation, E as RunPermissionDeniedEvent, F as RunRateLimitEvent, H as RunStatus, J as RunTaskCompletedEvent, K as RunTaskStartedEvent, L as RunTaskUpdatedEvent, N as RunToCompletionOptions, Q as RunToCompletionResult, U as RunToolProgressEvent, V as RunTripwireEvent, W as SDKAssistantMessage, X as SDKImage, Y as SDKImageDimension, Z as SDKObjectDelta, _ as SDKRequestMessage, $ as SDKStatusMessage, a0 as SDKSystemMessage, a1 as SDKTaskMessage, a2 as SDKThinkingMessage, a3 as SDKToolUseMessage, a4 as SDKUserMessage, a5 as SDKUserMessageEvent, a6 as SendOptions, a7 as ShellCommand, a8 as ShellConversationTurn, a9 as ShellOutput, aa as ShellOutputDeltaUpdate, ab as StepCompletedUpdate, ac as StepStartedUpdate, ad as StreamToCompletionResult, ae as SummaryCompletedUpdate, af as SummaryStartedUpdate, ag as SummaryUpdate, ah as TextBlock, ai as TextDeltaUpdate, aj as ThinkingCompletedUpdate, ak as ThinkingDeltaUpdate, al as ThinkingMessage, am as TokenDeltaUpdate, an as TokenUsage, ao as ToolCall, ap as ToolCallCompletedUpdate, aq as ToolCallStartedUpdate, ar as ToolContextMessage, as as ToolResult, at as ToolResultGuardOptions, au as ToolUseBlock, av as TurnEndedUpdate, aw as UserMessage, ax as UserMessageAppendedUpdate, ay as emitRunEvent } from './run-CdWiihyU.js';
|
|
7
7
|
import * as zod from 'zod';
|
|
8
8
|
import { ZodType, z } from 'zod';
|
|
9
9
|
|
|
@@ -842,6 +842,55 @@ declare class Budget {
|
|
|
842
842
|
static snapshot(): readonly BudgetSnapshot[];
|
|
843
843
|
}
|
|
844
844
|
|
|
845
|
+
/**
|
|
846
|
+
* SE25 — deterministic, no-LLM guardrail processors built on the SE24
|
|
847
|
+
* {@link Processor} seam. Cheap and churn-free (no provider/model deltas), so
|
|
848
|
+
* they are safe to own in-core — unlike the LLM-classifier processors, which are
|
|
849
|
+
* delegated (see the guardrails ADR). All are OPT-IN: add them to
|
|
850
|
+
* `AgentOptions.inputProcessors` / `outputProcessors`.
|
|
851
|
+
*
|
|
852
|
+
* @public
|
|
853
|
+
*/
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* Approximate token count from string length. This is an ESTIMATE
|
|
857
|
+
* (≈ UTF-16-code-units / 4, NOT Unicode code points, NOT an exact per-model
|
|
858
|
+
* tokenizer count) — good enough for a coarse cap, and dependency-free.
|
|
859
|
+
*/
|
|
860
|
+
declare function estimateTokens(text: string): number;
|
|
861
|
+
/** Options for {@link createUnicodeNormalizer}. @public */
|
|
862
|
+
interface UnicodeNormalizerOptions {
|
|
863
|
+
/** Remove C0 + C1 control chars + DEL (keeps tab / newline / carriage-return). Default `false`. */
|
|
864
|
+
stripControlChars?: boolean;
|
|
865
|
+
/** Collapse runs of intra-line whitespace to one space, 3+ blank lines to one, and trim. Default `false`. Uses legacy `\s`; Unicode-only whitespace (U+00A0 NBSP, U+FEFF BOM, U+2000–U+200A) is NOT collapsed. */
|
|
866
|
+
collapseWhitespace?: boolean;
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* SE25 — an input processor that normalizes user text: Unicode NFC (so
|
|
870
|
+
* canonically-equivalent sequences compare equal) plus optional control-char
|
|
871
|
+
* stripping and whitespace collapsing. Pure + deterministic; no LLM. Mirrors
|
|
872
|
+
* Mastra's `UnicodeNormalizer`.
|
|
873
|
+
*
|
|
874
|
+
* @public
|
|
875
|
+
*/
|
|
876
|
+
declare function createUnicodeNormalizer(opts?: UnicodeNormalizerOptions): Processor;
|
|
877
|
+
/** Options for {@link createTokenLimiter}. @public */
|
|
878
|
+
interface TokenLimiterOptions {
|
|
879
|
+
/** Positive integer token budget (estimate — see {@link estimateTokens}). */
|
|
880
|
+
limit: number;
|
|
881
|
+
/** Over the limit: `"truncate"` (default, cut to fit) or `"block"` (abort with a tripwire). */
|
|
882
|
+
strategy?: "truncate" | "block";
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* SE25 — a processor that caps text to a token budget. Placed in
|
|
886
|
+
* `inputProcessors` it limits the prompt; in `outputProcessors` it limits the
|
|
887
|
+
* response. Uses a char-based estimate (no tokenizer dep). `truncate` cuts to
|
|
888
|
+
* fit; `block` aborts (tripwire). Mirrors Mastra's `TokenLimiterProcessor`.
|
|
889
|
+
*
|
|
890
|
+
* @public
|
|
891
|
+
*/
|
|
892
|
+
declare function createTokenLimiter(opts: TokenLimiterOptions): Processor;
|
|
893
|
+
|
|
845
894
|
/**
|
|
846
895
|
* Options for {@link defineProvider}.
|
|
847
896
|
*
|
|
@@ -2520,4 +2569,4 @@ declare function toShareGptTrajectory(result: BatchResult, options?: {
|
|
|
2520
2569
|
model?: string;
|
|
2521
2570
|
}): ShareGptTrajectory | null;
|
|
2522
2571
|
|
|
2523
|
-
export { Agent, AgentBuilder, AgentDefinition, type AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, ConversationStorageAdapter, type CounterBudgetTrackerOptions, CustomTool, type DeepPartial, type DefineProviderOptions, type DefineToolSpec, type DreamingSweepOptions, type DreamingSweepResult, ErrorMetadata, EventBus, type EvictReason, FileSystemConversationStorage, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, InMemoryConversationStorage, InlineSkill, JobQueue, type JobQueueOptions, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryId, MemoryProvider, MemorySettings, MessageOrigin, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, type NormalizedJsonSchema, type PermissionAction, PermissionEngine, type PermissionEngineOptions, type PermissionGate, type PermissionGateContext, type PermissionGateDecision, type PermissionMode, type PermissionPluginOptions, type PermissionRule, Plugin, PluginsSettings, PreToolCallDecision, ProviderProfile, ProviderRoutingSettings, type ReplayHistoryOptions, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type SessionCapabilityResult, type SessionListOptions, type SessionManager, SessionMeta, SessionMetaPatch, type SessionScope, type SessionSummary, type ShareGptMessage, type ShareGptTrajectory, SkillsSettings, type Squad, type SquadOptions, type SquadRun, StoredMessage, 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, ToolError, ToolResultContentBlock, UsageAccumulator, applyMode, buildReplayHistory, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createPermissionPlugin, createSessionManager, createSquad, defineProvider, defineSkillReadTool, defineTool, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, preflightCheck, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, withCwdMutex };
|
|
2572
|
+
export { Agent, AgentBuilder, AgentDefinition, type AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, ConversationStorageAdapter, type CounterBudgetTrackerOptions, CustomTool, type DeepPartial, type DefineProviderOptions, type DefineToolSpec, type DreamingSweepOptions, type DreamingSweepResult, ErrorMetadata, EventBus, type EvictReason, FileSystemConversationStorage, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, InMemoryConversationStorage, InlineSkill, JobQueue, type JobQueueOptions, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryId, MemoryProvider, MemorySettings, MessageOrigin, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, type NormalizedJsonSchema, type PermissionAction, PermissionEngine, type PermissionEngineOptions, type PermissionGate, type PermissionGateContext, type PermissionGateDecision, type PermissionMode, type PermissionPluginOptions, type PermissionRule, Plugin, PluginsSettings, PreToolCallDecision, Processor, ProviderProfile, ProviderRoutingSettings, type ReplayHistoryOptions, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type SessionCapabilityResult, type SessionListOptions, type SessionManager, SessionMeta, SessionMetaPatch, type SessionScope, type SessionSummary, type ShareGptMessage, type ShareGptTrajectory, SkillsSettings, type Squad, type SquadOptions, type SquadRun, StoredMessage, 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, type TokenLimiterOptions, ToolError, ToolResultContentBlock, type UnicodeNormalizerOptions, UsageAccumulator, applyMode, buildReplayHistory, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createPermissionPlugin, createSessionManager, createSquad, createTokenLimiter, createUnicodeNormalizer, defineProvider, defineSkillReadTool, defineTool, estimateTokens, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, preflightCheck, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, withCwdMutex };
|
package/dist/index.js
CHANGED
|
@@ -7734,8 +7734,18 @@ function validateCloudToolParity(options) {
|
|
|
7734
7734
|
if (options.cloud === void 0) return;
|
|
7735
7735
|
rejectFunctionSystemPrompt(options);
|
|
7736
7736
|
rejectFunctionSkills(options);
|
|
7737
|
+
rejectProcessors(options);
|
|
7737
7738
|
rejectStdioMcpLocalPaths(options);
|
|
7738
7739
|
}
|
|
7740
|
+
function rejectProcessors(options) {
|
|
7741
|
+
const hasProcessors = (options.inputProcessors?.length ?? 0) > 0 || (options.outputProcessors?.length ?? 0) > 0;
|
|
7742
|
+
if (hasProcessors) {
|
|
7743
|
+
throw new ConfigurationError(
|
|
7744
|
+
"Cloud agents can't run guardrail processors \u2014 a Processor carries function handlers that don't survive serialization to PaaS. Run processors on a local agent, or move the guardrail into a server-side gateway in front of TheoCloud.",
|
|
7745
|
+
{ code: "cloud_incompatible_function_resolver" }
|
|
7746
|
+
);
|
|
7747
|
+
}
|
|
7748
|
+
}
|
|
7739
7749
|
function rejectFunctionSystemPrompt(options) {
|
|
7740
7750
|
if (typeof options.systemPrompt === "function") {
|
|
7741
7751
|
throw new ConfigurationError(
|
|
@@ -17674,6 +17684,145 @@ function ponyfillAny(signals) {
|
|
|
17674
17684
|
return ctrl.signal;
|
|
17675
17685
|
}
|
|
17676
17686
|
|
|
17687
|
+
// src/internal/runtime/processors/run-processors.ts
|
|
17688
|
+
var ProcessorAbort = class {
|
|
17689
|
+
constructor(processorId, reason) {
|
|
17690
|
+
this.processorId = processorId;
|
|
17691
|
+
this.reason = reason;
|
|
17692
|
+
}
|
|
17693
|
+
processorId;
|
|
17694
|
+
reason;
|
|
17695
|
+
};
|
|
17696
|
+
function fireViolation(processor, violation) {
|
|
17697
|
+
try {
|
|
17698
|
+
processor.onViolation?.(violation);
|
|
17699
|
+
} catch {
|
|
17700
|
+
}
|
|
17701
|
+
}
|
|
17702
|
+
function controlsFor(processor) {
|
|
17703
|
+
return {
|
|
17704
|
+
abort(reason) {
|
|
17705
|
+
throw new ProcessorAbort(processor.id, reason);
|
|
17706
|
+
},
|
|
17707
|
+
warn(message, detail) {
|
|
17708
|
+
fireViolation(processor, {
|
|
17709
|
+
processorId: processor.id,
|
|
17710
|
+
message,
|
|
17711
|
+
...detail !== void 0 ? { detail } : {}
|
|
17712
|
+
});
|
|
17713
|
+
}
|
|
17714
|
+
};
|
|
17715
|
+
}
|
|
17716
|
+
function selectHandler(processor, phase) {
|
|
17717
|
+
if (phase === "input") {
|
|
17718
|
+
return processor.processInput ? { kind: "input", fn: processor.processInput } : void 0;
|
|
17719
|
+
}
|
|
17720
|
+
return processor.processOutput ? { kind: "output", fn: processor.processOutput } : void 0;
|
|
17721
|
+
}
|
|
17722
|
+
function invokeHandler(handler, value, agentId, controls) {
|
|
17723
|
+
return handler.kind === "input" ? handler.fn({ message: value, agentId, ...controls }) : handler.fn({ text: value, agentId, ...controls });
|
|
17724
|
+
}
|
|
17725
|
+
async function runOneProcessor(processor, value, agentId, phase) {
|
|
17726
|
+
const handler = selectHandler(processor, phase);
|
|
17727
|
+
if (handler === void 0) return { value };
|
|
17728
|
+
try {
|
|
17729
|
+
const out = await invokeHandler(handler, value, agentId, controlsFor(processor));
|
|
17730
|
+
return { value: typeof out === "string" ? out : value };
|
|
17731
|
+
} catch (err) {
|
|
17732
|
+
if (!(err instanceof ProcessorAbort)) throw err;
|
|
17733
|
+
fireViolation(processor, { processorId: err.processorId, message: err.reason });
|
|
17734
|
+
return { tripwire: { reason: err.reason, processorId: err.processorId } };
|
|
17735
|
+
}
|
|
17736
|
+
}
|
|
17737
|
+
async function runPipeline(processors, initial, agentId, phase) {
|
|
17738
|
+
let value = initial;
|
|
17739
|
+
for (const processor of processors) {
|
|
17740
|
+
const step = await runOneProcessor(processor, value, agentId, phase);
|
|
17741
|
+
if ("tripwire" in step) return { kind: "tripwire", tripwire: step.tripwire };
|
|
17742
|
+
value = step.value;
|
|
17743
|
+
}
|
|
17744
|
+
return { kind: "ok", value };
|
|
17745
|
+
}
|
|
17746
|
+
function runInputProcessors(processors, message, agentId) {
|
|
17747
|
+
return runPipeline(processors, message, agentId, "input");
|
|
17748
|
+
}
|
|
17749
|
+
function runOutputProcessors(processors, text, agentId) {
|
|
17750
|
+
return runPipeline(processors, text, agentId, "output");
|
|
17751
|
+
}
|
|
17752
|
+
|
|
17753
|
+
// src/internal/runtime/processors/tripwire-run.ts
|
|
17754
|
+
var SUPPORTED = /* @__PURE__ */ new Set([
|
|
17755
|
+
"stream",
|
|
17756
|
+
"wait",
|
|
17757
|
+
"cancel",
|
|
17758
|
+
"conversation"
|
|
17759
|
+
]);
|
|
17760
|
+
function emptyStream() {
|
|
17761
|
+
return {
|
|
17762
|
+
next: () => Promise.resolve({ done: true, value: void 0 }),
|
|
17763
|
+
return: () => Promise.resolve({ done: true, value: void 0 }),
|
|
17764
|
+
throw: (err) => Promise.reject(err),
|
|
17765
|
+
[Symbol.asyncIterator]() {
|
|
17766
|
+
return this;
|
|
17767
|
+
}
|
|
17768
|
+
};
|
|
17769
|
+
}
|
|
17770
|
+
function createTripwireRun(args) {
|
|
17771
|
+
const id = globalThis.crypto.randomUUID();
|
|
17772
|
+
const result = {
|
|
17773
|
+
id,
|
|
17774
|
+
status: "cancelled",
|
|
17775
|
+
tripwire: args.tripwire,
|
|
17776
|
+
...args.model !== void 0 ? { model: args.model } : {}
|
|
17777
|
+
};
|
|
17778
|
+
const run = {
|
|
17779
|
+
id,
|
|
17780
|
+
agentId: args.agentId,
|
|
17781
|
+
status: "cancelled",
|
|
17782
|
+
...args.model !== void 0 ? { model: args.model } : {},
|
|
17783
|
+
stream: () => emptyStream(),
|
|
17784
|
+
wait: () => Promise.resolve(result),
|
|
17785
|
+
cancel: () => Promise.resolve(),
|
|
17786
|
+
conversation: () => Promise.resolve([]),
|
|
17787
|
+
supports: (op) => SUPPORTED.has(op),
|
|
17788
|
+
unsupportedReason: (op) => SUPPORTED.has(op) ? void 0 : `operation "${op}" is not available on a tripwire run`,
|
|
17789
|
+
onDidChangeStatus: () => () => {
|
|
17790
|
+
}
|
|
17791
|
+
// already terminal — status never changes
|
|
17792
|
+
};
|
|
17793
|
+
registerRun(run);
|
|
17794
|
+
return run;
|
|
17795
|
+
}
|
|
17796
|
+
|
|
17797
|
+
// src/internal/runtime/processors/wrap-output-run.ts
|
|
17798
|
+
function wrapRunWithOutputProcessors(args) {
|
|
17799
|
+
if (args.processors.length === 0) return args.run;
|
|
17800
|
+
const compute = async () => {
|
|
17801
|
+
const result = await args.run.wait();
|
|
17802
|
+
if (result.status !== "finished" || result.result === void 0) return result;
|
|
17803
|
+
const res = await runOutputProcessors(args.processors, result.result, args.agentId);
|
|
17804
|
+
if (res.kind === "ok") return { ...result, result: res.value };
|
|
17805
|
+
emitRunEvent(args.onRunEvent, {
|
|
17806
|
+
type: "tripwire",
|
|
17807
|
+
reason: res.tripwire.reason,
|
|
17808
|
+
processorId: res.tripwire.processorId
|
|
17809
|
+
});
|
|
17810
|
+
const { result: _suppressed, ...metadata } = result;
|
|
17811
|
+
return { ...metadata, status: "cancelled", tripwire: res.tripwire };
|
|
17812
|
+
};
|
|
17813
|
+
let processed;
|
|
17814
|
+
const wrappedWait = () => {
|
|
17815
|
+
processed ??= compute();
|
|
17816
|
+
return processed;
|
|
17817
|
+
};
|
|
17818
|
+
return new Proxy(args.run, {
|
|
17819
|
+
get(target, prop, receiver) {
|
|
17820
|
+
if (prop === "wait") return wrappedWait;
|
|
17821
|
+
return Reflect.get(target, prop, receiver);
|
|
17822
|
+
}
|
|
17823
|
+
});
|
|
17824
|
+
}
|
|
17825
|
+
|
|
17677
17826
|
// src/internal/runtime/local-agent/local-agent-memory-hooks.ts
|
|
17678
17827
|
var DEFAULT_MAX_RECALL_BYTES = 16e3;
|
|
17679
17828
|
async function applyPreUserSendHook(args) {
|
|
@@ -17721,11 +17870,38 @@ function wrapRunWithPostReplyHook(args) {
|
|
|
17721
17870
|
}
|
|
17722
17871
|
|
|
17723
17872
|
// src/internal/runtime/local-agent/local-agent-send.ts
|
|
17873
|
+
async function applyInputProcessors(inputs, message, rawUserText, options, sendModel) {
|
|
17874
|
+
const processors = inputs.options.inputProcessors;
|
|
17875
|
+
if (processors === void 0 || processors.length === 0) {
|
|
17876
|
+
return { userText: rawUserText, effectiveMessage: message };
|
|
17877
|
+
}
|
|
17878
|
+
const res = await runInputProcessors(processors, rawUserText, inputs.agentId);
|
|
17879
|
+
if (res.kind === "tripwire") {
|
|
17880
|
+
emitRunEvent(options.onRunEvent, {
|
|
17881
|
+
type: "tripwire",
|
|
17882
|
+
reason: res.tripwire.reason,
|
|
17883
|
+
processorId: res.tripwire.processorId
|
|
17884
|
+
});
|
|
17885
|
+
return {
|
|
17886
|
+
tripwireRun: createTripwireRun({
|
|
17887
|
+
agentId: inputs.agentId,
|
|
17888
|
+
tripwire: res.tripwire,
|
|
17889
|
+
model: sendModel
|
|
17890
|
+
})
|
|
17891
|
+
};
|
|
17892
|
+
}
|
|
17893
|
+
const effectiveMessage = typeof message === "string" ? res.value : { ...message, text: res.value };
|
|
17894
|
+
return { userText: res.value, effectiveMessage };
|
|
17895
|
+
}
|
|
17724
17896
|
async function executeSendLocked(inputs, message, options) {
|
|
17725
17897
|
if (inputs.disposed) throw new AgentDisposedError(inputs.agentId);
|
|
17726
17898
|
await consumePending(inputs.agentId, inputs.invalidationPending, inputs.clearInvalidation, inputs.reload);
|
|
17727
|
-
|
|
17728
|
-
|
|
17899
|
+
const sendModel = normalizeModel(options.model);
|
|
17900
|
+
inputs.applyModelOverride(sendModel);
|
|
17901
|
+
const rawUserText = typeof message === "string" ? message : message.text;
|
|
17902
|
+
const gated = await applyInputProcessors(inputs, message, rawUserText, options, sendModel);
|
|
17903
|
+
if ("tripwireRun" in gated) return gated.tripwireRun;
|
|
17904
|
+
const { userText, effectiveMessage } = gated;
|
|
17729
17905
|
if (inputs.options.onBeforeSend !== void 0) {
|
|
17730
17906
|
await inputs.options.onBeforeSend({
|
|
17731
17907
|
conversationId: inputs.agentId,
|
|
@@ -17737,7 +17913,7 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
17737
17913
|
pluginManager: inputs.pluginManagerCode,
|
|
17738
17914
|
agentId: inputs.agentId,
|
|
17739
17915
|
options: inputs.options,
|
|
17740
|
-
original:
|
|
17916
|
+
original: effectiveMessage,
|
|
17741
17917
|
userText,
|
|
17742
17918
|
sendOptions: options
|
|
17743
17919
|
});
|
|
@@ -17775,11 +17951,18 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
17775
17951
|
memoryTools,
|
|
17776
17952
|
effectiveMemoryProvider
|
|
17777
17953
|
);
|
|
17954
|
+
const outputProcessors = inputs.options.outputProcessors;
|
|
17955
|
+
const processedRun = outputProcessors !== void 0 && outputProcessors.length > 0 ? wrapRunWithOutputProcessors({
|
|
17956
|
+
run,
|
|
17957
|
+
processors: outputProcessors,
|
|
17958
|
+
agentId: inputs.agentId,
|
|
17959
|
+
onRunEvent: options.onRunEvent
|
|
17960
|
+
}) : run;
|
|
17778
17961
|
return wrapRunWithPostReplyHook({
|
|
17779
17962
|
pluginManager: inputs.pluginManagerCode,
|
|
17780
17963
|
agentId: inputs.agentId,
|
|
17781
17964
|
options: inputs.options,
|
|
17782
|
-
run,
|
|
17965
|
+
run: processedRun,
|
|
17783
17966
|
userText
|
|
17784
17967
|
});
|
|
17785
17968
|
}
|
|
@@ -19138,6 +19321,48 @@ var Budget = class {
|
|
|
19138
19321
|
}
|
|
19139
19322
|
};
|
|
19140
19323
|
|
|
19324
|
+
// src/built-in-processors.ts
|
|
19325
|
+
var CHARS_PER_TOKEN = 4;
|
|
19326
|
+
function estimateTokens(text) {
|
|
19327
|
+
return Math.ceil(text.length / CHARS_PER_TOKEN);
|
|
19328
|
+
}
|
|
19329
|
+
var CONTROL_CHARS = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F]/g;
|
|
19330
|
+
function createUnicodeNormalizer(opts = {}) {
|
|
19331
|
+
const stripControlChars = opts.stripControlChars ?? false;
|
|
19332
|
+
const collapseWhitespace = opts.collapseWhitespace ?? false;
|
|
19333
|
+
return {
|
|
19334
|
+
id: "unicode-normalizer",
|
|
19335
|
+
processInput(ctx) {
|
|
19336
|
+
let s = ctx.message.normalize("NFC");
|
|
19337
|
+
if (stripControlChars) s = s.replace(CONTROL_CHARS, "");
|
|
19338
|
+
if (collapseWhitespace) {
|
|
19339
|
+
s = s.replace(/[^\S\n]+/g, " ").replace(/ *\n */g, "\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
19340
|
+
}
|
|
19341
|
+
return s;
|
|
19342
|
+
}
|
|
19343
|
+
};
|
|
19344
|
+
}
|
|
19345
|
+
function createTokenLimiter(opts) {
|
|
19346
|
+
if (!Number.isInteger(opts.limit) || opts.limit <= 0) {
|
|
19347
|
+
throw new Error("createTokenLimiter: `limit` must be a positive integer.");
|
|
19348
|
+
}
|
|
19349
|
+
const limit = opts.limit;
|
|
19350
|
+
const strategy = opts.strategy ?? "truncate";
|
|
19351
|
+
const cap2 = (text, controls) => {
|
|
19352
|
+
const estimated = estimateTokens(text);
|
|
19353
|
+
if (estimated <= limit) return text;
|
|
19354
|
+
if (strategy === "block") {
|
|
19355
|
+
controls.abort(`exceeds token limit ${limit} (~${estimated} estimated)`);
|
|
19356
|
+
}
|
|
19357
|
+
return [...text].slice(0, limit * CHARS_PER_TOKEN).join("");
|
|
19358
|
+
};
|
|
19359
|
+
return {
|
|
19360
|
+
id: "token-limiter",
|
|
19361
|
+
processInput: (ctx) => cap2(ctx.message, ctx),
|
|
19362
|
+
processOutput: (ctx) => cap2(ctx.text, ctx)
|
|
19363
|
+
};
|
|
19364
|
+
}
|
|
19365
|
+
|
|
19141
19366
|
// src/create-skill.ts
|
|
19142
19367
|
function createSkill(spec) {
|
|
19143
19368
|
if (!spec.name) throw new Error("createSkill: `name` is required.");
|
|
@@ -19819,7 +20044,7 @@ function createCounterBudgetTracker(options = {}) {
|
|
|
19819
20044
|
}
|
|
19820
20045
|
|
|
19821
20046
|
// src/internal/runtime/context/replay-history.ts
|
|
19822
|
-
var
|
|
20047
|
+
var CHARS_PER_TOKEN2 = 4;
|
|
19823
20048
|
var DEFAULT_RESERVE_TOKENS = 8e3;
|
|
19824
20049
|
function finiteOr(value, fallback) {
|
|
19825
20050
|
return Number.isFinite(value) ? value : fallback;
|
|
@@ -19827,7 +20052,7 @@ function finiteOr(value, fallback) {
|
|
|
19827
20052
|
function charBudget(options) {
|
|
19828
20053
|
const window = finiteOr(options.contextWindowTokens, 0);
|
|
19829
20054
|
const reserve = finiteOr(options.reserveTokens ?? DEFAULT_RESERVE_TOKENS, DEFAULT_RESERVE_TOKENS);
|
|
19830
|
-
return Math.max(0, window - reserve) *
|
|
20055
|
+
return Math.max(0, window - reserve) * CHARS_PER_TOKEN2;
|
|
19831
20056
|
}
|
|
19832
20057
|
function assistantText2(event) {
|
|
19833
20058
|
return event.message.content.filter((block) => block.type === "text").map((block) => block.text).join("");
|
|
@@ -21513,6 +21738,6 @@ function safeStringify2(v) {
|
|
|
21513
21738
|
}
|
|
21514
21739
|
}
|
|
21515
21740
|
|
|
21516
|
-
export { Agent, AgentBuilder, AgentDisposedError, AgentRunError, AuthenticationError, Budget, BudgetExceededError, ConfigurationError, Cron, EventBus, FileSystemConversationStorage, GenerateObjectError, InMemoryConversationStorage, IntegrationNotConnectedError, InvalidTaskIdError, JobQueue, Memory, MemoryAdapterError, NetworkError, PermissionEngine, RateLimitError, Security, StreamObjectError, Task, TaskNotFoundError, Theokit, TheokitAgentError, ToolError, UnknownAgentError, UnsupportedBudgetOperationError, UnsupportedRunOperationError, UnsupportedTaskOperationError, UsageAccumulator, applyMode, buildReplayHistory, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createPermissionPlugin, createSessionManager, createSkill, createSquad, definePlugin, defineProvider, defineSkillReadTool, defineTool, emitRunEvent, extractRawId, getPricingEntry, inferApiMode, isTransientError, migrateSqliteToLance2 as migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, preflightCheck, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, withCwdMutex };
|
|
21741
|
+
export { Agent, AgentBuilder, AgentDisposedError, AgentRunError, AuthenticationError, Budget, BudgetExceededError, ConfigurationError, Cron, EventBus, FileSystemConversationStorage, GenerateObjectError, InMemoryConversationStorage, IntegrationNotConnectedError, InvalidTaskIdError, JobQueue, Memory, MemoryAdapterError, NetworkError, PermissionEngine, RateLimitError, Security, StreamObjectError, Task, TaskNotFoundError, Theokit, TheokitAgentError, ToolError, UnknownAgentError, UnsupportedBudgetOperationError, UnsupportedRunOperationError, UnsupportedTaskOperationError, UsageAccumulator, applyMode, buildReplayHistory, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createPermissionPlugin, createSessionManager, createSkill, createSquad, createTokenLimiter, createUnicodeNormalizer, definePlugin, defineProvider, defineSkillReadTool, defineTool, emitRunEvent, estimateTokens, extractRawId, getPricingEntry, inferApiMode, isTransientError, migrateSqliteToLance2 as migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, preflightCheck, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, withCwdMutex };
|
|
21517
21742
|
//# sourceMappingURL=index.js.map
|
|
21518
21743
|
//# sourceMappingURL=index.js.map
|