mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 05:00:16 +00:00
Fix NodeJS compat
This commit is contained in:
parent
e2d23a5abb
commit
197259c88a
19 changed files with 110 additions and 99 deletions
|
|
@ -1,8 +1,8 @@
|
|||
import { EventStream } from "../event-stream";
|
||||
import { EventStream } from "../event-stream.js";
|
||||
import { streamSimple } from "../stream.js";
|
||||
import type { AssistantMessage, Context, Message, ToolResultMessage, UserMessage } from "../types.js";
|
||||
import { validateToolArguments } from "../validation.js";
|
||||
import type { AgentContext, AgentEvent, AgentTool, AgentToolResult, PromptConfig } from "./types";
|
||||
import type { AgentContext, AgentEvent, AgentTool, AgentToolResult, PromptConfig } from "./types.js";
|
||||
|
||||
// Main prompt function - returns a stream of events
|
||||
export function prompt(
|
||||
|
|
@ -13,8 +13,8 @@ export function prompt(
|
|||
streamFn?: typeof streamSimple,
|
||||
): EventStream<AgentEvent, AgentContext["messages"]> {
|
||||
const stream = new EventStream<AgentEvent, AgentContext["messages"]>(
|
||||
(event) => event.type === "agent_end",
|
||||
(event) => (event.type === "agent_end" ? event.messages : []),
|
||||
(event: AgentEvent) => event.type === "agent_end",
|
||||
(event: AgentEvent) => (event.type === "agent_end" ? event.messages : []),
|
||||
);
|
||||
|
||||
// Run the prompt async
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
export { prompt } from "./agent";
|
||||
export * from "./tools";
|
||||
export type { AgentContext, AgentEvent, AgentTool, PromptConfig } from "./types";
|
||||
export { prompt } from "./agent.js";
|
||||
export * from "./tools/index.js";
|
||||
export type { AgentContext, AgentEvent, AgentTool, PromptConfig } from "./types.js";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { type Static, Type } from "@sinclair/typebox";
|
||||
import type { AgentTool } from "../../agent";
|
||||
import type { AgentTool } from "../../agent/types.js";
|
||||
|
||||
export interface CalculateResult {
|
||||
output: string;
|
||||
|
|
@ -26,7 +26,7 @@ export const calculateTool: AgentTool<typeof calculateSchema, undefined> = {
|
|||
name: "calculate",
|
||||
description: "Evaluate mathematical expressions",
|
||||
parameters: calculateSchema,
|
||||
execute: async (_toolCallId, args) => {
|
||||
execute: async (_toolCallId: string, args: CalculateParams) => {
|
||||
return calculate(args.expression);
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { type Static, Type } from "@sinclair/typebox";
|
||||
import type { AgentTool } from "../../agent";
|
||||
import type { AgentToolResult } from "../types";
|
||||
import type { AgentTool } from "../../agent/index.js";
|
||||
import type { AgentToolResult } from "../types.js";
|
||||
|
||||
export interface GetCurrentTimeResult extends AgentToolResult<{ utcTimestamp: number }> {}
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ export const getCurrentTimeTool: AgentTool<typeof getCurrentTimeSchema, { utcTim
|
|||
name: "get_current_time",
|
||||
description: "Get the current date and time",
|
||||
parameters: getCurrentTimeSchema,
|
||||
execute: async (_toolCallId, args) => {
|
||||
execute: async (_toolCallId: string, args: GetCurrentTimeParams) => {
|
||||
return getCurrentTime(args.timezone);
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
export { calculate, calculateTool } from "./calculate";
|
||||
export { getCurrentTime, getCurrentTimeTool } from "./get-current-time";
|
||||
export { calculate, calculateTool } from "./calculate.js";
|
||||
export { getCurrentTime, getCurrentTimeTool } from "./get-current-time.js";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue