UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

62 lines (61 loc) • 2.44 kB
import { i as asOptionalObjectRecord } from "./record-coerce-CVPuDqcc.mjs"; import { l as getAgentRunContext, u as getAgentRunContextOwnership } from "./agent-run-registry-D7vkrqFT.mjs"; import { o as emitAgentEventForOwner, s as emitAgentEventForRunContext } from "./agent-events-BdfWYmot.mjs"; import { n as readNodePermissionDetails } from "./node-permissions-COlNEJge.mjs"; //#region src/gateway/server-methods/nodes.permission-missing.ts const CAPABILITY_NAMES = { notifications: "Notifications", accessibility: "Accessibility", eventPosting: "Event Posting", screenRecording: "Screen Recording", camera: "Camera", microphone: "Microphone", speechRecognition: "Speech Recognition", location: "Location", computerControl: "Computer Control", canvas: "Canvas" }; /** A native refusal belongs to the requesting run, never a payload-supplied session. */ function publishNodePermissionMissing(e) { const t = asOptionalObjectRecord(e.error); const n = t?.code === "PERMISSION_MISSING" ? readNodePermissionDetails(t.details) : void 0; if (!n) return; const r = { nodeId: e.nodeId, ...e.nodeName ? { nodeName: e.nodeName } : {}, command: e.command, ...n }; const i = e.agentRuntimeIdentity ?? e.client?.internal?.agentRuntimeIdentity; let a = false; if (i && e.context.validateAgentRuntimeApprovalAuthority?.(i) === true) { const e = i.operationalRunInstance.runId; const t = getAgentRunContext(e); const n = getAgentRunContextOwnership(e)?.exclusiveClaimId; if (t) { const e = { runId: i.operationalRunInstance.runId, lifecycleGeneration: i.delegatedAuthority.lifecycleGeneration, sessionKey: i.sessionKey, agentId: i.agentId, stream: "notice", data: { phase: "warning", kind: "permission_missing", permissionMissing: r } }; a = (n ? emitAgentEventForOwner(e, n) : emitAgentEventForRunContext(e, t)) && t.isControlUiVisible !== false; } } return { permissionMissing: r, message: [ `PERMISSION_MISSING: ${n.capabilities.map((e) => CAPABILITY_NAMES[e] ?? e).join(", ")} required on node ${e.nodeName ? `${e.nodeName} (${e.nodeId})` : e.nodeId} (${n.state}).`, a ? "The user has been shown a Grant card in the chat." : "Grant access in the OpenClaw Mac app: Settings → This Mac → Permissions.", "Do not retry until the user confirms that access has been granted." ].join(" ") }; } //#endregion export { publishNodePermissionMissing as t };