@shuttle-ai/render-react 0.0.1

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.
Files changed (96) hide show
  1. package/README.md +5 -0
  2. package/dist/cjs/agentWork/action/index.cjs +1 -0
  3. package/dist/cjs/agentWork/agent/aiMessage/index.cjs +1 -0
  4. package/dist/cjs/agentWork/agent/index.cjs +1 -0
  5. package/dist/cjs/agentWork/agent/toolRender/confirm.cjs +1 -0
  6. package/dist/cjs/agentWork/agent/toolRender/index.cjs +1 -0
  7. package/dist/cjs/agentWork/agent/userMessage/index.cjs +1 -0
  8. package/dist/cjs/agentWork/render.cjs +1 -0
  9. package/dist/cjs/context/agent/base.cjs +1 -0
  10. package/dist/cjs/context/agent/provider.cjs +1 -0
  11. package/dist/cjs/context/agent/useAgent.cjs +1 -0
  12. package/dist/cjs/context/agentWork/base.cjs +1 -0
  13. package/dist/cjs/context/agentWork/provider.cjs +1 -0
  14. package/dist/cjs/context/agentWork/useWork.cjs +1 -0
  15. package/dist/cjs/context/agentWork/useWorkContext.cjs +1 -0
  16. package/dist/cjs/context/tool/base.cjs +1 -0
  17. package/dist/cjs/context/tool/provider.cjs +1 -0
  18. package/dist/cjs/context/tool/useTool.cjs +1 -0
  19. package/dist/cjs/hooks/useAgentMessages.cjs +1 -0
  20. package/dist/cjs/hooks/useAgentStatus.cjs +1 -0
  21. package/dist/cjs/hooks/useAiMessage.cjs +1 -0
  22. package/dist/cjs/hooks/useRootAgent.cjs +1 -0
  23. package/dist/cjs/hooks/useToolMessage.cjs +1 -0
  24. package/dist/cjs/hooks/useWorkAutoRunScope.cjs +1 -0
  25. package/dist/cjs/hooks/useWorkStatus.cjs +1 -0
  26. package/dist/cjs/index.cjs +1 -0
  27. package/dist/cjs/index.css +1 -0
  28. package/dist/cjs/markdownRender/index.cjs +1 -0
  29. package/dist/cjs/tools/writeTodos/index.cjs +1 -0
  30. package/dist/cjs/tools/writeTodos/render.cjs +1 -0
  31. package/dist/es/agentWork/action/index.mjs +80 -0
  32. package/dist/es/agentWork/agent/aiMessage/index.mjs +25 -0
  33. package/dist/es/agentWork/agent/index.mjs +45 -0
  34. package/dist/es/agentWork/agent/toolRender/confirm.mjs +96 -0
  35. package/dist/es/agentWork/agent/toolRender/index.mjs +49 -0
  36. package/dist/es/agentWork/agent/userMessage/index.mjs +24 -0
  37. package/dist/es/agentWork/render.mjs +38 -0
  38. package/dist/es/context/agent/base.mjs +7 -0
  39. package/dist/es/context/agent/provider.mjs +10 -0
  40. package/dist/es/context/agent/useAgent.mjs +8 -0
  41. package/dist/es/context/agentWork/base.mjs +8 -0
  42. package/dist/es/context/agentWork/provider.mjs +21 -0
  43. package/dist/es/context/agentWork/useWork.mjs +8 -0
  44. package/dist/es/context/agentWork/useWorkContext.mjs +8 -0
  45. package/dist/es/context/tool/base.mjs +9 -0
  46. package/dist/es/context/tool/provider.mjs +33 -0
  47. package/dist/es/context/tool/useTool.mjs +8 -0
  48. package/dist/es/hooks/useAgentMessages.mjs +10 -0
  49. package/dist/es/hooks/useAgentStatus.mjs +10 -0
  50. package/dist/es/hooks/useAiMessage.mjs +13 -0
  51. package/dist/es/hooks/useRootAgent.mjs +10 -0
  52. package/dist/es/hooks/useToolMessage.mjs +13 -0
  53. package/dist/es/hooks/useWorkAutoRunScope.mjs +10 -0
  54. package/dist/es/hooks/useWorkStatus.mjs +10 -0
  55. package/dist/es/index.css +1 -0
  56. package/dist/es/index.mjs +50 -0
  57. package/dist/es/markdownRender/index.mjs +13 -0
  58. package/dist/es/tools/writeTodos/index.mjs +16 -0
  59. package/dist/es/tools/writeTodos/render.mjs +37 -0
  60. package/dist/types/agentWork/action/index.d.ts +1 -0
  61. package/dist/types/agentWork/agent/aiMessage/index.d.ts +5 -0
  62. package/dist/types/agentWork/agent/index.d.ts +7 -0
  63. package/dist/types/agentWork/agent/toolRender/confirm.d.ts +12 -0
  64. package/dist/types/agentWork/agent/toolRender/index.d.ts +6 -0
  65. package/dist/types/agentWork/agent/userMessage/index.d.ts +8 -0
  66. package/dist/types/agentWork/index.d.ts +7 -0
  67. package/dist/types/agentWork/render.d.ts +7 -0
  68. package/dist/types/context/agent/base.d.ts +4 -0
  69. package/dist/types/context/agent/index.d.ts +2 -0
  70. package/dist/types/context/agent/provider.d.ts +7 -0
  71. package/dist/types/context/agent/useAgent.d.ts +1 -0
  72. package/dist/types/context/agentWork/base.d.ts +6 -0
  73. package/dist/types/context/agentWork/index.d.ts +3 -0
  74. package/dist/types/context/agentWork/provider.d.ts +14 -0
  75. package/dist/types/context/agentWork/useWork.d.ts +1 -0
  76. package/dist/types/context/agentWork/useWorkContext.d.ts +1 -0
  77. package/dist/types/context/index.d.ts +3 -0
  78. package/dist/types/context/tool/base.d.ts +11 -0
  79. package/dist/types/context/tool/index.d.ts +2 -0
  80. package/dist/types/context/tool/provider.d.ts +12 -0
  81. package/dist/types/context/tool/useTool.d.ts +2 -0
  82. package/dist/types/hooks/index.d.ts +7 -0
  83. package/dist/types/hooks/useAgentMessages.d.ts +2 -0
  84. package/dist/types/hooks/useAgentStatus.d.ts +2 -0
  85. package/dist/types/hooks/useAiMessage.d.ts +3 -0
  86. package/dist/types/hooks/useRootAgent.d.ts +2 -0
  87. package/dist/types/hooks/useToolMessage.d.ts +3 -0
  88. package/dist/types/hooks/useWorkAutoRunScope.d.ts +2 -0
  89. package/dist/types/hooks/useWorkStatus.d.ts +2 -0
  90. package/dist/types/index.d.ts +5 -0
  91. package/dist/types/markdownRender/index.d.ts +5 -0
  92. package/dist/types/tools/index.d.ts +1 -0
  93. package/dist/types/tools/writeTodos/index.d.ts +3 -0
  94. package/dist/types/tools/writeTodos/render.d.ts +5 -0
  95. package/dist/types/type.d.ts +19 -0
  96. package/package.json +54 -0
@@ -0,0 +1,8 @@
1
+ import { useContext as o } from "react";
2
+ import { toolContext as t } from "./base.mjs";
3
+ function n() {
4
+ return o(t);
5
+ }
6
+ export {
7
+ n as useTool
8
+ };
@@ -0,0 +1,10 @@
1
+ import { useState as o, useEffect as r } from "react";
2
+ function n(s) {
3
+ const [e, t] = o(s.messages);
4
+ return r(() => s.on("messages", (f) => {
5
+ t([...f]);
6
+ }), [s]), e;
7
+ }
8
+ export {
9
+ n as default
10
+ };
@@ -0,0 +1,10 @@
1
+ import { useState as f, useEffect as o } from "react";
2
+ function n(t) {
3
+ const [s, u] = f(t.status);
4
+ return o(() => t.on("status", (e) => {
5
+ u(e);
6
+ }), [t]), s;
7
+ }
8
+ export {
9
+ n as default
10
+ };
@@ -0,0 +1,13 @@
1
+ import { useState as o, useEffect as u } from "react";
2
+ function c(e, t) {
3
+ const [i, r] = o();
4
+ return u(() => {
5
+ const n = e.on("aiMessage", (s) => {
6
+ s.id === t && r({ ...s });
7
+ }), f = e.messages.find((s) => s.role === "assistant" && s.id === t);
8
+ return f && r(f), n;
9
+ }, [e, t]), i;
10
+ }
11
+ export {
12
+ c as default
13
+ };
@@ -0,0 +1,10 @@
1
+ import { useState as n, useEffect as r } from "react";
2
+ function g(e) {
3
+ const [t, o] = n();
4
+ return r(() => e.on("agent", () => {
5
+ o(e.getRootAgent());
6
+ }), []), t;
7
+ }
8
+ export {
9
+ g as default
10
+ };
@@ -0,0 +1,13 @@
1
+ import { useState as u, useEffect as i } from "react";
2
+ function l(e, t) {
3
+ const [f, s] = u();
4
+ return i(() => {
5
+ const n = e.on("toolMessage", (o) => {
6
+ o.id === t && s({ ...o });
7
+ }), r = e.messages.find((o) => o.role === "tool" && o.id === t);
8
+ return r && s(r), n;
9
+ }, [e, t]), f;
10
+ }
11
+ export {
12
+ l as default
13
+ };
@@ -0,0 +1,10 @@
1
+ import { useState as u, useEffect as n } from "react";
2
+ function s(e) {
3
+ const [o, t] = u(e.autoRunScope);
4
+ return n(() => e.on("autoRunScope", () => {
5
+ t(e.autoRunScope);
6
+ }), []), o;
7
+ }
8
+ export {
9
+ s as default
10
+ };
@@ -0,0 +1,10 @@
1
+ import { useState as u, useEffect as r } from "react";
2
+ function o(t) {
3
+ const [s, e] = u(t.status);
4
+ return r(() => t.on("status", () => {
5
+ e(t.status);
6
+ }), []), s;
7
+ }
8
+ export {
9
+ o as default
10
+ };
@@ -0,0 +1 @@
1
+ .agent-work{display:flex;flex-direction:column}.agent-work .agent-work-main{flex:1;overflow-y:auto;padding:12px}.agent-work .agent-work-main .agent-work-agent{display:flex;flex-direction:column;gap:1rem;position:relative}.agent-work .agent-work-main .agent-work-agent:before{content:" ";display:inline-block;position:absolute;top:8px;left:0;width:1px;z-index:-1;height:calc(100% - 8px);background-color:#0000001a}.agent-work .agent-work-main .agent-work-agent-message{padding:0 12px;display:flex;flex-direction:column;gap:1rem}.agent-work-agent-message.user-message{position:relative}.agent-work-agent-message.user-message .agent-work-agent-message-expand-icon{position:absolute;top:8px;left:0;transform:translate(-50%);width:1rem;height:1rem;display:flex;align-items:center;justify-content:center;border-radius:50%;background-color:#fff;box-shadow:0 0 4px #0000001a;font-size:12px;cursor:pointer}.agent-work-agent-message.user-message .agent-work-agent-message-content{background-color:#fff;box-shadow:0 0 8px #0000001a;padding:8px 12px;border-radius:8px;margin:0;font-size:1rem}.agent-work-agent-tool{display:flex;flex-direction:column;padding:8px;border-radius:8px;background-color:#1677ff33;box-shadow:0 0 8px #0000001a}.agent-work-agent-tool .agent-work-agent-fn-tool{display:flex;flex-direction:column;gap:8px}.agent-work-agent-tool .agent-work-agent-fn-tool .fn-tool-name{margin:0;font-weight:700}.agent-work-agent-tool .agent-work-agent-fn-tool .fn-tool-args,.agent-work-agent-tool .agent-work-agent-fn-tool .fn-tool-result{margin:0;padding-top:8px;border-top:1px solid #d9d9d9}.agent-work-agent-tool .agent-work-agent-fn-tool .fn-tool-result:empty{display:none}.agent-work-agent-tool .fn-tool-confirm{display:flex;flex-direction:column;gap:4px;padding-top:8px;border-top:1px solid #d9d9d9}.agent-work-agent-tool .fn-tool-confirm .fn-tool-confirm-tip{font-size:14px}.agent-work-agent-tool .fn-tool-confirm .fn-tool-confirm-button-group{display:flex;align-items:center;gap:2rem}.agent-work-agent-message.ai-message .ai-message-content{padding:8px;border-radius:8px;background-color:#aff0b566;box-shadow:0 0 8px #0000001a}.agent-work-agent-message.ai-message .ai-message-content>.markdown-body{background-color:transparent}.agent-work-agent-message.ai-message .agent-work-agent-children,.agent-work-agent-message.ai-message .agent-work-agent-tools{display:flex;flex-direction:column;gap:1rem}.agent-work-action{display:flex;flex-direction:column;border-radius:8px;border:1px solid #d9d9d9}.agent-work-action:has(.agent-work-action-input:focus){border-color:#1677ff;box-shadow:0 0 4px #4096ffaa}.agent-work-action:has(.agent-work-action-input.ant-input-disabled){background-color:#0000000a}.agent-work-action .agent-work-action-input.ant-input-disabled{background-color:transparent}.agent-work-action .agent-work-action-input{border:none;outline:none;box-shadow:none;resize:none}.agent-work-action .agent-work-action-btns{display:flex;align-items:center;justify-content:flex-end;padding:4px 11px;gap:8px}.shuttle-ai-tool-todo{list-style:none;padding:0;margin:0;display:flex;flex-direction:column;gap:8px}.shuttle-ai-tool-todo .shuttle-ai-tool-todo-header{font-size:14px;font-weight:500;color:#333}.shuttle-ai-tool-todo .shuttle-ai-tool-todo-item{display:inline-block;width:fit-content;font-size:14px}.shuttle-ai-tool-todo .shuttle-ai-tool-todo-item.status-in_progress{color:transparent;-webkit-background-clip:text;background-clip:text;background-image:linear-gradient(90deg,#000 0% 45%,#f5222d 45%,#52c41a,#1677ff 55%,#000 55% 100%);background-size:200% auto;animation:bg-scan 1s linear infinite}.shuttle-ai-tool-todo .shuttle-ai-tool-todo-item.status-completed{text-decoration:line-through;color:#888}@keyframes bg-scan{0%{background-position:100% center}to{background-position:0% center}}
@@ -0,0 +1,50 @@
1
+ import "@shuttle-ai/type";
2
+ /* empty css */
3
+ import { default as a } from "./agentWork/render.mjs";
4
+ import { default as f } from "./agentWork/agent/index.mjs";
5
+ import { default as d } from "./agentWork/action/index.mjs";
6
+ import { default as p } from "./agentWork/agent/aiMessage/index.mjs";
7
+ import { default as x } from "./agentWork/agent/userMessage/index.mjs";
8
+ import { default as g } from "./agentWork/agent/toolRender/index.mjs";
9
+ import { default as i } from "./agentWork/agent/toolRender/confirm.mjs";
10
+ import { useWork as R } from "./context/agentWork/useWork.mjs";
11
+ import { useWorkContext as T } from "./context/agentWork/useWorkContext.mjs";
12
+ import { default as v } from "./context/agentWork/provider.mjs";
13
+ import { useAgent as S } from "./context/agent/useAgent.mjs";
14
+ import { default as w } from "./context/agent/provider.mjs";
15
+ import { useTool as U } from "./context/tool/useTool.mjs";
16
+ import { default as h } from "./context/tool/provider.mjs";
17
+ import { default as q } from "./hooks/useWorkStatus.mjs";
18
+ import { default as z } from "./hooks/useWorkAutoRunScope.mjs";
19
+ import { default as D } from "./hooks/useRootAgent.mjs";
20
+ import { default as F } from "./hooks/useAgentMessages.mjs";
21
+ import { default as H } from "./hooks/useAgentStatus.mjs";
22
+ import { default as J } from "./hooks/useToolMessage.mjs";
23
+ import { default as L } from "./hooks/useAiMessage.mjs";
24
+ import { default as O } from "./tools/writeTodos/index.mjs";
25
+ import { default as V } from "./markdownRender/index.mjs";
26
+ export {
27
+ w as AgentProvider,
28
+ d as AgentWorkAction,
29
+ f as AgentWorkAgent,
30
+ v as AgentWorkProvider,
31
+ a as AgentWorkRender,
32
+ p as AiMessageRender,
33
+ V as MarkdownRender,
34
+ i as ToolConfirmRender,
35
+ h as ToolProvider,
36
+ g as ToolRender,
37
+ x as UserMessageRender,
38
+ S as useAgent,
39
+ F as useAgentMessages,
40
+ H as useAgentStatus,
41
+ L as useAiMessage,
42
+ D as useRootAgent,
43
+ U as useTool,
44
+ J as useToolMessage,
45
+ R as useWork,
46
+ z as useWorkAutoRunScope,
47
+ T as useWorkContext,
48
+ q as useWorkStatus,
49
+ O as writeTodosTool
50
+ };
@@ -0,0 +1,13 @@
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import o from "react-markdown";
3
+ import e from "remark-gfm";
4
+ import a from "remark-breaks";
5
+ import t from "remark-frontmatter";
6
+ import i from "rehype-raw";
7
+ import "github-markdown-css/github-markdown.css";
8
+ function u({ children: m }) {
9
+ return /* @__PURE__ */ r("div", { className: "markdown-body", children: /* @__PURE__ */ r(o, { remarkPlugins: [e, a, t], rehypePlugins: [i], children: m }) });
10
+ }
11
+ export {
12
+ u as default
13
+ };
@@ -0,0 +1,16 @@
1
+ import e from "./render.mjs";
2
+ const r = {
3
+ name: "write_todos",
4
+ description: "Write todos",
5
+ run: {
6
+ type: "render",
7
+ Render: e
8
+ },
9
+ extras: {
10
+ onlyShow: !0,
11
+ disableExport: !0
12
+ }
13
+ };
14
+ export {
15
+ r as default
16
+ };
@@ -0,0 +1,37 @@
1
+ import { jsxs as o, jsx as e } from "react/jsx-runtime";
2
+ import i from "classnames";
3
+ import { UnorderedListOutlined as m } from "@ant-design/icons";
4
+ import "react";
5
+ import "../../context/agentWork/base.mjs";
6
+ import "@shuttle-ai/client";
7
+ import "../../context/agent/base.mjs";
8
+ import { useTool as l } from "../../context/tool/useTool.mjs";
9
+ import "../../context/tool/base.mjs";
10
+ /* empty css */
11
+ function j() {
12
+ const { args: r } = l();
13
+ return /* @__PURE__ */ o("ul", { className: "shuttle-ai-tool-todo", children: [
14
+ /* @__PURE__ */ o("li", { className: "shuttle-ai-tool-todo-header", children: [
15
+ /* @__PURE__ */ e(m, {}),
16
+ " 待办"
17
+ ] }),
18
+ r.todos.map((t, s) => /* @__PURE__ */ o(
19
+ "li",
20
+ {
21
+ className: i(
22
+ "shuttle-ai-tool-todo-item",
23
+ `status-${t.status}`
24
+ ),
25
+ children: [
26
+ s + 1,
27
+ ". ",
28
+ t.content
29
+ ]
30
+ },
31
+ t.content
32
+ ))
33
+ ] });
34
+ }
35
+ export {
36
+ j as default
37
+ };
@@ -0,0 +1 @@
1
+ export default function AgentWorkAction(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ interface Props {
2
+ messageId: string;
3
+ }
4
+ export default function AiMessage({ messageId }: Props): import("react/jsx-runtime").JSX.Element | null;
5
+ export {};
@@ -0,0 +1,7 @@
1
+ import { Agent } from '@shuttle-ai/client';
2
+ interface Porps {
3
+ agent: Agent;
4
+ isRoot?: boolean;
5
+ }
6
+ export default function AgentWorkAgent({ agent, isRoot }: Porps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,12 @@
1
+ import { ShuttleAi } from '@shuttle-ai/type';
2
+ import { Agent } from '@shuttle-ai/client';
3
+ type WithPromise<T> = T | Promise<T>;
4
+ interface Props {
5
+ toolId: string;
6
+ result?: ShuttleAi.Tool.ConfirmResult;
7
+ agent: Agent;
8
+ getConfirmResult?: () => WithPromise<Pick<ShuttleAi.Tool.ConfirmResult, 'result' | 'newArgs'>>;
9
+ getNewArgs?: () => WithPromise<ShuttleAi.Tool.ConfirmResult['newArgs']>;
10
+ }
11
+ export default function ConfirmRender({ toolId, result, agent, getConfirmResult, getNewArgs, }: Props): import("react/jsx-runtime").JSX.Element;
12
+ export {};
@@ -0,0 +1,6 @@
1
+ import { ShuttleAi } from '@shuttle-ai/type';
2
+ interface Props {
3
+ toolCall: ShuttleAi.Tool.Call;
4
+ }
5
+ export default function ToolRender({ toolCall }: Props): import("react/jsx-runtime").JSX.Element | null;
6
+ export {};
@@ -0,0 +1,8 @@
1
+ import { ShuttleAi } from '@shuttle-ai/type';
2
+ interface Props {
3
+ message: ShuttleAi.Message.User;
4
+ closed?: boolean;
5
+ onToggleClose?: (messageId: string) => void | Promise<void>;
6
+ }
7
+ export default function UserMessage({ message, closed, onToggleClose }: Props): import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1,7 @@
1
+ export { default as AgentWorkRender } from './render';
2
+ export { default as AgentWorkAgent } from './agent';
3
+ export { default as AgentWorkAction } from './action';
4
+ export { default as AiMessageRender } from './agent/aiMessage';
5
+ export { default as UserMessageRender } from './agent/userMessage';
6
+ export { default as ToolRender } from './agent/toolRender';
7
+ export { default as ToolConfirmRender } from './agent/toolRender/confirm';
@@ -0,0 +1,7 @@
1
+ interface Props {
2
+ className?: string;
3
+ style?: React.CSSProperties;
4
+ empty?: React.ReactNode;
5
+ }
6
+ export default function AgentWorkRender({ className, style, empty }: Props): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,4 @@
1
+ import { Agent } from '@shuttle-ai/client';
2
+ export declare const agentContext: import('react').Context<{
3
+ agent: Agent;
4
+ }>;
@@ -0,0 +1,2 @@
1
+ export { useAgent } from './useAgent';
2
+ export { default as AgentProvider } from './provider';
@@ -0,0 +1,7 @@
1
+ import { Agent } from '@shuttle-ai/client';
2
+ interface Props {
3
+ children?: React.ReactNode;
4
+ agent: Agent;
5
+ }
6
+ export default function AgentProvider({ children, agent }: Props): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1 @@
1
+ export declare function useAgent(): import('packages/client/src').Agent;
@@ -0,0 +1,6 @@
1
+ import { AgentWork } from '@shuttle-ai/client';
2
+ import { ShuttleAi } from '@shuttle-ai/type';
3
+ export declare const agentWorkContext: import('react').Context<{
4
+ work: AgentWork;
5
+ context: ShuttleAi.Client.ReactRender.Context;
6
+ }>;
@@ -0,0 +1,3 @@
1
+ export { useWork } from './useWork';
2
+ export { useWorkContext } from './useWorkContext';
3
+ export { default as AgentWorkProvider } from './provider';
@@ -0,0 +1,14 @@
1
+ import { ShuttleAi } from '@shuttle-ai/type';
2
+ import { AgentWork } from '@shuttle-ai/client';
3
+ interface BaseProps {
4
+ children?: React.ReactNode;
5
+ context: ShuttleAi.Client.ReactRender.Context;
6
+ }
7
+ interface WithAgentProps extends BaseProps {
8
+ work: AgentWork;
9
+ }
10
+ interface WorkOptionProps extends BaseProps, ShuttleAi.Client.Work.Options {
11
+ }
12
+ type Props = WithAgentProps | WorkOptionProps;
13
+ export default function AgentWorkProvider({ children, context, ...rest }: Props): import("react/jsx-runtime").JSX.Element;
14
+ export {};
@@ -0,0 +1 @@
1
+ export declare function useWork(): import('packages/client/src').AgentWork;
@@ -0,0 +1 @@
1
+ export declare function useWorkContext(): import("@shuttle-ai/type").ShuttleAi.Client.ReactRender.Context;
@@ -0,0 +1,3 @@
1
+ export * from './agentWork';
2
+ export * from './agent';
3
+ export * from './tool';
@@ -0,0 +1,11 @@
1
+ import { ShuttleAi } from '@shuttle-ai/type';
2
+ import { Agent } from '@shuttle-ai/client';
3
+ export interface ToolContext<T extends Record<string, any> = Record<string, any>> {
4
+ args: T;
5
+ agent: Agent;
6
+ toolId: string;
7
+ content?: string;
8
+ confirmResult?: ShuttleAi.Tool.ConfirmResult;
9
+ confirm?: (result: ShuttleAi.Tool.ConfirmResult) => Promise<void>;
10
+ }
11
+ export declare const toolContext: import('react').Context<ToolContext<Record<string, any>>>;
@@ -0,0 +1,2 @@
1
+ export { useTool } from './useTool';
2
+ export { default as ToolProvider } from './provider';
@@ -0,0 +1,12 @@
1
+ import { Agent } from '@shuttle-ai/client';
2
+ import { ShuttleAi } from '@shuttle-ai/type';
3
+ interface Props {
4
+ args: Record<string, any>;
5
+ content?: string;
6
+ toolId: string;
7
+ confirmResult?: ShuttleAi.Tool.ConfirmResult;
8
+ agent: Agent;
9
+ run: ShuttleAi.Client.Agent.RenderTool;
10
+ }
11
+ export default function ToolProvider({ args, content, toolId, confirmResult, agent, run, }: Props): import("react/jsx-runtime").JSX.Element;
12
+ export {};
@@ -0,0 +1,2 @@
1
+ import { ToolContext } from './base';
2
+ export declare function useTool<T extends Record<string, any> = Record<string, any>>(): ToolContext<T>;
@@ -0,0 +1,7 @@
1
+ export { default as useWorkStatus } from './useWorkStatus';
2
+ export { default as useWorkAutoRunScope } from './useWorkAutoRunScope';
3
+ export { default as useRootAgent } from './useRootAgent';
4
+ export { default as useAgentMessages } from './useAgentMessages';
5
+ export { default as useAgentStatus } from './useAgentStatus';
6
+ export { default as useToolMessage } from './useToolMessage';
7
+ export { default as useAiMessage } from './useAiMessage';
@@ -0,0 +1,2 @@
1
+ import { Agent } from '@shuttle-ai/client';
2
+ export default function useAgentMessages(agent: Agent): import("@shuttle-ai/type").ShuttleAi.Message.Define[];
@@ -0,0 +1,2 @@
1
+ import { Agent } from '@shuttle-ai/client';
2
+ export default function useAgentStatus(agent: Agent): "idle" | "running" | "waitRevoke";
@@ -0,0 +1,3 @@
1
+ import { Agent } from '@shuttle-ai/client';
2
+ import { ShuttleAi } from '@shuttle-ai/type';
3
+ export default function useAiMessage(agent: Agent, messageId: string): ShuttleAi.Message.AI | undefined;
@@ -0,0 +1,2 @@
1
+ import { AgentWork, Agent } from '@shuttle-ai/client';
2
+ export default function useRootAgent(work: AgentWork): Agent | undefined;
@@ -0,0 +1,3 @@
1
+ import { Agent } from '@shuttle-ai/client';
2
+ import { ShuttleAi } from '@shuttle-ai/type';
3
+ export default function useToolMessage(agent: Agent, messageId: string): ShuttleAi.Message.Tool | undefined;
@@ -0,0 +1,2 @@
1
+ import { AgentWork } from '@shuttle-ai/client';
2
+ export default function useWorkAutoRunScope(work: AgentWork): "read" | "always" | "none";
@@ -0,0 +1,2 @@
1
+ import { AgentWork } from '@shuttle-ai/client';
2
+ export default function useWorkStatus(work: AgentWork): "idle" | "running" | "pending";
@@ -0,0 +1,5 @@
1
+ export * from './agentWork';
2
+ export * from './context';
3
+ export * from './hooks';
4
+ export * from './tools';
5
+ export { default as MarkdownRender } from './markdownRender';
@@ -0,0 +1,5 @@
1
+ interface MarkdownRenderProps {
2
+ children: string;
3
+ }
4
+ export default function MarkdownRender({ children }: MarkdownRenderProps): import("react/jsx-runtime").JSX.Element;
5
+ export {};
@@ -0,0 +1 @@
1
+ export { default as writeTodosTool } from './writeTodos';
@@ -0,0 +1,3 @@
1
+ import { ShuttleAi } from '@shuttle-ai/type';
2
+ declare const writeTodosTool: ShuttleAi.Client.Agent.WithRunTool;
3
+ export default writeTodosTool;
@@ -0,0 +1,5 @@
1
+ export interface TodoItem {
2
+ content: string;
3
+ status: 'in_progress' | 'pending' | 'completed';
4
+ }
5
+ export default function WriteTodosRender(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,19 @@
1
+ declare module '@shuttle-ai/type' {
2
+ namespace ShuttleAi {
3
+ namespace Client {
4
+ namespace Agent {
5
+ interface RenderTool {
6
+ Render: React.FC<any>;
7
+ defaultProps?: Record<string, any> | ((params: {
8
+ args: Record<string, any>;
9
+ content?: string;
10
+ }) => Record<string, any>);
11
+ }
12
+ }
13
+ namespace ReactRender {
14
+ interface Context {
15
+ }
16
+ }
17
+ }
18
+ }
19
+ }
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@shuttle-ai/render-react",
3
+ "version": "0.0.1",
4
+ "author": "Mingbing-get <1508850533@qq.com>",
5
+ "license": "MIT",
6
+ "description": "Shuttle AI web端智能体react渲染库",
7
+ "main": "dist/cjs/index.cjs",
8
+ "module": "dist/es/index.mjs",
9
+ "types": "dist/types/index.d.ts",
10
+ "type": "module",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/types/index.d.ts",
14
+ "import": "./dist/es/index.mjs",
15
+ "require": "./dist/cjs/index.cjs"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "README.md"
21
+ ],
22
+ "dependencies": {
23
+ "classnames": "^2.5.1",
24
+ "github-markdown-css": "^5.8.1",
25
+ "react": "^18.2.0",
26
+ "react-dom": "^18.2.0",
27
+ "antd": "^6.1.1",
28
+ "@ant-design/icons": "^6.1.0",
29
+ "react-markdown": "^10.1.0",
30
+ "rehype-raw": "^7.0.0",
31
+ "remark-breaks": "^4.0.0",
32
+ "remark-frontmatter": "^5.0.0",
33
+ "remark-gfm": "^4.0.1",
34
+ "@shuttle-ai/type": "0.0.1",
35
+ "@shuttle-ai/client": "0.0.1"
36
+ },
37
+ "devDependencies": {
38
+ "typescript": "^5.3.3",
39
+ "@types/react": "^18.2.60",
40
+ "@types/react-dom": "^18.2.19",
41
+ "@vitejs/plugin-react": "^4.2.1"
42
+ },
43
+ "access": "public",
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "scripts": {
48
+ "build": "vite build",
49
+ "dev": "vite",
50
+ "clean": "rm -rf dist",
51
+ "type-check": "tsc --noEmit",
52
+ "test": "echo \"Error: no test specified\" && exit 1"
53
+ }
54
+ }