@blueking/ai-blueking 2.2.0-beta.4 → 2.2.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55767,7 +55767,7 @@ var EZ = ["src"], DZ = {
55767
55767
  }
55768
55768
  };
55769
55769
  }, w2 = /* @__PURE__ */ function(e) {
55770
- return e.FlowAgentEnd = "flow_agent_end", e.FlowAgentResult = "flow_agent_result", e.FlowAgentStart = "flow_agent_start", e.FlowAgentUpdate = "flow_agent_update", e.KnowledgeRagEnd = "knowledge_rag_end", e.KnowledgeRagResult = "knowledge_rag_result", e.KnowledgeRagStart = "knowledge_rag_start", e.KnowledgeRagTextContent = "knowledge_rag_text_content", e.ReferenceDocument = "reference_document", e.TempMessage = "temp_message", e.ApprovalResult = "approval_result", e;
55770
+ return e.FlowAgentEnd = "flow_agent_end", e.FlowAgentResult = "flow_agent_result", e.FlowAgentStart = "flow_agent_start", e.FlowAgentUpdate = "flow_agent_update", e.FlowAgentRestart = "flow_agent_restart", e.KnowledgeRagEnd = "knowledge_rag_end", e.KnowledgeRagResult = "knowledge_rag_result", e.KnowledgeRagStart = "knowledge_rag_start", e.KnowledgeRagTextContent = "knowledge_rag_text_content", e.ReferenceDocument = "reference_document", e.TempMessage = "temp_message", e.ApprovalResult = "approval_result", e;
55771
55771
  }({}), T2 = /* @__PURE__ */ function(e) {
55772
55772
  return e.ActivityDelta = "ACTIVITY_DELTA", e.ActivitySnapshot = "ACTIVITY_SNAPSHOT", e.Custom = "CUSTOM", e.MessagesSnapshot = "MESSAGES_SNAPSHOT", e.Raw = "RAW", e.RunError = "RUN_ERROR", e.RunFinished = "RUN_FINISHED", e.RunStarted = "RUN_STARTED", e.StateDelta = "STATE_DELTA", e.StateSnapshot = "STATE_SNAPSHOT", e.StepFinished = "STEP_FINISHED", e.StepStarted = "STEP_STARTED", e.TextMessageChunk = "TEXT_MESSAGE_CHUNK", e.TextMessageContent = "TEXT_MESSAGE_CONTENT", e.TextMessageEnd = "TEXT_MESSAGE_END", e.TextMessageStart = "TEXT_MESSAGE_START", e.ThinkingEnd = "THINKING_END", e.ThinkingStart = "THINKING_START", e.ThinkingTextMessageContent = "THINKING_TEXT_MESSAGE_CONTENT", e.ThinkingTextMessageEnd = "THINKING_TEXT_MESSAGE_END", e.ThinkingTextMessageStart = "THINKING_TEXT_MESSAGE_START", e.ToolCallArgs = "TOOL_CALL_ARGS", e.ToolCallChunk = "TOOL_CALL_CHUNK", e.ToolCallEnd = "TOOL_CALL_END", e.ToolCallResult = "TOOL_CALL_RESULT", e.ToolCallStart = "TOOL_CALL_START", e;
55773
55773
  }({}), E2 = /* @__PURE__ */ function(e) {
@@ -55800,6 +55800,9 @@ var EZ = ["src"], DZ = {
55800
55800
  case w2.FlowAgentEnd:
55801
55801
  this.handleFlowAgentEndCustomEvent(e);
55802
55802
  break;
55803
+ case w2.FlowAgentRestart:
55804
+ this.handleFlowAgentRestartCustomEvent(e);
55805
+ break;
55803
55806
  case w2.ReferenceDocument:
55804
55807
  this.handleReferenceDocumentCustomEvent(e);
55805
55808
  break;
@@ -55839,6 +55842,12 @@ var EZ = ["src"], DZ = {
55839
55842
  });
55840
55843
  }
55841
55844
  }
55845
+ handleFlowAgentRestartCustomEvent(e) {
55846
+ let t = e.value;
55847
+ this.messageModule.list.value.forEach((e) => {
55848
+ e.role === f2.Activity && e.activityType === d2.FlowAgent && e.content[0].task_id === t[0].task_id && (e.status = p2.Streaming);
55849
+ });
55850
+ }
55842
55851
  handleFlowAgentResultCustomEvent(e) {
55843
55852
  let t = this.messageModule.getCurrentLoadingMessage();
55844
55853
  t && t.role === f2.Activity && t.activityType === d2.FlowAgent && (t.content = e.value);
@@ -55850,7 +55859,7 @@ var EZ = ["src"], DZ = {
55850
55859
  activityType: d2.FlowAgent,
55851
55860
  content: t.map((e) => ({
55852
55861
  nodes: {},
55853
- task_id: Number(e.task_id),
55862
+ task_id: e.task_id,
55854
55863
  task_name: "",
55855
55864
  task_outputs: [],
55856
55865
  task_state: E2.Created
@@ -56124,11 +56133,11 @@ var EZ = ["src"], DZ = {
56124
56133
  }, j2 = /* @__PURE__ */ function(e) {
56125
56134
  return e.Running = "running", e.Finished = "finished", e.Failed = "failed", e.Cancelled = "cancelled", e;
56126
56135
  }({}), M2 = (e, t) => {
56127
- let n = /* @__PURE__ */ R(null), r = /* @__PURE__ */ R(!1), i = /* @__PURE__ */ R(!1), a = t || new A2(), o = null, s = null, c = () => (r.value = !0, e.http?.agent.getAgentInfo().then((e) => {
56136
+ let n = /* @__PURE__ */ R(null), r = /* @__PURE__ */ R(!1), i = /* @__PURE__ */ R(!1), a = t || new A2(), o = null, s = null, c = null, l = () => (r.value = !0, e.http?.agent.getAgentInfo().then((e) => {
56128
56137
  n.value = e;
56129
56138
  }).finally(() => {
56130
56139
  r.value = !1;
56131
- })), l = (t, n) => {
56140
+ })), u = (t, n) => {
56132
56141
  let r = t.promptSetting?.content?.at(-1);
56133
56142
  r?.role === f2.Pause && e.message?.createAndPlusMessage({
56134
56143
  role: f2.Assistant,
@@ -56137,12 +56146,12 @@ var EZ = ["src"], DZ = {
56137
56146
  sessionCode: n,
56138
56147
  property: { extra: { pause: !0 } }
56139
56148
  });
56140
- }, u = (t, n, r, i) => e.http?.message.userOperation(t, n, r, i).then(() => {
56141
- n === h2.ApprovalCancel ? (h(), m(t)) : d({
56149
+ }, d = (t, n, r, i) => e.http?.message.userOperation(t, n, r, i).then(() => {
56150
+ n === h2.ApprovalCancel ? (g(), h(t)) : f({
56142
56151
  sessionCode: t,
56143
56152
  config: i
56144
56153
  });
56145
- }), d = async ({ sessionCode: t, url: n, config: r, resume: s, input: c, lastMessageId: l }) => {
56154
+ }), f = async ({ sessionCode: t, url: n, config: r, resume: s, input: c, lastMessageId: l }) => {
56146
56155
  a instanceof A2 && a.injectMessageModule(e.message), c && e.message?.list.value.push({
56147
56156
  role: f2.User,
56148
56157
  content: c,
@@ -56166,7 +56175,7 @@ var EZ = ["src"], DZ = {
56166
56175
  i.value = !1, a.onDone?.call(a), c && e.http?.message?.getMessages(t).then((t) => {
56167
56176
  let n = e.message?.list.value.findLast((e) => e.role === f2.User);
56168
56177
  n.id = t.findLast((e) => e.role === f2.User).id;
56169
- }), m(t);
56178
+ }), h(t);
56170
56179
  },
56171
56180
  onError: (e) => {
56172
56181
  i.value = !1, a.onError?.call(a, e);
@@ -56179,63 +56188,63 @@ var EZ = ["src"], DZ = {
56179
56188
  },
56180
56189
  ...r
56181
56190
  }).catch(() => {});
56182
- }, f = async (t, n, r, i, a) => {
56191
+ }, p = async (t, n, r, i, a) => {
56183
56192
  await e.message?.createAndPlusMessage({
56184
56193
  role: f2.User,
56185
56194
  content: t,
56186
56195
  status: p2.Complete,
56187
56196
  sessionCode: n,
56188
56197
  ...a && { property: a }
56189
- }), d({
56198
+ }), f({
56190
56199
  sessionCode: n,
56191
56200
  url: r,
56192
56201
  config: i
56193
56202
  });
56194
- }, p = (t, n, r) => {
56203
+ }, m = (t, n, r) => {
56195
56204
  if (e.session?.current.value?.status === j2.Running) {
56196
56205
  let i = e.message?.list.value.at(-1)?.id;
56197
- d({
56206
+ f({
56198
56207
  sessionCode: t,
56199
56208
  url: n,
56200
56209
  config: r,
56201
56210
  lastMessageId: i
56202
56211
  });
56203
56212
  }
56204
- }, m = (t) => {
56213
+ }, h = (t) => {
56205
56214
  let n = e.message?.list.value.at(-1), r = n?.content?.outcome?.type === D2.Interrupt ? n.content.outcome.interrupts.find((e) => [O2.Pending, O2.Draft].includes(e.metadata?.ticket?.status)) : void 0;
56206
- n?.role === f2.Interrupt && r && e.http?.session.isResumeSession(t).then((n) => {
56207
- n ? d({
56215
+ n?.role === f2.Interrupt && r && (g(), s = new AbortController(), e.http?.session.isResumeSession(t, { controller: s }).then((n) => {
56216
+ n ? f({
56208
56217
  sessionCode: t,
56209
56218
  resume: {
56210
56219
  interruptId: r.id,
56211
56220
  status: k2.Resolved
56212
56221
  }
56213
- }) : s = setTimeout(() => {
56214
- t === e.session?.current?.value?.sessionCode && m(t);
56215
- }, 3e4);
56216
- });
56217
- }, h = () => {
56218
- s &&= (clearTimeout(s), null);
56222
+ }) : c = setTimeout(() => {
56223
+ t === e.session?.current?.value?.sessionCode && h(t);
56224
+ }, 15e3);
56225
+ }));
56226
+ }, g = () => {
56227
+ clearTimeout(c), c = null, s?.abort?.(), s = null;
56219
56228
  };
56220
56229
  return {
56221
56230
  info: n,
56222
56231
  isInfoLoading: r,
56223
56232
  isChatting: i,
56224
- chat: f,
56225
- handleRole: l,
56233
+ chat: p,
56234
+ handleRole: u,
56226
56235
  resendMessage: async (t, n, r, i, a) => {
56227
56236
  let o = e.message?.list.value || [], s = o.findIndex((e) => String(e.id) === t);
56228
56237
  if (s === -1) throw Error(`Message not found: ${t}`);
56229
56238
  let c = o[s];
56230
56239
  if (c.role !== f2.User) throw Error("Can only resend user messages");
56231
- let l = c.content, u = c.property, f = r ?? l, p = o.slice(s), m = e.message?.deleteMessages(p), h = e.message?.createAndPlusMessage({
56240
+ let l = c.content, u = c.property, d = r ?? l, p = o.slice(s), m = e.message?.deleteMessages(p), h = e.message?.createAndPlusMessage({
56232
56241
  role: f2.User,
56233
- content: f,
56242
+ content: d,
56234
56243
  status: p2.Complete,
56235
56244
  sessionCode: n,
56236
56245
  ...u && { property: u }
56237
56246
  });
56238
- d({
56247
+ f({
56239
56248
  sessionCode: n,
56240
56249
  url: i,
56241
56250
  config: a
@@ -56243,19 +56252,19 @@ var EZ = ["src"], DZ = {
56243
56252
  console.error("[resendMessage] API error:", e);
56244
56253
  });
56245
56254
  },
56246
- resumeStreamingChat: p,
56255
+ resumeStreamingChat: m,
56247
56256
  abortChat: () => {
56248
56257
  o?.abort?.(), o = null;
56249
56258
  },
56250
56259
  stopChat: async (t) => e.http.message?.stopChat(t),
56251
- getAgentInfo: c,
56260
+ getAgentInfo: l,
56252
56261
  reset: (e) => {
56253
56262
  a = e || new A2(), n.value = null, r.value = !1;
56254
56263
  },
56255
- pollResumeSession: m,
56256
- clearLongPollTimer: h,
56257
- userOperationStreamRequest: u,
56258
- streamRequest: d
56264
+ pollResumeSession: h,
56265
+ clearLongPollTimer: g,
56266
+ userOperationStreamRequest: d,
56267
+ streamRequest: f
56259
56268
  };
56260
56269
  };
56261
56270
  //#endregion
@@ -56472,8 +56481,8 @@ var F2 = class {
56472
56481
  return l.data;
56473
56482
  } catch (e) {
56474
56483
  if (a && clearTimeout(a), e instanceof Error && e.name === "AbortError") {
56475
- let e = R2("Request timeout", r, "ECONNABORTED", void 0);
56476
- throw this.dispatchError(e), this.applyResponseErrorInterceptors(e);
56484
+ console.warn("User canceled request", e.message);
56485
+ return;
56477
56486
  }
56478
56487
  let t = e.isAxiosError === !0 ? e : R2(e.message, r, e.code, void 0);
56479
56488
  throw this.dispatchError(t), this.applyResponseErrorInterceptors(t);