(workspaceId: string, run: DevToolsRun, metadataId?: string)
| 171 | } |
| 172 | |
| 173 | async createRun(workspaceId: string, run: DevToolsRun, metadataId?: string): Promise<void> { |
| 174 | if (!this.enabled) { |
| 175 | return; |
| 176 | } |
| 177 | |
| 178 | assert(workspaceId.trim().length > 0, "DevToolsService.createRun requires a workspaceId"); |
| 179 | assert(run.workspaceId === workspaceId, "DevToolsService.createRun run/workspace mismatch"); |
| 180 | |
| 181 | await this.ensureLoaded(workspaceId); |
| 182 | const data = this.getOrCreateWorkspaceData(workspaceId); |
| 183 | |
| 184 | // Apply queued run metadata (for example, effective tool policy) captured |
| 185 | // before the stream reached provider middleware. Lookup is keyed by request |
| 186 | // metadata ID so overlapping requests cannot overwrite each other. |
| 187 | const byWorkspace = this.pendingRunMetadata.get(workspaceId); |
| 188 | const normalizedMetadataId = metadataId?.trim(); |
| 189 | if (byWorkspace && normalizedMetadataId != null && normalizedMetadataId.length > 0) { |
| 190 | const pendingMetadata = byWorkspace.get(normalizedMetadataId); |
| 191 | if (pendingMetadata != null) { |
| 192 | Object.assign(run, pendingMetadata); |
| 193 | byWorkspace.delete(normalizedMetadataId); |
| 194 | } |
| 195 | |
| 196 | if (byWorkspace.size === 0) { |
| 197 | this.pendingRunMetadata.delete(workspaceId); |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | data.runs.set(run.id, run); |
| 202 | await this.appendToFile(workspaceId, { type: "run", run }); |
| 203 | |
| 204 | const summary = this.buildRunSummary(data, run.id); |
| 205 | this.emitWorkspaceEvent(workspaceId, { type: "run-created", run: summary }); |
| 206 | } |
| 207 | |
| 208 | async createStep(workspaceId: string, step: DevToolsStep): Promise<void> { |
| 209 | if (!this.enabled) { |
nothing calls this directly
no test coverage detected