@theokit/sdk 3.1.1 → 3.2.2
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 +36 -0
- package/dist/a2a/index.cjs +188 -49
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +188 -49
- package/dist/a2a/index.js.map +1 -1
- package/dist/{cron-C2jWAvlQ.d.cts → cron-4u1UdmgC.d.cts} +1 -1
- package/dist/{cron-BLRe166v.d.ts → cron-DuhVPer6.d.ts} +1 -1
- package/dist/cron.cjs +188 -49
- 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 +188 -49
- package/dist/cron.js.map +1 -1
- package/dist/{errors-D_Bfo30u.d.ts → errors-_fPS0X80.d.ts} +1 -1
- package/dist/{errors-DZpCGlYv.d.cts → errors-jxK4yfp5.d.cts} +1 -1
- package/dist/errors.d.cts +2 -2
- package/dist/eval.cjs +188 -64
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +188 -64
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +197 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +197 -50
- package/dist/index.js.map +1 -1
- package/dist/internal/runtime/context/context-discovery.d.ts +1 -1
- package/dist/internal/runtime/context/context-glob.d.ts +1 -0
- package/dist/internal/runtime/context/context-manager.d.ts +18 -1
- package/dist/internal/runtime/context/context-mdc-parser.d.ts +7 -6
- package/dist/internal/runtime/context/context-rules-frontmatter.d.ts +30 -0
- package/dist/internal/runtime/context/context-yaml-lite.d.ts +26 -0
- package/dist/project.cjs.map +1 -1
- package/dist/project.js.map +1 -1
- package/dist/{run-CLXKMRgq.d.cts → run-CrHz9BAP.d.cts} +9 -0
- package/dist/{run-CLXKMRgq.d.ts → run-CrHz9BAP.d.ts} +9 -0
- package/dist/sandbox/index.cjs +8 -9
- package/dist/sandbox/index.cjs.map +1 -1
- package/dist/sandbox/index.js +8 -9
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/types.d.cts +0 -1
- package/dist/sandbox/types.d.ts +0 -1
- package/dist/types/run.d.ts +9 -0
- package/package.json +3 -3
package/dist/a2a/index.js
CHANGED
|
@@ -959,10 +959,10 @@ function buildToolPrompt(prompt) {
|
|
|
959
959
|
Respond by calling the \`output\` tool with the structured answer that matches the schema.`;
|
|
960
960
|
}
|
|
961
961
|
function setupStructuredOutput(schema, maxRetries) {
|
|
962
|
-
const
|
|
962
|
+
const z8 = requireZod();
|
|
963
963
|
const jsonSchema = toJsonSchema(schema, { unrepresentable: "any" });
|
|
964
964
|
return {
|
|
965
|
-
z:
|
|
965
|
+
z: z8,
|
|
966
966
|
jsonSchema,
|
|
967
967
|
maxRetries: maxRetries ?? 1,
|
|
968
968
|
initialUsage: { inputTokens: 0, outputTokens: 0 }
|
|
@@ -4740,7 +4740,14 @@ var init_env_policy = __esm({
|
|
|
4740
4740
|
/[_-]PWD/i,
|
|
4741
4741
|
/CREDENTIAL/i,
|
|
4742
4742
|
/PRIVATE/i,
|
|
4743
|
-
/_AUTH/i
|
|
4743
|
+
/_AUTH/i,
|
|
4744
|
+
// #54-a — value-embedded-secret conventions (no generic `*_URL` — see keep-list test).
|
|
4745
|
+
/DSN/i,
|
|
4746
|
+
/WEBHOOK/i,
|
|
4747
|
+
/COOKIE/i,
|
|
4748
|
+
/CONNECTION[_-]?STRING/i,
|
|
4749
|
+
// Known DB / message-broker connection-string vars (carry `user:pass@`).
|
|
4750
|
+
/(?:^|[_-])(?:DATABASE|DB|REDIS|MONGO(?:DB)?|POSTGRES(?:QL)?|MYSQL|MARIADB|AMQP|RABBITMQ|CLICKHOUSE|ELASTIC(?:SEARCH)?|CASSANDRA|COUCHDB|MEMCACHED|NATS|KAFKA)[_-]?(?:URL|URI|DSN|CONNECTION)/i
|
|
4744
4751
|
];
|
|
4745
4752
|
CORE_VARS = [
|
|
4746
4753
|
"PATH",
|
|
@@ -6038,7 +6045,7 @@ async function buildSystemPromptContext(inputs, userText, memoryFacts, manager =
|
|
|
6038
6045
|
memory: memoryFacts.map((fact) => ({ text: fact.text }))
|
|
6039
6046
|
};
|
|
6040
6047
|
}
|
|
6041
|
-
async function buildAssemblyContext(inputs, userText, baseSystemPrompt, memoryFacts, activeMemorySummary) {
|
|
6048
|
+
async function buildAssemblyContext(inputs, userText, baseSystemPrompt, memoryFacts, activeMemorySummary, contextPaths) {
|
|
6042
6049
|
const resolved = await resolveSendSkills(inputs, userText, memoryFacts);
|
|
6043
6050
|
const baseCtx = await buildSystemPromptContext(inputs, userText, memoryFacts, resolved.manager);
|
|
6044
6051
|
const assemblyCtx = {
|
|
@@ -6051,19 +6058,21 @@ async function buildAssemblyContext(inputs, userText, baseSystemPrompt, memoryFa
|
|
|
6051
6058
|
assemblyCtx.activeMemorySummary = activeMemorySummary;
|
|
6052
6059
|
}
|
|
6053
6060
|
if (inputs.context !== void 0) {
|
|
6061
|
+
await inputs.context.applyScope(contextPaths);
|
|
6054
6062
|
const internal = inputs.context.internalAssemblySnapshot();
|
|
6055
6063
|
assemblyCtx.contextSnapshot = { sources: internal.sources };
|
|
6056
6064
|
if (internal.maxTokens !== void 0) assemblyCtx.contextMaxTokens = internal.maxTokens;
|
|
6057
6065
|
}
|
|
6058
6066
|
return assemblyCtx;
|
|
6059
6067
|
}
|
|
6060
|
-
async function assembleSystemPromptForSend(inputs, userText, baseSystemPrompt, memoryFacts, activeMemorySummary) {
|
|
6068
|
+
async function assembleSystemPromptForSend(inputs, userText, baseSystemPrompt, memoryFacts, activeMemorySummary, contextPaths) {
|
|
6061
6069
|
const ctx = await buildAssemblyContext(
|
|
6062
6070
|
inputs,
|
|
6063
6071
|
userText,
|
|
6064
6072
|
baseSystemPrompt,
|
|
6065
6073
|
memoryFacts,
|
|
6066
|
-
activeMemorySummary
|
|
6074
|
+
activeMemorySummary,
|
|
6075
|
+
contextPaths
|
|
6067
6076
|
);
|
|
6068
6077
|
return inputs.systemPromptPipeline.assemble(ctx);
|
|
6069
6078
|
}
|
|
@@ -6770,6 +6779,14 @@ var init_context_discovery = __esm({
|
|
|
6770
6779
|
followImports: false,
|
|
6771
6780
|
priority: 40
|
|
6772
6781
|
},
|
|
6782
|
+
{
|
|
6783
|
+
id: "theokit-rules",
|
|
6784
|
+
pattern: ".theokit/rules/*.md",
|
|
6785
|
+
scope: "globbed",
|
|
6786
|
+
parser: "rules-frontmatter",
|
|
6787
|
+
followImports: false,
|
|
6788
|
+
priority: 45
|
|
6789
|
+
},
|
|
6773
6790
|
{
|
|
6774
6791
|
id: "theokit-context",
|
|
6775
6792
|
pattern: ".theokit/context/*.md",
|
|
@@ -6853,32 +6870,27 @@ var init_context_import_resolver = __esm({
|
|
|
6853
6870
|
MAX_HOPS = 5;
|
|
6854
6871
|
}
|
|
6855
6872
|
});
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
}
|
|
6861
|
-
const yamlBody = m[1] ?? "";
|
|
6862
|
-
const body = m[2] ?? "";
|
|
6863
|
-
try {
|
|
6864
|
-
const parsed = parseSimpleYaml2(yamlBody);
|
|
6865
|
-
const validated = McdFrontmatterSchema.safeParse(parsed);
|
|
6866
|
-
if (!validated.success) return void 0;
|
|
6867
|
-
return { frontmatter: validated.data, body };
|
|
6868
|
-
} catch {
|
|
6869
|
-
return void 0;
|
|
6870
|
-
}
|
|
6873
|
+
|
|
6874
|
+
// src/internal/runtime/context/context-glob.ts
|
|
6875
|
+
function globToRegex(glob) {
|
|
6876
|
+
const compiled = glob.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*\//g, "::GLOBSTAR_SLASH::").replace(/\*\*/g, "::GLOBSTAR::").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(/::GLOBSTAR_SLASH::/g, "(?:.*/)?").replace(/::GLOBSTAR::/g, ".*");
|
|
6877
|
+
return new RegExp(`^${compiled}$`);
|
|
6871
6878
|
}
|
|
6872
|
-
function
|
|
6873
|
-
if (
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
const globRes = fm.globs.map(globToRegex);
|
|
6877
|
-
return touchedFiles.some((file) => globRes.some((re) => re.test(file)));
|
|
6879
|
+
function anyGlobMatches(patterns, paths) {
|
|
6880
|
+
if (patterns.length === 0 || paths.length === 0) return false;
|
|
6881
|
+
const res = patterns.map(globToRegex);
|
|
6882
|
+
return paths.some((p) => res.some((re) => re.test(p)));
|
|
6878
6883
|
}
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6884
|
+
var init_context_glob = __esm({
|
|
6885
|
+
"src/internal/runtime/context/context-glob.ts"() {
|
|
6886
|
+
}
|
|
6887
|
+
});
|
|
6888
|
+
|
|
6889
|
+
// src/internal/runtime/context/context-yaml-lite.ts
|
|
6890
|
+
function splitFrontmatter3(content) {
|
|
6891
|
+
const m = FRONTMATTER_RE.exec(content);
|
|
6892
|
+
if (m === null) return { yaml: void 0, body: content };
|
|
6893
|
+
return { yaml: m[1] ?? "", body: m[2] ?? "" };
|
|
6882
6894
|
}
|
|
6883
6895
|
function parseSimpleYaml2(yaml) {
|
|
6884
6896
|
const out = {};
|
|
@@ -6925,15 +6937,76 @@ function parseScalar(s) {
|
|
|
6925
6937
|
if (/^-?\d+$/.test(s)) return parseInt(s, 10);
|
|
6926
6938
|
return s.replace(/^["']|["']$/g, "");
|
|
6927
6939
|
}
|
|
6928
|
-
var
|
|
6940
|
+
var FRONTMATTER_RE;
|
|
6941
|
+
var init_context_yaml_lite = __esm({
|
|
6942
|
+
"src/internal/runtime/context/context-yaml-lite.ts"() {
|
|
6943
|
+
FRONTMATTER_RE = /^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/;
|
|
6944
|
+
}
|
|
6945
|
+
});
|
|
6946
|
+
function parseMdc(content) {
|
|
6947
|
+
const { yaml, body } = splitFrontmatter3(content);
|
|
6948
|
+
if (yaml === void 0) {
|
|
6949
|
+
return { frontmatter: { alwaysApply: true }, body: content };
|
|
6950
|
+
}
|
|
6951
|
+
try {
|
|
6952
|
+
const parsed = parseSimpleYaml2(yaml);
|
|
6953
|
+
const validated = McdFrontmatterSchema.safeParse(parsed);
|
|
6954
|
+
if (!validated.success) return void 0;
|
|
6955
|
+
return { frontmatter: validated.data, body };
|
|
6956
|
+
} catch {
|
|
6957
|
+
return void 0;
|
|
6958
|
+
}
|
|
6959
|
+
}
|
|
6960
|
+
function shouldActivate(fm, touchedFiles) {
|
|
6961
|
+
if (fm.alwaysApply === true) return true;
|
|
6962
|
+
if (fm.globs === void 0 || fm.globs.length === 0) return false;
|
|
6963
|
+
return anyGlobMatches(fm.globs, touchedFiles);
|
|
6964
|
+
}
|
|
6965
|
+
var McdFrontmatterSchema;
|
|
6929
6966
|
var init_context_mdc_parser = __esm({
|
|
6930
6967
|
"src/internal/runtime/context/context-mdc-parser.ts"() {
|
|
6968
|
+
init_context_glob();
|
|
6969
|
+
init_context_yaml_lite();
|
|
6931
6970
|
McdFrontmatterSchema = z.object({
|
|
6932
6971
|
description: z.string().optional(),
|
|
6933
6972
|
globs: z.array(z.string()).optional(),
|
|
6934
6973
|
alwaysApply: z.boolean().optional()
|
|
6935
6974
|
});
|
|
6936
|
-
|
|
6975
|
+
}
|
|
6976
|
+
});
|
|
6977
|
+
function parseRules(content) {
|
|
6978
|
+
const { yaml, body } = splitFrontmatter3(content);
|
|
6979
|
+
if (yaml === void 0) {
|
|
6980
|
+
return { frontmatter: { alwaysApply: true }, body: content };
|
|
6981
|
+
}
|
|
6982
|
+
try {
|
|
6983
|
+
const parsed = parseSimpleYaml2(yaml);
|
|
6984
|
+
const validated = RulesFrontmatterSchema.safeParse(parsed);
|
|
6985
|
+
if (!validated.success) return void 0;
|
|
6986
|
+
return { frontmatter: validated.data, body };
|
|
6987
|
+
} catch {
|
|
6988
|
+
return void 0;
|
|
6989
|
+
}
|
|
6990
|
+
}
|
|
6991
|
+
function shouldActivateRule(fm, inScopePaths) {
|
|
6992
|
+
if (fm.enabled === false) return false;
|
|
6993
|
+
if (fm.alwaysApply === true) return true;
|
|
6994
|
+
const patterns = [...fm.paths ?? [], ...fm.globs ?? []];
|
|
6995
|
+
if (patterns.length === 0) return false;
|
|
6996
|
+
return anyGlobMatches(patterns, inScopePaths);
|
|
6997
|
+
}
|
|
6998
|
+
var RulesFrontmatterSchema;
|
|
6999
|
+
var init_context_rules_frontmatter = __esm({
|
|
7000
|
+
"src/internal/runtime/context/context-rules-frontmatter.ts"() {
|
|
7001
|
+
init_context_glob();
|
|
7002
|
+
init_context_yaml_lite();
|
|
7003
|
+
RulesFrontmatterSchema = z.object({
|
|
7004
|
+
description: z.string().optional(),
|
|
7005
|
+
paths: z.array(z.string()).optional(),
|
|
7006
|
+
globs: z.array(z.string()).optional(),
|
|
7007
|
+
alwaysApply: z.boolean().optional(),
|
|
7008
|
+
enabled: z.boolean().optional()
|
|
7009
|
+
});
|
|
6937
7010
|
}
|
|
6938
7011
|
});
|
|
6939
7012
|
async function runDiscovery(opts) {
|
|
@@ -6969,6 +7042,9 @@ async function loadOneSource(spec, path, opts, gitRoot) {
|
|
|
6969
7042
|
if (spec.parser === "mdc") {
|
|
6970
7043
|
return loadMdcSource(spec, path, id, opts);
|
|
6971
7044
|
}
|
|
7045
|
+
if (spec.parser === "rules-frontmatter") {
|
|
7046
|
+
return loadRulesSource(spec, path, id, opts);
|
|
7047
|
+
}
|
|
6972
7048
|
if (spec.parser === "frontmatter-zod") {
|
|
6973
7049
|
return void 0;
|
|
6974
7050
|
}
|
|
@@ -6992,6 +7068,24 @@ async function loadMdcSource(spec, path, id, opts) {
|
|
|
6992
7068
|
truncated: false
|
|
6993
7069
|
};
|
|
6994
7070
|
}
|
|
7071
|
+
async function loadRulesSource(spec, path, id, opts) {
|
|
7072
|
+
let raw;
|
|
7073
|
+
try {
|
|
7074
|
+
raw = await readFile(path, "utf8");
|
|
7075
|
+
} catch {
|
|
7076
|
+
return void 0;
|
|
7077
|
+
}
|
|
7078
|
+
const parsed = parseRules(raw);
|
|
7079
|
+
if (parsed === void 0) return void 0;
|
|
7080
|
+
if (!shouldActivateRule(parsed.frontmatter, opts.touchedFiles ?? [])) return void 0;
|
|
7081
|
+
return {
|
|
7082
|
+
id,
|
|
7083
|
+
source: path,
|
|
7084
|
+
content: parsed.body,
|
|
7085
|
+
priority: spec.priority,
|
|
7086
|
+
truncated: false
|
|
7087
|
+
};
|
|
7088
|
+
}
|
|
6995
7089
|
async function loadPlainMarkdownSource(spec, path, id, opts) {
|
|
6996
7090
|
const loaded = await loadPlainMarkdown(path, { maxBytesPerFile: opts.maxBytesPerFile });
|
|
6997
7091
|
if (loaded === void 0) return void 0;
|
|
@@ -7017,6 +7111,7 @@ var init_context_discovery_runner = __esm({
|
|
|
7017
7111
|
init_context_import_resolver();
|
|
7018
7112
|
init_context_loaders();
|
|
7019
7113
|
init_context_mdc_parser();
|
|
7114
|
+
init_context_rules_frontmatter();
|
|
7020
7115
|
}
|
|
7021
7116
|
});
|
|
7022
7117
|
var ContextSourceFrontmatterSchema;
|
|
@@ -7152,6 +7247,10 @@ function matchesGlob(pattern, path) {
|
|
|
7152
7247
|
function tokenizeContent(content) {
|
|
7153
7248
|
return content.split(/\s+/).filter((token) => token.length > 0);
|
|
7154
7249
|
}
|
|
7250
|
+
function sameScope(a, b) {
|
|
7251
|
+
if (a.length !== b.length) return false;
|
|
7252
|
+
return a.every((v, i) => v === b[i]);
|
|
7253
|
+
}
|
|
7155
7254
|
var FileContextManager;
|
|
7156
7255
|
var init_context_manager = __esm({
|
|
7157
7256
|
"src/internal/runtime/context/context-manager.ts"() {
|
|
@@ -7172,6 +7271,13 @@ var init_context_manager = __esm({
|
|
|
7172
7271
|
settings;
|
|
7173
7272
|
settingSourcesIncludeProject;
|
|
7174
7273
|
state;
|
|
7274
|
+
/**
|
|
7275
|
+
* The in-scope file set used by the most recent `refresh`. Tracked so
|
|
7276
|
+
* `applyScope` only touches state when the scope actually changes — a
|
|
7277
|
+
* caller that never scopes (the common case) keeps the create-time
|
|
7278
|
+
* snapshot untouched, at zero per-send cost.
|
|
7279
|
+
*/
|
|
7280
|
+
lastScope = [];
|
|
7175
7281
|
async initialize() {
|
|
7176
7282
|
if (!this.settingSourcesIncludeProject && this.settings.manager !== "file") {
|
|
7177
7283
|
this.state = { config: { sources: [] }, loadedSources: [] };
|
|
@@ -7179,14 +7285,31 @@ var init_context_manager = __esm({
|
|
|
7179
7285
|
}
|
|
7180
7286
|
await this.refresh();
|
|
7181
7287
|
}
|
|
7182
|
-
|
|
7288
|
+
/**
|
|
7289
|
+
* Re-run discovery for a specific per-send in-scope file set (T3). Path-scoped
|
|
7290
|
+
* rules (`.theokit/rules/*.md`, `.cursor/rules/*.mdc` globs) activate iff a
|
|
7291
|
+
* pattern matches one of `contextPaths`. Idempotent: unchanged scope is a
|
|
7292
|
+
* no-op, and `undefined` scope while never previously scoped never touches
|
|
7293
|
+
* state (preserves the create-time snapshot for non-users).
|
|
7294
|
+
*/
|
|
7295
|
+
async applyScope(contextPaths) {
|
|
7296
|
+
const scope = contextPaths ?? [];
|
|
7297
|
+
if (scope.length === 0 && this.lastScope.length === 0) return;
|
|
7298
|
+
if (sameScope(scope, this.lastScope)) return;
|
|
7299
|
+
await this.refresh({ touchedFiles: scope });
|
|
7300
|
+
}
|
|
7301
|
+
async refresh(opts) {
|
|
7302
|
+
const touchedFiles = opts?.touchedFiles ?? [];
|
|
7303
|
+
this.lastScope = [...touchedFiles];
|
|
7183
7304
|
const config = await loadContextConfig(this.cwd);
|
|
7184
7305
|
const legacy = await loadSources(config, this.cwd);
|
|
7185
7306
|
const maxBytesPerFile = this.settings.maxBytesPerFile ?? DEFAULT_MAX_BYTES_PER_FILE;
|
|
7186
7307
|
const maxBytesTotal = this.settings.maxBytesTotal ?? DEFAULT_MAX_BYTES_TOTAL;
|
|
7187
7308
|
const discovered = await runDiscovery({
|
|
7188
7309
|
cwd: this.cwd,
|
|
7189
|
-
maxBytesPerFile
|
|
7310
|
+
maxBytesPerFile,
|
|
7311
|
+
touchedFiles
|
|
7312
|
+
});
|
|
7190
7313
|
const legacyAsAggregator = legacy.map((src) => ({
|
|
7191
7314
|
id: src.name,
|
|
7192
7315
|
source: src.path,
|
|
@@ -9379,7 +9502,10 @@ async function runAgentLoop(inputs) {
|
|
|
9379
9502
|
}
|
|
9380
9503
|
budget.consume();
|
|
9381
9504
|
inputs.budgetTracker?.nextIteration?.();
|
|
9382
|
-
if (inputs.signal?.aborted === true)
|
|
9505
|
+
if (inputs.signal?.aborted === true) {
|
|
9506
|
+
ctx.finalStatus = "cancelled";
|
|
9507
|
+
break;
|
|
9508
|
+
}
|
|
9383
9509
|
}
|
|
9384
9510
|
if (lastTurnDecision === "continue" && budget.shouldContinue() === false) {
|
|
9385
9511
|
ctx.stoppedAtIterationLimit = true;
|
|
@@ -9564,15 +9690,15 @@ async function guardAndTransformToolResults(inputs, raw, ctx) {
|
|
|
9564
9690
|
}
|
|
9565
9691
|
async function continueOrTerminate(inputs, ctx, llmOutput) {
|
|
9566
9692
|
if (llmOutput.errored) return "error";
|
|
9567
|
-
|
|
9568
|
-
|
|
9693
|
+
const tCtx = { agentId: inputs.agentId, runId: inputs.runId };
|
|
9694
|
+
const text = llmOutput.text.length > 0 ? await transformLlmOutputText(inputs, llmOutput.text, tCtx) : llmOutput.text;
|
|
9695
|
+
if (text.length > 0) {
|
|
9696
|
+
await emitAssistantTextStep(inputs, ctx, text);
|
|
9569
9697
|
}
|
|
9570
9698
|
if (llmOutput.stopReason !== "tool_use" || llmOutput.toolCalls.length === 0) {
|
|
9571
9699
|
return finishOrReflect(inputs, ctx, llmOutput);
|
|
9572
9700
|
}
|
|
9573
|
-
|
|
9574
|
-
const outText = await transformLlmOutputText(inputs, llmOutput.text, tCtx);
|
|
9575
|
-
ctx.messages.push(buildAssistantTurn(outText, llmOutput.toolCalls));
|
|
9701
|
+
ctx.messages.push(buildAssistantTurn(text, llmOutput.toolCalls));
|
|
9576
9702
|
const rawResults = await dispatchTools(
|
|
9577
9703
|
// SE12 — forward a read-only text projection of the transcript-so-far to tool
|
|
9578
9704
|
// handlers via `ctx.messages` (consumed by defineSubAgent's messageFilter).
|
|
@@ -12896,7 +13022,12 @@ var init_client = __esm({
|
|
|
12896
13022
|
code: "mcp_http_error"
|
|
12897
13023
|
});
|
|
12898
13024
|
}
|
|
12899
|
-
|
|
13025
|
+
try {
|
|
13026
|
+
return await response.json();
|
|
13027
|
+
} catch (cause) {
|
|
13028
|
+
if (isAbortLike(cause)) throw mcpTimeoutError(this.name, timeoutMs);
|
|
13029
|
+
throw cause;
|
|
13030
|
+
}
|
|
12900
13031
|
}
|
|
12901
13032
|
};
|
|
12902
13033
|
}
|
|
@@ -13136,9 +13267,11 @@ function declarativeSubagentTools(agentOptions, parentTools) {
|
|
|
13136
13267
|
return subAgentToolsFromDefinitions(agents2, parentTools);
|
|
13137
13268
|
}
|
|
13138
13269
|
function bindParentCredentials(tools, agentOptions) {
|
|
13270
|
+
const parentPlugins = Array.isArray(agentOptions.plugins) ? agentOptions.plugins : void 0;
|
|
13139
13271
|
const credentials = {
|
|
13140
13272
|
...agentOptions.apiKey !== void 0 ? { apiKey: agentOptions.apiKey } : {},
|
|
13141
|
-
...typeof agentOptions.model === "object" ? { model: agentOptions.model } : {}
|
|
13273
|
+
...typeof agentOptions.model === "object" ? { model: agentOptions.model } : {},
|
|
13274
|
+
...parentPlugins !== void 0 ? { plugins: parentPlugins } : {}
|
|
13142
13275
|
};
|
|
13143
13276
|
for (const tool of tools) inheritSubAgentCredentials(tool, credentials);
|
|
13144
13277
|
}
|
|
@@ -15663,10 +15796,11 @@ var init_local_agent_memory = __esm({
|
|
|
15663
15796
|
}
|
|
15664
15797
|
buildTelemetryRecallArgs(telemetry) {
|
|
15665
15798
|
const userId = typeof this.options.memoryContext?.userId === "string" ? this.options.memoryContext.userId : void 0;
|
|
15799
|
+
const tenantId = typeof this.options.memoryContext?.tenantId === "string" ? this.options.memoryContext.tenantId : void 0;
|
|
15666
15800
|
return {
|
|
15667
15801
|
...telemetry !== void 0 ? { telemetry } : {},
|
|
15668
15802
|
...userId !== void 0 ? { userId } : {},
|
|
15669
|
-
namespace: "default",
|
|
15803
|
+
namespace: tenantId ?? "default",
|
|
15670
15804
|
scope: "session"
|
|
15671
15805
|
};
|
|
15672
15806
|
}
|
|
@@ -16963,7 +17097,8 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
16963
17097
|
userText,
|
|
16964
17098
|
baseSystemPrompt,
|
|
16965
17099
|
memoryFacts,
|
|
16966
|
-
activeMemorySummary
|
|
17100
|
+
activeMemorySummary,
|
|
17101
|
+
options.contextPaths
|
|
16967
17102
|
);
|
|
16968
17103
|
const projectedSystemPrompt = await projectCurrentObjective(
|
|
16969
17104
|
inputs.storageHandle,
|
|
@@ -17851,7 +17986,7 @@ var init_local_agent = __esm({
|
|
|
17851
17986
|
runPreHook: (ut) => this.runPreHook(ut),
|
|
17852
17987
|
// biome-ignore format: G8 budget — callbacks wire to private methods.
|
|
17853
17988
|
resolveSystemPromptForSend: (ut, o, mf) => this.resolveSystemPrompt(ut, o, mf),
|
|
17854
|
-
assembleSystemPromptForSend: (ut, bp, mf, ams) => assembleSystemPromptForSend(this.assemblyInputs(), ut, bp, mf, ams),
|
|
17989
|
+
assembleSystemPromptForSend: (ut, bp, mf, ams, cp) => assembleSystemPromptForSend(this.assemblyInputs(), ut, bp, mf, ams, cp),
|
|
17855
17990
|
dispatchRun: (msg, o, sp, mf, pm, mt, mp) => this.dispatchRun(msg, o, sp, mf, pm, mt, mp)
|
|
17856
17991
|
},
|
|
17857
17992
|
message,
|
|
@@ -18999,15 +19134,19 @@ async function collectChildToolResults(run) {
|
|
|
18999
19134
|
${lines.join("\n")}
|
|
19000
19135
|
</subagent-tool-results>`;
|
|
19001
19136
|
}
|
|
19002
|
-
|
|
19003
|
-
const { Agent: Agent2 } = await Promise.resolve().then(() => (init_agent(), agent_exports));
|
|
19137
|
+
function buildChildCreateOptions(spec, inherited) {
|
|
19004
19138
|
const model = spec.model ? { id: spec.model } : inherited?.model;
|
|
19005
|
-
|
|
19139
|
+
return {
|
|
19006
19140
|
...inherited?.apiKey !== void 0 ? { apiKey: inherited.apiKey } : {},
|
|
19007
19141
|
...model !== void 0 ? { model } : {},
|
|
19142
|
+
...inherited?.plugins !== void 0 ? { plugins: inherited.plugins } : {},
|
|
19008
19143
|
systemPrompt: spec.instructions,
|
|
19009
19144
|
tools: spec.tools ?? []
|
|
19010
|
-
}
|
|
19145
|
+
};
|
|
19146
|
+
}
|
|
19147
|
+
async function runChildAgent(spec, input, signal, maxSteps, inherited) {
|
|
19148
|
+
const { Agent: Agent2 } = await Promise.resolve().then(() => (init_agent(), agent_exports));
|
|
19149
|
+
const agent = await Agent2.create(buildChildCreateOptions(spec, inherited));
|
|
19011
19150
|
try {
|
|
19012
19151
|
const sendOptions = {
|
|
19013
19152
|
...signal !== void 0 ? { signal } : {},
|