@sema-agent/server 7.79.0 → 7.79.1
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/file-history-disclosure.d.ts +53 -0
- package/dist/file-history-disclosure.js +89 -0
- package/dist/http/admission.d.ts +56 -0
- package/dist/http/admission.js +560 -0
- package/dist/http/approval-sweeps.d.ts +21 -0
- package/dist/http/approval-sweeps.js +138 -0
- package/dist/http/dispatch.d.ts +96 -0
- package/dist/http/dispatch.js +499 -0
- package/dist/http/request-guards.d.ts +51 -0
- package/dist/http/request-guards.js +205 -0
- package/dist/http/resume-legs.d.ts +80 -0
- package/dist/http/resume-legs.js +1230 -0
- package/dist/http/server.d.ts +19 -104
- package/dist/http/server.js +23 -2589
- package/dist/main.js +2 -0
- package/dist/observability/metrics.js +1 -1
- package/dist/plugins/file-history-store-sql.js +12 -11
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -28,6 +28,7 @@ import { createToolTracer, createPermissionDeniedMeter } from "./observability/t
|
|
|
28
28
|
import { createRegistryJwtVerifier } from "./auth-bridge.js";
|
|
29
29
|
import { createMetrics } from "./observability/metrics.js";
|
|
30
30
|
import { installFailOpenRecorder } from "./observability/fail-open.js";
|
|
31
|
+
import { installFileHistoryFailureRecorder } from "./file-history-disclosure.js";
|
|
31
32
|
import { installSecretEnvScrubRecorder } from "./observability/secret-env-scrub.js";
|
|
32
33
|
import { setRunTerminalObserver } from "./observability/run-terminal-log.js";
|
|
33
34
|
import { setRedactionObserver, redactSecrets } from "./trace/redact.js";
|
|
@@ -96,6 +97,7 @@ async function main() {
|
|
|
96
97
|
const metrics = createMetrics();
|
|
97
98
|
installFailOpenRecorder({ logger, metrics });
|
|
98
99
|
installSecretEnvScrubRecorder({ logger, metrics });
|
|
100
|
+
installFileHistoryFailureRecorder({ logger, metrics });
|
|
99
101
|
logConfigDiagnostics(logger);
|
|
100
102
|
for (const w of drainNumEnvWarnings())
|
|
101
103
|
logger.warn("config_env_invalid_using_default", { env: w.env, raw: w.raw });
|
|
@@ -221,7 +221,7 @@ export function createMetrics() {
|
|
|
221
221
|
m.counter("degraded_total", "Tasks degraded to a cheaper model (1.40), by reason (budget/rate_limit/breaker_open)");
|
|
222
222
|
m.counter("task_model_not_allowlisted_resume_total", "Resumed legs whose model/compactionModel is outside the @-mention allowlist (allowed to keep running by design — the allowlist gates fresh picks only)");
|
|
223
223
|
m.counter("prompt_constitution_total", "Prompt assembly constitution mode per task (core 1.243 提示词主权): steady state = core; provider-assembled/replaced/legacy warrant eyes");
|
|
224
|
-
m.counter("rewind_snapshot_failed_total", "Per-turn rewind file snapshots that failed, by code (
|
|
224
|
+
m.counter("rewind_snapshot_failed_total", "Per-turn rewind file snapshots that failed, by the engine's FileHistoryResult.error.code (snapshot_failed/aborted/…; `unknown` = the disclosure text carried no readable code). COARSE on purpose — whether a failure is permanent (the same file will fail every turn until the deployment changes) is counted by file_history_permanent_failure_total instead, from the typed error object rather than from prose");
|
|
225
225
|
m.counter("verifications_total", "Tasks run through the verification gate (1.44), by final verdict");
|
|
226
226
|
m.counter("cascade_total", "Tasks run through the model cascade (1.45), by outcome (passed/exhausted)");
|
|
227
227
|
m.counter("degenerate_total", "Degenerate-output failures (1.59), by salvage class (a/b/unknown)");
|
|
@@ -4,6 +4,7 @@ import { SqlBlobBackend } from "./blob-backend.js";
|
|
|
4
4
|
import { mysqlDriver, pgDriver } from "./sql-driver.js";
|
|
5
5
|
import { isMissingColumnError } from "./sql-errors.js";
|
|
6
6
|
import { recordFailOpen } from "../observability/fail-open.js";
|
|
7
|
+
import { discloseCaughtFailure } from "../file-history-disclosure.js";
|
|
7
8
|
export const FILE_HISTORY_BLOB_TABLE = "file_history_blob";
|
|
8
9
|
export const FILE_HISTORY_BLOB_KEY_PREFIX = "file-history/";
|
|
9
10
|
const sha256hex = (s) => createHash("sha256").update(s).digest("hex");
|
|
@@ -116,7 +117,7 @@ export class SqlFileHistoryStore {
|
|
|
116
117
|
return { ok: false, error: { code: "track_failed", message: `first-touch record for ${absPath} kept racing a concurrent retraction — retry` } };
|
|
117
118
|
}
|
|
118
119
|
catch (err) {
|
|
119
|
-
return { ok: false, error: { code: "track_failed", message: `first-touch record for ${absPath} could not be persisted: ${err
|
|
120
|
+
return { ok: false, error: { code: "track_failed", message: `first-touch record for ${absPath} could not be persisted: ${discloseCaughtFailure(err)}` } };
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
async annulIneligibleReason(scope, keyHash, absPath) {
|
|
@@ -189,7 +190,7 @@ export class SqlFileHistoryStore {
|
|
|
189
190
|
return { ok: false, error: { code: "conflict", message: `first-touch record for ${absPath} was replaced while this retraction was being proven` } };
|
|
190
191
|
}
|
|
191
192
|
catch (err) {
|
|
192
|
-
return { ok: false, error: { code: "track_failed", message: `annulling the first-touch record for ${absPath} failed: ${err
|
|
193
|
+
return { ok: false, error: { code: "track_failed", message: `annulling the first-touch record for ${absPath} failed: ${discloseCaughtFailure(err)}` } };
|
|
193
194
|
}
|
|
194
195
|
}
|
|
195
196
|
async loadTracked(exec, scope, forUpdate = false) {
|
|
@@ -296,7 +297,7 @@ export class SqlFileHistoryStore {
|
|
|
296
297
|
}
|
|
297
298
|
}
|
|
298
299
|
catch (err) {
|
|
299
|
-
return { ok: false, error: { code: "snapshot_failed", message: err
|
|
300
|
+
return { ok: false, error: { code: "snapshot_failed", message: discloseCaughtFailure(err) } };
|
|
300
301
|
}
|
|
301
302
|
this.activeAttempts.add(lease);
|
|
302
303
|
try {
|
|
@@ -398,7 +399,7 @@ export class SqlFileHistoryStore {
|
|
|
398
399
|
catch (err) {
|
|
399
400
|
await conn.rollback().catch(() => undefined);
|
|
400
401
|
this.spentAttempts.add(lease);
|
|
401
|
-
return { ok: false, error: { code: "snapshot_failed", message: `boundary for entry "${entryId}" could not be committed: ${err
|
|
402
|
+
return { ok: false, error: { code: "snapshot_failed", message: `boundary for entry "${entryId}" could not be committed: ${discloseCaughtFailure(err)}` } };
|
|
402
403
|
}
|
|
403
404
|
finally {
|
|
404
405
|
conn.release();
|
|
@@ -408,7 +409,7 @@ export class SqlFileHistoryStore {
|
|
|
408
409
|
}
|
|
409
410
|
catch (err) {
|
|
410
411
|
this.spentAttempts.add(lease);
|
|
411
|
-
return { ok: false, error: { code: "snapshot_failed", message: err
|
|
412
|
+
return { ok: false, error: { code: "snapshot_failed", message: discloseCaughtFailure(err) } };
|
|
412
413
|
}
|
|
413
414
|
finally {
|
|
414
415
|
this.activeAttempts.delete(lease);
|
|
@@ -475,7 +476,7 @@ export class SqlFileHistoryStore {
|
|
|
475
476
|
});
|
|
476
477
|
}
|
|
477
478
|
catch (err) {
|
|
478
|
-
applied = { outcome: "failed", reason: err
|
|
479
|
+
applied = { outcome: "failed", reason: discloseCaughtFailure(err) };
|
|
479
480
|
}
|
|
480
481
|
if (applied.outcome === "applied")
|
|
481
482
|
ledger.filesChanged.push(t.trackKey);
|
|
@@ -492,7 +493,7 @@ export class SqlFileHistoryStore {
|
|
|
492
493
|
}
|
|
493
494
|
catch (err) {
|
|
494
495
|
const touched = empty.filesChanged.length > 0 || empty.identicalSkipped.length > 0 || empty.refused.length > 0 || empty.failed.length > 0;
|
|
495
|
-
return { outcome: touched ? "partial" : "failed", ...empty, error: { code: "restore_failed", message: err
|
|
496
|
+
return { outcome: touched ? "partial" : "failed", ...empty, error: { code: "restore_failed", message: discloseCaughtFailure(err) } };
|
|
496
497
|
}
|
|
497
498
|
}
|
|
498
499
|
async restorePlan(scope, entryId) {
|
|
@@ -593,7 +594,7 @@ export class SqlFileHistoryStore {
|
|
|
593
594
|
return { ok: true };
|
|
594
595
|
}
|
|
595
596
|
catch (err) {
|
|
596
|
-
return { ok: false, error: { code: "snapshot_failed", message: `putBlob ${hash} write/upload failed: ${err
|
|
597
|
+
return { ok: false, error: { code: "snapshot_failed", message: `putBlob ${hash} write/upload failed: ${discloseCaughtFailure(err)}` } };
|
|
597
598
|
}
|
|
598
599
|
}
|
|
599
600
|
async getBlob(hash) {
|
|
@@ -636,7 +637,7 @@ export class SqlFileHistoryStore {
|
|
|
636
637
|
}
|
|
637
638
|
}
|
|
638
639
|
catch (err) {
|
|
639
|
-
return { ok: false, error: { code: "conflict", message: `adoptScope failed: ${err
|
|
640
|
+
return { ok: false, error: { code: "conflict", message: `adoptScope failed: ${discloseCaughtFailure(err)}` } };
|
|
640
641
|
}
|
|
641
642
|
}
|
|
642
643
|
async scopeEmpty(exec, scope, forUpdate = false) {
|
|
@@ -735,7 +736,7 @@ export class SqlFileHistoryStore {
|
|
|
735
736
|
bytes = await srcGetBlob(hash);
|
|
736
737
|
}
|
|
737
738
|
catch (err) {
|
|
738
|
-
return { ok: false, error: { code: "unsupported_format", message: `source blob ${hash} fetch failed: ${err
|
|
739
|
+
return { ok: false, error: { code: "unsupported_format", message: `source blob ${hash} fetch failed: ${discloseCaughtFailure(err)}` } };
|
|
739
740
|
}
|
|
740
741
|
if (bytes === undefined)
|
|
741
742
|
return { ok: false, error: { code: "not_found", message: `source blob ${hash} is missing — the envelope's graph cannot be completed, so nothing is published` } };
|
|
@@ -786,7 +787,7 @@ export class SqlFileHistoryStore {
|
|
|
786
787
|
}
|
|
787
788
|
}
|
|
788
789
|
catch (err) {
|
|
789
|
-
return { ok: false, error: { code: "unsupported_format", message: `importHistory failed: ${err
|
|
790
|
+
return { ok: false, error: { code: "unsupported_format", message: `importHistory failed: ${discloseCaughtFailure(err)}` } };
|
|
790
791
|
}
|
|
791
792
|
}
|
|
792
793
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sema-agent/server",
|
|
3
|
-
"version": "7.79.
|
|
3
|
+
"version": "7.79.1",
|
|
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",
|