@stacksjs/ai 0.70.23 → 0.70.26
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/README.md +1 -0
- package/dist/src/agents/claude/index.d.ts +29 -0
- package/dist/src/agents/index.d.ts +6 -0
- package/dist/src/buddy.d.ts +67 -0
- package/dist/src/drivers/anthropic/index.d.ts +34 -0
- package/dist/src/drivers/claude-agent-sdk/index.d.ts +36 -0
- package/dist/src/drivers/index.d.ts +13 -0
- package/dist/src/drivers/ollama/index.d.ts +83 -0
- package/dist/src/drivers/openai/index.d.ts +59 -0
- package/dist/src/image.d.ts +83 -0
- package/dist/src/index.d.ts +22 -0
- package/dist/src/index.js +175 -0
- package/dist/src/mcp.d.ts +112 -0
- package/dist/src/personalization.d.ts +103 -0
- package/dist/src/search.d.ts +91 -0
- package/dist/src/text.d.ts +10 -0
- package/dist/src/types.d.ts +157 -0
- package/dist/src/utils/client-bedrock-runtime.d.ts +16 -0
- package/dist/src/utils/client-bedrock.d.ts +27 -0
- package/dist/src/utils/model-access.d.ts +1 -0
- package/package.json +29 -8
- package/dist/client-bedrock-runtime.d.ts +0 -7
- package/dist/client-bedrock.d.ts +0 -5
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -3391
- package/dist/model-access.d.ts +0 -1
- package/dist/text.d.ts +0 -9
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Module Types
|
|
3
|
+
*
|
|
4
|
+
* Shared type definitions for AI drivers and agents.
|
|
5
|
+
*/
|
|
6
|
+
export declare interface AIMessage {
|
|
7
|
+
role: 'user' | 'assistant' | 'system'
|
|
8
|
+
content: string | AIMessageContent[]
|
|
9
|
+
}
|
|
10
|
+
export declare interface AIMessageContent {
|
|
11
|
+
type: 'text' | 'image_url' | 'image'
|
|
12
|
+
text?: string
|
|
13
|
+
image_url?: { url: string, detail?: 'auto' | 'low' | 'high' }
|
|
14
|
+
source?: { type: 'base64', media_type: string, data: string }
|
|
15
|
+
}
|
|
16
|
+
export declare interface AIDriver {
|
|
17
|
+
name: string
|
|
18
|
+
process: (command: string, context: string, history: AIMessage[]) => Promise<string>
|
|
19
|
+
stream?: (command: string, context: string, history: AIMessage[]) => AsyncGenerator<string>
|
|
20
|
+
embed?: (input: string | string[]) => Promise<number[] | number[][]>
|
|
21
|
+
}
|
|
22
|
+
export declare interface AIDriverConfig {
|
|
23
|
+
apiKey?: string
|
|
24
|
+
baseUrl?: string
|
|
25
|
+
model?: string
|
|
26
|
+
maxTokens?: number
|
|
27
|
+
}
|
|
28
|
+
export declare interface StreamingResult {
|
|
29
|
+
stream: ReadableStream<Uint8Array>
|
|
30
|
+
fullResponse: Promise<string>
|
|
31
|
+
}
|
|
32
|
+
export declare interface EmbeddingResult {
|
|
33
|
+
embedding: number[]
|
|
34
|
+
index: number
|
|
35
|
+
object: string
|
|
36
|
+
}
|
|
37
|
+
export declare interface EmbeddingsResponse {
|
|
38
|
+
data: EmbeddingResult[]
|
|
39
|
+
model: string
|
|
40
|
+
usage: {
|
|
41
|
+
prompt_tokens: number
|
|
42
|
+
total_tokens: number
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export declare interface ChatCompletionOptions {
|
|
46
|
+
model?: string
|
|
47
|
+
maxTokens?: number
|
|
48
|
+
temperature?: number
|
|
49
|
+
topP?: number
|
|
50
|
+
stop?: string | string[]
|
|
51
|
+
stream?: boolean
|
|
52
|
+
}
|
|
53
|
+
export declare interface AIResult {
|
|
54
|
+
content: string
|
|
55
|
+
model: string
|
|
56
|
+
usage?: {
|
|
57
|
+
promptTokens: number
|
|
58
|
+
completionTokens: number
|
|
59
|
+
totalTokens: number
|
|
60
|
+
}
|
|
61
|
+
finishReason?: string
|
|
62
|
+
}
|
|
63
|
+
export declare interface ClaudeAPIResponse {
|
|
64
|
+
content: Array<{ type: string, text: string }>
|
|
65
|
+
}
|
|
66
|
+
export declare interface OpenAIAPIResponse {
|
|
67
|
+
choices: Array<{ message: { content: string } }>
|
|
68
|
+
}
|
|
69
|
+
export declare interface OllamaAPIResponse {
|
|
70
|
+
message: { content: string }
|
|
71
|
+
}
|
|
72
|
+
export declare interface ClaudeStreamEvent {
|
|
73
|
+
type: string
|
|
74
|
+
subtype?: string
|
|
75
|
+
message?: {
|
|
76
|
+
content: Array<{
|
|
77
|
+
type: string
|
|
78
|
+
text?: string
|
|
79
|
+
name?: string
|
|
80
|
+
input?: Record<string, unknown>
|
|
81
|
+
}>
|
|
82
|
+
}
|
|
83
|
+
delta?: { text?: string }
|
|
84
|
+
result?: string
|
|
85
|
+
index?: number
|
|
86
|
+
content_block?: {
|
|
87
|
+
type: string
|
|
88
|
+
text?: string
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Buddy Types
|
|
92
|
+
export declare interface RepoState {
|
|
93
|
+
path: string
|
|
94
|
+
name: string
|
|
95
|
+
branch: string
|
|
96
|
+
hasChanges: boolean
|
|
97
|
+
lastCommit?: string
|
|
98
|
+
}
|
|
99
|
+
export declare interface GitHubCredentials {
|
|
100
|
+
token: string
|
|
101
|
+
username: string
|
|
102
|
+
name: string
|
|
103
|
+
email: string
|
|
104
|
+
}
|
|
105
|
+
export declare interface BuddyState {
|
|
106
|
+
repo: RepoState | null
|
|
107
|
+
conversationHistory: AIMessage[]
|
|
108
|
+
currentDriver: string
|
|
109
|
+
github: GitHubCredentials | null
|
|
110
|
+
}
|
|
111
|
+
export declare interface BuddyConfig {
|
|
112
|
+
workDir: string
|
|
113
|
+
commitMessage: string
|
|
114
|
+
ollamaHost: string
|
|
115
|
+
ollamaModel: string
|
|
116
|
+
}
|
|
117
|
+
export declare interface BuddyApiKeys {
|
|
118
|
+
anthropic?: string
|
|
119
|
+
openai?: string
|
|
120
|
+
claudeCliHost?: string
|
|
121
|
+
}
|
|
122
|
+
// Image types
|
|
123
|
+
export declare interface ImageGenerationConfig {
|
|
124
|
+
provider: 'openai'
|
|
125
|
+
model?: string
|
|
126
|
+
apiKey?: string
|
|
127
|
+
}
|
|
128
|
+
// Search/RAG types
|
|
129
|
+
export declare interface SearchConfig {
|
|
130
|
+
embeddingProvider: 'openai' | 'ollama'
|
|
131
|
+
embeddingModel?: string
|
|
132
|
+
generationProvider?: 'anthropic' | 'openai' | 'ollama'
|
|
133
|
+
generationModel?: string
|
|
134
|
+
}
|
|
135
|
+
// MCP types
|
|
136
|
+
export declare interface MCPConfig {
|
|
137
|
+
servers: Array<{
|
|
138
|
+
name: string
|
|
139
|
+
command?: string
|
|
140
|
+
args?: string[]
|
|
141
|
+
url?: string
|
|
142
|
+
env?: Record<string, string>
|
|
143
|
+
}>
|
|
144
|
+
}
|
|
145
|
+
// AI module config (used by @stacksjs/config)
|
|
146
|
+
export declare interface AIConfig {
|
|
147
|
+
default?: string
|
|
148
|
+
models?: string[]
|
|
149
|
+
drivers?: {
|
|
150
|
+
anthropic?: AIDriverConfig & { anthropicVersion?: string }
|
|
151
|
+
openai?: AIDriverConfig & { embeddingModel?: string }
|
|
152
|
+
ollama?: AIDriverConfig & { host?: string; embeddingModel?: string }
|
|
153
|
+
}
|
|
154
|
+
image?: ImageGenerationConfig
|
|
155
|
+
search?: SearchConfig
|
|
156
|
+
mcp?: MCPConfig
|
|
157
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { InvokeModelCommandInput, InvokeModelCommandOutput, InvokeModelWithResponseStreamCommandInput, InvokeModelWithResponseStreamCommandOutput } from '@stacksjs/ts-cloud/aws';
|
|
2
|
+
export type { InvokeModelCommandInput, InvokeModelWithResponseStreamCommandInput };
|
|
3
|
+
/*
|
|
4
|
+
* Invoke Model
|
|
5
|
+
* @param {InvokeModelCommandInput} params
|
|
6
|
+
* @returns {Promise<InvokeModelCommandOutput>}
|
|
7
|
+
* @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/BedrockRuntime.html#invokeModel-property
|
|
8
|
+
*/
|
|
9
|
+
export declare function invokeModel(params: InvokeModelCommandInput): Promise<InvokeModelCommandOutput>;
|
|
10
|
+
/*
|
|
11
|
+
* Invoke Model With Response Stream
|
|
12
|
+
* @param {InvokeModelWithResponseStreamCommandInput} params
|
|
13
|
+
* @returns {Promise<InvokeModelWithResponseStreamCommandOutput>}
|
|
14
|
+
* @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/BedrockRuntime.html#invokeModelWithResponseStream-property
|
|
15
|
+
*/
|
|
16
|
+
export declare function invokeModelWithResponseStream(params: InvokeModelWithResponseStreamCommandInput): Promise<InvokeModelWithResponseStreamCommandOutput>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { CreateModelCustomizationJobCommandInput, CreateModelCustomizationJobCommandOutput, GetModelCustomizationJobCommandInput, GetModelCustomizationJobCommandOutput, ListFoundationModelsCommandInput, ListFoundationModelsCommandOutput } from '@stacksjs/ts-cloud/aws';
|
|
2
|
+
export type {
|
|
3
|
+
CreateModelCustomizationJobCommandInput,
|
|
4
|
+
GetModelCustomizationJobCommandInput,
|
|
5
|
+
ListFoundationModelsCommandInput,
|
|
6
|
+
};
|
|
7
|
+
/*
|
|
8
|
+
* Create Model Customization Job
|
|
9
|
+
* @param {CreateModelCustomizationJobCommandInput} params
|
|
10
|
+
* @returns {Promise<CreateModelCustomizationJobCommandOutput>}
|
|
11
|
+
* @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Bedrock.html#CreateModelCustomizationJob-property
|
|
12
|
+
*/
|
|
13
|
+
export declare function createModelCustomizationJob(param: CreateModelCustomizationJobCommandInput): Promise<CreateModelCustomizationJobCommandOutput>;
|
|
14
|
+
/*
|
|
15
|
+
* Get Model Customization Job
|
|
16
|
+
* @param {GetModelCustomizationJobCommandInput} params
|
|
17
|
+
* @returns {Promise<GetModelCustomizationJobCommandOutput>}
|
|
18
|
+
* @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Bedrock.html#getModelCustomizationJob-property
|
|
19
|
+
*/
|
|
20
|
+
export declare function getModelCustomizationJob(params: GetModelCustomizationJobCommandInput): Promise<GetModelCustomizationJobCommandOutput>;
|
|
21
|
+
/*
|
|
22
|
+
* List Foundation Models
|
|
23
|
+
* @param {ListFoundationModelsCommandInput} params
|
|
24
|
+
* @returns {Promise<ListFoundationModelsCommandOutput>}
|
|
25
|
+
* @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Bedrock.html#listFoundationModels-property
|
|
26
|
+
*/
|
|
27
|
+
export declare function listFoundationModels(params: ListFoundationModelsCommandInput): Promise<ListFoundationModelsCommandOutput>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function requestModelAccess(): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/ai",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.70.
|
|
4
|
+
"version": "0.70.26",
|
|
5
5
|
"description": "Stacks Artificial Intelligence.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
|
-
"contributors": [
|
|
7
|
+
"contributors": [
|
|
8
|
+
"Chris Breuer <chris@stacksjs.com>"
|
|
9
|
+
],
|
|
8
10
|
"license": "MIT",
|
|
9
11
|
"funding": "https://github.com/sponsors/chrisbbreuer",
|
|
10
12
|
"homepage": "https://github.com/stacksjs/stacks/tree/main/storage/framework/core/ai#readme",
|
|
@@ -18,33 +20,52 @@
|
|
|
18
20
|
},
|
|
19
21
|
"keywords": [
|
|
20
22
|
"ai",
|
|
21
|
-
"
|
|
23
|
+
"anthropic",
|
|
22
24
|
"openai",
|
|
25
|
+
"ollama",
|
|
26
|
+
"embeddings",
|
|
27
|
+
"rag",
|
|
28
|
+
"mcp",
|
|
29
|
+
"vision",
|
|
23
30
|
"artificial intelligence",
|
|
24
31
|
"api",
|
|
25
32
|
"stacks"
|
|
26
33
|
],
|
|
27
34
|
"exports": {
|
|
28
35
|
".": {
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"bun": "./src/index.ts",
|
|
29
38
|
"import": "./dist/index.js"
|
|
30
39
|
},
|
|
31
40
|
"./*": {
|
|
41
|
+
"bun": "./src/*",
|
|
32
42
|
"import": "./dist/*"
|
|
33
43
|
}
|
|
34
44
|
},
|
|
35
45
|
"module": "dist/index.js",
|
|
36
46
|
"types": "dist/index.d.ts",
|
|
37
|
-
"files": [
|
|
47
|
+
"files": [
|
|
48
|
+
"README.md",
|
|
49
|
+
"dist"
|
|
50
|
+
],
|
|
38
51
|
"scripts": {
|
|
39
52
|
"build": "bun build.ts",
|
|
40
53
|
"typecheck": "bun tsc --noEmit",
|
|
41
54
|
"test": "bun test",
|
|
42
55
|
"prepublishOnly": "bun run build"
|
|
43
56
|
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@stacksjs/ts-cloud": "^0.2.15"
|
|
59
|
+
},
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"@anthropic-ai/claude-agent-sdk": "^0.2.79"
|
|
62
|
+
},
|
|
63
|
+
"peerDependenciesMeta": {
|
|
64
|
+
"@anthropic-ai/claude-agent-sdk": {
|
|
65
|
+
"optional": true
|
|
66
|
+
}
|
|
67
|
+
},
|
|
44
68
|
"devDependencies": {
|
|
45
|
-
"
|
|
46
|
-
"@aws-sdk/credential-providers": "^3.778.0",
|
|
47
|
-
"@stacksjs/development": "0.70.22",
|
|
48
|
-
"aws-sdk-client-mock": "^4.1.0"
|
|
69
|
+
"better-dx": "^0.2.12"
|
|
49
70
|
}
|
|
50
71
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export type { InvokeModelCommandInput, InvokeModelWithResponseStreamCommandInput }
|
|
2
|
-
export declare const client: BedrockRuntimeClient;
|
|
3
|
-
declare const logger: unknown;
|
|
4
|
-
export declare function invokeModel(params: InvokeModelCommandInput): Promise<InvokeModelCommandOutput>;
|
|
5
|
-
export declare function invokeModelWithResponseStream(params: InvokeModelWithResponseStreamCommandInput): Promise<InvokeModelWithResponseStreamCommandOutput>;
|
|
6
|
-
|
|
7
|
-
export { InvokeModelCommand }
|
package/dist/client-bedrock.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
declare const client: unknown;
|
|
3
|
-
export declare function createModelCustomizationJob(param: CreateModelCustomizationJobCommandInput): Promise<CreateModelCustomizationJobCommandOutput>;
|
|
4
|
-
export declare function getModelCustomizationJob(params: GetModelCustomizationJobCommandInput): Promise<GetModelCustomizationJobCommandOutput>;
|
|
5
|
-
export declare function listFoundationModels(params: ListFoundationModelsCommandInput): Promise<ListFoundationModelsCommandOutput>;
|
package/dist/index.d.ts
DELETED