@tulip-systems/ai 0.11.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/LICENSE +662 -0
- package/dist/agents/lib/definitions.server.d.mts +11 -0
- package/dist/agents/lib/definitions.server.mjs +14 -0
- package/dist/agents/lib/delegation.server.d.mts +15 -0
- package/dist/agents/lib/delegation.server.mjs +28 -0
- package/dist/agents/lib/instructions.server.d.mts +14 -0
- package/dist/agents/lib/instructions.server.mjs +26 -0
- package/dist/agents/lib/types.d.mts +26 -0
- package/dist/agents/server.d.mts +5 -0
- package/dist/agents/server.mjs +5 -0
- package/dist/chat/client.d.mts +10 -0
- package/dist/chat/client.mjs +12 -0
- package/dist/chat/components/agent-activity.client.d.mts +14 -0
- package/dist/chat/components/agent-activity.client.mjs +26 -0
- package/dist/chat/components/assistant-panel.client.d.mts +40 -0
- package/dist/chat/components/assistant-panel.client.mjs +53 -0
- package/dist/chat/components/chat-composer.client.d.mts +160 -0
- package/dist/chat/components/chat-composer.client.mjs +266 -0
- package/dist/chat/components/chat-message.client.d.mts +92 -0
- package/dist/chat/components/chat-message.client.mjs +121 -0
- package/dist/chat/components/chat-thread.client.d.mts +130 -0
- package/dist/chat/components/chat-thread.client.mjs +164 -0
- package/dist/chat/components/message-part.client.d.mts +23 -0
- package/dist/chat/components/message-part.client.mjs +38 -0
- package/dist/chat/components/starter-prompts.client.d.mts +25 -0
- package/dist/chat/components/starter-prompts.client.mjs +31 -0
- package/dist/chat/components/tool-call-card.client.d.mts +29 -0
- package/dist/chat/components/tool-call-card.client.mjs +60 -0
- package/dist/chat/lib/classes.mjs +7 -0
- package/dist/chat/lib/parts.d.mts +10 -0
- package/dist/chat/lib/parts.mjs +25 -0
- package/dist/chat/lib/stream.server.d.mts +24 -0
- package/dist/chat/lib/stream.server.mjs +34 -0
- package/dist/chat/lib/types.d.mts +21 -0
- package/dist/chat/server.d.mts +3 -0
- package/dist/chat/server.mjs +3 -0
- package/dist/chat.d.mts +3 -0
- package/dist/chat.mjs +3 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +1 -0
- package/dist/mcp/lib/content.d.mts +66 -0
- package/dist/mcp/lib/content.d.mts.map +1 -0
- package/dist/mcp/lib/content.mjs +115 -0
- package/dist/mcp/lib/content.mjs.map +1 -0
- package/dist/mcp/lib/tool-result.server.d.mts +12 -0
- package/dist/mcp/lib/tool-result.server.d.mts.map +1 -0
- package/dist/mcp/lib/tool-result.server.mjs +10 -0
- package/dist/mcp/lib/tool-result.server.mjs.map +1 -0
- package/dist/mcp/lib/types.d.mts +27 -0
- package/dist/mcp/server.d.mts +3 -0
- package/dist/mcp/server.mjs +3 -0
- package/dist/mcp/types.d.mts +27 -0
- package/dist/mcp/types.d.mts.map +1 -0
- package/dist/server/mcp-content.d.mts +44 -0
- package/dist/server/mcp-content.d.mts.map +1 -0
- package/dist/server/mcp-content.mjs +71 -0
- package/dist/server/mcp-content.mjs.map +1 -0
- package/dist/server/tools.d.mts +61 -0
- package/dist/server/tools.d.mts.map +1 -0
- package/dist/server/tools.mjs +47 -0
- package/dist/server/tools.mjs.map +1 -0
- package/dist/server.d.mts +3 -0
- package/dist/server.mjs +4 -0
- package/dist/tools/client.d.mts +3 -0
- package/dist/tools/client.mjs +5 -0
- package/dist/tools/lib/ai-sdk.server.d.mts +12 -0
- package/dist/tools/lib/ai-sdk.server.d.mts.map +1 -0
- package/dist/tools/lib/ai-sdk.server.mjs +38 -0
- package/dist/tools/lib/ai-sdk.server.mjs.map +1 -0
- package/dist/tools/lib/define-tool.server.d.mts +9 -0
- package/dist/tools/lib/define-tool.server.d.mts.map +1 -0
- package/dist/tools/lib/define-tool.server.mjs +13 -0
- package/dist/tools/lib/define-tool.server.mjs.map +1 -0
- package/dist/tools/lib/definitions.client.d.mts +20 -0
- package/dist/tools/lib/definitions.client.mjs +21 -0
- package/dist/tools/lib/definitions.d.mts +16 -0
- package/dist/tools/lib/definitions.d.mts.map +1 -0
- package/dist/tools/lib/definitions.mjs +20 -0
- package/dist/tools/lib/definitions.mjs.map +1 -0
- package/dist/tools/lib/resolvers.d.mts +41 -0
- package/dist/tools/lib/resolvers.d.mts.map +1 -0
- package/dist/tools/lib/resolvers.mjs +43 -0
- package/dist/tools/lib/resolvers.mjs.map +1 -0
- package/dist/tools/lib/types.client.d.mts +13 -0
- package/dist/tools/lib/types.d.mts +33 -0
- package/dist/tools/resolvers/agent.server.d.mts +27 -0
- package/dist/tools/resolvers/agent.server.d.mts.map +1 -0
- package/dist/tools/resolvers/agent.server.mjs +44 -0
- package/dist/tools/resolvers/agent.server.mjs.map +1 -0
- package/dist/tools/resolvers/mcp.server.d.mts +31 -0
- package/dist/tools/resolvers/mcp.server.d.mts.map +1 -0
- package/dist/tools/resolvers/mcp.server.mjs +20 -0
- package/dist/tools/resolvers/mcp.server.mjs.map +1 -0
- package/dist/tools/server.d.mts +5 -0
- package/dist/tools/server.mjs +5 -0
- package/dist/tools/types.d.mts +33 -0
- package/dist/tools/types.d.mts.map +1 -0
- package/package.json +61 -0
- package/src/agents/entry.server.ts +7 -0
- package/src/agents/lib/definitions.server.ts +14 -0
- package/src/agents/lib/delegation.server.ts +33 -0
- package/src/agents/lib/instructions.server.ts +37 -0
- package/src/agents/lib/types.ts +32 -0
- package/src/chat/components/agent-activity.client.tsx +21 -0
- package/src/chat/components/chat-composer.client.tsx +379 -0
- package/src/chat/components/chat-message.client.tsx +166 -0
- package/src/chat/components/chat-thread.client.tsx +242 -0
- package/src/chat/components/message-part.client.tsx +59 -0
- package/src/chat/components/starter-prompts.client.tsx +49 -0
- package/src/chat/components/tool-call-card.client.tsx +78 -0
- package/src/chat/entry.client.ts +18 -0
- package/src/chat/entry.server.ts +5 -0
- package/src/chat/entry.ts +5 -0
- package/src/chat/lib/parts.ts +33 -0
- package/src/chat/lib/stream.server.ts +40 -0
- package/src/chat/lib/types.ts +20 -0
- package/src/entry.ts +24 -0
- package/src/mcp/entry.server.ts +2 -0
- package/src/mcp/lib/content.ts +131 -0
- package/src/mcp/lib/types.ts +28 -0
- package/src/styles.css +1 -0
- package/src/tools/entry.client.ts +7 -0
- package/src/tools/entry.server.ts +11 -0
- package/src/tools/lib/definitions.client.ts +21 -0
- package/src/tools/lib/definitions.ts +24 -0
- package/src/tools/lib/types.client.ts +11 -0
- package/src/tools/lib/types.ts +44 -0
- package/src/tools/resolvers/agent.server.ts +78 -0
- package/src/tools/resolvers/mcp.server.ts +40 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "server-cli-only";
|
|
2
|
+
import { ToolLoopAgent } from "ai";
|
|
3
|
+
|
|
4
|
+
//#region src/agents/lib/definitions.server.ts
|
|
5
|
+
/**
|
|
6
|
+
* Creates an AI SDK tool-loop agent with Tulip's package-level entrypoint.
|
|
7
|
+
* This keeps applications from importing the underlying agent implementation directly.
|
|
8
|
+
*/
|
|
9
|
+
function createAgent(settings) {
|
|
10
|
+
return new ToolLoopAgent(settings);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { createAgent };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ToolContext, TulipToolDefinition } from "../../tools/lib/types.mjs";
|
|
2
|
+
import { DelegateToAgentToolOptions } from "./types.mjs";
|
|
3
|
+
import "../../tools/server.mjs";
|
|
4
|
+
import "server-cli-only";
|
|
5
|
+
|
|
6
|
+
//#region src/agents/lib/delegation.server.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Defines a Tulip tool that delegates work to another agent and returns its result.
|
|
9
|
+
* Resolve the returned definition with `resolveAgentTool()` before passing it to an agent.
|
|
10
|
+
*/
|
|
11
|
+
declare function delegateToAgentTool<const TName extends string, TInput extends Record<string, unknown>, TOutput = {
|
|
12
|
+
summary: string;
|
|
13
|
+
}, TContext extends ToolContext = ToolContext>(options: DelegateToAgentToolOptions<TName, TInput, TOutput, TContext>): TulipToolDefinition<TName, TInput, TOutput, TContext>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { delegateToAgentTool };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineTool } from "../../tools/lib/definitions.mjs";
|
|
2
|
+
import "server-cli-only";
|
|
3
|
+
|
|
4
|
+
//#region src/agents/lib/delegation.server.ts
|
|
5
|
+
/**
|
|
6
|
+
* Defines a Tulip tool that delegates work to another agent and returns its result.
|
|
7
|
+
* Resolve the returned definition with `resolveAgentTool()` before passing it to an agent.
|
|
8
|
+
*/
|
|
9
|
+
function delegateToAgentTool(options) {
|
|
10
|
+
return defineTool({
|
|
11
|
+
name: options.name,
|
|
12
|
+
title: options.title,
|
|
13
|
+
description: options.description,
|
|
14
|
+
inputSchema: options.inputSchema,
|
|
15
|
+
outputSchema: options.outputSchema,
|
|
16
|
+
contextSchema: options.contextSchema,
|
|
17
|
+
async execute(input, { abortSignal }) {
|
|
18
|
+
const result = await options.agent.generate({
|
|
19
|
+
prompt: options.prompt ? options.prompt(input) : String(input.task ?? ""),
|
|
20
|
+
abortSignal
|
|
21
|
+
});
|
|
22
|
+
return options.output ? options.output(result, input) : { summary: result.text };
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { delegateToAgentTool };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "server-cli-only";
|
|
2
|
+
|
|
3
|
+
//#region src/agents/lib/instructions.server.d.ts
|
|
4
|
+
type LoadAgentInstructionsOptions = {
|
|
5
|
+
path?: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Loads an agent's always-on instructions from a file next to the agent module.
|
|
9
|
+
* Pass `import.meta.url` from the agent file so relative paths resolve from that agent folder.
|
|
10
|
+
* Defaults to `./instructions.md`.
|
|
11
|
+
*/
|
|
12
|
+
declare function loadAgentInstructions(importMetaUrl: string, options?: LoadAgentInstructionsOptions): string;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { LoadAgentInstructionsOptions, loadAgentInstructions };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import "server-cli-only";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
|
|
4
|
+
//#region src/agents/lib/instructions.server.ts
|
|
5
|
+
const instructionCache = /* @__PURE__ */ new Map();
|
|
6
|
+
/**
|
|
7
|
+
* Loads an agent's always-on instructions from a file next to the agent module.
|
|
8
|
+
* Pass `import.meta.url` from the agent file so relative paths resolve from that agent folder.
|
|
9
|
+
* Defaults to `./instructions.md`.
|
|
10
|
+
*/
|
|
11
|
+
function loadAgentInstructions(importMetaUrl, options = {}) {
|
|
12
|
+
const instructionUrl = new URL(options.path ?? "./instructions.md", importMetaUrl);
|
|
13
|
+
const cacheKey = instructionUrl.href;
|
|
14
|
+
const cached = instructionCache.get(cacheKey);
|
|
15
|
+
if (cached !== void 0) return cached;
|
|
16
|
+
try {
|
|
17
|
+
const instructions = readFileSync(instructionUrl, "utf-8");
|
|
18
|
+
instructionCache.set(cacheKey, instructions);
|
|
19
|
+
return instructions;
|
|
20
|
+
} catch (error) {
|
|
21
|
+
throw new Error(`Unable to load agent instructions from ${instructionUrl.pathname}.`, { cause: error });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { loadAgentInstructions };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ToolContext, TulipToolDefinition } from "../../tools/lib/types.mjs";
|
|
2
|
+
import { Agent, Experimental_AgentSettings, FlexibleSchema, ToolSet } from "ai";
|
|
3
|
+
|
|
4
|
+
//#region src/agents/lib/types.d.ts
|
|
5
|
+
type AgentSettings = Experimental_AgentSettings;
|
|
6
|
+
type CreatedAgent<TTools extends ToolSet = ToolSet> = Agent<never, TTools, Record<string, unknown>, never>;
|
|
7
|
+
type DelegationTargetAgent = {
|
|
8
|
+
generate(options: {
|
|
9
|
+
prompt: string;
|
|
10
|
+
abortSignal?: AbortSignal;
|
|
11
|
+
}): PromiseLike<{
|
|
12
|
+
text: string;
|
|
13
|
+
}>;
|
|
14
|
+
};
|
|
15
|
+
type DelegateToAgentToolOptions<TName extends string, TInput extends Record<string, unknown>, TOutput, TContext extends ToolContext = ToolContext> = Pick<TulipToolDefinition<TName, TInput, TOutput, TContext>, "name" | "title" | "description"> & {
|
|
16
|
+
agent: DelegationTargetAgent;
|
|
17
|
+
inputSchema: FlexibleSchema<TInput>;
|
|
18
|
+
outputSchema?: FlexibleSchema<TOutput>;
|
|
19
|
+
contextSchema?: FlexibleSchema<TContext>;
|
|
20
|
+
prompt?: (input: TInput) => string;
|
|
21
|
+
output?: (result: {
|
|
22
|
+
text: string;
|
|
23
|
+
}, input: TInput) => TOutput;
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { AgentSettings, CreatedAgent, DelegateToAgentToolOptions, DelegationTargetAgent };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AgentSettings, CreatedAgent, DelegateToAgentToolOptions, DelegationTargetAgent } from "./lib/types.mjs";
|
|
2
|
+
import { createAgent } from "./lib/definitions.server.mjs";
|
|
3
|
+
import { delegateToAgentTool } from "./lib/delegation.server.mjs";
|
|
4
|
+
import { LoadAgentInstructionsOptions, loadAgentInstructions } from "./lib/instructions.server.mjs";
|
|
5
|
+
export { AgentSettings, CreatedAgent, DelegateToAgentToolOptions, DelegationTargetAgent, LoadAgentInstructionsOptions, createAgent, delegateToAgentTool, loadAgentInstructions };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createAgent } from "./lib/definitions.server.mjs";
|
|
2
|
+
import { delegateToAgentTool } from "./lib/delegation.server.mjs";
|
|
3
|
+
import { loadAgentInstructions } from "./lib/instructions.server.mjs";
|
|
4
|
+
|
|
5
|
+
export { createAgent, delegateToAgentTool, loadAgentInstructions };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AgentActivity, AgentActivityProps } from "./components/agent-activity.client.mjs";
|
|
2
|
+
import { ChatComposer, ChatComposerActions, ChatComposerAttachmentButton, ChatComposerInput, ChatComposerModelSelect, ChatComposerProps, ChatComposerStatus, ChatComposerSubmit, ChatComposerToolbar } from "./components/chat-composer.client.mjs";
|
|
3
|
+
import { ChatPart, StreamAgentChatOptions, ToolChatPart } from "./lib/types.mjs";
|
|
4
|
+
import { ChatMessage, ChatMessageContent, ChatMessageFooter, ChatMessageHeader, ChatMessageParts, ChatMessageProps } from "./components/chat-message.client.mjs";
|
|
5
|
+
import { ChatThread, ChatThreadActivity, ChatThreadBottom, ChatThreadContent, ChatThreadMessage, ChatThreadProps, ChatThreadScrollButton } from "./components/chat-thread.client.mjs";
|
|
6
|
+
import { ChatMessagePart, ChatMessagePartProps } from "./components/message-part.client.mjs";
|
|
7
|
+
import { StarterPrompts, StarterPromptsProps } from "./components/starter-prompts.client.mjs";
|
|
8
|
+
import { ToolCallCard, ToolCallCardLabels, ToolCallCardProps } from "./components/tool-call-card.client.mjs";
|
|
9
|
+
import { getChatPartKey, getDefaultToolTitle, getToolName, isToolPart, stringifyChatValue } from "./lib/parts.mjs";
|
|
10
|
+
export { AgentActivity, AgentActivityProps, ChatComposer, ChatComposerActions, ChatComposerAttachmentButton, ChatComposerInput, ChatComposerModelSelect, ChatComposerProps, ChatComposerStatus, ChatComposerSubmit, ChatComposerToolbar, ChatMessage, ChatMessageContent, ChatMessageFooter, ChatMessageHeader, ChatMessagePart, ChatMessagePartProps, ChatMessageParts, ChatMessageProps, ChatPart, ChatThread, ChatThreadActivity, ChatThreadBottom, ChatThreadContent, ChatThreadMessage, ChatThreadProps, ChatThreadScrollButton, StarterPrompts, StarterPromptsProps, StreamAgentChatOptions, ToolCallCard, ToolCallCardLabels, ToolCallCardProps, ToolChatPart, getChatPartKey, getDefaultToolTitle, getToolName, isToolPart, stringifyChatValue };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { getChatPartKey, getDefaultToolTitle, getToolName, isToolPart, stringifyChatValue } from "./lib/parts.mjs";
|
|
4
|
+
import { AgentActivity } from "./components/agent-activity.client.mjs";
|
|
5
|
+
import { ChatComposer, ChatComposerActions, ChatComposerAttachmentButton, ChatComposerInput, ChatComposerModelSelect, ChatComposerStatus, ChatComposerSubmit, ChatComposerToolbar } from "./components/chat-composer.client.mjs";
|
|
6
|
+
import { ToolCallCard } from "./components/tool-call-card.client.mjs";
|
|
7
|
+
import { ChatMessagePart } from "./components/message-part.client.mjs";
|
|
8
|
+
import { ChatMessage, ChatMessageContent, ChatMessageFooter, ChatMessageHeader, ChatMessageParts } from "./components/chat-message.client.mjs";
|
|
9
|
+
import { ChatThread, ChatThreadActivity, ChatThreadBottom, ChatThreadContent, ChatThreadMessage, ChatThreadScrollButton } from "./components/chat-thread.client.mjs";
|
|
10
|
+
import { StarterPrompts } from "./components/starter-prompts.client.mjs";
|
|
11
|
+
|
|
12
|
+
export { AgentActivity, ChatComposer, ChatComposerActions, ChatComposerAttachmentButton, ChatComposerInput, ChatComposerModelSelect, ChatComposerStatus, ChatComposerSubmit, ChatComposerToolbar, ChatMessage, ChatMessageContent, ChatMessageFooter, ChatMessageHeader, ChatMessagePart, ChatMessageParts, ChatThread, ChatThreadActivity, ChatThreadBottom, ChatThreadContent, ChatThreadMessage, ChatThreadScrollButton, StarterPrompts, ToolCallCard, getChatPartKey, getDefaultToolTitle, getToolName, isToolPart, stringifyChatValue };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
|
+
|
|
3
|
+
//#region src/chat/components/agent-activity.client.d.ts
|
|
4
|
+
type AgentActivityProps = {
|
|
5
|
+
className?: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Small typing indicator for an agent that is currently streaming a response.
|
|
9
|
+
*/
|
|
10
|
+
declare function AgentActivity({
|
|
11
|
+
className
|
|
12
|
+
}: AgentActivityProps): react_jsx_runtime0.JSX.Element;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { AgentActivity, AgentActivityProps };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@tulip-systems/core/lib";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/chat/components/agent-activity.client.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Small typing indicator for an agent that is currently streaming a response.
|
|
9
|
+
*/
|
|
10
|
+
function AgentActivity({ className }) {
|
|
11
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
12
|
+
className: cn("flex h-7 w-fit items-center gap-1 px-1", className),
|
|
13
|
+
children: [
|
|
14
|
+
/* @__PURE__ */ jsx("span", {
|
|
15
|
+
className: "sr-only",
|
|
16
|
+
children: "Assistant is responding"
|
|
17
|
+
}),
|
|
18
|
+
/* @__PURE__ */ jsx("span", { className: "size-1.5 animate-pulse rounded-full bg-muted-foreground/50 [animation-delay:-0.3s]" }),
|
|
19
|
+
/* @__PURE__ */ jsx("span", { className: "size-1.5 animate-pulse rounded-full bg-muted-foreground/50 [animation-delay:-0.15s]" }),
|
|
20
|
+
/* @__PURE__ */ jsx("span", { className: "size-1.5 animate-pulse rounded-full bg-muted-foreground/50" })
|
|
21
|
+
]
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { AgentActivity };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
|
+
import { ComponentProps, PropsWithChildren } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/chat/components/assistant-panel.client.d.ts
|
|
5
|
+
type AssistantPanelProps = PropsWithChildren<{
|
|
6
|
+
open?: boolean;
|
|
7
|
+
defaultOpen?: boolean;
|
|
8
|
+
onOpenChange?: (open: boolean) => void;
|
|
9
|
+
className?: string;
|
|
10
|
+
}>;
|
|
11
|
+
type AssistantPanelContentProps = ComponentProps<"div">;
|
|
12
|
+
type AssistantPanelThreadProps = ComponentProps<"div">;
|
|
13
|
+
type AssistantPanelInputProps = ComponentProps<"div">;
|
|
14
|
+
/**
|
|
15
|
+
* A composable admin assistant panel shell.
|
|
16
|
+
*
|
|
17
|
+
* The panel only renders its children while open, so expensive chat state can
|
|
18
|
+
* live in child components without slowing down the app when the panel is closed.
|
|
19
|
+
*/
|
|
20
|
+
declare function AssistantPanel({
|
|
21
|
+
open,
|
|
22
|
+
defaultOpen,
|
|
23
|
+
onOpenChange,
|
|
24
|
+
className,
|
|
25
|
+
children
|
|
26
|
+
}: AssistantPanelProps): react_jsx_runtime0.JSX.Element;
|
|
27
|
+
declare function AssistantPanelContent({
|
|
28
|
+
className,
|
|
29
|
+
...props
|
|
30
|
+
}: AssistantPanelContentProps): react_jsx_runtime0.JSX.Element;
|
|
31
|
+
declare function AssistantPanelThread({
|
|
32
|
+
className,
|
|
33
|
+
...props
|
|
34
|
+
}: AssistantPanelThreadProps): react_jsx_runtime0.JSX.Element;
|
|
35
|
+
declare function AssistantPanelInput({
|
|
36
|
+
className,
|
|
37
|
+
...props
|
|
38
|
+
}: AssistantPanelInputProps): react_jsx_runtime0.JSX.Element;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { AssistantPanel, AssistantPanelContent, AssistantPanelContentProps, AssistantPanelInput, AssistantPanelInputProps, AssistantPanelProps, AssistantPanelThread, AssistantPanelThreadProps };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@tulip-systems/core/lib";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
|
|
7
|
+
//#region src/chat/components/assistant-panel.client.tsx
|
|
8
|
+
/**
|
|
9
|
+
* A composable admin assistant panel shell.
|
|
10
|
+
*
|
|
11
|
+
* The panel only renders its children while open, so expensive chat state can
|
|
12
|
+
* live in child components without slowing down the app when the panel is closed.
|
|
13
|
+
*/
|
|
14
|
+
function AssistantPanel({ open, defaultOpen = false, onOpenChange, className, children }) {
|
|
15
|
+
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
16
|
+
const isOpen = open ?? internalOpen;
|
|
17
|
+
function setOpen(nextOpen) {
|
|
18
|
+
if (open === void 0) setInternalOpen(nextOpen);
|
|
19
|
+
onOpenChange?.(nextOpen);
|
|
20
|
+
}
|
|
21
|
+
return /* @__PURE__ */ jsxs("aside", {
|
|
22
|
+
"data-state": isOpen ? "open" : "closed",
|
|
23
|
+
className: cn("relative z-40 flex h-dvh w-[min(100vw,30rem)] shrink-0 flex-col border-border/60 border-l bg-sidebar/70 shadow-2xl backdrop-blur-2xl transition-[transform,width] duration-200 md:relative md:inset-auto md:h-dvh", isOpen ? "translate-x-0 px-content md:w-[30rem]" : "translate-x-full md:w-content md:translate-x-0", className),
|
|
24
|
+
children: [isOpen && children, /* @__PURE__ */ jsx("button", {
|
|
25
|
+
className: "absolute inset-y-0 left-0 h-full w-content bg-sidebar/70 hover:bg-primary/10",
|
|
26
|
+
type: "button",
|
|
27
|
+
onClick: () => setOpen(!isOpen),
|
|
28
|
+
"data-state": isOpen ? "open" : "closed",
|
|
29
|
+
"aria-label": isOpen ? "Close assistant panel" : "Open assistant panel"
|
|
30
|
+
})]
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function AssistantPanelContent({ className, ...props }) {
|
|
34
|
+
return /* @__PURE__ */ jsx("div", {
|
|
35
|
+
className: cn("flex min-h-0 flex-1 flex-col", className),
|
|
36
|
+
...props
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function AssistantPanelThread({ className, ...props }) {
|
|
40
|
+
return /* @__PURE__ */ jsx("div", {
|
|
41
|
+
className: cn("min-h-0 flex-1 overflow-hidden", className),
|
|
42
|
+
...props
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function AssistantPanelInput({ className, ...props }) {
|
|
46
|
+
return /* @__PURE__ */ jsx("div", {
|
|
47
|
+
className: cn("shrink-0 border-border/50 border-t bg-background/35 px-3 pt-3 pb-4 backdrop-blur-xl", className),
|
|
48
|
+
...props
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
export { AssistantPanel, AssistantPanelContent, AssistantPanelInput, AssistantPanelThread };
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { ChatStatus } from "ai";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
import { Button, Textarea } from "@tulip-systems/core/components";
|
|
4
|
+
import { ComponentProps, ReactNode } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/chat/components/chat-composer.client.d.ts
|
|
7
|
+
type ChatComposerProps = Omit<ComponentProps<"form">, "onSubmit"> & {
|
|
8
|
+
value: string;
|
|
9
|
+
onValueChange: (value: string) => void;
|
|
10
|
+
onSubmit: (value: string) => void;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
status?: ChatStatus;
|
|
13
|
+
statusLabel?: ReactNode;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Provides the root composer shell and shared state for all chat composer slots.
|
|
17
|
+
* Use it as the controlled boundary for the current draft value and submit handler.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <ChatComposer value={input} onValueChange={setInput} onSubmit={sendMessage}>
|
|
22
|
+
* <ChatComposerInput placeholder="Ask something..." />
|
|
23
|
+
* <ChatComposerToolbar>
|
|
24
|
+
* <ChatComposerActions>
|
|
25
|
+
* <ChatComposerAttachmentButton />
|
|
26
|
+
* </ChatComposerActions>
|
|
27
|
+
* <ChatComposerSubmit />
|
|
28
|
+
* </ChatComposerToolbar>
|
|
29
|
+
* </ChatComposer>
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
declare function ChatComposer({
|
|
33
|
+
value,
|
|
34
|
+
onValueChange,
|
|
35
|
+
onSubmit,
|
|
36
|
+
disabled,
|
|
37
|
+
status,
|
|
38
|
+
statusLabel,
|
|
39
|
+
className,
|
|
40
|
+
children,
|
|
41
|
+
...props
|
|
42
|
+
}: ChatComposerProps): react_jsx_runtime0.JSX.Element;
|
|
43
|
+
/**
|
|
44
|
+
* Renders the auto-growing textarea connected to the nearest `ChatComposer`.
|
|
45
|
+
* Pressing Enter submits the composer, while Shift+Enter inserts a new line.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```tsx
|
|
49
|
+
* <ChatComposerInput placeholder="Ask something..." rows={3} />
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
declare function ChatComposerInput({
|
|
53
|
+
rows,
|
|
54
|
+
className,
|
|
55
|
+
onKeyDown,
|
|
56
|
+
...props
|
|
57
|
+
}: Omit<ComponentProps<typeof Textarea>, "value" | "onChange" | "disabled">): react_jsx_runtime0.JSX.Element;
|
|
58
|
+
/**
|
|
59
|
+
* Renders the bottom toolbar area for composer actions and the submit button.
|
|
60
|
+
* Place `ChatComposerActions` on the left and `ChatComposerSubmit` on the right.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```tsx
|
|
64
|
+
* <ChatComposerToolbar>
|
|
65
|
+
* <ChatComposerActions>
|
|
66
|
+
* <ChatComposerAttachmentButton />
|
|
67
|
+
* </ChatComposerActions>
|
|
68
|
+
* <ChatComposerSubmit />
|
|
69
|
+
* </ChatComposerToolbar>
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
declare function ChatComposerToolbar({
|
|
73
|
+
className,
|
|
74
|
+
...props
|
|
75
|
+
}: ComponentProps<"div">): react_jsx_runtime0.JSX.Element;
|
|
76
|
+
/**
|
|
77
|
+
* Groups secondary composer controls such as attachments, model selection, or status.
|
|
78
|
+
* It keeps action controls aligned together inside `ChatComposerToolbar`.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```tsx
|
|
82
|
+
* <ChatComposerActions>
|
|
83
|
+
* <ChatComposerAttachmentButton />
|
|
84
|
+
* <ChatComposerModelSelect>GPT-5.5</ChatComposerModelSelect>
|
|
85
|
+
* <ChatComposerStatus />
|
|
86
|
+
* </ChatComposerActions>
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
declare function ChatComposerActions({
|
|
90
|
+
className,
|
|
91
|
+
...props
|
|
92
|
+
}: ComponentProps<"div">): react_jsx_runtime0.JSX.Element;
|
|
93
|
+
/**
|
|
94
|
+
* Renders an attachment action button for opening a file picker or context picker.
|
|
95
|
+
* It uses a file-upload icon and `Context toevoegen` accessible label by default.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```tsx
|
|
99
|
+
* <ChatComposerAttachmentButton onClick={openFilePicker} />
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
declare function ChatComposerAttachmentButton({
|
|
103
|
+
className,
|
|
104
|
+
disabled,
|
|
105
|
+
...props
|
|
106
|
+
}: ComponentProps<typeof Button>): react_jsx_runtime0.JSX.Element;
|
|
107
|
+
/**
|
|
108
|
+
* Renders a compact model selector trigger inside the composer toolbar.
|
|
109
|
+
* Use it as a simple button or compose it with a popover/select in application code.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```tsx
|
|
113
|
+
* <ChatComposerModelSelect onClick={openModelMenu}>GPT-5.5</ChatComposerModelSelect>
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
declare function ChatComposerModelSelect({
|
|
117
|
+
className,
|
|
118
|
+
disabled,
|
|
119
|
+
children,
|
|
120
|
+
...props
|
|
121
|
+
}: ComponentProps<typeof Button>): react_jsx_runtime0.JSX.Element;
|
|
122
|
+
/**
|
|
123
|
+
* Displays the current composer status from `ChatComposer.status` and `statusLabel`.
|
|
124
|
+
* It renders nothing when no label or children are provided.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```tsx
|
|
128
|
+
* <ChatComposer status="streaming" statusLabel="Thinking...">
|
|
129
|
+
* <ChatComposerInput />
|
|
130
|
+
* <ChatComposerToolbar>
|
|
131
|
+
* <ChatComposerActions>
|
|
132
|
+
* <ChatComposerStatus />
|
|
133
|
+
* </ChatComposerActions>
|
|
134
|
+
* <ChatComposerSubmit />
|
|
135
|
+
* </ChatComposerToolbar>
|
|
136
|
+
* </ChatComposer>
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
declare function ChatComposerStatus({
|
|
140
|
+
className,
|
|
141
|
+
children,
|
|
142
|
+
...props
|
|
143
|
+
}: ComponentProps<"div">): react_jsx_runtime0.JSX.Element | null;
|
|
144
|
+
/**
|
|
145
|
+
* Renders the primary submit button for the current composer draft.
|
|
146
|
+
* It uses an arrow-up icon by default and disables itself while the composer cannot submit.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```tsx
|
|
150
|
+
* <ChatComposerSubmit />
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
declare function ChatComposerSubmit({
|
|
154
|
+
className,
|
|
155
|
+
disabled,
|
|
156
|
+
onClick,
|
|
157
|
+
...props
|
|
158
|
+
}: ComponentProps<typeof Button>): react_jsx_runtime0.JSX.Element;
|
|
159
|
+
//#endregion
|
|
160
|
+
export { ChatComposer, ChatComposerActions, ChatComposerAttachmentButton, ChatComposerInput, ChatComposerModelSelect, ChatComposerProps, ChatComposerStatus, ChatComposerSubmit, ChatComposerToolbar };
|