@sema-agent/server 7.146.0 → 7.147.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/MIGRATION.md +384 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/USAGE.md +170 -66
- package/deploy/facts/lanes.json +7 -0
- package/deploy/sema-up/README.md +2 -2
- package/deploy/sema-up/chart/templates/_helpers.tpl +22 -0
- package/deploy/sema-up/chart/templates/server-v4pro.yaml +5 -4
- package/deploy/sema-up/chart/templates/server.yaml +5 -4
- package/deploy/sema-up/chart/values.yaml +1 -1
- package/deploy/sema-up/cluster-up.sh +2 -1
- package/deploy/sema-up/lib/flagshape.sh +4 -0
- package/deploy/sema-up/lib/lanes.json +2 -5
- package/deploy/sema-up/sema-up.sh +12 -9
- package/deploy/sema-up/stack/compose.yaml +5 -4
- package/deploy/sema-up/stack/sema-stack-cluster.yaml +4 -3
- package/dist/approval-card.d.ts +4 -4
- package/dist/approval.d.ts +3 -3
- package/dist/audit.js +2 -2
- package/dist/bench/s1/live-deps.js +3 -1
- package/dist/boot/crash-last.js +2 -1
- package/dist/boot/device-lane.js +5 -5
- package/dist/boot/engine-lease.d.ts +12 -11
- package/dist/boot/execution-env.d.ts +2 -1
- package/dist/boot/execution-env.js +45 -33
- package/dist/boot/execution-lane.d.ts +37 -9
- package/dist/boot/execution-lane.js +74 -20
- package/dist/boot/exit-boundary.d.ts +1 -1
- package/dist/boot/exit-last.js +2 -1
- package/dist/boot/governance-seams.d.ts +2 -2
- package/dist/boot/leader.js +1 -1
- package/dist/boot/memory-boundary.d.ts +11 -11
- package/dist/boot/memory-boundary.js +3 -3
- package/dist/boot/memory-consolidation.d.ts +13 -24
- package/dist/boot/memory-consolidation.js +0 -13
- package/dist/boot/org-memory.js +3 -2
- package/dist/boot/parked-revive-gate.d.ts +1 -1
- package/dist/boot/parked-revive-gate.js +1 -1
- package/dist/boot/reapers.js +1 -1
- package/dist/boot/resolve-spec.js +91 -111
- package/dist/boot/retention-lane.d.ts +4 -42
- package/dist/boot/session-faces.d.ts +1 -0
- package/dist/boot/session-faces.js +8 -2
- package/dist/boot/stage-01-config.d.ts +1 -1
- package/dist/boot/stage-01-config.js +6 -2
- package/dist/boot/stage-02-web-admin-pull.d.ts +1 -1
- package/dist/boot/stage-02-web-admin-pull.js +10 -8
- package/dist/boot/stage-03-store-backend.d.ts +1 -1
- package/dist/boot/stage-04-stores.d.ts +1 -1
- package/dist/boot/stage-05-execution-env.d.ts +2 -2
- package/dist/boot/stage-05-execution-env.js +3 -3
- package/dist/boot/stage-06-runners.d.ts +3 -3
- package/dist/boot/stage-06-runners.js +1 -3
- package/dist/boot/stage-07-capability-layer.d.ts +3 -3
- package/dist/boot/stage-07-capability-layer.js +4 -9
- package/dist/boot/stage-08-reapers.d.ts +3 -3
- package/dist/boot/stage-09-leader.d.ts +4 -3
- package/dist/boot/stage-10-http-server.d.ts +4 -3
- package/dist/boot/stage-10-http-server.js +2 -1
- package/dist/boot/stores.d.ts +9 -0
- package/dist/boot/stores.js +18 -7
- package/dist/boot/web-admin.js +3 -3
- package/dist/capabilities/center-plugins.d.ts +2 -0
- package/dist/capabilities/center-plugins.js +6 -2
- package/dist/capabilities/composite-members.d.ts +1 -0
- package/dist/capabilities/composite-members.js +1 -0
- package/dist/capabilities/execution-lane.d.ts +7 -7
- package/dist/capabilities/execution-lane.js +2 -2
- package/dist/capabilities/hands-lane.d.ts +1 -1
- package/dist/capabilities/scenarios.d.ts +32 -18
- package/dist/capabilities/scenarios.js +13 -9
- package/dist/capabilities/settings-contract.d.ts +29 -0
- package/dist/capabilities/settings-contract.js +14 -0
- package/dist/capabilities/skills.d.ts +5 -5
- package/dist/capability-facts.d.ts +38 -0
- package/dist/capability-facts.js +34 -1
- package/dist/center-credential-renewer.js +3 -2
- package/dist/config-catalog.js +6 -5
- package/dist/config-invariants.d.ts +18 -3
- package/dist/config-invariants.js +36 -19
- package/dist/config-lkg.d.ts +1 -1
- package/dist/config-lkg.js +5 -6
- package/dist/config-provider.js +2 -0
- package/dist/config-types.d.ts +190 -186
- package/dist/config.d.ts +68 -5
- package/dist/config.js +80 -54
- package/dist/degenerate-instrument.js +1 -1
- package/dist/deploy-facts.js +3 -2
- package/dist/deployment-shape.d.ts +21 -12
- package/dist/deployment-shape.js +24 -6
- package/dist/env-facts.d.ts +7 -5
- package/dist/env-facts.js +10 -6
- package/dist/execution-config-root.d.ts +5 -5
- package/dist/execution-config-root.js +5 -5
- package/dist/execution-env-purpose.d.ts +14 -0
- package/dist/execution-env-purpose.js +29 -0
- package/dist/execution-lane-caps.d.ts +49 -86
- package/dist/execution-lane-caps.js +52 -62
- package/dist/execution-placement.d.ts +18 -2
- package/dist/execution-placement.js +19 -0
- package/dist/file-history-disclosure.d.ts +2 -2
- package/dist/fleet/drain-entry.d.ts +17 -10
- package/dist/fleet/drain-entry.js +1 -1
- package/dist/fleet/serving-lease.js +3 -4
- package/dist/history-anchor.d.ts +22 -0
- package/dist/history-anchor.js +14 -0
- package/dist/hooks/command-spawn.d.ts +1 -4
- package/dist/hooks/command-spawn.js +0 -11
- package/dist/hooks/hook-runner.d.ts +52 -8
- package/dist/hooks/hook-runner.js +160 -36
- package/dist/http/approval-sweeps.d.ts +2 -5
- package/dist/http/approval-sweeps.js +3 -2
- package/dist/http/checkpoint-ctx.d.ts +17 -0
- package/dist/http/checkpoint-ctx.js +6 -0
- package/dist/http/claim-latency.d.ts +10 -0
- package/dist/http/claim-latency.js +12 -0
- package/dist/http/dispatch.js +1 -1
- package/dist/http/durable-run-leg.js +2 -1
- package/dist/http/execution-context.d.ts +3 -1
- package/dist/http/execution-context.js +4 -0
- package/dist/http/memory-compliance-failure-reply.d.ts +1 -1
- package/dist/http/memory-compliance-failure-reply.js +3 -0
- package/dist/http/memory-store-refusal-reply.d.ts +3 -3
- package/dist/http/memory-store-refusal-reply.js +3 -0
- package/dist/http/owner-access.d.ts +11 -0
- package/dist/http/owner-access.js +7 -4
- package/dist/http/principal-gate.d.ts +3 -14
- package/dist/http/principal-gate.js +0 -13
- package/dist/http/request-guards.d.ts +1 -1
- package/dist/http/resume-legs.d.ts +7 -10
- package/dist/http/resume-legs.js +79 -50
- package/dist/http/rewind-files-reply.d.ts +34 -0
- package/dist/http/rewind-files-reply.js +36 -0
- package/dist/http/route-ctx.d.ts +32 -16
- package/dist/http/route-table.js +2 -0
- package/dist/http/routes/approvals-assistant.js +5 -25
- package/dist/http/routes/capabilities.js +8 -2
- package/dist/http/routes/devices.js +1 -1
- package/dist/http/routes/memory-origin.d.ts +1 -1
- package/dist/http/routes/notify-wake.js +2 -1
- package/dist/http/routes/projects.d.ts +70 -0
- package/dist/http/routes/projects.js +86 -0
- package/dist/http/routes/rules.js +30 -2
- package/dist/http/routes/runs.js +8 -8
- package/dist/http/routes/session-sync.js +27 -10
- package/dist/http/routes/sessions.d.ts +7 -1
- package/dist/http/routes/sessions.js +104 -2
- package/dist/http/routes/tasks.js +9 -3
- package/dist/http/server.d.ts +24 -10
- package/dist/http/server.js +17 -6
- package/dist/http/stored-body-replay.d.ts +5 -3
- package/dist/http/stored-body-replay.js +10 -1
- package/dist/http/wire-types.d.ts +19 -10
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/instruction-source-notice.d.ts +1 -1
- package/dist/memory-embedder-reembed.d.ts +38 -0
- package/dist/memory-embedder-reembed.js +20 -0
- package/dist/memory-incident-sink.d.ts +0 -28
- package/dist/memory-incident-sink.js +5 -0
- package/dist/memory-scope.d.ts +2 -2
- package/dist/memory-scope.js +1 -1
- package/dist/memory-store-refusal.d.ts +17 -4
- package/dist/memory-store-refusal.js +1 -1
- package/dist/memory-sync-client.d.ts +2 -0
- package/dist/memory-sync-client.js +13 -11
- package/dist/memory-sync.js +1 -1
- package/dist/model-compat.d.ts +35 -21
- package/dist/model-compat.js +49 -21
- package/dist/model-entry-refusal.d.ts +11 -1
- package/dist/model-entry-refusal.js +7 -0
- package/dist/namespaced-rule-name.d.ts +18 -1
- package/dist/namespaced-rule-name.js +12 -0
- package/dist/observability/fail-open.d.ts +17 -9
- package/dist/observability/fail-open.js +17 -9
- package/dist/observability/metrics.d.ts +2 -0
- package/dist/observability/metrics.js +2 -0
- package/dist/observability/secret-env-scrub.d.ts +30 -4
- package/dist/observability/secret-env-scrub.js +15 -3
- package/dist/orchestration/workflow-agent-session-index.d.ts +7 -12
- package/dist/orchestration/workflow-agent-session-index.js +1 -6
- package/dist/orchestration/workflow-completion-inbox.d.ts +26 -6
- package/dist/orchestration/workflow-completion-inbox.js +63 -45
- package/dist/org-memory-admission.d.ts +5 -2
- package/dist/org-memory-admission.js +25 -10
- package/dist/parked-decide.d.ts +33 -26
- package/dist/parked-decide.js +36 -44
- package/dist/plugins/approval-ask-store-file.d.ts +10 -2
- package/dist/plugins/approval-ask-store-file.js +37 -4
- package/dist/plugins/approval-ask-store-memory.d.ts +5 -3
- package/dist/plugins/approval-ask-store-memory.js +11 -2
- package/dist/plugins/approval-ask-store-sql.d.ts +3 -0
- package/dist/plugins/approval-ask-store-sql.js +3 -1
- package/dist/plugins/blob-backend.d.ts +38 -195
- package/dist/plugins/blob-backend.js +33 -229
- package/dist/plugins/caching-session-store.d.ts +9 -4
- package/dist/plugins/checkpoint-index-columns.d.ts +1 -1
- package/dist/plugins/checkpoint-index-columns.js +3 -2
- package/dist/plugins/checkpoint-store-face.d.ts +1 -1
- package/dist/plugins/device-store-sql.d.ts +2 -2
- package/dist/plugins/device-store-sql.js +5 -10
- package/dist/plugins/execution-lane-rename-m40.d.ts +20 -0
- package/dist/plugins/execution-lane-rename-m40.js +10 -0
- package/dist/plugins/execution-placement-sql.d.ts +63 -88
- package/dist/plugins/execution-placement-sql.js +94 -54
- package/dist/plugins/file-run-store.d.ts +26 -12
- package/dist/plugins/file-run-store.js +63 -63
- package/dist/plugins/imported-layer-root-retirement.d.ts +17 -8
- package/dist/plugins/imported-layer-root-retirement.js +4 -8
- package/dist/plugins/inbox-payload-column.d.ts +14 -0
- package/dist/plugins/inbox-payload-column.js +13 -0
- package/dist/plugins/local-checkpoint-store.d.ts +5 -0
- package/dist/plugins/local-checkpoint-store.js +11 -7
- package/dist/plugins/local-data-dir-modes-m39.d.ts +48 -0
- package/dist/plugins/local-data-dir-modes-m39.js +182 -0
- package/dist/plugins/local-engine-high-water.d.ts +11 -0
- package/dist/plugins/local-engine-high-water.js +59 -0
- package/dist/plugins/local-session-store.d.ts +91 -25
- package/dist/plugins/local-session-store.js +124 -45
- package/dist/plugins/local-task-attachment-store.d.ts +2 -0
- package/dist/plugins/local-task-attachment-store.js +10 -11
- package/dist/plugins/memory-embedder-fingerprint.d.ts +33 -10
- package/dist/plugins/memory-embedder-fingerprint.js +52 -12
- package/dist/plugins/memory-embedder.d.ts +1 -1
- package/dist/plugins/memory-embedder.js +2 -2
- package/dist/plugins/memory-engine-pg.d.ts +4 -3
- package/dist/plugins/memory-engine-pg.js +4 -4
- package/dist/plugins/memory-engine-sql-apply.d.ts +13 -4
- package/dist/plugins/memory-engine-sql-apply.js +1 -1
- package/dist/plugins/memory-engine-tidb.d.ts +8 -5
- package/dist/plugins/memory-engine-tidb.js +7 -8
- package/dist/plugins/one-time-migrations.d.ts +145 -35
- package/dist/plugins/one-time-migrations.js +272 -120
- package/dist/plugins/owner-only-file-mode.d.ts +29 -0
- package/dist/plugins/owner-only-file-mode.js +141 -0
- package/dist/plugins/permission-rule-store-file.d.ts +8 -8
- package/dist/plugins/permission-rule-store-file.js +14 -2
- package/dist/plugins/pg-pool.d.ts +2 -1
- package/dist/plugins/pg-pool.js +11 -4
- package/dist/plugins/release-version.d.ts +20 -0
- package/dist/plugins/release-version.js +28 -0
- package/dist/plugins/remote-env-adb.d.ts +20 -4
- package/dist/plugins/remote-env-adb.js +39 -11
- package/dist/plugins/remote-env-e2b.d.ts +12 -3
- package/dist/plugins/remote-env-e2b.js +6 -4
- package/dist/plugins/remote-env-host.d.ts +9 -1
- package/dist/plugins/remote-env-host.js +6 -5
- package/dist/plugins/remote-env-k8s.d.ts +5 -2
- package/dist/plugins/remote-env-k8s.js +15 -4
- package/dist/plugins/remote-env-local-docker.d.ts +4 -1
- package/dist/plugins/remote-env-local-docker.js +3 -3
- package/dist/plugins/remote-env-ssh.d.ts +8 -2
- package/dist/plugins/remote-env-ssh.js +26 -24
- package/dist/plugins/remote-shell.d.ts +59 -30
- package/dist/plugins/remote-shell.js +175 -62
- package/dist/plugins/retention-declaration.d.ts +37 -0
- package/dist/plugins/retention-declaration.js +9 -0
- package/dist/plugins/retention-deployment.d.ts +126 -0
- package/dist/plugins/retention-deployment.js +88 -0
- package/dist/plugins/retention-lane-store-sql.d.ts +74 -4
- package/dist/plugins/retention-lane-store-sql.js +103 -1
- package/dist/plugins/retention-sql.d.ts +29 -0
- package/dist/plugins/retention-sql.js +8 -0
- package/dist/plugins/schema-consistency.d.ts +0 -6
- package/dist/plugins/schema-consistency.js +1 -2
- package/dist/plugins/schema-ensure-legs.d.ts +1 -1
- package/dist/plugins/schema-ensure-legs.js +11 -1
- package/dist/plugins/session-ext-table.d.ts +74 -0
- package/dist/plugins/session-ext-table.js +121 -0
- package/dist/plugins/session-fork.d.ts +1 -1
- package/dist/plugins/session-row-sql.d.ts +8 -7
- package/dist/plugins/session-row-sql.js +15 -7
- package/dist/plugins/session-store-sql.d.ts +131 -0
- package/dist/plugins/session-store-sql.js +298 -0
- package/dist/plugins/session-workspace-cell.d.ts +2 -2
- package/dist/plugins/session-workspace-cell.js +2 -2
- package/dist/plugins/shared-memory-store-sql.d.ts +10 -0
- package/dist/plugins/shared-memory-store-sql.js +13 -13
- package/dist/plugins/snapshot-bucket-presence.js +1 -1
- package/dist/plugins/sql-driver.d.ts +23 -7
- package/dist/plugins/sql-driver.js +41 -8
- package/dist/plugins/sql-errors.d.ts +5 -2
- package/dist/plugins/sql-errors.js +4 -0
- package/dist/plugins/store-backend.d.ts +35 -8
- package/dist/plugins/store-backend.js +184 -62
- package/dist/plugins/store-contracts.d.ts +9 -2
- package/dist/plugins/store-contracts.js +1 -0
- package/dist/plugins/task-attachment-store.d.ts +6 -8
- package/dist/plugins/task-attachment-store.js +15 -10
- package/dist/plugins/task-list-store-sql.d.ts +1 -1
- package/dist/plugins/text-column-capacity.d.ts +21 -0
- package/dist/plugins/text-column-capacity.js +5 -0
- package/dist/plugins/tidb-pool.d.ts +3 -2
- package/dist/plugins/tidb-pool.js +19 -31
- package/dist/plugins/user-input-ledger-sql.d.ts +1 -1
- package/dist/read-face-posture.d.ts +6 -6
- package/dist/read-face-posture.js +2 -2
- package/dist/request-value-closure.d.ts +5 -5
- package/dist/request-value-closure.js +1 -1
- package/dist/rules-consent.d.ts +41 -13
- package/dist/rules-consent.js +101 -53
- package/dist/run-local.js +17 -13
- package/dist/runs.d.ts +48 -30
- package/dist/runs.js +26 -16
- package/dist/runtime-caps-resolver.d.ts +15 -8
- package/dist/runtime-caps-resolver.js +14 -10
- package/dist/sealed-key-layout.d.ts +2 -3
- package/dist/sealed-key-layout.js +0 -1
- package/dist/sealed-key.js +7 -5
- package/dist/security.d.ts +5 -3
- package/dist/sema-config-dir.js +2 -2
- package/dist/server-secret-env.d.ts +2 -0
- package/dist/service-version.d.ts +2 -1
- package/dist/service-version.js +2 -2
- package/dist/session-error-wire.d.ts +1 -1
- package/dist/session-incarnation.d.ts +8 -5
- package/dist/session-resident-background.d.ts +85 -32
- package/dist/session-resident-background.js +75 -7
- package/dist/session-row.d.ts +1 -1
- package/dist/session-sync-kernel.d.ts +1 -1
- package/dist/session-workspace.d.ts +11 -2
- package/dist/session-workspace.js +5 -0
- package/dist/sighup-idle.d.ts +1 -1
- package/dist/store-posture.d.ts +2 -1
- package/dist/stored-request-hooks-m20.d.ts +3 -2
- package/dist/stored-request-hooks-m20.js +19 -14
- package/dist/stores-sql/blob-index-sql.d.ts +148 -0
- package/dist/stores-sql/blob-index-sql.js +154 -0
- package/dist/stores-sql/checkpoint-store-sql.d.ts +1 -1
- package/dist/stores-sql/checkpoint-store-sql.js +11 -27
- package/dist/{plugins → stores-sql}/file-history-store-sql.d.ts +23 -11
- package/dist/{plugins → stores-sql}/file-history-store-sql.js +23 -18
- package/dist/{plugins → stores-sql}/pg-session-storage.d.ts +23 -76
- package/dist/{plugins → stores-sql}/pg-session-storage.js +80 -209
- package/dist/{plugins → stores-sql}/retention-store-sql.d.ts +123 -217
- package/dist/{plugins → stores-sql}/retention-store-sql.js +66 -190
- package/dist/{plugins → stores-sql}/session-event-payload.d.ts +1 -1
- package/dist/{plugins → stores-sql}/session-event-payload.js +1 -1
- package/dist/stores-sql/session-policy-store-sql.d.ts +1 -1
- package/dist/stores-sql/session-write-hooks.d.ts +59 -0
- package/dist/stores-sql/session-write-hooks.js +2 -0
- package/dist/{plugins → stores-sql}/tidb-session-storage.d.ts +10 -11
- package/dist/{plugins → stores-sql}/tidb-session-storage.js +10 -21
- package/dist/{plugins → stores-sql}/tidb-session-store.d.ts +32 -122
- package/dist/{plugins → stores-sql}/tidb-session-store.js +71 -171
- package/dist/stores-sql/tool-result-store-sql.d.ts +1 -1
- package/dist/stores-sql/tool-result-store-sql.js +1 -1
- package/dist/stores-sql/windowed-session-storage.d.ts +56 -0
- package/dist/stores-sql/windowed-session-storage.js +61 -0
- package/dist/task-a2a.d.ts +7 -1
- package/dist/task-a2a.js +15 -14
- package/dist/task-cwd.d.ts +11 -3
- package/dist/task-cwd.js +17 -1
- package/dist/task-mcp.d.ts +10 -2
- package/dist/task-mcp.js +13 -16
- package/dist/task-settings.d.ts +9 -4
- package/dist/task-settings.js +17 -6
- package/dist/tool-approval.d.ts +21 -8
- package/dist/tool-approval.js +10 -6
- package/dist/trace/core-keyset-guard.d.ts +9 -3
- package/dist/trace/engine-notice-wire.d.ts +1 -1
- package/dist/trace/engine-notice-wire.js +2 -0
- package/dist/trace/exit-seat.d.ts +23 -1
- package/dist/trace/exit-seat.js +3 -0
- package/dist/trace/project.d.ts +33 -16
- package/dist/trace/project.js +12 -9
- package/dist/trace/redact.d.ts +1 -1
- package/dist/trace/redact.js +61 -73
- package/dist/trace/self-minted-wire.d.ts +263 -10
- package/dist/trace/self-minted-wire.js +90 -2
- package/dist/trace/sema-provenance.d.ts +45 -41
- package/dist/trace/sema-provenance.js +81 -10
- package/dist/trace/task-notification-facets.d.ts +70 -2
- package/dist/trace/task-notification-facets.js +71 -1
- package/dist/trace/wire-projection-faces.d.ts +38 -2
- package/dist/trace/wire-projection-faces.js +26 -1
- package/dist/unread-request-members.d.ts +66 -0
- package/dist/unread-request-members.js +41 -0
- package/dist/user-input-ledger.d.ts +2 -2
- package/dist/web-admin-client/apply-effective.js +22 -26
- package/dist/web-admin-client/candidate-gate.d.ts +35 -3
- package/dist/web-admin-client/candidate-gate.js +53 -5
- package/dist/web-admin-client/center-request.d.ts +4 -1
- package/dist/web-admin-client/center-request.js +2 -1
- package/dist/web-admin-client/effective-keys.js +0 -1
- package/dist/web-admin-client/facade.d.ts +1 -1
- package/dist/web-admin-client/http-client.d.ts +1 -0
- package/dist/web-admin-client/http-client.js +17 -9
- package/dist/web-admin-client/restart-signal.js +5 -2
- package/dist/web-admin-client/skills-mcp.d.ts +20 -6
- package/dist/web-admin-client/skills-mcp.js +26 -21
- package/dist/web-admin-client/types.d.ts +34 -49
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +2 -2
- package/package.json +13 -12
- package/scripts/drain-check-local.mjs +2 -28
- package/scripts/drain-check.mysql.sql +2 -18
- package/scripts/drain-check.pg.sql +2 -18
- package/wire-changes/server@7.147.0.json +813 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { recordFailOpen } from "./observability/fail-open.js";
|
|
2
|
+
import { isStoreFormRefusalCode } from "./memory-store-refusal.js";
|
|
1
3
|
import { redactIncarnations } from "./session-incarnation.js";
|
|
2
4
|
import { codeFieldOf } from "./terminal.js";
|
|
3
5
|
import { seatText } from "./trace/exit-seat.js";
|
|
@@ -10,6 +12,9 @@ export function createMemoryEngineIncidentSink(deps) {
|
|
|
10
12
|
detail: redactIncarnations(String(err)),
|
|
11
13
|
});
|
|
12
14
|
deps.metrics?.inc("memory_engine_incident_total", { ...codeField });
|
|
15
|
+
const { code } = codeField;
|
|
16
|
+
if (isStoreFormRefusalCode(code))
|
|
17
|
+
recordFailOpen("server.memory.store-form-refused-step-skipped", `code=${code}`);
|
|
13
18
|
};
|
|
14
19
|
}
|
|
15
20
|
export function createOperatorFaceIncidentSink(deps, event) {
|
package/dist/memory-scope.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ export declare function memoryScopeFor(config: ServiceConfig, principal?: string
|
|
|
57
57
|
*
|
|
58
58
|
* **一条规则,与车道无关**(主会话 09-23 裁 ②):项目根 = spec 解析出的**真任务根**(`boot/resolve-spec.ts`
|
|
59
59
|
* 的 `realTaskRootOf`,[ref] 属主;run-local 腿 = 它的 `workspaceDir`)。本进程读得到这个根 ⇒ 求项目身份并铸项目层键
|
|
60
|
-
* (
|
|
60
|
+
* (无手的 `none` 车道的真任务根是 `process.cwd()`,读得到,所以照常铸 —— 它的语义就是「项目 = 任务根指向的地方」,不需要另一个词);
|
|
61
61
|
* 读不到(根在沙箱/设备盘上,或 host 车道会话没登记 cwd、spec 期还不知道根)⇒ 调用方传 `undefined` ⇒ `{ absent: "unreadable" }`,
|
|
62
62
|
* core 铸 operator 通知 `memory.project_scope_absent`,写照常落全局层 —— **响亮**,不是静默落 `local`。
|
|
63
63
|
*
|
|
@@ -106,7 +106,7 @@ export declare function replicatesProjectLayersOf(coverage: MemoryReplicationCov
|
|
|
106
106
|
* (`MEMORY_ENGINE_REMOTE_LANE=allow`, e.g. ssh to a host on the same NFS mount).
|
|
107
107
|
*
|
|
108
108
|
* Pure posture probe (memoryEngineBackendFor consumes it; main.ts logs it): `undefined` = no plane split
|
|
109
|
-
* (the lane's file plane IS this worker's fs — `
|
|
109
|
+
* (the lane's file plane IS this worker's fs — `none` / `host`), `dark` = split + fail-closed, `forced` =
|
|
110
110
|
* split + operator override.
|
|
111
111
|
* The plane question reads the execution environment block (`hostLocalPaths`, sole author `capabilitiesFor`) — it used to be the
|
|
112
112
|
* hand-written synonym `lane === undefined || lane === "host"`; readings are unchanged lane by lane.
|
package/dist/memory-scope.js
CHANGED
|
@@ -68,7 +68,7 @@ export function replicatesProjectLayersOf(coverage, owner) {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
export function memoryEngineRemoteLanePosture(config) {
|
|
71
|
-
const lane =
|
|
71
|
+
const lane = config.remoteExec.provider;
|
|
72
72
|
if (capabilitiesFor(config).hostLocalPaths)
|
|
73
73
|
return undefined;
|
|
74
74
|
return { lane, posture: config.memoryEngineRemoteLaneAllowed === true ? "forced" : "dark" };
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* **店形拒**(store-form refusal)在本仓的唯一读法属主(纯叶:零 http / 零 boot 依赖)—— core
|
|
2
|
+
* **店形拒**(store-form refusal)在本仓的唯一读法属主(纯叶:零 http / 零 boot 依赖)—— core 店形拒**一族**(族表 `STORE_FORM_REFUSAL_CODES`,引擎 7.65.0 起三码;
|
|
3
|
+
* 本仓按族读,下面点名的成员只是举例与历史,不是判据):
|
|
3
4
|
* · `memory.target_outside_store`(core 7.31.1 [ref]):记忆 store 里的一个目录经软链通到了 store **外**(或 store 根在 backend 打开 / 引擎首次
|
|
4
5
|
* 挂载之后被改指)⇒ 引擎对落点在外的删 / 写 / 重放 / 自身写一律**不做**;
|
|
5
6
|
* · `memory.scope_home_not_directory`(core 7.44.0 [ref]):一只 scope home(`<memoryDir>/<label>`)不是真目录 —— 被换成软链 / 普通文件 / 特殊文件
|
|
6
7
|
* (`detail.form` ∈ `symlink` | `file` | `other`,`lstat` 判、不跟链)。修前 core 对这一形抛不带码的 `ControlPlaneCorruptError`(与真控制面损坏同类同形),
|
|
7
|
-
* 平铺布局(条目直接住在 home 里)于是答 500,而同一换法在嵌套布局下一层答 409 ——
|
|
8
|
-
*
|
|
8
|
+
* 平铺布局(条目直接住在 home 里)于是答 500,而同一换法在嵌套布局下一层答 409 —— 现在两布局同答这一码;
|
|
9
|
+
* · `memory.control_plane_links_unsupported`(core 7.65.0):记忆控制面所在的文件系统不能建硬链接 ⇒ File 记忆店在打开处被拒(构造期抛 ⇒ 起服拒;
|
|
10
|
+
* 引擎 mount 时开它自己的店被拒 ⇒ Runner 记忆相 fail-open,这一跑 memoryless,见 `memory-incident-sink.ts`)。
|
|
11
|
+
* 族里各码的形相同:普通 `Error` + `.code` + `.detail`(`{ path }`;home 那一码多 `form`),**句子以码领头、不含任何宿主路径**(core 7.44.0 起,
|
|
9
12
|
* 路径只在 `detail.path`)。core 的读法:operator 要处置的盘形(去掉那只链 / 放回真目录),**不是**可重试的 IO 故障,也**不是**对调用方的裁决;
|
|
10
|
-
*
|
|
13
|
+
* 盘形修好之前重发恒拒。本仓据此一条规则:族内同答、409、码原样;路径只进运维行(HTTP 映射一处,见 `http/memory-store-refusal-reply.ts`)。
|
|
11
14
|
*
|
|
12
15
|
* ## 两条到达车道,两个读者(本模块各给一只,别处不许再写第二份判据)
|
|
13
16
|
* ① **抛出面**(抹除 / 出处 / 外源列表 / 清标 / bundle 导出导入 —— 凡触 store 树的 backend 面):`.code` 就是码
|
|
@@ -36,6 +39,16 @@
|
|
|
36
39
|
*/
|
|
37
40
|
import { type ScopeHomeForm, type StoreFormRefusalCode } from "@sema-agent/core";
|
|
38
41
|
import type { Logger } from "./observability/logger.js";
|
|
42
|
+
/**
|
|
43
|
+
* 词表与型全取 core 包根([ref] / core 7.45.0 [ref];此前 core 不导出,本文件自写两只码字面量与族表 —— 那份手抄随本版退役):
|
|
44
|
+
* · 族 = `STORE_FORM_REFUSAL_CODES`,型 `StoreFormRefusalCode`;族判只读族表、不点成员(族的成员归 core,不在这里由人裁)。HTTP 映射逐码写字面量
|
|
45
|
+
* (错误码目录门扫源码字面量,变量态的码对它隐形),两处穷举:`http/memory-store-refusal-reply.ts`(operator 面)与 `http/memory-compliance-failure-reply.ts`(会话所有者面)——
|
|
46
|
+
* 引擎加一码 ⇒ 两处编译红、各补一臂(引擎 7.65.0 的第三码 `CONTROL_PLANE_LINKS_UNSUPPORTED` 就是这样补的);记忆相上撞到它的 fail-open 臂〔mount 开店被拒 / mount 后的一步记忆活被拒〕在 `memory-incident-sink.ts` 登记;
|
|
47
|
+
* · 抛出面的形 = `StoreFormRefusal`(普通 `Error` + `code` + `detail: StoreFormRefusalDetail`);
|
|
48
|
+
* · `detail.form` 的闭集 = `SCOPE_HOME_FORMS`(型 `ScopeHomeForm`):闭集内原样读,闭集外不读(引擎说不出的词不进运维行)。
|
|
49
|
+
*/
|
|
50
|
+
/** 族判(族表 `STORE_FORM_REFUSAL_CODES` 的唯一判据):{@link storeFormRefusalOf} 用它判抛出面的 `.code`;记忆事故席用它判 `codeFieldOf` 已经读出的码(那一席码只许读一次)。 */
|
|
51
|
+
export declare const isStoreFormRefusalCode: (code: unknown) => code is StoreFormRefusalCode;
|
|
39
52
|
/** 一次店形拒的读数(纯数据)。`path` / `form` 取自 core 的 `detail`(读不出 ⇒ `undefined`,不猜、不从句子里抠)。 */
|
|
40
53
|
export interface StoreFormRefusalReading {
|
|
41
54
|
readonly code: StoreFormRefusalCode;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SCOPE_HOME_FORMS, STORE_FORM_REFUSAL_CODES } from "@sema-agent/core";
|
|
2
|
-
const isStoreFormRefusalCode = (code) => STORE_FORM_REFUSAL_CODES.includes(code);
|
|
2
|
+
export const isStoreFormRefusalCode = (code) => STORE_FORM_REFUSAL_CODES.includes(code);
|
|
3
3
|
const isScopeHomeForm = (form) => SCOPE_HOME_FORMS.includes(form);
|
|
4
4
|
export function storeFormRefusalOf(err) {
|
|
5
5
|
if (!(err instanceof Error))
|
|
@@ -40,6 +40,8 @@ export declare function createMemorySyncTransport(opts: {
|
|
|
40
40
|
/** 一层的游标文件路径:引擎根 `memoryEngineDir`(= `RunnerDeps.memoryEngineDir` 的那一个值)下 `sync-cursors/<scope 摘要>.json`。一层一只,不随对端变、不随店变。
|
|
41
41
|
* 落在子目录里:与更早的根下一层文件名 `sync-cursor-<peer>.json` 的空间不相交。 */
|
|
42
42
|
export declare function memorySyncCursorPath(memoryEngineDir: string, scope: string): string;
|
|
43
|
+
/** 全部游标文件的父目录 `<引擎根>/sync-cursors`(游标路径与一次性迁移 M39 的名册同读这一只;缺省 File 记忆引擎根 = 数据根 ⇒ `<数据根>/sync-cursors`)。 */
|
|
44
|
+
export declare function memorySyncCursorDirFor(memoryEngineDir: string): string;
|
|
43
45
|
/**
|
|
44
46
|
* ⑦ 停驻层的出路(闭集;今天唯一成员)。`delete_cursor` = 删掉这一层的游标文件,下一轮从空基线重收敛。读面 `memorySync.parked[].wayOut` 与运维行同读这只词;
|
|
45
47
|
* 加一个词 ⇒ {@link wayOutSentence} 的穷尽 switch 编译红(句子先写好,词才上得了 wire)。
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { createHash
|
|
2
|
-
import {
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { readFile, readdir, rename, rmdir, stat } from "node:fs/promises";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
|
-
import { carriesCredential, syncMemoryScope, } from "@sema-agent/core";
|
|
4
|
+
import { carriesCredential, ensureDir, syncMemoryScope, } from "@sema-agent/core";
|
|
5
5
|
import { replicationCovers } from "./memory-scope.js";
|
|
6
6
|
import { parseProjectLayerKey } from "./project-layer-key.js";
|
|
7
|
+
import { atomicWriteFileAsync } from "./plugins/owner-only-file-mode.js";
|
|
7
8
|
import { ONE_TIME_MIGRATIONS, migrationWindowOpen } from "./plugins/one-time-migrations.js";
|
|
8
9
|
import { buildMemorySyncIdentityBootRefusal, readMemorySyncIdentity } from "./memory-sync-identity.js";
|
|
9
10
|
import { buildDisplaySafeUrl } from "./trace/redact.js";
|
|
@@ -44,7 +45,10 @@ function scopeDigest(scope) {
|
|
|
44
45
|
return createHash("sha256").update(scope, "utf8").digest("hex").slice(0, 32);
|
|
45
46
|
}
|
|
46
47
|
export function memorySyncCursorPath(memoryEngineDir, scope) {
|
|
47
|
-
return join(memoryEngineDir,
|
|
48
|
+
return join(memorySyncCursorDirFor(memoryEngineDir), `${scopeDigest(scope)}.json`);
|
|
49
|
+
}
|
|
50
|
+
export function memorySyncCursorDirFor(memoryEngineDir) {
|
|
51
|
+
return join(memoryEngineDir, SYNC_CURSOR_DIR);
|
|
48
52
|
}
|
|
49
53
|
const CURSOR_AXES = { scope: true, peer: true, store: true, incarnation: true };
|
|
50
54
|
const CURSOR_FOUND = { absent: true, other: true };
|
|
@@ -142,10 +146,8 @@ async function loadLayerBaseline(path, scope) {
|
|
|
142
146
|
return { kind: "cursor", cursor };
|
|
143
147
|
}
|
|
144
148
|
async function saveCursor(path, cursor) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
await writeFile(tmp, JSON.stringify(cursor), "utf8");
|
|
148
|
-
await rename(tmp, path);
|
|
149
|
+
ensureDir(dirname(path));
|
|
150
|
+
await atomicWriteFileAsync(path, JSON.stringify(cursor), { durability: "best-effort" });
|
|
149
151
|
}
|
|
150
152
|
const LEGACY_PEER_SEGMENT = "central";
|
|
151
153
|
const LEGACY_ROOT_CURSOR_FILE = "sync-cursor-central.json";
|
|
@@ -191,7 +193,7 @@ export async function relocateSyncCursorsM31(memoryEngineDir, log, opts) {
|
|
|
191
193
|
log.warn("memory_sync_cursor_not_relocated", { path: from, to, note: "this layer already has a cursor at its path, so the file written by an earlier version stays where it is and no round reads it; delete it" });
|
|
192
194
|
return;
|
|
193
195
|
}
|
|
194
|
-
|
|
196
|
+
ensureDir(dirname(to));
|
|
195
197
|
try {
|
|
196
198
|
await rename(from, to);
|
|
197
199
|
}
|
|
@@ -203,7 +205,7 @@ export async function relocateSyncCursorsM31(memoryEngineDir, log, opts) {
|
|
|
203
205
|
moved += 1;
|
|
204
206
|
log.info("memory_sync_cursor_relocated", { from, to });
|
|
205
207
|
};
|
|
206
|
-
const legacyDir = join(memoryEngineDir,
|
|
208
|
+
const legacyDir = join(memorySyncCursorDirFor(memoryEngineDir), LEGACY_PEER_SEGMENT);
|
|
207
209
|
let names = [];
|
|
208
210
|
try {
|
|
209
211
|
names = await readdir(legacyDir);
|
|
@@ -214,7 +216,7 @@ export async function relocateSyncCursorsM31(memoryEngineDir, log, opts) {
|
|
|
214
216
|
}
|
|
215
217
|
for (const name of [...names].sort()) {
|
|
216
218
|
if (/^[0-9a-f]{32}\.json$/.test(name))
|
|
217
|
-
await move(join(legacyDir, name), join(memoryEngineDir,
|
|
219
|
+
await move(join(legacyDir, name), join(memorySyncCursorDirFor(memoryEngineDir), name));
|
|
218
220
|
}
|
|
219
221
|
if (names.length > 0) {
|
|
220
222
|
try {
|
package/dist/memory-sync.js
CHANGED
|
@@ -219,7 +219,7 @@ export async function performMemorySync(backend, sync, scope, req, now = Date.no
|
|
|
219
219
|
const patches = [
|
|
220
220
|
...plan.pull.map((e) => {
|
|
221
221
|
const base = req.baseRevs[e.id];
|
|
222
|
-
return base !== undefined ? { op: "update", id: e.id, entry: e, baseRev: base } : { op: "add", id: e.id, entry: e };
|
|
222
|
+
return base !== undefined ? { op: "update", id: e.id, entry: e, baseRev: base } : { op: "add", id: e.id, entry: e, guard: "absent" };
|
|
223
223
|
}),
|
|
224
224
|
...plan.deleteLocal.map((d) => ({ op: "delete", id: d.id, baseRev: d.baseRev })),
|
|
225
225
|
];
|
package/dist/model-compat.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `Model.compat` ——
|
|
3
|
-
*
|
|
2
|
+
* `Model.compat` —— 一只模型对**它那条线路**的兼容声明(声明面 settings-schema 1.10.0 `ModelEntry.compat`,契约包解析透明、形归本服务):
|
|
3
|
+
* openai-completions 条目读 core `OpenAICompletionsCompat`,anthropic-messages 条目读 core `AnthropicMessagesCompat`(**按线路读**,
|
|
4
|
+
* 线路 = 条目的 `api`:core 的 `Model.compat` 按 `TApi` 分型,契约 `ModelEntry` 强制 `provider:"anthropic"` ⟺ `api:"anthropic-messages"`)。
|
|
5
|
+
* 本模块是**两条腿共用的唯一判据点 + 唯一铸点**,
|
|
4
6
|
* 与 `toolFaces` 的读法(引擎根导出的 `readToolFaces`,`task-mcp.ts` / `skills-mcp.ts` 两腿同问)同一个「判据单点、多腿一致」的形。
|
|
5
7
|
*
|
|
6
8
|
* ## 它治的病(1.10.0 CHANGELOG + core 型面顶注双向亲读)
|
|
@@ -11,10 +13,10 @@
|
|
|
11
13
|
* 真需求 = vLLM / Qwen 类**缺省开思考**的网关:关思考只能靠 `chat_template_kwargs.enable_thinking=false`
|
|
12
14
|
* (`thinkingFormat: "qwen-chat-template"`),否则 auto 档每一轮都白烧一段思考。
|
|
13
15
|
*
|
|
14
|
-
* ##
|
|
15
|
-
* `THINKING_LEVEL_TABLE` / `THINKING_FORMAT_TABLE` / `MAX_TOKENS_FIELD_TABLE` 都是 `Record<闭集词, true>`,
|
|
16
|
-
* `COMPAT_KEY_READERS` 是 `{ [K in keyof Required<
|
|
17
|
-
* core
|
|
16
|
+
* ## 对表全部**从 core 的型面铸**,本仓一个词都不枚举
|
|
17
|
+
* `THINKING_LEVEL_TABLE` / `THINKING_FORMAT_TABLE` / `MAX_TOKENS_FIELD_TABLE` / `THINKING_MODE_TABLE` 都是 `Record<闭集词, true>`,
|
|
18
|
+
* `COMPAT_KEY_READERS` 是 `{ [A in 线路]: { [K in keyof Required<Model<A>["compat"]>]: 读器 } }` 的**映射型**(线路 = 契约 `ModelEntry.api` 的闭集):
|
|
19
|
+
* core 加词/删词、加键/删键,或契约加一条线路,表当场 tsc 红(`MODEL_DEGRADE_ON` 的 `Set<DegradeReason>` 同款纪律)。
|
|
18
20
|
* 映射型这一步是刻意的 —— 只钉「键集相等」会留下一个洞:core 加一键、有人把它补进白名单却忘了写读器,
|
|
19
21
|
* 于是这个键被**允许但不读** = 静默丢。读器与键集是**同一张表**,那个洞在结构上不存在。
|
|
20
22
|
*
|
|
@@ -27,13 +29,19 @@
|
|
|
27
29
|
* 反方向(整只模型不进)的代价则不成比例:一个拼错的 `thinkingFormat` 会让这只模型从目录里消失,
|
|
28
30
|
* 用户面直接是 `request.unknown_reference`。
|
|
29
31
|
*
|
|
30
|
-
*
|
|
32
|
+
* 判形**整只判**(每条线路内):任一键不合 —— 含写了另一条线路的键 —— ⇒ 整只声明不收(和 `toolFaces` 每只工具「applied whole or not at all」
|
|
31
33
|
* 同律)。留下好的那几键 = 让运维以为整条声明生效了,而实际发出去的请求是半张脸。
|
|
32
34
|
*/
|
|
33
35
|
import type { Model } from "@sema-agent/core";
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
export type
|
|
36
|
+
import type { ModelEntry } from "@sema-agent/settings-schema";
|
|
37
|
+
/** 目录条目的线路闭集 = 契约 `ModelEntry.api`(契约加一条线路 ⇒ 读器表缺一行 ⇒ tsc 红)。 */
|
|
38
|
+
export type CatalogApi = ModelEntry["api"];
|
|
39
|
+
/** 一条线路的 compat 型 —— core 的 index 没有按名导出它们,从 `Model` 的**型面**取(`Model<TApi>` 的 `compat` 按 api 分叉)。这不是抄一份结构,是引用同一个型。 */
|
|
40
|
+
export type CompatOf<A extends CatalogApi> = NonNullable<Model<A>["compat"]>;
|
|
41
|
+
/** core `OpenAICompletionsCompat`。 */
|
|
42
|
+
export type OpenAICompletionsCompat = CompatOf<"openai-completions">;
|
|
43
|
+
/** core `AnthropicMessagesCompat`。 */
|
|
44
|
+
export type AnthropicMessagesCompat = CompatOf<"anthropic-messages">;
|
|
37
45
|
/** 六档思考梯(core `ThinkingLevel`)。`MODEL_DEFAULT_THINKING` / `MODEL_REASONING_EFFORT_LEVELS` /
|
|
38
46
|
* `compat.reasoningEffortLevels` 三处共用**这一张**表 —— [ref] 件⑤ 起就是「上游加一档而这里不补 ⇒
|
|
39
47
|
* 编译红」的锁步姿势,本模块只是把它挪到了它真正的家(compat 的一个键)。 */
|
|
@@ -48,34 +56,40 @@ export declare const isThinkingFormat: (w: unknown) => w is ModelThinkingFormat;
|
|
|
48
56
|
/** `maxTokensField` 两词闭集(缺席 ⇒ core 按模型 id 推断,见 `inferMaxTokensField`)。 */
|
|
49
57
|
export type ModelMaxTokensField = NonNullable<OpenAICompletionsCompat["maxTokensField"]>;
|
|
50
58
|
export declare const MAX_TOKENS_FIELDS: readonly ModelMaxTokensField[];
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
export declare const
|
|
59
|
+
/** anthropic 线路 `thinkingMode` 两词闭集(core:`budget` = `thinking:{type:"enabled",budget_tokens}`;`adaptive` = `thinking:{type:"adaptive"}`、无 budget、关不掉)。 */
|
|
60
|
+
export type AnthropicThinkingMode = NonNullable<AnthropicMessagesCompat["thinkingMode"]>;
|
|
61
|
+
export declare const ANTHROPIC_THINKING_MODES: readonly AnthropicThinkingMode[];
|
|
62
|
+
type CompatKey<A extends CatalogApi> = keyof Required<CompatOf<A>>;
|
|
63
|
+
/** 每条线路的键闭集(书写序取自上表),未知键拒因文案与铸点遍历的单一真源。 */
|
|
64
|
+
export declare const MODEL_COMPAT_KEYS: {
|
|
65
|
+
readonly [A in CatalogApi]: readonly CompatKey<A>[];
|
|
66
|
+
};
|
|
54
67
|
/**
|
|
55
68
|
* 一条目录条目的 `compat` 判形结果:
|
|
56
69
|
* · `{ ok: true, compat }` —— 合形(`compat` 缺席 = 这条条目没有声明,或声明了一个**空**对象:
|
|
57
70
|
* 两者对 core 同义,都不铸键);
|
|
58
71
|
* · `{ ok: false, issue }` —— 判不出形,调用方**整只丢**这条声明并留一句 warn(见模块头注)。
|
|
59
|
-
* `issue`
|
|
72
|
+
* `issue` 只带线路、键名与哪一段不合,**不带值** —— 与 `source` / `toolFaces` 同一条留痕纪律。
|
|
60
73
|
*/
|
|
61
|
-
export type ModelCompatRead = {
|
|
74
|
+
export type ModelCompatRead<A extends CatalogApi> = {
|
|
62
75
|
ok: true;
|
|
63
|
-
compat?:
|
|
76
|
+
compat?: CompatOf<A>;
|
|
64
77
|
} | {
|
|
65
78
|
ok: false;
|
|
66
79
|
issue: string;
|
|
67
80
|
};
|
|
68
|
-
/** 从任一腿的原始条目里读出 `compat`
|
|
69
|
-
export declare function readModelCompat(v: unknown): ModelCompatRead
|
|
81
|
+
/** 从任一腿的原始条目里读出 `compat`(按条目的线路)—— **本地 config.d 腿与 center 腿共用的唯一判据点**。 */
|
|
82
|
+
export declare function readModelCompat<A extends CatalogApi>(api: A, v: unknown): ModelCompatRead<A>;
|
|
70
83
|
/**
|
|
71
|
-
* `Model.compat` 的**唯一铸点**(env
|
|
84
|
+
* `Model.compat` 的**唯一铸点**(env 腿与目录腿都经这里;按线路)。层序 = 优先级,**前层逐键赢、后层补缺席**
|
|
72
85
|
* (BL-8:目录条目声明 ?? env 缺省 —— 不是整只替换,否则一条只写了 `thinkingFormat` 的目录条目会把
|
|
73
86
|
* 部署级的 `MODEL_REASONING_EFFORT_LEVELS` 静默吃掉,正是 `contextWindow`/`maxTokens` 那一族的老病)。
|
|
87
|
+
* 层必须是同一条线路的声明(调用方只把同线路的 env 缺省叠进来 —— 见 `toModel`)。
|
|
74
88
|
*
|
|
75
89
|
* 归一两条(两腿因此对同一个空值给出同一个下场):值 `undefined` = 这一层没声明这一键;
|
|
76
|
-
* `reasoningEffortLevels`
|
|
90
|
+
* 数组值为**空表** = 没声明这一键(`reasoningEffortLevels` / `effortLevels`;env 腿的空 CSV 与目录腿的 `[]` 同义)。
|
|
77
91
|
* 全空 ⇒ 回 `undefined` = **不铸这个键**(缺席 = core 走自己的推断 = 今日行为)。
|
|
78
92
|
*/
|
|
79
|
-
export declare function buildModelCompat(...layers: ReadonlyArray<
|
|
93
|
+
export declare function buildModelCompat<A extends CatalogApi>(api: A, ...layers: ReadonlyArray<CompatOf<A> | undefined>): CompatOf<A> | undefined;
|
|
80
94
|
export {};
|
|
81
95
|
//# sourceMappingURL=model-compat.d.ts.map
|
package/dist/model-compat.js
CHANGED
|
@@ -6,47 +6,75 @@ export const THINKING_FORMATS = Object.keys(THINKING_FORMAT_TABLE);
|
|
|
6
6
|
export const isThinkingFormat = (w) => typeof w === "string" && THINKING_FORMATS.includes(w);
|
|
7
7
|
const MAX_TOKENS_FIELD_TABLE = { max_tokens: true, max_completion_tokens: true };
|
|
8
8
|
export const MAX_TOKENS_FIELDS = Object.keys(MAX_TOKENS_FIELD_TABLE);
|
|
9
|
+
const THINKING_MODE_TABLE = { budget: true, adaptive: true };
|
|
10
|
+
export const ANTHROPIC_THINKING_MODES = Object.keys(THINKING_MODE_TABLE);
|
|
11
|
+
const readBoolean = (v) => (typeof v === "boolean" ? v : undefined);
|
|
12
|
+
const readLadder = (v) => (Array.isArray(v) && v.every(isThinkingTier) ? v : undefined);
|
|
9
13
|
const COMPAT_KEY_READERS = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
"openai-completions": {
|
|
15
|
+
supportsReasoningEffort: readBoolean,
|
|
16
|
+
requiresReasoningContentOnAssistantMessages: readBoolean,
|
|
17
|
+
maxTokensField: (v) => (typeof v === "string" && MAX_TOKENS_FIELDS.includes(v) ? v : undefined),
|
|
18
|
+
thinkingFormat: (v) => (isThinkingFormat(v) ? v : undefined),
|
|
19
|
+
reasoningEffortLevels: readLadder,
|
|
20
|
+
},
|
|
21
|
+
"anthropic-messages": {
|
|
22
|
+
thinkingMode: (v) => (typeof v === "string" && ANTHROPIC_THINKING_MODES.includes(v) ? v : undefined),
|
|
23
|
+
effortLevels: readLadder,
|
|
24
|
+
supportsTemperature: readBoolean,
|
|
25
|
+
contextManagement: readBoolean,
|
|
26
|
+
interleavedThinking: readBoolean,
|
|
27
|
+
},
|
|
15
28
|
};
|
|
16
|
-
export const MODEL_COMPAT_KEYS =
|
|
17
|
-
|
|
18
|
-
|
|
29
|
+
export const MODEL_COMPAT_KEYS = {
|
|
30
|
+
"openai-completions": Object.keys(COMPAT_KEY_READERS["openai-completions"]),
|
|
31
|
+
"anthropic-messages": Object.keys(COMPAT_KEY_READERS["anthropic-messages"]),
|
|
32
|
+
};
|
|
33
|
+
const isKeyOf = (table, k) => Object.hasOwn(table, k);
|
|
34
|
+
export function readModelCompat(api, v) {
|
|
19
35
|
if (v === undefined)
|
|
20
36
|
return { ok: true };
|
|
21
37
|
if (v === null || typeof v !== "object" || Array.isArray(v))
|
|
22
38
|
return { ok: false, issue: `compat is ${v === null ? "null" : Array.isArray(v) ? "an array" : typeof v}, not an object of wire-compat keys` };
|
|
39
|
+
return COMPAT_LEGS[api].read(v);
|
|
40
|
+
}
|
|
41
|
+
function readCompatWith(api, readers, v) {
|
|
23
42
|
const out = {};
|
|
24
43
|
for (const [k, raw] of Object.entries(v)) {
|
|
25
|
-
if (!
|
|
26
|
-
return { ok: false, issue: `unknown key ${JSON.stringify(k)} (valid: ${
|
|
27
|
-
const read =
|
|
44
|
+
if (!isKeyOf(readers, k))
|
|
45
|
+
return { ok: false, issue: `unknown key ${JSON.stringify(k)} for an ${api} entry (valid: ${Object.keys(readers).join(" | ")})` };
|
|
46
|
+
const read = readers[k](raw);
|
|
28
47
|
if (read === undefined)
|
|
29
|
-
return { ok: false, issue: `key ${JSON.stringify(k)} does not fit the wire-compat shape` };
|
|
48
|
+
return { ok: false, issue: `key ${JSON.stringify(k)} does not fit the ${api} wire-compat shape` };
|
|
30
49
|
out[k] = read;
|
|
31
50
|
}
|
|
32
51
|
return Object.keys(out).length > 0 ? { ok: true, compat: out } : { ok: true };
|
|
33
52
|
}
|
|
34
|
-
export function buildModelCompat(...layers) {
|
|
53
|
+
export function buildModelCompat(api, ...layers) {
|
|
54
|
+
return COMPAT_LEGS[api].build(layers);
|
|
55
|
+
}
|
|
56
|
+
const declaresKey = (v) => v !== undefined && !(Array.isArray(v) && v.length === 0);
|
|
57
|
+
function buildCompatWith(keys, layers) {
|
|
35
58
|
const out = {};
|
|
36
59
|
for (const layer of layers) {
|
|
37
60
|
if (layer === undefined)
|
|
38
61
|
continue;
|
|
39
|
-
for (const k of
|
|
40
|
-
if (k
|
|
62
|
+
for (const k of keys) {
|
|
63
|
+
if (Object.hasOwn(out, k) || !declaresKey(layer[k]))
|
|
41
64
|
continue;
|
|
42
|
-
|
|
43
|
-
if (v === undefined)
|
|
44
|
-
continue;
|
|
45
|
-
if (k === "reasoningEffortLevels" && Array.isArray(v) && v.length === 0)
|
|
46
|
-
continue;
|
|
47
|
-
out[k] = v;
|
|
65
|
+
out[k] = layer[k];
|
|
48
66
|
}
|
|
49
67
|
}
|
|
50
68
|
return Object.keys(out).length > 0 ? out : undefined;
|
|
51
69
|
}
|
|
70
|
+
const COMPAT_LEGS = {
|
|
71
|
+
"openai-completions": {
|
|
72
|
+
read: (v) => readCompatWith("openai-completions", COMPAT_KEY_READERS["openai-completions"], v),
|
|
73
|
+
build: (layers) => buildCompatWith(MODEL_COMPAT_KEYS["openai-completions"], layers),
|
|
74
|
+
},
|
|
75
|
+
"anthropic-messages": {
|
|
76
|
+
read: (v) => readCompatWith("anthropic-messages", COMPAT_KEY_READERS["anthropic-messages"], v),
|
|
77
|
+
build: (layers) => buildCompatWith(MODEL_COMPAT_KEYS["anthropic-messages"], layers),
|
|
78
|
+
},
|
|
79
|
+
};
|
|
52
80
|
//# sourceMappingURL=model-compat.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ModelEntryRefusalCode, type ModelPlaneRefusalCode, type ModelRefusalsSignal } from "@sema-agent/settings-schema";
|
|
2
2
|
import { type DroppedCatalogEntry } from "./web-admin-client/read-warnings.js";
|
|
3
3
|
import { type ModelTableLeg } from "./model-select.js";
|
|
4
|
+
import type { CandidateRejectionNote } from "./web-admin-client/candidate-gate.js";
|
|
4
5
|
/**
|
|
5
6
|
* 条目拒因码 → 本仓铸它的成因 —— **以码为键**([ref]):码闭集的属主是 settings-schema(`MODEL_ENTRY_REFUSAL_CODES`,6.2.0 起;此前本仓
|
|
6
7
|
* 自持一份同名码表,撞名已消灭、零别名)。那边加一个条目码 ⇒ 本表缺键 ⇒ 本仓 tsc 红(只拿 `satisfies` 约束码值证明的是「子集」,
|
|
@@ -132,10 +133,17 @@ export declare function echoModelRef(ref: string): string;
|
|
|
132
133
|
* 别名段(`(catalog entry …)`)的判断读原形:ref 与条目名逐字相同 ⇒ 不带,不因回显截短而误判成「另有条目」。
|
|
133
134
|
*/
|
|
134
135
|
export declare function modelUnavailableMessage(field: string, requested: string, name: string, r: ModelEntryRefusal): string;
|
|
135
|
-
/** 缺省模型不变量读的切面(`ServiceConfig` 与 `CrossInvariantView`
|
|
136
|
+
/** 缺省模型不变量读的切面(`ServiceConfig` 与 `CrossInvariantView` 都结构满足;可选成员缺席 = 没有被拒的候选)。 */
|
|
136
137
|
export interface DefaultModelView {
|
|
137
138
|
readonly models: Readonly<Record<string, unknown>>;
|
|
138
139
|
readonly modelRefusals: Readonly<Record<string, ModelEntryRefusal>>;
|
|
140
|
+
/**
|
|
141
|
+
* [ref] ① —— **为何这张 env 表上没有目录**:候选判官整拒了最近一份候选(一个域都没应用),于是回落 env。值是判官交出的拒因列(`rejected.errors`,与 `config_candidate_rejected`
|
|
142
|
+
* 行体的 `errors` 同一份事实)经 `buildCandidateRejectionNotes` 投成的纯数据 —— 每个被拒文档一格:文档名 · 拒码 · 原因类词 · 文档路径(本地读腿)。**不含 `error` 原文**:
|
|
143
|
+
* 契约 / 读腿的原句可能点名链接指向的目标路径等操作数,只留在 warn 行(那里已过产出边界脱敏);句子函数不读日志、不读原句、不自铸第二份。
|
|
144
|
+
* 缺席 / 空 = 没有被拒的候选(纯 env 部署、候选被收下、dry-run)⇒ 拒因句逐字不变。只有 `env` 腿的句子读它(`catalog` 腿说的是目录候选自己没有缺省,与候选被整拒无关)。
|
|
145
|
+
*/
|
|
146
|
+
readonly candidateRejectionNotes?: readonly CandidateRejectionNote[];
|
|
139
147
|
}
|
|
140
148
|
/**
|
|
141
149
|
* 🔴 [ref] —— **这张模型表有没有一只缺省模型**(`models.default`)。`undefined` = 有。
|
|
@@ -146,6 +154,8 @@ export interface DefaultModelView {
|
|
|
146
154
|
*
|
|
147
155
|
* 拒因一句:码 + 这条腿上**真实**的出路 + 若目录在场但每条都不可用,点名它们与各自的码。env 腿句首保留 `MODEL_ID is required`
|
|
148
156
|
* 这个既有的可 grep 片段(壳与运维脚本认它);目录腿不提 `MODEL_ID`(见 {@link ModelTableLeg})。
|
|
157
|
+
* env 腿若是因「候选被判官整拒」才回落到这张表({@link DefaultModelView.candidateRejectionNotes}),同一行再追加「回落原因」:被拒的文档名 + 拒码 + 原因类词 + 文档路径 ——
|
|
158
|
+
* 不带配置值、不带链接指向的目标路径、不抄任何 `error` 原文;只追加,句首的 grep 锚不动,没有被拒候选时整句逐字不变。
|
|
149
159
|
*/
|
|
150
160
|
export declare function defaultModelRefusal(view: DefaultModelView, leg: ModelTableLeg): string | undefined;
|
|
151
161
|
/** 一个被铸出的被拒名字:`name` = 被拒条目的名字,`target` = 增广把它指向的那条条目,`via` = 它是以什么身份被铸出的。 */
|
|
@@ -152,6 +152,12 @@ export function modelUnavailableMessage(field, requested, name, r) {
|
|
|
152
152
|
const alias = requested === name ? "" : ` (catalog entry "${name}")`;
|
|
153
153
|
return `${field} "${echoModelRef(requested)}"${alias} is published in the catalog but unavailable on this deployment [${r.code}] — ${r.detail}`;
|
|
154
154
|
}
|
|
155
|
+
function candidateFellBackClause(notes) {
|
|
156
|
+
if (notes === undefined || notes.length === 0)
|
|
157
|
+
return "";
|
|
158
|
+
const rows = notes.map((n) => `"${n.document}" [${n.code}] ${n.cause}${n.path !== undefined ? `: ${n.path}` : ""}`);
|
|
159
|
+
return ` (the config candidate was rejected whole and none of its domains applied, so its catalog is not in this table; fix or remove the named document(s) — the config_candidate_rejected warn line has the full diagnostics — rejected: ${rows.join(" | ")})`;
|
|
160
|
+
}
|
|
155
161
|
export function defaultModelRefusal(view, leg) {
|
|
156
162
|
if (Object.hasOwn(view.models, DEFAULT_MODEL_REF) && view.models[DEFAULT_MODEL_REF] !== undefined)
|
|
157
163
|
return undefined;
|
|
@@ -161,6 +167,7 @@ export function defaultModelRefusal(view, leg) {
|
|
|
161
167
|
case "env":
|
|
162
168
|
return (`MODEL_ID is required when no catalog default resolves [${DEFAULT_MODEL_MISSING_CODE}] — this model table has no default model` +
|
|
163
169
|
unavailable +
|
|
170
|
+
candidateFellBackClause(view.candidateRejectionNotes) +
|
|
164
171
|
". Set MODEL_ID=<model name your gateway serves>, or enable at least one model this host can serve in the catalog " +
|
|
165
172
|
"(config.d/models.json, or the web-admin) — either one is enough (a web-admin that answers after the boot budget " +
|
|
166
173
|
"counts as absent at boot: raise CONFIG_BOOT_FETCH_BUDGET_MS to wait for it).");
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* (本文件那只判与它在会话规则写口、SQL 店写口、四张条目表上的调用)退役,零双读。
|
|
8
8
|
*
|
|
9
9
|
* **调它的面**(点名,不是「每个面」):运维三张名表(`APPROVAL_REQUIRE` / `DENY` / `NEVER_AUTO`)与中心下发的同名表、请求
|
|
10
|
-
* `settings.permissions.{ask,deny}`(经 `config.ts` 的 `unmatchableToolNamesRefusal`)
|
|
10
|
+
* `settings.permissions.{ask,deny,neverAuto}`(经 `config.ts` 的 `unmatchableToolNamesRefusal`)。这些面上退役且无后继的名字在**有通告席**的表上不拒、行原样留着(唯一读法 {@link isRetiredWithoutSuccessor};
|
|
11
|
+
* 通告席见 `UnmatchableToolNameJudgment.noticeSeat`),请求体 `neverAuto` 没有通告席、照拒。会话规则写口直接调 core 的 `assertSessionRuleNamesCurrent`
|
|
11
12
|
* (同一只判官的店形);引擎 allow 层的条目表(请求 `settings.permissions.allow`、运维 `APPROVAL_GRANT`、技能两只清单)交引擎 `compileAllowList`
|
|
12
13
|
* (名册 = {@link TOOL_NAME_ROSTER};判官判非现役的条目读成 `tool_name`,名册里有的只差大小写读成 `near_miss`)。
|
|
13
14
|
* **不调它的面**:`/v1/rules` 的持久规则写口与 `cc-import` 导入口(`http/routes/rules.ts`、`rules-consent.ts` 与两只持久规则店零判官调用)—— 如实未接,
|
|
@@ -51,6 +52,22 @@ export declare const NAME_TABLE_BEHAVIOR: "deny";
|
|
|
51
52
|
* (core 7.55.0 [ref]:`mcp__*` 在 deny / ask 里是这一协议的每一只工具、在 allow 里什么也不是),漏传态度的调用点是编译错,不是一条静默的「不带态度」读法。
|
|
52
53
|
*/
|
|
53
54
|
export declare function unmatchableRuleNameOf(name: string, behavior: PermissionRule["behavior"]): UnmatchableRuleName | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* **限制表上跳过的那一行**,唯一一只读法:引擎判官判 `retired`,且判词**不带** 1:1 后继 `currentName`(退役表那一行写的是 `removed` / `folded into`,不是 `renamed`)。
|
|
57
|
+
* 这样一行够不着任何工具,也没有可以改写成的现名 —— 引擎准备期的名字审计用同一位(`retired` ∧ 无 `currentName`)把它排出审计、照跑,并铸一条 `config.legacy_tool_name`。
|
|
58
|
+
* 本服务**有通告席**的前门读这一只:**不拒、不改写表**(行原样留着 —— 与引擎同:引擎只把它排出审计,编出的策略里那一行照在,名册里真有同名工具时它照管);
|
|
59
|
+
* 不拒必须配恰一句话 —— 没有人说话的表(请求体 `settings.permissions.neverAuto`、选择器清单)照拒:选择器 / 技能表候引擎发退役名通告,`neverAuto` 候引擎导出通告句源后由本服务铸。
|
|
60
|
+
* 谁读这张表谁说一句:引擎读的表(请求体 `settings.permissions` 的规则桶)由引擎铸通告;只有本服务读的表(运维 `APPROVAL_REQUIRE` / `DENY` / `NEVER_AUTO`、
|
|
61
|
+
* 中心下发的 `approvalRequire`)由读它的那一处按 {@link retiredWithoutSuccessorEntries} 在起服 / 落配日志里点名。本服务的名册看不到嵌入方自挂的工具,
|
|
62
|
+
* 所以「够不着」只对本服务知道的工具成立 —— 去掉这一行会让嵌入方自挂的同名工具失去这条限制(静默放宽),留着它最坏是一条死行。
|
|
63
|
+
* 有后继的改名(`Task` ⇒ `Agent`、`KillShell` ⇒ `TaskStop`)不是这一形:写的人要的那只工具换了名字,照拒并给现名。其它判词不经这里。
|
|
64
|
+
*/
|
|
65
|
+
export declare function isRetiredWithoutSuccessor(v: UnmatchableRuleName | undefined): boolean;
|
|
66
|
+
/** 一张**只有本服务读**的限制名表(条目就是工具名:运维 `APPROVAL_REQUIRE` / `DENY` / `NEVER_AUTO`、中心下发的 `approvalRequire`)里按 {@link isRetiredWithoutSuccessor} 读出的那几行(带退役表自己那一行),供读表处点名;表本身不动。 */
|
|
67
|
+
export declare function retiredWithoutSuccessorEntries(names: readonly string[], behavior: PermissionRule["behavior"]): readonly {
|
|
68
|
+
readonly entry: string;
|
|
69
|
+
readonly guidance: string;
|
|
70
|
+
}[];
|
|
54
71
|
/**
|
|
55
72
|
* 判词 → 「为什么永远匹配不到 + 怎么写」(不复述条目本身 —— 调用方的句子已点名它)。引擎判词的 `guidance` 原样带出,是改法指引的**唯一**一句
|
|
56
73
|
* (本仓不在后面追加 1:1 现名:通配名上那个现名是摘要名或更窄的写法,照写不生效;现名过境给机器读的位,如会话规则拒体顶层的 `currentName`);
|
|
@@ -10,6 +10,18 @@ export function unmatchableRuleNameOf(name, behavior) {
|
|
|
10
10
|
const verdict = judgeRuleToolName(name, TOOL_NAME_ROSTER, behavior);
|
|
11
11
|
return verdict.kind === "current" ? undefined : verdict;
|
|
12
12
|
}
|
|
13
|
+
export function isRetiredWithoutSuccessor(v) {
|
|
14
|
+
return v?.kind === "retired" && v.currentName === undefined;
|
|
15
|
+
}
|
|
16
|
+
export function retiredWithoutSuccessorEntries(names, behavior) {
|
|
17
|
+
const out = [];
|
|
18
|
+
for (const name of names) {
|
|
19
|
+
const verdict = unmatchableRuleNameOf(name, behavior);
|
|
20
|
+
if (verdict?.kind === "retired" && isRetiredWithoutSuccessor(verdict))
|
|
21
|
+
out.push({ entry: name, guidance: verdict.guidance });
|
|
22
|
+
}
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
13
25
|
export function describeUnmatchableRuleName(v, name) {
|
|
14
26
|
switch (v.kind) {
|
|
15
27
|
case "retired":
|