MCPcopy Create free account
hub / github.com/Work-Fisher/code-claw / launchRunRequest

Function launchRunRequest

tools/claw-launcher-ui/server.mjs:3331–3402  ·  view source on GitHub ↗
(request)

Source from the content-addressed store, hash-verified

3329}
3330
3331function launchRunRequest(request) {
3332 void Promise.resolve()
3333 .then(() => executeRunRequest(request))
3334 .catch(async error => {
3335 const message = formatUserFacingError(
3336 error instanceof Error ? error.message : String(error),
3337 )
3338 const timestamp = safeNow()
3339 const nextTranscript = [
3340 ...state.transcript,
3341 {
3342 id: createId('assistant-final'),
3343 role: 'assistant',
3344 entryType: 'assistant',
3345 title: 'Assistant',
3346 content: message,
3347 timestamp,
3348 streaming: false,
3349 isError: true,
3350 },
3351 ]
3352 trimArray(nextTranscript, 500)
3353
3354 const nextTimeline = [
3355 ...state.timeline,
3356 {
3357 id: createId('result'),
3358 kind: 'result',
3359 status: 'error',
3360 title: '运行失败',
3361 content: message,
3362 timestamp,
3363 },
3364 ]
3365 trimArray(nextTimeline, 300)
3366
3367 updateState(draft => {
3368 draft.status = draft.gateway.status === 'ready' ? 'ready' : 'idle'
3369 draft.run.status = 'idle'
3370 draft.run.endedAt = timestamp
3371 draft.run.exitCode = -1
3372 draft.run.lastResult = {
3373 totalCostUsd: null,
3374 numTurns: 0,
3375 }
3376 draft.transcript = nextTranscript
3377 draft.timeline = nextTimeline
3378 })
3379
3380 pushLog('ui', `运行启动失败:${message}`, 'error')
3381
3382 if (request.sessionId) {
3383 await saveAppSessionState({
3384 sessionId: request.sessionId,
3385 workspaceDir: request.workspaceDir,
3386 transcript: nextTranscript,
3387 toolCalls: state.toolCalls,
3388 timeline: nextTimeline,

Callers 1

startClawPromptFunction · 0.85

Calls 8

executeRunRequestFunction · 0.85
formatUserFacingErrorFunction · 0.85
safeNowFunction · 0.85
createIdFunction · 0.85
trimArrayFunction · 0.85
updateStateFunction · 0.85
pushLogFunction · 0.85
saveAppSessionStateFunction · 0.85

Tested by

no test coverage detected