@theokit/sdk 4.41.1 → 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 +60 -0
- package/dist/{agent-JDJEBJHU.cjs → agent-DRUORJTU.cjs} +8 -7
- package/dist/{agent-JDJEBJHU.cjs.map → agent-DRUORJTU.cjs.map} +1 -1
- package/dist/{agent-LVKAYADR.js → agent-MVYGMWPM.js} +7 -6
- package/dist/{agent-LVKAYADR.js.map → agent-MVYGMWPM.js.map} +1 -1
- package/dist/{chunk-RPL3POFZ.cjs → chunk-4OQXDCMN.cjs} +50 -380
- package/dist/chunk-4OQXDCMN.cjs.map +1 -0
- 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-GAXYZXYY.cjs +352 -0
- package/dist/chunk-GAXYZXYY.cjs.map +1 -0
- package/dist/{chunk-GTLH2NI2.cjs → chunk-HLGEXZZP.cjs} +5 -5
- package/dist/{chunk-GTLH2NI2.cjs.map → chunk-HLGEXZZP.cjs.map} +1 -1
- package/dist/{chunk-AUMSEL33.js → chunk-O67XODD5.js} +3 -3
- package/dist/{chunk-AUMSEL33.js.map → chunk-O67XODD5.js.map} +1 -1
- 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-DHLVOLUX.js → chunk-V5V5A6B7.js} +12 -342
- package/dist/chunk-V5V5A6B7.js.map +1 -0
- package/dist/chunk-ZZAAQOAZ.js +344 -0
- package/dist/chunk-ZZAAQOAZ.js.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/path-containment.d.ts +24 -0
- package/package.json +23 -12
- package/dist/chunk-DHLVOLUX.js.map +0 -1
- package/dist/chunk-RPL3POFZ.cjs.map +0 -1
|
@@ -46,7 +46,7 @@ function persistTurnToTranscript(store, loc, sessionId, turn, onCompact) {
|
|
|
46
46
|
const count = (recordCounts.get(key) ?? 0) + 1;
|
|
47
47
|
recordCounts.set(key, count);
|
|
48
48
|
if (turn.autoCompact !== void 0) {
|
|
49
|
-
const { autoCompactIfNeeded } = await import('./compact-session-
|
|
49
|
+
const { autoCompactIfNeeded } = await import('./compact-session-GF2CBKXB.js');
|
|
50
50
|
const fired = await autoCompactIfNeeded({
|
|
51
51
|
store,
|
|
52
52
|
loc,
|
|
@@ -105,5 +105,5 @@ function enqueueSessionWrite(cwd, agentId, fn) {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
export { appendSessionMessage, clearSession, discardSession, enqueueSessionWrite, flushSessionWrites, getSessionMessages, hydrateSession, persistTurnToTranscript };
|
|
108
|
-
//# sourceMappingURL=chunk-
|
|
109
|
-
//# sourceMappingURL=chunk-
|
|
108
|
+
//# sourceMappingURL=chunk-UJ7HK7BX.js.map
|
|
109
|
+
//# sourceMappingURL=chunk-UJ7HK7BX.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internal/session/agent-session.ts"],"names":[],"mappings":";;;;;AAwCA,IAAM,aAAA,uBAAoB,GAAA,EAA2B;AACrD,IAAM,YAAA,uBAAmB,GAAA,EAAoB;AAStC,SAAS,oBAAA,CAAqB,SAAiB,OAAA,EAA+B;AACnF,EAAA,MAAM,QAAA,GAAW,QAAA,CAAS,GAAA,CAAI,OAAO,KAAK,EAAC;AAC3C,EAAA,QAAA,CAAS,KAAK,OAAO,CAAA;AAIrB,EAAA,QAAA,CAAS,OAAO,OAAO,CAAA;AACvB,EAAA,QAAA,CAAS,GAAA,CAAI,SAAS,QAAQ,CAAA;AAC9B,EAAA,cAAA,EAAe;AACjB;AAWO,IAAM,mBAAA,GAAsB,EAAA;AAEnC,SAAS,cAAA,GAAuB;AAC9B,EAAA,OAAO,QAAA,CAAS,OAAO,mBAAA,EAAqB;AAC1C,IAAA,MAAM,MAAA,GAAS,QAAA,CAAS,IAAA,EAAK,CAAE,MAAK,CAAE,KAAA;AACtC,IAAA,IAAI,WAAW,MAAA,EAAW;AAC1B,IAAA,QAAA,CAAS,OAAO,MAAM,CAAA;AACtB,IAAA,iBAAA,CAAkB,MAAM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A,EAAA,OAAO,MAAA;AACT","file":"chunk-IMX5YODO.js","sourcesContent":["import type { SessionStore } from \"../../types/session-store.js\";\nimport {\n type PersistTurnInput,\n persistTurn,\n readSessionMessages,\n type TranscriptLocation,\n} from \"./agent-session-store.js\";\n\n/**\n * Per-agent conversation history kept across runs (and across `Agent.resume()`\n * within the same process). Lets the fixture responder recall prior facts when\n * the user asks a follow-up question.\n *\n * SE40 — disk persistence IS the native Claude-shaped `.jsonl` transcript. The\n * in-memory cache holds the narrowed `SessionMessage[]` (user/assistant text) so\n * a send can read `priorMessages` synchronously; the whole rich turn (user +\n * assistant + tool blocks) lands on disk once per send via {@link persistTurnToTranscript}\n * (fed by `run.conversation()`). Hydration on resume reconstructs the session by\n * walking the transcript DAG (`readSessionMessages`).\n *\n * @internal\n */\n\n// `SessionMessage` lives in `./session-types.ts` (leaf types file). Re-exported\n// for back-compat with downstream importers that pulled it from here.\nexport type { SessionMessage } from \"./session-types.js\";\n\nimport type { SessionMessage } from \"./session-types.js\";\n\n// M75 — the cache lives in a leaf; see session-cache.ts for the reason (cycle broken by extraction).\nexport {\n hydratedKeys,\n invalidateSessionCache,\n sessions,\n transcriptKey,\n} from \"./session-cache.js\";\n\nimport { diag } from \"../diagnostics.js\";\nimport { hydratedKeys, sessions, transcriptKey } from \"./session-cache.js\";\n\nconst pendingWrites = new Map<string, Promise<void>>();\nconst recordCounts = new Map<string, number>();\n\n/**\n * Append a session message to the in-memory cache only. Disk persistence for the\n * whole turn happens once per send via {@link persistTurnToTranscript}; the cache\n * feeds `priorMessages` / `onBeforeSend.previousMessageCount` synchronously.\n *\n * @internal\n */\nexport function appendSessionMessage(agentId: string, message: SessionMessage): void {\n const existing = sessions.get(agentId) ?? [];\n existing.push(message);\n // `delete` + `set` reinserts at the END: a JS `Map` preserves insertion order, so the first key\n // is always the least recently touched. That is the entire LRU, with no new structure (parsimony\n // rungs 2/5 — the ordering we need is already a language guarantee).\n sessions.delete(agentId);\n sessions.set(agentId, existing);\n enforceCeiling();\n}\n\n/**\n * Ceiling on sessions kept in memory.\n *\n * The runtime only reads the **active** session; the rest is pure cache, rebuildable from the\n * on-disk transcript. 32 is deliberately generous — the primary removal path is the explicit\n * `discardSession()` at the end of the agent's life, and this ceiling is a safety net against a\n * long-lived process running hundreds of sessions (plan risk #2: a tight ceiling could evict a\n * session still referenced by an in-flight async path).\n */\nexport const MAX_CACHED_SESSIONS = 32;\n\nfunction enforceCeiling(): void {\n while (sessions.size > MAX_CACHED_SESSIONS) {\n const oldest = sessions.keys().next().value;\n if (oldest === undefined) return;\n sessions.delete(oldest);\n forgetBookkeeping(oldest);\n }\n}\n\n/**\n * Erases the bookkeeping for an `agentId` across EVERY `cwd` it appears in.\n *\n * The three maps are keyed by `transcriptKey(cwd, agentId)`; `sessions` is the only one keyed by the\n * raw `agentId`. The ceiling's first version deleted from all three using `sessions`' key — that is,\n * deleted nothing — and left `hydratedKeys` **orphaned**. Since `hydrateSession` returns early when\n * the marker is present, an evicted session came back **empty** instead of rehydrating from disk:\n * silent amnesia, and a regression new to M95, because before it nothing evicted.\n *\n * The ceiling only knows the `agentId`, not the `cwd`, so it scans by suffix — which is the format\n * `transcriptKey` produces. A scan rather than an index because these maps hold tens of entries, not\n * thousands: a reverse index here would be new structure for a problem that does not exist.\n */\nfunction forgetBookkeeping(agentId: string): void {\n const suffix = transcriptKey(\"\", agentId).slice(0 - agentId.length - 2);\n for (const k of [...hydratedKeys]) if (k.endsWith(suffix)) hydratedKeys.delete(k);\n for (const k of [...pendingWrites.keys()]) if (k.endsWith(suffix)) pendingWrites.delete(k);\n for (const k of [...recordCounts.keys()]) if (k.endsWith(suffix)) recordCounts.delete(k);\n}\n\n/**\n * Erases the agent's module bookkeeping and returns how many entries were removed.\n *\n * M95 — `invalidateSessionCache` used to clear **two** of the four maps (`sessions`, `hydratedKeys`);\n * `pendingWrites` and `recordCounts` were never touched by id, so they grew for the life of the\n * process. Neither is large per entry — the leak is in count, not volume — but a cache with no owner\n * for removal is a cache that only grows.\n *\n * Returns the count so the caller can prove the removal; a second discard returns 0, which is what\n * makes the idempotency test possible without exposing the maps.\n */\nexport function discardSession(cwd: string, agentId: string): number {\n const key = transcriptKey(cwd, agentId);\n let removed = 0;\n // `sessions` is NOT erased here — and the distinction is measured, not aesthetic. It holds the\n // readable conversation, and there is a legitimate reader AFTER dispose: the golden\n // `two-concurrent-sends-serialize` calls `getSessionMessages(agentId)` after `agent.dispose()`.\n // Erasing it here returned an empty list and broke two goldens. What bounds it is the LRU ceiling\n // above; the three below are pure bookkeeping, with no post-dispose reader.\n //\n // The key is `transcriptKey(cwd, agentId)` in ALL THREE — not the raw `agentId`. The first version\n // erased two of them by `agentId` and therefore **never erased anything**; the test did not catch\n // it because it only asserted that the SECOND call returns 0, which is true either way.\n if (hydratedKeys.delete(key)) removed++;\n if (pendingWrites.delete(key)) removed++;\n if (recordCounts.delete(key)) removed++;\n return removed;\n}\n\nexport function getSessionMessages(agentId: string): SessionMessage[] {\n return sessions.get(agentId) ?? [];\n}\n\n/**\n * Persist a full conversation turn (user + assistant + tool blocks) to the native\n * transcript. Chained per-(agent, transcript) so on-disk order matches send order,\n * and fire-and-forget so `send()` is not blocked by disk I/O. Every\n * M50 — when the caller supplies `turn.autoCompact`, size-driven auto-compaction (usage real vs\n * the model's context window) runs in this same chain, surfaced via the optional `onCompact` observer.\n *\n * @internal\n */\nexport function persistTurnToTranscript(\n store: SessionStore,\n loc: TranscriptLocation,\n sessionId: string,\n turn: PersistTurnInput,\n onCompact?: () => void,\n): void {\n const key = transcriptKey(loc.cwd, loc.agentId);\n // PRE-EXISTING debt, exposed when M75 fixed the Biome config that used to abort before\n // sweeping these files (a nested root under refactor/). It is not new code and was not touched\n // by M75; refactoring SDK internals without review would trade a visible problem for a diff\n // risky. Tracked in usetheodev/theokit-sdk#151.\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: see the reason just above\n const chained = (pendingWrites.get(key) ?? Promise.resolve()).then(async () => {\n try {\n await persistTurn(store, loc, sessionId, turn);\n const count = (recordCounts.get(key) ?? 0) + 1;\n recordCounts.set(key, count);\n // M50 — the 50-turn no-summary boundary stub is GONE (it silently amnesia'd the session).\n // Auto-compaction is now size-driven with a real summary: see `maybeAutoCompact` below,\n // invoked in this same write chain by the post-run lifecycle when usage is known.\n if (turn.autoCompact !== undefined) {\n const { autoCompactIfNeeded } = await import(\"./compact-session.js\");\n const fired = await autoCompactIfNeeded({\n store,\n loc,\n sessionId,\n usageTotal: turn.autoCompact.usageTotal,\n contextWindow: turn.autoCompact.contextWindow,\n turnCount: count,\n summarize: turn.autoCompact.summarize,\n });\n if (fired) onCompact?.();\n }\n } catch (cause) {\n const msg = cause instanceof Error ? cause.message : String(cause);\n diag(`[theokit-sdk] session transcript write failed (${loc.agentId}): ${msg}\\n`);\n }\n });\n pendingWrites.set(\n key,\n chained.then(\n () => undefined,\n () => undefined,\n ),\n );\n}\n\n/**\n * Load the persisted transcript into the in-memory cache. Idempotent per\n * (baseDir, cwd, agentId). Call once per agent lifecycle before the first read.\n *\n * @internal\n */\nexport async function hydrateSession(\n agentId: string,\n loc: { store: SessionStore; cwd: string },\n): Promise<void> {\n const key = transcriptKey(loc.cwd, agentId);\n if (hydratedKeys.has(key)) return;\n hydratedKeys.add(key);\n\n const persisted = await readSessionMessages(loc.store, agentId);\n if (persisted.length === 0) return;\n // M51 review F4 — the DISK is the source of truth at hydration time: after an invalidation\n // (compact/inject), an in-flight turn may have repopulated the cache with a SINGLE message before\n // this hydrate ran; the old \"skip when non-empty\" guard then pinned the parent to a 1-message\n // context (history + injected pair lost until restart). The persist chain serializes writes, so\n // the disk already contains that in-flight turn — replacing is always correct.\n sessions.set(agentId, persisted);\n}\n\n/**\n * Wait for all pending transcript writes to settle. Used by tests and by the\n * agent dispose path so on-disk state matches in-memory before the caller proceeds.\n *\n * @internal\n */\nexport async function flushSessionWrites(): Promise<void> {\n while (pendingWrites.size > 0) {\n const all = Array.from(pendingWrites.values());\n pendingWrites.clear();\n await Promise.all(all);\n }\n}\n\nexport function clearSession(agentId: string): void {\n sessions.delete(agentId);\n}\n\n/**\n * M50 review F1 — drop BOTH the message cache and the hydration marker so the NEXT send re-hydrates\n * from disk. Without this, a compaction only helps after a process restart: the live process keeps\n * sending the full pre-compact history (the cache is read synchronously by every send).\n */\n/**\n * M50 review F5 — run `fn` serialized on the SAME per-(cwd,agentId) write chain the per-turn\n * persistence uses, so a manual `Agent.compact` can never interleave with an in-flight turn's\n * writes (boundary landing mid-turn would orphan the turn from the replay).\n */\nexport function enqueueSessionWrite<T>(\n cwd: string,\n agentId: string,\n fn: () => Promise<T>,\n): Promise<T> {\n const key = transcriptKey(cwd, agentId);\n const prior = pendingWrites.get(key) ?? Promise.resolve();\n const result = prior.then(fn);\n pendingWrites.set(\n key,\n result.then(\n () => undefined,\n () => undefined,\n ),\n );\n return result;\n}\n\n/** Test-only: drop every cached session and hydration marker. @internal */\nexport function clearAllSessions(): void {\n sessions.clear();\n hydratedKeys.clear();\n recordCounts.clear();\n // M50 review F11 — the auto-compact attempt marks live on globalThis; tests reset them here.\n const g = globalThis as unknown as Record<symbol, Map<string, number>>;\n const sym = Symbol.for(\"theokit-sdk.session.auto-compact-attempts\");\n g[sym]?.clear();\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/internal/session/agent-session.ts"],"names":[],"mappings":";;;;;AAwCA,IAAM,aAAA,uBAAoB,GAAA,EAA2B;AACrD,IAAM,YAAA,uBAAmB,GAAA,EAAoB;AAStC,SAAS,oBAAA,CAAqB,SAAiB,OAAA,EAA+B;AACnF,EAAA,MAAM,QAAA,GAAW,QAAA,CAAS,GAAA,CAAI,OAAO,KAAK,EAAC;AAC3C,EAAA,QAAA,CAAS,KAAK,OAAO,CAAA;AAIrB,EAAA,QAAA,CAAS,OAAO,OAAO,CAAA;AACvB,EAAA,QAAA,CAAS,GAAA,CAAI,SAAS,QAAQ,CAAA;AAC9B,EAAA,cAAA,EAAe;AACjB;AAWO,IAAM,mBAAA,GAAsB,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M,QAAQ,aAAA,CAAc,GAAA,CAAI,GAAG,CAAA,IAAK,QAAQ,OAAA,EAAQ;AACxD,EAAA,MAAM,MAAA,GAAS,KAAA,CAAM,IAAA,CAAK,EAAE,CAAA;AAC5B,EAAA,aAAA,CAAc,GAAA;AAAA,IACZ,GAAA;AAAA,IACA,MAAA,CAAO,IAAA;AAAA,MACL,MAAM,MAAA;AAAA,MACN,MAAM;AAAA;AACR,GACF;AACA,EAAA,OAAO,MAAA;AACT","file":"chunk-UJ7HK7BX.js","sourcesContent":["import type { SessionStore } from \"../../types/session-store.js\";\nimport {\n type PersistTurnInput,\n persistTurn,\n readSessionMessages,\n type TranscriptLocation,\n} from \"./agent-session-store.js\";\n\n/**\n * Per-agent conversation history kept across runs (and across `Agent.resume()`\n * within the same process). Lets the fixture responder recall prior facts when\n * the user asks a follow-up question.\n *\n * SE40 — disk persistence IS the native Claude-shaped `.jsonl` transcript. The\n * in-memory cache holds the narrowed `SessionMessage[]` (user/assistant text) so\n * a send can read `priorMessages` synchronously; the whole rich turn (user +\n * assistant + tool blocks) lands on disk once per send via {@link persistTurnToTranscript}\n * (fed by `run.conversation()`). Hydration on resume reconstructs the session by\n * walking the transcript DAG (`readSessionMessages`).\n *\n * @internal\n */\n\n// `SessionMessage` lives in `./session-types.ts` (leaf types file). Re-exported\n// for back-compat with downstream importers that pulled it from here.\nexport type { SessionMessage } from \"./session-types.js\";\n\nimport type { SessionMessage } from \"./session-types.js\";\n\n// M75 — the cache lives in a leaf; see session-cache.ts for the reason (cycle broken by extraction).\nexport {\n hydratedKeys,\n invalidateSessionCache,\n sessions,\n transcriptKey,\n} from \"./session-cache.js\";\n\nimport { diag } from \"../diagnostics.js\";\nimport { hydratedKeys, sessions, transcriptKey } from \"./session-cache.js\";\n\nconst pendingWrites = new Map<string, Promise<void>>();\nconst recordCounts = new Map<string, number>();\n\n/**\n * Append a session message to the in-memory cache only. Disk persistence for the\n * whole turn happens once per send via {@link persistTurnToTranscript}; the cache\n * feeds `priorMessages` / `onBeforeSend.previousMessageCount` synchronously.\n *\n * @internal\n */\nexport function appendSessionMessage(agentId: string, message: SessionMessage): void {\n const existing = sessions.get(agentId) ?? [];\n existing.push(message);\n // `delete` + `set` reinserts at the END: a JS `Map` preserves insertion order, so the first key\n // is always the least recently touched. That is the entire LRU, with no new structure (parsimony\n // rungs 2/5 — the ordering we need is already a language guarantee).\n sessions.delete(agentId);\n sessions.set(agentId, existing);\n enforceCeiling();\n}\n\n/**\n * Ceiling on sessions kept in memory.\n *\n * The runtime only reads the **active** session; the rest is pure cache, rebuildable from the\n * on-disk transcript. 32 is deliberately generous — the primary removal path is the explicit\n * `discardSession()` at the end of the agent's life, and this ceiling is a safety net against a\n * long-lived process running hundreds of sessions (plan risk #2: a tight ceiling could evict a\n * session still referenced by an in-flight async path).\n */\nexport const MAX_CACHED_SESSIONS = 32;\n\nfunction enforceCeiling(): void {\n while (sessions.size > MAX_CACHED_SESSIONS) {\n const oldest = sessions.keys().next().value;\n if (oldest === undefined) return;\n sessions.delete(oldest);\n forgetBookkeeping(oldest);\n }\n}\n\n/**\n * Erases the bookkeeping for an `agentId` across EVERY `cwd` it appears in.\n *\n * The three maps are keyed by `transcriptKey(cwd, agentId)`; `sessions` is the only one keyed by the\n * raw `agentId`. The ceiling's first version deleted from all three using `sessions`' key — that is,\n * deleted nothing — and left `hydratedKeys` **orphaned**. Since `hydrateSession` returns early when\n * the marker is present, an evicted session came back **empty** instead of rehydrating from disk:\n * silent amnesia, and a regression new to M95, because before it nothing evicted.\n *\n * The ceiling only knows the `agentId`, not the `cwd`, so it scans by suffix — which is the format\n * `transcriptKey` produces. A scan rather than an index because these maps hold tens of entries, not\n * thousands: a reverse index here would be new structure for a problem that does not exist.\n */\nfunction forgetBookkeeping(agentId: string): void {\n const suffix = transcriptKey(\"\", agentId).slice(0 - agentId.length - 2);\n for (const k of [...hydratedKeys]) if (k.endsWith(suffix)) hydratedKeys.delete(k);\n for (const k of [...pendingWrites.keys()]) if (k.endsWith(suffix)) pendingWrites.delete(k);\n for (const k of [...recordCounts.keys()]) if (k.endsWith(suffix)) recordCounts.delete(k);\n}\n\n/**\n * Erases the agent's module bookkeeping and returns how many entries were removed.\n *\n * M95 — `invalidateSessionCache` used to clear **two** of the four maps (`sessions`, `hydratedKeys`);\n * `pendingWrites` and `recordCounts` were never touched by id, so they grew for the life of the\n * process. Neither is large per entry — the leak is in count, not volume — but a cache with no owner\n * for removal is a cache that only grows.\n *\n * Returns the count so the caller can prove the removal; a second discard returns 0, which is what\n * makes the idempotency test possible without exposing the maps.\n */\nexport function discardSession(cwd: string, agentId: string): number {\n const key = transcriptKey(cwd, agentId);\n let removed = 0;\n // `sessions` is NOT erased here — and the distinction is measured, not aesthetic. It holds the\n // readable conversation, and there is a legitimate reader AFTER dispose: the golden\n // `two-concurrent-sends-serialize` calls `getSessionMessages(agentId)` after `agent.dispose()`.\n // Erasing it here returned an empty list and broke two goldens. What bounds it is the LRU ceiling\n // above; the three below are pure bookkeeping, with no post-dispose reader.\n //\n // The key is `transcriptKey(cwd, agentId)` in ALL THREE — not the raw `agentId`. The first version\n // erased two of them by `agentId` and therefore **never erased anything**; the test did not catch\n // it because it only asserted that the SECOND call returns 0, which is true either way.\n if (hydratedKeys.delete(key)) removed++;\n if (pendingWrites.delete(key)) removed++;\n if (recordCounts.delete(key)) removed++;\n return removed;\n}\n\nexport function getSessionMessages(agentId: string): SessionMessage[] {\n return sessions.get(agentId) ?? [];\n}\n\n/**\n * Persist a full conversation turn (user + assistant + tool blocks) to the native\n * transcript. Chained per-(agent, transcript) so on-disk order matches send order,\n * and fire-and-forget so `send()` is not blocked by disk I/O. Every\n * M50 — when the caller supplies `turn.autoCompact`, size-driven auto-compaction (usage real vs\n * the model's context window) runs in this same chain, surfaced via the optional `onCompact` observer.\n *\n * @internal\n */\nexport function persistTurnToTranscript(\n store: SessionStore,\n loc: TranscriptLocation,\n sessionId: string,\n turn: PersistTurnInput,\n onCompact?: () => void,\n): void {\n const key = transcriptKey(loc.cwd, loc.agentId);\n // PRE-EXISTING debt, exposed when M75 fixed the Biome config that used to abort before\n // sweeping these files (a nested root under refactor/). It is not new code and was not touched\n // by M75; refactoring SDK internals without review would trade a visible problem for a diff\n // risky. Tracked in usetheodev/theokit-sdk#151.\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: see the reason just above\n const chained = (pendingWrites.get(key) ?? Promise.resolve()).then(async () => {\n try {\n await persistTurn(store, loc, sessionId, turn);\n const count = (recordCounts.get(key) ?? 0) + 1;\n recordCounts.set(key, count);\n // M50 — the 50-turn no-summary boundary stub is GONE (it silently amnesia'd the session).\n // Auto-compaction is now size-driven with a real summary: see `maybeAutoCompact` below,\n // invoked in this same write chain by the post-run lifecycle when usage is known.\n if (turn.autoCompact !== undefined) {\n const { autoCompactIfNeeded } = await import(\"./compact-session.js\");\n const fired = await autoCompactIfNeeded({\n store,\n loc,\n sessionId,\n usageTotal: turn.autoCompact.usageTotal,\n contextWindow: turn.autoCompact.contextWindow,\n turnCount: count,\n summarize: turn.autoCompact.summarize,\n });\n if (fired) onCompact?.();\n }\n } catch (cause) {\n const msg = cause instanceof Error ? cause.message : String(cause);\n diag(`[theokit-sdk] session transcript write failed (${loc.agentId}): ${msg}\\n`);\n }\n });\n pendingWrites.set(\n key,\n chained.then(\n () => undefined,\n () => undefined,\n ),\n );\n}\n\n/**\n * Load the persisted transcript into the in-memory cache. Idempotent per\n * (baseDir, cwd, agentId). Call once per agent lifecycle before the first read.\n *\n * @internal\n */\nexport async function hydrateSession(\n agentId: string,\n loc: { store: SessionStore; cwd: string },\n): Promise<void> {\n const key = transcriptKey(loc.cwd, agentId);\n if (hydratedKeys.has(key)) return;\n hydratedKeys.add(key);\n\n const persisted = await readSessionMessages(loc.store, agentId);\n if (persisted.length === 0) return;\n // M51 review F4 — the DISK is the source of truth at hydration time: after an invalidation\n // (compact/inject), an in-flight turn may have repopulated the cache with a SINGLE message before\n // this hydrate ran; the old \"skip when non-empty\" guard then pinned the parent to a 1-message\n // context (history + injected pair lost until restart). The persist chain serializes writes, so\n // the disk already contains that in-flight turn — replacing is always correct.\n sessions.set(agentId, persisted);\n}\n\n/**\n * Wait for all pending transcript writes to settle. Used by tests and by the\n * agent dispose path so on-disk state matches in-memory before the caller proceeds.\n *\n * @internal\n */\nexport async function flushSessionWrites(): Promise<void> {\n while (pendingWrites.size > 0) {\n const all = Array.from(pendingWrites.values());\n pendingWrites.clear();\n await Promise.all(all);\n }\n}\n\nexport function clearSession(agentId: string): void {\n sessions.delete(agentId);\n}\n\n/**\n * M50 review F1 — drop BOTH the message cache and the hydration marker so the NEXT send re-hydrates\n * from disk. Without this, a compaction only helps after a process restart: the live process keeps\n * sending the full pre-compact history (the cache is read synchronously by every send).\n */\n/**\n * M50 review F5 — run `fn` serialized on the SAME per-(cwd,agentId) write chain the per-turn\n * persistence uses, so a manual `Agent.compact` can never interleave with an in-flight turn's\n * writes (boundary landing mid-turn would orphan the turn from the replay).\n */\nexport function enqueueSessionWrite<T>(\n cwd: string,\n agentId: string,\n fn: () => Promise<T>,\n): Promise<T> {\n const key = transcriptKey(cwd, agentId);\n const prior = pendingWrites.get(key) ?? Promise.resolve();\n const result = prior.then(fn);\n pendingWrites.set(\n key,\n result.then(\n () => undefined,\n () => undefined,\n ),\n );\n return result;\n}\n\n/** Test-only: drop every cached session and hydration marker. @internal */\nexport function clearAllSessions(): void {\n sessions.clear();\n hydratedKeys.clear();\n recordCounts.clear();\n // M50 review F11 — the auto-compact attempt marks live on globalThis; tests reset them here.\n const g = globalThis as unknown as Record<symbol, Map<string, number>>;\n const sym = Symbol.for(\"theokit-sdk.session.auto-compact-attempts\");\n g[sym]?.clear();\n}\n"]}
|
|
@@ -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, insideRoot, truncateWithMarker } from './chunk-ZZAAQOAZ.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,9 +3966,10 @@ 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
|
-
const legacyAsAggregator = legacy.map((src) => ({
|
|
3972
|
+
const legacyAsAggregator = legacy.filter((src) => src.status !== "excluded").map((src) => ({
|
|
4303
3973
|
id: src.name,
|
|
4304
3974
|
source: src.path,
|
|
4305
3975
|
content: src.tokens.join(""),
|
|
@@ -4433,7 +4103,7 @@ async function loadSources(config, cwd) {
|
|
|
4433
4103
|
continue;
|
|
4434
4104
|
}
|
|
4435
4105
|
const absolute = resolve(cwd, source.path);
|
|
4436
|
-
if (!absolute
|
|
4106
|
+
if (!insideRoot(absolute, cwd)) {
|
|
4437
4107
|
results.push({ ...source, status: "excluded", tokens: [] });
|
|
4438
4108
|
continue;
|
|
4439
4109
|
}
|
|
@@ -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-V5V5A6B7.js.map
|
|
10323
|
+
//# sourceMappingURL=chunk-V5V5A6B7.js.map
|