@sema-agent/server 1.286.0 → 1.288.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.
@@ -16,6 +16,10 @@ export interface FleetTaskRow {
16
16
  queuedCount?: number;
17
17
  awaitingPlanApproval?: boolean;
18
18
  currentAction?: string;
19
+ currentTool?: {
20
+ toolName: string;
21
+ target?: string;
22
+ };
19
23
  toolUses?: number;
20
24
  transcriptId?: string;
21
25
  }
@@ -277,7 +277,7 @@ export function fleetBackgroundChildPublisher(bus, log) {
277
277
  : {}),
278
278
  };
279
279
  remember(e.taskId, m);
280
- bus.publishTask({ id: e.taskId, name: redactSecrets(e.description ?? e.name ?? e.taskId), ...(e.agentType ? { agentType: redactSecrets(e.agentType) } : {}), ...rowTags(m), status: "running", tokens: 0 });
280
+ bus.publishTask({ id: e.taskId, name: redactSecrets(e.description ?? e.name ?? e.taskId), ...(e.agentType ? { agentType: redactSecrets(e.agentType) } : {}), ...rowTags(m), status: "running", tokens: 0, ...(e.transcriptId ? { transcriptId: e.transcriptId } : {}) });
281
281
  dlog("bg_child_event", { kind: "spawn", taskId: e.taskId, sessionScoped: e.sessionScoped, scope: m.tenantScope, hostSessionId: m.hostSessionId ?? null, parentTaskId: m.parentTaskId ?? null });
282
282
  return;
283
283
  }
@@ -314,7 +314,10 @@ export function fleetBackgroundChildPublisher(bus, log) {
314
314
  const name = e.name ? redactSecrets(e.name) : undefined;
315
315
  const agentType = e.agentType ? redactSecrets(e.agentType) : name;
316
316
  const currentAction = e.currentAction ? redactSecrets(e.currentAction) : undefined;
317
- bus.publishTask({ id: e.taskId, ...rowTags(m), status: "running", ...(tokens !== undefined ? { tokens } : {}), ...(name ? { name } : {}), ...(agentType ? { agentType } : {}), ...(currentAction ? { currentAction } : {}), ...(e.usage?.toolUses !== undefined ? { toolUses: e.usage.toolUses } : {}), ...(e.transcriptId ? { transcriptId: e.transcriptId } : {}) });
317
+ const currentTool = e.currentTool
318
+ ? { toolName: e.currentTool.toolName, ...(e.currentTool.target !== undefined ? { target: redactSecrets(e.currentTool.target).slice(0, 300) } : {}) }
319
+ : undefined;
320
+ bus.publishTask({ id: e.taskId, ...rowTags(m), status: "running", ...(tokens !== undefined ? { tokens } : {}), ...(name ? { name } : {}), ...(agentType ? { agentType } : {}), ...(currentAction ? { currentAction } : {}), ...(currentTool ? { currentTool } : {}), ...(e.usage?.toolUses !== undefined ? { toolUses: e.usage.toolUses } : {}), ...(e.transcriptId ? { transcriptId: e.transcriptId } : {}) });
318
321
  return;
319
322
  }
320
323
  const status = e.status === "completed" ? "completed" : e.status === "killed" ? "killed" : "failed";
@@ -132,7 +132,7 @@ export async function ensurePgBackgroundAgentSchema(q) {
132
132
  handle VARCHAR(190) COLLATE "C" NOT NULL,
133
133
  scope VARCHAR(190) NOT NULL,
134
134
  owner VARCHAR(190) NOT NULL,
135
- session_scoped BOOLEAN NOT NULL,
135
+ session_scoped SMALLINT NOT NULL,
136
136
  session_id VARCHAR(190),
137
137
  parent_session_id VARCHAR(190),
138
138
  -- core 1.367 δ(additive,TiDB 同案):root 锚(listBySession 第二臂)
@@ -7,9 +7,9 @@ export const PG_IMAGE_BAKE_SCHEMA = [
7
7
  profile VARCHAR(128) NOT NULL,
8
8
  bands JSONB NULL,
9
9
  base_ref VARCHAR(255) NULL,
10
- push BOOLEAN NOT NULL DEFAULT FALSE,
11
- dry_run BOOLEAN NOT NULL DEFAULT FALSE,
12
- logs BOOLEAN NOT NULL DEFAULT FALSE,
10
+ push SMALLINT NOT NULL DEFAULT 0,
11
+ dry_run SMALLINT NOT NULL DEFAULT 0,
12
+ logs SMALLINT NOT NULL DEFAULT 0,
13
13
  argv JSONB NOT NULL,
14
14
  status VARCHAR(16) NOT NULL,
15
15
  state VARCHAR(16) NULL,
@@ -26,7 +26,7 @@ export const PG_IMAGE_BAKE_SCHEMA = [
26
26
  ingest_secret VARCHAR(64) NULL,
27
27
  runner_id VARCHAR(64) NULL,
28
28
  lease_until TIMESTAMPTZ(3) NULL,
29
- cancel_requested BOOLEAN NOT NULL DEFAULT FALSE,
29
+ cancel_requested SMALLINT NOT NULL DEFAULT 0,
30
30
  requested_by VARCHAR(128) NULL,
31
31
  created_at TIMESTAMPTZ(3) NOT NULL,
32
32
  updated_at TIMESTAMPTZ(3) NOT NULL,
@@ -141,14 +141,14 @@ export class PgImageBake {
141
141
  try {
142
142
  await this.pool.query("INSERT INTO image_bake (bake_id, profile, bands, base_ref, push, dry_run, logs, argv, status, " +
143
143
  "idem_key, cancel_requested, requested_by, created_at, updated_at) " +
144
- "VALUES ($1,$2,$3::jsonb,$4,$5,$6,$7,$8::jsonb,'queued',$9,FALSE,$10,$11,$12)", [
144
+ "VALUES ($1,$2,$3::jsonb,$4,$5,$6,$7,$8::jsonb,'queued',$9,0,$10,$11,$12)", [
145
145
  bakeId,
146
146
  input.profile,
147
147
  input.bands == null ? null : JSON.stringify(input.bands),
148
148
  input.baseRef,
149
- input.push,
150
- input.dryRun,
151
- input.logs,
149
+ input.push ? 1 : 0,
150
+ input.dryRun ? 1 : 0,
151
+ input.logs ? 1 : 0,
152
152
  JSON.stringify(input.argv),
153
153
  input.idemKey,
154
154
  input.requestedBy,
@@ -179,15 +179,15 @@ export class PgImageBake {
179
179
  await conn.query("SELECT pool FROM image_bake_admit WHERE pool = $1 FOR UPDATE", [this.poolName]);
180
180
  const res = await conn.query("INSERT INTO image_bake (bake_id, profile, bands, base_ref, push, dry_run, logs, argv, status, " +
181
181
  "idem_key, cancel_requested, requested_by, created_at, updated_at) " +
182
- "SELECT $1,$2,$3::jsonb,$4,$5,$6,$7,$8::jsonb,'queued',$9,FALSE,$10,$11,$12 WHERE NOT EXISTS " +
183
- "(SELECT 1 FROM image_bake WHERE status IN ('queued','running') AND dry_run = FALSE)", [
182
+ "SELECT $1,$2,$3::jsonb,$4,$5,$6,$7,$8::jsonb,'queued',$9,0,$10,$11,$12 WHERE NOT EXISTS " +
183
+ "(SELECT 1 FROM image_bake WHERE status IN ('queued','running') AND dry_run = 0)", [
184
184
  bakeId,
185
185
  input.profile,
186
186
  input.bands == null ? null : JSON.stringify(input.bands),
187
187
  input.baseRef,
188
- input.push,
189
- input.dryRun,
190
- input.logs,
188
+ input.push ? 1 : 0,
189
+ input.dryRun ? 1 : 0,
190
+ input.logs ? 1 : 0,
191
191
  JSON.stringify(input.argv),
192
192
  input.idemKey,
193
193
  input.requestedBy,
@@ -229,7 +229,7 @@ export class PgImageBake {
229
229
  return res.rows[0] ? mapRow(res.rows[0]) : null;
230
230
  }
231
231
  async findActiveAny() {
232
- const res = await this.pool.query(`SELECT ${SELECT_COLS} FROM image_bake WHERE status IN ('queued','running') AND dry_run = FALSE ` +
232
+ const res = await this.pool.query(`SELECT ${SELECT_COLS} FROM image_bake WHERE status IN ('queued','running') AND dry_run = 0 ` +
233
233
  "ORDER BY created_at ASC LIMIT 1");
234
234
  return res.rows[0] ? mapRow(res.rows[0]) : null;
235
235
  }
@@ -413,7 +413,7 @@ export class PgImageBake {
413
413
  return (leaseRes.rowCount ?? 0) >= 1;
414
414
  }
415
415
  async requestCancel(bakeId) {
416
- const res = await this.pool.query("UPDATE image_bake SET cancel_requested = TRUE, updated_at = $1 WHERE bake_id = $2 AND status IN ('queued','running')", [new Date(), bakeId]);
416
+ const res = await this.pool.query("UPDATE image_bake SET cancel_requested = 1, updated_at = $1 WHERE bake_id = $2 AND status IN ('queued','running')", [new Date(), bakeId]);
417
417
  return (res.rowCount ?? 0) > 0;
418
418
  }
419
419
  async isCancelRequested(bakeId) {
@@ -21,7 +21,7 @@ export const PG_IMAGE_INDEX_SCHEMA = [
21
21
  generator_version VARCHAR(32),
22
22
  build_date TIMESTAMPTZ(3),
23
23
  supersedes VARCHAR(64),
24
- signed BOOLEAN NOT NULL DEFAULT FALSE,
24
+ signed SMALLINT NOT NULL DEFAULT 0,
25
25
  created_at TIMESTAMPTZ(3) NOT NULL,
26
26
  updated_at TIMESTAMPTZ(3) NOT NULL,
27
27
  PRIMARY KEY (id)
@@ -129,7 +129,7 @@ function upsertParams(e, id, now) {
129
129
  e.generatorVersion == null ? null : pgSanitizeText(e.generatorVersion),
130
130
  e.buildDate ? new Date(e.buildDate) : null,
131
131
  e.supersedes == null ? null : pgSanitizeText(e.supersedes),
132
- e.signed ? true : false,
132
+ e.signed ? 1 : 0,
133
133
  now,
134
134
  now,
135
135
  ];
@@ -16,7 +16,7 @@ function rowToEntry(r) {
16
16
  };
17
17
  }
18
18
  const RESOLVE_WHERE_TIDB = `name_key = ? AND BINARY scope = ? AND (BINARY owner = ? OR (session_scoped = 1 AND ? IS NOT NULL AND BINARY owner = ?))`;
19
- const RESOLVE_WHERE_PG = `name_key = $1 AND scope = $2 AND (owner = $3 OR (session_scoped = TRUE AND $4::varchar IS NOT NULL AND owner = $5))`;
19
+ const RESOLVE_WHERE_PG = `name_key = $1 AND scope = $2 AND (owner = $3 OR (session_scoped = 1 AND $4::varchar IS NOT NULL AND owner = $5))`;
20
20
  const COLS = "name, agent_id, session_id, tool_use_id, owner, scope, session_scoped, root_session_id, model, created_at_ms";
21
21
  export async function ensureTiDBRosterSchema(pool) {
22
22
  await pool.query(`CREATE TABLE IF NOT EXISTS ${ROSTER_TABLE} (
@@ -53,7 +53,7 @@ export async function ensurePgRosterSchema(q) {
53
53
  -- owner/scope:core 1.365 BREAKING 双轴必填(TiDB 同案;曾 nullable 的由来见两 ensure 上方顶注 ①)
54
54
  owner VARCHAR(190) COLLATE "C" NOT NULL,
55
55
  scope VARCHAR(190) COLLATE "C" NOT NULL,
56
- session_scoped BOOLEAN,
56
+ session_scoped SMALLINT,
57
57
  -- core 1.367 δ(additive,TiDB 同案):RosterEntry.rootSessionId verbatim 存
58
58
  root_session_id VARCHAR(190),
59
59
  -- core 1.373 additive(TiDB 同案):解析后模型 id(NULL = 该 spawn 未记录模型)
@@ -75,7 +75,7 @@ function upsertParams(entry, now) {
75
75
  entry.toolUseId ?? null,
76
76
  entry.owner,
77
77
  entry.scope,
78
- entry.sessionScoped === undefined ? null : entry.sessionScoped,
78
+ entry.sessionScoped === undefined ? null : entry.sessionScoped ? 1 : 0,
79
79
  entry.rootSessionId ?? null,
80
80
  entry.model ?? null,
81
81
  entry.createdAt,
@@ -3,12 +3,12 @@ type AssertAllKeysHandled<T extends never> = T;
3
3
  type NotificationProjected = "task_id" | "task_type" | "toolUseId" | "status" | "summary" | "result" | "output_file" | "usage" | "sessionId" | "seq" | "lines" | "stoppedBy" | "source" | "exitCode" | "partial" | "diagnostics" | "recentSteps" | "editedFiles" | "resumable";
4
4
  type _GuardNotification = AssertAllKeysHandled<Exclude<keyof TaskNotificationPayload, NotificationProjected>>;
5
5
  type BgNotifProjected = "taskId" | "sessionId" | "seq" | "status" | "summary" | "stoppedBy" | "resumable" | "recentSteps" | "editedFiles" | "usage" | "transcriptId" | "rootSessionId" | "parentTaskId";
6
- type BgNotifExcluded = "kind" | "sessionScoped" | "owner" | "scope" | "description" | "agentType" | "name" | "currentAction" | "parentSessionId" | "startedAt" | "workflowRunId" | "progressTaskId" | "progressParentTaskId";
6
+ type BgNotifExcluded = "kind" | "sessionScoped" | "owner" | "scope" | "description" | "agentType" | "name" | "currentAction" | "currentTool" | "parentSessionId" | "startedAt" | "workflowRunId" | "progressTaskId" | "progressParentTaskId";
7
7
  type _GuardBgNotif = AssertAllKeysHandled<Exclude<keyof BackgroundChildEvent, BgNotifProjected | BgNotifExcluded>>;
8
8
  type RosterProjected = "name" | "agentId" | "sessionId" | "toolUseId" | "owner" | "scope" | "sessionScoped" | "rootSessionId" | "model" | "createdAt";
9
9
  type _GuardRoster = AssertAllKeysHandled<Exclude<keyof RosterEntry, RosterProjected>>;
10
10
  type AskProjected = "toolName" | "args" | "message" | "sourceTaskId" | "fromSubagent" | "sourceAgentName";
11
- type AskExcluded = "toolCallId" | "preview" | "principal";
11
+ type AskExcluded = "toolCallId" | "preview" | "principal" | "requiresRealApproval";
12
12
  type _GuardAsk = AssertAllKeysHandled<Exclude<keyof AskRequest, AskProjected | AskExcluded>>;
13
13
  type TaskEventHandled = "text_delta" | "reasoning_delta" | "tool_start" | "tool_end" | "turn_end" | "compacted" | "diagnostics" | "message_committed" | "status" | "task_notification" | "task_progress" | "steering_injected" | "workspace_changed" | "done" | "context_usage";
14
14
  type _GuardTaskEvent = AssertAllKeysHandled<Exclude<TaskEvent["type"], TaskEventHandled>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sema-agent/server",
3
- "version": "1.286.0",
3
+ "version": "1.288.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",
@@ -47,7 +47,7 @@
47
47
  "build:binary:run-local:darwin-arm64": "bun build --compile --target=bun-darwin-arm64 src/run-local.ts --outfile dist/run-local-darwin-arm64"
48
48
  },
49
49
  "dependencies": {
50
- "@sema-agent/core": "^1.424.0",
50
+ "@sema-agent/core": "^1.427.0",
51
51
  "@sema-agent/registry-core": "^0.10.21",
52
52
  "e2b": "^2.28.0",
53
53
  "libsodium-wrappers": "^0.8.4",