@opengeni/core 0.12.2 → 0.12.5
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 +2 -1
- package/dist/index.js +39 -16
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/access/index.ts +5 -1
- package/src/domain/capabilities.ts +47 -23
- package/src/domain/sessions.ts +8 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Settings } from '@opengeni/config';
|
|
2
|
-
import { ScheduledTask, Document, GitHubAppApiPort, ConnectionCredentialsPort, SessionAuthorizationPort, Permission, AccessContext, AccessGrant, SessionAuthorizationActor, SessionAuthorizationTarget, SessionAuthorizationOperation, SessionAuthorizationSurface, SessionAuthorizationListScope, LimitAction, LimitDecision, TurnInitiator, 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, TurnExecutionPolicyV1, GoalSpec, SessionMcpServerMetadata, CreateSessionResponse, SessionMcpApprovalPolicy, UpdateSessionMcpApprovalPolicyResponse, UpdateSessionToolPolicyRequest, ConnectionMetadata, OpenGeniSlackBotConnectionMetadata, WorkspaceMember, NewSessionDraft, SessionControlRequest, SessionControlResponse, WorkspaceInferenceControlRequest, WorkspaceInferenceControlResponse, DeleteSessionQueueItemRequest, SessionQueueMutationResponse, EditSessionQueueItemRequest, ComposerDraft, MoveSessionQueueItemRequest, SaveComposerDraftRequest, SteerSessionQueueItemRequest } from '@opengeni/contracts';
|
|
2
|
+
import { ScheduledTask, Document, GitHubAppApiPort, ConnectionCredentialsPort, SessionAuthorizationPort, Permission, AccessContext, AccessGrant, SessionAuthorizationActor, SessionAuthorizationTarget, SessionAuthorizationOperation, SessionAuthorizationSurface, SessionAuthorizationListScope, LimitAction, LimitDecision, TurnInitiator, 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, 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
5
|
import { Database, SandboxRecord, EnabledMcpCapabilityServer, UpdateScheduledTaskInput, SessionCommandActor, CreateSessionMcpServerInput, UpdateSessionMcpServerCredentialsInput, ConnectionMetadataWithVerification } from '@opengeni/db';
|
|
@@ -831,6 +831,7 @@ declare function createAndStartSession(input: {
|
|
|
831
831
|
initialMessage: string;
|
|
832
832
|
turnInstructions?: string | null;
|
|
833
833
|
resources: ResourceRef[];
|
|
834
|
+
skills?: SessionSkill[];
|
|
834
835
|
tools: ToolRef[];
|
|
835
836
|
toolPolicy?: SessionToolPolicy;
|
|
836
837
|
clientEventId?: string;
|
package/dist/index.js
CHANGED
|
@@ -698,6 +698,10 @@ function hasPermission(permissions, permission) {
|
|
|
698
698
|
}
|
|
699
699
|
async function resolveAccessContext(c, deps) {
|
|
700
700
|
if (deps.settings.productAccessMode === "local") {
|
|
701
|
+
const delegated = await delegatedAccessContext(c, deps, "local");
|
|
702
|
+
if (delegated) {
|
|
703
|
+
return delegated;
|
|
704
|
+
}
|
|
701
705
|
return await bootstrapWorkspace(deps.db, {
|
|
702
706
|
accountExternalSource: "opengeni:local",
|
|
703
707
|
accountExternalId: "default",
|
|
@@ -1200,6 +1204,7 @@ import {
|
|
|
1200
1204
|
getVariableSet as getVariableSet2,
|
|
1201
1205
|
listCapabilityCatalogItems,
|
|
1202
1206
|
listCapabilityInstallations,
|
|
1207
|
+
listConnectionsMetadata,
|
|
1203
1208
|
listEnabledMcpCapabilityServers,
|
|
1204
1209
|
listPackInstallations as listPackInstallations2,
|
|
1205
1210
|
mcpServerIdForCapability,
|
|
@@ -1803,14 +1808,10 @@ function normalizedMcpCredentialHeaders(headers) {
|
|
|
1803
1808
|
return Object.fromEntries(entries);
|
|
1804
1809
|
}
|
|
1805
1810
|
async function validateMcpCapabilityConnectionRef(input, item, ref) {
|
|
1806
|
-
|
|
1807
|
-
throw new HTTPException6(422, {
|
|
1808
|
-
message: "subject-owned connection refs are not supported for agent runtime use yet"
|
|
1809
|
-
});
|
|
1810
|
-
}
|
|
1811
|
+
const subjectScope = ref.subjectScope ?? "workspace";
|
|
1811
1812
|
const normalized = {
|
|
1812
1813
|
providerDomain: ref.providerDomain.trim(),
|
|
1813
|
-
subjectScope
|
|
1814
|
+
subjectScope,
|
|
1814
1815
|
...ref.connectionId ? { connectionId: ref.connectionId } : {},
|
|
1815
1816
|
...ref.provider ? { provider: ref.provider.trim() } : {},
|
|
1816
1817
|
...ref.kind ? { kind: ref.kind } : {},
|
|
@@ -1826,23 +1827,30 @@ async function validateMcpCapabilityConnectionRef(input, item, ref) {
|
|
|
1826
1827
|
message: "MCP capabilities need a remote streamable HTTP endpoint before they can use a connectionRef"
|
|
1827
1828
|
});
|
|
1828
1829
|
}
|
|
1829
|
-
|
|
1830
|
-
return normalized;
|
|
1831
|
-
}
|
|
1832
|
-
const connection = await getConnectionMetadata(
|
|
1830
|
+
let connection = normalized.connectionId ? await getConnectionMetadata(
|
|
1833
1831
|
input.db,
|
|
1834
1832
|
input.workspaceId,
|
|
1835
1833
|
normalized.connectionId,
|
|
1836
1834
|
input.grant.subjectId
|
|
1837
|
-
);
|
|
1835
|
+
) : null;
|
|
1836
|
+
if (!connection && subjectScope === "subject" && !normalized.connectionId) {
|
|
1837
|
+
const visible = await listConnectionsMetadata(
|
|
1838
|
+
input.db,
|
|
1839
|
+
input.workspaceId,
|
|
1840
|
+
input.grant.subjectId
|
|
1841
|
+
);
|
|
1842
|
+
connection = visible.find(
|
|
1843
|
+
(candidate) => candidate.subjectId === input.grant.subjectId && candidate.providerDomain === normalized.providerDomain && (!normalized.kind || candidate.kind === normalized.kind) && candidate.status === "active"
|
|
1844
|
+
) ?? null;
|
|
1845
|
+
}
|
|
1838
1846
|
if (!connection) {
|
|
1839
1847
|
throw new HTTPException6(422, {
|
|
1840
|
-
message: "connectionRef
|
|
1848
|
+
message: "connectionRef does not reference a visible active connection"
|
|
1841
1849
|
});
|
|
1842
1850
|
}
|
|
1843
|
-
if (connection.subjectId !== null) {
|
|
1851
|
+
if (subjectScope === "subject" && connection.subjectId !== input.grant.subjectId || subjectScope === "workspace" && connection.subjectId !== null) {
|
|
1844
1852
|
throw new HTTPException6(422, {
|
|
1845
|
-
message:
|
|
1853
|
+
message: `connectionRef does not reference a ${subjectScope}-owned connection`
|
|
1846
1854
|
});
|
|
1847
1855
|
}
|
|
1848
1856
|
if (connection.status !== "active") {
|
|
@@ -1860,6 +1868,11 @@ async function validateMcpCapabilityConnectionRef(input, item, ref) {
|
|
|
1860
1868
|
message: "connectionRef.kind does not match the referenced connection"
|
|
1861
1869
|
});
|
|
1862
1870
|
}
|
|
1871
|
+
if (subjectScope === "subject") {
|
|
1872
|
+
const genericSubjectRef = { ...normalized, kind: connection.kind };
|
|
1873
|
+
delete genericSubjectRef.connectionId;
|
|
1874
|
+
return genericSubjectRef;
|
|
1875
|
+
}
|
|
1863
1876
|
return normalized;
|
|
1864
1877
|
}
|
|
1865
1878
|
function authDeferredMcpConnectivity() {
|
|
@@ -2374,8 +2387,14 @@ function installationConnectionRef(config) {
|
|
|
2374
2387
|
if (!ref || typeof ref !== "object") {
|
|
2375
2388
|
return null;
|
|
2376
2389
|
}
|
|
2377
|
-
const { connectionId, providerDomain, kind } = ref;
|
|
2378
|
-
if (typeof
|
|
2390
|
+
const { connectionId, providerDomain, kind, subjectScope } = ref;
|
|
2391
|
+
if (typeof providerDomain !== "string" || typeof kind !== "string") {
|
|
2392
|
+
return null;
|
|
2393
|
+
}
|
|
2394
|
+
if (subjectScope === "subject") {
|
|
2395
|
+
return { providerDomain, kind, subjectScope: "subject" };
|
|
2396
|
+
}
|
|
2397
|
+
if (typeof connectionId !== "string") {
|
|
2379
2398
|
return null;
|
|
2380
2399
|
}
|
|
2381
2400
|
return { connectionId, providerDomain, kind };
|
|
@@ -3745,6 +3764,7 @@ async function createAndStartSession(input) {
|
|
|
3745
3764
|
initialMessage: input.initialMessage,
|
|
3746
3765
|
initialTurnInstructions: input.turnInstructions ?? null,
|
|
3747
3766
|
resources: input.resources,
|
|
3767
|
+
skills: input.skills ?? [],
|
|
3748
3768
|
tools: input.tools,
|
|
3749
3769
|
...input.toolPolicy ? { toolPolicy: input.toolPolicy } : {},
|
|
3750
3770
|
metadata: sessionMetadata,
|
|
@@ -3788,6 +3808,7 @@ async function createAndStartSession(input) {
|
|
|
3788
3808
|
initialMessage: input.initialMessage,
|
|
3789
3809
|
initialTurnInstructions: input.turnInstructions ?? null,
|
|
3790
3810
|
resources: input.resources,
|
|
3811
|
+
skills: input.skills ?? [],
|
|
3791
3812
|
tools: input.tools,
|
|
3792
3813
|
...input.toolPolicy ? { toolPolicy: input.toolPolicy } : {},
|
|
3793
3814
|
metadata: sessionMetadata,
|
|
@@ -4082,6 +4103,7 @@ async function createSessionForRequest(deps, grant, workspaceId, rawPayload) {
|
|
|
4082
4103
|
const resources = normalizeResources(
|
|
4083
4104
|
hasOwnProperty(rawPayload, "resources") ? payload.resources : parentSession?.resources ?? payload.resources
|
|
4084
4105
|
);
|
|
4106
|
+
const skills = hasOwnProperty(rawPayload, "skills") ? payload.skills : parentSession?.skills ?? payload.skills;
|
|
4085
4107
|
const toolsProvided = hasOwnProperty(rawPayload, "tools");
|
|
4086
4108
|
const requestedTools = validateToolRefs(
|
|
4087
4109
|
toolsProvided ? payload.tools : parentSession?.tools ?? payload.tools,
|
|
@@ -4308,6 +4330,7 @@ async function createSessionForRequest(deps, grant, workspaceId, rawPayload) {
|
|
|
4308
4330
|
initialMessage: payload.initialMessage,
|
|
4309
4331
|
turnInstructions: payload.turnInstructions ?? null,
|
|
4310
4332
|
resources,
|
|
4333
|
+
skills,
|
|
4311
4334
|
tools,
|
|
4312
4335
|
toolPolicy,
|
|
4313
4336
|
...payload.clientEventId ? { clientEventId: payload.clientEventId } : {},
|