@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,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
+ };