@sema-agent/server 7.136.0 → 7.138.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 +501 -139
- package/README.md +1 -0
- package/README.zh-CN.md +1 -0
- package/USAGE.md +149 -34
- package/deploy/sema-up/README.md +14 -0
- package/deploy/sema-up/chart/templates/sandbox-rbac.yaml +7 -1
- package/deploy/sema-up/stack/sema-stack-cluster.yaml +7 -1
- package/dist/approval-card.d.ts +21 -14
- package/dist/approval-card.js +1 -0
- package/dist/approval-content-kind.d.ts +6 -0
- package/dist/approval-content-kind.js +7 -0
- package/dist/approval-gate-currency.d.ts +48 -6
- package/dist/approval-gate-currency.js +16 -9
- package/dist/approval-hmac.d.ts +13 -1
- package/dist/approval-hmac.js +1 -1
- package/dist/approval.js +3 -3
- package/dist/audit.js +1 -0
- package/dist/auth-bridge.js +2 -2
- package/dist/background-agent-name.d.ts +5 -0
- package/dist/background-agent-name.js +5 -0
- package/dist/boot/budget-tracing.d.ts +1 -12
- package/dist/boot/deployment-mods.d.ts +46 -16
- package/dist/boot/deployment-mods.js +82 -6
- package/dist/boot/execution-env.d.ts +24 -1
- package/dist/boot/execution-env.js +69 -6
- package/dist/boot/governance-seams.d.ts +10 -17
- package/dist/boot/governance-seams.js +5 -17
- package/dist/boot/leader.d.ts +3 -0
- package/dist/boot/leader.js +1 -0
- package/dist/boot/org-delivery.js +15 -2
- package/dist/boot/reapers.d.ts +3 -0
- package/dist/boot/reapers.js +15 -1
- package/dist/boot/resolve-spec.d.ts +7 -0
- package/dist/boot/resolve-spec.js +36 -26
- package/dist/boot/retention-lane.d.ts +11 -5
- package/dist/boot/retention-lane.js +2 -2
- package/dist/boot/runner-deps.d.ts +7 -3
- package/dist/boot/runner-deps.js +1 -0
- package/dist/boot/stage-03-store-backend.d.ts +1 -1
- package/dist/boot/stage-04-stores.d.ts +2 -13
- package/dist/boot/stage-05-execution-env.d.ts +6 -13
- package/dist/boot/stage-05-execution-env.js +17 -5
- package/dist/boot/stage-06-runners.d.ts +6 -13
- package/dist/boot/stage-06-runners.js +10 -3
- package/dist/boot/stage-07-capability-layer.d.ts +7 -13
- package/dist/boot/stage-07-capability-layer.js +3 -3
- package/dist/boot/stage-08-reapers.d.ts +7 -13
- package/dist/boot/stage-08-reapers.js +2 -1
- package/dist/boot/stage-09-leader.d.ts +7 -13
- package/dist/boot/stage-09-leader.js +2 -2
- package/dist/boot/stage-10-http-server.d.ts +7 -13
- package/dist/boot/stage-10-http-server.js +6 -3
- package/dist/boot/stores.d.ts +1 -1
- package/dist/boot/web-admin.d.ts +5 -2
- package/dist/boot/web-admin.js +3 -3
- package/dist/brain.js +5 -5
- package/dist/broker/broker.d.ts +89 -0
- package/dist/broker/broker.js +287 -0
- package/dist/broker/constants.d.ts +39 -0
- package/dist/broker/constants.js +15 -0
- package/dist/broker/http1.d.ts +111 -0
- package/dist/broker/http1.js +256 -0
- package/dist/broker/lease-book.d.ts +87 -0
- package/dist/broker/lease-book.js +142 -0
- package/dist/broker/lease-file.d.ts +60 -0
- package/dist/broker/lease-file.js +127 -0
- package/dist/broker/main.d.ts +2 -0
- package/dist/broker/main.js +20 -0
- package/dist/budget.d.ts +17 -15
- package/dist/budget.js +2 -2
- package/dist/capabilities/composite-members.d.ts +2 -1
- package/dist/capabilities/composite-members.js +2 -1
- package/dist/capabilities/engine-capabilities.js +1 -0
- package/dist/capabilities/mcp-probe.d.ts +36 -11
- package/dist/capabilities/mcp-probe.js +44 -5
- package/dist/capabilities/scenarios.d.ts +23 -8
- package/dist/capabilities/scenarios.js +13 -8
- package/dist/capabilities/skills.d.ts +28 -5
- package/dist/capabilities/skills.js +8 -0
- package/dist/capability-facts.d.ts +6 -0
- package/dist/capability-facts.js +5 -0
- package/dist/center-credential-renewer.js +5 -1
- package/dist/checkpoint-ctx-seal-m28.d.ts +3 -10
- package/dist/checkpoint-ctx-seal-m28.js +1 -1
- package/dist/checkpoint-identity.d.ts +13 -6
- package/dist/config-catalog.js +16 -7
- package/dist/config-types.d.ts +24 -7
- package/dist/config.d.ts +1 -1
- package/dist/config.js +42 -13
- package/dist/deployment-governance.d.ts +2 -2
- package/dist/deployment-governance.js +7 -9
- package/dist/deployment-shape.d.ts +6 -6
- package/dist/device-ws-protocol.d.ts +1 -0
- package/dist/device-ws-protocol.js +2 -1
- package/dist/file-history-disclosure.d.ts +4 -2
- package/dist/file-history-disclosure.js +2 -0
- package/dist/gate-settlement.d.ts +71 -0
- package/dist/gate-settlement.js +40 -0
- package/dist/hooks/classic-stations.d.ts +12 -54
- package/dist/hooks/classic-stations.js +1 -0
- package/dist/hooks/command-spawn.d.ts +2 -2
- package/dist/hooks/hook-runner.js +14 -14
- package/dist/http/admission.js +14 -9
- package/dist/http/approval-sweeps.js +4 -3
- package/dist/http/caller-trust.d.ts +2 -1
- package/dist/http/caller-trust.js +1 -3
- package/dist/http/checkpoint-ctx.d.ts +48 -7
- package/dist/http/checkpoint-ctx.js +40 -0
- package/dist/http/dispatch.d.ts +4 -0
- package/dist/http/dispatch.js +18 -10
- package/dist/http/durable-run-leg.d.ts +5 -1
- package/dist/http/durable-run-leg.js +5 -3
- package/dist/http/health-self-report.d.ts +2 -2
- package/dist/http/memory-compliance-failure-reply.js +3 -0
- package/dist/http/principal-gate.d.ts +15 -10
- package/dist/http/principal-gate.js +48 -9
- package/dist/http/resume-legs.d.ts +7 -31
- package/dist/http/resume-legs.js +185 -126
- package/dist/http/route-ctx.d.ts +38 -53
- package/dist/http/route-ctx.js +2 -5
- package/dist/http/routes/a2a-serve.js +10 -4
- package/dist/http/routes/agents-roster.d.ts +1 -1
- package/dist/http/routes/agents-roster.js +5 -1
- package/dist/http/routes/approvals-assistant.js +24 -10
- package/dist/http/routes/capabilities.js +23 -11
- package/dist/http/routes/mcp-reconnect.d.ts +3 -2
- package/dist/http/routes/mcp-reconnect.js +7 -7
- package/dist/http/routes/memory-consolidation.d.ts +1 -1
- package/dist/http/routes/memory-origin.d.ts +1 -1
- package/dist/http/routes/rules.js +3 -3
- package/dist/http/routes/runs.js +13 -8
- package/dist/http/routes/session-sync.js +42 -6
- package/dist/http/routes/sessions.js +6 -3
- package/dist/http/routes/side-query.js +2 -3
- package/dist/http/routes/tasks.js +794 -780
- package/dist/http/server.d.ts +35 -25
- package/dist/http/stored-body-replay.d.ts +3 -3
- package/dist/http/stored-body-replay.js +6 -1
- package/dist/http/wire-types.d.ts +66 -33
- package/dist/identity-source.d.ts +65 -0
- package/dist/identity-source.js +45 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/leader/wire.d.ts +7 -0
- package/dist/leader/wire.js +5 -4
- package/dist/mcp-assertion-header.d.ts +51 -40
- package/dist/mcp-assertion-header.js +10 -11
- package/dist/mcp-authorization-face.d.ts +27 -0
- package/dist/mcp-authorization-face.js +15 -0
- package/dist/memory-operator-faces.d.ts +13 -4
- package/dist/memory-operator-faces.js +1 -17
- package/dist/memory-store-refusal.d.ts +3 -3
- package/dist/memory-sync-client.js +72 -57
- package/dist/memory-sync.d.ts +1 -1
- package/dist/model-entry-refusal.d.ts +2 -0
- package/dist/model-entry-refusal.js +11 -0
- package/dist/model-route-gap.d.ts +6 -22
- package/dist/model-route-gap.js +7 -5
- package/dist/model-select.d.ts +6 -17
- package/dist/model-select.js +0 -3
- package/dist/mods-declaration.d.ts +110 -0
- package/dist/mods-declaration.js +109 -0
- package/dist/namespaced-rule-name.d.ts +1 -1
- package/dist/observability/err-text.d.ts +5 -0
- package/dist/observability/err-text.js +9 -0
- package/dist/observability/fail-open.d.ts +17 -1
- package/dist/observability/fail-open.js +17 -1
- package/dist/observability/metrics.js +1 -1
- package/dist/observability/run-terminal.js +1 -0
- package/dist/observability/secret-env-scrub.d.ts +1 -1
- package/dist/observability/secret-env-scrub.js +1 -1
- package/dist/operator-ask.d.ts +2 -2
- package/dist/org-delivery-gate.js +1 -1
- package/dist/org-memory-admission.d.ts +2 -2
- package/dist/org-memory-admission.js +39 -2
- package/dist/parked-decide.d.ts +15 -2
- package/dist/parked-decide.js +17 -10
- package/dist/peer-directory.js +2 -0
- package/dist/peer-seat.d.ts +150 -0
- package/dist/peer-seat.js +239 -0
- package/dist/permission-rule-list.d.ts +2 -2
- package/dist/permission-rule-vocab.d.ts +7 -7
- package/dist/permission-rule-vocab.js +3 -3
- package/dist/plain-string-record.d.ts +38 -0
- package/dist/plain-string-record.js +38 -0
- package/dist/plugins/background-agent-store-sql.js +6 -3
- package/dist/plugins/caching-session-store.d.ts +5 -0
- package/dist/plugins/caching-session-store.js +6 -0
- package/dist/plugins/checkpoint-store-sql.d.ts +34 -29
- package/dist/plugins/checkpoint-store-sql.js +14 -14
- package/dist/plugins/file-history-store-sql.js +10 -16
- package/dist/plugins/file-run-store.js +8 -2
- package/dist/plugins/k8s-exec-protocol.d.ts +69 -13
- package/dist/plugins/k8s-exec-protocol.js +116 -28
- package/dist/plugins/k8s-pod-delete-failure.d.ts +25 -0
- package/dist/plugins/k8s-pod-delete-failure.js +17 -0
- package/dist/plugins/k8s-pod-reaper.d.ts +106 -0
- package/dist/plugins/k8s-pod-reaper.js +122 -0
- package/dist/plugins/local-checkpoint-store.d.ts +4 -17
- package/dist/plugins/local-checkpoint-store.js +3 -4
- package/dist/plugins/local-session-store.d.ts +66 -27
- package/dist/plugins/local-session-store.js +60 -28
- package/dist/plugins/mailbox-store-sql.d.ts +11 -3
- package/dist/plugins/mailbox-store-sql.js +103 -15
- package/dist/plugins/memory-run-store.js +2 -0
- package/dist/plugins/memory-sync-store-pg.d.ts +16 -5
- package/dist/plugins/memory-sync-store-tidb.d.ts +3 -3
- package/dist/plugins/one-time-migrations.d.ts +34 -12
- package/dist/plugins/one-time-migrations.js +51 -9
- package/dist/plugins/permission-rule-store-file.js +2 -2
- package/dist/plugins/permission-rule-store-sql.d.ts +17 -17
- package/dist/plugins/permission-rule-store-sql.js +37 -30
- package/dist/plugins/pg-pool.js +4 -0
- package/dist/plugins/pg-session-storage.d.ts +10 -2
- package/dist/plugins/pg-session-storage.js +20 -7
- package/dist/plugins/remote-env-adb.d.ts +6 -1
- package/dist/plugins/remote-env-adb.js +2 -1
- package/dist/plugins/remote-env-device.d.ts +6 -1
- package/dist/plugins/remote-env-device.js +5 -1
- package/dist/plugins/remote-env-e2b.d.ts +5 -0
- package/dist/plugins/remote-env-e2b.js +2 -1
- package/dist/plugins/remote-env-file-error.d.ts +8 -1
- package/dist/plugins/remote-env-file-error.js +7 -1
- package/dist/plugins/remote-env-host.d.ts +10 -2
- package/dist/plugins/remote-env-host.js +8 -2
- package/dist/plugins/remote-env-k8s.d.ts +140 -11
- package/dist/plugins/remote-env-k8s.js +277 -15
- package/dist/plugins/remote-env-local-docker.d.ts +5 -0
- package/dist/plugins/remote-env-local-docker.js +2 -1
- package/dist/plugins/remote-env-ssh.d.ts +6 -1
- package/dist/plugins/remote-env-ssh.js +2 -1
- package/dist/plugins/retention-store-sql.d.ts +14 -2
- package/dist/plugins/retention-store-sql.js +6 -0
- package/dist/plugins/run-store-sql.js +10 -4
- package/dist/plugins/session-fork.d.ts +10 -13
- package/dist/plugins/session-fork.js +5 -25
- package/dist/plugins/session-ownership.d.ts +24 -3
- package/dist/plugins/session-ownership.js +24 -5
- package/dist/plugins/session-workspace-cell.d.ts +17 -0
- package/dist/plugins/session-workspace-cell.js +38 -0
- package/dist/plugins/sql-errors.d.ts +23 -2
- package/dist/plugins/sql-errors.js +15 -0
- package/dist/plugins/store-backend.js +7 -7
- package/dist/plugins/store-contracts.d.ts +10 -1
- package/dist/plugins/store-fault.d.ts +2 -2
- package/dist/plugins/store-fault.js +4 -2
- package/dist/plugins/tidb-pool.js +13 -0
- package/dist/plugins/tidb-session-store.d.ts +17 -2
- package/dist/plugins/tidb-session-store.js +18 -7
- package/dist/plugins/tool-result-store-sql.d.ts +13 -6
- package/dist/plugins/tool-result-store-sql.js +8 -7
- package/dist/plugins/worktree-isolation.d.ts +3 -2
- package/dist/plugins/worktree-isolation.js +1 -7
- package/dist/project-identity.d.ts +1 -14
- package/dist/project-identity.js +0 -4
- package/dist/request-key-closure.js +1 -1
- package/dist/request-value-closure.d.ts +31 -2
- package/dist/request-value-closure.js +7 -1
- package/dist/rule-entry-list.d.ts +3 -2
- package/dist/rule-entry-list.js +2 -2
- package/dist/rules-consent.js +12 -7
- package/dist/run-local.d.ts +2 -2
- package/dist/run-local.js +12 -6
- package/dist/runs.d.ts +7 -1
- package/dist/runs.js +8 -2
- package/dist/runtime-governance.d.ts +5 -5
- package/dist/sandbox-git-lease.d.ts +49 -0
- package/dist/sandbox-git-lease.js +60 -0
- package/dist/sandbox-git-plane.d.ts +84 -0
- package/dist/sandbox-git-plane.js +105 -0
- package/dist/security.d.ts +16 -4
- package/dist/security.js +8 -3
- package/dist/server-secret-env.d.ts +12 -3
- package/dist/server-secret-env.js +18 -2
- package/dist/session-error-wire.d.ts +14 -6
- package/dist/session-error-wire.js +2 -1
- package/dist/session-incarnation.d.ts +4 -5
- package/dist/session-incarnation.js +2 -2
- package/dist/session-policy-wire.d.ts +1 -1
- package/dist/session-policy-wire.js +2 -2
- package/dist/session-sync.d.ts +1 -1
- package/dist/session-workspace.d.ts +130 -0
- package/dist/session-workspace.js +83 -0
- package/dist/spec-fields.d.ts +44 -14
- package/dist/spec-fields.js +33 -12
- package/dist/standing-answer-grant.d.ts +2 -13
- package/dist/standing-answer-grant.js +0 -7
- package/dist/stored-request-prompt-profile-m30.d.ts +49 -0
- package/dist/stored-request-prompt-profile-m30.js +25 -0
- package/dist/task-a2a.d.ts +44 -14
- package/dist/task-a2a.js +46 -20
- package/dist/task-mcp.d.ts +34 -21
- package/dist/task-mcp.js +46 -22
- package/dist/task-settings.d.ts +2 -2
- package/dist/tool-approval.d.ts +43 -9
- package/dist/tool-approval.js +57 -15
- package/dist/tool-rule-names.d.ts +5 -0
- package/dist/trace/core-keyset-guard.d.ts +34 -19
- package/dist/trace/engine-notice-wire.d.ts +1 -1
- package/dist/trace/engine-notice-wire.js +4 -0
- package/dist/trace/exit-seat.d.ts +20 -1
- package/dist/trace/exit-seat.js +5 -2
- package/dist/trace/extension-call-face.d.ts +33 -0
- package/dist/trace/extension-call-face.js +39 -0
- package/dist/trace/ledger-sink.d.ts +4 -5
- package/dist/trace/ledger-sink.js +3 -7
- package/dist/trace/project.d.ts +62 -10
- package/dist/trace/project.js +49 -9
- package/dist/trace/redact.d.ts +18 -6
- package/dist/trace/redact.js +154 -60
- package/dist/trace/self-minted-wire.d.ts +500 -7
- package/dist/trace/self-minted-wire.js +182 -1
- package/dist/trace/wire-projection-faces.d.ts +7 -5
- package/dist/trace/wire-projection-faces.js +9 -4
- package/dist/user-authored-text.d.ts +2 -2
- package/dist/user-authored-text.js +16 -1
- package/dist/web-admin-client/apply-effective.js +0 -1
- package/dist/web-admin-client/center-request.d.ts +23 -4
- package/dist/web-admin-client/center-request.js +42 -8
- package/dist/web-admin-client/http-client.js +6 -6
- package/dist/web-admin-client/skills-mcp.d.ts +8 -4
- package/dist/web-admin-client/skills-mcp.js +31 -18
- package/dist/web-admin-client/types.d.ts +10 -5
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +11 -5
- package/package.json +3 -3
- package/wire-changes/server@7.137.0.json +825 -0
- package/wire-changes/server@7.138.0.json +446 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MAX_MINTED_TOOL_RESULT_REF_CHARS, assertSafeToolResultRef, assertToolResultProvenanceMatch, normalizeToolResultProvenance } from "@sema-agent/core";
|
|
2
2
|
import { pgSanitizeText } from "./pg-safe-json.js";
|
|
3
3
|
import { mysqlDriver, pgDriver } from "./sql-driver.js";
|
|
4
|
-
import { MANAGED_RETENTION } from "./retention-store-sql.js";
|
|
4
|
+
import { MANAGED_RETENTION, UNMANAGED_RETENTION } from "./retention-store-sql.js";
|
|
5
5
|
import { ensureIndexes } from "./ensure-index.js";
|
|
6
6
|
export const PG_TOOL_RESULT_SCHEMA = [
|
|
7
7
|
`CREATE TABLE IF NOT EXISTS tool_result (
|
|
@@ -49,9 +49,10 @@ export async function assertToolResultProvenanceSchema(query, dialect) {
|
|
|
49
49
|
}
|
|
50
50
|
export class SqlToolResultStore {
|
|
51
51
|
db;
|
|
52
|
-
retention
|
|
53
|
-
constructor(db) {
|
|
52
|
+
retention;
|
|
53
|
+
constructor(db, opts = {}) {
|
|
54
54
|
this.db = db;
|
|
55
|
+
this.retention = opts.retention ?? UNMANAGED_RETENTION;
|
|
55
56
|
}
|
|
56
57
|
q(tidb, pg) {
|
|
57
58
|
return this.db.dialect === "tidb" ? tidb : pg;
|
|
@@ -128,13 +129,13 @@ export class SqlToolResultStore {
|
|
|
128
129
|
}
|
|
129
130
|
}
|
|
130
131
|
export class TiDBToolResultStore extends SqlToolResultStore {
|
|
131
|
-
constructor(pool) {
|
|
132
|
-
super(mysqlDriver(pool));
|
|
132
|
+
constructor(pool, opts) {
|
|
133
|
+
super(mysqlDriver(pool), opts);
|
|
133
134
|
}
|
|
134
135
|
}
|
|
135
136
|
export class PgToolResultStore extends SqlToolResultStore {
|
|
136
|
-
constructor(pool) {
|
|
137
|
-
super(pgDriver(pool));
|
|
137
|
+
constructor(pool, opts) {
|
|
138
|
+
super(pgDriver(pool), opts);
|
|
138
139
|
}
|
|
139
140
|
}
|
|
140
141
|
//# sourceMappingURL=tool-result-store-sql.js.map
|
|
@@ -54,8 +54,9 @@ export declare function withWorktreeIsolation(baseFactory: ExecutionEnvFactory,
|
|
|
54
54
|
* post-kill Runner hook). NEVER throws (a prune failure is logged, never fatal).
|
|
55
55
|
*
|
|
56
56
|
* NOTE: `git worktree prune` only deregisters worktrees whose DIRECTORY is missing. A crashed run that left
|
|
57
|
-
* the dir intact is NOT reaped by prune alone — that is acceptable for v1 (the worktree lives under
|
|
58
|
-
*
|
|
57
|
+
* the dir intact is NOT reaped by prune alone — that is acceptable for v1 (the worktree lives under core's known
|
|
58
|
+
* managed parent `<repoRoot>/<WORKTREE_PARENT>/` on its own `sema/<name>` branch and is human-/script-reapable;
|
|
59
|
+
* a stricter age-based sweep is a follow-on).
|
|
59
60
|
*/
|
|
60
61
|
export declare function reapOrphanWorktrees(baseEnvForGit: ExecutionEnv, repoRoot: string, logger?: WorktreeIsolationLogger): Promise<void>;
|
|
61
62
|
//# sourceMappingURL=worktree-isolation.d.ts.map
|
|
@@ -31,7 +31,7 @@ export function withWorktreeIsolation(baseFactory, opts) {
|
|
|
31
31
|
return baseFactory(ctx);
|
|
32
32
|
}
|
|
33
33
|
let innerDestroy;
|
|
34
|
-
const { env, worktreeDir } = await serialize(() => addWorktree(opts.baseEnvForGit, {
|
|
34
|
+
const { env, worktreeDir, baseSha } = await serialize(() => addWorktree(opts.baseEnvForGit, {
|
|
35
35
|
repoRoot,
|
|
36
36
|
sessionId: ctx.sessionId,
|
|
37
37
|
rootEnvAt: async (dir) => {
|
|
@@ -43,12 +43,6 @@ export function withWorktreeIsolation(baseFactory, opts) {
|
|
|
43
43
|
},
|
|
44
44
|
...(opts.commit ? { commit: opts.commit } : {}),
|
|
45
45
|
}));
|
|
46
|
-
let baseSha;
|
|
47
|
-
{
|
|
48
|
-
const r = await opts.baseEnvForGit.exec("git rev-parse HEAD", { cwd: worktreeDir });
|
|
49
|
-
if (r.ok && r.value.exitCode === 0)
|
|
50
|
-
baseSha = r.value.stdout.trim();
|
|
51
|
-
}
|
|
52
46
|
const isChanged = async () => {
|
|
53
47
|
const status = await opts.baseEnvForGit.exec("git status --porcelain", { cwd: worktreeDir });
|
|
54
48
|
if (!status.ok || status.value.exitCode !== 0)
|
|
@@ -4,19 +4,6 @@ import { type ProjectLayerIdentity } from "./project-layer-key.js";
|
|
|
4
4
|
export type { MemoryProjectKey };
|
|
5
5
|
/** 本仓会说的缺席词。`not_git` 刻意排除:裁 D 起非 git 目录按目录键控,不是缺席(core 闭集仍收它,本仓不铸)。 */
|
|
6
6
|
export type ProjectIdentityAbsentReason = Exclude<MemoryProjectKeyAbsentReason, "not_git">;
|
|
7
|
-
/** 一个任务根的项目身份:canonical 项目根,或说得出理由的缺席。 */
|
|
8
|
-
export type ProjectIdentity = {
|
|
9
|
-
readonly root: string;
|
|
10
|
-
} | {
|
|
11
|
-
readonly absent: ProjectIdentityAbsentReason;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* 任务根 → 项目身份([ref] 四例;见文件头)。纯文件系统读,零子进程。
|
|
15
|
-
* `taskRoot` 必须是**本进程读得到**的路径(调用方按车道判:根在沙箱/设备盘上就别调,直接给 `unreadable`)。
|
|
16
|
-
*
|
|
17
|
-
* 一次向上走,规则三条按优先序:最近的 `.git`(① ② ③)> 链上最近的裸仓布局(④ bare)> 非 git 按目录键控(④)。
|
|
18
|
-
*/
|
|
19
|
-
export declare function resolveProjectIdentity(taskRoot: string): ProjectIdentity;
|
|
20
7
|
/**
|
|
21
8
|
* 退役 `repo:` 键的**唯一**铸点([ref] ①:`repo:` + sha256 hex 前 24;`root` 为 realpath 字符串,不加尾斜杠、不折大小写)。
|
|
22
9
|
* [ref] 起它只是一次性迁移的来源(`memory-project-layer.ts` 把这一层的条目折进新键;窗见 `plugins/one-time-migrations.ts` 登记表)。
|
|
@@ -39,7 +26,7 @@ export declare function assertProjectLayerOwnable(scope: string, envName: string
|
|
|
39
26
|
export declare function normalizeGitRemoteUrl(url: string): string | undefined;
|
|
40
27
|
/**
|
|
41
28
|
* 任务根 → 项目层身份([ref]):当前档(`r` 优先,没有 origin 退 `p`)+ 本 checkout 的低档(`r` 档时 = 它的 `p` 档)。
|
|
42
|
-
*
|
|
29
|
+
* 缺席形 = 找根的缺席词(`bare` / `unreadable`);git 配置在而读不了 ⇒ `unreadable`。
|
|
43
30
|
*/
|
|
44
31
|
export declare function projectLayerIdentityOf(taskRoot: string): {
|
|
45
32
|
readonly root: string;
|
package/dist/project-identity.js
CHANGED
|
@@ -87,10 +87,6 @@ function canonicalTaskRoot(taskRoot) {
|
|
|
87
87
|
p = parent;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
export function resolveProjectIdentity(taskRoot) {
|
|
91
|
-
const located = locateProject(taskRoot);
|
|
92
|
-
return "root" in located ? { root: located.root } : located;
|
|
93
|
-
}
|
|
94
90
|
function locateProject(taskRoot) {
|
|
95
91
|
const root = canonicalTaskRoot(taskRoot);
|
|
96
92
|
if (root === "unreadable")
|
|
@@ -26,7 +26,7 @@ const TASK_BODY_DECLARED_KEYS = [
|
|
|
26
26
|
"excludeAllTools", "excludeTools", "fileHistory",
|
|
27
27
|
"finalVerification", "forwardSubagentEvents", "images", "inheritEnv", "interactiveTools", "jobId", "limits", "maxCostUsd",
|
|
28
28
|
"maxTokens", "mcpServers", "memory", "memoryCapture", "memoryWrite", "model", "objective", "oneShot", "outputRetries", "outputStyle",
|
|
29
|
-
"outputSchema", "permissionMode", "projectId", "projectMemory", "
|
|
29
|
+
"outputSchema", "permissionMode", "projectId", "projectMemory", "promptLean", "reasoningEffort", "requireExistingSession",
|
|
30
30
|
"resilience", "restoreFiles", "resumeAt", "resumeAtMode", "retainBackgroundProcesses", "retainSubagentSessions",
|
|
31
31
|
"rewindFiles", "rewindFilesTo", "sandboxImageProfile", "scenario", "scratchpadDir", "selfOrchestration",
|
|
32
32
|
"sessionId", "settings", "skills", "suggestNextPrompts", "systemPrompt", "taskId", "toolMaterializeStrategy",
|
|
@@ -118,7 +118,36 @@ export declare const INHERIT_ENV_WORDS: readonly ["all", "scrub"];
|
|
|
118
118
|
export type TaskInheritEnv = (typeof INHERIT_ENV_WORDS)[number];
|
|
119
119
|
/** 词表外的拒句(wire 可见;点名两词与各自的意思 —— 拿错的人要在同一条回执里读到该发什么)。 */
|
|
120
120
|
export declare const INHERIT_ENV_VALUE_MESSAGE: string;
|
|
121
|
-
/**
|
|
122
|
-
|
|
121
|
+
/**
|
|
122
|
+
* `inheritEnv` 的 `request.field_invalid` 400 的机读 `reason`([ref];闭集,**一种拒因一个词**,读者穷举读)—— 拒体另带 `field: "inheritEnv"` 与它,
|
|
123
|
+
* 壳靠这两位认「这条 400 真是 `inheritEnv` 的」,不猜句子。同一个键的**三只** 400 是一类,词表一张:
|
|
124
|
+
* · `unknown_word` —— 值形:是字符串,但不在受理词表(`"ALL"` · `"everything"` · `""`);
|
|
125
|
+
* · `not_a_string` —— 值形:根本不是字符串(名单形 `string[]` · 布尔 · 数字 · `null` · 对象);
|
|
126
|
+
* · `lane_not_host` —— `"all"` 落在非 host 车道(只有 host 工厂消费这一位,别的车道没有消费点);
|
|
127
|
+
* · `no_authorizer_session` —— `"all"` 而部署不接 authorizer(绑定按会话键控,没有会话就没有地方兑现)。
|
|
128
|
+
* 前两词的判官是 {@link inheritEnvFieldIssue}(只看体);后两词的判官在 `boot/resolve-spec.ts`(要读部署事实,两腿同过)。
|
|
129
|
+
* 不在这组的:`422 request.host_posture_refused`(托管部署不兑现 `"all"`)—— 那不是这个键的值写错,而是部署姿态拒,码与写容纳面那条腿共用,按 `errorCode` 认(契约 §18)。
|
|
130
|
+
* 加一种拒因 ⇒ 这里加一个词(并在判官处给它一个分支);词与因一一对应,没有一因两词、也没有一词两因。
|
|
131
|
+
* 词的铸点只有 {@link inheritEnvFacts} 一处:受理门与 resolveSpec 只经它出机读位,不手拼 `field` / `reason`。
|
|
132
|
+
*/
|
|
133
|
+
export declare const INHERIT_ENV_REFUSAL_REASONS: readonly ["unknown_word", "not_a_string", "lane_not_host", "no_authorizer_session"];
|
|
134
|
+
export type InheritEnvRefusalReason = (typeof INHERIT_ENV_REFUSAL_REASONS)[number];
|
|
135
|
+
/** 拒体上的机读位(加性键:直接当 `request.field_invalid` 的附加键用;型别名而不是接口 —— 要能直接当 `Record<string, unknown>` 用)。 */
|
|
136
|
+
export type InheritEnvFacts = {
|
|
137
|
+
readonly field: "inheritEnv";
|
|
138
|
+
readonly reason: InheritEnvRefusalReason;
|
|
139
|
+
};
|
|
140
|
+
/** `inheritEnv` 机读位的**唯一铸点**:`field` 恒为键名,`reason` 是 {@link INHERIT_ENV_REFUSAL_REASONS} 里的词。 */
|
|
141
|
+
export declare function inheritEnvFacts(reason: InheritEnvRefusalReason): InheritEnvFacts;
|
|
142
|
+
/** 一次值形裁决的产物:wire 句 + 机读位。 */
|
|
143
|
+
export interface InheritEnvFieldIssue {
|
|
144
|
+
readonly message: string;
|
|
145
|
+
readonly facts: InheritEnvFacts;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* `inheritEnv` 在场且不在词表里 ⇒ 拒(句 + 机读位);缺席或合法 ⇒ `null`。**两腿(fresh admission / resume 重放)共用这一只**,判据与句子在这一处,机读位经 {@link inheritEnvFacts}。
|
|
149
|
+
* 句子对两种坏值形是同一句(点名两词与「名单不是请求值」);`reason` 区分它们。
|
|
150
|
+
*/
|
|
151
|
+
export declare function inheritEnvFieldIssue(raw: unknown): InheritEnvFieldIssue | null;
|
|
123
152
|
export {};
|
|
124
153
|
//# sourceMappingURL=request-value-closure.d.ts.map
|
|
@@ -37,12 +37,18 @@ export const INHERIT_ENV_WORDS = ["all", "scrub"];
|
|
|
37
37
|
export const INHERIT_ENV_VALUE_MESSAGE = `inheritEnv must be one of ${INHERIT_ENV_WORDS.map((w) => JSON.stringify(w)).join(" | ")} when present ` +
|
|
38
38
|
`("all" = the model-driven host shell inherits this machine's whole environment except this deployment's own credentials (its configuration directory's secret-typed names), honored only on a single-user host-lane deployment; ` +
|
|
39
39
|
`"scrub" = the default scrub of credential-shaped variables, accepted on every lane; absent = "scrub") — a name list is not a request value`;
|
|
40
|
+
export const INHERIT_ENV_REFUSAL_REASONS = ["unknown_word", "not_a_string", "lane_not_host", "no_authorizer_session"];
|
|
41
|
+
export function inheritEnvFacts(reason) {
|
|
42
|
+
return { field: "inheritEnv", reason };
|
|
43
|
+
}
|
|
40
44
|
export function inheritEnvFieldIssue(raw) {
|
|
41
45
|
if (raw === null || raw === undefined || typeof raw !== "object" || Array.isArray(raw))
|
|
42
46
|
return null;
|
|
43
47
|
const value = raw.inheritEnv;
|
|
44
48
|
if (value === undefined)
|
|
45
49
|
return null;
|
|
46
|
-
|
|
50
|
+
if (INHERIT_ENV_WORDS.includes(value))
|
|
51
|
+
return null;
|
|
52
|
+
return { message: INHERIT_ENV_VALUE_MESSAGE, facts: inheritEnvFacts(typeof value === "string" ? "unknown_word" : "not_a_string") };
|
|
47
53
|
}
|
|
48
54
|
//# sourceMappingURL=request-value-closure.js.map
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* (拒面按 ③ 的方向分),拒句点名有界({@link MAX_NAMED_INERT_ENTRIES} 条 + 计数),清单先过条数帽({@link inertToolListEntryOf})。
|
|
27
27
|
* **真未知名**(拼写合法、没有近似也没有退役对应 —— 懒挂载的合法形,例如一台之后才连上的 MCP 服务器的工具)不是读成空:原样保留、运维行告知一次,不拒。
|
|
28
28
|
* 选择器读一条条目 = 引擎 `judgeToolNameList` 的读法({@link selectorEntryName}):先取工具名那一段再只判名字(限制侧 `Tool(content)` ⇒ 整只工具,内容里写什么都不读;放行侧内容形引擎告「什么也不授」,受理口不拒);
|
|
29
|
-
* `*`
|
|
29
|
+
* `*` 在放行侧是「本层不设名单」、在限制侧是整名 glob(引擎文法 5,7.137.0 起;此前读成空、受理口拒);限制侧整个协议的名字 `mcp__*` / `mcp__*__*` / `a2a__*` 合法 —— 那是引擎条目读法的读数(core 7.55.0 [ref]:
|
|
30
30
|
* `compileAllowList(…, "deny", 名册)` 把它们读成这一协议的每一只工具),本仓不另写豁免。
|
|
31
31
|
* ⑤ **机读位**:拒体的码与句子是第一处命中的清单的(句子冻结),体另带这一遍判下来的**全部**读成空的条目(`entry-problems.ts` 的 `detail.problems`,{@link inertToolListEntryOf} 铸);
|
|
32
32
|
* 放行侧选择器清单里受理口没拒、却什么也不放的条目随受理应答的 `warnings` 交回({@link allowSelectorWarningsOf})—— 两处读同一次条目读法({@link selectorReadings}),不另判。
|
|
@@ -55,7 +55,8 @@ export declare function allowLayerEntryCountIssue(field: string, list: readonly
|
|
|
55
55
|
/** 一条引擎读成空的条目(引擎的形:原因词,名字层另带判词 / 1:1 现名;包根不导出这只具名型 ⇒ 从 `compileAllowList` 的返回型取,不手抄)。 */
|
|
56
56
|
export type InertRuleEntry = ReturnType<typeof compileAllowList>["inert"][number];
|
|
57
57
|
/**
|
|
58
|
-
* ③ 引擎读一张**规则条目表**(`behavior` 方向)时读成空的条目(
|
|
58
|
+
* ③ 引擎读一张**规则条目表**(`behavior` 方向)时读成空的条目(引擎文法 5,core 7.56.0:allow 表里名内的 `*` 只在协议名的工具段里读,别处的 `*` 只作废它自己、旁边的条目照读;
|
|
59
|
+
* deny / ask 表里带 `*` 的名是整名 glob,不读空)。条目名过引擎判官,
|
|
59
60
|
* 名册是本仓**唯一**的一张({@link TOOL_NAME_ROSTER},`namespaced-rule-name.ts`:引擎目录 ∪ 本仓自铸的工具名)—— 两个方向、每一处读条目名的地方(请求体的规则表、技能清单、选择器清单、
|
|
60
61
|
* 运维 / 中心的审批名单)传同一张,没有「这一处空名册、那一处带名册」的两种读法。工具名选择器清单另走 {@link inertToolListEntryOf}。
|
|
61
62
|
*/
|
package/dist/rule-entry-list.js
CHANGED
|
@@ -27,9 +27,9 @@ export function inertRuleEntryGuidance(i) {
|
|
|
27
27
|
case "near_miss":
|
|
28
28
|
return `the tool name differs from a mounted tool only by case${write}`;
|
|
29
29
|
case "wildcard_all":
|
|
30
|
-
return "`*`
|
|
30
|
+
return "`*` grants nothing on an allow list (the entries beside it still apply) — name the tools instead; on a deny or ask list `*` is every tool";
|
|
31
31
|
case "namespace_wildcard":
|
|
32
|
-
return "a
|
|
32
|
+
return "an allow list reads a `*` only in a protocol name's tool segment — name the server: mcp__<server> or mcp__<server>__*; on a deny or ask list a `*` in a name is a glob over the whole name (mcp__* is every MCP tool, mcp__git* every tool whose name starts with it)";
|
|
33
33
|
case "content_unsupported":
|
|
34
34
|
return "this tool takes no content form here — name the tool itself, or use Bash(<command>) / Bash(<prefix>:*) for a shell command";
|
|
35
35
|
case "grammar":
|
package/dist/rules-consent.js
CHANGED
|
@@ -5,7 +5,7 @@ import { createLogger } from "./observability/logger.js";
|
|
|
5
5
|
import { ABSOLUTE_HOST_PATH_MAX, hasControlOrBidi } from "@sema-agent/settings-schema";
|
|
6
6
|
import { isDirectWritableRuleBehavior } from "./permission-rule-vocab.js";
|
|
7
7
|
import { hasBidiControls } from "./text-bidi.js";
|
|
8
|
-
import { confirmRuleApproval, RULE_BEHAVIORS, parseRuleText, ruleReachesProgramRun,
|
|
8
|
+
import { confirmRuleApproval, RULE_BEHAVIORS, parseRuleText, ruleReachesProgramRun, precheckEditedRuleText, prepareCardApproval, prepareCcImport, redeemRuleBatch, redeemRuleTicket, addPersistedRule, removePersistedRule, isValidDurableScope, effectiveOrThrow, readRowBehavior, readRuleOwner, } from "@sema-agent/core";
|
|
9
9
|
import { buildRulePayloadHash } from "./plugins/permission-rule-store-sql.js";
|
|
10
10
|
export const RULE_IMPORT_TICKET_TTL_MS = 10 * 60_000;
|
|
11
11
|
export const RULE_IMPORT_RETRY_AFTER_SEC = 2;
|
|
@@ -70,21 +70,24 @@ export function sameWireRuleIdentity(row, identity) {
|
|
|
70
70
|
function storeForBucket(provider, ref) {
|
|
71
71
|
if (typeof ref === "string")
|
|
72
72
|
return provider.forPrincipal(ref);
|
|
73
|
-
|
|
73
|
+
const owner = readRuleOwner(ref);
|
|
74
|
+
if (owner === undefined)
|
|
75
|
+
throw new Error("unrecognised permission-rule bucket reference (not a plain owner record, an unknown kind, or a principal that is no principal name) — refusing to guess which bucket it names");
|
|
76
|
+
switch (owner.kind) {
|
|
74
77
|
case "principal":
|
|
75
|
-
return provider.forPrincipal(
|
|
78
|
+
return provider.forPrincipal(owner.principal);
|
|
76
79
|
case "local-owner":
|
|
77
80
|
if (provider.forLocalOwner === undefined) {
|
|
78
81
|
throw new Error("this provider has no local-owner bucket (forLocalOwner is not implemented) — a local-owner rule cannot be listed or removed through it");
|
|
79
82
|
}
|
|
80
83
|
return provider.forLocalOwner();
|
|
81
84
|
default: {
|
|
82
|
-
const unknown =
|
|
85
|
+
const unknown = owner;
|
|
83
86
|
throw new Error(`unrecognised permission-rule bucket reference (${JSON.stringify(unknown)}) — refusing to guess which bucket it names`);
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
89
|
}
|
|
87
|
-
function
|
|
90
|
+
function isCommandRuleMatch(match) {
|
|
88
91
|
switch (match) {
|
|
89
92
|
case "exact":
|
|
90
93
|
case "prefix":
|
|
@@ -101,6 +104,8 @@ function isSupportedRuleMatch(match) {
|
|
|
101
104
|
case "host":
|
|
102
105
|
case "subdomain":
|
|
103
106
|
return false;
|
|
107
|
+
case "tool":
|
|
108
|
+
return false;
|
|
104
109
|
default: {
|
|
105
110
|
const unknown = match;
|
|
106
111
|
void unknown;
|
|
@@ -202,7 +207,7 @@ function screenLocalImportRow(row) {
|
|
|
202
207
|
const written = parseRuleText(row.rule, row.behavior);
|
|
203
208
|
if ("reject" in written)
|
|
204
209
|
return { reason: "rule_rejected", detail: `${written.reject.code}: ${written.reject.message}` };
|
|
205
|
-
if (
|
|
210
|
+
if (!isCommandRuleMatch(written.rule.match))
|
|
206
211
|
return consistent(written.rule);
|
|
207
212
|
if (written.rule.behavior !== "allow") {
|
|
208
213
|
if (!ruleReachesProgramRun(written.rule, row.command)) {
|
|
@@ -351,7 +356,7 @@ export function createRuleConsentLane(stores, opts) {
|
|
|
351
356
|
if ("reject" in canonical) {
|
|
352
357
|
return { ok: false, reason: "edit-rejected", detail: `the canonical spelling the engine minted does not re-parse: ${canonical.reject.message}` };
|
|
353
358
|
}
|
|
354
|
-
if (!
|
|
359
|
+
if (!isCommandRuleMatch(canonical.rule.match)) {
|
|
355
360
|
return { ok: false, reason: "edit-rejected", detail: `the edited rule resolves to an unsupported match form (${String(canonical.rule.match)})` };
|
|
356
361
|
}
|
|
357
362
|
ticket = minted.ticket;
|
package/dist/run-local.d.ts
CHANGED
|
@@ -174,8 +174,8 @@ type NoTtyRemedy = NoTtySpokenRemedy | "terminal_only";
|
|
|
174
174
|
* · `shell_floor`:shell 地板被抬到 always —— `AUTONOMY=ask`(`autonomyOverrides`)与 `MANUAL_MODE_SHELL_GATE=always`,真 Runner 读数两者的类集都是 `[shell_floor]`(**不是** `operator_forced`):
|
|
175
175
|
* 单独一句,不与 `operator_forced` 的来源混在一起 —— 混说会把 `APPROVAL_NEVER_AUTO` 的问指到一定没设的 `AUTONOMY`;
|
|
176
176
|
* · 其余:引擎自己的问(写门 / 形状层 / 写保护 / 探针 / 钩子 / 组织规则 / 引擎的守卫 / 工具标记 …)没有一只本部署旋钮能放行 —— 只说去终端答。
|
|
177
|
-
* 不借 core 的 `headlessApprovalRemedy`:那一句是给**库的调用方**的出路(「wire an approver (`onAsk`)
|
|
178
|
-
*
|
|
177
|
+
* 不借 core 的 `headlessApprovalRemedy`:那一句是给**库的调用方**的出路(「wire an approver (`onAsk`)」;core 7.56.0 [ref] 起它不再教模式放行,
|
|
178
|
+
* 那一条出路只作数据骑在通告的 `detail.remedies` 上),而本腿的席**已经接好**(缺的是终端),也没有任何命令行旗给 `permissionMode` —— 照搬会把运维指向一个不存在的旋钮。
|
|
179
179
|
*
|
|
180
180
|
* `autoBudgetReleases`:`APPROVAL_AUTO_BUDGET` 能放行这类问吗(读 `createDurableAskPolicy` 的预算臂:只放行**没进 `APPROVAL_NEVER_AUTO`、耐久资源没耗尽**的
|
|
181
181
|
* `APPROVAL_REQUIRE` 命中,换成一句带理由的 allow)。按 `classes` **整体**读:集里每一类都放得行才建议预算 —— 折叠了别的类(`operator_forced` 等)说明另一层的问仍在,
|
package/dist/run-local.js
CHANGED
|
@@ -45,14 +45,16 @@ import { createMemoryEngineIncidentSink } from "./memory-incident-sink.js";
|
|
|
45
45
|
import { fileMemoryEngineRoot, memoryEngineBackendFor, memorySpecForRequest } from "./memory-scope.js";
|
|
46
46
|
import { createMemoryProjectLayers } from "./memory-project-layer.js";
|
|
47
47
|
import { assertProjectLayerOwnable } from "./project-identity.js";
|
|
48
|
+
import { declaredCredential } from "./model-route-gap.js";
|
|
48
49
|
import { judgeServedModelRoute } from "./model-route-endpoint.js";
|
|
49
50
|
import { createMemorySyncRunner, createMemorySyncTransport } from "./memory-sync-client.js";
|
|
50
51
|
import { buildPricing, cappedCeiling, createTracer } from "./budget.js";
|
|
51
52
|
import { createSharedRunnerDeps } from "./boot/runner-deps.js";
|
|
53
|
+
import { createPeerDesk } from "./peer-seat.js";
|
|
52
54
|
import { createGovernanceSeams } from "./boot/governance-seams.js";
|
|
53
55
|
import { assertRetentionLaneWirable } from "./boot/retention-lane.js";
|
|
54
56
|
import { createOrgMemoryAdmissionWiring } from "./boot/org-memory.js";
|
|
55
|
-
import {
|
|
57
|
+
import { assembleDeploymentMods } from "./boot/deployment-mods.js";
|
|
56
58
|
import { createKeyResolver } from "./key-resolver.js";
|
|
57
59
|
import { createLogger } from "./observability/logger.js";
|
|
58
60
|
import { fatalExit } from "./boot/fatal-exit.js";
|
|
@@ -121,7 +123,7 @@ export function missingGatewayRequirements(config) {
|
|
|
121
123
|
if (config.gatewayBaseUrl === undefined)
|
|
122
124
|
return missing;
|
|
123
125
|
const perModelEnvs = Object.values(config.modelApiKeyEnv ?? {});
|
|
124
|
-
const haveGatewayKey =
|
|
126
|
+
const haveGatewayKey = declaredCredential(config.gatewayApiKey) !== undefined;
|
|
125
127
|
const catalogModelNames = new Set(Object.values(config.models ?? {}).map((m) => m.name));
|
|
126
128
|
const allModelsHaveOwnKey = catalogModelNames.size > 0 &&
|
|
127
129
|
[...catalogModelNames].every((n) => {
|
|
@@ -164,6 +166,7 @@ export const NO_TTY_ASK_CLASS_ROW = {
|
|
|
164
166
|
shell_floor: { remedy: "shell_gate", autoBudgetReleases: false },
|
|
165
167
|
target_unresolved: { remedy: "terminal_only", autoBudgetReleases: false },
|
|
166
168
|
probe: { remedy: "terminal_only", autoBudgetReleases: false },
|
|
169
|
+
write_protection_on_disk: { remedy: "terminal_only", autoBudgetReleases: false },
|
|
167
170
|
write_protection: { remedy: "terminal_only", autoBudgetReleases: false },
|
|
168
171
|
tool_marks_mcp: { remedy: "terminal_only", autoBudgetReleases: false },
|
|
169
172
|
tool_marks_a2a: { remedy: "terminal_only", autoBudgetReleases: false },
|
|
@@ -363,6 +366,8 @@ export async function runLocal(argv, deps = {}) {
|
|
|
363
366
|
return 2;
|
|
364
367
|
}
|
|
365
368
|
const configProvider = createConfigProvider(providerInput);
|
|
369
|
+
const peerDesk = createPeerDesk({ log: logger });
|
|
370
|
+
const rosterLease = peerDesk.lease("roster");
|
|
366
371
|
let effective;
|
|
367
372
|
let candidatePrompts;
|
|
368
373
|
let applying = false;
|
|
@@ -387,9 +392,9 @@ export async function runLocal(argv, deps = {}) {
|
|
|
387
392
|
effective = r.effective;
|
|
388
393
|
candidatePrompts = verdict.prompts;
|
|
389
394
|
if (effective?.mcp)
|
|
390
|
-
config.mcpServers = resolveMcpServers(effective.mcp, logger);
|
|
395
|
+
config.mcpServers = resolveMcpServers(effective.mcp, peerDesk, rosterLease, logger);
|
|
391
396
|
if (effective?.a2a)
|
|
392
|
-
config.a2aPeers = resolveA2aPeers(effective.a2a, logger);
|
|
397
|
+
config.a2aPeers = resolveA2aPeers(effective.a2a, peerDesk, rosterLease, logger);
|
|
393
398
|
applyCenterReadFace(config, r.effective, logger, { phase: "boot" });
|
|
394
399
|
logger.info("config_loaded", { source: configProvider.kind, version: r.effective.version });
|
|
395
400
|
}
|
|
@@ -576,9 +581,9 @@ export async function runLocal(argv, deps = {}) {
|
|
|
576
581
|
{ name: "checkpointStore", store: fileBackend.checkpointStore },
|
|
577
582
|
{ name: "toolResultStore", store: fileBackend.toolResultStore },
|
|
578
583
|
],
|
|
584
|
+
retentionExecutor: null,
|
|
579
585
|
});
|
|
580
|
-
const deploymentMods =
|
|
581
|
-
await assertDeploymentModsAdmitted(deploymentMods);
|
|
586
|
+
const { registrations: deploymentMods } = await assembleDeploymentMods({ metrics, brandIdentity: true, declaration: config.modsDeclaration, logger });
|
|
582
587
|
const sharedRunnerDeps = createSharedRunnerDeps({
|
|
583
588
|
metrics,
|
|
584
589
|
config,
|
|
@@ -603,6 +608,7 @@ export async function runLocal(argv, deps = {}) {
|
|
|
603
608
|
orgMemoryAdmission,
|
|
604
609
|
sharedMemoryStores: undefined,
|
|
605
610
|
mcpRevocations: undefined,
|
|
611
|
+
peerDesk,
|
|
606
612
|
});
|
|
607
613
|
const runnerDeps = {
|
|
608
614
|
...sharedRunnerDeps,
|
package/dist/runs.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { type ApprovalFrameFamily, type ToolApprovalCoordinator } from "./tool-a
|
|
|
11
11
|
import { type FleetRunPublisher } from "./fleet/fleet-bus.js";
|
|
12
12
|
import { type WorkflowCompletionInbox } from "./orchestration/workflow-completion-inbox.js";
|
|
13
13
|
import type { RunAcceptance } from "./run-acceptance.js";
|
|
14
|
+
import type { SessionWorkspaceRecorder } from "./session-workspace.js";
|
|
14
15
|
import type { VerifyRoundsSpec } from "./http/verify-rounds.js";
|
|
15
16
|
import type { UserInputLedger } from "./user-input-ledger.js";
|
|
16
17
|
/**
|
|
@@ -374,7 +375,12 @@ userInputLedger?: UserInputLedger,
|
|
|
374
375
|
* 这次提交的受理座(`src/run-acceptance.ts`):标题器只在引擎受理之后起。普通流形逐帧喂;只回结果的 verify / cascade 形(以及终局写口的
|
|
375
376
|
* 重试腿)终局落行之后收尾一次。缺席 ⇒ 不起标题(起标题此前由路由层在建行时做)。
|
|
376
377
|
*/
|
|
377
|
-
acceptance?: RunAcceptance
|
|
378
|
+
acceptance?: RunAcceptance,
|
|
379
|
+
/**
|
|
380
|
+
* 会话行的位置与项目那一格的记录座(`session-workspace.ts`;唯一写者):普通流形逐帧喂(这条腿自己的 `workspace_changed` 排一次写),
|
|
381
|
+
* `done` 时等写落定再落终局。只回结果的 verify / cascade 形宿主手里没有流 ⇒ 不记。缺席 ⇒ 不记行(与本参数存在之前逐字相同)。
|
|
382
|
+
*/
|
|
383
|
+
workspaceRecorder?: SessionWorkspaceRecorder): Promise<void>;
|
|
378
384
|
/** How often a running instance refreshes its run's updated_at (liveness, independent of events).
|
|
379
385
|
* Must stay strictly below `runStaleSec` (asserted at startup AND on every hot config candidate) or the
|
|
380
386
|
* reaper would race live runs. [ref]:数值的单源是 `config-invariants.ts`(那条不变量的属主),两个消费面
|
package/dist/runs.js
CHANGED
|
@@ -7,6 +7,7 @@ import { isSessionErrorCode, sessionErrorHttp } from "./session-error-wire.js";
|
|
|
7
7
|
import { redactErrorMessage } from "./observability/run-terminal.js";
|
|
8
8
|
import { withPrincipal } from "./observability/principal-context.js";
|
|
9
9
|
import { withModelReachScope } from "./model-reach-scope.js";
|
|
10
|
+
import { runSkillsOf } from "./capabilities/skills.js";
|
|
10
11
|
import { createInstructionSelectionLeg } from "./instruction-selection.js";
|
|
11
12
|
import { redactSecrets } from "./trace/redact.js";
|
|
12
13
|
import { taskNotificationEventData, appendModelUsageDelta, appendPromptManifest, attachModelUsage } from "./trace/project.js";
|
|
@@ -83,6 +84,10 @@ const PREPARE_REFUSAL_HTTP_STATUS = {
|
|
|
83
84
|
"config.legacy_tool_name": 400,
|
|
84
85
|
"config.memory_capture_unsupported": 409,
|
|
85
86
|
"prompt.assembled_role_refused": 400,
|
|
87
|
+
"config.project_id_invalid": 400,
|
|
88
|
+
"config.project_identity_mismatch": 409,
|
|
89
|
+
"config.memory_project_marker": 409,
|
|
90
|
+
"config.memory_project_marker_nested": 409,
|
|
86
91
|
};
|
|
87
92
|
export function resumeAtHttpStatus(result) {
|
|
88
93
|
const code = failureCodeOf(result.terminal);
|
|
@@ -252,7 +257,7 @@ export async function graftParkToolCallId(result, cs) {
|
|
|
252
257
|
const id = await parkToolCallId(result, cs);
|
|
253
258
|
return id === undefined ? result : { ...result, toolCallId: id };
|
|
254
259
|
}
|
|
255
|
-
export async function runInBackground(runner, spec, runStore, taskId, metrics, principal, verify, cascade, instrumentDegenerate, planCacheProbe, persistThinking = false, inflight, preemptable, steerable, modelUsage, elicitation, elicitOwner, captureTurnAnchor, fleetPublisher, captureUserMessageAnchor, question, workflowCompletionInbox, subagentSteer, completionDiagLog, sendUserFile, promptManifests, approval, parkCheckpointReader, pendingEngineNotices, trustedInternals, userInputLedger, acceptance) {
|
|
260
|
+
export async function runInBackground(runner, spec, runStore, taskId, metrics, principal, verify, cascade, instrumentDegenerate, planCacheProbe, persistThinking = false, inflight, preemptable, steerable, modelUsage, elicitation, elicitOwner, captureTurnAnchor, fleetPublisher, captureUserMessageAnchor, question, workflowCompletionInbox, subagentSteer, completionDiagLog, sendUserFile, promptManifests, approval, parkCheckpointReader, pendingEngineNotices, trustedInternals, userInputLedger, acceptance, workspaceRecorder) {
|
|
256
261
|
const startedAt = Date.now();
|
|
257
262
|
metrics?.addGauge("runs_active", 1);
|
|
258
263
|
fleetPublisher?.onStart();
|
|
@@ -330,7 +335,7 @@ export async function runInBackground(runner, spec, runStore, taskId, metrics, p
|
|
|
330
335
|
metrics?.inc("tasks_total", { status: "needs_review" });
|
|
331
336
|
};
|
|
332
337
|
const instructionLeg = createInstructionSelectionLeg();
|
|
333
|
-
const sink = createLedgerSink({ appendEvent: (seq, type, data) => runStore.appendEvent(taskId, seq, type, data), persistThinking, notifiedKeys, onActivity: (kind, statusData) => recordTurnActivity(taskId, kind, statusData),
|
|
338
|
+
const sink = createLedgerSink({ appendEvent: (seq, type, data) => runStore.appendEvent(taskId, seq, type, data), persistThinking, notifiedKeys, onActivity: (kind, statusData) => recordTurnActivity(taskId, kind, statusData), legSections: () => ({ instructions: instructionLeg.segment(), skills: runSkillsOf(spec) }) });
|
|
334
339
|
const append = (type, data) => sink.append(type, data);
|
|
335
340
|
const flush = () => sink.flush();
|
|
336
341
|
const flushModelUsage = () => appendModelUsageDelta(append, modelUsage, taskId);
|
|
@@ -452,6 +457,7 @@ export async function runInBackground(runner, spec, runStore, taskId, metrics, p
|
|
|
452
457
|
fleetPublisher?.onEvent(ev);
|
|
453
458
|
await userInputLedger?.observeLegEvent(stream, ev);
|
|
454
459
|
acceptance?.observe(ev);
|
|
460
|
+
await workspaceRecorder?.observe(ev);
|
|
455
461
|
await flushPromptManifest();
|
|
456
462
|
switch (ev.type) {
|
|
457
463
|
case "text_delta":
|
|
@@ -65,9 +65,9 @@ export declare function validateCommandRules(rules: CommandRule[]): string[];
|
|
|
65
65
|
* (deny-wins) by {@link applyRuntimeGovernance}, so it is tighten-only.
|
|
66
66
|
*
|
|
67
67
|
* 🔴 **[ref]:返回叶,不在这里折**(改名自 `compileCommandPolicy`,修前返回 blocklist 形里 `combinePolicies(coarseDeny, askList)` 的
|
|
68
|
-
* 一只折叠)。复合命令(`a && b`、管道、`;`)上两只叶都按「解析不了 ⇒ 问」问 ⇒
|
|
69
|
-
*
|
|
70
|
-
* {@link applyRuntimeGovernance} 逐叶盖位、折**一次**:本函数不知道出身这件事,治理层只有一个折叠点。 (Assumes commands are pre-validated by
|
|
68
|
+
* 一只折叠)。复合命令(`a && b`、管道、`;`)上两只叶都按「解析不了 ⇒ 问」问 ⇒ 那只折叠把落选者的类记进引擎的认证记录(core 7.56.0:
|
|
69
|
+
* `attestation.foldedClasses`;7.39.0–7.48.x 是对象身份担保的 `foldedAskClasses` 成员,副本被按名拒;7.49.0 [ref] 起带引擎记录的副本照收),而治理层要给每只 ask 盖部署出身。
|
|
70
|
+
* 叶交出去,由 {@link applyRuntimeGovernance} 逐叶盖位、折**一次**:本函数不知道出身这件事,治理层只有一个折叠点。 (Assumes commands are pre-validated by
|
|
71
71
|
* {@link validateCommandRules}; an un-matchable command here is simply inert, never a parse error.)
|
|
72
72
|
*
|
|
73
73
|
* 🔴 **[ref]:词表外的 `decision` 折 `deny`,不折 `ask`。** {@link validateCommandRules} 的头注写下的那条
|
|
@@ -271,8 +271,8 @@ export declare function governanceOriginOf(gate: {
|
|
|
271
271
|
*
|
|
272
272
|
* 🔴 **[ref](core [ref] 7.39.0)—— 治理层只有一个折叠点**:两种输入都交**叶**(`compileCommandPolicyLayers` 的那几只、
|
|
273
273
|
* `sensitivePathLayers` 的那几只),本函数对每一片叶各盖一次部署出身(`createDeploymentAuthoredPolicy`),再交 core
|
|
274
|
-
* `combinePolicies`
|
|
275
|
-
* `foldedAskClasses` 时交给 core
|
|
274
|
+
* `combinePolicies` 折一次;折叠是最外层,输出经标记观察器原物交回。修前是「先折、再在折叠输出上展开盖位」——7.39.0–7.48.x 上折叠带出
|
|
275
|
+
* `foldedAskClasses` 时交给 core 的是副本,被按名拒(工具不跑、无卡);core 7.56.0 起那一成员退役、落选者的类骑在 `attestation` 记录上。
|
|
276
276
|
*/
|
|
277
277
|
export declare function applyRuntimeGovernance(base: TaskSpec, governance: {
|
|
278
278
|
autonomy?: Autonomy;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** Why an entry is withdrawn — the server's own words (closed set; the vault's per-origin and whole-answer words join it with the plane's renewal). */
|
|
2
|
+
export type SandboxLeaseWithdrawReason = "center_unavailable" | "insecure_transport";
|
|
3
|
+
/** The sentence kinds an entry carries: a withdrawal reason, or the `ready` entry's "the git host refused the credential". */
|
|
4
|
+
export type SandboxLeaseSentenceKind = SandboxLeaseWithdrawReason | "credential_rejected";
|
|
5
|
+
/** What git shows for an entry (single line, no credential, names the origin and the way out). */
|
|
6
|
+
export declare function sandboxLeaseSentence(kind: SandboxLeaseSentenceKind, origin: string): string;
|
|
7
|
+
/** One origin's lease as the server decides it (the writer supplies `i`, `origin`, `leaseId` and the sentences). */
|
|
8
|
+
export type SandboxLeaseEntryInput = {
|
|
9
|
+
readonly state: "ready";
|
|
10
|
+
readonly username: string;
|
|
11
|
+
readonly secret: string;
|
|
12
|
+
readonly credentialId: string;
|
|
13
|
+
readonly version: number;
|
|
14
|
+
readonly ttlMs: number;
|
|
15
|
+
} | {
|
|
16
|
+
readonly state: "withdrawn";
|
|
17
|
+
readonly reason: SandboxLeaseWithdrawReason;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The lease file text for a pod whose origin table is `origins` (one input per origin, same order). Refused (never sent) when the broker
|
|
21
|
+
* would refuse it: an input count that is not the table's, a `ready` input for an http origin, `ttlMs` outside (0, 300 000], a malformed
|
|
22
|
+
* value. The refusal names the entry and the rule, never a value.
|
|
23
|
+
*/
|
|
24
|
+
export declare function buildSandboxLeaseFile(origins: readonly string[], entries: readonly SandboxLeaseEntryInput[], mintLeaseId?: () => string): {
|
|
25
|
+
ok: true;
|
|
26
|
+
text: string;
|
|
27
|
+
} | {
|
|
28
|
+
ok: false;
|
|
29
|
+
problem: string;
|
|
30
|
+
};
|
|
31
|
+
/** The lease a pod starts with, before the first answer from the vault: every entry withdrawn (https ⇒ `center_unavailable`, http ⇒ `insecure_transport`). */
|
|
32
|
+
export declare function placeholderLeaseEntries(origins: readonly string[]): SandboxLeaseEntryInput[];
|
|
33
|
+
/**
|
|
34
|
+
* The lease time of one vault answer: `min(cacheUntil, expiresAt ?? cacheUntil) − answeredAt − rttMs`, capped at the broker's ceiling,
|
|
35
|
+
* at least 1; `undefined` when that is ≤ 0 or any reading is not a finite number (the entry is then written `withdrawn`). The three times are
|
|
36
|
+
* the vault's own clock; `rttMs` is this server's monotonic measure of the request it sent and the answer it got.
|
|
37
|
+
*/
|
|
38
|
+
export declare function sandboxLeaseTtlMs(answer: {
|
|
39
|
+
readonly answeredAt: number;
|
|
40
|
+
readonly cacheUntil: number;
|
|
41
|
+
readonly expiresAt: number | null;
|
|
42
|
+
}, rttMs: number): number | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* The agent container's git routes (non-secret env): one `url.<broker route>.insteadOf = <origin>/` triplet per origin, in the pod's
|
|
45
|
+
* origin-table order — git then sends `<origin>/<owner>/<repo>/…` to the broker's loopback route `/o/<i>/…` (http origins too: they are
|
|
46
|
+
* forwarded without a credential and answered with their sentence).
|
|
47
|
+
*/
|
|
48
|
+
export declare function sandboxGitRouteEnv(origins: readonly string[]): Record<string, string>;
|
|
49
|
+
//# sourceMappingURL=sandbox-git-lease.d.ts.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { BROKER_HOST, BROKER_PORT } from "./broker/constants.js";
|
|
3
|
+
import { LEASE_TTL_MAX_MS, parseLeaseFile, serializeLeaseFile } from "./broker/lease-file.js";
|
|
4
|
+
export function sandboxLeaseSentence(kind, origin) {
|
|
5
|
+
switch (kind) {
|
|
6
|
+
case "center_unavailable":
|
|
7
|
+
return `your git credential for ${origin} is not available right now (the console could not be reached); retry shortly, and do not paste a token into the conversation`;
|
|
8
|
+
case "insecure_transport":
|
|
9
|
+
return `${origin} is served over plain http, so member credentials are never sent to it; ask the operator to serve it over https`;
|
|
10
|
+
case "credential_rejected":
|
|
11
|
+
return `${origin} rejected your git credential; reconnect it in the console, then retry`;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function buildSandboxLeaseFile(origins, entries, mintLeaseId = () => `l_${randomUUID()}`) {
|
|
15
|
+
if (entries.length !== origins.length)
|
|
16
|
+
return { ok: false, problem: `the lease has ${entries.length} entries for a pod routed to ${origins.length} origins` };
|
|
17
|
+
const file = {
|
|
18
|
+
v: 1,
|
|
19
|
+
origins: entries.map((e, i) => {
|
|
20
|
+
const origin = origins[i];
|
|
21
|
+
return e.state === "ready"
|
|
22
|
+
? {
|
|
23
|
+
i,
|
|
24
|
+
origin,
|
|
25
|
+
state: "ready",
|
|
26
|
+
leaseId: mintLeaseId(),
|
|
27
|
+
ttlMs: e.ttlMs,
|
|
28
|
+
username: e.username,
|
|
29
|
+
secret: e.secret,
|
|
30
|
+
credentialId: e.credentialId,
|
|
31
|
+
version: e.version,
|
|
32
|
+
unusableMessage: sandboxLeaseSentence("center_unavailable", origin),
|
|
33
|
+
rejectedMessage: sandboxLeaseSentence("credential_rejected", origin),
|
|
34
|
+
}
|
|
35
|
+
: { i, origin, state: "withdrawn", reason: e.reason, unusableMessage: sandboxLeaseSentence(e.reason, origin) };
|
|
36
|
+
}),
|
|
37
|
+
};
|
|
38
|
+
const text = serializeLeaseFile(file);
|
|
39
|
+
const judged = parseLeaseFile(text);
|
|
40
|
+
return judged.ok ? { ok: true, text } : { ok: false, problem: judged.problem };
|
|
41
|
+
}
|
|
42
|
+
export function placeholderLeaseEntries(origins) {
|
|
43
|
+
return origins.map((o) => ({ state: "withdrawn", reason: o.startsWith("https://") ? "center_unavailable" : "insecure_transport" }));
|
|
44
|
+
}
|
|
45
|
+
export function sandboxLeaseTtlMs(answer, rttMs) {
|
|
46
|
+
const until = answer.expiresAt === null ? answer.cacheUntil : Math.min(answer.cacheUntil, answer.expiresAt);
|
|
47
|
+
const ms = until - answer.answeredAt - rttMs;
|
|
48
|
+
if (!Number.isFinite(ms) || ms <= 0)
|
|
49
|
+
return undefined;
|
|
50
|
+
return Math.max(1, Math.min(LEASE_TTL_MAX_MS, Math.floor(ms)));
|
|
51
|
+
}
|
|
52
|
+
export function sandboxGitRouteEnv(origins) {
|
|
53
|
+
const env = { GIT_CONFIG_COUNT: String(origins.length) };
|
|
54
|
+
origins.forEach((origin, i) => {
|
|
55
|
+
env[`GIT_CONFIG_KEY_${i}`] = `url.http://${BROKER_HOST}:${BROKER_PORT}/o/${i}/.insteadOf`;
|
|
56
|
+
env[`GIT_CONFIG_VALUE_${i}`] = `${origin}/`;
|
|
57
|
+
});
|
|
58
|
+
return env;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=sandbox-git-lease.js.map
|