@theokit/sdk 4.16.7 → 4.17.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 +12 -0
- package/dist/agent.d.ts +12 -0
- package/dist/cron.cjs +60 -3
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.js +60 -3
- package/dist/cron.js.map +1 -1
- package/dist/eval.cjs +60 -3
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +60 -3
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +60 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +60 -3
- package/dist/index.js.map +1 -1
- package/dist/internal/session/inject-session.d.ts +15 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.17.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix(session): hydration REPLACES the cache from disk (source of truth) instead of skipping when non-empty — after an invalidation (compact/inject), an in-flight turn repopulating the cache with one message used to pin the parent to a 1-message context until restart (M51 review F4; race test added).
|
|
8
|
+
|
|
9
|
+
## 4.17.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- feat(session): `Agent.injectSessionTurn(agentId, {userText, assistantText})` — append a SYNTHETIC user+assistant pair to a local session's persisted transcript WITHOUT running an LLM turn (the Codex review-exit mechanism: the parent conversation "learns" a result for follow-ups). Chains onto the DAG leaf, invalidates the in-memory cache, serialized on the per-agent write chain (M51 agent-builder).
|
|
14
|
+
|
|
3
15
|
## 4.16.7
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/agent.d.ts
CHANGED
|
@@ -187,6 +187,18 @@ export declare class Agent {
|
|
|
187
187
|
trigger?: "manual" | "auto";
|
|
188
188
|
summarize?: (messages: readonly import("./compaction.js").CompressibleMessage[]) => Promise<string>;
|
|
189
189
|
}): Promise<import("./internal/session/compact-session.js").CompactResult>;
|
|
190
|
+
/**
|
|
191
|
+
* M51 — inject a SYNTHETIC user+assistant pair into a LOCAL session's persisted transcript WITHOUT
|
|
192
|
+
* running an LLM turn (the Codex review-exit mechanism: the parent thread "learns" a result — e.g.
|
|
193
|
+
* review findings — so follow-ups work). Appends onto the DAG leaf and invalidates the in-memory
|
|
194
|
+
* cache; serialized on the per-agent write chain.
|
|
195
|
+
*
|
|
196
|
+
* @public
|
|
197
|
+
*/
|
|
198
|
+
static injectSessionTurn(agentId: string, turn: {
|
|
199
|
+
userText: string;
|
|
200
|
+
assistantText: string;
|
|
201
|
+
}): Promise<void>;
|
|
190
202
|
/**
|
|
191
203
|
* Permanently delete a cloud agent.
|
|
192
204
|
*
|
package/dist/cron.cjs
CHANGED
|
@@ -5948,9 +5948,7 @@ async function hydrateSession(agentId, loc) {
|
|
|
5948
5948
|
hydratedKeys.add(key);
|
|
5949
5949
|
const persisted = await readSessionMessages(loc.store, agentId);
|
|
5950
5950
|
if (persisted.length === 0) return;
|
|
5951
|
-
|
|
5952
|
-
sessions.set(agentId, persisted);
|
|
5953
|
-
}
|
|
5951
|
+
sessions.set(agentId, persisted);
|
|
5954
5952
|
}
|
|
5955
5953
|
async function flushSessionWrites() {
|
|
5956
5954
|
while (pendingWrites.size > 0) {
|
|
@@ -7597,6 +7595,32 @@ var init_batch = __esm({
|
|
|
7597
7595
|
}
|
|
7598
7596
|
});
|
|
7599
7597
|
|
|
7598
|
+
// src/internal/session/inject-session.ts
|
|
7599
|
+
var inject_session_exports = {};
|
|
7600
|
+
__export(inject_session_exports, {
|
|
7601
|
+
injectSessionTurn: () => injectSessionTurn
|
|
7602
|
+
});
|
|
7603
|
+
async function injectSessionTurn(opts) {
|
|
7604
|
+
await enqueueSessionWrite(opts.loc.cwd, opts.loc.agentId, async () => {
|
|
7605
|
+
const prior = await opts.store.readRecords(opts.loc.agentId);
|
|
7606
|
+
const transcript = SessionTranscript.fromRecords(prior, {
|
|
7607
|
+
cwd: opts.loc.cwd,
|
|
7608
|
+
sessionId: opts.sessionId,
|
|
7609
|
+
model: opts.loc.model ?? "unknown"
|
|
7610
|
+
});
|
|
7611
|
+
transcript.appendUserTurn(opts.userText);
|
|
7612
|
+
transcript.appendAssistantTurn({ text: opts.assistantText });
|
|
7613
|
+
await opts.store.appendRecords(opts.loc.agentId, transcript.records().slice(prior.length));
|
|
7614
|
+
invalidateSessionCache(opts.loc.cwd, opts.loc.agentId);
|
|
7615
|
+
});
|
|
7616
|
+
}
|
|
7617
|
+
var init_inject_session = __esm({
|
|
7618
|
+
"src/internal/session/inject-session.ts"() {
|
|
7619
|
+
init_session_transcript();
|
|
7620
|
+
init_agent_session();
|
|
7621
|
+
}
|
|
7622
|
+
});
|
|
7623
|
+
|
|
7600
7624
|
// src/agent-builder.ts
|
|
7601
7625
|
var AgentBuilder = class {
|
|
7602
7626
|
opts = {};
|
|
@@ -19904,6 +19928,39 @@ var Agent = class _Agent {
|
|
|
19904
19928
|
})
|
|
19905
19929
|
}));
|
|
19906
19930
|
}
|
|
19931
|
+
/**
|
|
19932
|
+
* M51 — inject a SYNTHETIC user+assistant pair into a LOCAL session's persisted transcript WITHOUT
|
|
19933
|
+
* running an LLM turn (the Codex review-exit mechanism: the parent thread "learns" a result — e.g.
|
|
19934
|
+
* review findings — so follow-ups work). Appends onto the DAG leaf and invalidates the in-memory
|
|
19935
|
+
* cache; serialized on the per-agent write chain.
|
|
19936
|
+
*
|
|
19937
|
+
* @public
|
|
19938
|
+
*/
|
|
19939
|
+
static async injectSessionTurn(agentId, turn) {
|
|
19940
|
+
let reg = getRegisteredAgent(agentId);
|
|
19941
|
+
if (reg === void 0) {
|
|
19942
|
+
await hydrateRegistryFromDisk(process.cwd());
|
|
19943
|
+
reg = getRegisteredAgent(agentId);
|
|
19944
|
+
}
|
|
19945
|
+
if (reg === void 0 || reg.runtime !== "local") {
|
|
19946
|
+
throw new UnknownAgentError(`No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`);
|
|
19947
|
+
}
|
|
19948
|
+
const cwd = reg.cwd ?? process.cwd();
|
|
19949
|
+
const optModel = reg.options.model;
|
|
19950
|
+
const model = reg.model?.id ?? (typeof optModel === "string" ? optModel : optModel?.id) ?? "unknown";
|
|
19951
|
+
const { injectSessionTurn: injectSessionTurn2 } = await Promise.resolve().then(() => (init_inject_session(), inject_session_exports));
|
|
19952
|
+
const { FsSessionStore: FsSessionStore2 } = await Promise.resolve().then(() => (init_fs_session_store(), fs_session_store_exports));
|
|
19953
|
+
const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await Promise.resolve().then(() => (init_session_transcript(), session_transcript_exports));
|
|
19954
|
+
const baseDir = reg.options.local?.baseDir !== void 0 ? expandTilde2(reg.options.local.baseDir) : defaultBaseDir2();
|
|
19955
|
+
const store = new FsSessionStore2({ baseDir, cwd });
|
|
19956
|
+
await injectSessionTurn2({
|
|
19957
|
+
store,
|
|
19958
|
+
loc: { cwd, agentId, model },
|
|
19959
|
+
sessionId: agentId,
|
|
19960
|
+
userText: turn.userText,
|
|
19961
|
+
assistantText: turn.assistantText
|
|
19962
|
+
});
|
|
19963
|
+
}
|
|
19907
19964
|
/**
|
|
19908
19965
|
* Permanently delete a cloud agent.
|
|
19909
19966
|
*
|