@theokit/sdk 4.62.0 → 4.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +66 -0
- package/dist/{agent-NVBFTY5H.js → agent-536OOESZ.js} +8 -6
- package/dist/{agent-NVBFTY5H.js.map → agent-536OOESZ.js.map} +1 -1
- package/dist/{agent-VYPUO4UB.cjs → agent-5KYMG63I.cjs} +9 -7
- package/dist/{agent-VYPUO4UB.cjs.map → agent-5KYMG63I.cjs.map} +1 -1
- package/dist/{agent-DIu6FooJ.d.ts → agent-BFno7Sfn.d.ts} +36 -21
- package/dist/{agent-D3Xr_-6Z.d.cts → agent-X0DKA943.d.cts} +36 -21
- package/dist/chunk-A4RAL2ER.cjs +51 -0
- package/dist/chunk-A4RAL2ER.cjs.map +1 -0
- package/dist/chunk-A4VHSE56.cjs +21 -0
- package/dist/chunk-A4VHSE56.cjs.map +1 -0
- package/dist/{chunk-CQ2TQ32Y.js → chunk-AMFXSENK.js} +3 -48
- package/dist/chunk-AMFXSENK.js.map +1 -0
- package/dist/chunk-C7QPML3L.js +831 -0
- package/dist/chunk-C7QPML3L.js.map +1 -0
- package/dist/{chunk-CWHTMNNK.cjs → chunk-CASUEY42.cjs} +4 -4
- package/dist/{chunk-CWHTMNNK.cjs.map → chunk-CASUEY42.cjs.map} +1 -1
- package/dist/{chunk-SKOCYA55.js → chunk-CHKH5452.js} +37 -50
- package/dist/chunk-CHKH5452.js.map +1 -0
- package/dist/chunk-EHJEZAOO.cjs +864 -0
- package/dist/chunk-EHJEZAOO.cjs.map +1 -0
- package/dist/chunk-IRCJ7EHV.cjs +201 -0
- package/dist/chunk-IRCJ7EHV.cjs.map +1 -0
- package/dist/chunk-LW7G5DYW.js +19 -0
- package/dist/chunk-LW7G5DYW.js.map +1 -0
- package/dist/{chunk-IBYRA5PM.js → chunk-MG3SOM3M.js} +3 -3
- package/dist/{chunk-IBYRA5PM.js.map → chunk-MG3SOM3M.js.map} +1 -1
- package/dist/{chunk-AH6WD7JR.cjs → chunk-NLXOGBRJ.cjs} +45 -58
- package/dist/chunk-NLXOGBRJ.cjs.map +1 -0
- package/dist/{chunk-SKXBJ2NU.cjs → chunk-NXH4GPAQ.cjs} +2 -49
- package/dist/chunk-NXH4GPAQ.cjs.map +1 -0
- package/dist/chunk-R6TA2DRJ.js +194 -0
- package/dist/chunk-R6TA2DRJ.js.map +1 -0
- package/dist/{chunk-6OBIWHDR.cjs → chunk-UUP3MUZ6.cjs} +20 -361
- package/dist/chunk-UUP3MUZ6.cjs.map +1 -0
- package/dist/chunk-WE22OXQA.js +48 -0
- package/dist/chunk-WE22OXQA.js.map +1 -0
- package/dist/{chunk-QEKI3YKI.js → chunk-YTR3RBUZ.js} +13 -348
- package/dist/chunk-YTR3RBUZ.js.map +1 -0
- package/dist/{cron-BcWmzWzT.d.cts → cron-BuiRPrvt.d.cts} +1 -1
- package/dist/{cron-De6hzWCF.d.ts → cron-C2SIi31n.d.ts} +1 -1
- package/dist/cron.cjs +8 -6
- package/dist/cron.d.cts +2 -2
- package/dist/cron.d.ts +2 -2
- package/dist/cron.js +7 -5
- package/dist/eval.cjs +7 -5
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +6 -4
- package/dist/eval.js.map +1 -1
- package/dist/{index-manager-RHPFVFSC.cjs → index-manager-6TEEIWM7.cjs} +7 -6
- package/dist/{index-manager-RHPFVFSC.cjs.map → index-manager-6TEEIWM7.cjs.map} +1 -1
- package/dist/{index-manager-AHAYJ33H.js → index-manager-ACEQG3IJ.js} +6 -5
- package/dist/{index-manager-AHAYJ33H.js.map → index-manager-ACEQG3IJ.js.map} +1 -1
- package/dist/index.cjs +35 -208
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.js +22 -195
- package/dist/index.js.map +1 -1
- package/dist/internal/memory/active-memory.d.ts +8 -1
- package/dist/internal/memory/dreaming/diary.d.ts +39 -2
- package/dist/internal/memory/index-db.d.ts +44 -1
- package/dist/internal/memory/index-manager-contract.d.ts +10 -0
- package/dist/internal/memory/index-manager-helpers.d.ts +20 -1
- package/dist/internal/memory/index-manager.d.ts +1 -1
- package/dist/internal/memory/lance-index.d.ts +15 -1
- package/dist/internal/memory/migrate-sqlite-to-lance.d.ts +43 -0
- package/dist/internal/memory/storage/index.cjs +95 -12
- package/dist/internal/memory/storage/index.d.cts +11 -1
- package/dist/internal/memory/storage/index.d.ts +11 -1
- package/dist/internal/memory/storage/index.js +4 -1
- package/dist/internal/memory/storage/markdown-store.d.cts +13 -42
- package/dist/internal/memory/storage/markdown-store.d.ts +13 -42
- package/dist/internal/memory/storage/memory-root.d.cts +93 -0
- package/dist/internal/memory/storage/memory-root.d.ts +93 -0
- package/dist/internal/memory/storage/session-loader.d.cts +35 -1
- package/dist/internal/memory/storage/session-loader.d.ts +35 -1
- package/dist/internal/memory/storage/session-summary-writer.d.cts +50 -2
- package/dist/internal/memory/storage/session-summary-writer.d.ts +50 -2
- package/dist/internal/memory/storage/transcript-store.d.cts +38 -1
- package/dist/internal/memory/storage/transcript-store.d.ts +38 -1
- package/dist/internal/memory/storage/wiki-loader.d.cts +27 -2
- package/dist/internal/memory/storage/wiki-loader.d.ts +27 -2
- package/dist/internal/memory/tools.d.ts +8 -1
- package/dist/internal/memory/types.d.ts +5 -0
- package/dist/internal/persistence/index.cjs +12 -11
- package/dist/internal/persistence/index.cjs.map +1 -1
- package/dist/internal/persistence/index.js +2 -1
- package/dist/internal/persistence/index.js.map +1 -1
- package/dist/internal/persistence/session-dir.d.cts +0 -15
- package/dist/internal/persistence/session-dir.d.ts +0 -15
- package/dist/internal/runtime/memory/memory-store.d.ts +2 -2
- package/dist/persistence.cjs +9 -8
- package/dist/persistence.cjs.map +1 -1
- package/dist/persistence.js +2 -1
- package/dist/persistence.js.map +1 -1
- package/dist/subagents-loader.d.cts +1 -1
- package/dist/subagents-loader.d.ts +1 -1
- package/dist/types/agent.d.ts +11 -0
- package/dist/types/memory-provider.d.ts +8 -0
- package/docs/error-codes.md +10 -9
- package/docs/harness-capability-map.md +57 -17
- package/docs/memory-decisions.md +44 -7
- package/package.json +1 -1
- package/dist/chunk-2UCFUSPW.cjs +0 -468
- package/dist/chunk-2UCFUSPW.cjs.map +0 -1
- package/dist/chunk-6OBIWHDR.cjs.map +0 -1
- package/dist/chunk-AH6WD7JR.cjs.map +0 -1
- package/dist/chunk-CQ2TQ32Y.js.map +0 -1
- package/dist/chunk-QEKI3YKI.js.map +0 -1
- package/dist/chunk-SKOCYA55.js.map +0 -1
- package/dist/chunk-SKXBJ2NU.cjs.map +0 -1
- package/dist/chunk-WCLDJSMY.js +0 -456
- package/dist/chunk-WCLDJSMY.js.map +0 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { submit, emitRunEvent } from './chunk-SUKXXLWD.js';
|
|
2
2
|
import { enqueueSessionWrite, hydrateSession, persistTurnToTranscript, flushSessionWrites, appendSessionMessage, getSessionMessages, discardSession, clearSession } from './chunk-YEXA3PGR.js';
|
|
3
|
-
import { IndexManager
|
|
3
|
+
import { IndexManager } from './chunk-YTR3RBUZ.js';
|
|
4
4
|
import { loadHookConfig, warnOnce, currentPersonalityContext, warnPersonalitySwitchInsideFork } from './chunk-MZ2FGBLZ.js';
|
|
5
5
|
import { extractCodePlugins } from './chunk-2SFBB54R.js';
|
|
6
6
|
import { createOpenAiCompatibleRuntime } from './chunk-XN7NOENA.js';
|
|
7
|
-
import {
|
|
7
|
+
import { persistActiveMemoryTranscript } from './chunk-LW7G5DYW.js';
|
|
8
|
+
import { resolveMemoryRoot, writeSessionSummary, MEMORY_KINDS, appendFact, readFacts, legacyMemoryJsonPath, memoryMdPath, appendFactToMarkdown } from './chunk-C7QPML3L.js';
|
|
8
9
|
import { FsSessionStore } from './chunk-YJDH3CKG.js';
|
|
9
10
|
import { discoverProviderPlugins, getConfiguredBaseUrl, httpRequest, isFixtureApiKey, presentProviderCredentialEnvVars, CircuitBreaker, buildDefaultSummarizer, shouldUseRealLocalRuntime, parseSseStream, resolveProviderChain, inferProviderFromApiKey, detectPrimaryProvider, warnProviderPrecedenceOnce, tryFirstEvent, relayStream, renderToolResultContentText } from './chunk-YXGAW7BB.js';
|
|
10
11
|
import { resolveChildEnv } from './chunk-HKCKOAIO.js';
|
|
@@ -904,7 +905,7 @@ async function migrateLegacyJson(cwd, config) {
|
|
|
904
905
|
if (!await fileExists(jsonPath)) {
|
|
905
906
|
return { migrated: false, factCount: 0, reason: "no-legacy-json" };
|
|
906
907
|
}
|
|
907
|
-
if (await fileExists(memoryMdPath(cwd))) {
|
|
908
|
+
if (await fileExists(memoryMdPath(resolveMemoryRoot(cwd, config)))) {
|
|
908
909
|
diag(
|
|
909
910
|
`[theokit-sdk] memory migration skipped: both MEMORY.md and legacy JSON exist at ${jsonPath}; leaving both intact
|
|
910
911
|
`
|
|
@@ -933,19 +934,19 @@ function extractMemoryKind(message) {
|
|
|
933
934
|
const lowered = declared.toLowerCase();
|
|
934
935
|
return MEMORY_KINDS.includes(lowered) ? lowered : void 0;
|
|
935
936
|
}
|
|
936
|
-
async function readMemoryFacts(cwd, config
|
|
937
|
+
async function readMemoryFacts(cwd, config) {
|
|
937
938
|
if (!config.enabled) return [];
|
|
938
939
|
await migrateLegacyJson(cwd, config);
|
|
939
|
-
return readFacts(cwd, config
|
|
940
|
+
return readFacts(cwd, config);
|
|
940
941
|
}
|
|
941
|
-
async function appendMemoryFact(cwd, config, fact
|
|
942
|
+
async function appendMemoryFact(cwd, config, fact) {
|
|
942
943
|
if (!config.enabled) return;
|
|
943
944
|
await migrateLegacyJson(cwd, config);
|
|
944
945
|
const sanitized = {
|
|
945
946
|
text: redactSecrets(fact.text),
|
|
946
947
|
...fact.kind === void 0 ? {} : { kind: fact.kind }
|
|
947
948
|
};
|
|
948
|
-
await appendFact(cwd, config, sanitized
|
|
949
|
+
await appendFact(cwd, config, sanitized);
|
|
949
950
|
}
|
|
950
951
|
|
|
951
952
|
// src/internal/runtime/fixtures/fixture-scripts.ts
|
|
@@ -2132,10 +2133,6 @@ function resolveSessionDir(local) {
|
|
|
2132
2133
|
}
|
|
2133
2134
|
return defaultBaseDir();
|
|
2134
2135
|
}
|
|
2135
|
-
function explicitSessionDir(local) {
|
|
2136
|
-
if (local?.sessionDir === void 0 && local?.baseDir === void 0) return void 0;
|
|
2137
|
-
return resolveSessionDir(local);
|
|
2138
|
-
}
|
|
2139
2136
|
var SCHEMA_VERSION2 = 1;
|
|
2140
2137
|
var FILE_NAME = "personality.json";
|
|
2141
2138
|
function emptyState() {
|
|
@@ -2791,6 +2788,9 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2791
2788
|
if (result.status === "finished" && result.result !== void 0 && sessionTranscriptAllowed(inputs.memory)) {
|
|
2792
2789
|
const summaryArgs = {
|
|
2793
2790
|
cwd: workspaceCwd,
|
|
2791
|
+
// Resolved once, here, and handed to both writers. Recomputing it inside either one is how
|
|
2792
|
+
// the summary ended up in a directory the indexer never scanned (#463).
|
|
2793
|
+
memoryRoot: resolveMemoryRoot(workspaceCwd, inputs.memory),
|
|
2794
2794
|
runId: result.id,
|
|
2795
2795
|
agentId,
|
|
2796
2796
|
userText,
|
|
@@ -7781,17 +7781,6 @@ async function reloadLocalAgent(agent) {
|
|
|
7781
7781
|
agent.options.agents
|
|
7782
7782
|
);
|
|
7783
7783
|
}
|
|
7784
|
-
async function persistActiveMemoryTranscript(cwd, transcript) {
|
|
7785
|
-
try {
|
|
7786
|
-
const dir = join(memoryDir(cwd), "transcripts", "active-memory");
|
|
7787
|
-
const file = join(dir, `${transcript.runId}.json`);
|
|
7788
|
-
await atomicWriteJson(file, transcript);
|
|
7789
|
-
} catch (cause) {
|
|
7790
|
-
const message = cause instanceof Error ? cause.message : String(cause);
|
|
7791
|
-
diag(`[theokit-sdk] active-memory transcript persist failed: ${message}
|
|
7792
|
-
`);
|
|
7793
|
-
}
|
|
7794
|
-
}
|
|
7795
7784
|
|
|
7796
7785
|
// src/internal/memory/active-memory.ts
|
|
7797
7786
|
var DEFAULTS = {
|
|
@@ -7927,7 +7916,7 @@ async function finalize(args, queryMode, result) {
|
|
|
7927
7916
|
};
|
|
7928
7917
|
args.cache?.set(args.userText, queryMode, result, tenantCtx);
|
|
7929
7918
|
if (args.persistTranscripts === true && args.cwd !== void 0) {
|
|
7930
|
-
await persistActiveMemoryTranscript(args.cwd, {
|
|
7919
|
+
await persistActiveMemoryTranscript(args.memoryRoot ?? resolveMemoryRoot(args.cwd), {
|
|
7931
7920
|
runId: args.runId ?? `run-${Date.now()}`,
|
|
7932
7921
|
startedAtMs: Date.now() - result.durationMs,
|
|
7933
7922
|
userText: args.userText,
|
|
@@ -8413,7 +8402,7 @@ function createMemorySearchTool(opts) {
|
|
|
8413
8402
|
};
|
|
8414
8403
|
}
|
|
8415
8404
|
function createMemoryGetTool(opts) {
|
|
8416
|
-
const memoryRoot = resolve(
|
|
8405
|
+
const memoryRoot = resolve(opts.root);
|
|
8417
8406
|
return {
|
|
8418
8407
|
name: "memory_get",
|
|
8419
8408
|
description: GET_DESCRIPTION,
|
|
@@ -8495,6 +8484,7 @@ var LocalAgentMemory = class {
|
|
|
8495
8484
|
toolsCache;
|
|
8496
8485
|
breaker;
|
|
8497
8486
|
cache;
|
|
8487
|
+
memoryRootCache;
|
|
8498
8488
|
/**
|
|
8499
8489
|
* Sync view of the tool cache (SDK 2.0 Phase 1 Stage 2b — iter 19+).
|
|
8500
8490
|
* Returns the cached MemoryToolSpec[] when `ensureTools()` has run
|
|
@@ -8516,14 +8506,15 @@ var LocalAgentMemory = class {
|
|
|
8516
8506
|
if (this.toolsCache !== void 0) return this.toolsCache;
|
|
8517
8507
|
try {
|
|
8518
8508
|
const embedding = await this.maybeCreateEmbeddingRuntime();
|
|
8519
|
-
const
|
|
8509
|
+
const memoryRoot = this.memoryRoot();
|
|
8510
|
+
const openOpts = { cwd: this.workspaceCwd, memoryRoot };
|
|
8520
8511
|
if (embedding !== void 0) openOpts.embedding = embedding;
|
|
8521
8512
|
if (cfg?.backend !== void 0) openOpts.backend = cfg.backend;
|
|
8522
8513
|
this.index = await IndexManager.open(openOpts);
|
|
8523
8514
|
await this.index.sync();
|
|
8524
8515
|
this.toolsCache = [
|
|
8525
8516
|
createMemorySearchTool({ index: this.index }),
|
|
8526
|
-
createMemoryGetTool({
|
|
8517
|
+
createMemoryGetTool({ root: memoryRoot })
|
|
8527
8518
|
];
|
|
8528
8519
|
return this.toolsCache;
|
|
8529
8520
|
} catch (cause) {
|
|
@@ -8554,12 +8545,21 @@ var LocalAgentMemory = class {
|
|
|
8554
8545
|
cache: this.cache,
|
|
8555
8546
|
agentKey: this.agentId,
|
|
8556
8547
|
cwd: this.workspaceCwd,
|
|
8548
|
+
memoryRoot: this.memoryRoot(),
|
|
8557
8549
|
...cfg.persistTranscripts === true ? { persistTranscripts: true } : {},
|
|
8558
8550
|
runId: `${this.agentId}-${Date.now()}`,
|
|
8559
8551
|
...this.buildTelemetryRecallArgs(telemetry)
|
|
8560
8552
|
});
|
|
8561
8553
|
return result.summary;
|
|
8562
8554
|
}
|
|
8555
|
+
/**
|
|
8556
|
+
* Where this agent's memory lives — resolved once and shared by the index, the `memory_get` tool
|
|
8557
|
+
* and the active-memory transcript writer. Three separate resolutions is how they drifted (#463).
|
|
8558
|
+
*/
|
|
8559
|
+
memoryRoot() {
|
|
8560
|
+
this.memoryRootCache ??= resolveMemoryRoot(this.workspaceCwd, this.options.memory);
|
|
8561
|
+
return this.memoryRootCache;
|
|
8562
|
+
}
|
|
8563
8563
|
buildActiveMemoryOptions(cfg) {
|
|
8564
8564
|
if (cfg === void 0) return { enabled: true };
|
|
8565
8565
|
return {
|
|
@@ -9008,19 +9008,17 @@ async function localAgentFork(parent, options) {
|
|
|
9008
9008
|
() => forkAgentImpl(parent, options, { create })
|
|
9009
9009
|
);
|
|
9010
9010
|
}
|
|
9011
|
-
async function persistMemoryFactIfWritePrompt(workspaceCwd, memoryConfig, userText
|
|
9011
|
+
async function persistMemoryFactIfWritePrompt(workspaceCwd, memoryConfig, userText) {
|
|
9012
9012
|
if (memoryConfig?.enabled !== true) return;
|
|
9013
9013
|
if (!isMemoryWritePrompt(userText)) return;
|
|
9014
9014
|
const fact = extractMemoryFact(userText);
|
|
9015
9015
|
if (fact.length === 0) return;
|
|
9016
9016
|
const kind = extractMemoryKind(userText);
|
|
9017
9017
|
await safeCall(
|
|
9018
|
-
() => appendMemoryFact(
|
|
9019
|
-
|
|
9020
|
-
|
|
9021
|
-
|
|
9022
|
-
memoryHome
|
|
9023
|
-
),
|
|
9018
|
+
() => appendMemoryFact(workspaceCwd, memoryConfig, {
|
|
9019
|
+
text: fact,
|
|
9020
|
+
...kind === void 0 ? {} : { kind }
|
|
9021
|
+
}),
|
|
9024
9022
|
void 0,
|
|
9025
9023
|
"memory write"
|
|
9026
9024
|
);
|
|
@@ -9516,19 +9514,8 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9516
9514
|
});
|
|
9517
9515
|
const priorMessages = [...getSessionMessages(inputs.agentId)];
|
|
9518
9516
|
appendSessionMessage(inputs.agentId, { role: "user", text: userText });
|
|
9519
|
-
|
|
9520
|
-
await
|
|
9521
|
-
inputs.workspaceCwd,
|
|
9522
|
-
inputs.options.memory,
|
|
9523
|
-
userText,
|
|
9524
|
-
memoryHome
|
|
9525
|
-
);
|
|
9526
|
-
const memoryFacts = await readMemoryForSend(
|
|
9527
|
-
inputs.workspaceCwd,
|
|
9528
|
-
inputs.options.memory,
|
|
9529
|
-
memoryHome,
|
|
9530
|
-
userText
|
|
9531
|
-
);
|
|
9517
|
+
await persistMemoryFactIfWritePrompt(inputs.workspaceCwd, inputs.options.memory, userText);
|
|
9518
|
+
const memoryFacts = await readMemoryForSend(inputs.workspaceCwd, inputs.options.memory, userText);
|
|
9532
9519
|
const portPathActive = shouldUsePortMemoryPath();
|
|
9533
9520
|
const legacyTools = portPathActive ? void 0 : await inputs.memoryGlue.ensureTools();
|
|
9534
9521
|
const legacySummary = portPathActive ? void 0 : await inputs.memoryGlue.runActiveMemoryIfEnabled(userText, priorMessages, inputs.telemetry);
|
|
@@ -9590,10 +9577,10 @@ function buildCompletionCheckDeps() {
|
|
|
9590
9577
|
}
|
|
9591
9578
|
};
|
|
9592
9579
|
}
|
|
9593
|
-
function readMemoryForSend(workspaceCwd, memoryConfig,
|
|
9580
|
+
function readMemoryForSend(workspaceCwd, memoryConfig, query) {
|
|
9594
9581
|
if (memoryConfig?.enabled !== true) return Promise.resolve([]);
|
|
9595
9582
|
return safeCall(
|
|
9596
|
-
async () => selectFactsForInjection(await readMemoryFacts(workspaceCwd, memoryConfig
|
|
9583
|
+
async () => selectFactsForInjection(await readMemoryFacts(workspaceCwd, memoryConfig), {
|
|
9597
9584
|
...query === void 0 ? {} : { query }
|
|
9598
9585
|
}),
|
|
9599
9586
|
[],
|
|
@@ -10775,5 +10762,5 @@ async function openLocalStore(reg) {
|
|
|
10775
10762
|
}
|
|
10776
10763
|
|
|
10777
10764
|
export { Agent, AgentBuilder, DEFAULT_AGENTIC_MODEL_ID, MEMORY_EMBEDDING_ADAPTERS, Tool, ToolError, UsageAccumulator, computeCost, generateCronId, getPricingEntry, openRouterMemoryEmbeddingProviderAdapter };
|
|
10778
|
-
//# sourceMappingURL=chunk-
|
|
10779
|
-
//# sourceMappingURL=chunk-
|
|
10765
|
+
//# sourceMappingURL=chunk-CHKH5452.js.map
|
|
10766
|
+
//# sourceMappingURL=chunk-CHKH5452.js.map
|