@linnlabs/linnkit 0.45.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 (40) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/dist/cli.cjs +65 -243
  3. package/dist/cli.cjs.map +1 -1
  4. package/dist/cli.js +65 -243
  5. package/dist/cli.js.map +1 -1
  6. package/dist/context-manager.cjs +7 -6
  7. package/dist/context-manager.cjs.map +1 -1
  8. package/dist/context-manager.js +7 -6
  9. package/dist/context-manager.js.map +1 -1
  10. package/dist/index.cjs +75 -253
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.js +75 -253
  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 +65 -243
  17. package/dist/quickstart.cjs.map +1 -1
  18. package/dist/quickstart.js +65 -243
  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 -4
  23. package/dist/runtime-kernel/graph-engine/types.d.ts +1 -4
  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.cjs +75 -253
  29. package/dist/runtime-kernel.cjs.map +1 -1
  30. package/dist/runtime-kernel.js +75 -253
  31. package/dist/runtime-kernel.js.map +1 -1
  32. package/dist/testkit.cjs +83 -261
  33. package/dist/testkit.cjs.map +1 -1
  34. package/dist/testkit.js +83 -261
  35. package/dist/testkit.js.map +1 -1
  36. package/docs/integration/agent-registration-guide.md +1 -1
  37. package/docs/integration/context-engineering.md +5 -5
  38. package/docs/integration/llm-provider.md +1 -1
  39. package/docs/integration/tool-development-guide.md +4 -2
  40. package/package.json +2 -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,18 +5289,14 @@ function createExecuteLlmStage(dependencies) {
5356
5289
  "turnId"
5357
5290
  ],
5358
5291
  writes: [
5359
- "cloudQuotaFallbackAppliedModelId",
5360
5292
  "modelFallbackAudit",
5361
5293
  "llmCallStartedAt",
5362
5294
  "llmResp",
5363
5295
  "llmCallDurationMs",
5364
- "executorLocalPatch",
5365
5296
  "contextUsage"
5366
5297
  ],
5367
5298
  async run(ctx) {
5368
- let cloudQuotaFallbackAppliedModelId;
5369
5299
  let modelFallbackAudit;
5370
- let lastSuccessfulLlmModelId;
5371
5300
  let contextUsage;
5372
5301
  const modelFallbackRejections = [];
5373
5302
  const promptBudget = ctx.promptBudget;
@@ -5385,11 +5314,7 @@ function createExecuteLlmStage(dependencies) {
5385
5314
  streamEventHandler,
5386
5315
  ctx.signal,
5387
5316
  {
5388
- onCloudQuotaFallbackApplied(fallbackModelId) {
5389
- cloudQuotaFallbackAppliedModelId = readNonEmptyString3(fallbackModelId);
5390
- },
5391
- onLlmAttemptSucceeded(activeModelId, attemptContextUsage) {
5392
- lastSuccessfulLlmModelId = readNonEmptyString3(activeModelId);
5317
+ onLlmAttemptSucceeded(_activeModelId, attemptContextUsage) {
5393
5318
  contextUsage = attemptContextUsage;
5394
5319
  },
5395
5320
  onModelFallbackApplied(info) {
@@ -5485,12 +5410,10 @@ function createExecuteLlmStage(dependencies) {
5485
5410
  });
5486
5411
  }
5487
5412
  return {
5488
- cloudQuotaFallbackAppliedModelId,
5489
5413
  modelFallbackAudit,
5490
5414
  llmCallStartedAt,
5491
5415
  llmResp,
5492
5416
  llmCallDurationMs,
5493
- executorLocalPatch: lastSuccessfulLlmModelId ? { lastSuccessfulLlmModelId } : void 0,
5494
5417
  contextUsage
5495
5418
  };
5496
5419
  }
@@ -6407,18 +6330,16 @@ function createPrepareCallStage(dependencies) {
6407
6330
  "toolDefinitionTokens"
6408
6331
  ],
6409
6332
  async run(ctx) {
6410
- const lockedRunModelId = readNonEmptyString3(ctx.executorLocal?.runLockedModelId);
6411
- const requestedModelId = lockedRunModelId ?? ctx.request.model_id;
6333
+ const requestedModelId = ctx.request.model_id;
6412
6334
  const modelId = dependencies.modelResolver.resolveModelId(requestedModelId);
6413
6335
  await emitAuditEnvelope(ctx.audit, {
6414
6336
  action: "model.select",
6415
6337
  actor: { kind: "system" },
6416
6338
  decision: {
6417
6339
  outcome: "recorded",
6418
- reason: lockedRunModelId ? "run model lock" : requestedModelId ? "request model id" : "default model resolver",
6340
+ reason: requestedModelId ? "request model id" : "default model resolver",
6419
6341
  metadata: {
6420
6342
  requestedModelId,
6421
- lockedRunModelId,
6422
6343
  selectedModelId: modelId
6423
6344
  }
6424
6345
  },
@@ -6465,10 +6386,6 @@ function createPrepareCallStage(dependencies) {
6465
6386
  if (ctx.executorLocal?.lockRequestedModelId === true) {
6466
6387
  llmOptions.allow_model_fallback = false;
6467
6388
  }
6468
- const isRunContinuation = ctx.executorLocal?.llmInvocationKind === "continuation";
6469
- if (dependencies.cloudQuotaFallbackModelId && modelConfig?.billing_mode === "cloud" && modelId !== dependencies.cloudQuotaFallbackModelId && isRunContinuation && ctx.executorLocal?.lockRequestedModelId !== true) {
6470
- llmOptions.cloud_quota_fallback_model_id = dependencies.cloudQuotaFallbackModelId;
6471
- }
6472
6389
  const effectiveEffort = resolveEffectiveEffort(
6473
6390
  ctx.request.reasoning_effort,
6474
6391
  modelConfig?.reasoning
@@ -6585,12 +6502,11 @@ function applyCalibration(rawLocalTotal, imageInputTokens, coefficient) {
6585
6502
  }
6586
6503
 
6587
6504
  // src/runtime-kernel/graph-engine/executor.ts
6588
- var logger6 = new Logger("GraphAgentExecutor");
6505
+ var logger5 = new Logger("GraphAgentExecutor");
6589
6506
  var GraphAgentExecutor = class {
6590
6507
  llmCaller;
6591
6508
  toolRuntime;
6592
6509
  contextBuilder;
6593
- cloudQuotaFallbackModelId;
6594
6510
  modelResolver;
6595
6511
  modelCatalog;
6596
6512
  telemetryPort;
@@ -6602,7 +6518,6 @@ var GraphAgentExecutor = class {
6602
6518
  this.llmCaller = dependencies.llmCaller;
6603
6519
  this.toolRuntime = dependencies.toolRuntime;
6604
6520
  this.contextBuilder = dependencies.contextBuilder;
6605
- this.cloudQuotaFallbackModelId = readNonEmptyString3(dependencies.cloudQuotaFallbackModelId);
6606
6521
  this.modelCatalog = dependencies.modelCatalog ?? createEmptyModelCatalog();
6607
6522
  this.modelResolver = dependencies.modelResolver ?? new ModelResolver({
6608
6523
  modelCatalog: this.modelCatalog
@@ -6619,8 +6534,7 @@ var GraphAgentExecutor = class {
6619
6534
  createPrepareCallStage({
6620
6535
  modelResolver: this.modelResolver,
6621
6536
  modelCatalog: this.modelCatalog,
6622
- toolCatalog: this.toolRuntime,
6623
- cloudQuotaFallbackModelId: this.cloudQuotaFallbackModelId
6537
+ toolCatalog: this.toolRuntime
6624
6538
  }),
6625
6539
  createBuildContextStage({
6626
6540
  contextBuilder: this.contextBuilder
@@ -6642,7 +6556,7 @@ var GraphAgentExecutor = class {
6642
6556
  }),
6643
6557
  createBuildDecisionStage()
6644
6558
  ];
6645
- this.middlewares = [llmTelemetryMiddleware, runModelLockMiddleware];
6559
+ this.middlewares = [llmTelemetryMiddleware];
6646
6560
  }
6647
6561
  async tick(input, eventHandler) {
6648
6562
  const ctx = {
@@ -6667,7 +6581,7 @@ var GraphAgentExecutor = class {
6667
6581
  audit: this.auditPort,
6668
6582
  tokenizer: this.tokenizer
6669
6583
  };
6670
- logger6.info("[GraphAgentExecutor] tick \u8C03\u7528", {
6584
+ logger5.info("[GraphAgentExecutor] tick \u8C03\u7528", {
6671
6585
  stream: input.stream === true,
6672
6586
  hasEventHandler: Boolean(eventHandler),
6673
6587
  hasSummarizationCallbacks: Boolean(input.summarizationCallbacks)
@@ -7690,7 +7604,7 @@ var LlmNodeEventBridge = class {
7690
7604
  };
7691
7605
 
7692
7606
  // src/runtime-kernel/graph-engine/nodes/llmNode.ts
7693
- var logger7 = new Logger("LlmNode");
7607
+ var logger6 = new Logger("LlmNode");
7694
7608
  var LlmNode = class {
7695
7609
  id = "llm";
7696
7610
  reasoner;
@@ -7699,7 +7613,7 @@ var LlmNode = class {
7699
7613
  }
7700
7614
  async run(state) {
7701
7615
  const local = state.local ?? {};
7702
- logger7.info("[LlmNode] \u5F00\u59CB\u6267\u884C LLM \u8282\u70B9", {
7616
+ logger6.info("[LlmNode] \u5F00\u59CB\u6267\u884C LLM \u8282\u70B9", {
7703
7617
  localKeys: Object.keys(local)
7704
7618
  });
7705
7619
  const graphLocal = readGraphAgentLocal(state.local);
@@ -7714,12 +7628,12 @@ var LlmNode = class {
7714
7628
  signal,
7715
7629
  history
7716
7630
  } = graphLocal;
7717
- logger7.info("[LlmNode] \u5DF2\u52A0\u8F7D\u5386\u53F2\u4E8B\u4EF6", {
7631
+ logger6.info("[LlmNode] \u5DF2\u52A0\u8F7D\u5386\u53F2\u4E8B\u4EF6", {
7718
7632
  historyCount: history.length,
7719
7633
  hasSummarizationCallbacks: Boolean(summarizationCallbacks)
7720
7634
  });
7721
7635
  if (!request) {
7722
- logger7.warn("Request object is missing, yielding.");
7636
+ logger6.warn("Request object is missing, yielding.");
7723
7637
  return { kind: "yield", events: [] };
7724
7638
  }
7725
7639
  const turnId = requireRuntimeIdentity(graphLocal.turnId, "turnId");
@@ -7812,12 +7726,12 @@ var LlmNode = class {
7812
7726
  ...nodeState.streamRuntimeEvents,
7813
7727
  ...contextUsageEvent ? [contextUsageEvent] : []
7814
7728
  ];
7815
- logger7.info("[LlmNode] \u5386\u53F2\u4E8B\u4EF6\u5DF2\u66F4\u65B0", {
7729
+ logger6.info("[LlmNode] \u5386\u53F2\u4E8B\u4EF6\u5DF2\u66F4\u65B0", {
7816
7730
  previousCount: history.length,
7817
7731
  nextCount: patch.history.length,
7818
7732
  streamedEventCount: nodeState.streamRuntimeEvents.length
7819
7733
  });
7820
- logger7.info("[LlmNode] \u6267\u884C\u5668\u51B3\u7B56\u5B8C\u6210", {
7734
+ logger6.info("[LlmNode] \u6267\u884C\u5668\u51B3\u7B56\u5B8C\u6210", {
7821
7735
  decisionKind: decision.kind,
7822
7736
  emittedEventCount: combinedEvents.length
7823
7737
  });
@@ -7839,7 +7753,7 @@ var LlmNode = class {
7839
7753
  }
7840
7754
  case "error": {
7841
7755
  const { name, message, stack } = decision.error;
7842
- logger7.error("[LlmNode] Executor returned an error", { name, message, stack });
7756
+ logger6.error("[LlmNode] Executor returned an error", { name, message, stack });
7843
7757
  return { kind: "yield", events: combinedEvents };
7844
7758
  }
7845
7759
  default: {
@@ -7945,7 +7859,7 @@ async function resolveToolModelInput(input) {
7945
7859
  }
7946
7860
 
7947
7861
  // src/runtime-kernel/graph-engine/nodes/toolNode.finalAnswerProjector.ts
7948
- function readNonEmptyString5(value) {
7862
+ function readNonEmptyString4(value) {
7949
7863
  if (typeof value !== "string") {
7950
7864
  return void 0;
7951
7865
  }
@@ -7953,7 +7867,7 @@ function readNonEmptyString5(value) {
7953
7867
  return normalized.length > 0 ? normalized : void 0;
7954
7868
  }
7955
7869
  function resolveFinalAnswerFromToolControl(finalAnswer) {
7956
- return readNonEmptyString5(finalAnswer);
7870
+ return readNonEmptyString4(finalAnswer);
7957
7871
  }
7958
7872
 
7959
7873
  // src/runtime-kernel/graph-engine/nodes/toolNode.helpers.ts
@@ -8209,7 +8123,7 @@ function buildErrorLocalState(params) {
8209
8123
  }
8210
8124
 
8211
8125
  // src/runtime-kernel/tools/argNormalizer.ts
8212
- var logger8 = new Logger("ToolArgNormalizer");
8126
+ var logger7 = new Logger("ToolArgNormalizer");
8213
8127
  function isRecord10(v) {
8214
8128
  return !!v && typeof v === "object" && !Array.isArray(v);
8215
8129
  }
@@ -8229,7 +8143,7 @@ function joinPath(basePath, segment) {
8229
8143
  function logJsonEncodedNormalization(expectedType, options) {
8230
8144
  const toolPrefix = options.toolName ? `${options.toolName}.` : "";
8231
8145
  const path = options.path ?? "<root>";
8232
- logger8.warn("normalized JSON-encoded tool argument", {
8146
+ logger7.warn("normalized JSON-encoded tool argument", {
8233
8147
  expectedType,
8234
8148
  path: `${toolPrefix}${path}`
8235
8149
  });
@@ -8585,7 +8499,7 @@ function stripRuntimeReservedToolContextPatch(patch) {
8585
8499
  }
8586
8500
 
8587
8501
  // src/runtime-kernel/graph-engine/nodes/toolNode.eventBridge.ts
8588
- var logger9 = new Logger("ToolNode");
8502
+ var logger8 = new Logger("ToolNode");
8589
8503
  var ToolNodeEventBridge = class {
8590
8504
  constructor(deps) {
8591
8505
  this.deps = deps;
@@ -8607,7 +8521,7 @@ var ToolNodeEventBridge = class {
8607
8521
  status,
8608
8522
  payload: { ...payload }
8609
8523
  };
8610
- logger9.info("[ToolNode] \u53D1\u51FA tool_process \u4E8B\u4EF6", {
8524
+ logger8.info("[ToolNode] \u53D1\u51FA tool_process \u4E8B\u4EF6", {
8611
8525
  phase,
8612
8526
  status,
8613
8527
  toolName: this.deps.toolName,
@@ -8647,7 +8561,7 @@ var ToolNodeEventBridge = class {
8647
8561
  const answerId = generateAnswerSegmentId();
8648
8562
  const id = answerId;
8649
8563
  const timestamp = Date.now();
8650
- 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", {
8651
8565
  sourceToolName: params.sourceToolName,
8652
8566
  toolCallId: this.deps.toolCallId,
8653
8567
  conversationId: this.deps.conversationId,
@@ -8705,7 +8619,7 @@ var ToolNodeEventBridge = class {
8705
8619
  };
8706
8620
 
8707
8621
  // src/runtime-kernel/graph-engine/nodes/toolNode.executionSetup.ts
8708
- var logger10 = new Logger("ToolNode");
8622
+ var logger9 = new Logger("ToolNode");
8709
8623
  function parseToolArgs(call) {
8710
8624
  const rawArguments = typeof call.function?.arguments === "string" ? call.function.arguments : "";
8711
8625
  if (!rawArguments.trim()) {
@@ -8725,7 +8639,7 @@ function parseToolArgs(call) {
8725
8639
  return { ok: true, value: parsed };
8726
8640
  } catch (error) {
8727
8641
  const reason = error instanceof Error ? error.message : "Unknown JSON parse error";
8728
- logger10.warn("failed to parse tool arguments", { error });
8642
+ logger9.warn("failed to parse tool arguments", { error });
8729
8643
  return {
8730
8644
  ok: false,
8731
8645
  error: `Tool arguments are not valid JSON: ${reason}`
@@ -9119,7 +9033,7 @@ async function claimPendingUserInputs(state, result) {
9119
9033
  }
9120
9034
 
9121
9035
  // src/runtime-kernel/graph-engine/nodes/toolNode.ts
9122
- var logger11 = new Logger("ToolNode");
9036
+ var logger10 = new Logger("ToolNode");
9123
9037
  function isAbortSignal(value) {
9124
9038
  return value !== null && typeof value === "object" && "aborted" in value;
9125
9039
  }
@@ -9332,7 +9246,7 @@ var ToolNode = class {
9332
9246
  throw abortError;
9333
9247
  }
9334
9248
  const prepared = prepareToolNodeContext(state);
9335
- logger11.info("[ToolNode] \u5F00\u59CB\u6267\u884C\u5DE5\u5177\u8282\u70B9", {
9249
+ logger10.info("[ToolNode] \u5F00\u59CB\u6267\u884C\u5DE5\u5177\u8282\u70B9", {
9336
9250
  conversationId: prepared.conversationId,
9337
9251
  turnId: prepared.turnId,
9338
9252
  pendingCallCount: calls.length
@@ -9347,7 +9261,7 @@ var ToolNode = class {
9347
9261
  toolCatalog: this.toolRuntime
9348
9262
  });
9349
9263
  if (!execution) {
9350
- logger11.warn("no tool name found in call");
9264
+ logger10.warn("no tool name found in call");
9351
9265
  return { kind: "yield", events: [] };
9352
9266
  }
9353
9267
  if (typeof execution.protocolError === "string") {
@@ -9387,7 +9301,7 @@ var ToolNode = class {
9387
9301
  call,
9388
9302
  context: prepared.toolContext,
9389
9303
  abortGraceMs: this.abortGraceMs,
9390
- 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", {
9391
9305
  toolName: execution.toolName,
9392
9306
  toolCallId: execution.toolCallId,
9393
9307
  conversationId: prepared.conversationId,
@@ -9557,7 +9471,7 @@ var ToolNode = class {
9557
9471
  runtimeEvents: context.bridge.getRuntimeEvents()
9558
9472
  });
9559
9473
  if (control?.terminateRun) {
9560
- 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", {
9561
9475
  toolName: context.toolName,
9562
9476
  toolCallId: context.toolCallId,
9563
9477
  conversationId: context.conversationId,
@@ -9566,7 +9480,7 @@ var ToolNode = class {
9566
9480
  return { kind: "yield", events: context.bridge.getRuntimeEvents() };
9567
9481
  }
9568
9482
  if (remainingCalls.length === 0 && context.local.toolBatchCompletionMode === "yield_after_batch") {
9569
- 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", {
9570
9484
  toolName: context.toolName,
9571
9485
  toolCallId: context.toolCallId,
9572
9486
  conversationId: context.conversationId,
@@ -10013,6 +9927,8 @@ var executor = z.object({
10013
9927
  lastStepsHintThreshold: counter.optional(),
10014
9928
  systemReminderPolicy: AgentSpecSystemReminderPolicy.optional(),
10015
9929
  toolObservationPolicy: AgentSpecToolObservationGovernancePolicy.optional(),
9930
+ // 已删除字段:0.45 及更早的 checkpoint 可能带 lastSuccessfulLlmModelId,0.46 及更早的可能带云端额度兜底留下的
9931
+ // runLockedModelId;照常接受,读入时丢弃(兜底已移除,恢复后按请求的模型继续)。
10016
9932
  runLockedModelId: z.string().optional(),
10017
9933
  lastSuccessfulLlmModelId: z.string().optional(),
10018
9934
  llmInvocationKind: z.enum(["user_initiated", "continuation"]).optional(),
@@ -10023,7 +9939,7 @@ var executor = z.object({
10023
9939
  committedCount: counter,
10024
9940
  lastCommittedFingerprint: z.string().optional()
10025
9941
  }).strict().optional()
10026
- }).strict();
9942
+ }).strict().transform(({ lastSuccessfulLlmModelId: _retired, runLockedModelId: _retiredLock, ...state }) => state);
10027
9943
  var checkpoint = z.object({
10028
9944
  nodeId: z.string().min(1),
10029
9945
  schemaVersion: z.literal(ENGINE_STATE_SCHEMA_VERSION).optional(),
@@ -10337,7 +10253,7 @@ __export(execution_exports, {
10337
10253
  });
10338
10254
 
10339
10255
  // src/runtime-kernel/execution/event-bus.ts
10340
- var logger12 = new Logger("EventBus");
10256
+ var logger11 = new Logger("EventBus");
10341
10257
  var TypedEventEmitter = class {
10342
10258
  listeners = /* @__PURE__ */ new Map();
10343
10259
  maxListeners = 10;
@@ -10345,7 +10261,7 @@ var TypedEventEmitter = class {
10345
10261
  const listeners = this.getListeners(event);
10346
10262
  listeners.add(listener);
10347
10263
  if (listeners.size > this.maxListeners) {
10348
- logger12.warn("EventBus listener count exceeds configured max", {
10264
+ logger11.warn("EventBus listener count exceeds configured max", {
10349
10265
  event: String(event),
10350
10266
  count: listeners.size,
10351
10267
  maxListeners: this.maxListeners
@@ -10405,7 +10321,7 @@ var EventBus = class extends TypedEventEmitter {
10405
10321
  super();
10406
10322
  this.executionId = executionId;
10407
10323
  this.setMaxListeners(30);
10408
- logger12.info(`EventBus created for execution ${this.executionId}`);
10324
+ logger11.info(`EventBus created for execution ${this.executionId}`);
10409
10325
  }
10410
10326
  /**
10411
10327
  * 发布一个事件到总线
@@ -10414,7 +10330,7 @@ var EventBus = class extends TypedEventEmitter {
10414
10330
  publish(envelope) {
10415
10331
  if (envelope.trace.execution_id !== this.executionId) {
10416
10332
  const error = new Error("EventEnvelope execution_id does not match EventBus instance.");
10417
- logger12.error("Mismatched execution_id", {
10333
+ logger11.error("Mismatched execution_id", {
10418
10334
  busExecutionId: this.executionId,
10419
10335
  eventExecutionId: envelope.trace.execution_id,
10420
10336
  eventSeq: envelope.seq
@@ -10426,7 +10342,7 @@ var EventBus = class extends TypedEventEmitter {
10426
10342
  const error = new Error(
10427
10343
  "EventBus only accepts RuntimeEvent with formal run routing identity."
10428
10344
  );
10429
- logger12.error("RuntimeEvent is missing formal run routing identity", {
10345
+ logger11.error("RuntimeEvent is missing formal run routing identity", {
10430
10346
  executionId: this.executionId,
10431
10347
  eventId: envelope.payload.id,
10432
10348
  eventType: envelope.payload.type
@@ -10440,14 +10356,14 @@ var EventBus = class extends TypedEventEmitter {
10440
10356
  * 关闭总线,清理所有监听器
10441
10357
  */
10442
10358
  close() {
10443
- logger12.info(`Closing EventBus for execution ${this.executionId}`);
10359
+ logger11.info(`Closing EventBus for execution ${this.executionId}`);
10444
10360
  this.emit("close");
10445
10361
  this.removeAllListeners();
10446
10362
  }
10447
10363
  };
10448
10364
 
10449
10365
  // src/runtime-kernel/execution/sequencer.ts
10450
- var logger13 = new Logger("EventSequencer");
10366
+ var logger12 = new Logger("EventSequencer");
10451
10367
  var EventSequencer = class {
10452
10368
  executionId;
10453
10369
  traceId;
@@ -10455,7 +10371,7 @@ var EventSequencer = class {
10455
10371
  constructor(conversationId, traceId) {
10456
10372
  this.executionId = generateExecutionId();
10457
10373
  this.traceId = traceId || generateTraceId();
10458
- logger13.info(`EventSequencer created for conversation ${conversationId}`, {
10374
+ logger12.info(`EventSequencer created for conversation ${conversationId}`, {
10459
10375
  executionId: this.executionId,
10460
10376
  traceId: this.traceId
10461
10377
  });
@@ -11313,7 +11229,7 @@ var ThoughtStreamSegmenter = class {
11313
11229
  };
11314
11230
 
11315
11231
  // src/runtime-kernel/llm/streaming-adapter.ts
11316
- var logger14 = new Logger("LlmCaller");
11232
+ var logger13 = new Logger("LlmCaller");
11317
11233
  var CanonicalInferenceFailureError = class extends Error {
11318
11234
  errorCode;
11319
11235
  recoverable;
@@ -11537,7 +11453,7 @@ async function callLlmStream(params) {
11537
11453
  } catch (error) {
11538
11454
  const normalized = error instanceof Error ? error : new Error(String(error));
11539
11455
  if (normalized.name === "AbortError") {
11540
- 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 });
11541
11457
  throw normalized;
11542
11458
  }
11543
11459
  const classification = ErrorClassifier.classify(normalized, {
@@ -11613,7 +11529,7 @@ var LlmRetryEpisode = class {
11613
11529
  };
11614
11530
 
11615
11531
  // src/runtime-kernel/llm/retry-fallback-routing.ts
11616
- var logger15 = new Logger("LlmCaller");
11532
+ var logger14 = new Logger("LlmCaller");
11617
11533
  function tryPolicyModelSwitch(deps, activeModelId, excludedModelIds, requirement, fallbackObserver, error, evaluateFallbackPromptCapacity2) {
11618
11534
  deps.modelCatalog.getModelById(activeModelId);
11619
11535
  const policyDecision = deps.policyEngine.decideOnError(error, {
@@ -11643,81 +11559,16 @@ function tryPolicyModelSwitch(deps, activeModelId, excludedModelIds, requirement
11643
11559
  reason: "no_eligible_fallback_candidate",
11644
11560
  requiredPlacements: requirement.placements
11645
11561
  });
11646
- 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");
11647
11563
  return null;
11648
11564
  }
11649
- logger15.warn("Policy \u5207\u6362\u6A21\u578B\u7EE7\u7EED", {
11565
+ logger14.warn("Policy \u5207\u6362\u6A21\u578B\u7EE7\u7EED", {
11650
11566
  reason: policyDecision.reason,
11651
11567
  activeModelId,
11652
11568
  fallbackModelId
11653
11569
  });
11654
11570
  return fallbackModelId;
11655
11571
  }
11656
- function tryCloudQuotaFallback({
11657
- deps,
11658
- activeModelId,
11659
- options,
11660
- excludedModelIds,
11661
- requirement,
11662
- error,
11663
- fallbackObserver,
11664
- evaluateFallbackPromptCapacity: evaluateFallbackPromptCapacity2
11665
- }) {
11666
- const fallbackModelId = options.cloud_quota_fallback_model_id;
11667
- if (!fallbackModelId || !ErrorClassifier.isCloudQuotaError(error) || excludedModelIds.has(fallbackModelId)) {
11668
- return null;
11669
- }
11670
- const fallbackConfig = deps.modelCatalog.getModelById(fallbackModelId);
11671
- if (!fallbackConfig?.api_key) {
11672
- fallbackObserver?.onModelFallbackRejected?.({
11673
- fromModelId: activeModelId,
11674
- candidateModelId: fallbackModelId,
11675
- policy: "cloud-quota",
11676
- reason: "fallback_model_unavailable",
11677
- requiredPlacements: requirement.placements
11678
- });
11679
- logger15.warn("\u4E91\u7AEF\u9650\u989D\u964D\u7EA7\u76EE\u6807\u4E0D\u53EF\u7528\uFF08\u672A\u6CE8\u518C\u6216\u7F3A\u5C11 API Key\uFF09", { fallbackModelId });
11680
- return null;
11681
- }
11682
- const compatibility = evaluateModelInputCompatibility(fallbackConfig, requirement);
11683
- if (!compatibility.compatible) {
11684
- fallbackObserver?.onModelFallbackRejected?.({
11685
- fromModelId: activeModelId,
11686
- candidateModelId: fallbackModelId,
11687
- policy: "cloud-quota",
11688
- reason: compatibility.reason,
11689
- requiredPlacements: requirement.placements
11690
- });
11691
- 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", {
11692
- fallbackModelId,
11693
- requiredPlacements: requirement.placements,
11694
- reason: compatibility.reason
11695
- });
11696
- return null;
11697
- }
11698
- const capacityAdmission = evaluateFallbackPromptCapacity2?.(fallbackModelId);
11699
- if (capacityAdmission && !capacityAdmission.admitted) {
11700
- fallbackObserver?.onModelFallbackRejected?.({
11701
- fromModelId: activeModelId,
11702
- candidateModelId: fallbackModelId,
11703
- policy: "cloud-quota",
11704
- reason: capacityAdmission.reason,
11705
- requiredPlacements: requirement.placements
11706
- });
11707
- 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", {
11708
- fallbackModelId,
11709
- reason: capacityAdmission.reason
11710
- });
11711
- return null;
11712
- }
11713
- logger15.warn("\u4E91\u7AEF\u9650\u989D\u964D\u7EA7\uFF08run \u5185\u7EED\u8DD1\uFF09", {
11714
- activeModelId,
11715
- fallbackModelId,
11716
- reason: error.message
11717
- });
11718
- fallbackObserver?.onCloudQuotaFallbackApplied?.(fallbackModelId);
11719
- return fallbackModelId;
11720
- }
11721
11572
 
11722
11573
  // src/runtime-kernel/llm/usage-telemetry.ts
11723
11574
  async function callPlainCompletion(inferencePort, modelId, messages, options = {}, signal, traceId) {
@@ -11840,7 +11691,7 @@ var LlmImageInputError = class extends Error {
11840
11691
  };
11841
11692
 
11842
11693
  // src/runtime-kernel/llm/retry-fallback.ts
11843
- var logger16 = new Logger("LlmCaller");
11694
+ var logger15 = new Logger("LlmCaller");
11844
11695
  async function callWithRetryFallback(params) {
11845
11696
  const {
11846
11697
  deps,
@@ -11868,11 +11719,9 @@ async function callWithRetryFallback(params) {
11868
11719
  const retryEpisode = new LlmRetryEpisode(traceId, eventHandler);
11869
11720
  let previousAttemptTracker;
11870
11721
  if (!clientRetryEnabled) {
11871
- const activeCfg = deps.modelCatalog.getModelById(modelId);
11872
- logger16.debug("\u5BA2\u6237\u7AEF\u91CD\u8BD5\u5DF2\u7981\u7528", {
11722
+ logger15.debug("\u5BA2\u6237\u7AEF\u91CD\u8BD5\u5DF2\u7981\u7528", {
11873
11723
  modelId,
11874
- billing_mode: activeCfg?.billing_mode,
11875
- 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"
11876
11725
  });
11877
11726
  }
11878
11727
  try {
@@ -11908,7 +11757,7 @@ async function callWithRetryFallback(params) {
11908
11757
  }) : void 0;
11909
11758
  try {
11910
11759
  if (isRetry) {
11911
- logger16.info("LLM \u8C03\u7528\u91CD\u8BD5", { attempt, configuredMaxRetries });
11760
+ logger15.info("LLM \u8C03\u7528\u91CD\u8BD5", { attempt, configuredMaxRetries });
11912
11761
  }
11913
11762
  actualAttempts++;
11914
11763
  retryEpisode.retrying(actualAttempts);
@@ -11937,7 +11786,7 @@ async function callWithRetryFallback(params) {
11937
11786
  if (deps.retryConfig.enableEmptyResponseRetry && !responseContent?.trim() && !toolCallsFromLLM?.length) {
11938
11787
  throw new Error("LLM\u8FD4\u56DE\u4E86\u7A7A\u54CD\u5E94");
11939
11788
  }
11940
- logger16.debug("LLM \u8C03\u7528\u6210\u529F", { attempts: actualAttempts, maxTotalAttempts });
11789
+ logger15.debug("LLM \u8C03\u7528\u6210\u529F", { attempts: actualAttempts, maxTotalAttempts });
11941
11790
  if (attemptContextUsage) {
11942
11791
  fallbackObserver?.onLlmAttemptSucceeded?.(activeModelId, attemptContextUsage);
11943
11792
  } else {
@@ -11948,7 +11797,7 @@ async function callWithRetryFallback(params) {
11948
11797
  } catch (error) {
11949
11798
  lastError = error instanceof Error ? error : new Error(String(error));
11950
11799
  if (lastError.name === "AbortError") {
11951
- 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", {
11952
11801
  attempt: attempt + 1,
11953
11802
  actualAttempts,
11954
11803
  maxTotalAttempts,
@@ -11967,7 +11816,7 @@ async function callWithRetryFallback(params) {
11967
11816
  total_attempts: actualAttempts,
11968
11817
  error_code: classification.errorCode
11969
11818
  };
11970
- logger16.error("LLM \u8C03\u7528\u5931\u8D25", {
11819
+ logger15.error("LLM \u8C03\u7528\u5931\u8D25", {
11971
11820
  attempt: attempt + 1,
11972
11821
  maxAttempts: currentMaxRetries + 1,
11973
11822
  actualAttempts,
@@ -11976,7 +11825,7 @@ async function callWithRetryFallback(params) {
11976
11825
  });
11977
11826
  previousAttemptTracker = attemptTracker;
11978
11827
  if (!hasLlmAttemptBudgetRemaining({ actualAttempts, maxTotalAttempts })) {
11979
- 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", {
11980
11829
  actualAttempts,
11981
11830
  maxTotalAttempts
11982
11831
  });
@@ -12006,37 +11855,15 @@ async function callWithRetryFallback(params) {
12006
11855
  attempt -= 1;
12007
11856
  continue;
12008
11857
  }
12009
- const quotaFallbackModelId = tryCloudQuotaFallback({
12010
- deps,
12011
- activeModelId,
12012
- options,
12013
- excludedModelIds,
12014
- requirement,
12015
- error: lastError,
12016
- fallbackObserver,
12017
- evaluateFallbackPromptCapacity: invocationContext?.evaluateFallbackPromptCapacity
12018
- });
12019
- if (quotaFallbackModelId) {
12020
- fallbackObserver?.onModelFallbackApplied?.({
12021
- fromModelId: activeModelId,
12022
- toModelId: quotaFallbackModelId,
12023
- reason: lastError.message,
12024
- policy: "cloud-quota"
12025
- });
12026
- activeModelId = quotaFallbackModelId;
12027
- excludedModelIds.add(quotaFallbackModelId);
12028
- attempt -= 1;
12029
- continue;
12030
- }
12031
11858
  }
12032
11859
  if (classification.category === "non_retryable" /* NON_RETRYABLE */) {
12033
- 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 });
12034
11861
  retryEpisode.finish("failed", failedRetryState);
12035
11862
  emitFinalError(eventHandler, pendingErrorEvent, lastError, classification, retryEpisode.activeId);
12036
11863
  throw lastError;
12037
11864
  }
12038
11865
  if (attempt >= configuredMaxRetries || categoryRetries[category] >= currentMaxRetries) {
12039
- 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 });
12040
11867
  retryEpisode.finish("exhausted", failedRetryState);
12041
11868
  emitFinalError(eventHandler, pendingErrorEvent, lastError, classification, retryEpisode.activeId);
12042
11869
  throw lastError;
@@ -12048,9 +11875,9 @@ async function callWithRetryFallback(params) {
12048
11875
  6e4
12049
11876
  );
12050
11877
  if (classification.category === "rate_limit" /* RATE_LIMIT */) {
12051
- 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 });
12052
11879
  } else if (classification.category === "retryable" /* RETRYABLE */) {
12053
- 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 });
12054
11881
  }
12055
11882
  throwIfAborted(signal, "\u5EF6\u8FDF\u7B49\u5F85\u524D\u68C0\u6D4B\u5230\u53D6\u6D88\u4FE1\u53F7\uFF0C\u505C\u6B62\u91CD\u8BD5");
12056
11883
  categoryRetries[category] += 1;
@@ -12087,16 +11914,11 @@ function waitForRetry(delayMs, signal) {
12087
11914
  }
12088
11915
  function isClientRetryEnabledForModel(modelCatalog, modelId, options) {
12089
11916
  if (options.retry_policy === "none") return false;
12090
- const cfg = modelCatalog.getModelById(modelId);
12091
- if (cfg?.billing_mode === "cloud") return false;
12092
- if (options.retry_policy === "client") return true;
12093
- if (!cfg) return true;
12094
- if (cfg.enable_client_retry === false) return false;
12095
- return true;
11917
+ return modelCatalog.getModelById(modelId)?.enable_client_retry !== false;
12096
11918
  }
12097
11919
  function throwIfAborted(signal, message) {
12098
11920
  if (!signal?.aborted) return;
12099
- logger16.info(message);
11921
+ logger15.info(message);
12100
11922
  const reason = signal.reason;
12101
11923
  if (reason instanceof Error && reason.name === "AbortError") throw reason;
12102
11924
  const reasonText = typeof reason === "string" && reason.trim().length > 0 ? reason : "stream_interrupted";
@@ -12414,7 +12236,7 @@ async function recoverChildRunEventsFromCheckpoint(params) {
12414
12236
  }
12415
12237
 
12416
12238
  // src/runtime-kernel/child-runs/childRunInvoker.ts
12417
- var logger17 = new Logger("ChildRunInvoker");
12239
+ var logger16 = new Logger("ChildRunInvoker");
12418
12240
  var ChildRunInvoker = class {
12419
12241
  modelResolver;
12420
12242
  createLlmNode;
@@ -12456,7 +12278,7 @@ var ChildRunInvoker = class {
12456
12278
  const resolvedParentRunId = parentRunId ?? parentToolContext.runId;
12457
12279
  const depthDecision = decideChildRunDepth({ parentToolContext });
12458
12280
  if (!depthDecision.allowed) {
12459
- 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", {
12460
12282
  runId: childRunId,
12461
12283
  parentRunId: resolvedParentRunId,
12462
12284
  parentDepth: depthDecision.parentDepth,
@@ -12473,7 +12295,7 @@ var ChildRunInvoker = class {
12473
12295
  };
12474
12296
  }
12475
12297
  if (abortSignal?.aborted || parentToolContext.abortSignal?.aborted) {
12476
- 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", {
12477
12299
  runId: childRunId,
12478
12300
  parentRunId: resolvedParentRunId
12479
12301
  });
@@ -12497,7 +12319,7 @@ var ChildRunInvoker = class {
12497
12319
  }
12498
12320
  const turnId = config.initialInput?.turnId ?? generateTurnId();
12499
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");
12500
- logger17.info(`\u542F\u52A8 child-run: ${agentConfig.id}`, {
12322
+ logger16.info(`\u542F\u52A8 child-run: ${agentConfig.id}`, {
12501
12323
  conversationId: runtimeConversationId,
12502
12324
  checkpointKey: internalCheckpointKey,
12503
12325
  maxSteps,
@@ -12615,7 +12437,7 @@ var ChildRunInvoker = class {
12615
12437
  );
12616
12438
  finalAnswer = extractFinalAnswer(allEvents);
12617
12439
  lastProgress = finalAnswer ? void 0 : extractLastProgress(allEvents);
12618
- logger17.info("child-run \u6267\u884C\u5B8C\u6210", {
12440
+ logger16.info("child-run \u6267\u884C\u5B8C\u6210", {
12619
12441
  stepCount,
12620
12442
  eventCount: allEvents.length,
12621
12443
  hasFinalAnswer: !!finalAnswer,
@@ -12645,13 +12467,13 @@ var ChildRunInvoker = class {
12645
12467
  cancelled = abortSignal?.aborted === true || isAbortError2(err);
12646
12468
  error = err instanceof Error ? err.message : String(err);
12647
12469
  if (cancelled) {
12648
- logger17.info("child-run \u6267\u884C\u53D6\u6D88", {
12470
+ logger16.info("child-run \u6267\u884C\u53D6\u6D88", {
12649
12471
  runId: childRunId,
12650
12472
  parentRunId: resolvedParentRunId,
12651
12473
  message: error
12652
12474
  });
12653
12475
  } else {
12654
- logger17.error(
12476
+ logger16.error(
12655
12477
  "child-run \u6267\u884C\u5931\u8D25:",
12656
12478
  err instanceof Error ? {
12657
12479
  name: err.name,
@@ -12747,7 +12569,7 @@ var ChildRunInvoker = class {
12747
12569
  function isAbortError2(error) {
12748
12570
  return error instanceof Error && error.name === "AbortError";
12749
12571
  }
12750
- function readNonEmptyString6(value) {
12572
+ function readNonEmptyString5(value) {
12751
12573
  if (typeof value !== "string") {
12752
12574
  return void 0;
12753
12575
  }
@@ -12755,7 +12577,7 @@ function readNonEmptyString6(value) {
12755
12577
  return trimmed.length > 0 ? trimmed : void 0;
12756
12578
  }
12757
12579
  function resolveChildRunConversationId(params) {
12758
- const conversationId = readNonEmptyString6(params.explicitConversationId) ?? readNonEmptyString6(params.parentToolContext.conversationId);
12580
+ const conversationId = readNonEmptyString5(params.explicitConversationId) ?? readNonEmptyString5(params.parentToolContext.conversationId);
12759
12581
  if (!conversationId) {
12760
12582
  throw new Error(
12761
12583
  "ChildRunInvoker requires conversationId from admission or parent ToolContext."
@@ -12764,7 +12586,7 @@ function resolveChildRunConversationId(params) {
12764
12586
  return conversationId;
12765
12587
  }
12766
12588
  function resolveChildRunModelId(params) {
12767
- const explicitModelId = readNonEmptyString6(params.explicitModelId);
12589
+ const explicitModelId = readNonEmptyString5(params.explicitModelId);
12768
12590
  if (explicitModelId) {
12769
12591
  return explicitModelId;
12770
12592
  }
@@ -13709,7 +13531,7 @@ function runMetaFromRecord(record) {
13709
13531
  }
13710
13532
 
13711
13533
  // src/runtime-kernel/run-supervisor/functions/awaitingUserWatcher.ts
13712
- var logger18 = new Logger("RunSupervisorAwaitingUserWatcher");
13534
+ var logger17 = new Logger("RunSupervisorAwaitingUserWatcher");
13713
13535
  function isRecord16(value) {
13714
13536
  return typeof value === "object" && value !== null && !Array.isArray(value);
13715
13537
  }
@@ -13754,7 +13576,7 @@ function createAwaitingUserWatcher(options) {
13754
13576
  resumeToken: event.resume_token
13755
13577
  }
13756
13578
  }).catch((error) => {
13757
- 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 });
13758
13580
  });
13759
13581
  };
13760
13582
  const dispose = () => {
@@ -15021,7 +14843,7 @@ function createScriptedInferenceHarness(script, options = {}) {
15021
14843
  }
15022
14844
 
15023
14845
  // src/context-manager/shared/MessageFormatter.ts
15024
- var logger19 = new Logger("MessageFormatter");
14846
+ var logger18 = new Logger("MessageFormatter");
15025
14847
  var MessageFormatter = class {
15026
14848
  fenceRegistry;
15027
14849
  constructor(options = {}) {
@@ -15087,12 +14909,12 @@ var MessageFormatter = class {
15087
14909
  case "context_injection": {
15088
14910
  const fenceKind = metadata?.fenceKind;
15089
14911
  if (!fenceKind) {
15090
- logger19.warn("context_injection missing metadata.fenceKind, skipping");
14912
+ logger18.warn("context_injection missing metadata.fenceKind, skipping");
15091
14913
  return null;
15092
14914
  }
15093
14915
  const descriptor = fenceRegistry?.get(fenceKind);
15094
14916
  if (!descriptor) {
15095
- logger19.warn("fence kind is not registered, skipping", { fenceKind });
14917
+ logger18.warn("fence kind is not registered, skipping", { fenceKind });
15096
14918
  return null;
15097
14919
  }
15098
14920
  return {
@@ -15131,7 +14953,7 @@ var MessageFormatter = class {
15131
14953
  case "task_completion":
15132
14954
  return { role, content };
15133
14955
  default:
15134
- logger19.warn("unhandled message type for chat history, skipping", { type });
14956
+ logger18.warn("unhandled message type for chat history, skipping", { type });
15135
14957
  return null;
15136
14958
  }
15137
14959
  }
@@ -15146,7 +14968,7 @@ z.object({
15146
14968
  }).strict();
15147
14969
 
15148
14970
  // src/context-manager/profiles/agent/utils/toolOutputSummarizer.ts
15149
- var logger21 = new Logger("ToolOutputSummarizer");
14971
+ var logger20 = new Logger("ToolOutputSummarizer");
15150
14972
  var DEFAULT_SUMMARIZER_CONFIG = {
15151
14973
  fullContentThreshold: 400,
15152
14974
  textPreviewLength: 200,
@@ -15186,7 +15008,7 @@ var ToolOutputSummarizer = class {
15186
15008
  return tool.getExecutionSummary(output);
15187
15009
  }
15188
15010
  } catch (error) {
15189
- logger21.error("tool getExecutionSummary failed", { toolName, error });
15011
+ logger20.error("tool getExecutionSummary failed", { toolName, error });
15190
15012
  }
15191
15013
  return null;
15192
15014
  }
@@ -15237,14 +15059,14 @@ var summarizeToolOutput = (toolName, output, toolSummaryProvider, config) => {
15237
15059
  };
15238
15060
 
15239
15061
  // src/context-manager/profiles/agent/utils/eventConverter.ts
15240
- var logger22 = new Logger("AgentEventConverter");
15062
+ var logger21 = new Logger("AgentEventConverter");
15241
15063
  function isHistorySummaryEvent(event) {
15242
15064
  return "type" in event && event.type === "history_summary";
15243
15065
  }
15244
15066
  function convertEventToAiMessage(event) {
15245
15067
  if (isHistorySummaryEvent(event)) {
15246
15068
  const replacedIds = Array.isArray(event.replaced_message_ids) ? event.replaced_message_ids : [];
15247
- logger22.debug("Converted history_summary RuntimeEvent to AiMessage", {
15069
+ logger21.debug("Converted history_summary RuntimeEvent to AiMessage", {
15248
15070
  summaryId: event.id,
15249
15071
  replacedCount: replacedIds.length,
15250
15072
  summarySeq: event.summary_seq,