@shuttle-ai/render-react 0.0.4 → 0.0.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.
- package/dist/cjs/agentWork/agent/toolRender/confirm.cjs +1 -1
- package/dist/es/agentWork/agent/toolRender/confirm.mjs +26 -25
- package/dist/types/agentWork/agent/toolRender/confirm.d.ts +2 -1
- package/dist/types/hooks/useAgentMessages.d.ts +1 -1
- package/dist/types/hooks/useAiMessage.d.ts +1 -2
- package/dist/types/hooks/useToolMessage.d.ts +1 -2
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react/jsx-runtime"),a=require("react"),s=require("antd"),v=require("@ant-design/icons");function x({toolId:u,result:t,agent:d,getConfirmResult:i,getNewArgs:h,onAfterConfirm:f}){const[r,p]=a.useState(t?.type==="reject"?"reject":"accept"),[c,j]=a.useState(t?.reason||""),[m,y]=a.useState(!1);a.useEffect(()=>{t?.type&&p(t.type==="reject"?"reject":"accept")},[t?.type]),a.useEffect(()=>{t?.reason&&j(t.reason)},[t?.reason]);const o=a.useCallback(async()=>{if(r==="reject"&&!c){s.message.warning("请输入拒绝原因");return}y(!0);try{const e=r==="accept"?{type:"confirm",newArgs:await h?.()}:{type:"reject",reason:c};if(e.type==="confirm"&&i){const l=await i();l&&(e.result=l.result,e.newArgs=l.newArgs,e.type="confirmWithResult")}await d.confirmTool(u,e),f?.()}catch(e){throw e}finally{y(!1)}},[r,c,u,d,i,f]),g=a.useCallback(e=>{e.shiftKey||(e.preventDefault(),o())},[o]);return n.jsxs("div",{className:"fn-tool-confirm",children:[n.jsx("span",{className:"fn-tool-confirm-tip",children:"是否允许执行?"}),n.jsxs("div",{className:"fn-tool-confirm-button-group",children:[n.jsxs(s.Radio.Group,{size:"small",optionType:"button",value:r,disabled:!!t,onChange:e=>p(e.target.value),children:[n.jsx(s.Radio,{value:"accept",children:"接受"}),n.jsx(s.Radio,{value:"reject",children:"拒绝"})]}),n.jsx(s.Button,{disabled:!!t,size:"small",type:"primary",danger:r==="reject",loading:m,onClick:o,icon:n.jsx(v.SendOutlined,{}),children:"提交"})]}),r==="reject"&&n.jsx(s.Input.TextArea,{disabled:!!t,placeholder:"请输入拒绝原因",value:c,onChange:e=>j(e.target.value),rows:3,onPressEnter:g})]})}exports.default=x;
|
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
import { jsxs as s, jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { useState as l, useEffect as
|
|
3
|
-
import { message as
|
|
4
|
-
import { SendOutlined as
|
|
5
|
-
function
|
|
2
|
+
import { useState as l, useEffect as j, useCallback as g } from "react";
|
|
3
|
+
import { message as x, Radio as p, Button as T, Input as A } from "antd";
|
|
4
|
+
import { SendOutlined as E } from "@ant-design/icons";
|
|
5
|
+
function z({
|
|
6
6
|
toolId: f,
|
|
7
7
|
result: t,
|
|
8
8
|
agent: d,
|
|
9
9
|
getConfirmResult: o,
|
|
10
|
-
getNewArgs:
|
|
10
|
+
getNewArgs: v,
|
|
11
|
+
onAfterConfirm: m
|
|
11
12
|
}) {
|
|
12
|
-
const [n,
|
|
13
|
+
const [n, u] = l(
|
|
13
14
|
t?.type === "reject" ? "reject" : "accept"
|
|
14
|
-
), [a,
|
|
15
|
-
|
|
16
|
-
t?.type &&
|
|
17
|
-
}, [t?.type]),
|
|
18
|
-
t?.reason &&
|
|
15
|
+
), [a, y] = l(t?.reason || ""), [w, h] = l(!1);
|
|
16
|
+
j(() => {
|
|
17
|
+
t?.type && u(t.type === "reject" ? "reject" : "accept");
|
|
18
|
+
}, [t?.type]), j(() => {
|
|
19
|
+
t?.reason && y(t.reason);
|
|
19
20
|
}, [t?.reason]);
|
|
20
|
-
const c =
|
|
21
|
+
const c = g(async () => {
|
|
21
22
|
if (n === "reject" && !a) {
|
|
22
|
-
|
|
23
|
+
x.warning("请输入拒绝原因");
|
|
23
24
|
return;
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
+
h(!0);
|
|
26
27
|
try {
|
|
27
28
|
const e = n === "accept" ? {
|
|
28
29
|
type: "confirm",
|
|
29
|
-
newArgs: await
|
|
30
|
+
newArgs: await v?.()
|
|
30
31
|
} : {
|
|
31
32
|
type: "reject",
|
|
32
33
|
reason: a
|
|
@@ -35,13 +36,13 @@ function S({
|
|
|
35
36
|
const i = await o();
|
|
36
37
|
i && (e.result = i.result, e.newArgs = i.newArgs, e.type = "confirmWithResult");
|
|
37
38
|
}
|
|
38
|
-
await d.confirmTool(f, e);
|
|
39
|
+
await d.confirmTool(f, e), m?.();
|
|
39
40
|
} catch (e) {
|
|
40
41
|
throw e;
|
|
41
42
|
} finally {
|
|
42
|
-
|
|
43
|
+
h(!1);
|
|
43
44
|
}
|
|
44
|
-
}, [n, a, f, d, o]),
|
|
45
|
+
}, [n, a, f, d, o, m]), b = g(
|
|
45
46
|
(e) => {
|
|
46
47
|
e.shiftKey || (e.preventDefault(), c());
|
|
47
48
|
},
|
|
@@ -57,7 +58,7 @@ function S({
|
|
|
57
58
|
optionType: "button",
|
|
58
59
|
value: n,
|
|
59
60
|
disabled: !!t,
|
|
60
|
-
onChange: (e) =>
|
|
61
|
+
onChange: (e) => u(e.target.value),
|
|
61
62
|
children: [
|
|
62
63
|
/* @__PURE__ */ r(p, { value: "accept", children: "接受" }),
|
|
63
64
|
/* @__PURE__ */ r(p, { value: "reject", children: "拒绝" })
|
|
@@ -65,15 +66,15 @@ function S({
|
|
|
65
66
|
}
|
|
66
67
|
),
|
|
67
68
|
/* @__PURE__ */ r(
|
|
68
|
-
|
|
69
|
+
T,
|
|
69
70
|
{
|
|
70
71
|
disabled: !!t,
|
|
71
72
|
size: "small",
|
|
72
73
|
type: "primary",
|
|
73
74
|
danger: n === "reject",
|
|
74
|
-
loading:
|
|
75
|
+
loading: w,
|
|
75
76
|
onClick: c,
|
|
76
|
-
icon: /* @__PURE__ */ r(
|
|
77
|
+
icon: /* @__PURE__ */ r(E, {}),
|
|
77
78
|
children: "提交"
|
|
78
79
|
}
|
|
79
80
|
)
|
|
@@ -84,13 +85,13 @@ function S({
|
|
|
84
85
|
disabled: !!t,
|
|
85
86
|
placeholder: "请输入拒绝原因",
|
|
86
87
|
value: a,
|
|
87
|
-
onChange: (e) =>
|
|
88
|
+
onChange: (e) => y(e.target.value),
|
|
88
89
|
rows: 3,
|
|
89
|
-
onPressEnter:
|
|
90
|
+
onPressEnter: b
|
|
90
91
|
}
|
|
91
92
|
)
|
|
92
93
|
] });
|
|
93
94
|
}
|
|
94
95
|
export {
|
|
95
|
-
|
|
96
|
+
z as default
|
|
96
97
|
};
|
|
@@ -7,6 +7,7 @@ interface Props {
|
|
|
7
7
|
agent: Agent;
|
|
8
8
|
getConfirmResult?: () => WithPromise<Pick<ShuttleAi.Tool.ConfirmResult, 'result' | 'newArgs'>>;
|
|
9
9
|
getNewArgs?: () => WithPromise<ShuttleAi.Tool.ConfirmResult['newArgs']>;
|
|
10
|
+
onAfterConfirm?: () => void;
|
|
10
11
|
}
|
|
11
|
-
export default function ConfirmRender({ toolId, result, agent, getConfirmResult, getNewArgs, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export default function ConfirmRender({ toolId, result, agent, getConfirmResult, getNewArgs, onAfterConfirm, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
12
13
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Agent } from '@shuttle-ai/client';
|
|
2
|
-
export default function useAgentMessages(agent: Agent):
|
|
2
|
+
export default function useAgentMessages(agent: Agent): ShuttleAi.Message.Define[];
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import { Agent } from '@shuttle-ai/client';
|
|
2
|
-
|
|
3
|
-
export default function useAiMessage(agent: Agent, messageId: string): ShuttleAi.Message.AI | undefined;
|
|
2
|
+
export default function useAiMessage(agent: Agent, messageId: string): any;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import { Agent } from '@shuttle-ai/client';
|
|
2
|
-
|
|
3
|
-
export default function useToolMessage(agent: Agent, messageId: string): ShuttleAi.Message.Tool | undefined;
|
|
2
|
+
export default function useToolMessage(agent: Agent, messageId: string): any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shuttle-ai/render-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"author": "Mingbing-get <1508850533@qq.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Shuttle AI web端智能体react渲染库",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"remark-breaks": "^4.0.0",
|
|
36
36
|
"remark-frontmatter": "^5.0.0",
|
|
37
37
|
"remark-gfm": "^4.0.1",
|
|
38
|
-
"@shuttle-ai/client": "0.0.
|
|
39
|
-
"@shuttle-ai/type": "0.0.
|
|
38
|
+
"@shuttle-ai/client": "0.0.5",
|
|
39
|
+
"@shuttle-ai/type": "0.0.5"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"typescript": "^5.3.3",
|