@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
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { parseDueAtMs } from '../../../servertool/clock/task-store.js';
|
|
2
|
+
import { parseClockScheduleDirectiveCandidateWithNative } from '../../../router/virtual-router/engine-selection/native-chat-process-clock-directive-parser.js';
|
|
3
|
+
function normalizeRecurrence(recurrence) {
|
|
4
|
+
if (!recurrence) {
|
|
5
|
+
return undefined;
|
|
6
|
+
}
|
|
7
|
+
if (recurrence.kind === 'interval') {
|
|
8
|
+
if (typeof recurrence.everyMinutes !== 'number' || recurrence.everyMinutes <= 0) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
kind: 'interval',
|
|
13
|
+
maxRuns: Math.floor(recurrence.maxRuns),
|
|
14
|
+
everyMinutes: Math.floor(recurrence.everyMinutes)
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
kind: recurrence.kind,
|
|
19
|
+
maxRuns: Math.floor(recurrence.maxRuns)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function hydrateClockScheduleDirectiveCandidate(candidate) {
|
|
23
|
+
const dueAtMs = parseDueAtMs(candidate.dueAt);
|
|
24
|
+
if (!dueAtMs || !candidate.task) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
const recurrence = normalizeRecurrence(candidate.recurrence);
|
|
28
|
+
if (candidate.recurrence && !recurrence) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
dueAtMs,
|
|
33
|
+
dueAt: new Date(dueAtMs).toISOString(),
|
|
34
|
+
task: candidate.task,
|
|
35
|
+
...(recurrence ? { recurrence } : {})
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export function parseClockScheduleDirectiveCandidatePayload(payload) {
|
|
39
|
+
const raw = String(payload || '').trim();
|
|
40
|
+
return parseClockScheduleDirectiveCandidateWithNative(raw);
|
|
41
|
+
}
|
|
42
|
+
export function parseClockScheduleDirectivePayload(payload) {
|
|
43
|
+
const candidate = parseClockScheduleDirectiveCandidatePayload(payload);
|
|
44
|
+
if (!candidate) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return hydrateClockScheduleDirectiveCandidate(candidate);
|
|
48
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { StandardizedMessage } from '../types/standardized.js';
|
|
2
|
+
import type { ClockTaskRecurrence } from '../../../servertool/clock/task-store.js';
|
|
3
|
+
export type ClockScheduleDirective = {
|
|
4
|
+
dueAtMs: number;
|
|
5
|
+
dueAt: string;
|
|
6
|
+
task: string;
|
|
7
|
+
recurrence?: ClockTaskRecurrence;
|
|
8
|
+
};
|
|
9
|
+
export declare function stripClockClearDirectiveFromText(text: string): {
|
|
10
|
+
hadClear: boolean;
|
|
11
|
+
next: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function extractClockScheduleDirectivesFromText(text: string): {
|
|
14
|
+
directives: ClockScheduleDirective[];
|
|
15
|
+
next: string;
|
|
16
|
+
};
|
|
17
|
+
export declare function extractClockScheduleDirectivesFromContent(content: StandardizedMessage['content']): {
|
|
18
|
+
directives: ClockScheduleDirective[];
|
|
19
|
+
next: StandardizedMessage['content'];
|
|
20
|
+
};
|
|
21
|
+
export declare function stripClockClearDirectiveFromContent(content: StandardizedMessage['content']): {
|
|
22
|
+
hadClear: boolean;
|
|
23
|
+
next: StandardizedMessage['content'];
|
|
24
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { stripClockClearDirectiveText } from '../../../router/virtual-router/engine-selection/native-router-hotpath.js';
|
|
2
|
+
import { extractClockScheduleDirectiveTextPartsWithNative } from '../../../router/virtual-router/engine-selection/native-chat-process-clock-directive-parser.js';
|
|
3
|
+
import { hydrateClockScheduleDirectiveCandidate } from './chat-process-clock-directive-parser.js';
|
|
4
|
+
export function stripClockClearDirectiveFromText(text) {
|
|
5
|
+
const analysis = stripClockClearDirectiveText(String(text || ''));
|
|
6
|
+
return {
|
|
7
|
+
hadClear: analysis.hadClear,
|
|
8
|
+
next: analysis.next
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export function extractClockScheduleDirectivesFromText(text) {
|
|
12
|
+
const raw = String(text || '');
|
|
13
|
+
const parts = extractClockScheduleDirectiveTextPartsWithNative(raw);
|
|
14
|
+
const directives = [];
|
|
15
|
+
const nextParts = [];
|
|
16
|
+
for (const part of parts) {
|
|
17
|
+
if (part.kind === 'text') {
|
|
18
|
+
nextParts.push(part.text);
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
const parsed = part.candidate ? hydrateClockScheduleDirectiveCandidate(part.candidate) : null;
|
|
22
|
+
if (!parsed) {
|
|
23
|
+
nextParts.push(part.full);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
directives.push(parsed);
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
directives,
|
|
30
|
+
next: nextParts.join('').replace(/\n{3,}/g, '\n\n').trim()
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function extractClockScheduleDirectivesFromContent(content) {
|
|
34
|
+
if (typeof content === 'string') {
|
|
35
|
+
const result = extractClockScheduleDirectivesFromText(content);
|
|
36
|
+
return { directives: result.directives, next: result.next };
|
|
37
|
+
}
|
|
38
|
+
if (Array.isArray(content)) {
|
|
39
|
+
const directives = [];
|
|
40
|
+
const next = content.map((part) => {
|
|
41
|
+
if (typeof part === 'string') {
|
|
42
|
+
const result = extractClockScheduleDirectivesFromText(part);
|
|
43
|
+
if (result.directives.length) {
|
|
44
|
+
directives.push(...result.directives);
|
|
45
|
+
}
|
|
46
|
+
return result.next;
|
|
47
|
+
}
|
|
48
|
+
if (part && typeof part === 'object' && !Array.isArray(part)) {
|
|
49
|
+
const block = part;
|
|
50
|
+
const text = typeof block.text === 'string' ? block.text : undefined;
|
|
51
|
+
if (!text) {
|
|
52
|
+
return part;
|
|
53
|
+
}
|
|
54
|
+
const result = extractClockScheduleDirectivesFromText(text);
|
|
55
|
+
if (result.directives.length) {
|
|
56
|
+
directives.push(...result.directives);
|
|
57
|
+
}
|
|
58
|
+
return { ...block, text: result.next };
|
|
59
|
+
}
|
|
60
|
+
return part;
|
|
61
|
+
});
|
|
62
|
+
return { directives, next };
|
|
63
|
+
}
|
|
64
|
+
return { directives: [], next: content };
|
|
65
|
+
}
|
|
66
|
+
export function stripClockClearDirectiveFromContent(content) {
|
|
67
|
+
if (typeof content === 'string') {
|
|
68
|
+
const { hadClear, next } = stripClockClearDirectiveFromText(content);
|
|
69
|
+
return { hadClear, next };
|
|
70
|
+
}
|
|
71
|
+
if (Array.isArray(content)) {
|
|
72
|
+
let hadClear = false;
|
|
73
|
+
const next = content.map((part) => {
|
|
74
|
+
if (typeof part === 'string') {
|
|
75
|
+
const stripped = stripClockClearDirectiveFromText(part);
|
|
76
|
+
if (stripped.hadClear) {
|
|
77
|
+
hadClear = true;
|
|
78
|
+
}
|
|
79
|
+
return stripped.next;
|
|
80
|
+
}
|
|
81
|
+
if (part && typeof part === 'object' && !Array.isArray(part)) {
|
|
82
|
+
const block = part;
|
|
83
|
+
const text = typeof block.text === 'string' ? block.text : undefined;
|
|
84
|
+
if (!text) {
|
|
85
|
+
return part;
|
|
86
|
+
}
|
|
87
|
+
const stripped = stripClockClearDirectiveFromText(text);
|
|
88
|
+
if (stripped.hadClear) {
|
|
89
|
+
hadClear = true;
|
|
90
|
+
}
|
|
91
|
+
return { ...block, text: stripped.next };
|
|
92
|
+
}
|
|
93
|
+
return part;
|
|
94
|
+
});
|
|
95
|
+
return { hadClear, next };
|
|
96
|
+
}
|
|
97
|
+
return { hadClear: false, next: content };
|
|
98
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { StandardizedMessage } from '../types/standardized.js';
|
|
2
|
+
import { type ClockScheduleDirective } from './chat-process-clock-directives.js';
|
|
3
|
+
export interface ClockReminderDirectiveExtraction {
|
|
4
|
+
hadClear: boolean;
|
|
5
|
+
clockScheduleDirectives: ClockScheduleDirective[];
|
|
6
|
+
baseMessages: StandardizedMessage[];
|
|
7
|
+
}
|
|
8
|
+
export declare function extractClockReminderDirectives(messages: StandardizedMessage[]): ClockReminderDirectiveExtraction;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { findLastUserMessageIndex } from './chat-process-clock-reminder-messages.js';
|
|
2
|
+
import { extractClockReminderDirectivesWithNative } from '../../../router/virtual-router/engine-selection/native-chat-process-clock-reminder-directives.js';
|
|
3
|
+
import { hydrateClockScheduleDirectiveCandidate } from './chat-process-clock-directive-parser.js';
|
|
4
|
+
function resolveDirectivesFromCandidates(candidates) {
|
|
5
|
+
const directives = [];
|
|
6
|
+
let hasInvalid = false;
|
|
7
|
+
for (const candidate of candidates) {
|
|
8
|
+
const parsed = hydrateClockScheduleDirectiveCandidate(candidate);
|
|
9
|
+
if (parsed) {
|
|
10
|
+
directives.push(parsed);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
hasInvalid = true;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return { directives, hasInvalid };
|
|
17
|
+
}
|
|
18
|
+
function mergeResolvedBaseMessagesPreservingReferences(original, resolvedBaseMessages) {
|
|
19
|
+
const lastUserIdx = findLastUserMessageIndex(original);
|
|
20
|
+
const merged = original.slice();
|
|
21
|
+
if (lastUserIdx >= 0) {
|
|
22
|
+
const current = original[lastUserIdx];
|
|
23
|
+
const resolved = resolvedBaseMessages[lastUserIdx];
|
|
24
|
+
if (current && resolved) {
|
|
25
|
+
merged[lastUserIdx] = { ...current, content: resolved.content };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return merged;
|
|
29
|
+
}
|
|
30
|
+
export function extractClockReminderDirectives(messages) {
|
|
31
|
+
const resolved = extractClockReminderDirectivesWithNative(messages);
|
|
32
|
+
const resolvedDirectives = resolveDirectivesFromCandidates(resolved.directiveCandidates);
|
|
33
|
+
const hasInvalidCandidate = resolvedDirectives.hasInvalid;
|
|
34
|
+
const shouldKeepOriginalMessages = hasInvalidCandidate;
|
|
35
|
+
return {
|
|
36
|
+
hadClear: shouldKeepOriginalMessages ? false : resolved.hadClear,
|
|
37
|
+
clockScheduleDirectives: shouldKeepOriginalMessages ? [] : resolvedDirectives.directives,
|
|
38
|
+
baseMessages: shouldKeepOriginalMessages
|
|
39
|
+
? messages
|
|
40
|
+
: mergeResolvedBaseMessagesPreservingReferences(messages, resolved.baseMessages)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { StandardizedMessage, StandardizedRequest } from '../types/standardized.js';
|
|
2
|
+
export declare function buildDueReminderUserMessage(reservation: unknown, dueInjectText: string): StandardizedMessage | null;
|
|
3
|
+
export declare function buildClockReminderMetadata(options: {
|
|
4
|
+
nextRequest: StandardizedRequest;
|
|
5
|
+
metadata: Record<string, unknown>;
|
|
6
|
+
dueUserMessage: StandardizedMessage | null;
|
|
7
|
+
reservation: unknown;
|
|
8
|
+
}): StandardizedRequest['metadata'];
|
|
9
|
+
export declare function buildClockReminderMessages(options: {
|
|
10
|
+
baseMessages: StandardizedMessage[];
|
|
11
|
+
markerToolMessages: StandardizedMessage[];
|
|
12
|
+
dueUserMessage: StandardizedMessage | null;
|
|
13
|
+
timeTagLine: string;
|
|
14
|
+
}): StandardizedMessage[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { buildClockReminderMessagesWithNative, buildClockReminderMetadataWithNative, buildDueReminderUserMessageWithNative } from '../../../router/virtual-router/engine-selection/native-chat-process-clock-reminder-semantics.js';
|
|
2
|
+
export function buildDueReminderUserMessage(reservation, dueInjectText) {
|
|
3
|
+
return buildDueReminderUserMessageWithNative(reservation, dueInjectText);
|
|
4
|
+
}
|
|
5
|
+
export function buildClockReminderMetadata(options) {
|
|
6
|
+
return buildClockReminderMetadataWithNative(options.nextRequest.metadata, options.metadata, options.dueUserMessage, options.reservation);
|
|
7
|
+
}
|
|
8
|
+
export function buildClockReminderMessages(options) {
|
|
9
|
+
return buildClockReminderMessagesWithNative(options.baseMessages, options.markerToolMessages, options.dueUserMessage, options.timeTagLine);
|
|
10
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { StandardizedMessage } from '../types/standardized.js';
|
|
2
|
+
import type { ClockScheduleDirective } from './chat-process-clock-directives.js';
|
|
3
|
+
export declare function buildClockMarkerScheduleMessages(requestId: string, markerIndex: number, marker: ClockScheduleDirective, payload: Record<string, unknown>): StandardizedMessage[];
|
|
4
|
+
export declare function findLastUserMessageIndex(messages: StandardizedMessage[]): number;
|
|
5
|
+
export declare function injectTimeTagIntoMessages(messages: StandardizedMessage[], timeTagLine: string): StandardizedMessage[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { buildClockMarkerScheduleMessagesWithNative, findLastUserMessageIndexWithNative, injectTimeTagIntoMessagesWithNative } from '../../../router/virtual-router/engine-selection/native-chat-process-clock-reminder-semantics.js';
|
|
2
|
+
export function buildClockMarkerScheduleMessages(requestId, markerIndex, marker, payload) {
|
|
3
|
+
return buildClockMarkerScheduleMessagesWithNative(requestId, markerIndex, marker, payload);
|
|
4
|
+
}
|
|
5
|
+
export function findLastUserMessageIndex(messages) {
|
|
6
|
+
return findLastUserMessageIndexWithNative(messages);
|
|
7
|
+
}
|
|
8
|
+
export function injectTimeTagIntoMessages(messages, timeTagLine) {
|
|
9
|
+
return injectTimeTagIntoMessagesWithNative(messages, timeTagLine);
|
|
10
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { logClock } from '../../../servertool/clock/log.js';
|
|
2
|
+
import { reserveDueTasksForRequest, scheduleClockTasks, type ClockConfigSnapshot, type ClockReservation } from '../../../servertool/clock/task-store.js';
|
|
3
|
+
import type { StandardizedMessage } from '../types/standardized.js';
|
|
4
|
+
import type { ClockScheduleDirective } from './chat-process-clock-directives.js';
|
|
5
|
+
import { buildClockMarkerScheduleMessages } from './chat-process-clock-reminder-messages.js';
|
|
6
|
+
type ClockReminderSchedulingDeps = {
|
|
7
|
+
nowFn?: () => number;
|
|
8
|
+
logClockFn?: typeof logClock;
|
|
9
|
+
scheduleClockTasksFn?: typeof scheduleClockTasks;
|
|
10
|
+
buildClockMarkerScheduleMessagesFn?: typeof buildClockMarkerScheduleMessages;
|
|
11
|
+
};
|
|
12
|
+
type ClockReminderReservationDeps = {
|
|
13
|
+
reserveDueTasksForRequestFn?: typeof reserveDueTasksForRequest;
|
|
14
|
+
};
|
|
15
|
+
export declare function scheduleClockReminderDirectiveMessages(options: {
|
|
16
|
+
clockScheduleDirectives: ClockScheduleDirective[];
|
|
17
|
+
sessionId: string | null;
|
|
18
|
+
requestId: string;
|
|
19
|
+
clockConfig: ClockConfigSnapshot;
|
|
20
|
+
}, deps?: ClockReminderSchedulingDeps): Promise<StandardizedMessage[]>;
|
|
21
|
+
export declare function reserveClockDueReminderForRequest(options: {
|
|
22
|
+
hadClear: boolean;
|
|
23
|
+
sessionId: string | null;
|
|
24
|
+
requestId: string;
|
|
25
|
+
clockConfig: ClockConfigSnapshot;
|
|
26
|
+
}, deps?: ClockReminderReservationDeps): Promise<{
|
|
27
|
+
reservation: ClockReservation | null;
|
|
28
|
+
dueInjectText: string;
|
|
29
|
+
}>;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { logClock } from '../../../servertool/clock/log.js';
|
|
2
|
+
import { reserveDueTasksForRequest, scheduleClockTasks } from '../../../servertool/clock/task-store.js';
|
|
3
|
+
import { buildClockMarkerScheduleMessages } from './chat-process-clock-reminder-messages.js';
|
|
4
|
+
import { buildGuardedClockScheduleItemWithNative, normalizeDueInjectTextWithNative, shouldReserveClockDueReminderWithNative } from '../../../router/virtual-router/engine-selection/native-chat-process-clock-reminder-orchestration-semantics.js';
|
|
5
|
+
export async function scheduleClockReminderDirectiveMessages(options, deps = {}) {
|
|
6
|
+
const nowFn = deps.nowFn ?? Date.now;
|
|
7
|
+
const logClockFn = deps.logClockFn ?? logClock;
|
|
8
|
+
const scheduleClockTasksFn = deps.scheduleClockTasksFn ?? scheduleClockTasks;
|
|
9
|
+
const buildMessagesFn = deps.buildClockMarkerScheduleMessagesFn ?? buildClockMarkerScheduleMessages;
|
|
10
|
+
let markerToolMessages = [];
|
|
11
|
+
for (let index = 0; index < options.clockScheduleDirectives.length; index += 1) {
|
|
12
|
+
const marker = options.clockScheduleDirectives[index];
|
|
13
|
+
const now = nowFn();
|
|
14
|
+
const guardedItem = buildGuardedClockScheduleItemWithNative(marker, options.requestId, Number(options.clockConfig.dueWindowMs), Number(now));
|
|
15
|
+
if (!options.sessionId) {
|
|
16
|
+
markerToolMessages = markerToolMessages.concat(buildMessagesFn(options.requestId, index, marker, {
|
|
17
|
+
ok: false,
|
|
18
|
+
action: 'schedule',
|
|
19
|
+
message: 'clock requires tmux session scope (clientTmuxSessionId/tmuxSessionId).'
|
|
20
|
+
}));
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const scheduled = await scheduleClockTasksFn(options.sessionId, [guardedItem], options.clockConfig);
|
|
25
|
+
markerToolMessages = markerToolMessages.concat(buildMessagesFn(options.requestId, index, marker, {
|
|
26
|
+
ok: true,
|
|
27
|
+
action: 'schedule',
|
|
28
|
+
scheduled: scheduled.map((entry) => ({
|
|
29
|
+
taskId: entry.taskId,
|
|
30
|
+
dueAt: new Date(entry.dueAtMs).toISOString(),
|
|
31
|
+
task: entry.task,
|
|
32
|
+
deliveryCount: entry.deliveryCount
|
|
33
|
+
}))
|
|
34
|
+
}));
|
|
35
|
+
logClockFn('schedule', { sessionId: options.sessionId, count: scheduled.length, source: 'marker' });
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
markerToolMessages = markerToolMessages.concat(buildMessagesFn(options.requestId, index, marker, {
|
|
39
|
+
ok: false,
|
|
40
|
+
action: 'schedule',
|
|
41
|
+
message: `clock.schedule failed: ${error instanceof Error ? error.message : String(error ?? 'unknown')}`
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return markerToolMessages;
|
|
46
|
+
}
|
|
47
|
+
export async function reserveClockDueReminderForRequest(options, deps = {}) {
|
|
48
|
+
const shouldReserve = shouldReserveClockDueReminderWithNative(options.hadClear, options.sessionId);
|
|
49
|
+
if (!shouldReserve) {
|
|
50
|
+
return { reservation: null, dueInjectText: '' };
|
|
51
|
+
}
|
|
52
|
+
const reserveDueTasksForRequestFn = deps.reserveDueTasksForRequestFn ?? reserveDueTasksForRequest;
|
|
53
|
+
try {
|
|
54
|
+
const reserved = await reserveDueTasksForRequestFn({
|
|
55
|
+
reservationId: `${options.requestId}:clock`,
|
|
56
|
+
sessionId: options.sessionId,
|
|
57
|
+
config: options.clockConfig,
|
|
58
|
+
requestId: options.requestId
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
reservation: reserved.reservation,
|
|
62
|
+
dueInjectText: normalizeDueInjectTextWithNative(reserved.injectText)
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return { reservation: null, dueInjectText: '' };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { buildTimeTagLine, getClockTimeSnapshot } from '../../../servertool/clock/ntp.js';
|
|
2
|
+
export declare const CLOCK_TIME_TAG_FALLBACK_LINE = "[Time/Date]: utc=`1970-01-01T00:00:00.000Z` local=`1970-01-01 00:00:00.000 +00:00` tz=`unknown` nowMs=`0` ntpOffsetMs=`0`";
|
|
3
|
+
type ClockReminderTimeTagDeps = {
|
|
4
|
+
getClockTimeSnapshotFn?: typeof getClockTimeSnapshot;
|
|
5
|
+
buildTimeTagLineFn?: typeof buildTimeTagLine;
|
|
6
|
+
fallbackLine?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function resolveClockReminderTimeTagLine(deps?: ClockReminderTimeTagDeps): Promise<string>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { buildTimeTagLine, getClockTimeSnapshot } from '../../../servertool/clock/ntp.js';
|
|
2
|
+
import { resolveClockTimeTagFallbackLineWithNative } from '../../../router/virtual-router/engine-selection/native-chat-process-clock-reminder-time-tag-semantics.js';
|
|
3
|
+
export const CLOCK_TIME_TAG_FALLBACK_LINE = '[Time/Date]: utc=`1970-01-01T00:00:00.000Z` local=`1970-01-01 00:00:00.000 +00:00` tz=`unknown` nowMs=`0` ntpOffsetMs=`0`';
|
|
4
|
+
export async function resolveClockReminderTimeTagLine(deps = {}) {
|
|
5
|
+
const getClockTimeSnapshotFn = deps.getClockTimeSnapshotFn ?? getClockTimeSnapshot;
|
|
6
|
+
const buildTimeTagLineFn = deps.buildTimeTagLineFn ?? buildTimeTagLine;
|
|
7
|
+
const fallbackLine = resolveClockTimeTagFallbackLineWithNative(deps.fallbackLine, CLOCK_TIME_TAG_FALLBACK_LINE);
|
|
8
|
+
try {
|
|
9
|
+
const snapshot = await getClockTimeSnapshotFn();
|
|
10
|
+
if (snapshot) {
|
|
11
|
+
return buildTimeTagLineFn(snapshot);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
// best-effort
|
|
16
|
+
}
|
|
17
|
+
return fallbackLine;
|
|
18
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { readRuntimeMetadata } from '../../shared/runtime-metadata.js';
|
|
2
|
+
import { clearClockSession, resolveClockConfig, startClockDaemonIfNeeded } from '../../../servertool/clock/task-store.js';
|
|
3
|
+
import { logClock } from '../../../servertool/clock/log.js';
|
|
4
|
+
import { resolveClockSessionScope } from '../../../servertool/clock/session-scope.js';
|
|
5
|
+
import { applyHubOperations } from '../ops/operations.js';
|
|
6
|
+
import { buildClockStandardToolsOperations } from './chat-process-clock-tools.js';
|
|
7
|
+
import { reserveClockDueReminderForRequest, scheduleClockReminderDirectiveMessages } from './chat-process-clock-reminder-orchestration.js';
|
|
8
|
+
import { buildClockReminderMessages, buildClockReminderMetadata, buildDueReminderUserMessage } from './chat-process-clock-reminder-finalize.js';
|
|
9
|
+
import { resolveClockReminderTimeTagLine } from './chat-process-clock-reminder-time-tag.js';
|
|
10
|
+
import { extractClockReminderDirectives } from './chat-process-clock-reminder-directives.js';
|
|
11
|
+
import { isClientInjectReady } from './client-inject-readiness.js';
|
|
12
|
+
import { resolveClockReminderFlowPlanWithNative } from '../../../router/virtual-router/engine-selection/native-chat-process-clock-reminders-semantics.js';
|
|
13
|
+
function resolveSessionIdForClock(metadata, request) {
|
|
14
|
+
const requestMetadata = request.metadata && typeof request.metadata === 'object' && !Array.isArray(request.metadata)
|
|
15
|
+
? request.metadata
|
|
16
|
+
: null;
|
|
17
|
+
return resolveClockSessionScope(metadata, requestMetadata);
|
|
18
|
+
}
|
|
19
|
+
export async function maybeInjectClockRemindersAndApplyDirectives(request, metadata, requestId) {
|
|
20
|
+
if (!isClientInjectReady(metadata)) {
|
|
21
|
+
return request;
|
|
22
|
+
}
|
|
23
|
+
const rt = readRuntimeMetadata(metadata);
|
|
24
|
+
const flowPlan = resolveClockReminderFlowPlanWithNative(rt);
|
|
25
|
+
// Do not inject reminders or apply clock directives during internal servertool followup hops.
|
|
26
|
+
if (flowPlan.skipForServerToolFollowup) {
|
|
27
|
+
return request;
|
|
28
|
+
}
|
|
29
|
+
const rawConfig = rt?.clock;
|
|
30
|
+
const clockConfig = resolveClockConfig(rawConfig);
|
|
31
|
+
if (!clockConfig) {
|
|
32
|
+
return request;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
await startClockDaemonIfNeeded(clockConfig);
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
// best-effort
|
|
39
|
+
}
|
|
40
|
+
const sessionId = resolveSessionIdForClock(metadata, request);
|
|
41
|
+
const messages = Array.isArray(request.messages) ? request.messages : [];
|
|
42
|
+
// 1) Apply <**clock:clear**> and <**clock:{...}**> marker extraction (latest user message only).
|
|
43
|
+
const { hadClear, clockScheduleDirectives, baseMessages } = extractClockReminderDirectives(messages);
|
|
44
|
+
if (hadClear) {
|
|
45
|
+
if (sessionId) {
|
|
46
|
+
try {
|
|
47
|
+
await clearClockSession(sessionId);
|
|
48
|
+
logClock('cleared', { sessionId });
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// best-effort: user directive should not crash request
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Continue: still inject per-request time tag (but skip due reminders).
|
|
55
|
+
}
|
|
56
|
+
// 2) Apply private schedule directives: <**clock:{time,message}**>
|
|
57
|
+
// Convert to actual clock scheduling and append synthetic tool_call/tool_result messages
|
|
58
|
+
// so downstream model sees canonical tool semantics.
|
|
59
|
+
const markerToolMessages = await scheduleClockReminderDirectiveMessages({
|
|
60
|
+
clockScheduleDirectives,
|
|
61
|
+
sessionId,
|
|
62
|
+
requestId,
|
|
63
|
+
clockConfig
|
|
64
|
+
});
|
|
65
|
+
// 3) Inject due reminders as a user message + attach reservation for response-side commit.
|
|
66
|
+
const { reservation, dueInjectText } = await reserveClockDueReminderForRequest({
|
|
67
|
+
hadClear,
|
|
68
|
+
sessionId,
|
|
69
|
+
requestId,
|
|
70
|
+
clockConfig
|
|
71
|
+
});
|
|
72
|
+
const dueUserMessage = buildDueReminderUserMessage(reservation, dueInjectText);
|
|
73
|
+
// 4) When we have due tasks, ensure a standard tool set is present (best-effort).
|
|
74
|
+
let nextRequest = request;
|
|
75
|
+
if (dueUserMessage) {
|
|
76
|
+
const ensureToolsOps = buildClockStandardToolsOperations();
|
|
77
|
+
nextRequest = applyHubOperations(nextRequest, ensureToolsOps);
|
|
78
|
+
}
|
|
79
|
+
// 5) Per-request time injection (user time tag or paired clock.get tool result).
|
|
80
|
+
const timeTagLine = await resolveClockReminderTimeTagLine();
|
|
81
|
+
const withReservationMetadata = buildClockReminderMetadata({
|
|
82
|
+
nextRequest,
|
|
83
|
+
metadata,
|
|
84
|
+
dueUserMessage,
|
|
85
|
+
reservation
|
|
86
|
+
});
|
|
87
|
+
// Always inject time via user-role content to keep the tag visible without adding
|
|
88
|
+
// extra tool-call semantics that may distract the model.
|
|
89
|
+
//
|
|
90
|
+
// IMPORTANT: do not append an extra trailing user message, otherwise the Virtual Router
|
|
91
|
+
// sees `latestMessageFromUser=true` and will force "thinking:user-input" even during
|
|
92
|
+
// tool followups (last message role=tool), which breaks `coding/search/tools` routing.
|
|
93
|
+
const timeInjectedMessages = buildClockReminderMessages({
|
|
94
|
+
baseMessages,
|
|
95
|
+
markerToolMessages,
|
|
96
|
+
dueUserMessage,
|
|
97
|
+
timeTagLine
|
|
98
|
+
});
|
|
99
|
+
return {
|
|
100
|
+
...nextRequest,
|
|
101
|
+
messages: timeInjectedMessages,
|
|
102
|
+
metadata: withReservationMetadata
|
|
103
|
+
};
|
|
104
|
+
}
|