@theokit/sdk 2.23.0 → 2.25.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 +56 -0
- package/dist/a2a/index.cjs +259 -192
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +259 -192
- package/dist/a2a/index.js.map +1 -1
- package/dist/create-skill.d.ts +8 -0
- package/dist/{cron-7CruUd_0.d.ts → cron-B44D-678.d.ts} +67 -4
- package/dist/{cron-Bpt_1khA.d.cts → cron-qI-dbG7c.d.cts} +67 -4
- package/dist/cron.cjs +246 -181
- 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 +246 -181
- package/dist/cron.js.map +1 -1
- package/dist/define-tool.d.ts +33 -20
- package/dist/{errors-CkCaIqVP.d.cts → errors-DIKBXffg.d.cts} +1 -1
- package/dist/{errors-BuwwkrAk.d.ts → errors-DRS-kqOK.d.ts} +1 -1
- package/dist/errors.d.cts +2 -2
- package/dist/eval.cjs +246 -181
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +246 -181
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +299 -186
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +75 -27
- package/dist/index.d.ts +75 -27
- package/dist/index.js +299 -187
- package/dist/index.js.map +1 -1
- package/dist/internal/runtime/local-agent/local-agent-bootstrap.d.ts +2 -4
- package/dist/internal/runtime/skills/skill-frontmatter.d.ts +6 -0
- package/dist/{run-CrIulPF7.d.cts → run-Cr0C6cOM.d.cts} +17 -0
- package/dist/{run-CrIulPF7.d.ts → run-Cr0C6cOM.d.ts} +17 -0
- package/dist/skills.cjs.map +1 -1
- package/dist/skills.js.map +1 -1
- package/dist/types/agent.d.ts +57 -2
- package/dist/types/run.d.ts +17 -0
- package/dist/workflow.cjs +37 -0
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +47 -1
- package/dist/workflow.d.ts +47 -1
- package/dist/workflow.js +37 -2
- package/dist/workflow.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -572,10 +572,10 @@ function buildToolPrompt(prompt) {
|
|
|
572
572
|
Respond by calling the \`output\` tool with the structured answer that matches the schema.`;
|
|
573
573
|
}
|
|
574
574
|
function setupStructuredOutput(schema, maxRetries) {
|
|
575
|
-
const
|
|
575
|
+
const z9 = requireZod();
|
|
576
576
|
const jsonSchema = toJsonSchema(schema, { unrepresentable: "any" });
|
|
577
577
|
return {
|
|
578
|
-
z:
|
|
578
|
+
z: z9,
|
|
579
579
|
jsonSchema,
|
|
580
580
|
maxRetries: maxRetries ?? 1,
|
|
581
581
|
initialUsage: { inputTokens: 0, outputTokens: 0 }
|
|
@@ -6043,7 +6043,8 @@ function stripSecretsFromOptions(options) {
|
|
|
6043
6043
|
local: serializeLocal(options.local),
|
|
6044
6044
|
cloud: serializeCloud(options.cloud),
|
|
6045
6045
|
memory: serializeMemory(options.memory),
|
|
6046
|
-
|
|
6046
|
+
// SE22 — a SkillsResolver function isn't serializable; persist only the static form.
|
|
6047
|
+
skills: serializeEnabledList(typeof options.skills === "function" ? void 0 : options.skills),
|
|
6047
6048
|
// Code-`Plugin` objects are closures and cannot be persisted (like custom
|
|
6048
6049
|
// tools); only the named-enable settings form is serialized.
|
|
6049
6050
|
plugins: serializeEnabledList(asPluginsSettings(options.plugins)),
|
|
@@ -6351,6 +6352,7 @@ function serializeCloud2(cloud) {
|
|
|
6351
6352
|
return result;
|
|
6352
6353
|
}
|
|
6353
6354
|
function serializeSkills(skills) {
|
|
6355
|
+
if (typeof skills === "function") return void 0;
|
|
6354
6356
|
if (skills?.enabled === void 0 || skills.enabled.length === 0) return void 0;
|
|
6355
6357
|
return { enabled: [...skills.enabled] };
|
|
6356
6358
|
}
|
|
@@ -7731,6 +7733,7 @@ init_errors();
|
|
|
7731
7733
|
function validateCloudToolParity(options) {
|
|
7732
7734
|
if (options.cloud === void 0) return;
|
|
7733
7735
|
rejectFunctionSystemPrompt(options);
|
|
7736
|
+
rejectFunctionSkills(options);
|
|
7734
7737
|
rejectStdioMcpLocalPaths(options);
|
|
7735
7738
|
}
|
|
7736
7739
|
function rejectFunctionSystemPrompt(options) {
|
|
@@ -7741,6 +7744,14 @@ function rejectFunctionSystemPrompt(options) {
|
|
|
7741
7744
|
);
|
|
7742
7745
|
}
|
|
7743
7746
|
}
|
|
7747
|
+
function rejectFunctionSkills(options) {
|
|
7748
|
+
if (typeof options.skills === "function") {
|
|
7749
|
+
throw new ConfigurationError(
|
|
7750
|
+
"Cloud agents require skills as a static settings object. SkillsResolver functions can't run on PaaS \u2014 resolve to a SkillsSettings object before Agent.create() or move the dynamic logic into a hook rule.",
|
|
7751
|
+
{ code: "cloud_incompatible_function_resolver" }
|
|
7752
|
+
);
|
|
7753
|
+
}
|
|
7754
|
+
}
|
|
7744
7755
|
function rejectStdioMcpLocalPaths(options) {
|
|
7745
7756
|
if (options.mcpServers === void 0) return;
|
|
7746
7757
|
for (const [name, config] of Object.entries(options.mcpServers)) {
|
|
@@ -9567,9 +9578,224 @@ function parseFrontmatterFields(frontmatter) {
|
|
|
9567
9578
|
return out;
|
|
9568
9579
|
}
|
|
9569
9580
|
|
|
9581
|
+
// src/internal/runtime/skills/discover-skills.ts
|
|
9582
|
+
init_errors();
|
|
9583
|
+
init_path_guard();
|
|
9584
|
+
|
|
9585
|
+
// src/internal/runtime/skills/skill-frontmatter.ts
|
|
9586
|
+
init_errors();
|
|
9587
|
+
init_yaml_frontmatter();
|
|
9588
|
+
function asString(v) {
|
|
9589
|
+
return typeof v === "string" ? v : void 0;
|
|
9590
|
+
}
|
|
9591
|
+
function toStringFields(raw) {
|
|
9592
|
+
const out = {};
|
|
9593
|
+
for (const [k, v] of Object.entries(raw)) out[k] = asString(v);
|
|
9594
|
+
return out;
|
|
9595
|
+
}
|
|
9596
|
+
function parseSkillFrontmatter(raw, fallbackName) {
|
|
9597
|
+
const fields = extractAndParseFrontmatter(raw, fallbackName);
|
|
9598
|
+
const name = resolveName(fields, fallbackName);
|
|
9599
|
+
ensureRequiredFields(fields, name);
|
|
9600
|
+
return buildFrontmatter(fields, name);
|
|
9601
|
+
}
|
|
9602
|
+
function stripSkillFrontmatter(raw) {
|
|
9603
|
+
const match = /^---\s*\n[\s\S]*?\n---\s*\n/.exec(raw);
|
|
9604
|
+
return (match === null ? raw : raw.slice(match[0].length)).trim();
|
|
9605
|
+
}
|
|
9606
|
+
function extractAndParseFrontmatter(raw, fallbackName) {
|
|
9607
|
+
const match = /^---\s*\n([\s\S]*?)\n---\s*\n/.exec(raw);
|
|
9608
|
+
if (match === null) {
|
|
9609
|
+
throw new ConfigurationError(`Skill ${fallbackName} is missing frontmatter`, {
|
|
9610
|
+
code: "missing_frontmatter"
|
|
9611
|
+
});
|
|
9612
|
+
}
|
|
9613
|
+
const frontmatter = match[1] ?? "";
|
|
9614
|
+
try {
|
|
9615
|
+
return toStringFields(parseSimpleYaml(frontmatter));
|
|
9616
|
+
} catch (cause) {
|
|
9617
|
+
const detail = cause instanceof Error ? cause.message : String(cause);
|
|
9618
|
+
throw new ConfigurationError(
|
|
9619
|
+
`Skill ${fallbackName} has malformed YAML frontmatter: ${detail}`,
|
|
9620
|
+
{ code: "schema_invalid", cause }
|
|
9621
|
+
);
|
|
9622
|
+
}
|
|
9623
|
+
}
|
|
9624
|
+
function resolveName(fields, fallbackName) {
|
|
9625
|
+
if (hasContent(fields.name)) return fields.name;
|
|
9626
|
+
if (hasContent(fallbackName)) return fallbackName;
|
|
9627
|
+
throw new ConfigurationError("Skill at unknown path is missing required field: name", {
|
|
9628
|
+
code: "schema_invalid"
|
|
9629
|
+
});
|
|
9630
|
+
}
|
|
9631
|
+
function ensureRequiredFields(fields, name) {
|
|
9632
|
+
if (!hasContent(fields.description)) {
|
|
9633
|
+
throw new ConfigurationError(`Skill ${name} is missing required field: description`, {
|
|
9634
|
+
code: "schema_invalid"
|
|
9635
|
+
});
|
|
9636
|
+
}
|
|
9637
|
+
}
|
|
9638
|
+
function buildFrontmatter(fields, name) {
|
|
9639
|
+
const description = fields.description;
|
|
9640
|
+
if (description === void 0) {
|
|
9641
|
+
throw new ConfigurationError(`Skill ${name} missing description`, { code: "schema_invalid" });
|
|
9642
|
+
}
|
|
9643
|
+
const result = { name, description };
|
|
9644
|
+
if (hasContent(fields.category)) result.category = fields.category;
|
|
9645
|
+
const deps = parseDependencies(fields.dependencies);
|
|
9646
|
+
if (deps !== void 0) result.dependencies = deps;
|
|
9647
|
+
return result;
|
|
9648
|
+
}
|
|
9649
|
+
function parseDependencies(raw) {
|
|
9650
|
+
if (!hasContent(raw)) return void 0;
|
|
9651
|
+
const deps = raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
9652
|
+
return deps.length > 0 ? deps : void 0;
|
|
9653
|
+
}
|
|
9654
|
+
function hasContent(value) {
|
|
9655
|
+
return value !== void 0 && value.trim().length > 0;
|
|
9656
|
+
}
|
|
9657
|
+
|
|
9658
|
+
// src/internal/runtime/skills/discover-skills.ts
|
|
9659
|
+
async function discoverSkills(dir, options) {
|
|
9660
|
+
let entries;
|
|
9661
|
+
try {
|
|
9662
|
+
entries = await readWorkspaceDir(dir, "skills_read_error", "skills directory");
|
|
9663
|
+
} catch {
|
|
9664
|
+
return [];
|
|
9665
|
+
}
|
|
9666
|
+
const skills = [];
|
|
9667
|
+
for (const entry of entries) {
|
|
9668
|
+
if (!entry.isDirectory()) continue;
|
|
9669
|
+
let skillDir;
|
|
9670
|
+
try {
|
|
9671
|
+
skillDir = safePathJoin(dir, entry.name);
|
|
9672
|
+
assertNoSymlinkEscape(skillDir, dir);
|
|
9673
|
+
} catch {
|
|
9674
|
+
continue;
|
|
9675
|
+
}
|
|
9676
|
+
const skillPath = join(skillDir, "SKILL.md");
|
|
9677
|
+
let raw;
|
|
9678
|
+
try {
|
|
9679
|
+
raw = await readFile(skillPath, "utf8");
|
|
9680
|
+
} catch {
|
|
9681
|
+
continue;
|
|
9682
|
+
}
|
|
9683
|
+
const skill = tryParseSkill(raw, entry.name, skillPath, options);
|
|
9684
|
+
if (skill !== void 0) skills.push(skill);
|
|
9685
|
+
}
|
|
9686
|
+
return skills;
|
|
9687
|
+
}
|
|
9688
|
+
function tryParseSkill(raw, fallbackName, source, options) {
|
|
9689
|
+
try {
|
|
9690
|
+
const frontmatter = parseSkillFrontmatter(raw, fallbackName);
|
|
9691
|
+
const skill = {
|
|
9692
|
+
name: frontmatter.name,
|
|
9693
|
+
description: frontmatter.description,
|
|
9694
|
+
source
|
|
9695
|
+
};
|
|
9696
|
+
if (frontmatter.category !== void 0) skill.category = frontmatter.category;
|
|
9697
|
+
if (frontmatter.dependencies !== void 0) skill.dependencies = frontmatter.dependencies;
|
|
9698
|
+
return skill;
|
|
9699
|
+
} catch (cause) {
|
|
9700
|
+
if (cause instanceof ConfigurationError) {
|
|
9701
|
+
options?.onInvalidSkill?.({
|
|
9702
|
+
name: fallbackName,
|
|
9703
|
+
source,
|
|
9704
|
+
code: cause.code ?? "unknown",
|
|
9705
|
+
message: cause.message
|
|
9706
|
+
});
|
|
9707
|
+
return void 0;
|
|
9708
|
+
}
|
|
9709
|
+
throw cause;
|
|
9710
|
+
}
|
|
9711
|
+
}
|
|
9712
|
+
|
|
9713
|
+
// src/internal/runtime/skills/skills-manager.ts
|
|
9714
|
+
var SkillsManager = class {
|
|
9715
|
+
constructor(cwd, _enabled, settingSourcesIncludeProject, skillsDir, inline) {
|
|
9716
|
+
this.cwd = cwd;
|
|
9717
|
+
this.settingSourcesIncludeProject = settingSourcesIncludeProject;
|
|
9718
|
+
this.skillsDir = skillsDir;
|
|
9719
|
+
this.inline = inline;
|
|
9720
|
+
}
|
|
9721
|
+
cwd;
|
|
9722
|
+
settingSourcesIncludeProject;
|
|
9723
|
+
skillsDir;
|
|
9724
|
+
inline;
|
|
9725
|
+
skills = [];
|
|
9726
|
+
async initialize() {
|
|
9727
|
+
if (!this.settingSourcesIncludeProject) {
|
|
9728
|
+
this.skills = this.mergeInline([]);
|
|
9729
|
+
return;
|
|
9730
|
+
}
|
|
9731
|
+
await this.refresh();
|
|
9732
|
+
}
|
|
9733
|
+
async refresh() {
|
|
9734
|
+
const skillsRoot = this.skillsDir ?? join(this.cwd, ".theokit", "skills");
|
|
9735
|
+
const discovered = await discoverSkills(skillsRoot, {
|
|
9736
|
+
onInvalidSkill: (info) => {
|
|
9737
|
+
process.stderr.write(
|
|
9738
|
+
`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
|
|
9739
|
+
`
|
|
9740
|
+
);
|
|
9741
|
+
}
|
|
9742
|
+
});
|
|
9743
|
+
this.skills = this.mergeInline(discovered);
|
|
9744
|
+
}
|
|
9745
|
+
/** M22 — merge inline skills over discovered ones; inline wins on a name conflict. */
|
|
9746
|
+
mergeInline(discovered) {
|
|
9747
|
+
if (this.inline === void 0 || this.inline.length === 0) return discovered;
|
|
9748
|
+
const inlineNames = new Set(this.inline.map((s) => s.name));
|
|
9749
|
+
return [...discovered.filter((s) => !inlineNames.has(s.name)), ...this.inline];
|
|
9750
|
+
}
|
|
9751
|
+
list() {
|
|
9752
|
+
return Promise.resolve(this.skills);
|
|
9753
|
+
}
|
|
9754
|
+
/**
|
|
9755
|
+
* SE20 — resolve a skill by name INCLUDING its body. Inline (`createSkill`)
|
|
9756
|
+
* skills carry `instructions` on the object; filesystem skills read the body
|
|
9757
|
+
* from their `source` SKILL.md (frontmatter stripped). `undefined` when no
|
|
9758
|
+
* enabled skill matches (malformed skills were already excluded at discovery).
|
|
9759
|
+
*/
|
|
9760
|
+
async get(name) {
|
|
9761
|
+
const skill = this.skills.find((s) => s.name === name);
|
|
9762
|
+
if (skill === void 0) return void 0;
|
|
9763
|
+
const instructions = typeof skill.instructions === "string" ? skill.instructions : stripSkillFrontmatter(await readFile(skill.source, "utf8"));
|
|
9764
|
+
const references = skill.references;
|
|
9765
|
+
return {
|
|
9766
|
+
name: skill.name,
|
|
9767
|
+
description: skill.description,
|
|
9768
|
+
instructions,
|
|
9769
|
+
...references !== void 0 ? { references } : {}
|
|
9770
|
+
};
|
|
9771
|
+
}
|
|
9772
|
+
};
|
|
9773
|
+
|
|
9570
9774
|
// src/internal/runtime/system-prompt/local-assembly.ts
|
|
9571
|
-
async function
|
|
9572
|
-
const skills = inputs.
|
|
9775
|
+
async function resolveSendSkills(inputs, userText, memoryFacts) {
|
|
9776
|
+
const skills = inputs.options.skills;
|
|
9777
|
+
if (typeof skills !== "function") {
|
|
9778
|
+
return { manager: inputs.skillsManager, autoInject: skills?.autoInject ?? true };
|
|
9779
|
+
}
|
|
9780
|
+
const settings = await skills({
|
|
9781
|
+
agentId: inputs.agentId,
|
|
9782
|
+
cwd: inputs.workspaceCwd,
|
|
9783
|
+
model: inputs.model,
|
|
9784
|
+
userMessage: userText,
|
|
9785
|
+
memory: memoryFacts.map((fact) => ({ text: fact.text }))
|
|
9786
|
+
});
|
|
9787
|
+
const manager = new SkillsManager(
|
|
9788
|
+
inputs.workspaceCwd,
|
|
9789
|
+
settings.enabled,
|
|
9790
|
+
inputs.settingSourcesIncludeProject,
|
|
9791
|
+
settings.skillsDir,
|
|
9792
|
+
settings.inline
|
|
9793
|
+
);
|
|
9794
|
+
await manager.initialize();
|
|
9795
|
+
return { manager, autoInject: settings.autoInject ?? true };
|
|
9796
|
+
}
|
|
9797
|
+
async function buildSystemPromptContext(inputs, userText, memoryFacts, manager = inputs.skillsManager) {
|
|
9798
|
+
const skills = manager !== void 0 ? await manager.list() : [];
|
|
9573
9799
|
return {
|
|
9574
9800
|
agentId: inputs.agentId,
|
|
9575
9801
|
cwd: inputs.workspaceCwd,
|
|
@@ -9580,10 +9806,11 @@ async function buildSystemPromptContext(inputs, userText, memoryFacts) {
|
|
|
9580
9806
|
};
|
|
9581
9807
|
}
|
|
9582
9808
|
async function buildAssemblyContext(inputs, userText, baseSystemPrompt, memoryFacts, activeMemorySummary) {
|
|
9583
|
-
const
|
|
9809
|
+
const resolved = await resolveSendSkills(inputs, userText, memoryFacts);
|
|
9810
|
+
const baseCtx = await buildSystemPromptContext(inputs, userText, memoryFacts, resolved.manager);
|
|
9584
9811
|
const assemblyCtx = {
|
|
9585
9812
|
...baseCtx,
|
|
9586
|
-
skillsAutoInject:
|
|
9813
|
+
skillsAutoInject: resolved.autoInject,
|
|
9587
9814
|
memoryAutoInject: inputs.options.memory?.autoInject ?? true
|
|
9588
9815
|
};
|
|
9589
9816
|
if (baseSystemPrompt !== void 0) assemblyCtx.baseSystemPrompt = baseSystemPrompt;
|
|
@@ -10836,177 +11063,6 @@ async function loadPluginManifestFromMarkdown(pluginsRoot, folderName) {
|
|
|
10836
11063
|
return metadata;
|
|
10837
11064
|
}
|
|
10838
11065
|
|
|
10839
|
-
// src/internal/runtime/skills/discover-skills.ts
|
|
10840
|
-
init_errors();
|
|
10841
|
-
init_path_guard();
|
|
10842
|
-
|
|
10843
|
-
// src/internal/runtime/skills/skill-frontmatter.ts
|
|
10844
|
-
init_errors();
|
|
10845
|
-
init_yaml_frontmatter();
|
|
10846
|
-
function asString(v) {
|
|
10847
|
-
return typeof v === "string" ? v : void 0;
|
|
10848
|
-
}
|
|
10849
|
-
function toStringFields(raw) {
|
|
10850
|
-
const out = {};
|
|
10851
|
-
for (const [k, v] of Object.entries(raw)) out[k] = asString(v);
|
|
10852
|
-
return out;
|
|
10853
|
-
}
|
|
10854
|
-
function parseSkillFrontmatter(raw, fallbackName) {
|
|
10855
|
-
const fields = extractAndParseFrontmatter(raw, fallbackName);
|
|
10856
|
-
const name = resolveName(fields, fallbackName);
|
|
10857
|
-
ensureRequiredFields(fields, name);
|
|
10858
|
-
return buildFrontmatter(fields, name);
|
|
10859
|
-
}
|
|
10860
|
-
function extractAndParseFrontmatter(raw, fallbackName) {
|
|
10861
|
-
const match = /^---\s*\n([\s\S]*?)\n---\s*\n/.exec(raw);
|
|
10862
|
-
if (match === null) {
|
|
10863
|
-
throw new ConfigurationError(`Skill ${fallbackName} is missing frontmatter`, {
|
|
10864
|
-
code: "missing_frontmatter"
|
|
10865
|
-
});
|
|
10866
|
-
}
|
|
10867
|
-
const frontmatter = match[1] ?? "";
|
|
10868
|
-
try {
|
|
10869
|
-
return toStringFields(parseSimpleYaml(frontmatter));
|
|
10870
|
-
} catch (cause) {
|
|
10871
|
-
const detail = cause instanceof Error ? cause.message : String(cause);
|
|
10872
|
-
throw new ConfigurationError(
|
|
10873
|
-
`Skill ${fallbackName} has malformed YAML frontmatter: ${detail}`,
|
|
10874
|
-
{ code: "schema_invalid", cause }
|
|
10875
|
-
);
|
|
10876
|
-
}
|
|
10877
|
-
}
|
|
10878
|
-
function resolveName(fields, fallbackName) {
|
|
10879
|
-
if (hasContent(fields.name)) return fields.name;
|
|
10880
|
-
if (hasContent(fallbackName)) return fallbackName;
|
|
10881
|
-
throw new ConfigurationError("Skill at unknown path is missing required field: name", {
|
|
10882
|
-
code: "schema_invalid"
|
|
10883
|
-
});
|
|
10884
|
-
}
|
|
10885
|
-
function ensureRequiredFields(fields, name) {
|
|
10886
|
-
if (!hasContent(fields.description)) {
|
|
10887
|
-
throw new ConfigurationError(`Skill ${name} is missing required field: description`, {
|
|
10888
|
-
code: "schema_invalid"
|
|
10889
|
-
});
|
|
10890
|
-
}
|
|
10891
|
-
}
|
|
10892
|
-
function buildFrontmatter(fields, name) {
|
|
10893
|
-
const description = fields.description;
|
|
10894
|
-
if (description === void 0) {
|
|
10895
|
-
throw new ConfigurationError(`Skill ${name} missing description`, { code: "schema_invalid" });
|
|
10896
|
-
}
|
|
10897
|
-
const result = { name, description };
|
|
10898
|
-
if (hasContent(fields.category)) result.category = fields.category;
|
|
10899
|
-
const deps = parseDependencies(fields.dependencies);
|
|
10900
|
-
if (deps !== void 0) result.dependencies = deps;
|
|
10901
|
-
return result;
|
|
10902
|
-
}
|
|
10903
|
-
function parseDependencies(raw) {
|
|
10904
|
-
if (!hasContent(raw)) return void 0;
|
|
10905
|
-
const deps = raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
10906
|
-
return deps.length > 0 ? deps : void 0;
|
|
10907
|
-
}
|
|
10908
|
-
function hasContent(value) {
|
|
10909
|
-
return value !== void 0 && value.trim().length > 0;
|
|
10910
|
-
}
|
|
10911
|
-
|
|
10912
|
-
// src/internal/runtime/skills/discover-skills.ts
|
|
10913
|
-
async function discoverSkills(dir, options) {
|
|
10914
|
-
let entries;
|
|
10915
|
-
try {
|
|
10916
|
-
entries = await readWorkspaceDir(dir, "skills_read_error", "skills directory");
|
|
10917
|
-
} catch {
|
|
10918
|
-
return [];
|
|
10919
|
-
}
|
|
10920
|
-
const skills = [];
|
|
10921
|
-
for (const entry of entries) {
|
|
10922
|
-
if (!entry.isDirectory()) continue;
|
|
10923
|
-
let skillDir;
|
|
10924
|
-
try {
|
|
10925
|
-
skillDir = safePathJoin(dir, entry.name);
|
|
10926
|
-
assertNoSymlinkEscape(skillDir, dir);
|
|
10927
|
-
} catch {
|
|
10928
|
-
continue;
|
|
10929
|
-
}
|
|
10930
|
-
const skillPath = join(skillDir, "SKILL.md");
|
|
10931
|
-
let raw;
|
|
10932
|
-
try {
|
|
10933
|
-
raw = await readFile(skillPath, "utf8");
|
|
10934
|
-
} catch {
|
|
10935
|
-
continue;
|
|
10936
|
-
}
|
|
10937
|
-
const skill = tryParseSkill(raw, entry.name, skillPath, options);
|
|
10938
|
-
if (skill !== void 0) skills.push(skill);
|
|
10939
|
-
}
|
|
10940
|
-
return skills;
|
|
10941
|
-
}
|
|
10942
|
-
function tryParseSkill(raw, fallbackName, source, options) {
|
|
10943
|
-
try {
|
|
10944
|
-
const frontmatter = parseSkillFrontmatter(raw, fallbackName);
|
|
10945
|
-
const skill = {
|
|
10946
|
-
name: frontmatter.name,
|
|
10947
|
-
description: frontmatter.description,
|
|
10948
|
-
source
|
|
10949
|
-
};
|
|
10950
|
-
if (frontmatter.category !== void 0) skill.category = frontmatter.category;
|
|
10951
|
-
if (frontmatter.dependencies !== void 0) skill.dependencies = frontmatter.dependencies;
|
|
10952
|
-
return skill;
|
|
10953
|
-
} catch (cause) {
|
|
10954
|
-
if (cause instanceof ConfigurationError) {
|
|
10955
|
-
options?.onInvalidSkill?.({
|
|
10956
|
-
name: fallbackName,
|
|
10957
|
-
source,
|
|
10958
|
-
code: cause.code ?? "unknown",
|
|
10959
|
-
message: cause.message
|
|
10960
|
-
});
|
|
10961
|
-
return void 0;
|
|
10962
|
-
}
|
|
10963
|
-
throw cause;
|
|
10964
|
-
}
|
|
10965
|
-
}
|
|
10966
|
-
|
|
10967
|
-
// src/internal/runtime/skills/skills-manager.ts
|
|
10968
|
-
var SkillsManager = class {
|
|
10969
|
-
constructor(cwd, _enabled, settingSourcesIncludeProject, skillsDir, inline) {
|
|
10970
|
-
this.cwd = cwd;
|
|
10971
|
-
this.settingSourcesIncludeProject = settingSourcesIncludeProject;
|
|
10972
|
-
this.skillsDir = skillsDir;
|
|
10973
|
-
this.inline = inline;
|
|
10974
|
-
}
|
|
10975
|
-
cwd;
|
|
10976
|
-
settingSourcesIncludeProject;
|
|
10977
|
-
skillsDir;
|
|
10978
|
-
inline;
|
|
10979
|
-
skills = [];
|
|
10980
|
-
async initialize() {
|
|
10981
|
-
if (!this.settingSourcesIncludeProject) {
|
|
10982
|
-
this.skills = this.mergeInline([]);
|
|
10983
|
-
return;
|
|
10984
|
-
}
|
|
10985
|
-
await this.refresh();
|
|
10986
|
-
}
|
|
10987
|
-
async refresh() {
|
|
10988
|
-
const skillsRoot = this.skillsDir ?? join(this.cwd, ".theokit", "skills");
|
|
10989
|
-
const discovered = await discoverSkills(skillsRoot, {
|
|
10990
|
-
onInvalidSkill: (info) => {
|
|
10991
|
-
process.stderr.write(
|
|
10992
|
-
`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
|
|
10993
|
-
`
|
|
10994
|
-
);
|
|
10995
|
-
}
|
|
10996
|
-
});
|
|
10997
|
-
this.skills = this.mergeInline(discovered);
|
|
10998
|
-
}
|
|
10999
|
-
/** M22 — merge inline skills over discovered ones; inline wins on a name conflict. */
|
|
11000
|
-
mergeInline(discovered) {
|
|
11001
|
-
if (this.inline === void 0 || this.inline.length === 0) return discovered;
|
|
11002
|
-
const inlineNames = new Set(this.inline.map((s) => s.name));
|
|
11003
|
-
return [...discovered.filter((s) => !inlineNames.has(s.name)), ...this.inline];
|
|
11004
|
-
}
|
|
11005
|
-
list() {
|
|
11006
|
-
return Promise.resolve(this.skills);
|
|
11007
|
-
}
|
|
11008
|
-
};
|
|
11009
|
-
|
|
11010
11066
|
// src/internal/runtime/local-agent/local-agent-bootstrap.ts
|
|
11011
11067
|
function registerLocalAgent(args) {
|
|
11012
11068
|
registerAgent({
|
|
@@ -11042,16 +11098,23 @@ function bootstrapSubmanagers(args) {
|
|
|
11042
11098
|
);
|
|
11043
11099
|
}
|
|
11044
11100
|
if (args.options.skills !== void 0 || args.settingSourcesIncludeProject) {
|
|
11101
|
+
const staticSkills = typeof args.options.skills === "function" ? void 0 : args.options.skills;
|
|
11045
11102
|
out.skillsManager = new SkillsManager(
|
|
11046
11103
|
args.workspaceCwd,
|
|
11047
|
-
|
|
11104
|
+
staticSkills?.enabled,
|
|
11048
11105
|
args.settingSourcesIncludeProject,
|
|
11049
11106
|
// M22 — custom skills directory + inline (code-defined) skills.
|
|
11050
|
-
|
|
11051
|
-
|
|
11107
|
+
staticSkills?.skillsDir,
|
|
11108
|
+
staticSkills?.inline
|
|
11052
11109
|
);
|
|
11053
11110
|
const localSkills = out.skillsManager;
|
|
11054
|
-
out.skills = {
|
|
11111
|
+
out.skills = {
|
|
11112
|
+
// Project to the public shape (name + description only). Inline skills carry
|
|
11113
|
+
// their body + references on the object; `list()` must never leak them —
|
|
11114
|
+
// the body is reachable exclusively through `get()`.
|
|
11115
|
+
list: async () => (await localSkills.list()).map((s) => ({ name: s.name, description: s.description })),
|
|
11116
|
+
get: (name) => localSkills.get(name)
|
|
11117
|
+
};
|
|
11055
11118
|
}
|
|
11056
11119
|
if (args.options.plugins !== void 0 || args.settingSourcesIncludePlugins) {
|
|
11057
11120
|
out.pluginsManager = new PluginsManager(
|
|
@@ -15785,6 +15848,7 @@ function levenshtein(a, b) {
|
|
|
15785
15848
|
}
|
|
15786
15849
|
|
|
15787
15850
|
// src/internal/runtime/local-agent/real-local-run.ts
|
|
15851
|
+
init_async_local_storage();
|
|
15788
15852
|
function createRealLocalRun(options) {
|
|
15789
15853
|
const { userText, id, startTime } = prepareRunContext(options.message);
|
|
15790
15854
|
const supported = /* @__PURE__ */ new Set(["stream", "wait", "cancel", "conversation"]);
|
|
@@ -15896,6 +15960,7 @@ function buildLoopInputs(options, runId, userText) {
|
|
|
15896
15960
|
...options.onStep !== void 0 ? { onStep: options.onStep } : {},
|
|
15897
15961
|
...options.onDelta !== void 0 ? { onDelta: options.onDelta } : {},
|
|
15898
15962
|
...options.sendOptions.toolChoice !== void 0 ? { toolChoice: options.sendOptions.toolChoice } : {},
|
|
15963
|
+
...options.sendOptions.activeTools !== void 0 ? { activeTools: options.sendOptions.activeTools } : {},
|
|
15899
15964
|
...options.priorMessages !== void 0 ? { priorMessages: options.priorMessages } : {},
|
|
15900
15965
|
...options.memoryTools !== void 0 && options.memoryTools.length > 0 ? { memoryTools: options.memoryTools } : {},
|
|
15901
15966
|
...buildCustomToolsInput(
|
|
@@ -16026,7 +16091,7 @@ var RealLocalRun = class extends FixtureRunBase {
|
|
|
16026
16091
|
}
|
|
16027
16092
|
async executeAgentLoop(inputs) {
|
|
16028
16093
|
try {
|
|
16029
|
-
const output = await runAgentLoop(inputs);
|
|
16094
|
+
const output = inputs.activeTools !== void 0 ? await withToolWhitelist(new Set(inputs.activeTools), () => runAgentLoop(inputs)) : await runAgentLoop(inputs);
|
|
16030
16095
|
this.applyAgentLoopOutput(output);
|
|
16031
16096
|
this.transitionTo(output.finalStatus);
|
|
16032
16097
|
} catch (cause) {
|
|
@@ -17963,7 +18028,7 @@ var LocalAgent = class {
|
|
|
17963
18028
|
}
|
|
17964
18029
|
// biome-ignore format: G8 budget — thin accessor for the assembly inputs.
|
|
17965
18030
|
assemblyInputs() {
|
|
17966
|
-
return { agentId: this.agentId, workspaceCwd: this.workspaceCwd, model: this.model, options: this.options, context: this.context, skillsManager: this.skillsManager, systemPromptPipeline: this.systemPromptPipeline };
|
|
18031
|
+
return { agentId: this.agentId, workspaceCwd: this.workspaceCwd, model: this.model, options: this.options, context: this.context, skillsManager: this.skillsManager, settingSourcesIncludeProject: this.settingSourcesIncludeProject, systemPromptPipeline: this.systemPromptPipeline };
|
|
17967
18032
|
}
|
|
17968
18033
|
async resolveSystemPrompt(userText, options, memoryFacts) {
|
|
17969
18034
|
const base = await resolveSystemPromptForSend(
|
|
@@ -19083,7 +19148,8 @@ function createSkill(spec) {
|
|
|
19083
19148
|
source: `inline://${spec.name}`,
|
|
19084
19149
|
instructions: spec.instructions,
|
|
19085
19150
|
...spec.category !== void 0 ? { category: spec.category } : {},
|
|
19086
|
-
...spec.dependencies !== void 0 ? { dependencies: spec.dependencies } : {}
|
|
19151
|
+
...spec.dependencies !== void 0 ? { dependencies: spec.dependencies } : {},
|
|
19152
|
+
...spec.references !== void 0 ? { references: spec.references } : {}
|
|
19087
19153
|
};
|
|
19088
19154
|
}
|
|
19089
19155
|
|
|
@@ -19510,8 +19576,53 @@ function defineProvider(profile, opts) {
|
|
|
19510
19576
|
};
|
|
19511
19577
|
}
|
|
19512
19578
|
|
|
19579
|
+
// src/define-skill-read-tool.ts
|
|
19580
|
+
init_to_json_schema();
|
|
19581
|
+
var SkillReadInputSchema = z.object({
|
|
19582
|
+
name: z.string().min(1, "skill_read: `name` is required.")
|
|
19583
|
+
});
|
|
19584
|
+
function renderSkill(skill) {
|
|
19585
|
+
const parts = [`# Skill: ${skill.name}`, "", skill.instructions];
|
|
19586
|
+
const refs = skill.references;
|
|
19587
|
+
if (refs !== void 0 && Object.keys(refs).length > 0) {
|
|
19588
|
+
parts.push("", "## References");
|
|
19589
|
+
for (const [file, content] of Object.entries(refs)) {
|
|
19590
|
+
parts.push("", `### ${file}`, content);
|
|
19591
|
+
}
|
|
19592
|
+
}
|
|
19593
|
+
return parts.join("\n");
|
|
19594
|
+
}
|
|
19595
|
+
function defineSkillReadTool(skills) {
|
|
19596
|
+
const seen = /* @__PURE__ */ new Set();
|
|
19597
|
+
for (const skill of skills) {
|
|
19598
|
+
if (seen.has(skill.name)) {
|
|
19599
|
+
throw new Error(`defineSkillReadTool: duplicate skill name "${skill.name}".`);
|
|
19600
|
+
}
|
|
19601
|
+
seen.add(skill.name);
|
|
19602
|
+
}
|
|
19603
|
+
return {
|
|
19604
|
+
name: "skill_read",
|
|
19605
|
+
description: "Read a skill's full instructions (and any bundled reference documents) by its name. Use this to load the body of a skill listed in the <skills> block before acting on it.",
|
|
19606
|
+
inputSchema: toJsonSchema(SkillReadInputSchema),
|
|
19607
|
+
handler: (input) => {
|
|
19608
|
+
const { name } = SkillReadInputSchema.parse(input);
|
|
19609
|
+
const skill = skills.find((s) => s.name === name);
|
|
19610
|
+
if (skill === void 0) {
|
|
19611
|
+
const available = skills.map((s) => s.name).join(", ");
|
|
19612
|
+
return `Skill "${name}" not found. Available skills: ${available.length > 0 ? available : "(none)"}.`;
|
|
19613
|
+
}
|
|
19614
|
+
return renderSkill(skill);
|
|
19615
|
+
}
|
|
19616
|
+
};
|
|
19617
|
+
}
|
|
19618
|
+
|
|
19513
19619
|
// src/define-tool.ts
|
|
19514
19620
|
init_to_json_schema();
|
|
19621
|
+
function shapeToolResult(spec, out) {
|
|
19622
|
+
const validated = spec.outputSchema === void 0 ? out : spec.outputSchema.parse(out);
|
|
19623
|
+
if (spec.toModelOutput !== void 0) return spec.toModelOutput(validated);
|
|
19624
|
+
return typeof validated === "string" ? validated : JSON.stringify(validated);
|
|
19625
|
+
}
|
|
19515
19626
|
function defineTool(spec) {
|
|
19516
19627
|
const inputSchema = toJsonSchema(spec.inputSchema, {
|
|
19517
19628
|
unrepresentable: "any"
|
|
@@ -19526,7 +19637,8 @@ function defineTool(spec) {
|
|
|
19526
19637
|
schema: spec.inputSchema
|
|
19527
19638
|
}).value : input;
|
|
19528
19639
|
const parsed = spec.inputSchema.parse(raw);
|
|
19529
|
-
|
|
19640
|
+
const out = await spec.handler(parsed, ctx);
|
|
19641
|
+
return shapeToolResult(spec, out);
|
|
19530
19642
|
}
|
|
19531
19643
|
};
|
|
19532
19644
|
}
|
|
@@ -21401,6 +21513,6 @@ function safeStringify2(v) {
|
|
|
21401
21513
|
}
|
|
21402
21514
|
}
|
|
21403
21515
|
|
|
21404
|
-
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, ToolError, UnknownAgentError, UnsupportedBudgetOperationError, UnsupportedRunOperationError, UnsupportedTaskOperationError, UsageAccumulator, applyMode, buildReplayHistory, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createPermissionPlugin, createSessionManager, createSkill, createSquad, definePlugin, defineProvider, defineTool, emitRunEvent, extractRawId, getPricingEntry, inferApiMode, isTransientError, migrateSqliteToLance2 as migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, preflightCheck, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, withCwdMutex };
|
|
21516
|
+
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, ToolError, UnknownAgentError, UnsupportedBudgetOperationError, UnsupportedRunOperationError, UnsupportedTaskOperationError, UsageAccumulator, applyMode, buildReplayHistory, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createPermissionPlugin, createSessionManager, createSkill, createSquad, definePlugin, defineProvider, defineSkillReadTool, defineTool, emitRunEvent, extractRawId, getPricingEntry, inferApiMode, isTransientError, migrateSqliteToLance2 as migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, preflightCheck, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, withCwdMutex };
|
|
21405
21517
|
//# sourceMappingURL=index.js.map
|
|
21406
21518
|
//# sourceMappingURL=index.js.map
|