@theokit/sdk 2.19.0 → 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 +8 -0
- package/dist/a2a/index.cjs +42 -7
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +42 -7
- package/dist/a2a/index.js.map +1 -1
- package/dist/create-skill.d.ts +29 -0
- package/dist/{cron-D_wK1S-0.d.cts → cron-B8fqui49.d.cts} +58 -1
- package/dist/{cron-Cep07kTz.d.ts → cron-D2yLOrk2.d.ts} +58 -1
- package/dist/cron.cjs +42 -7
- 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 +42 -7
- package/dist/cron.js.map +1 -1
- package/dist/eval.cjs +42 -7
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +42 -7
- package/dist/eval.js.map +1 -1
- package/dist/generate-object.d.ts +16 -2
- package/dist/index.cjs +105 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -3
- package/dist/index.d.ts +19 -3
- package/dist/index.js +104 -8
- package/dist/index.js.map +1 -1
- package/dist/types/agent.d.ts +10 -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;
|
|
@@ -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 };
|
|
@@ -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
|
@@ -2269,6 +2269,24 @@ function salvagePartial(schema, raw) {
|
|
|
2269
2269
|
}
|
|
2270
2270
|
return out;
|
|
2271
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
|
+
}
|
|
2272
2290
|
async function generateObjectImpl(options, deps) {
|
|
2273
2291
|
const { jsonSchema, maxRetries, initialUsage } = setupStructuredOutput(
|
|
2274
2292
|
options.schema,
|
|
@@ -2291,8 +2309,11 @@ async function generateObjectImpl(options, deps) {
|
|
|
2291
2309
|
}
|
|
2292
2310
|
throw new CaptureSentinel(input);
|
|
2293
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;
|
|
2294
2315
|
const agentOptions = buildTransientAgentOptions({
|
|
2295
|
-
model:
|
|
2316
|
+
model: structuringModel,
|
|
2296
2317
|
local: options.local,
|
|
2297
2318
|
outputTool,
|
|
2298
2319
|
...options.systemPrompt !== void 0 ? { systemPrompt: options.systemPrompt } : {},
|
|
@@ -2301,7 +2322,7 @@ async function generateObjectImpl(options, deps) {
|
|
|
2301
2322
|
});
|
|
2302
2323
|
const agent = await deps.create(agentOptions);
|
|
2303
2324
|
try {
|
|
2304
|
-
const userMessage = buildToolPrompt(
|
|
2325
|
+
const userMessage = buildToolPrompt(structuringPrompt);
|
|
2305
2326
|
let lastParseError;
|
|
2306
2327
|
for (let attempt = 0; attempt <= maxRetries; attempt += 1) {
|
|
2307
2328
|
capturedRaw = void 0;
|
|
@@ -8341,23 +8362,27 @@ function tryParseSkill(raw, fallbackName, source, options) {
|
|
|
8341
8362
|
|
|
8342
8363
|
// src/internal/runtime/skills/skills-manager.ts
|
|
8343
8364
|
var SkillsManager = class {
|
|
8344
|
-
constructor(cwd, _enabled, settingSourcesIncludeProject) {
|
|
8365
|
+
constructor(cwd, _enabled, settingSourcesIncludeProject, skillsDir, inline) {
|
|
8345
8366
|
this.cwd = cwd;
|
|
8346
8367
|
this.settingSourcesIncludeProject = settingSourcesIncludeProject;
|
|
8368
|
+
this.skillsDir = skillsDir;
|
|
8369
|
+
this.inline = inline;
|
|
8347
8370
|
}
|
|
8348
8371
|
cwd;
|
|
8349
8372
|
settingSourcesIncludeProject;
|
|
8373
|
+
skillsDir;
|
|
8374
|
+
inline;
|
|
8350
8375
|
skills = [];
|
|
8351
8376
|
async initialize() {
|
|
8352
8377
|
if (!this.settingSourcesIncludeProject) {
|
|
8353
|
-
this.skills = [];
|
|
8378
|
+
this.skills = this.mergeInline([]);
|
|
8354
8379
|
return;
|
|
8355
8380
|
}
|
|
8356
8381
|
await this.refresh();
|
|
8357
8382
|
}
|
|
8358
8383
|
async refresh() {
|
|
8359
|
-
const skillsRoot = path.join(this.cwd, ".theokit", "skills");
|
|
8360
|
-
|
|
8384
|
+
const skillsRoot = this.skillsDir ?? path.join(this.cwd, ".theokit", "skills");
|
|
8385
|
+
const discovered = await discoverSkills(skillsRoot, {
|
|
8361
8386
|
onInvalidSkill: (info) => {
|
|
8362
8387
|
process.stderr.write(
|
|
8363
8388
|
`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
|
|
@@ -8365,6 +8390,13 @@ var SkillsManager = class {
|
|
|
8365
8390
|
);
|
|
8366
8391
|
}
|
|
8367
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];
|
|
8368
8400
|
}
|
|
8369
8401
|
list() {
|
|
8370
8402
|
return Promise.resolve(this.skills);
|
|
@@ -8409,7 +8441,10 @@ function bootstrapSubmanagers(args) {
|
|
|
8409
8441
|
out.skillsManager = new SkillsManager(
|
|
8410
8442
|
args.workspaceCwd,
|
|
8411
8443
|
args.options.skills?.enabled,
|
|
8412
|
-
args.settingSourcesIncludeProject
|
|
8444
|
+
args.settingSourcesIncludeProject,
|
|
8445
|
+
// M22 — custom skills directory + inline (code-defined) skills.
|
|
8446
|
+
args.options.skills?.skillsDir,
|
|
8447
|
+
args.options.skills?.inline
|
|
8413
8448
|
);
|
|
8414
8449
|
const localSkills = out.skillsManager;
|
|
8415
8450
|
out.skills = { list: () => localSkills.list() };
|