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