@opengeni/runtime 0.7.0 → 0.7.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/index.d.ts CHANGED
@@ -684,7 +684,6 @@ type WorkspaceEnvironmentContext = {
684
684
  };
685
685
  type PersistentSessionSettings = {
686
686
  titleIsSet: boolean;
687
- childNotificationsMode?: "digest" | "passive";
688
687
  };
689
688
  /**
690
689
  * The rig a session rides (M3): its name + the active version pinned onto the
@@ -824,6 +823,8 @@ type PrepareToolsOptions = {
824
823
  workspaceId?: string;
825
824
  sessionId?: string;
826
825
  turnId?: string;
826
+ attemptId?: string;
827
+ executionGeneration?: number;
827
828
  subjectId?: string;
828
829
  subjectLabel?: string;
829
830
  firstPartyPermissions?: Permission[];
@@ -837,6 +838,8 @@ type PrepareInputOptions = {
837
838
  };
838
839
  declare function prepareRunInput(agent: Agent<any, any>, input: AgentSegmentInput, options?: PrepareInputOptions): Promise<PreparedAgentInput>;
839
840
  type RunAgentStreamOptions = {
841
+ /** Abort the provider/tool loop when the owning activity is cancelled. */
842
+ signal?: AbortSignal;
840
843
  sandboxClient?: unknown;
841
844
  sandboxEnvironment?: Record<string, string>;
842
845
  onRuntimeEvent?: (event: NormalizedRuntimeEvent) => Promise<void> | void;
package/dist/index.js CHANGED
@@ -2311,9 +2311,7 @@ function appendPersistentSessionSettings(composed, settings) {
2311
2311
  if (!settings) {
2312
2312
  return composed;
2313
2313
  }
2314
- const childState = settings.childNotificationsMode ? `; spawned-worker completion notifications are ${settings.childNotificationsMode}` : "";
2315
- const persistentTools = settings.childNotificationsMode ? "opengeni__set_session_title or opengeni__set_child_notifications_mode" : "opengeni__set_session_title";
2316
- return `${composed} Persistent session settings already in effect: the display title is ${settings.titleIsSet ? "set" : "not set"}${childState}. These settings persist across turns, continuations, and interruptions. Do not call ${persistentTools} merely to reassert an unchanged value; call them only when the current value actually needs to change.`;
2314
+ return `${composed} Persistent session settings already in effect: the display title is ${settings.titleIsSet ? "set" : "not set"}. This setting persists across turns, continuations, and interruptions. Do not call opengeni__set_session_title merely to reassert an unchanged value; call it only when the current value actually needs to change.`;
2317
2315
  }
2318
2316
  function appendWorkspaceMemory(composed, workspaceMemory) {
2319
2317
  const trimmed = workspaceMemory?.trim();
@@ -2822,7 +2820,9 @@ async function authNeededFetchResponse(options, serverId, request, auth, connect
2822
2820
  if (request.method === "tools/call") {
2823
2821
  return mcpToolAuthNeededResponse(request.id);
2824
2822
  }
2825
- return new Response("Authentication required for MCP server connection", { status: 401 });
2823
+ return new Response("Authentication required for MCP server connection", {
2824
+ status: 401
2825
+ });
2826
2826
  }
2827
2827
  async function publishAuthNeeded(options, payload) {
2828
2828
  try {
@@ -2965,6 +2965,8 @@ async function signFirstPartyDelegatedBearer(settings, options) {
2965
2965
  permissions: options.firstPartyPermissions ?? firstPartyMcpPermissions,
2966
2966
  ...options.sessionId ? { sessionId: options.sessionId } : {},
2967
2967
  ...options.turnId ? { turnId: options.turnId } : {},
2968
+ ...options.attemptId ? { attemptId: options.attemptId } : {},
2969
+ ...options.executionGeneration ? { executionGeneration: options.executionGeneration } : {},
2968
2970
  exp: Math.floor(Date.now() / 1e3) + 60 * 60
2969
2971
  });
2970
2972
  }
@@ -3134,7 +3136,10 @@ var PrefixedMcpServer = class {
3134
3136
  }
3135
3137
  return [];
3136
3138
  }
3137
- return tools.filter((tool2) => this.isAllowed(tool2.name)).map((tool2) => ({ ...tool2, name: prefixedMcpToolName(this.name, tool2.name) }));
3139
+ return tools.filter((tool2) => this.isAllowed(tool2.name)).map((tool2) => ({
3140
+ ...tool2,
3141
+ name: prefixedMcpToolName(this.name, tool2.name)
3142
+ }));
3138
3143
  }
3139
3144
  async callTool(toolName, args, meta) {
3140
3145
  const unprefixed = this.unprefixToolName(toolName);
@@ -3145,7 +3150,10 @@ var PrefixedMcpServer = class {
3145
3150
  return await this.inner.callTool(unprefixed, args, meta);
3146
3151
  } catch (error) {
3147
3152
  if (isAuthNeededMcpError(error)) {
3148
- return { isError: true, content: [{ type: "text", text: MCP_AUTH_NEEDED_MESSAGE }] };
3153
+ return {
3154
+ isError: true,
3155
+ content: [{ type: "text", text: MCP_AUTH_NEEDED_MESSAGE }]
3156
+ };
3149
3157
  }
3150
3158
  if (this.bestEffort) {
3151
3159
  const fields = safeMcpErrorFields(error);
@@ -3155,7 +3163,12 @@ var PrefixedMcpServer = class {
3155
3163
  );
3156
3164
  return {
3157
3165
  isError: true,
3158
- content: [{ type: "text", text: mcpToolUnavailableMessage(mcpErrorReason(fields)) }]
3166
+ content: [
3167
+ {
3168
+ type: "text",
3169
+ text: mcpToolUnavailableMessage(mcpErrorReason(fields))
3170
+ }
3171
+ ]
3159
3172
  };
3160
3173
  }
3161
3174
  throw error;
@@ -3393,8 +3406,12 @@ async function runAgentStream(agent, input, settings, overrides = {}) {
3393
3406
  throwOnCompactionNeeded: Boolean(
3394
3407
  overrides.contextCompactionSignalTokens || overrides.contextCompactionRequested
3395
3408
  ),
3396
- ...overrides.contextCompactionSignalTokens ? { contextCompactionSignalTokens: overrides.contextCompactionSignalTokens } : {},
3397
- ...overrides.contextCompactionRequested ? { contextCompactionRequested: overrides.contextCompactionRequested } : {}
3409
+ ...overrides.contextCompactionSignalTokens ? {
3410
+ contextCompactionSignalTokens: overrides.contextCompactionSignalTokens
3411
+ } : {},
3412
+ ...overrides.contextCompactionRequested ? {
3413
+ contextCompactionRequested: overrides.contextCompactionRequested
3414
+ } : {}
3398
3415
  }),
3399
3416
  genesisTitleInputFilter,
3400
3417
  overrides.callModelInputFilter
@@ -3403,7 +3420,8 @@ async function runAgentStream(agent, input, settings, overrides = {}) {
3403
3420
  const ownedRunOptions = {
3404
3421
  stream: true,
3405
3422
  maxTurns: settings.agentMaxModelCallsPerTurn,
3406
- callModelInputFilter: ownedFilter
3423
+ callModelInputFilter: ownedFilter,
3424
+ ...overrides.signal ? { signal: overrides.signal } : {}
3407
3425
  };
3408
3426
  ownedRunOptions.sandbox = {
3409
3427
  client: decoratedClient,
@@ -3460,7 +3478,9 @@ async function runAgentStream(agent, input, settings, overrides = {}) {
3460
3478
  throwOnCompactionNeeded: Boolean(
3461
3479
  overrides.contextCompactionSignalTokens || overrides.contextCompactionRequested
3462
3480
  ),
3463
- ...overrides.contextCompactionSignalTokens ? { contextCompactionSignalTokens: overrides.contextCompactionSignalTokens } : {},
3481
+ ...overrides.contextCompactionSignalTokens ? {
3482
+ contextCompactionSignalTokens: overrides.contextCompactionSignalTokens
3483
+ } : {},
3464
3484
  ...overrides.contextCompactionRequested ? { contextCompactionRequested: overrides.contextCompactionRequested } : {}
3465
3485
  }),
3466
3486
  genesisTitleInputFilter,
@@ -3474,7 +3494,8 @@ async function runAgentStream(agent, input, settings, overrides = {}) {
3474
3494
  // provider ids, trim to the input budget on the client-compaction path, and
3475
3495
  // raise the proactive compaction signal. This runs for turn-start replay AND
3476
3496
  // every mid-turn follow-up.
3477
- callModelInputFilter
3497
+ callModelInputFilter,
3498
+ ...overrides.signal ? { signal: overrides.signal } : {}
3478
3499
  };
3479
3500
  if (client) {
3480
3501
  runOptions.sandbox = {
@@ -3501,7 +3522,9 @@ function appendSandboxFileDownloadFailureNote(input, failures) {
3501
3522
  }
3502
3523
  }
3503
3524
  function runScopedRunner(settings) {
3504
- return new Runner({ modelProvider: new MultiProviderModelProvider(settings) });
3525
+ return new Runner({
3526
+ modelProvider: new MultiProviderModelProvider(settings)
3527
+ });
3505
3528
  }
3506
3529
  function maxTurnsExceededRunState(error) {
3507
3530
  if (!(error instanceof MaxTurnsExceededError)) {
@@ -3530,13 +3553,17 @@ function withManifestRefreshOnResume(client, targetManifest, context = {}) {
3530
3553
  return {
3531
3554
  backendId: client.backendId,
3532
3555
  ...client.supportsDefaultOptions !== void 0 ? { supportsDefaultOptions: client.supportsDefaultOptions } : {},
3533
- ...client.create ? { create: async (...args) => await client.create(...args) } : {},
3556
+ ...client.create ? {
3557
+ create: async (...args) => await client.create(...args)
3558
+ } : {},
3534
3559
  resume: async (state) => {
3535
3560
  const session = await client.resume(state);
3536
3561
  await applyMissingManifestEntries(session, targetManifest, context);
3537
3562
  return session;
3538
3563
  },
3539
- ...client.delete ? { delete: async (state) => await client.delete(state) } : {},
3564
+ ...client.delete ? {
3565
+ delete: async (state) => await client.delete(state)
3566
+ } : {},
3540
3567
  ...client.serializeSessionState ? {
3541
3568
  serializeSessionState: async (state, options) => await client.serializeSessionState(state, options)
3542
3569
  } : {},
@@ -3643,7 +3670,11 @@ function manifestEnvironmentDrift(current, target) {
3643
3670
  if (added.length === 0 && removed.length === 0 && changed.length === 0) {
3644
3671
  return null;
3645
3672
  }
3646
- return { added: added.sort(), removed: removed.sort(), changed: changed.sort() };
3673
+ return {
3674
+ added: added.sort(),
3675
+ removed: removed.sort(),
3676
+ changed: changed.sort()
3677
+ };
3647
3678
  }
3648
3679
  async function reportManifestEnvironmentDrift(current, target, context) {
3649
3680
  const drift = manifestEnvironmentDrift(current, target);
@@ -3651,7 +3682,10 @@ async function reportManifestEnvironmentDrift(current, target, context) {
3651
3682
  return null;
3652
3683
  }
3653
3684
  try {
3654
- await context.onRuntimeEvent?.({ type: "sandbox.env.drift", payload: drift });
3685
+ await context.onRuntimeEvent?.({
3686
+ type: "sandbox.env.drift",
3687
+ payload: drift
3688
+ });
3655
3689
  } catch {
3656
3690
  }
3657
3691
  return drift;
@@ -3759,7 +3793,9 @@ function withSandboxFileDownloads(client, downloads, context = {}) {
3759
3793
  ...client.resume ? {
3760
3794
  resume: async (state) => await wrapSession(await client.resume(state))
3761
3795
  } : {},
3762
- ...client.delete ? { delete: async (state) => await client.delete(state) } : {},
3796
+ ...client.delete ? {
3797
+ delete: async (state) => await client.delete(state)
3798
+ } : {},
3763
3799
  ...client.serializeSessionState ? {
3764
3800
  serializeSessionState: async (state, options) => await client.serializeSessionState(state, options)
3765
3801
  } : {},
@@ -3953,7 +3989,10 @@ function normalizeSdkEvent(event) {
3953
3989
  return out;
3954
3990
  }
3955
3991
  if (event.type === "agent_updated_stream_event") {
3956
- out.push({ type: "agent.updated", payload: { agent: event.agent?.name ?? null } });
3992
+ out.push({
3993
+ type: "agent.updated",
3994
+ payload: { agent: event.agent?.name ?? null }
3995
+ });
3957
3996
  return out;
3958
3997
  }
3959
3998
  if (event.type !== "run_item_stream_event") {
@@ -4084,7 +4123,9 @@ function inputTokenDetailsProp(raw) {
4084
4123
  if (!details || typeof details !== "object") {
4085
4124
  return {};
4086
4125
  }
4087
- return { inputTokensDetails: details };
4126
+ return {
4127
+ inputTokensDetails: details
4128
+ };
4088
4129
  }
4089
4130
  function outputTokenDetailsProp(raw) {
4090
4131
  const details = raw.outputTokensDetails ?? raw.output_tokens_details;
@@ -4179,7 +4220,9 @@ function objectStorageFileMount(settings, prefix) {
4179
4220
  accountKey: config2.accountKey,
4180
4221
  endpointUrl: config2.endpointUrl,
4181
4222
  readOnly: true,
4182
- mountStrategy: inContainerMountStrategy({ pattern: { type: "rclone", mode: "fuse" } })
4223
+ mountStrategy: inContainerMountStrategy({
4224
+ pattern: { type: "rclone", mode: "fuse" }
4225
+ })
4183
4226
  });
4184
4227
  }
4185
4228
  if (settings.objectStorageBackend === "aws-s3" || settings.objectStorageBackend === "gcs") {
@@ -4352,7 +4395,9 @@ function withSandboxLifecycleHooks(client, hooks, context) {
4352
4395
  ...client.resume ? {
4353
4396
  resume: async (state) => await wrapSession(await client.resume(state))
4354
4397
  } : {},
4355
- ...client.delete ? { delete: async (state) => await client.delete(state) } : {},
4398
+ ...client.delete ? {
4399
+ delete: async (state) => await client.delete(state)
4400
+ } : {},
4356
4401
  ...client.serializeSessionState ? {
4357
4402
  serializeSessionState: async (state, options) => await client.serializeSessionState(state, options)
4358
4403
  } : {},
@@ -4889,7 +4934,10 @@ async function runRigSetupHook(session, context = { environment: {} }) {
4889
4934
  const message = error instanceof Error ? error.message : String(error);
4890
4935
  await context.onRuntimeEvent?.({
4891
4936
  type: "rig.setup.failed",
4892
- payload: { ...payload, error: message.slice(-RIG_SETUP_OUTPUT_TAIL_LIMIT) }
4937
+ payload: {
4938
+ ...payload,
4939
+ error: message.slice(-RIG_SETUP_OUTPUT_TAIL_LIMIT)
4940
+ }
4893
4941
  });
4894
4942
  throw new Error(
4895
4943
  `Rig setup failed for rig "${rigSetup.rigName}" (version ${rigSetup.versionId}): ${message}`,
@@ -4912,7 +4960,10 @@ ${tail}` : ""}`
4912
4960
  );
4913
4961
  await context.onRuntimeEvent?.({
4914
4962
  type: "rig.setup.failed",
4915
- payload: { ...payload, error: failure.message.slice(-RIG_SETUP_OUTPUT_TAIL_LIMIT) }
4963
+ payload: {
4964
+ ...payload,
4965
+ error: failure.message.slice(-RIG_SETUP_OUTPUT_TAIL_LIMIT)
4966
+ }
4916
4967
  });
4917
4968
  throw failure;
4918
4969
  }
@@ -4922,8 +4973,14 @@ ${tail}` : ""}`
4922
4973
  });
4923
4974
  }
4924
4975
  async function runRepositoryCloneHook(session, resources, context = { environment: {} }) {
4925
- const payload = { name: "repository-clone", repositoryCount: resources.length };
4926
- await context.onRuntimeEvent?.({ type: "sandbox.operation.started", payload });
4976
+ const payload = {
4977
+ name: "repository-clone",
4978
+ repositoryCount: resources.length
4979
+ };
4980
+ await context.onRuntimeEvent?.({
4981
+ type: "sandbox.operation.started",
4982
+ payload
4983
+ });
4927
4984
  try {
4928
4985
  const gitTokenSeeds = {
4929
4986
  ...context.gitTokenSeeds ?? {},
@@ -4953,7 +5010,10 @@ ${repositoryCloneCommand(resources)}` : repositoryCloneCommand(resources);
4953
5010
  } else {
4954
5011
  throw new Error("Sandbox session does not support command execution");
4955
5012
  }
4956
- await context.onRuntimeEvent?.({ type: "sandbox.operation.completed", payload });
5013
+ await context.onRuntimeEvent?.({
5014
+ type: "sandbox.operation.completed",
5015
+ payload
5016
+ });
4957
5017
  } catch (error) {
4958
5018
  await context.onRuntimeEvent?.({
4959
5019
  type: "sandbox.operation.failed",
@@ -5047,8 +5107,14 @@ function hasAzureServicePrincipal(environment) {
5047
5107
  return Boolean(clientId && clientSecret && tenantId);
5048
5108
  }
5049
5109
  async function runAzureCliLoginHook(session, context = { environment: {} }) {
5050
- const payload = { name: "azure-cli-login", command: "az login --service-principal" };
5051
- await context.onRuntimeEvent?.({ type: "sandbox.operation.started", payload });
5110
+ const payload = {
5111
+ name: "azure-cli-login",
5112
+ command: "az login --service-principal"
5113
+ };
5114
+ await context.onRuntimeEvent?.({
5115
+ type: "sandbox.operation.started",
5116
+ payload
5117
+ });
5052
5118
  try {
5053
5119
  if (session.exec) {
5054
5120
  const result = await session.exec({
@@ -5071,7 +5137,10 @@ async function runAzureCliLoginHook(session, context = { environment: {} }) {
5071
5137
  } else {
5072
5138
  throw new Error("Sandbox session does not support command execution");
5073
5139
  }
5074
- await context.onRuntimeEvent?.({ type: "sandbox.operation.completed", payload });
5140
+ await context.onRuntimeEvent?.({
5141
+ type: "sandbox.operation.completed",
5142
+ payload
5143
+ });
5075
5144
  } catch (error) {
5076
5145
  await context.onRuntimeEvent?.({
5077
5146
  type: "sandbox.operation.failed",