@codeworksh/aikit 0.1.0 → 0.2.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.
@@ -1,75 +0,0 @@
1
- import { type Static, type TSchema, Type } from "@sinclair/typebox";
2
- import { Message } from "../message/message";
3
- import type { Model } from "../model/model";
4
- import type { Stream } from "../provider/stream";
5
-
6
- export namespace Agent {
7
- export const ToolTerminalResultSchema = Type.Union([Message.ToolCompletedSchema, Message.ToolErrorSchema]);
8
- export const ToolResultSchema = Type.Union([
9
- Message.ToolRunningSchema,
10
- Message.ToolCompletedSchema,
11
- Message.ToolErrorSchema,
12
- ]);
13
-
14
- export type ToolRunningResult<T> = Omit<Static<typeof Message.ToolRunningSchema>, "partial"> & {
15
- partial?: Omit<Static<typeof Message.ToolRunningPartial>, "details"> & {
16
- details?: T;
17
- };
18
- };
19
- export type ToolCompletedResult<T> = Omit<Static<typeof Message.ToolCompletedSchema>, "result"> & {
20
- result: Omit<Static<typeof Message.ToolSuccessResult>, "details"> & {
21
- details?: T;
22
- };
23
- };
24
- export type ToolErrorResult<T> = Omit<Static<typeof Message.ToolErrorSchema>, "result"> & {
25
- result: Omit<Static<typeof Message.ToolErrorResult>, "details"> & {
26
- details?: T;
27
- };
28
- };
29
- export type ToolTerminalResult<T> = ToolCompletedResult<T> | ToolErrorResult<T>;
30
-
31
- // callback for tool execution updates.
32
- // consumers can narrow on status if needed
33
- // type inference:
34
- // U - update
35
- export type ToolUpdateCallback<U = any> = (result: ToolRunningResult<U>) => void;
36
-
37
- export interface AgentTool<TParameters extends TSchema = TSchema, U = any, R = U> extends Message.Tool<TParameters> {
38
- // A human-readable label for the tool for display
39
- label: string;
40
- execute: (
41
- callID: string,
42
- params: Static<TParameters>,
43
- signal?: AbortSignal,
44
- onUpdate?: ToolUpdateCallback<U>,
45
- ) => Promise<ToolTerminalResult<R>>;
46
- }
47
- export type AnyAgentTool = AgentTool<any, any, any>;
48
-
49
- export interface State<TTool extends AnyAgentTool = AnyAgentTool> {
50
- systemPrompt: string;
51
- model: Model.Value;
52
- thinkingLevel: Stream.ThinkingLevel;
53
- tools: TTool[];
54
- messages: Message.Message[];
55
- isStreaming: boolean;
56
- streamMessage: Message.Message | null;
57
- pendingToolCalls: Set<string>;
58
- error?: string;
59
- }
60
-
61
- // AgentContext is like Message.Context but uses AgentTool
62
- export interface AgentContext<TTool extends AnyAgentTool = AnyAgentTool> {
63
- systemPrompt: string;
64
- messages: Message.Message[];
65
- tools?: TTool[];
66
- }
67
-
68
- export const ToolCallInFlightSchema = Type.Object({
69
- callID: Type.String(),
70
- name: Type.String(),
71
- rawArgs: Type.Record(Type.String(), Type.Any()),
72
- args: Type.Optional(Type.Any()), // post validation
73
- });
74
- export type ToolCallInFlight = Static<typeof ToolCallInFlightSchema>;
75
- }