@theokit/sdk 4.41.0 → 4.42.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 +55 -0
- package/dist/{agent-6C2ODKFU.cjs → agent-HGDXQEQQ.cjs} +8 -7
- package/dist/{agent-6C2ODKFU.cjs.map → agent-HGDXQEQQ.cjs.map} +1 -1
- package/dist/{agent-35MGOZVH.js → agent-WUVYXIFX.js} +7 -6
- package/dist/{agent-35MGOZVH.js.map → agent-WUVYXIFX.js.map} +1 -1
- package/dist/chunk-22EMHGBO.cjs +351 -0
- package/dist/chunk-22EMHGBO.cjs.map +1 -0
- package/dist/{chunk-Y33IGXCJ.cjs → chunk-EYEZDADP.cjs} +5 -5
- package/dist/{chunk-Y33IGXCJ.cjs.map → chunk-EYEZDADP.cjs.map} +1 -1
- package/dist/{chunk-ZO2L5U6F.cjs → chunk-FAUKVJCC.cjs} +3 -3
- package/dist/{chunk-ZO2L5U6F.cjs.map → chunk-FAUKVJCC.cjs.map} +1 -1
- package/dist/{chunk-DCKIS53K.js → chunk-KO5V6L3E.js} +9 -319
- package/dist/chunk-KO5V6L3E.js.map +1 -0
- package/dist/{chunk-BHWHE453.js → chunk-MPD5EGJ6.js} +3 -3
- package/dist/{chunk-BHWHE453.js.map → chunk-MPD5EGJ6.js.map} +1 -1
- package/dist/chunk-Q2PPSHBS.js +344 -0
- package/dist/chunk-Q2PPSHBS.js.map +1 -0
- package/dist/{chunk-FMIKUGF2.cjs → chunk-QFFNMJAS.cjs} +5 -5
- package/dist/{chunk-FMIKUGF2.cjs.map → chunk-QFFNMJAS.cjs.map} +1 -1
- package/dist/{chunk-UTYCG4RB.js → chunk-TDDRPFO3.js} +3 -3
- package/dist/{chunk-UTYCG4RB.js.map → chunk-TDDRPFO3.js.map} +1 -1
- package/dist/{chunk-IMX5YODO.js → chunk-UJ7HK7BX.js} +3 -3
- package/dist/{chunk-IMX5YODO.js.map → chunk-UJ7HK7BX.js.map} +1 -1
- package/dist/{chunk-F5DSDDBY.cjs → chunk-YHQ3DG24.cjs} +48 -358
- package/dist/chunk-YHQ3DG24.cjs.map +1 -0
- package/dist/{compact-session-65XCKO6H.js → compact-session-GF2CBKXB.js} +4 -4
- package/dist/{compact-session-65XCKO6H.js.map → compact-session-GF2CBKXB.js.map} +1 -1
- package/dist/{compact-session-OU6SRPVJ.cjs → compact-session-UUCBTBCZ.cjs} +12 -12
- package/dist/{compact-session-OU6SRPVJ.cjs.map → compact-session-UUCBTBCZ.cjs.map} +1 -1
- package/dist/context/index.cjs +35 -0
- package/dist/context/index.cjs.map +1 -0
- package/dist/context/index.d.cts +78 -0
- package/dist/context/index.d.ts +78 -0
- package/dist/context/index.js +18 -0
- package/dist/context/index.js.map +1 -0
- package/dist/cron.cjs +7 -6
- package/dist/cron.js +6 -5
- package/dist/eval.cjs +6 -5
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +5 -4
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +34 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -8
- package/dist/index.js.map +1 -1
- package/dist/{inject-session-DDC36KKP.cjs → inject-session-I3HK3AHB.cjs} +4 -4
- package/dist/{inject-session-DDC36KKP.cjs.map → inject-session-I3HK3AHB.cjs.map} +1 -1
- package/dist/{inject-session-UBM4KVSV.js → inject-session-NR64GB3T.js} +3 -3
- package/dist/{inject-session-UBM4KVSV.js.map → inject-session-NR64GB3T.js.map} +1 -1
- package/dist/internal/runtime/context/context-discovery-runner.d.ts +9 -0
- package/dist/internal/runtime/context/context-import-resolver.d.ts +17 -0
- package/dist/server/auth/index.d.cts +11 -207
- package/dist/server/auth/index.d.ts +11 -207
- package/dist/server/errors-envelope.d.cts +6 -12
- package/dist/server/errors-envelope.d.ts +6 -12
- package/package.json +11 -1
- package/dist/chunk-DCKIS53K.js.map +0 -1
- package/dist/chunk-F5DSDDBY.cjs.map +0 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
|
+
import { enqueueSessionWrite, hydrateSession, persistTurnToTranscript, flushSessionWrites, appendSessionMessage, getSessionMessages, discardSession, clearSession } from './chunk-UJ7HK7BX.js';
|
|
1
2
|
import { extractCodePlugins } from './chunk-2SFBB54R.js';
|
|
2
3
|
import { submit, emitRunEvent } from './chunk-GNMPCZNN.js';
|
|
3
|
-
import { enqueueSessionWrite, hydrateSession, persistTurnToTranscript, flushSessionWrites, appendSessionMessage, getSessionMessages, discardSession, clearSession } from './chunk-IMX5YODO.js';
|
|
4
4
|
import { FsSessionStore } from './chunk-PYM5OUL4.js';
|
|
5
|
-
import { discoverProviderPlugins, getConfiguredBaseUrl, httpRequest, isFixtureApiKey, shouldUseRealLocalRuntime, CircuitBreaker, buildDefaultSummarizer, parseSseStream, resolveProviderChain, inferProviderFromApiKey, detectPrimaryProvider, tryFirstEvent, relayStream, renderToolResultContentText } from './chunk-
|
|
5
|
+
import { discoverProviderPlugins, getConfiguredBaseUrl, httpRequest, isFixtureApiKey, shouldUseRealLocalRuntime, CircuitBreaker, buildDefaultSummarizer, parseSseStream, resolveProviderChain, inferProviderFromApiKey, detectPrimaryProvider, tryFirstEvent, relayStream, renderToolResultContentText } from './chunk-TDDRPFO3.js';
|
|
6
6
|
import { IndexManager, writeSessionSummary, memoryDir, appendFact, readFacts, legacyMemoryJsonPath, memoryMdPath, appendFactToMarkdown } from './chunk-RJBHWM6D.js';
|
|
7
7
|
import { loadHookConfig, warnOnce, currentPersonalityContext, warnPersonalitySwitchInsideFork } from './chunk-J5RW43IR.js';
|
|
8
8
|
import { resolveChildEnv } from './chunk-AM2CNBKE.js';
|
|
9
|
+
import { DEFAULT_MAX_BYTES_PER_FILE, runDiscovery, truncateWithMarker } from './chunk-Q2PPSHBS.js';
|
|
9
10
|
import { readVersionedJson, getTheokitHome, writeVersionedJson } from './chunk-ZS6SLELQ.js';
|
|
10
11
|
import { createOpenAiCompatibleRuntime } from './chunk-LLE7HPRI.js';
|
|
11
12
|
import { sanitizeToolInput } from './chunk-U54XCYG3.js';
|
|
12
13
|
import { withInheritedSubAgentCredentials, subAgentToolsFromDefinitions } from './chunk-RP5HQVLD.js';
|
|
13
14
|
import { setAgentFacade } from './chunk-6X6ID4MO.js';
|
|
14
|
-
import { findGitRoot, DEFAULT_DISCOVERY_SPECS, walkUpForFile, walkUpForGlob } from './chunk-UJ7IQJAG.js';
|
|
15
15
|
import { withToolWhitelist, checkToolWhitelist } from './chunk-7AD3ZTZL.js';
|
|
16
16
|
import { mapWithConcurrency } from './chunk-AZ6FKDQR.js';
|
|
17
17
|
import { defaultBaseDir, expandTilde } from './chunk-AF4BBKIF.js';
|
|
@@ -30,7 +30,7 @@ import { AgentRunError, coerceToKnownAgentRunErrorCode, UnknownAgentError, Confi
|
|
|
30
30
|
import { diag, redactSecrets } from './chunk-PBML2FHN.js';
|
|
31
31
|
import { stat, mkdir, readFile, readdir, access, unlink } from 'fs/promises';
|
|
32
32
|
import { randomUUID, createHash } from 'crypto';
|
|
33
|
-
import { join, dirname, resolve,
|
|
33
|
+
import { join, dirname, resolve, isAbsolute } from 'path';
|
|
34
34
|
import { spawn } from 'child_process';
|
|
35
35
|
import { z } from 'zod';
|
|
36
36
|
import { createRequire } from 'module';
|
|
@@ -3868,52 +3868,6 @@ function splitFrontmatter(raw, source, errorCodePrefix) {
|
|
|
3868
3868
|
body: raw.slice(match[0].length)
|
|
3869
3869
|
};
|
|
3870
3870
|
}
|
|
3871
|
-
var HEAD_RATIO = 0.7;
|
|
3872
|
-
var TAIL_RATIO = 0.2;
|
|
3873
|
-
var MARKER = "\n\n\u2026[truncated by theokit]\n\n";
|
|
3874
|
-
var DEFAULT_MAX_BYTES_PER_FILE = 4e4;
|
|
3875
|
-
function truncateWithMarker(content, max) {
|
|
3876
|
-
if (content.length <= max) {
|
|
3877
|
-
return { truncated: false, finalContent: content };
|
|
3878
|
-
}
|
|
3879
|
-
if (max <= MARKER.length) {
|
|
3880
|
-
return { truncated: true, finalContent: content.slice(0, max) };
|
|
3881
|
-
}
|
|
3882
|
-
const budget = max - MARKER.length;
|
|
3883
|
-
const headBytes = Math.floor(budget * (HEAD_RATIO / (HEAD_RATIO + TAIL_RATIO)));
|
|
3884
|
-
const tailBytes = budget - headBytes;
|
|
3885
|
-
return {
|
|
3886
|
-
truncated: true,
|
|
3887
|
-
finalContent: content.slice(0, headBytes) + MARKER + content.slice(-tailBytes)
|
|
3888
|
-
};
|
|
3889
|
-
}
|
|
3890
|
-
async function loadPlainMarkdown(absPath, opts = {}) {
|
|
3891
|
-
const max = opts.maxBytesPerFile ?? DEFAULT_MAX_BYTES_PER_FILE;
|
|
3892
|
-
let content;
|
|
3893
|
-
try {
|
|
3894
|
-
content = await readFile(absPath, "utf8");
|
|
3895
|
-
} catch {
|
|
3896
|
-
return void 0;
|
|
3897
|
-
}
|
|
3898
|
-
const { truncated, finalContent } = truncateWithMarker(content, max);
|
|
3899
|
-
if (truncated) {
|
|
3900
|
-
emitTruncationCounter(absPath);
|
|
3901
|
-
}
|
|
3902
|
-
return {
|
|
3903
|
-
source: absPath,
|
|
3904
|
-
content: finalContent,
|
|
3905
|
-
originalBytes: content.length,
|
|
3906
|
-
truncated
|
|
3907
|
-
};
|
|
3908
|
-
}
|
|
3909
|
-
function emitTruncationCounter(source) {
|
|
3910
|
-
const tracer = globalThis.__theokit_tracer;
|
|
3911
|
-
if (tracer?.inc === void 0) return;
|
|
3912
|
-
try {
|
|
3913
|
-
tracer.inc("context_files_truncated", { file: source });
|
|
3914
|
-
} catch {
|
|
3915
|
-
}
|
|
3916
|
-
}
|
|
3917
3871
|
|
|
3918
3872
|
// src/internal/runtime/context/context-aggregator.ts
|
|
3919
3873
|
var DEFAULT_MAX_BYTES_TOTAL = 12e4;
|
|
@@ -3953,271 +3907,6 @@ function emitTotalDropCounter(droppedSources) {
|
|
|
3953
3907
|
} catch {
|
|
3954
3908
|
}
|
|
3955
3909
|
}
|
|
3956
|
-
var IMPORT_RE = /^@(\S+)\s*$/gm;
|
|
3957
|
-
var MAX_HOPS = 5;
|
|
3958
|
-
async function resolveImports(content, basePath, opts) {
|
|
3959
|
-
if (opts.depth >= MAX_HOPS) {
|
|
3960
|
-
return `${content}
|
|
3961
|
-
|
|
3962
|
-
\u2026[@import depth limit ${MAX_HOPS} reached]
|
|
3963
|
-
|
|
3964
|
-
`;
|
|
3965
|
-
}
|
|
3966
|
-
const baseDir = dirname(basePath);
|
|
3967
|
-
return replaceAsync(content, IMPORT_RE, async (raw) => {
|
|
3968
|
-
const absolute = resolveImportPath(raw, baseDir);
|
|
3969
|
-
if (opts.visited.has(absolute)) {
|
|
3970
|
-
return `[@import cycle detected: ${raw}]`;
|
|
3971
|
-
}
|
|
3972
|
-
opts.visited.add(absolute);
|
|
3973
|
-
const loaded = await loadPlainMarkdown(absolute, { maxBytesPerFile: opts.maxBytesPerFile });
|
|
3974
|
-
if (loaded === void 0) {
|
|
3975
|
-
return `[@import not found: ${raw}]`;
|
|
3976
|
-
}
|
|
3977
|
-
return resolveImports(loaded.content, absolute, {
|
|
3978
|
-
visited: opts.visited,
|
|
3979
|
-
depth: opts.depth + 1,
|
|
3980
|
-
maxBytesPerFile: opts.maxBytesPerFile
|
|
3981
|
-
});
|
|
3982
|
-
});
|
|
3983
|
-
}
|
|
3984
|
-
function resolveImportPath(raw, baseDir) {
|
|
3985
|
-
if (raw.startsWith("~/")) {
|
|
3986
|
-
return resolve(join(homedir(), raw.slice(2)));
|
|
3987
|
-
}
|
|
3988
|
-
if (isAbsolute(raw)) {
|
|
3989
|
-
return resolve(raw);
|
|
3990
|
-
}
|
|
3991
|
-
return resolve(join(baseDir, raw));
|
|
3992
|
-
}
|
|
3993
|
-
async function replaceAsync(content, re, replacer) {
|
|
3994
|
-
const matches = [];
|
|
3995
|
-
const localRe = new RegExp(re.source, re.flags);
|
|
3996
|
-
let m;
|
|
3997
|
-
while ((m = localRe.exec(content)) !== null) {
|
|
3998
|
-
matches.push({ match: m[0], raw: m[1] ?? "", index: m.index });
|
|
3999
|
-
if (m.index === localRe.lastIndex) localRe.lastIndex += 1;
|
|
4000
|
-
}
|
|
4001
|
-
if (matches.length === 0) return content;
|
|
4002
|
-
let result = "";
|
|
4003
|
-
let cursor = 0;
|
|
4004
|
-
for (const entry of matches) {
|
|
4005
|
-
result += content.slice(cursor, entry.index);
|
|
4006
|
-
result += await replacer(entry.raw);
|
|
4007
|
-
cursor = entry.index + entry.match.length;
|
|
4008
|
-
}
|
|
4009
|
-
result += content.slice(cursor);
|
|
4010
|
-
return result;
|
|
4011
|
-
}
|
|
4012
|
-
|
|
4013
|
-
// src/internal/runtime/context/context-glob.ts
|
|
4014
|
-
function globToRegex(glob) {
|
|
4015
|
-
const compiled = glob.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*\//g, "::GLOBSTAR_SLASH::").replace(/\*\*/g, "::GLOBSTAR::").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(/::GLOBSTAR_SLASH::/g, "(?:.*/)?").replace(/::GLOBSTAR::/g, ".*");
|
|
4016
|
-
return new RegExp(`^${compiled}$`);
|
|
4017
|
-
}
|
|
4018
|
-
function anyGlobMatches(patterns, paths) {
|
|
4019
|
-
if (patterns.length === 0 || paths.length === 0) return false;
|
|
4020
|
-
const res = patterns.map(globToRegex);
|
|
4021
|
-
return paths.some((p) => res.some((re) => re.test(p)));
|
|
4022
|
-
}
|
|
4023
|
-
|
|
4024
|
-
// src/internal/runtime/context/context-yaml-lite.ts
|
|
4025
|
-
var FRONTMATTER_RE = /^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/;
|
|
4026
|
-
function splitFrontmatter2(content) {
|
|
4027
|
-
const m = FRONTMATTER_RE.exec(content);
|
|
4028
|
-
if (m === null) return { yaml: void 0, body: content };
|
|
4029
|
-
return { yaml: m[1] ?? "", body: m[2] ?? "" };
|
|
4030
|
-
}
|
|
4031
|
-
function parseSimpleYaml2(yaml) {
|
|
4032
|
-
const out = {};
|
|
4033
|
-
const lines = yaml.split(/\r?\n/);
|
|
4034
|
-
let i = 0;
|
|
4035
|
-
while (i < lines.length) {
|
|
4036
|
-
const line = lines[i];
|
|
4037
|
-
i += 1;
|
|
4038
|
-
if (line === void 0) continue;
|
|
4039
|
-
const trimmed = line.trim();
|
|
4040
|
-
if (trimmed === "" || trimmed.startsWith("#")) continue;
|
|
4041
|
-
const colon = trimmed.indexOf(":");
|
|
4042
|
-
if (colon === -1) throw new Error(`Invalid YAML line: ${trimmed}`);
|
|
4043
|
-
const key = trimmed.slice(0, colon).trim();
|
|
4044
|
-
const rest = trimmed.slice(colon + 1).trim();
|
|
4045
|
-
if (rest === "") {
|
|
4046
|
-
const items = [];
|
|
4047
|
-
while (i < lines.length) {
|
|
4048
|
-
const next = lines[i];
|
|
4049
|
-
if (next === void 0) break;
|
|
4050
|
-
const nextTrim = next.trim();
|
|
4051
|
-
if (nextTrim.startsWith("- ")) {
|
|
4052
|
-
items.push(parseScalar(nextTrim.slice(2).trim()));
|
|
4053
|
-
i += 1;
|
|
4054
|
-
} else if (nextTrim === "") {
|
|
4055
|
-
i += 1;
|
|
4056
|
-
} else {
|
|
4057
|
-
break;
|
|
4058
|
-
}
|
|
4059
|
-
}
|
|
4060
|
-
out[key] = items;
|
|
4061
|
-
} else if (rest.startsWith("[") && rest.endsWith("]")) {
|
|
4062
|
-
const inner = rest.slice(1, -1).trim();
|
|
4063
|
-
out[key] = inner === "" ? [] : inner.split(",").map((s) => parseScalar(s.trim().replace(/^["']|["']$/g, "")));
|
|
4064
|
-
} else {
|
|
4065
|
-
out[key] = parseScalar(rest);
|
|
4066
|
-
}
|
|
4067
|
-
}
|
|
4068
|
-
return out;
|
|
4069
|
-
}
|
|
4070
|
-
function parseScalar(s) {
|
|
4071
|
-
if (s === "true") return true;
|
|
4072
|
-
if (s === "false") return false;
|
|
4073
|
-
if (/^-?\d+$/.test(s)) return parseInt(s, 10);
|
|
4074
|
-
return s.replace(/^["']|["']$/g, "");
|
|
4075
|
-
}
|
|
4076
|
-
|
|
4077
|
-
// src/internal/runtime/context/context-mdc-parser.ts
|
|
4078
|
-
var McdFrontmatterSchema = z.object({
|
|
4079
|
-
description: z.string().optional(),
|
|
4080
|
-
globs: z.array(z.string()).optional(),
|
|
4081
|
-
alwaysApply: z.boolean().optional()
|
|
4082
|
-
});
|
|
4083
|
-
function parseMdc(content) {
|
|
4084
|
-
const { yaml, body } = splitFrontmatter2(content);
|
|
4085
|
-
if (yaml === void 0) {
|
|
4086
|
-
return { frontmatter: { alwaysApply: true }, body: content };
|
|
4087
|
-
}
|
|
4088
|
-
try {
|
|
4089
|
-
const parsed = parseSimpleYaml2(yaml);
|
|
4090
|
-
const validated = McdFrontmatterSchema.safeParse(parsed);
|
|
4091
|
-
if (!validated.success) return void 0;
|
|
4092
|
-
return { frontmatter: validated.data, body };
|
|
4093
|
-
} catch {
|
|
4094
|
-
return void 0;
|
|
4095
|
-
}
|
|
4096
|
-
}
|
|
4097
|
-
function shouldActivate(fm, touchedFiles) {
|
|
4098
|
-
if (fm.alwaysApply === true) return true;
|
|
4099
|
-
if (fm.globs === void 0 || fm.globs.length === 0) return false;
|
|
4100
|
-
return anyGlobMatches(fm.globs, touchedFiles);
|
|
4101
|
-
}
|
|
4102
|
-
var RulesFrontmatterSchema = z.object({
|
|
4103
|
-
description: z.string().optional(),
|
|
4104
|
-
paths: z.array(z.string()).optional(),
|
|
4105
|
-
globs: z.array(z.string()).optional(),
|
|
4106
|
-
alwaysApply: z.boolean().optional(),
|
|
4107
|
-
enabled: z.boolean().optional()
|
|
4108
|
-
});
|
|
4109
|
-
function parseRules(content) {
|
|
4110
|
-
const { yaml, body } = splitFrontmatter2(content);
|
|
4111
|
-
if (yaml === void 0) {
|
|
4112
|
-
return { frontmatter: { alwaysApply: true }, body: content };
|
|
4113
|
-
}
|
|
4114
|
-
try {
|
|
4115
|
-
const parsed = parseSimpleYaml2(yaml);
|
|
4116
|
-
const validated = RulesFrontmatterSchema.safeParse(parsed);
|
|
4117
|
-
if (!validated.success) return void 0;
|
|
4118
|
-
return { frontmatter: validated.data, body };
|
|
4119
|
-
} catch {
|
|
4120
|
-
return void 0;
|
|
4121
|
-
}
|
|
4122
|
-
}
|
|
4123
|
-
function shouldActivateRule(fm, inScopePaths) {
|
|
4124
|
-
if (fm.enabled === false) return false;
|
|
4125
|
-
if (fm.alwaysApply === true) return true;
|
|
4126
|
-
const patterns = [...fm.paths ?? [], ...fm.globs ?? []];
|
|
4127
|
-
if (patterns.length === 0) return false;
|
|
4128
|
-
return anyGlobMatches(patterns, inScopePaths);
|
|
4129
|
-
}
|
|
4130
|
-
|
|
4131
|
-
// src/internal/runtime/context/context-discovery-runner.ts
|
|
4132
|
-
async function runDiscovery(opts) {
|
|
4133
|
-
const gitRoot = findGitRoot(opts.cwd);
|
|
4134
|
-
const specs = opts.specs ?? DEFAULT_DISCOVERY_SPECS;
|
|
4135
|
-
const out = [];
|
|
4136
|
-
const seenReal = /* @__PURE__ */ new Set();
|
|
4137
|
-
for (const spec of specs) {
|
|
4138
|
-
if (spec.id === "theokit-context") continue;
|
|
4139
|
-
const paths = await resolvePathsForSpec(spec, opts.cwd, gitRoot);
|
|
4140
|
-
for (const path of paths) {
|
|
4141
|
-
if (seenReal.has(path)) continue;
|
|
4142
|
-
seenReal.add(path);
|
|
4143
|
-
const source = await loadOneSource(spec, path, opts, gitRoot);
|
|
4144
|
-
if (source !== void 0) out.push(source);
|
|
4145
|
-
}
|
|
4146
|
-
}
|
|
4147
|
-
return out;
|
|
4148
|
-
}
|
|
4149
|
-
async function resolvePathsForSpec(spec, cwd, gitRoot) {
|
|
4150
|
-
if (spec.scope === "cwd-only") {
|
|
4151
|
-
return walkUpForFile(cwd, spec.pattern, cwd);
|
|
4152
|
-
}
|
|
4153
|
-
if (spec.scope === "git-root-walk") {
|
|
4154
|
-
return walkUpForFile(cwd, spec.pattern, gitRoot ?? cwd);
|
|
4155
|
-
}
|
|
4156
|
-
return walkUpForGlob(cwd, spec.pattern);
|
|
4157
|
-
}
|
|
4158
|
-
async function loadOneSource(spec, path, opts, gitRoot) {
|
|
4159
|
-
const relPath = relative(gitRoot ?? opts.cwd, dirname(path));
|
|
4160
|
-
const needsSuffix = spec.scope !== "cwd-only" && relPath !== "" && relPath !== ".";
|
|
4161
|
-
const id = needsSuffix ? `${spec.id}@${relPath}` : spec.id;
|
|
4162
|
-
if (spec.parser === "mdc") {
|
|
4163
|
-
return loadMdcSource(spec, path, id, opts);
|
|
4164
|
-
}
|
|
4165
|
-
if (spec.parser === "rules-frontmatter") {
|
|
4166
|
-
return loadRulesSource(spec, path, id, opts);
|
|
4167
|
-
}
|
|
4168
|
-
if (spec.parser === "frontmatter-zod") {
|
|
4169
|
-
return void 0;
|
|
4170
|
-
}
|
|
4171
|
-
return loadPlainMarkdownSource(spec, path, id, opts);
|
|
4172
|
-
}
|
|
4173
|
-
async function loadParsedSource(spec, path, id, parse, isActive) {
|
|
4174
|
-
let raw;
|
|
4175
|
-
try {
|
|
4176
|
-
raw = await readFile(path, "utf8");
|
|
4177
|
-
} catch {
|
|
4178
|
-
return void 0;
|
|
4179
|
-
}
|
|
4180
|
-
const parsed = parse(raw);
|
|
4181
|
-
if (parsed === void 0 || !isActive(parsed.frontmatter)) return void 0;
|
|
4182
|
-
return { id, source: path, content: parsed.body, priority: spec.priority, truncated: false };
|
|
4183
|
-
}
|
|
4184
|
-
function loadMdcSource(spec, path, id, opts) {
|
|
4185
|
-
return loadParsedSource(
|
|
4186
|
-
spec,
|
|
4187
|
-
path,
|
|
4188
|
-
id,
|
|
4189
|
-
parseMdc,
|
|
4190
|
-
(fm) => shouldActivate(fm, opts.touchedFiles ?? [])
|
|
4191
|
-
);
|
|
4192
|
-
}
|
|
4193
|
-
function loadRulesSource(spec, path, id, opts) {
|
|
4194
|
-
return loadParsedSource(
|
|
4195
|
-
spec,
|
|
4196
|
-
path,
|
|
4197
|
-
id,
|
|
4198
|
-
parseRules,
|
|
4199
|
-
(fm) => shouldActivateRule(fm, opts.touchedFiles ?? [])
|
|
4200
|
-
);
|
|
4201
|
-
}
|
|
4202
|
-
async function loadPlainMarkdownSource(spec, path, id, opts) {
|
|
4203
|
-
const loaded = await loadPlainMarkdown(path, { maxBytesPerFile: opts.maxBytesPerFile });
|
|
4204
|
-
if (loaded === void 0) return void 0;
|
|
4205
|
-
let content = loaded.content;
|
|
4206
|
-
if (spec.followImports) {
|
|
4207
|
-
content = await resolveImports(content, path, {
|
|
4208
|
-
visited: /* @__PURE__ */ new Set([path]),
|
|
4209
|
-
depth: 0,
|
|
4210
|
-
maxBytesPerFile: opts.maxBytesPerFile
|
|
4211
|
-
});
|
|
4212
|
-
}
|
|
4213
|
-
return {
|
|
4214
|
-
id,
|
|
4215
|
-
source: path,
|
|
4216
|
-
content,
|
|
4217
|
-
priority: spec.priority,
|
|
4218
|
-
truncated: loaded.truncated
|
|
4219
|
-
};
|
|
4220
|
-
}
|
|
4221
3910
|
var ContextSourceFrontmatterSchema = z.object({
|
|
4222
3911
|
/** Identifier; defaults to filename slug if omitted. */
|
|
4223
3912
|
name: z.string().min(1).optional(),
|
|
@@ -4277,6 +3966,7 @@ var FileContextManager = class {
|
|
|
4277
3966
|
const discovered = await runDiscovery({
|
|
4278
3967
|
cwd: this.cwd,
|
|
4279
3968
|
maxBytesPerFile,
|
|
3969
|
+
skipLegacyTheokitContext: true,
|
|
4280
3970
|
touchedFiles
|
|
4281
3971
|
});
|
|
4282
3972
|
const legacyAsAggregator = legacy.map((src) => ({
|
|
@@ -10459,7 +10149,7 @@ var Agent = class _Agent {
|
|
|
10459
10149
|
`No local agent "${agentId}" registered \u2014 compact targets local sessions.`
|
|
10460
10150
|
);
|
|
10461
10151
|
}
|
|
10462
|
-
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-
|
|
10152
|
+
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-GF2CBKXB.js');
|
|
10463
10153
|
const { cwd, model, store } = await openLocalStore(reg);
|
|
10464
10154
|
return enqueueSessionWrite(
|
|
10465
10155
|
cwd,
|
|
@@ -10495,7 +10185,7 @@ var Agent = class _Agent {
|
|
|
10495
10185
|
`No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`
|
|
10496
10186
|
);
|
|
10497
10187
|
}
|
|
10498
|
-
const { injectSessionTurn } = await import('./inject-session-
|
|
10188
|
+
const { injectSessionTurn } = await import('./inject-session-NR64GB3T.js');
|
|
10499
10189
|
const { cwd, model, store } = await openLocalStore(reg);
|
|
10500
10190
|
await injectSessionTurn({
|
|
10501
10191
|
store,
|
|
@@ -10629,5 +10319,5 @@ async function openLocalStore(reg) {
|
|
|
10629
10319
|
}
|
|
10630
10320
|
|
|
10631
10321
|
export { Agent, AgentBuilder, DEFAULT_AGENTIC_MODEL_ID, MEMORY_EMBEDDING_ADAPTERS, Tool, ToolError, UsageAccumulator, computeCost, generateCronId, getPricingEntry, openRouterMemoryEmbeddingProviderAdapter, resolveApiKey };
|
|
10632
|
-
//# sourceMappingURL=chunk-
|
|
10633
|
-
//# sourceMappingURL=chunk-
|
|
10322
|
+
//# sourceMappingURL=chunk-KO5V6L3E.js.map
|
|
10323
|
+
//# sourceMappingURL=chunk-KO5V6L3E.js.map
|