@opengeni/core 5.0.1 → 5.0.5-canary.39992356589001

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 (222) hide show
  1. package/README.md +3 -3
  2. package/dist/access/index.d.ts +147 -8
  3. package/dist/application/composer-submit.d.ts +1 -1
  4. package/dist/application/connect-operation.d.ts +3 -0
  5. package/dist/application/draft-model-preparation.d.ts +21 -0
  6. package/dist/application/external-workspace-members.d.ts +4 -2
  7. package/dist/application/modal-native-live-declaration-join.d.ts +37 -0
  8. package/dist/application/modal-native-original-configuration.d.ts +79 -0
  9. package/dist/application/modal-native-worker-host-transport.d.ts +297 -0
  10. package/dist/application/organization-privacy.d.ts +78 -0
  11. package/dist/application/prepared-mcp-connection.d.ts +31 -0
  12. package/dist/application/sandbox-recovery.d.ts +69 -2
  13. package/dist/application/session-commands.d.ts +376 -2
  14. package/dist/application/session-tenancy.d.ts +13 -4
  15. package/dist/application/site-session-cancellation.d.ts +14 -0
  16. package/dist/billing/agent-run-admission.d.ts +21 -0
  17. package/dist/billing/limits.d.ts +21 -1
  18. package/dist/billing/model-call-admission.d.ts +34 -0
  19. package/dist/billing/model-usage-settlement.d.ts +112 -0
  20. package/dist/canonical-human-identities.js +1 -1
  21. package/dist/{chunk-2MKMRGSY.js → chunk-C3BPQGEH.js} +2 -2
  22. package/dist/{chunk-LCQXNR62.js → chunk-DMVCCCCX.js} +52 -3
  23. package/dist/chunk-DMVCCCCX.js.map +1 -0
  24. package/dist/{chunk-GVO3N37G.js → chunk-R5FLZL3D.js} +11 -2
  25. package/dist/chunk-R5FLZL3D.js.map +1 -0
  26. package/dist/{chunk-MM6N7CTO.js → chunk-TTWTXQB2.js} +75 -5
  27. package/dist/chunk-TTWTXQB2.js.map +1 -0
  28. package/dist/codex-model-availability.d.ts +51 -8
  29. package/dist/default-session-model.d.ts +82 -15
  30. package/dist/dependencies.d.ts +44 -7
  31. package/dist/developer-setup-credential-ceiling.d.ts +10 -0
  32. package/dist/domain/agent-config-resolution.d.ts +10 -15
  33. package/dist/domain/automations.d.ts +8 -1
  34. package/dist/domain/browser-retained-downloads.d.ts +58 -0
  35. package/dist/domain/capabilities.d.ts +152 -5
  36. package/dist/domain/connector-tool-permissions.d.ts +39 -3
  37. package/dist/domain/direct-model-provider.d.ts +22 -0
  38. package/dist/domain/editable-artifacts/ports.d.ts +5 -0
  39. package/dist/domain/editable-artifacts/service.d.ts +8 -0
  40. package/dist/domain/editable-artifacts/types.d.ts +1 -1
  41. package/dist/domain/encryption-key.d.ts +12 -0
  42. package/dist/domain/file-audience.d.ts +64 -0
  43. package/dist/domain/insights-usage.d.ts +50 -0
  44. package/dist/domain/insights.d.ts +17 -2
  45. package/dist/domain/knowledge-preparation.d.ts +9 -3
  46. package/dist/domain/knowledge-search.d.ts +4 -0
  47. package/dist/domain/mcp-account-bindings.d.ts +0 -2
  48. package/dist/domain/mcp-account-routes.d.ts +21 -0
  49. package/dist/domain/mcp-streamable-http-client.d.ts +33 -0
  50. package/dist/domain/personal-connection-delegations.d.ts +34 -14
  51. package/dist/domain/pr-review.d.ts +30 -11
  52. package/dist/domain/realtime-voice-billing.d.ts +103 -0
  53. package/dist/domain/resources.d.ts +18 -2
  54. package/dist/domain/scheduled-task-access.d.ts +75 -56
  55. package/dist/domain/scheduled-task-account-audit.d.ts +27 -0
  56. package/dist/domain/scheduled-task-audience.d.ts +70 -0
  57. package/dist/domain/scheduled-tasks.d.ts +51 -18
  58. package/dist/domain/session-connection-accounts.d.ts +41 -4
  59. package/dist/domain/session-start-timing.d.ts +7 -0
  60. package/dist/domain/session-tool-policy.d.ts +27 -11
  61. package/dist/domain/sessions.d.ts +76 -7
  62. package/dist/domain/site-audience.d.ts +52 -0
  63. package/dist/domain/slack-bot.d.ts +6 -15
  64. package/dist/domain/slack-publication-secret-safety.d.ts +1 -1
  65. package/dist/domain/vaults/external-provider-connections.d.ts +126 -0
  66. package/dist/domain/vaults/index.d.ts +8 -0
  67. package/dist/domain/vaults/mapping.d.ts +41 -0
  68. package/dist/domain/vaults/provider-registry.d.ts +75 -0
  69. package/dist/domain/vaults/provider-sync.d.ts +290 -0
  70. package/dist/domain/vaults/provider-writes.d.ts +147 -0
  71. package/dist/domain/vaults/remote-provider-runtime.d.ts +7 -0
  72. package/dist/domain/vaults/secret-resolver.d.ts +62 -0
  73. package/dist/domain/vaults/types.d.ts +24 -0
  74. package/dist/domain/vaults/vault-service.d.ts +35 -0
  75. package/dist/domain/voice-input-billing.d.ts +77 -0
  76. package/dist/domain/web-search-billing.d.ts +51 -0
  77. package/dist/domain/workspace-credits.d.ts +7 -0
  78. package/dist/editable-artifact-live/application.d.ts +6 -0
  79. package/dist/editable-artifact-live.js +2 -2
  80. package/dist/editable-artifacts.js +4 -2
  81. package/dist/goal-admission.d.ts +664 -0
  82. package/dist/host-session-usage-limit.d.ts +15 -0
  83. package/dist/index.d.ts +38 -3
  84. package/dist/index.js +21167 -10908
  85. package/dist/index.js.map +1 -1
  86. package/dist/managed-session.d.ts +61 -1
  87. package/dist/model-call.d.ts +58 -0
  88. package/dist/model-catalog.d.ts +46 -4
  89. package/dist/model-provider-credentials.d.ts +43 -0
  90. package/dist/product-usage-metrics.d.ts +30 -0
  91. package/dist/rigs/index.d.ts +1 -13
  92. package/dist/sandbox/agent-background-commands.d.ts +22 -0
  93. package/dist/sandbox/compute-plane.d.ts +39 -0
  94. package/dist/sandbox/fleet.d.ts +103 -5
  95. package/dist/sandbox/output-release.d.ts +52 -0
  96. package/dist/sandbox/routing.d.ts +61 -2
  97. package/dist/sandbox/runtime-settings.d.ts +11 -2
  98. package/dist/session-authorization.d.ts +20 -0
  99. package/dist/session-usage-limit-metrics.d.ts +60 -0
  100. package/dist/session-usage-limits.d.ts +89 -0
  101. package/dist/site-session-access.d.ts +7 -0
  102. package/dist/site-session-origin.d.ts +37 -2
  103. package/dist/transcription.d.ts +120 -3
  104. package/dist/turn-surface.d.ts +5 -3
  105. package/dist/user-presence.d.ts +32 -0
  106. package/dist/workflow-wake-contract.d.ts +13 -1
  107. package/package.json +16 -14
  108. package/src/access/index.ts +1010 -39
  109. package/src/access/service-initiator.ts +2 -2
  110. package/src/application/api-integration-servers.ts +9 -0
  111. package/src/application/composer-submit.ts +1 -1
  112. package/src/application/connect-authority.ts +3 -3
  113. package/src/application/connect-operation.ts +14 -9
  114. package/src/application/draft-model-preparation.ts +66 -0
  115. package/src/application/external-continuation.ts +20 -3
  116. package/src/application/external-link-work-admission.ts +3 -0
  117. package/src/application/external-workspace-members.ts +33 -9
  118. package/src/application/modal-native-live-declaration-join.ts +196 -0
  119. package/src/application/modal-native-original-configuration.ts +261 -0
  120. package/src/application/modal-native-worker-host-transport.ts +263 -0
  121. package/src/application/new-session-drafts.ts +62 -40
  122. package/src/application/organization-privacy.ts +195 -0
  123. package/src/application/prepared-mcp-connection.ts +133 -0
  124. package/src/application/sandbox-recovery.ts +55 -8
  125. package/src/application/session-commands.ts +95 -20
  126. package/src/application/session-mcp-credential-rotation.ts +4 -3
  127. package/src/application/session-tenancy.ts +253 -44
  128. package/src/application/site-session-cancellation.ts +47 -0
  129. package/src/application/user-resource-grants.ts +0 -13
  130. package/src/billing/agent-run-admission.ts +117 -0
  131. package/src/billing/limits.ts +97 -9
  132. package/src/billing/model-call-admission.ts +118 -0
  133. package/src/billing/model-usage-settlement.ts +472 -0
  134. package/src/codex-model-availability.ts +327 -109
  135. package/src/default-session-model.ts +309 -144
  136. package/src/dependencies.ts +47 -6
  137. package/src/developer-setup-credential-ceiling.ts +60 -0
  138. package/src/domain/agent-config-resolution.ts +38 -47
  139. package/src/domain/automations.ts +76 -2
  140. package/src/domain/browser-retained-downloads.ts +232 -0
  141. package/src/domain/capabilities.ts +886 -104
  142. package/src/domain/connector-tool-permissions.ts +367 -109
  143. package/src/domain/direct-model-provider.ts +100 -0
  144. package/src/domain/editable-artifacts/ports.ts +8 -0
  145. package/src/domain/editable-artifacts/service.ts +67 -2
  146. package/src/domain/editable-artifacts/types.ts +1 -1
  147. package/src/domain/encryption-key.ts +26 -0
  148. package/src/domain/file-audience.ts +147 -0
  149. package/src/domain/file-owner.ts +1 -0
  150. package/src/domain/github-action-policies.ts +1 -1
  151. package/src/domain/insights-usage.ts +86 -0
  152. package/src/domain/insights.ts +109 -9
  153. package/src/domain/knowledge-preparation.test.ts +63 -0
  154. package/src/domain/knowledge-preparation.ts +24 -10
  155. package/src/domain/knowledge-search.test.ts +97 -1
  156. package/src/domain/knowledge-search.ts +20 -4
  157. package/src/domain/mcp-account-bindings.ts +7 -18
  158. package/src/domain/mcp-account-routes.ts +152 -0
  159. package/src/domain/mcp-streamable-http-client.ts +158 -0
  160. package/src/domain/organization-integration-catalog.ts +1 -0
  161. package/src/domain/personal-connection-delegations.ts +132 -183
  162. package/src/domain/pr-review.ts +2 -2
  163. package/src/domain/realtime-voice-billing.ts +427 -0
  164. package/src/domain/resources.ts +47 -4
  165. package/src/domain/scheduled-task-access.ts +207 -167
  166. package/src/domain/scheduled-task-account-audit.ts +90 -0
  167. package/src/domain/scheduled-task-audience.ts +248 -0
  168. package/src/domain/scheduled-tasks.ts +1106 -426
  169. package/src/domain/session-connection-accounts.ts +168 -10
  170. package/src/domain/session-start-timing.ts +60 -0
  171. package/src/domain/session-tool-policy.ts +122 -42
  172. package/src/domain/sessions.ts +1272 -565
  173. package/src/domain/site-audience.ts +130 -0
  174. package/src/domain/slack-bot.ts +21 -26
  175. package/src/domain/slack-publication-secret-safety.ts +1 -1
  176. package/src/domain/vaults/external-provider-connections.ts +395 -0
  177. package/src/domain/vaults/index.ts +27 -0
  178. package/src/domain/vaults/mapping.ts +284 -0
  179. package/src/domain/vaults/provider-registry.ts +230 -0
  180. package/src/domain/vaults/provider-sync.ts +887 -0
  181. package/src/domain/vaults/provider-writes.ts +632 -0
  182. package/src/domain/vaults/remote-provider-runtime.ts +129 -0
  183. package/src/domain/vaults/secret-resolver.ts +634 -0
  184. package/src/domain/vaults/types.ts +26 -0
  185. package/src/domain/vaults/vault-service.ts +1508 -0
  186. package/src/domain/voice-input-billing.ts +334 -0
  187. package/src/domain/web-search-billing.ts +169 -0
  188. package/src/domain/workspace-credits.ts +13 -0
  189. package/src/editable-artifact-live/application.ts +22 -0
  190. package/src/goal-admission.ts +220 -0
  191. package/src/host-session-usage-limit.ts +25 -0
  192. package/src/index.ts +60 -5
  193. package/src/managed-session.ts +105 -5
  194. package/src/model-call.ts +79 -0
  195. package/src/model-catalog.ts +369 -85
  196. package/src/model-provider-credentials.ts +506 -0
  197. package/src/product-usage-metrics.ts +101 -0
  198. package/src/rigs/index.ts +7 -95
  199. package/src/sandbox/agent-background-commands.ts +140 -0
  200. package/src/sandbox/compute-plane.ts +124 -0
  201. package/src/sandbox/fleet.ts +434 -32
  202. package/src/sandbox/output-release.ts +90 -0
  203. package/src/sandbox/routing.ts +287 -41
  204. package/src/sandbox/runtime-settings.ts +111 -4
  205. package/src/session-authorization.ts +273 -66
  206. package/src/session-usage-limit-metrics.ts +95 -0
  207. package/src/session-usage-limits.ts +415 -0
  208. package/src/site-session-access.ts +46 -0
  209. package/src/site-session-origin.ts +79 -5
  210. package/src/transcription.ts +123 -4
  211. package/src/turn-surface.ts +5 -3
  212. package/src/user-presence.ts +134 -0
  213. package/src/workflow-wake-contract.ts +14 -1
  214. package/dist/chunk-GVO3N37G.js.map +0 -1
  215. package/dist/chunk-LCQXNR62.js.map +0 -1
  216. package/dist/chunk-MM6N7CTO.js.map +0 -1
  217. package/dist/domain/environments.d.ts +0 -29
  218. package/dist/domain/knowledge-messages.test.d.ts +0 -1
  219. package/dist/domain/knowledge-preparation.test.d.ts +0 -1
  220. package/dist/domain/knowledge-search.test.d.ts +0 -1
  221. package/src/domain/environments.ts +0 -115
  222. /package/dist/{chunk-2MKMRGSY.js.map → chunk-C3BPQGEH.js.map} +0 -0
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @opengeni/core
2
2
 
3
- `@opengeni/core` is the extracted OpenGeni server core: domain flows, access checks, billing/admission helpers, sandbox fleet/routing helpers, and the shared dependency types that HTTP routes and embedded hosts use.
3
+ `@opengeni/core` is the extracted Opengeni server core: domain flows, access checks, billing/admission helpers, sandbox fleet/routing helpers, and the shared dependency types that HTTP routes and embedded hosts use.
4
4
 
5
5
  It owns code that is not intrinsically HTTP or Temporal process bootstrapping:
6
6
 
@@ -11,7 +11,7 @@ It owns code that is not intrinsically HTTP or Temporal process bootstrapping:
11
11
 
12
12
  `@opengeni/api-router` owns the Hono app, middleware, HTTP route adapters, MCP HTTP transport, and API-direct sandbox endpoints. `@opengeni/worker-bundle` owns Temporal worker construction, workflows, activities, and process lifecycle. Both consume `@opengeni/core`; core does not import either app.
13
13
 
14
- The package is used by standalone OpenGeni through those app runners and by embedded hosts that call core directly or mount the API router.
14
+ The package is used by standalone Opengeni through those app runners and by embedded hosts that call core directly or mount the API router.
15
15
 
16
16
  ## Scope honesty: engine-core, not domain-core
17
17
 
@@ -19,5 +19,5 @@ This package is the **engine core** — the transport-mostly-neutral heart of th
19
19
  server, extracted so embedders can mount it. It still carries server-flavored
20
20
  dependencies (notably Hono's `HTTPException` as the domain error type and the
21
21
  full persistence/runtime closure). It is NOT a pure domain library and does not
22
- try to be one; if you need OpenGeni without any server runtime, you want the
22
+ try to be one; if you need Opengeni without any server runtime, you want the
23
23
  REST API + `@opengeni/sdk` instead.
@@ -1,15 +1,114 @@
1
1
  import { type Settings } from "@opengeni/config";
2
2
  import { ExternalActorAttribution, type ExternalActorContinuation } from "@opengeni/contracts/external-identities";
3
- import { type AccountGrant, type AccessContext, type AccessGrant, type OrganizationApiKeyAccess, Permission, type Workspace } from "@opengeni/contracts";
3
+ import { type AccountGrant, type AccessContext, type AccessGrant, type OrganizationApiKeyAccess, OrganizationWorkspaceScope, Permission, type Workspace } from "@opengeni/contracts";
4
4
  import { type Database } from "@opengeni/db";
5
5
  import type { Context } from "hono";
6
+ import { z } from "zod";
6
7
  import type { ManagedAuth } from "../managed-auth-type.js";
7
8
  import type { ManagedAuthSessionAdapter } from "../managed-auth-session-sets.js";
9
+ import type { UserPresenceRecorder } from "../user-presence.js";
10
+ /** Only canonical authentication can prove setup-key provenance. */
11
+ export declare function isDeveloperSetupApiKeyContext(context: AccessContext): boolean;
12
+ /** Provenance from canonical raw-key or verified restricted-token authentication. */
13
+ export declare function isDeveloperSetupAuthorization(authorization: AccessGrantAuthorization | undefined): boolean;
14
+ /** Exact grant objects resolved under authenticated setup-only provenance. */
15
+ export declare function isDeveloperSetupGrant(grant: AccessGrant): boolean;
16
+ /** Setup-derived credentials cannot carry literal organization or key authority. */
17
+ export declare function isDeveloperSetupDelegatedPermissionAllowed(permission: Permission): boolean;
18
+ /** Canonical authentication provenance, including the backing key of asUser. */
19
+ export declare function requireApiKeyManagementContext(context: AccessContext): void;
20
+ /** Membership is not an escape hatch for minting durable credentials. */
21
+ export declare function requireApiKeyDelegationContext(context: AccessContext, permissions: Permission[]): void;
22
+ /** Downstream legacy credentials cannot encode a partially selected admin. */
23
+ export declare function requireExplicitPermissionDelegation(grant: Pick<AccessGrant, "permissions" | "permissionMode">, requested: Permission[]): void;
24
+ export type DelegatedHumanAuthorization = Readonly<{
25
+ organizationId: string;
26
+ /** Exact native person subject, never an external identity or service. */
27
+ subjectId: string;
28
+ permissions: Permission[];
29
+ workspaceScope: OrganizationWorkspaceScope;
30
+ }>;
31
+ declare const delegatedHumanProfileSchema: z.ZodObject<{
32
+ id: z.ZodString;
33
+ name: z.ZodNullable<z.ZodString>;
34
+ email: z.ZodString;
35
+ emailVerified: z.ZodOptional<z.ZodBoolean>;
36
+ }, z.core.$strip>;
37
+ export type VerifiedDelegatedHumanContext = Readonly<{
38
+ /** Native identity projection only, never a browser/auth session. Absence of
39
+ * emailVerified means the native lookup did not prove email verification. */
40
+ user: Readonly<z.infer<typeof delegatedHumanProfileSchema>>;
41
+ subjectId: string;
42
+ authorization: DelegatedHumanAuthorization;
43
+ context: AccessContext;
44
+ }>;
45
+ /**
46
+ * TRUSTED OAUTH VERIFIED DISPATCH ONLY. Before each stamp the in-process caller
47
+ * must validate the live OAuth grant, revocation, exact native person subject,
48
+ * organization, permission ceilings and workspace scope. This API does not
49
+ * verify OAuth and must NEVER be called with headers, metadata, token claims,
50
+ * a previous request's proof, or other unverified caller input.
51
+ *
52
+ * Stamp the exact raw Request that the actions dispatcher will pass to routes,
53
+ * before any access resolution. Cloning/wrapping a Request does not copy proof.
54
+ * The resolver reloads the real native person's live access on this request
55
+ * (and on fresh reauthorization); no session or cached grant is fabricated or
56
+ * transplanted. This proof never becomes managed-cookie/person-present proof.
57
+ */
58
+ export declare function stampDelegatedHumanAuthorization(request: Request, input: DelegatedHumanAuthorization): void;
59
+ /**
60
+ * Verified published-Site dispatch only: the caller has verified the signed
61
+ * gateway, served host and opaque viewer cookie. This is exact-workspace
62
+ * ownership for session routes, not a console login or a generic Site bearer.
63
+ * Native people use the existing delegated-human resolver; external owning
64
+ * users reload their existing membership without provisioning a new identity.
65
+ */
66
+ export declare function stampSiteViewerSessionAuthorization(request: Request, input: {
67
+ organizationId: string;
68
+ workspaceId: string;
69
+ subjectId: string;
70
+ permissions: Permission[];
71
+ }): void;
72
+ /** Token prefix of personal API keys, which act as the person who made them. */
73
+ export declare const PERSONAL_API_KEY_TOKEN_PREFIX = "ogp_";
74
+ /**
75
+ * A personal API key acts as its owner. Call once per incoming request, after
76
+ * any middleware that may rebuild the Request and before access resolution:
77
+ * an active personal key stamps this exact raw Request with its owner and
78
+ * access setting, so the request resolves through the same live-access path as
79
+ * a person's signed-in agent (their current membership, role and workspaces,
80
+ * capped by the key) and routes treat it as that person. Anything else is left
81
+ * to the ordinary resolver, which refuses an unknown or revoked key.
82
+ */
83
+ export declare function stampPersonalApiKeyRequest(request: Request, deps: Pick<AccessDeps, "db">): Promise<boolean>;
84
+ /** Immutable verified dispatch bounds for this exact raw Request, not a grant. */
85
+ export declare function verifiedDelegatedHumanAuthorizationForRequest(request: Request): DelegatedHumanAuthorization | null;
86
+ /**
87
+ * Resolve the exact verified OAuth-dispatch person and constrained live native
88
+ * access for this raw Request. Unstamped requests (even browser cookies) fail
89
+ * closed; callers must not fall back to a service or subject-shaped identity.
90
+ * Uses the same request-local native resolution as requireAccessContext.
91
+ *
92
+ * No session, session id or managed-cookie proof is created. emailVerified is
93
+ * forwarded only when the native profile lookup supplies it; missing is not
94
+ * verified and must never be filled from OAuth claims, headers or metadata.
95
+ */
96
+ export declare function requireVerifiedDelegatedHumanContext(c: Context, deps: AccessDeps): Promise<VerifiedDelegatedHumanContext>;
97
+ /** Exact resolved owning-person authorization; clones and service claims fail.
98
+ * Supplying the raw Request additionally binds proof to that exact dispatch,
99
+ * not another request with the same native person and authorization bounds. */
100
+ export declare function isVerifiedDelegatedHumanAuthorization(authorization: AccessGrantAuthorization, request?: Request): boolean;
101
+ /**
102
+ * Default permissions for a membership created on an external user's first
103
+ * request. Keep equal to `CONVERSATION_PERMISSIONS` in
104
+ * `packages/sdk/src/tenant-workspaces.ts`: conversation use only, no admin.
105
+ */
106
+ export declare const EXTERNAL_FIRST_USE_MEMBER_PERMISSIONS: readonly Permission[];
8
107
  /** Creation audit only, never an authentication or delegation token. Metadata
9
108
  * claiming to be external is insufficient; the exact resolver proof is needed. */
10
109
  export declare function externalAttributionForAuthorization(authorization: AccessGrantAuthorization | undefined, grant: AccessGrant): ExternalActorAttribution | null;
11
110
  export declare function externalActorContinuationForAuthorization(authorization: AccessGrantAuthorization): ExternalActorContinuation | null;
12
- /** Dedicated owning-user proof. External admission never sets the native
111
+ /** Dedicated owning-user proof. External/OAuth admission never sets the native
13
112
  * cookie stamp. The resource/session layer still checks the exact owner. */
14
113
  export declare function hasVerifiedOwningUserAuthorization(authorization: AccessGrantAuthorization): boolean;
15
114
  /** Request-local organization service-key proof, not a principal-kind claim. */
@@ -17,14 +116,17 @@ export declare function isVerifiedOrganizationServiceAuthorization(authorization
17
116
  export type AccountScopedApiKeyWorkspaceAuthority = Readonly<{
18
117
  accountId: string;
19
118
  permissions: Permission[];
119
+ workspaceScope: OrganizationWorkspaceScope;
120
+ permissionMode: "legacy" | "explicit";
20
121
  }>;
122
+ export declare function organizationWorkspaceInScope(scope: OrganizationWorkspaceScope, workspaceId: string): boolean;
21
123
  /**
22
124
  * Return account-scoped API-key workspace authority only for the exact
23
125
  * AccessContext object stamped by successful API-key authentication. Subject
24
126
  * shape alone is deliberately insufficient.
25
127
  */
26
128
  export declare function accountScopedApiKeyWorkspaceAuthority(context: AccessContext): AccountScopedApiKeyWorkspaceAuthority | null;
27
- /** The organization access tier is derived from the stored workspace-admin wildcard. */
129
+ /** Classify stored scopes without changing the legacy full/read permission sets. */
28
130
  export declare function organizationApiKeyAccess(permissions: Permission[]): OrganizationApiKeyAccess;
29
131
  /**
30
132
  * Opaque, request-local proof that the canonical access resolver authorized the
@@ -43,6 +145,8 @@ export type AccessDeps = {
43
145
  settings: Settings;
44
146
  managedAuth?: ManagedAuth | null;
45
147
  managedAuthSessionAdapter?: ManagedAuthSessionAdapter | null;
148
+ /** Analytics only: notes canonical managed-cookie activity, never authority. */
149
+ userPresence?: UserPresenceRecorder | null;
46
150
  };
47
151
  /** null means this is not an authenticated external lane; [] means that lane
48
152
  * has no readable inventory. Callers must not fall back from [] to service or
@@ -64,8 +168,9 @@ export type AccessGrantAuthorization = {
64
168
  contextIntegrity: boolean;
65
169
  /**
66
170
  * Did this request authenticate as the canonical managed-cookie (Better Auth)
67
- * session that OWNS this grant's subject? The single input to the owner-only
68
- * managed personal-workspace exception; see `isCanonicalManagedHumanSession`.
171
+ * session that OWNS this grant's subject? Cookie/person-present ceremonies
172
+ * retain this strict gate; owning-user boundaries use
173
+ * `hasVerifiedOwningUserAuthorization` instead.
69
174
  * False for every bearer, API-key, delegated, service, local, and configured
70
175
  * principal, and for any future path that does not verify a cookie.
71
176
  */
@@ -109,11 +214,44 @@ export declare function requireCanonicalLocalAccountAdministrator(c: Context, de
109
214
  export declare function requireAccessGrantAuthorization(c: Context, deps: AccessDeps, workspaceId: string, permission?: Permission): Promise<AccessGrantAuthorization>;
110
215
  /**
111
216
  * Settings administration is narrower than workspace administration. The
112
- * canonical managed-cookie owner may configure their Personal workspace, but
217
+ * verified owning user may configure their Personal workspace, but
113
218
  * never acquires the admin wildcard (and its membership/delegation powers).
219
+ * Delegated owners also need workspace:admin in their verified dispatch/key
220
+ * ceiling: a read-only delegation cannot turn ownership into a settings write.
114
221
  * Only use this boundary for workspace configuration, not access management.
115
222
  */
116
223
  export declare function requireWorkspaceSettingsGrant(c: Context, deps: AccessDeps, workspaceId: string): Promise<AccessGrant>;
224
+ /**
225
+ * Authority for a shared workspace's own Members surface (list, candidates,
226
+ * add, change, remove). A holder of the requested workspace permission keeps
227
+ * the ordinary grant. Otherwise an active organization owner or administrator,
228
+ * authenticated by the canonical managed cookie, manages any shared workspace
229
+ * in their organization exactly as through the organization control plane,
230
+ * with or without an operational membership row there. Every other principal
231
+ * (API keys, delegated bearers, agents, services, local/configured access)
232
+ * and every Personal workspace keeps the original refusal. The database
233
+ * functions re-derive the organization role under the organization fence.
234
+ */
235
+ export declare function requireWorkspaceMemberManagementAuthority(c: Context, deps: AccessDeps, workspaceId: string, permission: "members:manage" | "workspace:read"): Promise<{
236
+ grant: AccessGrant;
237
+ organizationAdministrator: boolean;
238
+ }>;
239
+ /**
240
+ * The subject whose inbox this request may read, or null when it has none.
241
+ * A signed-in person (`user:`, no key) requires verified managed-human
242
+ * provenance, including approved native app credentials. The local
243
+ * install's human qualifies only when the in-process local bootstrap produced
244
+ * this context (so a delegated bearer naming `dev` cannot borrow it), with the
245
+ * human-session, non-delegated, non-service, keyless shape of
246
+ * {@link accessContextHasInbox}. An agent acting as a person (verified
247
+ * in-process dispatch) reads that person's inbox within its organization and
248
+ * workspaces: the inbox routes check each item's workspace on this context.
249
+ * An external user (`external_user:`) reads their own inbox only through the
250
+ * organization key that resolved them as an external actor, within that
251
+ * organization; a linked native identity acts as its `user:` person, whose
252
+ * inbox is read by signing in to Opengeni, not through a product's key.
253
+ */
254
+ export declare function inboxSubjectForContext(context: AccessContext): string | null;
117
255
  export declare function requirePermission(grant: AccessGrant, permission: Permission): void;
118
256
  /**
119
257
  * Require a permission to be present literally on the grant. This deliberately
@@ -122,5 +260,6 @@ export declare function requirePermission(grant: AccessGrant, permission: Permis
122
260
  * acquire implicitly.
123
261
  */
124
262
  export declare function requireLiteralPermission(grant: AccessGrant, permission: Permission): void;
125
- export declare function hasLiteralPermission(permissions: Permission[], permission: Permission): boolean;
126
- export declare function hasPermission(permissions: Permission[], permission: Permission): boolean;
263
+ export declare function hasLiteralPermission(permissions: readonly Permission[], permission: Permission): boolean;
264
+ export declare function hasPermission(permissions: readonly Permission[], permission: Permission, permissionMode?: AccessGrant["permissionMode"]): boolean;
265
+ export {};
@@ -18,7 +18,7 @@ export type SubmitComposerDraftForRequestOptions = {
18
18
  * This is the application boundary shared by the stock HTTP adapter and an
19
19
  * in-process embedding host. A host may prepare its own durable business state
20
20
  * before calling this function and project the returned receipt afterward, but
21
- * OpenGeni remains the sole authority for draft validation/rotation, event
21
+ * Opengeni remains the sole authority for draft validation/rotation, event
22
22
  * append, turn creation, routing, and idempotent replay.
23
23
  */
24
24
  export declare function submitComposerDraftForRequest(deps: AcceptSessionUserMessageDependencies, grant: AccessGrant, workspaceId: string, sessionId: string, input: SubmitComposerDraftRequest, options?: SubmitComposerDraftForRequestOptions): Promise<SubmitComposerDraftResponse>;
@@ -26,6 +26,9 @@ export declare function executeConnectOperation(input: {
26
26
  /** Trusted server adapter classification, never derived from request data.
27
27
  * Cancellation releases pending setup; it acquires no integration authority. */
28
28
  purpose?: "acquisition" | "cancellation";
29
+ /** Trusted adapter's exact attempt fence, inside the organization policy
30
+ * prefix and before Connect row locks, for both claim and final commit. */
31
+ beforeOperation?: ((tx: Database) => Promise<void>) | undefined;
29
32
  authorize: ConnectOperationAuthorization;
30
33
  execute: (attempt: ConnectAttempt) => Promise<PreparedConnectOperation>;
31
34
  }): Promise<ConnectAttempt>;
@@ -0,0 +1,21 @@
1
+ import { type Settings } from "@opengeni/config";
2
+ import { type Database } from "@opengeni/db";
3
+ import { refreshCoreCodexModelEntitlements } from "../codex-model-availability.js";
4
+ /**
5
+ * A committed, debounced draft save is a hint, never turn admission. Prepare
6
+ * only reusable shared catalog facts. No workflow, lease, model, MCP or
7
+ * sandbox is started, and Send still makes every authority decision itself.
8
+ * React and React Native durable composers already share this save path.
9
+ */
10
+ export declare function prepareDraftModel(deps: {
11
+ db: Database;
12
+ settings: Settings;
13
+ }, context: {
14
+ accountId: string;
15
+ workspaceId: string;
16
+ subjectId: string;
17
+ }, draft: {
18
+ text: string;
19
+ resources: readonly unknown[];
20
+ model: string;
21
+ }, refresh?: typeof refreshCoreCodexModelEntitlements): void;
@@ -1,7 +1,9 @@
1
1
  import type { Context } from "hono";
2
2
  import { type ExternalIdentity } from "@opengeni/contracts/external-identities";
3
3
  import { type AccessDeps } from "../access/index.js";
4
- /** Explicit host onboarding. Ordinary asUser reads never call this operation.
4
+ /** Explicit host onboarding. Ordinary asUser requests never call this
5
+ * operation; their first-use membership is `provisionExternalMemberOnFirstUse`
6
+ * in `../access`, under the same key authority and lifecycle fence.
5
7
  * Existing memberships are not overwritten, including reduced permissions. */
6
8
  export declare function addExternalWorkspaceMemberForRequest(c: Context, deps: AccessDeps, workspaceId: string, input: unknown): Promise<ExternalIdentity>;
7
9
  export declare function lookupExternalIdentityForRequest(c: Context, deps: AccessDeps, organizationId: string, input: unknown): Promise<{
@@ -26,7 +28,7 @@ export declare function cancelExternalWorkspaceMemberGrantForRequest(c: Context,
26
28
  export declare function updateExternalWorkspaceMemberForRequest(c: Context, deps: AccessDeps, organizationId: string, workspaceId: string, membershipId: string, input: unknown): Promise<{
27
29
  subjectId: string;
28
30
  organizationMembershipId: string;
29
- permissions: ("account:admin" | "account:read" | "api_keys:manage" | "artifacts:publish" | "artifacts:read" | "billing:manage" | "billing:read" | "capabilities:manage" | "codemode:call" | "connections:read" | "connections:write" | "documents:manage" | "documents:search" | "enrollments:manage" | "enrollments:read" | "environments:manage" | "environments:use" | "files:read" | "files:upload" | "files:write" | "github:manage" | "github:use" | "goals:manage" | "mcp_servers:attach" | "members:manage" | "rigs:manage" | "rigs:use" | "scheduled_tasks:manage" | "scheduled_tasks:run" | "secrets:list" | "secrets:read" | "secrets:write" | "sessions:control" | "sessions:create" | "sessions:read" | "stream:acknowledge" | "stream:control" | "stream:view" | "terminal:attach" | "variable-sets:attach" | "variable-sets:list" | "variable-sets:manage" | "variable-sets:read" | "variable-sets:use" | "variable-sets:write" | "workspace:admin" | "workspace:create" | "workspace:read")[];
31
+ permissions: ("account:admin" | "account:read" | "api_keys:manage" | "artifacts:publish" | "artifacts:read" | "billing:manage" | "billing:read" | "capabilities:manage" | "codemode:call" | "connections:read" | "connections:write" | "documents:manage" | "documents:search" | "enrollments:manage" | "enrollments:read" | "environments:manage" | "environments:use" | "files:read" | "files:upload" | "files:write" | "github:manage" | "github:use" | "goals:manage" | "mcp_servers:attach" | "members:manage" | "rigs:manage" | "rigs:use" | "scheduled_tasks:manage" | "scheduled_tasks:run" | "secrets:list" | "secrets:read" | "secrets:use" | "secrets:write" | "sessions:control" | "sessions:create" | "sessions:read" | "stream:acknowledge" | "stream:control" | "stream:view" | "terminal:attach" | "usage_allowances:manage" | "variable-sets:attach" | "variable-sets:list" | "variable-sets:manage" | "variable-sets:read" | "variable-sets:use" | "variable-sets:write" | "workspace:admin" | "workspace:create" | "workspace:read")[];
30
32
  narrowed: boolean;
31
33
  replay: boolean;
32
34
  }>;
@@ -0,0 +1,37 @@
1
+ import type { Settings } from "@opengeni/config";
2
+ import { ModalNativePreparationDeclarationV2 } from "@opengeni/contracts/modal-native-proof-v2";
3
+ import { type Database, type ModalNativeLiveOriginProjection, type ModalNativeLiveOriginResult } from "@opengeni/db";
4
+ import { type NativeOriginalConfigurationSample } from "./modal-native-original-configuration.js";
5
+ type JoinSettings = Pick<Settings, "delegationSecret" | "modalTokenId" | "modalTokenSecret" | "modalEnvironment" | "environmentsEncryptionKey">;
6
+ /** Sensitive request-local data only. Do not publish/log/cache across commit.
7
+ * The sample contains immutable credential strings which disposal cannot erase.
8
+ * This result has no native-I/O, replay, custody or effect authority. */
9
+ export type NativeLiveDeclarationJoin = Readonly<{
10
+ requestId: string;
11
+ declaration: ModalNativePreparationDeclarationV2;
12
+ projection: ModalNativeLiveOriginProjection;
13
+ configuration: NativeOriginalConfigurationSample;
14
+ }>;
15
+ export type NativeLiveDeclarationJoinResult = {
16
+ kind: "joined_data";
17
+ data: NativeLiveDeclarationJoin;
18
+ } | {
19
+ kind: "off";
20
+ } | {
21
+ kind: "refused";
22
+ } | Exclude<ModalNativeLiveOriginResult, {
23
+ kind: "live";
24
+ }>;
25
+ /** Own bytes BEFORE either verifying or parsing. After the blocking SQL join,
26
+ * re-read the explicit CURRENT deployment root/profile and reverify current
27
+ * expiry over those SAME owned bytes. A historical MAC witness is insufficient.
28
+ * No tenant/subject GUC change, general access-token resolver, provider await,
29
+ * fallback, registration or error-to-success conversion occurs here.
30
+ *
31
+ * Input execution/human fields are signed CORRELATION, not caller authority:
32
+ * compare them to the exact DB-derived accepted original projection. This does
33
+ * NOT independently prove that the canonical worker produced the request.
34
+ * Enter an existing scoped transaction before any tenancy/control/row lock;
35
+ * consume the result in that transaction and dispose its sample afterward. */
36
+ export declare function lockNativeLiveDeclarationJoinTx(scopedTx: Database, settings: JoinSettings, envelope: string, inputBody: Uint8Array): Promise<NativeLiveDeclarationJoinResult>;
37
+ export {};
@@ -0,0 +1,79 @@
1
+ import type { Settings } from "@opengeni/config";
2
+ import { ModalNativePreparationDeclarationV2 } from "@opengeni/contracts/modal-native-proof-v2";
3
+ declare const SUBKEY_DOMAIN = "opengeni:modal-native:configuration-equality:subkey:v2";
4
+ declare const MESSAGE_DOMAIN = "opengeni:modal-native:configuration-equality:framed:v2\0";
5
+ type ConfigurationSettings = Pick<Settings, "modalTokenId" | "modalTokenSecret" | "modalEnvironment" | "environmentsEncryptionKey">;
6
+ export type NativeOriginalConfigurationSnapshot = Readonly<{
7
+ serverUrl: string;
8
+ tokenId: string;
9
+ tokenSecret: string;
10
+ environment: string;
11
+ }>;
12
+ declare function readProfile(environment: string): Readonly<{
13
+ protocol: "modal-direct-original-read-grpc-v1";
14
+ version: 1;
15
+ sourceGitBlob: "7599f5b80cf111a25f78f427cfb2616d7e24b36c";
16
+ serverUrl: "https://api.modal.com:443";
17
+ serverSelection: "host-pinned-modal-0.9-default";
18
+ credentialSelection: "explicit-deployment-settings-pair-only";
19
+ environmentSelection: "explicit-own-settings-no-default";
20
+ environment: string;
21
+ environmentTransmittedByCpReads: false;
22
+ namespaceSelection: "unbound-until-authenticated-once-capture";
23
+ modalProjectionVersion: "0.9.0";
24
+ grpcJsVersion: "1.14.4";
25
+ protobufJsVersion: "7.6.5";
26
+ rpcPrefix: "/modal.client.ModalClient/";
27
+ methods: readonly ["AuthTokenGet", "WorkspaceNameLookup", "TaskGetCommandRouterAccess"];
28
+ authHeaders: {
29
+ readonly clientType: "8";
30
+ readonly clientVersion: "1.0.0";
31
+ readonly libmodalVersion: "modal-js/0.9.0";
32
+ };
33
+ tlsPolicy: "explicit-node-tls-rootCertificates-v1";
34
+ tlsRootsSha256: string;
35
+ retries: 0;
36
+ nativeChainDeadlineMs: 30000;
37
+ maxWireBytes: 1048576;
38
+ }>;
39
+ type PrivateDescription = Readonly<{
40
+ protocol: "opengeni-modal-native-configuration-equality";
41
+ version: 2;
42
+ purpose: "original-native-custody-proof";
43
+ configurationCaptureRef: ModalNativePreparationDeclarationV2["configurationCaptureRef"];
44
+ proofGrantRef: ModalNativePreparationDeclarationV2["proofGrantRef"];
45
+ declarationJson: string;
46
+ declarationSha256: string;
47
+ profile: ReturnType<typeof readProfile>;
48
+ keySelection: "existing-environments-encryption-root-current-only";
49
+ algorithm: "hmac-sha256";
50
+ subkeyDomain: typeof SUBKEY_DOMAIN;
51
+ messageDomain: typeof MESSAGE_DOMAIN;
52
+ }>;
53
+ /** Sensitive PRIVATE storage draft, not proof that any row or grant committed. */
54
+ export type NativeOriginalConfigurationDraftV2 = Readonly<{
55
+ description: PrivateDescription;
56
+ equality: Uint8Array;
57
+ }>;
58
+ declare const sampleBrand: unique symbol;
59
+ export type NativeOriginalConfigurationSample = Readonly<{
60
+ [sampleBrand]: true;
61
+ }>;
62
+ /** Samples ONLY explicit own settings, without environment/profile/SDK lookup.
63
+ * A parsed declaration merely supplies correlation. Genuine known app/image
64
+ * provenance and same-transaction host/grant/admission checks remain external.
65
+ */
66
+ export declare function sampleNativeOriginalConfiguration(settings: ConfigurationSettings, declarationBytes: Uint8Array): NativeOriginalConfigurationSample | null;
67
+ /** Private draft extraction for protected storage only; never a status DTO. */
68
+ export declare function privateNativeOriginalConfigurationDraft(sample: NativeOriginalConfigurationSample): NativeOriginalConfigurationDraftV2 | null;
69
+ /** Same sampled strings for a future authenticated native caller; NOT a grant. */
70
+ export declare function nativeOriginalConfigurationSnapshot(sample: NativeOriginalConfigurationSample): NativeOriginalConfigurationSnapshot | null;
71
+ /** PRIVATE equality check only. No public oracle, grant renewal or key fallback.
72
+ * Restart reconstruction still requires an authenticated protected original row.
73
+ */
74
+ export declare function currentNativeOriginalConfigurationMatches(sample: NativeOriginalConfigurationSample, settings: ConfigurationSettings): boolean;
75
+ /** Wipes owned mutable copies, not JS immutable strings or native I/O/custody.
76
+ * A future owning native caller must join its real callbacks separately.
77
+ */
78
+ export declare function disposeNativeOriginalConfigurationSample(sample: NativeOriginalConfigurationSample): void;
79
+ export {};