@sema-agent/server 1.254.0 → 1.256.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/main.js CHANGED
@@ -5,7 +5,7 @@ import { homedir } from "node:os";
5
5
  import { join } from "node:path";
6
6
  import { loadRemoteExec } from "@sema-agent/registry-core/node";
7
7
  import { skillContentHash } from "@sema-agent/registry-core";
8
- import { Runner, TtlSessionStore, uuidv7, FileRosterStore, FileBackgroundAgentStore, defaultTaskRegistry, combinePolicies, createDurableQuestionPolicy, createAllowDenyPolicy, tightenTaskSpec, isThinkingLevel, QUESTION_AWAITS_RESUME, FileWorkflowRunStore, InMemoryWorkflowRunStore, workflowsCapability, NodeLspManager, createFileWorkflowScriptStore, expandTiers, NodeExecutionEnv, CenterPromptSource, FilePromptArtifactStore, FilePromptSourceStateStore, MemoryPromptArtifactStore, MemoryPromptSourceStateStore, verifyPromptArtifact } from "@sema-agent/core";
8
+ import { Runner, TtlSessionStore, uuidv7, FileRosterStore, FileBackgroundAgentStore, FileMailboxStore, defaultTaskRegistry, combinePolicies, createDurableQuestionPolicy, createAllowDenyPolicy, tightenTaskSpec, isThinkingLevel, QUESTION_AWAITS_RESUME, FileWorkflowRunStore, InMemoryWorkflowRunStore, workflowsCapability, NodeLspManager, createFileWorkflowScriptStore, expandTiers, NodeExecutionEnv, CenterPromptSource, FilePromptArtifactStore, FilePromptSourceStateStore, MemoryPromptArtifactStore, MemoryPromptSourceStateStore, verifyPromptArtifact } from "@sema-agent/core";
9
9
  import { PgMemoryEngineBackend, ensurePgMemoryEngineSchema } from "./plugins/memory-engine-pg.js";
10
10
  import { TiDBMemoryEngineBackend, ensureTiDBMemoryEngineSchema } from "./plugins/memory-engine-tidb.js";
11
11
  import { PgMemoryHistoryStore, ensurePgMemoryHistorySchema, PgMemorySyncStore, ensurePgMemorySyncSchema } from "./plugins/memory-sync-store-pg.js";
@@ -79,6 +79,7 @@ import { validatePromptsDomain, centerPromptProvider, centerIdentityAssembled, a
79
79
  import { defaultLkgPath, defaultSkillCacheDir, saveLkg, loadLkg } from "./config-lkg.js";
80
80
  import { TiDBRosterStore, PgRosterStore, ensureTiDBRosterSchema, ensurePgRosterSchema } from "./plugins/roster-store-sql.js";
81
81
  import { TiDBBackgroundAgentStore, PgBackgroundAgentStore, ensureTiDBBackgroundAgentSchema, ensurePgBackgroundAgentSchema } from "./plugins/background-agent-store-sql.js";
82
+ import { TiDBMailboxStore, PgMailboxStore, ensureTiDBMailboxSchema, ensurePgMailboxSchema } from "./plugins/mailbox-store-sql.js";
82
83
  import { createPrincipalCapsClient, gateExecutionLane, scopedTokenNeedsWorker, applyObserverEnvOptIn } from "./runtime-caps-resolver.js";
83
84
  import { applyRuntimeGovernance, stripDelegationTools } from "./runtime-governance.js";
84
85
  import { parseTaskSettings, applyTaskSettings, coercePermissionMode, withPermissionMode, effectiveThinking, acceptAppendSystemPrompt, hasConstitutionAnchors, providerDropsAppend, MAX_SETTINGS_OUTPUT_STYLE_CHARS } from "./task-settings.js";
@@ -534,6 +535,24 @@ async function main() {
534
535
  if (backgroundAgentStore)
535
536
  logger.info("background_agent_store_enabled", { backend: pgPool ? "pg" : mysqlPool ? "tidb" : "file" });
536
537
  }
538
+ let mailboxStore;
539
+ {
540
+ const mysqlPool = backend?.mysqlPool?.();
541
+ const pgPool = backend?.pgPool?.();
542
+ if (pgPool) {
543
+ await ensurePgMailboxSchema(async (text, params) => pgPool.query(text, params));
544
+ mailboxStore = new PgMailboxStore(pgPool);
545
+ }
546
+ else if (mysqlPool) {
547
+ await ensureTiDBMailboxSchema(mysqlPool);
548
+ mailboxStore = new TiDBMailboxStore(mysqlPool);
549
+ }
550
+ else if (backend?.kind === "local") {
551
+ mailboxStore = new FileMailboxStore(config.localDataRoot ?? localRoot);
552
+ }
553
+ if (mailboxStore)
554
+ logger.info("mailbox_store_enabled", { backend: pgPool ? "pg" : mysqlPool ? "tidb" : "file" });
555
+ }
537
556
  const memoryExportBackend = config.memoryEngineBackend !== "file" ? memoryEngine?.backend : undefined;
538
557
  const memoryLane = memoryEngineRemoteLanePosture(config);
539
558
  if (config.memoryEngineBackend === "file" || !config.memoryEngineEnabled) {
@@ -931,6 +950,7 @@ async function main() {
931
950
  promptSource,
932
951
  ...(rosterStore ? { rosterStore } : {}),
933
952
  ...(backgroundAgentStore ? { backgroundAgentStore } : {}),
953
+ ...(mailboxStore ? { mailboxStore } : {}),
934
954
  brain,
935
955
  models: config.models,
936
956
  roles: config.roles,
@@ -1120,7 +1140,7 @@ async function main() {
1120
1140
  if (sessionTitler)
1121
1141
  logger.info("session_auto_title_enabled", {});
1122
1142
  const workflowsCapable = workflowsCapability(runnerDeps);
1123
- const subRunner = new Runner({ brain, models: config.models, roles: config.roles, pricing, tracer, promptSource, sessionStore: new ForkRoutingSessionStore(sessionStore, new TtlSessionStore({ defaultTtlDays: 1 / 24 })), ...(executionEnvFactory ? { executionEnvFactory } : {}), ...(lspManager ? { lspManager } : {}), ...(backgroundAgentStore ? { backgroundAgentStore } : {}) });
1143
+ const subRunner = new Runner({ brain, models: config.models, roles: config.roles, pricing, tracer, promptSource, sessionStore: new ForkRoutingSessionStore(sessionStore, new TtlSessionStore({ defaultTtlDays: 1 / 24 })), ...(executionEnvFactory ? { executionEnvFactory } : {}), ...(lspManager ? { lspManager } : {}), ...(backgroundAgentStore ? { backgroundAgentStore } : {}), ...(mailboxStore ? { mailboxStore } : {}) });
1124
1144
  const authorize = createAuthorizer(config, sessionStore);
1125
1145
  const runStore = backend ? backend.run() : undefined;
1126
1146
  const resumeAnchorStore = backend ? backend.resumeAnchor() : undefined;