@opengeni/core 0.18.0 → 0.19.0
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.
|
@@ -68,6 +68,12 @@ export declare function controlAgentSessionWorkstream(deps: {
|
|
|
68
68
|
workspaceControlEventId: string;
|
|
69
69
|
interruptionCount: number;
|
|
70
70
|
wakeCount: number;
|
|
71
|
+
cancelledSessionCount: number;
|
|
72
|
+
cancelledTurnCount: number;
|
|
73
|
+
affectedSessionEvents: Array<{
|
|
74
|
+
sessionId: string;
|
|
75
|
+
eventIds: string[];
|
|
76
|
+
}>;
|
|
71
77
|
replay: boolean;
|
|
72
78
|
authorization: ResolvedSessionAuthorization | null;
|
|
73
79
|
}>;
|
|
@@ -57,6 +57,8 @@ export declare function createAndStartSession(input: {
|
|
|
57
57
|
accountId: string;
|
|
58
58
|
workspaceId: string;
|
|
59
59
|
initialMessage: string;
|
|
60
|
+
/** Create the session shell without an initial user event/agent turn. */
|
|
61
|
+
deferInitialTurn?: boolean;
|
|
60
62
|
turnInstructions?: string | null;
|
|
61
63
|
resources: ResourceRef[];
|
|
62
64
|
skills?: SessionSkill[];
|
|
@@ -83,6 +85,7 @@ export declare function createAndStartSession(input: {
|
|
|
83
85
|
rigVersionId?: string | null;
|
|
84
86
|
goal?: GoalSpec | null;
|
|
85
87
|
instructions?: string | null;
|
|
88
|
+
policyRole?: string | null;
|
|
86
89
|
firstPartyMcpPermissions?: Permission[] | null;
|
|
87
90
|
firstPartyMcpTools: FirstPartyMcpToolName[];
|
|
88
91
|
mcpServers?: CreateSessionMcpServerInput[];
|
package/dist/index.js
CHANGED
|
@@ -3730,7 +3730,8 @@ import {
|
|
|
3730
3730
|
canonicalizeConfiguredModelId,
|
|
3731
3731
|
configuredAllowedModels,
|
|
3732
3732
|
policyProviderIdForModel,
|
|
3733
|
-
resolveTurnExecutionPolicyV1
|
|
3733
|
+
resolveTurnExecutionPolicyV1,
|
|
3734
|
+
WORKSPACE_GATEWAY_MODEL_ID_PREFIX
|
|
3734
3735
|
} from "@opengeni/config";
|
|
3735
3736
|
import {
|
|
3736
3737
|
CreateSessionRequest,
|
|
@@ -4171,6 +4172,7 @@ async function createAndStartSession(input) {
|
|
|
4171
4172
|
firstPartyMcpPermissions: input.firstPartyMcpPermissions ?? null,
|
|
4172
4173
|
firstPartyMcpTools: input.firstPartyMcpTools,
|
|
4173
4174
|
instructions: input.instructions ?? null,
|
|
4175
|
+
policyRole: input.policyRole ?? null,
|
|
4174
4176
|
parentSessionId: input.parentSessionId ?? null,
|
|
4175
4177
|
createIdempotencyKey: input.createIdempotencyKey,
|
|
4176
4178
|
sandboxGroupId: input.sandboxGroupId ?? null,
|
|
@@ -4217,6 +4219,7 @@ async function createAndStartSession(input) {
|
|
|
4217
4219
|
firstPartyMcpPermissions: input.firstPartyMcpPermissions ?? null,
|
|
4218
4220
|
firstPartyMcpTools: input.firstPartyMcpTools,
|
|
4219
4221
|
instructions: input.instructions ?? null,
|
|
4222
|
+
policyRole: input.policyRole ?? null,
|
|
4220
4223
|
parentSessionId: input.parentSessionId ?? null,
|
|
4221
4224
|
sandboxGroupId: input.sandboxGroupId ?? null,
|
|
4222
4225
|
...input.sandboxOs ? { sandboxOs: input.sandboxOs } : {},
|
|
@@ -4279,7 +4282,8 @@ async function finishStartSession(input, session) {
|
|
|
4279
4282
|
...input.goal.successCriteria !== void 0 ? { successCriteria: input.goal.successCriteria } : {},
|
|
4280
4283
|
...input.goal.maxAutoContinuations !== void 0 ? { maxAutoContinuations: input.goal.maxAutoContinuations } : {}
|
|
4281
4284
|
} : null,
|
|
4282
|
-
consumeNewSessionDraft: input.consumeNewSessionDraft ?? null
|
|
4285
|
+
consumeNewSessionDraft: input.consumeNewSessionDraft ?? null,
|
|
4286
|
+
deferInitialTurn: input.deferInitialTurn === true
|
|
4283
4287
|
});
|
|
4284
4288
|
await publishDurableSessionEvents(input.bus, session.workspaceId, session.id, started.events);
|
|
4285
4289
|
if (started.workflowWakeRevision !== null) {
|
|
@@ -4309,6 +4313,9 @@ function canonicalConfiguredModel(settings, model) {
|
|
|
4309
4313
|
if (settings.codexSubscriptionEnabled && canonicalModel.startsWith(CODEX_MODEL_ID_PREFIX)) {
|
|
4310
4314
|
return canonicalModel;
|
|
4311
4315
|
}
|
|
4316
|
+
if (canonicalModel.startsWith(WORKSPACE_GATEWAY_MODEL_ID_PREFIX)) {
|
|
4317
|
+
return canonicalModel;
|
|
4318
|
+
}
|
|
4312
4319
|
throw new HTTPException10(422, { message: `model is not available: ${model}` });
|
|
4313
4320
|
}
|
|
4314
4321
|
function assertConfiguredModel(settings, model) {
|
|
@@ -4593,7 +4600,7 @@ async function createSessionForRequest(deps, grant, workspaceId, rawPayload) {
|
|
|
4593
4600
|
workspaceId,
|
|
4594
4601
|
payload.variableSetId
|
|
4595
4602
|
) : null;
|
|
4596
|
-
const requestedRigId = payload.rigId
|
|
4603
|
+
const requestedRigId = payload.rigId === void 0 ? await getWorkspaceDefaultRigId(db, workspaceId) : payload.rigId;
|
|
4597
4604
|
let frozenRigId = null;
|
|
4598
4605
|
let frozenRigVersionId = null;
|
|
4599
4606
|
if (requestedRigId) {
|
|
@@ -4761,13 +4768,15 @@ async function createSessionForRequest(deps, grant, workspaceId, rawPayload) {
|
|
|
4761
4768
|
}
|
|
4762
4769
|
}
|
|
4763
4770
|
}
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
+
if (payload.startMode !== "realtime") {
|
|
4772
|
+
await requireLimit(deps, {
|
|
4773
|
+
accountId: grant.accountId,
|
|
4774
|
+
workspaceId,
|
|
4775
|
+
action: "agent_run:create",
|
|
4776
|
+
quantity: 1,
|
|
4777
|
+
model
|
|
4778
|
+
});
|
|
4779
|
+
}
|
|
4771
4780
|
const creationInitiator = creationInitiatorForGrant(grant);
|
|
4772
4781
|
let session;
|
|
4773
4782
|
try {
|
|
@@ -4778,7 +4787,8 @@ async function createSessionForRequest(deps, grant, workspaceId, rawPayload) {
|
|
|
4778
4787
|
workflowClient,
|
|
4779
4788
|
accountId: grant.accountId,
|
|
4780
4789
|
workspaceId,
|
|
4781
|
-
initialMessage: payload.initialMessage,
|
|
4790
|
+
initialMessage: payload.initialMessage ?? "",
|
|
4791
|
+
deferInitialTurn: payload.startMode === "realtime",
|
|
4782
4792
|
turnInstructions: payload.turnInstructions ?? null,
|
|
4783
4793
|
resources,
|
|
4784
4794
|
skills,
|
|
@@ -4813,6 +4823,7 @@ async function createSessionForRequest(deps, grant, workspaceId, rawPayload) {
|
|
|
4813
4823
|
// contracts schema). Persisted on the row; composed system-level at turn
|
|
4814
4824
|
// time. Not surfaced as an event.
|
|
4815
4825
|
instructions: payload.instructions ?? null,
|
|
4826
|
+
policyRole: payload.policyRole ?? null,
|
|
4816
4827
|
firstPartyMcpPermissions,
|
|
4817
4828
|
firstPartyMcpTools,
|
|
4818
4829
|
mcpServers: sessionMcpServers.dbServers,
|
|
@@ -4844,21 +4855,23 @@ async function createSessionForRequest(deps, grant, workspaceId, rawPayload) {
|
|
|
4844
4855
|
}
|
|
4845
4856
|
throw error;
|
|
4846
4857
|
}
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4858
|
+
if (payload.startMode !== "realtime") {
|
|
4859
|
+
await recordWorkspaceUsage(deps, {
|
|
4860
|
+
accountId: grant.accountId,
|
|
4861
|
+
workspaceId,
|
|
4862
|
+
subjectId: grant.subjectId,
|
|
4863
|
+
eventType: "agent_run.created",
|
|
4864
|
+
quantity: 1,
|
|
4865
|
+
unit: "run",
|
|
4866
|
+
sourceResourceType: "session",
|
|
4867
|
+
sourceResourceId: session.id,
|
|
4868
|
+
sessionId: session.id,
|
|
4869
|
+
initiator: session.createdBy,
|
|
4870
|
+
initiatorContext: session.createdByContext,
|
|
4871
|
+
origin: creationInitiator.actor ? "system" : "user",
|
|
4872
|
+
idempotencyKey: `agent_run.created:${workspaceId}:${session.id}`
|
|
4873
|
+
});
|
|
4874
|
+
}
|
|
4862
4875
|
return session;
|
|
4863
4876
|
}
|
|
4864
4877
|
async function acceptSessionUserMessage(deps, grant, workspaceId, sessionId, input) {
|
|
@@ -6839,11 +6852,13 @@ async function controlHumanSessionWorkstream(deps, context, input) {
|
|
|
6839
6852
|
authorization?.relatedSessionAccess ?? "root"
|
|
6840
6853
|
),
|
|
6841
6854
|
interruptionCount: result.interruptionCount,
|
|
6842
|
-
wakeCount: result.wakeCount
|
|
6855
|
+
wakeCount: result.wakeCount,
|
|
6856
|
+
cancelledSessionCount: result.cancelledSessionCount,
|
|
6857
|
+
cancelledTurnCount: result.cancelledTurnCount
|
|
6843
6858
|
};
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
|
|
6859
|
+
for (const affected of result.affectedSessionEvents) {
|
|
6860
|
+
await publishSessionEventIds(deps, context.workspaceId, affected.sessionId, affected.eventIds);
|
|
6861
|
+
}
|
|
6847
6862
|
await publishWorkspaceControlEvent(deps, context.workspaceId, result.workspaceControlEventId);
|
|
6848
6863
|
await requestControlWakeDispatch(deps, result.wakeCount);
|
|
6849
6864
|
return response;
|