@theokit/sdk 4.16.6 → 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,17 @@
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
+
9
+ ## 4.16.7
10
+
11
+ ### Patch Changes
12
+
13
+ - fix(session): a model-prefix profile only wins the summarizer route when its credential is actually RESOLVABLE (oauth/none own their auth; api_key needs one of the profile's env vars set) — an `openai` prefix with only OPENROUTER_API_KEY in the environment now falls through to env detection instead of failing with "No provider client".
14
+
3
15
  ## 4.16.6
4
16
 
5
17
  ### 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
@@ -6064,10 +6064,12 @@ function buildDefaultSummarizer(opts) {
6064
6064
  return async (messages) => {
6065
6065
  registerBuiltins();
6066
6066
  const modelPrefix = opts.agentModel.includes("/") ? opts.agentModel.slice(0, opts.agentModel.indexOf("/")) : void 0;
6067
+ const prefixProfile = modelPrefix !== void 0 ? getProviderProfile(modelPrefix) : void 0;
6068
+ const prefixUsable = prefixProfile !== void 0 && (prefixProfile.authType !== "api_key" || prefixProfile.envVars.some((v) => (process.env[v] ?? "").length > 0));
6067
6069
  const route = resolveSummarizerRoute({
6068
6070
  keyProvider: inferProviderFromApiKey(opts.apiKey),
6069
6071
  modelPrefix,
6070
- prefixHasProfile: modelPrefix !== void 0 && getProviderProfile(modelPrefix) !== void 0,
6072
+ prefixHasProfile: prefixUsable,
6071
6073
  envProvider: detectPrimaryProvider()
6072
6074
  });
6073
6075
  const provider = route.provider;
@@ -7595,6 +7597,32 @@ var init_batch = __esm({
7595
7597
  }
7596
7598
  });
7597
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
+
7598
7626
  // src/agent-builder.ts
7599
7627
  var AgentBuilder = class {
7600
7628
  opts = {};
@@ -19902,6 +19930,39 @@ var Agent = class _Agent {
19902
19930
  })
19903
19931
  }));
19904
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
+ }
19905
19966
  /**
19906
19967
  * Permanently delete a cloud agent.
19907
19968
  *