@abot-ai/runtime 1.1.0 → 1.2.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 (268) hide show
  1. package/README.md +6 -3
  2. package/dist/src/capabilities/tool-types.d.ts +1 -1
  3. package/dist/src/model-gateway/providers/ollama/generation-options.d.ts +1 -3
  4. package/dist/src/model-gateway/providers/ollama/generation-options.js +1 -5
  5. package/dist/src/model-gateway/providers/ollama/payload.js +0 -8
  6. package/dist/src/model-gateway/server/request-body.js +1 -0
  7. package/dist/src/plugin-sdk/index.d.ts +2 -0
  8. package/dist/src/plugin-sdk/index.js +2 -0
  9. package/dist/src/plugin-sdk/tool-availability-brief.d.ts +9 -0
  10. package/dist/src/plugin-sdk/tool-availability-brief.js +48 -0
  11. package/dist/src/plugin-sdk/tool-availability-overview.d.ts +9 -0
  12. package/dist/src/plugin-sdk/tool-availability-overview.js +62 -0
  13. package/dist/src/runtime/adapters/registered-tool-payload-plan.d.ts +0 -9
  14. package/dist/src/runtime/adapters/registered-tool-payload-plan.js +0 -67
  15. package/dist/src/runtime/adapters/registered-tool-payload-related-artifacts.d.ts +13 -0
  16. package/dist/src/runtime/adapters/registered-tool-payload-related-artifacts.js +84 -0
  17. package/dist/src/runtime/adapters/registered-tool-worker-capabilities/catalog.js +4 -0
  18. package/dist/src/runtime/adapters/registered-tool-worker-capabilities/execution.js +3 -0
  19. package/dist/src/runtime/adapters/registered-tool-worker-capabilities/payload-lifecycle.d.ts +1 -0
  20. package/dist/src/runtime/adapters/registered-tool-worker-capabilities/payload-lifecycle.js +11 -1
  21. package/dist/src/runtime/adapters/registered-tool-worker-capabilities/payload-stages.d.ts +1 -0
  22. package/dist/src/runtime/adapters/registered-tool-worker-capabilities/payload-stages.js +9 -1
  23. package/dist/src/runtime/capabilities/request-bound-tool-registry.js +1 -24
  24. package/dist/src/runtime/capabilities/tool-availability.d.ts +6 -0
  25. package/dist/src/runtime/capabilities/tool-availability.js +28 -0
  26. package/dist/src/runtime/context/capability-brief.d.ts +25 -0
  27. package/dist/src/runtime/context/capability-brief.js +106 -0
  28. package/dist/src/runtime/context/request-tool-results-message-binding.d.ts +6 -0
  29. package/dist/src/runtime/context/request-tool-results-message-binding.js +30 -0
  30. package/dist/src/runtime/context/request-tool-results-scope.d.ts +3 -0
  31. package/dist/src/runtime/context/request-tool-results-scope.js +8 -0
  32. package/dist/src/runtime/context/request-tool-results.d.ts +8 -4
  33. package/dist/src/runtime/context/request-tool-results.js +49 -38
  34. package/dist/src/runtime/orchestration/role-calls/candidate-validation.js +8 -1
  35. package/dist/src/runtime/orchestration/role-calls/child-return.d.ts +4 -0
  36. package/dist/src/runtime/orchestration/role-calls/child-return.js +25 -5
  37. package/dist/src/runtime/orchestration/role-calls/command-decoder.js +8 -3
  38. package/dist/src/runtime/orchestration/role-calls/command-dispatch/child-transitions.d.ts +1 -1
  39. package/dist/src/runtime/orchestration/role-calls/command-dispatch/child-transitions.js +17 -2
  40. package/dist/src/runtime/orchestration/role-calls/command-dispatch.d.ts +1 -1
  41. package/dist/src/runtime/orchestration/role-calls/command-dispatch.js +2 -2
  42. package/dist/src/runtime/orchestration/role-calls/contracts.d.ts +5 -2
  43. package/dist/src/runtime/orchestration/role-calls/contracts.js +4 -4
  44. package/dist/src/runtime/orchestration/role-calls/dependency-results.d.ts +1 -1
  45. package/dist/src/runtime/orchestration/role-calls/dependency-results.js +1 -0
  46. package/dist/src/runtime/orchestration/role-calls/index.d.ts +5 -1
  47. package/dist/src/runtime/orchestration/role-calls/index.js +5 -1
  48. package/dist/src/runtime/orchestration/role-calls/ledger.d.ts +3 -1
  49. package/dist/src/runtime/orchestration/role-calls/ledger.js +9 -2
  50. package/dist/src/runtime/orchestration/role-calls/reducer.d.ts +1 -1
  51. package/dist/src/runtime/orchestration/role-calls/reducer.js +2 -2
  52. package/dist/src/runtime/orchestration/role-calls/result-receipt.d.ts +49 -0
  53. package/dist/src/runtime/orchestration/role-calls/result-receipt.js +188 -0
  54. package/dist/src/runtime/orchestration/role-calls/return-result-receipt.d.ts +19 -0
  55. package/dist/src/runtime/orchestration/role-calls/return-result-receipt.js +52 -0
  56. package/dist/src/runtime/orchestration/role-calls/transactions.js +1 -0
  57. package/dist/src/runtime/orchestration/role-calls/work-result-lineage.d.ts +34 -0
  58. package/dist/src/runtime/orchestration/role-calls/work-result-lineage.js +185 -0
  59. package/dist/src/runtime/orchestration/role-calls/work-result-receipt.d.ts +36 -0
  60. package/dist/src/runtime/orchestration/role-calls/work-result-receipt.js +187 -0
  61. package/dist/src/runtime/orchestration/role-executors/activation/result-normalization.js +6 -3
  62. package/dist/src/runtime/orchestration/role-executors/child-invocation/transaction.js +1 -0
  63. package/dist/src/runtime/orchestration/role-executors/contracts.d.ts +2 -1
  64. package/dist/src/runtime/orchestration/worker-capabilities/assignment-provenance.d.ts +36 -0
  65. package/dist/src/runtime/orchestration/worker-capabilities/assignment-provenance.js +171 -0
  66. package/dist/src/runtime/orchestration/worker-capabilities/contracts.d.ts +32 -1
  67. package/dist/src/runtime/orchestration/worker-capabilities/execution/invocation-preparation.d.ts +2 -1
  68. package/dist/src/runtime/orchestration/worker-capabilities/execution/invocation-preparation.js +3 -0
  69. package/dist/src/runtime/orchestration/worker-capabilities/execution.js +42 -19
  70. package/dist/src/runtime/orchestration/worker-capabilities/index.d.ts +2 -0
  71. package/dist/src/runtime/orchestration/worker-capabilities/index.js +2 -0
  72. package/dist/src/runtime/orchestration/worker-capabilities/payload-assignment-validation.d.ts +3 -0
  73. package/dist/src/runtime/orchestration/worker-capabilities/payload-assignment-validation.js +30 -0
  74. package/dist/src/runtime/orchestration/worker-capabilities/payload-author.js +8 -19
  75. package/dist/src/runtime/orchestration/worker-capabilities/payload-contracts.d.ts +5 -1
  76. package/dist/src/runtime/orchestration/worker-capabilities/payload-instructions.js +1 -1
  77. package/dist/src/runtime/orchestration/worker-capabilities/payload-source-provenance.d.ts +14 -0
  78. package/dist/src/runtime/orchestration/worker-capabilities/payload-source-provenance.js +132 -0
  79. package/dist/src/runtime/request/capability-brief.d.ts +5 -0
  80. package/dist/src/runtime/request/capability-brief.js +24 -0
  81. package/dist/src/runtime/request/execution-scope.d.ts +2 -1
  82. package/dist/src/runtime/request/role-executor-composition.js +1 -1
  83. package/dist/src/runtime/request/worker-capability-composition.d.ts +2 -1
  84. package/dist/src/runtime/request/worker-capability-composition.js +6 -1
  85. package/dist/src/runtime/request/worker-capability-payload.js +11 -8
  86. package/dist/src/runtime/steps/execution-agent/prompt.js +4 -3
  87. package/dist/src/runtime/steps/planner-decision/capability-catalog-context.d.ts +14 -0
  88. package/dist/src/runtime/steps/planner-decision/capability-catalog-context.js +87 -0
  89. package/dist/src/runtime/steps/planner-decision/contracts.d.ts +3 -5
  90. package/dist/src/runtime/steps/planner-decision/contracts.js +3 -3
  91. package/dist/src/runtime/steps/planner-decision/format.d.ts +3 -2
  92. package/dist/src/runtime/steps/planner-decision/format.js +73 -76
  93. package/dist/src/runtime/steps/planner-decision/input.d.ts +4 -3
  94. package/dist/src/runtime/steps/planner-decision/input.js +10 -7
  95. package/dist/src/runtime/steps/planner-decision/parser.d.ts +3 -2
  96. package/dist/src/runtime/steps/planner-decision/parser.js +10 -19
  97. package/dist/src/runtime/steps/planner-decision/plan-parser.js +18 -12
  98. package/dist/src/runtime/steps/planner-decision/prompt.js +33 -28
  99. package/dist/src/runtime/steps/planner-decision/resume.d.ts +1 -1
  100. package/dist/src/runtime/steps/planner-decision/resume.js +38 -1
  101. package/dist/src/runtime/steps/planner-decision/run.d.ts +3 -2
  102. package/dist/src/runtime/steps/reviewer-decision/audit-coverage.d.ts +10 -0
  103. package/dist/src/runtime/steps/reviewer-decision/audit-coverage.js +186 -0
  104. package/dist/src/runtime/steps/reviewer-decision/contracts.d.ts +3 -8
  105. package/dist/src/runtime/steps/reviewer-decision/contracts.js +12 -6
  106. package/dist/src/runtime/steps/reviewer-decision/delegated-context.d.ts +24 -0
  107. package/dist/src/runtime/steps/reviewer-decision/delegated-context.js +70 -0
  108. package/dist/src/runtime/steps/reviewer-decision/diagnostics.js +1 -1
  109. package/dist/src/runtime/steps/reviewer-decision/format.js +37 -24
  110. package/dist/src/runtime/steps/reviewer-decision/input.js +1 -1
  111. package/dist/src/runtime/steps/reviewer-decision/model-context.d.ts +4 -3
  112. package/dist/src/runtime/steps/reviewer-decision/model-context.js +92 -10
  113. package/dist/src/runtime/steps/reviewer-decision/parser.js +19 -1
  114. package/dist/src/runtime/steps/reviewer-decision/projection.js +42 -68
  115. package/dist/src/runtime/steps/reviewer-decision/prompt.js +10 -5
  116. package/dist/src/runtime/steps/reviewer-decision/run.js +12 -3
  117. package/dist/src/runtime/steps/reviewer-decision/verification-coverage.d.ts +14 -0
  118. package/dist/src/runtime/steps/reviewer-decision/verification-coverage.js +52 -0
  119. package/dist/src/runtime/steps/supervisor-decision/capability-brief.d.ts +14 -0
  120. package/dist/src/runtime/steps/supervisor-decision/capability-brief.js +38 -0
  121. package/dist/src/runtime/steps/supervisor-decision/contracts.d.ts +7 -3
  122. package/dist/src/runtime/steps/supervisor-decision/diagnostics.d.ts +2 -0
  123. package/dist/src/runtime/steps/supervisor-decision/diagnostics.js +8 -2
  124. package/dist/src/runtime/steps/supervisor-decision/format.js +32 -20
  125. package/dist/src/runtime/steps/supervisor-decision/input.d.ts +4 -1
  126. package/dist/src/runtime/steps/supervisor-decision/input.js +19 -1
  127. package/dist/src/runtime/steps/supervisor-decision/parser.js +62 -59
  128. package/dist/src/runtime/steps/supervisor-decision/prompt.js +6 -7
  129. package/dist/src/runtime/steps/supervisor-decision/resume.js +47 -1
  130. package/dist/src/runtime/steps/supervisor-decision/run.js +10 -0
  131. package/dist/src/runtime/steps/supervisor-decision/working-directory.js +2 -1
  132. package/dist/src/runtime/steps/worker-decision/contracts.d.ts +2 -1
  133. package/dist/src/runtime/steps/worker-decision/input/canonical-state.js +8 -1
  134. package/dist/src/runtime/steps/worker-decision/input/diagnostic-projection.js +2 -2
  135. package/dist/src/runtime/steps/worker-decision/input/prompt-context.d.ts +1 -0
  136. package/dist/src/runtime/steps/worker-decision/input/prompt-context.js +4 -1
  137. package/dist/src/runtime/steps/worker-decision/input/reference-context.js +34 -14
  138. package/dist/src/runtime/steps/worker-decision/input/types.d.ts +2 -1
  139. package/dist/src/runtime/steps/worker-decision/input.d.ts +1 -0
  140. package/dist/src/runtime/steps/worker-decision/input.js +1 -0
  141. package/dist/src/runtime/steps/worker-decision/payload-dependency-results.d.ts +8 -0
  142. package/dist/src/runtime/steps/worker-decision/payload-dependency-results.js +19 -0
  143. package/dist/src/runtime/steps/worker-decision/prompt.js +8 -8
  144. package/dist/src/runtime/steps/worker-decision/result-author.js +18 -11
  145. package/dist/src/runtime/steps/worker-decision/run.js +2 -2
  146. package/dist/src/web-ui/app/ARCHITECTURE.md +19 -6
  147. package/dist/src/web-ui/app/app.js +6 -7
  148. package/dist/src/web-ui/app/components/composer-context-window.d.ts +25 -0
  149. package/dist/src/web-ui/app/components/composer-context-window.js +155 -0
  150. package/dist/src/web-ui/app/components/composer-plan.d.ts +9 -0
  151. package/dist/src/web-ui/app/components/composer-plan.js +128 -0
  152. package/dist/src/web-ui/app/components/conversation-activity.d.ts +5 -6
  153. package/dist/src/web-ui/app/components/conversation-activity.js +64 -157
  154. package/dist/src/web-ui/app/components/conversation-role-cards.d.ts +23 -0
  155. package/dist/src/web-ui/app/components/conversation-role-cards.js +181 -0
  156. package/dist/src/web-ui/app/components/conversation-sidebar-layout.js +12 -0
  157. package/dist/src/web-ui/app/components/conversation-sources.d.ts +7 -0
  158. package/dist/src/web-ui/app/components/conversation-sources.js +182 -0
  159. package/dist/src/web-ui/app/components/conversation-view.js +34 -6
  160. package/dist/src/web-ui/app/components/model-selector.js +4 -1
  161. package/dist/src/web-ui/app/components/operations-section.js +46 -0
  162. package/dist/src/web-ui/app/components/workspace-shell.js +86 -78
  163. package/dist/src/web-ui/app/controllers/realtime-event-controller.d.ts +1 -0
  164. package/dist/src/web-ui/app/controllers/realtime-event-controller.js +55 -90
  165. package/dist/src/web-ui/app/controllers/runtime-selection-controller.js +2 -0
  166. package/dist/src/web-ui/app/controllers/session-controller.js +17 -12
  167. package/dist/src/web-ui/app/index.html +209 -210
  168. package/dist/src/web-ui/app/lib/composer-plan-model.d.ts +32 -0
  169. package/dist/src/web-ui/app/lib/composer-plan-model.js +108 -0
  170. package/dist/src/web-ui/app/lib/conversation-role-model.d.ts +19 -0
  171. package/dist/src/web-ui/app/lib/conversation-role-model.js +193 -0
  172. package/dist/src/web-ui/app/lib/event-presentation.js +30 -9
  173. package/dist/src/web-ui/app/lib/source-url-policy.d.ts +2 -0
  174. package/dist/src/web-ui/app/lib/source-url-policy.js +31 -0
  175. package/dist/src/web-ui/app/lib/task-progress.d.ts +53 -0
  176. package/dist/src/web-ui/app/lib/task-progress.js +233 -0
  177. package/dist/src/web-ui/app/lib/tool-invocation-count.d.ts +5 -0
  178. package/dist/src/web-ui/app/lib/tool-invocation-count.js +21 -0
  179. package/dist/src/web-ui/app/lib/web-source-event.d.ts +8 -0
  180. package/dist/src/web-ui/app/lib/web-source-event.js +21 -0
  181. package/dist/src/web-ui/app/lib/web-sources.d.ts +36 -0
  182. package/dist/src/web-ui/app/lib/web-sources.js +177 -0
  183. package/dist/src/web-ui/app/styles/00-tokens-base.css +15 -3
  184. package/dist/src/web-ui/app/styles/10-shell-sessions.css +24 -34
  185. package/dist/src/web-ui/app/styles/12-conversation-sidebar.css +93 -0
  186. package/dist/src/web-ui/app/styles/20-chat-composer.css +55 -472
  187. package/dist/src/web-ui/app/styles/21-composer-controls.css +368 -0
  188. package/dist/src/web-ui/app/styles/22-composer-context-window.css +90 -0
  189. package/dist/src/web-ui/app/styles/23-composer-plan.css +171 -0
  190. package/dist/src/web-ui/app/styles/24-conversation-role-cards.css +205 -0
  191. package/dist/src/web-ui/app/styles/25-conversation-sources.css +141 -0
  192. package/dist/src/web-ui/app/styles/30-inspector-config.css +21 -209
  193. package/dist/src/web-ui/app/styles/35-memory-onboarding.css +8 -8
  194. package/dist/src/web-ui/app/styles/36-memory-management.css +13 -13
  195. package/dist/src/web-ui/app/styles/37-config-operations.css +197 -0
  196. package/dist/src/web-ui/app/styles/40-config-workspace.css +36 -36
  197. package/dist/src/web-ui/app/styles/90-responsive.css +14 -77
  198. package/dist/src/web-ui/app/styles/foundation.css +2 -2
  199. package/dist/src/web-ui/app/styles.css +7 -0
  200. package/dist/src/web-ui/app/ui-behavior.d.ts +1 -1
  201. package/dist/src/web-ui/app/ui-behavior.js +1 -1
  202. package/docs/configuration.md +15 -8
  203. package/docs/installation.md +7 -4
  204. package/docs/known-limitations.md +21 -0
  205. package/docs/plugins.md +28 -13
  206. package/docs/runtime-invariant-coverage.md +18 -17
  207. package/docs/runtime-prompt-policy-contracts.md +27 -17
  208. package/package.json +4 -3
  209. package/plugins/capability-brief/source/index.ts +5 -48
  210. package/plugins/capability-brief/src/index.cjs +46 -33
  211. package/plugins/system-probe/plugin.json +1 -0
  212. package/plugins/web/README.md +125 -0
  213. package/plugins/web/plugin.json +1 -1
  214. package/plugins/web/skills/web_fetch_skill/SKILL.md +2 -2
  215. package/plugins/web/skills/web_search_skill/SKILL.md +8 -4
  216. package/plugins/web/source/errors.ts +5 -1
  217. package/plugins/web/source/fetch-presentation.ts +61 -0
  218. package/plugins/web/source/fetch-service.ts +2 -31
  219. package/plugins/web/source/light/config.ts +196 -0
  220. package/plugins/web/source/light/crawl/origin-gate.ts +134 -0
  221. package/plugins/web/source/light/crawl/robots-cache.ts +71 -0
  222. package/plugins/web/source/light/crawl/robots-parser.ts +132 -0
  223. package/plugins/web/source/light/crawl/robots-policy.ts +154 -0
  224. package/plugins/web/source/light/crawl/session-budget.ts +141 -0
  225. package/plugins/web/source/light/crawl/transport.ts +216 -0
  226. package/plugins/web/source/light/discovery/candidate-values.ts +63 -0
  227. package/plugins/web/source/light/discovery/feed-document.ts +127 -0
  228. package/plugins/web/source/light/discovery/html-links.ts +80 -0
  229. package/plugins/web/source/light/discovery/html-robots-directives.ts +29 -0
  230. package/plugins/web/source/light/discovery/markup-tree.ts +145 -0
  231. package/plugins/web/source/light/discovery/origin-dates.ts +71 -0
  232. package/plugins/web/source/light/discovery/sitemap-document.ts +63 -0
  233. package/plugins/web/source/light/documents/cache-policy.ts +28 -0
  234. package/plugins/web/source/light/documents/document-cache.ts +99 -0
  235. package/plugins/web/source/light/documents/document-charset.ts +89 -0
  236. package/plugins/web/source/light/documents/document-contract.ts +20 -0
  237. package/plugins/web/source/light/documents/document-reader.ts +75 -0
  238. package/plugins/web/source/light/documents/extract-document.ts +124 -0
  239. package/plugins/web/source/light/documents/http-cache-freshness.ts +68 -0
  240. package/plugins/web/source/light/documents/response-decoding.ts +120 -0
  241. package/plugins/web/source/light/ranking/document-ranking.ts +114 -0
  242. package/plugins/web/source/light/ranking/query-normalization.ts +69 -0
  243. package/plugins/web/source/light/search-collection.ts +136 -0
  244. package/plugins/web/source/light/search-frontier.ts +246 -0
  245. package/plugins/web/source/light/search-metadata.ts +84 -0
  246. package/plugins/web/source/light/search-service.ts +154 -0
  247. package/plugins/web/source/light/search-unavailable.ts +33 -0
  248. package/plugins/web/source/light/sources/catalog.ts +312 -0
  249. package/plugins/web/source/light/sources/source-definition.ts +9 -0
  250. package/plugins/web/source/light/sources/source-selection.ts +35 -0
  251. package/plugins/web/source/plugin.ts +70 -56
  252. package/plugins/web/source/public-http.ts +10 -1
  253. package/plugins/web/source/search-presentation.ts +63 -63
  254. package/plugins/web/source/search-service-selector.ts +31 -0
  255. package/plugins/web/source/search-service.ts +6 -0
  256. package/plugins/web/source/search-source-presentation.ts +76 -0
  257. package/plugins/web/source/search-types.ts +4 -0
  258. package/plugins/web/source/source-output-receipts.ts +267 -0
  259. package/plugins/web/source/source-receipt-budget.ts +51 -0
  260. package/plugins/web/source/source-receipt-contract.ts +18 -0
  261. package/plugins/web/src/index.cjs +3214 -288
  262. package/src/runtime/README.md +30 -9
  263. package/dist/src/model-gateway/structured-output/budget.d.ts +0 -7
  264. package/dist/src/model-gateway/structured-output/budget.js +0 -20
  265. package/dist/src/model-gateway/structured-output/schema-character-estimator.d.ts +0 -1
  266. package/dist/src/model-gateway/structured-output/schema-character-estimator.js +0 -211
  267. package/dist/src/model-gateway/structured-output-budget.d.ts +0 -1
  268. package/dist/src/model-gateway/structured-output-budget.js +0 -1
@@ -0,0 +1,312 @@
1
+ import type { LightSource } from "./source-definition.js";
2
+
3
+ export const LIGHT_SOURCE_SET_ID = "abot-light-public-sources";
4
+ export const LIGHT_SOURCE_SET_VERSION = 1;
5
+
6
+ // Explicit origin pages and publisher feeds. This is a bounded source catalog,
7
+ // not an Internet index or a promise that every source is currently reachable.
8
+ export const DEFAULT_LIGHT_SOURCES: readonly LightSource[] = Object.freeze(
9
+ [
10
+ {
11
+ id: "israel-government",
12
+ title: "Israel Government",
13
+ description:
14
+ "Official Israeli government and Prime Minister's Office publications.",
15
+ keywords: [
16
+ "government",
17
+ "israel",
18
+ "prime minister",
19
+ "ממשלה",
20
+ "ראש ממשלה",
21
+ "ישראל",
22
+ ],
23
+ languages: ["he", "en"],
24
+ entryUrls: [
25
+ "https://www.gov.il/he/departments/prime_ministers_office",
26
+ "https://www.gov.il/en/departments/prime_ministers_office",
27
+ ],
28
+ allowedOrigins: ["https://www.gov.il"],
29
+ },
30
+ {
31
+ id: "uk-government",
32
+ title: "UK Government",
33
+ description:
34
+ "Official UK government leadership and public announcements.",
35
+ keywords: [
36
+ "government",
37
+ "uk",
38
+ "britain",
39
+ "prime minister",
40
+ "politics",
41
+ "ממשלה",
42
+ "בריטניה",
43
+ ],
44
+ languages: ["en"],
45
+ entryUrls: [
46
+ "https://www.gov.uk/government/ministers/prime-minister",
47
+ "https://www.gov.uk/government/organisations/prime-ministers-office-10-downing-street",
48
+ ],
49
+ allowedOrigins: ["https://www.gov.uk"],
50
+ },
51
+ {
52
+ id: "wikipedia-en",
53
+ title: "Wikipedia English",
54
+ description: "General reference articles and current events in English.",
55
+ keywords: [
56
+ "reference",
57
+ "encyclopedia",
58
+ "government",
59
+ "history",
60
+ "science",
61
+ "israel",
62
+ "prime minister",
63
+ "ויקיפדיה",
64
+ "ידע",
65
+ ],
66
+ languages: ["en"],
67
+ entryUrls: [
68
+ "https://en.wikipedia.org/wiki/Portal:Current_events",
69
+ "https://en.wikipedia.org/wiki/Prime_Minister_of_Israel",
70
+ ],
71
+ allowedOrigins: ["https://en.wikipedia.org"],
72
+ },
73
+ {
74
+ id: "wikipedia-he",
75
+ title: "Wikipedia Hebrew",
76
+ description: "General reference articles in Hebrew.",
77
+ keywords: [
78
+ "reference",
79
+ "encyclopedia",
80
+ "israel",
81
+ "ויקיפדיה",
82
+ "ידע",
83
+ "ישראל",
84
+ "ראש ממשלה",
85
+ "היסטוריה",
86
+ "מדע",
87
+ ],
88
+ languages: ["he"],
89
+ entryUrls: [
90
+ "https://he.wikipedia.org/wiki/ראש_ממשלת_ישראל",
91
+ "https://he.wikipedia.org/wiki/ישראל",
92
+ ],
93
+ allowedOrigins: ["https://he.wikipedia.org"],
94
+ },
95
+ {
96
+ id: "openai",
97
+ title: "OpenAI",
98
+ description: "OpenAI product, AI research, and company publications.",
99
+ keywords: [
100
+ "openai",
101
+ "gpt",
102
+ "chatgpt",
103
+ "ai",
104
+ "artificial intelligence",
105
+ "בינה מלאכותית",
106
+ "מודלים",
107
+ ],
108
+ languages: ["en"],
109
+ entryUrls: [
110
+ "https://openai.com/news/rss.xml",
111
+ "https://openai.com/news/",
112
+ ],
113
+ allowedOrigins: ["https://openai.com"],
114
+ },
115
+ {
116
+ id: "nodejs",
117
+ title: "Node.js",
118
+ description:
119
+ "Official Node.js releases, runtime news, and project announcements.",
120
+ keywords: [
121
+ "node",
122
+ "nodejs",
123
+ "node.js",
124
+ "javascript",
125
+ "runtime",
126
+ "release",
127
+ "software",
128
+ "תוכנה",
129
+ "פיתוח",
130
+ ],
131
+ languages: ["en"],
132
+ entryUrls: [
133
+ "https://nodejs.org/en/feed/blog.xml",
134
+ "https://nodejs.org/en/blog",
135
+ ],
136
+ allowedOrigins: ["https://nodejs.org"],
137
+ },
138
+ {
139
+ id: "nasa",
140
+ title: "NASA",
141
+ description: "Space missions, astronomy, and science news from NASA.",
142
+ keywords: [
143
+ "nasa",
144
+ "space",
145
+ "science",
146
+ "astronomy",
147
+ "research",
148
+ "חלל",
149
+ "מדע",
150
+ ],
151
+ languages: ["en"],
152
+ entryUrls: [
153
+ "https://www.nasa.gov/feed/",
154
+ "https://www.nasa.gov/news/all-news/",
155
+ ],
156
+ allowedOrigins: ["https://www.nasa.gov", "https://science.nasa.gov"],
157
+ },
158
+ {
159
+ id: "bbc-world",
160
+ title: "BBC World",
161
+ description: "International news from BBC News.",
162
+ keywords: [
163
+ "world",
164
+ "international",
165
+ "news",
166
+ "politics",
167
+ "government",
168
+ "חדשות",
169
+ "עולם",
170
+ "ממשלה",
171
+ ],
172
+ languages: ["en"],
173
+ entryUrls: ["https://feeds.bbci.co.uk/news/world/rss.xml"],
174
+ allowedOrigins: [
175
+ "https://feeds.bbci.co.uk",
176
+ "https://www.bbc.com",
177
+ "https://www.bbc.co.uk",
178
+ "https://bbc.com",
179
+ ],
180
+ },
181
+ {
182
+ id: "guardian-world",
183
+ title: "The Guardian World",
184
+ description: "International affairs and world news.",
185
+ keywords: ["world", "international", "news", "politics", "חדשות", "עולם"],
186
+ languages: ["en"],
187
+ entryUrls: ["https://www.theguardian.com/world/rss"],
188
+ allowedOrigins: ["https://www.theguardian.com"],
189
+ },
190
+ {
191
+ id: "cbc-world",
192
+ title: "CBC World",
193
+ description: "World news and international reporting.",
194
+ keywords: ["world", "international", "news", "canada", "חדשות", "עולם"],
195
+ languages: ["en"],
196
+ entryUrls: ["https://www.cbc.ca/webfeed/rss/rss-world"],
197
+ allowedOrigins: ["https://www.cbc.ca"],
198
+ },
199
+ {
200
+ id: "geektime",
201
+ title: "Geektime",
202
+ description:
203
+ "Technology, startups, software, and AI reporting in Hebrew.",
204
+ keywords: [
205
+ "technology",
206
+ "ai",
207
+ "gpt",
208
+ "software",
209
+ "startups",
210
+ "טכנולוגיה",
211
+ "בינה מלאכותית",
212
+ "כתבות",
213
+ "תוכנה",
214
+ ],
215
+ languages: ["he"],
216
+ entryUrls: ["https://www.geektime.co.il/feed/"],
217
+ allowedOrigins: ["https://www.geektime.co.il"],
218
+ },
219
+ {
220
+ id: "techcrunch",
221
+ title: "TechCrunch",
222
+ description: "Technology companies, startups, and AI news.",
223
+ keywords: [
224
+ "technology",
225
+ "ai",
226
+ "gpt",
227
+ "software",
228
+ "startups",
229
+ "טכנולוגיה",
230
+ "בינה מלאכותית",
231
+ "כתבות",
232
+ ],
233
+ languages: ["en"],
234
+ entryUrls: ["https://techcrunch.com/feed/"],
235
+ allowedOrigins: ["https://techcrunch.com"],
236
+ },
237
+ {
238
+ id: "ynet",
239
+ title: "Ynet",
240
+ description: "Israeli general news headlines in Hebrew.",
241
+ keywords: [
242
+ "israel",
243
+ "news",
244
+ "politics",
245
+ "ישראל",
246
+ "חדשות",
247
+ "ממשלה",
248
+ "ראש ממשלה",
249
+ ],
250
+ languages: ["he"],
251
+ entryUrls: ["https://www.ynet.co.il/Integration/StoryRss2.xml"],
252
+ allowedOrigins: ["https://www.ynet.co.il"],
253
+ },
254
+ {
255
+ id: "walla",
256
+ title: "Walla News",
257
+ description: "Israeli current affairs and general news in Hebrew.",
258
+ keywords: ["israel", "news", "politics", "ישראל", "חדשות", "ממשלה"],
259
+ languages: ["he"],
260
+ entryUrls: ["https://rss.walla.co.il/feed/1"],
261
+ allowedOrigins: [
262
+ "https://rss.walla.co.il",
263
+ "https://news.walla.co.il",
264
+ "https://www.walla.co.il",
265
+ ],
266
+ },
267
+ {
268
+ id: "times-of-israel",
269
+ title: "The Times of Israel",
270
+ description: "Israeli and regional news in English.",
271
+ keywords: [
272
+ "israel",
273
+ "news",
274
+ "politics",
275
+ "government",
276
+ "prime minister",
277
+ "ישראל",
278
+ "חדשות",
279
+ "ראש ממשלה",
280
+ ],
281
+ languages: ["en"],
282
+ entryUrls: ["https://www.timesofisrael.com/feed/"],
283
+ allowedOrigins: ["https://www.timesofisrael.com"],
284
+ },
285
+ {
286
+ id: "nature",
287
+ title: "Nature",
288
+ description: "Science news and research publications.",
289
+ keywords: [
290
+ "science",
291
+ "research",
292
+ "nature",
293
+ "ai",
294
+ "biology",
295
+ "physics",
296
+ "מדע",
297
+ "מחקר",
298
+ ],
299
+ languages: ["en"],
300
+ entryUrls: ["https://www.nature.com/nature.rss"],
301
+ allowedOrigins: ["https://www.nature.com"],
302
+ },
303
+ ].map((source) =>
304
+ Object.freeze({
305
+ ...source,
306
+ keywords: Object.freeze(source.keywords),
307
+ languages: Object.freeze(source.languages),
308
+ entryUrls: Object.freeze(source.entryUrls),
309
+ allowedOrigins: Object.freeze(source.allowedOrigins),
310
+ }),
311
+ ),
312
+ );
@@ -0,0 +1,9 @@
1
+ export type LightSource = Readonly<{
2
+ id: string;
3
+ title: string;
4
+ description: string;
5
+ keywords: readonly string[];
6
+ languages: readonly string[];
7
+ entryUrls: readonly string[];
8
+ allowedOrigins: readonly string[];
9
+ }>;
@@ -0,0 +1,35 @@
1
+ import { countTermMatches } from "../ranking/query-normalization.js";
2
+ import type { LightSource } from "./source-definition.js";
3
+
4
+ export function selectLightSources(
5
+ queries: readonly string[],
6
+ sources: readonly LightSource[],
7
+ limit: number,
8
+ ): readonly LightSource[] {
9
+ const rankings = queries.map((query) => {
10
+ const ranked = sources
11
+ .map((source, index) => ({
12
+ source,
13
+ index,
14
+ score: countTermMatches(
15
+ query,
16
+ `${source.title} ${source.description} ${source.keywords.join(" ")}`,
17
+ ),
18
+ }))
19
+ .sort(
20
+ (left, right) => right.score - left.score || left.index - right.index,
21
+ );
22
+ const matching = ranked.filter(({ score }) => score > 0);
23
+ if (matching.length > 0) return matching;
24
+ return ranked;
25
+ });
26
+ const selected = new Map<string, LightSource>();
27
+ for (let rank = 0; rank < sources.length; rank += 1) {
28
+ for (const ranking of rankings) {
29
+ if (selected.size >= limit) return Object.freeze([...selected.values()]);
30
+ const item = ranking[rank];
31
+ if (item) selected.set(item.source.id, item.source);
32
+ }
33
+ }
34
+ return Object.freeze([...selected.values()]);
35
+ }
@@ -2,13 +2,13 @@ import {
2
2
  failureFromError,
3
3
  failureResult,
4
4
  readBoundedInteger,
5
- successResult,
6
5
  type RuntimePluginEntrypoint,
7
6
  type RuntimePluginLoadContext,
8
7
  } from "../../../src/plugin-sdk/index.js";
9
8
 
10
9
  import { isWebPluginError } from "./errors.js";
11
- import { createWebFetchService, formatFetchedPages } from "./fetch-service.js";
10
+ import { createWebFetchService } from "./fetch-service.js";
11
+ import { buildFetchPresentation } from "./fetch-presentation.js";
12
12
  import { WEB_LIMITS } from "./limits.js";
13
13
  import {
14
14
  parseFetchParams,
@@ -20,13 +20,18 @@ import {
20
20
  createPublicHttpClient,
21
21
  type PublicHttpClient,
22
22
  } from "./public-http.js";
23
- import { createBraveSearchService } from "./search-service.js";
23
+ import { selectWebSearchService } from "./search-service-selector.js";
24
+ import { projectLightSearchEventMeta } from "./light/search-metadata.js";
25
+ import { lightSearchFailureResult } from "./light/search-unavailable.js";
26
+ import { successWithSourceReceipts } from "./source-receipt-budget.js";
24
27
 
25
28
  export type WebPluginDependencies = Readonly<{
26
29
  httpClient?: PublicHttpClient;
27
30
  }>;
28
31
 
29
32
  function failure(error: unknown, operation: string) {
33
+ const lightFailure = lightSearchFailureResult(error);
34
+ if (lightFailure) return lightFailure;
30
35
  if (isWebPluginError(error)) {
31
36
  return failureResult({
32
37
  errorCode: error.code,
@@ -54,11 +59,12 @@ export function createWebPlugin(
54
59
  maximum: 10_000,
55
60
  defaultValue: WEB_LIMITS.retryBaseMs,
56
61
  });
57
- const searchService = createBraveSearchService({
62
+ const searchService = selectWebSearchService({
58
63
  apiKey: braveApiKey,
59
64
  retryBaseMs,
60
65
  httpClient,
61
66
  fetchService,
67
+ lightConfig: context.config?.light,
62
68
  });
63
69
 
64
70
  const handlers: RuntimePluginEntrypoint["handlers"] = {
@@ -69,25 +75,29 @@ export function createWebPlugin(
69
75
  urls,
70
76
  executionContext?.abortSignal,
71
77
  );
72
- return successResult({
73
- output: formatFetchedPages(pages),
74
- progress: true,
75
- producedNewInformation: true,
76
- data: {
77
- hasData: true,
78
- itemCount: pages.length,
79
- eventMeta: {
80
- urls: pages.map(({ finalUrl }) => finalUrl),
81
- partialUrls: pages
82
- .filter(({ partialContent }) => partialContent)
83
- .map(({ finalUrl }) => finalUrl),
84
- },
85
- observationMeta: {
86
- kind: "volatile_external",
87
- carryPolicy: "never",
78
+ const presentation = buildFetchPresentation(pages);
79
+ return successWithSourceReceipts(
80
+ {
81
+ output: presentation.output,
82
+ progress: true,
83
+ producedNewInformation: true,
84
+ data: {
85
+ hasData: true,
86
+ itemCount: pages.length,
87
+ eventMeta: {
88
+ urls: pages.map(({ finalUrl }) => finalUrl),
89
+ partialUrls: pages
90
+ .filter(({ partialContent }) => partialContent)
91
+ .map(({ finalUrl }) => finalUrl),
92
+ },
93
+ observationMeta: {
94
+ kind: "volatile_external",
95
+ carryPolicy: "never",
96
+ },
88
97
  },
89
98
  },
90
- });
99
+ { version: 1, operation: "fetch", sources: presentation.sources },
100
+ );
91
101
  } catch (error) {
92
102
  return failure(error, "web_fetch");
93
103
  }
@@ -99,43 +109,47 @@ export function createWebPlugin(
99
109
  queries,
100
110
  executionContext?.abortSignal,
101
111
  );
102
- return successResult({
103
- output: search.output,
104
- progress: search.hits.length > 0,
105
- producedNewInformation: search.hits.length > 0,
106
- data: {
107
- hasData: search.hits.length > 0,
108
- itemCount: search.hits.length,
109
- eventMeta: {
110
- query: queries[0],
111
- queries,
112
- urls: search.hits.map(({ url }) => url),
113
- fetchedUrls: search.sourceFetches.flatMap(({ page }) =>
114
- page ? [page.finalUrl] : [],
115
- ),
116
- partialFetchedUrls: search.sourceFetches.flatMap(({ page }) =>
117
- page?.partialContent ? [page.finalUrl] : [],
118
- ),
119
- sourceFetchErrors: search.sourceFetches.flatMap(
120
- ({ hit, errorCode, error }) =>
121
- error
122
- ? [
123
- {
124
- url: hit.url,
125
- errorCode,
126
- error,
127
- },
128
- ]
129
- : [],
130
- ),
131
- coverage: search.coverage,
132
- },
133
- observationMeta: {
134
- kind: "volatile_external",
135
- carryPolicy: "never",
112
+ return successWithSourceReceipts(
113
+ {
114
+ output: search.output,
115
+ progress: search.hits.length > 0,
116
+ producedNewInformation: search.hits.length > 0,
117
+ data: {
118
+ hasData: search.hits.length > 0,
119
+ itemCount: search.hits.length,
120
+ eventMeta: {
121
+ query: queries[0],
122
+ queries,
123
+ urls: search.hits.map(({ url }) => url),
124
+ fetchedUrls: search.sourceFetches.flatMap(({ page }) =>
125
+ page ? [page.finalUrl] : [],
126
+ ),
127
+ partialFetchedUrls: search.sourceFetches.flatMap(({ page }) =>
128
+ page?.partialContent ? [page.finalUrl] : [],
129
+ ),
130
+ sourceFetchErrors: search.sourceFetches.flatMap(
131
+ ({ hit, errorCode, error }) =>
132
+ error
133
+ ? [
134
+ {
135
+ url: hit.url,
136
+ errorCode,
137
+ error,
138
+ },
139
+ ]
140
+ : [],
141
+ ),
142
+ coverage: search.coverage,
143
+ ...projectLightSearchEventMeta(search.lightSearch),
144
+ },
145
+ observationMeta: {
146
+ kind: "volatile_external",
147
+ carryPolicy: "never",
148
+ },
136
149
  },
137
150
  },
138
- });
151
+ search.webSources,
152
+ );
139
153
  } catch (error) {
140
154
  return failure(error, "web_search");
141
155
  }
@@ -27,6 +27,7 @@ export type PublicHttpRequest = Readonly<{
27
27
  headers?: Readonly<Record<string, string>>;
28
28
  maxBytes?: number;
29
29
  maxRedirects?: number;
30
+ followRedirects?: boolean;
30
31
  timeoutMs?: number;
31
32
  abortSignal?: AbortSignal;
32
33
  }>;
@@ -37,6 +38,14 @@ export type PublicHttpClient = Readonly<{
37
38
 
38
39
  const REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308]);
39
40
 
41
+ function canFollowHttpRedirect(
42
+ request: PublicHttpRequest,
43
+ status: number,
44
+ ): boolean {
45
+ if (request.followRedirects === false) return false;
46
+ return REDIRECT_STATUSES.has(status);
47
+ }
48
+
40
49
  function redirectLocation(response: HopResponse): string | undefined {
41
50
  const raw = response.headers.location;
42
51
  return Array.isArray(raw) ? raw[0] : raw;
@@ -107,7 +116,7 @@ export function createPublicHttpClient(
107
116
  deadline,
108
117
  request.abortSignal,
109
118
  );
110
- if (!REDIRECT_STATUSES.has(response.status)) {
119
+ if (!canFollowHttpRedirect(request, response.status)) {
111
120
  return Object.freeze({
112
121
  requestedUrl: requested.toString(),
113
122
  finalUrl: current.toString(),