@sema-agent/server 7.149.0 → 7.150.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 +122 -9
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/USAGE.md +39 -15
- package/dist/approval-card.d.ts +1 -1
- package/dist/approval-gate-currency.d.ts +1 -1
- package/dist/audit.d.ts +1 -1
- package/dist/audit.js +2 -2
- package/dist/background-session-reap.d.ts +1 -1
- package/dist/boot/deferred-sandbox-path-env.d.ts +5 -3
- package/dist/boot/deferred-sandbox-path-env.js +1 -2
- package/dist/boot/parked-revive-gate.d.ts +5 -5
- package/dist/boot/parked-revive-gate.js +2 -3
- package/dist/boot/resolve-spec.d.ts +4 -5
- package/dist/boot/resolve-spec.js +61 -25
- package/dist/boot/retention-lane.d.ts +1 -1
- package/dist/boot/session-faces.js +21 -21
- package/dist/boot/stage-03-store-backend.js +2 -2
- package/dist/boot/stage-06-runners.js +1 -2
- package/dist/boot/stage-07-capability-layer.js +1 -1
- package/dist/boot/stage-10-http-server.d.ts +33 -1
- package/dist/boot/stage-10-http-server.js +9 -4
- package/dist/boot/web-admin.d.ts +1 -1
- package/dist/capability-facts.d.ts +65 -56
- package/dist/capability-facts.js +42 -35
- package/dist/config-catalog.js +1 -1
- package/dist/config-types.d.ts +12 -11
- package/dist/deployment-governance.d.ts +7 -28
- package/dist/deployment-governance.js +1 -14
- package/dist/device-ws-hub.d.ts +1 -0
- package/dist/device-ws-hub.js +64 -28
- package/dist/device-ws-protocol.d.ts +20 -6
- package/dist/device-ws-protocol.js +9 -2
- package/dist/engine-identity.d.ts +7 -1
- package/dist/engine-identity.js +5 -0
- package/dist/field-conflict.d.ts +2 -2
- package/dist/fleet/engine-signal.d.ts +14 -1
- package/dist/fleet/engine-signal.js +5 -1
- package/dist/fleet/fleet-reconciler.d.ts +1 -1
- package/dist/fleet/serving-lease.d.ts +18 -3
- package/dist/fleet/serving-lease.js +81 -35
- package/dist/fleet-client.d.ts +13 -11
- package/dist/fleet-client.js +53 -33
- package/dist/history-anchor.js +1 -1
- package/dist/hitl-delivery.d.ts +1 -3
- package/dist/hitl-delivery.js +1 -1
- package/dist/http/active-run-conflict.d.ts +3 -7
- package/dist/http/active-run-conflict.js +2 -2
- package/dist/http/admission.js +2 -2
- package/dist/http/approval-sweeps.js +2 -1
- package/dist/http/caller-trust.d.ts +2 -2
- package/dist/http/caller-trust.js +3 -3
- package/dist/http/checkpoint-ctx.d.ts +18 -63
- package/dist/http/checkpoint-ctx.js +1 -24
- package/dist/http/claim-heartbeat.d.ts +4 -4
- package/dist/http/claim-heartbeat.js +3 -3
- package/dist/http/dispatch.js +2 -2
- package/dist/http/durable-run-leg.js +4 -4
- package/dist/http/owner-access.d.ts +243 -19
- package/dist/http/owner-access.js +184 -5
- package/dist/http/readiness.d.ts +4 -2
- package/dist/http/resume-ctx-read.js +16 -1
- package/dist/http/resume-legs.js +18 -14
- package/dist/http/route-ctx.d.ts +23 -11
- package/dist/http/routes/a2a-serve.js +15 -14
- package/dist/http/routes/approvals-assistant.d.ts +3 -2
- package/dist/http/routes/approvals-assistant.js +8 -9
- package/dist/http/routes/capabilities.js +4 -3
- package/dist/http/routes/config-catalog.d.ts +1 -1
- package/dist/http/routes/mcp-reconnect.js +2 -2
- package/dist/http/routes/memory-origin.d.ts +1 -1
- package/dist/http/routes/notify-wake.js +2 -3
- package/dist/http/routes/projects.d.ts +1 -0
- package/dist/http/routes/projects.js +5 -3
- package/dist/http/routes/retention-ops.d.ts +1 -1
- package/dist/http/routes/run-permission-mode.d.ts +1 -1
- package/dist/http/routes/run-permission-mode.js +2 -2
- package/dist/http/routes/runs.d.ts +1 -1
- package/dist/http/routes/runs.js +23 -30
- package/dist/http/routes/session-memory-sync.js +4 -5
- package/dist/http/routes/session-sync.js +3 -7
- package/dist/http/routes/sessions.d.ts +1 -1
- package/dist/http/routes/sessions.js +18 -44
- package/dist/http/routes/tasks.js +9 -8
- package/dist/http/routes/trace-usage.js +14 -14
- package/dist/http/routes/workflows.d.ts +1 -0
- package/dist/http/routes/workflows.js +20 -38
- package/dist/http/server.d.ts +8 -4
- package/dist/http/server.js +5 -1
- package/dist/http/stored-body-replay.d.ts +3 -24
- package/dist/http/stored-body-replay.js +2 -12
- package/dist/http/submit-ctx.d.ts +1 -2
- package/dist/http/submit-ctx.js +3 -2
- package/dist/http/submit-replay.d.ts +15 -2
- package/dist/http/submit-replay.js +10 -4
- package/dist/http/wire-types.d.ts +6 -3
- package/dist/leader/endpoint.js +9 -8
- package/dist/leg-facts.d.ts +8 -2
- package/dist/leg-facts.js +1 -0
- package/dist/mcp-authorization-face.d.ts +18 -14
- package/dist/mcp-authorization-face.js +3 -2
- package/dist/memory-store-refusal.d.ts +1 -1
- package/dist/observability/corrupt-read-seat.d.ts +1 -1
- package/dist/observability/fail-open.d.ts +5 -5
- package/dist/observability/fail-open.js +5 -5
- package/dist/observability/logger.d.ts +7 -0
- package/dist/observability/logger.js +3 -1
- package/dist/observability/run-terminal.d.ts +1 -1
- package/dist/owner-faces.d.ts +27 -3
- package/dist/owner-faces.js +2 -0
- package/dist/peer-seat.d.ts +1 -1
- package/dist/peer-seat.js +52 -59
- package/dist/plugins/exec-path-law.d.ts +34 -0
- package/dist/plugins/exec-path-law.js +13 -0
- package/dist/plugins/file-run-store.js +1 -1
- package/dist/plugins/local-checkpoint-store.d.ts +4 -1
- package/dist/plugins/local-checkpoint-store.js +3 -0
- package/dist/plugins/memory-run-store.js +1 -1
- package/dist/plugins/one-time-migrations.d.ts +74 -49
- package/dist/plugins/one-time-migrations.js +134 -69
- package/dist/plugins/pg-pool.js +4 -0
- package/dist/plugins/posix-shell-fs.js +4 -2
- package/dist/plugins/remote-env-adb.js +3 -2
- package/dist/plugins/remote-env-device.js +8 -6
- package/dist/plugins/remote-env-e2b.d.ts +3 -1
- package/dist/plugins/remote-env-e2b.js +11 -8
- package/dist/plugins/remote-env-host.d.ts +1 -1
- package/dist/plugins/remote-env-host.js +20 -11
- package/dist/plugins/remote-env-k8s.js +3 -2
- package/dist/plugins/remote-env-local-docker.js +3 -2
- package/dist/plugins/remote-env-ssh.js +4 -3
- package/dist/plugins/remote-shell.d.ts +3 -1
- package/dist/plugins/remote-shell.js +3 -3
- package/dist/plugins/replica-registration.d.ts +35 -0
- package/dist/plugins/replica-registration.js +48 -0
- package/dist/plugins/retention-lane-store-sql.d.ts +1 -1
- package/dist/plugins/run-store-sql.d.ts +1 -1
- package/dist/plugins/run-store-sql.js +2 -2
- package/dist/plugins/scenario-prefix-switch-m42.d.ts +6 -12
- package/dist/plugins/scenario-prefix-switch-m42.js +7 -5
- package/dist/plugins/schema-consistency.d.ts +7 -5
- package/dist/plugins/schema-consistency.js +29 -16
- package/dist/plugins/schema-drift-sentence.js +1 -1
- package/dist/plugins/serving-requirement.d.ts +49 -0
- package/dist/plugins/serving-requirement.js +53 -0
- package/dist/plugins/stop-then-start-sentence.d.ts +42 -3
- package/dist/plugins/stop-then-start-sentence.js +44 -0
- package/dist/plugins/store-backend.d.ts +1 -1
- package/dist/plugins/store-contracts.d.ts +12 -2
- package/dist/plugins/store-contracts.js +3 -0
- package/dist/plugins/tidb-pool.js +4 -0
- package/dist/process-instance.d.ts +3 -0
- package/dist/process-instance.js +7 -0
- package/dist/project-context.d.ts +66 -0
- package/dist/project-context.js +70 -0
- package/dist/question.d.ts +9 -21
- package/dist/question.js +28 -19
- package/dist/run-cancel-card.d.ts +1 -1
- package/dist/run-cancel-card.js +2 -1
- package/dist/security.d.ts +1 -1
- package/dist/session-agent.d.ts +1 -10
- package/dist/session-agent.js +0 -6
- package/dist/session-incarnation.d.ts +18 -4
- package/dist/session-incarnation.js +4 -1
- package/dist/session-notify-door.d.ts +4 -4
- package/dist/session-notify-door.js +5 -6
- package/dist/session-rules-seat.d.ts +4 -3
- package/dist/session-rules-seat.js +3 -11
- package/dist/session-sync.js +3 -3
- package/dist/stores-sql/checkpoint-store-sql.d.ts +21 -2
- package/dist/stores-sql/checkpoint-store-sql.js +106 -18
- package/dist/stores-sql/retention-store-sql.d.ts +1 -1
- package/dist/task-cwd.d.ts +4 -3
- package/dist/task-settings.d.ts +13 -0
- package/dist/task-settings.js +13 -7
- package/dist/tool-approval.d.ts +7 -6
- package/dist/tool-approval.js +41 -37
- package/dist/trace/engine-notice-wire.d.ts +14 -0
- package/dist/trace/engine-notice-wire.js +18 -1
- package/dist/trace/project.d.ts +4 -3
- package/dist/trace/project.js +3 -2
- package/dist/trace/projection-table.d.ts +33 -2
- package/dist/trace/self-minted-wire.d.ts +150 -17
- package/dist/trace/self-minted-wire.js +54 -16
- package/dist/trace/tool-card.d.ts +3 -0
- package/dist/trace/tool-card.js +24 -0
- package/dist/trace/tool-output-media.d.ts +2 -1
- package/dist/unattended-permission-mode.d.ts +1 -1
- package/dist/web-admin-client/apply-effective.d.ts +1 -1
- package/dist/web-admin-client/effective-keys.d.ts +1 -1
- package/dist/web-admin-client/skills-mcp.d.ts +1 -1
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +57 -29
- package/package.json +2 -2
- package/wire-changes/server@7.150.0.json +335 -0
|
@@ -14,7 +14,7 @@ import type { FlatServiceDeps } from "./server.js";
|
|
|
14
14
|
import { buildActiveRunConflict } from "./active-run-conflict.js";
|
|
15
15
|
import { rootSessionAbsentAnswer } from "./execution-context.js";
|
|
16
16
|
import { type RefusalBody } from "./refusal-body.js";
|
|
17
|
-
import {
|
|
17
|
+
import type { OwnerAwareSessionStore } from "../security.js";
|
|
18
18
|
/** 认领赢的那一拍起心跳(与后台腿 `runInBackground` 同一只周期、同一条带属主的刷新);交回停表。行已不在跑 ⇒ 心跳自停(起跑之前的复核随后答失认领)。刷新失败不抛(计数),下一拍再刷。 */
|
|
19
19
|
export declare function startClaimHeartbeat(runStore: RunHeartbeatStore, taskId: string, owner: string | null, metrics: {
|
|
20
20
|
inc(name: string, labels?: Record<string, string>): void;
|
|
@@ -26,12 +26,12 @@ export declare function claimStillHeld(runStore: ClaimFenceStore, sessionId: str
|
|
|
26
26
|
* 先按 {@link withdrawClaimedRun} 撤掉本请求刚认领的这条 run(删掉本请求铸的这一行 —— `legId` = 建行交回的持有腿,不留一条没起跑的 `running` 行占着会话等收割),再原样上抛。
|
|
27
27
|
*/
|
|
28
28
|
export declare function recheckClaimBeforeLaunch(deps: Pick<FlatServiceDeps, "checkpointStore" | "config" | "logger"> & LostClaimSessionFace, runStore: ClaimFenceStore & LostClaimStore, sessionId: string, taskId: string, legId: string): Promise<Awaited<ReturnType<typeof refusalAfterLostClaim>> | undefined>;
|
|
29
|
-
/** 失认领答复读会话店的那一面:只问头读(`
|
|
29
|
+
/** 失认领答复读会话店的那一面:只问头读(店有没有它由属主存取器的 `sessionFactsReadOf` 判)—— 不要整只会话店。 */
|
|
30
30
|
export interface LostClaimSessionFace {
|
|
31
|
-
readonly sessionStorage?:
|
|
31
|
+
readonly sessionStorage?: Pick<OwnerAwareSessionStore, "headOf"> | undefined;
|
|
32
32
|
}
|
|
33
33
|
/** 失认领答复与撤回本次 run 读写的那几面。 */
|
|
34
|
-
export type LostClaimStore = Pick<RunStore, "getActiveTaskId" | "
|
|
34
|
+
export type LostClaimStore = Pick<RunStore, "getActiveTaskId" | "withdrawMintedRun" | "getRun">;
|
|
35
35
|
/**
|
|
36
36
|
* 起跑之前认领复核没过的答复(三条提交腿同一只;三臂按「此刻是谁的事实」分,各读各的):
|
|
37
37
|
* · 认领此刻在别的 run 上 ⇒ 409 冲突体(与建行时认领输同一只材料,`conflict.session_active_run`);
|
|
@@ -5,7 +5,7 @@ import { rootSessionAbsentAnswer } from "./execution-context.js";
|
|
|
5
5
|
import { readTurnActivityMs } from "../turn-activity.js";
|
|
6
6
|
import { withdrawClaimedRun } from "./claimed-run.js";
|
|
7
7
|
import { refusalBody } from "./refusal-body.js";
|
|
8
|
-
import {
|
|
8
|
+
import { sessionFactsReadOf } from "./owner-access.js";
|
|
9
9
|
export function startClaimHeartbeat(runStore, taskId, owner, metrics) {
|
|
10
10
|
const timer = setInterval(() => {
|
|
11
11
|
beatRunHeartbeat(runStore, taskId, owner, () => clearInterval(timer), () => {
|
|
@@ -38,8 +38,8 @@ export async function refusalAfterLostClaim(deps, runStore, sessionId, taskId) {
|
|
|
38
38
|
if (holder !== undefined && holder !== taskId) {
|
|
39
39
|
return { status: 409, body: await buildActiveRunConflict({ runStore, checkpointStore: deps.checkpointStore, governance: deps.config, turnActivity: readTurnActivityMs }, sessionId, holder) };
|
|
40
40
|
}
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
41
|
+
const sessionFactsOf = sessionFactsReadOf(deps.sessionStorage);
|
|
42
|
+
if (sessionFactsOf !== undefined && (await sessionFactsOf(sessionId)) === undefined)
|
|
43
43
|
return rootSessionAbsentAnswer();
|
|
44
44
|
return { status: 409, body: refusalBody({ errorCode: "conflict.claim_lost", message: "the run this request claimed was settled by the stale-run verdict before the engine started it (its claim heartbeat did not land within the reap window) — nothing ran" }) };
|
|
45
45
|
}
|
package/dist/http/dispatch.js
CHANGED
|
@@ -9,7 +9,7 @@ import { ROUTE_METHOD_ORDER } from "./route-ctx.js";
|
|
|
9
9
|
import { READ_CREDENTIAL_ROUTES, PUBLIC_ROUTES, POST_CREDENTIAL_ROUTES, routeLabel, isBillableSubmitPath, billableKindOf, isCredentialGatedRewrite, isMethodDispatchedSubmitPath, lookupRoute, isProbePath, isSubscriptionRequest } from "./route-table.js";
|
|
10
10
|
import { sendJson, sendError, sendHttpError, isSseResponse, endSseWithError } from "./send.js";
|
|
11
11
|
import { admissionRefusalOf, readinessOf, healthReadinessKeys, sendReadyz, sendBillableRefusal, billableRefusalOf, billableRefusalFrame } from "./readiness.js";
|
|
12
|
-
import { ENGINE_SIGNAL_KEY, buildEngineSignal, fleetMembershipKeys, healthConfigLedgerKeys, healthDrainingKeys, mintEngineSignal, restartActionable } from "../fleet/engine-signal.js";
|
|
12
|
+
import { ENGINE_SIGNAL_KEY, buildEngineSignal, fleetMembershipKeys, healthConfigLedgerKeys, healthDrainingKeys, memberLeaseOf, mintEngineSignal, restartActionable } from "../fleet/engine-signal.js";
|
|
13
13
|
import { buildHealthSelfReport } from "./health-self-report.js";
|
|
14
14
|
import { projectHealthBody } from "./health-reader.js";
|
|
15
15
|
import { projectHealthStoreSection, unwiredStorePosture } from "../store-posture.js";
|
|
@@ -331,7 +331,7 @@ export function createDispatch(ctx) {
|
|
|
331
331
|
}
|
|
332
332
|
const billableKind = req.method === "POST" && !isMethodDispatchedSubmitPath(url) ? billableKindOf(url) : undefined;
|
|
333
333
|
if (billableKind !== undefined) {
|
|
334
|
-
const refusal = admissionRefusalOf(readinessOf(deps), deps
|
|
334
|
+
const refusal = admissionRefusalOf(readinessOf(deps), memberLeaseOf(deps), billableKind);
|
|
335
335
|
if (refusal !== undefined) {
|
|
336
336
|
sendBillableRefusal(res, refusal);
|
|
337
337
|
return;
|
|
@@ -16,7 +16,7 @@ import { clearTurnActivity, readTurnActivityMs } from "../turn-activity.js";
|
|
|
16
16
|
import { recordResourceWindow } from "../resource-window.js";
|
|
17
17
|
import { persistSubmissionCtx, SUBMIT_CTX_CLAIM_LOST } from "./submit-ctx.js";
|
|
18
18
|
import { withdrawClaimedRun } from "./claimed-run.js";
|
|
19
|
-
import {
|
|
19
|
+
import { sessionFactsReadOf } from "./owner-access.js";
|
|
20
20
|
import { createSessionWorkspaceRecorder, sessionWorkspaceStoreOf } from "../session-workspace.js";
|
|
21
21
|
export async function mintAndDriveDurableRun(ctx, runStore, args) {
|
|
22
22
|
const { deps } = ctx;
|
|
@@ -89,10 +89,10 @@ function launchDurableRun(ctx, runStore, args, sessionId, taskId, trustedInterna
|
|
|
89
89
|
const { deps } = ctx;
|
|
90
90
|
const { inflightRuns, preemptableRuns, steerableRuns } = ctx.registry;
|
|
91
91
|
const anchorOwner = args.prepared.auth?.subject ?? null;
|
|
92
|
-
const
|
|
93
|
-
const captureTurnAnchor = deps.resumeAnchorStore &&
|
|
92
|
+
const sessionFactsOf = sessionFactsReadOf(deps.sessionStorage);
|
|
93
|
+
const captureTurnAnchor = deps.resumeAnchorStore && sessionFactsOf
|
|
94
94
|
? async (eventId) => {
|
|
95
|
-
const leaf = (await
|
|
95
|
+
const leaf = (await sessionFactsOf(sessionId))?.leafId;
|
|
96
96
|
if (leaf)
|
|
97
97
|
await deps.resumeAnchorStore.put(sessionId, eventId, leaf, anchorOwner);
|
|
98
98
|
}
|
|
@@ -11,16 +11,30 @@
|
|
|
11
11
|
* `policyFace` = 策略面〔面表键〕,与 `session_owner_unreadable` 那一行的 `face` = 口名分开命名:一个字段名一义)。
|
|
12
12
|
*
|
|
13
13
|
* 嵌套可选读(会话面板的上一腿、审批预览)与协议口(A2A、leader、提交重放)用 {@link seesRun} / {@link seesSession}:不下发,看不见 = 没有,由调用点走它自己的缺席路径。
|
|
14
|
+
*
|
|
15
|
+
* ## 读只经这里([ref] 第二阶段)
|
|
16
|
+
* 请求路径上带属主的 run / 会话行**只有本模块读**,交出去的只有两种:**承认**(判过的行 —— 门 `admit*`、非下发读 `readVisible*`、承认之后的重读也是这两只,
|
|
17
|
+
* 同一只入口再判一次)与**不带属主格的一格事实**(`*FactsOf` / `*LeafReadOf` / `latestRunIdOf` / `sessionAgentOf`:持有认领的腿与承认派生的读要的那一格 ——
|
|
18
|
+
* 状态 / 位置 / 所属会话 / 叶子 / 委派元组,行本身不出本模块)。列表的属主过滤落成店的过滤参数也只在这里({@link listVisibleRuns} / {@link listRunsOfScope})。
|
|
19
|
+
* 路由层看到的店在型上没有按 id 读口({@link RouteRunStore} / {@link RouteSessionStore}:那几口的型是 `never`,调不了;视图仍是那只店的子型,交给本模块的口与持认领腿的
|
|
20
|
+
* 写口照常),视图只在一处铸({@link sealRouteDeps})。
|
|
14
21
|
*/
|
|
15
22
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
16
|
-
import type { SessionHead } from "@sema-agent/core";
|
|
23
|
+
import type { SessionHead, WorkflowRun, WorkflowRunStore } from "@sema-agent/core";
|
|
24
|
+
import type { RunStore, StoreBackend } from "../plugins/store-backend.js";
|
|
17
25
|
import { type Logger } from "../observability/logger.js";
|
|
18
|
-
import type { RunRecord } from "../plugins/store-contracts.js";
|
|
26
|
+
import type { LatestRunRef, RunListQuery, RunRecord } from "../plugins/store-contracts.js";
|
|
19
27
|
import type { ServiceConfig } from "../config-types.js";
|
|
20
|
-
import
|
|
28
|
+
import type { SessionAuditReadOpts } from "../audit.js";
|
|
29
|
+
import { type DeploymentShapeInput } from "../deployment-shape.js";
|
|
30
|
+
import { type SessionAgent } from "../session-agent.js";
|
|
31
|
+
import { type SessionFace } from "../session-incarnation.js";
|
|
32
|
+
import { type Admitted, type Caller, type FaceId, type ListFaceId, type ListFilter, type OwnedReading, type Qual, type RunFaceId, type SessionFaceId, type WorkflowFaceId } from "../owner-faces.js";
|
|
21
33
|
import { type Person, type Subject } from "../owner-brands.js";
|
|
22
34
|
import { type OwnerAwareSessionStore } from "../security.js";
|
|
23
35
|
import { type OperatorRoster } from "./principal-gate.js";
|
|
36
|
+
import { type RouteDeps } from "./route-ctx.js";
|
|
37
|
+
import type { FlatServiceDeps } from "./server.js";
|
|
24
38
|
import type { AgentRosterRouteId } from "./routes/agents-roster.js";
|
|
25
39
|
import type { ApprovalsAssistantRouteId } from "./routes/approvals-assistant.js";
|
|
26
40
|
import type { BackgroundRouteId } from "./routes/background.js";
|
|
@@ -36,6 +50,7 @@ import type { SessionSyncRouteId } from "./routes/session-sync.js";
|
|
|
36
50
|
import type { SessionsListRouteId } from "./routes/sessions-list.js";
|
|
37
51
|
import type { SessionsRouteId } from "./routes/sessions.js";
|
|
38
52
|
import type { TraceUsageRouteId } from "./routes/trace-usage.js";
|
|
53
|
+
import type { WorkflowAgentSteerRouteId, WorkflowsRouteId } from "./routes/workflows.js";
|
|
39
54
|
/** 存取器读的装配:部署配置(身份来源只从配置读,见 `identity-source.ts` 的 `configuredIdentitySources`)+ 运维日志。`FlatServiceDeps` 结构上满足。 */
|
|
40
55
|
export interface OwnerAccessWiring {
|
|
41
56
|
readonly config: ServiceConfig;
|
|
@@ -56,10 +71,10 @@ export declare function callerOf(req: IncomingMessage, w: Pick<OwnerAccessWiring
|
|
|
56
71
|
export declare function callerOfDecision(base: Caller, decider: Person | undefined, roster: OperatorRoster): Caller;
|
|
57
72
|
/** 决定者的主体(唯一读法;{@link callerOfDecision} 与只要主体 + 运维位的决断腿同读):证明推出的人 × 请求的场景(请求没带场景 ⇒ 与人逐字节同)。 */
|
|
58
73
|
export declare function deciderSubjectOf(requestSubject: Subject | undefined, decider: Person | undefined): Subject | undefined;
|
|
59
|
-
/**
|
|
60
|
-
export type OwnedRouteId = RunsRouteId | RunVerbsRouteId | RunPermissionModeRouteId | RunMemoryCaptureRouteId | SessionsRouteId | SessionSyncRouteId | SessionMemorySyncRouteId | BackgroundRouteId | McpReconnectRouteId | NotifyWakeRouteId | TraceUsageRouteId | ApprovalsAssistantRouteId | SessionsListRouteId | FleetRouteId | ProjectsRouteId | AgentRosterRouteId;
|
|
74
|
+
/** 属主面与列表面所在十八个域的路由 id(全部;无属主门的那几条登 `null`)。 */
|
|
75
|
+
export type OwnedRouteId = WorkflowsRouteId | WorkflowAgentSteerRouteId | RunsRouteId | RunVerbsRouteId | RunPermissionModeRouteId | RunMemoryCaptureRouteId | SessionsRouteId | SessionSyncRouteId | SessionMemorySyncRouteId | BackgroundRouteId | McpReconnectRouteId | NotifyWakeRouteId | TraceUsageRouteId | ApprovalsAssistantRouteId | SessionsListRouteId | FleetRouteId | ProjectsRouteId | AgentRosterRouteId;
|
|
61
76
|
/**
|
|
62
|
-
* 🔴 **路由 → 面**(闭集穷举;`satisfies Record
|
|
77
|
+
* 🔴 **路由 → 面**(闭集穷举;`satisfies Record<…>`:十八个路由域里加一条路由不登 = 编译红,登错资源的面由 {@link admitRunRow} / {@link admitSessionRow} / {@link admitWorkflowRun} 的签名挡)。
|
|
63
78
|
* 列表 / 舰队读面登列表面(`list.read` / `session.list`:属主视域经 `owner-faces.ts` 的 `listFilterOf` 从这一行派生)。
|
|
64
79
|
* `null` = 这条路由不在本表判属主:提交面、ask / 检查点面(属主门在腿里经 `owner-faces.ts` 的 `keyAdmits` 判:决定 / 应答的属主是停驻行与问账行,不是路径上的这一行)。
|
|
65
80
|
*/
|
|
@@ -134,6 +149,11 @@ export declare const ROUTE_FACES: {
|
|
|
134
149
|
readonly "assistant-task-preempt": "run.preempt";
|
|
135
150
|
readonly "assistant-task-resume": "run.resume";
|
|
136
151
|
readonly "assistant-task-plan-review": "run.decision";
|
|
152
|
+
readonly "workflows-list": "workflow.read";
|
|
153
|
+
readonly "workflow-detail": "workflow.read";
|
|
154
|
+
readonly "workflow-journal": "workflow.read";
|
|
155
|
+
readonly "workflow-stream": "workflow.read";
|
|
156
|
+
readonly "workflow-agent-steer": "workflow.steer";
|
|
137
157
|
readonly "sessions-list": "session.list";
|
|
138
158
|
readonly "sendfile-links": "list.read";
|
|
139
159
|
readonly "fleet-stream": "list.read";
|
|
@@ -153,7 +173,11 @@ export type SessionRouteId = {
|
|
|
153
173
|
export type ListRouteId = {
|
|
154
174
|
[R in keyof RouteFaces]: RouteFaces[R] extends ListFaceId ? R : never;
|
|
155
175
|
}[keyof RouteFaces];
|
|
156
|
-
|
|
176
|
+
/** 登到工作流面的路由(由表派生)。 */
|
|
177
|
+
export type WorkflowRouteId = {
|
|
178
|
+
[R in keyof RouteFaces]: RouteFaces[R] extends WorkflowFaceId ? R : never;
|
|
179
|
+
}[keyof RouteFaces];
|
|
180
|
+
type RoutedId = RunRouteId | SessionRouteId | ListRouteId | WorkflowRouteId;
|
|
157
181
|
/** 协议口 / 嵌套读的面(不经路由表的那几只;路由面一律经 {@link ROUTE_FACES})。 */
|
|
158
182
|
export type ProtocolFaceId = "run.a2a" | "run.leader" | "run.replay" | "run.preview" | "run.panel" | "run.anchor";
|
|
159
183
|
/** 读 run 行的口:登到 run 面的路由 + 协议口 / 嵌套读(由两张既有闭集派生)。 */
|
|
@@ -343,14 +367,18 @@ export declare function deliverVerdict<R extends OwnedReading>(entry: Entry, res
|
|
|
343
367
|
* 交回承认(行 + 全部资格)或 `undefined`(已应答)。`id` = 路径上的 run id(句子的句柄指路;按幂等键读的口不传)。
|
|
344
368
|
*/
|
|
345
369
|
export declare function admitRunRow(entry: Entry, res: ServerResponse, runStore: RunObserver, row: RunRecord | null | undefined, id?: string): Promise<Admitted<RunRecord> | undefined>;
|
|
370
|
+
/** 本模块门读的 run 店:按 id 读口 + 观察口(路由层的视图上这一读口封着 —— 视图交得进来,路由自己调不了)。 */
|
|
371
|
+
export type RunGateStore = Pick<RunStore, "getRun"> & RunObserver;
|
|
346
372
|
/** run 面的门,行由本模块读(店唯一的按 id 读 `getRun`):路由不再自己读行(裸读普查门 ④ 的路由基线据此归零)。 */
|
|
347
|
-
export declare function admitRunById(entry: Entry, res: ServerResponse, runStore:
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
373
|
+
export declare function admitRunById(entry: Entry, res: ServerResponse, runStore: RunGateStore, taskId: string): Promise<Admitted<RunRecord> | undefined>;
|
|
374
|
+
/** run 面的门,按提交幂等键读行(`GET /v1/runs?idempotencyKey=`;键由调用方的身份铸,别人的键算出的是另一把):没有 / 看不见同一只投影,没有路径 id ⇒ 常量句。 */
|
|
375
|
+
export declare function admitRunByIdem(entry: Entry, res: ServerResponse, runStore: Pick<RunStore, "getRunByIdem"> & RunObserver, idemKey: string): Promise<Admitted<RunRecord> | undefined>;
|
|
376
|
+
/**
|
|
377
|
+
* run 行的非下发读:本模块按 id 读一行并判(属主门 + 本口的 `RUN_STATE_FACES`),看不见 ≡ 没有(`undefined`),调用点走它自己的缺席路径。
|
|
378
|
+
* 两种读者同用:嵌套可选读 / 协议口,与**承认之后的重读**(取消 / 抢占 / steer / 中断的竞态重读、流的逐拍复读、A2A 的等待循环)—— 重读用承认它的同一只入口,
|
|
379
|
+
* 对新读数再判一次同一只(run 行的属主不变,这一判对同一位调用方恒同答;行没了 ⇒ 没有)。交回承认(行 + 资格)。
|
|
380
|
+
*/
|
|
381
|
+
export declare function readVisibleRun(entry: Entry, runStore: RunGateStore, taskId: string): Promise<Admitted<RunRecord> | undefined>;
|
|
354
382
|
/** run 行可见吗(不下发;嵌套可选读与协议口):看不见 ≡ 没有。 */
|
|
355
383
|
export declare function seesRun(entry: Entry, owner: string | null | undefined): boolean;
|
|
356
384
|
/**
|
|
@@ -376,16 +404,35 @@ export declare function readOwnerCell<T>(entry: Entry, sessionId: string, read:
|
|
|
376
404
|
* 会话面的门:调用点读到的那一读(`undefined` / `null` = 没有;读不出按面折过的也是 `undefined`)交进来 —— 没有 ⇒ 投影;行格(无主、且 placement 改得了判时问一次);
|
|
377
405
|
* 运维旁路 → 前门 → 看不见 ⇒ 同一投影。交回承认(读数 + 全部资格)或 `undefined`(已应答)。
|
|
378
406
|
*/
|
|
379
|
-
export declare function admitSessionRow<T extends OwnedReading>(entry: Entry, res: ServerResponse, store:
|
|
407
|
+
export declare function admitSessionRow<T extends OwnedReading>(entry: Entry, res: ServerResponse, store: PlacementReadingStore | undefined, sessionId: string, reading: T | null | undefined): Promise<Admitted<T> | undefined>;
|
|
380
408
|
/**
|
|
381
409
|
* 会话行的判(不下发):行格只经 `security.ts` 的 {@link sessionCellFor}(无主行的 placed 位只在两种假设不都放行时问店;存档读不出按面表 `placementUnreadable` 列;
|
|
382
410
|
* 别的读故障照常上抛)。事件流把这一判整个框进它的读期上限,判完再 {@link deliverVerdict}。
|
|
383
411
|
*/
|
|
384
|
-
export declare function judgeSessionRow<T extends OwnedReading>(entry: Entry, store:
|
|
385
|
-
/**
|
|
386
|
-
export
|
|
412
|
+
export declare function judgeSessionRow<T extends OwnedReading>(entry: Entry, store: PlacementReadingStore | undefined, sessionId: string, reading: T): Promise<OwnerVerdict<T>>;
|
|
413
|
+
/** 本模块门读的会话店:按 id 头读(路由层的视图上封着)+ 无主行 placed 位的问询(可缺)。 */
|
|
414
|
+
export type SessionGateStore = Required<Pick<OwnerAwareSessionStore, "headOf">> & PlacementReadingStore;
|
|
415
|
+
/** 交 placed 位问询的店(可缺:店不交 ⇒ 无主行读作普通无主行,`security.ts` 的 `sessionOwnerCellOf`)。 */
|
|
416
|
+
export type PlacementReadingStore = Pick<OwnerAwareSessionStore, "placementOf">;
|
|
417
|
+
/**
|
|
418
|
+
* 会话面按 id 的判(不下发):头由本模块读(会话店唯一的按 id 读 `headOf`;读不出按面的 `unreadable` 列折)并判;`undefined` = 没有这一行。
|
|
419
|
+
* 门 {@link admitSessionById} 与非下发读 {@link readVisibleSession} 都是它;事件流把它整个框进自己的读期上限,判完再 {@link deliverVerdict}。
|
|
420
|
+
*/
|
|
421
|
+
export declare function judgeSessionById(entry: Entry, store: SessionGateStore, sessionId: string): Promise<OwnerVerdict<SessionHead> | undefined>;
|
|
422
|
+
/** 会话面的门,头由本模块读:路由不再自己读头。没有 ⇒ 投影;前门 / 看不见经各自的下发口。 */
|
|
423
|
+
export declare function admitSessionById(entry: Entry, res: ServerResponse, store: SessionGateStore, sessionId: string): Promise<Admitted<SessionHead> | undefined>;
|
|
424
|
+
/**
|
|
425
|
+
* 会话行的非下发读:看不见 ≡ 没有。**承认之后的重读**用它(同一只入口对新读数再判一次同一只:两读之间易主 ⇒ 按新主判;行没了 ⇒ 没有)——
|
|
426
|
+
* 记忆同步栅栏的叶子复读等。住客(化身)绑定不在这里(见 `owner-faces.ts` 的 `Admitted`)。
|
|
427
|
+
*/
|
|
428
|
+
export declare function readVisibleSession(entry: Entry, store: SessionGateStore, sessionId: string): Promise<Admitted<SessionHead> | undefined>;
|
|
429
|
+
/**
|
|
430
|
+
* 承认之后的**世代围栏**(会话事件流的心跳拍):这只会话此刻的属主还是承认时读到的那一格吗 —— 删了(没有这一行 / 读不出按面折)或换主 ⇒ 否。
|
|
431
|
+
* 与 {@link readVisibleSession} 的「再判可见」不同:比的是同一行前后两次读到的属主(删建 / 易主 ⇒ 作废),两侧都是行上的属主,不是调用方身份。
|
|
432
|
+
*/
|
|
433
|
+
export declare function sessionOwnerUnchanged(entry: Entry, store: SessionGateStore, sessionId: string, admittedOwner: string | null): Promise<boolean>;
|
|
387
434
|
/** 会话行的完整判(不下发,交回承认 / `undefined`):两读之间要再判一次的口(同步导入的提交前复判)与「看不见按自己的形答」的口用。 */
|
|
388
|
-
export declare function judgeSession<T extends OwnedReading>(entry: Entry, store:
|
|
435
|
+
export declare function judgeSession<T extends OwnedReading>(entry: Entry, store: PlacementReadingStore | undefined, sessionId: string, reading: T): Promise<Admitted<T> | undefined>;
|
|
389
436
|
/** 这一份承认里的调用方是 fleet 吗(本口 `fleet` 列里的一格成立):fork 新属主「继承源属主」那一支读它。 */
|
|
390
437
|
export declare function admittedAsFleet(entry: Entry, admitted: {
|
|
391
438
|
readonly quals: ReadonlySet<Qual>;
|
|
@@ -397,5 +444,182 @@ export declare function entryIsFleet(entry: Entry): boolean;
|
|
|
397
444
|
* 路由 id 查表得列表面,`owner-faces.ts` 的 `listFilterOf` 从那一行派生(一只读法;trace 列表经 {@link enter} 拿入口后同读它)。
|
|
398
445
|
*/
|
|
399
446
|
export declare function routeListFilter<R extends ListRouteId>(req: IncomingMessage, w: Pick<OwnerAccessWiring, "config">, route: R): ListFilter;
|
|
447
|
+
/** run 店上读出带属主行的口(闭集):按 id、按提交幂等键、按会话(最近一条腿)、列表。 */
|
|
448
|
+
export type RunRowReadName = "getRun" | "getRunByIdem" | "latestRunForSession" | "listRuns";
|
|
449
|
+
/** 会话店上按 id 读出带属主行的口(闭集):头读、删除门的头读、委派子代的 placed 位 / 元组。 */
|
|
450
|
+
export type SessionRowReadName = "headOf" | "deletionHeadOf" | "placementOf";
|
|
451
|
+
/**
|
|
452
|
+
* 封口:这几口在型上调不了 —— 值上原样在。每一口的可缺与否照抄店形(`keyof Pick<T, K>` 同态保留修饰):店必交的读口 ⇒ 必有的 `never`;可缺的读口 ⇒ 可缺的 `never`(读作 `undefined`,
|
|
453
|
+
* 「在场」仍要能力事实证明:判过在场的见证上那一格是必有的 `never`,交得进要它在场的口)。修饰不能统一写成可缺:必有的方法与可缺的 `never` 相交,TS 把整只交叉型约成 `never`。
|
|
454
|
+
* 视图是那只店的**子型**:本模块的口与持认领腿的写口收完整的店形,视图交得进去。
|
|
455
|
+
*/
|
|
456
|
+
type ReadsSealed<T, K extends keyof T> = {
|
|
457
|
+
readonly [P in keyof Pick<T, K>]: never;
|
|
458
|
+
};
|
|
459
|
+
/** 路由层看到的 run 店({@link RunRowReadName} 封着)。 */
|
|
460
|
+
export type RouteRunStore = RunStore & ReadsSealed<RunStore, RunRowReadName>;
|
|
461
|
+
/** 路由层看到的会话店({@link SessionRowReadName} 封着)。 */
|
|
462
|
+
export type RouteSessionStore = OwnerAwareSessionStore & ReadsSealed<OwnerAwareSessionStore, SessionRowReadName>;
|
|
463
|
+
/** 路由层看到的存储后端:铸 run 店 / 会话店的两只工厂封着(路由从后端拿不到一只没封的店;后端的其余面照常)。 */
|
|
464
|
+
export type RouteBackend = StoreBackend & ReadsSealed<StoreBackend, "run" | "session">;
|
|
465
|
+
/**
|
|
466
|
+
* 🔴 **铸路由层的 deps 视图 —— 全仓唯一的一处**(`route-ctx.ts` 的 `RouteDeps`;值就是服务的那一只 deps,只在型上封住带属主的读口)。
|
|
467
|
+
* 子型收窄只能在铸点上说一次:之后路由拿到的 run / 会话店读不出带属主的行(编译红),交给本模块的口照读。
|
|
468
|
+
*/
|
|
469
|
+
export declare function sealRouteDeps(deps: FlatServiceDeps): RouteDeps;
|
|
470
|
+
/**
|
|
471
|
+
* 一条 run **不带属主格**的事实:状态、位置(哪一副本在跑)、所属会话。读者两种 —— 持有会话认领的腿读它持有 / 输给的那一条(认领冲突的 409 材料、
|
|
472
|
+
* 决定投递的回执幂等、提交流的兜底收场、取消动词会不会结算那张卡),与承认派生的读(承认过的会话上那条在飞 run 的状态;决定口的证明要绑的会话)。
|
|
473
|
+
* 行不出本模块:要属主或整行就走门 / {@link readVisibleRun}。`undefined` = 没有这一行。
|
|
474
|
+
*/
|
|
475
|
+
export interface RunFacts {
|
|
476
|
+
readonly status: RunRecord["status"];
|
|
477
|
+
readonly instanceId: RunRecord["instanceId"];
|
|
478
|
+
readonly sessionId: string;
|
|
479
|
+
}
|
|
480
|
+
export declare function runFactsOf(store: Pick<RunStore, "getRun">, taskId: string): Promise<RunFacts | undefined>;
|
|
481
|
+
/** 会话最近一条腿的 run id(不交属主;没有腿 ⇒ `undefined`):审批预览与记忆同步的栅栏只要 id —— 要行再经 {@link readVisibleRun} 判。 */
|
|
482
|
+
export declare function latestRunIdOf(store: Pick<RunStore, "latestRunForSession">, sessionId: string): Promise<string | undefined>;
|
|
483
|
+
/** 一只会话**不带属主 / 住客**的事实:叶子(`null` = 空会话)。叶子是惰性读(展开即读会话内容 —— 坏档在这里抛),只要「在不在」的读者不碰它。 */
|
|
484
|
+
export interface SessionFacts {
|
|
485
|
+
readonly leafId: string | null;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* 会话事实的读口:`undefined` = 没有这只会话。店没有按 id 头读 ⇒ 交回 `undefined`(这台部署读不出,调用方按自己的缺席臂)。
|
|
489
|
+
* 读者:回退锚的逐轮捕获(两条起跑腿读叶子)、失认领答复的「会话在不在」(不碰叶子)、同步拉取清单的当前叶子。
|
|
490
|
+
*/
|
|
491
|
+
export declare function sessionFactsReadOf(store: Pick<OwnerAwareSessionStore, "headOf"> | undefined): ((sessionId: string) => Promise<SessionFacts | undefined>) | undefined;
|
|
492
|
+
/**
|
|
493
|
+
* 会话在委派树里的位置(wire 键 `agent` 的值;唯一读口):店的 placed 位一读 → `session-agent.ts` 的 `sessionAgentOf`(元组不带属主)。店不交这一面 ⇒ `undefined`
|
|
494
|
+
* (这台部署不存元组,不探)。探针抛 ⇒ 原样上抛 —— 读不出怎么说归读者(视图读响亮失败;队列只缺那一行的键并计数),本函数不替任何一面把故障说成「不是子代」。
|
|
495
|
+
*/
|
|
496
|
+
export declare function readSessionAgent(store: Pick<OwnerAwareSessionStore, "placementOf"> | undefined, sessionId: string): Promise<SessionAgent | undefined>;
|
|
497
|
+
/**
|
|
498
|
+
* 会话通知投递之前的住客复核(律在 `session-notify-door.ts` 头注「复核住客」):此刻的住客还是门承认过的那一位吗 —— `same` / `gone`(会话没了)/ `replaced`(换了住客)。
|
|
499
|
+
* 店没有按 id 头读 ⇒ 交回 `undefined`(调用方先判;门响亮拒)。
|
|
500
|
+
*/
|
|
501
|
+
export declare function occupantRecheckOf(store: Pick<OwnerAwareSessionStore, "headOf"> | undefined): ((sessionId: string, occupant: Pick<SessionHead, "owner" | "incarnation">) => Promise<"same" | "gone" | "replaced">) | undefined;
|
|
502
|
+
/**
|
|
503
|
+
* 引擎会话规则席的键(律在 `session-rules-seat.ts` 头注):引擎交来的人恰是这只会话属主背后的人 ⇒ 键 = 会话属主;否则原样(没带场景的会话属主与人字节相同)。
|
|
504
|
+
* 属主只经会话店的头读一处;读不到头(会话不在 / 店不交头读)⇒ 原样。
|
|
505
|
+
*/
|
|
506
|
+
export declare function engineRulesKeyOf(store: Pick<OwnerAwareSessionStore, "headOf"> | undefined, sessionId: string, principal: string | undefined): Promise<string | undefined>;
|
|
507
|
+
/**
|
|
508
|
+
* 会话最近一条腿的 run 指针(`LatestRunRef`:id + 属主 + 排序键;刻意不是整行 —— 不把结果 blob 拖进按会话的读)经本口的属主门判:看不见 ≡ 没有。
|
|
509
|
+
* 读者:会话面板的上一腿(面 `run.panel`,看不见 = 不投那个键)。
|
|
510
|
+
*/
|
|
511
|
+
export declare function readVisibleLatestRun(entry: Entry, store: Pick<RunStore, "latestRunForSession">, sessionId: string): Promise<LatestRunRef | undefined>;
|
|
512
|
+
/** run 列表的属主过滤参数(一只派生,读与游标指纹同读):视域钉住一位主体 ⇒ 强制那一位(调用方点名的 `owner` 不算);不钉人(fleet)⇒ 点名的照用(运维视图)。 */
|
|
513
|
+
export declare function runListOwnerOf(filter: ListFilter, named: string | undefined): string | undefined;
|
|
514
|
+
/** run 列表的读口(列表面 `list.read`):过滤参数由 {@link runListOwnerOf} 从视域派生,只在这里落成店的过滤参数。 */
|
|
515
|
+
export declare function listVisibleRuns(store: Pick<RunStore, "listRuns">, filter: ListFilter, named: string | undefined, query: Omit<RunListQuery, "owner">): Promise<RunRecord[]>;
|
|
516
|
+
/** 审批 / 助手面按停驻 scope 列 run:属主过滤 = scope 的属主键(公共 scope `_` ⇒ 属主为 null 的 run,主体 ⇒ 恰它的;`security.ts` 的唯一编解码),只在这里落成店的过滤参数。 */
|
|
517
|
+
export declare function listRunsOfScope(store: Pick<RunStore, "listRuns">, scope: string, limit: number): Promise<RunRecord[]>;
|
|
518
|
+
/** 一把提交钥匙命中的行对这位调用方算什么:`visible` = 读得到的那一行;`occupied` = 有行但不是这次提交拿得到的(看不见 / 自带 taskId 而键指着别的行)—— 回执 409,不回显那一行。 */
|
|
519
|
+
export type ReplayHit = {
|
|
520
|
+
readonly kind: "visible";
|
|
521
|
+
readonly row: RunRecord;
|
|
522
|
+
} | {
|
|
523
|
+
readonly kind: "occupied";
|
|
524
|
+
};
|
|
525
|
+
/** 提交重放的判(纯):命中的行(进门按钥匙读到的 / 建行撞唯一键时观察到的)对这位提交者(认领面的调用方 `claimCallerOf`:不放 fleet、不放运维)算什么。 */
|
|
526
|
+
export declare function replayHitOf(subject: Subject | undefined, config: DeploymentShapeInput<"principal">, row: RunRecord, clientTaskId: string | undefined): ReplayHit;
|
|
527
|
+
/** 提交重放读:按一把钥匙读行(`Idempotency-Key` 铸的键,或调用方自铸的 `body.taskId`)并判;没有命中 ⇒ `undefined`(这是一次新提交)。 */
|
|
528
|
+
export declare function readReplayHit(subject: Subject | undefined, config: DeploymentShapeInput<"principal">, store: Pick<RunStore, "getRun" | "getRunByIdem">, key: {
|
|
529
|
+
readonly idemKey: string;
|
|
530
|
+
} | {
|
|
531
|
+
readonly taskId: string;
|
|
532
|
+
}, clientTaskId: string | undefined): Promise<ReplayHit | undefined>;
|
|
533
|
+
/** 会话视图读(`sessionAudit`:存档读出的视图 + 头读的属主)。 */
|
|
534
|
+
type SessionViewRead = NonNullable<FlatServiceDeps["sessionAudit"]>;
|
|
535
|
+
/**
|
|
536
|
+
* 读**会话视图**的三口(`GET /v1/sessions/:id` / `…/memory-status` / `…/memory/erase`)的「归属 + 读存档」**唯一**一段([ref];律在 `routes/sessions.ts` 的调用点注):
|
|
537
|
+
* 会话店有头读 ⇒ 先判归属(门同 head / fork / sync 各口),非属主拿到的应答与「属主的会话完好」时逐字相同;只接了视图面 ⇒ 视图只能先读,读失败时归属还没判出来 ⇒
|
|
538
|
+
* 换成一只不带码的错上抛。视图读完之后再判一次同一只(两读之间换主 ⇒ 按新主拒;读后会话消失 ⇒ 没有这一行)。交回视图,`undefined` = 已应答。
|
|
539
|
+
*/
|
|
540
|
+
export declare function admitSessionView(entry: Entry, res: ServerResponse, store: Pick<OwnerAwareSessionStore, "headOf" | "placementOf"> | undefined, sessionAudit: SessionViewRead, sessionId: string, readOpts?: SessionAuditReadOpts): Promise<({
|
|
541
|
+
owner: string | null;
|
|
542
|
+
} & Record<string, unknown>) | undefined>;
|
|
543
|
+
/** 同步族的门读结果:活行的住客(拉取只认它)、占着这个 id 的那一位(活行 ∪ 在删行)、这位调用方碰不碰得了占着的那一行(面 `session.own`)。 */
|
|
544
|
+
export interface SyncGateReading {
|
|
545
|
+
readonly face: SessionFace | undefined;
|
|
546
|
+
readonly occupant: SessionFace | undefined;
|
|
547
|
+
readonly mayTouch: boolean;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* 同步族(拉取 / 推送 / 干跑 / 导入第二阶段)的门读 —— 一只判据、两个时刻(律在 `routes/session-sync.ts` 的门注):会话店的头读投成活住客;「这个 id 被占着吗」只有
|
|
551
|
+
* 一种读法,与认领面同一只 `deletionHeadReadOf`(活行 ∪ 在删行:在删的行对活行读法是「不在」,但它仍占着这个 id);占着的那一行准不准这位调用方碰 = 面表 `session.own`。
|
|
552
|
+
*/
|
|
553
|
+
export declare function readSyncGate(entry: Entry, store: DeletionGateStore, sessionId: string): Promise<SyncGateReading>;
|
|
554
|
+
/** 工具结果店的出处读口(core `ToolResultStore.ownerOf`:这枚 ref 写下时声明的会话 / task)。 */
|
|
555
|
+
export interface ToolResultProvenanceReader {
|
|
556
|
+
ownerOf?(ref: string): Promise<{
|
|
557
|
+
readonly sessionId: string;
|
|
558
|
+
readonly taskId?: string;
|
|
559
|
+
} | undefined> | {
|
|
560
|
+
readonly sessionId: string;
|
|
561
|
+
readonly taskId?: string;
|
|
562
|
+
} | undefined;
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* 一枚工具结果 ref 属于这条**已承认**的 run 吗(律在 `routes/trace-usage.ts` 的 ②-a 段):店记着的出处是这条 run 的会话,且出处若点名了 task 则必须是这条。
|
|
566
|
+
* 店不交出处 / 出处缺席 ⇒ 判不过(fail-closed:读面对没有出处的 ref 一律 404)。
|
|
567
|
+
*/
|
|
568
|
+
export declare function toolResultRefOwned(store: ToolResultProvenanceReader | undefined, ref: string, run: Pick<RunRecord, "sessionId" | "taskId">): Promise<boolean>;
|
|
569
|
+
/**
|
|
570
|
+
* leader 登记表的请求口读(协议面 `run.leader`;`GET /v1/leader/:id` 与取消口,含取消口 CAS 输之后的重读):按 id 读一行,按交来的可见判
|
|
571
|
+
* (boot 装的 `seesRunAs("run.leader")`)判,看不见 ≡ 没有。驱动腿与旗读拍读本副本自己在驱动的行,不经这里。
|
|
572
|
+
*/
|
|
573
|
+
export declare function readVisibleLeaderRow<R extends {
|
|
574
|
+
readonly owner: string | null;
|
|
575
|
+
}>(store: {
|
|
576
|
+
getRun(id: string): Promise<R | undefined>;
|
|
577
|
+
}, id: string, visible: (owner: string | null) => boolean): Promise<R | undefined>;
|
|
578
|
+
/** 工作流按 id 四口的会话断言(受理相;`label` = 发过的日志字段 `face`;判法与 run 面同一只 {@link sessionAsserted})。列表口不判(摘要没有那一格)。 */
|
|
579
|
+
export declare const WORKFLOW_SESSION_ASSERTION: {
|
|
580
|
+
readonly "workflow-detail": {
|
|
581
|
+
readonly phase: "accept";
|
|
582
|
+
readonly label: "workflow.detail";
|
|
583
|
+
};
|
|
584
|
+
readonly "workflow-journal": {
|
|
585
|
+
readonly phase: "accept";
|
|
586
|
+
readonly label: "workflow.journal";
|
|
587
|
+
};
|
|
588
|
+
readonly "workflow-stream": {
|
|
589
|
+
readonly phase: "accept";
|
|
590
|
+
readonly label: "workflow.stream";
|
|
591
|
+
};
|
|
592
|
+
readonly "workflow-agent-steer": {
|
|
593
|
+
readonly phase: "accept";
|
|
594
|
+
readonly label: "workflow.agent-steer";
|
|
595
|
+
};
|
|
596
|
+
};
|
|
597
|
+
/** 工作流行的承认:门放过的那一行 + 调用方(换成引擎身份之后)对它持有的全部资格。 */
|
|
598
|
+
export interface WorkflowAdmission {
|
|
599
|
+
readonly row: WorkflowRun;
|
|
600
|
+
readonly quals: ReadonlySet<Qual>;
|
|
601
|
+
}
|
|
602
|
+
/** 工作流门的一次判(不下发):承认,或拒因(没有 / 前门 / 看不见 / 会话断言不符)。 */
|
|
603
|
+
export type WorkflowVerdict = WorkflowAdmission | "missing" | "door" | "not_visible" | "session_mismatch";
|
|
604
|
+
/**
|
|
605
|
+
* 工作流列表(`GET /v1/workflows`)—— 属主过滤只在这里落成店参数:调用方换成它的引擎身份(与 {@link judgeWorkflowRun} 同一只换算),店按 `scope` 列筛。
|
|
606
|
+
* 面表 `workflow.read` 只给属主(不放 fleet / 运维)⇒ 列表 = 调用方自己那一格的行。
|
|
607
|
+
*/
|
|
608
|
+
export declare function listVisibleWorkflows(entry: Entry, store: Pick<WorkflowRunStore, "listByScope">, opts: Parameters<WorkflowRunStore["listByScope"]>[1]): ReturnType<WorkflowRunStore["listByScope"]>;
|
|
609
|
+
/**
|
|
610
|
+
* 🔴 **工作流行的判(唯一一处;[ref] 第二阶段)**:按 id 读一行(店的 `get`,不带 scope —— 修前是 core 按 scope 读 + 路由再比一次 scope,两读答同一问),
|
|
611
|
+
* 行格 = `scope` 列的属主键(引擎写下的引擎身份,恒有主);调用方一侧换成它的引擎身份(`engine-identity.ts` 的 `engineScopeOf`:引擎按它写 scope ——
|
|
612
|
+
* 带场景的请求是那个人,匿名是 `"default"`)再过事实函数 {@link qualsOf} + 面表;前门按这次请求的调用方判。承认之后按 {@link WORKFLOW_SESSION_ASSERTION} 判会话断言。
|
|
613
|
+
*/
|
|
614
|
+
export declare function judgeWorkflowRun(entry: Entry, store: Pick<WorkflowRunStore, "get">, runId: string): Promise<WorkflowVerdict>;
|
|
615
|
+
/** 工作流按 id 读面的门:没有 / 看不见 / 会话断言不符同一只投影(`workflow_missing`),前门经它的下发口。交回承认或 `undefined`(已应答)。 */
|
|
616
|
+
export declare function admitWorkflowRun(entry: Entry, res: ServerResponse, store: Pick<WorkflowRunStore, "get">, runId: string): Promise<WorkflowAdmission | undefined>;
|
|
617
|
+
/** 删除门读的会话店:头读在场(能力事实 `sessionDelete` 的见证)+ 店可交的删除门头读与 placed 位问询。 */
|
|
618
|
+
export type DeletionGateStore = SessionGateStore & Pick<OwnerAwareSessionStore, "deletionHeadOf">;
|
|
619
|
+
/**
|
|
620
|
+
* 会话删除门(`DELETE /v1/sessions/:id`):读的头是删除门那一只(`session-incarnation.ts` 的 `deletionHeadReadOf`:local 店删到一半的行 —— 读者早已读作不在 —— 也答得出
|
|
621
|
+
* 开始删它的那位属主:那位重发收得完,别人得到与「不在」同一句;别的店 = `headOf`,与协调器围栏读同一只),行格的 placed 位问询 = 店自己的那一只(绑好宿主)。其余同 {@link admitSessionById}。
|
|
622
|
+
*/
|
|
623
|
+
export declare function admitSessionForDeletion(entry: Entry, res: ServerResponse, store: DeletionGateStore, sessionId: string): Promise<Admitted<SessionHead> | undefined>;
|
|
400
624
|
export {};
|
|
401
625
|
//# sourceMappingURL=owner-access.d.ts.map
|