@jsonstudio/llms 0.6.2172 → 0.6.2979
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/conversion/compat/antigravity-session-signature.js +35 -1
- package/dist/conversion/compat/profiles/chat-gemini-cli.json +0 -7
- package/dist/conversion/compat/profiles/chat-gemini.json +0 -6
- package/dist/conversion/hub/core/detour-registry.d.ts +2 -0
- package/dist/conversion/hub/core/hub-context.d.ts +3 -1
- package/dist/conversion/hub/core/index.d.ts +1 -0
- package/dist/conversion/hub/core/stage-driver.js +2 -0
- package/dist/conversion/hub/format-adapters/anthropic-format-adapter.js +15 -4
- package/dist/conversion/hub/format-adapters/chat-format-adapter.js +15 -4
- package/dist/conversion/hub/format-adapters/gemini-format-adapter.js +15 -4
- package/dist/conversion/hub/format-adapters/responses-format-adapter.js +15 -4
- package/dist/conversion/hub/hub-feature.js +3 -2
- package/dist/conversion/hub/node-support.js +9 -4
- package/dist/conversion/hub/operation-table/operation-table-runner.js +10 -6
- package/dist/conversion/hub/operation-table/semantic-mappers/anthropic-mapper.js +2 -2
- package/dist/conversion/hub/operation-table/semantic-mappers/chat-mapper.js +10 -10
- package/dist/conversion/hub/operation-table/semantic-mappers/gemini-mapper.js +4 -8
- package/dist/conversion/hub/operation-table/semantic-mappers/responses-mapper.js +19 -65
- package/dist/conversion/hub/ops/operations.js +2 -121
- package/dist/conversion/hub/pipeline/compat/compat-engine.js +6 -0
- package/dist/conversion/hub/pipeline/compat/compat-pipeline-executor.d.ts +1 -1
- package/dist/conversion/hub/pipeline/compat/compat-pipeline-executor.js +33 -1042
- package/dist/conversion/hub/pipeline/compat/compat-profile-resolver.js +2 -0
- package/dist/conversion/hub/pipeline/compat/compat-profile-store.js +2 -0
- package/dist/conversion/hub/pipeline/compat/compat-types.d.ts +14 -17
- package/dist/conversion/hub/pipeline/compat/native-adapter-context.d.ts +3 -0
- package/dist/conversion/hub/pipeline/compat/native-adapter-context.js +39 -0
- package/dist/conversion/hub/pipeline/hub-pipeline.js +115 -262
- package/dist/conversion/hub/pipeline/session-identifiers.js +6 -196
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage1_format_parse/index.d.ts +1 -2
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage1_format_parse/index.js +37 -1
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/index.js +12 -86
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/semantic-lift.d.ts +14 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/semantic-lift.js +24 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/archive/shell-like-tool-call-normalization-fallback.d.ts +2 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/archive/shell-like-tool-call-normalization-fallback.js +157 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-capture-orchestration.d.ts +16 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-capture-orchestration.js +29 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-factories.js +3 -1
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/index.d.ts +2 -15
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/index.js +8 -595
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/responses-context-snapshot.d.ts +8 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/responses-context-snapshot.js +28 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-diagnostics.d.ts +2 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-diagnostics.js +4 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-snapshot.d.ts +10 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-snapshot.js +12 -0
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/context-merge.d.ts +3 -0
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/context-merge.js +30 -0
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/index.js +9 -129
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage2_format_build/index.d.ts +1 -4
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage2_format_build/index.js +9 -26
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage3_compat/index.js +32 -14
- package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage1_tool_governance/index.d.ts +2 -2
- package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage1_tool_governance/index.js +48 -8
- package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage2_route_select/index.js +18 -3
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/index.js +10 -198
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/stream-json-sniffer.d.ts +3 -0
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/stream-json-sniffer.js +81 -0
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage2_format_parse/index.d.ts +1 -2
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage2_format_parse/index.js +36 -1
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage3_semantic_map/index.js +3 -1
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/chat-process-semantics-bridge.d.ts +6 -0
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/chat-process-semantics-bridge.js +17 -0
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/client-remap-protocol-switch.d.ts +9 -0
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/client-remap-protocol-switch.js +28 -0
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/index.d.ts +1 -2
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/index.js +14 -102
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage2_sse_stream/index.js +3 -1
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage1_tool_governance/index.js +12 -10
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage2_finalize/index.js +6 -5
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage3_servertool_orchestration/index.d.ts +11 -1
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage3_servertool_orchestration/index.js +10 -32
- package/dist/conversion/hub/pipeline/stages/utils.js +17 -1
- package/dist/conversion/hub/pipeline/target-utils.js +14 -91
- package/dist/conversion/hub/pipelines/inbound.js +3 -1
- package/dist/conversion/hub/pipelines/outbound.js +2 -0
- package/dist/conversion/hub/policy/policy-engine.js +9 -3
- package/dist/conversion/hub/policy/protocol-spec.js +20 -148
- package/dist/conversion/hub/process/chat-process-anthropic-alias.d.ts +2 -0
- package/dist/conversion/hub/process/chat-process-anthropic-alias.js +36 -0
- package/dist/conversion/hub/process/chat-process-clock-directive-parser.d.ts +5 -0
- package/dist/conversion/hub/process/chat-process-clock-directive-parser.js +48 -0
- package/dist/conversion/hub/process/chat-process-clock-directives.d.ts +24 -0
- package/dist/conversion/hub/process/chat-process-clock-directives.js +98 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-directives.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-directives.js +42 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-finalize.d.ts +14 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-finalize.js +10 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-messages.d.ts +5 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-messages.js +10 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-orchestration.d.ts +30 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-orchestration.js +68 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-time-tag.d.ts +9 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-time-tag.js +18 -0
- package/dist/conversion/hub/process/chat-process-clock-reminders.d.ts +2 -0
- package/dist/conversion/hub/process/chat-process-clock-reminders.js +104 -0
- package/dist/conversion/hub/process/chat-process-clock-tool-schemas.d.ts +3 -0
- package/dist/conversion/hub/process/chat-process-clock-tool-schemas.js +233 -0
- package/dist/conversion/hub/process/chat-process-clock-tools.d.ts +6 -0
- package/dist/conversion/hub/process/chat-process-clock-tools.js +41 -0
- package/dist/conversion/hub/process/chat-process-continue-execution.d.ts +11 -0
- package/dist/conversion/hub/process/chat-process-continue-execution.js +82 -0
- package/dist/conversion/hub/process/chat-process-governance-context.d.ts +15 -0
- package/dist/conversion/hub/process/chat-process-governance-context.js +7 -0
- package/dist/conversion/hub/process/chat-process-governance-finalize.d.ts +16 -0
- package/dist/conversion/hub/process/chat-process-governance-finalize.js +11 -0
- package/dist/conversion/hub/process/chat-process-governance-orchestration.d.ts +9 -0
- package/dist/conversion/hub/process/chat-process-governance-orchestration.js +47 -0
- package/dist/conversion/hub/process/chat-process-governed-control-ops.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-governed-control-ops.js +5 -0
- package/dist/conversion/hub/process/chat-process-governed-filter-call.d.ts +12 -0
- package/dist/conversion/hub/process/chat-process-governed-filter-call.js +18 -0
- package/dist/conversion/hub/process/chat-process-governed-merge.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-governed-merge.js +11 -0
- package/dist/conversion/hub/process/chat-process-media.d.ts +3 -0
- package/dist/conversion/hub/process/chat-process-media.js +18 -0
- package/dist/conversion/hub/process/chat-process-node-result.d.ts +23 -0
- package/dist/conversion/hub/process/chat-process-node-result.js +24 -0
- package/dist/conversion/hub/process/chat-process-pending-tool-sync.d.ts +14 -0
- package/dist/conversion/hub/process/chat-process-pending-tool-sync.js +52 -0
- package/dist/conversion/hub/process/chat-process-post-governed-normalization.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-post-governed-normalization.js +16 -0
- package/dist/conversion/hub/process/chat-process-review.d.ts +2 -0
- package/dist/conversion/hub/process/chat-process-review.js +8 -0
- package/dist/conversion/hub/process/chat-process-servertool-orchestration.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-servertool-orchestration.js +22 -0
- package/dist/conversion/hub/process/chat-process-tool-normalization.d.ts +2 -0
- package/dist/conversion/hub/process/chat-process-tool-normalization.js +4 -0
- package/dist/conversion/hub/process/chat-process-web-search-intent.d.ts +12 -0
- package/dist/conversion/hub/process/chat-process-web-search-intent.js +13 -0
- package/dist/conversion/hub/process/chat-process-web-search-tool-schema.d.ts +3 -0
- package/dist/conversion/hub/process/chat-process-web-search-tool-schema.js +4 -0
- package/dist/conversion/hub/process/chat-process-web-search.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-web-search.js +26 -0
- package/dist/conversion/hub/process/chat-process.d.ts +2 -19
- package/dist/conversion/hub/process/chat-process.js +12 -1701
- package/dist/conversion/hub/process/client-inject-readiness.d.ts +1 -0
- package/dist/conversion/hub/process/client-inject-readiness.js +4 -0
- package/dist/conversion/hub/registry.js +5 -2
- package/dist/conversion/hub/response/chat-response-utils.js +5 -86
- package/dist/conversion/hub/response/provider-response.d.ts +9 -0
- package/dist/conversion/hub/response/provider-response.js +6 -21
- package/dist/conversion/hub/response/response-mappers.js +2 -26
- package/dist/conversion/hub/response/response-runtime.js +2 -93
- package/dist/conversion/hub/semantic-mappers/anthropic-mapper.d.ts +1 -0
- package/dist/conversion/hub/semantic-mappers/anthropic-mapper.js +1 -0
- package/dist/conversion/hub/semantic-mappers/chat-mapper.d.ts +1 -0
- package/dist/conversion/hub/semantic-mappers/chat-mapper.js +1 -0
- package/dist/conversion/hub/semantic-mappers/gemini-mapper.d.ts +1 -0
- package/dist/conversion/hub/semantic-mappers/gemini-mapper.js +1 -0
- package/dist/conversion/hub/semantic-mappers/responses-mapper.d.ts +1 -0
- package/dist/conversion/hub/semantic-mappers/responses-mapper.js +1 -0
- package/dist/conversion/hub/snapshot-recorder.js +10 -3
- package/dist/conversion/hub/standardized-bridge.js +11 -288
- package/dist/conversion/hub/tool-governance/engine.js +5 -0
- package/dist/conversion/hub/tool-governance/rules.js +10 -10
- package/dist/conversion/hub/tool-session-compat.d.ts +2 -2
- package/dist/conversion/hub/tool-session-compat.js +17 -231
- package/dist/conversion/hub/tool-surface/tool-surface-engine.js +5 -3
- package/dist/conversion/responses/responses-host-policy.js +2 -12
- package/dist/conversion/responses/responses-openai-bridge/response-payload.js +6 -82
- package/dist/conversion/responses/responses-openai-bridge/types.d.ts +1 -0
- package/dist/conversion/responses/responses-openai-bridge.js +21 -54
- package/dist/conversion/shared/anthropic-message-utils.js +151 -13
- package/dist/conversion/shared/args-mapping.js +2 -146
- package/dist/conversion/shared/bridge-actions.js +203 -718
- package/dist/conversion/shared/bridge-id-utils.js +5 -71
- package/dist/conversion/shared/bridge-instructions.js +2 -1
- package/dist/conversion/shared/bridge-message-types.d.ts +2 -0
- package/dist/conversion/shared/bridge-message-utils.js +1 -2
- package/dist/conversion/shared/bridge-metadata.d.ts +1 -0
- package/dist/conversion/shared/bridge-metadata.js +4 -0
- package/dist/conversion/shared/bridge-policies.js +5 -189
- package/dist/conversion/shared/chat-envelope-validator.js +2 -126
- package/dist/conversion/shared/chat-output-normalizer.js +2 -54
- package/dist/conversion/shared/compaction-detect.js +2 -57
- package/dist/conversion/shared/gemini-tool-utils.js +9 -524
- package/dist/conversion/shared/jsonish.js +3 -160
- package/dist/conversion/shared/mcp-injection.js +3 -169
- package/dist/conversion/shared/media.js +2 -7
- package/dist/conversion/shared/metadata-passthrough.js +9 -46
- package/dist/conversion/shared/openai-finalizer.js +2 -1
- package/dist/conversion/shared/openai-message-normalize.js +11 -283
- package/dist/conversion/shared/output-content-normalizer.js +9 -112
- package/dist/conversion/shared/payload-budget.js +2 -85
- package/dist/conversion/shared/protocol-state.js +11 -7
- package/dist/conversion/shared/reasoning-mapping.js +2 -6
- package/dist/conversion/shared/reasoning-normalizer.js +4 -1
- package/dist/conversion/shared/reasoning-tool-normalizer.js +14 -126
- package/dist/conversion/shared/reasoning-tool-parser.js +4 -87
- package/dist/conversion/shared/reasoning-utils.js +2 -6
- package/dist/conversion/shared/responses-conversation-store.js +4 -82
- package/dist/conversion/shared/responses-output-builder.js +11 -47
- package/dist/conversion/shared/responses-reasoning-registry.js +7 -1
- package/dist/conversion/shared/responses-request-adapter.d.ts +7 -1
- package/dist/conversion/shared/responses-request-adapter.js +14 -1
- package/dist/conversion/shared/responses-response-utils.js +6 -7
- package/dist/conversion/shared/responses-tool-utils.d.ts +1 -0
- package/dist/conversion/shared/responses-tool-utils.js +90 -14
- package/dist/conversion/shared/runtime-metadata.js +13 -5
- package/dist/conversion/shared/streaming-text-extractor.js +2 -7
- package/dist/conversion/shared/text-markup-normalizer/normalize.d.ts +1 -1
- package/dist/conversion/shared/text-markup-normalizer/normalize.js +43 -17
- package/dist/conversion/shared/text-markup-normalizer.d.ts +1 -0
- package/dist/conversion/shared/text-markup-normalizer.js +1 -0
- package/dist/conversion/shared/thought-signature-validator.js +3 -2
- package/dist/conversion/shared/tool-argument-repairer.js +2 -2
- package/dist/conversion/shared/tool-call-id-manager.js +5 -7
- package/dist/conversion/shared/tool-call-utils.js +3 -45
- package/dist/conversion/shared/tool-canonicalizer.js +25 -29
- package/dist/conversion/shared/tool-filter-pipeline.js +4 -99
- package/dist/conversion/shared/tool-governor.d.ts +6 -0
- package/dist/conversion/shared/tool-governor.js +43 -125
- package/dist/conversion/shared/tool-harvester.js +2 -8
- package/dist/conversion/shared/tool-mapping.js +2 -5
- package/dist/conversion/shared/tooling.d.ts +0 -4
- package/dist/conversion/shared/tooling.js +18 -0
- package/dist/native/router_hotpath_napi.node +0 -0
- package/dist/router/virtual-router/engine/provider-key/parse.d.ts +1 -6
- package/dist/router/virtual-router/engine/provider-key/parse.js +1 -43
- package/dist/router/virtual-router/engine/routing-state/store.js +48 -12
- package/dist/router/virtual-router/engine-logging.js +4 -3
- package/dist/router/virtual-router/engine-selection/alias-selection.js +45 -83
- package/dist/router/virtual-router/engine-selection/key-parsing.js +9 -23
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-directive-parser.d.ts +20 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-directive-parser.js +163 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-directives.d.ts +7 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-directives.js +103 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-orchestration-semantics.d.ts +10 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-orchestration-semantics.js +110 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-semantics.d.ts +8 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-semantics.js +281 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-time-tag-semantics.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-time-tag-semantics.js +25 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminders-semantics.d.ts +4 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminders-semantics.js +44 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-tool-schema-semantics.d.ts +2 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-tool-schema-semantics.js +62 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-governance-semantics.d.ts +40 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-governance-semantics.js +484 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-governed-filter-semantics.d.ts +9 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-governed-filter-semantics.js +64 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-node-result-semantics.d.ts +5 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-node-result-semantics.js +163 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-post-governed-normalization-semantics.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-post-governed-normalization-semantics.js +49 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-servertool-orchestration-semantics.d.ts +30 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-servertool-orchestration-semantics.js +446 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-web-search-intent-semantics.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-web-search-intent-semantics.js +49 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-action-semantics.d.ts +134 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-action-semantics.js +729 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-policy-semantics.d.ts +62 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-policy-semantics.js +338 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-edge-stage-semantics.d.ts +18 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-edge-stage-semantics.js +317 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-inbound-outbound-semantics.d.ts +22 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-inbound-outbound-semantics.js +426 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-orchestration-semantics.d.ts +57 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-orchestration-semantics.js +705 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.d.ts +46 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.js +503 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-outbound-semantics.d.ts +146 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-outbound-semantics.js +570 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-process-semantics.d.ts +25 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-process-semantics.js +148 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-resp-semantics.d.ts +25 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-resp-semantics.js +637 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-session-identifiers-semantics.d.ts +11 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-session-identifiers-semantics.js +207 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-target-semantics.d.ts +3 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-target-semantics.js +128 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-analysis.d.ts +57 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-analysis.js +217 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-loader.d.ts +5 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-loader.js +284 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-policy.d.ts +5 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-policy.js +18 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-quota-buckets.d.ts +25 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-quota-buckets.js +85 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath.d.ts +59 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath.js +117 -0
- package/dist/router/virtual-router/engine-selection/native-shared-conversion-semantics.d.ts +76 -0
- package/dist/router/virtual-router/engine-selection/native-shared-conversion-semantics.js +1166 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-alias-selection-semantics.d.ts +16 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-alias-selection-semantics.js +96 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-actions-semantics.d.ts +6 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-actions-semantics.js +85 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-semantics.d.ts +9 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-semantics.js +70 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-state-semantics.d.ts +2 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-state-semantics.js +76 -0
- package/dist/router/virtual-router/engine-selection/route-utils.js +1 -1
- package/dist/router/virtual-router/engine-selection/tier-selection-antigravity-session-lease.d.ts +10 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-antigravity-session-lease.js +231 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-antigravity-target-split.d.ts +4 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-antigravity-target-split.js +43 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-quota-integration.d.ts +27 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-quota-integration.js +116 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-select.d.ts +1 -1
- package/dist/router/virtual-router/engine-selection/tier-selection-select.js +29 -129
- package/dist/router/virtual-router/engine-selection/tier-selection.js +2 -265
- package/dist/router/virtual-router/engine.js +258 -249
- package/dist/router/virtual-router/features.js +2 -2
- package/dist/router/virtual-router/routing-instructions.d.ts +5 -7
- package/dist/router/virtual-router/routing-instructions.js +93 -66
- package/dist/router/virtual-router/routing-stop-message-actions.js +91 -112
- package/dist/router/virtual-router/routing-stop-message-parser.js +9 -132
- package/dist/router/virtual-router/routing-stop-message-state-codec.d.ts +1 -0
- package/dist/router/virtual-router/routing-stop-message-state-codec.js +58 -71
- package/dist/router/virtual-router/sticky-session-store.js +4 -2
- package/dist/router/virtual-router/stop-message-file-resolver.d.ts +1 -0
- package/dist/router/virtual-router/stop-message-file-resolver.js +10 -0
- package/dist/router/virtual-router/stop-message-state-sync.d.ts +1 -1
- package/dist/router/virtual-router/stop-message-state-sync.js +3 -7
- package/dist/router/virtual-router/token-counter.js +0 -9
- package/dist/router/virtual-router/types.d.ts +9 -7
- package/dist/servertool/clock/config.js +23 -51
- package/dist/servertool/clock/io.js +1 -0
- package/dist/servertool/clock/session-scope.d.ts +2 -2
- package/dist/servertool/clock/session-scope.js +5 -47
- package/dist/servertool/engine.d.ts +9 -0
- package/dist/servertool/engine.js +196 -79
- package/dist/servertool/handlers/antigravity-thought-signature-bootstrap.js +2 -2
- package/dist/servertool/handlers/clock.js +1 -1
- package/dist/servertool/handlers/continue-execution.js +8 -4
- package/dist/servertool/handlers/followup-request-builder.js +18 -1
- package/dist/servertool/handlers/gemini-empty-reply-continue.js +7 -1
- package/dist/servertool/handlers/review.js +180 -0
- package/dist/servertool/handlers/stop-message-auto/blocked-report.js +59 -1
- package/dist/servertool/handlers/stop-message-auto/iflow-followup.d.ts +23 -2
- package/dist/servertool/handlers/stop-message-auto/iflow-followup.js +397 -89
- package/dist/servertool/handlers/stop-message-auto/routing-state.d.ts +5 -15
- package/dist/servertool/handlers/stop-message-auto/routing-state.js +29 -55
- package/dist/servertool/handlers/stop-message-auto/runtime-utils.d.ts +6 -0
- package/dist/servertool/handlers/stop-message-auto/runtime-utils.js +35 -61
- package/dist/servertool/handlers/stop-message-auto.js +392 -76
- package/dist/servertool/server-side-tools.d.ts +1 -0
- package/dist/servertool/server-side-tools.js +90 -52
- package/dist/servertool/types.d.ts +17 -0
- package/dist/tools/apply-patch/patch-text/normalize.js +11 -0
- package/dist/tools/exec-command/validator.d.ts +4 -1
- package/dist/tools/exec-command/validator.js +87 -3
- package/dist/tools/tool-registry.d.ts +7 -1
- package/dist/tools/tool-registry.js +3 -2
- package/package.json +115 -7
- package/dist/servertool/handlers/stop-message-stage-policy/bd-runtime.d.ts +0 -18
- package/dist/servertool/handlers/stop-message-stage-policy/bd-runtime.js +0 -398
- package/dist/servertool/handlers/stop-message-stage-policy/decision.d.ts +0 -9
- package/dist/servertool/handlers/stop-message-stage-policy/decision.js +0 -127
- package/dist/servertool/handlers/stop-message-stage-policy/observation.d.ts +0 -2
- package/dist/servertool/handlers/stop-message-stage-policy/observation.js +0 -179
- package/dist/servertool/handlers/stop-message-stage-policy/templates.d.ts +0 -4
- package/dist/servertool/handlers/stop-message-stage-policy/templates.js +0 -96
- package/dist/servertool/handlers/stop-message-stage-policy/text-utils.d.ts +0 -9
- package/dist/servertool/handlers/stop-message-stage-policy/text-utils.js +0 -89
- package/dist/servertool/handlers/stop-message-stage-policy/types.d.ts +0 -59
- package/dist/servertool/handlers/stop-message-stage-policy.d.ts +0 -3
- package/dist/servertool/handlers/stop-message-stage-policy.js +0 -2
- /package/dist/servertool/handlers/{stop-message-stage-policy/types.js → review.d.ts} +0 -0
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import * as childProcess from 'node:child_process';
|
|
2
|
+
import * as fs from 'node:fs';
|
|
3
|
+
import * as os from 'node:os';
|
|
4
|
+
import * as path from 'node:path';
|
|
2
5
|
import { readRuntimeMetadata } from '../../../conversion/shared/runtime-metadata.js';
|
|
3
6
|
import { extractTextFromMessageContent } from './blocked-report.js';
|
|
7
|
+
import { appendServerToolProgressFileEvent } from '../../log/progress-file.js';
|
|
8
|
+
const DEFAULT_STOP_MESSAGE_AI_DONE_MARKER = '[STOPMESSAGE_DONE]';
|
|
9
|
+
const DEFAULT_STOP_MESSAGE_AI_APPROVED_MARKER = '[STOPMESSAGE_APPROVED]';
|
|
4
10
|
const STOP_MESSAGE_AUTOMESSAGE_IFLOW_TIMEOUT_MS = 300_000;
|
|
5
11
|
const STOP_MESSAGE_AUTOMESSAGE_IFLOW_TIMEOUT_MAX_MS = 300_000;
|
|
6
12
|
const STOP_MESSAGE_AUTOMESSAGE_IFLOW_TIMEOUT_TEST_CAP_MS = 800;
|
|
@@ -8,80 +14,100 @@ const STOP_MESSAGE_AUTOMESSAGE_PROMPT_MAX_CHARS = 18_000;
|
|
|
8
14
|
const STOP_MESSAGE_AUTOMESSAGE_OUTPUT_MAX_CHARS = 1_600;
|
|
9
15
|
const STOP_MESSAGE_AUTOMESSAGE_LOG_SUMMARY_MAX_CHARS = 200;
|
|
10
16
|
const ANSI_ESCAPE_PATTERN = /\x1B\[[0-?]*[ -/]*[@-~]/g;
|
|
11
|
-
export function
|
|
12
|
-
if (!
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
const command = resolveStopMessageAutoMessageIflowCommand();
|
|
16
|
-
if (!command) {
|
|
17
|
+
export function renderStopMessageAutoFollowupViaAi(args) {
|
|
18
|
+
if (!isStopMessageAutoMessageEnabled()) {
|
|
17
19
|
return null;
|
|
18
20
|
}
|
|
19
|
-
const
|
|
20
|
-
if (!prompt) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
const timeoutMs = resolveStopMessageAutoMessageIflowTimeoutMs();
|
|
21
|
+
const backendOrder = resolveStopMessageAutoMessageBackendOrder();
|
|
24
22
|
const maxOutputChars = resolveStopMessageAutoMessageIflowOutputMaxChars();
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
23
|
+
const workingDirectory = resolveStopMessageAutoMessageWorkingDirectory(args.workingDirectory);
|
|
24
|
+
for (const backend of backendOrder) {
|
|
25
|
+
const command = resolveStopMessageAutoMessageCommand(backend);
|
|
26
|
+
if (!command) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const prompt = buildStopMessageAutoMessageIflowPrompt(args, backend);
|
|
30
|
+
if (!prompt) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const invocation = createStopMessageAutoMessageInvocation(backend, prompt);
|
|
34
|
+
const timeoutMs = resolveStopMessageAutoMessageTimeoutMs(backend);
|
|
35
|
+
const requestSummary = summarizeStopMessageAutoMessageLog([
|
|
36
|
+
`base=${args.baseStopMessageText || ''}`,
|
|
37
|
+
`candidate=${args.candidateFollowupText || ''}`,
|
|
38
|
+
`assistant=${args.responseSnapshot.assistantText || ''}`,
|
|
39
|
+
`reasoning=${args.responseSnapshot.reasoningText || ''}`,
|
|
40
|
+
`completionClaimed=${args.completionClaimed === true ? 'yes' : 'no'}`,
|
|
41
|
+
`backend=${backend}`,
|
|
42
|
+
`cwd=${workingDirectory || 'n/a'}`
|
|
43
|
+
].join(' | '), STOP_MESSAGE_AUTOMESSAGE_LOG_SUMMARY_MAX_CHARS);
|
|
44
|
+
logStopMessageAutoMessageIflow({
|
|
45
|
+
requestId: args.requestId,
|
|
46
|
+
stage: 'request',
|
|
47
|
+
requestSummary
|
|
41
48
|
});
|
|
42
|
-
|
|
43
|
-
const
|
|
49
|
+
try {
|
|
50
|
+
const result = childProcess.spawnSync(command, invocation.args, {
|
|
51
|
+
encoding: 'utf8',
|
|
52
|
+
timeout: timeoutMs,
|
|
53
|
+
maxBuffer: 1024 * 1024,
|
|
54
|
+
...(workingDirectory ? { cwd: workingDirectory } : {})
|
|
55
|
+
});
|
|
56
|
+
if (result.error || result.status !== 0) {
|
|
57
|
+
const responseSummary = summarizeStopMessageAutoMessageLog(sanitizeStopMessageAutoMessageOutput(result.stderr || result.stdout, STOP_MESSAGE_AUTOMESSAGE_OUTPUT_MAX_CHARS), STOP_MESSAGE_AUTOMESSAGE_LOG_SUMMARY_MAX_CHARS);
|
|
58
|
+
logStopMessageAutoMessageIflow({
|
|
59
|
+
requestId: args.requestId,
|
|
60
|
+
stage: 'response',
|
|
61
|
+
status: result.status ?? -1,
|
|
62
|
+
requestSummary,
|
|
63
|
+
responseSummary,
|
|
64
|
+
error: result.error ? String(result.error) : 'non_zero_exit'
|
|
65
|
+
});
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const backendOutput = backend === 'codex'
|
|
69
|
+
? sanitizeStopMessageAutoMessageOutput(readStopMessageAutoMessageCodexOutput(invocation.outputFilePath), maxOutputChars)
|
|
70
|
+
: '';
|
|
71
|
+
const stdout = backendOutput || sanitizeStopMessageAutoMessageOutput(result.stdout, maxOutputChars);
|
|
72
|
+
if (stdout) {
|
|
73
|
+
logStopMessageAutoMessageIflow({
|
|
74
|
+
requestId: args.requestId,
|
|
75
|
+
stage: 'response',
|
|
76
|
+
status: result.status ?? 0,
|
|
77
|
+
requestSummary,
|
|
78
|
+
responseSummary: summarizeStopMessageAutoMessageLog(stdout, STOP_MESSAGE_AUTOMESSAGE_LOG_SUMMARY_MAX_CHARS)
|
|
79
|
+
});
|
|
80
|
+
return stdout;
|
|
81
|
+
}
|
|
82
|
+
const stderr = sanitizeStopMessageAutoMessageOutput(result.stderr, maxOutputChars);
|
|
44
83
|
logStopMessageAutoMessageIflow({
|
|
45
84
|
requestId: args.requestId,
|
|
46
85
|
stage: 'response',
|
|
47
|
-
status: result.status ??
|
|
86
|
+
status: result.status ?? 0,
|
|
48
87
|
requestSummary,
|
|
49
|
-
responseSummary,
|
|
50
|
-
error: result.error ? String(result.error) : 'non_zero_exit'
|
|
88
|
+
responseSummary: summarizeStopMessageAutoMessageLog(stderr, STOP_MESSAGE_AUTOMESSAGE_LOG_SUMMARY_MAX_CHARS)
|
|
51
89
|
});
|
|
52
|
-
|
|
90
|
+
if (stderr) {
|
|
91
|
+
return stderr;
|
|
92
|
+
}
|
|
53
93
|
}
|
|
54
|
-
|
|
55
|
-
if (stdout) {
|
|
94
|
+
catch (error) {
|
|
56
95
|
logStopMessageAutoMessageIflow({
|
|
57
96
|
requestId: args.requestId,
|
|
58
97
|
stage: 'response',
|
|
59
|
-
status:
|
|
98
|
+
status: -1,
|
|
60
99
|
requestSummary,
|
|
61
|
-
|
|
100
|
+
error: error instanceof Error ? error.message : String(error ?? 'unknown_error')
|
|
62
101
|
});
|
|
63
|
-
return stdout;
|
|
64
102
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
stage: 'response',
|
|
69
|
-
status: result.status ?? 0,
|
|
70
|
-
requestSummary,
|
|
71
|
-
responseSummary: summarizeStopMessageAutoMessageLog(stderr, STOP_MESSAGE_AUTOMESSAGE_LOG_SUMMARY_MAX_CHARS)
|
|
72
|
-
});
|
|
73
|
-
return stderr || null;
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
logStopMessageAutoMessageIflow({
|
|
77
|
-
requestId: args.requestId,
|
|
78
|
-
stage: 'response',
|
|
79
|
-
status: -1,
|
|
80
|
-
requestSummary,
|
|
81
|
-
error: error instanceof Error ? error.message : String(error ?? 'unknown_error')
|
|
82
|
-
});
|
|
83
|
-
return null;
|
|
103
|
+
finally {
|
|
104
|
+
invocation.cleanup();
|
|
105
|
+
}
|
|
84
106
|
}
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
export function renderStopMessageAutoFollowupViaIflow(args) {
|
|
110
|
+
return renderStopMessageAutoFollowupViaAi(args);
|
|
85
111
|
}
|
|
86
112
|
export function extractStopMessageAutoResponseSnapshot(base, adapterContext) {
|
|
87
113
|
const providerProtocol = extractStopMessageProviderProtocol(adapterContext);
|
|
@@ -114,8 +140,8 @@ export function extractStopMessageAutoResponseSnapshot(base, adapterContext) {
|
|
|
114
140
|
toNonEmptyText(payload.finish_reason).toLowerCase() ||
|
|
115
141
|
toNonEmptyText(payload.status).toLowerCase() ||
|
|
116
142
|
undefined;
|
|
117
|
-
const assistantText = responsesText
|
|
118
|
-
const reasoningText = responsesReasoning
|
|
143
|
+
const assistantText = dedupeAndJoinTexts([responsesText, anthropicContent]);
|
|
144
|
+
const reasoningText = dedupeAndJoinTexts([responsesReasoning, anthropicReasoning]);
|
|
119
145
|
return {
|
|
120
146
|
...(providerProtocol ? { providerProtocol } : {}),
|
|
121
147
|
...(responseFinishReason ? { finishReason: responseFinishReason } : {}),
|
|
@@ -145,6 +171,17 @@ export function extractResponsesOutputText(base) {
|
|
|
145
171
|
if (typeof item.type !== 'string')
|
|
146
172
|
continue;
|
|
147
173
|
const type = String(item.type).trim().toLowerCase();
|
|
174
|
+
if (type.includes('tool') || type.includes('function') || type.includes('call')) {
|
|
175
|
+
const toolText = extractUnknownText(item.input) ||
|
|
176
|
+
extractUnknownText(item.arguments) ||
|
|
177
|
+
extractUnknownText(item.args) ||
|
|
178
|
+
extractUnknownText(item.patch) ||
|
|
179
|
+
extractUnknownText(item);
|
|
180
|
+
if (toolText) {
|
|
181
|
+
chunks.push(toolText);
|
|
182
|
+
}
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
148
185
|
if (type !== 'message')
|
|
149
186
|
continue;
|
|
150
187
|
const content = Array.isArray(item.content) ? (item.content) : [];
|
|
@@ -154,10 +191,21 @@ export function extractResponsesOutputText(base) {
|
|
|
154
191
|
const pType = typeof part.type === 'string'
|
|
155
192
|
? String(part.type).trim().toLowerCase()
|
|
156
193
|
: '';
|
|
157
|
-
if (pType === 'output_text') {
|
|
194
|
+
if (pType === 'output_text' || pType === 'text' || pType === 'input_text') {
|
|
158
195
|
const text = typeof part.text === 'string' ? String(part.text) : '';
|
|
159
196
|
if (text.trim().length)
|
|
160
197
|
chunks.push(text.trim());
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
const fallback = extractUnknownText(part.text) ||
|
|
201
|
+
extractUnknownText(part.input) ||
|
|
202
|
+
extractUnknownText(part.arguments) ||
|
|
203
|
+
extractUnknownText(part.args) ||
|
|
204
|
+
extractUnknownText(part.patch) ||
|
|
205
|
+
extractUnknownText(part.content) ||
|
|
206
|
+
extractUnknownText(part.value);
|
|
207
|
+
if (fallback) {
|
|
208
|
+
chunks.push(fallback);
|
|
161
209
|
}
|
|
162
210
|
}
|
|
163
211
|
}
|
|
@@ -177,8 +225,11 @@ export function hasToolLikeOutput(value) {
|
|
|
177
225
|
type === 'function_call' ||
|
|
178
226
|
type.includes('tool'));
|
|
179
227
|
}
|
|
180
|
-
function
|
|
181
|
-
const raw = String(process.env.
|
|
228
|
+
function isStopMessageAutoMessageEnabled() {
|
|
229
|
+
const raw = String(process.env.ROUTECODEX_STOPMESSAGE_AI_FOLLOWUP_ENABLED ??
|
|
230
|
+
process.env.ROUTECODEX_STOPMESSAGE_AUTOMESSAGE_ENABLED ??
|
|
231
|
+
process.env.ROUTECODEX_STOPMESSAGE_AUTOMESSAGE_IFLOW ??
|
|
232
|
+
'')
|
|
182
233
|
.trim()
|
|
183
234
|
.toLowerCase();
|
|
184
235
|
if (!raw) {
|
|
@@ -189,20 +240,63 @@ function isStopMessageAutoMessageIflowEnabled() {
|
|
|
189
240
|
}
|
|
190
241
|
return true;
|
|
191
242
|
}
|
|
192
|
-
function
|
|
193
|
-
const
|
|
243
|
+
function resolveStopMessageAutoMessageBackendOrder() {
|
|
244
|
+
const preferred = resolveStopMessageAutoMessageBackend();
|
|
245
|
+
if (preferred === 'iflow') {
|
|
246
|
+
return ['iflow', 'codex'];
|
|
247
|
+
}
|
|
248
|
+
return ['codex', 'iflow'];
|
|
249
|
+
}
|
|
250
|
+
function resolveStopMessageAutoMessageBackend() {
|
|
251
|
+
const raw = String(process.env.ROUTECODEX_STOPMESSAGE_AI_FOLLOWUP_BACKEND ??
|
|
252
|
+
process.env.ROUTECODEX_STOPMESSAGE_AUTOMESSAGE_BACKEND ??
|
|
253
|
+
'').trim().toLowerCase();
|
|
254
|
+
if (raw === 'iflow') {
|
|
255
|
+
return 'iflow';
|
|
256
|
+
}
|
|
257
|
+
if (raw === 'codex') {
|
|
258
|
+
return 'codex';
|
|
259
|
+
}
|
|
260
|
+
const legacyIflowHint = String(process.env.ROUTECODEX_STOPMESSAGE_AUTOMESSAGE_IFLOW || '').trim().toLowerCase();
|
|
261
|
+
if (legacyIflowHint && legacyIflowHint !== '0' && legacyIflowHint !== 'false' && legacyIflowHint !== 'no' && legacyIflowHint !== 'off') {
|
|
262
|
+
return 'iflow';
|
|
263
|
+
}
|
|
264
|
+
return 'codex';
|
|
265
|
+
}
|
|
266
|
+
function resolveStopMessageAutoMessageCommand(backend) {
|
|
267
|
+
if (backend === 'codex') {
|
|
268
|
+
const codexRaw = String(process.env.ROUTECODEX_STOPMESSAGE_AI_FOLLOWUP_CODEX_BIN ??
|
|
269
|
+
process.env.ROUTECODEX_STOPMESSAGE_AUTOMESSAGE_CODEX_BIN ??
|
|
270
|
+
'').trim();
|
|
271
|
+
return codexRaw || 'codex';
|
|
272
|
+
}
|
|
273
|
+
const raw = String(process.env.ROUTECODEX_STOPMESSAGE_AI_FOLLOWUP_IFLOW_BIN ??
|
|
274
|
+
process.env.ROUTECODEX_STOPMESSAGE_AUTOMESSAGE_IFLOW_BIN ??
|
|
275
|
+
'').trim();
|
|
194
276
|
return raw || 'iflow';
|
|
195
277
|
}
|
|
196
|
-
function
|
|
197
|
-
|
|
278
|
+
function resolveStopMessageAutoMessageWorkingDirectory(value) {
|
|
279
|
+
return typeof value === 'string' && value.trim() ? value.trim() : undefined;
|
|
280
|
+
}
|
|
281
|
+
function resolveStopMessageAutoMessageTimeoutMs(backend) {
|
|
282
|
+
const raw = String(process.env.ROUTECODEX_STOPMESSAGE_AI_FOLLOWUP_TIMEOUT_MS ??
|
|
283
|
+
process.env.ROUTECODEX_STOPMESSAGE_AUTOMESSAGE_TIMEOUT_MS ??
|
|
284
|
+
'').trim();
|
|
198
285
|
const parsed = Number(raw);
|
|
199
286
|
const explicitTimeout = Number.isFinite(parsed) && parsed > 0
|
|
200
287
|
? Math.max(200, Math.min(STOP_MESSAGE_AUTOMESSAGE_IFLOW_TIMEOUT_MAX_MS, Math.floor(parsed)))
|
|
201
288
|
: STOP_MESSAGE_AUTOMESSAGE_IFLOW_TIMEOUT_MS;
|
|
202
289
|
let resolvedTimeout = explicitTimeout;
|
|
203
|
-
const explicitCommand =
|
|
204
|
-
|
|
205
|
-
|
|
290
|
+
const explicitCommand = backend === 'codex'
|
|
291
|
+
? String(process.env.ROUTECODEX_STOPMESSAGE_AI_FOLLOWUP_CODEX_BIN ??
|
|
292
|
+
process.env.ROUTECODEX_STOPMESSAGE_AUTOMESSAGE_CODEX_BIN ??
|
|
293
|
+
'').trim()
|
|
294
|
+
: String(process.env.ROUTECODEX_STOPMESSAGE_AI_FOLLOWUP_IFLOW_BIN ??
|
|
295
|
+
process.env.ROUTECODEX_STOPMESSAGE_AUTOMESSAGE_IFLOW_BIN ??
|
|
296
|
+
'').trim();
|
|
297
|
+
const defaultCommand = backend === 'codex' ? 'codex' : 'iflow';
|
|
298
|
+
const usingDefaultCommand = !explicitCommand || explicitCommand === defaultCommand;
|
|
299
|
+
if (process.env.JEST_WORKER_ID && usingDefaultCommand) {
|
|
206
300
|
resolvedTimeout = Math.min(resolvedTimeout, STOP_MESSAGE_AUTOMESSAGE_IFLOW_TIMEOUT_TEST_CAP_MS);
|
|
207
301
|
}
|
|
208
302
|
const followupTimeoutRaw = String(process.env.ROUTECODEX_SERVERTOOL_FOLLOWUP_TIMEOUT_MS || '').trim();
|
|
@@ -213,8 +307,45 @@ function resolveStopMessageAutoMessageIflowTimeoutMs() {
|
|
|
213
307
|
}
|
|
214
308
|
return resolvedTimeout;
|
|
215
309
|
}
|
|
310
|
+
function createStopMessageAutoMessageInvocation(backend, prompt) {
|
|
311
|
+
if (backend !== 'codex') {
|
|
312
|
+
return {
|
|
313
|
+
args: ['-p', prompt],
|
|
314
|
+
cleanup: () => {
|
|
315
|
+
// no-op
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'routecodex-stopmessage-codex-'));
|
|
320
|
+
const outputFilePath = path.join(dir, 'last-message.txt');
|
|
321
|
+
return {
|
|
322
|
+
args: ['exec', '--color', 'never', '--skip-git-repo-check', '--output-last-message', outputFilePath, prompt],
|
|
323
|
+
outputFilePath,
|
|
324
|
+
cleanup: () => {
|
|
325
|
+
try {
|
|
326
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
327
|
+
}
|
|
328
|
+
catch {
|
|
329
|
+
// ignore cleanup errors
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
function readStopMessageAutoMessageCodexOutput(outputFilePath) {
|
|
335
|
+
if (!outputFilePath) {
|
|
336
|
+
return '';
|
|
337
|
+
}
|
|
338
|
+
try {
|
|
339
|
+
return fs.readFileSync(outputFilePath, 'utf8');
|
|
340
|
+
}
|
|
341
|
+
catch {
|
|
342
|
+
return '';
|
|
343
|
+
}
|
|
344
|
+
}
|
|
216
345
|
function resolveStopMessageAutoMessageIflowOutputMaxChars() {
|
|
217
|
-
const raw = String(process.env.
|
|
346
|
+
const raw = String(process.env.ROUTECODEX_STOPMESSAGE_AI_FOLLOWUP_OUTPUT_MAX_CHARS ??
|
|
347
|
+
process.env.ROUTECODEX_STOPMESSAGE_AUTOMESSAGE_OUTPUT_MAX_CHARS ??
|
|
348
|
+
'').trim();
|
|
218
349
|
const parsed = Number(raw);
|
|
219
350
|
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
220
351
|
return STOP_MESSAGE_AUTOMESSAGE_OUTPUT_MAX_CHARS;
|
|
@@ -246,26 +377,69 @@ function truncateStopMessageAutoMessagePrompt(value, maxChars) {
|
|
|
246
377
|
}
|
|
247
378
|
return `${text.slice(0, maxChars)}...`;
|
|
248
379
|
}
|
|
249
|
-
function buildStopMessageAutoMessageIflowPrompt(args) {
|
|
380
|
+
function buildStopMessageAutoMessageIflowPrompt(args, backend) {
|
|
381
|
+
const usedRepeats = Math.max(0, Math.floor(args.usedRepeats));
|
|
382
|
+
const maxRepeats = Math.max(0, Math.floor(args.maxRepeats));
|
|
383
|
+
const nextRound = usedRepeats + 1;
|
|
384
|
+
const roundsLabel = maxRepeats > 0 ? `${nextRound}/${maxRepeats}` : `${nextRound}/n/a`;
|
|
385
|
+
const remaining = maxRepeats > 0 ? Math.max(0, maxRepeats - nextRound) : 0;
|
|
386
|
+
const overallGoal = (typeof args.candidateFollowupText === 'string' && args.candidateFollowupText.trim()) ||
|
|
387
|
+
(typeof args.baseStopMessageText === 'string' && args.baseStopMessageText.trim()) ||
|
|
388
|
+
'继续执行';
|
|
389
|
+
const approvedMarker = resolveStopMessageAiApprovedMarker(args.approvedMarker);
|
|
390
|
+
const completionClaimed = args.completionClaimed === true;
|
|
391
|
+
const isFirstPrompt = Boolean(args.isFirstPrompt);
|
|
392
|
+
const historyBlock = renderStopMessageAiHistoryEntries(args.historyEntries);
|
|
250
393
|
const lines = [
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
394
|
+
isFirstPrompt
|
|
395
|
+
? '你是 RouteCodex 的 ai-followup 生成器(首次引导)。'
|
|
396
|
+
: '你是 RouteCodex 的 ai-followup 生成器(续轮系统约束)。',
|
|
397
|
+
'角色定位:你是“执行审稿人(reviewer)”,默认做审慎核验但不要吹毛求疵,仍以证据驱动判断。',
|
|
398
|
+
'任务:根据“短期目标(用户输入) + 当前执行进度 + 模型反馈消息内容 + 历史记录(xxx)”,生成下一步用户 followup 消息。',
|
|
399
|
+
isFirstPrompt ? '首次提示词(完整规则):' : '续轮系统提示词(延续同一目标):',
|
|
254
400
|
'1) 只输出一段可直接注入的用户消息文本;不要解释、不要 JSON、不要代码块。',
|
|
255
|
-
'
|
|
256
|
-
'
|
|
257
|
-
'
|
|
258
|
-
'
|
|
401
|
+
'1.1) 输出目标固定为:根据当前状态调整后的下一步 followup 消息文本。',
|
|
402
|
+
'2) 模型反馈=消息内容(assistantText/reasoningText/responseExcerpt);你的指令必须基于这些实际内容,不得凭空编造状态。',
|
|
403
|
+
'3) 先做代码 review(最多一句),再给指令:必须结合 workingDirectory 下当前实现/测试/构建状态给出建议;不能只做抽象建议。',
|
|
404
|
+
'3.1) 主模型若声明“完成了某项”,优先核验与 overallGoal 直接相关的关键项;非关键分支/小目标可记录为后续补充验证,不必阻塞推进。',
|
|
405
|
+
'3.2) 通过标准以“总体目标是否达成”为主;当主目标证据充分时,允许次要项暂未验证,并给出后续补测建议。',
|
|
406
|
+
'3.3) 若主模型声称“无法完成/被阻塞”,你必须要求其提供阻塞证据,并判断是否存在可继续推进的最小可执行动作。',
|
|
407
|
+
'3.4) 必要时必须要求其打开并检查已改代码(明确到文件),再给出具体修改建议,不允许停留在抽象层面。',
|
|
408
|
+
'4) 必须包含至少一个可执行动作(具体文件、命令、检查点或验证目标),并尽量最小化下一步范围;优先“写动作”(改代码/补测试)。',
|
|
409
|
+
'5) 禁止输出空泛短答:如“继续”“继续执行”“好的”“收到”“ok”。',
|
|
410
|
+
'6) 禁止把回复做成纯状态汇总;默认是推进执行,直到阶段目标或总体目标完成。',
|
|
411
|
+
'7) 只有在消息内容或历史记录里存在明确证据时,才允许判断“偏离目标”;否则按同轨推进,不要泛化指责偏离。',
|
|
412
|
+
'8) 若判定偏离,必须在指令里点明证据来源(来自消息内容或历史记录)并给出回轨的最小动作;若无证据,直接给下一步动作。',
|
|
413
|
+
'9) 禁止把 review 责任交回主模型(例如“请你先自己 review/自查代码”);review 必须由你(ai-followup)先完成。',
|
|
414
|
+
'10) 禁止连续安排纯只读/纯汇报命令(如 cargo llvm-cov report、cat/head/tail/rg/git status);若上一轮没有代码修改证据,本轮必须先给出写动作(修改文件或新增测试),再允许验证命令。',
|
|
415
|
+
'11) 覆盖率类命令只能作为写动作后的验证步骤,不能作为本轮唯一或首要动作。',
|
|
416
|
+
completionClaimed
|
|
417
|
+
? '12) 参考信号:主模型本轮声称“已完成”,但你必须独立核验,不能直接采信。'
|
|
418
|
+
: '12) 主模型未显式声称完成;你仍可基于证据独立判断是否达成总体目标。',
|
|
419
|
+
`13) 当关键路径证据充分且确认已完成总体目标时,允许只输出 ${approvedMarker} 作为唯一内容;若仅剩非关键小项未验证,也可判定通过并建议后续补齐。`,
|
|
420
|
+
`14) 若证据不足或主目标未达成,严禁输出 ${approvedMarker}。`,
|
|
421
|
+
'',
|
|
422
|
+
'本轮注入上下文(必须参考):',
|
|
423
|
+
`overallGoal(短期目标): ${overallGoal}`,
|
|
259
424
|
'',
|
|
260
425
|
`baseStopMessage: ${args.baseStopMessageText || 'n/a'}`,
|
|
261
426
|
`candidateFollowup: ${args.candidateFollowupText || 'n/a'}`,
|
|
262
|
-
`repeat: ${
|
|
427
|
+
`repeat: ${roundsLabel}`,
|
|
428
|
+
`progress: used=${usedRepeats} next=${nextRound} max=${maxRepeats > 0 ? maxRepeats : 'n/a'} remaining=${maxRepeats > 0 ? remaining : 'n/a'}`,
|
|
263
429
|
`requestId: ${args.requestId || 'n/a'}`,
|
|
264
430
|
`sessionId: ${args.sessionId || 'n/a'}`,
|
|
265
431
|
`providerKey: ${args.providerKey || 'n/a'}`,
|
|
266
432
|
`model: ${args.model || 'n/a'}`,
|
|
433
|
+
`workingDirectory: ${args.workingDirectory || 'n/a'}`,
|
|
434
|
+
`completionClaimedByMainModel: ${completionClaimed ? 'yes' : 'no'}`,
|
|
435
|
+
`reviewApprovedMarker: ${approvedMarker}`,
|
|
436
|
+
'historyRecord(xxx): 见下方 stopMessage 历史轨迹',
|
|
437
|
+
'modelFeedback(消息内容): 见下方 assistantText/reasoningText/responseExcerpt',
|
|
438
|
+
'',
|
|
439
|
+
'stopMessage 历史轨迹(最近轮次,按时间升序):',
|
|
440
|
+
historyBlock,
|
|
267
441
|
'',
|
|
268
|
-
'
|
|
442
|
+
'当前模型反馈(结构化摘录):',
|
|
269
443
|
`responseProtocol: ${args.responseSnapshot.providerProtocol || 'n/a'}`,
|
|
270
444
|
`finishReason: ${args.responseSnapshot.finishReason || 'n/a'}`,
|
|
271
445
|
'',
|
|
@@ -278,9 +452,44 @@ function buildStopMessageAutoMessageIflowPrompt(args) {
|
|
|
278
452
|
'responseExcerpt:',
|
|
279
453
|
truncateStopMessageAutoMessagePrompt(args.responseSnapshot.responseExcerpt || 'n/a', 6_000)
|
|
280
454
|
];
|
|
281
|
-
|
|
455
|
+
const closingInstruction = `现在做完成校验:若确认已完成,仅输出 ${approvedMarker};否则输出“根据当前状态调整后的下一步 followup 消息文本”。`;
|
|
456
|
+
lines.push('', closingInstruction);
|
|
282
457
|
const prompt = lines.join('\n').trim();
|
|
283
|
-
|
|
458
|
+
if (prompt.length <= STOP_MESSAGE_AUTOMESSAGE_PROMPT_MAX_CHARS) {
|
|
459
|
+
return prompt;
|
|
460
|
+
}
|
|
461
|
+
const reserve = closingInstruction.length + 4;
|
|
462
|
+
if (STOP_MESSAGE_AUTOMESSAGE_PROMPT_MAX_CHARS <= reserve + 32) {
|
|
463
|
+
return truncateStopMessageAutoMessagePrompt(prompt, STOP_MESSAGE_AUTOMESSAGE_PROMPT_MAX_CHARS);
|
|
464
|
+
}
|
|
465
|
+
const headLimit = STOP_MESSAGE_AUTOMESSAGE_PROMPT_MAX_CHARS - reserve - 3;
|
|
466
|
+
const head = prompt.slice(0, headLimit).trimEnd();
|
|
467
|
+
return `${head}...\n\n${closingInstruction}`;
|
|
468
|
+
}
|
|
469
|
+
export function buildStopMessageAutoMessageIflowPromptForTests(args, backend = 'iflow') {
|
|
470
|
+
return buildStopMessageAutoMessageIflowPrompt(args, backend);
|
|
471
|
+
}
|
|
472
|
+
function renderStopMessageAiHistoryEntries(entries) {
|
|
473
|
+
if (!Array.isArray(entries) || entries.length === 0) {
|
|
474
|
+
return '- (empty)';
|
|
475
|
+
}
|
|
476
|
+
const normalized = entries
|
|
477
|
+
.slice(-8)
|
|
478
|
+
.map((entry) => {
|
|
479
|
+
const round = Number.isFinite(entry?.round) ? Math.max(0, Math.floor(entry.round)) : 0;
|
|
480
|
+
const assistant = truncateStopMessageAutoMessagePrompt(String(entry?.assistantText || ''), 280);
|
|
481
|
+
const followup = truncateStopMessageAutoMessagePrompt(String(entry?.followupText || ''), 280);
|
|
482
|
+
const reasoning = truncateStopMessageAutoMessagePrompt(String(entry?.reasoningText || ''), 220);
|
|
483
|
+
const parts = [
|
|
484
|
+
`round=${round || 'n/a'}`,
|
|
485
|
+
assistant ? `assistant=${assistant}` : '',
|
|
486
|
+
reasoning ? `reasoning=${reasoning}` : '',
|
|
487
|
+
followup ? `followup=${followup}` : ''
|
|
488
|
+
].filter(Boolean);
|
|
489
|
+
return `- ${parts.join(' | ')}`;
|
|
490
|
+
})
|
|
491
|
+
.filter((line) => line.trim().length > 0);
|
|
492
|
+
return normalized.length > 0 ? normalized.join('\n') : '- (empty)';
|
|
284
493
|
}
|
|
285
494
|
function summarizeStopMessageAutoMessageLog(value, maxChars) {
|
|
286
495
|
const text = typeof value === 'string' ? value : '';
|
|
@@ -296,8 +505,32 @@ function summarizeStopMessageAutoMessageLog(value, maxChars) {
|
|
|
296
505
|
}
|
|
297
506
|
return `${singleLine.slice(0, maxChars)}...`;
|
|
298
507
|
}
|
|
508
|
+
export function resolveStopMessageAiDoneMarker(value) {
|
|
509
|
+
const explicit = typeof value === 'string' && value.trim() ? value.trim() : '';
|
|
510
|
+
if (explicit) {
|
|
511
|
+
return explicit;
|
|
512
|
+
}
|
|
513
|
+
const envValue = String(process.env.ROUTECODEX_STOPMESSAGE_AI_DONE_MARKER || '').trim();
|
|
514
|
+
if (envValue) {
|
|
515
|
+
return envValue;
|
|
516
|
+
}
|
|
517
|
+
return DEFAULT_STOP_MESSAGE_AI_DONE_MARKER;
|
|
518
|
+
}
|
|
519
|
+
export function resolveStopMessageAiApprovedMarker(value) {
|
|
520
|
+
const explicit = typeof value === 'string' && value.trim() ? value.trim() : '';
|
|
521
|
+
if (explicit) {
|
|
522
|
+
return explicit;
|
|
523
|
+
}
|
|
524
|
+
const envValue = String(process.env.ROUTECODEX_STOPMESSAGE_AI_APPROVED_MARKER || '').trim();
|
|
525
|
+
if (envValue) {
|
|
526
|
+
return envValue;
|
|
527
|
+
}
|
|
528
|
+
return DEFAULT_STOP_MESSAGE_AI_APPROVED_MARKER;
|
|
529
|
+
}
|
|
299
530
|
function isStopMessageAutoMessageIflowTraceEnabled() {
|
|
300
|
-
const raw = String(process.env.
|
|
531
|
+
const raw = String(process.env.ROUTECODEX_STOPMESSAGE_AI_FOLLOWUP_TRACE ??
|
|
532
|
+
process.env.ROUTECODEX_STOPMESSAGE_IFLOW_TRACE ??
|
|
533
|
+
'').trim().toLowerCase();
|
|
301
534
|
if (!raw) {
|
|
302
535
|
return true;
|
|
303
536
|
}
|
|
@@ -307,6 +540,29 @@ function isStopMessageAutoMessageIflowTraceEnabled() {
|
|
|
307
540
|
return true;
|
|
308
541
|
}
|
|
309
542
|
function logStopMessageAutoMessageIflow(args) {
|
|
543
|
+
const requestId = args.requestId && args.requestId.trim() ? args.requestId.trim() : 'unknown';
|
|
544
|
+
const stage = args.stage;
|
|
545
|
+
const statusToken = typeof args.status === 'number' ? ` status=${args.status}` : '';
|
|
546
|
+
const errorToken = args.error ? ` error=${args.error}` : '';
|
|
547
|
+
const requestSummary = args.requestSummary || '';
|
|
548
|
+
const responseSummary = args.responseSummary || '';
|
|
549
|
+
const eventMessage = stage === 'request'
|
|
550
|
+
? requestSummary
|
|
551
|
+
: `${requestSummary}${requestSummary && (responseSummary || statusToken || errorToken) ? ' | ' : ''}${responseSummary}${statusToken}${errorToken}`.trim();
|
|
552
|
+
const eventResult = stage === 'request'
|
|
553
|
+
? 'sent'
|
|
554
|
+
: args.error || (typeof args.status === 'number' && args.status !== 0)
|
|
555
|
+
? 'failed'
|
|
556
|
+
: 'completed';
|
|
557
|
+
appendServerToolProgressFileEvent({
|
|
558
|
+
requestId,
|
|
559
|
+
flowId: 'stop_message_flow',
|
|
560
|
+
tool: 'ai_followup',
|
|
561
|
+
stage,
|
|
562
|
+
result: eventResult,
|
|
563
|
+
message: eventMessage,
|
|
564
|
+
step: stage === 'request' ? 3 : 4
|
|
565
|
+
});
|
|
310
566
|
if (!isStopMessageAutoMessageIflowTraceEnabled()) {
|
|
311
567
|
return;
|
|
312
568
|
}
|
|
@@ -316,7 +572,7 @@ function logStopMessageAutoMessageIflow(args) {
|
|
|
316
572
|
const request = args.requestSummary || '';
|
|
317
573
|
// cyan: outbound request summary
|
|
318
574
|
// eslint-disable-next-line no-console
|
|
319
|
-
console.log(`\x1b[38;5;45m[servertool][
|
|
575
|
+
console.log(`\x1b[38;5;45m[servertool][ai-followup] SEND${requestIdPart} ${request}\x1b[0m`);
|
|
320
576
|
return;
|
|
321
577
|
}
|
|
322
578
|
const response = args.responseSummary || '';
|
|
@@ -325,12 +581,12 @@ function logStopMessageAutoMessageIflow(args) {
|
|
|
325
581
|
const errorPart = args.error ? ` error=${args.error}` : '';
|
|
326
582
|
// red: failed response summary
|
|
327
583
|
// eslint-disable-next-line no-console
|
|
328
|
-
console.log(`\x1b[38;5;196m[servertool][
|
|
584
|
+
console.log(`\x1b[38;5;196m[servertool][ai-followup] RECV${requestIdPart}${statusPart}${errorPart} ${response}\x1b[0m`);
|
|
329
585
|
return;
|
|
330
586
|
}
|
|
331
587
|
// green: successful response summary
|
|
332
588
|
// eslint-disable-next-line no-console
|
|
333
|
-
console.log(`\x1b[38;5;46m[servertool][
|
|
589
|
+
console.log(`\x1b[38;5;46m[servertool][ai-followup] RECV${requestIdPart} ${response}\x1b[0m`);
|
|
334
590
|
}
|
|
335
591
|
catch {
|
|
336
592
|
// ignore logging failures
|
|
@@ -346,11 +602,44 @@ function extractStopMessageProviderProtocol(adapterContext) {
|
|
|
346
602
|
return fromRuntime || undefined;
|
|
347
603
|
}
|
|
348
604
|
function extractStopMessageAssistantText(message) {
|
|
605
|
+
const chunks = [];
|
|
349
606
|
const contentText = extractTextFromMessageContent(message.content);
|
|
350
607
|
if (contentText) {
|
|
351
|
-
|
|
608
|
+
chunks.push(contentText);
|
|
609
|
+
}
|
|
610
|
+
const directKeys = [
|
|
611
|
+
'text',
|
|
612
|
+
'output_text',
|
|
613
|
+
'response',
|
|
614
|
+
'summary',
|
|
615
|
+
'message',
|
|
616
|
+
'result',
|
|
617
|
+
'command',
|
|
618
|
+
'patch'
|
|
619
|
+
];
|
|
620
|
+
for (const key of directKeys) {
|
|
621
|
+
const text = extractUnknownText(message[key]);
|
|
622
|
+
if (text) {
|
|
623
|
+
chunks.push(text);
|
|
624
|
+
}
|
|
352
625
|
}
|
|
353
|
-
|
|
626
|
+
const toolLikeKeys = [
|
|
627
|
+
'tool_calls',
|
|
628
|
+
'tool_call',
|
|
629
|
+
'function_call',
|
|
630
|
+
'tool_use',
|
|
631
|
+
'input',
|
|
632
|
+
'arguments',
|
|
633
|
+
'args',
|
|
634
|
+
'payload'
|
|
635
|
+
];
|
|
636
|
+
for (const key of toolLikeKeys) {
|
|
637
|
+
const text = extractUnknownText(message[key]);
|
|
638
|
+
if (text) {
|
|
639
|
+
chunks.push(text);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
return dedupeAndJoinTexts(chunks);
|
|
354
643
|
}
|
|
355
644
|
function extractStopMessageReasoningText(message) {
|
|
356
645
|
const explicitKeys = [
|
|
@@ -447,7 +736,26 @@ function extractUnknownText(value, depth = 0) {
|
|
|
447
736
|
return '';
|
|
448
737
|
}
|
|
449
738
|
const record = value;
|
|
450
|
-
const priorityKeys = [
|
|
739
|
+
const priorityKeys = [
|
|
740
|
+
'text',
|
|
741
|
+
'content',
|
|
742
|
+
'value',
|
|
743
|
+
'summary',
|
|
744
|
+
'reasoning',
|
|
745
|
+
'thinking',
|
|
746
|
+
'analysis',
|
|
747
|
+
'function',
|
|
748
|
+
'input',
|
|
749
|
+
'arguments',
|
|
750
|
+
'args',
|
|
751
|
+
'patch',
|
|
752
|
+
'payload',
|
|
753
|
+
'result',
|
|
754
|
+
'command',
|
|
755
|
+
'message',
|
|
756
|
+
'output_text',
|
|
757
|
+
'name'
|
|
758
|
+
];
|
|
451
759
|
const parts = [];
|
|
452
760
|
for (const key of priorityKeys) {
|
|
453
761
|
if (!(key in record)) {
|