@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.
Files changed (79) hide show
  1. package/.config/agents.library/code-simplifier.md +5 -0
  2. package/.config/agents.library/qa-engineer.md +74 -0
  3. package/.config/agents.library/software-architect.md +278 -0
  4. package/.config/agents.predefined/worker.md +3 -0
  5. package/.config/config.predefined.json +825 -0
  6. package/.config/prompts.library/code-review.md +8 -0
  7. package/.config/prompts.library/feature-dev.md +6 -0
  8. package/.config/prompts.predefined/shortcuts/commit-by-user.md +9 -0
  9. package/.config/prompts.predefined/shortcuts/commit.md +10 -0
  10. package/.config/prompts.predefined/shortcuts/general-question.md +6 -0
  11. package/LICENSE +21 -0
  12. package/README.md +624 -0
  13. package/bin/plain +3 -0
  14. package/bin/plain-interrupt +6 -0
  15. package/bin/plain-notify-desktop +19 -0
  16. package/bin/plain-notify-terminal-bell +3 -0
  17. package/package.json +57 -0
  18. package/sandbox/bin/plain-sandbox +972 -0
  19. package/src/agent.d.ts +48 -0
  20. package/src/agent.mjs +159 -0
  21. package/src/agentLoop.mjs +369 -0
  22. package/src/agentState.mjs +41 -0
  23. package/src/cliArgs.mjs +45 -0
  24. package/src/cliFormatter.mjs +217 -0
  25. package/src/cliInteractive.mjs +739 -0
  26. package/src/config.d.ts +48 -0
  27. package/src/config.mjs +168 -0
  28. package/src/context/consumeInterruptMessage.mjs +30 -0
  29. package/src/context/loadAgentRoles.mjs +272 -0
  30. package/src/context/loadPrompts.mjs +312 -0
  31. package/src/context/loadUserMessageContext.mjs +147 -0
  32. package/src/env.mjs +46 -0
  33. package/src/main.mjs +202 -0
  34. package/src/mcp.mjs +202 -0
  35. package/src/model.d.ts +109 -0
  36. package/src/modelCaller.mjs +29 -0
  37. package/src/modelDefinition.d.ts +73 -0
  38. package/src/prompt.mjs +128 -0
  39. package/src/providers/anthropic.d.ts +248 -0
  40. package/src/providers/anthropic.mjs +596 -0
  41. package/src/providers/gemini.d.ts +208 -0
  42. package/src/providers/gemini.mjs +752 -0
  43. package/src/providers/openai.d.ts +281 -0
  44. package/src/providers/openai.mjs +551 -0
  45. package/src/providers/openaiCompatible.d.ts +147 -0
  46. package/src/providers/openaiCompatible.mjs +658 -0
  47. package/src/providers/platform/azure.mjs +42 -0
  48. package/src/providers/platform/bedrock.mjs +74 -0
  49. package/src/providers/platform/googleCloud.mjs +34 -0
  50. package/src/subagent.mjs +247 -0
  51. package/src/tmpfile.mjs +27 -0
  52. package/src/tool.d.ts +74 -0
  53. package/src/toolExecutor.mjs +236 -0
  54. package/src/toolInputValidator.mjs +183 -0
  55. package/src/toolUseApprover.mjs +98 -0
  56. package/src/tools/askGoogle.mjs +135 -0
  57. package/src/tools/delegateToSubagent.d.ts +4 -0
  58. package/src/tools/delegateToSubagent.mjs +48 -0
  59. package/src/tools/execCommand.d.ts +22 -0
  60. package/src/tools/execCommand.mjs +200 -0
  61. package/src/tools/fetchWebPage.mjs +96 -0
  62. package/src/tools/patchFile.d.ts +4 -0
  63. package/src/tools/patchFile.mjs +96 -0
  64. package/src/tools/reportAsSubagent.d.ts +3 -0
  65. package/src/tools/reportAsSubagent.mjs +44 -0
  66. package/src/tools/tavilySearch.d.ts +6 -0
  67. package/src/tools/tavilySearch.mjs +57 -0
  68. package/src/tools/tmuxCommand.d.ts +14 -0
  69. package/src/tools/tmuxCommand.mjs +194 -0
  70. package/src/tools/writeFile.d.ts +4 -0
  71. package/src/tools/writeFile.mjs +56 -0
  72. package/src/utils/evalJSONConfig.mjs +48 -0
  73. package/src/utils/matchValue.d.ts +6 -0
  74. package/src/utils/matchValue.mjs +40 -0
  75. package/src/utils/noThrow.mjs +31 -0
  76. package/src/utils/notify.mjs +28 -0
  77. package/src/utils/parseFileRange.mjs +18 -0
  78. package/src/utils/readFileRange.mjs +33 -0
  79. package/src/utils/retryOnError.mjs +41 -0
@@ -0,0 +1,281 @@
1
+ /* Model */
2
+ export type OpenAIModelConfig = {
3
+ model: string;
4
+ reasoning: {
5
+ effort: "minimal" | "low" | "medium" | "high" | "xhigh";
6
+ summary: "auto" | "concise" | "detailed";
7
+ };
8
+ store?: boolean;
9
+ include?: ["reasoning.encrypted_content"];
10
+ };
11
+
12
+ /**
13
+ * Request
14
+ * https://platform.openai.com/docs/api-reference/responses/create
15
+ */
16
+ export type OpenAIRequest = OpenAIModelConfig & {
17
+ input: OpenAIInputItem[];
18
+ tools?: OpenAIToolFunction[];
19
+ stream?: boolean;
20
+ };
21
+
22
+ /* Input */
23
+ export type OpenAIInputItem =
24
+ | OpenAIInputMessage
25
+ | OpenAIFunctionToolCallOutput
26
+ | OpenAIOutputItem;
27
+
28
+ export type OpenAIInputMessage = {
29
+ role: "user" | "system";
30
+ content: OpenAIInputContent[];
31
+ };
32
+
33
+ export type OpenAIInputContent = OpenAIInputText | OpenAIInputImage;
34
+
35
+ export type OpenAIInputText = {
36
+ type: "input_text";
37
+ text: string;
38
+ };
39
+
40
+ export type OpenAIInputImage = {
41
+ type: "input_image";
42
+ image_url: string;
43
+ detail?: "low" | "high" | "auto";
44
+ };
45
+
46
+ /* Tool */
47
+ export type OpenAIToolFunction = {
48
+ type: "function";
49
+ name: string;
50
+ description: string;
51
+ parameters: Record<string, unknown>;
52
+ };
53
+
54
+ export type OpenAIFunctionToolCallOutput = {
55
+ type: "function_call_output";
56
+ call_id: string;
57
+ output: string;
58
+ };
59
+
60
+ /* Response */
61
+ export type OpenAIResponse = {
62
+ id: string;
63
+ object: "response";
64
+ output: OpenAIOutputItem[];
65
+ usage: OpenAIUsage;
66
+ };
67
+
68
+ /* Output */
69
+ export type OpenAIOutputItem =
70
+ | OpenAIReasoning
71
+ | OpenAIOutputMessage
72
+ | OpenAIFunctionToolCall;
73
+
74
+ export type OpenAIOutputMessage = {
75
+ id: string;
76
+ type: "message";
77
+ role: "assistant";
78
+ content: OpenAIOutputContent[];
79
+ status: "in_progress" | "completed" | "incomplete";
80
+ };
81
+
82
+ export type OpenAIOutputContent = OpenAIOutputText | OpenAIOutputRefusal;
83
+
84
+ export type OpenAIOutputText = {
85
+ type: "output_text";
86
+ text: string;
87
+ annotations?: unknown;
88
+ };
89
+
90
+ export type OpenAIOutputRefusal = {
91
+ type: "refusal";
92
+ refusal: string;
93
+ };
94
+
95
+ export type OpenAIFunctionToolCall = {
96
+ id: string;
97
+ type: "function_call";
98
+ call_id: string;
99
+ name: string;
100
+ arguments: string;
101
+ status?: "in_progress" | "completed" | "incomplete";
102
+ };
103
+
104
+ export type OpenAIReasoning = {
105
+ id: string;
106
+ type: "reasoning";
107
+ summary: {
108
+ type: "summary_text";
109
+ text: string;
110
+ }[];
111
+ encrypted_content: string;
112
+ };
113
+
114
+ export type OpenAIUsage = {
115
+ input_tokens: number;
116
+ input_tokens_details: {
117
+ cached_tokens: number;
118
+ };
119
+ output_tokens: number;
120
+ output_tokens_details: {
121
+ reasoning_tokens: number;
122
+ };
123
+ total_tokens: number;
124
+ };
125
+
126
+ /* Streaming Data */
127
+ export type OpenAIStreamEvent =
128
+ | OpenAIStreamEventResponseCreated
129
+ | OpenAIStreamEventResponseInProgress
130
+ | OpenAIStreamEventResponseCompleted
131
+ | OpenAIStreamEventResponseFailed
132
+ | OpenAIStreamEventResponseOutputItemAdded
133
+ | OpenAIStreamEventResponseOutputItemDone
134
+ | OpenAIStreamEventResponseContentPartAdded
135
+ | OpenAIStreamEventResponseContentPartDone
136
+ | OpenAIStreamEventResponseFunctionCallArgumentsDelta
137
+ | OpenAIStreamEventResponseFunctionCallArgumentsDone
138
+ | OpenAIStreamEventResponseOutputTextDelta
139
+ | OpenAIStreamEventResponseOutputTextDone
140
+ | OpenAIStreamEventReasoningSummaryPartAdded
141
+ | OpenAIStreamEventReasoningSummaryPartDone
142
+ | OpenAIStreamEventReasoningSummaryTextDelta
143
+ | OpenAIStreamEventReasoningSummaryTextDone;
144
+
145
+ export type OpenAIStreamEventResponseCreated = {
146
+ type: "response.created";
147
+ sequence_number: number;
148
+ response: unknown;
149
+ };
150
+
151
+ export type OpenAIStreamEventResponseInProgress = {
152
+ type: "response.in_progress";
153
+ sequence_number: number;
154
+ response: unknown;
155
+ };
156
+
157
+ export type OpenAIStreamEventResponseCompleted = {
158
+ type: "response.completed";
159
+ sequence_number: number;
160
+ response: OpenAIResponse;
161
+ };
162
+
163
+ export type OpenAIStreamEventResponseFailed = {
164
+ type: "response.failed";
165
+ sequence_number: number;
166
+ response: {
167
+ error: unknown;
168
+ };
169
+ };
170
+
171
+ export type OpenAIStreamEventResponseOutputItemAdded = {
172
+ type: "response.output_item.added";
173
+ sequence_number: number;
174
+ output_index: number;
175
+ item: OpenAIOutputItem;
176
+ };
177
+
178
+ export type OpenAIStreamEventResponseOutputItemDone = {
179
+ type: "response.output_item.done";
180
+ sequence_number: number;
181
+ output_index: number;
182
+ item: OpenAIOutputItem;
183
+ };
184
+
185
+ export type OpenAIStreamEventResponseContentPartAdded = {
186
+ type: "response.content_part.added";
187
+ sequence_number: number;
188
+ item_id: string;
189
+ output_index: number;
190
+ content_index: number;
191
+ part: OpenAIOutputContent;
192
+ };
193
+
194
+ export type OpenAIStreamEventResponseContentPartDone = {
195
+ type: "response.content_part.done";
196
+ sequence_number: number;
197
+ item_id: string;
198
+ output_index: number;
199
+ content_index: number;
200
+ part: OpenAIOutputContent;
201
+ };
202
+
203
+ export type OpenAIStreamEventResponseFunctionCallArgumentsDelta = {
204
+ type: "response.function_call_arguments.delta";
205
+ sequence_number: number;
206
+ item_id: string;
207
+ output_index: number;
208
+ delta: string;
209
+ obfuscation: string;
210
+ };
211
+
212
+ export type OpenAIStreamEventResponseFunctionCallArgumentsDone = {
213
+ type: "response.function_call_arguments.done";
214
+ sequence_number: number;
215
+ item_id: string;
216
+ output_index: number;
217
+ arguments: string;
218
+ };
219
+
220
+ export type OpenAIStreamEventResponseOutputTextDelta = {
221
+ type: "response.output_text.delta";
222
+ sequence_number: number;
223
+ item_id: string;
224
+ output_index: number;
225
+ content_index: number;
226
+ delta: string;
227
+ logprobs: unknown[];
228
+ obfuscation: string;
229
+ };
230
+
231
+ export type OpenAIStreamEventResponseOutputTextDone = {
232
+ type: "response.output_text.done";
233
+ sequence_number: number;
234
+ item_id: string;
235
+ output_index: number;
236
+ content_index: number;
237
+ text: string;
238
+ logprobs: unknown[];
239
+ };
240
+
241
+ export type OpenAIStreamEventReasoningSummaryPartAdded = {
242
+ type: "response.reasoning_summary_part.added";
243
+ sequence_number: number;
244
+ item_id: string;
245
+ output_index: number;
246
+ summary_index: number;
247
+ part: {
248
+ type: "summary_text";
249
+ text: string;
250
+ };
251
+ };
252
+
253
+ export type OpenAIStreamEventReasoningSummaryPartDone = {
254
+ type: "response.reasoning_summary_part.done";
255
+ sequence_number: number;
256
+ item_id: string;
257
+ output_index: number;
258
+ summary_index: number;
259
+ part: {
260
+ type: "summary_text";
261
+ text: string;
262
+ };
263
+ };
264
+
265
+ export type OpenAIStreamEventReasoningSummaryTextDelta = {
266
+ type: "response.reasoning_summary_text.delta";
267
+ sequence_number: number;
268
+ item_id: string;
269
+ output_index: number;
270
+ summary_index: number;
271
+ delta: string;
272
+ };
273
+
274
+ export type OpenAIStreamEventReasoningSummaryTextDone = {
275
+ type: "response.reasoning_summary_text.done";
276
+ sequence_number: number;
277
+ item_id: string;
278
+ output_index: number;
279
+ summary_index: number;
280
+ text: string;
281
+ };