@opengeni/core 3.0.1 → 3.1.2

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 (257) hide show
  1. package/README.md +4 -4
  2. package/dist/access/index.d.ts +131 -7
  3. package/dist/access/service-initiator.d.ts +3 -0
  4. package/dist/application/archived-session-imports.d.ts +6 -0
  5. package/dist/application/composer-submit.d.ts +1 -1
  6. package/dist/application/connect-operation.d.ts +6 -0
  7. package/dist/application/external-workspace-members.d.ts +13 -1
  8. package/dist/application/modal-native-live-declaration-join.d.ts +37 -0
  9. package/dist/application/modal-native-original-configuration.d.ts +79 -0
  10. package/dist/application/modal-native-worker-host-transport.d.ts +297 -0
  11. package/dist/application/new-session-drafts.d.ts +29 -2
  12. package/dist/application/organization-privacy.d.ts +57 -0
  13. package/dist/application/prepared-mcp-connection.d.ts +31 -0
  14. package/dist/application/sandbox-recovery.d.ts +58 -0
  15. package/dist/application/session-commands.d.ts +3 -0
  16. package/dist/application/session-tenancy.d.ts +13 -4
  17. package/dist/billing/agent-run-admission.d.ts +21 -0
  18. package/dist/billing/limits.d.ts +27 -1
  19. package/dist/billing/model-call-admission.d.ts +34 -0
  20. package/dist/billing/model-usage-settlement.d.ts +112 -0
  21. package/dist/canonical-human-identities.js +1 -1
  22. package/dist/{chunk-VCZFFEPB.js → chunk-7T2SZ7BI.js} +16 -2
  23. package/dist/chunk-7T2SZ7BI.js.map +1 -0
  24. package/dist/{chunk-ZYCNLYGH.js → chunk-OMJFIIWK.js} +178 -12
  25. package/dist/chunk-OMJFIIWK.js.map +1 -0
  26. package/dist/{chunk-H7X52RI2.js → chunk-QI2M2B2K.js} +83 -8
  27. package/dist/chunk-QI2M2B2K.js.map +1 -0
  28. package/dist/{chunk-OF65T3PM.js → chunk-TTWTXQB2.js} +94 -6
  29. package/dist/chunk-TTWTXQB2.js.map +1 -0
  30. package/dist/codex-model-availability.d.ts +55 -0
  31. package/dist/default-session-model.d.ts +192 -0
  32. package/dist/dependencies.d.ts +41 -7
  33. package/dist/developer-setup-credential-ceiling.d.ts +10 -0
  34. package/dist/domain/agent-config-resolution.d.ts +49 -0
  35. package/dist/domain/automations.d.ts +8 -1
  36. package/dist/domain/capabilities.d.ts +112 -8
  37. package/dist/domain/connection-account-selection-error.d.ts +8 -0
  38. package/dist/domain/connector-tool-permissions.d.ts +62 -0
  39. package/dist/domain/direct-model-provider.d.ts +3 -0
  40. package/dist/domain/editable-artifacts/agent-application.d.ts +10 -1
  41. package/dist/domain/editable-artifacts/durable-export.d.ts +22 -1
  42. package/dist/domain/editable-artifacts/ports.d.ts +10 -0
  43. package/dist/domain/editable-artifacts/service.d.ts +3 -1
  44. package/dist/domain/editable-artifacts/types.d.ts +1 -1
  45. package/dist/domain/encryption-key.d.ts +12 -0
  46. package/dist/domain/insights-timing.d.ts +16 -0
  47. package/dist/domain/insights-usage.d.ts +27 -0
  48. package/dist/domain/insights.d.ts +21 -3
  49. package/dist/domain/knowledge-files.d.ts +1 -1
  50. package/dist/domain/knowledge-preparation.d.ts +10 -0
  51. package/dist/domain/knowledge-preparation.test.d.ts +1 -0
  52. package/dist/domain/knowledge-search.d.ts +15 -76
  53. package/dist/domain/mcp-account-bindings.d.ts +17 -0
  54. package/dist/domain/mcp-account-routes.d.ts +21 -0
  55. package/dist/domain/native-mcp-connection-admission.d.ts +3 -0
  56. package/dist/domain/organization-integration-catalog.d.ts +15 -0
  57. package/dist/domain/personal-connection-delegations.d.ts +73 -12
  58. package/dist/domain/pr-review.d.ts +121 -6
  59. package/dist/domain/realtime-voice-billing.d.ts +103 -0
  60. package/dist/domain/resources.d.ts +17 -1
  61. package/dist/domain/scheduled-task-access.d.ts +265 -0
  62. package/dist/domain/scheduled-task-account-audit.d.ts +27 -0
  63. package/dist/domain/scheduled-task-audience.d.ts +70 -0
  64. package/dist/domain/scheduled-tasks.d.ts +61 -18
  65. package/dist/domain/session-connection-accounts.d.ts +53 -0
  66. package/dist/domain/session-file-access.d.ts +4 -0
  67. package/dist/domain/session-native-connection-replacement.d.ts +14 -0
  68. package/dist/domain/session-start-timing.d.ts +7 -0
  69. package/dist/domain/session-tool-policy.d.ts +102 -4
  70. package/dist/domain/sessions.d.ts +179 -15
  71. package/dist/domain/site-audience.d.ts +52 -0
  72. package/dist/domain/skills.d.ts +29 -1
  73. package/dist/domain/slack-bot.d.ts +46 -1
  74. package/dist/domain/slack-publication-secret-safety.d.ts +1 -1
  75. package/dist/domain/vaults/index.d.ts +7 -0
  76. package/dist/domain/vaults/mapping.d.ts +25 -0
  77. package/dist/domain/vaults/provider-registry.d.ts +72 -0
  78. package/dist/domain/vaults/provider-sync.d.ts +176 -0
  79. package/dist/domain/vaults/provider-writes.d.ts +57 -0
  80. package/dist/domain/vaults/secret-resolver.d.ts +34 -0
  81. package/dist/domain/vaults/types.d.ts +24 -0
  82. package/dist/domain/vaults/vault-service.d.ts +35 -0
  83. package/dist/domain/voice-input-billing.d.ts +77 -0
  84. package/dist/domain/web-search-billing.d.ts +51 -0
  85. package/dist/domain/workspace-credits.d.ts +7 -0
  86. package/dist/editable-artifact-live/application.d.ts +2 -1
  87. package/dist/editable-artifact-live/server.d.ts +5 -1
  88. package/dist/editable-artifact-live/ticket.d.ts +2 -1
  89. package/dist/editable-artifact-live/types.d.ts +9 -0
  90. package/dist/editable-artifact-live.js +2 -2
  91. package/dist/editable-artifacts.js +10 -2
  92. package/dist/goal-admission.d.ts +627 -0
  93. package/dist/host-session-usage-limit.d.ts +15 -0
  94. package/dist/index.d.ts +43 -8
  95. package/dist/index.js +22682 -11743
  96. package/dist/index.js.map +1 -1
  97. package/dist/managed-session.d.ts +110 -7
  98. package/dist/model-call.d.ts +58 -0
  99. package/dist/model-catalog.d.ts +29 -3
  100. package/dist/model-provider-credentials.d.ts +43 -0
  101. package/dist/product-usage-metrics.d.ts +30 -0
  102. package/dist/rigs/index.d.ts +1 -13
  103. package/dist/sandbox/fleet.d.ts +58 -4
  104. package/dist/sandbox/routing.d.ts +42 -2
  105. package/dist/sandbox/runtime-settings.d.ts +27 -17
  106. package/dist/session-authorization.d.ts +10 -0
  107. package/dist/session-usage-limit-metrics.d.ts +60 -0
  108. package/dist/session-usage-limits.d.ts +89 -0
  109. package/dist/site-agent-clamp.d.ts +71 -0
  110. package/dist/site-session-origin.d.ts +39 -2
  111. package/dist/transcription.d.ts +120 -3
  112. package/dist/turn-surface.d.ts +20 -0
  113. package/dist/user-presence.d.ts +32 -0
  114. package/dist/workflow-wake-contract.d.ts +13 -1
  115. package/package.json +15 -22
  116. package/src/access/index.ts +961 -38
  117. package/src/access/service-initiator.ts +50 -0
  118. package/src/application/api-integration-servers.ts +9 -0
  119. package/src/application/archived-session-imports.ts +161 -0
  120. package/src/application/composer-submit.ts +3 -2
  121. package/src/application/connect-authority.ts +3 -3
  122. package/src/application/connect-operation.ts +37 -3
  123. package/src/application/external-continuation.ts +20 -3
  124. package/src/application/external-link-work-admission.ts +3 -0
  125. package/src/application/external-workspace-members.ts +51 -3
  126. package/src/application/modal-native-live-declaration-join.ts +196 -0
  127. package/src/application/modal-native-original-configuration.ts +261 -0
  128. package/src/application/modal-native-worker-host-transport.ts +263 -0
  129. package/src/application/new-session-drafts.ts +172 -55
  130. package/src/application/organization-privacy.ts +161 -0
  131. package/src/application/prepared-mcp-connection.ts +133 -0
  132. package/src/application/sandbox-recovery.ts +78 -0
  133. package/src/application/session-commands.ts +73 -1
  134. package/src/application/session-mcp-credential-rotation.ts +61 -18
  135. package/src/application/session-tenancy.ts +262 -44
  136. package/src/application/user-resource-grants.ts +1 -29
  137. package/src/billing/agent-run-admission.ts +117 -0
  138. package/src/billing/limits.ts +138 -14
  139. package/src/billing/model-call-admission.ts +118 -0
  140. package/src/billing/model-usage-settlement.ts +472 -0
  141. package/src/codex-model-availability.ts +264 -0
  142. package/src/default-session-model.ts +692 -0
  143. package/src/dependencies.ts +48 -6
  144. package/src/developer-setup-credential-ceiling.ts +60 -0
  145. package/src/domain/agent-config-resolution.ts +148 -0
  146. package/src/domain/automations.ts +76 -2
  147. package/src/domain/capabilities.ts +830 -181
  148. package/src/domain/connection-account-selection-error.ts +19 -0
  149. package/src/domain/connector-tool-permissions.ts +572 -0
  150. package/src/domain/direct-model-provider.ts +62 -0
  151. package/src/domain/editable-artifacts/agent-application.ts +44 -6
  152. package/src/domain/editable-artifacts/durable-export.ts +100 -5
  153. package/src/domain/editable-artifacts/in-memory.ts +6 -0
  154. package/src/domain/editable-artifacts/ports.ts +11 -0
  155. package/src/domain/editable-artifacts/service.ts +20 -0
  156. package/src/domain/editable-artifacts/types.ts +1 -1
  157. package/src/domain/encryption-key.ts +26 -0
  158. package/src/domain/file-owner.ts +16 -1
  159. package/src/domain/github-action-policies.ts +1 -1
  160. package/src/domain/github-skill-source.ts +3 -1
  161. package/src/domain/insights-timing.ts +95 -0
  162. package/src/domain/insights-usage.ts +67 -0
  163. package/src/domain/insights.ts +167 -43
  164. package/src/domain/knowledge-files.ts +10 -3
  165. package/src/domain/knowledge-messages.ts +1 -0
  166. package/src/domain/knowledge-preparation.test.ts +276 -0
  167. package/src/domain/knowledge-preparation.ts +147 -0
  168. package/src/domain/knowledge-search.test.ts +617 -5
  169. package/src/domain/knowledge-search.ts +240 -23
  170. package/src/domain/mcp-account-bindings.ts +169 -0
  171. package/src/domain/mcp-account-routes.ts +152 -0
  172. package/src/domain/native-mcp-connection-admission.ts +14 -0
  173. package/src/domain/organization-integration-catalog.ts +88 -0
  174. package/src/domain/personal-connection-delegations.ts +399 -257
  175. package/src/domain/pr-review.ts +24 -8
  176. package/src/domain/realtime-voice-billing.ts +425 -0
  177. package/src/domain/resources.ts +50 -4
  178. package/src/domain/scheduled-task-access.ts +1089 -0
  179. package/src/domain/scheduled-task-account-audit.ts +90 -0
  180. package/src/domain/scheduled-task-audience.ts +249 -0
  181. package/src/domain/scheduled-tasks.ts +1313 -374
  182. package/src/domain/session-connection-accounts.ts +239 -0
  183. package/src/domain/session-file-access.ts +47 -0
  184. package/src/domain/session-native-connection-replacement.ts +64 -0
  185. package/src/domain/session-start-timing.ts +60 -0
  186. package/src/domain/session-tool-policy.ts +489 -14
  187. package/src/domain/sessions.ts +2254 -717
  188. package/src/domain/site-audience.ts +130 -0
  189. package/src/domain/skills.ts +9 -0
  190. package/src/domain/slack-bot.ts +141 -4
  191. package/src/domain/slack-publication-secret-safety.ts +1 -1
  192. package/src/domain/vaults/index.ts +19 -0
  193. package/src/domain/vaults/mapping.ts +190 -0
  194. package/src/domain/vaults/provider-registry.ts +201 -0
  195. package/src/domain/vaults/provider-sync.ts +531 -0
  196. package/src/domain/vaults/provider-writes.ts +288 -0
  197. package/src/domain/vaults/secret-resolver.ts +464 -0
  198. package/src/domain/vaults/types.ts +26 -0
  199. package/src/domain/vaults/vault-service.ts +1316 -0
  200. package/src/domain/voice-input-billing.ts +330 -0
  201. package/src/domain/web-search-billing.ts +169 -0
  202. package/src/domain/workspace-credits.ts +13 -0
  203. package/src/editable-artifact-live/application.ts +8 -1
  204. package/src/editable-artifact-live/server.ts +154 -6
  205. package/src/editable-artifact-live/ticket.ts +86 -1
  206. package/src/editable-artifact-live/types.ts +10 -0
  207. package/src/goal-admission.ts +220 -0
  208. package/src/host-session-usage-limit.ts +25 -0
  209. package/src/index.ts +75 -11
  210. package/src/managed-session.ts +137 -6
  211. package/src/model-call.ts +79 -0
  212. package/src/model-catalog.ts +345 -91
  213. package/src/model-provider-credentials.ts +394 -0
  214. package/src/product-usage-metrics.ts +101 -0
  215. package/src/rigs/index.ts +23 -111
  216. package/src/sandbox/fleet.ts +253 -28
  217. package/src/sandbox/routing.ts +204 -43
  218. package/src/sandbox/runtime-settings.ts +159 -85
  219. package/src/session-authorization.ts +172 -23
  220. package/src/session-usage-limit-metrics.ts +95 -0
  221. package/src/session-usage-limits.ts +415 -0
  222. package/src/site-agent-clamp.ts +226 -0
  223. package/src/site-session-origin.ts +84 -5
  224. package/src/transcription.ts +123 -4
  225. package/src/turn-surface.ts +47 -0
  226. package/src/user-presence.ts +134 -0
  227. package/src/workflow-wake-contract.ts +14 -1
  228. package/dist/application/host-mcp-owner.d.ts +0 -6
  229. package/dist/application/host-mcp-resolvers.d.ts +0 -13
  230. package/dist/chunk-5WZYFL45.js +0 -266
  231. package/dist/chunk-5WZYFL45.js.map +0 -1
  232. package/dist/chunk-H7X52RI2.js.map +0 -1
  233. package/dist/chunk-OF65T3PM.js.map +0 -1
  234. package/dist/chunk-VCZFFEPB.js.map +0 -1
  235. package/dist/chunk-ZYCNLYGH.js.map +0 -1
  236. package/dist/domain/connection-authority.d.ts +0 -97
  237. package/dist/domain/connection-authority.js +0 -169
  238. package/dist/domain/connection-authority.js.map +0 -1
  239. package/dist/domain/environments.d.ts +0 -33
  240. package/dist/domain/host-mcp-authority-source-admission.d.ts +0 -10
  241. package/dist/domain/host-mcp-task-admission.d.ts +0 -18
  242. package/dist/domain/packs.d.ts +0 -59
  243. package/dist/domain/product-integration-pack.d.ts +0 -44
  244. package/dist/domain/product-integration-skill.gen.d.ts +0 -5
  245. package/dist/remote-mcp-credentials.d.ts +0 -23
  246. package/dist/remote-mcp-credentials.js +0 -11
  247. package/dist/remote-mcp-credentials.js.map +0 -1
  248. package/src/application/host-mcp-owner.ts +0 -41
  249. package/src/application/host-mcp-resolvers.ts +0 -84
  250. package/src/domain/connection-authority.ts +0 -329
  251. package/src/domain/environments.ts +0 -120
  252. package/src/domain/host-mcp-authority-source-admission.ts +0 -25
  253. package/src/domain/host-mcp-task-admission.ts +0 -121
  254. package/src/domain/packs.ts +0 -699
  255. package/src/domain/product-integration-pack.ts +0 -42
  256. package/src/domain/product-integration-skill.gen.ts +0 -52
  257. package/src/remote-mcp-credentials.ts +0 -361
@@ -1,699 +0,0 @@
1
- import { createHash } from "node:crypto";
2
-
3
- import {
4
- CapabilityPack,
5
- StoredCapabilityPack,
6
- OPENGENI_PR_REVIEW_PACK_ID,
7
- OPENGENI_PR_REVIEW_SESSION_ROLE,
8
- stableJson,
9
- type CapabilityPackSkill,
10
- type PackComponentResolution,
11
- type PackInstallationPreview,
12
- type PackRigResolution,
13
- type ScheduledTaskAgentConfig,
14
- type SocialConnection,
15
- } from "@opengeni/contracts";
16
- import {
17
- getPackInstallation,
18
- getRig,
19
- getVariableSet,
20
- getWorkspacePack,
21
- listPackInstallations,
22
- listWorkspacePacks,
23
- resolvePackComponentReferences,
24
- resolvePackInlineSkillReferences,
25
- type Database,
26
- } from "@opengeni/db";
27
- import { buildPortableSkillArtifact } from "@opengeni/runtime/skill-library";
28
- import { HTTPException } from "hono/http-exception";
29
- import {
30
- OPENGENI_PR_REVIEW_AGENT_INSTRUCTIONS,
31
- OPENGENI_PR_REVIEW_SKILL,
32
- PR_REVIEW_AUTOMATION_ADAPTER_ID,
33
- PR_REVIEW_AUTOMATION_TEMPLATE_ID,
34
- } from "./pr-review";
35
- import { OPENGENI_PRODUCT_INTEGRATION_PACK } from "./product-integration-pack";
36
-
37
- export const MARKETING_SOCIAL_PACK_ID = "marketing-social-daily-analysis";
38
-
39
- const marketingSocialPack: CapabilityPack = {
40
- id: MARKETING_SOCIAL_PACK_ID,
41
- name: "Marketing social daily analysis",
42
- description:
43
- "Connect social accounts, attach marketing knowledge, and schedule agents to produce daily media performance analysis.",
44
- role: "marketing",
45
- category: "social-media",
46
- version: "0.1.0",
47
- // Built-in packs deliberately declare no sandboxImage and no skills: the
48
- // worker's pack-runtime resolution only reads manifest-registered packs
49
- // (see apps/worker/src/activities/packs.ts), and a test enforces this.
50
- skills: [],
51
- components: [],
52
- automationTemplates: [],
53
- tools: [
54
- { kind: "mcp", id: "opengeni" },
55
- { kind: "mcp", id: "docs" },
56
- ],
57
- connectors: [
58
- {
59
- id: "x",
60
- name: "X",
61
- category: "social-media",
62
- authModel: "oauth2_authorization_code_pkce",
63
- providers: ["x"],
64
- scopes: ["tweet.read", "tweet.write", "users.read", "offline.access"],
65
- required: false,
66
- metadata: {
67
- docs: "https://docs.x.com/fundamentals/authentication/oauth-2-0/authorization-code",
68
- firstParty: true,
69
- oauthStartPath: "/social/oauth/start",
70
- },
71
- },
72
- {
73
- id: "reddit",
74
- name: "Reddit",
75
- category: "social-media",
76
- authModel: "oauth2_authorization_code",
77
- providers: ["reddit"],
78
- scopes: ["identity", "read", "submit", "privatemessages", "history"],
79
- required: false,
80
- metadata: {
81
- docs: "https://github.com/reddit-archive/reddit/wiki/OAuth2",
82
- firstParty: true,
83
- oauthStartPath: "/social/oauth/start",
84
- },
85
- },
86
- {
87
- id: "linkedin",
88
- name: "LinkedIn",
89
- category: "social-media",
90
- authModel: "oauth2_authorization_code",
91
- providers: ["linkedin"],
92
- scopes: ["r_organization_social", "rw_organization_admin"],
93
- required: false,
94
- metadata: {
95
- docs: "https://learn.microsoft.com/en-us/linkedin/marketing/community-management/community-management-overview",
96
- },
97
- },
98
- {
99
- id: "instagram",
100
- name: "Instagram",
101
- category: "social-media",
102
- authModel: "oauth2_authorization_code",
103
- providers: ["instagram", "facebook"],
104
- scopes: [
105
- "instagram_basic",
106
- "instagram_manage_insights",
107
- "pages_read_engagement",
108
- "pages_show_list",
109
- ],
110
- required: false,
111
- metadata: {
112
- docs: "https://developers.facebook.com/docs/instagram-platform/instagram-graph-api/",
113
- },
114
- },
115
- {
116
- id: "tiktok",
117
- name: "TikTok",
118
- category: "social-media",
119
- authModel: "oauth2_authorization_code",
120
- providers: ["tiktok"],
121
- scopes: ["user.info.basic", "video.list"],
122
- required: false,
123
- metadata: {
124
- docs: "https://developers.tiktok.com/doc/tiktok-api-v2-introduction/",
125
- },
126
- },
127
- {
128
- id: "youtube",
129
- name: "YouTube",
130
- category: "social-media",
131
- authModel: "oauth2_authorization_code",
132
- providers: ["youtube"],
133
- scopes: [
134
- "https://www.googleapis.com/auth/youtube.readonly",
135
- "https://www.googleapis.com/auth/yt-analytics.readonly",
136
- ],
137
- required: false,
138
- metadata: {
139
- docs: "https://developers.google.com/youtube/v3",
140
- },
141
- },
142
- ],
143
- knowledge: [
144
- {
145
- type: "document_base",
146
- id: "marketing-playbook",
147
- name: "Marketing playbook",
148
- description:
149
- "Optional workspace document base with brand voice, campaign calendars, audience research, and reporting rules.",
150
- required: false,
151
- },
152
- ],
153
- scheduledTaskTemplates: [
154
- {
155
- id: "daily-social-analysis",
156
- name: "Daily social analysis",
157
- description: "Review the latest social posts and account signals every day.",
158
- defaultSchedule: {
159
- type: "calendar",
160
- timeZone: "UTC",
161
- hour: 9,
162
- minute: 0,
163
- },
164
- defaultRunMode: "new_session_per_run",
165
- defaultOverlapPolicy: "skip",
166
- },
167
- ],
168
- metadata: {
169
- skill: "social-media-marketing",
170
- firstPartyMcpTools: [
171
- "social_connections_list",
172
- "social_posts_recent",
173
- "social_daily_analysis_context",
174
- "x_accounts_list",
175
- "x_search_live",
176
- "x_mentions_live",
177
- "x_thread_fetch",
178
- "x_posts_sync",
179
- "x_post_reply",
180
- "reddit_accounts_list",
181
- "reddit_search_live",
182
- "reddit_mentions_live",
183
- "reddit_thread_fetch",
184
- "reddit_posts_sync",
185
- "reddit_post_reply",
186
- ],
187
- },
188
- };
189
-
190
- const openGeniPrReviewPack: CapabilityPack = {
191
- id: OPENGENI_PR_REVIEW_PACK_ID,
192
- name: "OpenGeni Review Bot",
193
- description:
194
- "Run provider-neutral, exact-head pull-request reviews from GitHub, GitLab, or Azure DevOps webhooks.",
195
- role: "software-engineering",
196
- category: "code-review",
197
- version: "0.2.0",
198
- skills: [OPENGENI_PR_REVIEW_SKILL],
199
- components: [],
200
- tools: [],
201
- connectors: [
202
- {
203
- id: "github",
204
- name: "GitHub App",
205
- category: "source-control",
206
- authModel: "credential_ref",
207
- providers: ["github"],
208
- scopes: ["metadata:read", "contents:read", "pull_requests:write"],
209
- required: false,
210
- metadata: {
211
- oneOf: "source-control-provider",
212
- setupPath: "/pr-review/registrations",
213
- webhookEvents: ["pull_request"],
214
- credentialMode: "short_lived_installation_token",
215
- },
216
- },
217
- {
218
- id: "gitlab",
219
- name: "GitLab project token",
220
- category: "source-control",
221
- authModel: "credential_ref",
222
- providers: ["gitlab"],
223
- scopes: ["api", "read_repository"],
224
- required: false,
225
- metadata: {
226
- oneOf: "source-control-provider",
227
- setupPath: "/pr-review/registrations",
228
- webhookEvents: ["Merge Request Hook"],
229
- credentialMode: "provider_token",
230
- },
231
- },
232
- {
233
- id: "azure-devops",
234
- name: "Azure DevOps identity token",
235
- category: "source-control",
236
- authModel: "credential_ref",
237
- providers: ["azure_devops"],
238
- scopes: ["vso.code", "vso.threads_full"],
239
- required: false,
240
- metadata: {
241
- oneOf: "source-control-provider",
242
- setupPath: "/pr-review/registrations",
243
- webhookEvents: ["git.pullrequest.created", "git.pullrequest.updated"],
244
- credentialMode: "provider_token",
245
- },
246
- },
247
- ],
248
- knowledge: [],
249
- scheduledTaskTemplates: [],
250
- automationTemplates: [
251
- {
252
- id: PR_REVIEW_AUTOMATION_TEMPLATE_ID,
253
- name: "Review pull requests",
254
- description: "Start one exact-head review session for each accepted pull-request revision.",
255
- adapterId: PR_REVIEW_AUTOMATION_ADAPTER_ID,
256
- eventTypes: ["pull_request.review_requested"],
257
- configuration: {},
258
- connectionRequirement: "source-control-provider",
259
- sessionTemplate: {
260
- prompt: "Review the accepted pull-request revision and publish actionable findings.",
261
- instructions: OPENGENI_PR_REVIEW_AGENT_INSTRUCTIONS,
262
- resources: [],
263
- skills: [OPENGENI_PR_REVIEW_SKILL],
264
- tools: [],
265
- firstPartyMcpTools: [],
266
- firstPartyMcpPermissions: [],
267
- model: null,
268
- reasoningEffort: null,
269
- sandboxBackend: null,
270
- policyRole: OPENGENI_PR_REVIEW_SESSION_ROLE,
271
- metadata: { role: OPENGENI_PR_REVIEW_SESSION_ROLE },
272
- },
273
- },
274
- ],
275
- metadata: {
276
- automation: "pull_request_review",
277
- providers: ["github", "gitlab", "azure_devops"],
278
- sessionRole: "pull_request_review",
279
- },
280
- };
281
-
282
- const packs = [
283
- marketingSocialPack,
284
- openGeniPrReviewPack,
285
- OPENGENI_PRODUCT_INTEGRATION_PACK,
286
- ] satisfies CapabilityPack[];
287
-
288
- export function listCapabilityPacks(): CapabilityPack[] {
289
- return packs;
290
- }
291
-
292
- export function getCapabilityPack(packId: string): CapabilityPack | null {
293
- return packs.find((pack) => pack.id === packId) ?? null;
294
- }
295
-
296
- export function isBuiltInCapabilityPack(packId: string): boolean {
297
- return getCapabilityPack(packId) !== null;
298
- }
299
-
300
- /**
301
- * Built-in packs plus the manifests registered for this workspace. Stored
302
- * manifests retain exact historical bytes. Execution views derive Skill labels
303
- * from their files, but malformed content needs explicit repair, not omission.
304
- */
305
- export async function listWorkspaceCapabilityPacks(
306
- db: Database,
307
- workspaceId: string,
308
- ): Promise<CapabilityPack[]> {
309
- const registered = await listWorkspacePacks(db, workspaceId);
310
- const builtInIds = new Set(packs.map((pack) => pack.id));
311
- const registeredPacks = registered
312
- .filter((registration) => !builtInIds.has(registration.pack.id))
313
- .map((registration) => {
314
- const parsed = StoredCapabilityPack.safeParse(registration.pack);
315
- if (!parsed.success)
316
- throw new HTTPException(422, {
317
- message: `Stored Pack ${registration.pack.id} requires repair before it can be used: ${parsed.error.message}`,
318
- });
319
- return parsed.data;
320
- });
321
- return [...packs, ...registeredPacks];
322
- }
323
-
324
- export async function resolveCapabilityPack(
325
- db: Database,
326
- workspaceId: string,
327
- packId: string,
328
- ): Promise<CapabilityPack | null> {
329
- const builtIn = getCapabilityPack(packId);
330
- if (builtIn) {
331
- return builtIn;
332
- }
333
- const registration = await getWorkspacePack(db, workspaceId, packId);
334
- if (!registration) {
335
- return null;
336
- }
337
- const parsed = StoredCapabilityPack.safeParse(registration.pack);
338
- if (!parsed.success)
339
- throw new HTTPException(422, {
340
- message: `Stored Pack ${packId} requires repair before it can be used: ${parsed.error.message}`,
341
- });
342
- return parsed.data;
343
- }
344
-
345
- export function capabilityPackManifestDigest(pack: CapabilityPack): string {
346
- return createHash("sha256").update(stableJson(pack)).digest("hex");
347
- }
348
-
349
- /** True when the Pack must use the owner-aware V2 preview/install lifecycle. */
350
- export function capabilityPackRequiresInstallationPlan(pack: CapabilityPack): boolean {
351
- return (
352
- pack.components.length > 0 ||
353
- pack.skills.length > 0 ||
354
- (pack.automationTemplates?.length ?? 0) > 0 ||
355
- pack.rig !== undefined ||
356
- pack.sandboxImage !== undefined ||
357
- pack.sandboxProviderImages !== undefined
358
- );
359
- }
360
-
361
- export type InlinePackSkillInstall = {
362
- componentKey: string;
363
- capabilityId: string;
364
- pluginKey: string;
365
- sourceUrl: string;
366
- repositoryUrl: string;
367
- sourceCommit: string;
368
- sourcePath: string;
369
- name: string;
370
- description: string;
371
- activationMode: "workspace_managed" | "session_selected";
372
- contentSha256: string;
373
- totalBytes: number;
374
- files: Array<{ path: string; content: string; byteSize: number; contentSha256: string }>;
375
- };
376
-
377
- /** Convert a legacy inline Pack Skill into the ordinary immutable Skill model. */
378
- export function inlinePackSkillInstall(
379
- pack: CapabilityPack,
380
- skill: CapabilityPackSkill,
381
- ): InlinePackSkillInstall {
382
- const artifact = buildPortableSkillArtifact(skill.files);
383
- if (artifact.name.toLowerCase() !== skill.name.toLowerCase()) {
384
- throw new HTTPException(422, {
385
- message: `Pack Skill ${skill.name} has SKILL.md name ${artifact.name}; the names must match`,
386
- });
387
- }
388
- const normalizedName = skill.name.toLowerCase();
389
- const activationMode = skill.activationMode ?? "workspace_managed";
390
- const activationIdentity = activationMode === "session_selected" ? "session-selected/" : "";
391
- const encodedSkill = encodeURIComponent(normalizedName);
392
- const sourceUrl = `https://opengeni.invalid/pack-inline-skills/${activationIdentity}${encodedSkill}/${artifact.contentSha256}`;
393
- const capabilityId = `skill:pack-inline/${activationIdentity}${normalizedName}@${artifact.contentSha256}`;
394
- return {
395
- componentKey: `inline-skill/${normalizedName}`,
396
- capabilityId,
397
- pluginKey: `pack-skill/${activationIdentity}${normalizedName}/${artifact.contentSha256}`,
398
- sourceUrl,
399
- repositoryUrl: "https://opengeni.invalid/pack-inline-skills",
400
- sourceCommit: artifact.contentSha256,
401
- sourcePath: normalizedName,
402
- name: artifact.name,
403
- description: artifact.description,
404
- activationMode,
405
- contentSha256: artifact.contentSha256,
406
- totalBytes: artifact.totalBytes,
407
- files: artifact.files.map((file) => ({
408
- path: file.path,
409
- content: file.content,
410
- byteSize: new TextEncoder().encode(file.content).byteLength,
411
- contentSha256: createHash("sha256").update(file.content).digest("hex"),
412
- })),
413
- };
414
- }
415
-
416
- export async function previewCapabilityPackInstallation(
417
- db: Database,
418
- access: { accountId: string; workspaceId: string; subjectId: string },
419
- pack: CapabilityPack,
420
- options: { rigId?: string; variableSetId?: string } = {},
421
- ): Promise<PackInstallationPreview> {
422
- const { workspaceId } = access;
423
- const installation = await getPackInstallation(db, workspaceId, pack.id);
424
- const inlineInstalls = pack.skills.map((skill) => inlinePackSkillInstall(pack, skill));
425
- const manifestDigest = capabilityPackManifestDigest(pack);
426
- const inlineRequirements = inlineInstalls.map((inline) => ({
427
- key: inline.componentKey,
428
- capabilityId: inline.capabilityId,
429
- name: inline.name,
430
- activationMode: inline.activationMode,
431
- contentSha256: inline.contentSha256,
432
- }));
433
- const [referencedComponents, plannedInlineComponents, installedSessionSelectedComponents] =
434
- await Promise.all([
435
- resolvePackComponentReferences(db, workspaceId, pack.components),
436
- resolvePackInlineSkillReferences(db, workspaceId, inlineRequirements, installation?.id),
437
- installation?.status === "active" && installation.manifestDigest === manifestDigest
438
- ? resolvePackInlineSkillReferences(
439
- db,
440
- workspaceId,
441
- inlineRequirements.filter(
442
- (requirement) => requirement.activationMode === "session_selected",
443
- ),
444
- )
445
- : Promise.resolve([]),
446
- ]);
447
- const installedSessionSelectedByKey = new Map(
448
- installedSessionSelectedComponents.map((component) => [component.key, component]),
449
- );
450
- // Installation planning excludes the Pack's own current ownership so an
451
- // update can replace old inline content. For launch affordances, preserve an
452
- // independently resolved active facet-installation id on an exact installed
453
- // manifest. A missing facet retains the future capability id and therefore
454
- // cannot be mistaken for something a new session can select right now.
455
- const inlineComponents = plannedInlineComponents.map((component) => {
456
- const installed = installedSessionSelectedByKey.get(component.key);
457
- return installed?.status === "ready" && installed.resolvedId
458
- ? { ...component, resolvedId: installed.resolvedId }
459
- : component;
460
- });
461
- const components: PackComponentResolution[] = [...referencedComponents, ...inlineComponents];
462
- const blockers = components
463
- .filter((component) => component.required && component.status !== "ready")
464
- .map((component) =>
465
- component.status === "missing"
466
- ? `${component.label} is not installed in this workspace`
467
- : `${component.label} does not match the Pack's pinned version`,
468
- );
469
- const rig = await resolvePackRig(
470
- db,
471
- workspaceId,
472
- pack,
473
- options.rigId,
474
- installation?.selectedRigId,
475
- );
476
- if (
477
- rig.status !== "ready" &&
478
- rig.status !== "not_required" &&
479
- (rig.required || rig.requestedRigId !== null || rig.rigId !== null)
480
- ) {
481
- blockers.push(packRigBlocker(rig, pack.sandboxImage ?? null));
482
- }
483
- const variableSetId =
484
- options.variableSetId ?? storedVariableSetId(installation?.metadata) ?? null;
485
- if (pack.variableSet?.required && !variableSetId) {
486
- blockers.push("Choose saved configuration before installing this Pack");
487
- } else if (variableSetId) {
488
- const variableSet = await getVariableSet(db, access, variableSetId);
489
- if (!variableSet) {
490
- blockers.push("The selected configuration no longer exists in this workspace");
491
- } else {
492
- const missing = (pack.variableSet?.requiredVariables ?? []).filter(
493
- (name) => !variableSet.variables.some((variable) => variable.name === name),
494
- );
495
- if (missing.length > 0) {
496
- blockers.push(`Configuration is missing required value(s): ${missing.join(", ")}`);
497
- }
498
- }
499
- }
500
- const action =
501
- !installation || installation.status === "disabled"
502
- ? "install"
503
- : installation.manifestDigest === manifestDigest
504
- ? "repair"
505
- : "update";
506
- return {
507
- packId: pack.id,
508
- packVersion: pack.version,
509
- manifestDigest,
510
- installationVersion: installation?.version ?? null,
511
- action,
512
- ready: blockers.length === 0,
513
- blockers,
514
- components,
515
- rig,
516
- variableSetId,
517
- legacyInlineSkillCount: pack.skills.length,
518
- legacySandboxImage: pack.sandboxImage ?? null,
519
- };
520
- }
521
-
522
- async function resolvePackRig(
523
- db: Database,
524
- workspaceId: string,
525
- pack: CapabilityPack,
526
- requestedRigId: string | undefined,
527
- storedRigId: string | null | undefined,
528
- ): Promise<PackRigResolution> {
529
- const required = pack.rig?.required === true || Boolean(pack.sandboxImage);
530
- const selectedRigId = pack.rig?.rigId ?? requestedRigId ?? storedRigId ?? null;
531
- if (!required && !selectedRigId) {
532
- return {
533
- required: false,
534
- status: "not_required",
535
- requestedRigId: requestedRigId ?? null,
536
- rigId: null,
537
- rigVersionId: null,
538
- name: null,
539
- image: null,
540
- };
541
- }
542
- if (pack.rig?.rigId && requestedRigId && pack.rig.rigId !== requestedRigId) {
543
- return {
544
- required,
545
- status: "mismatch",
546
- requestedRigId,
547
- rigId: pack.rig.rigId,
548
- rigVersionId: null,
549
- name: null,
550
- image: null,
551
- };
552
- }
553
- if (!selectedRigId) {
554
- return {
555
- required,
556
- status: "missing",
557
- requestedRigId: requestedRigId ?? null,
558
- rigId: null,
559
- rigVersionId: null,
560
- name: null,
561
- image: null,
562
- };
563
- }
564
- const rig = await getRig(db, workspaceId, selectedRigId);
565
- if (!rig?.activeVersion) {
566
- return {
567
- required,
568
- status: "missing",
569
- requestedRigId: requestedRigId ?? null,
570
- rigId: selectedRigId,
571
- rigVersionId: null,
572
- name: rig?.name ?? null,
573
- image: null,
574
- };
575
- }
576
- // Explicit Rig images are disabled: a selected Rig always composes on the
577
- // deployment platform base. Historical image values remain stored but are
578
- // neither effective runtime truth nor a valid v2 Pack compatibility target.
579
- const image = null;
580
- const status = pack.sandboxImage
581
- ? "mismatch"
582
- : pack.rig?.requireVerified && rig.activeVersionHealth?.checkHealth !== "passing"
583
- ? "unverified"
584
- : "ready";
585
- return {
586
- required,
587
- status,
588
- requestedRigId: requestedRigId ?? null,
589
- rigId: rig.id,
590
- rigVersionId: rig.activeVersion.id,
591
- name: rig.name,
592
- image,
593
- };
594
- }
595
-
596
- function packRigBlocker(rig: PackRigResolution, legacyImage: string | null): string {
597
- if (rig.status === "missing") {
598
- return "Choose an available compute environment before installing this Pack";
599
- }
600
- if (rig.status === "unverified") {
601
- return "Verify the selected compute environment before installing this Pack";
602
- }
603
- if (legacyImage) {
604
- return `This Pack requires the retired explicit sandbox image ${legacyImage}; Rig-bound Packs currently must use the deployment-managed platform sandbox`;
605
- }
606
- return "The selected compute environment does not satisfy this Pack's requirement";
607
- }
608
-
609
- function storedVariableSetId(metadata: Record<string, unknown> | undefined): string | null {
610
- const value = metadata?.variableSetId ?? metadata?.environmentId;
611
- return typeof value === "string" && value.length > 0 ? value : null;
612
- }
613
-
614
- /**
615
- * v1 pack-scoped runtime rule: at most one enabled pack per workspace may
616
- * declare a `sandboxImage` — there is deliberately no image composition or
617
- * layering. Enforced when a pack is enabled (both the packs endpoint and the
618
- * generic capability enable path) and re-checked at session start by the
619
- * worker, which also covers manifests re-registered after enablement.
620
- */
621
- export async function assertPackSandboxImageCompatible(
622
- db: Database,
623
- workspaceId: string,
624
- pack: CapabilityPack,
625
- ): Promise<void> {
626
- if (!pack.sandboxImage) {
627
- return;
628
- }
629
- const installations = await listPackInstallations(db, workspaceId);
630
- for (const installation of installations) {
631
- if (installation.status !== "active" || installation.packId === pack.id) {
632
- continue;
633
- }
634
- const other = await resolveCapabilityPack(db, workspaceId, installation.packId);
635
- if (other?.sandboxImage) {
636
- throw new HTTPException(409, {
637
- message: `pack ${pack.id} declares a sandbox image, but enabled pack ${other.id} already declares one; only one enabled pack per workspace may declare sandboxImage — disable ${other.id} first`,
638
- });
639
- }
640
- }
641
- }
642
-
643
- export function buildMarketingDailyAnalysisAgentConfig(input: {
644
- connections: SocialConnection[];
645
- documentBaseIds: string[];
646
- promptInstructions?: string;
647
- }): ScheduledTaskAgentConfig {
648
- const connectionIds = input.connections.map((connection) => connection.id);
649
- return {
650
- prompt: marketingDailyAnalysisPrompt({
651
- connections: input.connections,
652
- documentBaseIds: input.documentBaseIds,
653
- ...(input.promptInstructions ? { promptInstructions: input.promptInstructions } : {}),
654
- }),
655
- resources: [],
656
- tools: marketingSocialPack.tools,
657
- metadata: {
658
- packId: MARKETING_SOCIAL_PACK_ID,
659
- packTemplateId: "daily-social-analysis",
660
- socialConnectionIds: connectionIds,
661
- documentBaseIds: input.documentBaseIds,
662
- analysisWindowHours: 24,
663
- },
664
- };
665
- }
666
-
667
- function marketingDailyAnalysisPrompt(input: {
668
- connections: SocialConnection[];
669
- documentBaseIds: string[];
670
- promptInstructions?: string;
671
- }): string {
672
- const connectionLines = input.connections
673
- .map((connection) => {
674
- return `- ${connection.provider}: ${connection.accountHandle} (${connection.id})`;
675
- })
676
- .join("\n");
677
- const knowledgeLine =
678
- input.documentBaseIds.length > 0
679
- ? `Use these document base IDs for brand/campaign knowledge through the docs MCP: ${input.documentBaseIds.join(", ")}.`
680
- : "No document base IDs were selected; rely only on social context returned by tools.";
681
- const extra = input.promptInstructions
682
- ? `\nAdditional operator instructions:\n${input.promptInstructions.trim()}\n`
683
- : "";
684
-
685
- return [
686
- "Run the daily social media analysis for the selected accounts.",
687
- "",
688
- "First call the OpenGeni MCP tool social_daily_analysis_context with the selected connection IDs and a 24 hour analysis window. Use social_posts_recent only if you need a narrower follow-up query.",
689
- knowledgeLine,
690
- "",
691
- "Selected accounts:",
692
- connectionLines,
693
- extra,
694
- "Produce a concise report with these sections: executive summary, notable account changes, winning posts, underperforming posts, audience and content signals, recommended actions for the next 24 hours, and data gaps.",
695
- "Use only metrics and posts returned by tools or document search. Do not invent metrics, posts, or account capabilities.",
696
- ]
697
- .filter(Boolean)
698
- .join("\n");
699
- }