@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/dist/eval.js CHANGED
@@ -5944,9 +5944,7 @@ async function hydrateSession(agentId, loc) {
5944
5944
  hydratedKeys.add(key);
5945
5945
  const persisted = await readSessionMessages(loc.store, agentId);
5946
5946
  if (persisted.length === 0) return;
5947
- if (!sessions.has(agentId) || sessions.get(agentId)?.length === 0) {
5948
- sessions.set(agentId, persisted);
5949
- }
5947
+ sessions.set(agentId, persisted);
5950
5948
  }
5951
5949
  async function flushSessionWrites() {
5952
5950
  while (pendingWrites.size > 0) {
@@ -7593,6 +7591,32 @@ var init_batch = __esm({
7593
7591
  }
7594
7592
  });
7595
7593
 
7594
+ // src/internal/session/inject-session.ts
7595
+ var inject_session_exports = {};
7596
+ __export(inject_session_exports, {
7597
+ injectSessionTurn: () => injectSessionTurn
7598
+ });
7599
+ async function injectSessionTurn(opts) {
7600
+ await enqueueSessionWrite(opts.loc.cwd, opts.loc.agentId, async () => {
7601
+ const prior = await opts.store.readRecords(opts.loc.agentId);
7602
+ const transcript = SessionTranscript.fromRecords(prior, {
7603
+ cwd: opts.loc.cwd,
7604
+ sessionId: opts.sessionId,
7605
+ model: opts.loc.model ?? "unknown"
7606
+ });
7607
+ transcript.appendUserTurn(opts.userText);
7608
+ transcript.appendAssistantTurn({ text: opts.assistantText });
7609
+ await opts.store.appendRecords(opts.loc.agentId, transcript.records().slice(prior.length));
7610
+ invalidateSessionCache(opts.loc.cwd, opts.loc.agentId);
7611
+ });
7612
+ }
7613
+ var init_inject_session = __esm({
7614
+ "src/internal/session/inject-session.ts"() {
7615
+ init_session_transcript();
7616
+ init_agent_session();
7617
+ }
7618
+ });
7619
+
7596
7620
  // src/agent-builder.ts
7597
7621
  var AgentBuilder = class {
7598
7622
  opts = {};
@@ -19896,6 +19920,39 @@ var Agent = class _Agent {
19896
19920
  })
19897
19921
  }));
19898
19922
  }
19923
+ /**
19924
+ * M51 — inject a SYNTHETIC user+assistant pair into a LOCAL session's persisted transcript WITHOUT
19925
+ * running an LLM turn (the Codex review-exit mechanism: the parent thread "learns" a result — e.g.
19926
+ * review findings — so follow-ups work). Appends onto the DAG leaf and invalidates the in-memory
19927
+ * cache; serialized on the per-agent write chain.
19928
+ *
19929
+ * @public
19930
+ */
19931
+ static async injectSessionTurn(agentId, turn) {
19932
+ let reg = getRegisteredAgent(agentId);
19933
+ if (reg === void 0) {
19934
+ await hydrateRegistryFromDisk(process.cwd());
19935
+ reg = getRegisteredAgent(agentId);
19936
+ }
19937
+ if (reg === void 0 || reg.runtime !== "local") {
19938
+ throw new UnknownAgentError(`No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`);
19939
+ }
19940
+ const cwd = reg.cwd ?? process.cwd();
19941
+ const optModel = reg.options.model;
19942
+ const model = reg.model?.id ?? (typeof optModel === "string" ? optModel : optModel?.id) ?? "unknown";
19943
+ const { injectSessionTurn: injectSessionTurn2 } = await Promise.resolve().then(() => (init_inject_session(), inject_session_exports));
19944
+ const { FsSessionStore: FsSessionStore2 } = await Promise.resolve().then(() => (init_fs_session_store(), fs_session_store_exports));
19945
+ const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await Promise.resolve().then(() => (init_session_transcript(), session_transcript_exports));
19946
+ const baseDir = reg.options.local?.baseDir !== void 0 ? expandTilde2(reg.options.local.baseDir) : defaultBaseDir2();
19947
+ const store = new FsSessionStore2({ baseDir, cwd });
19948
+ await injectSessionTurn2({
19949
+ store,
19950
+ loc: { cwd, agentId, model },
19951
+ sessionId: agentId,
19952
+ userText: turn.userText,
19953
+ assistantText: turn.assistantText
19954
+ });
19955
+ }
19899
19956
  /**
19900
19957
  * Permanently delete a cloud agent.
19901
19958
  *