@opengeni/core 3.0.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/access/index.d.ts +131 -7
- package/dist/access/service-initiator.d.ts +3 -0
- package/dist/application/archived-session-imports.d.ts +6 -0
- package/dist/application/composer-submit.d.ts +1 -1
- package/dist/application/connect-operation.d.ts +6 -0
- package/dist/application/external-workspace-members.d.ts +13 -1
- package/dist/application/modal-native-live-declaration-join.d.ts +37 -0
- package/dist/application/modal-native-original-configuration.d.ts +79 -0
- package/dist/application/modal-native-worker-host-transport.d.ts +297 -0
- package/dist/application/new-session-drafts.d.ts +29 -2
- package/dist/application/organization-privacy.d.ts +57 -0
- package/dist/application/prepared-mcp-connection.d.ts +31 -0
- package/dist/application/sandbox-recovery.d.ts +58 -0
- package/dist/application/session-commands.d.ts +3 -0
- package/dist/application/session-tenancy.d.ts +13 -4
- package/dist/billing/agent-run-admission.d.ts +21 -0
- package/dist/billing/limits.d.ts +27 -1
- package/dist/billing/model-call-admission.d.ts +34 -0
- package/dist/billing/model-usage-settlement.d.ts +112 -0
- package/dist/canonical-human-identities.js +1 -1
- package/dist/{chunk-VCZFFEPB.js → chunk-7T2SZ7BI.js} +16 -2
- package/dist/chunk-7T2SZ7BI.js.map +1 -0
- package/dist/{chunk-ZYCNLYGH.js → chunk-OMJFIIWK.js} +178 -12
- package/dist/chunk-OMJFIIWK.js.map +1 -0
- package/dist/{chunk-H7X52RI2.js → chunk-QI2M2B2K.js} +83 -8
- package/dist/chunk-QI2M2B2K.js.map +1 -0
- package/dist/{chunk-OF65T3PM.js → chunk-TTWTXQB2.js} +94 -6
- package/dist/chunk-TTWTXQB2.js.map +1 -0
- package/dist/codex-model-availability.d.ts +55 -0
- package/dist/default-session-model.d.ts +192 -0
- package/dist/dependencies.d.ts +41 -7
- package/dist/developer-setup-credential-ceiling.d.ts +10 -0
- package/dist/domain/agent-config-resolution.d.ts +49 -0
- package/dist/domain/automations.d.ts +8 -1
- package/dist/domain/capabilities.d.ts +112 -8
- package/dist/domain/connection-account-selection-error.d.ts +8 -0
- package/dist/domain/connector-tool-permissions.d.ts +62 -0
- package/dist/domain/direct-model-provider.d.ts +3 -0
- package/dist/domain/editable-artifacts/agent-application.d.ts +10 -1
- package/dist/domain/editable-artifacts/durable-export.d.ts +22 -1
- package/dist/domain/editable-artifacts/ports.d.ts +10 -0
- package/dist/domain/editable-artifacts/service.d.ts +3 -1
- package/dist/domain/editable-artifacts/types.d.ts +1 -1
- package/dist/domain/encryption-key.d.ts +12 -0
- package/dist/domain/insights-timing.d.ts +16 -0
- package/dist/domain/insights-usage.d.ts +27 -0
- package/dist/domain/insights.d.ts +21 -3
- package/dist/domain/knowledge-files.d.ts +1 -1
- package/dist/domain/knowledge-preparation.d.ts +10 -0
- package/dist/domain/knowledge-preparation.test.d.ts +1 -0
- package/dist/domain/knowledge-search.d.ts +15 -76
- package/dist/domain/mcp-account-bindings.d.ts +17 -0
- package/dist/domain/mcp-account-routes.d.ts +21 -0
- package/dist/domain/native-mcp-connection-admission.d.ts +3 -0
- package/dist/domain/organization-integration-catalog.d.ts +15 -0
- package/dist/domain/personal-connection-delegations.d.ts +73 -12
- package/dist/domain/pr-review.d.ts +121 -6
- package/dist/domain/realtime-voice-billing.d.ts +103 -0
- package/dist/domain/resources.d.ts +17 -1
- package/dist/domain/scheduled-task-access.d.ts +265 -0
- package/dist/domain/scheduled-task-account-audit.d.ts +27 -0
- package/dist/domain/scheduled-task-audience.d.ts +70 -0
- package/dist/domain/scheduled-tasks.d.ts +61 -18
- package/dist/domain/session-connection-accounts.d.ts +53 -0
- package/dist/domain/session-file-access.d.ts +4 -0
- package/dist/domain/session-native-connection-replacement.d.ts +14 -0
- package/dist/domain/session-start-timing.d.ts +7 -0
- package/dist/domain/session-tool-policy.d.ts +102 -4
- package/dist/domain/sessions.d.ts +179 -15
- package/dist/domain/site-audience.d.ts +52 -0
- package/dist/domain/skills.d.ts +29 -1
- package/dist/domain/slack-bot.d.ts +46 -1
- package/dist/domain/slack-publication-secret-safety.d.ts +1 -1
- package/dist/domain/vaults/index.d.ts +7 -0
- package/dist/domain/vaults/mapping.d.ts +25 -0
- package/dist/domain/vaults/provider-registry.d.ts +72 -0
- package/dist/domain/vaults/provider-sync.d.ts +176 -0
- package/dist/domain/vaults/provider-writes.d.ts +57 -0
- package/dist/domain/vaults/secret-resolver.d.ts +34 -0
- package/dist/domain/vaults/types.d.ts +24 -0
- package/dist/domain/vaults/vault-service.d.ts +35 -0
- package/dist/domain/voice-input-billing.d.ts +77 -0
- package/dist/domain/web-search-billing.d.ts +51 -0
- package/dist/domain/workspace-credits.d.ts +7 -0
- package/dist/editable-artifact-live/application.d.ts +2 -1
- package/dist/editable-artifact-live/server.d.ts +5 -1
- package/dist/editable-artifact-live/ticket.d.ts +2 -1
- package/dist/editable-artifact-live/types.d.ts +9 -0
- package/dist/editable-artifact-live.js +2 -2
- package/dist/editable-artifacts.js +10 -2
- package/dist/goal-admission.d.ts +627 -0
- package/dist/host-session-usage-limit.d.ts +15 -0
- package/dist/index.d.ts +43 -8
- package/dist/index.js +22682 -11743
- package/dist/index.js.map +1 -1
- package/dist/managed-session.d.ts +110 -7
- package/dist/model-call.d.ts +58 -0
- package/dist/model-catalog.d.ts +29 -3
- package/dist/model-provider-credentials.d.ts +43 -0
- package/dist/product-usage-metrics.d.ts +30 -0
- package/dist/rigs/index.d.ts +1 -13
- package/dist/sandbox/fleet.d.ts +58 -4
- package/dist/sandbox/routing.d.ts +42 -2
- package/dist/sandbox/runtime-settings.d.ts +27 -17
- package/dist/session-authorization.d.ts +10 -0
- package/dist/session-usage-limit-metrics.d.ts +60 -0
- package/dist/session-usage-limits.d.ts +89 -0
- package/dist/site-agent-clamp.d.ts +71 -0
- package/dist/site-session-origin.d.ts +39 -2
- package/dist/transcription.d.ts +120 -3
- package/dist/turn-surface.d.ts +20 -0
- package/dist/user-presence.d.ts +32 -0
- package/dist/workflow-wake-contract.d.ts +13 -1
- package/package.json +15 -22
- package/src/access/index.ts +961 -38
- package/src/access/service-initiator.ts +50 -0
- package/src/application/api-integration-servers.ts +9 -0
- package/src/application/archived-session-imports.ts +161 -0
- package/src/application/composer-submit.ts +3 -2
- package/src/application/connect-authority.ts +3 -3
- package/src/application/connect-operation.ts +37 -3
- package/src/application/external-continuation.ts +20 -3
- package/src/application/external-link-work-admission.ts +3 -0
- package/src/application/external-workspace-members.ts +51 -3
- package/src/application/modal-native-live-declaration-join.ts +196 -0
- package/src/application/modal-native-original-configuration.ts +261 -0
- package/src/application/modal-native-worker-host-transport.ts +263 -0
- package/src/application/new-session-drafts.ts +172 -55
- package/src/application/organization-privacy.ts +161 -0
- package/src/application/prepared-mcp-connection.ts +133 -0
- package/src/application/sandbox-recovery.ts +78 -0
- package/src/application/session-commands.ts +73 -1
- package/src/application/session-mcp-credential-rotation.ts +61 -18
- package/src/application/session-tenancy.ts +262 -44
- package/src/application/user-resource-grants.ts +1 -29
- package/src/billing/agent-run-admission.ts +117 -0
- package/src/billing/limits.ts +138 -14
- package/src/billing/model-call-admission.ts +118 -0
- package/src/billing/model-usage-settlement.ts +472 -0
- package/src/codex-model-availability.ts +264 -0
- package/src/default-session-model.ts +692 -0
- package/src/dependencies.ts +48 -6
- package/src/developer-setup-credential-ceiling.ts +60 -0
- package/src/domain/agent-config-resolution.ts +148 -0
- package/src/domain/automations.ts +76 -2
- package/src/domain/capabilities.ts +830 -181
- package/src/domain/connection-account-selection-error.ts +19 -0
- package/src/domain/connector-tool-permissions.ts +572 -0
- package/src/domain/direct-model-provider.ts +62 -0
- package/src/domain/editable-artifacts/agent-application.ts +44 -6
- package/src/domain/editable-artifacts/durable-export.ts +100 -5
- package/src/domain/editable-artifacts/in-memory.ts +6 -0
- package/src/domain/editable-artifacts/ports.ts +11 -0
- package/src/domain/editable-artifacts/service.ts +20 -0
- package/src/domain/editable-artifacts/types.ts +1 -1
- package/src/domain/encryption-key.ts +26 -0
- package/src/domain/file-owner.ts +16 -1
- package/src/domain/github-action-policies.ts +1 -1
- package/src/domain/github-skill-source.ts +3 -1
- package/src/domain/insights-timing.ts +95 -0
- package/src/domain/insights-usage.ts +67 -0
- package/src/domain/insights.ts +167 -43
- package/src/domain/knowledge-files.ts +10 -3
- package/src/domain/knowledge-messages.ts +1 -0
- package/src/domain/knowledge-preparation.test.ts +276 -0
- package/src/domain/knowledge-preparation.ts +147 -0
- package/src/domain/knowledge-search.test.ts +617 -5
- package/src/domain/knowledge-search.ts +240 -23
- package/src/domain/mcp-account-bindings.ts +169 -0
- package/src/domain/mcp-account-routes.ts +152 -0
- package/src/domain/native-mcp-connection-admission.ts +14 -0
- package/src/domain/organization-integration-catalog.ts +88 -0
- package/src/domain/personal-connection-delegations.ts +399 -257
- package/src/domain/pr-review.ts +24 -8
- package/src/domain/realtime-voice-billing.ts +425 -0
- package/src/domain/resources.ts +50 -4
- package/src/domain/scheduled-task-access.ts +1089 -0
- package/src/domain/scheduled-task-account-audit.ts +90 -0
- package/src/domain/scheduled-task-audience.ts +249 -0
- package/src/domain/scheduled-tasks.ts +1313 -374
- package/src/domain/session-connection-accounts.ts +239 -0
- package/src/domain/session-file-access.ts +47 -0
- package/src/domain/session-native-connection-replacement.ts +64 -0
- package/src/domain/session-start-timing.ts +60 -0
- package/src/domain/session-tool-policy.ts +489 -14
- package/src/domain/sessions.ts +2254 -717
- package/src/domain/site-audience.ts +130 -0
- package/src/domain/skills.ts +9 -0
- package/src/domain/slack-bot.ts +141 -4
- package/src/domain/slack-publication-secret-safety.ts +1 -1
- package/src/domain/vaults/index.ts +19 -0
- package/src/domain/vaults/mapping.ts +190 -0
- package/src/domain/vaults/provider-registry.ts +201 -0
- package/src/domain/vaults/provider-sync.ts +531 -0
- package/src/domain/vaults/provider-writes.ts +288 -0
- package/src/domain/vaults/secret-resolver.ts +464 -0
- package/src/domain/vaults/types.ts +26 -0
- package/src/domain/vaults/vault-service.ts +1316 -0
- package/src/domain/voice-input-billing.ts +330 -0
- package/src/domain/web-search-billing.ts +169 -0
- package/src/domain/workspace-credits.ts +13 -0
- package/src/editable-artifact-live/application.ts +8 -1
- package/src/editable-artifact-live/server.ts +154 -6
- package/src/editable-artifact-live/ticket.ts +86 -1
- package/src/editable-artifact-live/types.ts +10 -0
- package/src/goal-admission.ts +220 -0
- package/src/host-session-usage-limit.ts +25 -0
- package/src/index.ts +75 -11
- package/src/managed-session.ts +137 -6
- package/src/model-call.ts +79 -0
- package/src/model-catalog.ts +345 -91
- package/src/model-provider-credentials.ts +394 -0
- package/src/product-usage-metrics.ts +101 -0
- package/src/rigs/index.ts +23 -111
- package/src/sandbox/fleet.ts +253 -28
- package/src/sandbox/routing.ts +204 -43
- package/src/sandbox/runtime-settings.ts +159 -85
- package/src/session-authorization.ts +172 -23
- package/src/session-usage-limit-metrics.ts +95 -0
- package/src/session-usage-limits.ts +415 -0
- package/src/site-agent-clamp.ts +226 -0
- package/src/site-session-origin.ts +84 -5
- package/src/transcription.ts +123 -4
- package/src/turn-surface.ts +47 -0
- package/src/user-presence.ts +134 -0
- package/src/workflow-wake-contract.ts +14 -1
- package/dist/application/host-mcp-owner.d.ts +0 -6
- package/dist/application/host-mcp-resolvers.d.ts +0 -13
- package/dist/chunk-5WZYFL45.js +0 -266
- package/dist/chunk-5WZYFL45.js.map +0 -1
- package/dist/chunk-H7X52RI2.js.map +0 -1
- package/dist/chunk-OF65T3PM.js.map +0 -1
- package/dist/chunk-VCZFFEPB.js.map +0 -1
- package/dist/chunk-ZYCNLYGH.js.map +0 -1
- package/dist/domain/connection-authority.d.ts +0 -97
- package/dist/domain/connection-authority.js +0 -169
- package/dist/domain/connection-authority.js.map +0 -1
- package/dist/domain/environments.d.ts +0 -33
- package/dist/domain/host-mcp-authority-source-admission.d.ts +0 -10
- package/dist/domain/host-mcp-task-admission.d.ts +0 -18
- package/dist/domain/packs.d.ts +0 -59
- package/dist/domain/product-integration-pack.d.ts +0 -44
- package/dist/domain/product-integration-skill.gen.d.ts +0 -5
- package/dist/remote-mcp-credentials.d.ts +0 -23
- package/dist/remote-mcp-credentials.js +0 -11
- package/dist/remote-mcp-credentials.js.map +0 -1
- package/src/application/host-mcp-owner.ts +0 -41
- package/src/application/host-mcp-resolvers.ts +0 -84
- package/src/domain/connection-authority.ts +0 -329
- package/src/domain/environments.ts +0 -120
- package/src/domain/host-mcp-authority-source-admission.ts +0 -25
- package/src/domain/host-mcp-task-admission.ts +0 -121
- package/src/domain/packs.ts +0 -699
- package/src/domain/product-integration-pack.ts +0 -42
- package/src/domain/product-integration-skill.gen.ts +0 -52
- package/src/remote-mcp-credentials.ts +0 -361
package/src/dependencies.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Settings } from "@opengeni/config";
|
|
2
2
|
import type {
|
|
3
|
-
ConnectionCredentialsPort,
|
|
4
3
|
Document,
|
|
5
4
|
DocumentAuthorityKind,
|
|
5
|
+
EntitlementsPort,
|
|
6
6
|
GitHubAppApiPort,
|
|
7
7
|
ScheduledTask,
|
|
8
8
|
ScheduledTaskTriggerType,
|
|
@@ -10,14 +10,18 @@ import type {
|
|
|
10
10
|
TurnInitiator,
|
|
11
11
|
} from "@opengeni/contracts";
|
|
12
12
|
import type { Database, SessionWorkflowWakeDeliveryResult } from "@opengeni/db";
|
|
13
|
+
import type { VaultConnectionCredentialsPort } from "@opengeni/vaults";
|
|
14
|
+
import type { OnePasswordVaultProviderFactory } from "./domain/vaults/provider-registry";
|
|
13
15
|
import type { DocumentServices } from "@opengeni/documents";
|
|
14
16
|
import type { EventBus } from "@opengeni/events";
|
|
15
17
|
import type { Observability } from "@opengeni/observability";
|
|
18
|
+
import type { UserPresenceRecorder } from "./user-presence";
|
|
16
19
|
import type { createObjectStorage } from "@opengeni/storage";
|
|
17
20
|
import type { ManagedAuth } from "./managed-auth-type";
|
|
18
21
|
import type { ManagedAuthSessionAdapter } from "./managed-auth-session-sets";
|
|
19
22
|
import type { ApiSandboxClient, ResumeBoxByIdInput, ResumedSandboxSession } from "./sandbox-types";
|
|
20
23
|
import type { TranscriptionSegmenter, TranscriptionService } from "./transcription";
|
|
24
|
+
import type { ModelCallService } from "./model-call";
|
|
21
25
|
import type { EditableArtifactApplicationPort } from "./editable-artifact-live";
|
|
22
26
|
import type { ResolvedCatalogSettings } from "./model-catalog";
|
|
23
27
|
import type {
|
|
@@ -68,13 +72,23 @@ export type SessionWorkflowClient = {
|
|
|
68
72
|
workflowId: string;
|
|
69
73
|
workflowWakeRevision: number;
|
|
70
74
|
}) => Promise<void>;
|
|
71
|
-
syncScheduledTask: (input: {
|
|
75
|
+
syncScheduledTask: (input: {
|
|
76
|
+
task: Pick<ScheduledTask, "id" | "workspaceId" | "temporalScheduleId">;
|
|
77
|
+
/**
|
|
78
|
+
* Compensate under the same per-schedule writer lock. Return the error to
|
|
79
|
+
* throw only after this transaction commits; lock/commit failures bypass
|
|
80
|
+
* that receipt. A failing compensation must roll back its own savepoint.
|
|
81
|
+
*/
|
|
82
|
+
onFailure?: (tx: Database, error: unknown) => Promise<Error>;
|
|
83
|
+
}) => Promise<void>;
|
|
72
84
|
deleteScheduledTaskSchedule: (input: { temporalScheduleId: string }) => Promise<void>;
|
|
73
85
|
triggerScheduledTask: (input: {
|
|
74
86
|
task: ScheduledTask;
|
|
75
87
|
agentRunUsageIdempotencyKey: string;
|
|
76
88
|
triggerWorkflowId: string;
|
|
77
89
|
initiator: TurnInitiator;
|
|
90
|
+
/** Server-frozen caller ceiling for this run, independent of task ownership. */
|
|
91
|
+
credentialRestriction?: "developer_setup";
|
|
78
92
|
triggerType?: Extract<
|
|
79
93
|
ScheduledTaskTriggerType,
|
|
80
94
|
"manual" | "initial" | "provider_event" | "retry" | "repair"
|
|
@@ -101,7 +115,12 @@ export type DocumentIndexClient = {
|
|
|
101
115
|
};
|
|
102
116
|
|
|
103
117
|
export type ManagedEmailMessage = {
|
|
104
|
-
kind:
|
|
118
|
+
kind:
|
|
119
|
+
| "email_verification"
|
|
120
|
+
| "password_reset"
|
|
121
|
+
| "organization_user_setup"
|
|
122
|
+
| "sign_in_method_changed"
|
|
123
|
+
| "site_abuse_notice";
|
|
105
124
|
from: string;
|
|
106
125
|
to: string;
|
|
107
126
|
subject: string;
|
|
@@ -140,6 +159,8 @@ export type AppDependencies = {
|
|
|
140
159
|
*/
|
|
141
160
|
catalogSourceSettings?: Settings;
|
|
142
161
|
db: Database;
|
|
162
|
+
/** Read-only host funding admission; unset uses the standalone billing ledger. */
|
|
163
|
+
entitlements?: EntitlementsPort | null;
|
|
143
164
|
/**
|
|
144
165
|
* Host-composed editable artifact engine. Standalone startup binds the same
|
|
145
166
|
* native kernel/DB/object-store implementation; embedded hosts may inject an
|
|
@@ -165,6 +186,11 @@ export type AppDependencies = {
|
|
|
165
186
|
documentIndexer?: DocumentIndexClient;
|
|
166
187
|
documentServices?: DocumentServices;
|
|
167
188
|
observability?: Observability;
|
|
189
|
+
/**
|
|
190
|
+
* Throttled server-side presence for canonical managed browser sessions
|
|
191
|
+
* (`createUserPresenceRecorder`). Analytics only; never an authorization input.
|
|
192
|
+
*/
|
|
193
|
+
userPresence?: UserPresenceRecorder | null;
|
|
168
194
|
readinessChecks?: Partial<Record<"db" | "nats" | "temporal", () => Promise<void> | void>>;
|
|
169
195
|
githubStateSecret?: string;
|
|
170
196
|
/**
|
|
@@ -173,14 +199,21 @@ export type AppDependencies = {
|
|
|
173
199
|
* App credentials; standalone deployments fall back to @opengeni/github.
|
|
174
200
|
*/
|
|
175
201
|
githubAppApi?: GitHubAppApiPort;
|
|
176
|
-
/** Optional provider seam for the separately registered
|
|
202
|
+
/** Optional provider seam for the separately registered Opengeni Lens App. */
|
|
177
203
|
prReviewGithubAppApi?: GitHubAppApiPort;
|
|
178
204
|
/**
|
|
179
205
|
* Optional host-owned connection credential seam. API-side consumers use
|
|
180
206
|
* the MCP leg for Codemode/Code Mode; worker consumers bind the same port
|
|
181
|
-
* for model MCP, Git, and
|
|
207
|
+
* for model MCP, Git, and run credentials. `vaultProvider` is the host's
|
|
208
|
+
* password manager, linked as vaults with `source: "host"` (OP-6).
|
|
209
|
+
*/
|
|
210
|
+
connectionCredentials?: VaultConnectionCredentialsPort | null;
|
|
211
|
+
/**
|
|
212
|
+
* Builds 1Password providers for linked vaults. apps/api and apps/worker
|
|
213
|
+
* bind it to a dynamic `import("@opengeni/vaults-onepassword")`; unset means
|
|
214
|
+
* 1Password vaults report `provider_unavailable`.
|
|
182
215
|
*/
|
|
183
|
-
|
|
216
|
+
onePasswordVaultProvider?: OnePasswordVaultProviderFactory | null;
|
|
184
217
|
/**
|
|
185
218
|
* Optional embedding-host session ACL. Unset preserves standalone workspace
|
|
186
219
|
* authorization; once bound, every session-addressed surface fails closed on
|
|
@@ -194,12 +227,16 @@ export type AppDependencies = {
|
|
|
194
227
|
managedEmailTransport?: ManagedEmailTransport;
|
|
195
228
|
/** Injectable Codex HTTP transport for deterministic API/provider tests. */
|
|
196
229
|
codexFetch?: typeof fetch;
|
|
230
|
+
/** Injectable transport for customer OpenAI/Azure connection checks. */
|
|
231
|
+
directModelFetch?: typeof fetch;
|
|
197
232
|
/** Injectable GitHub transport for deterministic personal-OAuth tests. */
|
|
198
233
|
githubPersonalFetch?: typeof fetch;
|
|
199
234
|
/** Injectable credential-free GitHub transport for public repository verification tests. */
|
|
200
235
|
githubAnonymousFetch?: typeof fetch;
|
|
201
236
|
/** Injectable xAI OAuth/subscription transport for deterministic API/provider tests. */
|
|
202
237
|
xaiFetch?: typeof fetch;
|
|
238
|
+
/** Injectable Claude usage transport on the shared core, for deterministic API tests. */
|
|
239
|
+
claudeFetch?: typeof fetch;
|
|
203
240
|
/** Injectable Slack Web API transport for deterministic bot-connection tests. */
|
|
204
241
|
slackFetch?: typeof fetch;
|
|
205
242
|
/** Injectable Google OAuth/Drive transport for deterministic connector tests. */
|
|
@@ -210,6 +247,8 @@ export type AppDependencies = {
|
|
|
210
247
|
apiIntegrationOAuthFetch?: typeof fetch;
|
|
211
248
|
/** Injectable specification/introspection transport, still network-policy checked. */
|
|
212
249
|
apiIntegrationSourceFetch?: typeof fetch;
|
|
250
|
+
/** Injectable bounded MCP initialization/tools-list probe for Connect tests. */
|
|
251
|
+
mcpCapabilityProbe?: import("./domain/capabilities").McpCapabilityProbe;
|
|
213
252
|
atlassianFetch?: typeof fetch;
|
|
214
253
|
/** Injectable MCP OAuth setup deadline for deterministic stalled-provider tests. */
|
|
215
254
|
oauthStartDeadlineMs?: number;
|
|
@@ -219,6 +258,8 @@ export type AppDependencies = {
|
|
|
219
258
|
transcription?: TranscriptionService | null;
|
|
220
259
|
/** Optional host-owned long-form audio normalization/segmentation service. */
|
|
221
260
|
transcriptionSegmenter?: TranscriptionSegmenter | null;
|
|
261
|
+
/** Stateless single model calls (chat completions); built from settings when omitted. */
|
|
262
|
+
modelCalls?: ModelCallService | null;
|
|
222
263
|
// The API process's OWN agent-loop-free sandbox client (constructed from
|
|
223
264
|
// settings via @opengeni/runtime/sandbox). Undefined when sandboxBackend=none.
|
|
224
265
|
// This is the foundation of the API-direct control plane: the API resumes
|
|
@@ -265,6 +306,7 @@ export type AcceptSessionUserMessageDependencies = Pick<
|
|
|
265
306
|
| "bus"
|
|
266
307
|
| "sessionAuthorization"
|
|
267
308
|
| "schedulePromptPostCommit"
|
|
309
|
+
| "observability"
|
|
268
310
|
> & {
|
|
269
311
|
workflowClient: Pick<SessionWorkflowClient, "wakeSessionWorkflow">;
|
|
270
312
|
objectStorage: ObjectStorageDependency;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readTurnExecutionPolicyV1,
|
|
3
|
+
type AccessGrant,
|
|
4
|
+
type Permission,
|
|
5
|
+
type TurnExecutionPolicyV1,
|
|
6
|
+
} from "@opengeni/contracts";
|
|
7
|
+
import { HTTPException } from "hono/http-exception";
|
|
8
|
+
import {
|
|
9
|
+
isDeveloperSetupAuthorization,
|
|
10
|
+
isDeveloperSetupGrant,
|
|
11
|
+
isDeveloperSetupDelegatedPermissionAllowed,
|
|
12
|
+
type AccessGrantAuthorization,
|
|
13
|
+
} from "./access";
|
|
14
|
+
|
|
15
|
+
/** The policy must be server-frozen, never supplied as request metadata. */
|
|
16
|
+
export function requireDeveloperSetupDelegatedPermissions(
|
|
17
|
+
policy: TurnExecutionPolicyV1,
|
|
18
|
+
permissions: readonly Permission[] | undefined,
|
|
19
|
+
): void {
|
|
20
|
+
if (policy.credentialRestriction !== "developer_setup") return;
|
|
21
|
+
const forbidden = permissions?.find(
|
|
22
|
+
(permission) => !isDeveloperSetupDelegatedPermissionAllowed(permission),
|
|
23
|
+
);
|
|
24
|
+
if (forbidden) {
|
|
25
|
+
throw new HTTPException(403, {
|
|
26
|
+
message: `Developer setup cannot delegate first-party MCP permission: ${forbidden}`,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Only pass server-owned persisted session/turn metadata, never request JSON. */
|
|
32
|
+
export function withDeveloperSetupCredentialRestriction(
|
|
33
|
+
policy: TurnExecutionPolicyV1,
|
|
34
|
+
source: {
|
|
35
|
+
grant?: AccessGrant;
|
|
36
|
+
authorization?: AccessGrantAuthorization | undefined;
|
|
37
|
+
trustedMetadata?: readonly unknown[];
|
|
38
|
+
},
|
|
39
|
+
): TurnExecutionPolicyV1 {
|
|
40
|
+
let restricted =
|
|
41
|
+
policy.credentialRestriction === "developer_setup" ||
|
|
42
|
+
isDeveloperSetupAuthorization(source.authorization) ||
|
|
43
|
+
(source.grant !== undefined && isDeveloperSetupGrant(source.grant));
|
|
44
|
+
for (const metadata of source.trustedMetadata ?? []) {
|
|
45
|
+
if (metadata === null || metadata === undefined) continue;
|
|
46
|
+
let inherited: ReturnType<typeof readTurnExecutionPolicyV1>;
|
|
47
|
+
try {
|
|
48
|
+
inherited = readTurnExecutionPolicyV1(metadata);
|
|
49
|
+
} catch {
|
|
50
|
+
throw new HTTPException(409, { message: "The frozen session credential ceiling is invalid" });
|
|
51
|
+
}
|
|
52
|
+
if (
|
|
53
|
+
inherited.kind === "valid" &&
|
|
54
|
+
inherited.policy.credentialRestriction === "developer_setup"
|
|
55
|
+
) {
|
|
56
|
+
restricted = true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return restricted ? { ...policy, credentialRestriction: "developer_setup" } : policy;
|
|
60
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import {
|
|
2
|
+
agentConfigDeploymentPolicy,
|
|
3
|
+
resolveSessionFirstPartyMcpTools,
|
|
4
|
+
type Settings,
|
|
5
|
+
} from "@opengeni/config";
|
|
6
|
+
import {
|
|
7
|
+
AgentConfigError,
|
|
8
|
+
agentConfigFirstPartyMcpTools,
|
|
9
|
+
agentConfigToolRefs,
|
|
10
|
+
legacyEffectiveAgentCapabilities,
|
|
11
|
+
resolveAgentConfig,
|
|
12
|
+
resolveWorkspaceAgentDefaults,
|
|
13
|
+
resolveWorkspaceAgentHumanInputEnabled,
|
|
14
|
+
type AgentConfigCreator,
|
|
15
|
+
type AgentConfigParent,
|
|
16
|
+
type AgentConfigRequest,
|
|
17
|
+
type FirstPartyMcpToolName,
|
|
18
|
+
type ResolvedAgentCapabilities,
|
|
19
|
+
type ResolvedAgentConfig,
|
|
20
|
+
type Session,
|
|
21
|
+
type SessionToolPolicy,
|
|
22
|
+
type ToolRef,
|
|
23
|
+
} from "@opengeni/contracts";
|
|
24
|
+
import { HTTPException } from "hono/http-exception";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Run an agent-config resolution step and surface its typed failure as a 422
|
|
28
|
+
* whose `cause` keeps the `AgentConfigError` (the API renders its code as
|
|
29
|
+
* `details.code`; MCP and Slack keep the plain message).
|
|
30
|
+
*/
|
|
31
|
+
export function withAgentConfigHttpErrors<T>(fn: () => T): T {
|
|
32
|
+
try {
|
|
33
|
+
return fn();
|
|
34
|
+
} catch (error) {
|
|
35
|
+
if (error instanceof AgentConfigError) {
|
|
36
|
+
throw new HTTPException(422, { message: error.message, cause: error });
|
|
37
|
+
}
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The current effective capabilities of a null-config session (the conversion/child ceiling). */
|
|
43
|
+
export function legacySessionAgentCapabilities(
|
|
44
|
+
settings: Settings,
|
|
45
|
+
session: Pick<Session, "firstPartyMcpTools" | "tools" | "toolPolicy">,
|
|
46
|
+
workspaceSettings: unknown,
|
|
47
|
+
/** The workspace's current omitted-tools default server ids, when known. */
|
|
48
|
+
defaultServerIds?: Iterable<string>,
|
|
49
|
+
): ResolvedAgentCapabilities {
|
|
50
|
+
return legacyEffectiveAgentCapabilities({
|
|
51
|
+
firstPartyMcpTools: resolveSessionFirstPartyMcpTools(settings, session, workspaceSettings),
|
|
52
|
+
tools: session.tools,
|
|
53
|
+
toolPolicy: session.toolPolicy,
|
|
54
|
+
humanInputEnabled: resolveWorkspaceAgentHumanInputEnabled(workspaceSettings),
|
|
55
|
+
...(defaultServerIds ? { defaultServerIds } : {}),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** A parent session as a resolution input: its frozen config, or its legacy ceiling. */
|
|
60
|
+
export function agentConfigParentFor(
|
|
61
|
+
settings: Settings,
|
|
62
|
+
parent: Session,
|
|
63
|
+
workspaceSettings: unknown,
|
|
64
|
+
): AgentConfigParent {
|
|
65
|
+
return parent.agent
|
|
66
|
+
? { kind: "configured", config: parent.agent }
|
|
67
|
+
: {
|
|
68
|
+
kind: "legacy",
|
|
69
|
+
ceiling: legacySessionAgentCapabilities(settings, parent, workspaceSettings),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Resolve the frozen agent configuration for a new session. Every creator
|
|
75
|
+
* calls this: `createSessionForRequest` (public API, MCP `session_create`,
|
|
76
|
+
* Slack, drafts), automations, and the scheduled worker. Returns `config:
|
|
77
|
+
* null` for exact legacy behavior.
|
|
78
|
+
*/
|
|
79
|
+
export function resolveSessionAgentConfigForCreate(input: {
|
|
80
|
+
settings: Settings;
|
|
81
|
+
creator: AgentConfigCreator;
|
|
82
|
+
request: AgentConfigRequest | undefined;
|
|
83
|
+
instructions: string | undefined;
|
|
84
|
+
workspaceSettings: unknown;
|
|
85
|
+
parent: Session | null;
|
|
86
|
+
goal: boolean;
|
|
87
|
+
}): { config: ResolvedAgentConfig | null; instructions: string | undefined } {
|
|
88
|
+
return withAgentConfigHttpErrors(() =>
|
|
89
|
+
resolveAgentConfig({
|
|
90
|
+
creator: input.creator,
|
|
91
|
+
request: input.request,
|
|
92
|
+
instructions: input.instructions,
|
|
93
|
+
workspace: {
|
|
94
|
+
defaults: resolveWorkspaceAgentDefaults(input.workspaceSettings),
|
|
95
|
+
humanInputEnabled: resolveWorkspaceAgentHumanInputEnabled(input.workspaceSettings),
|
|
96
|
+
},
|
|
97
|
+
deployment: agentConfigDeploymentPolicy(input.settings),
|
|
98
|
+
...(input.parent
|
|
99
|
+
? {
|
|
100
|
+
parent: agentConfigParentFor(input.settings, input.parent, input.workspaceSettings),
|
|
101
|
+
}
|
|
102
|
+
: {}),
|
|
103
|
+
goal: input.goal,
|
|
104
|
+
}),
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Write a resolved configuration through to the legacy columns the runtime
|
|
110
|
+
* reads today. `null` returns the inputs unchanged; `"all"` also does.
|
|
111
|
+
*/
|
|
112
|
+
export function applySessionAgentConfigWriteThrough(input: {
|
|
113
|
+
config: ResolvedAgentConfig | null;
|
|
114
|
+
firstPartyMcpTools: FirstPartyMcpToolName[];
|
|
115
|
+
explicitFirstPartyMcpTools?: readonly FirstPartyMcpToolName[] | undefined;
|
|
116
|
+
tools: ToolRef[];
|
|
117
|
+
toolPolicy: SessionToolPolicy;
|
|
118
|
+
productServerIds: Iterable<string>;
|
|
119
|
+
explicitServerIds?: Iterable<string> | undefined;
|
|
120
|
+
}): {
|
|
121
|
+
firstPartyMcpTools: FirstPartyMcpToolName[];
|
|
122
|
+
tools: ToolRef[];
|
|
123
|
+
toolPolicy: SessionToolPolicy;
|
|
124
|
+
} {
|
|
125
|
+
const { config } = input;
|
|
126
|
+
if (!config) {
|
|
127
|
+
return {
|
|
128
|
+
firstPartyMcpTools: input.firstPartyMcpTools,
|
|
129
|
+
tools: input.tools,
|
|
130
|
+
toolPolicy: input.toolPolicy,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return withAgentConfigHttpErrors(() => {
|
|
134
|
+
const firstPartyMcpTools = agentConfigFirstPartyMcpTools(
|
|
135
|
+
config,
|
|
136
|
+
input.firstPartyMcpTools,
|
|
137
|
+
input.explicitFirstPartyMcpTools,
|
|
138
|
+
);
|
|
139
|
+
const refs = agentConfigToolRefs({
|
|
140
|
+
config,
|
|
141
|
+
tools: input.tools,
|
|
142
|
+
toolPolicy: input.toolPolicy,
|
|
143
|
+
productServerIds: new Set(input.productServerIds),
|
|
144
|
+
...(input.explicitServerIds ? { explicitServerIds: new Set(input.explicitServerIds) } : {}),
|
|
145
|
+
});
|
|
146
|
+
return { firstPartyMcpTools, tools: refs.tools, toolPolicy: refs.toolPolicy };
|
|
147
|
+
});
|
|
148
|
+
}
|
|
@@ -4,12 +4,71 @@ import {
|
|
|
4
4
|
AutomationNormalizedEvent,
|
|
5
5
|
AutomationSessionTemplate,
|
|
6
6
|
SignedJsonAutomationEnvelope,
|
|
7
|
+
readTurnExecutionPolicyV1,
|
|
8
|
+
type AccessGrant,
|
|
9
|
+
type Permission,
|
|
7
10
|
type AutomationAdapterId,
|
|
8
11
|
type AutomationSource,
|
|
9
12
|
type AutomationTrigger,
|
|
10
13
|
} from "@opengeni/contracts";
|
|
14
|
+
import { getSession, getSessionTurnForAttempt, type Database } from "@opengeni/db";
|
|
15
|
+
import { HTTPException } from "hono/http-exception";
|
|
16
|
+
import { isDeveloperSetupGrant, isDeveloperSetupDelegatedPermissionAllowed } from "../access";
|
|
17
|
+
import { creationInitiatorForGrant } from "./sessions";
|
|
11
18
|
import { prReviewAutomationAdapter } from "./pr-review";
|
|
12
19
|
|
|
20
|
+
/** Canonical authenticated grant or exact server-owned originating policy only. */
|
|
21
|
+
export async function automationCredentialRestrictionForGrant(
|
|
22
|
+
db: Database,
|
|
23
|
+
grant: AccessGrant,
|
|
24
|
+
): Promise<AutomationSessionTemplate["credentialRestriction"]> {
|
|
25
|
+
if (isDeveloperSetupGrant(grant)) return "developer_setup";
|
|
26
|
+
const actor = creationInitiatorForGrant(grant).actor;
|
|
27
|
+
if (!actor) return undefined;
|
|
28
|
+
const turn = await getSessionTurnForAttempt(
|
|
29
|
+
db,
|
|
30
|
+
grant.workspaceId,
|
|
31
|
+
actor.sessionId,
|
|
32
|
+
actor.attemptId,
|
|
33
|
+
);
|
|
34
|
+
const session = await getSession(db, grant.workspaceId, actor.sessionId);
|
|
35
|
+
if (!turn || turn.id !== actor.turnId || !session || session.accountId !== grant.accountId) {
|
|
36
|
+
throw new HTTPException(403, {
|
|
37
|
+
message: "the creating automation agent attempt is not available",
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
for (const metadata of [turn.metadata, session.metadata]) {
|
|
41
|
+
let policy: ReturnType<typeof readTurnExecutionPolicyV1>;
|
|
42
|
+
try {
|
|
43
|
+
policy = readTurnExecutionPolicyV1(metadata);
|
|
44
|
+
} catch {
|
|
45
|
+
throw new HTTPException(409, {
|
|
46
|
+
message: "The frozen automation creator credential ceiling is invalid",
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if (policy.kind === "valid" && policy.policy.credentialRestriction === "developer_setup") {
|
|
50
|
+
return "developer_setup";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Explicit delegated scopes must stay within the frozen setup ceiling. */
|
|
57
|
+
export function requireAutomationCredentialRestrictionPermissions(
|
|
58
|
+
restriction: AutomationSessionTemplate["credentialRestriction"],
|
|
59
|
+
permissions: readonly Permission[],
|
|
60
|
+
): void {
|
|
61
|
+
if (restriction !== "developer_setup") return;
|
|
62
|
+
const forbidden = permissions.find(
|
|
63
|
+
(permission) => !isDeveloperSetupDelegatedPermissionAllowed(permission),
|
|
64
|
+
);
|
|
65
|
+
if (forbidden) {
|
|
66
|
+
throw new HTTPException(403, {
|
|
67
|
+
message: `Developer setup cannot delegate automation permission: ${forbidden}`,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
13
72
|
export type AutomationAdapterRenderResult = {
|
|
14
73
|
initialMessage: string;
|
|
15
74
|
sessionTemplate: AutomationSessionTemplate;
|
|
@@ -147,7 +206,19 @@ export function buildAutomationAcceptedExecution(input: {
|
|
|
147
206
|
eventId: string;
|
|
148
207
|
event: AutomationNormalizedEvent;
|
|
149
208
|
render: AutomationAdapterRenderResult;
|
|
209
|
+
/** Trusted caller restriction from the immutable stored event, not adapter JSON. */
|
|
210
|
+
credentialRestriction?: "developer_setup";
|
|
150
211
|
}): AutomationAcceptedExecution {
|
|
212
|
+
// Adapter output is a rendering, not authority. Reattach the immutable
|
|
213
|
+
// trigger/event marker even if an adapter rebuilds or strips its template.
|
|
214
|
+
const { credentialRestriction: _renderRestriction, ...renderTemplate } =
|
|
215
|
+
AutomationSessionTemplate.parse(input.render.sessionTemplate);
|
|
216
|
+
const credentialRestriction =
|
|
217
|
+
input.trigger.sessionTemplate.credentialRestriction ?? input.credentialRestriction;
|
|
218
|
+
requireAutomationCredentialRestrictionPermissions(
|
|
219
|
+
credentialRestriction,
|
|
220
|
+
renderTemplate.firstPartyMcpPermissions,
|
|
221
|
+
);
|
|
151
222
|
return AutomationAcceptedExecution.parse({
|
|
152
223
|
version: 1,
|
|
153
224
|
accountId: input.accountId,
|
|
@@ -160,9 +231,12 @@ export function buildAutomationAcceptedExecution(input: {
|
|
|
160
231
|
adapterId: input.event.adapterId,
|
|
161
232
|
occurrenceKey: input.event.occurrenceKey,
|
|
162
233
|
initialMessage: input.render.initialMessage,
|
|
163
|
-
sessionTemplate:
|
|
234
|
+
sessionTemplate: {
|
|
235
|
+
...renderTemplate,
|
|
236
|
+
...(credentialRestriction ? { credentialRestriction } : {}),
|
|
237
|
+
},
|
|
164
238
|
serviceSubjectId: `automation:${input.trigger.id}`,
|
|
165
|
-
serviceLabel: `
|
|
239
|
+
serviceLabel: `Opengeni automation: ${input.trigger.name}`,
|
|
166
240
|
provenance: {
|
|
167
241
|
sourceId: input.source.id,
|
|
168
242
|
sourceVersion: input.source.version,
|