@theokit/sdk 4.42.0 → 4.42.1
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 +31 -0
- package/dist/{agent-HGDXQEQQ.cjs → agent-DRUORJTU.cjs} +5 -5
- package/dist/{agent-HGDXQEQQ.cjs.map → agent-DRUORJTU.cjs.map} +1 -1
- package/dist/{agent-WUVYXIFX.js → agent-MVYGMWPM.js} +4 -4
- package/dist/{agent-WUVYXIFX.js.map → agent-MVYGMWPM.js.map} +1 -1
- package/dist/{chunk-YHQ3DG24.cjs → chunk-4OQXDCMN.cjs} +10 -10
- package/dist/chunk-4OQXDCMN.cjs.map +1 -0
- package/dist/{chunk-22EMHGBO.cjs → chunk-GAXYZXYY.cjs} +8 -7
- package/dist/chunk-GAXYZXYY.cjs.map +1 -0
- package/dist/{chunk-EYEZDADP.cjs → chunk-HLGEXZZP.cjs} +5 -5
- package/dist/{chunk-EYEZDADP.cjs.map → chunk-HLGEXZZP.cjs.map} +1 -1
- package/dist/{chunk-MPD5EGJ6.js → chunk-O67XODD5.js} +3 -3
- package/dist/{chunk-MPD5EGJ6.js.map → chunk-O67XODD5.js.map} +1 -1
- package/dist/{chunk-KO5V6L3E.js → chunk-V5V5A6B7.js} +5 -5
- package/dist/chunk-V5V5A6B7.js.map +1 -0
- package/dist/{chunk-Q2PPSHBS.js → chunk-ZZAAQOAZ.js} +9 -9
- package/dist/chunk-ZZAAQOAZ.js.map +1 -0
- package/dist/context/index.cjs +5 -5
- package/dist/context/index.js +2 -2
- package/dist/cron.cjs +4 -4
- package/dist/cron.js +3 -3
- package/dist/eval.cjs +3 -3
- package/dist/eval.js +2 -2
- package/dist/index.cjs +19 -19
- package/dist/index.js +5 -5
- package/dist/internal/runtime/context/path-containment.d.ts +24 -0
- package/dist/server/auth/index.d.cts +207 -11
- package/dist/server/auth/index.d.ts +207 -11
- package/dist/server/errors-envelope.d.cts +12 -6
- package/dist/server/errors-envelope.d.ts +12 -6
- package/package.json +13 -12
- package/dist/chunk-22EMHGBO.cjs.map +0 -1
- package/dist/chunk-KO5V6L3E.js.map +0 -1
- package/dist/chunk-Q2PPSHBS.js.map +0 -1
- package/dist/chunk-YHQ3DG24.cjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { findGitRoot, DEFAULT_DISCOVERY_SPECS, walkUpForFile, walkUpForGlob } from './chunk-UJ7IQJAG.js';
|
|
2
|
-
import { realpathSync } from 'fs';
|
|
3
2
|
import { homedir } from 'os';
|
|
4
|
-
import {
|
|
3
|
+
import { relative, isAbsolute, dirname, resolve, join } from 'path';
|
|
5
4
|
import { readFile } from 'fs/promises';
|
|
5
|
+
import { realpathSync } from 'fs';
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
|
|
8
8
|
var HEAD_RATIO = 0.7;
|
|
@@ -51,10 +51,6 @@ function emitTruncationCounter(source) {
|
|
|
51
51
|
} catch {
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
// src/internal/runtime/context/context-import-resolver.ts
|
|
56
|
-
var IMPORT_RE = /^@(\S+)\s*$/gm;
|
|
57
|
-
var MAX_HOPS = 5;
|
|
58
54
|
function realOrResolved(path) {
|
|
59
55
|
try {
|
|
60
56
|
return realpathSync(path);
|
|
@@ -66,6 +62,10 @@ function insideRoot(target, root) {
|
|
|
66
62
|
const rel = relative(realOrResolved(root), realOrResolved(target));
|
|
67
63
|
return rel !== "" && !rel.startsWith("..") && !isAbsolute(rel);
|
|
68
64
|
}
|
|
65
|
+
|
|
66
|
+
// src/internal/runtime/context/context-import-resolver.ts
|
|
67
|
+
var IMPORT_RE = /^@(\S+)\s*$/gm;
|
|
68
|
+
var MAX_HOPS = 5;
|
|
69
69
|
async function resolveImports(content, basePath, opts) {
|
|
70
70
|
if (opts.depth >= MAX_HOPS) {
|
|
71
71
|
return `${content}
|
|
@@ -339,6 +339,6 @@ async function loadPlainMarkdownSource(spec, path, id, opts, gitRoot) {
|
|
|
339
339
|
};
|
|
340
340
|
}
|
|
341
341
|
|
|
342
|
-
export { DEFAULT_MAX_BYTES_PER_FILE, parseRules, resolveImports, runDiscovery, shouldActivateRule, truncateWithMarker };
|
|
343
|
-
//# sourceMappingURL=chunk-
|
|
344
|
-
//# sourceMappingURL=chunk-
|
|
342
|
+
export { DEFAULT_MAX_BYTES_PER_FILE, insideRoot, parseRules, resolveImports, runDiscovery, shouldActivateRule, truncateWithMarker };
|
|
343
|
+
//# sourceMappingURL=chunk-ZZAAQOAZ.js.map
|
|
344
|
+
//# sourceMappingURL=chunk-ZZAAQOAZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/internal/runtime/context/context-loaders.ts","../src/internal/runtime/context/path-containment.ts","../src/internal/runtime/context/context-import-resolver.ts","../src/internal/runtime/context/context-glob.ts","../src/internal/runtime/context/context-yaml-lite.ts","../src/internal/runtime/context/context-rules-frontmatter.ts","../src/internal/runtime/context/context-mdc-parser.ts","../src/internal/runtime/context/context-discovery-runner.ts"],"names":["resolvePath","isAbsolute","z","relative","dirname","readFile"],"mappings":";;;;;;;AAaA,IAAM,UAAA,GAAa,GAAA;AACnB,IAAM,UAAA,GAAa,GAAA;AACnB,IAAM,MAAA,GAAS,sCAAA;AAGR,IAAM,0BAAA,GAA6B;AAiCnC,SAAS,kBAAA,CAAmB,SAAiB,GAAA,EAA6B;AAC/E,EAAA,IAAI,OAAA,CAAQ,UAAU,GAAA,EAAK;AACzB,IAAA,OAAO,EAAE,SAAA,EAAW,KAAA,EAAO,YAAA,EAAc,OAAA,EAAQ;AAAA,EACnD;AAEA,EAAA,IAAI,GAAA,IAAO,OAAO,MAAA,EAAQ;AACxB,IAAA,OAAO,EAAE,WAAW,IAAA,EAAM,YAAA,EAAc,QAAQ,KAAA,CAAM,CAAA,EAAG,GAAG,CAAA,EAAE;AAAA,EAChE;AACA,EAAA,MAAM,MAAA,GAAS,MAAM,MAAA,CAAO,M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C,EAAA,KACnD,kBAAA,CAAmB,IAAI,IAAA,CAAK,YAAA,IAAgB,EAAE;AAAA,GAChD;AACF;AAEA,eAAe,uBAAA,CACb,IAAA,EACA,IAAA,EACA,EAAA,EACA,MACA,OAAA,EACuC;AACvC,EAAA,MAAM,MAAA,GAAS,MAAM,iBAAA,CAAkB,IAAA,EAAM,EAAE,eAAA,EAAiB,IAAA,CAAK,iBAAiB,CAAA;AACtF,EAAA,IAAI,MAAA,KAAW,QAAW,OAAO,MAAA;AACjC,EAAA,IAAI,UAAU,MAAA,CAAO,OAAA;AACrB,EAAA,IAAI,KAAK,aAAA,EAAe;AACtB,IAAA,OAAA,GAAU,MAAM,cAAA,CAAe,OAAA,EAAS,IAAA,EAAM;AAAA,MAC5C,OAAA,kBAAS,IAAI,GAAA,CAAI,CAAC,IAAI,CAAC,CAAA;AAAA,MACvB,KAAA,EAAO,CAAA;AAAA,MACP,iBAAiB,IAAA,CAAK,eAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAKtB,WAAA,EAAa,IAAA,CAAK,UAAA,IAAc,OAAA,IAAW,IAAA,CAAK;AAAA,KACjD,CAAA;AAAA,EACH;AACA,EAAA,OAAO;AAAA,IACL,EAAA;AAAA,IACA,MAAA,EAAQ,IAAA;AAAA,IACR,OAAA;AAAA,IACA,UAAU,IAAA,CAAK,QAAA;AAAA,IACf,WAAW,MAAA,CAAO;AAAA,GACpB;AACF","file":"chunk-ZZAAQOAZ.js","sourcesContent":["/**\n * Context file loaders + truncation (T1.2, ADRs D154 / D155 / D159).\n *\n * Reads context source files from disk, applies the per-file size cap\n * with 70%/20% head/tail truncation, and emits the\n * `context_files_truncated` telemetry counter when the cap fires.\n * Pure (no I/O) for `truncateWithMarker` — testable in isolation.\n *\n * @internal\n */\n\nimport { readFile } from \"node:fs/promises\";\n\nconst HEAD_RATIO = 0.7;\nconst TAIL_RATIO = 0.2;\nconst MARKER = \"\\n\\n…[truncated by theokit]\\n\\n\";\n\n/** Default per-file cap (40k chars ≈ 10k tokens). D155. */\nexport const DEFAULT_MAX_BYTES_PER_FILE = 40_000;\n\nexport interface LoadedSource {\n /** Absolute path the content came from. */\n readonly source: string;\n readonly content: string;\n readonly originalBytes: number;\n readonly truncated: boolean;\n}\n\nexport interface TruncateResult {\n readonly truncated: boolean;\n readonly finalContent: string;\n}\n\n/**\n * Cap `content` at `max` characters with 70%/20% head/tail truncation\n * and an explicit marker. Pure — no I/O, no telemetry.\n *\n * EC-C: when `max <= MARKER.length`, skip the marker entirely and\n * return a head-only slice. Without this guard, `budget = max -\n * MARKER.length` would go negative and `content.slice(-tailBytes)`\n * would slice from the END of the string rather than truncating.\n *\n * EC-H: codepoint integrity — `String.slice()` operates on UTF-16\n * code units, which can split surrogate pairs. We accept that\n * trailing/leading replacement chars (U+FFFD) may appear at boundaries.\n * Modern LLMs tolerate them; byte-exact safety would require Buffer\n * slicing + TextDecoder with `fatal: true` retry, which adds complexity\n * without value.\n *\n * @public\n */\nexport function truncateWithMarker(content: string, max: number): TruncateResult {\n if (content.length <= max) {\n return { truncated: false, finalContent: content };\n }\n // EC-C: max too small to fit even the marker — return head-only slice.\n if (max <= MARKER.length) {\n return { truncated: true, finalContent: content.slice(0, max) };\n }\n const budget = max - MARKER.length;\n const headBytes = Math.floor(budget * (HEAD_RATIO / (HEAD_RATIO + TAIL_RATIO)));\n const tailBytes = budget - headBytes;\n return {\n truncated: true,\n finalContent: content.slice(0, headBytes) + MARKER + content.slice(-tailBytes),\n };\n}\n\n/**\n * Read a file from disk and apply the per-file cap. Emits telemetry\n * counter when truncation fires.\n *\n * EC-G: file deleted between discovery and read (FS race) → returns\n * `undefined`, never throws.\n *\n * @internal\n */\nexport async function loadPlainMarkdown(\n absPath: string,\n opts: { maxBytesPerFile?: number } = {},\n): Promise<LoadedSource | undefined> {\n const max = opts.maxBytesPerFile ?? DEFAULT_MAX_BYTES_PER_FILE;\n let content: string;\n try {\n content = await readFile(absPath, \"utf8\");\n } catch {\n // EC-G: ENOENT / EACCES / etc → caller treats as missing.\n return undefined;\n }\n const { truncated, finalContent } = truncateWithMarker(content, max);\n if (truncated) {\n emitTruncationCounter(absPath);\n }\n return {\n source: absPath,\n content: finalContent,\n originalBytes: content.length,\n truncated,\n };\n}\n\n/**\n * EC-L: telemetry no-op when OTel is not imported. We import the tracer\n * lazily and use `safeCall` so the lookup never throws and never pulls\n * OTel into the import graph for users without `@opentelemetry/api`\n * installed.\n *\n * @internal\n */\nfunction emitTruncationCounter(source: string): void {\n // Lazy resolution via globalThis avoids static import of telemetry/tracer.\n // Tests can spy via the same path; production users without OTel see no-op.\n const tracer = (\n globalThis as { __theokit_tracer?: { inc?: (k: string, attrs: unknown) => void } }\n ).__theokit_tracer;\n if (tracer?.inc === undefined) return;\n try {\n tracer.inc(\"context_files_truncated\", { file: source });\n } catch {\n // Telemetry must never break the loader.\n }\n}\n","/**\n * The one rule for \"is this resolved path inside that root\".\n *\n * Extracted because the package held it twice, at different strengths, for the same question. The\n * correct version lived as a private function in `context-import-resolver.ts`, written for the\n * 4.41.1 patch; the context manager had its own `absolute.startsWith(resolvePath(cwd))`, which\n * admits two escapes:\n *\n * - **No separator boundary.** With `root = /home/user/proj`, the path `/home/user/proj-evil/x`\n * starts with the root string and is NOT inside it. A sibling directory whose name merely\n * extends the project's is enough; no `..` past the parent is needed.\n * - **Lexical, not real.** A symlink whose name sits inside the root and whose target does not\n * passes any comparison made before symlink resolution.\n *\n * The obvious escapes (`../../etc/passwd`, an absolute path) ARE refused by a prefix test, which is\n * why the weaker version survived review: it looks like it works on the inputs a reader tries.\n *\n * Both readers of repository-supplied paths now share this module. That is DRY about the RULE\n * rather than about line count — one piece of knowledge, one representation, so the two cannot\n * drift apart again.\n *\n * @internal\n */\n\nimport { realpathSync } from \"node:fs\";\nimport { isAbsolute, relative } from \"node:path\";\n\n/**\n * The real path, or the lexical one when it cannot be resolved.\n *\n * The fallback is load-bearing rather than defensive: the context manager checks containment BEFORE\n * it stats the file, so a source that is legitimately absent must still be judged on its declared\n * location instead of being refused for the wrong reason.\n *\n * @internal\n */\nexport function realOrResolved(path: string): string {\n try {\n return realpathSync(path);\n } catch {\n return path;\n }\n}\n\n/**\n * Whether `target` is inside `root`, compared AFTER symlink resolution.\n *\n * `relative()` supplies the separator boundary that a prefix test lacks: it answers `..` for a\n * sibling, `''` for the root itself, and an absolute path when the two are on different roots.\n *\n * @internal\n */\nexport function insideRoot(target: string, root: string): boolean {\n const rel = relative(realOrResolved(root), realOrResolved(target));\n return rel !== \"\" && !rel.startsWith(\"..\") && !isAbsolute(rel);\n}\n","/**\n * `@path/to/file` import resolver (T2.1, ADR D156).\n *\n * Anthropic/Gemini convention: lines that are EXACTLY `@path` get\n * replaced with the imported file's content, recursively (5-hop cap),\n * with cycle detection. Inline `see @x.md, also @y.md` references are\n * NOT resolved (EC-Q — own-line only, mirrors Anthropic's actual\n * behavior).\n *\n * EC-D fix: every imported file is itself capped at `maxBytesPerFile`\n * via `loadPlainMarkdown` BEFORE concatenation. Prevents a CLAUDE.md\n * with 5 imports of 30k each from ballooning to 150k of imported\n * content before the outer cap fires.\n *\n * @internal\n */\n\nimport { homedir } from \"node:os\";\nimport { dirname, isAbsolute, join, resolve as resolvePath } from \"node:path\";\n\nimport { loadPlainMarkdown } from \"./context-loaders.js\";\nimport { insideRoot } from \"./path-containment.js\";\n\n/** EC-Q: line-anchored. `@path` must be alone on its line. */\nconst IMPORT_RE = /^@(\\S+)\\s*$/gm;\nconst MAX_HOPS = 5;\n\nexport interface ResolveImportsOptions {\n /** Absolute paths already resolved (cycle detection). */\n readonly visited: Set<string>;\n /** Current recursion depth — caps at MAX_HOPS. */\n readonly depth: number;\n /** Per-import file cap (EC-D). Forwarded to loadPlainMarkdown. */\n readonly maxBytesPerFile: number;\n /**\n * The directory an import may not escape. When set, a target resolving outside it is\n * refused and replaced with a placeholder.\n *\n * The file carrying the import is REPOSITORY-CONTROLLED — `CLAUDE.md` and `GEMINI.md`\n * are the two default specs with `followImports: true`, and both are found by\n * `git-root-walk` inside the tree the agent was pointed at. Without a root, a cloned\n * repository could name `@~/.ssh/id_rsa` or any absolute path and have its contents\n * inlined into the system prompt, and from there sent to the model provider. The\n * traversal guard that already existed (`isSafePattern`) guards the discovery PATTERN,\n * not the import TARGET, so it never saw this.\n *\n * OPTIONAL, so a caller outside the discovery path keeps the previous behaviour rather\n * than breaking on an upgrade. `runDiscovery` always supplies `gitRoot ?? cwd` — the\n * same value it already uses to keep absolute paths out of `<source name=\"\">`.\n */\n readonly projectRoot?: string;\n}\n\n/**\n * Resolve `@path` directives in `content`. Each match is replaced with\n * the imported file content (already cap-truncated per EC-D), and\n * recursion continues on the resolved content until MAX_HOPS or cycle.\n *\n * Failure modes (placeholders, never throws):\n * - file not found → `[@import not found: <path>]`\n * - cycle detected → `[@import cycle detected: <path>]`\n * - depth exceeded → trailing `\\n\\n…[@import depth limit 5 reached]\\n\\n`\n *\n * @internal\n */\nexport async function resolveImports(\n content: string,\n basePath: string,\n opts: ResolveImportsOptions,\n): Promise<string> {\n if (opts.depth >= MAX_HOPS) {\n return `${content}\\n\\n…[@import depth limit ${MAX_HOPS} reached]\\n\\n`;\n }\n const baseDir = dirname(basePath);\n return replaceAsync(content, IMPORT_RE, async (raw) => {\n const absolute = resolveImportPath(raw, baseDir);\n // Containment BEFORE the read. Reporting the refusal after loading the file would\n // already have put the bytes in memory, and the placeholder names the path the author\n // wrote rather than the resolved one — echoing `/home/<user>/.ssh/id_rsa` back into the\n // prompt would leak the layout of the machine to the same untrusted document.\n if (opts.projectRoot !== undefined && !insideRoot(absolute, opts.projectRoot)) {\n return `[@import outside the project root, refused: ${raw}]`;\n }\n if (opts.visited.has(absolute)) {\n return `[@import cycle detected: ${raw}]`;\n }\n opts.visited.add(absolute);\n const loaded = await loadPlainMarkdown(absolute, { maxBytesPerFile: opts.maxBytesPerFile });\n if (loaded === undefined) {\n return `[@import not found: ${raw}]`;\n }\n // Recurse with same visited set + incremented depth. `projectRoot` is FORWARDED: an\n // imported file is repository-controlled too, so a root that applied only at depth 0\n // would be escapable in one extra hop.\n return resolveImports(loaded.content, absolute, {\n visited: opts.visited,\n depth: opts.depth + 1,\n maxBytesPerFile: opts.maxBytesPerFile,\n ...(opts.projectRoot === undefined ? {} : { projectRoot: opts.projectRoot }),\n });\n });\n}\n\nfunction resolveImportPath(raw: string, baseDir: string): string {\n if (raw.startsWith(\"~/\")) {\n return resolvePath(join(homedir(), raw.slice(2)));\n }\n if (isAbsolute(raw)) {\n return resolvePath(raw);\n }\n return resolvePath(join(baseDir, raw));\n}\n\n/**\n * Async equivalent of `String.prototype.replace` — sequential. Returns\n * `content` with every `re` match replaced by `await replacer(match)`.\n *\n * @internal\n */\nasync function replaceAsync(\n content: string,\n re: RegExp,\n replacer: (raw: string) => Promise<string>,\n): Promise<string> {\n const matches: Array<{ match: string; raw: string; index: number }> = [];\n // Reset lastIndex; clone the regex to avoid stateful traps.\n const localRe = new RegExp(re.source, re.flags);\n let m: RegExpExecArray | null;\n // biome-ignore lint/suspicious/noAssignInExpressions: idiomatic regex loop\n while ((m = localRe.exec(content)) !== null) {\n matches.push({ match: m[0], raw: m[1] ?? \"\", index: m.index });\n if (m.index === localRe.lastIndex) localRe.lastIndex += 1;\n }\n if (matches.length === 0) return content;\n let result = \"\";\n let cursor = 0;\n for (const entry of matches) {\n result += content.slice(cursor, entry.index);\n result += await replacer(entry.raw);\n cursor = entry.index + entry.match.length;\n }\n result += content.slice(cursor);\n return result;\n}\n","/**\n * Shared glob → RegExp compiler for context discovery (extracted from the\n * MDC parser so the `.cursor/rules/*.mdc` and `.theokit/rules/*.md` parsers\n * share ONE implementation — DRY, no new dependency).\n *\n * Supports `**` (any depth), `*` (single path segment, no `/`), `?` (single\n * non-separator char). Sufficient for the patterns Cursor and Claude Code\n * themselves recommend.\n *\n * @internal\n */\nexport function globToRegex(glob: string): RegExp {\n // Support **/ (zero-or-more path segments), ** (any depth), * (single\n // segment), ? (single non-separator char). `**/` collapses so `src/**/*.ts`\n // matches `src/foo.ts` AND `src/a/b/foo.ts` — the semantics Cursor and Claude\n // Code document (\"src/**/* → all files under src/\"). `*` and `?` never cross a\n // `/` (strict glob segment semantics). Escape other regex metas.\n const compiled = glob\n .replace(/[.+^${}()|[\\]\\\\]/g, \"\\\\$&\")\n .replace(/\\*\\*\\//g, \"::GLOBSTAR_SLASH::\")\n .replace(/\\*\\*/g, \"::GLOBSTAR::\")\n .replace(/\\*/g, \"[^/]*\")\n .replace(/\\?/g, \"[^/]\")\n .replace(/::GLOBSTAR_SLASH::/g, \"(?:.*/)?\")\n .replace(/::GLOBSTAR::/g, \".*\");\n return new RegExp(`^${compiled}$`);\n}\n\n/**\n * True when any of `patterns` glob-matches any of `paths`. Central helper so\n * both rule parsers agree on activation semantics.\n *\n * @internal\n */\nexport function anyGlobMatches(\n patterns: ReadonlyArray<string>,\n paths: ReadonlyArray<string>,\n): boolean {\n if (patterns.length === 0 || paths.length === 0) return false;\n const res = patterns.map(globToRegex);\n return paths.some((p) => res.some((re) => re.test(p)));\n}\n","/**\n * Minimal YAML-subset frontmatter parsing shared by the `.cursor/rules/*.mdc`\n * and `.theokit/rules/*.md` parsers (extracted for DRY — one parser, one set\n * of edge-case behaviours, no new dependency).\n *\n * Handles `key: value` lines (string scalars, booleans, integers) and `key:`\n * followed by indented `- item` arrays or inline `[a, b]` arrays. Sufficient\n * for the small, fixed frontmatter field sets these rule files use. Throws on\n * a truly malformed line (no colon).\n *\n * NOTE — distinct from the sibling `yaml-frontmatter.ts` `parseSimpleYaml` on\n * purpose: that one parses INLINE arrays only (`key: [a, b]`), whereas rule\n * files (`.cursor/rules/*.mdc`, `.theokit/rules/*.md`) use MULTI-LINE `- item`\n * lists (`paths:` / `globs:`), which this parser adds. Unifying onto the inline\n * parser would drop multi-line list support; unifying the other way would touch\n * the skills/subagents/persistence loaders that depend on the inline one. The\n * two intentionally coexist until a shared parser handles both shapes.\n *\n * @internal\n */\n\nconst FRONTMATTER_RE = /^---\\s*\\n([\\s\\S]*?)\\n---\\s*\\n([\\s\\S]*)$/;\n\nexport interface FrontmatterSplit {\n /** Raw YAML block between the `---` fences, or undefined when absent. */\n readonly yaml: string | undefined;\n /** The markdown body after the frontmatter (or the whole content). */\n readonly body: string;\n}\n\n/**\n * Split `---`-fenced frontmatter from the body. When no frontmatter fence is\n * present, `yaml` is undefined and `body` is the whole content.\n *\n * @internal\n */\nexport function splitFrontmatter(content: string): FrontmatterSplit {\n const m = FRONTMATTER_RE.exec(content);\n if (m === null) return { yaml: undefined, body: content };\n return { yaml: m[1] ?? \"\", body: m[2] ?? \"\" };\n}\n\n/**\n * Parse the minimal YAML subset. Throws on a line without a colon (malformed).\n *\n * @internal\n */\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: YAML-subset parser handles scalars + multi-line arrays + inline arrays in a single pass; extracting helpers fragments the line-state machine.\nexport function parseSimpleYaml(yaml: string): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n const lines = yaml.split(/\\r?\\n/);\n let i = 0;\n while (i < lines.length) {\n const line = lines[i];\n i += 1;\n if (line === undefined) continue;\n const trimmed = line.trim();\n if (trimmed === \"\" || trimmed.startsWith(\"#\")) continue;\n const colon = trimmed.indexOf(\":\");\n if (colon === -1) throw new Error(`Invalid YAML line: ${trimmed}`);\n const key = trimmed.slice(0, colon).trim();\n const rest = trimmed.slice(colon + 1).trim();\n if (rest === \"\") {\n // Possible array; collect indented `- item` lines.\n const items: string[] = [];\n while (i < lines.length) {\n const next = lines[i];\n if (next === undefined) break;\n const nextTrim = next.trim();\n if (nextTrim.startsWith(\"- \")) {\n items.push(parseScalar(nextTrim.slice(2).trim()) as string);\n i += 1;\n } else if (nextTrim === \"\") {\n i += 1;\n } else {\n break;\n }\n }\n out[key] = items;\n } else if (rest.startsWith(\"[\") && rest.endsWith(\"]\")) {\n // Inline array `globs: [\"**/*.ts\", \"**/*.tsx\"]`\n const inner = rest.slice(1, -1).trim();\n out[key] =\n inner === \"\"\n ? []\n : inner.split(\",\").map((s) => parseScalar(s.trim().replace(/^[\"']|[\"']$/g, \"\")));\n } else {\n out[key] = parseScalar(rest);\n }\n }\n return out;\n}\n\nfunction parseScalar(s: string): string | boolean | number {\n if (s === \"true\") return true;\n if (s === \"false\") return false;\n if (/^-?\\d+$/.test(s)) return parseInt(s, 10);\n // Strip surrounding quotes if present.\n return s.replace(/^[\"']|[\"']$/g, \"\");\n}\n","/**\n * Parser for `.theokit/rules/*.md` — theokit-native path-scoped rules,\n * mirroring Claude Code's `.claude/rules/`.\n *\n * Frontmatter fields:\n * - `paths` — glob-pattern array (Claude Code parity: `.claude/rules` uses `paths:`).\n * - `globs` — glob-pattern array (Cursor-compatible alias; unioned with `paths`).\n * - `alwaysApply` — activate unconditionally (no scope needed).\n * - `enabled` — set `false` to disable the rule entirely (wins over everything).\n * - `description` — human note; not used for activation in v1.\n *\n * Activation (`shouldActivateRule`):\n * - `enabled: false` → never activates.\n * - `alwaysApply: true` → always activates.\n * - otherwise → activates iff a `paths`/`globs` pattern matches an in-scope\n * file (the caller's `agent.send(..., { contextPaths })`). With no in-scope\n * files, a scoped rule stays dormant (parity with Cursor `.mdc`).\n *\n * A file with no `---` frontmatter is treated as an unconditional rule\n * (`alwaysApply: true`). Malformed YAML → `undefined` (caller drops + counts).\n *\n * Glob + YAML subset are shared with the MDC parser (DRY, no new dependency).\n *\n * @internal\n */\n\nimport { z } from \"zod\";\n\nimport { anyGlobMatches } from \"./context-glob.js\";\nimport { parseSimpleYaml, splitFrontmatter } from \"./context-yaml-lite.js\";\n\n/** YAML frontmatter schema for `.theokit/rules/*.md` files. @internal */\nexport const RulesFrontmatterSchema = z.object({\n description: z.string().optional(),\n paths: z.array(z.string()).optional(),\n globs: z.array(z.string()).optional(),\n alwaysApply: z.boolean().optional(),\n enabled: z.boolean().optional(),\n});\n\nexport type RulesFrontmatter = z.infer<typeof RulesFrontmatterSchema>;\n\nexport interface RulesParseResult {\n readonly frontmatter: RulesFrontmatter;\n readonly body: string;\n}\n\n/**\n * Parse `.theokit/rules/*.md` content into frontmatter + body. No frontmatter\n * fence → unconditional rule. Malformed YAML → `undefined`.\n *\n * @internal\n */\nexport function parseRules(content: string): RulesParseResult | undefined {\n const { yaml, body } = splitFrontmatter(content);\n if (yaml === undefined) {\n return { frontmatter: { alwaysApply: true }, body: content };\n }\n try {\n const parsed = parseSimpleYaml(yaml);\n const validated = RulesFrontmatterSchema.safeParse(parsed);\n if (!validated.success) return undefined;\n return { frontmatter: validated.data, body };\n } catch {\n return undefined;\n }\n}\n\n/**\n * Decide whether a rule activates given the in-scope files. `paths` and\n * `globs` are unioned; both are glob patterns matched against the caller's\n * declared scope.\n *\n * @internal\n */\nexport function shouldActivateRule(\n fm: RulesFrontmatter,\n inScopePaths: ReadonlyArray<string>,\n): boolean {\n if (fm.enabled === false) return false;\n if (fm.alwaysApply === true) return true;\n const patterns = [...(fm.paths ?? []), ...(fm.globs ?? [])];\n if (patterns.length === 0) return false;\n return anyGlobMatches(patterns, inScopePaths);\n}\n","/**\n * MDC (Markdown Cursor) parser for `.cursor/rules/*.mdc` (T3.1, ADR D154).\n *\n * Parses YAML frontmatter with `description` / `globs` / `alwaysApply`\n * fields. Honors activation per Cursor's docs:\n * - `alwaysApply: true` → activates unconditionally.\n * - `alwaysApply: false` + matching glob in `touchedFiles` → activates.\n * - `alwaysApply: false` + no glob match → skipped.\n *\n * **EC-I (v1 semantic):** at `agent.send()` time, `touchedFiles` is empty\n * UNLESS the caller passes `contextPaths` (the in-scope file set). When\n * `contextPaths` is provided, per-glob activation fires; otherwise only\n * `alwaysApply: true` rules activate. Description-based \"agent requested\"\n * classification is out of scope.\n *\n * Glob matching + the YAML subset are shared with the `.theokit/rules/*.md`\n * parser via `context-glob.ts` / `context-yaml-lite.ts` (DRY, no new dep).\n *\n * @internal\n */\n\nimport { z } from \"zod\";\n\nimport { anyGlobMatches } from \"./context-glob.js\";\nimport { parseSimpleYaml, splitFrontmatter } from \"./context-yaml-lite.js\";\n\n/** YAML frontmatter schema for MDC files. @internal */\nexport const McdFrontmatterSchema = z.object({\n description: z.string().optional(),\n globs: z.array(z.string()).optional(),\n alwaysApply: z.boolean().optional(),\n});\n\nexport type McdFrontmatter = z.infer<typeof McdFrontmatterSchema>;\n\nexport interface McdParseResult {\n readonly frontmatter: McdFrontmatter;\n readonly body: string;\n}\n\n/**\n * Parse `.mdc` content. Returns frontmatter + body. EC-18: when the\n * file has no `---` frontmatter, returns `frontmatter: {alwaysApply:\n * true}` so the body is treated as an unconditional rule.\n *\n * On YAML parse error, returns `undefined` and the caller emits a\n * telemetry counter (EC-21).\n *\n * @internal\n */\nexport function parseMdc(content: string): McdParseResult | undefined {\n const { yaml, body } = splitFrontmatter(content);\n if (yaml === undefined) {\n // EC-18: no frontmatter — treat as alwaysApply\n return { frontmatter: { alwaysApply: true }, body: content };\n }\n try {\n const parsed = parseSimpleYaml(yaml);\n const validated = McdFrontmatterSchema.safeParse(parsed);\n if (!validated.success) return undefined;\n return { frontmatter: validated.data, body };\n } catch {\n return undefined;\n }\n}\n\n/**\n * Decide whether an MDC rule activates given the currently-touched\n * files. EC-I: empty `touchedFiles` → only `alwaysApply: true`\n * activates.\n *\n * @internal\n */\nexport function shouldActivate(fm: McdFrontmatter, touchedFiles: ReadonlyArray<string>): boolean {\n if (fm.alwaysApply === true) return true;\n if (fm.globs === undefined || fm.globs.length === 0) return false;\n return anyGlobMatches(fm.globs, touchedFiles);\n}\n","/**\n * Multi-format context discovery runner (T5.1, ADRs D150-D156).\n *\n * Walks `DEFAULT_DISCOVERY_SPECS` (or caller override), loads each\n * spec via the appropriate parser, applies `@import` resolution where\n * declared, and returns a flat list of `AggregatorSource[]` ready for\n * the aggregate cap.\n *\n * **EC-E privacy fix:** source disambiguation uses\n * `relative(gitRoot ?? cwd, ...)` — NEVER absolute paths in\n * `<source name=\"\">`.\n *\n * @internal\n */\n\nimport { readFile } from \"node:fs/promises\";\nimport { dirname, relative } from \"node:path\";\n\nimport type { AggregatorSource } from \"./context-aggregator.js\";\nimport {\n DEFAULT_DISCOVERY_SPECS,\n type DiscoverySpec,\n findGitRoot,\n walkUpForFile,\n walkUpForGlob,\n} from \"./context-discovery.js\";\nimport { resolveImports } from \"./context-import-resolver.js\";\nimport { loadPlainMarkdown } from \"./context-loaders.js\";\nimport { parseMdc, shouldActivate } from \"./context-mdc-parser.js\";\nimport { parseRules, shouldActivateRule } from \"./context-rules-frontmatter.js\";\n\nexport interface DiscoveryRunnerOptions {\n /** Workspace root passed to all discovery scopes. */\n readonly cwd: string;\n /** Per-file truncation cap (D155). */\n readonly maxBytesPerFile: number;\n /** Optional override of the default registry. */\n readonly specs?: ReadonlyArray<DiscoverySpec>;\n /** Cursor MDC: file paths the LLM has touched this turn (EC-I: empty at send-time). */\n readonly touchedFiles?: ReadonlyArray<string>;\n /** When true, skip `theokit-context` spec — caller already handles the legacy path. */\n readonly skipLegacyTheokitContext?: boolean;\n /**\n * The root an `@import` may not escape. Defaults to `gitRoot ?? cwd` — the same value\n * this runner already uses to keep absolute paths out of `<source name=\"\">`.\n *\n * Present so an embedder with a trust boundary narrower than the repository can declare\n * it. Absent, the repository IS the boundary, which is the honest default for a document\n * discovered by walking the repository.\n */\n readonly importRoot?: string;\n}\n\n/**\n * Run discovery + loading across all specs. Returns sources ready for\n * the aggregator (priority + content fields populated).\n *\n * @internal\n */\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: per-spec dispatch ladder + cross-spec dedup is a flat orchestrator; splitting would obscure the priority-merge invariant.\nexport async function runDiscovery(opts: DiscoveryRunnerOptions): Promise<AggregatorSource[]> {\n const gitRoot = findGitRoot(opts.cwd);\n const specs = opts.specs ?? DEFAULT_DISCOVERY_SPECS;\n const out: AggregatorSource[] = [];\n const seenReal = new Set<string>();\n\n for (const spec of specs) {\n if (opts.skipLegacyTheokitContext && spec.id === \"theokit-context\") continue;\n const paths = await resolvePathsForSpec(spec, opts.cwd, gitRoot);\n for (const path of paths) {\n if (seenReal.has(path)) continue;\n seenReal.add(path);\n const source = await loadOneSource(spec, path, opts, gitRoot);\n if (source !== undefined) out.push(source);\n }\n }\n return out;\n}\n\nasync function resolvePathsForSpec(\n spec: DiscoverySpec,\n cwd: string,\n gitRoot: string | undefined,\n): Promise<string[]> {\n if (spec.scope === \"cwd-only\") {\n return walkUpForFile(cwd, spec.pattern, cwd);\n }\n if (spec.scope === \"git-root-walk\") {\n return walkUpForFile(cwd, spec.pattern, gitRoot ?? cwd);\n }\n // globbed\n return walkUpForGlob(cwd, spec.pattern);\n}\n\nasync function loadOneSource(\n spec: DiscoverySpec,\n path: string,\n opts: DiscoveryRunnerOptions,\n gitRoot: string | undefined,\n): Promise<AggregatorSource | undefined> {\n // EC-E privacy: name uses relative-to-git-root for disambiguation;\n // NEVER absolute paths in the public `<source name=\"\">` attribute.\n // For cwd-only specs (THEO.md), no disambiguation is needed because\n // the scope can only ever match a single file.\n const relPath = relative(gitRoot ?? opts.cwd, dirname(path));\n const needsSuffix = spec.scope !== \"cwd-only\" && relPath !== \"\" && relPath !== \".\";\n const id = needsSuffix ? `${spec.id}@${relPath}` : spec.id;\n\n if (spec.parser === \"mdc\") {\n return loadMdcSource(spec, path, id, opts);\n }\n if (spec.parser === \"rules-frontmatter\") {\n return loadRulesSource(spec, path, id, opts);\n }\n if (spec.parser === \"frontmatter-zod\") {\n // Legacy `.theokit/context/*.md` — handled by `loadContextConfig` in\n // `context-manager.ts` for backward compat. We skip here unless caller\n // explicitly wants us to load it (currently always skipped).\n return undefined;\n }\n // plain-markdown\n return loadPlainMarkdownSource(spec, path, id, opts, gitRoot);\n}\n\n/**\n * Shared read → parse → activation-gate → source pipeline for the frontmatter\n * discovery parsers (mdc, rules). Binds the parser + the activation predicate so\n * the mdc and rules loaders differ only in those two, not in the surrounding\n * read/guard/shape boilerplate (DRY).\n */\nasync function loadParsedSource<F>(\n spec: DiscoverySpec,\n path: string,\n id: string,\n parse: (raw: string) => { frontmatter: F; body: string } | undefined,\n isActive: (frontmatter: F) => boolean,\n): Promise<AggregatorSource | undefined> {\n let raw: string;\n try {\n raw = await readFile(path, \"utf8\");\n } catch {\n return undefined;\n }\n const parsed = parse(raw);\n if (parsed === undefined || !isActive(parsed.frontmatter)) return undefined;\n return { id, source: path, content: parsed.body, priority: spec.priority, truncated: false };\n}\n\nfunction loadMdcSource(\n spec: DiscoverySpec,\n path: string,\n id: string,\n opts: DiscoveryRunnerOptions,\n): Promise<AggregatorSource | undefined> {\n return loadParsedSource(spec, path, id, parseMdc, (fm) =>\n shouldActivate(fm, opts.touchedFiles ?? []),\n );\n}\n\nfunction loadRulesSource(\n spec: DiscoverySpec,\n path: string,\n id: string,\n opts: DiscoveryRunnerOptions,\n): Promise<AggregatorSource | undefined> {\n return loadParsedSource(spec, path, id, parseRules, (fm) =>\n shouldActivateRule(fm, opts.touchedFiles ?? []),\n );\n}\n\nasync function loadPlainMarkdownSource(\n spec: DiscoverySpec,\n path: string,\n id: string,\n opts: DiscoveryRunnerOptions,\n gitRoot: string | undefined,\n): Promise<AggregatorSource | undefined> {\n const loaded = await loadPlainMarkdown(path, { maxBytesPerFile: opts.maxBytesPerFile });\n if (loaded === undefined) return undefined;\n let content = loaded.content;\n if (spec.followImports) {\n content = await resolveImports(content, path, {\n visited: new Set([path]),\n depth: 0,\n maxBytesPerFile: opts.maxBytesPerFile,\n // The document carrying the import is repository-controlled, so the repository is the\n // boundary it may not cross. Without this, `CLAUDE.md` / `GEMINI.md` — the two specs\n // with `followImports: true` — could name any absolute or `~/` path and have it\n // inlined into the system prompt.\n projectRoot: opts.importRoot ?? gitRoot ?? opts.cwd,\n });\n }\n return {\n id,\n source: path,\n content,\n priority: spec.priority,\n truncated: loaded.truncated,\n };\n}\n"]}
|
package/dist/context/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkGAXYZXYY_cjs = require('../chunk-GAXYZXYY.cjs');
|
|
4
4
|
var chunkYPEPCZHF_cjs = require('../chunk-YPEPCZHF.cjs');
|
|
5
5
|
|
|
6
6
|
// src/context/index.ts
|
|
@@ -11,20 +11,20 @@ function resolveContextImports(content, basePath, options) {
|
|
|
11
11
|
maxBytesPerFile: options.maxBytesPerFile,
|
|
12
12
|
projectRoot: options.projectRoot
|
|
13
13
|
};
|
|
14
|
-
return
|
|
14
|
+
return chunkGAXYZXYY_cjs.resolveImports(content, basePath, internalOptions);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
Object.defineProperty(exports, "parseRules", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: function () { return
|
|
19
|
+
get: function () { return chunkGAXYZXYY_cjs.parseRules; }
|
|
20
20
|
});
|
|
21
21
|
Object.defineProperty(exports, "runDiscovery", {
|
|
22
22
|
enumerable: true,
|
|
23
|
-
get: function () { return
|
|
23
|
+
get: function () { return chunkGAXYZXYY_cjs.runDiscovery; }
|
|
24
24
|
});
|
|
25
25
|
Object.defineProperty(exports, "shouldActivateRule", {
|
|
26
26
|
enumerable: true,
|
|
27
|
-
get: function () { return
|
|
27
|
+
get: function () { return chunkGAXYZXYY_cjs.shouldActivateRule; }
|
|
28
28
|
});
|
|
29
29
|
Object.defineProperty(exports, "DEFAULT_DISCOVERY_SPECS", {
|
|
30
30
|
enumerable: true,
|
package/dist/context/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { resolveImports } from '../chunk-
|
|
2
|
-
export { parseRules, runDiscovery, shouldActivateRule } from '../chunk-
|
|
1
|
+
import { resolveImports } from '../chunk-ZZAAQOAZ.js';
|
|
2
|
+
export { parseRules, runDiscovery, shouldActivateRule } from '../chunk-ZZAAQOAZ.js';
|
|
3
3
|
export { DEFAULT_DISCOVERY_SPECS } from '../chunk-UJ7IQJAG.js';
|
|
4
4
|
|
|
5
5
|
// src/context/index.ts
|
package/dist/cron.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunkHLGEXZZP_cjs = require('./chunk-HLGEXZZP.cjs');
|
|
4
|
+
require('./chunk-4OQXDCMN.cjs');
|
|
5
5
|
require('./chunk-FAUKVJCC.cjs');
|
|
6
6
|
require('./chunk-BV2MWEMV.cjs');
|
|
7
7
|
require('./chunk-KCQUYQ3V.cjs');
|
|
@@ -14,7 +14,7 @@ require('./chunk-FZ4YMZA3.cjs');
|
|
|
14
14
|
require('./chunk-GH52NOCL.cjs');
|
|
15
15
|
require('./chunk-HECR7KF5.cjs');
|
|
16
16
|
require('./chunk-BBZYXVLZ.cjs');
|
|
17
|
-
require('./chunk-
|
|
17
|
+
require('./chunk-GAXYZXYY.cjs');
|
|
18
18
|
require('./chunk-6X2HUT4A.cjs');
|
|
19
19
|
require('./chunk-7PESI6YD.cjs');
|
|
20
20
|
require('./chunk-S4Q5OMIK.cjs');
|
|
@@ -51,7 +51,7 @@ require('./chunk-ZHPET3LZ.cjs');
|
|
|
51
51
|
|
|
52
52
|
Object.defineProperty(exports, "Cron", {
|
|
53
53
|
enumerable: true,
|
|
54
|
-
get: function () { return
|
|
54
|
+
get: function () { return chunkHLGEXZZP_cjs.Cron; }
|
|
55
55
|
});
|
|
56
56
|
//# sourceMappingURL=cron.cjs.map
|
|
57
57
|
//# sourceMappingURL=cron.cjs.map
|
package/dist/cron.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { Cron } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { Cron } from './chunk-O67XODD5.js';
|
|
2
|
+
import './chunk-V5V5A6B7.js';
|
|
3
3
|
import './chunk-UJ7HK7BX.js';
|
|
4
4
|
import './chunk-2SFBB54R.js';
|
|
5
5
|
import './chunk-GNMPCZNN.js';
|
|
@@ -12,7 +12,7 @@ import './chunk-ZTEAJAE6.js';
|
|
|
12
12
|
import './chunk-RJBHWM6D.js';
|
|
13
13
|
import './chunk-J5RW43IR.js';
|
|
14
14
|
import './chunk-AM2CNBKE.js';
|
|
15
|
-
import './chunk-
|
|
15
|
+
import './chunk-ZZAAQOAZ.js';
|
|
16
16
|
import './chunk-ZS6SLELQ.js';
|
|
17
17
|
import './chunk-LLE7HPRI.js';
|
|
18
18
|
import './chunk-SNKY3C2L.js';
|
package/dist/eval.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkR3CKCRK3_cjs = require('./chunk-R3CKCRK3.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunk4OQXDCMN_cjs = require('./chunk-4OQXDCMN.cjs');
|
|
5
5
|
require('./chunk-FAUKVJCC.cjs');
|
|
6
6
|
require('./chunk-BV2MWEMV.cjs');
|
|
7
7
|
require('./chunk-KCQUYQ3V.cjs');
|
|
@@ -14,7 +14,7 @@ require('./chunk-FZ4YMZA3.cjs');
|
|
|
14
14
|
require('./chunk-GH52NOCL.cjs');
|
|
15
15
|
require('./chunk-HECR7KF5.cjs');
|
|
16
16
|
require('./chunk-BBZYXVLZ.cjs');
|
|
17
|
-
require('./chunk-
|
|
17
|
+
require('./chunk-GAXYZXYY.cjs');
|
|
18
18
|
require('./chunk-6X2HUT4A.cjs');
|
|
19
19
|
require('./chunk-7PESI6YD.cjs');
|
|
20
20
|
require('./chunk-S4Q5OMIK.cjs');
|
|
@@ -774,7 +774,7 @@ function makeDefaultEmbedder(opts) {
|
|
|
774
774
|
let runtime;
|
|
775
775
|
return (texts) => {
|
|
776
776
|
if (runtime === void 0) {
|
|
777
|
-
runtime =
|
|
777
|
+
runtime = chunk4OQXDCMN_cjs.openRouterMemoryEmbeddingProviderAdapter.create(embedderCreateOptions(opts));
|
|
778
778
|
}
|
|
779
779
|
return runtime.then((rt) => rt.embed(texts));
|
|
780
780
|
};
|
package/dist/eval.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { shellEscapePosix, LocalSandbox } from './chunk-DEZ75ET5.js';
|
|
2
|
-
import { openRouterMemoryEmbeddingProviderAdapter } from './chunk-
|
|
2
|
+
import { openRouterMemoryEmbeddingProviderAdapter } from './chunk-V5V5A6B7.js';
|
|
3
3
|
import './chunk-UJ7HK7BX.js';
|
|
4
4
|
import './chunk-2SFBB54R.js';
|
|
5
5
|
import './chunk-GNMPCZNN.js';
|
|
@@ -12,7 +12,7 @@ import './chunk-ZTEAJAE6.js';
|
|
|
12
12
|
import './chunk-RJBHWM6D.js';
|
|
13
13
|
import './chunk-J5RW43IR.js';
|
|
14
14
|
import './chunk-AM2CNBKE.js';
|
|
15
|
-
import './chunk-
|
|
15
|
+
import './chunk-ZZAAQOAZ.js';
|
|
16
16
|
import './chunk-ZS6SLELQ.js';
|
|
17
17
|
import './chunk-LLE7HPRI.js';
|
|
18
18
|
import './chunk-SNKY3C2L.js';
|
package/dist/index.cjs
CHANGED
|
@@ -8,8 +8,8 @@ require('./chunk-WIGJGFH4.cjs');
|
|
|
8
8
|
var chunkJO76RWCA_cjs = require('./chunk-JO76RWCA.cjs');
|
|
9
9
|
require('./chunk-RBQYHEZD.cjs');
|
|
10
10
|
require('./chunk-PNVDQL5Y.cjs');
|
|
11
|
-
var
|
|
12
|
-
var
|
|
11
|
+
var chunkHLGEXZZP_cjs = require('./chunk-HLGEXZZP.cjs');
|
|
12
|
+
var chunk4OQXDCMN_cjs = require('./chunk-4OQXDCMN.cjs');
|
|
13
13
|
require('./chunk-FAUKVJCC.cjs');
|
|
14
14
|
require('./chunk-BV2MWEMV.cjs');
|
|
15
15
|
var chunkKCQUYQ3V_cjs = require('./chunk-KCQUYQ3V.cjs');
|
|
@@ -22,7 +22,7 @@ require('./chunk-FZ4YMZA3.cjs');
|
|
|
22
22
|
var chunkGH52NOCL_cjs = require('./chunk-GH52NOCL.cjs');
|
|
23
23
|
require('./chunk-HECR7KF5.cjs');
|
|
24
24
|
require('./chunk-BBZYXVLZ.cjs');
|
|
25
|
-
require('./chunk-
|
|
25
|
+
require('./chunk-GAXYZXYY.cjs');
|
|
26
26
|
require('./chunk-6X2HUT4A.cjs');
|
|
27
27
|
require('./chunk-7PESI6YD.cjs');
|
|
28
28
|
require('./chunk-S4Q5OMIK.cjs');
|
|
@@ -63,8 +63,8 @@ var fs = require('fs');
|
|
|
63
63
|
// src/agent-factory.ts
|
|
64
64
|
function createAgentFactory(common) {
|
|
65
65
|
return {
|
|
66
|
-
forSession: (agentId, overrides) =>
|
|
67
|
-
getOrCreate: (agentId, overrides) =>
|
|
66
|
+
forSession: (agentId, overrides) => chunk4OQXDCMN_cjs.Agent.create(mergeAgentOptions(common, overrides, agentId)),
|
|
67
|
+
getOrCreate: (agentId, overrides) => chunk4OQXDCMN_cjs.Agent.getOrCreate(agentId, mergeAgentOptions(common, overrides, agentId))
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
function mergeAgentOptions(common, overrides, agentId) {
|
|
@@ -1168,7 +1168,7 @@ var Memory = {
|
|
|
1168
1168
|
return await peer.IndexManager.open(openArgs);
|
|
1169
1169
|
}
|
|
1170
1170
|
const { IndexManager } = await import('./index-manager-YFFEPISE.cjs');
|
|
1171
|
-
openArgs.embedding = await resolveEmbedding(opts.embedding,
|
|
1171
|
+
openArgs.embedding = await resolveEmbedding(opts.embedding, chunk4OQXDCMN_cjs.MEMORY_EMBEDDING_ADAPTERS);
|
|
1172
1172
|
return await IndexManager.open(openArgs);
|
|
1173
1173
|
},
|
|
1174
1174
|
/**
|
|
@@ -1179,7 +1179,7 @@ var Memory = {
|
|
|
1179
1179
|
*/
|
|
1180
1180
|
async runDreamingSweep(opts) {
|
|
1181
1181
|
const peer = await tryLoadSdkMemoryPeer();
|
|
1182
|
-
const catalog = peer !== null ? peer.MEMORY_EMBEDDING_ADAPTERS :
|
|
1182
|
+
const catalog = peer !== null ? peer.MEMORY_EMBEDDING_ADAPTERS : chunk4OQXDCMN_cjs.MEMORY_EMBEDDING_ADAPTERS;
|
|
1183
1183
|
const sweepArgs = await buildDreamingSweepArgs(opts, catalog);
|
|
1184
1184
|
const result = peer !== null ? (
|
|
1185
1185
|
// biome-ignore lint/suspicious/noExplicitAny: peer is dynamically loaded — structural compat ensured by sdk-memory
|
|
@@ -1601,7 +1601,7 @@ function isBuiltAgent(m) {
|
|
|
1601
1601
|
return typeof m.send === "function";
|
|
1602
1602
|
}
|
|
1603
1603
|
async function materialize(def, index) {
|
|
1604
|
-
const { Agent: Agent2 } = await import('./agent-
|
|
1604
|
+
const { Agent: Agent2 } = await import('./agent-DRUORJTU.cjs');
|
|
1605
1605
|
return Agent2.create({
|
|
1606
1606
|
// `AgentDefinition.model` admits the sentinel `'inherit'`, which is not a model id. Inheriting
|
|
1607
1607
|
// here means "declare nothing and let the default apply" — forwarding the literal would create
|
|
@@ -1743,7 +1743,7 @@ var FIXTURE_USER = {
|
|
|
1743
1743
|
};
|
|
1744
1744
|
var FIXTURE_MODELS = [
|
|
1745
1745
|
{
|
|
1746
|
-
id:
|
|
1746
|
+
id: chunk4OQXDCMN_cjs.DEFAULT_AGENTIC_MODEL_ID,
|
|
1747
1747
|
name: "Gemini 2.0 Flash",
|
|
1748
1748
|
displayName: "Gemini 2.0 Flash",
|
|
1749
1749
|
parameters: [
|
|
@@ -1946,7 +1946,7 @@ var Theokit = class {
|
|
|
1946
1946
|
envVars: p.envVars
|
|
1947
1947
|
}));
|
|
1948
1948
|
},
|
|
1949
|
-
embeddingAdapters: () => Object.entries(
|
|
1949
|
+
embeddingAdapters: () => Object.entries(chunk4OQXDCMN_cjs.MEMORY_EMBEDDING_ADAPTERS).map(([id, adapter]) => ({
|
|
1950
1950
|
id,
|
|
1951
1951
|
transport: adapter.transport,
|
|
1952
1952
|
defaultModel: adapter.defaultModel
|
|
@@ -1978,7 +1978,7 @@ function resolveLocalProviderBaseUrl(providerName, fallback) {
|
|
|
1978
1978
|
return fallback;
|
|
1979
1979
|
}
|
|
1980
1980
|
async function executeCatalogRequest(request) {
|
|
1981
|
-
const apiKey =
|
|
1981
|
+
const apiKey = chunk4OQXDCMN_cjs.resolveApiKey(request.apiKey);
|
|
1982
1982
|
if (apiKey === void 0) {
|
|
1983
1983
|
throw new chunkYULF6FPB_cjs.AuthenticationError("Missing API key", { code: "missing_api_key" });
|
|
1984
1984
|
}
|
|
@@ -2104,35 +2104,35 @@ Object.defineProperty(exports, "GenerateObjectError", {
|
|
|
2104
2104
|
});
|
|
2105
2105
|
Object.defineProperty(exports, "Cron", {
|
|
2106
2106
|
enumerable: true,
|
|
2107
|
-
get: function () { return
|
|
2107
|
+
get: function () { return chunkHLGEXZZP_cjs.Cron; }
|
|
2108
2108
|
});
|
|
2109
2109
|
Object.defineProperty(exports, "Agent", {
|
|
2110
2110
|
enumerable: true,
|
|
2111
|
-
get: function () { return
|
|
2111
|
+
get: function () { return chunk4OQXDCMN_cjs.Agent; }
|
|
2112
2112
|
});
|
|
2113
2113
|
Object.defineProperty(exports, "AgentBuilder", {
|
|
2114
2114
|
enumerable: true,
|
|
2115
|
-
get: function () { return
|
|
2115
|
+
get: function () { return chunk4OQXDCMN_cjs.AgentBuilder; }
|
|
2116
2116
|
});
|
|
2117
2117
|
Object.defineProperty(exports, "Tool", {
|
|
2118
2118
|
enumerable: true,
|
|
2119
|
-
get: function () { return
|
|
2119
|
+
get: function () { return chunk4OQXDCMN_cjs.Tool; }
|
|
2120
2120
|
});
|
|
2121
2121
|
Object.defineProperty(exports, "ToolError", {
|
|
2122
2122
|
enumerable: true,
|
|
2123
|
-
get: function () { return
|
|
2123
|
+
get: function () { return chunk4OQXDCMN_cjs.ToolError; }
|
|
2124
2124
|
});
|
|
2125
2125
|
Object.defineProperty(exports, "UsageAccumulator", {
|
|
2126
2126
|
enumerable: true,
|
|
2127
|
-
get: function () { return
|
|
2127
|
+
get: function () { return chunk4OQXDCMN_cjs.UsageAccumulator; }
|
|
2128
2128
|
});
|
|
2129
2129
|
Object.defineProperty(exports, "computeCost", {
|
|
2130
2130
|
enumerable: true,
|
|
2131
|
-
get: function () { return
|
|
2131
|
+
get: function () { return chunk4OQXDCMN_cjs.computeCost; }
|
|
2132
2132
|
});
|
|
2133
2133
|
Object.defineProperty(exports, "getPricingEntry", {
|
|
2134
2134
|
enumerable: true,
|
|
2135
|
-
get: function () { return
|
|
2135
|
+
get: function () { return chunk4OQXDCMN_cjs.getPricingEntry; }
|
|
2136
2136
|
});
|
|
2137
2137
|
Object.defineProperty(exports, "emitRunEvent", {
|
|
2138
2138
|
enumerable: true,
|
package/dist/index.js
CHANGED
|
@@ -6,9 +6,9 @@ import './chunk-O3IZ7JEL.js';
|
|
|
6
6
|
import { Workflow, agentStep } from './chunk-EON4YTR6.js';
|
|
7
7
|
import './chunk-HK4HRLWE.js';
|
|
8
8
|
import './chunk-CAH3G4IS.js';
|
|
9
|
-
export { Cron } from './chunk-
|
|
10
|
-
import { MEMORY_EMBEDDING_ADAPTERS, resolveApiKey, DEFAULT_AGENTIC_MODEL_ID, Agent } from './chunk-
|
|
11
|
-
export { Agent, AgentBuilder, Tool, ToolError, UsageAccumulator, computeCost, getPricingEntry } from './chunk-
|
|
9
|
+
export { Cron } from './chunk-O67XODD5.js';
|
|
10
|
+
import { MEMORY_EMBEDDING_ADAPTERS, resolveApiKey, DEFAULT_AGENTIC_MODEL_ID, Agent } from './chunk-V5V5A6B7.js';
|
|
11
|
+
export { Agent, AgentBuilder, Tool, ToolError, UsageAccumulator, computeCost, getPricingEntry } from './chunk-V5V5A6B7.js';
|
|
12
12
|
import './chunk-UJ7HK7BX.js';
|
|
13
13
|
import './chunk-2SFBB54R.js';
|
|
14
14
|
import { configure, submit, list, get, cancel, subscribe } from './chunk-GNMPCZNN.js';
|
|
@@ -22,7 +22,7 @@ import './chunk-ZTEAJAE6.js';
|
|
|
22
22
|
import { lanceStoragePath, LanceIndex, readFactsFromMarkdown, defaultIndexPath, openMemoryDb, memoryDir } from './chunk-RJBHWM6D.js';
|
|
23
23
|
import './chunk-J5RW43IR.js';
|
|
24
24
|
import './chunk-AM2CNBKE.js';
|
|
25
|
-
import './chunk-
|
|
25
|
+
import './chunk-ZZAAQOAZ.js';
|
|
26
26
|
import './chunk-ZS6SLELQ.js';
|
|
27
27
|
import './chunk-LLE7HPRI.js';
|
|
28
28
|
import './chunk-SNKY3C2L.js';
|
|
@@ -1604,7 +1604,7 @@ function isBuiltAgent(m) {
|
|
|
1604
1604
|
return typeof m.send === "function";
|
|
1605
1605
|
}
|
|
1606
1606
|
async function materialize(def, index) {
|
|
1607
|
-
const { Agent: Agent2 } = await import('./agent-
|
|
1607
|
+
const { Agent: Agent2 } = await import('./agent-MVYGMWPM.js');
|
|
1608
1608
|
return Agent2.create({
|
|
1609
1609
|
// `AgentDefinition.model` admits the sentinel `'inherit'`, which is not a model id. Inheriting
|
|
1610
1610
|
// here means "declare nothing and let the default apply" — forwarding the literal would create
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one rule for "is this resolved path inside that root".
|
|
3
|
+
*
|
|
4
|
+
* Extracted because the package held it twice, at different strengths, for the same question. The
|
|
5
|
+
* correct version lived as a private function in `context-import-resolver.ts`, written for the
|
|
6
|
+
* 4.41.1 patch; the context manager had its own `absolute.startsWith(resolvePath(cwd))`, which
|
|
7
|
+
* admits two escapes:
|
|
8
|
+
*
|
|
9
|
+
* - **No separator boundary.** With `root = /home/user/proj`, the path `/home/user/proj-evil/x`
|
|
10
|
+
* starts with the root string and is NOT inside it. A sibling directory whose name merely
|
|
11
|
+
* extends the project's is enough; no `..` past the parent is needed.
|
|
12
|
+
* - **Lexical, not real.** A symlink whose name sits inside the root and whose target does not
|
|
13
|
+
* passes any comparison made before symlink resolution.
|
|
14
|
+
*
|
|
15
|
+
* The obvious escapes (`../../etc/passwd`, an absolute path) ARE refused by a prefix test, which is
|
|
16
|
+
* why the weaker version survived review: it looks like it works on the inputs a reader tries.
|
|
17
|
+
*
|
|
18
|
+
* Both readers of repository-supplied paths now share this module. That is DRY about the RULE
|
|
19
|
+
* rather than about line count — one piece of knowledge, one representation, so the two cannot
|
|
20
|
+
* drift apart again.
|
|
21
|
+
*
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export {};
|