@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.
@@ -2579,4 +2579,4 @@ declare class Cron {
2579
2579
  static status(_options?: CronStartOptions): Promise<CronSchedulerStatus>;
2580
2580
  }
2581
2581
 
2582
- export { type CronSchedulerStatus as $, type AgentOptions as A, type BudgetTracker as B, type CloudOptions as C, type BudgetUsageEvent as D, type CloudEnv as E, type CloudRepo as F, type GetAgentOptions as G, type ContextBudget as H, type InlineSkill as I, type ContextManagerKind as J, type ContextSnapshot as K, type LocalOptions as L, type MemorySettings as M, type ContextSource as N, type ContextSourceStatus as O, type ProviderRoutingSettings as P, type CreateSkillSpec as Q, Cron as R, type SystemPromptResolver as S, type CronCreateOptions as T, type CronGetOptions as U, type CronJob as V, type CronJobStatus as W, type CronListOptions as X, type CronOperationOptions as Y, type CronRunOptions as Z, type CronRuntime as _, type AgentDefinition as a, type CronStartOptions as a0, type HookName as a1, type InvalidateCacheOptions as a2, type MemoryAdapter as a3, type MemoryAdapterCapabilities as a4, type MemoryContext as a5, type MemoryFact as a6, type MemoryProviderHandle as a7, type MemoryProviderInitOptions as a8, type MemoryRevision as a9, type SkillsResolver as aA, type SkillsResolverContext as aB, type SystemPromptContext as aC, type SystemPromptMemoryFact as aD, type SystemPromptSkillRef as aE, type TelemetrySettings as aF, type MemoryToolSchema as aa, type MemoryTurnMessage as ab, type PersonalityPreset as ac, type PluginContext as ad, type PostAssistantReplyContext as ae, type PreToolCallContext as af, type PreUserSendContext as ag, type PreUserSendResult as ah, type ProviderCapability as ai, type ProviderRoute as aj, type ProviderTransform as ak, type ProviderTransformContext as al, type RecordSessionSummaryArgs as am, type ResolvedProviderRoute as an, type RunUntilIterator as ao, type SDKAgentPlugins as ap, type SDKAgentSkillDetail as aq, type SDKAgentSkills as ar, type SDKArtifact as as, type SDKContextManager as at, type SDKPluginMetadata as au, type SDKProvidersManager as av, type SessionRecord as aw, type SessionStore as ax, type SettingSource as ay, Skill as az, type ContextSettings as b, type PluginsSettings as c, type SkillsSettings as d, type SDKAgent as e, type ListAgentsOptions as f, type ListResult as g, type SDKAgentInfo as h, type ListRunsOptions as i, type GetRunOptions as j, type AgentOperationOptions as k, type GoalOptions as l, type GoalEvent as m, type GoalResult as n, type Plugin as o, type ProviderProfile as p, type MemoryProvider as q, type MemoryId as r, type PreToolCallDecision as s, type StepResult as t, type SDKProvider as u, type ActiveMemoryPassArgs as v, type ActiveMemoryPassResult as w, type AgentMemory as x, type BudgetCheck as y, type BudgetTotal as z };
2582
+ export { type CronSchedulerStatus as $, type AgentOptions as A, type BudgetTracker as B, type CloudOptions as C, type BudgetUsageEvent as D, type CloudEnv as E, type CloudRepo as F, type GetAgentOptions as G, type ContextBudget as H, type InlineSkill as I, type ContextManagerKind as J, type ContextSnapshot as K, type LocalOptions as L, type MemorySettings as M, type ContextSource as N, type ContextSourceStatus as O, type ProviderRoutingSettings as P, type CreateSkillSpec as Q, Cron as R, type SystemPromptResolver as S, type CronCreateOptions as T, type CronGetOptions as U, type CronJob as V, type CronJobStatus as W, type CronListOptions as X, type CronOperationOptions as Y, type CronRunOptions as Z, type CronRuntime as _, type AgentDefinition as a, type CronStartOptions as a0, type HookName as a1, type InvalidateCacheOptions as a2, type MemoryAdapter as a3, type MemoryAdapterCapabilities as a4, type MemoryContext as a5, type MemoryFact as a6, type MemoryProviderHandle as a7, type MemoryProviderInitOptions as a8, type MemoryRevision as a9, type SkillsResolver as aA, type SkillsResolverContext as aB, type SystemPromptContext as aC, type SystemPromptMemoryFact as aD, type SystemPromptSkillRef as aE, type TelemetrySettings as aF, type MemoryToolSchema as aa, type MemoryTurnMessage as ab, type PersonalityPreset as ac, type PluginContext as ad, type PostAssistantReplyContext as ae, type PreToolCallContext as af, type PreUserSendContext as ag, type PreUserSendResult as ah, type ProviderCapability as ai, type ProviderRoute as aj, type ProviderTransform as ak, type ProviderTransformContext as al, type RecordSessionSummaryArgs as am, type ResolvedProviderRoute as an, type RunUntilIterator as ao, type SDKAgentPlugins as ap, type SDKAgentSkillDetail as aq, type SDKAgentSkills as ar, type SDKArtifact as as, type SDKContextManager as at, type SDKPluginMetadata as au, type SDKProvidersManager as av, type SessionRecord as aw, type SessionStore as ax, type SettingSource as ay, Skill as az, type ContextSettings as b, type PluginsSettings as c, type SkillsSettings as d, type SDKAgent as e, type ListAgentsOptions as f, type ListResult as g, type SDKAgentInfo as h, type ListRunsOptions as i, type GetRunOptions as j, type AgentOperationOptions as k, type Plugin as l, type ProviderProfile as m, type GoalOptions as n, type GoalEvent as o, type GoalResult as p, type MemoryProvider as q, type MemoryId as r, type PreToolCallDecision as s, type StepResult as t, type SDKProvider as u, type ActiveMemoryPassArgs as v, type ActiveMemoryPassResult as w, type AgentMemory as x, type BudgetCheck as y, type BudgetTotal as z };
@@ -2579,4 +2579,4 @@ declare class Cron {
2579
2579
  static status(_options?: CronStartOptions): Promise<CronSchedulerStatus>;
2580
2580
  }
2581
2581
 
2582
- export { type CronSchedulerStatus as $, type AgentOptions as A, type BudgetTracker as B, type CloudOptions as C, type BudgetUsageEvent as D, type CloudEnv as E, type CloudRepo as F, type GetAgentOptions as G, type ContextBudget as H, type InlineSkill as I, type ContextManagerKind as J, type ContextSnapshot as K, type LocalOptions as L, type MemorySettings as M, type ContextSource as N, type ContextSourceStatus as O, type ProviderRoutingSettings as P, type CreateSkillSpec as Q, Cron as R, type SystemPromptResolver as S, type CronCreateOptions as T, type CronGetOptions as U, type CronJob as V, type CronJobStatus as W, type CronListOptions as X, type CronOperationOptions as Y, type CronRunOptions as Z, type CronRuntime as _, type AgentDefinition as a, type CronStartOptions as a0, type HookName as a1, type InvalidateCacheOptions as a2, type MemoryAdapter as a3, type MemoryAdapterCapabilities as a4, type MemoryContext as a5, type MemoryFact as a6, type MemoryProviderHandle as a7, type MemoryProviderInitOptions as a8, type MemoryRevision as a9, type SkillsResolver as aA, type SkillsResolverContext as aB, type SystemPromptContext as aC, type SystemPromptMemoryFact as aD, type SystemPromptSkillRef as aE, type TelemetrySettings as aF, type MemoryToolSchema as aa, type MemoryTurnMessage as ab, type PersonalityPreset as ac, type PluginContext as ad, type PostAssistantReplyContext as ae, type PreToolCallContext as af, type PreUserSendContext as ag, type PreUserSendResult as ah, type ProviderCapability as ai, type ProviderRoute as aj, type ProviderTransform as ak, type ProviderTransformContext as al, type RecordSessionSummaryArgs as am, type ResolvedProviderRoute as an, type RunUntilIterator as ao, type SDKAgentPlugins as ap, type SDKAgentSkillDetail as aq, type SDKAgentSkills as ar, type SDKArtifact as as, type SDKContextManager as at, type SDKPluginMetadata as au, type SDKProvidersManager as av, type SessionRecord as aw, type SessionStore as ax, type SettingSource as ay, Skill as az, type ContextSettings as b, type PluginsSettings as c, type SkillsSettings as d, type SDKAgent as e, type ListAgentsOptions as f, type ListResult as g, type SDKAgentInfo as h, type ListRunsOptions as i, type GetRunOptions as j, type AgentOperationOptions as k, type GoalOptions as l, type GoalEvent as m, type GoalResult as n, type Plugin as o, type ProviderProfile as p, type MemoryProvider as q, type MemoryId as r, type PreToolCallDecision as s, type StepResult as t, type SDKProvider as u, type ActiveMemoryPassArgs as v, type ActiveMemoryPassResult as w, type AgentMemory as x, type BudgetCheck as y, type BudgetTotal as z };
2582
+ export { type CronSchedulerStatus as $, type AgentOptions as A, type BudgetTracker as B, type CloudOptions as C, type BudgetUsageEvent as D, type CloudEnv as E, type CloudRepo as F, type GetAgentOptions as G, type ContextBudget as H, type InlineSkill as I, type ContextManagerKind as J, type ContextSnapshot as K, type LocalOptions as L, type MemorySettings as M, type ContextSource as N, type ContextSourceStatus as O, type ProviderRoutingSettings as P, type CreateSkillSpec as Q, Cron as R, type SystemPromptResolver as S, type CronCreateOptions as T, type CronGetOptions as U, type CronJob as V, type CronJobStatus as W, type CronListOptions as X, type CronOperationOptions as Y, type CronRunOptions as Z, type CronRuntime as _, type AgentDefinition as a, type CronStartOptions as a0, type HookName as a1, type InvalidateCacheOptions as a2, type MemoryAdapter as a3, type MemoryAdapterCapabilities as a4, type MemoryContext as a5, type MemoryFact as a6, type MemoryProviderHandle as a7, type MemoryProviderInitOptions as a8, type MemoryRevision as a9, type SkillsResolver as aA, type SkillsResolverContext as aB, type SystemPromptContext as aC, type SystemPromptMemoryFact as aD, type SystemPromptSkillRef as aE, type TelemetrySettings as aF, type MemoryToolSchema as aa, type MemoryTurnMessage as ab, type PersonalityPreset as ac, type PluginContext as ad, type PostAssistantReplyContext as ae, type PreToolCallContext as af, type PreUserSendContext as ag, type PreUserSendResult as ah, type ProviderCapability as ai, type ProviderRoute as aj, type ProviderTransform as ak, type ProviderTransformContext as al, type RecordSessionSummaryArgs as am, type ResolvedProviderRoute as an, type RunUntilIterator as ao, type SDKAgentPlugins as ap, type SDKAgentSkillDetail as aq, type SDKAgentSkills as ar, type SDKArtifact as as, type SDKContextManager as at, type SDKPluginMetadata as au, type SDKProvidersManager as av, type SessionRecord as aw, type SessionStore as ax, type SettingSource as ay, Skill as az, type ContextSettings as b, type PluginsSettings as c, type SkillsSettings as d, type SDKAgent as e, type ListAgentsOptions as f, type ListResult as g, type SDKAgentInfo as h, type ListRunsOptions as i, type GetRunOptions as j, type AgentOperationOptions as k, type Plugin as l, type ProviderProfile as m, type GoalOptions as n, type GoalEvent as o, type GoalResult as p, type MemoryProvider as q, type MemoryId as r, type PreToolCallDecision as s, type StepResult as t, type SDKProvider as u, type ActiveMemoryPassArgs as v, type ActiveMemoryPassResult as w, type AgentMemory as x, type BudgetCheck as y, type BudgetTotal as z };
package/dist/cron.cjs CHANGED
@@ -6001,12 +6001,14 @@ __export(compact_session_exports, {
6001
6001
  shouldAutoCompact: () => shouldAutoCompact
6002
6002
  });
6003
6003
  function isCompactSummary(content) {
6004
- return content.startsWith(COMPACT_SUMMARY_MARKER);
6004
+ return content.startsWith(COMPACT_SUMMARY_MARKER) || content.startsWith("[[theokit:goal-continuation]]");
6005
6005
  }
6006
6006
  function plainText(content) {
6007
6007
  if (typeof content === "string") return content;
6008
6008
  if (!Array.isArray(content)) return void 0;
6009
- const texts = content.filter((p) => p !== null && typeof p === "object" && p.type === "text" && typeof p.text === "string").map((p) => p.text);
6009
+ const texts = content.filter(
6010
+ (p) => p !== null && typeof p === "object" && p.type === "text" && typeof p.text === "string"
6011
+ ).map((p) => p.text);
6010
6012
  return texts.length > 0 ? texts.join("\n") : void 0;
6011
6013
  }
6012
6014
  async function compactSessionTranscript(opts) {
@@ -6127,8 +6129,10 @@ async function autoCompactIfNeeded(opts) {
6127
6129
  return true;
6128
6130
  } catch (cause) {
6129
6131
  const msg = cause instanceof Error ? cause.message : String(cause);
6130
- process.stderr.write(`[theokit-sdk] auto-compaction failed (left transcript untouched): ${msg}
6131
- `);
6132
+ process.stderr.write(
6133
+ `[theokit-sdk] auto-compaction failed (left transcript untouched): ${msg}
6134
+ `
6135
+ );
6132
6136
  return false;
6133
6137
  }
6134
6138
  }
@@ -6138,11 +6142,11 @@ var init_compact_session = __esm({
6138
6142
  init_compaction();
6139
6143
  init_router();
6140
6144
  init_real_local_run_provider();
6145
+ init_session_transcript();
6141
6146
  init_providers();
6142
6147
  init_compression_model_registry();
6143
6148
  init_compression_summarizer();
6144
6149
  init_agent_session();
6145
- init_session_transcript();
6146
6150
  COMPACT_SUMMARY_MARKER = "[[theokit:compact-summary]]";
6147
6151
  COMPACT_USER_MESSAGE_MAX_TOKENS = 2e4;
6148
6152
  autoCompactAttempts = (() => {
@@ -6247,6 +6251,14 @@ var init_context = __esm({
6247
6251
  }
6248
6252
  });
6249
6253
 
6254
+ // src/goal-loop.ts
6255
+ var GOAL_CONTINUATION_MARKER;
6256
+ var init_goal_loop = __esm({
6257
+ "src/goal-loop.ts"() {
6258
+ GOAL_CONTINUATION_MARKER = "[[theokit:goal-continuation]]";
6259
+ }
6260
+ });
6261
+
6250
6262
  // src/internal/runtime/lifecycle/run-until.ts
6251
6263
  var run_until_exports = {};
6252
6264
  __export(run_until_exports, {
@@ -6390,6 +6402,7 @@ async function* runUntilImpl(agent, goal, options, deps) {
6390
6402
  }
6391
6403
  function composeContinuation(goal, lastResponse) {
6392
6404
  return [
6405
+ GOAL_CONTINUATION_MARKER,
6393
6406
  "Continue working toward the active goal.",
6394
6407
  "",
6395
6408
  `<objective>
@@ -6410,11 +6423,12 @@ ${goal}
6410
6423
  " current state, requirement by requirement. Treat uncertain or indirect evidence as not achieved.",
6411
6424
  "",
6412
6425
  `Your last response was:
6413
- ${lastResponse.slice(0, 1e3)}`
6426
+ ${lastResponse.slice(-1e3)}`
6414
6427
  ].join("\n");
6415
6428
  }
6416
6429
  var init_run_until = __esm({
6417
6430
  "src/internal/runtime/lifecycle/run-until.ts"() {
6431
+ init_goal_loop();
6418
6432
  }
6419
6433
  });
6420
6434
 
@@ -17154,7 +17168,9 @@ async function loadDriver(filePath) {
17154
17168
  }
17155
17169
  try {
17156
17170
  const mod = await (driverLoaderOverrides?.nodeSqlite?.() ?? Promise.resolve(
17157
- process.getBuiltinModule?.("node:sqlite") ?? (() => {
17171
+ process.getBuiltinModule?.(
17172
+ "node:sqlite"
17173
+ ) ?? (() => {
17158
17174
  throw new Error("node:sqlite built-in unavailable (Node < 22.3)");
17159
17175
  })()
17160
17176
  ));
@@ -19688,8 +19704,8 @@ async function getRegisteredAgentOrThrow(agentId) {
19688
19704
  // src/agent.ts
19689
19705
  init_errors();
19690
19706
  init_discovery();
19691
- init_agent_session();
19692
19707
  init_agent_factory_registry();
19708
+ init_agent_session();
19693
19709
  var streamObjectImport;
19694
19710
  var Agent = class _Agent {
19695
19711
  constructor() {
@@ -19981,7 +19997,9 @@ var Agent = class _Agent {
19981
19997
  reg = getRegisteredAgent(agentId);
19982
19998
  }
19983
19999
  if (reg === void 0 || reg.runtime !== "local") {
19984
- throw new UnknownAgentError(`No local agent "${agentId}" registered \u2014 compact targets local sessions.`);
20000
+ throw new UnknownAgentError(
20001
+ `No local agent "${agentId}" registered \u2014 compact targets local sessions.`
20002
+ );
19985
20003
  }
19986
20004
  const cwd = reg.cwd ?? process.cwd();
19987
20005
  const optModel = reg.options.model;
@@ -19991,16 +20009,20 @@ var Agent = class _Agent {
19991
20009
  const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await Promise.resolve().then(() => (init_session_transcript(), session_transcript_exports));
19992
20010
  const baseDir = reg.options.local?.baseDir !== void 0 ? expandTilde2(reg.options.local.baseDir) : defaultBaseDir2();
19993
20011
  const store = new FsSessionStore2({ baseDir, cwd });
19994
- return enqueueSessionWrite(cwd, agentId, () => compactSessionTranscript2({
19995
- store,
19996
- loc: { cwd, agentId, model },
19997
- sessionId: agentId,
19998
- trigger: options.trigger ?? "manual",
19999
- summarize: options.summarize ?? buildDefaultSummarizer2({
20000
- agentModel: model,
20001
- ...reg.options.apiKey !== void 0 ? { apiKey: reg.options.apiKey } : {}
20012
+ return enqueueSessionWrite(
20013
+ cwd,
20014
+ agentId,
20015
+ () => compactSessionTranscript2({
20016
+ store,
20017
+ loc: { cwd, agentId, model },
20018
+ sessionId: agentId,
20019
+ trigger: options.trigger ?? "manual",
20020
+ summarize: options.summarize ?? buildDefaultSummarizer2({
20021
+ agentModel: model,
20022
+ ...reg.options.apiKey !== void 0 ? { apiKey: reg.options.apiKey } : {}
20023
+ })
20002
20024
  })
20003
- }));
20025
+ );
20004
20026
  }
20005
20027
  /**
20006
20028
  * M51 — inject a SYNTHETIC user+assistant pair into a LOCAL session's persisted transcript WITHOUT
@@ -20017,7 +20039,9 @@ var Agent = class _Agent {
20017
20039
  reg = getRegisteredAgent(agentId);
20018
20040
  }
20019
20041
  if (reg === void 0 || reg.runtime !== "local") {
20020
- throw new UnknownAgentError(`No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`);
20042
+ throw new UnknownAgentError(
20043
+ `No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`
20044
+ );
20021
20045
  }
20022
20046
  const cwd = reg.cwd ?? process.cwd();
20023
20047
  const optModel = reg.options.model;