@sema-agent/server 1.239.0 → 1.241.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/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/fleet/fleet-bus.d.ts +3 -0
- package/dist/fleet/fleet-bus.d.ts.map +1 -1
- package/dist/fleet/fleet-bus.js +27 -2
- package/dist/fleet/fleet-bus.js.map +1 -1
- package/dist/http/server.d.ts.map +1 -1
- package/dist/http/server.js +45 -23
- package/dist/http/server.js.map +1 -1
- package/dist/main.js +1 -0
- package/dist/main.js.map +1 -1
- package/dist/plugins/memory-engine-pg.d.ts.map +1 -1
- package/dist/plugins/memory-engine-pg.js +22 -10
- package/dist/plugins/memory-engine-pg.js.map +1 -1
- package/dist/plugins/memory-sync-store-pg.d.ts.map +1 -1
- package/dist/plugins/memory-sync-store-pg.js +4 -3
- package/dist/plugins/memory-sync-store-pg.js.map +1 -1
- package/dist/plugins/pg-approval-store.d.ts.map +1 -1
- package/dist/plugins/pg-approval-store.js +2 -1
- package/dist/plugins/pg-approval-store.js.map +1 -1
- package/dist/plugins/pg-checkpoint-store.d.ts.map +1 -1
- package/dist/plugins/pg-checkpoint-store.js +7 -6
- package/dist/plugins/pg-checkpoint-store.js.map +1 -1
- package/dist/plugins/pg-image-bake.d.ts +1 -1
- package/dist/plugins/pg-image-bake.d.ts.map +1 -1
- package/dist/plugins/pg-image-bake.js +17 -15
- package/dist/plugins/pg-image-bake.js.map +1 -1
- package/dist/plugins/pg-image-index.d.ts.map +1 -1
- package/dist/plugins/pg-image-index.js +18 -9
- package/dist/plugins/pg-image-index.js.map +1 -1
- package/dist/plugins/pg-outcome-ledger.d.ts.map +1 -1
- package/dist/plugins/pg-outcome-ledger.js +5 -4
- package/dist/plugins/pg-outcome-ledger.js.map +1 -1
- package/dist/plugins/pg-run-store.d.ts.map +1 -1
- package/dist/plugins/pg-run-store.js +6 -5
- package/dist/plugins/pg-run-store.js.map +1 -1
- package/dist/plugins/pg-safe-json.d.ts +9 -0
- package/dist/plugins/pg-safe-json.d.ts.map +1 -0
- package/dist/plugins/pg-safe-json.js +90 -0
- package/dist/plugins/pg-safe-json.js.map +1 -0
- package/dist/plugins/pg-session-policy-store.d.ts.map +1 -1
- package/dist/plugins/pg-session-policy-store.js +4 -0
- package/dist/plugins/pg-session-policy-store.js.map +1 -1
- package/dist/plugins/pg-session-storage.d.ts.map +1 -1
- package/dist/plugins/pg-session-storage.js +5 -4
- package/dist/plugins/pg-session-storage.js.map +1 -1
- package/dist/plugins/pg-tool-result-store.d.ts.map +1 -1
- package/dist/plugins/pg-tool-result-store.js +2 -1
- package/dist/plugins/pg-tool-result-store.js.map +1 -1
- package/dist/plugins/pg-workflow-journal-store.d.ts.map +1 -1
- package/dist/plugins/pg-workflow-journal-store.js.map +1 -1
- package/dist/plugins/remote-env-e2b.d.ts.map +1 -1
- package/dist/plugins/remote-env-e2b.js.map +1 -1
- package/dist/plugins/tidb-image-bake.d.ts +1 -1
- package/dist/plugins/tidb-image-bake.d.ts.map +1 -1
- package/dist/plugins/tidb-image-bake.js +3 -2
- package/dist/plugins/tidb-image-bake.js.map +1 -1
- package/dist/plugins/tidb-workflow-journal-store.d.ts.map +1 -1
- package/dist/plugins/tidb-workflow-journal-store.js.map +1 -1
- package/dist/tool-approval.d.ts +1 -0
- package/dist/tool-approval.d.ts.map +1 -1
- package/dist/tool-approval.js +13 -8
- package/dist/tool-approval.js.map +1 -1
- package/package.json +2 -2
package/dist/http/server.js
CHANGED
|
@@ -30,6 +30,7 @@ import { composeSupervisorCost, infraCost, infraUsageFromEvents, hasInfraPricing
|
|
|
30
30
|
import { redactSecrets, redactDeep, redactedPreview } from "../trace/redact.js";
|
|
31
31
|
import { usageSummary, usageSeries, usageBreakdown } from "../usage-analytics.js";
|
|
32
32
|
import { IdempotencyCache } from "./idempotency.js";
|
|
33
|
+
import { pgHasUnstorable } from "../plugins/pg-safe-json.js";
|
|
33
34
|
export const MAX_USER_SKILLS = 10;
|
|
34
35
|
export const MAX_SKILL_CONTENT_CHARS = 1_048_576;
|
|
35
36
|
export const MAX_SYSTEM_PROMPT_CHARS = 16_384;
|
|
@@ -140,10 +141,10 @@ const RUN_STEER_RE = /^\/v1\/runs\/([^/]+)\/steer$/;
|
|
|
140
141
|
const RUN_DETACH_RE = /^\/v1\/runs\/([^/]+)\/detach$/;
|
|
141
142
|
const RUN_COMPACT_RE = /^\/v1\/runs\/([^/]+)\/compact$/;
|
|
142
143
|
function runNotFoundBody(id) {
|
|
143
|
-
const aStar = /^a[0-9a-f]{4,}$/i.test(id);
|
|
144
|
+
const aStar = /^(?:a|wa)[0-9a-f]{4,}$/i.test(id);
|
|
144
145
|
return {
|
|
145
146
|
error: aStar
|
|
146
|
-
? `run not found — "${id}" looks like
|
|
147
|
+
? `run not found — "${id}" looks like an agent handle (a*/wa* domain), which is never in the run store; use the TaskOutput tool (or the workflow journal / subagents surface) to read it, and the run's durable taskId (X-Task-Id) for this endpoint`
|
|
147
148
|
: "run not found — the id belongs to no run in this deployment's run store (a run from another server process, or an in-memory store that did not survive a restart, is not visible here)",
|
|
148
149
|
};
|
|
149
150
|
}
|
|
@@ -5469,7 +5470,7 @@ async function ingestBakeLine(bakes, idx, bake, line, registry) {
|
|
|
5469
5470
|
const cancelled = doneStatus === "CANCELLED";
|
|
5470
5471
|
const errorText = typeof line.error === "string" ? redactSecrets(line.error) : null;
|
|
5471
5472
|
const tag = typeof line.tag === "string" ? line.tag : bake.tag;
|
|
5472
|
-
|
|
5473
|
+
let digest = typeof line.digest === "string" && line.digest.length > 0 ? line.digest : null;
|
|
5473
5474
|
let indexId = bake.indexId;
|
|
5474
5475
|
let repo = bake.repo;
|
|
5475
5476
|
let ref = bake.ref;
|
|
@@ -5484,27 +5485,35 @@ async function ingestBakeLine(bakes, idx, bake, line, registry) {
|
|
|
5484
5485
|
const fresh = await bakes.getBake(bakeId);
|
|
5485
5486
|
const nonTerminal = !!fresh && (fresh.status === "queued" || fresh.status === "running");
|
|
5486
5487
|
if (manifestBody && typeof manifestBody === "object" && nonTerminal) {
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
|
|
5491
|
-
manifestSha = typeof line.manifestSha === "string" ? line.manifestSha : (typeof line.manifest?.sha256 === "string" ? String(line.manifest.sha256) : bake.manifestSha);
|
|
5492
|
-
const entry = manifestToIndexEntry(manifestBody, { repo, digest, status: "building", manifestSha, sizeBytes: manifestBody.sizeBytes ?? null, signed: false });
|
|
5493
|
-
entry.visibility = "public";
|
|
5494
|
-
entry.tenantId = null;
|
|
5495
|
-
indexId = await idx.registerBuilding(entry);
|
|
5496
|
-
ref = `${repo}@${digest}`;
|
|
5497
|
-
await bakes.setIndexId(bakeId, indexId);
|
|
5498
|
-
registerSteps.push({ step: "register", status: "ok" });
|
|
5499
|
-
}
|
|
5500
|
-
catch (err) {
|
|
5488
|
+
const profile = bake.profile && bake.profile !== "custom" ? bake.profile : (manifestBody.profile && manifestBody.profile !== "custom" ? manifestBody.profile : "custom");
|
|
5489
|
+
repo = registry ? `${registry}/${profile}` : `sema-images/${profile}`;
|
|
5490
|
+
manifestSha = typeof line.manifestSha === "string" ? line.manifestSha : (typeof line.manifest?.sha256 === "string" ? String(line.manifest.sha256) : bake.manifestSha);
|
|
5491
|
+
if (pgHasUnstorable(digest) || pgHasUnstorable(repo) || pgHasUnstorable(manifestSha)) {
|
|
5501
5492
|
indexId = null;
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5493
|
+
registerSteps.push({ step: "register", status: "skipped", reason: "identity fields contained unstorable bytes" });
|
|
5494
|
+
}
|
|
5495
|
+
else {
|
|
5496
|
+
registerSteps.push({ step: "register", status: "running" });
|
|
5497
|
+
try {
|
|
5498
|
+
const entry = manifestToIndexEntry(manifestBody, { repo, digest, status: "building", manifestSha, sizeBytes: manifestBody.sizeBytes ?? null, signed: false });
|
|
5499
|
+
entry.visibility = "public";
|
|
5500
|
+
entry.tenantId = null;
|
|
5501
|
+
indexId = await idx.registerBuilding(entry);
|
|
5502
|
+
ref = `${repo}@${digest}`;
|
|
5503
|
+
const bound = await bakes.setIndexId(bakeId, indexId);
|
|
5504
|
+
if (!bound)
|
|
5505
|
+
indexId = null;
|
|
5506
|
+
registerSteps.push({ step: "register", status: "ok" });
|
|
5507
|
+
}
|
|
5508
|
+
catch (err) {
|
|
5509
|
+
indexId = null;
|
|
5510
|
+
ref = `${repo}@${digest}`;
|
|
5511
|
+
finalStatus = "FAILED";
|
|
5512
|
+
registerDowngraded = true;
|
|
5513
|
+
finalExit = exitCode ?? 0;
|
|
5514
|
+
finalError = redactSecrets(`index register failed after a COMPLETE build (built-but-unregistered partial): ${String(err?.message ?? err)}`);
|
|
5515
|
+
registerSteps.push({ step: "register", status: "fail", reason: "index register failed (TiDB?)" });
|
|
5516
|
+
}
|
|
5508
5517
|
}
|
|
5509
5518
|
}
|
|
5510
5519
|
}
|
|
@@ -5519,6 +5528,19 @@ async function ingestBakeLine(bakes, idx, bake, line, registry) {
|
|
|
5519
5528
|
const conflictBands = errorCode === "band-conflict" && Array.isArray(line.conflictBands)
|
|
5520
5529
|
? line.conflictBands.filter((b) => typeof b === "string")
|
|
5521
5530
|
: null;
|
|
5531
|
+
const identityInvalid = (typeof digest === "string" && pgHasUnstorable(digest)) ||
|
|
5532
|
+
(typeof repo === "string" && pgHasUnstorable(repo)) ||
|
|
5533
|
+
(typeof ref === "string" && pgHasUnstorable(ref)) ||
|
|
5534
|
+
(typeof manifestSha === "string" && pgHasUnstorable(manifestSha));
|
|
5535
|
+
if (identityInvalid) {
|
|
5536
|
+
finalStatus = "FAILED";
|
|
5537
|
+
digest = null;
|
|
5538
|
+
repo = null;
|
|
5539
|
+
ref = null;
|
|
5540
|
+
manifestSha = null;
|
|
5541
|
+
indexId = null;
|
|
5542
|
+
finalError = finalError ? `${finalError}; identity fields contained unstorable bytes` : "terminal frame identity fields contained unstorable bytes";
|
|
5543
|
+
}
|
|
5522
5544
|
const finalState = (finalStatus === "COMPLETE" ? "COMPLETE" : finalStatus === "CANCELLED" ? "CANCELLED" : "FAILED");
|
|
5523
5545
|
const coarse = coarseStatusForState(finalState);
|
|
5524
5546
|
let affectedRows = 0;
|