@theokit/sdk 2.3.0 → 2.5.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 +113 -0
- package/dist/a2a/index.cjs +103 -48
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +104 -49
- package/dist/a2a/index.js.map +1 -1
- package/dist/compaction.cjs +78 -0
- package/dist/compaction.cjs.map +1 -0
- package/dist/compaction.d.cts +76 -0
- package/dist/compaction.d.ts +76 -0
- package/dist/compaction.js +70 -0
- package/dist/compaction.js.map +1 -0
- package/dist/{cron-B_H8rn-j.d.cts → cron-B656C3iq.d.cts} +8 -0
- package/dist/{cron-DX6HbHxd.d.ts → cron-CM2M9mhB.d.ts} +8 -0
- package/dist/cron.cjs +104 -57
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.d.cts +1 -1
- package/dist/cron.d.ts +1 -1
- package/dist/cron.js +104 -57
- package/dist/cron.js.map +1 -1
- package/dist/eval.cjs +296 -73
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.d.cts +2 -0
- package/dist/eval.d.ts +2 -0
- package/dist/eval.js +295 -75
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +135 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -7
- package/dist/index.d.ts +42 -7
- package/dist/index.js +135 -66
- package/dist/index.js.map +1 -1
- package/dist/internal/agent-loop/loop.d.ts +5 -0
- package/dist/internal/eval/code-runner.d.ts +28 -0
- package/dist/internal/llm/model-capabilities.d.ts +40 -0
- package/dist/internal/llm/model-identifier.d.ts +9 -1
- package/dist/internal/llm/model-option.d.ts +38 -0
- package/dist/internal/persistence/index.cjs +68 -0
- package/dist/internal/persistence/index.cjs.map +1 -1
- package/dist/internal/persistence/index.d.cts +1 -0
- package/dist/internal/persistence/index.d.ts +1 -0
- package/dist/internal/persistence/index.js +65 -1
- package/dist/internal/persistence/index.js.map +1 -1
- package/dist/internal/persistence/jsonl.d.cts +34 -0
- package/dist/internal/persistence/jsonl.d.ts +34 -0
- package/dist/internal/runtime/compression/compression-attempt.d.ts +24 -0
- package/dist/internal/runtime/compression/compression-config.d.ts +33 -0
- package/dist/internal/runtime/compression/compression-decision.d.ts +10 -0
- package/dist/internal/runtime/compression/compression-helpers.d.ts +18 -0
- package/dist/internal/runtime/compression/compression-model-registry.d.ts +41 -0
- package/dist/internal/runtime/compression/compression-summarizer.d.ts +29 -0
- package/dist/internal/runtime/context/project-instructions.d.ts +66 -0
- package/dist/internal/runtime/context/replay-history.d.ts +43 -0
- package/dist/internal/runtime/hooks/hooks-frontmatter.d.ts +1 -1
- package/dist/internal/runtime/skills/discover-skills.d.ts +68 -0
- package/dist/internal/runtime/skills/skills-block.d.ts +18 -0
- package/dist/internal/runtime/skills/subagent-tool-scope.d.ts +25 -0
- package/dist/messages.cjs +24 -0
- package/dist/messages.cjs.map +1 -0
- package/dist/messages.d.cts +33 -0
- package/dist/messages.d.ts +33 -0
- package/dist/messages.js +20 -0
- package/dist/messages.js.map +1 -0
- package/dist/models.cjs +233 -0
- package/dist/models.cjs.map +1 -0
- package/dist/models.d.cts +16 -0
- package/dist/models.d.ts +16 -0
- package/dist/models.js +228 -0
- package/dist/models.js.map +1 -0
- package/dist/permission-engine.d.ts +12 -4
- package/dist/project.cjs +149 -0
- package/dist/project.cjs.map +1 -0
- package/dist/project.d.cts +14 -0
- package/dist/project.d.ts +14 -0
- package/dist/project.js +146 -0
- package/dist/project.js.map +1 -0
- package/dist/sandbox/index.cjs +71 -1
- package/dist/sandbox/index.cjs.map +1 -1
- package/dist/sandbox/index.d.cts +1 -0
- package/dist/sandbox/index.d.ts +1 -0
- package/dist/sandbox/index.js +70 -2
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/provision.d.cts +53 -0
- package/dist/sandbox/provision.d.ts +53 -0
- package/dist/sandbox/shell-escape.d.cts +8 -0
- package/dist/sandbox/shell-escape.d.ts +8 -0
- package/dist/scorers.d.ts +19 -1
- package/dist/skills.cjs +282 -0
- package/dist/skills.cjs.map +1 -0
- package/dist/skills.d.cts +19 -0
- package/dist/skills.d.ts +19 -0
- package/dist/skills.js +279 -0
- package/dist/skills.js.map +1 -0
- package/dist/subagents.cjs +24 -0
- package/dist/subagents.cjs.map +1 -0
- package/dist/subagents.d.cts +14 -0
- package/dist/subagents.d.ts +14 -0
- package/dist/subagents.js +21 -0
- package/dist/subagents.js.map +1 -0
- package/dist/types/agent.d.ts +8 -0
- package/dist/types/eval.d.ts +71 -0
- package/package.json +74 -14
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot } from './errors-QDYUPABr.cjs';
|
|
2
2
|
export { A as AgentDisposedError, c as AgentRunError, d as AgentRunErrorCode, e as AuthenticationError, f as BudgetExceedEvent, g as BudgetExceededError, h as BudgetLimit, i as BudgetMode, j as BudgetScope, k as BudgetThresholdEvent, l as BudgetWindow, C as ConfigurationError, E as ErrorCode, m as ErrorMetadata, 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-QDYUPABr.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 MemoryContext, m as ConversationStorageAdapter, n as StoredMessage, B as BudgetTracker, o as MemoryProvider, p as MemoryId, q as SDKProvider } from './cron-
|
|
4
|
-
export { r as ActiveMemoryPassArgs, s as ActiveMemoryPassResult, t as AgentMemory, u as BudgetCheck, v as BudgetTotal, w as BudgetUsageEvent, x as CloudEnv, y as CloudRepo, z as ContextBudget, D as ContextManagerKind, E as ContextSnapshot, F as ContextSource, H as ContextSourceStatus, I as Cron, J as CronCreateOptions, K as CronGetOptions, N as CronJob, O as CronJobStatus, Q as CronListOptions, R as CronOperationOptions, T as CronRunOptions, U as CronRuntime, V as CronSchedulerStatus, W as CronStartOptions, X as GoalEvent, Y as GoalOptions, Z as GoalResult, _ as InvalidateCacheOptions, $ as MemoryAdapter, a0 as MemoryAdapterCapabilities, a1 as MemoryFact, a2 as MemoryProviderHandle, a3 as MemoryProviderInitOptions, a4 as MemoryRevision, a5 as MemoryToolSchema, a6 as MemoryTurnMessage, a7 as PersonalityPreset, a8 as ProviderCapability, a9 as ProviderRoute, aa as RecordSessionSummaryArgs, ab as ResolvedProviderRoute, ac as RunUntilIterator, ad as SDKAgentPlugins, ae as SDKAgentSkills, af as SDKArtifact, ag as SDKContextManager, ah as SDKPluginMetadata, ai as SDKProvidersManager, aj as SettingSource, ak as SystemPromptContext, al as SystemPromptMemoryFact, am as SystemPromptSkillRef, an as TelemetrySettings } from './cron-
|
|
3
|
+
import { A as AgentOptions, L as LocalOptions, P as ProviderRoutingSettings, S as SystemPromptResolver, C as CloudOptions, M as MemorySettings, a as AgentDefinition, b as ContextSettings, c as PluginsSettings, d as SkillsSettings, e as SDKAgent, f as ListAgentsOptions, g as ListResult, h as SDKAgentInfo, G as GetAgentOptions, i as ListRunsOptions, j as GetRunOptions, k as AgentOperationOptions, l as MemoryContext, m as ConversationStorageAdapter, n as StoredMessage, B as BudgetTracker, o as MemoryProvider, p as MemoryId, q as SDKProvider } from './cron-B656C3iq.cjs';
|
|
4
|
+
export { r as ActiveMemoryPassArgs, s as ActiveMemoryPassResult, t as AgentMemory, u as BudgetCheck, v as BudgetTotal, w as BudgetUsageEvent, x as CloudEnv, y as CloudRepo, z as ContextBudget, D as ContextManagerKind, E as ContextSnapshot, F as ContextSource, H as ContextSourceStatus, I as Cron, J as CronCreateOptions, K as CronGetOptions, N as CronJob, O as CronJobStatus, Q as CronListOptions, R as CronOperationOptions, T as CronRunOptions, U as CronRuntime, V as CronSchedulerStatus, W as CronStartOptions, X as GoalEvent, Y as GoalOptions, Z as GoalResult, _ as InvalidateCacheOptions, $ as MemoryAdapter, a0 as MemoryAdapterCapabilities, a1 as MemoryFact, a2 as MemoryProviderHandle, a3 as MemoryProviderInitOptions, a4 as MemoryRevision, a5 as MemoryToolSchema, a6 as MemoryTurnMessage, a7 as PersonalityPreset, a8 as ProviderCapability, a9 as ProviderRoute, aa as RecordSessionSummaryArgs, ab as ResolvedProviderRoute, ac as RunUntilIterator, ad as SDKAgentPlugins, ae as SDKAgentSkills, af as SDKArtifact, ag as SDKContextManager, ah as SDKPluginMetadata, ai as SDKProvidersManager, aj as SettingSource, ak as SystemPromptContext, al as SystemPromptMemoryFact, am as SystemPromptSkillRef, an as TelemetrySettings } from './cron-B656C3iq.cjs';
|
|
5
5
|
import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, S as SDKMessage } from './run-BPRYG1Id.cjs';
|
|
6
6
|
export { A as AgentConversationTurn, c as AssistantMessage, d as ConversationStep, e as ConversationTurn, f as CostBreakdown, g as CostSource, h as CostStatus, I as InteractionUpdate, i as McpAuthConfig, j as McpHttpServerConfig, k as McpOAuthConfig, l as McpStdioServerConfig, m as ModelParameterValue, P as PartialToolCallUpdate, n as RunErrorDetail, o as RunGitInfo, p as RunOperation, q as RunStatus, r as RunToCompletionOptions, s as RunToCompletionResult, t as SDKAssistantMessage, u as SDKImage, v as SDKImageDimension, w as SDKObjectDelta, x as SDKRequestMessage, y as SDKStatusMessage, z as SDKSystemMessage, B as SDKTaskMessage, D as SDKThinkingMessage, E as SDKToolUseMessage, F as SDKUserMessage, G as SDKUserMessageEvent, H as SendOptions, J as ShellCommand, K as ShellConversationTurn, L as ShellOutput, N as ShellOutputDeltaUpdate, O as StepCompletedUpdate, Q as StepStartedUpdate, T as SummaryCompletedUpdate, U as SummaryStartedUpdate, V as SummaryUpdate, W as TextBlock, X as TextDeltaUpdate, Y as ThinkingCompletedUpdate, Z as ThinkingDeltaUpdate, _ as ThinkingMessage, $ as TokenDeltaUpdate, a0 as TokenUsage, a1 as ToolCall, a2 as ToolCallCompletedUpdate, a3 as ToolCallStartedUpdate, a4 as ToolResult, a5 as ToolUseBlock, a6 as TurnEndedUpdate, a7 as UserMessage, a8 as UserMessageAppendedUpdate } from './run-BPRYG1Id.cjs';
|
|
7
7
|
import * as zod from 'zod';
|
|
@@ -1428,8 +1428,9 @@ declare function migrateSqliteToLance(options: MigrateOptions): Promise<MigrateR
|
|
|
1428
1428
|
/**
|
|
1429
1429
|
* `PermissionEngine` — first-match permission rules for tool invocations.
|
|
1430
1430
|
*
|
|
1431
|
-
* Evaluates a tool name against an ordered list of rules.
|
|
1432
|
-
*
|
|
1431
|
+
* Evaluates a tool name against an ordered list of rules. First matching rule
|
|
1432
|
+
* wins; when no rule matches the `defaultAction` is returned (M7-4 — default
|
|
1433
|
+
* `"allow"`, opt into default-deny via `{ defaultAction: "deny" }`).
|
|
1433
1434
|
*/
|
|
1434
1435
|
type PermissionAction = "allow" | "deny" | "ask";
|
|
1435
1436
|
interface PermissionRule {
|
|
@@ -1438,15 +1439,49 @@ interface PermissionRule {
|
|
|
1438
1439
|
/** Action to take when rule matches. */
|
|
1439
1440
|
action: PermissionAction;
|
|
1440
1441
|
}
|
|
1442
|
+
/** Options for {@link PermissionEngine}. */
|
|
1443
|
+
interface PermissionEngineOptions {
|
|
1444
|
+
/** Action when no rule matches. Default `"allow"` (backward-compatible). M7-4. */
|
|
1445
|
+
readonly defaultAction?: PermissionAction;
|
|
1446
|
+
}
|
|
1441
1447
|
declare class PermissionEngine {
|
|
1442
1448
|
private readonly rules;
|
|
1443
|
-
|
|
1449
|
+
private readonly defaultAction;
|
|
1450
|
+
constructor(rules: PermissionRule[], options?: PermissionEngineOptions);
|
|
1444
1451
|
/**
|
|
1445
|
-
* Evaluate a tool name against the rules. First match wins;
|
|
1452
|
+
* Evaluate a tool name against the rules. First match wins; falls back to the
|
|
1453
|
+
* configured `defaultAction` (default `"allow"`) when no rule matches.
|
|
1446
1454
|
*/
|
|
1447
1455
|
evaluate(toolName: string): PermissionAction;
|
|
1448
1456
|
}
|
|
1449
1457
|
|
|
1458
|
+
/**
|
|
1459
|
+
* M7-5 — `createPermissionPlugin`: wire a {@link PermissionEngine} into the
|
|
1460
|
+
* `definePlugin` `pre_tool_call` veto seam. This is the canonical exemplar that
|
|
1461
|
+
* gives `PermissionEngine` a real caller (it was previously exported-but-unwired):
|
|
1462
|
+
* on each tool call the engine's verdict maps to the veto contract —
|
|
1463
|
+
* `"deny"` -> block, `"ask"` -> the caller's `onAsk` resolver (or block, fail-closed),
|
|
1464
|
+
* `"allow"` -> pass.
|
|
1465
|
+
*
|
|
1466
|
+
* @public
|
|
1467
|
+
*/
|
|
1468
|
+
|
|
1469
|
+
/** Options for {@link createPermissionPlugin}. */
|
|
1470
|
+
interface PermissionPluginOptions {
|
|
1471
|
+
/** Plugin name (default `"permission-engine"`). */
|
|
1472
|
+
readonly name?: string;
|
|
1473
|
+
/**
|
|
1474
|
+
* Resolver for the `"ask"` verdict. Returns a veto (`{block,message}`) to deny
|
|
1475
|
+
* or `undefined` to allow. Default: fail-closed (block with "requires approval").
|
|
1476
|
+
*/
|
|
1477
|
+
readonly onAsk?: (toolName: string) => PreToolCallDecision | undefined;
|
|
1478
|
+
}
|
|
1479
|
+
/**
|
|
1480
|
+
* Build a `general` plugin that vetoes tool calls per the engine's verdict.
|
|
1481
|
+
* Register it on an agent's plugin manager (same as the ACP permission plugin).
|
|
1482
|
+
*/
|
|
1483
|
+
declare function createPermissionPlugin(engine: PermissionEngine, opts?: PermissionPluginOptions): Plugin;
|
|
1484
|
+
|
|
1450
1485
|
/**
|
|
1451
1486
|
* Public security namespace (T2.1, ADR D68).
|
|
1452
1487
|
*
|
|
@@ -2151,4 +2186,4 @@ declare function toShareGptTrajectory(result: BatchResult, options?: {
|
|
|
2151
2186
|
model?: string;
|
|
2152
2187
|
}): ShareGptTrajectory | null;
|
|
2153
2188
|
|
|
2154
|
-
export { Agent, AgentBuilder, AgentDefinition, type AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, ConversationStorageAdapter, type CounterBudgetTrackerOptions, CustomTool, type DeepPartial, type DefineProviderOptions, type DefineToolSpec, type DreamingSweepOptions, type DreamingSweepResult, EventBus, type EvictReason, FileSystemConversationStorage, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, type HookName, InMemoryConversationStorage, JobQueue, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryContext, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, PermissionEngine, type Plugin, type PluginContext, PluginsSettings, type PostAssistantReplyContext, type PreToolCallContext, type PreToolCallDecision, type PreUserSendContext, type PreUserSendResult, type ProviderProfile, ProviderRoutingSettings, type ReplayHistoryOptions, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type ShareGptMessage, type ShareGptTrajectory, SkillsSettings, type Squad, type SquadOptions, type SquadRun, StoredMessage, StreamObjectError, type StreamObjectEvent, type StreamObjectOptions, SystemPromptResolver, TASK_RESERVED_PREFIXES, Task, type TaskCancelResult, type TaskConfigureOptions, type TaskEvent, type TaskFilter, type TaskHandle, type TaskKind, type TaskState, type TaskStoreOptions, type TaskSubmitOptions, type TaskWorkContext, type TaskWorkFn, Theokit, TheokitAgentError, type TheokitRequestOptions, UsageAccumulator, buildReplayHistory, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createSquad, definePlugin, defineProvider, defineTool, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeUsage, preflightCheck, toShareGptTrajectory, withCwdMutex };
|
|
2189
|
+
export { Agent, AgentBuilder, AgentDefinition, type AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, ConversationStorageAdapter, type CounterBudgetTrackerOptions, CustomTool, type DeepPartial, type DefineProviderOptions, type DefineToolSpec, type DreamingSweepOptions, type DreamingSweepResult, EventBus, type EvictReason, FileSystemConversationStorage, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, type HookName, InMemoryConversationStorage, JobQueue, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryContext, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, type PermissionAction, PermissionEngine, type PermissionEngineOptions, type PermissionPluginOptions, type PermissionRule, type Plugin, type PluginContext, PluginsSettings, type PostAssistantReplyContext, type PreToolCallContext, type PreToolCallDecision, type PreUserSendContext, type PreUserSendResult, type ProviderProfile, ProviderRoutingSettings, type ReplayHistoryOptions, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type ShareGptMessage, type ShareGptTrajectory, SkillsSettings, type Squad, type SquadOptions, type SquadRun, StoredMessage, StreamObjectError, type StreamObjectEvent, type StreamObjectOptions, SystemPromptResolver, TASK_RESERVED_PREFIXES, Task, type TaskCancelResult, type TaskConfigureOptions, type TaskEvent, type TaskFilter, type TaskHandle, type TaskKind, type TaskState, type TaskStoreOptions, type TaskSubmitOptions, type TaskWorkContext, type TaskWorkFn, Theokit, TheokitAgentError, type TheokitRequestOptions, UsageAccumulator, buildReplayHistory, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createPermissionPlugin, createSquad, definePlugin, defineProvider, defineTool, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeUsage, preflightCheck, toShareGptTrajectory, withCwdMutex };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot } from './errors-DG_7CAUg.js';
|
|
2
2
|
export { A as AgentDisposedError, c as AgentRunError, d as AgentRunErrorCode, e as AuthenticationError, f as BudgetExceedEvent, g as BudgetExceededError, h as BudgetLimit, i as BudgetMode, j as BudgetScope, k as BudgetThresholdEvent, l as BudgetWindow, C as ConfigurationError, E as ErrorCode, m as ErrorMetadata, 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-DG_7CAUg.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 MemoryContext, m as ConversationStorageAdapter, n as StoredMessage, B as BudgetTracker, o as MemoryProvider, p as MemoryId, q as SDKProvider } from './cron-
|
|
4
|
-
export { r as ActiveMemoryPassArgs, s as ActiveMemoryPassResult, t as AgentMemory, u as BudgetCheck, v as BudgetTotal, w as BudgetUsageEvent, x as CloudEnv, y as CloudRepo, z as ContextBudget, D as ContextManagerKind, E as ContextSnapshot, F as ContextSource, H as ContextSourceStatus, I as Cron, J as CronCreateOptions, K as CronGetOptions, N as CronJob, O as CronJobStatus, Q as CronListOptions, R as CronOperationOptions, T as CronRunOptions, U as CronRuntime, V as CronSchedulerStatus, W as CronStartOptions, X as GoalEvent, Y as GoalOptions, Z as GoalResult, _ as InvalidateCacheOptions, $ as MemoryAdapter, a0 as MemoryAdapterCapabilities, a1 as MemoryFact, a2 as MemoryProviderHandle, a3 as MemoryProviderInitOptions, a4 as MemoryRevision, a5 as MemoryToolSchema, a6 as MemoryTurnMessage, a7 as PersonalityPreset, a8 as ProviderCapability, a9 as ProviderRoute, aa as RecordSessionSummaryArgs, ab as ResolvedProviderRoute, ac as RunUntilIterator, ad as SDKAgentPlugins, ae as SDKAgentSkills, af as SDKArtifact, ag as SDKContextManager, ah as SDKPluginMetadata, ai as SDKProvidersManager, aj as SettingSource, ak as SystemPromptContext, al as SystemPromptMemoryFact, am as SystemPromptSkillRef, an as TelemetrySettings } from './cron-
|
|
3
|
+
import { A as AgentOptions, L as LocalOptions, P as ProviderRoutingSettings, S as SystemPromptResolver, C as CloudOptions, M as MemorySettings, a as AgentDefinition, b as ContextSettings, c as PluginsSettings, d as SkillsSettings, e as SDKAgent, f as ListAgentsOptions, g as ListResult, h as SDKAgentInfo, G as GetAgentOptions, i as ListRunsOptions, j as GetRunOptions, k as AgentOperationOptions, l as MemoryContext, m as ConversationStorageAdapter, n as StoredMessage, B as BudgetTracker, o as MemoryProvider, p as MemoryId, q as SDKProvider } from './cron-CM2M9mhB.js';
|
|
4
|
+
export { r as ActiveMemoryPassArgs, s as ActiveMemoryPassResult, t as AgentMemory, u as BudgetCheck, v as BudgetTotal, w as BudgetUsageEvent, x as CloudEnv, y as CloudRepo, z as ContextBudget, D as ContextManagerKind, E as ContextSnapshot, F as ContextSource, H as ContextSourceStatus, I as Cron, J as CronCreateOptions, K as CronGetOptions, N as CronJob, O as CronJobStatus, Q as CronListOptions, R as CronOperationOptions, T as CronRunOptions, U as CronRuntime, V as CronSchedulerStatus, W as CronStartOptions, X as GoalEvent, Y as GoalOptions, Z as GoalResult, _ as InvalidateCacheOptions, $ as MemoryAdapter, a0 as MemoryAdapterCapabilities, a1 as MemoryFact, a2 as MemoryProviderHandle, a3 as MemoryProviderInitOptions, a4 as MemoryRevision, a5 as MemoryToolSchema, a6 as MemoryTurnMessage, a7 as PersonalityPreset, a8 as ProviderCapability, a9 as ProviderRoute, aa as RecordSessionSummaryArgs, ab as ResolvedProviderRoute, ac as RunUntilIterator, ad as SDKAgentPlugins, ae as SDKAgentSkills, af as SDKArtifact, ag as SDKContextManager, ah as SDKPluginMetadata, ai as SDKProvidersManager, aj as SettingSource, ak as SystemPromptContext, al as SystemPromptMemoryFact, am as SystemPromptSkillRef, an as TelemetrySettings } from './cron-CM2M9mhB.js';
|
|
5
5
|
import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, S as SDKMessage } from './run-BPRYG1Id.js';
|
|
6
6
|
export { A as AgentConversationTurn, c as AssistantMessage, d as ConversationStep, e as ConversationTurn, f as CostBreakdown, g as CostSource, h as CostStatus, I as InteractionUpdate, i as McpAuthConfig, j as McpHttpServerConfig, k as McpOAuthConfig, l as McpStdioServerConfig, m as ModelParameterValue, P as PartialToolCallUpdate, n as RunErrorDetail, o as RunGitInfo, p as RunOperation, q as RunStatus, r as RunToCompletionOptions, s as RunToCompletionResult, t as SDKAssistantMessage, u as SDKImage, v as SDKImageDimension, w as SDKObjectDelta, x as SDKRequestMessage, y as SDKStatusMessage, z as SDKSystemMessage, B as SDKTaskMessage, D as SDKThinkingMessage, E as SDKToolUseMessage, F as SDKUserMessage, G as SDKUserMessageEvent, H as SendOptions, J as ShellCommand, K as ShellConversationTurn, L as ShellOutput, N as ShellOutputDeltaUpdate, O as StepCompletedUpdate, Q as StepStartedUpdate, T as SummaryCompletedUpdate, U as SummaryStartedUpdate, V as SummaryUpdate, W as TextBlock, X as TextDeltaUpdate, Y as ThinkingCompletedUpdate, Z as ThinkingDeltaUpdate, _ as ThinkingMessage, $ as TokenDeltaUpdate, a0 as TokenUsage, a1 as ToolCall, a2 as ToolCallCompletedUpdate, a3 as ToolCallStartedUpdate, a4 as ToolResult, a5 as ToolUseBlock, a6 as TurnEndedUpdate, a7 as UserMessage, a8 as UserMessageAppendedUpdate } from './run-BPRYG1Id.js';
|
|
7
7
|
import * as zod from 'zod';
|
|
@@ -1428,8 +1428,9 @@ declare function migrateSqliteToLance(options: MigrateOptions): Promise<MigrateR
|
|
|
1428
1428
|
/**
|
|
1429
1429
|
* `PermissionEngine` — first-match permission rules for tool invocations.
|
|
1430
1430
|
*
|
|
1431
|
-
* Evaluates a tool name against an ordered list of rules.
|
|
1432
|
-
*
|
|
1431
|
+
* Evaluates a tool name against an ordered list of rules. First matching rule
|
|
1432
|
+
* wins; when no rule matches the `defaultAction` is returned (M7-4 — default
|
|
1433
|
+
* `"allow"`, opt into default-deny via `{ defaultAction: "deny" }`).
|
|
1433
1434
|
*/
|
|
1434
1435
|
type PermissionAction = "allow" | "deny" | "ask";
|
|
1435
1436
|
interface PermissionRule {
|
|
@@ -1438,15 +1439,49 @@ interface PermissionRule {
|
|
|
1438
1439
|
/** Action to take when rule matches. */
|
|
1439
1440
|
action: PermissionAction;
|
|
1440
1441
|
}
|
|
1442
|
+
/** Options for {@link PermissionEngine}. */
|
|
1443
|
+
interface PermissionEngineOptions {
|
|
1444
|
+
/** Action when no rule matches. Default `"allow"` (backward-compatible). M7-4. */
|
|
1445
|
+
readonly defaultAction?: PermissionAction;
|
|
1446
|
+
}
|
|
1441
1447
|
declare class PermissionEngine {
|
|
1442
1448
|
private readonly rules;
|
|
1443
|
-
|
|
1449
|
+
private readonly defaultAction;
|
|
1450
|
+
constructor(rules: PermissionRule[], options?: PermissionEngineOptions);
|
|
1444
1451
|
/**
|
|
1445
|
-
* Evaluate a tool name against the rules. First match wins;
|
|
1452
|
+
* Evaluate a tool name against the rules. First match wins; falls back to the
|
|
1453
|
+
* configured `defaultAction` (default `"allow"`) when no rule matches.
|
|
1446
1454
|
*/
|
|
1447
1455
|
evaluate(toolName: string): PermissionAction;
|
|
1448
1456
|
}
|
|
1449
1457
|
|
|
1458
|
+
/**
|
|
1459
|
+
* M7-5 — `createPermissionPlugin`: wire a {@link PermissionEngine} into the
|
|
1460
|
+
* `definePlugin` `pre_tool_call` veto seam. This is the canonical exemplar that
|
|
1461
|
+
* gives `PermissionEngine` a real caller (it was previously exported-but-unwired):
|
|
1462
|
+
* on each tool call the engine's verdict maps to the veto contract —
|
|
1463
|
+
* `"deny"` -> block, `"ask"` -> the caller's `onAsk` resolver (or block, fail-closed),
|
|
1464
|
+
* `"allow"` -> pass.
|
|
1465
|
+
*
|
|
1466
|
+
* @public
|
|
1467
|
+
*/
|
|
1468
|
+
|
|
1469
|
+
/** Options for {@link createPermissionPlugin}. */
|
|
1470
|
+
interface PermissionPluginOptions {
|
|
1471
|
+
/** Plugin name (default `"permission-engine"`). */
|
|
1472
|
+
readonly name?: string;
|
|
1473
|
+
/**
|
|
1474
|
+
* Resolver for the `"ask"` verdict. Returns a veto (`{block,message}`) to deny
|
|
1475
|
+
* or `undefined` to allow. Default: fail-closed (block with "requires approval").
|
|
1476
|
+
*/
|
|
1477
|
+
readonly onAsk?: (toolName: string) => PreToolCallDecision | undefined;
|
|
1478
|
+
}
|
|
1479
|
+
/**
|
|
1480
|
+
* Build a `general` plugin that vetoes tool calls per the engine's verdict.
|
|
1481
|
+
* Register it on an agent's plugin manager (same as the ACP permission plugin).
|
|
1482
|
+
*/
|
|
1483
|
+
declare function createPermissionPlugin(engine: PermissionEngine, opts?: PermissionPluginOptions): Plugin;
|
|
1484
|
+
|
|
1450
1485
|
/**
|
|
1451
1486
|
* Public security namespace (T2.1, ADR D68).
|
|
1452
1487
|
*
|
|
@@ -2151,4 +2186,4 @@ declare function toShareGptTrajectory(result: BatchResult, options?: {
|
|
|
2151
2186
|
model?: string;
|
|
2152
2187
|
}): ShareGptTrajectory | null;
|
|
2153
2188
|
|
|
2154
|
-
export { Agent, AgentBuilder, AgentDefinition, type AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, ConversationStorageAdapter, type CounterBudgetTrackerOptions, CustomTool, type DeepPartial, type DefineProviderOptions, type DefineToolSpec, type DreamingSweepOptions, type DreamingSweepResult, EventBus, type EvictReason, FileSystemConversationStorage, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, type HookName, InMemoryConversationStorage, JobQueue, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryContext, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, PermissionEngine, type Plugin, type PluginContext, PluginsSettings, type PostAssistantReplyContext, type PreToolCallContext, type PreToolCallDecision, type PreUserSendContext, type PreUserSendResult, type ProviderProfile, ProviderRoutingSettings, type ReplayHistoryOptions, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type ShareGptMessage, type ShareGptTrajectory, SkillsSettings, type Squad, type SquadOptions, type SquadRun, StoredMessage, StreamObjectError, type StreamObjectEvent, type StreamObjectOptions, SystemPromptResolver, TASK_RESERVED_PREFIXES, Task, type TaskCancelResult, type TaskConfigureOptions, type TaskEvent, type TaskFilter, type TaskHandle, type TaskKind, type TaskState, type TaskStoreOptions, type TaskSubmitOptions, type TaskWorkContext, type TaskWorkFn, Theokit, TheokitAgentError, type TheokitRequestOptions, UsageAccumulator, buildReplayHistory, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createSquad, definePlugin, defineProvider, defineTool, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeUsage, preflightCheck, toShareGptTrajectory, withCwdMutex };
|
|
2189
|
+
export { Agent, AgentBuilder, AgentDefinition, type AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, ConversationStorageAdapter, type CounterBudgetTrackerOptions, CustomTool, type DeepPartial, type DefineProviderOptions, type DefineToolSpec, type DreamingSweepOptions, type DreamingSweepResult, EventBus, type EvictReason, FileSystemConversationStorage, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, type HookName, InMemoryConversationStorage, JobQueue, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryContext, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, type PermissionAction, PermissionEngine, type PermissionEngineOptions, type PermissionPluginOptions, type PermissionRule, type Plugin, type PluginContext, PluginsSettings, type PostAssistantReplyContext, type PreToolCallContext, type PreToolCallDecision, type PreUserSendContext, type PreUserSendResult, type ProviderProfile, ProviderRoutingSettings, type ReplayHistoryOptions, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type ShareGptMessage, type ShareGptTrajectory, SkillsSettings, type Squad, type SquadOptions, type SquadRun, StoredMessage, StreamObjectError, type StreamObjectEvent, type StreamObjectOptions, SystemPromptResolver, TASK_RESERVED_PREFIXES, Task, type TaskCancelResult, type TaskConfigureOptions, type TaskEvent, type TaskFilter, type TaskHandle, type TaskKind, type TaskState, type TaskStoreOptions, type TaskSubmitOptions, type TaskWorkContext, type TaskWorkFn, Theokit, TheokitAgentError, type TheokitRequestOptions, UsageAccumulator, buildReplayHistory, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createPermissionPlugin, createSquad, definePlugin, defineProvider, defineTool, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeUsage, preflightCheck, toShareGptTrajectory, withCwdMutex };
|
package/dist/index.js
CHANGED
|
@@ -8956,6 +8956,8 @@ function parseSubagentMarkdown(raw, filename) {
|
|
|
8956
8956
|
if (fields.model !== void 0) {
|
|
8957
8957
|
definition.model = fields.model === "inherit" ? "inherit" : { id: fields.model };
|
|
8958
8958
|
}
|
|
8959
|
+
const tools = fields.tools?.split(/[\s,]+/).map((t) => t.trim()).filter((t) => t.length > 0);
|
|
8960
|
+
if (tools !== void 0 && tools.length > 0) definition.tools = tools;
|
|
8959
8961
|
return { name, definition };
|
|
8960
8962
|
}
|
|
8961
8963
|
function splitFrontmatter2(raw, filename) {
|
|
@@ -9119,21 +9121,24 @@ ${lines.join("\n")}
|
|
|
9119
9121
|
}
|
|
9120
9122
|
};
|
|
9121
9123
|
|
|
9124
|
+
// src/internal/runtime/skills/skills-block.ts
|
|
9125
|
+
function buildSkillsBlock(skills) {
|
|
9126
|
+
if (skills.length === 0) return void 0;
|
|
9127
|
+
const lines = skills.map(
|
|
9128
|
+
(skill) => ` - ${escapeBlockBody(skill.name)}: ${escapeBlockBody(skill.description)}`
|
|
9129
|
+
);
|
|
9130
|
+
return `<skills>
|
|
9131
|
+
${lines.join("\n")}
|
|
9132
|
+
</skills>`;
|
|
9133
|
+
}
|
|
9134
|
+
|
|
9122
9135
|
// src/internal/runtime/system-prompt/sources/skills-provider.ts
|
|
9123
9136
|
var SkillsPromptProvider = class {
|
|
9124
9137
|
id = "skills";
|
|
9125
9138
|
priority = 20;
|
|
9126
9139
|
contribute(ctx) {
|
|
9127
9140
|
if (ctx.skillsAutoInject === false) return Promise.resolve(void 0);
|
|
9128
|
-
|
|
9129
|
-
const lines = ctx.skills.map((skill) => {
|
|
9130
|
-
const name = escapeBlockBody(skill.name);
|
|
9131
|
-
const description = escapeBlockBody(skill.description);
|
|
9132
|
-
return ` - ${name}: ${description}`;
|
|
9133
|
-
});
|
|
9134
|
-
return Promise.resolve(`<skills>
|
|
9135
|
-
${lines.join("\n")}
|
|
9136
|
-
</skills>`);
|
|
9141
|
+
return Promise.resolve(buildSkillsBlock(ctx.skills));
|
|
9137
9142
|
}
|
|
9138
9143
|
};
|
|
9139
9144
|
|
|
@@ -10242,7 +10247,7 @@ async function loadPluginManifestFromMarkdown(pluginsRoot, folderName) {
|
|
|
10242
10247
|
return metadata;
|
|
10243
10248
|
}
|
|
10244
10249
|
|
|
10245
|
-
// src/internal/runtime/skills/skills
|
|
10250
|
+
// src/internal/runtime/skills/discover-skills.ts
|
|
10246
10251
|
init_errors();
|
|
10247
10252
|
init_path_guard();
|
|
10248
10253
|
|
|
@@ -10315,6 +10320,61 @@ function hasContent(value) {
|
|
|
10315
10320
|
return value !== void 0 && value.trim().length > 0;
|
|
10316
10321
|
}
|
|
10317
10322
|
|
|
10323
|
+
// src/internal/runtime/skills/discover-skills.ts
|
|
10324
|
+
async function discoverSkills(dir, options) {
|
|
10325
|
+
let entries;
|
|
10326
|
+
try {
|
|
10327
|
+
entries = await readWorkspaceDir(dir, "skills_read_error", "skills directory");
|
|
10328
|
+
} catch {
|
|
10329
|
+
return [];
|
|
10330
|
+
}
|
|
10331
|
+
const skills = [];
|
|
10332
|
+
for (const entry of entries) {
|
|
10333
|
+
if (!entry.isDirectory()) continue;
|
|
10334
|
+
let skillDir;
|
|
10335
|
+
try {
|
|
10336
|
+
skillDir = safePathJoin(dir, entry.name);
|
|
10337
|
+
assertNoSymlinkEscape(skillDir, dir);
|
|
10338
|
+
} catch {
|
|
10339
|
+
continue;
|
|
10340
|
+
}
|
|
10341
|
+
const skillPath = join(skillDir, "SKILL.md");
|
|
10342
|
+
let raw;
|
|
10343
|
+
try {
|
|
10344
|
+
raw = await readFile(skillPath, "utf8");
|
|
10345
|
+
} catch {
|
|
10346
|
+
continue;
|
|
10347
|
+
}
|
|
10348
|
+
const skill = tryParseSkill(raw, entry.name, skillPath, options);
|
|
10349
|
+
if (skill !== void 0) skills.push(skill);
|
|
10350
|
+
}
|
|
10351
|
+
return skills;
|
|
10352
|
+
}
|
|
10353
|
+
function tryParseSkill(raw, fallbackName, source, options) {
|
|
10354
|
+
try {
|
|
10355
|
+
const frontmatter = parseSkillFrontmatter(raw, fallbackName);
|
|
10356
|
+
const skill = {
|
|
10357
|
+
name: frontmatter.name,
|
|
10358
|
+
description: frontmatter.description,
|
|
10359
|
+
source
|
|
10360
|
+
};
|
|
10361
|
+
if (frontmatter.category !== void 0) skill.category = frontmatter.category;
|
|
10362
|
+
if (frontmatter.dependencies !== void 0) skill.dependencies = frontmatter.dependencies;
|
|
10363
|
+
return skill;
|
|
10364
|
+
} catch (cause) {
|
|
10365
|
+
if (cause instanceof ConfigurationError) {
|
|
10366
|
+
options?.onInvalidSkill?.({
|
|
10367
|
+
name: fallbackName,
|
|
10368
|
+
source,
|
|
10369
|
+
code: cause.code ?? "unknown",
|
|
10370
|
+
message: cause.message
|
|
10371
|
+
});
|
|
10372
|
+
return void 0;
|
|
10373
|
+
}
|
|
10374
|
+
throw cause;
|
|
10375
|
+
}
|
|
10376
|
+
}
|
|
10377
|
+
|
|
10318
10378
|
// src/internal/runtime/skills/skills-manager.ts
|
|
10319
10379
|
var SkillsManager = class {
|
|
10320
10380
|
constructor(cwd, _enabled, settingSourcesIncludeProject) {
|
|
@@ -10332,56 +10392,20 @@ var SkillsManager = class {
|
|
|
10332
10392
|
await this.refresh();
|
|
10333
10393
|
}
|
|
10334
10394
|
async refresh() {
|
|
10335
|
-
this.skills = [];
|
|
10336
10395
|
const skillsRoot = join(this.cwd, ".theokit", "skills");
|
|
10337
|
-
|
|
10338
|
-
|
|
10339
|
-
|
|
10340
|
-
|
|
10341
|
-
|
|
10342
|
-
|
|
10343
|
-
assertNoSymlinkEscape(skillDir, skillsRoot);
|
|
10344
|
-
} catch {
|
|
10345
|
-
continue;
|
|
10346
|
-
}
|
|
10347
|
-
const skillPath = join(skillDir, "SKILL.md");
|
|
10348
|
-
let raw;
|
|
10349
|
-
try {
|
|
10350
|
-
raw = await readFile(skillPath, "utf8");
|
|
10351
|
-
} catch {
|
|
10352
|
-
continue;
|
|
10396
|
+
this.skills = await discoverSkills(skillsRoot, {
|
|
10397
|
+
onInvalidSkill: (info) => {
|
|
10398
|
+
process.stderr.write(
|
|
10399
|
+
`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
|
|
10400
|
+
`
|
|
10401
|
+
);
|
|
10353
10402
|
}
|
|
10354
|
-
|
|
10355
|
-
if (metadata !== void 0) this.skills.push(metadata);
|
|
10356
|
-
}
|
|
10403
|
+
});
|
|
10357
10404
|
}
|
|
10358
10405
|
list() {
|
|
10359
10406
|
return Promise.resolve(this.skills);
|
|
10360
10407
|
}
|
|
10361
10408
|
};
|
|
10362
|
-
function tryParseSkill(raw, fallbackName, source) {
|
|
10363
|
-
try {
|
|
10364
|
-
const frontmatter = parseSkillFrontmatter(raw, fallbackName);
|
|
10365
|
-
const metadata = {
|
|
10366
|
-
name: frontmatter.name,
|
|
10367
|
-
description: frontmatter.description,
|
|
10368
|
-
source
|
|
10369
|
-
};
|
|
10370
|
-
if (frontmatter.category !== void 0) metadata.category = frontmatter.category;
|
|
10371
|
-
if (frontmatter.dependencies !== void 0) metadata.dependencies = frontmatter.dependencies;
|
|
10372
|
-
return metadata;
|
|
10373
|
-
} catch (cause) {
|
|
10374
|
-
if (cause instanceof ConfigurationError) {
|
|
10375
|
-
const code = cause.code ?? "unknown";
|
|
10376
|
-
process.stderr.write(
|
|
10377
|
-
`[theokit-sdk] skill ${fallbackName} skipped (${code}): ${cause.message}
|
|
10378
|
-
`
|
|
10379
|
-
);
|
|
10380
|
-
return void 0;
|
|
10381
|
-
}
|
|
10382
|
-
throw cause;
|
|
10383
|
-
}
|
|
10384
|
-
}
|
|
10385
10409
|
|
|
10386
10410
|
// src/internal/runtime/local-agent/local-agent-bootstrap.ts
|
|
10387
10411
|
function registerLocalAgent(args) {
|
|
@@ -10794,6 +10818,7 @@ async function initLoopContext(inputs) {
|
|
|
10794
10818
|
finalStatus: "finished",
|
|
10795
10819
|
usage: new UsageAccumulator(),
|
|
10796
10820
|
nudgeAttempts: 0,
|
|
10821
|
+
stopFeedbackAttempts: 0,
|
|
10797
10822
|
...memoryProviderHandle !== void 0 ? { memoryProviderHandle } : {},
|
|
10798
10823
|
...memorySystemPromptAdditions !== void 0 ? { memorySystemPromptAdditions } : {}
|
|
10799
10824
|
};
|
|
@@ -10938,8 +10963,9 @@ function registerLoopError(ctx, cause) {
|
|
|
10938
10963
|
if (ctx.error !== void 0) return;
|
|
10939
10964
|
const rawMessage = cause?.message;
|
|
10940
10965
|
const message = typeof rawMessage === "string" ? rawMessage : cause instanceof Error ? cause.message : String(cause);
|
|
10966
|
+
const metaCode = cause?.metadata?.code;
|
|
10941
10967
|
const rawCode = cause?.code;
|
|
10942
|
-
const code = typeof rawCode === "string" ? rawCode : void 0;
|
|
10968
|
+
const code = typeof metaCode === "string" ? metaCode : typeof rawCode === "string" ? rawCode : void 0;
|
|
10943
10969
|
ctx.error = code !== void 0 ? { message, code, cause } : { message, cause };
|
|
10944
10970
|
}
|
|
10945
10971
|
async function runCollectorLoop(generator, inputs, ctx) {
|
|
@@ -11735,6 +11761,7 @@ function computeUsageCost(inputs, usage) {
|
|
|
11735
11761
|
|
|
11736
11762
|
// src/internal/agent-loop/loop.ts
|
|
11737
11763
|
var MAX_NUDGE_ATTEMPTS = 2;
|
|
11764
|
+
var MAX_STOP_FEEDBACK_ATTEMPTS = 2;
|
|
11738
11765
|
async function runAgentLoop(inputs) {
|
|
11739
11766
|
const sendSpan = inputs.telemetry?.startSpan("agent.send", {
|
|
11740
11767
|
agentId: inputs.agentId,
|
|
@@ -11892,6 +11919,28 @@ function shouldNudgeAndContinue(ctx, llmOutput) {
|
|
|
11892
11919
|
});
|
|
11893
11920
|
return true;
|
|
11894
11921
|
}
|
|
11922
|
+
async function reflectAfterStop(inputs, ctx) {
|
|
11923
|
+
const result = await inputs.hooks.run({
|
|
11924
|
+
event: "stop",
|
|
11925
|
+
agentId: inputs.agentId,
|
|
11926
|
+
runId: inputs.runId
|
|
11927
|
+
});
|
|
11928
|
+
if (result.blocked) return false;
|
|
11929
|
+
if (ctx.stopFeedbackAttempts >= MAX_STOP_FEEDBACK_ATTEMPTS) return false;
|
|
11930
|
+
const feedback = result.decisions.find(
|
|
11931
|
+
(d) => d.decision === "feedback" && (d.feedback ?? "").length > 0
|
|
11932
|
+
)?.feedback;
|
|
11933
|
+
if (feedback === void 0) return false;
|
|
11934
|
+
ctx.stopFeedbackAttempts += 1;
|
|
11935
|
+
ctx.messages.push({ role: "user", content: [{ type: "text", text: feedback }] });
|
|
11936
|
+
return true;
|
|
11937
|
+
}
|
|
11938
|
+
async function finishOrReflect(inputs, ctx, llmOutput) {
|
|
11939
|
+
if (shouldNudgeAndContinue(ctx, llmOutput)) return "continue";
|
|
11940
|
+
if (await reflectAfterStop(inputs, ctx)) return "continue";
|
|
11941
|
+
ctx.finalStatus = "finished";
|
|
11942
|
+
return "done";
|
|
11943
|
+
}
|
|
11895
11944
|
async function runIteration(inputs, ctx) {
|
|
11896
11945
|
const llmOutput = await streamLlmTurn(inputs, ctx);
|
|
11897
11946
|
accumulateUsage(ctx.usage, llmOutput);
|
|
@@ -11925,9 +11974,7 @@ async function continueOrTerminate(inputs, ctx, llmOutput) {
|
|
|
11925
11974
|
await emitAssistantTextStep(inputs, ctx, llmOutput.text);
|
|
11926
11975
|
}
|
|
11927
11976
|
if (llmOutput.stopReason !== "tool_use" || llmOutput.toolCalls.length === 0) {
|
|
11928
|
-
|
|
11929
|
-
ctx.finalStatus = "finished";
|
|
11930
|
-
return "done";
|
|
11977
|
+
return finishOrReflect(inputs, ctx, llmOutput);
|
|
11931
11978
|
}
|
|
11932
11979
|
ctx.messages.push(buildAssistantTurn(llmOutput.text, llmOutput.toolCalls));
|
|
11933
11980
|
const toolResults = await dispatchTools(inputs, ctx.tools, llmOutput.toolCalls, ctx.events);
|
|
@@ -18665,25 +18712,47 @@ async function migrateSqliteToLance2(options) {
|
|
|
18665
18712
|
|
|
18666
18713
|
// src/permission-engine.ts
|
|
18667
18714
|
var PermissionEngine = class {
|
|
18668
|
-
constructor(rules) {
|
|
18715
|
+
constructor(rules, options = {}) {
|
|
18669
18716
|
this.rules = rules;
|
|
18717
|
+
this.defaultAction = options.defaultAction ?? "allow";
|
|
18670
18718
|
}
|
|
18671
18719
|
rules;
|
|
18720
|
+
defaultAction;
|
|
18672
18721
|
/**
|
|
18673
|
-
* Evaluate a tool name against the rules. First match wins;
|
|
18722
|
+
* Evaluate a tool name against the rules. First match wins; falls back to the
|
|
18723
|
+
* configured `defaultAction` (default `"allow"`) when no rule matches.
|
|
18674
18724
|
*/
|
|
18675
18725
|
evaluate(toolName) {
|
|
18676
18726
|
for (const rule of this.rules) {
|
|
18677
|
-
|
|
18678
|
-
|
|
18679
|
-
} else {
|
|
18680
|
-
if (rule.tool.test(toolName)) return rule.action;
|
|
18681
|
-
}
|
|
18727
|
+
const matches = typeof rule.tool === "string" ? rule.tool === toolName : rule.tool.test(toolName);
|
|
18728
|
+
if (matches) return rule.action;
|
|
18682
18729
|
}
|
|
18683
|
-
return
|
|
18730
|
+
return this.defaultAction;
|
|
18684
18731
|
}
|
|
18685
18732
|
};
|
|
18686
18733
|
|
|
18734
|
+
// src/permission-plugin.ts
|
|
18735
|
+
function createPermissionPlugin(engine, opts = {}) {
|
|
18736
|
+
return definePlugin({
|
|
18737
|
+
name: opts.name ?? "permission-engine",
|
|
18738
|
+
version: "1.0.0",
|
|
18739
|
+
kind: "general",
|
|
18740
|
+
register(ctx) {
|
|
18741
|
+
ctx.on("pre_tool_call", (rawCtx) => {
|
|
18742
|
+
const { name } = rawCtx;
|
|
18743
|
+
const action = engine.evaluate(name);
|
|
18744
|
+
if (action === "deny") {
|
|
18745
|
+
return { block: true, message: `denied by permission engine: ${name}` };
|
|
18746
|
+
}
|
|
18747
|
+
if (action === "ask") {
|
|
18748
|
+
return opts.onAsk ? opts.onAsk(name) : { block: true, message: `requires approval: ${name}` };
|
|
18749
|
+
}
|
|
18750
|
+
return void 0;
|
|
18751
|
+
});
|
|
18752
|
+
}
|
|
18753
|
+
});
|
|
18754
|
+
}
|
|
18755
|
+
|
|
18687
18756
|
// src/security.ts
|
|
18688
18757
|
init_security();
|
|
18689
18758
|
var Security = class {
|
|
@@ -19453,6 +19522,6 @@ function safeStringify2(v) {
|
|
|
19453
19522
|
}
|
|
19454
19523
|
}
|
|
19455
19524
|
|
|
19456
|
-
export { Agent, AgentBuilder, AgentDisposedError, AgentRunError, AuthenticationError, Budget, BudgetExceededError, ConfigurationError, Cron, EventBus, FileSystemConversationStorage, GenerateObjectError, InMemoryConversationStorage, IntegrationNotConnectedError, InvalidTaskIdError, JobQueue, Memory, MemoryAdapterError, NetworkError, PermissionEngine, RateLimitError, Security, StreamObjectError, Task, TaskNotFoundError, Theokit, TheokitAgentError, UnknownAgentError, UnsupportedBudgetOperationError, UnsupportedRunOperationError, UnsupportedTaskOperationError, UsageAccumulator, buildReplayHistory, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createSquad, definePlugin, defineProvider, defineTool, extractRawId, getPricingEntry, inferApiMode, isTransientError, migrateSqliteToLance2 as migrateSqliteToLance, mkMemoryId, normalizeUsage, preflightCheck, toShareGptTrajectory, withCwdMutex };
|
|
19525
|
+
export { Agent, AgentBuilder, AgentDisposedError, AgentRunError, AuthenticationError, Budget, BudgetExceededError, ConfigurationError, Cron, EventBus, FileSystemConversationStorage, GenerateObjectError, InMemoryConversationStorage, IntegrationNotConnectedError, InvalidTaskIdError, JobQueue, Memory, MemoryAdapterError, NetworkError, PermissionEngine, RateLimitError, Security, StreamObjectError, Task, TaskNotFoundError, Theokit, TheokitAgentError, UnknownAgentError, UnsupportedBudgetOperationError, UnsupportedRunOperationError, UnsupportedTaskOperationError, UsageAccumulator, buildReplayHistory, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createPermissionPlugin, createSquad, definePlugin, defineProvider, defineTool, extractRawId, getPricingEntry, inferApiMode, isTransientError, migrateSqliteToLance2 as migrateSqliteToLance, mkMemoryId, normalizeUsage, preflightCheck, toShareGptTrajectory, withCwdMutex };
|
|
19457
19526
|
//# sourceMappingURL=index.js.map
|
|
19458
19527
|
//# sourceMappingURL=index.js.map
|