@opengeni/core 0.12.5 → 0.12.10
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/dist/index.d.ts +43 -17
- package/dist/index.js +113 -58
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/access/index.ts +3 -0
- package/src/application/session-commands.ts +19 -8
- package/src/dependencies.ts +4 -2
- package/src/domain/capabilities.ts +36 -1
- package/src/domain/session-tool-policy.ts +5 -14
- package/src/domain/sessions.ts +102 -66
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Settings } from '@opengeni/config';
|
|
2
|
-
import { ScheduledTask, Document, GitHubAppApiPort, ConnectionCredentialsPort, SessionAuthorizationPort, Permission, AccessContext, AccessGrant, SessionAuthorizationActor, SessionAuthorizationTarget, SessionAuthorizationOperation, SessionAuthorizationSurface, SessionAuthorizationListScope, LimitAction, LimitDecision,
|
|
2
|
+
import { ScheduledTask, TurnInitiator, Document, GitHubAppApiPort, ConnectionCredentialsPort, SessionAuthorizationPort, Permission, AccessContext, AccessGrant, SessionAuthorizationActor, SessionAuthorizationTarget, SessionAuthorizationOperation, SessionAuthorizationSurface, SessionAuthorizationListScope, LimitAction, LimitDecision, TurnInitiatorContext, SessionTurnSource, CapabilityCatalogItem, CapabilityInstallation, CapabilityCatalogResponse, CreateCapabilityCatalogItemRequest, EnableCapabilityRequest, VariableSet, Rig, RigVersion, CreateRigRequest, RigDefinitionEditPayload, RigChange, ProposeRigChangeRequest, UpdateRigRequest, CapabilityPack, SocialConnection, ScheduledTaskAgentConfig, ToolRef, ResourceRef, SessionEffectiveToolPolicy, SessionToolPolicy, Session, CreateScheduledTaskRequest, UpdateScheduledTaskRequest, SessionSpawnDenial, ReasoningEffort, SessionMcpCredentialUpdateInput, SessionEvent, SessionTurn, SessionSkill, TurnExecutionPolicyV1, GoalSpec, FirstPartyMcpToolName, SessionMcpServerMetadata, CreateSessionResponse, SessionMcpApprovalPolicy, UpdateSessionMcpApprovalPolicyResponse, UpdateSessionToolPolicyRequest, ConnectionMetadata, OpenGeniSlackBotConnectionMetadata, WorkspaceMember, NewSessionDraft, SessionControlRequest, SessionControlResponse, WorkspaceInferenceControlRequest, WorkspaceInferenceControlResponse, DeleteSessionQueueItemRequest, SessionQueueMutationResponse, EditSessionQueueItemRequest, ComposerDraft, MoveSessionQueueItemRequest, SaveComposerDraftRequest, SteerSessionQueueItemRequest } from '@opengeni/contracts';
|
|
3
3
|
export { mergeToolRefs, stableJson } from '@opengeni/contracts';
|
|
4
4
|
import * as _opengeni_db from '@opengeni/db';
|
|
5
|
-
import { Database, SandboxRecord, EnabledMcpCapabilityServer, UpdateScheduledTaskInput, SessionCommandActor, CreateSessionMcpServerInput, UpdateSessionMcpServerCredentialsInput, ConnectionMetadataWithVerification } from '@opengeni/db';
|
|
5
|
+
import { Database, SandboxRecord, EnabledMcpCapabilityServer, UpdateScheduledTaskInput, SessionCommandActor, CreateSessionMcpServerInput, UpdateSessionMcpServerCredentialsInput, ConnectionMetadataWithVerification, SessionCommandReceiptRow } from '@opengeni/db';
|
|
6
6
|
import { DocumentServices } from '@opengeni/documents';
|
|
7
7
|
import { EventBus } from '@opengeni/events';
|
|
8
8
|
import { Observability } from '@opengeni/observability';
|
|
@@ -106,8 +106,9 @@ type SessionWorkflowClient = {
|
|
|
106
106
|
}) => Promise<void>;
|
|
107
107
|
triggerScheduledTask: (input: {
|
|
108
108
|
task: ScheduledTask;
|
|
109
|
-
agentRunUsageIdempotencyKey
|
|
110
|
-
triggerWorkflowId
|
|
109
|
+
agentRunUsageIdempotencyKey: string;
|
|
110
|
+
triggerWorkflowId: string;
|
|
111
|
+
initiator: TurnInitiator;
|
|
111
112
|
}) => Promise<void>;
|
|
112
113
|
startRigVerification: (input: {
|
|
113
114
|
workspaceId: string;
|
|
@@ -534,6 +535,13 @@ declare function disableCapability(input: {
|
|
|
534
535
|
capabilityId: string;
|
|
535
536
|
}): Promise<CapabilityInstallation>;
|
|
536
537
|
declare function settingsWithEnabledCapabilityMcpServers(db: Database, workspaceId: string, settings: Settings): Promise<Settings>;
|
|
538
|
+
/**
|
|
539
|
+
* Register Codex Apps as an optional runtime MCP when the deployment enables
|
|
540
|
+
* it. Registration only makes the server selectable; the session tool policy
|
|
541
|
+
* decides whether the model sees it, and Codex credential resolution
|
|
542
|
+
* independently decides whether calls can authenticate.
|
|
543
|
+
*/
|
|
544
|
+
declare function settingsWithCodexAppsMcpServer(settings: Settings): Settings;
|
|
537
545
|
declare function settingsWithMcpCapabilityServers(settings: Settings, enabled: EnabledMcpCapabilityServer[]): Settings;
|
|
538
546
|
declare function discoverMcpRegistryCapabilities(input: {
|
|
539
547
|
query?: string;
|
|
@@ -691,11 +699,8 @@ type ResolvedSessionToolPolicy = {
|
|
|
691
699
|
effectivePolicy: SessionEffectiveToolPolicy;
|
|
692
700
|
};
|
|
693
701
|
type SessionToolPolicyInput = {
|
|
694
|
-
toolPolicy
|
|
702
|
+
toolPolicy: SessionToolPolicy;
|
|
695
703
|
sessionTools: ToolRef[];
|
|
696
|
-
turnTools?: ToolRef[];
|
|
697
|
-
/** Undefined preserves the legacy merge path for pre-provenance callers. */
|
|
698
|
-
turnToolsProvided?: boolean;
|
|
699
704
|
availableMcpServerIds: Iterable<string>;
|
|
700
705
|
/** Current omitted-tools defaults, intentionally narrower than all servers. */
|
|
701
706
|
defaultMcpServerIds?: Iterable<string>;
|
|
@@ -795,6 +800,13 @@ declare class SessionSpawnDeniedError extends Error {
|
|
|
795
800
|
readonly denial: SessionSpawnDenial;
|
|
796
801
|
constructor(denial: SessionSpawnDenial);
|
|
797
802
|
}
|
|
803
|
+
/**
|
|
804
|
+
* Resolve per-session first-party tool visibility without consulting
|
|
805
|
+
* authorization. Top-level omission uses the minimal runtime default (stored
|
|
806
|
+
* as null); child omission snapshots the parent's exact effective selection.
|
|
807
|
+
* Explicit [] is authoritative and must never widen.
|
|
808
|
+
*/
|
|
809
|
+
declare function resolveFirstPartyMcpToolsForCreate(requested: FirstPartyMcpToolName[] | undefined, parentStored: FirstPartyMcpToolName[] | null | undefined): FirstPartyMcpToolName[];
|
|
798
810
|
declare function sessionSpawnDenialEnvelope(error: SessionSpawnDeniedError): {
|
|
799
811
|
readonly error: {
|
|
800
812
|
readonly code: "nested_agent_depth_exceeded" | "nested_agent_depth_override_forbidden";
|
|
@@ -833,7 +845,7 @@ declare function createAndStartSession(input: {
|
|
|
833
845
|
resources: ResourceRef[];
|
|
834
846
|
skills?: SessionSkill[];
|
|
835
847
|
tools: ToolRef[];
|
|
836
|
-
toolPolicy
|
|
848
|
+
toolPolicy: SessionToolPolicy;
|
|
837
849
|
clientEventId?: string;
|
|
838
850
|
model: string;
|
|
839
851
|
reasoningEffort: Settings["openaiReasoningEffort"];
|
|
@@ -854,6 +866,7 @@ declare function createAndStartSession(input: {
|
|
|
854
866
|
goal?: GoalSpec | null;
|
|
855
867
|
instructions?: string | null;
|
|
856
868
|
firstPartyMcpPermissions?: Permission[] | null;
|
|
869
|
+
firstPartyMcpTools: FirstPartyMcpToolName[];
|
|
857
870
|
mcpServers?: CreateSessionMcpServerInput[];
|
|
858
871
|
sessionMcpServers?: SessionMcpServerMetadata[];
|
|
859
872
|
parentSessionId?: string | null;
|
|
@@ -924,8 +937,6 @@ declare function postUserMessageTurn(input: {
|
|
|
924
937
|
text: string;
|
|
925
938
|
turnInstructions?: string | null;
|
|
926
939
|
resources: ResourceRef[];
|
|
927
|
-
tools: ToolRef[];
|
|
928
|
-
toolsProvided: boolean;
|
|
929
940
|
model?: string | null;
|
|
930
941
|
reasoningEffort?: Settings["openaiReasoningEffort"] | null;
|
|
931
942
|
clientEventId?: string;
|
|
@@ -958,15 +969,12 @@ declare function createSessionForRequest(deps: ApiRouteDeps, grant: AccessGrant,
|
|
|
958
969
|
* `POST /sessions/:id/events` and the first-party MCP `session_send_message`
|
|
959
970
|
* tool: resource/tool validation, usage limits, the locked append + turn
|
|
960
971
|
* enqueue, and usage recording. `toolsProvided: false` durably preserves an
|
|
961
|
-
*
|
|
962
|
-
* empty array is a deliberate per-turn narrowing.
|
|
972
|
+
* Tool selection is durable session state and never rides a follow-up prompt.
|
|
963
973
|
*/
|
|
964
974
|
declare function acceptSessionUserMessage(deps: AcceptSessionUserMessageDependencies, grant: AccessGrant, workspaceId: string, sessionId: string, input: {
|
|
965
975
|
text: string;
|
|
966
976
|
turnInstructions?: string | null;
|
|
967
977
|
resources?: ResourceRef[];
|
|
968
|
-
tools?: ToolRef[];
|
|
969
|
-
toolsProvided: boolean;
|
|
970
978
|
model?: string | null;
|
|
971
979
|
reasoningEffort?: ReasoningEffort | null;
|
|
972
980
|
clientEventId?: string;
|
|
@@ -1091,6 +1099,8 @@ type HumanSessionCommandContext = {
|
|
|
1091
1099
|
workspaceId: string;
|
|
1092
1100
|
sessionId: string;
|
|
1093
1101
|
subjectId: string;
|
|
1102
|
+
/** See AgentSessionCommandContext.authorizationSurface. */
|
|
1103
|
+
authorizationSurface?: SessionAuthorizationSurface;
|
|
1094
1104
|
};
|
|
1095
1105
|
type AgentSessionCommandContext = {
|
|
1096
1106
|
accountId: string;
|
|
@@ -1100,6 +1110,13 @@ type AgentSessionCommandContext = {
|
|
|
1100
1110
|
callerTurnId: string;
|
|
1101
1111
|
callerAttemptId: string;
|
|
1102
1112
|
callerExecutionGeneration: number;
|
|
1113
|
+
/**
|
|
1114
|
+
* The trusted adapter surface that owns this command's one authorization
|
|
1115
|
+
* decision. Direct core callers omit it and retain the canonical `core`
|
|
1116
|
+
* surface; adapters that delegate the complete command set it explicitly so
|
|
1117
|
+
* they do not authorize once at the edge and then repeat the host call here.
|
|
1118
|
+
*/
|
|
1119
|
+
authorizationSurface?: SessionAuthorizationSurface;
|
|
1103
1120
|
};
|
|
1104
1121
|
type SessionAuthorizationCommandDeps = {
|
|
1105
1122
|
db: Database;
|
|
@@ -1135,7 +1152,16 @@ declare function controlAgentSessionWorkstream(deps: {
|
|
|
1135
1152
|
action: "pause" | "resume";
|
|
1136
1153
|
idempotencyKey: string;
|
|
1137
1154
|
reason?: string | null;
|
|
1138
|
-
}): Promise<
|
|
1155
|
+
}): Promise<{
|
|
1156
|
+
authorization: ResolvedSessionAuthorization | null;
|
|
1157
|
+
receipt: SessionCommandReceiptRow;
|
|
1158
|
+
control: _opengeni_db.EffectiveSessionControl;
|
|
1159
|
+
sessionControlEventId: string;
|
|
1160
|
+
workspaceControlEventId: string;
|
|
1161
|
+
interruptionCount: number;
|
|
1162
|
+
wakeCount: number;
|
|
1163
|
+
replay: boolean;
|
|
1164
|
+
}>;
|
|
1139
1165
|
declare function moveHumanQueuePrompt(deps: {
|
|
1140
1166
|
db: Database;
|
|
1141
1167
|
bus: EventBus;
|
|
@@ -1170,4 +1196,4 @@ declare function controlHumanWorkspace(deps: {
|
|
|
1170
1196
|
declare function getHumanComposerDraft(deps: SessionAuthorizationCommandDeps, context: HumanSessionCommandContext): Promise<ComposerDraft>;
|
|
1171
1197
|
declare function saveHumanComposerDraft(deps: SessionAuthorizationCommandDeps, context: HumanSessionCommandContext, input: SaveComposerDraftRequest): Promise<ComposerDraft>;
|
|
1172
1198
|
|
|
1173
|
-
export { type AcceptSessionUserMessageDependencies, type AccessDeps, type AgentSessionCommandContext, type ApiRouteDeps, type ApiSandboxClient, type ApiSandboxSession, type AppDependencies, type ChannelARoutingServices, type DocumentIndexClient, type FleetContext, type FleetListResult, type FleetLiveness, type FleetReadinessHold, type FleetSandboxEntry, type FleetServices, type FleetSwapResult, type HumanSessionCommandContext, type LimitCheckInput, type LimitDependencies, MARKETING_SOCIAL_PACK_ID, MAX_CHECKS_PER_RIG, MAX_CREDENTIAL_HOOKS_PER_RIG, MAX_DEFAULT_VARIABLE_SETS_PER_RIG, MAX_ENVIRONMENTS_PER_WORKSPACE, MAX_RIGS_PER_WORKSPACE, MAX_VARIABLES_PER_ENVIRONMENT, type ManagedAuth, type McpCapabilityProbe, type McpCapabilityProbeInput, type McpCapabilityProbeResult, type ObjectStorageDependency, type ProvisionResult, type ResolvedSessionAuthorization, type ResolvedSessionToolPolicy, type ResumeBoxByIdInput, type ResumedSandboxSession, type RigServices, type RigVerificationClassification, type RunOnOp, type RunOnResult, SESSION_AUTHORIZATION_DEFAULT_REAUTHORIZE_MS, SESSION_WORKFLOW_WAKE_DISPATCHER_PERIOD_MS, SESSION_WORKFLOW_WAKE_DISPATCHER_SCHEDULE_ID, SESSION_WORKFLOW_WAKE_DISPATCHER_WORKFLOW_TYPE, SessionAuthorizationDeniedError, type SessionAuthorizationDependencies, SessionAuthorizationUnavailableError, SessionSpawnDeniedError, type SessionToolPolicyInput, type SessionWorkflowClient, acceptSessionUserMessage, activateRigVersionForApi, appendRigSetupCommand, applyCapabilityEnablement, assertAllowedEnvironmentVariableName, assertAllowedVariableSetVariableName, assertConfiguredModel, assertPackSandboxImageCompatible, assertToolRefsSubset, assertWorkspaceDeletable, assertWorkspaceMemberRemovable, assertWorkspaceModelPolicyAllows, availableToolRefs, buildCapabilityCatalog, buildFleetContextForSession, buildMarketingDailyAnalysisAgentConfig, canonicalConfiguredModel, checkLimit, classifyRigVerificationOutcome, controlAgentSessionWorkstream, controlHumanSessionWorkstream, controlHumanWorkspace, createAndStartSession, createCatalogItem, createRigForApi, createRigVersionForApi, createSessionForRequest, createValidatedScheduledTask, deleteHumanQueuePrompt, deleteRigForApi, disableCapability, discoverMcpRegistryCapabilities, editHumanQueuePrompt, enableCapability, enabledCapabilityMcpToolRefs, getActorNewSessionDraft, getCapabilityPack, getHumanComposerDraft, hasPermission, hasReservedOpenGeniSlackBotMetadata, hasReservedOpenGeniSlackBotSessionMetadata, isAuthoritativeGitHubRepositorySelectionError, isBuiltInCapabilityPack, isOpenGeniSlackBotConnection, isTrustedScheduledSlackBotSession, isUserMember, listCapabilityPacks, listFleet, listRigChangesForApi, listRigVersionsForApi, listWorkspaceCapabilityPacks, manualScheduledTaskTriggerUsageKey, manualScheduledTaskTriggerWorkflowId, memberCanAdminister, mergeResourceRefs, moveHumanQueuePrompt, normalizeResources, officialMcpRegistryUrl, openGeniSlackBotMetadata, postUserMessageTurn, promoteSetupAppendChange, promoteVerifiedDefinitionEditChangeForApi, proposeRigChangeForApi, provisionSandbox, readSessionLineage, reasoningEffortForSession, recordRigAuditEvent, recordVariableSetAuditEvent, recordWorkspaceUsage, relayConfigFromSettings, relayDialBaseFromSettings, requireAccessContext, requireAccessGrant, requireEnvironmentEncryption, requireLimit, requireOpenGeniSlackBotConnection, requirePermission, requireQueuedTurnForApi, requireRigChangeForApi, requireRigForApi, requireScheduledTaskForApi, requireSessionAuthorization, requireSessionAuthorizationListScope, requireVariableSetEncryption, requireVariableSetForApi, resolveCapabilityPack, resolveMemberSubjectId, resolveSessionToolPolicy, restoreScheduledTask, rigActorForGrant, routingEnabled, runOnSandbox, saveActorNewSessionDraft, saveHumanComposerDraft, scheduledSlackBotConnectionId, scheduledTaskTemporalScheduleId, scheduledTaskToolsProvided, scheduledTaskTriggerToken, sendAgentSessionMessage, sessionSpawnDenialEnvelope, sessionToolPolicyAllowsDefaultNativeTools, sessionWithEffectiveToolPolicy, settingsWithEnabledCapabilityMcpServers, settingsWithMcpCapabilityServers, settingsWithSessionMcpServerMetadata, steerAgentSession, steerHumanQueuePrompt, swapActiveSandbox, syncCreatedScheduledTask, syncUpdatedScheduledTask, updateRigForApi, updateSessionMcpApprovalPolicy, updateSessionTitle, updateSessionToolPolicy, validateFileResources, validateGitHubRepositorySelection, validateGitHubRepositorySelectionShape, validateGitHubRepositorySelectionShapes, validateMcpCapabilityConnection, validateOpenGeniSlackBotConnectionSelection, validateToolRefs, validateToolRefsForSessionPolicy, validateVariableSetAttachment, validatedScheduledTaskUpdate, withDefaultEnabledCapabilityMcpTools, workflowIdForSession, workspaceSessionToolPolicyDefaultServerIds, workspaceSessionToolPolicyServerIds, wrapChannelABoxWithRouting };
|
|
1199
|
+
export { type AcceptSessionUserMessageDependencies, type AccessDeps, type AgentSessionCommandContext, type ApiRouteDeps, type ApiSandboxClient, type ApiSandboxSession, type AppDependencies, type ChannelARoutingServices, type DocumentIndexClient, type FleetContext, type FleetListResult, type FleetLiveness, type FleetReadinessHold, type FleetSandboxEntry, type FleetServices, type FleetSwapResult, type HumanSessionCommandContext, type LimitCheckInput, type LimitDependencies, MARKETING_SOCIAL_PACK_ID, MAX_CHECKS_PER_RIG, MAX_CREDENTIAL_HOOKS_PER_RIG, MAX_DEFAULT_VARIABLE_SETS_PER_RIG, MAX_ENVIRONMENTS_PER_WORKSPACE, MAX_RIGS_PER_WORKSPACE, MAX_VARIABLES_PER_ENVIRONMENT, type ManagedAuth, type McpCapabilityProbe, type McpCapabilityProbeInput, type McpCapabilityProbeResult, type ObjectStorageDependency, type ProvisionResult, type ResolvedSessionAuthorization, type ResolvedSessionToolPolicy, type ResumeBoxByIdInput, type ResumedSandboxSession, type RigServices, type RigVerificationClassification, type RunOnOp, type RunOnResult, SESSION_AUTHORIZATION_DEFAULT_REAUTHORIZE_MS, SESSION_WORKFLOW_WAKE_DISPATCHER_PERIOD_MS, SESSION_WORKFLOW_WAKE_DISPATCHER_SCHEDULE_ID, SESSION_WORKFLOW_WAKE_DISPATCHER_WORKFLOW_TYPE, SessionAuthorizationDeniedError, type SessionAuthorizationDependencies, SessionAuthorizationUnavailableError, SessionSpawnDeniedError, type SessionToolPolicyInput, type SessionWorkflowClient, acceptSessionUserMessage, activateRigVersionForApi, appendRigSetupCommand, applyCapabilityEnablement, assertAllowedEnvironmentVariableName, assertAllowedVariableSetVariableName, assertConfiguredModel, assertPackSandboxImageCompatible, assertToolRefsSubset, assertWorkspaceDeletable, assertWorkspaceMemberRemovable, assertWorkspaceModelPolicyAllows, availableToolRefs, buildCapabilityCatalog, buildFleetContextForSession, buildMarketingDailyAnalysisAgentConfig, canonicalConfiguredModel, checkLimit, classifyRigVerificationOutcome, controlAgentSessionWorkstream, controlHumanSessionWorkstream, controlHumanWorkspace, createAndStartSession, createCatalogItem, createRigForApi, createRigVersionForApi, createSessionForRequest, createValidatedScheduledTask, deleteHumanQueuePrompt, deleteRigForApi, disableCapability, discoverMcpRegistryCapabilities, editHumanQueuePrompt, enableCapability, enabledCapabilityMcpToolRefs, getActorNewSessionDraft, getCapabilityPack, getHumanComposerDraft, hasPermission, hasReservedOpenGeniSlackBotMetadata, hasReservedOpenGeniSlackBotSessionMetadata, isAuthoritativeGitHubRepositorySelectionError, isBuiltInCapabilityPack, isOpenGeniSlackBotConnection, isTrustedScheduledSlackBotSession, isUserMember, listCapabilityPacks, listFleet, listRigChangesForApi, listRigVersionsForApi, listWorkspaceCapabilityPacks, manualScheduledTaskTriggerUsageKey, manualScheduledTaskTriggerWorkflowId, memberCanAdminister, mergeResourceRefs, moveHumanQueuePrompt, normalizeResources, officialMcpRegistryUrl, openGeniSlackBotMetadata, postUserMessageTurn, promoteSetupAppendChange, promoteVerifiedDefinitionEditChangeForApi, proposeRigChangeForApi, provisionSandbox, readSessionLineage, reasoningEffortForSession, recordRigAuditEvent, recordVariableSetAuditEvent, recordWorkspaceUsage, relayConfigFromSettings, relayDialBaseFromSettings, requireAccessContext, requireAccessGrant, requireEnvironmentEncryption, requireLimit, requireOpenGeniSlackBotConnection, requirePermission, requireQueuedTurnForApi, requireRigChangeForApi, requireRigForApi, requireScheduledTaskForApi, requireSessionAuthorization, requireSessionAuthorizationListScope, requireVariableSetEncryption, requireVariableSetForApi, resolveCapabilityPack, resolveFirstPartyMcpToolsForCreate, resolveMemberSubjectId, resolveSessionToolPolicy, restoreScheduledTask, rigActorForGrant, routingEnabled, runOnSandbox, saveActorNewSessionDraft, saveHumanComposerDraft, scheduledSlackBotConnectionId, scheduledTaskTemporalScheduleId, scheduledTaskToolsProvided, scheduledTaskTriggerToken, sendAgentSessionMessage, sessionSpawnDenialEnvelope, sessionToolPolicyAllowsDefaultNativeTools, sessionWithEffectiveToolPolicy, settingsWithCodexAppsMcpServer, settingsWithEnabledCapabilityMcpServers, settingsWithMcpCapabilityServers, settingsWithSessionMcpServerMetadata, steerAgentSession, steerHumanQueuePrompt, swapActiveSandbox, syncCreatedScheduledTask, syncUpdatedScheduledTask, updateRigForApi, updateSessionMcpApprovalPolicy, updateSessionTitle, updateSessionToolPolicy, validateFileResources, validateGitHubRepositorySelection, validateGitHubRepositorySelectionShape, validateGitHubRepositorySelectionShapes, validateMcpCapabilityConnection, validateOpenGeniSlackBotConnectionSelection, validateToolRefs, validateToolRefsForSessionPolicy, validateVariableSetAttachment, validatedScheduledTaskUpdate, withDefaultEnabledCapabilityMcpTools, workflowIdForSession, workspaceSessionToolPolicyDefaultServerIds, workspaceSessionToolPolicyServerIds, wrapChannelABoxWithRouting };
|
package/dist/index.js
CHANGED
|
@@ -829,6 +829,7 @@ async function delegatedAccessContext(c, deps, mode, token = bearerToken(c)) {
|
|
|
829
829
|
metadata: {
|
|
830
830
|
delegated: true,
|
|
831
831
|
...payload.sessionId ? { sessionId: payload.sessionId } : {},
|
|
832
|
+
...payload.firstPartyMcpTools !== void 0 ? { firstPartyMcpTools: payload.firstPartyMcpTools } : {},
|
|
832
833
|
// Caller identity: the turn that minted this token. Tools classify the
|
|
833
834
|
// CALLER from this instead of re-reading the live active pointer.
|
|
834
835
|
...payload.turnId ? { turnId: payload.turnId } : {},
|
|
@@ -1189,6 +1190,12 @@ import { environmentsEncryptionKeyBytes as environmentsEncryptionKeyBytes2 } fro
|
|
|
1189
1190
|
import {
|
|
1190
1191
|
CapabilityCatalogItem
|
|
1191
1192
|
} from "@opengeni/contracts";
|
|
1193
|
+
import {
|
|
1194
|
+
CODEX_APPS_MCP_SERVER_ID,
|
|
1195
|
+
CODEX_APPS_MCP_SERVER_NAME,
|
|
1196
|
+
CODEX_APPS_MCP_URL,
|
|
1197
|
+
CODEX_APPS_STARTUP_TIMEOUT_MS
|
|
1198
|
+
} from "@opengeni/codex";
|
|
1192
1199
|
import {
|
|
1193
1200
|
decryptVariableSetValue,
|
|
1194
1201
|
decryptedCapabilityHeaders,
|
|
@@ -2029,7 +2036,26 @@ async function disableCapability(input) {
|
|
|
2029
2036
|
}
|
|
2030
2037
|
async function settingsWithEnabledCapabilityMcpServers(db, workspaceId, settings) {
|
|
2031
2038
|
const enabled = await listEnabledMcpCapabilityServers(db, workspaceId);
|
|
2032
|
-
return settingsWithMcpCapabilityServers(settings, enabled);
|
|
2039
|
+
return settingsWithCodexAppsMcpServer(settingsWithMcpCapabilityServers(settings, enabled));
|
|
2040
|
+
}
|
|
2041
|
+
function settingsWithCodexAppsMcpServer(settings) {
|
|
2042
|
+
if (!settings.codexConnectedAppsEnabled || settings.mcpServers.some((server) => server.id === CODEX_APPS_MCP_SERVER_ID)) {
|
|
2043
|
+
return settings;
|
|
2044
|
+
}
|
|
2045
|
+
return {
|
|
2046
|
+
...settings,
|
|
2047
|
+
mcpServers: [
|
|
2048
|
+
...settings.mcpServers,
|
|
2049
|
+
{
|
|
2050
|
+
id: CODEX_APPS_MCP_SERVER_ID,
|
|
2051
|
+
name: CODEX_APPS_MCP_SERVER_NAME,
|
|
2052
|
+
url: CODEX_APPS_MCP_URL,
|
|
2053
|
+
timeoutMs: CODEX_APPS_STARTUP_TIMEOUT_MS,
|
|
2054
|
+
// Availability is credential-specific, so discover on every run.
|
|
2055
|
+
cacheToolsList: false
|
|
2056
|
+
}
|
|
2057
|
+
]
|
|
2058
|
+
};
|
|
2033
2059
|
}
|
|
2034
2060
|
function settingsWithMcpCapabilityServers(settings, enabled) {
|
|
2035
2061
|
if (enabled.length === 0) {
|
|
@@ -3225,15 +3251,15 @@ function projectIds(ids) {
|
|
|
3225
3251
|
};
|
|
3226
3252
|
}
|
|
3227
3253
|
function resolveSessionToolPolicy(input) {
|
|
3228
|
-
const policy = input.toolPolicy
|
|
3254
|
+
const policy = input.toolPolicy;
|
|
3229
3255
|
const availableIds = new Set(input.availableMcpServerIds);
|
|
3230
3256
|
const defaultIds = new Set(input.defaultMcpServerIds ?? []);
|
|
3231
3257
|
const mandatoryIds = MANDATORY_SESSION_MCP_SERVER_IDS.filter(
|
|
3232
3258
|
(id) => availableIds.has(id)
|
|
3233
3259
|
);
|
|
3234
3260
|
const mandatoryIdSet = new Set(mandatoryIds);
|
|
3235
|
-
const selectedRefs =
|
|
3236
|
-
const tracksWorkspaceDefaults = policy.mode === "workspace_default"
|
|
3261
|
+
const selectedRefs = mergeToolRefs2([], input.sessionTools);
|
|
3262
|
+
const tracksWorkspaceDefaults = policy.mode === "workspace_default";
|
|
3237
3263
|
let toolRefs = selectedRefs.filter((tool) => tool.optional !== true || availableIds.has(tool.id));
|
|
3238
3264
|
if (tracksWorkspaceDefaults) {
|
|
3239
3265
|
toolRefs = mergeToolRefs2(
|
|
@@ -3319,7 +3345,7 @@ function sessionWithEffectiveToolPolicy(session, workspaceServerIds, workspaceDe
|
|
|
3319
3345
|
return {
|
|
3320
3346
|
...session,
|
|
3321
3347
|
effectiveToolPolicy: resolveSessionToolPolicy({
|
|
3322
|
-
|
|
3348
|
+
toolPolicy: session.toolPolicy,
|
|
3323
3349
|
sessionTools: session.tools,
|
|
3324
3350
|
availableMcpServerIds: availableIds,
|
|
3325
3351
|
defaultMcpServerIds: workspaceDefaultServerIds
|
|
@@ -3351,6 +3377,8 @@ import {
|
|
|
3351
3377
|
import {
|
|
3352
3378
|
CreateSessionRequest,
|
|
3353
3379
|
DEFAULT_FIRST_PARTY_MCP_PERMISSIONS,
|
|
3380
|
+
DEFAULT_FIRST_PARTY_MCP_TOOLS,
|
|
3381
|
+
FIRST_PARTY_MCP_TOOL_NAMES,
|
|
3354
3382
|
OPENGENI_SLACK_BOT_SESSION_METADATA_KEY as OPENGENI_SLACK_BOT_SESSION_METADATA_KEY2,
|
|
3355
3383
|
SessionSpawnDenial,
|
|
3356
3384
|
ServiceTurnInitiator,
|
|
@@ -3473,6 +3501,11 @@ var SessionSpawnDeniedError = class extends Error {
|
|
|
3473
3501
|
this.denial = denial;
|
|
3474
3502
|
}
|
|
3475
3503
|
};
|
|
3504
|
+
function resolveFirstPartyMcpToolsForCreate(requested, parentStored) {
|
|
3505
|
+
if (requested !== void 0) return [...requested];
|
|
3506
|
+
if (parentStored === void 0) return [...DEFAULT_FIRST_PARTY_MCP_TOOLS];
|
|
3507
|
+
return [...parentStored ?? DEFAULT_FIRST_PARTY_MCP_TOOLS];
|
|
3508
|
+
}
|
|
3476
3509
|
function sessionSpawnDeniedMessage(denial) {
|
|
3477
3510
|
if (denial.code === "nested_agent_depth_override_forbidden") {
|
|
3478
3511
|
return `requested nested-agent depth limit ${denial.requestedMaxNestedAgentDepthOverride ?? "unknown"} exceeds inherited limit ${denial.effectiveMaxNestedAgentDepth}; workspace:admin is required to increase it`;
|
|
@@ -3766,7 +3799,7 @@ async function createAndStartSession(input) {
|
|
|
3766
3799
|
resources: input.resources,
|
|
3767
3800
|
skills: input.skills ?? [],
|
|
3768
3801
|
tools: input.tools,
|
|
3769
|
-
|
|
3802
|
+
toolPolicy: input.toolPolicy,
|
|
3770
3803
|
metadata: sessionMetadata,
|
|
3771
3804
|
...input.createdBy ? { createdBy: input.createdBy } : {},
|
|
3772
3805
|
...input.createdByContext ? { createdByContext: input.createdByContext } : {},
|
|
@@ -3777,6 +3810,7 @@ async function createAndStartSession(input) {
|
|
|
3777
3810
|
rigId: input.rigId ?? null,
|
|
3778
3811
|
rigVersionId: input.rigVersionId ?? null,
|
|
3779
3812
|
firstPartyMcpPermissions: input.firstPartyMcpPermissions ?? null,
|
|
3813
|
+
firstPartyMcpTools: input.firstPartyMcpTools,
|
|
3780
3814
|
instructions: input.instructions ?? null,
|
|
3781
3815
|
parentSessionId: input.parentSessionId ?? null,
|
|
3782
3816
|
createIdempotencyKey: input.createIdempotencyKey,
|
|
@@ -3810,7 +3844,7 @@ async function createAndStartSession(input) {
|
|
|
3810
3844
|
resources: input.resources,
|
|
3811
3845
|
skills: input.skills ?? [],
|
|
3812
3846
|
tools: input.tools,
|
|
3813
|
-
|
|
3847
|
+
toolPolicy: input.toolPolicy,
|
|
3814
3848
|
metadata: sessionMetadata,
|
|
3815
3849
|
...input.createdBy ? { createdBy: input.createdBy } : {},
|
|
3816
3850
|
...input.createdByContext ? { createdByContext: input.createdByContext } : {},
|
|
@@ -3821,6 +3855,7 @@ async function createAndStartSession(input) {
|
|
|
3821
3855
|
rigId: input.rigId ?? null,
|
|
3822
3856
|
rigVersionId: input.rigVersionId ?? null,
|
|
3823
3857
|
firstPartyMcpPermissions: input.firstPartyMcpPermissions ?? null,
|
|
3858
|
+
firstPartyMcpTools: input.firstPartyMcpTools,
|
|
3824
3859
|
instructions: input.instructions ?? null,
|
|
3825
3860
|
parentSessionId: input.parentSessionId ?? null,
|
|
3826
3861
|
sandboxGroupId: input.sandboxGroupId ?? null,
|
|
@@ -3874,7 +3909,7 @@ async function finishStartSession(input, session) {
|
|
|
3874
3909
|
reasoningEffortFallback: input.reasoningEffort,
|
|
3875
3910
|
turnExecutionPolicy: input.turnExecutionPolicy,
|
|
3876
3911
|
createdEventPayload: {
|
|
3877
|
-
|
|
3912
|
+
toolPolicy: input.toolPolicy,
|
|
3878
3913
|
...input.variableSet ? { variableSetId: input.variableSet.id, variableSetName: input.variableSet.name } : {},
|
|
3879
3914
|
...input.sessionMcpServers?.length ? { mcpServers: input.sessionMcpServers } : {}
|
|
3880
3915
|
},
|
|
@@ -3987,8 +4022,6 @@ async function postUserMessageTurn(input) {
|
|
|
3987
4022
|
text: input.text,
|
|
3988
4023
|
turnInstructions: input.turnInstructions ?? null,
|
|
3989
4024
|
resources: input.resources,
|
|
3990
|
-
tools: input.tools,
|
|
3991
|
-
toolsProvided: input.toolsProvided,
|
|
3992
4025
|
model: requestedModel,
|
|
3993
4026
|
reasoningEffort: requestedReasoningEffort,
|
|
3994
4027
|
reasoningEffortFallback: input.reasoningEffortFallback ?? settings.openaiReasoningEffort,
|
|
@@ -4216,6 +4249,20 @@ async function createSessionForRequest(deps, grant, workspaceId, rawPayload) {
|
|
|
4216
4249
|
message: "goal-bearing sessions require goals:manage in the resulting first-party MCP permission set"
|
|
4217
4250
|
});
|
|
4218
4251
|
}
|
|
4252
|
+
const firstPartyMcpTools = resolveFirstPartyMcpToolsForCreate(
|
|
4253
|
+
payload.firstPartyMcpTools,
|
|
4254
|
+
parentSession ? parentSession.firstPartyMcpTools : void 0
|
|
4255
|
+
);
|
|
4256
|
+
if (payload.goal) {
|
|
4257
|
+
const missingGoalTools = ["goal_update", "goal_complete", "goal_pause"].filter(
|
|
4258
|
+
(name) => !firstPartyMcpTools.includes(name)
|
|
4259
|
+
);
|
|
4260
|
+
if (missingGoalTools.length > 0) {
|
|
4261
|
+
throw new HTTPException10(422, {
|
|
4262
|
+
message: `goal-bearing sessions require first-party MCP tools: ${missingGoalTools.join(", ")}`
|
|
4263
|
+
});
|
|
4264
|
+
}
|
|
4265
|
+
}
|
|
4219
4266
|
const sandboxChoice = payload.sandbox ?? (parentSessionId ? "shared" : "new");
|
|
4220
4267
|
let sandboxGroupId = null;
|
|
4221
4268
|
let inheritedBackend;
|
|
@@ -4362,6 +4409,7 @@ async function createSessionForRequest(deps, grant, workspaceId, rawPayload) {
|
|
|
4362
4409
|
// time. Not surfaced as an event.
|
|
4363
4410
|
instructions: payload.instructions ?? null,
|
|
4364
4411
|
firstPartyMcpPermissions,
|
|
4412
|
+
firstPartyMcpTools,
|
|
4365
4413
|
mcpServers: sessionMcpServers.dbServers,
|
|
4366
4414
|
sessionMcpServers: sessionMcpServers.metadata,
|
|
4367
4415
|
parentSessionId,
|
|
@@ -4408,22 +4456,12 @@ async function createSessionForRequest(deps, grant, workspaceId, rawPayload) {
|
|
|
4408
4456
|
return session;
|
|
4409
4457
|
}
|
|
4410
4458
|
async function acceptSessionUserMessage(deps, grant, workspaceId, sessionId, input) {
|
|
4411
|
-
if (input.toolsProvided && !deps.settings.sessionTurnToolReplacementEnabled) {
|
|
4412
|
-
throw new HTTPException10(503, {
|
|
4413
|
-
message: "explicit follow-up tool replacement is temporarily unavailable until provenance-aware turn workers finish rolling out; omit tools to inherit the session policy and retry"
|
|
4414
|
-
});
|
|
4415
|
-
}
|
|
4416
4459
|
const { settings, db, bus, workflowClient, objectStorage } = deps;
|
|
4417
4460
|
await requireSessionAuthorization(deps, grant, {
|
|
4418
4461
|
sessionId,
|
|
4419
4462
|
operation: input.delivery === "steer" ? "session.steer" : "session.append",
|
|
4420
4463
|
surface: "core"
|
|
4421
4464
|
});
|
|
4422
|
-
const capabilityRuntimeSettings = await settingsWithEnabledCapabilityMcpServers(
|
|
4423
|
-
db,
|
|
4424
|
-
workspaceId,
|
|
4425
|
-
settings
|
|
4426
|
-
);
|
|
4427
4465
|
const existingSession = await requireSession2(db, workspaceId, sessionId);
|
|
4428
4466
|
const requestedModel = canonicalConfiguredModel(settings, input.model ?? null) ?? null;
|
|
4429
4467
|
const effectiveModel = canonicalConfiguredModel(settings, requestedModel ?? existingSession.model) ?? null;
|
|
@@ -4442,27 +4480,7 @@ async function acceptSessionUserMessage(deps, grant, workspaceId, sessionId, inp
|
|
|
4442
4480
|
reasoningEffort: effectiveReasoningEffort,
|
|
4443
4481
|
reasoningSource: input.reasoningEffort == null ? "session" : "explicit"
|
|
4444
4482
|
});
|
|
4445
|
-
const runtimeSettings = settingsWithSessionMcpServerMetadata(
|
|
4446
|
-
capabilityRuntimeSettings,
|
|
4447
|
-
existingSession.mcpServers
|
|
4448
|
-
);
|
|
4449
4483
|
const requestedResources = normalizeResources(input.resources ?? []);
|
|
4450
|
-
const tracksWorkspaceDefaults = existingSession.toolPolicy?.mode === "workspace_default";
|
|
4451
|
-
const sessionPolicyTools = withFirstPartyTools(
|
|
4452
|
-
tracksWorkspaceDefaults ? withDefaultEnabledCapabilityMcpTools(
|
|
4453
|
-
availableToolRefs(existingSession.tools, runtimeSettings),
|
|
4454
|
-
settings,
|
|
4455
|
-
capabilityRuntimeSettings
|
|
4456
|
-
) : existingSession.tools,
|
|
4457
|
-
runtimeSettings
|
|
4458
|
-
);
|
|
4459
|
-
const validatedTools = input.toolsProvided ? validateToolRefsForSessionPolicy({
|
|
4460
|
-
requested: input.tools ?? [],
|
|
4461
|
-
settings: runtimeSettings,
|
|
4462
|
-
allowedTools: sessionPolicyTools,
|
|
4463
|
-
message: "message tools may only narrow the session tool policy"
|
|
4464
|
-
}) : [];
|
|
4465
|
-
const requestedTools = input.toolsProvided ? validatedTools : [];
|
|
4466
4484
|
await requireLimit(deps, {
|
|
4467
4485
|
accountId: grant.accountId,
|
|
4468
4486
|
workspaceId,
|
|
@@ -4496,8 +4514,6 @@ async function acceptSessionUserMessage(deps, grant, workspaceId, sessionId, inp
|
|
|
4496
4514
|
text: input.text,
|
|
4497
4515
|
turnInstructions: input.turnInstructions ?? null,
|
|
4498
4516
|
resources: requestedResources,
|
|
4499
|
-
tools: requestedTools,
|
|
4500
|
-
toolsProvided: input.toolsProvided,
|
|
4501
4517
|
model: input.model ?? null,
|
|
4502
4518
|
reasoningEffort: input.reasoningEffort ?? null,
|
|
4503
4519
|
reasoningEffortFallback: sessionReasoningEffort,
|
|
@@ -4604,7 +4620,7 @@ async function updateSessionMcpApprovalPolicy(deps, grant, sessionId, serverId,
|
|
|
4604
4620
|
effectiveFrom: "next_attempt"
|
|
4605
4621
|
};
|
|
4606
4622
|
}
|
|
4607
|
-
function toolPolicyAuditSnapshot(session, tools, policy = session.toolPolicy
|
|
4623
|
+
function toolPolicyAuditSnapshot(session, tools, firstPartyMcpTools, policy = session.toolPolicy) {
|
|
4608
4624
|
const allToolRefs = mergeToolRefs([], tools).sort((left, right) => {
|
|
4609
4625
|
const leftMandatory = left.kind === "mcp" && left.id === "opengeni";
|
|
4610
4626
|
const rightMandatory = right.kind === "mcp" && right.id === "opengeni";
|
|
@@ -4623,6 +4639,8 @@ function toolPolicyAuditSnapshot(session, tools, policy = session.toolPolicy ??
|
|
|
4623
4639
|
toolIds: [...toolRefs].sort((left, right) => `${left.kind}:${left.id}`.localeCompare(`${right.kind}:${right.id}`)).map((tool) => tool.id),
|
|
4624
4640
|
toolRefs,
|
|
4625
4641
|
toolCount: allToolRefs.length,
|
|
4642
|
+
firstPartyMcpTools: [...firstPartyMcpTools].sort(),
|
|
4643
|
+
firstPartyMcpToolCount: firstPartyMcpTools.length,
|
|
4626
4644
|
truncated: allToolRefs.length > toolRefs.length
|
|
4627
4645
|
};
|
|
4628
4646
|
}
|
|
@@ -4656,10 +4674,12 @@ async function updateSessionToolPolicy(deps, grant, sessionId, request) {
|
|
|
4656
4674
|
}
|
|
4657
4675
|
return withFirstPartyTools(validatedTools, runtimeSettings);
|
|
4658
4676
|
})() : null;
|
|
4677
|
+
const explicitRequestedFirstPartyTools = explicitRequest ? [...explicitRequest.firstPartyMcpTools] : null;
|
|
4659
4678
|
const workspaceDefaultTools = withFirstPartyTools(
|
|
4660
4679
|
withDefaultEnabledCapabilityMcpTools([], deps.settings, capabilityRuntimeSettings),
|
|
4661
4680
|
runtimeSettings
|
|
4662
4681
|
);
|
|
4682
|
+
const workspaceDefaultFirstPartyTools = [...FIRST_PARTY_MCP_TOOL_NAMES];
|
|
4663
4683
|
const events = await appendSessionEventsWithLockedSessionUpdate(
|
|
4664
4684
|
deps.db,
|
|
4665
4685
|
grant.workspaceId,
|
|
@@ -4670,6 +4690,7 @@ async function updateSessionToolPolicy(deps, grant, sessionId, request) {
|
|
|
4670
4690
|
throw new SessionToolPolicyVersionConflictError(currentVersion);
|
|
4671
4691
|
}
|
|
4672
4692
|
let nextTools;
|
|
4693
|
+
let nextFirstPartyMcpTools;
|
|
4673
4694
|
let nextPolicy;
|
|
4674
4695
|
if (session.parentSessionId) {
|
|
4675
4696
|
const parent = await context.getLockedSession(session.parentSessionId);
|
|
@@ -4685,6 +4706,9 @@ async function updateSessionToolPolicy(deps, grant, sessionId, request) {
|
|
|
4685
4706
|
) : parent.tools,
|
|
4686
4707
|
runtimeSettings
|
|
4687
4708
|
);
|
|
4709
|
+
const parentFirstPartyMcpTools = [
|
|
4710
|
+
...parent.firstPartyMcpTools ?? DEFAULT_FIRST_PARTY_MCP_TOOLS
|
|
4711
|
+
];
|
|
4688
4712
|
if (requestedMode === "workspace_default") {
|
|
4689
4713
|
if (!parentTracksWorkspaceDefaults) {
|
|
4690
4714
|
throw new HTTPException10(403, {
|
|
@@ -4692,6 +4716,7 @@ async function updateSessionToolPolicy(deps, grant, sessionId, request) {
|
|
|
4692
4716
|
});
|
|
4693
4717
|
}
|
|
4694
4718
|
nextTools = parentEffective;
|
|
4719
|
+
nextFirstPartyMcpTools = parentFirstPartyMcpTools;
|
|
4695
4720
|
nextPolicy = {
|
|
4696
4721
|
mode: "workspace_default",
|
|
4697
4722
|
inheritedFromSessionId: parent.id
|
|
@@ -4703,6 +4728,16 @@ async function updateSessionToolPolicy(deps, grant, sessionId, request) {
|
|
|
4703
4728
|
parentEffective,
|
|
4704
4729
|
"session tools may only narrow the parent session tool policy"
|
|
4705
4730
|
);
|
|
4731
|
+
const parentFirstPartySet = new Set(parentFirstPartyMcpTools);
|
|
4732
|
+
const widenedFirstPartyTool = explicitRequestedFirstPartyTools.find(
|
|
4733
|
+
(tool) => !parentFirstPartySet.has(tool)
|
|
4734
|
+
);
|
|
4735
|
+
if (widenedFirstPartyTool) {
|
|
4736
|
+
throw new HTTPException10(403, {
|
|
4737
|
+
message: `session OpenGeni tools may only narrow the parent policy: ${widenedFirstPartyTool}`
|
|
4738
|
+
});
|
|
4739
|
+
}
|
|
4740
|
+
nextFirstPartyMcpTools = explicitRequestedFirstPartyTools;
|
|
4706
4741
|
nextPolicy = {
|
|
4707
4742
|
mode: "explicit",
|
|
4708
4743
|
inheritedFromSessionId: parent.id
|
|
@@ -4710,13 +4745,19 @@ async function updateSessionToolPolicy(deps, grant, sessionId, request) {
|
|
|
4710
4745
|
}
|
|
4711
4746
|
} else {
|
|
4712
4747
|
nextTools = requestedMode === "workspace_default" ? workspaceDefaultTools : explicitRequestedTools;
|
|
4748
|
+
nextFirstPartyMcpTools = requestedMode === "workspace_default" ? workspaceDefaultFirstPartyTools : explicitRequestedFirstPartyTools;
|
|
4713
4749
|
nextPolicy = { mode: requestedMode, inheritedFromSessionId: null };
|
|
4714
4750
|
}
|
|
4715
|
-
const currentPolicy = session.toolPolicy
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4751
|
+
const currentPolicy = session.toolPolicy;
|
|
4752
|
+
const unchanged = stableJson2({
|
|
4753
|
+
tools: session.tools,
|
|
4754
|
+
firstPartyMcpTools: session.firstPartyMcpTools ?? DEFAULT_FIRST_PARTY_MCP_TOOLS,
|
|
4755
|
+
policy: currentPolicy
|
|
4756
|
+
}) === stableJson2({
|
|
4757
|
+
tools: nextTools,
|
|
4758
|
+
firstPartyMcpTools: nextFirstPartyMcpTools,
|
|
4759
|
+
policy: nextPolicy
|
|
4760
|
+
});
|
|
4720
4761
|
if (unchanged) {
|
|
4721
4762
|
return { events: [] };
|
|
4722
4763
|
}
|
|
@@ -4726,8 +4767,18 @@ async function updateSessionToolPolicy(deps, grant, sessionId, request) {
|
|
|
4726
4767
|
{
|
|
4727
4768
|
type: "session.tool_policy.updated",
|
|
4728
4769
|
payload: {
|
|
4729
|
-
before: toolPolicyAuditSnapshot(
|
|
4730
|
-
|
|
4770
|
+
before: toolPolicyAuditSnapshot(
|
|
4771
|
+
session,
|
|
4772
|
+
session.tools,
|
|
4773
|
+
[...session.firstPartyMcpTools ?? DEFAULT_FIRST_PARTY_MCP_TOOLS],
|
|
4774
|
+
currentPolicy
|
|
4775
|
+
),
|
|
4776
|
+
after: toolPolicyAuditSnapshot(
|
|
4777
|
+
session,
|
|
4778
|
+
nextTools,
|
|
4779
|
+
nextFirstPartyMcpTools,
|
|
4780
|
+
nextPolicy
|
|
4781
|
+
),
|
|
4731
4782
|
version: nextVersion,
|
|
4732
4783
|
effectiveFrom: "next_attempt"
|
|
4733
4784
|
}
|
|
@@ -4735,6 +4786,7 @@ async function updateSessionToolPolicy(deps, grant, sessionId, request) {
|
|
|
4735
4786
|
],
|
|
4736
4787
|
update: {
|
|
4737
4788
|
tools: nextTools,
|
|
4789
|
+
firstPartyMcpTools: nextFirstPartyMcpTools,
|
|
4738
4790
|
toolPolicy: nextPolicy,
|
|
4739
4791
|
toolPolicyVersion: nextVersion,
|
|
4740
4792
|
expectedToolPolicyVersion: request.expectedVersion
|
|
@@ -5305,14 +5357,14 @@ async function authorizeHumanSessionCommand(deps, context, operation) {
|
|
|
5305
5357
|
return await requireSessionAuthorization(deps, humanAccessGrant(context), {
|
|
5306
5358
|
sessionId: context.sessionId,
|
|
5307
5359
|
operation,
|
|
5308
|
-
surface: "core"
|
|
5360
|
+
surface: context.authorizationSurface ?? "core"
|
|
5309
5361
|
});
|
|
5310
5362
|
}
|
|
5311
5363
|
async function authorizeAgentSessionCommand(deps, context, targetSessionId, operation) {
|
|
5312
5364
|
return await requireSessionAuthorization(deps, agentAccessGrant(context), {
|
|
5313
5365
|
sessionId: targetSessionId,
|
|
5314
5366
|
operation,
|
|
5315
|
-
surface: "core"
|
|
5367
|
+
surface: context.authorizationSurface ?? "core"
|
|
5316
5368
|
});
|
|
5317
5369
|
}
|
|
5318
5370
|
function agentActor(context) {
|
|
@@ -5443,7 +5495,12 @@ async function steerAgentSession(deps, context, input) {
|
|
|
5443
5495
|
return result;
|
|
5444
5496
|
}
|
|
5445
5497
|
async function controlAgentSessionWorkstream(deps, context, input) {
|
|
5446
|
-
await authorizeAgentSessionCommand(
|
|
5498
|
+
const authorization = await authorizeAgentSessionCommand(
|
|
5499
|
+
deps,
|
|
5500
|
+
context,
|
|
5501
|
+
input.targetSessionId,
|
|
5502
|
+
"session.control"
|
|
5503
|
+
);
|
|
5447
5504
|
const result = await withWorkspaceRls(
|
|
5448
5505
|
deps.db,
|
|
5449
5506
|
context.workspaceId,
|
|
@@ -5464,7 +5521,7 @@ async function controlAgentSessionWorkstream(deps, context, input) {
|
|
|
5464
5521
|
]);
|
|
5465
5522
|
await publishWorkspaceControlEvent(deps, context.workspaceId, result.workspaceControlEventId);
|
|
5466
5523
|
await requestControlWakeDispatch(deps, result.wakeCount);
|
|
5467
|
-
return result;
|
|
5524
|
+
return { ...result, authorization };
|
|
5468
5525
|
}
|
|
5469
5526
|
function receipt(row) {
|
|
5470
5527
|
return {
|
|
@@ -5486,8 +5543,6 @@ function composerDraft(row) {
|
|
|
5486
5543
|
revision: row.revision,
|
|
5487
5544
|
text: row.text,
|
|
5488
5545
|
resources: row.resources,
|
|
5489
|
-
tools: row.tools,
|
|
5490
|
-
toolsProvided: row.toolsProvided,
|
|
5491
5546
|
model: row.model,
|
|
5492
5547
|
reasoningEffort: row.reasoningEffort,
|
|
5493
5548
|
sourceTurnId: row.sourceTurnId,
|
|
@@ -5705,8 +5760,6 @@ async function getHumanComposerDraft(deps, context) {
|
|
|
5705
5760
|
revision: 0,
|
|
5706
5761
|
text: "",
|
|
5707
5762
|
resources: [],
|
|
5708
|
-
tools: [],
|
|
5709
|
-
toolsProvided: false,
|
|
5710
5763
|
model: session.model,
|
|
5711
5764
|
reasoningEffort: reasoningEffortForMetadata2(session.metadata, "medium"),
|
|
5712
5765
|
sourceTurnId: null,
|
|
@@ -5832,6 +5885,7 @@ export {
|
|
|
5832
5885
|
requireVariableSetEncryption,
|
|
5833
5886
|
requireVariableSetForApi,
|
|
5834
5887
|
resolveCapabilityPack,
|
|
5888
|
+
resolveFirstPartyMcpToolsForCreate,
|
|
5835
5889
|
resolveMemberSubjectId,
|
|
5836
5890
|
resolveSessionToolPolicy,
|
|
5837
5891
|
restoreScheduledTask,
|
|
@@ -5848,6 +5902,7 @@ export {
|
|
|
5848
5902
|
sessionSpawnDenialEnvelope,
|
|
5849
5903
|
sessionToolPolicyAllowsDefaultNativeTools,
|
|
5850
5904
|
sessionWithEffectiveToolPolicy,
|
|
5905
|
+
settingsWithCodexAppsMcpServer,
|
|
5851
5906
|
settingsWithEnabledCapabilityMcpServers,
|
|
5852
5907
|
settingsWithMcpCapabilityServers,
|
|
5853
5908
|
settingsWithSessionMcpServerMetadata,
|