@opengeni/core 0.18.1 → 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
@@ -4172,6 +4172,7 @@ async function createAndStartSession(input) {
4172
4172
  firstPartyMcpPermissions: input.firstPartyMcpPermissions ?? null,
4173
4173
  firstPartyMcpTools: input.firstPartyMcpTools,
4174
4174
  instructions: input.instructions ?? null,
4175
+ policyRole: input.policyRole ?? null,
4175
4176
  parentSessionId: input.parentSessionId ?? null,
4176
4177
  createIdempotencyKey: input.createIdempotencyKey,
4177
4178
  sandboxGroupId: input.sandboxGroupId ?? null,
@@ -4218,6 +4219,7 @@ async function createAndStartSession(input) {
4218
4219
  firstPartyMcpPermissions: input.firstPartyMcpPermissions ?? null,
4219
4220
  firstPartyMcpTools: input.firstPartyMcpTools,
4220
4221
  instructions: input.instructions ?? null,
4222
+ policyRole: input.policyRole ?? null,
4221
4223
  parentSessionId: input.parentSessionId ?? null,
4222
4224
  sandboxGroupId: input.sandboxGroupId ?? null,
4223
4225
  ...input.sandboxOs ? { sandboxOs: input.sandboxOs } : {},
@@ -4280,7 +4282,8 @@ async function finishStartSession(input, session) {
4280
4282
  ...input.goal.successCriteria !== void 0 ? { successCriteria: input.goal.successCriteria } : {},
4281
4283
  ...input.goal.maxAutoContinuations !== void 0 ? { maxAutoContinuations: input.goal.maxAutoContinuations } : {}
4282
4284
  } : null,
4283
- consumeNewSessionDraft: input.consumeNewSessionDraft ?? null
4285
+ consumeNewSessionDraft: input.consumeNewSessionDraft ?? null,
4286
+ deferInitialTurn: input.deferInitialTurn === true
4284
4287
  });
4285
4288
  await publishDurableSessionEvents(input.bus, session.workspaceId, session.id, started.events);
4286
4289
  if (started.workflowWakeRevision !== null) {
@@ -4597,7 +4600,7 @@ async function createSessionForRequest(deps, grant, workspaceId, rawPayload) {
4597
4600
  workspaceId,
4598
4601
  payload.variableSetId
4599
4602
  ) : null;
4600
- const requestedRigId = payload.rigId ?? await getWorkspaceDefaultRigId(db, workspaceId);
4603
+ const requestedRigId = payload.rigId === void 0 ? await getWorkspaceDefaultRigId(db, workspaceId) : payload.rigId;
4601
4604
  let frozenRigId = null;
4602
4605
  let frozenRigVersionId = null;
4603
4606
  if (requestedRigId) {
@@ -4765,13 +4768,15 @@ async function createSessionForRequest(deps, grant, workspaceId, rawPayload) {
4765
4768
  }
4766
4769
  }
4767
4770
  }
4768
- await requireLimit(deps, {
4769
- accountId: grant.accountId,
4770
- workspaceId,
4771
- action: "agent_run:create",
4772
- quantity: 1,
4773
- model
4774
- });
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
+ }
4775
4780
  const creationInitiator = creationInitiatorForGrant(grant);
4776
4781
  let session;
4777
4782
  try {
@@ -4782,7 +4787,8 @@ async function createSessionForRequest(deps, grant, workspaceId, rawPayload) {
4782
4787
  workflowClient,
4783
4788
  accountId: grant.accountId,
4784
4789
  workspaceId,
4785
- initialMessage: payload.initialMessage,
4790
+ initialMessage: payload.initialMessage ?? "",
4791
+ deferInitialTurn: payload.startMode === "realtime",
4786
4792
  turnInstructions: payload.turnInstructions ?? null,
4787
4793
  resources,
4788
4794
  skills,
@@ -4817,6 +4823,7 @@ async function createSessionForRequest(deps, grant, workspaceId, rawPayload) {
4817
4823
  // contracts schema). Persisted on the row; composed system-level at turn
4818
4824
  // time. Not surfaced as an event.
4819
4825
  instructions: payload.instructions ?? null,
4826
+ policyRole: payload.policyRole ?? null,
4820
4827
  firstPartyMcpPermissions,
4821
4828
  firstPartyMcpTools,
4822
4829
  mcpServers: sessionMcpServers.dbServers,
@@ -4848,21 +4855,23 @@ async function createSessionForRequest(deps, grant, workspaceId, rawPayload) {
4848
4855
  }
4849
4856
  throw error;
4850
4857
  }
4851
- await recordWorkspaceUsage(deps, {
4852
- accountId: grant.accountId,
4853
- workspaceId,
4854
- subjectId: grant.subjectId,
4855
- eventType: "agent_run.created",
4856
- quantity: 1,
4857
- unit: "run",
4858
- sourceResourceType: "session",
4859
- sourceResourceId: session.id,
4860
- sessionId: session.id,
4861
- initiator: session.createdBy,
4862
- initiatorContext: session.createdByContext,
4863
- origin: creationInitiator.actor ? "system" : "user",
4864
- idempotencyKey: `agent_run.created:${workspaceId}:${session.id}`
4865
- });
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
+ }
4866
4875
  return session;
4867
4876
  }
4868
4877
  async function acceptSessionUserMessage(deps, grant, workspaceId, sessionId, input) {
@@ -6843,11 +6852,13 @@ async function controlHumanSessionWorkstream(deps, context, input) {
6843
6852
  authorization?.relatedSessionAccess ?? "root"
6844
6853
  ),
6845
6854
  interruptionCount: result.interruptionCount,
6846
- wakeCount: result.wakeCount
6855
+ wakeCount: result.wakeCount,
6856
+ cancelledSessionCount: result.cancelledSessionCount,
6857
+ cancelledTurnCount: result.cancelledTurnCount
6847
6858
  };
6848
- await publishSessionEventIds(deps, context.workspaceId, context.sessionId, [
6849
- result.sessionControlEventId
6850
- ]);
6859
+ for (const affected of result.affectedSessionEvents) {
6860
+ await publishSessionEventIds(deps, context.workspaceId, affected.sessionId, affected.eventIds);
6861
+ }
6851
6862
  await publishWorkspaceControlEvent(deps, context.workspaceId, result.workspaceControlEventId);
6852
6863
  await requestControlWakeDispatch(deps, result.wakeCount);
6853
6864
  return response;