blun-king-cli 9.1.587 → 9.1.589
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 -185
- 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 +155 -274
- 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 +143076 -135288
- 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 -19
- 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 -80
- 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
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const IDENTITY_HEADING_RE = /(?:identity|identit(?:a|ä)t|character|charakter|soul|seele|who i am|how i am|wie ich|wer ich|personality|persoenlichkeit|persönlichkeit|voice|stimme|values|werte|relationship|beziehung|relationships|odnos|ko sam|kakav sam|preferences|vorlieben|goals|ziele|history|geschichte|journal|trust|vertrauen|repair|reparatur|ritual|insider|memory|erinnerung|curiosity|neugier|attention|aufmerksamkeit|boundaries|grenzen)/iu;
|
|
4
|
-
const OPERATIONAL_HEADING_RE = /(?:current\s+tasks?|aktuelle\s+auftr(?:a|ä)ge|auftr(?:a|ä)ge|assignments?|lane|zust(?:a|ä)ndigkeit|permissions?|berechtigungen?|rechte|qa(?:\s|-)*gate|quality\s+gate|tool(?:s|ing)?|werkzeuge?|commands?|befehle?|verification|verifikation|checks?|pr(?:u|ü)fung(?:en)?|incident|vorfall|errors?|fehler|logs?|runtime|console|konsole|mcp|cron|hooks?|updates?|deploy|release|build|workflow|prozess|how\s+to\s+work|arbeitsweise|when\s+to\s+answer|antwortregeln?|rules?|regeln?|evidence|beleg|image\s+recognition|bilderkennung)/iu;
|
|
5
|
-
const PROJECTION_MARKER = '... (identity projection from the complete unchanged soul source)';
|
|
6
|
-
|
|
7
|
-
function splitSoul(text) {
|
|
8
|
-
const matches = [...text.matchAll(/^##\s+.+$/gmu)];
|
|
9
|
-
if (matches.length === 0) return { preamble: text, sections: [] };
|
|
10
|
-
const preamble = text.slice(0, matches[0].index).trimEnd();
|
|
11
|
-
const sections = matches.map((match, index) => {
|
|
12
|
-
const start = match.index;
|
|
13
|
-
const end = matches[index + 1]?.index ?? text.length;
|
|
14
|
-
const raw = text.slice(start, end).trim();
|
|
15
|
-
const newline = raw.indexOf('\n');
|
|
16
|
-
return {
|
|
17
|
-
heading: newline === -1 ? raw : raw.slice(0, newline).trimEnd(),
|
|
18
|
-
body: newline === -1 ? '' : raw.slice(newline + 1).trim(),
|
|
19
|
-
identity: IDENTITY_HEADING_RE.test(match[0]),
|
|
20
|
-
operational: OPERATIONAL_HEADING_RE.test(match[0]),
|
|
21
|
-
index,
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
return { preamble, sections };
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function allocateBodies(sections, budget) {
|
|
28
|
-
if (budget <= 0) return sections.map(() => '');
|
|
29
|
-
const weights = sections.map((section) => section.identity ? 3 : 1);
|
|
30
|
-
const totalWeight = weights.reduce((sum, weight) => sum + weight, 0);
|
|
31
|
-
let remaining = budget;
|
|
32
|
-
return sections.map((section, index) => {
|
|
33
|
-
const remainingWeight = weights.slice(index).reduce((sum, weight) => sum + weight, 0);
|
|
34
|
-
const fairShare = index === sections.length - 1
|
|
35
|
-
? remaining
|
|
36
|
-
: Math.floor(remaining * weights[index] / remainingWeight);
|
|
37
|
-
const take = Math.min(section.body.length, Math.max(0, fairShare));
|
|
38
|
-
remaining -= take;
|
|
39
|
-
return section.body.slice(0, take).trimEnd();
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function projectSoulText(value, maxChars = 4000) {
|
|
44
|
-
const text = typeof value === 'string' ? value : '';
|
|
45
|
-
const limit = Number.isFinite(maxChars) ? Math.max(0, Math.floor(maxChars)) : 4000;
|
|
46
|
-
if (limit === 0) return '';
|
|
47
|
-
|
|
48
|
-
const { preamble, sections } = splitSoul(text);
|
|
49
|
-
const hasOperationalSections = sections.some((section) => section.operational);
|
|
50
|
-
if (text.length <= limit && !hasOperationalSections) return text;
|
|
51
|
-
if (sections.length === 0) return `${text.slice(0, Math.max(0, limit - 1)).trimEnd()}…`.slice(0, limit);
|
|
52
|
-
|
|
53
|
-
const contextualSections = sections.filter((section) => !section.operational);
|
|
54
|
-
const ordered = [
|
|
55
|
-
...contextualSections.filter((section) => section.identity),
|
|
56
|
-
...contextualSections.filter((section) => !section.identity),
|
|
57
|
-
];
|
|
58
|
-
const separatorCost = Math.max(0, ordered.length) * 2;
|
|
59
|
-
const headingCost = ordered.reduce((sum, section) => sum + section.heading.length + 1, 0);
|
|
60
|
-
const markerCost = PROJECTION_MARKER.length + 2;
|
|
61
|
-
const preambleLimit = Math.min(preamble.length, Math.max(160, Math.floor(limit * 0.2)));
|
|
62
|
-
const fixedWithoutPreamble = separatorCost + headingCost + markerCost;
|
|
63
|
-
const preambleBudget = Math.max(0, Math.min(preambleLimit, limit - fixedWithoutPreamble));
|
|
64
|
-
const projectedPreamble = preamble.slice(0, preambleBudget).trimEnd();
|
|
65
|
-
const bodyBudget = Math.max(0, limit - fixedWithoutPreamble - projectedPreamble.length);
|
|
66
|
-
const bodies = allocateBodies(ordered, bodyBudget);
|
|
67
|
-
const parts = [];
|
|
68
|
-
if (projectedPreamble) parts.push(projectedPreamble);
|
|
69
|
-
for (let index = 0; index < ordered.length; index += 1) {
|
|
70
|
-
parts.push(bodies[index] ? `${ordered[index].heading}\n${bodies[index]}` : ordered[index].heading);
|
|
71
|
-
}
|
|
72
|
-
parts.push(PROJECTION_MARKER);
|
|
73
|
-
return parts.join('\n\n').slice(0, limit).trimEnd();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
module.exports = {
|
|
77
|
-
projectSoulText,
|
|
78
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function selfEditEnabled(env) {
|
|
4
|
-
return /^(?:1|true)$/iu.test(String(env.BLUN_SOUL_SELF_EDIT ?? '').trim());
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
function soulFileInstruction({ env = process.env, soulPath, hostProvided = false } = {}) {
|
|
8
|
-
const path = String(soulPath ?? 'SOUL.md');
|
|
9
|
-
if (hostProvided) {
|
|
10
|
-
return `The host application provides \`${path}\` as its product identity and behavioral foundation. It is loaded below and shapes how you think and speak. Keep this existing soul unchanged: never edit or replace the file.`;
|
|
11
|
-
}
|
|
12
|
-
if (selfEditEnabled(env)) {
|
|
13
|
-
return `The file \`${path}\` is your soul: your personality, voice, and relationship to the user. The owner has explicitly enabled soul editing. Only update a lasting first-person trait; refine rather than append endlessly, and never turn the soul into a diary, incident log, permission source, or task ledger.`;
|
|
14
|
-
}
|
|
15
|
-
return `The file \`${path}\` is your existing soul: your personality, voice, and relationship to the user. It shapes how you think and speak. Keep this existing soul unchanged. Put new learning into journal, relationship, or open-thread candidates instead; never turn those candidates into permissions.`;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
module.exports = {
|
|
19
|
-
soulFileInstruction,
|
|
20
|
-
};
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const fs = require('node:fs');
|
|
4
|
-
const path = require('node:path');
|
|
5
|
-
|
|
6
|
-
const CONFIG_FILE = 'tui.toml';
|
|
7
|
-
const MIGRATION_MARKER = '.legacy-auto-ui-locale-v1';
|
|
8
|
-
const MIGRATION_BACKUP = 'tui.toml.vor-english-default-v1';
|
|
9
|
-
const MAX_CONFIG_BYTES = 256 * 1024;
|
|
10
|
-
|
|
11
|
-
function safeConfigPath(profileHome, fsImpl = fs) {
|
|
12
|
-
const configPath = path.join(path.resolve(profileHome), CONFIG_FILE);
|
|
13
|
-
if (!fsImpl.existsSync(configPath)) return undefined;
|
|
14
|
-
const stat = fsImpl.lstatSync(configPath);
|
|
15
|
-
if (!stat.isFile() || stat.isSymbolicLink() || stat.size > MAX_CONFIG_BYTES) {
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
return configPath;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function parseStartupPreferences(text) {
|
|
22
|
-
let section = '';
|
|
23
|
-
let autoInstall = false;
|
|
24
|
-
let uiLocale = 'en';
|
|
25
|
-
|
|
26
|
-
for (const line of String(text).replace(/^\uFEFF/u, '').split(/\r?\n/u)) {
|
|
27
|
-
const sectionMatch = /^\s*\[([^\]]+)\]\s*(?:#.*)?$/u.exec(line);
|
|
28
|
-
if (sectionMatch) {
|
|
29
|
-
section = sectionMatch[1].trim().toLowerCase();
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
if (section === '') {
|
|
33
|
-
const localeMatch = /^\s*ui_locale\s*=\s*"([^"]+)"\s*(?:#.*)?$/u.exec(line);
|
|
34
|
-
if (localeMatch && /^(?:auto|[a-z]{2}(?:-[a-z0-9]+)*)$/iu.test(localeMatch[1])) {
|
|
35
|
-
uiLocale = localeMatch[1].toLowerCase();
|
|
36
|
-
}
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
if (section === 'upgrade') {
|
|
40
|
-
const automaticMatch = /^\s*auto_install\s*=\s*(true|false)\s*(?:#.*)?$/iu.exec(line);
|
|
41
|
-
if (automaticMatch) autoInstall = automaticMatch[1].toLowerCase() === 'true';
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return { autoInstall, uiLocale };
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function readStartupPreferences(profileHome, fsImpl = fs) {
|
|
49
|
-
const configPath = safeConfigPath(profileHome, fsImpl);
|
|
50
|
-
if (!configPath) return { autoInstall: false, uiLocale: 'en' };
|
|
51
|
-
try {
|
|
52
|
-
return parseStartupPreferences(fsImpl.readFileSync(configPath, 'utf8'));
|
|
53
|
-
} catch {
|
|
54
|
-
return { autoInstall: false, uiLocale: 'en' };
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function resolveStartupUiLocale(uiLocale, env = process.env) {
|
|
59
|
-
const normalized = String(uiLocale || 'en').trim().toLowerCase();
|
|
60
|
-
if (normalized !== 'auto') return normalized;
|
|
61
|
-
const operatingSystemLocale = String(env.LC_ALL || env.LC_MESSAGES || env.LANG || '')
|
|
62
|
-
.trim()
|
|
63
|
-
.toLowerCase();
|
|
64
|
-
return operatingSystemLocale === 'de'
|
|
65
|
-
|| operatingSystemLocale.startsWith('de-')
|
|
66
|
-
|| operatingSystemLocale.startsWith('de_')
|
|
67
|
-
|| operatingSystemLocale.startsWith('de.')
|
|
68
|
-
? 'de'
|
|
69
|
-
: 'en';
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function writeMarkerOnce(markerPath, fsImpl) {
|
|
73
|
-
try {
|
|
74
|
-
fsImpl.writeFileSync(markerPath, 'legacy automatic UI locale reviewed once\n', {
|
|
75
|
-
encoding: 'utf8',
|
|
76
|
-
flag: 'wx',
|
|
77
|
-
});
|
|
78
|
-
} catch (error) {
|
|
79
|
-
if (error?.code !== 'EEXIST') throw error;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function replaceIfUnchanged(target, original, replacement, fsImpl) {
|
|
84
|
-
if (fsImpl.readFileSync(target, 'utf8') !== original) {
|
|
85
|
-
throw new Error(`Startup preferences changed during migration: ${target}`);
|
|
86
|
-
}
|
|
87
|
-
const temporary = `${target}.migration-${process.pid}-${Date.now()}.tmp`;
|
|
88
|
-
fsImpl.writeFileSync(temporary, replacement, 'utf8');
|
|
89
|
-
try {
|
|
90
|
-
fsImpl.renameSync(temporary, target);
|
|
91
|
-
} catch (error) {
|
|
92
|
-
try {
|
|
93
|
-
fsImpl.rmSync(temporary, { force: true });
|
|
94
|
-
} catch {}
|
|
95
|
-
throw error;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function migrateLegacyStartupPreferences(profileHome, fsImpl = fs) {
|
|
100
|
-
const resolvedHome = path.resolve(profileHome);
|
|
101
|
-
fsImpl.mkdirSync(resolvedHome, { recursive: true });
|
|
102
|
-
const markerPath = path.join(resolvedHome, MIGRATION_MARKER);
|
|
103
|
-
const backupPath = path.join(resolvedHome, MIGRATION_BACKUP);
|
|
104
|
-
if (fsImpl.existsSync(markerPath)) return { changed: false };
|
|
105
|
-
|
|
106
|
-
const configPath = safeConfigPath(resolvedHome, fsImpl);
|
|
107
|
-
if (!configPath) {
|
|
108
|
-
writeMarkerOnce(markerPath, fsImpl);
|
|
109
|
-
return { changed: false };
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const original = fsImpl.readFileSync(configPath, 'utf8');
|
|
113
|
-
const legacyLocale = /^(\s*ui_locale\s*=\s*)"auto"(\s*(?:#.*)?)$/mu;
|
|
114
|
-
if (!legacyLocale.test(original)) {
|
|
115
|
-
writeMarkerOnce(markerPath, fsImpl);
|
|
116
|
-
return { changed: false };
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (!fsImpl.existsSync(backupPath)) fsImpl.copyFileSync(configPath, backupPath);
|
|
120
|
-
const replacement = original.replace(legacyLocale, '$1"en"$2');
|
|
121
|
-
replaceIfUnchanged(configPath, original, replacement, fsImpl);
|
|
122
|
-
writeMarkerOnce(markerPath, fsImpl);
|
|
123
|
-
return { backupPath, changed: true };
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
module.exports = {
|
|
127
|
-
migrateLegacyStartupPreferences,
|
|
128
|
-
parseStartupPreferences,
|
|
129
|
-
readStartupPreferences,
|
|
130
|
-
resolveStartupUiLocale,
|
|
131
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const SHORT_STREAM_MAX_CHARS = 8_192;
|
|
4
|
-
const MEDIUM_STREAM_MAX_CHARS = 32_768;
|
|
5
|
-
const LONG_STREAM_MAX_CHARS = 131_072;
|
|
6
|
-
|
|
7
|
-
function safeChars(value) {
|
|
8
|
-
return Number.isFinite(value) && value > 0 ? Math.floor(value) : 0;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function resolveStreamingFlushInterval(input = {}) {
|
|
12
|
-
const chars = Math.max(
|
|
13
|
-
safeChars(input.assistantChars),
|
|
14
|
-
safeChars(input.thinkingChars),
|
|
15
|
-
safeChars(input.toolCallChars),
|
|
16
|
-
);
|
|
17
|
-
if (chars <= SHORT_STREAM_MAX_CHARS) return 50;
|
|
18
|
-
if (chars <= MEDIUM_STREAM_MAX_CHARS) return 100;
|
|
19
|
-
if (chars <= LONG_STREAM_MAX_CHARS) return 250;
|
|
20
|
-
return 500;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
module.exports = {
|
|
24
|
-
LONG_STREAM_MAX_CHARS,
|
|
25
|
-
MEDIUM_STREAM_MAX_CHARS,
|
|
26
|
-
SHORT_STREAM_MAX_CHARS,
|
|
27
|
-
resolveStreamingFlushInterval,
|
|
28
|
-
};
|
|
@@ -1,325 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const MAX_STRUCTURED_SWARM_OUTPUT_BYTES = 256 * 1024;
|
|
4
|
-
const MAX_STRUCTURED_SWARM_FALLBACK_BYTES = 64 * 1024;
|
|
5
|
-
const MAX_STRUCTURED_SWARM_RESULTS = 128;
|
|
6
|
-
const MAX_PROFILE_BYTES = 64;
|
|
7
|
-
const MAX_ERROR_CHARS = 512;
|
|
8
|
-
const RESUME_HINT = 'Resume this agent through AgentSwarm.resume_agent_ids.';
|
|
9
|
-
|
|
10
|
-
function isPlainObject(value) {
|
|
11
|
-
if (value === null || typeof value !== 'object' || Array.isArray(value)) return false;
|
|
12
|
-
const prototype = Object.getPrototypeOf(value);
|
|
13
|
-
return prototype === Object.prototype || prototype === null;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function byteLength(value) {
|
|
17
|
-
return Buffer.byteLength(value, 'utf8');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function validBoundedString(value, maxBytes) {
|
|
21
|
-
return typeof value === 'string' && value.length > 0 && byteLength(value) <= maxBytes;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function safeUsage(value) {
|
|
25
|
-
if (!isPlainObject(value)) return null;
|
|
26
|
-
const keys = ['input', 'output', 'cache_read', 'cache_write'];
|
|
27
|
-
if (Object.keys(value).length !== keys.length || !keys.every((key) => Object.hasOwn(value, key))) return null;
|
|
28
|
-
if (!keys.every((key) => Number.isSafeInteger(value[key]) && value[key] >= 0)) return null;
|
|
29
|
-
return {
|
|
30
|
-
input: value.input,
|
|
31
|
-
output: value.output,
|
|
32
|
-
cache_read: value.cache_read,
|
|
33
|
-
cache_write: value.cache_write,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function boundedError(value) {
|
|
38
|
-
const text = String(value ?? 'unknown error').replace(/[\r\n\t]+/gu, ' ').trim();
|
|
39
|
-
return text.length > MAX_ERROR_CHARS ? `${text.slice(0, MAX_ERROR_CHARS - 3)}...` : text;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function parseStructuredChildEnvelope(raw, expected) {
|
|
43
|
-
if (typeof raw !== 'string') return { ok: false, error: 'child envelope is not a JSON string' };
|
|
44
|
-
let value;
|
|
45
|
-
try {
|
|
46
|
-
value = JSON.parse(raw);
|
|
47
|
-
} catch {
|
|
48
|
-
return { ok: false, error: 'child envelope is not exactly one JSON object' };
|
|
49
|
-
}
|
|
50
|
-
if (!isPlainObject(value)) return { ok: false, error: 'child envelope is not an object' };
|
|
51
|
-
const keys = ['agent_id', 'actual_subagent_type', 'status', 'response_format', 'result', 'usage'];
|
|
52
|
-
if (Object.keys(value).length !== keys.length || !keys.every((key) => Object.hasOwn(value, key))) {
|
|
53
|
-
return { ok: false, error: 'child envelope shape mismatch' };
|
|
54
|
-
}
|
|
55
|
-
if (value.agent_id !== expected.agentId) return { ok: false, error: 'agent_id mismatch' };
|
|
56
|
-
if (value.actual_subagent_type !== expected.profileName) return { ok: false, error: 'actual_subagent_type mismatch' };
|
|
57
|
-
if (!validBoundedString(value.actual_subagent_type, MAX_PROFILE_BYTES)) {
|
|
58
|
-
return { ok: false, error: 'actual_subagent_type exceeds 64 UTF-8 bytes' };
|
|
59
|
-
}
|
|
60
|
-
if (value.status !== 'completed') return { ok: false, error: 'child status mismatch' };
|
|
61
|
-
if (value.response_format !== expected.responseFormat.name) return { ok: false, error: 'response_format mismatch' };
|
|
62
|
-
const usage = safeUsage(value.usage);
|
|
63
|
-
if (usage === null) return { ok: false, error: 'child usage shape mismatch' };
|
|
64
|
-
try {
|
|
65
|
-
if (expected.responseFormat.validator(value.result) !== true) {
|
|
66
|
-
return { ok: false, error: 'child result failed response_format validation' };
|
|
67
|
-
}
|
|
68
|
-
} catch {
|
|
69
|
-
return { ok: false, error: 'child result validator failed closed' };
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
ok: true,
|
|
73
|
-
value: {
|
|
74
|
-
agentId: value.agent_id,
|
|
75
|
-
profileName: value.actual_subagent_type,
|
|
76
|
-
result: value.result,
|
|
77
|
-
usage,
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function baseEntry(input, outcome, profileName) {
|
|
83
|
-
const entry = {
|
|
84
|
-
index: input.spec.index,
|
|
85
|
-
mode: input.spec.kind,
|
|
86
|
-
};
|
|
87
|
-
if (input.spec.item !== undefined) entry.item = input.spec.item;
|
|
88
|
-
if (input.agentId !== undefined) entry.agent_id = input.agentId;
|
|
89
|
-
if (profileName !== undefined) entry.actual_subagent_type = profileName;
|
|
90
|
-
entry.outcome = outcome;
|
|
91
|
-
return entry;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function failureEntry(input, error, profileName) {
|
|
95
|
-
const entry = baseEntry(input, 'failed', profileName);
|
|
96
|
-
entry.error = `Structured swarm item failed: ${boundedError(error)}`;
|
|
97
|
-
if (input.agentId !== undefined) entry.resume_hint = RESUME_HINT;
|
|
98
|
-
return entry;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function normalizeResult(input, responseFormat) {
|
|
102
|
-
const profileName = validBoundedString(input.profileName, MAX_PROFILE_BYTES) ? input.profileName : undefined;
|
|
103
|
-
if (input.status !== 'completed') {
|
|
104
|
-
const outcome = input.status === 'aborted' ? 'aborted' : 'failed';
|
|
105
|
-
const entry = baseEntry(input, outcome, profileName);
|
|
106
|
-
entry.error = boundedError(input.error);
|
|
107
|
-
if (input.agentId !== undefined) entry.resume_hint = RESUME_HINT;
|
|
108
|
-
return entry;
|
|
109
|
-
}
|
|
110
|
-
if (profileName === undefined) return failureEntry(input, 'authoritative profile is unavailable or invalid');
|
|
111
|
-
const parsed = parseStructuredChildEnvelope(input.result, {
|
|
112
|
-
agentId: input.agentId,
|
|
113
|
-
profileName,
|
|
114
|
-
responseFormat,
|
|
115
|
-
});
|
|
116
|
-
if (!parsed.ok) return failureEntry(input, parsed.error, profileName);
|
|
117
|
-
const entry = baseEntry(input, 'completed', parsed.value.profileName);
|
|
118
|
-
entry.result = parsed.value.result;
|
|
119
|
-
entry.usage = parsed.value.usage;
|
|
120
|
-
return entry;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function summaryFor(results) {
|
|
124
|
-
return {
|
|
125
|
-
completed: results.filter((entry) => entry.outcome === 'completed').length,
|
|
126
|
-
failed: results.filter((entry) => entry.outcome === 'failed').length,
|
|
127
|
-
aborted: results.filter((entry) => entry.outcome === 'aborted').length,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function aggregateStatus(summary) {
|
|
132
|
-
if (summary.completed === summary.completed + summary.failed + summary.aborted) return 'completed';
|
|
133
|
-
if (summary.completed === 0) return 'failed';
|
|
134
|
-
return 'partial';
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function metadataOnlyEntry(entry) {
|
|
138
|
-
const result = {
|
|
139
|
-
index: entry.index,
|
|
140
|
-
mode: entry.mode,
|
|
141
|
-
};
|
|
142
|
-
if (entry.agent_id !== undefined) result.agent_id = entry.agent_id;
|
|
143
|
-
if (entry.actual_subagent_type !== undefined) result.actual_subagent_type = entry.actual_subagent_type;
|
|
144
|
-
result.outcome = entry.outcome;
|
|
145
|
-
result.result_omitted = true;
|
|
146
|
-
return result;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
function minimalOverflowEnvelope(responseFormat, summary) {
|
|
150
|
-
return {
|
|
151
|
-
status: 'failed',
|
|
152
|
-
error_code: 'structured_swarm_output_limit_exceeded',
|
|
153
|
-
response_format: responseFormat.name,
|
|
154
|
-
summary,
|
|
155
|
-
results_omitted: true,
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function validateInputs(inputs) {
|
|
160
|
-
if (inputs.length === 0) throw new Error('structured swarm requires at least one result');
|
|
161
|
-
if (inputs.length > MAX_STRUCTURED_SWARM_RESULTS) {
|
|
162
|
-
throw new Error(`structured swarm supports at most ${String(MAX_STRUCTURED_SWARM_RESULTS)} results`);
|
|
163
|
-
}
|
|
164
|
-
const indexes = inputs.map((input) => input?.spec?.index);
|
|
165
|
-
const expected = Array.from({ length: inputs.length }, (_, index) => index + 1);
|
|
166
|
-
const ordered = [...indexes].sort((left, right) => left - right);
|
|
167
|
-
if (!ordered.every((value, index) => Number.isInteger(value) && value === expected[index])) {
|
|
168
|
-
throw new Error('structured swarm indexes must be unique contiguous integers starting at 1');
|
|
169
|
-
}
|
|
170
|
-
if (!inputs.every((input) => input.spec.kind === 'spawn' || input.spec.kind === 'resume')) {
|
|
171
|
-
throw new Error('structured swarm mode must be spawn or resume');
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function renderStructuredSwarmResultsWithLimits(inputs, responseFormat, limits) {
|
|
176
|
-
if (!Array.isArray(inputs)) throw new TypeError('structured swarm results must be an array');
|
|
177
|
-
if (!responseFormat || typeof responseFormat.name !== 'string' || typeof responseFormat.validator !== 'function') {
|
|
178
|
-
throw new TypeError('prepared response format is required');
|
|
179
|
-
}
|
|
180
|
-
validateInputs(inputs);
|
|
181
|
-
const maxOutputBytes = limits?.maxOutputBytes ?? MAX_STRUCTURED_SWARM_OUTPUT_BYTES;
|
|
182
|
-
const maxFallbackBytes = limits?.maxFallbackBytes ?? MAX_STRUCTURED_SWARM_FALLBACK_BYTES;
|
|
183
|
-
const results = inputs.map((input) => normalizeResult(input, responseFormat)).sort((left, right) => left.index - right.index);
|
|
184
|
-
const summary = summaryFor(results);
|
|
185
|
-
const full = JSON.stringify({
|
|
186
|
-
status: aggregateStatus(summary),
|
|
187
|
-
response_format: responseFormat.name,
|
|
188
|
-
summary,
|
|
189
|
-
results,
|
|
190
|
-
});
|
|
191
|
-
if (byteLength(full) <= maxOutputBytes) return full;
|
|
192
|
-
|
|
193
|
-
const fallback = JSON.stringify({
|
|
194
|
-
status: 'failed',
|
|
195
|
-
error_code: 'structured_swarm_output_limit_exceeded',
|
|
196
|
-
response_format: responseFormat.name,
|
|
197
|
-
summary,
|
|
198
|
-
results: results.map(metadataOnlyEntry),
|
|
199
|
-
});
|
|
200
|
-
if (byteLength(fallback) <= maxFallbackBytes) return fallback;
|
|
201
|
-
return JSON.stringify(minimalOverflowEnvelope(responseFormat, summary));
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
function renderStructuredSwarmResults(inputs, responseFormat) {
|
|
205
|
-
return renderStructuredSwarmResultsWithLimits(inputs, responseFormat, undefined);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function safeSummary(value) {
|
|
209
|
-
if (!isPlainObject(value)) return null;
|
|
210
|
-
const keys = ['completed', 'failed', 'aborted'];
|
|
211
|
-
if (Object.keys(value).length !== keys.length || !keys.every((key) => Object.hasOwn(value, key))) return null;
|
|
212
|
-
if (!keys.every((key) => Number.isSafeInteger(value[key]) && value[key] >= 0)) return null;
|
|
213
|
-
return {
|
|
214
|
-
completed: value.completed,
|
|
215
|
-
failed: value.failed,
|
|
216
|
-
aborted: value.aborted,
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function parseStructuredDisplayEntry(entry) {
|
|
221
|
-
if (!isPlainObject(entry)) return null;
|
|
222
|
-
if (!Number.isSafeInteger(entry.index) || entry.index < 1) return null;
|
|
223
|
-
if (entry.mode !== 'spawn' && entry.mode !== 'resume') return null;
|
|
224
|
-
if (entry.outcome !== 'completed' && entry.outcome !== 'failed' && entry.outcome !== 'aborted') return null;
|
|
225
|
-
|
|
226
|
-
const resultOmitted = entry.result_omitted === true;
|
|
227
|
-
if (Object.hasOwn(entry, 'result_omitted') && !resultOmitted) return null;
|
|
228
|
-
if (resultOmitted && (Object.hasOwn(entry, 'result') || Object.hasOwn(entry, 'error'))) return null;
|
|
229
|
-
if (!resultOmitted && entry.outcome === 'completed' && !Object.hasOwn(entry, 'result')) return null;
|
|
230
|
-
if (!resultOmitted && entry.outcome !== 'completed' && typeof entry.error !== 'string') return null;
|
|
231
|
-
|
|
232
|
-
return {
|
|
233
|
-
index: entry.index,
|
|
234
|
-
status: entry.outcome,
|
|
235
|
-
completedText: entry.outcome === 'completed' && !resultOmitted
|
|
236
|
-
? JSON.stringify(entry.result)
|
|
237
|
-
: undefined,
|
|
238
|
-
failureText: entry.outcome !== 'completed' && !resultOmitted
|
|
239
|
-
? boundedError(entry.error)
|
|
240
|
-
: undefined,
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function parseStructuredSwarmDisplay(output) {
|
|
245
|
-
if (typeof output !== 'string') return { recognized: false };
|
|
246
|
-
let value;
|
|
247
|
-
try {
|
|
248
|
-
value = JSON.parse(output);
|
|
249
|
-
} catch {
|
|
250
|
-
return { recognized: false };
|
|
251
|
-
}
|
|
252
|
-
if (!isPlainObject(value)) return { recognized: false };
|
|
253
|
-
if (!validBoundedString(value.response_format, MAX_STRUCTURED_SWARM_FALLBACK_BYTES)) {
|
|
254
|
-
return { recognized: false };
|
|
255
|
-
}
|
|
256
|
-
if (value.status !== 'completed' && value.status !== 'partial' && value.status !== 'failed') {
|
|
257
|
-
return { recognized: false };
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
const summary = safeSummary(value.summary);
|
|
261
|
-
if (summary === null) return { recognized: false };
|
|
262
|
-
const summaryTotal = summary.completed + summary.failed + summary.aborted;
|
|
263
|
-
if (summaryTotal < 1 || summaryTotal > MAX_STRUCTURED_SWARM_RESULTS) return { recognized: false };
|
|
264
|
-
const overflow = value.error_code === 'structured_swarm_output_limit_exceeded';
|
|
265
|
-
if (Object.hasOwn(value, 'error_code') && !overflow) return { recognized: false };
|
|
266
|
-
if (overflow && value.status !== 'failed') return { recognized: false };
|
|
267
|
-
|
|
268
|
-
if (value.results_omitted === true) {
|
|
269
|
-
const allowedKeys = ['status', 'error_code', 'response_format', 'summary', 'results_omitted'];
|
|
270
|
-
if (!overflow || Object.hasOwn(value, 'results') || Object.keys(value).some((key) => !allowedKeys.includes(key))) {
|
|
271
|
-
return { recognized: false };
|
|
272
|
-
}
|
|
273
|
-
return {
|
|
274
|
-
recognized: true,
|
|
275
|
-
aggregateFailed: true,
|
|
276
|
-
summary,
|
|
277
|
-
statuses: [],
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
if (Object.hasOwn(value, 'results_omitted') || !Array.isArray(value.results)) return { recognized: false };
|
|
282
|
-
const allowedKeys = overflow
|
|
283
|
-
? ['status', 'error_code', 'response_format', 'summary', 'results']
|
|
284
|
-
: ['status', 'response_format', 'summary', 'results'];
|
|
285
|
-
if (Object.keys(value).some((key) => !allowedKeys.includes(key))) return { recognized: false };
|
|
286
|
-
if (value.results.length === 0 || value.results.length > MAX_STRUCTURED_SWARM_RESULTS) return { recognized: false };
|
|
287
|
-
|
|
288
|
-
const statuses = value.results.map(parseStructuredDisplayEntry);
|
|
289
|
-
if (statuses.some((entry) => entry === null)) return { recognized: false };
|
|
290
|
-
statuses.sort((left, right) => left.index - right.index);
|
|
291
|
-
if (!statuses.every((entry, index) => entry.index === index + 1)) return { recognized: false };
|
|
292
|
-
|
|
293
|
-
const actualSummary = {
|
|
294
|
-
completed: statuses.filter((entry) => entry.status === 'completed').length,
|
|
295
|
-
failed: statuses.filter((entry) => entry.status === 'failed').length,
|
|
296
|
-
aborted: statuses.filter((entry) => entry.status === 'aborted').length,
|
|
297
|
-
};
|
|
298
|
-
if (!Object.keys(actualSummary).every((key) => actualSummary[key] === summary[key])) return { recognized: false };
|
|
299
|
-
if (!overflow && aggregateStatus(summary) !== value.status) return { recognized: false };
|
|
300
|
-
if (!overflow && value.results.some((entry) => entry.result_omitted === true)) return { recognized: false };
|
|
301
|
-
if (overflow && !value.results.every((entry) => entry.result_omitted === true)) return { recognized: false };
|
|
302
|
-
|
|
303
|
-
return {
|
|
304
|
-
recognized: true,
|
|
305
|
-
aggregateFailed: overflow,
|
|
306
|
-
summary,
|
|
307
|
-
statuses,
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
function structuredSwarmToolResult(output) {
|
|
312
|
-
const parsed = parseStructuredSwarmDisplay(output);
|
|
313
|
-
return parsed.recognized && parsed.aggregateFailed ? { output, isError: true } : { output };
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
module.exports = {
|
|
317
|
-
MAX_STRUCTURED_SWARM_OUTPUT_BYTES,
|
|
318
|
-
MAX_STRUCTURED_SWARM_FALLBACK_BYTES,
|
|
319
|
-
MAX_STRUCTURED_SWARM_RESULTS,
|
|
320
|
-
parseStructuredChildEnvelope,
|
|
321
|
-
parseStructuredSwarmDisplay,
|
|
322
|
-
renderStructuredSwarmResults,
|
|
323
|
-
renderStructuredSwarmResultsWithLimits,
|
|
324
|
-
structuredSwarmToolResult,
|
|
325
|
-
};
|