@theokit/sdk 3.2.2 → 3.3.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 +15 -0
- package/dist/a2a/index.cjs +56 -12
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +56 -12
- package/dist/a2a/index.js.map +1 -1
- package/dist/{cron-DuhVPer6.d.ts → cron-BxoLC-XX.d.cts} +15 -1
- package/dist/{cron-4u1UdmgC.d.cts → cron-DFta_5kE.d.ts} +15 -1
- package/dist/cron.cjs +56 -12
- 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 +56 -12
- package/dist/cron.js.map +1 -1
- package/dist/{errors-_fPS0X80.d.ts → errors-CFEt27lI.d.ts} +1 -1
- package/dist/{errors-jxK4yfp5.d.cts → errors-CIDoPGa7.d.cts} +1 -1
- package/dist/errors.d.cts +2 -2
- package/dist/eval.cjs +56 -12
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +56 -12
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +64 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -93
- package/dist/index.d.ts +7 -93
- package/dist/index.js +64 -16
- package/dist/index.js.map +1 -1
- package/dist/internal/persistence/pagination.d.cts +14 -1
- package/dist/internal/persistence/pagination.d.ts +14 -1
- package/dist/internal/plugins/types.d.cts +7 -0
- package/dist/internal/plugins/types.d.ts +7 -0
- package/dist/permission-engine.d.ts +4 -3
- package/dist/{run-CrHz9BAP.d.cts → run-CL5Rw6a5.d.cts} +98 -1
- package/dist/{run-CrHz9BAP.d.ts → run-CL5Rw6a5.d.ts} +98 -1
- package/dist/types/agent.d.ts +7 -0
- package/dist/types/run.d.ts +10 -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, O as ObjectiveRecord, B as BudgetTracker, r as MemoryProvider, s as MemoryId, t as PreToolCallDecision, u as StepResult, v as SDKProvider } from './cron-
|
|
4
|
-
export { w as ActiveMemoryPassArgs, x as ActiveMemoryPassResult, y as AgentGoalConfig, z as AgentMemory, D as BudgetCheck, E as BudgetTotal, F as BudgetUsageEvent, H as CloudEnv, J as CloudRepo, K as ContextBudget, N as ContextManagerKind, Q as ContextSnapshot, R as ContextSource, T as ContextSourceStatus, U as CreateSkillSpec, V as Cron, W as CronCreateOptions, X as CronGetOptions, Y as CronJob, Z as CronJobStatus, _ as CronListOptions, $ as CronOperationOptions, a0 as CronRunOptions, a1 as CronRuntime, a2 as CronSchedulerStatus, a3 as CronStartOptions, a4 as DurableGoalOptions, a5 as GoalEvent, a6 as GoalOptions, a7 as GoalResult, a8 as HookName, a9 as InvalidateCacheOptions, aa as MemoryAdapter, ab as MemoryAdapterCapabilities, ac as MemoryContext, ad as MemoryFact, ae as MemoryProviderHandle, af as MemoryProviderInitOptions, ag as MemoryRevision, ah as MemoryToolSchema, ai as MemoryTurnMessage, aj as ObjectiveStatus, ak as PersonalityPreset, al as PluginContext, am as PostAssistantReplyContext, an as PreToolCallContext, ao as PreUserSendContext, ap as PreUserSendResult, aq as ProviderCapability, ar as ProviderRoute, as as RecordSessionSummaryArgs, at as ResolvedProviderRoute, au as RunUntilIterator, av as SDKAgentPlugins, aw as SDKAgentSkillDetail, ax as SDKAgentSkills, ay as SDKArtifact, az as SDKContextManager, aA as SDKPluginMetadata, aB as SDKProvidersManager, aC as SettingSource, aD as Skill, aE as SkillsResolver, aF as SkillsResolverContext, aG as SystemPromptContext, aH as SystemPromptMemoryFact, aI as SystemPromptSkillRef, aJ as TelemetrySettings } from './cron-
|
|
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 } from './run-
|
|
6
|
-
export { A as AgentConversationTurn,
|
|
1
|
+
import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot, E as ErrorMetadata } from './errors-CIDoPGa7.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-CIDoPGa7.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, O as ObjectiveRecord, B as BudgetTracker, r as MemoryProvider, s as MemoryId, t as PreToolCallDecision, u as StepResult, v as SDKProvider } from './cron-BxoLC-XX.cjs';
|
|
4
|
+
export { w as ActiveMemoryPassArgs, x as ActiveMemoryPassResult, y as AgentGoalConfig, z as AgentMemory, D as BudgetCheck, E as BudgetTotal, F as BudgetUsageEvent, H as CloudEnv, J as CloudRepo, K as ContextBudget, N as ContextManagerKind, Q as ContextSnapshot, R as ContextSource, T as ContextSourceStatus, U as CreateSkillSpec, V as Cron, W as CronCreateOptions, X as CronGetOptions, Y as CronJob, Z as CronJobStatus, _ as CronListOptions, $ as CronOperationOptions, a0 as CronRunOptions, a1 as CronRuntime, a2 as CronSchedulerStatus, a3 as CronStartOptions, a4 as DurableGoalOptions, a5 as GoalEvent, a6 as GoalOptions, a7 as GoalResult, a8 as HookName, a9 as InvalidateCacheOptions, aa as MemoryAdapter, ab as MemoryAdapterCapabilities, ac as MemoryContext, ad as MemoryFact, ae as MemoryProviderHandle, af as MemoryProviderInitOptions, ag as MemoryRevision, ah as MemoryToolSchema, ai as MemoryTurnMessage, aj as ObjectiveStatus, ak as PersonalityPreset, al as PluginContext, am as PostAssistantReplyContext, an as PreToolCallContext, ao as PreUserSendContext, ap as PreUserSendResult, aq as ProviderCapability, ar as ProviderRoute, as as RecordSessionSummaryArgs, at as ResolvedProviderRoute, au as RunUntilIterator, av as SDKAgentPlugins, aw as SDKAgentSkillDetail, ax as SDKAgentSkills, ay as SDKArtifact, az as SDKContextManager, aA as SDKPluginMetadata, aB as SDKProvidersManager, aC as SettingSource, aD as Skill, aE as SkillsResolver, aF as SkillsResolverContext, aG as SystemPromptContext, aH as SystemPromptMemoryFact, aI as SystemPromptSkillRef, aJ as TelemetrySettings } from './cron-BxoLC-XX.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 PermissionMode, d as PermissionEngine } from './run-CL5Rw6a5.cjs';
|
|
6
|
+
export { A as AgentConversationTurn, e as AssistantMessage, f as CompletionCheck, g as CompletionCheckResult, h as ConversationStep, i as ConversationTurn, j as CostBreakdown, k as CostSource, l as CostStatus, D as DoomLoopThresholds, G as GenerateOptions, m as GenerateRunResult, I as ImageBlock, n as InputProcessorContext, o as InteractionUpdate, p as McpAuthConfig, q as McpHttpServerConfig, r as McpOAuthConfig, s as McpStdioServerConfig, t as MessageOrigin, u as ModelParameterValue, O as OutputProcessorContext, v as PartialToolCallUpdate, w as PermissionAction, x as PermissionEngineOptions, y as PermissionRule, z as ProcessorControls, B as ProcessorTripwire, E as ProcessorViolation, F as RunCompactBoundaryEvent, H as RunCompletionCheckEvent, J as RunErrorDetail, K as RunEvent, L as RunEventSink, 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-CL5Rw6a5.cjs';
|
|
7
7
|
import * as zod from 'zod';
|
|
8
8
|
import { ZodType, z } from 'zod';
|
|
9
9
|
|
|
@@ -1470,92 +1470,6 @@ interface MigrateResult {
|
|
|
1470
1470
|
*/
|
|
1471
1471
|
declare function migrateSqliteToLance(options: MigrateOptions): Promise<MigrateResult>;
|
|
1472
1472
|
|
|
1473
|
-
/**
|
|
1474
|
-
* `PermissionEngine` — first-match permission rules for tool invocations.
|
|
1475
|
-
*
|
|
1476
|
-
* Evaluates a tool name (and optional arguments, #55) against an ordered list
|
|
1477
|
-
* of rules. First matching rule wins; when no rule matches the `defaultAction`
|
|
1478
|
-
* is returned. #55 — the default is now `"ask"` (FAIL-CLOSED): a permission
|
|
1479
|
-
* engine that cannot positively allow must not silently allow. Opt back into
|
|
1480
|
-
* the previous fail-open behavior with `{ defaultAction: "allow" }`.
|
|
1481
|
-
*/
|
|
1482
|
-
type PermissionAction = "allow" | "deny" | "ask";
|
|
1483
|
-
/**
|
|
1484
|
-
* SE1 — a per-run permission MODE that adjusts the rule-engine verdict globally.
|
|
1485
|
-
* A PURE post-processor of the verdict (no tool-safety metadata needed, so it fits
|
|
1486
|
-
* a bring-your-own-tools runtime). Grounded in OpenCode (plan agent = deny-all,
|
|
1487
|
-
* `dangerously-skip-permissions`) + Codex (`AskForApproval`: `OnRequest` default,
|
|
1488
|
-
* `Never`, `UnlessTrusted`). See {@link applyMode} for the exact table.
|
|
1489
|
-
*
|
|
1490
|
-
* - `default` — verdict as-is (rules decide; unmatched ⇒ `ask`, fail-closed).
|
|
1491
|
-
* - `plan` — read-only: `allow` rules pass, everything else ⇒ `deny` (mutations blocked).
|
|
1492
|
-
* NOTE: `plan` gates on the resolved verdict, so an engine configured with
|
|
1493
|
-
* `{ defaultAction: "allow" }` still yields `allow` for UNMATCHED calls under
|
|
1494
|
-
* `plan` — pair `plan` with the default fail-closed engine (`defaultAction: "ask"`)
|
|
1495
|
-
* for full read-only behavior.
|
|
1496
|
-
* - `acceptEdits` — auto-approve the UNMATCHED verdict, but STILL honor an explicit
|
|
1497
|
-
* `ask` rule (a caller gates a risky tool with an ask rule). Codex `UnlessTrusted`.
|
|
1498
|
-
* - `bypass` — everything ⇒ `allow` EXCEPT an explicit `deny` rule. Never asks.
|
|
1499
|
-
* OpenCode `dangerously-skip-permissions` / Codex `Never`.
|
|
1500
|
-
*/
|
|
1501
|
-
type PermissionMode = "default" | "plan" | "acceptEdits" | "bypass";
|
|
1502
|
-
/**
|
|
1503
|
-
* SE1 — apply a {@link PermissionMode} to a rule-engine verdict. Pure.
|
|
1504
|
-
*
|
|
1505
|
-
* `explicit` is `true` when the verdict came from a rule that matched by name (and
|
|
1506
|
-
* args), `false` when it is the fail-closed default for an unmatched call. The flag
|
|
1507
|
-
* is load-bearing for `acceptEdits`, which auto-approves the unmatched default but
|
|
1508
|
-
* keeps honoring an explicit `ask` rule (unlike `bypass`, which allows even that).
|
|
1509
|
-
*
|
|
1510
|
-
* INVARIANT (both OpenCode + Codex): an explicit `deny` is immune to EVERY
|
|
1511
|
-
* auto-approve mode — `bypass`/`acceptEdits` never un-deny.
|
|
1512
|
-
*/
|
|
1513
|
-
declare function applyMode(verdict: PermissionAction, mode: PermissionMode, explicit: boolean): PermissionAction;
|
|
1514
|
-
/**
|
|
1515
|
-
* #55 — an argument matcher. A rule with `args` gates on the tool's argument
|
|
1516
|
-
* VALUES, not just its name: an exact string, a RegExp (tested against the
|
|
1517
|
-
* stringified value), or a predicate. Every declared arg must match for the
|
|
1518
|
-
* rule to apply — so `{ tool: "shell", args: { command: /rm\s+-rf/ } }` denies
|
|
1519
|
-
* a destructive shell call while leaving `ls` to fall through.
|
|
1520
|
-
*/
|
|
1521
|
-
type ArgMatcher = string | RegExp | ((value: unknown) => boolean);
|
|
1522
|
-
interface PermissionRule {
|
|
1523
|
-
/** Tool name (exact string) or pattern (RegExp). */
|
|
1524
|
-
tool: string | RegExp;
|
|
1525
|
-
/**
|
|
1526
|
-
* #55 — optional per-argument matchers. When present, the rule matches only
|
|
1527
|
-
* if the tool name matches AND every declared arg predicate matches the
|
|
1528
|
-
* corresponding call argument. A missing/undefined arg fails its predicate
|
|
1529
|
-
* (the rule does not match) — never throws.
|
|
1530
|
-
*/
|
|
1531
|
-
args?: Record<string, ArgMatcher>;
|
|
1532
|
-
/** Action to take when rule matches. */
|
|
1533
|
-
action: PermissionAction;
|
|
1534
|
-
}
|
|
1535
|
-
/** Options for {@link PermissionEngine}. */
|
|
1536
|
-
interface PermissionEngineOptions {
|
|
1537
|
-
/**
|
|
1538
|
-
* Action when no rule matches. #55 — default is now `"ask"` (fail-closed): a
|
|
1539
|
-
* permission engine that cannot positively allow must not silently allow.
|
|
1540
|
-
* Pass `"allow"` to restore the previous fail-open behavior.
|
|
1541
|
-
*/
|
|
1542
|
-
readonly defaultAction?: PermissionAction;
|
|
1543
|
-
}
|
|
1544
|
-
declare class PermissionEngine {
|
|
1545
|
-
#private;
|
|
1546
|
-
private readonly rules;
|
|
1547
|
-
private readonly defaultAction;
|
|
1548
|
-
constructor(rules: PermissionRule[], options?: PermissionEngineOptions);
|
|
1549
|
-
/**
|
|
1550
|
-
* Evaluate a tool name (and optional arguments) against the rules. First
|
|
1551
|
-
* match wins; falls back to the configured `defaultAction` (default `"ask"`,
|
|
1552
|
-
* fail-closed) when no rule matches. #55 — a rule with `args` gates on the
|
|
1553
|
-
* argument values, so the same tool name can resolve to different actions
|
|
1554
|
-
* depending on what it is asked to do.
|
|
1555
|
-
*/
|
|
1556
|
-
evaluate(toolName: string, args?: Record<string, unknown>, mode?: PermissionMode): PermissionAction;
|
|
1557
|
-
}
|
|
1558
|
-
|
|
1559
1473
|
/**
|
|
1560
1474
|
* M7-5 — `createPermissionPlugin`: wire a {@link PermissionEngine} into the
|
|
1561
1475
|
* `definePlugin` `pre_tool_call` veto seam. This is the canonical exemplar that
|
|
@@ -2406,4 +2320,4 @@ declare function toShareGptTrajectory(result: BatchResult, options?: {
|
|
|
2406
2320
|
model?: string;
|
|
2407
2321
|
}): ShareGptTrajectory | null;
|
|
2408
2322
|
|
|
2409
|
-
export { Agent, AgentBuilder, AgentDefinition, 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, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, NoopMemoryProvider, type NormalizedJsonSchema, ObjectiveRecord,
|
|
2323
|
+
export { Agent, AgentBuilder, AgentDefinition, 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, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, NoopMemoryProvider, type NormalizedJsonSchema, ObjectiveRecord, PermissionEngine, type PermissionGate, type PermissionGateContext, type PermissionGateDecision, PermissionMode, PermissionPlugin, type PermissionPluginOptions, Plugin, PluginsSettings, PreToolCallDecision, Processor, Provider, ProviderProfile, ProviderRoutingSettings, type ReplayHistoryOptions, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, Session, type SessionCapabilityResult, type SessionListOptions, type SessionManager, SessionMeta, SessionMetaPatch, type SessionScope, type SessionSummary, type ShareGptMessage, type ShareGptTrajectory, SkillReadTool, SkillsSettings, 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, TokenLimiter, type TokenLimiterOptions, Tool, ToolError, ToolResultContentBlock, UnicodeNormalizer, type UnicodeNormalizerOptions, UsageAccumulator, buildReplayHistory, chargeAndCheckThresholds, computeCost, createCounterBudgetTracker, 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, O as ObjectiveRecord, B as BudgetTracker, r as MemoryProvider, s as MemoryId, t as PreToolCallDecision, u as StepResult, v as SDKProvider } from './cron-
|
|
4
|
-
export { w as ActiveMemoryPassArgs, x as ActiveMemoryPassResult, y as AgentGoalConfig, z as AgentMemory, D as BudgetCheck, E as BudgetTotal, F as BudgetUsageEvent, H as CloudEnv, J as CloudRepo, K as ContextBudget, N as ContextManagerKind, Q as ContextSnapshot, R as ContextSource, T as ContextSourceStatus, U as CreateSkillSpec, V as Cron, W as CronCreateOptions, X as CronGetOptions, Y as CronJob, Z as CronJobStatus, _ as CronListOptions, $ as CronOperationOptions, a0 as CronRunOptions, a1 as CronRuntime, a2 as CronSchedulerStatus, a3 as CronStartOptions, a4 as DurableGoalOptions, a5 as GoalEvent, a6 as GoalOptions, a7 as GoalResult, a8 as HookName, a9 as InvalidateCacheOptions, aa as MemoryAdapter, ab as MemoryAdapterCapabilities, ac as MemoryContext, ad as MemoryFact, ae as MemoryProviderHandle, af as MemoryProviderInitOptions, ag as MemoryRevision, ah as MemoryToolSchema, ai as MemoryTurnMessage, aj as ObjectiveStatus, ak as PersonalityPreset, al as PluginContext, am as PostAssistantReplyContext, an as PreToolCallContext, ao as PreUserSendContext, ap as PreUserSendResult, aq as ProviderCapability, ar as ProviderRoute, as as RecordSessionSummaryArgs, at as ResolvedProviderRoute, au as RunUntilIterator, av as SDKAgentPlugins, aw as SDKAgentSkillDetail, ax as SDKAgentSkills, ay as SDKArtifact, az as SDKContextManager, aA as SDKPluginMetadata, aB as SDKProvidersManager, aC as SettingSource, aD as Skill, aE as SkillsResolver, aF as SkillsResolverContext, aG as SystemPromptContext, aH as SystemPromptMemoryFact, aI as SystemPromptSkillRef, aJ as TelemetrySettings } from './cron-
|
|
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 } from './run-
|
|
6
|
-
export { A as AgentConversationTurn,
|
|
1
|
+
import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot, E as ErrorMetadata } from './errors-CFEt27lI.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-CFEt27lI.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, O as ObjectiveRecord, B as BudgetTracker, r as MemoryProvider, s as MemoryId, t as PreToolCallDecision, u as StepResult, v as SDKProvider } from './cron-DFta_5kE.js';
|
|
4
|
+
export { w as ActiveMemoryPassArgs, x as ActiveMemoryPassResult, y as AgentGoalConfig, z as AgentMemory, D as BudgetCheck, E as BudgetTotal, F as BudgetUsageEvent, H as CloudEnv, J as CloudRepo, K as ContextBudget, N as ContextManagerKind, Q as ContextSnapshot, R as ContextSource, T as ContextSourceStatus, U as CreateSkillSpec, V as Cron, W as CronCreateOptions, X as CronGetOptions, Y as CronJob, Z as CronJobStatus, _ as CronListOptions, $ as CronOperationOptions, a0 as CronRunOptions, a1 as CronRuntime, a2 as CronSchedulerStatus, a3 as CronStartOptions, a4 as DurableGoalOptions, a5 as GoalEvent, a6 as GoalOptions, a7 as GoalResult, a8 as HookName, a9 as InvalidateCacheOptions, aa as MemoryAdapter, ab as MemoryAdapterCapabilities, ac as MemoryContext, ad as MemoryFact, ae as MemoryProviderHandle, af as MemoryProviderInitOptions, ag as MemoryRevision, ah as MemoryToolSchema, ai as MemoryTurnMessage, aj as ObjectiveStatus, ak as PersonalityPreset, al as PluginContext, am as PostAssistantReplyContext, an as PreToolCallContext, ao as PreUserSendContext, ap as PreUserSendResult, aq as ProviderCapability, ar as ProviderRoute, as as RecordSessionSummaryArgs, at as ResolvedProviderRoute, au as RunUntilIterator, av as SDKAgentPlugins, aw as SDKAgentSkillDetail, ax as SDKAgentSkills, ay as SDKArtifact, az as SDKContextManager, aA as SDKPluginMetadata, aB as SDKProvidersManager, aC as SettingSource, aD as Skill, aE as SkillsResolver, aF as SkillsResolverContext, aG as SystemPromptContext, aH as SystemPromptMemoryFact, aI as SystemPromptSkillRef, aJ as TelemetrySettings } from './cron-DFta_5kE.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 PermissionMode, d as PermissionEngine } from './run-CL5Rw6a5.js';
|
|
6
|
+
export { A as AgentConversationTurn, e as AssistantMessage, f as CompletionCheck, g as CompletionCheckResult, h as ConversationStep, i as ConversationTurn, j as CostBreakdown, k as CostSource, l as CostStatus, D as DoomLoopThresholds, G as GenerateOptions, m as GenerateRunResult, I as ImageBlock, n as InputProcessorContext, o as InteractionUpdate, p as McpAuthConfig, q as McpHttpServerConfig, r as McpOAuthConfig, s as McpStdioServerConfig, t as MessageOrigin, u as ModelParameterValue, O as OutputProcessorContext, v as PartialToolCallUpdate, w as PermissionAction, x as PermissionEngineOptions, y as PermissionRule, z as ProcessorControls, B as ProcessorTripwire, E as ProcessorViolation, F as RunCompactBoundaryEvent, H as RunCompletionCheckEvent, J as RunErrorDetail, K as RunEvent, L as RunEventSink, 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-CL5Rw6a5.js';
|
|
7
7
|
import * as zod from 'zod';
|
|
8
8
|
import { ZodType, z } from 'zod';
|
|
9
9
|
|
|
@@ -1470,92 +1470,6 @@ interface MigrateResult {
|
|
|
1470
1470
|
*/
|
|
1471
1471
|
declare function migrateSqliteToLance(options: MigrateOptions): Promise<MigrateResult>;
|
|
1472
1472
|
|
|
1473
|
-
/**
|
|
1474
|
-
* `PermissionEngine` — first-match permission rules for tool invocations.
|
|
1475
|
-
*
|
|
1476
|
-
* Evaluates a tool name (and optional arguments, #55) against an ordered list
|
|
1477
|
-
* of rules. First matching rule wins; when no rule matches the `defaultAction`
|
|
1478
|
-
* is returned. #55 — the default is now `"ask"` (FAIL-CLOSED): a permission
|
|
1479
|
-
* engine that cannot positively allow must not silently allow. Opt back into
|
|
1480
|
-
* the previous fail-open behavior with `{ defaultAction: "allow" }`.
|
|
1481
|
-
*/
|
|
1482
|
-
type PermissionAction = "allow" | "deny" | "ask";
|
|
1483
|
-
/**
|
|
1484
|
-
* SE1 — a per-run permission MODE that adjusts the rule-engine verdict globally.
|
|
1485
|
-
* A PURE post-processor of the verdict (no tool-safety metadata needed, so it fits
|
|
1486
|
-
* a bring-your-own-tools runtime). Grounded in OpenCode (plan agent = deny-all,
|
|
1487
|
-
* `dangerously-skip-permissions`) + Codex (`AskForApproval`: `OnRequest` default,
|
|
1488
|
-
* `Never`, `UnlessTrusted`). See {@link applyMode} for the exact table.
|
|
1489
|
-
*
|
|
1490
|
-
* - `default` — verdict as-is (rules decide; unmatched ⇒ `ask`, fail-closed).
|
|
1491
|
-
* - `plan` — read-only: `allow` rules pass, everything else ⇒ `deny` (mutations blocked).
|
|
1492
|
-
* NOTE: `plan` gates on the resolved verdict, so an engine configured with
|
|
1493
|
-
* `{ defaultAction: "allow" }` still yields `allow` for UNMATCHED calls under
|
|
1494
|
-
* `plan` — pair `plan` with the default fail-closed engine (`defaultAction: "ask"`)
|
|
1495
|
-
* for full read-only behavior.
|
|
1496
|
-
* - `acceptEdits` — auto-approve the UNMATCHED verdict, but STILL honor an explicit
|
|
1497
|
-
* `ask` rule (a caller gates a risky tool with an ask rule). Codex `UnlessTrusted`.
|
|
1498
|
-
* - `bypass` — everything ⇒ `allow` EXCEPT an explicit `deny` rule. Never asks.
|
|
1499
|
-
* OpenCode `dangerously-skip-permissions` / Codex `Never`.
|
|
1500
|
-
*/
|
|
1501
|
-
type PermissionMode = "default" | "plan" | "acceptEdits" | "bypass";
|
|
1502
|
-
/**
|
|
1503
|
-
* SE1 — apply a {@link PermissionMode} to a rule-engine verdict. Pure.
|
|
1504
|
-
*
|
|
1505
|
-
* `explicit` is `true` when the verdict came from a rule that matched by name (and
|
|
1506
|
-
* args), `false` when it is the fail-closed default for an unmatched call. The flag
|
|
1507
|
-
* is load-bearing for `acceptEdits`, which auto-approves the unmatched default but
|
|
1508
|
-
* keeps honoring an explicit `ask` rule (unlike `bypass`, which allows even that).
|
|
1509
|
-
*
|
|
1510
|
-
* INVARIANT (both OpenCode + Codex): an explicit `deny` is immune to EVERY
|
|
1511
|
-
* auto-approve mode — `bypass`/`acceptEdits` never un-deny.
|
|
1512
|
-
*/
|
|
1513
|
-
declare function applyMode(verdict: PermissionAction, mode: PermissionMode, explicit: boolean): PermissionAction;
|
|
1514
|
-
/**
|
|
1515
|
-
* #55 — an argument matcher. A rule with `args` gates on the tool's argument
|
|
1516
|
-
* VALUES, not just its name: an exact string, a RegExp (tested against the
|
|
1517
|
-
* stringified value), or a predicate. Every declared arg must match for the
|
|
1518
|
-
* rule to apply — so `{ tool: "shell", args: { command: /rm\s+-rf/ } }` denies
|
|
1519
|
-
* a destructive shell call while leaving `ls` to fall through.
|
|
1520
|
-
*/
|
|
1521
|
-
type ArgMatcher = string | RegExp | ((value: unknown) => boolean);
|
|
1522
|
-
interface PermissionRule {
|
|
1523
|
-
/** Tool name (exact string) or pattern (RegExp). */
|
|
1524
|
-
tool: string | RegExp;
|
|
1525
|
-
/**
|
|
1526
|
-
* #55 — optional per-argument matchers. When present, the rule matches only
|
|
1527
|
-
* if the tool name matches AND every declared arg predicate matches the
|
|
1528
|
-
* corresponding call argument. A missing/undefined arg fails its predicate
|
|
1529
|
-
* (the rule does not match) — never throws.
|
|
1530
|
-
*/
|
|
1531
|
-
args?: Record<string, ArgMatcher>;
|
|
1532
|
-
/** Action to take when rule matches. */
|
|
1533
|
-
action: PermissionAction;
|
|
1534
|
-
}
|
|
1535
|
-
/** Options for {@link PermissionEngine}. */
|
|
1536
|
-
interface PermissionEngineOptions {
|
|
1537
|
-
/**
|
|
1538
|
-
* Action when no rule matches. #55 — default is now `"ask"` (fail-closed): a
|
|
1539
|
-
* permission engine that cannot positively allow must not silently allow.
|
|
1540
|
-
* Pass `"allow"` to restore the previous fail-open behavior.
|
|
1541
|
-
*/
|
|
1542
|
-
readonly defaultAction?: PermissionAction;
|
|
1543
|
-
}
|
|
1544
|
-
declare class PermissionEngine {
|
|
1545
|
-
#private;
|
|
1546
|
-
private readonly rules;
|
|
1547
|
-
private readonly defaultAction;
|
|
1548
|
-
constructor(rules: PermissionRule[], options?: PermissionEngineOptions);
|
|
1549
|
-
/**
|
|
1550
|
-
* Evaluate a tool name (and optional arguments) against the rules. First
|
|
1551
|
-
* match wins; falls back to the configured `defaultAction` (default `"ask"`,
|
|
1552
|
-
* fail-closed) when no rule matches. #55 — a rule with `args` gates on the
|
|
1553
|
-
* argument values, so the same tool name can resolve to different actions
|
|
1554
|
-
* depending on what it is asked to do.
|
|
1555
|
-
*/
|
|
1556
|
-
evaluate(toolName: string, args?: Record<string, unknown>, mode?: PermissionMode): PermissionAction;
|
|
1557
|
-
}
|
|
1558
|
-
|
|
1559
1473
|
/**
|
|
1560
1474
|
* M7-5 — `createPermissionPlugin`: wire a {@link PermissionEngine} into the
|
|
1561
1475
|
* `definePlugin` `pre_tool_call` veto seam. This is the canonical exemplar that
|
|
@@ -2406,4 +2320,4 @@ declare function toShareGptTrajectory(result: BatchResult, options?: {
|
|
|
2406
2320
|
model?: string;
|
|
2407
2321
|
}): ShareGptTrajectory | null;
|
|
2408
2322
|
|
|
2409
|
-
export { Agent, AgentBuilder, AgentDefinition, 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, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, NoopMemoryProvider, type NormalizedJsonSchema, ObjectiveRecord,
|
|
2323
|
+
export { Agent, AgentBuilder, AgentDefinition, 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, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, NoopMemoryProvider, type NormalizedJsonSchema, ObjectiveRecord, PermissionEngine, type PermissionGate, type PermissionGateContext, type PermissionGateDecision, PermissionMode, PermissionPlugin, type PermissionPluginOptions, Plugin, PluginsSettings, PreToolCallDecision, Processor, Provider, ProviderProfile, ProviderRoutingSettings, type ReplayHistoryOptions, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, Session, type SessionCapabilityResult, type SessionListOptions, type SessionManager, SessionMeta, SessionMetaPatch, type SessionScope, type SessionSummary, type ShareGptMessage, type ShareGptTrajectory, SkillReadTool, SkillsSettings, 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, TokenLimiter, type TokenLimiterOptions, Tool, ToolError, ToolResultContentBlock, UnicodeNormalizer, type UnicodeNormalizerOptions, UsageAccumulator, buildReplayHistory, chargeAndCheckThresholds, computeCost, createCounterBudgetTracker, estimateTokens, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, preflightCheck, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, withCwdMutex };
|
package/dist/index.js
CHANGED
|
@@ -5170,12 +5170,23 @@ var init_objective_coerce = __esm({
|
|
|
5170
5170
|
// src/internal/persistence/pagination.ts
|
|
5171
5171
|
function paginate(items, opts) {
|
|
5172
5172
|
if (opts === void 0 || opts.offset === void 0 && opts.limit === void 0) return items;
|
|
5173
|
-
const start =
|
|
5174
|
-
const
|
|
5173
|
+
const start = opts.offset === void 0 ? 0 : requireNonNegativeInt(opts.offset, "offset");
|
|
5174
|
+
const limit = opts.limit === void 0 ? void 0 : requireNonNegativeInt(opts.limit, "limit");
|
|
5175
|
+
const end = limit === void 0 ? items.length : start + limit;
|
|
5175
5176
|
return items.slice(start, end);
|
|
5176
5177
|
}
|
|
5178
|
+
function requireNonNegativeInt(value, field) {
|
|
5179
|
+
if (!Number.isInteger(value) || value < 0) {
|
|
5180
|
+
throw new ConfigurationError(
|
|
5181
|
+
`Invalid pagination ${field}: expected a non-negative integer, got ${value}`,
|
|
5182
|
+
{ code: "pagination_invalid" }
|
|
5183
|
+
);
|
|
5184
|
+
}
|
|
5185
|
+
return value;
|
|
5186
|
+
}
|
|
5177
5187
|
var init_pagination = __esm({
|
|
5178
5188
|
"src/internal/persistence/pagination.ts"() {
|
|
5189
|
+
init_errors();
|
|
5179
5190
|
}
|
|
5180
5191
|
});
|
|
5181
5192
|
|
|
@@ -9002,7 +9013,9 @@ async function vetoFromPluginPreHook(inputs, call, callId, events) {
|
|
|
9002
9013
|
name: call.name,
|
|
9003
9014
|
args: call.input,
|
|
9004
9015
|
agentId: inputs.agentId,
|
|
9005
|
-
runId: inputs.runId
|
|
9016
|
+
runId: inputs.runId,
|
|
9017
|
+
// SE1 — thread the run's permission mode so a PermissionPlugin gates per-run.
|
|
9018
|
+
...inputs.permissionMode !== void 0 ? { permissionMode: inputs.permissionMode } : {}
|
|
9006
9019
|
});
|
|
9007
9020
|
if (pluginVeto === void 0) return void 0;
|
|
9008
9021
|
emitRunEvent(inputs.runEventSink, {
|
|
@@ -10347,6 +10360,8 @@ function parseRetryAfter(headers) {
|
|
|
10347
10360
|
if (raw === null) return void 0;
|
|
10348
10361
|
const n = Number(raw);
|
|
10349
10362
|
if (Number.isFinite(n) && n >= 0) return Math.ceil(n);
|
|
10363
|
+
const dateMs = Date.parse(raw);
|
|
10364
|
+
if (Number.isFinite(dateMs)) return Math.max(0, Math.ceil((dateMs - Date.now()) / 1e3));
|
|
10350
10365
|
return void 0;
|
|
10351
10366
|
}
|
|
10352
10367
|
function truncateRaw(body) {
|
|
@@ -10667,6 +10682,7 @@ function buildAnthropicBody(request) {
|
|
|
10667
10682
|
var AnthropicClient, AnthropicStreamAccumulator;
|
|
10668
10683
|
var init_anthropic3 = __esm({
|
|
10669
10684
|
"src/internal/llm/anthropic.ts"() {
|
|
10685
|
+
init_errors();
|
|
10670
10686
|
init_anthropic2();
|
|
10671
10687
|
init_anthropic_shared();
|
|
10672
10688
|
init_finish();
|
|
@@ -10720,12 +10736,23 @@ var init_anthropic3 = __esm({
|
|
|
10720
10736
|
const events = accumulator.consume(parsed);
|
|
10721
10737
|
for (const event of events) yield event;
|
|
10722
10738
|
}
|
|
10739
|
+
if (!accumulator.finishReasonSeen) {
|
|
10740
|
+
throw new NetworkError("Anthropic SSE stream truncated (no stop_reason)", {
|
|
10741
|
+
code: "stream_truncated"
|
|
10742
|
+
});
|
|
10743
|
+
}
|
|
10723
10744
|
return accumulator.finish();
|
|
10724
10745
|
}
|
|
10725
10746
|
};
|
|
10726
10747
|
AnthropicStreamAccumulator = class {
|
|
10727
10748
|
text = "";
|
|
10728
10749
|
stopReason = "end_turn";
|
|
10750
|
+
/**
|
|
10751
|
+
* M2 #61 — whether a `message_delta` carrying a real `stop_reason` was seen.
|
|
10752
|
+
* A stream that closes before it is a truncation (server FIN / proxy hiccup),
|
|
10753
|
+
* not a clean `end_turn` — the caller throws `stream_truncated` on `false`.
|
|
10754
|
+
*/
|
|
10755
|
+
sawStopReason = false;
|
|
10729
10756
|
inputTokens;
|
|
10730
10757
|
outputTokens;
|
|
10731
10758
|
cacheReadTokens;
|
|
@@ -10772,6 +10799,9 @@ var init_anthropic3 = __esm({
|
|
|
10772
10799
|
* spinning the SSE parser.
|
|
10773
10800
|
*/
|
|
10774
10801
|
handleMessageDelta(md) {
|
|
10802
|
+
if (md.delta.stop_reason !== void 0 && md.delta.stop_reason !== null) {
|
|
10803
|
+
this.sawStopReason = true;
|
|
10804
|
+
}
|
|
10775
10805
|
this.stopReason = mapAnthropicStopReason(md.delta.stop_reason);
|
|
10776
10806
|
if (md.usage?.input_tokens !== void 0) this.inputTokens = md.usage.input_tokens;
|
|
10777
10807
|
if (md.usage?.output_tokens !== void 0) this.outputTokens = md.usage.output_tokens;
|
|
@@ -10782,6 +10812,10 @@ var init_anthropic3 = __esm({
|
|
|
10782
10812
|
this.cacheReadTokens = md.usage.cache_read_input_tokens;
|
|
10783
10813
|
}
|
|
10784
10814
|
}
|
|
10815
|
+
/** M2 #61 — whether the terminal `message_delta` (stop_reason) was seen. */
|
|
10816
|
+
get finishReasonSeen() {
|
|
10817
|
+
return this.sawStopReason;
|
|
10818
|
+
}
|
|
10785
10819
|
finish() {
|
|
10786
10820
|
const toolCalls = [];
|
|
10787
10821
|
for (const [index, tool] of this.toolCalls.entries()) {
|
|
@@ -13015,7 +13049,6 @@ var init_client = __esm({
|
|
|
13015
13049
|
// concurrent request so parallel tool dispatch after a drop awaits one handshake
|
|
13016
13050
|
// instead of racing (or spuriously failing with mcp_not_init).
|
|
13017
13051
|
dropped = false;
|
|
13018
|
-
reconnectAttempts = 0;
|
|
13019
13052
|
reconnectPromise;
|
|
13020
13053
|
get timeoutMs() {
|
|
13021
13054
|
return this.config.requestTimeoutMs ?? DEFAULT_MCP_TIMEOUT_MS;
|
|
@@ -13068,15 +13101,22 @@ var init_client = __esm({
|
|
|
13068
13101
|
return this.reconnectPromise;
|
|
13069
13102
|
}
|
|
13070
13103
|
async reconnect() {
|
|
13071
|
-
|
|
13072
|
-
|
|
13104
|
+
let lastErr;
|
|
13105
|
+
for (let attempt = 0; attempt < MAX_RECONNECT_ATTEMPTS; attempt += 1) {
|
|
13106
|
+
await reconnectDelay(attempt);
|
|
13107
|
+
this.spawnChild();
|
|
13108
|
+
try {
|
|
13109
|
+
await super.initialize();
|
|
13110
|
+
this.dropped = false;
|
|
13111
|
+
return;
|
|
13112
|
+
} catch (err) {
|
|
13113
|
+
lastErr = err;
|
|
13114
|
+
}
|
|
13073
13115
|
}
|
|
13074
|
-
|
|
13075
|
-
|
|
13076
|
-
|
|
13077
|
-
|
|
13078
|
-
this.dropped = false;
|
|
13079
|
-
this.reconnectAttempts = 0;
|
|
13116
|
+
throw new NetworkError(`MCP ${this.name} reconnect exhausted`, {
|
|
13117
|
+
code: "mcp_disconnected",
|
|
13118
|
+
...lastErr instanceof Error ? { cause: lastErr } : {}
|
|
13119
|
+
});
|
|
13080
13120
|
}
|
|
13081
13121
|
async close() {
|
|
13082
13122
|
this.rejectAllPending(new NetworkError(`MCP ${this.name} closed`, { code: "mcp_closed" }));
|
|
@@ -13400,6 +13440,10 @@ function buildLoopInputs(options, runId, userText) {
|
|
|
13400
13440
|
...options.onDelta !== void 0 ? { onDelta: options.onDelta } : {},
|
|
13401
13441
|
...options.sendOptions.toolChoice !== void 0 ? { toolChoice: options.sendOptions.toolChoice } : {},
|
|
13402
13442
|
...options.sendOptions.activeTools !== void 0 ? { activeTools: options.sendOptions.activeTools } : {},
|
|
13443
|
+
// SE1 — resolve the run's permission mode: per-send wins over creation-time.
|
|
13444
|
+
...(options.sendOptions.permissionMode ?? options.agentOptions.permissionMode) !== void 0 ? {
|
|
13445
|
+
permissionMode: options.sendOptions.permissionMode ?? options.agentOptions.permissionMode
|
|
13446
|
+
} : {},
|
|
13403
13447
|
...options.priorMessages !== void 0 ? { priorMessages: options.priorMessages } : {},
|
|
13404
13448
|
...options.memoryTools !== void 0 && options.memoryTools.length > 0 ? { memoryTools: options.memoryTools } : {},
|
|
13405
13449
|
...buildCustomToolsInput(
|
|
@@ -22805,13 +22849,17 @@ function applyMode(verdict, mode, explicit) {
|
|
|
22805
22849
|
return verdict;
|
|
22806
22850
|
// allow stays allow
|
|
22807
22851
|
case "bypass":
|
|
22852
|
+
case "bypassPermissions":
|
|
22808
22853
|
return "allow";
|
|
22809
22854
|
}
|
|
22810
22855
|
}
|
|
22811
22856
|
function argMatches(matcher, value) {
|
|
22812
22857
|
if (typeof matcher === "function") return matcher(value);
|
|
22813
22858
|
if (value === void 0) return false;
|
|
22814
|
-
if (matcher instanceof RegExp)
|
|
22859
|
+
if (matcher instanceof RegExp) {
|
|
22860
|
+
matcher.lastIndex = 0;
|
|
22861
|
+
return matcher.test(String(value));
|
|
22862
|
+
}
|
|
22815
22863
|
return matcher === value;
|
|
22816
22864
|
}
|
|
22817
22865
|
var PermissionEngine = class {
|
|
@@ -22855,19 +22903,19 @@ async function resolveAsk(opts, name, args, mode) {
|
|
|
22855
22903
|
} catch {
|
|
22856
22904
|
return { block: true, message: `permission gate error (fail-closed): ${name}` };
|
|
22857
22905
|
}
|
|
22858
|
-
return decision
|
|
22906
|
+
return decision?.behavior === "allow" ? void 0 : { block: true, message: decision?.message ?? `denied: ${name}` };
|
|
22859
22907
|
}
|
|
22860
22908
|
return opts.onAsk ? opts.onAsk(name) : { block: true, message: `requires approval: ${name}` };
|
|
22861
22909
|
}
|
|
22862
22910
|
function createPermissionPlugin(engine, opts = {}) {
|
|
22863
|
-
const mode = opts.mode ?? "default";
|
|
22864
22911
|
return definePlugin({
|
|
22865
22912
|
name: opts.name ?? "permission-engine",
|
|
22866
22913
|
version: "1.0.0",
|
|
22867
22914
|
kind: "general",
|
|
22868
22915
|
register(ctx) {
|
|
22869
22916
|
ctx.on("pre_tool_call", async (rawCtx) => {
|
|
22870
|
-
const { name, args } = rawCtx;
|
|
22917
|
+
const { name, args, permissionMode } = rawCtx;
|
|
22918
|
+
const mode = permissionMode ?? opts.mode ?? "default";
|
|
22871
22919
|
const action = engine.evaluate(name, args, mode);
|
|
22872
22920
|
if (action === "deny") {
|
|
22873
22921
|
return { block: true, message: `denied by permission engine: ${name}` };
|