@opengeni/core 4.0.0 → 4.0.1
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/application/new-session-drafts.d.ts +96 -0
- package/dist/domain/knowledge-messages.d.ts +2 -2
- package/dist/domain/pr-review.d.ts +2 -2
- package/dist/domain/session-tool-policy.d.ts +9 -0
- package/dist/domain/sessions.d.ts +22 -0
- package/dist/index.js +257 -179
- package/dist/index.js.map +1 -1
- package/dist/sandbox/fleet.d.ts +1 -1
- package/dist/sandbox/runtime-settings.d.ts +7 -0
- package/package.json +10 -10
- package/src/application/new-session-drafts.ts +42 -0
- package/src/domain/github-skill-source.ts +3 -1
- package/src/domain/session-tool-policy.ts +18 -2
- package/src/domain/sessions.ts +70 -11
- package/src/model-catalog.ts +35 -31
- package/src/sandbox/fleet.ts +5 -4
- package/src/sandbox/runtime-settings.ts +23 -0
package/dist/index.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ManagedAuthActorLeaseOutcomeUnknownError,
|
|
3
|
+
getManagedAuthRequestActorAbortSignal,
|
|
4
|
+
getManagedAuthRequestActorAdmissionStamp,
|
|
5
|
+
getManagedAuthRequestActorEpoch,
|
|
6
|
+
getManagedAuthRequestActorLeaseStamp,
|
|
7
|
+
getManagedSession,
|
|
8
|
+
markManagedAuthRequestActorTransitionApplied,
|
|
9
|
+
releaseManagedAuthRequestActorLease,
|
|
10
|
+
validateManagedAuthRequestActorLease
|
|
11
|
+
} from "./chunk-OF65T3PM.js";
|
|
12
|
+
import "./chunk-QO5GVFFO.js";
|
|
1
13
|
import {
|
|
2
14
|
EDITABLE_ARTIFACT_HINT_MAX_BYTES,
|
|
3
15
|
EDITABLE_ARTIFACT_HINT_SUBJECT_PREFIX,
|
|
@@ -26,18 +38,6 @@ import {
|
|
|
26
38
|
encodeEditableArtifactLiveServerWireFrame,
|
|
27
39
|
inspectEditableArtifactLiveWireEnvelope
|
|
28
40
|
} from "./chunk-ZYCNLYGH.js";
|
|
29
|
-
import {
|
|
30
|
-
ManagedAuthActorLeaseOutcomeUnknownError,
|
|
31
|
-
getManagedAuthRequestActorAbortSignal,
|
|
32
|
-
getManagedAuthRequestActorAdmissionStamp,
|
|
33
|
-
getManagedAuthRequestActorEpoch,
|
|
34
|
-
getManagedAuthRequestActorLeaseStamp,
|
|
35
|
-
getManagedSession,
|
|
36
|
-
markManagedAuthRequestActorTransitionApplied,
|
|
37
|
-
releaseManagedAuthRequestActorLease,
|
|
38
|
-
validateManagedAuthRequestActorLease
|
|
39
|
-
} from "./chunk-OF65T3PM.js";
|
|
40
|
-
import "./chunk-QO5GVFFO.js";
|
|
41
41
|
import {
|
|
42
42
|
EDITABLE_ARTIFACT_EXPORT_MAX_DOWNLOAD_BYTES,
|
|
43
43
|
EDITABLE_ARTIFACT_EXPORT_MAX_OPTIONS_BYTES,
|
|
@@ -1501,6 +1501,7 @@ import {
|
|
|
1501
1501
|
configuredGatewayWorkspaceProductModelIds,
|
|
1502
1502
|
configuredGatewayOrganizationProductModelIds,
|
|
1503
1503
|
configuredModels,
|
|
1504
|
+
isModelAvailableForNewSelection,
|
|
1504
1505
|
configuredModelNotes,
|
|
1505
1506
|
configuredOpenRouterWorkspaceProductModelIds,
|
|
1506
1507
|
configuredOpenRouterOrganizationProductModelIds,
|
|
@@ -1944,7 +1945,7 @@ function resolveWorkspaceModelSelection(input) {
|
|
|
1944
1945
|
const requestedNowMs = input.now?.getTime();
|
|
1945
1946
|
const nowMs = typeof requestedNowMs === "number" && Number.isFinite(requestedNowMs) ? requestedNowMs : Date.now();
|
|
1946
1947
|
const maxAgeMs = typeof input.credentialReadinessMaxAgeMs === "number" && Number.isFinite(input.credentialReadinessMaxAgeMs) && input.credentialReadinessMaxAgeMs >= 0 ? input.credentialReadinessMaxAgeMs : MODEL_CREDENTIAL_READINESS_OBSERVATION_MAX_AGE_MS;
|
|
1947
|
-
return configuredModels(catalogSettings).map((model) => {
|
|
1948
|
+
return configuredModels(catalogSettings).filter((model) => isModelAvailableForNewSelection(catalogSettings, model.id)).map((model) => {
|
|
1948
1949
|
const provider = providers.get(model.providerId);
|
|
1949
1950
|
const policyAllowed = evaluateWorkspaceModelPolicy(input.policy, {
|
|
1950
1951
|
providerId: model.providerId,
|
|
@@ -2462,6 +2463,21 @@ function managedSessionGroupBackend(deploymentBackend, sessionBackend) {
|
|
|
2462
2463
|
const backend = sessionBackend === "selfhosted" ? deploymentBackend : sessionBackend;
|
|
2463
2464
|
return backend === "none" || backend === "selfhosted" ? null : backend;
|
|
2464
2465
|
}
|
|
2466
|
+
var SESSION_GROUP_MACHINE_NAMES = {
|
|
2467
|
+
local: "this computer",
|
|
2468
|
+
docker: "Docker",
|
|
2469
|
+
modal: "Modal",
|
|
2470
|
+
daytona: "Daytona",
|
|
2471
|
+
runloop: "Runloop",
|
|
2472
|
+
e2b: "E2B",
|
|
2473
|
+
blaxel: "Blaxel",
|
|
2474
|
+
cloudflare: "Cloudflare",
|
|
2475
|
+
vercel: "Vercel",
|
|
2476
|
+
opensandbox: "OpenSandbox"
|
|
2477
|
+
};
|
|
2478
|
+
function sessionGroupMachinePresentation(backend) {
|
|
2479
|
+
return { name: SESSION_GROUP_MACHINE_NAMES[backend], kind: backend };
|
|
2480
|
+
}
|
|
2465
2481
|
function managedSessionGroupOs(sessionBackend, sessionOs) {
|
|
2466
2482
|
return sessionBackend === "selfhosted" ? "linux" : sessionOs;
|
|
2467
2483
|
}
|
|
@@ -2671,10 +2687,11 @@ async function listFleet(services, ctx) {
|
|
|
2671
2687
|
groupLease && (groupLease.recovery.restore.status === "degraded" || groupLease.recovery.restore.status === "unrecoverable" || groupLease.recovery.workspace.status === "degraded" || groupLease.recovery.workspace.status === "unrecoverable")
|
|
2672
2688
|
);
|
|
2673
2689
|
const groupOperationAvailability = groupOnline ? "ready" : groupRecoveryUnavailable ? "unavailable" : groupRecovering ? "recovering" : "wakeable";
|
|
2690
|
+
const presentation = sessionGroupMachinePresentation(groupBackend);
|
|
2674
2691
|
entries.push({
|
|
2675
2692
|
id: ctx.sessionGroupId,
|
|
2676
|
-
kind:
|
|
2677
|
-
name:
|
|
2693
|
+
kind: presentation.kind,
|
|
2694
|
+
name: presentation.name,
|
|
2678
2695
|
liveness: groupOnline ? "online" : groupRecovering ? "reconnecting" : "offline",
|
|
2679
2696
|
active: groupActive,
|
|
2680
2697
|
isSessionGroup: true,
|
|
@@ -3666,6 +3683,7 @@ function sessionCreationMetadata(metadata) {
|
|
|
3666
3683
|
import {
|
|
3667
3684
|
canonicalizeConfiguredModelId,
|
|
3668
3685
|
configuredAllowedModels,
|
|
3686
|
+
withCodexCatalogProvider as withCodexCatalogProvider2,
|
|
3669
3687
|
ORGANIZATION_GATEWAY_MODEL_ID_PREFIX as ORGANIZATION_GATEWAY_MODEL_ID_PREFIX2,
|
|
3670
3688
|
ORGANIZATION_OPENROUTER_MODEL_ID_PREFIX as ORGANIZATION_OPENROUTER_MODEL_ID_PREFIX2,
|
|
3671
3689
|
resolveFirstPartyMcpToolPolicy,
|
|
@@ -3691,7 +3709,7 @@ import {
|
|
|
3691
3709
|
ServiceTurnInitiatorContext,
|
|
3692
3710
|
evaluateWorkspaceModelPolicy as evaluateWorkspaceModelPolicy2,
|
|
3693
3711
|
normalizeAutomaticSessionTitle,
|
|
3694
|
-
resolveWorkspaceSessionToolDefaults,
|
|
3712
|
+
resolveWorkspaceSessionToolDefaults as resolveWorkspaceSessionToolDefaults2,
|
|
3695
3713
|
metadataWithTurnExecutionPolicyV1,
|
|
3696
3714
|
readTurnExecutionPolicyV1,
|
|
3697
3715
|
stableJson as stableJson3,
|
|
@@ -3726,7 +3744,7 @@ import {
|
|
|
3726
3744
|
getSessionTurnPersonalConnectionDelegations as getSessionTurnPersonalConnectionDelegations2,
|
|
3727
3745
|
getSessionTurnXaiProviderAccountAuthoritySnapshot,
|
|
3728
3746
|
getWorkspaceModelPolicy,
|
|
3729
|
-
requireWorkspace as
|
|
3747
|
+
requireWorkspace as requireWorkspace4,
|
|
3730
3748
|
initializeSessionStartAtomically,
|
|
3731
3749
|
listSessionTurns,
|
|
3732
3750
|
listSessionMcpServersForChildInheritance,
|
|
@@ -5580,6 +5598,153 @@ function storedConnectionRef(config) {
|
|
|
5580
5598
|
return !!ref && typeof ref === "object" && !Array.isArray(ref) && typeof ref.providerDomain === "string";
|
|
5581
5599
|
}
|
|
5582
5600
|
|
|
5601
|
+
// src/domain/session-tool-policy.ts
|
|
5602
|
+
import {
|
|
5603
|
+
SESSION_EFFECTIVE_TOOL_POLICY_ID_LIMIT,
|
|
5604
|
+
SESSION_EFFECTIVE_TOOL_POLICY_ID_MAX_LENGTH,
|
|
5605
|
+
mergeToolRefs,
|
|
5606
|
+
resolveWorkspaceSessionToolDefaults
|
|
5607
|
+
} from "@opengeni/contracts";
|
|
5608
|
+
import { requireWorkspace as requireWorkspace3 } from "@opengeni/db";
|
|
5609
|
+
var MANDATORY_SESSION_MCP_SERVER_IDS = ["opengeni"];
|
|
5610
|
+
var PROJECTABLE_REGISTRY_ID = /^[A-Za-z0-9_-]+$/;
|
|
5611
|
+
function sortedIds(ids) {
|
|
5612
|
+
return [...new Set(ids)].sort();
|
|
5613
|
+
}
|
|
5614
|
+
function defaultSessionMcpServerIds(servers) {
|
|
5615
|
+
const mandatory = new Set(MANDATORY_SESSION_MCP_SERVER_IDS);
|
|
5616
|
+
return sortedIds([...servers].map((server) => server.id).filter((id) => !mandatory.has(id)));
|
|
5617
|
+
}
|
|
5618
|
+
function projectIds(ids) {
|
|
5619
|
+
const projectable = ids.filter(
|
|
5620
|
+
(id) => id.length <= SESSION_EFFECTIVE_TOOL_POLICY_ID_MAX_LENGTH && PROJECTABLE_REGISTRY_ID.test(id)
|
|
5621
|
+
);
|
|
5622
|
+
return {
|
|
5623
|
+
ids: projectable.slice(0, SESSION_EFFECTIVE_TOOL_POLICY_ID_LIMIT),
|
|
5624
|
+
truncated: projectable.length !== ids.length || projectable.length > SESSION_EFFECTIVE_TOOL_POLICY_ID_LIMIT
|
|
5625
|
+
};
|
|
5626
|
+
}
|
|
5627
|
+
function resolveSessionToolPolicy(input) {
|
|
5628
|
+
const policy = input.toolPolicy;
|
|
5629
|
+
const availableIds = new Set(input.availableMcpServerIds);
|
|
5630
|
+
const defaultIds = new Set(input.defaultMcpServerIds ?? []);
|
|
5631
|
+
const mandatoryIds = MANDATORY_SESSION_MCP_SERVER_IDS.filter(
|
|
5632
|
+
(id) => availableIds.has(id)
|
|
5633
|
+
);
|
|
5634
|
+
const mandatoryIdSet = new Set(mandatoryIds);
|
|
5635
|
+
const tracksWorkspaceDefaults = policy.mode === "workspace_default";
|
|
5636
|
+
const excludedIds = new Set(tracksWorkspaceDefaults ? policy.excludedMcpServerIds : []);
|
|
5637
|
+
const selectedRefs = mergeToolRefs([], input.sessionTools).filter(
|
|
5638
|
+
(tool) => !excludedIds.has(tool.id) || mandatoryIdSet.has(tool.id)
|
|
5639
|
+
);
|
|
5640
|
+
let toolRefs = selectedRefs.filter((tool) => availableIds.has(tool.id));
|
|
5641
|
+
if (tracksWorkspaceDefaults) {
|
|
5642
|
+
toolRefs = mergeToolRefs(
|
|
5643
|
+
toolRefs,
|
|
5644
|
+
sortedIds(defaultIds).filter((id) => availableIds.has(id) && !excludedIds.has(id)).map((id) => ({ kind: "mcp", id, optional: true }))
|
|
5645
|
+
);
|
|
5646
|
+
}
|
|
5647
|
+
toolRefs = mergeToolRefs(
|
|
5648
|
+
toolRefs,
|
|
5649
|
+
mandatoryIds.map((id) => ({ kind: "mcp", id }))
|
|
5650
|
+
);
|
|
5651
|
+
const requestedEffectiveRefs = mergeToolRefs(
|
|
5652
|
+
selectedRefs,
|
|
5653
|
+
tracksWorkspaceDefaults ? sortedIds(defaultIds).filter((id) => availableIds.has(id) && !excludedIds.has(id)).map((id) => ({ kind: "mcp", id, optional: true })) : []
|
|
5654
|
+
);
|
|
5655
|
+
const effectiveIds = sortedIds(
|
|
5656
|
+
mergeToolRefs(
|
|
5657
|
+
requestedEffectiveRefs,
|
|
5658
|
+
mandatoryIds.map((id) => ({ kind: "mcp", id }))
|
|
5659
|
+
).map((tool) => tool.id)
|
|
5660
|
+
);
|
|
5661
|
+
const configuredIds = effectiveIds.filter((id) => availableIds.has(id));
|
|
5662
|
+
const configuredIdSet = new Set(configuredIds);
|
|
5663
|
+
const droppedIds = effectiveIds.filter((id) => !configuredIdSet.has(id));
|
|
5664
|
+
const deferredIds = sortedIds(
|
|
5665
|
+
toolRefs.filter((tool) => configuredIdSet.has(tool.id) && tool.eager !== true).map((tool) => tool.id)
|
|
5666
|
+
);
|
|
5667
|
+
const selectedIds = sortedIds(
|
|
5668
|
+
selectedRefs.filter(
|
|
5669
|
+
(tool) => !mandatoryIdSet.has(tool.id) && !(tracksWorkspaceDefaults && tool.optional === true)
|
|
5670
|
+
).map((tool) => tool.id)
|
|
5671
|
+
);
|
|
5672
|
+
const projections = {
|
|
5673
|
+
selected: projectIds(selectedIds),
|
|
5674
|
+
effective: projectIds(effectiveIds),
|
|
5675
|
+
mandatory: projectIds(sortedIds(mandatoryIds)),
|
|
5676
|
+
deferred: projectIds(deferredIds),
|
|
5677
|
+
configured: projectIds(configuredIds),
|
|
5678
|
+
dropped: projectIds(droppedIds)
|
|
5679
|
+
};
|
|
5680
|
+
return {
|
|
5681
|
+
toolRefs,
|
|
5682
|
+
effectivePolicy: {
|
|
5683
|
+
mode: policy.mode,
|
|
5684
|
+
inheritedFromSessionId: policy.inheritedFromSessionId,
|
|
5685
|
+
selectedIds: projections.selected.ids,
|
|
5686
|
+
effectiveIds: projections.effective.ids,
|
|
5687
|
+
mandatoryIds: projections.mandatory.ids,
|
|
5688
|
+
lazyRouter: {
|
|
5689
|
+
state: deferredIds.length > 0 ? "required" : "disabled",
|
|
5690
|
+
deferredIds: projections.deferred.ids
|
|
5691
|
+
},
|
|
5692
|
+
configuredIds: projections.configured.ids,
|
|
5693
|
+
droppedIds: projections.dropped.ids,
|
|
5694
|
+
counts: {
|
|
5695
|
+
selected: selectedIds.length,
|
|
5696
|
+
effective: effectiveIds.length,
|
|
5697
|
+
mandatory: mandatoryIds.length,
|
|
5698
|
+
deferred: deferredIds.length,
|
|
5699
|
+
configured: configuredIds.length,
|
|
5700
|
+
dropped: droppedIds.length
|
|
5701
|
+
},
|
|
5702
|
+
idsTruncated: Object.values(projections).some((projection) => projection.truncated)
|
|
5703
|
+
}
|
|
5704
|
+
};
|
|
5705
|
+
}
|
|
5706
|
+
async function workspaceSessionToolPolicyServerIds(db, workspaceId, settings, subjectId) {
|
|
5707
|
+
const runtimeSettings = await settingsWithEnabledCapabilityMcpServers(db, workspaceId, settings, {
|
|
5708
|
+
...subjectId ? { subjectId } : {}
|
|
5709
|
+
});
|
|
5710
|
+
return sortedIds(runtimeSettings.mcpServers.map((server) => server.id));
|
|
5711
|
+
}
|
|
5712
|
+
async function workspaceSessionToolPolicyDefaultServerIds(db, workspaceId, settings, subjectId) {
|
|
5713
|
+
const runtimeSettings = await settingsWithEnabledCapabilityMcpServers(db, workspaceId, settings, {
|
|
5714
|
+
...subjectId ? { subjectId } : {}
|
|
5715
|
+
});
|
|
5716
|
+
const workspace = await requireWorkspace3(db, workspaceId);
|
|
5717
|
+
return workspaceSessionToolPolicyDefaultServerIdsFor(
|
|
5718
|
+
runtimeSettings.mcpServers,
|
|
5719
|
+
workspace.settings
|
|
5720
|
+
);
|
|
5721
|
+
}
|
|
5722
|
+
function workspaceSessionToolPolicyDefaultServerIdsFor(runtimeMcpServers, workspaceSettings) {
|
|
5723
|
+
const availableDefaults = defaultSessionMcpServerIds(runtimeMcpServers);
|
|
5724
|
+
const configured = resolveWorkspaceSessionToolDefaults(workspaceSettings);
|
|
5725
|
+
if (!configured?.mcpServerIds) return availableDefaults;
|
|
5726
|
+
const available = new Set(availableDefaults);
|
|
5727
|
+
return sortedIds([
|
|
5728
|
+
...configured.mcpServerIds.filter((id) => available.has(id)),
|
|
5729
|
+
...configured.inheritConnectedMcpServers ? availableDefaults.filter((id) => !["opengeni", "files", "docs"].includes(id)) : []
|
|
5730
|
+
]);
|
|
5731
|
+
}
|
|
5732
|
+
function sessionWithEffectiveToolPolicy(session, workspaceServerIds, workspaceDefaultServerIds = []) {
|
|
5733
|
+
const availableIds = new Set(workspaceServerIds);
|
|
5734
|
+
for (const server of session.mcpServers) {
|
|
5735
|
+
availableIds.add(server.id);
|
|
5736
|
+
}
|
|
5737
|
+
return {
|
|
5738
|
+
...session,
|
|
5739
|
+
effectiveToolPolicy: resolveSessionToolPolicy({
|
|
5740
|
+
toolPolicy: session.toolPolicy,
|
|
5741
|
+
sessionTools: session.tools,
|
|
5742
|
+
availableMcpServerIds: availableIds,
|
|
5743
|
+
defaultMcpServerIds: workspaceDefaultServerIds
|
|
5744
|
+
}).effectivePolicy
|
|
5745
|
+
};
|
|
5746
|
+
}
|
|
5747
|
+
|
|
5583
5748
|
// src/domain/timeline-annotations.ts
|
|
5584
5749
|
import {
|
|
5585
5750
|
DraftTimelineAnnotations,
|
|
@@ -5760,7 +5925,7 @@ import {
|
|
|
5760
5925
|
gitCredentialProviderForRepository,
|
|
5761
5926
|
defaultRepositoryMountPath,
|
|
5762
5927
|
mergeResourceRefs as mergeContractResourceRefs,
|
|
5763
|
-
mergeToolRefs,
|
|
5928
|
+
mergeToolRefs as mergeToolRefs2,
|
|
5764
5929
|
normalizeRepositorySubpath,
|
|
5765
5930
|
normalizeRepositoryTransportUri,
|
|
5766
5931
|
normalizeResourceMountPath,
|
|
@@ -5800,20 +5965,20 @@ function validateToolRefs(tools, settings) {
|
|
|
5800
5965
|
...tool.eager === true ? { eager: true } : {}
|
|
5801
5966
|
});
|
|
5802
5967
|
}
|
|
5803
|
-
return
|
|
5968
|
+
return mergeToolRefs2([], out);
|
|
5804
5969
|
}
|
|
5805
5970
|
function enabledCapabilityMcpToolRefs(settings, runtimeSettings) {
|
|
5806
5971
|
const configuredIds = new Set(settings.mcpServers.map((server) => server.id));
|
|
5807
5972
|
return runtimeSettings.mcpServers.filter((server) => !configuredIds.has(server.id)).map((server) => ({ kind: "mcp", id: server.id, optional: true }));
|
|
5808
5973
|
}
|
|
5809
5974
|
function withDefaultEnabledCapabilityMcpTools(tools, settings, runtimeSettings) {
|
|
5810
|
-
return
|
|
5975
|
+
return mergeToolRefs2(tools, enabledCapabilityMcpToolRefs(settings, runtimeSettings));
|
|
5811
5976
|
}
|
|
5812
5977
|
function withWorkspaceDefaultMcpTools(tools, settings, runtimeSettings, defaults2) {
|
|
5813
5978
|
if (!defaults2?.mcpServerIds) {
|
|
5814
5979
|
return withDefaultEnabledCapabilityMcpTools(tools, settings, runtimeSettings);
|
|
5815
5980
|
}
|
|
5816
|
-
return
|
|
5981
|
+
return mergeToolRefs2(
|
|
5817
5982
|
tools,
|
|
5818
5983
|
validateToolRefs(
|
|
5819
5984
|
[
|
|
@@ -7855,6 +8020,12 @@ function canonicalConfiguredModel(settings, model) {
|
|
|
7855
8020
|
return model;
|
|
7856
8021
|
}
|
|
7857
8022
|
const canonicalModel = canonicalizeConfiguredModelId(settings, model);
|
|
8023
|
+
if (canonicalModel.startsWith(CODEX_MODEL_ID_PREFIX) && settings.resolvedCodexModelsJson !== void 0) {
|
|
8024
|
+
if (settings.codexSubscriptionEnabled && configuredAllowedModels(withCodexCatalogProvider2(settings)).includes(canonicalModel)) {
|
|
8025
|
+
return canonicalModel;
|
|
8026
|
+
}
|
|
8027
|
+
throw new HTTPException15(422, { message: `model is not available: ${model}` });
|
|
8028
|
+
}
|
|
7858
8029
|
if (configuredAllowedModels(settings).includes(canonicalModel)) {
|
|
7859
8030
|
return canonicalModel;
|
|
7860
8031
|
}
|
|
@@ -8383,8 +8554,8 @@ async function createSessionForRequestInFileScope(unresolvedDeps, grant, workspa
|
|
|
8383
8554
|
message: `parent session not found in workspace: ${parentSessionId}`
|
|
8384
8555
|
});
|
|
8385
8556
|
}
|
|
8386
|
-
const workspace = await
|
|
8387
|
-
const workspaceSessionToolDefaults =
|
|
8557
|
+
const workspace = await requireWorkspace4(db, workspaceId);
|
|
8558
|
+
const workspaceSessionToolDefaults = resolveWorkspaceSessionToolDefaults2(workspace.settings);
|
|
8388
8559
|
const parentAuthority = parentSession ? await getSessionAuthorityProjection4(db, workspaceId, parentSession.id) : null;
|
|
8389
8560
|
if (parentSession && !parentAuthority) {
|
|
8390
8561
|
throw new HTTPException15(403, {
|
|
@@ -9426,23 +9597,32 @@ async function acceptSessionUserMessageInFileScope(deps, grant, workspaceId, ses
|
|
|
9426
9597
|
connectionDelegationSource.sessionId,
|
|
9427
9598
|
connectionDelegationSource.turnId
|
|
9428
9599
|
) : null;
|
|
9600
|
+
const capabilityRuntimeSettings = await settingsWithEnabledCapabilityMcpServers(
|
|
9601
|
+
db,
|
|
9602
|
+
workspaceId,
|
|
9603
|
+
settings,
|
|
9604
|
+
inheritedPersonalConnectionDelegations ? {
|
|
9605
|
+
personalConnectionDelegations: inheritedPersonalConnectionDelegations
|
|
9606
|
+
} : { subjectId: grant.subjectId }
|
|
9607
|
+
);
|
|
9429
9608
|
const runtimeSettings = settingsWithSessionMcpServerMetadata(
|
|
9430
|
-
|
|
9431
|
-
db,
|
|
9432
|
-
workspaceId,
|
|
9433
|
-
settings,
|
|
9434
|
-
inheritedPersonalConnectionDelegations ? {
|
|
9435
|
-
personalConnectionDelegations: inheritedPersonalConnectionDelegations
|
|
9436
|
-
} : { subjectId: grant.subjectId }
|
|
9437
|
-
),
|
|
9609
|
+
capabilityRuntimeSettings,
|
|
9438
9610
|
existingSession.mcpServers
|
|
9439
9611
|
);
|
|
9612
|
+
const connectionAccountTools = sessionToolsForConnectionAccounts({
|
|
9613
|
+
session: existingSession,
|
|
9614
|
+
runtimeMcpServers: runtimeSettings.mcpServers,
|
|
9615
|
+
defaultMcpServerIds: workspaceSessionToolPolicyDefaultServerIdsFor(
|
|
9616
|
+
capabilityRuntimeSettings.mcpServers,
|
|
9617
|
+
(await requireWorkspace4(db, workspaceId)).settings
|
|
9618
|
+
)
|
|
9619
|
+
});
|
|
9440
9620
|
const { personalConnectionDelegations, mcpAccountBindings } = await freezeConnectionAccounts({
|
|
9441
9621
|
db,
|
|
9442
9622
|
accountId: grant.accountId,
|
|
9443
9623
|
workspaceId,
|
|
9444
9624
|
settings: runtimeSettings,
|
|
9445
|
-
tools:
|
|
9625
|
+
tools: connectionAccountTools,
|
|
9446
9626
|
resources: [...existingSession.resources, ...requestedResources],
|
|
9447
9627
|
source: connectionDelegationSource,
|
|
9448
9628
|
targetSessionId: sessionId,
|
|
@@ -9607,7 +9787,7 @@ async function updateSessionMcpApprovalPolicy(deps, grant, sessionId, serverId,
|
|
|
9607
9787
|
};
|
|
9608
9788
|
}
|
|
9609
9789
|
function toolPolicyAuditSnapshot(session, tools, firstPartyMcpTools, policy = session.toolPolicy) {
|
|
9610
|
-
const allToolRefs =
|
|
9790
|
+
const allToolRefs = mergeToolRefs2([], tools).sort((left, right) => {
|
|
9611
9791
|
const leftMandatory = left.kind === "mcp" && left.id === "opengeni";
|
|
9612
9792
|
const rightMandatory = right.kind === "mcp" && right.id === "opengeni";
|
|
9613
9793
|
if (leftMandatory !== rightMandatory) return leftMandatory ? -1 : 1;
|
|
@@ -9644,8 +9824,8 @@ async function updateSessionToolPolicy(deps, grant, sessionId, request) {
|
|
|
9644
9824
|
requirePermission(grant, "sessions:control");
|
|
9645
9825
|
const agentAttemptCaller = grantHasAgentAttemptAuthority(grant);
|
|
9646
9826
|
const existingSession = await requireSession2(deps.db, grant.workspaceId, sessionId);
|
|
9647
|
-
const workspace = await
|
|
9648
|
-
const workspaceSessionToolDefaults =
|
|
9827
|
+
const workspace = await requireWorkspace4(deps.db, grant.workspaceId);
|
|
9828
|
+
const workspaceSessionToolDefaults = resolveWorkspaceSessionToolDefaults2(workspace.settings);
|
|
9649
9829
|
const capabilityRuntimeSettings = await settingsWithEnabledCapabilityMcpServers(
|
|
9650
9830
|
deps.db,
|
|
9651
9831
|
grant.workspaceId,
|
|
@@ -9930,7 +10110,15 @@ function withFirstPartyTools(tools, runtimeSettings) {
|
|
|
9930
10110
|
if (!runtimeSettings.mcpServers.some((server) => server.id === "opengeni")) {
|
|
9931
10111
|
return tools;
|
|
9932
10112
|
}
|
|
9933
|
-
return
|
|
10113
|
+
return mergeToolRefs2(tools, [{ kind: "mcp", id: "opengeni" }]);
|
|
10114
|
+
}
|
|
10115
|
+
function sessionToolsForConnectionAccounts(input) {
|
|
10116
|
+
return resolveSessionToolPolicy({
|
|
10117
|
+
toolPolicy: input.session.toolPolicy,
|
|
10118
|
+
sessionTools: input.session.tools,
|
|
10119
|
+
availableMcpServerIds: [...input.runtimeMcpServers].map((server) => server.id),
|
|
10120
|
+
defaultMcpServerIds: input.defaultMcpServerIds
|
|
10121
|
+
}).toolRefs;
|
|
9934
10122
|
}
|
|
9935
10123
|
function hasOwnProperty(value, key) {
|
|
9936
10124
|
return Boolean(
|
|
@@ -10629,12 +10817,13 @@ import { HTTPException as HTTPException19 } from "hono/http-exception";
|
|
|
10629
10817
|
import { pinnedFetch as pinnedFetch2, readResponseJsonBounded as readResponseJsonBounded2, readResponseTextBounded } from "@opengeni/network";
|
|
10630
10818
|
import {
|
|
10631
10819
|
PORTABLE_SKILL_MAX_FILES as PORTABLE_SKILL_MAX_FILES2,
|
|
10820
|
+
PORTABLE_SKILL_MAX_FILE_BYTES as PORTABLE_SKILL_MAX_FILE_BYTES2,
|
|
10632
10821
|
PORTABLE_SKILL_MAX_TOTAL_BYTES as PORTABLE_SKILL_MAX_TOTAL_BYTES2
|
|
10633
10822
|
} from "@opengeni/runtime/skill-library";
|
|
10634
10823
|
var githubApiBase = "https://api.github.com";
|
|
10635
10824
|
var githubRequestTimeoutMs = 15e3;
|
|
10636
10825
|
var githubMetadataMaxBytes = 4 * 1024 * 1024;
|
|
10637
|
-
var githubBlobResponseMaxBytes =
|
|
10826
|
+
var githubBlobResponseMaxBytes = PORTABLE_SKILL_MAX_FILE_BYTES2 * 2;
|
|
10638
10827
|
function createGitHubSkillSourceClient(settings, requestJson = (path, maxBytes, label) => githubJson(settings, path, maxBytes, label)) {
|
|
10639
10828
|
const readJson = requestJson;
|
|
10640
10829
|
const cache = /* @__PURE__ */ new Map();
|
|
@@ -12187,147 +12376,6 @@ function personalGitHubActionPolicyActor(input) {
|
|
|
12187
12376
|
};
|
|
12188
12377
|
}
|
|
12189
12378
|
|
|
12190
|
-
// src/domain/session-tool-policy.ts
|
|
12191
|
-
import {
|
|
12192
|
-
SESSION_EFFECTIVE_TOOL_POLICY_ID_LIMIT,
|
|
12193
|
-
SESSION_EFFECTIVE_TOOL_POLICY_ID_MAX_LENGTH,
|
|
12194
|
-
mergeToolRefs as mergeToolRefs2,
|
|
12195
|
-
resolveWorkspaceSessionToolDefaults as resolveWorkspaceSessionToolDefaults2
|
|
12196
|
-
} from "@opengeni/contracts";
|
|
12197
|
-
import { requireWorkspace as requireWorkspace4 } from "@opengeni/db";
|
|
12198
|
-
var MANDATORY_SESSION_MCP_SERVER_IDS = ["opengeni"];
|
|
12199
|
-
var PROJECTABLE_REGISTRY_ID = /^[A-Za-z0-9_-]+$/;
|
|
12200
|
-
function sortedIds(ids) {
|
|
12201
|
-
return [...new Set(ids)].sort();
|
|
12202
|
-
}
|
|
12203
|
-
function defaultSessionMcpServerIds(servers) {
|
|
12204
|
-
const mandatory = new Set(MANDATORY_SESSION_MCP_SERVER_IDS);
|
|
12205
|
-
return sortedIds([...servers].map((server) => server.id).filter((id) => !mandatory.has(id)));
|
|
12206
|
-
}
|
|
12207
|
-
function projectIds(ids) {
|
|
12208
|
-
const projectable = ids.filter(
|
|
12209
|
-
(id) => id.length <= SESSION_EFFECTIVE_TOOL_POLICY_ID_MAX_LENGTH && PROJECTABLE_REGISTRY_ID.test(id)
|
|
12210
|
-
);
|
|
12211
|
-
return {
|
|
12212
|
-
ids: projectable.slice(0, SESSION_EFFECTIVE_TOOL_POLICY_ID_LIMIT),
|
|
12213
|
-
truncated: projectable.length !== ids.length || projectable.length > SESSION_EFFECTIVE_TOOL_POLICY_ID_LIMIT
|
|
12214
|
-
};
|
|
12215
|
-
}
|
|
12216
|
-
function resolveSessionToolPolicy(input) {
|
|
12217
|
-
const policy = input.toolPolicy;
|
|
12218
|
-
const availableIds = new Set(input.availableMcpServerIds);
|
|
12219
|
-
const defaultIds = new Set(input.defaultMcpServerIds ?? []);
|
|
12220
|
-
const mandatoryIds = MANDATORY_SESSION_MCP_SERVER_IDS.filter(
|
|
12221
|
-
(id) => availableIds.has(id)
|
|
12222
|
-
);
|
|
12223
|
-
const mandatoryIdSet = new Set(mandatoryIds);
|
|
12224
|
-
const tracksWorkspaceDefaults = policy.mode === "workspace_default";
|
|
12225
|
-
const excludedIds = new Set(tracksWorkspaceDefaults ? policy.excludedMcpServerIds : []);
|
|
12226
|
-
const selectedRefs = mergeToolRefs2([], input.sessionTools).filter(
|
|
12227
|
-
(tool) => !excludedIds.has(tool.id) || mandatoryIdSet.has(tool.id)
|
|
12228
|
-
);
|
|
12229
|
-
let toolRefs = selectedRefs.filter((tool) => availableIds.has(tool.id));
|
|
12230
|
-
if (tracksWorkspaceDefaults) {
|
|
12231
|
-
toolRefs = mergeToolRefs2(
|
|
12232
|
-
toolRefs,
|
|
12233
|
-
sortedIds(defaultIds).filter((id) => availableIds.has(id) && !excludedIds.has(id)).map((id) => ({ kind: "mcp", id, optional: true }))
|
|
12234
|
-
);
|
|
12235
|
-
}
|
|
12236
|
-
toolRefs = mergeToolRefs2(
|
|
12237
|
-
toolRefs,
|
|
12238
|
-
mandatoryIds.map((id) => ({ kind: "mcp", id }))
|
|
12239
|
-
);
|
|
12240
|
-
const requestedEffectiveRefs = mergeToolRefs2(
|
|
12241
|
-
selectedRefs,
|
|
12242
|
-
tracksWorkspaceDefaults ? sortedIds(defaultIds).filter((id) => availableIds.has(id) && !excludedIds.has(id)).map((id) => ({ kind: "mcp", id, optional: true })) : []
|
|
12243
|
-
);
|
|
12244
|
-
const effectiveIds = sortedIds(
|
|
12245
|
-
mergeToolRefs2(
|
|
12246
|
-
requestedEffectiveRefs,
|
|
12247
|
-
mandatoryIds.map((id) => ({ kind: "mcp", id }))
|
|
12248
|
-
).map((tool) => tool.id)
|
|
12249
|
-
);
|
|
12250
|
-
const configuredIds = effectiveIds.filter((id) => availableIds.has(id));
|
|
12251
|
-
const configuredIdSet = new Set(configuredIds);
|
|
12252
|
-
const droppedIds = effectiveIds.filter((id) => !configuredIdSet.has(id));
|
|
12253
|
-
const deferredIds = sortedIds(
|
|
12254
|
-
toolRefs.filter((tool) => configuredIdSet.has(tool.id) && tool.eager !== true).map((tool) => tool.id)
|
|
12255
|
-
);
|
|
12256
|
-
const selectedIds = sortedIds(
|
|
12257
|
-
selectedRefs.filter(
|
|
12258
|
-
(tool) => !mandatoryIdSet.has(tool.id) && !(tracksWorkspaceDefaults && tool.optional === true)
|
|
12259
|
-
).map((tool) => tool.id)
|
|
12260
|
-
);
|
|
12261
|
-
const projections = {
|
|
12262
|
-
selected: projectIds(selectedIds),
|
|
12263
|
-
effective: projectIds(effectiveIds),
|
|
12264
|
-
mandatory: projectIds(sortedIds(mandatoryIds)),
|
|
12265
|
-
deferred: projectIds(deferredIds),
|
|
12266
|
-
configured: projectIds(configuredIds),
|
|
12267
|
-
dropped: projectIds(droppedIds)
|
|
12268
|
-
};
|
|
12269
|
-
return {
|
|
12270
|
-
toolRefs,
|
|
12271
|
-
effectivePolicy: {
|
|
12272
|
-
mode: policy.mode,
|
|
12273
|
-
inheritedFromSessionId: policy.inheritedFromSessionId,
|
|
12274
|
-
selectedIds: projections.selected.ids,
|
|
12275
|
-
effectiveIds: projections.effective.ids,
|
|
12276
|
-
mandatoryIds: projections.mandatory.ids,
|
|
12277
|
-
lazyRouter: {
|
|
12278
|
-
state: deferredIds.length > 0 ? "required" : "disabled",
|
|
12279
|
-
deferredIds: projections.deferred.ids
|
|
12280
|
-
},
|
|
12281
|
-
configuredIds: projections.configured.ids,
|
|
12282
|
-
droppedIds: projections.dropped.ids,
|
|
12283
|
-
counts: {
|
|
12284
|
-
selected: selectedIds.length,
|
|
12285
|
-
effective: effectiveIds.length,
|
|
12286
|
-
mandatory: mandatoryIds.length,
|
|
12287
|
-
deferred: deferredIds.length,
|
|
12288
|
-
configured: configuredIds.length,
|
|
12289
|
-
dropped: droppedIds.length
|
|
12290
|
-
},
|
|
12291
|
-
idsTruncated: Object.values(projections).some((projection) => projection.truncated)
|
|
12292
|
-
}
|
|
12293
|
-
};
|
|
12294
|
-
}
|
|
12295
|
-
async function workspaceSessionToolPolicyServerIds(db, workspaceId, settings, subjectId) {
|
|
12296
|
-
const runtimeSettings = await settingsWithEnabledCapabilityMcpServers(db, workspaceId, settings, {
|
|
12297
|
-
...subjectId ? { subjectId } : {}
|
|
12298
|
-
});
|
|
12299
|
-
return sortedIds(runtimeSettings.mcpServers.map((server) => server.id));
|
|
12300
|
-
}
|
|
12301
|
-
async function workspaceSessionToolPolicyDefaultServerIds(db, workspaceId, settings, subjectId) {
|
|
12302
|
-
const runtimeSettings = await settingsWithEnabledCapabilityMcpServers(db, workspaceId, settings, {
|
|
12303
|
-
...subjectId ? { subjectId } : {}
|
|
12304
|
-
});
|
|
12305
|
-
const availableDefaults = defaultSessionMcpServerIds(runtimeSettings.mcpServers);
|
|
12306
|
-
const workspace = await requireWorkspace4(db, workspaceId);
|
|
12307
|
-
const configured = resolveWorkspaceSessionToolDefaults2(workspace.settings);
|
|
12308
|
-
if (!configured?.mcpServerIds) return availableDefaults;
|
|
12309
|
-
const available = new Set(availableDefaults);
|
|
12310
|
-
return sortedIds([
|
|
12311
|
-
...configured.mcpServerIds.filter((id) => available.has(id)),
|
|
12312
|
-
...configured.inheritConnectedMcpServers ? availableDefaults.filter((id) => !["opengeni", "files", "docs"].includes(id)) : []
|
|
12313
|
-
]);
|
|
12314
|
-
}
|
|
12315
|
-
function sessionWithEffectiveToolPolicy(session, workspaceServerIds, workspaceDefaultServerIds = []) {
|
|
12316
|
-
const availableIds = new Set(workspaceServerIds);
|
|
12317
|
-
for (const server of session.mcpServers) {
|
|
12318
|
-
availableIds.add(server.id);
|
|
12319
|
-
}
|
|
12320
|
-
return {
|
|
12321
|
-
...session,
|
|
12322
|
-
effectiveToolPolicy: resolveSessionToolPolicy({
|
|
12323
|
-
toolPolicy: session.toolPolicy,
|
|
12324
|
-
sessionTools: session.tools,
|
|
12325
|
-
availableMcpServerIds: availableIds,
|
|
12326
|
-
defaultMcpServerIds: workspaceDefaultServerIds
|
|
12327
|
-
}).effectivePolicy
|
|
12328
|
-
};
|
|
12329
|
-
}
|
|
12330
|
-
|
|
12331
12379
|
// src/domain/scheduled-tasks.ts
|
|
12332
12380
|
import {
|
|
12333
12381
|
scheduledTaskKnowledgeSource,
|
|
@@ -15932,6 +15980,7 @@ import {
|
|
|
15932
15980
|
publicNewSessionDraftOptions,
|
|
15933
15981
|
requireFileForSubject as requireFileForSubject2,
|
|
15934
15982
|
saveNewSessionDraftInTransaction,
|
|
15983
|
+
reusableNewSessionRepositoryResource,
|
|
15935
15984
|
withWorkspaceSubjectRls as withWorkspaceSubjectRls6
|
|
15936
15985
|
} from "@opengeni/db";
|
|
15937
15986
|
import { HTTPException as HTTPException23 } from "hono/http-exception";
|
|
@@ -16153,6 +16202,31 @@ async function saveActorNewSessionDraft(...args) {
|
|
|
16153
16202
|
const actor = authorization ? await fileOwnerContextForAccess(deps, authorization, "sessions:create") : { subjectId: grant.subjectId, privateFileOwnerSubjectId: null };
|
|
16154
16203
|
return withSessionRlsActorContext6(actor, () => saveActorNewSessionDraftInFileScope(...args));
|
|
16155
16204
|
}
|
|
16205
|
+
async function getActorNewSessionDefaults(deps, grant, workspaceId) {
|
|
16206
|
+
const draft = await getActorNewSessionDraft(deps, grant, workspaceId);
|
|
16207
|
+
const options = draft.options;
|
|
16208
|
+
return {
|
|
16209
|
+
// Revision zero is a synthetic empty form, not a user's model preference.
|
|
16210
|
+
...draft.revision > 0 ? {
|
|
16211
|
+
model: draft.model,
|
|
16212
|
+
reasoningEffort: draft.reasoningEffort,
|
|
16213
|
+
latencyMode: draft.latencyMode
|
|
16214
|
+
} : {},
|
|
16215
|
+
resources: draft.resources.flatMap(
|
|
16216
|
+
(resource) => resource.kind === "repository" ? [reusableNewSessionRepositoryResource(resource)] : []
|
|
16217
|
+
),
|
|
16218
|
+
...draft.toolsProvided ? { tools: draft.tools } : options.excludedMcpServerIds ? { excludedMcpServerIds: options.excludedMcpServerIds } : {},
|
|
16219
|
+
...options.firstPartyMcpTools ? { firstPartyMcpTools: options.firstPartyMcpTools } : {},
|
|
16220
|
+
...options.firstPartyMcpPermissions ? { firstPartyMcpPermissions: options.firstPartyMcpPermissions } : {},
|
|
16221
|
+
...options.variableSetIds ? { variableSetIds: options.variableSetIds } : {},
|
|
16222
|
+
...options.rigId ? { rigId: options.rigId } : {},
|
|
16223
|
+
...options.sandboxBackend ? { sandboxBackend: options.sandboxBackend } : {},
|
|
16224
|
+
...options.targetSandboxId ? {
|
|
16225
|
+
targetSandboxId: options.targetSandboxId,
|
|
16226
|
+
...options.workingDir ? { workingDir: options.workingDir } : {}
|
|
16227
|
+
} : {}
|
|
16228
|
+
};
|
|
16229
|
+
}
|
|
16156
16230
|
|
|
16157
16231
|
// src/application/composer-submit.ts
|
|
16158
16232
|
async function submitComposerDraftForRequest(deps, grant, workspaceId, sessionId, input, options = {}) {
|
|
@@ -17907,6 +17981,7 @@ export {
|
|
|
17907
17981
|
freezeAgentChildAutomaticTitleInCreatorContext,
|
|
17908
17982
|
freezeConnectionAccounts,
|
|
17909
17983
|
freezePersonalConnectionDelegations,
|
|
17984
|
+
getActorNewSessionDefaults,
|
|
17910
17985
|
getActorNewSessionDraft,
|
|
17911
17986
|
getAutomationAdapter,
|
|
17912
17987
|
getConnectorToolPermissions,
|
|
@@ -17977,7 +18052,7 @@ export {
|
|
|
17977
18052
|
mergeCausalFrontiers,
|
|
17978
18053
|
mergeResourceRefs,
|
|
17979
18054
|
mergeRigDefaultVariableSetEnvironment,
|
|
17980
|
-
mergeToolRefs,
|
|
18055
|
+
mergeToolRefs2 as mergeToolRefs,
|
|
17981
18056
|
modelFundingForAdmission,
|
|
17982
18057
|
moveHumanQueuePrompt,
|
|
17983
18058
|
nativeConnectionCapabilityRecommendations,
|
|
@@ -18128,9 +18203,11 @@ export {
|
|
|
18128
18203
|
searchKnowledgeEntries,
|
|
18129
18204
|
selectedPersonalConnectionServers,
|
|
18130
18205
|
sendAgentSessionMessage,
|
|
18206
|
+
sessionGroupMachinePresentation,
|
|
18131
18207
|
sessionMcpRotationFingerprint,
|
|
18132
18208
|
sessionRlsActorForAuthorization,
|
|
18133
18209
|
sessionSpawnDenialEnvelope,
|
|
18210
|
+
sessionToolsForConnectionAccounts,
|
|
18134
18211
|
sessionWithEffectiveToolPolicy,
|
|
18135
18212
|
settingsWithApiIntegrationServers,
|
|
18136
18213
|
settingsWithCodexAppsMcpServer,
|
|
@@ -18196,6 +18273,7 @@ export {
|
|
|
18196
18273
|
workspaceCustomModelReference,
|
|
18197
18274
|
workspaceInsightsPhaseMetricObserver,
|
|
18198
18275
|
workspaceSessionToolPolicyDefaultServerIds,
|
|
18276
|
+
workspaceSessionToolPolicyDefaultServerIdsFor,
|
|
18199
18277
|
workspaceSessionToolPolicyServerIds,
|
|
18200
18278
|
wrapChannelABoxWithRouting
|
|
18201
18279
|
};
|