@theokit/sdk 3.2.3 → 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 +6 -0
- package/dist/a2a/index.cjs +7 -1
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +7 -1
- 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 +7 -1
- 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 +7 -1
- 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 +7 -1
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +7 -1
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +15 -5
- 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 +15 -5
- package/dist/index.js.map +1 -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
|
@@ -9013,7 +9013,9 @@ async function vetoFromPluginPreHook(inputs, call, callId, events) {
|
|
|
9013
9013
|
name: call.name,
|
|
9014
9014
|
args: call.input,
|
|
9015
9015
|
agentId: inputs.agentId,
|
|
9016
|
-
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 } : {}
|
|
9017
9019
|
});
|
|
9018
9020
|
if (pluginVeto === void 0) return void 0;
|
|
9019
9021
|
emitRunEvent(inputs.runEventSink, {
|
|
@@ -13438,6 +13440,10 @@ function buildLoopInputs(options, runId, userText) {
|
|
|
13438
13440
|
...options.onDelta !== void 0 ? { onDelta: options.onDelta } : {},
|
|
13439
13441
|
...options.sendOptions.toolChoice !== void 0 ? { toolChoice: options.sendOptions.toolChoice } : {},
|
|
13440
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
|
+
} : {},
|
|
13441
13447
|
...options.priorMessages !== void 0 ? { priorMessages: options.priorMessages } : {},
|
|
13442
13448
|
...options.memoryTools !== void 0 && options.memoryTools.length > 0 ? { memoryTools: options.memoryTools } : {},
|
|
13443
13449
|
...buildCustomToolsInput(
|
|
@@ -22843,13 +22849,17 @@ function applyMode(verdict, mode, explicit) {
|
|
|
22843
22849
|
return verdict;
|
|
22844
22850
|
// allow stays allow
|
|
22845
22851
|
case "bypass":
|
|
22852
|
+
case "bypassPermissions":
|
|
22846
22853
|
return "allow";
|
|
22847
22854
|
}
|
|
22848
22855
|
}
|
|
22849
22856
|
function argMatches(matcher, value) {
|
|
22850
22857
|
if (typeof matcher === "function") return matcher(value);
|
|
22851
22858
|
if (value === void 0) return false;
|
|
22852
|
-
if (matcher instanceof RegExp)
|
|
22859
|
+
if (matcher instanceof RegExp) {
|
|
22860
|
+
matcher.lastIndex = 0;
|
|
22861
|
+
return matcher.test(String(value));
|
|
22862
|
+
}
|
|
22853
22863
|
return matcher === value;
|
|
22854
22864
|
}
|
|
22855
22865
|
var PermissionEngine = class {
|
|
@@ -22893,19 +22903,19 @@ async function resolveAsk(opts, name, args, mode) {
|
|
|
22893
22903
|
} catch {
|
|
22894
22904
|
return { block: true, message: `permission gate error (fail-closed): ${name}` };
|
|
22895
22905
|
}
|
|
22896
|
-
return decision
|
|
22906
|
+
return decision?.behavior === "allow" ? void 0 : { block: true, message: decision?.message ?? `denied: ${name}` };
|
|
22897
22907
|
}
|
|
22898
22908
|
return opts.onAsk ? opts.onAsk(name) : { block: true, message: `requires approval: ${name}` };
|
|
22899
22909
|
}
|
|
22900
22910
|
function createPermissionPlugin(engine, opts = {}) {
|
|
22901
|
-
const mode = opts.mode ?? "default";
|
|
22902
22911
|
return definePlugin({
|
|
22903
22912
|
name: opts.name ?? "permission-engine",
|
|
22904
22913
|
version: "1.0.0",
|
|
22905
22914
|
kind: "general",
|
|
22906
22915
|
register(ctx) {
|
|
22907
22916
|
ctx.on("pre_tool_call", async (rawCtx) => {
|
|
22908
|
-
const { name, args } = rawCtx;
|
|
22917
|
+
const { name, args, permissionMode } = rawCtx;
|
|
22918
|
+
const mode = permissionMode ?? opts.mode ?? "default";
|
|
22909
22919
|
const action = engine.evaluate(name, args, mode);
|
|
22910
22920
|
if (action === "deny") {
|
|
22911
22921
|
return { block: true, message: `denied by permission engine: ${name}` };
|