@theokit/sdk 4.41.1 → 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 +29 -0
- package/dist/{agent-JDJEBJHU.cjs → agent-HGDXQEQQ.cjs} +8 -7
- package/dist/{agent-JDJEBJHU.cjs.map → agent-HGDXQEQQ.cjs.map} +1 -1
- package/dist/{agent-LVKAYADR.js → agent-WUVYXIFX.js} +7 -6
- package/dist/{agent-LVKAYADR.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-GTLH2NI2.cjs → chunk-EYEZDADP.cjs} +5 -5
- package/dist/{chunk-GTLH2NI2.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-DHLVOLUX.js → chunk-KO5V6L3E.js} +10 -340
- package/dist/chunk-KO5V6L3E.js.map +1 -0
- package/dist/{chunk-AUMSEL33.js → chunk-MPD5EGJ6.js} +3 -3
- package/dist/{chunk-AUMSEL33.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-RPL3POFZ.cjs → chunk-YHQ3DG24.cjs} +48 -378
- 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/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-DHLVOLUX.js.map +0 -1
- package/dist/chunk-RPL3POFZ.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,11 +30,11 @@ 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';
|
|
37
|
-
import { existsSync
|
|
37
|
+
import { existsSync } from 'fs';
|
|
38
38
|
import { homedir } from 'os';
|
|
39
39
|
|
|
40
40
|
// src/agent-builder.ts
|
|
@@ -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,291 +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
|
-
function realOrResolved(path) {
|
|
3959
|
-
try {
|
|
3960
|
-
return realpathSync(path);
|
|
3961
|
-
} catch {
|
|
3962
|
-
return path;
|
|
3963
|
-
}
|
|
3964
|
-
}
|
|
3965
|
-
function insideRoot(target, root) {
|
|
3966
|
-
const rel = relative(realOrResolved(root), realOrResolved(target));
|
|
3967
|
-
return rel !== "" && !rel.startsWith("..") && !isAbsolute(rel);
|
|
3968
|
-
}
|
|
3969
|
-
async function resolveImports(content, basePath, opts) {
|
|
3970
|
-
if (opts.depth >= MAX_HOPS) {
|
|
3971
|
-
return `${content}
|
|
3972
|
-
|
|
3973
|
-
\u2026[@import depth limit ${MAX_HOPS} reached]
|
|
3974
|
-
|
|
3975
|
-
`;
|
|
3976
|
-
}
|
|
3977
|
-
const baseDir = dirname(basePath);
|
|
3978
|
-
return replaceAsync(content, IMPORT_RE, async (raw) => {
|
|
3979
|
-
const absolute = resolveImportPath(raw, baseDir);
|
|
3980
|
-
if (opts.projectRoot !== void 0 && !insideRoot(absolute, opts.projectRoot)) {
|
|
3981
|
-
return `[@import outside the project root, refused: ${raw}]`;
|
|
3982
|
-
}
|
|
3983
|
-
if (opts.visited.has(absolute)) {
|
|
3984
|
-
return `[@import cycle detected: ${raw}]`;
|
|
3985
|
-
}
|
|
3986
|
-
opts.visited.add(absolute);
|
|
3987
|
-
const loaded = await loadPlainMarkdown(absolute, { maxBytesPerFile: opts.maxBytesPerFile });
|
|
3988
|
-
if (loaded === void 0) {
|
|
3989
|
-
return `[@import not found: ${raw}]`;
|
|
3990
|
-
}
|
|
3991
|
-
return resolveImports(loaded.content, absolute, {
|
|
3992
|
-
visited: opts.visited,
|
|
3993
|
-
depth: opts.depth + 1,
|
|
3994
|
-
maxBytesPerFile: opts.maxBytesPerFile,
|
|
3995
|
-
...opts.projectRoot === void 0 ? {} : { projectRoot: opts.projectRoot }
|
|
3996
|
-
});
|
|
3997
|
-
});
|
|
3998
|
-
}
|
|
3999
|
-
function resolveImportPath(raw, baseDir) {
|
|
4000
|
-
if (raw.startsWith("~/")) {
|
|
4001
|
-
return resolve(join(homedir(), raw.slice(2)));
|
|
4002
|
-
}
|
|
4003
|
-
if (isAbsolute(raw)) {
|
|
4004
|
-
return resolve(raw);
|
|
4005
|
-
}
|
|
4006
|
-
return resolve(join(baseDir, raw));
|
|
4007
|
-
}
|
|
4008
|
-
async function replaceAsync(content, re, replacer) {
|
|
4009
|
-
const matches = [];
|
|
4010
|
-
const localRe = new RegExp(re.source, re.flags);
|
|
4011
|
-
let m;
|
|
4012
|
-
while ((m = localRe.exec(content)) !== null) {
|
|
4013
|
-
matches.push({ match: m[0], raw: m[1] ?? "", index: m.index });
|
|
4014
|
-
if (m.index === localRe.lastIndex) localRe.lastIndex += 1;
|
|
4015
|
-
}
|
|
4016
|
-
if (matches.length === 0) return content;
|
|
4017
|
-
let result = "";
|
|
4018
|
-
let cursor = 0;
|
|
4019
|
-
for (const entry of matches) {
|
|
4020
|
-
result += content.slice(cursor, entry.index);
|
|
4021
|
-
result += await replacer(entry.raw);
|
|
4022
|
-
cursor = entry.index + entry.match.length;
|
|
4023
|
-
}
|
|
4024
|
-
result += content.slice(cursor);
|
|
4025
|
-
return result;
|
|
4026
|
-
}
|
|
4027
|
-
|
|
4028
|
-
// src/internal/runtime/context/context-glob.ts
|
|
4029
|
-
function globToRegex(glob) {
|
|
4030
|
-
const compiled = glob.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*\//g, "::GLOBSTAR_SLASH::").replace(/\*\*/g, "::GLOBSTAR::").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(/::GLOBSTAR_SLASH::/g, "(?:.*/)?").replace(/::GLOBSTAR::/g, ".*");
|
|
4031
|
-
return new RegExp(`^${compiled}$`);
|
|
4032
|
-
}
|
|
4033
|
-
function anyGlobMatches(patterns, paths) {
|
|
4034
|
-
if (patterns.length === 0 || paths.length === 0) return false;
|
|
4035
|
-
const res = patterns.map(globToRegex);
|
|
4036
|
-
return paths.some((p) => res.some((re) => re.test(p)));
|
|
4037
|
-
}
|
|
4038
|
-
|
|
4039
|
-
// src/internal/runtime/context/context-yaml-lite.ts
|
|
4040
|
-
var FRONTMATTER_RE = /^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/;
|
|
4041
|
-
function splitFrontmatter2(content) {
|
|
4042
|
-
const m = FRONTMATTER_RE.exec(content);
|
|
4043
|
-
if (m === null) return { yaml: void 0, body: content };
|
|
4044
|
-
return { yaml: m[1] ?? "", body: m[2] ?? "" };
|
|
4045
|
-
}
|
|
4046
|
-
function parseSimpleYaml2(yaml) {
|
|
4047
|
-
const out = {};
|
|
4048
|
-
const lines = yaml.split(/\r?\n/);
|
|
4049
|
-
let i = 0;
|
|
4050
|
-
while (i < lines.length) {
|
|
4051
|
-
const line = lines[i];
|
|
4052
|
-
i += 1;
|
|
4053
|
-
if (line === void 0) continue;
|
|
4054
|
-
const trimmed = line.trim();
|
|
4055
|
-
if (trimmed === "" || trimmed.startsWith("#")) continue;
|
|
4056
|
-
const colon = trimmed.indexOf(":");
|
|
4057
|
-
if (colon === -1) throw new Error(`Invalid YAML line: ${trimmed}`);
|
|
4058
|
-
const key = trimmed.slice(0, colon).trim();
|
|
4059
|
-
const rest = trimmed.slice(colon + 1).trim();
|
|
4060
|
-
if (rest === "") {
|
|
4061
|
-
const items = [];
|
|
4062
|
-
while (i < lines.length) {
|
|
4063
|
-
const next = lines[i];
|
|
4064
|
-
if (next === void 0) break;
|
|
4065
|
-
const nextTrim = next.trim();
|
|
4066
|
-
if (nextTrim.startsWith("- ")) {
|
|
4067
|
-
items.push(parseScalar(nextTrim.slice(2).trim()));
|
|
4068
|
-
i += 1;
|
|
4069
|
-
} else if (nextTrim === "") {
|
|
4070
|
-
i += 1;
|
|
4071
|
-
} else {
|
|
4072
|
-
break;
|
|
4073
|
-
}
|
|
4074
|
-
}
|
|
4075
|
-
out[key] = items;
|
|
4076
|
-
} else if (rest.startsWith("[") && rest.endsWith("]")) {
|
|
4077
|
-
const inner = rest.slice(1, -1).trim();
|
|
4078
|
-
out[key] = inner === "" ? [] : inner.split(",").map((s) => parseScalar(s.trim().replace(/^["']|["']$/g, "")));
|
|
4079
|
-
} else {
|
|
4080
|
-
out[key] = parseScalar(rest);
|
|
4081
|
-
}
|
|
4082
|
-
}
|
|
4083
|
-
return out;
|
|
4084
|
-
}
|
|
4085
|
-
function parseScalar(s) {
|
|
4086
|
-
if (s === "true") return true;
|
|
4087
|
-
if (s === "false") return false;
|
|
4088
|
-
if (/^-?\d+$/.test(s)) return parseInt(s, 10);
|
|
4089
|
-
return s.replace(/^["']|["']$/g, "");
|
|
4090
|
-
}
|
|
4091
|
-
|
|
4092
|
-
// src/internal/runtime/context/context-mdc-parser.ts
|
|
4093
|
-
var McdFrontmatterSchema = z.object({
|
|
4094
|
-
description: z.string().optional(),
|
|
4095
|
-
globs: z.array(z.string()).optional(),
|
|
4096
|
-
alwaysApply: z.boolean().optional()
|
|
4097
|
-
});
|
|
4098
|
-
function parseMdc(content) {
|
|
4099
|
-
const { yaml, body } = splitFrontmatter2(content);
|
|
4100
|
-
if (yaml === void 0) {
|
|
4101
|
-
return { frontmatter: { alwaysApply: true }, body: content };
|
|
4102
|
-
}
|
|
4103
|
-
try {
|
|
4104
|
-
const parsed = parseSimpleYaml2(yaml);
|
|
4105
|
-
const validated = McdFrontmatterSchema.safeParse(parsed);
|
|
4106
|
-
if (!validated.success) return void 0;
|
|
4107
|
-
return { frontmatter: validated.data, body };
|
|
4108
|
-
} catch {
|
|
4109
|
-
return void 0;
|
|
4110
|
-
}
|
|
4111
|
-
}
|
|
4112
|
-
function shouldActivate(fm, touchedFiles) {
|
|
4113
|
-
if (fm.alwaysApply === true) return true;
|
|
4114
|
-
if (fm.globs === void 0 || fm.globs.length === 0) return false;
|
|
4115
|
-
return anyGlobMatches(fm.globs, touchedFiles);
|
|
4116
|
-
}
|
|
4117
|
-
var RulesFrontmatterSchema = z.object({
|
|
4118
|
-
description: z.string().optional(),
|
|
4119
|
-
paths: z.array(z.string()).optional(),
|
|
4120
|
-
globs: z.array(z.string()).optional(),
|
|
4121
|
-
alwaysApply: z.boolean().optional(),
|
|
4122
|
-
enabled: z.boolean().optional()
|
|
4123
|
-
});
|
|
4124
|
-
function parseRules(content) {
|
|
4125
|
-
const { yaml, body } = splitFrontmatter2(content);
|
|
4126
|
-
if (yaml === void 0) {
|
|
4127
|
-
return { frontmatter: { alwaysApply: true }, body: content };
|
|
4128
|
-
}
|
|
4129
|
-
try {
|
|
4130
|
-
const parsed = parseSimpleYaml2(yaml);
|
|
4131
|
-
const validated = RulesFrontmatterSchema.safeParse(parsed);
|
|
4132
|
-
if (!validated.success) return void 0;
|
|
4133
|
-
return { frontmatter: validated.data, body };
|
|
4134
|
-
} catch {
|
|
4135
|
-
return void 0;
|
|
4136
|
-
}
|
|
4137
|
-
}
|
|
4138
|
-
function shouldActivateRule(fm, inScopePaths) {
|
|
4139
|
-
if (fm.enabled === false) return false;
|
|
4140
|
-
if (fm.alwaysApply === true) return true;
|
|
4141
|
-
const patterns = [...fm.paths ?? [], ...fm.globs ?? []];
|
|
4142
|
-
if (patterns.length === 0) return false;
|
|
4143
|
-
return anyGlobMatches(patterns, inScopePaths);
|
|
4144
|
-
}
|
|
4145
|
-
|
|
4146
|
-
// src/internal/runtime/context/context-discovery-runner.ts
|
|
4147
|
-
async function runDiscovery(opts) {
|
|
4148
|
-
const gitRoot = findGitRoot(opts.cwd);
|
|
4149
|
-
const specs = opts.specs ?? DEFAULT_DISCOVERY_SPECS;
|
|
4150
|
-
const out = [];
|
|
4151
|
-
const seenReal = /* @__PURE__ */ new Set();
|
|
4152
|
-
for (const spec of specs) {
|
|
4153
|
-
if (spec.id === "theokit-context") continue;
|
|
4154
|
-
const paths = await resolvePathsForSpec(spec, opts.cwd, gitRoot);
|
|
4155
|
-
for (const path of paths) {
|
|
4156
|
-
if (seenReal.has(path)) continue;
|
|
4157
|
-
seenReal.add(path);
|
|
4158
|
-
const source = await loadOneSource(spec, path, opts, gitRoot);
|
|
4159
|
-
if (source !== void 0) out.push(source);
|
|
4160
|
-
}
|
|
4161
|
-
}
|
|
4162
|
-
return out;
|
|
4163
|
-
}
|
|
4164
|
-
async function resolvePathsForSpec(spec, cwd, gitRoot) {
|
|
4165
|
-
if (spec.scope === "cwd-only") {
|
|
4166
|
-
return walkUpForFile(cwd, spec.pattern, cwd);
|
|
4167
|
-
}
|
|
4168
|
-
if (spec.scope === "git-root-walk") {
|
|
4169
|
-
return walkUpForFile(cwd, spec.pattern, gitRoot ?? cwd);
|
|
4170
|
-
}
|
|
4171
|
-
return walkUpForGlob(cwd, spec.pattern);
|
|
4172
|
-
}
|
|
4173
|
-
async function loadOneSource(spec, path, opts, gitRoot) {
|
|
4174
|
-
const relPath = relative(gitRoot ?? opts.cwd, dirname(path));
|
|
4175
|
-
const needsSuffix = spec.scope !== "cwd-only" && relPath !== "" && relPath !== ".";
|
|
4176
|
-
const id = needsSuffix ? `${spec.id}@${relPath}` : spec.id;
|
|
4177
|
-
if (spec.parser === "mdc") {
|
|
4178
|
-
return loadMdcSource(spec, path, id, opts);
|
|
4179
|
-
}
|
|
4180
|
-
if (spec.parser === "rules-frontmatter") {
|
|
4181
|
-
return loadRulesSource(spec, path, id, opts);
|
|
4182
|
-
}
|
|
4183
|
-
if (spec.parser === "frontmatter-zod") {
|
|
4184
|
-
return void 0;
|
|
4185
|
-
}
|
|
4186
|
-
return loadPlainMarkdownSource(spec, path, id, opts, gitRoot);
|
|
4187
|
-
}
|
|
4188
|
-
async function loadParsedSource(spec, path, id, parse, isActive) {
|
|
4189
|
-
let raw;
|
|
4190
|
-
try {
|
|
4191
|
-
raw = await readFile(path, "utf8");
|
|
4192
|
-
} catch {
|
|
4193
|
-
return void 0;
|
|
4194
|
-
}
|
|
4195
|
-
const parsed = parse(raw);
|
|
4196
|
-
if (parsed === void 0 || !isActive(parsed.frontmatter)) return void 0;
|
|
4197
|
-
return { id, source: path, content: parsed.body, priority: spec.priority, truncated: false };
|
|
4198
|
-
}
|
|
4199
|
-
function loadMdcSource(spec, path, id, opts) {
|
|
4200
|
-
return loadParsedSource(
|
|
4201
|
-
spec,
|
|
4202
|
-
path,
|
|
4203
|
-
id,
|
|
4204
|
-
parseMdc,
|
|
4205
|
-
(fm) => shouldActivate(fm, opts.touchedFiles ?? [])
|
|
4206
|
-
);
|
|
4207
|
-
}
|
|
4208
|
-
function loadRulesSource(spec, path, id, opts) {
|
|
4209
|
-
return loadParsedSource(
|
|
4210
|
-
spec,
|
|
4211
|
-
path,
|
|
4212
|
-
id,
|
|
4213
|
-
parseRules,
|
|
4214
|
-
(fm) => shouldActivateRule(fm, opts.touchedFiles ?? [])
|
|
4215
|
-
);
|
|
4216
|
-
}
|
|
4217
|
-
async function loadPlainMarkdownSource(spec, path, id, opts, gitRoot) {
|
|
4218
|
-
const loaded = await loadPlainMarkdown(path, { maxBytesPerFile: opts.maxBytesPerFile });
|
|
4219
|
-
if (loaded === void 0) return void 0;
|
|
4220
|
-
let content = loaded.content;
|
|
4221
|
-
if (spec.followImports) {
|
|
4222
|
-
content = await resolveImports(content, path, {
|
|
4223
|
-
visited: /* @__PURE__ */ new Set([path]),
|
|
4224
|
-
depth: 0,
|
|
4225
|
-
maxBytesPerFile: opts.maxBytesPerFile,
|
|
4226
|
-
// The document carrying the import is repository-controlled, so the repository is the
|
|
4227
|
-
// boundary it may not cross. Without this, `CLAUDE.md` / `GEMINI.md` — the two specs
|
|
4228
|
-
// with `followImports: true` — could name any absolute or `~/` path and have it
|
|
4229
|
-
// inlined into the system prompt.
|
|
4230
|
-
projectRoot: opts.importRoot ?? gitRoot ?? opts.cwd
|
|
4231
|
-
});
|
|
4232
|
-
}
|
|
4233
|
-
return {
|
|
4234
|
-
id,
|
|
4235
|
-
source: path,
|
|
4236
|
-
content,
|
|
4237
|
-
priority: spec.priority,
|
|
4238
|
-
truncated: loaded.truncated
|
|
4239
|
-
};
|
|
4240
|
-
}
|
|
4241
3910
|
var ContextSourceFrontmatterSchema = z.object({
|
|
4242
3911
|
/** Identifier; defaults to filename slug if omitted. */
|
|
4243
3912
|
name: z.string().min(1).optional(),
|
|
@@ -4297,6 +3966,7 @@ var FileContextManager = class {
|
|
|
4297
3966
|
const discovered = await runDiscovery({
|
|
4298
3967
|
cwd: this.cwd,
|
|
4299
3968
|
maxBytesPerFile,
|
|
3969
|
+
skipLegacyTheokitContext: true,
|
|
4300
3970
|
touchedFiles
|
|
4301
3971
|
});
|
|
4302
3972
|
const legacyAsAggregator = legacy.map((src) => ({
|
|
@@ -10479,7 +10149,7 @@ var Agent = class _Agent {
|
|
|
10479
10149
|
`No local agent "${agentId}" registered \u2014 compact targets local sessions.`
|
|
10480
10150
|
);
|
|
10481
10151
|
}
|
|
10482
|
-
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-
|
|
10152
|
+
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-GF2CBKXB.js');
|
|
10483
10153
|
const { cwd, model, store } = await openLocalStore(reg);
|
|
10484
10154
|
return enqueueSessionWrite(
|
|
10485
10155
|
cwd,
|
|
@@ -10515,7 +10185,7 @@ var Agent = class _Agent {
|
|
|
10515
10185
|
`No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`
|
|
10516
10186
|
);
|
|
10517
10187
|
}
|
|
10518
|
-
const { injectSessionTurn } = await import('./inject-session-
|
|
10188
|
+
const { injectSessionTurn } = await import('./inject-session-NR64GB3T.js');
|
|
10519
10189
|
const { cwd, model, store } = await openLocalStore(reg);
|
|
10520
10190
|
await injectSessionTurn({
|
|
10521
10191
|
store,
|
|
@@ -10649,5 +10319,5 @@ async function openLocalStore(reg) {
|
|
|
10649
10319
|
}
|
|
10650
10320
|
|
|
10651
10321
|
export { Agent, AgentBuilder, DEFAULT_AGENTIC_MODEL_ID, MEMORY_EMBEDDING_ADAPTERS, Tool, ToolError, UsageAccumulator, computeCost, generateCronId, getPricingEntry, openRouterMemoryEmbeddingProviderAdapter, resolveApiKey };
|
|
10652
|
-
//# sourceMappingURL=chunk-
|
|
10653
|
-
//# sourceMappingURL=chunk-
|
|
10322
|
+
//# sourceMappingURL=chunk-KO5V6L3E.js.map
|
|
10323
|
+
//# sourceMappingURL=chunk-KO5V6L3E.js.map
|