@infinityi/engine-lib 1.3.1 → 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 (401) 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 +52 -0
  400. package/package.json +78 -4
  401. package/dist/index-02s1fjxr.js +0 -226
@@ -0,0 +1,472 @@
1
+ import {
2
+ createHttpToolClient
3
+ } from "../index-mr1hs98z.js";
4
+ import"../index-k0q7x4mz.js";
5
+ import"../index-zdggff0y.js";
6
+ import {
7
+ s
8
+ } from "../index-mnx5mqbs.js";
9
+ import"../index-4c15ysa8.js";
10
+ import"../index-ajr3nk10.js";
11
+ import {
12
+ defineTool
13
+ } from "../index-a67ej96j.js";
14
+ import"../index-37x76zdn.js";
15
+
16
+ // src/tools-web/define.ts
17
+ import { Readability } from "@mozilla/readability";
18
+ import robotsParser from "robots-parser";
19
+
20
+ // src/tools-web/html.ts
21
+ import { parseHTML } from "linkedom";
22
+ function compactWhitespace(text) {
23
+ return text.replace(/\s+/g, " ").trim();
24
+ }
25
+ function documentFromHtml(html) {
26
+ return parseHTML(html).document;
27
+ }
28
+ function removeNoise(document) {
29
+ for (const selector of ["script", "style", "noscript", "template", "svg"]) {
30
+ for (const node of Array.from(document.querySelectorAll(selector))) {
31
+ node.remove?.();
32
+ }
33
+ }
34
+ }
35
+ function normalizeUrl(raw, baseUrl) {
36
+ try {
37
+ const url = new URL(raw, baseUrl);
38
+ if (url.protocol !== "http:" && url.protocol !== "https:")
39
+ return null;
40
+ url.hash = "";
41
+ return url.href;
42
+ } catch {
43
+ return null;
44
+ }
45
+ }
46
+ function parseStaticHtml(html, baseUrl, maxLinks = Number.POSITIVE_INFINITY) {
47
+ const document = documentFromHtml(html);
48
+ const title = compactWhitespace(document.querySelector("title")?.textContent ?? "");
49
+ removeNoise(document);
50
+ const root = document.body ?? document.documentElement;
51
+ const text = compactWhitespace(root?.textContent ?? "");
52
+ const links = [];
53
+ const seen = new Set;
54
+ for (const anchor of Array.from(document.querySelectorAll("a[href]"))) {
55
+ if (links.length >= maxLinks)
56
+ break;
57
+ if (anchor.getAttribute === undefined)
58
+ continue;
59
+ const href = anchor.getAttribute("href");
60
+ if (href === null)
61
+ continue;
62
+ const url = normalizeUrl(href, baseUrl);
63
+ if (url === null || seen.has(url))
64
+ continue;
65
+ seen.add(url);
66
+ const linkText = compactWhitespace(anchor.textContent ?? "");
67
+ links.push({ url, ...linkText !== "" ? { text: linkText } : {} });
68
+ }
69
+ return {
70
+ ...title !== "" ? { title } : {},
71
+ text,
72
+ links
73
+ };
74
+ }
75
+ function readabilityDocument(html) {
76
+ return documentFromHtml(html);
77
+ }
78
+ function compactText(text) {
79
+ return compactWhitespace(text);
80
+ }
81
+
82
+ // src/tools-web/define.ts
83
+ var DEFAULT_USER_AGENT = "engine-lib";
84
+ var DEFAULT_MAX_SEARCH_RESULTS = 10;
85
+ var DEFAULT_MAX_PAGE_TEXT_CHARS = 12000;
86
+ var DEFAULT_MAX_CRAWL_PAGES = 10;
87
+ var DEFAULT_MAX_LINKS_PER_PAGE = 25;
88
+ var WEB_SEARCH_PARAMS = s.object({
89
+ query: s.string({ description: "Search query." }),
90
+ max_results: s.optional(s.number({ int: true, description: "Maximum results to return." }))
91
+ });
92
+ var URL_PARAMS = s.object({
93
+ url: s.string({ description: "Absolute http(s) URL." }),
94
+ max_body_chars: s.optional(s.number({ int: true, description: "Returned text character cap." }))
95
+ });
96
+ var CRAWL_PARAMS = s.object({
97
+ url: s.string({ description: "Absolute http(s) URL to start from." }),
98
+ depth: s.optional(s.number({ int: true, description: "Maximum crawl depth from the start URL." })),
99
+ max_pages: s.optional(s.number({ int: true, description: "Maximum pages to fetch." })),
100
+ max_links_per_page: s.optional(s.number({ int: true, description: "Maximum links to keep from each page." })),
101
+ same_host: s.optional(s.boolean({ description: "Restrict crawl to the start URL host. Defaults to true." }))
102
+ });
103
+ function fail(error) {
104
+ if (error instanceof Error)
105
+ return { ok: false, error: error.message };
106
+ return { ok: false, error: String(error) };
107
+ }
108
+ function clamp(value, fallback, min, max) {
109
+ const n = value ?? fallback;
110
+ return Math.max(min, Math.min(max, n));
111
+ }
112
+ function firstSnippet(text, max = 240) {
113
+ const compact = compactText(text);
114
+ if (compact === "")
115
+ return;
116
+ return compact.length <= max ? compact : compact.slice(0, max);
117
+ }
118
+ function isHtml(result) {
119
+ const type = (result.contentType ?? "").toLowerCase();
120
+ return type.includes("text/html") || type.includes("application/xhtml+xml");
121
+ }
122
+ function titleFromTextFallback(url) {
123
+ try {
124
+ return new URL(url).hostname;
125
+ } catch {
126
+ return url;
127
+ }
128
+ }
129
+ function sourceFor(requestedUrl, result, fetchedAt, title, snippet, robots) {
130
+ return {
131
+ url: requestedUrl,
132
+ finalUrl: result.finalUrl,
133
+ ...title !== undefined ? { title } : {},
134
+ fetchedAt,
135
+ ...result.contentType !== undefined ? { contentType: result.contentType } : {},
136
+ status: result.status,
137
+ ...snippet !== undefined ? { snippet } : {},
138
+ ...robots !== undefined ? { robots } : {}
139
+ };
140
+ }
141
+ function citationFor(source) {
142
+ return {
143
+ url: source.finalUrl,
144
+ ...source.title !== undefined ? { title: source.title } : {},
145
+ ...source.snippet !== undefined ? { snippet: source.snippet } : {},
146
+ fetchedAt: source.fetchedAt
147
+ };
148
+ }
149
+ function normalizeSearchResult(result, fetchedAt) {
150
+ const source = result.source ?? {
151
+ url: result.url,
152
+ finalUrl: result.url,
153
+ ...result.title !== undefined ? { title: result.title } : {},
154
+ fetchedAt,
155
+ ...result.snippet !== undefined ? { snippet: result.snippet } : {}
156
+ };
157
+ return {
158
+ url: result.url,
159
+ ...result.title !== undefined ? { title: result.title } : source.title !== undefined ? { title: source.title } : {},
160
+ ...result.snippet !== undefined ? { snippet: result.snippet } : source.snippet !== undefined ? { snippet: source.snippet } : {},
161
+ source,
162
+ citation: result.citation ?? citationFor(source)
163
+ };
164
+ }
165
+ function robotsPolicyFor(config, url) {
166
+ const host = url.hostname.toLowerCase();
167
+ return config.robotsByHost?.[host] ?? config.robots ?? "enforce";
168
+ }
169
+ function originOf(url) {
170
+ return `${url.protocol}//${url.host}`;
171
+ }
172
+ function robotsUrlFor(url) {
173
+ return `${originOf(url)}/robots.txt`;
174
+ }
175
+ function sameHost(url, start) {
176
+ try {
177
+ const next = new URL(url);
178
+ return next.hostname.toLowerCase() === start.hostname.toLowerCase();
179
+ } catch {
180
+ return false;
181
+ }
182
+ }
183
+ function normalizeFetchText(result, maxChars) {
184
+ if (typeof result.body === "string" && isHtml(result)) {
185
+ const parsed = parseStaticHtml(result.body, result.finalUrl);
186
+ const limited = result.bodyTruncated || parsed.text.length > maxChars;
187
+ return {
188
+ text: parsed.text.slice(0, maxChars),
189
+ html: result.body,
190
+ title: parsed.title,
191
+ links: parsed.links,
192
+ truncated: limited,
193
+ bodyTruncated: result.bodyTruncated
194
+ };
195
+ }
196
+ if (typeof result.body === "string") {
197
+ const text = compactText(result.body);
198
+ return {
199
+ text: text.slice(0, maxChars),
200
+ links: [],
201
+ truncated: result.bodyTruncated || text.length > maxChars,
202
+ bodyTruncated: result.bodyTruncated
203
+ };
204
+ }
205
+ if (result.bodyJson !== undefined) {
206
+ const text = compactText(JSON.stringify(result.bodyJson));
207
+ return {
208
+ text: text.slice(0, maxChars),
209
+ links: [],
210
+ truncated: text.length > maxChars,
211
+ bodyTruncated: result.bodyTruncated
212
+ };
213
+ }
214
+ return { text: "", links: [], truncated: false, bodyTruncated: result.bodyTruncated };
215
+ }
216
+ function createRobotsChecker(config, http) {
217
+ const cache = new Map;
218
+ const userAgent = config.userAgent ?? DEFAULT_USER_AGENT;
219
+ async function fetchRobots(url, ctx) {
220
+ const origin = originOf(url);
221
+ const cached = cache.get(origin);
222
+ if (cached !== undefined)
223
+ return cached;
224
+ const promise = (async () => {
225
+ try {
226
+ const response = await http.get(robotsUrlFor(url), {
227
+ maxBytes: 512000,
228
+ maxBodyChars: 512000,
229
+ headers: [{ name: "user-agent", value: userAgent }]
230
+ }, ctx);
231
+ if (response.status < 200 || response.status >= 300 || typeof response.body !== "string") {
232
+ return { status: response.status, rules: robotsParser(robotsUrlFor(url), "") };
233
+ }
234
+ return {
235
+ status: response.status,
236
+ rules: robotsParser(robotsUrlFor(url), response.body)
237
+ };
238
+ } catch (error) {
239
+ return { status: "error", error: error instanceof Error ? error.message : String(error) };
240
+ }
241
+ })();
242
+ cache.set(origin, promise);
243
+ return promise;
244
+ }
245
+ return async function checkRobots(rawUrl, ctx) {
246
+ const url = new URL(rawUrl);
247
+ const policy = robotsPolicyFor(config, url);
248
+ if (policy === "ignore")
249
+ return { policy };
250
+ const record = await fetchRobots(url, ctx);
251
+ if (record.status === "error") {
252
+ const robots2 = { policy, reason: record.error };
253
+ if (policy === "enforce") {
254
+ throw new Error(`robots.txt could not be fetched for ${originOf(url)}: ${record.error}`);
255
+ }
256
+ return robots2;
257
+ }
258
+ const allowed = record.rules?.isAllowed(rawUrl, userAgent);
259
+ const isAllowed = allowed !== false;
260
+ const robots = {
261
+ policy,
262
+ allowed: isAllowed,
263
+ ...!isAllowed ? { reason: "robots.txt disallows this URL" } : {}
264
+ };
265
+ if (!isAllowed && policy === "enforce") {
266
+ throw new Error(`robots.txt disallows ${rawUrl}`);
267
+ }
268
+ return robots;
269
+ };
270
+ }
271
+ function webTools(config) {
272
+ const http = config.httpClient ?? createHttpToolClient(config);
273
+ const checkRobots = createRobotsChecker(config, http);
274
+ const maxSearchResults = config.maxSearchResults ?? DEFAULT_MAX_SEARCH_RESULTS;
275
+ const maxPageTextChars = config.maxPageTextChars ?? DEFAULT_MAX_PAGE_TEXT_CHARS;
276
+ const maxCrawlPages = config.maxCrawlPages ?? DEFAULT_MAX_CRAWL_PAGES;
277
+ const maxLinksPerPage = config.maxLinksPerPage ?? DEFAULT_MAX_LINKS_PER_PAGE;
278
+ async function fetchPageInternal(rawUrl, maxChars, ctx) {
279
+ const robots = await checkRobots(rawUrl, ctx);
280
+ const response = await http.get(rawUrl, {
281
+ maxBodyChars: Math.max(maxChars * 4, maxChars),
282
+ headers: [{ name: "user-agent", value: config.userAgent ?? DEFAULT_USER_AGENT }]
283
+ }, ctx);
284
+ const fetchedAt = new Date().toISOString();
285
+ const textInfo = normalizeFetchText(response, maxChars);
286
+ const snippet = firstSnippet(textInfo.text);
287
+ const title = textInfo.title ?? titleFromTextFallback(response.finalUrl);
288
+ const source = sourceFor(rawUrl, response, fetchedAt, title, snippet, robots);
289
+ return {
290
+ source,
291
+ citation: citationFor(source),
292
+ text: textInfo.text,
293
+ textTruncated: textInfo.truncated,
294
+ bodyTruncated: textInfo.bodyTruncated,
295
+ html: textInfo.html,
296
+ links: textInfo.links
297
+ };
298
+ }
299
+ const webSearch = defineTool({
300
+ name: "web_search",
301
+ description: "Search the web through the host's injected search provider and return normalized citations.",
302
+ parameters: WEB_SEARCH_PARAMS,
303
+ async execute(args, ctx) {
304
+ try {
305
+ if (config.searchProvider === undefined) {
306
+ return { ok: false, error: "web_search requires a searchProvider" };
307
+ }
308
+ const maxResults = clamp(args.max_results, maxSearchResults, 1, maxSearchResults);
309
+ const fetchedAt = new Date().toISOString();
310
+ const raw = await config.searchProvider.search({ query: args.query, maxResults }, ctx);
311
+ const results = raw.slice(0, maxResults).map((result) => normalizeSearchResult(result, fetchedAt));
312
+ return {
313
+ ok: true,
314
+ content: {
315
+ query: args.query,
316
+ results,
317
+ truncated: raw.length > results.length
318
+ }
319
+ };
320
+ } catch (error) {
321
+ return fail(error);
322
+ }
323
+ }
324
+ });
325
+ const fetchPage = defineTool({
326
+ name: "fetch_page",
327
+ description: "Fetch one static HTML/text page and return compact text with source metadata and a citation.",
328
+ parameters: URL_PARAMS,
329
+ async execute(args, ctx) {
330
+ try {
331
+ const maxChars = clamp(args.max_body_chars, maxPageTextChars, 1, maxPageTextChars);
332
+ const page = await fetchPageInternal(args.url, maxChars, ctx);
333
+ return {
334
+ ok: true,
335
+ content: {
336
+ source: page.source,
337
+ citation: page.citation,
338
+ text: page.text,
339
+ textTruncated: page.textTruncated
340
+ }
341
+ };
342
+ } catch (error) {
343
+ return fail(error);
344
+ }
345
+ }
346
+ });
347
+ const extractReadableText = defineTool({
348
+ name: "extract_readable_text",
349
+ description: "Fetch one static page and extract readable article text, falling back to page text.",
350
+ parameters: URL_PARAMS,
351
+ async execute(args, ctx) {
352
+ try {
353
+ const maxChars = clamp(args.max_body_chars, maxPageTextChars, 1, maxPageTextChars);
354
+ const page = await fetchPageInternal(args.url, maxChars, ctx);
355
+ let text = page.text;
356
+ let title = page.source.title;
357
+ let textTruncated = page.textTruncated;
358
+ let readable = false;
359
+ let byline;
360
+ let excerpt;
361
+ if (page.html !== undefined) {
362
+ try {
363
+ const article = new Readability(readabilityDocument(page.html), {
364
+ charThreshold: 20
365
+ }).parse();
366
+ const articleText = compactText(article?.textContent ?? "");
367
+ if (articleText !== "") {
368
+ const articleTruncated = articleText.length > maxChars;
369
+ text = articleText.slice(0, maxChars);
370
+ textTruncated = page.bodyTruncated || articleTruncated;
371
+ title = article?.title ?? title;
372
+ byline = article?.byline ?? undefined;
373
+ excerpt = article?.excerpt ?? undefined;
374
+ readable = true;
375
+ }
376
+ } catch {
377
+ readable = false;
378
+ }
379
+ }
380
+ const source = {
381
+ ...page.source,
382
+ ...title !== undefined ? { title } : {},
383
+ ...firstSnippet(text) !== undefined ? { snippet: firstSnippet(text) } : {}
384
+ };
385
+ return {
386
+ ok: true,
387
+ content: {
388
+ source,
389
+ citation: citationFor(source),
390
+ title,
391
+ text,
392
+ textTruncated,
393
+ readable,
394
+ ...byline !== undefined ? { byline } : {},
395
+ ...excerpt !== undefined ? { excerpt } : {}
396
+ }
397
+ };
398
+ } catch (error) {
399
+ return fail(error);
400
+ }
401
+ }
402
+ });
403
+ const crawlLinks = defineTool({
404
+ name: "crawl_links",
405
+ description: "Fetch a bounded set of static pages and return same-host links by default.",
406
+ parameters: CRAWL_PARAMS,
407
+ async execute(args, ctx) {
408
+ try {
409
+ const start = new URL(args.url);
410
+ const depth = clamp(args.depth, 1, 0, 5);
411
+ const maxPages = clamp(args.max_pages, maxCrawlPages, 1, maxCrawlPages);
412
+ const linksPerPage = clamp(args.max_links_per_page, maxLinksPerPage, 1, maxLinksPerPage);
413
+ const requireSameHost = args.same_host ?? true;
414
+ const queue = [{ url: start.href, depth: 0 }];
415
+ const queued = new Set([start.href]);
416
+ const seen = new Set;
417
+ let truncated = false;
418
+ const pages = [];
419
+ const errors = [];
420
+ while (queue.length > 0 && pages.length < maxPages) {
421
+ const next = queue.shift();
422
+ queued.delete(next.url);
423
+ if (seen.has(next.url))
424
+ continue;
425
+ seen.add(next.url);
426
+ if (requireSameHost && !sameHost(next.url, start))
427
+ continue;
428
+ let page;
429
+ try {
430
+ page = await fetchPageInternal(next.url, maxPageTextChars, ctx);
431
+ } catch (error) {
432
+ const message = error instanceof Error ? error.message : String(error);
433
+ if (next.depth === 0)
434
+ throw error;
435
+ errors.push({ url: next.url, error: message });
436
+ continue;
437
+ }
438
+ const eligibleLinks = requireSameHost ? page.links.filter((link) => sameHost(link.url, start)) : page.links;
439
+ const links = eligibleLinks.slice(0, linksPerPage);
440
+ if (eligibleLinks.length > links.length)
441
+ truncated = true;
442
+ pages.push({ source: page.source, citation: page.citation, links });
443
+ if (next.depth < depth) {
444
+ for (const link of links) {
445
+ if (seen.has(link.url))
446
+ continue;
447
+ if (queued.has(link.url))
448
+ continue;
449
+ queue.push({ url: link.url, depth: next.depth + 1 });
450
+ queued.add(link.url);
451
+ }
452
+ }
453
+ }
454
+ return {
455
+ ok: true,
456
+ content: {
457
+ startUrl: start.href,
458
+ pages,
459
+ errors,
460
+ truncated: truncated || queue.length > 0
461
+ }
462
+ };
463
+ } catch (error) {
464
+ return fail(error);
465
+ }
466
+ }
467
+ });
468
+ return { webSearch, fetchPage, extractReadableText, crawlLinks };
469
+ }
470
+ export {
471
+ webTools
472
+ };
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Public types for `@infinityi/engine-lib/tools-web`.
3
+ *
4
+ * Web tools sit above `tools-http`: they fetch static HTML/text, normalize
5
+ * search results from an injected provider, extract readable article text, and
6
+ * crawl bounded same-host links.
7
+ *
8
+ * @module
9
+ */
10
+ import type { EngineContext } from "../runtime/types";
11
+ import type { ToolDefinition } from "../tools/types";
12
+ import type { HttpToolClient, HttpToolsConfig } from "../tools-http";
13
+ /** Robots handling mode for page fetches and crawling. */
14
+ export type RobotsPolicy = "enforce" | "metadata" | "ignore";
15
+ /** Request passed to an injected search provider. */
16
+ export interface SearchRequest {
17
+ readonly query: string;
18
+ readonly maxResults: number;
19
+ }
20
+ /** Search result shape accepted from and returned by web search. */
21
+ export interface SearchResult {
22
+ readonly url: string;
23
+ readonly title?: string;
24
+ readonly snippet?: string;
25
+ readonly source?: SourceMetadata;
26
+ readonly citation?: Citation;
27
+ }
28
+ /** Search provider contract. No built-in paid/vendor provider is bundled. */
29
+ export interface SearchProvider {
30
+ search(request: SearchRequest, ctx?: EngineContext): Promise<readonly SearchResult[]> | readonly SearchResult[];
31
+ }
32
+ /** Compact source metadata carried by every web result. */
33
+ export interface SourceMetadata {
34
+ readonly url: string;
35
+ readonly finalUrl: string;
36
+ readonly title?: string;
37
+ readonly fetchedAt: string;
38
+ readonly contentType?: string;
39
+ readonly status?: number;
40
+ readonly snippet?: string;
41
+ readonly robots?: {
42
+ readonly policy: RobotsPolicy;
43
+ readonly allowed?: boolean;
44
+ readonly reason?: string;
45
+ };
46
+ }
47
+ /** Citation metadata suitable for model-visible attribution. */
48
+ export interface Citation {
49
+ readonly url: string;
50
+ readonly title?: string;
51
+ readonly snippet?: string;
52
+ readonly fetchedAt: string;
53
+ }
54
+ /** Configuration for {@link webTools}. */
55
+ export interface WebToolsConfig extends HttpToolsConfig {
56
+ /** Optional prebuilt HTTP client. If omitted, one is created from this config. */
57
+ readonly httpClient?: HttpToolClient;
58
+ /** Provider used by `web_search`; omitted providers make only that tool fail. */
59
+ readonly searchProvider?: SearchProvider;
60
+ /** Global robots policy. Defaults to `enforce`. */
61
+ readonly robots?: RobotsPolicy;
62
+ /** Per-host robots policy overrides, keyed by lower-case hostname. */
63
+ readonly robotsByHost?: Readonly<Record<string, RobotsPolicy>>;
64
+ /** User-Agent used for robots checks and optional default request headers. */
65
+ readonly userAgent?: string;
66
+ /** Upper bound for `web_search.max_results`. Defaults to 10. */
67
+ readonly maxSearchResults?: number;
68
+ /** Upper bound for returned page text. Defaults to 12_000 characters. */
69
+ readonly maxPageTextChars?: number;
70
+ /** Upper bound for crawl pages. Defaults to 10. */
71
+ readonly maxCrawlPages?: number;
72
+ /** Upper bound for links returned per crawled page. Defaults to 25. */
73
+ readonly maxLinksPerPage?: number;
74
+ }
75
+ /** The ready-made web tool definitions. */
76
+ export interface WebTools {
77
+ readonly webSearch: ToolDefinition;
78
+ readonly fetchPage: ToolDefinition;
79
+ readonly extractReadableText: ToolDefinition;
80
+ readonly crawlLinks: ToolDefinition;
81
+ }
package/docs/README.md CHANGED
@@ -1,19 +1,63 @@
1
1
  # engine-lib documentation
2
2
 
3
- - **Guide & concepts:** [`../README.md`](../README.md) - project goal, design principles, and annotated usage scenarios.
4
- - **Runnable examples:** [`../examples/`](../examples/) - small, offline programs you can run with `bun`.
3
+ Start with the repository [`README.md`](../README.md) for project goals,
4
+ constraints, and the fastest overview. Use these pages when you need runnable
5
+ examples, import-path details, or feature-specific behavior.
5
6
 
6
- ## API reference
7
+ ## Guides
8
+
9
+ | Guide | Covers |
10
+ | --- | --- |
11
+ | [Getting started](./getting-started.md) | installation, quickstart, examples, and API docs |
12
+ | [Providers](./providers.md) | built-in provider factories, capabilities, custom adapters |
13
+ | [Tools and schemas](./tools.md) | `s`, `defineTool`, tool results, error recovery |
14
+ | [Execution](./execution.md) | `runAgent`, streaming, cancellation, run failures |
15
+ | [Sessions and context](./sessions-and-context.md) | durable history, context injection, context windows |
16
+ | [Events and telemetry](./events-and-telemetry.md) | run events, subscribers, telemetry integration |
17
+ | [Multi-agent](./multi-agent.md) | handoffs, registries, and sub-agents as tools |
18
+ | [Optional tool packs](./optional-tool-packs.md) | shell, filesystem, HTTP, and web tool safety |
19
+ | [Testing and lifecycle](./testing-and-lifecycle.md) | test doubles, conformance, Forge lifecycle |
20
+
21
+ ## Examples
22
+
23
+ Runnable examples live in [`../examples/`](../examples/). Most use mock
24
+ providers or fake transports and do not need network credentials.
25
+
26
+ ```bash
27
+ bun run examples
28
+ ```
29
+
30
+ The example set includes:
31
+
32
+ - `examples/incident-analysis.ts` - an offline end-to-end agent with a tool,
33
+ context, session, and events
34
+ - `examples/01-minimal-agent.ts` - smallest buffered run
35
+ - `examples/02-custom-tool.ts` - typed tool parameters and tool results
36
+ - `examples/03-streaming.ts` - streaming events and `completed`
37
+ - `examples/04-sessions-context.ts` - session history and injected context
38
+ - `examples/05-events-subscribers.ts` - subscriber fan-out and failure isolation
39
+ - `examples/06-multi-agent-handoff.ts` - handoff to a specialist
40
+ - `examples/07-sub-agent-tool.ts` - `asTool` delegation
41
+ - `examples/08-testing-agent.ts` - deterministic agent test pattern
42
+ - `examples/09-tools-filesystem.ts` - allowed-root filesystem tools
43
+ - `examples/10-tools-http-web.ts` - HTTP and web tools with fake fetch/search
44
+ - `examples/11-shell-tools.ts` - policy-gated command execution
45
+ - `examples/12-provider-openai.ts` - real OpenAI provider, gated by env
46
+ - `examples/13-lifecycle.ts` - Forge lifecycle component shape
47
+
48
+ ## API Reference
7
49
 
8
50
  The full API reference is generated from source doc-comments with
9
51
  [TypeDoc](https://typedoc.org):
10
52
 
11
53
  ```bash
12
- bun run docs # writes HTML to docs/api/ (git-ignored)
54
+ bun run docs
13
55
  ```
14
56
 
15
- Then open `docs/api/index.html`. Configuration lives in `typedoc.json` in the
16
- source repository; the documented entry points are the public import surfaces:
57
+ Then open `docs/api/index.html`. The output is git-ignored; regenerate it
58
+ locally or publish it from CI.
59
+
60
+ The TypeDoc entry points are aligned with the public package exports:
17
61
 
18
62
  | Import | Module |
19
63
  | --- | --- |
@@ -24,13 +68,17 @@ source repository; the documented entry points are the public import surfaces:
24
68
  | `@infinityi/engine-lib/runtime` | Forge secret and telemetry integration helpers |
25
69
  | `@infinityi/engine-lib/providers` | provider contracts, built-in provider factories, and advanced adapter/HTTP/SSE helpers |
26
70
  | `@infinityi/engine-lib/tools` | tool definitions and tool-result mapping helpers |
71
+ | `@infinityi/engine-lib/tools-shell` | optional policy-gated command execution tools |
72
+ | `@infinityi/engine-lib/tools-fs` | optional allowed-root filesystem and workspace tools |
73
+ | `@infinityi/engine-lib/tools-http` | optional policy-gated HTTP GET/POST tools and client |
74
+ | `@infinityi/engine-lib/tools-web` | optional static web/search tools built on `tools-http` |
27
75
  | `@infinityi/engine-lib/agent` | agent definitions, registries, handoffs, and sub-agent-as-tool helpers |
28
76
  | `@infinityi/engine-lib/execution` | `runAgent` and run result/event types |
29
77
  | `@infinityi/engine-lib/session` | session handles and session store contract |
78
+ | `@infinityi/engine-lib/session-stores` | optional durable session stores for Forge SQL, SQLite, PostgreSQL, Redis, and filesystem JSONL |
30
79
  | `@infinityi/engine-lib/context` | context providers and context-window strategies |
80
+ | `@infinityi/engine-lib/retrieval` | optional RAG primitives: document loaders, chunkers, embeddings, vector stores, retrievers, and retriever context providers |
31
81
  | `@infinityi/engine-lib/events` | event hub, subscribers, event projection helpers, and telemetry bridge |
32
82
  | `@infinityi/engine-lib/lifecycle` | Forge lifecycle adapter (`agentRuntimeComponent`) |
33
- | `@infinityi/engine-lib/testing` | network-free test doubles (`mockProvider`, `scriptedProvider`, `textResult`, `toolCallResult`, `jsonFetch`/`sseFetch`, `inMemorySessionStore`) |
34
- | `@infinityi/engine-lib/testing/conformance` | the provider conformance battery (`runProviderConformance`) |
35
-
36
- The output is intentionally not committed; regenerate it locally or in CI.
83
+ | `@infinityi/engine-lib/testing` | network-free test doubles |
84
+ | `@infinityi/engine-lib/testing/conformance` | provider conformance battery |
@@ -0,0 +1 @@
1
+ TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
@@ -0,0 +1 @@
1
+ window.hierarchyData = "eJydlstO4zAUht/Fa7fEuThxdiOmiBkJDZqOYIFYmOS0tca1K9sMRajvPkrLxUkDcbrpojq/v9/n5rwgo7WzqLwrME1TTGhEcUZzTCKa32NkYCGhckIri8oXVDQ/iq8BlejbEpSbGaMNwuivUDUqSVxg9GgkKlElubVgz6AJsNOP4OnKrSXChwBUImfrSaOeHP7AqFoJWRtQqLxLMkwzzDJMshzHaYrjnOAkSnCSRPc7jJLM83Nt9D9Rgwm11IofcLXDiPqsP1rLUM577DCD+Yx5tYI1v+FS1LwpQCivVzcm6yTOmuSSuHvj8V56VMNZIFnugWdbqB7HMNuCURcvUhyTdH/5IvU8XPHt3MHGzrYVQA11qJVe3XACYtKBX3JV68XiFH6vNMBC6ls456oCKcPBbUEALic+TisHW3crVK2fgpFHomFsEiX+wK1AymstRfUcPGsdSQAyiTzkhZBgn62D9Thur24YntH8aMG80+KMvtGEcmAWvAJ7JlQN29ed8ingPb4zT4TmzTDRVjPN1FIoeC1XEL2lGGsiLyguiv1Gywva2WhjXHjxAR52GBWFv0B/KOvM4/4pHUM9loXBSZSQFv0K1to8z8FaodXcaQNf9dkb/FgVsL+jdpv1Ib9sthDaZy3HUoYJi1LcJAATxhiOSRLhmLD9J0PTk565X5sms1wGzYI9TEFbE1gOGvm9d+nc5jC5A0intbSTlXOb6YdmdFJoRvZ3pxnpmGia2p5rtRDLcU484Wg7OTmUIif+LryFh7FunuBh2pYFVoNF/ka60GYJ37njodNhD3ET2wTaaa8+YE5Yynrfgp9WK3mql89PCXHEfEe/oRb2RB9H2pDPntbbeC61Bf4gYcQC6ZjoPSKsRZp94Zm5AdMcAPXpZnqPCDGz2/0HFTOXRQ=="