@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.
- package/LICENSE +21 -0
- package/README.md +13 -12
- package/index.d.mts +8934 -0
- package/index.mjs +2515 -0
- package/index.mjs.map +1 -0
- package/package.json +60 -58
- package/src/agent/agent.ts +0 -75
- package/src/agent/loop.ts +0 -786
- package/src/agent.ts +0 -11
- package/src/event/event.ts +0 -271
- package/src/index.ts +0 -10
- package/src/llm.ts +0 -29
- package/src/message/message.ts +0 -280
- package/src/model/catalog.ts +0 -95
- package/src/model/model.ts +0 -253
- package/src/provider/provider.ts +0 -43
- package/src/provider/providers/anthropic/index.ts +0 -769
- package/src/provider/register.ts +0 -14
- package/src/provider/stream.ts +0 -299
- package/src/stream.ts +0 -72
- package/src/utils/eventstream.ts +0 -95
- package/src/utils/helpers.ts +0 -24
- package/src/utils/jsonparse.ts +0 -32
- package/src/utils/overflow.ts +0 -121
- package/src/utils/sanitize.ts +0 -25
- package/src/utils/validation.ts +0 -63
package/src/agent/agent.ts
DELETED
|
@@ -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
|
-
}
|