@theokit/sdk 4.19.0 → 4.19.2

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/eval.cjs CHANGED
@@ -6000,12 +6000,14 @@ __export(compact_session_exports, {
6000
6000
  shouldAutoCompact: () => shouldAutoCompact
6001
6001
  });
6002
6002
  function isCompactSummary(content) {
6003
- return content.startsWith(COMPACT_SUMMARY_MARKER);
6003
+ return content.startsWith(COMPACT_SUMMARY_MARKER) || content.startsWith("[[theokit:goal-continuation]]");
6004
6004
  }
6005
6005
  function plainText(content) {
6006
6006
  if (typeof content === "string") return content;
6007
6007
  if (!Array.isArray(content)) return void 0;
6008
- const texts = content.filter((p) => p !== null && typeof p === "object" && p.type === "text" && typeof p.text === "string").map((p) => p.text);
6008
+ const texts = content.filter(
6009
+ (p) => p !== null && typeof p === "object" && p.type === "text" && typeof p.text === "string"
6010
+ ).map((p) => p.text);
6009
6011
  return texts.length > 0 ? texts.join("\n") : void 0;
6010
6012
  }
6011
6013
  async function compactSessionTranscript(opts) {
@@ -6126,8 +6128,10 @@ async function autoCompactIfNeeded(opts) {
6126
6128
  return true;
6127
6129
  } catch (cause) {
6128
6130
  const msg = cause instanceof Error ? cause.message : String(cause);
6129
- process.stderr.write(`[theokit-sdk] auto-compaction failed (left transcript untouched): ${msg}
6130
- `);
6131
+ process.stderr.write(
6132
+ `[theokit-sdk] auto-compaction failed (left transcript untouched): ${msg}
6133
+ `
6134
+ );
6131
6135
  return false;
6132
6136
  }
6133
6137
  }
@@ -6137,11 +6141,11 @@ var init_compact_session = __esm({
6137
6141
  init_compaction();
6138
6142
  init_router();
6139
6143
  init_real_local_run_provider();
6144
+ init_session_transcript();
6140
6145
  init_providers();
6141
6146
  init_compression_model_registry();
6142
6147
  init_compression_summarizer();
6143
6148
  init_agent_session();
6144
- init_session_transcript();
6145
6149
  COMPACT_SUMMARY_MARKER = "[[theokit:compact-summary]]";
6146
6150
  COMPACT_USER_MESSAGE_MAX_TOKENS = 2e4;
6147
6151
  autoCompactAttempts = (() => {
@@ -6246,6 +6250,14 @@ var init_context = __esm({
6246
6250
  }
6247
6251
  });
6248
6252
 
6253
+ // src/goal-loop.ts
6254
+ var GOAL_CONTINUATION_MARKER;
6255
+ var init_goal_loop = __esm({
6256
+ "src/goal-loop.ts"() {
6257
+ GOAL_CONTINUATION_MARKER = "[[theokit:goal-continuation]]";
6258
+ }
6259
+ });
6260
+
6249
6261
  // src/internal/runtime/lifecycle/run-until.ts
6250
6262
  var run_until_exports = {};
6251
6263
  __export(run_until_exports, {
@@ -6389,6 +6401,7 @@ async function* runUntilImpl(agent, goal, options, deps) {
6389
6401
  }
6390
6402
  function composeContinuation(goal, lastResponse) {
6391
6403
  return [
6404
+ GOAL_CONTINUATION_MARKER,
6392
6405
  "Continue working toward the active goal.",
6393
6406
  "",
6394
6407
  `<objective>
@@ -6409,11 +6422,12 @@ ${goal}
6409
6422
  " current state, requirement by requirement. Treat uncertain or indirect evidence as not achieved.",
6410
6423
  "",
6411
6424
  `Your last response was:
6412
- ${lastResponse.slice(0, 1e3)}`
6425
+ ${lastResponse.slice(-1e3)}`
6413
6426
  ].join("\n");
6414
6427
  }
6415
6428
  var init_run_until = __esm({
6416
6429
  "src/internal/runtime/lifecycle/run-until.ts"() {
6430
+ init_goal_loop();
6417
6431
  }
6418
6432
  });
6419
6433
 
@@ -17149,7 +17163,9 @@ async function loadDriver(filePath) {
17149
17163
  }
17150
17164
  try {
17151
17165
  const mod = await (driverLoaderOverrides?.nodeSqlite?.() ?? Promise.resolve(
17152
- process.getBuiltinModule?.("node:sqlite") ?? (() => {
17166
+ process.getBuiltinModule?.(
17167
+ "node:sqlite"
17168
+ ) ?? (() => {
17153
17169
  throw new Error("node:sqlite built-in unavailable (Node < 22.3)");
17154
17170
  })()
17155
17171
  ));
@@ -19683,8 +19699,8 @@ async function getRegisteredAgentOrThrow(agentId) {
19683
19699
  // src/agent.ts
19684
19700
  init_errors();
19685
19701
  init_discovery();
19686
- init_agent_session();
19687
19702
  init_agent_factory_registry();
19703
+ init_agent_session();
19688
19704
  var streamObjectImport;
19689
19705
  var Agent = class _Agent {
19690
19706
  constructor() {
@@ -19976,7 +19992,9 @@ var Agent = class _Agent {
19976
19992
  reg = getRegisteredAgent(agentId);
19977
19993
  }
19978
19994
  if (reg === void 0 || reg.runtime !== "local") {
19979
- throw new UnknownAgentError(`No local agent "${agentId}" registered \u2014 compact targets local sessions.`);
19995
+ throw new UnknownAgentError(
19996
+ `No local agent "${agentId}" registered \u2014 compact targets local sessions.`
19997
+ );
19980
19998
  }
19981
19999
  const cwd = reg.cwd ?? process.cwd();
19982
20000
  const optModel = reg.options.model;
@@ -19986,16 +20004,20 @@ var Agent = class _Agent {
19986
20004
  const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await Promise.resolve().then(() => (init_session_transcript(), session_transcript_exports));
19987
20005
  const baseDir = reg.options.local?.baseDir !== void 0 ? expandTilde2(reg.options.local.baseDir) : defaultBaseDir2();
19988
20006
  const store = new FsSessionStore2({ baseDir, cwd });
19989
- return enqueueSessionWrite(cwd, agentId, () => compactSessionTranscript2({
19990
- store,
19991
- loc: { cwd, agentId, model },
19992
- sessionId: agentId,
19993
- trigger: options.trigger ?? "manual",
19994
- summarize: options.summarize ?? buildDefaultSummarizer2({
19995
- agentModel: model,
19996
- ...reg.options.apiKey !== void 0 ? { apiKey: reg.options.apiKey } : {}
20007
+ return enqueueSessionWrite(
20008
+ cwd,
20009
+ agentId,
20010
+ () => compactSessionTranscript2({
20011
+ store,
20012
+ loc: { cwd, agentId, model },
20013
+ sessionId: agentId,
20014
+ trigger: options.trigger ?? "manual",
20015
+ summarize: options.summarize ?? buildDefaultSummarizer2({
20016
+ agentModel: model,
20017
+ ...reg.options.apiKey !== void 0 ? { apiKey: reg.options.apiKey } : {}
20018
+ })
19997
20019
  })
19998
- }));
20020
+ );
19999
20021
  }
20000
20022
  /**
20001
20023
  * M51 — inject a SYNTHETIC user+assistant pair into a LOCAL session's persisted transcript WITHOUT
@@ -20012,7 +20034,9 @@ var Agent = class _Agent {
20012
20034
  reg = getRegisteredAgent(agentId);
20013
20035
  }
20014
20036
  if (reg === void 0 || reg.runtime !== "local") {
20015
- throw new UnknownAgentError(`No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`);
20037
+ throw new UnknownAgentError(
20038
+ `No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`
20039
+ );
20016
20040
  }
20017
20041
  const cwd = reg.cwd ?? process.cwd();
20018
20042
  const optModel = reg.options.model;