@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/cron.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import './run-
|
|
2
|
-
export {
|
|
1
|
+
import './run-Cr0C6cOM.cjs';
|
|
2
|
+
export { R as Cron } from './cron-qI-dbG7c.cjs';
|
|
3
3
|
import 'zod';
|
package/dist/cron.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import './run-
|
|
2
|
-
export {
|
|
1
|
+
import './run-Cr0C6cOM.js';
|
|
2
|
+
export { R as Cron } from './cron-B44D-678.js';
|
|
3
3
|
import 'zod';
|
package/dist/cron.js
CHANGED
|
@@ -3459,7 +3459,8 @@ function stripSecretsFromOptions(options) {
|
|
|
3459
3459
|
local: serializeLocal(options.local),
|
|
3460
3460
|
cloud: serializeCloud(options.cloud),
|
|
3461
3461
|
memory: serializeMemory(options.memory),
|
|
3462
|
-
|
|
3462
|
+
// SE22 — a SkillsResolver function isn't serializable; persist only the static form.
|
|
3463
|
+
skills: serializeEnabledList(typeof options.skills === "function" ? void 0 : options.skills),
|
|
3463
3464
|
// Code-`Plugin` objects are closures and cannot be persisted (like custom
|
|
3464
3465
|
// tools); only the named-enable settings form is serialized.
|
|
3465
3466
|
plugins: serializeEnabledList(asPluginsSettings(options.plugins)),
|
|
@@ -3767,6 +3768,7 @@ function serializeCloud2(cloud) {
|
|
|
3767
3768
|
return result;
|
|
3768
3769
|
}
|
|
3769
3770
|
function serializeSkills(skills) {
|
|
3771
|
+
if (typeof skills === "function") return void 0;
|
|
3770
3772
|
if (skills?.enabled === void 0 || skills.enabled.length === 0) return void 0;
|
|
3771
3773
|
return { enabled: [...skills.enabled] };
|
|
3772
3774
|
}
|
|
@@ -5238,6 +5240,7 @@ init_errors();
|
|
|
5238
5240
|
function validateCloudToolParity(options) {
|
|
5239
5241
|
if (options.cloud === void 0) return;
|
|
5240
5242
|
rejectFunctionSystemPrompt(options);
|
|
5243
|
+
rejectFunctionSkills(options);
|
|
5241
5244
|
rejectStdioMcpLocalPaths(options);
|
|
5242
5245
|
}
|
|
5243
5246
|
function rejectFunctionSystemPrompt(options) {
|
|
@@ -5248,6 +5251,14 @@ function rejectFunctionSystemPrompt(options) {
|
|
|
5248
5251
|
);
|
|
5249
5252
|
}
|
|
5250
5253
|
}
|
|
5254
|
+
function rejectFunctionSkills(options) {
|
|
5255
|
+
if (typeof options.skills === "function") {
|
|
5256
|
+
throw new ConfigurationError(
|
|
5257
|
+
"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.",
|
|
5258
|
+
{ code: "cloud_incompatible_function_resolver" }
|
|
5259
|
+
);
|
|
5260
|
+
}
|
|
5261
|
+
}
|
|
5251
5262
|
function rejectStdioMcpLocalPaths(options) {
|
|
5252
5263
|
if (options.mcpServers === void 0) return;
|
|
5253
5264
|
for (const [name, config] of Object.entries(options.mcpServers)) {
|
|
@@ -7104,9 +7115,223 @@ function parseFrontmatterFields(frontmatter) {
|
|
|
7104
7115
|
return out;
|
|
7105
7116
|
}
|
|
7106
7117
|
|
|
7118
|
+
// src/internal/runtime/skills/discover-skills.ts
|
|
7119
|
+
init_errors();
|
|
7120
|
+
|
|
7121
|
+
// src/internal/runtime/skills/skill-frontmatter.ts
|
|
7122
|
+
init_errors();
|
|
7123
|
+
init_yaml_frontmatter();
|
|
7124
|
+
function asString(v) {
|
|
7125
|
+
return typeof v === "string" ? v : void 0;
|
|
7126
|
+
}
|
|
7127
|
+
function toStringFields(raw) {
|
|
7128
|
+
const out = {};
|
|
7129
|
+
for (const [k, v] of Object.entries(raw)) out[k] = asString(v);
|
|
7130
|
+
return out;
|
|
7131
|
+
}
|
|
7132
|
+
function parseSkillFrontmatter(raw, fallbackName) {
|
|
7133
|
+
const fields = extractAndParseFrontmatter(raw, fallbackName);
|
|
7134
|
+
const name = resolveName(fields, fallbackName);
|
|
7135
|
+
ensureRequiredFields(fields, name);
|
|
7136
|
+
return buildFrontmatter(fields, name);
|
|
7137
|
+
}
|
|
7138
|
+
function stripSkillFrontmatter(raw) {
|
|
7139
|
+
const match = /^---\s*\n[\s\S]*?\n---\s*\n/.exec(raw);
|
|
7140
|
+
return (match === null ? raw : raw.slice(match[0].length)).trim();
|
|
7141
|
+
}
|
|
7142
|
+
function extractAndParseFrontmatter(raw, fallbackName) {
|
|
7143
|
+
const match = /^---\s*\n([\s\S]*?)\n---\s*\n/.exec(raw);
|
|
7144
|
+
if (match === null) {
|
|
7145
|
+
throw new ConfigurationError(`Skill ${fallbackName} is missing frontmatter`, {
|
|
7146
|
+
code: "missing_frontmatter"
|
|
7147
|
+
});
|
|
7148
|
+
}
|
|
7149
|
+
const frontmatter = match[1] ?? "";
|
|
7150
|
+
try {
|
|
7151
|
+
return toStringFields(parseSimpleYaml(frontmatter));
|
|
7152
|
+
} catch (cause) {
|
|
7153
|
+
const detail = cause instanceof Error ? cause.message : String(cause);
|
|
7154
|
+
throw new ConfigurationError(
|
|
7155
|
+
`Skill ${fallbackName} has malformed YAML frontmatter: ${detail}`,
|
|
7156
|
+
{ code: "schema_invalid", cause }
|
|
7157
|
+
);
|
|
7158
|
+
}
|
|
7159
|
+
}
|
|
7160
|
+
function resolveName(fields, fallbackName) {
|
|
7161
|
+
if (hasContent(fields.name)) return fields.name;
|
|
7162
|
+
if (hasContent(fallbackName)) return fallbackName;
|
|
7163
|
+
throw new ConfigurationError("Skill at unknown path is missing required field: name", {
|
|
7164
|
+
code: "schema_invalid"
|
|
7165
|
+
});
|
|
7166
|
+
}
|
|
7167
|
+
function ensureRequiredFields(fields, name) {
|
|
7168
|
+
if (!hasContent(fields.description)) {
|
|
7169
|
+
throw new ConfigurationError(`Skill ${name} is missing required field: description`, {
|
|
7170
|
+
code: "schema_invalid"
|
|
7171
|
+
});
|
|
7172
|
+
}
|
|
7173
|
+
}
|
|
7174
|
+
function buildFrontmatter(fields, name) {
|
|
7175
|
+
const description = fields.description;
|
|
7176
|
+
if (description === void 0) {
|
|
7177
|
+
throw new ConfigurationError(`Skill ${name} missing description`, { code: "schema_invalid" });
|
|
7178
|
+
}
|
|
7179
|
+
const result = { name, description };
|
|
7180
|
+
if (hasContent(fields.category)) result.category = fields.category;
|
|
7181
|
+
const deps = parseDependencies(fields.dependencies);
|
|
7182
|
+
if (deps !== void 0) result.dependencies = deps;
|
|
7183
|
+
return result;
|
|
7184
|
+
}
|
|
7185
|
+
function parseDependencies(raw) {
|
|
7186
|
+
if (!hasContent(raw)) return void 0;
|
|
7187
|
+
const deps = raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
7188
|
+
return deps.length > 0 ? deps : void 0;
|
|
7189
|
+
}
|
|
7190
|
+
function hasContent(value) {
|
|
7191
|
+
return value !== void 0 && value.trim().length > 0;
|
|
7192
|
+
}
|
|
7193
|
+
|
|
7194
|
+
// src/internal/runtime/skills/discover-skills.ts
|
|
7195
|
+
async function discoverSkills(dir, options) {
|
|
7196
|
+
let entries;
|
|
7197
|
+
try {
|
|
7198
|
+
entries = await readWorkspaceDir(dir, "skills_read_error", "skills directory");
|
|
7199
|
+
} catch {
|
|
7200
|
+
return [];
|
|
7201
|
+
}
|
|
7202
|
+
const skills = [];
|
|
7203
|
+
for (const entry of entries) {
|
|
7204
|
+
if (!entry.isDirectory()) continue;
|
|
7205
|
+
let skillDir;
|
|
7206
|
+
try {
|
|
7207
|
+
skillDir = safePathJoin(dir, entry.name);
|
|
7208
|
+
assertNoSymlinkEscape(skillDir, dir);
|
|
7209
|
+
} catch {
|
|
7210
|
+
continue;
|
|
7211
|
+
}
|
|
7212
|
+
const skillPath = join(skillDir, "SKILL.md");
|
|
7213
|
+
let raw;
|
|
7214
|
+
try {
|
|
7215
|
+
raw = await readFile(skillPath, "utf8");
|
|
7216
|
+
} catch {
|
|
7217
|
+
continue;
|
|
7218
|
+
}
|
|
7219
|
+
const skill = tryParseSkill(raw, entry.name, skillPath, options);
|
|
7220
|
+
if (skill !== void 0) skills.push(skill);
|
|
7221
|
+
}
|
|
7222
|
+
return skills;
|
|
7223
|
+
}
|
|
7224
|
+
function tryParseSkill(raw, fallbackName, source, options) {
|
|
7225
|
+
try {
|
|
7226
|
+
const frontmatter = parseSkillFrontmatter(raw, fallbackName);
|
|
7227
|
+
const skill = {
|
|
7228
|
+
name: frontmatter.name,
|
|
7229
|
+
description: frontmatter.description,
|
|
7230
|
+
source
|
|
7231
|
+
};
|
|
7232
|
+
if (frontmatter.category !== void 0) skill.category = frontmatter.category;
|
|
7233
|
+
if (frontmatter.dependencies !== void 0) skill.dependencies = frontmatter.dependencies;
|
|
7234
|
+
return skill;
|
|
7235
|
+
} catch (cause) {
|
|
7236
|
+
if (cause instanceof ConfigurationError) {
|
|
7237
|
+
options?.onInvalidSkill?.({
|
|
7238
|
+
name: fallbackName,
|
|
7239
|
+
source,
|
|
7240
|
+
code: cause.code ?? "unknown",
|
|
7241
|
+
message: cause.message
|
|
7242
|
+
});
|
|
7243
|
+
return void 0;
|
|
7244
|
+
}
|
|
7245
|
+
throw cause;
|
|
7246
|
+
}
|
|
7247
|
+
}
|
|
7248
|
+
|
|
7249
|
+
// src/internal/runtime/skills/skills-manager.ts
|
|
7250
|
+
var SkillsManager = class {
|
|
7251
|
+
constructor(cwd, _enabled, settingSourcesIncludeProject, skillsDir, inline) {
|
|
7252
|
+
this.cwd = cwd;
|
|
7253
|
+
this.settingSourcesIncludeProject = settingSourcesIncludeProject;
|
|
7254
|
+
this.skillsDir = skillsDir;
|
|
7255
|
+
this.inline = inline;
|
|
7256
|
+
}
|
|
7257
|
+
cwd;
|
|
7258
|
+
settingSourcesIncludeProject;
|
|
7259
|
+
skillsDir;
|
|
7260
|
+
inline;
|
|
7261
|
+
skills = [];
|
|
7262
|
+
async initialize() {
|
|
7263
|
+
if (!this.settingSourcesIncludeProject) {
|
|
7264
|
+
this.skills = this.mergeInline([]);
|
|
7265
|
+
return;
|
|
7266
|
+
}
|
|
7267
|
+
await this.refresh();
|
|
7268
|
+
}
|
|
7269
|
+
async refresh() {
|
|
7270
|
+
const skillsRoot = this.skillsDir ?? join(this.cwd, ".theokit", "skills");
|
|
7271
|
+
const discovered = await discoverSkills(skillsRoot, {
|
|
7272
|
+
onInvalidSkill: (info) => {
|
|
7273
|
+
process.stderr.write(
|
|
7274
|
+
`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
|
|
7275
|
+
`
|
|
7276
|
+
);
|
|
7277
|
+
}
|
|
7278
|
+
});
|
|
7279
|
+
this.skills = this.mergeInline(discovered);
|
|
7280
|
+
}
|
|
7281
|
+
/** M22 — merge inline skills over discovered ones; inline wins on a name conflict. */
|
|
7282
|
+
mergeInline(discovered) {
|
|
7283
|
+
if (this.inline === void 0 || this.inline.length === 0) return discovered;
|
|
7284
|
+
const inlineNames = new Set(this.inline.map((s) => s.name));
|
|
7285
|
+
return [...discovered.filter((s) => !inlineNames.has(s.name)), ...this.inline];
|
|
7286
|
+
}
|
|
7287
|
+
list() {
|
|
7288
|
+
return Promise.resolve(this.skills);
|
|
7289
|
+
}
|
|
7290
|
+
/**
|
|
7291
|
+
* SE20 — resolve a skill by name INCLUDING its body. Inline (`createSkill`)
|
|
7292
|
+
* skills carry `instructions` on the object; filesystem skills read the body
|
|
7293
|
+
* from their `source` SKILL.md (frontmatter stripped). `undefined` when no
|
|
7294
|
+
* enabled skill matches (malformed skills were already excluded at discovery).
|
|
7295
|
+
*/
|
|
7296
|
+
async get(name) {
|
|
7297
|
+
const skill = this.skills.find((s) => s.name === name);
|
|
7298
|
+
if (skill === void 0) return void 0;
|
|
7299
|
+
const instructions = typeof skill.instructions === "string" ? skill.instructions : stripSkillFrontmatter(await readFile(skill.source, "utf8"));
|
|
7300
|
+
const references = skill.references;
|
|
7301
|
+
return {
|
|
7302
|
+
name: skill.name,
|
|
7303
|
+
description: skill.description,
|
|
7304
|
+
instructions,
|
|
7305
|
+
...references !== void 0 ? { references } : {}
|
|
7306
|
+
};
|
|
7307
|
+
}
|
|
7308
|
+
};
|
|
7309
|
+
|
|
7107
7310
|
// src/internal/runtime/system-prompt/local-assembly.ts
|
|
7108
|
-
async function
|
|
7109
|
-
const skills = inputs.
|
|
7311
|
+
async function resolveSendSkills(inputs, userText, memoryFacts) {
|
|
7312
|
+
const skills = inputs.options.skills;
|
|
7313
|
+
if (typeof skills !== "function") {
|
|
7314
|
+
return { manager: inputs.skillsManager, autoInject: skills?.autoInject ?? true };
|
|
7315
|
+
}
|
|
7316
|
+
const settings = await skills({
|
|
7317
|
+
agentId: inputs.agentId,
|
|
7318
|
+
cwd: inputs.workspaceCwd,
|
|
7319
|
+
model: inputs.model,
|
|
7320
|
+
userMessage: userText,
|
|
7321
|
+
memory: memoryFacts.map((fact) => ({ text: fact.text }))
|
|
7322
|
+
});
|
|
7323
|
+
const manager = new SkillsManager(
|
|
7324
|
+
inputs.workspaceCwd,
|
|
7325
|
+
settings.enabled,
|
|
7326
|
+
inputs.settingSourcesIncludeProject,
|
|
7327
|
+
settings.skillsDir,
|
|
7328
|
+
settings.inline
|
|
7329
|
+
);
|
|
7330
|
+
await manager.initialize();
|
|
7331
|
+
return { manager, autoInject: settings.autoInject ?? true };
|
|
7332
|
+
}
|
|
7333
|
+
async function buildSystemPromptContext(inputs, userText, memoryFacts, manager = inputs.skillsManager) {
|
|
7334
|
+
const skills = manager !== void 0 ? await manager.list() : [];
|
|
7110
7335
|
return {
|
|
7111
7336
|
agentId: inputs.agentId,
|
|
7112
7337
|
cwd: inputs.workspaceCwd,
|
|
@@ -7117,10 +7342,11 @@ async function buildSystemPromptContext(inputs, userText, memoryFacts) {
|
|
|
7117
7342
|
};
|
|
7118
7343
|
}
|
|
7119
7344
|
async function buildAssemblyContext(inputs, userText, baseSystemPrompt, memoryFacts, activeMemorySummary) {
|
|
7120
|
-
const
|
|
7345
|
+
const resolved = await resolveSendSkills(inputs, userText, memoryFacts);
|
|
7346
|
+
const baseCtx = await buildSystemPromptContext(inputs, userText, memoryFacts, resolved.manager);
|
|
7121
7347
|
const assemblyCtx = {
|
|
7122
7348
|
...baseCtx,
|
|
7123
|
-
skillsAutoInject:
|
|
7349
|
+
skillsAutoInject: resolved.autoInject,
|
|
7124
7350
|
memoryAutoInject: inputs.options.memory?.autoInject ?? true
|
|
7125
7351
|
};
|
|
7126
7352
|
if (baseSystemPrompt !== void 0) assemblyCtx.baseSystemPrompt = baseSystemPrompt;
|
|
@@ -8372,176 +8598,6 @@ async function loadPluginManifestFromMarkdown(pluginsRoot, folderName) {
|
|
|
8372
8598
|
return metadata;
|
|
8373
8599
|
}
|
|
8374
8600
|
|
|
8375
|
-
// src/internal/runtime/skills/discover-skills.ts
|
|
8376
|
-
init_errors();
|
|
8377
|
-
|
|
8378
|
-
// src/internal/runtime/skills/skill-frontmatter.ts
|
|
8379
|
-
init_errors();
|
|
8380
|
-
init_yaml_frontmatter();
|
|
8381
|
-
function asString(v) {
|
|
8382
|
-
return typeof v === "string" ? v : void 0;
|
|
8383
|
-
}
|
|
8384
|
-
function toStringFields(raw) {
|
|
8385
|
-
const out = {};
|
|
8386
|
-
for (const [k, v] of Object.entries(raw)) out[k] = asString(v);
|
|
8387
|
-
return out;
|
|
8388
|
-
}
|
|
8389
|
-
function parseSkillFrontmatter(raw, fallbackName) {
|
|
8390
|
-
const fields = extractAndParseFrontmatter(raw, fallbackName);
|
|
8391
|
-
const name = resolveName(fields, fallbackName);
|
|
8392
|
-
ensureRequiredFields(fields, name);
|
|
8393
|
-
return buildFrontmatter(fields, name);
|
|
8394
|
-
}
|
|
8395
|
-
function extractAndParseFrontmatter(raw, fallbackName) {
|
|
8396
|
-
const match = /^---\s*\n([\s\S]*?)\n---\s*\n/.exec(raw);
|
|
8397
|
-
if (match === null) {
|
|
8398
|
-
throw new ConfigurationError(`Skill ${fallbackName} is missing frontmatter`, {
|
|
8399
|
-
code: "missing_frontmatter"
|
|
8400
|
-
});
|
|
8401
|
-
}
|
|
8402
|
-
const frontmatter = match[1] ?? "";
|
|
8403
|
-
try {
|
|
8404
|
-
return toStringFields(parseSimpleYaml(frontmatter));
|
|
8405
|
-
} catch (cause) {
|
|
8406
|
-
const detail = cause instanceof Error ? cause.message : String(cause);
|
|
8407
|
-
throw new ConfigurationError(
|
|
8408
|
-
`Skill ${fallbackName} has malformed YAML frontmatter: ${detail}`,
|
|
8409
|
-
{ code: "schema_invalid", cause }
|
|
8410
|
-
);
|
|
8411
|
-
}
|
|
8412
|
-
}
|
|
8413
|
-
function resolveName(fields, fallbackName) {
|
|
8414
|
-
if (hasContent(fields.name)) return fields.name;
|
|
8415
|
-
if (hasContent(fallbackName)) return fallbackName;
|
|
8416
|
-
throw new ConfigurationError("Skill at unknown path is missing required field: name", {
|
|
8417
|
-
code: "schema_invalid"
|
|
8418
|
-
});
|
|
8419
|
-
}
|
|
8420
|
-
function ensureRequiredFields(fields, name) {
|
|
8421
|
-
if (!hasContent(fields.description)) {
|
|
8422
|
-
throw new ConfigurationError(`Skill ${name} is missing required field: description`, {
|
|
8423
|
-
code: "schema_invalid"
|
|
8424
|
-
});
|
|
8425
|
-
}
|
|
8426
|
-
}
|
|
8427
|
-
function buildFrontmatter(fields, name) {
|
|
8428
|
-
const description = fields.description;
|
|
8429
|
-
if (description === void 0) {
|
|
8430
|
-
throw new ConfigurationError(`Skill ${name} missing description`, { code: "schema_invalid" });
|
|
8431
|
-
}
|
|
8432
|
-
const result = { name, description };
|
|
8433
|
-
if (hasContent(fields.category)) result.category = fields.category;
|
|
8434
|
-
const deps = parseDependencies(fields.dependencies);
|
|
8435
|
-
if (deps !== void 0) result.dependencies = deps;
|
|
8436
|
-
return result;
|
|
8437
|
-
}
|
|
8438
|
-
function parseDependencies(raw) {
|
|
8439
|
-
if (!hasContent(raw)) return void 0;
|
|
8440
|
-
const deps = raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
8441
|
-
return deps.length > 0 ? deps : void 0;
|
|
8442
|
-
}
|
|
8443
|
-
function hasContent(value) {
|
|
8444
|
-
return value !== void 0 && value.trim().length > 0;
|
|
8445
|
-
}
|
|
8446
|
-
|
|
8447
|
-
// src/internal/runtime/skills/discover-skills.ts
|
|
8448
|
-
async function discoverSkills(dir, options) {
|
|
8449
|
-
let entries;
|
|
8450
|
-
try {
|
|
8451
|
-
entries = await readWorkspaceDir(dir, "skills_read_error", "skills directory");
|
|
8452
|
-
} catch {
|
|
8453
|
-
return [];
|
|
8454
|
-
}
|
|
8455
|
-
const skills = [];
|
|
8456
|
-
for (const entry of entries) {
|
|
8457
|
-
if (!entry.isDirectory()) continue;
|
|
8458
|
-
let skillDir;
|
|
8459
|
-
try {
|
|
8460
|
-
skillDir = safePathJoin(dir, entry.name);
|
|
8461
|
-
assertNoSymlinkEscape(skillDir, dir);
|
|
8462
|
-
} catch {
|
|
8463
|
-
continue;
|
|
8464
|
-
}
|
|
8465
|
-
const skillPath = join(skillDir, "SKILL.md");
|
|
8466
|
-
let raw;
|
|
8467
|
-
try {
|
|
8468
|
-
raw = await readFile(skillPath, "utf8");
|
|
8469
|
-
} catch {
|
|
8470
|
-
continue;
|
|
8471
|
-
}
|
|
8472
|
-
const skill = tryParseSkill(raw, entry.name, skillPath, options);
|
|
8473
|
-
if (skill !== void 0) skills.push(skill);
|
|
8474
|
-
}
|
|
8475
|
-
return skills;
|
|
8476
|
-
}
|
|
8477
|
-
function tryParseSkill(raw, fallbackName, source, options) {
|
|
8478
|
-
try {
|
|
8479
|
-
const frontmatter = parseSkillFrontmatter(raw, fallbackName);
|
|
8480
|
-
const skill = {
|
|
8481
|
-
name: frontmatter.name,
|
|
8482
|
-
description: frontmatter.description,
|
|
8483
|
-
source
|
|
8484
|
-
};
|
|
8485
|
-
if (frontmatter.category !== void 0) skill.category = frontmatter.category;
|
|
8486
|
-
if (frontmatter.dependencies !== void 0) skill.dependencies = frontmatter.dependencies;
|
|
8487
|
-
return skill;
|
|
8488
|
-
} catch (cause) {
|
|
8489
|
-
if (cause instanceof ConfigurationError) {
|
|
8490
|
-
options?.onInvalidSkill?.({
|
|
8491
|
-
name: fallbackName,
|
|
8492
|
-
source,
|
|
8493
|
-
code: cause.code ?? "unknown",
|
|
8494
|
-
message: cause.message
|
|
8495
|
-
});
|
|
8496
|
-
return void 0;
|
|
8497
|
-
}
|
|
8498
|
-
throw cause;
|
|
8499
|
-
}
|
|
8500
|
-
}
|
|
8501
|
-
|
|
8502
|
-
// src/internal/runtime/skills/skills-manager.ts
|
|
8503
|
-
var SkillsManager = class {
|
|
8504
|
-
constructor(cwd, _enabled, settingSourcesIncludeProject, skillsDir, inline) {
|
|
8505
|
-
this.cwd = cwd;
|
|
8506
|
-
this.settingSourcesIncludeProject = settingSourcesIncludeProject;
|
|
8507
|
-
this.skillsDir = skillsDir;
|
|
8508
|
-
this.inline = inline;
|
|
8509
|
-
}
|
|
8510
|
-
cwd;
|
|
8511
|
-
settingSourcesIncludeProject;
|
|
8512
|
-
skillsDir;
|
|
8513
|
-
inline;
|
|
8514
|
-
skills = [];
|
|
8515
|
-
async initialize() {
|
|
8516
|
-
if (!this.settingSourcesIncludeProject) {
|
|
8517
|
-
this.skills = this.mergeInline([]);
|
|
8518
|
-
return;
|
|
8519
|
-
}
|
|
8520
|
-
await this.refresh();
|
|
8521
|
-
}
|
|
8522
|
-
async refresh() {
|
|
8523
|
-
const skillsRoot = this.skillsDir ?? join(this.cwd, ".theokit", "skills");
|
|
8524
|
-
const discovered = await discoverSkills(skillsRoot, {
|
|
8525
|
-
onInvalidSkill: (info) => {
|
|
8526
|
-
process.stderr.write(
|
|
8527
|
-
`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
|
|
8528
|
-
`
|
|
8529
|
-
);
|
|
8530
|
-
}
|
|
8531
|
-
});
|
|
8532
|
-
this.skills = this.mergeInline(discovered);
|
|
8533
|
-
}
|
|
8534
|
-
/** M22 — merge inline skills over discovered ones; inline wins on a name conflict. */
|
|
8535
|
-
mergeInline(discovered) {
|
|
8536
|
-
if (this.inline === void 0 || this.inline.length === 0) return discovered;
|
|
8537
|
-
const inlineNames = new Set(this.inline.map((s) => s.name));
|
|
8538
|
-
return [...discovered.filter((s) => !inlineNames.has(s.name)), ...this.inline];
|
|
8539
|
-
}
|
|
8540
|
-
list() {
|
|
8541
|
-
return Promise.resolve(this.skills);
|
|
8542
|
-
}
|
|
8543
|
-
};
|
|
8544
|
-
|
|
8545
8601
|
// src/internal/runtime/local-agent/local-agent-bootstrap.ts
|
|
8546
8602
|
function registerLocalAgent(args) {
|
|
8547
8603
|
registerAgent({
|
|
@@ -8577,16 +8633,23 @@ function bootstrapSubmanagers(args) {
|
|
|
8577
8633
|
);
|
|
8578
8634
|
}
|
|
8579
8635
|
if (args.options.skills !== void 0 || args.settingSourcesIncludeProject) {
|
|
8636
|
+
const staticSkills = typeof args.options.skills === "function" ? void 0 : args.options.skills;
|
|
8580
8637
|
out.skillsManager = new SkillsManager(
|
|
8581
8638
|
args.workspaceCwd,
|
|
8582
|
-
|
|
8639
|
+
staticSkills?.enabled,
|
|
8583
8640
|
args.settingSourcesIncludeProject,
|
|
8584
8641
|
// M22 — custom skills directory + inline (code-defined) skills.
|
|
8585
|
-
|
|
8586
|
-
|
|
8642
|
+
staticSkills?.skillsDir,
|
|
8643
|
+
staticSkills?.inline
|
|
8587
8644
|
);
|
|
8588
8645
|
const localSkills = out.skillsManager;
|
|
8589
|
-
out.skills = {
|
|
8646
|
+
out.skills = {
|
|
8647
|
+
// Project to the public shape (name + description only). Inline skills carry
|
|
8648
|
+
// their body + references on the object; `list()` must never leak them —
|
|
8649
|
+
// the body is reachable exclusively through `get()`.
|
|
8650
|
+
list: async () => (await localSkills.list()).map((s) => ({ name: s.name, description: s.description })),
|
|
8651
|
+
get: (name) => localSkills.get(name)
|
|
8652
|
+
};
|
|
8590
8653
|
}
|
|
8591
8654
|
if (args.options.plugins !== void 0 || args.settingSourcesIncludePlugins) {
|
|
8592
8655
|
out.pluginsManager = new PluginsManager(
|
|
@@ -13304,6 +13367,7 @@ function levenshtein(a, b) {
|
|
|
13304
13367
|
}
|
|
13305
13368
|
|
|
13306
13369
|
// src/internal/runtime/local-agent/real-local-run.ts
|
|
13370
|
+
init_async_local_storage();
|
|
13307
13371
|
function createRealLocalRun(options) {
|
|
13308
13372
|
const { userText, id, startTime } = prepareRunContext(options.message);
|
|
13309
13373
|
const supported = /* @__PURE__ */ new Set(["stream", "wait", "cancel", "conversation"]);
|
|
@@ -13415,6 +13479,7 @@ function buildLoopInputs(options, runId, userText) {
|
|
|
13415
13479
|
...options.onStep !== void 0 ? { onStep: options.onStep } : {},
|
|
13416
13480
|
...options.onDelta !== void 0 ? { onDelta: options.onDelta } : {},
|
|
13417
13481
|
...options.sendOptions.toolChoice !== void 0 ? { toolChoice: options.sendOptions.toolChoice } : {},
|
|
13482
|
+
...options.sendOptions.activeTools !== void 0 ? { activeTools: options.sendOptions.activeTools } : {},
|
|
13418
13483
|
...options.priorMessages !== void 0 ? { priorMessages: options.priorMessages } : {},
|
|
13419
13484
|
...options.memoryTools !== void 0 && options.memoryTools.length > 0 ? { memoryTools: options.memoryTools } : {},
|
|
13420
13485
|
...buildCustomToolsInput(
|
|
@@ -13545,7 +13610,7 @@ var RealLocalRun = class extends FixtureRunBase {
|
|
|
13545
13610
|
}
|
|
13546
13611
|
async executeAgentLoop(inputs) {
|
|
13547
13612
|
try {
|
|
13548
|
-
const output = await runAgentLoop(inputs);
|
|
13613
|
+
const output = inputs.activeTools !== void 0 ? await withToolWhitelist(new Set(inputs.activeTools), () => runAgentLoop(inputs)) : await runAgentLoop(inputs);
|
|
13549
13614
|
this.applyAgentLoopOutput(output);
|
|
13550
13615
|
this.transitionTo(output.finalStatus);
|
|
13551
13616
|
} catch (cause) {
|
|
@@ -16430,7 +16495,7 @@ var LocalAgent = class {
|
|
|
16430
16495
|
}
|
|
16431
16496
|
// biome-ignore format: G8 budget — thin accessor for the assembly inputs.
|
|
16432
16497
|
assemblyInputs() {
|
|
16433
|
-
return { agentId: this.agentId, workspaceCwd: this.workspaceCwd, model: this.model, options: this.options, context: this.context, skillsManager: this.skillsManager, systemPromptPipeline: this.systemPromptPipeline };
|
|
16498
|
+
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 };
|
|
16434
16499
|
}
|
|
16435
16500
|
async resolveSystemPrompt(userText, options, memoryFacts) {
|
|
16436
16501
|
const base = await resolveSystemPromptForSend(
|