Jelajahi Sumber

feat: 支持调试页编辑阶段输入

Developer 1 Minggu lalu
induk
melakukan
a1203cacb5
3 mengubah file dengan 31 tambahan dan 7 penghapusan
  1. TEMPAT SAMPAH
      dist.zip
  2. 3 2
      src/api/agent/index.js
  3. 28 5
      src/views/modules/agent/report-agent-debug.vue

TEMPAT SAMPAH
dist.zip


+ 3 - 2
src/api/agent/index.js

@@ -473,10 +473,11 @@ export function getReportPipelineDebug(reportId) {
   })
 }
 
-export function startReportPipelineDebugStage(reportId, stageNo) {
+export function startReportPipelineDebugStage(reportId, stageNo, data) {
   return request({
     url: `/core/report/pipeline/debug/${reportId}/stages/${stageNo}`,
-    method: 'post'
+    method: 'post',
+    data
   })
 }
 

+ 28 - 5
src/views/modules/agent/report-agent-debug.vue

@@ -2,7 +2,7 @@
   <div class="debug-page">
     <div class="page-title">报告智能体单步调试</div>
     <el-alert
-      title="该工具仅发起临时智能体调用,不会写入或覆盖正式报告的阶段状态、输入、输出和产物。"
+      title="每一步输入会优先使用本调试会话上一步的结果自动组装,仍可在发送前修改。临时调用不会覆盖正式报告数据。"
       type="warning"
       :closable="false"
       show-icon
@@ -48,8 +48,14 @@
 
         <el-alert v-if="stage.inputError" class="input-error" type="error" :closable="false" :title="`当前输入组装失败:${stage.inputError}`" />
         <el-collapse>
-          <el-collapse-item title="本次将发送的输入" name="current-input">
-            <pre v-if="stage.currentInput">{{ pretty(stage.currentInput) }}</pre>
+          <el-collapse-item title="本次将发送的输入(可编辑)" name="current-input">
+            <el-input
+              v-if="stage.currentInput"
+              v-model="inputDrafts[stage.stageNo]"
+              type="textarea"
+              :autosize="{ minRows: 12, maxRows: 22 }"
+              class="json-editor"
+            />
             <span v-else class="empty">当前阶段没有可组装的智能体输入。</span>
           </el-collapse-item>
           <el-collapse-item title="正式流程已保存的输入快照" name="saved-input">
@@ -96,7 +102,8 @@ export default {
       detail: null,
       job: null,
       runningStageNo: null,
-      pollTimer: null
+      pollTimer: null,
+      inputDrafts: {}
     }
   },
   computed: {
@@ -131,6 +138,10 @@ export default {
         const response = await getReportPipelineDebug(this.reportId)
         if (!response || response.code !== 0) return this.showError(response && response.msg)
         this.detail = response.data
+        this.inputDrafts = {}
+        this.detail.stages.forEach(stage => {
+          if (stage.currentInput) this.$set(this.inputDrafts, stage.stageNo, this.pretty(stage.currentInput.payload))
+        })
       } finally {
         this.loading = false
       }
@@ -139,7 +150,18 @@ export default {
       this.clearPoll()
       this.runningStageNo = stage.stageNo
       try {
-        const response = await startReportPipelineDebugStage(this.detail.reportId, stage.stageNo)
+        let payload
+        try {
+          payload = JSON.parse(this.inputDrafts[stage.stageNo])
+        } catch (error) {
+          this.runningStageNo = null
+          return this.showError('输入必须是合法的 JSON 对象')
+        }
+        if (!payload || Array.isArray(payload) || typeof payload !== 'object') {
+          this.runningStageNo = null
+          return this.showError('输入必须是 JSON 对象')
+        }
+        const response = await startReportPipelineDebugStage(this.detail.reportId, stage.stageNo, payload)
         if (!response || response.code !== 0) {
           this.runningStageNo = null
           return this.showError(response && response.msg)
@@ -190,6 +212,7 @@ export default {
 .agent-key { margin-left: 12px; color: #909399; font-size: 13px; }
 .input-error { margin: 14px 0; }
 pre { margin: 0; padding: 14px; max-height: 420px; overflow: auto; background: #1e293b; color: #e2e8f0; border-radius: 4px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
+.json-editor ::v-deep textarea { min-height: 280px !important; font-family: Consolas, Monaco, monospace; line-height: 1.5; }
 .empty { color: #909399; }
 .job-card p { font-size: 13px; color: #606266; word-break: break-all; }
 </style>