@jussmor/sdk-ai 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/dist/conversation-kIkMQdYK.d.cts +105 -0
- package/dist/conversation-kIkMQdYK.d.ts +105 -0
- package/dist/conversation-store-CAyPuBjk.d.ts +10 -0
- package/dist/conversation-store-Cl42jpsA.d.cts +10 -0
- package/dist/index.cjs +1630 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +251 -0
- package/dist/index.d.ts +251 -0
- package/dist/index.js +1536 -0
- package/dist/index.js.map +1 -0
- package/dist/memory-uBLqrQRY.d.cts +28 -0
- package/dist/memory-uBLqrQRY.d.ts +28 -0
- package/dist/providers/llm/anthropic.cjs +275 -0
- package/dist/providers/llm/anthropic.cjs.map +1 -0
- package/dist/providers/llm/anthropic.d.cts +22 -0
- package/dist/providers/llm/anthropic.d.ts +22 -0
- package/dist/providers/llm/anthropic.js +240 -0
- package/dist/providers/llm/anthropic.js.map +1 -0
- package/dist/providers/llm/ollama.cjs +195 -0
- package/dist/providers/llm/ollama.cjs.map +1 -0
- package/dist/providers/llm/ollama.d.cts +23 -0
- package/dist/providers/llm/ollama.d.ts +23 -0
- package/dist/providers/llm/ollama.js +170 -0
- package/dist/providers/llm/ollama.js.map +1 -0
- package/dist/providers/llm/openai.cjs +213 -0
- package/dist/providers/llm/openai.cjs.map +1 -0
- package/dist/providers/llm/openai.d.cts +22 -0
- package/dist/providers/llm/openai.d.ts +22 -0
- package/dist/providers/llm/openai.js +178 -0
- package/dist/providers/llm/openai.js.map +1 -0
- package/dist/providers/memory/filesystem.cjs +112 -0
- package/dist/providers/memory/filesystem.cjs.map +1 -0
- package/dist/providers/memory/filesystem.d.cts +17 -0
- package/dist/providers/memory/filesystem.d.ts +17 -0
- package/dist/providers/memory/filesystem.js +87 -0
- package/dist/providers/memory/filesystem.js.map +1 -0
- package/dist/providers/store/filesystem.cjs +87 -0
- package/dist/providers/store/filesystem.cjs.map +1 -0
- package/dist/providers/store/filesystem.d.cts +14 -0
- package/dist/providers/store/filesystem.d.ts +14 -0
- package/dist/providers/store/filesystem.js +62 -0
- package/dist/providers/store/filesystem.js.map +1 -0
- package/dist/providers/thread/memory.cjs +81 -0
- package/dist/providers/thread/memory.cjs.map +1 -0
- package/dist/providers/thread/memory.d.cts +14 -0
- package/dist/providers/thread/memory.d.ts +14 -0
- package/dist/providers/thread/memory.js +56 -0
- package/dist/providers/thread/memory.js.map +1 -0
- package/dist/providers/thread/sqlite.cjs +917 -0
- package/dist/providers/thread/sqlite.cjs.map +1 -0
- package/dist/providers/thread/sqlite.d.cts +17 -0
- package/dist/providers/thread/sqlite.d.ts +17 -0
- package/dist/providers/thread/sqlite.js +911 -0
- package/dist/providers/thread/sqlite.js.map +1 -0
- package/dist/providers/tokenizers/auto.cjs +136 -0
- package/dist/providers/tokenizers/auto.cjs.map +1 -0
- package/dist/providers/tokenizers/auto.d.cts +24 -0
- package/dist/providers/tokenizers/auto.d.ts +24 -0
- package/dist/providers/tokenizers/auto.js +107 -0
- package/dist/providers/tokenizers/auto.js.map +1 -0
- package/dist/streaming-B-P6Fw_k.d.cts +372 -0
- package/dist/streaming-BtD23BE0.d.ts +372 -0
- package/dist/thread-C2b9xRMJ.d.cts +30 -0
- package/dist/thread-C2b9xRMJ.d.ts +30 -0
- package/dist/tokenizer-BhG_RGUk.d.cts +13 -0
- package/dist/tokenizer-BhG_RGUk.d.ts +13 -0
- package/package.json +84 -0
- package/src/agent-loop.ts +311 -0
- package/src/agent-source.ts +12 -0
- package/src/artifact.ts +31 -0
- package/src/compaction.ts +75 -0
- package/src/context-budget.ts +65 -0
- package/src/conversation-store.ts +8 -0
- package/src/conversation.ts +42 -0
- package/src/dispatch.ts +207 -0
- package/src/engine.ts +53 -0
- package/src/execution-context.ts +31 -0
- package/src/index.ts +37 -0
- package/src/interrupt-store.ts +25 -0
- package/src/interrupt.ts +55 -0
- package/src/llm-router.ts +34 -0
- package/src/llm.ts +100 -0
- package/src/memory-selector.ts +38 -0
- package/src/memory.ts +34 -0
- package/src/mode.ts +81 -0
- package/src/permissions.ts +104 -0
- package/src/protocol.ts +1 -0
- package/src/providers/llm/anthropic.ts +298 -0
- package/src/providers/llm/ollama.ts +219 -0
- package/src/providers/llm/openai.ts +215 -0
- package/src/providers/memory/filesystem.ts +99 -0
- package/src/providers/store/filesystem.ts +64 -0
- package/src/providers/thread/memory.ts +67 -0
- package/src/providers/thread/sqlite.ts +147 -0
- package/src/providers/tokenizers/auto.ts +26 -0
- package/src/providers/tokenizers/byte.ts +27 -0
- package/src/providers/tokenizers/tiktoken.ts +91 -0
- package/src/reasoning.ts +7 -0
- package/src/rule-matcher.ts +32 -0
- package/src/runtime.ts +416 -0
- package/src/safety.ts +56 -0
- package/src/sandbox.ts +23 -0
- package/src/session-context.ts +33 -0
- package/src/skill-source.ts +21 -0
- package/src/streaming.ts +124 -0
- package/src/system-prompt.ts +71 -0
- package/src/system-reminder.ts +9 -0
- package/src/thread.ts +33 -0
- package/src/tokenizer.ts +31 -0
- package/src/tool.ts +175 -0
- package/src/tracing.ts +63 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
type Role = "system" | "user" | "assistant" | "tool";
|
|
2
|
+
interface ImageContent {
|
|
3
|
+
source?: string;
|
|
4
|
+
mediaType?: string;
|
|
5
|
+
url?: string;
|
|
6
|
+
}
|
|
7
|
+
interface DocumentContent {
|
|
8
|
+
source?: string;
|
|
9
|
+
mediaType?: string;
|
|
10
|
+
url?: string;
|
|
11
|
+
title?: string;
|
|
12
|
+
cacheControl?: string;
|
|
13
|
+
}
|
|
14
|
+
interface ToolCallEntry {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
arguments: string;
|
|
18
|
+
}
|
|
19
|
+
interface ToolChoice {
|
|
20
|
+
type: "auto" | "any" | "tool";
|
|
21
|
+
name?: string;
|
|
22
|
+
disableParallelToolUse?: boolean;
|
|
23
|
+
}
|
|
24
|
+
interface ChatMessage {
|
|
25
|
+
role: Role;
|
|
26
|
+
content: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
toolCallId?: string;
|
|
29
|
+
toolCalls?: ToolCallEntry[];
|
|
30
|
+
images?: ImageContent[];
|
|
31
|
+
documents?: DocumentContent[];
|
|
32
|
+
}
|
|
33
|
+
interface ToolFuncParams {
|
|
34
|
+
type: "object";
|
|
35
|
+
properties?: Record<string, ToolParam>;
|
|
36
|
+
required?: string[];
|
|
37
|
+
}
|
|
38
|
+
interface ToolParam {
|
|
39
|
+
type: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
enum?: string[];
|
|
42
|
+
items?: ToolParam;
|
|
43
|
+
properties?: Record<string, ToolParam>;
|
|
44
|
+
required?: string[];
|
|
45
|
+
}
|
|
46
|
+
interface ToolDef {
|
|
47
|
+
type: "function";
|
|
48
|
+
function: {
|
|
49
|
+
name: string;
|
|
50
|
+
description: string;
|
|
51
|
+
parameters: ToolFuncParams;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
interface ChatRequest {
|
|
55
|
+
model?: string;
|
|
56
|
+
messages: ChatMessage[];
|
|
57
|
+
tools?: ToolDef[];
|
|
58
|
+
toolChoice?: ToolChoice;
|
|
59
|
+
temperature?: number;
|
|
60
|
+
topP?: number;
|
|
61
|
+
topK?: number;
|
|
62
|
+
maxTokens?: number;
|
|
63
|
+
reasoningEffort?: string;
|
|
64
|
+
thinkingBudget?: number;
|
|
65
|
+
stop?: string[];
|
|
66
|
+
metadata?: Record<string, string>;
|
|
67
|
+
}
|
|
68
|
+
interface TokenUsage {
|
|
69
|
+
promptTokens: number;
|
|
70
|
+
completionTokens: number;
|
|
71
|
+
totalTokens: number;
|
|
72
|
+
}
|
|
73
|
+
interface ChatResponse {
|
|
74
|
+
content: string;
|
|
75
|
+
reasoning?: string;
|
|
76
|
+
thinkingContent?: string;
|
|
77
|
+
toolCalls?: ToolCallEntry[];
|
|
78
|
+
finishReason: string;
|
|
79
|
+
usage: TokenUsage;
|
|
80
|
+
model?: string;
|
|
81
|
+
}
|
|
82
|
+
interface LLMProvider {
|
|
83
|
+
chat(req: ChatRequest, signal?: AbortSignal): Promise<ChatResponse>;
|
|
84
|
+
}
|
|
85
|
+
interface ModelRouter {
|
|
86
|
+
route(model: string): LLMProvider;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
interface Conversation {
|
|
90
|
+
id: string;
|
|
91
|
+
threadId?: string;
|
|
92
|
+
messages: ChatMessage[];
|
|
93
|
+
memoryRead: boolean;
|
|
94
|
+
turnCount: number;
|
|
95
|
+
createdAt: Date;
|
|
96
|
+
lastTurnAt?: Date;
|
|
97
|
+
}
|
|
98
|
+
declare function newConversation(id: string): Conversation;
|
|
99
|
+
declare function isCold(conv: Conversation): boolean;
|
|
100
|
+
declare function appendUser(conv: Conversation, content: string): void;
|
|
101
|
+
declare function appendAssistant(conv: Conversation, content: string): void;
|
|
102
|
+
declare function incrementTurn(conv: Conversation): void;
|
|
103
|
+
declare function messageCount(conv: Conversation): number;
|
|
104
|
+
|
|
105
|
+
export { type ChatMessage as C, type DocumentContent as D, type ImageContent as I, type LLMProvider as L, type ModelRouter as M, type Role as R, type ToolCallEntry as T, type Conversation as a, type ChatRequest as b, type ChatResponse as c, type TokenUsage as d, type ToolChoice as e, type ToolDef as f, type ToolFuncParams as g, type ToolParam as h, appendAssistant as i, appendUser as j, incrementTurn as k, isCold as l, messageCount as m, newConversation as n };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
type Role = "system" | "user" | "assistant" | "tool";
|
|
2
|
+
interface ImageContent {
|
|
3
|
+
source?: string;
|
|
4
|
+
mediaType?: string;
|
|
5
|
+
url?: string;
|
|
6
|
+
}
|
|
7
|
+
interface DocumentContent {
|
|
8
|
+
source?: string;
|
|
9
|
+
mediaType?: string;
|
|
10
|
+
url?: string;
|
|
11
|
+
title?: string;
|
|
12
|
+
cacheControl?: string;
|
|
13
|
+
}
|
|
14
|
+
interface ToolCallEntry {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
arguments: string;
|
|
18
|
+
}
|
|
19
|
+
interface ToolChoice {
|
|
20
|
+
type: "auto" | "any" | "tool";
|
|
21
|
+
name?: string;
|
|
22
|
+
disableParallelToolUse?: boolean;
|
|
23
|
+
}
|
|
24
|
+
interface ChatMessage {
|
|
25
|
+
role: Role;
|
|
26
|
+
content: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
toolCallId?: string;
|
|
29
|
+
toolCalls?: ToolCallEntry[];
|
|
30
|
+
images?: ImageContent[];
|
|
31
|
+
documents?: DocumentContent[];
|
|
32
|
+
}
|
|
33
|
+
interface ToolFuncParams {
|
|
34
|
+
type: "object";
|
|
35
|
+
properties?: Record<string, ToolParam>;
|
|
36
|
+
required?: string[];
|
|
37
|
+
}
|
|
38
|
+
interface ToolParam {
|
|
39
|
+
type: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
enum?: string[];
|
|
42
|
+
items?: ToolParam;
|
|
43
|
+
properties?: Record<string, ToolParam>;
|
|
44
|
+
required?: string[];
|
|
45
|
+
}
|
|
46
|
+
interface ToolDef {
|
|
47
|
+
type: "function";
|
|
48
|
+
function: {
|
|
49
|
+
name: string;
|
|
50
|
+
description: string;
|
|
51
|
+
parameters: ToolFuncParams;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
interface ChatRequest {
|
|
55
|
+
model?: string;
|
|
56
|
+
messages: ChatMessage[];
|
|
57
|
+
tools?: ToolDef[];
|
|
58
|
+
toolChoice?: ToolChoice;
|
|
59
|
+
temperature?: number;
|
|
60
|
+
topP?: number;
|
|
61
|
+
topK?: number;
|
|
62
|
+
maxTokens?: number;
|
|
63
|
+
reasoningEffort?: string;
|
|
64
|
+
thinkingBudget?: number;
|
|
65
|
+
stop?: string[];
|
|
66
|
+
metadata?: Record<string, string>;
|
|
67
|
+
}
|
|
68
|
+
interface TokenUsage {
|
|
69
|
+
promptTokens: number;
|
|
70
|
+
completionTokens: number;
|
|
71
|
+
totalTokens: number;
|
|
72
|
+
}
|
|
73
|
+
interface ChatResponse {
|
|
74
|
+
content: string;
|
|
75
|
+
reasoning?: string;
|
|
76
|
+
thinkingContent?: string;
|
|
77
|
+
toolCalls?: ToolCallEntry[];
|
|
78
|
+
finishReason: string;
|
|
79
|
+
usage: TokenUsage;
|
|
80
|
+
model?: string;
|
|
81
|
+
}
|
|
82
|
+
interface LLMProvider {
|
|
83
|
+
chat(req: ChatRequest, signal?: AbortSignal): Promise<ChatResponse>;
|
|
84
|
+
}
|
|
85
|
+
interface ModelRouter {
|
|
86
|
+
route(model: string): LLMProvider;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
interface Conversation {
|
|
90
|
+
id: string;
|
|
91
|
+
threadId?: string;
|
|
92
|
+
messages: ChatMessage[];
|
|
93
|
+
memoryRead: boolean;
|
|
94
|
+
turnCount: number;
|
|
95
|
+
createdAt: Date;
|
|
96
|
+
lastTurnAt?: Date;
|
|
97
|
+
}
|
|
98
|
+
declare function newConversation(id: string): Conversation;
|
|
99
|
+
declare function isCold(conv: Conversation): boolean;
|
|
100
|
+
declare function appendUser(conv: Conversation, content: string): void;
|
|
101
|
+
declare function appendAssistant(conv: Conversation, content: string): void;
|
|
102
|
+
declare function incrementTurn(conv: Conversation): void;
|
|
103
|
+
declare function messageCount(conv: Conversation): number;
|
|
104
|
+
|
|
105
|
+
export { type ChatMessage as C, type DocumentContent as D, type ImageContent as I, type LLMProvider as L, type ModelRouter as M, type Role as R, type ToolCallEntry as T, type Conversation as a, type ChatRequest as b, type ChatResponse as c, type TokenUsage as d, type ToolChoice as e, type ToolDef as f, type ToolFuncParams as g, type ToolParam as h, appendAssistant as i, appendUser as j, incrementTurn as k, isCold as l, messageCount as m, newConversation as n };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { a as Conversation } from './conversation-kIkMQdYK.js';
|
|
2
|
+
|
|
3
|
+
interface ConversationStore {
|
|
4
|
+
save(conv: Conversation, signal?: AbortSignal): Promise<void>;
|
|
5
|
+
load(id: string, signal?: AbortSignal): Promise<Conversation | undefined>;
|
|
6
|
+
list(threadId?: string, signal?: AbortSignal): Promise<Conversation[]>;
|
|
7
|
+
delete(id: string, signal?: AbortSignal): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type { ConversationStore as C };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { a as Conversation } from './conversation-kIkMQdYK.cjs';
|
|
2
|
+
|
|
3
|
+
interface ConversationStore {
|
|
4
|
+
save(conv: Conversation, signal?: AbortSignal): Promise<void>;
|
|
5
|
+
load(id: string, signal?: AbortSignal): Promise<Conversation | undefined>;
|
|
6
|
+
list(threadId?: string, signal?: AbortSignal): Promise<Conversation[]>;
|
|
7
|
+
delete(id: string, signal?: AbortSignal): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type { ConversationStore as C };
|