@sema-agent/server 1.286.0 → 1.287.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.
|
@@ -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
|
|
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
|
|
11
|
-
dry_run
|
|
12
|
-
logs
|
|
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
|
|
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,
|
|
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,
|
|
183
|
-
"(SELECT 1 FROM image_bake WHERE status IN ('queued','running') AND dry_run =
|
|
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 =
|
|
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 =
|
|
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
|
|
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 ?
|
|
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 =
|
|
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
|
|
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,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sema-agent/server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.287.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.
|
|
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",
|