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

Function executeRunRequest

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

Source from the content-addressed store, hash-verified

3063}
3064
3065async function executeRunRequest(request) {
3066 if (
3067 state.run.status === 'running' ||
3068 persistentHost?.activeTurn ||
3069 (clawChild && clawChild.exitCode === null)
3070 ) {
3071 throw new Error('当前已经有一个运行中的任务。')
3072 }
3073
3074 const { config, prompt } = request
3075 await saveConfig(config)
3076 const gatewayUrl = await ensureGateway(config)
3077 const workspaceDir = request.workspaceDir
3078 const runner = await resolveRunner(config)
3079 const model = config.clawModel || 'sonnet'
3080 const beforeClawSessions = await listSessions(workspaceDir)
3081 const beforeSessionIds = new Set(beforeClawSessions.map(item => item.sessionId))
3082 const fallbackPromptContext = await buildPromptWithCarryOver(state.transcript, prompt)
3083 const appSessionId =
3084 request.sessionId || state.sessions.selectedSessionId || state.run.sessionId || createId('session')
3085 const nextUserEntry = {
3086 id: createId('user'),
3087 role: 'user',
3088 entryType: 'user',
3089 title: 'You',
3090 content: prompt,
3091 timestamp: safeNow(),
3092 streaming: false,
3093 isError: false,
3094 }
3095 const nextTranscript = [...state.transcript, nextUserEntry]
3096 trimArray(nextTranscript, 500)
3097 const startedAt = safeNow()
3098 const nextTimeline = [
3099 ...state.timeline,
3100 {
3101 id: createId('start'),
3102 kind: 'status',
3103 status: 'running',
3104 title: 'claw-code 已启动',
3105 content: [
3106 `运行方式:${runner.label}`,
3107 `工作区:${workspaceDir}`,
3108 countConversationEntries(state.transcript) > 0
3109 ? '上下文延续:将优先沿用当前会话的历史上下文。'
3110 : '上下文延续:当前从新一轮开始。',
3111 ].join('\n'),
3112 timestamp: startedAt,
3113 },
3114 ]
3115 trimArray(nextTimeline, 300)
3116 const contextMessageCount = countConversationEntries(nextTranscript)
3117
3118 const args = [
3119 ...runner.args,
3120 '--model',
3121 model,
3122 '--permission-mode',

Callers 3

pumpRunQueueFunction · 0.85
approvePendingRunFunction · 0.85
launchRunRequestFunction · 0.85

Calls 15

saveConfigFunction · 0.85
ensureGatewayFunction · 0.85
resolveRunnerFunction · 0.85
listSessionsFunction · 0.85
buildPromptWithCarryOverFunction · 0.85
createIdFunction · 0.85
safeNowFunction · 0.85
trimArrayFunction · 0.85
countConversationEntriesFunction · 0.85
updateStateFunction · 0.85
saveAppSessionStateFunction · 0.85
listAppSessionsFunction · 0.85

Tested by

no test coverage detected