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