@opengeni/core 0.28.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/README.md +1 -1
  2. package/dist/access/external-actor-authority.d.ts +47 -0
  3. package/dist/access/index.d.ts +182 -3
  4. package/dist/access/service-initiator.d.ts +3 -0
  5. package/dist/application/api-integration-servers.d.ts +20 -0
  6. package/dist/application/archived-session-imports.d.ts +6 -0
  7. package/dist/application/composer-submit.d.ts +24 -0
  8. package/dist/application/connect-authority.d.ts +13 -0
  9. package/dist/application/connect-operation.d.ts +31 -0
  10. package/dist/application/external-continuation.d.ts +15 -0
  11. package/dist/application/external-identity-lifecycle.d.ts +20 -0
  12. package/dist/application/external-link-work-admission.d.ts +12 -0
  13. package/dist/application/external-workspace-members.d.ts +34 -0
  14. package/dist/application/modal-native-worker-host-transport.d.ts +297 -0
  15. package/dist/application/new-session-drafts.d.ts +39 -2
  16. package/dist/application/sandbox-recovery.d.ts +58 -0
  17. package/dist/application/session-commands.d.ts +26 -13
  18. package/dist/application/session-mcp-credential-rotation.d.ts +29 -0
  19. package/dist/application/session-tenancy.d.ts +19 -0
  20. package/dist/application/user-resource-grants.d.ts +20 -0
  21. package/dist/billing/limits.d.ts +11 -0
  22. package/dist/canonical-human-identities.d.ts +7 -2
  23. package/dist/canonical-human-identities.js +17 -4
  24. package/dist/canonical-human-identities.js.map +1 -1
  25. package/dist/{chunk-6WKPWE5S.js → chunk-2MKMRGSY.js} +108 -24
  26. package/dist/chunk-2MKMRGSY.js.map +1 -0
  27. package/dist/{chunk-NYPMQ7NO.js → chunk-GVO3N37G.js} +205 -37
  28. package/dist/chunk-GVO3N37G.js.map +1 -0
  29. package/dist/{chunk-JJU6I5XD.js → chunk-LCQXNR62.js} +36 -10
  30. package/dist/chunk-LCQXNR62.js.map +1 -0
  31. package/dist/chunk-MM6N7CTO.js +387 -0
  32. package/dist/chunk-MM6N7CTO.js.map +1 -0
  33. package/dist/chunk-QO5GVFFO.js +235 -0
  34. package/dist/chunk-QO5GVFFO.js.map +1 -0
  35. package/dist/codex-model-availability.d.ts +14 -0
  36. package/dist/default-session-model.d.ts +139 -0
  37. package/dist/dependencies.d.ts +87 -4
  38. package/dist/developer-setup-credential-ceiling.d.ts +10 -0
  39. package/dist/domain/agent-config-resolution.d.ts +49 -0
  40. package/dist/domain/automations.d.ts +58 -0
  41. package/dist/domain/capabilities.d.ts +22 -4
  42. package/dist/domain/company-profile-agent-admin.d.ts +25 -0
  43. package/dist/domain/connection-account-selection-error.d.ts +8 -0
  44. package/dist/domain/connector-tool-permissions.d.ts +36 -0
  45. package/dist/domain/direct-model-provider.d.ts +3 -0
  46. package/dist/domain/editable-artifacts/agent-application.d.ts +10 -1
  47. package/dist/domain/editable-artifacts/durable-export.d.ts +22 -1
  48. package/dist/domain/editable-artifacts/ports.d.ts +10 -0
  49. package/dist/domain/editable-artifacts/service.d.ts +4 -3
  50. package/dist/domain/environments.d.ts +5 -9
  51. package/dist/domain/external-creation-attribution.d.ts +6 -0
  52. package/dist/domain/file-owner.d.ts +8 -0
  53. package/dist/domain/github-action-policies.d.ts +36 -0
  54. package/dist/domain/github-repository-bindings.d.ts +117 -0
  55. package/dist/domain/github-skill-source.d.ts +5 -0
  56. package/dist/domain/governed-learning-slack-publication.d.ts +45 -0
  57. package/dist/domain/insights-timing.d.ts +16 -0
  58. package/dist/domain/insights-usage.d.ts +27 -0
  59. package/dist/domain/insights.d.ts +28 -1
  60. package/dist/domain/knowledge-files.d.ts +20 -0
  61. package/dist/domain/knowledge-messages.d.ts +39 -0
  62. package/dist/domain/knowledge-messages.test.d.ts +1 -0
  63. package/dist/domain/knowledge-preparation.d.ts +10 -0
  64. package/dist/domain/knowledge-preparation.test.d.ts +1 -0
  65. package/dist/domain/knowledge-search.d.ts +15 -0
  66. package/dist/domain/knowledge-search.test.d.ts +1 -0
  67. package/dist/domain/knowledge.d.ts +9 -0
  68. package/dist/domain/mcp-account-bindings.d.ts +19 -0
  69. package/dist/domain/mcp-account-routes.d.ts +21 -0
  70. package/dist/domain/native-mcp-connection-admission.d.ts +3 -0
  71. package/dist/domain/organization-integration-catalog.d.ts +15 -0
  72. package/dist/domain/organization-membership-lifecycle.d.ts +1 -0
  73. package/dist/domain/personal-connection-delegations.d.ts +87 -4
  74. package/dist/domain/pr-review.d.ts +249 -0
  75. package/dist/domain/resources.d.ts +24 -3
  76. package/dist/domain/scheduled-task-access.d.ts +247 -0
  77. package/dist/domain/scheduled-tasks.d.ts +103 -6
  78. package/dist/domain/session-connection-accounts.d.ts +16 -0
  79. package/dist/domain/session-file-access.d.ts +4 -0
  80. package/dist/domain/session-native-connection-replacement.d.ts +14 -0
  81. package/dist/domain/session-start-timing.d.ts +7 -0
  82. package/dist/domain/session-tool-policy.d.ts +93 -4
  83. package/dist/domain/sessions.d.ts +275 -28
  84. package/dist/domain/skill-imports.d.ts +1 -0
  85. package/dist/domain/skill-search.d.ts +30 -0
  86. package/dist/domain/skills.d.ts +117 -0
  87. package/dist/domain/slack-bot.d.ts +46 -1
  88. package/dist/domain/workspace-members.d.ts +8 -1
  89. package/dist/editable-artifact-live/application.d.ts +12 -3
  90. package/dist/editable-artifact-live/ports.d.ts +0 -1
  91. package/dist/editable-artifact-live/server.d.ts +5 -2
  92. package/dist/editable-artifact-live/ticket.d.ts +2 -2
  93. package/dist/editable-artifact-live/types.d.ts +14 -2
  94. package/dist/editable-artifact-live.js +2 -2
  95. package/dist/editable-artifacts.js +10 -4
  96. package/dist/index.d.ts +49 -3
  97. package/dist/index.js +18826 -6847
  98. package/dist/index.js.map +1 -1
  99. package/dist/managed-auth-session-sets.d.ts +131 -0
  100. package/dist/managed-auth-session-sets.js +51 -0
  101. package/dist/managed-auth-session-sets.js.map +1 -0
  102. package/dist/managed-session.d.ts +98 -11
  103. package/dist/model-catalog.d.ts +117 -0
  104. package/dist/product-usage-metrics.d.ts +30 -0
  105. package/dist/rigs/index.d.ts +22 -5
  106. package/dist/rigs/provider-images.d.ts +1 -1
  107. package/dist/sandbox/fleet.d.ts +59 -10
  108. package/dist/sandbox/routing.d.ts +22 -2
  109. package/dist/sandbox/runtime-settings.d.ts +56 -0
  110. package/dist/session-authorization.d.ts +38 -1
  111. package/dist/site-session-origin.d.ts +9 -0
  112. package/dist/transcription.d.ts +12 -1
  113. package/dist/turn-surface.d.ts +18 -0
  114. package/dist/user-presence.d.ts +32 -0
  115. package/package.json +18 -11
  116. package/src/access/external-actor-authority.ts +94 -0
  117. package/src/access/index.ts +1386 -44
  118. package/src/access/service-initiator.ts +50 -0
  119. package/src/application/api-integration-servers.ts +215 -0
  120. package/src/application/archived-session-imports.ts +161 -0
  121. package/src/application/composer-submit.ts +77 -0
  122. package/src/application/connect-authority.ts +77 -0
  123. package/src/application/connect-operation.ts +80 -0
  124. package/src/application/external-continuation.ts +129 -0
  125. package/src/application/external-identity-lifecycle.ts +48 -0
  126. package/src/application/external-link-work-admission.ts +90 -0
  127. package/src/application/external-workspace-members.ts +232 -0
  128. package/src/application/modal-native-worker-host-transport.ts +263 -0
  129. package/src/application/new-session-drafts.ts +222 -29
  130. package/src/application/sandbox-recovery.ts +78 -0
  131. package/src/application/session-commands.ts +430 -73
  132. package/src/application/session-mcp-credential-rotation.ts +217 -0
  133. package/src/application/session-tenancy.ts +445 -0
  134. package/src/application/user-resource-grants.ts +154 -0
  135. package/src/billing/limits.ts +103 -24
  136. package/src/canonical-human-identities.ts +22 -3
  137. package/src/codex-model-availability.ts +136 -0
  138. package/src/default-session-model.ts +656 -0
  139. package/src/dependencies.ts +97 -5
  140. package/src/developer-setup-credential-ceiling.ts +60 -0
  141. package/src/domain/agent-config-resolution.ts +148 -0
  142. package/src/domain/automations.ts +270 -0
  143. package/src/domain/capabilities.ts +244 -151
  144. package/src/domain/company-profile-agent-admin.ts +56 -0
  145. package/src/domain/connection-account-selection-error.ts +19 -0
  146. package/src/domain/connector-tool-permissions.ts +371 -0
  147. package/src/domain/direct-model-provider.ts +62 -0
  148. package/src/domain/editable-artifacts/agent-application.ts +61 -15
  149. package/src/domain/editable-artifacts/durable-export.ts +100 -5
  150. package/src/domain/editable-artifacts/in-memory.ts +6 -0
  151. package/src/domain/editable-artifacts/ports.ts +11 -0
  152. package/src/domain/editable-artifacts/service.ts +32 -1
  153. package/src/domain/editable-artifacts/snapshot-compaction.ts +9 -5
  154. package/src/domain/editable-artifacts/snapshot-verifier-genesis.ts +10 -8
  155. package/src/domain/editable-artifacts/snapshot-verifier.ts +10 -3
  156. package/src/domain/environments.ts +25 -45
  157. package/src/domain/external-creation-attribution.ts +22 -0
  158. package/src/domain/file-owner.ts +67 -0
  159. package/src/domain/github-action-policies.ts +169 -0
  160. package/src/domain/github-repository-bindings.ts +295 -0
  161. package/src/domain/github-skill-source.ts +233 -0
  162. package/src/domain/governed-learning-slack-publication.ts +157 -0
  163. package/src/domain/insights-timing.ts +95 -0
  164. package/src/domain/insights-usage.ts +67 -0
  165. package/src/domain/insights.ts +270 -169
  166. package/src/domain/knowledge-files.ts +46 -0
  167. package/src/domain/knowledge-messages.test.ts +91 -0
  168. package/src/domain/knowledge-messages.ts +106 -0
  169. package/src/domain/knowledge-preparation.test.ts +276 -0
  170. package/src/domain/knowledge-preparation.ts +147 -0
  171. package/src/domain/knowledge-search.test.ts +561 -0
  172. package/src/domain/knowledge-search.ts +256 -0
  173. package/src/domain/knowledge.ts +133 -0
  174. package/src/domain/mcp-account-bindings.ts +171 -0
  175. package/src/domain/mcp-account-routes.ts +121 -0
  176. package/src/domain/native-mcp-connection-admission.ts +14 -0
  177. package/src/domain/organization-integration-catalog.ts +88 -0
  178. package/src/domain/organization-membership-lifecycle.ts +10 -0
  179. package/src/domain/personal-connection-delegations.ts +758 -115
  180. package/src/domain/pr-review.ts +687 -0
  181. package/src/domain/resources.ts +182 -25
  182. package/src/domain/scheduled-task-access.ts +1052 -0
  183. package/src/domain/scheduled-tasks.ts +1952 -215
  184. package/src/domain/session-connection-accounts.ts +67 -0
  185. package/src/domain/session-file-access.ts +47 -0
  186. package/src/domain/session-native-connection-replacement.ts +64 -0
  187. package/src/domain/session-start-timing.ts +55 -0
  188. package/src/domain/session-tool-policy.ts +443 -19
  189. package/src/domain/sessions.ts +3417 -619
  190. package/src/domain/skill-imports.ts +137 -17
  191. package/src/domain/skill-search.ts +221 -0
  192. package/src/domain/skills.ts +104 -0
  193. package/src/domain/slack-bot.ts +128 -3
  194. package/src/domain/workspace-members.ts +34 -2
  195. package/src/editable-artifact-live/application.ts +29 -4
  196. package/src/editable-artifact-live/ports.ts +0 -1
  197. package/src/editable-artifact-live/server.ts +167 -13
  198. package/src/editable-artifact-live/ticket.ts +87 -6
  199. package/src/editable-artifact-live/types.ts +16 -2
  200. package/src/editable-artifact-live/wire.ts +0 -10
  201. package/src/index.ts +69 -4
  202. package/src/managed-auth-session-sets.ts +371 -0
  203. package/src/managed-session.ts +520 -2
  204. package/src/model-catalog.ts +873 -0
  205. package/src/product-usage-metrics.ts +101 -0
  206. package/src/rigs/index.ts +179 -63
  207. package/src/rigs/provider-images.ts +2 -3
  208. package/src/sandbox/fleet.ts +471 -59
  209. package/src/sandbox/routing.ts +160 -33
  210. package/src/sandbox/runtime-settings.ts +281 -0
  211. package/src/session-authorization.ts +262 -78
  212. package/src/site-session-origin.ts +22 -0
  213. package/src/transcription.ts +13 -1
  214. package/src/turn-surface.ts +45 -0
  215. package/src/user-presence.ts +134 -0
  216. package/dist/chunk-6WKPWE5S.js.map +0 -1
  217. package/dist/chunk-IBOEYG6N.js +0 -34
  218. package/dist/chunk-IBOEYG6N.js.map +0 -1
  219. package/dist/chunk-JJU6I5XD.js.map +0 -1
  220. package/dist/chunk-NYPMQ7NO.js.map +0 -1
  221. package/dist/domain/durable-learning-slack-publication.d.ts +0 -72
  222. package/dist/domain/packs.d.ts +0 -55
  223. package/src/domain/durable-learning-slack-publication.ts +0 -202
  224. package/src/domain/packs.ts +0 -556
@@ -0,0 +1,49 @@
1
+ import { type Settings } from "@opengeni/config";
2
+ import { type AgentConfigCreator, type AgentConfigParent, type AgentConfigRequest, type FirstPartyMcpToolName, type ResolvedAgentCapabilities, type ResolvedAgentConfig, type Session, type SessionToolPolicy, type ToolRef } from "@opengeni/contracts";
3
+ /**
4
+ * Run an agent-config resolution step and surface its typed failure as a 422
5
+ * whose `cause` keeps the `AgentConfigError` (the API renders its code as
6
+ * `details.code`; MCP and Slack keep the plain message).
7
+ */
8
+ export declare function withAgentConfigHttpErrors<T>(fn: () => T): T;
9
+ /** The current effective capabilities of a null-config session (the conversion/child ceiling). */
10
+ export declare function legacySessionAgentCapabilities(settings: Settings, session: Pick<Session, "firstPartyMcpTools" | "tools" | "toolPolicy">, workspaceSettings: unknown,
11
+ /** The workspace's current omitted-tools default server ids, when known. */
12
+ defaultServerIds?: Iterable<string>): ResolvedAgentCapabilities;
13
+ /** A parent session as a resolution input: its frozen config, or its legacy ceiling. */
14
+ export declare function agentConfigParentFor(settings: Settings, parent: Session, workspaceSettings: unknown): AgentConfigParent;
15
+ /**
16
+ * Resolve the frozen agent configuration for a new session. Every creator
17
+ * calls this: `createSessionForRequest` (public API, MCP `session_create`,
18
+ * Slack, drafts), automations, and the scheduled worker. Returns `config:
19
+ * null` for exact legacy behavior.
20
+ */
21
+ export declare function resolveSessionAgentConfigForCreate(input: {
22
+ settings: Settings;
23
+ creator: AgentConfigCreator;
24
+ request: AgentConfigRequest | undefined;
25
+ instructions: string | undefined;
26
+ workspaceSettings: unknown;
27
+ parent: Session | null;
28
+ goal: boolean;
29
+ }): {
30
+ config: ResolvedAgentConfig | null;
31
+ instructions: string | undefined;
32
+ };
33
+ /**
34
+ * Write a resolved configuration through to the legacy columns the runtime
35
+ * reads today. `null` returns the inputs unchanged; `"all"` also does.
36
+ */
37
+ export declare function applySessionAgentConfigWriteThrough(input: {
38
+ config: ResolvedAgentConfig | null;
39
+ firstPartyMcpTools: FirstPartyMcpToolName[];
40
+ explicitFirstPartyMcpTools?: readonly FirstPartyMcpToolName[] | undefined;
41
+ tools: ToolRef[];
42
+ toolPolicy: SessionToolPolicy;
43
+ productServerIds: Iterable<string>;
44
+ explicitServerIds?: Iterable<string> | undefined;
45
+ }): {
46
+ firstPartyMcpTools: FirstPartyMcpToolName[];
47
+ tools: ToolRef[];
48
+ toolPolicy: SessionToolPolicy;
49
+ };
@@ -0,0 +1,58 @@
1
+ import { AutomationAcceptedExecution, AutomationNormalizedEvent, AutomationSessionTemplate, type AccessGrant, type Permission, type AutomationAdapterId, type AutomationSource, type AutomationTrigger } from "@opengeni/contracts";
2
+ import { type Database } from "@opengeni/db";
3
+ /** Canonical authenticated grant or exact server-owned originating policy only. */
4
+ export declare function automationCredentialRestrictionForGrant(db: Database, grant: AccessGrant): Promise<AutomationSessionTemplate["credentialRestriction"]>;
5
+ /** Explicit delegated scopes must stay within the frozen setup ceiling. */
6
+ export declare function requireAutomationCredentialRestrictionPermissions(restriction: AutomationSessionTemplate["credentialRestriction"], permissions: readonly Permission[]): void;
7
+ export type AutomationAdapterRenderResult = {
8
+ initialMessage: string;
9
+ sessionTemplate: AutomationSessionTemplate;
10
+ provenance: Record<string, unknown>;
11
+ };
12
+ export type AutomationAdapter = {
13
+ id: AutomationAdapterId;
14
+ verify(input: {
15
+ rawBody: Uint8Array;
16
+ headers: Headers;
17
+ secret: string;
18
+ sourceConfiguration: Record<string, unknown>;
19
+ }): boolean;
20
+ deliveryKey(input: {
21
+ headers: Headers;
22
+ requestDigest: string;
23
+ }): string;
24
+ normalize(input: {
25
+ rawBody: Uint8Array;
26
+ headers: Headers;
27
+ sourceConfiguration: Record<string, unknown>;
28
+ }): AutomationNormalizedEvent;
29
+ validateSourceConfiguration(configuration: Record<string, unknown>): void;
30
+ validateTriggerConfiguration(configuration: Record<string, unknown>): void;
31
+ validateTriggerParameters(parameters: Record<string, unknown>): void;
32
+ matches(input: {
33
+ event: AutomationNormalizedEvent;
34
+ trigger: AutomationTrigger;
35
+ }): boolean;
36
+ render(input: {
37
+ event: AutomationNormalizedEvent;
38
+ trigger: AutomationTrigger;
39
+ source: Pick<AutomationSource, "id" | "adapterId" | "version" | "configuration">;
40
+ }): AutomationAdapterRenderResult;
41
+ };
42
+ export declare const SIGNED_JSON_AUTOMATION_ADAPTER_ID: "signed-json.v1";
43
+ export declare const signedJsonAutomationAdapter: AutomationAdapter;
44
+ export declare function registerAutomationAdapter(adapter: AutomationAdapter): void;
45
+ export declare function getAutomationAdapter(adapterId: string): AutomationAdapter | null;
46
+ export declare function requireAutomationAdapter(adapterId: string): AutomationAdapter;
47
+ export declare function automationRequestDigest(adapterId: string, rawBody: Uint8Array): string;
48
+ export declare function buildAutomationAcceptedExecution(input: {
49
+ accountId: string;
50
+ workspaceId: string;
51
+ source: AutomationSource;
52
+ trigger: AutomationTrigger;
53
+ eventId: string;
54
+ event: AutomationNormalizedEvent;
55
+ render: AutomationAdapterRenderResult;
56
+ /** Trusted caller restriction from the immutable stored event, not adapter JSON. */
57
+ credentialRestriction?: "developer_setup";
58
+ }): AutomationAcceptedExecution;
@@ -14,7 +14,7 @@ export declare function createCatalogItem(input: {
14
14
  workspaceId: string;
15
15
  payload: CreateCapabilityCatalogItemRequest;
16
16
  }): Promise<CapabilityCatalogItem>;
17
- export declare function enableCapability(input: {
17
+ type EnableCapabilityInput = {
18
18
  db: Database;
19
19
  grant: AccessGrant;
20
20
  accountId: string;
@@ -23,19 +23,37 @@ export declare function enableCapability(input: {
23
23
  capabilityId: string;
24
24
  payload: EnableCapabilityRequest;
25
25
  probeMcpServer?: McpCapabilityProbe;
26
- }): Promise<CapabilityInstallation>;
26
+ };
27
+ export declare function enableCapability(input: EnableCapabilityInput): Promise<CapabilityInstallation>;
28
+ /** Probe outside a durable Connect commit; persist the exact prepared settings
29
+ * inside the caller's authorized receipt transaction. Native enable uses this too. */
30
+ export declare function prepareCapabilityEnable(input: EnableCapabilityInput): Promise<{
31
+ commit: (db: Database) => Promise<{
32
+ id: string;
33
+ accountId: string;
34
+ workspaceId: string;
35
+ capabilityId: string;
36
+ kind: "api" | "mcp" | "plugin" | "skill";
37
+ status: "active" | "disabled";
38
+ config: Record<string, unknown>;
39
+ metadata: Record<string, unknown>;
40
+ enabledAt: string;
41
+ updatedAt: string;
42
+ }>;
43
+ }>;
27
44
  export type McpCapabilityProbeInput = {
28
45
  id: string;
29
46
  name: string;
30
47
  url: string;
31
48
  timeoutMs: number;
32
49
  headers?: Record<string, string>;
50
+ settings?: Settings;
33
51
  };
34
52
  export type McpCapabilityProbeResult = {
35
53
  toolCount: number;
36
54
  };
37
55
  export type McpCapabilityProbe = (input: McpCapabilityProbeInput) => Promise<McpCapabilityProbeResult>;
38
- export declare function validateMcpCapabilityConnection(item: CapabilityCatalogItem, probe?: McpCapabilityProbe, headers?: Record<string, string>): Promise<Record<string, unknown>>;
56
+ export declare function validateMcpCapabilityConnection(item: CapabilityCatalogItem, probe?: McpCapabilityProbe, headers?: Record<string, string>, settings?: Settings): Promise<Record<string, unknown>>;
39
57
  export declare function disableCapability(input: {
40
58
  db: Database;
41
59
  accountId: string;
@@ -85,7 +103,7 @@ export declare function codexAppsCatalogItem(available: boolean): CapabilityCata
85
103
  * row for GitHub resources, Documents, schedules, or other platform features.
86
104
  */
87
105
  export declare function nativeConnectionCapabilityRecommendations(): CapabilityCatalogItem[];
88
- export declare function applyCapabilityEnablement(item: CapabilityCatalogItem, installation: CapabilityInstallation | undefined, activePackIds: Set<string>): CapabilityCatalogItem;
106
+ export declare function applyCapabilityEnablement(item: CapabilityCatalogItem, installation: CapabilityInstallation | undefined): CapabilityCatalogItem;
89
107
  export type CapabilityCatalogSearchMatch = {
90
108
  item: CapabilityCatalogItem;
91
109
  score: number;
@@ -0,0 +1,25 @@
1
+ import { type CompanyProfileAgentConfirmationReceipt, type CompanyProfileAgentProposalReceipt } from "@opengeni/contracts";
2
+ import { confirmCompanyProfileForAgent, proposeCompanyProfileForAgent, type Database } from "@opengeni/db";
3
+ export { CompanyProfileAgentAdminError } from "@opengeni/db";
4
+ export type CompanyProfileAgentAdminRouterOptions = {
5
+ db: Database;
6
+ propose?: typeof proposeCompanyProfileForAgent;
7
+ confirm?: typeof confirmCompanyProfileForAgent;
8
+ };
9
+ /**
10
+ * Explicit organization administration is intentionally separate from derived
11
+ * workspace learning. The database capabilities own exact-attempt admission,
12
+ * current organization-owner authority, the separate organization policy,
13
+ * canonical review when required, tenant isolation, CAS, and immutable
14
+ * receipts.
15
+ */
16
+ export declare function createCompanyProfileAgentAdminRouter(options: CompanyProfileAgentAdminRouterOptions): {
17
+ propose: (input: {
18
+ attempt: unknown;
19
+ request: unknown;
20
+ }) => Promise<CompanyProfileAgentProposalReceipt>;
21
+ confirm: (input: {
22
+ attempt: unknown;
23
+ request: unknown;
24
+ }) => Promise<CompanyProfileAgentConfirmationReceipt>;
25
+ };
@@ -0,0 +1,8 @@
1
+ import { HTTPException } from "hono/http-exception";
2
+ import { ConnectionAccountSelectionDiagnostic } from "@opengeni/contracts";
3
+ /** An account choice needs attention; retrying the same work cannot fix it. */
4
+ export declare class ConnectionAccountSelectionError extends HTTPException {
5
+ name: string;
6
+ readonly diagnostic: ConnectionAccountSelectionDiagnostic;
7
+ constructor(message: string, diagnostic?: ConnectionAccountSelectionDiagnostic);
8
+ }
@@ -0,0 +1,36 @@
1
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2
+ import type { Settings } from "@opengeni/config";
3
+ import type { AccessGrant, ConnectorToolPermissionsResponse, UpdateConnectorToolPermissionsRequest, ConnectionMetadata, McpServerConnectionRef } from "@opengeni/contracts";
4
+ import { type Database } from "@opengeni/db";
5
+ type Input = {
6
+ db: Database;
7
+ settings: Settings;
8
+ workspaceId: string;
9
+ grant: AccessGrant;
10
+ capabilityId: string;
11
+ personalOwnerVerified: boolean;
12
+ };
13
+ type ListedTool = {
14
+ name: string;
15
+ title?: string | undefined;
16
+ description?: string | undefined;
17
+ annotations?: {
18
+ readOnlyHint?: boolean | undefined;
19
+ destructiveHint?: boolean | undefined;
20
+ title?: string | undefined;
21
+ } | undefined;
22
+ };
23
+ export declare function connectorToolGroup(tool: ListedTool): "read" | "write" | "other";
24
+ /** A selector can supply discovery credentials only when one visible account
25
+ * matches. Never apply one account's approval choices to an arbitrary sibling. */
26
+ export declare function unpinnedConnectorToolPermissionAccount<T extends ConnectionMetadata>(ref: McpServerConnectionRef, visible: T[], subjectId: string): T | null;
27
+ export declare function connectorToolPermissionReference(ref: McpServerConnectionRef, connectionId: string): McpServerConnectionRef;
28
+ /** Use the same adapter-owned identities as execution for reviewed local catalogs. */
29
+ export declare function reviewedConnectorToolCatalog(server: Pick<Settings["mcpServers"][number], "url" | "connectionRef" | "allowedTools">, grantedScopes: readonly string[]): ListedTool[] | null;
30
+ /** Collect discovery pages without changing the caller's connection or authority. */
31
+ export declare function collectConnectorToolPages(client: Pick<Client, "listTools">, deadline: AbortSignal): Promise<ListedTool[]>;
32
+ export declare function getConnectorToolPermissions(input: Input): Promise<ConnectorToolPermissionsResponse>;
33
+ export declare function updateConnectorToolPermissions(input: Input & {
34
+ payload: UpdateConnectorToolPermissionsRequest;
35
+ }): Promise<void>;
36
+ export {};
@@ -0,0 +1,3 @@
1
+ import { DirectModelProviderMetadata } from "@opengeni/contracts";
2
+ /** Verify the customer's exact route without persisting their key or test response. */
3
+ export declare function verifyDirectModelAccess(input: DirectModelProviderMetadata, apiKey: string, fetchImpl?: typeof fetch): Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import { type DocumentArtifactCommand, type DocumentArtifactQuery, type PresentationArtifactCommand, type PresentationArtifactQuery, type SpreadsheetArtifactCommand, type SpreadsheetArtifactKernelQuery } from "@opengeni/contracts/editable-artifacts";
2
- import type { EditableArtifactDurableExportService, EditableArtifactMaterializationFormat, EditableArtifactMaterializationJob } from "./durable-export.js";
2
+ import { type EditableArtifactDurableExportService, type EditableArtifactMaterializationFormat, type EditableArtifactMaterializationJob } from "./durable-export.js";
3
3
  import type { EditableArtifactService } from "./service.js";
4
4
  import { type EditableArtifact, type EditableArtifactActor, type EditableArtifactClientTransactionId, type EditableArtifactId, type EditableArtifactModality, type EditableArtifactOriginalImport, type EditableArtifactScope, type ImportEditableArtifactRequest } from "./types.js";
5
5
  import type { EditableArtifactKernelState } from "./ports.js";
@@ -30,6 +30,7 @@ export type EditableArtifactAgentContext = Readonly<{
30
30
  }>;
31
31
  export type EditableArtifactAgentMetadata = Readonly<{
32
32
  id: string;
33
+ artifactReference: string;
33
34
  modality: EditableArtifactModality;
34
35
  title: string;
35
36
  lifecycle: EditableArtifact["lifecycle"];
@@ -116,6 +117,12 @@ export type EditableArtifactAgentApplicationDependencies = Readonly<{
116
117
  exports: EditableArtifactDurableExportService;
117
118
  associations: EditableArtifactAgentAssociationPort;
118
119
  inspector: EditableArtifactAgentInspectionKernelPort;
120
+ /** Production persists proof only after a successful native query. */
121
+ recordInspection?: (input: EditableArtifactAgentContext & {
122
+ artifact: EditableArtifactAgentMetadata;
123
+ queryHash: string;
124
+ queryKind: string;
125
+ }) => Promise<string>;
119
126
  officeImports: EditableArtifactOfficeImportPort;
120
127
  workspaceFiles: EditableArtifactAgentWorkspaceFilePort;
121
128
  }>;
@@ -125,6 +132,7 @@ export type EditableArtifactAgentApplicationDependencies = Readonly<{
125
132
  */
126
133
  export declare class EditableArtifactAgentApplication {
127
134
  private readonly dependencies;
135
+ describeExportFormats(): string;
128
136
  constructor(dependencies: EditableArtifactAgentApplicationDependencies);
129
137
  list(input: EditableArtifactAgentContext & Readonly<{
130
138
  limit?: number;
@@ -151,6 +159,7 @@ export declare class EditableArtifactAgentApplication {
151
159
  }>): Promise<Readonly<{
152
160
  artifact: EditableArtifactAgentMetadata;
153
161
  projection: unknown;
162
+ inspectionReceiptId?: string;
154
163
  }>>;
155
164
  apply(input: EditableArtifactAgentContext & Readonly<{
156
165
  artifactId: EditableArtifactId;
@@ -4,6 +4,17 @@ import { type EditableArtifactActor, type EditableArtifactCausalFrontier, type E
4
4
  export declare const EDITABLE_ARTIFACT_EXPORT_MAX_DOWNLOAD_BYTES: number;
5
5
  export declare const EDITABLE_ARTIFACT_EXPORT_MAX_OPTIONS_BYTES: number;
6
6
  export type EditableArtifactMaterializationFormat = "xlsx" | "pptx" | "docx" | "pdf" | "png" | "webp";
7
+ /**
8
+ * Stock production export formats. Custom deployments advertise their own
9
+ * capabilities on the profile port; this list never overrides their resolver.
10
+ * Extend the stock list only together with a real deployed codec.
11
+ */
12
+ export declare const EDITABLE_ARTIFACT_EXPORT_FORMATS: Readonly<Record<EditableArtifactModality, readonly EditableArtifactMaterializationFormat[]>>;
13
+ /** Human/agent-readable summary of {@link EDITABLE_ARTIFACT_EXPORT_FORMATS}. */
14
+ export declare function describeEditableArtifactExportFormats(): string;
15
+ export declare function describeConfiguredExportFormats(configuredFormats: Readonly<Record<EditableArtifactModality, readonly EditableArtifactMaterializationFormat[]>>): string;
16
+ /** Typed refusal that tells the caller which formats do exist. */
17
+ export declare function unsupportedEditableArtifactExport(modality: EditableArtifactModality, format: string, formats?: Readonly<Record<EditableArtifactModality, readonly EditableArtifactMaterializationFormat[]>>): EditableArtifactDurableExportError;
7
18
  export type EditableArtifactMaterializationMimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/pdf" | "image/png" | "image/webp";
8
19
  export type EditableArtifactPinnedVersion = Readonly<{
9
20
  scope: EditableArtifactScope;
@@ -58,6 +69,9 @@ export type EditableArtifactMaterializationProfile = Readonly<{
58
69
  }>;
59
70
  /** Server-owned profile lookup. Clients never supply executable identity facts. */
60
71
  export interface EditableArtifactMaterializationProfilePort {
72
+ /** Deployment-owned discovery; resolve remains the authority for exact options.
73
+ * Optional for existing custom adapters, whose support is resolved dynamically. */
74
+ supportedFormats?: Readonly<Record<EditableArtifactModality, readonly EditableArtifactMaterializationFormat[]>>;
61
75
  resolve(input: Readonly<{
62
76
  modality: EditableArtifactModality;
63
77
  format: EditableArtifactMaterializationFormat;
@@ -165,7 +179,7 @@ export type EditableArtifactMaterializationDownload = Readonly<{
165
179
  export type EditableArtifactDurableExportErrorCode = "invalid_request" | "not_found" | "forbidden" | "conflict" | "unsupported_format" | "not_ready" | "unavailable";
166
180
  export declare class EditableArtifactDurableExportError extends Error {
167
181
  readonly code: EditableArtifactDurableExportErrorCode;
168
- constructor(code: EditableArtifactDurableExportErrorCode);
182
+ constructor(code: EditableArtifactDurableExportErrorCode, message?: string);
169
183
  }
170
184
  export type EditableArtifactDurableExportServiceDependencies = Readonly<{
171
185
  authorization: EditableArtifactAuthorizationPort;
@@ -178,6 +192,13 @@ export type EditableArtifactDurableExportServiceDependencies = Readonly<{
178
192
  export declare class EditableArtifactDurableExportService {
179
193
  private readonly dependencies;
180
194
  constructor(dependencies: EditableArtifactDurableExportServiceDependencies);
195
+ describeFormats(): string;
196
+ /** Read-only exact preflight: no snapshot, ID allocation, or store write. */
197
+ preflight(input: {
198
+ modality: EditableArtifactModality;
199
+ format: EditableArtifactMaterializationFormat;
200
+ options?: Readonly<Record<string, unknown>>;
201
+ }): Promise<EditableArtifactMaterializationProfile>;
181
202
  pinVersion(input: DurableExportContext & {
182
203
  idempotencyKey: string;
183
204
  name: string;
@@ -1,3 +1,4 @@
1
+ import type { Database } from "@opengeni/db";
1
2
  import type { EditableArtifact, EditableArtifactActor, EditableArtifactCausalFrontier, EditableArtifactId, EditableArtifactLiveOutboxRecord, EditableArtifactMutationIntent, EditableArtifactOperationId, EditableArtifactOperationRecord, EditableArtifactOriginOperation, EditableArtifactOriginalImport, EditableArtifactOutboxId, EditableArtifactOutboxRetryFailureCode, EditableArtifactOutboxDeadLetterFailureCode, EditableArtifactPermission, EditableArtifactReceipt, EditableArtifactScope, EditableArtifactSequenceCheckpoint, EditableArtifactSnapshotId, EditableArtifactSnapshotMetadata, EditableArtifactStableId, EditableArtifactStateHash, EditableArtifactTransactionId, EditableArtifactClientTransactionId, EditableArtifactCommittedTransactionRecord, EditableArtifactModality, EditableArtifactRequestHash, EditableArtifactSerialized, EditableArtifactSerializedCommittedTransactionRecord, EditableArtifactSerializedSnapshotMetadata, EditableArtifactSpreadsheet, EditableArtifactSpreadsheetCommittedTransactionRecord, EditableArtifactSpreadsheetSnapshotMetadata, CreateEditableArtifactResult, PublishEditableArtifactSnapshotRequest, ValidatedEditableArtifactMutationIntent } from "./types.js";
2
3
  export type EditableArtifactAuthorizationRequest = Readonly<{
3
4
  scope: EditableArtifactScope;
@@ -202,6 +203,8 @@ export type ReadEditableArtifactTransactionBasisRequest = Readonly<{
202
203
  clientTransactionId: EditableArtifactReceipt["clientTransactionId"];
203
204
  previousLocalTransactionId: EditableArtifactReceipt["previousLocalTransactionId"];
204
205
  selectiveUndoOperationIds: readonly EditableArtifactOperationId[];
206
+ /** Backend-only live authority; checked transactionally even on receipt replay. */
207
+ authorizeCommit?: EditableArtifactCommitAuthorizer;
205
208
  }>;
206
209
  export type EditableArtifactTransactionUndoBasis = Readonly<{
207
210
  operationId: EditableArtifactOperationId;
@@ -232,6 +235,12 @@ export type ExpectedEditableArtifactPredecessor = Readonly<{
232
235
  replicaId: EditableArtifactReceipt["replicaId"];
233
236
  replicaCounter: number;
234
237
  }>;
238
+ /**
239
+ * Receives the actual persistence transaction, never a separate pool handle.
240
+ * May run repeatedly for replay, lock admission and final persistence; must not
241
+ * perform external mutations. Stores without this transaction capability deny.
242
+ */
243
+ export type EditableArtifactCommitAuthorizer = (tx: Database) => Promise<void>;
235
244
  export type TryCommitAppliedEditableArtifactTransactionRequest = CommitAppliedEditableArtifactTransaction & Readonly<{
236
245
  scope: EditableArtifactScope;
237
246
  artifactId: EditableArtifactId;
@@ -239,6 +248,7 @@ export type TryCommitAppliedEditableArtifactTransactionRequest = CommitAppliedEd
239
248
  expectedAuthorizationRevision: number;
240
249
  /** Rechecked by durable production stores in the commit transaction. */
241
250
  authorizationActor: EditableArtifactActor;
251
+ authorizeCommit?: EditableArtifactCommitAuthorizer;
242
252
  actorKey: string;
243
253
  clientTransactionId: EditableArtifactReceipt["clientTransactionId"];
244
254
  requestHash: EditableArtifactReceipt["requestHash"];
@@ -1,14 +1,13 @@
1
- import type { AuthoritativeEditableArtifactKernelPort, EditableArtifactAuthorizationPort, EditableArtifactClockPort, EditableArtifactCompactionPort, EditableArtifactGenesisPort, EditableArtifactKernelState, EditableArtifactMutationIntentCodecPort, EditableArtifactSnapshotVerifierPort, EditableArtifactStableIdFactoryPort, EditableArtifactStorePort } from "./ports.js";
1
+ import type { EditableArtifactCommitAuthorizer, AuthoritativeEditableArtifactKernelPort, EditableArtifactAuthorizationPort, EditableArtifactClockPort, EditableArtifactCompactionPort, EditableArtifactGenesisPort, EditableArtifactKernelState, EditableArtifactMutationIntentCodecPort, EditableArtifactSnapshotVerifierPort, EditableArtifactStableIdFactoryPort, EditableArtifactStorePort } from "./ports.js";
2
2
  import { type ApplyEditableArtifactTransactionRequest, type ApplyEditableArtifactTransactionResult, type CreateEditableArtifactRequest, type CreateEditableArtifactResult, type ImportEditableArtifactRequest, type EditableArtifact, type EditableArtifactActor, type EditableArtifactClientTransactionId, type EditableArtifactReceipt, type EditableArtifactScope, type EditableArtifactSnapshotMetadata, type PublishEditableArtifactSnapshotRequest } from "./types.js";
3
3
  export declare const EDITABLE_ARTIFACT_MAX_OPERATIONS_PER_TRANSACTION = 4096;
4
4
  export declare const EDITABLE_ARTIFACT_MAX_UNDO_TARGETS_PER_TRANSACTION: number;
5
5
  export declare const EDITABLE_ARTIFACT_MAX_COMMAND_BYTES_PER_TRANSACTION: number;
6
6
  export declare const EDITABLE_ARTIFACT_MAX_INTENT_BYTES_PER_TRANSACTION: number;
7
- export declare const EDITABLE_ARTIFACT_INTENT_PROTOCOL_VERSION = 1;
8
7
  export declare const EDITABLE_ARTIFACT_MAX_OPERATION_BYTES_PER_TRANSACTION: number;
9
8
  /** Canonical OGACO envelope bound. Kept as an alias for existing consumers. */
10
9
  export declare const EDITABLE_ARTIFACT_MAX_COMMITTED_TRANSACTION_BYTES: number;
11
- export declare const EDITABLE_ARTIFACT_OPERATION_PROTOCOL_VERSION: 1;
10
+ export declare const EDITABLE_ARTIFACT_OPERATION_PROTOCOL_VERSION: 2;
12
11
  export declare const EDITABLE_ARTIFACT_MAX_COMMIT_ATTEMPTS = 4;
13
12
  /** Compact well before hard replay ceilings so one maximum transaction cannot cross them. */
14
13
  export declare const EDITABLE_ARTIFACT_COMPACTION_TRANSACTION_THRESHOLD = 1024;
@@ -81,6 +80,8 @@ export declare class EditableArtifactService {
81
80
  artifactId: EditableArtifact["id"];
82
81
  actor: EditableArtifactActor;
83
82
  request: ApplyEditableArtifactTransactionRequest;
83
+ /** Authenticated backend authority, not part of the client mutation envelope. */
84
+ authorizeCommit?: EditableArtifactCommitAuthorizer;
84
85
  }): Promise<ApplyEditableArtifactTransactionResult>;
85
86
  private applyTransactionOptimistically;
86
87
  compactCurrentHead(input: {
@@ -1,5 +1,5 @@
1
1
  import { type Settings } from "@opengeni/config";
2
- import type { AccessGrant, VariableSet } from "@opengeni/contracts";
2
+ import { type AccessGrant, type VariableSet } from "@opengeni/contracts";
3
3
  import { type Database } from "@opengeni/db";
4
4
  export declare const MAX_ENVIRONMENTS_PER_WORKSPACE = 25;
5
5
  export declare const MAX_VARIABLES_PER_ENVIRONMENT = 100;
@@ -9,12 +9,10 @@ export declare const assertAllowedEnvironmentVariableName: typeof assertAllowedV
9
9
  export declare function requireVariableSetEncryption(settings: Settings): Uint8Array;
10
10
  /** @deprecated use requireVariableSetEncryption */
11
11
  export declare const requireEnvironmentEncryption: typeof requireVariableSetEncryption;
12
- export declare function requireVariableSetForApi(db: Database, workspaceId: string, variableSetId: string): Promise<VariableSet>;
12
+ export declare function requireVariableSetForApi(db: Database, grant: AccessGrant, variableSetId: string): Promise<VariableSet>;
13
13
  /**
14
- * Validates an variableSet attachment supplied in a request payload (session
15
- * create, scheduled task create/update, pack enable). Requires the
16
- * `variable-sets:use` permission unless the attachment was already authorized
17
- * (pack-installation-inherited attachments), and maps a missing or
14
+ * Validates a Variable Set attachment supplied in a session or task request.
15
+ * Requires attach and use permissions, and maps a missing or
18
16
  * cross-variable set to 422 because the id is payload, not the route
19
17
  * target. RLS plus the workspace_id clause make cross-workspace ids
20
18
  * indistinguishable from missing ones.
@@ -22,9 +20,7 @@ export declare function requireVariableSetForApi(db: Database, workspaceId: stri
22
20
  export declare function validateVariableSetAttachment(deps: {
23
21
  settings: Settings;
24
22
  db: Database;
25
- }, grant: AccessGrant, workspaceId: string, variableSetId: string, options?: {
26
- preauthorized?: boolean;
27
- }): Promise<VariableSet>;
23
+ }, grant: AccessGrant, workspaceId: string, variableSetId: string): Promise<VariableSet>;
28
24
  export declare function recordVariableSetAuditEvent(db: Database, input: {
29
25
  grant: AccessGrant;
30
26
  action: "variable_set.created" | "variable_set.updated" | "variable_set.deleted" | "variable_set.variable.set" | "variable_set.variable.deleted";
@@ -0,0 +1,6 @@
1
+ import type { AccessGrant } from "@opengeni/contracts";
2
+ import { type AccessGrantAuthorization } from "../access/index.js";
3
+ export declare const EXTERNAL_CREATION_ATTRIBUTION_KEY = "opengeniExternalCreationAttribution";
4
+ /** Retained alongside session.created metadata; this is not a live permission
5
+ * snapshot and must never authorize a follow-up, child, or scheduled turn. */
6
+ export declare function externalCreationMetadata(metadata: Record<string, unknown> | undefined, authorization: AccessGrantAuthorization | undefined, grant: AccessGrant): Record<string, unknown> | undefined;
@@ -0,0 +1,8 @@
1
+ import { type SessionRlsActorContext } from "@opengeni/db";
2
+ import type { AccessGrant, Permission } from "@opengeni/contracts";
3
+ import { type AccessGrantAuthorization } from "../access/index.js";
4
+ import type { ApiRouteDeps } from "../dependencies.js";
5
+ /** Personal original-file access follows verified ownership, never a subject-shaped bearer. */
6
+ export declare function fileOwnerContextForAccess(deps: Pick<ApiRouteDeps, "db">, access: AccessGrantAuthorization, permission: Permission): Promise<SessionRlsActorContext>;
7
+ /** Internal MCP/core callers can prove an agent attempt without inventing a human authorization. */
8
+ export declare function fileOwnerContextForAgent(deps: Pick<ApiRouteDeps, "db">, grant: AccessGrant, permission: Permission): Promise<SessionRlsActorContext>;
@@ -0,0 +1,36 @@
1
+ import type { GitHubActionPolicyActor, GitHubActionPolicyActorState, GitHubActionPolicyDecision, GitHubActionPolicyGroup } from "@opengeni/contracts";
2
+ import { type ConnectorActionPolicySnapshotEntry, type Database } from "@opengeni/db";
3
+ import { GITHUB_REST_MCP_APP_SERVER_ID, GITHUB_REST_MCP_PERSONAL_SERVER_ID } from "@opengeni/runtime/github-rest-mcp";
4
+ export declare const GITHUB_ACTION_POLICY_GROUP_TOOL_NAMES: {
5
+ readonly routine: ("issue_comment" | "issue_create" | "issue_update" | "pull_request_comment" | "pull_request_create" | "pull_request_request_review" | "pull_request_update" | "ref_create")[];
6
+ readonly review: readonly ["pull_request_review_submit"];
7
+ readonly merge: readonly ["pull_request_merge"];
8
+ };
9
+ export type GitHubActionPolicyActorBinding = {
10
+ actor: GitHubActionPolicyActor;
11
+ label: string;
12
+ connectionId: string;
13
+ serverId: typeof GITHUB_REST_MCP_APP_SERVER_ID | typeof GITHUB_REST_MCP_PERSONAL_SERVER_ID;
14
+ };
15
+ export declare function projectGitHubActionPolicyActor(policies: readonly ConnectorActionPolicySnapshotEntry[], binding: GitHubActionPolicyActorBinding): GitHubActionPolicyActorState;
16
+ export declare function listGitHubActionPolicyActors(db: Database, input: {
17
+ accountId: string;
18
+ workspaceId: string;
19
+ actors: readonly GitHubActionPolicyActorBinding[];
20
+ }): Promise<GitHubActionPolicyActorState[]>;
21
+ export declare function updateGitHubActionPolicyGroup(db: Database, input: {
22
+ accountId: string;
23
+ workspaceId: string;
24
+ subjectId: string;
25
+ actor: GitHubActionPolicyActorBinding;
26
+ group: GitHubActionPolicyGroup;
27
+ decision: GitHubActionPolicyDecision;
28
+ }): Promise<GitHubActionPolicyActorState>;
29
+ export declare function githubAppActionPolicyActor(input: {
30
+ installationId: number;
31
+ accountLogin: string | null;
32
+ }): GitHubActionPolicyActorBinding;
33
+ export declare function personalGitHubActionPolicyActor(input: {
34
+ connectionId: string;
35
+ githubLogin: string;
36
+ }): GitHubActionPolicyActorBinding;
@@ -0,0 +1,117 @@
1
+ import type { RepositoryResourceRef, ResourceRef } from "@opengeni/contracts";
2
+ import { type Database } from "@opengeni/db";
3
+ /**
4
+ * GitHub App repository-binding resolution for bare repository resources.
5
+ *
6
+ * A repository resource that names a GitHub repository by URI alone (no
7
+ * `githubInstallationId`/`githubRepositoryId`) never mints an installation
8
+ * token, so the sandbox clones it anonymously and cannot push or use `gh`.
9
+ * The workspace allowlist (`github_installation_repositories`) stores only
10
+ * numeric repository ids, so resolving a URI needs the installation's owner
11
+ * login from the durable binding plus one provider read for the repository id.
12
+ * This module owns the pure parts: URI parsing, candidate selection under the
13
+ * workspace's auditable bindings, and the exactly-one-match stamping rule. The
14
+ * provider read is injected so the worker can supply the live GitHub lookup
15
+ * while tests stay deterministic.
16
+ */
17
+ export type GitHubRepositoryCoordinates = {
18
+ owner: string;
19
+ name: string;
20
+ };
21
+ /**
22
+ * Parse a GitHub repository reference into owner/name, else null. Accepts
23
+ * `https://github.com/<owner>/<repo>[.git][/]`, `www.github.com`,
24
+ * `ssh://git@github.com/<owner>/<repo>[.git]`, and the scp-like
25
+ * `git@github.com:<owner>/<repo>[.git]`.
26
+ */
27
+ export declare function parseGitHubRepositoryCoordinates(uri: string): GitHubRepositoryCoordinates | null;
28
+ export type UnboundGitHubRepositoryResource = {
29
+ resource: RepositoryResourceRef;
30
+ owner: string;
31
+ name: string;
32
+ };
33
+ /**
34
+ * Repository resources that name a github.com repository without any
35
+ * platform identity: no GitHub App ids, no credential binding, no personal
36
+ * connection, and either the explicit `github` provider or no provider at all.
37
+ * Resources that already carry ids, legacy provider ids, a binding, or a
38
+ * connection are someone else's authority and are never rewritten here.
39
+ */
40
+ export declare function unboundGitHubRepositoryResources(resources: readonly ResourceRef[]): UnboundGitHubRepositoryResource[];
41
+ export type GitHubRepositoryBindingCandidate = {
42
+ installationId: number;
43
+ accountLogin: string;
44
+ repositoryIds: number[];
45
+ };
46
+ /**
47
+ * The workspace's auditable GitHub App bindings, under workspace RLS. Only
48
+ * bindings that could authorize a token mint are candidates; legacy
49
+ * `unverified` rows never resolve a URI.
50
+ */
51
+ export declare function listGitHubRepositoryBindingCandidates(db: Database, workspaceId: string): Promise<GitHubRepositoryBindingCandidate[]>;
52
+ export type GitHubRepositoryBindingLookup = (input: {
53
+ installationId: number;
54
+ owner: string;
55
+ name: string;
56
+ }) => Promise<{
57
+ id: number;
58
+ } | null>;
59
+ export type GitHubRepositoryBinding = {
60
+ installationId: number;
61
+ repositoryId: number;
62
+ };
63
+ export type GitHubRepositoryBindingOutcome = {
64
+ status: "resolved";
65
+ binding: GitHubRepositoryBinding;
66
+ }
67
+ /** No workspace binding owns this repository's account: anonymous, as before. */
68
+ | {
69
+ status: "unbound";
70
+ }
71
+ /** The account is bound, but no installation's allowlist holds this repository. */
72
+ | {
73
+ status: "not_allowlisted";
74
+ installationIds: number[];
75
+ }
76
+ /** More than one bound installation's allowlist holds this repository. */
77
+ | {
78
+ status: "ambiguous";
79
+ installationIds: number[];
80
+ }
81
+ /** The provider lookup failed (suspended/deleted installation, outage). */
82
+ | {
83
+ status: "unavailable";
84
+ installationIds: number[];
85
+ message: string;
86
+ };
87
+ export type GitHubRepositoryBindingResolution = {
88
+ uri: string;
89
+ owner: string;
90
+ name: string;
91
+ outcome: GitHubRepositoryBindingOutcome;
92
+ };
93
+ export type GitHubRepositoryBindingResolutionResult = {
94
+ resources: ResourceRef[];
95
+ bindings: Map<string, GitHubRepositoryBinding>;
96
+ resolutions: GitHubRepositoryBindingResolution[];
97
+ };
98
+ /**
99
+ * Resolve every bare github.com repository resource against the workspace's
100
+ * auditable bindings. A resource is stamped only when exactly one bound
101
+ * installation's allowlist contains the repository id GitHub reports for that
102
+ * URI through that installation. Every other case leaves the resource bare
103
+ * and reports why, so the caller can surface a warning without ever failing
104
+ * the turn or the session. Distinct URIs resolve concurrently, as do the
105
+ * candidate installations of one owner.
106
+ */
107
+ export declare function resolveGitHubRepositoryBindings(input: {
108
+ resources: readonly ResourceRef[];
109
+ candidates: readonly GitHubRepositoryBindingCandidate[];
110
+ lookup: GitHubRepositoryBindingLookup;
111
+ }): Promise<GitHubRepositoryBindingResolutionResult>;
112
+ /**
113
+ * Stamp resolved GitHub App ids onto the matching bare resources of any
114
+ * resource list (turn resources and runtime resources must agree, because the
115
+ * credential binding id and token filename derive from the installation id).
116
+ */
117
+ export declare function applyGitHubRepositoryBindings(resources: readonly ResourceRef[], bindings: ReadonlyMap<string, GitHubRepositoryBinding>): ResourceRef[];
@@ -0,0 +1,5 @@
1
+ import type { Settings } from "@opengeni/config";
2
+ import type { GitHubSkillSourceClient } from "./skill-imports.js";
3
+ type GitHubJsonRequest = (path: string, maxBytes: number, label: string) => Promise<unknown>;
4
+ export declare function createGitHubSkillSourceClient(settings: Settings, requestJson?: GitHubJsonRequest): GitHubSkillSourceClient;
5
+ export {};