@linnlabs/linnkit 0.46.0 → 0.47.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/cli.cjs +64 -246
  3. package/dist/cli.cjs.map +1 -1
  4. package/dist/cli.js +64 -246
  5. package/dist/cli.js.map +1 -1
  6. package/dist/context-manager.cjs +7 -7
  7. package/dist/context-manager.cjs.map +1 -1
  8. package/dist/context-manager.js +7 -7
  9. package/dist/context-manager.js.map +1 -1
  10. package/dist/index.cjs +74 -257
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.js +74 -257
  13. package/dist/index.js.map +1 -1
  14. package/dist/ports/llm-call.d.cts +2 -16
  15. package/dist/ports/llm-call.d.ts +2 -16
  16. package/dist/quickstart.cjs +64 -246
  17. package/dist/quickstart.cjs.map +1 -1
  18. package/dist/quickstart.js +64 -246
  19. package/dist/quickstart.js.map +1 -1
  20. package/dist/runtime-kernel/graph-engine/executor.d.cts +0 -2
  21. package/dist/runtime-kernel/graph-engine/executor.d.ts +0 -2
  22. package/dist/runtime-kernel/graph-engine/types.d.cts +1 -2
  23. package/dist/runtime-kernel/graph-engine/types.d.ts +1 -2
  24. package/dist/runtime-kernel/llm/definitions/llmFallbackObserver.d.cts +1 -2
  25. package/dist/runtime-kernel/llm/definitions/llmFallbackObserver.d.ts +1 -2
  26. package/dist/runtime-kernel/llm/modelCatalog.d.cts +2 -3
  27. package/dist/runtime-kernel/llm/modelCatalog.d.ts +2 -3
  28. package/dist/runtime-kernel/tools/toolContextRuntime.d.cts +1 -1
  29. package/dist/runtime-kernel/tools/toolContextRuntime.d.ts +1 -1
  30. package/dist/runtime-kernel/tools/toolExecutionContext.d.cts +0 -10
  31. package/dist/runtime-kernel/tools/toolExecutionContext.d.ts +0 -10
  32. package/dist/runtime-kernel.cjs +74 -257
  33. package/dist/runtime-kernel.cjs.map +1 -1
  34. package/dist/runtime-kernel.js +74 -257
  35. package/dist/runtime-kernel.js.map +1 -1
  36. package/dist/testkit.cjs +82 -265
  37. package/dist/testkit.cjs.map +1 -1
  38. package/dist/testkit.js +82 -265
  39. package/dist/testkit.js.map +1 -1
  40. package/docs/integration/llm-provider.md +1 -1
  41. package/docs/integration/tool-development-guide.md +1 -1
  42. package/package.json +1 -1
package/dist/testkit.js CHANGED
@@ -608,18 +608,6 @@ var ErrorClassifier = class {
608
608
  });
609
609
  }
610
610
  }
611
- const quotaPatterns = ["\u5DF2\u8FBE\u4E0A\u9650", "\u514D\u8D39\u671F\u5DF2\u7ED3\u675F"];
612
- for (const pattern of quotaPatterns) {
613
- if (errorMessage.includes(pattern)) {
614
- logClassification(context, "\u68C0\u6D4B\u5230\u4E91\u7AEF\u989D\u5EA6\u9650\u5236\uFF0C\u4E0D\u91CD\u8BD5", { matchedPattern: pattern });
615
- return createClassification("non_retryable" /* NON_RETRYABLE */, `\u4E91\u7AEF\u989D\u5EA6\u9650\u5236: ${pattern}`, null, {
616
- errorCode: ENGINE_ERROR_CODES.LLM_PROVIDER_DOWN,
617
- recoverable: false,
618
- hint: "check_billing_or_provider_status",
619
- metadata: { matchedPattern: pattern }
620
- });
621
- }
622
- }
623
611
  const authPatterns = [
624
612
  { pattern: "unauthorized", code: "401" },
625
613
  { pattern: "forbidden", code: "403" },
@@ -874,17 +862,6 @@ var ErrorClassifier = class {
874
862
  }
875
863
  return Math.max(baseDelay, classification.suggestedDelay ?? 0);
876
864
  }
877
- static isCloudQuotaError(error) {
878
- const msg = (error.message || "").toLowerCase();
879
- const patterns = [
880
- "\u989D\u5EA6\u4E0A\u9650",
881
- "\u5DF2\u8FBE\u4E0A\u9650",
882
- "\u514D\u8D39\u671F\u5DF2\u7ED3\u675F",
883
- "\u8BE5\u6A21\u578B\u6682\u4E0D\u53EF\u7528",
884
- "cloud_quota_exhausted"
885
- ];
886
- return patterns.some((pattern) => msg.includes(pattern));
887
- }
888
865
  };
889
866
  var NonBlankIdentitySchema = z.string().max(200).refine(
890
867
  (value) => value.trim().length > 0 && value === value.trim(),
@@ -4073,8 +4050,8 @@ var TokenCalculator = class {
4073
4050
  return;
4074
4051
  }
4075
4052
  this.failedEncodingWarnings.add(requestedEncoding);
4076
- const logger23 = new Logger("TokenCalculator");
4077
- logger23.warn("tiktoken encoding unavailable, falling back to avgCharsPerToken estimator", {
4053
+ const logger22 = new Logger("TokenCalculator");
4054
+ logger22.warn("tiktoken encoding unavailable, falling back to avgCharsPerToken estimator", {
4078
4055
  requestedEncoding,
4079
4056
  error
4080
4057
  });
@@ -4166,49 +4143,6 @@ var llmTelemetryMiddleware = async (ctx, stage, next) => {
4166
4143
  });
4167
4144
  };
4168
4145
 
4169
- // src/runtime-kernel/graph-engine/functions/runModelLock.ts
4170
- function readNonEmptyString4(value) {
4171
- if (typeof value !== "string") return void 0;
4172
- const trimmed = value.trim();
4173
- return trimmed.length > 0 ? trimmed : void 0;
4174
- }
4175
- function decideRunModelLockPatch(params) {
4176
- if (params.stageId !== "execute_llm") {
4177
- return { shouldLog: false };
4178
- }
4179
- const normalized = readNonEmptyString4(params.appliedFallbackModelId);
4180
- if (!normalized) {
4181
- return { shouldLog: false };
4182
- }
4183
- if (readNonEmptyString4(params.currentRunLockedModelId) === normalized) {
4184
- return { shouldLog: false };
4185
- }
4186
- return {
4187
- executorLocalPatch: { runLockedModelId: normalized },
4188
- shouldLog: true
4189
- };
4190
- }
4191
-
4192
- // src/runtime-kernel/graph-engine/tick-pipeline/middlewares/runModelLockMiddleware.ts
4193
- var logger4 = new Logger("GraphAgentExecutor");
4194
- var runModelLockMiddleware = async (ctx, stage, next) => {
4195
- await next();
4196
- const decision = decideRunModelLockPatch({
4197
- stageId: stage.id,
4198
- appliedFallbackModelId: ctx.cloudQuotaFallbackAppliedModelId,
4199
- currentRunLockedModelId: ctx.executorLocalPatch?.runLockedModelId ?? ctx.executorLocal?.runLockedModelId
4200
- });
4201
- if (!decision.executorLocalPatch) {
4202
- return;
4203
- }
4204
- if (decision.shouldLog) {
4205
- logger4.warn(`\u68C0\u6D4B\u5230\u4E91\u7AEF\u989D\u5EA6\u964D\u7EA7\uFF0C\u5DF2\u9501\u5B9A\u672C run \u540E\u7EED\u6A21\u578B: ${ctx.modelId} -> ${decision.executorLocalPatch.runLockedModelId}`);
4206
- }
4207
- return {
4208
- executorLocalPatch: decision.executorLocalPatch
4209
- };
4210
- };
4211
-
4212
4146
  // src/runtime-kernel/graph-engine/tick-pipeline/runTickPipeline.ts
4213
4147
  var tickPipelineContextKeys = [
4214
4148
  "input",
@@ -4244,7 +4178,6 @@ var tickPipelineContextKeys = [
4244
4178
  "decision",
4245
4179
  "systemReminderHitRuleIds",
4246
4180
  "contextTrace",
4247
- "cloudQuotaFallbackAppliedModelId",
4248
4181
  "modelFallbackAudit",
4249
4182
  "telemetry",
4250
4183
  "audit",
@@ -4583,7 +4516,7 @@ ${normalized}
4583
4516
  }
4584
4517
 
4585
4518
  // src/runtime-kernel/system-reminder/apply.ts
4586
- var logger5 = new Logger("SystemReminder");
4519
+ var logger4 = new Logger("SystemReminder");
4587
4520
  var readString2 = (v) => {
4588
4521
  if (typeof v !== "string") return void 0;
4589
4522
  const s = v;
@@ -4646,7 +4579,7 @@ function applySystemReminders(params) {
4646
4579
  } catch {
4647
4580
  }
4648
4581
  }
4649
- logger5.info("SystemReminder \u5DF2\u6CE8\u5165\u5230 LLM \u8F93\u5165\u672B\u5C3E", {
4582
+ logger4.info("SystemReminder \u5DF2\u6CE8\u5165\u5230 LLM \u8F93\u5165\u672B\u5C3E", {
4650
4583
  ruleIds: injectedRuleIds.length > 0 ? injectedRuleIds : Array.from(seenRuleIds),
4651
4584
  promptKey: ctx.request.promptKey,
4652
4585
  executorLocal: {
@@ -5356,7 +5289,6 @@ function createExecuteLlmStage(dependencies) {
5356
5289
  "turnId"
5357
5290
  ],
5358
5291
  writes: [
5359
- "cloudQuotaFallbackAppliedModelId",
5360
5292
  "modelFallbackAudit",
5361
5293
  "llmCallStartedAt",
5362
5294
  "llmResp",
@@ -5364,7 +5296,6 @@ function createExecuteLlmStage(dependencies) {
5364
5296
  "contextUsage"
5365
5297
  ],
5366
5298
  async run(ctx) {
5367
- let cloudQuotaFallbackAppliedModelId;
5368
5299
  let modelFallbackAudit;
5369
5300
  let contextUsage;
5370
5301
  const modelFallbackRejections = [];
@@ -5383,9 +5314,6 @@ function createExecuteLlmStage(dependencies) {
5383
5314
  streamEventHandler,
5384
5315
  ctx.signal,
5385
5316
  {
5386
- onCloudQuotaFallbackApplied(fallbackModelId) {
5387
- cloudQuotaFallbackAppliedModelId = readNonEmptyString3(fallbackModelId);
5388
- },
5389
5317
  onLlmAttemptSucceeded(_activeModelId, attemptContextUsage) {
5390
5318
  contextUsage = attemptContextUsage;
5391
5319
  },
@@ -5482,7 +5410,6 @@ function createExecuteLlmStage(dependencies) {
5482
5410
  });
5483
5411
  }
5484
5412
  return {
5485
- cloudQuotaFallbackAppliedModelId,
5486
5413
  modelFallbackAudit,
5487
5414
  llmCallStartedAt,
5488
5415
  llmResp,
@@ -6403,18 +6330,16 @@ function createPrepareCallStage(dependencies) {
6403
6330
  "toolDefinitionTokens"
6404
6331
  ],
6405
6332
  async run(ctx) {
6406
- const lockedRunModelId = readNonEmptyString3(ctx.executorLocal?.runLockedModelId);
6407
- const requestedModelId = lockedRunModelId ?? ctx.request.model_id;
6333
+ const requestedModelId = ctx.request.model_id;
6408
6334
  const modelId = dependencies.modelResolver.resolveModelId(requestedModelId);
6409
6335
  await emitAuditEnvelope(ctx.audit, {
6410
6336
  action: "model.select",
6411
6337
  actor: { kind: "system" },
6412
6338
  decision: {
6413
6339
  outcome: "recorded",
6414
- reason: lockedRunModelId ? "run model lock" : requestedModelId ? "request model id" : "default model resolver",
6340
+ reason: requestedModelId ? "request model id" : "default model resolver",
6415
6341
  metadata: {
6416
6342
  requestedModelId,
6417
- lockedRunModelId,
6418
6343
  selectedModelId: modelId
6419
6344
  }
6420
6345
  },
@@ -6461,10 +6386,6 @@ function createPrepareCallStage(dependencies) {
6461
6386
  if (ctx.executorLocal?.lockRequestedModelId === true) {
6462
6387
  llmOptions.allow_model_fallback = false;
6463
6388
  }
6464
- const isRunContinuation = ctx.executorLocal?.llmInvocationKind === "continuation";
6465
- if (dependencies.cloudQuotaFallbackModelId && modelConfig?.billing_mode === "cloud" && modelId !== dependencies.cloudQuotaFallbackModelId && isRunContinuation && ctx.executorLocal?.lockRequestedModelId !== true) {
6466
- llmOptions.cloud_quota_fallback_model_id = dependencies.cloudQuotaFallbackModelId;
6467
- }
6468
6389
  const effectiveEffort = resolveEffectiveEffort(
6469
6390
  ctx.request.reasoning_effort,
6470
6391
  modelConfig?.reasoning
@@ -6581,12 +6502,11 @@ function applyCalibration(rawLocalTotal, imageInputTokens, coefficient) {
6581
6502
  }
6582
6503
 
6583
6504
  // src/runtime-kernel/graph-engine/executor.ts
6584
- var logger6 = new Logger("GraphAgentExecutor");
6505
+ var logger5 = new Logger("GraphAgentExecutor");
6585
6506
  var GraphAgentExecutor = class {
6586
6507
  llmCaller;
6587
6508
  toolRuntime;
6588
6509
  contextBuilder;
6589
- cloudQuotaFallbackModelId;
6590
6510
  modelResolver;
6591
6511
  modelCatalog;
6592
6512
  telemetryPort;
@@ -6598,7 +6518,6 @@ var GraphAgentExecutor = class {
6598
6518
  this.llmCaller = dependencies.llmCaller;
6599
6519
  this.toolRuntime = dependencies.toolRuntime;
6600
6520
  this.contextBuilder = dependencies.contextBuilder;
6601
- this.cloudQuotaFallbackModelId = readNonEmptyString3(dependencies.cloudQuotaFallbackModelId);
6602
6521
  this.modelCatalog = dependencies.modelCatalog ?? createEmptyModelCatalog();
6603
6522
  this.modelResolver = dependencies.modelResolver ?? new ModelResolver({
6604
6523
  modelCatalog: this.modelCatalog
@@ -6615,8 +6534,7 @@ var GraphAgentExecutor = class {
6615
6534
  createPrepareCallStage({
6616
6535
  modelResolver: this.modelResolver,
6617
6536
  modelCatalog: this.modelCatalog,
6618
- toolCatalog: this.toolRuntime,
6619
- cloudQuotaFallbackModelId: this.cloudQuotaFallbackModelId
6537
+ toolCatalog: this.toolRuntime
6620
6538
  }),
6621
6539
  createBuildContextStage({
6622
6540
  contextBuilder: this.contextBuilder
@@ -6638,7 +6556,7 @@ var GraphAgentExecutor = class {
6638
6556
  }),
6639
6557
  createBuildDecisionStage()
6640
6558
  ];
6641
- this.middlewares = [llmTelemetryMiddleware, runModelLockMiddleware];
6559
+ this.middlewares = [llmTelemetryMiddleware];
6642
6560
  }
6643
6561
  async tick(input, eventHandler) {
6644
6562
  const ctx = {
@@ -6663,7 +6581,7 @@ var GraphAgentExecutor = class {
6663
6581
  audit: this.auditPort,
6664
6582
  tokenizer: this.tokenizer
6665
6583
  };
6666
- logger6.info("[GraphAgentExecutor] tick \u8C03\u7528", {
6584
+ logger5.info("[GraphAgentExecutor] tick \u8C03\u7528", {
6667
6585
  stream: input.stream === true,
6668
6586
  hasEventHandler: Boolean(eventHandler),
6669
6587
  hasSummarizationCallbacks: Boolean(input.summarizationCallbacks)
@@ -7686,7 +7604,7 @@ var LlmNodeEventBridge = class {
7686
7604
  };
7687
7605
 
7688
7606
  // src/runtime-kernel/graph-engine/nodes/llmNode.ts
7689
- var logger7 = new Logger("LlmNode");
7607
+ var logger6 = new Logger("LlmNode");
7690
7608
  var LlmNode = class {
7691
7609
  id = "llm";
7692
7610
  reasoner;
@@ -7695,7 +7613,7 @@ var LlmNode = class {
7695
7613
  }
7696
7614
  async run(state) {
7697
7615
  const local = state.local ?? {};
7698
- logger7.info("[LlmNode] \u5F00\u59CB\u6267\u884C LLM \u8282\u70B9", {
7616
+ logger6.info("[LlmNode] \u5F00\u59CB\u6267\u884C LLM \u8282\u70B9", {
7699
7617
  localKeys: Object.keys(local)
7700
7618
  });
7701
7619
  const graphLocal = readGraphAgentLocal(state.local);
@@ -7710,12 +7628,12 @@ var LlmNode = class {
7710
7628
  signal,
7711
7629
  history
7712
7630
  } = graphLocal;
7713
- logger7.info("[LlmNode] \u5DF2\u52A0\u8F7D\u5386\u53F2\u4E8B\u4EF6", {
7631
+ logger6.info("[LlmNode] \u5DF2\u52A0\u8F7D\u5386\u53F2\u4E8B\u4EF6", {
7714
7632
  historyCount: history.length,
7715
7633
  hasSummarizationCallbacks: Boolean(summarizationCallbacks)
7716
7634
  });
7717
7635
  if (!request) {
7718
- logger7.warn("Request object is missing, yielding.");
7636
+ logger6.warn("Request object is missing, yielding.");
7719
7637
  return { kind: "yield", events: [] };
7720
7638
  }
7721
7639
  const turnId = requireRuntimeIdentity(graphLocal.turnId, "turnId");
@@ -7808,12 +7726,12 @@ var LlmNode = class {
7808
7726
  ...nodeState.streamRuntimeEvents,
7809
7727
  ...contextUsageEvent ? [contextUsageEvent] : []
7810
7728
  ];
7811
- logger7.info("[LlmNode] \u5386\u53F2\u4E8B\u4EF6\u5DF2\u66F4\u65B0", {
7729
+ logger6.info("[LlmNode] \u5386\u53F2\u4E8B\u4EF6\u5DF2\u66F4\u65B0", {
7812
7730
  previousCount: history.length,
7813
7731
  nextCount: patch.history.length,
7814
7732
  streamedEventCount: nodeState.streamRuntimeEvents.length
7815
7733
  });
7816
- logger7.info("[LlmNode] \u6267\u884C\u5668\u51B3\u7B56\u5B8C\u6210", {
7734
+ logger6.info("[LlmNode] \u6267\u884C\u5668\u51B3\u7B56\u5B8C\u6210", {
7817
7735
  decisionKind: decision.kind,
7818
7736
  emittedEventCount: combinedEvents.length
7819
7737
  });
@@ -7835,7 +7753,7 @@ var LlmNode = class {
7835
7753
  }
7836
7754
  case "error": {
7837
7755
  const { name, message, stack } = decision.error;
7838
- logger7.error("[LlmNode] Executor returned an error", { name, message, stack });
7756
+ logger6.error("[LlmNode] Executor returned an error", { name, message, stack });
7839
7757
  return { kind: "yield", events: combinedEvents };
7840
7758
  }
7841
7759
  default: {
@@ -7941,7 +7859,7 @@ async function resolveToolModelInput(input) {
7941
7859
  }
7942
7860
 
7943
7861
  // src/runtime-kernel/graph-engine/nodes/toolNode.finalAnswerProjector.ts
7944
- function readNonEmptyString5(value) {
7862
+ function readNonEmptyString4(value) {
7945
7863
  if (typeof value !== "string") {
7946
7864
  return void 0;
7947
7865
  }
@@ -7949,7 +7867,7 @@ function readNonEmptyString5(value) {
7949
7867
  return normalized.length > 0 ? normalized : void 0;
7950
7868
  }
7951
7869
  function resolveFinalAnswerFromToolControl(finalAnswer) {
7952
- return readNonEmptyString5(finalAnswer);
7870
+ return readNonEmptyString4(finalAnswer);
7953
7871
  }
7954
7872
 
7955
7873
  // src/runtime-kernel/graph-engine/nodes/toolNode.helpers.ts
@@ -8205,7 +8123,7 @@ function buildErrorLocalState(params) {
8205
8123
  }
8206
8124
 
8207
8125
  // src/runtime-kernel/tools/argNormalizer.ts
8208
- var logger8 = new Logger("ToolArgNormalizer");
8126
+ var logger7 = new Logger("ToolArgNormalizer");
8209
8127
  function isRecord10(v) {
8210
8128
  return !!v && typeof v === "object" && !Array.isArray(v);
8211
8129
  }
@@ -8225,7 +8143,7 @@ function joinPath(basePath, segment) {
8225
8143
  function logJsonEncodedNormalization(expectedType, options) {
8226
8144
  const toolPrefix = options.toolName ? `${options.toolName}.` : "";
8227
8145
  const path = options.path ?? "<root>";
8228
- logger8.warn("normalized JSON-encoded tool argument", {
8146
+ logger7.warn("normalized JSON-encoded tool argument", {
8229
8147
  expectedType,
8230
8148
  path: `${toolPrefix}${path}`
8231
8149
  });
@@ -8395,7 +8313,6 @@ var TOOL_CONTEXT_RUNTIME_RESERVED_KEYS = [
8395
8313
  "conversationView",
8396
8314
  "userQuery",
8397
8315
  "modelId",
8398
- "activeModelId",
8399
8316
  "conversationId",
8400
8317
  "turnId",
8401
8318
  "runId",
@@ -8582,7 +8499,7 @@ function stripRuntimeReservedToolContextPatch(patch) {
8582
8499
  }
8583
8500
 
8584
8501
  // src/runtime-kernel/graph-engine/nodes/toolNode.eventBridge.ts
8585
- var logger9 = new Logger("ToolNode");
8502
+ var logger8 = new Logger("ToolNode");
8586
8503
  var ToolNodeEventBridge = class {
8587
8504
  constructor(deps) {
8588
8505
  this.deps = deps;
@@ -8604,7 +8521,7 @@ var ToolNodeEventBridge = class {
8604
8521
  status,
8605
8522
  payload: { ...payload }
8606
8523
  };
8607
- logger9.info("[ToolNode] \u53D1\u51FA tool_process \u4E8B\u4EF6", {
8524
+ logger8.info("[ToolNode] \u53D1\u51FA tool_process \u4E8B\u4EF6", {
8608
8525
  phase,
8609
8526
  status,
8610
8527
  toolName: this.deps.toolName,
@@ -8644,7 +8561,7 @@ var ToolNodeEventBridge = class {
8644
8561
  const answerId = generateAnswerSegmentId();
8645
8562
  const id = answerId;
8646
8563
  const timestamp = Date.now();
8647
- logger9.info("[ToolNode] \u5DE5\u5177\u8F93\u51FA\u6620\u5C04\u4E3A final_answer", {
8564
+ logger8.info("[ToolNode] \u5DE5\u5177\u8F93\u51FA\u6620\u5C04\u4E3A final_answer", {
8648
8565
  sourceToolName: params.sourceToolName,
8649
8566
  toolCallId: this.deps.toolCallId,
8650
8567
  conversationId: this.deps.conversationId,
@@ -8702,7 +8619,7 @@ var ToolNodeEventBridge = class {
8702
8619
  };
8703
8620
 
8704
8621
  // src/runtime-kernel/graph-engine/nodes/toolNode.executionSetup.ts
8705
- var logger10 = new Logger("ToolNode");
8622
+ var logger9 = new Logger("ToolNode");
8706
8623
  function parseToolArgs(call) {
8707
8624
  const rawArguments = typeof call.function?.arguments === "string" ? call.function.arguments : "";
8708
8625
  if (!rawArguments.trim()) {
@@ -8722,19 +8639,13 @@ function parseToolArgs(call) {
8722
8639
  return { ok: true, value: parsed };
8723
8640
  } catch (error) {
8724
8641
  const reason = error instanceof Error ? error.message : "Unknown JSON parse error";
8725
- logger10.warn("failed to parse tool arguments", { error });
8642
+ logger9.warn("failed to parse tool arguments", { error });
8726
8643
  return {
8727
8644
  ok: false,
8728
8645
  error: `Tool arguments are not valid JSON: ${reason}`
8729
8646
  };
8730
8647
  }
8731
8648
  }
8732
- function readRunLockedModelId(local) {
8733
- const executorLocal = local.executorLocal;
8734
- if (!isRecord9(executorLocal)) return void 0;
8735
- const lockedModelId = executorLocal.runLockedModelId;
8736
- return typeof lockedModelId === "string" && lockedModelId.trim() ? lockedModelId : void 0;
8737
- }
8738
8649
  function prepareToolNodeContext(state) {
8739
8650
  const local = state.local || {};
8740
8651
  const toolContext = isRecord9(local.toolContext) ? local.toolContext : {};
@@ -8752,7 +8663,6 @@ function prepareToolNodeContext(state) {
8752
8663
  }
8753
8664
  });
8754
8665
  attachWorkingHistoryView({ state, toolContext });
8755
- toolContext.activeModelId = readRunLockedModelId(local) ?? toolContext.modelId;
8756
8666
  return {
8757
8667
  state,
8758
8668
  local,
@@ -9123,7 +9033,7 @@ async function claimPendingUserInputs(state, result) {
9123
9033
  }
9124
9034
 
9125
9035
  // src/runtime-kernel/graph-engine/nodes/toolNode.ts
9126
- var logger11 = new Logger("ToolNode");
9036
+ var logger10 = new Logger("ToolNode");
9127
9037
  function isAbortSignal(value) {
9128
9038
  return value !== null && typeof value === "object" && "aborted" in value;
9129
9039
  }
@@ -9336,7 +9246,7 @@ var ToolNode = class {
9336
9246
  throw abortError;
9337
9247
  }
9338
9248
  const prepared = prepareToolNodeContext(state);
9339
- logger11.info("[ToolNode] \u5F00\u59CB\u6267\u884C\u5DE5\u5177\u8282\u70B9", {
9249
+ logger10.info("[ToolNode] \u5F00\u59CB\u6267\u884C\u5DE5\u5177\u8282\u70B9", {
9340
9250
  conversationId: prepared.conversationId,
9341
9251
  turnId: prepared.turnId,
9342
9252
  pendingCallCount: calls.length
@@ -9351,7 +9261,7 @@ var ToolNode = class {
9351
9261
  toolCatalog: this.toolRuntime
9352
9262
  });
9353
9263
  if (!execution) {
9354
- logger11.warn("no tool name found in call");
9264
+ logger10.warn("no tool name found in call");
9355
9265
  return { kind: "yield", events: [] };
9356
9266
  }
9357
9267
  if (typeof execution.protocolError === "string") {
@@ -9391,7 +9301,7 @@ var ToolNode = class {
9391
9301
  call,
9392
9302
  context: prepared.toolContext,
9393
9303
  abortGraceMs: this.abortGraceMs,
9394
- onAbandon: () => logger11.warn("[ToolNode] \u5DE5\u5177\u672A\u5728\u505C\u6B62\u671F\u9650\u5185\u7ED3\u675F\uFF0C\u6309\u4E2D\u65AD\u5904\u7406\u5E76\u4E22\u5F03\u8FDF\u5230\u7ED3\u679C", {
9304
+ onAbandon: () => logger10.warn("[ToolNode] \u5DE5\u5177\u672A\u5728\u505C\u6B62\u671F\u9650\u5185\u7ED3\u675F\uFF0C\u6309\u4E2D\u65AD\u5904\u7406\u5E76\u4E22\u5F03\u8FDF\u5230\u7ED3\u679C", {
9395
9305
  toolName: execution.toolName,
9396
9306
  toolCallId: execution.toolCallId,
9397
9307
  conversationId: prepared.conversationId,
@@ -9561,7 +9471,7 @@ var ToolNode = class {
9561
9471
  runtimeEvents: context.bridge.getRuntimeEvents()
9562
9472
  });
9563
9473
  if (control?.terminateRun) {
9564
- logger11.info("[ToolNode] \u6536\u5230 control.terminateRun\uFF0C\u6267\u884C\u5B8C\u5DE5\u5177\u540E\u76F4\u63A5 yield \u7ED3\u675F\u672C\u8F6E run", {
9474
+ logger10.info("[ToolNode] \u6536\u5230 control.terminateRun\uFF0C\u6267\u884C\u5B8C\u5DE5\u5177\u540E\u76F4\u63A5 yield \u7ED3\u675F\u672C\u8F6E run", {
9565
9475
  toolName: context.toolName,
9566
9476
  toolCallId: context.toolCallId,
9567
9477
  conversationId: context.conversationId,
@@ -9570,7 +9480,7 @@ var ToolNode = class {
9570
9480
  return { kind: "yield", events: context.bridge.getRuntimeEvents() };
9571
9481
  }
9572
9482
  if (remainingCalls.length === 0 && context.local.toolBatchCompletionMode === "yield_after_batch") {
9573
- logger11.info("[ToolNode] \u5DE5\u5177\u6279\u6B21\u5DF2\u7ED3\u7B97\uFF0C\u6309 Host \u7B56\u7565\u76F4\u63A5 yield", {
9483
+ logger10.info("[ToolNode] \u5DE5\u5177\u6279\u6B21\u5DF2\u7ED3\u7B97\uFF0C\u6309 Host \u7B56\u7565\u76F4\u63A5 yield", {
9574
9484
  toolName: context.toolName,
9575
9485
  toolCallId: context.toolCallId,
9576
9486
  conversationId: context.conversationId,
@@ -10017,8 +9927,9 @@ var executor = z.object({
10017
9927
  lastStepsHintThreshold: counter.optional(),
10018
9928
  systemReminderPolicy: AgentSpecSystemReminderPolicy.optional(),
10019
9929
  toolObservationPolicy: AgentSpecToolObservationGovernancePolicy.optional(),
9930
+ // 已删除字段:0.45 及更早的 checkpoint 可能带 lastSuccessfulLlmModelId,0.46 及更早的可能带云端额度兜底留下的
9931
+ // runLockedModelId;照常接受,读入时丢弃(兜底已移除,恢复后按请求的模型继续)。
10020
9932
  runLockedModelId: z.string().optional(),
10021
- // 0.45 及更早的 checkpoint 可能带这个已删除字段;照常接受,读入时丢弃。
10022
9933
  lastSuccessfulLlmModelId: z.string().optional(),
10023
9934
  llmInvocationKind: z.enum(["user_initiated", "continuation"]).optional(),
10024
9935
  llmInvocationCount: counter.optional(),
@@ -10028,7 +9939,7 @@ var executor = z.object({
10028
9939
  committedCount: counter,
10029
9940
  lastCommittedFingerprint: z.string().optional()
10030
9941
  }).strict().optional()
10031
- }).strict().transform(({ lastSuccessfulLlmModelId: _retired, ...state }) => state);
9942
+ }).strict().transform(({ lastSuccessfulLlmModelId: _retired, runLockedModelId: _retiredLock, ...state }) => state);
10032
9943
  var checkpoint = z.object({
10033
9944
  nodeId: z.string().min(1),
10034
9945
  schemaVersion: z.literal(ENGINE_STATE_SCHEMA_VERSION).optional(),
@@ -10342,7 +10253,7 @@ __export(execution_exports, {
10342
10253
  });
10343
10254
 
10344
10255
  // src/runtime-kernel/execution/event-bus.ts
10345
- var logger12 = new Logger("EventBus");
10256
+ var logger11 = new Logger("EventBus");
10346
10257
  var TypedEventEmitter = class {
10347
10258
  listeners = /* @__PURE__ */ new Map();
10348
10259
  maxListeners = 10;
@@ -10350,7 +10261,7 @@ var TypedEventEmitter = class {
10350
10261
  const listeners = this.getListeners(event);
10351
10262
  listeners.add(listener);
10352
10263
  if (listeners.size > this.maxListeners) {
10353
- logger12.warn("EventBus listener count exceeds configured max", {
10264
+ logger11.warn("EventBus listener count exceeds configured max", {
10354
10265
  event: String(event),
10355
10266
  count: listeners.size,
10356
10267
  maxListeners: this.maxListeners
@@ -10410,7 +10321,7 @@ var EventBus = class extends TypedEventEmitter {
10410
10321
  super();
10411
10322
  this.executionId = executionId;
10412
10323
  this.setMaxListeners(30);
10413
- logger12.info(`EventBus created for execution ${this.executionId}`);
10324
+ logger11.info(`EventBus created for execution ${this.executionId}`);
10414
10325
  }
10415
10326
  /**
10416
10327
  * 发布一个事件到总线
@@ -10419,7 +10330,7 @@ var EventBus = class extends TypedEventEmitter {
10419
10330
  publish(envelope) {
10420
10331
  if (envelope.trace.execution_id !== this.executionId) {
10421
10332
  const error = new Error("EventEnvelope execution_id does not match EventBus instance.");
10422
- logger12.error("Mismatched execution_id", {
10333
+ logger11.error("Mismatched execution_id", {
10423
10334
  busExecutionId: this.executionId,
10424
10335
  eventExecutionId: envelope.trace.execution_id,
10425
10336
  eventSeq: envelope.seq
@@ -10431,7 +10342,7 @@ var EventBus = class extends TypedEventEmitter {
10431
10342
  const error = new Error(
10432
10343
  "EventBus only accepts RuntimeEvent with formal run routing identity."
10433
10344
  );
10434
- logger12.error("RuntimeEvent is missing formal run routing identity", {
10345
+ logger11.error("RuntimeEvent is missing formal run routing identity", {
10435
10346
  executionId: this.executionId,
10436
10347
  eventId: envelope.payload.id,
10437
10348
  eventType: envelope.payload.type
@@ -10445,14 +10356,14 @@ var EventBus = class extends TypedEventEmitter {
10445
10356
  * 关闭总线,清理所有监听器
10446
10357
  */
10447
10358
  close() {
10448
- logger12.info(`Closing EventBus for execution ${this.executionId}`);
10359
+ logger11.info(`Closing EventBus for execution ${this.executionId}`);
10449
10360
  this.emit("close");
10450
10361
  this.removeAllListeners();
10451
10362
  }
10452
10363
  };
10453
10364
 
10454
10365
  // src/runtime-kernel/execution/sequencer.ts
10455
- var logger13 = new Logger("EventSequencer");
10366
+ var logger12 = new Logger("EventSequencer");
10456
10367
  var EventSequencer = class {
10457
10368
  executionId;
10458
10369
  traceId;
@@ -10460,7 +10371,7 @@ var EventSequencer = class {
10460
10371
  constructor(conversationId, traceId) {
10461
10372
  this.executionId = generateExecutionId();
10462
10373
  this.traceId = traceId || generateTraceId();
10463
- logger13.info(`EventSequencer created for conversation ${conversationId}`, {
10374
+ logger12.info(`EventSequencer created for conversation ${conversationId}`, {
10464
10375
  executionId: this.executionId,
10465
10376
  traceId: this.traceId
10466
10377
  });
@@ -11318,7 +11229,7 @@ var ThoughtStreamSegmenter = class {
11318
11229
  };
11319
11230
 
11320
11231
  // src/runtime-kernel/llm/streaming-adapter.ts
11321
- var logger14 = new Logger("LlmCaller");
11232
+ var logger13 = new Logger("LlmCaller");
11322
11233
  var CanonicalInferenceFailureError = class extends Error {
11323
11234
  errorCode;
11324
11235
  recoverable;
@@ -11542,7 +11453,7 @@ async function callLlmStream(params) {
11542
11453
  } catch (error) {
11543
11454
  const normalized = error instanceof Error ? error : new Error(String(error));
11544
11455
  if (normalized.name === "AbortError") {
11545
- logger14.info("Canonical inference \u6536\u5230\u53D6\u6D88\u7EC8\u6001\uFF0C\u4E0D\u53D1\u5E03\u666E\u901A error event", { modelId });
11456
+ logger13.info("Canonical inference \u6536\u5230\u53D6\u6D88\u7EC8\u6001\uFF0C\u4E0D\u53D1\u5E03\u666E\u901A error event", { modelId });
11546
11457
  throw normalized;
11547
11458
  }
11548
11459
  const classification = ErrorClassifier.classify(normalized, {
@@ -11618,7 +11529,7 @@ var LlmRetryEpisode = class {
11618
11529
  };
11619
11530
 
11620
11531
  // src/runtime-kernel/llm/retry-fallback-routing.ts
11621
- var logger15 = new Logger("LlmCaller");
11532
+ var logger14 = new Logger("LlmCaller");
11622
11533
  function tryPolicyModelSwitch(deps, activeModelId, excludedModelIds, requirement, fallbackObserver, error, evaluateFallbackPromptCapacity2) {
11623
11534
  deps.modelCatalog.getModelById(activeModelId);
11624
11535
  const policyDecision = deps.policyEngine.decideOnError(error, {
@@ -11648,81 +11559,16 @@ function tryPolicyModelSwitch(deps, activeModelId, excludedModelIds, requirement
11648
11559
  reason: "no_eligible_fallback_candidate",
11649
11560
  requiredPlacements: requirement.placements
11650
11561
  });
11651
- logger15.warn("Policy\u8981\u6C42\u5207\u6362\u6A21\u578B\uFF0C\u4F46\u672A\u627E\u5230\u53EF\u7528\u5907\u7528\u6A21\u578B\uFF08\u53EF\u80FD\u672A\u914D\u7F6E API Key\uFF09");
11562
+ logger14.warn("Policy\u8981\u6C42\u5207\u6362\u6A21\u578B\uFF0C\u4F46\u672A\u627E\u5230\u53EF\u7528\u5907\u7528\u6A21\u578B\uFF08\u53EF\u80FD\u672A\u914D\u7F6E API Key\uFF09");
11652
11563
  return null;
11653
11564
  }
11654
- logger15.warn("Policy \u5207\u6362\u6A21\u578B\u7EE7\u7EED", {
11565
+ logger14.warn("Policy \u5207\u6362\u6A21\u578B\u7EE7\u7EED", {
11655
11566
  reason: policyDecision.reason,
11656
11567
  activeModelId,
11657
11568
  fallbackModelId
11658
11569
  });
11659
11570
  return fallbackModelId;
11660
11571
  }
11661
- function tryCloudQuotaFallback({
11662
- deps,
11663
- activeModelId,
11664
- options,
11665
- excludedModelIds,
11666
- requirement,
11667
- error,
11668
- fallbackObserver,
11669
- evaluateFallbackPromptCapacity: evaluateFallbackPromptCapacity2
11670
- }) {
11671
- const fallbackModelId = options.cloud_quota_fallback_model_id;
11672
- if (!fallbackModelId || !ErrorClassifier.isCloudQuotaError(error) || excludedModelIds.has(fallbackModelId)) {
11673
- return null;
11674
- }
11675
- const fallbackConfig = deps.modelCatalog.getModelById(fallbackModelId);
11676
- if (!fallbackConfig?.api_key) {
11677
- fallbackObserver?.onModelFallbackRejected?.({
11678
- fromModelId: activeModelId,
11679
- candidateModelId: fallbackModelId,
11680
- policy: "cloud-quota",
11681
- reason: "fallback_model_unavailable",
11682
- requiredPlacements: requirement.placements
11683
- });
11684
- logger15.warn("\u4E91\u7AEF\u9650\u989D\u964D\u7EA7\u76EE\u6807\u4E0D\u53EF\u7528\uFF08\u672A\u6CE8\u518C\u6216\u7F3A\u5C11 API Key\uFF09", { fallbackModelId });
11685
- return null;
11686
- }
11687
- const compatibility = evaluateModelInputCompatibility(fallbackConfig, requirement);
11688
- if (!compatibility.compatible) {
11689
- fallbackObserver?.onModelFallbackRejected?.({
11690
- fromModelId: activeModelId,
11691
- candidateModelId: fallbackModelId,
11692
- policy: "cloud-quota",
11693
- reason: compatibility.reason,
11694
- requiredPlacements: requirement.placements
11695
- });
11696
- logger15.warn("\u4E91\u7AEF\u9650\u989D\u964D\u7EA7\u76EE\u6807\u4E0D\u6EE1\u8DB3\u5F53\u524D\u8F93\u5165\u80FD\u529B\uFF0C\u4FDD\u7559\u539F\u59CB\u9519\u8BEF", {
11697
- fallbackModelId,
11698
- requiredPlacements: requirement.placements,
11699
- reason: compatibility.reason
11700
- });
11701
- return null;
11702
- }
11703
- const capacityAdmission = evaluateFallbackPromptCapacity2?.(fallbackModelId);
11704
- if (capacityAdmission && !capacityAdmission.admitted) {
11705
- fallbackObserver?.onModelFallbackRejected?.({
11706
- fromModelId: activeModelId,
11707
- candidateModelId: fallbackModelId,
11708
- policy: "cloud-quota",
11709
- reason: capacityAdmission.reason,
11710
- requiredPlacements: requirement.placements
11711
- });
11712
- logger15.warn("\u4E91\u7AEF\u9650\u989D\u964D\u7EA7\u76EE\u6807\u4E0D\u6EE1\u8DB3\u5F53\u524D Prompt \u5BB9\u91CF\u8981\u6C42\uFF0C\u4FDD\u7559\u539F\u59CB\u9519\u8BEF", {
11713
- fallbackModelId,
11714
- reason: capacityAdmission.reason
11715
- });
11716
- return null;
11717
- }
11718
- logger15.warn("\u4E91\u7AEF\u9650\u989D\u964D\u7EA7\uFF08run \u5185\u7EED\u8DD1\uFF09", {
11719
- activeModelId,
11720
- fallbackModelId,
11721
- reason: error.message
11722
- });
11723
- fallbackObserver?.onCloudQuotaFallbackApplied?.(fallbackModelId);
11724
- return fallbackModelId;
11725
- }
11726
11572
 
11727
11573
  // src/runtime-kernel/llm/usage-telemetry.ts
11728
11574
  async function callPlainCompletion(inferencePort, modelId, messages, options = {}, signal, traceId) {
@@ -11845,7 +11691,7 @@ var LlmImageInputError = class extends Error {
11845
11691
  };
11846
11692
 
11847
11693
  // src/runtime-kernel/llm/retry-fallback.ts
11848
- var logger16 = new Logger("LlmCaller");
11694
+ var logger15 = new Logger("LlmCaller");
11849
11695
  async function callWithRetryFallback(params) {
11850
11696
  const {
11851
11697
  deps,
@@ -11873,11 +11719,9 @@ async function callWithRetryFallback(params) {
11873
11719
  const retryEpisode = new LlmRetryEpisode(traceId, eventHandler);
11874
11720
  let previousAttemptTracker;
11875
11721
  if (!clientRetryEnabled) {
11876
- const activeCfg = deps.modelCatalog.getModelById(modelId);
11877
- logger16.debug("\u5BA2\u6237\u7AEF\u91CD\u8BD5\u5DF2\u7981\u7528", {
11722
+ logger15.debug("\u5BA2\u6237\u7AEF\u91CD\u8BD5\u5DF2\u7981\u7528", {
11878
11723
  modelId,
11879
- billing_mode: activeCfg?.billing_mode,
11880
- reason: options.retry_policy === "none" ? "options.retry_policy=none" : "model config (cloud billing or enable_client_retry=false)"
11724
+ reason: options.retry_policy === "none" ? "options.retry_policy=none" : "model config enable_client_retry=false"
11881
11725
  });
11882
11726
  }
11883
11727
  try {
@@ -11913,7 +11757,7 @@ async function callWithRetryFallback(params) {
11913
11757
  }) : void 0;
11914
11758
  try {
11915
11759
  if (isRetry) {
11916
- logger16.info("LLM \u8C03\u7528\u91CD\u8BD5", { attempt, configuredMaxRetries });
11760
+ logger15.info("LLM \u8C03\u7528\u91CD\u8BD5", { attempt, configuredMaxRetries });
11917
11761
  }
11918
11762
  actualAttempts++;
11919
11763
  retryEpisode.retrying(actualAttempts);
@@ -11942,7 +11786,7 @@ async function callWithRetryFallback(params) {
11942
11786
  if (deps.retryConfig.enableEmptyResponseRetry && !responseContent?.trim() && !toolCallsFromLLM?.length) {
11943
11787
  throw new Error("LLM\u8FD4\u56DE\u4E86\u7A7A\u54CD\u5E94");
11944
11788
  }
11945
- logger16.debug("LLM \u8C03\u7528\u6210\u529F", { attempts: actualAttempts, maxTotalAttempts });
11789
+ logger15.debug("LLM \u8C03\u7528\u6210\u529F", { attempts: actualAttempts, maxTotalAttempts });
11946
11790
  if (attemptContextUsage) {
11947
11791
  fallbackObserver?.onLlmAttemptSucceeded?.(activeModelId, attemptContextUsage);
11948
11792
  } else {
@@ -11953,7 +11797,7 @@ async function callWithRetryFallback(params) {
11953
11797
  } catch (error) {
11954
11798
  lastError = error instanceof Error ? error : new Error(String(error));
11955
11799
  if (lastError.name === "AbortError") {
11956
- logger16.info("LLM \u8C03\u7528\u5DF2\u53D6\u6D88\uFF0C\u4E0D\u8FDB\u5165 provider failure \u5206\u7C7B\u4E0E\u91CD\u8BD5\u6D41\u7A0B", {
11800
+ logger15.info("LLM \u8C03\u7528\u5DF2\u53D6\u6D88\uFF0C\u4E0D\u8FDB\u5165 provider failure \u5206\u7C7B\u4E0E\u91CD\u8BD5\u6D41\u7A0B", {
11957
11801
  attempt: attempt + 1,
11958
11802
  actualAttempts,
11959
11803
  maxTotalAttempts,
@@ -11972,7 +11816,7 @@ async function callWithRetryFallback(params) {
11972
11816
  total_attempts: actualAttempts,
11973
11817
  error_code: classification.errorCode
11974
11818
  };
11975
- logger16.error("LLM \u8C03\u7528\u5931\u8D25", {
11819
+ logger15.error("LLM \u8C03\u7528\u5931\u8D25", {
11976
11820
  attempt: attempt + 1,
11977
11821
  maxAttempts: currentMaxRetries + 1,
11978
11822
  actualAttempts,
@@ -11981,7 +11825,7 @@ async function callWithRetryFallback(params) {
11981
11825
  });
11982
11826
  previousAttemptTracker = attemptTracker;
11983
11827
  if (!hasLlmAttemptBudgetRemaining({ actualAttempts, maxTotalAttempts })) {
11984
- logger16.error("\u5DF2\u8FBE\u5230 LLM \u603B\u8C03\u7528\u6B21\u6570\u4E0A\u9650\uFF0C\u505C\u6B62\u91CD\u8BD5/\u5207\u6A21\u578B", {
11828
+ logger15.error("\u5DF2\u8FBE\u5230 LLM \u603B\u8C03\u7528\u6B21\u6570\u4E0A\u9650\uFF0C\u505C\u6B62\u91CD\u8BD5/\u5207\u6A21\u578B", {
11985
11829
  actualAttempts,
11986
11830
  maxTotalAttempts
11987
11831
  });
@@ -12011,37 +11855,15 @@ async function callWithRetryFallback(params) {
12011
11855
  attempt -= 1;
12012
11856
  continue;
12013
11857
  }
12014
- const quotaFallbackModelId = tryCloudQuotaFallback({
12015
- deps,
12016
- activeModelId,
12017
- options,
12018
- excludedModelIds,
12019
- requirement,
12020
- error: lastError,
12021
- fallbackObserver,
12022
- evaluateFallbackPromptCapacity: invocationContext?.evaluateFallbackPromptCapacity
12023
- });
12024
- if (quotaFallbackModelId) {
12025
- fallbackObserver?.onModelFallbackApplied?.({
12026
- fromModelId: activeModelId,
12027
- toModelId: quotaFallbackModelId,
12028
- reason: lastError.message,
12029
- policy: "cloud-quota"
12030
- });
12031
- activeModelId = quotaFallbackModelId;
12032
- excludedModelIds.add(quotaFallbackModelId);
12033
- attempt -= 1;
12034
- continue;
12035
- }
12036
11858
  }
12037
11859
  if (classification.category === "non_retryable" /* NON_RETRYABLE */) {
12038
- logger16.error("\u9519\u8BEF\u4E0D\u53EF\u91CD\u8BD5\uFF0C\u76F4\u63A5\u5931\u8D25", { reason: classification.reason });
11860
+ logger15.error("\u9519\u8BEF\u4E0D\u53EF\u91CD\u8BD5\uFF0C\u76F4\u63A5\u5931\u8D25", { reason: classification.reason });
12039
11861
  retryEpisode.finish("failed", failedRetryState);
12040
11862
  emitFinalError(eventHandler, pendingErrorEvent, lastError, classification, retryEpisode.activeId);
12041
11863
  throw lastError;
12042
11864
  }
12043
11865
  if (attempt >= configuredMaxRetries || categoryRetries[category] >= currentMaxRetries) {
12044
- logger16.error("\u5DF2\u8FBE\u5230\u6700\u5927\u91CD\u8BD5\u6B21\u6570\uFF0C\u653E\u5F03\u91CD\u8BD5", { maxRetries: currentMaxRetries });
11866
+ logger15.error("\u5DF2\u8FBE\u5230\u6700\u5927\u91CD\u8BD5\u6B21\u6570\uFF0C\u653E\u5F03\u91CD\u8BD5", { maxRetries: currentMaxRetries });
12045
11867
  retryEpisode.finish("exhausted", failedRetryState);
12046
11868
  emitFinalError(eventHandler, pendingErrorEvent, lastError, classification, retryEpisode.activeId);
12047
11869
  throw lastError;
@@ -12053,9 +11875,9 @@ async function callWithRetryFallback(params) {
12053
11875
  6e4
12054
11876
  );
12055
11877
  if (classification.category === "rate_limit" /* RATE_LIMIT */) {
12056
- logger16.warn("\u901F\u7387\u9650\u5236\u9519\u8BEF\uFF0C\u5EF6\u8FDF\u540E\u91CD\u8BD5", { retryDelay, reason: classification.reason });
11878
+ logger15.warn("\u901F\u7387\u9650\u5236\u9519\u8BEF\uFF0C\u5EF6\u8FDF\u540E\u91CD\u8BD5", { retryDelay, reason: classification.reason });
12057
11879
  } else if (classification.category === "retryable" /* RETRYABLE */) {
12058
- logger16.warn("\u53EF\u91CD\u8BD5\u9519\u8BEF\uFF0C\u5EF6\u8FDF\u540E\u91CD\u8BD5", { retryDelay, reason: classification.reason });
11880
+ logger15.warn("\u53EF\u91CD\u8BD5\u9519\u8BEF\uFF0C\u5EF6\u8FDF\u540E\u91CD\u8BD5", { retryDelay, reason: classification.reason });
12059
11881
  }
12060
11882
  throwIfAborted(signal, "\u5EF6\u8FDF\u7B49\u5F85\u524D\u68C0\u6D4B\u5230\u53D6\u6D88\u4FE1\u53F7\uFF0C\u505C\u6B62\u91CD\u8BD5");
12061
11883
  categoryRetries[category] += 1;
@@ -12092,16 +11914,11 @@ function waitForRetry(delayMs, signal) {
12092
11914
  }
12093
11915
  function isClientRetryEnabledForModel(modelCatalog, modelId, options) {
12094
11916
  if (options.retry_policy === "none") return false;
12095
- const cfg = modelCatalog.getModelById(modelId);
12096
- if (cfg?.billing_mode === "cloud") return false;
12097
- if (options.retry_policy === "client") return true;
12098
- if (!cfg) return true;
12099
- if (cfg.enable_client_retry === false) return false;
12100
- return true;
11917
+ return modelCatalog.getModelById(modelId)?.enable_client_retry !== false;
12101
11918
  }
12102
11919
  function throwIfAborted(signal, message) {
12103
11920
  if (!signal?.aborted) return;
12104
- logger16.info(message);
11921
+ logger15.info(message);
12105
11922
  const reason = signal.reason;
12106
11923
  if (reason instanceof Error && reason.name === "AbortError") throw reason;
12107
11924
  const reasonText = typeof reason === "string" && reason.trim().length > 0 ? reason : "stream_interrupted";
@@ -12419,7 +12236,7 @@ async function recoverChildRunEventsFromCheckpoint(params) {
12419
12236
  }
12420
12237
 
12421
12238
  // src/runtime-kernel/child-runs/childRunInvoker.ts
12422
- var logger17 = new Logger("ChildRunInvoker");
12239
+ var logger16 = new Logger("ChildRunInvoker");
12423
12240
  var ChildRunInvoker = class {
12424
12241
  modelResolver;
12425
12242
  createLlmNode;
@@ -12461,7 +12278,7 @@ var ChildRunInvoker = class {
12461
12278
  const resolvedParentRunId = parentRunId ?? parentToolContext.runId;
12462
12279
  const depthDecision = decideChildRunDepth({ parentToolContext });
12463
12280
  if (!depthDecision.allowed) {
12464
- logger17.warn("child-run \u6DF1\u5EA6\u8D85\u8FC7\u4E0A\u9650\uFF0C\u62D2\u7EDD\u7EE7\u7EED\u9012\u5F52\u6267\u884C", {
12281
+ logger16.warn("child-run \u6DF1\u5EA6\u8D85\u8FC7\u4E0A\u9650\uFF0C\u62D2\u7EDD\u7EE7\u7EED\u9012\u5F52\u6267\u884C", {
12465
12282
  runId: childRunId,
12466
12283
  parentRunId: resolvedParentRunId,
12467
12284
  parentDepth: depthDecision.parentDepth,
@@ -12478,7 +12295,7 @@ var ChildRunInvoker = class {
12478
12295
  };
12479
12296
  }
12480
12297
  if (abortSignal?.aborted || parentToolContext.abortSignal?.aborted) {
12481
- logger17.info("child-run \u5728\u4EFB\u52A1\u63A5\u7EB3\u524D\u5DF2\u53D6\u6D88", {
12298
+ logger16.info("child-run \u5728\u4EFB\u52A1\u63A5\u7EB3\u524D\u5DF2\u53D6\u6D88", {
12482
12299
  runId: childRunId,
12483
12300
  parentRunId: resolvedParentRunId
12484
12301
  });
@@ -12502,7 +12319,7 @@ var ChildRunInvoker = class {
12502
12319
  }
12503
12320
  const turnId = config.initialInput?.turnId ?? generateTurnId();
12504
12321
  if (config.initialInput && (!turnId.trim() || config.initialInput.request.query !== userMessage || config.initialInput.request.promptKey !== agentConfig.promptKey || !config.initialInput.request.model_id)) throw new Error("Child initial input does not match the admitted invocation");
12505
- logger17.info(`\u542F\u52A8 child-run: ${agentConfig.id}`, {
12322
+ logger16.info(`\u542F\u52A8 child-run: ${agentConfig.id}`, {
12506
12323
  conversationId: runtimeConversationId,
12507
12324
  checkpointKey: internalCheckpointKey,
12508
12325
  maxSteps,
@@ -12620,7 +12437,7 @@ var ChildRunInvoker = class {
12620
12437
  );
12621
12438
  finalAnswer = extractFinalAnswer(allEvents);
12622
12439
  lastProgress = finalAnswer ? void 0 : extractLastProgress(allEvents);
12623
- logger17.info("child-run \u6267\u884C\u5B8C\u6210", {
12440
+ logger16.info("child-run \u6267\u884C\u5B8C\u6210", {
12624
12441
  stepCount,
12625
12442
  eventCount: allEvents.length,
12626
12443
  hasFinalAnswer: !!finalAnswer,
@@ -12650,13 +12467,13 @@ var ChildRunInvoker = class {
12650
12467
  cancelled = abortSignal?.aborted === true || isAbortError2(err);
12651
12468
  error = err instanceof Error ? err.message : String(err);
12652
12469
  if (cancelled) {
12653
- logger17.info("child-run \u6267\u884C\u53D6\u6D88", {
12470
+ logger16.info("child-run \u6267\u884C\u53D6\u6D88", {
12654
12471
  runId: childRunId,
12655
12472
  parentRunId: resolvedParentRunId,
12656
12473
  message: error
12657
12474
  });
12658
12475
  } else {
12659
- logger17.error(
12476
+ logger16.error(
12660
12477
  "child-run \u6267\u884C\u5931\u8D25:",
12661
12478
  err instanceof Error ? {
12662
12479
  name: err.name,
@@ -12752,7 +12569,7 @@ var ChildRunInvoker = class {
12752
12569
  function isAbortError2(error) {
12753
12570
  return error instanceof Error && error.name === "AbortError";
12754
12571
  }
12755
- function readNonEmptyString6(value) {
12572
+ function readNonEmptyString5(value) {
12756
12573
  if (typeof value !== "string") {
12757
12574
  return void 0;
12758
12575
  }
@@ -12760,7 +12577,7 @@ function readNonEmptyString6(value) {
12760
12577
  return trimmed.length > 0 ? trimmed : void 0;
12761
12578
  }
12762
12579
  function resolveChildRunConversationId(params) {
12763
- const conversationId = readNonEmptyString6(params.explicitConversationId) ?? readNonEmptyString6(params.parentToolContext.conversationId);
12580
+ const conversationId = readNonEmptyString5(params.explicitConversationId) ?? readNonEmptyString5(params.parentToolContext.conversationId);
12764
12581
  if (!conversationId) {
12765
12582
  throw new Error(
12766
12583
  "ChildRunInvoker requires conversationId from admission or parent ToolContext."
@@ -12769,7 +12586,7 @@ function resolveChildRunConversationId(params) {
12769
12586
  return conversationId;
12770
12587
  }
12771
12588
  function resolveChildRunModelId(params) {
12772
- const explicitModelId = readNonEmptyString6(params.explicitModelId);
12589
+ const explicitModelId = readNonEmptyString5(params.explicitModelId);
12773
12590
  if (explicitModelId) {
12774
12591
  return explicitModelId;
12775
12592
  }
@@ -13714,7 +13531,7 @@ function runMetaFromRecord(record) {
13714
13531
  }
13715
13532
 
13716
13533
  // src/runtime-kernel/run-supervisor/functions/awaitingUserWatcher.ts
13717
- var logger18 = new Logger("RunSupervisorAwaitingUserWatcher");
13534
+ var logger17 = new Logger("RunSupervisorAwaitingUserWatcher");
13718
13535
  function isRecord16(value) {
13719
13536
  return typeof value === "object" && value !== null && !Array.isArray(value);
13720
13537
  }
@@ -13759,7 +13576,7 @@ function createAwaitingUserWatcher(options) {
13759
13576
  resumeToken: event.resume_token
13760
13577
  }
13761
13578
  }).catch((error) => {
13762
- logger18.warn("failed to mark awaiting_user from requires_user_interaction", { error });
13579
+ logger17.warn("failed to mark awaiting_user from requires_user_interaction", { error });
13763
13580
  });
13764
13581
  };
13765
13582
  const dispose = () => {
@@ -15026,7 +14843,7 @@ function createScriptedInferenceHarness(script, options = {}) {
15026
14843
  }
15027
14844
 
15028
14845
  // src/context-manager/shared/MessageFormatter.ts
15029
- var logger19 = new Logger("MessageFormatter");
14846
+ var logger18 = new Logger("MessageFormatter");
15030
14847
  var MessageFormatter = class {
15031
14848
  fenceRegistry;
15032
14849
  constructor(options = {}) {
@@ -15092,12 +14909,12 @@ var MessageFormatter = class {
15092
14909
  case "context_injection": {
15093
14910
  const fenceKind = metadata?.fenceKind;
15094
14911
  if (!fenceKind) {
15095
- logger19.warn("context_injection missing metadata.fenceKind, skipping");
14912
+ logger18.warn("context_injection missing metadata.fenceKind, skipping");
15096
14913
  return null;
15097
14914
  }
15098
14915
  const descriptor = fenceRegistry?.get(fenceKind);
15099
14916
  if (!descriptor) {
15100
- logger19.warn("fence kind is not registered, skipping", { fenceKind });
14917
+ logger18.warn("fence kind is not registered, skipping", { fenceKind });
15101
14918
  return null;
15102
14919
  }
15103
14920
  return {
@@ -15136,7 +14953,7 @@ var MessageFormatter = class {
15136
14953
  case "task_completion":
15137
14954
  return { role, content };
15138
14955
  default:
15139
- logger19.warn("unhandled message type for chat history, skipping", { type });
14956
+ logger18.warn("unhandled message type for chat history, skipping", { type });
15140
14957
  return null;
15141
14958
  }
15142
14959
  }
@@ -15151,7 +14968,7 @@ z.object({
15151
14968
  }).strict();
15152
14969
 
15153
14970
  // src/context-manager/profiles/agent/utils/toolOutputSummarizer.ts
15154
- var logger21 = new Logger("ToolOutputSummarizer");
14971
+ var logger20 = new Logger("ToolOutputSummarizer");
15155
14972
  var DEFAULT_SUMMARIZER_CONFIG = {
15156
14973
  fullContentThreshold: 400,
15157
14974
  textPreviewLength: 200,
@@ -15191,7 +15008,7 @@ var ToolOutputSummarizer = class {
15191
15008
  return tool.getExecutionSummary(output);
15192
15009
  }
15193
15010
  } catch (error) {
15194
- logger21.error("tool getExecutionSummary failed", { toolName, error });
15011
+ logger20.error("tool getExecutionSummary failed", { toolName, error });
15195
15012
  }
15196
15013
  return null;
15197
15014
  }
@@ -15242,14 +15059,14 @@ var summarizeToolOutput = (toolName, output, toolSummaryProvider, config) => {
15242
15059
  };
15243
15060
 
15244
15061
  // src/context-manager/profiles/agent/utils/eventConverter.ts
15245
- var logger22 = new Logger("AgentEventConverter");
15062
+ var logger21 = new Logger("AgentEventConverter");
15246
15063
  function isHistorySummaryEvent(event) {
15247
15064
  return "type" in event && event.type === "history_summary";
15248
15065
  }
15249
15066
  function convertEventToAiMessage(event) {
15250
15067
  if (isHistorySummaryEvent(event)) {
15251
15068
  const replacedIds = Array.isArray(event.replaced_message_ids) ? event.replaced_message_ids : [];
15252
- logger22.debug("Converted history_summary RuntimeEvent to AiMessage", {
15069
+ logger21.debug("Converted history_summary RuntimeEvent to AiMessage", {
15253
15070
  summaryId: event.id,
15254
15071
  replacedCount: replacedIds.length,
15255
15072
  summarySeq: event.summary_seq,