@bohuyeshan/openagent-labforge-core 3.11.4 → 3.11.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/cli/index.js CHANGED
@@ -9195,7 +9195,7 @@ var {
9195
9195
  // package.json
9196
9196
  var package_default = {
9197
9197
  name: "@bohuyeshan/openagent-labforge-core",
9198
- version: "3.11.4",
9198
+ version: "3.11.5",
9199
9199
  description: "The Best AI Agent Harness - Batteries-Included OpenCode Plugin with Multi-Model Orchestration, Parallel Background Agents, and Crafted LSP/AST Tools",
9200
9200
  main: "dist/index.js",
9201
9201
  types: "dist/index.d.ts",
package/dist/index.js CHANGED
@@ -97954,9 +97954,10 @@ function createChatMessageHandler3(args) {
97954
97954
  const pluginContext = ctx;
97955
97955
  const isRuntimeFallbackEnabled = hooks2.runtimeFallback !== null && hooks2.runtimeFallback !== undefined && (typeof pluginConfig.runtime_fallback === "boolean" ? pluginConfig.runtime_fallback : pluginConfig.runtime_fallback?.enabled ?? false);
97956
97956
  return async (input, output) => {
97957
+ const isInternalInitiatedPrompt = hasInternalInitiatorMarker(output.parts);
97957
97958
  const previousSessionModel = getSessionModel(input.sessionID);
97958
97959
  const currentInputModel = input.model;
97959
- const manualModelChangeDetected = currentInputModel !== undefined && previousSessionModel !== undefined && (currentInputModel.providerID !== previousSessionModel.providerID || currentInputModel.modelID !== previousSessionModel.modelID);
97960
+ const manualModelChangeDetected = !isInternalInitiatedPrompt && currentInputModel !== undefined && previousSessionModel !== undefined && (currentInputModel.providerID !== previousSessionModel.providerID || currentInputModel.modelID !== previousSessionModel.modelID);
97960
97961
  if (manualModelChangeDetected) {
97961
97962
  clearPendingModelFallback(input.sessionID);
97962
97963
  clearSessionFallbackChain(input.sessionID);
@@ -97966,12 +97967,14 @@ function createChatMessageHandler3(args) {
97966
97967
  const forcedModel = getSessionForcedModel(input.sessionID);
97967
97968
  const rawInputModel = input.model;
97968
97969
  const rawInputModelId = modelToString(rawInputModel);
97969
- if (rawInputModel !== undefined) {
97970
+ if (!isInternalInitiatedPrompt && rawInputModel !== undefined) {
97970
97971
  setSessionAutoModelRouting(input.sessionID, isAutoModelSelection(rawInputModelId));
97971
97972
  }
97972
97973
  const autoModelRoutingEnabled = isSessionAutoModelRoutingEnabled(input.sessionID);
97973
97974
  if (strictUserModelPriority && lockedModel) {
97974
- if (!rawInputModel) {
97975
+ if (isInternalInitiatedPrompt) {
97976
+ input.model = lockedModel;
97977
+ } else if (!rawInputModel) {
97975
97978
  input.model = lockedModel;
97976
97979
  } else if (isAutoModelSelection(rawInputModelId)) {
97977
97980
  clearSessionModelLock(input.sessionID);
@@ -98078,29 +98081,33 @@ function createChatMessageHandler3(args) {
98078
98081
  providerID: output.message["model"].providerID ?? "",
98079
98082
  modelID: output.message["model"].modelID ?? ""
98080
98083
  } : undefined;
98081
- if (requestedModel !== undefined && isAutoModelSelection(requestedModelId)) {
98082
- clearSessionModelLock(input.sessionID);
98083
- clearSessionForcedModel(input.sessionID);
98084
- } else if (shouldLockToRequestedModel) {
98085
- setSessionModelLock(input.sessionID, requestedModel);
98086
- if (modelBeforeUserLock && modelBeforeUserLock.providerID.length > 0 && modelBeforeUserLock.modelID.length > 0 && !sameModel(modelBeforeUserLock, requestedModel)) {
98087
- setSessionForcedModel(input.sessionID, modelBeforeUserLock);
98088
- } else {
98084
+ if (!isInternalInitiatedPrompt) {
98085
+ if (requestedModel !== undefined && isAutoModelSelection(requestedModelId)) {
98086
+ clearSessionModelLock(input.sessionID);
98089
98087
  clearSessionForcedModel(input.sessionID);
98088
+ } else if (shouldLockToRequestedModel) {
98089
+ setSessionModelLock(input.sessionID, requestedModel);
98090
+ if (modelBeforeUserLock && modelBeforeUserLock.providerID.length > 0 && modelBeforeUserLock.modelID.length > 0 && !sameModel(modelBeforeUserLock, requestedModel)) {
98091
+ setSessionForcedModel(input.sessionID, modelBeforeUserLock);
98092
+ } else {
98093
+ clearSessionForcedModel(input.sessionID);
98094
+ }
98090
98095
  }
98091
98096
  }
98092
- if (shouldLockToRequestedModel) {
98097
+ if (!isInternalInitiatedPrompt && shouldLockToRequestedModel) {
98093
98098
  output.message["model"] = requestedModel;
98094
98099
  }
98095
- const finalOutputModel = output.message["model"];
98096
- if (finalOutputModel && typeof finalOutputModel === "object" && "providerID" in finalOutputModel && "modelID" in finalOutputModel) {
98097
- const providerID = finalOutputModel.providerID;
98098
- const modelID = finalOutputModel.modelID;
98099
- if (typeof providerID === "string" && typeof modelID === "string") {
98100
- setSessionModel(input.sessionID, { providerID, modelID });
98100
+ if (!isInternalInitiatedPrompt) {
98101
+ const finalOutputModel = output.message["model"];
98102
+ if (finalOutputModel && typeof finalOutputModel === "object" && "providerID" in finalOutputModel && "modelID" in finalOutputModel) {
98103
+ const providerID = finalOutputModel.providerID;
98104
+ const modelID = finalOutputModel.modelID;
98105
+ if (typeof providerID === "string" && typeof modelID === "string") {
98106
+ setSessionModel(input.sessionID, { providerID, modelID });
98107
+ }
98108
+ } else if (requestedModel) {
98109
+ setSessionModel(input.sessionID, requestedModel);
98101
98110
  }
98102
- } else if (requestedModel) {
98103
- setSessionModel(input.sessionID, requestedModel);
98104
98111
  }
98105
98112
  };
98106
98113
  }
@@ -98114,6 +98121,9 @@ function sameModel(left, right) {
98114
98121
  return false;
98115
98122
  return left.providerID === right.providerID && left.modelID === right.modelID;
98116
98123
  }
98124
+ function hasInternalInitiatorMarker(parts) {
98125
+ return parts.some((part) => part.type === "text" && typeof part.text === "string" && part.text.includes(OMO_INTERNAL_INITIATOR_MARKER));
98126
+ }
98117
98127
 
98118
98128
  // src/plugin/messages-transform.ts
98119
98129
  function createMessagesTransformHandler(args) {
@@ -98171,6 +98181,11 @@ function normalizeSessionStatusToIdle(input) {
98171
98181
  function isRecord12(value) {
98172
98182
  return typeof value === "object" && value !== null;
98173
98183
  }
98184
+ function hasInternalInitiatorMarker2(parts) {
98185
+ if (!Array.isArray(parts))
98186
+ return false;
98187
+ return parts.some((part) => isRecord12(part) && part.type === "text" && typeof part.text === "string" && part.text.includes(OMO_INTERNAL_INITIATOR_MARKER));
98188
+ }
98174
98189
  function normalizeFallbackModelID(modelID) {
98175
98190
  return modelID.replace(/-thinking$/i, "").replace(/-max$/i, "").replace(/-high$/i, "");
98176
98191
  }
@@ -98246,6 +98261,43 @@ function createEventHandler2(args) {
98246
98261
  const lastHandledModelErrorMessageID = new Map;
98247
98262
  const lastHandledRetryStatusKey = new Map;
98248
98263
  const lastKnownModelBySession = new Map;
98264
+ const internalMarkerCache2 = new Map;
98265
+ const INTERNAL_MARKER_CACHE_LIMIT2 = 1000;
98266
+ const rememberInternalMarker = (cacheKey, hasMarker) => {
98267
+ internalMarkerCache2.set(cacheKey, hasMarker);
98268
+ if (internalMarkerCache2.size > INTERNAL_MARKER_CACHE_LIMIT2) {
98269
+ internalMarkerCache2.clear();
98270
+ }
98271
+ };
98272
+ const isInternalInitiatedUserMessage = async (sessionID, props, info) => {
98273
+ if (hasInternalInitiatorMarker2(props?.parts))
98274
+ return true;
98275
+ if (hasInternalInitiatorMarker2(info?.parts))
98276
+ return true;
98277
+ if (hasInternalInitiatorMarker2(info?.content))
98278
+ return true;
98279
+ const messageID = typeof info?.id === "string" ? info.id : undefined;
98280
+ if (!messageID)
98281
+ return false;
98282
+ const cacheKey = `${sessionID}:${messageID}`;
98283
+ const cached3 = internalMarkerCache2.get(cacheKey);
98284
+ if (cached3 !== undefined)
98285
+ return cached3;
98286
+ const loadMessage = pluginContext.client.session.message;
98287
+ if (typeof loadMessage !== "function")
98288
+ return false;
98289
+ try {
98290
+ const response = await loadMessage({
98291
+ path: { id: sessionID, messageID }
98292
+ });
98293
+ const hasMarker = hasInternalInitiatorMarker2(response.data?.parts);
98294
+ rememberInternalMarker(cacheKey, hasMarker);
98295
+ return hasMarker;
98296
+ } catch {
98297
+ rememberInternalMarker(cacheKey, false);
98298
+ return false;
98299
+ }
98300
+ };
98249
98301
  const resolveFallbackProviderID = (sessionID, providerHint) => {
98250
98302
  const sessionModel = getSessionModel(sessionID);
98251
98303
  if (sessionModel?.providerID) {
@@ -98397,15 +98449,18 @@ function createEventHandler2(args) {
98397
98449
  const agent = info?.agent;
98398
98450
  const role = info?.role;
98399
98451
  if (sessionID && role === "user") {
98400
- const isCompactionMessage = agent ? isCompactionAgent4(agent) : false;
98401
- if (agent && !isCompactionMessage) {
98402
- updateSessionAgent(sessionID, agent);
98403
- }
98404
- const providerID = info?.providerID;
98405
- const modelID = info?.modelID;
98406
- if (providerID && modelID && !isCompactionMessage) {
98407
- lastKnownModelBySession.set(sessionID, { providerID, modelID });
98408
- setSessionModel(sessionID, { providerID, modelID });
98452
+ const isInternalUserMessage = await isInternalInitiatedUserMessage(sessionID, props, info);
98453
+ if (!isInternalUserMessage) {
98454
+ const isCompactionMessage = agent ? isCompactionAgent4(agent) : false;
98455
+ if (agent && !isCompactionMessage) {
98456
+ updateSessionAgent(sessionID, agent);
98457
+ }
98458
+ const providerID = info?.providerID;
98459
+ const modelID = info?.modelID;
98460
+ if (providerID && modelID && !isCompactionMessage) {
98461
+ lastKnownModelBySession.set(sessionID, { providerID, modelID });
98462
+ setSessionModel(sessionID, { providerID, modelID });
98463
+ }
98409
98464
  }
98410
98465
  }
98411
98466
  if (sessionID && role === "assistant" && !isRuntimeFallbackEnabled && isModelFallbackEnabled && isSessionAutoModelRoutingEnabled(sessionID)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bohuyeshan/openagent-labforge-core",
3
- "version": "3.11.4",
3
+ "version": "3.11.5",
4
4
  "description": "The Best AI Agent Harness - Batteries-Included OpenCode Plugin with Multi-Model Orchestration, Parallel Background Agents, and Crafted LSP/AST Tools",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",