@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/dist/index.d.cts CHANGED
@@ -650,6 +650,18 @@ declare class Agent {
650
650
  trigger?: "manual" | "auto";
651
651
  summarize?: (messages: readonly CompressibleMessage[]) => Promise<string>;
652
652
  }): Promise<CompactResult>;
653
+ /**
654
+ * M51 — inject a SYNTHETIC user+assistant pair into a LOCAL session's persisted transcript WITHOUT
655
+ * running an LLM turn (the Codex review-exit mechanism: the parent thread "learns" a result — e.g.
656
+ * review findings — so follow-ups work). Appends onto the DAG leaf and invalidates the in-memory
657
+ * cache; serialized on the per-agent write chain.
658
+ *
659
+ * @public
660
+ */
661
+ static injectSessionTurn(agentId: string, turn: {
662
+ userText: string;
663
+ assistantText: string;
664
+ }): Promise<void>;
653
665
  /**
654
666
  * Permanently delete a cloud agent.
655
667
  *
package/dist/index.d.ts CHANGED
@@ -650,6 +650,18 @@ declare class Agent {
650
650
  trigger?: "manual" | "auto";
651
651
  summarize?: (messages: readonly CompressibleMessage[]) => Promise<string>;
652
652
  }): Promise<CompactResult>;
653
+ /**
654
+ * M51 — inject a SYNTHETIC user+assistant pair into a LOCAL session's persisted transcript WITHOUT
655
+ * running an LLM turn (the Codex review-exit mechanism: the parent thread "learns" a result — e.g.
656
+ * review findings — so follow-ups work). Appends onto the DAG leaf and invalidates the in-memory
657
+ * cache; serialized on the per-agent write chain.
658
+ *
659
+ * @public
660
+ */
661
+ static injectSessionTurn(agentId: string, turn: {
662
+ userText: string;
663
+ assistantText: string;
664
+ }): Promise<void>;
653
665
  /**
654
666
  * Permanently delete a cloud agent.
655
667
  *
package/dist/index.js CHANGED
@@ -6234,10 +6234,12 @@ function buildDefaultSummarizer(opts) {
6234
6234
  return async (messages) => {
6235
6235
  registerBuiltins();
6236
6236
  const modelPrefix = opts.agentModel.includes("/") ? opts.agentModel.slice(0, opts.agentModel.indexOf("/")) : void 0;
6237
+ const prefixProfile = modelPrefix !== void 0 ? getProviderProfile(modelPrefix) : void 0;
6238
+ const prefixUsable = prefixProfile !== void 0 && (prefixProfile.authType !== "api_key" || prefixProfile.envVars.some((v) => (process.env[v] ?? "").length > 0));
6237
6239
  const route = resolveSummarizerRoute({
6238
6240
  keyProvider: inferProviderFromApiKey(opts.apiKey),
6239
6241
  modelPrefix,
6240
- prefixHasProfile: modelPrefix !== void 0 && getProviderProfile(modelPrefix) !== void 0,
6242
+ prefixHasProfile: prefixUsable,
6241
6243
  envProvider: detectPrimaryProvider()
6242
6244
  });
6243
6245
  const provider = route.provider;
@@ -9026,6 +9028,32 @@ var init_batch = __esm({
9026
9028
  }
9027
9029
  });
9028
9030
 
9031
+ // src/internal/session/inject-session.ts
9032
+ var inject_session_exports = {};
9033
+ __export(inject_session_exports, {
9034
+ injectSessionTurn: () => injectSessionTurn
9035
+ });
9036
+ async function injectSessionTurn(opts) {
9037
+ await enqueueSessionWrite(opts.loc.cwd, opts.loc.agentId, async () => {
9038
+ const prior = await opts.store.readRecords(opts.loc.agentId);
9039
+ const transcript = SessionTranscript.fromRecords(prior, {
9040
+ cwd: opts.loc.cwd,
9041
+ sessionId: opts.sessionId,
9042
+ model: opts.loc.model ?? "unknown"
9043
+ });
9044
+ transcript.appendUserTurn(opts.userText);
9045
+ transcript.appendAssistantTurn({ text: opts.assistantText });
9046
+ await opts.store.appendRecords(opts.loc.agentId, transcript.records().slice(prior.length));
9047
+ invalidateSessionCache(opts.loc.cwd, opts.loc.agentId);
9048
+ });
9049
+ }
9050
+ var init_inject_session = __esm({
9051
+ "src/internal/session/inject-session.ts"() {
9052
+ init_session_transcript();
9053
+ init_agent_session();
9054
+ }
9055
+ });
9056
+
9029
9057
  // src/types/workflow.ts
9030
9058
  var WorkflowDuplicateStepIdError, WorkflowInputError, WorkflowOutputError, WorkflowStateError, WorkflowAlreadyRunningError, WorkflowSnapshotNotFoundError, WorkflowMaxIterationsExceededError, WorkflowNotSerializableError, WorkflowResumeStepNotFoundError, WorkflowParallelError, WorkflowCompensateNotImplementedError;
9031
9059
  var init_workflow = __esm({
@@ -21526,6 +21554,39 @@ var Agent = class _Agent {
21526
21554
  })
21527
21555
  }));
21528
21556
  }
21557
+ /**
21558
+ * M51 — inject a SYNTHETIC user+assistant pair into a LOCAL session's persisted transcript WITHOUT
21559
+ * running an LLM turn (the Codex review-exit mechanism: the parent thread "learns" a result — e.g.
21560
+ * review findings — so follow-ups work). Appends onto the DAG leaf and invalidates the in-memory
21561
+ * cache; serialized on the per-agent write chain.
21562
+ *
21563
+ * @public
21564
+ */
21565
+ static async injectSessionTurn(agentId, turn) {
21566
+ let reg = getRegisteredAgent(agentId);
21567
+ if (reg === void 0) {
21568
+ await hydrateRegistryFromDisk(process.cwd());
21569
+ reg = getRegisteredAgent(agentId);
21570
+ }
21571
+ if (reg === void 0 || reg.runtime !== "local") {
21572
+ throw new UnknownAgentError(`No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`);
21573
+ }
21574
+ const cwd = reg.cwd ?? process.cwd();
21575
+ const optModel = reg.options.model;
21576
+ const model = reg.model?.id ?? (typeof optModel === "string" ? optModel : optModel?.id) ?? "unknown";
21577
+ const { injectSessionTurn: injectSessionTurn2 } = await Promise.resolve().then(() => (init_inject_session(), inject_session_exports));
21578
+ const { FsSessionStore: FsSessionStore2 } = await Promise.resolve().then(() => (init_fs_session_store(), fs_session_store_exports));
21579
+ const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await Promise.resolve().then(() => (init_session_transcript(), session_transcript_exports));
21580
+ const baseDir = reg.options.local?.baseDir !== void 0 ? expandTilde2(reg.options.local.baseDir) : defaultBaseDir2();
21581
+ const store = new FsSessionStore2({ baseDir, cwd });
21582
+ await injectSessionTurn2({
21583
+ store,
21584
+ loc: { cwd, agentId, model },
21585
+ sessionId: agentId,
21586
+ userText: turn.userText,
21587
+ assistantText: turn.assistantText
21588
+ });
21589
+ }
21529
21590
  /**
21530
21591
  * Permanently delete a cloud agent.
21531
21592
  *