@sema-agent/server 1.318.0 → 1.320.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.
@@ -1,4 +1,4 @@
1
- import { CODE_AGENT_PROMPT, CODE_SYSTEM_PROMPT, DEFAULT_SYSTEM_PROMPT, assembleFullBodyTools, createGiteaIssueTool, defaultTaskRegistry } from "@sema-agent/core";
1
+ import { CODE_AGENT_PROMPT, CODE_SYSTEM_PROMPT, DEFAULT_SYSTEM_PROMPT, assembleCodeTools, createGiteaIssueTool, defaultTaskRegistry } from "@sema-agent/core";
2
2
  import { HttpError } from "../security.js";
3
3
  import { nowTool } from "./builtin-tools.js";
4
4
  import { GiteaClient, parseRepo, repoToolsFor } from "./repo-tools.js";
@@ -38,7 +38,7 @@ export function buildScenarios(deps) {
38
38
  return {
39
39
  tools: [
40
40
  nowTool(),
41
- ...assembleFullBodyTools({
41
+ ...assembleCodeTools({
42
42
  ...(deps.webFetchSummarize ? { webFetch: { summarize: deps.webFetchSummarize } } : {}),
43
43
  todoWrite: false,
44
44
  taskList: true,
@@ -454,7 +454,7 @@ async function handleRunsBody(req, res, url, ctx, miss) {
454
454
  leafId,
455
455
  gate: { kind: "task_done" },
456
456
  pendingAction: { kind: "task_done" },
457
- state: { activeTools: [], nestedStats: { tokens: 0, turns: 0, tasks: 0, costUsd: 0, costMicroUsd: 0 } },
457
+ state: { activeTools: [], nestedStats: { tokens: 0, turns: 0, tasks: 0, costMicroUsd: 0 } },
458
458
  status: "pending",
459
459
  createdAt: Date.now(),
460
460
  sourceTaskId: taskId,
@@ -1,4 +1,4 @@
1
- import { projectEvents, runSummary, mapTraceEvent } from "../../trace/project.js";
1
+ import { projectEvents, taskSummary, mapTraceEvent } from "../../trace/project.js";
2
2
  import { projectArtifacts } from "../../trace/artifacts.js";
3
3
  import { usageSummary, usageSeries, usageBreakdown } from "../../usage-analytics.js";
4
4
  import { sleep } from "../sse-log.js";
@@ -146,7 +146,7 @@ async function handleTaskList(res, runStore, query, forceOwner) {
146
146
  const rows = await runStore.listRuns({ ...(status ? { status } : {}), ...(jobId ? { jobId } : {}), ...(source ? { source } : {}), ...(owner ? { owner } : {}), ...(cursor ? { cursor } : {}), limit: limit + 1 });
147
147
  const hasMore = rows.length > limit;
148
148
  const page = hasMore ? rows.slice(0, limit) : rows;
149
- const tasks = page.map((r) => runSummary(r));
149
+ const tasks = page.map((r) => taskSummary(r));
150
150
  const last = page[page.length - 1];
151
151
  const nextCursor = hasMore && last ? encodeCursor({ createdAt: last.createdAt, taskId: last.taskId }) : undefined;
152
152
  sendJson(res, 200, { tasks, ...(nextCursor ? { nextCursor } : {}) });
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { loadConfig, type ServiceConfig } from "./config.js";
2
2
  export { createBrain } from "./brain.js";
3
3
  export { createSessionStore } from "./plugins/session-store.js";
4
+ export { createStoreBackend, type StoreBackend } from "./plugins/store-backend.js";
4
5
  export { createTidbPool, ensureSchema, SCHEMA_STATEMENTS } from "./plugins/tidb-pool.js";
5
6
  export { TiDBSessionStore } from "./plugins/tidb-session-store.js";
6
7
  export { TiDBSessionStorage } from "./plugins/tidb-session-storage.js";
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export { loadConfig } from "./config.js";
2
2
  export { createBrain } from "./brain.js";
3
3
  export { createSessionStore } from "./plugins/session-store.js";
4
+ export { createStoreBackend } from "./plugins/store-backend.js";
4
5
  export { createTidbPool, ensureSchema, SCHEMA_STATEMENTS } from "./plugins/tidb-pool.js";
5
6
  export { TiDBSessionStore } from "./plugins/tidb-session-store.js";
6
7
  export { TiDBSessionStorage } from "./plugins/tidb-session-storage.js";
@@ -187,7 +187,7 @@ export async function runLeaderTask(task, durableBaseSha, deps) {
187
187
  try {
188
188
  const rr = await w.runner.runTaskStream({ ...sub.spec, objective: deps.moduleGate.repairObjective(sub, verdict.reason ?? ""), sessionId: `${w.sessionId}-r${attempt + 1}` }).result();
189
189
  if (r.stats && rr?.stats)
190
- r.stats = { ...r.stats, tokens: (r.stats.tokens ?? 0) + (rr.stats.tokens ?? 0), costUsd: (r.stats.costUsd ?? 0) + (rr.stats.costUsd ?? 0) };
190
+ r.stats = { ...r.stats, tokens: (r.stats.tokens ?? 0) + (rr.stats.tokens ?? 0), costMicroUsd: (r.stats.costMicroUsd ?? 0) + (rr.stats.costMicroUsd ?? 0) };
191
191
  }
192
192
  catch (e) {
193
193
  r.status = "failed";
@@ -288,7 +288,7 @@ export async function runLeaderTask(task, durableBaseSha, deps) {
288
288
  if (sus1)
289
289
  return sus1;
290
290
  if (deps.replan?.budgetUsd !== undefined) {
291
- const spent = reports.reduce((s, r) => s + (r.stats?.costUsd ?? 0), 0);
291
+ const spent = reports.reduce((s, r) => s + (r.stats?.costMicroUsd ?? 0) / 1e6, 0);
292
292
  if (spent > deps.replan.budgetUsd) {
293
293
  return collapseToSingle("budget", `fan-out spent $${spent.toFixed(4)} > budget $${deps.replan.budgetUsd}`);
294
294
  }
@@ -107,7 +107,7 @@ export function createLeaderRunner(cfg) {
107
107
  .result();
108
108
  if (res.status !== "completed")
109
109
  throw new Error(`repair round ${round} did not complete (status=${res.status})`);
110
- return { costUsd: res.stats?.costUsd, note: res.result?.slice(0, 200) };
110
+ return { costUsd: res.stats?.costMicroUsd !== undefined ? res.stats.costMicroUsd / 1e6 : undefined, note: res.result?.slice(0, 200) };
111
111
  }
112
112
  finally {
113
113
  for (const f of oracleFiles) {
@@ -152,7 +152,7 @@ export function createLeaderRunner(cfg) {
152
152
  .result();
153
153
  if (res.status !== "completed")
154
154
  throw new Error(`conflict-resolve round ${round} did not complete (status=${res.status})`);
155
- return { costUsd: res.stats?.costUsd, note: res.result?.slice(0, 200) };
155
+ return { costUsd: res.stats?.costMicroUsd !== undefined ? res.stats.costMicroUsd / 1e6 : undefined, note: res.result?.slice(0, 200) };
156
156
  }
157
157
  finally {
158
158
  for (const f of oracleFiles) {
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, FileMailboxStore, defaultTaskRegistry, combinePolicies, createDurableQuestionPolicy, createAllowDenyPolicy, tightenTaskSpec, isThinkingLevel, QUESTION_AWAITS_RESUME, FileWorkflowRunStore, InMemoryWorkflowRunStore, workflowsCapability, NodeLspManager, createFileWorkflowScriptStore, expandTiers, NodeExecutionEnv, CenterPromptSource, FilePromptArtifactStore, FilePromptSourceStateStore, MemoryPromptArtifactStore, MemoryPromptSourceStateStore, verifyPromptArtifact, makeWebFetchSummarizer, resolveTaskModel as coreResolveTaskModel } 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, createWebFetchSummarizer, resolveTaskModel as coreResolveTaskModel } 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";
@@ -1328,7 +1328,7 @@ async function main() {
1328
1328
  })();
1329
1329
  if (!model)
1330
1330
  throw new Error("summarize model unresolved for this deployment");
1331
- return makeWebFetchSummarizer(brain, model)(content, prompt, signal);
1331
+ return createWebFetchSummarizer(brain, model)(content, prompt, signal);
1332
1332
  };
1333
1333
  const scenarioDeps = {
1334
1334
  runner, subRunner, model: "default", skills, repoClient, requirePrincipal: config.requirePrincipal,
@@ -1,4 +1,4 @@
1
- import type { SessionStore, AcquiredSession, SessionSummary } from "@sema-agent/core";
1
+ import type { SessionStore, AcquiredSession, SessionStoreSummary } from "@sema-agent/core";
2
2
  export declare class ForkRoutingSessionStore implements SessionStore {
3
3
  private readonly host;
4
4
  private readonly transient;
@@ -17,7 +17,7 @@ export declare class ForkRoutingSessionStore implements SessionStore {
17
17
  pin(sessionId: string): void | Promise<void>;
18
18
  unpin(sessionId: string): void | Promise<void>;
19
19
  noteTaskRun(sessionId: string, taskId: string): void | Promise<void>;
20
- list(): Promise<SessionSummary[]>;
20
+ list(): Promise<SessionStoreSummary[]>;
21
21
  promoteToHost(sessionId: string): Promise<void>;
22
22
  fork(sourceId: string, owner?: string | null): Promise<string | null>;
23
23
  get size(): number;
@@ -114,7 +114,7 @@ export function providerDropsAppend(provider, userSystemPrompt) {
114
114
  return false;
115
115
  }
116
116
  }
117
- return typeof provider.system === "function";
117
+ return false;
118
118
  }
119
119
  export function acceptAppendSystemPrompt(v, warn, packDropsAppend) {
120
120
  if (v === undefined)
@@ -220,7 +220,7 @@ export interface TaskSummary {
220
220
  label?: string;
221
221
  };
222
222
  }
223
- export declare function runSummary(run: RunRecord, latestEventType?: string): TaskSummary;
223
+ export declare function taskSummary(run: RunRecord, latestEventType?: string): TaskSummary;
224
224
  export declare function normalizeRunEventType(type: string): string;
225
225
  export declare function mapTraceEvent(type: string, seq: number, data: Record<string, unknown>): {
226
226
  event: string;
@@ -281,7 +281,7 @@ export function lastStep(latestEventType, status) {
281
281
  return { type: "responding" };
282
282
  }
283
283
  }
284
- export function runSummary(run, latestEventType) {
284
+ export function taskSummary(run, latestEventType) {
285
285
  const stats = (run.result?.stats ?? {});
286
286
  const terminal = run.status !== "running";
287
287
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sema-agent/server",
3
- "version": "1.318.0",
3
+ "version": "1.320.0",
4
4
  "description": "Sema Server — the server/API implementation layer for Sema, wiring core, registry, model providers, and cloud agent execution. Built on @sema-agent/core.",
5
5
  "type": "module",
6
6
  "license": "BUSL-1.1",
@@ -51,7 +51,7 @@
51
51
  "build:binary:run-local:darwin-arm64": "bun build --compile --target=bun-darwin-arm64 src/run-local.ts --outfile dist/run-local-darwin-arm64"
52
52
  },
53
53
  "dependencies": {
54
- "@sema-agent/core": "^1.452.0",
54
+ "@sema-agent/core": "^2.0.0",
55
55
  "@sema-agent/registry-core": "^0.10.21",
56
56
  "e2b": "^2.28.0",
57
57
  "libsodium-wrappers": "^0.8.4",