@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/index.cjs CHANGED
@@ -6121,9 +6121,7 @@ async function hydrateSession(agentId, loc) {
6121
6121
  hydratedKeys.add(key2);
6122
6122
  const persisted = await readSessionMessages(loc.store, agentId);
6123
6123
  if (persisted.length === 0) return;
6124
- if (!sessions.has(agentId) || sessions.get(agentId)?.length === 0) {
6125
- sessions.set(agentId, persisted);
6126
- }
6124
+ sessions.set(agentId, persisted);
6127
6125
  }
6128
6126
  async function flushSessionWrites() {
6129
6127
  while (pendingWrites.size > 0) {
@@ -9031,6 +9029,32 @@ var init_batch = __esm({
9031
9029
  }
9032
9030
  });
9033
9031
 
9032
+ // src/internal/session/inject-session.ts
9033
+ var inject_session_exports = {};
9034
+ __export(inject_session_exports, {
9035
+ injectSessionTurn: () => injectSessionTurn
9036
+ });
9037
+ async function injectSessionTurn(opts) {
9038
+ await enqueueSessionWrite(opts.loc.cwd, opts.loc.agentId, async () => {
9039
+ const prior = await opts.store.readRecords(opts.loc.agentId);
9040
+ const transcript = SessionTranscript.fromRecords(prior, {
9041
+ cwd: opts.loc.cwd,
9042
+ sessionId: opts.sessionId,
9043
+ model: opts.loc.model ?? "unknown"
9044
+ });
9045
+ transcript.appendUserTurn(opts.userText);
9046
+ transcript.appendAssistantTurn({ text: opts.assistantText });
9047
+ await opts.store.appendRecords(opts.loc.agentId, transcript.records().slice(prior.length));
9048
+ invalidateSessionCache(opts.loc.cwd, opts.loc.agentId);
9049
+ });
9050
+ }
9051
+ var init_inject_session = __esm({
9052
+ "src/internal/session/inject-session.ts"() {
9053
+ init_session_transcript();
9054
+ init_agent_session();
9055
+ }
9056
+ });
9057
+
9034
9058
  // src/types/workflow.ts
9035
9059
  var WorkflowDuplicateStepIdError, WorkflowInputError, WorkflowOutputError, WorkflowStateError, WorkflowAlreadyRunningError, WorkflowSnapshotNotFoundError, WorkflowMaxIterationsExceededError, WorkflowNotSerializableError, WorkflowResumeStepNotFoundError, WorkflowParallelError, WorkflowCompensateNotImplementedError;
9036
9060
  var init_workflow = __esm({
@@ -21531,6 +21555,39 @@ var Agent = class _Agent {
21531
21555
  })
21532
21556
  }));
21533
21557
  }
21558
+ /**
21559
+ * M51 — inject a SYNTHETIC user+assistant pair into a LOCAL session's persisted transcript WITHOUT
21560
+ * running an LLM turn (the Codex review-exit mechanism: the parent thread "learns" a result — e.g.
21561
+ * review findings — so follow-ups work). Appends onto the DAG leaf and invalidates the in-memory
21562
+ * cache; serialized on the per-agent write chain.
21563
+ *
21564
+ * @public
21565
+ */
21566
+ static async injectSessionTurn(agentId, turn) {
21567
+ let reg = getRegisteredAgent(agentId);
21568
+ if (reg === void 0) {
21569
+ await hydrateRegistryFromDisk(process.cwd());
21570
+ reg = getRegisteredAgent(agentId);
21571
+ }
21572
+ if (reg === void 0 || reg.runtime !== "local") {
21573
+ throw new exports.UnknownAgentError(`No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`);
21574
+ }
21575
+ const cwd = reg.cwd ?? process.cwd();
21576
+ const optModel = reg.options.model;
21577
+ const model = reg.model?.id ?? (typeof optModel === "string" ? optModel : optModel?.id) ?? "unknown";
21578
+ const { injectSessionTurn: injectSessionTurn2 } = await Promise.resolve().then(() => (init_inject_session(), inject_session_exports));
21579
+ const { FsSessionStore: FsSessionStore2 } = await Promise.resolve().then(() => (init_fs_session_store(), fs_session_store_exports));
21580
+ const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await Promise.resolve().then(() => (init_session_transcript(), session_transcript_exports));
21581
+ const baseDir = reg.options.local?.baseDir !== void 0 ? expandTilde2(reg.options.local.baseDir) : defaultBaseDir2();
21582
+ const store = new FsSessionStore2({ baseDir, cwd });
21583
+ await injectSessionTurn2({
21584
+ store,
21585
+ loc: { cwd, agentId, model },
21586
+ sessionId: agentId,
21587
+ userText: turn.userText,
21588
+ assistantText: turn.assistantText
21589
+ });
21590
+ }
21534
21591
  /**
21535
21592
  * Permanently delete a cloud agent.
21536
21593
  *