wi-chat 0.5.0 → 0.6.0
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.
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.js +34 -34
- package/dist/core/useChat.d.ts +6 -6
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +99 -94
- package/dist/mobile-ui/index.cjs +1 -1
- package/dist/mobile-ui/index.d.ts +1 -1
- package/dist/mobile-ui/index.js +88 -81
- package/dist/mobile-ui/style.css +1 -1
- package/dist/parser/answerCom/actionExecute/actionProtocol.d.ts +27 -0
- package/dist/parser/answerCom/actionExecute/parseAgentAction.d.ts +25 -0
- package/dist/parser/answerCom/actionExecute/parseCollectClarifications.d.ts +26 -0
- package/dist/parser/answerCom/actionExecute/reply.d.ts +17 -0
- package/dist/parser/answerCom/actionExecute/types.d.ts +26 -5
- package/dist/parser/index.cjs +2 -2
- package/dist/parser/index.d.ts +7 -5
- package/dist/parser/index.js +360 -294
- package/dist/parser/registry.d.ts +5 -5
- package/dist/renderers/agentAction/AgentActionStatus.vue.d.ts +19 -0
- package/dist/renderers/index.cjs +1 -1
- package/dist/renderers/index.d.ts +1 -0
- package/dist/renderers/index.js +523 -477
- package/dist/renderers/style.css +1 -1
- package/dist/tools/index.cjs +4 -4
- package/dist/tools/index.js +176 -161
- package/dist/tools/useAutoScroll.d.ts +11 -3
- package/dist/web-ui/index.cjs +1 -1
- package/dist/web-ui/index.d.ts +1 -1
- package/dist/web-ui/index.js +309 -303
- package/dist/web-ui/style.css +1 -1
- package/package.json +1 -1
- package/dist/parser/answerCom/actionExecute/parseActionExecute.d.ts +0 -28
package/dist/mobile-ui/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { provideOutputFileConfig as
|
|
2
|
-
import { AiAnswerBubble as
|
|
3
|
-
import { defineComponent as C, openBlock as i, createElementBlock as n, createVNode as f, unref as c, withKeys as
|
|
4
|
-
import { Field as
|
|
5
|
-
import { useAutoScroll as
|
|
6
|
-
const
|
|
1
|
+
import { provideOutputFileConfig as q, createAnswerContentMap as $, DeepThinkingSteps as x, AiAnswerBubble as P } from "wi-chat/renderers";
|
|
2
|
+
import { AgentActionStatus as ke, AiAnswerBubble as ve, ClarificationCard as Ce, DeepThinkingSteps as Te, IframePage as Ie, KnowledgeStreamResult as Se, OutputFile as Be, createAnswerContentMap as Ee, injectIframeResizerChild as Ae, provideIframePageConfig as Ve, provideOutputFileConfig as Fe, resolveIframePlaceholders as Oe, useIframePage as De } from "wi-chat/renderers";
|
|
3
|
+
import { defineComponent as C, openBlock as i, createElementBlock as n, createVNode as f, unref as c, withKeys as U, withModifiers as K, withCtx as O, createTextVNode as N, toDisplayString as y, ref as z, computed as L, watch as A, createElementVNode as _, createCommentVNode as k, Fragment as v, renderList as V, Transition as R, pushScopeId as j, popScopeId as W, renderSlot as F } from "vue";
|
|
4
|
+
import { Field as G, Button as H } from "vant";
|
|
5
|
+
import { useAutoScroll as J } from "wi-chat/tools";
|
|
6
|
+
const Q = { class: "wi-mobile-inputbox" }, X = /* @__PURE__ */ C({
|
|
7
7
|
__name: "Inputbox",
|
|
8
8
|
props: {
|
|
9
9
|
modelValue: { default: "" },
|
|
@@ -18,35 +18,35 @@ const J = { class: "wi-mobile-inputbox" }, Q = /* @__PURE__ */ C({
|
|
|
18
18
|
},
|
|
19
19
|
emits: ["update:modelValue", "submit", "stop"],
|
|
20
20
|
setup(l, { emit: u }) {
|
|
21
|
-
const o = l, t = u,
|
|
21
|
+
const o = l, t = u, r = () => {
|
|
22
22
|
if (o.talking) {
|
|
23
23
|
t("stop");
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
26
|
o.disabled || o.disabledSend || t("submit");
|
|
27
27
|
}, g = (e) => {
|
|
28
|
-
e.isComposing || e.keyCode === 229 || !o.enterExact || o.talking || (e.preventDefault(),
|
|
28
|
+
e.isComposing || e.keyCode === 229 || !o.enterExact || o.talking || (e.preventDefault(), r());
|
|
29
29
|
};
|
|
30
|
-
return (e, a) => (i(), n("div",
|
|
31
|
-
f(c(
|
|
30
|
+
return (e, a) => (i(), n("div", Q, [
|
|
31
|
+
f(c(G), {
|
|
32
32
|
"model-value": e.modelValue,
|
|
33
33
|
type: "textarea",
|
|
34
34
|
rows: "2",
|
|
35
35
|
autosize: "",
|
|
36
36
|
placeholder: e.placeholder,
|
|
37
37
|
disabled: e.disabled,
|
|
38
|
-
"onUpdate:modelValue": a[0] || (a[0] = (
|
|
39
|
-
onKeydown:
|
|
38
|
+
"onUpdate:modelValue": a[0] || (a[0] = (p) => t("update:modelValue", String(p ?? ""))),
|
|
39
|
+
onKeydown: U(K(g, ["exact"]), ["enter"])
|
|
40
40
|
}, null, 8, ["model-value", "placeholder", "disabled", "onKeydown"]),
|
|
41
|
-
f(c(
|
|
41
|
+
f(c(H), {
|
|
42
42
|
class: "wi-mobile-inputbox__btn",
|
|
43
43
|
type: e.talking ? "danger" : e.buttonType,
|
|
44
44
|
size: "small",
|
|
45
45
|
disabled: e.disabled,
|
|
46
|
-
onClick:
|
|
46
|
+
onClick: r
|
|
47
47
|
}, {
|
|
48
|
-
default:
|
|
49
|
-
|
|
48
|
+
default: O(() => [
|
|
49
|
+
N(y(e.talking ? e.stopText : e.submitText), 1)
|
|
50
50
|
]),
|
|
51
51
|
_: 1
|
|
52
52
|
}, 8, ["type", "disabled"])
|
|
@@ -54,25 +54,25 @@ const J = { class: "wi-mobile-inputbox" }, Q = /* @__PURE__ */ C({
|
|
|
54
54
|
}
|
|
55
55
|
}), T = (l, u) => {
|
|
56
56
|
const o = l.__vccOpts || l;
|
|
57
|
-
for (const [t,
|
|
58
|
-
o[t] =
|
|
57
|
+
for (const [t, r] of u)
|
|
58
|
+
o[t] = r;
|
|
59
59
|
return o;
|
|
60
|
-
},
|
|
60
|
+
}, Y = /* @__PURE__ */ T(X, [["__scopeId", "data-v-02f9c6a0"]]), Z = (l) => (j("data-v-04e966f6"), l = l(), W(), l), ee = {
|
|
61
61
|
key: 0,
|
|
62
62
|
class: "wi-mobile-chat-messages__loading"
|
|
63
|
-
},
|
|
63
|
+
}, te = {
|
|
64
64
|
key: 1,
|
|
65
65
|
class: "wi-mobile-chat-messages__empty"
|
|
66
|
-
},
|
|
66
|
+
}, se = /* @__PURE__ */ Z(() => /* @__PURE__ */ _("div", { class: "wi-mobile-chat-messages__empty-logo" }, "WI", -1)), oe = { class: "wi-mobile-chat-messages__empty-title" }, ae = { class: "wi-mobile-chat-messages__empty-description" }, ie = {
|
|
67
67
|
key: 0,
|
|
68
68
|
class: "wi-mobile-chat-messages__user"
|
|
69
|
-
},
|
|
69
|
+
}, ne = { class: "wi-mobile-chat-messages__user-wrapper" }, le = {
|
|
70
70
|
key: 0,
|
|
71
71
|
class: "wi-mobile-chat-messages__attachments"
|
|
72
|
-
},
|
|
72
|
+
}, de = { class: "wi-mobile-chat-messages__user-bubble" }, re = {
|
|
73
73
|
key: 1,
|
|
74
74
|
class: "wi-mobile-chat-messages__assistant"
|
|
75
|
-
},
|
|
75
|
+
}, pe = /* @__PURE__ */ C({
|
|
76
76
|
__name: "ChatMessagesView",
|
|
77
77
|
props: {
|
|
78
78
|
messages: { default: () => [] },
|
|
@@ -84,71 +84,77 @@ const J = { class: "wi-mobile-inputbox" }, Q = /* @__PURE__ */ C({
|
|
|
84
84
|
},
|
|
85
85
|
emits: ["loadOlder", "updateThinkingExpanded"],
|
|
86
86
|
setup(l, { expose: u, emit: o }) {
|
|
87
|
-
var
|
|
88
|
-
const t = l,
|
|
89
|
-
|
|
90
|
-
const g =
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
var B, E;
|
|
88
|
+
const t = l, r = o;
|
|
89
|
+
q(t.outputFileConfig ?? {});
|
|
90
|
+
const g = z(), { showScrollToBottom: e, forceScrollToBottom: a, requestScrollToBottom: p, resetScrollState: w, onReachTop: D } = J(g), M = L(() => $(t.parsers));
|
|
91
|
+
A(
|
|
92
|
+
() => t.messages.length === 0,
|
|
93
|
+
(d) => {
|
|
94
|
+
d && w();
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
let I = ((B = t.messages[0]) == null ? void 0 : B.id) ?? "", S = ((E = t.messages[t.messages.length - 1]) == null ? void 0 : E.id) ?? "";
|
|
98
|
+
return A(
|
|
93
99
|
() => t.messages,
|
|
94
100
|
() => {
|
|
95
|
-
var
|
|
96
|
-
const
|
|
97
|
-
I =
|
|
101
|
+
var b, m;
|
|
102
|
+
const d = ((b = t.messages[0]) == null ? void 0 : b.id) ?? "", h = ((m = t.messages[t.messages.length - 1]) == null ? void 0 : m.id) ?? "", s = d !== I && h === S;
|
|
103
|
+
I = d, S = h, !s && p();
|
|
98
104
|
},
|
|
99
105
|
{ deep: !0 }
|
|
100
|
-
),
|
|
106
|
+
), D(() => r("loadOlder")), u({
|
|
101
107
|
/** 强制滚动到底部 */
|
|
102
108
|
forceScrollToBottom: a,
|
|
103
109
|
/** 自动滚动开启时请求滚动到底部 */
|
|
104
|
-
requestScrollToBottom:
|
|
105
|
-
}), (
|
|
110
|
+
requestScrollToBottom: p
|
|
111
|
+
}), (d, h) => (i(), n("div", {
|
|
106
112
|
ref_key: "scrollEl",
|
|
107
113
|
ref: g,
|
|
108
114
|
class: "wi-mobile-chat-messages"
|
|
109
115
|
}, [
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
_("div",
|
|
113
|
-
_("div",
|
|
116
|
+
d.loading ? (i(), n("div", ee, "历史加载中...")) : d.messages.length === 0 ? (i(), n("div", te, [
|
|
117
|
+
se,
|
|
118
|
+
_("div", oe, y(d.emptyTitle), 1),
|
|
119
|
+
_("div", ae, y(d.emptyDescription), 1)
|
|
114
120
|
])) : k("", !0),
|
|
115
|
-
(i(!0), n(v, null, V(
|
|
116
|
-
var
|
|
121
|
+
(i(!0), n(v, null, V(d.messages, (s) => {
|
|
122
|
+
var b;
|
|
117
123
|
return i(), n(v, {
|
|
118
124
|
key: s.id
|
|
119
125
|
}, [
|
|
120
|
-
s.role === "user" ? (i(), n("div",
|
|
121
|
-
_("div",
|
|
122
|
-
(
|
|
126
|
+
s.role === "user" ? (i(), n("div", ie, [
|
|
127
|
+
_("div", ne, [
|
|
128
|
+
(b = s.attachments) != null && b.length ? (i(), n("div", le, [
|
|
123
129
|
(i(!0), n(v, null, V(s.attachments, (m) => (i(), n("span", {
|
|
124
130
|
key: m.name,
|
|
125
131
|
class: "wi-mobile-chat-messages__attachment"
|
|
126
132
|
}, y(m.name), 1))), 128))
|
|
127
133
|
])) : k("", !0),
|
|
128
|
-
_("div",
|
|
134
|
+
_("div", de, y(s.content), 1)
|
|
129
135
|
])
|
|
130
|
-
])) : (i(), n("div",
|
|
131
|
-
f(c(
|
|
136
|
+
])) : (i(), n("div", re, [
|
|
137
|
+
f(c(x), {
|
|
132
138
|
steps: s.thinking.steps,
|
|
133
139
|
expanded: s.thinking.expanded,
|
|
134
|
-
"onUpdate:expanded": (m) =>
|
|
140
|
+
"onUpdate:expanded": (m) => r("updateThinkingExpanded", s, m)
|
|
135
141
|
}, null, 8, ["steps", "expanded", "onUpdate:expanded"]),
|
|
136
|
-
f(c(
|
|
142
|
+
f(c(P), {
|
|
137
143
|
answer: s.answer,
|
|
138
144
|
error: s.error,
|
|
139
145
|
stopped: s.stopped,
|
|
140
|
-
"content-map":
|
|
146
|
+
"content-map": M.value
|
|
141
147
|
}, null, 8, ["answer", "error", "stopped", "content-map"])
|
|
142
148
|
]))
|
|
143
149
|
], 64);
|
|
144
150
|
}), 128)),
|
|
145
|
-
f(
|
|
146
|
-
default:
|
|
151
|
+
f(R, { name: "wi-mobile-chat-messages-fade" }, {
|
|
152
|
+
default: O(() => [
|
|
147
153
|
c(e) ? (i(), n("button", {
|
|
148
154
|
key: 0,
|
|
149
155
|
type: "button",
|
|
150
156
|
class: "wi-mobile-chat-messages__bottom",
|
|
151
|
-
onClick:
|
|
157
|
+
onClick: h[0] || (h[0] = //@ts-ignore
|
|
152
158
|
(...s) => c(a) && c(a)(...s))
|
|
153
159
|
}, " 回到底部 ")) : k("", !0)
|
|
154
160
|
]),
|
|
@@ -156,7 +162,7 @@ const J = { class: "wi-mobile-inputbox" }, Q = /* @__PURE__ */ C({
|
|
|
156
162
|
})
|
|
157
163
|
], 512));
|
|
158
164
|
}
|
|
159
|
-
}),
|
|
165
|
+
}), ue = /* @__PURE__ */ T(pe, [["__scopeId", "data-v-04e966f6"]]), me = { class: "wi-mobile-chat-container" }, ce = /* @__PURE__ */ C({
|
|
160
166
|
__name: "ChatContainer",
|
|
161
167
|
props: {
|
|
162
168
|
messages: { default: () => [] },
|
|
@@ -174,53 +180,54 @@ const J = { class: "wi-mobile-inputbox" }, Q = /* @__PURE__ */ C({
|
|
|
174
180
|
},
|
|
175
181
|
emits: ["update:question", "submit", "stop", "loadOlder", "updateThinkingExpanded"],
|
|
176
182
|
setup(l, { emit: u }) {
|
|
177
|
-
const o = l, t = u,
|
|
183
|
+
const o = l, t = u, r = () => {
|
|
178
184
|
o.hasMore && t("loadOlder");
|
|
179
185
|
}, g = () => {
|
|
180
186
|
t("submit", { text: o.question });
|
|
181
187
|
};
|
|
182
|
-
return (e, a) => (i(), n("section",
|
|
183
|
-
|
|
184
|
-
f(
|
|
188
|
+
return (e, a) => (i(), n("section", me, [
|
|
189
|
+
F(e.$slots, "messages", {}, () => [
|
|
190
|
+
f(ue, {
|
|
185
191
|
messages: e.messages,
|
|
186
192
|
parsers: e.parsers,
|
|
187
193
|
"output-file-config": e.outputFileConfig,
|
|
188
194
|
loading: e.loading,
|
|
189
195
|
"empty-title": e.emptyTitle,
|
|
190
196
|
"empty-description": e.emptyDescription,
|
|
191
|
-
onLoadOlder:
|
|
192
|
-
onUpdateThinkingExpanded: a[0] || (a[0] = (
|
|
197
|
+
onLoadOlder: r,
|
|
198
|
+
onUpdateThinkingExpanded: a[0] || (a[0] = (p, w) => t("updateThinkingExpanded", p, w))
|
|
193
199
|
}, null, 8, ["messages", "parsers", "output-file-config", "loading", "empty-title", "empty-description"])
|
|
194
200
|
], !0),
|
|
195
|
-
|
|
196
|
-
f(
|
|
201
|
+
F(e.$slots, "above-input", {}, void 0, !0),
|
|
202
|
+
f(Y, {
|
|
197
203
|
"model-value": e.question,
|
|
198
204
|
placeholder: e.placeholder,
|
|
199
205
|
disabled: e.disabled || !e.session,
|
|
200
206
|
"disabled-send": !e.question.trim(),
|
|
201
207
|
talking: e.talking,
|
|
202
|
-
"onUpdate:modelValue": a[1] || (a[1] = (
|
|
208
|
+
"onUpdate:modelValue": a[1] || (a[1] = (p) => t("update:question", p)),
|
|
203
209
|
onSubmit: g,
|
|
204
|
-
onStop: a[2] || (a[2] = (
|
|
210
|
+
onStop: a[2] || (a[2] = (p) => t("stop"))
|
|
205
211
|
}, null, 8, ["model-value", "placeholder", "disabled", "disabled-send", "talking"])
|
|
206
212
|
]));
|
|
207
213
|
}
|
|
208
|
-
}),
|
|
214
|
+
}), ye = /* @__PURE__ */ T(ce, [["__scopeId", "data-v-9bd22d00"]]);
|
|
209
215
|
export {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
Be as
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
Ve as
|
|
223
|
-
|
|
224
|
-
|
|
216
|
+
ke as AgentActionStatus,
|
|
217
|
+
ve as AiAnswerBubble,
|
|
218
|
+
ye as ChatContainer,
|
|
219
|
+
ue as ChatMessagesView,
|
|
220
|
+
Ce as ClarificationCard,
|
|
221
|
+
Te as DeepThinkingSteps,
|
|
222
|
+
Ie as IframePage,
|
|
223
|
+
Y as Inputbox,
|
|
224
|
+
Se as KnowledgeStreamResult,
|
|
225
|
+
Be as OutputFile,
|
|
226
|
+
Ee as createAnswerContentMap,
|
|
227
|
+
Ae as injectIframeResizerChild,
|
|
228
|
+
Ve as provideIframePageConfig,
|
|
229
|
+
Fe as provideOutputFileConfig,
|
|
230
|
+
Oe as resolveIframePlaceholders,
|
|
231
|
+
De as useIframePage
|
|
225
232
|
};
|
|
226
233
|
//# sourceMappingURL=index.js.map
|
package/dist/mobile-ui/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.wi-mobile-inputbox[data-v-02f9c6a0]{display:flex;align-items:flex-end;gap:8px;padding:10px 12px;border-top:1px solid var(--wi-chat-border, #e1e4e8);background:#f7f8fa}.wi-mobile-inputbox[data-v-02f9c6a0] .van-field__control{font-size:14px;line-height:1.75}.wi-mobile-inputbox__btn[data-v-02f9c6a0]{flex-shrink:0}.wi-mobile-chat-messages[data-v-
|
|
1
|
+
.wi-mobile-inputbox[data-v-02f9c6a0]{display:flex;align-items:flex-end;gap:8px;padding:10px 12px;border-top:1px solid var(--wi-chat-border, #e1e4e8);background:#f7f8fa}.wi-mobile-inputbox[data-v-02f9c6a0] .van-field__control{font-size:14px;line-height:1.75}.wi-mobile-inputbox__btn[data-v-02f9c6a0]{flex-shrink:0}.wi-mobile-chat-messages[data-v-04e966f6]{position:relative;flex:1;min-height:0;overflow-y:auto;padding:14px 12px;background:#f5f7fb;-webkit-overflow-scrolling:touch}.wi-mobile-chat-messages__loading[data-v-04e966f6],.wi-mobile-chat-messages__empty[data-v-04e966f6]{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:8px;color:#8a93a6;font-size:13px}.wi-mobile-chat-messages__empty-logo[data-v-04e966f6]{display:flex;align-items:center;justify-content:center;width:52px;height:52px;border-radius:16px;background:linear-gradient(135deg,var(--wi-chat-primary),color-mix(in srgb,var(--wi-chat-primary) 55%,#7b61ff));color:#fff;font-size:19px;font-weight:700}.wi-mobile-chat-messages__empty-title[data-v-04e966f6]{color:#2c3653;font-size:16px;font-weight:600}.wi-mobile-chat-messages__user[data-v-04e966f6]{display:flex;justify-content:flex-end;margin:12px 0}.wi-mobile-chat-messages__user-wrapper[data-v-04e966f6]{display:flex;flex-direction:column;align-items:flex-end;max-width:86%;gap:6px}.wi-mobile-chat-messages__attachments[data-v-04e966f6]{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:6px}.wi-mobile-chat-messages__attachment[data-v-04e966f6]{max-width:100%;padding:4px 8px;border:1px solid #dfe4ee;border-radius:6px;background:#fff;color:#53617c;font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wi-mobile-chat-messages__user-bubble[data-v-04e966f6]{max-width:100%;padding:9px 12px;border-radius:14px 4px 14px 14px;background:var(--wi-chat-primary);color:#fff;font-size:14px;line-height:1.65;white-space:pre-wrap;word-break:break-word}.wi-mobile-chat-messages__assistant[data-v-04e966f6]{width:fit-content;max-width:100%;margin:12px 0;padding:10px 11px;border:1px solid #e7eaf2;border-radius:4px 12px 12px;background:#fff;box-shadow:0 4px 14px #3137570d;color:#27344d;font-size:14px;line-height:1.7;word-break:break-word}.wi-mobile-chat-messages__bottom[data-v-04e966f6]{position:sticky;bottom:10px;left:100%;padding:5px 12px;border:1px solid #e1e4e8;border-radius:999px;background:#fff;box-shadow:0 4px 12px #31375724;color:#53617c;font-size:12px}.wi-mobile-chat-messages-fade-enter-active[data-v-04e966f6],.wi-mobile-chat-messages-fade-leave-active[data-v-04e966f6]{transition:opacity .2s ease}.wi-mobile-chat-messages-fade-enter-from[data-v-04e966f6],.wi-mobile-chat-messages-fade-leave-to[data-v-04e966f6]{opacity:0}.wi-mobile-chat-container[data-v-9bd22d00]{display:flex;flex-direction:column;height:100%;min-height:0;background:#f5f7fb}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { StreamChunk } from '../../sse';
|
|
1
2
|
import { ActionExecuteCommand, ActionResult, ActionDefinition } from './types';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -36,3 +37,29 @@ export declare const wrapActionFrame: (frame: unknown) => ActionResult;
|
|
|
36
37
|
* @returns 仅含 name / arguments 的 Action
|
|
37
38
|
*/
|
|
38
39
|
export declare const normalizeActionDefinition: (action: ActionDefinition) => ActionDefinition;
|
|
40
|
+
/**
|
|
41
|
+
* front_reply 帧内 action_execute 指令的读取结果(三态,供各 parser 精确分流):
|
|
42
|
+
* - `ignored`:不是本协议(mode 不是 front_reply / type 不是 action_execute)→ parser 应 `return false`;
|
|
43
|
+
* - `invalid`:是 action_execute 但字段非法 → 由负责该执行端的 parser 回失败帧;
|
|
44
|
+
* - `ok`:解析成功,parser 再按 executor / action.name 判断是否自己负责。
|
|
45
|
+
*/
|
|
46
|
+
export type FrontReplyActionResult = {
|
|
47
|
+
kind: 'ignored';
|
|
48
|
+
} | {
|
|
49
|
+
kind: 'invalid';
|
|
50
|
+
error: Error;
|
|
51
|
+
replyId?: string | number;
|
|
52
|
+
} | {
|
|
53
|
+
kind: 'ok';
|
|
54
|
+
command: ActionExecuteCommand;
|
|
55
|
+
replyId?: string | number;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* 读取 front_reply 帧里的 action_execute 指令(只做通用协议解析,不做业务筛选)。
|
|
59
|
+
*
|
|
60
|
+
* 严格按 `type === 'action_execute'` 认领:其它 front_reply 载荷(别的业务回包)
|
|
61
|
+
* 一律 `ignored`,确保 `front_reply` 通道还能被其它场景复用。
|
|
62
|
+
* @param chunk 流式数据块
|
|
63
|
+
* @returns 三态读取结果(见 FrontReplyActionResult)
|
|
64
|
+
*/
|
|
65
|
+
export declare const readFrontReplyAction: (chunk: StreamChunk) => FrontReplyActionResult;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AiAnswerReport } from '../../answer';
|
|
2
|
+
import { AnswerParser, AnswerParseOptions } from '../../registry';
|
|
3
|
+
import { StreamChunk } from '../../sse';
|
|
4
|
+
import { AgentActionValue } from './types';
|
|
5
|
+
|
|
6
|
+
/** agent 指令执行过程的回答类型(也是历史 report 的分发键) */
|
|
7
|
+
export declare const AGENT_ACTION_ANSWER_TYPE = "agent_action";
|
|
8
|
+
/**
|
|
9
|
+
* 处理实时流中的 agent 指令
|
|
10
|
+
* @param chunk 流式数据块
|
|
11
|
+
* @param reports 回答 reports 数组(registry 预取的同一引用,push 即累积)
|
|
12
|
+
* @param answerValues 回答整体结构(本 parser 不使用)
|
|
13
|
+
* @param options 解析配置(actionExecute 提供宿主执行器与回包通道)
|
|
14
|
+
* @returns 是否消费了该 chunk(只在自己负责的组合上返回 true)
|
|
15
|
+
*/
|
|
16
|
+
export declare const applyAgentActionChunk: (chunk: StreamChunk, reports: AiAnswerReport<any>[], _answerValues?: unknown, options?: AnswerParseOptions) => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* 历史归一化:历史里的执行过程卡片已无法确认执行结果,running 统一标为未知。
|
|
19
|
+
* @param report 历史 reports 中的执行过程报告(就地修改)
|
|
20
|
+
*/
|
|
21
|
+
export declare const normalizeAgentActionReport: (report: AiAnswerReport<AgentActionValue>) => void;
|
|
22
|
+
/**
|
|
23
|
+
* agent_action 答案类型的注册表条目(registry 内置)
|
|
24
|
+
*/
|
|
25
|
+
export declare const agentActionParser: AnswerParser<AgentActionValue>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AiAnswerReport } from '../../answer';
|
|
2
|
+
import { AnswerParser, AnswerParseOptions } from '../../registry';
|
|
3
|
+
import { StreamChunk } from '../../sse';
|
|
4
|
+
import { ClarificationViewModel } from './types';
|
|
5
|
+
|
|
6
|
+
/** 确认卡片的回答类型(也是历史 report 的分发键) */
|
|
7
|
+
export declare const COLLECT_CLARIFICATIONS_ANSWER_TYPE = "collect_clarifications";
|
|
8
|
+
/**
|
|
9
|
+
* 处理实时流中的确认项指令
|
|
10
|
+
* @param chunk 流式数据块
|
|
11
|
+
* @param reports 回答 reports 数组(registry 预取的同一引用,push 即累积)
|
|
12
|
+
* @param answerValues 回答整体结构(本 parser 不使用)
|
|
13
|
+
* @param options 解析配置(actionExecute 提供回包通道与错误回调)
|
|
14
|
+
* @returns 是否消费了该 chunk(只在自己负责的组合上返回 true)
|
|
15
|
+
*/
|
|
16
|
+
export declare const applyCollectClarificationsChunk: (chunk: StreamChunk, reports: AiAnswerReport<any>[], _answerValues?: unknown, options?: AnswerParseOptions) => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* 历史归一化:历史里的确认卡片没有在途请求,统一标为已失效(只读展示)。
|
|
19
|
+
* 实时链路产出的 pending 报告若仍有在途请求则保持原状。
|
|
20
|
+
* @param report 历史 reports 中的确认卡片报告(就地修改)
|
|
21
|
+
*/
|
|
22
|
+
export declare const normalizeCollectClarificationsReport: (report: AiAnswerReport<ClarificationViewModel>) => void;
|
|
23
|
+
/**
|
|
24
|
+
* collect_clarifications 答案类型的注册表条目(registry 内置)
|
|
25
|
+
*/
|
|
26
|
+
export declare const collectClarificationsParser: AnswerParser<ClarificationViewModel>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ActionExecuteOptions } from './types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 发送一条 wait_reply
|
|
5
|
+
* @param options action_execute 配置(提供 reply 回传通道)
|
|
6
|
+
* @param replyId 后端 front_reply 的 reply_id
|
|
7
|
+
* @param values 回包载荷
|
|
8
|
+
* @returns 是否回传成功(false = 无回传通道 / 连接已关闭 / 发送异常)
|
|
9
|
+
*/
|
|
10
|
+
export declare const replyWait: (options: ActionExecuteOptions | undefined, replyId: string | number | undefined, values: unknown) => boolean;
|
|
11
|
+
/**
|
|
12
|
+
* 回一条失败帧(指令非法 / 不支持的操作 / 执行异常),避免后端一直等待 wait_reply
|
|
13
|
+
* @param options action_execute 配置
|
|
14
|
+
* @param replyId 后端 reply_id
|
|
15
|
+
* @param message 失败原因
|
|
16
|
+
*/
|
|
17
|
+
export declare const replyFailure: (options: ActionExecuteOptions | undefined, replyId: string | number | undefined, message: string) => void;
|
|
@@ -45,13 +45,14 @@ export interface WaitReplyPayload {
|
|
|
45
45
|
values: unknown;
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
48
|
+
* action_execute 指令处理配置(只作用于 `executor === 'agent'` 的指令:
|
|
49
|
+
* agent 下发命令、宿主执行)。`executor === 'host'` 的 `collect_clarifications`
|
|
50
|
+
* 走确认卡片,不需要宿主注入执行器。
|
|
50
51
|
*/
|
|
51
|
-
export interface
|
|
52
|
+
export interface ActionExecuteOptions {
|
|
52
53
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
54
|
+
* 宿主执行器:`executor === 'agent'` 的 action 由宿主执行。
|
|
55
|
+
* 未提供时一律回失败帧(避免后端一直等待 wait_reply)。
|
|
55
56
|
* @param action 待执行的 Action(name + arguments)
|
|
56
57
|
* @returns 统一执行结果(同步或异步均可)
|
|
57
58
|
*/
|
|
@@ -68,6 +69,26 @@ export interface FrontReplyOptions {
|
|
|
68
69
|
*/
|
|
69
70
|
onError?: (error: unknown) => void;
|
|
70
71
|
}
|
|
72
|
+
/** agent 下发指令的执行状态:执行中 / 成功 / 失败 / 未知(历史回放,状态已无法确认) */
|
|
73
|
+
export type AgentActionStatus = 'running' | 'success' | 'error' | 'unknown';
|
|
74
|
+
/**
|
|
75
|
+
* agent 指令的执行过程卡片(`answer_type = 'agent_action'` 的 values)
|
|
76
|
+
* 对应 `front_reply + action_execute + executor='agent'`:agent 发出命令,宿主执行并回包。
|
|
77
|
+
*/
|
|
78
|
+
export interface AgentActionValue {
|
|
79
|
+
/** 卡片 id(取后端 reply_id,缺省时本地生成) */
|
|
80
|
+
id: string;
|
|
81
|
+
/** Action 名称 */
|
|
82
|
+
name: string;
|
|
83
|
+
/** Action 参数 */
|
|
84
|
+
arguments: Record<string, unknown>;
|
|
85
|
+
/** 当前执行状态 */
|
|
86
|
+
status: AgentActionStatus;
|
|
87
|
+
/** 状态说明(执行中 / 成功结果 / 失败原因) */
|
|
88
|
+
message: string;
|
|
89
|
+
/** 业务数据(执行成功时原样回传的 data,供 UI 展示) */
|
|
90
|
+
data?: unknown;
|
|
91
|
+
}
|
|
71
92
|
/** 确认项输入类型 */
|
|
72
93
|
export type ClarificationInputType = 'single_select' | 'multi_select' | 'date' | 'text';
|
|
73
94
|
/** 确认项回答方式:结构化选项 / 自然语言 */
|