@theokit/sdk 2.3.0 → 2.4.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 +97 -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 +104 -57
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +104 -57
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +104 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +104 -57
- package/dist/index.js.map +1 -1
- package/dist/internal/agent-loop/loop.d.ts +5 -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/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/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/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/package.json +63 -3
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';
|
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';
|
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);
|