@iinm/plain-agent 1.0.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/.config/agents.library/code-simplifier.md +5 -0
- package/.config/agents.library/qa-engineer.md +74 -0
- package/.config/agents.library/software-architect.md +278 -0
- package/.config/agents.predefined/worker.md +3 -0
- package/.config/config.predefined.json +825 -0
- package/.config/prompts.library/code-review.md +8 -0
- package/.config/prompts.library/feature-dev.md +6 -0
- package/.config/prompts.predefined/shortcuts/commit-by-user.md +9 -0
- package/.config/prompts.predefined/shortcuts/commit.md +10 -0
- package/.config/prompts.predefined/shortcuts/general-question.md +6 -0
- package/LICENSE +21 -0
- package/README.md +624 -0
- package/bin/plain +3 -0
- package/bin/plain-interrupt +6 -0
- package/bin/plain-notify-desktop +19 -0
- package/bin/plain-notify-terminal-bell +3 -0
- package/package.json +57 -0
- package/sandbox/bin/plain-sandbox +972 -0
- package/src/agent.d.ts +48 -0
- package/src/agent.mjs +159 -0
- package/src/agentLoop.mjs +369 -0
- package/src/agentState.mjs +41 -0
- package/src/cliArgs.mjs +45 -0
- package/src/cliFormatter.mjs +217 -0
- package/src/cliInteractive.mjs +739 -0
- package/src/config.d.ts +48 -0
- package/src/config.mjs +168 -0
- package/src/context/consumeInterruptMessage.mjs +30 -0
- package/src/context/loadAgentRoles.mjs +272 -0
- package/src/context/loadPrompts.mjs +312 -0
- package/src/context/loadUserMessageContext.mjs +147 -0
- package/src/env.mjs +46 -0
- package/src/main.mjs +202 -0
- package/src/mcp.mjs +202 -0
- package/src/model.d.ts +109 -0
- package/src/modelCaller.mjs +29 -0
- package/src/modelDefinition.d.ts +73 -0
- package/src/prompt.mjs +128 -0
- package/src/providers/anthropic.d.ts +248 -0
- package/src/providers/anthropic.mjs +596 -0
- package/src/providers/gemini.d.ts +208 -0
- package/src/providers/gemini.mjs +752 -0
- package/src/providers/openai.d.ts +281 -0
- package/src/providers/openai.mjs +551 -0
- package/src/providers/openaiCompatible.d.ts +147 -0
- package/src/providers/openaiCompatible.mjs +658 -0
- package/src/providers/platform/azure.mjs +42 -0
- package/src/providers/platform/bedrock.mjs +74 -0
- package/src/providers/platform/googleCloud.mjs +34 -0
- package/src/subagent.mjs +247 -0
- package/src/tmpfile.mjs +27 -0
- package/src/tool.d.ts +74 -0
- package/src/toolExecutor.mjs +236 -0
- package/src/toolInputValidator.mjs +183 -0
- package/src/toolUseApprover.mjs +98 -0
- package/src/tools/askGoogle.mjs +135 -0
- package/src/tools/delegateToSubagent.d.ts +4 -0
- package/src/tools/delegateToSubagent.mjs +48 -0
- package/src/tools/execCommand.d.ts +22 -0
- package/src/tools/execCommand.mjs +200 -0
- package/src/tools/fetchWebPage.mjs +96 -0
- package/src/tools/patchFile.d.ts +4 -0
- package/src/tools/patchFile.mjs +96 -0
- package/src/tools/reportAsSubagent.d.ts +3 -0
- package/src/tools/reportAsSubagent.mjs +44 -0
- package/src/tools/tavilySearch.d.ts +6 -0
- package/src/tools/tavilySearch.mjs +57 -0
- package/src/tools/tmuxCommand.d.ts +14 -0
- package/src/tools/tmuxCommand.mjs +194 -0
- package/src/tools/writeFile.d.ts +4 -0
- package/src/tools/writeFile.mjs +56 -0
- package/src/utils/evalJSONConfig.mjs +48 -0
- package/src/utils/matchValue.d.ts +6 -0
- package/src/utils/matchValue.mjs +40 -0
- package/src/utils/noThrow.mjs +31 -0
- package/src/utils/notify.mjs +28 -0
- package/src/utils/parseFileRange.mjs +18 -0
- package/src/utils/readFileRange.mjs +33 -0
- package/src/utils/retryOnError.mjs +41 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/* Model */
|
|
2
|
+
export type GeminiModelConfig = {
|
|
3
|
+
// https://ai.google.dev/gemini-api/docs/models
|
|
4
|
+
model: string;
|
|
5
|
+
requestConfig?: {
|
|
6
|
+
generationConfig: GeminiGenerationConfig;
|
|
7
|
+
safetySettings?: GeminiSafetySetting[];
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// https://ai.google.dev/api/generate-content
|
|
12
|
+
export type GeminiGenerationConfig = {
|
|
13
|
+
/**
|
|
14
|
+
* If less than 1, it tends to cause loops in Gemini 3.
|
|
15
|
+
* https://ai.google.dev/gemini-api/docs/troubleshooting?hl=ja#repetitive-tokens
|
|
16
|
+
*/
|
|
17
|
+
temperature?: number;
|
|
18
|
+
maxOutputTokens?: number;
|
|
19
|
+
thinkingConfig?: {
|
|
20
|
+
includeThoughts: boolean;
|
|
21
|
+
} & (
|
|
22
|
+
| {
|
|
23
|
+
thinkingBudget?: number;
|
|
24
|
+
}
|
|
25
|
+
| {
|
|
26
|
+
thinkingLevel?: "low" | "medium" | "high";
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type GeminiSafetySetting = {
|
|
32
|
+
/**
|
|
33
|
+
* - HARM_CATEGORY_SEXUALLY_EXPLICIT
|
|
34
|
+
* - HARM_CATEGORY_HATE_SPEECH
|
|
35
|
+
* - HARM_CATEGORY_HARASSMENT
|
|
36
|
+
* - HARM_CATEGORY_DANGEROUS_CONTENT
|
|
37
|
+
*/
|
|
38
|
+
category: string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* - BLOCK_NONE
|
|
42
|
+
* ...
|
|
43
|
+
*/
|
|
44
|
+
threshold: string;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/* Input */
|
|
48
|
+
export type GeminiGenerateContentInput = {
|
|
49
|
+
generationConfig: GeminiGenerationConfig;
|
|
50
|
+
safetySettings: GeminiSafetySetting[];
|
|
51
|
+
system_instruction?: {
|
|
52
|
+
parts: GeminiContentPartText[];
|
|
53
|
+
};
|
|
54
|
+
cachedContent?: string;
|
|
55
|
+
contents: (GeminiUserContent | GeminiModelContent | GeminiFunctionContent)[];
|
|
56
|
+
tools?: GeminiToolDefinition[];
|
|
57
|
+
toolConfig?: GeminiToolConfig;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/* Content */
|
|
61
|
+
export type GeminiContent =
|
|
62
|
+
| GeminiSystemContent
|
|
63
|
+
| GeminiModelContent
|
|
64
|
+
| GeminiUserContent
|
|
65
|
+
| GeminiFunctionContent;
|
|
66
|
+
|
|
67
|
+
export type GeminiSystemContent = {
|
|
68
|
+
role: "system";
|
|
69
|
+
parts: GeminiContentPartText[];
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export type GeminiModelContent = {
|
|
73
|
+
role: "model";
|
|
74
|
+
parts?: (GeminiContentPartText | GeminiContentPartFunctionCall)[];
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export type GeminiUserContent = {
|
|
78
|
+
role: "user";
|
|
79
|
+
parts: (GeminiContentPartText | GeminiContentPartInlineData)[];
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export type GeminiFunctionContent = {
|
|
83
|
+
role: "user";
|
|
84
|
+
parts: GeminiContentPartFunctionResponse[];
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/* Content Parts */
|
|
88
|
+
export type GeminiContentPartText = {
|
|
89
|
+
text: string;
|
|
90
|
+
thoughtSignature?: string;
|
|
91
|
+
thought?: boolean;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export type GeminiContentPartFunctionCall = {
|
|
95
|
+
functionCall: {
|
|
96
|
+
name: string;
|
|
97
|
+
args: Record<string, unknown>;
|
|
98
|
+
};
|
|
99
|
+
thoughtSignature?: string;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export type GeminiContentPartFunctionResponse = {
|
|
103
|
+
functionResponse: {
|
|
104
|
+
name: string;
|
|
105
|
+
response: {
|
|
106
|
+
name: string;
|
|
107
|
+
content: (GeminiContentPartText | GeminiContentPartInlineData)[];
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export type GeminiContentPartInlineData = {
|
|
113
|
+
inline_data: {
|
|
114
|
+
mime_type: string;
|
|
115
|
+
data: string;
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Tool
|
|
121
|
+
* ref. https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1beta1/FunctionDeclaration
|
|
122
|
+
*/
|
|
123
|
+
export type GeminiToolDefinition = {
|
|
124
|
+
functionDeclarations: {
|
|
125
|
+
name: string;
|
|
126
|
+
description: string;
|
|
127
|
+
parametersJsonSchema: Record<string, unknown>;
|
|
128
|
+
}[];
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export type GeminiToolConfig = {
|
|
132
|
+
functionCallingConfig?: {
|
|
133
|
+
mode?: "AUTO" | "ANY" | "NONE" | "VALIDATED";
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
/* Output */
|
|
138
|
+
export type GeminiGeneratedContent = {
|
|
139
|
+
candidates?: GeminiGeneratedContentCandidate[];
|
|
140
|
+
usageMetadata: GeminiUsageMetadata;
|
|
141
|
+
modelVersion: string;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export type GeminiGeneratedContentCandidate = {
|
|
145
|
+
content: GeminiModelContent;
|
|
146
|
+
/**
|
|
147
|
+
* - STOP
|
|
148
|
+
* ...
|
|
149
|
+
*/
|
|
150
|
+
finishReason?: "MALFORMED_FUNCTION_CALL" | string;
|
|
151
|
+
finishMessage?: string;
|
|
152
|
+
safetyRatings?: GeminiSafetyRating[];
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export type GeminiSafetyRating = {
|
|
156
|
+
category: string;
|
|
157
|
+
probability: string;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export type GeminiTokensDetail = {
|
|
161
|
+
/**
|
|
162
|
+
* - TEXT
|
|
163
|
+
*/
|
|
164
|
+
modality: string;
|
|
165
|
+
tokenCount: number;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export type GeminiUsageMetadata = {
|
|
169
|
+
totalTokenCount: number;
|
|
170
|
+
promptTokenCount: number;
|
|
171
|
+
cachedContentTokenCount?: number;
|
|
172
|
+
candidatesTokenCount?: number;
|
|
173
|
+
thoughtsTokenCount?: number;
|
|
174
|
+
promptTokensDetails: GeminiTokensDetail[];
|
|
175
|
+
cachedTokenDetails?: GeminiTokensDetail[];
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/* Caching */
|
|
179
|
+
export type GeminiCreateCachedContentInput = {
|
|
180
|
+
model: string;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* e.g., 600s
|
|
184
|
+
*/
|
|
185
|
+
ttl: string;
|
|
186
|
+
|
|
187
|
+
system_instruction?: {
|
|
188
|
+
parts: GeminiContentPartText[];
|
|
189
|
+
};
|
|
190
|
+
contents: (GeminiUserContent | GeminiModelContent | GeminiFunctionContent)[];
|
|
191
|
+
tools?: GeminiToolDefinition[];
|
|
192
|
+
toolConfig?: GeminiToolConfig;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
export type GeminiCachedContents = {
|
|
196
|
+
contents: unknown[];
|
|
197
|
+
tools: unknown[];
|
|
198
|
+
createTime: string;
|
|
199
|
+
updateTime: string;
|
|
200
|
+
usageMetadata: GeminiUsageMetadata;
|
|
201
|
+
expireTime: string;
|
|
202
|
+
ttl: string;
|
|
203
|
+
name: string;
|
|
204
|
+
displayName: string;
|
|
205
|
+
model: string;
|
|
206
|
+
systemInstruction: unknown;
|
|
207
|
+
toolConfig: unknown;
|
|
208
|
+
};
|