|
4 | 4 | type ExecutionIdentityAdmissionFacts, |
5 | 5 | } from "../audit/execution-identity-admission.js"; |
6 | 6 | import type { OpenClawConfig } from "../config/types.openclaw.js"; |
7 | | -import { captureAgentRunLifecycleGeneration } from "../infra/agent-events.js"; |
8 | | -import { createAgentExecutionAttribution } from "./agent-execution-attribution.js"; |
9 | | -import type { AgentCommandGatewayIngressOpts, AgentCommandOpts } from "./command/types.js"; |
| 7 | +import type { AgentCommandOpts } from "./command/types.js"; |
10 | 8 |
|
11 | 9 | type AgentCommandAdmissionIngress = ExecutionIdentityAdmissionFacts["ingress"]; |
12 | 10 |
|
@@ -55,74 +53,8 @@ function recordAgentCommandExecutionIdentity(params: { |
55 | 53 | ); |
56 | 54 | } |
57 | 55 |
|
58 | | -function resolveAgentCommandExecutionAttribution( |
59 | | - opts: AgentCommandOpts, |
60 | | - params: { |
61 | | - runId: string; |
62 | | - sessionKey?: string; |
63 | | - sessionId?: string; |
64 | | - sessionAgentId?: string; |
65 | | - }, |
66 | | -): { |
67 | | - attribution: NonNullable<AgentCommandOpts["executionAttribution"]>; |
68 | | - lifecycleGeneration: string; |
69 | | -} { |
70 | | - if (opts.executionAttribution && opts.executionAttribution.runId !== params.runId) { |
71 | | - throw new Error("Agent command execution attribution runId does not match the command runId."); |
72 | | - } |
73 | | - const lifecycleGeneration = |
74 | | - opts.executionAttribution?.lifecycleGeneration ?? |
75 | | - opts.lifecycleGeneration ?? |
76 | | - captureAgentRunLifecycleGeneration(params.runId); |
77 | | - return { |
78 | | - attribution: |
79 | | - opts.executionAttribution ?? |
80 | | - createAgentExecutionAttribution({ |
81 | | - runId: params.runId, |
82 | | - lifecycleGeneration, |
83 | | - sessionKey: params.sessionKey, |
84 | | - sessionId: params.sessionId, |
85 | | - agentId: params.sessionAgentId, |
86 | | - }), |
87 | | - lifecycleGeneration, |
88 | | - }; |
89 | | -} |
90 | | - |
91 | | -function replaceAgentCommandExecutionAttribution( |
92 | | - opts: AgentCommandOpts, |
93 | | - attribution: AgentCommandOpts["executionAttribution"], |
94 | | -): AgentCommandOpts { |
95 | | - return attribution === opts.executionAttribution |
96 | | - ? opts |
97 | | - : { ...opts, executionAttribution: attribution }; |
98 | | -} |
99 | | - |
100 | | -function prepareAgentCommandIngress( |
101 | | - opts: AgentCommandGatewayIngressOpts, |
102 | | - trustedAttribution: boolean, |
103 | | -): { |
104 | | - lifecycleGeneration: string; |
105 | | - opts: AgentCommandGatewayIngressOpts; |
106 | | -} { |
107 | | - const internalOpts: AgentCommandGatewayIngressOpts = trustedAttribution |
108 | | - ? opts |
109 | | - : { ...opts, executionAttribution: undefined }; |
110 | | - if (typeof internalOpts.allowModelOverride !== "boolean") { |
111 | | - throw new Error("allowModelOverride must be explicitly set for ingress agent runs."); |
112 | | - } |
113 | | - return { |
114 | | - lifecycleGeneration: |
115 | | - internalOpts.lifecycleGeneration ?? |
116 | | - captureAgentRunLifecycleGeneration(internalOpts.runId ?? ""), |
117 | | - opts: internalOpts, |
118 | | - }; |
119 | | -} |
120 | | - |
121 | 56 | export const executionIdentity = { |
122 | 57 | localIngress: LOCAL_CLI_ADMISSION_INGRESS, |
123 | | - prepareIngress: prepareAgentCommandIngress, |
124 | 58 | record: recordAgentCommandExecutionIdentity, |
125 | | - replaceAttribution: replaceAgentCommandExecutionAttribution, |
126 | | - resolveAttribution: resolveAgentCommandExecutionAttribution, |
127 | 59 | systemIngress, |
128 | 60 | }; |
0 commit comments