@infinityi/engine-lib 1.0.0 → 1.4.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 (405) hide show
  1. package/README.md +81 -445
  2. package/dist/agent/index.js +14 -8
  3. package/dist/context/index.d.ts +1 -1
  4. package/dist/context/index.js +8 -5
  5. package/dist/context/providers.d.ts +3 -3
  6. package/dist/context/types.d.ts +16 -1
  7. package/dist/errors.d.ts +18 -0
  8. package/dist/errors.js +6 -1
  9. package/dist/events/index.js +2 -1
  10. package/dist/execution/index.js +9 -4
  11. package/dist/execution/types.d.ts +14 -0
  12. package/dist/index-37x76zdn.js +4 -0
  13. package/dist/index-4c15ysa8.js +84 -0
  14. package/dist/{index-pwr8179t.js → index-7nb9qwa1.js} +23 -14
  15. package/dist/{index-jxgj4z08.js → index-9egrqxkf.js} +4 -0
  16. package/dist/index-9rr5dkzh.js +0 -0
  17. package/dist/{index-w34cbktd.js → index-a67ej96j.js} +1 -0
  18. package/dist/{index-64tt9696.js → index-aed6fe4z.js} +3 -3
  19. package/dist/{index-7690reng.js → index-ajr3nk10.js} +15 -1
  20. package/dist/index-c6kgts41.js +0 -0
  21. package/dist/{index-xsv43c5j.js → index-e14g2e48.js} +2 -2
  22. package/dist/index-k0q7x4mz.js +54 -0
  23. package/dist/index-mnx5mqbs.js +102 -0
  24. package/dist/index-mr1hs98z.js +661 -0
  25. package/dist/{index-yrqrxwjt.js → index-nvdsr51v.js} +4 -38
  26. package/dist/{index-jp2b31xs.js → index-vwcyawfk.js} +4 -4
  27. package/dist/index-ycjsqfpq.js +39 -0
  28. package/dist/{index-bqg01r42.js → index-zdggff0y.js} +183 -180
  29. package/dist/index.d.ts +2 -2
  30. package/dist/index.js +49 -38
  31. package/dist/lifecycle/index.js +2 -0
  32. package/dist/messages/index.js +1 -0
  33. package/dist/providers/index.js +5 -4
  34. package/dist/retrieval/chunking.d.ts +8 -0
  35. package/dist/retrieval/context.d.ts +4 -0
  36. package/dist/retrieval/index.d.ts +19 -0
  37. package/dist/retrieval/index.js +747 -0
  38. package/dist/retrieval/loaders.d.ts +8 -0
  39. package/dist/retrieval/memory.d.ts +29 -0
  40. package/dist/retrieval/retriever.d.ts +8 -0
  41. package/dist/retrieval/types.d.ts +253 -0
  42. package/dist/retrieval/utils.d.ts +11 -0
  43. package/dist/retrieval/vector-store.d.ts +13 -0
  44. package/dist/runtime/index.js +2 -1
  45. package/dist/schema/index.js +10 -4
  46. package/dist/session/index.js +1 -0
  47. package/dist/session-stores/codec.d.ts +8 -0
  48. package/dist/session-stores/forge-data.d.ts +43 -0
  49. package/dist/session-stores/hooks.d.ts +4 -0
  50. package/dist/session-stores/ids.d.ts +3 -0
  51. package/dist/session-stores/index.d.ts +20 -0
  52. package/dist/session-stores/index.js +1382 -0
  53. package/dist/session-stores/jsonl.d.ts +26 -0
  54. package/dist/session-stores/redis.d.ts +45 -0
  55. package/dist/session-stores/types.d.ts +45 -0
  56. package/dist/session-stores/versioning.d.ts +6 -0
  57. package/dist/testing/conformance.js +5 -4
  58. package/dist/testing/index.js +1 -0
  59. package/dist/tools/index.js +5 -3
  60. package/dist/tools-fs/define.d.ts +2 -0
  61. package/dist/tools-fs/files.d.ts +40 -0
  62. package/dist/tools-fs/git.d.ts +14 -0
  63. package/dist/tools-fs/index.d.ts +19 -0
  64. package/dist/tools-fs/index.js +1695 -0
  65. package/dist/tools-fs/policy.d.ts +32 -0
  66. package/dist/tools-fs/schemas.d.ts +31 -0
  67. package/dist/tools-fs/search.d.ts +45 -0
  68. package/dist/tools-fs/symbols.d.ts +12 -0
  69. package/dist/tools-fs/types.d.ts +151 -0
  70. package/dist/tools-http/client.d.ts +12 -0
  71. package/dist/tools-http/define.d.ts +12 -0
  72. package/dist/tools-http/events.d.ts +22 -0
  73. package/dist/tools-http/index.d.ts +24 -0
  74. package/dist/tools-http/index.js +18 -0
  75. package/dist/tools-http/policy.d.ts +52 -0
  76. package/dist/tools-http/types.d.ts +116 -0
  77. package/dist/tools-shell/define.d.ts +23 -0
  78. package/dist/tools-shell/events.d.ts +38 -0
  79. package/dist/tools-shell/exec.d.ts +37 -0
  80. package/dist/tools-shell/index.d.ts +30 -0
  81. package/dist/tools-shell/index.js +327 -0
  82. package/dist/tools-shell/policy.d.ts +42 -0
  83. package/dist/tools-shell/types.d.ts +121 -0
  84. package/dist/tools-web/define.d.ts +11 -0
  85. package/dist/tools-web/html.d.ts +22 -0
  86. package/dist/tools-web/index.d.ts +21 -0
  87. package/dist/tools-web/index.js +472 -0
  88. package/dist/tools-web/types.d.ts +81 -0
  89. package/docs/README.md +58 -10
  90. package/docs/api/.nojekyll +1 -0
  91. package/docs/api/assets/hierarchy.js +1 -0
  92. package/docs/api/assets/highlight.css +99 -0
  93. package/docs/api/assets/icons.js +18 -0
  94. package/docs/api/assets/icons.svg +1 -0
  95. package/docs/api/assets/main.js +60 -0
  96. package/docs/api/assets/navigation.js +1 -0
  97. package/docs/api/assets/search.js +1 -0
  98. package/docs/api/assets/style.css +1633 -0
  99. package/docs/api/classes/errors.AgentError.html +47 -0
  100. package/docs/api/classes/errors.CancelledError.html +46 -0
  101. package/docs/api/classes/errors.ContextWindowError.html +48 -0
  102. package/docs/api/classes/errors.ExecutionError.html +46 -0
  103. package/docs/api/classes/errors.FilesystemPolicyError.html +48 -0
  104. package/docs/api/classes/errors.MaxHandoffsExceededError.html +47 -0
  105. package/docs/api/classes/errors.MaxStepsExceededError.html +47 -0
  106. package/docs/api/classes/errors.ProviderError.html +47 -0
  107. package/docs/api/classes/errors.SchemaValidationError.html +47 -0
  108. package/docs/api/classes/errors.ShellPolicyError.html +50 -0
  109. package/docs/api/classes/errors.ToolError.html +47 -0
  110. package/docs/api/classes/errors.ToolValidationError.html +48 -0
  111. package/docs/api/classes/index.InMemorySessionStore.html +11 -0
  112. package/docs/api/classes/index.Secret.html +20 -0
  113. package/docs/api/classes/providers.StreamAccumulator.html +8 -0
  114. package/docs/api/classes/session-stores.FilesystemJsonlSessionStore.html +13 -0
  115. package/docs/api/classes/session-stores.ForgeDataSessionStore.html +14 -0
  116. package/docs/api/classes/session-stores.RedisSessionStore.html +12 -0
  117. package/docs/api/classes/tools-http.HttpPolicyError.html +41 -0
  118. package/docs/api/functions/agent.createToolRegistry.html +3 -0
  119. package/docs/api/functions/agent.handoffProviderTools.html +3 -0
  120. package/docs/api/functions/agent.handoffToolName.html +2 -0
  121. package/docs/api/functions/agent.resolveHandoffTargets.html +8 -0
  122. package/docs/api/functions/context.applyContextWindow.html +5 -0
  123. package/docs/api/functions/context.estimateTokens.html +3 -0
  124. package/docs/api/functions/context.resolveContext.html +5 -0
  125. package/docs/api/functions/events.createRunTelemetry.html +3 -0
  126. package/docs/api/functions/events.eventFields.html +4 -0
  127. package/docs/api/functions/events.eventPayload.html +5 -0
  128. package/docs/api/functions/execution.addUsage.html +2 -0
  129. package/docs/api/functions/execution.emptyUsage.html +2 -0
  130. package/docs/api/functions/index.asSchema.html +4 -0
  131. package/docs/api/functions/index.asTool.html +8 -0
  132. package/docs/api/functions/index.assistant.html +2 -0
  133. package/docs/api/functions/index.createAgentRegistry.html +5 -0
  134. package/docs/api/functions/index.createAnthropic.html +5 -0
  135. package/docs/api/functions/index.createEventHub.html +2 -0
  136. package/docs/api/functions/index.createGoogle.html +5 -0
  137. package/docs/api/functions/index.createOpenAI.html +5 -0
  138. package/docs/api/functions/index.createOpenAICompatible.html +7 -0
  139. package/docs/api/functions/index.createSession.html +3 -0
  140. package/docs/api/functions/index.defineAgent.html +7 -0
  141. package/docs/api/functions/index.defineTool.html +7 -0
  142. package/docs/api/functions/index.dynamicContext.html +2 -0
  143. package/docs/api/functions/index.fromJsonSchema.html +3 -0
  144. package/docs/api/functions/index.isSecret.html +4 -0
  145. package/docs/api/functions/index.loggingSubscriber.html +4 -0
  146. package/docs/api/functions/index.messageBusSubscriber.html +6 -0
  147. package/docs/api/functions/index.normalizeContent.html +2 -0
  148. package/docs/api/functions/index.resolveSecret.html +4 -0
  149. package/docs/api/functions/index.runAgent.html +19 -0
  150. package/docs/api/functions/index.staticContext.html +3 -0
  151. package/docs/api/functions/index.summarizeOldest.html +4 -0
  152. package/docs/api/functions/index.system.html +2 -0
  153. package/docs/api/functions/index.text.html +2 -0
  154. package/docs/api/functions/index.toJsonSchema.html +2 -0
  155. package/docs/api/functions/index.toolResult.html +2 -0
  156. package/docs/api/functions/index.truncateOldest.html +5 -0
  157. package/docs/api/functions/index.user.html +2 -0
  158. package/docs/api/functions/index.validateJsonSchema.html +3 -0
  159. package/docs/api/functions/lifecycle.agentRuntimeComponent.html +5 -0
  160. package/docs/api/functions/providers.collectStream.html +2 -0
  161. package/docs/api/functions/providers.createProvider.html +4 -0
  162. package/docs/api/functions/providers.createProviderHttp.html +3 -0
  163. package/docs/api/functions/providers.defaultProviderResilience.html +3 -0
  164. package/docs/api/functions/providers.openSseStream.html +6 -0
  165. package/docs/api/functions/providers.parseSse.html +2 -0
  166. package/docs/api/functions/providers.toProviderError.html +2 -0
  167. package/docs/api/functions/session-stores.createPostgresSessionStore.html +1 -0
  168. package/docs/api/functions/session-stores.createSqliteSessionStore.html +1 -0
  169. package/docs/api/functions/session-stores.isCloseableSessionStore.html +1 -0
  170. package/docs/api/functions/session-stores.isVersionedSessionStore.html +1 -0
  171. package/docs/api/functions/session-stores.migrateSessionStore.html +1 -0
  172. package/docs/api/functions/session-stores.withSessionStoreHooks.html +2 -0
  173. package/docs/api/functions/testing.byteStreamOf.html +2 -0
  174. package/docs/api/functions/testing.collectProviderStream.html +2 -0
  175. package/docs/api/functions/testing.conversation.html +2 -0
  176. package/docs/api/functions/testing.expectValid.html +3 -0
  177. package/docs/api/functions/testing.inMemorySessionStore.html +2 -0
  178. package/docs/api/functions/testing.jsonFetch.html +3 -0
  179. package/docs/api/functions/testing.mockProvider.html +3 -0
  180. package/docs/api/functions/testing.scriptedProvider.html +4 -0
  181. package/docs/api/functions/testing.sseFetch.html +3 -0
  182. package/docs/api/functions/testing.textResult.html +3 -0
  183. package/docs/api/functions/testing.toolCallResult.html +3 -0
  184. package/docs/api/functions/testing_conformance.runProviderConformance.html +3 -0
  185. package/docs/api/functions/tools-fs.filesystemTools.html +1 -0
  186. package/docs/api/functions/tools-http.createHttpToolClient.html +2 -0
  187. package/docs/api/functions/tools-http.httpTools.html +2 -0
  188. package/docs/api/functions/tools-shell.shellTools.html +4 -0
  189. package/docs/api/functions/tools-web.webTools.html +2 -0
  190. package/docs/api/functions/tools.renderToolContent.html +6 -0
  191. package/docs/api/functions/tools.toProviderTool.html +3 -0
  192. package/docs/api/functions/tools.toToolResultMessage.html +4 -0
  193. package/docs/api/hierarchy.html +1 -0
  194. package/docs/api/index.html +1 -0
  195. package/docs/api/interfaces/agent.ToolRegistry.html +8 -0
  196. package/docs/api/interfaces/errors.SchemaIssue.html +4 -0
  197. package/docs/api/interfaces/events.RunTelemetry.html +10 -0
  198. package/docs/api/interfaces/events.SpanHandle.html +6 -0
  199. package/docs/api/interfaces/index.AgentDefinition.html +16 -0
  200. package/docs/api/interfaces/index.AgentHooks.html +21 -0
  201. package/docs/api/interfaces/index.AgentRegistry.html +16 -0
  202. package/docs/api/interfaces/index.AnthropicOptions.html +13 -0
  203. package/docs/api/interfaces/index.AsToolOptions.html +13 -0
  204. package/docs/api/interfaces/index.CompletionRequest.html +30 -0
  205. package/docs/api/interfaces/index.CompletionResult.html +14 -0
  206. package/docs/api/interfaces/index.ContextItem.html +6 -0
  207. package/docs/api/interfaces/index.ContextProvider.html +5 -0
  208. package/docs/api/interfaces/index.ContextStrategy.html +8 -0
  209. package/docs/api/interfaces/index.ContextStrategyContext.html +8 -0
  210. package/docs/api/interfaces/index.ContextWindowOptions.html +8 -0
  211. package/docs/api/interfaces/index.CreateSessionOptions.html +10 -0
  212. package/docs/api/interfaces/index.EngineContext.html +10 -0
  213. package/docs/api/interfaces/index.EventHub.html +4 -0
  214. package/docs/api/interfaces/index.EventHubOptions.html +8 -0
  215. package/docs/api/interfaces/index.GenerationSettings.html +12 -0
  216. package/docs/api/interfaces/index.GoogleOptions.html +11 -0
  217. package/docs/api/interfaces/index.ImagePart.html +5 -0
  218. package/docs/api/interfaces/index.InstructionContext.html +9 -0
  219. package/docs/api/interfaces/index.JsonSchema.html +18 -0
  220. package/docs/api/interfaces/index.LoggingSubscriberOptions.html +4 -0
  221. package/docs/api/interfaces/index.Message.html +8 -0
  222. package/docs/api/interfaces/index.MessageBusSubscriberOptions.html +4 -0
  223. package/docs/api/interfaces/index.OpenAICompatibleOptions.html +16 -0
  224. package/docs/api/interfaces/index.OpenAIOptions.html +16 -0
  225. package/docs/api/interfaces/index.Provider.html +11 -0
  226. package/docs/api/interfaces/index.ProviderCapabilities.html +9 -0
  227. package/docs/api/interfaces/index.ProviderTool.html +6 -0
  228. package/docs/api/interfaces/index.ResponseSchema.html +6 -0
  229. package/docs/api/interfaces/index.RunBridge.html +10 -0
  230. package/docs/api/interfaces/index.RunOptions.html +39 -0
  231. package/docs/api/interfaces/index.RunResult.html +20 -0
  232. package/docs/api/interfaces/index.Schema.html +13 -0
  233. package/docs/api/interfaces/index.Session.html +13 -0
  234. package/docs/api/interfaces/index.SessionState.html +5 -0
  235. package/docs/api/interfaces/index.SessionStore.html +15 -0
  236. package/docs/api/interfaces/index.TextPart.html +4 -0
  237. package/docs/api/interfaces/index.ToolCall.html +9 -0
  238. package/docs/api/interfaces/index.ToolCallPart.html +6 -0
  239. package/docs/api/interfaces/index.ToolContext.html +21 -0
  240. package/docs/api/interfaces/index.ToolDefinition.html +14 -0
  241. package/docs/api/interfaces/index.ToolFailure.html +9 -0
  242. package/docs/api/interfaces/index.ToolResultPart.html +8 -0
  243. package/docs/api/interfaces/index.ToolSpec.html +6 -0
  244. package/docs/api/interfaces/index.ToolSuccess.html +6 -0
  245. package/docs/api/interfaces/index.Usage.html +9 -0
  246. package/docs/api/interfaces/lifecycle.AgentRuntimeOptions.html +17 -0
  247. package/docs/api/interfaces/providers.AdapterSpec.html +17 -0
  248. package/docs/api/interfaces/providers.ProviderHttpOptions.html +14 -0
  249. package/docs/api/interfaces/providers.SseMessage.html +6 -0
  250. package/docs/api/interfaces/providers.SseRequest.html +8 -0
  251. package/docs/api/interfaces/runtime.Logger.html +22 -0
  252. package/docs/api/interfaces/runtime.Telemetry.html +9 -0
  253. package/docs/api/interfaces/schema.OptionalSchema.html +13 -0
  254. package/docs/api/interfaces/session-stores.CloseableSessionStore.html +11 -0
  255. package/docs/api/interfaces/session-stores.CreatePostgresSessionStoreOptions.html +6 -0
  256. package/docs/api/interfaces/session-stores.CreateSqliteSessionStoreOptions.html +7 -0
  257. package/docs/api/interfaces/session-stores.FilesystemJsonlSessionStoreOptions.html +3 -0
  258. package/docs/api/interfaces/session-stores.ForgeDataSessionStoreOptions.html +5 -0
  259. package/docs/api/interfaces/session-stores.RedisSessionStoreClient.html +9 -0
  260. package/docs/api/interfaces/session-stores.RedisSessionStoreOptions.html +4 -0
  261. package/docs/api/interfaces/session-stores.RedisSessionStoreTransaction.html +6 -0
  262. package/docs/api/interfaces/session-stores.SessionArchiveRecord.html +7 -0
  263. package/docs/api/interfaces/session-stores.SessionArchiver.html +2 -0
  264. package/docs/api/interfaces/session-stores.SessionCompactionResult.html +3 -0
  265. package/docs/api/interfaces/session-stores.SessionCompactor.html +3 -0
  266. package/docs/api/interfaces/session-stores.SessionStoreCodec.html +6 -0
  267. package/docs/api/interfaces/session-stores.SessionStoreHookContext.html +3 -0
  268. package/docs/api/interfaces/session-stores.SessionStoreHooks.html +3 -0
  269. package/docs/api/interfaces/session-stores.VersionedSessionStore.html +11 -0
  270. package/docs/api/interfaces/testing.MockProviderOptions.html +12 -0
  271. package/docs/api/interfaces/testing.RecordedCall.html +4 -0
  272. package/docs/api/interfaces/testing.RecordingFetch.html +4 -0
  273. package/docs/api/interfaces/testing_conformance.ConformanceFixtures.html +12 -0
  274. package/docs/api/interfaces/testing_conformance.ConformanceOptions.html +10 -0
  275. package/docs/api/interfaces/testing_conformance.ConformanceTestApi.html +4 -0
  276. package/docs/api/interfaces/testing_conformance.ProviderIO.html +7 -0
  277. package/docs/api/interfaces/tools-fs.ApplyPatchArgs.html +6 -0
  278. package/docs/api/interfaces/tools-fs.DiffStatusArgs.html +5 -0
  279. package/docs/api/interfaces/tools-fs.EditRangeArgs.html +7 -0
  280. package/docs/api/interfaces/tools-fs.EditReplaceArgs.html +7 -0
  281. package/docs/api/interfaces/tools-fs.FilesystemTools.html +13 -0
  282. package/docs/api/interfaces/tools-fs.FilesystemToolsConfig.html +12 -0
  283. package/docs/api/interfaces/tools-fs.FindFilesArgs.html +7 -0
  284. package/docs/api/interfaces/tools-fs.OpenWindowArgs.html +5 -0
  285. package/docs/api/interfaces/tools-fs.ReadArgs.html +9 -0
  286. package/docs/api/interfaces/tools-fs.RepoMapArgs.html +7 -0
  287. package/docs/api/interfaces/tools-fs.SearchSemanticArgs.html +8 -0
  288. package/docs/api/interfaces/tools-fs.SearchTextArgs.html +11 -0
  289. package/docs/api/interfaces/tools-fs.SymbolInfo.html +7 -0
  290. package/docs/api/interfaces/tools-fs.SymbolsArgs.html +5 -0
  291. package/docs/api/interfaces/tools-fs.ValidationCommandRequest.html +4 -0
  292. package/docs/api/interfaces/tools-fs.ValidationCommandResult.html +6 -0
  293. package/docs/api/interfaces/tools-fs.ValidationOptions.html +4 -0
  294. package/docs/api/interfaces/tools-fs.WriteFileArgs.html +6 -0
  295. package/docs/api/interfaces/tools-http.HeaderEntry.html +4 -0
  296. package/docs/api/interfaces/tools-http.HttpClientRequest.html +11 -0
  297. package/docs/api/interfaces/tools-http.HttpPolicy.html +13 -0
  298. package/docs/api/interfaces/tools-http.HttpRequestResult.html +17 -0
  299. package/docs/api/interfaces/tools-http.HttpRetryOptions.html +10 -0
  300. package/docs/api/interfaces/tools-http.HttpToolClient.html +5 -0
  301. package/docs/api/interfaces/tools-http.HttpTools.html +4 -0
  302. package/docs/api/interfaces/tools-http.HttpToolsConfig.html +38 -0
  303. package/docs/api/interfaces/tools-shell.ApprovalDecision.html +5 -0
  304. package/docs/api/interfaces/tools-shell.CommandRequest.html +14 -0
  305. package/docs/api/interfaces/tools-shell.CommandResult.html +21 -0
  306. package/docs/api/interfaces/tools-shell.EnvPolicy.html +9 -0
  307. package/docs/api/interfaces/tools-shell.ShellPolicy.html +7 -0
  308. package/docs/api/interfaces/tools-shell.ShellTools.html +6 -0
  309. package/docs/api/interfaces/tools-shell.ShellToolsConfig.html +26 -0
  310. package/docs/api/interfaces/tools-web.Citation.html +6 -0
  311. package/docs/api/interfaces/tools-web.SearchProvider.html +3 -0
  312. package/docs/api/interfaces/tools-web.SearchRequest.html +4 -0
  313. package/docs/api/interfaces/tools-web.SearchResult.html +7 -0
  314. package/docs/api/interfaces/tools-web.SourceMetadata.html +10 -0
  315. package/docs/api/interfaces/tools-web.WebTools.html +6 -0
  316. package/docs/api/interfaces/tools-web.WebToolsConfig.html +56 -0
  317. package/docs/api/modules/agent.html +5 -0
  318. package/docs/api/modules/context.html +5 -0
  319. package/docs/api/modules/errors.html +8 -0
  320. package/docs/api/modules/events.html +16 -0
  321. package/docs/api/modules/execution.html +4 -0
  322. package/docs/api/modules/index.html +16 -0
  323. package/docs/api/modules/lifecycle.html +6 -0
  324. package/docs/api/modules/messages.html +3 -0
  325. package/docs/api/modules/providers.html +10 -0
  326. package/docs/api/modules/runtime.html +4 -0
  327. package/docs/api/modules/schema.html +5 -0
  328. package/docs/api/modules/session-stores.html +6 -0
  329. package/docs/api/modules/session.html +4 -0
  330. package/docs/api/modules/testing.html +4 -0
  331. package/docs/api/modules/testing_conformance.html +21 -0
  332. package/docs/api/modules/tools-fs.html +9 -0
  333. package/docs/api/modules/tools-http.html +8 -0
  334. package/docs/api/modules/tools-shell.html +12 -0
  335. package/docs/api/modules/tools-web.html +7 -0
  336. package/docs/api/modules/tools.html +4 -0
  337. package/docs/api/types/events.Attrs.html +2 -0
  338. package/docs/api/types/index.AnyRunOptions.html +3 -0
  339. package/docs/api/types/index.BufferedRunOptions.html +2 -0
  340. package/docs/api/types/index.ContentPart.html +2 -0
  341. package/docs/api/types/index.FinishReason.html +2 -0
  342. package/docs/api/types/index.Infer.html +2 -0
  343. package/docs/api/types/index.Instructions.html +5 -0
  344. package/docs/api/types/index.LogLevel.html +2 -0
  345. package/docs/api/types/index.Role.html +2 -0
  346. package/docs/api/types/index.RunEvent.html +30 -0
  347. package/docs/api/types/index.RunHandle.html +7 -0
  348. package/docs/api/types/index.RunInput.html +2 -0
  349. package/docs/api/types/index.RunSubscriber.html +4 -0
  350. package/docs/api/types/index.SafeParseResult.html +2 -0
  351. package/docs/api/types/index.StreamEvent.html +8 -0
  352. package/docs/api/types/index.StreamingRunOptions.html +2 -0
  353. package/docs/api/types/index.TelemetryHandle.html +2 -0
  354. package/docs/api/types/index.TokenCounter.html +2 -0
  355. package/docs/api/types/index.ToolChoice.html +2 -0
  356. package/docs/api/types/index.ToolResult.html +2 -0
  357. package/docs/api/types/lifecycle.ProviderProbe.html +2 -0
  358. package/docs/api/types/session-stores.SessionStoreHookOperation.html +1 -0
  359. package/docs/api/types/testing_conformance.MakeProvider.html +2 -0
  360. package/docs/api/types/tools-fs.SymbolKind.html +1 -0
  361. package/docs/api/types/tools-http.HostPattern.html +2 -0
  362. package/docs/api/types/tools-shell.CommandPattern.html +2 -0
  363. package/docs/api/types/tools-web.RobotsPolicy.html +2 -0
  364. package/docs/api/variables/events.SPAN_PROVIDER.html +2 -0
  365. package/docs/api/variables/events.SPAN_RUN.html +2 -0
  366. package/docs/api/variables/events.SPAN_TOOL.html +2 -0
  367. package/docs/api/variables/execution.DEFAULT_MAX_HANDOFFS.html +2 -0
  368. package/docs/api/variables/execution.DEFAULT_MAX_STEPS.html +2 -0
  369. package/docs/api/variables/index.s.html +11 -0
  370. package/docs/api/variables/providers.DEFAULT_TIMEOUT_MS.html +2 -0
  371. package/docs/api/variables/session-stores.SESSION_STORE_SCHEMA_VERSION.html +1 -0
  372. package/docs/api/variables/session-stores.jsonSessionStoreCodec.html +2 -0
  373. package/docs/api/variables/tools-http.HTTP_EVENT.html +2 -0
  374. package/docs/api/variables/tools-shell.SHELL_EVENT.html +2 -0
  375. package/docs/events-and-telemetry.md +68 -0
  376. package/docs/execution.md +63 -0
  377. package/docs/getting-started.md +73 -0
  378. package/docs/multi-agent.md +52 -0
  379. package/docs/optional-tool-packs.md +93 -0
  380. package/docs/providers.md +68 -0
  381. package/docs/retrieval.md +83 -0
  382. package/docs/sessions-and-context.md +82 -0
  383. package/docs/testing-and-lifecycle.md +60 -0
  384. package/docs/tools.md +69 -0
  385. package/examples/01-minimal-agent.ts +19 -0
  386. package/examples/02-custom-tool.ts +32 -0
  387. package/examples/03-streaming.ts +46 -0
  388. package/examples/04-sessions-context.ts +40 -0
  389. package/examples/05-events-subscribers.ts +35 -0
  390. package/examples/06-multi-agent-handoff.ts +27 -0
  391. package/examples/07-sub-agent-tool.ts +26 -0
  392. package/examples/08-testing-agent.ts +31 -0
  393. package/examples/09-tools-filesystem.ts +49 -0
  394. package/examples/10-tools-http-web.ts +74 -0
  395. package/examples/11-shell-tools.ts +39 -0
  396. package/examples/12-provider-openai.ts +24 -0
  397. package/examples/13-lifecycle.ts +37 -0
  398. package/examples/14-retrieval.ts +65 -0
  399. package/examples/incident-analysis.ts +39 -87
  400. package/package.json +78 -4
  401. package/dist/index-02s1fjxr.js +0 -226
  402. package/examples/README.md +0 -24
  403. package/examples/lifecycle.ts +0 -53
  404. package/examples/multi-agent.ts +0 -93
  405. package/examples/terminal-coder.ts +0 -80
@@ -0,0 +1,32 @@
1
+ import type { FilesystemToolsConfig } from "./types";
2
+ export interface AllowedRoot {
3
+ readonly logical: string;
4
+ readonly real: string;
5
+ }
6
+ export interface FilesystemPolicy {
7
+ readonly allowedRoots: readonly AllowedRoot[];
8
+ readonly defaultRoot: string;
9
+ readonly defaultRootReal: string;
10
+ readonly maxReadBytes: number;
11
+ readonly maxWriteBytes: number;
12
+ readonly maxEntries: number;
13
+ readonly maxResults: number;
14
+ }
15
+ export interface ResolvedPath {
16
+ readonly path: string;
17
+ readonly root: string;
18
+ readonly realPath?: string;
19
+ }
20
+ export declare class FilesystemAccessError extends Error {
21
+ constructor(message: string);
22
+ }
23
+ export declare function normalizePathForOutput(path: string): string;
24
+ export declare function isInside(root: string, candidate: string): boolean;
25
+ export declare function displayPath(root: string, path: string): string;
26
+ export declare function normalizeFilesystemPolicy(config: FilesystemToolsConfig): FilesystemPolicy;
27
+ export declare function resolvePath(policy: FilesystemPolicy, input: string | undefined, options?: {
28
+ readonly base?: string;
29
+ readonly mustExist?: boolean;
30
+ readonly forCreate?: boolean;
31
+ }): Promise<ResolvedPath>;
32
+ export declare function resolveRoot(policy: FilesystemPolicy, input: string | undefined): Promise<ResolvedPath>;
@@ -0,0 +1,31 @@
1
+ import type { JsonSchema, Schema } from "../schema/types";
2
+ import type { ApplyPatchArgs, DiffStatusArgs, EditRangeArgs, EditReplaceArgs, FindFilesArgs, OpenWindowArgs, ReadArgs, RepoMapArgs, SearchSemanticArgs, SearchTextArgs, SymbolsArgs, WriteFileArgs } from "./types";
3
+ interface RawJsonSchema {
4
+ readonly type?: JsonSchema["type"];
5
+ readonly description?: string;
6
+ readonly properties?: Readonly<Record<string, RawJsonSchema>>;
7
+ readonly required?: readonly string[];
8
+ readonly items?: RawJsonSchema;
9
+ readonly enum?: ReadonlyArray<string | number>;
10
+ readonly minimum?: number;
11
+ readonly maximum?: number;
12
+ readonly oneOf?: readonly RawJsonSchema[];
13
+ readonly default?: unknown;
14
+ readonly additionalProperties?: boolean | RawJsonSchema;
15
+ }
16
+ export declare function toolSchema<T>(jsonSchema: RawJsonSchema): Schema<T>;
17
+ export declare const SCHEMAS: {
18
+ readonly repoMap: Schema<RepoMapArgs>;
19
+ readonly findFiles: Schema<FindFilesArgs>;
20
+ readonly searchText: Schema<SearchTextArgs>;
21
+ readonly searchSemantic: Schema<SearchSemanticArgs>;
22
+ readonly symbols: Schema<SymbolsArgs>;
23
+ readonly read: Schema<ReadArgs>;
24
+ readonly openWindow: Schema<OpenWindowArgs>;
25
+ readonly editReplace: Schema<EditReplaceArgs>;
26
+ readonly editRange: Schema<EditRangeArgs>;
27
+ readonly applyPatch: Schema<ApplyPatchArgs>;
28
+ readonly writeFile: Schema<WriteFileArgs>;
29
+ readonly diffStatus: Schema<DiffStatusArgs>;
30
+ };
31
+ export {};
@@ -0,0 +1,45 @@
1
+ export interface TextSearchResult {
2
+ readonly path: string;
3
+ readonly line: number;
4
+ readonly column: number;
5
+ readonly preview: string;
6
+ readonly context: readonly {
7
+ readonly line: number;
8
+ readonly text: string;
9
+ readonly match: boolean;
10
+ }[];
11
+ }
12
+ export interface SemanticSearchResult {
13
+ readonly path: string;
14
+ readonly score: number;
15
+ readonly startLine: number;
16
+ readonly endLine: number;
17
+ readonly preview: string;
18
+ readonly symbol?: string;
19
+ }
20
+ export declare function searchText(root: string, options: {
21
+ readonly pattern: string;
22
+ readonly mode: "literal" | "regex";
23
+ readonly includeGlobs?: readonly string[];
24
+ readonly excludeGlobs?: readonly string[];
25
+ readonly caseSensitive: boolean;
26
+ readonly contextLines: number;
27
+ readonly maxResults: number;
28
+ readonly maxPreviewChars: number;
29
+ }): Promise<{
30
+ readonly results: TextSearchResult[];
31
+ readonly backend: "ripgrep" | "node";
32
+ readonly truncated: boolean;
33
+ }>;
34
+ export declare function searchSemantic(root: string, options: {
35
+ readonly query: string;
36
+ readonly includeGlobs?: readonly string[];
37
+ readonly excludeGlobs?: readonly string[];
38
+ readonly granularity: "file" | "chunk" | "symbol";
39
+ readonly maxResults: number;
40
+ readonly maxPreviewChars: number;
41
+ }): Promise<{
42
+ readonly results: SemanticSearchResult[];
43
+ readonly truncated: boolean;
44
+ }>;
45
+ export declare function parentDirectory(path: string): string;
@@ -0,0 +1,12 @@
1
+ import type { FilesystemPolicy } from "./policy";
2
+ import type { SymbolInfo, SymbolKind } from "./types";
3
+ export declare function symbolsForFile(absPath: string, root: string, maxBytes: number, kinds?: readonly SymbolKind[]): Promise<SymbolInfo[]>;
4
+ export declare function symbolsForPath(policy: FilesystemPolicy, input: string, options?: {
5
+ readonly recursive?: boolean;
6
+ readonly kinds?: readonly SymbolKind[];
7
+ readonly maxResults?: number;
8
+ }): Promise<{
9
+ readonly results: SymbolInfo[];
10
+ readonly truncated: boolean;
11
+ readonly root: string;
12
+ }>;
@@ -0,0 +1,151 @@
1
+ import type { ToolContext, ToolDefinition } from "../tools/types";
2
+ export interface ValidationCommandResult {
3
+ readonly ok: boolean;
4
+ readonly command: string;
5
+ readonly exitCode?: number | null;
6
+ readonly stdout?: string;
7
+ readonly stderr?: string;
8
+ }
9
+ export interface ValidationCommandRequest {
10
+ readonly cwd: string;
11
+ readonly changedFiles: readonly string[];
12
+ readonly ctx: ToolContext;
13
+ }
14
+ export interface FilesystemToolsConfig {
15
+ /** Absolute directories that every filesystem operation must remain within. */
16
+ readonly allowedRoots: readonly string[];
17
+ /** Default workspace root. Relative paths resolve from here. Defaults to the first allowed root. */
18
+ readonly defaultRoot?: string;
19
+ readonly maxReadBytes?: number;
20
+ readonly maxWriteBytes?: number;
21
+ readonly maxEntries?: number;
22
+ readonly maxResults?: number;
23
+ /**
24
+ * Optional host hook for validation commands requested by edit tools.
25
+ * When omitted, requested commands are reported as skipped rather than run.
26
+ */
27
+ readonly runValidationCommand?: (command: string, request: ValidationCommandRequest) => ValidationCommandResult | Promise<ValidationCommandResult>;
28
+ }
29
+ export interface ValidationOptions {
30
+ readonly syntax?: boolean;
31
+ readonly format?: boolean;
32
+ readonly tests?: readonly string[];
33
+ }
34
+ export interface RepoMapArgs {
35
+ readonly root?: string;
36
+ readonly depth?: number;
37
+ readonly include_files?: boolean;
38
+ readonly include_symbols?: boolean;
39
+ readonly max_entries?: number;
40
+ readonly respect_gitignore?: boolean;
41
+ }
42
+ export interface FindFilesArgs {
43
+ readonly query: string;
44
+ readonly mode?: "auto" | "exact" | "glob" | "fuzzy" | "extension" | "regex";
45
+ readonly root?: string;
46
+ readonly include_hidden?: boolean;
47
+ readonly respect_gitignore?: boolean;
48
+ readonly max_results?: number;
49
+ }
50
+ export interface SearchTextArgs {
51
+ readonly pattern: string;
52
+ readonly mode?: "literal" | "regex";
53
+ readonly root?: string;
54
+ readonly include_globs?: readonly string[];
55
+ readonly exclude_globs?: readonly string[];
56
+ readonly case_sensitive?: boolean;
57
+ readonly context_lines?: number;
58
+ readonly max_results?: number;
59
+ readonly max_preview_chars?: number;
60
+ readonly use_index?: boolean;
61
+ }
62
+ export interface SearchSemanticArgs {
63
+ readonly query: string;
64
+ readonly root?: string;
65
+ readonly include_globs?: readonly string[];
66
+ readonly exclude_globs?: readonly string[];
67
+ readonly granularity?: "file" | "chunk" | "symbol";
68
+ readonly max_results?: number;
69
+ readonly max_preview_chars?: number;
70
+ }
71
+ export interface SymbolsArgs {
72
+ readonly path: string;
73
+ readonly recursive?: boolean;
74
+ readonly symbol_kinds?: readonly SymbolKind[];
75
+ readonly max_results?: number;
76
+ }
77
+ export type SymbolKind = "class" | "function" | "method" | "interface" | "type" | "variable" | "import" | "export";
78
+ export interface ReadArgs {
79
+ readonly path: string;
80
+ readonly start_line?: number;
81
+ readonly end_line?: number;
82
+ readonly symbol?: string;
83
+ readonly max_bytes?: number;
84
+ readonly include_line_numbers?: boolean;
85
+ readonly collapse_imports?: boolean;
86
+ readonly collapse_comments?: boolean;
87
+ }
88
+ export interface OpenWindowArgs {
89
+ readonly path: string;
90
+ readonly anchor?: number | string;
91
+ readonly window_lines?: number;
92
+ readonly direction?: "center" | "next" | "prev";
93
+ }
94
+ export interface EditReplaceArgs {
95
+ readonly path: string;
96
+ readonly old_text: string;
97
+ readonly new_text: string;
98
+ readonly occurrence?: number;
99
+ readonly expected_file_version?: string;
100
+ readonly validate?: ValidationOptions;
101
+ }
102
+ export interface EditRangeArgs {
103
+ readonly path: string;
104
+ readonly start_line: number;
105
+ readonly end_line: number;
106
+ readonly new_text: string;
107
+ readonly expected_file_version: string;
108
+ readonly validate?: ValidationOptions;
109
+ }
110
+ export interface ApplyPatchArgs {
111
+ readonly patch: string;
112
+ readonly root?: string;
113
+ readonly dry_run?: boolean;
114
+ readonly expected_versions?: Readonly<Record<string, string>>;
115
+ readonly validate?: ValidationOptions;
116
+ }
117
+ export interface WriteFileArgs {
118
+ readonly path: string;
119
+ readonly content: string;
120
+ readonly mode?: "create_only" | "overwrite" | "append";
121
+ readonly expected_file_version?: string;
122
+ readonly create_dirs?: boolean;
123
+ }
124
+ export interface DiffStatusArgs {
125
+ readonly paths?: readonly string[];
126
+ readonly include_diff?: boolean;
127
+ readonly max_diff_chars?: number;
128
+ readonly context_lines?: number;
129
+ }
130
+ export interface SymbolInfo {
131
+ readonly path: string;
132
+ readonly name: string;
133
+ readonly kind: SymbolKind;
134
+ readonly startLine: number;
135
+ readonly endLine: number;
136
+ readonly signature?: string;
137
+ }
138
+ export interface FilesystemTools {
139
+ readonly repoMap: ToolDefinition<RepoMapArgs>;
140
+ readonly findFiles: ToolDefinition<FindFilesArgs>;
141
+ readonly searchText: ToolDefinition<SearchTextArgs>;
142
+ readonly searchSemantic: ToolDefinition<SearchSemanticArgs>;
143
+ readonly symbols: ToolDefinition<SymbolsArgs>;
144
+ readonly read: ToolDefinition<ReadArgs>;
145
+ readonly openWindow: ToolDefinition<OpenWindowArgs>;
146
+ readonly editReplace: ToolDefinition<EditReplaceArgs>;
147
+ readonly editRange: ToolDefinition<EditRangeArgs>;
148
+ readonly applyPatch: ToolDefinition<ApplyPatchArgs>;
149
+ readonly writeFile: ToolDefinition<WriteFileArgs>;
150
+ readonly diffStatus: ToolDefinition<DiffStatusArgs>;
151
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Low-level HTTP client for `tools-http`.
3
+ *
4
+ * It performs policy checks before every request and redirect target, follows
5
+ * redirects manually, uses Forge resilience for retry/timeout, and returns a
6
+ * compact parsed response.
7
+ *
8
+ * @module
9
+ */
10
+ import type { HttpToolClient, HttpToolsConfig } from "./types";
11
+ /** Create a policy-gated HTTP client. */
12
+ export declare function createHttpToolClient(config: HttpToolsConfig): HttpToolClient;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Ready-made HTTP tool definitions.
3
+ *
4
+ * The factory is intentionally thin: host configuration is bound once, model
5
+ * arguments are validated through JSON Schema, and every expected failure is
6
+ * returned as a tool error.
7
+ *
8
+ * @module
9
+ */
10
+ import type { HttpTools, HttpToolsConfig } from "./types";
11
+ /** Build the `http_get` and `http_post` tools bound to host policy. */
12
+ export declare function httpTools(config: HttpToolsConfig): HttpTools;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Custom run events emitted by `@infinityi/engine-lib/tools-http`.
3
+ *
4
+ * Emission is a no-op outside `runAgent`, matching the other optional tool
5
+ * packs. Events are intentionally compact and avoid response bodies.
6
+ *
7
+ * @module
8
+ */
9
+ import type { ToolContext } from "../tools/types";
10
+ import type { HttpRequestResult } from "./types";
11
+ /** Event names emitted by the HTTP tool module. */
12
+ export declare const HTTP_EVENT: {
13
+ readonly policy: "http.policy";
14
+ readonly requestStart: "http.request.start";
15
+ readonly requestEnd: "http.request.end";
16
+ };
17
+ /** Surface a URL policy decision. */
18
+ export declare function emitHttpPolicy(ctx: ToolContext | undefined, decision: "allow" | "deny", url: string, reason?: string): void;
19
+ /** Surface the beginning of a logical HTTP request. */
20
+ export declare function emitHttpRequestStart(ctx: ToolContext | undefined, method: string, url: string, timeoutMs: number): void;
21
+ /** Surface the end of a logical HTTP request or a transport failure. */
22
+ export declare function emitHttpRequestEnd(ctx: ToolContext | undefined, method: string, url: string, result: HttpRequestResult | undefined, error?: string): void;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * `@infinityi/engine-lib/tools-http` - optional, policy-gated HTTP tools.
3
+ *
4
+ * This subpath is intentionally absent from the root barrel. Hosts must opt in
5
+ * and provide explicit network scope with either `allowedHosts` or
6
+ * `allowPublicInternet: true`.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import { httpTools } from "@infinityi/engine-lib/tools-http";
11
+ *
12
+ * const http = httpTools({
13
+ * allowedHosts: ["api.example.com"],
14
+ * defaultHeaders: [{ name: "accept", value: "application/json" }],
15
+ * });
16
+ * ```
17
+ *
18
+ * @module
19
+ */
20
+ export { createHttpToolClient } from "./client";
21
+ export { httpTools } from "./define";
22
+ export { HTTP_EVENT } from "./events";
23
+ export { HttpPolicyError } from "./policy";
24
+ export type { HeaderEntry, HostPattern, HttpClientRequest, HttpPolicy, HttpRequestResult, HttpRetryOptions, HttpToolClient, HttpTools, HttpToolsConfig, } from "./types";
@@ -0,0 +1,18 @@
1
+ import {
2
+ HTTP_EVENT,
3
+ HttpPolicyError,
4
+ createHttpToolClient,
5
+ httpTools
6
+ } from "../index-mr1hs98z.js";
7
+ import"../index-k0q7x4mz.js";
8
+ import"../index-zdggff0y.js";
9
+ import"../index-4c15ysa8.js";
10
+ import"../index-ajr3nk10.js";
11
+ import"../index-a67ej96j.js";
12
+ import"../index-37x76zdn.js";
13
+ export {
14
+ httpTools,
15
+ createHttpToolClient,
16
+ HttpPolicyError,
17
+ HTTP_EVENT
18
+ };
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Pure policy helpers for `tools-http`.
3
+ *
4
+ * Host configuration is normalized eagerly by the factory/client. Per-request
5
+ * denials throw {@link HttpPolicyError}; ready-made tools catch these and
6
+ * return `{ ok: false, error }`.
7
+ *
8
+ * @module
9
+ */
10
+ import type { HeaderEntry, HostPattern, HttpToolsConfig } from "./types";
11
+ /** Host-side HTTP policy/configuration error. */
12
+ export declare class HttpPolicyError extends Error {
13
+ constructor(message: string, options?: ErrorOptions);
14
+ }
15
+ export interface NormalizedHttpConfig {
16
+ readonly allowPublicInternet: boolean;
17
+ readonly allowedHosts: readonly HostPattern[];
18
+ readonly deniedHosts: readonly HostPattern[];
19
+ readonly allowedProtocols: readonly string[];
20
+ readonly allowPrivateNetwork: boolean;
21
+ readonly allowCredentialedUrls: boolean;
22
+ readonly defaultHeaders: readonly HeaderEntry[];
23
+ readonly allowedRequestHeaders: ReadonlySet<string>;
24
+ readonly responseHeaderAllowlist: ReadonlySet<string>;
25
+ readonly defaultTimeoutMs: number;
26
+ readonly minTimeoutMs: number;
27
+ readonly maxTimeoutMs: number;
28
+ readonly maxResponseBytes: number;
29
+ readonly maxBodyChars: number;
30
+ readonly maxRedirects: number;
31
+ readonly retryMaxAttempts: number;
32
+ readonly retryInitialDelayMs: number;
33
+ readonly retryMaxDelayMs: number;
34
+ readonly retryUnsafeMethods: boolean;
35
+ readonly fetch: typeof fetch;
36
+ }
37
+ /** Normalize and validate host configuration. */
38
+ export declare function normalizeHttpConfig(config: HttpToolsConfig): NormalizedHttpConfig;
39
+ /** Clamp a caller/model-supplied number into a host-approved range. */
40
+ export declare function clamp(value: number, min: number, max: number): number;
41
+ /** Match a URL against a host policy pattern. */
42
+ export declare function matchesHost(url: URL, pattern: HostPattern): boolean;
43
+ /** Whether a hostname is an explicit private/local target. */
44
+ export declare function isPrivateTarget(hostname: string): boolean;
45
+ /** Validate one URL against the host-side HTTP policy. */
46
+ export declare function assertUrlAllowed(url: URL, config: NormalizedHttpConfig): void;
47
+ /** Convert model-supplied headers into the subset permitted by config. */
48
+ export declare function buildRequestHeaders(config: NormalizedHttpConfig, modelHeaders: readonly HeaderEntry[] | undefined, contentType?: string, options?: {
49
+ includeConfiguredHeaders?: boolean;
50
+ }): Headers;
51
+ /** Return response headers filtered through the configured allowlist. */
52
+ export declare function allowedResponseHeaders(headers: Headers, allowlist: ReadonlySet<string>): readonly HeaderEntry[];
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Public types for `@infinityi/engine-lib/tools-http`.
3
+ *
4
+ * The module is opt-in and host-configured: network scope, default headers,
5
+ * timeout limits, and response caps are all supplied by the application, not by
6
+ * the model. Per-call failures are returned as tool errors by the ready-made
7
+ * tools; the lower-level client throws ordinary errors for callers to handle.
8
+ *
9
+ * @module
10
+ */
11
+ import type { ToolDefinition } from "../tools/types";
12
+ /** A hostname policy entry. Strings support exact hosts, `host:port`, `*`, and `*.example.com`. */
13
+ export type HostPattern = string | RegExp;
14
+ /** A normalized HTTP header entry. */
15
+ export interface HeaderEntry {
16
+ readonly name: string;
17
+ readonly value: string;
18
+ }
19
+ /** Host-side network policy for low-level HTTP access. */
20
+ export interface HttpPolicy {
21
+ /**
22
+ * Hosts the tools may contact. Required unless
23
+ * {@link HttpToolsConfig.allowPublicInternet} is true.
24
+ */
25
+ readonly allowedHosts?: readonly HostPattern[];
26
+ /** Hosts denied even when otherwise allowed. Deny wins over allow. */
27
+ readonly deniedHosts?: readonly HostPattern[];
28
+ /** Allowed URL protocols. Defaults to `["https:", "http:"]`. */
29
+ readonly allowedProtocols?: readonly string[];
30
+ /** Allow private, loopback, link-local, multicast, and localhost targets. Defaults to false. */
31
+ readonly allowPrivateNetwork?: boolean;
32
+ /** Allow URLs with embedded username/password credentials. Defaults to false. */
33
+ readonly allowCredentialedUrls?: boolean;
34
+ }
35
+ /** Retry behavior for the HTTP client. */
36
+ export interface HttpRetryOptions {
37
+ /** Maximum attempts for retry-enabled methods. Defaults to 3. */
38
+ readonly maxAttempts?: number;
39
+ /** Initial exponential backoff delay in ms. Defaults to 100. */
40
+ readonly initialDelayMs?: number;
41
+ /** Maximum exponential backoff delay in ms. Defaults to 2_000. */
42
+ readonly maxDelayMs?: number;
43
+ /** Retry POST/other unsafe methods too. Defaults to false. */
44
+ readonly retryUnsafeMethods?: boolean;
45
+ }
46
+ /** Configuration for {@link httpTools} and {@link createHttpToolClient}. */
47
+ export interface HttpToolsConfig extends HttpPolicy {
48
+ /**
49
+ * Permit any public host. At least one of this or `allowedHosts` is required
50
+ * so hosts opt into network scope explicitly.
51
+ */
52
+ readonly allowPublicInternet?: boolean;
53
+ /** Headers supplied by the host on every request. */
54
+ readonly defaultHeaders?: readonly HeaderEntry[] | Readonly<Record<string, string>>;
55
+ /** Model-supplied request headers accepted by name. Defaults to none. */
56
+ readonly allowedRequestHeaders?: readonly string[];
57
+ /** Response headers exposed in results. Defaults to a compact safe allowlist. */
58
+ readonly responseHeaderAllowlist?: readonly string[];
59
+ /** Default per-attempt timeout. Defaults to 10_000ms. */
60
+ readonly defaultTimeoutMs?: number;
61
+ /** Minimum accepted timeout after clamping. Defaults to 100ms. */
62
+ readonly minTimeoutMs?: number;
63
+ /** Maximum accepted timeout after clamping. Defaults to 60_000ms. */
64
+ readonly maxTimeoutMs?: number;
65
+ /** Maximum bytes read from a response body. Defaults to 1_000_000. */
66
+ readonly maxResponseBytes?: number;
67
+ /** Maximum characters returned for parsed text bodies. Defaults to 20_000. */
68
+ readonly maxBodyChars?: number;
69
+ /** Maximum followed redirects. Defaults to 5. */
70
+ readonly maxRedirects?: number;
71
+ /** Retry configuration. GET retries are enabled by default. */
72
+ readonly retry?: HttpRetryOptions;
73
+ /** Inject a fetch implementation for tests or custom transports. */
74
+ readonly fetch?: typeof fetch;
75
+ }
76
+ /** A client request after tool argument mapping. */
77
+ export interface HttpClientRequest {
78
+ readonly method: "GET" | "POST";
79
+ readonly url: string;
80
+ readonly headers?: readonly HeaderEntry[];
81
+ readonly body?: string;
82
+ readonly bodyJson?: unknown;
83
+ readonly contentType?: string;
84
+ readonly timeoutMs?: number;
85
+ readonly maxBytes?: number;
86
+ readonly maxBodyChars?: number;
87
+ }
88
+ /** Compact metadata and parsed body for a received HTTP response. */
89
+ export interface HttpRequestResult {
90
+ readonly url: string;
91
+ readonly finalUrl: string;
92
+ readonly redirected: boolean;
93
+ readonly redirects: readonly string[];
94
+ readonly status: number;
95
+ readonly statusText: string;
96
+ readonly contentType?: string;
97
+ readonly headers: readonly HeaderEntry[];
98
+ readonly body?: string;
99
+ readonly bodyJson?: unknown;
100
+ readonly bodyOmitted: boolean;
101
+ readonly bodyTruncated: boolean;
102
+ readonly responseBytes: number;
103
+ readonly responseBytesTruncated: boolean;
104
+ readonly elapsedMs: number;
105
+ }
106
+ /** Low-level HTTP client backing both the HTTP and web tool packs. */
107
+ export interface HttpToolClient {
108
+ request(req: HttpClientRequest, ctx?: import("../tools/types").ToolContext): Promise<HttpRequestResult>;
109
+ get(url: string, options?: Omit<HttpClientRequest, "method" | "url" | "body" | "bodyJson" | "contentType">, ctx?: import("../tools/types").ToolContext): Promise<HttpRequestResult>;
110
+ post(url: string, options?: Omit<HttpClientRequest, "method" | "url">, ctx?: import("../tools/types").ToolContext): Promise<HttpRequestResult>;
111
+ }
112
+ /** The ready-made HTTP tool definitions. */
113
+ export interface HttpTools {
114
+ readonly httpGet: ToolDefinition;
115
+ readonly httpPost: ToolDefinition;
116
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * `shellTools` — the optional, policy-gated command-execution tool factory.
3
+ *
4
+ * Returns two {@link ToolDefinition}s, `run_command` (buffered) and
5
+ * `spawn_command` (streamed), that share one execution pipeline:
6
+ *
7
+ * validate cwd → classify command → (approval) → filter env → spawn → result
8
+ *
9
+ * Each gate emits a `custom` {@link RunEvent} so the host's existing
10
+ * subscribers/auditing see every policy decision, approval, and execution. A
11
+ * command never runs silently: a denied cwd, a denied command, or a withheld
12
+ * approval all return `{ ok: false, error }` *before* any process is created.
13
+ *
14
+ * @module
15
+ */
16
+ import type { ShellToolsConfig, ShellTools } from "./types";
17
+ /**
18
+ * Build a `run_command` / `spawn_command` pair bound to `config`.
19
+ *
20
+ * @throws {@link ShellPolicyError} if `allowedCwds` is empty or contains a
21
+ * non-absolute path (a host-side configuration fault, raised eagerly here).
22
+ */
23
+ export declare function shellTools(config: ShellToolsConfig): ShellTools;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Helpers that surface shell policy / approval / execution metadata onto the
3
+ * run's event stream as generic `custom` {@link RunEvent}s.
4
+ *
5
+ * All events share the `"shell."` name prefix so subscribers can filter the
6
+ * module's traffic. Emission goes through {@link ToolContext.run} (the
7
+ * {@link RunBridge}) and is a no-op when the tool runs outside `runAgent`, so a
8
+ * tool invoked directly in a test still works without a run.
9
+ *
10
+ * @module
11
+ */
12
+ import type { ToolContext } from "../tools/types";
13
+ import type { CommandRequest, CommandResult } from "./types";
14
+ /** Event names emitted by this module, under the shared `shell.` namespace. */
15
+ export declare const SHELL_EVENT: {
16
+ readonly policy: "shell.policy";
17
+ readonly approval: "shell.approval";
18
+ readonly execStart: "shell.exec.start";
19
+ readonly execChunk: "shell.exec.chunk";
20
+ readonly execEnd: "shell.exec.end";
21
+ };
22
+ /** A policy decision (cwd allowlist or command allow/deny). */
23
+ export declare function emitPolicy(ctx: ToolContext, decision: "allow" | "deny", req: Pick<CommandRequest, "command" | "args" | "mode">, reason?: string): void;
24
+ /** An approval lifecycle update. */
25
+ export declare function emitApproval(ctx: ToolContext, status: "requested" | "approved" | "denied", req: CommandRequest, reason?: string): void;
26
+ /** Execution is about to begin. */
27
+ export declare function emitExecStart(ctx: ToolContext, req: CommandRequest): void;
28
+ /** A streamed output chunk (only `spawn_command` emits these). */
29
+ export declare function emitExecChunk(ctx: ToolContext, stream: "stdout" | "stderr", text: string): void;
30
+ /** Execution finished; carries the structured result summary. */
31
+ export declare function emitExecEnd(ctx: ToolContext, result: CommandResult): void;
32
+ /**
33
+ * Execution failed before producing a result (the process could not be
34
+ * spawned). Emits a closing `shell.exec.end` so subscribers that pair
35
+ * start/end events always see the span close, with `error` set and `exitCode`
36
+ * null to mark that the command never ran.
37
+ */
38
+ export declare function emitExecError(ctx: ToolContext, req: CommandRequest, error: string): void;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The process-execution primitive behind both shell tools: a single
3
+ * `Bun.spawn` wrapper that enforces a timeout, captures stdout/stderr with
4
+ * byte-bounded truncation, and reports the exit code / signal.
5
+ *
6
+ * It has no knowledge of policy, approval, or events — those are layered on in
7
+ * `define.ts`. The only difference between the buffered (`run_command`) and
8
+ * streamed (`spawn_command`) tools is the optional {@link ExecOptions.onChunk}
9
+ * callback, which fires per output chunk as it arrives.
10
+ *
11
+ * @module
12
+ */
13
+ import type { CommandResult } from "./types";
14
+ /** A streamed output chunk delivered to {@link ExecOptions.onChunk}. */
15
+ export interface ExecChunk {
16
+ readonly stream: "stdout" | "stderr";
17
+ readonly text: string;
18
+ }
19
+ /** Inputs to {@link execCommand}. */
20
+ export interface ExecOptions {
21
+ readonly command: string;
22
+ readonly args: readonly string[];
23
+ readonly cwd: string;
24
+ readonly env: Record<string, string>;
25
+ readonly timeoutMs: number;
26
+ readonly maxOutputBytes: number;
27
+ /** Called for each output chunk as it streams in (used by `spawn_command`). */
28
+ readonly onChunk?: (chunk: ExecChunk) => void;
29
+ /** Caller cancellation (the run's `AbortSignal`); kills the process if aborted. */
30
+ readonly signal?: AbortSignal;
31
+ }
32
+ /**
33
+ * Spawn a command and resolve with a structured {@link CommandResult}. Never
34
+ * rejects for a non-zero exit — a failed command is data the model should see.
35
+ * Rejects only if the process cannot be spawned at all (e.g. unknown program).
36
+ */
37
+ export declare function execCommand(opts: ExecOptions): Promise<CommandResult>;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * `@infinityi/engine-lib/tools-shell` — an **optional** module providing safe,
3
+ * policy-gated command execution as ready-made tools.
4
+ *
5
+ * The core library ships no code-execution tools by design. This subpath is the
6
+ * opt-in exception for hosts that need it (coding terminals, ops agents): a
7
+ * single {@link shellTools} factory yields `run_command` (buffered) and
8
+ * `spawn_command` (streamed) tools wrapped in working-directory allowlists,
9
+ * environment filtering, command allow/deny policy, and optional approval
10
+ * hooks. Every decision is surfaced as a `custom` run event for auditing.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import { shellTools } from "@infinityi/engine-lib/tools-shell";
15
+ * import { defineAgent } from "@infinityi/engine-lib/agent";
16
+ *
17
+ * const { runCommand } = shellTools({
18
+ * allowedCwds: [process.cwd()],
19
+ * policy: { deny: [/\brm\b/, /\bsudo\b/] },
20
+ * env: { allow: ["PATH", "HOME"] },
21
+ * });
22
+ *
23
+ * const agent = defineAgent({ name: "ops", tools: [runCommand], ... });
24
+ * ```
25
+ *
26
+ * @module
27
+ */
28
+ export { shellTools } from "./define";
29
+ export { SHELL_EVENT } from "./events";
30
+ export type { ApprovalDecision, CommandPattern, CommandRequest, CommandResult, EnvPolicy, ShellPolicy, ShellTools, ShellToolsConfig, } from "./types";