@framers/agentos 0.15.63 → 0.15.65

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 (336) hide show
  1. package/.github/badges/tests.json +1 -1
  2. package/README.md +2 -2
  3. package/dist/agents/agency/AgencyMemoryManager.d.ts +3 -3
  4. package/dist/agents/agency/AgencyRegistry.d.ts +11 -1
  5. package/dist/agents/agency/AgencyRegistry.d.ts.map +1 -1
  6. package/dist/agents/agency/AgencyRegistry.js +38 -0
  7. package/dist/agents/agency/AgencyRegistry.js.map +1 -1
  8. package/dist/agents/agency/AgentCommunicationBus.d.ts +2 -2
  9. package/dist/agents/agency/index.d.ts +6 -6
  10. package/dist/agents/definitions/AgentCore.d.ts +11 -11
  11. package/dist/agents/definitions/AgentFactory.d.ts +3 -3
  12. package/dist/agents/definitions/AgentPoolAgent.d.ts +9 -9
  13. package/dist/agents/definitions/AgentPoolConfig.d.ts +2 -2
  14. package/dist/agents/definitions/IAgent.d.ts +4 -4
  15. package/dist/agents/definitions/IAgentFactory.d.ts +6 -6
  16. package/dist/api/AgentOS.d.ts +65 -44
  17. package/dist/api/AgentOS.d.ts.map +1 -1
  18. package/dist/api/AgentOS.js +43 -0
  19. package/dist/api/AgentOS.js.map +1 -1
  20. package/dist/api/agent.d.ts +9 -6
  21. package/dist/api/agent.d.ts.map +1 -1
  22. package/dist/api/agent.js.map +1 -1
  23. package/dist/api/embedText.d.ts +1 -1
  24. package/dist/api/gmi.d.ts.map +1 -1
  25. package/dist/api/gmi.js +27 -14
  26. package/dist/api/gmi.js.map +1 -1
  27. package/dist/api/hitl.d.ts +1 -1
  28. package/dist/api/index.d.ts +2 -1
  29. package/dist/api/index.d.ts.map +1 -1
  30. package/dist/api/index.js.map +1 -1
  31. package/dist/api/interfaces/IAgentOS.d.ts +16 -16
  32. package/dist/api/interfaces/IUnifiedAgent.d.ts +3 -3
  33. package/dist/api/runtime/AgentOSOrchestrator.d.ts +9 -9
  34. package/dist/api/runtime/CapabilityDiscoveryInitializer.d.ts +9 -9
  35. package/dist/api/runtime/ExternalToolResultHandler.d.ts +10 -10
  36. package/dist/api/runtime/GMIChunkTransformer.d.ts +6 -6
  37. package/dist/api/runtime/RagMemoryInitializer.d.ts +6 -6
  38. package/dist/api/runtime/SelfImprovementSessionManager.d.ts +4 -4
  39. package/dist/api/runtime/StreamChunkEmitter.d.ts +2 -2
  40. package/dist/api/runtime/TaskOutcomeTelemetryManager.d.ts +3 -3
  41. package/dist/api/runtime/TurnExecutionPipeline.d.ts +12 -12
  42. package/dist/api/runtime/WorkflowFacade.d.ts +16 -10
  43. package/dist/api/runtime/WorkflowFacade.d.ts.map +1 -1
  44. package/dist/api/runtime/WorkflowFacade.js +7 -0
  45. package/dist/api/runtime/WorkflowFacade.js.map +1 -1
  46. package/dist/api/runtime/agencyLaunch/gmiLaunchTool.d.ts +3 -2
  47. package/dist/api/runtime/agencyLaunch/gmiLaunchTool.d.ts.map +1 -1
  48. package/dist/api/runtime/agencyLaunch/gmiLaunchTool.js +122 -61
  49. package/dist/api/runtime/agencyLaunch/gmiLaunchTool.js.map +1 -1
  50. package/dist/api/runtime/agencyLaunch/index.d.ts +11 -0
  51. package/dist/api/runtime/agencyLaunch/index.d.ts.map +1 -0
  52. package/dist/api/runtime/agencyLaunch/index.js +11 -0
  53. package/dist/api/runtime/agencyLaunch/index.js.map +1 -0
  54. package/dist/api/runtime/agencyLaunch/launchRegistry.d.ts +4 -1
  55. package/dist/api/runtime/agencyLaunch/launchRegistry.d.ts.map +1 -1
  56. package/dist/api/runtime/agencyLaunch/launchRegistry.js.map +1 -1
  57. package/dist/api/runtime/agencyLaunch/meteredProviderManager.d.ts +13 -0
  58. package/dist/api/runtime/agencyLaunch/meteredProviderManager.d.ts.map +1 -1
  59. package/dist/api/runtime/agencyLaunch/meteredProviderManager.js +19 -0
  60. package/dist/api/runtime/agencyLaunch/meteredProviderManager.js.map +1 -1
  61. package/dist/api/runtime/agencyLaunch/runLaunch.d.ts +32 -3
  62. package/dist/api/runtime/agencyLaunch/runLaunch.d.ts.map +1 -1
  63. package/dist/api/runtime/agencyLaunch/runLaunch.js +57 -9
  64. package/dist/api/runtime/agencyLaunch/runLaunch.js.map +1 -1
  65. package/dist/api/runtime/agencyLaunch/runtimeLaunchTool.d.ts +84 -0
  66. package/dist/api/runtime/agencyLaunch/runtimeLaunchTool.d.ts.map +1 -0
  67. package/dist/api/runtime/agencyLaunch/runtimeLaunchTool.js +344 -0
  68. package/dist/api/runtime/agencyLaunch/runtimeLaunchTool.js.map +1 -0
  69. package/dist/api/runtime/agencyLaunch/runtimeSeat.d.ts +61 -0
  70. package/dist/api/runtime/agencyLaunch/runtimeSeat.d.ts.map +1 -0
  71. package/dist/api/runtime/agencyLaunch/runtimeSeat.js +277 -0
  72. package/dist/api/runtime/agencyLaunch/runtimeSeat.js.map +1 -0
  73. package/dist/api/runtime/agencyLaunch/seatToolView.d.ts +11 -0
  74. package/dist/api/runtime/agencyLaunch/seatToolView.d.ts.map +1 -0
  75. package/dist/api/runtime/agencyLaunch/seatToolView.js +69 -0
  76. package/dist/api/runtime/agencyLaunch/seatToolView.js.map +1 -0
  77. package/dist/api/runtime/agencyLaunch/types.d.ts +126 -13
  78. package/dist/api/runtime/agencyLaunch/types.d.ts.map +1 -1
  79. package/dist/api/runtime/agencyLaunch/types.js +102 -2
  80. package/dist/api/runtime/agencyLaunch/types.js.map +1 -1
  81. package/dist/api/runtime/capabilityContract.d.ts +7 -1
  82. package/dist/api/runtime/capabilityContract.d.ts.map +1 -1
  83. package/dist/api/runtime/capabilityContract.js +6 -0
  84. package/dist/api/runtime/capabilityContract.js.map +1 -1
  85. package/dist/api/runtime/externalToolPause.d.ts +2 -2
  86. package/dist/api/runtime/externalToolRegistry.d.ts +5 -5
  87. package/dist/api/runtime/global-default.d.ts +1 -1
  88. package/dist/api/runtime/gmiPersona.d.ts +6 -0
  89. package/dist/api/runtime/gmiPersona.d.ts.map +1 -1
  90. package/dist/api/runtime/gmiPersona.js +9 -1
  91. package/dist/api/runtime/gmiPersona.js.map +1 -1
  92. package/dist/api/runtime/gmiSession.d.ts +4 -3
  93. package/dist/api/runtime/gmiSession.d.ts.map +1 -1
  94. package/dist/api/runtime/gmiSession.js +1 -1
  95. package/dist/api/runtime/gmiSession.js.map +1 -1
  96. package/dist/api/runtime/lightweightAgentDiagnostics.d.ts +14 -6
  97. package/dist/api/runtime/lightweightAgentDiagnostics.d.ts.map +1 -1
  98. package/dist/api/runtime/lightweightAgentDiagnostics.js +10 -4
  99. package/dist/api/runtime/lightweightAgentDiagnostics.js.map +1 -1
  100. package/dist/api/runtime/personaLoaderResolution.d.ts +2 -2
  101. package/dist/api/runtime/processRequestWithExternalTools.d.ts +4 -4
  102. package/dist/api/runtime/processRequestWithRegisteredTools.d.ts +7 -7
  103. package/dist/api/runtime/resumeExternalToolRequestWithRegisteredTools.d.ts +8 -8
  104. package/dist/api/runtime/tool-emulation/activation.d.ts +1 -1
  105. package/dist/api/runtime/tool-emulation/history.d.ts +1 -1
  106. package/dist/api/runtime/tool-emulation/index.d.ts +5 -5
  107. package/dist/api/runtime/tool-emulation/loop.d.ts +2 -2
  108. package/dist/api/runtime/tool-emulation/renderer.d.ts +1 -1
  109. package/dist/api/runtime/toolCallGate.d.ts +2 -2
  110. package/dist/api/runtime/turn-phases/conversation-history.d.ts +3 -3
  111. package/dist/api/runtime/turn-phases/long-term-memory.d.ts +4 -4
  112. package/dist/api/runtime/turn-phases/prompt-profile.d.ts +2 -2
  113. package/dist/api/runtime/turn-phases/rolling-summary.d.ts +4 -4
  114. package/dist/api/runtime/turnFinalResponse.d.ts +3 -3
  115. package/dist/api/server/AgentOSServer.d.ts +1 -1
  116. package/dist/api/structured/output/IStructuredOutputManager.d.ts +1 -1
  117. package/dist/api/structured/output/StructuredOutputManager.d.ts +3 -3
  118. package/dist/api/structured/output/index.d.ts +3 -3
  119. package/dist/api/types/AgentOSExternalToolRequest.d.ts +1 -1
  120. package/dist/api/types/AgentOSInput.d.ts +3 -3
  121. package/dist/api/types/AgentOSResponse.d.ts +6 -6
  122. package/dist/api/types/OrchestratorConfig.d.ts +11 -11
  123. package/dist/api/types.d.ts +12 -6
  124. package/dist/api/types.d.ts.map +1 -1
  125. package/dist/api/types.js.map +1 -1
  126. package/dist/cognition/emergent/CreateWorkflowTool.d.ts +12 -2
  127. package/dist/cognition/emergent/CreateWorkflowTool.d.ts.map +1 -1
  128. package/dist/cognition/emergent/CreateWorkflowTool.js +12 -2
  129. package/dist/cognition/emergent/CreateWorkflowTool.js.map +1 -1
  130. package/dist/cognition/emergent/EmergentCapabilityEngine.d.ts +8 -1
  131. package/dist/cognition/emergent/EmergentCapabilityEngine.d.ts.map +1 -1
  132. package/dist/cognition/emergent/EmergentCapabilityEngine.js +11 -0
  133. package/dist/cognition/emergent/EmergentCapabilityEngine.js.map +1 -1
  134. package/dist/cognition/emergent/SelfImprovementConfig.d.ts +8 -2
  135. package/dist/cognition/emergent/SelfImprovementConfig.d.ts.map +1 -1
  136. package/dist/cognition/emergent/SelfImprovementConfig.js.map +1 -1
  137. package/dist/cognition/emergent/StepGate.d.ts +15 -3
  138. package/dist/cognition/emergent/StepGate.d.ts.map +1 -1
  139. package/dist/cognition/emergent/StepGate.js +33 -5
  140. package/dist/cognition/emergent/StepGate.js.map +1 -1
  141. package/dist/cognition/emergent/types.d.ts +4 -2
  142. package/dist/cognition/emergent/types.d.ts.map +1 -1
  143. package/dist/cognition/emergent/types.js.map +1 -1
  144. package/dist/cognition/marketplace/store/Marketplace.d.ts +2 -2
  145. package/dist/cognition/marketplace/store/index.d.ts +2 -2
  146. package/dist/cognition/memory/pipeline/lifecycle/IMemoryLifecycleManager.d.ts +5 -5
  147. package/dist/cognition/memory/pipeline/lifecycle/MemoryLifecycleManager.d.ts +6 -6
  148. package/dist/cognition/memory/retrieval/graph/knowledge/KnowledgeGraph.d.ts +3 -3
  149. package/dist/cognition/nlp/ITextProcessor.d.ts +1 -1
  150. package/dist/cognition/nlp/TextProcessingPipeline.d.ts +2 -2
  151. package/dist/cognition/nlp/ai_utilities/HybridUtilityAI.d.ts +1 -1
  152. package/dist/cognition/nlp/ai_utilities/IUtilityAI.d.ts +1 -1
  153. package/dist/cognition/nlp/ai_utilities/LLMUtilityAI.d.ts +4 -4
  154. package/dist/cognition/nlp/ai_utilities/StatisticalUtilityAI.d.ts +1 -1
  155. package/dist/cognition/nlp/ai_utilities/targetSchemaChecks.d.ts +1 -1
  156. package/dist/cognition/nlp/filters/StopWordFilter.d.ts +3 -3
  157. package/dist/cognition/nlp/index.d.ts +13 -13
  158. package/dist/cognition/nlp/language/LanguageService.d.ts +1 -1
  159. package/dist/cognition/nlp/language/index.d.ts +5 -5
  160. package/dist/cognition/nlp/language/providers/DeepLTranslationProvider.d.ts +1 -1
  161. package/dist/cognition/nlp/language/providers/OpenAITranslationProvider.d.ts +1 -1
  162. package/dist/cognition/nlp/language/providers/WhisperDetectionProvider.d.ts +1 -1
  163. package/dist/cognition/nlp/lemmatizers/NoOpLemmatizer.d.ts +2 -2
  164. package/dist/cognition/nlp/lemmatizers/WordNetLemmatizer.d.ts +2 -2
  165. package/dist/cognition/nlp/normalizers/AccentStripper.d.ts +2 -2
  166. package/dist/cognition/nlp/normalizers/LowercaseNormalizer.d.ts +2 -2
  167. package/dist/cognition/nlp/presets.d.ts +1 -1
  168. package/dist/cognition/nlp/stemmers/NoOpStemmer.d.ts +2 -2
  169. package/dist/cognition/nlp/stemmers/PorterStemmer.d.ts +2 -2
  170. package/dist/cognition/nlp/tokenizers/CodeTokenizer.d.ts +2 -2
  171. package/dist/cognition/nlp/tokenizers/StandardTokenizer.d.ts +2 -2
  172. package/dist/cognition/rag/EmbeddingManager.d.ts +3 -3
  173. package/dist/cognition/rag/IRetrievalAugmentor.d.ts +5 -5
  174. package/dist/cognition/rag/RetrievalAugmentor.d.ts +6 -6
  175. package/dist/cognition/rag/VectorStoreManager.d.ts +3 -3
  176. package/dist/cognition/rag/reranking/IRerankerService.d.ts +1 -1
  177. package/dist/cognition/rag/reranking/RerankerService.d.ts +3 -3
  178. package/dist/cognition/rag/reranking/index.d.ts +6 -6
  179. package/dist/cognition/rag/reranking/providers/CohereReranker.d.ts +1 -1
  180. package/dist/cognition/rag/reranking/providers/LocalCrossEncoderReranker.d.ts +1 -1
  181. package/dist/cognition/rag/reranking/providers/index.d.ts +2 -2
  182. package/dist/cognition/rag/vector-search/HnswIndexSidecar.d.ts +1 -1
  183. package/dist/cognition/rag/vector-search/index.d.ts +2 -2
  184. package/dist/cognition/rag/vector_stores/InMemoryVectorStore.d.ts +1 -1
  185. package/dist/cognition/rag/vector_stores/SqlVectorStore.d.ts +1 -1
  186. package/dist/cognition/substrate/CognitiveMemoryBridge.d.ts +2 -2
  187. package/dist/cognition/substrate/ConversationHistoryManager.d.ts +3 -3
  188. package/dist/cognition/substrate/GMI.d.ts +13 -7
  189. package/dist/cognition/substrate/GMI.d.ts.map +1 -1
  190. package/dist/cognition/substrate/GMI.js +52 -5
  191. package/dist/cognition/substrate/GMI.js.map +1 -1
  192. package/dist/cognition/substrate/GMIManager.d.ts +102 -23
  193. package/dist/cognition/substrate/GMIManager.d.ts.map +1 -1
  194. package/dist/cognition/substrate/GMIManager.js +202 -11
  195. package/dist/cognition/substrate/GMIManager.js.map +1 -1
  196. package/dist/cognition/substrate/IGMI.d.ts +19 -12
  197. package/dist/cognition/substrate/IGMI.d.ts.map +1 -1
  198. package/dist/cognition/substrate/IGMI.js.map +1 -1
  199. package/dist/cognition/substrate/MetapromptExecutor.d.ts +6 -6
  200. package/dist/cognition/substrate/SentimentTracker.d.ts +5 -5
  201. package/dist/cognition/substrate/memory/InMemoryWorkingMemory.d.ts +1 -1
  202. package/dist/cognition/substrate/persona_overlays/PersonaOverlayManager.d.ts +3 -3
  203. package/dist/cognition/substrate/persona_overlays/PersonaOverlayTypes.d.ts +2 -2
  204. package/dist/cognition/substrate/personas/IPersonaDefinition.d.ts +3 -3
  205. package/dist/cognition/substrate/personas/IPersonaLoader.d.ts +1 -1
  206. package/dist/cognition/substrate/personas/InMemoryPersonaLoader.d.ts +2 -2
  207. package/dist/cognition/substrate/personas/PersonaLoader.d.ts +2 -2
  208. package/dist/cognition/substrate/personas/PersonaValidation.d.ts +1 -1
  209. package/dist/cognition/substrate/personas/definitions/index.d.ts +1 -1
  210. package/dist/cognition/substrate/personas/personaNormalization.d.ts +1 -1
  211. package/dist/cognition/substrate/reasoningTraceLimits.d.ts +2 -2
  212. package/dist/cognition/substrate/toolCallGate.d.ts +1 -1
  213. package/dist/cognition/substrate/turnContent.d.ts +1 -1
  214. package/dist/cognition/web-search/WebSearchService.d.ts +1 -1
  215. package/dist/cognition/web-search/dedup.d.ts +1 -1
  216. package/dist/cognition/web-search/fusion.d.ts +1 -1
  217. package/dist/cognition/web-search/index.d.ts +8 -8
  218. package/dist/cognition/web-search/providers/BraveProvider.d.ts +1 -1
  219. package/dist/cognition/web-search/providers/FirecrawlProvider.d.ts +1 -1
  220. package/dist/cognition/web-search/providers/SerperProvider.d.ts +1 -1
  221. package/dist/cognition/web-search/providers/TavilyProvider.d.ts +1 -1
  222. package/dist/cognition/web-search/providers/index.d.ts +4 -4
  223. package/dist/cognition/web-search/types.d.ts +2 -2
  224. package/dist/core/conversation/ConversationContext.d.ts +2 -2
  225. package/dist/core/conversation/ConversationManager.d.ts +2 -2
  226. package/dist/core/conversation/ConversationMessage.d.ts +3 -3
  227. package/dist/core/conversation/ILongTermMemoryRetriever.d.ts +1 -1
  228. package/dist/core/conversation/IRollingSummaryMemorySink.d.ts +1 -1
  229. package/dist/core/conversation/RollingSummaryCompactor.d.ts +2 -2
  230. package/dist/core/embeddings/IEmbeddingManager.d.ts +1 -1
  231. package/dist/core/llm/IPromptEngine.d.ts +6 -6
  232. package/dist/core/llm/PromptEngine.d.ts +2 -2
  233. package/dist/core/llm/providers/AIModelProviderManager.d.ts +25 -14
  234. package/dist/core/llm/providers/AIModelProviderManager.d.ts.map +1 -1
  235. package/dist/core/llm/providers/AIModelProviderManager.js +18 -0
  236. package/dist/core/llm/providers/AIModelProviderManager.js.map +1 -1
  237. package/dist/core/llm/providers/errors/AnthropicProviderError.d.ts +1 -1
  238. package/dist/core/llm/providers/errors/ClaudeCodeProviderError.d.ts +1 -1
  239. package/dist/core/llm/providers/errors/GeminiCLIProviderError.d.ts +1 -1
  240. package/dist/core/llm/providers/errors/GeminiProviderError.d.ts +1 -1
  241. package/dist/core/llm/providers/errors/OllamaProviderError.d.ts +1 -1
  242. package/dist/core/llm/providers/errors/OpenAIProviderError.d.ts +1 -1
  243. package/dist/core/llm/providers/errors/OpenRouterProviderError.d.ts +1 -1
  244. package/dist/core/llm/providers/errors/RequestyProviderError.d.ts +1 -1
  245. package/dist/core/llm/providers/implementations/AnthropicProvider.d.ts +1 -1
  246. package/dist/core/llm/providers/implementations/ClaudeCodeCLIBridge.d.ts +5 -5
  247. package/dist/core/llm/providers/implementations/ClaudeCodeProvider.d.ts +1 -1
  248. package/dist/core/llm/providers/implementations/GeminiCLIBridge.d.ts +5 -5
  249. package/dist/core/llm/providers/implementations/GeminiCLIProvider.d.ts +1 -1
  250. package/dist/core/llm/providers/implementations/GeminiProvider.d.ts +1 -1
  251. package/dist/core/llm/providers/implementations/GroqProvider.d.ts +2 -2
  252. package/dist/core/llm/providers/implementations/LiteLLMProvider.d.ts +2 -2
  253. package/dist/core/llm/providers/implementations/MiniMaxProvider.d.ts +2 -2
  254. package/dist/core/llm/providers/implementations/MistralProvider.d.ts +2 -2
  255. package/dist/core/llm/providers/implementations/OllamaProvider.d.ts +1 -1
  256. package/dist/core/llm/providers/implementations/OpenAIProvider.d.ts +1 -1
  257. package/dist/core/llm/providers/implementations/OpenRouterProvider.d.ts +1 -1
  258. package/dist/core/llm/providers/implementations/RequestyProvider.d.ts +1 -1
  259. package/dist/core/llm/providers/implementations/TogetherProvider.d.ts +2 -2
  260. package/dist/core/llm/providers/implementations/XAIProvider.d.ts +2 -2
  261. package/dist/core/llm/providers/implementations/billing-probe-model.d.ts +1 -1
  262. package/dist/core/llm/routing/IModelRouter.d.ts +3 -3
  263. package/dist/core/llm/routing/ModelRouter.d.ts +3 -3
  264. package/dist/core/llm/routing/PolicyAwareRouter.d.ts +3 -3
  265. package/dist/core/llm/streaming/StreamingBatcher.d.ts +1 -1
  266. package/dist/core/llm/streaming/StreamingReconstructor.d.ts +2 -2
  267. package/dist/core/logging/PinoLogger.d.ts +1 -1
  268. package/dist/core/streaming/AsyncStreamClientBridge.d.ts +2 -2
  269. package/dist/core/streaming/IStreamClient.d.ts +1 -1
  270. package/dist/core/streaming/StreamingManager.d.ts +2 -2
  271. package/dist/core/tools/ITool.d.ts +13 -7
  272. package/dist/core/tools/ITool.d.ts.map +1 -1
  273. package/dist/core/tools/IToolOrchestrator.d.ts +7 -7
  274. package/dist/core/tools/ToolExecutor.d.ts +19 -13
  275. package/dist/core/tools/ToolExecutor.d.ts.map +1 -1
  276. package/dist/core/tools/ToolExecutor.js.map +1 -1
  277. package/dist/core/tools/ToolOrchestrator.d.ts +16 -8
  278. package/dist/core/tools/ToolOrchestrator.d.ts.map +1 -1
  279. package/dist/core/tools/ToolOrchestrator.js +37 -11
  280. package/dist/core/tools/ToolOrchestrator.js.map +1 -1
  281. package/dist/core/tools/permissions/IToolPermissionManager.d.ts +3 -3
  282. package/dist/core/tools/permissions/ToolPermissionManager.d.ts +2 -2
  283. package/dist/core/utils/index.d.ts +1 -1
  284. package/dist/core/utils/usage/UsageLedger.d.ts +1 -1
  285. package/dist/core/vector-store/IVectorStoreManager.d.ts +2 -2
  286. package/dist/extensions/ExtensionLoader.d.ts +2 -2
  287. package/dist/extensions/ExtensionManager.d.ts +4 -4
  288. package/dist/extensions/ExtensionRegistry.d.ts +1 -1
  289. package/dist/extensions/RegistryConfig.d.ts +1 -1
  290. package/dist/extensions/SharedServiceRegistry.d.ts +1 -1
  291. package/dist/extensions/events.d.ts +1 -1
  292. package/dist/extensions/index.d.ts +10 -10
  293. package/dist/extensions/manifest.d.ts +3 -3
  294. package/dist/extensions/types.d.ts +8 -8
  295. package/dist/index.d.ts +73 -72
  296. package/dist/index.d.ts.map +1 -1
  297. package/dist/index.js.map +1 -1
  298. package/dist/io/channels/social-posting/index.d.ts +3 -3
  299. package/dist/io/hearing/AdaptiveVAD.d.ts +1 -1
  300. package/dist/io/hearing/AudioProcessor.d.ts +2 -2
  301. package/dist/io/hearing/SilenceDetector.d.ts +1 -1
  302. package/dist/io/media/images/PolicyAwareImageRouter.d.ts +1 -1
  303. package/dist/orchestration/hitl/HumanInteractionManager.d.ts +2 -2
  304. package/dist/orchestration/hitl/index.d.ts +2 -2
  305. package/dist/orchestration/planner/IPlanningEngine.d.ts +1 -1
  306. package/dist/orchestration/planner/PlanningEngine.d.ts +3 -3
  307. package/dist/orchestration/planner/index.d.ts +2 -2
  308. package/dist/orchestration/turn-planner/IAgentOrchestrator.d.ts +2 -2
  309. package/dist/orchestration/turn-planner/TurnPlanner.d.ts +4 -4
  310. package/dist/orchestration/turn-planner/helpers.d.ts +2 -2
  311. package/dist/orchestration/workflows/IWorkflowEngine.d.ts +4 -4
  312. package/dist/orchestration/workflows/WorkflowEngine.d.ts +3 -3
  313. package/dist/orchestration/workflows/WorkflowTypes.d.ts +2 -2
  314. package/dist/orchestration/workflows/runtime/WorkflowRuntime.d.ts +9 -9
  315. package/dist/orchestration/workflows/storage/IWorkflowStore.d.ts +1 -1
  316. package/dist/orchestration/workflows/storage/InMemoryWorkflowStore.d.ts +2 -2
  317. package/dist/safety/evaluation/Evaluator.d.ts +1 -1
  318. package/dist/safety/evaluation/LLMJudge.d.ts +3 -3
  319. package/dist/safety/evaluation/index.d.ts +4 -4
  320. package/dist/safety/evaluation/observability/Tracer.d.ts +1 -1
  321. package/dist/safety/evaluation/observability/index.d.ts +5 -5
  322. package/dist/safety/guardrails/ICrossAgentGuardrailService.d.ts +2 -2
  323. package/dist/safety/guardrails/IGuardrailService.d.ts +3 -3
  324. package/dist/safety/guardrails/ParallelGuardrailDispatcher.d.ts +4 -4
  325. package/dist/safety/guardrails/builtin/PhraseListGuardrail.d.ts +4 -4
  326. package/dist/safety/guardrails/crossAgentGuardrailDispatcher.d.ts +4 -4
  327. package/dist/safety/guardrails/guardrailDispatcher.d.ts +4 -4
  328. package/dist/safety/guardrails/index.d.ts +8 -8
  329. package/dist/safety/guardrails/requiredGuardrails.d.ts +1 -1
  330. package/dist/safety/guardrails/sanitizedFinalResponse.d.ts +3 -3
  331. package/dist/safety/sandbox/executor/CodeSandbox.d.ts +2 -2
  332. package/dist/safety/sandbox/executor/ICodeSandbox.d.ts +1 -1
  333. package/dist/safety/sandbox/executor/index.d.ts +3 -3
  334. package/dist/safety/sandbox/subprocess/CLISubprocessBridge.d.ts +2 -2
  335. package/dist/safety/sandbox/subprocess/index.d.ts +4 -4
  336. package/package.json +1 -1
@@ -0,0 +1,277 @@
1
+ /**
2
+ * @file runtimeSeat.ts
3
+ * A seat of a team a GMI launched on the full runtime: a roster member over the one GMI the GMIManager built for it
4
+ * (`createAgencySeat`). Each call runs one turn of that GMI under the call's stop, in the seat session, as the parent
5
+ * turn's user and organization, with the launch frame in its metadata; the seat's calls run one at a time. A failed
6
+ * turn rejects with its error's name and code alone, as a gmi() seat's does, the error itself going to the launch's
7
+ * `logError`. Each call that ran a turn is reported to `onCall` when it ends (the agency registry's seat history).
8
+ * Each call hands the seat's tool view the approval gate the child agency passes with it, which the view asks on each
9
+ * of the call's tool calls.
10
+ * @internal
11
+ */
12
+ import { randomUUID } from 'node:crypto';
13
+ import { GMIInteractionType, GMIOutputChunkType, } from '../../../cognition/substrate/IGMI.js';
14
+ import { GMIError, GMIErrorCode } from '../../../core/utils/errors.js';
15
+ import { composeReceivedGate } from '../approval-gate.js';
16
+ import { TurnLock } from '../gmiSession.js';
17
+ import { SEAT_SUMMARY_CHARS } from './types.js';
18
+ /** A turn's usage, from its output. */
19
+ function usageOf(output) {
20
+ const usage = output?.usage;
21
+ const num = (value) => (typeof value === 'number' && Number.isFinite(value) ? value : 0);
22
+ const cost = usage?.totalCostUSD;
23
+ return {
24
+ promptTokens: num(usage?.promptTokens),
25
+ completionTokens: num(usage?.completionTokens),
26
+ totalTokens: num(usage?.totalTokens),
27
+ ...(typeof cost === 'number' && Number.isFinite(cost) ? { costUSD: cost } : {}),
28
+ };
29
+ }
30
+ /**
31
+ * The error a seat rejects with: the original's name and code alone, the rule sessionSeat()'s seats follow. A
32
+ * provider's or a handler's message can carry a URL or a credential, and a hierarchical manager's delegate tool hands
33
+ * a seat's rejection to the manager's model.
34
+ */
35
+ function seatError(name, code) {
36
+ const error = new Error(code ? `${name} (${code})` : name);
37
+ error.name = name;
38
+ if (code)
39
+ error.code = code;
40
+ return error;
41
+ }
42
+ /**
43
+ * The error a failed turn reported, whole, for the launch's `logError`: its ERROR chunk's details (a GMIError's plain
44
+ * form: name, message, code, details, stack), else its output's error.
45
+ */
46
+ function turnError(details, output, content) {
47
+ const text = (key) => {
48
+ const value = details?.[key];
49
+ return typeof value === 'string' ? value : undefined;
50
+ };
51
+ const code = text('code') ?? output?.code ?? GMIErrorCode.GMI_PROCESSING_ERROR;
52
+ const message = text('message') ?? output?.message ?? (typeof content === 'string' ? content : 'The turn failed.');
53
+ const error = new GMIError(message, code, output?.details ?? details?.details);
54
+ const name = text('name');
55
+ if (name)
56
+ error.name = name;
57
+ const stack = text('stack');
58
+ if (stack)
59
+ error.stack = stack;
60
+ return error;
61
+ }
62
+ /** The code of a thrown error, when it carries a string or numeric one. */
63
+ function codeOf(error) {
64
+ const code = error?.code;
65
+ return typeof code === 'string' ? code : typeof code === 'number' ? String(code) : undefined;
66
+ }
67
+ /**
68
+ * @param options - The seat's GMI, persona, session, user, organization, frame and record fields.
69
+ * @returns A roster member for the launch's child agency.
70
+ */
71
+ export function runtimeSeat(options) {
72
+ const record = {
73
+ role: options.role,
74
+ form: options.form,
75
+ ...(options.memberRef ? { member: options.memberRef } : {}),
76
+ status: 'not_run',
77
+ calls: 0,
78
+ summary: '',
79
+ usage: { promptTokens: 0, completionTokens: 0, totalTokens: 0 },
80
+ };
81
+ const lock = new TurnLock();
82
+ let closed = false;
83
+ let closing;
84
+ /** The seat's calls in flight, a call waiting for the seat's earlier turn among them. */
85
+ let running = 0;
86
+ /** A persistent member's input, after its role and brief; a temporary seat's instructions are its persona. */
87
+ const framed = (input) => {
88
+ if (options.form !== 'persistent')
89
+ return input;
90
+ const brief = options.brief?.trim();
91
+ return `Your role in this team: ${options.role}.${brief ? ` ${brief}` : ''}\n\n${input}`;
92
+ };
93
+ /** Adds a turn's usage to the record: a turn that failed after billed steps included. */
94
+ const addUsage = (usage) => {
95
+ record.usage.promptTokens += usage.promptTokens;
96
+ record.usage.completionTokens += usage.completionTokens;
97
+ record.usage.totalTokens += usage.totalTokens;
98
+ if (usage.costUSD !== undefined)
99
+ record.usage.costUSD = (record.usage.costUSD ?? 0) + usage.costUSD;
100
+ };
101
+ /**
102
+ * Hands `onCall` a copy of the record as the call that ran a turn left it, before the seat's next turn can change it.
103
+ * A function that throws changes nothing about the call.
104
+ */
105
+ const reportCall = () => {
106
+ if (!options.onCall)
107
+ return;
108
+ try {
109
+ options.onCall({ ...record, usage: { ...record.usage }, ...(record.error ? { error: { ...record.error } } : {}) });
110
+ }
111
+ catch (error) {
112
+ options.logError(error, 'launch_agency record');
113
+ }
114
+ };
115
+ /** Records a failed call and returns the error the seat rejects with: the failure's name and code, never its message. */
116
+ const failed = (error, signal) => {
117
+ const name = error instanceof Error ? error.name : 'Error';
118
+ const code = codeOf(error);
119
+ record.status = signal?.aborted === true || options.cutWhen() ? 'cut' : 'failed';
120
+ record.error = { name, ...(code ? { code } : {}) };
121
+ options.logError(error, `seat ${options.role}`);
122
+ return seatError(name, code);
123
+ };
124
+ /** One turn of the seat's GMI, under the call's stop. */
125
+ const runTurn = async (prompt, signal) => {
126
+ const calls = new Map();
127
+ let output;
128
+ let failure;
129
+ let lastStep;
130
+ let streamed = '';
131
+ try {
132
+ const turn = options.gmi.processTurnStream({
133
+ interactionId: `turn-${randomUUID()}`,
134
+ userId: options.userId,
135
+ sessionId: options.seatSessionId,
136
+ type: GMIInteractionType.TEXT,
137
+ content: framed(prompt),
138
+ metadata: {
139
+ ...(signal ? { options: { abortSignal: signal } } : {}),
140
+ agencyLaunch: options.frame,
141
+ agencyId: options.frame.launchId,
142
+ roleId: options.role,
143
+ ...(options.organizationId ? { organizationId: options.organizationId } : {}),
144
+ ...(options.toolCallGate ? { toolCallGate: options.toolCallGate } : {}),
145
+ },
146
+ });
147
+ for (;;) {
148
+ const next = await turn.next();
149
+ if (next.done) {
150
+ output = next.value;
151
+ break;
152
+ }
153
+ const chunk = next.value;
154
+ if (chunk.type === GMIOutputChunkType.TEXT_DELTA && typeof chunk.content === 'string') {
155
+ streamed += chunk.content;
156
+ }
157
+ else if (chunk.type === GMIOutputChunkType.STEP_FINISHED) {
158
+ lastStep = chunk.content;
159
+ }
160
+ else if (chunk.type === GMIOutputChunkType.TOOL_CALL_REQUEST && Array.isArray(chunk.content)) {
161
+ for (const call of chunk.content)
162
+ calls.set(call.id, { name: call.name, args: call.arguments });
163
+ }
164
+ else if (chunk.type === GMIOutputChunkType.TOOL_RESULT) {
165
+ const result = chunk.content;
166
+ const call = calls.get(result.toolCallId);
167
+ // A tool's error stays out of the record: its message can carry what the seat's model must not echo.
168
+ if (call && result.isError)
169
+ call.error = 'the tool failed';
170
+ else if (call)
171
+ call.result = result.result;
172
+ }
173
+ else if (chunk.type === GMIOutputChunkType.ERROR) {
174
+ failure = { details: chunk.errorDetails, content: chunk.content };
175
+ }
176
+ }
177
+ }
178
+ catch (thrown) {
179
+ throw failed(thrown, signal);
180
+ }
181
+ // A failed turn does not throw: it yields an ERROR chunk and returns its error with the usage of the steps it made.
182
+ if (failure || output?.error) {
183
+ addUsage(usageOf(output));
184
+ throw failed(turnError(failure?.details, output?.error, failure?.content), signal);
185
+ }
186
+ const text = output?.responseText ?? streamed;
187
+ const usage = usageOf(output);
188
+ addUsage(usage);
189
+ record.status = 'completed';
190
+ delete record.error;
191
+ record.summary = text.length > SEAT_SUMMARY_CHARS ? text.slice(0, SEAT_SUMMARY_CHARS) : text;
192
+ const persona = options.gmi.getPersona();
193
+ return {
194
+ provider: lastStep?.providerId ?? persona.defaultProviderId ?? '',
195
+ model: lastStep?.modelId ?? persona.defaultModelId ?? '',
196
+ text,
197
+ usage,
198
+ toolCalls: [...calls.values()],
199
+ finishReason: lastStep?.finishReason === 'length' ? 'length' : 'stop',
200
+ };
201
+ };
202
+ const handle = {
203
+ seatId: options.seatSessionId,
204
+ gmiId: options.gmi.gmiId,
205
+ personaId: options.personaId,
206
+ ...(options.description ? { description: options.description } : {}),
207
+ ...(options.dependsOn ? { dependsOn: [...options.dependsOn] } : {}),
208
+ async generate(prompt, opts) {
209
+ if (closed)
210
+ throw new Error('seat closed');
211
+ record.calls += 1;
212
+ running += 1;
213
+ try {
214
+ // A GMI runs one turn at a time (GMI.ensureReady): a manager that delegates twice at once waits here.
215
+ const release = await lock.acquire();
216
+ let ranTurn = false;
217
+ try {
218
+ if (closed) {
219
+ // The launch closed the seat while this call waited for its earlier turn: the call is cut, and runs nothing.
220
+ record.status = 'cut';
221
+ delete record.error;
222
+ throw new Error('seat closed');
223
+ }
224
+ ranTurn = true;
225
+ // The child agency passes its gate with each call (a value that is not a function refuses every tool): the
226
+ // view asks it on each of this call's tool calls. It is set once the call holds the seat's lock, so a call
227
+ // waiting for an earlier turn neither replaces nor clears that turn's gate.
228
+ options.setGate?.(composeReceivedGate(opts?.__approvalGate));
229
+ return await runTurn(prompt, opts?.abortSignal);
230
+ }
231
+ finally {
232
+ options.setGate?.(undefined);
233
+ // The registry's seat history hears of every call that ran a turn, answered or not.
234
+ if (ranTurn)
235
+ reportCall();
236
+ release();
237
+ }
238
+ }
239
+ finally {
240
+ running -= 1;
241
+ }
242
+ },
243
+ stream() {
244
+ throw new Error('a seat of a launched team runs through generate()');
245
+ },
246
+ session() {
247
+ throw new Error('a seat runs one session; call generate()');
248
+ },
249
+ async usage() {
250
+ return { ...record.usage };
251
+ },
252
+ close() {
253
+ closing ?? (closing = (async () => {
254
+ closed = true;
255
+ // A turn still running (a tool past the deadline) ends first; then the GMI goes.
256
+ const release = await lock.acquire();
257
+ try {
258
+ await options.release();
259
+ }
260
+ finally {
261
+ release();
262
+ }
263
+ })());
264
+ return closing;
265
+ },
266
+ record() {
267
+ // A turn still running once the launch has stopped (its deadline, its parent's stop, its budget) is cut, whatever
268
+ // the seat's earlier turns came to: the launch reports without that turn's answer, and without the error an
269
+ // earlier turn failed with, which did not end this one.
270
+ const cut = running > 0 && options.cutWhen();
271
+ const { error, ...withoutError } = record;
272
+ return { ...withoutError, ...(cut ? { status: 'cut' } : {}), usage: { ...record.usage }, ...(error && !cut ? { error: { ...error } } : {}) };
273
+ },
274
+ };
275
+ return handle;
276
+ }
277
+ //# sourceMappingURL=runtimeSeat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeSeat.js","sourceRoot":"","sources":["../../../../src/api/runtime/agencyLaunch/runtimeSeat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GAOnB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAuB,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAiD,MAAM,YAAY,CAAC;AAoD/F,uCAAuC;AACvC,SAAS,OAAO,CAAC,MAA6B;IAC5C,MAAM,KAAK,GAAG,MAAM,EAAE,KAAK,CAAC;IAC5B,MAAM,GAAG,GAAG,CAAC,KAAc,EAAU,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAA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AM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { IToolOrchestrator } from '../../../core/tools/IToolOrchestrator.js';
2
+ import { type ApprovalGateFn } from '../approval-gate.js';
3
+ /**
4
+ * @param base - The runtime's shared tool orchestrator.
5
+ * @param names - The seat's tool names.
6
+ * @param gateOf - The approval gate of the call the seat serves, read at each tool call: the one the child agency
7
+ * passes with that call; undefined between calls and for a team that has none.
8
+ * @returns The seat's orchestrator.
9
+ */
10
+ export declare function seatToolView(base: IToolOrchestrator, names: ReadonlySet<string>, gateOf?: () => ApprovalGateFn | undefined): IToolOrchestrator;
11
+ //# sourceMappingURL=seatToolView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seatToolView.d.ts","sourceRoot":"","sources":["../../../../src/api/runtime/agencyLaunch/seatToolView.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,EAAqC,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAO7F;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,iBAAiB,EACvB,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,EAC1B,MAAM,GAAE,MAAM,cAAc,GAAG,SAA2B,GACzD,iBAAiB,CAwDnB"}
@@ -0,0 +1,69 @@
1
+ import { APPROVAL_GRANTED, askApprovalGate } from '../approval-gate.js';
2
+ import { withMembers } from '../withMembers.js';
3
+ /** Why a call outside the seat's names was not run, as the model reads it. */
4
+ const NOT_IN_SEAT = 'not available in this seat';
5
+ /**
6
+ * @param base - The runtime's shared tool orchestrator.
7
+ * @param names - The seat's tool names.
8
+ * @param gateOf - The approval gate of the call the seat serves, read at each tool call: the one the child agency
9
+ * passes with that call; undefined between calls and for a team that has none.
10
+ * @returns The seat's orchestrator.
11
+ */
12
+ export function seatToolView(base, names, gateOf = () => undefined) {
13
+ const visible = (tools) => tools.filter((tool) => names.has(tool.name));
14
+ const processToolCall = async (details) => {
15
+ const req = details.toolCallRequest;
16
+ if (!names.has(req.name)) {
17
+ return {
18
+ toolCallId: req.id,
19
+ toolName: req.name,
20
+ output: { skipped: true, reason: NOT_IN_SEAT },
21
+ isError: true,
22
+ errorDetails: { message: `Skipped: ${NOT_IN_SEAT}`, code: 'TOOL_NOT_IN_SEAT' },
23
+ };
24
+ }
25
+ // The gate of the call the seat serves, after the name filter, about a tool the orchestrator has: anything but the
26
+ // exact approval skips the tool, and the model is told why. A tool the orchestrator does not have is reported by it
27
+ // without asking anyone, and so is a call whose stop has come: the orchestrator refuses it (STEP_ABORTED). The view
28
+ // does not see the step of the GMI's tool loop, so the request names step 0.
29
+ const gate = gateOf();
30
+ const current = gate ? await base.getTool(req.name) : undefined;
31
+ let bound;
32
+ if (gate && current && !details.signal?.aborted) {
33
+ const verdict = await askApprovalGate(gate, { name: req.name, args: req.arguments ?? {}, id: req.id, step: 0 });
34
+ if (verdict !== APPROVAL_GRANTED) {
35
+ return {
36
+ toolCallId: req.id,
37
+ toolName: req.name,
38
+ output: { skipped: true, reason: verdict.reason },
39
+ isError: true,
40
+ errorDetails: { message: `Skipped: ${verdict.reason}` },
41
+ };
42
+ }
43
+ // The approval is for the registration the gate was asked about. A composed step arrives with the instance its
44
+ // pipeline checked already.
45
+ if (!details.tool)
46
+ bound = current;
47
+ }
48
+ const callerTurn = {
49
+ ...(details.callerTurn ?? {}),
50
+ toolNames: names,
51
+ ...(gate ? { approvalGate: gate } : {}),
52
+ dispatch: processToolCall,
53
+ };
54
+ // The orchestrator checks and runs the bound instance alone, and refuses the call (STEP_REPLACED) when another
55
+ // registration took the name while the approval was pending.
56
+ return base.processToolCall({ ...details, ...(bound ? { tool: bound } : {}), callerTurn });
57
+ };
58
+ return withMembers(base, {
59
+ processToolCall,
60
+ listAvailableTools: async (context) => visible(await base.listAvailableTools(context)),
61
+ // The base's listDiscoveredTools calls its own listAvailableTools, which this view does not reach.
62
+ ...(typeof base.listDiscoveredTools === 'function'
63
+ ? {
64
+ listDiscoveredTools: async (...args) => visible(await base.listDiscoveredTools(...args)),
65
+ }
66
+ : {}),
67
+ });
68
+ }
69
+ //# sourceMappingURL=seatToolView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seatToolView.js","sourceRoot":"","sources":["../../../../src/api/runtime/agencyLaunch/seatToolView.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAuB,MAAM,qBAAqB,CAAC;AAC7F,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,8EAA8E;AAC9E,MAAM,WAAW,GAAG,4BAA4B,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAC1B,IAAuB,EACvB,KAA0B,EAC1B,SAA2C,GAAG,EAAE,CAAC,SAAS;IAE1D,MAAM,OAAO,GAAG,CAA6B,KAAU,EAAO,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9G,MAAM,eAAe,GAAyC,KAAK,EAAE,OAAO,EAAE,EAAE;QAC9E,MAAM,GAAG,GAAG,OAAO,CAAC,eAAe,CAAC;QACpC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,OAAO;gBACL,UAAU,EAAE,GAAG,CAAC,EAAE;gBAClB,QAAQ,EAAE,GAAG,CAAC,IAAI;gBAClB,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE;gBAC9C,OAAO,EAAE,IAAI;gBACb,YAAY,EAAE,EAAE,OAAO,EAAE,YAAY,WAAW,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE;aAC/E,CAAC;QACJ,CAAC;QACD,mHAAmH;QACnH,oHAAoH;QACpH,oHAAoH;QACpH,6EAA6E;QAC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AO,IAAI,CAAC,eAAe,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;IAC7F,CAAC,CAAC;IACF,OAAO,WAAW,CAAC,IAAI,EAAE;QACvB,eAAe;QACf,kBAAkB,EAAE,KAAK,EAAE,OAAgE,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAC/I,mGAAmG;QACnG,GAAG,CAAC,OAAO,IAAI,CAAC,mBAAmB,KAAK,UAAU;YAChD,CAAC,CAAC;gBACE,mBAAmB,EAAE,KAAK,EAAE,GAAG,IAAuE,EAAE,EAAE,CACxG,OAAO,CAAC,MAAM,IAAI,CAAC,mBAAoB,CAAC,GAAG,IAAI,CAAC,CAAC;aACpD;YACH,CAAC,CAAC,EAAE,CAAC;KACR,CAAC,CAAC;AACL,CAAC"}
@@ -1,21 +1,30 @@
1
1
  /**
2
2
  * @file types.ts
3
3
  * The types and bounds of teams a GMI launches from a turn (`launch_agency`), and of the seats such a team and
4
- * `sessionSeat()` build. The package root and `src/api` export {@link LAUNCH_AGENCY_TOOL_NAME}, `sessionSeat()` and
5
- * the types of the `agencies` option, the tool's arguments and result and a seat; the launch registry, the engine
6
- * (`runLaunch`) and the tool factory (`createGmiLaunchTool`) stay internal.
4
+ * `sessionSeat()` build, with the tool's schema and description, which both surfaces offer. The package root and
5
+ * `src/api` export {@link LAUNCH_AGENCY_TOOL_NAME}, `sessionSeat()` and the types of the `agencies` options, a launch
6
+ * tree's limits, the tool's arguments and result, a seat, the frame a seat's turns carry, the turn a tool call came
7
+ * from, a tool hook and a launched team's registry record (`./index.ts` gathers them); neither exports the launch
8
+ * registry, the engine (`runLaunch`) or the tool factories (`createGmiLaunchTool`, `createRuntimeLaunchTool`).
7
9
  */
8
10
  import type { AgentOptions } from '../../agent.js';
9
11
  import type { Agent, AgencyStrategy, HitlConfig } from '../../types.js';
10
12
  import type { ApprovalGateFn } from '../approval-gate.js';
11
13
  import type { SpendBudget } from '../spendBudget.js';
14
+ import type { GMIToolCallGate } from '../../../cognition/substrate/IGMI.js';
15
+ import type { JSONSchemaObject } from '../../../core/tools/ITool.js';
12
16
  import type { IToolOrchestrator } from '../../../core/tools/IToolOrchestrator.js';
13
17
  export type { SeatMetadata } from '../../types.js';
14
18
  /** The tool's name on every surface. */
15
19
  export declare const LAUNCH_AGENCY_TOOL_NAME = "launch_agency";
16
20
  /** The six strategies a launch offers: the tool's input schema lists them and the engine accepts them. */
17
21
  export declare const LAUNCH_STRATEGIES: readonly ["sequential", "parallel", "debate", "review-loop", "hierarchical", "graph"];
18
- /** The capability a full-runtime persona's grant would name for the tool. No code reads it: gmi() is the one surface that registers `launch_agency`. */
22
+ /**
23
+ * The capability the full runtime's `launch_agency` requires (`requiredCapabilities`): only a persona whose
24
+ * `allowedCapabilities` names it lists and calls the tool, while the runtime checks capabilities strictly (its
25
+ * `toolPermissionManagerConfig.strictCapabilityChecking`, on by default). gmi() registers the tool for its agent alone
26
+ * and checks no capability.
27
+ */
19
28
  export declare const LAUNCH_CAPABILITY = "agency:launch";
20
29
  /** The five self-modification tools, which a seat never gets. */
21
30
  export declare const SELF_MODIFICATION_TOOLS: readonly ["forge_tool", "create_workflow", "manage_skills", "self_evaluate", "adapt_personality"];
@@ -31,7 +40,10 @@ export declare const LAUNCH_SETTLE_GRACE_MS = 5000;
31
40
  export declare const LAUNCH_TEXT_CHARS = 16000;
32
41
  /** The longest seat summary a launch returns. */
33
42
  export declare const SEAT_SUMMARY_CHARS = 1000;
34
- /** The prompt's allowance in the smallest launch: a child's token cap must cover it plus one call's output estimate. */
43
+ /**
44
+ * The prompt's allowance in the smallest launch: a child's token cap must cover it plus the output estimate of one call,
45
+ * the largest a seat of the team makes.
46
+ */
35
47
  export declare const MIN_LAUNCH_TOKENS = 2000;
36
48
  /** The longest role: `delegate_to_<role>` stays within the 64 characters OpenAI allows a function name. */
37
49
  export declare const MAX_ROLE_CHARS = 52;
@@ -43,7 +55,18 @@ export interface AgencyLaunchOptions {
43
55
  * Registers `launch_agency` on the agent's tool table. Default false. On gmi(), a launched team's manager, synthesizers
44
56
  * and temporary seats run on the provider and model the agent's first call resolved: those its options name, else the
45
57
  * environment's pair at that call, whatever the environment names later. A call that names its own provider or model
46
- * runs on that pair alone; a team it launches runs on the agent's.
58
+ * runs on that pair alone; a team it launches runs on the agent's. A temporary seat also takes the agent's other route
59
+ * and completion settings, its `onBeforeGeneration` and `onAfterGeneration` hooks and, of its controls,
60
+ * `controls.maxDurationMs` alone: a cap the agent's calls take from `controls.maxTotalTokens` does not reach a seat's
61
+ * calls, which the launch's budget bounds. Every seat's tool calls run the `onBeforeToolExecution` hooks of the turn
62
+ * that launched the team, a member's before its own. The manager and synthesizers, which agency() builds on agent(),
63
+ * take that pair with the agent's key and base URL alone: none of its hooks and no request timeout reach their calls,
64
+ * which the launch's deadline and budget bound. A seat whose call fails rejects with its error's name and code alone,
65
+ * so a provider's or a handler's message reaches no model of the team and not the result; the error itself goes to
66
+ * the agent's `on.error`, under `launch_agency seat <role>` (the console without one), as do the launch's other
67
+ * failures, a failed run apart: the team reports its run once, under `launch:<agencyId>`, with the error it rejected
68
+ * with. A seat's name holds its role and not its team, so two teams' seats of one role report under one name. A
69
+ * callback that throws or rejects fails no launch.
47
70
  */
48
71
  launch?: boolean;
49
72
  /** The deepest team level a launch tree reaches: an integer from 1 to 4, default 2. */
@@ -66,14 +89,54 @@ export interface AgencyLaunchOptions {
66
89
  defaultDeadlineMs?: number;
67
90
  /** The longest deadline a launch may name, in ms: from 1,000 to 3,600,000, default 600,000. */
68
91
  maxDeadlineMs?: number;
69
- /** gmi() only: the persistent members a launch may seat by agentKey, each a gmi() handle. */
92
+ /**
93
+ * gmi() only: the persistent members a launch may seat by agentKey, each a gmi() handle. The record is read once,
94
+ * when the agent is built: a member put in it afterwards, under a new key or an old one, is never seated.
95
+ */
70
96
  members?: Record<string, Agent>;
71
- /** The approval policy every launched team runs under after the gate the launching turn carries; applied at a root launch and inherited below it. */
97
+ /**
98
+ * The approval policy of the team a root launch builds, asked after the gate the launching turn carries. A nested
99
+ * launch passes that team's gate on, so `beforeTool` covers the seats of every team below it, each tool call asked
100
+ * once. `beforeAgent` and `beforeReturn` are asked in the root team alone: no nested team's seat or answer waits
101
+ * for them.
102
+ */
72
103
  hitl?: HitlConfig;
73
104
  }
74
- /** The bounds of a launch on the full runtime, with the route of its coordinator. AgentOSConfig takes no `agencies` option: gmi() is the one surface that registers `launch_agency`. */
75
- export interface RuntimeAgencyLaunchOptions extends Omit<AgencyLaunchOptions, 'members'> {
76
- /** The route of a launched team's manager and synthesizers (they call generateText). Default: the parent persona's provider and model, with the key and base URL of the runtime's entry for that provider. */
105
+ /**
106
+ * `AgentOSConfig.agencies`: whether the full runtime registers `launch_agency`, and every launch's bounds. `launch: true`
107
+ * registers the tool, which requires {@link LAUNCH_CAPABILITY}, so only a persona granted it lists and calls it. A
108
+ * seat is a GMI of the runtime's GMIManager: a registered persona a launch names by `personaId` (in place of
109
+ * `agentKey`), or a persona made for a temporary seat from the calling GMI's (its route, completion options,
110
+ * capabilities and hard limits, with the seat's instructions as its prompt). Every seat runs through a view of the
111
+ * runtime's tools that lists and runs its allowlist alone, as the parent turn's user and organization, with no
112
+ * cognitive memory, no retrieval and no learner.
113
+ */
114
+ export interface RuntimeAgencyLaunchOptions extends Omit<AgencyLaunchOptions, 'members' | 'launch'> {
115
+ /**
116
+ * Registers `launch_agency` among the runtime's config tools, for the personas granted `agency:launch`: a config tool
117
+ * of the host's own by that name then fails initialization. Default false. A seat whose call fails rejects with its
118
+ * error's name and code alone, so a provider's or a handler's message reaches no model of the team and not the
119
+ * result; the error itself goes to the runtime's logger (the one `AgentOS.create` takes, else its own), at warn,
120
+ * under `launch_agency seat <role>`, as do the launch's other failures (a failed run under `launch_agency run`). A
121
+ * logger that throws fails no launch. The output guardrails that judge the launching turn's tool calls
122
+ * (`config.evaluateToolCalls`) judge each call of every seat, a nested team's included, before it runs, beside the
123
+ * sources the launching turn retrieved, and a call they block is refused as the launching turn's would be. The usage
124
+ * the runtime's spend meter (`spendMeter`) records for the launching turn is that turn's own model calls: a team's
125
+ * calls are its seats' GMIs' and its coordinator's, which the launch's result reports (`usage`, `coordinatorUsage`).
126
+ */
127
+ launch?: boolean;
128
+ /**
129
+ * The route of a launched team's manager and synthesizers (they call generateText). Default: the provider and model of
130
+ * the persona of the GMI that launched the team, else the GMIs' defaults
131
+ * (`gmiManagerConfig.defaultGMIBaseConfigDefaults`); when neither names a provider, the one the runtime's provider
132
+ * manager serves that model from, as for the GMI itself. A route that names neither `apiKey` nor `baseUrl` takes the
133
+ * key of the entry in `modelProviderManagerConfig.providers` the runtime serves its provider from (the last enabled one
134
+ * whose provider started), and sends it where the runtime's provider sends it: to that entry's base URL, else to the
135
+ * provider's own endpoint, never to a base URL a global default or an environment variable names. An entry with a base
136
+ * URL and no key gives its base URL alone to an Ollama route only. What the route takes nothing for, generateText
137
+ * resolves for the provider, key and base URL together, as for any call that names neither. A route that names either
138
+ * keeps what it names and takes nothing of the entry.
139
+ */
77
140
  coordinator?: {
78
141
  provider: string;
79
142
  model: string;
@@ -116,6 +179,13 @@ export interface CallerTurnContext {
116
179
  toolHooks?: readonly ToolCallHook[];
117
180
  /** The processToolCall of the view that made the call; the step gate runs each step of a composed tool through it. */
118
181
  dispatch?: IToolOrchestrator['processToolCall'];
182
+ /**
183
+ * The full runtime: the gate the turn's output guardrails that judge tool calls (`config.evaluateToolCalls`) ask
184
+ * before each call of the turn's own tool round. A GMI whose turn has one passes it with every call it makes, asked
185
+ * beside the sources the turn retrieved, and a team a call launches gives it to each of its seats' turns, so a seat's
186
+ * calls are judged as the launching turn's are, beside what that turn read.
187
+ */
188
+ toolCallGate?: GMIToolCallGate;
119
189
  }
120
190
  /** One seat a launch names: exactly one of `instructions`, `agentKey` (gmi()) or `personaId` (the full runtime). */
121
191
  export type LaunchSeatSpec = {
@@ -172,9 +242,12 @@ export type LaunchStatus = 'completed' | 'timed_out' | 'budget_exhausted' | 'can
172
242
  * or a composed tool one of whose steps its allowlist leaves out.
173
243
  * - `seat_form_unsupported`: a seat form the surface does not run (`personaId` on gmi(), `agentKey` on the full runtime).
174
244
  * - `unknown_member`: a seat names a member the surface does not have.
175
- * - `member_unavailable`: a member could not be seated.
245
+ * - `member_unavailable`: a seat could not be built: a member that cannot take a seat (on the full runtime, a persona
246
+ * the user's tier or strict validation refuses), or the agent or GMI made for a temporary seat.
176
247
  * - `duplicate_member`: two seats name one member.
177
- * - `budget_unavailable`: the launch's token cap cannot cover one call, or it has no dollars left.
248
+ * - `budget_unavailable`: the launch's token cap cannot cover one call of the seat whose calls are largest
249
+ * (`MIN_LAUNCH_TOKENS` for the prompt and that seat's output estimate, on the route its calls run on), or it has no
250
+ * dollars left.
178
251
  * - `parent_launch_closed`: the team the calling seat sits in is closing or gone.
179
252
  */
180
253
  export type LaunchRefusalCode = 'invalid_arguments' | 'depth_exceeded' | 'too_many_seats' | 'concurrency_exceeded' | 'unknown_tool' | 'tool_not_allowed' | 'seat_form_unsupported' | 'unknown_member' | 'member_unavailable' | 'duplicate_member' | 'budget_unavailable' | 'parent_launch_closed';
@@ -272,14 +345,29 @@ export interface LaunchRecordMetadata {
272
345
  /** The goal's first 200 characters. */
273
346
  goalPreview: string;
274
347
  startedAt: string;
348
+ /**
349
+ * 'running' while the team runs; 'closing' once the launch has returned while a seat, or a launch its seats started,
350
+ * still holds a GMI; the launch's own status, merged with `closedAt` and `usage` just before the entry is removed.
351
+ */
275
352
  status: 'running' | 'closing' | LaunchStatus;
353
+ /** When the launch returned its result. */
276
354
  closedAt?: string;
355
+ /** The seats' usage, as the launch's result reports it. */
277
356
  usage?: LaunchUsage;
278
357
  }
279
358
  /** Whether `value` is a handle gmi() built (the non-enumerable mark gmi() sets). */
280
359
  export declare function isGmiHandle(value: unknown): value is Agent;
281
360
  /** The options a gmi() handle was built with, or undefined for any other value. */
282
361
  export declare function gmiOptionsOf(value: unknown): AgentOptions | undefined;
362
+ /**
363
+ * Reads the provider and model a gmi() handle's persona resolved (the pair its options name, else the environment's at
364
+ * its first build), or undefined for any other value. The read builds the agent's shared state, as its first session
365
+ * does.
366
+ */
367
+ export declare function gmiRouteOf(value: unknown): (() => Promise<{
368
+ provider?: string;
369
+ model?: string;
370
+ }>) | undefined;
283
371
  /**
284
372
  * Applies the defaults of `agencies` and checks every bound, at construction (`gmi()`, `AgentOS.initialize`).
285
373
  *
@@ -291,6 +379,31 @@ export declare function gmiOptionsOf(value: unknown): AgentOptions | undefined;
291
379
  * @throws {AgencyConfigError} For `hitl` approvals with no handler, the rule `agency()` applies.
292
380
  */
293
381
  export declare function resolveLaunchLimits(options: AgencyLaunchOptions | RuntimeAgencyLaunchOptions): LaunchLimits;
382
+ /**
383
+ * The persistent members a surface's `launch_agency` seats as themselves: gmi()'s `agencies.members` by `agentKey`, or
384
+ * the full runtime's registered personas by `personaId`.
385
+ */
386
+ export type LaunchMemberForm = {
387
+ field: 'agentKey';
388
+ keys: readonly string[];
389
+ } | {
390
+ field: 'personaId';
391
+ };
392
+ /**
393
+ * The input schema `launch_agency` offers the model. Counts, unknown keys and the forms' rules are the engine's
394
+ * (`validateLaunchArgs`), with its codes.
395
+ *
396
+ * @param limits - The tree's limits: the seat count and the deadlines the schema states.
397
+ * @param members - The members the surface seats as themselves; none, and the schema offers instructions alone.
398
+ */
399
+ export declare function launchAgencyInputSchema(limits: LaunchLimits, members?: LaunchMemberForm): JSONSchemaObject;
400
+ /**
401
+ * What the model reads about `launch_agency`.
402
+ *
403
+ * @param limits - The tree's limits: the seat count the description states.
404
+ * @param members - The members the surface seats as themselves; none, and every seat is an agent made for the team.
405
+ */
406
+ export declare function launchAgencyDescription(limits: LaunchLimits, members?: LaunchMemberForm): string;
294
407
  /** A tool as the seat rules read it: its name and, for a composed tool, the tools its steps call. */
295
408
  export interface SeatToolLike {
296
409
  readonly name: string;