blun-king-cli 9.1.586 → 9.1.588
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/CHANGELOG.md +11 -178
- package/LIESMICH.txt +51 -13
- package/README.md +44 -47
- package/agent-spine-plugin/.codex-plugin/plugin.json +16 -4
- package/agent-spine-plugin/CHANGELOG.md +37 -5
- package/agent-spine-plugin/README.md +3 -3
- package/agent-spine-plugin/blun.plugin.json +45 -10
- package/agent-spine-plugin/docs/artifact-evaluation.md +93 -0
- package/agent-spine-plugin/docs/host-integration.md +42 -27
- package/agent-spine-plugin/docs/preflight-recall.md +4 -2
- package/agent-spine-plugin/docs/session-timeline.md +97 -236
- package/agent-spine-plugin/docs/world-model.md +25 -0
- package/agent-spine-plugin/hooks/codex.json +1 -1
- package/agent-spine-plugin/hooks/hooks.json +1 -1
- package/agent-spine-plugin/package.json +1 -3
- package/agent-spine-plugin/scripts/check-hosts.js +3 -3
- package/agent-spine-plugin/scripts/release-check.js +10 -5
- package/agent-spine-plugin/scripts/run-checks.js +4 -1
- package/agent-spine-plugin/scripts/run-tests-hermetic.js +32 -6
- package/agent-spine-plugin/src/cli-learning.js +15 -0
- package/agent-spine-plugin/src/cli.js +2 -0
- package/agent-spine-plugin/src/hook.js +32 -32
- package/agent-spine-plugin/src/lib/action-lesson-recall.js +73 -8
- package/agent-spine-plugin/src/lib/briefing.js +146 -36
- package/agent-spine-plugin/src/lib/channel-continuity.js +19 -0
- package/agent-spine-plugin/src/lib/delivery-agent-usage.js +14 -7
- package/agent-spine-plugin/src/lib/gateway-group-response.js +128 -0
- package/agent-spine-plugin/src/lib/gateway-runs.js +24 -15
- package/agent-spine-plugin/src/lib/hook-briefing-use.js +13 -3
- package/agent-spine-plugin/src/lib/hook-context.js +16 -3
- package/agent-spine-plugin/src/lib/hook-output.js +129 -5
- package/agent-spine-plugin/src/lib/hook-timeline.js +5 -3
- package/agent-spine-plugin/src/lib/indexed-memory.js +2 -2
- package/agent-spine-plugin/src/lib/learning-artifact-evaluator.js +114 -0
- package/agent-spine-plugin/src/lib/learning-context.js +11 -4
- package/agent-spine-plugin/src/lib/learning-measurements.js +2 -2
- package/agent-spine-plugin/src/lib/mcp-runtime.js +89 -3
- package/agent-spine-plugin/src/lib/mcp-source-context.js +12 -2
- package/agent-spine-plugin/src/lib/mcp-timeline-tools.js +91 -8
- package/agent-spine-plugin/src/lib/mcp-world-tools.js +2 -2
- package/agent-spine-plugin/src/lib/owned-file-lock.js +20 -1
- package/agent-spine-plugin/src/lib/persona-runtime.js +2 -2
- package/agent-spine-plugin/src/lib/preflight-delivery-id.js +27 -0
- package/agent-spine-plugin/src/lib/preflight.js +4 -4
- package/agent-spine-plugin/src/lib/session-timeline-codex.js +15 -0
- package/agent-spine-plugin/src/lib/session-timeline-contract.js +12 -4
- package/agent-spine-plugin/src/lib/session-timeline-event-extract.js +36 -7
- package/agent-spine-plugin/src/lib/session-timeline-host-origin.js +13 -10
- package/agent-spine-plugin/src/lib/session-timeline-invocation.js +1 -1
- package/agent-spine-plugin/src/lib/session-timeline-king.js +14 -0
- package/agent-spine-plugin/src/lib/session-timeline-prior.js +18 -12
- package/agent-spine-plugin/src/lib/session-timeline-provider.js +5 -0
- package/agent-spine-plugin/src/lib/session-timeline-query.js +2 -0
- package/agent-spine-plugin/src/lib/session-timeline-results.js +35 -10
- package/agent-spine-plugin/src/lib/session-timeline-source-open.js +30 -0
- package/agent-spine-plugin/src/lib/session-timeline.js +122 -75
- package/agent-spine-plugin/src/lib/source-roots.js +3 -2
- package/agent-spine-plugin/src/lib/task-knowledge-context.js +22 -1
- package/agent-spine-plugin/src/lib/timeline-continuation-update.js +100 -0
- package/agent-spine-plugin/src/lib/timeline-tool-guard.js +30 -7
- package/agent-spine-plugin/src/lib/timeline-user-feedback.js +217 -0
- package/agent-spine-plugin/src/lib/timeline-world-capture.js +233 -0
- package/agent-spine-plugin/src/lib/world-knowledge.js +59 -2
- package/agent-spine-plugin/src/lib/world-model.js +64 -9
- package/agent-spine-plugin/src/worker.js +13 -1
- package/bin/blun.js +43 -28
- package/bin/core-bootstrap.js +5 -4
- package/bin/king.js +43 -28
- package/bin/launcher-mode.js +1 -10
- package/bin/launcher-runtime.js +128 -295
- package/bin/managed-node.js +0 -0
- package/bin/managed-plugin-selection.cjs +0 -1
- package/bin/native-module-repair.js +0 -0
- package/bin/node-runtime.js +0 -0
- package/bin/node-version.js +0 -0
- package/bin/plugin-bootstrap.js +56 -120
- package/bin/private-paths.js +11 -34
- package/bin/standard-tools-bootstrap.js +34 -114
- package/bin/turn-thinking-policy.cjs +3 -11
- package/bin/update-copy.js +200 -0
- package/bin/update-lease.js +0 -0
- package/bin/update-notice.js +136 -289
- package/bin/verify-agent-behavior.cjs +122 -0
- package/bin/verify-agent-components.cjs +104 -0
- package/bin/verify-bundled-agent-sources.cjs +57 -0
- package/blun.mjs +143078 -135241
- package/bundled-agent-sources.json +701 -0
- package/package.json +12 -15
- package/standard-skills/translate-native/README.md +1293 -0
- package/standard-skills/translate-native/SKILL.md +172 -22
- package/standard-skills/translate-native/VERSION +1 -1
- package/standard-skills/translate-native/agents/openai.yaml +18 -0
- package/standard-skills/translate-native/assets/icon.svg +8 -0
- package/standard-skills/translate-native/docs/BLUN_CODE_INTEGRATION.md +76 -0
- package/standard-skills/translate-native/docs/PREMORTEM.md +489 -0
- package/standard-skills/translate-native/docs/WEBSITE_LOCALIZATION.md +2035 -0
- package/standard-skills/translate-native/docs/WEBSITE_LOCALIZATION_API.md +1302 -0
- package/standard-skills/translate-native/docs/WEBSITE_LOCALIZATION_EVIDENCE_HTTP.md +136 -0
- package/standard-skills/translate-native/docs/WEBSITE_LOCALIZATION_HEALTH_HTTP.md +130 -0
- package/standard-skills/translate-native/docs/WEBSITE_LOCALIZATION_HTTP_PROVIDER.md +175 -0
- package/standard-skills/translate-native/docs/WEBSITE_LOCALIZATION_RECEIPT_VERIFIER_HTTP.md +86 -0
- package/standard-skills/translate-native/integrations/AGENT_RULES.md +32 -0
- package/standard-skills/translate-native/integrations/adapters/blun-code-language-guard.js +514 -0
- package/standard-skills/translate-native/integrations/adapters/node-language-guard.js +230 -0
- package/standard-skills/translate-native/integrations/audit_log.py +327 -0
- package/standard-skills/translate-native/integrations/claude_language_hook.js +1536 -0
- package/standard-skills/translate-native/integrations/commercial_localization_profile.py +42 -0
- package/standard-skills/translate-native/integrations/delivery-policy.example.json +28 -0
- package/standard-skills/translate-native/integrations/enforced_delivery.py +543 -0
- package/standard-skills/translate-native/integrations/guard_service.py +435 -0
- package/standard-skills/translate-native/integrations/language_gateway.py +67 -0
- package/standard-skills/translate-native/integrations/mcp_auth_headers.py +198 -0
- package/standard-skills/translate-native/integrations/mcp_http_gateway.py +429 -0
- package/standard-skills/translate-native/integrations/non_language_html_entities.js +1485 -0
- package/standard-skills/translate-native/integrations/pre_output_guard.py +65 -0
- package/standard-skills/translate-native/integrations/task_router.py +101 -0
- package/standard-skills/translate-native/integrations/website_localization.py +401 -0
- package/standard-skills/translate-native/integrations/website_localization_api.py +581 -0
- package/standard-skills/translate-native/integrations/website_localization_benchmark.py +1885 -0
- package/standard-skills/translate-native/integrations/website_localization_benchmark_campaign.py +1772 -0
- package/standard-skills/translate-native/integrations/website_localization_benchmark_candidate.py +506 -0
- package/standard-skills/translate-native/integrations/website_localization_benchmark_http.py +400 -0
- package/standard-skills/translate-native/integrations/website_localization_benchmark_review_store.py +781 -0
- package/standard-skills/translate-native/integrations/website_localization_benchmark_reviewer_http.py +500 -0
- package/standard-skills/translate-native/integrations/website_localization_benchmark_runtime.py +1107 -0
- package/standard-skills/translate-native/integrations/website_localization_benchmark_suite.py +463 -0
- package/standard-skills/translate-native/integrations/website_localization_cms.py +2835 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_client.py +875 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_dispatch.py +805 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_http.py +588 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_lifecycle_monitor.py +991 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_receiver.py +1441 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_receiver_runtime.py +414 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_receiver_store.py +1073 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_removal_dispatch.py +865 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_source_client.py +583 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_source_delivery.py +964 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_source_delivery_runtime.py +665 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_source_http.py +1153 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_source_runtime.py +675 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_source_service.py +1125 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_terminal_notification.py +674 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_terminal_notification_http.py +444 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_terminal_notification_receiver.py +1469 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_terminal_notification_receiver_runtime.py +1142 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_terminal_processing_monitor.py +634 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_terminal_receiver_client.py +804 -0
- package/standard-skills/translate-native/integrations/website_localization_deepl_baseline.py +922 -0
- package/standard-skills/translate-native/integrations/website_localization_evidence_http.py +482 -0
- package/standard-skills/translate-native/integrations/website_localization_health.py +1541 -0
- package/standard-skills/translate-native/integrations/website_localization_health_http.py +372 -0
- package/standard-skills/translate-native/integrations/website_localization_http_provider.py +297 -0
- package/standard-skills/translate-native/integrations/website_localization_native_reference_http.py +479 -0
- package/standard-skills/translate-native/integrations/website_localization_native_reference_intake.py +363 -0
- package/standard-skills/translate-native/integrations/website_localization_native_reference_queue.py +1449 -0
- package/standard-skills/translate-native/integrations/website_localization_native_reference_store.py +420 -0
- package/standard-skills/translate-native/integrations/website_localization_quality_profiles.py +235 -0
- package/standard-skills/translate-native/integrations/website_localization_queue.py +671 -0
- package/standard-skills/translate-native/integrations/website_localization_receipt_verifier_http.py +516 -0
- package/standard-skills/translate-native/integrations/website_localization_release.py +928 -0
- package/standard-skills/translate-native/integrations/website_localization_release_coordinator.py +1008 -0
- package/standard-skills/translate-native/integrations/website_localization_runner.py +276 -0
- package/standard-skills/translate-native/integrations/website_localization_runtime.py +862 -0
- package/standard-skills/translate-native/integrations/website_localization_service.py +350 -0
- package/standard-skills/translate-native/integrations/website_localization_supervisor.py +511 -0
- package/standard-skills/translate-native/integrations/website_localization_worker.py +663 -0
- package/standard-skills/translate-native/provenance.json +3 -4
- package/standard-skills/translate-native/references/commercial-localization.md +177 -0
- package/standard-skills/translate-native/scripts/blun_language_guard.py +7 -1
- package/standard-skills/translate-native/scripts/check_commercial_review.py +80 -0
- package/standard-skills/translate-native/scripts/commercial_localization_profile.py +333 -0
- package/standard-tools/language-guard/LICENSE +21 -0
- package/standard-tools/language-guard/VERSION +1 -0
- package/standard-tools/language-guard/blun_language_guard.py +7 -1
- package/standard-tools/language-guard/check_commercial_review.py +80 -0
- package/standard-tools/language-guard/commercial_localization_profile.py +333 -0
- package/standard-tools/language-guard/language_gateway.py +62 -0
- package/standard-tools/language-guard/pre_output_guard.py +64 -0
- package/standard-tools/language-guard/provenance.json +4 -11
- package/standard-tools/manifest.json +34 -11
- package/telegram-plugin/commands/access.md +2 -10
- package/telegram-plugin/dist/bridge.mjs +64041 -687
- package/telegram-plugin/dist/mcp-server.mjs +72810 -9027
- package/telegram-plugin/dist/noise.mjs +28 -63511
- package/agent-spine-plugin/CONTRIBUTING.md +0 -52
- package/agent-spine-plugin/SECURITY.md +0 -47
- package/agent-spine-plugin/docs/assignment-continuation.md +0 -48
- package/agent-spine-plugin/docs/releasing.md +0 -85
- package/agent-spine-plugin/docs/structured-completion.md +0 -67
- package/bin/abort-listener-policy.cjs +0 -43
- package/bin/active-steer-priority-policy.cjs +0 -24
- package/bin/agent-api-http-adapter.mjs +0 -446
- package/bin/agent-api-private-http-server.mjs +0 -288
- package/bin/agent-api-runtime.mjs +0 -252
- package/bin/agent-api-service-environment.mjs +0 -236
- package/bin/agent-api-service-host.mjs +0 -209
- package/bin/agent-api-service-process.mjs +0 -171
- package/bin/agent-api-session-registry.mjs +0 -428
- package/bin/agent-api-tool-broker.cjs +0 -248
- package/bin/agent-api-turn-controller.mjs +0 -461
- package/bin/agent-api-usage-journal.cjs +0 -259
- package/bin/agent-resume-snapshot.cjs +0 -241
- package/bin/agentspine-king-goal-inbox.mjs +0 -111
- package/bin/agentspine-king-goal-intake.mjs +0 -106
- package/bin/approval-rejection-stop.cjs +0 -15
- package/bin/assistant-message-offload-policy.cjs +0 -284
- package/bin/baseline-skill-performance-policy.cjs +0 -39
- package/bin/bash-search-scope-policy.cjs +0 -49
- package/bin/codebase-search-runtime.cjs +0 -23
- package/bin/cognitive-action-checkpoint.cjs +0 -1104
- package/bin/cognitive-attention-delivery.cjs +0 -76
- package/bin/cognitive-attention-policy.cjs +0 -143
- package/bin/cognitive-attention-runtime.cjs +0 -91
- package/bin/cognitive-context-projection.cjs +0 -73
- package/bin/cognitive-cross-portal-acceptance.cjs +0 -443
- package/bin/cognitive-effective-view.cjs +0 -77
- package/bin/cognitive-focus-projection.cjs +0 -206
- package/bin/cognitive-focus-scope.cjs +0 -37
- package/bin/cognitive-goal-autostart-policy.cjs +0 -72
- package/bin/cognitive-goal-time-trigger-controller.cjs +0 -146
- package/bin/cognitive-memory-adapter.cjs +0 -282
- package/bin/cognitive-memory-command.cjs +0 -293
- package/bin/cognitive-memory-provider.cjs +0 -92
- package/bin/cognitive-salience-policy.cjs +0 -159
- package/bin/cognitive-state-store.cjs +0 -508
- package/bin/cognitive-turn-lifecycle.cjs +0 -624
- package/bin/cognitive-work-focus.cjs +0 -180
- package/bin/compaction-history-archive.cjs +0 -166
- package/bin/compaction-history-startup.cjs +0 -50
- package/bin/compaction-model-policy.cjs +0 -31
- package/bin/compaction-stage-policy.cjs +0 -21
- package/bin/compaction-transaction-policy.cjs +0 -122
- package/bin/config-write-dedup-policy.cjs +0 -27
- package/bin/context-budget-ledger.cjs +0 -31
- package/bin/context-doctor-policy.cjs +0 -70
- package/bin/context-insight-policy.cjs +0 -36
- package/bin/context-performance-policy.cjs +0 -15
- package/bin/context-pressure-policy.cjs +0 -20
- package/bin/cron-run-output.cjs +0 -45
- package/bin/cron-run-store.cjs +0 -145
- package/bin/curiosity-scout-policy.cjs +0 -49
- package/bin/default-model-output-budget-policy.cjs +0 -28
- package/bin/durable-task-resume-policy.cjs +0 -130
- package/bin/durable-task-resume-runtime.cjs +0 -117
- package/bin/durable-task-resume-store.cjs +0 -88
- package/bin/editable-tool-approval-policy.cjs +0 -540
- package/bin/editable-tool-approval-runtime.cjs +0 -99
- package/bin/effective-system-prompt-cache-policy.cjs +0 -33
- package/bin/error-memory-performance-policy.cjs +0 -113
- package/bin/file-observation-policy.cjs +0 -133
- package/bin/foreground-output-capture-policy.cjs +0 -41
- package/bin/generated-source-health.cjs +0 -142
- package/bin/glob-pattern-policy.cjs +0 -13
- package/bin/goal-completion-evidence-policy.cjs +0 -120
- package/bin/grep-output-limit-policy.cjs +0 -39
- package/bin/historical-media-projection-policy.cjs +0 -48
- package/bin/history-offload-pressure-policy.cjs +0 -33
- package/bin/html-to-research-markdown.cjs +0 -147
- package/bin/identity-context-policy.cjs +0 -764
- package/bin/identity-journal-policy.cjs +0 -107
- package/bin/input-draft-persistence.cjs +0 -77
- package/bin/king-tui-function-contract.json +0 -33
- package/bin/launcher-restart-policy.cjs +0 -150
- package/bin/live-response-repetition-guard.cjs +0 -196
- package/bin/llm-config-log-dedup-policy.cjs +0 -76
- package/bin/loop-event-record-policy.cjs +0 -174
- package/bin/managed-context-startup-policy.cjs +0 -27
- package/bin/media-activity-layout-policy.cjs +0 -34
- package/bin/media-auto-retrieval-policy.cjs +0 -90
- package/bin/media-result-policy.cjs +0 -59
- package/bin/micro-compaction-policy.cjs +0 -145
- package/bin/mistake-relevance-policy.cjs +0 -319
- package/bin/model-retry-progress-policy.cjs +0 -46
- package/bin/native-large-file-io.cjs +0 -42
- package/bin/native-runtime-cache.cjs +0 -76
- package/bin/natural-presence-policy.cjs +0 -28
- package/bin/noninteractive-shell-env-policy.cjs +0 -19
- package/bin/observer-hooks.cjs +0 -14
- package/bin/outbound-claim-provenance.cjs +0 -150
- package/bin/oversized-context-offload-policy.cjs +0 -86
- package/bin/pending-media-policy.cjs +0 -182
- package/bin/pending-token-estimate-policy.cjs +0 -41
- package/bin/personal-memory-consent-policy.cjs +0 -72
- package/bin/personal-memory-performance-policy.cjs +0 -12
- package/bin/personality-choice-policy.cjs +0 -101
- package/bin/personality-memory-adapter.cjs +0 -379
- package/bin/personality-mode.cjs +0 -46
- package/bin/personality-setup-policy.cjs +0 -197
- package/bin/proactive-compaction-policy.cjs +0 -25
- package/bin/profile-identity-resolution.cjs +0 -136
- package/bin/profile-runtime.cjs +0 -318
- package/bin/profile-tool-exclusion-policy.cjs +0 -37
- package/bin/programmatic-context-isolation.cjs +0 -25
- package/bin/programmatic-tool-runtime.mjs +0 -627
- package/bin/provider-idle-timeout-policy.cjs +0 -14
- package/bin/provider-model-refresh-deadline.cjs +0 -53
- package/bin/provider-model-refresh-policy.cjs +0 -107
- package/bin/rate-limit-recovery-policy.cjs +0 -47
- package/bin/read-batch-policy.cjs +0 -32
- package/bin/read-continuation-policy.cjs +0 -59
- package/bin/recurring-cron-history-policy.cjs +0 -124
- package/bin/relationship-continuity-policy.cjs +0 -143
- package/bin/relationship-curiosity-policy.cjs +0 -107
- package/bin/relationship-learning-policy.cjs +0 -168
- package/bin/release-artifact-freeze-policy.cjs +0 -30
- package/bin/reload-plugin-bootstrap.cjs +0 -18
- package/bin/reload-queue-policy.cjs +0 -38
- package/bin/repeated-assistant-response-policy.cjs +0 -232
- package/bin/repeated-injection-projection.cjs +0 -107
- package/bin/repeated-user-message-projection.cjs +0 -8
- package/bin/research-page-result.cjs +0 -74
- package/bin/retry-checkpoint-policy.cjs +0 -13
- package/bin/runtime-exit-ledger.cjs +0 -144
- package/bin/scoped-cron-run-policy.cjs +0 -358
- package/bin/session-checkpoint-policy.cjs +0 -25
- package/bin/session-compaction-policy.cjs +0 -84
- package/bin/session-replay-policy.cjs +0 -20
- package/bin/session-replay-window-policy.cjs +0 -40
- package/bin/session-resume-checkpoint.cjs +0 -254
- package/bin/session-scrollback-archive.cjs +0 -229
- package/bin/skill-activation-performance-policy.cjs +0 -69
- package/bin/skill-listing-performance-policy.cjs +0 -92
- package/bin/soul-organization-policy.cjs +0 -78
- package/bin/soul-preservation-policy.cjs +0 -20
- package/bin/startup-preferences.cjs +0 -131
- package/bin/streaming-flush-performance-policy.cjs +0 -28
- package/bin/structured-agent-swarm-output.cjs +0 -325
- package/bin/structured-subagent-output.cjs +0 -252
- package/bin/subagent-context-fork-policy.cjs +0 -155
- package/bin/subagent-max-tokens-handoff-policy.cjs +0 -69
- package/bin/subagent-parent-responsiveness.cjs +0 -19
- package/bin/subagent-skill-policy.cjs +0 -206
- package/bin/subagent-timeout-policy.cjs +0 -182
- package/bin/subagent-tool-policy.cjs +0 -60
- package/bin/subagent-usage-rollup-policy.cjs +0 -29
- package/bin/system-prompt-context-policy.cjs +0 -124
- package/bin/system-prompt-token-cache-policy.cjs +0 -60
- package/bin/telegram-addressed-focus.cjs +0 -55
- package/bin/telegram-addressed-priority.cjs +0 -12
- package/bin/telegram-approval-relay.cjs +0 -290
- package/bin/telegram-bot-priority.cjs +0 -17
- package/bin/telegram-console-status-policy.cjs +0 -174
- package/bin/telegram-context-projection-policy.cjs +0 -141
- package/bin/telegram-delivery-lifecycle.cjs +0 -125
- package/bin/telegram-direct-focus-policy.cjs +0 -273
- package/bin/telegram-mcp-compatibility.cjs +0 -49
- package/bin/telegram-media-delivery-policy.cjs +0 -42
- package/bin/telegram-private-conversation-policy.cjs +0 -185
- package/bin/telegram-queue-handoff-policy.cjs +0 -73
- package/bin/telegram-remote-status-policy.cjs +0 -120
- package/bin/telegram-session-queue-runtime.mjs +0 -306
- package/bin/telegram-text-chunk-policy.cjs +0 -63
- package/bin/telegram-truncated-reply-policy.cjs +0 -37
- package/bin/telegram-urgent-policy.cjs +0 -45
- package/bin/telemetry-spool-policy.cjs +0 -57
- package/bin/thinking-activity-status-policy.cjs +0 -132
- package/bin/thinking-only-guard.cjs +0 -79
- package/bin/todo-list-turn-policy.cjs +0 -131
- package/bin/tool-call-loop-policy.cjs +0 -51
- package/bin/tool-file-persistence.cjs +0 -141
- package/bin/tool-result-offload-policy.cjs +0 -359
- package/bin/tool-result-offload-telemetry.cjs +0 -12
- package/bin/tool-schema-token-cache-policy.cjs +0 -41
- package/bin/tool-stream-preview-policy.cjs +0 -9
- package/bin/tui-functional-contract.cjs +0 -55
- package/bin/turn-tool-performance-policy.cjs +0 -486
- package/bin/usage-cache-efficiency-policy.cjs +0 -26
- package/bin/user-home-path-policy.cjs +0 -13
- package/bin/user-message-offload-policy.cjs +0 -103
- package/bin/user-prompt-hook-origin-policy.cjs +0 -34
- package/bin/user-tool-record-policy.cjs +0 -7
- package/bin/validated-learning-insight-policy.cjs +0 -58
- package/bin/validated-learning-outcome-trace.cjs +0 -107
- package/bin/validated-learning-performance-policy.cjs +0 -53
- package/bin/validated-learning-signal.cjs +0 -463
- package/bin/windows-bash-dialect-policy.cjs +0 -25
- package/bin/windows-node-crash-dump.cjs +0 -110
- package/bin/write-continuation-policy.cjs +0 -69
- package/codebase-index/README.md +0 -82
- package/codebase-index/codebase_index.py +0 -470
- package/standard-skills/agent-browser/SKILL.md +0 -19
- package/standard-skills/agent-browser/references/runtime.md +0 -8
- package/standard-skills/blun-session-inspector/SKILL.md +0 -41
- package/standard-skills/blun-session-inspector/scripts/inspect-session.cjs +0 -437
- package/standard-skills/design-taste-frontend/SKILL.md +0 -1206
- package/standard-skills/full-output-enforcement/SKILL.md +0 -49
- package/standard-skills/high-end-visual-design/SKILL.md +0 -98
- package/standard-skills/image-to-code/SKILL.md +0 -1228
- package/standard-skills/industrial-brutalist-ui/SKILL.md +0 -92
- package/standard-skills/minimalist-ui/SKILL.md +0 -85
- package/standard-skills/motion-design-taste/SKILL.md +0 -74
- package/standard-skills/playwright-testing/SKILL.md +0 -19
- package/standard-skills/playwright-testing/references/runtime.md +0 -7
- package/standard-skills/premortem/SKILL.md +0 -148
- package/standard-skills/redesign-existing-projects/SKILL.md +0 -178
- package/standard-skills/research-evidence/SKILL.md +0 -39
- package/standard-skills/research-evidence/references/evidence-format.md +0 -104
- package/standard-skills/research-evidence/scripts/evidence-collection.cjs +0 -260
- package/standard-skills/research-evidence/scripts/score-report.cjs +0 -130
- package/standard-skills/screenshot-lesen/SKILL.md +0 -52
- package/standard-skills/stitch-design-taste/DESIGN.md +0 -121
- package/standard-skills/stitch-design-taste/SKILL.md +0 -184
- package/standard-skills/telegram-channel/SKILL.md +0 -18
- package/standard-skills/telegram-channel/references/runtime.md +0 -7
- package/standard-skills/venture-flywheel/SKILL.md +0 -32
- package/standard-skills/venture-flywheel/identity/project-identity.cjs +0 -146
- package/standard-skills/venture-flywheel/policy/capability-engine.cjs +0 -114
- package/standard-skills/venture-flywheel/policy/repository-trust.cjs +0 -229
- package/standard-skills/venture-flywheel/references/BEISPIELE-phase0.md +0 -146
- package/standard-skills/venture-flywheel/references/CAPABILITY-MAP.md +0 -34
- package/standard-skills/venture-flywheel/references/SPEC-phase0-identity-trust.md +0 -77
- package/standard-skills/venture-flywheel/references/SPEC-phase0-state-events.md +0 -93
- package/standard-skills/venture-flywheel/schemas/capability-decision.schema.json +0 -13
- package/standard-skills/venture-flywheel/schemas/execution-event.schema.json +0 -44
- package/standard-skills/venture-flywheel/schemas/project-identity.schema.json +0 -32
- package/standard-skills/venture-flywheel/schemas/repository-trust.schema.json +0 -57
- package/standard-skills/venture-flywheel/schemas/run-transition.schema.json +0 -59
- package/standard-skills/venture-flywheel/state/execution-event.cjs +0 -191
- package/standard-skills/venture-flywheel/state/task-state-machine.cjs +0 -190
- package/standard-skills/web-lesen/SKILL.md +0 -73
- package/standard-skills/web-lesen/scripts/crawl_public.py +0 -379
- package/standard-skills/windows-mcp/SKILL.md +0 -19
- package/standard-skills/windows-mcp/references/runtime.md +0 -9
- package/telegram-plugin/DELIVERY.md +0 -36
- package/telegram-plugin/bin/telegram-approval-relay.cjs +0 -290
- package/telegram-plugin/bin/telegram-console-status-policy.cjs +0 -175
- package/telegram-plugin/bin/telegram-delivery-lifecycle.cjs +0 -125
- package/telegram-plugin/bin/telegram-direct-reply-policy.cjs +0 -48
- package/telegram-plugin/bin/telegram-launcher-status-queue.cjs +0 -122
- package/telegram-plugin/bin/telegram-private-conversation-policy.cjs +0 -186
- package/telegram-plugin/bin/telegram-remote-status-policy.cjs +0 -121
- package/telegram-plugin/bin/telegram-reply-parts.cjs +0 -149
- package/telegram-plugin/bin/telegram-text-chunk-policy.cjs +0 -63
- package/telegram-plugin/bin/telegram-typing-keepalive.cjs +0 -89
- package/telegram-plugin/compat/mcp-server-fa511cd1.mjs +0 -73825
- /package/{bin → scripts}/fix-node-pty-perms.js +0 -0
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Provider-neutral HTTPS adapter for one anonymous benchmark review pass."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import hashlib
|
|
7
|
+
import importlib.util
|
|
8
|
+
import json
|
|
9
|
+
import re
|
|
10
|
+
import socket
|
|
11
|
+
import sys
|
|
12
|
+
import urllib.error
|
|
13
|
+
import urllib.parse
|
|
14
|
+
import urllib.request
|
|
15
|
+
from dataclasses import dataclass
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
from typing import Any, Callable, Mapping, Protocol
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
REQUEST_SCHEMA = "blun.website-localization-benchmark-review-http-request.v1"
|
|
21
|
+
RESPONSE_SCHEMA = "blun.website-localization-benchmark-review-http-response.v1"
|
|
22
|
+
MAX_ENDPOINT_LENGTH = 2048
|
|
23
|
+
MAX_HEADER_VALUE_LENGTH = 4096
|
|
24
|
+
MAX_REQUEST_BYTES = 8_500_000
|
|
25
|
+
MAX_RESPONSE_BYTES = 4_000_000
|
|
26
|
+
HEADER_NAME = re.compile(r"^[!#$%&'*+.^_`|~0-9A-Za-z-]{1,128}$")
|
|
27
|
+
REVIEW_ID = re.compile(r"^benchmark-review-[0-9a-f]{64}$")
|
|
28
|
+
ERROR_CODE = re.compile(r"^[a-z][a-z0-9_.-]{0,127}$")
|
|
29
|
+
RESERVED_HEADERS = {
|
|
30
|
+
"accept", "accept-encoding", "connection", "content-length", "content-type",
|
|
31
|
+
"host", "idempotency-key", "transfer-encoding", "x-benchmark-review-id",
|
|
32
|
+
"x-benchmark-review-request-sha256", "x-benchmark-review-phase",
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _load_module(name: str, path: Path):
|
|
37
|
+
spec = importlib.util.spec_from_file_location(name, path)
|
|
38
|
+
if spec is None or spec.loader is None:
|
|
39
|
+
raise RuntimeError(f"cannot load benchmark reviewer dependency: {path.name}")
|
|
40
|
+
module = importlib.util.module_from_spec(spec)
|
|
41
|
+
sys.modules[spec.name] = module
|
|
42
|
+
spec.loader.exec_module(module)
|
|
43
|
+
return module
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
_ROOT = Path(__file__).resolve().parents[1]
|
|
47
|
+
_BENCHMARK = _load_module(
|
|
48
|
+
"blun_website_localization_http_benchmark_reviewer",
|
|
49
|
+
_ROOT / "integrations" / "website_localization_benchmark.py",
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class HTTPBenchmarkReviewerFailed(RuntimeError):
|
|
54
|
+
"""Content-free adapter failure understood by benchmark orchestration."""
|
|
55
|
+
|
|
56
|
+
benchmark_reviewer_failure = True
|
|
57
|
+
|
|
58
|
+
def __init__(self, code: str, *, retryable: bool):
|
|
59
|
+
if not isinstance(code, str) or ERROR_CODE.fullmatch(code) is None:
|
|
60
|
+
raise ValueError("HTTP benchmark reviewer error code is invalid")
|
|
61
|
+
if not isinstance(retryable, bool):
|
|
62
|
+
raise ValueError("HTTP benchmark reviewer retryability must be boolean")
|
|
63
|
+
super().__init__(code)
|
|
64
|
+
self.code = code
|
|
65
|
+
self.retryable = retryable
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@dataclass(frozen=True)
|
|
69
|
+
class HTTPResult:
|
|
70
|
+
status: int
|
|
71
|
+
headers: tuple[tuple[str, str], ...]
|
|
72
|
+
body: bytes
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class HTTPTransport(Protocol):
|
|
76
|
+
def post(
|
|
77
|
+
self,
|
|
78
|
+
url: str,
|
|
79
|
+
headers: Mapping[str, str],
|
|
80
|
+
body: bytes,
|
|
81
|
+
*,
|
|
82
|
+
timeout: float,
|
|
83
|
+
) -> HTTPResult: ...
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class _NoRedirect(urllib.request.HTTPRedirectHandler):
|
|
87
|
+
def redirect_request(self, req, fp, code, msg, headers, newurl):
|
|
88
|
+
return None
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class URLTransport:
|
|
92
|
+
"""Perform one bounded HTTP request without following redirects."""
|
|
93
|
+
|
|
94
|
+
def __init__(self):
|
|
95
|
+
self._opener = urllib.request.build_opener(_NoRedirect)
|
|
96
|
+
|
|
97
|
+
def post(
|
|
98
|
+
self,
|
|
99
|
+
url: str,
|
|
100
|
+
headers: Mapping[str, str],
|
|
101
|
+
body: bytes,
|
|
102
|
+
*,
|
|
103
|
+
timeout: float,
|
|
104
|
+
) -> HTTPResult:
|
|
105
|
+
request = urllib.request.Request(
|
|
106
|
+
url, data=body, headers=dict(headers), method="POST",
|
|
107
|
+
)
|
|
108
|
+
try:
|
|
109
|
+
response = self._opener.open(request, timeout=timeout)
|
|
110
|
+
except urllib.error.HTTPError as error:
|
|
111
|
+
response_headers = tuple(error.headers.items()) if error.headers else ()
|
|
112
|
+
return HTTPResult(int(error.code), response_headers, b"")
|
|
113
|
+
except (urllib.error.URLError, TimeoutError, socket.timeout, OSError):
|
|
114
|
+
raise HTTPBenchmarkReviewerFailed("network", retryable=True) from None
|
|
115
|
+
try:
|
|
116
|
+
response_body = response.read(MAX_RESPONSE_BYTES + 1)
|
|
117
|
+
return HTTPResult(
|
|
118
|
+
int(response.status), tuple(response.headers.items()), response_body,
|
|
119
|
+
)
|
|
120
|
+
except (TimeoutError, socket.timeout, OSError):
|
|
121
|
+
raise HTTPBenchmarkReviewerFailed("network", retryable=True) from None
|
|
122
|
+
finally:
|
|
123
|
+
response.close()
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def _canonical_json(value: Any, *, code: str, maximum: int) -> bytes:
|
|
127
|
+
try:
|
|
128
|
+
encoded = json.dumps(
|
|
129
|
+
value,
|
|
130
|
+
ensure_ascii=False,
|
|
131
|
+
allow_nan=False,
|
|
132
|
+
sort_keys=True,
|
|
133
|
+
separators=(",", ":"),
|
|
134
|
+
).encode("utf-8")
|
|
135
|
+
except (TypeError, ValueError, UnicodeEncodeError, RecursionError):
|
|
136
|
+
raise HTTPBenchmarkReviewerFailed(code, retryable=False) from None
|
|
137
|
+
if not encoded or len(encoded) > maximum:
|
|
138
|
+
raise HTTPBenchmarkReviewerFailed(code, retryable=False)
|
|
139
|
+
return encoded
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def _pairs(items):
|
|
143
|
+
result = {}
|
|
144
|
+
for key, value in items:
|
|
145
|
+
if key in result:
|
|
146
|
+
raise ValueError("duplicate JSON key")
|
|
147
|
+
result[key] = value
|
|
148
|
+
return result
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def _constant(value):
|
|
152
|
+
raise ValueError("non-finite JSON number")
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def _endpoint(value: Any, allow_loopback_http: bool) -> str:
|
|
156
|
+
if (
|
|
157
|
+
not isinstance(value, str)
|
|
158
|
+
or value != value.strip()
|
|
159
|
+
or not value
|
|
160
|
+
or not value.isascii()
|
|
161
|
+
or len(value) > MAX_ENDPOINT_LENGTH
|
|
162
|
+
or any(ord(character) <= 32 or ord(character) == 127 for character in value)
|
|
163
|
+
):
|
|
164
|
+
raise ValueError("endpoint is invalid")
|
|
165
|
+
try:
|
|
166
|
+
parsed = urllib.parse.urlsplit(value)
|
|
167
|
+
hostname = parsed.hostname
|
|
168
|
+
port = parsed.port
|
|
169
|
+
except ValueError:
|
|
170
|
+
raise ValueError("endpoint is invalid") from None
|
|
171
|
+
if (
|
|
172
|
+
not hostname
|
|
173
|
+
or not hostname.isascii()
|
|
174
|
+
or parsed.username is not None
|
|
175
|
+
or parsed.password is not None
|
|
176
|
+
or parsed.query
|
|
177
|
+
or parsed.fragment
|
|
178
|
+
or not parsed.path.startswith("/")
|
|
179
|
+
or parsed.path.startswith("//")
|
|
180
|
+
):
|
|
181
|
+
raise ValueError("endpoint is invalid")
|
|
182
|
+
if parsed.scheme == "https":
|
|
183
|
+
pass
|
|
184
|
+
elif (
|
|
185
|
+
parsed.scheme == "http"
|
|
186
|
+
and allow_loopback_http
|
|
187
|
+
and hostname.lower() in {"localhost", "127.0.0.1", "::1"}
|
|
188
|
+
):
|
|
189
|
+
pass
|
|
190
|
+
else:
|
|
191
|
+
raise ValueError("endpoint must use HTTPS")
|
|
192
|
+
if port is not None and not 1 <= port <= 65535:
|
|
193
|
+
raise ValueError("endpoint is invalid")
|
|
194
|
+
return value
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def _authentication_headers(provider: Callable[[], Mapping[str, str]]) -> dict[str, str]:
|
|
198
|
+
try:
|
|
199
|
+
supplied = provider()
|
|
200
|
+
except Exception:
|
|
201
|
+
raise HTTPBenchmarkReviewerFailed("authentication", retryable=False) from None
|
|
202
|
+
if not isinstance(supplied, Mapping) or not supplied:
|
|
203
|
+
raise HTTPBenchmarkReviewerFailed("authentication", retryable=False)
|
|
204
|
+
result: dict[str, str] = {}
|
|
205
|
+
normalized_names: set[str] = set()
|
|
206
|
+
for name, value in supplied.items():
|
|
207
|
+
normalized = name.lower() if isinstance(name, str) else ""
|
|
208
|
+
if (
|
|
209
|
+
not isinstance(name, str)
|
|
210
|
+
or HEADER_NAME.fullmatch(name) is None
|
|
211
|
+
or normalized in RESERVED_HEADERS
|
|
212
|
+
or normalized in normalized_names
|
|
213
|
+
or not isinstance(value, str)
|
|
214
|
+
or not value
|
|
215
|
+
or not value.isascii()
|
|
216
|
+
or len(value) > MAX_HEADER_VALUE_LENGTH
|
|
217
|
+
or "\r" in value
|
|
218
|
+
or "\n" in value
|
|
219
|
+
or any(ord(character) < 32 or ord(character) == 127 for character in value)
|
|
220
|
+
):
|
|
221
|
+
raise HTTPBenchmarkReviewerFailed("authentication", retryable=False)
|
|
222
|
+
normalized_names.add(normalized)
|
|
223
|
+
result[name] = value
|
|
224
|
+
return result
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def _response_headers(value: Any) -> dict[str, str]:
|
|
228
|
+
if not isinstance(value, tuple):
|
|
229
|
+
raise HTTPBenchmarkReviewerFailed("transport_invalid", retryable=True)
|
|
230
|
+
result: dict[str, str] = {}
|
|
231
|
+
for item in value:
|
|
232
|
+
if (
|
|
233
|
+
not isinstance(item, tuple)
|
|
234
|
+
or len(item) != 2
|
|
235
|
+
or not all(isinstance(part, str) for part in item)
|
|
236
|
+
):
|
|
237
|
+
raise HTTPBenchmarkReviewerFailed("transport_invalid", retryable=True)
|
|
238
|
+
name, content = item[0].lower(), item[1].strip()
|
|
239
|
+
if name in {"content-type", "content-length"}:
|
|
240
|
+
if name in result:
|
|
241
|
+
raise HTTPBenchmarkReviewerFailed("response_headers", retryable=True)
|
|
242
|
+
result[name] = content
|
|
243
|
+
return result
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
def _blind_input(value: dict[str, Any], *, phase: str, locale: str) -> None:
|
|
247
|
+
common = {
|
|
248
|
+
"blind_id", "benchmark_version", "benchmark_suite", "target",
|
|
249
|
+
"content_type", "audience", "tone_profile", "policy_version",
|
|
250
|
+
"quality_profile", "variants", "response_schema",
|
|
251
|
+
}
|
|
252
|
+
phase_fields = (
|
|
253
|
+
{"target_terms"}
|
|
254
|
+
if phase == "target_native"
|
|
255
|
+
else {"source", "glossary", "protected_terms"}
|
|
256
|
+
)
|
|
257
|
+
if set(value) != common | phase_fields:
|
|
258
|
+
code = "source_blindness" if phase == "target_native" else "request_invalid"
|
|
259
|
+
raise HTTPBenchmarkReviewerFailed(code, retryable=False)
|
|
260
|
+
variants = value["variants"]
|
|
261
|
+
response_schema = value["response_schema"]
|
|
262
|
+
benchmark_suite = value["benchmark_suite"]
|
|
263
|
+
commercial_fidelity = (
|
|
264
|
+
phase == "source_fidelity" and value["content_type"] == "commercial"
|
|
265
|
+
)
|
|
266
|
+
commercial_dimensions = (
|
|
267
|
+
benchmark_suite.get("commercial_dimensions")
|
|
268
|
+
if isinstance(benchmark_suite, dict)
|
|
269
|
+
and commercial_fidelity
|
|
270
|
+
else None
|
|
271
|
+
)
|
|
272
|
+
if (
|
|
273
|
+
not isinstance(benchmark_suite, dict)
|
|
274
|
+
or not isinstance(value["target"], dict)
|
|
275
|
+
or value["target"].get("locale") != locale
|
|
276
|
+
or not isinstance(variants, list)
|
|
277
|
+
or len(variants) != 2
|
|
278
|
+
or [item.get("label") if isinstance(item, dict) else None for item in variants]
|
|
279
|
+
!= ["A", "B"]
|
|
280
|
+
or any(
|
|
281
|
+
set(item) != {"label", "text"}
|
|
282
|
+
or not isinstance(item["text"], str)
|
|
283
|
+
or not item["text"]
|
|
284
|
+
for item in variants
|
|
285
|
+
)
|
|
286
|
+
or not isinstance(response_schema, dict)
|
|
287
|
+
or response_schema.get("schema") != _BENCHMARK.REVIEW_SCHEMA
|
|
288
|
+
or response_schema.get("phase") != phase
|
|
289
|
+
or response_schema.get("target_locale") != locale
|
|
290
|
+
or response_schema.get("blind_id") != value["blind_id"]
|
|
291
|
+
):
|
|
292
|
+
raise HTTPBenchmarkReviewerFailed("request_invalid", retryable=False)
|
|
293
|
+
if commercial_fidelity and commercial_dimensions != list(
|
|
294
|
+
_BENCHMARK._WORKER._COMMERCIAL.DIMENSIONS
|
|
295
|
+
):
|
|
296
|
+
raise HTTPBenchmarkReviewerFailed("request_invalid", retryable=False)
|
|
297
|
+
expected_response_schema = _BENCHMARK._review_response_contract(
|
|
298
|
+
phase=phase,
|
|
299
|
+
locale=locale,
|
|
300
|
+
blind_id=value["blind_id"],
|
|
301
|
+
commercial_dimensions=(
|
|
302
|
+
commercial_dimensions if commercial_fidelity else None
|
|
303
|
+
),
|
|
304
|
+
)
|
|
305
|
+
if response_schema != expected_response_schema:
|
|
306
|
+
raise HTTPBenchmarkReviewerFailed("request_invalid", retryable=False)
|
|
307
|
+
if not commercial_fidelity and "commercial_dimensions" in benchmark_suite:
|
|
308
|
+
raise HTTPBenchmarkReviewerFailed("request_invalid", retryable=False)
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
def _request_payload(request: Any) -> tuple[dict[str, Any], bytes]:
|
|
312
|
+
try:
|
|
313
|
+
payload = request.as_payload()
|
|
314
|
+
review_id = request.review_id
|
|
315
|
+
phase = request.phase
|
|
316
|
+
target_locale = request.target_locale
|
|
317
|
+
system_instruction = request.system_instruction
|
|
318
|
+
review_input = request.input
|
|
319
|
+
except Exception:
|
|
320
|
+
raise HTTPBenchmarkReviewerFailed("request_invalid", retryable=False) from None
|
|
321
|
+
input_value = review_input if isinstance(review_input, dict) else {}
|
|
322
|
+
commercial_fidelity = (
|
|
323
|
+
phase == "source_fidelity"
|
|
324
|
+
and input_value.get("content_type") == "commercial"
|
|
325
|
+
)
|
|
326
|
+
expected_system = {
|
|
327
|
+
"target_native": _BENCHMARK._NATIVE_SYSTEM,
|
|
328
|
+
"source_fidelity": _BENCHMARK._FIDELITY_SYSTEM + (
|
|
329
|
+
"\n" + _BENCHMARK._COMMERCIAL_BENCHMARK_FIDELITY_SYSTEM
|
|
330
|
+
if commercial_fidelity else ""
|
|
331
|
+
),
|
|
332
|
+
}
|
|
333
|
+
if (
|
|
334
|
+
not isinstance(payload, dict)
|
|
335
|
+
or set(payload) != {
|
|
336
|
+
"schema", "review_id", "phase", "target_locale",
|
|
337
|
+
"system_instruction", "input",
|
|
338
|
+
}
|
|
339
|
+
or payload != {
|
|
340
|
+
"schema": request.schema,
|
|
341
|
+
"review_id": review_id,
|
|
342
|
+
"phase": phase,
|
|
343
|
+
"target_locale": target_locale,
|
|
344
|
+
"system_instruction": system_instruction,
|
|
345
|
+
"input": review_input,
|
|
346
|
+
}
|
|
347
|
+
or request.schema != _BENCHMARK.BENCHMARK_SCHEMA
|
|
348
|
+
or not isinstance(review_id, str)
|
|
349
|
+
or REVIEW_ID.fullmatch(review_id) is None
|
|
350
|
+
or phase not in expected_system
|
|
351
|
+
or system_instruction != expected_system[phase]
|
|
352
|
+
or not isinstance(target_locale, str)
|
|
353
|
+
or _BENCHMARK.IDENTIFIER.fullmatch(target_locale) is None
|
|
354
|
+
or not isinstance(review_input, dict)
|
|
355
|
+
or not isinstance(review_input.get("blind_id"), str)
|
|
356
|
+
or not review_input["blind_id"].startswith("blind-")
|
|
357
|
+
):
|
|
358
|
+
raise HTTPBenchmarkReviewerFailed("request_invalid", retryable=False)
|
|
359
|
+
_blind_input(review_input, phase=phase, locale=target_locale)
|
|
360
|
+
raw = _canonical_json(payload, code="request_invalid", maximum=MAX_REQUEST_BYTES)
|
|
361
|
+
return payload, raw
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
class HTTPBenchmarkReviewerAdapter:
|
|
365
|
+
"""Send exactly one bound, anonymous review request to an attached service."""
|
|
366
|
+
|
|
367
|
+
def __init__(
|
|
368
|
+
self,
|
|
369
|
+
endpoint: str,
|
|
370
|
+
authentication_headers: Callable[[], Mapping[str, str]],
|
|
371
|
+
*,
|
|
372
|
+
transport: HTTPTransport | None = None,
|
|
373
|
+
timeout: float = 60.0,
|
|
374
|
+
allow_loopback_http: bool = False,
|
|
375
|
+
):
|
|
376
|
+
if not isinstance(allow_loopback_http, bool):
|
|
377
|
+
raise TypeError("allow_loopback_http must be boolean")
|
|
378
|
+
self.endpoint = _endpoint(endpoint, allow_loopback_http)
|
|
379
|
+
if not callable(authentication_headers):
|
|
380
|
+
raise TypeError("authentication_headers must be callable")
|
|
381
|
+
if (
|
|
382
|
+
isinstance(timeout, bool)
|
|
383
|
+
or not isinstance(timeout, (int, float))
|
|
384
|
+
or not 0 < timeout <= 300
|
|
385
|
+
):
|
|
386
|
+
raise ValueError("timeout is outside the supported range")
|
|
387
|
+
self.authentication_headers = authentication_headers
|
|
388
|
+
self.transport = URLTransport() if transport is None else transport
|
|
389
|
+
if not callable(getattr(self.transport, "post", None)):
|
|
390
|
+
raise TypeError("transport must provide post")
|
|
391
|
+
self.timeout = float(timeout)
|
|
392
|
+
|
|
393
|
+
def review(self, request: Any) -> Mapping[str, Any]:
|
|
394
|
+
payload, request_bytes = _request_payload(request)
|
|
395
|
+
request_sha256 = hashlib.sha256(request_bytes).hexdigest()
|
|
396
|
+
review_id = payload["review_id"]
|
|
397
|
+
body = _canonical_json(
|
|
398
|
+
{
|
|
399
|
+
"schema": REQUEST_SCHEMA,
|
|
400
|
+
"review_id": review_id,
|
|
401
|
+
"request_sha256": request_sha256,
|
|
402
|
+
"review": payload,
|
|
403
|
+
},
|
|
404
|
+
code="request_invalid",
|
|
405
|
+
maximum=MAX_REQUEST_BYTES,
|
|
406
|
+
)
|
|
407
|
+
headers = _authentication_headers(self.authentication_headers)
|
|
408
|
+
headers.update({
|
|
409
|
+
"Accept": "application/json",
|
|
410
|
+
"Accept-Encoding": "identity",
|
|
411
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
412
|
+
"Idempotency-Key": review_id,
|
|
413
|
+
"X-Benchmark-Review-Id": review_id,
|
|
414
|
+
"X-Benchmark-Review-Phase": payload["phase"],
|
|
415
|
+
"X-Benchmark-Review-Request-Sha256": request_sha256,
|
|
416
|
+
})
|
|
417
|
+
try:
|
|
418
|
+
result = self.transport.post(
|
|
419
|
+
self.endpoint, headers, body, timeout=self.timeout,
|
|
420
|
+
)
|
|
421
|
+
except HTTPBenchmarkReviewerFailed:
|
|
422
|
+
raise
|
|
423
|
+
except Exception:
|
|
424
|
+
raise HTTPBenchmarkReviewerFailed("network", retryable=True) from None
|
|
425
|
+
try:
|
|
426
|
+
_, current_request_bytes = _request_payload(request)
|
|
427
|
+
except HTTPBenchmarkReviewerFailed:
|
|
428
|
+
raise HTTPBenchmarkReviewerFailed("request_mutated", retryable=False) from None
|
|
429
|
+
if current_request_bytes != request_bytes:
|
|
430
|
+
raise HTTPBenchmarkReviewerFailed("request_mutated", retryable=False)
|
|
431
|
+
if (
|
|
432
|
+
not isinstance(result, HTTPResult)
|
|
433
|
+
or isinstance(result.status, bool)
|
|
434
|
+
or not isinstance(result.status, int)
|
|
435
|
+
or not 100 <= result.status <= 599
|
|
436
|
+
):
|
|
437
|
+
raise HTTPBenchmarkReviewerFailed("transport_invalid", retryable=True)
|
|
438
|
+
if result.status != 200:
|
|
439
|
+
if 300 <= result.status <= 399:
|
|
440
|
+
raise HTTPBenchmarkReviewerFailed("redirect", retryable=False)
|
|
441
|
+
retryable = result.status in {408, 425, 429} or 500 <= result.status <= 599
|
|
442
|
+
raise HTTPBenchmarkReviewerFailed("http_status", retryable=retryable)
|
|
443
|
+
response_headers = _response_headers(result.headers)
|
|
444
|
+
content_type = response_headers.get("content-type", "").lower().replace(" ", "")
|
|
445
|
+
if content_type not in {"application/json", "application/json;charset=utf-8"}:
|
|
446
|
+
raise HTTPBenchmarkReviewerFailed("response_content_type", retryable=True)
|
|
447
|
+
if (
|
|
448
|
+
not isinstance(result.body, bytes)
|
|
449
|
+
or not result.body
|
|
450
|
+
or len(result.body) > MAX_RESPONSE_BYTES
|
|
451
|
+
):
|
|
452
|
+
raise HTTPBenchmarkReviewerFailed("response_size", retryable=True)
|
|
453
|
+
declared = response_headers.get("content-length")
|
|
454
|
+
if declared is not None and (
|
|
455
|
+
not declared.isascii()
|
|
456
|
+
or not declared.isdecimal()
|
|
457
|
+
or int(declared) != len(result.body)
|
|
458
|
+
):
|
|
459
|
+
raise HTTPBenchmarkReviewerFailed("response_size", retryable=True)
|
|
460
|
+
try:
|
|
461
|
+
text = result.body.decode("utf-8")
|
|
462
|
+
if text.startswith("\ufeff"):
|
|
463
|
+
raise ValueError("BOM rejected")
|
|
464
|
+
envelope = json.loads(
|
|
465
|
+
text, object_pairs_hook=_pairs, parse_constant=_constant,
|
|
466
|
+
)
|
|
467
|
+
except (UnicodeDecodeError, json.JSONDecodeError, ValueError, RecursionError):
|
|
468
|
+
raise HTTPBenchmarkReviewerFailed("response_json", retryable=True) from None
|
|
469
|
+
if not isinstance(envelope, dict) or set(envelope) != {
|
|
470
|
+
"schema", "review_id", "request_sha256", "review",
|
|
471
|
+
}:
|
|
472
|
+
raise HTTPBenchmarkReviewerFailed("response_invalid", retryable=False)
|
|
473
|
+
if (
|
|
474
|
+
envelope["schema"] != RESPONSE_SCHEMA
|
|
475
|
+
or envelope["review_id"] != review_id
|
|
476
|
+
or envelope["request_sha256"] != request_sha256
|
|
477
|
+
):
|
|
478
|
+
raise HTTPBenchmarkReviewerFailed("response_binding", retryable=False)
|
|
479
|
+
response = envelope["review"]
|
|
480
|
+
if not isinstance(response, dict):
|
|
481
|
+
raise HTTPBenchmarkReviewerFailed("response_invalid", retryable=False)
|
|
482
|
+
try:
|
|
483
|
+
_BENCHMARK._validate_review(
|
|
484
|
+
response,
|
|
485
|
+
phase=payload["phase"],
|
|
486
|
+
locale=payload["target_locale"],
|
|
487
|
+
blind_id=payload["input"]["blind_id"],
|
|
488
|
+
commercial_dimensions=(
|
|
489
|
+
payload["input"]["benchmark_suite"].get(
|
|
490
|
+
"commercial_dimensions",
|
|
491
|
+
)
|
|
492
|
+
if payload["phase"] == "source_fidelity"
|
|
493
|
+
and payload["input"]["content_type"] == "commercial"
|
|
494
|
+
else None
|
|
495
|
+
),
|
|
496
|
+
)
|
|
497
|
+
except Exception:
|
|
498
|
+
raise HTTPBenchmarkReviewerFailed("response_invalid", retryable=False) from None
|
|
499
|
+
_canonical_json(response, code="response_invalid", maximum=MAX_RESPONSE_BYTES)
|
|
500
|
+
return response
|