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