@theokit/sdk 2.18.1 → 2.20.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 +14 -0
- package/dist/a2a/index.cjs +83 -15
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +83 -15
- package/dist/a2a/index.js.map +1 -1
- package/dist/create-skill.d.ts +29 -0
- package/dist/{cron-Bbg0mBOv.d.ts → cron-B8fqui49.d.cts} +59 -2
- package/dist/{cron-ZLSKbDbB.d.cts → cron-D2yLOrk2.d.ts} +59 -2
- package/dist/cron.cjs +83 -15
- 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 +83 -15
- package/dist/cron.js.map +1 -1
- package/dist/define-tool.d.ts +1 -0
- package/dist/{errors-qyVYfk9H.d.ts → errors-5lj1EWgs.d.ts} +1 -1
- package/dist/{errors-1tVcX3Fq.d.cts → errors-CE-lMBi2.d.cts} +1 -1
- package/dist/errors.d.cts +2 -2
- package/dist/eval.cjs +83 -15
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +83 -15
- package/dist/eval.js.map +1 -1
- package/dist/generate-object.d.ts +27 -2
- package/dist/index.cjs +146 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -7
- package/dist/index.d.ts +35 -7
- package/dist/index.js +145 -16
- package/dist/index.js.map +1 -1
- package/dist/{run-pE-34AAo.d.cts → run-BgfBWX-z.d.cts} +13 -1
- package/dist/{run-pE-34AAo.d.ts → run-BgfBWX-z.d.ts} +13 -1
- package/dist/types/agent-prims.d.ts +4 -1
- package/dist/types/agent.d.ts +10 -0
- package/dist/types/run.d.ts +9 -0
- package/package.json +14 -14
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* M22 — `createSkill`: define a skill in TypeScript, without a `SKILL.md` file on disk.
|
|
3
|
+
*
|
|
4
|
+
* An inline skill is usable ALONGSIDE filesystem skills (`AgentOptions.skills.inline`), and points
|
|
5
|
+
* an agent at code-defined capabilities without a `.theokit/skills/<name>/SKILL.md`. Like file
|
|
6
|
+
* skills, its `name` + `description` surface in the `<skills>` system-prompt block; its
|
|
7
|
+
* `instructions` (the body) travel on the object for the consumer (the SDK injects name+description,
|
|
8
|
+
* not bodies — inline and file skills are symmetric there). Inline skills override file skills on a
|
|
9
|
+
* name conflict (mirrors the subagents-loader precedent).
|
|
10
|
+
*/
|
|
11
|
+
import type { Skill } from "./internal/runtime/skills/discover-skills.js";
|
|
12
|
+
/** A code-defined skill (from {@link createSkill}) — a {@link Skill} plus its inline body. */
|
|
13
|
+
export interface InlineSkill extends Skill {
|
|
14
|
+
/** The skill body/instructions (inline skills carry it here instead of a SKILL.md file). */
|
|
15
|
+
instructions: string;
|
|
16
|
+
}
|
|
17
|
+
/** Spec accepted by {@link createSkill}. */
|
|
18
|
+
export interface CreateSkillSpec {
|
|
19
|
+
name: string;
|
|
20
|
+
description: string;
|
|
21
|
+
instructions: string;
|
|
22
|
+
category?: string;
|
|
23
|
+
dependencies?: string[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Build an {@link InlineSkill} from a code spec. Fails fast on an empty `name`/`description`
|
|
27
|
+
* (error-handling.md). The synthetic `source` (`inline://<name>`) marks it as file-less.
|
|
28
|
+
*/
|
|
29
|
+
export declare function createSkill(spec: CreateSkillSpec): InlineSkill;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CustomTool, M as ModelSelection, G as SDKUserMessage, J as SendOptions, b as Run, r as RunToCompletionOptions, s as RunToCompletionResult, S as SDKMessage, U as StreamToCompletionResult, a as McpServerConfig } from './run-
|
|
1
|
+
import { C as CustomTool, M as ModelSelection, G as SDKUserMessage, J as SendOptions, b as Run, r as RunToCompletionOptions, s as RunToCompletionResult, S as SDKMessage, U as StreamToCompletionResult, a as McpServerConfig } from './run-BgfBWX-z.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Fork primitive public type contracts (T1.2, ADRs D110-D114).
|
|
@@ -680,6 +680,53 @@ interface ConversationStorageAdapter {
|
|
|
680
680
|
dispose?(): Promise<void>;
|
|
681
681
|
}
|
|
682
682
|
|
|
683
|
+
/**
|
|
684
|
+
* A discovered skill's metadata. The skill BODY is never included — only the
|
|
685
|
+
* strict frontmatter fields plus the resolved `source` path.
|
|
686
|
+
*
|
|
687
|
+
* Public via `@theokit/sdk/skills`.
|
|
688
|
+
*
|
|
689
|
+
* @public
|
|
690
|
+
*/
|
|
691
|
+
interface Skill {
|
|
692
|
+
name: string;
|
|
693
|
+
description: string;
|
|
694
|
+
/** Absolute path to the discovered `SKILL.md`. */
|
|
695
|
+
source: string;
|
|
696
|
+
category?: string;
|
|
697
|
+
dependencies?: string[];
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* M22 — `createSkill`: define a skill in TypeScript, without a `SKILL.md` file on disk.
|
|
702
|
+
*
|
|
703
|
+
* An inline skill is usable ALONGSIDE filesystem skills (`AgentOptions.skills.inline`), and points
|
|
704
|
+
* an agent at code-defined capabilities without a `.theokit/skills/<name>/SKILL.md`. Like file
|
|
705
|
+
* skills, its `name` + `description` surface in the `<skills>` system-prompt block; its
|
|
706
|
+
* `instructions` (the body) travel on the object for the consumer (the SDK injects name+description,
|
|
707
|
+
* not bodies — inline and file skills are symmetric there). Inline skills override file skills on a
|
|
708
|
+
* name conflict (mirrors the subagents-loader precedent).
|
|
709
|
+
*/
|
|
710
|
+
|
|
711
|
+
/** A code-defined skill (from {@link createSkill}) — a {@link Skill} plus its inline body. */
|
|
712
|
+
interface InlineSkill extends Skill {
|
|
713
|
+
/** The skill body/instructions (inline skills carry it here instead of a SKILL.md file). */
|
|
714
|
+
instructions: string;
|
|
715
|
+
}
|
|
716
|
+
/** Spec accepted by {@link createSkill}. */
|
|
717
|
+
interface CreateSkillSpec {
|
|
718
|
+
name: string;
|
|
719
|
+
description: string;
|
|
720
|
+
instructions: string;
|
|
721
|
+
category?: string;
|
|
722
|
+
dependencies?: string[];
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* Build an {@link InlineSkill} from a code spec. Fails fast on an empty `name`/`description`
|
|
726
|
+
* (error-handling.md). The synthetic `source` (`inline://<name>`) marks it as file-less.
|
|
727
|
+
*/
|
|
728
|
+
declare function createSkill(spec: CreateSkillSpec): InlineSkill;
|
|
729
|
+
|
|
683
730
|
/**
|
|
684
731
|
* Context manager backend.
|
|
685
732
|
*
|
|
@@ -1182,6 +1229,16 @@ interface SkillsSettings {
|
|
|
1182
1229
|
* skills itself.
|
|
1183
1230
|
*/
|
|
1184
1231
|
autoInject?: boolean;
|
|
1232
|
+
/**
|
|
1233
|
+
* M22 — discover skills from a CUSTOM directory (containing `<name>/SKILL.md`) instead of the
|
|
1234
|
+
* default `<cwd>/.theokit/skills`. Absent ⇒ the default root.
|
|
1235
|
+
*/
|
|
1236
|
+
skillsDir?: string;
|
|
1237
|
+
/**
|
|
1238
|
+
* M22 — code-defined skills (from `createSkill`) merged with the discovered ones. An inline skill
|
|
1239
|
+
* overrides a discovered file skill of the same name.
|
|
1240
|
+
*/
|
|
1241
|
+
inline?: InlineSkill[];
|
|
1185
1242
|
}
|
|
1186
1243
|
/**
|
|
1187
1244
|
* Memory configuration accepted by `Agent.create()` via {@link AgentOptions.memory}.
|
|
@@ -2039,4 +2096,4 @@ declare class Cron {
|
|
|
2039
2096
|
static status(_options?: CronStartOptions): Promise<CronSchedulerStatus>;
|
|
2040
2097
|
}
|
|
2041
2098
|
|
|
2042
|
-
export { type
|
|
2099
|
+
export { type GoalOptions as $, type AgentOptions as A, type BudgetTracker as B, type CloudOptions as C, type CloudRepo as D, type ContextBudget as E, type ContextManagerKind as F, type GetAgentOptions as G, type ContextSnapshot as H, type ContextSource as I, type ContextSourceStatus as J, type CreateSkillSpec as K, type LocalOptions as L, type MemorySettings as M, Cron as N, type CronCreateOptions as O, type ProviderRoutingSettings as P, type CronGetOptions as Q, type CronJob as R, type SystemPromptResolver as S, type CronJobStatus as T, type CronListOptions as U, type CronOperationOptions as V, type CronRunOptions as W, type CronRuntime as X, type CronSchedulerStatus as Y, type CronStartOptions as Z, type GoalEvent as _, type AgentDefinition as a, type GoalResult as a0, type HookName as a1, type InlineSkill as a2, type InvalidateCacheOptions as a3, type MemoryAdapter as a4, type MemoryAdapterCapabilities as a5, type MemoryContext as a6, type MemoryFact as a7, type MemoryProviderHandle as a8, type MemoryProviderInitOptions as a9, definePlugin as aA, type MemoryRevision as aa, type MemoryToolSchema as ab, type MemoryTurnMessage as ac, type PersonalityPreset as ad, type PluginContext as ae, type PostAssistantReplyContext as af, type PreToolCallContext as ag, type PreUserSendContext as ah, type PreUserSendResult as ai, type ProviderCapability as aj, type ProviderRoute as ak, type RecordSessionSummaryArgs as al, type ResolvedProviderRoute as am, type RunUntilIterator as an, type SDKAgentPlugins as ao, type SDKAgentSkills as ap, type SDKArtifact as aq, type SDKContextManager as ar, type SDKPluginMetadata as as, type SDKProvidersManager as at, type SettingSource as au, type SystemPromptContext as av, type SystemPromptMemoryFact as aw, type SystemPromptSkillRef as ax, type TelemetrySettings as ay, createSkill as az, type ContextSettings as b, type PluginsSettings as c, type SkillsSettings as d, type SDKAgent as e, type ListAgentsOptions as f, type ListResult as g, type SDKAgentInfo as h, type ListRunsOptions as i, type GetRunOptions as j, type AgentOperationOptions as k, type ProviderProfile as l, type Plugin as m, type ConversationStorageAdapter as n, type StoredMessage as o, type MemoryProvider as p, type MemoryId as q, type PreToolCallDecision as r, type SDKProvider as s, type ActiveMemoryPassArgs as t, type ActiveMemoryPassResult as u, type AgentMemory as v, type BudgetCheck as w, type BudgetTotal as x, type BudgetUsageEvent as y, type CloudEnv as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CustomTool, M as ModelSelection, G as SDKUserMessage, J as SendOptions, b as Run, r as RunToCompletionOptions, s as RunToCompletionResult, S as SDKMessage, U as StreamToCompletionResult, a as McpServerConfig } from './run-
|
|
1
|
+
import { C as CustomTool, M as ModelSelection, G as SDKUserMessage, J as SendOptions, b as Run, r as RunToCompletionOptions, s as RunToCompletionResult, S as SDKMessage, U as StreamToCompletionResult, a as McpServerConfig } from './run-BgfBWX-z.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Fork primitive public type contracts (T1.2, ADRs D110-D114).
|
|
@@ -680,6 +680,53 @@ interface ConversationStorageAdapter {
|
|
|
680
680
|
dispose?(): Promise<void>;
|
|
681
681
|
}
|
|
682
682
|
|
|
683
|
+
/**
|
|
684
|
+
* A discovered skill's metadata. The skill BODY is never included — only the
|
|
685
|
+
* strict frontmatter fields plus the resolved `source` path.
|
|
686
|
+
*
|
|
687
|
+
* Public via `@theokit/sdk/skills`.
|
|
688
|
+
*
|
|
689
|
+
* @public
|
|
690
|
+
*/
|
|
691
|
+
interface Skill {
|
|
692
|
+
name: string;
|
|
693
|
+
description: string;
|
|
694
|
+
/** Absolute path to the discovered `SKILL.md`. */
|
|
695
|
+
source: string;
|
|
696
|
+
category?: string;
|
|
697
|
+
dependencies?: string[];
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* M22 — `createSkill`: define a skill in TypeScript, without a `SKILL.md` file on disk.
|
|
702
|
+
*
|
|
703
|
+
* An inline skill is usable ALONGSIDE filesystem skills (`AgentOptions.skills.inline`), and points
|
|
704
|
+
* an agent at code-defined capabilities without a `.theokit/skills/<name>/SKILL.md`. Like file
|
|
705
|
+
* skills, its `name` + `description` surface in the `<skills>` system-prompt block; its
|
|
706
|
+
* `instructions` (the body) travel on the object for the consumer (the SDK injects name+description,
|
|
707
|
+
* not bodies — inline and file skills are symmetric there). Inline skills override file skills on a
|
|
708
|
+
* name conflict (mirrors the subagents-loader precedent).
|
|
709
|
+
*/
|
|
710
|
+
|
|
711
|
+
/** A code-defined skill (from {@link createSkill}) — a {@link Skill} plus its inline body. */
|
|
712
|
+
interface InlineSkill extends Skill {
|
|
713
|
+
/** The skill body/instructions (inline skills carry it here instead of a SKILL.md file). */
|
|
714
|
+
instructions: string;
|
|
715
|
+
}
|
|
716
|
+
/** Spec accepted by {@link createSkill}. */
|
|
717
|
+
interface CreateSkillSpec {
|
|
718
|
+
name: string;
|
|
719
|
+
description: string;
|
|
720
|
+
instructions: string;
|
|
721
|
+
category?: string;
|
|
722
|
+
dependencies?: string[];
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* Build an {@link InlineSkill} from a code spec. Fails fast on an empty `name`/`description`
|
|
726
|
+
* (error-handling.md). The synthetic `source` (`inline://<name>`) marks it as file-less.
|
|
727
|
+
*/
|
|
728
|
+
declare function createSkill(spec: CreateSkillSpec): InlineSkill;
|
|
729
|
+
|
|
683
730
|
/**
|
|
684
731
|
* Context manager backend.
|
|
685
732
|
*
|
|
@@ -1182,6 +1229,16 @@ interface SkillsSettings {
|
|
|
1182
1229
|
* skills itself.
|
|
1183
1230
|
*/
|
|
1184
1231
|
autoInject?: boolean;
|
|
1232
|
+
/**
|
|
1233
|
+
* M22 — discover skills from a CUSTOM directory (containing `<name>/SKILL.md`) instead of the
|
|
1234
|
+
* default `<cwd>/.theokit/skills`. Absent ⇒ the default root.
|
|
1235
|
+
*/
|
|
1236
|
+
skillsDir?: string;
|
|
1237
|
+
/**
|
|
1238
|
+
* M22 — code-defined skills (from `createSkill`) merged with the discovered ones. An inline skill
|
|
1239
|
+
* overrides a discovered file skill of the same name.
|
|
1240
|
+
*/
|
|
1241
|
+
inline?: InlineSkill[];
|
|
1185
1242
|
}
|
|
1186
1243
|
/**
|
|
1187
1244
|
* Memory configuration accepted by `Agent.create()` via {@link AgentOptions.memory}.
|
|
@@ -2039,4 +2096,4 @@ declare class Cron {
|
|
|
2039
2096
|
static status(_options?: CronStartOptions): Promise<CronSchedulerStatus>;
|
|
2040
2097
|
}
|
|
2041
2098
|
|
|
2042
|
-
export { type
|
|
2099
|
+
export { type GoalOptions as $, type AgentOptions as A, type BudgetTracker as B, type CloudOptions as C, type CloudRepo as D, type ContextBudget as E, type ContextManagerKind as F, type GetAgentOptions as G, type ContextSnapshot as H, type ContextSource as I, type ContextSourceStatus as J, type CreateSkillSpec as K, type LocalOptions as L, type MemorySettings as M, Cron as N, type CronCreateOptions as O, type ProviderRoutingSettings as P, type CronGetOptions as Q, type CronJob as R, type SystemPromptResolver as S, type CronJobStatus as T, type CronListOptions as U, type CronOperationOptions as V, type CronRunOptions as W, type CronRuntime as X, type CronSchedulerStatus as Y, type CronStartOptions as Z, type GoalEvent as _, type AgentDefinition as a, type GoalResult as a0, type HookName as a1, type InlineSkill as a2, type InvalidateCacheOptions as a3, type MemoryAdapter as a4, type MemoryAdapterCapabilities as a5, type MemoryContext as a6, type MemoryFact as a7, type MemoryProviderHandle as a8, type MemoryProviderInitOptions as a9, definePlugin as aA, type MemoryRevision as aa, type MemoryToolSchema as ab, type MemoryTurnMessage as ac, type PersonalityPreset as ad, type PluginContext as ae, type PostAssistantReplyContext as af, type PreToolCallContext as ag, type PreUserSendContext as ah, type PreUserSendResult as ai, type ProviderCapability as aj, type ProviderRoute as ak, type RecordSessionSummaryArgs as al, type ResolvedProviderRoute as am, type RunUntilIterator as an, type SDKAgentPlugins as ao, type SDKAgentSkills as ap, type SDKArtifact as aq, type SDKContextManager as ar, type SDKPluginMetadata as as, type SDKProvidersManager as at, type SettingSource as au, type SystemPromptContext as av, type SystemPromptMemoryFact as aw, type SystemPromptSkillRef as ax, type TelemetrySettings as ay, createSkill as az, type ContextSettings as b, type PluginsSettings as c, type SkillsSettings as d, type SDKAgent as e, type ListAgentsOptions as f, type ListResult as g, type SDKAgentInfo as h, type ListRunsOptions as i, type GetRunOptions as j, type AgentOperationOptions as k, type ProviderProfile as l, type Plugin as m, type ConversationStorageAdapter as n, type StoredMessage as o, type MemoryProvider as p, type MemoryId as q, type PreToolCallDecision as r, type SDKProvider as s, type ActiveMemoryPassArgs as t, type ActiveMemoryPassResult as u, type AgentMemory as v, type BudgetCheck as w, type BudgetTotal as x, type BudgetUsageEvent as y, type CloudEnv as z };
|
package/dist/cron.cjs
CHANGED
|
@@ -2256,6 +2256,37 @@ __export(generate_object_exports, {
|
|
|
2256
2256
|
GenerateObjectError: () => GenerateObjectError,
|
|
2257
2257
|
generateObjectImpl: () => generateObjectImpl
|
|
2258
2258
|
});
|
|
2259
|
+
function salvagePartial(schema, raw) {
|
|
2260
|
+
if (typeof raw !== "object" || raw === null) return raw;
|
|
2261
|
+
const shape = schema.shape;
|
|
2262
|
+
if (shape === void 0 || typeof shape !== "object") return raw;
|
|
2263
|
+
const rawObj = raw;
|
|
2264
|
+
const out = {};
|
|
2265
|
+
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
2266
|
+
if (typeof fieldSchema?.safeParse !== "function") continue;
|
|
2267
|
+
const parsed = fieldSchema.safeParse(rawObj[key]);
|
|
2268
|
+
if (parsed.success) out[key] = parsed.data;
|
|
2269
|
+
}
|
|
2270
|
+
return out;
|
|
2271
|
+
}
|
|
2272
|
+
async function runReasoningPhase(options, deps) {
|
|
2273
|
+
const reasoningOptions = {
|
|
2274
|
+
model: options.model,
|
|
2275
|
+
local: options.local,
|
|
2276
|
+
...options.systemPrompt !== void 0 ? { systemPrompt: options.systemPrompt } : {},
|
|
2277
|
+
...options.apiKey !== void 0 ? { apiKey: options.apiKey } : {},
|
|
2278
|
+
...options.providers !== void 0 ? { providers: options.providers } : {}
|
|
2279
|
+
};
|
|
2280
|
+
const reasoningAgent = await deps.create(reasoningOptions);
|
|
2281
|
+
try {
|
|
2282
|
+
const run = await reasoningAgent.send(options.prompt);
|
|
2283
|
+
const result = await run.wait();
|
|
2284
|
+
const text = result.result;
|
|
2285
|
+
return typeof text === "string" ? text : options.prompt;
|
|
2286
|
+
} finally {
|
|
2287
|
+
await disposeAndDeleteTransient(reasoningAgent, deps.delete);
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2259
2290
|
async function generateObjectImpl(options, deps) {
|
|
2260
2291
|
const { jsonSchema, maxRetries, initialUsage } = setupStructuredOutput(
|
|
2261
2292
|
options.schema,
|
|
@@ -2278,8 +2309,11 @@ async function generateObjectImpl(options, deps) {
|
|
|
2278
2309
|
}
|
|
2279
2310
|
throw new CaptureSentinel(input);
|
|
2280
2311
|
});
|
|
2312
|
+
const reasoningText = options.structuringModel !== void 0 ? await runReasoningPhase(options, deps) : void 0;
|
|
2313
|
+
const structuringModel = options.structuringModel ?? options.model;
|
|
2314
|
+
const structuringPrompt = reasoningText ?? options.prompt;
|
|
2281
2315
|
const agentOptions = buildTransientAgentOptions({
|
|
2282
|
-
model:
|
|
2316
|
+
model: structuringModel,
|
|
2283
2317
|
local: options.local,
|
|
2284
2318
|
outputTool,
|
|
2285
2319
|
...options.systemPrompt !== void 0 ? { systemPrompt: options.systemPrompt } : {},
|
|
@@ -2288,7 +2322,7 @@ async function generateObjectImpl(options, deps) {
|
|
|
2288
2322
|
});
|
|
2289
2323
|
const agent = await deps.create(agentOptions);
|
|
2290
2324
|
try {
|
|
2291
|
-
const userMessage = buildToolPrompt(
|
|
2325
|
+
const userMessage = buildToolPrompt(structuringPrompt);
|
|
2292
2326
|
let lastParseError;
|
|
2293
2327
|
for (let attempt = 0; attempt <= maxRetries; attempt += 1) {
|
|
2294
2328
|
capturedRaw = void 0;
|
|
@@ -2322,6 +2356,22 @@ async function generateObjectImpl(options, deps) {
|
|
|
2322
2356
|
}
|
|
2323
2357
|
lastParseError = parsed.error;
|
|
2324
2358
|
}
|
|
2359
|
+
if (options.errorStrategy === "return-raw") {
|
|
2360
|
+
return {
|
|
2361
|
+
object: capturedRaw,
|
|
2362
|
+
raw: capturedRaw,
|
|
2363
|
+
usage: lastUsage,
|
|
2364
|
+
finishReason: "tool_use"
|
|
2365
|
+
};
|
|
2366
|
+
}
|
|
2367
|
+
if (options.errorStrategy === "return-partial") {
|
|
2368
|
+
return {
|
|
2369
|
+
object: salvagePartial(options.schema, capturedRaw),
|
|
2370
|
+
raw: capturedRaw,
|
|
2371
|
+
usage: lastUsage,
|
|
2372
|
+
finishReason: "tool_use"
|
|
2373
|
+
};
|
|
2374
|
+
}
|
|
2325
2375
|
throw new GenerateObjectError(
|
|
2326
2376
|
"parse_failed",
|
|
2327
2377
|
"Schema parse failed after all retries.",
|
|
@@ -8312,23 +8362,27 @@ function tryParseSkill(raw, fallbackName, source, options) {
|
|
|
8312
8362
|
|
|
8313
8363
|
// src/internal/runtime/skills/skills-manager.ts
|
|
8314
8364
|
var SkillsManager = class {
|
|
8315
|
-
constructor(cwd, _enabled, settingSourcesIncludeProject) {
|
|
8365
|
+
constructor(cwd, _enabled, settingSourcesIncludeProject, skillsDir, inline) {
|
|
8316
8366
|
this.cwd = cwd;
|
|
8317
8367
|
this.settingSourcesIncludeProject = settingSourcesIncludeProject;
|
|
8368
|
+
this.skillsDir = skillsDir;
|
|
8369
|
+
this.inline = inline;
|
|
8318
8370
|
}
|
|
8319
8371
|
cwd;
|
|
8320
8372
|
settingSourcesIncludeProject;
|
|
8373
|
+
skillsDir;
|
|
8374
|
+
inline;
|
|
8321
8375
|
skills = [];
|
|
8322
8376
|
async initialize() {
|
|
8323
8377
|
if (!this.settingSourcesIncludeProject) {
|
|
8324
|
-
this.skills = [];
|
|
8378
|
+
this.skills = this.mergeInline([]);
|
|
8325
8379
|
return;
|
|
8326
8380
|
}
|
|
8327
8381
|
await this.refresh();
|
|
8328
8382
|
}
|
|
8329
8383
|
async refresh() {
|
|
8330
|
-
const skillsRoot = path.join(this.cwd, ".theokit", "skills");
|
|
8331
|
-
|
|
8384
|
+
const skillsRoot = this.skillsDir ?? path.join(this.cwd, ".theokit", "skills");
|
|
8385
|
+
const discovered = await discoverSkills(skillsRoot, {
|
|
8332
8386
|
onInvalidSkill: (info) => {
|
|
8333
8387
|
process.stderr.write(
|
|
8334
8388
|
`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
|
|
@@ -8336,6 +8390,13 @@ var SkillsManager = class {
|
|
|
8336
8390
|
);
|
|
8337
8391
|
}
|
|
8338
8392
|
});
|
|
8393
|
+
this.skills = this.mergeInline(discovered);
|
|
8394
|
+
}
|
|
8395
|
+
/** M22 — merge inline skills over discovered ones; inline wins on a name conflict. */
|
|
8396
|
+
mergeInline(discovered) {
|
|
8397
|
+
if (this.inline === void 0 || this.inline.length === 0) return discovered;
|
|
8398
|
+
const inlineNames = new Set(this.inline.map((s) => s.name));
|
|
8399
|
+
return [...discovered.filter((s) => !inlineNames.has(s.name)), ...this.inline];
|
|
8339
8400
|
}
|
|
8340
8401
|
list() {
|
|
8341
8402
|
return Promise.resolve(this.skills);
|
|
@@ -8380,7 +8441,10 @@ function bootstrapSubmanagers(args) {
|
|
|
8380
8441
|
out.skillsManager = new SkillsManager(
|
|
8381
8442
|
args.workspaceCwd,
|
|
8382
8443
|
args.options.skills?.enabled,
|
|
8383
|
-
args.settingSourcesIncludeProject
|
|
8444
|
+
args.settingSourcesIncludeProject,
|
|
8445
|
+
// M22 — custom skills directory + inline (code-defined) skills.
|
|
8446
|
+
args.options.skills?.skillsDir,
|
|
8447
|
+
args.options.skills?.inline
|
|
8384
8448
|
);
|
|
8385
8449
|
const localSkills = out.skillsManager;
|
|
8386
8450
|
out.skills = { list: () => localSkills.list() };
|
|
@@ -9220,22 +9284,23 @@ async function executeTool(inputs, resolved, call) {
|
|
|
9220
9284
|
return { stdout: "", stderr: `Unknown tool ${call.name}`, exitCode: 127 };
|
|
9221
9285
|
}
|
|
9222
9286
|
if (resolved.origin === "shell") return runShellTool(inputs, call);
|
|
9223
|
-
if (resolved.origin === "memory") return runMemoryTool(resolved, call);
|
|
9224
|
-
if (resolved.origin === "custom")
|
|
9287
|
+
if (resolved.origin === "memory") return runMemoryTool(resolved, call, inputs.context);
|
|
9288
|
+
if (resolved.origin === "custom")
|
|
9289
|
+
return runCustomTool(resolved, call, inputs.signal, inputs.context);
|
|
9225
9290
|
return runMcpTool(inputs, resolved, call);
|
|
9226
9291
|
}
|
|
9227
|
-
async function runMemoryTool(resolved, call) {
|
|
9228
|
-
return runHandlerTool("memory", resolved.memoryHandler, call);
|
|
9292
|
+
async function runMemoryTool(resolved, call, context) {
|
|
9293
|
+
return runHandlerTool("memory", resolved.memoryHandler, call, void 0, context);
|
|
9229
9294
|
}
|
|
9230
|
-
async function runCustomTool(resolved, call, signal) {
|
|
9231
|
-
return runHandlerTool("custom", resolved.customHandler, call, signal);
|
|
9295
|
+
async function runCustomTool(resolved, call, signal, context) {
|
|
9296
|
+
return runHandlerTool("custom", resolved.customHandler, call, signal, context);
|
|
9232
9297
|
}
|
|
9233
|
-
async function runHandlerTool(kind, handler, call, signal) {
|
|
9298
|
+
async function runHandlerTool(kind, handler, call, signal, context) {
|
|
9234
9299
|
if (handler === void 0) {
|
|
9235
9300
|
return { stdout: "", stderr: `${kind} tool ${call.name} has no handler`, exitCode: 127 };
|
|
9236
9301
|
}
|
|
9237
9302
|
try {
|
|
9238
|
-
const stdout = await handler(call.input, { signal });
|
|
9303
|
+
const stdout = await handler(call.input, { signal, context });
|
|
9239
9304
|
return { stdout, stderr: "", exitCode: 0 };
|
|
9240
9305
|
} catch (cause) {
|
|
9241
9306
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
@@ -13118,6 +13183,9 @@ function buildLoopInputs(options, runId, userText) {
|
|
|
13118
13183
|
// D318 — forward SendOptions.signal to the agent loop so streamLlmTurn
|
|
13119
13184
|
// can attach it to the LLM `fetch({ signal })` call.
|
|
13120
13185
|
...options.sendOptions.signal !== void 0 ? { signal: options.sendOptions.signal } : {},
|
|
13186
|
+
// M7 — forward SendOptions.context to the loop so every tool handler receives
|
|
13187
|
+
// it on `ctx.context` (shared run config set once, e.g. projectRoot).
|
|
13188
|
+
...options.sendOptions.context !== void 0 ? { context: options.sendOptions.context } : {},
|
|
13121
13189
|
// #58 / #57 — forward the per-tool timeout + tool-result guard so a consumer
|
|
13122
13190
|
// can enable them via SendOptions (not only internal AgentLoopInputs).
|
|
13123
13191
|
...options.sendOptions.perToolTimeoutMs !== void 0 ? { perToolTimeoutMs: options.sendOptions.perToolTimeoutMs } : {},
|