@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,248 @@
|
|
|
1
|
+
/* Model */
|
|
2
|
+
export type AnthropicModelConfig = {
|
|
3
|
+
model: string;
|
|
4
|
+
max_tokens: number;
|
|
5
|
+
|
|
6
|
+
temperature?: number;
|
|
7
|
+
|
|
8
|
+
// thinking model options
|
|
9
|
+
thinking?: {
|
|
10
|
+
type: "enabled";
|
|
11
|
+
budget_tokens: number;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/* Request */
|
|
16
|
+
export type AnthropicRequestInput = {
|
|
17
|
+
model?: string;
|
|
18
|
+
max_tokens: number;
|
|
19
|
+
temperature?: number;
|
|
20
|
+
thinking?: {
|
|
21
|
+
type: "enabled";
|
|
22
|
+
budget_tokens: number;
|
|
23
|
+
};
|
|
24
|
+
system: AnthropicMessageContentText[];
|
|
25
|
+
messages: (AnthropicUserMessage | AnthropicAssistantMessage)[];
|
|
26
|
+
tools?: AnthropicToolDefinition[];
|
|
27
|
+
stream?: boolean;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/* Output */
|
|
31
|
+
export type AnthropicChatCompletion = {
|
|
32
|
+
id: string;
|
|
33
|
+
type: "message";
|
|
34
|
+
role: "assistant";
|
|
35
|
+
model: string;
|
|
36
|
+
content: AnthropicAssistantMessageContent[];
|
|
37
|
+
stop_reason: string;
|
|
38
|
+
usage: AnthropicChatCompletionUsage;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/* Message */
|
|
42
|
+
export type AnthropicMessage =
|
|
43
|
+
| AnthropicSystemMessage
|
|
44
|
+
| AnthropicUserMessage
|
|
45
|
+
| AnthropicAssistantMessage;
|
|
46
|
+
|
|
47
|
+
export type AnthropicSystemMessage = {
|
|
48
|
+
role: "system";
|
|
49
|
+
content: AnthropicMessageContentText[];
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type AnthropicUserMessage = {
|
|
53
|
+
role: "user";
|
|
54
|
+
content: (
|
|
55
|
+
| AnthropicMessageContentText
|
|
56
|
+
| AnthropicMessageContentImage
|
|
57
|
+
| AnthropicMessageContentToolResult
|
|
58
|
+
)[];
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type AnthropicAssistantMessage = {
|
|
62
|
+
role: "assistant";
|
|
63
|
+
content: AnthropicAssistantMessageContent[];
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/* Message Content */
|
|
67
|
+
export type AnthropicAssistantMessageContent =
|
|
68
|
+
| AnthropicMessageContentThinking
|
|
69
|
+
| AnthropicMessageContentRedactedThinking
|
|
70
|
+
| AnthropicMessageContentText
|
|
71
|
+
| AnthropicMessageContentToolCall;
|
|
72
|
+
|
|
73
|
+
export type AnthropicMessageContentThinking = {
|
|
74
|
+
type: "thinking";
|
|
75
|
+
thinking: string;
|
|
76
|
+
signature: string;
|
|
77
|
+
cache_control?: { type: "ephemeral" };
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// https://platform.claude.com/docs/en/build-with-claude/extended-thinking#thinking-redaction
|
|
81
|
+
export type AnthropicMessageContentRedactedThinking = {
|
|
82
|
+
type: "redacted_thinking";
|
|
83
|
+
data: string;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export type AnthropicMessageContentText = {
|
|
87
|
+
type: "text";
|
|
88
|
+
text: string;
|
|
89
|
+
cache_control?: { type: "ephemeral" };
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export type AnthropicMessageContentImage = {
|
|
93
|
+
type: "image";
|
|
94
|
+
source: {
|
|
95
|
+
type: "base64";
|
|
96
|
+
media_type: string;
|
|
97
|
+
data: string;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export type AnthropicMessageContentToolCall = {
|
|
102
|
+
type: "tool_use";
|
|
103
|
+
id: string;
|
|
104
|
+
name: string;
|
|
105
|
+
input: Record<string, unknown>;
|
|
106
|
+
cache_control?: { type: "ephemeral" };
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export type AnthropicMessageContentToolResult = {
|
|
110
|
+
type: "tool_result";
|
|
111
|
+
tool_use_id: string;
|
|
112
|
+
content: (AnthropicMessageContentText | AnthropicMessageContentImage)[];
|
|
113
|
+
is_error?: boolean;
|
|
114
|
+
cache_control?: { type: "ephemeral" };
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/* Usage */
|
|
118
|
+
export type AnthropicChatCompletionUsage = {
|
|
119
|
+
input_tokens: number;
|
|
120
|
+
output_tokens: number;
|
|
121
|
+
cache_creation_input_tokens?: number;
|
|
122
|
+
cache_read_input_tokens?: number;
|
|
123
|
+
service_tier?: string;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
/* Tool */
|
|
127
|
+
export type AnthropicToolDefinition = {
|
|
128
|
+
name: string;
|
|
129
|
+
description: string;
|
|
130
|
+
input_schema: Record<string, unknown>;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/* Streaming Event */
|
|
134
|
+
export type AnthropicStreamEvent =
|
|
135
|
+
| AnthropicStreamEventMessageStart
|
|
136
|
+
| AnthropicStreamEventContentBlockStart
|
|
137
|
+
| AnthropicStreamEventPing
|
|
138
|
+
| AnthropicStreamEventContentBlockDelta
|
|
139
|
+
| AnthropicStreamEventContentBlockStop
|
|
140
|
+
| AnthropicStreamEventMessageDelta
|
|
141
|
+
| AnthropicStreamEventMessageStop;
|
|
142
|
+
|
|
143
|
+
export type AnthropicStreamEventMessageStart = {
|
|
144
|
+
type: "message_start";
|
|
145
|
+
message: AnthropicStreamEventMessage;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export type AnthropicStreamEventMessage = {
|
|
149
|
+
id: string;
|
|
150
|
+
type: "message";
|
|
151
|
+
role: "assistant";
|
|
152
|
+
content: unknown[];
|
|
153
|
+
model: string;
|
|
154
|
+
stop_reason: string | null;
|
|
155
|
+
stop_sequence: string | null;
|
|
156
|
+
usage: AnthropicStreamEventUsage;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export type AnthropicStreamEventUsage = {
|
|
160
|
+
input_tokens: number;
|
|
161
|
+
output_tokens: number;
|
|
162
|
+
cache_creation_input_tokens?: number;
|
|
163
|
+
cache_read_input_tokens?: number;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export type AnthropicStreamEventContentBlockStart = {
|
|
167
|
+
type: "content_block_start";
|
|
168
|
+
index: number;
|
|
169
|
+
content_block: AnthropicStreamEventContentBlock;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export type AnthropicStreamEventContentBlock =
|
|
173
|
+
| AnthropicStreamEventContentBlockText
|
|
174
|
+
| AnthropicStreamEventContentBlockToolUse
|
|
175
|
+
| AnthropicStreamEventContentBlockThinking;
|
|
176
|
+
|
|
177
|
+
export type AnthropicStreamEventContentBlockText = {
|
|
178
|
+
type: "text";
|
|
179
|
+
text: string;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
export type AnthropicStreamEventContentBlockToolUse = {
|
|
183
|
+
type: "tool_use";
|
|
184
|
+
id: string;
|
|
185
|
+
name: string;
|
|
186
|
+
input: Record<string, unknown>;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export type AnthropicStreamEventContentBlockThinking = {
|
|
190
|
+
type: "thinking";
|
|
191
|
+
thinking: string;
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
export type AnthropicStreamEventPing = {
|
|
195
|
+
type: "ping";
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
export type AnthropicStreamEventContentBlockDelta = {
|
|
199
|
+
type: "content_block_delta";
|
|
200
|
+
index: number;
|
|
201
|
+
delta: AnthropicStreamEventDelta;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
export type AnthropicStreamEventDelta =
|
|
205
|
+
| AnthropicStreamEventDeltaText
|
|
206
|
+
| AnthropicStreamEventDeltaInputJson
|
|
207
|
+
| AnthropicStreamEventDeltaThinking
|
|
208
|
+
| AnthropicStreamEventDeltaSignature;
|
|
209
|
+
|
|
210
|
+
export type AnthropicStreamEventDeltaText = {
|
|
211
|
+
type: "text_delta";
|
|
212
|
+
text: string;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export type AnthropicStreamEventDeltaInputJson = {
|
|
216
|
+
type: "input_json_delta";
|
|
217
|
+
partial_json: string;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
export type AnthropicStreamEventDeltaThinking = {
|
|
221
|
+
type: "thinking_delta";
|
|
222
|
+
thinking: string;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
export type AnthropicStreamEventDeltaSignature = {
|
|
226
|
+
type: "signature_delta";
|
|
227
|
+
signature: string;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
export type AnthropicStreamEventContentBlockStop = {
|
|
231
|
+
type: "content_block_stop";
|
|
232
|
+
index: number;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
export type AnthropicStreamEventMessageDelta = {
|
|
236
|
+
type: "message_delta";
|
|
237
|
+
delta: {
|
|
238
|
+
stop_reason: string | null;
|
|
239
|
+
stop_sequence: string | null;
|
|
240
|
+
};
|
|
241
|
+
usage?: {
|
|
242
|
+
output_tokens: number;
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
export type AnthropicStreamEventMessageStop = {
|
|
247
|
+
type: "message_stop";
|
|
248
|
+
};
|