@kalenkevich/agent_007 0.0.1

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 (247) hide show
  1. package/dist/agent/agent.d.ts +17 -0
  2. package/dist/agent/agent.js +6 -0
  3. package/dist/agent/agent.js.map +1 -0
  4. package/dist/agent/agent_event.d.ts +108 -0
  5. package/dist/agent/agent_event.js +56 -0
  6. package/dist/agent/agent_event.js.map +1 -0
  7. package/dist/agent/agent_event_utils.d.ts +5 -0
  8. package/dist/agent/agent_event_utils.js +66 -0
  9. package/dist/agent/agent_event_utils.js.map +1 -0
  10. package/dist/agent/cli_agent/cli_agent.d.ts +41 -0
  11. package/dist/agent/cli_agent/cli_agent.js +324 -0
  12. package/dist/agent/cli_agent/cli_agent.js.map +1 -0
  13. package/dist/agent/cli_agent/system_prompt.d.ts +1 -0
  14. package/dist/agent/cli_agent/system_prompt.js +58 -0
  15. package/dist/agent/cli_agent/system_prompt.js.map +1 -0
  16. package/dist/agent/cli_agent.d.ts +34 -0
  17. package/dist/agent/cli_agent.js +91 -0
  18. package/dist/agent/cli_agent.js.map +1 -0
  19. package/dist/agent/planner_agent/planner_agent.d.ts +28 -0
  20. package/dist/agent/planner_agent/planner_agent.js +102 -0
  21. package/dist/agent/planner_agent/planner_agent.js.map +1 -0
  22. package/dist/agent/request_processor/basic_request_processor.d.ts +17 -0
  23. package/dist/agent/request_processor/basic_request_processor.js +28 -0
  24. package/dist/agent/request_processor/basic_request_processor.js.map +1 -0
  25. package/dist/agent/request_processor/compaction_processor.d.ts +17 -0
  26. package/dist/agent/request_processor/compaction_processor.js +118 -0
  27. package/dist/agent/request_processor/compaction_processor.js.map +1 -0
  28. package/dist/agent/request_processor/request_processor.d.ts +11 -0
  29. package/dist/agent/request_processor/request_processor.js +2 -0
  30. package/dist/agent/request_processor/request_processor.js.map +1 -0
  31. package/dist/cli/init_project_command_handler.d.ts +3 -0
  32. package/dist/cli/init_project_command_handler.js +58 -0
  33. package/dist/cli/init_project_command_handler.js.map +1 -0
  34. package/dist/cli/loader.d.ts +6 -0
  35. package/dist/cli/loader.js +27 -0
  36. package/dist/cli/loader.js.map +1 -0
  37. package/dist/cli/prompt_utils.d.ts +11 -0
  38. package/dist/cli/prompt_utils.js +18 -0
  39. package/dist/cli/prompt_utils.js.map +1 -0
  40. package/dist/cli/run_command.d.ts +6 -0
  41. package/dist/cli/run_command.js +72 -0
  42. package/dist/cli/run_command.js.map +1 -0
  43. package/dist/cli/run_interactive_command.d.ts +6 -0
  44. package/dist/cli/run_interactive_command.js +282 -0
  45. package/dist/cli/run_interactive_command.js.map +1 -0
  46. package/dist/cli/run_noninteractive_command.d.ts +6 -0
  47. package/dist/cli/run_noninteractive_command.js +60 -0
  48. package/dist/cli/run_noninteractive_command.js.map +1 -0
  49. package/dist/cli_entrypoint.d.ts +2 -0
  50. package/dist/cli_entrypoint.js +110 -0
  51. package/dist/cli_entrypoint.js.map +1 -0
  52. package/dist/command/commnad_handler.d.ts +3 -0
  53. package/dist/command/commnad_handler.js +2 -0
  54. package/dist/command/commnad_handler.js.map +1 -0
  55. package/dist/command/init_project_command_handler.d.ts +4 -0
  56. package/dist/command/init_project_command_handler.js +58 -0
  57. package/dist/command/init_project_command_handler.js.map +1 -0
  58. package/dist/config/app_dir.d.ts +1 -0
  59. package/dist/config/app_dir.js +4 -0
  60. package/dist/config/app_dir.js.map +1 -0
  61. package/dist/config/config.d.ts +21 -0
  62. package/dist/config/config.js +2 -0
  63. package/dist/config/config.js.map +1 -0
  64. package/dist/config/config_loader.d.ts +2 -0
  65. package/dist/config/config_loader.js +47 -0
  66. package/dist/config/config_loader.js.map +1 -0
  67. package/dist/config/config_store.d.ts +10 -0
  68. package/dist/config/config_store.js +44 -0
  69. package/dist/config/config_store.js.map +1 -0
  70. package/dist/content.d.ts +51 -0
  71. package/dist/content.js +16 -0
  72. package/dist/content.js.map +1 -0
  73. package/dist/core/functions.d.ts +1 -0
  74. package/dist/core/functions.js +6 -0
  75. package/dist/core/functions.js.map +1 -0
  76. package/dist/core/loop.d.ts +20 -0
  77. package/dist/core/loop.js +121 -0
  78. package/dist/core/loop.js.map +1 -0
  79. package/dist/core/project_service.d.ts +11 -0
  80. package/dist/core/project_service.js +26 -0
  81. package/dist/core/project_service.js.map +1 -0
  82. package/dist/core/run.d.ts +6 -0
  83. package/dist/core/run.js +25 -0
  84. package/dist/core/run.js.map +1 -0
  85. package/dist/index.d.ts +1 -0
  86. package/dist/index.js +2 -0
  87. package/dist/index.js.map +1 -0
  88. package/dist/logger.d.ts +27 -0
  89. package/dist/logger.js +98 -0
  90. package/dist/logger.js.map +1 -0
  91. package/dist/model/adaptive_model.d.ts +16 -0
  92. package/dist/model/adaptive_model.js +57 -0
  93. package/dist/model/adaptive_model.js.map +1 -0
  94. package/dist/model/google/gemini_model.d.ts +15 -0
  95. package/dist/model/google/gemini_model.js +131 -0
  96. package/dist/model/google/gemini_model.js.map +1 -0
  97. package/dist/model/google/gemini_response_utils.d.ts +3 -0
  98. package/dist/model/google/gemini_response_utils.js +36 -0
  99. package/dist/model/google/gemini_response_utils.js.map +1 -0
  100. package/dist/model/google/gemini_streaming_utils.d.ts +28 -0
  101. package/dist/model/google/gemini_streaming_utils.js +235 -0
  102. package/dist/model/google/gemini_streaming_utils.js.map +1 -0
  103. package/dist/model/google/gen_ai_convert_utils.d.ts +6 -0
  104. package/dist/model/google/gen_ai_convert_utils.js +117 -0
  105. package/dist/model/google/gen_ai_convert_utils.js.map +1 -0
  106. package/dist/model/model.d.ts +11 -0
  107. package/dist/model/model.js +2 -0
  108. package/dist/model/model.js.map +1 -0
  109. package/dist/model/registry.d.ts +19 -0
  110. package/dist/model/registry.js +47 -0
  111. package/dist/model/registry.js.map +1 -0
  112. package/dist/model/request.d.ts +13 -0
  113. package/dist/model/request.js +2 -0
  114. package/dist/model/request.js.map +1 -0
  115. package/dist/model/request_builder_utils.d.ts +19 -0
  116. package/dist/model/request_builder_utils.js +43 -0
  117. package/dist/model/request_builder_utils.js.map +1 -0
  118. package/dist/model/response.d.ts +60 -0
  119. package/dist/model/response.js +2 -0
  120. package/dist/model/response.js.map +1 -0
  121. package/dist/model/util_llm.d.ts +10 -0
  122. package/dist/model/util_llm.js +149 -0
  123. package/dist/model/util_llm.js.map +1 -0
  124. package/dist/session/session.d.ts +14 -0
  125. package/dist/session/session.js +2 -0
  126. package/dist/session/session.js.map +1 -0
  127. package/dist/session/session_file_service.d.ts +23 -0
  128. package/dist/session/session_file_service.js +147 -0
  129. package/dist/session/session_file_service.js.map +1 -0
  130. package/dist/skills/skill.d.ts +23 -0
  131. package/dist/skills/skill.js +12 -0
  132. package/dist/skills/skill.js.map +1 -0
  133. package/dist/tools/build_in/find.d.ts +3 -0
  134. package/dist/tools/build_in/find.js +71 -0
  135. package/dist/tools/build_in/find.js.map +1 -0
  136. package/dist/tools/build_in/grep.d.ts +3 -0
  137. package/dist/tools/build_in/grep.js +97 -0
  138. package/dist/tools/build_in/grep.js.map +1 -0
  139. package/dist/tools/build_in/index.d.ts +1 -0
  140. package/dist/tools/build_in/index.js +13 -0
  141. package/dist/tools/build_in/index.js.map +1 -0
  142. package/dist/tools/build_in/list_dir.d.ts +3 -0
  143. package/dist/tools/build_in/list_dir.js +46 -0
  144. package/dist/tools/build_in/list_dir.js.map +1 -0
  145. package/dist/tools/build_in/view_file.d.ts +3 -0
  146. package/dist/tools/build_in/view_file.js +44 -0
  147. package/dist/tools/build_in/view_file.js.map +1 -0
  148. package/dist/tools/build_in/write_file.d.ts +3 -0
  149. package/dist/tools/build_in/write_file.js +50 -0
  150. package/dist/tools/build_in/write_file.js.map +1 -0
  151. package/dist/tools/functional_tool.d.ts +18 -0
  152. package/dist/tools/functional_tool.js +20 -0
  153. package/dist/tools/functional_tool.js.map +1 -0
  154. package/dist/tools/schema.d.ts +86 -0
  155. package/dist/tools/schema.js +37 -0
  156. package/dist/tools/schema.js.map +1 -0
  157. package/dist/tools/tool.d.ts +30 -0
  158. package/dist/tools/tool.js +9 -0
  159. package/dist/tools/tool.js.map +1 -0
  160. package/dist/tools/tool_call_policy.d.ts +4 -0
  161. package/dist/tools/tool_call_policy.js +4 -0
  162. package/dist/tools/tool_call_policy.js.map +1 -0
  163. package/dist/tools/tool_policy.d.ts +4 -0
  164. package/dist/tools/tool_policy.js +4 -0
  165. package/dist/tools/tool_policy.js.map +1 -0
  166. package/dist/ui/ui.d.ts +1 -0
  167. package/dist/ui/ui.js +2 -0
  168. package/dist/ui/ui.js.map +1 -0
  169. package/dist/user_input.d.ts +20 -0
  170. package/dist/user_input.js +21 -0
  171. package/dist/user_input.js.map +1 -0
  172. package/package.json +44 -0
  173. package/src/agent/agent.ts +18 -0
  174. package/src/agent/agent_event.ts +171 -0
  175. package/src/agent/agent_event_utils.ts +87 -0
  176. package/src/agent/cli_agent/cli_agent.ts +418 -0
  177. package/src/agent/cli_agent/system_prompt.ts +57 -0
  178. package/src/agent/planner_agent/planner_agent.ts +136 -0
  179. package/src/agent/request_processor/basic_request_processor.ts +46 -0
  180. package/src/agent/request_processor/compaction_processor.ts +164 -0
  181. package/src/agent/request_processor/request_processor.ts +13 -0
  182. package/src/cli/loader.ts +27 -0
  183. package/src/cli/prompt_utils.ts +19 -0
  184. package/src/cli/run_interactive_command.ts +337 -0
  185. package/src/cli/run_noninteractive_command.ts +74 -0
  186. package/src/cli_entrypoint.ts +128 -0
  187. package/src/command/commnad_handler.ts +3 -0
  188. package/src/command/init_project_command_handler.ts +66 -0
  189. package/src/config/app_dir.ts +4 -0
  190. package/src/config/config.ts +24 -0
  191. package/src/config/config_loader.ts +57 -0
  192. package/src/config/config_store.ts +50 -0
  193. package/src/content.ts +87 -0
  194. package/src/core/functions.ts +7 -0
  195. package/src/core/loop.ts +165 -0
  196. package/src/core/project_service.ts +38 -0
  197. package/src/core/run.ts +36 -0
  198. package/src/index.ts +1 -0
  199. package/src/logger.ts +128 -0
  200. package/src/model/adaptive_model.ts +77 -0
  201. package/src/model/google/gemini_model.ts +194 -0
  202. package/src/model/google/gemini_response_utils.ts +46 -0
  203. package/src/model/google/gemini_streaming_utils.ts +294 -0
  204. package/src/model/google/gen_ai_convert_utils.ts +149 -0
  205. package/src/model/model.ts +18 -0
  206. package/src/model/registry.ts +61 -0
  207. package/src/model/request.ts +15 -0
  208. package/src/model/request_builder_utils.ts +79 -0
  209. package/src/model/response.ts +66 -0
  210. package/src/model/util_llm.ts +167 -0
  211. package/src/session/session.ts +16 -0
  212. package/src/session/session_file_service.ts +207 -0
  213. package/src/skills/skill.ts +38 -0
  214. package/src/tools/build_in/find.ts +80 -0
  215. package/src/tools/build_in/grep.ts +101 -0
  216. package/src/tools/build_in/index.ts +13 -0
  217. package/src/tools/build_in/list_dir.ts +50 -0
  218. package/src/tools/build_in/view_file.ts +47 -0
  219. package/src/tools/build_in/write_file.ts +53 -0
  220. package/src/tools/functional_tool.ts +59 -0
  221. package/src/tools/schema.ts +87 -0
  222. package/src/tools/tool.ts +68 -0
  223. package/src/tools/tool_call_policy.ts +7 -0
  224. package/src/ui/ui.ts +0 -0
  225. package/src/user_input.ts +51 -0
  226. package/tests/integration/util_llm_test.ts +42 -0
  227. package/tests/unit/adaptive_model_test.ts +122 -0
  228. package/tests/unit/agent/request_processor/compaction_processor_test.ts +121 -0
  229. package/tests/unit/cli/prompt_utils_test.ts +47 -0
  230. package/tests/unit/cli_agent_test.ts +476 -0
  231. package/tests/unit/content_test.ts +56 -0
  232. package/tests/unit/logger_test.ts +109 -0
  233. package/tests/unit/loop_test.ts +141 -0
  234. package/tests/unit/model/gemini_model_test.ts +111 -0
  235. package/tests/unit/planner_agent_test.ts +52 -0
  236. package/tests/unit/project_service_test.ts +102 -0
  237. package/tests/unit/session_file_service_test.ts +160 -0
  238. package/tests/unit/tools/find_test.ts +40 -0
  239. package/tests/unit/tools/grep_test.ts +43 -0
  240. package/tests/unit/tools/list_dir_test.ts +32 -0
  241. package/tests/unit/tools/view_file_test.ts +32 -0
  242. package/tests/unit/tools/write_file_test.ts +44 -0
  243. package/tests/unit/user_input_test.ts +55 -0
  244. package/tests/unit/util_llm_test.ts +61 -0
  245. package/todo.md +29 -0
  246. package/tsconfig.json +33 -0
  247. package/vitest.config.ts +33 -0
@@ -0,0 +1,86 @@
1
+ /** Data type of the schema field. */
2
+ export declare enum Type {
3
+ /**
4
+ * Not specified, should not be used.
5
+ */
6
+ TYPE_UNSPECIFIED = "TYPE_UNSPECIFIED",
7
+ /**
8
+ * OpenAPI string type
9
+ */
10
+ STRING = "STRING",
11
+ /**
12
+ * OpenAPI number type
13
+ */
14
+ NUMBER = "NUMBER",
15
+ /**
16
+ * OpenAPI integer type
17
+ */
18
+ INTEGER = "INTEGER",
19
+ /**
20
+ * OpenAPI boolean type
21
+ */
22
+ BOOLEAN = "BOOLEAN",
23
+ /**
24
+ * OpenAPI array type
25
+ */
26
+ ARRAY = "ARRAY",
27
+ /**
28
+ * OpenAPI object type
29
+ */
30
+ OBJECT = "OBJECT",
31
+ /**
32
+ * Null type
33
+ */
34
+ NULL = "NULL"
35
+ }
36
+ /** Schema is used to define the format of input/output data.
37
+
38
+ Represents a select subset of an [OpenAPI 3.0 schema
39
+ object](https://spec.openapis.org/oas/v3.0.3#schema-object). More fields may
40
+ be added in the future as needed. */
41
+ export interface Schema {
42
+ /** Optional. The instance must be valid against any (one or more) of the subschemas listed in `any_of`. */
43
+ anyOf?: Schema[];
44
+ /** Optional. Default value to use if the field is not specified. */
45
+ default?: unknown;
46
+ /** Optional. Describes the data. The model uses this field to understand the purpose of the schema and how to use it. It is a best practice to provide a clear and descriptive explanation for the schema and its properties here, rather than in the prompt. */
47
+ description?: string;
48
+ /** Optional. Possible values of the field. This field can be used to restrict a value to a fixed set of values. To mark a field as an enum, set `format` to `enum` and provide the list of possible values in `enum`. For example: 1. To define directions: `{type:STRING, format:enum, enum:["EAST", "NORTH", "SOUTH", "WEST"]}` 2. To define apartment numbers: `{type:INTEGER, format:enum, enum:["101", "201", "301"]}` */
49
+ enum?: string[];
50
+ /** Optional. Example of an instance of this schema. */
51
+ example?: unknown;
52
+ /** Optional. The format of the data. For `NUMBER` type, format can be `float` or `double`. For `INTEGER` type, format can be `int32` or `int64`. For `STRING` type, format can be `email`, `byte`, `date`, `date-time`, `password`, and other formats to further refine the data type. */
53
+ format?: string;
54
+ /** Optional. If type is `ARRAY`, `items` specifies the schema of elements in the array. */
55
+ items?: Schema;
56
+ /** Optional. If type is `ARRAY`, `max_items` specifies the maximum number of items in an array. */
57
+ maxItems?: string;
58
+ /** Optional. If type is `STRING`, `max_length` specifies the maximum length of the string. */
59
+ maxLength?: string;
60
+ /** Optional. If type is `OBJECT`, `max_properties` specifies the maximum number of properties that can be provided. */
61
+ maxProperties?: string;
62
+ /** Optional. If type is `INTEGER` or `NUMBER`, `maximum` specifies the maximum allowed value. */
63
+ maximum?: number;
64
+ /** Optional. If type is `ARRAY`, `min_items` specifies the minimum number of items in an array. */
65
+ minItems?: string;
66
+ /** Optional. If type is `STRING`, `min_length` specifies the minimum length of the string. */
67
+ minLength?: string;
68
+ /** Optional. If type is `OBJECT`, `min_properties` specifies the minimum number of properties that can be provided. */
69
+ minProperties?: string;
70
+ /** Optional. If type is `INTEGER` or `NUMBER`, `minimum` specifies the minimum allowed value. */
71
+ minimum?: number;
72
+ /** Optional. Indicates if the value of this field can be null. */
73
+ nullable?: boolean;
74
+ /** Optional. If type is `STRING`, `pattern` specifies a regular expression that the string must match. */
75
+ pattern?: string;
76
+ /** Optional. If type is `OBJECT`, `properties` is a map of property names to schema definitions for each property of the object. */
77
+ properties?: Record<string, Schema>;
78
+ /** Optional. Order of properties displayed or used where order matters. This is not a standard field in OpenAPI specification, but can be used to control the order of properties. */
79
+ propertyOrdering?: string[];
80
+ /** Optional. If type is `OBJECT`, `required` lists the names of properties that must be present. */
81
+ required?: string[];
82
+ /** Optional. Title for the schema. */
83
+ title?: string;
84
+ /** Optional. Data type of the schema field. */
85
+ type?: Type;
86
+ }
@@ -0,0 +1,37 @@
1
+ /** Data type of the schema field. */
2
+ export var Type;
3
+ (function (Type) {
4
+ /**
5
+ * Not specified, should not be used.
6
+ */
7
+ Type["TYPE_UNSPECIFIED"] = "TYPE_UNSPECIFIED";
8
+ /**
9
+ * OpenAPI string type
10
+ */
11
+ Type["STRING"] = "STRING";
12
+ /**
13
+ * OpenAPI number type
14
+ */
15
+ Type["NUMBER"] = "NUMBER";
16
+ /**
17
+ * OpenAPI integer type
18
+ */
19
+ Type["INTEGER"] = "INTEGER";
20
+ /**
21
+ * OpenAPI boolean type
22
+ */
23
+ Type["BOOLEAN"] = "BOOLEAN";
24
+ /**
25
+ * OpenAPI array type
26
+ */
27
+ Type["ARRAY"] = "ARRAY";
28
+ /**
29
+ * OpenAPI object type
30
+ */
31
+ Type["OBJECT"] = "OBJECT";
32
+ /**
33
+ * Null type
34
+ */
35
+ Type["NULL"] = "NULL";
36
+ })(Type || (Type = {}));
37
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/tools/schema.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,MAAM,CAAN,IAAY,IAiCX;AAjCD,WAAY,IAAI;IACd;;OAEG;IACH,6CAAqC,CAAA;IACrC;;OAEG;IACH,yBAAiB,CAAA;IACjB;;OAEG;IACH,yBAAiB,CAAA;IACjB;;OAEG;IACH,2BAAmB,CAAA;IACnB;;OAEG;IACH,2BAAmB,CAAA;IACnB;;OAEG;IACH,uBAAe,CAAA;IACf;;OAEG;IACH,yBAAiB,CAAA;IACjB;;OAEG;IACH,qBAAa,CAAA;AACf,CAAC,EAjCW,IAAI,KAAJ,IAAI,QAiCf"}
@@ -0,0 +1,30 @@
1
+ import { z as z3 } from "zod/v3";
2
+ import { z as z4 } from "zod/v4";
3
+ import type { Schema } from "./schema.js";
4
+ export declare enum Behavior {
5
+ UNSPECIFIED = "UNSPECIFIED",
6
+ BLOCKING = "BLOCKING",
7
+ NON_BLOCKING = "NON_BLOCKING"
8
+ }
9
+ export interface FunctionDeclaration {
10
+ description?: string;
11
+ name?: string;
12
+ parameters?: Schema;
13
+ parametersJsonSchema?: unknown;
14
+ response?: Schema;
15
+ responseJsonSchema?: unknown;
16
+ behavior?: Behavior;
17
+ }
18
+ export type ToolInputSchema = z3.ZodObject<z3.ZodRawShape> | z4.ZodObject<z4.ZodRawShape> | Schema | undefined;
19
+ export type ToolOutputSchema = z3.ZodObject<z3.ZodRawShape> | z4.ZodObject<z4.ZodRawShape> | Schema | undefined;
20
+ export type ToolInput<TParameters extends ToolInputSchema> = TParameters extends z3.ZodObject<infer T, infer U, infer V> ? z3.infer<z3.ZodObject<T, U, V>> : TParameters extends z4.ZodObject<infer T> ? z4.infer<z4.ZodObject<T>> : TParameters extends Schema ? unknown : string;
21
+ export type ToolOutput<TOutputParameters extends ToolOutputSchema> = TOutputParameters extends z3.ZodObject<infer T, infer U, infer V> ? z3.infer<z3.ZodObject<T, U, V>> : TOutputParameters extends z4.ZodObject<infer T> ? z4.infer<z4.ZodObject<T>> : TOutputParameters extends Schema ? unknown : string;
22
+ export type ToolExecuteFunction<TInputParameters extends ToolInputSchema = ToolInputSchema, TOutputParameters extends ToolOutputSchema = ToolOutputSchema> = (input: ToolInput<TInputParameters>) => Promise<ToolOutput<TOutputParameters>> | ToolOutput<TOutputParameters>;
23
+ export interface Tool<TInputParameters extends ToolInputSchema = ToolInputSchema, TOutputParameters extends ToolOutputSchema = ToolOutputSchema> {
24
+ name: string;
25
+ description: string;
26
+ params: ToolInputSchema;
27
+ output: ToolOutputSchema;
28
+ execute: ToolExecuteFunction<TInputParameters, TOutputParameters>;
29
+ toFunctionDeclaration(): FunctionDeclaration;
30
+ }
@@ -0,0 +1,9 @@
1
+ import { z as z3 } from "zod/v3";
2
+ import { z as z4 } from "zod/v4";
3
+ export var Behavior;
4
+ (function (Behavior) {
5
+ Behavior["UNSPECIFIED"] = "UNSPECIFIED";
6
+ Behavior["BLOCKING"] = "BLOCKING";
7
+ Behavior["NON_BLOCKING"] = "NON_BLOCKING";
8
+ })(Behavior || (Behavior = {}));
9
+ //# sourceMappingURL=tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.js","sourceRoot":"","sources":["../../src/tools/tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,QAAQ,CAAC;AAGjC,MAAM,CAAN,IAAY,QAIX;AAJD,WAAY,QAAQ;IAClB,uCAA2B,CAAA;IAC3B,iCAAqB,CAAA;IACrB,yCAA6B,CAAA;AAC/B,CAAC,EAJW,QAAQ,KAAR,QAAQ,QAInB"}
@@ -0,0 +1,4 @@
1
+ export interface ToolCallPolicy {
2
+ confirmationRequired: boolean;
3
+ }
4
+ export declare const DEFAULT_POLICY: ToolCallPolicy;
@@ -0,0 +1,4 @@
1
+ export const DEFAULT_POLICY = {
2
+ confirmationRequired: true,
3
+ };
4
+ //# sourceMappingURL=tool_call_policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool_call_policy.js","sourceRoot":"","sources":["../../src/tools/tool_call_policy.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,cAAc,GAAmB;IAC5C,oBAAoB,EAAE,IAAI;CAC3B,CAAC"}
@@ -0,0 +1,4 @@
1
+ export interface RunToolPolicy {
2
+ confirmationRequired: boolean;
3
+ }
4
+ export declare const DEFAULT_POLICY: RunToolPolicy;
@@ -0,0 +1,4 @@
1
+ export const DEFAULT_POLICY = {
2
+ confirmationRequired: true,
3
+ };
4
+ //# sourceMappingURL=tool_policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool_policy.js","sourceRoot":"","sources":["../../src/tools/tool_policy.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,cAAc,GAAkB;IAC3C,oBAAoB,EAAE,IAAI;CAC3B,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
package/dist/ui/ui.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ui.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/ui/ui.ts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ import type { ModelConfig } from "./config/config.js";
2
+ import type { Content, ContentPart } from "./content.js";
3
+ import type { UserInputResponseEvent } from "./agent/agent_event.js";
4
+ export type UserCommand = SetModelCommand | PlanCommand;
5
+ export declare enum UserCommandType {
6
+ SET_MODEL = "set_model",
7
+ PLAN = "plan"
8
+ }
9
+ export interface SetModelCommand {
10
+ command: UserCommandType.SET_MODEL;
11
+ modelName: string;
12
+ config?: ModelConfig;
13
+ }
14
+ export interface PlanCommand {
15
+ command: UserCommandType.PLAN;
16
+ task: string;
17
+ }
18
+ export type UserInput = string | Content | ContentPart | ContentPart[] | UserCommand | UserInputResponseEvent;
19
+ export declare function isUserCommand(userInput: UserInput): userInput is UserCommand;
20
+ export declare function toContentParts(userInput: string | Content | ContentPart | ContentPart[]): ContentPart[];
@@ -0,0 +1,21 @@
1
+ export var UserCommandType;
2
+ (function (UserCommandType) {
3
+ UserCommandType["SET_MODEL"] = "set_model";
4
+ UserCommandType["PLAN"] = "plan";
5
+ })(UserCommandType || (UserCommandType = {}));
6
+ export function isUserCommand(userInput) {
7
+ return userInput.command !== undefined;
8
+ }
9
+ export function toContentParts(userInput) {
10
+ if (typeof userInput === "string") {
11
+ return [{ type: "text", text: userInput }];
12
+ }
13
+ if (Array.isArray(userInput)) {
14
+ return userInput;
15
+ }
16
+ if ("parts" in userInput) {
17
+ return userInput.parts;
18
+ }
19
+ return [userInput];
20
+ }
21
+ //# sourceMappingURL=user_input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user_input.js","sourceRoot":"","sources":["../src/user_input.ts"],"names":[],"mappings":"AAMA,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,0CAAuB,CAAA;IACvB,gCAAa,CAAA;AACf,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AAqBD,MAAM,UAAU,aAAa,CAAC,SAAoB;IAChD,OAAQ,SAAyB,CAAC,OAAO,KAAK,SAAS,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,SAAyD;IAEzD,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QAClC,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QAC7B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,OAAO,IAAI,SAAS,EAAE,CAAC;QACzB,OAAO,SAAS,CAAC,KAAK,CAAC;IACzB,CAAC;IAED,OAAO,CAAC,SAAS,CAAC,CAAC;AACrB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@kalenkevich/agent_007",
3
+ "version": "0.0.1",
4
+ "author": "Alexey Kalenkevich",
5
+ "description": "Yet another AI agent coding harness.",
6
+ "type": "module",
7
+ "module": "./dist/index.js",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/kalenkevich/agent_007"
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js",
16
+ "default": "./dist/index.js"
17
+ }
18
+ },
19
+ "bin": {
20
+ "agent007": "./dist/cli_entrypoint.js",
21
+ "agent_007": "./dist/cli_entrypoint.js"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "scripts": {
27
+ "build": "tsc",
28
+ "start": "node ./dist/cli_entrypoint.js --debug",
29
+ "test": "vitest --project unit --project integration --project e2e",
30
+ "test:unit": "vitest --project unit",
31
+ "test:integration": "vitest --project integration",
32
+ "test:e2e": "vitest --project e2e"
33
+ },
34
+ "keywords": [],
35
+ "license": "ISC",
36
+ "dependencies": {
37
+ "@google/genai": "^1.49.0",
38
+ "zod": "^4.3.6"
39
+ },
40
+ "devDependencies": {
41
+ "typescript": "^6.0.2",
42
+ "vitest": "^4.1.4"
43
+ }
44
+ }
@@ -0,0 +1,18 @@
1
+ import { type UserInput } from "../user_input.js";
2
+ import { type LlmModel } from "../model/model.js";
3
+ import { type Tool } from "../tools/tool.js";
4
+ import { type Skill } from "../skills/skill.js";
5
+ import { type AgentEvent } from "./agent_event.js";
6
+
7
+ export interface Agent {
8
+ id: string;
9
+ name: string;
10
+ description: string;
11
+ instructions: string;
12
+ model: LlmModel;
13
+ tools?: Tool[];
14
+ skills?: Skill[];
15
+ run(input: UserInput): AsyncGenerator<AgentEvent, void, unknown>;
16
+ abort(): Promise<void>;
17
+ getHistory(): AgentEvent[];
18
+ }
@@ -0,0 +1,171 @@
1
+ import type { ContentPart } from "../content.js";
2
+
3
+ export enum AgentEventType {
4
+ START = "START",
5
+ END = "END",
6
+ MESSAGE = "MESSAGE",
7
+ TOOL_CALL = "TOOL_CALL",
8
+ TOOL_RESPONSE = "TOOL_RESPONSE",
9
+ USER_INPUT_REQUEST = "USER_INPUT_REQUEST",
10
+ USER_INPUT_RESPONSE = "USER_INPUT_RESPONSE",
11
+ ERROR = "ERROR",
12
+ USAGE = "USAGE",
13
+ COMPACTION = "COMPACTION",
14
+ }
15
+
16
+ export enum AgentEndReason {
17
+ COMPLETED = "completed",
18
+ FAILED = "failed",
19
+ ABORTED = "aborted",
20
+ MAX_TURNS = "max_turns",
21
+ MAX_BUDGET = "max_budget",
22
+ MAX_TIME = "max_time",
23
+ REFUSAL = "refusal",
24
+ USER_RESPONSE_PENDING = "user_response_pending",
25
+ }
26
+
27
+ export type AgentEvent =
28
+ | AgentStartEvent
29
+ | AgentEndEvent
30
+ | MessageEvent
31
+ | ToolCallEvent
32
+ | ToolResponseEvent
33
+ | UserInputRequestEvent
34
+ | UserInputResponseEvent
35
+ | ErrorEvent
36
+ | UsageEvent
37
+ | CompactionEvent;
38
+
39
+ export interface BaseAgentEvent {
40
+ // Event unique id
41
+ id: string;
42
+ // Agent stream / execution id
43
+ streamId: string;
44
+ timestamp: string;
45
+ role: "user" | "agent";
46
+ parts?: ContentPart[];
47
+ partial?: boolean;
48
+ }
49
+
50
+ export interface AgentStartEvent extends BaseAgentEvent {
51
+ type: AgentEventType.START;
52
+ }
53
+
54
+ export function isAgentStartEvent(event: AgentEvent): event is AgentStartEvent {
55
+ return event.type === AgentEventType.START;
56
+ }
57
+
58
+ export interface AgentEndEvent extends BaseAgentEvent {
59
+ type: AgentEventType.END;
60
+ reason: AgentEndReason;
61
+ userRequestIds?: string[];
62
+ data?: Record<string, unknown>;
63
+ }
64
+
65
+ export function isAgentEndEvent(event: AgentEvent): event is AgentEndEvent {
66
+ return event.type === AgentEventType.END;
67
+ }
68
+
69
+ export interface MessageEvent extends BaseAgentEvent {
70
+ type: AgentEventType.MESSAGE;
71
+ parts: ContentPart[];
72
+ }
73
+
74
+ export function isMessageEvent(event: AgentEvent): event is MessageEvent {
75
+ return event.type === AgentEventType.MESSAGE;
76
+ }
77
+
78
+ export interface ToolCallEvent extends BaseAgentEvent {
79
+ type: AgentEventType.TOOL_CALL;
80
+ requestId: string;
81
+ name: string;
82
+ args: Record<string, unknown>;
83
+ }
84
+
85
+ export function isToolCallEvent(event: AgentEvent): event is ToolCallEvent {
86
+ return event.type === AgentEventType.TOOL_CALL;
87
+ }
88
+
89
+ export interface ToolResponseEvent extends BaseAgentEvent {
90
+ type: AgentEventType.TOOL_RESPONSE;
91
+ requestId: string;
92
+ name: string;
93
+ /** Multi-part content to be sent to the model. */
94
+ parts?: ContentPart[];
95
+ /** Structured data to be sent to the model. */
96
+ result: Record<string, unknown> | string;
97
+ /** The tool call encountered an error that will be sent to the model. */
98
+ error?: string;
99
+ }
100
+
101
+ export function isToolResponseEvent(
102
+ event: AgentEvent,
103
+ ): event is ToolResponseEvent {
104
+ return event.type === AgentEventType.TOOL_RESPONSE;
105
+ }
106
+
107
+ export interface UserInputRequestEvent extends BaseAgentEvent {
108
+ type: AgentEventType.USER_INPUT_REQUEST;
109
+ title?: string;
110
+ /** A unique ID for the elicitation request, correlated in response. */
111
+ requestId: string;
112
+ /** The question / content to display to the user. */
113
+ message: string;
114
+ requestSchema?: Record<string, unknown>;
115
+ }
116
+
117
+ export function isUserInputRequestEvent(
118
+ event: AgentEvent,
119
+ ): event is UserInputRequestEvent {
120
+ return event.type === AgentEventType.USER_INPUT_REQUEST;
121
+ }
122
+
123
+ export interface UserInputResponseEvent extends BaseAgentEvent {
124
+ type: AgentEventType.USER_INPUT_RESPONSE;
125
+ requestId: string;
126
+ data?: Record<string, unknown>;
127
+ // 'cancel' here means ignore - the run will continue as if this response has not been provided
128
+ action?: "accept" | "decline" | "cancel";
129
+ }
130
+
131
+ export function isUserInputResponseEvent(
132
+ event: unknown,
133
+ ): event is UserInputResponseEvent {
134
+ return (
135
+ (event as UserInputResponseEvent).type ===
136
+ AgentEventType.USER_INPUT_RESPONSE
137
+ );
138
+ }
139
+
140
+ export interface ErrorEvent extends BaseAgentEvent {
141
+ type: AgentEventType.ERROR;
142
+ statusCode: number;
143
+ errorMessage?: string;
144
+ fatal?: boolean;
145
+ }
146
+
147
+ export function isErrorEvent(event: AgentEvent): event is ErrorEvent {
148
+ return event.type === AgentEventType.ERROR;
149
+ }
150
+
151
+ export interface UsageEvent extends BaseAgentEvent {
152
+ type: AgentEventType.USAGE;
153
+ model: string;
154
+ inputTokens?: number;
155
+ outputTokens?: number;
156
+ cachedTokens?: number;
157
+ cost?: { amount: number; currency?: string };
158
+ }
159
+
160
+ export function isUsageEvent(event: AgentEvent): event is UsageEvent {
161
+ return event.type === AgentEventType.USAGE;
162
+ }
163
+
164
+ export interface CompactionEvent extends BaseAgentEvent {
165
+ type: AgentEventType.COMPACTION;
166
+ strategy: "truncate" | "summarize";
167
+ }
168
+
169
+ export function isCompactionEvent(event: AgentEvent): event is CompactionEvent {
170
+ return event.type === AgentEventType.COMPACTION;
171
+ }
@@ -0,0 +1,87 @@
1
+ import {
2
+ type AgentEvent,
3
+ AgentEventType,
4
+ isUsageEvent,
5
+ isAgentStartEvent,
6
+ isAgentEndEvent,
7
+ } from "./agent_event.js";
8
+ import type { LlmResponse } from "../model/response.js";
9
+ import type { Content } from "../content.js";
10
+
11
+ export function getContentFromAgentEvent(
12
+ agentEvent: AgentEvent,
13
+ ): Content | undefined {
14
+ if (
15
+ isUsageEvent(agentEvent) ||
16
+ isAgentStartEvent(agentEvent) ||
17
+ isAgentEndEvent(agentEvent) ||
18
+ agentEvent.partial
19
+ ) {
20
+ return undefined;
21
+ }
22
+
23
+ return {
24
+ role: agentEvent.role,
25
+ parts: agentEvent.parts ?? [],
26
+ };
27
+ }
28
+
29
+ export function llmResponseToAgentEvents(
30
+ response: LlmResponse,
31
+ ): Partial<AgentEvent>[] {
32
+ if (response.errorCode || response.errorMessage) {
33
+ return [
34
+ {
35
+ type: AgentEventType.ERROR,
36
+ role: "agent",
37
+ errorMessage: response.errorMessage || "Unknown error",
38
+ statusCode: 500,
39
+ partial: response.partial,
40
+ },
41
+ ];
42
+ }
43
+
44
+ const events: Partial<AgentEvent>[] = [];
45
+
46
+ for (const part of response.content?.parts ?? []) {
47
+ if (part.type === "text" || part.type === "thought") {
48
+ const contentEvent: Partial<AgentEvent> = {
49
+ type: AgentEventType.MESSAGE,
50
+ role: "agent",
51
+ parts: [part],
52
+ partial: response.partial,
53
+ };
54
+ events.push(contentEvent);
55
+ continue;
56
+ }
57
+
58
+ if (part.type === "function_call") {
59
+ const contentEvent: Partial<AgentEvent> = {
60
+ type: AgentEventType.TOOL_CALL,
61
+ role: "agent",
62
+ parts: [part],
63
+ requestId: part.id,
64
+ name: part.name,
65
+ args: part.args,
66
+ partial: response.partial,
67
+ };
68
+ events.push(contentEvent);
69
+ continue;
70
+ }
71
+
72
+ if (part.type === "function_response") {
73
+ const contentEvent: Partial<AgentEvent> = {
74
+ type: AgentEventType.TOOL_RESPONSE,
75
+ role: "agent",
76
+ parts: [part],
77
+ requestId: part.id,
78
+ name: part.name,
79
+ result: part.response,
80
+ partial: response.partial,
81
+ };
82
+ events.push(contentEvent);
83
+ }
84
+ }
85
+
86
+ return events;
87
+ }