@spearwolf/shadow-objects 0.33.0 → 0.35.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 (312) hide show
  1. package/CHANGELOG.md +350 -61
  2. package/README.md +66 -13
  3. package/bundle.js +6 -53
  4. package/package.json +15 -3
  5. package/src/ChangeTrailRefusedError.d.ts +27 -0
  6. package/src/ChangeTrailRefusedError.d.ts.map +1 -0
  7. package/src/ChangeTrailRefusedError.js +12 -0
  8. package/src/ChangeTrailRefusedError.js.map +7 -0
  9. package/src/EntityUuidInUseError.d.ts +19 -0
  10. package/src/EntityUuidInUseError.d.ts.map +1 -0
  11. package/src/EntityUuidInUseError.js +11 -0
  12. package/src/EntityUuidInUseError.js.map +7 -0
  13. package/src/WorkerTimeoutError.d.ts +26 -0
  14. package/src/WorkerTimeoutError.d.ts.map +1 -0
  15. package/src/WorkerTimeoutError.js +12 -0
  16. package/src/WorkerTimeoutError.js.map +7 -0
  17. package/src/bundle.d.ts +1 -1
  18. package/src/bundle.d.ts.map +1 -1
  19. package/src/bundle.js +1 -1
  20. package/src/bundle.js.map +2 -2
  21. package/src/constants.d.ts +13 -2
  22. package/src/constants.d.ts.map +1 -1
  23. package/src/constants.js +7 -1
  24. package/src/constants.js.map +2 -2
  25. package/src/create-worker.bundle.d.ts +1 -1
  26. package/src/create-worker.bundle.d.ts.map +1 -1
  27. package/src/create-worker.bundle.js.map +1 -1
  28. package/src/create-worker.d.ts +1 -1
  29. package/src/create-worker.d.ts.map +1 -1
  30. package/src/create-worker.js.map +1 -1
  31. package/src/elements/ShaeElement.d.ts +70 -2
  32. package/src/elements/ShaeElement.d.ts.map +1 -1
  33. package/src/elements/ShaeElement.js +129 -25
  34. package/src/elements/ShaeElement.js.map +3 -3
  35. package/src/elements/ShaeEntElement.d.ts +39 -1
  36. package/src/elements/ShaeEntElement.d.ts.map +1 -1
  37. package/src/elements/ShaeEntElement.js +397 -167
  38. package/src/elements/ShaeEntElement.js.map +2 -2
  39. package/src/elements/ShaeLifecycleElement.d.ts +71 -0
  40. package/src/elements/ShaeLifecycleElement.d.ts.map +1 -0
  41. package/src/elements/ShaeLifecycleElement.js +83 -0
  42. package/src/elements/ShaeLifecycleElement.js.map +7 -0
  43. package/src/elements/ShaePropElement.d.ts +61 -2
  44. package/src/elements/ShaePropElement.d.ts.map +1 -1
  45. package/src/elements/ShaePropElement.js +264 -219
  46. package/src/elements/ShaePropElement.js.map +2 -2
  47. package/src/elements/ShaeWorkerElement.d.ts +59 -5
  48. package/src/elements/ShaeWorkerElement.d.ts.map +1 -1
  49. package/src/elements/ShaeWorkerElement.js +271 -73
  50. package/src/elements/ShaeWorkerElement.js.map +2 -2
  51. package/src/elements/constants.d.ts +9 -0
  52. package/src/elements/constants.d.ts.map +1 -1
  53. package/src/elements/constants.js +18 -0
  54. package/src/elements/constants.js.map +2 -2
  55. package/src/elements/deferredTeardown.d.ts +24 -0
  56. package/src/elements/deferredTeardown.d.ts.map +1 -0
  57. package/src/elements/deferredTeardown.js +30 -0
  58. package/src/elements/deferredTeardown.js.map +7 -0
  59. package/src/elements/displayContentsRule.d.ts +25 -0
  60. package/src/elements/displayContentsRule.d.ts.map +1 -0
  61. package/src/elements/displayContentsRule.js +37 -0
  62. package/src/elements/displayContentsRule.js.map +7 -0
  63. package/src/elements/events.d.ts +10 -7
  64. package/src/elements/events.d.ts.map +1 -1
  65. package/src/elements/forwardCustomEvents.d.ts +19 -0
  66. package/src/elements/forwardCustomEvents.d.ts.map +1 -0
  67. package/src/elements/forwardCustomEvents.js +47 -0
  68. package/src/elements/forwardCustomEvents.js.map +7 -0
  69. package/src/elements/hostedSlots.d.ts +36 -0
  70. package/src/elements/hostedSlots.d.ts.map +1 -0
  71. package/src/elements/hostedSlots.js +118 -0
  72. package/src/elements/hostedSlots.js.map +7 -0
  73. package/src/elements/parentRemoval.d.ts +18 -0
  74. package/src/elements/parentRemoval.d.ts.map +1 -0
  75. package/src/elements/parentRemoval.js +60 -0
  76. package/src/elements/parentRemoval.js.map +7 -0
  77. package/src/elements/propValueConverters.d.ts +3 -0
  78. package/src/elements/propValueConverters.d.ts.map +1 -0
  79. package/src/elements/propValueConverters.js +54 -0
  80. package/src/elements/propValueConverters.js.map +7 -0
  81. package/src/elements/requestEntAncestor.d.ts +32 -0
  82. package/src/elements/requestEntAncestor.d.ts.map +1 -0
  83. package/src/elements/requestEntAncestor.js +16 -0
  84. package/src/elements/requestEntAncestor.js.map +7 -0
  85. package/src/elements.js.map +1 -1
  86. package/src/in-the-dark/Entity.d.ts +143 -3
  87. package/src/in-the-dark/Entity.d.ts.map +1 -1
  88. package/src/in-the-dark/Entity.js +330 -63
  89. package/src/in-the-dark/Entity.js.map +3 -3
  90. package/src/in-the-dark/Kernel.d.ts +98 -16
  91. package/src/in-the-dark/Kernel.d.ts.map +1 -1
  92. package/src/in-the-dark/Kernel.js +466 -379
  93. package/src/in-the-dark/Kernel.js.map +3 -3
  94. package/src/in-the-dark/Registry.d.ts +7 -1
  95. package/src/in-the-dark/Registry.d.ts.map +1 -1
  96. package/src/in-the-dark/Registry.js +112 -14
  97. package/src/in-the-dark/Registry.js.map +2 -2
  98. package/src/in-the-dark/ShadowObject.d.ts.map +1 -1
  99. package/src/in-the-dark/ShadowObject.js +1 -0
  100. package/src/in-the-dark/ShadowObject.js.map +2 -2
  101. package/src/in-the-dark/ShadowObjectCreationScope.d.ts +133 -0
  102. package/src/in-the-dark/ShadowObjectCreationScope.d.ts.map +1 -0
  103. package/src/in-the-dark/ShadowObjectCreationScope.js +603 -0
  104. package/src/in-the-dark/ShadowObjectCreationScope.js.map +7 -0
  105. package/src/in-the-dark/SignalsPath.d.ts +2 -0
  106. package/src/in-the-dark/SignalsPath.d.ts.map +1 -1
  107. package/src/in-the-dark/SignalsPath.js +6 -2
  108. package/src/in-the-dark/SignalsPath.js.map +2 -2
  109. package/src/in-the-dark/displayName.d.ts +4 -0
  110. package/src/in-the-dark/displayName.d.ts.map +1 -0
  111. package/src/in-the-dark/displayName.js +5 -0
  112. package/src/in-the-dark/displayName.js.map +7 -0
  113. package/src/in-the-dark/events.js.map +1 -1
  114. package/src/in-the-dark/importModule.d.ts +7 -0
  115. package/src/in-the-dark/importModule.d.ts.map +1 -1
  116. package/src/in-the-dark/importModule.js +5 -2
  117. package/src/in-the-dark/importModule.js.map +2 -2
  118. package/src/index.d.ts +9 -1
  119. package/src/index.d.ts.map +1 -1
  120. package/src/index.js +9 -1
  121. package/src/index.js.map +2 -2
  122. package/src/inspect/createKernelSnapshot.d.ts +17 -0
  123. package/src/inspect/createKernelSnapshot.d.ts.map +1 -0
  124. package/src/inspect/createKernelSnapshot.js +247 -0
  125. package/src/inspect/createKernelSnapshot.js.map +7 -0
  126. package/src/inspect/createViewSnapshot.d.ts +10 -0
  127. package/src/inspect/createViewSnapshot.d.ts.map +1 -0
  128. package/src/inspect/createViewSnapshot.js +143 -0
  129. package/src/inspect/createViewSnapshot.js.map +7 -0
  130. package/src/inspect/normalizeInspectRequest.d.ts +32 -0
  131. package/src/inspect/normalizeInspectRequest.d.ts.map +1 -0
  132. package/src/inspect/normalizeInspectRequest.js +55 -0
  133. package/src/inspect/normalizeInspectRequest.js.map +7 -0
  134. package/src/inspect/serializeValue.d.ts +13 -0
  135. package/src/inspect/serializeValue.d.ts.map +1 -0
  136. package/src/inspect/serializeValue.js +149 -0
  137. package/src/inspect/serializeValue.js.map +7 -0
  138. package/src/inspect/types.d.ts +260 -0
  139. package/src/inspect/types.d.ts.map +1 -0
  140. package/src/inspect/types.js +1 -0
  141. package/src/inspect/types.js.map +7 -0
  142. package/src/model-context/ModelContextLike.d.ts +59 -0
  143. package/src/model-context/ModelContextLike.d.ts.map +1 -0
  144. package/src/model-context/ModelContextLike.js +15 -0
  145. package/src/model-context/ModelContextLike.js.map +7 -0
  146. package/src/model-context/exposeShadowEnvsToModelContext.d.ts +48 -0
  147. package/src/model-context/exposeShadowEnvsToModelContext.d.ts.map +1 -0
  148. package/src/model-context/exposeShadowEnvsToModelContext.js +39 -0
  149. package/src/model-context/exposeShadowEnvsToModelContext.js.map +7 -0
  150. package/src/model-context/redactProps.d.ts +14 -0
  151. package/src/model-context/redactProps.d.ts.map +1 -0
  152. package/src/model-context/redactProps.js +22 -0
  153. package/src/model-context/redactProps.js.map +7 -0
  154. package/src/model-context/sharedExposure.d.ts +32 -0
  155. package/src/model-context/sharedExposure.d.ts.map +1 -0
  156. package/src/model-context/sharedExposure.js +108 -0
  157. package/src/model-context/sharedExposure.js.map +7 -0
  158. package/src/model-context/toolSupport.d.ts +72 -0
  159. package/src/model-context/toolSupport.d.ts.map +1 -0
  160. package/src/model-context/toolSupport.js +145 -0
  161. package/src/model-context/toolSupport.js.map +7 -0
  162. package/src/model-context/tools/findEntities.d.ts +15 -0
  163. package/src/model-context/tools/findEntities.d.ts.map +1 -0
  164. package/src/model-context/tools/findEntities.js +71 -0
  165. package/src/model-context/tools/findEntities.js.map +7 -0
  166. package/src/model-context/tools/getEntity.d.ts +16 -0
  167. package/src/model-context/tools/getEntity.d.ts.map +1 -0
  168. package/src/model-context/tools/getEntity.js +65 -0
  169. package/src/model-context/tools/getEntity.js.map +7 -0
  170. package/src/model-context/tools/getEntityTree.d.ts +4 -0
  171. package/src/model-context/tools/getEntityTree.d.ts.map +1 -0
  172. package/src/model-context/tools/getEntityTree.js +58 -0
  173. package/src/model-context/tools/getEntityTree.js.map +7 -0
  174. package/src/model-context/tools/getRegistry.d.ts +14 -0
  175. package/src/model-context/tools/getRegistry.d.ts.map +1 -0
  176. package/src/model-context/tools/getRegistry.js +39 -0
  177. package/src/model-context/tools/getRegistry.js.map +7 -0
  178. package/src/model-context/tools/index.d.ts +9 -0
  179. package/src/model-context/tools/index.d.ts.map +1 -0
  180. package/src/model-context/tools/index.js +16 -0
  181. package/src/model-context/tools/index.js.map +7 -0
  182. package/src/model-context/tools/listEnvs.d.ts +33 -0
  183. package/src/model-context/tools/listEnvs.d.ts.map +1 -0
  184. package/src/model-context/tools/listEnvs.js +37 -0
  185. package/src/model-context/tools/listEnvs.js.map +7 -0
  186. package/src/model-context.d.ts +13 -0
  187. package/src/model-context.d.ts.map +1 -0
  188. package/src/model-context.js +15 -0
  189. package/src/model-context.js.map +7 -0
  190. package/src/shadow-objects.d.ts +4 -0
  191. package/src/shadow-objects.d.ts.map +1 -1
  192. package/src/shadow-objects.js +6 -0
  193. package/src/shadow-objects.js.map +2 -2
  194. package/src/shadow-objects.worker.js +0 -1
  195. package/src/shadow-objects.worker.js.map +2 -2
  196. package/src/shae-ent.js.map +1 -1
  197. package/src/shae-prop.js +2 -2
  198. package/src/shae-prop.js.map +2 -2
  199. package/src/shae-worker.js.map +1 -1
  200. package/src/testing/TestEntity.d.ts +79 -0
  201. package/src/testing/TestEntity.d.ts.map +1 -0
  202. package/src/testing/TestEntity.js +135 -0
  203. package/src/testing/TestEntity.js.map +7 -0
  204. package/src/testing/createTestKernel.d.ts +11 -0
  205. package/src/testing/createTestKernel.d.ts.map +1 -0
  206. package/src/testing/createTestKernel.js +132 -0
  207. package/src/testing/createTestKernel.js.map +7 -0
  208. package/src/testing/mountShadowObject.d.ts +21 -0
  209. package/src/testing/mountShadowObject.d.ts.map +1 -0
  210. package/src/testing/mountShadowObject.js +72 -0
  211. package/src/testing/mountShadowObject.js.map +7 -0
  212. package/src/testing/recordKernelErrors.d.ts +21 -0
  213. package/src/testing/recordKernelErrors.d.ts.map +1 -0
  214. package/src/testing/recordKernelErrors.js +39 -0
  215. package/src/testing/recordKernelErrors.js.map +7 -0
  216. package/src/testing/settle.d.ts +15 -0
  217. package/src/testing/settle.d.ts.map +1 -0
  218. package/src/testing/settle.js +19 -0
  219. package/src/testing/settle.js.map +7 -0
  220. package/src/testing/types.d.ts +119 -0
  221. package/src/testing/types.d.ts.map +1 -0
  222. package/src/testing/types.js +1 -0
  223. package/src/testing/types.js.map +7 -0
  224. package/src/testing.d.ts +14 -0
  225. package/src/testing.d.ts.map +1 -0
  226. package/src/testing.js +11 -0
  227. package/src/testing.js.map +7 -0
  228. package/src/types.d.ts +185 -14
  229. package/src/types.d.ts.map +1 -1
  230. package/src/utils/ConsoleLogger.d.ts +45 -10
  231. package/src/utils/ConsoleLogger.d.ts.map +1 -1
  232. package/src/utils/ConsoleLogger.js +51 -26
  233. package/src/utils/ConsoleLogger.js.map +2 -2
  234. package/src/utils/FrameLoop.d.ts +42 -3
  235. package/src/utils/FrameLoop.d.ts.map +1 -1
  236. package/src/utils/FrameLoop.js +71 -10
  237. package/src/utils/FrameLoop.js.map +2 -2
  238. package/src/utils/MicrotaskCollector.d.ts +45 -0
  239. package/src/utils/MicrotaskCollector.d.ts.map +1 -0
  240. package/src/utils/MicrotaskCollector.js +33 -0
  241. package/src/utils/MicrotaskCollector.js.map +7 -0
  242. package/src/utils/MicrotaskGate.d.ts +17 -0
  243. package/src/utils/MicrotaskGate.d.ts.map +1 -0
  244. package/src/utils/MicrotaskGate.js +20 -0
  245. package/src/utils/MicrotaskGate.js.map +7 -0
  246. package/src/utils/array-utils.js.map +1 -1
  247. package/src/utils/attr-utils.d.ts +11 -0
  248. package/src/utils/attr-utils.d.ts.map +1 -1
  249. package/src/utils/attr-utils.js +5 -1
  250. package/src/utils/attr-utils.js.map +2 -2
  251. package/src/utils/constants.js.map +1 -1
  252. package/src/utils/generateUUID.d.ts +11 -0
  253. package/src/utils/generateUUID.d.ts.map +1 -1
  254. package/src/utils/generateUUID.js +31 -266
  255. package/src/utils/generateUUID.js.map +2 -2
  256. package/src/utils/props-utils.d.ts +3 -2
  257. package/src/utils/props-utils.d.ts.map +1 -1
  258. package/src/utils/props-utils.js +13 -24
  259. package/src/utils/props-utils.js.map +2 -2
  260. package/src/utils/runGuarded.d.ts +27 -0
  261. package/src/utils/runGuarded.d.ts.map +1 -0
  262. package/src/utils/runGuarded.js +11 -0
  263. package/src/utils/runGuarded.js.map +7 -0
  264. package/src/utils/toMaybe.d.ts.map +1 -1
  265. package/src/utils/toMaybe.js.map +1 -1
  266. package/src/utils/toNamespace.d.ts.map +1 -1
  267. package/src/utils/toNamespace.js.map +1 -1
  268. package/src/utils/toUrlString.d.ts +12 -0
  269. package/src/utils/toUrlString.d.ts.map +1 -1
  270. package/src/utils/toUrlString.js.map +2 -2
  271. package/src/utils/waitForMessageOfType.d.ts +12 -1
  272. package/src/utils/waitForMessageOfType.d.ts.map +1 -1
  273. package/src/utils/waitForMessageOfType.js +16 -1
  274. package/src/utils/waitForMessageOfType.js.map +2 -2
  275. package/src/view/ComponentChanges.d.ts +88 -1
  276. package/src/view/ComponentChanges.d.ts.map +1 -1
  277. package/src/view/ComponentChanges.js +243 -73
  278. package/src/view/ComponentChanges.js.map +2 -2
  279. package/src/view/ComponentContext.d.ts +206 -16
  280. package/src/view/ComponentContext.d.ts.map +1 -1
  281. package/src/view/ComponentContext.js +548 -91
  282. package/src/view/ComponentContext.js.map +2 -2
  283. package/src/view/ComponentMemory.d.ts +3 -3
  284. package/src/view/ComponentMemory.d.ts.map +1 -1
  285. package/src/view/ComponentMemory.js.map +1 -1
  286. package/src/view/IShadowObjectEnvProxy.d.ts +38 -3
  287. package/src/view/IShadowObjectEnvProxy.d.ts.map +1 -1
  288. package/src/view/LocalShadowObjectEnv.d.ts +8 -1
  289. package/src/view/LocalShadowObjectEnv.d.ts.map +1 -1
  290. package/src/view/LocalShadowObjectEnv.js +23 -7
  291. package/src/view/LocalShadowObjectEnv.js.map +2 -2
  292. package/src/view/RemoteWorkerEnv.d.ts +108 -5
  293. package/src/view/RemoteWorkerEnv.d.ts.map +1 -1
  294. package/src/view/RemoteWorkerEnv.js +244 -77
  295. package/src/view/RemoteWorkerEnv.js.map +2 -2
  296. package/src/view/ShadowEnv.d.ts +79 -2
  297. package/src/view/ShadowEnv.d.ts.map +1 -1
  298. package/src/view/ShadowEnv.js +323 -59
  299. package/src/view/ShadowEnv.js.map +3 -3
  300. package/src/view/ViewComponent.d.ts +78 -14
  301. package/src/view/ViewComponent.d.ts.map +1 -1
  302. package/src/view/ViewComponent.js +90 -14
  303. package/src/view/ViewComponent.js.map +2 -2
  304. package/src/view/cloneChangeTrail.js.map +2 -2
  305. package/src/worker/MessageRouter.d.ts +14 -0
  306. package/src/worker/MessageRouter.d.ts.map +1 -1
  307. package/src/worker/MessageRouter.js +98 -15
  308. package/src/worker/MessageRouter.js.map +2 -2
  309. package/src/worker/WorkerRuntime.d.ts +22 -1
  310. package/src/worker/WorkerRuntime.d.ts.map +1 -1
  311. package/src/worker/WorkerRuntime.js +60 -8
  312. package/src/worker/WorkerRuntime.js.map +2 -2
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/model-context/exposeShadowEnvsToModelContext.ts"],
4
+ "sourcesContent": ["import type {InspectRequest} from '../inspect/types.js';\nimport {ConsoleLogger} from '../utils/ConsoleLogger.js';\nimport {findModelContext, type ModelContextLike} from './ModelContextLike.js';\nimport type {RedactRule} from './redactProps.js';\nimport {joinSharedExposure} from './sharedExposure.js';\nimport type {NamespaceRule} from './toolSupport.js';\n\nexport interface ExposeOptions {\n /** Where to register. Default: `document.modelContext`, then `navigator.modelContext`; neither means \"not available\". */\n modelContext?: ModelContextLike;\n /** Prefix for every tool name. Default `'shae-'`. Together with `modelContext` it names the registration this call shares. */\n toolPrefix?: string;\n /** Aborting it takes this call's share back; the tools leave with the last share. */\n signal?: AbortSignal;\n /** Passed through to `registerTool()` by the call that opens the registration. Default: not set, so the platform default applies. */\n exposedTo?: string[];\n /** Default limits for every tool call, set by the call that opens the registration; a call's own input wins field by field. */\n limits?: Partial<InspectRequest>;\n /** Property names whose values are replaced by `{$type: 'redacted'}` in every answer, on the Kernel's and the View's side alike. Property values only. Cumulates with every other share of the registration. */\n redactProps?: RedactRule;\n /** Which environments this share exposes: a list of namespaces or a predicate over the namespace an environment is registered under. Default: every environment that holds a namespace. The registration exposes the union over its shares; a namespace outside it is refused like an unknown one. */\n namespaces?: NamespaceRule;\n}\n\nexport interface ExposeHandle {\n /** `false` when no model context was found; then `tools` is empty and nothing was registered. */\n available: boolean;\n /** The tool names of the shared registration, with the prefix. */\n tools: string[];\n /** Takes this call's share back; the tools leave with the last share. Idempotent. The same as aborting `options.signal`. */\n dispose(): void;\n}\n\nexport const DefaultToolPrefix = 'shae-';\n\n/**\n * Registers the five read-only inspection tools on the platform's model context, so that an\n * agent can see the Shadow Environments on the page. Nothing is exposed without this call or\n * the `expose-to-model-context` attribute of `<shae-worker>`, which goes through it; every value\n * in every answer is application state, and the docs say what that means before they show the\n * first line of code.\n *\n * One registration per model context and prefix, shared: every call and every element is a\n * share of it, the first opens it, the last to go closes it, and the tools answer from the union\n * of what the shares expose and redact. A second call under the same prefix therefore joins\n * rather than fails.\n *\n * Resolves, never rejects, where the platform has no model context -- the same application code\n * runs in every browser. Rejects with what `registerTool()` rejected with -- a `NotAllowedError`\n * under a Permissions Policy that disables `tools` -- and those are the caller's to handle.\n * Registration is all-or-nothing: a rejection midway takes back what was registered before it.\n */\nexport async function exposeShadowEnvsToModelContext(options: ExposeOptions = {}): Promise<ExposeHandle> {\n const modelContext = options.modelContext ?? findModelContext();\n\n if (modelContext === undefined) {\n new ConsoleLogger('ModelContext').info('no model context on this platform, nothing registered');\n return {available: false, tools: [], dispose() {}};\n }\n\n const {signal} = options;\n if (signal?.aborted) return {available: true, tools: [], dispose() {}};\n\n const settings = {limits: options.limits ?? {}, ...(options.exposedTo !== undefined ? {exposedTo: options.exposedTo} : {})};\n const membership = joinSharedExposure(\n modelContext,\n options.toolPrefix ?? DefaultToolPrefix,\n {namespaces: options.namespaces, redactProps: options.redactProps},\n settings,\n );\n\n const dispose = () => {\n membership.leave();\n signal?.removeEventListener('abort', dispose);\n };\n signal?.addEventListener('abort', dispose, {once: true});\n\n try {\n const tools = await membership.tools;\n return {available: true, tools, dispose};\n } catch (error) {\n dispose();\n throw error;\n }\n}\n"],
5
+ "mappings": "AACA,SAAQ,qBAAoB;AAC5B,SAAQ,wBAA8C;AAEtD,SAAQ,0BAAyB;AA6B1B,MAAM,oBAAoB;AAmBjC,eAAsB,+BAA+B,UAAyB,CAAC,GAA0B;AACvG,QAAM,eAAe,QAAQ,gBAAgB,iBAAiB;AAE9D,MAAI,iBAAiB,QAAW;AAC9B,QAAI,cAAc,cAAc,EAAE,KAAK,uDAAuD;AAC9F,WAAO,EAAC,WAAW,OAAO,OAAO,CAAC,GAAG,UAAU;AAAA,IAAC,EAAC;AAAA,EACnD;AAEA,QAAM,EAAC,OAAM,IAAI;AACjB,MAAI,QAAQ,QAAS,QAAO,EAAC,WAAW,MAAM,OAAO,CAAC,GAAG,UAAU;AAAA,EAAC,EAAC;AAErE,QAAM,WAAW,EAAC,QAAQ,QAAQ,UAAU,CAAC,GAAG,GAAI,QAAQ,cAAc,SAAY,EAAC,WAAW,QAAQ,UAAS,IAAI,CAAC,EAAE;AAC1H,QAAM,aAAa;AAAA,IACjB;AAAA,IACA,QAAQ,cAAc;AAAA,IACtB,EAAC,YAAY,QAAQ,YAAY,aAAa,QAAQ,YAAW;AAAA,IACjE;AAAA,EACF;AAEA,QAAM,UAAU,MAAM;AACpB,eAAW,MAAM;AACjB,YAAQ,oBAAoB,SAAS,OAAO;AAAA,EAC9C;AACA,UAAQ,iBAAiB,SAAS,SAAS,EAAC,MAAM,KAAI,CAAC;AAEvD,MAAI;AACF,UAAM,QAAQ,MAAM,WAAW;AAC/B,WAAO,EAAC,WAAW,MAAM,OAAO,QAAO;AAAA,EACzC,SAAS,OAAO;AACd,YAAQ;AACR,UAAM;AAAA,EACR;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,14 @@
1
+ import type { EnvSnapshot } from '../inspect/types.js';
2
+ /** Property names whose values are hidden: a list of names, or a predicate over name and Entity uuid. */
3
+ export type RedactRule = string[] | ((name: string, uuid: string) => boolean);
4
+ export type RedactPredicate = (name: string, uuid: string) => boolean;
5
+ export declare const toRedactPredicate: (rule: RedactRule | undefined) => RedactPredicate | undefined;
6
+ /**
7
+ * Replaces the value of every property the rule names by `{$type: 'redacted'}`, on the Kernel's
8
+ * Entities and the View's components alike, in place. Property values only: an Entity Context
9
+ * that carries the same secret is not covered, and the docs say so. In place is safe because a
10
+ * snapshot is built fresh for every call -- plain data from the builder, or a structured clone
11
+ * from the worker -- and nobody else holds it.
12
+ */
13
+ export declare function redactSnapshot(snapshot: EnvSnapshot, redact: RedactPredicate): EnvSnapshot;
14
+ //# sourceMappingURL=redactProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redactProps.d.ts","sourceRoot":"","sources":["../../../src/model-context/redactProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAe,MAAM,qBAAqB,CAAC;AAEnE,yGAAyG;AACzG,MAAM,MAAM,UAAU,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;AAE9E,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;AAEtE,eAAO,MAAM,iBAAiB,SAAU,UAAU,GAAG,SAAS,KAAG,eAAe,GAAG,SAKlF,CAAC;AAgBF;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,GAAG,WAAW,CAI1F"}
@@ -0,0 +1,22 @@
1
+ const toRedactPredicate = (rule) => {
2
+ if (rule === void 0) return void 0;
3
+ if (typeof rule === "function") return rule;
4
+ const names = new Set(rule);
5
+ return (name) => names.has(name);
6
+ };
7
+ const redactNode = (node, redact) => {
8
+ for (const prop of node.props ?? []) {
9
+ if (redact(prop.name, node.uuid)) prop.value = { $type: "redacted" };
10
+ }
11
+ for (const child of node.children ?? []) redactNode(child, redact);
12
+ };
13
+ function redactSnapshot(snapshot, redact) {
14
+ for (const root of snapshot.kernel?.roots ?? []) redactNode(root, redact);
15
+ for (const root of snapshot.view?.roots ?? []) redactNode(root, redact);
16
+ return snapshot;
17
+ }
18
+ export {
19
+ redactSnapshot,
20
+ toRedactPredicate
21
+ };
22
+ //# sourceMappingURL=redactProps.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/model-context/redactProps.ts"],
4
+ "sourcesContent": ["import type {EnvSnapshot, PropSnapshot} from '../inspect/types.js';\n\n/** Property names whose values are hidden: a list of names, or a predicate over name and Entity uuid. */\nexport type RedactRule = string[] | ((name: string, uuid: string) => boolean);\n\nexport type RedactPredicate = (name: string, uuid: string) => boolean;\n\nexport const toRedactPredicate = (rule: RedactRule | undefined): RedactPredicate | undefined => {\n if (rule === undefined) return undefined;\n if (typeof rule === 'function') return rule;\n const names = new Set(rule);\n return (name) => names.has(name);\n};\n\ninterface NodeWithProps {\n uuid: string;\n props?: PropSnapshot[];\n children?: NodeWithProps[];\n}\n\nconst redactNode = (node: NodeWithProps, redact: RedactPredicate): void => {\n for (const prop of node.props ?? []) {\n // `routes` stays: whether a value routes is not the value\n if (redact(prop.name, node.uuid)) prop.value = {$type: 'redacted'};\n }\n for (const child of node.children ?? []) redactNode(child, redact);\n};\n\n/**\n * Replaces the value of every property the rule names by `{$type: 'redacted'}`, on the Kernel's\n * Entities and the View's components alike, in place. Property values only: an Entity Context\n * that carries the same secret is not covered, and the docs say so. In place is safe because a\n * snapshot is built fresh for every call -- plain data from the builder, or a structured clone\n * from the worker -- and nobody else holds it.\n */\nexport function redactSnapshot(snapshot: EnvSnapshot, redact: RedactPredicate): EnvSnapshot {\n for (const root of snapshot.kernel?.roots ?? []) redactNode(root, redact);\n for (const root of snapshot.view?.roots ?? []) redactNode(root, redact);\n return snapshot;\n}\n"],
5
+ "mappings": "AAOO,MAAM,oBAAoB,CAAC,SAA8D;AAC9F,MAAI,SAAS,OAAW,QAAO;AAC/B,MAAI,OAAO,SAAS,WAAY,QAAO;AACvC,QAAM,QAAQ,IAAI,IAAI,IAAI;AAC1B,SAAO,CAAC,SAAS,MAAM,IAAI,IAAI;AACjC;AAQA,MAAM,aAAa,CAAC,MAAqB,WAAkC;AACzE,aAAW,QAAQ,KAAK,SAAS,CAAC,GAAG;AAEnC,QAAI,OAAO,KAAK,MAAM,KAAK,IAAI,EAAG,MAAK,QAAQ,EAAC,OAAO,WAAU;AAAA,EACnE;AACA,aAAW,SAAS,KAAK,YAAY,CAAC,EAAG,YAAW,OAAO,MAAM;AACnE;AASO,SAAS,eAAe,UAAuB,QAAsC;AAC1F,aAAW,QAAQ,SAAS,QAAQ,SAAS,CAAC,EAAG,YAAW,MAAM,MAAM;AACxE,aAAW,QAAQ,SAAS,MAAM,SAAS,CAAC,EAAG,YAAW,MAAM,MAAM;AACtE,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,32 @@
1
+ import type { InspectRequest } from '../inspect/types.js';
2
+ import type { ModelContextLike } from './ModelContextLike.js';
3
+ import { type RedactRule } from './redactProps.js';
4
+ import { type NamespaceRule } from './toolSupport.js';
5
+ /** What one share of a registration brings: the environments it exposes and the properties it hides. */
6
+ export interface ExposureMember {
7
+ /** `undefined` exposes every environment that holds a namespace. */
8
+ namespaces: NamespaceRule | undefined;
9
+ redactProps: RedactRule | undefined;
10
+ }
11
+ /** What the registration takes from the member that opens it, and from nobody after that. */
12
+ export interface ExposureSettings {
13
+ limits: Partial<InspectRequest>;
14
+ exposedTo?: string[];
15
+ }
16
+ export interface ExposureMembership {
17
+ /**
18
+ * The names the registration ended with -- empty when it was closed while it was still
19
+ * registering. Rejects with what `registerTool()` rejected with; the registration is gone then.
20
+ */
21
+ readonly tools: Promise<string[]>;
22
+ /** Takes this share back. The last share out closes the registration. Idempotent. */
23
+ leave(): void;
24
+ }
25
+ /**
26
+ * Joins the registration under `prefix` on `modelContext`, opening it when there is none. The
27
+ * member's rules count from the next tool call on; `settings` count only for the member that
28
+ * opens -- a later member with other values is reported and joins under the opener's, because
29
+ * `exposedTo` has gone to the platform by then and one set of `limits` is all a tool has.
30
+ */
31
+ export declare function joinSharedExposure(modelContext: ModelContextLike, prefix: string, member: ExposureMember, settings: ExposureSettings): ExposureMembership;
32
+ //# sourceMappingURL=sharedExposure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sharedExposure.d.ts","sourceRoot":"","sources":["../../../src/model-context/sharedExposure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAGxD,OAAO,KAAK,EAAC,gBAAgB,EAA8B,MAAM,uBAAuB,CAAC;AACzF,OAAO,EAAuB,KAAK,UAAU,EAAoB,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAC,KAAK,aAAa,EAAyC,MAAM,kBAAkB,CAAC;AAG5F,wGAAwG;AACxG,MAAM,WAAW,cAAc;IAC7B,oEAAoE;IACpE,UAAU,EAAE,aAAa,GAAG,SAAS,CAAC;IACtC,WAAW,EAAE,UAAU,GAAG,SAAS,CAAC;CACrC;AAED,6FAA6F;AAC7F,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAClC,qFAAqF;IACrF,KAAK,IAAI,IAAI,CAAC;CACf;AAkHD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,gBAAgB,EAC9B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,gBAAgB,GACzB,kBAAkB,CA8BpB"}
@@ -0,0 +1,108 @@
1
+ import { ConsoleLogger } from "../utils/ConsoleLogger.js";
2
+ import { toRedactPredicate } from "./redactProps.js";
3
+ import { toNamespacePredicate } from "./toolSupport.js";
4
+ import { createTools } from "./tools/index.js";
5
+ const registry = /* @__PURE__ */ new WeakMap();
6
+ const logger = new ConsoleLogger("ModelContext");
7
+ const unionNamespaces = (members) => {
8
+ const predicates = [];
9
+ for (const member of members) {
10
+ const predicate = toNamespacePredicate(member.namespaces);
11
+ if (predicate === void 0) return void 0;
12
+ predicates.push(predicate);
13
+ }
14
+ return (ns) => predicates.some((accepts) => accepts(ns));
15
+ };
16
+ const unionRedaction = (members) => {
17
+ const predicates = [];
18
+ for (const member of members) {
19
+ const predicate = toRedactPredicate(member.redactProps);
20
+ if (predicate !== void 0) predicates.push(predicate);
21
+ }
22
+ if (predicates.length === 0) return void 0;
23
+ return (name, uuid) => predicates.some((hides) => hides(name, uuid));
24
+ };
25
+ const registerAll = async (modelContext, ctx, exposure) => {
26
+ const { controller, settings } = exposure;
27
+ const registerOptions = { signal: controller.signal };
28
+ if (settings.exposedTo !== void 0) registerOptions.exposedTo = settings.exposedTo;
29
+ const registered = [];
30
+ try {
31
+ for (const tool of createTools(ctx)) {
32
+ if (controller.signal.aborted) break;
33
+ await modelContext.registerTool(tool, registerOptions);
34
+ registered.push(tool.name);
35
+ }
36
+ } catch (error) {
37
+ controller.abort(error);
38
+ logger.error("registering the tools failed", error);
39
+ throw error;
40
+ }
41
+ if (controller.signal.aborted) return [];
42
+ logger.info(`registered ${registered.length} tools`, registered);
43
+ return registered;
44
+ };
45
+ const open = (modelContext, prefix, settings) => {
46
+ const members = /* @__PURE__ */ new Set();
47
+ const exposure = {
48
+ members,
49
+ controller: new AbortController(),
50
+ settings,
51
+ tools: Promise.resolve([]),
52
+ closed: false
53
+ };
54
+ const ctx = {
55
+ prefix,
56
+ limits: settings.limits,
57
+ get isExposed() {
58
+ return unionNamespaces(members);
59
+ },
60
+ get redact() {
61
+ return unionRedaction(members);
62
+ }
63
+ };
64
+ exposure.tools = registerAll(modelContext, ctx, exposure);
65
+ exposure.tools.catch(() => close(modelContext, prefix, exposure));
66
+ return exposure;
67
+ };
68
+ const close = (modelContext, prefix, exposure) => {
69
+ if (exposure.closed) return;
70
+ exposure.closed = true;
71
+ exposure.controller.abort();
72
+ const byPrefix = registry.get(modelContext);
73
+ if (byPrefix?.get(prefix) === exposure) byPrefix.delete(prefix);
74
+ };
75
+ const sameSettings = (a, b) => JSON.stringify(a.limits) === JSON.stringify(b.limits) && JSON.stringify(a.exposedTo) === JSON.stringify(b.exposedTo);
76
+ function joinSharedExposure(modelContext, prefix, member, settings) {
77
+ let byPrefix = registry.get(modelContext);
78
+ if (byPrefix === void 0) {
79
+ byPrefix = /* @__PURE__ */ new Map();
80
+ registry.set(modelContext, byPrefix);
81
+ }
82
+ let exposure = byPrefix.get(prefix);
83
+ if (exposure === void 0) {
84
+ exposure = open(modelContext, prefix, settings);
85
+ byPrefix.set(prefix, exposure);
86
+ } else if (!sameSettings(exposure.settings, settings)) {
87
+ logger.warn(
88
+ `the tools under "${prefix}" are already registered with other limits or exposedTo; the values of the first call apply`,
89
+ { inEffect: exposure.settings, ignored: settings }
90
+ );
91
+ }
92
+ const joined = exposure;
93
+ joined.members.add(member);
94
+ let left = false;
95
+ return {
96
+ tools: joined.tools,
97
+ leave() {
98
+ if (left) return;
99
+ left = true;
100
+ joined.members.delete(member);
101
+ if (joined.members.size === 0) close(modelContext, prefix, joined);
102
+ }
103
+ };
104
+ }
105
+ export {
106
+ joinSharedExposure
107
+ };
108
+ //# sourceMappingURL=sharedExposure.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/model-context/sharedExposure.ts"],
4
+ "sourcesContent": ["import type {InspectRequest} from '../inspect/types.js';\nimport type {NamespaceType} from '../types.js';\nimport {ConsoleLogger} from '../utils/ConsoleLogger.js';\nimport type {ModelContextLike, ModelContextRegisterOptions} from './ModelContextLike.js';\nimport {type RedactPredicate, type RedactRule, toRedactPredicate} from './redactProps.js';\nimport {type NamespaceRule, type ToolContext, toNamespacePredicate} from './toolSupport.js';\nimport {createTools} from './tools/index.js';\n\n/** What one share of a registration brings: the environments it exposes and the properties it hides. */\nexport interface ExposureMember {\n /** `undefined` exposes every environment that holds a namespace. */\n namespaces: NamespaceRule | undefined;\n redactProps: RedactRule | undefined;\n}\n\n/** What the registration takes from the member that opens it, and from nobody after that. */\nexport interface ExposureSettings {\n limits: Partial<InspectRequest>;\n exposedTo?: string[];\n}\n\nexport interface ExposureMembership {\n /**\n * The names the registration ended with -- empty when it was closed while it was still\n * registering. Rejects with what `registerTool()` rejected with; the registration is gone then.\n */\n readonly tools: Promise<string[]>;\n /** Takes this share back. The last share out closes the registration. Idempotent. */\n leave(): void;\n}\n\ninterface Exposure {\n readonly members: Set<ExposureMember>;\n readonly controller: AbortController;\n readonly settings: ExposureSettings;\n tools: Promise<string[]>;\n closed: boolean;\n}\n\n/*\n * One registration per model context and prefix, per copy of the package: the tools carry\n * fixed names and the platform refuses a duplicate, so whoever wants them joins the one that\n * exists. Keyed weakly on the model context, so a fake built in a test goes when the test does.\n */\nconst registry = new WeakMap<ModelContextLike, Map<string, Exposure>>();\n\nconst logger = new ConsoleLogger('ModelContext');\n\n/**\n * The namespaces a registration exposes right now: `undefined` -- every environment -- as soon\n * as one member has no rule, otherwise \"any member's rule accepts it\".\n */\nconst unionNamespaces = (members: Iterable<ExposureMember>): ((ns: NamespaceType) => boolean) | undefined => {\n const predicates: ((ns: NamespaceType) => boolean)[] = [];\n for (const member of members) {\n const predicate = toNamespacePredicate(member.namespaces);\n if (predicate === undefined) return undefined;\n predicates.push(predicate);\n }\n return (ns) => predicates.some((accepts) => accepts(ns));\n};\n\n/**\n * The redaction a registration applies right now: a value is hidden when any member's rule\n * says so. `undefined` while no member brings a rule, so the walk over the snapshot is skipped.\n */\nconst unionRedaction = (members: Iterable<ExposureMember>): RedactPredicate | undefined => {\n const predicates: RedactPredicate[] = [];\n for (const member of members) {\n const predicate = toRedactPredicate(member.redactProps);\n if (predicate !== undefined) predicates.push(predicate);\n }\n if (predicates.length === 0) return undefined;\n return (name, uuid) => predicates.some((hides) => hides(name, uuid));\n};\n\n/**\n * The registration loop, all-or-nothing: a rejection midway aborts the controller, which takes\n * back what was registered before it, and is rethrown for every member to see.\n */\nconst registerAll = async (modelContext: ModelContextLike, ctx: ToolContext, exposure: Exposure): Promise<string[]> => {\n const {controller, settings} = exposure;\n const registerOptions: ModelContextRegisterOptions = {signal: controller.signal};\n if (settings.exposedTo !== undefined) registerOptions.exposedTo = settings.exposedTo;\n\n const registered: string[] = [];\n try {\n for (const tool of createTools(ctx)) {\n if (controller.signal.aborted) break;\n await modelContext.registerTool(tool, registerOptions);\n registered.push(tool.name);\n }\n } catch (error) {\n controller.abort(error);\n logger.error('registering the tools failed', error);\n throw error;\n }\n\n // closed while registering: the platform has already taken the tools back\n if (controller.signal.aborted) return [];\n\n logger.info(`registered ${registered.length} tools`, registered);\n return registered;\n};\n\nconst open = (modelContext: ModelContextLike, prefix: string, settings: ExposureSettings): Exposure => {\n const members = new Set<ExposureMember>();\n const exposure: Exposure = {\n members,\n controller: new AbortController(),\n settings,\n tools: Promise.resolve([]),\n closed: false,\n };\n // getters, not values: the tools read both at the start of every call (`inspectEnvs`), so a\n // member joining or leaving is seen by the next call and nothing has to be re-registered\n const ctx: ToolContext = {\n prefix,\n limits: settings.limits,\n get isExposed() {\n return unionNamespaces(members);\n },\n get redact() {\n return unionRedaction(members);\n },\n };\n exposure.tools = registerAll(modelContext, ctx, exposure);\n // a registration that failed is not kept: the next member to arrive first opens a new one\n exposure.tools.catch(() => close(modelContext, prefix, exposure));\n return exposure;\n};\n\nconst close = (modelContext: ModelContextLike, prefix: string, exposure: Exposure): void => {\n if (exposure.closed) return;\n exposure.closed = true;\n exposure.controller.abort();\n const byPrefix = registry.get(modelContext);\n if (byPrefix?.get(prefix) === exposure) byPrefix.delete(prefix);\n};\n\nconst sameSettings = (a: ExposureSettings, b: ExposureSettings): boolean =>\n JSON.stringify(a.limits) === JSON.stringify(b.limits) && JSON.stringify(a.exposedTo) === JSON.stringify(b.exposedTo);\n\n/**\n * Joins the registration under `prefix` on `modelContext`, opening it when there is none. The\n * member's rules count from the next tool call on; `settings` count only for the member that\n * opens -- a later member with other values is reported and joins under the opener's, because\n * `exposedTo` has gone to the platform by then and one set of `limits` is all a tool has.\n */\nexport function joinSharedExposure(\n modelContext: ModelContextLike,\n prefix: string,\n member: ExposureMember,\n settings: ExposureSettings,\n): ExposureMembership {\n let byPrefix = registry.get(modelContext);\n if (byPrefix === undefined) {\n byPrefix = new Map();\n registry.set(modelContext, byPrefix);\n }\n\n let exposure = byPrefix.get(prefix);\n if (exposure === undefined) {\n exposure = open(modelContext, prefix, settings);\n byPrefix.set(prefix, exposure);\n } else if (!sameSettings(exposure.settings, settings)) {\n logger.warn(\n `the tools under \"${prefix}\" are already registered with other limits or exposedTo; the values of the first call apply`,\n {inEffect: exposure.settings, ignored: settings},\n );\n }\n\n const joined = exposure;\n joined.members.add(member);\n let left = false;\n return {\n tools: joined.tools,\n leave() {\n if (left) return;\n left = true;\n joined.members.delete(member);\n if (joined.members.size === 0) close(modelContext, prefix, joined);\n },\n };\n}\n"],
5
+ "mappings": "AAEA,SAAQ,qBAAoB;AAE5B,SAA+C,yBAAwB;AACvE,SAA8C,4BAA2B;AACzE,SAAQ,mBAAkB;AAsC1B,MAAM,WAAW,oBAAI,QAAiD;AAEtE,MAAM,SAAS,IAAI,cAAc,cAAc;AAM/C,MAAM,kBAAkB,CAAC,YAAoF;AAC3G,QAAM,aAAiD,CAAC;AACxD,aAAW,UAAU,SAAS;AAC5B,UAAM,YAAY,qBAAqB,OAAO,UAAU;AACxD,QAAI,cAAc,OAAW,QAAO;AACpC,eAAW,KAAK,SAAS;AAAA,EAC3B;AACA,SAAO,CAAC,OAAO,WAAW,KAAK,CAAC,YAAY,QAAQ,EAAE,CAAC;AACzD;AAMA,MAAM,iBAAiB,CAAC,YAAmE;AACzF,QAAM,aAAgC,CAAC;AACvC,aAAW,UAAU,SAAS;AAC5B,UAAM,YAAY,kBAAkB,OAAO,WAAW;AACtD,QAAI,cAAc,OAAW,YAAW,KAAK,SAAS;AAAA,EACxD;AACA,MAAI,WAAW,WAAW,EAAG,QAA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C,QAAgB,aAA6B;AAC1F,MAAI,SAAS,OAAQ;AACrB,WAAS,SAAS;AAClB,WAAS,WAAW,MAAM;AAC1B,QAAM,WAAW,SAAS,IAAI,YAAY;AAC1C,MAAI,UAAU,IAAI,MAAM,MAAM,SAAU,UAAS,OAAO,MAAM;AAChE;AAEA,MAAM,eAAe,CAAC,GAAqB,MACzC,KAAK,UAAU,EAAE,MAAM,MAAM,KAAK,UAAU,EAAE,MAAM,KAAK,KAAK,UAAU,EAAE,SAAS,MAAM,KAAK,UAAU,EAAE,SAAS;AAQ9G,SAAS,mBACd,cACA,QACA,QACA,UACoB;AACpB,MAAI,WAAW,SAAS,IAAI,YAAY;AACxC,MAAI,aAAa,QAAW;AAC1B,eAAW,oBAAI,IAAI;AACnB,aAAS,IAAI,cAAc,QAAQ;AAAA,EACrC;AAEA,MAAI,WAAW,SAAS,IAAI,MAAM;AAClC,MAAI,aAAa,QAAW;AAC1B,eAAW,KAAK,cAAc,QAAQ,QAAQ;AAC9C,aAAS,IAAI,QAAQ,QAAQ;AAAA,EAC/B,WAAW,CAAC,aAAa,SAAS,UAAU,QAAQ,GAAG;AACrD,WAAO;AAAA,MACL,oBAAoB,MAAM;AAAA,MAC1B,EAAC,UAAU,SAAS,UAAU,SAAS,SAAQ;AAAA,IACjD;AAAA,EACF;AAEA,QAAM,SAAS;AACf,SAAO,QAAQ,IAAI,MAAM;AACzB,MAAI,OAAO;AACX,SAAO;AAAA,IACL,OAAO,OAAO;AAAA,IACd,QAAQ;AACN,UAAI,KAAM;AACV,aAAO;AACP,aAAO,QAAQ,OAAO,MAAM;AAC5B,UAAI,OAAO,QAAQ,SAAS,EAAG,OAAM,cAAc,QAAQ,MAAM;AAAA,IACnE;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,72 @@
1
+ import type { EnvSnapshot, InspectInclude, InspectRequest } from '../inspect/types.js';
2
+ import type { NamespaceType } from '../types.js';
3
+ import type { ModelContextToolAnnotations, ModelContextToolLike, ModelContextToolResult } from './ModelContextLike.js';
4
+ import { type RedactPredicate } from './redactProps.js';
5
+ /** What every tool shares: the name prefix, the defaults of the exposure, and the redaction rule. */
6
+ export interface ToolContext {
7
+ prefix: string;
8
+ /** Defaults for every call; the call's own input wins field by field. */
9
+ limits: Partial<InspectRequest>;
10
+ redact: RedactPredicate | undefined;
11
+ /** Which environments the tools see, by the namespace each is registered under; `undefined` means every one. */
12
+ isExposed: ((ns: NamespaceType) => boolean) | undefined;
13
+ }
14
+ /** Every tool declares both: nothing here writes, and every value may be what a user typed. */
15
+ export declare const ReadOnlyAnnotations: Readonly<ModelContextToolAnnotations>;
16
+ /** The global namespace as a tool names it: the description of its symbol, the same string `EnvSnapshot.namespace` carries. */
17
+ export declare const GlobalNamespaceName: string;
18
+ /** The namespace a tool input names, as `ShadowEnv.get()` takes it. */
19
+ export declare const toNamespace: (name: string) => NamespaceType;
20
+ /** Which environments an exposure covers: a list of namespaces, or a predicate over the namespace an environment is registered under. */
21
+ export type NamespaceRule = NamespaceType[] | ((ns: NamespaceType) => boolean);
22
+ export declare const toNamespacePredicate: (rule: NamespaceRule | undefined) => ((ns: NamespaceType) => boolean) | undefined;
23
+ export declare const NamespaceInputSchema: Readonly<{
24
+ type: "string";
25
+ description: `The namespace of one Shadow Environment, as the list-envs tool reports it; the global namespace is "${string}". Without it, every environment answers.`;
26
+ }>;
27
+ /** A refusal the tool can phrase. `runTool()` turns it into an error result with the bare message. */
28
+ export declare class ToolError extends Error {
29
+ name: string;
30
+ }
31
+ /**
32
+ * A typed reader over whatever the platform handed to `execute`: anything but an object reads as
33
+ * empty, a missing or `null` field is `undefined`, a field of the wrong type is a `ToolError`.
34
+ */
35
+ export declare class ToolInput {
36
+ #private;
37
+ constructor(input: unknown);
38
+ string(key: string): string | undefined;
39
+ requiredString(key: string): string;
40
+ number(key: string): number | undefined;
41
+ stringList(key: string): string[] | undefined;
42
+ }
43
+ export declare const readInclude: (input: ToolInput) => InspectInclude[] | undefined;
44
+ export declare const textResult: (summary: string, structured: Record<string, unknown>) => ModelContextToolResult;
45
+ export declare const errorResult: (message: string) => ModelContextToolResult;
46
+ /**
47
+ * Wraps a tool body. The input is read through `ToolInput`; a refused input and a failure inside
48
+ * the environment come back as an error result, so the wording reaches the agent -- a platform
49
+ * that sees a rejection reports a generic failure and drops the message. Only the caller's own
50
+ * abort rejects.
51
+ */
52
+ export declare const runTool: (body: (input: ToolInput, signal: AbortSignal | undefined) => Promise<ModelContextToolResult>) => (input: unknown, options?: {
53
+ signal?: AbortSignal;
54
+ }) => Promise<ModelContextToolResult>;
55
+ /** The request of one call: the exposure's defaults under the call's own fields, `values` merged one level down. */
56
+ export declare const buildRequest: (limits: Partial<InspectRequest>, own: InspectRequest) => InspectRequest;
57
+ /**
58
+ * The environments a call addresses -- one by namespace, or every one that holds a namespace --
59
+ * each described by `ShadowEnv.inspect()` and redacted where the exposure asks for it. An
60
+ * unknown namespace is a `ToolError`; an environment that cannot answer costs its own entry,
61
+ * with the reason under `error`, exactly as `inspectAll()` reports it.
62
+ *
63
+ * A namespace the exposure does not cover is refused with the same words as an unknown one, so an
64
+ * agent cannot tell the two apart. Both rules are read once, at the top: an exposure whose members
65
+ * change answers every call from the set it had when the call began.
66
+ */
67
+ export declare const inspectEnvs: (namespace: string | undefined, request: InspectRequest, signal: AbortSignal | undefined, ctx: ToolContext) => Promise<EnvSnapshot[]>;
68
+ /** One line per environment, for the text half of a result. */
69
+ export declare const describeEnv: (s: EnvSnapshot) => string;
70
+ export declare const NoEnvironments = "no Shadow Environment holds a namespace";
71
+ export declare const defineTool: (ctx: ToolContext, name: string, tool: Omit<ModelContextToolLike, 'name' | 'annotations'>) => ModelContextToolLike;
72
+ //# sourceMappingURL=toolSupport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolSupport.d.ts","sourceRoot":"","sources":["../../../src/model-context/toolSupport.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,WAAW,EAAE,cAAc,EAAE,cAA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shot } from "./redactProps.js";
4
+ const ReadOnlyAnnotations = Object.freeze({
5
+ readOnlyHint: true,
6
+ untrustedContentHint: true
7
+ });
8
+ const namespaceName = (ns) => typeof ns === "symbol" ? ns.description ?? "" : ns;
9
+ const GlobalNamespaceName = namespaceName(GlobalNS);
10
+ const toNamespace = (name) => name === GlobalNamespaceName ? GlobalNS : name;
11
+ const toNamespacePredicate = (rule) => {
12
+ if (rule === void 0) return void 0;
13
+ if (typeof rule === "function") return rule;
14
+ const names = new Set(rule);
15
+ return (ns) => names.has(ns);
16
+ };
17
+ const NamespaceInputSchema = Object.freeze({
18
+ type: "string",
19
+ description: `The namespace of one Shadow Environment, as the list-envs tool reports it; the global namespace is "${GlobalNamespaceName}". Without it, every environment answers.`
20
+ });
21
+ class ToolError extends Error {
22
+ constructor() {
23
+ super(...arguments);
24
+ this.name = "ToolError";
25
+ }
26
+ }
27
+ class ToolInput {
28
+ #raw;
29
+ constructor(input) {
30
+ this.#raw = typeof input === "object" && input !== null ? input : {};
31
+ }
32
+ string(key) {
33
+ const val = this.#raw[key];
34
+ if (val === void 0 || val === null) return void 0;
35
+ if (typeof val !== "string") throw new ToolError(`"${key}" must be a string`);
36
+ return val;
37
+ }
38
+ requiredString(key) {
39
+ const val = this.string(key);
40
+ if (val === void 0 || val === "") throw new ToolError(`"${key}" is required`);
41
+ return val;
42
+ }
43
+ number(key) {
44
+ const val = this.#raw[key];
45
+ if (val === void 0 || val === null) return void 0;
46
+ if (typeof val !== "number" || Number.isNaN(val)) throw new ToolError(`"${key}" must be a number`);
47
+ return val;
48
+ }
49
+ stringList(key) {
50
+ const val = this.#raw[key];
51
+ if (val === void 0 || val === null) return void 0;
52
+ if (!Array.isArray(val) || !val.every((item) => typeof item === "string")) {
53
+ throw new ToolError(`"${key}" must be a list of strings`);
54
+ }
55
+ return val;
56
+ }
57
+ }
58
+ const Includes = ["props", "shadowObjects", "contexts", "registry"];
59
+ const readInclude = (input) => {
60
+ const list = input.stringList("include");
61
+ if (list === void 0) return void 0;
62
+ for (const item of list) {
63
+ if (!Includes.includes(item)) {
64
+ throw new ToolError(`"include" knows only ${Includes.join(", ")}; got "${item}"`);
65
+ }
66
+ }
67
+ return list;
68
+ };
69
+ const textResult = (summary, structured) => ({
70
+ content: [{ type: "text", text: `${summary}
71
+
72
+ ${JSON.stringify(structured)}` }],
73
+ structuredContent: structured
74
+ });
75
+ const errorResult = (message) => ({
76
+ content: [{ type: "text", text: message }],
77
+ isError: true
78
+ });
79
+ const describeFailure = (error) => {
80
+ if (error instanceof ToolError) return error.message;
81
+ if (error instanceof Error) return `${error.name}: ${error.message}`;
82
+ return String(error);
83
+ };
84
+ const runTool = (body) => async (input, options) => {
85
+ const signal = options?.signal;
86
+ try {
87
+ return await body(new ToolInput(input), signal);
88
+ } catch (error) {
89
+ if (signal?.aborted) throw error;
90
+ return errorResult(describeFailure(error));
91
+ }
92
+ };
93
+ const buildRequest = (limits, own) => {
94
+ const request = { ...limits, ...own };
95
+ if (limits.values !== void 0 || own.values !== void 0) request.values = { ...limits.values, ...own.values };
96
+ return request;
97
+ };
98
+ const inspectEnvs = async (namespace, request, signal, ctx) => {
99
+ const only = ctx.isExposed;
100
+ const redact = ctx.redact;
101
+ let snapshots;
102
+ if (namespace === void 0) {
103
+ snapshots = await ShadowEnv.inspectAll(request, signal, only);
104
+ } else {
105
+ const ns = toNamespace(namespace);
106
+ const env = only === void 0 || only(ns) ? ShadowEnv.get(ns) : void 0;
107
+ if (env === void 0) throw new ToolError(`no Shadow Environment holds the namespace "${namespace}"`);
108
+ snapshots = [await env.inspect(request, signal)];
109
+ }
110
+ if (redact !== void 0) {
111
+ for (const snapshot of snapshots) redactSnapshot(snapshot, redact);
112
+ }
113
+ return snapshots;
114
+ };
115
+ const describeEnv = (s) => {
116
+ const parts = [s.kind, s.state.isReady ? "ready" : "not ready"];
117
+ if (s.kernel !== void 0) parts.push(`${s.kernel.counts.entities} entities`);
118
+ if (s.error !== void 0) parts.push(`error: ${s.error.name}: ${s.error.message}`);
119
+ return `${s.namespace} (${parts.join(", ")})`;
120
+ };
121
+ const NoEnvironments = "no Shadow Environment holds a namespace";
122
+ const defineTool = (ctx, name, tool) => ({
123
+ name: `${ctx.prefix}${name}`,
124
+ annotations: { ...ReadOnlyAnnotations },
125
+ ...tool
126
+ });
127
+ export {
128
+ GlobalNamespaceName,
129
+ NamespaceInputSchema,
130
+ NoEnvironments,
131
+ ReadOnlyAnnotations,
132
+ ToolError,
133
+ ToolInput,
134
+ buildRequest,
135
+ defineTool,
136
+ describeEnv,
137
+ errorResult,
138
+ inspectEnvs,
139
+ readInclude,
140
+ runTool,
141
+ textResult,
142
+ toNamespace,
143
+ toNamespacePredicate
144
+ };
145
+ //# sourceMappingURL=toolSupport.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/model-context/toolSupport.ts"],
4
+ "sourcesContent": ["import {GlobalNS} from '../constants.js';\nimport type {EnvSnapshot, InspectInclude, InspectRequest} from '../inspect/types.js';\nimport type {NamespaceType} from '../types.js';\nimport {ShadowEnv} from '../view/ShadowEnv.js';\nimport type {ModelContextToolAnnotations, ModelContextToolLike, ModelContextToolResult} from './ModelContextLike.js';\nimport {type RedactPredicate, redactSnapshot} from './redactProps.js';\n\n/** What every tool shares: the name prefix, the defaults of the exposure, and the redaction rule. */\nexport interface ToolContext {\n prefix: string;\n /** Defaults for every call; the call's own input wins field by field. */\n limits: Partial<InspectRequest>;\n redact: RedactPredicate | undefined;\n /** Which environments the tools see, by the namespace each is registered under; `undefined` means every one. */\n isExposed: ((ns: NamespaceType) => boolean) | undefined;\n}\n\n/** Every tool declares both: nothing here writes, and every value may be what a user typed. */\nexport const ReadOnlyAnnotations: Readonly<ModelContextToolAnnotations> = Object.freeze({\n readOnlyHint: true,\n untrustedContentHint: true,\n});\n\nconst namespaceName = (ns: NamespaceType): string => (typeof ns === 'symbol' ? (ns.description ?? '') : ns);\n\n/** The global namespace as a tool names it: the description of its symbol, the same string `EnvSnapshot.namespace` carries. */\nexport const GlobalNamespaceName: string = namespaceName(GlobalNS);\n\n/** The namespace a tool input names, as `ShadowEnv.get()` takes it. */\nexport const toNamespace = (name: string): NamespaceType => (name === GlobalNamespaceName ? GlobalNS : name);\n\n/** Which environments an exposure covers: a list of namespaces, or a predicate over the namespace an environment is registered under. */\nexport type NamespaceRule = NamespaceType[] | ((ns: NamespaceType) => boolean);\n\nexport const toNamespacePredicate = (rule: NamespaceRule | undefined): ((ns: NamespaceType) => boolean) | undefined => {\n if (rule === undefined) return undefined;\n if (typeof rule === 'function') return rule;\n const names = new Set<NamespaceType>(rule);\n return (ns) => names.has(ns);\n};\n\nexport const NamespaceInputSchema = Object.freeze({\n type: 'string',\n description: `The namespace of one Shadow Environment, as the list-envs tool reports it; the global namespace is \"${GlobalNamespaceName}\". Without it, every environment answers.`,\n});\n\n/** A refusal the tool can phrase. `runTool()` turns it into an error result with the bare message. */\nexport class ToolError extends Error {\n override name = 'ToolError';\n}\n\n/**\n * A typed reader over whatever the platform handed to `execute`: anything but an object reads as\n * empty, a missing or `null` field is `undefined`, a field of the wrong type is a `ToolError`.\n */\nexport class ToolInput {\n readonly #raw: Record<string, unknown>;\n\n constructor(input: unknown) {\n this.#raw = typeof input === 'object' && input !== null ? (input as Record<string, unknown>) : {};\n }\n\n string(key: string): string | undefined {\n const val = this.#raw[key];\n if (val === undefined || val === null) return undefined;\n if (typeof val !== 'string') throw new ToolError(`\"${key}\" must be a string`);\n return val;\n }\n\n requiredString(key: string): string {\n const val = this.string(key);\n if (val === undefined || val === '') throw new ToolError(`\"${key}\" is required`);\n return val;\n }\n\n number(key: string): number | undefined {\n const val = this.#raw[key];\n if (val === undefined || val === null) return undefined;\n if (typeof val !== 'number' || Number.isNaN(val)) throw new ToolError(`\"${key}\" must be a number`);\n return val;\n }\n\n stringList(key: string): string[] | undefined {\n const val = this.#raw[key];\n if (val === undefined || val === null) return undefined;\n if (!Array.isArray(val) || !val.every((item) => typeof item === 'string')) {\n throw new ToolError(`\"${key}\" must be a list of strings`);\n }\n return val as string[];\n }\n}\n\nconst Includes: readonly InspectInclude[] = ['props', 'shadowObjects', 'contexts', 'registry'];\n\nexport const readInclude = (input: ToolInput): InspectInclude[] | undefined => {\n const list = input.stringList('include');\n if (list === undefined) return undefined;\n for (const item of list) {\n if (!(Includes as readonly string[]).includes(item)) {\n throw new ToolError(`\"include\" knows only ${Includes.join(', ')}; got \"${item}\"`);\n }\n }\n return list as InspectInclude[];\n};\n\nexport const textResult = (summary: string, structured: Record<string, unknown>): ModelContextToolResult => ({\n content: [{type: 'text', text: `${summary}\\n\\n${JSON.stringify(structured)}`}],\n structuredContent: structured,\n});\n\nexport const errorResult = (message: string): ModelContextToolResult => ({\n content: [{type: 'text', text: message}],\n isError: true,\n});\n\nconst describeFailure = (error: unknown): string => {\n if (error instanceof ToolError) return error.message;\n if (error instanceof Error) return `${error.name}: ${error.message}`;\n return String(error);\n};\n\n/**\n * Wraps a tool body. The input is read through `ToolInput`; a refused input and a failure inside\n * the environment come back as an error result, so the wording reaches the agent -- a platform\n * that sees a rejection reports a generic failure and drops the message. Only the caller's own\n * abort rejects.\n */\nexport const runTool =\n (body: (input: ToolInput, signal: AbortSignal | undefined) => Promise<ModelContextToolResult>) =>\n async (input: unknown, options?: {signal?: AbortSignal}): Promise<ModelContextToolResult> => {\n const signal = options?.signal;\n try {\n return await body(new ToolInput(input), signal);\n } catch (error) {\n if (signal?.aborted) throw error;\n return errorResult(describeFailure(error));\n }\n };\n\n/** The request of one call: the exposure's defaults under the call's own fields, `values` merged one level down. */\nexport const buildRequest = (limits: Partial<InspectRequest>, own: InspectRequest): InspectRequest => {\n const request: InspectRequest = {...limits, ...own};\n if (limits.values !== undefined || own.values !== undefined) request.values = {...limits.values, ...own.values};\n return request;\n};\n\n/**\n * The environments a call addresses -- one by namespace, or every one that holds a namespace --\n * each described by `ShadowEnv.inspect()` and redacted where the exposure asks for it. An\n * unknown namespace is a `ToolError`; an environment that cannot answer costs its own entry,\n * with the reason under `error`, exactly as `inspectAll()` reports it.\n *\n * A namespace the exposure does not cover is refused with the same words as an unknown one, so an\n * agent cannot tell the two apart. Both rules are read once, at the top: an exposure whose members\n * change answers every call from the set it had when the call began.\n */\nexport const inspectEnvs = async (\n namespace: string | undefined,\n request: InspectRequest,\n signal: AbortSignal | undefined,\n ctx: ToolContext,\n): Promise<EnvSnapshot[]> => {\n const only = ctx.isExposed;\n const redact = ctx.redact;\n\n let snapshots: EnvSnapshot[];\n if (namespace === undefined) {\n snapshots = await ShadowEnv.inspectAll(request, signal, only);\n } else {\n const ns = toNamespace(namespace);\n const env = only === undefined || only(ns) ? ShadowEnv.get(ns) : undefined;\n if (env === undefined) throw new ToolError(`no Shadow Environment holds the namespace \"${namespace}\"`);\n snapshots = [await env.inspect(request, signal)];\n }\n if (redact !== undefined) {\n for (const snapshot of snapshots) redactSnapshot(snapshot, redact);\n }\n return snapshots;\n};\n\n/** One line per environment, for the text half of a result. */\nexport const describeEnv = (s: EnvSnapshot): string => {\n const parts = [s.kind, s.state.isReady ? 'ready' : 'not ready'];\n if (s.kernel !== undefined) parts.push(`${s.kernel.counts.entities} entities`);\n if (s.error !== undefined) parts.push(`error: ${s.error.name}: ${s.error.message}`);\n return `${s.namespace} (${parts.join(', ')})`;\n};\n\nexport const NoEnvironments = 'no Shadow Environment holds a namespace';\n\nexport const defineTool = (\n ctx: ToolContext,\n name: string,\n tool: Omit<ModelContextToolLike, 'name' | 'annotations'>,\n): ModelContextToolLike => ({\n name: `${ctx.prefix}${name}`,\n annotations: {...ReadOnlyAnnotations},\n ...tool,\n});\n"],
5
+ "mappings": "AAAA,SAAQ,gBAAe;AAGvB,SAAQ,iBAAgB;AAExB,SAA8B,sBAAqB;AAa5C,MAAM,sBAA6D,OAAO,OAAO;AAAA,EACtF,cAAc;AAAA,EACd,sBAAsB;AACxB,CAAC;AAED,MAAM,gBAAgB,CAAC,OAA+B,OAAO,OAAO,WAAY,GAAG,eAAe,KAAM;AAG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AAG,IAAI;AAAA,EAC1B,aAAa,EAAC,GAAG,oBAAmB;AAAA,EACpC,GAAG;AACL;",
6
+ "names": []
7
+ }
@@ -0,0 +1,15 @@
1
+ import type { EntityMatch } from '../../inspect/types.js';
2
+ import type { ModelContextToolLike } from '../ModelContextLike.js';
3
+ import { type ToolContext } from '../toolSupport.js';
4
+ export interface FindEntitiesEntry {
5
+ namespace: string;
6
+ matches: EntityMatch[];
7
+ /** How many matched before the limit. */
8
+ total: number;
9
+ error?: {
10
+ name: string;
11
+ message: string;
12
+ };
13
+ }
14
+ export declare const createFindEntitiesTool: (ctx: ToolContext) => ModelContextToolLike;
15
+ //# sourceMappingURL=findEntities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findEntities.d.ts","sourceRoot":"","sources":["../../../../src/model-context/tools/findEntities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,WAAW,EAAC,MAAM,wBAAwB,CAAC;AACtE,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAOL,KAAK,WAAW,EAGjB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC,CAAC;CACzC;AAED,eAAO,MAAM,sBAAsB,QAAS,WAAW,KAAG,oBAkEtD,CAAC"}
@@ -0,0 +1,71 @@
1
+ import {
2
+ buildRequest,
3
+ defineTool,
4
+ inspectEnvs,
5
+ NamespaceInputSchema,
6
+ NoEnvironments,
7
+ runTool,
8
+ ToolError,
9
+ textResult
10
+ } from "../toolSupport.js";
11
+ const createFindEntitiesTool = (ctx) => defineTool(ctx, "find-entities", {
12
+ title: "Find Entities",
13
+ description: "Search the Entity Tree of one Shadow Environment, or of every one, so that the answer stays small: every Entity that meets all given criteria, as uuid, token and the token path from the root. At least one criterion. The search runs where the Kernel runs and ships the matches, not the tree.",
14
+ inputSchema: {
15
+ type: "object",
16
+ properties: {
17
+ namespace: NamespaceInputSchema,
18
+ token: { type: "string", description: "The token of the Entity, exact." },
19
+ propName: { type: "string", description: "A property name the Entity carries." },
20
+ shadowObject: { type: "string", description: "The display name of a Shadow Object attached to the Entity." },
21
+ contextName: { type: "string", description: "A string Entity Context name the Entity uses or provides." },
22
+ limit: {
23
+ type: "integer",
24
+ minimum: 1,
25
+ description: "How many matches to carry. Default 50; total counts every match regardless."
26
+ }
27
+ },
28
+ additionalProperties: false
29
+ },
30
+ execute: runTool(async (input, signal) => {
31
+ const filter = {};
32
+ const token = input.string("token");
33
+ if (token !== void 0) filter.token = token;
34
+ const propName = input.string("propName");
35
+ if (propName !== void 0) filter.propName = propName;
36
+ const shadowObject = input.string("shadowObject");
37
+ if (shadowObject !== void 0) filter.shadowObject = shadowObject;
38
+ const contextName = input.string("contextName");
39
+ if (contextName !== void 0) filter.contextName = contextName;
40
+ const limit = input.number("limit");
41
+ if (limit !== void 0) filter.limit = limit;
42
+ if (token === void 0 && propName === void 0 && shadowObject === void 0 && contextName === void 0) {
43
+ throw new ToolError("at least one of token, propName, shadowObject, contextName is required");
44
+ }
45
+ const envs = await inspectEnvs(
46
+ input.string("namespace"),
47
+ buildRequest(ctx.limits, { filter, maxDepth: 0, maxNodes: 1, include: [] }),
48
+ signal,
49
+ ctx
50
+ );
51
+ const results = envs.map((s) => {
52
+ const entry = {
53
+ namespace: s.namespace,
54
+ matches: s.kernel?.search?.matches ?? [],
55
+ total: s.kernel?.search?.total ?? 0
56
+ };
57
+ if (s.error !== void 0) entry.error = s.error;
58
+ return entry;
59
+ });
60
+ const summary = results.map((r) => {
61
+ const carried = r.matches.length < r.total ? `, ${r.matches.length} carried` : "";
62
+ const failed = r.error === void 0 ? "" : ` (error: ${r.error.name}: ${r.error.message})`;
63
+ return `${r.namespace}: ${r.total} match${r.total === 1 ? "" : "es"}${carried}${failed}`;
64
+ }).join("; ");
65
+ return textResult(summary || NoEnvironments, { results });
66
+ })
67
+ });
68
+ export {
69
+ createFindEntitiesTool
70
+ };
71
+ //# sourceMappingURL=findEntities.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/model-context/tools/findEntities.ts"],
4
+ "sourcesContent": ["import type {EntityFilter, EntityMatch} from '../../inspect/types.js';\nimport type {ModelContextToolLike} from '../ModelContextLike.js';\nimport {\n buildRequest,\n defineTool,\n inspectEnvs,\n NamespaceInputSchema,\n NoEnvironments,\n runTool,\n type ToolContext,\n ToolError,\n textResult,\n} from '../toolSupport.js';\n\nexport interface FindEntitiesEntry {\n namespace: string;\n matches: EntityMatch[];\n /** How many matched before the limit. */\n total: number;\n error?: {name: string; message: string};\n}\n\nexport const createFindEntitiesTool = (ctx: ToolContext): ModelContextToolLike =>\n defineTool(ctx, 'find-entities', {\n title: 'Find Entities',\n description:\n 'Search the Entity Tree of one Shadow Environment, or of every one, so that the answer stays small: every Entity that meets all given criteria, as uuid, token and the token path from the root. At least one criterion. The search runs where the Kernel runs and ships the matches, not the tree.',\n inputSchema: {\n type: 'object',\n properties: {\n namespace: NamespaceInputSchema,\n token: {type: 'string', description: 'The token of the Entity, exact.'},\n propName: {type: 'string', description: 'A property name the Entity carries.'},\n shadowObject: {type: 'string', description: 'The display name of a Shadow Object attached to the Entity.'},\n contextName: {type: 'string', description: 'A string Entity Context name the Entity uses or provides.'},\n limit: {\n type: 'integer',\n minimum: 1,\n description: 'How many matches to carry. Default 50; total counts every match regardless.',\n },\n },\n additionalProperties: false,\n },\n execute: runTool(async (input, signal) => {\n const filter: EntityFilter = {};\n const token = input.string('token');\n if (token !== undefined) filter.token = token;\n const propName = input.string('propName');\n if (propName !== undefined) filter.propName = propName;\n const shadowObject = input.string('shadowObject');\n if (shadowObject !== undefined) filter.shadowObject = shadowObject;\n const contextName = input.string('contextName');\n if (contextName !== undefined) filter.contextName = contextName;\n const limit = input.number('limit');\n if (limit !== undefined) filter.limit = limit;\n\n if (token === undefined && propName === undefined && shadowObject === undefined && contextName === undefined) {\n throw new ToolError('at least one of token, propName, shadowObject, contextName is required');\n }\n\n // the Kernel side ignores the walk limits under a filter; they cut the View half, which\n // this tool does not report, to the least the request allows\n const envs = await inspectEnvs(\n input.string('namespace'),\n buildRequest(ctx.limits, {filter, maxDepth: 0, maxNodes: 1, include: []}),\n signal,\n ctx,\n );\n\n const results = envs.map((s) => {\n const entry: FindEntitiesEntry = {\n namespace: s.namespace,\n matches: s.kernel?.search?.matches ?? [],\n total: s.kernel?.search?.total ?? 0,\n };\n if (s.error !== undefined) entry.error = s.error;\n return entry;\n });\n\n const summary = results\n .map((r) => {\n const carried = r.matches.length < r.total ? `, ${r.matches.length} carried` : '';\n const failed = r.error === undefined ? '' : ` (error: ${r.error.name}: ${r.error.message})`;\n return `${r.namespace}: ${r.total} match${r.total === 1 ? '' : 'es'}${carried}${failed}`;\n })\n .join('; ');\n return textResult(summary || NoEnvironments, {results});\n }),\n });\n"],
5
+ "mappings": "AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AAUA,MAAM,yBAAyB,CAAC,QACrC,WAAW,KAAK,iBAAiB;AAAA,EAC/B,OAAO;AAAA,EACP,aACE;AAAA,EACF,aAAa;AAAA,IACX,MAAM;AAAA,IACN,YAAY;AAAA,MACV,WAAW;AAAA,MACX,OAAO,EAAC,MAAM,UAAU,aAAa,kCAAiC;AAAA,MACtE,UAAU,EAAC,MAAM,UAAU,aAAa,sCAAqC;AAAA,MAC7E,cAAc,EAAC,MAAM,UAAU,aAAa,8DAA6D;AAAA,MACzG,aAAa,EAAC,MAAM,UAAU,aAAa,4DAA2D;AAAA,MACtG,OAAO;AAAA,QACL,MAAM;AAAA,Q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AAU,SAAY,KAAK,YAAY,EAAE,MAAM,IAAI,KAAK,EAAE,MAAM,OAAO;AACxF,aAAO,GAAG,EAAE,SAAS,KAAK,EAAE,KAAK,SAAS,EAAE,UAAU,IAAI,KAAK,IAAI,GAAG,OAAO,GAAG,MAAM;AAAA,IACxF,CAAC,EACA,KAAK,IAAI;AACZ,WAAO,WAAW,WAAW,gBAAgB,EAAC,QAAO,CAAC;AAAA,EACxD,CAAC;AACH,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,16 @@
1
+ import type { EntityNodeSnapshot, TruncationNote, ViewComponentSnapshot } from '../../inspect/types.js';
2
+ import type { ModelContextToolLike } from '../ModelContextLike.js';
3
+ import { type ToolContext } from '../toolSupport.js';
4
+ /** One Entity in one environment, with the chain above it and the View's component of the same uuid. */
5
+ export interface EntityMatchEntry {
6
+ namespace: string;
7
+ entity: Omit<EntityNodeSnapshot, 'ancestors'>;
8
+ ancestors: {
9
+ uuid: string;
10
+ token: string;
11
+ }[];
12
+ view?: ViewComponentSnapshot;
13
+ truncation?: TruncationNote[];
14
+ }
15
+ export declare const createGetEntityTool: (ctx: ToolContext) => ModelContextToolLike;
16
+ //# sourceMappingURL=getEntity.d.ts.map